Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751740AbdIMLhp (ORCPT ); Wed, 13 Sep 2017 07:37:45 -0400 Received: from mail-co1nam03on0074.outbound.protection.outlook.com ([104.47.40.74]:41408 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751015AbdIMLhm (ORCPT ); Wed, 13 Sep 2017 07:37:42 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Vadim.Lomovtsev@cavium.com; Date: Wed, 13 Sep 2017 04:37:36 -0700 From: Vadim Lomovtsev To: Alex Williamson Cc: bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, David.Daney@cavium.com, jcm@redhat.com, Robert.Richter@cavium.com, Wilson.Snyder@cavium.com, Jayachandran.Nair@cavium.com Subject: Re: [PATCH] PCI: quirks: update cavium ACS quirk implementation Message-ID: <20170913113736.GA17702@localhost.localdomain> References: <1505217316-15702-1-git-send-email-Vadim.Lomovtsev@caviumnetworks.com> <20170912101545.01977624@t450s.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170912101545.01977624@t450s.home> User-Agent: Mutt/1.6.1 (2016-04-27) X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: MWHPR18CA0030.namprd18.prod.outlook.com (10.175.9.144) To CY4PR07MB2999.namprd07.prod.outlook.com (10.172.116.13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 85056825-029a-4a96-07ce-08d4fa9bd7a4 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CY4PR07MB2999; X-Microsoft-Exchange-Diagnostics: 1;CY4P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AX50tGJZuu6lRqdsWdwyHUOEV4OiljOB+GWGiR4CRMTUlJID9897EJ7iNvWelPTvQ2W5JSHcjjFQWYB/KNxM+MAs686DA2nXtWY9QKDWBlAHSJbYUJhZMZCLUAg8DCyBmAOUYW/3wtL1C/Gi5ni/lTtF5xg4+1cYMcVbbrgH3D1NbqlOS9PFo0IleuQnRKMSRXVHKXCeLEYFHY5CebY/pig30lcxaVAoaVtJUDCgn3m7d2MHpbNP2ojbAlG325rC/wZfJSQ9KaNNE46tgHZoXH6t9zuJCGrrCB5yvTCvAHFJ9+ybbqwwiUFgC156yID6krrMlMChZzAM6cjnYzLJXbkrn9SzkxJ+gxLObS5bwwoJowhZz/O+HsMphDgjrFjhpTD7/r7SGSgBWYP1wXQ2j6Vx3mKM/+TAFVt6uHecElBBUxthr0+s4yXfBSLVKEP+Rn3caoUobm0=;4:M0TQbJwR48W3tx/2nkSiuunyEpiyHERODocPhJnzlheZsL4Gs7Qysn7vSJgNIq/y5k8nWHlOxA51h3oJX93hxN4RzETpfHxk61zAvgihAQa4PuJ05cQseJCSBoSTbwLBe/kQxZzwx0Kkj7oVpCzGI0XDJu/71zxTCj8cCa0lK1Q2KzmFyYYA8rWGNy74EIhzQr2QOuofU5Z5kZnt3pgKfd5AkmVMaJoWdahWkCt9iVKqn9DP5P+APONhohxhSbSZ 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)(10201501046)(3002001)(100000703101)(100105400095)(93006095)(6041248)(20161123562025)(20161123558100)(20161123560025)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR07MB2999;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR07MB2999; X-Forefront-PRVS: 042957ACD7 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(6009001)(346002)(366002)(376002)(189002)(199003)(24454002)(1076002)(5660300001)(101416001)(6666003)(106356001)(105586002)(551934003)(15650500001)(53936002)(97736004)(6246003)(50986999)(76176999)(54356999)(9686003)(189998001)(2950100002)(42882006)(55016002)(47776003)(6916009)(305945005)(2906002)(316002)(229853002)(68736007)(16526017)(66066001)(7736002)(478600001)(72206003)(33656002)(4326008)(8936002)(50466002)(3846002)(81166006)(25786009)(6116002)(23726003)(4001350100001)(61506002)(83506001)(107886003)(81156014)(575784001)(110136004)(6506006)(8676002)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR07MB2999;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR07MB2999;23:XoijEiXLXLpks4UDKNCUZAs/2GuU8m20BvTvnIOr2?= =?us-ascii?Q?1E8BYZ9m2bF2jCPNPUPx5T0508TGPRaUbckag9w5pWINi7MyJJi8pNt8pnDv?= =?us-ascii?Q?ZcJmnhyepI3HrihGtcJXG7y7VtBfWtCQOpPopXgVnTnVuUH4KAgaWsEKc6xy?= =?us-ascii?Q?RjHilGHD0T88lM1bCU2A5ZWT1uHX3UY4cdKUXhWLU36Nox1ALfcwOUEz6krt?= =?us-ascii?Q?B0JTiqeQQtQtMOuxuny8gaUNWYwSkg4L6Jxxcr2yFAFpk14K+Pdrq7PzUWRA?= =?us-ascii?Q?EKV9KaD3dO4d/zeiuw9yk7if2H8i/4qf+asWsFqCoFHpVo/QxVWOYy5mULGI?= =?us-ascii?Q?Z11RLI4pKxs49C9HPSOCqPPdUJouAbpFevwBsxyyv86k3CyXquNWJ6ns3h83?= =?us-ascii?Q?k+X/AjwzXc2GkFu0ujkraNeW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iqVHug4TRQVovGzuSbN3a8S5OVhzTgfO7eyTIv1DCUoeUAPQ7Clf+hA4?= =?us-ascii?Q?bwDYw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;CY4PR07MB2999;6:zMd45BgTomIbXQVmmbn/I0SaHyPauJQ/PrgAXJcP8qoZqINstIYfg9tlmpMlnGINZZmYaeL/P7bTqfWgGw8TZtnqPrFBruqpumYOQH53FDwCTZTi3x+F9A7iupk/ETQNMSCEYCRpPQ1LZJOd+5EJlFAiqQ0AjhNoIktk6Q47OG3EMSJmeK9ojYmP3kB65yw4q/RaTZPmfhkZY87I5L2gS6kzu8obrsQAYNxDu4wqQFen2riaNz8FA4qUH6f7tyKqPKSnabfGT34fwnAZct5KWJ9S1ijn1gEE4UTM+WbNYULr/uv/4udW8hmtKrwxSrd0QcgkoRFYAE3u4Q+3tU2hOw==;5:IY+34oF+R39GkYZ1pGuB6BbuSFkSski1aPLR3r7KbGpr0KSgwuD6n14dpoK5fLhXKkogElkxb2ef08IwiJvF3sSlKvI8aVLgdTipcnv00+Zv4jyhaEq2uLQDmcOq522oIIr46rmCFRU0Yf++oXVT6g==;24:VJzByy6zPfN/EKkeM60IeapsNrS74CIwrpSTlkQ+zUYeYNAkpO939laC13tfGTRuAzVKYYlQvnpRs7DXeQ9rdzLuK3I9cBJvC0iqkio2SFo=;7:mWAMiRsg6Hl+HHsMu3TsiB1J7LwMXpIUZlBsknoFkadOxHrt0RNjYcczkI0ECy3jc3pFFo/IRmd2XO3ztOS4hasObNP8j/65wFUpSO5zlKaFPpzRBdcis+TT48P3XK8m4JeDeSRD2QMnLCPPmqTGxnEBgfp5lKdUzxYvnKlxC9HgzdkWM4enBFt7LbN0TkqZ9yICLKjHqFfNNGJ0DhJvRA9HVqkuBWatCJr8RMPfFZA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2017 11:37:40.5339 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB2999 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4271 Lines: 104 On Tue, Sep 12, 2017 at 10:15:45AM -0600, Alex Williamson wrote: > On Tue, 12 Sep 2017 04:55:16 -0700 > Vadim Lomovtsev wrote: > > > This commit makes PIC ACS quirk applicable only to Cavium PCIE devices > > and Cavium PCIE Root Ports which has limited PCI capabilities in terms > > of no ACS support. Match function checks for ACS support and exact ACS > > bits set at the device capabilities. > > Also by this commit we get rid off device ID range values checkings. > > > > Signed-off-by: Vadim Lomovtsev > > --- > > drivers/pci/quirks.c | 30 +++++++++++++++++++++++++----- > > 1 file changed, 25 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c > > index a4d3361..11ca951 100644 > > --- a/drivers/pci/quirks.c > > +++ b/drivers/pci/quirks.c > > @@ -4211,6 +4211,29 @@ static int pci_quirk_amd_sb_acs(struct pci_dev *dev, u16 acs_flags) > > #endif > > } > > > > +#define CAVIUM_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) > > +{ > > + int pos = 0; > > + u32 caps = 0; > > + > > + /* Filter out a few obvious non-matches first */ > > + if (!pci_is_pcie(dev) || pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) > > + return false; > > + > > + /* Get the ACS caps offset */ > > + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS); > > + if (pos) { > > + pci_read_config_dword(dev, pos + PCI_ACS_CAP, &caps); > > + /* If we have no such bits set, then we will need a quirk */ > > + return ((caps & CAVIUM_ACS_FLAGS) != CAVIUM_ACS_FLAGS); > > + } > > + > > + return true; > > +} > > + > > static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags) > > { > > /* > > @@ -4218,13 +4241,10 @@ static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags) > > * 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); > > - > > - if (!((dev->device >= 0xa000) && (dev->device <= 0xa0ff))) > > + if (!pci_quirk_cavium_acs_match(dev)) > > return -ENOTTY; > > > > - return acs_flags ? 0 : 1; > > + return acs_flags & ~(CAVIUM_ACS_FLAGS) ? 0 : 1; > > } > > > > static int pci_quirk_xgene_acs(struct pci_dev *dev, u16 acs_flags) > > No please. As I read it, this is assuming that any Cavium PCIe root > port supports the equivalent isolation flags. Do you have a crystal > ball to know about all the future PCIe root ports that Cavium is going > to ship? Well, yes, my bad then. Would the check for exact device id (or some range) of pcie device/root port be more suitable here (as it is implemented for other vendors) ? > Quirk the devices you can verify support the equivalent > isolation capabilities and solve this problem automatically for future > devices by implementing ACS in hardware. No free pass for all future > hardware, especially not one that overrides the hardware potentially > implementing ACS in the future and ignoring it if it's not sufficient. > We're actually trying to be diligent to test for isolation and this > entirely ignores that. > > Also, as we've been through with APM, how do you justify each of these > ACS flags? Claiming that a device does not support peer-to-peer does > not automatically justify Source Validation. What feature of your > hardware allows you to claim that? How does a root port that does not > support P2P imply anything about Transaction Blocking? What about > Direct Translated P2P? If the device doesn't support P2P, doesn't that > mean it shouldn't claim DT? Like the attempted APM quirk, I think this > original quirk here has just taken and misapplied the mask we use for > multifunction devices where downstream ports have much different > requirements for ACS. Thanks, My understanding that CN81xx/83xx/88xx pcie bridges/root ports has no ACS support. And the original mask was constructed in that way erroneously copied I guess. Would the resetting of RR/CR/UF/SV bits be more correct here ? > > Alex WBR, Vadim