Skip to contentSkip to conversation

x86: punit_atom: punit device state debug driver

PATCH Superseded Srinivas Pandruvada 2 participants 3 messages May 4, 2015

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86: punit_atom: punit device state debug driver

v2
Addressed Ingo Molnar's comments
- Fix commit message
- Added punit explanation
- Formatting comments
- Moved to arch/x86/platform/intel_mid
- changed the debugfs file name

v1
Based on review comments
- Changed to tristate instead of bool
- Moved config to kconfig.debug
- Added debug in module name
- Returning -ENXIO on debugfs file create error

v0:
Base version

Srinivas Pandruvada (1):
x86: punit_atom: punit device state debug driver

 arch/x86/Kconfig.debug                         |   9 ++
 arch/x86/platform/intel-mid/Makefile           |   2 +
 arch/x86/platform/intel-mid/punit_atom_debug.c | 185 +++++++++++++++++++++++++
 3 files changed, 196 insertions(+)
 create mode 100644 arch/x86/platform/intel-mid/punit_atom_debug.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/1 x86: punit_atom: punit device state debug driver

The patch adds a debug driver, which dumps the power states of all the North complex (NC) devices. This debug interface is useful to figure out the devices, which blocks the S0ix transitions on the platform. This is extremely useful during enabling PM on customer platforms and derivatives.

This submission is based on the submission from
Kumar P, Mahesh <mahesh.kumar.p.intel.com>.
https://lkml.org/lkml/2014/11/5/367
The changes done on top of the above submission:
- Dropped changes to config for PMC_ATOM, as PMC_ATOM is not just a debug driver as suggested by the change. It has additional power off interface also.
- Instead of just using nc ("North complex") use punit_.. similar to south complex PMC.
- Removed pmc_config structure, as we don't need to predefine number of register, we want to dump. This way new register can be added without changing NC_NUM_DEVICES.
- prefixed function with punit_
- The debugfs directory will be punit_atom, which is NC equivalent of pmc_atom, which we already exposed by pmc_atom driver.
- Added explanation for register and shift defines
- Will not create debugfs if the cpuid doesn't match
- Formatting changes to match compliance to coding convention
- Address review comments

---
 arch/x86/Kconfig.debug                         |   9 ++
 arch/x86/platform/intel-mid/Makefile           |   2 +
 arch/x86/platform/intel-mid/punit_atom_debug.c | 185 +++++++++++++++++++++++++
 3 files changed, 196 insertions(+)
 create mode 100644 arch/x86/platform/intel-mid/punit_atom_debug.c
arch/x86/Kconfig.debug +9 -0
index 20028da..4f42c3a 100644
@@ -336,4 +336,13 @@ config X86_DEBUG_STATIC_CPU_HAS
 
 	  If unsure, say N.
 
+config PUNIT_ATOM_DEBUG
+	tristate "ATOM Punit debug driver"
+	depends on DEBUG_FS
+	select IOSF_MBI
+	---help---
+	  This is a debug driver, which gets the power states
+	  of all Punit North Complex devices. The power states of
+	  each device is exposed as part of the debugfs interface.
+
 endmenu
arch/x86/platform/intel-mid/Makefile +2 -0
index 0a8ee70..4763952 100644
@@ -5,3 +5,5 @@ obj-$(CONFIG_EARLY_PRINTK_INTEL_MID) += early_printk_intel_mid.o
 ifdef CONFIG_X86_INTEL_MID
 obj-$(CONFIG_SFI) += sfi.o device_libs/
 endif
+
+obj-$(CONFIG_PUNIT_ATOM_DEBUG) += punit_atom_debug.o
arch/x86/platform/intel-mid/punit_atom_debug.c new file +185 -0

185 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

arch/x86/platform/intel-mid/punit_atom_debug.c line 57

Quoted 7 lines · Srinivas Pandruvada
arch/x86/platform/intel-mid/punit_atom_debug.c new file +7 -0
+struct punit_device {
+	char *name;
+	int reg;
+	int sss_pos;
+};
+
+static struct punit_device *punit_device;

So this pointer gets initialized in punit_atom_debug_init() and points either to punit_device_byt or punit_device_cht.

Quoted 2 lines
(quoted diff) +2 -0
+static const struct punit_device punit_device_byt[] = {
+	{ "GFX RENDER",	PWRGT_STATUS,	RENDER_POS },

...

Quoted 13 lines
arch/x86/platform/intel-mid/punit_atom_debug.c new file +12 -0
+	{ NULL }
+};
 
+static int punit_dev_state_show(struct seq_file *seq_file, void *unused)
+{
+	u32 punit_pwr_status;
+	int index;
+	int status;
+
+	seq_puts(seq_file, "\n\nPUNIT NORTH COMPLEX DEVICES :\n");
+	while (punit_device->name) {
+		status = iosf_mbi_read(PUNIT_PORT, BT_MBI_PMC_READ,
+				       punit_device->reg,

arch/x86/platform/intel-mid/punit_atom_debug.c line 100

Quoted 10 lines
arch/x86/platform/intel-mid/punit_atom_debug.c new file +10 -0
+				       &punit_pwr_status);
+		if (status)
+			seq_printf(seq_file, "%9s : Read Failed\n",
+				   punit_device->name);
+		else  {
+			index = (punit_pwr_status >> punit_device->sss_pos) & 3;
+			seq_printf(seq_file, "%9s : %s\n", punit_device->name,
+				   dstates[index]);
+		}
+		punit_device++;

So you happily increment the above pointer. So after the first readout of that debug file the pointer will point to the end of that table. And any further readouts will simply fail.

Completely useless and untested crap.

Thanks,

tglx