From patchwork Tue May 26 13:01:31 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: 1298041 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 49WZ1Y28CTz9sRW; Tue, 26 May 2020 23:04:49 +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 1jdZG5-0006sH-Ie; Tue, 26 May 2020 13:04:41 +0000 Received: from mail-pj1-f65.google.com ([209.85.216.65]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jdZEl-0005rR-Rg for kernel-team@lists.ubuntu.com; Tue, 26 May 2020 13:03:20 +0000 Received: by mail-pj1-f65.google.com with SMTP id s69so1395824pjb.4 for ; Tue, 26 May 2020 06:03:19 -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=ZOMpoPQW/YrXA1lD4KI0Dw/+cxyj6V98hxHgBwAiSNqyMi0L7dApHV3Fhw6Lnmz7/D I0ACKZFCzbkVRs9KXO//fkZfv+vYC4l0lH6Cagg0sC32krGrhTdRHstMikAO8PI85w9R XyXq2Kr507yrkPeISXW8aTPRsQqOsKMv38fFcHPFg6kdeQtl7NI2YqftFeqT51ge7rUQ 7CBVjexNjkHKsUGZdW9GEoj0V5o93G6MNYz0U2rQc1WCwAJlOS7UBc/YgC3TS5TSWsjP PhnLwVuscYSNsHI6YqF0AQZj6HqMLfMT/aC5HZdlRLujRUMtVRPJpncG6o3ChjsaV/Hk D6Pw== X-Gm-Message-State: AOAM531rrtkryYcVO4W7XaRgIOmGHvG5pfIgYPvgY5JTYt68aKcsC4YQ Y35s5jRNnR8OyshH0YfgvlpkXxMm5jA= X-Google-Smtp-Source: ABdhPJzjllowV3dK/wmRnUPMcCa067NzsCSgBuCHbiFtReHG6+rJWsXATyG2ni5zZgN5pN87K2mxFw== X-Received: by 2002:a17:90a:ad86:: with SMTP id s6mr25885881pjq.193.1590498197180; Tue, 26 May 2020 06:03:17 -0700 (PDT) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id c21sm14907819pfo.131.2020.05.26.06.03.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 06:03:16 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 27/60][SRU][OEM-5.6] UBUNTU: SAUCE: iommu: Keep a list of allocated groups in __iommu_probe_device() Date: Tue, 26 May 2020 21:01:31 +0800 Message-Id: <20200526130204.238445-28-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200526130204.238445-1-vicamo.yang@canonical.com> References: <20200526130204.238445-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);