From nobody Sat Apr 11 05:10:36 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CD50C25B0D for ; Mon, 15 Aug 2022 16:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232165AbiHOQRo (ORCPT ); Mon, 15 Aug 2022 12:17:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231135AbiHOQQE (ORCPT ); Mon, 15 Aug 2022 12:16:04 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4AD94EE00 for ; Mon, 15 Aug 2022 09:16:03 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C3B691063; Mon, 15 Aug 2022 09:16:03 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 19D003F70D; Mon, 15 Aug 2022 09:16:01 -0700 (PDT) From: Robin Murphy To: will@kernel.org Cc: joro@8bytes.org, iommu@lists.linux.dev, subkhankulov@ispras.ru, khoroshilov@ispras.ru, linux-kernel@vger.kernel.org Subject: [PATCH] iommu/io-pgtable-arm: Remove iommu_dev==NULL special case Date: Mon, 15 Aug 2022 17:15:55 +0100 Message-Id: X-Mailer: git-send-email 2.36.1.dirty MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The special case to allow iommu_dev=3D=3DNULL 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 Signed-off-by: Robin Murphy --- 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; =20 VM_BUG_ON((gfp & __GFP_HIGHMEM)); - p =3D alloc_pages_node(dev ? dev_to_node(dev) : NUMA_NO_NODE, - gfp | __GFP_ZERO, order); + p =3D alloc_pages_node(dev_to_node(dev), gfp | __GFP_ZERO, order); if (!p) return NULL; =20 @@ -1343,12 +1342,17 @@ static int __init arm_lpae_do_selftests(void) }; =20 int i, j, pass =3D 0, fail =3D 0; + struct device dev; struct io_pgtable_cfg cfg =3D { .tlb =3D &dummy_tlb_ops, .oas =3D 48, .coherent_walk =3D true, + .iommu_dev =3D &dev, }; =20 + /* __arm_lpae_alloc_pages() merely needs dev_to_node() to work */ + set_dev_node(&dev, NUMA_NO_NODE); + for (i =3D 0; i < ARRAY_SIZE(pgsize); ++i) { for (j =3D 0; j < ARRAY_SIZE(ias); ++j) { cfg.pgsize_bitmap =3D pgsize[i]; --=20 2.36.1.dirty