Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fde2817e authored by Chandra Sai Chidipudi's avatar Chandra Sai Chidipudi Committed by Gerrit - the friendly Code Review server
Browse files

soc: qcom: Guard minidump code with #ifdef



Minidump is not supported in some devices.
Protect the minidump code with #ifdef macro.

Change-Id: Ie0366d7ee7338069186c21947a89a0f6c40eeaae
Signed-off-by: default avatarChandra Sai Chidipudi <cchidipu@codeaurora.org>
parent 422e6ccb
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
/* Copyright (c) 2010-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2010-2020, 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
@@ -71,11 +71,14 @@


static void __iomem *pil_info_base;
#ifdef CONFIG_QCOM_MINIDUMP
static void __iomem *minidump_debug;
static struct md_global_toc *g_md_toc;
#endif

void *pil_ipc_log;

#ifdef CONFIG_QCOM_MINIDUMP
static void __iomem *map_prop(const char *propname)
{
	struct device_node *np = of_find_compatible_node(NULL, NULL, propname);
@@ -92,6 +95,7 @@ static void __iomem *map_prop(const char *propname)

	return addr;
}
#endif

/**
 * proxy_timeout - Override for proxy vote timeouts
@@ -176,6 +180,7 @@ struct pil_priv {
	size_t region_size;
};

#ifdef CONFIG_QCOM_MINIDUMP
/**
 * struct aux_minidumpinfo - State maintained for each aux minidump entry dumped
 * during SSR
@@ -465,6 +470,7 @@ static void print_aux_minidump_tocs(struct pil_desc *desc)
			 (unsigned int)toc->md_ss_smem_regions_baseptr);
	}
}
#endif

/**
 * pil_do_ramdump() - Ramdump an image
@@ -482,6 +488,7 @@ int pil_do_ramdump(struct pil_desc *desc,
	struct pil_seg *seg;
	int count = 0, ret;

#ifdef CONFIG_QCOM_MINIDUMP
	if (desc->minidump_ss) {
		pr_debug("Minidump : md_ss_toc->md_ss_toc_init is 0x%x\n",
			(unsigned int)desc->minidump_ss->md_ss_toc_init);
@@ -519,6 +526,7 @@ int pil_do_ramdump(struct pil_desc *desc,
		}
	}
	pr_debug("Continuing with full SSR dump for %s\n", desc->name);
#endif
	list_for_each_entry(seg, &priv->segs, list)
		count++;

@@ -1495,6 +1503,7 @@ bool is_timeout_disabled(void)
	return disable_timeouts;
}

#ifdef CONFIG_QCOM_MINIDUMP
static int collect_aux_minidump_ids(struct pil_desc *desc)
{
	u32 id;
@@ -1537,6 +1546,7 @@ static int collect_aux_minidump_ids(struct pil_desc *desc)

	return 0;
}
#endif

/**
 * pil_desc_init() - Initialize a pil descriptor
@@ -1551,10 +1561,12 @@ int pil_desc_init(struct pil_desc *desc)
{
	struct pil_priv *priv;
	void __iomem *addr;
	void *ss_toc_addr;
	int ret;
	char buf[sizeof(priv->info->name)];
#ifdef CONFIG_QCOM_MINIDUMP
	void *ss_toc_addr;
	struct device_node *ofnode = desc->dev->of_node;
#endif

	if (WARN(desc->ops->proxy_unvote && !desc->ops->proxy_vote,
				"Invalid proxy voting. Ignoring\n"))
@@ -1577,6 +1589,8 @@ int pil_desc_init(struct pil_desc *desc)
		strlcpy(buf, desc->name, sizeof(buf));
		__iowrite32_copy(priv->info->name, buf, sizeof(buf) / 4);
	}

#ifdef CONFIG_QCOM_MINIDUMP
	if (of_property_read_u32(ofnode, "qcom,minidump-id",
		&desc->minidump_id))
		pr_err("minidump-id not found for %s\n", desc->name);
@@ -1593,6 +1607,7 @@ int pil_desc_init(struct pil_desc *desc)
				       desc->name);
		}
	}
#endif

	ret = pil_parse_devicetree(desc);
	if (ret)
@@ -1630,15 +1645,19 @@ int pil_desc_init(struct pil_desc *desc)
	if (!desc->unmap_fw_mem)
		desc->unmap_fw_mem = unmap_fw_mem;

#ifdef CONFIG_QCOM_MINIDUMP
	desc->minidump_as_elf32 = of_property_read_bool(
					ofnode, "qcom,minidump-as-elf32");
#endif

	return 0;
err_parse_dt:
	ida_simple_remove(&pil_ida, priv->id);
err:
#ifdef CONFIG_QCOM_MINIDUMP
	kfree(desc->aux_minidump);
	kfree(desc->aux_minidump_ids);
#endif
	kfree(priv);
	return ret;
}
@@ -1684,7 +1703,9 @@ static int __init msm_pil_init(void)
	struct device_node *np;
	struct resource res;
	int i;
#ifdef CONFIG_QCOM_MINIDUMP
	size_t size;
#endif

	np = of_find_compatible_node(NULL, NULL, "qcom,msm-imem-pil");
	if (!np) {
@@ -1707,6 +1728,7 @@ static int __init msm_pil_init(void)
	for (i = 0; i < resource_size(&res)/sizeof(u32); i++)
		writel_relaxed(0, pil_info_base + (i * sizeof(u32)));

#ifdef CONFIG_QCOM_MINIDUMP
	/* Get Global minidump ToC*/
	g_md_toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID,
				 &size);
@@ -1717,6 +1739,7 @@ static int __init msm_pil_init(void)
	}

	minidump_debug = map_prop(MINIDUMP_DEBUG_PROP);
#endif

	pil_wq = alloc_workqueue("pil_workqueue", WQ_HIGHPRI | WQ_UNBOUND, 0);
	if (!pil_wq)
@@ -1737,8 +1760,11 @@ static void __exit msm_pil_exit(void)
	unregister_pm_notifier(&pil_pm_notifier);
	if (pil_info_base)
		iounmap(pil_info_base);

#ifdef CONFIG_QCOM_MINIDUMP
	if (minidump_debug)
		iounmap(minidump_debug);
#endif
}
module_exit(msm_pil_exit);

+3 −1
Original line number Diff line number Diff line
/* Copyright (c) 2010-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2010-2020, 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
@@ -74,12 +74,14 @@ struct pil_desc {
	bool signal_aop;
	struct mbox_client cl;
	struct mbox_chan *mbox;
#ifdef CONFIG_QCOM_MINIDUMP
	struct md_ss_toc *minidump_ss;
	struct md_ss_toc **aux_minidump;
	int minidump_id;
	int *aux_minidump_ids;
	int num_aux_minidump_ids;
	bool minidump_as_elf32;
#endif
};

/**
+14 −3
Original line number Diff line number Diff line
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2020, 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
@@ -302,8 +302,10 @@ static int pil_msa_wait_for_mba_ready(struct q6v5_data *drv)
	u32 status;
	u64 val;

#ifdef CONFIG_QCOM_MINIDUMP
	if (of_property_read_bool(dev->of_node, "qcom,minidump-id"))
		pbl_mba_boot_timeout_ms = MBA_ENCRYPTION_TIMEOUT;
#endif

	val = is_timeout_disabled() ? 0 : pbl_mba_boot_timeout_ms * 1000;

@@ -567,6 +569,7 @@ static int pil_mss_reset(struct pil_desc *pil)
	struct q6v5_data *drv = container_of(pil, struct q6v5_data, desc);
	phys_addr_t start_addr = pil_get_entry_addr(pil);
	u32 debug_val = 0;
	bool minidump_ss;
	int ret;

	trace_pil_func(__func__);
@@ -585,7 +588,13 @@ static int pil_mss_reset(struct pil_desc *pil)
	if (ret)
		goto err_clks;

	if (!pil->minidump_ss || !pil->modem_ssr) {
	minidump_ss = true;
#ifdef CONFIG_QCOM_MINIDUMP
	if (pil->minidump_ss)
		minidump_ss = false;
#endif

	if (minidump_ss || !pil->modem_ssr) {
		/* Save state of modem debug register before full reset */
		debug_val = readl_relaxed(drv->reg_base + QDSP6SS_DBG_CFG);
	}
@@ -598,7 +607,7 @@ static int pil_mss_reset(struct pil_desc *pil)
	if (ret)
		goto err_restart;

	if (!pil->minidump_ss || !pil->modem_ssr) {
	if (minidump_ss || !pil->modem_ssr) {
		writel_relaxed(debug_val, drv->reg_base + QDSP6SS_DBG_CFG);
		if (modem_dbg_cfg)
			writel_relaxed(modem_dbg_cfg,
@@ -797,6 +806,7 @@ int pil_mss_reset_load_mba(struct pil_desc *pil)
	return ret;
}

#ifdef CONFIG_QCOM_MINIDUMP
int pil_mss_debug_reset(struct pil_desc *pil)
{
	struct q6v5_data *drv = container_of(pil, struct q6v5_data, desc);
@@ -859,6 +869,7 @@ int pil_mss_debug_reset(struct pil_desc *pil)
		clk_disable_unprepare(drv->ahb_clk);
	return ret;
}
#endif

static int pil_msa_auth_modem_mdt(struct pil_desc *pil, const u8 *metadata,
				  size_t size)
+5 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2020, 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
@@ -22,7 +22,9 @@ struct modem_data {
	struct subsys_device *subsys;
	struct subsys_desc subsys_desc;
	void *ramdump_dev;
#ifdef CONFIG_QCOM_MINIDUMP
	void *minidump_dev;
#endif
	bool crash_shutdown;
	u32 pas_id;
	bool ignore_errors;
@@ -47,5 +49,7 @@ int pil_mss_deinit_image(struct pil_desc *pil);
int __pil_mss_deinit_image(struct pil_desc *pil, bool err_path);
int pil_mss_assert_resets(struct q6v5_data *drv);
int pil_mss_deassert_resets(struct q6v5_data *drv);
#ifdef CONFIG_QCOM_MINIDUMP
int pil_mss_debug_reset(struct pil_desc *pil);
#endif
#endif
+15 −2
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2020, 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
@@ -185,9 +185,11 @@ static int modem_ramdump(int enable, const struct subsys_desc *subsys)
	if (ret)
		return ret;

#ifdef CONFIG_QCOM_MINIDUMP
	ret = pil_mss_debug_reset(&drv->q6->desc);
	if (ret)
		return ret;
#endif

	pil_mss_remove_proxy_votes(&drv->q6->desc);
	ret = pil_mss_make_proxy_votes(&drv->q6->desc);
@@ -198,8 +200,13 @@ static int modem_ramdump(int enable, const struct subsys_desc *subsys)
	if (ret)
		return ret;

#ifdef CONFIG_QCOM_MINIDUMP
	ret = pil_do_ramdump(&drv->q6->desc,
			drv->ramdump_dev, drv->minidump_dev);
#else
	ret = pil_do_ramdump(&drv->q6->desc,
			drv->ramdump_dev, NULL);
#endif
	if (ret < 0)
		pr_err("Unable to dump modem fw memory (rc = %d).\n", ret);

@@ -283,6 +290,8 @@ static int pil_subsys_init(struct modem_data *drv,
		ret = -ENOMEM;
		goto err_ramdump;
	}

#ifdef CONFIG_QCOM_MINIDUMP
	drv->minidump_dev = create_ramdump_device("md_modem", &pdev->dev);
	if (!drv->minidump_dev) {
		pr_err("%s: Unable to create a modem minidump device.\n",
@@ -290,11 +299,13 @@ static int pil_subsys_init(struct modem_data *drv,
		ret = -ENOMEM;
		goto err_minidump;
	}

#endif
	return 0;

#ifdef CONFIG_QCOM_MINIDUMP
err_minidump:
	destroy_ramdump_device(drv->ramdump_dev);
#endif
err_ramdump:
	subsys_unregister(drv->subsys);
err_subsys:
@@ -485,7 +496,9 @@ static int pil_mss_driver_exit(struct platform_device *pdev)

	subsys_unregister(drv->subsys);
	destroy_ramdump_device(drv->ramdump_dev);
#ifdef CONFIG_QCOM_MINIDUMP
	destroy_ramdump_device(drv->minidump_dev);
#endif
	pil_desc_release(&drv->q6->desc);
	return 0;
}
Loading