Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964814AbdIYNJC (ORCPT ); Mon, 25 Sep 2017 09:09:02 -0400 Received: from mail-sn1nam01on0054.outbound.protection.outlook.com ([104.47.32.54]:48544 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934495AbdIYNI7 (ORCPT ); Mon, 25 Sep 2017 09:08:59 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Vadim.Lomovtsev@cavium.com; From: Vadim Lomovtsev To: linux-kernel@vger.kernel.org, alex.williamson@redhat.com, bhelgaas@google.com, linux-pci@vger.kernel.org Cc: Wilson.Snyder@cavium.com, jcm@redhat.com, Vadim Lomovtsev Subject: [PATCH v5] PCI: quirks: update Cavium ThunderX ACS quirk implementation Date: Mon, 25 Sep 2017 06:08:40 -0700 Message-Id: <1506344920-24016-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1505724481-28413-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> References: <1505724481-28413-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: CY4PR03CA0096.namprd03.prod.outlook.com (10.171.242.165) To CY4PR07MB2997.namprd07.prod.outlook.com (10.172.116.11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2da7676f-72df-4f4b-87ab-08d504169558 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075);SRVR:CY4PR07MB2997; X-Microsoft-Exchange-Diagnostics: 1;CY4PR07MB2997;3:hpUPj0rGn7HLlxBfsCDYLynpWKQ8VTfRBg4CvqqInAdG8IB9yXJY3yT3d+Jni+rvCri+0E2o5ZV56itkMjrbQAlVHrlOyBbdo647hp3/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z0V13YOMlH4y5ZzXJMX3TwN1eNS2dxpZ6a8xyXk0of8Vca6ccD3Q3wL7D2AoILTEoMl6exdlnAzMf/4BjO/6SHMLsTSTf1A7jzWBAs6HbxsfHADb5/tvGP1f2e9q/ViKTdHwk7uXPfkKUC2q35pGuagPf3gme69/j0LkjyCxmZvCrxB+MPKm4FVGodqdoRBRNOS48HlDQOKMSQ7v6dJfeFd3qCA0JwZ2TBZtODuxZviJRZfyDtte0NvE8g7AhY6gllHti/cBEYifmwMYM03d9IBTraKKCxtd39M9Tq9iSJIxHpsO6TfIkas9mrYVgkTb6resxAS+WNJxl4JbA2er27VVjIFjpNVZg=;4:M5rHQqVYsCtFEUCUw20M61SWQgywddTL+Q8jBgwff7SAJn+57jFukuDaRvlisPCn13AH7j/ARYIQK2ehHFehX7aSL1HyH4YxHYv880G/y7XupOWzKGFpmjR4kPRwPmHlHfW9vMcdJZSLKusXlRD+DFMRf0QMjEpSHM7ZapY1lVKWCCAntjH3LjjwgMJBWDNMiJZZuCVdN8ZcOgiyNE7AhNbQFE6rcCeU2d7tahdOPTEGWh0PxMwqdFfpQfJLBS0o 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)(5005006)(8121501046)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(6041248)(20161123558100)(20161123555025)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR07MB2997;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR07MB2997; X-Forefront-PRVS: 04410E544A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6069001)(346002)(376002)(199003)(189002)(101416001)(72206003)(15650500001)(6486002)(69596002)(575784001)(316002)(36756003)(48376002)(6666003)(305945005)(25786009)(50466002)(4326008)(42882006)(2950100002)(478600001)(53416004)(81166006)(81156014)(50986999)(107886003)(6506006)(50226002)(105586002)(8676002)(68736007)(97736004)(53936002)(76176999)(5660300001)(5003940100001)(8936002)(189998001)(16586007)(2906002)(47776003)(16526017)(3846002)(106356001)(6116002)(66066001)(6512007)(7736002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR07MB2997;H:localhost.localdomain.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR07MB2997;23:hDt3EPuvVVdO9GG3F1BietaJETMZB9allPGpZLS2h?= =?us-ascii?Q?BtfHK12Ux/N8W8fVkuZL/X1OoLZdEC/9tUWyRRv0TfCOcrOWoEkhFu+ugMV9?= =?us-ascii?Q?5kl/XLqAPdJxZiojWMxPVCsf0UYfVjVke3nLcwgaX54rOe+ceuLek2Zo8QOW?= =?us-ascii?Q?al1e3y333taEn3bfnw8/RgASRKo5CH2EgRnzoKdU69W3s/xa5RPvBPQDVchD?= =?us-ascii?Q?IMQy73tiwlgD2/u+IQaM/JwSBv8ksc7aZikD4rJMJIW0L31h+1BIIcwIzLpP?= =?us-ascii?Q?CryIWXvrOtGB4dU3pzuC4FG17g3udeDKWEgxRnscq5XB5lGXYJwS0CO7QC6o?= =?us-ascii?Q?n5CT2nCafcWUiTQ/HkpPZISnmHoFX+5qb1ZfHdsmzDpFvJdOZjtuLvaMnHWF?= =?us-ascii?Q?9D3Jjxdp+ZaVmN9MuU6iXYpUpNhyzMQ4dAcJOFggcsVuRH1kx5tAXmpE7OY8?= =?us-ascii?Q?meiC5Gg4LOgodOO4jlr832lFKJQelod9Bz1jTyKundOcNEwCyDwS2HLB0TIq?= =?us-ascii?Q?pFN9YqT14VDIjHjtKPbzl1dA2kzuy/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VC37NBSn8wEhYVLPpK/MLu8c8nUEuW9uNqqmkD7Js4Zgb2D3ZerQQBm9Xp7zr6S+04BfH8xBgvcTTl61Ydmh6DdnH2Wo2NAH98wQH9Q==;5:CMWF1wYyeDvQItldUdLJ+AxQyE74hhWgfSVldSw5HZWsKQnuP4jHN8CXjKZzM0A5svRTXwHr/OqJaZsbIDA7bESebzdYv5sAeQqp36PnaPRIHqZ02jrWtIFLXhy/t4N3GX3MyNXmur8fj0n3furr7Q==;24:zNOQStihW4NqfowCHIq7Va+F6Ljy2uQq6sBJEPPQgG2RkbcV4F1wLCMwQV6dydBYpLfnf/oFuDexhwrmEetev058Rs+xP+ExvEJKpeicfVU=;7:VRUyRzvXHKOmk/m3weV+tO3b0CsBaX9SjMKH8KF6j+IK9AhDBtRsryvOhz68reuCpDFiA02WtY/oKctUwTIs1KnbzontfpOv5ZotVzJzGNTmY1ZT6asPnCliSYf6QBIuVa2A0hhturVbfJ+diNEDXdY56pahkrtwdohwda7Td22n2q+3Skl5SxikwTl87GMdBoLwxPuAbxe410Y59b12fWvAnWdqn4eFIvfmHbhs/1c= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2017 13:08:58.1379 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB2997 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2569 Lines: 63 This commit makes Cavium PCI ACS quirk applicable only to Cavium ThunderX (CN8XXX) family 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/request redirection, upstream forwarding and validation features enabled. Current quirk implementation doesn't take into account PCIERCs which also needs to be quirked. So the pci device id check mask is updated and check of device ID moved into separate function. Signed-off-by: Vadim Lomovtsev --- drivers/pci/quirks.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index a4d3361..0fd2e15 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -4211,20 +4211,33 @@ 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 Cavium downstream ports doesn't advertise their ACS capability registers. + * However, the RTL internally implements similar protection as if + * ACS had completion redirection, forwarding and validation features enabled. + * So by this flags we're asserting that the hardware implements and + * enables equivalent ACS functionality for these flags. + */ +#define CAVIUM_CN8XXX_ACS_FLAGS (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_SV | PCI_ACS_UF) + +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. + * Effectively selects all downstream ports for whole ThunderX 1 family + * by 0xa00 mask (which represents 8 SoCs), while the lower bits of device ID + * are used to indicate which subdevice is used within the SoC. */ - 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