3008-armv8-aarch32-Add-SMP-support-for-32-bit-Linux.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. From 5d06e90bd0e3bdd104b7b25173e05617f02dc44d Mon Sep 17 00:00:00 2001
  2. From: Alison Wang <b18965@freescale.com>
  3. Date: Fri, 13 May 2016 15:09:47 +0800
  4. Subject: [PATCH 08/70] armv8: aarch32: Add SMP support for 32-bit Linux
  5. The patch adds SMP support for running 32-bit Linux kernel. Spin-table
  6. method is used for SMP support.
  7. Signed-off-by: Alison Wang <alison.wang@nxp.com>
  8. Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
  9. ---
  10. arch/arm/mach-imx/common.h | 1 +
  11. arch/arm/mach-imx/mach-ls1043a.c | 1 +
  12. arch/arm/mach-imx/platsmp.c | 49 ++++++++++++++++++++++++++++++++++++++
  13. 3 files changed, 51 insertions(+)
  14. --- a/arch/arm/mach-imx/common.h
  15. +++ b/arch/arm/mach-imx/common.h
  16. @@ -155,5 +155,6 @@ static inline void imx_init_l2cache(void
  17. extern struct smp_operations imx_smp_ops;
  18. extern struct smp_operations ls1021a_smp_ops;
  19. +extern const struct smp_operations layerscape_smp_ops;
  20. #endif
  21. --- a/arch/arm/mach-imx/mach-ls1043a.c
  22. +++ b/arch/arm/mach-imx/mach-ls1043a.c
  23. @@ -17,5 +17,6 @@ static const char * const ls1043a_dt_com
  24. };
  25. DT_MACHINE_START(LS1043A, "Freescale LS1043A")
  26. + .smp = smp_ops(layerscape_smp_ops),
  27. .dt_compat = ls1043a_dt_compat,
  28. MACHINE_END
  29. --- a/arch/arm/mach-imx/platsmp.c
  30. +++ b/arch/arm/mach-imx/platsmp.c
  31. @@ -14,6 +14,7 @@
  32. #include <linux/of_address.h>
  33. #include <linux/of.h>
  34. #include <linux/smp.h>
  35. +#include <linux/types.h>
  36. #include <asm/cacheflush.h>
  37. #include <asm/page.h>
  38. @@ -26,6 +27,8 @@
  39. u32 g_diag_reg;
  40. static void __iomem *scu_base;
  41. +static u64 cpu_release_addr[NR_CPUS];
  42. +
  43. static struct map_desc scu_io_desc __initdata = {
  44. /* .virtual and .pfn are run-time assigned */
  45. .length = SZ_4K,
  46. @@ -127,3 +130,49 @@ struct smp_operations ls1021a_smp_ops _
  47. .smp_prepare_cpus = ls1021a_smp_prepare_cpus,
  48. .smp_boot_secondary = ls1021a_boot_secondary,
  49. };
  50. +
  51. +static int layerscape_smp_boot_secondary(unsigned int cpu,
  52. + struct task_struct *idle)
  53. +{
  54. + u32 secondary_startup_phys;
  55. + __le32 __iomem *release_addr;
  56. +
  57. + secondary_startup_phys = virt_to_phys(secondary_startup);
  58. +
  59. + release_addr = ioremap_cache((u32)cpu_release_addr[cpu],
  60. + sizeof(u64));
  61. + if (!release_addr)
  62. + return -ENOMEM;
  63. +
  64. + writel_relaxed(secondary_startup_phys, release_addr);
  65. + writel_relaxed(0, release_addr + 1);
  66. + __cpuc_flush_dcache_area((__force void *)release_addr,
  67. + sizeof(u64));
  68. +
  69. + sev();
  70. +
  71. + iounmap(release_addr);
  72. +
  73. + return 0;
  74. +}
  75. +
  76. +static void layerscape_smp_init_cpus(void)
  77. +{
  78. + struct device_node *dnt = NULL;
  79. + unsigned int cpu = 0;
  80. +
  81. + while ((dnt = of_find_node_by_type(dnt, "cpu"))) {
  82. + if (of_property_read_u64(dnt, "cpu-release-addr",
  83. + &cpu_release_addr[cpu])) {
  84. + pr_err("CPU %d: missing or invalid cpu-release-addr property\n",
  85. + cpu);
  86. + }
  87. +
  88. + cpu++;
  89. + }
  90. +}
  91. +
  92. +const struct smp_operations layerscape_smp_ops __initconst = {
  93. + .smp_init_cpus = layerscape_smp_init_cpus,
  94. + .smp_boot_secondary = layerscape_smp_boot_secondary,
  95. +};