[PATCH v2 1/3] fpga: manager: change status api prototype, don't use older

Nava kishore Manne nava.manne at xilinx.com
Tue Jun 21 02:28:31 PDT 2022


Different vendors have different error sets defined by Hardware.
If we always define the new bits when we cannot find an exact 1:1
mapping in the core the 64 bits would soon be used out. Also, it's
hard to understand the mixture of different error sets.

To address these issues updated the status interface to handle the
vendor-specific messages in a generic way. With the updated status
interface the vendor-specific driver files can independently handle
the error messages.

Signed-off-by: Nava kishore Manne <nava.manne at xilinx.com>
---
Changes for v2:
              - New patch.

 drivers/fpga/dfl-fme-mgr.c    | 20 ++++++++++----------
 drivers/fpga/fpga-mgr.c       | 24 +++++-------------------
 include/linux/fpga/fpga-mgr.h |  2 +-
 3 files changed, 16 insertions(+), 30 deletions(-)

diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c
index af0785783b52..5a8e6a41c85c 100644
--- a/drivers/fpga/dfl-fme-mgr.c
+++ b/drivers/fpga/dfl-fme-mgr.c
@@ -72,22 +72,22 @@ struct fme_mgr_priv {
 	u64 pr_error;
 };
 
-static u64 pr_error_to_mgr_status(u64 err)
+static ssize_t pr_error_to_mgr_status(u64 err, char *buf)
 {
-	u64 status = 0;
+	ssize_t len = 0;
 
 	if (err & FME_PR_ERR_OPERATION_ERR)
-		status |= FPGA_MGR_STATUS_OPERATION_ERR;
+		len += sprintf(buf + len, "reconfig operation error\n");
 	if (err & FME_PR_ERR_CRC_ERR)
-		status |= FPGA_MGR_STATUS_CRC_ERR;
+		len += sprintf(buf + len, "reconfig CRC error\n");
 	if (err & FME_PR_ERR_INCOMPATIBLE_BS)
-		status |= FPGA_MGR_STATUS_INCOMPATIBLE_IMAGE_ERR;
+		len += sprintf(buf + len, "reconfig incompatible image\n");
 	if (err & FME_PR_ERR_PROTOCOL_ERR)
-		status |= FPGA_MGR_STATUS_IP_PROTOCOL_ERR;
+		len += sprintf(buf + len, "reconfig IP protocol error\n");
 	if (err & FME_PR_ERR_FIFO_OVERFLOW)
-		status |= FPGA_MGR_STATUS_FIFO_OVERFLOW_ERR;
+		len += sprintf(buf + len, "reconfig fifo overflow error\n");
 
-	return status;
+	return len;
 }
 
 static u64 fme_mgr_pr_error_handle(void __iomem *fme_pr)
@@ -252,11 +252,11 @@ static int fme_mgr_write_complete(struct fpga_manager *mgr,
 	return 0;
 }
 
-static u64 fme_mgr_status(struct fpga_manager *mgr)
+static ssize_t fme_mgr_status(struct fpga_manager *mgr, char *buf)
 {
 	struct fme_mgr_priv *priv = mgr->priv;
 
-	return pr_error_to_mgr_status(priv->pr_error);
+	return pr_error_to_mgr_status(priv->pr_error, buf);
 }
 
 static const struct fpga_manager_ops fme_mgr_ops = {
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index 08dc85fcd511..ae8de13a482e 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -38,10 +38,11 @@ static inline enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr)
 	return FPGA_MGR_STATE_UNKNOWN;
 }
 
-static inline u64 fpga_mgr_status(struct fpga_manager *mgr)
+static inline ssize_t fpga_mgr_status(struct fpga_manager *mgr, char *buf)
 {
 	if (mgr->mops->status)
-		return mgr->mops->status(mgr);
+		return mgr->mops->status(mgr, buf);
+
 	return 0;
 }
 
@@ -460,23 +461,8 @@ static ssize_t status_show(struct device *dev,
 			   struct device_attribute *attr, char *buf)
 {
 	struct fpga_manager *mgr = to_fpga_manager(dev);
-	u64 status;
-	int len = 0;
-
-	status = fpga_mgr_status(mgr);
-
-	if (status & FPGA_MGR_STATUS_OPERATION_ERR)
-		len += sprintf(buf + len, "reconfig operation error\n");
-	if (status & FPGA_MGR_STATUS_CRC_ERR)
-		len += sprintf(buf + len, "reconfig CRC error\n");
-	if (status & FPGA_MGR_STATUS_INCOMPATIBLE_IMAGE_ERR)
-		len += sprintf(buf + len, "reconfig incompatible image\n");
-	if (status & FPGA_MGR_STATUS_IP_PROTOCOL_ERR)
-		len += sprintf(buf + len, "reconfig IP protocol error\n");
-	if (status & FPGA_MGR_STATUS_FIFO_OVERFLOW_ERR)
-		len += sprintf(buf + len, "reconfig fifo overflow error\n");
-
-	return len;
+
+	return fpga_mgr_status(mgr, buf);
 }
 
 static DEVICE_ATTR_RO(name);
diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
index 0f9468771bb9..42c24426fb7f 100644
--- a/include/linux/fpga/fpga-mgr.h
+++ b/include/linux/fpga/fpga-mgr.h
@@ -154,7 +154,7 @@ struct fpga_manager_info {
 struct fpga_manager_ops {
 	size_t initial_header_size;
 	enum fpga_mgr_states (*state)(struct fpga_manager *mgr);
-	u64 (*status)(struct fpga_manager *mgr);
+	ssize_t (*status)(struct fpga_manager *mgr, char *buf);
 	int (*write_init)(struct fpga_manager *mgr,
 			  struct fpga_image_info *info,
 			  const char *buf, size_t count);
-- 
2.25.1




More information about the linux-arm-kernel mailing list