aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hv
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-13 14:32:55 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-26 12:01:16 -0400
commit8681db445ed407167cd0d78c48727773b132367b (patch)
tree70cb5d80249c0718e9bc789b2a9ffa0b68101e50 /drivers/hv
parent7c55e1d0e64cf5acd8cf4a25927e2c7c322063aa (diff)
hv: make "monitor_pages" a "real" pointer array
monitor_pages was a void pointer, containing an unknown number of arrays that we just "knew" were a child and parent array of a specific size. Instead of that implicit knowledge, let's make them a real pointer, allowing us to have type safety, and a semblance of sane addressing schemes. Tested-by: "K. Y. Srinivasan" <kys@microsoft.com> Cc: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hv')
-rw-r--r--drivers/hv/channel.c10
-rw-r--r--drivers/hv/connection.c21
-rw-r--r--drivers/hv/hyperv_vmbus.h2
3 files changed, 15 insertions, 18 deletions
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index dde30b48c56c..04bf06560085 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -47,8 +47,8 @@ static void vmbus_setevent(struct vmbus_channel *channel)
47 (unsigned long *) vmbus_connection.send_int_page + 47 (unsigned long *) vmbus_connection.send_int_page +
48 (channel->offermsg.child_relid >> 5)); 48 (channel->offermsg.child_relid >> 5));
49 49
50 monitorpage = vmbus_connection.monitor_pages; 50 /* Get the child to parent monitor page */
51 monitorpage++; /* Get the child to parent monitor page */ 51 monitorpage = vmbus_connection.monitor_pages[1];
52 52
53 sync_set_bit(channel->monitor_bit, 53 sync_set_bit(channel->monitor_bit,
54 (unsigned long *)&monitorpage->trigger_group 54 (unsigned long *)&monitorpage->trigger_group
@@ -69,8 +69,7 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
69 u8 monitor_group = (u8)channel->offermsg.monitorid / 32; 69 u8 monitor_group = (u8)channel->offermsg.monitorid / 32;
70 u8 monitor_offset = (u8)channel->offermsg.monitorid % 32; 70 u8 monitor_offset = (u8)channel->offermsg.monitorid % 32;
71 71
72 monitorpage = (struct hv_monitor_page *)vmbus_connection.monitor_pages; 72 monitorpage = vmbus_connection.monitor_pages[0];
73
74 debuginfo->servermonitor_pending = 73 debuginfo->servermonitor_pending =
75 monitorpage->trigger_group[monitor_group].pending; 74 monitorpage->trigger_group[monitor_group].pending;
76 debuginfo->servermonitor_latency = 75 debuginfo->servermonitor_latency =
@@ -79,8 +78,7 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
79 monitorpage->parameter[monitor_group] 78 monitorpage->parameter[monitor_group]
80 [monitor_offset].connectionid.u.id; 79 [monitor_offset].connectionid.u.id;
81 80
82 monitorpage++; 81 monitorpage = vmbus_connection.monitor_pages[1];
83
84 debuginfo->clientmonitor_pending = 82 debuginfo->clientmonitor_pending =
85 monitorpage->trigger_group[monitor_group].pending; 83 monitorpage->trigger_group[monitor_group].pending;
86 debuginfo->clientmonitor_latency = 84 debuginfo->clientmonitor_latency =
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 8f4743ab5fb2..4faea979975e 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -76,10 +76,8 @@ static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo,
76 msg->header.msgtype = CHANNELMSG_INITIATE_CONTACT; 76 msg->header.msgtype = CHANNELMSG_INITIATE_CONTACT;
77 msg->vmbus_version_requested = version; 77 msg->vmbus_version_requested = version;
78 msg->interrupt_page = virt_to_phys(vmbus_connection.int_page); 78 msg->interrupt_page = virt_to_phys(vmbus_connection.int_page);
79 msg->monitor_page1 = virt_to_phys(vmbus_connection.monitor_pages); 79 msg->monitor_page1 = virt_to_phys(vmbus_connection.monitor_pages[0]);
80 msg->monitor_page2 = virt_to_phys( 80 msg->monitor_page2 = virt_to_phys(vmbus_connection.monitor_pages[1]);
81 (void *)((unsigned long)vmbus_connection.monitor_pages +
82 PAGE_SIZE));
83 81
84 /* 82 /*
85 * Add to list before we send the request since we may 83 * Add to list before we send the request since we may
@@ -169,9 +167,10 @@ int vmbus_connect(void)
169 * Setup the monitor notification facility. The 1st page for 167 * Setup the monitor notification facility. The 1st page for
170 * parent->child and the 2nd page for child->parent 168 * parent->child and the 2nd page for child->parent
171 */ 169 */
172 vmbus_connection.monitor_pages = 170 vmbus_connection.monitor_pages[0] = (void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 0);
173 (void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 1); 171 vmbus_connection.monitor_pages[1] = (void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 0);
174 if (vmbus_connection.monitor_pages == NULL) { 172 if ((vmbus_connection.monitor_pages[0] == NULL) ||
173 (vmbus_connection.monitor_pages[1] == NULL)) {
175 ret = -ENOMEM; 174 ret = -ENOMEM;
176 goto cleanup; 175 goto cleanup;
177 } 176 }
@@ -229,10 +228,10 @@ cleanup:
229 vmbus_connection.int_page = NULL; 228 vmbus_connection.int_page = NULL;
230 } 229 }
231 230
232 if (vmbus_connection.monitor_pages) { 231 free_pages((unsigned long)vmbus_connection.monitor_pages[0], 1);
233 free_pages((unsigned long)vmbus_connection.monitor_pages, 1); 232 free_pages((unsigned long)vmbus_connection.monitor_pages[1], 1);
234 vmbus_connection.monitor_pages = NULL; 233 vmbus_connection.monitor_pages[0] = NULL;
235 } 234 vmbus_connection.monitor_pages[1] = NULL;
236 235
237 kfree(msginfo); 236 kfree(msginfo);
238 237
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index d84918fe19ab..d58c22ffb29a 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -612,7 +612,7 @@ struct vmbus_connection {
612 * 2 pages - 1st page for parent->child notification and 2nd 612 * 2 pages - 1st page for parent->child notification and 2nd
613 * is child->parent notification 613 * is child->parent notification
614 */ 614 */
615 void *monitor_pages; 615 struct hv_monitor_page *monitor_pages[2];
616 struct list_head chn_msg_list; 616 struct list_head chn_msg_list;
617 spinlock_t channelmsg_lock; 617 spinlock_t channelmsg_lock;
618 618