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
6 From: Stephen Hemminger <stephen@networkplumber.org>
8 commit 05d00bc94ac27d220d8a78e365d7fa3a26dcca17 upstream.
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.
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>
19 drivers/hv/ring_buffer.c | 17 ++++-------------
20 include/linux/hyperv.h | 14 --------------
21 2 files changed, 4 insertions(+), 27 deletions(-)
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_
27 struct hv_ring_buffer_info *rbi = &channel->inbound;
29 - /* set state for later hv_pkt_iter_close */
30 - rbi->cached_read_index = rbi->ring_buffer->read_index;
32 if (hv_pkt_iter_avail(rbi) < sizeof(struct vmpacket_descriptor))
35 @@ -388,10 +385,7 @@ __hv_pkt_iter_next(struct vmbus_channel
36 rbi->priv_read_index -= dsize;
39 - if (hv_pkt_iter_avail(rbi) < sizeof(struct vmpacket_descriptor))
42 - return hv_get_ring_buffer(rbi) + rbi->priv_read_index;
43 + return hv_pkt_iter_first(channel);
45 EXPORT_SYMBOL_GPL(__hv_pkt_iter_next);
47 @@ -401,7 +395,7 @@ EXPORT_SYMBOL_GPL(__hv_pkt_iter_next);
48 void hv_pkt_iter_close(struct vmbus_channel *channel)
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);
56 @@ -430,13 +424,10 @@ void hv_pkt_iter_close(struct vmbus_chan
60 - cur_write_sz = hv_get_bytes_to_write(rbi);
62 - if (cur_write_sz < pending_sz)
63 + if (hv_get_bytes_to_write(rbi) < pending_sz)
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);
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;
78 - u32 cached_read_index;
82 @@ -180,19 +179,6 @@ static inline u32 hv_get_bytes_to_write(
86 -static inline u32 hv_get_cached_bytes_to_write(
87 - const struct hv_ring_buffer_info *rbi)
89 - u32 read_loc, write_loc, dsize, write;
91 - dsize = rbi->ring_datasize;
92 - read_loc = rbi->cached_read_index;
93 - write_loc = rbi->ring_buffer->write_index;
95 - write = write_loc >= read_loc ? dsize - (write_loc - read_loc) :
96 - read_loc - write_loc;
100 * VMBUS version is 32 bit entity broken up into
101 * two 16 bit quantities: major_number. minor_number.