From patchwork Fri Aug 20 01:02:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olof Johansson X-Patchwork-Id: 177242 Return-path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on void.printf.net X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.9 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.2.5 Envelope-to: chris@printf.net Delivery-date: Fri, 20 Aug 2010 02:02:48 +0100 Received: from lists.laptop.org ([18.85.2.145] helo=mail.laptop.org) by void.printf.net with esmtp (Exim 4.69) (envelope-from ) id 1OmG0M-0000GE-Ni for chris@printf.net; Fri, 20 Aug 2010 02:02:47 +0100 Received: by mail.laptop.org (Postfix) id 4B00423AAC; Thu, 19 Aug 2010 21:02:28 -0400 (EDT) Delivered-To: cjb@laptop.org Received: from spam.laptop.org (spam.laptop.org [18.85.46.23]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.laptop.org (Postfix) with ESMTPS id 3BF1923AAB for ; Thu, 19 Aug 2010 21:02:28 -0400 (EDT) X-ASG-Debug-ID: 1282266164-0b74c4200001-zHW3sV Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by spam.laptop.org with ESMTP id ThHisRU8I0sTHiFA for ; Thu, 19 Aug 2010 21:02:44 -0400 (EDT) X-Barracuda-Envelope-From: linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751265Ab0HTBCn (ORCPT ); Thu, 19 Aug 2010 21:02:43 -0400 Received: from mail.lixom.net ([70.86.134.90]:50673 "EHLO mail.lixom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751049Ab0HTBCn (ORCPT ); Thu, 19 Aug 2010 21:02:43 -0400 Received: by mail.lixom.net (Postfix, from userid 1000) id EF36A56611F; Thu, 19 Aug 2010 20:02:42 -0500 (CDT) Date: Thu, 19 Aug 2010 20:02:42 -0500 From: Olof Johansson To: Andrew Morton Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org X-ASG-Orig-Subj: [PATCH v2] mmc: add config and runtime option for number of mmcblk minors Subject: [PATCH v2] mmc: add config and runtime option for number of mmcblk minors Message-ID: <20100820010242.GA29588@lixom.net> References: <20100818041333.GA14149@lixom.net> <20100818171636.0625b668.akpm@linux-foundation.org> <20100819032230.GA21980@lixom.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100819032230.GA21980@lixom.net> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Barracuda-Connect: vger.kernel.org[209.132.180.67] X-Barracuda-Start-Time: 1282266164 X-Barracuda-URL: http://18.85.46.23:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at laptop.org X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.5 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.38465 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- diff --git a/drivers/mmc/card/Kconfig b/drivers/mmc/card/Kconfig index 3f2a912..57e4416 100644 --- a/drivers/mmc/card/Kconfig +++ b/drivers/mmc/card/Kconfig @@ -14,6 +14,23 @@ config MMC_BLOCK mount the filesystem. Almost everyone wishing MMC support should say Y or M here. +config MMC_BLOCK_MINORS + int "Number of minors per block device" + range 4 256 + default 8 + help + Number of minors per block device. One is needed for every + partition on the disk (plus one for the whole disk). + + Number of total MMC minors available is 256, so your number + of supported block devices will be limited to 256 divided + by this number. + + Default is 8 to be backwards compatible with previous + hardwired device numbering. + + If unsure, say 8 here. + config MMC_BLOCK_BOUNCE bool "Use bounce buffer for simple hosts" depends on MMC_BLOCK diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index cb9fbc8..143b23e 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -43,14 +43,26 @@ #include "queue.h" MODULE_ALIAS("mmc:block"); +#ifdef MODULE_PARAM_PREFIX +#undef MODULE_PARAM_PREFIX +#endif +#define MODULE_PARAM_PREFIX "mmcblk." -/* - * max 8 partitions per card + +/* + * The defaults come from config options but can be overriden by module + * or bootarg options. + */ +static int perdev_minors = CONFIG_MMC_BLOCK_MINORS; + +/* + * We've only got one major, so number of mmcblk devices is + * limited to 256 / number of minors per device. */ -#define MMC_SHIFT 3 -#define MMC_NUM_MINORS (256 >> MMC_SHIFT) +static int max_devices = DIV_ROUND_UP(256, CONFIG_MMC_BLOCK_MINORS); -static DECLARE_BITMAP(dev_use, MMC_NUM_MINORS); +/* 256 minors, so at most 256 separate devices */ +static DECLARE_BITMAP(dev_use, 256); /* * There is one mmc_blk_data per slot. @@ -66,6 +78,9 @@ struct mmc_blk_data { static DEFINE_MUTEX(open_lock); +module_param(perdev_minors, int, 0644); +MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device"); + static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk) { struct mmc_blk_data *md; @@ -87,10 +102,10 @@ static void mmc_blk_put(struct mmc_blk_data *md) md->usage--; if (md->usage == 0) { int devmaj = MAJOR(disk_devt(md->disk)); - int devidx = MINOR(disk_devt(md->disk)) >> MMC_SHIFT; + int devidx = MINOR(disk_devt(md->disk)) / perdev_minors; if (!devmaj) - devidx = md->disk->first_minor >> MMC_SHIFT; + devidx = md->disk->first_minor / perdev_minors; blk_cleanup_queue(md->queue.queue); @@ -482,8 +497,8 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) struct mmc_blk_data *md; int devidx, ret; - devidx = find_first_zero_bit(dev_use, MMC_NUM_MINORS); - if (devidx >= MMC_NUM_MINORS) + devidx = find_first_zero_bit(dev_use, max_devices); + if (devidx >= max_devices) return ERR_PTR(-ENOSPC); __set_bit(devidx, dev_use); @@ -500,7 +515,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) */ md->read_only = mmc_blk_readonly(card); - md->disk = alloc_disk(1 << MMC_SHIFT); + md->disk = alloc_disk(perdev_minors); if (md->disk == NULL) { ret = -ENOMEM; goto err_kfree; @@ -517,7 +532,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) md->queue.data = md; md->disk->major = MMC_BLOCK_MAJOR; - md->disk->first_minor = devidx << MMC_SHIFT; + md->disk->first_minor = devidx * perdev_minors; md->disk->fops = &mmc_bdops; md->disk->private_data = md; md->disk->queue = md->queue.queue; @@ -593,7 +608,6 @@ static int mmc_blk_probe(struct mmc_card *card) { struct mmc_blk_data *md; int err; - char cap_str[10]; /* @@ -683,6 +697,11 @@ static int __init mmc_blk_init(void) { int res; + if (perdev_minors != CONFIG_MMC_BLOCK_MINORS) { + pr_info("mmcblk: using %d minors per device\n", perdev_minors); + max_devices = DIV_ROUND_UP(256, perdev_minors); + } + res = register_blkdev(MMC_BLOCK_MAJOR, "mmc"); if (res) goto out;