From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754532AbbCaOVX (ORCPT ); Tue, 31 Mar 2015 10:21:23 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:34783 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752558AbbCaOVT (ORCPT ); Tue, 31 Mar 2015 10:21:19 -0400 Message-ID: <551AAD5B.4020104@gmail.com> Date: Tue, 31 Mar 2015 17:21:15 +0300 From: Boaz Harrosh User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Boaz Harrosh , Christoph Hellwig 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 References: <1427358764-6126-1-git-send-email-hch@lst.de> <55143A8B.2060304@plexistor.com> <20150331092526.GA25958@lst.de> <551A762A.7090307@plexistor.com> In-Reply-To: <551A762A.7090307@plexistor.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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