Repository navigation
ni: lci: Add LCI (Virtual Bench) support to kernel v4.14 - #303
Merged
Merged
Conversation
Add device trees for the NI VB-8012, VB-8034, and VB-8054 and the Digilent ADP5250, ADP5470, and ADP5490. ni-lci.dtsi describes the board they share: gem0 with the Marvell 88E1512 PHY, the uart0 console, usb0 in peripheral mode with its ULPI pinmux for the g_lci gadget, the PL fabric clocks FCLK0-3 for the FPGA design, and the raw-NAND fsbl/u-boot/boot-config/root partitions. The VB-8034, VB-8054, ADP5470, and ADP5490 enable Ethernet. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Set the MTD device's DT node in the pl353 NAND probe so ofpart registers the partitions declared under the nand node. VirtualBench devices use them for ubi.mtd=boot-config/root and root=/dev/mtdblockN. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Add the National Instruments LCI (VirtualBench) USB gadget. f_hidbulk is a HID/bulk-switchable function registered as 'hid_bulk': alt0 is a HID interrupt interface, and the first instance's alt1 exposes 8 bulk endpoints for high throughput. g_lci composes 4 hid_bulk interfaces plus an optional mass-storage CD-ROM, configured by the g_lci.* module parameters. The composite source is lci.c so the g_lci module name does not collide with its only object. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Contributor
|
@jhershbe Was targeting 4.14 branch intentional? NILRT ARM is moving to 6.18 btw. |
chaitu236
reviewed
Oct 12, 2026
chaitu236
left a comment
Contributor
There was a problem hiding this comment.
If there is a WI, can you link to PR description. And testing section
Contributor
Author
Yes, this is an intermediate step toward adding 6.18 support. |
Skip the NILRT target-runnable fixdep/modpost/genksyms/recordmcount when NILRT_NO_ONTARGET_TOOLS is set. They need a target libc and a target elfconfig.h, which a cross-only OE build does not provide, and VirtualBench devices do not build modules on-target. NILRT builds keep them by default for the module-versioning-headers package. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Set OTGSC.OT (OTG Termination) from the Zynq controller reset notifier, as the Zynq-7000 TRM requires when the controller operates as a device. The OTGSC interrupt status bits are write-1-to-clear, so write them as zero. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Add a UIO driver for the LCI FPGA on NI VirtualBench devices. It exposes the FPGA registers and DMA memory as maps 0 and 1, and the FPGA interrupt, which the handler masks and irqcontrol unmasks. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Add the LCI FPGA node for uio_lci: FPGA registers at 0x40000000, the DMA buffer region at 0x0d600000, and PL interrupt 29, level high. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Set reset-on-timeout on the SWDT so the board resets when the LCI daemon stops petting /dev/watchdog. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
jhershbe
force-pushed
the
virtualbench/26.5/4.14
branch
from
October 13, 2026 15:19
433d298 to
f14b1e5
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The new USB and UIO drivers contain exploitable bounds, user-copy, cleanup, and IRQ synchronization defects.
10 open findings
Do not copy to userspace while holding the IRQ-disabled spinlock · New Reject endpoint index equal to the array length · New Handle partial copy_from_user failures to prevent kernel data leaks · New Bound SET_REPORT length before queuing the EP0 request · New Track initialized resources during bind failure cleanup · New Serialize IRQ disable-depth updates with the device lock · New Propagate required IRQ lookup failures · New Prevent packet copies from exceeding the requested read length · New Propagate request allocation failures and unwind allocated requests · New Free the OUT request and buffer during gadget cleanup · New
What changed in this PR
Adds NI LCI/VirtualBench platform support to the ARM Zynq kernel.
Changes:
- Adds device trees, FPGA UIO access, and NAND/USB controller integration.
- Introduces the LCI composite USB gadget with HID/bulk and optional mass storage.
- Adds controls for omitting target-side build tools.
| File | Description |
|---|---|
| scripts/mod/Makefile | Honors the target-tools opt-out. |
| scripts/Makefile | Conditionally builds target scripts. |
| scripts/genksyms/Makefile | Conditionally builds target genksyms. |
| scripts/basic/Makefile | Conditionally builds target fixdep. |
| drivers/usb/gadget/legacy/Makefile | Builds the LCI gadget. |
| drivers/usb/gadget/legacy/lci.c | Defines the composite LCI gadget. |
| drivers/usb/gadget/legacy/Kconfig | Adds LCI gadget configuration. |
| drivers/usb/gadget/Kconfig | Adds the HID/bulk function symbol. |
| drivers/usb/gadget/function/u_hidbulk.h | Defines HID/bulk options. |
| drivers/usb/gadget/function/Makefile | Builds the HID/bulk function. |
| drivers/usb/gadget/function/f_hidbulk.c | Implements HID/bulk endpoints and devices. |
| drivers/usb/chipidea/ci_hdrc_usb2.c | Adds Zynq reset handling. |
| drivers/usb/chipidea/bits.h | Defines the OTG termination bit. |
| drivers/uio/uio_lci.c | Exposes LCI FPGA resources through UIO. |
| drivers/uio/Makefile | Builds the LCI UIO driver. |
| drivers/uio/Kconfig | Adds LCI UIO configuration. |
| drivers/mtd/nand/pl353_nand.c | Enables DT NAND partition discovery. |
| arch/arm/boot/dts/ni-lci.dtsi | Defines shared LCI hardware. |
| arch/arm/boot/dts/ni-76F6.dts | Adds NI VB-8012. |
| arch/arm/boot/dts/ni-77DE.dts | Adds NI VB-8034. |
| arch/arm/boot/dts/ni-78B4.dts | Adds NI VB-8054. |
| arch/arm/boot/dts/ni-7AB9.dts | Adds Digilent ADP5250. |
| arch/arm/boot/dts/ni-7ABA.dts | Adds Digilent ADP5470. |
| arch/arm/boot/dts/ni-7ABB.dts | Adds Digilent ADP5490. |
| arch/arm/boot/dts/Makefile | Registers the new DTBs. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| goto out; | ||
| } | ||
|
|
||
| copy_to_user(buffer + actual, req->buf, req->actual); |
Comment on lines
+563
to
+565
| if (index > BULK_ENDPOINTS) { | ||
| return -EINVAL; | ||
| } |
| if (!req->buf) | ||
| goto out; | ||
|
|
||
| copy_from_user(req->buf, buffer, count); |
Comment on lines
+745
to
+750
| case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8 | ||
| | HID_REQ_SET_REPORT): | ||
| VDBG(cdev, "set_report | wLenght=%d\n", ctrl->wLength); | ||
| req->context = hidg; | ||
| req->complete = hidg_set_report_complete; | ||
| goto respond; |
Comment on lines
+1262
to
+1266
| for(i=0; i<BULK_ENDPOINTS; i++) | ||
| { | ||
| device_destroy(hidg_bulk_class, MKDEV(bulk_major, i)); | ||
|
|
||
| usb_ep_disable(hidg->bulk_eps[i]); |
Comment on lines
+26
to
+27
| if (!test_and_set_bit(IRQ_DISABLED_FLAG, &priv->flags)) | ||
| disable_irq_nosync(irq); |
Comment on lines
+79
to
+82
| irq = platform_get_irq(pdev, 0); | ||
| if (irq == -EPROBE_DEFER) | ||
| return irq; | ||
| priv->info.irq = irq < 0 ? UIO_IRQ_NONE : irq; |
| while (actual <= 0) { | ||
| /* dump completed requests into the read buffer */ | ||
| list_for_each_entry_safe(req, safe_req, req_list, list) { | ||
| if (count < req->actual) |
| NULL, "hidg_bulk%d", i); | ||
| } | ||
|
|
||
| hidg_bulk_alloc_reqs(hidg); |
Comment on lines
+1295
to
+1298
| /* disable/free request and end point */ | ||
| usb_ep_disable(hidg->in_ep); | ||
| kfree(hidg->req->buf); | ||
| usb_ep_free_request(hidg->in_ep, hidg->req); |
chaitu236
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Tested on VB-8034 via NILE
Build-tested (via xilinx-zynq, sumo): linux-nilrt and linux-nilrt-debug