From 54007e59aae2e10563ad247bfb623ff46efbd839 Mon Sep 17 00:00:00 2001 From: Raghavendra Rao Ananta Date: Fri, 7 Aug 2020 09:58:53 -0700 Subject: [PATCH] qcom: pil: Move the IMEM location for disabling timeouts Currently, the PIL driver expects the debug cookie for disabling the check for subsystem bootup timeouts in the PIL's standard IMEM location. However, since the bootloader also loads the firmware, it's possible that it can use this location to set the cookie that's needed for ramdump parsers. As a result, the original timeout cookie, that's usually set before bootloader even begins, is overwritten. Hence, move the timeout cookie to a different location to avoid this conflict. Change-Id: I2e368e9fbd7e996e2a4290b75818fae8cb9277be Signed-off-by: Raghavendra Rao Ananta --- drivers/soc/qcom/peripheral-loader.c | 65 +++++++++++++++++++--------- 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/drivers/soc/qcom/peripheral-loader.c b/drivers/soc/qcom/peripheral-loader.c index 92b153afd78a..587797b2b558 100644 --- a/drivers/soc/qcom/peripheral-loader.c +++ b/drivers/soc/qcom/peripheral-loader.c @@ -54,6 +54,7 @@ #define NUM_OF_ENCRYPTED_KEY 3 static void __iomem *pil_info_base; +static void __iomem *pil_disable_timeout_base; static struct md_global_toc *g_md_toc; /** @@ -1676,39 +1677,61 @@ static int pil_pm_notify(struct notifier_block *b, unsigned long event, void *p) static struct notifier_block pil_pm_notifier = { .notifier_call = pil_pm_notify, }; - -static int __init msm_pil_init(void) +static void __iomem * __init pil_get_resource(const char *prop, + resource_size_t *out_size) { + void __iomem *base_addr; struct device_node *np; struct resource res; + + np = of_find_compatible_node(NULL, NULL, prop); + if (!np) { + pr_warn("pil: failed to find %s node\n", prop); + return NULL; + } + + if (of_address_to_resource(np, 0, &res)) { + pr_warn("pil: address to resource for %s failed\n", prop); + return NULL; + } + + base_addr = ioremap(res.start, resource_size(&res)); + if (!base_addr) { + pr_warn("pil: could not map region for %s\n", prop); + return NULL; + } + + if (out_size) + *out_size = resource_size(&res); + + return base_addr; +} +static int __init msm_pil_init(void) +{ + resource_size_t res_size; int i; - np = of_find_compatible_node(NULL, NULL, "qcom,msm-imem-pil"); - if (!np) { - pr_warn("pil: failed to find qcom,msm-imem-pil node\n"); - goto out; + pil_info_base = pil_get_resource("qcom,msm-imem-pil", &res_size); + if (pil_info_base) { + for (i = 0; i < res_size / sizeof(u32); i++) + writel_relaxed(0, pil_info_base + (i * sizeof(u32))); } - if (of_address_to_resource(np, 0, &res)) { - pr_warn("pil: address to resource on imem region failed\n"); - goto out; + + pil_disable_timeout_base = + pil_get_resource("qcom,msm-imem-pil-disable-timeout", NULL); + if (pil_disable_timeout_base) { + if (__raw_readl(pil_disable_timeout_base) == 0x53444247) { + pr_info("pil: pil-imem set to disable pil timeouts\n"); + disable_timeouts = true; + } + + iounmap(pil_disable_timeout_base); } - pil_info_base = ioremap(res.start, resource_size(&res)); - if (!pil_info_base) { - pr_warn("pil: could not map imem region\n"); - goto out; - } - if (__raw_readl(pil_info_base) == 0x53444247) { - pr_info("pil: pil-imem set to disable pil timeouts\n"); - disable_timeouts = true; - } - for (i = 0; i < resource_size(&res)/sizeof(u32); i++) - writel_relaxed(0, pil_info_base + (i * sizeof(u32))); pil_wq = alloc_workqueue("pil_workqueue", WQ_HIGHPRI | WQ_UNBOUND, 0); if (!pil_wq) pr_warn("pil: Defaulting to sequential firmware loading.\n"); -out: return register_pm_notifier(&pil_pm_notifier); } subsys_initcall(msm_pil_init);