Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp654718yba; Thu, 16 May 2019 07:00:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcWxqXzd5OJfJfpFYgCUO11tWi1xuaoyu/59B/O8bDWZJXnl0EwxUjiRVkJ5vkSSEEm9Tp X-Received: by 2002:a63:4820:: with SMTP id v32mr50072778pga.89.1558015221258; Thu, 16 May 2019 07:00:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558015221; cv=none; d=google.com; s=arc-20160816; b=0IhxKCvhvbLsssIPp0b/E3VkSG3CVLvCn3rlURYK6DhN+spNmjnRpBw1hv/WPjlHx8 yJ2k5F4+A4SrCxJhKdHwvwf/BBfMxQTXRh1NL5xJJJIxHBSbDFGi7lRkK7s37DAKuKEp iiOiXRPkIJ3Jut5x5UVrHcZenpvC2bDQeuN4z8+Zis8MVCfml24BYZ4aOuc4u4A/UOT1 UNEirZZsJOqsmSPC0PBse0kzRwiG342bKCsY6jJHgOhyjILGEG5aA5cClzWFF3hRRYGL rsOZ5l9WNabd5hkZN/0wA5ZRRe+1R3Rq2S6/dz4ZByxjHfuVFB8JFT3vFPg+axhVe6l3 PMfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=4W8nxk4k4MVtLI1JLQcZmk+Bl22d4lanY5c6NY2cMcc=; b=YdYuOB+prTWaBedIpx6rdO4EOduqDCKgFkUJfL9K9J2Ak3c6/RHWHecbkC8hOsxxNw 0IfBDvl4Fb7epbtuMbTIf6EmOA07SswEt0UtKxislO2AM+wgvsM9lc8JO5KjrwcGQvBh dpg/j+ztDsTb2K6jz27IC3gU+0LgtU+ze19EZXxXqrBxijzrYh77Rct8DiwW16vgM90g 081Dy2vRX4ZhqN4TEm7/jjKnrM/6uPfpVINLGucPieLbSXCyClNCE2rlw2LK3UXi7W1q E12KGtZCs5ghELR3Jmzc5+XiOfGBZJOSwOrK480IVuJUeyudI+HOXXnkDLkCEErw5BRV qpGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o23si4711708pgm.595.2019.05.16.07.00.01; Thu, 16 May 2019 07:00:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727455AbfEPN7V (ORCPT + 99 others); Thu, 16 May 2019 09:59:21 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:35713 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726758AbfEPN7U (ORCPT ); Thu, 16 May 2019 09:59:20 -0400 Received: by mail-qt1-f194.google.com with SMTP id a39so4010797qtk.2 for ; Thu, 16 May 2019 06:59:19 -0700 (PDT) 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; bh=4W8nxk4k4MVtLI1JLQcZmk+Bl22d4lanY5c6NY2cMcc=; b=VxyNZWfrgtnB9ptUWo6s47B71sYxNkC0dG6MevW7/M4L8zdvjKMTcmdN2OyjW/Z2Si +qY4DnHfikMiiqWp9/+nawr3UoHY1GoZ26jjqgOqdjQyxBlFiRl2zaH4qKt/HGWXPKG6 9CjxJriJ3QqK5V5iUhEcsjILjavqJCerLfJCWnHaHzjE9IdI9qCG8u2gRuVSsPZ1YZj9 LTsvZp3upcxVGTw5pIBrVZLx4RzMik+uuD+TgDqcUpl8V2mTLaNWq1eLQxywNb8N1HWy L4lq/z4LfP5QueAjkochMvzukrkCE0X7iXJqRwPevf9P3tceqFURZMtXkGJoY5pbOLf6 tOPw== X-Gm-Message-State: APjAAAWNIw2EIcYLTroO6FlHGnVZwkEPKerlQpiKnPlHMw6JQt3A3Ii0 yM0M6sc6OkTNYGeXQUPvgC9Ybg== X-Received: by 2002:a0c:fe48:: with SMTP id u8mr39012393qvs.234.1558015159428; Thu, 16 May 2019 06:59:19 -0700 (PDT) Received: from redhat.com ([185.54.206.10]) by smtp.gmail.com with ESMTPSA id o37sm3676500qta.86.2019.05.16.06.59.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 16 May 2019 06:59:18 -0700 (PDT) Date: Thu, 16 May 2019 09:59:09 -0400 From: "Michael S. Tsirkin" To: David Hildenbrand Cc: Pankaj Gupta , linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-acpi@vger.kernel.org, qemu-devel@nongnu.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, dan.j.williams@intel.com, zwisler@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, jasowang@redhat.com, willy@infradead.org, rjw@rjwysocki.net, hch@infradead.org, lenb@kernel.org, jack@suse.cz, tytso@mit.edu, adilger.kernel@dilger.ca, darrick.wong@oracle.com, lcapitulino@redhat.com, kwolf@redhat.com, imammedo@redhat.com, jmoyer@redhat.com, nilal@redhat.com, riel@surriel.com, stefanha@redhat.com, aarcange@redhat.com, david@fromorbit.com, cohuck@redhat.com, xiaoguangrong.eric@gmail.com, pbonzini@redhat.com, kilobyte@angband.pl, yuval.shaia@oracle.com, jstaron@google.com Subject: Re: [PATCH v9 2/7] virtio-pmem: Add virtio pmem driver Message-ID: <20190516095618-mutt-send-email-mst@kernel.org> References: <20190514145422.16923-1-pagupta@redhat.com> <20190514145422.16923-3-pagupta@redhat.com> <9f6b1d8e-ef90-7d8b-56da-61a426953ba3@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9f6b1d8e-ef90-7d8b-56da-61a426953ba3@redhat.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, May 15, 2019 at 10:46:00PM +0200, David Hildenbrand wrote: > > + vpmem->vdev = vdev; > > + vdev->priv = vpmem; > > + err = init_vq(vpmem); > > + if (err) { > > + dev_err(&vdev->dev, "failed to initialize virtio pmem vq's\n"); > > + goto out_err; > > + } > > + > > + virtio_cread(vpmem->vdev, struct virtio_pmem_config, > > + start, &vpmem->start); > > + virtio_cread(vpmem->vdev, struct virtio_pmem_config, > > + size, &vpmem->size); > > + > > + res.start = vpmem->start; > > + res.end = vpmem->start + vpmem->size-1; > > nit: " - 1;" > > > + vpmem->nd_desc.provider_name = "virtio-pmem"; > > + vpmem->nd_desc.module = THIS_MODULE; > > + > > + vpmem->nvdimm_bus = nvdimm_bus_register(&vdev->dev, > > + &vpmem->nd_desc); > > + if (!vpmem->nvdimm_bus) { > > + dev_err(&vdev->dev, "failed to register device with nvdimm_bus\n"); > > + err = -ENXIO; > > + goto out_vq; > > + } > > + > > + dev_set_drvdata(&vdev->dev, vpmem->nvdimm_bus); > > + > > + ndr_desc.res = &res; > > + ndr_desc.numa_node = nid; > > + ndr_desc.flush = async_pmem_flush; > > + set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags); > > + set_bit(ND_REGION_ASYNC, &ndr_desc.flags); > > + nd_region = nvdimm_pmem_region_create(vpmem->nvdimm_bus, &ndr_desc); > > + if (!nd_region) { > > + dev_err(&vdev->dev, "failed to create nvdimm region\n"); > > + err = -ENXIO; > > + goto out_nd; > > + } > > + nd_region->provider_data = dev_to_virtio(nd_region->dev.parent->parent); > > + return 0; > > +out_nd: > > + nvdimm_bus_unregister(vpmem->nvdimm_bus); > > +out_vq: > > + vdev->config->del_vqs(vdev); > > +out_err: > > + return err; > > +} > > + > > +static void virtio_pmem_remove(struct virtio_device *vdev) > > +{ > > + struct nvdimm_bus *nvdimm_bus = dev_get_drvdata(&vdev->dev); > > + > > + nvdimm_bus_unregister(nvdimm_bus); > > + vdev->config->del_vqs(vdev); > > + vdev->config->reset(vdev); > > +} > > + > > +static struct virtio_driver virtio_pmem_driver = { > > + .driver.name = KBUILD_MODNAME, > > + .driver.owner = THIS_MODULE, > > + .id_table = id_table, > > + .probe = virtio_pmem_probe, > > + .remove = virtio_pmem_remove, > > +}; > > + > > +module_virtio_driver(virtio_pmem_driver); > > +MODULE_DEVICE_TABLE(virtio, id_table); > > +MODULE_DESCRIPTION("Virtio pmem driver"); > > +MODULE_LICENSE("GPL"); > > diff --git a/drivers/nvdimm/virtio_pmem.h b/drivers/nvdimm/virtio_pmem.h > > new file mode 100644 > > index 000000000000..ab1da877575d > > --- /dev/null > > +++ b/drivers/nvdimm/virtio_pmem.h > > @@ -0,0 +1,60 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +/* > > + * virtio_pmem.h: virtio pmem Driver > > + * > > + * Discovers persistent memory range information > > + * from host and provides a virtio based flushing > > + * interface. > > + **/ > > + > > +#ifndef _LINUX_VIRTIO_PMEM_H > > +#define _LINUX_VIRTIO_PMEM_H > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +struct virtio_pmem_request { > > + /* Host return status corresponding to flush request */ > > + int ret; > > + > > + /* command name*/ > > + char name[16]; > > So ... why are we sending string commands and expect native-endianess > integers and don't define a proper request/response structure + request > types in include/uapi/linux/virtio_pmem.h like passing names could be ok. I missed the fact we return a native endian int. Pls fix that. > > struct virtio_pmem_resp { > __virtio32 ret; > } > > #define VIRTIO_PMEM_REQ_TYPE_FLUSH 1 > struct virtio_pmem_req { > __virtio16 type; > } > > ... and this way we also define a proper endianess format for exchange > and keep it extensible > > @MST, what's your take on this? Extensions can always use feature bits so I don't think it's a problem. > > -- > > Thanks, > > David / dhildenb