From nobody Mon Feb 9 20:10:23 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 E1EA12F617B for ; Tue, 2 Dec 2025 14:23:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764685396; cv=none; b=T3miTGFpIQUYtz/lcfP3IImwNVEzspuTrfLI6yqPQIu//wjYDdH7cK+tZhjUkaKqrsLcZWbsmzBswK8ljOCJ3Abrgsw7Ak0oAjr8AKsunnL1WrTGvLzk4qBf7hHFbIzCsAGBTf8qybBV8ScJts0XAgPpvBwO9FiiawdHwJ3r57U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764685396; c=relaxed/simple; bh=oM0ISSThfe2iHQAvvM0MrsB3sAcFN54Yba1v/k79Xuc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KI6WlFwi0fQ5uttySQblkfGjxHpIgO7xTWR4yl7ShbOc9qi7hPG7emjtrL1rHupXHH+r3r5JpgWb01kFpkP71XzoekvS10ZwTARb+qDHgbtjdYIgAdfIup9Bmh8XHVH8MZ7vD4BztdUDr+zkYIz01XF2mLQz7tAJ3dDWH0Fm0Po= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=lqURRuOX; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=GM0LkQMn; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="lqURRuOX"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="GM0LkQMn" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5B27oIsp1926505 for ; Tue, 2 Dec 2025 14:23:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= GRDphVVsp5LhUNJNYA7xXoCBYkOqQfNzQnKNHXq8CQY=; b=lqURRuOXFyU9HwQd 5vMP3R/f1zVgh/LEL0Dr+73H90MfYxQ6gDxM75foN0k3QKGXV85Xt92Bvd5NEM4X BVkcpGQg2I05Hd1iExWRT0LMAB70uHjV69eBdQVmbAA6FX8T4VbdfcqfVxwRf+fQ stweY1l7ixy0vztj5VU44bTpJecgb+wqsBD5KGi1RkzqcAR/cP/vOzK92exv9HTL w+kHfFiePCCSK47pk8pZK817SdfwjfEvXNVQ/tEYFj41avdSaFPGKINiwMmfc9cc cuM7uMtnja0iyswsLYW/++t3DTkHFyzNUuZ2PTECPRYHUwlUDNYUmWUM31kKbQay eypvpw== Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4asm4xtj95-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 02 Dec 2025 14:23:13 +0000 (GMT) Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-7b9321b9312so10092335b3a.1 for ; Tue, 02 Dec 2025 06:23:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1764685393; x=1765290193; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=GRDphVVsp5LhUNJNYA7xXoCBYkOqQfNzQnKNHXq8CQY=; b=GM0LkQMnwzPkU5N3Ra3pzWjCjubn969rAh6mbzCYaE4dC9cXEn/D8um/EOIA5ET36k 08EiVZW39kSWjqdU6EzBc+ABTop97kd2SiwHBRq2hllTSteus66h+Jt6ee/G0Q8ZTJTO TY9qJU72Do9lNEYCNjjDOCymigT+n+wX+N69qNHkupUtww+o5SRwnNNhdMhUNR+uOtPQ L2XSzgNfEyo63hX4OkLtQfMTh29X+f+pedO/ctrB2jjiYkbNGZs5Hhy2m55nV/DU0v6D pBW7zOVjw1jRuWLURS0kMpHlAGv2UQlE6k2AxVJMDrMBKcP2oCbTzh3btuvLBODlRD2M mS8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764685393; x=1765290193; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=GRDphVVsp5LhUNJNYA7xXoCBYkOqQfNzQnKNHXq8CQY=; b=Wrx+8JalEHk+/mSJCDtsjHUjc1V5DZ7oR35PU68WqHTamj1wPPO+nTzUUfkJyLcgAn qMV8ypBqh28Wq7vEx6AAyDA/gGHf700WJlE5uX9DPN5ae2KH4cYf5D1GzLu23/KRRCst /G0uHNm+Z6FAQXIg/S9gjP9VR9BAi6trH1oMbuM+90tgzFR1B1Dqe8L1VWlur2OhVxg7 Imu/sRnOGHKlf5B7EexQO9cTUZjQBrptUKR/6hkXGCgw+a2jOL1qByHaeSO45X9z8Hwx IcjWIp6uXCrTorrUhxURut2vSuAzmOL8nknz1ifZQxIAlqFiE1nZKOl9VCmfSXtVpHuC 5sZA== X-Forwarded-Encrypted: i=1; AJvYcCWI2p2zwKnePQMzU8G5YEK5N/bXvunzeEJtX24a7rDGWpIUInZwpJkzZpGN6q0tAk3HpcmgvGV+NMp8s0g=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6GG2RA451BtpfPJMlJoHo+/eD0CCdCZbrD1kUfJvSncAWZPQ0 aODDiWswLGwiXZ+1ihSZRs4eodRfEhWCxOSnPNObxy4MyrDNaCO4wD7v+4lZR84ohw3f1m5j6WG YNY0ZALr59jM2DMy4GIakhwJsFFQBYf7LEfdW8yA9y6eOn2QX2Tq33/zWG+gXnbYGYm4= X-Gm-Gg: ASbGncuucfXcHZsiOzZf/vEUPrlFlTmvaud7+gituJL34p1toUaK+KIhFBQzON9PqVK EPlGMymCQkJsf2m2OGh3akrhna5UXyAY+GN85/uTabAy6Y+BSNEChWmgJ0LEpfVugaLuwSsPfQ3 A1NfqPDeSkV1tcP5xZf49BX3nmLBUObmeF8A7NRwiqr1w4fvh2yd2HPsg6gCf8r6Gb4nZ4TjA/Q I/Aqpsmd7IaKOi3BpN4sv8eHZ5tteZHSVWqf9YE+i2/eytHHxzq/nQ0UXlLpzsg0Qp7E0u9kRBD kJ+jU+/061WRN4X9HqVZ6mDiZNDIbRrm+OOlPNurdbtOg5CI49oHrTKkApm3j1qyfCj7zTDFtoR e2gXFbfS3ItqyFoqahABaLder92sZJw/fpVv7QCk= X-Received: by 2002:a05:6a21:6da2:b0:35e:5a46:2d6b with SMTP id adf61e73a8af0-36150e26ca3mr50873153637.8.1764685392340; Tue, 02 Dec 2025 06:23:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmRMklphSE8VVuEbGA85j8N7H5uZ2KxuEkKiykxwE99ZSiS5YgQWecQiu6eqV5ikDDhCSWqg== X-Received: by 2002:a05:6a21:6da2:b0:35e:5a46:2d6b with SMTP id adf61e73a8af0-36150e26ca3mr50873103637.8.1764685391735; Tue, 02 Dec 2025 06:23:11 -0800 (PST) Received: from [192.168.1.102] ([120.60.68.196]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-be5095a4821sm15659084a12.29.2025.12.02.06.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Dec 2025 06:23:11 -0800 (PST) From: Manivannan Sadhasivam Date: Tue, 02 Dec 2025 19:52:50 +0530 Subject: [PATCH v2 3/4] PCI: Disable ACS SV capability for the broken IDT switches Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251202-pci_acs-v2-3-5d2759a71489@oss.qualcomm.com> References: <20251202-pci_acs-v2-0-5d2759a71489@oss.qualcomm.com> In-Reply-To: <20251202-pci_acs-v2-0-5d2759a71489@oss.qualcomm.com> To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, Naresh Kamboju , Pavankumar Kondeti , Xingang Wang , Marek Szyprowski , Robin Murphy , Jason Gunthorpe , Manivannan Sadhasivam , Manivannan Sadhasivam X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=7289; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=oM0ISSThfe2iHQAvvM0MrsB3sAcFN54Yba1v/k79Xuc=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpLvZATIoifLli8Kza8XkZceVvVn5inlfSqDTzg jYBy9E0vLuJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaS72QAAKCRBVnxHm/pHO 9VgeB/oChngyIc4/wh1yLoqGtD6dV1a075pZRLSOe/aIThC1e6M72oVl5MWzn4DMh312D+aGUYd kdjWoaWP6z+xvgW7myDelsL+9jXCVVqEwqRlhxy/ukeCTn01PxAl+Gnq8O9IEe2ZvvfCXNH61/t QNOJFFDGx0yrXdGqur8orEi7i1RageUArTpIx7ZK280arIuuRb3MCZDukRvT0hRabB9ooBJrouh s/kVg7j6Vm4rX+INquiU70DiFwBHwMDpeO98bNnI4ZsNgLHTo8G2IiGeyD8kwcBkeQfq9+Pa01g fSg1DijCOd6l4rzpBnfMEKUr7dzXl07JGQAMfUryxby6S6PT X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Proofpoint-GUID: n4Y2ch_ncukELHw058OlGP24WEkOW3w2 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAyMDExNSBTYWx0ZWRfX2CVK3r/G+n2b B6ytKh3wYGvPJXeJfD4sEylNx44EvZSmdh4/FJvRXezwysIBvGu9lzsgmEyb+TtB1y4R2VTrSyw FCcsFWmgr8783mpQ1g/9TsMEsFbxwuchmoxF5tugevCLweRl6xKo+2j2QH8qjdaXOjJlCc3Qxk8 /A9vZyf45aIL/sPWIAu/SRMMHB4I0YP330I8QLkyNd4yPFCXy1veLysJbYpMTVVTeAjQPMRC16A nFLwJXM4QWhbByu2BEpi1spXdbCQDGYSVIckeEvLEmmVjPpLxeu6kn/J71ZBVX5BkfQXYaJvZ7A CZhOqKeLLvr0/NY4Sg96k1JYiDESvB5h73C2v7V3giuHv3KOfvzcRAUtVLBKyo0rbHk7xoKOpz8 rFtwjjwcOpKqTMfr1xMUBgW0spUwGw== X-Authority-Analysis: v=2.4 cv=cPTtc1eN c=1 sm=1 tr=0 ts=692ef651 cx=c_pps a=WW5sKcV1LcKqjgzy2JUPuA==:117 a=8ziBJk15IZ5r+wOU3RLduA==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=DsWDNE5MgSBdAu1L5fIA:9 a=QEXdDO2ut3YA:10 a=OpyuDcXvxspvyRM73sMx:22 X-Proofpoint-ORIG-GUID: n4Y2ch_ncukELHw058OlGP24WEkOW3w2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-01_01,2025-11-27_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 phishscore=0 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512020115 Some IDT switches behave erratically when ACS Source Validation is enabled. For example, they incorrectly flag an ACS Source Validation error on completions for config read requests even though PCIe r4.0, sec 6.12.1.1, says that completions are never affected by ACS Source Validation. Even though IDT suggests working around this issue by issuing a config write before the first config read, so that the device caches the bus and device number. But it would still be fragile since the device could loose the IDs after the reset and any further access may trigger ACS SV violation. Hence, to properly fix the issue, the respective capability needs to be disabled. Since the ACS Capabilities are RO values, and are cached in the 'pci_dev::acs_capabilities' field, add a new field for broken caps, set it in quirks and use it to remove the broken capabilities in pci_acs_init(). This will allow pci_enable_acs() helper to disable the relevant ACS ctrls. It should be noted that the quirk should be of the fixup_header level, so that it gets called before pci_acs_init(). With this, the previous workaround can now be safely removed. Signed-off-by: Manivannan Sadhasivam --- drivers/pci/pci.c | 1 + drivers/pci/pci.h | 1 - drivers/pci/probe.c | 12 ----------- drivers/pci/quirks.c | 61 ++++++++++++------------------------------------= ---- include/linux/pci.h | 1 + 5 files changed, 16 insertions(+), 60 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 4eb5b487c982..6ed35affea06 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3681,6 +3681,7 @@ void pci_acs_init(struct pci_dev *dev) return; =20 pci_read_config_word(dev, pos + PCI_ACS_CAP, &dev->acs_capabilities); + dev->acs_capabilities &=3D ~dev->acs_broken_cap; } =20 void pci_rebar_init(struct pci_dev *pdev) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 972b28fc5455..56ba7d60d658 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -430,7 +430,6 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, in= t devfn, u32 *pl, int rrs_timeout); bool pci_bus_generic_read_dev_vendor_id(struct pci_bus *bus, int devfn, u3= 2 *pl, int rrs_timeout); -int pci_idt_bus_quirk(struct pci_bus *bus, int devfn, u32 *pl, int rrs_tim= eout); =20 int pci_setup_device(struct pci_dev *dev); void __pci_size_stdbars(struct pci_dev *dev, int count, diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 9cd032dff31e..6f8142cf9487 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2517,18 +2517,6 @@ bool pci_bus_generic_read_dev_vendor_id(struct pci_b= us *bus, int devfn, u32 *l, bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, int timeout) { -#ifdef CONFIG_PCI_QUIRKS - struct pci_dev *bridge =3D bus->self; - - /* - * Certain IDT switches have an issue where they improperly trigger - * ACS Source Validation errors on completions for config reads. - */ - if (bridge && bridge->vendor =3D=3D PCI_VENDOR_ID_IDT && - bridge->device =3D=3D 0x80b5) - return pci_idt_bus_quirk(bus, devfn, l, timeout); -#endif - return pci_bus_generic_read_dev_vendor_id(bus, devfn, l, timeout); } EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index b9c252aa6fe0..a5956726a49f 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -5778,59 +5778,26 @@ DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(PCI_VENDOR_ID_= NVIDIA, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY, 16, quirk_nvidia_hda); =20 /* - * Some IDT switches incorrectly flag an ACS Source Validation error on - * completions for config read requests even though PCIe r4.0, sec - * 6.12.1.1, says that completions are never affected by ACS Source - * Validation. Here's the text of IDT 89H32H8G3-YC, erratum #36: + * Some IDT switches behave erratically when ACS Source Validation is enab= led. + * For example, they incorrectly flag an ACS Source Validation error on + * completions for config read requests even though PCIe r4.0, sec 6.12.1.= 1, + * says that completions are never affected by ACS Source Validation. * - * Item #36 - Downstream port applies ACS Source Validation to Completio= ns - * Section 6.12.1.1 of the PCI Express Base Specification 3.1 states that - * completions are never affected by ACS Source Validation. However, - * completions received by a downstream port of the PCIe switch from a - * device that has not yet captured a PCIe bus number are incorrectly - * dropped by ACS Source Validation by the switch downstream port. + * Even though IDT suggests working around this issue by issuing a config = write + * before the first config read, so that the switch caches the bus and dev= ice + * number, it would still be fragile since the device could loose the IDs = after + * the reset. * - * The workaround suggested by IDT is to issue a config write to the - * downstream device before issuing the first config read. This allows the - * downstream device to capture its bus and device numbers (see PCIe r4.0, - * sec 2.2.9), thus avoiding the ACS error on the completion. - * - * However, we don't know when the device is ready to accept the config - * write, so we do config reads until we receive a non-Config Request Retry - * Status, then do the config write. - * - * To avoid hitting the erratum when doing the config reads, we disable ACS - * SV around this process. + * Hence, a reliable fix would be to assume that these switches don't supp= ort + * ACS SV. */ -int pci_idt_bus_quirk(struct pci_bus *bus, int devfn, u32 *l, int timeout) +static void pci_disable_acs_sv(struct pci_dev *dev) { - int pos; - u16 ctrl =3D 0; - bool found; - struct pci_dev *bridge =3D bus->self; - - pos =3D bridge->acs_cap; - - /* Disable ACS SV before initial config reads */ - if (pos) { - pci_read_config_word(bridge, pos + PCI_ACS_CTRL, &ctrl); - if (ctrl & PCI_ACS_SV) - pci_write_config_word(bridge, pos + PCI_ACS_CTRL, - ctrl & ~PCI_ACS_SV); - } + pci_info(dev, "Disabling broken ACS SV\n"); =20 - found =3D pci_bus_generic_read_dev_vendor_id(bus, devfn, l, timeout); - - /* Write Vendor ID (read-only) so the endpoint latches its bus/dev */ - if (found) - pci_bus_write_config_word(bus, devfn, PCI_VENDOR_ID, 0); - - /* Re-enable ACS_SV if it was previously enabled */ - if (ctrl & PCI_ACS_SV) - pci_write_config_word(bridge, pos + PCI_ACS_CTRL, ctrl); - - return found; + dev->acs_broken_cap |=3D PCI_ACS_SV; } +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IDT, 0x80b5, pci_disable_acs_sv); =20 /* * Microsemi Switchtec NTB uses devfn proxy IDs to move TLPs between diff --git a/include/linux/pci.h b/include/linux/pci.h index c6ee1dfdb0fb..246c0ca34308 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -544,6 +544,7 @@ struct pci_dev { #endif u16 acs_cap; /* ACS Capability offset */ u16 acs_capabilities; /* ACS Capabilities */ + u16 acs_broken_cap; /* Broken ACS Capabilities */ u8 supported_speeds; /* Supported Link Speeds Vector */ phys_addr_t rom; /* Physical address if not from BAR */ size_t romlen; /* Length if not from BAR */ --=20 2.48.1