Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 May 2016 07:14:04 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300481 - head/sys/dev/hyperv/vmbus
Message-ID:  <201605230714.u4N7E4LE022665@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Mon May 23 07:14:04 2016
New Revision: 300481
URL: https://svnweb.freebsd.org/changeset/base/300481

Log:
  hyperv/vmbus: Declare Synic message and event w/ proper types
  
  Avoid ugly casts.
  
  MFC after:	1 week
  Sponsored by:	Microsoft OSTC
  Differential Revision:	https://reviews.freebsd.org/D6446

Modified:
  head/sys/dev/hyperv/vmbus/hv_connection.c
  head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
  head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h

Modified: head/sys/dev/hyperv/vmbus/hv_connection.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_connection.c	Mon May 23 07:06:53 2016	(r300480)
+++ head/sys/dev/hyperv/vmbus/hv_connection.c	Mon May 23 07:14:04 2016	(r300481)
@@ -333,8 +333,8 @@ vmbus_event_proc(struct vmbus_softc *sc,
 {
 	hv_vmbus_synic_event_flags *event;
 
-	event = ((hv_vmbus_synic_event_flags *)
-	    hv_vmbus_g_context.syn_ic_event_page[cpu]) + HV_VMBUS_MESSAGE_SINT;
+	event = hv_vmbus_g_context.syn_ic_event_page[cpu] +
+	    HV_VMBUS_MESSAGE_SINT;
 
 	/*
 	 * On Host with Win8 or above, the event page can be checked directly
@@ -349,8 +349,8 @@ vmbus_event_proc_compat(struct vmbus_sof
 {
 	hv_vmbus_synic_event_flags *event;
 
-	event = ((hv_vmbus_synic_event_flags *)
-	    hv_vmbus_g_context.syn_ic_event_page[cpu]) + HV_VMBUS_MESSAGE_SINT;
+	event = hv_vmbus_g_context.syn_ic_event_page[cpu] +
+	    HV_VMBUS_MESSAGE_SINT;
 
 	if (atomic_testandclear_int(&event->flags32[0], 0)) {
 		vmbus_event_flags_proc(

Modified: head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c	Mon May 23 07:06:53 2016	(r300480)
+++ head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c	Mon May 23 07:14:04 2016	(r300481)
@@ -79,8 +79,9 @@ vmbus_msg_task(void *arg __unused, int p
 {
 	hv_vmbus_message *msg;
 
-	msg = ((hv_vmbus_message *)hv_vmbus_g_context.syn_ic_msg_page[curcpu]) +
+	msg = hv_vmbus_g_context.syn_ic_msg_page[curcpu] +
 	    HV_VMBUS_MESSAGE_SINT;
+
 	for (;;) {
 		const hv_vmbus_channel_msg_table_entry *entry;
 		hv_vmbus_channel_msg_header *hdr;
@@ -134,9 +135,8 @@ static inline int
 hv_vmbus_isr(struct trapframe *frame)
 {
 	struct vmbus_softc *sc = vmbus_get_softc();
+	hv_vmbus_message *msg, *msg_base;
 	int cpu = curcpu;
-	hv_vmbus_message *msg;
-	void *page_addr;
 
 	/*
 	 * The Windows team has advised that we check for events
@@ -146,8 +146,8 @@ hv_vmbus_isr(struct trapframe *frame)
 	sc->vmbus_event_proc(sc, cpu);
 
 	/* Check if there are actual msgs to be process */
-	page_addr = hv_vmbus_g_context.syn_ic_msg_page[cpu];
-	msg = ((hv_vmbus_message *)page_addr) + HV_VMBUS_TIMER_SINT;
+	msg_base = hv_vmbus_g_context.syn_ic_msg_page[cpu];
+	msg = msg_base + HV_VMBUS_TIMER_SINT;
 
 	/* we call eventtimer process the message */
 	if (msg->header.message_type == HV_MESSAGE_TIMER_EXPIRED) {
@@ -178,7 +178,7 @@ hv_vmbus_isr(struct trapframe *frame)
 		}
 	}
 
-	msg = ((hv_vmbus_message *)page_addr) + HV_VMBUS_MESSAGE_SINT;
+	msg = msg_base + HV_VMBUS_MESSAGE_SINT;
 	if (msg->header.message_type != HV_MESSAGE_TYPE_NONE) {
 		taskqueue_enqueue(hv_vmbus_g_context.hv_msg_tq[cpu],
 		    &hv_vmbus_g_context.hv_msg_task[cpu]);

Modified: head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h	Mon May 23 07:06:53 2016	(r300480)
+++ head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h	Mon May 23 07:14:04 2016	(r300481)
@@ -197,11 +197,14 @@ enum {
 
 #define HV_HYPERCALL_PARAM_ALIGN sizeof(uint64_t)
 
+struct vmbus_message;
+union vmbus_event_flags;
+
 typedef struct {
 	hv_bool_uint8_t	syn_ic_initialized;
 
-	hv_vmbus_handle	syn_ic_msg_page[MAXCPU];
-	hv_vmbus_handle	syn_ic_event_page[MAXCPU];
+	struct vmbus_message	*syn_ic_msg_page[MAXCPU];
+	union vmbus_event_flags	*syn_ic_event_page[MAXCPU];
 	/*
 	 * For FreeBSD cpuid to Hyper-V vcpuid mapping.
 	 */
@@ -303,7 +306,7 @@ typedef struct {
 /*
  *  Define synthetic interrupt controller message format
  */
-typedef struct {
+typedef struct vmbus_message {
 	hv_vmbus_msg_header	header;
 	union {
 		uint64_t	payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
@@ -578,7 +581,7 @@ typedef struct {
 /*
  * Define the synthetic interrupt controller event flags format
  */
-typedef union {
+typedef union vmbus_event_flags {
 	uint8_t		flags8[HV_EVENT_FLAGS_BYTE_COUNT];
 	uint32_t	flags32[HV_EVENT_FLAGS_DWORD_COUNT];
 	unsigned long	flagsul[HV_EVENT_FLAGS_ULONG_COUNT];



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605230714.u4N7E4LE022665>