Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2072583iof; Tue, 7 Jun 2022 18:51:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8rS++MaeVBSRL54lfIVSP2z6jvgyF+jjJz0KONjxWt7+4jOA+l4Qwg9hvrnpX7VqjAnj8 X-Received: by 2002:a63:86c3:0:b0:3fd:9c06:ee37 with SMTP id x186-20020a6386c3000000b003fd9c06ee37mr13529275pgd.357.1654653061887; Tue, 07 Jun 2022 18:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654653061; cv=none; d=google.com; s=arc-20160816; b=S0bgrdfkVDgm/S1UGoNRcOzISSFavp5BnV+2mYk+6wTEQ/PKWV03vAaT2ltMtqn07Y NbsDnMGSRcGzEefz/mb3oDJpKrU6ocLK8J4634kOSgKbIe+Tiw8DWMwlGxfTpdLUBh/K V7znWJwZUoqOCJnOTpjK3hwQqe7p++WigC7R1eqqvmK189WMuVcrNPyI37FdArGXqPYU 9OKaSUpMNWi2FIp349C0vaI8hIrbHptmDH5ddUw7E98fQ0GoLAkPaap0yAwa8HBzu2EG L27CnpI5z83ZclTmQ64KyFsdoc0cBRMhDUOjrXWd3JdjE78BJntdw1U3RnxbfWpBOz2T M68w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Hf1jc2du12TaQ+e4X7BuWjrmUs1aIjYSqtWkFD5qagY=; b=nWaeYoFm1d3OzpKe5JXzxgtfQnUXKGRNRKsrpWBrezxVIk6JJgqjF/gfzlnuwSx6Nu EBKPXXSb2Bkz7RAJiuqCAxAwlVNjQGTT6yjTkyEs76eThe26Y8sP/lDJeUvWJCutkIlM MHIf3TVMW9eKCDtVLgFr7KIWt+5Xm5QNVDrM8aKQEncEQLcrRlr0DFTBDduuUAg6xAZ6 Xl5KZRbUxmRSQp00gxRbXcDfVgRGOfud0aC9mBPRmJjtX/nK31rDR5cZ+Y8MXPs+mcAb eOrw3yOMNajZdPtMH4EvNOGsQzX7NfN3CVWp2DjBKlWUvWJALLZORGS9HAuLcxIxrKvy xfqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@pqrs.dk header.s=google header.b=g0RwDCzm; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id a193-20020a6390ca000000b003fdf7e8b368si5309707pge.278.2022.06.07.18.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 18:51:01 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@pqrs.dk header.s=google header.b=g0RwDCzm; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4084F2CDB0D; Tue, 7 Jun 2022 18:35:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383234AbiFGWBa (ORCPT + 99 others); Tue, 7 Jun 2022 18:01:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379167AbiFGVCI (ORCPT ); Tue, 7 Jun 2022 17:02:08 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0A69188EAB for ; Tue, 7 Jun 2022 11:46:44 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id kq6so23966550ejb.11 for ; Tue, 07 Jun 2022 11:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Hf1jc2du12TaQ+e4X7BuWjrmUs1aIjYSqtWkFD5qagY=; b=g0RwDCzmZvnD1xCt3VnYuZhl/AWtldB3ALD6hW4OFq3z4SpjCZt5npFzx3rTDpgTot qGdMrHlbN2eOawV4Xdr8qaH2EKlMnOCNc5YvTP/X8rADjPgMqAlKUlhtqSi3MFvjAtBJ y7drJXyG191FFsXHCD8yGbaUoiW0XsGSDf6yw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Hf1jc2du12TaQ+e4X7BuWjrmUs1aIjYSqtWkFD5qagY=; b=BiYwLWTcJrDBp/+crMiz6NHt6LLyYLTxsyXn0NaRo4G9o72gcGoRw47j38fNjeObbE +utKWfCWeLNlY1MdTlbiXJX1et4OB5GIP6+cAI3J0/K66WhTqx7MheS52t17MzW1yivr CovwDOH6amHtWhlzulzlWmrTsbob6FM10SkrURM1QdarDhU+E5tcLrE5ka1BUATh4Ijw ehbbFvBM5YGBiQmSyw0HdxxZVRQLdn2QuAvJv87ixEcqHnZpeuqjg8qhILb/HKzWbtFc YsIazaNEk6ADd6jPrgsNTQ+LBdVzJUxZVh8/K4nF6rx4g1hDYSk6/2gkRup44KfRFfw1 uTRA== X-Gm-Message-State: AOAM533BvBGqbMw8pXPQFOhc8n+Fd+DWi3ykO542VXP/5trRUdUks0dG cWOwMzChKJGojzUobOAUSngVqQ== X-Received: by 2002:a17:907:7b86:b0:711:d2c8:ab18 with SMTP id ne6-20020a1709077b8600b00711d2c8ab18mr9788400ejc.580.1654627602945; Tue, 07 Jun 2022 11:46:42 -0700 (PDT) Received: from localhost.localdomain (80.71.142.18.ipv4.parknet.dk. [80.71.142.18]) by smtp.gmail.com with ESMTPSA id y18-20020a056402171200b0042dc0181307sm10839131edu.93.2022.06.07.11.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 11:46:42 -0700 (PDT) From: =?UTF-8?q?Alvin=20=C5=A0ipraga?= To: luizluca@gmail.com, Linus Walleij , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , "Russell King (Oracle)" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v2] net: dsa: realtek: rtl8365mb: fix GMII caps for ports with internal PHY Date: Tue, 7 Jun 2022 20:46:24 +0200 Message-Id: <20220607184624.417641-1-alvin@pqrs.dk> X-Mailer: git-send-email 2.36.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alvin Šipraga Since commit a18e6521a7d9 ("net: phylink: handle NA interface mode in phylink_fwnode_phy_connect()"), phylib defaults to GMII when no phy-mode or phy-connection-type property is specified in a DSA port node of the device tree. The same commit caused a regression in rtl8365mb whereby phylink would fail to connect, because the driver did not advertise support for GMII for ports with internal PHY. It should be noted that the aforementioned regression is not because the blamed commit was incorrect: on the contrary, the blamed commit is correcting the previous behaviour whereby unspecified phy-mode would cause the internal interface mode to be PHY_INTERFACE_MODE_NA. The rtl8365mb driver only worked by accident before because it _did_ advertise support for PHY_INTERFACE_MODE_NA, despite NA being reserved for internal use by phylink. With one mistake fixed, the other was exposed. Commit a5dba0f207e5 ("net: dsa: rtl8365mb: add GMII as user port mode") then introduced implicit support for GMII mode on ports with internal PHY to allow a PHY connection for device trees where the phy-mode is not explicitly set to "internal". At this point everything was working OK again. Subsequently, commit 6ff6064605e9 ("net: dsa: realtek: convert to phylink_generic_validate()") broke this behaviour again by discarding the usage of rtl8365mb_phy_mode_supported() - where this GMII support was indicated - while switching to the new .phylink_get_caps API. With the new API, rtl8365mb_phy_mode_supported() is no longer needed. Remove it altogether and add back the GMII capability - this time to rtl8365mb_phylink_get_caps() - so that the above default behaviour works for ports with internal PHY again. Fixes: 6ff6064605e9 ("net: dsa: realtek: convert to phylink_generic_validate()") Signed-off-by: Alvin Šipraga --- v1 -> v2: - no code changes - added more detail in the commit description after Luiz and Russel's help finding commit a18e6521a7d9 --- drivers/net/dsa/realtek/rtl8365mb.c | 38 +++++++---------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c index 3bb42a9f236d..769f672e9128 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -955,35 +955,21 @@ static int rtl8365mb_ext_config_forcemode(struct realtek_priv *priv, int port, return 0; } -static bool rtl8365mb_phy_mode_supported(struct dsa_switch *ds, int port, - phy_interface_t interface) -{ - int ext_int; - - ext_int = rtl8365mb_extint_port_map[port]; - - if (ext_int < 0 && - (interface == PHY_INTERFACE_MODE_NA || - interface == PHY_INTERFACE_MODE_INTERNAL || - interface == PHY_INTERFACE_MODE_GMII)) - /* Internal PHY */ - return true; - else if ((ext_int >= 1) && - phy_interface_mode_is_rgmii(interface)) - /* Extension MAC */ - return true; - - return false; -} - static void rtl8365mb_phylink_get_caps(struct dsa_switch *ds, int port, struct phylink_config *config) { - if (dsa_is_user_port(ds, port)) + if (dsa_is_user_port(ds, port)) { __set_bit(PHY_INTERFACE_MODE_INTERNAL, config->supported_interfaces); - else if (dsa_is_cpu_port(ds, port)) + + /* GMII is the default interface mode for phylib, so + * we have to support it for ports with integrated PHY. + */ + __set_bit(PHY_INTERFACE_MODE_GMII, + config->supported_interfaces); + } else if (dsa_is_cpu_port(ds, port)) { phy_interface_set_rgmii(config->supported_interfaces); + } config->mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD; @@ -996,12 +982,6 @@ static void rtl8365mb_phylink_mac_config(struct dsa_switch *ds, int port, struct realtek_priv *priv = ds->priv; int ret; - if (!rtl8365mb_phy_mode_supported(ds, port, state->interface)) { - dev_err(priv->dev, "phy mode %s is unsupported on port %d\n", - phy_modes(state->interface), port); - return; - } - if (mode != MLO_AN_PHY && mode != MLO_AN_FIXED) { dev_err(priv->dev, "port %d supports only conventional PHY or fixed-link\n", -- 2.36.0