Skip to content

Commit fb313eb

Browse files
committed
Merge: platform/x86/intel/pmc: updates
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4668 Description: platform/x86/intel/pmc: updates JIRA: https://issues.redhat.com/browse/RHEL-46817 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=62475613 Tested: Did pmc testing on Intel (intel-arrowlake-s-02) system. Signed-off-by: Steve Best <sbest@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: David Arcari <darcari@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents 1e92e82 + b349666 commit fb313eb

File tree

4 files changed

+356
-226
lines changed

4 files changed

+356
-226
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
33
* This file contains platform specific structure definitions
4-
* and init function used by Meteor Lake PCH.
4+
* and init function used by Arrow Lake PCH.
55
*
66
* Copyright (c) 2022, Intel Corporation.
77
* All Rights Reserved.
@@ -673,13 +673,15 @@ static struct pmc_info arl_pmc_info_list[] = {
673673
};
674674

675675
#define ARL_NPU_PCI_DEV 0xad1d
676+
#define ARL_GNA_PCI_DEV 0xae4c
676677
/*
677678
* Set power state of select devices that do not have drivers to D3
678679
* so that they do not block Package C entry.
679680
*/
680681
static void arl_d3_fixup(void)
681682
{
682683
pmc_core_set_device_d3(ARL_NPU_PCI_DEV);
684+
pmc_core_set_device_d3(ARL_GNA_PCI_DEV);
683685
}
684686

685687
static int arl_resume(struct pmc_dev *pmcdev)

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

Lines changed: 74 additions & 11 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

@@ -1389,6 +1427,15 @@ static int pmc_core_probe(struct platform_device *pdev)
13891427
return -ENOMEM;
13901428
pmcdev->pmcs[PMC_IDX_MAIN] = primary_pmc;
13911429

1430+
/* The last element in msr_map is empty */
1431+
pmcdev->num_of_pkgc = ARRAY_SIZE(msr_map) - 1;
1432+
pmcdev->pkgc_res_cnt = devm_kcalloc(&pdev->dev,
1433+
pmcdev->num_of_pkgc,
1434+
sizeof(*pmcdev->pkgc_res_cnt),
1435+
GFP_KERNEL);
1436+
if (!pmcdev->pkgc_res_cnt)
1437+
return -ENOMEM;
1438+
13921439
/*
13931440
* Coffee Lake has CPU ID of Kaby Lake and Cannon Lake PCH. So here
13941441
* Sunrisepoint PCH regmap can't be used. Use Cannon Lake PCH regmap
@@ -1432,6 +1479,7 @@ static __maybe_unused int pmc_core_suspend(struct device *dev)
14321479
{
14331480
struct pmc_dev *pmcdev = dev_get_drvdata(dev);
14341481
struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN];
1482+
unsigned int i;
14351483

14361484
if (pmcdev->suspend)
14371485
pmcdev->suspend(pmcdev);
@@ -1440,9 +1488,11 @@ static __maybe_unused int pmc_core_suspend(struct device *dev)
14401488
if (pm_suspend_via_firmware())
14411489
return 0;
14421490

1443-
/* Save PC10 residency for checking later */
1444-
if (rdmsrl_safe(MSR_PKG_C10_RESIDENCY, &pmcdev->pc10_counter))
1445-
return -EIO;
1491+
/* Save PKGC residency for checking later */
1492+
for (i = 0; i < pmcdev->num_of_pkgc; i++) {
1493+
if (rdmsrl_safe(msr_map[i].bit_mask, &pmcdev->pkgc_res_cnt[i]))
1494+
return -EIO;
1495+
}
14461496

14471497
/* Save S0ix residency for checking later */
14481498
if (pmc_core_dev_state_get(pmc, &pmcdev->s0ix_counter))
@@ -1451,14 +1501,15 @@ static __maybe_unused int pmc_core_suspend(struct device *dev)
14511501
return 0;
14521502
}
14531503

1454-
static inline bool pmc_core_is_pc10_failed(struct pmc_dev *pmcdev)
1504+
static inline bool pmc_core_is_deepest_pkgc_failed(struct pmc_dev *pmcdev)
14551505
{
1456-
u64 pc10_counter;
1506+
u32 deepest_pkgc_msr = msr_map[pmcdev->num_of_pkgc - 1].bit_mask;
1507+
u64 deepest_pkgc_residency;
14571508

1458-
if (rdmsrl_safe(MSR_PKG_C10_RESIDENCY, &pc10_counter))
1509+
if (rdmsrl_safe(deepest_pkgc_msr, &deepest_pkgc_residency))
14591510
return false;
14601511

1461-
if (pc10_counter == pmcdev->pc10_counter)
1512+
if (deepest_pkgc_residency == pmcdev->pkgc_res_cnt[pmcdev->num_of_pkgc - 1])
14621513
return true;
14631514

14641515
return false;
@@ -1497,10 +1548,22 @@ int pmc_core_resume_common(struct pmc_dev *pmcdev)
14971548
if (!warn_on_s0ix_failures)
14981549
return 0;
14991550

1500-
if (pmc_core_is_pc10_failed(pmcdev)) {
1501-
/* S0ix failed because of PC10 entry failure */
1502-
dev_info(dev, "CPU did not enter PC10!!! (PC10 cnt=0x%llx)\n",
1503-
pmcdev->pc10_counter);
1551+
if (pmc_core_is_deepest_pkgc_failed(pmcdev)) {
1552+
/* S0ix failed because of deepest PKGC entry failure */
1553+
dev_info(dev, "CPU did not enter %s!!! (%s cnt=0x%llx)\n",
1554+
msr_map[pmcdev->num_of_pkgc - 1].name,
1555+
msr_map[pmcdev->num_of_pkgc - 1].name,
1556+
pmcdev->pkgc_res_cnt[pmcdev->num_of_pkgc - 1]);
1557+
1558+
for (i = 0; i < pmcdev->num_of_pkgc; i++) {
1559+
u64 pc_cnt;
1560+
1561+
if (!rdmsrl_safe(msr_map[i].bit_mask, &pc_cnt)) {
1562+
dev_info(dev, "Prev %s cnt = 0x%llx, Current %s cnt = 0x%llx\n",
1563+
msr_map[i].name, pmcdev->pkgc_res_cnt[i],
1564+
msr_map[i].name, pc_cnt);
1565+
}
1566+
}
15041567
return 0;
15051568
}
15061569

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

Lines changed: 14 additions & 2 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
@@ -282,12 +283,14 @@ enum ppfear_regs {
282283
#define LNL_PMC_LTR_OSSE 0x1B88
283284
#define LNL_NUM_IP_IGN_ALLOWED 27
284285
#define LNL_PPFEAR_NUM_ENTRIES 12
286+
#define LNL_S0IX_BLOCKER_OFFSET 0x2004
285287

286288
extern const char *pmc_lpm_modes[];
287289

288290
struct pmc_bit_map {
289291
const char *name;
290292
u32 bit_mask;
293+
u8 blk;
291294
};
292295

293296
/**
@@ -298,6 +301,7 @@ struct pmc_bit_map {
298301
* @pll_sts: Maps name of PLL to corresponding bit status
299302
* @slps0_dbg_maps: Array of SLP_S0_DBG* registers containing debug info
300303
* @ltr_show_sts: Maps PCH IP Names to their MMIO register offsets
304+
* @s0ix_blocker_maps: Maps name of IP block to S0ix blocker counter
301305
* @slp_s0_offset: PWRMBASE offset to read SLP_S0 residency
302306
* @ltr_ignore_offset: PWRMBASE offset to read/write LTR ignore bit
303307
* @regmap_length: Length of memory to map from PWRMBASE address to access
@@ -307,6 +311,7 @@ struct pmc_bit_map {
307311
* @pm_cfg_offset: PWRMBASE offset to PM_CFG register
308312
* @pm_read_disable_bit: Bit index to read PMC_READ_DISABLE
309313
* @slps0_dbg_offset: PWRMBASE offset to SLP_S0_DEBUG_REG*
314+
* @s0ix_blocker_offset PWRMBASE offset to S0ix blocker counter
310315
*
311316
* Each PCH has unique set of register offsets and bit indexes. This structure
312317
* captures them to have a common implementation.
@@ -319,6 +324,7 @@ struct pmc_reg_map {
319324
const struct pmc_bit_map *ltr_show_sts;
320325
const struct pmc_bit_map *msr_sts;
321326
const struct pmc_bit_map **lpm_sts;
327+
const struct pmc_bit_map **s0ix_blocker_maps;
322328
const u32 slp_s0_offset;
323329
const int slp_s0_res_counter_step;
324330
const u32 ltr_ignore_offset;
@@ -330,6 +336,7 @@ struct pmc_reg_map {
330336
const u32 slps0_dbg_offset;
331337
const u32 ltr_ignore_max;
332338
const u32 pm_vric1_offset;
339+
const u32 s0ix_blocker_offset;
333340
/* Low Power Mode registers */
334341
const int lpm_num_maps;
335342
const int lpm_num_modes;
@@ -385,7 +392,8 @@ struct pmc {
385392
* @pmc_xram_read_bit: flag to indicate whether PMC XRAM shadow registers
386393
* used to read MPHY PG and PLL status are available
387394
* @mutex_lock: mutex to complete one transcation
388-
* @pc10_counter: PC10 residency counter
395+
* @pkgc_res_cnt: Array of PKGC residency counters
396+
* @num_of_pkgc: Number of PKGC
389397
* @s0ix_counter: S0ix residency (step adjusted)
390398
* @num_lpm_modes: Count of enabled modes
391399
* @lpm_en_modes: Array of enabled modes from lowest to highest priority
@@ -403,13 +411,15 @@ struct pmc_dev {
403411
int pmc_xram_read_bit;
404412
struct mutex lock; /* generic mutex lock for PMC Core */
405413

406-
u64 pc10_counter;
407414
u64 s0ix_counter;
408415
int num_lpm_modes;
409416
int lpm_en_modes[LPM_MAX_NUM_MODES];
410417
void (*suspend)(struct pmc_dev *pmcdev);
411418
int (*resume)(struct pmc_dev *pmcdev);
412419

420+
u64 *pkgc_res_cnt;
421+
u8 num_of_pkgc;
422+
413423
bool has_die_c6;
414424
u32 die_c6_offset;
415425
struct telem_endpoint *punit_ep;
@@ -532,8 +542,10 @@ extern const struct pmc_bit_map lnl_vnn_req_status_2_map[];
532542
extern const struct pmc_bit_map lnl_vnn_req_status_3_map[];
533543
extern const struct pmc_bit_map lnl_vnn_misc_status_map[];
534544
extern const struct pmc_bit_map *lnl_lpm_maps[];
545+
extern const struct pmc_bit_map *lnl_blk_maps[];
535546
extern const struct pmc_bit_map lnl_pfear_map[];
536547
extern const struct pmc_bit_map *ext_lnl_pfear_map[];
548+
extern const struct pmc_bit_map lnl_signal_status_map[];
537549

538550
/* ARL */
539551
extern const struct pmc_bit_map arl_socs_ltr_show_map[];

0 commit comments

Comments
 (0)