Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4713803rdb; Fri, 15 Sep 2023 10:00:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF70lN692h9ezSSO+49jSvwVgPc30e4N+l6PsXAU2qzlXq0WpJAvGwD/JVLC6lUoYiQCiXf X-Received: by 2002:a05:6a20:9192:b0:149:44d9:bbb0 with SMTP id v18-20020a056a20919200b0014944d9bbb0mr2325373pzd.43.1694797250688; Fri, 15 Sep 2023 10:00:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694797250; cv=none; d=google.com; s=arc-20160816; b=p26ISQfMxtUaX/R7gzBXjsIzKViRczPkEhwMNkxlN8Z7n0y+Oxun9WHylNtiv9I3Y3 urDmyvuAIoYBRPcJsBjUJMF7ErBiktbhwdxylX17VcE/LPzAdJfeAExFa12IyFbYZzbb raI0NZVkRO3127szaeUOP4BENpkJTv/9X7/FrgVrap8e2Auy+rEsbpc27MuOJxVfg98d zVqTPB3wsdYr69Fc/U3GkzNtFXyOvByb8W7HHTKTJdkjEAzs+CXEoGTww+namqUSIym7 ktB2ICWBkJkLCer3f1qOqV89lNtR7VdBKO2WJQkgNutm98+oF2prHXv0E9nuHeOWzG0c TavQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=U1E2pjYwkQYyhMjbP9CzGox+91wcBiGJths0GMiXitI=; fh=3SO4sBNpOFNxfB4XNpCUWqe4lDXSOQ4O5f1XEPxUZRQ=; b=A4Q70a1/Yb2FChaoMwyCV4gDbqZFBt476QqSjFKnH4rfeo8HYk1hP3aIxBUSpXlLFo qqRFJrpLbnMgmBqZ4KFSkrE1c6qGNCgtPmfxtD3lO2xFhrfU8oTrt3yy+PIf0pLDe2Wm ZpLR7Lc/tQ4BLhPvwkCFdzj3DbPI1wOydavMaiJm6v9q6q70k6FoXzE7q3t+PTMCqrXF fcnJ20PHibc8gRhiJx494csgV4bDbhMxjil3rRizskvlAgYfl92MVskMbrlxxWbtPK+b qsQg92JMIcd5V+GdcddIhXT14ejO8ik/7zL5DddeDuMVbtoJFF0ZUyL8z7MywGbUNWud HHWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id k26-20020a6568da000000b005774978dd75si3577064pgt.175.2023.09.15.10.00.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 10:00:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 474E4836E267; Fri, 15 Sep 2023 09:59:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234978AbjIOQ6n (ORCPT + 99 others); Fri, 15 Sep 2023 12:58:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234442AbjIOQ6b (ORCPT ); Fri, 15 Sep 2023 12:58:31 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5B73119BC for ; Fri, 15 Sep 2023 09:58:26 -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 5C6AC12FC; Fri, 15 Sep 2023 09:59: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 0BB753F5A1; Fri, 15 Sep 2023 09:58:24 -0700 (PDT) From: Robin Murphy To: joro@8bytes.org, will@kernel.org Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, jgg@nvidia.com, baolu.lu@linux.intel.com Subject: [PATCH v3 2/7] iommu: Decouple iommu_present() from bus ops Date: Fri, 15 Sep 2023 17:58:06 +0100 Message-Id: X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 09:59:15 -0700 (PDT) Much as I'd like to remove iommu_present(), the final remaining users are proving stubbornly difficult to clean up, so kick that can down the road and just rework it to preserve the current behaviour without depending on bus ops. Reviewed-by: Lu Baolu Reviewed-by: Jason Gunthorpe Signed-off-by: Robin Murphy --- v3: Tweak to use the ops-based check rather than group-based, to properly match the existing behaviour --- drivers/iommu/iommu.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 4566d0001cd3..2f29ee9dea64 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1907,9 +1907,24 @@ int bus_iommu_probe(const struct bus_type *bus) return 0; } +static int __iommu_present(struct device *dev, void *unused) +{ + return dev_has_iommu(dev); +} + +/** + * iommu_present() - make platform-specific assumptions about an IOMMU + * @bus: bus to check + * + * Do not use this function. You want device_iommu_mapped() instead. + * + * Return: true if some IOMMU is present for some device on the given bus. In + * general it may not be the only IOMMU, and it may not be for the device you + * are ultimately interested in. + */ bool iommu_present(const struct bus_type *bus) { - return bus->iommu_ops != NULL; + return bus_for_each_dev(bus, NULL, NULL, __iommu_present) > 0; } EXPORT_SYMBOL_GPL(iommu_present); -- 2.39.2.101.g768bb238c484.dirty