From patchwork Tue Mar 31 14:21:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boaz Harrosh X-Patchwork-Id: 6130481 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E762B9F2EC for ; Tue, 31 Mar 2015 14:21:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0DFDF2018E for ; Tue, 31 Mar 2015 14:21:24 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7802F201C8 for ; Tue, 31 Mar 2015 14:21:21 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 41CB480F8F; Tue, 31 Mar 2015 07:21:21 -0700 (PDT) X-Original-To: linux-nvdimm@ml01.01.org Delivered-To: linux-nvdimm@ml01.01.org Received: from mail-wi0-x22d.google.com (mail-wi0-x22d.google.com [IPv6:2a00:1450:400c:c05::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EB84180F6A for ; Tue, 31 Mar 2015 07:21:19 -0700 (PDT) Received: by wiaa2 with SMTP id a2so28147933wia.0 for ; Tue, 31 Mar 2015 07:21:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=jG06UBs7aYUi6Eic5tHYMp6Kgxyw7Bbtv6iDN29rP0I=; b=D29KF1Co7LKiGjXd2+TRIUQnUb3oB5xJPDertU0UZJdKNh1onGTXgb1eNG/NJvolHd ffJaNZn57DFqOeHi2SQ7W0Pkxvd+1XFgRHBqmqdh76vZYX5JBN57T/gweEF868qbMTmg ooXcINNWPEK3KJEFt8vO03X3+L+gocUWakwXa2xm+vK2E5hyyz+/K/HxvfniFINnLEHl UO4kos7aTUVche/lTFMyhTuxxXwViEq3ENv/UnQoPAB7SHdz1ganx1au942PcH3OlLaW 6e1K4dcAbYqOOc97A9YHx5VhU5IaIbx5lx872GJ4uu8zSO9+BCzlwmt4WItWtUl2jfri f1Bw== X-Received: by 10.180.80.164 with SMTP id s4mr5785455wix.78.1427811678219; Tue, 31 Mar 2015 07:21:18 -0700 (PDT) Received: from [10.0.0.5] ([207.232.55.62]) by mx.google.com with ESMTPSA id es2sm6771781wib.8.2015.03.31.07.21.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Mar 2015 07:21:17 -0700 (PDT) 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 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> Cc: axboe@kernel.dk, linux-nvdimm@ml01.01.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [Linux-nvdimm] [RFC] SQUASHME: pmem: Split up pmem_probe from pmem_alloc X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }