Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751973AbdIUIjc (ORCPT ); Thu, 21 Sep 2017 04:39:32 -0400 Received: from mail-sn1nam02on0069.outbound.protection.outlook.com ([104.47.36.69]:45280 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751635AbdIUIja (ORCPT ); Thu, 21 Sep 2017 04:39:30 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Vadim.Lomovtsev@cavium.com; Date: Thu, 21 Sep 2017 01:39:21 -0700 From: Vadim Lomovtsev To: Alex Williamson Cc: bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Wilson.Snyder@cavium.com, jcm@redhat.com Subject: Re: [PATCH v4] PCI: quirks: update Cavium ThunderX ACS quirk implementation Message-ID: <20170921083921.GA2135@localhost.localdomain> References: <1505480233-22694-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> <1505724481-28413-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> <20170920103151.7e3fdb77@w520.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170920103151.7e3fdb77@w520.home> User-Agent: Mutt/1.6.1 (2016-04-27) X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: BN6PR1301CA0006.namprd13.prod.outlook.com (10.174.84.147) To BN6PR07MB2996.namprd07.prod.outlook.com (10.172.106.14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 60e4e1da-28e8-40b6-89eb-08d500cc4433 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:BN6PR07MB2996; X-Microsoft-Exchange-Di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wfWvwTIxdgZpJTmkgvn2AD4HiMXUKb2Twh0hBDPgX5aLP8ejETAm6MP1TCLvd7WB7yHiblX2fPXUPF+j1NDvk6VDQKeNqaXpQ2Cj7SMf+4EkGRscb5/cukAvGNS+/mTqY8FSA2Z+VTfMCspXWENq0/heaxDJ/NkRyACLTNsTtByLUV1T3nzRYIOwy4TD/qyyJTGgW39oXz2lrHG/KLM3a6LwbOzQNUdzpaD+hZq5byvQ869v6UgF6y2y8gvX3Sq0O0SoY5KCL8CtVpLiPcmrIlFo8CQH64E7jCfi1wsN1O6lNym7erNGxQ2FPypODgvpcL7XcYWuxrJwq7UTuLOGdw0nHWMbaIqBJ96J+Jq5V4+KTwxGrdXJoWJyEN1As9KqSwvZzHdpdt99opszdmVQMU4MDOzjb2EoZHhfCLUGfJdAWJB0s1h+EI7jSzxQMkGrMYOztfdoXPzk8CulelizLxptwYN1E0s=;4:NoN6Px06cV4RZz1MHMHbWPit2zP90S1RxYrL+ApE64vxEh7GNImADAmO+lgXXPxK8e44I72r9dgXCEKld/tBvHYajtbc1og+prMzbYOGzJedcizconyI3B2EV0oXwlmQFwqFovh1zeG4nubLOrnv91cuLMQXr2RzZLakVwUHsXZpWaESpiSA+v9JI+INNBdnbVqch8uwnrbB6a1rfiQv/7+LHCdnT9aff6uUp8BPwabY1ZKMPeMNzAqSSJnGhpQLmEWlqCfGG3p5AOY1oTEvsp4ORVjOEW7SNMlRZXc4Mlo= 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)(8121501046)(5005006)(10201501046)(3002001)(93006095)(100000703101)(100105400095)(6041248)(20161123560025)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN6PR07MB2996;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN6PR07MB2996; X-Forefront-PRVS: 04371797A5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6069001)(376002)(346002)(199003)(24454002)(189002)(2906002)(6246003)(6506006)(23726003)(81156014)(97736004)(3846002)(8936002)(105586002)(6116002)(106356001)(316002)(1076002)(55016002)(9686003)(7736002)(305945005)(58126008)(16586007)(16526017)(575784001)(61506002)(6666003)(83506001)(53936002)(81166006)(33656002)(66066001)(15650500001)(47776003)(478600001)(101416001)(54356999)(8676002)(25786009)(50986999)(76176999)(5660300001)(189998001)(229853002)(6916009)(50466002)(2950100002)(68736007)(42882006)(4326008)(72206003)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR07MB2996;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR07MB2996;23:aD6EQPeXGU+kdMTO0zX4IVGRWDtMJTgYmtiqvcNhm?= =?us-ascii?Q?Vj8MHLdC9hYMbp/u6I1alC15o9SuyKqtdkfdr8GS3KgEgWUC9Ym0rFyJm+Mm?= =?us-ascii?Q?VUBf/YnG3bYXwkVULlNi3/dTZewAE9NCtKH7s0HT0yokjKlUVlRFYmg1t3gk?= =?us-ascii?Q?63WQtPIBCNWyzPfoh/BUwEzv+8XaiEcBrNWO5myC6IkYEfLjMoe/BrhBU+Ns?= =?us-ascii?Q?bHkxq0Xi34PQQHk+nXIRNOOEvM3gRZabOiJKYxZY4ftL4PfD7r3Hq2pDyLyT?= =?us-ascii?Q?k2pahwtfwxRxhLeBsnHKTIKGDvAjIddVjq69pNYFQA88Ejy9Wp439cSxe3V4?= =?us-ascii?Q?sRH9XXhFp7/nci9PHIbThhYjfHcW1j6rIyhlxsXt5P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10ZCFD5gacw7wlSr?= X-Microsoft-Exchange-Diagnostics: 1;BN6PR07MB2996;6:uXyhv3iUEVKD/R/C4dsfAgBok52X7EgZt3QiGsOI14MESH+sz0HtoWKNWDl5RSeJkeq3RwDqKFlmAQkLg838mbTVtS7uFm4PfngGOfUfeHY42kipTVSFyhraIQDHBVr9TbE52S99PrWI4Eng9ws4Lartvb/5559fMhfNDYA0yYCyRoBdrkUiskhJwD9uSC0uOsYXt2j2lmhBTx+AbjWXEG5/8F1weHWYW7WNlzELxFKYOatBC8TGw+wj/onU0R0CozyxWreiaUoKvIw/sXrK2cJy7CSthFcX3behsN7rSx+Rs9iPvWIkBYQNrPSv0W4jmMy3v8hAiC0XAoIhHB1A/A==;5:/2/Gzht8u/ze9fR/D6rzW5HKbdhlhhcy5XLLoiTDErbZS0VgmjgUs/Pw0/c+I+pd0XoKDhms+pSqhV0QOy6Yf75w3VKPCasfE3cfJHPrhGVwUDP7M6OMLC+EA5jeZGv930g12BTyIniZgAdHlTpCoA==;24:szda/mZBdCmKjnUKLQjS9D292ix7mshzfZFujUzfYhpjX9j9HCwcHcSO2h/hXQS3DGItqsq+TuayUhUmety1+uGy1u2NMLPtNTRUAb4ep+k=;7:mM7Y17w/uB02Gr0B4fktusHnJWAvuLO4qagyD7fHuO8HHBYagY1i585Qk5jfLYCRXFY63WRzV8M126dn4PYSmcNCKTYuiTAElJCEUI3PT4WRh+x4JkS4enlMnE6UpNOJWIoZZrZZuyh/BQktdhVI1CN5jBAdhrzXR7T8rFI7Qd+uaUOmElQ/NktDsxHNdVhaLzDMG1rQRBq6JMoWMpk+FIndLC7kDw9Tz8CeSLMEjOo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2017 08:39:25.3943 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB2996 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4821 Lines: 114 On Wed, Sep 20, 2017 at 10:31:51AM -0600, Alex Williamson wrote: > On Mon, 18 Sep 2017 01:48:01 -0700 > Vadim Lomovtsev wrote: > > > 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. > > nit, put this down for later use.. > the description here still steals too much from the multifunction > quirk. description was just moved (and needs to be rewrited) since the orignal idea was just to extend quirk for all ThunderX family which has that limitation. Would the following be more suitable here: "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." ? > Multifunction devices can often support ACS with unimplemented > capabilities, which indicate that the device does not support the > behavior described by that capability bit. However, downstream ports > are required to implement certain ACS capabilities if they implement > ACS at all. So the code is actually asserting that the hardware > implements *and* enables equivalent ACS functionality for these flags. Yes it is. The hardware doesn't advertise ACS caps which is desing limitation, however it implements similar functionality to ACS provided flags which allows code to assert this. > > > + */ > > +#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)); > > That's effectively 2k device IDs, 0xa000-0xa7ff that you and Cavium are > vouching for ACS equivalent isolation. How many of these actually > exist? The PCI IDs database gets really sparse after the first 64 > entries. Internally are these device IDs allocated to programs based on > the same ASICs or is this just a slightly more restricted crystal ball > (ie. wishful thinking)? Thanks, The latter; this represents 8 SoCs, the lower 8 bits of the DEVID are used to indicate which subdevice is used within the SoC. Vadim > > Alex > > > +} > > > > - 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) >