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=1796445489; b=MzoWs6G516VpG0ddrQjp7W2PPWgbIJjY3jfh7vtTZaw2sxwKMfMNgac1RKMK3zHeXcVx uY6x8F4geFjXHI5b1j/C80Ctd0zAeiind8lFaAOcEZvpECvTx3cVZRTvcyvtBXSHUYceI n0V2mce9SDDAq77j9u2EqCVSmSq3stkKuLd1xlzdZ8/WzBq0JjfYRBun843LdXN1cSpJL PWJnBH5USv1bblguXg8NRjWJ02FSJPznWsIFpkb04CA6BC/7jhCzD8D+WBAFfVvMHN1eE 9Aq9T3QuS3XlZLJCBQPzBdEaPoPjbN416aqkfHiwaWtV08ZT4O+MlQ0ys+ER46PV/kw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796445489; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Bf4Gn01rvzDn6b6PeIGYoN1ms/rI/4wTe7w70UkBwjI=; b=1SRXTc83GD08rqWQGC637vXtFjUkm/CS6TTRhaISZ8jtMXTcF9nVGDMD6zbJSAV+IYBZ JpuJprB29Pgfo9cJp9qW96i+ew/SznAYNCEKIY9+e2poEg1tzNuuoFehyGLSvtVdOyeT/ Y2X2bIJDTcTkzcWGNwuQJ61nXeD09rWsgc38DZ0VFE/dWDA63sqp70NrBbUK7FS1JMQR1 L/c76qRmf8RfPOz1UZ/IvEMbZdpynCnUX9amzP3Ydsn+p9DNN48Sq9jcljb1BuM0sjC5P tP8HHWMISFQ933gG9hAB3iQfzkmDdultK4liWbQyR4lsuUZV7nMgYJ5vKw/jpD/b8Hw== 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=P+5yp4vE; 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 10AA7606A322; Sat, 5 Dec 2026 04:38:08 +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=P+5yp4vE Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85FF21F0092B; Sat, 5 Dec 2026 04:38:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796445488; bh=Bf4Gn01rvzDn6b6PeIGYoN1ms/rI/4wTe7w70UkBwjI=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=P+5yp4vEURsEoKcS5462F1X8LUBehxGxoSAzRRWjLNSl4nhr6VOWIL/Tc/LdJQkdg e3K02VmkdTOTTcFZalVroLKGdvCRm5ohxJ9KplAxAvUlgbFcRcF/5GQNPBWp6v8xWT RaESFYzpklEukiUtxHaJ1jQbBVq+8tzLBB9dl02aOgbl/c7APdSP0UB9K6IsyGsELS vb5tqez3mld9yUznLEPDQXYKGBp2fVK87QJ4lRjbnpJqNr2sBuFtOAFZjZINIea1aD pbu4dRmOjsAD82xCo2csTAQd3wvI4o5eKtpfAKbBhfjREohRTeEJdl31zx7GpjEk5M zT4CFAYO8KAmw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v18 12/19] PCI/CXL: Add CXL Device Reset sequencing Reply-To: sashiko-reviews@lists.linux.dev To: "Srirangan Madhavan" , linux-cxl@vger.kernel.org, linux-pci@vger.kernel.org In-Reply-To: <20261205041453.3946529-13-smadhavan@nvidia.com> References: <20261205041453.3946529-1-smadhavan@nvidia.com> <20261205041453.3946529-13-smadhavan@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 04:38:08 +0000 X-Mailing-List: linux-cxl@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 4 potential issues to consider: - [Medium] PCI/CXL: cxl_reset_function() gates probe on dynamic CXL enable bits - [Medium] PCI/CXL: cxl_reset_wait_cache_wbi() misses post-deadline status read - [Medium] PCI/CXL: cxl_reset_wait_done() checks deadline after status read - [Medium] PCI/CXL: cxl_reset_function() requires CXL.cache capability and enable -- commit 7d770790d7d42c69d9dc663a5c3fce0ee4f98b17 Author: Srirangan Madhavan PCI/CXL: Add CXL Device Reset sequencing This commit adds CXL Device Reset sequencing for Type 2 devices, including cache writeback and invalidation, transaction draining, IOMMU preparation, reset initiation with Memory Clear, and completion polling. > diff --git a/drivers/pci/cxl.c b/drivers/pci/cxl.c > index 56119e3fd03a6..4d6cfabab2c0e 100644 > --- a/drivers/pci/cxl.c > +++ b/drivers/pci/cxl.c [ ... ] > @@ -224,3 +228,238 @@ void pci_cxl_hdm_cache_release(struct pci_dev *pdev) [ ... ] > +static int cxl_reset_wait_cache_wbi(struct pci_dev *pdev, int dvsec) > +{ > + unsigned long deadline; > + u16 status2; > + int rc; > + > + rc =3D cxl_reset_update_ctrl2(pdev, dvsec, > + PCI_DVSEC_CXL_INIT_CACHE_WBI, 0); > + if (rc) > + return rc; > + > + deadline =3D jiffies + usecs_to_jiffies(CXL_CACHE_WBI_TIMEOUT_US); > + while (time_before(jiffies, deadline)) { > + usleep_range(CXL_CACHE_WBI_POLL_US, > + CXL_CACHE_WBI_POLL_US * 2); > + > + rc =3D cxl_pci_read_config_word(pdev, > + dvsec + PCI_DVSEC_CXL_STATUS2, > + &status2); > + if (rc) > + return rc; > + if (status2 & PCI_DVSEC_CXL_CACHE_INV) > + return 0; > + } > + > + pci_warn(pdev, "timed out waiting for CXL cache writeback and invalidat= e\n"); > + return -ETIMEDOUT; > +} [Severity: Medium] Can cxl_reset_wait_cache_wbi() return a spurious -ETIMEDOUT without re-checking PCI_DVSEC_CXL_STATUS2 after the deadline passes? If the thread is preempted across the 100 ms deadline right after computing deadline, or after a poll where PCI_DVSEC_CXL_CACHE_INV was still clear, time_before() exits the loop without reading Status2 again. That aborts the reset even if hardware completed writeback and invalidation in time. Sampling whether the timeout expired before reading Status2 (as poll_timeout_us() does) ensures one final check after the deadline. [ ... ] > + for (;;) { > + rc =3D pci_read_config_word(pdev, dvsec + PCI_DVSEC_CXL_STATUS2, > + &status2); > + if (rc) > + return pcibios_err_to_errno(rc); > + if (status2 !=3D U16_MAX) { > + if (status2 & PCI_DVSEC_CXL_RST_ERR) > + return -EIO; > + if (status2 & PCI_DVSEC_CXL_RST_DONE) > + return 0; > + } > + > + if (time_after_eq(jiffies, deadline)) { > + pci_err(pdev, "timed out waiting for CXL reset to complete\n"); > + return -ETIMEDOUT; > + } > + > + msleep(CXL_RESET_STATUS_POLL_MS); > + } [Severity: Medium] Can cxl_reset_wait_done() also report a spurious -ETIMEDOUT by checking time_after_eq(jiffies, deadline) after pci_read_config_word()? For a device advertising a 10 ms or 100 ms reset timeout, deadline is only 20 ms after the 100 ms quiet period. If the first config read stalls in RRS retries or the thread is preempted before the timeout check, the loop returns -ETIMEDOUT without reading Status2 again after the deadline. Recording expiration before reading PCI_DVSEC_CXL_STATUS2 avoids failing a reset that completed before the deadline. [ ... ] > +int cxl_reset_function(struct pci_dev *pdev, bool probe) > +{ > + u16 dvsec, cap, ctrl; > + int rc; > + > + rc =3D cxl_pci_device_dvsec(pdev, &dvsec, &cap); > + if (rc) > + return rc; > + if (!(cap & PCI_DVSEC_CXL_CACHE_CAPABLE) || > + !(cap & PCI_DVSEC_CXL_MEM_CAPABLE) || > + !(cap & PCI_DVSEC_CXL_RST_CAPABLE) || > + !(cap & PCI_DVSEC_CXL_RST_MEM_CLR_CAPABLE)) > + return -ENOTTY; > + > + rc =3D cxl_pci_read_config_word(pdev, dvsec + PCI_DVSEC_CXL_CTRL, &ctrl= ); > + if (rc) > + return rc; > + if (!(ctrl & PCI_DVSEC_CXL_CACHE_ENABLE) || > + !(ctrl & PCI_DVSEC_CXL_MEM_ENABLE)) > + return -ENOTTY; [Severity: Medium] As reported by Jonathan Cameron on v12 [1], should cxl_reset_function() require PCI_DVSEC_CXL_CACHE_CAPABLE and PCI_DVSEC_CXL_CACHE_ENABLE? A Type 2 device running with CXL.mem enabled and CXL.cache disabled, or a CXL.mem-only device with CXL Reset and Reset Memory Clear, gets -ENOTTY here and falls through to FLR without clearing device memory or resetting CXL.mem state. Relaxing the CXL.cache requirement here and gating cache disable, WBI, and policy restore in cxl_reset_execute() on CXL.cache being capable and enabled would cover those devices as well. > + > + if (probe) > + return 0; [Severity: Medium] Should the PCI_DVSEC_CXL_CTRL enable check happen after the probe return rather than before it? pci_init_reset_methods() probes reset methods once during PCI enumeration, before any driver binds to enable PCI_DVSEC_CXL_MEM_ENABLE or PCI_DVSEC_CXL_CACHE_ENABLE. If firmware leaves them disabled, cxl_reset is permanently excluded from dev->reset_methods[] and later resets fall back to FLR or bus reset without CXL Memory Clear. Checking only static capability bits in PCI_DVSEC_CXL_CAP during probe and checking PCI_DVSEC_CXL_CTRL only when executing the reset lets __pci_reset_function_locked() fall through cleanly when CXL is disabled. [1] https://lore.kernel.org/r/20260912022617.47860862@jic23-hlaptop --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205041453.3946= 529-1-smadhavan@nvidia.com?part=3D12