All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/io-pgtable-arm: Remove iommu_dev==NULL special case
@ 2022-08-15 16:15 Robin Murphy
  2022-09-07 12:19 ` Joerg Roedel
  0 siblings, 1 reply; 2+ messages in thread
From: Robin Murphy @ 2022-08-15 16:15 UTC (permalink / raw)
  To: will; +Cc: joro, iommu, subkhankulov, khoroshilov, linux-kernel

The special case to allow iommu_dev==NULL in __arm_lpae_alloc_pages() is
confusing to static checkers (and possibly readers in general), since
it's not obvious that that is only intended for the selftests. However
it only serves to get around the dev_to_node() call, and we can easily
fake up enough to make that work anyway, so let's simply remove this
consideration from the normal flow and punt the responsibility over to
the test harness itself.

Reported-by: Rustam Subkhankulov <subkhankulov@ispras.ru>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 drivers/iommu/io-pgtable-arm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
index 94ff319ae8ac..873a92bbd80c 100644
--- a/drivers/iommu/io-pgtable-arm.c
+++ b/drivers/iommu/io-pgtable-arm.c
@@ -200,8 +200,7 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp,
 	void *pages;
 
 	VM_BUG_ON((gfp & __GFP_HIGHMEM));
-	p = alloc_pages_node(dev ? dev_to_node(dev) : NUMA_NO_NODE,
-			     gfp | __GFP_ZERO, order);
+	p = alloc_pages_node(dev_to_node(dev), gfp | __GFP_ZERO, order);
 	if (!p)
 		return NULL;
 
@@ -1343,12 +1342,17 @@ static int __init arm_lpae_do_selftests(void)
 	};
 
 	int i, j, pass = 0, fail = 0;
+	struct device dev;
 	struct io_pgtable_cfg cfg = {
 		.tlb = &dummy_tlb_ops,
 		.oas = 48,
 		.coherent_walk = true,
+		.iommu_dev = &dev,
 	};
 
+	/* __arm_lpae_alloc_pages() merely needs dev_to_node() to work */
+	set_dev_node(&dev, NUMA_NO_NODE);
+
 	for (i = 0; i < ARRAY_SIZE(pgsize); ++i) {
 		for (j = 0; j < ARRAY_SIZE(ias); ++j) {
 			cfg.pgsize_bitmap = pgsize[i];
-- 
2.36.1.dirty


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iommu/io-pgtable-arm: Remove iommu_dev==NULL special case
  2022-08-15 16:15 [PATCH] iommu/io-pgtable-arm: Remove iommu_dev==NULL special case Robin Murphy
@ 2022-09-07 12:19 ` Joerg Roedel
  0 siblings, 0 replies; 2+ messages in thread
From: Joerg Roedel @ 2022-09-07 12:19 UTC (permalink / raw)
  To: Robin Murphy; +Cc: will, iommu, subkhankulov, khoroshilov, linux-kernel

On Mon, Aug 15, 2022 at 05:15:55PM +0100, Robin Murphy wrote:
> The special case to allow iommu_dev==NULL in __arm_lpae_alloc_pages() is
> confusing to static checkers (and possibly readers in general), since
> it's not obvious that that is only intended for the selftests. However
> it only serves to get around the dev_to_node() call, and we can easily
> fake up enough to make that work anyway, so let's simply remove this
> consideration from the normal flow and punt the responsibility over to
> the test harness itself.
> 
> Reported-by: Rustam Subkhankulov <subkhankulov@ispras.ru>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-07 12:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 16:15 [PATCH] iommu/io-pgtable-arm: Remove iommu_dev==NULL special case Robin Murphy
2022-09-07 12:19 ` Joerg Roedel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.