Received: by 10.192.165.148 with SMTP id m20csp4189244imm; Mon, 30 Apr 2018 13:30:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrzDflVkEqEt6/Wa9KpuQd8iAJEwM0jGuh1PD9PVbMDanq0+BPHbdSV0Hli1ft2I/Pc/Gsk X-Received: by 2002:a17:902:684c:: with SMTP id f12-v6mr13815337pln.139.1525120223974; Mon, 30 Apr 2018 13:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525120223; cv=none; d=google.com; s=arc-20160816; b=VGE/1lZ9sfCkEN+K7ficQk6fL54Gr4aMYRTD0gxy+XgfYkr4NAuYlXQs7bkkT3BpPc 5n5SuowC4NMAXeLk/SrsqGNmNK0nwTctVhRbXTlnJ3y0R1RPU6HLDxHkePtVetWfkWLL S8dAF3k8WH2nTYg6G9awA0u8OJsCaqL/4ETMm5q9bxMZvlA83o1U5XzKKNgkirNO50QW ejQ5RAlH9TaeF6Tbbpr6OuF5qwZUCyEpYGUE3Gdsmr3FxskuGEZsBQshQoLL/Wwan7B2 ZZjwCOqGfuhorsGFzVNHXJABqap18xP3YI/cOC6FAR1g5OAxaa6TW2x3dtBrk6Zu2eKv Jd4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=Z6nCINH4TDQ2HvVuyaCN8BsIo0cCVla1nyYda9rteV4=; b=N7RvZ85HsMj9DezVfUIl8bp8ulF4jJ627oS/JzfTPVrwnwxxod50aMBvxLQqcB2Vro 9TLsYypYmVuX8tCDVtdD1D1EZwfGZdPJFNfSBq1YA2TYemGBa6FQWmPUJo3OTWzTs9za rm7uMthBuOvdqjzDFok4nlGd07C0PD0ms0NAadXBFNaSc9I8+Zj5cTYiOrMgo2LDyw68 0M5/c+0Q6/W7xKKepbAKPxvoVS2JEuKWKNA04ct45UqGovKxGUcMtLbocfF50EpA12CC rcR16Adzy+X2dxBdAT2KYGNj08k6uFdKR1bThvNng+g4OsJ6rli70t0xlkMMneVOuTDA KX0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t9si8151413pfk.228.2018.04.30.13.30.09; Mon, 30 Apr 2018 13:30:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755753AbeD3U2h (ORCPT + 99 others); Mon, 30 Apr 2018 16:28:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:59880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755585AbeD3T0W (ORCPT ); Mon, 30 Apr 2018 15:26:22 -0400 Received: from localhost (unknown [104.132.1.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9450322DC0; Mon, 30 Apr 2018 19:26:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9450322DC0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alain Magloire , Gerd Hoffmann , Dave Airlie , Sean Paul Subject: [PATCH 4.9 19/61] drm/virtio: fix vq wait_event condition Date: Mon, 30 Apr 2018 12:24:22 -0700 Message-Id: <20180430183952.956075938@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430183951.312721450@linuxfoundation.org> References: <20180430183951.312721450@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gerd Hoffmann commit d02d270014f70dcab0117776b81a37b6fca745ae upstream. Wait until we have enough space in the virt queue to actually queue up our request. Avoids the guest spinning in case we have a non-zero amount of free entries but not enough for the request. Cc: stable@vger.kernel.org Reported-by: Alain Magloire Signed-off-by: Gerd Hoffmann Reviewed-by: Dave Airlie Link: http://patchwork.freedesktop.org/patch/msgid/20180403095904.11152-1-kraxel@redhat.com Signed-off-by: Sean Paul Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/virtio/virtgpu_vq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -324,7 +324,7 @@ retry: ret = virtqueue_add_sgs(vq, sgs, outcnt, incnt, vbuf, GFP_ATOMIC); if (ret == -ENOSPC) { spin_unlock(&vgdev->ctrlq.qlock); - wait_event(vgdev->ctrlq.ack_queue, vq->num_free); + wait_event(vgdev->ctrlq.ack_queue, vq->num_free >= outcnt + incnt); spin_lock(&vgdev->ctrlq.qlock); goto retry; } else { @@ -399,7 +399,7 @@ retry: ret = virtqueue_add_sgs(vq, sgs, outcnt, 0, vbuf, GFP_ATOMIC); if (ret == -ENOSPC) { spin_unlock(&vgdev->cursorq.qlock); - wait_event(vgdev->cursorq.ack_queue, vq->num_free); + wait_event(vgdev->cursorq.ack_queue, vq->num_free >= outcnt); spin_lock(&vgdev->cursorq.qlock); goto retry; } else {