Skip to content

Commit e13e893

Browse files
HaavardReikartben
authored andcommitted
net: buf: revert disallowing blocking in syswq
Reverts the change made in d4d5301 (The changes was moved to another file in a restructuring) The commit incorrectly assumed that no blocking would be allowed in the syswq. This has caused issues observed among others in #77241 and #80167 Signed-off-by: Håvard Reierstad <[email protected]>
1 parent b3c6151 commit e13e893

File tree

2 files changed

+12
-33
lines changed

2 files changed

+12
-33
lines changed

include/zephyr/net_buf.h

+12-27
Original file line numberDiff line numberDiff line change
@@ -1329,19 +1329,14 @@ int net_buf_id(const struct net_buf *buf);
13291329
/**
13301330
* @brief Allocate a new fixed buffer from a pool.
13311331
*
1332-
* @note Some types of data allocators do not support
1333-
* blocking (such as the HEAP type). In this case it's still possible
1334-
* for net_buf_alloc() to fail (return NULL) even if it was given
1335-
* K_FOREVER.
1336-
*
1337-
* @note The timeout value will be overridden to K_NO_WAIT if called from the
1338-
* system workqueue.
1339-
*
13401332
* @param pool Which pool to allocate the buffer from.
13411333
* @param timeout Affects the action taken should the pool be empty.
13421334
* If K_NO_WAIT, then return immediately. If K_FOREVER, then
13431335
* wait as long as necessary. Otherwise, wait until the specified
1344-
* timeout.
1336+
* timeout. Note that some types of data allocators do not support
1337+
* blocking (such as the HEAP type). In this case it's still possible
1338+
* for net_buf_alloc() to fail (return NULL) even if it was given
1339+
* K_FOREVER.
13451340
*
13461341
* @return New buffer or NULL if out of buffers.
13471342
*/
@@ -1369,20 +1364,15 @@ static inline struct net_buf * __must_check net_buf_alloc(struct net_buf_pool *p
13691364
/**
13701365
* @brief Allocate a new variable length buffer from a pool.
13711366
*
1372-
* @note Some types of data allocators do not support
1373-
* blocking (such as the HEAP type). In this case it's still possible
1374-
* for net_buf_alloc() to fail (return NULL) even if it was given
1375-
* K_FOREVER.
1376-
*
1377-
* @note The timeout value will be overridden to K_NO_WAIT if called from the
1378-
* system workqueue.
1379-
*
13801367
* @param pool Which pool to allocate the buffer from.
13811368
* @param size Amount of data the buffer must be able to fit.
13821369
* @param timeout Affects the action taken should the pool be empty.
13831370
* If K_NO_WAIT, then return immediately. If K_FOREVER, then
13841371
* wait as long as necessary. Otherwise, wait until the specified
1385-
* timeout.
1372+
* timeout. Note that some types of data allocators do not support
1373+
* blocking (such as the HEAP type). In this case it's still possible
1374+
* for net_buf_alloc() to fail (return NULL) even if it was given
1375+
* K_FOREVER.
13861376
*
13871377
* @return New buffer or NULL if out of buffers.
13881378
*/
@@ -1406,21 +1396,16 @@ struct net_buf * __must_check net_buf_alloc_len(struct net_buf_pool *pool,
14061396
* Allocate a new buffer from a pool, where the data pointer comes from the
14071397
* user and not from the pool.
14081398
*
1409-
* @note Some types of data allocators do not support
1410-
* blocking (such as the HEAP type). In this case it's still possible
1411-
* for net_buf_alloc() to fail (return NULL) even if it was given
1412-
* K_FOREVER.
1413-
*
1414-
* @note The timeout value will be overridden to K_NO_WAIT if called from the
1415-
* system workqueue.
1416-
*
14171399
* @param pool Which pool to allocate the buffer from.
14181400
* @param data External data pointer
14191401
* @param size Amount of data the pointed data buffer if able to fit.
14201402
* @param timeout Affects the action taken should the pool be empty.
14211403
* If K_NO_WAIT, then return immediately. If K_FOREVER, then
14221404
* wait as long as necessary. Otherwise, wait until the specified
1423-
* timeout.
1405+
* timeout. Note that some types of data allocators do not support
1406+
* blocking (such as the HEAP type). In this case it's still possible
1407+
* for net_buf_alloc() to fail (return NULL) even if it was given
1408+
* K_FOREVER.
14241409
*
14251410
* @return New buffer or NULL if out of buffers.
14261411
*/

lib/net_buf/buf.c

-6
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,6 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
271271

272272
k_spin_unlock(&pool->lock, key);
273273

274-
if (!K_TIMEOUT_EQ(timeout, K_NO_WAIT) &&
275-
k_current_get() == k_work_queue_thread_get(&k_sys_work_q)) {
276-
LOG_WRN("Timeout discarded. No blocking in syswq");
277-
timeout = K_NO_WAIT;
278-
}
279-
280274
#if defined(CONFIG_NET_BUF_LOG) && (CONFIG_NET_BUF_LOG_LEVEL >= LOG_LEVEL_WRN)
281275
if (K_TIMEOUT_EQ(timeout, K_FOREVER)) {
282276
uint32_t ref = k_uptime_get_32();

0 commit comments

Comments
 (0)