From b3a84b1d4ee8fa2ecd9f4e879956194b0f4aa9a4 Mon Sep 17 00:00:00 2001 From: Francisco Gil Date: Fri, 10 Oct 2025 13:41:54 +0200 Subject: [PATCH] linux-dey:RT: fix virtio_trans build on Cortex-A9 and enable mailbox support This patch fixes build failures of the virtio_trans driver (Cortex-A9, 32-bit ARM) when building a PREEMPT_RT-enabled kernel. The errors were caused by unresolved 64-bit division symbols (__aeabi_uldivmod / __aeabi_ldivmod) generated when the driver was compiled as a module. Changes included: * virtio_trans.c: - Replace 64-bit modulus operations (`idx % vt->{tx,rx}_vring_size`) with kernel-safe 64-bit division macros using `div_u64_rem()`. This prevents implicit calls to non-exported ARM EABI helpers that are not available to kernel modules on 32-bit ARM. * fragment-nxp-rt.config: - Enable the mailbox framework (`CONFIG_MAILBOX=y`) required by virtio mailbox-based transports. - Build the virtio transport driver into the kernel (`CONFIG_VIRTIO_TRANS=y`) instead of as a module, ensuring proper symbol resolution during link time. Without this a license error is shown when building the kernel in yocto. https://onedigi.atlassian.net/browse/DEL-9783 Signed-off-by: Francisco Gil --- ...-RT-support-based-on-latest-linux_6.6.36.patch | 15 +++++++++++---- .../linux-dey/imx-nxp-bsp/fragment-nxp-rt.config | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey/imx-nxp-bsp/0001-add-RT-support-based-on-latest-linux_6.6.36.patch b/meta-digi-arm/recipes-kernel/linux/linux-dey/imx-nxp-bsp/0001-add-RT-support-based-on-latest-linux_6.6.36.patch index 3c3588f19..31cb5086e 100644 --- a/meta-digi-arm/recipes-kernel/linux/linux-dey/imx-nxp-bsp/0001-add-RT-support-based-on-latest-linux_6.6.36.patch +++ b/meta-digi-arm/recipes-kernel/linux/linux-dey/imx-nxp-bsp/0001-add-RT-support-based-on-latest-linux_6.6.36.patch @@ -43642,6 +43642,7 @@ index 000000000000..13c003e2ba45 +#include +#include +#include ++#include +#include +#include +#include @@ -43815,8 +43816,11 @@ index 000000000000..13c003e2ba45 + } + + spin_lock(&vt->txvq_lock); -+ virttrans_queue_txbuf(vt, &vt->tx_sgl[idx % vt->tx_vring_size], -+ buf, vt->pkt_size); ++ u64 tmp_idx = idx; ++ u32 tmp_rem; ++ div_u64_rem(tmp_idx, vt->tx_vring_size, &tmp_rem); ++ virttrans_queue_txbuf(vt, &vt->tx_sgl[tmp_rem], ++ buf, vt->pkt_size); + idx++; + spin_unlock(&vt->txvq_lock); + @@ -43952,8 +43956,11 @@ index 000000000000..13c003e2ba45 + } + + spin_lock(&vt->rxvq_lock); -+ virttrans_queue_rxbuf(vt, &vt->rx_sgl[idx % vt->rx_vring_size], -+ buf, vt->pkt_size); ++ u64 tmp_idx = idx; ++ u32 tmp_rem; ++ div_u64_rem(tmp_idx, vt->rx_vring_size, &tmp_rem); ++ virttrans_queue_rxbuf(vt, &vt->rx_sgl[tmp_rem], ++ buf, vt->pkt_size); + idx++; + spin_unlock(&vt->rxvq_lock); + diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey/imx-nxp-bsp/fragment-nxp-rt.config b/meta-digi-arm/recipes-kernel/linux/linux-dey/imx-nxp-bsp/fragment-nxp-rt.config index 53f9881e7..0b608beaa 100644 --- a/meta-digi-arm/recipes-kernel/linux/linux-dey/imx-nxp-bsp/fragment-nxp-rt.config +++ b/meta-digi-arm/recipes-kernel/linux/linux-dey/imx-nxp-bsp/fragment-nxp-rt.config @@ -12,6 +12,7 @@ CONFIG_NET_EMATCH_STACK=32 CONFIG_NET_EMATCH_U32=y CONFIG_NET_EMATCH_META=y CONFIG_NET_PKTGEN=y +CONFIG_MAILBOX=y CONFIG_VIRTIO_NET=m CONFIG_NET_DSA_NETC=m CONFIG_NET_DSA_NETC_PTP=y @@ -21,7 +22,7 @@ CONFIG_EXPERT=y CONFIG_PREEMPT_RT=y CONFIG_RPMSG_TTY=m CONFIG_GENERIC_SOFTWARE_MAILBOX=y -CONFIG_VIRTIO_TRANS=m +CONFIG_VIRTIO_TRANS=y CONFIG_ACPI_CONTAINER=y CONFIG_THERMAL=y CONFIG_CLK_QORIQ=y