Skip to contentSkip to conversation

Fix Xen boot-time cpupools handling

PATCH In review Michal Orzel 2 participants 2 messages Jan 26, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix Xen boot-time cpupools handling

When retrieving a phandle for a CPU node using "fdtget -t x", the resulting hex number (in case the phandle exists) lacks the '0x' prefix. This value is subsequently used to construct the cpupool-cpus property. This results in an incorrect property generation that leads to Xen failure (example: cpupool-cpus < a> instead of < 0xa>). Address the issue by adding 0x prefix to the result from fdtget.

Additionally, avoid unnecessary regeneration of the phandle if it already exists.

Fixes b687773b5046 ("Add support for Xen boot-time cpupools")

---
This only worked if phandle did not exist or if its value did not contain a-f and was regenerated anyway.

---
 scripts/uboot-script-gen | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/uboot-script-gen +2 -2
index 078a667c61ab..3cc6b47c7c62 100755
@@ -262,12 +262,12 @@ function add_device_tree_cpupools()
             fi
 
             # set phandle for a cpu if there is none
-            if ! phandle=$(fdtget -t x "${DEVICE_TREE}" "$cpu" "phandle" 2> /dev/null)
+            if ! phandle="0x$(fdtget -t x "${DEVICE_TREE}" "$cpu" "phandle" 2> /dev/null)"
             then
                 get_next_phandle phandle
+                dt_set "$cpu" "phandle" "hex" "$phandle"
             fi
 
-            dt_set "$cpu" "phandle" "hex" "$phandle"
             cpu_phandles="$cpu_phandles $phandle"
             cpu_list="$cpu_list $cpu"
         done
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Michal Orzel

When retrieving a phandle for a CPU node using "fdtget -t x", the resulting hex number (in case the phandle exists) lacks the '0x' prefix. This value is subsequently used to construct the cpupool-cpus property. This results in an incorrect property generation that leads to Xen failure (example: cpupool-cpus < a> instead of < 0xa>). Address the issue by adding 0x prefix to the result from fdtget.

Quoted 5 lines

Additionally, avoid unnecessary regeneration of the phandle if it already exists.

Fixes b687773b5046 ("Add support for Xen boot-time cpupools")
Quoted 29 lines

---
This only worked if phandle did not exist or if its value did not contain a-f and was regenerated anyway.

---
 scripts/uboot-script-gen | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/uboot-script-gen +2 -2
index 078a667c61ab..3cc6b47c7c62 100755
@@ -262,12 +262,12 @@ function add_device_tree_cpupools()
             fi
 
             # set phandle for a cpu if there is none
-            if ! phandle=$(fdtget -t x "${DEVICE_TREE}" "$cpu" "phandle" 2> /dev/null)
+            if ! phandle="0x$(fdtget -t x "${DEVICE_TREE}" "$cpu" "phandle" 2> /dev/null)"
             then
                 get_next_phandle phandle
+                dt_set "$cpu" "phandle" "hex" "$phandle"
             fi
 
-            dt_set "$cpu" "phandle" "hex" "$phandle"
             cpu_phandles="$cpu_phandles $phandle"
             cpu_list="$cpu_list $cpu"
         done
Signature · 1 line
2.25.1