Merge tag 'hyperv-next-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyper...
[linux-2.6-microblaze.git] / drivers / hv / vmbus_drv.c
index 8c06b33..4ef5a66 100644 (file)
@@ -79,7 +79,7 @@ static struct notifier_block hyperv_panic_block = {
 static const char *fb_mmio_name = "fb_range";
 static struct resource *fb_mmio;
 static struct resource *hyperv_mmio;
-static DEFINE_SEMAPHORE(hyperv_mmio_lock);
+static DEFINE_MUTEX(hyperv_mmio_lock);
 
 static int vmbus_exists(void)
 {
@@ -960,6 +960,8 @@ static void vmbus_device_release(struct device *device)
        struct hv_device *hv_dev = device_to_hv_device(device);
        struct vmbus_channel *channel = hv_dev->channel;
 
+       hv_debug_rm_dev_dir(hv_dev);
+
        mutex_lock(&vmbus_connection.channel_mutex);
        hv_process_channel_removal(channel);
        mutex_unlock(&vmbus_connection.channel_mutex);
@@ -1273,7 +1275,7 @@ static void hv_kmsg_dump(struct kmsg_dumper *dumper,
         * Write dump contents to the page. No need to synchronize; panic should
         * be single-threaded.
         */
-       kmsg_dump_get_buffer(dumper, true, hv_panic_page, PAGE_SIZE,
+       kmsg_dump_get_buffer(dumper, true, hv_panic_page, HV_HYP_PAGE_SIZE,
                             &bytes_written);
        if (bytes_written)
                hyperv_report_panic_msg(panic_pa, bytes_written);
@@ -1373,7 +1375,7 @@ static int vmbus_bus_init(void)
                 */
                hv_get_crash_ctl(hyperv_crash_ctl);
                if (hyperv_crash_ctl & HV_CRASH_CTL_CRASH_NOTIFY_MSG) {
-                       hv_panic_page = (void *)get_zeroed_page(GFP_KERNEL);
+                       hv_panic_page = (void *)hv_alloc_hyperv_zeroed_page();
                        if (hv_panic_page) {
                                ret = kmsg_dump_register(&hv_kmsg_dumper);
                                if (ret)
@@ -1401,7 +1403,7 @@ err_alloc:
        hv_remove_vmbus_irq();
 
        bus_unregister(&hv_bus);
-       free_page((unsigned long)hv_panic_page);
+       hv_free_hyperv_page((unsigned long)hv_panic_page);
        unregister_sysctl_table(hv_ctl_table_hdr);
        hv_ctl_table_hdr = NULL;
        return ret;
@@ -1809,6 +1811,7 @@ int vmbus_device_register(struct hv_device *child_device_obj)
                pr_err("Unable to register primary channeln");
                goto err_kset_unregister;
        }
+       hv_debug_add_dev_dir(child_device_obj);
 
        return 0;
 
@@ -2010,7 +2013,7 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj,
        int retval;
 
        retval = -ENXIO;
-       down(&hyperv_mmio_lock);
+       mutex_lock(&hyperv_mmio_lock);
 
        /*
         * If overlaps with frame buffers are allowed, then first attempt to
@@ -2057,7 +2060,7 @@ int vmbus_allocate_mmio(struct resource **new, struct hv_device *device_obj,
        }
 
 exit:
-       up(&hyperv_mmio_lock);
+       mutex_unlock(&hyperv_mmio_lock);
        return retval;
 }
 EXPORT_SYMBOL_GPL(vmbus_allocate_mmio);
@@ -2074,7 +2077,7 @@ void vmbus_free_mmio(resource_size_t start, resource_size_t size)
 {
        struct resource *iter;
 
-       down(&hyperv_mmio_lock);
+       mutex_lock(&hyperv_mmio_lock);
        for (iter = hyperv_mmio; iter; iter = iter->sibling) {
                if ((iter->start >= start + size) || (iter->end <= start))
                        continue;
@@ -2082,7 +2085,7 @@ void vmbus_free_mmio(resource_size_t start, resource_size_t size)
                __release_region(iter, start, size);
        }
        release_mem_region(start, size);
-       up(&hyperv_mmio_lock);
+       mutex_unlock(&hyperv_mmio_lock);
 
 }
 EXPORT_SYMBOL_GPL(vmbus_free_mmio);
@@ -2215,8 +2218,7 @@ static int vmbus_bus_resume(struct device *dev)
         * We only use the 'vmbus_proto_version', which was in use before
         * hibernation, to re-negotiate with the host.
         */
-       if (vmbus_proto_version == VERSION_INVAL ||
-           vmbus_proto_version == 0) {
+       if (!vmbus_proto_version) {
                pr_err("Invalid proto version = 0x%x\n", vmbus_proto_version);
                return -EINVAL;
        }
@@ -2303,7 +2305,7 @@ static void hv_crash_handler(struct pt_regs *regs)
        vmbus_connection.conn_state = DISCONNECTED;
        cpu = smp_processor_id();
        hv_stimer_cleanup(cpu);
-       hv_synic_cleanup(cpu);
+       hv_synic_disable_regs(cpu);
        hyperv_cleanup();
 };
 
@@ -2373,6 +2375,7 @@ static int __init hv_acpi_init(void)
                ret = -ETIMEDOUT;
                goto cleanup;
        }
+       hv_debug_init();
 
        ret = vmbus_bus_init();
        if (ret)
@@ -2409,6 +2412,8 @@ static void __exit vmbus_exit(void)
 
                tasklet_kill(&hv_cpu->msg_dpc);
        }
+       hv_debug_rm_all_dir();
+
        vmbus_free_channels();
 
        if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) {