2016-11-29 05:56:55

by Harini Katakam

[permalink] [raw]
Subject: [PATCH v2] net: macb: Write only necessary bits in NCR in macb reset

In macb_reset_hw, use read-modify-write to disable RX and TX.
Existing settings, for ex. management port enable,
are being cleared in the current implementation.
Also certain reserved bits are read only.
Hence it is better to use read-modify-write.
Use the same method for clearing statistics as well.

Signed-off-by: Harini Katakam <[email protected]>
---

v2:
Make ctrl type as u32
Improve commit description

---
drivers/net/ethernet/cadence/macb.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 0e489bb..2ce3407 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -1744,14 +1744,18 @@ static void macb_reset_hw(struct macb *bp)
{
struct macb_queue *queue;
unsigned int q;
+ u32 ctrl;

/* Disable RX and TX (XXX: Should we halt the transmission
* more gracefully?)
*/
- macb_writel(bp, NCR, 0);
+ ctrl = macb_readl(bp, NCR);
+ ctrl &= ~(MACB_BIT(RE) | MACB_BIT(TE));
+ macb_writel(bp, NCR, ctrl);

/* Clear the stats registers (XXX: Update stats first?) */
- macb_writel(bp, NCR, MACB_BIT(CLRSTAT));
+ ctrl |= MACB_BIT(CLRSTAT);
+ macb_writel(bp, NCR, ctrl);

/* Clear all status flags */
macb_writel(bp, TSR, -1);
--
2.7.4


2016-11-29 08:58:38

by Nicolas Ferre

[permalink] [raw]
Subject: Re: [PATCH v2] net: macb: Write only necessary bits in NCR in macb reset

Le 29/11/2016 ? 06:56, Harini Katakam a ?crit :
> In macb_reset_hw, use read-modify-write to disable RX and TX.
> Existing settings, for ex. management port enable,
> are being cleared in the current implementation.
> Also certain reserved bits are read only.
> Hence it is better to use read-modify-write.
> Use the same method for clearing statistics as well.
>
> Signed-off-by: Harini Katakam <[email protected]>

Acked-by: Nicolas Ferre <[email protected]>

> ---
>
> v2:
> Make ctrl type as u32
> Improve commit description
>
> ---
> drivers/net/ethernet/cadence/macb.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index 0e489bb..2ce3407 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -1744,14 +1744,18 @@ static void macb_reset_hw(struct macb *bp)
> {
> struct macb_queue *queue;
> unsigned int q;
> + u32 ctrl;
>
> /* Disable RX and TX (XXX: Should we halt the transmission
> * more gracefully?)
> */
> - macb_writel(bp, NCR, 0);
> + ctrl = macb_readl(bp, NCR);
> + ctrl &= ~(MACB_BIT(RE) | MACB_BIT(TE));
> + macb_writel(bp, NCR, ctrl);
>
> /* Clear the stats registers (XXX: Update stats first?) */
> - macb_writel(bp, NCR, MACB_BIT(CLRSTAT));
> + ctrl |= MACB_BIT(CLRSTAT);
> + macb_writel(bp, NCR, ctrl);
>
> /* Clear all status flags */
> macb_writel(bp, TSR, -1);
>


--
Nicolas Ferre