soc: qcom: pil: Use subsys_set_error to indicate firmware errors

Use subsys_set_error() to indicate invalid firmware image
that prevented subsystem from coming up. Userspace helper
applications will find this useful to take suitable
recovery action.

Change-Id: Ie03e4f2652692f30d32bbe80b39fb49ba95ea728
Signed-off-by: Meghana Ashok <meghanaa@codeaurora.org>
[fixed minor conflicts]
Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org>
This commit is contained in:
Meghana Ashok 2017-04-13 16:03:18 +05:30 committed by Gerrit - the friendly Code Review server
parent 5b22bf499b
commit 7bd132d979
3 changed files with 14 additions and 1 deletions

View file

@ -66,6 +66,7 @@ static int proxy_timeout_ms = -1;
module_param(proxy_timeout_ms, int, S_IRUGO | S_IWUSR);
static bool disable_timeouts;
static const char firmware_error_msg[] = "firmware_error\n";
/**
* struct pil_mdt - Representation of <name>.mdt file in memory
* @hdr: ELF32 header
@ -673,12 +674,14 @@ static int pil_load_seg(struct pil_desc *desc, struct pil_seg *seg)
if (ret < 0) {
pil_err(desc, "Failed to locate blob %s or blob is too big(rc:%d)\n",
fw_name, ret);
subsys_set_error(desc->subsys_dev, firmware_error_msg);
return ret;
}
if (ret != seg->filesz) {
pil_err(desc, "Blob size %u doesn't match %lu\n",
ret, seg->filesz);
subsys_set_error(desc->subsys_dev, firmware_error_msg);
return -EPERM;
}
ret = 0;
@ -707,9 +710,11 @@ static int pil_load_seg(struct pil_desc *desc, struct pil_seg *seg)
if (desc->ops->verify_blob) {
ret = desc->ops->verify_blob(desc, seg->paddr, seg->sz);
if (ret)
if (ret) {
pil_err(desc, "Blob%u failed verification(rc:%d)\n",
num, ret);
subsys_set_error(desc->subsys_dev, firmware_error_msg);
}
}
return ret;
@ -790,6 +795,7 @@ int pil_boot(struct pil_desc *desc)
if (fw->size < sizeof(*ehdr)) {
pil_err(desc, "Not big enough to be an elf header\n");
subsys_set_error(desc->subsys_dev, firmware_error_msg);
ret = -EIO;
goto release_fw;
}
@ -799,18 +805,21 @@ int pil_boot(struct pil_desc *desc)
if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG)) {
pil_err(desc, "Not an elf header\n");
subsys_set_error(desc->subsys_dev, firmware_error_msg);
ret = -EIO;
goto release_fw;
}
if (ehdr->e_phnum == 0) {
pil_err(desc, "No loadable segments\n");
subsys_set_error(desc->subsys_dev, firmware_error_msg);
ret = -EIO;
goto release_fw;
}
if (sizeof(struct elf32_phdr) * ehdr->e_phnum +
sizeof(struct elf32_hdr) > fw->size) {
pil_err(desc, "Program headers not within mdt\n");
subsys_set_error(desc->subsys_dev, firmware_error_msg);
ret = -EIO;
goto release_fw;
}
@ -830,6 +839,7 @@ int pil_boot(struct pil_desc *desc)
ret = desc->ops->init_image(desc, fw->data, fw->size);
if (ret) {
pil_err(desc, "Initializing image failed(rc:%d)\n", ret);
subsys_set_error(desc->subsys_dev, firmware_error_msg);
goto err_boot;
}
@ -887,6 +897,7 @@ int pil_boot(struct pil_desc *desc)
ret = desc->ops->auth_and_reset(desc);
if (ret) {
pil_err(desc, "Failed to bring out of reset(rc:%d)\n", ret);
subsys_set_error(desc->subsys_dev, firmware_error_msg);
goto err_auth_and_reset;
}
pil_info(desc, "Brought out of reset\n");

View file

@ -44,6 +44,7 @@ struct pil_desc {
const char *name;
const char *fw_name;
struct device *dev;
struct subsys_device *subsys_dev;
const struct pil_reset_ops *ops;
struct module *owner;
unsigned long proxy_timeout;

View file

@ -222,6 +222,7 @@ static int pil_subsys_init(struct modem_data *drv,
goto err_subsys;
}
drv->q6->desc.subsys_dev = drv->subsys;
drv->ramdump_dev = create_ramdump_device("modem", &pdev->dev);
if (!drv->ramdump_dev) {
pr_err("%s: Unable to create a modem ramdump device.\n",