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

Commit 3e576089 authored by Aparna Das's avatar Aparna Das Committed by Gerrit - the friendly Code Review server
Browse files

coresight: get etm funnel port for associated cpu



Add support to retrieve CoreSight ETM funnel port for the CPU
associated with the ETM device to allow enabling and disabling
the correct funnel port to prevent trace flush hang during power
collapse.

Signed-off-by: default avatarAparna Das <adas@codeaurora.org>
Change-Id: I880881b5d4de4bf1947e5316eb1ad624176516dd
parent bb6f7a93
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1920,6 +1920,20 @@ static const struct attribute_group *etm_attr_grps[] = {
	NULL,
};

int coresight_etm_get_funnel_port(int cpu)
{
	struct coresight_platform_data *pdata;

	if (cpu > num_possible_cpus())
		return -EINVAL;
	if (!etmdrvdata[cpu])
		return -ENODEV;

	pdata = etmdrvdata[cpu]->dev->platform_data;
	return pdata->child_ports[0];
}
EXPORT_SYMBOL(coresight_etm_get_funnel_port);

static bool etm_arch_supported(uint8_t arch)
{
	switch (arch) {
+14 −0
Original line number Diff line number Diff line
@@ -2913,6 +2913,20 @@ static const struct attribute_group *etm_attr_grps[] = {
	NULL,
};

int coresight_etm_get_funnel_port(int cpu)
{
	struct coresight_platform_data *pdata;

	if (cpu > num_possible_cpus())
		return -EINVAL;
	if (!etmdrvdata[cpu])
		return -ENODEV;

	pdata = etmdrvdata[cpu]->dev->platform_data;
	return pdata->child_ports[0];
}
EXPORT_SYMBOL(coresight_etm_get_funnel_port);

static void etm_init_arch_data(void *info)
{
	uint32_t etmidr0;
+18 −4
Original line number Diff line number Diff line
@@ -111,12 +111,19 @@ static int funnel_enable_cpu_port(struct notifier_block *this,
	struct funnel_drvdata *drvdata = container_of(this,
						      struct funnel_drvdata,
						      jtag_restore_blk);
	int port;
	int cpu = raw_smp_processor_id();

	port = coresight_etm_get_funnel_port(cpu);
	if (port < 0) {
		pr_warn_ratelimited("error retrieving ETM funnel port: %#x\n",
				     port);
		return notifier_from_errno(port);
	}
	spin_lock(&drvdata->spinlock);
	if (!test_bit(cpu, drvdata->inport))
	if (!test_bit(port, drvdata->inport))
		goto out;
	__funnel_enable(drvdata, cpu);
	__funnel_enable(drvdata, port);
out:
	spin_unlock(&drvdata->spinlock);
	return NOTIFY_OK;
@@ -156,12 +163,19 @@ static int funnel_disable_cpu_port(struct notifier_block *this,
	struct funnel_drvdata *drvdata = container_of(this,
						      struct funnel_drvdata,
						      jtag_save_blk);
	int port;
	int cpu = raw_smp_processor_id();

	port = coresight_etm_get_funnel_port(cpu);
	if (port < 0) {
		pr_warn_ratelimited("error retrieving ETM funnel port: %#x\n",
				     port);
		return notifier_from_errno(port);
	}
	spin_lock(&drvdata->spinlock);
	if (!test_bit(cpu, drvdata->inport))
	if (!test_bit(port, drvdata->inport))
		goto out;
	__funnel_disable(drvdata, cpu);
	__funnel_disable(drvdata, port);
out:
	spin_unlock(&drvdata->spinlock);
	return NOTIFY_OK;
+5 −0
Original line number Diff line number Diff line
@@ -68,5 +68,10 @@ extern void etm_writel_cp14(uint32_t val, uint32_t off);
static inline unsigned int etm_readl_cp14(uint32_t off) { return 0; }
static inline void etm_writel_cp14(uint32_t val, uint32_t off) {}
#endif
#if defined(CONFIG_CORESIGHT_ETM) || defined(CONFIG_CORESIGHT_ETMV4)
extern int coresight_etm_get_funnel_port(int cpu);
#else
static inline int coresight_etm_get_funnel_port(int cpu) { return -ENOSYS; }
#endif

#endif