xen/acpi: xen memory hotplug minor updates
[firefly-linux-kernel-4.4.55.git] / drivers / xen / pcpu.c
index 5a27a4599a4a8dbb28aab05c305b799b7883d2ac..6536d5ab1697ba6d770a6d8b969d2340df832ec7 100644 (file)
@@ -332,6 +332,41 @@ static irqreturn_t xen_pcpu_interrupt(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
+/* Sync with Xen hypervisor after cpu hotadded */
+void xen_pcpu_hotplug_sync(void)
+{
+       schedule_work(&xen_pcpu_work);
+}
+EXPORT_SYMBOL_GPL(xen_pcpu_hotplug_sync);
+
+/*
+ * For hypervisor presented cpu, return logic cpu id;
+ * For hypervisor non-presented cpu, return -ENODEV.
+ */
+int xen_pcpu_id(uint32_t acpi_id)
+{
+       int cpu_id = 0, max_id = 0;
+       struct xen_platform_op op;
+
+       op.cmd = XENPF_get_cpuinfo;
+       while (cpu_id <= max_id) {
+               op.u.pcpu_info.xen_cpuid = cpu_id;
+               if (HYPERVISOR_dom0_op(&op)) {
+                       cpu_id++;
+                       continue;
+               }
+
+               if (acpi_id == op.u.pcpu_info.acpi_id)
+                       return cpu_id;
+               if (op.u.pcpu_info.max_present > max_id)
+                       max_id = op.u.pcpu_info.max_present;
+               cpu_id++;
+       }
+
+       return -ENODEV;
+}
+EXPORT_SYMBOL_GPL(xen_pcpu_id);
+
 static int __init xen_pcpu_init(void)
 {
        int irq, ret;