public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: kys@microsoft.com, haiyangz@microsoft.com
Cc: devel@linuxdriverproject.org, linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH 07/13] hv: make "monitor_pages" a "real" pointer array
Date: Fri, 13 Sep 2013 11:32:55 -0700	[thread overview]
Message-ID: <1379097181-23407-8-git-send-email-gregkh@linuxfoundation.org> (raw)
In-Reply-To: <1379097181-23407-1-git-send-email-gregkh@linuxfoundation.org>

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.

Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/hv/channel.c      | 10 ++++------
 drivers/hv/connection.c   | 21 ++++++++++-----------
 drivers/hv/hyperv_vmbus.h |  2 +-
 3 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index dde30b48..04bf0656 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -47,8 +47,8 @@ static void vmbus_setevent(struct vmbus_channel *channel)
 			(unsigned long *) vmbus_connection.send_int_page +
 			(channel->offermsg.child_relid >> 5));
 
-		monitorpage = vmbus_connection.monitor_pages;
-		monitorpage++; /* Get the child to parent monitor page */
+		/* Get the child to parent monitor page */
+		monitorpage = vmbus_connection.monitor_pages[1];
 
 		sync_set_bit(channel->monitor_bit,
 			(unsigned long *)&monitorpage->trigger_group
@@ -69,8 +69,7 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
 	u8 monitor_group = (u8)channel->offermsg.monitorid / 32;
 	u8 monitor_offset = (u8)channel->offermsg.monitorid % 32;
 
-	monitorpage = (struct hv_monitor_page *)vmbus_connection.monitor_pages;
-
+	monitorpage = vmbus_connection.monitor_pages[0];
 	debuginfo->servermonitor_pending =
 			monitorpage->trigger_group[monitor_group].pending;
 	debuginfo->servermonitor_latency =
@@ -79,8 +78,7 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
 			monitorpage->parameter[monitor_group]
 					[monitor_offset].connectionid.u.id;
 
-	monitorpage++;
-
+	monitorpage = vmbus_connection.monitor_pages[1];
 	debuginfo->clientmonitor_pending =
 			monitorpage->trigger_group[monitor_group].pending;
 	debuginfo->clientmonitor_latency =
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 8f4743ab..4faea979 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,
 	msg->header.msgtype = CHANNELMSG_INITIATE_CONTACT;
 	msg->vmbus_version_requested = version;
 	msg->interrupt_page = virt_to_phys(vmbus_connection.int_page);
-	msg->monitor_page1 = virt_to_phys(vmbus_connection.monitor_pages);
-	msg->monitor_page2 = virt_to_phys(
-			(void *)((unsigned long)vmbus_connection.monitor_pages +
-				 PAGE_SIZE));
+	msg->monitor_page1 = virt_to_phys(vmbus_connection.monitor_pages[0]);
+	msg->monitor_page2 = virt_to_phys(vmbus_connection.monitor_pages[1]);
 
 	/*
 	 * Add to list before we send the request since we may
@@ -169,9 +167,10 @@ int vmbus_connect(void)
 	 * Setup the monitor notification facility. The 1st page for
 	 * parent->child and the 2nd page for child->parent
 	 */
-	vmbus_connection.monitor_pages =
-	(void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 1);
-	if (vmbus_connection.monitor_pages == NULL) {
+	vmbus_connection.monitor_pages[0] = (void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 0);
+	vmbus_connection.monitor_pages[1] = (void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 0);
+	if ((vmbus_connection.monitor_pages[0] == NULL) ||
+	    (vmbus_connection.monitor_pages[1] == NULL)) {
 		ret = -ENOMEM;
 		goto cleanup;
 	}
@@ -229,10 +228,10 @@ cleanup:
 		vmbus_connection.int_page = NULL;
 	}
 
-	if (vmbus_connection.monitor_pages) {
-		free_pages((unsigned long)vmbus_connection.monitor_pages, 1);
-		vmbus_connection.monitor_pages = NULL;
-	}
+	free_pages((unsigned long)vmbus_connection.monitor_pages[0], 1);
+	free_pages((unsigned long)vmbus_connection.monitor_pages[1], 1);
+	vmbus_connection.monitor_pages[0] = NULL;
+	vmbus_connection.monitor_pages[1] = NULL;
 
 	kfree(msginfo);
 
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index d84918fe..d58c22ff 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -612,7 +612,7 @@ struct vmbus_connection {
 	 * 2 pages - 1st page for parent->child notification and 2nd
 	 * is child->parent notification
 	 */
-	void *monitor_pages;
+	struct hv_monitor_page *monitor_pages[2];
 	struct list_head chn_msg_list;
 	spinlock_t channelmsg_lock;
 
-- 
1.8.4.3.gca3854a


  parent reply	other threads:[~2013-09-13 18:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-13 18:32 [PATCH 00/13] hv: clean up dev_attr usage Greg Kroah-Hartman
2013-09-13 18:32 ` [PATCH 01/13] hv: use dev_groups for device attributes Greg Kroah-Hartman
2013-09-13 18:32 ` [PATCH 02/13] hv: move "state" bus attribute to dev_groups Greg Kroah-Hartman
2013-09-13 18:32 ` [PATCH 03/13] hv: move "monitor_id" " Greg Kroah-Hartman
2013-09-13 18:32 ` [PATCH 04/13] hv: move "modalias" " Greg Kroah-Hartman
2013-09-13 18:32 ` [PATCH 05/13] hv: move "class_id" " Greg Kroah-Hartman
2013-09-13 18:32 ` [PATCH 06/13] hv: move "device_id" " Greg Kroah-Hartman
2013-09-13 18:32 ` Greg Kroah-Hartman [this message]
2013-09-13 18:32 ` [PATCH 08/13] hv: move "client/server_monitor_pending" bus attributes " Greg Kroah-Hartman
2013-09-13 18:32 ` [PATCH 09/13] hv: move "client/server_monitor_latency" " Greg Kroah-Hartman
2013-09-13 18:32 ` [PATCH 10/13] hv: move "client/server_monitor_conn_id" " Greg Kroah-Hartman
2013-09-13 18:32 ` [PATCH 11/13] hv: delete vmbus_get_debug_info() Greg Kroah-Hartman
2013-09-13 18:33 ` [PATCH 12/13] hv: delete struct hv_dev_port_info Greg Kroah-Hartman
2013-09-13 18:33 ` [PATCH 13/13] hv: move ringbuffer bus attributes to dev_groups Greg Kroah-Hartman
2013-09-13 19:13 ` [PATCH 00/13] hv: clean up dev_attr usage KY Srinivasan
2013-09-17 18:42 ` KY Srinivasan
2013-09-26 15:59   ` Greg Kroah-Hartman
2013-09-26 22:36     ` KY Srinivasan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379097181-23407-8-git-send-email-gregkh@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=devel@linuxdriverproject.org \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox