ocxl: control via sysfs whether the FPGA is reloaded on a link reset
Subsystems (2)
PATCH v4 1/1 ocxl: control via sysfs whether the FPGA is reloaded on a link reset
From: Philippe Bergheaud <[email protected]>
Some opencapi FPGA images allow to control if the FPGA should be reloaded on the next adapter reset. If it is supported, the image specifies it through a Vendor Specific DVSEC in the config space of function 0.
---
Changelog:
v2:
- refine ResetReload debug message
- do not call get_function_0() if pci_dev is for function 0
v3:
- avoid get_function_0() in ocxl_config_set_reset_reload also
v4:
- simplify parsing of Vendor Specific DVSEC during AFU init
- only set/unset bit 0 of the config space register
- commonize code to fetch the right PCI function and DVSEC offset
- use kstrtoint() when parsing the sysfs buffer
Documentation/ABI/testing/sysfs-class-ocxl | 10 +++ drivers/misc/ocxl/config.c | 81 ++++++++++++++++++++-- drivers/misc/ocxl/ocxl_internal.h | 6 ++ drivers/misc/ocxl/sysfs.c | 35 ++++++++++ include/misc/ocxl-config.h | 1 + 5 files changed, 128 insertions(+), 5 deletions(-)
Documentation/ABI/testing/sysfs-class-ocxl +10 -0
@@ -33,3 +33,13 @@ Date: January 2018 Contact: [email protected] Description: read/write Give access the global mmio area for the AFU + +What: /sys/class/ocxl/<afu name>/reload_on_reset +Date: February 2020 +Contact: [email protected] +Description: read/write + Control whether the FPGA is reloaded on a link reset + 0 Do not reload FPGA image from flash + 1 Reload FPGA image from flash + unavailable + The device does not support this capability
drivers/misc/ocxl/config.c +76 -5
107 lines not on this page · raw message
drivers/misc/ocxl/ocxl_internal.h +6 -0
@@ -112,6 +112,12 @@ void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size);*/ int ocxl_config_get_pasid_info (struct pci_dev *dev,int *count); +/* +* Control whether the FPGA is reloaded on a link reset +*/ +int ocxl_config_get_reset_reload (struct pci_dev *dev,int *val); +int ocxl_config_set_reset_reload (struct pci_dev *dev,int val); +/* * Check if an AFU index is valid for the given function. *
drivers/misc/ocxl/sysfs.c +35 -0
@@ -51,11 +51,46 @@ static ssize_t contexts_show(struct device *device, afu->pasid_count, afu->pasid_max); } +static ssize_t reload_on_reset_show (struct device *device, +struct device_attribute *attr, +char *buf) +{ +struct ocxl_afu *afu =to_afu (device); +struct ocxl_fn *fn = afu->fn; +struct pci_dev *pci_dev =to_pci_dev (fn->dev.parent); +int val; + +if (ocxl_config_get_reset_reload (pci_dev, &val)) +return scnprintf (buf,PAGE_SIZE ,"unavailable\n" ); + +return scnprintf (buf,PAGE_SIZE ,"%d\n" , val); +} + +static ssize_t reload_on_reset_store (struct device *device, +struct device_attribute *attr, +const char *buf,size_t count) +{ +struct ocxl_afu *afu =to_afu (device); +struct ocxl_fn *fn = afu->fn; +struct pci_dev *pci_dev =to_pci_dev (fn->dev.parent); +int rc, val; + + rc =kstrtoint (buf,0 , &val); +if (rc || (val !=0 && val !=1 )) +return -EINVAL ; + +if (ocxl_config_set_reset_reload (pci_dev, val)) +return -ENODEV ; + +return count; +} +static struct device_attribute afu_attrs[] = {__ATTR_RO (global_mmio_size),__ATTR_RO (pp_mmio_size),__ATTR_RO (afu_version),__ATTR_RO (contexts), +__ATTR_RW (reload_on_reset), }; static ssize_t global_mmio_read(struct file *filp, struct kobject *kobj,
include/misc/ocxl-config.h +1 -0
@@ -41,5 +41,6 @@#define OCXL_DVSEC_VENDOR_CFG_VERS 0x0C#define OCXL_DVSEC_VENDOR_TLX_VERS 0x10#define OCXL_DVSEC_VENDOR_DLX_VERS 0x20 +#define OCXL_DVSEC_VENDOR_RESET_RELOAD 0x38#endif /* _OCXL_CONFIG_H_ */
Signature · 1 line
2.25.1
Quoted 8 lines · Frederic Barrat
From: Philippe Bergheaud <[email protected]>
Some opencapi FPGA images allow to control if the FPGA should be reloaded on the next adapter reset. If it is supported, the image specifies it through a Vendor Specific DVSEC in the config space of function 0.
Signed-off-by Philippe Bergheaud <[email protected]>Signed-off-by Frederic Barrat <[email protected]>
Thanks for the cleanups.
My earlier concerns have been addressed thanks to an update to the relevant specification - a Vendor Specific DVSEC with an IBM vendor ID and IBM-specific DVSEC ID is specific to the IBM CFG subsystem implementation, alternative implementations will need to use a different vendor IDs and DVSEC IDs.
Quoted 30 lines
---
Changelog:
v2:
- refine ResetReload debug message
- do not callget_function_0()ifpci_devis for function 0
v3:
- avoidget_function_0()inocxl_config_set_reset_reloadalso
v4:
- simplify parsing of Vendor Specific DVSEC during AFU init
- only set/unset bit 0 of the config space register
- commonize code to fetch the right PCI function and DVSEC offset
- usekstrtoint()when parsing the sysfs bufferDocumentation/ABI/testing/sysfs-class-ocxl | 10 +++ drivers/misc/ocxl/config.c | 81 ++++++++++++++++++++-- drivers/misc/ocxl/ocxl_internal.h | 6 ++ drivers/misc/ocxl/sysfs.c | 35 ++++++++++ include/misc/ocxl-config.h | 1 + 5 files changed, 128 insertions(+), 5 deletions(-)Documentation/ABI/testing/sysfs-class-ocxl +0
-0@@ -33,3 +33,13 @@ Date: January 2018 Contact: [email protected] Description: read/write Give access the global mmio area for the AFU
Documentation/ABI/testing/sysfs-class-ocxl Date: January 2018 · line 45
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-ocxl +10
-0+ +What: /sys/class/ocxl/<afu name>/reload_on_reset +Date: February 2020 +Contact: [email protected] +Description: read/write + Control whether the FPGA is reloaded on a link reset + 0 Do not reload FPGA image from flash + 1 Reload FPGA image from flash + unavailable + The device does not support this capability
We should perhaps document here that this is specific to the IBM CFG implementation and the IBM-specific DVSEC?
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited