Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp426525lqb; Tue, 28 May 2024 22:41:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCViZcFsV84lXOOTweuaFvq8b+UIxarARcDm2k2piKi+rLieMXCWxE65RbMttFvsRK7qLC8MkN6YYKCCRX2569b+Dfq/t+7ZONxmCvybHg== X-Google-Smtp-Source: AGHT+IEiZOlQ/Akkvjs32S34saEEcSN17xUWlyvCA0X+IJnDRx3Jh1sOpGxyxNfegw0pzktufPnl X-Received: by 2002:a05:6512:3988:b0:51c:5087:909f with SMTP id 2adb3069b0e04-529646e3c01mr11928821e87.10.1716961307247; Tue, 28 May 2024 22:41:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716961307; cv=pass; d=google.com; s=arc-20160816; b=b1/mLmajhFwRauEhJNIR6CsZ/MRvixqg6x5z/dZAQ4NG3/zmqFEwY5K2mHEFRknLsA scq80/y6SIio/PUWPkAs17Crn15cBgWGKwDERocAY3pgUtgGozmDlw4PD2j3dsZJhKEi MwrOVrmC4/jLpiK9rEsITqYwaUAV+T6HbAStoYLWHqQf3U1pziTC6VD1HA3fNZj0l+aD zZYvSZ5WSHBRi9pUKqlSd9wdx5RI0BPmEpkOFEpllIJySC3338iE8J+4CGP/rVmoCazw 9BazFPWod+QdDV3iFKODCj26CCMxWt7mGEXnGlrgJ8c7+uweW/Wco9BxHaLd46UsCJbS hPLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=tMiQ7Cbw+8pcGnhVlXIcVlYoqYJYIH8S5lBhErDpHHw=; fh=u7VIfotmvhCnFPKh0R845OAh004BwcT1TGiZ1dQEGzo=; b=x9pZl3Ud2azmLlc/I8JEXQoteOJJsGUKbVQMuAhGKEg1OJsd8Cn4zHoPDUWgO2xU6b nJvpiT71rAzoMjeOBCTgR6PZzFSTjTnGnp6xZvbhP5K3ojdN94qU2umXLG6N9Bxb0oLK GSt9VGgF+CZEqx7ZW1XXXwuvqoFVaMwXHrjxPsDp49tqBwssUQ7OYDwIRjPItXfVgF0H iFZDPazUOc28ebKpaiK252mrrBfXObduky8Maoa4N44oKfsLBG93lQlyjpWV+lFTdRNH 7j48xTDIeSd27S2Wx+yzPWkmVkB3G0BW8trqQkmTeTkoZMhYKYnTd7v91N9CxwV+j0ze newQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Klis21kM; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193470-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193470-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cd8ef93si599477466b.696.2024.05.28.22.41.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 22:41:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193470-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Klis21kM; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193470-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193470-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C87B01F27575 for ; Wed, 29 May 2024 05:41:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B391E15D5BE; Wed, 29 May 2024 05:36:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Klis21kM" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D49716F271 for ; Wed, 29 May 2024 05:36:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960999; cv=none; b=Kfgk2lSrxGWzC2v//SE9d+8R6qkOcAXNyubcWR5DZeFMvbHrnSU4BBhTbomul1iEcDpbSIXqXJoIUBtP9ggGHjvR3gyj9TShGzT3C1ZAHtWm4aRPjkIwf/Svz2bkFVrLcQzxa3H9YBzTWm+eWrlVdiNOiqlVX+63lv9ilVD0gMw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960999; c=relaxed/simple; bh=5KWn8VzkwrmikfdY6Ercb38rCkbe5TmNZrNn/P2jtlY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q/SyQRR+zn5wfdhnlMc2eCxDnzH+hXTroWuHpwUj1yTvjcOjGAQPIwCJiSDL/mJmwRvVv70B4DCrCfm2huU5G8xY70sKBqtejiWe+BktAYX2MjFCJERihMLL4tdSxgoDtDylYMa8LqEzFwc97mN5bGrZSKN2yPdarx9TWyutRqs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Klis21kM; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960998; x=1748496998; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5KWn8VzkwrmikfdY6Ercb38rCkbe5TmNZrNn/P2jtlY=; b=Klis21kMJD1gQdyxf0VTTacJhvx7ZkXK4XYj7AGY3NbocKHLMhxN1pNu +Hc/MAPBsl2uNCo7ydLlU41AJw7aFYuFuQ6Rm9bLHeR6vxhR+kFXHscwa XFnP+x+3xVsldYSrWKLvP5fBnDVuPvpPWJSIpjqXk53rDJUK/z6ugRX/p ELY8SYSSp7+CIo5B34IKA1zDKBYdcjf3Ckdxi+Acu5uWMUA29gGf/T8jS Sxnx94EEjR2iQMi86BwZkV/+AncbCrSlZplqFGBASFSnXvZ1jDX7ci/uu KhBzPWgErURqQon262ZQU97SKWnS/WaeHrt3IY2DJP+R6165m/LEGvYxI Q==; X-CSE-ConnectionGUID: uh8XYyvwRVKXeAVarmJRYA== X-CSE-MsgGUID: xo7gDOEZRo26Yz1N+FympA== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13569114" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13569114" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:36:32 -0700 X-CSE-ConnectionGUID: tfyd8XLnTFavgJ6eGMD+/g== X-CSE-MsgGUID: 8sz1WYkaSFSx14UMZlVbhA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257798" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:36:27 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 19/20] iommu/vt-d: Remove domain_update_iommu_cap() Date: Wed, 29 May 2024 13:32:49 +0800 Message-Id: <20240529053250.91284-20-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The attributes of a paging domain are initialized during the allocation process, and any attempt to attach a domain that is not compatible will result in a failure. Therefore, there is no need to update the domain attributes at the time of domain attachment. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 86 +------------------------------------ 1 file changed, 2 insertions(+), 84 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index e9393f5c2c50..74e005b1c4b4 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -366,36 +366,6 @@ static bool iommu_paging_structure_coherency(struct intel_iommu *iommu) ecap_smpwc(iommu->ecap) : ecap_coherent(iommu->ecap); } -static void domain_update_iommu_coherency(struct dmar_domain *domain) -{ - struct iommu_domain_info *info; - struct dmar_drhd_unit *drhd; - struct intel_iommu *iommu; - bool found = false; - unsigned long i; - - domain->iommu_coherency = true; - xa_for_each(&domain->iommu_array, i, info) { - found = true; - if (!iommu_paging_structure_coherency(info->iommu)) { - domain->iommu_coherency = false; - break; - } - } - if (found) - return; - - /* No hardware attached; use lowest common denominator */ - rcu_read_lock(); - for_each_active_iommu(iommu, drhd) { - if (!iommu_paging_structure_coherency(iommu)) { - domain->iommu_coherency = false; - break; - } - } - rcu_read_unlock(); -} - static int domain_update_iommu_superpage(struct dmar_domain *domain, struct intel_iommu *skip) { @@ -426,29 +396,6 @@ static int domain_update_iommu_superpage(struct dmar_domain *domain, return fls(mask); } -static int domain_update_device_node(struct dmar_domain *domain) -{ - struct device_domain_info *info; - int nid = NUMA_NO_NODE; - unsigned long flags; - - spin_lock_irqsave(&domain->lock, flags); - list_for_each_entry(info, &domain->devices, link) { - /* - * There could possibly be multiple device numa nodes as devices - * within the same domain may sit behind different IOMMUs. There - * isn't perfect answer in such situation, so we select first - * come first served policy. - */ - nid = dev_to_node(info->dev); - if (nid != NUMA_NO_NODE) - break; - } - spin_unlock_irqrestore(&domain->lock, flags); - - return nid; -} - /* Return the super pagesize bitmap if supported. */ static unsigned long domain_super_pgsize_bitmap(struct dmar_domain *domain) { @@ -466,35 +413,6 @@ static unsigned long domain_super_pgsize_bitmap(struct dmar_domain *domain) return bitmap; } -/* Some capabilities may be different across iommus */ -void domain_update_iommu_cap(struct dmar_domain *domain) -{ - domain_update_iommu_coherency(domain); - domain->iommu_superpage = domain_update_iommu_superpage(domain, NULL); - - /* - * If RHSA is missing, we should default to the device numa domain - * as fall back. - */ - if (domain->nid == NUMA_NO_NODE) - domain->nid = domain_update_device_node(domain); - - /* - * First-level translation restricts the input-address to a - * canonical address (i.e., address bits 63:N have the same - * value as address bit [N-1], where N is 48-bits with 4-level - * paging and 57-bits with 5-level paging). Hence, skip bit - * [N-1]. - */ - if (domain->use_first_level) - domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw - 1); - else - domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw); - - domain->domain.pgsize_bitmap |= domain_super_pgsize_bitmap(domain); - domain_update_iotlb(domain); -} - struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus, u8 devfn, int alloc) { @@ -1589,7 +1507,7 @@ int domain_attach_iommu(struct dmar_domain *domain, struct intel_iommu *iommu) ret = xa_err(curr) ? : -EBUSY; goto err_clear; } - domain_update_iommu_cap(domain); + domain_update_iotlb(domain); spin_unlock(&iommu->lock); return 0; @@ -1615,7 +1533,7 @@ void domain_detach_iommu(struct dmar_domain *domain, struct intel_iommu *iommu) clear_bit(info->did, iommu->domain_ids); xa_erase(&domain->iommu_array, iommu->seq_id); domain->nid = NUMA_NO_NODE; - domain_update_iommu_cap(domain); + domain_update_iotlb(domain); kfree(info); } spin_unlock(&iommu->lock); -- 2.34.1