All of lore.kernel.org
 help / color / mirror / Atom feed
From: Francois Romieu <romieu@fr.zoreil.com>
To: Peter Wu <lekensteyn@gmail.com>
Cc: netdev@vger.kernel.org, nic_swsd@realtek.com
Subject: Re: [PATCH] r8169: fix invalid register dump
Date: Thu, 15 Aug 2013 00:47:36 +0200	[thread overview]
Message-ID: <20130814224736.GA5193@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <2045708.ru9COLib4d@al>

Peter Wu <lekensteyn@gmail.com> :
[...]
> Checklist:
> 1. super large regs->len: won't be greater than R8169_REGS_SIZE (256)
> 2. regs->len == 0: 0 < 0 is false, nothing is copied
> 3. regs->len is 1, 2 or 3: i = 0, at most 3 bytes will be copied
> 4. regs->len is 4, i < 4 - 4, skip loop, 0 < regs->len, copy 4
> 5. regs->len is 5, i < 5 - 4, copy; 4 < regs->len, copy 1

Spartan implementation:

	u32 __iomem *ioaddr = tp->mmio_addr;
	u32 *dw = p;
	int i;

	...

	for (i = regs->len; i > 0; i -= 4)
		memcpy_fromio(dw++, ioaddr++, min(i, 4));

or (min() verges on gluttony):

	for (i = regs->len; i >= 4; i -= 4)
		memcpy_fromio(dw++, ioaddr++, 4);

	if (i > 0)
		memcpy_fromio(dw, ioaddr, i);

-- 
Ueimor

  reply	other threads:[~2013-08-14 22:47 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
2013-08-14 19:58     ` Francois Romieu
2013-08-14 21:31       ` Peter Wu
2013-08-14 22:47         ` Francois Romieu [this message]
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=20130814224736.GA5193@electric-eye.fr.zoreil.com \
    --to=romieu@fr.zoreil.com \
    --cc=lekensteyn@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nic_swsd@realtek.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.