From 75be2d0a45e168a0ac61ca4a6129ee6f85a9b5d4 Mon Sep 17 00:00:00 2001 From: bings Date: Mon, 26 Jun 2017 13:58:08 +0800 Subject: [PATCH] qcacld-3.0: Fix crash caused by sdio ramdump allocation For TF sdio chip with platform driver, ramdump is configured in platform driver. Driver can get the virtual memory, but it can't call ioremap again. If there is a platform driver, ramdump should be allocated in platform driver, and if there is no platform driver, ramdump should be allocated in driver. CRs-Fixed: 2066529 Change-Id: Ia2a32a4895f354e365522a30bbfac949ccb7a391 --- core/bmi/src/i_bmi.h | 1 - core/pld/src/pld_sdio.h | 62 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/core/bmi/src/i_bmi.h b/core/bmi/src/i_bmi.h index 477e4d9baad9..cc132d0a9ce4 100644 --- a/core/bmi/src/i_bmi.h +++ b/core/bmi/src/i_bmi.h @@ -59,7 +59,6 @@ #define AXI_LOCATION 0x000a0000 #define AXI_SIZE 0x00018000 -#define TOTAL_DUMP_SIZE 0x00200000 #define PCIE_READ_LIMIT 0x00005000 #define SHA256_DIGEST_SIZE 32 diff --git a/core/pld/src/pld_sdio.h b/core/pld/src/pld_sdio.h index c50ecf822d46..881c175acb1a 100644 --- a/core/pld/src/pld_sdio.h +++ b/core/pld/src/pld_sdio.h @@ -28,6 +28,7 @@ #endif #define PLD_QCA9377_REV1_1_VERSION 0x5020001 +#define TOTAL_DUMP_SIZE 0x00200000 #ifndef CONFIG_CNSS #define PLD_AR6004_VERSION_REV1_3 0x31c8088a @@ -120,4 +121,65 @@ static inline void pld_sdio_device_crashed(struct device *dev) { } #endif + +#ifdef CONFIG_PLD_SDIO_CNSS +/** + * pld_hif_sdio_get_virt_ramdump_mem() - Get virtual ramdump memory + * @dev: device + * @size: buffer to virtual memory size + * + * Return: virtual ramdump memory address + */ +static inline void *pld_hif_sdio_get_virt_ramdump_mem(struct device *dev, + unsigned long *size) +{ + return cnss_common_get_virt_ramdump_mem(dev, size); +} + +/** + * pld_hif_sdio_release_ramdump_mem() - Release virtual ramdump memory + * @address: virtual ramdump memory address + * + * Return: void + */ +static inline void pld_hif_sdio_release_ramdump_mem(unsigned long *address) +{ +} +#else +/** + * pld_hif_sdio_get_virt_ramdump_mem() - Get virtual ramdump memory + * @dev: device + * @size: buffer to virtual memory size + * + * Return: virtual ramdump memory address + */ +static inline void *pld_hif_sdio_get_virt_ramdump_mem(struct device *dev, + unsigned long *size) +{ + size_t length = 0; + int flags = GFP_KERNEL; + + length = TOTAL_DUMP_SIZE; + + if (size != NULL) + *size = (unsigned long)length; + + if (in_interrupt() || irqs_disabled() || in_atomic()) + flags = GFP_ATOMIC; + + return kzalloc(length, flags); +} + +/** + * pld_hif_sdio_release_ramdump_mem() - Release virtual ramdump memory + * @address: virtual ramdump memory address + * + * Return: void + */ +static inline void pld_hif_sdio_release_ramdump_mem(unsigned long *address) +{ + if (address != NULL) + kfree(address); +} +#endif #endif