cnss2: Add SMEM based Secure Peripheral check

Check secure peripheral HW state using SMEM APIs instead of
SCM APIs.

Change-Id: I3e652859189221d3b9d26bd2e71e254edf6843b0
CRs-Fixed: 3601121
This commit is contained in:
Naman Padhiar
2023-06-14 18:13:40 +05:30
committed by Rahul Choudhary
parent 89f8f5e0b2
commit e9066ddd35
5 changed files with 54 additions and 1 deletions

4
Kbuild
View File

@@ -38,6 +38,10 @@ ifeq ($(CONFIG_CNSS_HW_SECURE_DISABLE), y)
KBUILD_CPPFLAGS += -DCONFIG_CNSS_HW_SECURE_DISABLE
endif
ifeq ($(CONFIG_CNSS_HW_SECURE_SMEM), y)
KBUILD_CPPFLAGS += -DCONFIG_CNSS_HW_SECURE_SMEM
endif
ifeq ($(CONFIG_CNSS2_CONDITIONAL_POWEROFF),y)
KBUILD_CPPFLAGS += -DCONFIG_CNSS2_CONDITIONAL_POWEROFF
endif

View File

@@ -144,6 +144,13 @@ config CNSS_HW_SECURE_DISABLE
handle WLAN cold boot initialization sequence changes if HW is
disabled at boot and WLAN resume sequence after WLAN HW is enabled.
config CNSS_HW_SECURE_SMEM
bool "Enable SMEM API based HW peripheral security"
depends on CNSS2
help
If enabled, CNSS platform driver will use SMEM APIs intead of SCM
APIs to check peripheral secure state of HW.
config CNSS2_SSR_DRIVER_DUMP
bool "Enable Host SSR DRIVER DUMP Collection"
depends on CNSS2

View File

@@ -35,16 +35,21 @@
#include "reg.h"
#ifdef CONFIG_CNSS_HW_SECURE_DISABLE
#ifdef CONFIG_CNSS_HW_SECURE_SMEM
#include <linux/soc/qcom/smem.h>
#define PERISEC_SMEM_ID 651
#define HW_WIFI_UID 0x508
#else
#include "smcinvoke.h"
#include "smcinvoke_object.h"
#include "IClientEnv.h"
#define HW_STATE_UID 0x108
#define HW_OP_GET_STATE 1
#define HW_WIFI_UID 0x508
#define FEATURE_NOT_SUPPORTED 12
#define PERIPHERAL_NOT_FOUND 10
#endif
#endif
#define CNSS_DUMP_FORMAT_VER 0x11
#define CNSS_DUMP_FORMAT_VER_V2 0x22
@@ -4394,6 +4399,40 @@ static int cnss_reboot_notifier(struct notifier_block *nb,
}
#ifdef CONFIG_CNSS_HW_SECURE_DISABLE
#ifdef CONFIG_CNSS_HW_SECURE_SMEM
int cnss_wlan_hw_disable_check(struct cnss_plat_data *plat_priv)
{
uint32_t *peripheralStateInfo = NULL;
size_t size = 0;
/* Once this flag is set, secure peripheral feature
* will not be supported till next reboot
*/
if (plat_priv->sec_peri_feature_disable)
return 0;
peripheralStateInfo = qcom_smem_get(QCOM_SMEM_HOST_ANY, PERISEC_SMEM_ID, &size);
if (IS_ERR_OR_NULL(peripheralStateInfo)) {
if (PTR_ERR(peripheralStateInfo) != -ENOENT)
CNSS_ASSERT(0);
cnss_pr_dbg("Secure HW feature not enabled. ret = %d\n",
PTR_ERR(peripheralStateInfo));
plat_priv->sec_peri_feature_disable = true;
return 0;
}
cnss_pr_dbg("Secure HW state: %d\n", *peripheralStateInfo);
if ((*peripheralStateInfo >> (HW_WIFI_UID - 0x500)) & 0x1)
set_bit(CNSS_WLAN_HW_DISABLED,
&plat_priv->driver_state);
else
clear_bit(CNSS_WLAN_HW_DISABLED,
&plat_priv->driver_state);
return 0;
}
#else
int cnss_wlan_hw_disable_check(struct cnss_plat_data *plat_priv)
{
struct Object client_env;
@@ -4459,6 +4498,7 @@ end:
}
return ret;
}
#endif
#else
int cnss_wlan_hw_disable_check(struct cnss_plat_data *plat_priv)
{

View File

@@ -5,6 +5,7 @@ CONFIG_CNSS_QMI_SVC=m
CONFIG_BUS_AUTO_SUSPEND=y
CONFIG_CNSS2_SSR_DRIVER_DUMP=y
CONFIG_CNSS_HW_SECURE_DISABLE=y
CONFIG_CNSS_HW_SECURE_SMEM=y
CONFIG_CNSS2_SMMU_DB_SUPPORT=y
CONFIG_CNSS_PLAT_IPC_QMI_SVC=m
CONFIG_WCNSS_MEM_PRE_ALLOC=m

View File

@@ -5,6 +5,7 @@ CONFIG_CNSS_QMI_SVC=m
CONFIG_BUS_AUTO_SUSPEND=y
CONFIG_CNSS2_SSR_DRIVER_DUMP=y
CONFIG_CNSS_HW_SECURE_DISABLE=y
CONFIG_CNSS_HW_SECURE_SMEM=y
CONFIG_CNSS2_SMMU_DB_SUPPORT=y
CONFIG_CNSS_PLAT_IPC_QMI_SVC=m
CONFIG_WCNSS_MEM_PRE_ALLOC=m