Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1911022lqp; Tue, 16 Apr 2024 01:09:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVmWrNVjshHTCOk/NUWwsDPXY987+mGBdEnHsCE37AggU/QnA64vIBk9290UMWvYUKCftqe2IVFC6SryiX9cm5cWjl6y8K719K8CrLD2g== X-Google-Smtp-Source: AGHT+IFsIsgma7u85dhqf4fNo+H1GHtGegfbfb1nwWjaO+DiUpbgPAyrTxUF/pmh7C2opyDJpzBB X-Received: by 2002:ae9:e50d:0:b0:78d:7509:3321 with SMTP id w13-20020ae9e50d000000b0078d75093321mr12667183qkf.20.1713254985948; Tue, 16 Apr 2024 01:09:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713254985; cv=pass; d=google.com; s=arc-20160816; b=YT3CBgqT9fxTInHDPSPrRqr+JjssAxxS1CeG2V366q1oDXDXFi60xDxfwB9nl2B0fJ v/MkINwTUnFnU27Tgz2A5KRlyKL4cd9Rvo0zPPyxyW80FT6l3otxCoyDGUyG9CnpBd4X i5UHseokiOl5wXYopV+ogIfacouwrbJ52t0+AJJFfIQaxbWaYS6Z/PhoSdFODzvtx748 J23gMo8Ku0XS2WlcJuC/wGuWAKi1AKkABLYgHNgEV2W19CNsuHJ4NMzU/JiT7tTPWlEV c131zl1WY1//41mtY05/24LD6l85KDhRYIvZdn19Oa1QAqAj/a1P8waAQHmA9h606z/2 JszQ== 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=7almlYok4EB8hNIzFnJ+mT50IZAo9FOTYd/HVuonbqA=; fh=bewSQvuA0/GMLNkXZCY6BVvXowY1LyW/Ro23JMfVQ8s=; b=ucpd4PtojnRVW9+IiVkigUmdAO793ik6gLlSruCwldhFbnGYA5saxlikkKteaihxW6 5925TyZQCapgnHr0T17i0qlK46GMskhjr8gWVA/MJaWB4wkfuxrWUJoXMYGMUoA4nDKs xLLWAGZrg6yjA3jzJtaSUFobTFRKZ+UGZ9XTCHnkcSNNH2HFEl6YJgVNoLCTvqmQXfQ6 FnnlQtOuSjjAaYbksGNXxQdoPEi1OsqPJZb+i6cEIwCqvRlRZrlbRsWI1O2hxOGW4SaK J70856nmTFsYFNua5bIrTM7fxcMpyJvRGs47wUADJshaIjR1FM1EMSLejWqHnjfPbuBy GU8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=X8RFCUV+; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-146468-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146468-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c6-20020a05620a200600b0078da0a01a91si11594704qka.610.2024.04.16.01.09.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 01:09:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146468-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=X8RFCUV+; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-146468-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146468-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 933B21C22D0C for ; Tue, 16 Apr 2024 08:09:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A2AA15AAC9; Tue, 16 Apr 2024 08:08:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="X8RFCUV+" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 4F6F315AAA8 for ; Tue, 16 Apr 2024 08:08:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713254913; cv=none; b=rE1x61sSlDfN8S1oANxPdy1+SzbCF0fvka9wxJSzZV17xHDAERP2c4/J8FgRRn67Jc0IXOcuSfWON0BCphjkS2ZQ0Lwuk4Z3aNwWqG1Gj0Zs1I8baEXaSxktLP3PfZHZx+/ev2KPD/ZgdbmMoBU4xmi86wdUgRguZ84ixmmt+sI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713254913; c=relaxed/simple; bh=PJqJeyftw3Iz4RPiHxp7Y3vDbtVPKOGn7eAP8+TK5Hs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eTyb//S+/s65wGGvSMyqLqTwWePVi9pj4Eeb+hoQJFwS393iAenEa+pko2nAHxqqz5ttwfRkQyTyc5EX8ZSSCh80g1TjTxC0qviKk/gG7/P9qKOIzV8tsLDj9FNKUMdDvla0/r/+Uski4zOepuSBTTxA3llDaOYbapKQNedU6xE= 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=X8RFCUV+; arc=none smtp.client-ip=198.175.65.15 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=1713254912; x=1744790912; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PJqJeyftw3Iz4RPiHxp7Y3vDbtVPKOGn7eAP8+TK5Hs=; b=X8RFCUV+PBGQ1ORYu1Lcd5V+W+2Ah8ieOl3FxHOnkm6xk7J0wrsYEcW/ KuXlUUhPrpyz975aBfHnijUM6vy1K/MRUkYF2tPJYGySmrvRK+6wmbTCF IGVg+EXN0KfvjikcU0CoRDVwuKMTmCSCWAZ34vAUpBGcIN/KsLQtzwwSX N3RXaXX5o3EL8eTYHB/tmVNarf6Sub57V9Av/Kxi6n1t447+WWuCrVl4J FbNpiagJ6gBu4ISwL2A8jnSEQfSlFzDTpE2ufBJQzX2j5+v02AkQxyImo 1/aXUyjzVexPtcb7eoKfll1sazcpzZbGzScihspsjAu9CQOiuhcrOBFTH g==; X-CSE-ConnectionGUID: Sp8rtKNdRS2MgRDCNyHOdg== X-CSE-MsgGUID: QeaqirLkROCF/+HOwViVrQ== X-IronPort-AV: E=McAfee;i="6600,9927,11045"; a="12466475" X-IronPort-AV: E=Sophos;i="6.07,205,1708416000"; d="scan'208";a="12466475" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 01:08:32 -0700 X-CSE-ConnectionGUID: K1v2qB1pTqWCskoi7OblPg== X-CSE-MsgGUID: D3tiAYf5QDytCWHywEkdIw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,205,1708416000"; d="scan'208";a="22077729" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by orviesa010.jf.intel.com with ESMTP; 16 Apr 2024 01:08:30 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Kevin Tian , Jason Gunthorpe Cc: Tina Zhang , Yi Liu , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 06/12] iommu/vt-d: Use cache_tag_flush_range_np() in iotlb_sync_map Date: Tue, 16 Apr 2024 16:06:50 +0800 Message-Id: <20240416080656.60968-7-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416080656.60968-1-baolu.lu@linux.intel.com> References: <20240416080656.60968-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 iotlb_sync_map callback is called by the iommu core after non-present to present mappings are created. The iommu driver uses this callback to invalidate caches if IOMMU is working in caching mode and second-only translation is used for the domain. Use cache_tag_flush_range_np() in this callback. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 6bf5b91b03c5..c6a0d528ad19 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -1500,20 +1500,6 @@ static void iommu_flush_iotlb_psi(struct intel_iommu *iommu, iommu_flush_dev_iotlb(domain, addr, mask); } -/* Notification for newly created mappings */ -static void __mapping_notify_one(struct intel_iommu *iommu, struct dmar_domain *domain, - unsigned long pfn, unsigned int pages) -{ - /* - * It's a non-present to present mapping. Only flush if caching mode - * and second level. - */ - if (cap_caching_mode(iommu->cap) && !domain->use_first_level) - iommu_flush_iotlb_psi(iommu, domain, pfn, pages, 0, 1); - else - iommu_flush_write_buffer(iommu); -} - /* * Flush the relevant caches in nested translation if the domain * also serves as a parent @@ -4543,14 +4529,8 @@ static bool risky_device(struct pci_dev *pdev) static int intel_iommu_iotlb_sync_map(struct iommu_domain *domain, unsigned long iova, size_t size) { - struct dmar_domain *dmar_domain = to_dmar_domain(domain); - unsigned long pages = aligned_nrpages(iova, size); - unsigned long pfn = iova >> VTD_PAGE_SHIFT; - struct iommu_domain_info *info; - unsigned long i; + cache_tag_flush_range_np(to_dmar_domain(domain), iova, iova + size - 1); - xa_for_each(&dmar_domain->iommu_array, i, info) - __mapping_notify_one(info->iommu, dmar_domain, pfn, pages); return 0; } -- 2.34.1