Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp292584rdb; Thu, 30 Nov 2023 05:10:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQ1Bp3uMu/2KDCyeux04cS+tYgHPwCjpApV59h9zhABr9ciRf2QHmjLPnZpHudXrFAxjqh X-Received: by 2002:a05:6a20:c189:b0:189:7c2:508d with SMTP id bg9-20020a056a20c18900b0018907c2508dmr24194630pzb.12.1701349801115; Thu, 30 Nov 2023 05:10:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701349801; cv=none; d=google.com; s=arc-20160816; b=IAcPMHIhN7Tu5lnerFaoRgh28PO1n8h/n33GY9NUCNmr3y29Sw+W7ZhrtwdylYq+k8 3P2CgaCjrmTislygqzpZz9A69Kq+4LQ/bcORlxbydNvXcTFFz2vF2VPqcQH6oWiJyvog oy8SFuNYlooTIAADXvkoA8jATjt8EiiXKYa1pwXn8ouLQR9QjEOZil0PiQoqViiDG2fg VVYMQZ5o/AOtTxhMWyL7EVuatFZ+73ezH+6TejsPWtClUc6EAK7wpReuii/Qb4ehxCiS ScWHAe0hosP5AQ9UUty+rA8rrLapV278e509K1yAc8r6SqN88qLombG4WM7LptRBHPzB F2zg== 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=da5ufd57tWXpSlzE4MME0kb6SHbAqME3sLaJIDhv8Ic=; fh=MJpuNz4CR3Bo7ridKdGnXKES0qIsIAcJSN/XMZL7y1M=; b=0Nea+u2Z2Gg/pwNtVQK1lJN14pHKr8nRzSC/dja2gMv5UpOKavRqitxV14hy8AvvSI AkBSfr9coR4FCONiYKf9lPWHseCnDKpcgBe1+OTRuJpdisGJ+bvVfgoHC5DVR2kS8IYN xq+tTop981Yr2SZEUwBWnKp1w7h2oeJktpwC5ywjJvV2NxfysCbtIBi6Dau+zA+gxnSu PsqoNsHoWTNEw0cG0QxkkBR5C5sSSDFfXKUVluAB25x5r38n/fTShKfXmGoovCWxZasC 0ViDE+2w56m8KaSHQ8sV9ae+NI7dTZDf3XZP+jhG5wShofMvYnzKZGsRlNq+TTkBue+g m2GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Im/ArFDm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id w128-20020a636286000000b005b403446f1dsi1254833pgb.129.2023.11.30.05.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:10:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Im/ArFDm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 40CD8823D9FF; Thu, 30 Nov 2023 05:09:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345484AbjK3NJj (ORCPT + 99 others); Thu, 30 Nov 2023 08:09:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231990AbjK3NJi (ORCPT ); Thu, 30 Nov 2023 08:09:38 -0500 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 405CDD6C; Thu, 30 Nov 2023 05:09:44 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2c9bd3557cfso11929841fa.3; Thu, 30 Nov 2023 05:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701349782; x=1701954582; 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=da5ufd57tWXpSlzE4MME0kb6SHbAqME3sLaJIDhv8Ic=; b=Im/ArFDmlashnh2nGY5Pas2Jh2A+H02BvSG1THKpQ6YPT5lGkhe0u1QwA8kId/KdnT QwGsM+Le4By0z2U/CYkcvss52d/1nhScJYsa9WO4MuNT84qdRY6rBZKu1rJOQc69pfmb 8ZsZfiho8J9SMGk5DGrxxR6vJIzaUBBnZkao6HQSMm58X6e7c6PeEoGU8DU9ILOjFnPb lkdvwzZsd7cPBh37amTLRsLGO9vw/4/W7SX5+MyUw4nbVmboXBmpaYH9qwo2tAw7NnwX mAEnU1229VqxOcV30rzAfDbZqckdUuGy9e4z0b0tqzKZHt5FpDbQcfgWssofgxtfqhZf e1cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701349782; x=1701954582; 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=da5ufd57tWXpSlzE4MME0kb6SHbAqME3sLaJIDhv8Ic=; b=l0mvxam3MwkSlMHaaRdjPQtHp+K5w9iUdfiHJGAVtyuLlPkziV2xKS8vv5IH+4lVOB wfII4C0hNxFydHKX534KMtdbVKSSQvwlu1mY1dGgc65UiO3Ha8qHXG2I+AtZq8A8Ivko 1bVprhfP8Zqy0jv2M55CqjE6BbjfaX8y7MgUkJbvl4np2VZN4fWTadQmyiwMzaVIwiOo iBjl/MnwjWrJoRB3w0w9qPKpgWmQiU/lhIL597z/+KbvFoayoJO47L+zvUzbxdN4DrbC QYfPZA3ZJImddcxkaiRX/B73SD8Uhk1ha13EACJn5s/GzRE+DX8Ecy7K3EPvh9QGl9bh m2Hw== X-Gm-Message-State: AOJu0YyUriVqbNaWOPemfLVlHCHSEXdzeldK3kW98Dy1dinjmtfMdAB7 uVMJO6f1n+BpZPpF8i6mwzQ= X-Received: by 2002:a05:6512:284:b0:50b:bf57:7d6 with SMTP id j4-20020a056512028400b0050bbf5707d6mr4813341lfp.6.1701349782003; Thu, 30 Nov 2023 05:09:42 -0800 (PST) Received: from mobilestation ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id g15-20020a19e04f000000b0050bbd1feb5bsm165331lfj.199.2023.11.30.05.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:09:41 -0800 (PST) Date: Thu, 30 Nov 2023 16:09:37 +0300 From: Serge Semin To: Paolo Abeni Cc: Jianheng Zhang , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , 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 , James Li , Martin McKenny Subject: Re: [PATCH v3] net: stmmac: fix FPE events losing Message-ID: <5djt72m664jtskz4i7vu63cqpb67o4qeu2roqb6322slsypwos@vmf4n2emdazd> References: <1716792a3881338b1a416b1f4dd85a9437746ec2.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1716792a3881338b1a416b1f4dd85a9437746ec2.camel@redhat.com> 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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 30 Nov 2023 05:09:57 -0800 (PST) Hi Paolo On Thu, Nov 30, 2023 at 10:55:34AM +0100, Paolo Abeni wrote: > On Tue, 2023-11-28 at 05:56 +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") > > Reviewed-by: Serge Semin > > Signed-off-by: Jianheng Zhang > > --- > > 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); > > } > > It's unclear to me why it's not necessary to preserve the SVER/SRSP > bits across MAC_FPE_CTRL_STS writes. I guess they are not part of the > status bits? perhaps an explicit comment somewhere will help? The SRSP and SVER are self-cleared flags with no effect on zero writing. Their responsibility is to emit the Respond and Verify mPackets respectively. As soon as the packets are sent, the flags will be reset by hardware automatically. So no, they aren't a part of the status bits. Note since 'value' now isn't read from the MAC_FPE_CTRL_STS register, there is no point in clearing up these flags in the local variable because 'value' has now them cleared by default. Not sure whether a comment about that is required, since the described behavior is well documented in the Synopsys HW-manual. -Serge(y) > > Thanks > > Paolo > >