diff mbox series

[v2,11/14] pnv/xive: Only support crowd size of 0, 2, 4 and 16

Message ID 20241210000527.9541-21-kowal@linux.ibm.com (mailing list archive)
State New
Headers show
Series XIVE2 changes to support Group and Crowd operations | expand

Commit Message

Michael Kowal Dec. 10, 2024, 12:05 a.m. UTC
From: Glenn Miles <milesg@linux.vnet.ibm.com>

XIVE crowd sizes are encoded into a 2-bit field as follows:
  0: 0b00
  2: 0b01
  4: 0b10
 16: 0b11

A crowd size of 8 is not supported.

Signed-off-by: Glenn Miles <milesg@linux.vnet.ibm.com>
Signed-off-by: Michael Kowal <kowal@linux.ibm.com>
---
 hw/intc/xive.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/hw/intc/xive.c b/hw/intc/xive.c
index 2a7ce72606..df77098dd7 100644
--- a/hw/intc/xive.c
+++ b/hw/intc/xive.c
@@ -1687,7 +1687,26 @@  static uint8_t xive_get_group_level(bool crowd, bool ignore,
     uint8_t level = 0;
 
     if (crowd) {
-        level = ((ctz32(~nvp_blk) + 1) & 0b11) << 4;
+        /* crowd level is bit position of first 0 from the right in nvp_blk */
+        level = ctz32(~nvp_blk) + 1;
+
+        /*
+         * Supported crowd sizes are 2^1, 2^2, and 2^4. 2^3 is not supported.
+         * HW will encode level 4 as the value 3.  See xive2_pgofnext().
+         */
+        switch (level) {
+        case 1:
+        case 2:
+            break;
+        case 4:
+            level = 3;
+            break;
+        default:
+            g_assert_not_reached();
+        }
+
+        /* Crowd level bits reside in upper 2 bits of the 6 bit group level */
+        level <<= 4;
     }
     if (ignore) {
         level |= (ctz32(~nvp_index) + 1) & 0b1111;