Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp222165lqe; Tue, 9 Apr 2024 22:59:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWryiAif0jgqfd2+jyXHnU7uyKBCwd1i+RvAHcK7ypZjd8MbsjPPfg267jSOc1r5c7eipqJur6aXxDhBn/yCSwS8LrO/yrgU+jfO7Ys4g== X-Google-Smtp-Source: AGHT+IHuASX+S7NI4TXSkJm836Mu/5Ao5vJEwMCwNc+TRRF8E9ATcMxcCGcXSjsRSLFZ9o1GZoGB X-Received: by 2002:a50:c34b:0:b0:56e:2bfe:cdcd with SMTP id q11-20020a50c34b000000b0056e2bfecdcdmr1077117edb.1.1712728794558; Tue, 09 Apr 2024 22:59:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712728794; cv=pass; d=google.com; s=arc-20160816; b=sz219Yl3iCHDSck40sb3lY2CJqzpBEbgi6xnwMxXOi7ntfJvZHAhQB7UNw6uRsCgeZ JsCs1JpjsPNEbw6ycatjRDTU9biKyRrPnjSdPIe6/7ZlVuP8fV7N2/QtfKE80pHzFbhw IsfDrkxfu6upprVa66BUhg/x2q3Le4DdjC+YRW6u9Y0/6J5xNNRwgRe30D0rUevJRFxw aREx2i+P3obqgqH/77BDfzy3idwmHmt7bQw6H2TxdqyZUztf5cjfggnbV2J7E0n51eAm rJ5jGwZXD9vVy7XCvWaEbG9q27Vas9renrpps5ztf/n21db+JGfZ4yrlmxSIyW04oXSw QaEA== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=nNug/TBuHdop3K85Z/49l9uzdXlP+ngQY/ov6+Xn22Q=; fh=ajYVRJgJkDYUb+pdZFsiyAX/jgQ4YOLIHq0FyT4U3Sc=; b=Sl5hzMB1Ysf73yjg46BodkNUBAd6epcxmINmDcmirqqudJ17rZUQWjnA//CfTbxa31 DfQrSC1Wcw3O+IR/e3d3I0DEmW8YqPaOCoqCUW6UgEDPtDmDGWHI3OmvOMGDZk6YaWQe Ib0tqdih3BoiKvpw3cMzfqMbUCRitIMsZXZs9iMOgPGO50CUPWUvcSTMflVYRtW43434 5FTnvcu3lMVVdGqodhxug1K01ER4UKIsBDbAQwBB/U1Yr7bcyS72n7BxiDhRdgkbOVkn 5UKrmFJaPWcIYoHLIldV/vMO0weuVbVDMpynI5rlks/onuAw9/Sl46sL6CMRDMsv6PLk W6yw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MUOuL9HG; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-137953-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137953-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f21-20020a50d555000000b0056e3fe5f4f4si4644995edj.376.2024.04.09.22.59.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 22:59:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137953-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MUOuL9HG; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-137953-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137953-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 23B101F230D6 for ; Wed, 10 Apr 2024 05:59:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 697EC1C6AD; Wed, 10 Apr 2024 05:59:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MUOuL9HG" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.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 14953224EA for ; Wed, 10 Apr 2024 05:59:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712728781; cv=none; b=fu4MLmUm4Q1O7VNpl3lWK6Xq/5tuWb/Vp/B9tJslqQ6gfWEJTMgyj31Sc/KRSaj1WaUeYVh50NDnSJHQghdBiMnJLSLOchco+pnLQjJU/VmMBxAVWHGoNPwpmHJJ8dFfBguhkuoK1xf20vMBcj+T3rtHvpN1twP79qfPGqI7w+8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712728781; c=relaxed/simple; bh=kVXQ4bZM5bQZSi1MhboTtlK1NNrbVfyTWUnzwaNNWio=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=U3jVQ1406QQDoAuBcqyscWwN+DOa5WjwAvNnkpgRyM3rDIHOBzlCbbzwKvmsDuID6lTWbtsiMyGpGGUy/E6ZjH8jUF/edKGD1MfFZCdH4LHlRFAtdAQurzYE0099PZ6TiGhs7wtgGSENC4I6JJDA1VOFZt7Iz9+F5FIpW8ITXjc= 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=MUOuL9HG; arc=none smtp.client-ip=198.175.65.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=1712728780; x=1744264780; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=kVXQ4bZM5bQZSi1MhboTtlK1NNrbVfyTWUnzwaNNWio=; b=MUOuL9HGST2OetHbxLA59ISL13hfFq8q87lqg9XBhpveya3uMwZgp5YX UmgpxRMuBC7VPkmT0ecTdjUXCqcSoopSUQIjGqwVHDMj4CT7bcVKbMBsT 8geMinZwoAzOLsrqT5BTgeuGBuCeZCMFQzQN3WsAdGHq7MnxhXDvt8SEf KDyAXWTifjZ+eA7oBLRImYaB8+gTBGYtpoh166HTvPIKh91BcNdNS7yvd vtzbSZUUHi7tcwSLTAuVDL/TqTYhD+auwVmtDOWHygWRd2os0Xa6MvWfZ uP2xHmei+zfU/pTyBzFySlmWb8y6CLGPWorsT6fkjWqTMJmGLT7lJcaVy Q==; X-CSE-ConnectionGUID: ythGzPmCQN2MGfGzi5amUw== X-CSE-MsgGUID: w7D9zFdbQMKiGimVgbzizg== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="11913099" X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="11913099" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 22:59:39 -0700 X-CSE-ConnectionGUID: 1QT0hvkWQS6nzDJrsST11g== X-CSE-MsgGUID: jxcDG/cfSMCtYiMQw+t4cA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,190,1708416000"; d="scan'208";a="20516501" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 09 Apr 2024 22:59:38 -0700 From: Lu Baolu To: iommu@lists.linux.dev Cc: Kevin Tian , Yi Liu , Jacob Pan , Joerg Roedel , Will Deacon , Robin Murphy , linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v2 1/1] iommu/vt-d: Remove caching mode check before device TLB flush Date: Wed, 10 Apr 2024 13:58:23 +0800 Message-Id: <20240410055823.264501-1-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 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 Caching Mode (CM) of the Intel IOMMU indicates if the hardware implementation caches not-present or erroneous translation-structure entries except the first-stage translation. The caching mode is irrelevant to the device TLB , therefore there is no need to check it before a device TLB invalidation operation. iommu_flush_iotlb_psi() is called in map and unmap paths. The caching mode check before device TLB invalidation will cause device TLB invalidation always issued if IOMMU is not running in caching mode. This is wrong and causes unnecessary performance overhead. The removal of caching mode check in intel_flush_iotlb_all() doesn't impact anything no matter the IOMMU is working in caching mode or not. Commit <29b32839725f> ("iommu/vt-d: Do not use flush-queue when caching-mode is on") has already disabled flush-queue for caching mode, hence caching mode will never call intel_flush_iotlb_all(). Fixes: bf92df30df90 ("intel-iommu: Only avoid flushing device IOTLB for domain ID 0 in caching mode") Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) Change log: v2: - Squash two patches into a single one. - No functionality changes. v1: https://lore.kernel.org/linux-iommu/20240407144232.190355-1-baolu.lu@linux.intel.com/ diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 50eb9aed47cc..681789b1258d 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -1501,11 +1501,7 @@ static void iommu_flush_iotlb_psi(struct intel_iommu *iommu, else __iommu_flush_iotlb_psi(iommu, did, pfn, pages, ih); - /* - * In caching mode, changes of pages from non-present to present require - * flush. However, device IOTLB doesn't need to be flushed in this case. - */ - if (!cap_caching_mode(iommu->cap) || !map) + if (!map) iommu_flush_dev_iotlb(domain, addr, mask); } @@ -1579,8 +1575,7 @@ static void intel_flush_iotlb_all(struct iommu_domain *domain) iommu->flush.flush_iotlb(iommu, did, 0, 0, DMA_TLB_DSI_FLUSH); - if (!cap_caching_mode(iommu->cap)) - iommu_flush_dev_iotlb(dmar_domain, 0, MAX_AGAW_PFN_WIDTH); + iommu_flush_dev_iotlb(dmar_domain, 0, MAX_AGAW_PFN_WIDTH); } if (dmar_domain->nested_parent) -- 2.34.1