Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp167612ybv; Wed, 19 Feb 2020 18:43:06 -0800 (PST) X-Google-Smtp-Source: APXvYqxpKE71ipOQi5qg0qSQfM9jQJJ6leXeUE4i0NLykpMMtQdtJdr93DbLyEfLb4bljj7Te1GE X-Received: by 2002:a9d:7a56:: with SMTP id z22mr20665171otm.201.1582166586142; Wed, 19 Feb 2020 18:43:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582166586; cv=none; d=google.com; s=arc-20160816; b=N0apRcC5atubC7eGqUDFJhlRzs5u0SiBc9PAOpXXRl+l9Pq4RWKDTkJCU7AXD4MUnZ zg9fu6UH8t4g8hHu3kzuriX4JFj2UYlmBm9FbZsr97r0j7t4veOE6c/qwmnoO4CBaB+0 +sWQJOzyF8sq+1nvvW6MvCpKsNdy7iDZT8zkOhadikOoxJ029rW5ZpVOvvVH0XgEJlI6 8r93fb/DJToORrp8j5cfKQcG3NvKe1VxnjINQ3T4L5Y5tNC94Dfs5Zfm6CuPpsO1Ynj+ bu59v420JF9fCjAUmbOkuTKhok5UqbUh/le7/yCEZ7r7TpXHdMp7g24fCoTgHTZZ88+E SU6A== 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; bh=HiaWxxYWg8XGZLtWfyy+blYoCfkdUCeGyal8nOKYwIw=; b=CRic0GmA7QT69HOhE0oVUozaIpHqjFUvIFKWLlkLV/Ojy+GuV/98bzwKNV7rYUJVg7 6t8iUYscqE4p+UgeHu0uYR27YuUUQyk46YybMCO3RcDzA4o/TZrBHsir0akCXdG8oU+U 2BcC8/OTbudu7KEFwA+p36Jd5Z+Q5lmJ2aSNk4JW//sz7jD3kDetkIycfKIQxxc+FN/a tI34xLGqucqHvmE4B9wlDOX6ku22Hga64tASwmCocCv6Mcr99d2Eky7NPZZp/suCGUvF 6ObZ7p1k6qQh3JvyaHlatbGTMmp150QcPSDTc4HwbUdkFSU4ruEJTohEWvreTqAxhPEw A6PQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q66si10156096oig.65.2020.02.19.18.42.54; Wed, 19 Feb 2020 18:43:06 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727851AbgBTCmt (ORCPT + 99 others); Wed, 19 Feb 2020 21:42:49 -0500 Received: from mga02.intel.com ([134.134.136.20]:48607 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727211AbgBTCmt (ORCPT ); Wed, 19 Feb 2020 21:42:49 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Feb 2020 18:42:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,462,1574150400"; d="scan'208";a="229327721" Received: from dpdk-virtio-tbie-2.sh.intel.com (HELO ___) ([10.67.104.74]) by orsmga008.jf.intel.com with ESMTP; 19 Feb 2020 18:42:42 -0800 Date: Thu, 20 Feb 2020 10:42:21 +0800 From: Tiwei Bie To: Jason Gunthorpe 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: <20200220024220.GA43609@___> References: <20200131033651.103534-1-tiwei.bie@intel.com> <20200218135359.GA9608@ziepe.ca> <20200219025217.GA971968@___> <20200219131102.GN31668@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200219131102.GN31668@ziepe.ca> 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 09:11:02AM -0400, Jason Gunthorpe wrote: > 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. I see. Thanks! I will embed the cdev in each vhost_vdpa structure directly. Regards, Tiwei > > Jason