Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp1999369lfo; Sat, 28 May 2022 13:17:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgdW1tqy5rKav2Ao9P236bkHXbSSe5Zzjgm06Xuti77kQH+3TsugW/RYGorcOXfdXXk9SN X-Received: by 2002:a65:604a:0:b0:3f9:f423:b474 with SMTP id a10-20020a65604a000000b003f9f423b474mr31309865pgp.527.1653769027781; Sat, 28 May 2022 13:17:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653769027; cv=none; d=google.com; s=arc-20160816; b=Tp4VjZBmmvvWZGA+JwLu2ArM7KqieiSO6DSN5XqhYmz+mhNp06dqmemf3GymgyljY/ tMEoSlO7QqbyFoONwf6RSsTqgCT+VVNkZGbWFlMIPJ7ZtJZ8QycGoNFI055ZlXd35nY0 Q2uSaHx/3YOfyYAAAqA7v5Sb3XNYvlApz8rd6D7dOnxQMofDYfDoZe2pBQ7qXzzulZ7K tw3qJb/3t2+P+ud+c6YmSOeKEsZ3XYuWaEZAYSrOr5Vj7JcjUgoVCW3lkn2jcV7R6JcK ctm0mw79NBJh1yEeqmzFrqzI4T9LO7j/QTubaDtFwpYhSCJsYhaoRgETotyNckryYrue g2+Q== 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 :dkim-signature; bh=MVg1kn/o+sMAJcWcp/qHCQ6hEDFK7HHN1yL73MsYyaY=; b=zo+B9UiwB97nDXEwEBmMFIPbdyptziU6wdh2LaQwv7OzPUbk2aXPuvbUkjHMRgBALi FdQw0ztE4eeq0FbcesnfzARt5NaCoDDY7AJKq2CCsikh8AbRX59+WX/BxqLjVIqbxNVP 1GG0dcsEFcJ0s0u5fs+On3hjLU4pZWjzrjoASwR+B0FJuYTH+GvuXflv65X6QfPGKPIa 0ZZjEdUI20VXLoddtYkyjUcVlsboHE0Q1OzUHm6sIhH8ATpI3vRydUUMpq2bQ2hCk+e0 Sj9J1XaDPg8c4EgCbN+zRLBK/YJos8FbvqKJ51z1Op2Mr/dUf8Kd5TCcPoRlLb5UzCiS VmAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YtEVqM4c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j4-20020a056a00130400b005108b38be1csi10492076pfu.80.2022.05.28.13.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:17:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YtEVqM4c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7752A14E2C9; Sat, 28 May 2022 12:27:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343746AbiE0Geo (ORCPT + 99 others); Fri, 27 May 2022 02:34:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343519AbiE0GeS (ORCPT ); Fri, 27 May 2022 02:34:18 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E37465DBC1 for ; Thu, 26 May 2022 23:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653633248; x=1685169248; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vF3YcioRJVDwsDBVRvKtz+aDKrq2pdrUnoBxeCNvyro=; b=YtEVqM4c4p2+yqf8NwWwqxVQaWZke/3dPDHUQhajvRRg1vIe6hAy/swx bpAXkUcmh/6o9yMGTfbXGtkEjNq9vwACoBfxb9LQ9JSQsiXpRnnttmwJ6 RAsvQIoYfXkFuEMwfW6kY11B0cfSN7ZNB5qS4aEq3pEWSZ46759WMZ3CH VOhP8GnAhGXW6ypIKNqMpymQCCJFZOeObb0iVs3a0nKsaJz/i3llov4av +CtbtSnv+1t5WqtwEK+MlqfVwomafXvwKOHt8QSi5t8/qFqyuLNFgw+TG 0LgBtuBFml8sBBmiU5gyeE7jO0vGkbsjRkR5tG9bFHWQGHwRaZGhKJVKu A==; X-IronPort-AV: E=McAfee;i="6400,9594,10359"; a="335044857" X-IronPort-AV: E=Sophos;i="5.91,254,1647327600"; d="scan'208";a="335044857" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2022 23:34:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,254,1647327600"; d="scan'208";a="718688435" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga001.fm.intel.com with ESMTP; 26 May 2022 23:34:05 -0700 From: Lu Baolu To: Joerg Roedel , Kevin Tian , Ashok Raj , Christoph Hellwig , Jason Gunthorpe Cc: Will Deacon , Robin Murphy , Liu Yi L , Jacob jun Pan , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 04/12] iommu/vt-d: Use pci_get_domain_bus_and_slot() in pgtable_walk() Date: Fri, 27 May 2022 14:30:11 +0800 Message-Id: <20220527063019.3112905-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220527063019.3112905-1-baolu.lu@linux.intel.com> References: <20220527063019.3112905-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Use pci_get_domain_bus_and_slot() instead of searching the global list to retrieve the pci device pointer. This removes device_domain_list global list as there are no consumers anymore. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.h | 1 - drivers/iommu/intel/iommu.c | 33 ++++++--------------------------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h index 2f4a5b9509c0..6724703d573b 100644 --- a/drivers/iommu/intel/iommu.h +++ b/drivers/iommu/intel/iommu.h @@ -609,7 +609,6 @@ struct intel_iommu { /* PCI domain-device relationship */ struct device_domain_info { struct list_head link; /* link to domain siblings */ - struct list_head global; /* link to global list */ struct list_head table; /* link to pasid table */ u32 segment; /* PCI segment number */ u8 bus; /* PCI bus number */ diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 25d4c5200526..bbdd3417a1b1 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -131,8 +131,6 @@ static struct intel_iommu **g_iommus; static void __init check_tylersburg_isoch(void); static int rwbf_quirk; -static inline struct device_domain_info * -dmar_search_domain_by_dev_info(int segment, int bus, int devfn); /* * set to 1 to panic kernel if can't successfully enable VT-d @@ -315,7 +313,6 @@ static int iommu_skip_te_disable; #define IDENTMAP_AZALIA 4 static DEFINE_SPINLOCK(device_domain_lock); -static LIST_HEAD(device_domain_list); const struct iommu_ops intel_iommu_ops; static bool translation_pre_enabled(struct intel_iommu *iommu) @@ -845,9 +842,14 @@ static void pgtable_walk(struct intel_iommu *iommu, unsigned long pfn, u8 bus, u struct device_domain_info *info; struct dma_pte *parent, *pte; struct dmar_domain *domain; + struct pci_dev *pdev; int offset, level; - info = dmar_search_domain_by_dev_info(iommu->segment, bus, devfn); + pdev = pci_get_domain_bus_and_slot(iommu->segment, bus, devfn); + if (!pdev) + return; + + info = dev_iommu_priv_get(&pdev->dev); if (!info || !info->domain) { pr_info("device [%02x:%02x.%d] not probed\n", bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); @@ -2348,19 +2350,6 @@ static void domain_remove_dev_info(struct dmar_domain *domain) spin_unlock_irqrestore(&device_domain_lock, flags); } -static inline struct device_domain_info * -dmar_search_domain_by_dev_info(int segment, int bus, int devfn) -{ - struct device_domain_info *info; - - list_for_each_entry(info, &device_domain_list, global) - if (info->segment == segment && info->bus == bus && - info->devfn == devfn) - return info; - - return NULL; -} - static int domain_setup_first_level(struct intel_iommu *iommu, struct dmar_domain *domain, struct device *dev, @@ -4564,7 +4553,6 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev) struct pci_dev *pdev = dev_is_pci(dev) ? to_pci_dev(dev) : NULL; struct device_domain_info *info; struct intel_iommu *iommu; - unsigned long flags; u8 bus, devfn; iommu = device_to_iommu(dev, &bus, &devfn); @@ -4607,10 +4595,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev) } } - spin_lock_irqsave(&device_domain_lock, flags); - list_add(&info->global, &device_domain_list); dev_iommu_priv_set(dev, info); - spin_unlock_irqrestore(&device_domain_lock, flags); return &iommu->iommu; } @@ -4618,15 +4603,9 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev) static void intel_iommu_release_device(struct device *dev) { struct device_domain_info *info = dev_iommu_priv_get(dev); - unsigned long flags; dmar_remove_one_dev_info(dev); - - spin_lock_irqsave(&device_domain_lock, flags); dev_iommu_priv_set(dev, NULL); - list_del(&info->global); - spin_unlock_irqrestore(&device_domain_lock, flags); - kfree(info); set_dma_ops(dev, NULL); } -- 2.25.1