Received: by 10.192.165.148 with SMTP id m20csp4170901imm; Mon, 30 Apr 2018 13:07:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrx8hymlYFewPyXrSq6WKcPHgdnR1SniYdAxYjtsQp1pQKMnTbCr1+7PmymQYoYJOA7AmuI X-Received: by 10.98.217.5 with SMTP id s5mr13326762pfg.20.1525118847475; Mon, 30 Apr 2018 13:07:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525118847; cv=none; d=google.com; s=arc-20160816; b=Z53y7a4Dr4ZC9tFoGGnBimV2sxrnMstP8keceD/Yi04ESAi3CS2H8JtF45xmrLx4Pj YVWaKuK9Ej0iVVq33FnJtKvHOfL20mrzpxBCj92HfDFv3sQB9/Wwj9yE3MVKpeywJf0/ NlfHKfx2Xfl1oHXDBDpEnhj7DDi21RjrmIPTMnyVFy7hmSOViykr3l9y5ZDW/key5SGb wGfY8K1xCWqYqcGOq/K5+RUn3odRLFYXB2TO6kIxtSHN0GvMjWrNvrnGiUpMOFXaBT4b LbNuUBOsslT2T5MG/I9Ghx/ojBcs98lCaDL8MM7XfB6Tr3CD7isDD2zi+Dz6Jm9wk+DC IOOg== 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=Fm+DabXkO1nPCnIcyxnDGnbgpMga76E7bpXJlS1AIKs=; b=ejIlQ+MxPfuv14xHziote/6JCuqbXYrFWjNOBUv6GmOy46filrp79wrcZDgSUuo5Nn oHny0G22g9OplSEbFU7zuDnktBTvGJl7o/1kEFnd6DRhlRprLfEbSSsfDHTlqN/ti359 7RuC4MxiMzJVcgQulpVgDOpE3oWkfk5fONPIwWvb1GTmj7d1ED4IQBVeIDczzC/1EPfZ cnLjLSb+3+ir2vH2WtAhbNqRr0ru450wsCekbRzKSar7wzkiTv5HXu3clWFTY9xHCl1T RduhfdQVtccFXINDlunF/Yk3FxODHSiNG4wN4xZSRFLOMuTEn7FpG4i7d14Ycc3UE0b5 r6gg== 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 y63si8299350pfg.121.2018.04.30.13.07.13; Mon, 30 Apr 2018 13:07:27 -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 S1755975AbeD3UGz (ORCPT + 99 others); Mon, 30 Apr 2018 16:06:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:33830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755949AbeD3T1Y (ORCPT ); Mon, 30 Apr 2018 15:27:24 -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 0579422DAC; Mon, 30 Apr 2018 19:27:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0579422DAC 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.14 28/91] drm/virtio: fix vq wait_event condition Date: Mon, 30 Apr 2018 12:24:10 -0700 Message-Id: <20180430184005.658968269@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@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.14-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 @@ -291,7 +291,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 { @@ -366,7 +366,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 {