* Re: [patch] dma-pool: warn when coherent pool is depleted
@ 2020-06-21 21:12 Guenter Roeck
2020-06-28 4:25 ` David Rientjes via iommu
0 siblings, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2020-06-21 21:12 UTC (permalink / raw)
To: David Rientjes
Cc: Linux Kernel Mailing List, Linux IOMMU, Geert Uytterhoeven,
Robin Murphy, Christoph Hellwig
On Sun, Jun 21, 2020 at 01:43:02PM -0700, David Rientjes wrote:
> 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 <rientjes@google.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Also confirmed that coherent_pool=256k works around the crash
I had observed.
Guenter
> ---
> kernel/dma/pool.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c
> --- a/kernel/dma/pool.c
> +++ b/kernel/dma/pool.c
> @@ -239,12 +239,16 @@ void *dma_alloc_from_pool(struct device *dev, size_t size,
> }
>
> val = gen_pool_alloc(pool, size);
> - if (val) {
> + if (likely(val)) {
> phys_addr_t phys = gen_pool_virt_to_phys(pool, val);
>
> *ret_page = pfn_to_page(__phys_to_pfn(phys));
> ptr = (void *)val;
> memset(ptr, 0, size);
> + } else {
> + WARN_ONCE(1, "DMA coherent pool depleted, increase size "
> + "(recommended min coherent_pool=%zuK)\n",
> + gen_pool_size(pool) >> 9);
> }
> if (gen_pool_avail(pool) < atomic_pool_size)
> schedule_work(&atomic_pool_work);
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] dma-pool: warn when coherent pool is depleted
2020-06-21 21:12 [patch] dma-pool: warn when coherent pool is depleted Guenter Roeck
@ 2020-06-28 4:25 ` David Rientjes via iommu
2020-06-29 8:05 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: David Rientjes via iommu @ 2020-06-28 4:25 UTC (permalink / raw)
To: Guenter Roeck
Cc: Linux Kernel Mailing List, Linux IOMMU, Geert Uytterhoeven,
Robin Murphy, Christoph Hellwig
On Sun, 21 Jun 2020, Guenter Roeck wrote:
> > 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 <rientjes@google.com>
>
> Tested-by: Guenter Roeck <linux@roeck-us.net>
>
> Also confirmed that coherent_pool=256k works around the crash
> I had observed.
>
Thanks Guenter. Christoph, does it make sense to apply this patch since
there may not be an artifact left behind in the kernel log on allocation
failure by the caller?
> Guenter
>
> > ---
> > kernel/dma/pool.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c
> > --- a/kernel/dma/pool.c
> > +++ b/kernel/dma/pool.c
> > @@ -239,12 +239,16 @@ void *dma_alloc_from_pool(struct device *dev, size_t size,
> > }
> >
> > val = gen_pool_alloc(pool, size);
> > - if (val) {
> > + if (likely(val)) {
> > phys_addr_t phys = gen_pool_virt_to_phys(pool, val);
> >
> > *ret_page = pfn_to_page(__phys_to_pfn(phys));
> > ptr = (void *)val;
> > memset(ptr, 0, size);
> > + } else {
> > + WARN_ONCE(1, "DMA coherent pool depleted, increase size "
> > + "(recommended min coherent_pool=%zuK)\n",
> > + gen_pool_size(pool) >> 9);
> > }
> > if (gen_pool_avail(pool) < atomic_pool_size)
> > schedule_work(&atomic_pool_work);
>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] dma-pool: warn when coherent pool is depleted
2020-06-28 4:25 ` David Rientjes via iommu
@ 2020-06-29 8:05 ` Christoph Hellwig
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2020-06-29 8:05 UTC (permalink / raw)
To: David Rientjes
Cc: Linux Kernel Mailing List, Linux IOMMU, Geert Uytterhoeven,
Robin Murphy, Christoph Hellwig, Guenter Roeck
On Sat, Jun 27, 2020 at 09:25:21PM -0700, David Rientjes wrote:
> Thanks Guenter. Christoph, does it make sense to apply this patch since
> there may not be an artifact left behind in the kernel log on allocation
> failure by the caller?
Sorry, this fell through the cracks. I've added it to the dma-mapping
tree now.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 4+ messages in thread
* [patch] dma-pool: warn when coherent pool is depleted
@ 2020-06-21 20:43 David Rientjes via iommu
0 siblings, 0 replies; 4+ messages in thread
From: David Rientjes via iommu @ 2020-06-21 20:43 UTC (permalink / raw)
To: Christoph Hellwig, Guenter Roeck
Cc: Robin Murphy, Linux IOMMU, Geert Uytterhoeven, Linux Kernel Mailing List
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 <rientjes@google.com>
---
kernel/dma/pool.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c
--- a/kernel/dma/pool.c
+++ b/kernel/dma/pool.c
@@ -239,12 +239,16 @@ void *dma_alloc_from_pool(struct device *dev, size_t size,
}
val = gen_pool_alloc(pool, size);
- if (val) {
+ if (likely(val)) {
phys_addr_t phys = gen_pool_virt_to_phys(pool, val);
*ret_page = pfn_to_page(__phys_to_pfn(phys));
ptr = (void *)val;
memset(ptr, 0, size);
+ } else {
+ WARN_ONCE(1, "DMA coherent pool depleted, increase size "
+ "(recommended min coherent_pool=%zuK)\n",
+ gen_pool_size(pool) >> 9);
}
if (gen_pool_avail(pool) < atomic_pool_size)
schedule_work(&atomic_pool_work);
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-29 8:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-21 21:12 [patch] dma-pool: warn when coherent pool is depleted Guenter Roeck
2020-06-28 4:25 ` David Rientjes via iommu
2020-06-29 8:05 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2020-06-21 20:43 David Rientjes via iommu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).