Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp572555ybv; Wed, 19 Feb 2020 05:11:21 -0800 (PST) X-Google-Smtp-Source: APXvYqyIrfaTkzpGHgWBaJ6QgRFn/paLdB2otC0lwRuzfqaCJhI0dKo46TruNj1kh4vvqgeo2gMG X-Received: by 2002:aca:e106:: with SMTP id y6mr4617633oig.131.1582117881617; Wed, 19 Feb 2020 05:11:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582117881; cv=none; d=google.com; s=arc-20160816; b=muF+pvqSbKLXy0Wy/3t/QXm1tDy9JC8f1IGOZM1kukyAo14zV9Y3RdpH/FXftPV9Dm Q0fxkGU25Ukno3ZnG07dKDiakl9n6CjQgTEw9zrTlVgteNbVRK8xOqqOL0tWwYd3uYef GHg6vbfxmn99RcVidxRI5hGUfHBNwQEoH5rdmPSScgn6YJ2Am87GTgCIAVlOAA5Ocooi nnEVYDRV3ISKDEcZcqUbnHQMQlf8OaaIUg7fVfnyN04SuHlaLbP/HKZR5mYQgVbTNU6j /1KsL4Q+zlSpqlJ3aMFMHD7yTz30rFhjyqRmUW3NyZ2aqP/ztycn+YY0Zgxm2H3sBhX3 8sKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vlvlwshc67nfmD8mnuDhiaIo5+M0W9hN5kIZIDEuy2Q=; b=FvSJfN0fVFJNie7Qy1PrFEr26kCooaInfGG1PG0JziztZL3YK+9I173WQiTqDXzpAO bQ1/JfZUGC1nXzobRUR/OBxQUrNgXPYvxTGcESkFiMhdDPJ/ybyNa4IiJmvELRdgVmc2 JMPyaOe5axZJ6OkG3ec+Tf43W13z5n+t5Cm5+72sXykFVv2Tqa2S9fcI7DuUSJ2TlFfb LlbI7+ZuVWH3vnU5lDzs7B+yS83JXuaVGIJoixAExdVBjHHbPKXiRcyQ1S/Xolg1DR9l 229YsamoTPZdMJhyNizuzhbDJW9Oa4Q2kF9I3qsdM8QFN8n7xWiFrkX7R3XqNG/ax8GL zb5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=Rtapr6oX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e15si1139372otq.237.2020.02.19.05.11.09; Wed, 19 Feb 2020 05:11:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=Rtapr6oX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727487AbgBSNLE (ORCPT + 99 others); Wed, 19 Feb 2020 08:11:04 -0500 Received: from mail-qv1-f66.google.com ([209.85.219.66]:38213 "EHLO mail-qv1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726530AbgBSNLE (ORCPT ); Wed, 19 Feb 2020 08:11:04 -0500 Received: by mail-qv1-f66.google.com with SMTP id g6so128480qvy.5 for ; Wed, 19 Feb 2020 05:11:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=vlvlwshc67nfmD8mnuDhiaIo5+M0W9hN5kIZIDEuy2Q=; b=Rtapr6oXl/ZaEBtZq5MfyQnS/XVirN0sBqwZyUReZu3pzXQ2HAamZkYWPIMCtWRriL PlfqwVm3qUiKuPhjgf2FqEOb+9LWbcBCTU0xBqkoZ4U5iBzYnXMvl909/fXT0InfuC8B N70oP0+7MZYJDZZXXBUxPVRTR5UdfeLhq0Lh2CTq7o9GjhBv/uMIfVcKsNgtBKWUA9Bd 687rV989HvQ3dUWl7k2hSZ8DC/1JiuaaFAFdwdrXBvqkfrDwFIG5yF4aQW32+XtdODc3 C5J+OVhXMAC39OjPPCXmC+cRSbvP8SRplMyRJ8iDX10PRgz2xf6J2YBsk10bMlJIqOjF /bBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=vlvlwshc67nfmD8mnuDhiaIo5+M0W9hN5kIZIDEuy2Q=; b=h8zwCwbU8dmGrmA8hsUS+hBqfKnuLbXc95Wg9/MLTvgEHiUtUxqLTG1MIddXH/863g zNE9ghiIE2xNc0vEnA1SGbq5/LpyMkS2Dd7IpBBsvaq6SrFhPibUQEpVWg7zvPd0z7WB NHvI5nGxVwi+KaJU71q39Q2kEz8AM2MIcwNYu1rXDNyqCgRdV+ab429b/9pr2ZetK+kS PeEMRBGffpHUB982KvLBlHPVDNkTwuQAVMITbaZ0pRCr/KD3OIIm6Y9HVqVqAtr5UEur vuOitB3xixzuMdmiHJZ6vhlDnARCcoRszJSOaLZDBxb/MYfFtawy3G8mQsu8Din6axam LNVA== X-Gm-Message-State: APjAAAVeNRcwY8844lLnM2K8VlqXVv1uR7jWcVTUp1G5HyQ51+t9Jjc9 J1sk+YDJ6QrEymPAZDeOWHhfWg== X-Received: by 2002:a05:6214:965:: with SMTP id do5mr20929587qvb.202.1582117863137; Wed, 19 Feb 2020 05:11:03 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id m95sm939421qte.41.2020.02.19.05.11.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Feb 2020 05:11:02 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1j4P82-000137-AB; Wed, 19 Feb 2020 09:11:02 -0400 Date: Wed, 19 Feb 2020 09:11:02 -0400 From: Jason Gunthorpe To: Tiwei Bie Cc: mst@redhat.com, jasowang@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, shahafs@mellanox.com, rob.miller@broadcom.com, haotian.wang@sifive.com, eperezma@redhat.com, lulu@redhat.com, parav@mellanox.com, rdunlap@infradead.org, hch@infradead.org, jiri@mellanox.com, hanand@xilinx.com, mhabets@solarflare.com, maxime.coquelin@redhat.com, lingshan.zhu@intel.com, dan.daly@intel.com, cunming.liang@intel.com, zhihong.wang@intel.com Subject: Re: [PATCH] vhost: introduce vDPA based backend Message-ID: <20200219131102.GN31668@ziepe.ca> References: <20200131033651.103534-1-tiwei.bie@intel.com> <20200218135359.GA9608@ziepe.ca> <20200219025217.GA971968@___> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200219025217.GA971968@___> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 19, 2020 at 10:52:38AM +0800, Tiwei Bie wrote: > > > +static int __init vhost_vdpa_init(void) > > > +{ > > > + int r; > > > + > > > + idr_init(&vhost_vdpa.idr); > > > + mutex_init(&vhost_vdpa.mutex); > > > + init_waitqueue_head(&vhost_vdpa.release_q); > > > + > > > + /* /dev/vhost-vdpa/$vdpa_device_index */ > > > + vhost_vdpa.class = class_create(THIS_MODULE, "vhost-vdpa"); > > > + if (IS_ERR(vhost_vdpa.class)) { > > > + r = PTR_ERR(vhost_vdpa.class); > > > + goto err_class; > > > + } > > > + > > > + vhost_vdpa.class->devnode = vhost_vdpa_devnode; > > > + > > > + r = alloc_chrdev_region(&vhost_vdpa.devt, 0, MINORMASK + 1, > > > + "vhost-vdpa"); > > > + if (r) > > > + goto err_alloc_chrdev; > > > + > > > + cdev_init(&vhost_vdpa.cdev, &vhost_vdpa_fops); > > > + r = cdev_add(&vhost_vdpa.cdev, vhost_vdpa.devt, MINORMASK + 1); > > > + if (r) > > > + goto err_cdev_add; > > > > It is very strange, is the intention to create a single global char > > dev? > > No. It's to create a per-vdpa char dev named > vhost-vdpa/$vdpa_device_index in dev. > > I followed the code in VFIO which creates char dev > vfio/$GROUP dynamically, e.g.: > > https://github.com/torvalds/linux/blob/b1da3acc781c/drivers/vfio/vfio.c#L2164-L2180 > https://github.com/torvalds/linux/blob/b1da3acc781c/drivers/vfio/vfio.c#L373-L387 > https://github.com/torvalds/linux/blob/b1da3acc781c/drivers/vfio/vfio.c#L1553 > > Is it something unwanted? Yes it is unwanted. This is some special pattern for vfio's unique needs. Since this has a struct device for each char dev instance please use the normal cdev_device_add() driven pattern here, or justify why it needs to be special like this. Jason