Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp290262rdb; Thu, 25 Jan 2024 15:58:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IF935DiRRZgt8cUffGl6cPIbnwwLalGim+qHE80dfgyqzlPSMGnxx1qo7KUj3VLoxPSVGIJ X-Received: by 2002:aa7:9d0d:0:b0:6da:fc2b:5a88 with SMTP id k13-20020aa79d0d000000b006dafc2b5a88mr490109pfp.15.1706227106663; Thu, 25 Jan 2024 15:58:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706227106; cv=pass; d=google.com; s=arc-20160816; b=KiSjksY7jsGA9ir8v8UBcqmrAB7zNk6mwzpaUNP8WZVNCF2uSrakEqApHm1dZhvuBd sZ2IztSbgNg1XZpOaT+bEL3kaOfV4VyXPPLqeIr+AEzGfSABObEHfTPSYtfM2aNdLYpB VoYuIYwdzfDD0DaVi26sayQzQ6ijv1E/LbwmShQAOxkd3xGoAE1fCKRmuYcky8mWi9Ai Fx/ihGwZyron3IaBe4JtuiaSQfzYdRG9CpJ7+g/7v2Ay7Bs5nOZ4Cl9IWyb8ZDAKMNw1 od5uMFpR9qdzmLUBAdtPeFYNH2NBzrycCU9HuQQ2dNWovVrVBTuPdHnpozgUJSO0zJzO ptFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date; bh=9Lq35s46nc0G7M0MQuqZQ6tiP8YXZWYe33yy0EF4R9A=; fh=PSKt2T4ahRfeHNrfWWgfUhD9RL/5yirZATNH1iGDwvY=; b=iS35PRsf0y2hYaSVpvfUPAYQw+4ufL81HOlVpLzt3Th/zHeTtqUBx4dWtCC4mSTN9w zUomEgtRe7+igCc0AjSgX5c7v2A6tAmZb0tKwN3d2RUY+hoqOq3zbMtaJDa9cIr8pveC Ng+Kz9QlWfAOg8BIUEcEHEfGI5Rp1cycI01I9KzH1RFzbSJ9EkkwouXP8n54HCQul33+ IrByuQ/knvaKDaw5YTqqRHWQyU1E/jXQM6Z5dNjxc2NG/kitZqtoxKzF4tEX7aJJg3vR LVHecgk4oSvKzlLJvLTLb9+C0JMeTUFXJ3uaI2HgcfbnckbN8At5sZjQzR0qkvmWHYQ+ zfPg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=makrotopia.org); spf=pass (google.com: domain of linux-kernel+bounces-39428-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39428-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l186-20020a6391c3000000b005ce05e5d57asi87670pge.660.2024.01.25.15.58.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 15:58:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39428-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=makrotopia.org); spf=pass (google.com: domain of linux-kernel+bounces-39428-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39428-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 44FF828FDB3 for ; Thu, 25 Jan 2024 23:58:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 852091A29C; Thu, 25 Jan 2024 23:57:37 +0000 (UTC) Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B53818C38; Thu, 25 Jan 2024 23:57:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706227056; cv=none; b=KKWPfYuLYtEj/0rvnSEVrqYHfF1WzujPQY8L8J9BsmAzF4qr7zPbiBjkSnPB88EKPDoMtv3CyPyr98ha+TrasUPw8tkDGoMzGRChykd16obPiER0sK2D4hXSsxvs4uvrEHu9xMKqTR2yoK6VGGHO67c9gLOJ0zkBj0zCXw8CYUc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706227056; c=relaxed/simple; bh=HVwNsG4ex09BIiqCIlusj2ZhDSWkoJndoDRFh/vuS4Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=H/qsBRoe31+4qgrRPXCNDhYpj7V7/NDt7DSpvupOQDv2e/vHKUHDYNXrleT0iAV8oL5XRs5VjJ120EoRgYdtGggWhepKmRTl3qoHtnxBgis8dEQMTyKCf3rPkyx/gIY/KaJBseRg7TJ8tdLOV9RW3W19wQh3AL8k7mx4+s7GmwA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96.2) (envelope-from ) id 1rT9ax-0005RZ-26; Thu, 25 Jan 2024 23:57:19 +0000 Date: Thu, 25 Jan 2024 23:57:08 +0000 From: Daniel Golle To: =?utf-8?B?QXLEsW7DpyDDnE5BTA==?= Cc: DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, John Crispin Subject: Re: [PATCH net] net: dsa: mt7530: fix 10M/100M speed on MT7988 switch Message-ID: References: <99a038f3-18d2-44ca-8135-1faf7a37892a@arinc9.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <99a038f3-18d2-44ca-8135-1faf7a37892a@arinc9.com> On Fri, Jan 26, 2024 at 01:44:57AM +0300, Arınç ÜNAL wrote: > On 25.01.2024 19:18, Daniel Golle wrote: > > On Thu, Jan 25, 2024 at 12:49:19PM +0300, Arınç ÜNAL wrote: > > > On 24/01/2024 08:17, Daniel Golle wrote: > > > > Setup PMCR port register for actual speed and duplex on internally > > > > connected PHYs of the MT7988 built-in switch. This fixes links with > > > > speeds other than 1000M. > > > > > > > > Fixes: ("110c18bfed414 net: dsa: mt7530: introduce driver for MT7988 built-in switch") > > > > Signed-off-by: Daniel Golle > > > > > > Acked-by: Arınç ÜNAL > > > > > > I'm wondering why we manually set speed and duplex for these interface > > > modes in the first place. I don't how it works for > > > PHY_INTERFACE_MODE_INTERNAL but, at least for PHY_INTERFACE_MODE_TRGMII and > > > 802.3z interfaces, phylink should already supply proper speed and duplex. > > > > It's true that duplex should always be set to full-duplex already by > > phylink. However, speed could be 2500MBit/s (2500Base-X) or 2000MBit/s > > (?, TRGMII) and we yet need to program the PCR like if it was > > 1000MBit/s. > > > > Regarding the INTERNAL case: it was added by mistake. In case of > > MT7988, all ports of the switch are connected via INTERNAL links, > > however, the PHYs still need adjustment of the PCR register just like > > on all other MT753x switches and the CPU port is setup elsewhere > > anyway. > > It's not necessarily PHYs needing adjustment of the port MAC control > register. It's not the PHYs which need adjustment but the MAC PMCR register which does. > After reset, speed, duplex mode, etc. will be determined by polling > the PHY connected to the switch MAC. Yes, but as it is a DSA driver we don't use **hardware** PHY polling and keep that off. Instead, PHY interrupts or software PHY polling is used to have Linux determine the link properties. We're then forcing these properties on the MAC port of the switch. > on the PMCR because we're also configuring switch MACs that are not > connected to PHYs, meaning the switch cannot determine these properties by > polling a PHY. The switch **never** determines these properties itself when using the DSA driver. It has a facility to do so, and yes, when accessing Ethernet in U-Boot or when using the 'swconfig'-based driver then this facility is used. But, I repeat, when using DSA we do not use hardware PHY polling. We poll (or rather: react to interrupts) in software instead. > > From what I understand, this code block is for overriding the speed and > duplex variables to make the operations on the PMCR below work. It seems > that this is actually only useful for PHY_INTERFACE_MODE_2500BASEX. > PHY_INTERFACE_MODE_TRGMII is given SPEED_1000 by > drivers/net/phy/phylink.c:phylink_interface_max_speed(). > PHY_INTERFACE_MODE_2500BASEX is given SPEED_2500. Overriding the duplex > variable looks unnecessary. > > Your patch here doesn't affect CPU ports because MT7531 and MT7988 PMCRs This patch does not intend to affect the CPU port. As I've already said in my previous reply "[...] the CPU port is setup elsewhere anyway." Maybe it wasn't clear, but I meant that the CPU port settings are intentionally unaffected by this patch. It is intended to affect user ports which with phy-mode = "internal"; set in DTS -- here we **do** need to set PMCR according the external link speed and duplex. > are configured with cpu_port_config before mt753x_phylink_mac_link_up(), > and PHY_INTERFACE_MODE_INTERNAL is not used for MT7530 which, for MT7530, > PMCRs will be set only on mt753x_phylink_mac_link_up(). > > PMCR_FORCE_SPEED_1000 is set on cpu_port_config. If someone were to get rid > of cpu_port_config because of its utter uselessness, PMCR_FORCE_SPEED_1000 > would not be set, causing the link between port 6 MAC and SoC MAC to break. > > In conclusion, I will add "case SPEED_10000:" to the operations where the > speed and EEE bits are set on my patch for getting rid of cpu_port_config. PMCR needs to be set according to actual link speed for built-in TP PHYs. This is true for all mt7530 variants including MT7988. Maybe the confusion here is that on MT7988 we use 'internal' phy-mode for both, the switch CPU port's link to mtk_eth_soc gmac0 as well as the links to the 4 built-in 1GE switch PHYs. The latter were affected by wrongly overriding speed and duplex in case phy-mode is set to "internal", which should not have been put there (by me) in first place. Let's just remove it, ok?