Message ID | 20211011120504.254053-6-kraxel@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | RfC: try improve native hotplug for pcie root ports | expand |
On Mon, Oct 11, 2021 at 02:05:03PM +0200, Gerd Hoffmann wrote: > In case the slot is powered off (and the power indicator turned off too) > we can unplug right away, without round-trip to the guest. > > Also clear pending attention button press, there is nothing to care > about any more. > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> > --- > hw/pci/pcie.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c > index 70fc11ba4c7d..f3ac04399969 100644 > --- a/hw/pci/pcie.c > +++ b/hw/pci/pcie.c > @@ -561,6 +561,16 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, > return; > } > > + if (((sltctl & PCI_EXP_SLTCTL_PIC) == PCI_EXP_SLTCTL_PWR_IND_OFF) && > + ((sltctl & PCI_EXP_SLTCTL_PCC) == PCI_EXP_SLTCTL_PWR_OFF)) { > + /* slot is powered off -> unplug without round-trip to the guest */ > + pcie_cap_slot_do_unplug(hotplug_pdev); > + hotplug_event_notify(hotplug_pdev); > + pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA, > + PCI_EXP_SLTSTA_ABP); Does this handle all the things including link status etc btw? I don't remember off-hand. > + return; > + } > + > pcie_cap_slot_push_attention_button(hotplug_pdev); > } > > -- > 2.31.1
On Tue, Oct 12, 2021 at 01:56:31AM -0400, Michael S. Tsirkin wrote: > On Mon, Oct 11, 2021 at 02:05:03PM +0200, Gerd Hoffmann wrote: > > In case the slot is powered off (and the power indicator turned off too) > > we can unplug right away, without round-trip to the guest. > > > > Also clear pending attention button press, there is nothing to care > > about any more. > > > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> > > --- > > hw/pci/pcie.c | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c > > index 70fc11ba4c7d..f3ac04399969 100644 > > --- a/hw/pci/pcie.c > > +++ b/hw/pci/pcie.c > > @@ -561,6 +561,16 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, > > return; > > } > > > > + if (((sltctl & PCI_EXP_SLTCTL_PIC) == PCI_EXP_SLTCTL_PWR_IND_OFF) && > > + ((sltctl & PCI_EXP_SLTCTL_PCC) == PCI_EXP_SLTCTL_PWR_OFF)) { > > + /* slot is powered off -> unplug without round-trip to the guest */ > > + pcie_cap_slot_do_unplug(hotplug_pdev); > > + hotplug_event_notify(hotplug_pdev); > > + pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA, > > + PCI_EXP_SLTSTA_ABP); > > Does this handle all the things including link status etc btw? > I don't remember off-hand. Yes. See patch #4 which moves the relevant code to the new pcie_cap_slot_do_unplug() helper. take care, Gerd
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 70fc11ba4c7d..f3ac04399969 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -561,6 +561,16 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, return; } + if (((sltctl & PCI_EXP_SLTCTL_PIC) == PCI_EXP_SLTCTL_PWR_IND_OFF) && + ((sltctl & PCI_EXP_SLTCTL_PCC) == PCI_EXP_SLTCTL_PWR_OFF)) { + /* slot is powered off -> unplug without round-trip to the guest */ + pcie_cap_slot_do_unplug(hotplug_pdev); + hotplug_event_notify(hotplug_pdev); + pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA, + PCI_EXP_SLTSTA_ABP); + return; + } + pcie_cap_slot_push_attention_button(hotplug_pdev); }
In case the slot is powered off (and the power indicator turned off too) we can unplug right away, without round-trip to the guest. Also clear pending attention button press, there is nothing to care about any more. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- hw/pci/pcie.c | 10 ++++++++++ 1 file changed, 10 insertions(+)