Skip to content

Commit b8bf268

Browse files
committed
Merge tag 'fpga-dfl-for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mdf/linux-fpga into char-misc-next
Moritz writes: FPGA DFL Changes for 5.4 This pull-request contains the FPGA DFL changes for 5.4 - The first three patches are cleanup patches making use of dev_groups and making the init callback optional. - One patch adds userclock sysfs entries that are DFL specific - One patch exposes AFU port disable/enable functions - One patch adds error reporting - One patch adds AFU SignalTap support - One patch adds FME global error reporting - The final patch is a documentation patch that decribes the virtualization interfaces This patchset requires the 'dev_groups_all_drivers' tag from drivers core for the dev_groups refactoring as well as the DFL changes already in char-misc-next. Signed-off-by: Moritz Fischer <mdf@kernel.org> * tag 'fpga-dfl-for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mdf/linux-fpga: Documentation: fpga: dfl: add descriptions for virtualization and new interfaces. fpga: dfl: fme: add global error reporting support fpga: dfl: afu: add STP (SignalTap) support fpga: dfl: afu: add error reporting support. fpga: dfl: afu: expose __afu_port_enable/disable function. fpga: dfl: afu: add userclock sysfs interfaces. fpga: dfl: afu: convert platform_driver to use dev_groups fpga: dfl: fme: convert platform_driver to use dev_groups fpga: dfl: make init callback optional driver core: add dev_groups to all drivers
2 parents ec13c78 + 77a0ef4 commit b8bf268

14 files changed

Lines changed: 1058 additions & 74 deletions

File tree

‎Documentation/ABI/testing/sysfs-platform-dfl-fme‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,65 @@ Description: Read-only. It returns socket_id to indicate which socket
4444
this FPGA belongs to, only valid for integrated solution.
4545
User only needs this information, in case standard numa node
4646
can't provide correct information.
47+
48+
What: /sys/bus/platform/devices/dfl-fme.0/errors/pcie0_errors
49+
Date: August 2019
50+
KernelVersion: 5.4
51+
Contact: Wu Hao <hao.wu@intel.com>
52+
Description: Read-Write. Read this file for errors detected on pcie0 link.
53+
Write this file to clear errors logged in pcie0_errors. Write
54+
fails with -EINVAL if input parsing fails or input error code
55+
doesn't match.
56+
57+
What: /sys/bus/platform/devices/dfl-fme.0/errors/pcie1_errors
58+
Date: August 2019
59+
KernelVersion: 5.4
60+
Contact: Wu Hao <hao.wu@intel.com>
61+
Description: Read-Write. Read this file for errors detected on pcie1 link.
62+
Write this file to clear errors logged in pcie1_errors. Write
63+
fails with -EINVAL if input parsing fails or input error code
64+
doesn't match.
65+
66+
What: /sys/bus/platform/devices/dfl-fme.0/errors/nonfatal_errors
67+
Date: August 2019
68+
KernelVersion: 5.4
69+
Contact: Wu Hao <hao.wu@intel.com>
70+
Description: Read-only. It returns non-fatal errors detected.
71+
72+
What: /sys/bus/platform/devices/dfl-fme.0/errors/catfatal_errors
73+
Date: August 2019
74+
KernelVersion: 5.4
75+
Contact: Wu Hao <hao.wu@intel.com>
76+
Description: Read-only. It returns catastrophic and fatal errors detected.
77+
78+
What: /sys/bus/platform/devices/dfl-fme.0/errors/inject_errors
79+
Date: August 2019
80+
KernelVersion: 5.4
81+
Contact: Wu Hao <hao.wu@intel.com>
82+
Description: Read-Write. Read this file to check errors injected. Write this
83+
file to inject errors for testing purpose. Write fails with
84+
-EINVAL if input parsing fails or input inject error code isn't
85+
supported.
86+
87+
What: /sys/bus/platform/devices/dfl-fme.0/errors/fme_errors
88+
Date: August 2019
89+
KernelVersion: 5.4
90+
Contact: Wu Hao <hao.wu@intel.com>
91+
Description: Read-Write. Read this file to get errors detected on FME.
92+
Write this file to clear errors logged in fme_errors. Write
93+
fials with -EINVAL if input parsing fails or input error code
94+
doesn't match.
95+
96+
What: /sys/bus/platform/devices/dfl-fme.0/errors/first_error
97+
Date: August 2019
98+
KernelVersion: 5.4
99+
Contact: Wu Hao <hao.wu@intel.com>
100+
Description: Read-only. Read this file to get the first error detected by
101+
hardware.
102+
103+
What: /sys/bus/platform/devices/dfl-fme.0/errors/next_error
104+
Date: August 2019
105+
KernelVersion: 5.4
106+
Contact: Wu Hao <hao.wu@intel.com>
107+
Description: Read-only. Read this file to get the second error detected by
108+
hardware.

‎Documentation/ABI/testing/sysfs-platform-dfl-port‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,56 @@ Contact: Wu Hao <hao.wu@intel.com>
4646
Description: Read-write. Read or set AFU latency tolerance reporting value.
4747
Set ltr to 1 if the AFU can tolerate latency >= 40us or set it
4848
to 0 if it is latency sensitive.
49+
50+
What: /sys/bus/platform/devices/dfl-port.0/userclk_freqcmd
51+
Date: August 2019
52+
KernelVersion: 5.4
53+
Contact: Wu Hao <hao.wu@intel.com>
54+
Description: Write-only. User writes command to this interface to set
55+
userclock to AFU.
56+
57+
What: /sys/bus/platform/devices/dfl-port.0/userclk_freqsts
58+
Date: August 2019
59+
KernelVersion: 5.4
60+
Contact: Wu Hao <hao.wu@intel.com>
61+
Description: Read-only. Read this file to get the status of issued command
62+
to userclck_freqcmd.
63+
64+
What: /sys/bus/platform/devices/dfl-port.0/userclk_freqcntrcmd
65+
Date: August 2019
66+
KernelVersion: 5.4
67+
Contact: Wu Hao <hao.wu@intel.com>
68+
Description: Write-only. User writes command to this interface to set
69+
userclock counter.
70+
71+
What: /sys/bus/platform/devices/dfl-port.0/userclk_freqcntrsts
72+
Date: August 2019
73+
KernelVersion: 5.4
74+
Contact: Wu Hao <hao.wu@intel.com>
75+
Description: Read-only. Read this file to get the status of issued command
76+
to userclck_freqcntrcmd.
77+
78+
What: /sys/bus/platform/devices/dfl-port.0/errors/errors
79+
Date: August 2019
80+
KernelVersion: 5.4
81+
Contact: Wu Hao <hao.wu@intel.com>
82+
Description: Read-Write. Read this file to get errors detected on port and
83+
Accelerated Function Unit (AFU). Write error code to this file
84+
to clear errors. Write fails with -EINVAL if input parsing
85+
fails or input error code doesn't match. Write fails with
86+
-EBUSY or -ETIMEDOUT if error can't be cleared as hardware
87+
in low power state (-EBUSY) or not respoding (-ETIMEDOUT).
88+
89+
What: /sys/bus/platform/devices/dfl-port.0/errors/first_error
90+
Date: August 2019
91+
KernelVersion: 5.4
92+
Contact: Wu Hao <hao.wu@intel.com>
93+
Description: Read-only. Read this file to get the first error detected by
94+
hardware.
95+
96+
What: /sys/bus/platform/devices/dfl-port.0/errors/first_malformed_req
97+
Date: August 2019
98+
KernelVersion: 5.4
99+
Contact: Wu Hao <hao.wu@intel.com>
100+
Description: Read-only. Read this file to get the first malformed request
101+
captured by hardware.

‎Documentation/fpga/dfl.rst‎

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ The following functions are exposed through ioctls:
8787
- Get driver API version (DFL_FPGA_GET_API_VERSION)
8888
- Check for extensions (DFL_FPGA_CHECK_EXTENSION)
8989
- Program bitstream (DFL_FPGA_FME_PORT_PR)
90+
- Assign port to PF (DFL_FPGA_FME_PORT_ASSIGN)
91+
- Release port from PF (DFL_FPGA_FME_PORT_RELEASE)
9092

9193
More functions are exposed through sysfs
9294
(/sys/class/fpga_region/regionX/dfl-fme.n/):
@@ -102,6 +104,10 @@ More functions are exposed through sysfs
102104
one FPGA device may have more than one port, this sysfs interface indicates
103105
how many ports the FPGA device has.
104106

107+
Global error reporting management (errors/)
108+
error reporting sysfs interfaces allow user to read errors detected by the
109+
hardware, and clear the logged errors.
110+
105111

106112
FIU - PORT
107113
==========
@@ -143,6 +149,10 @@ More functions are exposed through sysfs:
143149
Read Accelerator GUID (afu_id)
144150
afu_id indicates which PR bitstream is programmed to this AFU.
145151

152+
Error reporting (errors/)
153+
error reporting sysfs interfaces allow user to read port/afu errors
154+
detected by the hardware, and clear the logged errors.
155+
146156

147157
DFL Framework Overview
148158
======================
@@ -218,6 +228,101 @@ the compat_id exposed by the target FPGA region. This check is usually done by
218228
userspace before calling the reconfiguration IOCTL.
219229

220230

231+
FPGA virtualization - PCIe SRIOV
232+
================================
233+
This section describes the virtualization support on DFL based FPGA device to
234+
enable accessing an accelerator from applications running in a virtual machine
235+
(VM). This section only describes the PCIe based FPGA device with SRIOV support.
236+
237+
Features supported by the particular FPGA device are exposed through Device
238+
Feature Lists, as illustrated below:
239+
240+
::
241+
242+
+-------------------------------+ +-------------+
243+
| PF | | VF |
244+
+-------------------------------+ +-------------+
245+
^ ^ ^ ^
246+
| | | |
247+
+-----|------------|---------|--------------|-------+
248+
| | | | | |
249+
| +-----+ +-------+ +-------+ +-------+ |
250+
| | FME | | Port0 | | Port1 | | Port2 | |
251+
| +-----+ +-------+ +-------+ +-------+ |
252+
| ^ ^ ^ |
253+
| | | | |
254+
| +-------+ +------+ +-------+ |
255+
| | AFU | | AFU | | AFU | |
256+
| +-------+ +------+ +-------+ |
257+
| |
258+
| DFL based FPGA PCIe Device |
259+
+---------------------------------------------------+
260+
261+
FME is always accessed through the physical function (PF).
262+
263+
Ports (and related AFUs) are accessed via PF by default, but could be exposed
264+
through virtual function (VF) devices via PCIe SRIOV. Each VF only contains
265+
1 Port and 1 AFU for isolation. Users could assign individual VFs (accelerators)
266+
created via PCIe SRIOV interface, to virtual machines.
267+
268+
The driver organization in virtualization case is illustrated below:
269+
::
270+
271+
+-------++------++------+ |
272+
| FME || FME || FME | |
273+
| FPGA || FPGA || FPGA | |
274+
|Manager||Bridge||Region| |
275+
+-------++------++------+ |
276+
+-----------------------+ +--------+ | +--------+
277+
| FME | | AFU | | | AFU |
278+
| Module | | Module | | | Module |
279+
+-----------------------+ +--------+ | +--------+
280+
+-----------------------+ | +-----------------------+
281+
| FPGA Container Device | | | FPGA Container Device |
282+
| (FPGA Base Region) | | | (FPGA Base Region) |
283+
+-----------------------+ | +-----------------------+
284+
+------------------+ | +------------------+
285+
| FPGA PCIE Module | | Virtual | FPGA PCIE Module |
286+
+------------------+ Host | Machine +------------------+
287+
-------------------------------------- | ------------------------------
288+
+---------------+ | +---------------+
289+
| PCI PF Device | | | PCI VF Device |
290+
+---------------+ | +---------------+
291+
292+
FPGA PCIe device driver is always loaded first once a FPGA PCIe PF or VF device
293+
is detected. It:
294+
295+
* Finishes enumeration on both FPGA PCIe PF and VF device using common
296+
interfaces from DFL framework.
297+
* Supports SRIOV.
298+
299+
The FME device driver plays a management role in this driver architecture, it
300+
provides ioctls to release Port from PF and assign Port to PF. After release
301+
a port from PF, then it's safe to expose this port through a VF via PCIe SRIOV
302+
sysfs interface.
303+
304+
To enable accessing an accelerator from applications running in a VM, the
305+
respective AFU's port needs to be assigned to a VF using the following steps:
306+
307+
#. The PF owns all AFU ports by default. Any port that needs to be
308+
reassigned to a VF must first be released through the
309+
DFL_FPGA_FME_PORT_RELEASE ioctl on the FME device.
310+
311+
#. Once N ports are released from PF, then user can use command below
312+
to enable SRIOV and VFs. Each VF owns only one Port with AFU.
313+
314+
::
315+
316+
echo N > $PCI_DEVICE_PATH/sriov_numvfs
317+
318+
#. Pass through the VFs to VMs
319+
320+
#. The AFU under VF is accessible from applications in VM (using the
321+
same driver inside the VF).
322+
323+
Note that an FME can't be assigned to a VF, thus PR and other management
324+
functions are only available via the PF.
325+
221326
Device enumeration
222327
==================
223328
This section introduces how applications enumerate the fpga device from

‎drivers/base/dd.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,16 @@ static int really_probe(struct device *dev, struct device_driver *drv)
554554
goto probe_failed;
555555
}
556556

557+
if (device_add_groups(dev, drv->dev_groups)) {
558+
dev_err(dev, "device_add_groups() failed\n");
559+
goto dev_groups_failed;
560+
}
561+
557562
if (test_remove) {
558563
test_remove = false;
559564

565+
device_remove_groups(dev, drv->dev_groups);
566+
560567
if (dev->bus->remove)
561568
dev->bus->remove(dev);
562569
else if (drv->remove)
@@ -584,6 +591,11 @@ static int really_probe(struct device *dev, struct device_driver *drv)
584591
drv->bus->name, __func__, dev_name(dev), drv->name);
585592
goto done;
586593

594+
dev_groups_failed:
595+
if (dev->bus->remove)
596+
dev->bus->remove(dev);
597+
else if (drv->remove)
598+
drv->remove(dev);
587599
probe_failed:
588600
if (dev->bus)
589601
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
@@ -1114,6 +1126,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)
11141126

11151127
pm_runtime_put_sync(dev);
11161128

1129+
device_remove_groups(dev, drv->dev_groups);
1130+
11171131
if (dev->bus && dev->bus->remove)
11181132
dev->bus->remove(dev);
11191133
else if (drv->remove)

‎drivers/fpga/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ obj-$(CONFIG_FPGA_DFL_FME_BRIDGE) += dfl-fme-br.o
3939
obj-$(CONFIG_FPGA_DFL_FME_REGION) += dfl-fme-region.o
4040
obj-$(CONFIG_FPGA_DFL_AFU) += dfl-afu.o
4141

42-
dfl-fme-objs := dfl-fme-main.o dfl-fme-pr.o
42+
dfl-fme-objs := dfl-fme-main.o dfl-fme-pr.o dfl-fme-error.o
4343
dfl-afu-objs := dfl-afu-main.o dfl-afu-region.o dfl-afu-dma-region.o
44+
dfl-afu-objs += dfl-afu-error.o
4445

4546
# Drivers for FPGAs which implement DFL
4647
obj-$(CONFIG_FPGA_DFL_PCI) += dfl-pci.o

0 commit comments

Comments
 (0)