Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp299552pxa; Wed, 5 Aug 2020 01:11:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCqhtGIhSnKidfpYmzr5vzyGEeJ+G0x8euNC0hQ+4ejyDqWLOEcUIL55Wck9m6k8m3hOQi X-Received: by 2002:a17:906:c08a:: with SMTP id f10mr1991740ejz.181.1596615109578; Wed, 05 Aug 2020 01:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596615109; cv=none; d=google.com; s=arc-20160816; b=JNUwZ0/eC/4R1PkS9QEhXyXhw9z5Qm/ucx8pnMTWd1Ado/FDE5vbk7oPsUf/NTarhL EoMOenqjHvOYzSJvrFXxmVdWRYIyoguZY/xgz7H0fzEYQ1EtKErAiV1ga+akbxW4Cgo/ gVWOVt9OLfT3vzYc0TgFYNjZk7N2WzUH7op+W5KtHPV5kshHnmHrWR2q8xN9oy9dI8uz aKT1j4026sgx8r3xZXg+5XtAqakMitikcx8uoszjxx46y+Q9rt4ahEp+V2nRFIzIp0+T kFot8uKZoqDy5McEWR/LBXAL8YETdc3XrWNLkiuN2/q/1VYKdc+jVkrnTDomBQHQDvJx GXPg== 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=54CekOq5nyKMM7BtMGAhsULPFpA9SluWl2e7PxuQNBc=; b=PUf2sVu7CEhPQBgADxABhotJEhNEjWt5VNC+ifMxBGGlVZLO5jjXqNMompF/AlmfNQ TXfj83lS783fYN6ujU5hliDDGkWqLoEDkdAAOZKqs+J2+P37JQsKO4daRcj/4eevZ4ty PqfZmy+iEUWwP1a8GALccZPjHTiLECjM4jRl9S5nNcand+R/YcHPLYGSsenfTqf9pRlc 5YGJWLmCMqKw6DV9bwPNI5lFy8M2ekAqIp190dw7i2r0uQ1v8lk3g+u049AWUoMjPlxE n+PXYVo07J2yDPp3Yt0rfKSXpL9TPRex6LaUT+7knAccBC8oXup8v3jNvipWSLc9TyzZ iCCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Ldy/ymRa"; 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 qw20si820115ejb.371.2020.08.05.01.11.24; Wed, 05 Aug 2020 01:11:49 -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="Ldy/ymRa"; 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 S1728301AbgHEILL (ORCPT + 99 others); Wed, 5 Aug 2020 04:11:11 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:32100 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728198AbgHEILK (ORCPT ); Wed, 5 Aug 2020 04:11:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596615061; 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=54CekOq5nyKMM7BtMGAhsULPFpA9SluWl2e7PxuQNBc=; b=Ldy/ymRaMF+GbqTSDAJvtNZubbdF1WWy1BF53vDNEY+UdgHFwFlTSHDZ2pak6Fxv2ziA50 /vF/ZukogEh07qpvaOzyXzfwcjxzIAvIrXTwQ7CCANANu6OEhUl4H8Y7SFQ/rfOzOvgFvy k/97+vi5BXmCnBoBtrQ+aaDsiEUdIVQ= 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-118-jW_6k5W0NICd4wdnZXdEJA-1; Wed, 05 Aug 2020 04:10:59 -0400 X-MC-Unique: jW_6k5W0NICd4wdnZXdEJA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0CA748B4279; Wed, 5 Aug 2020 08:10:51 +0000 (UTC) Received: from [10.72.12.225] (ovpn-12-225.pek2.redhat.com [10.72.12.225]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2765719C4F; Wed, 5 Aug 2020 08:10:47 +0000 (UTC) Subject: Re: [PATCH V4 linux-next 08/12] 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: <20200804162048.22587-1-eli@mellanox.com> <20200804162048.22587-9-eli@mellanox.com> From: Jason Wang Message-ID: <972bc164-0d9d-a7fa-6929-daee843f04d7@redhat.com> Date: Wed, 5 Aug 2020 16:10:46 +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: <20200804162048.22587-9-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.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/8/5 上午12:20, 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 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);