Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp187636rdb; Thu, 30 Nov 2023 01:56:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFl71FQvM/L+2a++HmmPAGAJei4pS/hY6VeqyQm6BbhB/t9NqP5Li5gl9wHcptkcXm94k8Q X-Received: by 2002:a05:6a20:ba99:b0:18b:30e2:7e55 with SMTP id fb25-20020a056a20ba9900b0018b30e27e55mr21902267pzb.46.1701338168127; Thu, 30 Nov 2023 01:56:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701338168; cv=none; d=google.com; s=arc-20160816; b=FrgyObk/hk33YweF9mEqH6WJk2fw4tmP203VjGUgnCggmgEUxBVQqLdC/umCZEJ15Y mWitVNurHCa8Vxcnf1V3J6kHccSlzuj+ahvK1b4llPbFueis1ngN1OUpd8omNwZy8TfY 9Ztoaawc3s9XxMjtrHDlWCGi5D9t5EQgR+/rnYORhPV0DxfqXGD9z9xdA8Sn3hiXMIJs u3r1QcGf/6clC35XkqH3rAGWI0docBgq3njVHdU7UoPaNOLc4+5z47A41KNgCtJSOZtX UsD1rN9J5kWZZ9nl0PcJ93D/eFId5boHiNYUO8jNggYXoY44t9u8bdk8qEriOGV8od91 aOOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=Za4sJve0w/4uyVCmAF/v91nTDwdldnwMa4Hd6aawqsI=; fh=VBIbLlAyhc9E4MBBbtKPzQY+hov05pZnFhjaiiIohMI=; b=AxFnkaAmmOxh/ynRlvSpDDrDM3g3tV8nFPSaYJRTGcHrAJRYkuVaDCKPoxLDF1qS9V NpIC84I8ffNQhq1U04QA+GNHVPRM+IhDh8kwK5IZBGc3+30NCUvBNOkzquKoC4B9kJVx o326Zy2LQK6zOaa44d3DNQZiJDO4QJqAIAnXPds3HMuEGj90Wok5B4p/zUdXYU29a8dZ 43QhDaZ/pOr9sMcGBFO8ZCL2BX9PQCMCLEMETEfqUUqtOpECWadn7qPLGXWWmuAzQPji C5QtxDostlrYiKa8B/s8mjDc9bj4LBKIIAQIL0Z0uh6z86nJUeGBZf+UL9Kc1CpzCTGb po3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d6ogwTAN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id h12-20020a170902f7cc00b001cc3527145bsi839634plw.29.2023.11.30.01.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 01:56:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d6ogwTAN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3A5EC80843C4; Thu, 30 Nov 2023 01:55:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235118AbjK3Jzg (ORCPT + 99 others); Thu, 30 Nov 2023 04:55:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235105AbjK3Jze (ORCPT ); Thu, 30 Nov 2023 04:55:34 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB17810D4 for ; Thu, 30 Nov 2023 01:55:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701338139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Za4sJve0w/4uyVCmAF/v91nTDwdldnwMa4Hd6aawqsI=; b=d6ogwTANIMa63VjPbYf//XXz2CxtICjO4MA8ZVNqnMz4tOxTPSx9jGf/LuO5TIHOiKIBVm osPbUq0ERSQiiHeTqSaS6od3NISuJhHQKIxiu0323+Z3jOf/9aLlNpyUCO+looVTqlXX/D khHcawX5BCuQzCI/Kxq7Cd4l+oBMBiI= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-GRORk_Y9O1yeoeZyJypJoA-1; Thu, 30 Nov 2023 04:55:38 -0500 X-MC-Unique: GRORk_Y9O1yeoeZyJypJoA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a15ce485c27so9307966b.0 for ; Thu, 30 Nov 2023 01:55:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701338137; x=1701942937; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Za4sJve0w/4uyVCmAF/v91nTDwdldnwMa4Hd6aawqsI=; b=ppO6Jg+4qmC8+ZQy2c8acPt4hSj8qEr4jhyGb6LKZCJM4IrG8uSwmVfa/KFe83IewY UVaOkkrmk3lduUDP0t8crV4/WfTbksJuGGEsV1q2EVnb7ep3QcH+hEtLTLqcBiLwnLtB rrqP2YM5g71pdxbjflD5ppCD3ZM9nUJiZ4gRJRGEbM+hKtHB50Mq7FIazGzvK9wI8Mwe T6+xPaldj6YNSpkFoyXapIjRilHtCXLpHOw52hP+NFBV5E6zG/9ZzEbWwJHGawQioDTg 1ulUO9fzXdOLD3YcFh3ja5tqEypLmiJxdepW5UtR2KcuQX57s5hLDas6n1eYXxwnFVYC ZHpw== X-Gm-Message-State: AOJu0Yx0557jbKTuyaZU6bG7ug0VfhqzG8NTVbClbONWf8GeN4DZJ9Mz yU3cERi6OFyzt+nsAgzIWReqLH/V59TwJEzY8FnKqc0HyDfqRsPys1HlvC7DXQcLUff7QvvJLnl Oyy3FvF6DXm+ng0glLsWbOOoh X-Received: by 2002:a17:906:3a50:b0:9e6:c282:5bd5 with SMTP id a16-20020a1709063a5000b009e6c2825bd5mr13208727ejf.3.1701338137064; Thu, 30 Nov 2023 01:55:37 -0800 (PST) X-Received: by 2002:a17:906:3a50:b0:9e6:c282:5bd5 with SMTP id a16-20020a1709063a5000b009e6c2825bd5mr13208709ejf.3.1701338136699; Thu, 30 Nov 2023 01:55:36 -0800 (PST) Received: from gerbillo.redhat.com (146-241-254-39.dyn.eolo.it. [146.241.254.39]) by smtp.gmail.com with ESMTPSA id q20-20020a170906145400b009fc927023bcsm495253ejc.34.2023.11.30.01.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 01:55:36 -0800 (PST) Message-ID: <1716792a3881338b1a416b1f4dd85a9437746ec2.camel@redhat.com> Subject: Re: [PATCH v3] net: stmmac: fix FPE events losing From: Paolo Abeni To: 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 Cc: "open list:STMMAC ETHERNET DRIVER" , "moderated list:ARM/STM32 ARCHITECTURE" , "moderated list:ARM/STM32 ARCHITECTURE" , open list , James Li , Martin McKenny Date: Thu, 30 Nov 2023 10:55:34 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 30 Nov 2023 01:55:50 -0800 (PST) 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 interrup= t > 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. >=20 > 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(-) >=20 > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/e= thernet/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, st= ruct net_device *dev, > } > } > =20 > -void dwmac5_fpe_configure(void __iomem *ioaddr, u32 num_txq, u32 num_rxq= , > +void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *c= fg, > + u32 num_txq, u32 num_rxq, > bool enable) > { > u32 value; > =20 > - if (!enable) { > - value =3D readl(ioaddr + MAC_FPE_CTRL_STS); > - > - value &=3D ~EFPE; > - > - writel(value, ioaddr + MAC_FPE_CTRL_STS); > - return; > + if (enable) { > + cfg->fpe_csr =3D EFPE; > + value =3D readl(ioaddr + GMAC_RXQ_CTRL1); > + value &=3D ~GMAC_RXQCTRL_FPRQ; > + value |=3D (num_rxq - 1) << GMAC_RXQCTRL_FPRQ_SHIFT; > + writel(value, ioaddr + GMAC_RXQ_CTRL1); > + } else { > + cfg->fpe_csr =3D 0; > } > - > - value =3D readl(ioaddr + GMAC_RXQ_CTRL1); > - value &=3D ~GMAC_RXQCTRL_FPRQ; > - value |=3D (num_rxq - 1) << GMAC_RXQCTRL_FPRQ_SHIFT; > - writel(value, ioaddr + GMAC_RXQ_CTRL1); > - > - value =3D readl(ioaddr + MAC_FPE_CTRL_STS); > - value |=3D EFPE; > - writel(value, ioaddr + MAC_FPE_CTRL_STS); > + writel(cfg->fpe_csr, ioaddr + MAC_FPE_CTRL_STS); > } > =20 > int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) > @@ -741,6 +735,9 @@ int dwmac5_fpe_irq_status(void __iomem *ioaddr, struc= t net_device *dev) > =20 > status =3D FPE_EVENT_UNKNOWN; > =20 > + /* 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 =3D readl(ioaddr + MAC_FPE_CTRL_STS); > =20 > if (value & TRSP) { > @@ -766,19 +763,15 @@ int dwmac5_fpe_irq_status(void __iomem *ioaddr, str= uct net_device *dev) > return status; > } > =20 > -void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, enum stmmac_mpacket_t= ype type) > +void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, struct stmmac_fpe_cfg= *cfg, > + enum stmmac_mpacket_type type) > { > - u32 value; > + u32 value =3D cfg->fpe_csr; > =20 > - value =3D readl(ioaddr + MAC_FPE_CTRL_STS); > - > - if (type =3D=3D MPACKET_VERIFY) { > - value &=3D ~SRSP; > + if (type =3D=3D MPACKET_VERIFY) > value |=3D SVER; > - } else { > - value &=3D ~SVER; > + else if (type =3D=3D MPACKET_RESPONSE) > value |=3D SRSP; > - } > =20 > 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? Thanks Paolo