Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Staging: hv: remove vmbus.c

Merge the functions into vmbus_drv.c as there's no need to have them
separate anymore. It will also make unwinding some of the function and
pointer mess easier, as well as making functions static in the future.

Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

+210 -237
+1 -1
drivers/staging/hv/Makefile
··· 5 5 obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o 6 6 7 7 hv_vmbus-y := vmbus_drv.o osd.o \ 8 - vmbus.o hv.o connection.o channel.o \ 8 + hv.o connection.o channel.o \ 9 9 channel_mgmt.o ring_buffer.o 10 10 hv_storvsc-y := storvsc_drv.o storvsc.o 11 11 hv_blkvsc-y := blkvsc_drv.o blkvsc.o
-236
drivers/staging/hv/vmbus.c
··· 1 - /* 2 - * Copyright (c) 2009, Microsoft Corporation. 3 - * 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. 7 - * 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 11 - * more details. 12 - * 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. 16 - * 17 - * Authors: 18 - * Haiyang Zhang <haiyangz@microsoft.com> 19 - * Hank Janssen <hjanssen@microsoft.com> 20 - * 21 - */ 22 - #include <linux/kernel.h> 23 - #include <linux/mm.h> 24 - #include <linux/slab.h> 25 - #include "osd.h" 26 - #include "logging.h" 27 - #include "version_info.h" 28 - #include "vmbus_private.h" 29 - 30 - static const char *gDriverName = "hyperv"; 31 - 32 - /* 33 - * Windows vmbus does not defined this. 34 - * We defined this to be consistent with other devices 35 - */ 36 - /* {c5295816-f63a-4d5f-8d1a-4daf999ca185} */ 37 - static const struct hv_guid gVmbusDeviceType = { 38 - .data = { 39 - 0x16, 0x58, 0x29, 0xc5, 0x3a, 0xf6, 0x5f, 0x4d, 40 - 0x8d, 0x1a, 0x4d, 0xaf, 0x99, 0x9c, 0xa1, 0x85 41 - } 42 - }; 43 - 44 - /* {ac3760fc-9adf-40aa-9427-a70ed6de95c5} */ 45 - static const struct hv_guid gVmbusDeviceId = { 46 - .data = { 47 - 0xfc, 0x60, 0x37, 0xac, 0xdf, 0x9a, 0xaa, 0x40, 48 - 0x94, 0x27, 0xa7, 0x0e, 0xd6, 0xde, 0x95, 0xc5 49 - } 50 - }; 51 - 52 - static struct hv_driver *gDriver; /* vmbus driver object */ 53 - static struct hv_device *gDevice; /* vmbus root device */ 54 - 55 - /* 56 - * VmbusChildDeviceAdd - Registers the child device with the vmbus 57 - */ 58 - int VmbusChildDeviceAdd(struct hv_device *ChildDevice) 59 - { 60 - return vmbus_child_device_register(gDevice, ChildDevice); 61 - } 62 - 63 - /* 64 - * VmbusOnDeviceAdd - Callback when the root bus device is added 65 - */ 66 - static int VmbusOnDeviceAdd(struct hv_device *dev, void *AdditionalInfo) 67 - { 68 - u32 *irqvector = AdditionalInfo; 69 - int ret; 70 - 71 - gDevice = dev; 72 - 73 - memcpy(&gDevice->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid)); 74 - memcpy(&gDevice->deviceInstance, &gVmbusDeviceId, 75 - sizeof(struct hv_guid)); 76 - 77 - /* strcpy(dev->name, "vmbus"); */ 78 - /* SynIC setup... */ 79 - on_each_cpu(hv_synic_init, (void *)irqvector, 1); 80 - 81 - /* Connect to VMBus in the root partition */ 82 - ret = VmbusConnect(); 83 - 84 - /* VmbusSendEvent(device->localPortId+1); */ 85 - return ret; 86 - } 87 - 88 - /* 89 - * VmbusOnDeviceRemove - Callback when the root bus device is removed 90 - */ 91 - static int VmbusOnDeviceRemove(struct hv_device *dev) 92 - { 93 - int ret = 0; 94 - 95 - vmbus_release_unattached_channels(); 96 - VmbusDisconnect(); 97 - on_each_cpu(hv_synic_cleanup, NULL, 1); 98 - return ret; 99 - } 100 - 101 - /* 102 - * VmbusOnCleanup - Perform any cleanup when the driver is removed 103 - */ 104 - static void VmbusOnCleanup(struct hv_driver *drv) 105 - { 106 - /* struct vmbus_driver *driver = (struct vmbus_driver *)drv; */ 107 - 108 - hv_cleanup(); 109 - } 110 - 111 - /* 112 - * vmbus_on_msg_dpc - DPC routine to handle messages from the hypervisior 113 - */ 114 - void vmbus_on_msg_dpc(struct hv_driver *drv) 115 - { 116 - int cpu = smp_processor_id(); 117 - void *page_addr = hv_context.synic_message_page[cpu]; 118 - struct hv_message *msg = (struct hv_message *)page_addr + 119 - VMBUS_MESSAGE_SINT; 120 - struct hv_message *copied; 121 - 122 - while (1) { 123 - if (msg->header.message_type == HVMSG_NONE) { 124 - /* no msg */ 125 - break; 126 - } else { 127 - copied = kmemdup(msg, sizeof(*copied), GFP_ATOMIC); 128 - if (copied == NULL) 129 - continue; 130 - 131 - osd_schedule_callback(gVmbusConnection.WorkQueue, 132 - vmbus_onmessage, 133 - (void *)copied); 134 - } 135 - 136 - msg->header.message_type = HVMSG_NONE; 137 - 138 - /* 139 - * Make sure the write to MessageType (ie set to 140 - * HVMSG_NONE) happens before we read the 141 - * MessagePending and EOMing. Otherwise, the EOMing 142 - * will not deliver any more messages since there is 143 - * no empty slot 144 - */ 145 - mb(); 146 - 147 - if (msg->header.message_flags.msg_pending) { 148 - /* 149 - * This will cause message queue rescan to 150 - * possibly deliver another msg from the 151 - * hypervisor 152 - */ 153 - wrmsrl(HV_X64_MSR_EOM, 0); 154 - } 155 - } 156 - } 157 - 158 - /* 159 - * vmbus_on_event_dpc - DPC routine to handle events from the hypervisior 160 - */ 161 - void vmbus_on_event_dpc(struct hv_driver *drv) 162 - { 163 - /* TODO: Process any events */ 164 - VmbusOnEvents(); 165 - } 166 - 167 - /* 168 - * vmbus_on_isr - ISR routine 169 - */ 170 - int vmbus_on_isr(struct hv_driver *drv) 171 - { 172 - int ret = 0; 173 - int cpu = smp_processor_id(); 174 - void *page_addr; 175 - struct hv_message *msg; 176 - union hv_synic_event_flags *event; 177 - 178 - page_addr = hv_context.synic_message_page[cpu]; 179 - msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT; 180 - 181 - /* Check if there are actual msgs to be process */ 182 - if (msg->header.message_type != HVMSG_NONE) { 183 - DPRINT_DBG(VMBUS, "received msg type %d size %d", 184 - msg->header.message_type, 185 - msg->header.payload_size); 186 - ret |= 0x1; 187 - } 188 - 189 - /* TODO: Check if there are events to be process */ 190 - page_addr = hv_context.synic_event_page[cpu]; 191 - event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT; 192 - 193 - /* Since we are a child, we only need to check bit 0 */ 194 - if (test_and_clear_bit(0, (unsigned long *) &event->flags32[0])) { 195 - DPRINT_DBG(VMBUS, "received event %d", event->flags32[0]); 196 - ret |= 0x2; 197 - } 198 - 199 - return ret; 200 - } 201 - 202 - /* 203 - * VmbusInitialize - Main entry point 204 - */ 205 - int VmbusInitialize(struct hv_driver *driver) 206 - { 207 - int ret; 208 - 209 - DPRINT_INFO(VMBUS, "+++++++ HV Driver version = %s +++++++", 210 - HV_DRV_VERSION); 211 - DPRINT_INFO(VMBUS, "+++++++ Vmbus supported version = %d +++++++", 212 - VMBUS_REVISION_NUMBER); 213 - DPRINT_INFO(VMBUS, "+++++++ Vmbus using SINT %d +++++++", 214 - VMBUS_MESSAGE_SINT); 215 - DPRINT_DBG(VMBUS, "sizeof(vmbus_channel_packet_page_buffer)=%zd, " 216 - "sizeof(VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER)=%zd", 217 - sizeof(struct vmbus_channel_packet_page_buffer), 218 - sizeof(struct vmbus_channel_packet_multipage_buffer)); 219 - 220 - driver->name = gDriverName; 221 - memcpy(&driver->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid)); 222 - 223 - /* Setup dispatch table */ 224 - driver->OnDeviceAdd = VmbusOnDeviceAdd; 225 - driver->OnDeviceRemove = VmbusOnDeviceRemove; 226 - driver->OnCleanup = VmbusOnCleanup; 227 - 228 - /* Hypervisor initialization...setup hypercall page..etc */ 229 - ret = hv_init(); 230 - if (ret != 0) 231 - DPRINT_ERR(VMBUS, "Unable to initialize the hypervisor - 0x%x", 232 - ret); 233 - gDriver = driver; 234 - 235 - return ret; 236 - }
+209
drivers/staging/hv/vmbus_drv.c
··· 33 33 #include "logging.h" 34 34 #include "vmbus.h" 35 35 #include "channel.h" 36 + #include "vmbus_private.h" 36 37 37 38 38 39 /* FIXME! We need to do this dynamically for PIC and APIC system */ ··· 122 121 .bus.uevent = vmbus_uevent, 123 122 .bus.dev_attrs = vmbus_device_attrs, 124 123 }; 124 + 125 + static const char *gDriverName = "hyperv"; 126 + 127 + /* 128 + * Windows vmbus does not defined this. 129 + * We defined this to be consistent with other devices 130 + */ 131 + /* {c5295816-f63a-4d5f-8d1a-4daf999ca185} */ 132 + static const struct hv_guid gVmbusDeviceType = { 133 + .data = { 134 + 0x16, 0x58, 0x29, 0xc5, 0x3a, 0xf6, 0x5f, 0x4d, 135 + 0x8d, 0x1a, 0x4d, 0xaf, 0x99, 0x9c, 0xa1, 0x85 136 + } 137 + }; 138 + 139 + /* {ac3760fc-9adf-40aa-9427-a70ed6de95c5} */ 140 + static const struct hv_guid gVmbusDeviceId = { 141 + .data = { 142 + 0xfc, 0x60, 0x37, 0xac, 0xdf, 0x9a, 0xaa, 0x40, 143 + 0x94, 0x27, 0xa7, 0x0e, 0xd6, 0xde, 0x95, 0xc5 144 + } 145 + }; 146 + 147 + static struct hv_driver *gDriver; /* vmbus driver object */ 148 + static struct hv_device *gDevice; /* vmbus root device */ 149 + 150 + /* 151 + * VmbusChildDeviceAdd - Registers the child device with the vmbus 152 + */ 153 + int VmbusChildDeviceAdd(struct hv_device *ChildDevice) 154 + { 155 + return vmbus_child_device_register(gDevice, ChildDevice); 156 + } 157 + 158 + /* 159 + * VmbusOnDeviceAdd - Callback when the root bus device is added 160 + */ 161 + static int VmbusOnDeviceAdd(struct hv_device *dev, void *AdditionalInfo) 162 + { 163 + u32 *irqvector = AdditionalInfo; 164 + int ret; 165 + 166 + gDevice = dev; 167 + 168 + memcpy(&gDevice->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid)); 169 + memcpy(&gDevice->deviceInstance, &gVmbusDeviceId, 170 + sizeof(struct hv_guid)); 171 + 172 + /* strcpy(dev->name, "vmbus"); */ 173 + /* SynIC setup... */ 174 + on_each_cpu(hv_synic_init, (void *)irqvector, 1); 175 + 176 + /* Connect to VMBus in the root partition */ 177 + ret = VmbusConnect(); 178 + 179 + /* VmbusSendEvent(device->localPortId+1); */ 180 + return ret; 181 + } 182 + 183 + /* 184 + * VmbusOnDeviceRemove - Callback when the root bus device is removed 185 + */ 186 + static int VmbusOnDeviceRemove(struct hv_device *dev) 187 + { 188 + int ret = 0; 189 + 190 + vmbus_release_unattached_channels(); 191 + VmbusDisconnect(); 192 + on_each_cpu(hv_synic_cleanup, NULL, 1); 193 + return ret; 194 + } 195 + 196 + /* 197 + * VmbusOnCleanup - Perform any cleanup when the driver is removed 198 + */ 199 + static void VmbusOnCleanup(struct hv_driver *drv) 200 + { 201 + /* struct vmbus_driver *driver = (struct vmbus_driver *)drv; */ 202 + 203 + hv_cleanup(); 204 + } 205 + 206 + /* 207 + * vmbus_on_msg_dpc - DPC routine to handle messages from the hypervisior 208 + */ 209 + void vmbus_on_msg_dpc(struct hv_driver *drv) 210 + { 211 + int cpu = smp_processor_id(); 212 + void *page_addr = hv_context.synic_message_page[cpu]; 213 + struct hv_message *msg = (struct hv_message *)page_addr + 214 + VMBUS_MESSAGE_SINT; 215 + struct hv_message *copied; 216 + 217 + while (1) { 218 + if (msg->header.message_type == HVMSG_NONE) { 219 + /* no msg */ 220 + break; 221 + } else { 222 + copied = kmemdup(msg, sizeof(*copied), GFP_ATOMIC); 223 + if (copied == NULL) 224 + continue; 225 + 226 + osd_schedule_callback(gVmbusConnection.WorkQueue, 227 + vmbus_onmessage, 228 + (void *)copied); 229 + } 230 + 231 + msg->header.message_type = HVMSG_NONE; 232 + 233 + /* 234 + * Make sure the write to MessageType (ie set to 235 + * HVMSG_NONE) happens before we read the 236 + * MessagePending and EOMing. Otherwise, the EOMing 237 + * will not deliver any more messages since there is 238 + * no empty slot 239 + */ 240 + mb(); 241 + 242 + if (msg->header.message_flags.msg_pending) { 243 + /* 244 + * This will cause message queue rescan to 245 + * possibly deliver another msg from the 246 + * hypervisor 247 + */ 248 + wrmsrl(HV_X64_MSR_EOM, 0); 249 + } 250 + } 251 + } 252 + 253 + /* 254 + * vmbus_on_event_dpc - DPC routine to handle events from the hypervisior 255 + */ 256 + void vmbus_on_event_dpc(struct hv_driver *drv) 257 + { 258 + /* TODO: Process any events */ 259 + VmbusOnEvents(); 260 + } 261 + 262 + /* 263 + * vmbus_on_isr - ISR routine 264 + */ 265 + int vmbus_on_isr(struct hv_driver *drv) 266 + { 267 + int ret = 0; 268 + int cpu = smp_processor_id(); 269 + void *page_addr; 270 + struct hv_message *msg; 271 + union hv_synic_event_flags *event; 272 + 273 + page_addr = hv_context.synic_message_page[cpu]; 274 + msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT; 275 + 276 + /* Check if there are actual msgs to be process */ 277 + if (msg->header.message_type != HVMSG_NONE) { 278 + DPRINT_DBG(VMBUS, "received msg type %d size %d", 279 + msg->header.message_type, 280 + msg->header.payload_size); 281 + ret |= 0x1; 282 + } 283 + 284 + /* TODO: Check if there are events to be process */ 285 + page_addr = hv_context.synic_event_page[cpu]; 286 + event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT; 287 + 288 + /* Since we are a child, we only need to check bit 0 */ 289 + if (test_and_clear_bit(0, (unsigned long *) &event->flags32[0])) { 290 + DPRINT_DBG(VMBUS, "received event %d", event->flags32[0]); 291 + ret |= 0x2; 292 + } 293 + 294 + return ret; 295 + } 296 + 297 + /* 298 + * VmbusInitialize - Main entry point 299 + */ 300 + int VmbusInitialize(struct hv_driver *driver) 301 + { 302 + int ret; 303 + 304 + DPRINT_INFO(VMBUS, "+++++++ HV Driver version = %s +++++++", 305 + HV_DRV_VERSION); 306 + DPRINT_INFO(VMBUS, "+++++++ Vmbus supported version = %d +++++++", 307 + VMBUS_REVISION_NUMBER); 308 + DPRINT_INFO(VMBUS, "+++++++ Vmbus using SINT %d +++++++", 309 + VMBUS_MESSAGE_SINT); 310 + DPRINT_DBG(VMBUS, "sizeof(vmbus_channel_packet_page_buffer)=%zd, " 311 + "sizeof(VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER)=%zd", 312 + sizeof(struct vmbus_channel_packet_page_buffer), 313 + sizeof(struct vmbus_channel_packet_multipage_buffer)); 314 + 315 + driver->name = gDriverName; 316 + memcpy(&driver->deviceType, &gVmbusDeviceType, sizeof(struct hv_guid)); 317 + 318 + /* Setup dispatch table */ 319 + driver->OnDeviceAdd = VmbusOnDeviceAdd; 320 + driver->OnDeviceRemove = VmbusOnDeviceRemove; 321 + driver->OnCleanup = VmbusOnCleanup; 322 + 323 + /* Hypervisor initialization...setup hypercall page..etc */ 324 + ret = hv_init(); 325 + if (ret != 0) 326 + DPRINT_ERR(VMBUS, "Unable to initialize the hypervisor - 0x%x", 327 + ret); 328 + gDriver = driver; 329 + 330 + return ret; 331 + } 125 332 126 333 static void get_channel_info(struct hv_device *device, 127 334 struct hv_device_info *info)