]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
UBUNTU: SAUCE: (noup) Drivers: hv: vmbus: Fix a bug in hv_need_to_signal_on_read()
authorJoseph Salisbury <joseph.salisbury@canonical.com>
Wed, 16 Mar 2016 18:28:24 +0000 (14:28 -0400)
committerTim Gardner <tim.gardner@canonical.com>
Wed, 6 Apr 2016 09:27:28 +0000 (10:27 +0100)
BugLink: http://bugs.launchpad.net/bugs/1556264
This patch has been submitted upstream, but has not landed in the mainline tree as of yet.

On the consumer side, we have interrupt driven flow management of the
producer. It is sufficient to base the signalling decision on the
amount of space that is available to write after the read is complete.
The current code samples the previous available space and uses this
in making the signalling decision. This state can be stale and is
unnecessary. Since the state can be stale, we end up not signalling
the host (when we should) and this can result in a hang. Fix this
problem by removing the unnecessary check.

I would like to thank Arseney Romanenko <arseneyr@microsoft.com>
for pointing out this bug.

OriginalAuthor: kys@microsoft.com
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/hv/ring_buffer.c

index b53702ce692f35652c8efcb987cc0d79aa1b6fc0..866a065c6d88b6b3f9a06612b8e8c5e06d815e8c 100644 (file)
@@ -103,8 +103,7 @@ static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi)
  *    there is room for the producer to send the pending packet.
  */
 
-static bool hv_need_to_signal_on_read(u32 prev_write_sz,
-                                     struct hv_ring_buffer_info *rbi)
+static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi)
 {
        u32 cur_write_sz;
        u32 r_size;
@@ -120,7 +119,7 @@ static bool hv_need_to_signal_on_read(u32 prev_write_sz,
        cur_write_sz = write_loc >= read_loc ? r_size - (write_loc - read_loc) :
                        read_loc - write_loc;
 
-       if ((prev_write_sz < pending_sz) && (cur_write_sz >= pending_sz))
+       if (cur_write_sz >= pending_sz)
                return true;
 
        return false;
@@ -458,7 +457,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
        /* Update the read index */
        hv_set_next_read_location(inring_info, next_read_location);
 
-       *signal = hv_need_to_signal_on_read(bytes_avail_towrite, inring_info);
+       *signal = hv_need_to_signal_on_read(inring_info);
 
 out_unlock:
        spin_unlock_irqrestore(&inring_info->ring_lock, flags);