From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DACC5C10F13 for ; Mon, 8 Apr 2019 13:20:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B04B72147A for ; Mon, 8 Apr 2019 13:20:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726584AbfDHNUy (ORCPT ); Mon, 8 Apr 2019 09:20:54 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36550 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726463AbfDHNUy (ORCPT ); Mon, 8 Apr 2019 09:20:54 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x38DI15H025264 for ; Mon, 8 Apr 2019 09:20:52 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2rr61m3y2k-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 08 Apr 2019 09:20:52 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 8 Apr 2019 14:20:50 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 8 Apr 2019 14:20:47 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x38DKjTh61014248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 8 Apr 2019 13:20:45 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A4E15A4065; Mon, 8 Apr 2019 13:20:45 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1A206A4051; Mon, 8 Apr 2019 13:20:45 +0000 (GMT) Received: from oc2783563651 (unknown [9.152.224.40]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 8 Apr 2019 13:20:45 +0000 (GMT) Date: Mon, 8 Apr 2019 15:20:43 +0200 From: Halil Pasic To: Cornelia Huck Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, Martin Schwidefsky , Sebastian Ott , virtualization@lists.linux-foundation.org, Christian Borntraeger , Viktor Mihajlovski , Vasily Gorbik , Janosch Frank , Claudio Imbrenda , Farhan Ali , Eric Farman , "Michael S . Tsirkin" Subject: Re: [RFC PATCH 01/12] virtio/s390: use vring_create_virtqueue In-Reply-To: <20190408130128.7859febe.cohuck@redhat.com> References: <20190404231622.52531-1-pasic@linux.ibm.com> <20190404231622.52531-2-pasic@linux.ibm.com> <20190408130128.7859febe.cohuck@redhat.com> Organization: IBM X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 19040813-4275-0000-0000-00000325892B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19040813-4276-0000-0000-000038349ED5 Message-Id: <20190408152043.42ff22fc@oc2783563651> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-08_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904080111 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Mon, 8 Apr 2019 13:01:28 +0200 Cornelia Huck wrote: > On Fri, 5 Apr 2019 01:16:11 +0200 > Halil Pasic wrote: > > > The commit 2a2d1382fe9d ("virtio: Add improved queue allocation API") > > establishes a new way of allocating virtqueues (as a part of the effort > > that taught DMA to virtio rings). > > > > In the future we will want virtio-ccw to use the DMA API as well. > > > > Let us switch from the legacy method of allocating virtqueues to > > vring_create_virtqueue() as the first step into that direction. > > > > Signed-off-by: Halil Pasic > > --- > > drivers/s390/virtio/virtio_ccw.c | 27 ++++++++------------------- > > 1 file changed, 8 insertions(+), 19 deletions(-) > > > > diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c > > index 74c328321889..edf4afe2d688 100644 > > --- a/drivers/s390/virtio/virtio_ccw.c > > +++ b/drivers/s390/virtio/virtio_ccw.c > > > @@ -516,17 +512,10 @@ static struct virtqueue *virtio_ccw_setup_vq(struct virtio_device *vdev, > > err = info->num; > > goto out_err; > > } > > - size = PAGE_ALIGN(vring_size(info->num, KVM_VIRTIO_CCW_RING_ALIGN)); > > - info->queue = alloc_pages_exact(size, GFP_KERNEL | __GFP_ZERO); > > - if (info->queue == NULL) { > > - dev_warn(&vcdev->cdev->dev, "no queue\n"); > > - err = -ENOMEM; > > - goto out_err; > > - } > > + vq = vring_create_virtqueue(i, info->num, KVM_VIRTIO_CCW_RING_ALIGN, > > + vdev, true, true, ctx, > > This second true means 'may_reduce_num'. Looking at the vring code, it > seems that this parameter is never checked; the code will try to > allocate a smaller queue if it can't get the requested size in any > case... this will probably be a problem for legacy virtio-pci, which > explicitly sets may_reduce_num to false. (I can try to come up with a > patch to fix that.) > Right. > > + virtio_ccw_kvm_notify, callback, name); > > > > - vq = vring_new_virtqueue(i, info->num, KVM_VIRTIO_CCW_RING_ALIGN, vdev, > > - true, ctx, info->queue, virtio_ccw_kvm_notify, > > - callback, name); > > if (!vq) { > > /* For now, we fail if we can't get the requested size. */ > > dev_warn(&vcdev->cdev->dev, "no vq\n"); > > @@ -534,15 +523,17 @@ static struct virtqueue *virtio_ccw_setup_vq(struct virtio_device *vdev, > > goto out_err; > > } > > > > + > > Extra blank line :) > > > /* Register it with the host. */ > > + queue = virtqueue_get_desc_addr(vq); > > if (vcdev->revision == 0) { > > - info->info_block->l.queue = (__u64)info->queue; > > + info->info_block->l.queue = queue; > > info->info_block->l.align = KVM_VIRTIO_CCW_RING_ALIGN; > > info->info_block->l.index = i; > > info->info_block->l.num = info->num; > > You always fill in the size requested by the host, but the actual size > may be smaller (see above). I don't think that is allowed for revision > 0 (which implies !virtio-1). You probably need to call > vring_create_virtqueue with may_reduce_num=false for revision 0 (and > wait for the generic vring code to be fixed...) I will have a look into this. > > > ccw->count = sizeof(info->info_block->l); > > } else { > > - info->info_block->s.desc = (__u64)info->queue; > > + info->info_block->s.desc = queue; > > info->info_block->s.index = i; > > info->info_block->s.num = info->num; > > Here, you need to obtain the actual number via > virtqueue_get_vring_size(). > Will change as requested. Thanks for having a look! Regards, Halil > > info->info_block->s.avail = (__u64)virtqueue_get_avail(vq); >