netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	David Miller <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next] net: phy: check return code when requesting PHY driver module
Date: Tue, 15 Jan 2019 22:43:27 +0100	[thread overview]
Message-ID: <20190115214327.GD26788@lunn.ch> (raw)
In-Reply-To: <7943c933-c353-1c0e-14c0-cdbb4d874d0a@gmail.com>

On Tue, Jan 15, 2019 at 09:33:52PM +0100, Heiner Kallweit wrote:
> When requesting the PHY driver module fails we'll bind the genphy
> driver later. This isn't obvious to the user and may cause, depending
> on the PHY, different types of issues. Therefore check the return code
> of request_module() and inform the user in case of failure.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/net/phy/phy_device.c | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index a2423cbb2..1527ed0f2 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -548,6 +548,17 @@ static const struct device_type mdio_bus_phy_type = {
>  	.pm = MDIO_BUS_PHY_PM_OPS,
>  };
>  
> +static void phy_request_driver_module(struct phy_device *dev, int phy_id)
> +{
> +	int ret;
> +
> +	ret = request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT,
> +			     MDIO_ID_ARGS(phy_id));
> +	if (IS_ENABLED(CONFIG_MODULES) && ret < 0)
> +		phydev_err(dev, "error %d loading PHY driver module for ID 0x%08x\n",
> +			   ret, phy_id);
> +}
> +
>  struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,
>  				     bool is_c45,
>  				     struct phy_c45_device_ids *c45_ids)
> @@ -610,12 +621,10 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,
>  			if (!(c45_ids->devices_in_package & (1 << i)))
>  				continue;
>  
> -			request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT,
> -				       MDIO_ID_ARGS(c45_ids->device_ids[i]));
> +			phy_request_driver_module(dev, c45_ids->device_ids[i]);

Hi Heiner

I'm not sure this is a good idea for a c45 device. It can have
multiple devices ids. All we really need is that a driver is loaded
for one of them. That driver should then be able to control all the
devices in the package. So i would probably only warn when all
request_module() calls of failed.

Maybe it is actually better to warning when we bind the generic phy
driver to the PHY? That is the real problem we are trying to warn
about.

I also think reporting this as an error is too strong. Some PHYs are
happy with the generic PHY driver. So i think a warning is better than
an error.

   Andrew

  reply	other threads:[~2019-01-15 21:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-15 20:33 [PATCH net-next] net: phy: check return code when requesting PHY driver module Heiner Kallweit
2019-01-15 21:43 ` Andrew Lunn [this message]
2019-01-15 21:52   ` Heiner Kallweit
2019-01-15 21:58     ` Heiner Kallweit
2019-01-15 22:40     ` Andrew Lunn
2019-01-15 22:32 ` Florian Fainelli
2019-01-16  6:06   ` Heiner Kallweit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190115214327.GD26788@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).