Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ec18b1e authored by Komal Seelam's avatar Komal Seelam Committed by Gerrit - the friendly Code Review server
Browse files

CNSS: Memory Allocation for Secure Firmware Feature



Allocate memory for target firmware binaries for hash computation.

Change-Id: Icd91029ad8913f6046f1e286d471842ba6cd6c0a
CRs-Fixed: 717910
Signed-off-by: default avatarKomal Kumar <kseelam@codeaurora.org>
parent 3511ae2a
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -311,6 +311,15 @@ config CNSS
	  This driver also adds support to integrate PCIe WLAN module to subsystem
	  restart framework.

config CNSS_SECURE_FW
	bool "Enable/Disable Memory Allocation for Secure Firmware Feature"
	depends on CNSS
	---help---
	  CLD Driver can use this for holding local copy of firmware
	  binaries which is used for sha crypto computation.
	  The Memory Allocation is done only if this Config Parameter is
	  enabled

config WCNSS_CORE_PRONTO
	tristate "Qualcomm WCNSS Pronto Support"
	depends on WCNSS_CORE
+30 −1
Original line number Diff line number Diff line
@@ -174,9 +174,11 @@ static struct cnss_data {
	uint32_t recovery_count;
	enum cnss_driver_status driver_status;
	void *dfs_nol_info;
#ifdef CONFIG_CNSS_SECURE_FW
	void *fw_mem;
#endif
} *penv;


static int cnss_wlan_vreg_on(struct cnss_wlan_vreg_info *vreg_info)
{
	int ret;
@@ -639,6 +641,20 @@ int cnss_get_fw_files_for_target(struct cnss_fw_files *pfw_files,
}
EXPORT_SYMBOL(cnss_get_fw_files_for_target);

#ifdef CONFIG_CNSS_SECURE_FW
static void cnss_wlan_fw_mem_alloc(struct pci_dev *pdev)
{
	penv->fw_mem = devm_kzalloc(&pdev->dev, MAX_FIRMWARE_SIZE, GFP_KERNEL);

	if (!penv->fw_mem)
		pr_debug("Memory not available for Secure FW\n");
}
#else
static void cnss_wlan_fw_mem_alloc(struct pci_dev *pdev)
{
}
#endif

static int cnss_wlan_pci_probe(struct pci_dev *pdev,
			       const struct pci_device_id *id)
{
@@ -685,6 +701,8 @@ static int cnss_wlan_pci_probe(struct pci_dev *pdev,
		goto err_pcie_suspend;
	}

	cnss_wlan_fw_mem_alloc(pdev);

	if (penv->revision_id != QCA6174_FW_3_0) {
		pr_debug("Supported Target Revision:%d\n", penv->revision_id);
		goto err_pcie_suspend;
@@ -1947,6 +1965,7 @@ void cnss_set_driver_status(enum cnss_driver_status driver_status)
}
EXPORT_SYMBOL(cnss_set_driver_status);

#ifdef CONFIG_CNSS_SECURE_FW
int cnss_get_sha_hash(const u8 *data, u32 data_len, u8 *hash_idx, u8 *out)
{
	struct scatterlist sg;
@@ -1975,6 +1994,16 @@ end:
}
EXPORT_SYMBOL(cnss_get_sha_hash);

void *cnss_get_fw_ptr(void)
{
	if (!penv)
		return NULL;

	return penv->fw_mem;
}
EXPORT_SYMBOL(cnss_get_fw_ptr);
#endif

module_init(cnss_initialize);
module_exit(cnss_exit);

+5 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@

#define CNSS_MAX_FILE_NAME	  20

#define MAX_FIRMWARE_SIZE (512 * 1024)

enum cnss_bus_width_type {
	CNSS_BUS_WIDTH_NONE,
	CNSS_BUS_WIDTH_LOW,
@@ -112,8 +114,11 @@ extern void cnss_get_boottime(struct timespec *ts);
extern void cnss_init_work(struct work_struct *work, work_func_t func);
extern void cnss_init_delayed_work(struct delayed_work *work, work_func_t func);
extern int cnss_request_bus_bandwidth(int bandwidth);

extern int cnss_get_sha_hash(const u8 *data, u32 data_len,
					u8 *hash_idx, u8 *out);
extern void *cnss_get_fw_ptr(void);

extern int cnss_get_codeswap_struct(struct codeswap_codeseg_info *swap_seg);

extern void cnss_pm_wake_lock_init(struct wakeup_source *ws, const char *name);