Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp50279ybg; Mon, 27 Jul 2020 23:06:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy25p361GELc2dojA12V0aFG1HyHGs3bwGdQM0hYpj+Oz9yG278RpoXKkfVxR4mfY7N/XIT X-Received: by 2002:a17:906:4d4f:: with SMTP id b15mr14036520ejv.534.1595916418295; Mon, 27 Jul 2020 23:06:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595916418; cv=none; d=google.com; s=arc-20160816; b=BWRVJ6NWohOMKXZcVLV0ghqjbcy82egbhlO+6rAL83Bi07rbD2/atb6txCH3to9QZH 2JmyHDUd1poE/HKRvxdMWlBpEyXNiUwV/uP0gL3QXIEqBWH1Cu9FCUBSPaKz6kII+b74 WB7VKTKBjAIubT72yoU839o8P+1B4puv9aodxOVcLQztzc+26jLfEwfCWgkTKw9qGkw1 7YBTgtm8fr5mlP6Q6X4PEvBoB1dCr9Iw734wCO2dvX/iqTgNhk4NkPWRovjRjh1uwbrd lQxqscrUtiXsiHBMOLXDcwlYUKyV9EAJ641wGt4iKuY89nqoigbUgVs7vnBm5tH/1j5K +aJw== 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=SgWahfREDRakVNUUijYsNE8B3mdUjF03p2ZHkRr8bZc=; b=WFa4neTLwCJqHEf7KdGUw5VccKd8Nv/uXCXtVtveImYDn4hWK0PDaW31luzWcuzynN UEHS4yY+9XQ1VIDkt+pVklWvhCUhrM3JZbZRzoJ18Fr9QC/SwmswYq03tE2BdWS0qFX0 7emPpVXqgxxUfifuWtJ3k8EyELMWAk+cJIVj7IYREocSoDdHe3ni5pKRf3hwkeBjyL1J UJwhHS9TxE9kTFkFK4cwdIDEyYDBnC66ZV32dNrmwfhS2m8mt8zM27fZ+Uqt3WPqLSTr qwa+KqngVPHUNvrk5Kp2v4Cx0GbUnxcALjpxsjLYTFOoMuDPoEKDUbZ8PZTsIeHAAYx6 Ulpw== 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 q3si6987166ejb.105.2020.07.27.23.06.36; Mon, 27 Jul 2020 23:06:58 -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 S1727820AbgG1GGP (ORCPT + 99 others); Tue, 28 Jul 2020 02:06:15 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:34885 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727803AbgG1GGM (ORCPT ); Tue, 28 Jul 2020 02:06:12 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from eli@mellanox.com) with SMTP; 28 Jul 2020 09:06:07 +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 06S667nA016842; Tue, 28 Jul 2020 09:06:07 +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 06S667Jq004233; Tue, 28 Jul 2020 09:06:07 +0300 Received: (from eli@localhost) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 06S667Xt004232; Tue, 28 Jul 2020 09:06:07 +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 V3 vhost next 06/10] vdpa: Modify get_vq_state() to return error code Date: Tue, 28 Jul 2020 09:05:35 +0300 Message-Id: <20200728060539.4163-7-eli@mellanox.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200728060539.4163-1-eli@mellanox.com> References: <20200728060539.4163-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 69032ee97824..d9b5f465ac81 100644 --- a/drivers/vdpa/ifcvf/ifcvf_main.c +++ b/drivers/vdpa/ifcvf/ifcvf_main.c @@ -235,12 +235,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 599519039f8d..ddf6086d43c2 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -427,14 +427,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 af98c11c9d26..fadad74f882e 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -360,7 +360,10 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, } if (cmd == 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; } diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 7b088bebffe8..000d71a9f988 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -185,8 +185,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); -- 2.26.0