Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp454165ybh; Mon, 20 Jul 2020 22:35:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1lUG+HIsgreV3n9KfNsJ0EGfjy9Fjny52ZXzZ+IM5202+QuY4nxg7SMWpHPtRQ+3IQBx8 X-Received: by 2002:a50:d9cb:: with SMTP id x11mr23364598edj.93.1595309724531; Mon, 20 Jul 2020 22:35:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595309724; cv=none; d=google.com; s=arc-20160816; b=KBpEoItlAHGXYuinBvm3pFIOnBmcyhgxk72MEXPw/jx9CGcnMmRYZtSPkhBRyxMyaY ouxQ7kkPjrRNx90B70Txzp+kWKPKK2OLEHupgwhGs8nZSbGHXy/gNf87eLXV+B1y/wWa 6De7OHYJL2aUKdmcCGR9Fi/ekEV9u/5DBiPVU2KNp29/URkJYKXOrQkh4T/lVRgLCXlA j/yfs5UbI8+29kRtjaTjb5LgD0R+4LIUfkVleiM5gVug865TqwWl9wwVaGh9mevJuWiB /qLea7MWE/UJ2fjEswK203Cpz63BAb9ojY8lhbtuqf2xLbfyw39qZ1wrusMuulnlVbDq OWRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=A9DeyT/Te+u96c5OpliRfzztbAI2QqHnWn+vnnjCPUw=; b=ba+OmES8ogDqDnyLOUr5MuPCIrY557E6+myt+fmzt7A2rp/Alv6q0kenIS1FL3lMJn 4n45KftSY15KaSEK0TOfGdJughwyTxPNDoVrm9BN3JjLbKoQBUclV9izKcgRVpvFGBy/ JnNq3LQuMLCYICakpy8nIZfytDbM3Sjj6FqtjnLv4EfwWhJKyshsPsZKwhzVwyM/XvzM cXXlw3KlDyvq80DfRTR84ekqMGSccFY2GhPzLKq6TfNBjLYJc1j844RnLjOXjmNKI++C 9/M8m6xTqR6XR3FuFfRuLKG75Ml7YYuolqdxY5jAQ7PNQBDleC5qLmz0dT7l1UQitHMy EO3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dmW4bC8h; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dj11si12363857edb.279.2020.07.20.22.35.01; Mon, 20 Jul 2020 22:35:24 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dmW4bC8h; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726978AbgGUFeu (ORCPT + 99 others); Tue, 21 Jul 2020 01:34:50 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:21263 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726010AbgGUFet (ORCPT ); Tue, 21 Jul 2020 01:34:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595309687; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A9DeyT/Te+u96c5OpliRfzztbAI2QqHnWn+vnnjCPUw=; b=dmW4bC8hzXY/0N+kTYSak7Gh5gnG+NEOOJjKvA3BxUMDwS7Eku6fBqGnY1rx+hFgjETTkI VCWW/mrFhF4leuc/F/y3ww1vWkYJtJ/6AVXZtaiNncJuqlILSj5stgvHkMHDdepe+oHmEX GhR1xV7960MD7tLFMYTl/F/HuA7epug= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-431-V-w9XEj9OJyWlwaYnSuNOg-1; Tue, 21 Jul 2020 01:34:45 -0400 X-MC-Unique: V-w9XEj9OJyWlwaYnSuNOg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D6A208017FB; Tue, 21 Jul 2020 05:34:43 +0000 (UTC) Received: from [10.72.12.202] (ovpn-12-202.pek2.redhat.com [10.72.12.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE86E5D9CA; Tue, 21 Jul 2020 05:34:35 +0000 (UTC) Subject: Re: [PATCH V2 vhost next 06/10] vdpa: Modify get_vq_state() to return error code To: Eli Cohen , mst@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: shahafs@mellanox.com, saeedm@mellanox.com, parav@mellanox.com References: <20200720071416.32112-1-eli@mellanox.com> <20200720071416.32112-7-eli@mellanox.com> From: Jason Wang Message-ID: <2e4a764e-391a-6b4e-26e0-1ccdd5d5e7a3@redhat.com> Date: Tue, 21 Jul 2020 13:34:33 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200720071416.32112-7-eli@mellanox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/7/20 下午3:14, Eli Cohen wrote: > 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 Acked-by: Jason Wang > --- > 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); >