Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp66238rwl; Thu, 6 Apr 2023 14:56:14 -0700 (PDT) X-Google-Smtp-Source: AKy350YcResLEVlvVmhlzLEjZmd5rsVEW2Wnk6n9inKdCXNj7WFjbEHd6W4KH5Be4/HVgCA9yVvb X-Received: by 2002:a62:1d8c:0:b0:62a:63e6:3282 with SMTP id d134-20020a621d8c000000b0062a63e63282mr336852pfd.11.1680818173775; Thu, 06 Apr 2023 14:56:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680818173; cv=pass; d=google.com; s=arc-20160816; b=VX1xKiZnrVghkVhbFNnuA4TyBJrfBsCr0Gkax8QptTXbzmHERhNtcPtkClhs9D7WFd CnZVDpjxxuCDeStdzbT4sywGrr+vE5WxrkKEZZ2v7MJ/myzyUngEgavroEPkmezHdQ/1 iavDzJnlpFfBGybzxrtpeqwEOp1KO/43gKWLn/2vjF6YS9YuywzAElzUH9N8ohl0UyeN x2+IRuhMCWc5GsIzchKoZrQ2eeZ4G+vpXOVFL+ny1kor3fNU1AKhnM+9pIaKTtljszQF yo2gZkodXffLxYMeSEUc2d5ooPeIu6EGMeNMO/wjrU8iGYMrC0gADtDgRsHdhudz4kDM D+ng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=bVE9spa830jciEurhBWqjwWCocYdpwZjmnytSHBmldo=; b=BD5+knRIN0aBH5yFy+rV5SMIjnYlBvyIfUfO+XfwNHfk5ctnBaUIrhiy4ujBMTJWnh wU5USykHcZPmM/3z0FnOkrZ+TvtwRHeY5csfzn12em//vj0TiIOEDe2175P6wSUtKF7x RldiX5BIE7t6pFuiYcL9XciIYsqq517paHJYAx2OUyNdvGsacMcSoSx9mGb9vQhE8mA7 NN1vogMOoSOjnNstJchL6NgztUTmviCmXohdy1SYzkviKDrLazH+Lm2QuBMPHRhAyqz8 42hnqOJ9ibyLthr0OnYzo8UmcmXj5Z2QU1AAOO5v8ciThMPXAeMslc0P+XkzmGK6Zpcv 1BQw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arinc9.com header.s=zmail header.b=eaZLIFgS; arc=pass (i=1 spf=pass spfdomain=arinc9.com dkim=pass dkdomain=arinc9.com dmarc=pass fromdomain=arinc9.com>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x17-20020aa79411000000b005de484ca9ccsi2262757pfo.149.2023.04.06.14.56.01; Thu, 06 Apr 2023 14:56:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@arinc9.com header.s=zmail header.b=eaZLIFgS; arc=pass (i=1 spf=pass spfdomain=arinc9.com dkim=pass dkdomain=arinc9.com dmarc=pass fromdomain=arinc9.com>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238586AbjDFVoo (ORCPT + 99 others); Thu, 6 Apr 2023 17:44:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjDFVon (ORCPT ); Thu, 6 Apr 2023 17:44:43 -0400 Received: from sender4-op-o10.zoho.com (sender4-op-o10.zoho.com [136.143.188.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FDF59EC5; Thu, 6 Apr 2023 14:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680817429; cv=none; d=zohomail.com; s=zohoarc; b=AlEkeDDLh1S57LcW+MhMjeu5fGJShDPvUxLGxVmhUt27lURr4otlLBohlOkXs69iC5B7c1rzzfZGvGuIwga8LllAiFvf8PwUiFlck3due6dI+cKysFDX02QiRnfbE2J82qeqtbqHcNIcZbJcOFmRu6iO2mx3n9gnR67MSBM8Gxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680817429; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=bVE9spa830jciEurhBWqjwWCocYdpwZjmnytSHBmldo=; b=P6LnP9dNw8GN/wX461OxQzmsSmfr4edLN6CHv6FTR1+beYwmqbILS5ZBwWaDLz/93hIED/TjFDTUX3vzUnHJscjporZyRDrBDAEiOfZWIkRIpWTxrOhvSPs9btp0Fur1YSm0kc1ZXeQNcbX5nEz6Urxe2l374pUrO5+slhX7m5o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=arinc9.com; spf=pass smtp.mailfrom=arinc.unal@arinc9.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1680817429; s=zmail; d=arinc9.com; i=arinc.unal@arinc9.com; h=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:Cc:Cc:References:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=bVE9spa830jciEurhBWqjwWCocYdpwZjmnytSHBmldo=; b=eaZLIFgS5iARc4YQQQEMS+njWNQCN9vINNo1mV+ZjZhd1jo6CUE5F+QcRESC73Wm JCXN9EL2Pob1gjeg5OWY/evfqBmFqJKa9JcJuiW6WfHtuKPffkU8ulG7AYHnnjbXeOT e30Q16TkAydJ8apHkzILBY84Y/StV9AusOs061hg= Received: from [10.10.10.3] (149.91.1.15 [149.91.1.15]) by mx.zohomail.com with SMTPS id 1680817428744230.95149889101833; Thu, 6 Apr 2023 14:43:48 -0700 (PDT) Message-ID: Date: Fri, 7 Apr 2023 00:43:41 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [RFC PATCH net-next] net: dsa: mt7530: fix port specifications for MT7988 Content-Language: en-US To: "Russell King (Oracle)" Cc: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , erkin.bozoglu@xeront.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org References: <20230406100445.52915-1-arinc.unal@arinc9.com> From: =?UTF-8?B?QXLEsW7DpyDDnE5BTA==?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ZohoMailClient: External X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 On 6.04.2023 14:07, Russell King (Oracle) wrote: > On Thu, Apr 06, 2023 at 01:04:45PM +0300, arinc9.unal@gmail.com wrote: >> From: Arınç ÜNAL >> >> On the switch on the MT7988 SoC, there are only 4 PHYs. There's only port 6 >> as the CPU port, there's no port 5. Split the switch statement with a check >> to enforce these for the switch on the MT7988 SoC. The internal phy-mode is >> specific to MT7988 so put it for MT7988 only. >> >> Signed-off-by: Arınç ÜNAL >> --- >> >> Daniel, this is based on the information you provided me about the switch. >> I will add this to my current patch series if it looks good to you. >> >> Arınç >> >> --- >> drivers/net/dsa/mt7530.c | 67 ++++++++++++++++++++++++++-------------- >> 1 file changed, 43 insertions(+), 24 deletions(-) >> >> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c >> index 6fbbdcb5987f..f167fa135ef1 100644 >> --- a/drivers/net/dsa/mt7530.c >> +++ b/drivers/net/dsa/mt7530.c >> @@ -2548,7 +2548,7 @@ static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port, >> phy_interface_zero(config->supported_interfaces); >> >> switch (port) { >> - case 0 ... 4: /* Internal phy */ >> + case 0 ... 3: /* Internal phy */ >> __set_bit(PHY_INTERFACE_MODE_INTERNAL, >> config->supported_interfaces); >> break; >> @@ -2710,37 +2710,56 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, >> struct mt7530_priv *priv = ds->priv; >> u32 mcr_cur, mcr_new; >> >> - switch (port) { >> - case 0 ... 4: /* Internal phy */ >> - if (state->interface != PHY_INTERFACE_MODE_GMII && >> - state->interface != PHY_INTERFACE_MODE_INTERNAL) >> - goto unsupported; >> - break; >> - case 5: /* Port 5, a CPU port. */ >> - if (priv->p5_interface == state->interface) >> + if (priv->id == ID_MT7988) { >> + switch (port) { >> + case 0 ... 3: /* Internal phy */ >> + if (state->interface != PHY_INTERFACE_MODE_INTERNAL) > > How do these end up with PHY_INTERFACE_MODE_INTERNAL ? phylib defaults > to GMII mode without something else being specified in DT. > > Also note that you should *not* be validating state->interface in the > mac_config() method because it's way too late to reject it - if you get > an unsupported interface here, then that is down to the get_caps() > method being buggy. Only report interfaces in get_caps() that you are > prepared to handle in the rest of the system. This is already the case for all three get_caps(). The supported interfaces for each port are properly defined. Though mt7988_mac_port_get_caps() clears the config->supported_interfaces bitmap before reporting the supported interfaces. I don't think this is needed as all bits in the bitmap should already be initialized to zero when the phylink_config structure is allocated. I'm not sure if your suggestion is to make sure the supported interfaces are properly reported on get_caps(), or validate state->interface somewhere else. Arınç