Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Octeon: False positive timeout

If we reach the test just below the loop with a `timeout' value of 0,
this does not mean that the timeout caused the loop to end, but rather
the `smi_rd.s.pending', in the last iteration. If timeout caused the
loop to end, then `timeout' is -1, not 0.

Since this can occur only in the last iteration, it is not very likely
to be a problem. By changing the post- to prefix decrement we ensure
that a timeout of 0 does mean it timed out.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Acked-by: David Daney <ddaney@caviumnetworks.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Roel Kluin and committed by
Ralf Baechle
fff9c815 e3bf887d

+1 -1
+1 -1
drivers/staging/octeon/cvmx-mdio.h
··· 421 421 do { 422 422 cvmx_wait(1000); 423 423 smi_rd.u64 = cvmx_read_csr(CVMX_SMIX_RD_DAT(bus_id)); 424 - } while (smi_rd.s.pending && timeout--); 424 + } while (smi_rd.s.pending && --timeout); 425 425 426 426 if (timeout <= 0) { 427 427 cvmx_dprintf("cvmx_mdio_45_read: bus_id %d phy_id %2d "