Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751948AbdI0UDr (ORCPT ); Wed, 27 Sep 2017 16:03:47 -0400 Received: from mail-by2nam03on0046.outbound.protection.outlook.com ([104.47.42.46]:43003 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751569AbdI0UDp (ORCPT ); Wed, 27 Sep 2017 16:03:45 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Vadim.Lomovtsev@cavium.com; Date: Wed, 27 Sep 2017 13:03:36 -0700 From: Vadim Lomovtsev To: bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wilson.Snyder@cavium.com, alex.williamson@redhat.com, vadim.lomovtsev@cavium.com Subject: Re: [PATCH v6] PCI: quirks: update Cavium ThunderX ACS quirk implementation Message-ID: <20170927200336.GA29443@localhost.localdomain> References: <1506344920-24016-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> <1506536439-29318-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1506536439-29318-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> User-Agent: Mutt/1.6.1 (2016-04-27) X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: YQBPR0101CA0009.CANPRD01.PROD.OUTLOOK.COM (52.132.64.22) To BN6PR07MB2993.namprd07.prod.outlook.com (10.172.106.11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bf04e078-6940-4d61-b9ad-08d505e2da7b X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075);SRVR:BN6PR07MB2993; X-Microsoft-Exchange-Diagnostics: 1;BN6PR07MB2993;3:FHQu8NRLAcuFLEdc5YqtK03ANI5SLH8sztK4HZrwpRjxCeT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AFMteoEEHXvfPT5B6mbFHQh0f2VtH2eLCJ6x6Z3xPKj9AJrRlMfSndT/z4oMlxGtLpQyzIl1LPbQr9u5fJ2kjG0rYskM+eCO7oDAHRCgLUfBmH21PZuAqC+3Ak/fQO5lNmUzoVprgBd2GXMiX2+i5NcOyi8KEMqIBZ6JNZhlvE2MDV3xdO19aWp+D8IClW8qRHlPbeDTy88kY1kThVO/SvZnQAqRvAYG7W+sVXSrBWIjmAOO8HlO5WkSPkdJY90hIoPapHiTWiE3qgOTmd1yEJ5iPCC8O5dccT8ZDnn6EP272jVWHop6O8wiFfGa9sPabCmlAjEQ6E2gksM+e74QhN1uHQrKwXnW3+2eJ9z+mYD+fzsOF09V+0X+3NjNI8Gdx5+ndqSDVprRnhBW7Yw7n+eJY27w=;4:uPJh4nr8pXYupMO8oTnEzUmluhEt+dz88DYA9AbZp/1UWCHNm2ZPfnKcLwjoGa4rYT2K1jAx1lxHWeanz+4XCqL4Ymt8REJlkv/zaVenZ7DMbTCFjzqpa7BjkIzxFD2ODcxYsPUUp74EI6yLT/quGowc6AGKMn2zsdy0O4HutrPalDPwn5ZG4AIywK2LCvtZrmCjsPUjzdfLGQfdu3jcfPc/heRVuhz7SyqvQfE9L8hDQzsBvmzTqCjwUCuOuLaN 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)(3002001)(93006095)(10201501046)(100000703101)(100105400095)(6041248)(20161123564025)(20161123558100)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN6PR07MB2993;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN6PR07MB2993; X-Forefront-PRVS: 04433051BF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(6009001)(346002)(376002)(189002)(199003)(24454002)(97736004)(33656002)(16586007)(16526017)(23726003)(316002)(9686003)(83506001)(15650500001)(6666003)(58126008)(1076002)(6116002)(3846002)(53936002)(42882006)(25786009)(575784001)(55016002)(4326008)(2950100002)(5660300001)(61506002)(76176999)(54356999)(50986999)(101416001)(8936002)(106356001)(81156014)(81166006)(189998001)(2906002)(72206003)(229853002)(47776003)(66066001)(7736002)(107886003)(50466002)(6246003)(6506006)(68736007)(8676002)(478600001)(305945005)(105586002)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR07MB2993;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR07MB2993;23:AwiJBgAOHEWY1CAo/EtR/Am/W8SnOSt8Kn6exnDvx?= =?us-ascii?Q?jjaCOHVhxw6t3arhSZimBO/2Y/+52lfJsscXnSQA0VsW/ZO15faGzfmNbKH9?= =?us-ascii?Q?oZYz1J4guGLJNYYzkOgxj7kePSITLprsa1HBMQEE54XFxJvJuU8fd9Yw9nFb?= =?us-ascii?Q?RSludBTtWfV0+dda0/iZacP84XDgb0wJim0TfhJeFtNp792OBM2PCJRXdYoR?= =?us-ascii?Q?6uLPf9HkOv9jhkOOLzhteefPJVGuYourw5jRx2fALwa6zuaETOR6T/FuYitk?= =?us-ascii?Q?PrOqHCIdkRIoum+iE/M/gjBVEzIRnp26VCnMmWxn8KgXvt+phi8oj0vmmK/J?= =?us-ascii?Q?7uJu52ACRCTSPd97joluahCX005JdqVQU85SzRc7oGeOgqpBgSZuVBD/tNK4?= =?us-ascii?Q?iww90ee/yR8hHWKQzkFuVFpZro4Xk7hduP2LoN/Ei277bUoamxjsIPOSF1so?= =?us-ascii?Q?Qyc/ME8iW/myQtb+Z0W7Do+eGXTc0ElTG+U91334zlQH+Vahq3MEe59/QL52?= =?us-ascii?Q?PXslM8dZuwPdwoTnkAIV0je4eMLPY2XL1PowjEX9tDsozAnht0GYVkMo2ko2?= =?us-ascii?Q?/Tid96RgbT4CCN89q/xdTPxpxdMPKM7A1HlwGaeW/6bx4jV2FSUujYiW73kZ?= =?us-ascii?Q?Vqvz9jD1s6u23wYAoN7Iq+ABmllBDxTvWqf77B4GrcJxI+aPkRb083XDxwME?= =?us-ascii?Q?DcEwW6pG72bHF2PyeA4+VMw5IIRgkg1Vq0YRBvYVcX2H38Jw5xBodlsHD5qW?= =?us-ascii?Q?Esl5f9bmF9orNRqq4XNevlJEhXCRFCZmoYj+sLFmliQ+f1txVkGDIdMm0KzH?= =?us-ascii?Q?LZVB8GldvMbnORTRwBeY1P6XsrLROTpqa7okMJiSuX8b/qgIraMZF5BdCRh6?= =?us-ascii?Q?bJC063tCae5j0jzPtrjEE9DcKT8CLgGu/DvDuiCeVEuOGfKiSmvmAG70+k25?= =?us-ascii?Q?obLTTttoTQK7pJc5Dw6QV2zFCA9+cAVqtNcWWZ12dYEcM8GHlouKaYRZMfP3?= =?us-ascii?Q?PfPEuir2c8X0ASjZ0W21AJXO2knd5ax4MBy5nUE3OWvylD60QCE4h51ZfFq1?= =?us-ascii?Q?5hC+PcwngCdU3lpX9LU2rN9E9HNgrPq8D92awZVOR7I2cM9fudrF+kTviAcl?= =?us-ascii?Q?9A7D4tXp/fQ1FD6i1xwpTk4uNe68iz0yVNhhPu5OMogBvSQviIJfEPDo0pNS?= =?us-ascii?Q?ymGzCqbkKwh5lZ00iijICua26XZlZbS+QHnzCcH7lnbeTHHvEZQ0SMXrALjE?= =?us-ascii?Q?bWrAA5dk2Ua1tTbS4A48ZOJUeZPgf7OU9o7J9Yf?= X-Microsoft-Exchange-Diagnostics: 1;BN6PR07MB2993;6:DPazVWdj3ZyYz9iYNsulaYxXf7cAz6VPDObnzi4/638UNeIGKIGavS9LC3wn/p3etasi5J+mr6psoZpgAk9azeb6IZSx+/9royzWGoFJhMGRfDuawsHNXkYoRtDBIRIGwhV2Vqn6UPF4Dj0TV37Mkk9YJwodISma9YN8hf9TuPtZD4oP4fpc3unJ97Wzir0F9xT2ekQ9se2DXNt7Coatq/z7rTM27E7qLTTaO9BTJSqvBtAcgy7r20kDQugvybTYVMxg+tDklsjYf5RT3zszrCQKZAOAm0QhIPVD57V7YAsNX2SuENTuGGqMmCoNwWLTW0ldHh5VknBod23EvaH1qA==;5:64BpxgYfGVYAazy8O+8OGGvN0syIlPXhd6IALaAFR+jumCHga8Yz8zrSXpxvO847CISIqFm6lQP0IjDAqHa5iKqdCvzpY7XjMMDUnJTZgzZ3zJBV9rRNwCf/TTGE4piBSL4G5jfTUkH60bMxd/s+SA==;24:HXIL0QVlfRHiIuR7bDOhcQWeMdRJn+5N7RxE3WXcpp+IDTw+cToks7md5PxU4NwfgMbmxNKMlN+KG8V+OByBnVXXJ8urG0gckZV1d//lFDc=;7:PZkloMNdotsM7g3pAdt/ltWWLGFjy3rej3d6X8FC8uJWaaQf+4gFkcUjeOWkdEq/+0JrcGFHNZx/4xKqC/43vIi/ySJotDy8m/3wpZ0UHzFIIPmx4aBGr/ugA5aHj4YsFauOS1m19BFuaKUbQ+/VpBaETCQhFwAgmBF+O7rVB1s0R4FUhfMzH9Egadd/GnOyJjaxqe+ZFezvK7kvgB/iVEouhOYZVLeaDcdE7HCf5ZM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2017 20:03:41.8926 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB2993 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3006 Lines: 75 Hi guys, I've found one typo (0xa00 instead of 0xa000 at code comment) and v6 has it fixed. I bring my apologies for that, could you please review this patch once again. WBR, Vadim On Wed, Sep 27, 2017 at 11:20:39AM -0700, Vadim Lomovtsev wrote: > 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 > --- > v5 -> v6: comment typo fix: change 0xa00 to 0xa000 > > 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..ed6c76d 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 0xa000 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.4.11 >