Received: from eggs.gnu.org ([2001:4830:134:3::10]:50944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XywGE-0002hF-2Q for qemu-devel@nongnu.org; Thu, 11 Dec 2014 00:26:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XywG6-0001GX-2c for qemu-devel@nongnu.org; Thu, 11 Dec 2014 00:25:57 -0500 Received: from skprod3.natinst.com ([130.164.80.24]:43720 helo=ni.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XywG5-0001GF-S0 for qemu-devel@nongnu.org; Thu, 11 Dec 2014 00:25:49 -0500 From: Richard Tollerton Date: Wed, 10 Dec 2014 23:23:46 -0600 Message-Id: <1418275427-18921-2-git-send-email-rich.tollerton@ni.com> In-Reply-To: <1418275427-18921-1-git-send-email-rich.tollerton@ni.com> References: <1418275427-18921-1-git-send-email-rich.tollerton@ni.com> Subject: [Qemu-devel] [PATCH v2 1/2] e1000: Clear MDIC register when PHY addr is invalid List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Richard Tollerton , kraxel@redhat.com, Jeff Westfahl , mst@redhat.com Some drivers probe PHY addresses beyond the first one, and also (unfortunately) don't check for MDIC_ERROR on reads. It appears that the driver assumes that the data reads will return zero in this case (invalid PHY address). Anecdotally, hardware is believed to do this; but qemu wasn't, and instead was reusing the previous value of the MDIC register. This screwed up driver init. To fix, don't reuse the current value of the MDIC register when an invalid PHY address is referenced; let the value be set to precisely MDIC_ERROR|MDIC_READY. Signed-off-by: Richard Tollerton Signed-off-by: Jeff Westfahl --- hw/net/e1000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index e33a4da..44ae3a8 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -457,7 +457,7 @@ set_mdic(E1000State *s, int index, uint32_t val) uint32_t addr = ((val & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT); if ((val & E1000_MDIC_PHY_MASK) >> E1000_MDIC_PHY_SHIFT != 1) // phy # - val = s->mac_reg[MDIC] | E1000_MDIC_ERROR; + val = E1000_MDIC_ERROR; else if (val & E1000_MDIC_OP_READ) { DBGOUT(MDIC, "MDIC read reg 0x%x\n", addr); if (!(phy_regcap[addr] & PHY_R)) { -- 2.1.3