qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: Yaniv Kamay <ykamay@redhat.com>, Dor Laor <dlaor@redhat.com>,
	Avi Kivity <avi@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/3] Add pci_bus_reset() function.
Date: Tue, 9 Jun 2009 18:24:33 +0300	[thread overview]
Message-ID: <20090609152433.GK5558@redhat.com> (raw)
In-Reply-To: <f43fc5580906090807n2794a15fne68ee6ccdcbd6d36@mail.gmail.com>

On Tue, Jun 09, 2009 at 06:07:00PM +0300, Blue Swirl wrote:
> On 6/9/09, Gleb Natapov <gleb@redhat.com> wrote:
> > On Tue, Jun 09, 2009 at 12:42:16AM +0300, Dor Laor wrote:
> >  > Gleb Natapov wrote:
> >  >> On Mon, Jun 08, 2009 at 05:35:11PM +0300, Avi Kivity wrote:
> >  >>
> >  >>> Gleb Natapov wrote:
> >  >>>
> >  >>>> To reset internal irq handling data structures.
> >  >>>>
> >  >>>> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> >  >>>> Signed-off-by: Yaniv Kamay <ykamay@redhat.com>
> >  >>>> ---
> >  >>>>  hw/pci.c |   16 ++++++++++++++++
> >  >>>>  1 files changed, 16 insertions(+), 0 deletions(-)
> >  >>>>
> >  >>>> diff --git a/hw/pci.c b/hw/pci.c
> >  >>>> index 02b335f..89fefdf 100644
> >  >>>> --- a/hw/pci.c
> >  >>>> +++ b/hw/pci.c
> >  >>>> @@ -88,6 +88,21 @@ static int  pcibus_load(QEMUFile *f, void *opaque, int version_id)
> >  >>>>      return 0;
> >  >>>>  }
> >  >>>>  +static void pci_bus_reset(void *opaque)
> >  >>>> +{
> >  >>>> +    PCIBus *bus = (PCIBus *)opaque;
> >  >>>> +    int i;
> >  >>>> +
> >  >>>> +    for (i = 0; i < bus->nirq; i++) {
> >  >>>> +        bus->irq_count[i] = 0;
> >  >>>> +    }
> >  >>>> +    for (i = 0; i < PCI_DEVICES_MAX; i++) {
> >  >>>> +        if (bus->devices[i])
> >  >>>> +            memset(bus->devices[i]->irq_state, 0,
> >  >>>> +                   sizeof(bus->devices[i]->irq_state));
> >  >>>> +    }
> >  >>>> +}
> >  >>>> +
> >  >>>>
> >  >>> Shouldn't each device's reset function bring its line low, thus
> >  >>> zeroing  the irq_state naturally?
> >  >>>
> >  >>> If not, we have a bug somewhere.  Note we have exactly the same issue
> >  >>>  with save/restore.
> >  >>>
> >  >>>
> >  >> They should, but I haven't found one that does.
> >  >>
> >  > virtio does and so do many others. Sad thing is that all should do it
> >  > since the line is shared.
> >  > e1000 and rtl8139 do not register a reset handler.
> >  >
> >
> > So somebody (not me) should go and fix all others.
> 
> Here's a 5 min patch to add reset to e1000 and rtl8139. Not too difficult?
> 
Very handy. I just discovered that e1000 continue to write to memory
after OS reboot with some OSes. Will check if this fixes it.


> >  > Maybe we should make it a required callback for pci_qdev_register? or better
> >  > have every (pci?) device register several callback together.
> >
> > May be.
> 
> If we go to this, I'd also make savevm/loadvm mandatory.

We need this for device hot unplug. We have to be able to reset only one
device at a time.

--
			Gleb.

  reply	other threads:[~2009-06-09 15:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-08 12:56 [Qemu-devel] [PATCH 1/3] Add rtc reset function Gleb Natapov
2009-06-08 12:56 ` [Qemu-devel] [PATCH 2/3] Add pci_bus_reset() function Gleb Natapov
2009-06-08 14:35   ` Avi Kivity
2009-06-08 14:37     ` Gleb Natapov
2009-06-08 14:42       ` Yaniv Kamay
2009-06-08 21:42       ` Dor Laor
2009-06-09  5:31         ` Gleb Natapov
2009-06-09 15:07           ` Blue Swirl
2009-06-09 15:24             ` Gleb Natapov [this message]
2009-06-09 15:53             ` Gleb Natapov
2009-06-09 16:07               ` Blue Swirl
2009-06-08 12:56 ` [Qemu-devel] [PATCH 3/3] Call piix3_reset() on system reset Gleb Natapov
2009-06-08 14:05 ` [Qemu-devel] Re: [PATCH 1/3] Add rtc reset function Jan Kiszka
2009-06-08 14:13   ` Gleb Natapov

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=20090609152433.GK5558@redhat.com \
    --to=gleb@redhat.com \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=dlaor@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=ykamay@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).