]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.13.9/vmbus-eliminate-duplicate-cached-index.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.13.9 / vmbus-eliminate-duplicate-cached-index.patch
1 From 05d00bc94ac27d220d8a78e365d7fa3a26dcca17 Mon Sep 17 00:00:00 2001
2 From: Stephen Hemminger <stephen@networkplumber.org>
3 Date: Sun, 25 Jun 2017 12:30:27 -0700
4 Subject: vmbus: eliminate duplicate cached index
5
6 From: Stephen Hemminger <stephen@networkplumber.org>
7
8 commit 05d00bc94ac27d220d8a78e365d7fa3a26dcca17 upstream.
9
10 Don't need cached read index anymore now that packet iterator
11 is used. The iterator has the original read index until the
12 visible read_index is updated.
13
14 Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
15 Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
16 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17
18 ---
19 drivers/hv/ring_buffer.c | 17 ++++-------------
20 include/linux/hyperv.h | 14 --------------
21 2 files changed, 4 insertions(+), 27 deletions(-)
22
23 --- a/drivers/hv/ring_buffer.c
24 +++ b/drivers/hv/ring_buffer.c
25 @@ -358,9 +358,6 @@ struct vmpacket_descriptor *hv_pkt_iter_
26 {
27 struct hv_ring_buffer_info *rbi = &channel->inbound;
28
29 - /* set state for later hv_pkt_iter_close */
30 - rbi->cached_read_index = rbi->ring_buffer->read_index;
31 -
32 if (hv_pkt_iter_avail(rbi) < sizeof(struct vmpacket_descriptor))
33 return NULL;
34
35 @@ -388,10 +385,7 @@ __hv_pkt_iter_next(struct vmbus_channel
36 rbi->priv_read_index -= dsize;
37
38 /* more data? */
39 - if (hv_pkt_iter_avail(rbi) < sizeof(struct vmpacket_descriptor))
40 - return NULL;
41 - else
42 - return hv_get_ring_buffer(rbi) + rbi->priv_read_index;
43 + return hv_pkt_iter_first(channel);
44 }
45 EXPORT_SYMBOL_GPL(__hv_pkt_iter_next);
46
47 @@ -401,7 +395,7 @@ EXPORT_SYMBOL_GPL(__hv_pkt_iter_next);
48 void hv_pkt_iter_close(struct vmbus_channel *channel)
49 {
50 struct hv_ring_buffer_info *rbi = &channel->inbound;
51 - u32 cur_write_sz, cached_write_sz;
52 + u32 orig_write_sz = hv_get_bytes_to_write(rbi);
53 u32 pending_sz;
54
55 /*
56 @@ -430,13 +424,10 @@ void hv_pkt_iter_close(struct vmbus_chan
57 if (pending_sz == 0)
58 return;
59
60 - cur_write_sz = hv_get_bytes_to_write(rbi);
61 -
62 - if (cur_write_sz < pending_sz)
63 + if (hv_get_bytes_to_write(rbi) < pending_sz)
64 return;
65
66 - cached_write_sz = hv_get_cached_bytes_to_write(rbi);
67 - if (cached_write_sz < pending_sz)
68 + if (orig_write_sz < pending_sz)
69 vmbus_setevent(channel);
70 }
71 EXPORT_SYMBOL_GPL(hv_pkt_iter_close);
72 --- a/include/linux/hyperv.h
73 +++ b/include/linux/hyperv.h
74 @@ -127,7 +127,6 @@ struct hv_ring_buffer_info {
75 u32 ring_data_startoffset;
76 u32 priv_write_index;
77 u32 priv_read_index;
78 - u32 cached_read_index;
79 };
80
81 /*
82 @@ -180,19 +179,6 @@ static inline u32 hv_get_bytes_to_write(
83 return write;
84 }
85
86 -static inline u32 hv_get_cached_bytes_to_write(
87 - const struct hv_ring_buffer_info *rbi)
88 -{
89 - u32 read_loc, write_loc, dsize, write;
90 -
91 - dsize = rbi->ring_datasize;
92 - read_loc = rbi->cached_read_index;
93 - write_loc = rbi->ring_buffer->write_index;
94 -
95 - write = write_loc >= read_loc ? dsize - (write_loc - read_loc) :
96 - read_loc - write_loc;
97 - return write;
98 -}
99 /*
100 * VMBUS version is 32 bit entity broken up into
101 * two 16 bit quantities: major_number. minor_number.