Skip to content

Commit 964dfbe

Browse files
kattisrinivasangregkh
authored andcommitted
Drivers: hv: vmbus: On the read path cleanup the logic to interrupt the host
commit 3372592 upstream. Signal the host when we determine the host is to be signaled - on th read path. The currrent code determines the need to signal in the ringbuffer code and actually issues the signal elsewhere. This can result in the host viewing this interrupt as spurious since the host may also poll the channel. Make the necessary adjustments. Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Cc: Rolf Neugebauer <rolf.neugebauer@docker.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e2fdf78 commit 964dfbe

4 files changed

Lines changed: 14 additions & 20 deletions

File tree

‎drivers/hv/channel.c‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -879,16 +879,9 @@ __vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
879879
u32 bufferlen, u32 *buffer_actual_len, u64 *requestid,
880880
bool raw)
881881
{
882-
int ret;
883-
bool signal = false;
884-
885-
ret = hv_ringbuffer_read(&channel->inbound, buffer, bufferlen,
886-
buffer_actual_len, requestid, &signal, raw);
882+
return hv_ringbuffer_read(channel, buffer, bufferlen,
883+
buffer_actual_len, requestid, raw);
887884

888-
if (signal)
889-
vmbus_setevent(channel);
890-
891-
return ret;
892885
}
893886

894887
int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,

‎drivers/hv/hyperv_vmbus.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ int hv_ringbuffer_write(struct vmbus_channel *channel,
532532
u32 kv_count, bool lock,
533533
bool kick_q);
534534

535-
int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
535+
int hv_ringbuffer_read(struct vmbus_channel *channel,
536536
void *buffer, u32 buflen, u32 *buffer_actual_len,
537-
u64 *requestid, bool *signal, bool raw);
537+
u64 *requestid, bool raw);
538538

539539
void hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
540540
struct hv_ring_buffer_debug_info *debug_info);

‎drivers/hv/ring_buffer.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,9 @@ int hv_ringbuffer_write(struct vmbus_channel *channel,
353353
return 0;
354354
}
355355

356-
int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
356+
int hv_ringbuffer_read(struct vmbus_channel *channel,
357357
void *buffer, u32 buflen, u32 *buffer_actual_len,
358-
u64 *requestid, bool *signal, bool raw)
358+
u64 *requestid, bool raw)
359359
{
360360
u32 bytes_avail_toread;
361361
u32 next_read_location = 0;
@@ -364,6 +364,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
364364
u32 offset;
365365
u32 packetlen;
366366
int ret = 0;
367+
struct hv_ring_buffer_info *inring_info = &channel->inbound;
367368

368369
if (buflen <= 0)
369370
return -EINVAL;
@@ -421,7 +422,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
421422
/* Update the read index */
422423
hv_set_next_read_location(inring_info, next_read_location);
423424

424-
*signal = hv_need_to_signal_on_read(inring_info);
425+
hv_signal_on_read(channel);
425426

426427
return ret;
427428
}

‎include/linux/hyperv.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,10 +1480,11 @@ hv_get_ring_buffer(struct hv_ring_buffer_info *ring_info)
14801480
* there is room for the producer to send the pending packet.
14811481
*/
14821482

1483-
static inline bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi)
1483+
static inline void hv_signal_on_read(struct vmbus_channel *channel)
14841484
{
14851485
u32 cur_write_sz;
14861486
u32 pending_sz;
1487+
struct hv_ring_buffer_info *rbi = &channel->inbound;
14871488

14881489
/*
14891490
* Issue a full memory barrier before making the signaling decision.
@@ -1501,14 +1502,14 @@ static inline bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi)
15011502
pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
15021503
/* If the other end is not blocked on write don't bother. */
15031504
if (pending_sz == 0)
1504-
return false;
1505+
return;
15051506

15061507
cur_write_sz = hv_get_bytes_to_write(rbi);
15071508

15081509
if (cur_write_sz >= pending_sz)
1509-
return true;
1510+
vmbus_setevent(channel);
15101511

1511-
return false;
1512+
return;
15121513
}
15131514

15141515
/*
@@ -1590,8 +1591,7 @@ static inline void commit_rd_index(struct vmbus_channel *channel)
15901591
virt_rmb();
15911592
ring_info->ring_buffer->read_index = ring_info->priv_read_index;
15921593

1593-
if (hv_need_to_signal_on_read(ring_info))
1594-
vmbus_set_event(channel);
1594+
hv_signal_on_read(channel);
15951595
}
15961596

15971597

0 commit comments

Comments
 (0)