public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork•no>
To: "Russell King (Oracle)" <linux@armlinux•org.uk>
Cc: "Jakub Kicinski" <kuba@kernel•org>,
	netdev@vger•kernel.org, 照山周一郎 <teruyama@springboard-inc•jp>
Subject: Re: [PATCH net,stable] phy: sfp: fix high power modules without diag mode
Date: Fri, 03 Dec 2021 14:55:17 +0100	[thread overview]
Message-ID: <877dclkd2y.fsf@miraculix.mork.no> (raw)
In-Reply-To: <YaoUW9KHyEQOt46b@shell.armlinux.org.uk> (Russell King's message of "Fri, 3 Dec 2021 12:58:03 +0000")

"Russell King (Oracle)" <linux@armlinux•org.uk> writes:

> Thinking a little more, how about this:
>
>  drivers/net/phy/sfp.c | 25 +++++++++++++++++++++----
>  1 file changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 51a1da50c608..4c900d063b19 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
> @@ -1752,17 +1752,20 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp)
>  static int sfp_module_parse_power(struct sfp *sfp)
>  {
>  	u32 power_mW = 1000;
> +	bool supports_a2;
>  
>  	if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_POWER_DECL))
>  		power_mW = 1500;
>  	if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_HIGH_POWER_LEVEL))
>  		power_mW = 2000;
>  
> +	supports_a2 = sfp->id.ext.sff8472_compliance !=
> +				SFP_SFF8472_COMPLIANCE_NONE ||
> +		      sfp->id.ext.diagmon & SFP_DIAGMON_DDM;
> +
>  	if (power_mW > sfp->max_power_mW) {
>  		/* Module power specification exceeds the allowed maximum. */
> -		if (sfp->id.ext.sff8472_compliance ==
> -			SFP_SFF8472_COMPLIANCE_NONE &&
> -		    !(sfp->id.ext.diagmon & SFP_DIAGMON_DDM)) {
> +		if (!supports_a2) {
>  			/* The module appears not to implement bus address
>  			 * 0xa2, so assume that the module powers up in the
>  			 * indicated mode.
> @@ -1779,11 +1782,24 @@ static int sfp_module_parse_power(struct sfp *sfp)
>  		}
>  	}
>  
> +	if (power_mW <= 1000) {
> +		/* Modules below 1W do not require a power change sequence */
> +		return 0;
> +	}
> +
> +	if (!supports_a2) {
> +		/* The module power level is below the host maximum and the
> +		 * module appears not to implement bus address 0xa2, so assume
> +		 * that the module powers up in the indicated mode.
> +		 */
> +		return 0;
> +	}
> +
>  	/* If the module requires a higher power mode, but also requires
>  	 * an address change sequence, warn the user that the module may
>  	 * not be functional.
>  	 */
> -	if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE && power_mW > 1000) {
> +	if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE) {
>  		dev_warn(sfp->dev,
>  			 "Address Change Sequence not supported but module requires %u.%uW, module may not be functional\n",
>  			 power_mW / 1000, (power_mW / 100) % 10);



Looks nice to me at least.  But I don't have the hardware to test it.


Bjørn

  reply	other threads:[~2021-12-03 13:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30  7:39 [PATCH net,stable] phy: sfp: fix high power modules without diag mode Bjørn Mork
2021-12-03  1:58 ` Jakub Kicinski
2021-12-03 11:54   ` Russell King (Oracle)
2021-12-03 12:58     ` Russell King (Oracle)
2021-12-03 13:55       ` Bjørn Mork [this message]
2021-12-04 12:38         ` Russell King (Oracle)
2021-12-06 10:35           ` Bjørn Mork
2021-12-06 15:39             ` 照山周一郎
2021-12-30 11:43               ` Bjørn Mork
2021-12-30 11:55                 ` Russell King (Oracle)
2021-12-30 12:00                   ` 照山周一郎
2022-01-15 16:58       ` Christian Lamparter
2022-01-17 14:24         ` Russell King (Oracle)
2022-01-17 14:44           ` Bjørn Mork
2022-01-17 14:49           ` Christian Lamparter
2022-01-18  6:58             ` 照山周一郎
2021-12-03 13:41     ` Bjørn Mork

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=877dclkd2y.fsf@miraculix.mork.no \
    --to=bjorn@mork$(echo .)no \
    --cc=kuba@kernel$(echo .)org \
    --cc=linux@armlinux$(echo .)org.uk \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=teruyama@springboard-inc$(echo .)jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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