Skip to contentSkip to conversation

spapr/drc: don't migrate DRC of cold-plugged CPUs and LMBs

PATCH In review Greg Kurz 2 participants 2 messages Jun 2, 2017 – Jun 5, 2017

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

PATCH 1/1 spapr/drc: don't migrate DRC of cold-plugged CPUs and LMBs

As explained in commit 5c0139a8c2f0 ("spapr: fix default DRC state for coldplugged LMBs"), guests expect cold-plugged LMBs to be pre-allocated and unisolated. The same goes for cold-plugged CPUs.

While here, let's convert g_assert(false) to the better self documenting g_assert_not_reached().

---

FWIW

$ git grep -i -E '(g_)?assert\((0|false)\)' | wc -l
100
$ git grep g_assert_not_reached | wc -l
244
---
 hw/ppc/spapr_drc.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
hw/ppc/spapr_drc.c +3 -7
index cc2400bcd57f..ab5f7cdf569c 100644
@@ -538,20 +538,16 @@ static bool spapr_drc_needed(void *opaque)
      */
     switch (drc->type) {
     case SPAPR_DR_CONNECTOR_TYPE_PCI:
-        rc = !((drc->isolation_state == SPAPR_DR_ISOLATION_STATE_UNISOLATED) &&
-               (drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE) &&
-               drc->configured && drc->signalled && !drc->awaiting_release);
-        break;
     case SPAPR_DR_CONNECTOR_TYPE_CPU:
     case SPAPR_DR_CONNECTOR_TYPE_LMB:
-        rc = !((drc->isolation_state == SPAPR_DR_ISOLATION_STATE_ISOLATED) &&
-               (drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) &&
+        rc = !((drc->isolation_state == SPAPR_DR_ISOLATION_STATE_UNISOLATED) &&
+               (drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE) &&
                drc->configured && drc->signalled && !drc->awaiting_release);
         break;
     case SPAPR_DR_CONNECTOR_TYPE_PHB:
     case SPAPR_DR_CONNECTOR_TYPE_VIO:
     default:
-        g_assert(false);
+        g_assert_not_reached();
     }
     return rc;
 }
#1 lore raw
Quoted 8 lines · Greg Kurz

As explained in commit 5c0139a8c2f0 ("spapr: fix default DRC state for coldplugged LMBs"), guests expect cold-plugged LMBs to be pre-allocated and unisolated. The same goes for cold-plugged CPUs.

While here, let's convert g_assert(false) to the better self documenting g_assert_not_reached().

I've applied this to ppc-for-2.10. I'm a bit concerned that this is just another bandaid thrown at the mess which is the DRC code. I'm hoping to clean this up more thoroughly, which will obsolete this, but in the meantime it shouldn't be any worse than what we have.

Quoted 41 lines

---

FWIW

$ git grep -i -E '(g_)?assert\((0|false)\)' | wc -l
100
$ git grep g_assert_not_reached | wc -l
244
---
 hw/ppc/spapr_drc.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
hw/ppc/spapr_drc.c +3 -7
index cc2400bcd57f..ab5f7cdf569c 100644
@@ -538,20 +538,16 @@ static bool spapr_drc_needed(void *opaque)
      */
     switch (drc->type) {
     case SPAPR_DR_CONNECTOR_TYPE_PCI:
-        rc = !((drc->isolation_state == SPAPR_DR_ISOLATION_STATE_UNISOLATED) &&
-               (drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE) &&
-               drc->configured && drc->signalled && !drc->awaiting_release);
-        break;
     case SPAPR_DR_CONNECTOR_TYPE_CPU:
     case SPAPR_DR_CONNECTOR_TYPE_LMB:
-        rc = !((drc->isolation_state == SPAPR_DR_ISOLATION_STATE_ISOLATED) &&
-               (drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) &&
+        rc = !((drc->isolation_state == SPAPR_DR_ISOLATION_STATE_UNISOLATED) &&
+               (drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE) &&
                drc->configured && drc->signalled && !drc->awaiting_release);
         break;
     case SPAPR_DR_CONNECTOR_TYPE_PHB:
     case SPAPR_DR_CONNECTOR_TYPE_VIO:
     default:
-        g_assert(false);
+        g_assert_not_reached();
     }
     return rc;
 }
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson