Blame SOURCES/0503-powerpc-do-CAS-in-a-more-compatible-way.patch

b9d01e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b9d01e
From: Daniel Axtens <dja@axtens.net>
b9d01e
Date: Fri, 8 Apr 2022 12:35:28 +1000
b9d01e
Subject: [PATCH] powerpc: do CAS in a more compatible way
b9d01e
b9d01e
I wrongly assumed that the most compatible way to perform CAS
b9d01e
negotiation was to only set the minimum number of vectors required
b9d01e
to ask for more memory. It turns out that this messes up booting
b9d01e
if the minimum VP capacity would be less than the default 10% in
b9d01e
vector 4.
b9d01e
b9d01e
Linux configures the minimum capacity to be 1%, so copy it for that
b9d01e
and for vector 3 which we now need to specify as well.
b9d01e
b9d01e
Signed-off-by: Daniel Axtens <dja@axtens.net>
b9d01e
(cherry picked from commit e6f02ad4e75cd995a8ee2954d28949c415b6cbfe)
b9d01e
(cherry picked from commit 9f825ebc319c56ca503741e6dc1a0f27ff36fe2d)
b9d01e
---
b9d01e
 grub-core/kern/ieee1275/init.c | 54 ++++++++++++++++++++++++------------------
b9d01e
 1 file changed, 31 insertions(+), 23 deletions(-)
b9d01e
b9d01e
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
b9d01e
index adf4bd5a88..1414695cc6 100644
b9d01e
--- a/grub-core/kern/ieee1275/init.c
b9d01e
+++ b/grub-core/kern/ieee1275/init.c
b9d01e
@@ -294,33 +294,37 @@ grub_ieee1275_total_mem (grub_uint64_t *total)
b9d01e
 
b9d01e
 /* Based on linux - arch/powerpc/kernel/prom_init.c */
b9d01e
 struct option_vector2 {
b9d01e
-	grub_uint8_t byte1;
b9d01e
-	grub_uint16_t reserved;
b9d01e
-	grub_uint32_t real_base;
b9d01e
-	grub_uint32_t real_size;
b9d01e
-	grub_uint32_t virt_base;
b9d01e
-	grub_uint32_t virt_size;
b9d01e
-	grub_uint32_t load_base;
b9d01e
-	grub_uint32_t min_rma;
b9d01e
-	grub_uint32_t min_load;
b9d01e
-	grub_uint8_t min_rma_percent;
b9d01e
-	grub_uint8_t max_pft_size;
b9d01e
+  grub_uint8_t byte1;
b9d01e
+  grub_uint16_t reserved;
b9d01e
+  grub_uint32_t real_base;
b9d01e
+  grub_uint32_t real_size;
b9d01e
+  grub_uint32_t virt_base;
b9d01e
+  grub_uint32_t virt_size;
b9d01e
+  grub_uint32_t load_base;
b9d01e
+  grub_uint32_t min_rma;
b9d01e
+  grub_uint32_t min_load;
b9d01e
+  grub_uint8_t min_rma_percent;
b9d01e
+  grub_uint8_t max_pft_size;
b9d01e
 } __attribute__((packed));
b9d01e
 
b9d01e
 struct pvr_entry {
b9d01e
-	  grub_uint32_t mask;
b9d01e
-	  grub_uint32_t entry;
b9d01e
+  grub_uint32_t mask;
b9d01e
+  grub_uint32_t entry;
b9d01e
 };
b9d01e
 
b9d01e
 struct cas_vector {
b9d01e
-    struct {
b9d01e
-      struct pvr_entry terminal;
b9d01e
-    } pvr_list;
b9d01e
-    grub_uint8_t num_vecs;
b9d01e
-    grub_uint8_t vec1_size;
b9d01e
-    grub_uint8_t vec1;
b9d01e
-    grub_uint8_t vec2_size;
b9d01e
-    struct option_vector2 vec2;
b9d01e
+  struct {
b9d01e
+    struct pvr_entry terminal;
b9d01e
+  } pvr_list;
b9d01e
+  grub_uint8_t num_vecs;
b9d01e
+  grub_uint8_t vec1_size;
b9d01e
+  grub_uint8_t vec1;
b9d01e
+  grub_uint8_t vec2_size;
b9d01e
+  struct option_vector2 vec2;
b9d01e
+  grub_uint8_t vec3_size;
b9d01e
+  grub_uint16_t vec3;
b9d01e
+  grub_uint8_t vec4_size;
b9d01e
+  grub_uint16_t vec4;
b9d01e
 } __attribute__((packed));
b9d01e
 
b9d01e
 /* Call ibm,client-architecture-support to try to get more RMA.
b9d01e
@@ -341,13 +345,17 @@ grub_ieee1275_ibm_cas (void)
b9d01e
   } args;
b9d01e
   struct cas_vector vector = {
b9d01e
     .pvr_list = { { 0x00000000, 0xffffffff } }, /* any processor */
b9d01e
-    .num_vecs = 2 - 1,
b9d01e
+    .num_vecs = 4 - 1,
b9d01e
     .vec1_size = 0,
b9d01e
     .vec1 = 0x80, /* ignore */
b9d01e
     .vec2_size = 1 + sizeof(struct option_vector2) - 2,
b9d01e
     .vec2 = {
b9d01e
       0, 0, -1, -1, -1, -1, -1, 512, -1, 0, 48
b9d01e
     },
b9d01e
+    .vec3_size = 2 - 1,
b9d01e
+    .vec3 = 0x00e0, // ask for FP + VMX + DFP but don't halt if unsatisfied
b9d01e
+    .vec4_size = 2 - 1,
b9d01e
+    .vec4 = 0x0001, // set required minimum capacity % to the lowest value
b9d01e
   };
b9d01e
 
b9d01e
   INIT_IEEE1275_COMMON (&args.common, "call-method", 3, 2);
b9d01e
@@ -360,7 +368,7 @@ grub_ieee1275_ibm_cas (void)
b9d01e
   args.ihandle = root;
b9d01e
   args.cas_addr = (grub_ieee1275_cell_t)&vector;
b9d01e
 
b9d01e
-  grub_printf("Calling ibm,client-architecture-support...");
b9d01e
+  grub_printf("Calling ibm,client-architecture-support from grub...");
b9d01e
   IEEE1275_CALL_ENTRY_FN (&args);
b9d01e
   grub_printf("done\n");
b9d01e