mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Mohr <andi@lisas.de>
To: "Björn Steinbrink" <B.Steinbrink@gmx.de>
Cc: Adrian Bunk <bunk@kernel.org>, Andreas Mohr <andi@lisas.de>,
	Richard Jonsson <richie@coderworld.net>,
	linux-kernel@vger.kernel.org, Ayaz Abdulla <aabdulla@nvidia.com>,
	jgarzik@pobox.com, netdev@vger.kernel.org
Subject: Re: forcedeth: MAC-address reversed on resume from suspend
Date: Fri, 4 Jan 2008 09:45:17 +0100	[thread overview]
Message-ID: <20080104084517.GA21628@rhlx01.hs-esslingen.de> (raw)
In-Reply-To: <20080104034357.GA2113@atjola.homenet>

Hi,

On Fri, Jan 04, 2008 at 04:43:57AM +0100, Björn Steinbrink wrote:
> On 2008.01.03 01:42:09 +0200, Adrian Bunk wrote:
> > [ original bug report: http://lkml.org/lkml/2008/1/2/253 ]
> > 
> > On Wed, Jan 02, 2008 at 10:48:43PM +0100, Andreas Mohr wrote:
> > > The nv_probe() function then nicely obeys this flag by reversing the
> > > address if needed, _however_ there's another function,
> > > nv_copy_mac_to_hw(), which does _NOT_ obey it and simply copies the
> > > _raw_ netdev dev_addr to the card register (NvRegMacAddrA etc.).
> 
> nv_copy_mac_to_hw() is called from nv_probe() _after_ the MAC address
> has been fixed, and from nv_set_mac_address() which is supposed to get a
> correct MAC address anyway. So I don't see any problem there.

/* set permanent address to be correct aswell */
... orig_mac fumbling ...

Why, then, does this driver do such a nice hack as:

        /* special op: write back the misordered MAC address - otherwise
         * the next nv_probe would see a wrong address.
         */
        writel(np->orig_mac[0], base + NvRegMacAddrA);
        writel(np->orig_mac[1], base + NvRegMacAddrB);

I really don't see why this driver needs to do these things in such a
messy way.

One thing is for certain: netdev->dev_addr is always in operating system
order, and order should always be handled properly when copying to/from
hardware.

Such a driver needs exactly *one* central helper method
to reverse an input MAC address in 6 bytes u8 format
(which could arguably be added to include/linux/etherdevice.h even,
since a wee bit too many devices seem to be having trouble
with wrongly ordered MAC addresses).
Then it needs exactly *one* function for I/O register access
to read a MAC address from a device and exactly *one* function
to write it back (both doing raw, unsorted format transfers only,
and possibly as inline function).

And then it needs these card I/O functions wrapped into two functions which
interface with driver- and OS-related MAC variables
(struct variables ALWAYS stored in usual system order, NOT H/W order!!!!!!)
which optionally reverse the address (if needed for a particular card).

And then there will never be any confusion about any MAC address format
anywhere any more, right?

I really don't mean to sound cranky, but this driver did ask for trouble,
and lots of it ;)

Thank you for your reply, and especially thank you for this very fast
patch!

I might even have enough time this weekend to work on this...

Andreas Mohr

  reply	other threads:[~2008-01-04  8:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-02 21:04 Richard Jonsson
2008-01-02 21:48 ` Andreas Mohr
2008-01-02 23:42   ` Adrian Bunk
2008-01-04  3:43     ` Björn Steinbrink
2008-01-04  8:45       ` Andreas Mohr [this message]
2008-01-04 10:17         ` Björn Steinbrink
2008-01-04 22:43           ` Andreas Mohr
2008-01-05  6:10             ` Björn Steinbrink
2008-01-05  6:39               ` Björn Steinbrink
2008-01-04 14:08       ` Richard Jonsson
2008-01-04 22:26         ` [PATCH] Fix forcedeth reversing the MAC address on suspend Björn Steinbrink
2008-01-07  1:47           ` Björn Steinbrink
2008-01-06 21:49       ` forcedeth: MAC-address reversed on resume from suspend Adolfo R. Brandes
2008-01-07  1:46         ` Björn Steinbrink
2008-01-07 12:02           ` Adolfo R. Brandes
2008-01-07 15:51           ` Richard Jonsson
2008-01-08  7:23           ` David Miller
2008-02-16  9:41             ` Adolfo R. Brandes
2008-01-04  1:35   ` Richard Jonsson

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=20080104084517.GA21628@rhlx01.hs-esslingen.de \
    --to=andi@lisas.de \
    --cc=B.Steinbrink@gmx.de \
    --cc=aabdulla@nvidia.com \
    --cc=bunk@kernel.org \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=richie@coderworld.net \
    /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

all inboxes | Powered by JetHome®