Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753283AbdLOGzN (ORCPT ); Fri, 15 Dec 2017 01:55:13 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:26899 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752642AbdLOGzL (ORCPT ); Fri, 15 Dec 2017 01:55:11 -0500 X-UUID: 3fcd032ccebe417999eccd61b45b5a35-20171215 Message-ID: <1513320903.28444.65.camel@mtkswgap22> Subject: [net-next] phylib: Add device reset GPIO support causes DSA MT7530 acquires reset-gpios fails From: Sean Wang To: , , , CC: , , , , , Date: Fri, 15 Dec 2017 14:55:03 +0800 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6120 Lines: 136 Hi Sergei, Recently I found the patch commit bafbdd527d56 (phylib: Add device reset GPIO support) would have the impact on MT7530 driver. Which causes the DSA MT7530 device (it's the child node under mdio bus) gets the reset-gpios fails because the same GPIO seems already be held in the earlier mdiobus_register_device call patched through the commit. do you have any idea how the commits also considers DSA case ? I guessed the DSA lan9303, mv88e8 switch should have the same issue since they have the same GPIO name as mdiobus_register_device required. drivers/net/dsa/lan9303-core.c:1303: chip->reset_gpio = devm_gpiod_get_optional(chip->dev, "reset", drivers/net/dsa/mv88e6xxx/chip.c:3936: chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); drivers/net/dsa/mt7530.c:1476: priv->reset = devm_gpiod_get_optional(&mdiodev->dev, "reset", Below is the stack dump I added in of_get_named_gpiod_flags call. Which apparently shows mdiobus_register_device would get gpio at first and then DSA driver does. [ 2.570607] [] (show_stack) from [] (dump_stack +0x98/0xac) [ 2.577779] [] (dump_stack) from [] (of_get_named_gpiod_flags+0xe8/0x128) [ 2.586239] [] (of_get_named_gpiod_flags) from [] (fwnode_get_named_gpiod+0x5c/0xd0) [ 2.595648] [] (fwnode_get_named_gpiod) from [] (mdiobus_register_device+0x64/0xa8) [ 2.604969] [] (mdiobus_register_device) from [] (mdio_device_register+0x34/0x8c) [ 2.614119] [] (mdio_device_register) from [] (of_mdiobus_register+0x150/0x2c8) [ 2.623097] [] (of_mdiobus_register) from [] (mtk_probe+0x6a4/0x820) [ 2.631128] [] (mtk_probe) from [] (platform_drv_probe+0x5c/0xc0) [ 2.638898] [] (platform_drv_probe) from [] (driver_probe_device+0x2f4/0x4d8) [ 2.647702] [] (driver_probe_device) from [] (__driver_attach+0x10c/0x128) [ 2.656248] [] (__driver_attach) from [] (bus_for_each_dev+0x78/0xac) [ 2.664364] [] (bus_for_each_dev) from [] (driver_attach+0x2c/0x30) [ 2.672307] [] (driver_attach) from [] (bus_add_driver+0x1e0/0x278) [ 2.680250] [] (bus_add_driver) from [] (driver_register+0x88/0x108)would [ 2.688277] [] (driver_register) from [] (__platform_driver_register+0x50/0x58) [ 2.697256] [] (__platform_driver_register) from [] (mtk_driver_init+0x24/0x28) [ 2.706234] [] (mtk_driver_init) from [] (do_one_initcall+0x50/0x17c) [ 2.714351] [] (do_one_initcall) from [] (kernel_init_freeable+0x154/0x1f4) [ 2.722984] [] (kernel_init_freeable) from [] (kernel_init+0x18/0x124) [ 2.731185] [] (kernel_init) from [] (ret_from_fork+0x14/0x2c) [ 2.738719] of_get_named_gpiod_flags: parsed 'reset-gpios' property of node '/ethernet@1b100000/mdio-bus/switch@0[0]' - status (0) [ 2.750631] mt7530 mdio-bus:00: GPIO lookup for consumer reset [ 2.756443] mt7530 mdio-bus:00: using device tree for GPIO lookup [ 2.762494] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.15.0-rc2-00819-g4d89425-dirty #6 [ 2.770514] Hardware name: Mediatek Cortex-A7 (Device Tree) [ 2.776049] [] (unwind_backtrace) from [] (show_stack+0x20/0x24) [ 2.783733] [] (show_stack) from [] (dump_stack +0x98/0xac) [ 2.790901] [] (dump_stack) from [] (of_get_named_gpiod_flags+0xe8/0x128) [ 2.799359] [] (of_get_named_gpiod_flags) from [] (of_find_gpio+0x70/0xfc) [ 2.807903] [] (of_find_gpio) from [] (gpiod_get_index+0xac/0x2a0) [ 2.815759] [] (gpiod_get_index) from [] (devm_gpiod_get_index+0x5c/0x98) [ 2.824220] [] (devm_gpiod_get_index) from [] (devm_gpiod_get_optional+0x20/0wouldx34) [ 2.833370] [] (devm_gpiod_get_optional) from [] (mt7530_probe+0x170/0x1a0) [ 2.842003] [] (mt7530_probe) from [] (mdio_probe +0x40/0x64) [ 2.849342] [] (mdio_probe) from [] (driver_probe_device+0x2f4/0x4d8) [ 2.857455] [] (driver_probe_device) from [] (__device_attach_driver+0xc8/0x144) [ 2.866518] [] (__device_attach_driver) from [] (bus_for_each_drv+0x70/0xa4)geert+renesas@glider.be [ 2.875235] [] (bus_for_each_drv) from [] (__device_attach+0xc0/0x150) [ 2.883434] [] (__device_attach) from [] (device_initial_probe+0x1c/0x20) [ 2.891893] [] (device_initial_probe) from [] (bus_probe_device+0x94/0x9c) [ 2.900440] [] (bus_probe_device) from [] (device_add+0x374/0x5c0) [ 2.908297] [] (device_add) from [] (mdio_device_register+0x44/0x8c) [ 2.916326] [] (mdio_device_register) from [] (of_mdiobus_register+0x150/0x2c8) [ 2.925302] [] (of_mdiobus_register) from [] (mtk_probe+0x6a4/0x820) and the related dts I used is as below would mdio: mdio-bus { #address-cells = <1>; #size-cells = <0>; switch@0 { compatible = "mediatek,mt7530"; #address-cells = <1>; #size-cells = <0>; reg = <0>; reset-gpios = <&pio 33 0>; core-supply = <&mt6323_vpa_reg>; io-supply = <&mt6323_vemc3v3_reg>; ports { #address-cells = <1>; #size-cells = <0>; reg = <0>; port@0 { reg = <0>; label = "wan"; }; Sean