All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mmc : general purpose partition support.
@ 2011-09-24  5:07 Namjae Jeon
       [not found] ` <4E80BE05.40401@linux.intel.com>
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Namjae Jeon @ 2011-09-24  5:07 UTC (permalink / raw)
  To: cjb, linux-mmc
  Cc: linux-kernel, awarkentin, adrian.hunter, james_p_freyensee, Namjae Jeon

It allows gerneral purpose partitions in MMC Device.
And I try to simpliy make mmc_blk_alloc_parts using mmc_part structure suggested by Andrei Warkentin.
After patching, we can see general purpose partitions like this.
> cat /proc/partitions
          179 0 847872 mmcblk0
          179 192 4096 mmcblk0gp4
          179 160 4096 mmcblk0gp3
          179 128 4096 mmcblk0gp2
          179 96  1052672 mmcblk0gp1
          179 64  1024 mmcblk0boot1
          179 32  1024 mmcblk0boot0

Signed-off-by: Namjae Jeon <linkinjeon@gmail.com>
---
 drivers/mmc/card/block.c |   30 ++++++++++++++++--------------
 drivers/mmc/core/mmc.c   |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/mmc/card.h |   19 ++++++++++++++++++-
 include/linux/mmc/mmc.h  |    2 --
 4 files changed, 79 insertions(+), 18 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 1ff5486..8ec7cfd 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1377,26 +1377,28 @@ static int mmc_blk_alloc_part(struct mmc_card *card,
 	return 0;
 }
 
+/* MMC Physical partition consist of two boot partitons and
+ * four general purpose partitions.
+ * if the register of respective partitions is set in ext_csd,
+ * it allocate block device to be accessed.
+ */
+
 static int mmc_blk_alloc_parts(struct mmc_card *card, struct mmc_blk_data *md)
 {
-	int ret = 0;
+	int i, ret = 0;
 
 	if (!mmc_card_mmc(card))
 		return 0;
 
-	if (card->ext_csd.boot_size) {
-		ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_BOOT0,
-					 card->ext_csd.boot_size >> 9,
-					 true,
-					 "boot0");
-		if (ret)
-			return ret;
-		ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_BOOT1,
-					 card->ext_csd.boot_size >> 9,
-					 true,
-					 "boot1");
-		if (ret)
-			return ret;
+	for (i = 0; i < MMC_MAX_NUM_PHY_PARTITION; i++) {
+		if (card->part[i].size) {
+			ret = mmc_blk_alloc_part(card, md, card->part[i].cookie,
+				card->part[i].size >> 9,
+				card->part[i].force_ro,
+				card->part[i].name);
+			if (ret)
+				return ret;
+		}
 	}
 
 	return ret;
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 5700b1c..56c4b9e 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -340,7 +340,18 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
 		 * There are two boot regions of equal size, defined in
 		 * multiples of 128K.
 		 */
-		card->ext_csd.boot_size = ext_csd[EXT_CSD_BOOT_MULT] << 17;
+		int i, boot_part_config;
+		if (ext_csd[EXT_CSD_BOOT_MULT]) {
+			for (i = 0, boot_part_config = 0x1;
+				i < MMC_NUM_BOOT_PARTITION;
+				i++, boot_part_config++) {
+				card->part[i].size =
+					ext_csd[EXT_CSD_BOOT_MULT] << 17;
+				card->part[i].cookie = boot_part_config;
+				sprintf(card->part[i].name, "boot%d", i);
+				card->part[i].force_ro = true;
+			}
+		}
 	}
 
 	card->ext_csd.raw_hc_erase_gap_size =
@@ -392,6 +403,39 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
 			card->ext_csd.enhanced_area_offset = -EINVAL;
 			card->ext_csd.enhanced_area_size = -EINVAL;
 		}
+
+		if (ext_csd[EXT_CSD_PARTITION_SUPPORT] & 0x1) {
+			u8 hc_erase_grp_sz =
+				ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE];
+			u8 hc_wp_grp_sz =
+				ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
+
+			card->ext_csd.enhanced_area_en = 1;
+
+			int i, gp_num, gp_part_config, gp_size_mult;
+			for (i = 2, gp_num = 1, gp_part_config = 0x4,
+				gp_size_mult = 143;
+				i < MMC_MAX_NUM_PHY_PARTITION;
+				i++, gp_num++, gp_part_config++,
+				gp_size_mult += 3) {
+					if (!ext_csd[gp_size_mult] &&
+						!ext_csd[gp_size_mult + 1] &&
+						!ext_csd[gp_size_mult + 2])
+						continue;
+				card->part[i].size =
+					(ext_csd[gp_size_mult + 2] << 16) +
+					(ext_csd[gp_size_mult + 1] << 8) +
+					ext_csd[gp_size_mult];
+				card->part[i].size *=
+					(size_t)(hc_erase_grp_sz *
+					hc_wp_grp_sz);
+				card->part[i].size <<= 19;
+				card->part[i].cookie = gp_part_config;
+				sprintf(card->part[i].name,
+					"gp%d", gp_num);
+				card->part[i].force_ro = false;
+			}
+		}
 		card->ext_csd.sec_trim_mult =
 			ext_csd[EXT_CSD_SEC_TRIM_MULT];
 		card->ext_csd.sec_erase_mult =
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index b460fc2..842f702 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -12,6 +12,7 @@
 
 #include <linux/mmc/core.h>
 #include <linux/mod_devicetable.h>
+#include <linux/genhd.h>
 
 struct mmc_cid {
 	unsigned int		manfid;
@@ -63,7 +64,6 @@ struct mmc_ext_csd {
 	bool			enhanced_area_en;	/* enable bit */
 	unsigned long long	enhanced_area_offset;	/* Units: Byte */
 	unsigned int		enhanced_area_size;	/* Units: KB */
-	unsigned int		boot_size;		/* in bytes */
 	u8			raw_partition_support;	/* 160 */
 	u8			raw_erased_mem_count;	/* 181 */
 	u8			raw_ext_csd_structure;	/* 194 */
@@ -157,6 +157,22 @@ struct sdio_func_tuple;
 
 #define SDIO_MAX_FUNCS		7
 
+/* The number of MMC physical partitions
+ * It consist of boot partitions(2), general purpose partitions(4) in MMC v4.4
+ */
+#define MMC_NUM_BOOT_PARTITION	2
+#define MMC_MAX_NUM_PHY_PARTITION	6
+
+/*
+ * MMC Physical partitions
+ */
+struct mmc_part {
+	unsigned int	size;	/* partition size (in bytes) */
+	unsigned int	cookie;	/* it used to part_type */
+	char	name[DISK_NAME_LEN];
+	bool	force_ro;	/* to make boot parts RO by default */
+};
+
 /*
  * MMC device
  */
@@ -216,6 +232,7 @@ struct mmc_card {
 	unsigned int		sd_bus_speed;	/* Bus Speed Mode set for the card */
 
 	struct dentry		*debugfs_root;
+	struct	mmc_part part[MMC_MAX_NUM_PHY_PARTITION];	/* mmc physical partitions */
 };
 
 /*
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index 5a794cb..33eae3d 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -301,8 +301,6 @@ struct _mmc_csd {
 #define EXT_CSD_WR_REL_PARAM_EN		(1<<2)
 
 #define EXT_CSD_PART_CONFIG_ACC_MASK	(0x7)
-#define EXT_CSD_PART_CONFIG_ACC_BOOT0	(0x1)
-#define EXT_CSD_PART_CONFIG_ACC_BOOT1	(0x2)
 
 #define EXT_CSD_CMD_SET_NORMAL		(1<<0)
 #define EXT_CSD_CMD_SET_SECURE		(1<<1)
-- 
1.7.4.4


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

* Re: [PATCH v2] mmc : general purpose partition support.
       [not found] ` <4E80BE05.40401@linux.intel.com>
@ 2011-09-28  1:13     ` NamJae Jeon
  0 siblings, 0 replies; 9+ messages in thread
From: NamJae Jeon @ 2011-09-28  1:13 UTC (permalink / raw)
  To: J Freyensee, cjb, linux-mmc, Andrei Warkentin, adrian.hunter,
	linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 10524 bytes --]

2011/9/27 J Freyensee <james_p_freyensee@linux.intel.com>:
> On 09/23/2011 10:07 PM, Namjae Jeon wrote:
>>
>> It allows gerneral purpose partitions in MMC Device.
>> And I try to simpliy make mmc_blk_alloc_parts using mmc_part structure
>> suggested by Andrei Warkentin.
>> After patching, we can see general purpose partitions like this.
>>>
>>> cat /proc/partitions
>>
>>           179 0 847872 mmcblk0
>>           179 192 4096 mmcblk0gp4
>>           179 160 4096 mmcblk0gp3
>>           179 128 4096 mmcblk0gp2
>>           179 96  1052672 mmcblk0gp1
>>           179 64  1024 mmcblk0boot1
>>           179 32  1024 mmcblk0boot0
>
> Looks reasonable to me.
Thanks for your review.
I want to know how the opinion of others.

>
>
>>
>> Signed-off-by: Namjae Jeon<linkinjeon@gmail.com>
>> ---
>>  drivers/mmc/card/block.c |   30 ++++++++++++++++--------------
>>  drivers/mmc/core/mmc.c   |   46
>> +++++++++++++++++++++++++++++++++++++++++++++-
>>  include/linux/mmc/card.h |   19 ++++++++++++++++++-
>>  include/linux/mmc/mmc.h  |    2 --
>>  4 files changed, 79 insertions(+), 18 deletions(-)
>>
>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>> index 1ff5486..8ec7cfd 100644
>> --- a/drivers/mmc/card/block.c
>> +++ b/drivers/mmc/card/block.c
>> @@ -1377,26 +1377,28 @@ static int mmc_blk_alloc_part(struct mmc_card
>> *card,
>>        return 0;
>>  }
>>
>> +/* MMC Physical partition consist of two boot partitons and
>> + * four general purpose partitions.
>> + * if the register of respective partitions is set in ext_csd,
>> + * it allocate block device to be accessed.
>> + */
>> +
>>  static int mmc_blk_alloc_parts(struct mmc_card *card, struct mmc_blk_data
>> *md)
>>  {
>> -       int ret = 0;
>> +       int i, ret = 0;
>>
>>        if (!mmc_card_mmc(card))
>>                return 0;
>>
>> -       if (card->ext_csd.boot_size) {
>> -               ret = mmc_blk_alloc_part(card, md,
>> EXT_CSD_PART_CONFIG_ACC_BOOT0,
>> -                                        card->ext_csd.boot_size>>  9,
>> -                                        true,
>> -                                        "boot0");
>> -               if (ret)
>> -                       return ret;
>> -               ret = mmc_blk_alloc_part(card, md,
>> EXT_CSD_PART_CONFIG_ACC_BOOT1,
>> -                                        card->ext_csd.boot_size>>  9,
>> -                                        true,
>> -                                        "boot1");
>> -               if (ret)
>> -                       return ret;
>> +       for (i = 0; i<  MMC_MAX_NUM_PHY_PARTITION; i++) {
>> +               if (card->part[i].size) {
>> +                       ret = mmc_blk_alloc_part(card, md,
>> card->part[i].cookie,
>> +                               card->part[i].size>>  9,
>> +                               card->part[i].force_ro,
>> +                               card->part[i].name);
>> +                       if (ret)
>> +                               return ret;
>> +               }
>>        }
>>
>>        return ret;
>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>> index 5700b1c..56c4b9e 100644
>> --- a/drivers/mmc/core/mmc.c
>> +++ b/drivers/mmc/core/mmc.c
>> @@ -340,7 +340,18 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8
>> *ext_csd)
>>                 * There are two boot regions of equal size, defined in
>>                 * multiples of 128K.
>>                 */
>> -               card->ext_csd.boot_size = ext_csd[EXT_CSD_BOOT_MULT]<<
>>  17;
>> +               int i, boot_part_config;
>> +               if (ext_csd[EXT_CSD_BOOT_MULT]) {
>> +                       for (i = 0, boot_part_config = 0x1;
>> +                               i<  MMC_NUM_BOOT_PARTITION;
>> +                               i++, boot_part_config++) {
>> +                               card->part[i].size =
>> +                                       ext_csd[EXT_CSD_BOOT_MULT]<<  17;
>> +                               card->part[i].cookie = boot_part_config;
>> +                               sprintf(card->part[i].name, "boot%d", i);
>> +                               card->part[i].force_ro = true;
>> +                       }
>> +               }
>>        }
>>
>>        card->ext_csd.raw_hc_erase_gap_size =
>> @@ -392,6 +403,39 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8
>> *ext_csd)
>>                        card->ext_csd.enhanced_area_offset = -EINVAL;
>>                        card->ext_csd.enhanced_area_size = -EINVAL;
>>                }
>> +
>> +               if (ext_csd[EXT_CSD_PARTITION_SUPPORT]&  0x1) {
>> +                       u8 hc_erase_grp_sz =
>> +                               ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE];
>> +                       u8 hc_wp_grp_sz =
>> +                               ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
>> +
>> +                       card->ext_csd.enhanced_area_en = 1;
>> +
>> +                       int i, gp_num, gp_part_config, gp_size_mult;
>> +                       for (i = 2, gp_num = 1, gp_part_config = 0x4,
>> +                               gp_size_mult = 143;
>> +                               i<  MMC_MAX_NUM_PHY_PARTITION;
>> +                               i++, gp_num++, gp_part_config++,
>> +                               gp_size_mult += 3) {
>> +                                       if (!ext_csd[gp_size_mult]&&
>> +                                               !ext_csd[gp_size_mult +
>> 1]&&
>> +                                               !ext_csd[gp_size_mult +
>> 2])
>> +                                               continue;
>> +                               card->part[i].size =
>> +                                       (ext_csd[gp_size_mult + 2]<<  16)
>> +
>> +                                       (ext_csd[gp_size_mult + 1]<<  8) +
>> +                                       ext_csd[gp_size_mult];
>> +                               card->part[i].size *=
>> +                                       (size_t)(hc_erase_grp_sz *
>> +                                       hc_wp_grp_sz);
>> +                               card->part[i].size<<= 19;
>> +                               card->part[i].cookie = gp_part_config;
>> +                               sprintf(card->part[i].name,
>> +                                       "gp%d", gp_num);
>> +                               card->part[i].force_ro = false;
>> +                       }
>> +               }
>>                card->ext_csd.sec_trim_mult =
>>                        ext_csd[EXT_CSD_SEC_TRIM_MULT];
>>                card->ext_csd.sec_erase_mult =
>> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
>> index b460fc2..842f702 100644
>> --- a/include/linux/mmc/card.h
>> +++ b/include/linux/mmc/card.h
>> @@ -12,6 +12,7 @@
>>
>>  #include<linux/mmc/core.h>
>>  #include<linux/mod_devicetable.h>
>> +#include<linux/genhd.h>
>>
>>  struct mmc_cid {
>>        unsigned int            manfid;
>> @@ -63,7 +64,6 @@ struct mmc_ext_csd {
>>        bool                    enhanced_area_en;       /* enable bit */
>>        unsigned long long      enhanced_area_offset;   /* Units: Byte */
>>        unsigned int            enhanced_area_size;     /* Units: KB */
>> -       unsigned int            boot_size;              /* in bytes */
>>        u8                      raw_partition_support;  /* 160 */
>>        u8                      raw_erased_mem_count;   /* 181 */
>>        u8                      raw_ext_csd_structure;  /* 194 */
>> @@ -157,6 +157,22 @@ struct sdio_func_tuple;
>>
>>  #define SDIO_MAX_FUNCS                7
>>
>> +/* The number of MMC physical partitions
>> + * It consist of boot partitions(2), general purpose partitions(4) in MMC
>> v4.4
>> + */
>> +#define MMC_NUM_BOOT_PARTITION 2
>> +#define MMC_MAX_NUM_PHY_PARTITION      6
>> +
>> +/*
>> + * MMC Physical partitions
>> + */
>> +struct mmc_part {
>> +       unsigned int    size;   /* partition size (in bytes) */
>> +       unsigned int    cookie; /* it used to part_type */
>> +       char    name[DISK_NAME_LEN];
>> +       bool    force_ro;       /* to make boot parts RO by default */
>> +};
>> +
>>  /*
>>   * MMC device
>>   */
>> @@ -216,6 +232,7 @@ struct mmc_card {
>>        unsigned int            sd_bus_speed;   /* Bus Speed Mode set for
>> the card */
>>
>>        struct dentry           *debugfs_root;
>> +       struct  mmc_part part[MMC_MAX_NUM_PHY_PARTITION];       /* mmc
>> physical partitions */
>>  };
>>
>>  /*
>> diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
>> index 5a794cb..33eae3d 100644
>> --- a/include/linux/mmc/mmc.h
>> +++ b/include/linux/mmc/mmc.h
>> @@ -301,8 +301,6 @@ struct _mmc_csd {
>>  #define EXT_CSD_WR_REL_PARAM_EN               (1<<2)
>>
>>  #define EXT_CSD_PART_CONFIG_ACC_MASK  (0x7)
>> -#define EXT_CSD_PART_CONFIG_ACC_BOOT0  (0x1)
>> -#define EXT_CSD_PART_CONFIG_ACC_BOOT1  (0x2)
>>
>>  #define EXT_CSD_CMD_SET_NORMAL                (1<<0)
>>  #define EXT_CSD_CMD_SET_SECURE                (1<<1)
>
>
> --
> J (James/Jay) Freyensee
> Storage Technology Group
> Intel Corporation
>
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH v2] mmc : general purpose partition support.
@ 2011-09-28  1:13     ` NamJae Jeon
  0 siblings, 0 replies; 9+ messages in thread
From: NamJae Jeon @ 2011-09-28  1:13 UTC (permalink / raw)
  To: J Freyensee, cjb, linux-mmc, Andrei Warkentin, adrian.hunter,
	linux-kernel

2011/9/27 J Freyensee <james_p_freyensee@linux.intel.com>:
> On 09/23/2011 10:07 PM, Namjae Jeon wrote:
>>
>> It allows gerneral purpose partitions in MMC Device.
>> And I try to simpliy make mmc_blk_alloc_parts using mmc_part structure
>> suggested by Andrei Warkentin.
>> After patching, we can see general purpose partitions like this.
>>>
>>> cat /proc/partitions
>>
>>           179 0 847872 mmcblk0
>>           179 192 4096 mmcblk0gp4
>>           179 160 4096 mmcblk0gp3
>>           179 128 4096 mmcblk0gp2
>>           179 96  1052672 mmcblk0gp1
>>           179 64  1024 mmcblk0boot1
>>           179 32  1024 mmcblk0boot0
>
> Looks reasonable to me.
Thanks for your review.
I want to know how the opinion of others.

>
>
>>
>> Signed-off-by: Namjae Jeon<linkinjeon@gmail.com>
>> ---
>>  drivers/mmc/card/block.c |   30 ++++++++++++++++--------------
>>  drivers/mmc/core/mmc.c   |   46
>> +++++++++++++++++++++++++++++++++++++++++++++-
>>  include/linux/mmc/card.h |   19 ++++++++++++++++++-
>>  include/linux/mmc/mmc.h  |    2 --
>>  4 files changed, 79 insertions(+), 18 deletions(-)
>>
>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>> index 1ff5486..8ec7cfd 100644
>> --- a/drivers/mmc/card/block.c
>> +++ b/drivers/mmc/card/block.c
>> @@ -1377,26 +1377,28 @@ static int mmc_blk_alloc_part(struct mmc_card
>> *card,
>>        return 0;
>>  }
>>
>> +/* MMC Physical partition consist of two boot partitons and
>> + * four general purpose partitions.
>> + * if the register of respective partitions is set in ext_csd,
>> + * it allocate block device to be accessed.
>> + */
>> +
>>  static int mmc_blk_alloc_parts(struct mmc_card *card, struct mmc_blk_data
>> *md)
>>  {
>> -       int ret = 0;
>> +       int i, ret = 0;
>>
>>        if (!mmc_card_mmc(card))
>>                return 0;
>>
>> -       if (card->ext_csd.boot_size) {
>> -               ret = mmc_blk_alloc_part(card, md,
>> EXT_CSD_PART_CONFIG_ACC_BOOT0,
>> -                                        card->ext_csd.boot_size>>  9,
>> -                                        true,
>> -                                        "boot0");
>> -               if (ret)
>> -                       return ret;
>> -               ret = mmc_blk_alloc_part(card, md,
>> EXT_CSD_PART_CONFIG_ACC_BOOT1,
>> -                                        card->ext_csd.boot_size>>  9,
>> -                                        true,
>> -                                        "boot1");
>> -               if (ret)
>> -                       return ret;
>> +       for (i = 0; i<  MMC_MAX_NUM_PHY_PARTITION; i++) {
>> +               if (card->part[i].size) {
>> +                       ret = mmc_blk_alloc_part(card, md,
>> card->part[i].cookie,
>> +                               card->part[i].size>>  9,
>> +                               card->part[i].force_ro,
>> +                               card->part[i].name);
>> +                       if (ret)
>> +                               return ret;
>> +               }
>>        }
>>
>>        return ret;
>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>> index 5700b1c..56c4b9e 100644
>> --- a/drivers/mmc/core/mmc.c
>> +++ b/drivers/mmc/core/mmc.c
>> @@ -340,7 +340,18 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8
>> *ext_csd)
>>                 * There are two boot regions of equal size, defined in
>>                 * multiples of 128K.
>>                 */
>> -               card->ext_csd.boot_size = ext_csd[EXT_CSD_BOOT_MULT]<<
>>  17;
>> +               int i, boot_part_config;
>> +               if (ext_csd[EXT_CSD_BOOT_MULT]) {
>> +                       for (i = 0, boot_part_config = 0x1;
>> +                               i<  MMC_NUM_BOOT_PARTITION;
>> +                               i++, boot_part_config++) {
>> +                               card->part[i].size =
>> +                                       ext_csd[EXT_CSD_BOOT_MULT]<<  17;
>> +                               card->part[i].cookie = boot_part_config;
>> +                               sprintf(card->part[i].name, "boot%d", i);
>> +                               card->part[i].force_ro = true;
>> +                       }
>> +               }
>>        }
>>
>>        card->ext_csd.raw_hc_erase_gap_size =
>> @@ -392,6 +403,39 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8
>> *ext_csd)
>>                        card->ext_csd.enhanced_area_offset = -EINVAL;
>>                        card->ext_csd.enhanced_area_size = -EINVAL;
>>                }
>> +
>> +               if (ext_csd[EXT_CSD_PARTITION_SUPPORT]&  0x1) {
>> +                       u8 hc_erase_grp_sz =
>> +                               ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE];
>> +                       u8 hc_wp_grp_sz =
>> +                               ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
>> +
>> +                       card->ext_csd.enhanced_area_en = 1;
>> +
>> +                       int i, gp_num, gp_part_config, gp_size_mult;
>> +                       for (i = 2, gp_num = 1, gp_part_config = 0x4,
>> +                               gp_size_mult = 143;
>> +                               i<  MMC_MAX_NUM_PHY_PARTITION;
>> +                               i++, gp_num++, gp_part_config++,
>> +                               gp_size_mult += 3) {
>> +                                       if (!ext_csd[gp_size_mult]&&
>> +                                               !ext_csd[gp_size_mult +
>> 1]&&
>> +                                               !ext_csd[gp_size_mult +
>> 2])
>> +                                               continue;
>> +                               card->part[i].size =
>> +                                       (ext_csd[gp_size_mult + 2]<<  16)
>> +
>> +                                       (ext_csd[gp_size_mult + 1]<<  8) +
>> +                                       ext_csd[gp_size_mult];
>> +                               card->part[i].size *=
>> +                                       (size_t)(hc_erase_grp_sz *
>> +                                       hc_wp_grp_sz);
>> +                               card->part[i].size<<= 19;
>> +                               card->part[i].cookie = gp_part_config;
>> +                               sprintf(card->part[i].name,
>> +                                       "gp%d", gp_num);
>> +                               card->part[i].force_ro = false;
>> +                       }
>> +               }
>>                card->ext_csd.sec_trim_mult =
>>                        ext_csd[EXT_CSD_SEC_TRIM_MULT];
>>                card->ext_csd.sec_erase_mult =
>> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
>> index b460fc2..842f702 100644
>> --- a/include/linux/mmc/card.h
>> +++ b/include/linux/mmc/card.h
>> @@ -12,6 +12,7 @@
>>
>>  #include<linux/mmc/core.h>
>>  #include<linux/mod_devicetable.h>
>> +#include<linux/genhd.h>
>>
>>  struct mmc_cid {
>>        unsigned int            manfid;
>> @@ -63,7 +64,6 @@ struct mmc_ext_csd {
>>        bool                    enhanced_area_en;       /* enable bit */
>>        unsigned long long      enhanced_area_offset;   /* Units: Byte */
>>        unsigned int            enhanced_area_size;     /* Units: KB */
>> -       unsigned int            boot_size;              /* in bytes */
>>        u8                      raw_partition_support;  /* 160 */
>>        u8                      raw_erased_mem_count;   /* 181 */
>>        u8                      raw_ext_csd_structure;  /* 194 */
>> @@ -157,6 +157,22 @@ struct sdio_func_tuple;
>>
>>  #define SDIO_MAX_FUNCS                7
>>
>> +/* The number of MMC physical partitions
>> + * It consist of boot partitions(2), general purpose partitions(4) in MMC
>> v4.4
>> + */
>> +#define MMC_NUM_BOOT_PARTITION 2
>> +#define MMC_MAX_NUM_PHY_PARTITION      6
>> +
>> +/*
>> + * MMC Physical partitions
>> + */
>> +struct mmc_part {
>> +       unsigned int    size;   /* partition size (in bytes) */
>> +       unsigned int    cookie; /* it used to part_type */
>> +       char    name[DISK_NAME_LEN];
>> +       bool    force_ro;       /* to make boot parts RO by default */
>> +};
>> +
>>  /*
>>   * MMC device
>>   */
>> @@ -216,6 +232,7 @@ struct mmc_card {
>>        unsigned int            sd_bus_speed;   /* Bus Speed Mode set for
>> the card */
>>
>>        struct dentry           *debugfs_root;
>> +       struct  mmc_part part[MMC_MAX_NUM_PHY_PARTITION];       /* mmc
>> physical partitions */
>>  };
>>
>>  /*
>> diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
>> index 5a794cb..33eae3d 100644
>> --- a/include/linux/mmc/mmc.h
>> +++ b/include/linux/mmc/mmc.h
>> @@ -301,8 +301,6 @@ struct _mmc_csd {
>>  #define EXT_CSD_WR_REL_PARAM_EN               (1<<2)
>>
>>  #define EXT_CSD_PART_CONFIG_ACC_MASK  (0x7)
>> -#define EXT_CSD_PART_CONFIG_ACC_BOOT0  (0x1)
>> -#define EXT_CSD_PART_CONFIG_ACC_BOOT1  (0x2)
>>
>>  #define EXT_CSD_CMD_SET_NORMAL                (1<<0)
>>  #define EXT_CSD_CMD_SET_SECURE                (1<<1)
>
>
> --
> J (James/Jay) Freyensee
> Storage Technology Group
> Intel Corporation
>

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

* Re: [PATCH v2] mmc : general purpose partition support.
  2011-09-24  5:07 [PATCH v2] mmc : general purpose partition support Namjae Jeon
       [not found] ` <4E80BE05.40401@linux.intel.com>
@ 2011-09-28 11:21 ` Linus Walleij
  2011-09-28 13:50   ` NamJae Jeon
  2011-09-28 16:08 ` Andrei Warkentin
  2 siblings, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2011-09-28 11:21 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: cjb, linux-mmc, linux-kernel, awarkentin, adrian.hunter,
	james_p_freyensee, sebras, Ulf Hansson, Stefan Nilsson XK,
	Per Forlin, johan.rudholm

On Sat, Sep 24, 2011 at 7:07 AM, Namjae Jeon <linkinjeon@gmail.com> wrote:

> It allows gerneral purpose partitions in MMC Device.
> And I try to simpliy make mmc_blk_alloc_parts using mmc_part structure suggested by Andrei Warkentin.
> After patching, we can see general purpose partitions like this.
>> cat /proc/partitions
>          179 0 847872 mmcblk0
>          179 192 4096 mmcblk0gp4
>          179 160 4096 mmcblk0gp3
>          179 128 4096 mmcblk0gp2
>          179 96  1052672 mmcblk0gp1

We notice there are 32 minors between 128 and 96,
how are these allocated?

>          179 64  1024 mmcblk0boot1
>          179 32  1024 mmcblk0boot0

Does this mean that each GP-partition can contain an MBR and thus several
subpartitions so we get things like:

mmcblk0gp1p1, mmcblk0gp1p2...

?

Yours,
Linus Walleij

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

* Re: [PATCH v2] mmc : general purpose partition support.
  2011-09-28 11:21 ` Linus Walleij
@ 2011-09-28 13:50   ` NamJae Jeon
  2011-09-29  6:47     ` Linus Walleij
  0 siblings, 1 reply; 9+ messages in thread
From: NamJae Jeon @ 2011-09-28 13:50 UTC (permalink / raw)
  To: Linus Walleij
  Cc: cjb, linux-mmc, linux-kernel, awarkentin, adrian.hunter,
	james_p_freyensee, sebras, Ulf Hansson, Stefan Nilsson XK,
	Per Forlin, johan.rudholm

2011/9/28 Linus Walleij <linus.walleij@linaro.org>:
> On Sat, Sep 24, 2011 at 7:07 AM, Namjae Jeon <linkinjeon@gmail.com> wrote:
>
>> It allows gerneral purpose partitions in MMC Device.
>> And I try to simpliy make mmc_blk_alloc_parts using mmc_part structure suggested by Andrei Warkentin.
>> After patching, we can see general purpose partitions like this.
>>> cat /proc/partitions
>>          179 0 847872 mmcblk0
>>          179 192 4096 mmcblk0gp4
>>          179 160 4096 mmcblk0gp3
>>          179 128 4096 mmcblk0gp2
>>          179 96  1052672 mmcblk0gp1
>
> We notice there are 32 minors between 128 and 96,
> how are these allocated?
You can insert maximum minors in menuconfig. I set to 32.
>
>>          179 64  1024 mmcblk0boot1
>>          179 32  1024 mmcblk0boot0
>
> Does this mean that each GP-partition can contain an MBR and thus several
> subpartitions so we get things like:
>
> mmcblk0gp1p1, mmcblk0gp1p2...
>
>
Yes, We can divide dos partitions(included MBR) using fdisk like your
words(mmcblk0gp1p1, mmcblk0gp1p2...)

> Yours,
> Linus Walleij
>

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

* Re: [PATCH v2] mmc : general purpose partition support.
  2011-09-24  5:07 [PATCH v2] mmc : general purpose partition support Namjae Jeon
       [not found] ` <4E80BE05.40401@linux.intel.com>
  2011-09-28 11:21 ` Linus Walleij
@ 2011-09-28 16:08 ` Andrei Warkentin
  2011-09-29  1:03   ` NamJae Jeon
  2 siblings, 1 reply; 9+ messages in thread
From: Andrei Warkentin @ 2011-09-28 16:08 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: linux-kernel, adrian hunter, james p freyensee, cjb, linux-mmc

Hi Namjae,

In general I think your approach is fine and solves the problem. See further inline
comments.

----- Original Message -----
> From: "Namjae Jeon" <linkinjeon@gmail.com>
> To: cjb@laptop.org, linux-mmc@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org, awarkentin@vmware.com, "adrian hunter" <adrian.hunter@intel.com>, "james p
> freyensee" <james_p_freyensee@linux.intel.com>, "Namjae Jeon" <linkinjeon@gmail.com>
> Sent: Saturday, September 24, 2011 1:07:00 AM
> Subject: [PATCH v2] mmc : general purpose partition support.
> 
> It allows gerneral purpose partitions in MMC Device.
> And I try to simpliy make mmc_blk_alloc_parts using mmc_part
> structure suggested by Andrei Warkentin.
> After patching, we can see general purpose partitions like this.
> > cat /proc/partitions
>           179 0 847872 mmcblk0
>           179 192 4096 mmcblk0gp4
>           179 160 4096 mmcblk0gp3
>           179 128 4096 mmcblk0gp2
>           179 96  1052672 mmcblk0gp1
>           179 64  1024 mmcblk0boot1
>           179 32  1024 mmcblk0boot0
> 
> Signed-off-by: Namjae Jeon <linkinjeon@gmail.com>

> +		if (ext_csd[EXT_CSD_BOOT_MULT]) {
> +			for (i = 0, boot_part_config = 0x1;
> +				i < MMC_NUM_BOOT_PARTITION;
> +				i++, boot_part_config++) {
> +				card->part[i].size = ...
> +				card->part[i].cookie = ...
> +				sprintf(card->part[i].name, "boot%d", i);
> +				card->part[i].force_ro = ...
> +			}
> +		}
>  	}
>  
>
> +		if (ext_csd[EXT_CSD_PARTITION_SUPPORT] & 0x1) {
> +                     ....
> +			int i, gp_num, gp_part_config, gp_size_mult;
> +			for (i = 2, gp_num = 1, gp_part_config = 0x4,
> +				card->part[i].size = ...
> +				card->part[i].cookie = ...
> +				sprintf(card->part[i].name,
> +					"gp%d", gp_num);
> +				card->part[i].force_ro = ..
> +			}
> +		}
>

I feel that you should factor out a function that operates on the static part[] array and
adds a new entry base name, index (i.e. the %d for gp%d), cookie, size, force. 
Otherwise you end up with these hidden mines like fixed indeces for
particular parts (i = 2, etc...) which becomes indecipherable for others. 
Plus you're mostly doing the same thing.

Thanks,
A

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

* Re: [PATCH v2] mmc : general purpose partition support.
  2011-09-28 16:08 ` Andrei Warkentin
@ 2011-09-29  1:03   ` NamJae Jeon
  0 siblings, 0 replies; 9+ messages in thread
From: NamJae Jeon @ 2011-09-29  1:03 UTC (permalink / raw)
  To: Andrei Warkentin
  Cc: linux-kernel, adrian hunter, james p freyensee, cjb, linux-mmc

2011/9/29 Andrei Warkentin <awarkentin@vmware.com>:
> Hi Namjae,
>
> In general I think your approach is fine and solves the problem. See further inline
> comments.
>
> ----- Original Message -----
>> From: "Namjae Jeon" <linkinjeon@gmail.com>
>> To: cjb@laptop.org, linux-mmc@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org, awarkentin@vmware.com, "adrian hunter" <adrian.hunter@intel.com>, "james p
>> freyensee" <james_p_freyensee@linux.intel.com>, "Namjae Jeon" <linkinjeon@gmail.com>
>> Sent: Saturday, September 24, 2011 1:07:00 AM
>> Subject: [PATCH v2] mmc : general purpose partition support.
>>
>> It allows gerneral purpose partitions in MMC Device.
>> And I try to simpliy make mmc_blk_alloc_parts using mmc_part
>> structure suggested by Andrei Warkentin.
>> After patching, we can see general purpose partitions like this.
>> > cat /proc/partitions
>>           179 0 847872 mmcblk0
>>           179 192 4096 mmcblk0gp4
>>           179 160 4096 mmcblk0gp3
>>           179 128 4096 mmcblk0gp2
>>           179 96  1052672 mmcblk0gp1
>>           179 64  1024 mmcblk0boot1
>>           179 32  1024 mmcblk0boot0
>>
>> Signed-off-by: Namjae Jeon <linkinjeon@gmail.com>
>
>> +             if (ext_csd[EXT_CSD_BOOT_MULT]) {
>> +                     for (i = 0, boot_part_config = 0x1;
>> +                             i < MMC_NUM_BOOT_PARTITION;
>> +                             i++, boot_part_config++) {
>> +                             card->part[i].size = ...
>> +                             card->part[i].cookie = ...
>> +                             sprintf(card->part[i].name, "boot%d", i);
>> +                             card->part[i].force_ro = ...
>> +                     }
>> +             }
>>       }
>>
>>
>> +             if (ext_csd[EXT_CSD_PARTITION_SUPPORT] & 0x1) {
>> +                     ....
>> +                     int i, gp_num, gp_part_config, gp_size_mult;
>> +                     for (i = 2, gp_num = 1, gp_part_config = 0x4,
>> +                             card->part[i].size = ...
>> +                             card->part[i].cookie = ...
>> +                             sprintf(card->part[i].name,
>> +                                     "gp%d", gp_num);
>> +                             card->part[i].force_ro = ..
>> +                     }
>> +             }
>>
>
> I feel that you should factor out a function that operates on the static part[] array and
> adds a new entry base name, index (i.e. the %d for gp%d), cookie, size, force.
> Otherwise you end up with these hidden mines like fixed indeces for
> particular parts (i = 2, etc...) which becomes indecipherable for others.
> Plus you're mostly doing the same thing.
>
Hi.
I think that factoring out a function will be not inefficient by many
agument and size calculation,. etc.
And I agree about readabiliby, readability is dropped by some fixed
value. so I will modify current patch.
plz review one more when I post new patch.
Thanks.
> Thanks,
> A
>

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

* Re: [PATCH v2] mmc : general purpose partition support.
  2011-09-28 13:50   ` NamJae Jeon
@ 2011-09-29  6:47     ` Linus Walleij
  2011-09-29  8:35       ` NamJae Jeon
  0 siblings, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2011-09-29  6:47 UTC (permalink / raw)
  To: NamJae Jeon
  Cc: cjb, linux-mmc, linux-kernel, awarkentin, adrian.hunter,
	james_p_freyensee, sebras, Ulf Hansson, Stefan Nilsson XK,
	Per Forlin, johan.rudholm

On Wed, Sep 28, 2011 at 3:50 PM, NamJae Jeon <linkinjeon@gmail.com> wrote:
> 2011/9/28 Linus Walleij <linus.walleij@linaro.org>:
>> On Sat, Sep 24, 2011 at 7:07 AM, Namjae Jeon <linkinjeon@gmail.com> wrote:
>>>
>>>          179 64  1024 mmcblk0boot1
>>>          179 32  1024 mmcblk0boot0
>>
>> Does this mean that each GP-partition can contain an MBR and thus several
>> subpartitions so we get things like:
>>
>> mmcblk0gp1p1, mmcblk0gp1p2...
>>
> Yes, We can divide dos partitions(included MBR) using fdisk like your
> words(mmcblk0gp1p1, mmcblk0gp1p2...)

OK that seems logical.

If this goes in, make a mental note to patch udev default rules
too, because currently they look like this:

rules.d/60-persistent-storage.rules:KERNEL=="mmcblk[0-9]",
SUBSYSTEMS=="mmc", ATTRS{name}=="?*", ATTRS{serial}=="?*",
ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}",
SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}"
rules.d/60-persistent-storage.rules:KERNEL=="mmcblk[0-9]p[0-9]",
ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*",
SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}-part%n"

(I guess Android also has this kind of rule baked into its "big init"
process that handles also what udev normally takes care of.)

Anyway:
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH v2] mmc : general purpose partition support.
  2011-09-29  6:47     ` Linus Walleij
@ 2011-09-29  8:35       ` NamJae Jeon
  0 siblings, 0 replies; 9+ messages in thread
From: NamJae Jeon @ 2011-09-29  8:35 UTC (permalink / raw)
  To: Linus Walleij
  Cc: cjb, linux-mmc, linux-kernel, awarkentin, adrian.hunter,
	james_p_freyensee, sebras, Ulf Hansson, Stefan Nilsson XK,
	Per Forlin, johan.rudholm

2011/9/29 Linus Walleij <linus.walleij@linaro.org>:
> On Wed, Sep 28, 2011 at 3:50 PM, NamJae Jeon <linkinjeon@gmail.com> wrote:
>> 2011/9/28 Linus Walleij <linus.walleij@linaro.org>:
>>> On Sat, Sep 24, 2011 at 7:07 AM, Namjae Jeon <linkinjeon@gmail.com> wrote:
>>>>
>>>>          179 64  1024 mmcblk0boot1
>>>>          179 32  1024 mmcblk0boot0
>>>
>>> Does this mean that each GP-partition can contain an MBR and thus several
>>> subpartitions so we get things like:
>>>
>>> mmcblk0gp1p1, mmcblk0gp1p2...
>>>
>> Yes, We can divide dos partitions(included MBR) using fdisk like your
>> words(mmcblk0gp1p1, mmcblk0gp1p2...)
>
> OK that seems logical.
>
> If this goes in, make a mental note to patch udev default rules
> too, because currently they look like this:
>
> rules.d/60-persistent-storage.rules:KERNEL=="mmcblk[0-9]",
> SUBSYSTEMS=="mmc", ATTRS{name}=="?*", ATTRS{serial}=="?*",
> ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}",
> SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}"
> rules.d/60-persistent-storage.rules:KERNEL=="mmcblk[0-9]p[0-9]",
> ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*",
> SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}-part%n"
>
> (I guess Android also has this kind of rule baked into its "big init"
> process that handles also what udev normally takes care of.)
>
> Anyway:
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
Thanks Linus~
I will modify a little code to improve the readability.
When I post patch v3 again, plz ack one more.
>
> Yours,
> Linus Walleij
>

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

end of thread, other threads:[~2011-09-29  8:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-24  5:07 [PATCH v2] mmc : general purpose partition support Namjae Jeon
     [not found] ` <4E80BE05.40401@linux.intel.com>
2011-09-28  1:13   ` NamJae Jeon
2011-09-28  1:13     ` NamJae Jeon
2011-09-28 11:21 ` Linus Walleij
2011-09-28 13:50   ` NamJae Jeon
2011-09-29  6:47     ` Linus Walleij
2011-09-29  8:35       ` NamJae Jeon
2011-09-28 16:08 ` Andrei Warkentin
2011-09-29  1:03   ` NamJae Jeon

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.