Re: [PATCH net-next v4 1/4] rust: core abstractions for network PHY drivers
From: Andrew Lunn <andrew@lunn.ch>
Date: 2023-10-17 12:38:38
Also in:
rust-for-linux
quoted
Because set_speed() updates the member in phy_device and read() updates the object that phy_device points to?`set_speed` is entirely implemented on the Rust side and is not protected by a lock.
With the current driver, all entry points into the driver are called from the phylib core, and the core guarantees that the lock is taken. So it should not matter if its entirely implemented in the Rust side, somewhere up the call stack, the lock was taken.
quoted
quoted
What about these functions? - resolve_aneg_linkmode - genphy_soft_reset - init_hw - start_aneg - genphy_read_status - genphy_update_link - genphy_read_lpa - genphy_read_abilitiesAs Andrew replied, all the functions update some member in phy_device.Do all of these functions lock the `bus->mdio_lock`?
When accessing the hardware, yes.
The basic architecture is that at the bottom we have an MDIO bus, and
on top of that bus, we have a number of devices. The MDIO core will
serialise access to the bus, so only one device on the bus can be
accessed at once. The phylib core will serialise access to the PHY,
but when there are multiple PHYs, the phylib core will allow parallel
access to different PHYs.
In summary, the core of each layer protects the drivers using that
layer from multiple parallel accesses from above.
Andrew