Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3707150rdh; Tue, 28 Nov 2023 01:19:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmPE9PWccCibZfdf/hKGy+gkKmd8taWqAeK+ug07G6WRLaRfPHnCSg/tczbxA0dZXTJJo9 X-Received: by 2002:a17:90a:1a10:b0:281:35e:82a1 with SMTP id 16-20020a17090a1a1000b00281035e82a1mr12263062pjk.48.1701163146824; Tue, 28 Nov 2023 01:19:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701163146; cv=none; d=google.com; s=arc-20160816; b=t+XMMJafVJXaFw17BQjuwimqaHalcW62ajm2gmSoDZxrTAEWikyaAOpv/UPLQhfODK 7OniW7s4y2hwmOjPNP0gA2f1DQBun3zGWxDHk8Yis0kpnCRHQFVVE9zf4het35Ow57fY Of9sUVRWydqtUNtqMLA3ClWu5PPxkoWYN2DtupeQY+YCglzY2cYTf0upR9Sz0CNTqrj3 hsrN1lchvfrs/GpluHuEBV69b5zezY7JvvV7dywCxqh5sjDEB4g6xpntkmtBV17kJI4S HNl4f9dN7BD2y0zdO3YhWLg+5yTfVXnX/bqgoRGhZVJXCQFkaPnQXJ+itOTzj0fDWq2A mg6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=RNvRwnmWbMcsSfw4MtpQ8A6yvzjLtDp5XU7GJHCHcNg=; fh=gunuyfxo9hKaHBFNsg32n9/NJltXdjizHNVtgSTMgqU=; b=MGALI7ACiQBdpERlxKG1Z0Nvzw0VmP1fvxAhPN/oHTJyfi7itTK5X861iRfz2itfCX BHGQ5Ab829q2wskraDPOTHnaEGxgf4Rmv1V8UEzuZyKVt1bBqFOB17bLdBCHbTQ3IPW8 9WU2wJcqG5ZqfVNL89V/peNJS6ui6bMXEkPjjZVoDr2n4GhmsZwjZlP8eLmHmh03lbxd 5PDFWxz9wNUPHKM6oPsP9a6CTkdlcApI2Q0gCQJnHVcftETfggPAaNLQcJjVhNE25m+v v4MA8w3RjCSQqW9yVrXtGsadkIUCeb8LpL4LsrncMVdatbHK0gg2VBwxnfv6h7z7kpq7 Ah9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="cGP/JFSw"; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id c18-20020a170903235200b001d0050e2469si233989plh.26.2023.11.28.01.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 01:19:06 -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=@bootlin.com header.s=gm1 header.b="cGP/JFSw"; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 9AAFD8157DE1; Tue, 28 Nov 2023 01:19:03 -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 S234805AbjK1JSn (ORCPT + 99 others); Tue, 28 Nov 2023 04:18:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234804AbjK1JSl (ORCPT ); Tue, 28 Nov 2023 04:18:41 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBAA0D53; Tue, 28 Nov 2023 01:18:45 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4EE001C000D; Tue, 28 Nov 2023 09:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701163123; 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=RNvRwnmWbMcsSfw4MtpQ8A6yvzjLtDp5XU7GJHCHcNg=; b=cGP/JFSwx72kYNQBXmTul4ItDEpXcm2qsZemcZUUfdQ62v0J+1ZmCtGtsukPTgd9m3/Cx8 SAv+jPBPn1349+noY/O6WWXBhVCuacr4Ja/Ug8c2cl/eMEsbML5lwJtw4o6hjjXelYmc/4 OWObjLP8VDosTxpJuVvUAcfJE3EY8Pw/a4hvsFUaGcV7mDE/P4/6izHG0fQN09wrerBpM4 77Mvw3E/+gaEVNvkg8U10TNasMlECQVIcMN0THLlqGP6vQgjrt6IKfvAsKwUTKtMN5NBRN JNYEOnHm88RD2yhmn2xj781DKV8QYS6O5NnAjM+jmNZWCLWtvOahHBnZ7kCWCw== Date: Tue, 28 Nov 2023 10:18:41 +0100 From: Thomas Petazzoni To: Maxime Chevallier Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski , Eric Dumazet , Paolo Abeni , linux-arm-kernel@lists.infradead.org, Alexandre Torgue , Jose Abreu , Maxime Coquelin , Simon Horman , linux-stm32@st-md-mailman.stormreply.com, alexis.lothore@bootlin.com Subject: Re: [PATCH net] net: stmmac: dwmac-socfpga: Don't access SGMII adapter when not available Message-ID: <20231128101841.627fc97e@windsurf> In-Reply-To: <20231128094538.228039-1-maxime.chevallier@bootlin.com> References: <20231128094538.228039-1-maxime.chevallier@bootlin.com> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-GND-Sasl: thomas.petazzoni@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=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 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]); Tue, 28 Nov 2023 01:19:03 -0800 (PST) On Tue, 28 Nov 2023 10:45:37 +0100 Maxime Chevallier wrote: > The SGMII adapter isn't present on all dwmac-socfpga implementations. > Make sure we don't try to configure it if we don't have this adapter. > > Fixes: 5d1f3fe7d2d5 ("net: stmmac: dwmac-sogfpga: use the lynx pcs driver") > Signed-off-by: Maxime Chevallier > --- > drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c > index ba2ce776bd4d..ae120792e1b6 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c > @@ -243,7 +243,8 @@ static void socfpga_sgmii_config(struct socfpga_dwmac *dwmac, bool enable) > { > u16 val = enable ? SGMII_ADAPTER_ENABLE : SGMII_ADAPTER_DISABLE; > > - writew(val, dwmac->sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG); > + if (dwmac->sgmii_adapter_base) > + writew(val, dwmac->sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG); > } > > static int socfpga_set_phy_mode_common(int phymode, u32 *val) Reviewed-by: Thomas Petazzoni As a follow-up improvement, there's an open-coded version of socfpga_sgmii_config() in socfpga_dwmac_fix_mac_speed(), which could be rewritten as such: socfpga_sgmii_config(dwmac, false); if (splitter_base) { val = readl(splitter_base + EMAC_SPLITTER_CTRL_REG); val &= ~EMAC_SPLITTER_CTRL_SPEED_MASK; switch (speed) { case 1000: val |= EMAC_SPLITTER_CTRL_SPEED_1000; break; case 100: val |= EMAC_SPLITTER_CTRL_SPEED_100; break; case 10: val |= EMAC_SPLITTER_CTRL_SPEED_10; break; default: return; } writel(val, splitter_base + EMAC_SPLITTER_CTRL_REG); } if (phy_dev) socfpga_sgmii_config(dwmac, true); But of course, that's not a fix so it should be a separate improvement. Best regards, Thomas -- Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com