Skip to content

Commit 77d5e27

Browse files
Iouri Tarassovchessturo
authored andcommitted
drivers: hv: dxgkrnl: Retry sending a VM bus packet when there is no place in the ring buffer
When D3DKMT requests are sent too quickly, the VM bus ring buffer could be full when a message is submitted. The change adds sleep and re-try count to handle this condition. Signed-off-by: Iouri Tarassov <iourit@linux.microsoft.com> [kms: forward port to 6.6 from 6.1. No code changes made.] Signed-off-by: Kelsey Steele <kelseysteele@microsoft.com>
1 parent a118bc3 commit 77d5e27

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

drivers/hv/dxgkrnl/dxgvmbus.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ int dxgvmb_send_sync_msg(struct dxgvmbuschannel *channel,
420420
struct dxgvmbuspacket *packet = NULL;
421421
struct dxgkvmb_command_vm_to_host *cmd1;
422422
struct dxgkvmb_command_vgpu_to_host *cmd2;
423+
int try_count = 0;
423424

424425
if (cmd_size > DXG_MAX_VM_BUS_PACKET_SIZE ||
425426
result_size > DXG_MAX_VM_BUS_PACKET_SIZE) {
@@ -453,9 +454,19 @@ int dxgvmb_send_sync_msg(struct dxgvmbuschannel *channel,
453454
list_add_tail(&packet->packet_list_entry, &channel->packet_list_head);
454455
spin_unlock_irq(&channel->packet_list_mutex);
455456

456-
ret = vmbus_sendpacket(channel->channel, command, cmd_size,
457-
packet->request_id, VM_PKT_DATA_INBAND,
458-
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
457+
do {
458+
ret = vmbus_sendpacket(channel->channel, command, cmd_size,
459+
packet->request_id, VM_PKT_DATA_INBAND,
460+
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
461+
/*
462+
* -EAGAIN is returned when the VM bus ring buffer if full.
463+
* Wait 2ms to allow the host to process messages and try again.
464+
*/
465+
if (ret == -EAGAIN) {
466+
usleep_range(1000, 2000);
467+
try_count++;
468+
}
469+
} while (ret == -EAGAIN && try_count < 50);
459470
if (ret) {
460471
DXG_ERR("vmbus_sendpacket failed: %x", ret);
461472
spin_lock_irq(&channel->packet_list_mutex);

0 commit comments

Comments
 (0)