diff options
author | Arnd Bergmann <arnd@arndb.de> | 2007-07-20 15:39:50 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@klappe.arndb.de> | 2007-07-20 15:42:18 -0400 |
commit | 9e7cbcbb6ede4299d52c839e352aae527c06124a (patch) | |
tree | b935ab88fa5367afd74d310eee329a3f0d708a7b /arch | |
parent | cbc23d3e7cb3c9fd3c9fce0bc3f44f687a9517c0 (diff) |
[CELL] cell: indexing of SPUs based on firmware vicinity properties
This patch links spus according to their physical position using
information provided by the firmware through a special vicinity
device-tree property. This property is present in current version
of Malta firmware.
Example of vicinity properties for a node in Malta:
Node: Vicinity property contains phandles of:
spe@0 [ spe@100000 , mic-tm@50a000 ]
spe@100000 [ spe@0 , spe@200000 ]
spe@200000 [ spe@100000 , spe@300000 ]
spe@300000 [ spe@200000 , bif0@512000 ]
spe@80000 [ spe@180000 , mic-tm@50a000 ]
spe@180000 [ spe@80000 , spe@280000 ]
spe@280000 [ spe@180000 , spe@380000 ]
spe@380000 [ spe@280000 , bif0@512000 ]
Only spe@* have a vicinity property (e.g., bif0@512000 and
mic-tm@50a000 do not have it).
Signed-off-by: Andre Detsch <adetsch@br.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/platforms/cell/spu_base.c | 90 |
1 files changed, 89 insertions, 1 deletions
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c index 5f399313b472..03b4a8eb9044 100644 --- a/arch/powerpc/platforms/cell/spu_base.c +++ b/arch/powerpc/platforms/cell/spu_base.c | |||
@@ -724,6 +724,92 @@ static int of_has_vicinity(void) | |||
724 | return of_find_property(spu_devnode(spu), "vicinity", NULL) != NULL; | 724 | return of_find_property(spu_devnode(spu), "vicinity", NULL) != NULL; |
725 | } | 725 | } |
726 | 726 | ||
727 | static struct spu *aff_devnode_spu(int cbe, struct device_node *dn) | ||
728 | { | ||
729 | struct spu *spu; | ||
730 | |||
731 | list_for_each_entry(spu, &cbe_spu_info[cbe].spus, cbe_list) | ||
732 | if (spu_devnode(spu) == dn) | ||
733 | return spu; | ||
734 | return NULL; | ||
735 | } | ||
736 | |||
737 | static struct spu * | ||
738 | aff_node_next_to(int cbe, struct device_node *target, struct device_node *avoid) | ||
739 | { | ||
740 | struct spu *spu; | ||
741 | const phandle *vic_handles; | ||
742 | int lenp, i; | ||
743 | |||
744 | list_for_each_entry(spu, &cbe_spu_info[cbe].spus, cbe_list) { | ||
745 | if (spu_devnode(spu) == avoid) | ||
746 | continue; | ||
747 | vic_handles = get_property(spu_devnode(spu), "vicinity", &lenp); | ||
748 | for (i=0; i < (lenp / sizeof(phandle)); i++) { | ||
749 | if (vic_handles[i] == target->linux_phandle) | ||
750 | return spu; | ||
751 | } | ||
752 | } | ||
753 | return NULL; | ||
754 | } | ||
755 | |||
756 | static void init_aff_fw_vicinity_node(int cbe) | ||
757 | { | ||
758 | struct spu *spu, *last_spu; | ||
759 | struct device_node *vic_dn, *last_spu_dn; | ||
760 | phandle avoid_ph; | ||
761 | const phandle *vic_handles; | ||
762 | const char *name; | ||
763 | int lenp, i, added, mem_aff; | ||
764 | |||
765 | last_spu = list_entry(cbe_spu_info[cbe].spus.next, struct spu, cbe_list); | ||
766 | avoid_ph = 0; | ||
767 | for (added = 1; added < cbe_spu_info[cbe].n_spus; added++) { | ||
768 | last_spu_dn = spu_devnode(last_spu); | ||
769 | vic_handles = get_property(last_spu_dn, "vicinity", &lenp); | ||
770 | |||
771 | for (i = 0; i < (lenp / sizeof(phandle)); i++) { | ||
772 | if (vic_handles[i] == avoid_ph) | ||
773 | continue; | ||
774 | |||
775 | vic_dn = of_find_node_by_phandle(vic_handles[i]); | ||
776 | if (!vic_dn) | ||
777 | continue; | ||
778 | |||
779 | name = get_property(vic_dn, "name", NULL); | ||
780 | if (strcmp(name, "spe") == 0) { | ||
781 | spu = aff_devnode_spu(cbe, vic_dn); | ||
782 | avoid_ph = last_spu_dn->linux_phandle; | ||
783 | } | ||
784 | else { | ||
785 | mem_aff = strcmp(name, "mic-tm") == 0; | ||
786 | spu = aff_node_next_to(cbe, vic_dn, last_spu_dn); | ||
787 | if (!spu) | ||
788 | continue; | ||
789 | if (mem_aff) { | ||
790 | last_spu->has_mem_affinity = 1; | ||
791 | spu->has_mem_affinity = 1; | ||
792 | } | ||
793 | avoid_ph = vic_dn->linux_phandle; | ||
794 | } | ||
795 | list_add_tail(&spu->aff_list, &last_spu->aff_list); | ||
796 | last_spu = spu; | ||
797 | break; | ||
798 | } | ||
799 | } | ||
800 | } | ||
801 | |||
802 | static void init_aff_fw_vicinity(void) | ||
803 | { | ||
804 | int cbe; | ||
805 | |||
806 | /* sets has_mem_affinity for each spu, as long as the | ||
807 | * spu->aff_list list, linking each spu to its neighbors | ||
808 | */ | ||
809 | for (cbe = 0; cbe < MAX_NUMNODES; cbe++) | ||
810 | init_aff_fw_vicinity_node(cbe); | ||
811 | } | ||
812 | |||
727 | static int __init init_spu_base(void) | 813 | static int __init init_spu_base(void) |
728 | { | 814 | { |
729 | int i, ret = 0; | 815 | int i, ret = 0; |
@@ -765,7 +851,9 @@ static int __init init_spu_base(void) | |||
765 | crash_register_spus(&spu_full_list); | 851 | crash_register_spus(&spu_full_list); |
766 | spu_add_sysdev_attr(&attr_stat); | 852 | spu_add_sysdev_attr(&attr_stat); |
767 | 853 | ||
768 | if (!of_has_vicinity()) { | 854 | if (of_has_vicinity()) { |
855 | init_aff_fw_vicinity(); | ||
856 | } else { | ||
769 | long root = of_get_flat_dt_root(); | 857 | long root = of_get_flat_dt_root(); |
770 | if (of_flat_dt_is_compatible(root, "IBM,CPBW-1.0")) | 858 | if (of_flat_dt_is_compatible(root, "IBM,CPBW-1.0")) |
771 | init_aff_QS20_harcoded(); | 859 | init_aff_QS20_harcoded(); |