* [PATCH] lib/dma-debug.c: fix __hash_bucket_find @ 2012-10-18 15:38 Ming Lei 2012-10-18 15:53 ` Ming Lei 0 siblings, 1 reply; 4+ messages in thread From: Ming Lei @ 2012-10-18 15:38 UTC (permalink / raw) To: linux-kernel Cc: Ming Lei, Joerg Roedel, Shuah Khan, Paul Gortmaker, Andrew Morton, Jakub Kicinski If there is only one match, the unique matched entry should be returned. Without the fix, the commit f62566214fe31c9f9b3218a42f1b19e6a9e6844a dma-debug: new interfaces to debug dma mapping errors can't work reliably because only device and dma_addr are passed to dma_mapping_error(). Cc: Joerg Roedel <joerg.roedel@amd.com> Cc: Shuah Khan <shuah.khan@hp.com> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jakub Kicinski <kubakici@wp.pl> Signed-off-by: Ming Lei <ming.lei@canonical.com> --- lib/dma-debug.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/dma-debug.c b/lib/dma-debug.c index 94aa94e..be132f3 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c @@ -283,6 +283,10 @@ static struct dma_debug_entry *__hash_bucket_find(struct hash_bucket *bucket, if (!match(ref, entry)) continue; + /* record the first match */ + if (!ret) + ret = entry; + /* * Some drivers map the same physical address multiple * times. Without a hardware IOMMU this results in the -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] lib/dma-debug.c: fix __hash_bucket_find 2012-10-18 15:38 [PATCH] lib/dma-debug.c: fix __hash_bucket_find Ming Lei @ 2012-10-18 15:53 ` Ming Lei 2012-10-18 17:20 ` Shuah Khan 0 siblings, 1 reply; 4+ messages in thread From: Ming Lei @ 2012-10-18 15:53 UTC (permalink / raw) To: linux-kernel Cc: Ming Lei, Joerg Roedel, Shuah Khan, Paul Gortmaker, Andrew Morton, Jakub Kicinski Hi, Below v1 should be more efficient and simper, sorry for the noise. Thanks, -- Ming Lei -- >From d275d195794ff80e018145f2fae714b35ddc49e2 Mon Sep 17 00:00:00 2001 From: Ming Lei <ming.lei@canonical.com> Date: Thu, 18 Oct 2012 23:30:57 +0800 Subject: [PATCH v1] lib/dma-debug.c: fix __hash_bucket_find If there is only one match, the unique matched entry should be returned. Without the fix, the commit f62566214fe31c9f9b3218a42f1b19e6a9e6844a dma-debug: new interfaces to debug dma mapping errors can't work reliably because only device and dma_addr are passed to dma_mapping_error(). Cc: Joerg Roedel <joerg.roedel@amd.com> Cc: Shuah Khan <shuah.khan@hp.com> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jakub Kicinski <kubakici@wp.pl> Signed-off-by: Ming Lei <ming.lei@canonical.com> --- lib/dma-debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dma-debug.c b/lib/dma-debug.c index 94aa94e..59f4a1a 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c @@ -277,7 +277,7 @@ static struct dma_debug_entry *__hash_bucket_find(struct hash_bucket *bucket, match_fn match) { struct dma_debug_entry *entry, *ret = NULL; - int matches = 0, match_lvl, last_lvl = 0; + int matches = 0, match_lvl, last_lvl = -1; list_for_each_entry(entry, &bucket->list, list) { if (!match(ref, entry)) @@ -306,7 +306,7 @@ static struct dma_debug_entry *__hash_bucket_find(struct hash_bucket *bucket, } else if (match_lvl > last_lvl) { /* * We found an entry that fits better then the - * previous one + * previous one or it is the 1st match. */ last_lvl = match_lvl; ret = entry; -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] lib/dma-debug.c: fix __hash_bucket_find 2012-10-18 15:53 ` Ming Lei @ 2012-10-18 17:20 ` Shuah Khan 2012-10-19 1:13 ` Ming Lei 0 siblings, 1 reply; 4+ messages in thread From: Shuah Khan @ 2012-10-18 17:20 UTC (permalink / raw) To: Ming Lei, Fengguang Wu Cc: linux-kernel, Joerg Roedel, Paul Gortmaker, Andrew Morton, Jakub Kicinski, shuahkhan On Thu, 2012-10-18 at 23:53 +0800, Ming Lei wrote: > Hi, > > Below v1 should be more efficient and simper, sorry for the noise. > > > Thanks, > -- > Ming Lei > > -- > From d275d195794ff80e018145f2fae714b35ddc49e2 Mon Sep 17 00:00:00 2001 > From: Ming Lei <ming.lei@canonical.com> > Date: Thu, 18 Oct 2012 23:30:57 +0800 > Subject: [PATCH v1] lib/dma-debug.c: fix __hash_bucket_find > > If there is only one match, the unique matched entry should be returned. > > Without the fix, the commit f62566214fe31c9f9b3218a42f1b19e6a9e6844a > > dma-debug: new interfaces to debug dma mapping errors > > can't work reliably because only device and dma_addr are passed to > dma_mapping_error(). > > Cc: Joerg Roedel <joerg.roedel@amd.com> > Cc: Shuah Khan <shuah.khan@hp.com> > Cc: Paul Gortmaker <paul.gortmaker@windriver.com> > Cc: Andrew Morton <akpm@linux-foundation.org> > Cc: Jakub Kicinski <kubakici@wp.pl> > Signed-off-by: Ming Lei <ming.lei@canonical.com> > --- > lib/dma-debug.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/dma-debug.c b/lib/dma-debug.c > index 94aa94e..59f4a1a 100644 > --- a/lib/dma-debug.c > +++ b/lib/dma-debug.c > @@ -277,7 +277,7 @@ static struct dma_debug_entry > *__hash_bucket_find(struct hash_bucket *bucket, > match_fn match) > { > struct dma_debug_entry *entry, *ret = NULL; > - int matches = 0, match_lvl, last_lvl = 0; > + int matches = 0, match_lvl, last_lvl = -1; > > list_for_each_entry(entry, &bucket->list, list) { > if (!match(ref, entry)) > @@ -306,7 +306,7 @@ static struct dma_debug_entry > *__hash_bucket_find(struct hash_bucket *bucket, > } else if (match_lvl > last_lvl) { > /* > * We found an entry that fits better then the > - * previous one > + * previous one or it is the 1st match. > */ > last_lvl = match_lvl; > ret = entry; Thanks for finding and fixing the problem. This fixes the problem Fengguang Wu reported: adding him to the thread. https://lkml.org/lkml/2012/10/14/233 I have a reliable test case and test system that reproduces the problem. Re-tested it with and without patch and didn't see the warning with your patch. That said, this patch is malformed and didn't apply cleanly. You have my Tested-by: Shuah Khan <shuah.khan@hp.com> Thanks, -- Shuah ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] lib/dma-debug.c: fix __hash_bucket_find 2012-10-18 17:20 ` Shuah Khan @ 2012-10-19 1:13 ` Ming Lei 0 siblings, 0 replies; 4+ messages in thread From: Ming Lei @ 2012-10-19 1:13 UTC (permalink / raw) To: shuah.khan Cc: Fengguang Wu, linux-kernel, Joerg Roedel, Paul Gortmaker, Andrew Morton, Jakub Kicinski, shuahkhan On Fri, Oct 19, 2012 at 1:20 AM, Shuah Khan <shuah.khan@hp.com> wrote: > Thanks for finding and fixing the problem. This fixes the problem > Fengguang Wu reported: adding him to the thread. > > https://lkml.org/lkml/2012/10/14/233 > > I have a reliable test case and test system that reproduces the problem. > Re-tested it with and without patch and didn't see the warning with your > patch. > > That said, this patch is malformed and didn't apply cleanly. > You have my > > Tested-by: Shuah Khan <shuah.khan@hp.com> OK, I will submit it again for merge. Thanks, -- Ming Lei ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-10-19 1:13 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-10-18 15:38 [PATCH] lib/dma-debug.c: fix __hash_bucket_find Ming Lei 2012-10-18 15:53 ` Ming Lei 2012-10-18 17:20 ` Shuah Khan 2012-10-19 1:13 ` Ming Lei
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox