Received: by 10.192.165.148 with SMTP id m20csp4160251imm; Mon, 30 Apr 2018 12:56:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoWfiBaB+JUz6M5RFDb/6Zn425SFYrLk3+p45jmPRAAIjoq7DWs6Pdv1KNZ7MnNSX1WEUpU X-Received: by 2002:a65:4189:: with SMTP id a9-v6mr10922266pgq.118.1525118170196; Mon, 30 Apr 2018 12:56:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525118170; cv=none; d=google.com; s=arc-20160816; b=o4O0iD6fFKdsTN5TzSiRaNt1m17PfMrp1MwLR0noeJWF86TSXthTmEDr/94swM/cxw WvDn5ZC+QPa+NEA/R4ejbiSTn0p4EaLKF+qAkLsFTMY8NQzqaYXeGAgX+m6u7Qu6JXGB DLLfnwVf/4Ps0bVApr/PjijW/PxC8zKgGd+LBFi8u2IGof7Xer6DCOEacfEEPo9H5DYM T0FmhxbRo428kLTMn7kG7gAt/zB2jRQQZURQMAxLk5do7v2zfsCvWr9/9s4qtPUz9JEM +dDHsfKKL9XFTib94QHbR2mSunNS8FKxYjDWQl7MkQ+0/moh4zO35NkudTdpWD2ADNwr ETpg== 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=tOgZcj4ZrDOy8Mxt5y2f9Yy4royyzsju31TyhcPFxMg=; b=k/YaE1bRT3fYRezalzHlbxJ5bqmvMVqQJLXRF/EKSYV6xm8s5P0372FkicG0WF6RMj GvVuNnyDW2oeZt7qoguDDaNzHRmSLCB4BbqX+ZUFakiPuM50oaR5I+S8P0GVmjQFWezu t4nhRS8uXe0nS2QQdl7XCsT3x1stMjF/1sGz6fWa0ADOC1dOYO5as18K4FvUiJAEeK9i Eaa9boIdpkOB37d7o8on+dA8WE19uZDfUcbAPca+/z8RH8tQnS6BODoqe6+0him/HzZz 4E7BwkaBq9zoPCnoSeiGGRCqD7xMv0s++oQDPv48UHz8dL9mEHlzUOj2HFuEaMp9QDJD TQuQ== 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 v8-v6si7865447plg.68.2018.04.30.12.55.26; Mon, 30 Apr 2018 12:56:10 -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 S1756380AbeD3TvF (ORCPT + 99 others); Mon, 30 Apr 2018 15:51:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:35402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756170AbeD3T2H (ORCPT ); Mon, 30 Apr 2018 15:28:07 -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 A4ADB22DC1; Mon, 30 Apr 2018 19:28:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4ADB22DC1 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.16 030/113] drm/virtio: fix vq wait_event condition Date: Mon, 30 Apr 2018 12:24:01 -0700 Message-Id: <20180430184016.343904638@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@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.16-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 {