All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anssi Hannula <anssi.hannula@bitwise.fi>
To: Claudiu Beznea <Claudiu.Beznea@microchip.com>
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: Thu, 9 Aug 2018 17:54:27 +0300	[thread overview]
Message-ID: <3c3a606e-b3e1-41fc-fcd8-7b98968fd06b@bitwise.fi> (raw)
In-Reply-To: <425ed5af-eac2-a58b-b6ca-f022a80367e4@microchip.com>

On 9.8.2018 11:26, Claudiu Beznea wrote:
> On 08.08.2018 15:19, Anssi Hannula wrote:
>> macb_close() calls macb_reset_hw() which zeroes NCR register, including
>> the MPE (Management Port Enable) bit.
>>
>> This will prevent accessing any other PHYs for other Ethernet MACs on
>> the MDIO bus which is still registered.
>>
>> Fix that by keeping the MPE bit set.
>>
>> Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
>> ---
>>  drivers/net/ethernet/cadence/macb_main.c | 7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
>> index dc09f9a8a49b..3ca98fc32144 100644
>> --- a/drivers/net/ethernet/cadence/macb_main.c
>> +++ b/drivers/net/ethernet/cadence/macb_main.c
>> @@ -2030,12 +2030,13 @@ static void macb_reset_hw(struct macb *bp)
>>  	unsigned int q;
>>  
>>  	/* Disable RX and TX (XXX: Should we halt the transmission
>> -	 * more gracefully?)
>> +	 * more gracefully?) but keep management port open since there
>> +	 * may be other users of the mdio bus
>>  	 */
>> -	macb_writel(bp, NCR, 0);
>> +	macb_writel(bp, NCR, MACB_BIT(MPE));
> Would be better to read the NCR and clear only RX and TX bits, something like:
> 	val = macb_readl(bp, NCR);
>
> 	/* Disable TX and RX. */
> 	val &= ~(MACB_BIT(TE) | MACB_BIT(RE));
>
> 	/* Clear statistics */
> 	val |= MACB_BIT(CLRSTAT);
>
> 	macb_writel(bp, NCR, val);
>
> MPE should have been enabled by previous operations.

macb_reset_hw() is called in init path too, though, so maybe clearing
all bits is intentional / wanted to get the controller to a known state,
even though the comment only mentions TX/RX?

If so, maybe the below would be better? But if you think just clearing
TE/RE is better I'll just do it like you suggested.

    val = macb_readl(bp, NCR);

    /* Keep only MDIO port active */
    val &= MACB_BIT(MPE);

    /* Clear statistics */
    val |= MACB_BIT(CLRSTAT);

    macb_writel(bp, NCR, val);



> Thank you,
> Claudiu Beznea
>
>>  
>>  	/* Clear the stats registers (XXX: Update stats first?) */
>> -	macb_writel(bp, NCR, MACB_BIT(CLRSTAT));
>> +	macb_writel(bp, NCR, MACB_BIT(CLRSTAT) | MACB_BIT(MPE));
>>  
>>  	/* Clear all status flags */
>>  	macb_writel(bp, TSR, -1);
>>

-- 
Anssi Hannula / Bitwise Oy
+358 503803997

  reply	other threads:[~2018-08-09 17:19 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 [this message]
2018-08-09 15:14     ` Andrew Lunn
2018-08-10  6:22       ` Anssi Hannula
2018-08-13  9:08         ` Claudiu Beznea
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=3c3a606e-b3e1-41fc-fcd8-7b98968fd06b@bitwise.fi \
    --to=anssi.hannula@bitwise.fi \
    --cc=Claudiu.Beznea@microchip.com \
    --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.