From f4ea0651ac77d2fcb8cbd79d908438d63906b721 Mon Sep 17 00:00:00 2001 From: Jonathan Rico Date: Mon, 21 Mar 2022 10:49:02 +0100 Subject: [PATCH] Bluetooth: hci: rpmsg: do not drop hci buffers This fixes an issue where we would drop the hci event if allocation from the hci event buffer pool didn't immediately succeed. The behavior is now to block on allocation, and warn the user every 10 seconds. Signed-off-by: Jonathan Rico --- drivers/bluetooth/hci/rpmsg.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/bluetooth/hci/rpmsg.c b/drivers/bluetooth/hci/rpmsg.c index 7f6710f4288..3cec7880cc0 100644 --- a/drivers/bluetooth/hci/rpmsg.c +++ b/drivers/bluetooth/hci/rpmsg.c @@ -78,15 +78,16 @@ static struct net_buf *bt_rpmsg_evt_recv(const uint8_t *data, size_t remaining) } BT_DBG("len %u", hdr.len); - buf = bt_buf_get_evt(hdr.evt, discardable, K_NO_WAIT); - if (!buf) { - if (discardable) { - BT_DBG("Discardable buffer pool full, ignoring event"); - } else { - BT_ERR("No available event buffers!"); + do { + buf = bt_buf_get_evt(hdr.evt, discardable, discardable ? K_NO_WAIT : K_SECONDS(10)); + if (!buf) { + if (discardable) { + BT_DBG("Discardable buffer pool full, ignoring event"); + return buf; + } + BT_WARN("Couldn't allocate a buffer after waiting 10 seconds."); } - return buf; - } + } while (!buf); net_buf_add_mem(buf, &hdr, sizeof(hdr));