netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] r8169: fix invalid register dump
@ 2013-08-18 13:41 Peter Wu
  2013-08-18 21:21 ` Francois Romieu
  2013-08-20 22:02 ` David Miller
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Wu @ 2013-08-18 13:41 UTC (permalink / raw)
  To: Francois Romieu, Ben Hutchings; +Cc: lekensteyn, netdev, nic_swsd

For some reason, my PCIe RTL8111E onboard NIC on a GA-Z68X-UD3H-B3
motherboard reads as FFs when reading from MMIO with a block size
larger than 7. Therefore change to reading blocks of four bytes.

Ben Hutchings noted that the buffer is large enough to hold all
registers, so now all registers are read. Since regs->len is not used
anymore, drop the superfluous range check as well. (ethtool would
already ensure that regs->len <= R8169_REGS_SIZE).

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
---
Hi,

This partly obsoletes "r8169,sis190: remove unnecessary length
check"[1]. I do not have sis190 hardware, but since that is based on
this r8169 driver, would it make sense to apply this patch to sis190
too?

Regards,
Peter

 [1]: http://www.spinics.net/lists/netdev/msg246824.html
---
 drivers/net/ethernet/realtek/r8169.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index b5eb419..c0c9e14 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -1897,12 +1897,13 @@ static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs,
 			     void *p)
 {
 	struct rtl8169_private *tp = netdev_priv(dev);
-
-	if (regs->len > R8169_REGS_SIZE)
-		regs->len = R8169_REGS_SIZE;
+	u32 __iomem *data = tp->mmio_addr;
+	u32 *dw = p;
+	int i;
 
 	rtl_lock_work(tp);
-	memcpy_fromio(p, tp->mmio_addr, regs->len);
+	for (i = 0; i < R8169_REGS_SIZE; i += 4)
+		memcpy_fromio(dw++, data++, 4);
 	rtl_unlock_work(tp);
 }
 
-- 
1.8.3.4

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

* Re: [PATCH v3] r8169: fix invalid register dump
  2013-08-18 13:41 [PATCH v3] r8169: fix invalid register dump Peter Wu
@ 2013-08-18 21:21 ` Francois Romieu
  2013-08-20 22:02 ` David Miller
  1 sibling, 0 replies; 8+ messages in thread
From: Francois Romieu @ 2013-08-18 21:21 UTC (permalink / raw)
  To: Peter Wu; +Cc: Ben Hutchings, netdev, nic_swsd

Peter Wu <lekensteyn@gmail.com> :
[...]
> check"[1]. I do not have sis190 hardware, but since that is based on
> this r8169 driver, would it make sense to apply this patch to sis190
> too?

Yes for the _REGS_SIZE part. Nobody proved that the memcpy_fromio split
is needed or even useful with a sis19x.

-- 
Ueimor

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

* Re: [PATCH v3] r8169: fix invalid register dump
  2013-08-18 13:41 [PATCH v3] r8169: fix invalid register dump Peter Wu
  2013-08-18 21:21 ` Francois Romieu
@ 2013-08-20 22:02 ` David Miller
  2013-08-21 20:40   ` Peter Wu
  1 sibling, 1 reply; 8+ messages in thread
From: David Miller @ 2013-08-20 22:02 UTC (permalink / raw)
  To: lekensteyn; +Cc: romieu, bhutchings, netdev, nic_swsd

From: Peter Wu <lekensteyn@gmail.com>
Date: Sun, 18 Aug 2013 15:41:38 +0200

> For some reason, my PCIe RTL8111E onboard NIC on a GA-Z68X-UD3H-B3
> motherboard reads as FFs when reading from MMIO with a block size
> larger than 7. Therefore change to reading blocks of four bytes.
> 
> Ben Hutchings noted that the buffer is large enough to hold all
> registers, so now all registers are read. Since regs->len is not used
> anymore, drop the superfluous range check as well. (ethtool would
> already ensure that regs->len <= R8169_REGS_SIZE).
> 
> Signed-off-by: Peter Wu <lekensteyn@gmail.com>
> ---
> Hi,
> 
> This partly obsoletes "r8169,sis190: remove unnecessary length
> check"[1]. I do not have sis190 hardware, but since that is based on
> this r8169 driver, would it make sense to apply this patch to sis190
> too?

You're going to have to respin this since I applied the length
check removal patch already.

Thanks.

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

* Re: [PATCH v3] r8169: fix invalid register dump
  2013-08-20 22:02 ` David Miller
@ 2013-08-21 20:40   ` Peter Wu
  2013-08-21 20:53     ` Francois Romieu
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Wu @ 2013-08-21 20:40 UTC (permalink / raw)
  To: David Miller; +Cc: romieu, bhutchings, netdev, nic_swsd

On Tuesday 20 August 2013 15:02:13 David Miller wrote:
> > This partly obsoletes "r8169,sis190: remove unnecessary length
> > check"[1]. I do not have sis190 hardware, but since that is based on
> > this r8169 driver, would it make sense to apply this patch to sis190
> > too?
> 
> You're going to have to respin this since I applied the length
> check removal patch already.

Please find the updated patch below. There may be differences in lines
because net-next has the r8169,sis190 patch and net the WOL fix.

Can I consider Francois reply[1] as Acked-by?

Thanks,
Peter

 [1]: http://lkml.kernel.org/r/20130817211407.GA30676@electric-eye.fr.zoreil.com

--
>From 56b7598a712e63841b6d8efb2245e5bb87990e01 Mon Sep 17 00:00:00 2001
From: Peter Wu <lekensteyn@gmail.com>
Date: Tue, 23 Jul 2013 12:27:27 +0200
Subject: [PATCH] r8169: fix invalid register dump

For some reason, my PCIe RTL8111E onboard NIC on a GA-Z68X-UD3H-B3
motherboard reads as FFs when reading from MMIO with a block size
larger than 7. Therefore change to reading blocks of four bytes.

Ben Hutchings noted that the buffer is large enough to hold all
registers, so now all registers are read.

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
---
 drivers/net/ethernet/realtek/r8169.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 93ee49d..f724d9c 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -1897,9 +1897,12 @@ static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs,
 			     void *p)
 {
 	struct rtl8169_private *tp = netdev_priv(dev);
-
+	u32 __iomem *data = tp->mmio_addr;
+	u32 *dw = p;
+	int i;
 	rtl_lock_work(tp);
-	memcpy_fromio(p, tp->mmio_addr, regs->len);
+	for (i = 0; i < R8169_REGS_SIZE; i += 4)
+		memcpy_fromio(dw++, data++, 4);
 	rtl_unlock_work(tp);
 }
 
-- 
1.8.3.4

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

* Re: [PATCH v3] r8169: fix invalid register dump
  2013-08-21 20:40   ` Peter Wu
@ 2013-08-21 20:53     ` Francois Romieu
  2013-08-21 21:13       ` Peter Wu
  2013-08-21 21:17       ` [PATCH net-next v4] " Peter Wu
  0 siblings, 2 replies; 8+ messages in thread
From: Francois Romieu @ 2013-08-21 20:53 UTC (permalink / raw)
  To: Peter Wu; +Cc: David Miller, bhutchings, netdev, nic_swsd

Peter Wu <lekensteyn@gmail.com> :
[...]
> Please find the updated patch below. There may be differences in lines
> because net-next has the r8169,sis190 patch and net the WOL fix.
> 
> Can I consider Francois reply[1] as Acked-by?

Yes, provided you insert an empty line between declarations and code.

You may / should send patches as normal submissions. It will probably
be easier for davem to use and you can always raise questions or add
minor remarks in the "--- ... diff" section.

-- 
Ueimor

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

* Re: [PATCH v3] r8169: fix invalid register dump
  2013-08-21 20:53     ` Francois Romieu
@ 2013-08-21 21:13       ` Peter Wu
  2013-08-21 21:17       ` [PATCH net-next v4] " Peter Wu
  1 sibling, 0 replies; 8+ messages in thread
From: Peter Wu @ 2013-08-21 21:13 UTC (permalink / raw)
  To: Francois Romieu; +Cc: David Miller, bhutchings, netdev, nic_swsd

On Wednesday 21 August 2013 22:53:25 Francois Romieu wrote:
> Peter Wu <lekensteyn@gmail.com> :
> [...]
> 
> > Please find the updated patch below. There may be differences in lines
> > because net-next has the r8169,sis190 patch and net the WOL fix.
> > 
> > Can I consider Francois reply[1] as Acked-by?
> 
> Yes, provided you insert an empty line between declarations and code.
Done, new patch will arrive in a minute.

> You may / should send patches as normal submissions. It will probably
> be easier for davem to use and you can always raise questions or add
> minor remarks in the "--- ... diff" section.

I noticed that patchwork also recognized submissions that are appended to a 
mail, so I tried that out ;-) Well, apparantly it does not work well with git, 
so I will just send a new patch with a useful In-Reply-To header.

Peter

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

* [PATCH net-next v4] r8169: fix invalid register dump
  2013-08-21 20:53     ` Francois Romieu
  2013-08-21 21:13       ` Peter Wu
@ 2013-08-21 21:17       ` Peter Wu
  2013-08-22 21:26         ` David Miller
  1 sibling, 1 reply; 8+ messages in thread
From: Peter Wu @ 2013-08-21 21:17 UTC (permalink / raw)
  To: netdev, David Miller; +Cc: nic_swsd, bhutchings, Francois Romieu, lekensteyn

For some reason, my PCIe RTL8111E onboard NIC on a GA-Z68X-UD3H-B3
motherboard reads as FFs when reading from MMIO with a block size
larger than 7. Therefore change to reading blocks of four bytes.

Ben Hutchings noted that the buffer is large enough to hold all
registers, so now all registers are read.

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
Acked-by: Francois Romieu <romieu@fr.zoreil.com>
---
 drivers/net/ethernet/realtek/r8169.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 93ee49d..c0c9e14 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -1897,9 +1897,13 @@ static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs,
 			     void *p)
 {
 	struct rtl8169_private *tp = netdev_priv(dev);
+	u32 __iomem *data = tp->mmio_addr;
+	u32 *dw = p;
+	int i;
 
 	rtl_lock_work(tp);
-	memcpy_fromio(p, tp->mmio_addr, regs->len);
+	for (i = 0; i < R8169_REGS_SIZE; i += 4)
+		memcpy_fromio(dw++, data++, 4);
 	rtl_unlock_work(tp);
 }
 
-- 
1.8.3.4

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

* Re: [PATCH net-next v4] r8169: fix invalid register dump
  2013-08-21 21:17       ` [PATCH net-next v4] " Peter Wu
@ 2013-08-22 21:26         ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2013-08-22 21:26 UTC (permalink / raw)
  To: lekensteyn; +Cc: netdev, nic_swsd, bhutchings, romieu

From: Peter Wu <lekensteyn@gmail.com>
Date: Wed, 21 Aug 2013 23:17:11 +0200

> For some reason, my PCIe RTL8111E onboard NIC on a GA-Z68X-UD3H-B3
> motherboard reads as FFs when reading from MMIO with a block size
> larger than 7. Therefore change to reading blocks of four bytes.
> 
> Ben Hutchings noted that the buffer is large enough to hold all
> registers, so now all registers are read.
> 
> Signed-off-by: Peter Wu <lekensteyn@gmail.com>
> Acked-by: Francois Romieu <romieu@fr.zoreil.com>

Applied, thanks.

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

end of thread, other threads:[~2013-08-22 21:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-18 13:41 [PATCH v3] r8169: fix invalid register dump Peter Wu
2013-08-18 21:21 ` Francois Romieu
2013-08-20 22:02 ` David Miller
2013-08-21 20:40   ` Peter Wu
2013-08-21 20:53     ` Francois Romieu
2013-08-21 21:13       ` Peter Wu
2013-08-21 21:17       ` [PATCH net-next v4] " Peter Wu
2013-08-22 21:26         ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).