From patchwork Wed Oct 30 18:00:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 287325 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E16992C0398 for ; Thu, 31 Oct 2013 05:36:31 +1100 (EST) Received: from localhost ([::1]:53914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vbad4-0004Lu-1l for incoming@patchwork.ozlabs.org; Wed, 30 Oct 2013 14:36:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vbacg-0004EP-UD for qemu-devel@nongnu.org; Wed, 30 Oct 2013 14:36:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vbaca-0008CN-Ub for qemu-devel@nongnu.org; Wed, 30 Oct 2013 14:36:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbacO-0008A0-CS; Wed, 30 Oct 2013 14:35:48 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9UIZh8C031766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 30 Oct 2013 14:35:44 -0400 Received: from yakj.usersys.redhat.com (ovpn-112-69.ams2.redhat.com [10.36.112.69]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9UI09JA031860; Wed, 30 Oct 2013 14:00:10 -0400 Message-ID: <52714929.1050005@redhat.com> Date: Wed, 30 Oct 2013 19:00:09 +0100 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130923 Thunderbird/17.0.9 MIME-Version: 1.0 To: Peter Maydell References: <52713936.9070309@redhat.com> In-Reply-To: X-Enigmail-Version: 1.6 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: QEMU Developers , jacek burghardt , qemu-discuss Subject: Re: [Qemu-devel] e1000 patch for osx 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 Il 30/10/2013 18:29, Peter Maydell ha scritto: > This looks odd -- you seem to be modifying val but then not > using the modified value before we reach the end of the function. > >> > } >> > >> > static void >> > @@ -445,8 +450,9 @@ set_mdic(E1000State *s, int index, uint32_t val) >> > } else { >> > if (addr < NPHYWRITEOPS && phyreg_writeops[addr]) { >> > phyreg_writeops[addr](s, index, data); >> > + } else { >> > + s->phy_reg[addr] = data; >> > } >> > - s->phy_reg[addr] = data; >> > } > ...and this part seems to remove the code which sets > phy_reg[PHY_CTRL], so it will now always read back as zero. Yeah, I forgot one line: Paolo diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 70a59fd..b7a1953 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -203,6 +203,12 @@ set_phy_ctrl(E1000State *s, int index, uint16_t val) DBGOUT(PHY, "Start link auto negotiation\n"); timer_mod(s->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500); } + + if (val & 0x8000) { + val &= 0x7fff; + set_ics(s, 0, E1000_ICR_LSC); + } + s->phy_reg[PHY_CTRL] = val; } static void @@ -445,8 +451,9 @@ set_mdic(E1000State *s, int index, uint32_t val) } else { if (addr < NPHYWRITEOPS && phyreg_writeops[addr]) { phyreg_writeops[addr](s, index, data); + } else { + s->phy_reg[addr] = data; } - s->phy_reg[addr] = data; } } s->mac_reg[MDIC] = val | E1000_MDIC_READY;