From patchwork Wed Oct 16 23:52:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13839071 X-Patchwork-Delegate: bhelgaas@google.com Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2068.outbound.protection.outlook.com [40.107.94.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1946282FA for ; Wed, 16 Oct 2024 23:52:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729122759; cv=fail; b=krPKrhaUvJPPf8HjHax7TF0TVZDqoGuItWzBRt6Y4ZZGV6plyikj04KDFzb6GPLtM1QklgCXz+LenfMjEAs1wDt7RSBhgzxWbhkd3u6amhD7MFN7594uY7IlvUPyw2q6O2NPuv/ZLz/nOGBPZ11Acm5v5ufmb2IVm8fre2Se7Q4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729122759; c=relaxed/simple; bh=LkfXqd8po5VFWNVd/xXzhylIa3f0fR9945CNffAhd54=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=oup4g4GEUJmn9bQhegs8QnvVrmmlRMvONhwvRtV09fAeXGlDypHyB0sjl5BQ1B/lJqZRQDUPfwHhUbIYm6F1BEXdL2qC8BiNPQuVIFjq/nuvC+Da7KgtiQVkggwEMcc9xtCn1EpiMP2xawOddBlH57vSVQgsM4Jm9sMITu/DtqY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=BJEl/Ea8; arc=fail smtp.client-ip=40.107.94.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="BJEl/Ea8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LSzBIfzk6waicx9SYQw7i8TzFELXTy+PMqWupmUIEEhL7AvE/LpjaA3Pr25ks2nUrtLslVPR93o5Wsdb9hJ0KSRgtJjTA12MEURPQuMN7P9BWQNRIKjpRUbKKzLeTklOTd1RsDe+RMlEbO4M/tnYfmbba1eluCURFfdoZyPUCOpRM47DgTLIfTrf4zimmdGmZm4egXrpo4Za4uf9KnGJVwqlXEnxkI6LaswhJcqBLM18KzzAMYHv9rF5wD2fmqo0BFgiDE+/qMcic+9q1eHshuZzkBdgVA9jrC6y5cjMt5uUDr4DeXD2HIS3CFJXTTpzvzkl7d0gCKUCSSsV2fo/aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DvSCKW1BOhBZB9WEk0vv9a9K072sSJ/KNk1Tki33iI0=; b=IT1ZQ40Tf+H2hXwLaid/6AnJXZ80+d1cXgR/hJ/nVwEa1PNSWiuggP/5mchr+nIG+sQnDMqwdbDlEzYvvN5rv1OSUfgIBBlJPus43zG1gwLx1m7IYESqWhsdcx+XfAuGh55+Vj0yEBfEKsrquw4PfD5l0+4VwBxVaiFGfTQ5HawPHJQOXWeRoXNQPaiFZ46bouF+VjyqZLNa8UnxGS4MiETn9b12qW1gjN30s2d0MNWRO9gZ6sZpxeyVlefv46P9yP5/0UqtmeQkv7fOt+3hPBgcbrn52sKbceydGEtxT/wG2exhmtMF465YfdbkdSaD3ewh1Ei8dOoa9+zaXfog0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DvSCKW1BOhBZB9WEk0vv9a9K072sSJ/KNk1Tki33iI0=; b=BJEl/Ea8rNB6FVCyZ3BQ4e47+vARibRn/bGtu5UQnWAxXGqFt75r1aqz3pmXRoYw3FNkAU+bU81ggdhL//Nv384ZJVJQ8pVZoyaEgCQGvCk1Fa5IO3id+AGc6oe/XNShTp6B5T/xk0WHdCUm6l3MOGSmmMosIQcJ8Vq9Naaw0WJ3jrMcQFkxydo3cQJEtiXKgomvIK+kdxWCTXnPPaBVHEOBpG6kG7di9/4YzFkiaEUEJ+aQ1E4WvCJMhqMu62NxzXAwvBumONsHz1DUz1RI/6gwi+zadVFIk+FRL8gIl2me/mxFsOaIo3iMGUmxAX8K+4QZ5XU4fuXTRSgungbDIg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MW6PR12MB8663.namprd12.prod.outlook.com (2603:10b6:303:240::9) by SA3PR12MB9090.namprd12.prod.outlook.com (2603:10b6:806:397::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Wed, 16 Oct 2024 23:52:35 +0000 Received: from MW6PR12MB8663.namprd12.prod.outlook.com ([fe80::594:5be3:34d:77f]) by MW6PR12MB8663.namprd12.prod.outlook.com ([fe80::594:5be3:34d:77f%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 23:52:34 +0000 From: Jason Gunthorpe To: linux-pci@vger.kernel.org Cc: Bjorn Helgaas , Jiri Slaby , Steffen Dirkwinkel , patches@lists.linux.dev, Vidya Sagar Subject: [PATCH rc] PCI: Fix pci_enable_acs() support for the ACS quirks Date: Wed, 16 Oct 2024 20:52:33 -0300 Message-ID: <0-v1-f96b686c625b+124-pci_acs_quirk_fix_jgg@nvidia.com> X-ClientProxiedBy: BN9P223CA0016.NAMP223.PROD.OUTLOOK.COM (2603:10b6:408:10b::21) To MW6PR12MB8663.namprd12.prod.outlook.com (2603:10b6:303:240::9) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW6PR12MB8663:EE_|SA3PR12MB9090:EE_ X-MS-Office365-Filtering-Correlation-Id: 76084d59-b767-4f1d-cab7-08dcee3d9b5d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: 4YojpjXu6bjXqdUtIbQQ+9qbT1Y06H3+CBMADg0GVIe0sA90T46bXdZ9E2V2/DBZsrSkkzwQT5Wre8aocpL+qmAs0aOrVEZI5V0IWNIVwV0kMITYw/B8o5nBQBKzeF58efEhKye6sCNsIGUkp86oXiCZfr3LDHJE0sN7QsftqOrEGBEYCj7bZ0OizEKVcThK90bf5LyXPORa2OZKPV2Ng5wXEdM4pAZZ160nkUdkmZGrRbsNpdgWNNFRe7vbjUT9lP5/+4tNaH/xSIT0TAxMNXnIt+IAGth69qPxf6ynXLCr94y1q+quPQae+pswrbKt54A+YFVZfaqn/jXOgRuePgA72JFQGCdWB+P2g6M/EUywDK8ZPf5PkHFaE4V0PHBv5xeMA4zXDsvgv0VFjpbXTxOcZR/mJI8OUXlzBYEzFGRbfi621dLEEPGrfA29+INucaHcnuCr1ICLJQt0lcai3kWcOcgloxRueVUQFPViEazEzikR0AVIRgXbT+3TxIh6rGcCMxdovzfZd4bV7Tn4hGySqA2ykOsuJQLgotnQjMBzn+XFmf2FowqQNojetOJpEycOCTsrk+9RytdTP0KkAX44ltmVSvB7PBMRoZmiP7wQFjs/+s7H7C5xSfnDnSMGiGxhjO5qhk6EJjXcDu6vwyF14mrwpfH+nfj65lHtWVsqwdQXLuat1DNFIWNhkAxJzFAvjydjld/o3bU7HslT5dnY+XkNbPGtRVR7yNsmMJkjeufKHzcSY8OYJ145yg3JHF/QHc9fifASXtRi3aRmbyvu4MAqlO7LFup3eUWLMFuKguPLCtWJQTMuHcUj7SNvSB2FYK3cwfC+CzUTOiAoh/5GCcZeDS6qkGsihymYcXB2yA3ULfQ8jV/7p5KXimfcSkTBfTBvs4wFbBKsDzP7la+fxT616vimF7XkJQXk/UjnG7o88kkVVS3vNG8IWukcnuiPW6vab0AJGHZPsRYLoJaAOx6eDEwRhDX5boRY8XEMA6a8gr2Ers3DW0aC7TU/T5/VBP6Fdlu1w3orTTuhuhe7uYRireTj5ClhZQpe3Nz6Awf4yvyCPYWj1PZhvMa7aq5jromZAXUwLobR3Gp68ByetpbHszzhfMCUxvYgHN1ZW3KAqgbdg4/Fa1V4i0/YBPAa7gcP+nErxHoP8r+RK5b5Kw4onjTJyKQkk0gx/a9yRqxq3c95VZB51a9UdWHvOBfWnZqVWBniQrJJxtEjIwBndHFYTIWuHcEzvzRuF7rtonvSAks81YLh1aiBRZmhUrsewL3mTRNuoW5OXxbRZDdbzoUSfhr3CezqO9iEzUZdM3RRem3q93HpWnfu/t+b X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW6PR12MB8663.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eMuPyODudC0hCYxwgxUf/LT5rcQ88UhW8w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8rn0AsexPJF0fiP4RhDfmsAQBKR5MYMpRZtqxH++u9QYPpSamzJAXFpZ1773OhMNG3nSkNWMmZ0zxfHTvHgUXyvRYV2kHxc9hSY152w37OvtRFYLg3JzxpIQhDEQqFAMXATeY4bBD4rREnHunkb+Dhq+qJzZAK6z1pyYGiM+S6vnGpiplRslI9vNoyTM3KWuB5Eu/cfWkY+922MwK+QIQQjT1igRsMGlyNHZHZUywmsSWZm8S2hFUJlw9spRGZI4clzqpQIsIXSt3PLRG0ubKrqHCBNAaLJ5l3Hn3apFuq1hp9kkKpQbeyNiP8rJBDmPAjfZiP1QoFTcLxJmvB7tKxK2lewLv3YYnrCfwu7RlrVrmHmv7T6NEJ1UXwwkEb4S2U0MT+HX4vlIck1aE/LypMLS6GEyIQ6of69u4JYPER5cG+CrfKO7WicuewUbRyE8O5SIbS0ZHki9A7Eoy97SmWSdv8= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76084d59-b767-4f1d-cab7-08dcee3d9b5d X-MS-Exchange-CrossTenant-AuthSource: MW6PR12MB8663.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 23:52:34.7805 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HkM/pF577xFPVsiSHPbsyT/K4YoOTe2nOCw0QUYLG1MVDuRK719sXw7zRf+U5agL X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9090 There are ACS quirks that hijack the normal ACS processing and deliver to to special quirk code. The enable path needs to call pci_dev_specific_enable_acs() and then pci_dev_specific_acs_enabled() will report the hidden ACS state controlled by the quirk. The recent rework got this out of order and we should try to call pci_dev_specific_enable_acs() regardless of any actual ACS support in the device. As before command line parameters that effect standard PCI ACS don't interact with the quirk versions, including the new config_acs= option. Fixes: 47c8846a49ba ("PCI: Extend ACS configurability") Reported-by: Jiri Slaby Closes: https://lore.kernel.org/all/e89107da-ac99-4d3a-9527-a4df9986e120@kernel.org Closes: https://bugzilla.suse.com/show_bug.cgi?id=1229019 Tested-by: Steffen Dirkwinkel Signed-off-by: Jason Gunthorpe --- drivers/pci/pci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) base-commit: dc5006cfcf62bea88076a587344ba5e00e66d1c6 diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 7d85c04fbba2ae..225a6cd2e9ca3b 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1067,8 +1067,15 @@ static void pci_std_enable_acs(struct pci_dev *dev, struct pci_acs *caps) static void pci_enable_acs(struct pci_dev *dev) { struct pci_acs caps; + bool enable_acs = false; int pos; + /* If an iommu is present we start with kernel default caps */ + if (pci_acs_enable) { + if (pci_dev_specific_enable_acs(dev)) + enable_acs = true; + } + pos = dev->acs_cap; if (!pos) return; @@ -1077,11 +1084,8 @@ static void pci_enable_acs(struct pci_dev *dev) pci_read_config_word(dev, pos + PCI_ACS_CTRL, &caps.ctrl); caps.fw_ctrl = caps.ctrl; - /* If an iommu is present we start with kernel default caps */ - if (pci_acs_enable) { - if (pci_dev_specific_enable_acs(dev)) - pci_std_enable_acs(dev, &caps); - } + if (enable_acs) + pci_std_enable_acs(dev, &caps); /* * Always apply caps from the command line, even if there is no iommu.