Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp586102ybz; Wed, 15 Apr 2020 14:35:14 -0700 (PDT) X-Google-Smtp-Source: APiQypIjsOKLjIWTZOjOcp6gJCnjKwkB0ergMlyZDlecsnlAb0tVF4+gDGEXqVyXqTZfnFGdnv++ X-Received: by 2002:aa7:d4c4:: with SMTP id t4mr27175737edr.181.1586986513943; Wed, 15 Apr 2020 14:35:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586986513; cv=none; d=google.com; s=arc-20160816; b=dNkIPMsriN0J7e9CKnlsDY9zrcekINS3OmDt46T4NAonO5+PEpiFmy3b+HVRMHbxxZ gSZilijKy8eNc10A4CtdfwHHznGs7ta1jtcfu1RIlovN+WPQUmXeWWZ+QUi3S28NPZiB MsZBbpxzNud0OvykJ3YnZoKiloZlaDRrvN3t+9gqUmcKnxwl3jcjm0CsngXrzBdB07YQ ovYIRujlSKBTZSaXZ4Nvr6qFXlzf+8J/wNEbaGzUWf6trgPJ+OSSEdqFZ90fSbFokl4i sBP3OrejsxEDd0j6eW7mYVbysBjEqArqjx2tarTgbPT68QbXMa9Pgltlw8ZdSSbFb2fW iKlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=uqLRIK+QSK18XKvyazNHH/IBUjjjZ9/JUtb+3dFxuxM=; b=TDTVBxnL+NWXbTK9vFm8VNvcHqSUWFzVZKX+bE+xzf/exkkvgauty+BwRjR4ae8COW ytR+5G9RS4Y5z+CUCRkOYZTAA4bpz/+L/GkKRaJElKFimuQIRqYlxfckbBOKLCKKffvt lk9BleXc5AMufqLTYjm9qqDsSBInJGDrT3e+RpY+yi2gtkl4AiKbvOVgLAM6d2n5fSf9 O58lAt24xep3jW03Ki4rmL1AIwHTm90cGlONkqx3OpM9RlC0ZLaC/vw06Hr56mRj2Ev4 GVPhtA6nF/S5/dQkWVAHe6vwTChmo6bDo+Eod+mpKaLL+pcTK1KrwVp9LXfngI7moQxQ Bfpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si10483584eja.417.2020.04.15.14.34.50; Wed, 15 Apr 2020 14:35:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731521AbgDNNYf (ORCPT + 99 others); Tue, 14 Apr 2020 09:24:35 -0400 Received: from 8bytes.org ([81.169.241.247]:35236 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502890AbgDNNQE (ORCPT ); Tue, 14 Apr 2020 09:16:04 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id D28195D8; Tue, 14 Apr 2020 15:15:53 +0200 (CEST) From: Joerg Roedel To: Joerg Roedel , Will Deacon , Robin Murphy , Marek Szyprowski , Kukjin Kim , Krzysztof Kozlowski , David Woodhouse , Lu Baolu , Andy Gross , Bjorn Andersson , Matthias Brugger , Rob Clark , Heiko Stuebner , Gerald Schaefer , Thierry Reding , Jonathan Hunter , Jean-Philippe Brucker Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-tegra@vger.kernel.org, virtualization@lists.linux-foundation.org, Joerg Roedel Subject: [PATCH v2 13/33] iommu: Export bus_iommu_probe() and make is safe for re-probing Date: Tue, 14 Apr 2020 15:15:22 +0200 Message-Id: <20200414131542.25608-14-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200414131542.25608-1-joro@8bytes.org> References: <20200414131542.25608-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Add a check to the bus_iommu_probe() call-path to make sure it ignores devices which have already been successfully probed. Then export the bus_iommu_probe() function so it can be used by IOMMU drivers. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 6 +++++- include/linux/iommu.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 834a45da0ed0..a2ff95424044 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1615,6 +1615,10 @@ static int probe_iommu_group(struct device *dev, void *data) if (!dev_iommu_get(dev)) return -ENOMEM; + /* Device is probed already if in a group */ + if (iommu_group_get(dev) != NULL) + return 0; + if (!try_module_get(ops->owner)) { ret = -EINVAL; goto err_free_dev_iommu; @@ -1783,7 +1787,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group) iommu_do_create_direct_mappings); } -static int bus_iommu_probe(struct bus_type *bus) +int bus_iommu_probe(struct bus_type *bus) { const struct iommu_ops *ops = bus->iommu_ops; int ret; diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 30170d191e5e..fea1622408ad 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -445,6 +445,7 @@ static inline void iommu_iotlb_gather_init(struct iommu_iotlb_gather *gather) #define IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER 6 /* Post Driver unbind */ extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops); +extern int bus_iommu_probe(struct bus_type *bus); extern bool iommu_present(struct bus_type *bus); extern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap); extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus); -- 2.17.1