From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: davem@davemloft.net, "Jakub Kicinski" <kuba@kernel.org>,
"Eric Dumazet" <edumazet@google.com>,
"Paolo Abeni" <pabeni@redhat.com>,
"Russell King" <linux@armlinux.org.uk>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
thomas.petazzoni@bootlin.com,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Köry Maincent" <kory.maincent@bootlin.com>,
"Simon Horman" <horms@kernel.org>,
"Romain Gantois" <romain.gantois@bootlin.com>,
"Antoine Tenart" <atenart@kernel.org>,
"Marek Behún" <kabel@kernel.org>,
"Sean Anderson" <sean.anderson@linux.dev>,
"Bjørn Mork" <bjorn@mork.no>
Subject: Re: [PATCH net-next v2 1/2] net: phy: sfp: Add support for SMBus module access
Date: Tue, 25 Feb 2025 14:56:17 +0100 [thread overview]
Message-ID: <20250225145617.1ed1833d@fedora.home> (raw)
In-Reply-To: <6ff4a225-07c0-40f6-9509-c4fa79966266@lunn.ch>
Hi Andrew,
> > -static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c)
> > +static int sfp_smbus_read(struct sfp *sfp, bool a2, u8 dev_addr, void *buf,
>
> Maybe call this sfp_smbus_byte_read(), leaving space for
> sfp_smbus_word_read() in the future.
Good idea, I'll do that :)
> > + size_t len)
> > {
> > - if (!i2c_check_functionality(i2c, I2C_FUNC_I2C))
> > - return -EINVAL;
> > + u8 bus_addr = a2 ? 0x51 : 0x50;
> > + union i2c_smbus_data smbus_data;
> > + u8 *data = buf;
> > + int ret;
> > +
> > + while (len) {
> > + ret = i2c_smbus_xfer(sfp->i2c, bus_addr, 0,
> > + I2C_SMBUS_READ, dev_addr,
> > + I2C_SMBUS_BYTE_DATA, &smbus_data);
> > + if (ret < 0)
> > + return ret;
>
> Isn't this the wrong order? You should do the upper byte first, then
> the lower?
You might be correct. As I have been running that code out-of-tree for
a while, I was thinking that surely I'd have noticed if this was
wrong, however there are only a few cases where we actually write to
SFP :
- sfp_modify_u8(...) => one-byte write
- in sfp_cotsworks_fixup_check(...) there are 2 writes : one 1-byte
write and a 3-bytes write.
As I don't have any cotsworks SFP, then it looks like having the writes
mis-ordered would have stayed un-noticed on my side as I only
stressed the 1 byte write path...
So, good catch :) Let me triple-check and see if I can find any
conceivable way of testing that...
Thanks,
Maxime
next prev parent reply other threads:[~2025-02-25 13:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-25 11:20 [PATCH net-next v2 0/2] net: phy: sfp: Add single-byte SMBus SFP access Maxime Chevallier
2025-02-25 11:20 ` [PATCH net-next v2 1/2] net: phy: sfp: Add support for SMBus module access Maxime Chevallier
2025-02-25 13:41 ` Andrew Lunn
2025-02-25 13:56 ` Maxime Chevallier [this message]
2025-02-25 14:58 ` Andrew Lunn
2025-02-25 18:23 ` Russell King (Oracle)
2025-02-25 18:06 ` Russell King (Oracle)
2025-02-25 18:04 ` Russell King (Oracle)
2025-02-25 18:20 ` Maxime Chevallier
2025-02-25 18:41 ` Sean Anderson
2025-02-25 18:48 ` Maxime Chevallier
2025-03-08 18:42 ` Maxime Chevallier
2025-02-25 11:20 ` [PATCH net-next v2 2/2] net: mdio: mdio-i2c: Add support for single-byte SMBus operations Maxime Chevallier
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=20250225145617.1ed1833d@fedora.home \
--to=maxime.chevallier@bootlin.com \
--cc=andrew@lunn.ch \
--cc=atenart@kernel.org \
--cc=bjorn@mork.no \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=kabel@kernel.org \
--cc=kory.maincent@bootlin.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 \
--cc=romain.gantois@bootlin.com \
--cc=sean.anderson@linux.dev \
--cc=thomas.petazzoni@bootlin.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;
as well as URLs for NNTP newsgroup(s).