Message ID | 20230525095438.2766625-1-nava.kishore.manne@amd.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [RFC] fpga: fpga-bridge: Add manual set option via sysfs | expand |
Ping! > -----Original Message----- > From: Manne, Nava kishore <nava.kishore.manne@amd.com> > Sent: Thursday, May 25, 2023 3:25 PM > To: mdf@kernel.org; hao.wu@intel.com; yilun.xu@intel.com; > trix@redhat.com; Manne, Nava kishore <nava.kishore.manne@amd.com>; > linux-kernel@vger.kernel.org; linux-fpga@vger.kernel.org > Subject: [RFC PATCH] fpga: fpga-bridge: Add manual set option via sysfs > > This patch is intended for manual testing only. > It is provide an option to manually test bridges. > > Enabling bridge (!0 values are handled) > br1# echo 1 > /sys/class/fpga_bridge/<bridge>/set > > Disable bridge > br1# echo 0 > /sys/class/fpga_bridge/<bridge>/set > > Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com> > --- > .../ABI/testing/sysfs-class-fpga-bridge | 9 ++++++ > drivers/fpga/fpga-bridge.c | 30 +++++++++++++++++++ > 2 files changed, 39 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-class-fpga-bridge > b/Documentation/ABI/testing/sysfs-class-fpga-bridge > index 312ae2c579d8..e157eb737bfb 100644 > --- a/Documentation/ABI/testing/sysfs-class-fpga-bridge > +++ b/Documentation/ABI/testing/sysfs-class-fpga-bridge > @@ -9,3 +9,12 @@ Date: January 2016 > KernelVersion: 4.5 > Contact: Alan Tull <atull@opensource.altera.com> > Description: Show bridge state as "enabled" or "disabled" > + > +What: /sys/class/fpga_bridge/<bridge>/set > +Date: May 2023 > +KernelVersion: 6.4 > +Contact: Nava kishore Manne <nava.kishore.manne@amd.com> > +Description: Manual set bridge state (0-disable, !0 enable). > + Enabling this option requires that the module is > + compiled with #define DEBUG which is enabled by default > + when CONFIG_DEBUG_KERNEL is setup. > diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c index > a6c25dee9cc1..54d15b709b10 100644 > --- a/drivers/fpga/fpga-bridge.c > +++ b/drivers/fpga/fpga-bridge.c > @@ -13,6 +13,12 @@ > #include <linux/slab.h> > #include <linux/spinlock.h> > > +/* For enabling manual bridge set(enable/disable) function */ #ifdef > +CONFIG_DEBUG_KERNEL #undef DEBUG #define DEBUG #endif > + > static DEFINE_IDA(fpga_bridge_ida); > static struct class *fpga_bridge_class; > > @@ -307,9 +313,33 @@ static ssize_t state_show(struct device *dev, static > DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(state); > > +#ifdef DEBUG > +static ssize_t set_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct fpga_bridge *bridge = to_fpga_bridge(dev); > + long enable; > + int ret; > + > + ret = kstrtol(buf, 16, &enable); > + if (ret) > + return ret; > + > + if (bridge->br_ops && bridge->br_ops->enable_set) > + enable = bridge->br_ops->enable_set(bridge, !!enable); > + > + return count; > +} > +static DEVICE_ATTR_WO(set); > +#endif > + > static struct attribute *fpga_bridge_attrs[] = { > &dev_attr_name.attr, > &dev_attr_state.attr, > +#ifdef DEBUG > + &dev_attr_set.attr, > +#endif > NULL, > }; > ATTRIBUTE_GROUPS(fpga_bridge); > -- > 2.25.1
On 2023-06-21 at 04:00:53 +0000, Manne, Nava kishore wrote: > Ping! > > > -----Original Message----- > > From: Manne, Nava kishore <nava.kishore.manne@amd.com> > > Sent: Thursday, May 25, 2023 3:25 PM > > To: mdf@kernel.org; hao.wu@intel.com; yilun.xu@intel.com; > > trix@redhat.com; Manne, Nava kishore <nava.kishore.manne@amd.com>; > > linux-kernel@vger.kernel.org; linux-fpga@vger.kernel.org > > Subject: [RFC PATCH] fpga: fpga-bridge: Add manual set option via sysfs > > > > This patch is intended for manual testing only. Debug interfaces should be in debugfs. But before that, I'm not convinced why we need this interface. Even with DEBUG or debugfs we try best not to break the system. But this bridge enable/disable interface will break the functionality of FPGA region silently. Thanks Yilun > > It is provide an option to manually test bridges. > > > > Enabling bridge (!0 values are handled) > > br1# echo 1 > /sys/class/fpga_bridge/<bridge>/set > > > > Disable bridge > > br1# echo 0 > /sys/class/fpga_bridge/<bridge>/set > > > > Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com> > > --- > > .../ABI/testing/sysfs-class-fpga-bridge | 9 ++++++ > > drivers/fpga/fpga-bridge.c | 30 +++++++++++++++++++ > > 2 files changed, 39 insertions(+) > > > > diff --git a/Documentation/ABI/testing/sysfs-class-fpga-bridge > > b/Documentation/ABI/testing/sysfs-class-fpga-bridge > > index 312ae2c579d8..e157eb737bfb 100644 > > --- a/Documentation/ABI/testing/sysfs-class-fpga-bridge > > +++ b/Documentation/ABI/testing/sysfs-class-fpga-bridge > > @@ -9,3 +9,12 @@ Date: January 2016 > > KernelVersion: 4.5 > > Contact: Alan Tull <atull@opensource.altera.com> > > Description: Show bridge state as "enabled" or "disabled" > > + > > +What: /sys/class/fpga_bridge/<bridge>/set > > +Date: May 2023 > > +KernelVersion: 6.4 > > +Contact: Nava kishore Manne <nava.kishore.manne@amd.com> > > +Description: Manual set bridge state (0-disable, !0 enable). > > + Enabling this option requires that the module is > > + compiled with #define DEBUG which is enabled by default > > + when CONFIG_DEBUG_KERNEL is setup. > > diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c index > > a6c25dee9cc1..54d15b709b10 100644 > > --- a/drivers/fpga/fpga-bridge.c > > +++ b/drivers/fpga/fpga-bridge.c > > @@ -13,6 +13,12 @@ > > #include <linux/slab.h> > > #include <linux/spinlock.h> > > > > +/* For enabling manual bridge set(enable/disable) function */ #ifdef > > +CONFIG_DEBUG_KERNEL #undef DEBUG #define DEBUG #endif > > + > > static DEFINE_IDA(fpga_bridge_ida); > > static struct class *fpga_bridge_class; > > > > @@ -307,9 +313,33 @@ static ssize_t state_show(struct device *dev, static > > DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(state); > > > > +#ifdef DEBUG > > +static ssize_t set_store(struct device *dev, > > + struct device_attribute *attr, > > + const char *buf, size_t count) > > +{ > > + struct fpga_bridge *bridge = to_fpga_bridge(dev); > > + long enable; > > + int ret; > > + > > + ret = kstrtol(buf, 16, &enable); > > + if (ret) > > + return ret; > > + > > + if (bridge->br_ops && bridge->br_ops->enable_set) > > + enable = bridge->br_ops->enable_set(bridge, !!enable); > > + > > + return count; > > +} > > +static DEVICE_ATTR_WO(set); > > +#endif > > + > > static struct attribute *fpga_bridge_attrs[] = { > > &dev_attr_name.attr, > > &dev_attr_state.attr, > > +#ifdef DEBUG > > + &dev_attr_set.attr, > > +#endif > > NULL, > > }; > > ATTRIBUTE_GROUPS(fpga_bridge); > > -- > > 2.25.1 >
diff --git a/Documentation/ABI/testing/sysfs-class-fpga-bridge b/Documentation/ABI/testing/sysfs-class-fpga-bridge index 312ae2c579d8..e157eb737bfb 100644 --- a/Documentation/ABI/testing/sysfs-class-fpga-bridge +++ b/Documentation/ABI/testing/sysfs-class-fpga-bridge @@ -9,3 +9,12 @@ Date: January 2016 KernelVersion: 4.5 Contact: Alan Tull <atull@opensource.altera.com> Description: Show bridge state as "enabled" or "disabled" + +What: /sys/class/fpga_bridge/<bridge>/set +Date: May 2023 +KernelVersion: 6.4 +Contact: Nava kishore Manne <nava.kishore.manne@amd.com> +Description: Manual set bridge state (0-disable, !0 enable). + Enabling this option requires that the module is + compiled with #define DEBUG which is enabled by default + when CONFIG_DEBUG_KERNEL is setup. diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c index a6c25dee9cc1..54d15b709b10 100644 --- a/drivers/fpga/fpga-bridge.c +++ b/drivers/fpga/fpga-bridge.c @@ -13,6 +13,12 @@ #include <linux/slab.h> #include <linux/spinlock.h> +/* For enabling manual bridge set(enable/disable) function */ +#ifdef CONFIG_DEBUG_KERNEL +#undef DEBUG +#define DEBUG +#endif + static DEFINE_IDA(fpga_bridge_ida); static struct class *fpga_bridge_class; @@ -307,9 +313,33 @@ static ssize_t state_show(struct device *dev, static DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(state); +#ifdef DEBUG +static ssize_t set_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct fpga_bridge *bridge = to_fpga_bridge(dev); + long enable; + int ret; + + ret = kstrtol(buf, 16, &enable); + if (ret) + return ret; + + if (bridge->br_ops && bridge->br_ops->enable_set) + enable = bridge->br_ops->enable_set(bridge, !!enable); + + return count; +} +static DEVICE_ATTR_WO(set); +#endif + static struct attribute *fpga_bridge_attrs[] = { &dev_attr_name.attr, &dev_attr_state.attr, +#ifdef DEBUG + &dev_attr_set.attr, +#endif NULL, }; ATTRIBUTE_GROUPS(fpga_bridge);
This patch is intended for manual testing only. It is provide an option to manually test bridges. Enabling bridge (!0 values are handled) br1# echo 1 > /sys/class/fpga_bridge/<bridge>/set Disable bridge br1# echo 0 > /sys/class/fpga_bridge/<bridge>/set Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com> --- .../ABI/testing/sysfs-class-fpga-bridge | 9 ++++++ drivers/fpga/fpga-bridge.c | 30 +++++++++++++++++++ 2 files changed, 39 insertions(+)