CXL reset support for Type 2 devices
v3 cover CXL reset support for Type 2 devices
From: Srirangan Madhavan <[email protected]>
Hi folks!
This patch series introduces support for the CXL Reset method for CXL devices, implementing the reset procedure outlined in CXL Spec [1] v3.2, Sections 9.6 and 9.7.
v3 changes:
- Restrict CXL reset to Type 2 devices only
- Add host and device cache flushing for
* all sibling functions on multi-function devices
* all sibling devices in a given region
- Add region teardown and memory online detection before reset
- Add configuration state save/restore (DVSEC, HDM, IDE)
- Split the series by subsystem and functional blocks
v2 changes:
- De-duplicate CXL DVSEC register defines under include/cxl/pci.h
- Fix style-related issues
v1 changes:
- Added cover letter and dropped the RFC
The RFC patches can be found here [2]
v2 patches can be found here [3]
Motivation:
-----------
This change is broadly useful for reasons including but not limited to the following:
- As support for Type 2 devices [4] is being introduced, more devices will require finer-grained reset mechanisms beyond bus-wide reset methods.
- FLR does not affect CXL.cache or CXL.mem protocols, making CXL Reset the preferred method in some cases.
- The CXL spec (Sections 7.2.3 Binding and Unbinding, 9.5 FLR) highlights use cases like function rebinding and error recovery, where CXL Reset is explicitly mentioned.
Change Description:
-------------------
Patch 1: Move CXL DVSEC defines to the CXL PCI header
- Consolidate DVSEC register definitions under include/cxl/pci.h
Patch 2: Switch PCI CXL port DVSEC defines
- Use the shared CXL PCI header in the PCI core
Patch 3: Add Type 2 helper and reset DVSEC bits
- Add helper to identify Type 2 devices
- Define DVSEC reset/cache control bits
Patch 4: Add the CXL reset method in the PCI core
- Implement cxl_reset() method with capability checks and reset sequence
- Restrict to Type 2 devices
Patch 5: Add reset preparation and region teardown
- Implement region validation and teardown before reset
- Add device cache flush for all sibling devices in a given region
Patch 6: Wire CXL reset prepare/cleanup in PCI
- Call CXL reset prepare/cleanup around the core reset flow
Patch 7: Add host CPU cache flush and multi-function support
- Add host CPU cache flush (x86: wbinvd, arm64: dcache_clean_inval_poc)
- Add device cache flush for all sibling functions on multi-function devices
Patch 8: Add DVSEC configuration state save/restore
- Save/restore DVSEC registers (DEVCTL, DEVCTL2) with CONFIG_LOCK handling
Patch 9: Save/restore CXL config around reset
- Save PCI and CXL config before reset and restore afterwards
Patch 10: Add HDM decoder and IDE state save/restore
- Save/restore HDM decoder and IDE register state
The reset sequence: validate device type, check memory offline, tear down regions, flush host CPU caches, flush device caches (all functions), save config state, initiate reset, wait for completion, restore config state.
Command line to test the CXL reset on a capable device:
echo cxl_reset > /sys/bus/pci/devices/<pci_device>/reset_method echo 1 > /sys/bus/pci/devices/<pci_device>/reset
[1] https://computeexpresslink.org/cxl-specification/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/linux-cxl/[email protected]/
Srirangan Madhavan (10):
[PATCH v3 1/10] cxl: move DVSEC defines to cxl pci header [PATCH v3 2/10] PCI: switch CXL port DVSEC defines
[PATCH v3 3/10] cxl/pci: add type 2 helper and reset DVSEC bits [PATCH v3 4/10] PCI: add CXL reset method
[PATCH v3 5/10] cxl/pci: add reset prepare and region teardown [PATCH v3 6/10] PCI: wire CXL reset prepare/cleanup
[PATCH v3 7/10] cxl/pci: add host cache flush and multi-function reset [PATCH v3 8/10] cxl/pci: add DVSEC config save/restore [PATCH v3 9/10] PCI: save/restore CXL config around reset [PATCH v3 10/10] cxl/pci: add HDM decoder and IDE save/restore
drivers/cxl/core/pci.c | 1 + drivers/cxl/core/regs.c | 8 + drivers/cxl/cxl.h | 4 + drivers/cxl/cxlpci.h | 53 --- drivers/cxl/pci.c | 621 +++++++++++++++++++++++++++++++++- drivers/pci/pci.c | 146 +++++++- include/cxl/pci.h | 134 ++++++++ include/linux/pci.h | 5 +- include/uapi/linux/pci_regs.h | 5 - 9 files changed, 909 insertions(+), 68 deletions(-) create mode 100644 include/cxl/pci.h
--
2.34.1
PATCH v3 1/10 cxl: move DVSEC defines to cxl pci header
From: Srirangan Madhavan <[email protected]>
CXL DVSEC definitions are shared across PCI core and CXL drivers, so move the register macros into the common CXL PCI header. This keeps the DVSEC surface in one place and avoids duplication as the reset and config helpers build on these offsets and bitfields.
--- drivers/cxl/core/pci.c | 1 + drivers/cxl/core/regs.c | 1 + drivers/cxl/cxlpci.h | 53 ----------------------------------- drivers/cxl/pci.c | 1 + include/cxl/pci.h | 62 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 53 deletions(-) create mode 100644 include/cxl/pci.h
drivers/cxl/core/pci.c +1 -0
@@ -7,6 +7,7 @@#include <linux/pci.h> #include <linux/pci-doe.h> #include <linux/aer.h> +#include <cxl/pci.h> #include <cxlpci.h> #include <cxlmem.h> #include <cxl.h>
drivers/cxl/core/regs.c +1 -0
@@ -4,6 +4,7 @@#include <linux/device.h> #include <linux/slab.h> #include <linux/pci.h> +#include <cxl/pci.h> #include <cxlmem.h> #include <cxlpci.h> #include <pmu.h>
drivers/cxl/cxlpci.h +0 -53
59 lines not on this page · raw message
drivers/cxl/pci.c +1 -0
@@ -12,6 +12,7 @@#include <linux/aer.h> #include <linux/io.h> #include <cxl/mailbox.h> +#include <cxl/pci.h> #include "cxlmem.h" #include "cxlpci.h" #include "cxl.h"
include/cxl/pci.h new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v3 2/10 PCI: switch CXL port DVSEC defines
In reply to [email protected]From: Srirangan Madhavan <[email protected]>
The PCI core consumes CXL port DVSEC fields for reset handling, so switch it to use the shared CXL PCI header instead of the uapi header. This aligns the core with the header split and keeps internal code from depending on uapi-only definitions.
--- drivers/pci/pci.c | 17 +++++++++-------- include/uapi/linux/pci_regs.h | 5 ----- 2 files changed, 9 insertions(+), 13 deletions(-)
drivers/pci/pci.c +9 -8
@@ -30,6 +30,7 @@#include <asm/dma.h> #include <linux/aer.h> #include <linux/bitfield.h> +#include <cxl/pci.h> #include "pci.h" DEFINE_MUTEX (pci_slot_mutex);
@@ -4842,7 +4843,7 @@ static int pci_dev_reset_slot_function(struct pci_dev *dev, bool probe)static u16 cxl_port_dvsec (struct pci_dev *dev) {return pci_find_dvsec_capability (dev,PCI_VENDOR_ID_CXL , -PCI_DVSEC_CXL_PORT ); +CXL_DVSEC_PORT_EXTENSIONS ); }static bool cxl_sbr_masked (struct pci_dev *dev)
@@ -4854,7 +4855,7 @@ static bool cxl_sbr_masked(struct pci_dev *dev)if (!dvsec)return false; - rc =pci_read_config_word (dev, dvsec +PCI_DVSEC_CXL_PORT_CTL , ®); + rc =pci_read_config_word (dev, dvsec +CXL_DVSEC_PORT_CTL , ®);if (rc ||PCI_POSSIBLE_ERROR (reg))return false;
@@ -4863,7 +4864,7 @@ static bool cxl_sbr_masked(struct pci_dev *dev)* bit in Bridge Control has no effect. When 1, the Port generates * hot reset when the SBR bit is set to 1. */ -if (reg &PCI_DVSEC_CXL_PORT_CTL_UNMASK_SBR ) +if (reg &CXL_DVSEC_UNMASK_SBR )return false;return true;
@@ -4908,22 +4909,22 @@ static int cxl_reset_bus_function(struct pci_dev *dev, bool probe)if (probe)return 0 ; - rc =pci_read_config_word (bridge, dvsec +PCI_DVSEC_CXL_PORT_CTL , ®); + rc =pci_read_config_word (bridge, dvsec +CXL_DVSEC_PORT_CTL , ®);if (rc)return -ENOTTY ; -if (reg &PCI_DVSEC_CXL_PORT_CTL_UNMASK_SBR ) { +if (reg &CXL_DVSEC_UNMASK_SBR ) { val = reg; }else { - val = reg |PCI_DVSEC_CXL_PORT_CTL_UNMASK_SBR ; -pci_write_config_word (bridge, dvsec +PCI_DVSEC_CXL_PORT_CTL , + val = reg |CXL_DVSEC_UNMASK_SBR ; +pci_write_config_word (bridge, dvsec +CXL_DVSEC_PORT_CTL , val); } rc =pci_reset_bus_function (dev, probe);if (reg != val) -pci_write_config_word (bridge, dvsec +PCI_DVSEC_CXL_PORT_CTL , +pci_write_config_word (bridge, dvsec +CXL_DVSEC_PORT_CTL , reg);return rc;
include/uapi/linux/pci_regs.h +0 -5
@@ -1253,11 +1253,6 @@#define PCI_DEV3_STA 0x0c/* Device 3 Status Register */ #define PCI_DEV3_STA_SEGMENT 0x8/* Segment Captured (end-to-end flit-mode detected) */ -/* Compute Express Link (CXL r3.1, sec 8.1.5) */ -#define PCI_DVSEC_CXL_PORT 3 -#define PCI_DVSEC_CXL_PORT_CTL 0x0c -#define PCI_DVSEC_CXL_PORT_CTL_UNMASK_SBR 0x00000001 -/* Integrity and Data Encryption Extended Capability */ #define PCI_IDE_CAP 0x04#define PCI_IDE_CAP_LINK 0x1/* Link IDE Stream Supported */
Signature · 1 line
2.34.1
PATCH v3 3/10 cxl: add type 2 helper and reset DVSEC bits
In reply to [email protected]From: Srirangan Madhavan <[email protected]>
Introduce a helper to identify CXL Type 2 devices and define the DVSEC reset/cache control bits used by the reset flow.
--- drivers/cxl/pci.c | 10 ++++++++++ include/cxl/pci.h | 14 ++++++++++++++ 2 files changed, 24 insertions(+)
drivers/cxl/pci.c +10 -0
@@ -1082,6 +1082,16 @@ static pci_ers_result_t cxl_slot_reset(struct pci_dev *pdev)return PCI_ERS_RESULT_RECOVERED ; } +bool cxl_is_type2_device (struct pci_dev *pdev) +{ +struct cxl_dev_state *cxlds =pci_get_drvdata (pdev); + +if (!cxlds) +return false; + +return cxlds->type ==CXL_DEVTYPE_DEVMEM ; +} +static void cxl_error_resume (struct pci_dev *pdev) {struct cxl_dev_state *cxlds =pci_get_drvdata (pdev);
include/cxl/pci.h +14 -0
@@ -14,10 +14,24 @@/* CXL 2.0 8.1.3: PCIe DVSEC for CXL Device */ #define CXL_DVSEC_PCIE_DEVICE 0#define CXL_DVSEC_CAP_OFFSET 0xA +#define CXL_DVSEC_CACHE_CAPABLE BIT(0)#define CXL_DVSEC_MEM_CAPABLE BIT(2)#define CXL_DVSEC_HDM_COUNT_MASK GENMASK(5, 4) +#define CXL_DVSEC_CACHE_WBI_CAPABLE BIT(6) +#define CXL_DVSEC_CXL_RST_CAPABLE BIT(7) +#define CXL_DVSEC_CXL_RST_TIMEOUT_MASK GENMASK(10, 8) +#define CXL_DVSEC_CXL_RST_MEM_CLR_CAPABLE BIT(11)#define CXL_DVSEC_CTRL_OFFSET 0xC#define CXL_DVSEC_MEM_ENABLE BIT(2) +#define CXL_DVSEC_CTRL2_OFFSET 0x10 +#define CXL_DVSEC_DISABLE_CACHING BIT(0) +#define CXL_DVSEC_INIT_CACHE_WBI BIT(1) +#define CXL_DVSEC_INIT_CXL_RESET BIT(2) +#define CXL_DVSEC_CXL_RST_MEM_CLR_ENABLE BIT(3) +#define CXL_DVSEC_STATUS2_OFFSET 0x12 +#define CXL_DVSEC_CACHE_INVALID BIT(0) +#define CXL_DVSEC_CXL_RST_COMPLETE BIT(1) +#define CXL_DVSEC_CXL_RESET_ERR BIT(2)#define CXL_DVSEC_RANGE_SIZE_HIGH (i) (0x18 + ((i) * 0x10))#define CXL_DVSEC_RANGE_SIZE_LOW (i) (0x1C + ((i) * 0x10))#define CXL_DVSEC_MEM_INFO_VALID BIT(0)
--
2.34.1
PATCH v3 4/10 PCI: add CXL reset method
In reply to [email protected]From: Srirangan Madhavan <[email protected]>
Add a PCI reset method "cxl_reset" that drives the CXL reset sequence using DVSEC controls and timeout encoding. The method is restricted to Type 2 devices, limiting the scope of the changes.
--- drivers/pci/pci.c | 100 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 3 +- 2 files changed, 102 insertions(+), 1 deletion(-)
drivers/pci/pci.c +100 -0
@@ -4892,6 +4892,105 @@ static int pci_reset_bus_function(struct pci_dev *dev, bool probe)return pci_parent_bus_reset (dev, probe); } +static int cxl_reset_init (struct pci_dev *dev,u16 dvsec) +{ +/* +* Timeout values ref CXL Spec v3.2 Ch 8 Control and Status Registers, +* under section 8.1.3.1 DVSEC CXL Capability. +*/ +u32 reset_timeouts_ms[] = {10 ,100 ,1000 ,10000 ,100000 }; +u16 reg; +u32 timeout_ms; +int rc, ind; + +/* Check if CXL Reset MEM CLR is supported. */ + rc =pci_read_config_word (dev, dvsec +CXL_DVSEC_CAP_OFFSET , ®); +if (rc) +return rc; + +if (reg &CXL_DVSEC_CXL_RST_MEM_CLR_CAPABLE ) { + rc =pci_read_config_word (dev, dvsec +CXL_DVSEC_CTRL2_OFFSET , + ®); +if (rc) +return rc; + + reg |=CXL_DVSEC_CXL_RST_MEM_CLR_ENABLE ; +pci_write_config_word (dev, dvsec +CXL_DVSEC_CTRL2_OFFSET , reg); + } + +/* Read timeout value. */ + rc =pci_read_config_word (dev, dvsec +CXL_DVSEC_CAP_OFFSET , ®); +if (rc) +return rc; + ind =FIELD_GET (CXL_DVSEC_CXL_RST_TIMEOUT_MASK , reg); + timeout_ms = reset_timeouts_ms[ind]; + +/* Write reset config. */ + rc =pci_read_config_word (dev, dvsec +CXL_DVSEC_CTRL2_OFFSET , ®); +if (rc) +return rc; + + reg |=CXL_DVSEC_INIT_CXL_RESET ; +pci_write_config_word (dev, dvsec +CXL_DVSEC_CTRL2_OFFSET , reg); + +/* Wait till timeout and then check reset status is complete. */ +msleep (timeout_ms); + rc =pci_read_config_word (dev, dvsec +CXL_DVSEC_STATUS2_OFFSET , ®); +if (rc) +return rc; +if (reg &CXL_DVSEC_CXL_RESET_ERR || + ~reg &CXL_DVSEC_CXL_RST_COMPLETE ) +return -ETIMEDOUT ; + + rc =pci_read_config_word (dev, dvsec +CXL_DVSEC_CTRL2_OFFSET , ®); +if (rc) +return rc; + reg &= (~CXL_DVSEC_DISABLE_CACHING ); +pci_write_config_word (dev, dvsec +CXL_DVSEC_CTRL2_OFFSET , reg); + +return 0 ; +} + +/** +* cxl_reset - initiate a cxl reset +* @dev: device to reset +* @probe: if true, return 0 if device can be reset this way +* +* Initiate a cxl reset on @dev. +*/ +static int cxl_reset (struct pci_dev *dev,bool probe) +{ +u16 dvsec, reg; +int rc; + + dvsec =pci_find_dvsec_capability (dev,PCI_VENDOR_ID_CXL , +CXL_DVSEC_PCIE_DEVICE ); +if (!dvsec) +return -ENOTTY ; + +/* Check if CXL Reset is supported. */ + rc =pci_read_config_word (dev, dvsec +CXL_DVSEC_CAP_OFFSET , ®); +if (rc) +return -ENOTTY ; + +if (reg &CXL_DVSEC_CXL_RST_CAPABLE ==0 ) +return -ENOTTY ; + +/* +* Expose CXL reset for Type 2 devices. +*/ +if (!cxl_is_type2_device (dev)) +return -ENOTTY ; + +if (probe) +return 0 ; + +if (!pci_wait_for_pending_transaction (dev)) +pci_err (dev,"timed out waiting for pending transaction; performing function level reset anyway\n" ); + +return cxl_reset_init (dev, dvsec); +} +static int cxl_reset_bus_function (struct pci_dev *dev,bool probe) {struct pci_dev *bridge;
@@ -5016,6 +5115,7 @@ const struct pci_reset_fn_method pci_reset_fn_methods[] = { { pci_dev_acpi_reset, .name = "acpi" }, { pcie_reset_flr, .name = "flr" }, { pci_af_flr, .name = "af_flr" }, + { cxl_reset, .name = "cxl_reset" }, { pci_pm_reset, .name = "pm" }, { pci_reset_bus_function, .name = "bus" }, { cxl_reset_bus_function, .name = "cxl_bus" },
include/linux/pci.h +2 -1
@@ -51,7 +51,7 @@ PCI_STATUS_PARITY)/* Number of reset methods used in pci_reset_fn_methods array in pci.c */ -#define PCI_NUM_RESET_METHODS 8 +#define PCI_NUM_RESET_METHODS 9#define PCI_RESET_PROBE true#define PCI_RESET_DO_RESET false
@@ -1464,6 +1464,7 @@ int __must_check pci_resize_resource(struct pci_dev *dev, int i, int size,int pci_select_bars (struct pci_dev *dev,unsigned long flags);bool pci_device_is_present (struct pci_dev *pdev); +bool cxl_is_type2_device (struct pci_dev *dev);void pci_ignore_hotplug (struct pci_dev *dev);struct pci_dev *pci_real_dma_dev (struct pci_dev *dev);int pci_status_get_and_clear_errors (struct pci_dev *pdev);
--
2.34.1
kernel test robot
build botRe: [PATCH v3 4/10] PCI: add CXL reset method
kernel test robot noticed the following build errors:
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on pci/next]
[also build test ERROR on pci/for-linus linus/master v6.19-rc5] [cannot apply to next-20260116]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/smadhavan-nvidia-com/cxl-move-DVSEC-defines-to-cxl-pci-header/20260116-094457 base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next patch link: https://lore.kernel.org/r/20260116014146.2149236-5-smadhavan%40nvidia.com patch subject: [PATCH v3 4/10] PCI: add CXL reset method config: alpha-allnoconfig (https://download.01.org/0day-ci/archive/20260117/[email protected]/config) compiler: alpha-linux-gcc (GCC) 15.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260117/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
drivers/pci/pci.c: In function 'cxl_reset':
>> drivers/pci/pci.c:4979:17: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
4979 | if (reg & CXL_DVSEC_CXL_RST_CAPABLE == 0)
| ^
--
alpha-linux-ld: drivers/pci/pci.o: in function `cxl_reset':
>> (.text+0x6cec): undefined reference to `cxl_is_type2_device'
>> alpha-linux-ld: (.text+0x6cf4): undefined reference to `cxl_is_type2_device'Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v3 4/10] PCI: add CXL reset method
In reply to [email protected]kernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on pci/next]
[also build test WARNING on pci/for-linus linus/master v6.19-rc5] [cannot apply to next-20260116]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/smadhavan-nvidia-com/cxl-move-DVSEC-defines-to-cxl-pci-header/20260116-094457 base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next patch link: https://lore.kernel.org/r/20260116014146.2149236-5-smadhavan%40nvidia.com patch subject: [PATCH v3 4/10] PCI: add CXL reset method config: loongarch-allnoconfig (https://download.01.org/0day-ci/archive/20260117/[email protected]/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260117/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/pci/pci.c:4979:10: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses]
4979 | if (reg & CXL_DVSEC_CXL_RST_CAPABLE == 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/pci/pci.c:4979:10: note: place parentheses around the '==' expression to silence this warning
4979 | if (reg & CXL_DVSEC_CXL_RST_CAPABLE == 0)
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/pci/pci.c:4979:10: note: place parentheses around the & expression to evaluate it first
4979 | if (reg & CXL_DVSEC_CXL_RST_CAPABLE == 0)
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~1 warning generated.
vim +4979 drivers/pci/pci.c
4956
4957 /**
4958 * cxl_reset - initiate a cxl reset
4959 * @dev: device to reset
4960 * @probe: if true, return 0 if device can be reset this way
4961 *
4962 * Initiate a cxl reset on @dev.
4963 */
4964 static int cxl_reset(struct pci_dev *dev, bool probe)
4965 {
4966 u16 dvsec, reg;
4967 int rc;
4968
4969 dvsec = pci_find_dvsec_capability(dev, PCI_VENDOR_ID_CXL,
4970 CXL_DVSEC_PCIE_DEVICE);
4971 if (!dvsec)
4972 return -ENOTTY;
4973
4974 /* Check if CXL Reset is supported. */
4975 rc = pci_read_config_word(dev, dvsec + CXL_DVSEC_CAP_OFFSET, ®);
4976 if (rc)
4977 return -ENOTTY;
4978
> 4979 if (reg & CXL_DVSEC_CXL_RST_CAPABLE == 0)
4980 return -ENOTTY;
4981
4982 /*
4983 * Expose CXL reset for Type 2 devices.
4984 */
4985 if (!cxl_is_type2_device(dev))
4986 return -ENOTTY;
4987
4988 if (probe)
4989 return 0;
4990
4991 if (!pci_wait_for_pending_transaction(dev))
4992 pci_err(dev, "timed out waiting for pending transaction; performing function level reset anyway\n");
4993
4994 return cxl_reset_init(dev, dvsec);
4995 }
4996
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v3 5/10 cxl: add reset prepare and region teardown
In reply to [email protected]From: Srirangan Madhavan <[email protected]>
Prepare a Type 2 device for cxl_reset by validating memory is offline, flushing device caches for region participants, and tearing down decoders under cxl_region_rwsem. The lock stays held across reset to prevent new region creation while reset is in progress.
--- drivers/cxl/pci.c | 214 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+)
drivers/cxl/pci.c +214 -0
@@ -1092,6 +1092,220 @@ bool cxl_is_type2_device(struct pci_dev *pdev)return cxlds->type ==CXL_DEVTYPE_DEVMEM ; } +static int cxl_check_region_driver_bound (struct device *dev,void *data) +{ +struct cxl_decoder *cxld =to_cxl_decoder (dev); + +if (!is_endpoint_decoder (dev)) +return 0 ; + +guard (rwsem_read)(&cxl_region_rwsem); +if (cxld->region && cxld->region->driver) +return -EBUSY ; + +return 0 ; +} + +static int cxl_decoder_kill_region_iter (struct device *dev,void *data) +{ +struct cxl_endpoint_decoder *cxled =to_cxl_endpoint_decoder (dev); +int rc; + +if (!is_endpoint_decoder (dev)) +return 0 ; + +if (!cxled->cxld.region) +return 0 ; + +cxl_decoder_kill_region_locked (cxled); + + rc =device_for_each_child (&cxled->cxld.dev,NULL , + cxl_check_region_driver_bound); +if (rc) +return rc; + +return 0 ; +} + +static int cxl_device_cache_wb_invalidate (struct pci_dev *pdev) +{ +struct cxl_dev_state *cxlds =pci_get_drvdata (pdev); +u16 reg, val, cap; +int dvsec, rc; + +if (!cxlds) +return -ENODEV ; + + dvsec = cxlds->cxl_dvsec; +if (!dvsec) +return -ENODEV ; + + rc =pci_read_config_word (pdev, dvsec +CXL_DVSEC_CAP_OFFSET , &cap); +if (rc) +return rc; + +if (!(cap &CXL_DVSEC_CACHE_WBI_CAPABLE )) +return 1 ; + + rc =pci_read_config_word (pdev, dvsec +CXL_DVSEC_CTRL2_OFFSET , &val); +if (rc) +return rc; + + val |=CXL_DVSEC_INIT_CACHE_WBI ; + rc =pci_write_config_word (pdev, dvsec +CXL_DVSEC_CTRL2_OFFSET , val); +if (rc) +return rc; + +do { + rc =pci_read_config_word (pdev, dvsec +CXL_DVSEC_STATUS2_OFFSET , ®); +if (rc) +return rc; + }while (!(reg &CXL_DVSEC_CACHE_INVALID )); + +return 0 ; +} + +static int cxl_region_flush_device_caches (struct device *dev,void *data) +{ +struct cxl_endpoint_decoder *cxled =to_cxl_endpoint_decoder (dev); +struct cxl_region *cxlr = cxled->cxld.region; +struct cxl_region_params *p = &cxlr->params; +struct pci_dev *target_pdev = data; +int i, rc; + +if (!is_endpoint_decoder (dev)) +return 0 ; + +if (!cxlr || !cxlr->params.res) +return 0 ; + +for (i =0 ; i < p->nr_targets; i++) { +struct cxl_endpoint_decoder *target_cxled = p->targets[i]; +struct cxl_memdev *target_cxlmd =cxled_to_memdev (target_cxled); +struct cxl_dev_state *target_cxlds = target_cxlmd->cxlds; + +if (!target_cxlds || !target_cxlds->pdev) +continue ; + +if (target_cxlds->pdev != target_pdev) +continue ; + + rc =cxl_device_cache_wb_invalidate (target_pdev); +if (rc && rc !=1 ) +return rc; + } + +return 0 ; +} + +/** +* cxl_reset_prepare_memdev - Prepare CXL device for reset +* @pdev: PCI device +* +* Validates it's safe to reset and tears down regions atomically under lock. +* Acquires cxl_region_rwsem and keeps it held throughout reset. +* +* Return: 0 on success (lock held), -EBUSY if memory online, negative on error +*/ +static int cxl_reset_prepare_memdev (struct pci_dev *pdev) +{ +struct cxl_dev_state *cxlds =pci_get_drvdata (pdev); +struct cxl_memdev *cxlmd; +struct cxl_port *endpoint; +int rc; + +if (!cxlds) +return -ENODEV ; + + cxlmd = cxlds->cxlmd; +if (!cxlmd) +return -ENODEV ; + + endpoint = cxlmd->endpoint; +if (!endpoint) +return 0 ; + +if (cxl_num_decoders_committed (endpoint) ==0 ) +return 0 ; + +down_write (&cxl_region_rwsem); + +/* Check and error out if memory is online */ + rc =device_for_each_child (&endpoint->dev,NULL , + cxl_check_region_driver_bound); +if (rc) { +up_write (&cxl_region_rwsem); +dev_err (&pdev->dev, +"Reset blocked: device has active regions with drivers bound\n" ); +return -EBUSY ; + } + +/* Flush device caches and tear down regions */ +device_for_each_child (&endpoint->dev, pdev, + cxl_region_flush_device_caches); + + rc =device_for_each_child (&endpoint->dev,NULL , + cxl_decoder_kill_region_iter); +if (rc) { +up_write (&cxl_region_rwsem); +dev_err (&pdev->dev,"Failed to tear down regions: %d\n" , rc); +return rc; + } + +/* Keep cxl_region_rwsem held, released by cleanup function */ +return 0 ; +} + +/** +* cxl_reset_cleanup_memdev - Release locks after CXL reset +* @pdev: PCI device +*/ +static void cxl_reset_cleanup_memdev (struct pci_dev *pdev) +{ +if (lockdep_is_held_type (&cxl_region_rwsem,-1 )) +up_write (&cxl_region_rwsem); +} + +/** +* cxl_reset_prepare_device - Prepare CXL device for reset +* @pdev: PCI device being reset +* +* CXL-reset-specific preparation. Validates memory is offline, flushes +* device caches, and tears down regions. +* +* Returns: 0 on success, -EBUSY if memory online, negative on error +*/ +int cxl_reset_prepare_device (struct pci_dev *pdev) +{ +int rc; + + rc =cxl_reset_prepare_memdev (pdev); +if (rc) { +if (rc == -EBUSY ) +dev_err (&pdev->dev, +"Cannot reset: device has online memory or active regions\n" ); +else +dev_err (&pdev->dev, +"Failed to prepare device for reset: %d\n" , rc); +return rc; + } + +return 0 ; +} +EXPORT_SYMBOL_NS_GPL (cxl_reset_prepare_device,"CXL" ); + +/** +* cxl_reset_cleanup_device - Cleanup after CXL reset +* @pdev: PCI device that was reset +* +* Releases region locks held during reset. +*/ +void cxl_reset_cleanup_device (struct pci_dev *pdev) +{ +cxl_reset_cleanup_memdev (pdev); +} +EXPORT_SYMBOL_NS_GPL (cxl_reset_cleanup_device,"CXL" ); +static void cxl_error_resume (struct pci_dev *pdev) {struct cxl_dev_state *cxlds =pci_get_drvdata (pdev);
--
2.34.1
PATCH v3 6/10 PCI: wire CXL reset prepare/cleanup
In reply to [email protected]From: Srirangan Madhavan <[email protected]>
Wire CXL reset preparation and cleanup into the PCI CXL reset path. The flow now validates/offlines regions, performs teardown and cache flushes, then releases the lock on completion or error. This keeps the common reset_prepare flow intact while adding cxl_reset-specific quiesce logic.
--- drivers/pci/pci.c | 19 ++++++++++++++++++- include/linux/pci.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-)
drivers/pci/pci.c +18 -1
@@ -4985,10 +4985,27 @@ static int cxl_reset(struct pci_dev *dev, bool probe)if (probe)return 0 ; +/* +* CXL-reset-specific preparation: validate memory offline, +* tear down regions, flush device caches. +*/ + rc =cxl_reset_prepare_device (dev); +if (rc) +return rc; +if (!pci_wait_for_pending_transaction (dev))pci_err (dev,"timed out waiting for pending transaction; performing function level reset anyway\n" ); -return cxl_reset_init (dev, dvsec); + rc =cxl_reset_init (dev, dvsec); +if (rc) + goto out_cleanup; + +cxl_reset_cleanup_device (dev); +return 0 ; + +out_cleanup: +cxl_reset_cleanup_device (dev); +return rc; }static int cxl_reset_bus_function (struct pci_dev *dev,bool probe)
include/linux/pci.h +2 -0
@@ -1465,6 +1465,8 @@ int __must_check pci_resize_resource(struct pci_dev *dev, int i, int size,int pci_select_bars (struct pci_dev *dev,unsigned long flags);bool pci_device_is_present (struct pci_dev *pdev);bool cxl_is_type2_device (struct pci_dev *dev); +int cxl_reset_prepare_device (struct pci_dev *pdev); +void cxl_reset_cleanup_device (struct pci_dev *pdev);void pci_ignore_hotplug (struct pci_dev *dev);struct pci_dev *pci_real_dma_dev (struct pci_dev *dev);int pci_status_get_and_clear_errors (struct pci_dev *pdev);
--
2.34.1
PATCH v3 7/10 cxl: add host cache flush and multi-function reset
In reply to [email protected]From: Srirangan Madhavan <[email protected]>
Flush host CPU caches for mapped HDM ranges after teardown and prepare sibling Type 2 functions on multi-function devices. The host cache maintenance uses wbinvd_on_all_cpus() on x86 and VA-based PoC clean+ invalidate on arm64 via memremap() and on_each_cpu(), matching the required ordering before reset.
--- drivers/cxl/pci.c | 150 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 2 deletions(-)
drivers/cxl/pci.c +148 -2
@@ -11,6 +11,10 @@#include <linux/pci.h> #include <linux/aer.h> #include <linux/io.h> +#include <linux/align.h> +#include <linux/cache.h> +#include <linux/cacheflush.h> +#include <linux/smp.h> #include <cxl/mailbox.h> #include <cxl/pci.h> #include "cxlmem.h"
@@ -1092,6 +1096,71 @@ bool cxl_is_type2_device(struct pci_dev *pdev)return cxlds->type ==CXL_DEVTYPE_DEVMEM ; } +#ifdef CONFIG_ARM64 +struct cxl_cache_flush_ctx { +void *va; +size_t len; +}; + +static void cxl_flush_by_va_local (void *info) +{ +struct cxl_cache_flush_ctx *ctx = info; + +dcache_clean_inval_poc ((unsigned long )ctx->va, + (unsigned long )ctx->va + ctx->len); + asmvolatile ("dsb ish" :::"memory" ); +} +#endif + +static int cxl_region_flush_host_cpu_caches (struct device *dev,void *data) +{ +struct cxl_endpoint_decoder *cxled =to_cxl_endpoint_decoder (dev); +struct cxl_region *cxlr = cxled->cxld.region; +struct resource *res; + +if (!is_endpoint_decoder (dev)) +return 0 ; + +if (!cxlr || !cxlr->params.res) +return 0 ; + + res = cxlr->params.res; + +#ifdef CONFIG_X86 +static bool flushed; + +if (!flushed) { +wbinvd_on_all_cpus (); + flushed = true; + } +#elif defined(CONFIG_ARM64 ) +void *va; +size_t len, line_size =L1_CACHE_BYTES ; +phys_addr_t start, end, aligned_start, aligned_end; +struct cxl_cache_flush_ctx flush_ctx; + + start = res->start; + end = res->end; + + aligned_start =ALIGN_DOWN (start, line_size); + aligned_end =ALIGN (end +1 , line_size); + len = aligned_end - aligned_start; + + va =memremap (aligned_start, len,MEMREMAP_WB ); +if (!va) { +pr_warn ("Failed to map region for cache flush\n" ); +return 0 ; + } + + flush_ctx.va = va; + flush_ctx.len = len; +on_each_cpu (cxl_flush_by_va_local, &flush_ctx,1 ); + +memunmap (va); +#endif +return 0 ; +} +static int cxl_check_region_driver_bound (struct device *dev,void *data) {struct cxl_decoder *cxld =to_cxl_decoder (dev);
@@ -1252,6 +1321,9 @@ static int cxl_reset_prepare_memdev(struct pci_dev *pdev)return rc; } +device_for_each_child (&endpoint->dev,NULL , + cxl_region_flush_host_cpu_caches); +/* Keep cxl_region_rwsem held, released by cleanup function */ return 0 ; }
@@ -1266,12 +1338,79 @@ static void cxl_reset_cleanup_memdev(struct pci_dev *pdev)up_write (&cxl_region_rwsem); } +static int cxl_reset_prepare_all_functions (struct pci_dev *pdev) +{ +struct pci_dev *func_dev; +unsigned int devfn; +int func, rc; +struct pci_dev *prepared_funcs[8 ] = {NULL }; +int prepared_count =0 ; + +for (func =0 ; func <8 ; func++) { + devfn =PCI_DEVFN (PCI_SLOT (pdev->devfn), func); + +if (devfn == pdev->devfn) +continue ; + + func_dev =pci_get_slot (pdev->bus, devfn); +if (!func_dev) +continue ; + +if (!cxl_is_type2_device (func_dev)) { +pci_dev_put (func_dev); +continue ; + } + + rc =cxl_reset_prepare_memdev (func_dev); +if (rc) { +pci_dev_put (func_dev); + goto cleanup_funcs; + } + + prepared_funcs[prepared_count++] = func_dev; + } + +return 0 ; + +cleanup_funcs: +for (func =0 ; func < prepared_count; func++) { +if (prepared_funcs[func]) { +cxl_reset_cleanup_memdev (prepared_funcs[func]); +pci_dev_put (prepared_funcs[func]); + } + } +return rc; +} + +static void cxl_reset_cleanup_all_functions (struct pci_dev *pdev) +{ +struct pci_dev *func_dev; +unsigned int devfn; +int func; + +for (func =0 ; func <8 ; func++) { + devfn =PCI_DEVFN (PCI_SLOT (pdev->devfn), func); + +if (devfn == pdev->devfn) +continue ; + + func_dev =pci_get_slot (pdev->bus, devfn); +if (!func_dev) +continue ; + +if (cxl_is_type2_device (func_dev)) +cxl_reset_cleanup_memdev (func_dev); + +pci_dev_put (func_dev); + } +} +/** * cxl_reset_prepare_device - Prepare CXL device for reset * @pdev: PCI device being reset * * CXL-reset-specific preparation. Validates memory is offline, flushes -* device caches, and tears down regions. +* device caches, and tears down regions for device and siblings. * * Returns: 0 on success, -EBUSY if memory online, negative on error */
@@ -1290,6 +1429,12 @@ int cxl_reset_prepare_device(struct pci_dev *pdev)return rc; } + rc =cxl_reset_prepare_all_functions (pdev); +if (rc) { +cxl_reset_cleanup_memdev (pdev); +return rc; + } +return 0 ; }EXPORT_SYMBOL_NS_GPL (cxl_reset_prepare_device,"CXL" );
@@ -1298,10 +1443,11 @@ EXPORT_SYMBOL_NS_GPL(cxl_reset_prepare_device, "CXL");* cxl_reset_cleanup_device - Cleanup after CXL reset * @pdev: PCI device that was reset * -* Releases region locks held during reset. +* Releases region locks for device and all sibling functions. */ void cxl_reset_cleanup_device (struct pci_dev *pdev) { +cxl_reset_cleanup_all_functions (pdev);cxl_reset_cleanup_memdev (pdev); }EXPORT_SYMBOL_NS_GPL (cxl_reset_cleanup_device,"CXL" );
--
2.34.1
PATCH v3 8/10 cxl: add DVSEC config save/restore
In reply to [email protected]From: Srirangan Madhavan <[email protected]>
Save and restore CXL DVSEC control registers across reset with CONFIG_LOCK handling so RWL fields are preserved when locked. This maintains device policy and capability state across cxl_reset while avoiding writes to locked fields.
--- drivers/cxl/pci.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++ include/cxl/pci.h | 15 +++++++ 2 files changed, 122 insertions(+)
drivers/cxl/pci.c +107 -0
@@ -1161,6 +1161,113 @@ static int cxl_region_flush_host_cpu_caches(struct device *dev, void *data)return 0 ; } +/* +* CXL DVSEC register save/restore +*/ +static int cxl_save_dvsec_state (struct pci_dev *pdev, +struct cxl_type2_saved_state *state,int dvsec) +{ +int rc; + + rc =pci_read_config_word (pdev, dvsec +CXL_DVSEC_CTRL_OFFSET , + &state->dvsec_ctrl); +if (rc) +return rc; + + rc =pci_read_config_word (pdev, dvsec +CXL_DVSEC_CTRL2_OFFSET , + &state->dvsec_ctrl2); +return rc; +} + +static int cxl_restore_dvsec_state (struct pci_dev *pdev, +const struct cxl_type2_saved_state *state, +int dvsec,bool config_locked) +{ +int rc; +u16 val_to_restore; + +if (config_locked) { +u16 current_val; + + rc =pci_read_config_word (pdev, dvsec +CXL_DVSEC_CTRL_OFFSET , + ¤t_val); +if (rc) +return rc; + + val_to_restore = (current_val &CXL_DVSEC_CTRL_RWL_MASK ) | + (state->dvsec_ctrl & ~CXL_DVSEC_CTRL_RWL_MASK ); + }else { + val_to_restore = state->dvsec_ctrl; + } + + rc =pci_write_config_word (pdev, dvsec +CXL_DVSEC_CTRL_OFFSET , + val_to_restore); +if (rc) +return rc; + + rc =pci_write_config_word (pdev, dvsec +CXL_DVSEC_CTRL2_OFFSET , + state->dvsec_ctrl2); +return rc; +} + +/** +* cxl_config_save_state - Save CXL configuration state +* @pdev: PCI device +* @state: Structure to store saved state +* +* Saves CXL DVSEC state before reset. +*/ +int cxl_config_save_state (struct pci_dev *pdev, +struct cxl_type2_saved_state *state) +{ +struct cxl_dev_state *cxlds =pci_get_drvdata (pdev); +int dvsec; + +if (!cxlds || !state) +return -EINVAL ; + +memset (state,0 ,sizeof (*state)); + + dvsec = cxlds->cxl_dvsec; +if (!dvsec) +return -ENODEV ; + +return cxl_save_dvsec_state (pdev, state, dvsec); +} +EXPORT_SYMBOL_NS_GPL (cxl_config_save_state,"CXL" ); + +/** +* cxl_config_restore_state - Restore CXL configuration state +* @pdev: PCI device +* @state: Previously saved state +* +* Restores CXL DVSEC state after reset. +*/ +int cxl_config_restore_state (struct pci_dev *pdev, +const struct cxl_type2_saved_state *state) +{ +struct cxl_dev_state *cxlds =pci_get_drvdata (pdev); +bool config_locked; +int rc, dvsec; +u16 lock_reg; + +if (!cxlds || !state) +return -EINVAL ; + + dvsec = cxlds->cxl_dvsec; +if (!dvsec) +return -ENODEV ; + + rc =pci_read_config_word (pdev, dvsec +CXL_DVSEC_LOCK_OFFSET , &lock_reg); +if (rc) +return rc; + + config_locked = !!(lock_reg &CXL_DVSEC_LOCK_CONFIG_LOCK ); + +return cxl_restore_dvsec_state (pdev, state, dvsec, config_locked); +} +EXPORT_SYMBOL_NS_GPL (cxl_config_restore_state,"CXL" ); +static int cxl_check_region_driver_bound (struct device *dev,void *data) {struct cxl_decoder *cxld =to_cxl_decoder (dev);
include/cxl/pci.h +15 -0
@@ -4,6 +4,18 @@#ifndef __CXL_ACCEL_PCI_H#define __CXL_ACCEL_PCI_H +/* CXL Type 2 device state for save/restore across reset */ +struct cxl_type2_saved_state { +/* DVSEC registers */ +u16 dvsec_ctrl; +u16 dvsec_ctrl2; +}; + +int cxl_config_save_state (struct pci_dev *pdev, +struct cxl_type2_saved_state *state); +int cxl_config_restore_state (struct pci_dev *pdev, +const struct cxl_type2_saved_state *state); +/* * See section 8.1 Configuration Space Registers in the CXL 2.0 * Specification. Names are taken straight from the specification with "CXL" and
@@ -23,6 +35,7 @@#define CXL_DVSEC_CXL_RST_MEM_CLR_CAPABLE BIT(11)#define CXL_DVSEC_CTRL_OFFSET 0xC#define CXL_DVSEC_MEM_ENABLE BIT(2) +#define CXL_DVSEC_CTRL_RWL_MASK 0x5FED#define CXL_DVSEC_CTRL2_OFFSET 0x10#define CXL_DVSEC_DISABLE_CACHING BIT(0)#define CXL_DVSEC_INIT_CACHE_WBI BIT(1)
@@ -32,6 +45,8 @@#define CXL_DVSEC_CACHE_INVALID BIT(0)#define CXL_DVSEC_CXL_RST_COMPLETE BIT(1)#define CXL_DVSEC_CXL_RESET_ERR BIT(2) +#define CXL_DVSEC_LOCK_OFFSET 0x14 +#define CXL_DVSEC_LOCK_CONFIG_LOCK BIT(0)#define CXL_DVSEC_RANGE_SIZE_HIGH (i) (0x18 + ((i) * 0x10))#define CXL_DVSEC_RANGE_SIZE_LOW (i) (0x1C + ((i) * 0x10))#define CXL_DVSEC_MEM_INFO_VALID BIT(0)
--
2.34.1
PATCH v3 9/10 PCI: save/restore CXL config around reset
In reply to [email protected]From: Srirangan Madhavan <[email protected]>
Save PCI and CXL configuration state before cxl_reset and restore it after reset completes. This preserves DVSEC state alongside standard PCI state and avoids losing reset-sensitive CXL configuration.
--- drivers/pci/pci.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/pci/pci.c +12 -0
@@ -4960,6 +4960,7 @@ static int cxl_reset_init(struct pci_dev *dev, u16 dvsec)*/ static int cxl_reset (struct pci_dev *dev,bool probe) { +struct cxl_type2_saved_state cxl_state;u16 dvsec, reg;int rc;
@@ -4985,6 +4986,11 @@ static int cxl_reset(struct pci_dev *dev, bool probe)if (probe)return 0 ; +pci_save_state (dev); + rc =cxl_config_save_state (dev, &cxl_state); +if (rc) +pci_warn (dev,"Failed to save CXL config state: %d\n" , rc); +/* * CXL-reset-specific preparation: validate memory offline, * tear down regions, flush device caches.
@@ -5000,10 +5006,16 @@ static int cxl_reset(struct pci_dev *dev, bool probe)if (rc) goto out_cleanup; +pci_restore_state (dev); + rc =cxl_config_restore_state (dev, &cxl_state); +if (rc) +pci_warn (dev,"Failed to restore CXL config state: %d\n" , rc); +cxl_reset_cleanup_device (dev);return 0 ; out_cleanup: +pci_restore_state (dev);cxl_reset_cleanup_device (dev);return rc; }
--
2.34.1
PATCH v3 10/10 cxl: add HDM decoder and IDE save/restore
In reply to [email protected]From: Srirangan Madhavan <[email protected]>
Extend state save/restore to HDM decoder and IDE registers for Type 2 devices. The HDM/IDE blocks are located via the component register map, then preserved across reset to retain decoder configuration and IDE policy. This avoids losing HDM/IDE programming when cxl_reset is issued.
--- drivers/cxl/core/regs.c | 7 ++ drivers/cxl/cxl.h | 4 ++ drivers/cxl/pci.c | 153 ++++++++++++++++++++++++++++++++++++++-- include/cxl/pci.h | 43 +++++++++++ 4 files changed, 201 insertions(+), 6 deletions(-)
drivers/cxl/core/regs.c +7 -0
@@ -93,6 +93,12 @@ void cxl_probe_component_regs(struct device *dev, void __iomem *base, length =CXL_RAS_CAPABILITY_LENGTH ; rmap = &map->ras;break ; +case CXL_CM_CAP_CAP_ID_IDE : +dev_dbg (dev,"found IDE capability (0x%x)\n" , + offset); + length =CXL_IDE_CAPABILITY_LENGTH ; + rmap = &map->ide; +break ;default :dev_dbg (dev,"Unknown CM cap ID: %d (0x%x)\n" , cap_id, offset);
@@ -212,6 +218,7 @@ int cxl_map_component_regs(const struct cxl_register_map *map, } mapinfo[] = { { &map->component_map.hdm_decoder, ®s->hdm_decoder }, { &map->component_map.ras, ®s->ras }, + { &map->component_map.ide, ®s->ide }, }; int i;
drivers/cxl/cxl.h +4 -0
@@ -39,8 +39,10 @@ extern const struct nvdimm_security_ops *cxl_security_ops;#define CXL_CM_CAP_PTR_MASK GENMASK(31, 20)#define CXL_CM_CAP_CAP_ID_RAS 0x2 +#define CXL_CM_CAP_CAP_ID_IDE 0x4#define CXL_CM_CAP_CAP_ID_HDM 0x5#define CXL_CM_CAP_CAP_HDM_VERSION 1 +#define CXL_IDE_CAPABILITY_LENGTH 0x20/* HDM decoders CXL 2.0 8.2.5.12 CXL HDM Decoder Capability Structure */ #define CXL_HDM_DECODER_CAP_OFFSET 0x0
@@ -214,6 +216,7 @@ struct cxl_regs {struct_group_tagged (cxl_component_regs, component, void __iomem *hdm_decoder;void __iomem *ras; +void __iomem *ide; );/* * Common set of CXL Device register block base pointers
@@ -256,6 +259,7 @@ struct cxl_reg_map {struct cxl_component_reg_map {struct cxl_reg_map hdm_decoder;struct cxl_reg_map ras; +struct cxl_reg_map ide; };struct cxl_device_reg_map {
drivers/cxl/pci.c +147 -6
193 lines not on this page · raw message
include/cxl/pci.h +43 -0
60 lines not on this page · raw message
--
2.34.1
Alison Schofield
maintainerQuoted 7 lines · On Fri, Jan 16, 2026 at 01:41:36AM +0000, [email protected] wrote:
From: Srirangan Madhavan <[email protected]>
Hi folks!
This patch series introduces support for the CXL Reset method for CXL devices, implementing the reset procedure outlined in CXL Spec [1] v3.2, Sections 9.6 and 9.7.
Hi,
Seems something is missing from the set or a dependency not noted. It stops compiling at Patch 8 cxl: add reset prepare and region teardown
-- Alison
Hi Alison,
Thank you for the heads‑up. I’ve respun the series as v4 and rebased it on pci/next as mentioned by the testbot. The v4 changes are limited to build‑fixes from the bot report + Reported‑by/Closes on the reset method patch. And the reproduce steps from testbot clear locally for me now.
In v4 & v3 , “reset prepare and region teardown” is patch 5 (not 8). If you still see a build failure at that point, could you share the exact error/log and the tree/config you’re using? I’ll take a look right away.
Thanks,
Srirangan
________________________________________
From: Alison Schofield <[email protected]>
Sent: Sunday, January 18, 2026 2:29 PM
To: Srirangan Madhavan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Vishal Aslot; Vikram Sethi; Shanker Donthineni; Vidya Sagar; Matt Ochs; Jason Sequeira
Subject: Re: [PATCH v3 0/10] CXL reset support for Type 2 devices
External email: Use caution opening links or attachments
Quoted 7 lines · On Fri, Jan 16, 2026 at 01:41:36AM +0000, [email protected] wrote:
From: Srirangan Madhavan <[email protected]>
Hi folks!
This patch series introduces support for the CXL Reset method for CXL devices, implementing the reset procedure outlined in CXL Spec [1] v3.2, Sections 9.6 and 9.7.
Hi,
Seems something is missing from the set or a dependency not noted. It stops compiling at Patch 8 cxl: add reset prepare and region teardown
-- Alison
A message that is not in the archive (sent off-list or not yet received): CY5PR12MB6226EE35D88E6F4442572D1CC389A@CY5PR12MB6226.namprd12.prod.outlook.com
Alison Schofield
maintainerQuoted 3 lines · Srirangan Madhavan
Hi Alison,
Thank you for the heads‑up. I’ve respun the series as v4 and rebased it on pci/next as mentioned by the testbot. The v4 changes are limited to build‑fixes from the bot report + Reported‑by/Closes on the reset method patch. And the reproduce steps from testbot clear locally for me now.
pci/next? Ah, that's different than what we typically do in drivers/cxl. I was expecting a mainline base commit - like 6.19-rc6. Anyway v4 still has conflicts w that. What is the dependency that is on pci/next? I can see the impact, appended below, but pci/next has a slew of things since 6.19-rc1.
drivers/cxl/pci.c:1090:6: error: redefinition of ‘cxl_is_type2_device’
1090 | bool cxl_is_type2_device(struct pci_dev *pdev)
| ^~~~~~~~~~~~~~~~~~~
In file included from drivers/cxl/pci.c:11:
./include/linux/pci.h:1472:20: note: previous definition of ‘cxl_is_type2_device’ with type ‘bool(struct pci_dev *)’ {aka ‘_Bool(struct pci_dev *)’}
1472 | static inline bool cxl_is_type2_device(struct pci_dev *dev)
| ^~~~~~~~~~~~~~~~~~~
drivers/cxl/pci.c: In function ‘cxl_check_region_driver_bound’:
drivers/cxl/pci.c:1419:28: error: ‘cxl_region_rwsem’ undeclared (first use in this function); did you mean ‘cxl_region_ref’?
1419 | guard(rwsem_read)(&cxl_region_rwsem);
| ^~~~~~~~~~~~~~~~
| cxl_region_refdrivers/cxl/pci.c:1419:28: note: each undeclared identifier is reported only once for each function it appears indrivers/cxl/pci.c:1420:41: error: ‘struct cxl_region’ has no member named ‘driver’
1420 | if (cxld->region && cxld->region->driver)
| ^~drivers/cxl/pci.c: In function ‘cxl_decoder_kill_region_iter’:drivers/cxl/pci.c:1437:9: error: implicit declaration of function ‘cxl_decoder_kill_region_locked’; did you mean ‘cxl_decoder_kill_region_iter’? [-Werror=implicit-function-declaration]
1437 | cxl_decoder_kill_region_locked(cxled);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| cxl_decoder_kill_region_iter
drivers/cxl/pci.c: In function ‘cxl_region_flush_device_caches’:
drivers/cxl/pci.c:1504:53: error: ‘struct cxl_dev_state’ has no member named ‘pdev’; did you mean ‘dev’?
1504 | if (!target_cxlds || !target_cxlds->pdev)
| ^~~~
| dev
drivers/cxl/pci.c:1507:35: error: ‘struct cxl_dev_state’ has no member named ‘pdev’; did you mean ‘dev’?
1507 | if (target_cxlds->pdev != target_pdev)
| ^~~~
| dev
drivers/cxl/pci.c: In function ‘cxl_reset_prepare_memdev’:
drivers/cxl/pci.c:1548:21: error: ‘cxl_region_rwsem’ undeclared (first use in this function); did you mean ‘cxl_region_ref’?
1548 | down_write(&cxl_region_rwsem);
| ^~~~~~~~~~~~~~~~
| cxl_region_ref
In file included from ./include/linux/spinlock.h:63,
from ./include/linux/sched.h:37,
from ./include/linux/percpu.h:12,
from ./arch/x86/include/asm/msr.h:16,
from ./arch/x86/include/asm/tsc.h:11,
from ./arch/x86/include/asm/timex.h:6,
from ./include/linux/timex.h:67,
from ./include/linux/time32.h:13,
from ./include/linux/time.h:60,
from ./include/linux/stat.h:19,
from ./include/linux/module.h:13,
from drivers/cxl/pci.c:6:
drivers/cxl/pci.c: In function ‘cxl_reset_cleanup_memdev’:
drivers/cxl/pci.c:1585:35: error: ‘cxl_region_rwsem’ undeclared (first use in this function); did you mean ‘cxl_region_ref’?
1585 | if (lockdep_is_held_type(&cxl_region_rwsem, -1))
| ^~~~~~~~~~~~~~~~./include/linux/lockdep.h:253:61: note: in definition of macro ‘lockdep_is_held_type’
253 | fine lockdep_is_held_type(lock, r) lock_is_held_type(&(lock)->dep_map, (r))
| ^~~~
drivers/cxl/pci.c: At top level:drivers/cxl/pci.c:1665:5: error: redefinition of ‘cxl_reset_prepare_device’
1665 | int cxl_reset_prepare_device(struct pci_dev *pdev)
| ^~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/pci.h:1477:19: note: previous definition of ‘cxl_reset_prepare_device’ with type ‘int(struct pci_dev *)’
1477 | static inline int cxl_reset_prepare_device(struct pci_dev *pdev)
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/cxl/pci.c:1696:6: error: redefinition of ‘cxl_reset_cleanup_device’
1696 | void cxl_reset_cleanup_device(struct pci_dev *pdev)
| ^~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/pci.h:1482:20: note: previous definition of ‘cxl_reset_cleanup_device’ with type ‘void(struct pci_dev *)’
1482 | static inline void cxl_reset_cleanup_device(struct pci_dev *pdev)
| ^~~~~~~~~~~~~~~~~~~~~~~~cc1: some warnings being treated as errors