fate#314663 hyper-v memory ballooning support
[opensuse:kernel-source.git] / patches.suse / suse-hv-fate314665-0014-Drivers-hv-Manage-signaling-state-on-a-per-connectio.patch
1 Patch-mainline: submitted
2 From: <ohering@suse.de>
3 Date: Sat, 1 Dec 2012 06:46:45 -0800
4 Subject: [PATCH 14/28] Drivers: hv: Manage signaling state on a per-connection
5  basis
6
7 The current code has a global handle for supporting signaling of the host
8 from guest. Make this a per-channel attribute as on some versions of the
9 host we can signal on per-channel handle.
10
11 Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
12 Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
13 ---
14  drivers/hv/channel_mgmt.c | 20 ++++++++++++++++++++
15  drivers/hv/hyperv_vmbus.h | 21 ---------------------
16  include/linux/hyperv.h    | 25 +++++++++++++++++++++++++
17  3 files changed, 45 insertions(+), 21 deletions(-)
18
19 diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
20 index e4a128a..bf5b56a 100644
21 --- a/drivers/hv/channel_mgmt.c
22 +++ b/drivers/hv/channel_mgmt.c
23 @@ -287,6 +287,26 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
24          */
25         newchannel->batched_reading = true;
26  
27 +       /*
28 +        * Setup state for signalling the host.
29 +        */
30 +       newchannel->sig_event = (struct hv_input_signal_event *)
31 +                               (ALIGN((unsigned long)
32 +                               &newchannel->sig_buf,
33 +                               HV_HYPERCALL_PARAM_ALIGN));
34 +
35 +       newchannel->sig_event->connectionid.asu32 = 0;
36 +       newchannel->sig_event->connectionid.u.id = VMBUS_EVENT_CONNECTION_ID;
37 +       newchannel->sig_event->flag_number = 0;
38 +       newchannel->sig_event->rsvdz = 0;
39 +
40 +       if (vmbus_proto_version != VERSION_WS2008) {
41 +               newchannel->is_dedicated_interrupt =
42 +                               (offer->is_dedicated_interrupt != 0);
43 +               newchannel->sig_event->connectionid.u.id =
44 +                               offer->connection_id;
45 +       }
46 +
47         memcpy(&newchannel->offermsg, offer,
48                sizeof(struct vmbus_channel_offer_channel));
49         newchannel->monitor_grp = (u8)offer->monitorid / 32;
50 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
51 index cd48ac3..1bc7500 100644
52 --- a/drivers/hv/hyperv_vmbus.h
53 +++ b/drivers/hv/hyperv_vmbus.h
54 @@ -101,15 +101,6 @@ enum hv_message_type {
55  /* Define invalid partition identifier. */
56  #define HV_PARTITION_ID_INVALID                ((u64)0x0)
57  
58 -/* Define connection identifier type. */
59 -union hv_connection_id {
60 -       u32 asu32;
61 -       struct {
62 -               u32 id:24;
63 -               u32 reserved:8;
64 -       } u;
65 -};
66 -
67  /* Define port identifier type. */
68  union hv_port_id {
69         u32 asu32;
70 @@ -338,13 +329,6 @@ struct hv_input_post_message {
71         u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
72  };
73  
74 -/* Definition of the hv_signal_event hypercall input structure. */
75 -struct hv_input_signal_event {
76 -       union hv_connection_id connectionid;
77 -       u16 flag_number;
78 -       u16 rsvdz;
79 -};
80 -
81  /*
82   * Versioning definitions used for guests reporting themselves to the
83   * hypervisor, and visa versa.
84 @@ -498,11 +482,6 @@ static const uuid_le VMBUS_SERVICE_ID = {
85  
86  
87  
88 -struct hv_input_signal_event_buffer {
89 -       u64 align8;
90 -       struct hv_input_signal_event event;
91 -};
92 -
93  struct hv_context {
94         /* We only support running on top of Hyper-V
95         * So at this point this really can only contain the Hyper-V ID
96 diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
97 index e725026..c6e2c44 100644
98 --- a/include/linux/hyperv.h
99 +++ b/include/linux/hyperv.h
100 @@ -897,6 +897,27 @@ struct vmbus_close_msg {
101         struct vmbus_channel_close_channel msg;
102  };
103  
104 +/* Define connection identifier type. */
105 +union hv_connection_id {
106 +       u32 asu32;
107 +       struct {
108 +               u32 id:24;
109 +               u32 reserved:8;
110 +       } u;
111 +};
112 +
113 +/* Definition of the hv_signal_event hypercall input structure. */
114 +struct hv_input_signal_event {
115 +       union hv_connection_id connectionid;
116 +       u16 flag_number;
117 +       u16 rsvdz;
118 +};
119 +
120 +struct hv_input_signal_event_buffer {
121 +       u64 align8;
122 +       struct hv_input_signal_event event;
123 +};
124 +
125  struct vmbus_channel {
126         struct list_head listentry;
127  
128 @@ -946,6 +967,10 @@ struct vmbus_channel {
129          */
130  
131         bool batched_reading;
132 +
133 +       bool is_dedicated_interrupt;
134 +       struct hv_input_signal_event_buffer sig_buf;
135 +       struct hv_input_signal_event *sig_event;
136  };
137  
138  static inline void set_channel_read_state(struct vmbus_channel *c, bool state)
139 -- 
140 1.8.0.1
141