Subject: Re: [EXT] [PATCH] net: ethernet: fec: Replace interrupt driven MDIO with polled IO

From: Andrew Lunn <[email-masked]>
Date: Tue, 14 Apr 2020 05:49:20 +0200

On Tue, Apr 14, 2020 at 03:07:09AM +0000, Andy Duan wrote:
> From: Andrew Lunn <[email-masked]> Sent: Tuesday, April 14, 2020 8:46 AM
> > Measurements of the MDIO bus have shown that driving the MDIO bus using
> > interrupts is slow. Back to back MDIO transactions take about 90uS, with
> > 25uS spent performing the transaction, and the remainder of the time the bus
> > is idle.
> > 
> > Replacing the completion interrupt with polled IO results in back to back
> > transactions of 40uS. The polling loop waiting for the hardware to complete
> > the transaction takes around 27uS. Which suggests interrupt handling has an
> > overhead of 50uS, and polled IO nearly halves this overhead, and doubles the
> > MDIO performance.
> > 
> 
> Although the mdio performance is better, but polling IO by reading register
> cause system/bus loading more heavy.

Hi Andy

I actually think is reduces the system bus load. With interrupts we
have 27uS waiting for the interrupt when the bus is idle, followed by
63uS the CPU is busy handling the interrupt and setting up the next
transfer, which will case the bus to be loaded. So the system bus is
busy for 63uS per transaction. With polled IO, yes the system bus is
busy for 27uS polling while the transaction happens, and then another
13uS setting up the next transaction. But in total, that is only 40uS.

So with interrupts we have 63uS of load per transaction, vs 40uS of
load per transaction for polled IO. Polled IO is better for the bus.

I also have follow up patches which allows the bus to be run at higher
speeds. The Ethernet switch i have on the bus is happy to run a 5MHz
rather than the default 2.5MHz. That reduces the transaction time by a
1/2. The switch will also work without the MDIO preamble, again
reducing the size of the MDIO transaction by 1/2. Combining all these,
interrupt handling becomes very expensive. You do not want to be doing
interrupts every 7uS.

     Andrew