Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1753629rdb; Sat, 23 Dec 2023 23:37:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1dNSjRL0661bP3PJJOP4LstCJMvcuvSpoGBEvWXMIKstvE7fz0f3DNxSvEFw+8HgdNVh6 X-Received: by 2002:a05:6402:5bc4:b0:550:e014:5254 with SMTP id gy4-20020a0564025bc400b00550e0145254mr2094994edb.27.1703403479565; Sat, 23 Dec 2023 23:37:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703403479; cv=none; d=google.com; s=arc-20160816; b=tt/qmUPFRQx2/80EgqtTsxGsJJiwZOqlterq3TEFEWfSMy/HWmVobbxA2VF/U3rU2a /M4WgaE8O0S6rBRQTwDOH8WJu/WWhI6hd2Gh4CnWhqt9gbgsoJh4HTeKMfB+gssZK1+O oQAMhp+oAucfwb5QnGenqGnIVBQifDKJX3OYcI9Hzh80jLfkSJsA/gHUhNkrm4j3uQ30 zTXAGYvcjtOrnK5p4YgmzZO1VNyZ4O2klDoUQX/5ADBV9En437IKDQsjuZC85El+Ul3q i+hrNRvG0eaSORWK+q0vbaqlgkQ8wEMwHHvAc/Pzs6qVu+nJ9ymaGvZFUJam0DO/4KkC Lt8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=iJeCIB0MUy6a0K9bJwBkE5sgfhPIDLdWREiwE76A+mY=; fh=Y7sDK4dAMzybLgU2e34hIo4cM3LenhoC5YveU2yhsQQ=; b=wM/cGX89segXIEs0/hpEbxgVzfrziPOp1TG6E9Clt2GrJg5YcSh2OaaiMYbBKXYUzs lSZl/tnQ9qxJUeJAMes0zZSvjPIdQ2JJpqIH+3AoHpXY9uNq8xUpNgFamh1BvrD5a0N0 klHqP7BtlQ6KT+a+I97n0hDqF2yLuYffRUcabKRiaqKWcHT9PHeet5RogKC4UO9VQD+3 2wwosJKbwTBbewU9ZxrVTj2ytAHHYnw8dp945ImZ0phzPKT2Utvj6R3Kk/LAuMq7V3+R e4MBiPkZ7tnGsvQ8SmgeOJpzwzWpNRMajYjK9bWvJbopUc2IhwdCQcxQE4K1r4CPwhHF DBfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arinc9.com header.s=gm1 header.b=YVheBZkd; spf=pass (google.com: domain of linux-kernel+bounces-10650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10650-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arinc9.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dm5-20020a05640222c500b0055462f1ef9esi2074104edb.33.2023.12.23.23.37.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 23:37:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@arinc9.com header.s=gm1 header.b=YVheBZkd; spf=pass (google.com: domain of linux-kernel+bounces-10650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10650-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arinc9.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id C7C051F21869 for ; Sun, 24 Dec 2023 07:37:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 417CD15CF; Sun, 24 Dec 2023 07:37:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arinc9.com header.i=@arinc9.com header.b="YVheBZkd" X-Original-To: linux-kernel@vger.kernel.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 3CD5A10F8; Sun, 24 Dec 2023 07:37:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arinc9.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arinc9.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 77AFCE0002; Sun, 24 Dec 2023 07:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arinc9.com; s=gm1; t=1703403455; 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=iJeCIB0MUy6a0K9bJwBkE5sgfhPIDLdWREiwE76A+mY=; b=YVheBZkd+rhv1Xtb3FKA22bt980BBrx4xCqK/81PQCTxpyc5Wk49AigoBhuQ9fKYYlW1p0 IIWVefIMrIamZxJF/PY8MnLwj/iknBUDOSFyLFEtFD5elyOcEaKd+kRR2ct9f3If72F+YI EXZI3H0bUn0o/VGWn5C9ADlUaYxmfAfQgil1ZVNUVzibym7PA4Gug4OltqiagqG8khm0D+ kYJarMXArnOvwAcGrUVo/6izvnHh07Pkbu/VU+vh7fLZhDoc2fcvtou8y7k9CjEO21qxME lQVIzqBJ5Hsl5LNUWGVinF5UWhaYk4r/3uKFLW25b8Za7R+mY5++YahAwiNfDg== Message-ID: <6600c6b1-2230-4963-940c-8b95a01750fd@arinc9.com> Date: Sun, 24 Dec 2023 10:37:12 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next] net: dsa: mt7530: register OF node for internal MDIO bus To: Vladimir Oltean Cc: Daniel Golle , Landen Chao , DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , David Bauer , mithat.guner@xeront.com, 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: <20231220173539.59071-1-arinc.unal@arinc9.com> <20231220173539.59071-1-arinc.unal@arinc9.com> <20231221151607.ujobhh4aet4obxdz@skbuf> Content-Language: en-US From: =?UTF-8?B?QXLEsW7DpyDDnE5BTA==?= In-Reply-To: <20231221151607.ujobhh4aet4obxdz@skbuf> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-GND-Sasl: arinc.unal@arinc9.com On 21.12.2023 18:16, Vladimir Oltean wrote: > On Wed, Dec 20, 2023 at 07:35:39PM +0200, Arınç ÜNAL wrote: >> From: David Bauer >> >> The MT753x switches provide a switch-internal MDIO bus for the embedded >> PHYs. >> >> Register a OF sub-node on the switch OF-node for this internal MDIO bus. >> This allows to configure the embedded PHYs using device-tree. >> >> Signed-off-by: David Bauer >> Signed-off-by: Daniel Golle >> Signed-off-by: Arınç ÜNAL >> --- > > Can you please not assign "bus" to ds->user_mii_bus unless there is no > "mdio" OF node? We don't need ds->user_mii_bus populated when it is > described in device tree. Do you mean like this: diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 391c4dbdff42..d239462a4bd8 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2155,15 +2155,21 @@ mt7530_setup_mdio(struct mt7530_priv *priv) { struct dsa_switch *ds = priv->ds; struct device *dev = priv->dev; + struct device_node *np, *mnp; struct mii_bus *bus; static int idx; int ret; + np = priv->dev->of_node; + mnp = of_get_child_by_name(np, "mdio"); + bus = devm_mdiobus_alloc(dev); if (!bus) return -ENOMEM; - ds->user_mii_bus = bus; + if (mnp == NULL) + ds->user_mii_bus = bus; + bus->priv = priv; bus->name = KBUILD_MODNAME "-mii"; snprintf(bus->id, MII_BUS_ID_SIZE, KBUILD_MODNAME "-%d", idx++); @@ -2177,7 +2183,8 @@ mt7530_setup_mdio(struct mt7530_priv *priv) if (priv->irq) mt7530_setup_mdio_irq(priv); - ret = devm_mdiobus_register(dev, bus); + ret = devm_of_mdiobus_register(dev, bus, mnp); + of_node_put(mnp); if (ret) { dev_err(dev, "failed to register MDIO bus: %d\n", ret); if (priv->irq) If the MDIO bus of the switch is defined on the devicetree, the (!ds->user_mii_bus && ds->ops->phy_read) check in dsa_switch_setup will be true so the MDIO bus will be attempted to be registered again, resulting in a kernel panic. [ 1.369012] mt7530-mdio mdio-bus:1f: MT7530 adapts as multi-chip module [ 1.391552] CPU 0 Unable to handle kernel paging request at virtual address 00000700, epc == 802eb948, ra == 802eb938 [ 1.402205] Oops[#1]: [ 1.404481] CPU: 0 PID: 26 Comm: kworker/u5:1 Not tainted 6.7.0-rc6-next-20231222-00012-g9997041f4e67-dirty #281 [ 1.414622] Hardware name: UniElec U7621-06 (16M flash) [ 1.419829] Workqueue: events_unbound deferred_probe_work_func [ 1.425664] $ 0 : 00000000 00000001 00000011 00000700 [ 1.430895] $ 4 : 00000700 814d0000 00000000 00000000 [ 1.436123] $ 8 : 00000001 00000011 00000011 81595a80 [ 1.441353] $12 : 81595a80 81595ad8 81595a80 81595ad8 [ 1.446585] $16 : 81589a80 00000000 82019000 81589600 [ 1.451815] $20 : 807d4a88 8205a280 00000005 00000000 [ 1.457045] $24 : 00000000 802efd60 [ 1.462274] $28 : 81594000 81595c18 80760000 802eb938 [ 1.467505] Hi : 00000000 [ 1.470371] Lo : 00000000 [ 1.473235] epc : 802eb948 mt753x_setup+0x39c/0x3bc [ 1.478283] ra : 802eb938 mt753x_setup+0x38c/0x3bc [ 1.483324] Status: 11000403 KERNEL EXL IE [ 1.487508] Cause : 4080000c (ExcCode 03) [ 1.491502] BadVA : 00000700 [ 1.494367] PrId : 0001992f (MIPS 1004Kc) [ 1.498446] Process kworker/u5:1 (pid: 26, threadinfo=(ptrval), task=(ptrval), tls=00000000) [ 1.506853] Stack : 7fffffff 00000000 8205a280 00000000 806a8ab8 81589a80 8205a280 81521f00 [ 1.515224] 81521f08 8157dc00 806ba49c 8205a280 00000001 804c6374 81589e00 81589c80 [ 1.523601] 806a5ed0 81589600 00000000 81595c9c 805cab30 806d0000 8069e96c 806b99cc [ 1.531971] 00000006 00000dc0 ffffffff 802bd188 81589600 802bd29c fffffff4 fffffff4 [ 1.540341] 8205a480 807d339c 00000000 00000000 00000000 00000000 00000000 00000000 [ 1.548707] ... [ 1.551150] Call Trace: [ 1.553583] [<802eb948>] mt753x_setup+0x39c/0x3bc [ 1.558286] [<804c6374>] dsa_register_switch+0x924/0xcc4 [ 1.563592] [<802ddad0>] mdio_probe+0x34/0x6c [ 1.567943] [<802b95d0>] really_probe+0x16c/0x2dc [ 1.572639] [<802b995c>] driver_probe_device+0x40/0xd0 [ 1.577767] [<802b9a4c>] __device_attach_driver+0x60/0xe8 [ 1.583154] [<802b7694>] bus_for_each_drv+0xc8/0xf4 [ 1.588042] [<802b9d8c>] __device_attach+0xd8/0x14c [ 1.592912] [<802b831c>] bus_probe_device+0x48/0xd8 [ 1.597788] [<802b8f5c>] deferred_probe_work_func+0xb4/0xcc [ 1.603348] [<8003ab1c>] process_scheduled_works+0x1dc/0x2b8 [ 1.609015] [<8003b1b0>] worker_thread+0x2dc/0x330 [ 1.613804] [<80041d4c>] kthread+0xf8/0x100 [ 1.617996] [<80002a18>] ret_from_kernel_thread+0x14/0x1c [ 1.623385] [ 1.624869] Code: 8ea30030 00042080 00641821 26310001 1636fff1 00003825 1000ff67 02803025 [ 1.634638] [ 1.636435] ---[ end trace 0000000000000000 ]--- Arınç