From: Nava kishore Manne <nava.kishore.manne@amd.com>
To: <mdf@kernel.org>, <hao.wu@intel.com>, <yilun.xu@intel.com>,
<trix@redhat.com>, <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
Date: Thu, 25 May 2023 15:24:38 +0530 [thread overview]
Message-ID: <20230525095438.2766625-1-nava.kishore.manne@amd.com> (raw)
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
next reply other threads:[~2023-05-25 9:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 9:54 Nava kishore Manne [this message]
2023-06-21 4:00 ` [RFC PATCH] fpga: fpga-bridge: Add manual set option via sysfs Manne, Nava kishore
2023-06-25 8:39 ` Xu Yilun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230525095438.2766625-1-nava.kishore.manne@amd.com \
--to=nava.kishore.manne@amd.com \
--cc=hao.wu@intel.com \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mdf@kernel.org \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).