Skip to content

Commit 41a8b2c

Browse files
WuHao270gregkh
authored andcommitted
fpga: region: add compat_id support
This patch introduces a compat_id pointer member and sysfs interface for each fpga region, similar as compat_id for fpga manager, it allows applications to read the per region compat_id for compatibility checking before other actions on this fpga-region (e.g. PR). 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 99a560b commit 41a8b2c

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
What: /sys/class/fpga_region/<region>/compat_id
2+
Date: June 2018
3+
KernelVersion: 4.19
4+
Contact: Wu Hao <hao.wu@intel.com>
5+
Description: FPGA region id for compatibility check, e.g. compatibility
6+
of the FPGA reconfiguration hardware and image. This value
7+
is defined or calculated by the layer that is creating the
8+
FPGA region. This interface returns the compat_id value or
9+
just error code -ENOENT in case compat_id is not used.

‎drivers/fpga/fpga-region.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,27 @@ int fpga_region_program_fpga(struct fpga_region *region)
158158
}
159159
EXPORT_SYMBOL_GPL(fpga_region_program_fpga);
160160

161+
static ssize_t compat_id_show(struct device *dev,
162+
struct device_attribute *attr, char *buf)
163+
{
164+
struct fpga_region *region = to_fpga_region(dev);
165+
166+
if (!region->compat_id)
167+
return -ENOENT;
168+
169+
return sprintf(buf, "%016llx%016llx\n",
170+
(unsigned long long)region->compat_id->id_h,
171+
(unsigned long long)region->compat_id->id_l);
172+
}
173+
174+
static DEVICE_ATTR_RO(compat_id);
175+
176+
static struct attribute *fpga_region_attrs[] = {
177+
&dev_attr_compat_id.attr,
178+
NULL,
179+
};
180+
ATTRIBUTE_GROUPS(fpga_region);
181+
161182
/**
162183
* fpga_region_create - alloc and init a struct fpga_region
163184
* @dev: device parent
@@ -258,6 +279,7 @@ static int __init fpga_region_init(void)
258279
if (IS_ERR(fpga_region_class))
259280
return PTR_ERR(fpga_region_class);
260281

282+
fpga_region_class->dev_groups = fpga_region_groups;
261283
fpga_region_class->dev_release = fpga_region_dev_release;
262284

263285
return 0;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* @bridge_list: list of FPGA bridges specified in region
1515
* @mgr: FPGA manager
1616
* @info: FPGA image info
17+
* @compat_id: FPGA region id for compatibility check.
1718
* @priv: private data
1819
* @get_bridges: optional function to get bridges to a list
1920
*/
@@ -23,6 +24,7 @@ struct fpga_region {
2324
struct list_head bridge_list;
2425
struct fpga_manager *mgr;
2526
struct fpga_image_info *info;
27+
struct fpga_compat_id *compat_id;
2628
void *priv;
2729
int (*get_bridges)(struct fpga_region *region);
2830
};

0 commit comments

Comments
 (0)