From patchwork Tue May 26 12:59:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1297979 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49WYwf2KGXz9sTH; Tue, 26 May 2020 23:00:34 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jdZC0-0003qv-Lf; Tue, 26 May 2020 13:00:28 +0000 Received: from mail-pj1-f67.google.com ([209.85.216.67]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jdZBx-0003nE-4Z for kernel-team@lists.ubuntu.com; Tue, 26 May 2020 13:00:25 +0000 Received: by mail-pj1-f67.google.com with SMTP id n15so1312134pjt.4 for ; Tue, 26 May 2020 06:00:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=89N/hCkZ06Pcn3p+O/PpS/RDqSeV50gIHsn8Q1GXELw=; b=PYz43XV8e0wRhrjhpO65d3ua2hqhVKW7xtysLsC4b9cD5Su7yTP8GMUT+dxdOVFl7x f+1a9CmTNMzwlOsuNCHVLApzPbg7IlVD/7j0x+tf8RtVhbzXpmmzyVQdzJxQyM85vyqW lscS3JQBiWx0s0VkmMjOmMbiaaaxG4x1CCDD4tlFjAkXfeDKK/rZeF/Mw505ir8zKT0Q expnAEMokUeDB6Uj+NVZ6/aMly2DRc4Dtp83ygpgvzrDoLvLHRnootcnIA7aXvl+uDej AlDhc/zGwbuBnWT7qjyq0H3+iyaAYZsxoyFQM5a8ZN7dHF5MHSkTOKwzsvtxRUiIfVwX YSig== X-Gm-Message-State: AOAM530uTSlFm2Qg442vvoroCum8aFfCIp5JC9YbVuj40T/XSd13Sncp mH+Q+S55ybTwSl7QhKoMdfBdCCmjiHU= X-Google-Smtp-Source: ABdhPJxPE9Arr8pHQ8hV8QYSHJBI42Z7zx+v+oXJh1A4u1spOGdcO3BKIfCxZdKIWbCDwnpvA/UP9Q== X-Received: by 2002:a17:902:8e88:: with SMTP id bg8mr991366plb.92.1590498022721; Tue, 26 May 2020 06:00:22 -0700 (PDT) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id a2sm15310983pfl.28.2020.05.26.06.00.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 06:00:21 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 09/42][SRU][U] UBUNTU: SAUCE: iommu: Keep a list of allocated groups in __iommu_probe_device() Date: Tue, 26 May 2020 20:59:21 +0800 Message-Id: <20200526125954.237403-10-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200526125954.237403-1-vicamo.yang@canonical.com> References: <20200526125954.237403-1-vicamo.yang@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Joerg Roedel BugLink: https://bugs.launchpad.net/bugs/1876707 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 Tested-by: Marek Szyprowski Acked-by: Marek Szyprowski Link: https://lore.kernel.org/r/20200429133712.31431-10-joro@8bytes.org Signed-off-by: Joerg Roedel (cherry picked from commit 41df6dcc0a3ff4fb654c3d969ab96ba9c4f0e796 iommu/next) Signed-off-by: You-Sheng Yang --- 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 23021e7de5d0..c9b0b7e15cf4 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 { @@ -185,7 +186,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; @@ -205,6 +206,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; @@ -235,7 +239,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 @@ -568,6 +572,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);