From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-nvdimm@ml01.01.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, x86@kernel.org, boaz@plexistor.com,
axboe@kernel.dk
Subject: Re: [PATCH 1/3] pmem: Initial version of persistent memory driver
Date: Wed, 25 Mar 2015 14:21:53 -0600 [thread overview]
Message-ID: <1427314913.14654.1.camel@theros.lm.intel.com> (raw)
In-Reply-To: <1427299449-26722-2-git-send-email-hch@lst.de>
On Wed, 2015-03-25 at 17:04 +0100, Christoph Hellwig wrote:
> From: Ross Zwisler <ross.zwisler@linux.intel.com>
>
> PMEM is a new driver that presents a reserved range of memory as a
> block device. This is useful for developing with NV-DIMMs, and
> can be used with volatile memory as a development platform.
>
> Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> [hch: convert to use a platform_device for discovery, fix partition
> support]
Overall I really like this approach. It makes things simpler, removes
unneeded code and most importantly removes the ability for the user to have a
configuration where the PMEM / memmap reservation via the command line don't
match the parameters given to pmem.
What needed to be fixed with the partition support? I used to have real
numbers for first_minor and passed into alloc_disk(), but simplified it based
on code found in this commit in the nvme driver:
469071a37afc NVMe: Dynamically allocate partition numbers
This has worked fine for me - is there some test case in which it breaks?
> +static int pmem_probe(struct platform_device *pdev)
> +{
> + struct pmem_device *pmem;
> + struct gendisk *disk;
> + struct resource *res;
> + int idx, err;
> +
> + if (WARN_ON(pdev->num_resources > 1))
> + return -ENXIO;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res)
> + return -ENXIO;
> +
> + pmem = kzalloc(sizeof(*pmem), GFP_KERNEL);
> + if (unlikely(!pmem))
> + return -ENOMEM;
> +
> + pmem->phys_addr = res->start;
> + pmem->size = resource_size(res);
> +
> + err = pmem_mapmem(pmem);
> + if (unlikely(err))
> + goto out_free_dev;
> +
> + err = -ENOMEM;
> + pmem->pmem_queue = blk_alloc_queue(GFP_KERNEL);
> + if (unlikely(!pmem->pmem_queue))
> + goto out_unmap;
> +
> + blk_queue_make_request(pmem->pmem_queue, pmem_make_request);
> + blk_queue_max_hw_sectors(pmem->pmem_queue, 1024);
> + blk_queue_bounce_limit(pmem->pmem_queue, BLK_BOUNCE_ANY);
> +
> + disk = alloc_disk(PMEM_MINORS);
> + if (unlikely(!disk))
> + goto out_free_queue;
> +
> + idx = atomic_inc_return(&pmem_index) - 1;
> +
> + disk->major = pmem_major;
> + disk->first_minor = PMEM_MINORS * idx;
> + disk->fops = &pmem_fops;
> + disk->private_data = pmem;
> + disk->queue = pmem->pmem_queue;
> + disk->flags = GENHD_FL_EXT_DEVT;
> + sprintf(disk->disk_name, "pmem%d", idx);
> + disk->driverfs_dev = &pdev->dev;
> + set_capacity(disk, pmem->size >> SECTOR_SHIFT);
> + pmem->pmem_disk = disk;
> +
> + add_disk(disk);
> +
> + platform_set_drvdata(pdev, pmem);
> + return 0;
> +
> +out_free_queue:
> + blk_cleanup_queue(pmem->pmem_queue);
> +out_unmap:
> + pmem_unmapmem(pmem);
> +out_free_dev:
> + kfree(pmem);
> +out:
This label is no longer used, and can be removed.
next prev parent reply other threads:[~2015-03-25 20:21 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-25 16:04 another pmem variant Christoph Hellwig
2015-03-25 16:04 ` [PATCH 1/3] pmem: Initial version of persistent memory driver Christoph Hellwig
2015-03-25 20:19 ` Paul Bolle
2015-03-25 20:26 ` Ross Zwisler
2015-03-26 8:04 ` Christoph Hellwig
2015-03-25 20:21 ` Ross Zwisler [this message]
2015-03-26 8:06 ` Christoph Hellwig
2015-05-04 16:43 ` Ross Zwisler
2015-05-07 7:26 ` Christoph Hellwig
2015-05-07 8:35 ` Boaz Harrosh
2015-03-25 16:04 ` [PATCH 2/3] x86: add a is_e820_ram() helper Christoph Hellwig
2015-03-26 2:15 ` [Linux-nvdimm] " Dan Williams
2015-03-26 8:01 ` Christoph Hellwig
2015-03-26 13:57 ` Dan Williams
2015-03-26 14:32 ` Christoph Hellwig
2015-03-25 16:04 ` [PATCH 3/3] x86: add support for the non-standard protected e820 type Christoph Hellwig
2015-03-25 19:47 ` Elliott, Robert (Server Storage)
2015-03-26 8:02 ` Christoph Hellwig
2015-03-25 20:23 ` Ross Zwisler
2015-03-25 20:29 ` [Linux-nvdimm] " Dan Williams
2015-03-25 20:25 ` Ross Zwisler
2015-03-26 8:03 ` Christoph Hellwig
2015-03-25 20:35 ` [Linux-nvdimm] " Dan Williams
2015-03-25 16:33 ` [Linux-nvdimm] another pmem variant Dan Williams
2015-03-25 16:44 ` Christoph Hellwig
2015-03-25 17:00 ` Dan Williams
2015-03-25 17:04 ` Christoph Hellwig
2015-03-25 17:18 ` Dan Williams
2015-04-13 9:01 ` Greg KH
2015-04-13 16:02 ` Dan Williams
2015-03-25 18:09 ` Brooks, Adam J
2015-03-25 18:46 ` Christoph Hellwig
2015-03-25 21:02 ` Ross Zwisler
-- strict thread matches above, loose matches on Subject: below --
2015-03-26 8:32 another pmem variant V2 Christoph Hellwig
2015-03-26 8:32 ` [PATCH 1/3] pmem: Initial version of persistent memory driver Christoph Hellwig
2015-04-08 18:33 Dr. Greg Wettstein
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=1427314913.14654.1.camel@theros.lm.intel.com \
--to=ross.zwisler@linux.intel.com \
--cc=axboe@kernel.dk \
--cc=boaz@plexistor.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@ml01.01.org \
--cc=x86@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).