Received: by 10.192.165.148 with SMTP id m20csp4197312imm; Mon, 30 Apr 2018 13:39:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZooMgnFddqUgElKFmntPuW17keY71fM+NWX8wbN807yjsOi6+BsjFapPBveHM9pFupPD7Vq X-Received: by 10.98.78.200 with SMTP id c191mr13035287pfb.153.1525120796129; Mon, 30 Apr 2018 13:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525120796; cv=none; d=google.com; s=arc-20160816; b=Gv7QO3yVxIrvs/YC0RyLxlm+jT4CbW8nOTgnbvK8wcgyc/nrxB/vboVDcyyYEJhTLI a9GUMgczIsI37cr5zGulhl7An4xTtuX8ZHyYYxAuFAA2kASZcZ/ExEeuQogOThcV1eVg k1WVeJiBy/2ZMt/gq/Xnu1KekomoHHCYwiYJJMDkgi4IaN85UJjaBaEXFV46H6rmtXcA 3eV8K7clubUzo9On2oQj6RLNzFesnoQgQucjeGaZ/H6a5x3u/6CFnw14uQ611Io4wO/l hD1qc6mpX8ZXosBtWmdO0pqcSC1HafY/1pN6U94V/OF3/c35qY28AN7fxScvsyenwgwk 6j6g== 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=T6v8JTDYJkQy3JXyya+0jMtt+w9ATCvH+vJ+JiL9PFw=; b=zXM3fEYRuEMi9/r2gFN7R4lF8/GQs5yPVzPxLduYP8n7a1PbLGCVPSXcS30r4gOm2D ghd1ETmnmhhXlyT3Vp4c+w5lZTLOZhi7g611skcJIjGwuPZytgOnIqYM1dPw2Iiw9lu2 vi/gNL9+isCiS1euN+NXIhxa/+xwvjhbUCFo6xjUxFPgN59K1gS9g0eTZd+TjcMbPoXs Ui5oRhN6NJZrzTAzr5lXW05S3ognV3nQvAbZuDP/n3z8s9ZJ0bsQeNzWReixfpaBbD2a YIkBmHCIGEeqwAtUV+S3z366S1HuZEjHHpCt88AvKj+qVwTU44WVasudzpbFnrX5gLYZ 908A== 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 a16-v6si6764373pgn.39.2018.04.30.13.39.42; Mon, 30 Apr 2018 13:39:56 -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 S1755473AbeD3UjU (ORCPT + 99 others); Mon, 30 Apr 2018 16:39:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:58634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755369AbeD3TZs (ORCPT ); Mon, 30 Apr 2018 15:25:48 -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 A5B1C22DBE; Mon, 30 Apr 2018 19:25:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5B1C22DBE 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.4 15/44] drm/virtio: fix vq wait_event condition Date: Mon, 30 Apr 2018 12:24:26 -0700 Message-Id: <20180430190946.952441015@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430190946.093694747@linuxfoundation.org> References: <20180430190946.093694747@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.4-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 {