qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 1/5] spapr.c: assert first DRC LMB earlier in spapr_memory_unplug_request()
Date: Fri, 26 Feb 2021 13:32:57 -0300	[thread overview]
Message-ID: <20210226163301.419727-2-danielhb413@gmail.com> (raw)
In-Reply-To: <20210226163301.419727-1-danielhb413@gmail.com>

We are asserting the existence of the first DRC LMB after sending unplug
requests to all LMBs of the DIMM, where every DRC is being asserted
inside the loop. This means that the first DRC is being asserted twice.

We will use the first DRC to simplify the code a bit in the next patch,
so instead of removing the duplicated assert, let's do it earlier.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/ppc/spapr.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 6eaddb12cb..74e046b522 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3664,7 +3664,7 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
     uint32_t nr_lmbs;
     uint64_t size, addr_start, addr;
     int i;
-    SpaprDrc *drc;
+    SpaprDrc *drc, *drc_start;
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
         error_setg(errp, "nvdimm device hot unplug is not supported yet.");
@@ -3677,6 +3677,10 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
     addr_start = object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP,
                                           &error_abort);
 
+    drc_start = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB,
+                                addr_start / SPAPR_MEMORY_BLOCK_SIZE);
+    g_assert(drc_start);
+
     /*
      * An existing pending dimm state for this DIMM means that there is an
      * unplug operation in progress, waiting for the spapr_lmb_release
@@ -3701,11 +3705,9 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
         addr += SPAPR_MEMORY_BLOCK_SIZE;
     }
 
-    drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB,
-                          addr_start / SPAPR_MEMORY_BLOCK_SIZE);
-    g_assert(drc);
     spapr_hotplug_req_remove_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB,
-                                              nr_lmbs, spapr_drc_index(drc));
+                                              nr_lmbs,
+                                              spapr_drc_index(drc_start));
 }
 
 /* Callback to be called during DRC release. */
-- 
2.29.2



  reply	other threads:[~2021-02-26 16:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-26 16:32 [PATCH 0/5] send QAPI_EVENT_MEM_UNPLUG_ERROR for ppc64 unplugs Daniel Henrique Barboza
2021-02-26 16:32 ` Daniel Henrique Barboza [this message]
2021-03-01 14:11   ` [PATCH 1/5] spapr.c: assert first DRC LMB earlier in spapr_memory_unplug_request() Greg Kurz
2021-02-26 16:32 ` [PATCH 2/5] spapr.c: check unplug_request flag " Daniel Henrique Barboza
2021-03-01 14:13   ` Greg Kurz
2021-03-02  2:03   ` David Gibson
2021-03-02 10:39     ` Daniel Henrique Barboza
2021-02-26 16:32 ` [PATCH 3/5] spapr.c: add 'unplug already in progress' message for PHB unplug Daniel Henrique Barboza
2021-03-01 14:14   ` Greg Kurz
2021-03-02  2:06   ` David Gibson
2021-02-26 16:33 ` [PATCH 4/5] spapr_pci.c: add 'unplug already in progress' message for PCI unplug Daniel Henrique Barboza
2021-03-01 14:14   ` Greg Kurz
2021-03-02  2:08   ` David Gibson
2021-02-26 16:33 ` [PATCH 5/5] spapr.c: send QAPI event when memory hotunplug fails Daniel Henrique Barboza
2021-03-01 14:19   ` Greg Kurz
2021-03-02  2:11   ` 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=20210226163301.419727-2-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).