From: Russell King Date: Tue, 25 Aug 2015 08:49:53 +0000 (+0100) Subject: net: fec: use reinit_completion() in mdio accessor functions X-Git-Tag: v4.14-rc1~4848^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aac27c7a0d76683f7f4bdf41cec174db2819f635;p=platform%2Fkernel%2Flinux-rpi.git net: fec: use reinit_completion() in mdio accessor functions Rather than re-initialising the entire completion on every mdio access, use reinit_completion() which only resets the completion count. This avoids possible reinitialisation of the contained spinlock and waitqueue while they may be in use (eg, mid-completion.) Such an event could occur if there's a long delay in interrupt handling causing the mdio accessor to time out, then a second access comes in while the interrupt handler on a different CPU has called complete(). Another scenario where this has been observed is while locking has been missing at the phy layer, allowing concurrent attempts to access the MDIO bus. Signed-off-by: Russell King Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 271bb58..b349e6f 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -1778,7 +1778,7 @@ static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum) return ret; fep->mii_timeout = 0; - init_completion(&fep->mdio_done); + reinit_completion(&fep->mdio_done); /* start a read op */ writel(FEC_MMFR_ST | FEC_MMFR_OP_READ | @@ -1817,7 +1817,7 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum, return ret; fep->mii_timeout = 0; - init_completion(&fep->mdio_done); + reinit_completion(&fep->mdio_done); /* start a write op */ writel(FEC_MMFR_ST | FEC_MMFR_OP_WRITE |