Skip to content

Commit d8dc1b9

Browse files
xpardee-createjwrdegoede
authored andcommitted
platform/x86:intel/pmc: Add support to show S0ix blocker counter
S0ix blocker counter is available in PWRM space. Add support to read and show S0ix blocker counter value through debugfs. Signed-off-by: Xi Pardee <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 4f3eec1 commit d8dc1b9

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

drivers/platform/x86/intel/pmc/core.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,41 @@ static int pmc_core_ltr_show(struct seq_file *s, void *unused)
678678
}
679679
DEFINE_SHOW_ATTRIBUTE(pmc_core_ltr);
680680

681+
static int pmc_core_s0ix_blocker_show(struct seq_file *s, void *unused)
682+
{
683+
struct pmc_dev *pmcdev = s->private;
684+
unsigned int pmcidx;
685+
686+
for (pmcidx = 0; pmcidx < ARRAY_SIZE(pmcdev->pmcs); pmcidx++) {
687+
const struct pmc_bit_map **maps;
688+
unsigned int arr_size, r_idx;
689+
u32 offset, counter;
690+
struct pmc *pmc;
691+
692+
pmc = pmcdev->pmcs[pmcidx];
693+
if (!pmc)
694+
continue;
695+
maps = pmc->map->s0ix_blocker_maps;
696+
offset = pmc->map->s0ix_blocker_offset;
697+
arr_size = pmc_core_lpm_get_arr_size(maps);
698+
699+
for (r_idx = 0; r_idx < arr_size; r_idx++) {
700+
const struct pmc_bit_map *map;
701+
702+
for (map = maps[r_idx]; map->name; map++) {
703+
if (!map->blk)
704+
continue;
705+
counter = pmc_core_reg_read(pmc, offset);
706+
seq_printf(s, "PMC%d:%-30s %-30d\n", pmcidx,
707+
map->name, counter);
708+
offset += map->blk * S0IX_BLK_SIZE;
709+
}
710+
}
711+
}
712+
return 0;
713+
}
714+
DEFINE_SHOW_ATTRIBUTE(pmc_core_s0ix_blocker);
715+
681716
static inline u64 adjust_lpm_residency(struct pmc *pmc, u32 offset,
682717
const int lpm_adj_x2)
683718
{
@@ -1197,6 +1232,9 @@ static void pmc_core_dbgfs_register(struct pmc_dev *pmcdev)
11971232

11981233
debugfs_create_file("ltr_show", 0444, dir, pmcdev, &pmc_core_ltr_fops);
11991234

1235+
if (primary_pmc->map->s0ix_blocker_maps)
1236+
debugfs_create_file("s0ix_blocker", 0444, dir, pmcdev, &pmc_core_s0ix_blocker_fops);
1237+
12001238
debugfs_create_file("package_cstate_show", 0444, dir, primary_pmc,
12011239
&pmc_core_pkgc_fops);
12021240

drivers/platform/x86/intel/pmc/core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct telem_endpoint;
2222

2323
#define PMC_BASE_ADDR_DEFAULT 0xFE000000
2424
#define MAX_NUM_PMC 3
25+
#define S0IX_BLK_SIZE 4
2526

2627
/* Sunrise Point Power Management Controller PCI Device ID */
2728
#define SPT_PMC_PCI_DEVICE_ID 0x9d21
@@ -288,6 +289,7 @@ extern const char *pmc_lpm_modes[];
288289
struct pmc_bit_map {
289290
const char *name;
290291
u32 bit_mask;
292+
u8 blk;
291293
};
292294

293295
/**
@@ -298,6 +300,7 @@ struct pmc_bit_map {
298300
* @pll_sts: Maps name of PLL to corresponding bit status
299301
* @slps0_dbg_maps: Array of SLP_S0_DBG* registers containing debug info
300302
* @ltr_show_sts: Maps PCH IP Names to their MMIO register offsets
303+
* @s0ix_blocker_maps: Maps name of IP block to S0ix blocker counter
301304
* @slp_s0_offset: PWRMBASE offset to read SLP_S0 residency
302305
* @ltr_ignore_offset: PWRMBASE offset to read/write LTR ignore bit
303306
* @regmap_length: Length of memory to map from PWRMBASE address to access
@@ -307,6 +310,7 @@ struct pmc_bit_map {
307310
* @pm_cfg_offset: PWRMBASE offset to PM_CFG register
308311
* @pm_read_disable_bit: Bit index to read PMC_READ_DISABLE
309312
* @slps0_dbg_offset: PWRMBASE offset to SLP_S0_DEBUG_REG*
313+
* @s0ix_blocker_offset PWRMBASE offset to S0ix blocker counter
310314
*
311315
* Each PCH has unique set of register offsets and bit indexes. This structure
312316
* captures them to have a common implementation.
@@ -319,6 +323,7 @@ struct pmc_reg_map {
319323
const struct pmc_bit_map *ltr_show_sts;
320324
const struct pmc_bit_map *msr_sts;
321325
const struct pmc_bit_map **lpm_sts;
326+
const struct pmc_bit_map **s0ix_blocker_maps;
322327
const u32 slp_s0_offset;
323328
const int slp_s0_res_counter_step;
324329
const u32 ltr_ignore_offset;
@@ -330,6 +335,7 @@ struct pmc_reg_map {
330335
const u32 slps0_dbg_offset;
331336
const u32 ltr_ignore_max;
332337
const u32 pm_vric1_offset;
338+
const u32 s0ix_blocker_offset;
333339
/* Low Power Mode registers */
334340
const int lpm_num_maps;
335341
const int lpm_num_modes;

0 commit comments

Comments
 (0)