[RESEND,v14,04/13] PCI: Enable PASID only when ACS RR & UF enabled on upstream path
Message ID | 20221031005917.45690-5-baolu.lu@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2042293wru; Sun, 30 Oct 2022 18:08:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6EkZCTg/oZV7XuLG7iQYzBBVtNM55K6urfpvVavBFkUXTkDzTOrG+gobkFdSeP+89ScXaf X-Received: by 2002:a17:906:6a04:b0:7ad:b388:9fa4 with SMTP id qw4-20020a1709066a0400b007adb3889fa4mr8499067ejc.199.1667178524448; Sun, 30 Oct 2022 18:08:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667178524; cv=none; d=google.com; s=arc-20160816; b=zC6ZgKDQizf8mY3cvhvO6kdVpduYWL+polWUG3Y9U3+xxa12x8XDxM5hWnhZYj0Kjc E1NA6/2IwzxaowjYlzliWRWzOKW9e5nzh1u6yLYBAKQzzCenuQikB3gRZK8B1TNLaopz OlT3NQXfvkz+lqfsUlXXCIroVHRN6HzNWOWk02tq/Mw9PCVRfuK7johAhZGty9FIRXTU dqCT10ZD76dyp/Wn4T3wZy9083J/lNiKK6b3zs4WjTPE2etFOGREweTnXS8v0w35VGZo BwqQomNP+lDEBU7lD973gbOXsz26Qe4AANLQsx2EN0GQY2Ma3ufUTBwHxVlpuZX2i6UK hvsQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+wYKC0TXZJHAH63ysbH7SOGFH9zDYFay4C3CInPHp94=; b=RZEwk1OCbDJpaxjZnGisoEe8eO+8sGNO25En9YngE2cOrDCkTzM0+4ui9UEZvPuQeA KkdlDeo+LrnAqEXQdRpPp72Id+XyWESBQY/V9z8UGL4XbLpW1r369rVyiqQ6k2Yrlv0+ gFNuQHrJ5WHYL1Z2KMExmXDCD+8ZyI9p02xv1rOURUC5jfND+8YCSkG6AnwBSMhaSJ1G dkGTxpt1NXJ5stQkOKhuz5vUvDeXlsKHpFF26VHoRXEjRTIsm95IZS7EqXMVx6w+4p+V q0Ny/aXEPx5nvRM0Yke2MZlOct07RYFAOMRMpJ6AN5ktvOu5I++aMW6i8UBTLzvkvBJM f65A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Rc4hZU6p; 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 dt5-20020a170907728500b0078da3218b54si7197070ejc.171.2022.10.30.18.08.21; Sun, 30 Oct 2022 18:08:44 -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=Rc4hZU6p; 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 S229761AbiJaBGU (ORCPT <rfc822;kartikey406@gmail.com> + 99 others); Sun, 30 Oct 2022 21:06:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbiJaBGP (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 30 Oct 2022 21:06:15 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C25B8A1A2 for <linux-kernel@vger.kernel.org>; Sun, 30 Oct 2022 18:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667178368; x=1698714368; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EMDXCRdwqlGlnOwAqWbXNb8UnPKBXi5/6JNHQV9oHYo=; b=Rc4hZU6pbFJ/ujbgG31gzzi9SDobqf527RhzyyRZaCWOEYaRQ7PCzcs4 TJMq1VVoK5OlLckouXVGsgwbhuJAgEbHZHYByl5zWgJ2f3UbazMFIx7Ub K0RQfpuR5o3qgHQq5aq521ne84egwAMPQTqqitcy/23AWHwrl9K3VW/AI uC4F6aLdQVbZqpMFR7sb6wKdAEobefF35/PhDYdtE5N9SCT0fMAzn7DHL vWcx4R7KbiFg0jKnVlA2J9dcAdX4ju5mCnyW2S6KDAE9JUCcrhHG72nIM fXgX25uyaZDKFZLu9A9sIy1EHfoYbVQGruakZwPPQsnhLxzx9wMJRVhUF g==; X-IronPort-AV: E=McAfee;i="6500,9779,10516"; a="373001668" X-IronPort-AV: E=Sophos;i="5.95,227,1661842800"; d="scan'208";a="373001668" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2022 18:06:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10516"; a="584496166" X-IronPort-AV: E=Sophos;i="5.95,227,1661842800"; d="scan'208";a="584496166" Received: from allen-box.sh.intel.com ([10.239.159.48]) by orsmga003.jf.intel.com with ESMTP; 30 Oct 2022 18:06:06 -0700 From: Lu Baolu <baolu.lu@linux.intel.com> To: Joerg Roedel <joro@8bytes.org> Cc: Jason Gunthorpe <jgg@nvidia.com>, Kevin Tian <kevin.tian@intel.com>, Will Deacon <will@kernel.org>, Robin Murphy <robin.murphy@arm.com>, Jean-Philippe Brucker <jean-philippe@linaro.com>, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RESEND PATCH v14 04/13] PCI: Enable PASID only when ACS RR & UF enabled on upstream path Date: Mon, 31 Oct 2022 08:59:08 +0800 Message-Id: <20221031005917.45690-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221031005917.45690-1-baolu.lu@linux.intel.com> References: <20221031005917.45690-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748163388219646879?= X-GMAIL-MSGID: =?utf-8?q?1748163388219646879?= |
Series |
iommu: SVA and IOPF refactoring
|
|
Commit Message
Baolu Lu
Oct. 31, 2022, 12:59 a.m. UTC
The Requester ID/Process Address Space ID (PASID) combination identifies an address space distinct from the PCI bus address space, e.g., an address space defined by an IOMMU. But the PCIe fabric routes Memory Requests based on the TLP address, ignoring any PASID (PCIe r6.0, sec 2.2.10.4), so a TLP with PASID that SHOULD go upstream to the IOMMU may instead be routed as a P2P Request if its address falls in a bridge window. To ensure that all Memory Requests with PASID are routed upstream, only enable PASID if ACS P2P Request Redirect and Upstream Forwarding are enabled for the path leading to the device. Suggested-by: Jason Gunthorpe <jgg@nvidia.com> Suggested-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Tested-by: Tony Zhu <tony.zhu@intel.com> --- drivers/pci/ats.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c index c967ad6e2626..f9cc2e10b676 100644 --- a/drivers/pci/ats.c +++ b/drivers/pci/ats.c @@ -382,6 +382,9 @@ int pci_enable_pasid(struct pci_dev *pdev, int features) if (!pasid) return -EINVAL; + if (!pci_acs_path_enabled(pdev, NULL, PCI_ACS_RR | PCI_ACS_UF)) + return -EINVAL; + pci_read_config_word(pdev, pasid + PCI_PASID_CAP, &supported); supported &= PCI_PASID_CAP_EXEC | PCI_PASID_CAP_PRIV;