From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1yR6-00044r-JX for qemu-devel@nongnu.org; Fri, 19 Dec 2014 09:21:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1yR1-00025y-30 for qemu-devel@nongnu.org; Fri, 19 Dec 2014 09:21:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49536) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1yR0-00025g-QG for qemu-devel@nongnu.org; Fri, 19 Dec 2014 09:21:39 -0500 Date: Fri, 19 Dec 2014 16:21:32 +0200 From: "Michael S. Tsirkin" Message-ID: <20141219142132.GA13200@redhat.com> References: <1418995104-26262-1-git-send-email-stefanha@redhat.com> <1418995104-26262-6-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1418995104-26262-6-git-send-email-stefanha@redhat.com> Subject: Re: [Qemu-devel] [PULL 5/5] e1000: defer packets until BM enabled List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Peter Maydell , qemu-devel@nongnu.org On Fri, Dec 19, 2014 at 01:18:24PM +0000, Stefan Hajnoczi wrote: > From: "Michael S. Tsirkin" > > Some guests seem to set BM for e1000 after > enabling RX. > If packets arrive in the window, device is wedged. > Probably works by luck on real hardware, work around > this by making can_receive depend on BM. > > Tested-by: Gabriel Somlo > Signed-off-by: Michael S. Tsirkin > Reviewed-by: Jason Wang > Signed-off-by: Stefan Hajnoczi Pls defer this. This does not help windows as I thought it does, no point in making changes until we have figured it out. > --- > hw/net/e1000.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > diff --git a/hw/net/e1000.c b/hw/net/e1000.c > index e33a4da..89c5788 100644 > --- a/hw/net/e1000.c > +++ b/hw/net/e1000.c > @@ -33,6 +33,7 @@ > #include "sysemu/sysemu.h" > #include "sysemu/dma.h" > #include "qemu/iov.h" > +#include "qemu/range.h" > > #include "e1000_regs.h" > > @@ -923,7 +924,9 @@ e1000_can_receive(NetClientState *nc) > E1000State *s = qemu_get_nic_opaque(nc); > > return (s->mac_reg[STATUS] & E1000_STATUS_LU) && > - (s->mac_reg[RCTL] & E1000_RCTL_EN) && e1000_has_rxbufs(s, 1); > + (s->mac_reg[RCTL] & E1000_RCTL_EN) && > + (s->parent_obj.config[PCI_COMMAND] & PCI_COMMAND_MASTER) && > + e1000_has_rxbufs(s, 1); > } > > static uint64_t rx_desc_base(E1000State *s) > @@ -1529,6 +1532,20 @@ static NetClientInfo net_e1000_info = { > .link_status_changed = e1000_set_link_status, > }; > > +static void e1000_write_config(PCIDevice *pci_dev, uint32_t address, > + uint32_t val, int len) > +{ > + E1000State *s = E1000(pci_dev); > + > + 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)) { > + qemu_flush_queued_packets(qemu_get_queue(s->nic)); > + } > +} > + > + > static int pci_e1000_init(PCIDevice *pci_dev) > { > DeviceState *dev = DEVICE(pci_dev); > @@ -1539,6 +1556,8 @@ static int pci_e1000_init(PCIDevice *pci_dev) > int i; > uint8_t *macaddr; > > + pci_dev->config_write = e1000_write_config; > + > pci_conf = pci_dev->config; > > /* TODO: RST# value should be 0, PCI spec 6.2.4 */ > -- > 2.1.0