Linux-EDAC Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] EDAC, pnd2: Fix ioremap() size in dnv_rd_reg()
@ 2019-08-09 14:18 Stephen Douthit
  2019-08-09 17:25 ` Luck, Tony
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Douthit @ 2019-08-09 14:18 UTC (permalink / raw)
  To: Tony Luck, Borislav Petkov, Mauro Carvalho Chehab, James Morse
  Cc: Stephen Douthit, linux-edac, linux-kernel

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 <stephend@silicom-usa.com>
---
 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] EDAC, pnd2: Fix ioremap() size in dnv_rd_reg()
  2019-08-09 14:18 [PATCH] EDAC, pnd2: Fix ioremap() size in dnv_rd_reg() Stephen Douthit
@ 2019-08-09 17:25 ` Luck, Tony
  2019-08-09 17:32   ` Borislav Petkov
  0 siblings, 1 reply; 3+ messages in thread
From: Luck, Tony @ 2019-08-09 17:25 UTC (permalink / raw)
  To: Stephen Douthit
  Cc: Borislav Petkov, Mauro Carvalho Chehab, James Morse, linux-edac,
	linux-kernel

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]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] EDAC, pnd2: Fix ioremap() size in dnv_rd_reg()
  2019-08-09 17:25 ` Luck, Tony
@ 2019-08-09 17:32   ` Borislav Petkov
  0 siblings, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2019-08-09 17:32 UTC (permalink / raw)
  To: Luck, Tony
  Cc: Stephen Douthit, Mauro Carvalho Chehab, James Morse, linux-edac,
	linux-kernel

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-09 14:18 [PATCH] EDAC, pnd2: Fix ioremap() size in dnv_rd_reg() Stephen Douthit
2019-08-09 17:25 ` Luck, Tony
2019-08-09 17:32   ` Borislav Petkov

Linux-EDAC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-edac/0 linux-edac/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-edac linux-edac/ https://lore.kernel.org/linux-edac \
		linux-edac@vger.kernel.org linux-edac@archiver.kernel.org
	public-inbox-index linux-edac


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-edac


AGPL code for this site: git clone https://public-inbox.org/ public-inbox