<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/dma/pool.c, branch v5.8</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v5.8</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.8'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2020-07-14T13:46:32Z</updated>
<entry>
<title>dma-pool: do not allocate pool memory from CMA</title>
<updated>2020-07-14T13:46:32Z</updated>
<author>
<name>Nicolas Saenz Julienne</name>
<email>nsaenzjulienne@suse.de</email>
</author>
<published>2020-07-08T16:49:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d9765e41d8e9ea2251bf73735a2895c8bad546fc'/>
<id>urn:sha1:d9765e41d8e9ea2251bf73735a2895c8bad546fc</id>
<content type='text'>
There is no guarantee to CMA's placement, so allocating a zone specific
atomic pool from CMA might return memory from a completely different
memory zone. So stop using it.

Fixes: c84dc6e68a1d ("dma-pool: add additional coherent pools to map to gfp mask")
Reported-by: Jeremy Linton &lt;jeremy.linton@arm.com&gt;
Signed-off-by: Nicolas Saenz Julienne &lt;nsaenzjulienne@suse.de&gt;
Tested-by: Jeremy Linton &lt;jeremy.linton@arm.com&gt;
Acked-by: David Rientjes &lt;rientjes@google.com&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
<entry>
<title>dma-pool: make sure atomic pool suits device</title>
<updated>2020-07-14T13:42:33Z</updated>
<author>
<name>Nicolas Saenz Julienne</name>
<email>nsaenzjulienne@suse.de</email>
</author>
<published>2020-07-14T12:39:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=81e9d894e03f9a279102c7aac62ea7cbf9949f4b'/>
<id>urn:sha1:81e9d894e03f9a279102c7aac62ea7cbf9949f4b</id>
<content type='text'>
When allocating DMA memory from a pool, the core can only guess which
atomic pool will fit a device's constraints. If it doesn't, get a safer
atomic pool and try again.

Fixes: c84dc6e68a1d ("dma-pool: add additional coherent pools to map to gfp mask")
Reported-by: Jeremy Linton &lt;jeremy.linton@arm.com&gt;
Suggested-by: Robin Murphy &lt;robin.murphy@arm.com&gt;
Signed-off-by: Nicolas Saenz Julienne &lt;nsaenzjulienne@suse.de&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
<entry>
<title>dma-pool: introduce dma_guess_pool()</title>
<updated>2020-07-14T13:42:30Z</updated>
<author>
<name>Nicolas Saenz Julienne</name>
<email>nsaenzjulienne@suse.de</email>
</author>
<published>2020-07-14T12:39:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=48b6703858dd5526c82d8ff2dbac59acab3a9dda'/>
<id>urn:sha1:48b6703858dd5526c82d8ff2dbac59acab3a9dda</id>
<content type='text'>
dma-pool's dev_to_pool() creates the false impression that there is a
way to grantee a mapping between a device's DMA constraints and an
atomic pool. It tuns out it's just a guess, and the device might need to
use an atomic pool containing memory from a 'safer' (or lower) memory
zone.

To help mitigate this, introduce dma_guess_pool() which can be fed a
device's DMA constraints and atomic pools already known to be faulty, in
order for it to provide an better guess on which pool to use.

Signed-off-by: Nicolas Saenz Julienne &lt;nsaenzjulienne@suse.de&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
<entry>
<title>dma-pool: get rid of dma_in_atomic_pool()</title>
<updated>2020-07-14T13:42:27Z</updated>
<author>
<name>Nicolas Saenz Julienne</name>
<email>nsaenzjulienne@suse.de</email>
</author>
<published>2020-07-14T12:39:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=23e469be6239d9cf3d921fc3e38545491df56534'/>
<id>urn:sha1:23e469be6239d9cf3d921fc3e38545491df56534</id>
<content type='text'>
The function is only used once and can be simplified to a one-liner.

Signed-off-by: Nicolas Saenz Julienne &lt;nsaenzjulienne@suse.de&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
<entry>
<title>dma-mapping: warn when coherent pool is depleted</title>
<updated>2020-06-29T08:05:21Z</updated>
<author>
<name>David Rientjes</name>
<email>rientjes@google.com</email>
</author>
<published>2020-06-21T20:43:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=71cdec4fab76667dabdbb2ca232b039004ebd40f'/>
<id>urn:sha1:71cdec4fab76667dabdbb2ca232b039004ebd40f</id>
<content type='text'>
When a DMA coherent pool is depleted, allocation failures may or may not
get reported in the kernel log depending on the allocator.

The admin does have a workaround, however, by using coherent_pool= on the
kernel command line.

Provide some guidance on the failure and a recommended minimum size for
the pools (double the size).

Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
Tested-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
<entry>
<title>dma-pool: fix too large DMA pools on medium memory size systems</title>
<updated>2020-06-09T13:25:52Z</updated>
<author>
<name>Geert Uytterhoeven</name>
<email>geert@linux-m68k.org</email>
</author>
<published>2020-06-08T13:22:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3ee06a6d532f75f20528ff4d2c473cda36c484fe'/>
<id>urn:sha1:3ee06a6d532f75f20528ff4d2c473cda36c484fe</id>
<content type='text'>
On systems with at least 32 MiB, but less than 32 GiB of RAM, the DMA
memory pools are much larger than intended (e.g. 2 MiB instead of 128
KiB on a 256 MiB system).

Fix this by correcting the calculation of the number of GiBs of RAM in
the system.  Invert the order of the min/max operations, to keep on
calculating in pages until the last step, which aids readability.

Fixes: 1d659236fb43c4d2 ("dma-pool: scale the default DMA coherent pool size with memory capacity")
Signed-off-by: Geert Uytterhoeven &lt;geert@linux-m68k.org&gt;
Acked-by: David Rientjes &lt;rientjes@google.com&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
<entry>
<title>dma-pool: scale the default DMA coherent pool size with memory capacity</title>
<updated>2020-04-25T11:17:06Z</updated>
<author>
<name>David Rientjes</name>
<email>rientjes@google.com</email>
</author>
<published>2020-04-15T00:05:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1d659236fb43c4d2b37af7a4309681e834e9ec9a'/>
<id>urn:sha1:1d659236fb43c4d2b37af7a4309681e834e9ec9a</id>
<content type='text'>
When AMD memory encryption is enabled, some devices may use more than
256KB/sec from the atomic pools.  It would be more appropriate to scale
the default size based on memory capacity unless the coherent_pool
option is used on the kernel command line.

This provides a slight optimization on initial expansion and is deemed
appropriate due to the increased reliance on the atomic pools.  Note that
the default size of 128KB per pool will normally be larger than the
single coherent pool implementation since there are now up to three
coherent pools (DMA, DMA32, and kernel).

Note that even prior to this patch, coherent_pool= for sizes larger than
1 &lt;&lt; (PAGE_SHIFT + MAX_ORDER-1) can fail.  With new dynamic expansion
support, this would be trivially extensible to allow even larger initial
sizes.

Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
<entry>
<title>dma-pool: add pool sizes to debugfs</title>
<updated>2020-04-25T11:17:05Z</updated>
<author>
<name>David Rientjes</name>
<email>rientjes@google.com</email>
</author>
<published>2020-04-15T00:04:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2edc5bb3c5cc42131438460a50b7b16905c81c2a'/>
<id>urn:sha1:2edc5bb3c5cc42131438460a50b7b16905c81c2a</id>
<content type='text'>
The atomic DMA pools can dynamically expand based on non-blocking
allocations that need to use it.

Export the sizes of each of these pools, in bytes, through debugfs for
measurement.

Suggested-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
[hch: remove the !CONFIG_DEBUG_FS stubs]
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
<entry>
<title>dma-direct: atomic allocations must come from atomic coherent pools</title>
<updated>2020-04-25T11:17:05Z</updated>
<author>
<name>David Rientjes</name>
<email>rientjes@google.com</email>
</author>
<published>2020-04-15T00:04:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=76a19940bd62a81148c303f3df6d0cee9ae4b509'/>
<id>urn:sha1:76a19940bd62a81148c303f3df6d0cee9ae4b509</id>
<content type='text'>
When a device requires unencrypted memory and the context does not allow
blocking, memory must be returned from the atomic coherent pools.

This avoids the remap when CONFIG_DMA_DIRECT_REMAP is not enabled and the
config only requires CONFIG_DMA_COHERENT_POOL.  This will be used for
CONFIG_AMD_MEM_ENCRYPT in a subsequent patch.

Keep all memory in these pools unencrypted.  When set_memory_decrypted()
fails, this prohibits the memory from being added.  If adding memory to
the genpool fails, and set_memory_encrypted() subsequently fails, there
is no alternative other than leaking the memory.

Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
<entry>
<title>dma-pool: dynamically expanding atomic pools</title>
<updated>2020-04-25T11:17:02Z</updated>
<author>
<name>David Rientjes</name>
<email>rientjes@google.com</email>
</author>
<published>2020-04-20T10:09:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=54adadf9b08571fb8b11dc9d0d3a2ddd39825efd'/>
<id>urn:sha1:54adadf9b08571fb8b11dc9d0d3a2ddd39825efd</id>
<content type='text'>
When an atomic pool becomes fully depleted because it is now relied upon
for all non-blocking allocations through the DMA API, allow background
expansion of each pool by a kworker.

When an atomic pool has less than the default size of memory left, kick
off a kworker to dynamically expand the pool in the background.  The pool
is doubled in size, up to MAX_ORDER-1.  If memory cannot be allocated at
the requested order, smaller allocation(s) are attempted.

This allows the default size to be kept quite low when one or more of the
atomic pools is not used.

Allocations for lowmem should also use GFP_KERNEL for the benefits of
reclaim, so use GFP_KERNEL | GFP_DMA and GFP_KERNEL | GFP_DMA32 for
lowmem allocations.

This also allows __dma_atomic_pool_init() to return a pointer to the pool
to make initialization cleaner.

Also switch over some node ids to the more appropriate NUMA_NO_NODE.

Signed-off-by: David Rientjes &lt;rientjes@google.com&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
</feed>
