Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp2019640lqa; Tue, 30 Apr 2024 06:23:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjCYMdk201dL97Lb7IejDSmCXCl27WSdomEz8louUHi2lpT2X6dSiOtw8H9RxEcLQneYGV3mqCRGWUnI1wSdCJ9aj4qTt7DNfL1K2U9A== X-Google-Smtp-Source: AGHT+IEzWzIoViXPAtwmG6v8fvyma4LG9xKNk1ozdYpSsOHneXRBxnTZkdy/5MXvOBD5nkcjOs5p X-Received: by 2002:a9d:7305:0:b0:6ea:2a7c:2900 with SMTP id e5-20020a9d7305000000b006ea2a7c2900mr12684175otk.25.1714483410901; Tue, 30 Apr 2024 06:23:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714483410; cv=pass; d=google.com; s=arc-20160816; b=Gzx6ZN230QzMh0JBS1I7maiOFSeaAGifNZVGBnP/JTYpHId5PxpAoehDKl3ex8YUAb XW+Ak3bPsqASXjM9IjOtKiOUjcTiH4CIDYDjivSwqF/4UXET3vrtoXBTy06acW7MA5fQ AgVLMttcgFji2w4R0DLkqfyWOYxDcvJWnYVYdO5G5c/nnGsYCjnZxzQ2Z3sTR4cCx0f9 1+z8/stHQ7nXwHiRG5/o/0bO/4ER093isfL1tgbppQrTL5VXkyn+QLPIYQyZVng7eY0b 78BytL7YR5QUtG3++hUNcjMkUh11wr+MjTrQbfyZW1i4sMqPPFMbYbyGv+p2iPxjn5mg n2Qw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=TwVm5+lnEYg5CEZ7tfzTszScGuXmoWaijPkjxaNJWew=; fh=4EWlNDj7Sp3A0Cqf4f+n2REgHPfSU51D/0YZzTraScw=; b=HrX4eS7/3401uI65uEBxWqZsmX1IGAHTbIJ6gEqKNYznaQKauBqI9LFWrRyUJ3f+qt pq/k4bQb/w7AOPMrQLgmM3iriyYOpSEu58RXrPhXqHhT2m2D7M8bGmbCbpXEQZbqBGMN kdt0G+CfB1RHFL0BSDzLs0+uQP2UY2kaBbJwI2wfSnMLF6rr7mNdJCMNegmaEyYFyYLI ffVJlwZ5hW9jVJPbUGwyZzZsaGdMrOwgou/TZeJGOFRXP56V5EAp6sudBQDkhmWqHJDR oD0A8iQ5SUb7Rg9mVBrOKonIAgZgQsfdlbBHV/m8eU3K+JPNZOFcpbJWUVR9vnxrgKdB twPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=hNdLY11M; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-163994-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163994-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id xy18-20020a05620a5dd200b0078f12b1596fsi28222697qkn.388.2024.04.30.06.23.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 06:23:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163994-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=hNdLY11M; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-163994-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163994-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8FADB1C22359 for ; Tue, 30 Apr 2024 13:23:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6611B172793; Tue, 30 Apr 2024 13:22:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="hNdLY11M" Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (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 5BAB5171E4F; Tue, 30 Apr 2024 13:22:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714483325; cv=none; b=L6vA0SAPB6zTgImiTkkVbkWv7kpSm0d6tTg5wMg9udr/Fg4kFdNrorVP8h+npxjydbwwaaBdUhNnl5JGgUVuY1nwkjeiONAc8HnnNaRzEmQ8Pkb57mYU7Q+8DCv+xFJKXznyDFRScZY7b/MKEsMF9R0/qHTkS9Ujwu5AfKy7sfQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714483325; c=relaxed/simple; bh=645CpjS+rCjcVeG1uX0G0Qqrq6Dq/rXy/+NHAKfbJ1I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gYmtxjWSMcMpDF5ZZK8dOD264GfAq3yyYgSiUR/7Hlxlor8JNDz3hg1rmSsl5poL6wF8xQNP0cMM4mvVMjx3FkFuAS4V4yNulXx6153PIQ6HUMt4+98q1MJAn/XswXiVCp2Nzgp4wK5FhhE3CDrQsyQL28baf3xEhclfDG/QPuE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=hNdLY11M; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=TwVm5+lnEYg5CEZ7tfzTszScGuXmoWaijPkjxaNJWew=; b=hNdLY11MBVwiLcsj/KLRRRmmP/ +UY3ZGxIEL2VvFBxE/WLExR1zJyiE6LBbzELdBA+fc3Uwl75f4ReqFshL4Nn3ECoBUEYCT3QXFn75 e4dRXSSCQt4hJtfgwWr2fwAkSx8FAErl5RBYCgAxH2oThySmZ6C0A36rYLwesuviP2mY=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1s1nQM-00EL6Y-Kn; Tue, 30 Apr 2024 15:21:34 +0200 Date: Tue, 30 Apr 2024 15:21:34 +0200 From: Andrew Lunn To: Daniel Golle Cc: =?utf-8?B?QXLEsW7DpyDDnE5BTA==?= , Felix Fietkau , Rob Herring , Krzysztof Kozlowski , Conor Dooley , DENG Qingfang , Sean Wang , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Landen Chao , devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH net] net: dsa: mt7530: fix impossible MDIO address and issue warning Message-ID: References: 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=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Apr 30, 2024 at 12:45:46AM +0100, Daniel Golle wrote: > The MDIO address of the MT7530 and MT7531 switch ICs can be configured > using bootstrap pins. However, there are only 4 possible options for the > switch itself: 7, 15, 23 and 31 (ie. only 3 and 4 can be configured, bit > 0~2 are always 111). Practically all boards known as of today use the > default setting which is to have the switch respond to address 31, while > the built-in switch PHYs respond to address 0~4 in this case. > > However, even in MediaTek's SDK the address of the switch is wrongly > stated in the device trees as 0 (while in reality it is 31), so warn the > user about such broken device tree and make a good guess what was > actually intended. > > This is imporant to not break compatibility with older Device Trees as > with commit 868ff5f4944a ("net: dsa: mt7530-mdio: read PHY address of > switch from device tree") the address in device tree will be taken into > account. Doing so instead of assuming the switch is always at > address 31 which was previously hard-coded will obviously break things > for many existing downstream device trees as they contain the wrong > address (0) which previously didn't matter. > > Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch") > Signed-off-by: Daniel Golle > --- > drivers/net/dsa/mt7530-mdio.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/net/dsa/mt7530-mdio.c b/drivers/net/dsa/mt7530-mdio.c > index fa3ee85a99c1..119630fd9060 100644 > --- a/drivers/net/dsa/mt7530-mdio.c > +++ b/drivers/net/dsa/mt7530-mdio.c > @@ -193,6 +193,19 @@ mt7530_probe(struct mdio_device *mdiodev) > return PTR_ERR(priv->io_pwr); > } > > + /* Only MDIO bus address 7, 15, 23 and 31 are valid options */ > + if (~(priv->mdiodev->addr & 0x7) & 0x7) { > + /* If the address in DT must be wrong, make a good guess about > + * the most likely intention, and issue a warning. > + */ > + int correct_addr = ((((priv->mdiodev->addr - 7) & ~0x7) % 0x20) + 7) & 0x1f; > + > + dev_warn(&mdiodev->dev, > + "impossible switch MDIO address in device tree: %d, assuming %d\n", > + priv->mdiodev->addr, correct_addr); You could include FW_WARN in this, to indicate this is a firmware issue. It is not used too much with DT, since it was originally intended for ACPI issues, but a few ARM systems use it with DT. Andrew