Commit 8bea96ef authored by M Chetan Kumar's avatar M Chetan Kumar Committed by David S. Miller

net: wwan: iosm: fw flashing and cd improvements

1> Function comments moved to .c file.
2> Use literals in return to improve readability.
3> Do error handling check instead of success check.
4> Redundant ret assignment removed.
Signed-off-by: default avatarM Chetan Kumar <m.chetan.kumar@linux.intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a5df6333
...@@ -5,7 +5,15 @@ ...@@ -5,7 +5,15 @@
#include "iosm_ipc_coredump.h" #include "iosm_ipc_coredump.h"
/* Collect coredump data from modem */ /**
* ipc_coredump_collect - To collect coredump
* @devlink: Pointer to devlink instance.
* @data: Pointer to snapshot
* @entry: ID of requested snapshot
* @region_size: Region size
*
* Returns: 0 on success, error on failure
*/
int ipc_coredump_collect(struct iosm_devlink *devlink, u8 **data, int entry, int ipc_coredump_collect(struct iosm_devlink *devlink, u8 **data, int entry,
u32 region_size) u32 region_size)
{ {
...@@ -38,20 +46,27 @@ int ipc_coredump_collect(struct iosm_devlink *devlink, u8 **data, int entry, ...@@ -38,20 +46,27 @@ int ipc_coredump_collect(struct iosm_devlink *devlink, u8 **data, int entry,
*data = data_ptr; *data = data_ptr;
return ret; return 0;
get_cd_fail: get_cd_fail:
vfree(data_ptr); vfree(data_ptr);
return ret; return ret;
} }
/* Get coredump list to be collected from modem */ /**
* ipc_coredump_get_list - Get coredump list from modem
* @devlink: Pointer to devlink instance.
* @cmd: RPSI command to be sent
*
* Returns: 0 on success, error on failure
*/
int ipc_coredump_get_list(struct iosm_devlink *devlink, u16 cmd) int ipc_coredump_get_list(struct iosm_devlink *devlink, u16 cmd)
{ {
u32 byte_read, num_entries, file_size; u32 byte_read, num_entries, file_size;
struct iosm_cd_table *cd_table; struct iosm_cd_table *cd_table;
u8 size[MAX_SIZE_LEN], i; u8 size[MAX_SIZE_LEN], i;
char *filename; char *filename;
int ret = 0; int ret;
cd_table = kzalloc(MAX_CD_LIST_SIZE, GFP_KERNEL); cd_table = kzalloc(MAX_CD_LIST_SIZE, GFP_KERNEL);
if (!cd_table) { if (!cd_table) {
......
...@@ -51,25 +51,9 @@ struct iosm_cd_table { ...@@ -51,25 +51,9 @@ struct iosm_cd_table {
struct iosm_cd_list list; struct iosm_cd_list list;
} __packed; } __packed;
/**
* ipc_coredump_collect - To collect coredump
* @devlink: Pointer to devlink instance.
* @data: Pointer to snapshot
* @entry: ID of requested snapshot
* @region_size: Region size
*
* Returns: 0 on success, error on failure
*/
int ipc_coredump_collect(struct iosm_devlink *devlink, u8 **data, int entry, int ipc_coredump_collect(struct iosm_devlink *devlink, u8 **data, int entry,
u32 region_size); u32 region_size);
/**
* ipc_coredump_get_list - Get coredump list
* @devlink: Pointer to devlink instance.
* @cmd: RPSI command to be sent
*
* Returns: 0 on success, error on failure
*/
int ipc_coredump_get_list(struct iosm_devlink *devlink, u16 cmd); int ipc_coredump_get_list(struct iosm_devlink *devlink, u16 cmd);
#endif /* _IOSM_IPC_COREDUMP_H_ */ #endif /* _IOSM_IPC_COREDUMP_H_ */
...@@ -134,11 +134,11 @@ static int ipc_devlink_flash_update(struct devlink *devlink, ...@@ -134,11 +134,11 @@ static int ipc_devlink_flash_update(struct devlink *devlink,
{ {
struct iosm_devlink *ipc_devlink = devlink_priv(devlink); struct iosm_devlink *ipc_devlink = devlink_priv(devlink);
enum iosm_flash_comp_type fls_type; enum iosm_flash_comp_type fls_type;
u32 rc = -EINVAL; int rc = -EINVAL;
u8 *mdm_rsp; u8 *mdm_rsp;
if (!params->component) if (!params->component)
return rc; return -EINVAL;
mdm_rsp = kzalloc(IOSM_EBL_DW_PACK_SIZE, GFP_KERNEL); mdm_rsp = kzalloc(IOSM_EBL_DW_PACK_SIZE, GFP_KERNEL);
if (!mdm_rsp) if (!mdm_rsp)
...@@ -153,11 +153,12 @@ static int ipc_devlink_flash_update(struct devlink *devlink, ...@@ -153,11 +153,12 @@ static int ipc_devlink_flash_update(struct devlink *devlink,
break; break;
case FLASH_COMP_TYPE_EBL: case FLASH_COMP_TYPE_EBL:
rc = ipc_flash_boot_ebl(ipc_devlink, params->fw); rc = ipc_flash_boot_ebl(ipc_devlink, params->fw);
if (!rc) if (rc)
rc = ipc_flash_boot_set_capabilities(ipc_devlink, break;
mdm_rsp); rc = ipc_flash_boot_set_capabilities(ipc_devlink, mdm_rsp);
if (!rc) if (rc)
rc = ipc_flash_read_swid(ipc_devlink, mdm_rsp); break;
rc = ipc_flash_read_swid(ipc_devlink, mdm_rsp);
break; break;
case FLASH_COMP_TYPE_FLS: case FLASH_COMP_TYPE_FLS:
rc = ipc_flash_send_fls(ipc_devlink, params->fw, mdm_rsp); rc = ipc_flash_send_fls(ipc_devlink, params->fw, mdm_rsp);
...@@ -185,7 +186,14 @@ static const struct devlink_ops devlink_flash_ops = { ...@@ -185,7 +186,14 @@ static const struct devlink_ops devlink_flash_ops = {
.flash_update = ipc_devlink_flash_update, .flash_update = ipc_devlink_flash_update,
}; };
/* Send command to modem to collect data */ /**
* ipc_devlink_send_cmd - Send command to Modem
* @ipc_devlink: Pointer to struct iosm_devlink
* @cmd: Command to be sent to modem
* @entry: Command entry number
*
* Returns: 0 on success and failure value on error
*/
int ipc_devlink_send_cmd(struct iosm_devlink *ipc_devlink, u16 cmd, u32 entry) int ipc_devlink_send_cmd(struct iosm_devlink *ipc_devlink, u16 cmd, u32 entry)
{ {
struct iosm_rpsi_cmd rpsi_cmd; struct iosm_rpsi_cmd rpsi_cmd;
...@@ -199,6 +207,7 @@ int ipc_devlink_send_cmd(struct iosm_devlink *ipc_devlink, u16 cmd, u32 entry) ...@@ -199,6 +207,7 @@ int ipc_devlink_send_cmd(struct iosm_devlink *ipc_devlink, u16 cmd, u32 entry)
sizeof(rpsi_cmd)); sizeof(rpsi_cmd));
} }
/* Function to create snapshot */
static int ipc_devlink_coredump_snapshot(struct devlink *dl, static int ipc_devlink_coredump_snapshot(struct devlink *dl,
const struct devlink_region_ops *ops, const struct devlink_region_ops *ops,
struct netlink_ext_ack *extack, struct netlink_ext_ack *extack,
...@@ -223,7 +232,8 @@ static int ipc_devlink_coredump_snapshot(struct devlink *dl, ...@@ -223,7 +232,8 @@ static int ipc_devlink_coredump_snapshot(struct devlink *dl,
if (cd_list->entry == (IOSM_NOF_CD_REGION - 1)) if (cd_list->entry == (IOSM_NOF_CD_REGION - 1))
ipc_coredump_get_list(ipc_devlink, rpsi_cmd_coredump_end); ipc_coredump_get_list(ipc_devlink, rpsi_cmd_coredump_end);
return rc; return 0;
coredump_collect_err: coredump_collect_err:
ipc_coredump_get_list(ipc_devlink, rpsi_cmd_coredump_end); ipc_coredump_get_list(ipc_devlink, rpsi_cmd_coredump_end);
return rc; return rc;
...@@ -270,7 +280,12 @@ static void ipc_devlink_destroy_region(struct iosm_devlink *ipc_devlink) ...@@ -270,7 +280,12 @@ static void ipc_devlink_destroy_region(struct iosm_devlink *ipc_devlink)
devlink_region_destroy(ipc_devlink->cd_regions[i]); devlink_region_destroy(ipc_devlink->cd_regions[i]);
} }
/* Handle registration to devlink framework */ /**
* ipc_devlink_init - Initialize/register devlink to IOSM driver
* @ipc_imem: Pointer to struct iosm_imem
*
* Returns: Pointer to iosm_devlink on success and NULL on failure
*/
struct iosm_devlink *ipc_devlink_init(struct iosm_imem *ipc_imem) struct iosm_devlink *ipc_devlink_init(struct iosm_imem *ipc_imem)
{ {
struct ipc_chnl_cfg chnl_cfg_flash = { 0 }; struct ipc_chnl_cfg chnl_cfg_flash = { 0 };
...@@ -335,7 +350,10 @@ struct iosm_devlink *ipc_devlink_init(struct iosm_imem *ipc_imem) ...@@ -335,7 +350,10 @@ struct iosm_devlink *ipc_devlink_init(struct iosm_imem *ipc_imem)
return NULL; return NULL;
} }
/* Handle unregistration of devlink */ /**
* ipc_devlink_deinit - To unintialize the devlink from IOSM driver.
* @ipc_devlink: Devlink instance
*/
void ipc_devlink_deinit(struct iosm_devlink *ipc_devlink) void ipc_devlink_deinit(struct iosm_devlink *ipc_devlink)
{ {
struct devlink *devlink_ctx = ipc_devlink->devlink_ctx; struct devlink *devlink_ctx = ipc_devlink->devlink_ctx;
......
...@@ -180,28 +180,10 @@ struct iosm_rpsi_cmd { ...@@ -180,28 +180,10 @@ struct iosm_rpsi_cmd {
__le16 crc; __le16 crc;
}; };
/**
* ipc_devlink_init - To initialize the devlink to IOSM driver
* @ipc_imem: Pointer to struct iosm_imem
*
* Returns: Pointer to iosm_devlink on success and NULL on failure
*/
struct iosm_devlink *ipc_devlink_init(struct iosm_imem *ipc_imem); struct iosm_devlink *ipc_devlink_init(struct iosm_imem *ipc_imem);
/**
* ipc_devlink_deinit - To unintialize the devlink from IOSM driver.
* @ipc_devlink: Devlink instance
*/
void ipc_devlink_deinit(struct iosm_devlink *ipc_devlink); void ipc_devlink_deinit(struct iosm_devlink *ipc_devlink);
/**
* ipc_devlink_send_cmd - Send command to Modem
* @ipc_devlink: Pointer to struct iosm_devlink
* @cmd: Command to be sent to modem
* @entry: Command entry number
*
* Returns: 0 on success and failure value on error
*/
int ipc_devlink_send_cmd(struct iosm_devlink *ipc_devlink, u16 cmd, u32 entry); int ipc_devlink_send_cmd(struct iosm_devlink *ipc_devlink, u16 cmd, u32 entry);
#endif /* _IOSM_IPC_DEVLINK_H */ #endif /* _IOSM_IPC_DEVLINK_H */
...@@ -40,7 +40,6 @@ static int ipc_flash_proc_check_ebl_rsp(void *hdr_rsp, void *payload_rsp) ...@@ -40,7 +40,6 @@ static int ipc_flash_proc_check_ebl_rsp(void *hdr_rsp, void *payload_rsp)
{ {
struct iosm_ebl_error *err_info = payload_rsp; struct iosm_ebl_error *err_info = payload_rsp;
u16 *rsp_code = hdr_rsp; u16 *rsp_code = hdr_rsp;
int res = 0;
u32 i; u32 i;
if (*rsp_code == IOSM_EBL_RSP_BUFF) { if (*rsp_code == IOSM_EBL_RSP_BUFF) {
...@@ -51,10 +50,10 @@ static int ipc_flash_proc_check_ebl_rsp(void *hdr_rsp, void *payload_rsp) ...@@ -51,10 +50,10 @@ static int ipc_flash_proc_check_ebl_rsp(void *hdr_rsp, void *payload_rsp)
err_info->error[i].error_code); err_info->error[i].error_code);
} }
} }
res = -EINVAL; return -EINVAL;
} }
return res; return 0;
} }
/* Send data to the modem */ /* Send data to the modem */
...@@ -90,7 +89,12 @@ static int ipc_flash_send_data(struct iosm_devlink *ipc_devlink, u32 size, ...@@ -90,7 +89,12 @@ static int ipc_flash_send_data(struct iosm_devlink *ipc_devlink, u32 size,
return ret; return ret;
} }
/* Allocate flash channel and read LER data from modem */ /**
* ipc_flash_link_establish - Flash link establishment
* @ipc_imem: Pointer to struct iosm_imem
*
* Returns: 0 on success and failure value on error
*/
int ipc_flash_link_establish(struct iosm_imem *ipc_imem) int ipc_flash_link_establish(struct iosm_imem *ipc_imem)
{ {
u8 ler_data[IOSM_LER_RSP_SIZE]; u8 ler_data[IOSM_LER_RSP_SIZE];
...@@ -109,6 +113,7 @@ int ipc_flash_link_establish(struct iosm_imem *ipc_imem) ...@@ -109,6 +113,7 @@ int ipc_flash_link_establish(struct iosm_imem *ipc_imem)
if (bytes_read != IOSM_LER_RSP_SIZE) if (bytes_read != IOSM_LER_RSP_SIZE)
goto devlink_read_fail; goto devlink_read_fail;
return 0; return 0;
devlink_read_fail: devlink_read_fail:
...@@ -179,12 +184,16 @@ static int ipc_flash_send_receive(struct iosm_devlink *ipc_devlink, u16 pack_id, ...@@ -179,12 +184,16 @@ static int ipc_flash_send_receive(struct iosm_devlink *ipc_devlink, u16 pack_id,
return ret; return ret;
} }
/* Set the capabilities for the EBL */ /**
* ipc_flash_boot_set_capabilities - Set modem boot capabilities in flash
* @ipc_devlink: Pointer to devlink structure
* @mdm_rsp: Pointer to modem response buffer
*
* Returns: 0 on success and failure value on error
*/
int ipc_flash_boot_set_capabilities(struct iosm_devlink *ipc_devlink, int ipc_flash_boot_set_capabilities(struct iosm_devlink *ipc_devlink,
u8 *mdm_rsp) u8 *mdm_rsp)
{ {
int ret;
ipc_devlink->ebl_ctx.ebl_sw_info_version = ipc_devlink->ebl_ctx.ebl_sw_info_version =
ipc_devlink->ebl_ctx.m_ebl_resp[EBL_RSP_SW_INFO_VER]; ipc_devlink->ebl_ctx.m_ebl_resp[EBL_RSP_SW_INFO_VER];
ipc_devlink->ebl_ctx.m_ebl_resp[EBL_SKIP_ERASE] = IOSM_CAP_NOT_ENHANCED; ipc_devlink->ebl_ctx.m_ebl_resp[EBL_SKIP_ERASE] = IOSM_CAP_NOT_ENHANCED;
...@@ -205,10 +214,9 @@ int ipc_flash_boot_set_capabilities(struct iosm_devlink *ipc_devlink, ...@@ -205,10 +214,9 @@ int ipc_flash_boot_set_capabilities(struct iosm_devlink *ipc_devlink,
/* Write back the EBL capability to modem /* Write back the EBL capability to modem
* Request Set Protcnf command * Request Set Protcnf command
*/ */
ret = ipc_flash_send_receive(ipc_devlink, FLASH_SET_PROT_CONF, return ipc_flash_send_receive(ipc_devlink, FLASH_SET_PROT_CONF,
ipc_devlink->ebl_ctx.m_ebl_resp, ipc_devlink->ebl_ctx.m_ebl_resp,
IOSM_EBL_RSP_SIZE, mdm_rsp); IOSM_EBL_RSP_SIZE, mdm_rsp);
return ret;
} }
/* Read the SWID type and SWID value from the EBL */ /* Read the SWID type and SWID value from the EBL */
...@@ -380,7 +388,14 @@ static int ipc_flash_download_region(struct iosm_devlink *ipc_devlink, ...@@ -380,7 +388,14 @@ static int ipc_flash_download_region(struct iosm_devlink *ipc_devlink,
return ret; return ret;
} }
/* Flash the individual fls files */ /**
* ipc_flash_send_fls - Inject Modem subsystem fls file to device
* @ipc_devlink: Pointer to devlink structure
* @fw: FW image
* @mdm_rsp: Pointer to modem response buffer
*
* Returns: 0 on success and failure value on error
*/
int ipc_flash_send_fls(struct iosm_devlink *ipc_devlink, int ipc_flash_send_fls(struct iosm_devlink *ipc_devlink,
const struct firmware *fw, u8 *mdm_rsp) const struct firmware *fw, u8 *mdm_rsp)
{ {
...@@ -420,7 +435,13 @@ int ipc_flash_send_fls(struct iosm_devlink *ipc_devlink, ...@@ -420,7 +435,13 @@ int ipc_flash_send_fls(struct iosm_devlink *ipc_devlink,
return ret; return ret;
} }
/* Inject RPSI */ /**
* ipc_flash_boot_psi - Inject PSI image
* @ipc_devlink: Pointer to devlink structure
* @fw: FW image
*
* Returns: 0 on success and failure value on error
*/
int ipc_flash_boot_psi(struct iosm_devlink *ipc_devlink, int ipc_flash_boot_psi(struct iosm_devlink *ipc_devlink,
const struct firmware *fw) const struct firmware *fw)
{ {
...@@ -470,7 +491,13 @@ int ipc_flash_boot_psi(struct iosm_devlink *ipc_devlink, ...@@ -470,7 +491,13 @@ int ipc_flash_boot_psi(struct iosm_devlink *ipc_devlink,
return ret; return ret;
} }
/* Inject EBL */ /**
* ipc_flash_boot_ebl - Inject EBL image
* @ipc_devlink: Pointer to devlink structure
* @fw: FW image
*
* Returns: 0 on success and failure value on error
*/
int ipc_flash_boot_ebl(struct iosm_devlink *ipc_devlink, int ipc_flash_boot_ebl(struct iosm_devlink *ipc_devlink,
const struct firmware *fw) const struct firmware *fw)
{ {
......
...@@ -211,61 +211,19 @@ struct iosm_flash_data { ...@@ -211,61 +211,19 @@ struct iosm_flash_data {
__le32 msg_length; __le32 msg_length;
}; };
/**
* ipc_flash_boot_psi - Inject PSI image
* @ipc_devlink: Pointer to devlink structure
* @fw: FW image
*
* Returns: 0 on success and failure value on error
*/
int ipc_flash_boot_psi(struct iosm_devlink *ipc_devlink, int ipc_flash_boot_psi(struct iosm_devlink *ipc_devlink,
const struct firmware *fw); const struct firmware *fw);
/**
* ipc_flash_boot_ebl - Inject EBL image
* @ipc_devlink: Pointer to devlink structure
* @fw: FW image
*
* Returns: 0 on success and failure value on error
*/
int ipc_flash_boot_ebl(struct iosm_devlink *ipc_devlink, int ipc_flash_boot_ebl(struct iosm_devlink *ipc_devlink,
const struct firmware *fw); const struct firmware *fw);
/**
* ipc_flash_boot_set_capabilities - Set modem bool capabilities in flash
* @ipc_devlink: Pointer to devlink structure
* @mdm_rsp: Pointer to modem response buffer
*
* Returns: 0 on success and failure value on error
*/
int ipc_flash_boot_set_capabilities(struct iosm_devlink *ipc_devlink, int ipc_flash_boot_set_capabilities(struct iosm_devlink *ipc_devlink,
u8 *mdm_rsp); u8 *mdm_rsp);
/**
* ipc_flash_link_establish - Flash link establishment
* @ipc_imem: Pointer to struct iosm_imem
*
* Returns: 0 on success and failure value on error
*/
int ipc_flash_link_establish(struct iosm_imem *ipc_imem); int ipc_flash_link_establish(struct iosm_imem *ipc_imem);
/**
* ipc_flash_read_swid - Get swid during flash phase
* @ipc_devlink: Pointer to devlink structure
* @mdm_rsp: Pointer to modem response buffer
*
* Returns: 0 on success and failure value on error
*/
int ipc_flash_read_swid(struct iosm_devlink *ipc_devlink, u8 *mdm_rsp); int ipc_flash_read_swid(struct iosm_devlink *ipc_devlink, u8 *mdm_rsp);
/**
* ipc_flash_send_fls - Inject Modem subsystem fls file to device
* @ipc_devlink: Pointer to devlink structure
* @fw: FW image
* @mdm_rsp: Pointer to modem response buffer
*
* Returns: 0 on success and failure value on error
*/
int ipc_flash_send_fls(struct iosm_devlink *ipc_devlink, int ipc_flash_send_fls(struct iosm_devlink *ipc_devlink,
const struct firmware *fw, u8 *mdm_rsp); const struct firmware *fw, u8 *mdm_rsp);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment