From: Alexander Graf <agraf@suse.de>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, gsomlo@gmail.com, stefanha@redhat.com,
mst@redhat.com
Subject: [Qemu-devel] [PATCH] e1000: Delay LSC until mask is active
Date: Thu, 3 Jul 2014 19:39:37 +0200 [thread overview]
Message-ID: <1404409177-3226-1-git-send-email-agraf@suse.de> (raw)
Mac OS X reads ICR on every interrupt. When the IRQ line is shared, this may
result in a race where LSC is not interpreted yet, but already gets cleared.
The guest already has a way of telling us that it can interpret LSC events
though and that's via the interrupt mask register (IMS).
So if we just leave the LSC interrupt bit pending, but invisible to the guest
as long as it's not ready to receive LSC interrupts, we basically defer the
interrupt to the earliest point in time when the guest would know how to
handle it.
This patch fixes occasional e1000 link detection hickups with Mac OS X.
Reported-by: Gabriel Somlo <somlo@cmu.edu>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
hw/net/e1000.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 0fc29a0..595e034 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -1090,9 +1090,24 @@ static uint32_t
mac_icr_read(E1000State *s, int index)
{
uint32_t ret = s->mac_reg[ICR];
+ uint32_t new_icr = 0;
DBGOUT(INTERRUPT, "ICR read: %x\n", ret);
- set_interrupt_cause(s, 0, 0);
+
+ /*
+ * Mac OS X reads ICR on every interrupt. When the IRQ line is shared,
+ * this may result in a race where LSC is not interpreted yet, but
+ * already gets cleared.
+ *
+ * The easiest fix is to delay LSC events until after they have been
+ * properly unmasked, so let's just claim we never saw any here.
+ */
+ if ((ret & E1000_ICS_LSC) && !(s->mac_reg[IMS] & E1000_ICS_LSC)) {
+ ret &= ~E1000_ICS_LSC;
+ new_icr |= E1000_ICS_LSC;
+ }
+
+ set_interrupt_cause(s, 0, new_icr);
return ret;
}
--
1.8.1.4
next reply other threads:[~2014-07-03 17:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-03 17:39 Alexander Graf [this message]
2014-07-03 17:57 ` [Qemu-devel] [PATCH] e1000: Delay LSC until mask is active Peter Maydell
2014-07-03 18:00 ` Alexander Graf
2014-07-03 20:18 ` Michael S. Tsirkin
2014-07-28 14:07 ` Alexander Graf
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=1404409177-3226-1-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--cc=gsomlo@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).