lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 12 Jan 2021 21:22:58 +0000
From:   Russell King - ARM Linux admin <linux@...linux.org.uk>
To:     Andrew Lunn <andrew@...n.ch>
Cc:     Marek BehĂșn <kabel@...nel.org>,
        netdev@...r.kernel.org, Jakub Kicinski <kuba@...nel.org>,
        davem@...emloft.net, pali@...nel.org
Subject: Re: [PATCH net-next v4 1/4] net: phy: mdio-i2c: support I2C MDIO
 protocol for RollBall SFP modules

On Tue, Jan 12, 2021 at 09:54:24PM +0100, Andrew Lunn wrote:
> > +static int i2c_transfer_rollball(struct i2c_adapter *i2c,
> > +				 struct i2c_msg *msgs, int num)
> > +{
> > +	u8 saved_page;
> > +	int ret;
> > +
> > +	i2c_lock_bus(i2c, I2C_LOCK_SEGMENT);
> > +
> > +	/* save original page */
> > +	ret = __i2c_rollball_get_page(i2c, msgs->addr, &saved_page);
> > +	if (ret)
> > +		goto unlock;
> > +
> > +	/* change to RollBall MDIO page */
> > +	ret = __i2c_rollball_set_page(i2c, msgs->addr, SFP_PAGE_ROLLBALL_MDIO);
> > +	if (ret)
> > +		goto unlock;
> > +
> > +	/* do the transfer */
> > +	ret = __i2c_transfer_err(i2c, msgs, num);
> > +	if (ret)
> > +		goto unlock;
> 
> If get page and set page worked, and you get an error in during the
> actual data transfer, i wonder if you should try restoring the page
> before returning with the error?

That's what we do with paged PHYs - if the access encounters an error,
we still attempt to restore the page and propagate the _original_ error.
We would only propagate the error from the page restore if it was the
only error.  See the logic and comments for phy_restore_page().

Note that phy_(save|select)_page()..phy_restore_page() deal with the
locking, which is why they always have to be paired (also means that
the user doesn't have to think too hard about error handling.)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ