From: "Roedel, Joerg" <Joerg.Roedel@amd.com>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Divy LeRay <divy@chelsio.com>,
Stanislaw Gruszka <sgruszka@redhat.com>,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH] dma-debug: hash_bucket_find needs to allow for offsets within an entry
Date: Wed, 20 Jul 2011 12:38:13 +0200 [thread overview]
Message-ID: <20110720103813.GL15108@amd.com> (raw)
In-Reply-To: <1311097278-30841-1-git-send-email-nhorman@tuxdriver.com>
Hi Neil,
thanks for your work on this :)
On Tue, Jul 19, 2011 at 01:41:18PM -0400, Neil Horman wrote:
> lib/dma-debug.c | 17 +++++++++++++++--
> 1 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/lib/dma-debug.c b/lib/dma-debug.c
> index db07bfd..333f0ee 100644
> --- a/lib/dma-debug.c
> +++ b/lib/dma-debug.c
> @@ -248,10 +248,23 @@ static struct dma_debug_entry *hash_bucket_find(struct hash_bucket *bucket,
> {
> struct dma_debug_entry *entry, *ret = NULL;
> int matches = 0, match_lvl, last_lvl = 0;
> + u64 estart, eend, rstart, rend;
> +
> + rstart = ref->dev_addr;
> + rend = rstart + ref->size;
>
> list_for_each_entry(entry, &bucket->list, list) {
> - if ((entry->dev_addr != ref->dev_addr) ||
> - (entry->dev != ref->dev))
> + estart = entry->dev_addr;
> + eend = estart + entry->size;
> +
> + /*
> + * An entry matches if the address range specified by the ref
> + * dev_addr and size falls entirely within the range specified
> + * by the entries dev_addr and size and the devices match
> + */
> + if (entry->dev != ref->dev)
> + continue;
> + if ((estart > rstart) || (eend < rend))
> continue;
>
> /*
But it is not that easy. The hash_fn works on the dev_addr, this means
to search all entries which might match you need to scan multiple
hash-buckets potentially.
In fact, you need to scan
hash_fn(estart) <= idx <= hash_fn(eend)
to be sure. The patch above also lifts up the check_unmap which is not
desired.
Thanks,
Joerg
--
AMD Operating System Research Center
Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
next prev parent reply other threads:[~2011-07-20 10:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-19 17:41 [PATCH] dma-debug: hash_bucket_find needs to allow for offsets within an entry Neil Horman
2011-07-20 10:38 ` Roedel, Joerg [this message]
2011-07-20 11:11 ` Neil Horman
2011-07-20 13:29 ` Roedel, Joerg
2011-07-20 14:32 ` Neil Horman
2011-07-20 14:59 ` Roedel, Joerg
2011-07-20 15:12 ` Neil Horman
2011-08-08 19:13 ` [PATCH] dma-debug: hash_bucket_find needs to allow for offsets within an entry (v2) Neil Horman
2011-08-10 13:31 ` Roedel, Joerg
2011-08-10 14:47 ` Neil Horman
2011-08-22 10:46 ` Neil Horman
2011-08-22 12:44 ` Roedel, Joerg
2011-08-22 13:20 ` Neil Horman
2011-08-22 16:46 ` Roedel, Joerg
2011-08-22 17:23 ` Neil Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110720103813.GL15108@amd.com \
--to=joerg.roedel@amd.com \
--cc=arnd@arndb.de \
--cc=divy@chelsio.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=sgruszka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox