Subject: cell: add hardcoded spu vicinity information for CBPW From: Andre Detsch This patch allows the use of spu affinity on CPBW platform, whose original FW does not provide affinity information. This is done through two hardcoded arrays, and by reading the reg property from each spu. Signed-off-by: Andre Detsch Signed-off-by: Arnd Bergmann --- Index: linux-2.6/arch/powerpc/platforms/cell/spu_base.c =================================================================== --- linux-2.6.orig/arch/powerpc/platforms/cell/spu_base.c +++ linux-2.6/arch/powerpc/platforms/cell/spu_base.c @@ -34,6 +34,7 @@ #include #include #include +#include const struct spu_management_ops *spu_management_ops; const struct spu_priv1_ops *spu_priv1_ops; @@ -669,9 +670,50 @@ module_exit(cleanup_spu_base); struct be_spu_info be_spu_info[MAX_NUMNODES]; EXPORT_SYMBOL_GPL(be_spu_info); +/* Hardcoded affinity idxs for CPBW */ +#define SPES_PER_BE 8 +static int CPBW_reg_idxs[SPES_PER_BE] = { 0, 2, 4, 6, 7, 5, 3, 1 }; +static int CPBW_reg_memory[SPES_PER_BE] = { 1, 1, 0, 0, 0, 0, 0, 0 }; + +static struct spu *spu_lookup(int node, const char* field, u32 value) +{ + struct spu *spu; + + list_for_each_entry(spu, &be_spu_info[node].available_spus, + available_list) { + BUG_ON(!spu->devnode); + if (*(u32 *)get_property(spu->devnode, field, NULL) == value) + return spu; + } + return NULL; +} + +static void init_aff_CPBW_harcoded(void) +{ + int node, i; + struct spu *last_spu, *spu; + u32 reg; + + for (node = 0; node < MAX_NUMNODES; node++) { + last_spu = NULL; + for (i = 0; i < SPES_PER_BE; i++) { + spu = spu_lookup(node, "reg", CPBW_reg_idxs[i]); + if (!spu) + continue; + reg = *(u32 *)get_property(spu->devnode, "reg", NULL); + spu->has_mem_affinity = CPBW_reg_memory[reg]; + if (last_spu) + list_add_tail(&spu->aff_list, + &last_spu->aff_list); + last_spu = spu; + } + } +} + static int __init init_spu_base(void) { int i, ret; + long root; if (!spu_management_ops) return 0; @@ -696,6 +738,11 @@ static int __init init_spu_base(void) xmon_register_spus(&spu_full_list); + root = of_get_flat_dt_root(); + if (of_flat_dt_is_compatible(root, "IBM,CPBW-1.0") || + of_flat_dt_is_compatible(root, "IBM,CPBW-SystemSim")) + init_aff_CPBW_harcoded(); + return ret; } module_init(init_spu_base);