Skip to content

ni: lci: Add LCI (Virtual Bench) support to kernel v4.14 - #303

Merged
gratian merged 8 commits into
ni:nilrt/master/4.14from
jhershbe:virtualbench/26.5/4.14
Oct 13, 2026
Merged

gratian merged 8 commits into
ni:nilrt/master/4.14from
jhershbe:virtualbench/26.5/4.14

Conversation

@jhershbe

@jhershbe jhershbe commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor
  • Add device trees
  • Add UIO driver definition
  • Add hid_bulk implementation
  • A few other minor fixes

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

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>
@chaitu236

Copy link
Copy Markdown
Contributor

@jhershbe Was targeting 4.14 branch intentional? NILRT ARM is moving to 6.18 btw.

@chaitu236 chaitu236 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a WI, can you link to PR description. And testing section

Comment thread scripts/basic/Makefile Resolved
@jhershbe

Copy link
Copy Markdown
Contributor Author

@jhershbe Was targeting 4.14 branch intentional? NILRT ARM is moving to 6.18 btw.

Yes, this is an intermediate step toward adding 6.18 support.

@jhershbe jhershbe closed this Oct 12, 2026
@jhershbe jhershbe reopened this Oct 12, 2026
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
jhershbe force-pushed the virtualbench/26.5/4.14 branch from 433d298 to f14b1e5 Compare October 13, 2026 15:19
@gratian
gratian requested review from a team and a balanced review from Copilot October 13, 2026 19:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new USB and UIO drivers contain exploitable bounds, user-copy, cleanup, and IRQ synchronization defects.

10 open findings
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 thread drivers/uio/uio_lci.c
Comment on lines +26 to +27
if (!test_and_set_bit(IRQ_DISABLED_FLAG, &priv->flags))
disable_irq_nosync(irq);
Comment thread drivers/uio/uio_lci.c
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);
@gratian
gratian merged commit 94904f0 into ni:nilrt/master/4.14 Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants