All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: make number of mmcblk minors configurable
@ 2010-08-18  4:13 Olof Johansson
  2010-08-19  0:16 ` Andrew Morton
  0 siblings, 1 reply; 16+ messages in thread
From: Olof Johansson @ 2010-08-18  4:13 UTC (permalink / raw)
  To: linux-mmc; +Cc: akpm, linux-kernel

The old limit of number of minor numbers per mmcblk device was hardcoded
at 8. This isn't enough for some of the more elaborate partitioning
schemes, for example those used by Chrome OS.

Since there might be a bunch of systems out there with static /dev
contents that relies on the old numbering scheme, let's make it a
build-time option with the default set to the previous 8.

Signed-off-by: Olof Johansson <olof@lixom.net>
---
 drivers/mmc/card/Kconfig |   10 ++++++++++
 drivers/mmc/card/block.c |   20 ++++++++------------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/card/Kconfig b/drivers/mmc/card/Kconfig
index 3f2a912..e939dcf 100644
--- a/drivers/mmc/card/Kconfig
+++ b/drivers/mmc/card/Kconfig
@@ -14,6 +14,16 @@ 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 32
+	default 8
+	help
+	  Number of minors per block device. One is needed for every
+	  partition (plus one for the whole device).
+	  Default is 8 to be backwards compatible with previous
+	  hardcoded device numbering.
+
 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 d545f79..524e232 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -45,13 +45,9 @@
 
 MODULE_ALIAS("mmc:block");
 
-/*
- * max 8 partitions per card
- */
-#define MMC_SHIFT	3
-#define MMC_NUM_MINORS	(256 >> MMC_SHIFT)
+#define MMC_MAX_DEVICES	((255 + CONFIG_MMC_BLOCK_MINORS) / CONFIG_MMC_BLOCK_MINORS)
 
-static DECLARE_BITMAP(dev_use, MMC_NUM_MINORS);
+static DECLARE_BITMAP(dev_use, MMC_MAX_DEVICES);
 
 /*
  * There is one mmc_blk_data per slot.
@@ -88,10 +84,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)) / CONFIG_MMC_BLOCK_MINORS;
 
 		if (!devmaj)
-			devidx = md->disk->first_minor >> MMC_SHIFT;
+			devidx = md->disk->first_minor / CONFIG_MMC_BLOCK_MINORS;
 
 		blk_cleanup_queue(md->queue.queue);
 
@@ -567,8 +563,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, MMC_MAX_DEVICES);
+	if (devidx >= MMC_MAX_DEVICES)
 		return ERR_PTR(-ENOSPC);
 	__set_bit(devidx, dev_use);
 
@@ -585,7 +581,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(CONFIG_MMC_BLOCK_MINORS);
 	if (md->disk == NULL) {
 		ret = -ENOMEM;
 		goto err_kfree;
@@ -602,7 +598,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 * CONFIG_MMC_BLOCK_MINORS;
 	md->disk->fops = &mmc_bdops;
 	md->disk->private_data = md;
 	md->disk->queue = md->queue.queue;
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] mmc: make number of mmcblk minors configurable
  2010-08-18  4:13 [PATCH] mmc: make number of mmcblk minors configurable Olof Johansson
@ 2010-08-19  0:16 ` Andrew Morton
  2010-08-19  3:22   ` Olof Johansson
  0 siblings, 1 reply; 16+ messages in thread
From: Andrew Morton @ 2010-08-19  0:16 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linux-mmc, linux-kernel

On Tue, 17 Aug 2010 23:13:33 -0500
Olof Johansson <olof@lixom.net> wrote:

> The old limit of number of minor numbers per mmcblk device was hardcoded
> at 8. This isn't enough for some of the more elaborate partitioning
> schemes, for example those used by Chrome OS.
> 
> Since there might be a bunch of systems out there with static /dev
> contents that relies on the old numbering scheme, let's make it a
> build-time option with the default set to the previous 8.
> 

How does the numbering scheme change?  What's the user-visible effect
of setting CONFIG_MMC_BLOCK_MINORS to, say, 16?

> ---
>  drivers/mmc/card/Kconfig |   10 ++++++++++
>  drivers/mmc/card/block.c |   20 ++++++++------------
>  2 files changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/mmc/card/Kconfig b/drivers/mmc/card/Kconfig
> index 3f2a912..e939dcf 100644
> --- a/drivers/mmc/card/Kconfig
> +++ b/drivers/mmc/card/Kconfig
> @@ -14,6 +14,16 @@ 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 32
> +	default 8
> +	help
> +	  Number of minors per block device. One is needed for every
> +	  partition (plus one for the whole device).
> +	  Default is 8 to be backwards compatible with previous
> +	  hardcoded device numbering.

If possible it would be better to do this with a kernel boot (or
modprobe) parameter.  That permits vendors to ship packaged kernels
with full functionality, etc.  Possible?  The default value of the
runtime-settable parameter could be Kconfigurable is there's a real
need for that.


>  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 d545f79..524e232 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -45,13 +45,9 @@
>  
>  MODULE_ALIAS("mmc:block");
>  
> -/*
> - * max 8 partitions per card
> - */
> -#define MMC_SHIFT	3
> -#define MMC_NUM_MINORS	(256 >> MMC_SHIFT)
> +#define MMC_MAX_DEVICES	((255 + CONFIG_MMC_BLOCK_MINORS) / CONFIG_MMC_BLOCK_MINORS)

So if I increase CONFIG_MMC_BLOCK_MINORS, I can no longer support as
many devices?  That'd be worth mentioning somewhere?

fwiw, the above could use DIV_ROUND_UP().



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] mmc: make number of mmcblk minors configurable
  2010-08-19  0:16 ` Andrew Morton
@ 2010-08-19  3:22   ` Olof Johansson
  2010-08-20  1:02     ` [PATCH v2] mmc: add config and runtime option for number of mmcblk minors Olof Johansson
  0 siblings, 1 reply; 16+ messages in thread
From: Olof Johansson @ 2010-08-19  3:22 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mmc, linux-kernel

Hi,

On Wed, Aug 18, 2010 at 05:16:36PM -0700, Andrew Morton wrote:
> On Tue, 17 Aug 2010 23:13:33 -0500
> Olof Johansson <olof@lixom.net> wrote:
> 
> > The old limit of number of minor numbers per mmcblk device was hardcoded
> > at 8. This isn't enough for some of the more elaborate partitioning
> > schemes, for example those used by Chrome OS.
> > 
> > Since there might be a bunch of systems out there with static /dev
> > contents that relies on the old numbering scheme, let's make it a
> > build-time option with the default set to the previous 8.
> > 
> 
> How does the numbering scheme change?  What's the user-visible effect
> of setting CONFIG_MMC_BLOCK_MINORS to, say, 16?

mmcblk0 will be 0, mmcblk0p1 1, etc. mmcblk1 (second device) will be
bumped up to start at minor 16 instead of 8 before, which is why I didn't
just bump up the static default and went with a config option instead.

FWIW, udev will happily keep creating device nodes for higher partitions,
so without this patch you end up with overlapping device entries where
mmcblk1p1 and mmcblk0p9 will be the same major/minor.

> > ---
> >  drivers/mmc/card/Kconfig |   10 ++++++++++
> >  drivers/mmc/card/block.c |   20 ++++++++------------
> >  2 files changed, 18 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/mmc/card/Kconfig b/drivers/mmc/card/Kconfig
> > index 3f2a912..e939dcf 100644
> > --- a/drivers/mmc/card/Kconfig
> > +++ b/drivers/mmc/card/Kconfig
> > @@ -14,6 +14,16 @@ 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 32
> > +	default 8
> > +	help
> > +	  Number of minors per block device. One is needed for every
> > +	  partition (plus one for the whole device).
> > +	  Default is 8 to be backwards compatible with previous
> > +	  hardcoded device numbering.
> 
> If possible it would be better to do this with a kernel boot (or
> modprobe) parameter.  That permits vendors to ship packaged kernels
> with full functionality, etc.  Possible?  The default value of the
> runtime-settable parameter could be Kconfigurable is there's a real
> need for that.

I considered just doing a runtime option, but it would be suboptimal in
our case (Chrome OS) since it would mean that we had yet another kernel
arg we always have to include on all platforms that boot from mmc devices.
Modprobe args won't work there because the driver is statically linked in
(and no ramdisk).

I can definitely change it to take the default from the Kconfig and make
it possible to override with boot/modprobe parameters though. Revised
patch to follow.

> >  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 d545f79..524e232 100644
> > --- a/drivers/mmc/card/block.c
> > +++ b/drivers/mmc/card/block.c
> > @@ -45,13 +45,9 @@
> >  
> >  MODULE_ALIAS("mmc:block");
> >  
> > -/*
> > - * max 8 partitions per card
> > - */
> > -#define MMC_SHIFT	3
> > -#define MMC_NUM_MINORS	(256 >> MMC_SHIFT)
> > +#define MMC_MAX_DEVICES	((255 + CONFIG_MMC_BLOCK_MINORS) / CONFIG_MMC_BLOCK_MINORS)
> 
> So if I increase CONFIG_MMC_BLOCK_MINORS, I can no longer support as
> many devices?  That'd be worth mentioning somewhere?

Yep, I'll add a comment and clarify it in the Kconfig help.

> fwiw, the above could use DIV_ROUND_UP().

Good point, will do.


-Olof

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2] mmc: add config and runtime option for number of mmcblk minors
  2010-08-19  3:22   ` Olof Johansson
@ 2010-08-20  1:02     ` Olof Johansson
  2010-08-20 22:13       ` [PATCH v3] " Olof Johansson
  0 siblings, 1 reply; 16+ messages in thread
From: Olof Johansson @ 2010-08-20  1:02 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mmc, linux-kernel

The old limit of number of minor numbers per mmcblk device was hardcoded
at 8. This isn't enough for some of the more elaborate partitioning
schemes, for example those used by Chrome OS.

Since there might be a bunch of systems out there with static /dev
contents that relies on the old numbering scheme, let's make it a
build-time option with the default set to the previous 8.

Also provide a boot/modprobe-time parameter to override the config
default: mmcblk.perdev_minors.

Signed-off-by: Olof Johansson <olof@lixom.net>

---

Changes since v1:
	* Runtime override of config default
	* Better help text
	* DIV_ROUND_UP for max_devices calculation
	* Clarify mmcblk device count limitations

 drivers/mmc/card/Kconfig |   17 +++++++++++++++++
 drivers/mmc/card/block.c |   43 +++++++++++++++++++++++++++++++------------
 2 files changed, 48 insertions(+), 12 deletions(-)

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;
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3] mmc: add config and runtime option for number of mmcblk minors
  2010-08-20  1:02     ` [PATCH v2] mmc: add config and runtime option for number of mmcblk minors Olof Johansson
@ 2010-08-20 22:13       ` Olof Johansson
  2010-08-20 22:18         ` sys_init_module system call runcoderen
  2010-09-08 14:25         ` [PATCH v3] mmc: add config and runtime option for number of mmcblk minors Lei Wen
  0 siblings, 2 replies; 16+ messages in thread
From: Olof Johansson @ 2010-08-20 22:13 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mmc, linux-kernel, Mandeep Baines

The old limit of number of minor numbers per mmcblk device was hardcoded
at 8. This isn't enough for some of the more elaborate partitioning
schemes, for example those used by Chrome OS.

Since there might be a bunch of systems out there with static /dev
contents that relies on the old numbering scheme, let's make it a
build-time option with the default set to the previous 8.

Also provide a boot/modprobe-time parameter to override the config
default: mmcblk.perdev_minors.

Signed-off-by: Olof Johansson <olof@lixom.net>
Cc: Mandeep Baines <msb@chromium.org>

---

Andrew, sorry for the churn but Mandeep had a couple of good points that
needed addressing.

Changes since v1:
	* Runtime override of config default
	* Better help text
	* DIV_ROUND_UP for max_devices calculation
	* Clarify mmcblk device count limitations

Changes since v2 based on feedback from Mandeep Baines:
	* DIV_ROUND_UP is doing the wrong thing, we'll end up using
	  the last fractional range of minors which we shouldn't.
	* Documentation/devices.txt update
	* No need to compute max_devices twice, just do it at runtime.
	* Permission fix for the module_param -- it's readonly.

 Documentation/devices.txt |    6 ++++++
 drivers/mmc/card/Kconfig  |   17 +++++++++++++++++
 drivers/mmc/card/block.c  |   41 ++++++++++++++++++++++++++++++-----------
 3 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/Documentation/devices.txt b/Documentation/devices.txt
index 1d83d12..fdf3821 100644
--- a/Documentation/devices.txt
+++ b/Documentation/devices.txt
@@ -2518,6 +2518,12 @@ Your cooperation is appreciated.
 		  8 = /dev/mmcblk1      Second SD/MMC card
 		    ...
 
+		The start of next SD/MMC card can be configured with
+		CONFIG_MMC_BLOCK_MINORS, or overridden at boot/modprobe
+		time using the mmcblk.perdev_minors option. That would
+		bump the offset between each card to be the configured
+		value instead of the default 8.
+
 179 char	CCube DVXChip-based PCI products
 		  0 = /dev/dvxirq0	First DVX device
 		  1 = /dev/dvxirq1	Second DVX device
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..ec94f56 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."
+
+
+/*
+ * The defaults come from config options but can be overriden by module
+ * or bootarg options.
+ */
+static int perdev_minors = CONFIG_MMC_BLOCK_MINORS;
 
 /*
- * max 8 partitions per card
+ * 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;
 
-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, 0444);
+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 = 256 / perdev_minors;
+
 	res = register_blkdev(MMC_BLOCK_MAJOR, "mmc");
 	if (res)
 		goto out;
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* sys_init_module system call
  2010-08-20 22:13       ` [PATCH v3] " Olof Johansson
@ 2010-08-20 22:18         ` runcoderen
  2010-08-20 22:32           ` Randy Dunlap
  2010-09-08 14:25         ` [PATCH v3] mmc: add config and runtime option for number of mmcblk minors Lei Wen
  1 sibling, 1 reply; 16+ messages in thread
From: runcoderen @ 2010-08-20 22:18 UTC (permalink / raw)
  To: linux-kernel

hi all
I find sys_init_module system call in kernel/module.c file.
but it did not find any.
the source code version is linux-2.6.35

does the kernel have changed?

the book I am reading is LDD 3rd edition

-- 

/****************************************
http://runcoderen.wordpress.com/
****************************************/


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: sys_init_module system call
  2010-08-20 22:18         ` sys_init_module system call runcoderen
@ 2010-08-20 22:32           ` Randy Dunlap
  2010-08-20 22:50             ` runcoderen
  0 siblings, 1 reply; 16+ messages in thread
From: Randy Dunlap @ 2010-08-20 22:32 UTC (permalink / raw)
  To: runcoderen; +Cc: linux-kernel

On Sat, 21 Aug 2010 06:18:04 +0800 runcoderen wrote:

> hi all
> I find sys_init_module system call in kernel/module.c file.
> but it did not find any.
> the source code version is linux-2.6.35
> 
> does the kernel have changed?
> 
> the book I am reading is LDD 3rd edition

You won't find a function in kernel/module.c that looks like it has
the name "sys_init_module".  Instead, the function is defined by using
a macro, and it looks like this:

/* This is where the real work happens */
SYSCALL_DEFINE3(init_module, void __user *, umod,
		unsigned long, len, const char __user *, uargs)
{



The use of SYSCALL_DEFINEx(func_name, args) is a fairly recent change
(well, January, 2009) that may be the reason why you think that there
has been a change.  See
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=1a94bc34768e463a93cb3751819709ab0ea80a01


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: sys_init_module system call
  2010-08-20 22:32           ` Randy Dunlap
@ 2010-08-20 22:50             ` runcoderen
  0 siblings, 0 replies; 16+ messages in thread
From: runcoderen @ 2010-08-20 22:50 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-kernel

hi Randy:
yes, it does!
Thanks a lot!
	runcoderen

在 2010-08-20五的 15:32 -0700,Randy Dunlap写道:
> On Sat, 21 Aug 2010 06:18:04 +0800 runcoderen wrote:
> 
> > hi all
> > I find sys_init_module system call in kernel/module.c file.
> > but it did not find any.
> > the source code version is linux-2.6.35
> > 
> > does the kernel have changed?
> > 
> > the book I am reading is LDD 3rd edition
> 
> You won't find a function in kernel/module.c that looks like it has
> the name "sys_init_module".  Instead, the function is defined by using
> a macro, and it looks like this:
> 
> /* This is where the real work happens */
> SYSCALL_DEFINE3(init_module, void __user *, umod,
> 		unsigned long, len, const char __user *, uargs)
> {
> 
> 
> 
> The use of SYSCALL_DEFINEx(func_name, args) is a fairly recent change
> (well, January, 2009) that may be the reason why you think that there
> has been a change.  See
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=1a94bc34768e463a93cb3751819709ab0ea80a01
> 
> 
> ---
> ~Randy
> *** Remember to use Documentation/SubmitChecklist when testing your code ***

-- 

/****************************************
http://runcoderen.wordpress.com/
****************************************/


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3] mmc: add config and runtime option for number of mmcblk minors
  2010-08-20 22:13       ` [PATCH v3] " Olof Johansson
  2010-08-20 22:18         ` sys_init_module system call runcoderen
@ 2010-09-08 14:25         ` Lei Wen
  2010-09-08 14:57           ` Olof Johansson
  1 sibling, 1 reply; 16+ messages in thread
From: Lei Wen @ 2010-09-08 14:25 UTC (permalink / raw)
  To: Olof Johansson; +Cc: Andrew Morton, linux-mmc, linux-kernel, Mandeep Baines

Hi,

On Sat, Aug 21, 2010 at 6:13 AM, Olof Johansson <olof@lixom.net> wrote:
> The old limit of number of minor numbers per mmcblk device was hardcoded
> at 8. This isn't enough for some of the more elaborate partitioning
> schemes, for example those used by Chrome OS.
>
> Since there might be a bunch of systems out there with static /dev
> contents that relies on the old numbering scheme, let's make it a
> build-time option with the default set to the previous 8.
>
> Also provide a boot/modprobe-time parameter to override the config
> default: mmcblk.perdev_minors.
>
> Signed-off-by: Olof Johansson <olof@lixom.net>
> Cc: Mandeep Baines <msb@chromium.org>
>
> ---
>
> Andrew, sorry for the churn but Mandeep had a couple of good points that
> needed addressing.
>
> Changes since v1:
>        * Runtime override of config default
>        * Better help text
>        * DIV_ROUND_UP for max_devices calculation
>        * Clarify mmcblk device count limitations
>
> Changes since v2 based on feedback from Mandeep Baines:
>        * DIV_ROUND_UP is doing the wrong thing, we'll end up using
>          the last fractional range of minors which we shouldn't.
>        * Documentation/devices.txt update
>        * No need to compute max_devices twice, just do it at runtime.
>        * Permission fix for the module_param -- it's readonly.
>
>  Documentation/devices.txt |    6 ++++++
>  drivers/mmc/card/Kconfig  |   17 +++++++++++++++++
>  drivers/mmc/card/block.c  |   41 ++++++++++++++++++++++++++++++-----------
>  3 files changed, 53 insertions(+), 11 deletions(-)
>
> diff --git a/Documentation/devices.txt b/Documentation/devices.txt
> index 1d83d12..fdf3821 100644
> --- a/Documentation/devices.txt
> +++ b/Documentation/devices.txt
> @@ -2518,6 +2518,12 @@ Your cooperation is appreciated.
>                  8 = /dev/mmcblk1      Second SD/MMC card
>                    ...
>
> +               The start of next SD/MMC card can be configured with
> +               CONFIG_MMC_BLOCK_MINORS, or overridden at boot/modprobe
> +               time using the mmcblk.perdev_minors option. That would
> +               bump the offset between each card to be the configured
> +               value instead of the default 8.
> +
>  179 char       CCube DVXChip-based PCI products
>                  0 = /dev/dvxirq0      First DVX device
>                  1 = /dev/dvxirq1      Second DVX device
> 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..ec94f56 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."
> +
> +
> +/*
> + * The defaults come from config options but can be overriden by module
> + * or bootarg options.
> + */
> +static int perdev_minors = CONFIG_MMC_BLOCK_MINORS;
>
>  /*
> - * max 8 partitions per card
> + * 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;
>
> -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, 0444);
> +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 = 256 / perdev_minors;
> +
>        res = register_blkdev(MMC_BLOCK_MAJOR, "mmc");
>        if (res)
>                goto out;
> --
> 1.5.6.5
>

The patch's purpose is good. As modern sd&mmc is used to host the file
system, the 8 partition limitation is becoming a kind of bottleneck...
But why not just add GENHD_FL_EXT_DEVT flag to allow mmc use extended
partition numbers?

Like this modification?
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 8d2bd24..2e3eeb1 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -557,6 +557,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct
mmc_card *card)
        md->disk->private_data = md;
        md->disk->queue = md->queue.queue;
        md->disk->driverfs_dev = &card->dev;
+       md->disk->flags |= GENHD_FL_EXT_DEVT;

        /*
         * As discussed on lkml, GENHD_FL_REMOVABLE should:

Best regards,
Lei

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v3] mmc: add config and runtime option for number of mmcblk minors
  2010-09-08 14:25         ` [PATCH v3] mmc: add config and runtime option for number of mmcblk minors Lei Wen
@ 2010-09-08 14:57           ` Olof Johansson
  2010-09-08 15:19             ` Kay Sievers
  0 siblings, 1 reply; 16+ messages in thread
From: Olof Johansson @ 2010-09-08 14:57 UTC (permalink / raw)
  To: Lei Wen; +Cc: Andrew Morton, linux-mmc, linux-kernel, Mandeep Baines

Hi,

On Wed, Sep 08, 2010 at 10:25:58PM +0800, Lei Wen wrote:

> The patch's purpose is good. As modern sd&mmc is used to host the file
> system, the 8 partition limitation is becoming a kind of bottleneck...
> But why not just add GENHD_FL_EXT_DEVT flag to allow mmc use extended
> partition numbers?

No need to quote the whole patch next time. :)

Given that MMC is sometimes used in deeply embedded environments where
udev might not be running to take care of dynamic device numbering,
I chose to stay with a static layout.

I could be convinced otherwise though. It would cause some additional
hassles for me since we start udev lateish during boot and have a
prepopulated /dev before that, but that can be dealt with.


-Olof


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3] mmc: add config and runtime option for number of mmcblk minors
  2010-09-08 14:57           ` Olof Johansson
@ 2010-09-08 15:19             ` Kay Sievers
  2010-09-08 15:57               ` Olof Johansson
  0 siblings, 1 reply; 16+ messages in thread
From: Kay Sievers @ 2010-09-08 15:19 UTC (permalink / raw)
  To: Olof Johansson
  Cc: Lei Wen, Andrew Morton, linux-mmc, linux-kernel, Mandeep Baines

On Wed, Sep 8, 2010 at 16:57, Olof Johansson <olof@lixom.net> wrote:
> On Wed, Sep 08, 2010 at 10:25:58PM +0800, Lei Wen wrote:
>
>> The patch's purpose is good. As modern sd&mmc is used to host the file
>> system, the 8 partition limitation is becoming a kind of bottleneck...
>> But why not just add GENHD_FL_EXT_DEVT flag to allow mmc use extended
>> partition numbers?
>
> No need to quote the whole patch next time. :)
>
> Given that MMC is sometimes used in deeply embedded environments where
> udev might not be running to take care of dynamic device numbering,
> I chose to stay with a static layout.
>
> I could be convinced otherwise though. It would cause some additional
> hassles for me since we start udev lateish during boot and have a
> prepopulated /dev before that, but that can be dealt with.

I think the extended number are only used for stuff larger than the static 8?

Apart from that, you can not reliably or securely use a static /dev
these days, you never know which device you talk to, because the
kernel has far too many dynamically assigned numbers. For that reason,
most embedded setups use the busybox hack to populate /dev. Recent
kernels have a devfs again, and there is no reason today to continue
any static /dev experiments -- unless someone is going over the entire
tree and fixes all the dynamic assignments, which is unlikely to
happen ever.

Kay

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3] mmc: add config and runtime option for number of mmcblk minors
  2010-09-08 15:19             ` Kay Sievers
@ 2010-09-08 15:57               ` Olof Johansson
  2010-09-08 16:48                 ` Colin Cross
  0 siblings, 1 reply; 16+ messages in thread
From: Olof Johansson @ 2010-09-08 15:57 UTC (permalink / raw)
  To: Kay Sievers
  Cc: Lei Wen, Andrew Morton, linux-mmc, linux-kernel, Mandeep Baines

On Wed, Sep 08, 2010 at 05:19:25PM +0200, Kay Sievers wrote:
> On Wed, Sep 8, 2010 at 16:57, Olof Johansson <olof@lixom.net> wrote:
> > On Wed, Sep 08, 2010 at 10:25:58PM +0800, Lei Wen wrote:
> >
> >> The patch's purpose is good. As modern sd&mmc is used to host the file
> >> system, the 8 partition limitation is becoming a kind of bottleneck...
> >> But why not just add GENHD_FL_EXT_DEVT flag to allow mmc use extended
> >> partition numbers?
> >
> > No need to quote the whole patch next time. :)
> >
> > Given that MMC is sometimes used in deeply embedded environments where
> > udev might not be running to take care of dynamic device numbering,
> > I chose to stay with a static layout.
> >
> > I could be convinced otherwise though. It would cause some additional
> > hassles for me since we start udev lateish during boot and have a
> > prepopulated /dev before that, but that can be dealt with.
> 
> I think the extended number are only used for stuff larger than the static 8?

Ah, yes, of course.

> Apart from that, you can not reliably or securely use a static /dev
> these days, you never know which device you talk to, because the
> kernel has far too many dynamically assigned numbers. For that reason,
> most embedded setups use the busybox hack to populate /dev. Recent
> kernels have a devfs again, and there is no reason today to continue
> any static /dev experiments -- unless someone is going over the entire
> tree and fixes all the dynamic assignments, which is unlikely to
> happen ever.

Yeah, it's a weak argument but I wanted to go for the least surprising
one for anyone who still relies on static numbering of mmc, since it's
used as root device, etc.

But with the first 8 minors being the same as before, there's little
reason to care about that -- the EXT_DEVT approach will actually be
the smaller change, since it won't renumber anything, just extend in a
different part of the address space.

Lei, want to submit a proper patch for it to replace mine?


-Olof

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3] mmc: add config and runtime option for number of mmcblk minors
  2010-09-08 15:57               ` Olof Johansson
@ 2010-09-08 16:48                 ` Colin Cross
  2010-09-08 16:50                   ` [PATCH] mmc_block: Allow more than 8 partitions per card Colin Cross
  0 siblings, 1 reply; 16+ messages in thread
From: Colin Cross @ 2010-09-08 16:48 UTC (permalink / raw)
  To: Olof Johansson
  Cc: Kay Sievers, Lei Wen, Andrew Morton, linux-mmc, linux-kernel,
	Mandeep Baines

On Wed, Sep 8, 2010 at 8:57 AM, Olof Johansson <olof@lixom.net> wrote:
> On Wed, Sep 08, 2010 at 05:19:25PM +0200, Kay Sievers wrote:
>> On Wed, Sep 8, 2010 at 16:57, Olof Johansson <olof@lixom.net> wrote:
>> > On Wed, Sep 08, 2010 at 10:25:58PM +0800, Lei Wen wrote:
>> >
>> >> The patch's purpose is good. As modern sd&mmc is used to host the file
>> >> system, the 8 partition limitation is becoming a kind of bottleneck...
>> >> But why not just add GENHD_FL_EXT_DEVT flag to allow mmc use extended
>> >> partition numbers?
>> >
>> > No need to quote the whole patch next time. :)
>> >
>> > Given that MMC is sometimes used in deeply embedded environments where
>> > udev might not be running to take care of dynamic device numbering,
>> > I chose to stay with a static layout.
>> >
>> > I could be convinced otherwise though. It would cause some additional
>> > hassles for me since we start udev lateish during boot and have a
>> > prepopulated /dev before that, but that can be dealt with.
>>
>> I think the extended number are only used for stuff larger than the static 8?
>
> Ah, yes, of course.
>
>> Apart from that, you can not reliably or securely use a static /dev
>> these days, you never know which device you talk to, because the
>> kernel has far too many dynamically assigned numbers. For that reason,
>> most embedded setups use the busybox hack to populate /dev. Recent
>> kernels have a devfs again, and there is no reason today to continue
>> any static /dev experiments -- unless someone is going over the entire
>> tree and fixes all the dynamic assignments, which is unlikely to
>> happen ever.
>
> Yeah, it's a weak argument but I wanted to go for the least surprising
> one for anyone who still relies on static numbering of mmc, since it's
> used as root device, etc.
>
> But with the first 8 minors being the same as before, there's little
> reason to care about that -- the EXT_DEVT approach will actually be
> the smaller change, since it won't renumber anything, just extend in a
> different part of the address space.
>
> Lei, want to submit a proper patch for it to replace mine?

I have a tested patch for this.  It also cleans up the connection
between devidx and minor numbers.  I'll send it shortly.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH] mmc_block: Allow more than 8 partitions per card
  2010-09-08 16:48                 ` Colin Cross
@ 2010-09-08 16:50                   ` Colin Cross
  2010-09-09  2:49                     ` Lei Wen
  2010-09-09  7:54                     ` Adrian Hunter
  0 siblings, 2 replies; 16+ messages in thread
From: Colin Cross @ 2010-09-08 16:50 UTC (permalink / raw)
  To: Olof Johansson
  Cc: Kay Sievers, Lei Wen, Andrew Morton, linux-mmc, linux-kernel,
	Mandeep Baines, Colin Cross

Set the GENHD_FL_EXT_DEVT flag, which will allocate minor numbers
in major 259 for partitions past disk->minors.

Also remove the use of disk_devt to determine devidx from md->disk.
md->disk->first_minor is always initialized from devidx and can
always be used to recover it.

Signed-off-by: Colin Cross <ccross@android.com>
---
 drivers/mmc/card/block.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index d545f79..07d8eb0 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -87,11 +87,7 @@ static void mmc_blk_put(struct mmc_blk_data *md)
 	mutex_lock(&open_lock);
 	md->usage--;
 	if (md->usage == 0) {
-		int devmaj = MAJOR(disk_devt(md->disk));
-		int devidx = MINOR(disk_devt(md->disk)) >> MMC_SHIFT;
-
-		if (!devmaj)
-			devidx = md->disk->first_minor >> MMC_SHIFT;
+		int devidx = md->disk->first_minor >> MMC_SHIFT;
 
 		blk_cleanup_queue(md->queue.queue);
 
@@ -607,6 +603,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
 	md->disk->private_data = md;
 	md->disk->queue = md->queue.queue;
 	md->disk->driverfs_dev = &card->dev;
+	md->disk->flags = GENHD_FL_EXT_DEVT;
 
 	/*
 	 * As discussed on lkml, GENHD_FL_REMOVABLE should:
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] mmc_block: Allow more than 8 partitions per card
  2010-09-08 16:50                   ` [PATCH] mmc_block: Allow more than 8 partitions per card Colin Cross
@ 2010-09-09  2:49                     ` Lei Wen
  2010-09-09  7:54                     ` Adrian Hunter
  1 sibling, 0 replies; 16+ messages in thread
From: Lei Wen @ 2010-09-09  2:49 UTC (permalink / raw)
  To: Colin Cross
  Cc: Olof Johansson, Kay Sievers, Andrew Morton, linux-mmc,
	linux-kernel, Mandeep Baines

On Thu, Sep 9, 2010 at 12:50 AM, Colin Cross <ccross@android.com> wrote:
> Set the GENHD_FL_EXT_DEVT flag, which will allocate minor numbers
> in major 259 for partitions past disk->minors.
>
> Also remove the use of disk_devt to determine devidx from md->disk.
> md->disk->first_minor is always initialized from devidx and can
> always be used to recover it.
>
> Signed-off-by: Colin Cross <ccross@android.com>
> ---
>  drivers/mmc/card/block.c |    7 ++-----
>  1 files changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index d545f79..07d8eb0 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -87,11 +87,7 @@ static void mmc_blk_put(struct mmc_blk_data *md)
>        mutex_lock(&open_lock);
>        md->usage--;
>        if (md->usage == 0) {
> -               int devmaj = MAJOR(disk_devt(md->disk));
> -               int devidx = MINOR(disk_devt(md->disk)) >> MMC_SHIFT;
> -
> -               if (!devmaj)
> -                       devidx = md->disk->first_minor >> MMC_SHIFT;
> +               int devidx = md->disk->first_minor >> MMC_SHIFT;
>
>                blk_cleanup_queue(md->queue.queue);
>
> @@ -607,6 +603,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
>        md->disk->private_data = md;
>        md->disk->queue = md->queue.queue;
>        md->disk->driverfs_dev = &card->dev;
> +       md->disk->flags = GENHD_FL_EXT_DEVT;
>
>        /*
>         * As discussed on lkml, GENHD_FL_REMOVABLE should:
> --
> 1.7.1
>

Looks good to me.
Acked-by: Lei Wen <leiwen@marvell.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] mmc_block: Allow more than 8 partitions per card
  2010-09-08 16:50                   ` [PATCH] mmc_block: Allow more than 8 partitions per card Colin Cross
  2010-09-09  2:49                     ` Lei Wen
@ 2010-09-09  7:54                     ` Adrian Hunter
  1 sibling, 0 replies; 16+ messages in thread
From: Adrian Hunter @ 2010-09-09  7:54 UTC (permalink / raw)
  To: Colin Cross
  Cc: Olof Johansson, Kay Sievers, Lei Wen, Andrew Morton, linux-mmc,
	linux-kernel, Mandeep Baines

ext Colin Cross wrote:
> Set the GENHD_FL_EXT_DEVT flag, which will allocate minor numbers
> in major 259 for partitions past disk->minors.
> 
> Also remove the use of disk_devt to determine devidx from md->disk.
> md->disk->first_minor is always initialized from devidx and can
> always be used to recover it.

Yeah, but it is a bit weird.  It seems to me that devidx should just
be a member of struct mmc_blk_data.

Doesn't look like devidx is cleared in all the error paths out of
mmc_blk_alloc() either, if you want something else to do ;-)

> 
> Signed-off-by: Colin Cross <ccross@android.com>
> ---
>  drivers/mmc/card/block.c |    7 ++-----
>  1 files changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index d545f79..07d8eb0 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -87,11 +87,7 @@ static void mmc_blk_put(struct mmc_blk_data *md)
>  	mutex_lock(&open_lock);
>  	md->usage--;
>  	if (md->usage == 0) {
> -		int devmaj = MAJOR(disk_devt(md->disk));
> -		int devidx = MINOR(disk_devt(md->disk)) >> MMC_SHIFT;
> -
> -		if (!devmaj)
> -			devidx = md->disk->first_minor >> MMC_SHIFT;
> +		int devidx = md->disk->first_minor >> MMC_SHIFT;
>  
>  		blk_cleanup_queue(md->queue.queue);
>  
> @@ -607,6 +603,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
>  	md->disk->private_data = md;
>  	md->disk->queue = md->queue.queue;
>  	md->disk->driverfs_dev = &card->dev;
> +	md->disk->flags = GENHD_FL_EXT_DEVT;
>  
>  	/*
>  	 * As discussed on lkml, GENHD_FL_REMOVABLE should:


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-09-09  7:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-18  4:13 [PATCH] mmc: make number of mmcblk minors configurable Olof Johansson
2010-08-19  0:16 ` Andrew Morton
2010-08-19  3:22   ` Olof Johansson
2010-08-20  1:02     ` [PATCH v2] mmc: add config and runtime option for number of mmcblk minors Olof Johansson
2010-08-20 22:13       ` [PATCH v3] " Olof Johansson
2010-08-20 22:18         ` sys_init_module system call runcoderen
2010-08-20 22:32           ` Randy Dunlap
2010-08-20 22:50             ` runcoderen
2010-09-08 14:25         ` [PATCH v3] mmc: add config and runtime option for number of mmcblk minors Lei Wen
2010-09-08 14:57           ` Olof Johansson
2010-09-08 15:19             ` Kay Sievers
2010-09-08 15:57               ` Olof Johansson
2010-09-08 16:48                 ` Colin Cross
2010-09-08 16:50                   ` [PATCH] mmc_block: Allow more than 8 partitions per card Colin Cross
2010-09-09  2:49                     ` Lei Wen
2010-09-09  7:54                     ` Adrian Hunter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.