From 65e65a3e73b31c097e59c6e8d4a9ed1eebbe9d8d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 8 Jan 2010 10:20:27 -0800 Subject: Staging: hv: remove unneeded OnHostRescan callback This callback was never called, so delete the thing. Cc: Hank Janssen Cc: Haiyang Zhang . Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/StorVscApi.h | 3 --- drivers/staging/hv/storvsc_drv.c | 1 - 2 files changed, 4 deletions(-) (limited to 'drivers/staging/hv') diff --git a/drivers/staging/hv/StorVscApi.h b/drivers/staging/hv/StorVscApi.h index 69c1406..1aca24e 100644 --- a/drivers/staging/hv/StorVscApi.h +++ b/drivers/staging/hv/StorVscApi.h @@ -91,9 +91,6 @@ struct storvsc_driver_object { /* Maximum # of requests in flight per channel/device */ u32 MaxOutstandingRequestsPerChannel; - /* Set by the caller to allow us to re-enumerate the bus on the host */ - void (*OnHostRescan)(struct hv_device *Device); - /* Specific to this driver */ int (*OnIORequest)(struct hv_device *Device, struct hv_storvsc_request *Request); diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index d49dc21..c383962 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -148,7 +148,6 @@ static int storvsc_drv_init(int (*drv_init)(struct hv_driver *drv)) vmbus_get_interface(&storvsc_drv_obj->Base.VmbusChannelInterface); storvsc_drv_obj->RingBufferSize = storvsc_ringbuffer_size; - storvsc_drv_obj->OnHostRescan = storvsc_host_rescan; /* Callback to client driver to complete the initialization */ drv_init(&storvsc_drv_obj->Base); -- cgit v1.1 From 99358ca725513de0a97971eb019d4a5544d83760 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 8 Jan 2010 10:21:58 -0800 Subject: Staging: hv: storvsc_drv: move unused functions Now that the callback pointer was removed, we can remove the code itself, as it is never used. Cc: Hank Janssen Cc: Haiyang Zhang . Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/storvsc_drv.c | 204 --------------------------------------- 1 file changed, 204 deletions(-) (limited to 'drivers/staging/hv') diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index c383962..56c911e 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -39,8 +39,6 @@ struct host_device_context { /* must be 1st field * FIXME this is a bug */ - struct work_struct host_rescan_work; - /* point back to our device context */ struct device_context *device_ctx; struct kmem_cache *request_pool; @@ -77,8 +75,6 @@ static int storvsc_queuecommand(struct scsi_cmnd *scmnd, static int storvsc_device_alloc(struct scsi_device *); static int storvsc_device_configure(struct scsi_device *); static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd); -static void storvsc_host_rescan_callback(struct work_struct *work); -static void storvsc_host_rescan(struct hv_device *device_obj); static int storvsc_remove(struct device *dev); static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl, @@ -94,8 +90,6 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl, struct scatterlist *bounce_sgl, unsigned int orig_sgl_count); -static int storvsc_report_luns(struct scsi_device *sdev, unsigned int luns[], - unsigned int *lun_count); static int storvsc_get_chs(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int *info); @@ -265,9 +259,6 @@ static int storvsc_probe(struct device *device) host_device_ctx->port = host->host_no; host_device_ctx->device_ctx = device_ctx; - INIT_WORK(&host_device_ctx->host_rescan_work, - storvsc_host_rescan_callback); - host_device_ctx->request_pool = kmem_cache_create(dev_name(&device_ctx->device), sizeof(struct storvsc_cmd_request) + @@ -908,201 +899,6 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd) return ret; } -/** - * storvsc_host_rescan - Rescan the scsi HBA - */ -static void storvsc_host_rescan_callback(struct work_struct *work) -{ - struct hv_device *device_obj = - &((struct host_device_context *)work)->device_ctx->device_obj; - struct device_context *device_ctx = to_device_context(device_obj); - struct Scsi_Host *host = dev_get_drvdata(&device_ctx->device); - struct scsi_device *sdev; - struct host_device_context *host_device_ctx; - struct scsi_device **sdevs_remove_list; - unsigned int sdevs_count = 0; - unsigned int found; - unsigned int i; - unsigned int lun_count = 0; - unsigned int *lun_list; - - DPRINT_ENTER(STORVSC_DRV); - - host_device_ctx = (struct host_device_context *)host->hostdata; - lun_list = kcalloc(STORVSC_MAX_LUNS_PER_TARGET, sizeof(unsigned int), - GFP_ATOMIC); - if (!lun_list) { - DPRINT_ERR(STORVSC_DRV, "unable to allocate lun list"); - return; - } - - sdevs_remove_list = kcalloc(STORVSC_MAX_LUNS_PER_TARGET, - sizeof(void *), GFP_ATOMIC); - if (!sdevs_remove_list) { - kfree(lun_list); - DPRINT_ERR(STORVSC_DRV, "unable to allocate lun remove list"); - return; - } - - DPRINT_INFO(STORVSC_DRV, "rescanning host for new scsi devices..."); - - /* Rescan for new device */ - scsi_scan_target(&host->shost_gendev, host_device_ctx->path, - host_device_ctx->target, SCAN_WILD_CARD, 1); - - DPRINT_INFO(STORVSC_DRV, "rescanning host for removed scsi device..."); - - /* Use the 1st device to send the report luns cmd */ - shost_for_each_device(sdev, host) { - lun_count = STORVSC_MAX_LUNS_PER_TARGET; - storvsc_report_luns(sdev, lun_list, &lun_count); - - DPRINT_INFO(STORVSC_DRV, - "report luns on scsi device (%p) found %u luns ", - sdev, lun_count); - DPRINT_INFO(STORVSC_DRV, - "existing luns on scsi device (%p) host (%d)", - sdev, host->host_no); - - scsi_device_put(sdev); - break; - } - - for (i = 0; i < lun_count; i++) - DPRINT_INFO(STORVSC_DRV, "%d) lun %u", i, lun_list[i]); - - /* Rescan for devices that may have been removed. - * We do not have to worry that new devices may have been added since - * this callback is serialized by the workqueue ie add/remove are done - * here. - */ - shost_for_each_device(sdev, host) { - /* See if this device is still here */ - found = 0; - for (i = 0; i < lun_count; i++) { - if (sdev->lun == lun_list[i]) { - found = 1; - break; - } - } - if (!found) { - DPRINT_INFO(STORVSC_DRV, "lun (%u) does not exists", - sdev->lun); - sdevs_remove_list[sdevs_count++] = sdev; - } - } - - /* Now remove the devices */ - for (i = 0; i < sdevs_count; i++) { - DPRINT_INFO(STORVSC_DRV, - "removing scsi device (%p) lun (%u)...", - sdevs_remove_list[i], sdevs_remove_list[i]->lun); - - /* make sure it is not removed from underneath us */ - if (!scsi_device_get(sdevs_remove_list[i])) { - scsi_remove_device(sdevs_remove_list[i]); - scsi_device_put(sdevs_remove_list[i]); - } - } - - DPRINT_INFO(STORVSC_DRV, "rescan completed on dev obj (%p) " - "target (%u) bus (%u)", device_obj, - host_device_ctx->target, host_device_ctx->path); - - kfree(lun_list); - kfree(sdevs_remove_list); - - DPRINT_EXIT(STORVSC_DRV); -} - -static int storvsc_report_luns(struct scsi_device *sdev, unsigned int luns[], - unsigned int *lun_count) -{ - int i, j; - unsigned int lun = 0; - unsigned int num_luns; - int result; - unsigned char *data; - struct scsi_sense_hdr sshdr; - unsigned char cmd[16] = {0}; - /* Add 1 to cover the report_lun header */ - unsigned int report_len = 8 * (STORVSC_MAX_LUNS_PER_TARGET+1); - unsigned long long *report_luns; - const unsigned int in_lun_count = *lun_count; - - *lun_count = 0; - - report_luns = kzalloc(report_len, GFP_ATOMIC); - if (!report_luns) - return -ENOMEM; - - cmd[0] = REPORT_LUNS; - - /* cmd length */ - *(unsigned int *)&cmd[6] = cpu_to_be32(report_len); - - result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, - (unsigned char *)report_luns, report_len, - &sshdr, 30 * HZ, 3, NULL); - if (result != 0) { - kfree(report_luns); - return -EBUSY; - } - - /* get the length from the first four bytes */ - report_len = be32_to_cpu(*(unsigned int *)&report_luns[0]); - - num_luns = (report_len / sizeof(unsigned long long)); - if (num_luns > in_lun_count) { - kfree(report_luns); - return -EINVAL; - } - - *lun_count = num_luns; - - DPRINT_DBG(STORVSC_DRV, - "report luns on scsi device (%p) found %u luns ", - sdev, num_luns); - - /* lun id starts at 1 */ - for (i = 1; i < num_luns + 1; i++) { - lun = 0; - data = (unsigned char *)&report_luns[i]; - for (j = 0; j < sizeof(lun); j += 2) { - lun = lun | (((data[j] << 8) | data[j + 1]) << - (j * 8)); - } - - luns[i-1] = lun; - } - - kfree(report_luns); - return 0; -} - -static void storvsc_host_rescan(struct hv_device *device_obj) -{ - struct device_context *device_ctx = to_device_context(device_obj); - struct Scsi_Host *host = dev_get_drvdata(&device_ctx->device); - struct host_device_context *host_device_ctx; - - DPRINT_ENTER(STORVSC_DRV); - - host_device_ctx = (struct host_device_context *)host->hostdata; - - DPRINT_INFO(STORVSC_DRV, "initiating rescan on dev obj (%p) " - "target (%u) bus (%u)...", device_obj, - host_device_ctx->target, host_device_ctx->path); - - /* - * We need to queue this since the scanning may block and the caller - * may be in an intr context - */ - /* scsi_queue_work(host, &host_device_ctx->host_rescan_work); */ - schedule_work(&host_device_ctx->host_rescan_work); - DPRINT_EXIT(STORVSC_DRV); -} - static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev, sector_t capacity, int *info) { -- cgit v1.1 From 354b0a643e89dd3163278c9a0ac9cbcb9ef5c298 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 8 Jan 2010 10:24:26 -0800 Subject: Staging: hv: remove unneeded OnHostReset callback This callback only calls one function, so just call the function instead, no need for indirection at all. Cc: Hank Janssen Cc: Haiyang Zhang . Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/StorVsc.c | 3 +-- drivers/staging/hv/StorVscApi.h | 2 +- drivers/staging/hv/storvsc_drv.c | 10 +--------- 3 files changed, 3 insertions(+), 12 deletions(-) (limited to 'drivers/staging/hv') diff --git a/drivers/staging/hv/StorVsc.c b/drivers/staging/hv/StorVsc.c index 2f7c425..38ea140 100644 --- a/drivers/staging/hv/StorVsc.c +++ b/drivers/staging/hv/StorVsc.c @@ -625,7 +625,7 @@ static int StorVscOnDeviceRemove(struct hv_device *Device) return 0; } -static int StorVscOnHostReset(struct hv_device *Device) +int StorVscOnHostReset(struct hv_device *Device) { struct storvsc_device *storDevice; struct storvsc_request_extension *request; @@ -842,7 +842,6 @@ int StorVscInitialize(struct hv_driver *Driver) storDriver->Base.OnCleanup = StorVscOnCleanup; storDriver->OnIORequest = StorVscOnIORequest; - storDriver->OnHostReset = StorVscOnHostReset; DPRINT_EXIT(STORVSC); diff --git a/drivers/staging/hv/StorVscApi.h b/drivers/staging/hv/StorVscApi.h index 1aca24e..126a858 100644 --- a/drivers/staging/hv/StorVscApi.h +++ b/drivers/staging/hv/StorVscApi.h @@ -94,7 +94,6 @@ struct storvsc_driver_object { /* Specific to this driver */ int (*OnIORequest)(struct hv_device *Device, struct hv_storvsc_request *Request); - int (*OnHostReset)(struct hv_device *Device); }; struct storvsc_device_info { @@ -105,6 +104,7 @@ struct storvsc_device_info { /* Interface */ int StorVscInitialize(struct hv_driver *driver); +int StorVscOnHostReset(struct hv_device *Device); int BlkVscInitialize(struct hv_driver *driver); #endif /* _STORVSC_API_H_ */ diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 56c911e..12f8f3f 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -870,13 +870,6 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd) struct host_device_context *host_device_ctx = (struct host_device_context *)scmnd->device->host->hostdata; struct device_context *device_ctx = host_device_ctx->device_ctx; - struct driver_context *driver_ctx = - driver_to_driver_context(device_ctx->device.driver); - struct storvsc_driver_context *storvsc_drv_ctx = - (struct storvsc_driver_context *)driver_ctx; - - struct storvsc_driver_object *storvsc_drv_obj = - &storvsc_drv_ctx->drv_obj; DPRINT_ENTER(STORVSC_DRV); @@ -884,8 +877,7 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd) scmnd->device, &device_ctx->device_obj); /* Invokes the vsc to reset the host/bus */ - ASSERT(storvsc_drv_obj->OnHostReset); - ret = storvsc_drv_obj->OnHostReset(&device_ctx->device_obj); + ret = StorVscOnHostReset(&device_ctx->device_obj); if (ret != 0) { DPRINT_EXIT(STORVSC_DRV); return ret; -- cgit v1.1 From 2d0753464b497287565c2e54d3ae67666852ef57 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 8 Jan 2010 10:24:42 -0800 Subject: Staging: hv: remove unneeded OnOpen callback This callback only calls one function, so just call the function instead, no need for indirection at all. Cc: Hank Janssen Cc: Haiyang Zhang . Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/NetVscApi.h | 2 +- drivers/staging/hv/RndisFilter.c | 5 +---- drivers/staging/hv/netvsc_drv.c | 7 +------ 3 files changed, 3 insertions(+), 11 deletions(-) (limited to 'drivers/staging/hv') diff --git a/drivers/staging/hv/NetVscApi.h b/drivers/staging/hv/NetVscApi.h index 1ce2b74..93b9226 100644 --- a/drivers/staging/hv/NetVscApi.h +++ b/drivers/staging/hv/NetVscApi.h @@ -105,7 +105,6 @@ struct netvsc_driver { void (*OnLinkStatusChanged)(struct hv_device *dev, u32 Status); /* Specific to this driver */ - int (*OnOpen)(struct hv_device *dev); int (*OnClose)(struct hv_device *dev); int (*OnSend)(struct hv_device *dev, struct hv_netvsc_packet *packet); @@ -119,5 +118,6 @@ struct netvsc_device_info { /* Interface */ int NetVscInitialize(struct hv_driver *drv); +int RndisFilterOnOpen(struct hv_device *Device); #endif /* _NETVSC_API_H_ */ diff --git a/drivers/staging/hv/RndisFilter.c b/drivers/staging/hv/RndisFilter.c index 26d7997..74f741e 100644 --- a/drivers/staging/hv/RndisFilter.c +++ b/drivers/staging/hv/RndisFilter.c @@ -85,8 +85,6 @@ static int RndisFilterOnDeviceRemove(struct hv_device *Device); static void RndisFilterOnCleanup(struct hv_driver *Driver); -static int RndisFilterOnOpen(struct hv_device *Device); - static int RndisFilterOnClose(struct hv_device *Device); static int RndisFilterOnSend(struct hv_device *Device, @@ -654,7 +652,6 @@ int RndisFilterInit(struct netvsc_driver *Driver) Driver->Base.OnDeviceRemove = RndisFilterOnDeviceRemove; Driver->Base.OnCleanup = RndisFilterOnCleanup; Driver->OnSend = RndisFilterOnSend; - Driver->OnOpen = RndisFilterOnOpen; Driver->OnClose = RndisFilterOnClose; /* Driver->QueryLinkStatus = RndisFilterQueryDeviceLinkStatus; */ Driver->OnReceiveCallback = RndisFilterOnReceive; @@ -888,7 +885,7 @@ static void RndisFilterOnCleanup(struct hv_driver *Driver) DPRINT_EXIT(NETVSC); } -static int RndisFilterOnOpen(struct hv_device *Device) +int RndisFilterOnOpen(struct hv_device *Device) { int ret; struct netvsc_device *netDevice = Device->Extension; diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 0d7459e..515cd23 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -72,11 +72,6 @@ static void netvsc_set_multicast_list(struct net_device *net) static int netvsc_open(struct net_device *net) { struct net_device_context *net_device_ctx = netdev_priv(net); - struct driver_context *driver_ctx = - driver_to_driver_context(net_device_ctx->device_ctx->device.driver); - struct netvsc_driver_context *net_drv_ctx = - (struct netvsc_driver_context *)driver_ctx; - struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj; struct hv_device *device_obj = &net_device_ctx->device_ctx->device_obj; int ret = 0; @@ -87,7 +82,7 @@ static int netvsc_open(struct net_device *net) sizeof(struct net_device_stats)); /* Open up the device */ - ret = net_drv_obj->OnOpen(device_obj); + ret = RndisFilterOnOpen(device_obj); if (ret != 0) { DPRINT_ERR(NETVSC_DRV, "unable to open device (ret %d).", ret); -- cgit v1.1 From 4f28900bcf9bb5e6fb0c18fc7ee325df66fe8bbd Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 8 Jan 2010 10:25:01 -0800 Subject: Staging: hv: remove unneeded OnClose callback This callback only calls one function, so just call the function instead, no need for indirection at all. Cc: Hank Janssen Cc: Haiyang Zhang . Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/NetVscApi.h | 2 +- drivers/staging/hv/RndisFilter.c | 5 +---- drivers/staging/hv/netvsc_drv.c | 7 +------ 3 files changed, 3 insertions(+), 11 deletions(-) (limited to 'drivers/staging/hv') diff --git a/drivers/staging/hv/NetVscApi.h b/drivers/staging/hv/NetVscApi.h index 93b9226..95d7a32 100644 --- a/drivers/staging/hv/NetVscApi.h +++ b/drivers/staging/hv/NetVscApi.h @@ -105,7 +105,6 @@ struct netvsc_driver { void (*OnLinkStatusChanged)(struct hv_device *dev, u32 Status); /* Specific to this driver */ - int (*OnClose)(struct hv_device *dev); int (*OnSend)(struct hv_device *dev, struct hv_netvsc_packet *packet); void *Context; @@ -119,5 +118,6 @@ struct netvsc_device_info { /* Interface */ int NetVscInitialize(struct hv_driver *drv); int RndisFilterOnOpen(struct hv_device *Device); +int RndisFilterOnClose(struct hv_device *Device); #endif /* _NETVSC_API_H_ */ diff --git a/drivers/staging/hv/RndisFilter.c b/drivers/staging/hv/RndisFilter.c index 74f741e..1ab7fa9 100644 --- a/drivers/staging/hv/RndisFilter.c +++ b/drivers/staging/hv/RndisFilter.c @@ -85,8 +85,6 @@ static int RndisFilterOnDeviceRemove(struct hv_device *Device); static void RndisFilterOnCleanup(struct hv_driver *Driver); -static int RndisFilterOnClose(struct hv_device *Device); - static int RndisFilterOnSend(struct hv_device *Device, struct hv_netvsc_packet *Packet); @@ -652,7 +650,6 @@ int RndisFilterInit(struct netvsc_driver *Driver) Driver->Base.OnDeviceRemove = RndisFilterOnDeviceRemove; Driver->Base.OnCleanup = RndisFilterOnCleanup; Driver->OnSend = RndisFilterOnSend; - Driver->OnClose = RndisFilterOnClose; /* Driver->QueryLinkStatus = RndisFilterQueryDeviceLinkStatus; */ Driver->OnReceiveCallback = RndisFilterOnReceive; @@ -900,7 +897,7 @@ int RndisFilterOnOpen(struct hv_device *Device) return ret; } -static int RndisFilterOnClose(struct hv_device *Device) +int RndisFilterOnClose(struct hv_device *Device) { int ret; struct netvsc_device *netDevice = Device->Extension; diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 515cd23..3234a7c 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -101,11 +101,6 @@ static int netvsc_open(struct net_device *net) static int netvsc_close(struct net_device *net) { struct net_device_context *net_device_ctx = netdev_priv(net); - struct driver_context *driver_ctx = - driver_to_driver_context(net_device_ctx->device_ctx->device.driver); - struct netvsc_driver_context *net_drv_ctx = - (struct netvsc_driver_context *)driver_ctx; - struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj; struct hv_device *device_obj = &net_device_ctx->device_ctx->device_obj; int ret; @@ -113,7 +108,7 @@ static int netvsc_close(struct net_device *net) netif_stop_queue(net); - ret = net_drv_obj->OnClose(device_obj); + ret = RndisFilterOnClose(device_obj); if (ret != 0) DPRINT_ERR(NETVSC_DRV, "unable to close device (ret %d).", ret); -- cgit v1.1 From a73e6b7c508f610eeb315c443d9ac79041124af0 Mon Sep 17 00:00:00 2001 From: Hank Janssen Date: Fri, 22 Jan 2010 19:17:50 +0000 Subject: Staging: hv: Remove xen legacy code and check for Hyper-V Removed legacy XEN layer from hypervisor setup, and made sure only Hyper-V is Is a valid hypervisor to run on. Signed-off-by: Hank Janssen Cc: Haiyang Zhang . Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/Hv.c | 205 +++++++++++++++++++----------------------------- drivers/staging/hv/Hv.h | 10 +-- 2 files changed, 84 insertions(+), 131 deletions(-) (limited to 'drivers/staging/hv') diff --git a/drivers/staging/hv/Hv.c b/drivers/staging/hv/Hv.c index c2809f2..51149e6 100644 --- a/drivers/staging/hv/Hv.c +++ b/drivers/staging/hv/Hv.c @@ -208,50 +208,51 @@ int HvInit(void) /* HvQueryHypervisorFeatures(maxLeaf); */ /* - * Determine if we are running on xenlinux (ie x2v shim) or native - * linux + * We only support running on top of Hyper-V */ rdmsrl(HV_X64_MSR_GUEST_OS_ID, gHvContext.GuestId); - if (gHvContext.GuestId == 0) { - /* Write our OS info */ - wrmsrl(HV_X64_MSR_GUEST_OS_ID, HV_LINUX_GUEST_ID); - gHvContext.GuestId = HV_LINUX_GUEST_ID; + + if (gHvContext.GuestId != 0) { + DPRINT_ERR(VMBUS, "Unknown guest id (0x%llx)!!", + gHvContext.GuestId); + goto Cleanup; } + /* Write our OS info */ + wrmsrl(HV_X64_MSR_GUEST_OS_ID, HV_LINUX_GUEST_ID); + gHvContext.GuestId = HV_LINUX_GUEST_ID; + /* See if the hypercall page is already set */ rdmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64); - if (gHvContext.GuestId == HV_LINUX_GUEST_ID) { - /* Allocate the hypercall page memory */ - /* virtAddr = osd_PageAlloc(1); */ - virtAddr = osd_VirtualAllocExec(PAGE_SIZE); - - if (!virtAddr) { - DPRINT_ERR(VMBUS, - "unable to allocate hypercall page!!"); - goto Cleanup; - } - hypercallMsr.Enable = 1; - /* hypercallMsr.GuestPhysicalAddress = - * virt_to_phys(virtAddr) >> PAGE_SHIFT; */ - hypercallMsr.GuestPhysicalAddress = vmalloc_to_pfn(virtAddr); - wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64); + /* + * Allocate the hypercall page memory + * virtAddr = osd_PageAlloc(1); + */ + virtAddr = osd_VirtualAllocExec(PAGE_SIZE); - /* Confirm that hypercall page did get setup. */ - hypercallMsr.AsUINT64 = 0; - rdmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64); - if (!hypercallMsr.Enable) { - DPRINT_ERR(VMBUS, "unable to set hypercall page!!"); - goto Cleanup; - } + if (!virtAddr) { + DPRINT_ERR(VMBUS, + "unable to allocate hypercall page!!"); + goto Cleanup; + } - gHvContext.HypercallPage = virtAddr; - } else { - DPRINT_ERR(VMBUS, "Unknown guest id (0x%llx)!!", - gHvContext.GuestId); + hypercallMsr.Enable = 1; + + hypercallMsr.GuestPhysicalAddress = vmalloc_to_pfn(virtAddr); + wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64); + + /* Confirm that hypercall page did get setup. */ + hypercallMsr.AsUINT64 = 0; + rdmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64); + + if (!hypercallMsr.Enable) { + DPRINT_ERR(VMBUS, "unable to set hypercall page!!"); goto Cleanup; } + gHvContext.HypercallPage = virtAddr; + DPRINT_INFO(VMBUS, "Hypercall page VA=%p, PA=0x%0llx", gHvContext.HypercallPage, (u64)hypercallMsr.GuestPhysicalAddress << PAGE_SHIFT); @@ -273,8 +274,6 @@ int HvInit(void) gHvContext.SignalEventParam->FlagNumber = 0; gHvContext.SignalEventParam->RsvdZ = 0; - /* DPRINT_DBG(VMBUS, "My id %llu", HvGetCurrentPartitionId()); */ - DPRINT_EXIT(VMBUS); return ret; @@ -311,17 +310,14 @@ void HvCleanup(void) kfree(gHvContext.SignalEventBuffer); } - if (gHvContext.GuestId == HV_LINUX_GUEST_ID) { - if (gHvContext.HypercallPage) { - hypercallMsr.AsUINT64 = 0; - wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64); - vfree(gHvContext.HypercallPage); - gHvContext.HypercallPage = NULL; - } + if (gHvContext.HypercallPage) { + hypercallMsr.AsUINT64 = 0; + wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64); + vfree(gHvContext.HypercallPage); + gHvContext.HypercallPage = NULL; } DPRINT_EXIT(VMBUS); - } /** @@ -393,7 +389,7 @@ void HvSynicInit(void *irqarg) union hv_synic_siefp siefp; union hv_synic_sint sharedSint; union hv_synic_scontrol sctrl; - u64 guestID; + u32 irqVector = *((u32 *)(irqarg)); int cpu = smp_processor_id(); @@ -409,71 +405,41 @@ void HvSynicInit(void *irqarg) DPRINT_INFO(VMBUS, "SynIC version: %llx", version); - /* TODO: Handle SMP */ - if (gHvContext.GuestId == HV_XENLINUX_GUEST_ID) { - DPRINT_INFO(VMBUS, "Skipping SIMP and SIEFP setup since " - "it is already set."); - - rdmsrl(HV_X64_MSR_SIMP, simp.AsUINT64); - rdmsrl(HV_X64_MSR_SIEFP, siefp.AsUINT64); - - DPRINT_DBG(VMBUS, "Simp: %llx, Sifep: %llx", - simp.AsUINT64, siefp.AsUINT64); - - /* - * Determine if we are running on xenlinux (ie x2v shim) or - * native linux - */ - rdmsrl(HV_X64_MSR_GUEST_OS_ID, guestID); - if (guestID == HV_LINUX_GUEST_ID) { - gHvContext.synICMessagePage[cpu] = - phys_to_virt(simp.BaseSimpGpa << PAGE_SHIFT); - gHvContext.synICEventPage[cpu] = - phys_to_virt(siefp.BaseSiefpGpa << PAGE_SHIFT); - } else { - DPRINT_ERR(VMBUS, "unknown guest id!!"); - goto Cleanup; - } - DPRINT_DBG(VMBUS, "MAPPED: Simp: %p, Sifep: %p", - gHvContext.synICMessagePage[cpu], - gHvContext.synICEventPage[cpu]); - } else { - gHvContext.synICMessagePage[cpu] = (void *)get_zeroed_page(GFP_ATOMIC); - if (gHvContext.synICMessagePage[cpu] == NULL) { - DPRINT_ERR(VMBUS, - "unable to allocate SYNIC message page!!"); - goto Cleanup; - } + gHvContext.synICMessagePage[cpu] = (void *)get_zeroed_page(GFP_ATOMIC); - gHvContext.synICEventPage[cpu] = (void *)get_zeroed_page(GFP_ATOMIC); - if (gHvContext.synICEventPage[cpu] == NULL) { - DPRINT_ERR(VMBUS, - "unable to allocate SYNIC event page!!"); - goto Cleanup; - } + if (gHvContext.synICMessagePage[cpu] == NULL) { + DPRINT_ERR(VMBUS, + "unable to allocate SYNIC message page!!"); + goto Cleanup; + } - /* Setup the Synic's message page */ - rdmsrl(HV_X64_MSR_SIMP, simp.AsUINT64); - simp.SimpEnabled = 1; - simp.BaseSimpGpa = virt_to_phys(gHvContext.synICMessagePage[cpu]) - >> PAGE_SHIFT; + gHvContext.synICEventPage[cpu] = (void *)get_zeroed_page(GFP_ATOMIC); - DPRINT_DBG(VMBUS, "HV_X64_MSR_SIMP msr set to: %llx", - simp.AsUINT64); + if (gHvContext.synICEventPage[cpu] == NULL) { + DPRINT_ERR(VMBUS, + "unable to allocate SYNIC event page!!"); + goto Cleanup; + } - wrmsrl(HV_X64_MSR_SIMP, simp.AsUINT64); + /* Setup the Synic's message page */ + rdmsrl(HV_X64_MSR_SIMP, simp.AsUINT64); + simp.SimpEnabled = 1; + simp.BaseSimpGpa = virt_to_phys(gHvContext.synICMessagePage[cpu]) + >> PAGE_SHIFT; - /* Setup the Synic's event page */ - rdmsrl(HV_X64_MSR_SIEFP, siefp.AsUINT64); - siefp.SiefpEnabled = 1; - siefp.BaseSiefpGpa = virt_to_phys(gHvContext.synICEventPage[cpu]) - >> PAGE_SHIFT; + DPRINT_DBG(VMBUS, "HV_X64_MSR_SIMP msr set to: %llx", simp.AsUINT64); - DPRINT_DBG(VMBUS, "HV_X64_MSR_SIEFP msr set to: %llx", - siefp.AsUINT64); + wrmsrl(HV_X64_MSR_SIMP, simp.AsUINT64); - wrmsrl(HV_X64_MSR_SIEFP, siefp.AsUINT64); - } + /* Setup the Synic's event page */ + rdmsrl(HV_X64_MSR_SIEFP, siefp.AsUINT64); + siefp.SiefpEnabled = 1; + siefp.BaseSiefpGpa = virt_to_phys(gHvContext.synICEventPage[cpu]) + >> PAGE_SHIFT; + + DPRINT_DBG(VMBUS, "HV_X64_MSR_SIEFP msr set to: %llx", siefp.AsUINT64); + + wrmsrl(HV_X64_MSR_SIEFP, siefp.AsUINT64); /* Setup the interception SINT. */ /* wrmsrl((HV_X64_MSR_SINT0 + HV_SYNIC_INTERCEPTION_SINT_INDEX), */ @@ -505,13 +471,11 @@ void HvSynicInit(void *irqarg) return; Cleanup: - if (gHvContext.GuestId == HV_LINUX_GUEST_ID) { - if (gHvContext.synICEventPage[cpu]) - osd_PageFree(gHvContext.synICEventPage[cpu], 1); + if (gHvContext.synICEventPage[cpu]) + osd_PageFree(gHvContext.synICEventPage[cpu], 1); - if (gHvContext.synICMessagePage[cpu]) - osd_PageFree(gHvContext.synICMessagePage[cpu], 1); - } + if (gHvContext.synICMessagePage[cpu]) + osd_PageFree(gHvContext.synICMessagePage[cpu], 1); DPRINT_EXIT(VMBUS); return; @@ -542,27 +506,20 @@ void HvSynicCleanup(void *arg) /* Disable the interrupt */ wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.AsUINT64); - /* - * Disable and free the resources only if we are running as - * native linux since in xenlinux, we are sharing the - * resources with the x2v shim - */ - if (gHvContext.GuestId == HV_LINUX_GUEST_ID) { - rdmsrl(HV_X64_MSR_SIMP, simp.AsUINT64); - simp.SimpEnabled = 0; - simp.BaseSimpGpa = 0; + rdmsrl(HV_X64_MSR_SIMP, simp.AsUINT64); + simp.SimpEnabled = 0; + simp.BaseSimpGpa = 0; - wrmsrl(HV_X64_MSR_SIMP, simp.AsUINT64); + wrmsrl(HV_X64_MSR_SIMP, simp.AsUINT64); - rdmsrl(HV_X64_MSR_SIEFP, siefp.AsUINT64); - siefp.SiefpEnabled = 0; - siefp.BaseSiefpGpa = 0; + rdmsrl(HV_X64_MSR_SIEFP, siefp.AsUINT64); + siefp.SiefpEnabled = 0; + siefp.BaseSiefpGpa = 0; - wrmsrl(HV_X64_MSR_SIEFP, siefp.AsUINT64); + wrmsrl(HV_X64_MSR_SIEFP, siefp.AsUINT64); - osd_PageFree(gHvContext.synICMessagePage[cpu], 1); - osd_PageFree(gHvContext.synICEventPage[cpu], 1); - } + osd_PageFree(gHvContext.synICMessagePage[cpu], 1); + osd_PageFree(gHvContext.synICEventPage[cpu], 1); DPRINT_EXIT(VMBUS); } diff --git a/drivers/staging/hv/Hv.h b/drivers/staging/hv/Hv.h index fce4b5c..41f5ebb 100644 --- a/drivers/staging/hv/Hv.h +++ b/drivers/staging/hv/Hv.h @@ -41,11 +41,6 @@ enum { #define HV_PRESENT_BIT 0x80000000 -#define HV_XENLINUX_GUEST_ID_LO 0x00000000 -#define HV_XENLINUX_GUEST_ID_HI 0x0B00B135 -#define HV_XENLINUX_GUEST_ID (((u64)HV_XENLINUX_GUEST_ID_HI << 32) \ - | HV_XENLINUX_GUEST_ID_LO) - #define HV_LINUX_GUEST_ID_LO 0x00000000 #define HV_LINUX_GUEST_ID_HI 0xB16B00B5 #define HV_LINUX_GUEST_ID (((u64)HV_LINUX_GUEST_ID_HI << 32) | \ @@ -102,8 +97,9 @@ struct hv_input_signal_event_buffer { }; struct hv_context { - /* XenLinux or native Linux. If XenLinux, the hypercall and synic pages - * has already been initialized */ + /* We only support running on top of Hyper-V + * So at this point this really can only contain the Hyper-V ID + */ u64 GuestId; void *HypercallPage; -- cgit v1.1 From 4408f5319b6c8784120e0784df315b87e8a5dfef Mon Sep 17 00:00:00 2001 From: "C. Bartlett" Date: Wed, 3 Feb 2010 15:34:27 +0000 Subject: Staging: hv: fix various coding style issues in RingBuffer.c This is a patch to the RingBuffer.c file that corrects various coding style warnings and errors found by checkpatch.pl [ The real solution here is to get rid of this file entirely, and use the kernel's internal ring buffer api, but until then, make these changes so as to make checkpatch.pl happy, and keep others from continuously sending this type of patch. - gkh] Signed-off-by: Craig Bartlett Cc: Bill Pemberton Cc: Nicolas Palix Cc: Hank Janssen Cc: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/RingBuffer.c | 153 ++++++++++++++++++++++------------------ 1 file changed, 86 insertions(+), 67 deletions(-) (limited to 'drivers/staging/hv') diff --git a/drivers/staging/hv/RingBuffer.c b/drivers/staging/hv/RingBuffer.c index f69ae33..80b8a2c 100644 --- a/drivers/staging/hv/RingBuffer.c +++ b/drivers/staging/hv/RingBuffer.c @@ -48,7 +48,7 @@ Description: static inline void GetRingBufferAvailBytes(RING_BUFFER_INFO *rbi, u32 *read, u32 *write) { - u32 read_loc,write_loc; + u32 read_loc, write_loc; /* Capture the read/write indices before they changed */ read_loc = rbi->RingBuffer->ReadIndex; @@ -68,7 +68,7 @@ Description: --*/ static inline u32 -GetNextWriteLocation(RING_BUFFER_INFO* RingInfo) +GetNextWriteLocation(RING_BUFFER_INFO *RingInfo) { u32 next = RingInfo->RingBuffer->WriteIndex; @@ -87,7 +87,7 @@ Description: --*/ static inline void -SetNextWriteLocation(RING_BUFFER_INFO* RingInfo, u32 NextWriteLocation) +SetNextWriteLocation(RING_BUFFER_INFO *RingInfo, u32 NextWriteLocation) { RingInfo->RingBuffer->WriteIndex = NextWriteLocation; } @@ -102,7 +102,7 @@ Description: --*/ static inline u32 -GetNextReadLocation(RING_BUFFER_INFO* RingInfo) +GetNextReadLocation(RING_BUFFER_INFO *RingInfo) { u32 next = RingInfo->RingBuffer->ReadIndex; @@ -122,7 +122,7 @@ Description: --*/ static inline u32 -GetNextReadLocationWithOffset(RING_BUFFER_INFO* RingInfo, u32 Offset) +GetNextReadLocationWithOffset(RING_BUFFER_INFO *RingInfo, u32 Offset) { u32 next = RingInfo->RingBuffer->ReadIndex; @@ -143,7 +143,7 @@ Description: --*/ static inline void -SetNextReadLocation(RING_BUFFER_INFO* RingInfo, u32 NextReadLocation) +SetNextReadLocation(RING_BUFFER_INFO *RingInfo, u32 NextReadLocation) { RingInfo->RingBuffer->ReadIndex = NextReadLocation; } @@ -159,7 +159,7 @@ Description: --*/ static inline void * -GetRingBuffer(RING_BUFFER_INFO* RingInfo) +GetRingBuffer(RING_BUFFER_INFO *RingInfo) { return (void *)RingInfo->RingBuffer->Buffer; } @@ -175,7 +175,7 @@ Description: --*/ static inline u32 -GetRingBufferSize(RING_BUFFER_INFO* RingInfo) +GetRingBufferSize(RING_BUFFER_INFO *RingInfo) { return RingInfo->RingDataSize; } @@ -190,9 +190,10 @@ Description: --*/ static inline u64 -GetRingBufferIndices(RING_BUFFER_INFO* RingInfo) +GetRingBufferIndices(RING_BUFFER_INFO *RingInfo) { - return ((u64)RingInfo->RingBuffer->WriteIndex << 32) || RingInfo->RingBuffer->ReadIndex; + return ((u64)RingInfo->RingBuffer->WriteIndex << 32) + || RingInfo->RingBuffer->ReadIndex; } @@ -210,9 +211,14 @@ void DumpRingInfo(RING_BUFFER_INFO *RingInfo, char *Prefix) u32 bytesAvailToWrite; u32 bytesAvailToRead; - GetRingBufferAvailBytes(RingInfo, &bytesAvailToRead, &bytesAvailToWrite); + GetRingBufferAvailBytes(RingInfo, + &bytesAvailToRead, + &bytesAvailToWrite); - DPRINT(VMBUS, DEBUG_RING_LVL, "%s <>", + DPRINT(VMBUS, + DEBUG_RING_LVL, + "%s <>", Prefix, RingInfo, RingInfo->RingBuffer->Buffer, @@ -229,13 +235,13 @@ static u32 CopyToRingBuffer( RING_BUFFER_INFO *RingInfo, u32 StartWriteOffset, - void * Src, + void *Src, u32 SrcLen); static u32 CopyFromRingBuffer( RING_BUFFER_INFO *RingInfo, - void * Dest, + void *Dest, u32 DestLen, u32 StartReadOffset); @@ -256,15 +262,15 @@ void RingBufferGetDebugInfo(RING_BUFFER_INFO *RingInfo, u32 bytesAvailToWrite; u32 bytesAvailToRead; - if (RingInfo->RingBuffer) - { - GetRingBufferAvailBytes(RingInfo, &bytesAvailToRead, &bytesAvailToWrite); + if (RingInfo->RingBuffer) { + GetRingBufferAvailBytes(RingInfo, + &bytesAvailToRead, + &bytesAvailToWrite); DebugInfo->BytesAvailToRead = bytesAvailToRead; DebugInfo->BytesAvailToWrite = bytesAvailToWrite; DebugInfo->CurrentReadIndex = RingInfo->RingBuffer->ReadIndex; DebugInfo->CurrentWriteIndex = RingInfo->RingBuffer->WriteIndex; - DebugInfo->CurrentInterruptMask = RingInfo->RingBuffer->InterruptMask; } } @@ -299,7 +305,7 @@ int RingBufferInit(RING_BUFFER_INFO *RingInfo, void *Buffer, u32 BufferLen) memset(RingInfo, 0, sizeof(RING_BUFFER_INFO)); - RingInfo->RingBuffer = (RING_BUFFER*)Buffer; + RingInfo->RingBuffer = (RING_BUFFER *)Buffer; RingInfo->RingBuffer->ReadIndex = RingInfo->RingBuffer->WriteIndex = 0; RingInfo->RingSize = BufferLen; @@ -319,7 +325,7 @@ Description: Cleanup the ring buffer --*/ -void RingBufferCleanup(RING_BUFFER_INFO* RingInfo) +void RingBufferCleanup(RING_BUFFER_INFO *RingInfo) { } @@ -335,14 +341,14 @@ Description: int RingBufferWrite(RING_BUFFER_INFO *OutRingInfo, struct scatterlist *sglist, u32 sgcount) { - int i=0; + int i = 0; u32 byteAvailToWrite; u32 byteAvailToRead; - u32 totalBytesToWrite=0; + u32 totalBytesToWrite = 0; struct scatterlist *sg; volatile u32 nextWriteLocation; - u64 prevIndices=0; + u64 prevIndices = 0; unsigned long flags; DPRINT_ENTER(VMBUS); @@ -356,17 +362,23 @@ int RingBufferWrite(RING_BUFFER_INFO *OutRingInfo, spin_lock_irqsave(&OutRingInfo->ring_lock, flags); - GetRingBufferAvailBytes(OutRingInfo, &byteAvailToRead, &byteAvailToWrite); + GetRingBufferAvailBytes(OutRingInfo, + &byteAvailToRead, + &byteAvailToWrite); DPRINT_DBG(VMBUS, "Writing %u bytes...", totalBytesToWrite); /* DumpRingInfo(OutRingInfo, "BEFORE "); */ - /* If there is only room for the packet, assume it is full. Otherwise, the next time around, we think the ring buffer */ + /* If there is only room for the packet, assume it is full. */ + /* Otherwise, the next time around, we think the ring buffer */ /* is empty since the read index == write index */ - if (byteAvailToWrite <= totalBytesToWrite) - { - DPRINT_DBG(VMBUS, "No more space left on outbound ring buffer (needed %u, avail %u)", totalBytesToWrite, byteAvailToWrite); + if (byteAvailToWrite <= totalBytesToWrite) { + DPRINT_DBG(VMBUS, + "No more space left on outbound ring buffer " + "(needed %u, avail %u)", + totalBytesToWrite, + byteAvailToWrite); spin_unlock_irqrestore(&OutRingInfo->ring_lock, flags); @@ -423,17 +435,22 @@ int RingBufferPeek(RING_BUFFER_INFO *InRingInfo, void *Buffer, u32 BufferLen) { u32 bytesAvailToWrite; u32 bytesAvailToRead; - u32 nextReadLocation=0; + u32 nextReadLocation = 0; unsigned long flags; spin_lock_irqsave(&InRingInfo->ring_lock, flags); - GetRingBufferAvailBytes(InRingInfo, &bytesAvailToRead, &bytesAvailToWrite); + GetRingBufferAvailBytes(InRingInfo, + &bytesAvailToRead, + &bytesAvailToWrite); /* Make sure there is something to read */ - if (bytesAvailToRead < BufferLen ) - { - /* DPRINT_DBG(VMBUS, "got callback but not enough to read !!", bytesAvailToRead, BufferLen); */ + if (bytesAvailToRead < BufferLen) { + /* DPRINT_DBG(VMBUS, + "got callback but not enough to read " + "!!", + bytesAvailToRead, + BufferLen); */ spin_unlock_irqrestore(&InRingInfo->ring_lock, flags); @@ -444,9 +461,9 @@ int RingBufferPeek(RING_BUFFER_INFO *InRingInfo, void *Buffer, u32 BufferLen) nextReadLocation = GetNextReadLocation(InRingInfo); nextReadLocation = CopyFromRingBuffer(InRingInfo, - Buffer, - BufferLen, - nextReadLocation); + Buffer, + BufferLen, + nextReadLocation); spin_unlock_irqrestore(&InRingInfo->ring_lock, flags); @@ -468,24 +485,29 @@ int RingBufferRead(RING_BUFFER_INFO *InRingInfo, void *Buffer, { u32 bytesAvailToWrite; u32 bytesAvailToRead; - u32 nextReadLocation=0; - u64 prevIndices=0; + u32 nextReadLocation = 0; + u64 prevIndices = 0; unsigned long flags; ASSERT(BufferLen > 0); spin_lock_irqsave(&InRingInfo->ring_lock, flags); - GetRingBufferAvailBytes(InRingInfo, &bytesAvailToRead, &bytesAvailToWrite); + GetRingBufferAvailBytes(InRingInfo, + &bytesAvailToRead, + &bytesAvailToWrite); DPRINT_DBG(VMBUS, "Reading %u bytes...", BufferLen); /* DumpRingInfo(InRingInfo, "BEFORE "); */ /* Make sure there is something to read */ - if (bytesAvailToRead < BufferLen ) - { - DPRINT_DBG(VMBUS, "got callback but not enough to read !!", bytesAvailToRead, BufferLen); + if (bytesAvailToRead < BufferLen) { + DPRINT_DBG(VMBUS, + "got callback but not enough to read " + "!!", + bytesAvailToRead, + BufferLen); spin_unlock_irqrestore(&InRingInfo->ring_lock, flags); @@ -495,17 +517,18 @@ int RingBufferRead(RING_BUFFER_INFO *InRingInfo, void *Buffer, nextReadLocation = GetNextReadLocationWithOffset(InRingInfo, Offset); nextReadLocation = CopyFromRingBuffer(InRingInfo, - Buffer, - BufferLen, - nextReadLocation); + Buffer, + BufferLen, + nextReadLocation); nextReadLocation = CopyFromRingBuffer(InRingInfo, - &prevIndices, - sizeof(u64), - nextReadLocation); + &prevIndices, + sizeof(u64), + nextReadLocation); /* Make sure all reads are done before we update the read index since */ - /* the writer may start writing to the read area once the read index is updated */ + /* the writer may start writing to the read area once the read index */ + /*is updated */ mb(); /* Update the read index */ @@ -533,25 +556,22 @@ static u32 CopyToRingBuffer( RING_BUFFER_INFO *RingInfo, u32 StartWriteOffset, - void * Src, + void *Src, u32 SrcLen) { - void * ringBuffer=GetRingBuffer(RingInfo); - u32 ringBufferSize=GetRingBufferSize(RingInfo); + void *ringBuffer = GetRingBuffer(RingInfo); + u32 ringBufferSize = GetRingBufferSize(RingInfo); u32 fragLen; - if (SrcLen > ringBufferSize - StartWriteOffset) /* wrap-around detected! */ - { + /* wrap-around detected! */ + if (SrcLen > ringBufferSize - StartWriteOffset) { DPRINT_DBG(VMBUS, "wrap-around detected!"); fragLen = ringBufferSize - StartWriteOffset; memcpy(ringBuffer + StartWriteOffset, Src, fragLen); memcpy(ringBuffer, Src + fragLen, SrcLen - fragLen); - } - else - { + } else memcpy(ringBuffer + StartWriteOffset, Src, SrcLen); - } StartWriteOffset += SrcLen; StartWriteOffset %= ringBufferSize; @@ -573,28 +593,27 @@ Description: static u32 CopyFromRingBuffer( RING_BUFFER_INFO *RingInfo, - void * Dest, + void *Dest, u32 DestLen, u32 StartReadOffset) { - void * ringBuffer=GetRingBuffer(RingInfo); - u32 ringBufferSize=GetRingBufferSize(RingInfo); + void *ringBuffer = GetRingBuffer(RingInfo); + u32 ringBufferSize = GetRingBufferSize(RingInfo); u32 fragLen; - if (DestLen > ringBufferSize - StartReadOffset) /* wrap-around detected at the src */ - { + /* wrap-around detected at the src */ + if (DestLen > ringBufferSize - StartReadOffset) { DPRINT_DBG(VMBUS, "src wrap-around detected!"); fragLen = ringBufferSize - StartReadOffset; memcpy(Dest, ringBuffer + StartReadOffset, fragLen); memcpy(Dest + fragLen, ringBuffer, DestLen - fragLen); - } - else - { + } else + memcpy(Dest, ringBuffer + StartReadOffset, DestLen); - } + StartReadOffset += DestLen; StartReadOffset %= ringBufferSize; -- cgit v1.1 From 26c14cc119204adc218259251919c5198d07dafe Mon Sep 17 00:00:00 2001 From: Hank Janssen Date: Thu, 11 Feb 2010 23:02:42 +0000 Subject: Staging: hv: Add proper versioning to HV drivers Provide proper versioning information for all HV drivers. With removal of build time/date/and Minor number as requested by Greg KH Signed-off-by: Hank Janssen Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/VersionInfo.h | 22 +++++++++++++++++++--- drivers/staging/hv/Vmbus.c | 6 ++---- drivers/staging/hv/blkvsc_drv.c | 2 ++ drivers/staging/hv/netvsc_drv.c | 5 +++-- drivers/staging/hv/storvsc_drv.c | 2 ++ drivers/staging/hv/vmbus_drv.c | 2 ++ 6 files changed, 30 insertions(+), 9 deletions(-) (limited to 'drivers/staging/hv') diff --git a/drivers/staging/hv/VersionInfo.h b/drivers/staging/hv/VersionInfo.h index 9c3641d..10d7b19 100644 --- a/drivers/staging/hv/VersionInfo.h +++ b/drivers/staging/hv/VersionInfo.h @@ -24,8 +24,24 @@ #ifndef __HV_VERSION_INFO #define __HV_VERSION_INFO -static const char VersionDate[] = __DATE__; -static const char VersionTime[] = __TIME__; -static const char VersionDesc[] = "Version 2.0"; +/* + * We use the same version numbering for all Hyper-V modules. + * + * Definition of versioning is as follows; + * + * Major Number Changes for these scenarios; + * 1. When a new version of Windows Hyper-V + * is released. + * 2. A Major change has occurred in the + * Linux IC's. + * (For example the merge for the first time + * into the kernel) Every time the Major Number + * changes, the Revision number is reset to 0. + * Minor Number Changes when new functionality is added + * to the Linux IC's that is not a bug fix. + * + */ +#define HV_DRV_VERSION "3.0" + #endif diff --git a/drivers/staging/hv/Vmbus.c b/drivers/staging/hv/Vmbus.c index 35a023e..3d0a240 100644 --- a/drivers/staging/hv/Vmbus.c +++ b/drivers/staging/hv/Vmbus.c @@ -273,10 +273,8 @@ int VmbusInitialize(struct hv_driver *drv) DPRINT_ENTER(VMBUS); - DPRINT_INFO(VMBUS, "+++++++ Build Date=%s %s +++++++", - VersionDate, VersionTime); - DPRINT_INFO(VMBUS, "+++++++ Build Description=%s +++++++", - VersionDesc); + DPRINT_INFO(VMBUS, "+++++++ HV Driver version = %s +++++++", + HV_DRV_VERSION); DPRINT_INFO(VMBUS, "+++++++ Vmbus supported version = %d +++++++", VMBUS_REVISION_NUMBER); DPRINT_INFO(VMBUS, "+++++++ Vmbus using SINT %d +++++++", diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 62b2828..635692d 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -31,6 +31,7 @@ #include #include "osd.h" #include "logging.h" +#include "VersionInfo.h" #include "vmbus.h" #include "StorVscApi.h" @@ -1507,6 +1508,7 @@ static void __exit blkvsc_exit(void) } MODULE_LICENSE("GPL"); +MODULE_VERSION(HV_DRV_VERSION); module_param(blkvsc_ringbuffer_size, int, S_IRUGO); module_init(blkvsc_init); module_exit(blkvsc_exit); diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 3234a7c..0a78067 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -35,11 +35,10 @@ #include #include "osd.h" #include "logging.h" +#include "VersionInfo.h" #include "vmbus.h" #include "NetVscApi.h" -MODULE_LICENSE("GPL"); - struct net_device_context { /* point back to our device context */ struct device_context *device_ctx; @@ -603,6 +602,8 @@ static void __exit netvsc_exit(void) DPRINT_EXIT(NETVSC_DRV); } +MODULE_LICENSE("GPL"); +MODULE_VERSION(HV_DRV_VERSION); module_param(netvsc_ringbuffer_size, int, S_IRUGO); module_init(netvsc_init); diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 12f8f3f..a10fa0e 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -32,6 +32,7 @@ #include #include "osd.h" #include "logging.h" +#include "VersionInfo.h" #include "vmbus.h" #include "StorVscApi.h" @@ -990,6 +991,7 @@ static void __exit storvsc_exit(void) } MODULE_LICENSE("GPL"); +MODULE_VERSION(HV_DRV_VERSION); module_param(storvsc_ringbuffer_size, int, S_IRUGO); module_init(storvsc_init); module_exit(storvsc_exit); diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 894eecf..92d70cd 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -24,6 +24,7 @@ #include #include #include +#include "VersionInfo.h" #include "osd.h" #include "logging.h" #include "vmbus.h" @@ -974,6 +975,7 @@ static void __exit vmbus_exit(void) } MODULE_LICENSE("GPL"); +MODULE_VERSION(HV_DRV_VERSION); module_param(vmbus_irq, int, S_IRUGO); module_param(vmbus_loglevel, int, S_IRUGO); -- cgit v1.1 From f916a34dc066c13ff2c8986657634cef06c07719 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Wed, 17 Feb 2010 20:58:47 +0000 Subject: Staging: hv: Rename struct device_context and re-arrange the fields inside Rename struct device_context and re-arrange the fields inside. Rename struct device_context to struct vm_device, and move struct device field to the end according to Document/driver-model standard. Signed-off-by: Hank Janssen Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/blkvsc_drv.c | 8 ++++---- drivers/staging/hv/netvsc_drv.c | 10 +++++----- drivers/staging/hv/storvsc_drv.c | 10 +++++----- drivers/staging/hv/vmbus.h | 12 ++++++------ drivers/staging/hv/vmbus_drv.c | 36 ++++++++++++++++++------------------ 5 files changed, 38 insertions(+), 38 deletions(-) (limited to 'drivers/staging/hv') diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 635692d..1d1a46f 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -93,7 +93,7 @@ struct blkvsc_request { /* Per device structure */ struct block_device_context { /* point back to our device context */ - struct device_context *device_ctx; + struct vm_device *device_ctx; struct kmem_cache *request_pool; spinlock_t lock; struct gendisk *gd; @@ -255,7 +255,7 @@ static int blkvsc_probe(struct device *device) (struct blkvsc_driver_context *)driver_ctx; struct storvsc_driver_object *storvsc_drv_obj = &blkvsc_drv_ctx->drv_obj; - struct device_context *device_ctx = device_to_device_context(device); + struct vm_device *device_ctx = device_to_vm_device(device); struct hv_device *device_obj = &device_ctx->device_obj; struct block_device_context *blkdev = NULL; @@ -746,7 +746,7 @@ static int blkvsc_remove(struct device *device) (struct blkvsc_driver_context *)driver_ctx; struct storvsc_driver_object *storvsc_drv_obj = &blkvsc_drv_ctx->drv_obj; - struct device_context *device_ctx = device_to_device_context(device); + struct vm_device *device_ctx = device_to_vm_device(device); struct hv_device *device_obj = &device_ctx->device_obj; struct block_device_context *blkdev = dev_get_drvdata(device); unsigned long flags; @@ -866,7 +866,7 @@ static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req, void (*request_completion)(struct hv_storvsc_request *)) { struct block_device_context *blkdev = blkvsc_req->dev; - struct device_context *device_ctx = blkdev->device_ctx; + struct vm_device *device_ctx = blkdev->device_ctx; struct driver_context *driver_ctx = driver_to_driver_context(device_ctx->device.driver); struct blkvsc_driver_context *blkvsc_drv_ctx = diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index 0a78067..1af3dcb 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -41,7 +41,7 @@ struct net_device_context { /* point back to our device context */ - struct device_context *device_ctx; + struct vm_device *device_ctx; struct net_device_stats stats; }; @@ -271,7 +271,7 @@ retry_send: static void netvsc_linkstatus_callback(struct hv_device *device_obj, unsigned int status) { - struct device_context *device_ctx = to_device_context(device_obj); + struct vm_device *device_ctx = to_vm_device(device_obj); struct net_device *net = dev_get_drvdata(&device_ctx->device); DPRINT_ENTER(NETVSC_DRV); @@ -298,7 +298,7 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj, static int netvsc_recv_callback(struct hv_device *device_obj, struct hv_netvsc_packet *packet) { - struct device_context *device_ctx = to_device_context(device_obj); + struct vm_device *device_ctx = to_vm_device(device_obj); struct net_device *net = dev_get_drvdata(&device_ctx->device); struct net_device_context *net_device_ctx; struct sk_buff *skb; @@ -390,7 +390,7 @@ static int netvsc_probe(struct device *device) struct netvsc_driver_context *net_drv_ctx = (struct netvsc_driver_context *)driver_ctx; struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj; - struct device_context *device_ctx = device_to_device_context(device); + struct vm_device *device_ctx = device_to_vm_device(device); struct hv_device *device_obj = &device_ctx->device_obj; struct net_device *net = NULL; struct net_device_context *net_device_ctx; @@ -462,7 +462,7 @@ static int netvsc_remove(struct device *device) struct netvsc_driver_context *net_drv_ctx = (struct netvsc_driver_context *)driver_ctx; struct netvsc_driver *net_drv_obj = &net_drv_ctx->drv_obj; - struct device_context *device_ctx = device_to_device_context(device); + struct vm_device *device_ctx = device_to_vm_device(device); struct net_device *net = dev_get_drvdata(&device_ctx->device); struct hv_device *device_obj = &device_ctx->device_obj; int ret; diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index a10fa0e..3988f4b 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -41,7 +41,7 @@ struct host_device_context { /* must be 1st field * FIXME this is a bug */ /* point back to our device context */ - struct device_context *device_ctx; + struct vm_device *device_ctx; struct kmem_cache *request_pool; unsigned int port; unsigned char path; @@ -234,7 +234,7 @@ static int storvsc_probe(struct device *device) (struct storvsc_driver_context *)driver_ctx; struct storvsc_driver_object *storvsc_drv_obj = &storvsc_drv_ctx->drv_obj; - struct device_context *device_ctx = device_to_device_context(device); + struct vm_device *device_ctx = device_to_vm_device(device); struct hv_device *device_obj = &device_ctx->device_obj; struct Scsi_Host *host; struct host_device_context *host_device_ctx; @@ -330,7 +330,7 @@ static int storvsc_remove(struct device *device) (struct storvsc_driver_context *)driver_ctx; struct storvsc_driver_object *storvsc_drv_obj = &storvsc_drv_ctx->drv_obj; - struct device_context *device_ctx = device_to_device_context(device); + struct vm_device *device_ctx = device_to_vm_device(device); struct hv_device *device_obj = &device_ctx->device_obj; struct Scsi_Host *host = dev_get_drvdata(device); struct host_device_context *host_device_ctx = @@ -631,7 +631,7 @@ static int storvsc_queuecommand(struct scsi_cmnd *scmnd, int ret; struct host_device_context *host_device_ctx = (struct host_device_context *)scmnd->device->host->hostdata; - struct device_context *device_ctx = host_device_ctx->device_ctx; + struct vm_device *device_ctx = host_device_ctx->device_ctx; struct driver_context *driver_ctx = driver_to_driver_context(device_ctx->device.driver); struct storvsc_driver_context *storvsc_drv_ctx = @@ -870,7 +870,7 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd) int ret; struct host_device_context *host_device_ctx = (struct host_device_context *)scmnd->device->host->hostdata; - struct device_context *device_ctx = host_device_ctx->device_ctx; + struct vm_device *device_ctx = host_device_ctx->device_ctx; DPRINT_ENTER(STORVSC_DRV); diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h index ae0a896..6404b84 100644 --- a/drivers/staging/hv/vmbus.h +++ b/drivers/staging/hv/vmbus.h @@ -43,23 +43,23 @@ struct driver_context { void (*shutdown)(struct device *); }; -struct device_context { +struct vm_device { struct work_struct probe_failed_work_item; struct hv_guid class_id; struct hv_guid device_id; int probe_error; - struct device device; struct hv_device device_obj; + struct device device; }; -static inline struct device_context *to_device_context(struct hv_device *d) +static inline struct vm_device *to_vm_device(struct hv_device *d) { - return container_of(d, struct device_context, device_obj); + return container_of(d, struct vm_device, device_obj); } -static inline struct device_context *device_to_device_context(struct device *d) +static inline struct vm_device *device_to_vm_device(struct device *d) { - return container_of(d, struct device_context, device); + return container_of(d, struct vm_device, device); } static inline struct driver_context *driver_to_driver_context(struct device_driver *d) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 92d70cd..de8729d 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -48,7 +48,7 @@ struct vmbus_driver_context { struct tasklet_struct event_dpc; /* The bus root device */ - struct device_context device_ctx; + struct vm_device device_ctx; }; static int vmbus_match(struct device *device, struct device_driver *driver); @@ -136,7 +136,7 @@ static ssize_t vmbus_show_device_attr(struct device *dev, struct device_attribute *dev_attr, char *buf) { - struct device_context *device_ctx = device_to_device_context(dev); + struct vm_device *device_ctx = device_to_vm_device(dev); struct hv_device_info device_info; memset(&device_info, 0, sizeof(struct hv_device_info)); @@ -246,7 +246,7 @@ static int vmbus_bus_init(int (*drv_init)(struct hv_driver *drv)) { struct vmbus_driver_context *vmbus_drv_ctx = &g_vmbus_drv; struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj; - struct device_context *dev_ctx = &g_vmbus_drv.device_ctx; + struct vm_device *dev_ctx = &g_vmbus_drv.device_ctx; int ret; unsigned int vector; @@ -308,7 +308,7 @@ static int vmbus_bus_init(int (*drv_init)(struct hv_driver *drv)) DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", vmbus_irq, vector); /* Call to bus driver to add the root device */ - memset(dev_ctx, 0, sizeof(struct device_context)); + memset(dev_ctx, 0, sizeof(struct vm_device)); ret = vmbus_drv_obj->Base.OnDeviceAdd(&dev_ctx->device_obj, &vector); if (ret != 0) { @@ -369,7 +369,7 @@ static void vmbus_bus_exit(void) struct vmbus_driver *vmbus_drv_obj = &g_vmbus_drv.drv_obj; struct vmbus_driver_context *vmbus_drv_ctx = &g_vmbus_drv; - struct device_context *dev_ctx = &g_vmbus_drv.device_ctx; + struct vm_device *dev_ctx = &g_vmbus_drv.device_ctx; DPRINT_ENTER(VMBUS_DRV); @@ -472,13 +472,13 @@ static struct hv_device *vmbus_child_device_create(struct hv_guid *type, struct hv_guid *instance, void *context) { - struct device_context *child_device_ctx; + struct vm_device *child_device_ctx; struct hv_device *child_device_obj; DPRINT_ENTER(VMBUS_DRV); /* Allocate the new child device */ - child_device_ctx = kzalloc(sizeof(struct device_context), GFP_KERNEL); + child_device_ctx = kzalloc(sizeof(struct vm_device), GFP_KERNEL); if (!child_device_ctx) { DPRINT_ERR(VMBUS_DRV, "unable to allocate device_context for child device"); @@ -527,10 +527,10 @@ static int vmbus_child_device_register(struct hv_device *root_device_obj, struct hv_device *child_device_obj) { int ret = 0; - struct device_context *root_device_ctx = - to_device_context(root_device_obj); - struct device_context *child_device_ctx = - to_device_context(child_device_obj); + struct vm_device *root_device_ctx = + to_vm_device(root_device_obj); + struct vm_device *child_device_ctx = + to_vm_device(child_device_obj); static atomic_t device_num = ATOMIC_INIT(0); DPRINT_ENTER(VMBUS_DRV); @@ -573,7 +573,7 @@ static int vmbus_child_device_register(struct hv_device *root_device_obj, */ static void vmbus_child_device_unregister(struct hv_device *device_obj) { - struct device_context *device_ctx = to_device_context(device_obj); + struct vm_device *device_ctx = to_vm_device(device_obj); DPRINT_ENTER(VMBUS_DRV); @@ -611,7 +611,7 @@ static void vmbus_child_device_destroy(struct hv_device *device_obj) */ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) { - struct device_context *device_ctx = device_to_device_context(device); + struct vm_device *device_ctx = device_to_vm_device(device); int ret; DPRINT_ENTER(VMBUS_DRV); @@ -688,7 +688,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver) { int match = 0; struct driver_context *driver_ctx = driver_to_driver_context(driver); - struct device_context *device_ctx = device_to_device_context(device); + struct vm_device *device_ctx = device_to_vm_device(device); DPRINT_ENTER(VMBUS_DRV); @@ -725,7 +725,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver) */ static void vmbus_probe_failed_cb(struct work_struct *context) { - struct device_context *device_ctx = (struct device_context *)context; + struct vm_device *device_ctx = (struct vm_device *)context; DPRINT_ENTER(VMBUS_DRV); @@ -747,8 +747,8 @@ static int vmbus_probe(struct device *child_device) int ret = 0; struct driver_context *driver_ctx = driver_to_driver_context(child_device->driver); - struct device_context *device_ctx = - device_to_device_context(child_device); + struct vm_device *device_ctx = + device_to_vm_device(child_device); DPRINT_ENTER(VMBUS_DRV); @@ -872,7 +872,7 @@ static void vmbus_bus_release(struct device *device) */ static void vmbus_device_release(struct device *device) { - struct device_context *device_ctx = device_to_device_context(device); + struct vm_device *device_ctx = device_to_vm_device(device); DPRINT_ENTER(VMBUS_DRV); -- cgit v1.1 From 0fa37b1ee936811c8aa8fcb72d189d02cf1575b9 Mon Sep 17 00:00:00 2001 From: Chris Nicholson Date: Sat, 20 Feb 2010 20:36:23 +0000 Subject: Staging: hv: fix brace coding style issue in Channel.c This is a patch to the Channel.c file that fixes up a brace warning found by checkpatch.pl Signed-off-by: Chris Nicholson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/Channel.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging/hv') diff --git a/drivers/staging/hv/Channel.c b/drivers/staging/hv/Channel.c index 746370e..d46eb145 100644 --- a/drivers/staging/hv/Channel.c +++ b/drivers/staging/hv/Channel.c @@ -991,9 +991,8 @@ void VmbusChannelOnTimer(unsigned long data) { struct vmbus_channel *channel = (struct vmbus_channel *)data; - if (channel->OnChannelCallback) { + if (channel->OnChannelCallback) channel->OnChannelCallback(channel->ChannelCallbackContext); - } } /** -- cgit v1.1 From 9a775dbd4e8c87b7d35549183145321c7205404e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 25 Feb 2010 16:42:10 -0800 Subject: Staging: hv: add a pci device table This allows the HV core to be properly found and autoloaded by the system tools. It uses the Microsoft virtual VGA device to trigger this. Cc: Haiyang Zhang Cc: Hank Janssen Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'drivers/staging/hv') diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index de8729d..186cbe6 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "VersionInfo.h" #include "osd.h" #include "logging.h" @@ -974,6 +975,22 @@ static void __exit vmbus_exit(void) return; } +/* + * We use a PCI table to determine if we should autoload this driver This is + * needed by distro tools to determine if the hyperv drivers should be + * installed and/or configured. We don't do anything else with the table, but + * it needs to be present. + * + * We might consider triggering off of DMI table info as well, as that does + * decribe the virtual machine being run on, but not all configuration tools + * seem to be able to handle DMI device ids properly. + */ +const static struct pci_device_id microsoft_hv_pci_table[] = { + { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */ + { 0 } +}; +MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table); + MODULE_LICENSE("GPL"); MODULE_VERSION(HV_DRV_VERSION); module_param(vmbus_irq, int, S_IRUGO); -- cgit v1.1 From c22090facd354749cfe99a46e903449c7ac07788 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 25 Feb 2010 16:43:15 -0800 Subject: Staging: hv: match on DMI values to know if we should run. The HV core mucks around with specific irqs and other low-level stuff and takes forever to determine that it really shouldn't be running on a machine. So instead, trigger off of the DMI system information and error out much sooner. This also allows the module loading tools to recognize that this code should be loaded on this type of system. Cc: Haiyang Zhang Cc: Hank Janssen Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'drivers/staging/hv') diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 186cbe6..2c90619 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "VersionInfo.h" #include "osd.h" #include "logging.h" @@ -948,6 +949,19 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id) } } +static struct dmi_system_id __initdata microsoft_hv_dmi_table[] = { + { + .ident = "Hyper-V", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), + DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"), + DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"), + }, + }, + { }, +}; +MODULE_DEVICE_TABLE(dmi, microsoft_hv_dmi_table); + static int __init vmbus_init(void) { int ret = 0; @@ -959,6 +973,9 @@ static int __init vmbus_init(void) vmbus_loglevel, HIWORD(vmbus_loglevel), LOWORD(vmbus_loglevel)); /* Todo: it is used for loglevel, to be ported to new kernel. */ + if (!dmi_check_system(microsoft_hv_dmi_table)) + return -ENODEV; + ret = vmbus_bus_init(VmbusInitialize); DPRINT_EXIT(VMBUS_DRV); @@ -980,10 +997,6 @@ static void __exit vmbus_exit(void) * needed by distro tools to determine if the hyperv drivers should be * installed and/or configured. We don't do anything else with the table, but * it needs to be present. - * - * We might consider triggering off of DMI table info as well, as that does - * decribe the virtual machine being run on, but not all configuration tools - * seem to be able to handle DMI device ids properly. */ const static struct pci_device_id microsoft_hv_pci_table[] = { { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */ -- cgit v1.1