[11/22] xive/p9: fix EQ bitmap assignment when allocation fails
diff mbox series

Message ID 20190903170413.4373-12-clg@kaod.org
State Superseded
Headers show
Series
  • xive: new interfaces, fixes and cleanups in a new driver
Related show

Checks

Context Check Description
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (7b12d5489fcfd73ef7ec0cb27eff7f8a5f13b238)

Commit Message

Cédric Le Goater Sept. 3, 2019, 5:04 p.m. UTC
Wehn allocating a EQ set for a VP, the EQ base index bit is marked as
allocated even if allocation fails, due to a lack of available pages.

Move bit assignment at the end of xive_alloc_eq_set().

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/xive-p9.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/hw/xive-p9.c b/hw/xive-p9.c
index 2232220babd6..b5c437fec8b1 100644
--- a/hw/xive-p9.c
+++ b/hw/xive-p9.c
@@ -849,6 +849,7 @@  static uint32_t xive_alloc_eq_set(struct xive *x, bool alloc_indirect)
 {
 	uint32_t ind_idx;
 	int idx;
+	int eq_base_idx;
 
 	xive_vdbg(x, "Allocating EQ set...\n");
 
@@ -860,14 +861,13 @@  static uint32_t xive_alloc_eq_set(struct xive *x, bool alloc_indirect)
 		xive_dbg(x, "Allocation from EQ bitmap failed !\n");
 		return XIVE_ALLOC_NO_SPACE;
 	}
-	bitmap_set_bit(*x->eq_map, idx);
 
-	idx <<= 3;
+	eq_base_idx = idx << 3;
 
-	xive_vdbg(x, "Got EQs 0x%x..0x%x\n", idx, idx + 7);
+	xive_vdbg(x, "Got EQs 0x%x..0x%x\n", eq_base_idx, eq_base_idx + 7);
 
 	/* Calculate the indirect page where the EQs reside */
-	ind_idx = idx / EQ_PER_PAGE;
+	ind_idx = eq_base_idx / EQ_PER_PAGE;
 
 	/* Is there an indirect page ? If not, check if we can provision it */
 	if (!x->eq_ind_base[ind_idx]) {
@@ -902,14 +902,15 @@  static uint32_t xive_alloc_eq_set(struct xive *x, bool alloc_indirect)
 		/* Any cache scrub needed ? */
 	}
 
-	return idx;
+	bitmap_set_bit(*x->eq_map, idx);
+	return eq_base_idx;
 }
 
 static void xive_free_eq_set(struct xive *x, uint32_t eqs)
 {
 	uint32_t idx;
 
-	xive_vdbg(x, "Freeing EQ set...\n");
+	xive_vdbg(x, "Freeing EQ 0x%x..0x%x\n", eqs, eqs + 7);
 
 	assert((eqs & 7) == 0);
 	assert(x->eq_map);