OSDN Git Service

soc: qcom: pil: timeouts to be disabled from pil-imem
authorPuja Gupta <pujag@codeaurora.org>
Sat, 14 May 2016 01:48:49 +0000 (18:48 -0700)
committerJeevan Shriram <jshriram@codeaurora.org>
Thu, 19 May 2016 23:10:34 +0000 (16:10 -0700)
Allow modem mba, modem pbl and err_ready timeouts to be disabled by
writing to starting of pil_imem region.

CRs-Fixed: 1015492
Change-Id: I786d8edcd89e3624ef05ffc9a6953a8f840bbac0
Signed-off-by: Puja Gupta <pujag@codeaurora.org>
drivers/soc/qcom/peripheral-loader.c
drivers/soc/qcom/peripheral-loader.h
drivers/soc/qcom/pil-msa.c
drivers/soc/qcom/subsystem_restart.c

index 009dbf5..e163dd7 100644 (file)
@@ -65,6 +65,7 @@ static void __iomem *pil_info_base;
 static int proxy_timeout_ms = -1;
 module_param(proxy_timeout_ms, int, S_IRUGO | S_IWUSR);
 
+static bool disable_timeouts;
 /**
  * struct pil_mdt - Representation of <name>.mdt file in memory
  * @hdr: ELF32 header
@@ -939,6 +940,10 @@ EXPORT_SYMBOL(pil_free_memory);
 
 static DEFINE_IDA(pil_ida);
 
+bool is_timeout_disabled(void)
+{
+       return disable_timeouts;
+}
 /**
  * pil_desc_init() - Initialize a pil descriptor
  * @desc: descriptor to intialize
@@ -1078,6 +1083,10 @@ static int __init msm_pil_init(void)
                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)));
 
index 1e8c065..c3689fa 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2010-2016, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -110,6 +110,7 @@ extern int pil_assign_mem_to_subsys_and_linux(struct pil_desc *desc,
                                                phys_addr_t addr, size_t size);
 extern int pil_reclaim_mem(struct pil_desc *desc, phys_addr_t addr, size_t size,
                                                int VMid);
+extern bool is_timeout_disabled(void);
 #else
 static inline int pil_desc_init(struct pil_desc *desc) { return 0; }
 static inline int pil_boot(struct pil_desc *desc) { return 0; }
@@ -144,6 +145,7 @@ static inline int pil_reclaim_mem(struct pil_desc *desc, phys_addr_t addr,
 {
        return 0;
 }
+extern bool is_timeout_disabled(void) { return false; }
 #endif
 
 #endif
index 618d872..16c6224 100644 (file)
@@ -239,10 +239,11 @@ static int pil_msa_wait_for_mba_ready(struct q6v5_data *drv)
        struct device *dev = drv->desc.dev;
        int ret;
        u32 status;
+       u64 val = is_timeout_disabled() ? 0 : pbl_mba_boot_timeout_ms * 1000;
 
        /* Wait for PBL completion. */
        ret = readl_poll_timeout(drv->rmb_base + RMB_PBL_STATUS, status,
-               status != 0, POLL_INTERVAL_US, pbl_mba_boot_timeout_ms * 1000);
+                                status != 0, POLL_INTERVAL_US, val);
        if (ret) {
                dev_err(dev, "PBL boot timed out\n");
                return ret;
@@ -254,7 +255,7 @@ static int pil_msa_wait_for_mba_ready(struct q6v5_data *drv)
 
        /* Wait for MBA completion. */
        ret = readl_poll_timeout(drv->rmb_base + RMB_MBA_STATUS, status,
-               status != 0, POLL_INTERVAL_US, pbl_mba_boot_timeout_ms * 1000);
+                               status != 0, POLL_INTERVAL_US, val);
        if (ret) {
                dev_err(dev, "MBA boot timed out\n");
                return ret;
@@ -318,13 +319,14 @@ int __pil_mss_deinit_image(struct pil_desc *pil, bool err_path)
        struct q6v5_data *q6_drv = container_of(pil, struct q6v5_data, desc);
        int ret = 0;
        s32 status;
+       u64 val = is_timeout_disabled() ? 0 : pbl_mba_boot_timeout_ms * 1000;
 
        if (err_path) {
                writel_relaxed(CMD_PILFAIL_NFY_MBA,
                                drv->rmb_base + RMB_MBA_COMMAND);
                ret = readl_poll_timeout(drv->rmb_base + RMB_MBA_STATUS, status,
-                       status == STATUS_MBA_UNLOCKED || status < 0,
-                       POLL_INTERVAL_US, pbl_mba_boot_timeout_ms * 1000);
+                               status == STATUS_MBA_UNLOCKED || status < 0,
+                               POLL_INTERVAL_US, val);
                if (ret)
                        dev_err(pil->dev, "MBA region unlock timed out\n");
                else if (status < 0)
@@ -649,6 +651,7 @@ static int pil_msa_auth_modem_mdt(struct pil_desc *pil, const u8 *metadata,
        dma_addr_t mdata_phys;
        s32 status;
        int ret;
+       u64 val = is_timeout_disabled() ? 0 : modem_auth_timeout_ms * 1000;
        DEFINE_DMA_ATTRS(attrs);
 
        drv->mba_mem_dev.coherent_dma_mask =
@@ -684,8 +687,8 @@ static int pil_msa_auth_modem_mdt(struct pil_desc *pil, const u8 *metadata,
        writel_relaxed(mdata_phys, drv->rmb_base + RMB_PMI_META_DATA);
        writel_relaxed(CMD_META_DATA_READY, drv->rmb_base + RMB_MBA_COMMAND);
        ret = readl_poll_timeout(drv->rmb_base + RMB_MBA_STATUS, status,
-               status == STATUS_META_DATA_AUTH_SUCCESS || status < 0,
-               POLL_INTERVAL_US, modem_auth_timeout_ms * 1000);
+                       status == STATUS_META_DATA_AUTH_SUCCESS || status < 0,
+                       POLL_INTERVAL_US, val);
        if (ret) {
                dev_err(pil->dev, "MBA authentication of headers timed out\n");
        } else if (status < 0) {
@@ -762,11 +765,11 @@ static int pil_msa_mba_auth(struct pil_desc *pil)
        struct q6v5_data *q6_drv = container_of(pil, struct q6v5_data, desc);
        int ret;
        s32 status;
+       u64 val = is_timeout_disabled() ? 0 : modem_auth_timeout_ms * 1000;
 
        /* Wait for all segments to be authenticated or an error to occur */
        ret = readl_poll_timeout(drv->rmb_base + RMB_MBA_STATUS, status,
-                       status == STATUS_AUTH_COMPLETE || status < 0,
-                       50, modem_auth_timeout_ms * 1000);
+               status == STATUS_AUTH_COMPLETE || status < 0, 50, val);
        if (ret) {
                dev_err(pil->dev, "MBA authentication of image timed out\n");
        } else if (status < 0) {
index 2e52c0c..32041c1 100644 (file)
@@ -39,6 +39,8 @@
 
 #include <asm/current.h>
 
+#include "peripheral-loader.h"
+
 #define DISABLE_SSR 0x9889deed
 /* If set to 0x9889deed, call to subsystem_restart_dev() returns immediately */
 static uint disable_restart_work;
@@ -596,8 +598,8 @@ static int wait_for_err_ready(struct subsys_device *subsys)
         * If subsys is using generic_irq in which case err_ready_irq will be 0,
         * don't return.
         */
-       if ((subsys->desc->generic_irq <= 0 && !subsys->desc->err_ready_irq)
-                                                       || enable_debug == 1)
+       if ((subsys->desc->generic_irq <= 0 && !subsys->desc->err_ready_irq) ||
+                               enable_debug == 1 || is_timeout_disabled())
                return 0;
 
        ret = wait_for_completion_timeout(&subsys->err_ready,