lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT


From: Giuseppe Modugno
Subject: [lwip-users] LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
Date: Tue, 4 Oct 2022 16:46:00 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1

I started from an example of NXP SDK for LPC546xx MCUs. I'm using baremetal (NO_SYS=1) and I found the following warning in enet_ethernetif_lpc.c, function ethernetif_tx_release():

---
#if NO_SYS
#if defined(LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT) && LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
        pbuf_free(p);
#else
#error "Bare metal requires LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT=1 because pbuf_free() is being called from an ISR"
#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */
...
---

It seems NXP code calls pbuf_free() inside ISR and this behaviour must be known to lwip by setting 1 to this macro. However it seems this macro is checked only in mem.c, if MEM_USE_POOLS is defined.

In my application I don't define MEM_USE_POOLS, so it is set to 0 by default in opt.h.

Does it mean I can avoid setting LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEX? I would like to set it to 0, because of the following warning found in opt.h:

---
 * ATTENTION: As you can see from the above description, this leads to dis-/  * enabling interrupts often, which can be slow! Also, on low memory, mem_malloc
 * can need longer.
---

However NXP code uses #error if this macro is not set, so I suspect there's a real risk to avoid setting it.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]