Browse Source

qcacld-3.0: Avoid using small buffer address

On some third-party platforms, we observe the memory physical
address below 0x2000 is allocated will cause HW/FW NOC error,
so this region memory should not be used by host.

This change will hold the memory if the allocated memory physical
address below 0x2000 until driver unload.

Change-Id: I11fb698d32e69852f1cb5c8eb99ead121b8db2f4
CRs-Fixed: 3419652
Zhiwei Yang 2 years ago
parent
commit
09cb1c6ac2
5 changed files with 41 additions and 1 deletions
  1. 1 0
      Kbuild
  2. 4 0
      Kconfig
  3. 9 1
      core/hdd/inc/wlan_hdd_driver_ops.h
  4. 20 0
      core/hdd/src/wlan_hdd_driver_ops.c
  5. 7 0
      core/hdd/src/wlan_hdd_main.c

+ 1 - 0
Kbuild

@@ -3352,6 +3352,7 @@ ccflags-y += -DDBR_HOLD_LARGE_MEM
 endif
 endif
 
+ccflags-$(CONFIG_QCA_DMA_PADDR_CHECK) += -DQCA_DMA_PADDR_CHECK
 ccflags-$(CONFIG_DP_TRAFFIC_END_INDICATION) += -DDP_TRAFFIC_END_INDICATION
 ccflags-$(CONFIG_THERMAL_STATS_SUPPORT) += -DTHERMAL_STATS_SUPPORT
 ccflags-$(CONFIG_PTT_SOCK_SVC_ENABLE) += -DPTT_SOCK_SVC_ENABLE

+ 4 - 0
Kconfig

@@ -135,4 +135,8 @@ config WLAN_TX_FLOW_CONTROL_V2
 	bool "Enable tx flow control version:2"
 	default n
 
+config QCA_DMA_PADDR_CHECK
+	bool "Enable dma memory addr check"
+	default n
+
 endif # QCA_CLD_WLAN

+ 9 - 1
core/hdd/inc/wlan_hdd_driver_ops.h

@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2015-2017, 2019, 2021 The Linux Foundation.
  * All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -175,4 +175,12 @@ void hdd_hif_set_enable_detection(struct hif_opaque_softc *hif_ctx, bool value)
 {
 }
 #endif /* HIF_DETECTION_LATENCY_ENABLE */
+
+/**
+ * hdd_deinit_qdf_ctx() - API to Deinitialize global QDF Device structure
+ * @domain: Debug domain
+ *
+ * Return: 0 - success, < 0 - failure
+ */
+int hdd_deinit_qdf_ctx(uint8_t domain);
 #endif /* __WLAN_HDD_DRIVER_OPS_H__ */

+ 20 - 0
core/hdd/src/wlan_hdd_driver_ops.c

@@ -534,6 +534,8 @@ static int hdd_init_qdf_ctx(struct device *dev, void *bdev,
 	qdf_dev->bus_type = bus_type;
 	qdf_dev->bid = bid;
 
+	qdf_dma_invalid_buf_list_init();
+
 	if (cds_smmu_mem_map_setup(qdf_dev, ucfg_ipa_is_ready()) !=
 		QDF_STATUS_SUCCESS) {
 		hdd_err("cds_smmu_mem_map_setup() failed");
@@ -542,6 +544,24 @@ static int hdd_init_qdf_ctx(struct device *dev, void *bdev,
 	return 0;
 }
 
+/**
+ * hdd_deinit_qdf_ctx() - API to Deinitialize global QDF Device structure
+ * @domain: Debug domain
+ *
+ * Return: 0 - success, < 0 - failure
+ */
+int hdd_deinit_qdf_ctx(uint8_t domain)
+{
+	qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
+
+	if (!qdf_dev)
+		return -EINVAL;
+
+	qdf_dma_invalid_buf_free(qdf_dev->dev, domain);
+
+	return 0;
+}
+
 /**
  * check_for_probe_defer() - API to check return value
  * @ret: Return Value

+ 7 - 0
core/hdd/src/wlan_hdd_main.c

@@ -3984,6 +3984,8 @@ static int hdd_debug_domain_set(enum qdf_debug_domain domain)
 
 	return ret;
 }
+
+#define hdd_debug_domain_get() qdf_debug_domain_get()
 #else
 static void hdd_check_for_objmgr_peer_leaks(struct wlan_objmgr_psoc *psoc)
 {
@@ -4052,6 +4054,7 @@ static void hdd_check_for_leaks(struct hdd_context *hdd_ctx, bool is_ssr)
 }
 
 #define hdd_debug_domain_set(domain) 0
+#define hdd_debug_domain_get() DEFAULT_DEBUG_DOMAIN_INIT
 #endif /* CONFIG_LEAK_DETECTION */
 
 #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE
@@ -15659,8 +15662,12 @@ int hdd_wlan_stop_modules(struct hdd_context *hdd_ctx, bool ftm_mode)
 	ucfg_dp_bbm_apply_independent_policy(hdd_ctx->psoc, &param);
 
 	hdd_deinit_adapter_ops_wq(hdd_ctx);
+	hdd_deinit_qdf_ctx(hdd_debug_domain_get());
+
 	hdd_check_for_leaks(hdd_ctx, is_recovery_stop);
 	hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT);
+	hdd_deinit_qdf_ctx(hdd_debug_domain_get());
+	qdf_dma_invalid_buf_list_deinit();
 
 	/* Restore PS params for monitor mode */
 	if (hdd_get_conparam() == QDF_GLOBAL_MONITOR_MODE)