coresight: Do not default to CPU0 for missing CPU phandle
Coresight platform support assumes that a missing "cpu" phandle defaults to CPU0. This could be problematic and unnecessarily binds components to CPU0, where they may not be. In coresight etm and cpu-debug drivers, abort the probe for such cases. Signed-off-by: Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com> Tested-by: Mathieu Poirier <mathieu.poirier@linaro.org> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> Link: https://lore.kernel.org/r/f1955ea19c714cf64ea54ec356a9aa85f3cd17b8.1562229018.git.saiprakash.ranjan@codeaurora.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
1141301c20
Коммит
996cdfaf53
|
@ -579,6 +579,9 @@ static int debug_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
drvdata->cpu = coresight_get_cpu(dev);
|
drvdata->cpu = coresight_get_cpu(dev);
|
||||||
|
if (drvdata->cpu < 0)
|
||||||
|
return drvdata->cpu;
|
||||||
|
|
||||||
if (per_cpu(debug_drvdata, drvdata->cpu)) {
|
if (per_cpu(debug_drvdata, drvdata->cpu)) {
|
||||||
dev_err(dev, "CPU%d drvdata has already been initialized\n",
|
dev_err(dev, "CPU%d drvdata has already been initialized\n",
|
||||||
drvdata->cpu);
|
drvdata->cpu);
|
||||||
|
|
|
@ -816,6 +816,9 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
}
|
}
|
||||||
|
|
||||||
drvdata->cpu = coresight_get_cpu(dev);
|
drvdata->cpu = coresight_get_cpu(dev);
|
||||||
|
if (drvdata->cpu < 0)
|
||||||
|
return drvdata->cpu;
|
||||||
|
|
||||||
desc.name = devm_kasprintf(dev, GFP_KERNEL, "etm%d", drvdata->cpu);
|
desc.name = devm_kasprintf(dev, GFP_KERNEL, "etm%d", drvdata->cpu);
|
||||||
if (!desc.name)
|
if (!desc.name)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
|
@ -1101,6 +1101,9 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
spin_lock_init(&drvdata->spinlock);
|
spin_lock_init(&drvdata->spinlock);
|
||||||
|
|
||||||
drvdata->cpu = coresight_get_cpu(dev);
|
drvdata->cpu = coresight_get_cpu(dev);
|
||||||
|
if (drvdata->cpu < 0)
|
||||||
|
return drvdata->cpu;
|
||||||
|
|
||||||
desc.name = devm_kasprintf(dev, GFP_KERNEL, "etm%d", drvdata->cpu);
|
desc.name = devm_kasprintf(dev, GFP_KERNEL, "etm%d", drvdata->cpu);
|
||||||
if (!desc.name)
|
if (!desc.name)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
|
@ -159,16 +159,16 @@ static int of_coresight_get_cpu(struct device *dev)
|
||||||
struct device_node *dn;
|
struct device_node *dn;
|
||||||
|
|
||||||
if (!dev->of_node)
|
if (!dev->of_node)
|
||||||
return 0;
|
return -ENODEV;
|
||||||
|
|
||||||
dn = of_parse_phandle(dev->of_node, "cpu", 0);
|
dn = of_parse_phandle(dev->of_node, "cpu", 0);
|
||||||
/* Affinity defaults to CPU0 */
|
|
||||||
if (!dn)
|
if (!dn)
|
||||||
return 0;
|
return -ENODEV;
|
||||||
|
|
||||||
cpu = of_cpu_node_to_id(dn);
|
cpu = of_cpu_node_to_id(dn);
|
||||||
of_node_put(dn);
|
of_node_put(dn);
|
||||||
|
|
||||||
/* Affinity to CPU0 if no cpu nodes are found */
|
return cpu;
|
||||||
return (cpu < 0) ? 0 : cpu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -310,7 +310,7 @@ of_get_coresight_platform_data(struct device *dev,
|
||||||
|
|
||||||
static inline int of_coresight_get_cpu(struct device *dev)
|
static inline int of_coresight_get_cpu(struct device *dev)
|
||||||
{
|
{
|
||||||
return 0;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -734,14 +734,14 @@ static int acpi_coresight_get_cpu(struct device *dev)
|
||||||
struct acpi_device *adev = ACPI_COMPANION(dev);
|
struct acpi_device *adev = ACPI_COMPANION(dev);
|
||||||
|
|
||||||
if (!adev)
|
if (!adev)
|
||||||
return 0;
|
return -ENODEV;
|
||||||
status = acpi_get_parent(adev->handle, &cpu_handle);
|
status = acpi_get_parent(adev->handle, &cpu_handle);
|
||||||
if (ACPI_FAILURE(status))
|
if (ACPI_FAILURE(status))
|
||||||
return 0;
|
return -ENODEV;
|
||||||
|
|
||||||
cpu = acpi_handle_to_logical_cpuid(cpu_handle);
|
cpu = acpi_handle_to_logical_cpuid(cpu_handle);
|
||||||
if (cpu >= nr_cpu_ids)
|
if (cpu >= nr_cpu_ids)
|
||||||
return 0;
|
return -ENODEV;
|
||||||
return cpu;
|
return cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -769,7 +769,7 @@ acpi_get_coresight_platform_data(struct device *dev,
|
||||||
|
|
||||||
static inline int acpi_coresight_get_cpu(struct device *dev)
|
static inline int acpi_coresight_get_cpu(struct device *dev)
|
||||||
{
|
{
|
||||||
return 0;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче