From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796347397; b=VGeNWjedJMnlhe8Fm8r7W3rULfOkoT0MzYkOQ+tm4I+hooBgV/ofPUuQiG0Y8wVT10FT /LWceCco8lxijKrep0gpilJEqUP7RnW0blzsjJJ1+vciEZEvUg/UUU1gmjg61dSwZqwhf 6wFC2T7Z8u8F1sZw6uGecYmZ5HKv5tNcGuJ8eBJDeMvXraMk8RlW7AYt8JhxWjJc8aIZU UQnjp8yfXsU2OxUdexStyVaEQbq9E5Ro+PCFrcyYwl2ord53rBHGCrxWYLeg0OuCNpOYi v1LU+pDw1LZIQNeiV2yu2pQ6HGwNNPxEpFZWUNeWjPw6Ct0qrsu/IBIpI579wTtwtSQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796347397; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=c6iXZTbIGwPnr8nrsDrdbA0jTMs0w8KQiV3Lmg/N1xg=; b=nIhFkqkv/xcdG09mGUHOBOmwsTpUwKymUfYPyBUKKSa+PIVKweYRkswtjSTrqwdcI0k5 qBYGjz4IdbQdXNrFdUxnXSjcERmzHcjpva14GixA8u8bPmngHpbqBbTbLClKRCGkr8yPx 9siKK2lEzRO8ygFD1ZthbrJZmHVm2BBS4JgZXbCqcGxiEZnrL/NPZI/2zHncMkgEZJJNz L4H/5JX+mQH7Bk0KjbZ3eoawwKNw6h3OSnEE2toOELnOURjIK77o75suU4oXpUS5f4uog EZWUaQkCh5PpFUVztHrbVdVQG8yJTp8kUYv4qMLxgBjlnq5imMFm3eBnO9xhlX4rhKg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PBn9DFE0; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFC40606A32C for ; Fri, 4 Dec 2026 01:23:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PBn9DFE0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 192FB1F000C2; Fri, 4 Dec 2026 01:23:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796347397; bh=c6iXZTbIGwPnr8nrsDrdbA0jTMs0w8KQiV3Lmg/N1xg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=PBn9DFE03YkoSH+dmMo0kKjcacjNmabufpUpegMdvTDR6FyjR5QSpOV9aR4+6978e ar0msw5teKGF41Le00JW/ozN347M0bE9RZnSoXx6XQV6b3wI4BA4yhWim7JvCC0FmM 85bw+NL0BJZknqLotMtlVTLMVrmQOyBNIHNp7ouT2dW09knASQ8h3Vk6BkO8R9OcKW PEyqZt8YiQhW0NndcyAosHRa8pHOjJcwbFREG8/OrwmKZ2DCFZOncY4PJ7WCSQMUm0 XcZvk9WwxWppqTyeHGIlErqAJVXElZ+drIJ5b1xDxK8oaCOhpbyNU8Yy6l1yymMJDg UNlGwfnYGk5UQ== Subject: Re: [PATCH v2 3/3] net: use dev_err_probe() for MDIO bus registration errors From: netdev-bot+sashiko@kernel.org To: 18255117159@163.com Cc: andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, netdev@vger.kernel.org Date: Fri, 04 Dec 2026 01:23:16 +0000 Message-ID: <179634739656.3146.5446342040655643355@kernel.org> In-Reply-To: <20261201042302.846523-4-18255117159@163.com> References: <20261201042302.846523-4-18255117159@163.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 4 · Low: 2 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The commit message says the patch stops callers that propagate the error from printing a misleading message on every -EPROBE_DEFER. - [Medium] The patch converts xemaclite_mdio_setup() to dev_err_probe(), but its only caller, xemaclite_of_probe(), ignores the return value:… - [Medium] eth: fbnic: dev_err_probe() in fbnic_mdiobus_create() with dropped error - [Medium] net: hns3: dev_err_probe() in hclge_mac_mdio_config() outside probe - [Low] rtl83xx_setup_user_mdio() is a shared helper, and this patch converted its error print to dev_err_probe(). - [Low] Several converted DSA call sites run from ds->ops->setup rather than from their own device's probe: mv88e6xxx_mdio_register() via… -- net: use dev_err_probe() for MDIO bus registration errors This converts the error prints after mdiobus_register(), of_mdiobus_register() and devm_mdiobus_register() in many network drivers to dev_err_probe(). The goal is that -EPROBE_DEFER no longer produces an error-level message on every deferral. Callers that run before netdev registration, or that drop the error, are meant to keep their existing prints. > net: use dev_err_probe() for MDIO bus registration errors > > Several callers of mdiobus_register(), of_mdiobus_register() and > devm_mdiobus_register() log the error with dev_err()/netdev_err() or > similar. When __mdiobus_register() returns -EPROBE_DEFER, the callers > that propagate the error would otherwise print a misleading message on > every defer. [Severity: Medium] Is this goal met for all the helpers converted here? Several of them are wrapped by a caller that prints its own unconditional dev_err() when the helper fails. A deferred probe therefore still logs at error level on every retry, and only the inner, more detailed message is silenced. The ksz_mdio_register() callers are ksz8463_setup() and ksz8_setup() in ksz8.c, and ksz9477_setup() in ksz9477.c: ret = ksz_mdio_register(dev); if (ret < 0) { dev_err(dev->dev, "failed to register the mdio"); lan937x_setup() does the same after lan937x_mdio_register(). rtl8365mb_setup() after rtl83xx_setup_user_mdio(): ret = rtl83xx_setup_user_mdio(ds); if (ret) { dev_err(priv->dev, "could not set up MDIO bus\n"); mlxbf_gige_probe() after mlxbf_gige_mdio_probe(), which also prints the -EPROBE_DEFER value: dev_err(priv->dev, "probe: mdio_probe failed: %pe\n", ERR_PTR(err)); spl2sw_probe() after spl2sw_mdio_init(): dev_err(&pdev->dev, "Failed to initialize mdio bus!\n"); tn40_probe() after tn40_mdiobus_init(): dev_err(&pdev->dev, "failed to initialize mdio bus.\n"); -EPROBE_DEFER can reach these callers in two ways: - ksz_mdio_register() returns it when of_mdio_find_bus() fails. - __mdiobus_register() returns it when devm_gpiod_get_optional(&bus->dev, "reset") defers, for a DT bus whose GPIO provider has not probed yet. For OF buses, __of_mdiobus_register() also passes through child PHY registration errors other than -ENODEV. Should these outer dev_err() calls be converted to dev_err_probe() as well, or dropped now that the helper reports the error? [ ... ] > diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c > index 425fd2d22c289..bbbe524016077 100644 > --- a/drivers/net/dsa/mv88e6xxx/chip.c > +++ b/drivers/net/dsa/mv88e6xxx/chip.c > @@ -3896,7 +3896,7 @@ static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip, > > err = of_mdiobus_register(bus, np); > if (err) { > - dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err); > + dev_err_probe(chip->dev, err, "Cannot register MDIO bus\n"); > mv88e6xxx_g2_irq_mdio_free(chip, bus); > goto out; > } [Severity: Medium] The commit message says callers that "drop the error and continue" keep their existing dev_err() calls. Isn't fbnic_mdiobus_create() one of those? Its only caller, fbnic_probe(), does not propagate the error: if (fbnic_mdiobus_create(fbd)) goto init_failure_mode; and init_failure_mode always returns 0, so that devlink stays registered for firmware updates: init_failure_mode: dev_warn(&pdev->dev, "Probe error encountered, entering init ..."); ... return 0; A deferral here therefore never leads to a retry. With dev_err_probe(), an -EPROBE_DEFER from devm_mdiobus_register() is logged only at debug level, and -ENOMEM is not logged at all. That leaves only the generic init failure mode warning, with nothing saying that the MDIO bus is the reason networking is unavailable. The old message also printed the errno, which is now gone for those cases. On -EPROBE_DEFER, dev_err_probe() also kasprintf()s a reason into fbd->dev->p->deferred_probe_reason. fbnic_probe() returns 0, so the device is never on the deferred list and driver_deferred_probe_del() never clears the reason. device_release() does not free it either, so the string leaks. Should fbnic_mdiobus_create() keep dev_err() with the errno, in line with the exclusion described in the commit message? [Severity: Low] Does dev_err_probe() attach the deferral reason to the right device here? mv88e6xxx_mdio_register() runs from mv88e6xxx_setup(), which is ds->ops->setup, not from the probe of chip->dev itself. The same applies to ksz_mdio_register(), lan937x_mdio_register(), mt7530_setup_mdio(), vsc9959_mdio_bus_alloc(), vsc9953_mdio_bus_alloc() and rtl83xx_setup_user_mdio(). In a multi-switch DSA tree, dsa_tree_setup() runs setup for every switch from the probe of whichever switch completes the tree last: dsa_switch_probe(B) dsa_tree_setup() A's ds->ops->setup() dev_err_probe(A's dev, -EPROBE_DEFER, ...) The driver core defers only B, but device_set_deferred_probe_reason() kasprintf()s a reason string onto the private data of A's device. A is never on the deferred list, so driver_deferred_probe_del() never clears the string. device_release() also frees the device private data without freeing deferred_probe_reason. Each retry frees the previous string before storing a new one, but the last string is leaked. devices_deferred also shows B with no reason, while the reason is stored on A. [ ... ] > diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c > index ad42c05d0a88d..913220827fae7 100644 > --- a/drivers/net/dsa/realtek/rtl83xx.c > +++ b/drivers/net/dsa/realtek/rtl83xx.c > @@ -120,8 +120,8 @@ int rtl83xx_setup_user_mdio(struct dsa_switch *ds) > > ret = devm_of_mdiobus_register(priv->dev, bus, mdio_np); > if (ret) { > - dev_err(priv->dev, "unable to register MDIO bus %s\n", > - bus->id); > + dev_err_probe(priv->dev, ret, "unable to register MDIO bus %s\n", > + bus->id); > goto err_put_node; > } [Severity: Medium] Is hclge_mac_mdio_config() always reached from the probe of mdio_bus->parent? It is called from hclge_init_ae_dev(), which is the init_ae_dev callback of the hclge ae_algo, and hns3.ko and hclge.ko are separate modules. Suppose hns3_probe() runs before hclge.ko is loaded. Then hnae3_register_ae_dev() only adds the ae_dev to hnae3_ae_dev_list, and the PCI probe completes. Later, hclge_init() calls hnae3_register_ae_algo(), which runs init_ae_dev() for the pending devices from module_init and drops the error: ret = ae_algo->ops->init_ae_dev(ae_dev); if (ret) { dev_err(&ae_dev->pdev->dev, "init ae_dev error, ret = %d\n", ret); continue; } On that path an -EPROBE_DEFER from mdiobus_register() never leads to a retry. dev_err_probe() still demotes the message naming the MDIO bus to debug level, and for -ENOMEM it logs nothing. Only the outer generic message with the errno remains. On -EPROBE_DEFER, dev_err_probe() also kasprintf()s a deferred probe reason onto hdev->pdev->dev. That device is already bound and is never placed on the deferred list. driver_deferred_probe_del() never clears the reason and device_release() does not free it, so the string leaks and never shows up in devices_deferred. Should this call site keep dev_err(), since hclge_init_ae_dev() is not guaranteed to run in the probe context of this device? [Severity: Low] rtl83xx_setup_user_mdio() is also called from rtl8366rb_setup(), which turns any failure into -ENODEV: ret = rtl83xx_setup_user_mdio(ds); if (ret) { dev_err(priv->dev, "could not set up MDIO bus\n"); return -ENODEV; } Suppose devm_of_mdiobus_register() returns -EPROBE_DEFER, for example because the reset-gpios provider on the mdio node has not probed yet. The driver core sees -ENODEV and never retries. dev_err_probe() now logs the message naming the bus only at debug level. It also stores a deferred-probe reason on priv->dev. That device is never on the deferred list, so the reason never appears in devices_deferred. Could this leave a permanent probe failure with only the generic "could not set up MDIO bus" line, and nothing showing that a deferral caused it? The -ENODEV conversion predates this patch, but losing the error-level message on that path is new. [ ... ] > diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c > index 4719d40a63ba3..8c24690f26b56 100644 > --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c > +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c > @@ -862,7 +862,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev) > rc = of_mdiobus_register(bus, np); > of_node_put(np); > if (rc) { > - dev_err(dev, "Failed to register mdio bus.\n"); > + dev_err_probe(dev, rc, "Failed to register mdio bus.\n"); > goto err_register; > } [Severity: Medium] The commit message says callers that "drop the error and continue; those keep their existing dev_err()/netdev_err() calls". However, the only caller of xemaclite_mdio_setup() ignores its return value: xemaclite_of_probe() { ... xemaclite_mdio_setup(lp, &ofdev->dev); ... } of_mdiobus_register() can return -EPROBE_DEFER here, either from a deferred reset GPIO in __mdiobus_register() or from a child PHY registration in __of_mdiobus_register(). In that case the probe continues and the netdev is registered without its MDIO bus. The only error-level message about this is now dev_dbg. dev_err_probe() also kasprintf()s a reason into ofdev->dev.p->deferred_probe_reason. The probe succeeds, so the device is never on the deferred list and driver_deferred_probe_del() never clears the reason. device_release() does not free it either, so the string leaks. Should this call site keep dev_err(), in line with the exclusion described in the commit message? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201042302.846523-1-18255117159%40163.com