cxl: Dirty shutdown followups
Davidlohr Bueso
maintainerv3 cover cxl: Dirty shutdown followups
Changes from v2:
- remove leftover cxl_gpf_device() declaration
Changes from v1 (https://lore.kernel.org/linux-cxl/[email protected]/):
- crated a new cxl_gpf_get_dvsec() helper to share for port and dev gpf (DaveJ)
- renamed cxl_dirty_shutdown_state() to cxl_arm_dirty_shutdown() (DaveJ)
- exported the cxl_gpf_get_dvsec() symbol used outside of core (Yi, DaveJ)
- introduced CXL_INVALID_DIRTY_SHUTDOWN_COUNT (DaveJ)
- use u64 for cxl_nvd->dirty_shutdowns,
- rename to cxl_nvdimm_setup_dirty_tracking() and use return statements (DaveJ)
- picked up review tag in patch 4 (DaveJ)
Hi,
Some followup patches to the GPF work. First two patches are from feedback provided by DaveJ. The third patch adds a $platform/dirty_shutdown sysfs attribute to expose the count to userspace. Fourth patch adds support emulating the set shutdown state command for the mock device.
Applies against the -next branch of cxl.git.
Thanks!
Davidlohr Bueso (4):
cxl/pci: Introduce cxl_gpf_get_dvsec()
cxl/pmem: Rename cxl_dirty_shutdown_state()
cxl/pmem: Export dirty shutdown count via sysfs
tools/testing/cxl: Set Shutdown State support
Documentation/ABI/testing/sysfs-bus-cxl | 12 +++ Documentation/driver-api/cxl/maturity-map.rst | 2 +- drivers/cxl/core/mbox.c | 25 +++++- drivers/cxl/core/pci.c | 38 ++++++--- drivers/cxl/cxl.h | 3 + drivers/cxl/cxlmem.h | 15 +++- drivers/cxl/pmem.c | 77 +++++++++++++++++-- tools/testing/cxl/test/mem.c | 23 ++++++ 8 files changed, 173 insertions(+), 22 deletions(-)
--
2.39.5
Davidlohr Bueso
maintainerPATCH v3 1/4 cxl/pci: Introduce cxl_gpf_get_dvsec()
Add a helper to fetch the port/device GPF dvsecs. This is currently only used for ports, but a later patch to export dirty count to users will make use of the device one.
--- drivers/cxl/core/pci.c | 38 ++++++++++++++++++++++++++++---------- drivers/cxl/cxl.h | 2 ++ 2 files changed, 30 insertions(+), 10 deletions(-)
drivers/cxl/core/pci.c +28 -10
@@ -1072,6 +1072,27 @@ int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c)#define GPF_TIMEOUT_BASE_MAX 2#define GPF_TIMEOUT_SCALE_MAX 7/* 10 seconds */ +int cxl_gpf_get_dvsec (struct device *dev,bool port) +{ +struct pci_dev *pdev; +int dvsec; + +if (!dev_is_pci (dev)) +return -EINVAL ; + + pdev =to_pci_dev (dev); +if (!pdev) +return -EINVAL ; + + dvsec =pci_find_dvsec_capability (pdev,PCI_VENDOR_ID_CXL , + port ?CXL_DVSEC_PORT_GPF :CXL_DVSEC_DEVICE_GPF ); +if (!dvsec) +pci_warn (pdev,"%s GPF DVSEC not present\n" , + port ?"Port" :"Device" ); +return dvsec; +} +EXPORT_SYMBOL_NS_GPL (cxl_gpf_get_dvsec,"CXL" ); +static int update_gpf_port_dvsec (struct pci_dev *pdev,int dvsec,int phase) {u64 base, scale;
@@ -1116,26 +1137,23 @@ int cxl_gpf_port_setup(struct device *dport_dev, struct cxl_port *port) {struct pci_dev *pdev; -if (!dev_is_pci (dport_dev)) -return 0 ; - - pdev =to_pci_dev (dport_dev); -if (!pdev || !port) +if (!port)return -EINVAL ;if (!port->gpf_dvsec) {int dvsec; - dvsec =pci_find_dvsec_capability (pdev,PCI_VENDOR_ID_CXL , -CXL_DVSEC_PORT_GPF ); -if (!dvsec) { -pci_warn (pdev,"Port GPF DVSEC not present\n" ); + dvsec =cxl_gpf_get_dvsec (dport_dev, true); +if (dvsec <=0 )return -EINVAL ; - } port->gpf_dvsec = dvsec; } + pdev =to_pci_dev (dport_dev); +if (!pdev) +return -EINVAL ; +update_gpf_port_dvsec (pdev, port->gpf_dvsec,1 );update_gpf_port_dvsec (pdev, port->gpf_dvsec,2 );
drivers/cxl/cxl.h +2 -0
@@ -901,4 +901,6 @@ bool cxl_endpoint_decoder_reset_detected(struct cxl_port *port);#define __mock static#endif +int cxl_gpf_get_dvsec (struct device *dev,bool port); +#endif /* __CXL_H__ */
Signature · 1 line
2.39.5