From patchwork Fri Apr 25 21:17:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Tollerton X-Patchwork-Id: 343008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B2486140143 for ; Sat, 26 Apr 2014 07:56:00 +1000 (EST) Received: from localhost ([::1]:60074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wdo6A-0005vx-C8 for incoming@patchwork.ozlabs.org; Fri, 25 Apr 2014 17:55:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdnVF-0003nz-Mq for qemu-devel@nongnu.org; Fri, 25 Apr 2014 17:17:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WdnV7-0002CM-Fp for qemu-devel@nongnu.org; Fri, 25 Apr 2014 17:17:49 -0400 Received: from skprod3.natinst.com ([130.164.80.24]:34300 helo=ni.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdnV7-0002Bk-7r for qemu-devel@nongnu.org; Fri, 25 Apr 2014 17:17:41 -0400 Received: from us-aus-mgwout1.amer.corp.natinst.com (nb-snip2-1338.natinst.com [130.164.19.135]) by us-aus-skprod3.natinst.com (8.14.5/8.14.5) with ESMTP id s3PLHdjs008819; Fri, 25 Apr 2014 16:17:39 -0500 Received: from weregild.amer.corp.natinst.com ([130.164.14.198]) by us-aus-mgwout1.amer.corp.natinst.com (Lotus Domino Release 8.5.3FP5) with ESMTP id 2014042516173926-268250 ; Fri, 25 Apr 2014 16:17:39 -0500 From: Richard Tollerton To: qemu-devel@nongnu.org Date: Fri, 25 Apr 2014 16:17:09 -0500 Message-Id: <1398460630-31557-2-git-send-email-rich.tollerton@ni.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1398460630-31557-1-git-send-email-rich.tollerton@ni.com> References: <1398460630-31557-1-git-send-email-rich.tollerton@ni.com> X-MIMETrack: Itemize by SMTP Server on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP5|July 31, 2013) at 04/25/2014 04:17:39 PM, Serialize by Router on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP5|July 31, 2013) at 04/25/2014 04:17:39 PM, Serialize complete at 04/25/2014 04:17:39 PM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.96, 1.0.14, 0.0.0000 definitions=2014-04-25_05:2014-04-25, 2014-04-25, 1970-01-01 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 130.164.80.24 X-Mailman-Approved-At: Fri, 25 Apr 2014 17:55:31 -0400 Cc: Richard Tollerton , jeff.westfahl@ni.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 1/2] e1000: Clear MDIC register when PHY addr is invalid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 8387443..c3c612c 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -429,7 +429,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)) {