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>
21 * 3/9/2011: K. Y. Srinivasan - Significant restructuring and cleanup
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/pci.h>
32 #include <linux/dmi.h>
33 #include <linux/slab.h>
34 #include <linux/completion.h>
35 #include "version_info.h"
40 #include "vmbus_private.h"
43 static struct pci_dev
*hv_pci_dev
;
45 static struct tasklet_struct msg_dpc
;
46 static struct tasklet_struct event_dpc
;
48 /* Main vmbus driver data structure */
53 unsigned int vmbus_loglevel
= (ALL_MODULES
<< 16 | INFO_LVL
);
54 EXPORT_SYMBOL(vmbus_loglevel
);
55 /* (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */
56 /* (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */
58 static int pci_probe_error
;
59 static struct completion probe_event
;
61 static void get_channel_info(struct hv_device
*device
,
62 struct hv_device_info
*info
)
64 struct vmbus_channel_debug_info debug_info
;
69 vmbus_get_debug_info(device
->channel
, &debug_info
);
71 info
->chn_id
= debug_info
.relid
;
72 info
->chn_state
= debug_info
.state
;
73 memcpy(&info
->chn_type
, &debug_info
.interfacetype
,
74 sizeof(struct hv_guid
));
75 memcpy(&info
->chn_instance
, &debug_info
.interface_instance
,
76 sizeof(struct hv_guid
));
78 info
->monitor_id
= debug_info
.monitorid
;
80 info
->server_monitor_pending
= debug_info
.servermonitor_pending
;
81 info
->server_monitor_latency
= debug_info
.servermonitor_latency
;
82 info
->server_monitor_conn_id
= debug_info
.servermonitor_connectionid
;
84 info
->client_monitor_pending
= debug_info
.clientmonitor_pending
;
85 info
->client_monitor_latency
= debug_info
.clientmonitor_latency
;
86 info
->client_monitor_conn_id
= debug_info
.clientmonitor_connectionid
;
88 info
->inbound
.int_mask
= debug_info
.inbound
.current_interrupt_mask
;
89 info
->inbound
.read_idx
= debug_info
.inbound
.current_read_index
;
90 info
->inbound
.write_idx
= debug_info
.inbound
.current_write_index
;
91 info
->inbound
.bytes_avail_toread
=
92 debug_info
.inbound
.bytes_avail_toread
;
93 info
->inbound
.bytes_avail_towrite
=
94 debug_info
.inbound
.bytes_avail_towrite
;
96 info
->outbound
.int_mask
=
97 debug_info
.outbound
.current_interrupt_mask
;
98 info
->outbound
.read_idx
= debug_info
.outbound
.current_read_index
;
99 info
->outbound
.write_idx
= debug_info
.outbound
.current_write_index
;
100 info
->outbound
.bytes_avail_toread
=
101 debug_info
.outbound
.bytes_avail_toread
;
102 info
->outbound
.bytes_avail_towrite
=
103 debug_info
.outbound
.bytes_avail_towrite
;
107 * vmbus_show_device_attr - Show the device attribute in sysfs.
109 * This is invoked when user does a
110 * "cat /sys/bus/vmbus/devices/<busdevice>/<attr name>"
112 static ssize_t
vmbus_show_device_attr(struct device
*dev
,
113 struct device_attribute
*dev_attr
,
116 struct hv_device
*device_ctx
= device_to_hv_device(dev
);
117 struct hv_device_info device_info
;
119 memset(&device_info
, 0, sizeof(struct hv_device_info
));
121 get_channel_info(device_ctx
, &device_info
);
123 if (!strcmp(dev_attr
->attr
.name
, "class_id")) {
124 return sprintf(buf
, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
125 "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
126 device_info
.chn_type
.data
[3],
127 device_info
.chn_type
.data
[2],
128 device_info
.chn_type
.data
[1],
129 device_info
.chn_type
.data
[0],
130 device_info
.chn_type
.data
[5],
131 device_info
.chn_type
.data
[4],
132 device_info
.chn_type
.data
[7],
133 device_info
.chn_type
.data
[6],
134 device_info
.chn_type
.data
[8],
135 device_info
.chn_type
.data
[9],
136 device_info
.chn_type
.data
[10],
137 device_info
.chn_type
.data
[11],
138 device_info
.chn_type
.data
[12],
139 device_info
.chn_type
.data
[13],
140 device_info
.chn_type
.data
[14],
141 device_info
.chn_type
.data
[15]);
142 } else if (!strcmp(dev_attr
->attr
.name
, "device_id")) {
143 return sprintf(buf
, "{%02x%02x%02x%02x-%02x%02x-%02x%02x-"
144 "%02x%02x%02x%02x%02x%02x%02x%02x}\n",
145 device_info
.chn_instance
.data
[3],
146 device_info
.chn_instance
.data
[2],
147 device_info
.chn_instance
.data
[1],
148 device_info
.chn_instance
.data
[0],
149 device_info
.chn_instance
.data
[5],
150 device_info
.chn_instance
.data
[4],
151 device_info
.chn_instance
.data
[7],
152 device_info
.chn_instance
.data
[6],
153 device_info
.chn_instance
.data
[8],
154 device_info
.chn_instance
.data
[9],
155 device_info
.chn_instance
.data
[10],
156 device_info
.chn_instance
.data
[11],
157 device_info
.chn_instance
.data
[12],
158 device_info
.chn_instance
.data
[13],
159 device_info
.chn_instance
.data
[14],
160 device_info
.chn_instance
.data
[15]);
161 } else if (!strcmp(dev_attr
->attr
.name
, "state")) {
162 return sprintf(buf
, "%d\n", device_info
.chn_state
);
163 } else if (!strcmp(dev_attr
->attr
.name
, "id")) {
164 return sprintf(buf
, "%d\n", device_info
.chn_id
);
165 } else if (!strcmp(dev_attr
->attr
.name
, "out_intr_mask")) {
166 return sprintf(buf
, "%d\n", device_info
.outbound
.int_mask
);
167 } else if (!strcmp(dev_attr
->attr
.name
, "out_read_index")) {
168 return sprintf(buf
, "%d\n", device_info
.outbound
.read_idx
);
169 } else if (!strcmp(dev_attr
->attr
.name
, "out_write_index")) {
170 return sprintf(buf
, "%d\n", device_info
.outbound
.write_idx
);
171 } else if (!strcmp(dev_attr
->attr
.name
, "out_read_bytes_avail")) {
172 return sprintf(buf
, "%d\n",
173 device_info
.outbound
.bytes_avail_toread
);
174 } else if (!strcmp(dev_attr
->attr
.name
, "out_write_bytes_avail")) {
175 return sprintf(buf
, "%d\n",
176 device_info
.outbound
.bytes_avail_towrite
);
177 } else if (!strcmp(dev_attr
->attr
.name
, "in_intr_mask")) {
178 return sprintf(buf
, "%d\n", device_info
.inbound
.int_mask
);
179 } else if (!strcmp(dev_attr
->attr
.name
, "in_read_index")) {
180 return sprintf(buf
, "%d\n", device_info
.inbound
.read_idx
);
181 } else if (!strcmp(dev_attr
->attr
.name
, "in_write_index")) {
182 return sprintf(buf
, "%d\n", device_info
.inbound
.write_idx
);
183 } else if (!strcmp(dev_attr
->attr
.name
, "in_read_bytes_avail")) {
184 return sprintf(buf
, "%d\n",
185 device_info
.inbound
.bytes_avail_toread
);
186 } else if (!strcmp(dev_attr
->attr
.name
, "in_write_bytes_avail")) {
187 return sprintf(buf
, "%d\n",
188 device_info
.inbound
.bytes_avail_towrite
);
189 } else if (!strcmp(dev_attr
->attr
.name
, "monitor_id")) {
190 return sprintf(buf
, "%d\n", device_info
.monitor_id
);
191 } else if (!strcmp(dev_attr
->attr
.name
, "server_monitor_pending")) {
192 return sprintf(buf
, "%d\n", device_info
.server_monitor_pending
);
193 } else if (!strcmp(dev_attr
->attr
.name
, "server_monitor_latency")) {
194 return sprintf(buf
, "%d\n", device_info
.server_monitor_latency
);
195 } else if (!strcmp(dev_attr
->attr
.name
, "server_monitor_conn_id")) {
196 return sprintf(buf
, "%d\n",
197 device_info
.server_monitor_conn_id
);
198 } else if (!strcmp(dev_attr
->attr
.name
, "client_monitor_pending")) {
199 return sprintf(buf
, "%d\n", device_info
.client_monitor_pending
);
200 } else if (!strcmp(dev_attr
->attr
.name
, "client_monitor_latency")) {
201 return sprintf(buf
, "%d\n", device_info
.client_monitor_latency
);
202 } else if (!strcmp(dev_attr
->attr
.name
, "client_monitor_conn_id")) {
203 return sprintf(buf
, "%d\n",
204 device_info
.client_monitor_conn_id
);
210 /* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
211 static struct device_attribute vmbus_device_attrs
[] = {
212 __ATTR(id
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
213 __ATTR(state
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
214 __ATTR(class_id
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
215 __ATTR(device_id
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
216 __ATTR(monitor_id
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
218 __ATTR(server_monitor_pending
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
219 __ATTR(server_monitor_latency
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
220 __ATTR(server_monitor_conn_id
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
222 __ATTR(client_monitor_pending
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
223 __ATTR(client_monitor_latency
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
224 __ATTR(client_monitor_conn_id
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
226 __ATTR(out_intr_mask
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
227 __ATTR(out_read_index
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
228 __ATTR(out_write_index
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
229 __ATTR(out_read_bytes_avail
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
230 __ATTR(out_write_bytes_avail
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
232 __ATTR(in_intr_mask
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
233 __ATTR(in_read_index
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
234 __ATTR(in_write_index
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
235 __ATTR(in_read_bytes_avail
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
236 __ATTR(in_write_bytes_avail
, S_IRUGO
, vmbus_show_device_attr
, NULL
),
242 * vmbus_uevent - add uevent for our device
244 * This routine is invoked when a device is added or removed on the vmbus to
245 * generate a uevent to udev in the userspace. The udev will then look at its
246 * rule and the uevent generated here to load the appropriate driver
248 static int vmbus_uevent(struct device
*device
, struct kobj_uevent_env
*env
)
250 struct hv_device
*dev
= device_to_hv_device(device
);
253 ret
= add_uevent_var(env
, "VMBUS_DEVICE_CLASS_GUID={"
254 "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
255 "%02x%02x%02x%02x%02x%02x%02x%02x}",
256 dev
->dev_type
.data
[3],
257 dev
->dev_type
.data
[2],
258 dev
->dev_type
.data
[1],
259 dev
->dev_type
.data
[0],
260 dev
->dev_type
.data
[5],
261 dev
->dev_type
.data
[4],
262 dev
->dev_type
.data
[7],
263 dev
->dev_type
.data
[6],
264 dev
->dev_type
.data
[8],
265 dev
->dev_type
.data
[9],
266 dev
->dev_type
.data
[10],
267 dev
->dev_type
.data
[11],
268 dev
->dev_type
.data
[12],
269 dev
->dev_type
.data
[13],
270 dev
->dev_type
.data
[14],
271 dev
->dev_type
.data
[15]);
276 ret
= add_uevent_var(env
, "VMBUS_DEVICE_DEVICE_GUID={"
277 "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
278 "%02x%02x%02x%02x%02x%02x%02x%02x}",
279 dev
->dev_instance
.data
[3],
280 dev
->dev_instance
.data
[2],
281 dev
->dev_instance
.data
[1],
282 dev
->dev_instance
.data
[0],
283 dev
->dev_instance
.data
[5],
284 dev
->dev_instance
.data
[4],
285 dev
->dev_instance
.data
[7],
286 dev
->dev_instance
.data
[6],
287 dev
->dev_instance
.data
[8],
288 dev
->dev_instance
.data
[9],
289 dev
->dev_instance
.data
[10],
290 dev
->dev_instance
.data
[11],
291 dev
->dev_instance
.data
[12],
292 dev
->dev_instance
.data
[13],
293 dev
->dev_instance
.data
[14],
294 dev
->dev_instance
.data
[15]);
303 * vmbus_match - Attempt to match the specified device to the specified driver
305 static int vmbus_match(struct device
*device
, struct device_driver
*driver
)
308 struct hv_driver
*drv
= drv_to_hv_drv(driver
);
309 struct hv_device
*device_ctx
= device_to_hv_device(device
);
311 /* We found our driver ? */
312 if (memcmp(&device_ctx
->dev_type
, &drv
->dev_type
,
313 sizeof(struct hv_guid
)) == 0)
320 * vmbus_probe - Add the new vmbus's child device
322 static int vmbus_probe(struct device
*child_device
)
325 struct hv_driver
*drv
=
326 drv_to_hv_drv(child_device
->driver
);
328 /* Let the specific open-source driver handles the probe if it can */
329 if (drv
->driver
.probe
) {
330 ret
= drv
->driver
.probe(child_device
);
332 pr_err("probe failed for device %s (%d)\n",
333 dev_name(child_device
), ret
);
336 pr_err("probe not set for driver %s\n",
337 dev_name(child_device
));
344 * vmbus_remove - Remove a vmbus device
346 static int vmbus_remove(struct device
*child_device
)
349 struct hv_driver
*drv
;
352 if (child_device
->driver
) {
353 drv
= drv_to_hv_drv(child_device
->driver
);
356 * Let the specific open-source driver handles the removal if
359 if (drv
->driver
.remove
) {
360 ret
= drv
->driver
.remove(child_device
);
362 pr_err("remove not set for driver %s\n",
363 dev_name(child_device
));
373 * vmbus_shutdown - Shutdown a vmbus device
375 static void vmbus_shutdown(struct device
*child_device
)
377 struct hv_driver
*drv
;
380 /* The device may not be attached yet */
381 if (!child_device
->driver
)
384 drv
= drv_to_hv_drv(child_device
->driver
);
386 /* Let the specific open-source driver handles the removal if it can */
387 if (drv
->driver
.shutdown
)
388 drv
->driver
.shutdown(child_device
);
395 * vmbus_device_release - Final callback release of the vmbus child device
397 static void vmbus_device_release(struct device
*device
)
399 struct hv_device
*device_ctx
= device_to_hv_device(device
);
405 /* The one and only one */
406 static struct hv_bus hv_bus
= {
408 .bus
.match
= vmbus_match
,
409 .bus
.shutdown
= vmbus_shutdown
,
410 .bus
.remove
= vmbus_remove
,
411 .bus
.probe
= vmbus_probe
,
412 .bus
.uevent
= vmbus_uevent
,
413 .bus
.dev_attrs
= vmbus_device_attrs
,
416 static const char *driver_name
= "hyperv";
419 struct onmessage_work_context
{
420 struct work_struct work
;
421 struct hv_message msg
;
424 static void vmbus_onmessage_work(struct work_struct
*work
)
426 struct onmessage_work_context
*ctx
;
428 ctx
= container_of(work
, struct onmessage_work_context
,
430 vmbus_onmessage(&ctx
->msg
);
435 * vmbus_on_msg_dpc - DPC routine to handle messages from the hypervisior
437 static void vmbus_on_msg_dpc(unsigned long data
)
439 int cpu
= smp_processor_id();
440 void *page_addr
= hv_context
.synic_message_page
[cpu
];
441 struct hv_message
*msg
= (struct hv_message
*)page_addr
+
443 struct onmessage_work_context
*ctx
;
446 if (msg
->header
.message_type
== HVMSG_NONE
) {
450 ctx
= kmalloc(sizeof(*ctx
), GFP_ATOMIC
);
453 INIT_WORK(&ctx
->work
, vmbus_onmessage_work
);
454 memcpy(&ctx
->msg
, msg
, sizeof(*msg
));
455 queue_work(vmbus_connection
.work_queue
, &ctx
->work
);
458 msg
->header
.message_type
= HVMSG_NONE
;
461 * Make sure the write to MessageType (ie set to
462 * HVMSG_NONE) happens before we read the
463 * MessagePending and EOMing. Otherwise, the EOMing
464 * will not deliver any more messages since there is
469 if (msg
->header
.message_flags
.msg_pending
) {
471 * This will cause message queue rescan to
472 * possibly deliver another msg from the
475 wrmsrl(HV_X64_MSR_EOM
, 0);
481 * vmbus_on_isr - ISR routine
483 static int vmbus_on_isr(void)
486 int cpu
= smp_processor_id();
488 struct hv_message
*msg
;
489 union hv_synic_event_flags
*event
;
491 page_addr
= hv_context
.synic_message_page
[cpu
];
492 msg
= (struct hv_message
*)page_addr
+ VMBUS_MESSAGE_SINT
;
494 /* Check if there are actual msgs to be process */
495 if (msg
->header
.message_type
!= HVMSG_NONE
)
498 /* TODO: Check if there are events to be process */
499 page_addr
= hv_context
.synic_event_page
[cpu
];
500 event
= (union hv_synic_event_flags
*)page_addr
+ VMBUS_MESSAGE_SINT
;
502 /* Since we are a child, we only need to check bit 0 */
503 if (sync_test_and_clear_bit(0, (unsigned long *) &event
->flags32
[0]))
510 static irqreturn_t
vmbus_isr(int irq
, void *dev_id
)
514 ret
= vmbus_on_isr();
516 /* Schedules a dpc if necessary */
518 if (test_bit(0, (unsigned long *)&ret
))
519 tasklet_schedule(&msg_dpc
);
521 if (test_bit(1, (unsigned long *)&ret
))
522 tasklet_schedule(&event_dpc
);
531 * vmbus_bus_init -Main vmbus driver initialization routine.
534 * - initialize the vmbus driver context
535 * - invoke the vmbus hv main init routine
536 * - get the irq resource
537 * - retrieve the channel offers
539 static int vmbus_bus_init(struct pci_dev
*pdev
)
544 /* Hypervisor initialization...setup hypercall page..etc */
547 pr_err("Unable to initialize the hypervisor - 0x%x\n", ret
);
551 hv_bus
.bus
.name
= driver_name
;
553 /* Initialize the bus context */
554 tasklet_init(&msg_dpc
, vmbus_on_msg_dpc
, 0);
555 tasklet_init(&event_dpc
, vmbus_on_event
, 0);
557 /* Now, register the bus with LDM */
558 ret
= bus_register(&hv_bus
.bus
);
564 /* Get the interrupt resource */
565 ret
= request_irq(pdev
->irq
, vmbus_isr
,
566 IRQF_SHARED
| IRQF_SAMPLE_RANDOM
,
570 pr_err("Unable to request IRQ %d\n",
573 bus_unregister(&hv_bus
.bus
);
579 vector
= IRQ0_VECTOR
+ pdev
->irq
;
582 * Notify the hypervisor of our irq and
583 * connect to the host.
585 on_each_cpu(hv_synic_init
, (void *)&vector
, 1);
586 ret
= vmbus_connect();
588 free_irq(pdev
->irq
, pdev
);
589 bus_unregister(&hv_bus
.bus
);
594 vmbus_request_offers();
595 wait_for_completion(&hv_channel_ready
);
602 * vmbus_child_driver_register() - Register a vmbus's child driver
603 * @drv: Pointer to driver structure you want to register
606 * Registers the given driver with Linux through the 'driver_register()' call
607 * And sets up the hyper-v vmbus handling for this driver.
608 * It will return the state of the 'driver_register()' call.
610 * Mainly used by Hyper-V drivers.
612 int vmbus_child_driver_register(struct device_driver
*drv
)
616 pr_info("child driver registering - name %s\n", drv
->name
);
618 /* The child driver on this vmbus */
619 drv
->bus
= &hv_bus
.bus
;
621 ret
= driver_register(drv
);
623 vmbus_request_offers();
627 EXPORT_SYMBOL(vmbus_child_driver_register
);
630 * vmbus_child_driver_unregister() - Unregister a vmbus's child driver
631 * @drv: Pointer to driver structure you want to un-register
634 * Un-register the given driver with Linux through the 'driver_unregister()'
635 * call. And ungegisters the driver from the Hyper-V vmbus handler.
637 * Mainly used by Hyper-V drivers.
639 void vmbus_child_driver_unregister(struct device_driver
*drv
)
641 pr_info("child driver unregistering - name %s\n", drv
->name
);
643 driver_unregister(drv
);
647 EXPORT_SYMBOL(vmbus_child_driver_unregister
);
650 * vmbus_child_device_create - Creates and registers a new child device
653 struct hv_device
*vmbus_child_device_create(struct hv_guid
*type
,
654 struct hv_guid
*instance
,
655 struct vmbus_channel
*channel
)
657 struct hv_device
*child_device_obj
;
659 /* Allocate the new child device */
660 child_device_obj
= kzalloc(sizeof(struct hv_device
), GFP_KERNEL
);
661 if (!child_device_obj
) {
662 pr_err("Unable to allocate device object for child device\n");
666 child_device_obj
->channel
= channel
;
667 memcpy(&child_device_obj
->dev_type
, type
, sizeof(struct hv_guid
));
668 memcpy(&child_device_obj
->dev_instance
, instance
,
669 sizeof(struct hv_guid
));
672 return child_device_obj
;
676 * vmbus_child_device_register - Register the child device
678 int vmbus_child_device_register(struct hv_device
*child_device_obj
)
682 static atomic_t device_num
= ATOMIC_INIT(0);
684 /* Set the device name. Otherwise, device_register() will fail. */
685 dev_set_name(&child_device_obj
->device
, "vmbus_0_%d",
686 atomic_inc_return(&device_num
));
688 /* The new device belongs to this bus */
689 child_device_obj
->device
.bus
= &hv_bus
.bus
; /* device->dev.bus; */
690 child_device_obj
->device
.parent
= &hv_pci_dev
->dev
;
691 child_device_obj
->device
.release
= vmbus_device_release
;
694 * Register with the LDM. This will kick off the driver/device
695 * binding...which will eventually call vmbus_match() and vmbus_probe()
697 ret
= device_register(&child_device_obj
->device
);
700 pr_err("Unable to register child device\n");
702 pr_info("child device %s registered\n",
703 dev_name(&child_device_obj
->device
));
709 * vmbus_child_device_unregister - Remove the specified child device
712 void vmbus_child_device_unregister(struct hv_device
*device_obj
)
715 * Kick off the process of unregistering the device.
716 * This will call vmbus_remove() and eventually vmbus_device_release()
718 device_unregister(&device_obj
->device
);
720 pr_info("child device %s unregistered\n",
721 dev_name(&device_obj
->device
));
725 static int __devinit
hv_pci_probe(struct pci_dev
*pdev
,
726 const struct pci_device_id
*ent
)
730 pci_probe_error
= pci_enable_device(pdev
);
734 pci_probe_error
= vmbus_bus_init(pdev
);
736 pci_disable_device(pdev
);
739 complete(&probe_event
);
740 return pci_probe_error
;
744 * We use a PCI table to determine if we should autoload this driver This is
745 * needed by distro tools to determine if the hyperv drivers should be
746 * installed and/or configured. We don't do anything else with the table, but
747 * it needs to be present.
749 static const struct pci_device_id microsoft_hv_pci_table
[] = {
750 { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
753 MODULE_DEVICE_TABLE(pci
, microsoft_hv_pci_table
);
755 static struct pci_driver hv_bus_driver
= {
757 .probe
= hv_pci_probe
,
758 .id_table
= microsoft_hv_pci_table
,
761 static int __init
hv_pci_init(void)
764 init_completion(&probe_event
);
765 ret
= pci_register_driver(&hv_bus_driver
);
769 * All the vmbus initialization occurs within the
770 * hv_pci_probe() function. Wait for hv_pci_probe()
773 wait_for_completion(&probe_event
);
776 pci_unregister_driver(&hv_bus_driver
);
777 return pci_probe_error
;
781 MODULE_LICENSE("GPL");
782 MODULE_VERSION(HV_DRV_VERSION
);
783 module_param(vmbus_loglevel
, int, S_IRUGO
|S_IWUSR
);
785 module_init(hv_pci_init
);