Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031333AbdIZPXj (ORCPT ); Tue, 26 Sep 2017 11:23:39 -0400 Received: from mail-co1nam03on0081.outbound.protection.outlook.com ([104.47.40.81]:39396 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S964826AbdIZPXg (ORCPT ); Tue, 26 Sep 2017 11:23:36 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Vadim.Lomovtsev@cavium.com; Date: Tue, 26 Sep 2017 08:23:27 -0700 From: Vadim Lomovtsev To: linux-kernel@vger.kernel.org, alex.williamson@redhat.com, bhelgaas@google.com, linux-pci@vger.kernel.org Cc: Wilson.Snyder@cavium.com, jcm@redhat.com, Vadim.Lomovtsev@cavium.com Subject: Re: [PATCH v5] PCI: quirks: update Cavium ThunderX ACS quirk implementation Message-ID: <20170926152327.GA26588@localhost.localdomain> References: <1505724481-28413-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> <1506344920-24016-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: <1506344920-24016-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: YQBPR0101CA0032.CANPRD01.PROD.OUTLOOK.COM (52.132.64.45) To BN6PR07MB2994.namprd07.prod.outlook.com (10.172.106.12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 481d307b-8c77-4e9a-171a-08d504f28d38 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075);SRVR:BN6PR07MB2994; X-Microsoft-Exchange-Diagnostics: 1;BN6PR07MB2994;3:UD2kx/gPnLSVRalUEhvJyY0ALvg/P/z7kFY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W6CpMYqWeOQBYe0w8uB43VniYmMHX71ur+4Tz62oGZiW0cxVQt7TwO/YMicgOe+dR5h6duNnC/HxlxtLXxrMR95L0ABejd4+kVtqk0nhcT/s7/0E5OyxkGMAhnjVrph9BEWUjs1WONpyGk3PnGoApo42rfXPrV+DUJCJSPczOf16WZkltYplC4t8ZHM/V/hE402ao9V2DEJXmvAs8amRroEKCsNwauN3fKxp+YJCXZ0exLbqE1m/JnvGWx8xaMLKnY0enKyGYNCHe4ahEeW9xYjFOeacQbNMTM7P2Ybrq/dK6iM9rhfnMDj93jAdoW0hRdwOxNXVFgI4wy2oowdDi1E1E4kVl+elXE6OE18WEnCzLtry7MWfEgJ72zhh3Hs1veQiIghp5CIomnvpt9k+BIG05BX/C7EBQo/CJFFDUL4=;4:n0+99yLc51uNzE81K+WEguq7zIiG5ZMWDjAKlEFct/9sHh6tIMSRKmlnWQhjxXAQJlu9ealHg2HD40hN6h1jsxL9YkrDb7NjF4ToHbS5RT/eR7KBMqVNLBCIcEIEWCrKPsR9mwjdt3+ETfkQiIb0PM8JvNHE5RvikjylNyP+2xS1647Lm6mg35w7Qfk5jL1wz3Nk8h3UILhcO8TqnoVJy1cuDokXFCS3oFd1jfgcqewL9SmejFY9a7pKqXpmf8Ob 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)(3002001)(10201501046)(100000703101)(100105400095)(93006095)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(20161123562025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN6PR07MB2994;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN6PR07MB2994; X-Forefront-PRVS: 0442E569BC X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(6009001)(346002)(376002)(24454002)(199003)(189002)(50986999)(6666003)(101416001)(105586002)(58126008)(16526017)(4326008)(575784001)(68736007)(2906002)(189998001)(83506001)(15650500001)(61506002)(106356001)(5660300001)(229853002)(97736004)(66066001)(81156014)(305945005)(1076002)(8676002)(25786009)(2950100002)(42882006)(3846002)(33656002)(6116002)(6506006)(23726003)(107886003)(81166006)(47776003)(54356999)(50466002)(76176999)(53936002)(55016002)(316002)(16586007)(8936002)(72206003)(9686003)(6246003)(478600001)(7736002)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR07MB2994;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR07MB2994;23:n2niVTYtF4bp8bohY9d7jCNCfrKXov4zW6ezRTksW?= =?us-ascii?Q?fiKSzmIHDez+9FAReunX9Y4nFNGs7Qxym3bgLSPgRvuCfjaiLAaPHfMRL38Y?= =?us-ascii?Q?J6iHlLKZli/91wOmkNTYO8RBhGtHl0lUSGthy7T9P06Mle/FjTIdS1EN1rMH?= =?us-ascii?Q?CKmK3/9dwXzuLiASlS9pJ0LfN1AUvWtZSmteQQIBE2CUhii5aJrWw3MPtl8M?= =?us-ascii?Q?1Ju1vw5ir8ktrt1uCiOBeuDVpuLo+86GAG+euj0FxIzyQCQEQAD6YhPuh8/e?= =?us-ascii?Q?Mm0w3HcRZ35HzzAQe3BbKtiPQZNidIvJlhy5c8yqv6jZ9TcwUJYIyz4WGDxk?= =?us-ascii?Q?RtyJe6mS0RQCwMTOp4OYI4ZJuS2kO2kWqLfpNM7rwQ+NpTMqUJ7188B9HYlq?= =?us-ascii?Q?LXQTdUHVXtyIwECUoAISWlVZuokPVurDV0MHEdN1SGwkwWq1mpsa6PaHsuye?= =?us-ascii?Q?z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JIfWOVJFwNZ5BZ/dO5NvM/LnY2hvr/YR1DBG23LG5YrAJ31y61TIkzkLckUENR18VxNsfv+YbQZ1qb+A+A9L5J8vnmQy5PI0aPXWN1gmj07EXpUb3UlVmEaYrmKXCeAYPya363yR+7+YOuFYKBA8OeKnppyPaGQlqUnh8W8dVX7P7p7FlzbKSvRuBPOcB0Z9ls2yy1S8YgL6c68tQXccoANF+XyU10IMPB7FLJJySGNlG2YXmQFa/08CNqPBw7yPtoSDtK1Za1tATX/pqutzrrgMBY3mhHDFTW0v7KyZX5vsrF1S4ZQ==;5:FP6XP0C6cwkhml/Fr2/VRqm9oIig0zmnAtIue30QROacN4fgLcdJbemHEgW70njw+qcn/Wq4mfR7OhHtS0bdIxcn5eBTfK/H3hRSTPLmIHUyYLJh8Z866gcAHRI+IFw74VxwEH59IS1I/K2TfWFE0w==;24:g5Fedck3xp03sxGEaKvZe3w4WuKMVriW37HXGpCAW4dEmS90tru+/ez3c/2m+TIH02Wohc0zfUmgZoQf2wUMZxFwMa1Ml2Cq5d+o14S9yi8=;7:Il4h6N58f5+XEuu9rzwqgm/4i59ZrFijjsTdPB5t8vQyE/0yerIDhho1uA7y2ukjtxZ2bjh7uWPdjjuiw9m2Hc0+V5IPjVA+gFH5iG8ocNotb8cpfmKsoS17/cMEFa1FcBo40Q9uKdHibQONjAweWfTThZTN4ZvvWfyRyObNZMRpkvcAGXruLZjpVJkjKQd/qKW7QI1IMUj74lpV/3eZ8Ln1fOZNEetMdM+mdc1pcWg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2017 15:23:33.0028 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB2994 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3013 Lines: 77 Hi guys, Could you please consider to review following patch? For v5 changes: - ACS mask comment has been updated. - comment has been added for device id filtering mask at match function to provide explantion of CN8xxx devid scheme. WBR, Vadim On Mon, Sep 25, 2017 at 06:08:40AM -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 > --- > 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..0fd2e15 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 0xa00 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.9.5 >