qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Amos Kong <akong@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: mst@redhat.com, jasowang@redhat.com, marcel.a@redhat.com,
	qemu-devel@nongnu.org, stefanha@redhat.com, somlo@cmu.edu
Subject: Re: [Qemu-devel] [PATCH 2/2] e1000: unconditionally enable bus mastering
Date: Wed, 11 Feb 2015 00:11:20 +0800	[thread overview]
Message-ID: <20150210161120.GA21088@air.redhat.com> (raw)
In-Reply-To: <20150206134636.GA18729@stefanha-thinkpad.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2717 bytes --]

On Fri, Feb 06, 2015 at 01:46:36PM +0000, Stefan Hajnoczi wrote:
> On Wed, Jan 07, 2015 at 04:08:29PM +0000, Stefan Hajnoczi wrote:
> > On Thu, Dec 18, 2014 at 05:22:19PM +0800, Amos Kong wrote:
> > > After enabled network debug of e1000 in Win2012-64r2 guest,
> > > Bus mastering of e1000 can't be enabled by e1000 driver. It
> > > caused guest can't get IP address.
> > > 
> > >   # bcdedit /debug on
> > >   # bcdedit /dbgsettings net hostip:192.168.122.100 port:50000
> > >   (We can use non-existed IP here, it's just used to pass the
> > >    setup, not really use it)
> > > 
> > > If we disable debug function, e1000 driver can enable bus
> > > mastering bit successfully, guest network is fine.
> > > 
> > > This patch changed e1000 backend to enalbe bus mastering
> > > unconditionally as a workaround.
> > > 
> > > Signed-off-by: Amos Kong <akong@redhat.com>
> > > ---
> > >  hw/net/e1000.c | 11 +++++++++--
> > >  1 file changed, 9 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/hw/net/e1000.c b/hw/net/e1000.c
> > > index ec9224b..82829ae 100644
> > > --- a/hw/net/e1000.c
> > > +++ b/hw/net/e1000.c
> > > @@ -1544,8 +1544,15 @@ static void e1000_write_config(PCIDevice *pci_dev, uint32_t address,
> > >  
> > >      pci_default_write_config(pci_dev, address, val, len);
> > >  
> > > -    if (range_covers_byte(address, len, PCI_COMMAND) &&
> > > -        (pci_dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER)) {
> > > +    if (range_covers_byte(address, len, PCI_COMMAND)) {
> > > +        /*
> > > +         * Some guest (eg: Win2012-64r2) doesn't enable bus mastering
> > > +         * correctly, it caused guest network down. So we unconditionally
> > > +         * enable PCI bus mastering and BM memory region for e1000 as
> > > +         * a workaround.
> > > +         */
> > > +        pci_dev->config[PCI_COMMAND] |= PCI_COMMAND_MASTER;
> > > +        memory_region_set_enabled(&pci_dev->bus_master_enable_region, true);
> > >          qemu_flush_queued_packets(qemu_get_queue(s->nic));
> > >          start_xmit(s);
> > >      }
> > 
> > This is weird.
> > 
> > Are you sure there's not some guest behavior missing like the NIC option
> > ROM leaving bus mastering enabled after the BIOS/EFI has booted, causing
> > Windows debug to work on physical machines?

QEMU emulated e1000 is too old, it's not in the official support
list of window network debug.

> > Before we merge a hack like this we should understand the problem 100%.
> 
> Any new insights into what is going on here?

It's not good to unconditionaly enable BM, we should enable/disable it
according to other event/status change.
 
> Stefan

-- 
			Amos.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-02-10 16:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-18  9:22 [Qemu-devel] [PATCH 0/2] ignore bus master for e1000 Amos Kong
2014-12-18  9:22 ` [Qemu-devel] [PATCH 1/2] e1000: defer packets until BM enabled Amos Kong
2014-12-18  9:22 ` [Qemu-devel] [PATCH 2/2] e1000: unconditionally enable bus mastering Amos Kong
2014-12-18  9:49   ` Jason Wang
2014-12-18 10:30     ` Amos Kong
2015-01-07 16:08   ` Stefan Hajnoczi
2015-02-06 13:46     ` Stefan Hajnoczi
2015-02-10 16:11       ` Amos Kong [this message]
2014-12-18 10:05 ` [Qemu-devel] [PATCH 0/2] ignore bus master for e1000 Jason Wang
2014-12-18 11:01   ` Denis V. Lunev
2014-12-18 11:11     ` Denis V. Lunev
2014-12-19  4:59       ` Jason Wang
2014-12-19  3:09   ` Amos Kong
2014-12-19  5:00     ` Jason Wang

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=20150210161120.GA21088@air.redhat.com \
    --to=akong@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=marcel.a@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=somlo@cmu.edu \
    --cc=stefanha@gmail.com \
    --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).