Skip to contentSkip to conversation

platform/x86/intel/pmc: Fix ioremap of bad address

PATCH In review David E. Box 2 participants 2 messages Jan 6, 2025 – Jan 7, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86/intel/pmc: Fix ioremap of bad address

In pmc_core_ssram_get_pmc(), the physical addresses for hidden SSRAM devices are retrieved from the MMIO region of the primary SSRAM device. If additional devices are not present, the address returned is zero. Currently, the code does not check for this condition, resulting in ioremap incorrectly attempting to map address 0. Add a check for a zero address and return 0 if no additional devices are found, as it is not an error for the device to be absent.

Fixes a01486dc4bb1 ("platform/x86/intel/pmc: Cleanup SSRAM discovery")
---
 drivers/platform/x86/intel/pmc/core_ssram.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/platform/x86/intel/pmc/core_ssram.c +4 -0
index 50ebfd586d3f..739569803017 100644
@@ -269,8 +269,12 @@ pmc_core_ssram_get_pmc(struct pmc_dev *pmcdev, int pmc_idx, u32 offset)
 		/*
 		 * The secondary PMC BARS (which are behind hidden PCI devices)
 		 * are read from fixed offsets in MMIO of the primary PMC BAR.
+		 * If a device is not present, the value will be 0.
 		 */
 		ssram_base = get_base(tmp_ssram, offset);
+		if (!ssram_base)
+			return 0;
+
 		ssram = ioremap(ssram_base, SSRAM_HDR_SIZE);
 		if (!ssram)
 			return -ENOMEM;

base-commit: 6b228cfc52a6e9b7149cf51e247076963d6561cd

Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 9 lines · David E. Box

In pmc_core_ssram_get_pmc(), the physical addresses for hidden SSRAM devices are retrieved from the MMIO region of the primary SSRAM device. If additional devices are not present, the address returned is zero. Currently, the code does not check for this condition, resulting in ioremap incorrectly attempting to map address 0. Add a check for a zero address and return 0 if no additional devices are found, as it is not an error for the device to be absent.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-fixes branch. Note it will show up in the public platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my local branch there, which might take a while.

The list of commits applied:
[1/1] platform/x86/intel/pmc: Fix ioremap of bad address

      commit: 1d7461d0c8330689117286169106af6531a747ed

--
i.