Skip to content

Commit 3fd31b1

Browse files
committed
modules: nrf_wifi: Fix bustest QSPI crash
Commit 5e25283("drivers: wifi: Create dedicated mem pool for Wi-Fi driver") introduced OSAL dependecy in the Zephyr QSPI driver for HL read, but in bustest we don't enable nrf_wifi OS module, so, it crashes here. And we should not be using OSAL APIs in Zephyr code anyway. And in this case we don't even need to use the heap, so, move the rx buffer to stack. Signed-off-by: Chaitanya Tata <[email protected]>
1 parent 366d45f commit 3fd31b1

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

include/zephyr/drivers/wifi/nrf_wifi/bus/rpu_hw_if.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ enum {
3131
NUM_MEM_BLOCKS
3232
};
3333

34+
/* Keeping it higher to avoid changing it ofter, but modify this value
35+
* if rpu_7002_memmap is changed.
36+
*/
37+
#define NRF_WIFI_QSPI_SLAVE_MAX_LATENCY 4
38+
3439
extern char blk_name[][15];
3540
extern uint32_t rpu_7002_memmap[][3];
3641

modules/nrf_wifi/bus/qspi_if.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#include <hal/nrf_clock.h>
2424
#include <hal/nrf_gpio.h>
2525

26+
#include <zephyr/drivers/wifi/nrf_wifi/bus/rpu_hw_if.h>
2627
#include "spi_nor.h"
27-
#include "osal_api.h"
2828

2929
/* The QSPI bus node which the NRF70 is on */
3030
#define QSPI_IF_BUS_NODE DT_NODELABEL(qspi)
@@ -1290,15 +1290,14 @@ int qspi_read(unsigned int addr, void *data, int len)
12901290
int qspi_hl_readw(unsigned int addr, void *data)
12911291
{
12921292
int status;
1293-
uint8_t *rxb = NULL;
12941293
uint32_t len = 4;
1294+
uint8_t rxb[4 + (NRF_WIFI_QSPI_SLAVE_MAX_LATENCY * 4)];
12951295

1296-
len = len + (4 * qspi_cfg->qspi_slave_latency);
1296+
len += (4 * qspi_cfg->qspi_slave_latency);
12971297

1298-
rxb = nrf_wifi_osal_mem_alloc(len);
1299-
1300-
if (rxb == NULL) {
1301-
LOG_ERR("%s: ERROR ENOMEM line %d", __func__, __LINE__);
1298+
if (len > sizeof(rxb)) {
1299+
LOG_ERR("%s: len exceeded, check NRF_WIFI_QSPI_SLAVE_MAX_LATENCY (len=%u, rxb=%zu)",
1300+
__func__, (unsigned int)len, sizeof(rxb));
13021301
return -ENOMEM;
13031302
}
13041303

@@ -1314,8 +1313,6 @@ int qspi_hl_readw(unsigned int addr, void *data)
13141313

13151314
*(uint32_t *)data = *(uint32_t *)(rxb + (len - 4));
13161315

1317-
nrf_wifi_osal_mem_free(rxb);
1318-
13191316
return status;
13201317
}
13211318

0 commit comments

Comments
 (0)