[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180910061332.28187-3-hch@lst.de>
Date: Mon, 10 Sep 2018 08:13:31 +0200
From: Christoph Hellwig <hch@....de>
To: iommu@...ts.linux-foundation.org
Cc: Marek Szyprowski <m.szyprowski@...sung.com>,
Robin Murphy <robin.murphy@....com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH 2/3] dma-mapping: simplify dma_direct get_required_mask
If we use fls64 we don't need to divide the max address into lower
and upper halves.
Signed-off-by: Christoph Hellwig <hch@....de>
---
drivers/base/platform.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index a255fc8aa483..7812b861b6da 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1185,21 +1185,9 @@ int __init platform_bus_init(void)
*/
u64 dma_direct_get_required_mask(struct device *dev)
{
- u32 low_totalram = ((max_pfn - 1) << PAGE_SHIFT);
- u32 high_totalram = ((max_pfn - 1) >> (32 - PAGE_SHIFT));
- u64 mask;
-
- if (!high_totalram) {
- /* convert to mask just covering totalram */
- low_totalram = (1 << (fls(low_totalram) - 1));
- low_totalram += low_totalram - 1;
- mask = low_totalram;
- } else {
- high_totalram = (1 << (fls(high_totalram) - 1));
- high_totalram += high_totalram - 1;
- mask = (((u64)high_totalram) << 32) + 0xffffffff;
- }
- return mask;
+ u64 end = ((max_pfn - 1) << PAGE_SHIFT);
+
+ return (1 << (fls64(end) - 1)) * 2 - 1;
}
#ifndef ARCH_HAS_DMA_GET_REQUIRED_MASK
--
2.18.0
Powered by blists - more mailing lists