qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: "Gabriel L. Somlo" <gsomlo@gmail.com>
Cc: "pbonzini@redhat.com" <pbonzini@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"stefanha@redhat.com" <stefanha@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] e1000 autoneg timing, piix/osx
Date: Thu, 03 Jul 2014 17:25:04 +0200	[thread overview]
Message-ID: <53B575D0.7080700@suse.de> (raw)
In-Reply-To: <20140703141451.GD1688@ERROL.INI.CMU.EDU>


On 03.07.14 16:14, Gabriel L. Somlo wrote:
> On Thu, Jul 03, 2014 at 04:02:06PM +0200, Alexander Graf wrote:
>> On 03.07.14 15:58, Gabriel L. Somlo wrote:
>>> On Thu, Jul 03, 2014 at 03:20:50PM +0200, Alexander Graf wrote:
>>>> On 03.07.2014, at 15:17, Gabriel L. Somlo <gsomlo@gmail.com> wrote:
>>>>
>>>>> On Thu, Jul 03, 2014 at 10:04:55AM +0200, Alexander Graf wrote:
>>>>>>> so Ethernet, SATA, and USB, all sharing IRQ 11. Is there an easy way
>>>>>>> to force one of those to use a different IRQ ?
>>>>> Oh, and on Q35, while Ethernet (and one of the USBs) is still on IRQ 11,
>>>>> SATA ended up on IRQ 10, and things are fine there...
>>>>>
>>>>>> IIRC if you plug the device in a different slot, the irq distribution
>>>>>> should be different :).
>>>>> Sorry for being thick, but I'm still trying to figure out if there's a
>>>>> command-line way of making that happen. Re-ordering the "-device"
>>>>> arguments to qemu obviously doesn't make a difference in how they're
>>>>> assigned...
>>>> The magic word is "devfn" :). It's basically the token PCI uses to find out which slot and function id a device is on. You can set "devfn" with the "addr" attribute on -device.
>>> OK. So simply doing "-device e1000-82545em,...,bus=pci.0,addr=5" to
>>> move it up one slot from its default of "4" gets it set up with IRQ 10.
>>> As long as it doesn't share an irq line with the SATA controller, the
>>> network link gets detected just fine, same as on Q35.
>>>
>>> So this is not really an autonegotiation or timing bug, it's an
>>> unfortunate side effect of the OS X built-in proprietary e1000 driver
>>> not playing nice when IRQs are shared with SATA in particular. At
>>> least as far as I'm able to tell so far... :)
>>>
>>> So I'll send out some autoneg cleanup patches after 2.1 is officially
>>> out, but the "osx link on piix not working" mystery is solved as far
>>> as I can tell :)
>> Maybe only ICR bits that actually would trigger an interrupt get cleared?
> you mean, modify e1000's mac_icr_read() to only clear bits on read if
> the mask says they should be "active" at that moment ?
>
> The e1000 spec doesn't seem to say that though, it's "you read it,
> it's now 0", regardless of the mask configuration.
>
> http://download.intel.com/design/network/manuals/8254x_GBe_SDM.pdf
> on page 293.

Maybe the IRQ line is simply never shared on real Macs :). Who knows.

Does this (untested!) patch make it work for you?


Alex

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 0fc29a0..7db0538 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
+     * property 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;
  }

  parent reply	other threads:[~2014-07-03 15:25 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-30 16:55 [Qemu-devel] [RFC PATCH v1 0/2] e1000: More link negotiation vs. OS X Gabriel L. Somlo
2014-06-30 16:55 ` [Qemu-devel] [RFC PATCH v1 1/2] e1000: clean up set_phy_ctrl function Gabriel L. Somlo
2014-06-30 18:04   ` Michael S. Tsirkin
2014-06-30 18:12     ` Gabriel L. Somlo
2014-06-30 19:29       ` Gabriel L. Somlo
2014-06-30 19:35         ` Gabriel L. Somlo
2014-06-30 16:55 ` [Qemu-devel] [RFC PATCH v1 2/2] e1000: adjust initial autoneg timing (for piix/osx) Gabriel L. Somlo
2014-06-30 17:55   ` Michael S. Tsirkin
2014-06-30 18:00     ` Paolo Bonzini
2014-06-30 18:21     ` Alexander Graf
2014-07-02  9:02       ` Gabriel L. Somlo
2014-07-02  9:16         ` Alexander Graf
2014-07-02 20:49           ` [Qemu-devel] e1000 autoneg timing, piix/osx Gabriel L. Somlo
2014-07-02 21:02             ` Alexander Graf
2014-07-02 21:14               ` Gabriel L. Somlo
2014-07-02 21:54                 ` Alexander Graf
2014-07-02 22:02                 ` Gabriel L. Somlo
2014-07-03  8:04                   ` Alexander Graf
2014-07-03 13:17                     ` Gabriel L. Somlo
2014-07-03 13:20                       ` Alexander Graf
2014-07-03 13:58                         ` Gabriel L. Somlo
2014-07-03 14:02                           ` Alexander Graf
2014-07-03 14:14                             ` Gabriel L. Somlo
2014-07-03 14:51                               ` Alexander Graf
2014-07-03 15:25                               ` Alexander Graf [this message]
2014-07-03 16:09                                 ` Paolo Bonzini
2014-07-03 16:43                                 ` Gabriel L. Somlo
2014-07-03 17:33                                   ` Alexander Graf
2014-07-02  9:33         ` [Qemu-devel] [RFC PATCH v1 2/2] e1000: adjust initial autoneg timing (for piix/osx) Michael S. Tsirkin
2014-07-02 12:05           ` Gabriel L. Somlo
2014-07-02 12:09             ` Michael S. Tsirkin
2014-07-02 14:21           ` Gabriel L. Somlo
2014-07-02 15:17             ` Michael S. Tsirkin

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=53B575D0.7080700@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).