drivers/base/cpu: crash data showing should depends on KEXEC_CORE
[platform/kernel/linux-starfive.git] / drivers / base / cpu.c
index 43dab03..548491d 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/cpufeature.h>
 #include <linux/tick.h>
 #include <linux/pm_qos.h>
+#include <linux/delay.h>
 #include <linux/sched/isolation.h>
 
 #include "base.h"
@@ -50,12 +51,30 @@ static int cpu_subsys_online(struct device *dev)
        int cpuid = dev->id;
        int from_nid, to_nid;
        int ret;
+       int retries = 0;
 
        from_nid = cpu_to_node(cpuid);
        if (from_nid == NUMA_NO_NODE)
                return -ENODEV;
 
+retry:
        ret = cpu_device_up(dev);
+
+       /*
+        * If -EBUSY is returned, it is likely that hotplug is temporarily
+        * disabled when cpu_hotplug_disable() was called. This condition is
+        * transient. So we retry after waiting for an exponentially
+        * increasing delay up to a total of at least 620ms as some PCI
+        * device initialization can take quite a while.
+        */
+       if (ret == -EBUSY) {
+               retries++;
+               if (retries > 5)
+                       return ret;
+               msleep(10 * (1 << retries));
+               goto retry;
+       }
+
        /*
         * When hot adding memory to memoryless node and enabling a cpu
         * on the node, node number of the cpu may internally change.
@@ -125,7 +144,7 @@ static DEVICE_ATTR(release, S_IWUSR, NULL, cpu_release_store);
 #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
 #endif /* CONFIG_HOTPLUG_CPU */
 
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 #include <linux/kexec.h>
 
 static ssize_t crash_notes_show(struct device *dev,
@@ -170,14 +189,14 @@ static const struct attribute_group crash_note_cpu_attr_group = {
 #endif
 
 static const struct attribute_group *common_cpu_attr_groups[] = {
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
        &crash_note_cpu_attr_group,
 #endif
        NULL
 };
 
 static const struct attribute_group *hotplugable_cpu_attr_groups[] = {
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
        &crash_note_cpu_attr_group,
 #endif
        NULL