platform/x86/intel/pmc: Fix ioremap of bad address
Subsystems (2)
PATCH 1/2 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.
--- drivers/platform/x86/intel/pmc/core_ssram.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/platform/x86/intel/pmc/core_ssram.c +4 -0
@@ -267,8 +267,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: 8e929cb546ee42c9a61d24fae60605e9e3192354
Signature · 1 line
2.43.0
PATCH 2/2 platform/x86/intel/pmc: Remove unnecessary ioremap
pmc_get_pmc() unnecessarily calls ioremap to access memory that is already available through a variable passed in as an argument. Replace the redundant ioremap call with direct use of the provided variable, and remove the ioremap and iounmap calls.
--- drivers/platform/x86/intel/pmc/core_ssram.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/platform/x86/intel/pmc/core_ssram.c +0 -6
@@ -171,13 +171,7 @@ pmc_add_pmt(struct pmc_dev *pmcdev, u64 ssram_base, void __iomem *ssram)u32 dvsec_offset;u32 table, hdr; - ssram =ioremap (ssram_base,SSRAM_HDR_SIZE ); -if (!ssram) -return ; - dvsec_offset =readl (ssram +SSRAM_DVSEC_OFFSET ); -iounmap (ssram); - dvsec =ioremap (ssram_base + dvsec_offset,SSRAM_DVSEC_SIZE );if (!dvsec)return ;
Signature · 1 line
2.43.0
Re: [PATCH 2/2] platform/x86/intel/pmc: Remove unnecessary ioremap
Quoted 4 lines · David E. Box
pmc_get_pmc()unnecessarily calls ioremap to access memory that is already available through a variable passed in as an argument. Replace the redundant ioremap call with direct use of the provided variable, and remove the ioremap and iounmap calls.
Woke up to a test failure on this one. I'll drop in V2 or modify after checking what I missed.
David
Quoted 26 lines
Signed-off-by David E. Box <[email protected]>---
drivers/platform/x86/intel/pmc/core_ssram.c | 6 ------1 file changed, 6 deletions(-)drivers/platform/x86/intel/pmc/core_ssram.c +0
-0@@ -171,13 +171,7 @@ pmc_add_pmt(struct pmc_dev *pmcdev, u64 ssram_base, void __iomem *ssram) u32 dvsec_offset; u32 table, hdr;drivers/platform/x86/intel/pmc/core_ssram.c +0
-4- ssram =ioremap (ssram_base,SSRAM_HDR_SIZE ); -if (!ssram) -return ; -
dvsec_offset=readl(ssram + SSRAM_DVSEC_OFFSET);drivers/platform/x86/intel/pmc/core_ssram.c +0
-2-iounmap (ssram); -dvsec =
ioremap(ssram_base + dvsec_offset, SSRAM_DVSEC_SIZE); if (!dvsec)
return;