arm64: Fix section mismatch with LTO caused by ambiguous const

Due to how dt_supported_cpu_ops and acpi_supported_cpu_ops are used,
they can be placed in a different section by the compiler when LTO is
used because it thinks that it belongs in another section. To really
make it clear to GCC that these belong in the __initconst section,
make the variables themselves const and refactor cpu_get_ops()
accordingly to make it compile.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Yousef Algadri <yusufgadrie@gmail.com>
Signed-off-by: Panchajanya Sarkar <panchajanya@azure-dev.live>
Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>
This commit is contained in:
Sultan Alsawaf
2020-03-11 09:29:21 -07:00
committed by UtsavBalar1231
parent f44b4829cc
commit afc16dfac0

View File

@@ -31,13 +31,13 @@ extern const struct cpu_operations cpu_psci_ops;
const struct cpu_operations *cpu_ops[NR_CPUS] __ro_after_init;
static const struct cpu_operations *dt_supported_cpu_ops[] __initconst = {
static const struct cpu_operations *const dt_supported_cpu_ops[] __initconst = {
&smp_spin_table_ops,
&cpu_psci_ops,
NULL,
};
static const struct cpu_operations *acpi_supported_cpu_ops[] __initconst = {
static const struct cpu_operations *const acpi_supported_cpu_ops[] __initconst = {
#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
&acpi_parking_protocol_ops,
#endif
@@ -47,15 +47,18 @@ static const struct cpu_operations *acpi_supported_cpu_ops[] __initconst = {
static const struct cpu_operations * __init cpu_get_ops(const char *name)
{
const struct cpu_operations **ops;
int i;
ops = acpi_disabled ? dt_supported_cpu_ops : acpi_supported_cpu_ops;
while (*ops) {
if (!strcmp(name, (*ops)->name))
return *ops;
ops++;
if (acpi_disabled) {
for (i = 0; i < ARRAY_SIZE(dt_supported_cpu_ops); i++) {
if (!strcmp(name, dt_supported_cpu_ops[i]->name))
return dt_supported_cpu_ops[i];
}
} else {
for (i = 0; i < ARRAY_SIZE(acpi_supported_cpu_ops); i++) {
if (!strcmp(name, acpi_supported_cpu_ops[i]->name))
return acpi_supported_cpu_ops[i];
}
}
return NULL;