From: Peter Wu <lekensteyn@gmail.com>
To: Francois Romieu <romieu@fr.zoreil.com>
Cc: netdev@vger.kernel.org, nic_swsd@realtek.com
Subject: Re: [PATCH] r8169: fix invalid register dump
Date: Wed, 14 Aug 2013 15:12:50 +0200 [thread overview]
Message-ID: <3465288.NFVErF5E7l@al> (raw)
In-Reply-To: <20130813222038.GC5635@electric-eye.fr.zoreil.com>
On Wednesday 14 August 2013 00:20:38 Francois Romieu wrote:
> > - memcpy_fromio(p, tp->mmio_addr, regs->len);
> > + for (i = 0; i < regs->len - 4; i += 4)
> > + memcpy_fromio(bytes + i, tp->mmio_addr + i, 4);
>
> regs->len is u32. regs->len - 4 should not underflow on normal situation but
> it's a bit sloppy.
Heh, I forgot about that case. Fixed it in the below patch. By the way,
have you observed similar behavior on other hardware?
Thanks,
Peter
--
From: Peter Wu <lekensteyn@gmail.com>
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.
Signed-off-by: Peter Wu <lekensteyn@gmail.com>
---
drivers/net/ethernet/realtek/r8169.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index b5eb419..d367763 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -1897,12 +1897,19 @@ static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs,
void *p)
{
struct rtl8169_private *tp = netdev_priv(dev);
+ char *bytes = p;
+ int i;
if (regs->len > R8169_REGS_SIZE)
regs->len = R8169_REGS_SIZE;
rtl_lock_work(tp);
- memcpy_fromio(p, tp->mmio_addr, regs->len);
+ if (regs->len >= 4) {
+ for (i = 0; i < regs->len - 4; i += 4)
+ memcpy_fromio(bytes + i, tp->mmio_addr + i, 4);
+ }
+ if (i < regs->len)
+ memcpy_fromio(bytes + i, tp->mmio_addr + i, regs->len - i);
rtl_unlock_work(tp);
}
--
1.8.3.4
next prev parent reply other threads:[~2013-08-14 13:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-13 20:37 [PATCH] r8169: fix invalid register dump Peter Wu
2013-08-13 22:20 ` Francois Romieu
2013-08-14 13:12 ` Peter Wu [this message]
2013-08-14 19:58 ` Francois Romieu
2013-08-14 21:31 ` Peter Wu
2013-08-14 22:47 ` Francois Romieu
2013-08-16 22:35 ` Peter Wu
2013-08-15 20:33 ` Ben Hutchings
2013-08-16 22:58 ` Peter Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3465288.NFVErF5E7l@al \
--to=lekensteyn@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
--cc=romieu@fr.zoreil.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.