All of lore.kernel.org
 help / color / mirror / Atom feed
From: Claudiu Beznea <Claudiu.Beznea@microchip.com>
To: Anssi Hannula <anssi.hannula@bitwise.fi>, Andrew Lunn <andrew@lunn.ch>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>,
	"David S. Miller" <davem@davemloft.net>, <netdev@vger.kernel.org>
Subject: Re: [PATCH] net: macb: do not disable MDIO bus when closing interface
Date: Mon, 13 Aug 2018 12:08:10 +0300	[thread overview]
Message-ID: <3e55fc51-503c-d174-841c-a1a5a0f5ae69@microchip.com> (raw)
In-Reply-To: <edd7aaf4-53dc-6d10-5c4b-2928a4612d99@bitwise.fi>



On 10.08.2018 09:22, Anssi Hannula wrote:
> On 9.8.2018 18:14, Andrew Lunn wrote:
>> Hi Anssi
> 
> Hi!
> 
>>> macb_reset_hw() is called in init path too,

I only see it in macb_close() and macb_open() called from macb_init_hw().

though, so maybe clearing
>>> all bits is intentional / wanted to get the controller to a known state,

As far as I know the NCR is used in this driver only to control transmit
enable, receive enable, MPE and tx start.

Not clearing NCR in the init phase should not have any impact on IP. Same
for not clearing Tx start on "if down" path (if tx is in progress).

>>> even though the comment only mentions TX/RX?
>> You need to be careful here. Once of_mdiobus_register() is called, the
>> MDIO should be usable. If you happen to have an Ethernet switch on the
>> bus, it could be probed then. The DSA driver will start using the bus.
>> Or if you have a second PHY, connected to some other MAC, it could be
>> used by the other MAC.  This all happens in the macb_probe function.
>>
>> Sometime later, the interface will be up'ed. At this point macb_open()
>> is called, which calls macb_init_hw(), which calls
>> macb_reset_hw(). What you don't want happening is changes to the NCR
>> at this point breaking an MDIO transaction which might be going on.
>>
>> Ideally, the MPE should be enabled before of_mdiobus_register(), and
>> left alone until mdiobus_unregister() is called in macb_remove().
> 
> Yep, fixing the use case of having PHYs of other MACs is why I wrote the
> patch :)
> 
> Currently the reset code disables MPE while other MACs are using PHYs on
> the bus.

MPE is set in the early phase of initialization, in macb_mii_init(), called
from probe() function. Due to the fact that NCR is cleared in
macb_reset_hw() it is set again at the end of macb_init_hw(). So, as per
Andrew comments in this thread, setting it in macb_mii_init() and letting
it unchanged until remove would be the best. So, if you clear only TE and
RE bits in macb_reset_hw() please also remove MACB_BIT(MPE) from below line
at the end of macb_init_hw():

        macb_writel(bp, NCR, MACB_BIT(RE) | MACB_BIT(TE) | MACB_BIT(MPE));


Thank you,
Claudiu Beznea

> 

  reply	other threads:[~2018-08-13 11:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-08 12:19 [PATCH] net: macb: do not disable MDIO bus when closing interface Anssi Hannula
2018-08-09  8:26 ` Claudiu Beznea
2018-08-09 14:54   ` Anssi Hannula
2018-08-09 15:14     ` Andrew Lunn
2018-08-10  6:22       ` Anssi Hannula
2018-08-13  9:08         ` Claudiu Beznea [this message]
2018-08-20 14:55           ` [PATCH] net: macb: do not disable MDIO bus at open/close time Anssi Hannula
2018-08-22 15:33             ` Claudiu Beznea
2018-08-23  7:45               ` [PATCH v2] " Anssi Hannula
2018-08-24 14:47                 ` Claudiu Beznea
2018-08-26  0:35                 ` David Miller

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=3e55fc51-503c-d174-841c-a1a5a0f5ae69@microchip.com \
    --to=claudiu.beznea@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=anssi.hannula@bitwise.fi \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@microchip.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.