From patchwork Thu Jun 15 07:16:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yanfei Xu X-Patchwork-Id: 108302 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp459998vqr; Thu, 15 Jun 2023 00:51:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ75f22v/o864tm/KnXxP+B7U8An3iIhglmb5zt7n5+3G+cdPtac9g7bAr4+ViSWAENq1+CN X-Received: by 2002:a17:906:c151:b0:933:4d37:82b2 with SMTP id dp17-20020a170906c15100b009334d3782b2mr20133554ejc.57.1686815479255; Thu, 15 Jun 2023 00:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686815479; cv=none; d=google.com; s=arc-20160816; b=ctJEi/hJDW4X91jAN8k9+cKdk/kOtb/KuifZcBpEyPTqwAFISsRka9nDVAoegww8H5 FNWqVgxK+Hb8IiuI7ByZfMgcKKaoL7lDV6Zh7qkHXhZgO9PplIfDmUI6uWXFn/qntjcv CWnT0kmEl/1KlnwHbhhHzyiNpZFYHnwTAGcmCI2F1Zewtp2AHC4C3wzd4FPxn7zwZpCt PI+lzCDJEypsma8lxLohffR9CO/xFb5xPTUEKWBgbnVFoJDSKgBHp2P100DFxN0c4vF1 vwyJ8J85912srvUO7OsdD8qxNXDU67V6/uVjQVTYPDaEqdmzQ0q08VslQ4CDrNKJKDhK pfSg== 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=pI9Kebwri7Wjwt5dIv+EfvKXtO/M52yhl/ynLaKFTh4=; b=pcCbCp4RpGDbpAoY79rDVqGbuP8DGf5mc10DFd+qK5S4oyt0FY+11gP/LZxj12yl1A KUAYBTj4ePcHtUuQQSdsDJUNVR1LdsBikn1ym+bIXKoE/MLpwkNv8hCb9+C1XU3nwgpj mTt2EC4Q8E/hMiwW2UdL1Wolr4CTRkFIytnpvA5jR2+IqlvGFonbBbaR6rX7AAp7fsab F9s3i3fmRFfMGmKPV9Vu/P4I0XAhHaQjN8oDOy1Ic7lZH5k3woIhNNFjjv6dTynffD68 Qvtfroj1E46jSgjHxO//+u+O+Q4Q2LyXbKN1k/Rkutc7EC1784B4AA5vAd91TUR7GX13 ikZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZjE8i8W5; 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 j18-20020a170906051200b0097459846857si419563eja.296.2023.06.15.00.50.55; Thu, 15 Jun 2023 00:51:19 -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=ZjE8i8W5; 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 S244147AbjFOHVI (ORCPT + 99 others); Thu, 15 Jun 2023 03:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238246AbjFOHU3 (ORCPT ); Thu, 15 Jun 2023 03:20:29 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 606D8270A for ; Thu, 15 Jun 2023 00:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686813532; x=1718349532; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=tv0xInhDNZvIGN29/qg5JZUQvfOAzDkVJk+y8zR9+Z0=; b=ZjE8i8W5fRSYFplo7odk277vLPw/NRW+H+Cg0bltmmU6YvIoa+B2nV6z HodB+9+nZRCpCSFkwTo7SyybDL1vvpbxXeD7ZDSRw88S5vJPJPGP5luyN Rbp8jjA/5EjQPHW0vCxkPd7E7PruPItMMao9OitTst5rjrSYbkNDK/7yp Xu6MQaczsHrg8YmR9MTmffUKsgLsWb4v1imMtyt5+r+Bb2YmkTOucMtGs guDVeococ+8h7VMb2jNsN5NmJ+XYZfbHpO1HwWJItf5XlO0grmoPALOGq Wl1EeJGAL0LFlHim7BxDEtybz+Ml4zTIQ4VonP4x7Yf2DkX6S7QG3mdmY w==; X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="339183070" X-IronPort-AV: E=Sophos;i="6.00,244,1681196400"; d="scan'208";a="339183070" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 00:18:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="706544678" X-IronPort-AV: E=Sophos;i="6.00,244,1681196400"; d="scan'208";a="706544678" Received: from tower.bj.intel.com ([10.238.157.62]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 00:18:49 -0700 From: Yanfei Xu To: dwmw2@infradead.org, baolu.lu@linux.intel.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, yanfei.xu@intel.com Subject: [PATCH] iommu/vt-d: Fix to flush cache of PASID directory table Date: Thu, 15 Jun 2023 15:16:13 +0800 Message-Id: <20230615071613.690639-1-yanfei.xu@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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?1768754227771261515?= X-GMAIL-MSGID: =?utf-8?q?1768754227771261515?= 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 to assign it with a page size. Fixes: 194b3348bdbb ("iommu/vt-d: Fix PASID directory pointer coherency") Signed-off-by: Yanfei Xu --- drivers/iommu/intel/pasid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index c5d479770e12..bde7df055865 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -115,7 +115,9 @@ int intel_pasid_alloc_table(struct device *dev) intel_pasid_max_id); size = max_pasid >> (PASID_PDE_SHIFT - 3); - order = size ? get_order(size) : 0; + if (!size) + size = PAGE_SIZE; + order = get_order(size); pages = alloc_pages_node(info->iommu->node, GFP_KERNEL | __GFP_ZERO, order); if (!pages) {