Skip to content

Commit 3f0b3e6

Browse files
committed
platform/x86:intel/pmc: Improve pmc_core_get_lpm_req()
JIRA: https://issues.redhat.com/browse/RHEL-110838 commit a59211e Author: Xi Pardee <xi.pardee@linux.intel.com> Date: Fri Apr 25 12:52:33 2025 -0700 platform/x86:intel/pmc: Improve pmc_core_get_lpm_req() Minor improvements on pmc_core_get_lpm_req(). 1. Move the long comment to be above the function 2. Use %pe to print error pointer 3. Remove unneeded devm_kfree call These changes improves the code maintainability. Signed-off-by: Xi Pardee <xi.pardee@linux.intel.com> Link: https://lore.kernel.org/r/20250425195237.493129-6-xi.pardee@linux.intel.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Steve Best <sbest@redhat.com>
1 parent 2a3351d commit 3f0b3e6

File tree

1 file changed

+45
-46
lines changed
  • drivers/platform/x86/intel/pmc

1 file changed

+45
-46
lines changed

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

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,50 @@ static u32 pmc_core_find_guid(struct pmc_info *list, const struct pmc_reg_map *m
13551355
return 0;
13561356
}
13571357

1358+
/*
1359+
* This function retrieves low power mode requirement data from PMC Low
1360+
* Power Mode (LPM) table.
1361+
*
1362+
* In telemetry space, the LPM table contains a 4 byte header followed
1363+
* by 8 consecutive mode blocks (one for each LPM mode). Each block
1364+
* has a 4 byte header followed by a set of registers that describe the
1365+
* IP state requirements for the given mode. The IP mapping is platform
1366+
* specific but the same for each block, making for easy analysis.
1367+
* Platforms only use a subset of the space to track the requirements
1368+
* for their IPs. Callers provide the requirement registers they use as
1369+
* a list of indices. Each requirement register is associated with an
1370+
* IP map that's maintained by the caller.
1371+
*
1372+
* Header
1373+
* +----+----------------------------+----------------------------+
1374+
* | 0 | REVISION | ENABLED MODES |
1375+
* +----+--------------+-------------+-------------+--------------+
1376+
*
1377+
* Low Power Mode 0 Block
1378+
* +----+--------------+-------------+-------------+--------------+
1379+
* | 1 | SUB ID | SIZE | MAJOR | MINOR |
1380+
* +----+--------------+-------------+-------------+--------------+
1381+
* | 2 | LPM0 Requirements 0 |
1382+
* +----+---------------------------------------------------------+
1383+
* | | ... |
1384+
* +----+---------------------------------------------------------+
1385+
* | 29 | LPM0 Requirements 27 |
1386+
* +----+---------------------------------------------------------+
1387+
*
1388+
* ...
1389+
*
1390+
* Low Power Mode 7 Block
1391+
* +----+--------------+-------------+-------------+--------------+
1392+
* | | SUB ID | SIZE | MAJOR | MINOR |
1393+
* +----+--------------+-------------+-------------+--------------+
1394+
* | 60 | LPM7 Requirements 0 |
1395+
* +----+---------------------------------------------------------+
1396+
* | | ... |
1397+
* +----+---------------------------------------------------------+
1398+
* | 87 | LPM7 Requirements 27 |
1399+
* +----+---------------------------------------------------------+
1400+
*
1401+
*/
13581402
static int pmc_core_get_lpm_req(struct pmc_dev *pmcdev, struct pmc *pmc, struct pci_dev *pcidev)
13591403
{
13601404
struct telem_endpoint *ep;
@@ -1374,8 +1418,7 @@ static int pmc_core_get_lpm_req(struct pmc_dev *pmcdev, struct pmc *pmc, struct
13741418

13751419
ep = pmt_telem_find_and_register_endpoint(pcidev, guid, 0);
13761420
if (IS_ERR(ep)) {
1377-
dev_dbg(&pmcdev->pdev->dev, "couldn't get telem endpoint %ld",
1378-
PTR_ERR(ep));
1421+
dev_dbg(&pmcdev->pdev->dev, "couldn't get telem endpoint %pe", ep);
13791422
return -EPROBE_DEFER;
13801423
}
13811424

@@ -1387,49 +1430,6 @@ static int pmc_core_get_lpm_req(struct pmc_dev *pmcdev, struct pmc *pmc, struct
13871430
goto unregister_ep;
13881431
}
13891432

1390-
/*
1391-
* PMC Low Power Mode (LPM) table
1392-
*
1393-
* In telemetry space, the LPM table contains a 4 byte header followed
1394-
* by 8 consecutive mode blocks (one for each LPM mode). Each block
1395-
* has a 4 byte header followed by a set of registers that describe the
1396-
* IP state requirements for the given mode. The IP mapping is platform
1397-
* specific but the same for each block, making for easy analysis.
1398-
* Platforms only use a subset of the space to track the requirements
1399-
* for their IPs. Callers provide the requirement registers they use as
1400-
* a list of indices. Each requirement register is associated with an
1401-
* IP map that's maintained by the caller.
1402-
*
1403-
* Header
1404-
* +----+----------------------------+----------------------------+
1405-
* | 0 | REVISION | ENABLED MODES |
1406-
* +----+--------------+-------------+-------------+--------------+
1407-
*
1408-
* Low Power Mode 0 Block
1409-
* +----+--------------+-------------+-------------+--------------+
1410-
* | 1 | SUB ID | SIZE | MAJOR | MINOR |
1411-
* +----+--------------+-------------+-------------+--------------+
1412-
* | 2 | LPM0 Requirements 0 |
1413-
* +----+---------------------------------------------------------+
1414-
* | | ... |
1415-
* +----+---------------------------------------------------------+
1416-
* | 29 | LPM0 Requirements 27 |
1417-
* +----+---------------------------------------------------------+
1418-
*
1419-
* ...
1420-
*
1421-
* Low Power Mode 7 Block
1422-
* +----+--------------+-------------+-------------+--------------+
1423-
* | | SUB ID | SIZE | MAJOR | MINOR |
1424-
* +----+--------------+-------------+-------------+--------------+
1425-
* | 60 | LPM7 Requirements 0 |
1426-
* +----+---------------------------------------------------------+
1427-
* | | ... |
1428-
* +----+---------------------------------------------------------+
1429-
* | 87 | LPM7 Requirements 27 |
1430-
* +----+---------------------------------------------------------+
1431-
*
1432-
*/
14331433
mode_offset = LPM_HEADER_OFFSET + LPM_MODE_OFFSET;
14341434
pmc_for_each_mode(mode, pmcdev) {
14351435
u32 *req_offset = pmc->lpm_req_regs + (mode * num_maps);
@@ -1442,7 +1442,6 @@ static int pmc_core_get_lpm_req(struct pmc_dev *pmcdev, struct pmc *pmc, struct
14421442
if (ret) {
14431443
dev_err(&pmcdev->pdev->dev,
14441444
"couldn't read Low Power Mode requirements: %d\n", ret);
1445-
devm_kfree(&pmcdev->pdev->dev, pmc->lpm_req_regs);
14461445
goto unregister_ep;
14471446
}
14481447
++req_offset;

0 commit comments

Comments
 (0)