spapr: add ibm, chip-id property in device tree
PATCH 1/1 spapr: add ibm, chip-id property in device tree
This adds a "ibm,chip-id" property for CPU nodes which should be the same for all cores in the same CPU socket. The recent guest kernels use this information to associate threads with sockets.
Refer to the kernel commit 256f2d4b463d3030ebc8d2b54f427543814a2bdc for more details.
--- hw/ppc/spapr.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/ppc/spapr.c +9 -0
@@ -308,6 +308,8 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,uint32_t interrupt_server_ranges_prop[] = {0 ,cpu_to_be32 (smp_cpus)};int i, smt =kvmppc_smt_threads ();unsigned char vec5[] = {0x0 ,0x0 ,0x0 ,0x0 ,0x0 ,0x80 }; +QemuOpts *opts =qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL ); +unsigned sockets = opts ?qemu_opt_get_number (opts,"sockets" ,0 ) :0 ; fdt =g_malloc0 (FDT_MAX_SIZE );_FDT ((fdt_create (fdt,FDT_MAX_SIZE )));
@@ -465,6 +467,13 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base, page_sizes_prop, page_sizes_prop_size))); } +if (sockets) { +int cpus_per_socket = smp_cpus / sockets; +uint32_t chip_id = cs->cpu_index / cpus_per_socket; + +_FDT ((fdt_property_cell (fdt,"ibm,chip-id" , chip_id))); + } +_FDT ((fdt_end_node (fdt))); }
Signature · 1 line
1.8.4.rc4
Quoted 26 lines · Alexey Kardashevskiy
This adds a "ibm,chip-id" property for CPU nodes which should be the same for all cores in the same CPU socket. The recent guest kernels use this information to associate threads with sockets.
Refer to the kernel commit
256f2d4b463d3030ebc8d2b54f427543814a2bdcfor more details.Signed-off-by Alexey Kardashevskiy <[email protected]>--- hw/ppc/spapr.c | 9 +++++++++ 1 file changed, 9 insertions(+)hw/ppc/spapr.c +2
-0@@ -308,6 +308,8 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,uint32_t interrupt_server_ranges_prop[] = {0 ,cpu_to_be32 (smp_cpus)};int i, smt =kvmppc_smt_threads ();unsigned char vec5[] = {0x0 ,0x0 ,0x0 ,0x0 ,0x0 ,0x80 }; +QemuOpts *opts =qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL ); +unsigned sockets = opts ?qemu_opt_get_number (opts,"sockets" ,0 ) :0 ; fdt =g_malloc0 (FDT_MAX_SIZE );_FDT ((fdt_create (fdt,FDT_MAX_SIZE )));
hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 475
Quoted 9 lines
hw/ppc/spapr.c +6
-0@@ -465,6 +467,13 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base, page_sizes_prop, page_sizes_prop_size))); } +if (sockets) { +int cpus_per_socket = smp_cpus / sockets; +uint32_t chip_id = cs->cpu_index / cpus_per_socket; + +_FDT ((fdt_property_cell (fdt,"ibm,chip-id" , chip_id))); + }
Have you verified this works correctly with threads? Also, I don't see why we should omit the chip-id when we don't define sockets.
Alex
Quoted 29 lines · Alexander Graf
Quoted 27 lines · Alexey Kardashevskiy
This adds a "ibm,chip-id" property for CPU nodes which should be the same for all cores in the same CPU socket. The recent guest kernels use this information to associate threads with sockets.
Refer to the kernel commit
256f2d4b463d3030ebc8d2b54f427543814a2bdcfor more details.Signed-off-by Alexey Kardashevskiy <[email protected]>--- hw/ppc/spapr.c | 9 +++++++++ 1 file changed, 9 insertions(+)hw/ppc/spapr.c +2
-0@@ -308,6 +308,8 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,uint32_t interrupt_server_ranges_prop[] = {0 ,cpu_to_be32 (smp_cpus)};int i, smt =kvmppc_smt_threads ();unsigned char vec5[] = {0x0 ,0x0 ,0x0 ,0x0 ,0x0 ,0x80 }; +QemuOpts *opts =qemu_opts_find (qemu_find_opts ("smp-opts" ),NULL ); +unsigned sockets = opts ?qemu_opt_get_number (opts,"sockets" ,0 ) :0 ; fdt =g_malloc0 (FDT_MAX_SIZE );_FDT ((fdt_create (fdt,FDT_MAX_SIZE )));@@ -465,6 +467,13 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base, page_sizes_prop, page_sizes_prop_size))); }
Quoted 8 lines
hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 475
Quoted 6 lines
hw/ppc/spapr.c +5
-0+ if (sockets) { +int cpus_per_socket = smp_cpus / sockets; +uint32_t chip_id = cs->cpu_index / cpus_per_socket; + +_FDT ((fdt_property_cell (fdt,"ibm,chip-id" , chip_id))); + }Have you verified this works correctly with threads?
Sorry, do not follow you.
-smp X,sockets=Y,threads=Z - what combination of XYZ is suspicious?
Quoted 2 lines
Also, I don't see why
we should omit the chip-id when we don't define sockets.
Why should we pollute device tree...
Signature · 1 line
Alexey