Skip to content

net: mdio: Clause 45 support for mdio-bcm-unimac

Florian Fainelli lkml netdev 8 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest4 patches 0 repliesNew
  2. v64 patches 2 repliesSuperseded
  3. v54 patches 3 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v4 posting 2/24 patches2 repliesSuperseded
v4 posting 1/24 patches2 repliesSuperseded
v34 patches3 repliesSuperseded
v24 patches7 repliesSuperseded
v13 patches11 repliesSuperseded

Changes in v7 from the cover letter

- patch 1:
- only map a failed read of MDIO_DEVS2, the first one, to -ENODEV in get_phy_c45_devs_in_pkg(). A failed read of MDIO_DEVS1 happens once MDIO_DEVS2 has answered, i.e. once the MMD has answered, and is returned as -EIO so that the PHY is not silently skipped. This also gets rid of get_phy_c45_probe_err()
- correct the commit message about sfp_sm_probe_phy(): the mdio-i2c buses report a PHY that does not answer as a read of all Fs, so only an I2C transport error on a RollBall module is affected, which is now retried and reported as "no PHY detected" instead of failing the module
- the errors of the vendor MMD presence check done while reading the identifiers are returned as is, as they were before this patch; reword the commit message to not claim more than that
- the commit message explains why the loop over the MMDs does not carry on after an MMD that did not answer: the vendor MMD presence check would end the scan before MMD 0 is probed
- the code changed since Nicolai's Reviewed-by tag was given, therefore the tag was removed
- patches 2 to 4: no changes

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4net: phy: Map C45 probe read errors to -ENODEV during bus scandrivers/net/phy/phy_device.c+29 -80 replies
2/4net: mdio: mdio-bcm-unimac: Define MDIO_OP_SHIFTdrivers/net/mdio/mdio-bcm-unimac.c+6 -40 replies
3/4net: mdio: mdio-bcm-unimac: Poll for completion at 1us granularitydrivers/net/mdio/mdio-bcm-unimac.c+16 -80 replies
4/4net: mdio: mdio-bcm-unimac: Add Clause 45 supportdrivers/net/mdio/mdio-bcm-unimac.c+126 -100 replies

Reviews trailers per patch

3 of 4 patches have a Reviewed-by or Acked-by.

PatchAndrew LunnNicolai Buchwitz
1/4
2/4R-b R-b
3/4R-b R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v7 thread

Cover letter [PATCH net-next v7 0/4] net: mdio: Clause 45 support for mdio-bcm-unimac

This patch series adds support for Clause 45 MDIO operations within the mdio-bcm-unimac driver. The series breaks things up in this way:

- make the C45 bus scan done by the MDIO core carry on when nothing answers at an address, as the C22 scan already does
- scope the existing defines to make it clear what is C22 vs. C45 specific
- rework the polling completion loop to be a tighter loop
- add support for clause 45 operations

Changes in v7:

- patch 1:
- only map a failed read of MDIO_DEVS2, the first one, to -ENODEV in get_phy_c45_devs_in_pkg(). A failed read of MDIO_DEVS1 happens once MDIO_DEVS2 has answered, i.e. once the MMD has answered, and is returned as -EIO so that the PHY is not silently skipped. This also gets rid of get_phy_c45_probe_err()
- correct the commit message about sfp_sm_probe_phy(): the mdio-i2c buses report a PHY that does not answer as a read of all Fs, so only an I2C transport error on a RollBall module is affected, which is now retried and reported as "no PHY detected" instead of failing the module
- the errors of the vendor MMD presence check done while reading the identifiers are returned as is, as they were before this patch; reword the commit message to not claim more than that
- the commit message explains why the loop over the MMDs does not carry on after an MMD that did not answer: the vendor MMD presence check would end the scan before MMD 0 is probed
- the code changed since Nicolai's Reviewed-by tag was given, therefore the tag was removed
- patches 2 to 4: no changes

Changes in v6:

- patches 1 to 3: no changes
- patch 4: collect Reviewed-by tag from Nicolai Buchwitz, no code changes

Changes in v5:

- patch 1:
- the commit message now says that mdio-bcm-unimac only provides read_c45() with patch 4, which enables the UniMAC case, so that a standalone backport knows about that dependency
- the commit message now lists the callers other than the bus scan that see -ENODEV instead of -EIO (of_mdio, sfp, mxl-gpy), which is what C22 callers already get
- the vendor MMD presence check done while reading the identifiers and the reads of the per-MMD identifiers are intentionally not mapped, since they only happen once a device has answered; say so in the commit message and reword the kernel-doc of get_phy_c45_ids() and phy_get_c45_ids() to document "a negative error code" rather than -EIO as the only alternative to -ENODEV
- patches 2 and 3: no changes
- patch 4:
- check that the controller is idle after every cycle (the C45 ADDR and data cycles as well as the C22 ones) instead of only after the ADDR cycle, since a wait_func() such as bcmgenet_mii_wait() returns 0 even when it timed out with START_BUSY still set, which could return the command bits instead of the read data or switch MDIO_CFG in the middle of a frame
- the commit message says that unimac_mdio_resume() waiting for the bus lock means that resume may wait for an in-flight MDIO access
- the commit message says that the C45 scan is slower than the C22 one on the platform device GENET registers without a Device Tree node (e.g.:
ACPI) because bcmgenet_mii_wait() sleeps per frame until GENET's interrupt is registered. This is not worked around in this series; making bcmgenet_mii_wait() poll in that window would be a separate GENET change

Changes in v4:

- patch 1:
- when the read of the devices in package registers of an MMD fails with -EIO or -ENODEV, treat it like an all Fs reply and probe MMD 0 instead of returning -ENODEV right away, so that PHYs that only respond on MMD 0 (e.g.: Cortina CS4315/CS4340) are still found on controllers that report a bus error for an MMD that does not answer. The remaining MMDs are not probed, to keep the cost of scanning an empty address bounded. -ENODEV is only returned if MMD 0 does not answer either
- add a Fixes: tag
- update the kernel-doc of get_phy_c45_ids() and phy_get_c45_ids()
- the code changed since Nicolai's Reviewed-by tag was given, which was kept, please let me know if it should be dropped
- patch 2: no changes
- patch 3: reword the comments about the poll timeout, which applies to each frame, a C45 access waits once for each of its two frames
- patch 4: no code changes, the commit message now mentions that the C45 scan also runs for the platform device GENET registers without a Device Tree node (e.g.: ACPI), since it does not mask any address

Changes in v3:

- patch 1: collect Reviewed-by tag from Nicolai Buchwitz, no code changes
- patches 2 and 3: no changes
- patch 4:
- after the ADDR cycle, make sure the controller is idle before starting the READ/WRITE cycle, since a wait_func() such as bcmgenet_mii_wait() returns 0 even when it timed out with START_BUSY still set
- take bus->mdio_lock in unimac_mdio_resume() around unimac_mdio_clk_set(), such that its read-modify-write of MDIO_CFG cannot race with the C22/C45 clause switch done by the accessors

Changes in v2:

- add patch 1, since providing read_c45/write_c45 makes the MDIO core scan for C45 PHYs on all addresses that are not masked. On a bus registered without a device tree node (e.g.: GENET with ACPI) a read from an empty address fails with -EIO, which get_phy_c45_ids() passed up instead of mapping it to -ENODEV, and made the whole bus registration fail. Reported by Nicolai Buchwitz.
- patches 2 and 3: collect Reviewed-by tags from Andrew Lunn and Nicolai Buchwitz, no code changes
- patch 4: no code changes

Florian Fainelli (4):
net: phy: Map C45 probe read errors to -ENODEV during bus scan
net: mdio: mdio-bcm-unimac: Define MDIO_OP_SHIFT
net: mdio: mdio-bcm-unimac: Poll for completion at 1us granularity
net: mdio: mdio-bcm-unimac: Add Clause 45 support

 drivers/net/mdio/mdio-bcm-unimac.c | 162 +++++++++++++++++++++++++----
 drivers/net/phy/phy_device.c       |  37 +++++--
 2 files changed, 173 insertions(+), 26 deletions(-)
Signature · 1 line
2.34.1