mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Jonas Jelonek <jelonek.jonas@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Bjørn Mork" <bjorn@mork.no>, "Simon Horman" <horms@kernel.org>
Subject: Re: [PATCH net-next v9 2/3] net: sfp: apply I2C adapter quirks to limit block size
Date: Fri, 29 May 2026 18:18:07 +0200	[thread overview]
Message-ID: <2bf0a2d1-634e-463b-a0bc-a8cbe930d5ad@bootlin.com> (raw)
In-Reply-To: <20260528205242.971410-3-jelonek.jonas@gmail.com>

Hi Jonas,

On 5/28/26 22:52, Jonas Jelonek wrote:
> The SFP driver assumes all I2C adapters support reading and writing the
> pre-defined block size SFP_EEPROM_BLOCK_SIZE of 16 bytes. This constant
> was probably chosen based on good guesses and known limitations of a
> range of I2C adapters and SFP modules.
> 
> However, I2C adapters may even support less and usually need to specify
> this via I2C quirks. Theoretically, such an adapter may provide full
> functionality but only support a read and write length of e.g. 8 bytes.
> Currently, the SFP driver doesn't account for that.
> 
> Add handling for I2C quirks in SFP I2C configuration taking the fields
> max_read_len and max_write_len in struct i2c_adapter_quirks into account
> to further limit the maximum block size if needed.
> 
> Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>

Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

Thanks !

Maxime

> ---
>   drivers/net/phy/sfp.c | 12 ++++++++++--
>   1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 376f7232f9ee..60f36cba3d83 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
> @@ -809,21 +809,29 @@ static int sfp_smbus_byte_write(struct sfp *sfp, bool a2, u8 dev_addr,
>   
>   static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c)
>   {
> +	size_t max_block_size;
> +
>   	sfp->i2c = i2c;
>   
>   	if (i2c_check_functionality(i2c, I2C_FUNC_I2C)) {
>   		sfp->read = sfp_i2c_read;
>   		sfp->write = sfp_i2c_write;
> -		sfp->i2c_max_block_size = SFP_EEPROM_BLOCK_SIZE;
> +		max_block_size = SFP_EEPROM_BLOCK_SIZE;
>   	} else if (i2c_check_functionality(i2c, I2C_FUNC_SMBUS_BYTE_DATA)) {
>   		sfp->read = sfp_smbus_byte_read;
>   		sfp->write = sfp_smbus_byte_write;
> -		sfp->i2c_max_block_size = 1;
> +		max_block_size = 1;
>   	} else {
>   		sfp->i2c = NULL;
>   		return -EINVAL;
>   	}
>   
> +	if (i2c->quirks && i2c->quirks->max_read_len)
> +		max_block_size = min(max_block_size, i2c->quirks->max_read_len);
> +	if (i2c->quirks && i2c->quirks->max_write_len)
> +		max_block_size = min(max_block_size, i2c->quirks->max_write_len);
> +
> +	sfp->i2c_max_block_size = max_block_size;
>   	sfp->i2c_block_size = sfp->i2c_max_block_size;
>   	return 0;
>   }


  reply	other threads:[~2026-05-29 16:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-28 20:52 [PATCH net-next v9 0/3] net: sfp: extend SMBus support Jonas Jelonek
2026-05-28 20:52 ` [PATCH net-next v9 1/3] net: sfp: initialize i2c_block_size at adapter configure time Jonas Jelonek
2026-06-04  1:06   ` Jakub Kicinski
2026-06-12  7:40     ` Jonas Jelonek
2026-06-12 14:14     ` Jonas Jelonek
2026-05-28 20:52 ` [PATCH net-next v9 2/3] net: sfp: apply I2C adapter quirks to limit block size Jonas Jelonek
2026-05-29 16:18   ` Maxime Chevallier [this message]
2026-05-28 20:52 ` [PATCH net-next v9 3/3] net: sfp: extend SMBus support Jonas Jelonek
2026-06-04  1:14 ` [PATCH net-next v9 0/3] " patchwork-bot+netdevbpf

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=2bf0a2d1-634e-463b-a0bc-a8cbe930d5ad@bootlin.com \
    --to=maxime.chevallier@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=bjorn@mork.no \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=jelonek.jonas@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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

Powered by JetHome