Subject: AW: [PATCH net-next 8/8] net: mdio: realtek-rtl9300: Convert port lookup from O(n) to O(1)

From: "Markus Stockhausen" <[email-masked]>
Date: Tue, 2 Jun 2026 22:02:06 +0200

> Von: Andrew Lunn <[email-masked]> 
> Gesendet: Dienstag, 2. Juni 2026 14:30
> An: Markus Stockhausen <[email-masked]>
> Betreff: Re: [PATCH net-next 8/8] net: mdio: realtek-rtl9300: Convert port
lookup from O(n) to O(1)
>...
> > Create a reverse lookup table per channel during setup. This stores 
> > the
> > (overall) port number per PHY (on that channel). Take special care 
> > about absent ports that are missing from device tree because of hardware
design.
> > Save memory by using s8 type for the table (-1 = absent, 0..56 = port).
> > Convert the lookup in otto_emdio_phy_to_port() from loop-based to 
> > table-based.
>
> Generally, for performance patches, you would include some benchmark
numbers.
>
> What percentage of the time of an MDIO transaction is doing the lookup, vs
shifting bits out the hardware and polling for completion?
> A 2.5MHz bus is not very fast, compared to a 500MHz CPU.

IIRC I saved 100us per polling loop over all 52 ports of a RTL839x switch.
But this was too long ago and I will need to verify this once again.  It is
not critical for now so I will drop the patch for v2.

Markus