Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'char-misc-4.16-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull hyperv fix from Greg KH:
"This is a single hyperv bugfix for 4.16-rc7.

It resolves an issue with the ring-buffer signaling to resolve
reported problems.

It's been in linux-next for a while now with no reported issues"

* tag 'char-misc-4.16-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
Drivers: hv: vmbus: Fix ring buffer signaling

+35 -17
+35 -17
drivers/hv/ring_buffer.c
··· 417 417 } 418 418 EXPORT_SYMBOL_GPL(__hv_pkt_iter_next); 419 419 420 + /* How many bytes were read in this iterator cycle */ 421 + static u32 hv_pkt_iter_bytes_read(const struct hv_ring_buffer_info *rbi, 422 + u32 start_read_index) 423 + { 424 + if (rbi->priv_read_index >= start_read_index) 425 + return rbi->priv_read_index - start_read_index; 426 + else 427 + return rbi->ring_datasize - start_read_index + 428 + rbi->priv_read_index; 429 + } 430 + 420 431 /* 421 432 * Update host ring buffer after iterating over packets. 422 433 */ 423 434 void hv_pkt_iter_close(struct vmbus_channel *channel) 424 435 { 425 436 struct hv_ring_buffer_info *rbi = &channel->inbound; 426 - u32 orig_write_sz = hv_get_bytes_to_write(rbi); 437 + u32 curr_write_sz, pending_sz, bytes_read, start_read_index; 427 438 428 439 /* 429 440 * Make sure all reads are done before we update the read index since ··· 442 431 * is updated. 443 432 */ 444 433 virt_rmb(); 434 + start_read_index = rbi->ring_buffer->read_index; 445 435 rbi->ring_buffer->read_index = rbi->priv_read_index; 436 + 437 + if (!rbi->ring_buffer->feature_bits.feat_pending_send_sz) 438 + return; 446 439 447 440 /* 448 441 * Issue a full memory barrier before making the signaling decision. ··· 461 446 */ 462 447 virt_mb(); 463 448 464 - /* If host has disabled notifications then skip */ 465 - if (rbi->ring_buffer->interrupt_mask) 449 + pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz); 450 + if (!pending_sz) 466 451 return; 467 452 468 - if (rbi->ring_buffer->feature_bits.feat_pending_send_sz) { 469 - u32 pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz); 453 + /* 454 + * Ensure the read of write_index in hv_get_bytes_to_write() 455 + * happens after the read of pending_send_sz. 456 + */ 457 + virt_rmb(); 458 + curr_write_sz = hv_get_bytes_to_write(rbi); 459 + bytes_read = hv_pkt_iter_bytes_read(rbi, start_read_index); 470 460 471 - /* 472 - * If there was space before we began iteration, 473 - * then host was not blocked. Also handles case where 474 - * pending_sz is zero then host has nothing pending 475 - * and does not need to be signaled. 476 - */ 477 - if (orig_write_sz > pending_sz) 478 - return; 461 + /* 462 + * If there was space before we began iteration, 463 + * then host was not blocked. 464 + */ 479 465 480 - /* If pending write will not fit, don't give false hope. */ 481 - if (hv_get_bytes_to_write(rbi) < pending_sz) 482 - return; 483 - } 466 + if (curr_write_sz - bytes_read > pending_sz) 467 + return; 468 + 469 + /* If pending write will not fit, don't give false hope. */ 470 + if (curr_write_sz <= pending_sz) 471 + return; 484 472 485 473 vmbus_setevent(channel); 486 474 }