From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796054084; b=WW0GLegXbQ8N7cqngQkuP4URsW0sW5r6ukzol1+FrHEVLPatjFjn82iYQ2qJVdC46CYj rUXOLaGR7sfZL6wReWf/5Vf+apcCNt5AJ1a3aFXKIJtqM1Od9HP6Pxzt970ZfhncA2HMb EJ0h55c5tPBl233NDixxL5o3q4LBI1YZtk27C53607YFwgXiY7HGz6qZIzAUNCPvjjZ1Z k67zDyZLu9WgSHN8w45SMi0WydztRYfhI0HW4zwQiBskBFhECb6CDEkeci+yIYQ957gML fsgqtLiQTgZvELAGpT4OEDRfjDAy14Y82t+t/4d2hGuDkCqm9gDn6ZBFTb3SFTDmGxA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796054084; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=3uLWKSPu0AYn/+TH/Tdhid1MaUy1UAde2A0qCpULLzk=; b=4TRzIprwdMW+q5346TdwKMnlAkuWrbKxJsaGQV2Y4zx3k44I/WUVvV+CtTOo3VzEY/xO D126k418VOvEKumy+jyNBqW5EFQQvVdWHau5Ge4Jm+4VWhY8srSGfrTQZoB368RMIeKu5 eO0BDA6vgzjqHyUtJG88PfFvxOgVtFA97jMGD3Zk6S+x8xv0zYgcSTzG1lves3gKRHy73 j92KwQHfeLWsQ2SWHz895TLpO1lnV7uJ2x0bwugZqzkohzEsP2CQ+Sg+z9CE/zTapHV+i Olnlp/wyX3HNstzLoc8ajlTzaKj9wIFiO2z4ZKqcetw5HHxkKQvjySOKbqdKOxxDeXg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KzPx5HFK; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C19E9606A331 for ; Mon, 30 Nov 2026 15:54:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KzPx5HFK Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D5681F000C1; Mon, 30 Nov 2026 15:54:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796054084; bh=3uLWKSPu0AYn/+TH/Tdhid1MaUy1UAde2A0qCpULLzk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=KzPx5HFKbK2s7DAx96f+KwHWXObuFiK0C3XPCZjitGSZayYqq1FnmSNxFfXTY5hKy CeADqhWdjccABRqng3YVcgm/x8HOQ4Lo4q80oWi4iRYE7DT24JDiSEjBcvGNX3n4H/ sP3xzHRbDS0xe86KBy70NXHBksaGDDT11zgOdpwjLhAp4ZaHQAX8jDrqEs60y+CgK+ f08b2cEx8fFBaXp4Sxkn+MSu6BCo1ihjFC5fveImtt5TNGHK8yUGE2eLzUcRDb3FI9 7LJDnX15ruNuk7ujf1C8J+B1+86lbmJ3pUFC5wn7QVzYQsFvqxEHP0hQz2MHub7QUe hVcTfS2GHU07A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] PCI: Quirk devices with broken MRRS function under PCIE_BUS_PERFORMANCE mode Reply-To: sashiko-reviews@lists.linux.dev To: "Feng Tang" Cc: linux-pci@vger.kernel.org In-Reply-To: <20261130154317.69012-1-feng.tang@linux.alibaba.com> References: <20261130154317.69012-1-feng.tang@linux.alibaba.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 15:54:40 +0000 X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] PCI: pcie_find_sbmps() ignores smaller MPSS on intermediate bridges -- commit 71fbc43c3b824c6971cd3594dc63449905c21a34 Author: Feng Tang PCI: Quirk devices with broken MRRS function under PCIE_BUS_PERFORMANCE mode This commit adds a quirk flag for PCIe devices that issue read requests exceeding their configured MRRS, and clamps the upstream Root Port's MPS and MRRS to the smallest MPSS among broken devices under it when running in PCIE_BUS_PERFORMANCE mode. > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c > index 2e84fc3d5df96..6e4b78b156f17 100644 > --- a/drivers/pci/probe.c > +++ b/drivers/pci/probe.c > @@ -3041,6 +3041,23 @@ static int pcie_bus_configure_set(struct pci_dev *= dev, void *data) > return 0; > } > =20 > +/* > + * Find the smallest mps of devices with broken MRRS function > + * under a Root Port, if they exist > + */ > +static int pcie_find_sbmps(struct pci_dev *dev, void *data) > +{ > + u8 *sbmps =3D data; > + > + if (!pci_is_pcie(dev)) > + return 0; > + > + if (dev->broken_mrrs && *sbmps > dev->pcie_mpss) > + *sbmps =3D dev->pcie_mpss; > + > + return 0; > +} > + > /* > * pcie_bus_configure_settings() requires that pci_walk_bus work in a to= p-down, > * parents then children fashion. If this changes, then this code will = not > @@ -3049,11 +3066,12 @@ static int pcie_bus_configure_set(struct pci_dev = *dev, void *data) > void pcie_bus_configure_settings(struct pci_bus *bus) > { > u8 smpss =3D 0; > + struct pci_dev *bridge =3D bus->self; > =20 > - if (!bus->self) > + if (!bridge) > return; > =20 > - if (!pci_is_pcie(bus->self)) > + if (!pci_is_pcie(bridge)) > return; > =20 > /* > @@ -3065,13 +3083,39 @@ void pcie_bus_configure_settings(struct pci_bus *= bus) > smpss =3D 0; > =20 > if (pcie_bus_config =3D=3D PCIE_BUS_SAFE) { > - smpss =3D bus->self->pcie_mpss; > + smpss =3D bridge->pcie_mpss; > =20 > - pcie_find_smpss(bus->self, &smpss); > + pcie_find_smpss(bridge, &smpss); > pci_walk_bus(bus, pcie_find_smpss, &smpss); > } > =20 > - pcie_bus_configure_set(bus->self, &smpss); > + if (pcie_bus_config =3D=3D PCIE_BUS_PERFORMANCE && > + pci_pcie_type(bridge) =3D=3D PCI_EXP_TYPE_ROOT_PORT) { > + u8 sbmps =3D bridge->pcie_mpss; > + > + /* > + * There are devices with broken MRRS function, that they issue > + * Memory Read Requests with length larger than their MRRS, and > + * the corresponding Root Port may return CplD packet with > + * length larger than device's MPS, triggering "Malformed TLP" > + * AER error. > + * > + * Limit Root Port's MPS/MRRS down to the smallest mps of all > + * broken devices under it to avoid such issue. > + */ > + pci_walk_bus(bus, pcie_find_sbmps, &sbmps); [Severity: Medium] Does pcie_find_sbmps() leave the Root Port's MPS larger than the endpoint's effective MPS when a broken_mrrs device sits behind an intermediate switch or bridge with a smaller pcie_mpss? pcie_find_sbmps() only checks dev->pcie_mpss on the broken_mrrs endpoint itself, whereas the subsequent top-down walk in pcie_write_mps() clamps each device's MPS to min(mps, pcie_get_mps(dev->bus->self)). If a Root Port supports 512B, an intermediate switch supports 128B, and the broken_mrrs endpoint supports 256B, the Root Port is set to 256B while the switch and endpoint are clamped to 128B, so the Root Port can still return 256B CplD packets that trigger Malformed TLP errors. Also, gating this block on pci_pcie_type(bridge) =3D=3D PCI_EXP_TYPE_ROOT_P= ORT skips the clamp completely when pcie_bus_configure_settings() is called during hotplug below a switch downstream port. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130154317.6901= 2-1-feng.tang@linux.alibaba.com?part=3D1