netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: tremyfr@gmail.com
Cc: festevam@gmail.com, linux@arm.linux.org.uk, B38611@freescale.com,
	Frank.Li@freescale.com, LW@karo-electronics.de,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: fec: add support of ethtool get_regs
Date: Sat, 09 May 2015 21:01:28 -0400 (EDT)	[thread overview]
Message-ID: <20150509.210128.2284066611245510581.davem@davemloft.net> (raw)
In-Reply-To: <554E8735.302@gmail.com>

From: Philippe Reynes <tremyfr@gmail.com>
Date: Sun, 10 May 2015 00:16:21 +0200

> Hi Fabio,
> 
> On 09/05/15 23:59, Fabio Estevam wrote:
>> Philippe,
>>
>> On Sat, May 9, 2015 at 6:17 PM, Russell King - ARM Linux
>> <linux@arm.linux.org.uk>  wrote:
>>
>>> Using memcpy_fromio() to copy device registers is not a good idea -
>>> it can use a variable access size which can cause bus faults.
>>
>> An example on how memcpy_fromio() can be avoided in get_regs:
>> drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c
> 
> Thanks for pointing me this example. I've already send a patch,
> and I've used drivers/net/ethernet/freescale/gianfar_ethtool.c
> as example. I hope it's a good example too.

I think you need to be much more careful and conservative in your
implementation.

You should skip I/O addresses that don't have defined registers
at those offsets for the chip in question.

Also, you should _very_ carefully evaluate each and every register you
dump and potentially skip certain registers which have strong negative
side effects if read arbitrarily.

For example, dumping the interrupt status register could cause pending
interrupt status to be cleared, and thus cause the driver to lose
interrupts and subsequently packet processing will hang.

  reply	other threads:[~2015-05-10  1:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-09 20:52 [PATCH] net: fec: add support of ethtool get_regs Philippe Reynes
2015-05-09 21:17 ` Russell King - ARM Linux
2015-05-09 21:31   ` David Miller
2015-05-09 21:59   ` Fabio Estevam
2015-05-09 22:16     ` Philippe Reynes
2015-05-10  1:01       ` David Miller [this message]
2015-05-10 21:43         ` Philippe Reynes

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=20150509.210128.2284066611245510581.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=B38611@freescale.com \
    --cc=Frank.Li@freescale.com \
    --cc=LW@karo-electronics.de \
    --cc=festevam@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=tremyfr@gmail.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 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).