qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Annie.li" <annie.li@oracle.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 1/1] pcie: Do not set power state for some hot-plugged devices
Date: Wed, 15 Dec 2021 14:20:28 -0500	[thread overview]
Message-ID: <1f85fe9e-0753-c35a-668d-3b6779bc703b@oracle.com> (raw)
In-Reply-To: <20211215060513.kugy3y32nj2te7ui@sirius.home.kraxel.org>


On 12/15/2021 1:05 AM, Gerd Hoffmann wrote:
> On Tue, Dec 14, 2021 at 09:53:12PM +0000, Annie Li wrote:
>> After the PCIe device is hot-plugged, the device's power state is
>> initialized as ON. However, the device isn't powered on yet, i.e.
>> the PCI_EXP_SYSCTL_PCC bit isn't set to PCI_EXP_SLTCTL_PWR_ON.
>> Later on, its power state will set back to OFF due to the non
>> PCI_EXP_SLTCTL_PWR_ON state. The device is invisible until
>> PCI_EXP_SLTCTL_PWR_ON is set.
>>
>> This may be appropriate for general PCIe hot-plug cases. However,
>> if the device is hot-plugged when the VM is in VM_STATE_PRELAUNCH
>> state, especially the system disk device, the firmware will fail
>> to find the system disk. As a result, the guest fails to boot.
> Maybe we should just not set DeviceState->hotplugged = true for devices
> added in VM_STATE_PRELAUNCH?  It's not actual hotplug (i.e. device added
> while the system is running) after all ...
Simply not setting "DeviceState->hotplugged" doesn't work. Devices 
created in
PHASE_MACHINE_READY phase are treated as hot-plugged devices. So I just 
tried
following change for the quick test, the device is still invisible to 
the firmware with
this change.

static void device_initfn(Object *obj)
{
...snip...
-     if (phase_check(PHASE_MACHINE_READY)) {
+    if (phase_check(PHASE_MACHINE_READY) && 
!runstate_check(RUN_STATE_PRELAUNCH)) {
         dev->hotplugged = 1;
         qdev_hot_added = true;
     }
...snip...
}

Thanks
Annie
>
> There are lots of places checking DeviceState->hotplugged, and I suspect
> we have similar issues elsewhere.
>
> take care,
>    Gerd
>


  reply	other threads:[~2021-12-15 19:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14 21:53 [PATCH 1/1] pcie: Do not set power state for some hot-plugged devices Annie Li
2021-12-15  6:05 ` Gerd Hoffmann
2021-12-15 19:20   ` Annie.li [this message]
2021-12-16  6:11     ` Gerd Hoffmann
2021-12-16 23:10       ` Annie.li
2021-12-17  6:47         ` Gerd Hoffmann

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=1f85fe9e-0753-c35a-668d-3b6779bc703b@oracle.com \
    --to=annie.li@oracle.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).