From: Boaz Harrosh <openosd@gmail.com>
To: Boaz Harrosh <boaz@plexistor.com>, Christoph Hellwig <hch@lst.de>
Cc: linux-nvdimm@ml01.01.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, x86@kernel.org,
ross.zwisler@linux.intel.com, axboe@kernel.dk
Subject: [RFC] SQUASHME: pmem: Split up pmem_probe from pmem_alloc
Date: Tue, 31 Mar 2015 17:21:15 +0300 [thread overview]
Message-ID: <551AAD5B.4020104@gmail.com> (raw)
In-Reply-To: <551A762A.7090307@plexistor.com>
On 03/31/2015 01:25 PM, Boaz Harrosh wrote:
<>
>
> And one last issue. I have some configuration "hardness" with the
> memmap=nn!aa Kernel command line API, it was better for me with the
> pmem map= module param. Will you be OK if I split pmem_probe() into
> calling pmem_alloc(addr, length), so I can keep an out-of-tree patch
> that adds the map= parameter to pmem?
>
Hi Christoph.
Is this too much ugly for you? The reason I need it is because
I would like to keep out-of-tree a patch that adds back the
map= module param so to have more fine grain control of my
pmem devices.
[And also to have mapping control per pmem device. For example
one device can be pages-mapped another uncached ioremap, 3rd
write through mapping, and so on]
In the patch if pmem loads without map= it will load like
yours, but if map= is not empty it will not call platform_driver_register()
and will manually load devices as before.
I can still do this, of course. But with this here split patch
it will be easier to maintain.
Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
---
drivers/block/pmem.c | 48 +++++++++++++++++++++++++++++++++---------------
1 file changed, 33 insertions(+), 15 deletions(-)
diff --git a/drivers/block/pmem.c b/drivers/block/pmem.c
index 62cc9d0..0fc5c66 100644
--- a/drivers/block/pmem.c
+++ b/drivers/block/pmem.c
@@ -193,20 +193,13 @@ static void pmem_unmapmem(struct pmem_device *pmem)
#endif /* !CONFIG_BLK_DEV_PMEM_USE_PAGES */
-static int pmem_probe(struct platform_device *pdev)
+static int pmem_alloc(struct resource *res, struct device *dev,
+ struct pmem_device **o_pmem)
{
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 (unlikely(!res))
- return -ENXIO;
-
pmem = kzalloc(sizeof(*pmem), GFP_KERNEL);
if (unlikely(!pmem))
return -ENOMEM;
@@ -240,13 +233,12 @@ static int pmem_probe(struct platform_device *pdev)
disk->queue = pmem->pmem_queue;
disk->flags = GENHD_FL_EXT_DEVT;
sprintf(disk->disk_name, "pmem%d", idx);
- disk->driverfs_dev = &pdev->dev;
+ disk->driverfs_dev = dev;
set_capacity(disk, pmem->size >> 9);
pmem->pmem_disk = disk;
add_disk(disk);
-
- platform_set_drvdata(pdev, pmem);
+ *o_pmem = pmem;
return 0;
out_free_queue:
@@ -255,19 +247,45 @@ out_unmap:
pmem_unmapmem(pmem);
out_free_dev:
kfree(pmem);
+ *o_pmem = NULL;
return err;
}
-static int pmem_remove(struct platform_device *pdev)
+static void pmem_free(struct pmem_device *pmem)
{
- struct pmem_device *pmem = platform_get_drvdata(pdev);
-
del_gendisk(pmem->pmem_disk);
put_disk(pmem->pmem_disk);
blk_cleanup_queue(pmem->pmem_queue);
pmem_unmapmem(pmem);
kfree(pmem);
+}
+
+static int pmem_probe(struct platform_device *pdev)
+{
+ struct pmem_device *pmem;
+ struct resource *res;
+ int err;
+
+ if (WARN_ON(pdev->num_resources > 1))
+ return -ENXIO;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (unlikely(!res))
+ return -ENXIO;
+
+ err = pmem_alloc(res, &pdev->dev, &pmem);
+ if (unlikely(err))
+ return err;
+
+ platform_set_drvdata(pdev, pmem);
+ return 0;
+}
+
+static int pmem_remove(struct platform_device *pdev)
+{
+ struct pmem_device *pmem = platform_get_drvdata(pdev);
+ pmem_free(pmem);
return 0;
}
--
1.9.3
next prev parent reply other threads:[~2015-03-31 14:21 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
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-03-26 14:12 ` [Linux-nvdimm] " Dan Williams
2015-03-26 14:35 ` Christoph Hellwig
2015-03-26 21:37 ` Ross Zwisler
2015-03-26 14:52 ` Boaz Harrosh
2015-03-26 15:59 ` Dan Williams
2015-03-26 8:32 ` [PATCH 2/3] x86: add a is_e820_ram() helper Christoph Hellwig
2015-03-26 9:02 ` Ingo Molnar
2015-03-26 9:34 ` Christoph Hellwig
2015-03-26 10:04 ` Ingo Molnar
2015-03-26 10:19 ` Christoph Hellwig
2015-03-26 10:28 ` Ingo Molnar
2015-03-26 10:29 ` Christoph Hellwig
2015-03-26 15:49 ` Boaz Harrosh
2015-03-26 16:02 ` [Linux-nvdimm] " Dan Williams
2015-03-26 16:07 ` Boaz Harrosh
2015-03-26 16:43 ` Christoph Hellwig
2015-03-26 18:46 ` Elliott, Robert (Server Storage)
2015-03-26 19:25 ` [Linux-nvdimm] " Dan Williams
2015-03-26 20:53 ` Ross Zwisler
2015-03-26 22:59 ` Yinghai Lu
2015-03-27 8:10 ` Christoph Hellwig
2015-03-26 8:32 ` [PATCH 3/3] x86: add support for the non-standard protected e820 type Christoph Hellwig
2015-03-26 16:57 ` another pmem variant V2 Boaz Harrosh
2015-03-26 17:02 ` [PATCH] SQUASHME: Streamline pmem.c Boaz Harrosh
2015-03-26 17:23 ` Christoph Hellwig
2015-03-26 22:17 ` Ross Zwisler
2015-03-26 22:22 ` Ross Zwisler
2015-03-26 23:31 ` [Linux-nvdimm] " Dan Williams
2015-03-31 13:44 ` Boaz Harrosh
2015-03-26 17:18 ` another pmem variant V2 Christoph Hellwig
2015-03-26 17:31 ` Boaz Harrosh
2015-03-26 18:38 ` Christoph Hellwig
2015-03-31 9:25 ` Christoph Hellwig
2015-03-31 10:25 ` Boaz Harrosh
2015-03-31 10:31 ` Boaz Harrosh
2015-03-31 14:21 ` Boaz Harrosh [this message]
2015-03-31 16:10 ` [RFC] SQUASHME: pmem: Split up pmem_probe from pmem_alloc Christoph Hellwig
2015-03-31 16:08 ` another pmem variant V2 Christoph Hellwig
2015-03-31 13:18 ` [SQUASHME 0/6] Streamline of Initial pmem submission Boaz Harrosh
2015-03-31 13:23 ` [PATCH 1/6] SQUASHME: Don't let e820_PMEM sections Boaz Harrosh
2015-03-31 17:16 ` [Linux-nvdimm] " Brooks, Adam J
2015-03-31 13:24 ` [PATCH 2/6] SQUASHME: pmem: Remove getgeo Boaz Harrosh
2015-03-31 13:25 ` [PATCH 3/6] SQUASHME: pmem: Streamline pmem driver Boaz Harrosh
2015-03-31 13:27 ` [PATCH 4/6] SQUSHME: pmem: Micro cleaning Boaz Harrosh
2015-03-31 15:17 ` [Linux-nvdimm] " Dan Williams
2015-03-31 15:24 ` Boaz Harrosh
2015-03-31 15:30 ` Dan Williams
2015-03-31 15:43 ` Boaz Harrosh
2015-03-31 19:40 ` Matthew Wilcox
2015-03-31 13:28 ` [PATCH 5/6] SQUASHME: pmem: Remove SECTOR_SHIFT Boaz Harrosh
2015-03-31 13:33 ` [PATCH 6/6] SQUASHME: pmem: Remove "... based on brd.c" + Copyright Boaz Harrosh
2015-03-31 15:14 ` another pmem variant V2 Boaz Harrosh
2015-03-31 16:16 ` Christoph Hellwig
2015-03-31 16:44 ` Ingo Molnar
2015-03-31 17:24 ` Christoph Hellwig
2015-03-31 17:33 ` [Linux-nvdimm] " Dan Williams
2015-04-01 7:50 ` Ingo Molnar
2015-04-01 8:06 ` Boaz Harrosh
2015-04-01 12:49 ` Boaz Harrosh
2015-03-31 22:11 ` Elliott, Robert (Server Storage)
2015-04-01 7:26 ` Christoph Hellwig
2015-04-02 15:11 ` Elliott, Robert (Server Storage)
2015-04-02 16:41 ` Christoph Hellwig
2015-04-02 18:03 ` Ingo Molnar
2015-04-01 19:33 ` Elliott, Robert (Server Storage)
2015-04-02 9:37 ` Christoph Hellwig
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=551AAD5B.4020104@gmail.com \
--to=openosd@gmail.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=ross.zwisler@linux.intel.com \
--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).