Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1586246rwb; Thu, 19 Jan 2023 12:39:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXuF6hxvaWSCOkzpvezGWFUdiUMyzED+aTjWfBvq+G6T9yMQ73a0LzJGLLosYAql98j6mgWR X-Received: by 2002:a17:902:c755:b0:194:cf89:cd15 with SMTP id q21-20020a170902c75500b00194cf89cd15mr2705202plq.15.1674160741270; Thu, 19 Jan 2023 12:39:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674160741; cv=none; d=google.com; s=arc-20160816; b=JIK7hl+QOs6JnJn3V2UEI02CRumsroCHOBSwFTi5fht8Jhl8rZu1SMmo3DY86VjMu+ 98Wyv+7aCpgePXbWa1FgC9cxvPscv9TaFq97OTU9CaxqwNuNe+HBXUSYwW0O781FJDJr OxtOB3P3j5h6+X1G/nK75UQPXIqKdSVxT8ARswE8mmaMeVYvYdYPP+gB02rgtyg0GJu1 F9lokAwH758yo3489RtO+lGtYq5GB9GqHDz60/xSCLBm2JNgwmUB+nb3z+OSWS7Y25yV uzipRQPArK8rSZk/eYkyPob5RegBXIUSt8C1chpRgZ00zRJStzYZYeR4C6cESzXSACpB E5DQ== 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=Q5TlwsA784Lxz3jyBYMQbqT6OTzKspMVWlP2LfiCt7c=; b=jUNUiZM/s6DyFF2pqQ5ZD6ZCq5JG3RyFNaTLHYz6UCo7mMR2pfZdMAHPZcx5jkIMff MznoqC5VAndZoFbIbzB2h9rvyQv2wenpohx30yEUvYy3v0GhCqYEOCXi4LFV2aGlr1nj RGp1bxFvGxYPGvlc6Xi8H9LnXoXsLKtUoJV0CzIdHNAaCRUIzKnEK3CRoHJ4NO23velD yqZY0ycZb9jqkw1yRRmCiM5k6795jSRbJmYQuQe1WL3XZWp8ZdoC0g6XoglxhJeP21LP Dami9QNz5Hl3nJsXY5UiHF1fA2V7XgCeexUOHPXOdq1HPKg3g2EY0yY/A+bXI9HRH/ll uJEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t63-20020a638142000000b004cfeacfba88si7516585pgd.320.2023.01.19.12.38.55; Thu, 19 Jan 2023 12:39:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231394AbjASTUX (ORCPT + 46 others); Thu, 19 Jan 2023 14:20:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231565AbjASTUD (ORCPT ); Thu, 19 Jan 2023 14:20:03 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3752F9EE07 for ; Thu, 19 Jan 2023 11:19:11 -0800 (PST) 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 7B3E41758; Thu, 19 Jan 2023 11:19:23 -0800 (PST) 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 312DD3F67D; Thu, 19 Jan 2023 11:18:41 -0800 (PST) From: Robin Murphy To: joro@8bytes.org, will@kernel.org Cc: hch@lst.de, jgg@nvidia.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] iommu: Decouple iommu_present() from bus ops Date: Thu, 19 Jan 2023 19:18:19 +0000 Message-Id: <1fb168b22cbbb5c24162d29d2a9aca339cda2c72.1673978700.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.36.1.dirty In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Robin Murphy --- 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 b189ed345057..a77d58e1b976 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1871,9 +1871,24 @@ int bus_iommu_probe(struct bus_type *bus) return ret; } +static int __iommu_present(struct device *dev, void *unused) +{ + return device_iommu_mapped(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(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.36.1.dirty