linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] fpga: fpga-bridge: Add manual set option via sysfs
@ 2023-05-25  9:54 Nava kishore Manne
  2023-06-21  4:00 ` Manne, Nava kishore
  0 siblings, 1 reply; 3+ messages in thread
From: Nava kishore Manne @ 2023-05-25  9:54 UTC (permalink / raw)
  To: mdf, hao.wu, yilun.xu, trix, nava.kishore.manne, linux-kernel,
	linux-fpga

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [RFC PATCH] fpga: fpga-bridge: Add manual set option via sysfs
  2023-05-25  9:54 [RFC PATCH] fpga: fpga-bridge: Add manual set option via sysfs Nava kishore Manne
@ 2023-06-21  4:00 ` Manne, Nava kishore
  2023-06-25  8:39   ` Xu Yilun
  0 siblings, 1 reply; 3+ messages in thread
From: Manne, Nava kishore @ 2023-06-21  4:00 UTC (permalink / raw)
  To: mdf, hao.wu, yilun.xu, trix, linux-kernel, linux-fpga

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] fpga: fpga-bridge: Add manual set option via sysfs
  2023-06-21  4:00 ` Manne, Nava kishore
@ 2023-06-25  8:39   ` Xu Yilun
  0 siblings, 0 replies; 3+ messages in thread
From: Xu Yilun @ 2023-06-25  8:39 UTC (permalink / raw)
  To: Manne, Nava kishore; +Cc: mdf, hao.wu, trix, linux-kernel, linux-fpga

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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-25  8:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-25  9:54 [RFC PATCH] fpga: fpga-bridge: Add manual set option via sysfs Nava kishore Manne
2023-06-21  4:00 ` Manne, Nava kishore
2023-06-25  8:39   ` Xu Yilun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).