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

Commit 741c6d09 authored by Rohit Vaswani's avatar Rohit Vaswani Committed by David Keitel
Browse files

soc: qcom: msm_rtb: Add support for hotplug RTB logging



Hotplug events are particularly interesting from system
point of view and tracing around the hotplug events would
provide essential information that could be used to debug
system issues.

Currently the code exists for arm32 only. Move it into its
own file so that it can be used for arm64 as well.

Change-Id: I695aeabe8742de3599b83dbf646d6c6be627057e
Signed-off-by: default avatarRohit Vaswani <rvaswani@codeaurora.org>
Signed-off-by: default avatarDavid Keitel <dkeitel@codeaurora.org>
parent 156aa1e4
Loading
Loading
Loading
Loading
+6 −30
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@
#include <linux/smp.h>
#include <linux/cpu.h>
#include <linux/notifier.h>
#include <linux/msm_rtb.h>
#include <soc/qcom/spm.h>
#include <soc/qcom/pm.h>
#include <linux/irqchip/arm-gic.h>
@@ -100,35 +99,12 @@ void __ref msm_cpu_die(unsigned int cpu)
		pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious);
}

#define CPU_SHIFT	0
#define CPU_MASK	0xF
#define CPU_OF(n)	(((n) & CPU_MASK) << CPU_SHIFT)
#define CPUSET_SHIFT	4
#define CPUSET_MASK	0xFFFF
#define CPUSET_OF(n)	(((n) & CPUSET_MASK) << CPUSET_SHIFT)

static int hotplug_rtb_callback(struct notifier_block *nfb,
static int hotplug_dying_callback(struct notifier_block *nfb,
				unsigned long action, void *hcpu)
{
	/*
	 * Bits [19:4] of the data are the online mask, lower 4 bits are the
	 * cpu number that is being changed. Additionally, changes to the
	 * online_mask that will be done by the current hotplug will be made
	 * even though they aren't necessarily in the online mask yet.
	 *
	 * XXX: This design is limited to supporting at most 16 cpus
	 */
	int this_cpumask = CPUSET_OF(1 << (int)hcpu);
	int cpumask = CPUSET_OF(cpumask_bits(cpu_online_mask)[0]);
	int cpudata = CPU_OF((int)hcpu) | cpumask;

	switch (action & (~CPU_TASKS_FROZEN)) {
	case CPU_STARTING:
		uncached_logk(LOGK_HOTPLUG, (void *)(cpudata | this_cpumask));
		break;
	case CPU_DYING:
		cpumask_set_cpu((unsigned long)hcpu, &cpu_dying_mask);
		uncached_logk(LOGK_HOTPLUG, (void *)(cpudata & ~this_cpumask));
		break;
	default:
		break;
@@ -136,8 +112,8 @@ static int hotplug_rtb_callback(struct notifier_block *nfb,

	return NOTIFY_OK;
}
static struct notifier_block hotplug_rtb_notifier = {
	.notifier_call = hotplug_rtb_callback,
static struct notifier_block hotplug_dying_notifier = {
	.notifier_call = hotplug_dying_callback,
};

int msm_platform_secondary_init(unsigned int cpu)
@@ -158,8 +134,8 @@ int msm_platform_secondary_init(unsigned int cpu)
	return ret;
}

static int __init init_hotplug(void)
static int __init init_hotplug_dying(void)
{
	return register_hotcpu_notifier(&hotplug_rtb_notifier);
	return register_hotcpu_notifier(&hotplug_dying_notifier);
}
early_initcall(init_hotplug);
early_initcall(init_hotplug_dying);
+5 −0
Original line number Diff line number Diff line
@@ -63,6 +63,11 @@ obj-$(CONFIG_MSM_CPU_PWR_CTL) += cpu_pwr_ctl.o
obj-$(CONFIG_MSM8994_V1_PMUIRQ_WA) += cti-pmu-irq.o
obj-$(CONFIG_MSM_XPU_ERR_FATAL) += scm-xpu.o

ifdef CONFIG_MSM_RTB
	obj-y += msm_rtb-hotplug.o
endif

obj-$(CONFIG_MSM_SHARED_HEAP_ACCESS) += shared_memory.o
obj-$(CONFIG_MSM_SYSTEM_HEALTH_MONITOR) += system_health_monitor_v01.o
obj-$(CONFIG_MSM_SYSTEM_HEALTH_MONITOR) += system_health_monitor.o
obj-$(CONFIG_MSM_RTB) += msm_rtb-hotplug.o
+57 −0
Original line number Diff line number Diff line
/*
 *  Copyright (C) 2002 ARM Ltd.
 *  All Rights Reserved
 *  Copyright (c) 2011-2014, 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 as
 * published by the Free Software Foundation.
 */
#include <linux/cpu.h>
#include <linux/notifier.h>
#include <linux/msm_rtb.h>

#define CPU_SHIFT	0
#define CPU_MASK	0xF
#define CPU_OF(n)	(((n) & CPU_MASK) << CPU_SHIFT)
#define CPUSET_SHIFT	4
#define CPUSET_MASK	0xFFFF
#define CPUSET_OF(n)	(((n) & CPUSET_MASK) << CPUSET_SHIFT)

static int hotplug_rtb_callback(struct notifier_block *nfb,
				unsigned long action, void *hcpu)
{
	/*
	 * Bits [19:4] of the data are the online mask, lower 4 bits are the
	 * cpu number that is being changed. Additionally, changes to the
	 * online_mask that will be done by the current hotplug will be made
	 * even though they aren't necessarily in the online mask yet.
	 *
	 * XXX: This design is limited to supporting at most 16 cpus
	 */
	unsigned long this_cpumask = CPUSET_OF(1 << (unsigned long)hcpu);
	unsigned long cpumask = CPUSET_OF(cpumask_bits(cpu_online_mask)[0]);
	unsigned long cpudata = CPU_OF((unsigned long)hcpu) | cpumask;

	switch (action & (~CPU_TASKS_FROZEN)) {
	case CPU_STARTING:
		uncached_logk(LOGK_HOTPLUG, (void *)(cpudata | this_cpumask));
		break;
	case CPU_DYING:
		uncached_logk(LOGK_HOTPLUG, (void *)(cpudata & ~this_cpumask));
		break;
	default:
		break;
	}

	return NOTIFY_OK;
}
static struct notifier_block hotplug_rtb_notifier = {
	.notifier_call = hotplug_rtb_callback,
};

static int __init init_hotplug_rtb(void)
{
	return register_hotcpu_notifier(&hotplug_rtb_notifier);
}
early_initcall(init_hotplug_rtb);