Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1874892lqp; Mon, 15 Apr 2024 23:30:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWbRpZQID33dZ63H9fcjr6GME2jBqgm3IXicwfC9i1WpHOa7zTBDEnmRnR7hvu04ATXcUnr00f/rMiPzyRIC4fYD5zWx1GKnR0jjeXrDQ== X-Google-Smtp-Source: AGHT+IHXWi7d8DqYS2lvRXFlRaEAN9icdDankTVXWXTYwfTcvZrfXW0EkNKlwWanLuH21H3pb6Oo X-Received: by 2002:a05:622a:138b:b0:434:f229:28ca with SMTP id o11-20020a05622a138b00b00434f22928camr14826111qtk.29.1713249052043; Mon, 15 Apr 2024 23:30:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713249052; cv=pass; d=google.com; s=arc-20160816; b=BGaRwUsG7JbSrpwWPvLG16u2jBmX/MCcIcxfLss5vb3FRqxN2smNd5bzMWDD3AukLW IgokdgfbIemGYArp1M49PYZXIsyoYNh2GQy/1FVNVgqOWpD5SuC2OFd5Lg12zmb2D1Kp mC65B6vX1N/mbTwtz+ZlUD6eTX4wZKb6q5QQkp0hXkkK+Oi9JqP4BbSUB5MrNkXTHry5 NSE0JGdp21aGPreYf1QsAqBT9mt0pd+FteTqZVW08VPswHBRRzNPygahNoDCGBebn0EQ Mq5uPWl8MYAQHSPFWm3saw6X9j2t9CauQCJ+P1Kp0WD7V9GnMOWfHeGjAcibYgknlvk3 dbyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=vhZxC8CwocG0yDiQiwsFJZo+BDOkNlW4THI7mmpk7dk=; fh=bgxQTjIt/6yfcK2aNvOv4IlIBty0TGpySFm/HwcxKKg=; b=P3QuMAsuUCrCGHH786b0F+SyKnwCp02DVHFr/ZZgxytgriCtgA8vnX2vTQOfX8Q1Yr ghy/s04bfKjlTr9vfhgMeJGK5PMPJaAPB2Vfeb1AVBObWClfRDZtbRkv+GrUOXvFmfso MRXKfsky+OorWhVxfLUyd+9o74embSvxhtokKL5VnjCmm7WWzCcl6xedqHVJRMFs4Rn1 Vvi5lX+qbJXpeHKK0veWQN90h1gb59L+5byPaOX3PoU90poyp0qFuFI9UY+nePPiegQs aeR2357I0mpnfWINDmVefQF8WyZcJL7qwbs0X9oDJ00s/6USOb66KlWHvxvLAJ6wpH9T zXdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hYHN4zgq; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-146347-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146347-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. [147.75.199.223]) by mx.google.com with ESMTPS id 3-20020ac85903000000b00434ec3ddb83si11809750qty.559.2024.04.15.23.30.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 23:30:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146347-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hYHN4zgq; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-146347-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146347-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 A20B91C210D0 for ; Tue, 16 Apr 2024 06:30:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D31FF6BFCF; Tue, 16 Apr 2024 06:30:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hYHN4zgq" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 BE6671E49D for ; Tue, 16 Apr 2024 06:30:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713249047; cv=none; b=kMN0f2p+BDhNk9BBkHXyOxZi2oNQYyYwmzhymzQ0ON58Yne1HRdogp3fogoXdflwNr4weX/ZBbMhGcQvR3GxFou4ub2YjAetOo1bLU5wevmqbWrSXuAydvMUnJyWbk0WdBCSkvatK+bM7Ro8XE9qsZ6Gjp/dVftxg73Xw6V1KOc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713249047; c=relaxed/simple; bh=R8Kkn/zbvxeFSDE1FVJAO/vEL694RCGZhuBpvql9wIQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=WIp25Kn5odGip1qy99UQMzhL1dsbVwnZOv+ziwNxthN05/EAMSs7x9gFksqoPniGDu4xJY1ctmWOeWxFXCsAbpYUWUC3VCl6fsFhzNjmCTFZUHdCi7SJdsoTymYgCsNSAwEe4OAQuL1NaL8Z+N1+FWxvQTLgB6Nq24qz/XsSHLc= 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=hYHN4zgq; arc=none smtp.client-ip=198.175.65.10 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=1713249045; x=1744785045; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=R8Kkn/zbvxeFSDE1FVJAO/vEL694RCGZhuBpvql9wIQ=; b=hYHN4zgqOiYe6QUpNT0c/Vkq/0dHGOzvBcaeNePbOhlB4P9cpx1VjUWH UOxGH5ElylBXFymbcG7pM7yWUfPJZ7qO1iHIujf4gsuxmafdiYBbTgl0B Y23jfoynaAYXw9UIwdrbPv3y9BK6ZsU764GSKOO4pJGIsN21PBb+8WHRW vus0kcs2CfpX0O/dKUxQgnDvSbNvOTu9opmr/seyr+/ZwileqyyETnG3+ WuqK7dws1f90obHUYxodChwSfcrxWh5KYkcBevHmXPla4cSN4UV8667Gs thhfAo5ZviX0RCotDqugLZvAkhfNeEH/CH6zrMdF5JHRtySVsCT49BEJL g==; X-CSE-ConnectionGUID: QlmneQT7RsOj1TLwKmgYuQ== X-CSE-MsgGUID: zhPtB8rcT7OGvqBhXIaEkw== X-IronPort-AV: E=McAfee;i="6600,9927,11045"; a="26123258" X-IronPort-AV: E=Sophos;i="6.07,205,1708416000"; d="scan'208";a="26123258" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2024 23:30:45 -0700 X-CSE-ConnectionGUID: V0zIrX3ySfyAUyEdzoqDqw== X-CSE-MsgGUID: 9aVQrBdTRe6tuO+5eZnh9A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,205,1708416000"; d="scan'208";a="59606714" Received: from zhaohaif-mobl.ccr.corp.intel.com (HELO [10.255.31.180]) ([10.255.31.180]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2024 23:30:41 -0700 Message-ID: <916dbee7-5ab1-4def-91fe-546e6ab974de@linux.intel.com> Date: Tue, 16 Apr 2024 14:30:38 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/1] iommu/vt-d: Remove caching mode check before device TLB flush To: Baolu Lu , iommu@lists.linux.dev Cc: Kevin Tian , Yi Liu , Jacob Pan , Joerg Roedel , Will Deacon , Robin Murphy , linux-kernel@vger.kernel.org References: <20240415013835.9527-1-baolu.lu@linux.intel.com> <9ba0b6a2-e6c1-46de-8d30-929567952c54@linux.intel.com> From: Ethan Zhao In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 4/16/2024 10:57 AM, Baolu Lu wrote: > On 4/16/24 8:53 AM, Ethan Zhao wrote: >> On 4/15/2024 9:38 AM, Lu Baolu wrote: >>> The Caching Mode (CM) of the Intel IOMMU indicates if the hardware >>> implementation caches not-present or erroneous translation-structure >>> entries except for 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. >>> >>> Remove two caching mode checks before device TLB invalidation in the >>> driver. The removal of these checks doesn't change the driver's >>> behavior >>> in critical map/unmap paths. Hence, there is no functionality or >>> performance impact, especially since commit <29b32839725f> >>> ("iommu/vt-d: >>> Do not use flush-queue when caching-mode is on") has already disabled >>> flush-queue for caching mode. Therefore, caching mode will never call >>> intel_flush_iotlb_all(). >>> >>> Signed-off-by: Lu Baolu >>> Reviewed-by: Kevin Tian >>> --- >>>   drivers/iommu/intel/iommu.c | 9 ++------- >>>   1 file changed, 2 insertions(+), 7 deletions(-) >>> >>> Change log: >>> v3: >>>   - It turned out that the removals don't change the driver's behavior, >>>     hence change it from a fix patch to a cleanup one. >>>   - No functionality changes. >>> v2: >>> https://lore.kernel.org/lkml/20240410055823.264501-1-baolu.lu@linux.intel.com/ >>>   - 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 a7ecd90303dc..f0a67e9d9faf 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); >>>   } >> >> Given devTLB flushing is irrelavent to CM, put iommu_flush_dev_iotlb() >> in iommu_flush_iotlb_psi() and called with CM checking context is not >> reasonable. the logic is buggy. >> >> 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); >> >> >> then how about fold all CM checking logic in iommu_flush_iotlb_psi() >> or speperate iommu_flush_dev_iotlb() from iommu_flush_iotlb_psi() ? > > I am refactoring the code with a new series. > > https://lore.kernel.org/linux-iommu/20240410020844.253535-1-baolu.lu@linux.intel.com/ > Great, thx. > > Best regards, > baolu