summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiago De Franco <hiago.franco@toradex.com>2023-12-19 13:32:17 -0300
committerJoao Paulo Goncalves <joao.goncalves@toradex.com>2023-12-21 14:29:02 -0300
commit856736e6c4c8844d5a89a02a9a8fb3794a13587e (patch)
treede07a4c3440e7a29e4ab52d4fe6e68158b1bce6c
parent5c3c271ced6f17ac96b471a57bebcf9d63b5cac2 (diff)
linux-toradex-mainline: Add patch for f_ncm.c
This patch addresses an issue related to NCM and the transmission of small packets, as when using VNC, for example. The ongoing discussion about this problem can be checked on the Linux kernel mailing list at [1]. Until the matter is resolved in the mainline, we should keep this patch here as it has demonstrated it solves the issue for now. Future updates can be made once the mainline fix is implemented. [1] https://lore.kernel.org/all/20231204183751.64202-1-hiagofranco@gmail.com/ Related-to: TEI-1078 Signed-off-by: Hiago De Franco <hiago.franco@toradex.com> Signed-off-by: Joao Paulo Goncalves <joao.goncalves@toradex.com>
-rw-r--r--recipes-kernel/linux/linux-toradex-mainline-git/0001-usb-gadget-f_ncm-Apply-workaround-for-packet-cloggin.patch68
-rw-r--r--recipes-kernel/linux/linux-toradex-mainline_git.bb1
2 files changed, 69 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-toradex-mainline-git/0001-usb-gadget-f_ncm-Apply-workaround-for-packet-cloggin.patch b/recipes-kernel/linux/linux-toradex-mainline-git/0001-usb-gadget-f_ncm-Apply-workaround-for-packet-cloggin.patch
new file mode 100644
index 0000000..dfdd723
--- /dev/null
+++ b/recipes-kernel/linux/linux-toradex-mainline-git/0001-usb-gadget-f_ncm-Apply-workaround-for-packet-cloggin.patch
@@ -0,0 +1,68 @@
+From 2147c8ddfaa746cdb8857db070f907fa9abfcb60 Mon Sep 17 00:00:00 2001
+From: Hiago De Franco <hiago.franco@toradex.com>
+Date: Tue, 19 Dec 2023 11:52:07 -0300
+Subject: [PATCH] usb: gadget: f_ncm: Apply workaround for packet clogging
+
+The existing size of 32 is causing significant slowness and freezing when
+utilizing the NCM protocol with a VNC client. This issue likely arises
+because the VNC protocol relies on sending numerous small packets, which
+accumulate until the 16KB limit is reached, leading to transmission
+delays.
+
+By decreasing TX_MAX_NUM_DPE to 4, we ensure that the NCM driver transmits
+packets at a reduced interval, thereby resolving the VNC performance
+issues. To comprehend how these packets are sent, refer to the code
+snippet below from f_ncm.c:
+
+```
+ /* If the new skb is too big for the current NCM NTB then
+ * set the current stored skb to be sent now and clear it
+ * ready for new data.
+ * NOTE: Assume maximum align for speed of calculation.
+ */
+ if (ncm->skb_tx_data
+ && (ncm->ndp_dgram_count >= TX_MAX_NUM_DPE
+ || (ncm->skb_tx_data->len +
+ div + rem + skb->len +
+ ncm->skb_tx_ndp->len + ndp_align + (2 * dgram_idx_len))
+ > max_size)) {
+ skb2 = package_for_tx(ncm);
+ if (!skb2)
+ goto err;
+ }
+```
+
+This issue is presently under investigation on the Linux kernel mailing
+list, and you can find the entire discussion at [1].
+
+[1] https://lore.kernel.org/all/20231204183751.64202-1-hiagofranco@gmail.com/
+
+Upstream-Status: Inappropriate [other]
+
+There is no proper patch for now, so instead we're using this patch that
+makes VNC work again as a temporarily solution until the mainline code
+gets fixed.
+
+Related-to: TEI-1078
+Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
+Signed-off-by: Joao Paulo Goncalves <joao.goncalves@toradex.com>
+---
+ drivers/usb/gadget/function/f_ncm.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
+index e0c183234283..5e972d1c1a0c 100644
+--- a/drivers/usb/gadget/function/f_ncm.c
++++ b/drivers/usb/gadget/function/f_ncm.c
+@@ -113,7 +113,7 @@ static inline unsigned ncm_bitrate(struct usb_gadget *g)
+ * Smaller packets are not likely to be trying to maximize the
+ * throughput and will be mstly sending smaller infrequent frames.
+ */
+-#define TX_MAX_NUM_DPE 32
++#define TX_MAX_NUM_DPE 4
+
+ /* Delay for the transmit to wait before sending an unfilled NTB frame. */
+ #define TX_TIMEOUT_NSECS 300000
+--
+2.34.1
+
diff --git a/recipes-kernel/linux/linux-toradex-mainline_git.bb b/recipes-kernel/linux/linux-toradex-mainline_git.bb
index 0e7c032..ffe78b3 100644
--- a/recipes-kernel/linux/linux-toradex-mainline_git.bb
+++ b/recipes-kernel/linux/linux-toradex-mainline_git.bb
@@ -52,6 +52,7 @@ SRC_URI:append = " \
file://0003-arm64-dts-freescale-verdin-imx8mp-add-support-to-mal.patch \
file://0003-arm64-dts-freescale-verdin-imx8mm-add-support-to-mal.patch \
file://0001-wifi-mwifiex-configure-BSSID-consistently-when-start.patch \
+ file://0001-usb-gadget-f_ncm-Apply-workaround-for-packet-cloggin.patch \
"
LINUX_VERSION ?= "6.1.65"