Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2923947rdh; Mon, 27 Nov 2023 02:21:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrNm8AsyYKjSJZ5l5wN3rUX8Fd5LWMekELvN5KT8y3g0saR0RdikYBK+jEf1zmTkAni/Yh X-Received: by 2002:a05:6a00:3996:b0:6c3:75e1:9dcd with SMTP id fi22-20020a056a00399600b006c375e19dcdmr10661325pfb.18.1701080485845; Mon, 27 Nov 2023 02:21:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701080485; cv=none; d=google.com; s=arc-20160816; b=oJrDuBL1n83Co0Ms4syhtRYHTYWG/jRcYvFhdA6YzYIlWC9kGbS4G3i+0P4GVV95wq xq9N5CdeRymCfLWwkZHf3e0y8lEY6YbR9SHghsQugFHQES/9IzFKb/LNr2tQo4jiNuqc BZd4L0R6/RABb3DkjY7uxPHNOlkGH0Yeq2RLbXwuxFVl8GXXEt0Oa4CPRlikgxbiteZr 9MhGt2MJTBV/4d8uaIEjJDGXz4vuKbKdkG02Yc2eT+Xd6hn1P9/4lSzrT1pf0WoH1P9D vtWQ+/H/KJn22rIPCOWOPq5y+ghum+ExOxYoNujru80VTKDVtbG0DfnB96SLP8YXFcZc stsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ExvmcaBmtMG79z7Iqahkd4y5Qc/HJbGcEwVPJT9+anc=; fh=3ws/gucWYpWb7WrhKdu1ySz4c3uzNbBq4I3/clguuZ0=; b=clA/xGDN4nIyHXSKunUmyo6DXQHBt3n+8t6Yuc7wzRcSFRNmLmU+Du3iKXxdAvy2bO q3lexMvf0zmi5j+syhm8apALWPKcMoRx1msxPL9gz9LY83GoluCLriDvohPSRJYZGWI/ zoOL2sk/uGOA6QnjmlXDk8R/oNRwHtds4dGf7vx+WUeo0xq8MoKILIoBxtoBCEl1V4Dc COyCv9LfSO7PbBM9150t5l4D81Cmopndv5nhxAvaMd4htaMkycDr6bEqiMeS+yE0wIoT NCMNzLcAJIkE1xJtvIelTJdBPmhBLkttq5gN/SB9bbNe8LzGtG3gfqxRdLKWFLFI3wde hivg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MZFgS3Hs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ck21-20020a056a02091500b005bd03d2fda6si9905948pgb.350.2023.11.27.02.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 02:21:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MZFgS3Hs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 9895E8055AF0; Mon, 27 Nov 2023 02:21:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232889AbjK0KUy (ORCPT + 99 others); Mon, 27 Nov 2023 05:20:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232738AbjK0KUx (ORCPT ); Mon, 27 Nov 2023 05:20:53 -0500 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6A1FDC; Mon, 27 Nov 2023 02:20:58 -0800 (PST) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2c871d566cfso44541351fa.3; Mon, 27 Nov 2023 02:20:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701080457; x=1701685257; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ExvmcaBmtMG79z7Iqahkd4y5Qc/HJbGcEwVPJT9+anc=; b=MZFgS3HsGu8hN02OnrAD739hjZvUo5bbZ+zb+pjcWaoRAVPzI/vez81M3Dq/aL52y/ rX9RzmKgZWAphXp56ihKR01nnESRb8zrjQLlvw6cdMQUfoImu0JtkIYnLvWHyijeiGEJ zUUliPlKG8RN8T/hPq6Ro6HgKt6C1Ot3Vy9dFVeSFo0AITIzNyh9yF1hqN2B3i3ywylk aw6rMcou68i7MoMyHM8u6TF+rOr232NL1igxGwcV/qe065MCGesNXosrPxuw8RaU7RDY spyaEQWjjcX1GvQlHjcBZSSkN3h9mmSPqTdAa/QWLure719y+Ai+/KQOdJqQZs0t3JxW 6UdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701080457; x=1701685257; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ExvmcaBmtMG79z7Iqahkd4y5Qc/HJbGcEwVPJT9+anc=; b=skhKKdixggFnKI8TdIV7Xc7D07kn/ztKlshMEm1CPjTcoENM7P6D8xatUQHyTdAxfH BnKKKyqX3uhXJqpbNdx98TnrsicMHJwzYhpWegrVesVhkYd4YbGuAyKsbcha7LrZbwKN hPwCtA4WUxgxOdE4VgjSCHgnICr+GD7rjclCydj066nXMKJ5vSH5d5lZK6uxBSqZBRy0 A2Fl5svV1pvC7JbxOvP//SnEHv2VODY314Jl8yZKUPP6Z9Qe9no3vsj1oUsqsJj0RH/l DMmZ1Z2/CVMBy3pNfAeBFy9Yfyi89Ay8/suwxXtlXfNiU8eQYGiLv+AToepjllF5srJx baqg== X-Gm-Message-State: AOJu0YxHHwuEhCAaprWCG0ZItmeJPPTxs1Bk9YIBci2mMGos09OPi6x5 tXmcKp0cg73/cQER2lbgGa9aF/dqrhh0ig== X-Received: by 2002:a2e:b74c:0:b0:2c9:a707:beb0 with SMTP id k12-20020a2eb74c000000b002c9a707beb0mr837832ljo.3.1701080456752; Mon, 27 Nov 2023 02:20:56 -0800 (PST) Received: from mobilestation ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id z26-20020a2eb53a000000b002bba2da7955sm1305573ljm.132.2023.11.27.02.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 02:20:56 -0800 (PST) Date: Mon, 27 Nov 2023 13:20:53 +0300 From: Serge Semin To: Jianheng Zhang Cc: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Simon Horman , Andrew Halaney , Bartosz Golaszewski , Shenwei Wang , Johannes Zink , "Russell King (Oracle" , Jochen Henneberg , Voon Weifeng , Mohammad Athari Bin Ismail , Ong Boon Leong , Tan Tee Min , "open list:STMMAC ETHERNET DRIVER" , "moderated list:ARM/STM32 ARCHITECTURE" , "moderated list:ARM/STM32 ARCHITECTURE" , open list , Martin McKenny , James Li Subject: Re: [PATCH v2] net: stmmac: fix FPE events losing Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 27 Nov 2023 02:21:22 -0800 (PST) Hi Jianheng On Mon, Nov 27, 2023 at 07:08:17AM +0000, Jianheng Zhang wrote: > > The status bits of register MAC_FPE_CTRL_STS are clear on read. Using > 32-bit read for MAC_FPE_CTRL_STS in dwmac5_fpe_configure() and > dwmac5_fpe_send_mpacket() clear the status bits. Then the stmmac interrupt > handler missing FPE event status and leads to FPE handshaking failure and > retries. > To avoid clear status bits of MAC_FPE_CTRL_STS in dwmac5_fpe_configure() > and dwmac5_fpe_send_mpacket(), add fpe_csr to stmmac_fpe_cfg structure to > cache the control bits of MAC_FPE_CTRL_STS and to avoid reading > MAC_FPE_CTRL_STS in those methods. > > Fixes: 5a5586112b92 ("net: stmmac: support FPE link partner hand-shaking procedure") > Signed-off-by: jianheng Thanks for the fix and taking all my notes and nitpicks into account. Reviewed-by: Serge Semin -Serge(y) > --- > drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 45 +++++++++------------- > drivers/net/ethernet/stmicro/stmmac/dwmac5.h | 4 +- > .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 3 +- > drivers/net/ethernet/stmicro/stmmac/hwif.h | 4 +- > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 +++- > drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 1 + > include/linux/stmmac.h | 1 + > 7 files changed, 36 insertions(+), 30 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c > index e95d35f..8fd1675 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c > @@ -710,28 +710,22 @@ void dwmac5_est_irq_status(void __iomem *ioaddr, struct net_device *dev, > } > } > > -void dwmac5_fpe_configure(void __iomem *ioaddr, u32 num_txq, u32 num_rxq, > +void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, > + u32 num_txq, u32 num_rxq, > bool enable) > { > u32 value; > > - if (!enable) { > - value = readl(ioaddr + MAC_FPE_CTRL_STS); > - > - value &= ~EFPE; > - > - writel(value, ioaddr + MAC_FPE_CTRL_STS); > - return; > + if (enable) { > + cfg->fpe_csr = EFPE; > + value = readl(ioaddr + GMAC_RXQ_CTRL1); > + value &= ~GMAC_RXQCTRL_FPRQ; > + value |= (num_rxq - 1) << GMAC_RXQCTRL_FPRQ_SHIFT; > + writel(value, ioaddr + GMAC_RXQ_CTRL1); > + } else { > + cfg->fpe_csr = 0; > } > - > - value = readl(ioaddr + GMAC_RXQ_CTRL1); > - value &= ~GMAC_RXQCTRL_FPRQ; > - value |= (num_rxq - 1) << GMAC_RXQCTRL_FPRQ_SHIFT; > - writel(value, ioaddr + GMAC_RXQ_CTRL1); > - > - value = readl(ioaddr + MAC_FPE_CTRL_STS); > - value |= EFPE; > - writel(value, ioaddr + MAC_FPE_CTRL_STS); > + writel(cfg->fpe_csr, ioaddr + MAC_FPE_CTRL_STS); > } > > int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) > @@ -741,6 +735,9 @@ int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) > > status = FPE_EVENT_UNKNOWN; > > + /* Reads from the MAC_FPE_CTRL_STS register should only be performed > + * here, since the status flags of MAC_FPE_CTRL_STS are "clear on read" > + */ > value = readl(ioaddr + MAC_FPE_CTRL_STS); > > if (value & TRSP) { > @@ -766,19 +763,15 @@ int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) > return status; > } > > -void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, enum stmmac_mpacket_type type) > +void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, > + enum stmmac_mpacket_type type) > { > - u32 value; > + u32 value = cfg->fpe_csr; > > - value = readl(ioaddr + MAC_FPE_CTRL_STS); > - > - if (type == MPACKET_VERIFY) { > - value &= ~SRSP; > + if (type == MPACKET_VERIFY) > value |= SVER; > - } else { > - value &= ~SVER; > + else if (type == MPACKET_RESPONSE) > value |= SRSP; > - } > > writel(value, ioaddr + MAC_FPE_CTRL_STS); > } > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h > index 53c138d..34e6207 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h > @@ -153,9 +153,11 @@ int dwmac5_est_configure(void __iomem *ioaddr, struct stmmac_est *cfg, > unsigned int ptp_rate); > void dwmac5_est_irq_status(void __iomem *ioaddr, struct net_device *dev, > struct stmmac_extra_stats *x, u32 txqcnt); > -void dwmac5_fpe_configure(void __iomem *ioaddr, u32 num_txq, u32 num_rxq, > +void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, > + u32 num_txq, u32 num_rxq, > bool enable); > void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, > + struct stmmac_fpe_cfg *cfg, > enum stmmac_mpacket_type type); > int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev); > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c > index 453e88b..a74e71d 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c > @@ -1484,7 +1484,8 @@ static int dwxgmac3_est_configure(void __iomem *ioaddr, struct stmmac_est *cfg, > return 0; > } > > -static void dwxgmac3_fpe_configure(void __iomem *ioaddr, u32 num_txq, > +static void dwxgmac3_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, > + u32 num_txq, > u32 num_rxq, bool enable) > { > u32 value; > diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h > index b95d3e1..68aa2d5 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h > +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h > @@ -412,9 +412,11 @@ struct stmmac_ops { > unsigned int ptp_rate); > void (*est_irq_status)(void __iomem *ioaddr, struct net_device *dev, > struct stmmac_extra_stats *x, u32 txqcnt); > - void (*fpe_configure)(void __iomem *ioaddr, u32 num_txq, u32 num_rxq, > + void (*fpe_configure)(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, > + u32 num_txq, u32 num_rxq, > bool enable); > void (*fpe_send_mpacket)(void __iomem *ioaddr, > + struct stmmac_fpe_cfg *cfg, > enum stmmac_mpacket_type type); > int (*fpe_irq_status)(void __iomem *ioaddr, struct net_device *dev); > }; > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index 3e50fd5..7791e9b 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -964,7 +964,8 @@ static void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up) > bool *hs_enable = &fpe_cfg->hs_enable; > > if (is_up && *hs_enable) { > - stmmac_fpe_send_mpacket(priv, priv->ioaddr, MPACKET_VERIFY); > + stmmac_fpe_send_mpacket(priv, priv->ioaddr, fpe_cfg, > + MPACKET_VERIFY); > } else { > *lo_state = FPE_STATE_OFF; > *lp_state = FPE_STATE_OFF; > @@ -5838,6 +5839,7 @@ static void stmmac_fpe_event_status(struct stmmac_priv *priv, int status) > /* If user has requested FPE enable, quickly response */ > if (*hs_enable) > stmmac_fpe_send_mpacket(priv, priv->ioaddr, > + fpe_cfg, > MPACKET_RESPONSE); > } > > @@ -7262,6 +7264,7 @@ static void stmmac_fpe_lp_task(struct work_struct *work) > if (*lo_state == FPE_STATE_ENTERING_ON && > *lp_state == FPE_STATE_ENTERING_ON) { > stmmac_fpe_configure(priv, priv->ioaddr, > + fpe_cfg, > priv->plat->tx_queues_to_use, > priv->plat->rx_queues_to_use, > *enable); > @@ -7280,6 +7283,7 @@ static void stmmac_fpe_lp_task(struct work_struct *work) > netdev_info(priv->dev, SEND_VERIFY_MPAKCET_FMT, > *lo_state, *lp_state); > stmmac_fpe_send_mpacket(priv, priv->ioaddr, > + fpe_cfg, > MPACKET_VERIFY); > } > /* Sleep then retry */ > @@ -7294,6 +7298,7 @@ void stmmac_fpe_handshake(struct stmmac_priv *priv, bool enable) > if (priv->plat->fpe_cfg->hs_enable != enable) { > if (enable) { > stmmac_fpe_send_mpacket(priv, priv->ioaddr, > + priv->plat->fpe_cfg, > MPACKET_VERIFY); > } else { > priv->plat->fpe_cfg->lo_fpe_state = FPE_STATE_OFF; > @@ -7754,6 +7759,7 @@ int stmmac_suspend(struct device *dev) > if (priv->dma_cap.fpesel) { > /* Disable FPE */ > stmmac_fpe_configure(priv, priv->ioaddr, > + priv->plat->fpe_cfg, > priv->plat->tx_queues_to_use, > priv->plat->rx_queues_to_use, false); > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c > index ac41ef4..6ad3e0a 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c > @@ -1079,6 +1079,7 @@ static int tc_setup_taprio(struct stmmac_priv *priv, > > priv->plat->fpe_cfg->enable = false; > stmmac_fpe_configure(priv, priv->ioaddr, > + priv->plat->fpe_cfg, > priv->plat->tx_queues_to_use, > priv->plat->rx_queues_to_use, > false); > diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h > index 0b4658a..dee5ad6 100644 > --- a/include/linux/stmmac.h > +++ b/include/linux/stmmac.h > @@ -175,6 +175,7 @@ struct stmmac_fpe_cfg { > bool hs_enable; /* FPE handshake enable */ > enum stmmac_fpe_state lp_fpe_state; /* Link Partner FPE state */ > enum stmmac_fpe_state lo_fpe_state; /* Local station FPE state */ > + u32 fpe_csr; /* MAC_FPE_CTRL_STS reg cache */ > }; > > struct stmmac_safety_feature_cfg { > -- > 1.8.3.1 > >