Subject: Re: [PATCH] net: phy: don't issue a module request if a driver is available

From: "Russell King (Oracle)" <[email-masked]>
Date: Thu, 2 Jan 2025 11:06:15 +0000

On Thu, Jan 02, 2025 at 12:51:22AM +0100, Francesco Valla wrote:
> Whenever a new PHY device is created, request_module() is called
> unconditionally, without checking if a driver for the new PHY is already
> available (either built-in or from a previous probe). This conflicts
> with async probing of the underlying MDIO bus and always throws a
> warning (because if a driver is loaded it _might_ cause a deadlock, if
> in turn it calls async_synchronize_full()).

Why aren't any of the phylib maintainers seeing this warning? Where does
the warning come from?

> +static bool phy_driver_exists(u32 phy_id)
> +{
> +	bool found = false;
> +	struct phy_drv_node *node;
> +
> +	down_read(&phy_drv_list_sem);
> +	list_for_each_entry(node, &phy_drv_list, list) {
> +		if (phy_id_compare(phy_id, node->drv->phy_id, node->drv->phy_id_mask)) {
> +			found = true;
> +			break;
> +		}
> +	}
> +	up_read(&phy_drv_list_sem);
> +
> +	return found;
> +}
> +

Why do we need this, along with the associated additional memory
allocations? What's wrong with bus_for_each_drv() which the core
code provides?

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!