Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751899AbdI2MWp (ORCPT ); Fri, 29 Sep 2017 08:22:45 -0400 Received: from mail-dm3nam03on0080.outbound.protection.outlook.com ([104.47.41.80]:23808 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750954AbdI2MWn (ORCPT ); Fri, 29 Sep 2017 08:22:43 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Vadim.Lomovtsev@cavium.com; Date: Fri, 29 Sep 2017 05:22:38 -0700 From: Vadim Lomovtsev To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Wilson.Snyder@cavium.com, alex.williamson@redhat.com Subject: Re: [PATCH v6] PCI: quirks: update Cavium ThunderX ACS quirk implementation Message-ID: <20170929122238.GA527@localhost.localdomain> References: <1506344920-24016-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> <1506536439-29318-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> <20170927141854.2ff65c73@w520.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170927141854.2ff65c73@w520.home> User-Agent: Mutt/1.6.1 (2016-04-27) X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: MWHPR12CA0044.namprd12.prod.outlook.com (10.172.49.30) To DM5PR07MB3002.namprd07.prod.outlook.com (10.172.87.140) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed0b5df6-b61b-4a79-ab0e-08d50734c80c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075);SRVR:DM5PR07MB3002; X-Microsoft-Exchange-Diagnostics: 1;DM5PR07MB3002;3:ccpXm+V+Y8fmwjiUUK0NeZt2gQMw1hUEz22CXi0y+wU9pr+Jurf7YwlOMQ5oZJcx+HHhP0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XtL+r5H0lLaslTK/utDe3YAu7VehOSq+gG+ZMUppuYIvTYoLHQ9jjMG8/Xz7yklIoFj/+jd7XKi4CHRtwS3mYCIm2lbn0fKxofabFVpUctcOABJLJHPAp5EaMrB9DiGig9FNUZC3zhMBSNXtUEpVQIj4FV7W/Oc/3h0UqVz3cWpQEHZQb7d8CEHImAc5DDR3+KlWolKQ6FFy5qn9djv9eRcksB0wKS0MODeUAlw/2bnPTc7QUAkwySRbHM7DsGOOVSuhpKNOpud+i7RHYBiDYr2C30pN4KyROEPX80LtvvLSOjSqbo4OhbHKbJgFD7cy1xsmoyvVwAATckfktmS4og9utHCUWJIkK6LyyFZg10CQy3wbkrnakEiIhgVKqUw=;4:auDcmcP1mwT4YdFdG0fOQSWRxtfgendVVoNfd6n9NdD6CaI/lAGlbdZ8FZ0FDpy+dpX5q9Vxf83QxyT267D4M9/mNQXM+O/buAaCk67noCh36vt65Q9errCjbV9gqSFezNj6BEzS3idYmgV2hvkRiRWEX5xu6eB7TNcOahm5Z3xNRi7T7MgUHlL+CtH5AflPE6WYr7elbHhxDX+kkqywyOxXF5FgWUjr23SLu06TT3g4w37pMlt3V0uN/JwFKtPy 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)(20161123564025)(20161123562025)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM5PR07MB3002;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM5PR07MB3002; X-Forefront-PRVS: 0445A82F82 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6069001)(376002)(346002)(199003)(189002)(24454002)(66066001)(4326008)(2906002)(575784001)(47776003)(305945005)(229853002)(106356001)(50986999)(16586007)(58126008)(101416001)(7736002)(76176999)(16526017)(6506006)(97736004)(83506001)(478600001)(5660300001)(316002)(54356999)(2950100002)(6666003)(25786009)(55016002)(68736007)(53936002)(3846002)(33656002)(1076002)(6116002)(42882006)(72206003)(81156014)(9686003)(81166006)(8676002)(6916009)(6246003)(23726003)(50466002)(189998001)(2361001)(2351001)(8936002)(105586002)(61506002)(15650500001)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR07MB3002;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM5PR07MB3002;23:yRaBN6zh9WuSjt3qSE0pOIAL8qQP/jsoj+1xYJqDn?= =?us-ascii?Q?9MAbVxYduWTFUIxxwlMYfl2K2su/1W6bHbEESbMlM4WlAisehJcTYWyRCyxf?= =?us-ascii?Q?djb2M+QxTX3v5OkeJspsOHF+HdCRtFiLyDr2JH+dY/RVVeEn8XAQllTON//0?= =?us-ascii?Q?A0vvMr4IRoRyd9YBi3aOEUqr222iV3GMPy8oUnqV6/hX1b6EhwPHAc93kUKt?= =?us-ascii?Q?32u5uYMS9iqWBbrWpesUA8wQuBMS+VKLVIR7i0WI+uDoH3pV/AKqMUUNxvTR?= =?us-ascii?Q?pLbmfIsWLcmvvi9terueEYnesZD+UNc8BjMWXxrZQT4Od0CXrTf6b9XIH75c?= =?us-ascii?Q?Fg+PM8txh7O/hTC6DxGFiZQ2kb15q4mc7Bghf9cAUITWK4RvzMW3min8kmLV?= =?us-ascii?Q?hciqIHZ3HxmfDukYw4gfmZa/ynoCTZWCmdF9eJDtns3djEUWTpyvrhTXePQG?= =?us-ascii?Q?30unfBMDTE+pvofo/BZtAlSykrmm6x6Xx6qd/kDwUAFpAhXQChrzTNe5LSSS?= =?us-ascii?Q?tp2yC4YPJ6+t7Mg1qNMYg7fe6yjGJkfVe20ntxEak2RzoueG4dxWV7vMs4Ic?= =?us-ascii?Q?qI0RU1TT4uwbT6ukZhAbXu2hVCAX0j8N3LcqqmMSi4FlPxcajfXs462jjLWH?= =?us-ascii?Q?ap9iR6Ny2dtPbTH63MwriEbsjh7vicf1ssPvrMNUaeZegTmwrl0B2YzsrhgS?= =?us-ascii?Q?8y/pVkkvN8d/zO9btkBz5TnX26LyYFv/7uMyNezAa6TJgbxLB/IOsGzDDNjg?= =?us-ascii?Q?0TY5ruW/S+SP72DSmJMykdJTtggtADij8ByxYok5sYbJlF0hDTwQ/4QqZD1u?= =?us-ascii?Q?dOo1ptQPBFLhKUj3o6LgHbctw5cifcnEBPP2qyz4E86lHNDD93jZD12u/YCp?= =?us-ascii?Q?gPhaQW6R7yI4tISovQhS8NmrbOR6CXWo3/KFV4xDh5N77fu/bMiBFVP8qLef?= =?us-ascii?Q?ssCs05vFoPrlW2CT22eKZHSNZTeM55V9hy/Ds0NfsaFCpyynNOY/Be6GCz07?= =?us-ascii?Q?OM3iSPpfrvApoOWIlQKmEuN5kSIuQE2DXpFupyCnyj/p7+pUtES2iPxwJ0zc?= =?us-ascii?Q?VUIkHI7rq+M1puxpPu3fEtljG6meqgpv/PsXjNDGImWQU2CUPHt6JZKbv3tW?= =?us-ascii?Q?6y0qmaIfd4cKvTEnZqAYC/hJPWV5ws7JUMaCylPYzABi9Yn6a0ede6ABjiYE?= =?us-ascii?Q?xfiTAOG7Kx7PVlkbBTqcaCDZAnjGxCqpeLOhP7FtGIBtu+69ju10ekah64E/?= =?us-ascii?Q?FAf2gxjQbMXDDMFo/ePx3+6c/BNiysyp7A3051nXtgmGChB9wuHFcWjLXqy8?= =?us-ascii?Q?HeOuLomSSlENDid3XAk8zo=3D?= X-Microsoft-Exchange-Diagnostics: 1;DM5PR07MB3002;6:dU5aSXPHuRaDuA5XQ1fcrl2XG9dnzXXNLYmf9IhiLGf4LyP445QCYHWw8Sn9oj7+xjP//ukWcPV/kXOxr5oRIxKU5Z13yh5rp70HT1IRjHYzqR5UKoXGP4aUT7lCbkBktY6y2nBXNukNnkbxGIOZSXz94Py31utmwXb6nB/6pihc3nr/qCvD22TLFbq9OZX8bqJd5uS4vpAgcgWI+5oB1tv38qYjaCA2wQPpsp+vcPoRKUoSv9Q7XZSEzxTcSguelMX0jAa+AGrnXHhrcDTwJGMsBFN5UtOvEUvkcIyXg/IDsjxYnpcXXWZcb4raawb0WsC9YotE1i2l/OZwMLIwpw==;5:fiU0j+gOaTLhAnqFndRABzv14MtNv5raXzRiZjTqZL9U/fRpX7UYsXE9HICe4vnvGPm/cPBaieOKbhqvBNm8seIS2F3Wd6uCbXMr4C7Qxw5T8PXqFqYTtvBgTdJIspoI/7NCqjGF5orQfd0kQXrxMg==;24:n+6lXPPTLy1NLFj40Jk7S8fo03Smu1UXEAAxl8XzWzzoksHmz94D15auifec4MU3/OMxJFfxuPLDEZKwbaJh3YAnrlOum7FrkJWGtyxhLG8=;7:KAQbgUqVfNzJCHlsrZs/VAysaPQgBqTUchorJzW4hNy4YT3zQvAdZ+qMMz6gZpBSMiqsrFt57jt1z+7QlukdIWmHbYW/jAA0UEb9y9QWPnTdTd/4gkeuCVLiUxK8VnZVt3EIb1EI8kHdbozwRsLnt04pPHAWEBDO6mYMWR/CuL6kaXDXHPFtXuNoaw2rb4qp/1QFtH0mXQiAu97WIaWg7fnlhtdgoR5yMHRVr3Ijcgo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2017 12:22:41.4072 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3002 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3190 Lines: 79 Hi Bjorn, On Wed, Sep 27, 2017 at 02:18:54PM -0600, Alex Williamson wrote: > On Wed, 27 Sep 2017 11:20:39 -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 > > Reviewed-by: Alex Williamson > If there is no any objections, could you please take this patch ? WBR, Vadim > > > 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) >