2 * Copyright (c) 2009, Microsoft Corporation.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
18 * Haiyang Zhang <haiyangz@microsoft.com>
19 * Hank Janssen <hjanssen@microsoft.com>
20 * K. Y. Srinivasan <kys@microsoft.com>
23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25 #include <linux/init.h>
26 #include <linux/module.h>
27 #include <linux/device.h>
28 #include <linux/irq.h>
29 #include <linux/interrupt.h>
30 #include <linux/sysctl.h>
31 #include <linux/slab.h>
32 #include <linux/acpi.h>
33 #include <acpi/acpi_bus.h>
34 #include <linux/completion.h>
35 #include <linux/hyperv.h>
36 #include <linux/kernel_stat.h>
37 #include <asm/hyperv.h>
38 #include <asm/hypervisor.h>
39 #include <asm/mshyperv.h>
40 #include "hyperv_vmbus.h"
43 static struct acpi_device *hv_acpi_dev;
45 static struct tasklet_struct msg_dpc;
46 static struct completion probe_event;
49 struct hv_device_info {
50 struct hv_dev_port_info inbound;
51 struct hv_dev_port_info outbound;
54 static int vmbus_exists(void)
56 if (hv_acpi_dev == NULL)
63 static void get_channel_info(struct hv_device *device,
64 struct hv_device_info *info)
66 struct hv_ring_buffer_debug_info inbound;
67 struct hv_ring_buffer_debug_info outbound;
72 hv_ringbuffer_get_debuginfo(&device->channel->inbound, &inbound);
73 hv_ringbuffer_get_debuginfo(&device->channel->outbound, &outbound);
75 info->inbound.int_mask = inbound.current_interrupt_mask;
76 info->inbound.read_idx = inbound.current_read_index;
77 info->inbound.write_idx = inbound.current_write_index;
78 info->inbound.bytes_avail_toread = inbound.bytes_avail_toread;
79 info->inbound.bytes_avail_towrite = inbound.bytes_avail_towrite;
81 info->outbound.int_mask = outbound.current_interrupt_mask;
82 info->outbound.read_idx = outbound.current_read_index;
83 info->outbound.write_idx = outbound.current_write_index;
84 info->outbound.bytes_avail_toread = outbound.bytes_avail_toread;
85 info->outbound.bytes_avail_towrite = outbound.bytes_avail_towrite;
88 #define VMBUS_ALIAS_LEN ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2)
89 static void print_alias_name(struct hv_device *hv_dev, char *alias_name)
92 for (i = 0; i < VMBUS_ALIAS_LEN; i += 2)
93 sprintf(&alias_name[i], "%02x", hv_dev->dev_type.b[i/2]);
97 * vmbus_show_device_attr - Show the device attribute in sysfs.
99 * This is invoked when user does a
100 * "cat /sys/bus/vmbus/devices/<busdevice>/<attr name>"
102 static ssize_t vmbus_show_device_attr(struct device *dev,
103 struct device_attribute *dev_attr,
106 struct hv_device *hv_dev = device_to_hv_device(dev);
107 struct hv_device_info *device_info;
110 device_info = kzalloc(sizeof(struct hv_device_info), GFP_KERNEL);
114 get_channel_info(hv_dev, device_info);
116 if (!strcmp(dev_attr->attr.name, "out_intr_mask")) {
117 ret = sprintf(buf, "%d\n", device_info->outbound.int_mask);
118 } else if (!strcmp(dev_attr->attr.name, "out_read_index")) {
119 ret = sprintf(buf, "%d\n", device_info->outbound.read_idx);
120 } else if (!strcmp(dev_attr->attr.name, "out_write_index")) {
121 ret = sprintf(buf, "%d\n", device_info->outbound.write_idx);
122 } else if (!strcmp(dev_attr->attr.name, "out_read_bytes_avail")) {
123 ret = sprintf(buf, "%d\n",
124 device_info->outbound.bytes_avail_toread);
125 } else if (!strcmp(dev_attr->attr.name, "out_write_bytes_avail")) {
126 ret = sprintf(buf, "%d\n",
127 device_info->outbound.bytes_avail_towrite);
128 } else if (!strcmp(dev_attr->attr.name, "in_intr_mask")) {
129 ret = sprintf(buf, "%d\n", device_info->inbound.int_mask);
130 } else if (!strcmp(dev_attr->attr.name, "in_read_index")) {
131 ret = sprintf(buf, "%d\n", device_info->inbound.read_idx);
132 } else if (!strcmp(dev_attr->attr.name, "in_write_index")) {
133 ret = sprintf(buf, "%d\n", device_info->inbound.write_idx);
134 } else if (!strcmp(dev_attr->attr.name, "in_read_bytes_avail")) {
135 ret = sprintf(buf, "%d\n",
136 device_info->inbound.bytes_avail_toread);
137 } else if (!strcmp(dev_attr->attr.name, "in_write_bytes_avail")) {
138 ret = sprintf(buf, "%d\n",
139 device_info->inbound.bytes_avail_towrite);
146 static u8 channel_monitor_group(struct vmbus_channel *channel)
148 return (u8)channel->offermsg.monitorid / 32;
151 static u8 channel_monitor_offset(struct vmbus_channel *channel)
153 return (u8)channel->offermsg.monitorid % 32;
156 static u32 channel_pending(struct vmbus_channel *channel,
157 struct hv_monitor_page *monitor_page)
159 u8 monitor_group = channel_monitor_group(channel);
160 return monitor_page->trigger_group[monitor_group].pending;
163 static u32 channel_latency(struct vmbus_channel *channel,
164 struct hv_monitor_page *monitor_page)
166 u8 monitor_group = channel_monitor_group(channel);
167 u8 monitor_offset = channel_monitor_offset(channel);
168 return monitor_page->latency[monitor_group][monitor_offset];
171 static u32 channel_conn_id(struct vmbus_channel *channel,
172 struct hv_monitor_page *monitor_page)
174 u8 monitor_group = channel_monitor_group(channel);
175 u8 monitor_offset = channel_monitor_offset(channel);
176 return monitor_page->parameter[monitor_group][monitor_offset].connectionid.u.id;
179 static ssize_t id_show(struct device *dev, struct device_attribute *dev_attr,
182 struct hv_device *hv_dev = device_to_hv_device(dev);
184 if (!hv_dev->channel)
186 return sprintf(buf, "%d\n", hv_dev->channel->offermsg.child_relid);
188 static DEVICE_ATTR_RO(id);
190 static ssize_t state_show(struct device *dev, struct device_attribute *dev_attr,
193 struct hv_device *hv_dev = device_to_hv_device(dev);
195 if (!hv_dev->channel)
197 return sprintf(buf, "%d\n", hv_dev->channel->state);
199 static DEVICE_ATTR_RO(state);
201 static ssize_t monitor_id_show(struct device *dev,
202 struct device_attribute *dev_attr, char *buf)
204 struct hv_device *hv_dev = device_to_hv_device(dev);
206 if (!hv_dev->channel)
208 return sprintf(buf, "%d\n", hv_dev->channel->offermsg.monitorid);
210 static DEVICE_ATTR_RO(monitor_id);
212 static ssize_t class_id_show(struct device *dev,
213 struct device_attribute *dev_attr, char *buf)
215 struct hv_device *hv_dev = device_to_hv_device(dev);
217 if (!hv_dev->channel)
219 return sprintf(buf, "{%pUl}\n",
220 hv_dev->channel->offermsg.offer.if_type.b);
222 static DEVICE_ATTR_RO(class_id);
224 static ssize_t device_id_show(struct device *dev,
225 struct device_attribute *dev_attr, char *buf)
227 struct hv_device *hv_dev = device_to_hv_device(dev);
229 if (!hv_dev->channel)
231 return sprintf(buf, "{%pUl}\n",
232 hv_dev->channel->offermsg.offer.if_instance.b);
234 static DEVICE_ATTR_RO(device_id);
236 static ssize_t modalias_show(struct device *dev,
237 struct device_attribute *dev_attr, char *buf)
239 struct hv_device *hv_dev = device_to_hv_device(dev);
240 char alias_name[VMBUS_ALIAS_LEN + 1];
242 print_alias_name(hv_dev, alias_name);
243 return sprintf(buf, "vmbus:%s\n", alias_name);
245 static DEVICE_ATTR_RO(modalias);
247 static ssize_t server_monitor_pending_show(struct device *dev,
248 struct device_attribute *dev_attr,
251 struct hv_device *hv_dev = device_to_hv_device(dev);
253 if (!hv_dev->channel)
255 return sprintf(buf, "%d\n",
256 channel_pending(hv_dev->channel,
257 vmbus_connection.monitor_pages[1]));
259 static DEVICE_ATTR_RO(server_monitor_pending);
261 static ssize_t client_monitor_pending_show(struct device *dev,
262 struct device_attribute *dev_attr,
265 struct hv_device *hv_dev = device_to_hv_device(dev);
267 if (!hv_dev->channel)
269 return sprintf(buf, "%d\n",
270 channel_pending(hv_dev->channel,
271 vmbus_connection.monitor_pages[1]));
273 static DEVICE_ATTR_RO(client_monitor_pending);
275 static ssize_t server_monitor_latency_show(struct device *dev,
276 struct device_attribute *dev_attr,
279 struct hv_device *hv_dev = device_to_hv_device(dev);
281 if (!hv_dev->channel)
283 return sprintf(buf, "%d\n",
284 channel_latency(hv_dev->channel,
285 vmbus_connection.monitor_pages[0]));
287 static DEVICE_ATTR_RO(server_monitor_latency);
289 static ssize_t client_monitor_latency_show(struct device *dev,
290 struct device_attribute *dev_attr,
293 struct hv_device *hv_dev = device_to_hv_device(dev);
295 if (!hv_dev->channel)
297 return sprintf(buf, "%d\n",
298 channel_latency(hv_dev->channel,
299 vmbus_connection.monitor_pages[1]));
301 static DEVICE_ATTR_RO(client_monitor_latency);
303 static ssize_t server_monitor_conn_id_show(struct device *dev,
304 struct device_attribute *dev_attr,
307 struct hv_device *hv_dev = device_to_hv_device(dev);
309 if (!hv_dev->channel)
311 return sprintf(buf, "%d\n",
312 channel_conn_id(hv_dev->channel,
313 vmbus_connection.monitor_pages[0]));
315 static DEVICE_ATTR_RO(server_monitor_conn_id);
317 static ssize_t client_monitor_conn_id_show(struct device *dev,
318 struct device_attribute *dev_attr,
321 struct hv_device *hv_dev = device_to_hv_device(dev);
323 if (!hv_dev->channel)
325 return sprintf(buf, "%d\n",
326 channel_conn_id(hv_dev->channel,
327 vmbus_connection.monitor_pages[1]));
329 static DEVICE_ATTR_RO(client_monitor_conn_id);
331 static struct attribute *vmbus_attrs[] = {
333 &dev_attr_state.attr,
334 &dev_attr_monitor_id.attr,
335 &dev_attr_class_id.attr,
336 &dev_attr_device_id.attr,
337 &dev_attr_modalias.attr,
338 &dev_attr_server_monitor_pending.attr,
339 &dev_attr_client_monitor_pending.attr,
340 &dev_attr_server_monitor_latency.attr,
341 &dev_attr_client_monitor_latency.attr,
342 &dev_attr_server_monitor_conn_id.attr,
343 &dev_attr_client_monitor_conn_id.attr,
346 ATTRIBUTE_GROUPS(vmbus);
348 /* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
349 static struct device_attribute vmbus_device_attrs[] = {
350 __ATTR(out_intr_mask, S_IRUGO, vmbus_show_device_attr, NULL),
351 __ATTR(out_read_index, S_IRUGO, vmbus_show_device_attr, NULL),
352 __ATTR(out_write_index, S_IRUGO, vmbus_show_device_attr, NULL),
353 __ATTR(out_read_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
354 __ATTR(out_write_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
356 __ATTR(in_intr_mask, S_IRUGO, vmbus_show_device_attr, NULL),
357 __ATTR(in_read_index, S_IRUGO, vmbus_show_device_attr, NULL),
358 __ATTR(in_write_index, S_IRUGO, vmbus_show_device_attr, NULL),
359 __ATTR(in_read_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
360 __ATTR(in_write_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
366 * vmbus_uevent - add uevent for our device
368 * This routine is invoked when a device is added or removed on the vmbus to
369 * generate a uevent to udev in the userspace. The udev will then look at its
370 * rule and the uevent generated here to load the appropriate driver
372 * The alias string will be of the form vmbus:guid where guid is the string
373 * representation of the device guid (each byte of the guid will be
374 * represented with two hex characters.
376 static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
378 struct hv_device *dev = device_to_hv_device(device);
380 char alias_name[VMBUS_ALIAS_LEN + 1];
382 print_alias_name(dev, alias_name);
383 ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name);
387 static uuid_le null_guid;
389 static inline bool is_null_guid(const __u8 *guid)
391 if (memcmp(guid, &null_guid, sizeof(uuid_le)))
397 * Return a matching hv_vmbus_device_id pointer.
398 * If there is no match, return NULL.
400 static const struct hv_vmbus_device_id *hv_vmbus_get_id(
401 const struct hv_vmbus_device_id *id,
404 for (; !is_null_guid(id->guid); id++)
405 if (!memcmp(&id->guid, guid, sizeof(uuid_le)))
414 * vmbus_match - Attempt to match the specified device to the specified driver
416 static int vmbus_match(struct device *device, struct device_driver *driver)
418 struct hv_driver *drv = drv_to_hv_drv(driver);
419 struct hv_device *hv_dev = device_to_hv_device(device);
421 if (hv_vmbus_get_id(drv->id_table, hv_dev->dev_type.b))
428 * vmbus_probe - Add the new vmbus's child device
430 static int vmbus_probe(struct device *child_device)
433 struct hv_driver *drv =
434 drv_to_hv_drv(child_device->driver);
435 struct hv_device *dev = device_to_hv_device(child_device);
436 const struct hv_vmbus_device_id *dev_id;
438 dev_id = hv_vmbus_get_id(drv->id_table, dev->dev_type.b);
440 ret = drv->probe(dev, dev_id);
442 pr_err("probe failed for device %s (%d)\n",
443 dev_name(child_device), ret);
446 pr_err("probe not set for driver %s\n",
447 dev_name(child_device));
454 * vmbus_remove - Remove a vmbus device
456 static int vmbus_remove(struct device *child_device)
458 struct hv_driver *drv = drv_to_hv_drv(child_device->driver);
459 struct hv_device *dev = device_to_hv_device(child_device);
464 pr_err("remove not set for driver %s\n",
465 dev_name(child_device));
472 * vmbus_shutdown - Shutdown a vmbus device
474 static void vmbus_shutdown(struct device *child_device)
476 struct hv_driver *drv;
477 struct hv_device *dev = device_to_hv_device(child_device);
480 /* The device may not be attached yet */
481 if (!child_device->driver)
484 drv = drv_to_hv_drv(child_device->driver);
494 * vmbus_device_release - Final callback release of the vmbus child device
496 static void vmbus_device_release(struct device *device)
498 struct hv_device *hv_dev = device_to_hv_device(device);
504 /* The one and only one */
505 static struct bus_type hv_bus = {
507 .match = vmbus_match,
508 .shutdown = vmbus_shutdown,
509 .remove = vmbus_remove,
510 .probe = vmbus_probe,
511 .uevent = vmbus_uevent,
512 .dev_attrs = vmbus_device_attrs,
513 .dev_groups = vmbus_groups,
516 static const char *driver_name = "hyperv";
519 struct onmessage_work_context {
520 struct work_struct work;
521 struct hv_message msg;
524 static void vmbus_onmessage_work(struct work_struct *work)
526 struct onmessage_work_context *ctx;
528 ctx = container_of(work, struct onmessage_work_context,
530 vmbus_onmessage(&ctx->msg);
534 static void vmbus_on_msg_dpc(unsigned long data)
536 int cpu = smp_processor_id();
537 void *page_addr = hv_context.synic_message_page[cpu];
538 struct hv_message *msg = (struct hv_message *)page_addr +
540 struct onmessage_work_context *ctx;
543 if (msg->header.message_type == HVMSG_NONE) {
547 ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
550 INIT_WORK(&ctx->work, vmbus_onmessage_work);
551 memcpy(&ctx->msg, msg, sizeof(*msg));
552 queue_work(vmbus_connection.work_queue, &ctx->work);
555 msg->header.message_type = HVMSG_NONE;
558 * Make sure the write to MessageType (ie set to
559 * HVMSG_NONE) happens before we read the
560 * MessagePending and EOMing. Otherwise, the EOMing
561 * will not deliver any more messages since there is
566 if (msg->header.message_flags.msg_pending) {
568 * This will cause message queue rescan to
569 * possibly deliver another msg from the
572 wrmsrl(HV_X64_MSR_EOM, 0);
577 static irqreturn_t vmbus_isr(int irq, void *dev_id)
579 int cpu = smp_processor_id();
581 struct hv_message *msg;
582 union hv_synic_event_flags *event;
583 bool handled = false;
585 page_addr = hv_context.synic_event_page[cpu];
586 if (page_addr == NULL)
589 event = (union hv_synic_event_flags *)page_addr +
592 * Check for events before checking for messages. This is the order
593 * in which events and messages are checked in Windows guests on
594 * Hyper-V, and the Windows team suggested we do the same.
597 if ((vmbus_proto_version == VERSION_WS2008) ||
598 (vmbus_proto_version == VERSION_WIN7)) {
600 /* Since we are a child, we only need to check bit 0 */
601 if (sync_test_and_clear_bit(0,
602 (unsigned long *) &event->flags32[0])) {
607 * Our host is win8 or above. The signaling mechanism
608 * has changed and we can directly look at the event page.
609 * If bit n is set then we have an interrup on the channel
616 tasklet_schedule(hv_context.event_dpc[cpu]);
619 page_addr = hv_context.synic_message_page[cpu];
620 msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
622 /* Check if there are actual msgs to be processed */
623 if (msg->header.message_type != HVMSG_NONE) {
625 tasklet_schedule(&msg_dpc);
635 * vmbus interrupt flow handler:
636 * vmbus interrupts can concurrently occur on multiple CPUs and
637 * can be handled concurrently.
640 static void vmbus_flow_handler(unsigned int irq, struct irq_desc *desc)
642 kstat_incr_irqs_this_cpu(irq, desc);
644 desc->action->handler(irq, desc->action->dev_id);
648 * vmbus_bus_init -Main vmbus driver initialization routine.
651 * - initialize the vmbus driver context
652 * - invoke the vmbus hv main init routine
653 * - get the irq resource
654 * - retrieve the channel offers
656 static int vmbus_bus_init(int irq)
660 /* Hypervisor initialization...setup hypercall page..etc */
663 pr_err("Unable to initialize the hypervisor - 0x%x\n", ret);
667 tasklet_init(&msg_dpc, vmbus_on_msg_dpc, 0);
669 ret = bus_register(&hv_bus);
673 ret = request_irq(irq, vmbus_isr, 0, driver_name, hv_acpi_dev);
676 pr_err("Unable to request IRQ %d\n",
682 * Vmbus interrupts can be handled concurrently on
683 * different CPUs. Establish an appropriate interrupt flow
684 * handler that can support this model.
686 irq_set_handler(irq, vmbus_flow_handler);
689 * Register our interrupt handler.
691 hv_register_vmbus_handler(irq, vmbus_isr);
693 ret = hv_synic_alloc();
697 * Initialize the per-cpu interrupt state and
698 * connect to the host.
700 on_each_cpu(hv_synic_init, NULL, 1);
701 ret = vmbus_connect();
705 vmbus_request_offers();
711 free_irq(irq, hv_acpi_dev);
714 bus_unregister(&hv_bus);
723 * __vmbus_child_driver_register - Register a vmbus's driver
724 * @drv: Pointer to driver structure you want to register
725 * @owner: owner module of the drv
726 * @mod_name: module name string
728 * Registers the given driver with Linux through the 'driver_register()' call
729 * and sets up the hyper-v vmbus handling for this driver.
730 * It will return the state of the 'driver_register()' call.
733 int __vmbus_driver_register(struct hv_driver *hv_driver, struct module *owner, const char *mod_name)
737 pr_info("registering driver %s\n", hv_driver->name);
739 ret = vmbus_exists();
743 hv_driver->driver.name = hv_driver->name;
744 hv_driver->driver.owner = owner;
745 hv_driver->driver.mod_name = mod_name;
746 hv_driver->driver.bus = &hv_bus;
748 ret = driver_register(&hv_driver->driver);
752 EXPORT_SYMBOL_GPL(__vmbus_driver_register);
755 * vmbus_driver_unregister() - Unregister a vmbus's driver
756 * @drv: Pointer to driver structure you want to un-register
758 * Un-register the given driver that was previous registered with a call to
759 * vmbus_driver_register()
761 void vmbus_driver_unregister(struct hv_driver *hv_driver)
763 pr_info("unregistering driver %s\n", hv_driver->name);
766 driver_unregister(&hv_driver->driver);
768 EXPORT_SYMBOL_GPL(vmbus_driver_unregister);
771 * vmbus_device_create - Creates and registers a new child device
774 struct hv_device *vmbus_device_create(uuid_le *type,
776 struct vmbus_channel *channel)
778 struct hv_device *child_device_obj;
780 child_device_obj = kzalloc(sizeof(struct hv_device), GFP_KERNEL);
781 if (!child_device_obj) {
782 pr_err("Unable to allocate device object for child device\n");
786 child_device_obj->channel = channel;
787 memcpy(&child_device_obj->dev_type, type, sizeof(uuid_le));
788 memcpy(&child_device_obj->dev_instance, instance,
792 return child_device_obj;
796 * vmbus_device_register - Register the child device
798 int vmbus_device_register(struct hv_device *child_device_obj)
802 static atomic_t device_num = ATOMIC_INIT(0);
804 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
805 atomic_inc_return(&device_num));
807 child_device_obj->device.bus = &hv_bus;
808 child_device_obj->device.parent = &hv_acpi_dev->dev;
809 child_device_obj->device.release = vmbus_device_release;
812 * Register with the LDM. This will kick off the driver/device
813 * binding...which will eventually call vmbus_match() and vmbus_probe()
815 ret = device_register(&child_device_obj->device);
818 pr_err("Unable to register child device\n");
820 pr_debug("child device %s registered\n",
821 dev_name(&child_device_obj->device));
827 * vmbus_device_unregister - Remove the specified child device
830 void vmbus_device_unregister(struct hv_device *device_obj)
832 pr_debug("child device %s unregistered\n",
833 dev_name(&device_obj->device));
836 * Kick off the process of unregistering the device.
837 * This will call vmbus_remove() and eventually vmbus_device_release()
839 device_unregister(&device_obj->device);
844 * VMBUS is an acpi enumerated device. Get the the IRQ information
848 static acpi_status vmbus_walk_resources(struct acpi_resource *res, void *irq)
851 if (res->type == ACPI_RESOURCE_TYPE_IRQ) {
852 struct acpi_resource_irq *irqp;
853 irqp = &res->data.irq;
855 *((unsigned int *)irq) = irqp->interrupts[0];
861 static int vmbus_acpi_add(struct acpi_device *device)
865 hv_acpi_dev = device;
867 result = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
868 vmbus_walk_resources, &irq);
870 if (ACPI_FAILURE(result)) {
871 complete(&probe_event);
874 complete(&probe_event);
878 static const struct acpi_device_id vmbus_acpi_device_ids[] = {
883 MODULE_DEVICE_TABLE(acpi, vmbus_acpi_device_ids);
885 static struct acpi_driver vmbus_acpi_driver = {
887 .ids = vmbus_acpi_device_ids,
889 .add = vmbus_acpi_add,
893 static int __init hv_acpi_init(void)
897 if (x86_hyper != &x86_hyper_ms_hyperv)
900 init_completion(&probe_event);
903 * Get irq resources first.
906 ret = acpi_bus_register_driver(&vmbus_acpi_driver);
911 t = wait_for_completion_timeout(&probe_event, 5*HZ);
922 ret = vmbus_bus_init(irq);
929 acpi_bus_unregister_driver(&vmbus_acpi_driver);
934 static void __exit vmbus_exit(void)
937 free_irq(irq, hv_acpi_dev);
938 vmbus_free_channels();
939 bus_unregister(&hv_bus);
941 acpi_bus_unregister_driver(&vmbus_acpi_driver);
945 MODULE_LICENSE("GPL");
947 subsys_initcall(hv_acpi_init);
948 module_exit(vmbus_exit);