<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/simtrace2/+/16575">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">usb_buf: Limit the maximum queue length to 3 elements<br><br>If there are already three elements in the to-be-transmitted queue<br>for the EP, let's free the first element of the queue.  This is a<br>clear indication that the USB host is not polling the endpoint<br>regularly.  Maybe there's no host application running at all?<br><br>This should obsolete Change-Id Ie9ebdd2ff966f67c9afd1ed760f106558f0091ad<br><br>Change-Id: Ie15183f16b22193ffdaf01845db2eae4c7f43c17<br>Closes: OS#4251<br>---<br>M firmware/libcommon/source/usb_buf.c<br>1 file changed, 12 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/firmware/libcommon/source/usb_buf.c b/firmware/libcommon/source/usb_buf.c</span><br><span>index 8ad5a0e..7892d6e 100644</span><br><span>--- a/firmware/libcommon/source/usb_buf.c</span><br><span>+++ b/firmware/libcommon/source/usb_buf.c</span><br><span>@@ -24,6 +24,7 @@</span><br><span> #include <errno.h></span><br><span> </span><br><span> #define USB_ALLOC_SIZE        280</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_MAX_QLEN       3</span><br><span> </span><br><span> static struct usb_buffered_ep usb_buffered_ep[BOARD_USB_NUMENDPOINTS];</span><br><span> </span><br><span>@@ -78,6 +79,17 @@</span><br><span> </span><br><span>         /* no need for irqsafe operation, as the usb_tx_queue is</span><br><span>      * processed only by the main loop context */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       if (ep->queue_len > USB_MAX_QLEN) {</span><br><span style="color: hsl(120, 100%, 40%);">+             struct msgb *evict;</span><br><span style="color: hsl(120, 100%, 40%);">+           /* free the first pending buffer in the queue */</span><br><span style="color: hsl(120, 100%, 40%);">+              TRACE_INFO("EP%02x: dropping first queue element (qlen=%u)\r\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                       ep->ep, ep->queue_len);</span><br><span style="color: hsl(120, 100%, 40%);">+              evict = msgb_dequeue_count(&ep->queue, &ep->queue_len);</span><br><span style="color: hsl(120, 100%, 40%);">+         OSMO_ASSERT(evict);</span><br><span style="color: hsl(120, 100%, 40%);">+           usb_buf_free(evict);</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  msgb_enqueue_count(&ep->queue, msg, &ep->queue_len);</span><br><span>   return 0;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/simtrace2/+/16575">change 16575</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/simtrace2/+/16575"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: simtrace2 </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ie15183f16b22193ffdaf01845db2eae4c7f43c17 </div>
<div style="display:none"> Gerrit-Change-Number: 16575 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>