aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2015-06-02 02:05:42 -0400
committerIngo Molnar <mingo@kernel.org>2015-06-02 02:05:42 -0400
commitf407a8258610169cd8e975dba7f0b2824562014c (patch)
tree6c87b2d168a4665411a9e16b9f481599f2db25bc /arch/sparc
parent960d447b94b22ceba286917056871d1dac8da697 (diff)
parentc46a024ea5eb0165114dbbc8c82c29b7bcf66e71 (diff)
Merge branch 'linus' into sched/core, to resolve conflict
Conflicts: arch/sparc/include/asm/topology_64.h Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/include/asm/cpudata_64.h3
-rw-r--r--arch/sparc/include/asm/pgtable_64.h22
-rw-r--r--arch/sparc/include/asm/topology_64.h3
-rw-r--r--arch/sparc/include/asm/trap_block.h2
-rw-r--r--arch/sparc/kernel/entry.h2
-rw-r--r--arch/sparc/kernel/leon_pci_grpci2.c1
-rw-r--r--arch/sparc/kernel/mdesc.c136
-rw-r--r--arch/sparc/kernel/pci.c59
-rw-r--r--arch/sparc/kernel/setup_64.c21
-rw-r--r--arch/sparc/kernel/smp_64.c13
-rw-r--r--arch/sparc/kernel/vmlinux.lds.S5
-rw-r--r--arch/sparc/mm/init_64.c74
12 files changed, 282 insertions, 59 deletions
diff --git a/arch/sparc/include/asm/cpudata_64.h b/arch/sparc/include/asm/cpudata_64.h
index a6e424d185d0..a6cfdabb6054 100644
--- a/arch/sparc/include/asm/cpudata_64.h
+++ b/arch/sparc/include/asm/cpudata_64.h
@@ -24,7 +24,8 @@ typedef struct {
24 unsigned int icache_line_size; 24 unsigned int icache_line_size;
25 unsigned int ecache_size; 25 unsigned int ecache_size;
26 unsigned int ecache_line_size; 26 unsigned int ecache_line_size;
27 int core_id; 27 unsigned short sock_id;
28 unsigned short core_id;
28 int proc_id; 29 int proc_id;
29} cpuinfo_sparc; 30} cpuinfo_sparc;
30 31
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
index dc165ebdf05a..2a52c91d2c8a 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -308,12 +308,26 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t prot)
308 " sllx %1, 32, %1\n" 308 " sllx %1, 32, %1\n"
309 " or %0, %1, %0\n" 309 " or %0, %1, %0\n"
310 " .previous\n" 310 " .previous\n"
311 " .section .sun_m7_2insn_patch, \"ax\"\n"
312 " .word 661b\n"
313 " sethi %%uhi(%4), %1\n"
314 " sethi %%hi(%4), %0\n"
315 " .word 662b\n"
316 " or %1, %%ulo(%4), %1\n"
317 " or %0, %%lo(%4), %0\n"
318 " .word 663b\n"
319 " sllx %1, 32, %1\n"
320 " or %0, %1, %0\n"
321 " .previous\n"
311 : "=r" (mask), "=r" (tmp) 322 : "=r" (mask), "=r" (tmp)
312 : "i" (_PAGE_PADDR_4U | _PAGE_MODIFIED_4U | _PAGE_ACCESSED_4U | 323 : "i" (_PAGE_PADDR_4U | _PAGE_MODIFIED_4U | _PAGE_ACCESSED_4U |
313 _PAGE_CP_4U | _PAGE_CV_4U | _PAGE_E_4U | 324 _PAGE_CP_4U | _PAGE_CV_4U | _PAGE_E_4U |
314 _PAGE_SPECIAL | _PAGE_PMD_HUGE | _PAGE_SZALL_4U), 325 _PAGE_SPECIAL | _PAGE_PMD_HUGE | _PAGE_SZALL_4U),
315 "i" (_PAGE_PADDR_4V | _PAGE_MODIFIED_4V | _PAGE_ACCESSED_4V | 326 "i" (_PAGE_PADDR_4V | _PAGE_MODIFIED_4V | _PAGE_ACCESSED_4V |
316 _PAGE_CP_4V | _PAGE_CV_4V | _PAGE_E_4V | 327 _PAGE_CP_4V | _PAGE_CV_4V | _PAGE_E_4V |
328 _PAGE_SPECIAL | _PAGE_PMD_HUGE | _PAGE_SZALL_4V),
329 "i" (_PAGE_PADDR_4V | _PAGE_MODIFIED_4V | _PAGE_ACCESSED_4V |
330 _PAGE_CP_4V | _PAGE_E_4V |
317 _PAGE_SPECIAL | _PAGE_PMD_HUGE | _PAGE_SZALL_4V)); 331 _PAGE_SPECIAL | _PAGE_PMD_HUGE | _PAGE_SZALL_4V));
318 332
319 return __pte((pte_val(pte) & mask) | (pgprot_val(prot) & ~mask)); 333 return __pte((pte_val(pte) & mask) | (pgprot_val(prot) & ~mask));
@@ -342,9 +356,15 @@ static inline pgprot_t pgprot_noncached(pgprot_t prot)
342 " andn %0, %4, %0\n" 356 " andn %0, %4, %0\n"
343 " or %0, %5, %0\n" 357 " or %0, %5, %0\n"
344 " .previous\n" 358 " .previous\n"
359 " .section .sun_m7_2insn_patch, \"ax\"\n"
360 " .word 661b\n"
361 " andn %0, %6, %0\n"
362 " or %0, %5, %0\n"
363 " .previous\n"
345 : "=r" (val) 364 : "=r" (val)
346 : "0" (val), "i" (_PAGE_CP_4U | _PAGE_CV_4U), "i" (_PAGE_E_4U), 365 : "0" (val), "i" (_PAGE_CP_4U | _PAGE_CV_4U), "i" (_PAGE_E_4U),
347 "i" (_PAGE_CP_4V | _PAGE_CV_4V), "i" (_PAGE_E_4V)); 366 "i" (_PAGE_CP_4V | _PAGE_CV_4V), "i" (_PAGE_E_4V),
367 "i" (_PAGE_CP_4V));
348 368
349 return __pgprot(val); 369 return __pgprot(val);
350} 370}
diff --git a/arch/sparc/include/asm/topology_64.h b/arch/sparc/include/asm/topology_64.h
index 9a928fcb7a9b..01d17046225a 100644
--- a/arch/sparc/include/asm/topology_64.h
+++ b/arch/sparc/include/asm/topology_64.h
@@ -40,11 +40,12 @@ static inline int pcibus_to_node(struct pci_bus *pbus)
40#ifdef CONFIG_SMP 40#ifdef CONFIG_SMP
41#define topology_physical_package_id(cpu) (cpu_data(cpu).proc_id) 41#define topology_physical_package_id(cpu) (cpu_data(cpu).proc_id)
42#define topology_core_id(cpu) (cpu_data(cpu).core_id) 42#define topology_core_id(cpu) (cpu_data(cpu).core_id)
43#define topology_core_cpumask(cpu) (&cpu_core_map[cpu]) 43#define topology_core_cpumask(cpu) (&cpu_core_sib_map[cpu])
44#define topology_sibling_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu)) 44#define topology_sibling_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu))
45#endif /* CONFIG_SMP */ 45#endif /* CONFIG_SMP */
46 46
47extern cpumask_t cpu_core_map[NR_CPUS]; 47extern cpumask_t cpu_core_map[NR_CPUS];
48extern cpumask_t cpu_core_sib_map[NR_CPUS];
48static inline const struct cpumask *cpu_coregroup_mask(int cpu) 49static inline const struct cpumask *cpu_coregroup_mask(int cpu)
49{ 50{
50 return &cpu_core_map[cpu]; 51 return &cpu_core_map[cpu];
diff --git a/arch/sparc/include/asm/trap_block.h b/arch/sparc/include/asm/trap_block.h
index 6fd4436d32f0..ec9c04de3664 100644
--- a/arch/sparc/include/asm/trap_block.h
+++ b/arch/sparc/include/asm/trap_block.h
@@ -79,6 +79,8 @@ struct sun4v_2insn_patch_entry {
79}; 79};
80extern struct sun4v_2insn_patch_entry __sun4v_2insn_patch, 80extern struct sun4v_2insn_patch_entry __sun4v_2insn_patch,
81 __sun4v_2insn_patch_end; 81 __sun4v_2insn_patch_end;
82extern struct sun4v_2insn_patch_entry __sun_m7_2insn_patch,
83 __sun_m7_2insn_patch_end;
82 84
83 85
84#endif /* !(__ASSEMBLY__) */ 86#endif /* !(__ASSEMBLY__) */
diff --git a/arch/sparc/kernel/entry.h b/arch/sparc/kernel/entry.h
index 07cc49e541f4..0f679421b468 100644
--- a/arch/sparc/kernel/entry.h
+++ b/arch/sparc/kernel/entry.h
@@ -69,6 +69,8 @@ void sun4v_patch_1insn_range(struct sun4v_1insn_patch_entry *,
69 struct sun4v_1insn_patch_entry *); 69 struct sun4v_1insn_patch_entry *);
70void sun4v_patch_2insn_range(struct sun4v_2insn_patch_entry *, 70void sun4v_patch_2insn_range(struct sun4v_2insn_patch_entry *,
71 struct sun4v_2insn_patch_entry *); 71 struct sun4v_2insn_patch_entry *);
72void sun_m7_patch_2insn_range(struct sun4v_2insn_patch_entry *,
73 struct sun4v_2insn_patch_entry *);
72extern unsigned int dcache_parity_tl1_occurred; 74extern unsigned int dcache_parity_tl1_occurred;
73extern unsigned int icache_parity_tl1_occurred; 75extern unsigned int icache_parity_tl1_occurred;
74 76
diff --git a/arch/sparc/kernel/leon_pci_grpci2.c b/arch/sparc/kernel/leon_pci_grpci2.c
index 94e392bdee7d..814fb1729b12 100644
--- a/arch/sparc/kernel/leon_pci_grpci2.c
+++ b/arch/sparc/kernel/leon_pci_grpci2.c
@@ -723,7 +723,6 @@ static int grpci2_of_probe(struct platform_device *ofdev)
723 err = -ENOMEM; 723 err = -ENOMEM;
724 goto err1; 724 goto err1;
725 } 725 }
726 memset(grpci2priv, 0, sizeof(*grpci2priv));
727 priv->regs = regs; 726 priv->regs = regs;
728 priv->irq = ofdev->archdata.irqs[0]; /* BASE IRQ */ 727 priv->irq = ofdev->archdata.irqs[0]; /* BASE IRQ */
729 priv->irq_mode = (capability & STS_IRQMODE) >> STS_IRQMODE_BIT; 728 priv->irq_mode = (capability & STS_IRQMODE) >> STS_IRQMODE_BIT;
diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c
index 26c80e18d7b1..6f80936e0eea 100644
--- a/arch/sparc/kernel/mdesc.c
+++ b/arch/sparc/kernel/mdesc.c
@@ -614,45 +614,68 @@ static void fill_in_one_cache(cpuinfo_sparc *c, struct mdesc_handle *hp, u64 mp)
614 } 614 }
615} 615}
616 616
617static void mark_core_ids(struct mdesc_handle *hp, u64 mp, int core_id) 617static void find_back_node_value(struct mdesc_handle *hp, u64 node,
618 char *srch_val,
619 void (*func)(struct mdesc_handle *, u64, int),
620 u64 val, int depth)
618{ 621{
619 u64 a; 622 u64 arc;
620
621 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_BACK) {
622 u64 t = mdesc_arc_target(hp, a);
623 const char *name;
624 const u64 *id;
625 623
626 name = mdesc_node_name(hp, t); 624 /* Since we have an estimate of recursion depth, do a sanity check. */
627 if (!strcmp(name, "cpu")) { 625 if (depth == 0)
628 id = mdesc_get_property(hp, t, "id", NULL); 626 return;
629 if (*id < NR_CPUS)
630 cpu_data(*id).core_id = core_id;
631 } else {
632 u64 j;
633 627
634 mdesc_for_each_arc(j, hp, t, MDESC_ARC_TYPE_BACK) { 628 mdesc_for_each_arc(arc, hp, node, MDESC_ARC_TYPE_BACK) {
635 u64 n = mdesc_arc_target(hp, j); 629 u64 n = mdesc_arc_target(hp, arc);
636 const char *n_name; 630 const char *name = mdesc_node_name(hp, n);
637 631
638 n_name = mdesc_node_name(hp, n); 632 if (!strcmp(srch_val, name))
639 if (strcmp(n_name, "cpu")) 633 (*func)(hp, n, val);
640 continue;
641 634
642 id = mdesc_get_property(hp, n, "id", NULL); 635 find_back_node_value(hp, n, srch_val, func, val, depth-1);
643 if (*id < NR_CPUS)
644 cpu_data(*id).core_id = core_id;
645 }
646 }
647 } 636 }
648} 637}
649 638
639static void __mark_core_id(struct mdesc_handle *hp, u64 node,
640 int core_id)
641{
642 const u64 *id = mdesc_get_property(hp, node, "id", NULL);
643
644 if (*id < num_possible_cpus())
645 cpu_data(*id).core_id = core_id;
646}
647
648static void __mark_sock_id(struct mdesc_handle *hp, u64 node,
649 int sock_id)
650{
651 const u64 *id = mdesc_get_property(hp, node, "id", NULL);
652
653 if (*id < num_possible_cpus())
654 cpu_data(*id).sock_id = sock_id;
655}
656
657static void mark_core_ids(struct mdesc_handle *hp, u64 mp,
658 int core_id)
659{
660 find_back_node_value(hp, mp, "cpu", __mark_core_id, core_id, 10);
661}
662
663static void mark_sock_ids(struct mdesc_handle *hp, u64 mp,
664 int sock_id)
665{
666 find_back_node_value(hp, mp, "cpu", __mark_sock_id, sock_id, 10);
667}
668
650static void set_core_ids(struct mdesc_handle *hp) 669static void set_core_ids(struct mdesc_handle *hp)
651{ 670{
652 int idx; 671 int idx;
653 u64 mp; 672 u64 mp;
654 673
655 idx = 1; 674 idx = 1;
675
676 /* Identify unique cores by looking for cpus backpointed to by
677 * level 1 instruction caches.
678 */
656 mdesc_for_each_node_by_name(hp, mp, "cache") { 679 mdesc_for_each_node_by_name(hp, mp, "cache") {
657 const u64 *level; 680 const u64 *level;
658 const char *type; 681 const char *type;
@@ -667,11 +690,72 @@ static void set_core_ids(struct mdesc_handle *hp)
667 continue; 690 continue;
668 691
669 mark_core_ids(hp, mp, idx); 692 mark_core_ids(hp, mp, idx);
693 idx++;
694 }
695}
696
697static int set_sock_ids_by_cache(struct mdesc_handle *hp, int level)
698{
699 u64 mp;
700 int idx = 1;
701 int fnd = 0;
702
703 /* Identify unique sockets by looking for cpus backpointed to by
704 * shared level n caches.
705 */
706 mdesc_for_each_node_by_name(hp, mp, "cache") {
707 const u64 *cur_lvl;
708
709 cur_lvl = mdesc_get_property(hp, mp, "level", NULL);
710 if (*cur_lvl != level)
711 continue;
712
713 mark_sock_ids(hp, mp, idx);
714 idx++;
715 fnd = 1;
716 }
717 return fnd;
718}
719
720static void set_sock_ids_by_socket(struct mdesc_handle *hp, u64 mp)
721{
722 int idx = 1;
670 723
724 mdesc_for_each_node_by_name(hp, mp, "socket") {
725 u64 a;
726
727 mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_FWD) {
728 u64 t = mdesc_arc_target(hp, a);
729 const char *name;
730 const u64 *id;
731
732 name = mdesc_node_name(hp, t);
733 if (strcmp(name, "cpu"))
734 continue;
735
736 id = mdesc_get_property(hp, t, "id", NULL);
737 if (*id < num_possible_cpus())
738 cpu_data(*id).sock_id = idx;
739 }
671 idx++; 740 idx++;
672 } 741 }
673} 742}
674 743
744static void set_sock_ids(struct mdesc_handle *hp)
745{
746 u64 mp;
747
748 /* If machine description exposes sockets data use it.
749 * Otherwise fallback to use shared L3 or L2 caches.
750 */
751 mp = mdesc_node_by_name(hp, MDESC_NODE_NULL, "sockets");
752 if (mp != MDESC_NODE_NULL)
753 return set_sock_ids_by_socket(hp, mp);
754
755 if (!set_sock_ids_by_cache(hp, 3))
756 set_sock_ids_by_cache(hp, 2);
757}
758
675static void mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id) 759static void mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id)
676{ 760{
677 u64 a; 761 u64 a;
@@ -707,7 +791,6 @@ static void __set_proc_ids(struct mdesc_handle *hp, const char *exec_unit_name)
707 continue; 791 continue;
708 792
709 mark_proc_ids(hp, mp, idx); 793 mark_proc_ids(hp, mp, idx);
710
711 idx++; 794 idx++;
712 } 795 }
713} 796}
@@ -900,6 +983,7 @@ void mdesc_fill_in_cpu_data(cpumask_t *mask)
900 983
901 set_core_ids(hp); 984 set_core_ids(hp);
902 set_proc_ids(hp); 985 set_proc_ids(hp);
986 set_sock_ids(hp);
903 987
904 mdesc_release(hp); 988 mdesc_release(hp);
905 989
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 6f7251fd2eab..c928bc64b4ba 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -1002,6 +1002,38 @@ static int __init pcibios_init(void)
1002subsys_initcall(pcibios_init); 1002subsys_initcall(pcibios_init);
1003 1003
1004#ifdef CONFIG_SYSFS 1004#ifdef CONFIG_SYSFS
1005
1006#define SLOT_NAME_SIZE 11 /* Max decimal digits + null in u32 */
1007
1008static void pcie_bus_slot_names(struct pci_bus *pbus)
1009{
1010 struct pci_dev *pdev;
1011 struct pci_bus *bus;
1012
1013 list_for_each_entry(pdev, &pbus->devices, bus_list) {
1014 char name[SLOT_NAME_SIZE];
1015 struct pci_slot *pci_slot;
1016 const u32 *slot_num;
1017 int len;
1018
1019 slot_num = of_get_property(pdev->dev.of_node,
1020 "physical-slot#", &len);
1021
1022 if (slot_num == NULL || len != 4)
1023 continue;
1024
1025 snprintf(name, sizeof(name), "%u", slot_num[0]);
1026 pci_slot = pci_create_slot(pbus, slot_num[0], name, NULL);
1027
1028 if (IS_ERR(pci_slot))
1029 pr_err("PCI: pci_create_slot returned %ld.\n",
1030 PTR_ERR(pci_slot));
1031 }
1032
1033 list_for_each_entry(bus, &pbus->children, node)
1034 pcie_bus_slot_names(bus);
1035}
1036
1005static void pci_bus_slot_names(struct device_node *node, struct pci_bus *bus) 1037static void pci_bus_slot_names(struct device_node *node, struct pci_bus *bus)
1006{ 1038{
1007 const struct pci_slot_names { 1039 const struct pci_slot_names {
@@ -1053,18 +1085,29 @@ static int __init of_pci_slot_init(void)
1053 1085
1054 while ((pbus = pci_find_next_bus(pbus)) != NULL) { 1086 while ((pbus = pci_find_next_bus(pbus)) != NULL) {
1055 struct device_node *node; 1087 struct device_node *node;
1088 struct pci_dev *pdev;
1089
1090 pdev = list_first_entry(&pbus->devices, struct pci_dev,
1091 bus_list);
1056 1092
1057 if (pbus->self) { 1093 if (pdev && pci_is_pcie(pdev)) {
1058 /* PCI->PCI bridge */ 1094 pcie_bus_slot_names(pbus);
1059 node = pbus->self->dev.of_node;
1060 } else { 1095 } else {
1061 struct pci_pbm_info *pbm = pbus->sysdata;
1062 1096
1063 /* Host PCI controller */ 1097 if (pbus->self) {
1064 node = pbm->op->dev.of_node; 1098
1065 } 1099 /* PCI->PCI bridge */
1100 node = pbus->self->dev.of_node;
1101
1102 } else {
1103 struct pci_pbm_info *pbm = pbus->sysdata;
1066 1104
1067 pci_bus_slot_names(node, pbus); 1105 /* Host PCI controller */
1106 node = pbm->op->dev.of_node;
1107 }
1108
1109 pci_bus_slot_names(node, pbus);
1110 }
1068 } 1111 }
1069 1112
1070 return 0; 1113 return 0;
diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c
index c38d19fc27ba..f7b261749383 100644
--- a/arch/sparc/kernel/setup_64.c
+++ b/arch/sparc/kernel/setup_64.c
@@ -255,6 +255,24 @@ void sun4v_patch_2insn_range(struct sun4v_2insn_patch_entry *start,
255 } 255 }
256} 256}
257 257
258void sun_m7_patch_2insn_range(struct sun4v_2insn_patch_entry *start,
259 struct sun4v_2insn_patch_entry *end)
260{
261 while (start < end) {
262 unsigned long addr = start->addr;
263
264 *(unsigned int *) (addr + 0) = start->insns[0];
265 wmb();
266 __asm__ __volatile__("flush %0" : : "r" (addr + 0));
267
268 *(unsigned int *) (addr + 4) = start->insns[1];
269 wmb();
270 __asm__ __volatile__("flush %0" : : "r" (addr + 4));
271
272 start++;
273 }
274}
275
258static void __init sun4v_patch(void) 276static void __init sun4v_patch(void)
259{ 277{
260 extern void sun4v_hvapi_init(void); 278 extern void sun4v_hvapi_init(void);
@@ -267,6 +285,9 @@ static void __init sun4v_patch(void)
267 285
268 sun4v_patch_2insn_range(&__sun4v_2insn_patch, 286 sun4v_patch_2insn_range(&__sun4v_2insn_patch,
269 &__sun4v_2insn_patch_end); 287 &__sun4v_2insn_patch_end);
288 if (sun4v_chip_type == SUN4V_CHIP_SPARC_M7)
289 sun_m7_patch_2insn_range(&__sun_m7_2insn_patch,
290 &__sun_m7_2insn_patch_end);
270 291
271 sun4v_hvapi_init(); 292 sun4v_hvapi_init();
272} 293}
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 61139d9924ca..19cd08d18672 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -60,8 +60,12 @@ DEFINE_PER_CPU(cpumask_t, cpu_sibling_map) = CPU_MASK_NONE;
60cpumask_t cpu_core_map[NR_CPUS] __read_mostly = 60cpumask_t cpu_core_map[NR_CPUS] __read_mostly =
61 { [0 ... NR_CPUS-1] = CPU_MASK_NONE }; 61 { [0 ... NR_CPUS-1] = CPU_MASK_NONE };
62 62
63cpumask_t cpu_core_sib_map[NR_CPUS] __read_mostly = {
64 [0 ... NR_CPUS-1] = CPU_MASK_NONE };
65
63EXPORT_PER_CPU_SYMBOL(cpu_sibling_map); 66EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
64EXPORT_SYMBOL(cpu_core_map); 67EXPORT_SYMBOL(cpu_core_map);
68EXPORT_SYMBOL(cpu_core_sib_map);
65 69
66static cpumask_t smp_commenced_mask; 70static cpumask_t smp_commenced_mask;
67 71
@@ -1243,6 +1247,15 @@ void smp_fill_in_sib_core_maps(void)
1243 } 1247 }
1244 } 1248 }
1245 1249
1250 for_each_present_cpu(i) {
1251 unsigned int j;
1252
1253 for_each_present_cpu(j) {
1254 if (cpu_data(i).sock_id == cpu_data(j).sock_id)
1255 cpumask_set_cpu(j, &cpu_core_sib_map[i]);
1256 }
1257 }
1258
1246 for_each_present_cpu(i) { 1259 for_each_present_cpu(i) {
1247 unsigned int j; 1260 unsigned int j;
1248 1261
diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S
index 09243057cb0b..f1a2f688b28a 100644
--- a/arch/sparc/kernel/vmlinux.lds.S
+++ b/arch/sparc/kernel/vmlinux.lds.S
@@ -138,6 +138,11 @@ SECTIONS
138 *(.pause_3insn_patch) 138 *(.pause_3insn_patch)
139 __pause_3insn_patch_end = .; 139 __pause_3insn_patch_end = .;
140 } 140 }
141 .sun_m7_2insn_patch : {
142 __sun_m7_2insn_patch = .;
143 *(.sun_m7_2insn_patch)
144 __sun_m7_2insn_patch_end = .;
145 }
141 PERCPU_SECTION(SMP_CACHE_BYTES) 146 PERCPU_SECTION(SMP_CACHE_BYTES)
142 147
143 . = ALIGN(PAGE_SIZE); 148 . = ALIGN(PAGE_SIZE);
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index cee9b77ddd05..c5d08b89a96c 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -54,6 +54,7 @@
54#include "init_64.h" 54#include "init_64.h"
55 55
56unsigned long kern_linear_pte_xor[4] __read_mostly; 56unsigned long kern_linear_pte_xor[4] __read_mostly;
57static unsigned long page_cache4v_flag;
57 58
58/* A bitmap, two bits for every 256MB of physical memory. These two 59/* A bitmap, two bits for every 256MB of physical memory. These two
59 * bits determine what page size we use for kernel linear 60 * bits determine what page size we use for kernel linear
@@ -1909,11 +1910,24 @@ static void __init sun4u_linear_pte_xor_finalize(void)
1909 1910
1910static void __init sun4v_linear_pte_xor_finalize(void) 1911static void __init sun4v_linear_pte_xor_finalize(void)
1911{ 1912{
1913 unsigned long pagecv_flag;
1914
1915 /* Bit 9 of TTE is no longer CV bit on M7 processor and it instead
1916 * enables MCD error. Do not set bit 9 on M7 processor.
1917 */
1918 switch (sun4v_chip_type) {
1919 case SUN4V_CHIP_SPARC_M7:
1920 pagecv_flag = 0x00;
1921 break;
1922 default:
1923 pagecv_flag = _PAGE_CV_4V;
1924 break;
1925 }
1912#ifndef CONFIG_DEBUG_PAGEALLOC 1926#ifndef CONFIG_DEBUG_PAGEALLOC
1913 if (cpu_pgsz_mask & HV_PGSZ_MASK_256MB) { 1927 if (cpu_pgsz_mask & HV_PGSZ_MASK_256MB) {
1914 kern_linear_pte_xor[1] = (_PAGE_VALID | _PAGE_SZ256MB_4V) ^ 1928 kern_linear_pte_xor[1] = (_PAGE_VALID | _PAGE_SZ256MB_4V) ^
1915 PAGE_OFFSET; 1929 PAGE_OFFSET;
1916 kern_linear_pte_xor[1] |= (_PAGE_CP_4V | _PAGE_CV_4V | 1930 kern_linear_pte_xor[1] |= (_PAGE_CP_4V | pagecv_flag |
1917 _PAGE_P_4V | _PAGE_W_4V); 1931 _PAGE_P_4V | _PAGE_W_4V);
1918 } else { 1932 } else {
1919 kern_linear_pte_xor[1] = kern_linear_pte_xor[0]; 1933 kern_linear_pte_xor[1] = kern_linear_pte_xor[0];
@@ -1922,7 +1936,7 @@ static void __init sun4v_linear_pte_xor_finalize(void)
1922 if (cpu_pgsz_mask & HV_PGSZ_MASK_2GB) { 1936 if (cpu_pgsz_mask & HV_PGSZ_MASK_2GB) {
1923 kern_linear_pte_xor[2] = (_PAGE_VALID | _PAGE_SZ2GB_4V) ^ 1937 kern_linear_pte_xor[2] = (_PAGE_VALID | _PAGE_SZ2GB_4V) ^
1924 PAGE_OFFSET; 1938 PAGE_OFFSET;
1925 kern_linear_pte_xor[2] |= (_PAGE_CP_4V | _PAGE_CV_4V | 1939 kern_linear_pte_xor[2] |= (_PAGE_CP_4V | pagecv_flag |
1926 _PAGE_P_4V | _PAGE_W_4V); 1940 _PAGE_P_4V | _PAGE_W_4V);
1927 } else { 1941 } else {
1928 kern_linear_pte_xor[2] = kern_linear_pte_xor[1]; 1942 kern_linear_pte_xor[2] = kern_linear_pte_xor[1];
@@ -1931,7 +1945,7 @@ static void __init sun4v_linear_pte_xor_finalize(void)
1931 if (cpu_pgsz_mask & HV_PGSZ_MASK_16GB) { 1945 if (cpu_pgsz_mask & HV_PGSZ_MASK_16GB) {
1932 kern_linear_pte_xor[3] = (_PAGE_VALID | _PAGE_SZ16GB_4V) ^ 1946 kern_linear_pte_xor[3] = (_PAGE_VALID | _PAGE_SZ16GB_4V) ^
1933 PAGE_OFFSET; 1947 PAGE_OFFSET;
1934 kern_linear_pte_xor[3] |= (_PAGE_CP_4V | _PAGE_CV_4V | 1948 kern_linear_pte_xor[3] |= (_PAGE_CP_4V | pagecv_flag |
1935 _PAGE_P_4V | _PAGE_W_4V); 1949 _PAGE_P_4V | _PAGE_W_4V);
1936 } else { 1950 } else {
1937 kern_linear_pte_xor[3] = kern_linear_pte_xor[2]; 1951 kern_linear_pte_xor[3] = kern_linear_pte_xor[2];
@@ -1958,6 +1972,13 @@ static phys_addr_t __init available_memory(void)
1958 return available; 1972 return available;
1959} 1973}
1960 1974
1975#define _PAGE_CACHE_4U (_PAGE_CP_4U | _PAGE_CV_4U)
1976#define _PAGE_CACHE_4V (_PAGE_CP_4V | _PAGE_CV_4V)
1977#define __DIRTY_BITS_4U (_PAGE_MODIFIED_4U | _PAGE_WRITE_4U | _PAGE_W_4U)
1978#define __DIRTY_BITS_4V (_PAGE_MODIFIED_4V | _PAGE_WRITE_4V | _PAGE_W_4V)
1979#define __ACCESS_BITS_4U (_PAGE_ACCESSED_4U | _PAGE_READ_4U | _PAGE_R)
1980#define __ACCESS_BITS_4V (_PAGE_ACCESSED_4V | _PAGE_READ_4V | _PAGE_R)
1981
1961/* We need to exclude reserved regions. This exclusion will include 1982/* We need to exclude reserved regions. This exclusion will include
1962 * vmlinux and initrd. To be more precise the initrd size could be used to 1983 * vmlinux and initrd. To be more precise the initrd size could be used to
1963 * compute a new lower limit because it is freed later during initialization. 1984 * compute a new lower limit because it is freed later during initialization.
@@ -2034,6 +2055,25 @@ void __init paging_init(void)
2034 memset(swapper_4m_tsb, 0x40, sizeof(swapper_4m_tsb)); 2055 memset(swapper_4m_tsb, 0x40, sizeof(swapper_4m_tsb));
2035#endif 2056#endif
2036 2057
2058 /* TTE.cv bit on sparc v9 occupies the same position as TTE.mcde
2059 * bit on M7 processor. This is a conflicting usage of the same
2060 * bit. Enabling TTE.cv on M7 would turn on Memory Corruption
2061 * Detection error on all pages and this will lead to problems
2062 * later. Kernel does not run with MCD enabled and hence rest
2063 * of the required steps to fully configure memory corruption
2064 * detection are not taken. We need to ensure TTE.mcde is not
2065 * set on M7 processor. Compute the value of cacheability
2066 * flag for use later taking this into consideration.
2067 */
2068 switch (sun4v_chip_type) {
2069 case SUN4V_CHIP_SPARC_M7:
2070 page_cache4v_flag = _PAGE_CP_4V;
2071 break;
2072 default:
2073 page_cache4v_flag = _PAGE_CACHE_4V;
2074 break;
2075 }
2076
2037 if (tlb_type == hypervisor) 2077 if (tlb_type == hypervisor)
2038 sun4v_pgprot_init(); 2078 sun4v_pgprot_init();
2039 else 2079 else
@@ -2274,13 +2314,6 @@ void free_initrd_mem(unsigned long start, unsigned long end)
2274} 2314}
2275#endif 2315#endif
2276 2316
2277#define _PAGE_CACHE_4U (_PAGE_CP_4U | _PAGE_CV_4U)
2278#define _PAGE_CACHE_4V (_PAGE_CP_4V | _PAGE_CV_4V)
2279#define __DIRTY_BITS_4U (_PAGE_MODIFIED_4U | _PAGE_WRITE_4U | _PAGE_W_4U)
2280#define __DIRTY_BITS_4V (_PAGE_MODIFIED_4V | _PAGE_WRITE_4V | _PAGE_W_4V)
2281#define __ACCESS_BITS_4U (_PAGE_ACCESSED_4U | _PAGE_READ_4U | _PAGE_R)
2282#define __ACCESS_BITS_4V (_PAGE_ACCESSED_4V | _PAGE_READ_4V | _PAGE_R)
2283
2284pgprot_t PAGE_KERNEL __read_mostly; 2317pgprot_t PAGE_KERNEL __read_mostly;
2285EXPORT_SYMBOL(PAGE_KERNEL); 2318EXPORT_SYMBOL(PAGE_KERNEL);
2286 2319
@@ -2312,8 +2345,7 @@ int __meminit vmemmap_populate(unsigned long vstart, unsigned long vend,
2312 _PAGE_P_4U | _PAGE_W_4U); 2345 _PAGE_P_4U | _PAGE_W_4U);
2313 if (tlb_type == hypervisor) 2346 if (tlb_type == hypervisor)
2314 pte_base = (_PAGE_VALID | _PAGE_SZ4MB_4V | 2347 pte_base = (_PAGE_VALID | _PAGE_SZ4MB_4V |
2315 _PAGE_CP_4V | _PAGE_CV_4V | 2348 page_cache4v_flag | _PAGE_P_4V | _PAGE_W_4V);
2316 _PAGE_P_4V | _PAGE_W_4V);
2317 2349
2318 pte_base |= _PAGE_PMD_HUGE; 2350 pte_base |= _PAGE_PMD_HUGE;
2319 2351
@@ -2450,14 +2482,14 @@ static void __init sun4v_pgprot_init(void)
2450 int i; 2482 int i;
2451 2483
2452 PAGE_KERNEL = __pgprot (_PAGE_PRESENT_4V | _PAGE_VALID | 2484 PAGE_KERNEL = __pgprot (_PAGE_PRESENT_4V | _PAGE_VALID |
2453 _PAGE_CACHE_4V | _PAGE_P_4V | 2485 page_cache4v_flag | _PAGE_P_4V |
2454 __ACCESS_BITS_4V | __DIRTY_BITS_4V | 2486 __ACCESS_BITS_4V | __DIRTY_BITS_4V |
2455 _PAGE_EXEC_4V); 2487 _PAGE_EXEC_4V);
2456 PAGE_KERNEL_LOCKED = PAGE_KERNEL; 2488 PAGE_KERNEL_LOCKED = PAGE_KERNEL;
2457 2489
2458 _PAGE_IE = _PAGE_IE_4V; 2490 _PAGE_IE = _PAGE_IE_4V;
2459 _PAGE_E = _PAGE_E_4V; 2491 _PAGE_E = _PAGE_E_4V;
2460 _PAGE_CACHE = _PAGE_CACHE_4V; 2492 _PAGE_CACHE = page_cache4v_flag;
2461 2493
2462#ifdef CONFIG_DEBUG_PAGEALLOC 2494#ifdef CONFIG_DEBUG_PAGEALLOC
2463 kern_linear_pte_xor[0] = _PAGE_VALID ^ PAGE_OFFSET; 2495 kern_linear_pte_xor[0] = _PAGE_VALID ^ PAGE_OFFSET;
@@ -2465,8 +2497,8 @@ static void __init sun4v_pgprot_init(void)
2465 kern_linear_pte_xor[0] = (_PAGE_VALID | _PAGE_SZ4MB_4V) ^ 2497 kern_linear_pte_xor[0] = (_PAGE_VALID | _PAGE_SZ4MB_4V) ^
2466 PAGE_OFFSET; 2498 PAGE_OFFSET;
2467#endif 2499#endif
2468 kern_linear_pte_xor[0] |= (_PAGE_CP_4V | _PAGE_CV_4V | 2500 kern_linear_pte_xor[0] |= (page_cache4v_flag | _PAGE_P_4V |
2469 _PAGE_P_4V | _PAGE_W_4V); 2501 _PAGE_W_4V);
2470 2502
2471 for (i = 1; i < 4; i++) 2503 for (i = 1; i < 4; i++)
2472 kern_linear_pte_xor[i] = kern_linear_pte_xor[0]; 2504 kern_linear_pte_xor[i] = kern_linear_pte_xor[0];
@@ -2479,12 +2511,12 @@ static void __init sun4v_pgprot_init(void)
2479 _PAGE_SZ4MB_4V | _PAGE_SZ512K_4V | 2511 _PAGE_SZ4MB_4V | _PAGE_SZ512K_4V |
2480 _PAGE_SZ64K_4V | _PAGE_SZ8K_4V); 2512 _PAGE_SZ64K_4V | _PAGE_SZ8K_4V);
2481 2513
2482 page_none = _PAGE_PRESENT_4V | _PAGE_ACCESSED_4V | _PAGE_CACHE_4V; 2514 page_none = _PAGE_PRESENT_4V | _PAGE_ACCESSED_4V | page_cache4v_flag;
2483 page_shared = (_PAGE_VALID | _PAGE_PRESENT_4V | _PAGE_CACHE_4V | 2515 page_shared = (_PAGE_VALID | _PAGE_PRESENT_4V | page_cache4v_flag |
2484 __ACCESS_BITS_4V | _PAGE_WRITE_4V | _PAGE_EXEC_4V); 2516 __ACCESS_BITS_4V | _PAGE_WRITE_4V | _PAGE_EXEC_4V);
2485 page_copy = (_PAGE_VALID | _PAGE_PRESENT_4V | _PAGE_CACHE_4V | 2517 page_copy = (_PAGE_VALID | _PAGE_PRESENT_4V | page_cache4v_flag |
2486 __ACCESS_BITS_4V | _PAGE_EXEC_4V); 2518 __ACCESS_BITS_4V | _PAGE_EXEC_4V);
2487 page_readonly = (_PAGE_VALID | _PAGE_PRESENT_4V | _PAGE_CACHE_4V | 2519 page_readonly = (_PAGE_VALID | _PAGE_PRESENT_4V | page_cache4v_flag |
2488 __ACCESS_BITS_4V | _PAGE_EXEC_4V); 2520 __ACCESS_BITS_4V | _PAGE_EXEC_4V);
2489 2521
2490 page_exec_bit = _PAGE_EXEC_4V; 2522 page_exec_bit = _PAGE_EXEC_4V;
@@ -2542,7 +2574,7 @@ static unsigned long kern_large_tte(unsigned long paddr)
2542 _PAGE_EXEC_4U | _PAGE_L_4U | _PAGE_W_4U); 2574 _PAGE_EXEC_4U | _PAGE_L_4U | _PAGE_W_4U);
2543 if (tlb_type == hypervisor) 2575 if (tlb_type == hypervisor)
2544 val = (_PAGE_VALID | _PAGE_SZ4MB_4V | 2576 val = (_PAGE_VALID | _PAGE_SZ4MB_4V |
2545 _PAGE_CP_4V | _PAGE_CV_4V | _PAGE_P_4V | 2577 page_cache4v_flag | _PAGE_P_4V |
2546 _PAGE_EXEC_4V | _PAGE_W_4V); 2578 _PAGE_EXEC_4V | _PAGE_W_4V);
2547 2579
2548 return val | paddr; 2580 return val | paddr;