From patchwork Mon Sep 18 08:48:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Lomovtsev X-Patchwork-Id: 9955733 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4828E60385 for ; Mon, 18 Sep 2017 08:48:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37FAB28B23 for ; Mon, 18 Sep 2017 08:48:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B48528BD8; Mon, 18 Sep 2017 08:48:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AFA128B23 for ; Mon, 18 Sep 2017 08:48:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752218AbdIRIsS (ORCPT ); Mon, 18 Sep 2017 04:48:18 -0400 Received: from mail-by2nam03on0087.outbound.protection.outlook.com ([104.47.42.87]:64121 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751830AbdIRIsR (ORCPT ); Mon, 18 Sep 2017 04:48:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=tm90TKwul8ua6+ZdFkKsaE4biLOW9tNRGIlA0wZTNuI=; b=HcSAQCRbBxMjD4hCCKG9lMpJ4dSpX/TW2PYLY6DGkDkl3EA+G7eaSZgiER8R/g4UdHV4BkepcO64HIVHZPpiZDGPWYYsNJdniiA1cMmQr2rGhxL7bWGrOywxwmdD4qipwK/C9CVXhXPh7Kmoz3K6+C5K8725OkbiT52zTW0oi8Y= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Vadim.Lomovtsev@cavium.com; Received: from localhost.localdomain.com (50.233.148.156) by MWHPR07MB3008.namprd07.prod.outlook.com (10.172.96.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11; Mon, 18 Sep 2017 08:48:14 +0000 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, Vadim Lomovtsev Subject: [PATCH v4] PCI: quirks: update Cavium ThunderX ACS quirk implementation Date: Mon, 18 Sep 2017 01:48:01 -0700 Message-Id: <1505724481-28413-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1505480233-22694-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> References: <1505480233-22694-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: YQXPR0101CA0063.CANPRD01.PROD.OUTLOOK.COM (52.132.74.40) To MWHPR07MB3008.namprd07.prod.outlook.com (10.172.96.14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce2836eb-f7dc-438f-4c61-08d4fe72006c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:MWHPR07MB3008; X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3008; 3:VYdRs4I1KAL6p5vIR5XaOXmOotZOM+wW44dH/wQFQjxv2fgEddShHI6k1K6qmdnfwD4/BaPar9cTdbgpVuUOlyYphqMGS0weofaz/vQUlhpxA4zOBhRRRAx4LfpjNlgOKzqI/ONhDCvj/S9/CGFBxyw+hbzvb8ZBGyAW4F4AozhRydvAWDnbRnfIIeIZp6qMCShDUpb485go6uEEzAjpuZCGF4YaSV7nWwWW6i3iNgK/j72OO1PDiXZ6RCOcAVcD; 25:aWXLrTCE2WldJa8kjQ0f5P5MycaoMjHFIOtg/rNh90o1/L9smJ27r9k6Ylkkd2LI8KPqAUZUq/83cr6ay1821/zgSI5muJelpDP91CeuYFtCrBAZtE+Pia5NqjlzpnJWqv/CWQW3rlb2qsfKIQoZMf0SK6o4+4LfPYFoW+lkA14fDus/3ySUEaTGadIGyD4OiKY8hMF2NlWAUcm4YqM0CmaR7T+IlAYUcPu0JmeIQm7mK257GBh2zwAi+J+xrT2f2E2AHXY7MjDUqQ91tPFAw4cbibEnPHBQZWKi6Shr+vE9uo4MTMgnJheqgZm15oTiTdIcDJJd3TNRklkQ9+AGig==; 31:YRndv0wLPyA5SDkfiwAE/hmbmFDToMjVCKtOc3qGwexdGb6I1H0qPCwZ5mVTGGDT4CFTGDgpVcyubkBFMhXHRZUVSEe9OEUJeJDP0un+kigOwcihEIgEzPnPHOE5pehyDSvRat4bIYhnjhPT85B5LsBGfKSAOXaEXgi+kRZ8zwMNEharOYwquxmZkZeybbmtwRYvmkCcGEIm26sjOzugyBCy0hLpe417ItMYxkeB04I= X-MS-TrafficTypeDiagnostic: MWHPR07MB3008: X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3008; 20:AskY0aPnJnkUMEgChSKz4VrFhXjIUSSgkwCU9cKRnsy2uEDRvksQNIfpJcXh10ZvNv62SaeOR0aGRmmpr0W0qUopE3cXnILSR5dVScI2G5IeX3JMQq4tOs7NnwEPWhX4ubBb9tDrl0Q92MOV/w9VTSFFm7vsaIpPr+uKzlTfvnzA8/+U0PAn44ppKeOGbilSQpxAJalCWOVEeUoMVsFZBqAMZ1rcLT/09q5FFGey/0QGDJ3ZVxCNIJgkRG+4rRsjm5YXshhUrr9ZGUDrP6xydgE8jv1gB/HqXtE682irn11ExbrUD9ww+gLslQK4Z3aP4hMBXgA/vw0nG+mTrHyQO5mvAM46AVGc2tdrjO8roMEmahdltRyOlxoFw9kGhR74lv8M8YTP/pnoqwiLakll4n+cWGDyUN7pXYMBhg2m4kHhO7VD58xfpnALweOrp8EFMbqr3xhsBPCQDVt9Pd+/3HqZVfZi/axzObMqzb9v+iV0wAyADIlrcUI/06zF0cHK+IMyJ6Fywr2dRd5BYa5avfuv3kYKJtjoG6PgLDtpMdQDSoMrQuq34a+XONtmv5Wrxl9qpGE71c3DJ18c1K7E9Ay42myzJmdKxoE8JN2aN+A=; 4:i+MILwImWTqbt7XIEFGcVl1HS4EUOJ33uvPjFiWk9saIqbm0VHENPVpI5ia0dO20Np2cAu1rojNWT1RcBFk7v1xEj4TEU6vQpRu7ax/WXgoXj439MEXLCUr04ZbmGhtxUrCdx75xGI9g+B/xlzBuGdRy9LbpOkgRn8uPArBmwTmgnryqTHrifu275duIK4uW4+gKff7H5rclUpYxgCNK9/zY1uFs4KtBgihNJb0YcXdp14RaqMH7JIZuHYtEHr66AnH45LmsOcmLPCWw7z2SDyO1LSJkqQ8kQXJw4oNYqac= X-Exchange-Antispam-Report-Test: UriScan:(788757137089); 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)(93006095)(100000703101)(100105400095)(3002001)(10201501046)(6041248)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR07MB3008; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR07MB3008; X-Forefront-PRVS: 04347F8039 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(6069001)(6009001)(376002)(346002)(189002)(199003)(81156014)(16586007)(97736004)(72206003)(6512007)(6116002)(50466002)(8936002)(8676002)(48376002)(107886003)(110136004)(316002)(68736007)(53936002)(7736002)(15650500001)(2906002)(6486002)(66066001)(47776003)(575784001)(5003940100001)(5660300001)(106356001)(53416004)(6666003)(478600001)(81166006)(305945005)(189998001)(4326008)(42882006)(2950100002)(101416001)(6506006)(69596002)(50986999)(76176999)(50226002)(3846002)(36756003)(25786009)(16526017)(105586002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3008; H:localhost.localdomain.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR07MB3008; 23:v+V5MbAUdhnPexMSKP6qVlG86ZmWgs+N0bvPaEaX7?= =?us-ascii?Q?6pFOYkZcG/izA5qeq2yMahCuJnoiQ3E9YN8Uu/zdG8R388qffrAPxxteVfUj?= =?us-ascii?Q?F99NVU/h/69Ab91nx6+PijOeNK+shX9RjVJdMSi+8dLW3Bju8DxCjaZgLZec?= =?us-ascii?Q?ULZyorpOJ4uLD0h0lPm2tUxD6+t3RLShKRNiuDY9rvUjiaqJvmJnWq9Q8mEE?= =?us-ascii?Q?axceI/gukIZoTb0yD/nwGdG9iooOJAAKhm46QzkVvzUpl6rbhdCfLtEbp9Jx?= =?us-ascii?Q?v6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utput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2017 08:48:14.0916 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3008 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/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 --- v1 : put device check into separate function and extend it to all Cavium PCIERC/PCCBR devices; v1 -> v2: update match function in order to filter only ThunderX devices by device ids to properly filter CN8XXX devices, update subject & description with ACS register info (rejected by maillist due to triple X in subject); v2 -> v3: update subject: remove CN8XXX from subject line, replace it with ThunderX; v3 -> v4: update ACS mask (remove TB and TD bits), update commit message (remove ACS register printout); drivers/pci/quirks.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index a4d3361..e6b904a 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -4211,20 +4211,26 @@ 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) +/* + * 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. + */ +#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. - */ - 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)