Skip to content

Commit ecb5fbe

Browse files
WuHao270gregkh
authored andcommitted
fpga: mgr: add status for fpga-manager
This patch adds status sysfs interface for fpga manager, it's a read only interface which allows user to get fpga manager status, including full/partial reconfiguration error and other status information. It adds a status callback to fpga_manager_ops too, allows each fpga_manager driver to define its own method to collect latest status from hardware. The following sysfs file is created: * /sys/class/fpga_manager/<fpga>/status Return status of fpga manager, including reconfiguration errors. Signed-off-by: Wu Hao <hao.wu@intel.com> Acked-by: Alan Tull <atull@kernel.org> Acked-by: Moritz Fischer <mdf@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 571d78b commit ecb5fbe

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

‎Documentation/ABI/testing/sysfs-class-fpga-manager‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,27 @@ Description: Read fpga manager state as a string.
3535
* write complete = Doing post programming steps
3636
* write complete error = Error while doing post programming
3737
* operating = FPGA is programmed and operating
38+
39+
What: /sys/class/fpga_manager/<fpga>/status
40+
Date: June 2018
41+
KernelVersion: 4.19
42+
Contact: Wu Hao <hao.wu@intel.com>
43+
Description: Read fpga manager status as a string.
44+
If FPGA programming operation fails, it could be caused by crc
45+
error or incompatible bitstream image. The intent of this
46+
interface is to provide more detailed information for FPGA
47+
programming errors to userspace. This is a list of strings for
48+
the supported status.
49+
50+
* reconfig operation error - invalid operations detected by
51+
reconfiguration hardware.
52+
e.g. start reconfiguration
53+
with errors not cleared
54+
* reconfig CRC error - CRC error detected by
55+
reconfiguration hardware.
56+
* reconfig incompatible image - reconfiguration image is
57+
incompatible with hardware
58+
* reconfig IP protocol error - protocol errors detected by
59+
reconfiguration hardware
60+
* reconfig fifo overflow error - FIFO overflow detected by
61+
reconfiguration hardware

‎drivers/fpga/fpga-mgr.c‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,40 @@ static ssize_t state_show(struct device *dev,
406406
return sprintf(buf, "%s\n", state_str[mgr->state]);
407407
}
408408

409+
static ssize_t status_show(struct device *dev,
410+
struct device_attribute *attr, char *buf)
411+
{
412+
struct fpga_manager *mgr = to_fpga_manager(dev);
413+
u64 status;
414+
int len = 0;
415+
416+
if (!mgr->mops->status)
417+
return -ENOENT;
418+
419+
status = mgr->mops->status(mgr);
420+
421+
if (status & FPGA_MGR_STATUS_OPERATION_ERR)
422+
len += sprintf(buf + len, "reconfig operation error\n");
423+
if (status & FPGA_MGR_STATUS_CRC_ERR)
424+
len += sprintf(buf + len, "reconfig CRC error\n");
425+
if (status & FPGA_MGR_STATUS_INCOMPATIBLE_IMAGE_ERR)
426+
len += sprintf(buf + len, "reconfig incompatible image\n");
427+
if (status & FPGA_MGR_STATUS_IP_PROTOCOL_ERR)
428+
len += sprintf(buf + len, "reconfig IP protocol error\n");
429+
if (status & FPGA_MGR_STATUS_FIFO_OVERFLOW_ERR)
430+
len += sprintf(buf + len, "reconfig fifo overflow error\n");
431+
432+
return len;
433+
}
434+
409435
static DEVICE_ATTR_RO(name);
410436
static DEVICE_ATTR_RO(state);
437+
static DEVICE_ATTR_RO(status);
411438

412439
static struct attribute *fpga_mgr_attrs[] = {
413440
&dev_attr_name.attr,
414441
&dev_attr_state.attr,
442+
&dev_attr_status.attr,
415443
NULL,
416444
};
417445
ATTRIBUTE_GROUPS(fpga_mgr);

‎include/linux/fpga/fpga-mgr.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ struct fpga_image_info {
101101
* struct fpga_manager_ops - ops for low level fpga manager drivers
102102
* @initial_header_size: Maximum number of bytes that should be passed into write_init
103103
* @state: returns an enum value of the FPGA's state
104+
* @status: returns status of the FPGA, including reconfiguration error code
104105
* @write_init: prepare the FPGA to receive confuration data
105106
* @write: write count bytes of configuration data to the FPGA
106107
* @write_sg: write the scatter list of configuration data to the FPGA
@@ -115,6 +116,7 @@ struct fpga_image_info {
115116
struct fpga_manager_ops {
116117
size_t initial_header_size;
117118
enum fpga_mgr_states (*state)(struct fpga_manager *mgr);
119+
u64 (*status)(struct fpga_manager *mgr);
118120
int (*write_init)(struct fpga_manager *mgr,
119121
struct fpga_image_info *info,
120122
const char *buf, size_t count);
@@ -126,6 +128,13 @@ struct fpga_manager_ops {
126128
const struct attribute_group **groups;
127129
};
128130

131+
/* FPGA manager status: Partial/Full Reconfiguration errors */
132+
#define FPGA_MGR_STATUS_OPERATION_ERR BIT(0)
133+
#define FPGA_MGR_STATUS_CRC_ERR BIT(1)
134+
#define FPGA_MGR_STATUS_INCOMPATIBLE_IMAGE_ERR BIT(2)
135+
#define FPGA_MGR_STATUS_IP_PROTOCOL_ERR BIT(3)
136+
#define FPGA_MGR_STATUS_FIFO_OVERFLOW_ERR BIT(4)
137+
129138
/**
130139
* struct fpga_manager - fpga manager structure
131140
* @name: name of low level fpga manager

0 commit comments

Comments
 (0)