> I added a statically-linked ethtool binary to my initramfs, and can
> confirm that retrieving the PHY statistics does not access the PHY
> registers when the device is suspended:
> 
>     # ethtool --phy-statistics eth0
>     no stats available
>     # ifconfig eth0 up
>     # ethtool --phy-statistics eth0
>     PHY statistics:
>        phy_receive_errors: 0
>        phy_idle_errors: 0
>     #
> 
> In the past, we've gone to great lengths to avoid accessing the PHY
> registers when the device is suspended, usually in the statistics
> handling (see e.g. [1][2]).

I would argue that is the wrong approach. The PHY device is a
device. It has its own lifetime. You would not suspend a PCI bus
controller without first suspending all PCI devices on the bus etc.

> +static int sh_mdiobb_read(struct mii_bus *bus, int phy, int reg)
> +{
> +     struct bb_info *bb = container_of(bus->priv, struct bb_info, ctrl);

mii_bus->parent should give you dev, so there is no need to add it to
bb_info.

> +     /* Wrap accessors with Runtime PM-aware ops */
> +     bitbang->read = mdp->mii_bus->read;
> +     bitbang->write = mdp->mii_bus->write;
> +     mdp->mii_bus->read = sh_mdiobb_read;
> +     mdp->mii_bus->write = sh_mdiobb_write;

I did wonder about just exporting the two functions so you can
directly call them.

Otherwise, this looks good.

           Andrew

Reply via email to