diff options
author | Yadukishore Kodicherla <yadukishore.kodicherla@broadcom.corp-partner.google.com> | 2023-06-12 11:34:52 +0530 |
---|---|---|
committer | Ken Sun <kensun@google.com> | 2023-06-13 14:39:56 +0000 |
commit | cd6345e418351b2e9bf5d28caeaded1c081149af (patch) | |
tree | a3b55d76e4572fc8f45e6acd689025be0043800a | |
parent | 0fefbb70317ee5df7ba5c03a9be92191f7b870ee (diff) | |
download | bcm4398-cd6345e418351b2e9bf5d28caeaded1c081149af.tar.gz |
DHD: Abort Wifi ON if EDL DMA buffer allocation fails
EDL(Extended Debug Lane) feature is a debug feature to get Dongle logs.
If it is not enabled due to host DMA buffer allocation fails, it will
cause random misbheavior in the firmware.
Hence Abort wifi on if EDL allocation has failed and debug further on
why it has failed.
Bug: 284591361
Test: Pass regression test.
Change-Id: I4ba317959ff8475b977e2e77360bfcb58044b288
Signed-off-by: Yadukishore Kodicherla <yadukishore.kodicherla@broadcom.corp-partner.google.com>
-rw-r--r-- | dhd.h | 1 | ||||
-rw-r--r-- | dhd_common.c | 12 | ||||
-rw-r--r-- | dhd_linux.c | 16 | ||||
-rw-r--r-- | dhd_pcie.c | 34 |
4 files changed, 37 insertions, 26 deletions
@@ -1848,6 +1848,7 @@ typedef struct dhd_pub { #ifdef EWP_EDL bool dongle_edl_support; dhd_dma_buf_t edl_ring_mem; + bool host_edl_mem_inited; #endif /* EWP_EDL */ #if defined(__linux__) struct mutex ndev_op_sync; diff --git a/dhd_common.c b/dhd_common.c index 2159183..f30d077 100644 --- a/dhd_common.c +++ b/dhd_common.c @@ -11297,10 +11297,13 @@ dhd_edl_mem_init(dhd_pub_t *dhd) bzero(&dhd->edl_ring_mem, sizeof(dhd->edl_ring_mem)); ret = dhd_dma_buf_alloc(dhd, &dhd->edl_ring_mem, DHD_EDL_RING_SIZE); if (ret != BCME_OK) { - DHD_ERROR(("%s: alloc of edl_ring_mem failed\n", - __FUNCTION__)); + DHD_ERROR(("%s: alloc of edl_ring_mem size(%u) failed \n", + __FUNCTION__, DHD_EDL_RING_SIZE)); + dhd->host_edl_mem_inited = FALSE; return BCME_ERROR; } + DHD_PRINT(("%s: EDL buffer allocated of size %u\n", __FUNCTION__, DHD_EDL_RING_SIZE)); + dhd->host_edl_mem_inited = TRUE; return BCME_OK; } @@ -11311,8 +11314,11 @@ dhd_edl_mem_init(dhd_pub_t *dhd) void dhd_edl_mem_deinit(dhd_pub_t *dhd) { - if (dhd->edl_ring_mem.va != NULL) + if (dhd->host_edl_mem_inited && dhd->edl_ring_mem.va) { dhd_dma_buf_free(dhd, &dhd->edl_ring_mem); + dhd->host_edl_mem_inited = FALSE; + DHD_PRINT(("%s: EDL buffer freed\n", __FUNCTION__)); + } } int diff --git a/dhd_linux.c b/dhd_linux.c index 72958a6..d22ead9 100644 --- a/dhd_linux.c +++ b/dhd_linux.c @@ -530,11 +530,6 @@ struct semaphore dhd_registration_sem; void dhd_generate_rand_mac_addr(struct ether_addr *ea_addr); -#ifdef EWP_EDL -int host_edl_support = TRUE; -module_param(host_edl_support, int, 0644); -#endif - /* deferred handlers */ static void dhd_ifadd_event_handler(void *handle, void *event_info, u8 event); static void dhd_ifdel_event_handler(void *handle, void *event_info, u8 event); @@ -9726,10 +9721,8 @@ dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen) #endif /* DHD_SDTC_ETB_DUMP */ #ifdef EWP_EDL - if (host_edl_support) { - if (DHD_EDL_MEM_INIT(&dhd->pub) != BCME_OK) { - host_edl_support = FALSE; - } + if (DHD_EDL_MEM_INIT(&dhd->pub) != BCME_OK) { + DHD_ERROR(("%s: EDL memory allocation failed\n", __FUNCTION__)); } #endif /* EWP_EDL */ @@ -15119,10 +15112,7 @@ void dhd_detach(dhd_pub_t *dhdp) #endif #ifdef EWP_EDL - if (host_edl_support) { - DHD_EDL_MEM_DEINIT(dhdp); - host_edl_support = FALSE; - } + DHD_EDL_MEM_DEINIT(dhdp); #endif /* EWP_EDL */ #if defined(WLTDLS) && defined(PCIE_FULL_DONGLE) @@ -189,10 +189,6 @@ int cc_wd_reset = FALSE; extern unsigned int system_rev; #endif /* SUPPORT_MULTIPLE_BOARD_REV */ -#ifdef EWP_EDL -extern int host_edl_support; -#endif - #ifdef BCMQT_HW extern int qt_dngl_timeout; #endif /* BCMQT_HW */ @@ -8889,7 +8885,19 @@ dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag) if (bcmerror) { DHD_ERROR(("%s: dhd_bus_start: %d\n", __FUNCTION__, bcmerror)); - bcmerror = BCME_NOTUP; + /* NORESOURCE means oob irq init failed + * NOMEM means host memory alloc failed + * in these cases retain the error code + * so that caller can take decision based + * on it to not collect debug_dump + * Because in such a case prot_init etc would + * not have happened and iovars/ioctls to FW + * should be avoided. + */ + if ((bcmerror != BCME_NORESOURCE) && + (bcmerror != BCME_NOMEM)) { + bcmerror = BCME_NOTUP; + } goto done; } @@ -16460,9 +16468,16 @@ dhdpcie_readshared(dhd_bus_t *bus) (sh->flags2 & PCIE_SHARED2_HSCB) == PCIE_SHARED2_HSCB; #ifdef EWP_EDL - if (host_edl_support) { - bus->dhd->dongle_edl_support = (sh->flags2 & PCIE_SHARED2_EDL_RING) ? TRUE : FALSE; - DHD_PRINT(("Dongle EDL support: %u\n", bus->dhd->dongle_edl_support)); + bus->dhd->dongle_edl_support = (sh->flags2 & PCIE_SHARED2_EDL_RING) ? TRUE : FALSE; + DHD_PRINT(("host_edl_mem_inited:%u Dongle EDL support: %u\n", bus->dhd->host_edl_mem_inited, + bus->dhd->dongle_edl_support)); + if (bus->dhd->dongle_edl_support && !bus->dhd->host_edl_mem_inited) { + DHD_ERROR(("Dongle supports EDL but host allocation failed during module init\n")); + DHD_PRINT(("Retry Allocating EDL buffer\n")); + if (DHD_EDL_MEM_INIT(bus->dhd) != BCME_OK) { + DHD_ERROR(("EDL Alloc failed. Abort!!\n")); + return BCME_NOMEM; + } } #endif /* EWP_EDL */ @@ -17316,8 +17331,7 @@ int dhd_bus_init(dhd_pub_t *dhdp, bool enforce_mutex) * reason, collect ewp init dumps */ if (ret == BCME_OK || ret == BCME_BADADDR || - ret == BCME_NOMEM || ret == BCME_DATA_NOTFOUND || - ret == BCME_UNSUPPORTED) { + ret == BCME_DATA_NOTFOUND || ret == BCME_UNSUPPORTED) { if (bus->api.fw_rev >= PCIE_SHARED_VERSION_9) { /* ewp hw new init sequence and ewp hw log collection * is supported only above ipc rev 9 |