Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp456823pxa; Tue, 4 Aug 2020 09:27:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsHFe7zEukRfMShLHpHUHHTUqug1dcbfwZXwfSwThOsy6UnMGLXV2wLwa1XZYd+spMqR2P X-Received: by 2002:a17:906:af0c:: with SMTP id lx12mr8240058ejb.228.1596558465548; Tue, 04 Aug 2020 09:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596558465; cv=none; d=google.com; s=arc-20160816; b=P5+GXqUF2VYqzF/NK6j5q7LRjpvUEoXTlctpLYmwSamFNAYKh2hN/TCVjgWE0NB3M8 oE3Fplj+OMvaIJEfoW3w7d7Ou1ZjcLytLFHSL4f4iHdXzH07CldwiiaaTpOCOZsdMYDz KGNgff24Qhjiz26w1s8D4F0o3fqLxuecJMM4nwu9kM+T+eBeknTx4ibkjnxLo11yeRvm nSzB3YBRdmCen4v/+Tc++vPMtEyoHpt1MVvcahkcKx/BRTnq3xnq/ro8PmAWLVvgO4HM sObz14xmHuai9rQ6DkWCwq6clLf9vHiSc9dFWH4Ct/Ym3/QzcjZqIHQs0eGtK5bec5zT 88CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=SmtBD/Ul2MsaFZhKprp6nGnxuAWbsfyyoEnAh1HfzHg=; b=T/q8Gn2wLQCijitAUWbY5bw8VXlpaP90UKj62OTIYMJ3K483TywFtRUb1onkEv/kBL ixAUAjY+qe6ibYbSWs7w/sPsB8vsi4YVMo0Pv5IN/BA+NL4MnYs3nUO4BIEGvVSErywg NuH9+lY3hT/9U9k0iU83vOS7et52ToTPdcpQOJj15HP4iuLH5FqRdBQvSyF25kGRQ9Rt nmXTMSjoOYqNA/O55jyLhnXt6MYGI31vfitCWOVUSUaeLVWDIiRB8preCjH9ZWcmWuHs aXwZtEGsrQpyz3NG0TRNhKPtFohHOCkaHB8OHszs0/M6wpi1qch3ll8SsPD8q6MG+t5d En+g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lh27si13308583ejb.545.2020.08.04.09.27.22; Tue, 04 Aug 2020 09:27:45 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729871AbgHDQYI (ORCPT + 99 others); Tue, 4 Aug 2020 12:24:08 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:43913 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729664AbgHDQU7 (ORCPT ); Tue, 4 Aug 2020 12:20:59 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from eli@mellanox.com) with SMTP; 4 Aug 2020 19:20:53 +0300 Received: from nps-server-21.mtl.labs.mlnx (nps-server-21.mtl.labs.mlnx [10.237.240.120]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 074GKrPM024053; Tue, 4 Aug 2020 19:20:53 +0300 Received: from nps-server-21.mtl.labs.mlnx (localhost [127.0.0.1]) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7) with ESMTP id 074GKrrM022649; Tue, 4 Aug 2020 19:20:53 +0300 Received: (from eli@localhost) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 074GKr0f022648; Tue, 4 Aug 2020 19:20:53 +0300 From: Eli Cohen To: mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: shahafs@mellanox.com, saeedm@mellanox.com, parav@mellanox.com, Eli Cohen Subject: [PATCH V4 linux-next 08/12] vdpa: Modify get_vq_state() to return error code Date: Tue, 4 Aug 2020 19:20:44 +0300 Message-Id: <20200804162048.22587-9-eli@mellanox.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200804162048.22587-1-eli@mellanox.com> References: <20200804162048.22587-1-eli@mellanox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Modify get_vq_state() so it returns an error code. In case of hardware acceleration, the available index may be retrieved from the device, an operation that can possibly fail. Reviewed-by: Parav Pandit Signed-off-by: Eli Cohen --- drivers/vdpa/ifcvf/ifcvf_main.c | 5 +++-- drivers/vdpa/vdpa_sim/vdpa_sim.c | 5 +++-- drivers/vhost/vdpa.c | 5 ++++- include/linux/vdpa.h | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c index dc311e972b9e..076d7ac5e723 100644 --- a/drivers/vdpa/ifcvf/ifcvf_main.c +++ b/drivers/vdpa/ifcvf/ifcvf_main.c @@ -237,12 +237,13 @@ static u16 ifcvf_vdpa_get_vq_num_max(struct vdpa_device *vdpa_dev) return IFCVF_QUEUE_MAX; } -static void ifcvf_vdpa_get_vq_state(struct vdpa_device *vdpa_dev, u16 qid, - struct vdpa_vq_state *state) +static int ifcvf_vdpa_get_vq_state(struct vdpa_device *vdpa_dev, u16 qid, + struct vdpa_vq_state *state) { struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); state->avail_index = ifcvf_get_vq_state(vf, qid); + return 0; } static int ifcvf_vdpa_set_vq_state(struct vdpa_device *vdpa_dev, u16 qid, diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index f1c351d5959b..c68741363643 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -464,14 +464,15 @@ static int vdpasim_set_vq_state(struct vdpa_device *vdpa, u16 idx, return 0; } -static void vdpasim_get_vq_state(struct vdpa_device *vdpa, u16 idx, - struct vdpa_vq_state *state) +static int vdpasim_get_vq_state(struct vdpa_device *vdpa, u16 idx, + struct vdpa_vq_state *state) { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx]; struct vringh *vrh = &vq->vring; state->avail_index = vrh->last_avail_idx; + return 0; } static u32 vdpasim_get_vq_align(struct vdpa_device *vdpa) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index c2e1e2d55084..a0b7c91948e1 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -392,7 +392,10 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, ops->set_vq_ready(vdpa, idx, s.num); return 0; case VHOST_GET_VRING_BASE: - ops->get_vq_state(v->vdpa, idx, &vq_state); + r = ops->get_vq_state(v->vdpa, idx, &vq_state); + if (r) + return r; + vq->last_avail_idx = vq_state.avail_index; break; case VHOST_GET_BACKEND_FEATURES: diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 8f412620071d..fd6e560d70f9 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -192,8 +192,8 @@ struct vdpa_config_ops { bool (*get_vq_ready)(struct vdpa_device *vdev, u16 idx); int (*set_vq_state)(struct vdpa_device *vdev, u16 idx, const struct vdpa_vq_state *state); - void (*get_vq_state)(struct vdpa_device *vdev, u16 idx, - struct vdpa_vq_state *state); + int (*get_vq_state)(struct vdpa_device *vdev, u16 idx, + struct vdpa_vq_state *state); struct vdpa_notification_area (*get_vq_notification)(struct vdpa_device *vdev, u16 idx); int (*get_vq_irq)(struct vdpa_device *vdv, u16 idx); -- 2.26.0