From: Jason Wang <jasowang@redhat.com>
To: Jason Gunthorpe <jgg@mellanox.com>
Cc: "mst@redhat.com" <mst@redhat.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"tiwei.bie@intel.com" <tiwei.bie@intel.com>,
"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>,
"cunming.liang@intel.com" <cunming.liang@intel.com>,
"zhihong.wang@intel.com" <zhihong.wang@intel.com>,
"rob.miller@broadcom.com" <rob.miller@broadcom.com>,
"xiao.w.wang@intel.com" <xiao.w.wang@intel.com>,
"haotian.wang@sifive.com" <haotian.wang@sifive.com>,
"lingshan.zhu@intel.com" <lingshan.zhu@intel.com>,
"eperezma@redhat.com" <eperezma@redhat.com>,
"lulu@redhat.com" <lulu@redhat.com>,
Parav Pandit <parav@mellanox.com>,
"kevin.tian@intel.com" <kevin.tian@intel.com>,
"stefanha@redhat.com" <stefanha@redhat.com>,
"rdunlap@infradead.org" <rdunlap@infradead.org>,
"hch@infradead.org" <hch@infradead.org>,
"aadam@redhat.com" <aadam@redhat.com>,
Jiri Pirko <jiri@mellanox.com>,
Shahaf Shuler <shahafs@mellanox.com>,
"hanand@xilinx.com" <hanand@xilinx.com>,
"mhabets@solarflare.com" <mhabets@solarflare.com>
Subject: Re: [PATCH V4 5/5] vdpasim: vDPA device simulator
Date: Wed, 26 Feb 2020 14:12:26 +0800 [thread overview]
Message-ID: <793a1b81-4f78-c405-4aae-f32a2bf67d87@redhat.com> (raw)
In-Reply-To: <6c341a77-a297-b7c7-dea5-b3f7b920b1f3@redhat.com>
On 2020/2/21 下午3:57, Jason Wang wrote:
>
> On 2020/2/20 下午11:12, Jason Gunthorpe wrote:
>> On Thu, Feb 20, 2020 at 02:11:41PM +0800, Jason Wang wrote:
>>> +static void vdpasim_device_release(struct device *dev)
>>> +{
>>> + struct vdpasim *vdpasim = dev_to_sim(dev);
>>> +
>>> + cancel_work_sync(&vdpasim->work);
>>> + kfree(vdpasim->buffer);
>>> + vhost_iotlb_free(vdpasim->iommu);
>>> + kfree(vdpasim);
>>> +}
>>> +
>>> +static struct vdpasim *vdpasim_create(void)
>>> +{
>>> + struct virtio_net_config *config;
>>> + struct vhost_iotlb *iommu;
>>> + struct vdpasim *vdpasim;
>>> + struct device *dev;
>>> + void *buffer;
>>> + int ret = -ENOMEM;
>>> +
>>> + iommu = vhost_iotlb_alloc(2048, 0);
>>> + if (!iommu)
>>> + goto err;
>>> +
>>> + buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
>>> + if (!buffer)
>>> + goto err_buffer;
>>> +
>>> + vdpasim = kzalloc(sizeof(*vdpasim), GFP_KERNEL);
>>> + if (!vdpasim)
>>> + goto err_alloc;
>>> +
>>> + vdpasim->buffer = buffer;
>>> + vdpasim->iommu = iommu;
>>> +
>>> + config = &vdpasim->config;
>>> + config->mtu = 1500;
>>> + config->status = VIRTIO_NET_S_LINK_UP;
>>> + eth_random_addr(config->mac);
>>> +
>>> + INIT_WORK(&vdpasim->work, vdpasim_work);
>>> + spin_lock_init(&vdpasim->lock);
>>> +
>>> + vringh_set_iotlb(&vdpasim->vqs[0].vring, vdpasim->iommu);
>>> + vringh_set_iotlb(&vdpasim->vqs[1].vring, vdpasim->iommu);
>>> +
>>> + dev = &vdpasim->dev;
>>> + dev->release = vdpasim_device_release;
>>> + dev->coherent_dma_mask = DMA_BIT_MASK(64);
>>> + set_dma_ops(dev, &vdpasim_dma_ops);
>>> + dev_set_name(dev, "%s", VDPASIM_NAME);
>>> +
>>> + ret = device_register(&vdpasim->dev);
>>> + if (ret)
>>> + goto err_init;
>> It is a bit weird to be creating this dummy parent, couldn't this be
>> done by just passing a NULL parent to vdpa_alloc_device, doing
>> set_dma_ops() on the vdpasim->vdpa->dev and setting dma_device to
>> vdpasim->vdpa->dev ?
>
>
> I think it works.
Rethink about this, since most hardware vDPA driver will have a parent
and will use it to find the parent structure e.g
dev_get_drvdata(vdpa->dev->parent)
So I keep this dummy parent in V5.
Thanks
WARNING: multiple messages have this Message-ID (diff)
From: Jason Wang <jasowang@redhat.com>
To: Jason Gunthorpe <jgg@mellanox.com>
Cc: "mst@redhat.com" <mst@redhat.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"tiwei.bie@intel.com" <tiwei.bie@intel.com>,
"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>,
"cunming.liang@intel.com" <cunming.liang@intel.com>,
"zhihong.wang@intel.com" <zhihong.wang@intel.com>,
"rob.miller@broadcom.com" <rob.miller@broadcom.com>,
"xiao.w.wang@intel.com" <xiao.w.wang@intel.com>,
"haotian.wang@sifive.com" <haotian.wang@sifive.com>,
"lingshan.zhu@intel.com" <lingshan.zhu@intel.com>,
"eperezma@redhat.com" <eperezma@redhat.com>,
"lulu@redhat.com" <lulu@redhat.co>
Subject: Re: [PATCH V4 5/5] vdpasim: vDPA device simulator
Date: Wed, 26 Feb 2020 14:12:26 +0800 [thread overview]
Message-ID: <793a1b81-4f78-c405-4aae-f32a2bf67d87@redhat.com> (raw)
In-Reply-To: <6c341a77-a297-b7c7-dea5-b3f7b920b1f3@redhat.com>
On 2020/2/21 下午3:57, Jason Wang wrote:
>
> On 2020/2/20 下午11:12, Jason Gunthorpe wrote:
>> On Thu, Feb 20, 2020 at 02:11:41PM +0800, Jason Wang wrote:
>>> +static void vdpasim_device_release(struct device *dev)
>>> +{
>>> + struct vdpasim *vdpasim = dev_to_sim(dev);
>>> +
>>> + cancel_work_sync(&vdpasim->work);
>>> + kfree(vdpasim->buffer);
>>> + vhost_iotlb_free(vdpasim->iommu);
>>> + kfree(vdpasim);
>>> +}
>>> +
>>> +static struct vdpasim *vdpasim_create(void)
>>> +{
>>> + struct virtio_net_config *config;
>>> + struct vhost_iotlb *iommu;
>>> + struct vdpasim *vdpasim;
>>> + struct device *dev;
>>> + void *buffer;
>>> + int ret = -ENOMEM;
>>> +
>>> + iommu = vhost_iotlb_alloc(2048, 0);
>>> + if (!iommu)
>>> + goto err;
>>> +
>>> + buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
>>> + if (!buffer)
>>> + goto err_buffer;
>>> +
>>> + vdpasim = kzalloc(sizeof(*vdpasim), GFP_KERNEL);
>>> + if (!vdpasim)
>>> + goto err_alloc;
>>> +
>>> + vdpasim->buffer = buffer;
>>> + vdpasim->iommu = iommu;
>>> +
>>> + config = &vdpasim->config;
>>> + config->mtu = 1500;
>>> + config->status = VIRTIO_NET_S_LINK_UP;
>>> + eth_random_addr(config->mac);
>>> +
>>> + INIT_WORK(&vdpasim->work, vdpasim_work);
>>> + spin_lock_init(&vdpasim->lock);
>>> +
>>> + vringh_set_iotlb(&vdpasim->vqs[0].vring, vdpasim->iommu);
>>> + vringh_set_iotlb(&vdpasim->vqs[1].vring, vdpasim->iommu);
>>> +
>>> + dev = &vdpasim->dev;
>>> + dev->release = vdpasim_device_release;
>>> + dev->coherent_dma_mask = DMA_BIT_MASK(64);
>>> + set_dma_ops(dev, &vdpasim_dma_ops);
>>> + dev_set_name(dev, "%s", VDPASIM_NAME);
>>> +
>>> + ret = device_register(&vdpasim->dev);
>>> + if (ret)
>>> + goto err_init;
>> It is a bit weird to be creating this dummy parent, couldn't this be
>> done by just passing a NULL parent to vdpa_alloc_device, doing
>> set_dma_ops() on the vdpasim->vdpa->dev and setting dma_device to
>> vdpasim->vdpa->dev ?
>
>
> I think it works.
Rethink about this, since most hardware vDPA driver will have a parent
and will use it to find the parent structure e.g
dev_get_drvdata(vdpa->dev->parent)
So I keep this dummy parent in V5.
Thanks
next prev parent reply other threads:[~2020-02-26 6:13 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-20 6:11 [PATCH V4 0/5] vDPA support Jason Wang
2020-02-20 6:11 ` [PATCH V4 1/5] vhost: factor out IOTLB Jason Wang
2020-02-20 6:11 ` [PATCH V4 2/5] vringh: IOTLB support Jason Wang
2020-02-20 6:11 ` [PATCH V4 3/5] vDPA: introduce vDPA bus Jason Wang
2020-02-20 15:14 ` Jason Gunthorpe
2020-02-20 15:14 ` Jason Gunthorpe
2020-02-21 7:54 ` Jason Wang
2020-02-21 7:54 ` Jason Wang
2020-02-24 6:14 ` Harpreet Singh Anand
2020-02-24 6:14 ` Harpreet Singh Anand
2020-02-24 6:48 ` Jason Wang
2020-02-24 6:48 ` Jason Wang
2020-02-20 6:11 ` [PATCH V4 4/5] virtio: introduce a vDPA based transport Jason Wang
2020-02-20 15:19 ` Jason Gunthorpe
2020-02-20 15:19 ` Jason Gunthorpe
2020-02-21 8:06 ` Jason Wang
2020-02-21 8:06 ` Jason Wang
2020-02-20 6:11 ` [PATCH V4 5/5] vdpasim: vDPA device simulator Jason Wang
2020-02-20 15:12 ` Jason Gunthorpe
2020-02-20 15:12 ` Jason Gunthorpe
2020-02-21 7:57 ` Jason Wang
2020-02-21 7:57 ` Jason Wang
2020-02-26 6:12 ` Jason Wang [this message]
2020-02-26 6:12 ` Jason Wang
2020-02-26 17:19 ` Jason Gunthorpe
2020-02-26 17:19 ` Jason Gunthorpe
2020-02-21 8:33 ` Harpreet Singh Anand
2020-02-21 8:33 ` Harpreet Singh Anand
2020-02-21 8:50 ` Jason Wang
2020-02-21 8:50 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=793a1b81-4f78-c405-4aae-f32a2bf67d87@redhat.com \
--to=jasowang@redhat.com \
--cc=aadam@redhat.com \
--cc=cunming.liang@intel.com \
--cc=eperezma@redhat.com \
--cc=hanand@xilinx.com \
--cc=haotian.wang@sifive.com \
--cc=hch@infradead.org \
--cc=jgg@mellanox.com \
--cc=jiri@mellanox.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=lingshan.zhu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lulu@redhat.com \
--cc=maxime.coquelin@redhat.com \
--cc=mhabets@solarflare.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=parav@mellanox.com \
--cc=rdunlap@infradead.org \
--cc=rob.miller@broadcom.com \
--cc=shahafs@mellanox.com \
--cc=stefanha@redhat.com \
--cc=tiwei.bie@intel.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=xiao.w.wang@intel.com \
--cc=zhihong.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.