Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751507AbdIOM5n (ORCPT ); Fri, 15 Sep 2017 08:57:43 -0400 Received: from mail-bn3nam01on0087.outbound.protection.outlook.com ([104.47.33.87]:31360 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751207AbdIOM5l (ORCPT ); Fri, 15 Sep 2017 08:57:41 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Vadim.Lomovtsev@cavium.com; From: Vadim Lomovtsev To: bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, alex.williamson@redhat.com Cc: Wilson.Snyder@cavium.com, David.Daney@cavium.com, jcm@redhat.com, Vadim Lomovtsev Subject: [PATCH v3] PCI: quirks: update Cavium ThunderX ACS quirk implementation Date: Fri, 15 Sep 2017 05:57:13 -0700 Message-Id: <1505480233-22694-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1505217316-15702-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> References: <1505217316-15702-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: MWHPR15CA0070.namprd15.prod.outlook.com (10.174.254.32) To MWHPR07MB3006.namprd07.prod.outlook.com (10.172.96.12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0358e450-94ff-4a20-a011-08d4fc3957aa X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:MWHPR07MB3006; X-Microsoft-Exchange-Diagnostics: 1;MWHPR07MB3006;3:J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mKLWN9UrgMQfHiD9GYS4Hzv6AP+IUQ+Us6y3w/aIQ5nYuxgb3jy6aFx3IQ5mNnfZsd/+hbVPw5jKLdthNix2P/wjWGaDSEkz8+VdVhpZE3X3rRxydnHPRv7B4idayL2W7MWCBmRJViiM9NGa09PdK2NBBjjGi1h9tPM4OLm4AcThYa6VKwm9RSAMC1QWWg/LTh7tV5d7Q376N/FGCOnuqGf0UQdfhZ6FSBwz3PWDKD9Nh9OA3Op7xZv8CQpXZEdGs/cxC9V4xLKtKmQlJsUJNQjlAsr/ifq6aLtODxqdvzrEwX56RPZceIQrjgU/3eakVAWztdX4OSd+yvDtQzuqWJhViwqGwdYGSbe1Y06wAniFVUVvn7ndoWy28dcTNFLRJ8ynKO2K5O/TiF2mLDvxq6YzB5B+gBhHY4gcgSQa85T9W9FCRqWFvAi5483J3yjy9dKprrJ5Qzv+Y=;4:U678+MBj+KAy70n7SqXz3S5JQ1+vaNTlKsCEq54qynewMK2HL4tYIOF4Ur8XYsqsPuhfV9rl6OdP285iznwBBiuV8LObzZDBZ0rDCXWBkc0Fm4KxEqq6VwHOS48apJ3fdx1shOSmGWVNd+r6X8dnPOuVUzkLDmEm+Gi5u57enDwMtC1olZf2l8VrDpPwJ2kZFfvkm09pbonKICUJ0I7ueRWEi/JmyH9ycU2c0LSnrlFmJhxloeAZv98cKt7Vewfq X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(3002001)(10201501046)(100000703101)(100105400095)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR07MB3006;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR07MB3006; X-Forefront-PRVS: 0431F981D8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6069001)(376002)(346002)(189002)(199003)(189998001)(575784001)(50466002)(4326008)(42882006)(48376002)(2950100002)(53416004)(6666003)(97736004)(5660300001)(53936002)(6512007)(6486002)(110136004)(107886003)(101416001)(36756003)(6506006)(551934003)(8936002)(76176999)(50986999)(81156014)(478600001)(81166006)(50226002)(8676002)(69596002)(68736007)(7736002)(16526017)(3846002)(6116002)(305945005)(16586007)(5003940100001)(72206003)(105586002)(2906002)(316002)(106356001)(25786009)(47776003)(66066001)(21314002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR07MB3006;H:localhost.localdomain.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;MWHPR07MB3006;23:Az3Lh8NRQDAqh2vsABjOeJDvdxqpcKhG7TxDeca9Z?= =?us-ascii?Q?J1LSGjeAAUtOJzaxvyJ3lP4URk3pWlmmZQAYFQ/6ToaFMFEuuW5x00NQVHh8?= =?us-ascii?Q?UmA70nRLNFbXPQ9HHhQwYgbjUg0M77WWIg9NAfY7isrlr+su854te766WP5L?= =?us-ascii?Q?T0GS8OJqVziS2LNK2ZYeL3yC3T9+MDuNorWoSqFy1oABcOQ8ghoW6oL7zfD3?= =?us-ascii?Q?AsvZjDvQHmbRSNAX5l1M4g6Fl3JIJxqnxzynOwNRqIHMuAKYqWRKKNh5QbcV?= =?us-ascii?Q?dq/Bg+Ecx65XRrAIj8aoQR7xlsOyEsik0OK/tBDkUE3j5frHeV82f5PMt+z7?= =?us-ascii?Q?pFy7rTmwietxO8aykEDsyBJ+MVZtPp/YqtCuUk7EHaXhroKNgmT8Q55mskFZ?= =?us-ascii?Q?HrMIbsp66yNh2M8gm9LxKKnhUrXq6mm/OA+es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CpIrme1NtQCBqWNm6ktAA4CvOM8QZFKMDCRYCfOoa73qPhbM7rYDJPpl7UWAsLJBgC2CuizQFI+jRWQ49+z1CcmkImhP3HE3fVHw+aJ2ddJ/AgyLQb5Dqevb7fV1EtBaKPOfQZtKDwEcgJAOJ6AifVbk0q5adnEgzu7KXvSsgC5D6OTj/KwP3rxF6c8GdYEtQ7eexEBLD9cVBDdG7h10XiBdYbWGjb5i8aErpjcMczORmX5nUODng3XMpCq/uPLzYCoTCzORPWUwdePXA2YDASKPDGH9j5X12GnqGdI/A1ufY7gQ==;5:xTV91v9e1/hvTpIphMrHEZGKZhOeOVvJsHbv2UWunuWGv7ciu0A0tPARl7/1SJBi8ptjewkfisZXPJgAqVi3+zUaZVILAQ9qMR7OKdPS6HbxQsGDcP8xSUGV+UBg7fY6I1K+8JqPbkANujmnuI5lmg==;24:d/1XiIUYzJsPuiqVQ49lwAr3SGGBn5QDnoc7QpWAAmM2ciQIhtCYUQ9DTu5QzCsH6EPUhKF5YRw63M7j4Z0DzM/+xJ1bjjmemyIX5b9GYbU=;7:C6Q+dz7cCd0f/ori2Nf9SZ0lun2Km6DQk/q09l2FERdFYm2uNeR8ysQ1xsV7Ixa2S7mMwScBAbyVGVtfOgs0Va4tOqu9Lv5VuCl3nXmCI/AbQ4E7ZlcsSEkaXlj+qL9R49mZbKHc5SXjQyGKclLd5pRrSsF0YNlK0mfRoyEH5HtDcF3SMVeuSIHHQGMdceXQzKA5IA6Xfnphfqf5UELSt5q8xs2VqRbzv4aOzHOt6PQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2017 12:57:37.7717 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3006 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4071 Lines: 82 This commit makes Cavium PCI ACS quirk applicable only to Cavium ThunderX (CN81/83/88XX) PCIE Root Ports which has limited PCI capabilities in terms of no ACS support advertisement. However, the RTL internally implements similar protection as if ACS had completion redirection, blocking and validation features enabled. Following settings are enforced by hardware on 8xxx although it does not have ACS: $PCCBR_XXX_ACS_CAP_CTL (as if it present) --------------------------------------------------------------------------------------------------------- Bit Field Field Reset Typical Field Pos Name Type Value Value Description --------------------------------------------------------------------------------------------------------- <31:23> -- RAZ -- -- Reserved. <22> DTE R/W 0 -- ACS direct translated P2P enable. Value ignored by hardware. <21> ECE RO 0 0 ACS P2P egress control enable. Always clear. <20> UFE R/W 0 -- ACS upstream forwarding enable. Value ignored by hardware. <19> CRE R/W 0 -- ACS completion redirect enable. Value ignored by hardware. <18> RRE R/W 0 -- ACS P2P request redirect enable. Value ignored by hardware. <17> TBE R/W 0 -- ACS transaction blocking enable. Value ignored by hardware. <16> SVE R/W 0 -- ACS source validation enable. Value ignored by hardware. <15:8> ECVS RO 0x0 0x0 Egress control vector size. Always zero. <7> -- RAZ -- -- Reserved. <6> DT RO 1 1 ACS direct translated P2P. Always set. <5> EC RO 0 0 ACS P2P egress control. Always clear. <4> UF RO 1 1 ACS upstream forwarding. Always set. <3> CR RO 1 1 ACS completion redirect. Always set. <2> RR RO 1 1 ACS P2P request redirect. Always set. <1> TB RO 1 1 ACS transaction blocking. Always set. <0> SV RO 1 1 ACS source validation. Always set. --------------------------------------------------------------------------------------------------------- Signed-off-by: Vadim Lomovtsev --- drivers/pci/quirks.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index a4d3361..f1786a5 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -4211,20 +4211,28 @@ static int pci_quirk_amd_sb_acs(struct pci_dev *dev, u16 acs_flags) #endif } -static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags) +/* + * The CN8XXX on-chip devices' PCCBR's do not advertise + * ACS, although the RTL internally implements similar protections as to + * if ACS had completion redirection, blocking and validation features + * enabled. + */ +#define CAVIUM_CN8XXX_ACS_FLAGS (PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR | \ + PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT) + +static __inline__ bool pci_quirk_cavium_acs_match(struct pci_dev *dev) { - /* - * Cavium devices matching this quirk do not perform peer-to-peer - * with other functions, allowing masking out these bits as if they - * were unimplemented in the ACS capability. - */ - acs_flags &= ~(PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR | - PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT); + return (pci_is_pcie(dev) && + (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) && + ((dev->device & 0xf800) == 0xa000)); +} - if (!((dev->device >= 0xa000) && (dev->device <= 0xa0ff))) +static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags) +{ + if (!pci_quirk_cavium_acs_match(dev)) return -ENOTTY; - return acs_flags ? 0 : 1; + return acs_flags & ~(CAVIUM_CN8XXX_ACS_FLAGS) ? 0 : 1; } static int pci_quirk_xgene_acs(struct pci_dev *dev, u16 acs_flags) -- 2.9.5