From: Aurelien Jarno <aurelien@aurel32.net>
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] e1000: Fix wrong microwire EEPROM state initialization
Date: Thu, 22 Jul 2010 14:15:42 +0200 [thread overview]
Message-ID: <20100722121542.GE2040@ohm.aurel32.net> (raw)
In-Reply-To: <1278770625-6757-1-git-send-email-tsutsui@ceres.dti.ne.jp>
On Sat, Jul 10, 2010 at 11:03:45PM +0900, Izumi Tsutsui wrote:
> This change fixes initialization of e1000's microwire EEPROM internal
> state values so that qemu's e1000 emulation works on NetBSD,
> which doesn't use Intel's em driver but has its own wm driver
> for the Intel i8254x Gigabit Ethernet.
>
> Previously set_eecd() function in e1000.c clears EEPROM internal state
> values on SK rising edge during CS==L, but according to FM93C06 EEPROM
> (which is MicroWire compatible) data sheet, EEPROM internal status
> should be cleared on CS rise edge regardless of SK input:
> "... a rising edge on this (CS) signal is required to reset the internal
> state-machine to accept a new cycle .."
> and nothing should be changed during CS (chip select) is inactive.
>
> Intel's em driver seems to explicitly raise SK output after CS is negated
> in em_standby_eeprom() so many other OSes that use Intel's driver
> don't have this problem even on the previous e1000.c implementation,
> but I can't find any articles that say the MICROWIRE or EEPROM spec
> requires such sequence, and actually hardware works fine without it
> (i.e. real i82540EM has been working on NetBSD).
>
> This fix also changes initialization to clear each state value in
> struct eecd_state individually rather than using memset() against
> the whole structre. The old_eecd member stores the last SK and CS
> signal levels and it should be preserved even after reset of internal
> EEPROM state to detect next signal edges for proper EEPROM emulation.
>
> Signed-off-by: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
> ---
> hw/e1000.c | 17 ++++++++---------
> 1 files changed, 8 insertions(+), 9 deletions(-)
Thanks, applied.
> diff --git a/hw/e1000.c b/hw/e1000.c
> index 0da65f9..db9143d 100644
> --- a/hw/e1000.c
> +++ b/hw/e1000.c
> @@ -262,21 +262,20 @@ set_eecd(E1000State *s, int index, uint32_t val)
>
> s->eecd_state.old_eecd = val & (E1000_EECD_SK | E1000_EECD_CS |
> E1000_EECD_DI|E1000_EECD_FWE_MASK|E1000_EECD_REQ);
> + if (!(E1000_EECD_CS & val)) // CS inactive; nothing to do
> + return;
> + if (E1000_EECD_CS & (val ^ oldval)) { // CS rise edge; reset state
> + s->eecd_state.val_in = 0;
> + s->eecd_state.bitnum_in = 0;
> + s->eecd_state.bitnum_out = 0;
> + s->eecd_state.reading = 0;
> + }
> if (!(E1000_EECD_SK & (val ^ oldval))) // no clock edge
> return;
> if (!(E1000_EECD_SK & val)) { // falling edge
> s->eecd_state.bitnum_out++;
> return;
> }
> - if (!(val & E1000_EECD_CS)) { // rising, no CS (EEPROM reset)
> - memset(&s->eecd_state, 0, sizeof s->eecd_state);
> - /*
> - * restore old_eecd's E1000_EECD_SK (known to be on)
> - * to avoid false detection of a clock edge
> - */
> - s->eecd_state.old_eecd = E1000_EECD_SK;
> - return;
> - }
> s->eecd_state.val_in <<= 1;
> if (val & E1000_EECD_DI)
> s->eecd_state.val_in |= 1;
> --
> 1.6.6.2
>
>
>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
next prev parent reply other threads:[~2010-07-22 12:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20100517132539.15293.52060.malonedeb@gandwana.canonical.com>
2010-06-02 22:02 ` [Qemu-devel] [Bug 581737] Re: Can't read e1000 NIC EEPROM on NetBSD guest Ryan Harper
2010-06-03 13:45 ` Izumi Tsutsui
2010-06-03 16:43 ` Ryan Harper
2010-06-13 5:16 ` Izumi Tsutsui
2010-06-13 12:21 ` Andreas Färber
2010-06-13 12:50 ` [Qemu-devel] [Bug 581737] Re: Can't read e1000 NIC EEPROM onNetBSD guest Izumi Tsutsui
2010-06-13 14:36 ` Andreas Färber
2010-07-10 14:03 ` [Qemu-devel] [PATCH] e1000: Fix wrong microwire EEPROM state initialization Izumi Tsutsui
2010-07-22 12:15 ` Aurelien Jarno [this message]
2010-06-13 13:10 ` [Qemu-devel] [Bug 581737] Re: Can't read e1000 NIC EEPROM on NetBSD guest Jonathan A. Kollasch
2010-06-13 14:02 ` Andreas Färber
2011-01-16 14:39 ` Aurelien Jarno
2011-02-20 17:13 ` Aurelien Jarno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100722121542.GE2040@ohm.aurel32.net \
--to=aurelien@aurel32.net \
--cc=qemu-devel@nongnu.org \
--cc=tsutsui@ceres.dti.ne.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).