From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: qemu-devel@nongnu.org
Cc: Daniel Henrique Barboza <danielhb413@gmail.com>,
qemu-ppc@nongnu.org, groug@kaod.org, david@gibson.dropbear.id.au
Subject: [PATCH v3 2/7] spapr_pci.c: simplify spapr_pci_unplug_request() function handling
Date: Thu, 11 Feb 2021 19:52:41 -0300 [thread overview]
Message-ID: <20210211225246.17315-3-danielhb413@gmail.com> (raw)
In-Reply-To: <20210211225246.17315-1-danielhb413@gmail.com>
When hotunplugging a PCI function we'll branch out the logic in two cases,
function zero and non-zero. If non-zero, we'll call spapr_drc_detach() and
nothing else. If it's function zero, we'll loop it once between all the
functions in the slot to call spapr_drc_detach() on them, and afterwards
we'll do another backwards loop where we'll signal the event to the guest.
We can simplify this logic. We can ignore all the DRC handling for non-zero
functions, since we'll end up doing that regardless when unplugging function
zero. And for function zero, everything can be done in a single loop, since
tt doesn't matter if we end up marking the function DRCs as unplug pending in
backwards order or not, as long as we call spapr_drc_detach() before issuing
the hotunplug event to the guest.
This will also avoid a possible scenario where the user starts to hotunplug
the slot, starting with a non-zero function, and then delays/forgets to
hotunplug function zero afterwards. This would keep the function DRC marked
as unplug requested indefinitely.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
hw/ppc/spapr_pci.c | 44 ++++++++++++++++----------------------------
1 file changed, 16 insertions(+), 28 deletions(-)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index f1c7479816..1791d98a49 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1709,38 +1709,26 @@ static void spapr_pci_unplug_request(HotplugHandler *plug_handler,
return;
}
- /* ensure any other present functions are pending unplug */
- if (PCI_FUNC(pdev->devfn) == 0) {
- for (i = 1; i < 8; i++) {
- func_drc = drc_from_devfn(phb, chassis, PCI_DEVFN(slotnr, i));
- func_drck = SPAPR_DR_CONNECTOR_GET_CLASS(func_drc);
- state = func_drck->dr_entity_sense(func_drc);
- if (state == SPAPR_DR_ENTITY_SENSE_PRESENT
- && !spapr_drc_unplug_requested(func_drc)) {
- /*
- * Attempting to remove function 0 of a multifunction
- * device will will cascade into removing all child
- * functions, even if their unplug weren't requested
- * beforehand.
- */
- spapr_drc_detach(func_drc);
- }
- }
+ /*
+ * The hotunplug itself will occur when unplugging function 0,
+ * regardless of marking any other functions DRCs as pending
+ * unplug beforehand (since 02a1536eee33).
+ */
+ if (PCI_FUNC(pdev->devfn) != 0) {
+ return;
}
- spapr_drc_detach(drc);
+ for (i = 7; i >= 0; i--) {
+ func_drc = drc_from_devfn(phb, chassis, PCI_DEVFN(slotnr, i));
+ func_drck = SPAPR_DR_CONNECTOR_GET_CLASS(func_drc);
+ state = func_drck->dr_entity_sense(func_drc);
- /* if this isn't func 0, defer unplug event. otherwise signal removal
- * for all present functions
- */
- if (PCI_FUNC(pdev->devfn) == 0) {
- for (i = 7; i >= 0; i--) {
- func_drc = drc_from_devfn(phb, chassis, PCI_DEVFN(slotnr, i));
- func_drck = SPAPR_DR_CONNECTOR_GET_CLASS(func_drc);
- state = func_drck->dr_entity_sense(func_drc);
- if (state == SPAPR_DR_ENTITY_SENSE_PRESENT) {
- spapr_hotplug_req_remove_by_index(func_drc);
+ if (state == SPAPR_DR_ENTITY_SENSE_PRESENT) {
+ /* Mark the DRC as requested unplug if needed. */
+ if (!spapr_drc_unplug_requested(func_drc)) {
+ spapr_drc_detach(func_drc);
}
+ spapr_hotplug_req_remove_by_index(func_drc);
}
}
}
--
2.29.2
next prev parent reply other threads:[~2021-02-11 22:58 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-11 22:52 [PATCH v3 0/7] CPU unplug timeout/LMB unplug cleanup in DRC reconfiguration Daniel Henrique Barboza
2021-02-11 22:52 ` [PATCH v3 1/7] spapr_drc.c: do not call spapr_drc_detach() in drc_isolate_logical() Daniel Henrique Barboza
2021-02-15 10:40 ` Greg Kurz
2021-02-17 0:51 ` David Gibson
2021-02-11 22:52 ` Daniel Henrique Barboza [this message]
2021-02-16 15:50 ` [PATCH v3 2/7] spapr_pci.c: simplify spapr_pci_unplug_request() function handling Greg Kurz
2021-02-16 16:09 ` Daniel Henrique Barboza
2021-02-16 17:16 ` Greg Kurz
2021-02-16 17:44 ` Daniel Henrique Barboza
2021-02-17 0:54 ` David Gibson
2021-02-11 22:52 ` [PATCH v3 3/7] spapr_drc.c: use spapr_drc_release() in isolate_physical/set_unusable Daniel Henrique Barboza
2021-02-17 0:57 ` David Gibson
2021-02-17 10:58 ` Greg Kurz
2021-02-11 22:52 ` [PATCH v3 4/7] spapr: rename spapr_drc_detach() to spapr_drc_unplug_request() Daniel Henrique Barboza
2021-02-17 0:58 ` David Gibson
2021-02-17 11:01 ` Greg Kurz
2021-02-11 22:52 ` [PATCH v3 5/7] spapr_drc.c: introduce unplug_timeout_timer Daniel Henrique Barboza
2021-02-17 1:14 ` David Gibson
2021-02-17 1:20 ` David Gibson
2021-02-11 22:52 ` [PATCH v3 6/7] spapr_drc.c: add hotunplug timeout for CPUs Daniel Henrique Barboza
2021-02-17 1:23 ` David Gibson
2021-02-11 22:52 ` [PATCH v3 7/7] spapr_drc.c: use DRC reconfiguration to cleanup DIMM unplug state Daniel Henrique Barboza
2021-02-17 2:31 ` David Gibson
2021-02-19 20:04 ` Daniel Henrique Barboza
2021-02-22 5:53 ` David Gibson
2021-02-19 21:31 ` Daniel Henrique Barboza
2021-02-22 5:54 ` David Gibson
2021-02-17 2:33 ` [PATCH v3 0/7] CPU unplug timeout/LMB unplug cleanup in DRC reconfiguration David Gibson
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=20210211225246.17315-3-danielhb413@gmail.com \
--to=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).