Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751858AbdIOTUF (ORCPT ); Fri, 15 Sep 2017 15:20:05 -0400 Received: from mail-sn1nam02on0061.outbound.protection.outlook.com ([104.47.36.61]:57264 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751782AbdIOTUD (ORCPT ); Fri, 15 Sep 2017 15:20:03 -0400 From: "Lomovtsev, Vadim" To: "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "alex.williamson@redhat.com" CC: "Snyder, Wilson" , "Daney, David" , "jcm@redhat.com" Subject: Re: [PATCH v3] PCI: quirks: update Cavium ThunderX ACS quirk implementation Thread-Topic: [PATCH v3] PCI: quirks: update Cavium ThunderX ACS quirk implementation Thread-Index: AQHTLiI2jkN1YRcHUU29B3qG+Kyr8aK2Tpx8 Date: Fri, 15 Sep 2017 19:20:01 +0000 Message-ID: References: <1505217316-15702-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com>,<1505480233-22694-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> In-Reply-To: <1505480233-22694-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Vadim.Lomovtsev@cavium.com; x-originating-ip: [5.3.192.156] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR07MB2937;6:jRnb15jUDY6k9qrFsnAKljCj/GJ1+dz3zMg7mNh3rHgR2e8c8TroxUoIfWiBc8W7lb+zJSsf1nLo4paHX0bJt14Iax0QD11O+KT45fRbh6l1nnAKubTVU6LffccWQmnAzkvn7CzWgK8EbpShaO6zxPCRTmcTmK844Lfqnf+HGaCXGkMpKIFXzY4sqhlhyehlo0eDqUXHo5tQeGu3bbVUcPIHo2w3Dm96oeqa4KFXqu06y6L5c9/03Inbcq+8Lkr/sAgGWB0NXhBEyR8/gILV5Lz70RvJz1jtgtuxRDm2mx9iQh1wdGt+7A7GAHwZrw08x+ZsuoGcJopd1rEc/TPGFA==;5:W4Qf22kUrxLLSgWQbhjuukxRqwmH4tVPrTjxEInx5a5enXDsRNP0/dZy3k/y+s4M/prjdqxaSPuC7ugR/3Xc7kM0ZDRSDxtmiyrzSoEt8VQdclEBBX2dznDbyFP56Hzi4UrQnuasv7+i3j++bDF2mQ==;24:oWQyz/HQjcfWsKwqc4BCaABM41WBvmU2lsEi7tJfKX7YLYUJk8Zx4EbTwn8yGzylmWkvT1z3UKvnznvj9hP4bub4js+lypW7H+zeZY81lDQ=;7:l8FuQpi68SWUIgaj3q5vmJVl6ueA3tnVOkxn5iK5hbbwDpz1qa4YSL/RDII1riHsXpvJJa4N2tMHFg1ERiSe0GHvfnNsecs41KZBjCbHe6b5CghlANCWsmPMA8/k/NqzlHmZSkxdTZHOY2yOKhdCq7gHz+U5CnNXJ82lMCUzeuXaLtz6oOF1CGyN2fr2aVvoBPc5UAwCXNb2YUst6UYk5lomxMPE586DjT9yULRcVR4= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10009020)(979002)(6009001)(376002)(346002)(189002)(199003)(377454003)(2201001)(305945005)(7736002)(316002)(68736007)(551934003)(8936002)(8676002)(478600001)(81166006)(81156014)(99286003)(53936002)(575784001)(6246003)(15650500001)(55016002)(25786009)(86362001)(9686003)(54906002)(4326008)(6306002)(66066001)(72206003)(74316002)(34040400001)(33656002)(2950100002)(229853002)(3660700001)(6436002)(3280700002)(2906002)(2900100001)(77096006)(102836003)(3846002)(2501003)(76176999)(6116002)(7696004)(189998001)(105586002)(50986999)(54356999)(106356001)(97736004)(5660300001)(101416001)(71446004)(14454004)(53546010)(966005)(6506006)(21314002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR07MB2937;H:DM5PR07MB3002.namprd07.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-correlation-id: da1cb2a1-7372-46ed-238f-08d4fc6ec303 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:DM5PR07MB2937; x-ms-traffictypediagnostic: DM5PR07MB2937: x-exchange-antispam-report-test: UriScan:(9452136761055)(211936372134217); 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)(93001095)(100000703101)(100105400095)(3002001)(10201501046)(920507026)(6041248)(20161123555025)(20161123562025)(20161123558100)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM5PR07MB2937;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM5PR07MB2937; x-forefront-prvs: 0431F981D8 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Sep 2017 19:20:01.2572 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB2937 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v8FJK9dL021335 Content-Length: 5414 Lines: 119 Hi guys, Sorry for wasting your time by getting back to this. Please correct me if I'm wrong,... So far it might fall into same discussion as happened here: https://lkml.org/lkml/2017/8/1/559 And to provided ACS mask I've already got a comment before for initial patch that it is not correct because it violates the spec. > +#define CAVIUM_CN8XXX_ACS_FLAGS (PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR | \ > + PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT) So from that point the proper mask is expected to be as following: > (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_SV) which should be enough to provide proper device isolation. and based on that it appears to got self-nack here. Are there any other comments on this ? Going to prepare and test v4 of patch. Sorry again for inconvenience. WBR, Vadim ________________________________________ From: Lomovtsev, Vadim Sent: Friday, September 15, 2017 3:57:13 PM To: bhelgaas@google.com; linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org; alex.williamson@redhat.com Cc: Snyder, Wilson; Daney, David; jcm@redhat.com; Lomovtsev, Vadim Subject: [PATCH v3] PCI: quirks: update Cavium ThunderX ACS quirk implementation 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 redirection, blocking and validation features enabled. Following settings are enforced by hardware on 8xxx although it does not have ACS: $PCCBR_XXX_ACS_CAP_CTL (as if it present) --------------------------------------------------------------------------------------------------------- Bit Field Field Reset Typical Field Pos Name Type Value Value Description --------------------------------------------------------------------------------------------------------- <31:23> -- RAZ -- -- Reserved. <22> DTE R/W 0 -- ACS direct translated P2P enable. Value ignored by hardware. <21> ECE RO 0 0 ACS P2P egress control enable. Always clear. <20> UFE R/W 0 -- ACS upstream forwarding enable. Value ignored by hardware. <19> CRE R/W 0 -- ACS completion redirect enable. Value ignored by hardware. <18> RRE R/W 0 -- ACS P2P request redirect enable. Value ignored by hardware. <17> TBE R/W 0 -- ACS transaction blocking enable. Value ignored by hardware. <16> SVE R/W 0 -- ACS source validation enable. Value ignored by hardware. <15:8> ECVS RO 0x0 0x0 Egress control vector size. Always zero. <7> -- RAZ -- -- Reserved. <6> DT RO 1 1 ACS direct translated P2P. Always set. <5> EC RO 0 0 ACS P2P egress control. Always clear. <4> UF RO 1 1 ACS upstream forwarding. Always set. <3> CR RO 1 1 ACS completion redirect. Always set. <2> RR RO 1 1 ACS P2P request redirect. Always set. <1> TB RO 1 1 ACS transaction blocking. Always set. <0> SV RO 1 1 ACS source validation. Always set. --------------------------------------------------------------------------------------------------------- Signed-off-by: Vadim Lomovtsev --- drivers/pci/quirks.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index a4d3361..f1786a5 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -4211,20 +4211,28 @@ 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 CN8XXX on-chip devices' PCCBR's do not advertise + * ACS, although the RTL internally implements similar protections as to + * if ACS had completion redirection, blocking and validation features + * enabled. + */ +#define CAVIUM_CN8XXX_ACS_FLAGS (PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR | \ + PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT) + +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) -- 2.9.5