From patchwork Tue Apr 7 18:37:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 11478719 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71070112C for ; Tue, 7 Apr 2020 18:39:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3A45A206BE for ; Tue, 7 Apr 2020 18:39:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hFDtZpn+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A45A206BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=8bytes.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=5jmwiYKhJLNkOgEfb1PqH+GSxVt1yaB3UmjwqxwCCVU=; b=hFDtZpn+lTOg1O4Dofl4GoD7/e jaToexRIzsazvjEKcEwyILCPCJkRMzGLE0S/K5jfPBP0RzH9kuEuJbzjZr1WlwPz9df7MR1u/opmh O+Rp74nwM7hCUtO0ypFA+cRGyEJaaGsLYE0EUF8q2Xhe+QyeQRFerWu4vKzW9l74/yDE++Sl9FtEP n33wjYuvWgC6G3HcP5K8SYRlGH6Go1XGHUTuIqmZ7IgSX1jXLqpVnhrx+m+2sDDbcYHVLnngMxVIW LD5vqdm35/uUDorAT00Vu+rwkU82S/hbKPahH/HB7JOOs8A1IOiaatn4fFTgYf3fph2ldkoT0ptDJ 3fZlVpnQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLt84-0008HK-9u; Tue, 07 Apr 2020 18:39:20 +0000 Received: from 8bytes.org ([81.169.241.247] helo=theia.8bytes.org) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLt6q-0006j5-Fi; Tue, 07 Apr 2020 18:38:08 +0000 Received: by theia.8bytes.org (Postfix, from userid 1000) id E3062312; Tue, 7 Apr 2020 20:37:49 +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 Subject: [RFC PATCH 09/34] iommu: Keep a list of allocated groups in __iommu_probe_device() Date: Tue, 7 Apr 2020 20:37:17 +0200 Message-Id: <20200407183742.4344-10-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200407183742.4344-1-joro@8bytes.org> References: <20200407183742.4344-1-joro@8bytes.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200407_113804_695235_8A2C98C6 X-CRM114-Status: GOOD ( 12.41 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [81.169.241.247 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-s390@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-rockchip@lists.infradead.org, iommu@lists.linux-foundation.org, Joerg Roedel , linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org From: Joerg Roedel This is needed to defer default_domain allocation for new IOMMU groups until all devices have been added to the group. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 7a385c18e1a5..18eb3623bd00 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -44,6 +44,7 @@ struct iommu_group { int id; struct iommu_domain *default_domain; struct iommu_domain *domain; + struct list_head entry; }; struct group_device { @@ -184,7 +185,7 @@ static void dev_iommu_free(struct device *dev) dev->iommu = NULL; } -static int __iommu_probe_device(struct device *dev) +static int __iommu_probe_device(struct device *dev, struct list_head *group_list) { const struct iommu_ops *ops = dev->bus->iommu_ops; struct iommu_device *iommu_dev; @@ -204,6 +205,9 @@ static int __iommu_probe_device(struct device *dev) } iommu_group_put(group); + if (group_list && !group->default_domain && list_empty(&group->entry)) + list_add_tail(&group->entry, group_list); + iommu_device_link(iommu_dev, dev); return 0; @@ -234,7 +238,7 @@ int iommu_probe_device(struct device *dev) if (ops->probe_device) { struct iommu_group *group; - ret = __iommu_probe_device(dev); + ret = __iommu_probe_device(dev, NULL); /* * Try to allocate a default domain - needs support from the @@ -567,6 +571,7 @@ struct iommu_group *iommu_group_alloc(void) group->kobj.kset = iommu_group_kset; mutex_init(&group->mutex); INIT_LIST_HEAD(&group->devices); + INIT_LIST_HEAD(&group->entry); BLOCKING_INIT_NOTIFIER_HEAD(&group->notifier); ret = ida_simple_get(&iommu_group_ida, 0, 0, GFP_KERNEL);