From patchwork Fri Jun 16 08:10:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yanfei Xu X-Patchwork-Id: 108927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1171647vqr; Fri, 16 Jun 2023 01:28:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5LxAlERgVw8rXC3QlCbtPHS3zIDNWWCIwxpb6V13sfkmUusXCm+wELRgaGqinAbJ0EVyl5 X-Received: by 2002:a05:6214:260f:b0:628:474b:aaef with SMTP id gu15-20020a056214260f00b00628474baaefmr1930217qvb.25.1686904113269; Fri, 16 Jun 2023 01:28:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686904113; cv=none; d=google.com; s=arc-20160816; b=rdXsfMd7SxGCfihYFGcRudRJlEK2uBEEQ07qKyBGd/1mbIKDLdsAYe7qiGOuA4/6l/ 76w5x2Dg+AKltO0CVjonrXLgujYsQibLhAzAryiXPOFbE4elzSTaMDuC1gd3yiRvYs0o qnC41gZDbWTabLDzuzgbJ00+YRve+miOlESPJQF/g18qAZabc2YAC2ia4LvoxYJoPrni RuOmBaRifpHwI62CjPSR77mnWg2Pjw0mMW7KkEMRgQpdaFg3/7kJnMRGSIYn6xF2DxFe oMf5p7C0AxDqLKJH+LYP/BQnG6aBYGn71pCf4DfCn/U/m6bRwzpL3+cukT2WVkXh68aG bdBA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=4OtzIMDtEB8RzmxhYMDke5FT++Hz2qsZRJ7GNYlt4/M=; b=hGhuppJvsIFIpVlon5mrJJ6PvPrNYVeoeKDFVfcoUeTShoaU9pDZVMZBuiAc7/HCVx QvHMqwYhEoknGJvmaLH0WJ7h+qPp6TxI4cOw/Ut5xMyEcLzjPwsmTO+n4Ot7h+obpuXY 4loB62sHG8fOBBghvLOMVYO3sUaW7rgJ+l1c1/6hagIgFKmpA21aGIIqaLKi+rWobJ7W Wg5720l7UKBSRmJ3gXm5zPMb1tii5XxOs2PZbCy1h/+XTjeMDun9ib+t7AbEQF/pgj0w 2oBffds14vyAW3FbxZ9hRkViDIMvSV9/DceUeMlzciIbDuwNALQKzJkpkIoa9LW01VhO 817Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q9fhaTqg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o14-20020a63920e000000b0053578f3de77si14374640pgd.239.2023.06.16.01.28.21; Fri, 16 Jun 2023 01:28:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q9fhaTqg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244919AbjFPIN2 (ORCPT + 99 others); Fri, 16 Jun 2023 04:13:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242564AbjFPIN0 (ORCPT ); Fri, 16 Jun 2023 04:13:26 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CCD22962 for ; Fri, 16 Jun 2023 01:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686903206; x=1718439206; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=6ItNP+JKSJICj4eyo+r6suaHTPScQyJ1JFtXO/FOP/0=; b=Q9fhaTqgipqVwUG3xsWDKuT9eKdmAR2EyYTO5s0opmgC/gFnkrIhzQax s045mqUZtE1eEuYB2PDywTsRFVgNRUd3pPC4p+0W7ygcRzAX/AdBbzDOV KF9ofTRhcBRk7OIhluzYaDa8VSc1DrjxpVc99nnK/A1Clct0aiA/gTurE f3mq58Knrafs2jz4ZOQZLYAx0PVjZB+oRSdPodow+awEnJCJHYJl0fWR7 DkEgln4UqH1+cI+I+8Jys1ckaKYlztguZmI2J+OwW+VgN9PPtlkg6Khw8 BnCOj+4ZDTTV40ovy6vFb3krSmBWpgd5p/N+ka7X8tm+ceglcQlNlLJp3 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="343898449" X-IronPort-AV: E=Sophos;i="6.00,247,1681196400"; d="scan'208";a="343898449" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2023 01:13:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="959538546" X-IronPort-AV: E=Sophos;i="6.00,247,1681196400"; d="scan'208";a="959538546" Received: from tower.bj.intel.com ([10.238.157.62]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2023 01:13:21 -0700 From: Yanfei Xu To: dwmw2@infradead.org, baolu.lu@linux.intel.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, tina.zhang@intel.com Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, yanfei.xu@intel.com Subject: [PATCH v2] iommu/vt-d: Fix to flush cache of PASID directory table Date: Fri, 16 Jun 2023 16:10:45 +0800 Message-Id: <20230616081045.721873-1-yanfei.xu@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768847167772966129?= X-GMAIL-MSGID: =?utf-8?q?1768847167772966129?= Even the PCI devices don't support pasid capability, PASID table is mandatory for a PCI device in scalable mode. However flushing cache of pasid directory table for these devices are not taken after pasid table is allocated as the "size" of table is zero. Fix it by calculating the size by page order. Found this when reading the code, no actual problem encountered for now Fixes: 194b3348bdbb ("iommu/vt-d: Fix PASID directory pointer coherency") Suggested-by: Lu Baolu Signed-off-by: Yanfei Xu --- v1->v2: use variable "order" to calculate the table size (Suggested by baolu) drivers/iommu/intel/pasid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index c5d479770e12..49fc5a038a14 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -129,7 +129,7 @@ int intel_pasid_alloc_table(struct device *dev) info->pasid_table = pasid_table; if (!ecap_coherent(info->iommu->ecap)) - clflush_cache_range(pasid_table->table, size); + clflush_cache_range(pasid_table->table, (1 << order) * PAGE_SIZE); return 0; }