dma-debug: change hash_bucket_find from first-fit to best-fit
dma-debug: change hash_bucket_find from first-fit to best-fit

Some device drivers map the same physical address multiple times to a
dma address. Without an IOMMU this results in the same dma address being
put into the dma-debug hash multiple times. With a first-fit match in
hash_bucket_find() this function may return the wrong dma_debug_entry.

This can result in false positive warnings. This patch fixes it by
changing the first-fit behavior of hash_bucket_find() into a best-fit
algorithm.

Reported-by: Torsten Kaiser <2b43f390e91b8ea0052cb5ea002450fcee745474@googlemail.com>
Reported-by: FUJITA Tomonori <93dac1fe9c4b2a3957982200319981492ad4976e@lab.ntt.co.jp>
Signed-off-by: Joerg Roedel <ebd221a096cbc71dd9e1991db28795933c85f380@amd.com>
Cc: 38b52dbb5f0b63d149982b6c5de788ec93a89032@linux-sh.org
Cc: 2b43f390e91b8ea0052cb5ea002450fcee745474@googlemail.com
Cc: 6cfcd53195f1aa0ac67c127c865c06914056063f@gmail.com
Cc: 165ab144a3ccfd9429d5c6466b275f24fafdb114@oracle.com
Cc: c7aa24d52dd751aba44a7843602dc14649cc8bce@panasas.com
Cc: FUJITA Tomonori <93dac1fe9c4b2a3957982200319981492ad4976e@lab.ntt.co.jp>
Cc: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>
Cc: <4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@kernel.org>
LKML-Reference: <f9ab123ba7b8181b4cced20abf363dcf80fc769b@amd.com>
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>

KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs