Skip to content

Commit 3872731

Browse files
aikmpe
authored andcommitted
powerps/pseries/dma: Add support for 2M IOMMU page size
The upcoming PAPR spec adds a 2M page size, bit 23 right after 16G page size in the "ibm,query-pe-dma-window" call. This adds support for the new page size. Since the new page size is out of sorted order, this changes the loop to not assume that shift[] is sorted. This has now been tested and is known to work on a pre-release version of phyp. Signed-off-by: Alexey Kardashevskiy <[email protected]> Reviewed-by: Leonardo Bras <[email protected]> Reviewed-by: Frederic Barrat <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e4e737b commit 3872731

File tree

1 file changed

+5
-5
lines changed
  • arch/powerpc/platforms/pseries

1 file changed

+5
-5
lines changed

arch/powerpc/platforms/pseries/iommu.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,14 +1159,15 @@ static void reset_dma_window(struct pci_dev *dev, struct device_node *par_dn)
11591159
/* Return largest page shift based on "IO Page Sizes" output of ibm,query-pe-dma-window. */
11601160
static int iommu_get_page_shift(u32 query_page_size)
11611161
{
1162-
/* Supported IO page-sizes according to LoPAR */
1162+
/* Supported IO page-sizes according to LoPAR, note that 2M is out of order */
11631163
const int shift[] = {
11641164
__builtin_ctzll(SZ_4K), __builtin_ctzll(SZ_64K), __builtin_ctzll(SZ_16M),
11651165
__builtin_ctzll(SZ_32M), __builtin_ctzll(SZ_64M), __builtin_ctzll(SZ_128M),
1166-
__builtin_ctzll(SZ_256M), __builtin_ctzll(SZ_16G)
1166+
__builtin_ctzll(SZ_256M), __builtin_ctzll(SZ_16G), __builtin_ctzll(SZ_2M)
11671167
};
11681168

11691169
int i = ARRAY_SIZE(shift) - 1;
1170+
int ret = 0;
11701171

11711172
/*
11721173
* On LoPAR, ibm,query-pe-dma-window outputs "IO Page Sizes" using a bit field:
@@ -1176,11 +1177,10 @@ static int iommu_get_page_shift(u32 query_page_size)
11761177
*/
11771178
for (; i >= 0 ; i--) {
11781179
if (query_page_size & (1 << i))
1179-
return shift[i];
1180+
ret = max(ret, shift[i]);
11801181
}
11811182

1182-
/* No valid page size found. */
1183-
return 0;
1183+
return ret;
11841184
}
11851185

11861186
static struct property *ddw_property_create(const char *propname, u32 liobn, u64 dma_addr,

0 commit comments

Comments
 (0)