2019-08-09 14:39:57

by Stephen Douthit

[permalink] [raw]
Subject: [PATCH] EDAC, pnd2: Fix ioremap() size in dnv_rd_reg()

Depending on how BIOS has marked the reserved region containing the 32KB
MCHBAR you can get warnings like:

resource sanity check: requesting [mem 0xfed10000-0xfed1ffff], which spans more than reserved [mem 0xfed10000-0xfed17fff]
caller dnv_rd_reg+0xc8/0x240 [pnd2_edac] mapping multiple BARs

Not all of the mmio regions used in dnv_rd_reg() are the same size. The
MCHBAR window is 32KB and the sideband ports are 64KB. Pass the correct
size to ioremap() depending on which resource we're reading from.

Signed-off-by: Stephen Douthit <[email protected]>
---
drivers/edac/pnd2_edac.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/edac/pnd2_edac.c b/drivers/edac/pnd2_edac.c
index 903a4f1fadcc..0153c730750e 100644
--- a/drivers/edac/pnd2_edac.c
+++ b/drivers/edac/pnd2_edac.c
@@ -268,11 +268,14 @@ static u64 get_sideband_reg_base_addr(void)
}
}

+#define DNV_MCHBAR_SIZE 0x8000
+#define DNV_SB_PORT_SIZE 0x10000
static int dnv_rd_reg(int port, int off, int op, void *data, size_t sz, char *name)
{
struct pci_dev *pdev;
char *base;
u64 addr;
+ unsigned long size;

if (op == 4) {
pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x1980, NULL);
@@ -287,15 +290,17 @@ static int dnv_rd_reg(int port, int off, int op, void *data, size_t sz, char *na
addr = get_mem_ctrl_hub_base_addr();
if (!addr)
return -ENODEV;
+ size = DNV_MCHBAR_SIZE;
} else {
/* MMIO via sideband register base address */
addr = get_sideband_reg_base_addr();
if (!addr)
return -ENODEV;
addr += (port << 16);
+ size = DNV_SB_PORT_SIZE;
}

- base = ioremap((resource_size_t)addr, 0x10000);
+ base = ioremap((resource_size_t)addr, size);
if (!base)
return -ENODEV;

--
2.21.0


2019-08-09 17:36:46

by Tony Luck

[permalink] [raw]
Subject: Re: [PATCH] EDAC, pnd2: Fix ioremap() size in dnv_rd_reg()

On Fri, Aug 09, 2019 at 02:18:02PM +0000, Stephen Douthit wrote:
> Depending on how BIOS has marked the reserved region containing the 32KB
> MCHBAR you can get warnings like:
>
> resource sanity check: requesting [mem 0xfed10000-0xfed1ffff], which spans more than reserved [mem 0xfed10000-0xfed17fff]
> caller dnv_rd_reg+0xc8/0x240 [pnd2_edac] mapping multiple BARs
>
> Not all of the mmio regions used in dnv_rd_reg() are the same size. The
> MCHBAR window is 32KB and the sideband ports are 64KB. Pass the correct
> size to ioremap() depending on which resource we're reading from.

Applied. Thanks.

-Tony

[Boris/Mauro: I pushed to edac-for-next branch in ras tree
git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.git]

2019-08-09 18:19:43

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH] EDAC, pnd2: Fix ioremap() size in dnv_rd_reg()

On Fri, Aug 09, 2019 at 10:25:33AM -0700, Luck, Tony wrote:
> [Boris/Mauro: I pushed to edac-for-next branch in ras tree
> git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.git]

Yap, this is the workflow. And from now on, we all should refresh
our local copies of edac-for-next before applying stuff. And when we
happen to push at the same time, we should be able to solve such seldom
conflicts on IRC. :-)

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.