Skip to contentSkip to conversation

char: xillybus: Add driver for XillyUSB (Xillybus variant for USB)

PATCH Superseded [email protected] 2 participants 4 messages Feb 1, 2021

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH v2 1/1 char: xillybus: Add driver for XillyUSB (Xillybus variant for USB)

From: Eli Billauer <[email protected]>

The XillyUSB driver is the USB variant for the Xillybus FPGA IP core. Even though it presents a nearly identical API on the FPGA and host, it's almost a complete rewrite of the driver: The framework for exchanging data on a USB bus is fundamentally different from doing the same with a PCIe interface, which leaves very little in common between the existing driver and the new one for XillyUSB.

---

Notes:
Changelog:

v2:
- Add comment in Kconfig file, saying XILLYUSB really doesn't depend on XILLYBUS (following comment by Randy Dunlap)

- Use SEEK_* predefined constants instead of numbers

 drivers/char/xillybus/Kconfig    |   13 +
 drivers/char/xillybus/Makefile   |    1 +
 drivers/char/xillybus/xillyusb.c | 2363 ++++++++++++++++++++++++++++++
 3 files changed, 2377 insertions(+)
 create mode 100644 drivers/char/xillybus/xillyusb.c
drivers/char/xillybus/Kconfig +13 -0
index 130dbdce858f..2b5192fd22b9 100644
@@ -32,3 +32,16 @@ config XILLYBUS_OF
 	  system, say M.
 
 endif # if XILLYBUS
+
+# XILLYUSB doesn't depend on XILLYBUS
+
+config XILLYUSB
+	tristate "XillyUSB: Xillybus generic FPGA interface for USB"
+	depends on USB
+	select CRC32
+	help
+	  XillyUSB is the Xillybus variant which uses USB for communicating
+	  with the FPGA.
+
+	  Set to M if you want Xillybus to use USB for communicating with
+	  the FPGA.
drivers/char/xillybus/Makefile +1 -0
index 099e9a3585fc..57471fb61a12 100644
@@ -6,3 +6,4 @@
 obj-$(CONFIG_XILLYBUS)		+= xillybus_core.o
 obj-$(CONFIG_XILLYBUS_PCIE)	+= xillybus_pcie.o
 obj-$(CONFIG_XILLYBUS_OF)	+= xillybus_of.o
+obj-$(CONFIG_XILLYUSB)		+= xillyusb.o
drivers/char/xillybus/xillyusb.c new file +2363 -0

2,363 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 8 lines · On Mon, Feb 01, 2021 at 04:16:51PM +0200, [email protected] wrote:

From: Eli Billauer <[email protected]>

The XillyUSB driver is the USB variant for the Xillybus FPGA IP core. Even though it presents a nearly identical API on the FPGA and host, it's almost a complete rewrite of the driver: The framework for exchanging data on a USB bus is fundamentally different from doing the same with a PCIe interface, which leaves very little in common between the existing driver and the new one for XillyUSB.

As this has nothing to do with the existing XillyBus code, and you aren't doing anything "fancy" with the character device nodes, why does this need to be a kernel driver at all? Why can't you just use libusb and talk to the device directly from userspace with no kernel driver needed?

And always cc: [email protected] when submitting a USB driver so that the developers there can review it.

thanks,

greg k-h

author maintainer
#2 lore raw

Hello, Greg.

Quoted 6 lines · Greg KH

As this has nothing to do with the existing XillyBus code, and you aren't doing anything "fancy" with the character device nodes, why does this need to be a kernel driver at all? Why can't you just use libusb and talk to the device directly from userspace with no kernel driver needed?

That's actually what I did in my first attempt.

However in order to provide the same API as the existing Xillybus driver, this driver must present some kind of device files.

Named pipes aren't sufficient, among others because closing a Xillybus device file is something that the hardware is informed about immediately. Also, when a device file is opened for write, the close() call should not return until all data has arrived to hardware (per existing API). This can't be guaranteed with named pipes.

So a user-space driver needs to rely on CUSE. Which I wasted two months on before realizing it's not stable enough to rely upon. My whines on CUSE can be found in my blog:

http://billauer.co.il/blog/2020/02/linux-cuse-fuse-libfuse-crash/

Quoted 3 lines

And always cc:[email protected] when submitting a USB driver so that the developers there can review it.

Sorry, I wasn't aware of that. Will resend this patch with this list cc'ed shortly.

Thanks,
Eli

maintainer
#3 lore raw
Quoted 8 lines · Eli Billauer

Hello, Greg.

Quoted 5 lines · Greg KH

As this has nothing to do with the existing XillyBus code, and you aren't doing anything "fancy" with the character device nodes, why does this need to be a kernel driver at all? Why can't you just use libusb and talk to the device directly from userspace with no kernel driver needed?

Quoted 4 lines

That's actually what I did in my first attempt.

However in order to provide the same API as the existing Xillybus driver, this driver must present some kind of device files.

But you are not providing the same API! Or so you are saying in the driver.

If you were, then you need to use the same device nodes that the existing xillybus code uses and share them. Which is what I asked about before.

Quoted 5 lines

Named pipes aren't sufficient, among others because closing a Xillybus device file is something that the hardware is informed about immediately. Also, when a device file is opened for write, the close() call should not return until all data has arrived to hardware (per existing API). This can't be guaranteed with named pipes.

What does a named pipe have to do with anything here?

Quoted 3 lines

So a user-space driver needs to rely on CUSE. Which I wasted two months on before realizing it's not stable enough to rely upon. My whines on CUSE can be found in my blog:

Why is cuse an issue here?

Just use libusb and have your userspace programs link against it.

thanks,

greg k-h