Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752085AbbEJBBe (ORCPT ); Sat, 9 May 2015 21:01:34 -0400 Received: from shards.monkeyblade.net ([149.20.54.216]:47037 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751962AbbEJBBc (ORCPT ); Sat, 9 May 2015 21:01:32 -0400 Date: Sat, 09 May 2015 21:01:28 -0400 (EDT) Message-Id: <20150509.210128.2284066611245510581.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 From: David Miller In-Reply-To: <554E8735.302@gmail.com> References: <20150509211746.GY2067@n2100.arm.linux.org.uk> <554E8735.302@gmail.com> X-Mailer: Mew version 6.6 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Sat, 09 May 2015 18:01:31 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1501 Lines: 39 From: Philippe Reynes 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 >> 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. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/