Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp407106pxu; Tue, 1 Dec 2020 14:29:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7Qz37+mtGV3hFDfxPfzEKXUAvAHklI/K7XR/mlyb3oJ/0SO4WWS4zgaEXDrmmxBDdTOFs X-Received: by 2002:aa7:df91:: with SMTP id b17mr4392075edy.272.1606861755600; Tue, 01 Dec 2020 14:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861755; cv=none; d=google.com; s=arc-20160816; b=DbNdasV+0s+1oRsqiBLSpfRMA7Jx0JsXHYcSX688AdHSJwu3EcU6tywAEPlB+m0sNz 0LBnFaJcw3MuSx71nysYDpIo+iv90ZaoUa5u8rgKtrbCKN+cUlw14gmet65HC4QkY/cZ 5+pcN2F3mseGGaFvcLL0C5cf1RcfHCy+gbxl+DGmmXDwxzbkkh6QJEtLLmu9QsF2GCI2 quFVIXdSD25l3Ltx0yGM9aIdXRb8eVDNNV8BEgnOywDCzBF9VsrWAgeMrL4LwSJIdBXh mZc2d8ei0ERUTknbtzy1sj9io6SbpNKUqbX7i1NFh3h1kXH0AskhbfJy8WFXqsDj32s7 ybUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B82efVw+GBEH0MEH18PZLzWh7BKFF98YumSuCoq+748=; b=xOpum8HxbPJdUL9JWlXajlkamfIN/9/OMyBvgHeLfvbL1sRX19tq/a4HHPMmPq3J8Y Daa2259a+XTxc2uYlY/oHrW9PiHpCb2VzCXP2CXq9sczBFc32X/81QpTokUIx4WWQxQu JjgqkUIi3zIcBSzo++9jonn4FCz+Um6lb31jZ0Tbln5BZU8d1wjorM/YSBq97Av6rOd0 Teiy+4Kw5hfdynYZfQZMD6rxNLhaZT1U26MfHmQejavEWZ/ZfQGE9L6qSG9gFCjhI62E CgvB+nqLR86iM7x80jzkNQq5H9uCygKvXUhgDDExWIS7zXiyVFTEElydEyJbSmW0nGN2 JCKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OAr1JeFa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rn4si852184ejb.216.2020.12.01.14.28.53; Tue, 01 Dec 2020 14:29:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OAr1JeFa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390591AbgLAJTH (ORCPT + 99 others); Tue, 1 Dec 2020 04:19:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:47992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389673AbgLAJKU (ORCPT ); Tue, 1 Dec 2020 04:10:20 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 78C272222A; Tue, 1 Dec 2020 09:09:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813780; bh=2iKQUJsUQI9l2vvcbu3mNWUXjhNPMztzv4VhPexSgrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OAr1JeFaC5FPEgoX2POERDEP5YH5EUOlLEUKmQ4Cxt2HOTmMfmBputvJUh5KuaBFQ /LpljF0j1N7X6EifM+S3lSCnfVDomWw9eOfufQaH3KObn5Se+Q/uaMZuH6jByoPUF0 415xy6Mvx6SjB8Rb+jStLUuVplJq5aAYTCbE5mao= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Christie , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Sasha Levin Subject: [PATCH 5.9 057/152] vhost: add helper to check if a vq has been setup Date: Tue, 1 Dec 2020 09:52:52 +0100 Message-Id: <20201201084719.420908068@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084711.707195422@linuxfoundation.org> References: <20201201084711.707195422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Christie [ Upstream commit 6bcf34224ac1e94103797fd68b9836061762f2b2 ] This adds a helper check if a vq has been setup. The next patches will use this when we move the vhost scsi cmd preallocation from per session to per vq. In the per vq case, we only want to allocate cmds for vqs that have actually been setup and not for all the possible vqs. Signed-off-by: Mike Christie Link: https://lore.kernel.org/r/1604986403-4931-2-git-send-email-michael.christie@oracle.com Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang Acked-by: Stefan Hajnoczi Signed-off-by: Sasha Levin --- drivers/vhost/vhost.c | 6 ++++++ drivers/vhost/vhost.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 9ad45e1d27f0f..23e7b2d624511 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -305,6 +305,12 @@ static void vhost_vring_call_reset(struct vhost_vring_call *call_ctx) spin_lock_init(&call_ctx->ctx_lock); } +bool vhost_vq_is_setup(struct vhost_virtqueue *vq) +{ + return vq->avail && vq->desc && vq->used && vhost_vq_access_ok(vq); +} +EXPORT_SYMBOL_GPL(vhost_vq_is_setup); + static void vhost_vq_reset(struct vhost_dev *dev, struct vhost_virtqueue *vq) { diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 9032d3c2a9f48..3d30b3da7bcf5 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -190,6 +190,7 @@ int vhost_get_vq_desc(struct vhost_virtqueue *, struct vhost_log *log, unsigned int *log_num); void vhost_discard_vq_desc(struct vhost_virtqueue *, int n); +bool vhost_vq_is_setup(struct vhost_virtqueue *vq); int vhost_vq_init_access(struct vhost_virtqueue *); int vhost_add_used(struct vhost_virtqueue *, unsigned int head, int len); int vhost_add_used_n(struct vhost_virtqueue *, struct vring_used_elem *heads, -- 2.27.0