Skip to contentSkip to conversation

mmc : general purpose partition support.

PATCH Superseded Namjae Jeon 3 participants 10 messages Sep 22, 2011 – Sep 24, 2011 1 message not in the archive MMC, SD and SDIO

v1 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc : general purpose partition support.

It allows general purpose parition in MMC Device. If it is enable, it will make mmcblk0gp1,gp2,gp3,gp4 partition like this.

Quoted 1 line

cat /proc/paritition

      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
---
 drivers/mmc/card/block.c |   36 ++++++++++++++++++++++++++++++++++++
 drivers/mmc/core/mmc.c   |   42 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mmc/card.h |    4 ++++
 include/linux/mmc/mmc.h  |    4 ++++
 4 files changed, 86 insertions(+), 0 deletions(-)
drivers/mmc/card/block.c +36 -0
index 9b90726..074ec55 100644
@@ -1402,6 +1402,42 @@ static int mmc_blk_alloc_parts(struct mmc_card *card, struct mmc_blk_data *md)
 			return ret;
 	}
 
+	if (card->ext_csd.gp1_size) {
+		ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP1,
+					card->ext_csd.gp1_size >> 9,
+					false,
+					"gp1");
+		if (ret)
+			return ret;
+	}
+
+	if (card->ext_csd.gp2_size) {
+		ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP2,
+					card->ext_csd.gp2_size >> 9,
+					false,
+					"gp2");
+		if (ret)
+			return ret;
+	}
+
+	if (card->ext_csd.gp3_size) {
+		ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP3,
+					card->ext_csd.gp3_size >> 9,
+					false,
+					"gp3");
+		if (ret)
+			return ret;
+	}
+
+	if (card->ext_csd.gp4_size) {
+		ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP4,
+					card->ext_csd.gp4_size >> 9,
+					false,
+					"gp4");
+		if (ret)
+			return ret;
+	}
+
 	return ret;
 }
 
drivers/mmc/core/mmc.c +42 -0

48 lines not on this page · raw message

include/linux/mmc/card.h +4 -0
index b460fc2..96a98a7 100644
@@ -64,6 +64,10 @@ struct mmc_ext_csd {
 	unsigned long long	enhanced_area_offset;	/* Units: Byte */
 	unsigned int		enhanced_area_size;	/* Units: KB */
 	unsigned int		boot_size;		/* in bytes */
+	unsigned int		gp1_size;		/* in bytes */
+	unsigned int		gp2_size;		/* in bytes */
+	unsigned int		gp3_size;		/* in bytes */
+	unsigned int		gp4_size;		/* in bytes */
 	u8			raw_partition_support;	/* 160 */
 	u8			raw_erased_mem_count;	/* 181 */
 	u8			raw_ext_csd_structure;	/* 194 */
include/linux/mmc/mmc.h +4 -0
index 5a794cb..380720a 100644
@@ -303,6 +303,10 @@ struct _mmc_csd {
 #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_PART_CONFIG_ACC_GP1	(0x4)
+#define EXT_CSD_PART_CONFIG_ACC_GP2	(0x5)
+#define EXT_CSD_PART_CONFIG_ACC_GP3	(0x6)
+#define EXT_CSD_PART_CONFIG_ACC_GP4	(0x7)
 
 #define EXT_CSD_CMD_SET_NORMAL		(1<<0)
 #define EXT_CSD_CMD_SET_SECURE		(1<<1)
Signature · 1 line
1.7.4.4
#1 lore raw
Quoted 26 lines · Namjae Jeon

It allows general purpose parition in MMC Device. If it is enable, it will make mmcblk0gp1,gp2,gp3,gp4 partition like this.

Quoted 1 line

cat /proc/paritition

       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
---
  drivers/mmc/card/block.c |   36 ++++++++++++++++++++++++++++++++++++
  drivers/mmc/core/mmc.c   |   42 ++++++++++++++++++++++++++++++++++++++++++
  include/linux/mmc/card.h |    4 ++++
  include/linux/mmc/mmc.h  |    4 ++++
  4 files changed, 86 insertions(+), 0 deletions(-)
drivers/mmc/card/block.c +0 -0
index 9b90726..074ec55 100644
@@ -1402,6 +1402,42 @@ static int mmc_blk_alloc_parts(struct mmc_card *card, struct mmc_blk_data *md)
  			return ret;
  	}

drivers/mmc/card/block.c static int mmc_blk_alloc_parts(struct mmc_card *card, struct mmc_blk_data *md) · line 1413

Quoted 10 lines
drivers/mmc/card/block.c +9 -0
 
+	if (card->ext_csd.gp1_size) {
+		ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP1,
+					card->ext_csd.gp1_size>>  9,
+					false,
+					"gp1");
+		if (ret)
+			return ret;
+	}
+

if mmc_blk_alloc_part() fails for 'if (card->ext_csd.pt1_size)', why would you want to give this code the opportunity to call mmc_blk_alloc_part() again with the next if() below? If mmc_blk_alloc_part() fails, is it a big problem, like kzalloc() failing?
If so, I would think you would want to immediately quit this function
and report an error (either use errno value or pass the value of ret).

Quoted 113 lines
drivers/mmc/card/block.c +27 -0
+	if (card->ext_csd.gp2_size) {
+		ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP2,
+					card->ext_csd.gp2_size>>  9,
+					false,
+					"gp2");
+		if (ret)
+			return ret;
+	}
+
+	if (card->ext_csd.gp3_size) {
+		ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP3,
+					card->ext_csd.gp3_size>>  9,
+					false,
+					"gp3");
+		if (ret)
+			return ret;
+	}
+
+	if (card->ext_csd.gp4_size) {
+		ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP4,
+					card->ext_csd.gp4_size>>  9,
+					false,
+					"gp4");
+		if (ret)
+			return ret;
+	}
+
  	return ret;
  }
 
drivers/mmc/core/mmc.c +42 -0
index 10f5a19..cc31511 100644
@@ -393,6 +393,48 @@ 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;
  		}
+
+		/*
+		 * General purpose partition Support
+		 */
+
+		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;
+
+			card->ext_csd.gp1_size =
+				(ext_csd[145]<<  16) + (ext_csd[144]<<  8) +
+				ext_csd[143];
+			card->ext_csd.gp1_size *=
+				(size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+			card->ext_csd.gp1_size<<= 19;
+
+			card->ext_csd.gp2_size =
+				(ext_csd[148]<<  16) + (ext_csd[147]<<  8) +
+				ext_csd[146];
+			card->ext_csd.gp2_size *=
+				(size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+				card->ext_csd.gp2_size<<= 19;
+
+			card->ext_csd.gp3_size =
+				(ext_csd[151]<<  16) + (ext_csd[150]<<  8) +
+				ext_csd[149];
+			card->ext_csd.gp3_size *=
+				(size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+			card->ext_csd.gp3_size<<= 19;
+
+			card->ext_csd.gp4_size =
+				(ext_csd[154]<<  16) + (ext_csd[153]<<  8) +
+				ext_csd[152];
+			card->ext_csd.gp4_size *=
+				(size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+			card->ext_csd.gp4_size<<= 19;
+		}
  		card->ext_csd.sec_trim_mult =
  			ext_csd[EXT_CSD_SEC_TRIM_MULT];
  		card->ext_csd.sec_erase_mult =
include/linux/mmc/card.h +4 -0
index b460fc2..96a98a7 100644
@@ -64,6 +64,10 @@ struct mmc_ext_csd {
  	unsigned long long	enhanced_area_offset;	/* Units: Byte */
  	unsigned int		enhanced_area_size;	/* Units: KB */
  	unsigned int		boot_size;		/* in bytes */
+	unsigned int		gp1_size;		/* in bytes */
+	unsigned int		gp2_size;		/* in bytes */
+	unsigned int		gp3_size;		/* in bytes */
+	unsigned int		gp4_size;		/* in bytes */
  	u8			raw_partition_support;	/* 160 */
  	u8			raw_erased_mem_count;	/* 181 */
  	u8			raw_ext_csd_structure;	/* 194 */
include/linux/mmc/mmc.h +4 -0
index 5a794cb..380720a 100644
@@ -303,6 +303,10 @@ struct _mmc_csd {
  #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_PART_CONFIG_ACC_GP1	(0x4)
+#define EXT_CSD_PART_CONFIG_ACC_GP2	(0x5)
+#define EXT_CSD_PART_CONFIG_ACC_GP3	(0x6)
+#define EXT_CSD_PART_CONFIG_ACC_GP4	(0x7)
 
  #define EXT_CSD_CMD_SET_NORMAL		(1<<0)
  #define EXT_CSD_CMD_SET_SECURE		(1<<1)
Signature · 3 lines
J (James/Jay) Freyensee
Storage Technology Group
Intel Corporation
#2 lore raw

2011/9/23 J Freyensee <[email protected]>:

Quoted 42 lines · Namjae Jeon
Quoted 41 lines

It allows general purpose parition in MMC Device. If it is enable, it will make mmcblk0gp1,gp2,gp3,gp4 partition like this.

Quoted 1 line

cat /proc/paritition

      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

---
 drivers/mmc/card/block.c |   36 ++++++++++++++++++++++++++++++++++++ drivers/mmc/core/mmc.c   |   42
++++++++++++++++++++++++++++++++++++++++++
 include/linux/mmc/card.h |    4 ++++ include/linux/mmc/mmc.h  |    4 ++++

 4 files changed, 86 insertions(+), 0 deletions(-)
drivers/mmc/card/block.c +8 -0
index 9b90726..074ec55 100644
@@ -1402,6 +1402,42 @@ static int mmc_blk_alloc_parts(struct mmc_card
 *card, struct mmc_blk_data *md)
                        return ret;
        }
 
+       if (card->ext_csd.gp1_size) {
+               ret = mmc_blk_alloc_part(card, md,
 EXT_CSD_PART_CONFIG_ACC_GP1,
+                                       card->ext_csd.gp1_size>>  9,
+                                       false,
+                                       "gp1");
+               if (ret)
+                       return ret;
+       }
Quoted 8 lines

drivers/mmc/card/block.c static int mmc_blk_alloc_parts(struct mmc_card · line 1415

Quoted 1 line
drivers/mmc/card/block.c +1 -0
+

if mmc_blk_alloc_part() fails for 'if (card->ext_csd.pt1_size)', why would you want to give this code the opportunity to call mmc_blk_alloc_part() again with the next if() below?  If mmc_blk_alloc_part() fails, is it a big problem, like kzalloc() failing?  If so, I would think you would want to immediately quit this function and report an error (either use errno value or pass the value of ret).

-> if card->ext_csd.gp1_size is no zero, it means general purpose partition is enable.
and it can set up to 4 partition in specification. so we should check it by next if().

Quoted 129 lines
Quoted 112 lines
drivers/mmc/card/block.c +11 -0
+       if (card->ext_csd.gp2_size) {
+               ret = mmc_blk_alloc_part(card, md,
 EXT_CSD_PART_CONFIG_ACC_GP2,
+                                       card->ext_csd.gp2_size>>  9,
+                                       false,
+                                       "gp2");
+               if (ret)
+                       return ret;
+       }
+
+       if (card->ext_csd.gp3_size) {
+               ret = mmc_blk_alloc_part(card, md,

EXT_CSD_PART_CONFIG_ACC_GP3,
+                                       card->ext_csd.gp3_size>>  9,
+                                       false,
+                                       "gp3");
+               if (ret)
+                       return ret;
+       }
+
+       if (card->ext_csd.gp4_size) {
+               ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP4,
+                                       card->ext_csd.gp4_size>>  9,
+                                       false,
+                                       "gp4");
+               if (ret)
+                       return ret;
+       }
+
       return ret;
 }

drivers/mmc/core/mmc.c +46 -0
index 10f5a19..cc31511 100644
@@ -393,6 +393,48 @@ 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;
                }
+
+               /*
+                * General purpose partition Support
+                */
+
+               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;
+
+                       card->ext_csd.gp1_size =
+                               (ext_csd[145]<<  16) + (ext_csd[144]<<  8)
+
+                               ext_csd[143];
+                       card->ext_csd.gp1_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp1_size<<= 19;
+
+                       card->ext_csd.gp2_size =
+                               (ext_csd[148]<<  16) + (ext_csd[147]<<  8)
+
+                               ext_csd[146];
+                       card->ext_csd.gp2_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                               card->ext_csd.gp2_size<<= 19;
+
+                       card->ext_csd.gp3_size =
+                               (ext_csd[151]<<  16) + (ext_csd[150]<<  8)
+
+                               ext_csd[149];
+                       card->ext_csd.gp3_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp3_size<<= 19;
+
+                       card->ext_csd.gp4_size =
+                               (ext_csd[154]<<  16) + (ext_csd[153]<<  8)
+
+                               ext_csd[152];
+                       card->ext_csd.gp4_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp4_size<<= 19;
+               }

               card->ext_csd.sec_trim_mult = ext_csd[EXT_CSD_SEC_TRIM_MULT]; card->ext_csd.sec_erase_mult =

include/linux/mmc/card.h +0 -0
index b460fc2..96a98a7 100644
@@ -64,6 +64,10 @@ struct mmc_ext_csd {

       unsigned long long      enhanced_area_offset;   /* Units: Byte */ unsigned int            enhanced_area_size;     /* Units: KB */ unsigned int            boot_size;              /* in bytes */
+       unsigned int            gp1_size;               /* in bytes */
+       unsigned int            gp2_size;               /* in bytes */
+       unsigned int            gp3_size;               /* in bytes */
+       unsigned int            gp4_size;               /* in bytes */ u8                      raw_partition_support;  /* 160 */ u8                      raw_erased_mem_count;   /* 181 */ u8                      raw_ext_csd_structure;  /* 194 */

include/linux/mmc/mmc.h +0 -0
index 5a794cb..380720a 100644

include/linux/mmc/mmc.h struct _mmc_csd { · line 312

Quoted 10 lines
include/linux/mmc/mmc.h +4 -0
@@ -303,6 +303,10 @@ struct _mmc_csd {
  #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_PART_CONFIG_ACC_GP1    (0x4)
+#define EXT_CSD_PART_CONFIG_ACC_GP2    (0x5)
+#define EXT_CSD_PART_CONFIG_ACC_GP3    (0x6)
+#define EXT_CSD_PART_CONFIG_ACC_GP4    (0x7)
 
  #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

#3 lore raw
Quoted 51 lines · NamJae Jeon

2011/9/23 J Freyensee<[email protected]>:

Quoted 42 lines · Namjae Jeon
Quoted 41 lines

It allows general purpose parition in MMC Device. If it is enable, it will make mmcblk0gp1,gp2,gp3,gp4 partition like this.

Quoted 1 line

cat /proc/paritition

       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
---
  drivers/mmc/card/block.c |   36 ++++++++++++++++++++++++++++++++++++
  drivers/mmc/core/mmc.c   |   42
++++++++++++++++++++++++++++++++++++++++++
  include/linux/mmc/card.h |    4 ++++
  include/linux/mmc/mmc.h  |    4 ++++
  4 files changed, 86 insertions(+), 0 deletions(-)
drivers/mmc/card/block.c +8 -0
index 9b90726..074ec55 100644
@@ -1402,6 +1402,42 @@ static int mmc_blk_alloc_parts(struct mmc_card
 *card, struct mmc_blk_data *md)
                        return ret;
        }
 
+       if (card->ext_csd.gp1_size) {
+               ret = mmc_blk_alloc_part(card, md,
 EXT_CSD_PART_CONFIG_ACC_GP1,
+                                       card->ext_csd.gp1_size>>    9,
+                                       false,
+                                       "gp1");
+               if (ret)
+                       return ret;
+       }
Quoted 8 lines

drivers/mmc/card/block.c static int mmc_blk_alloc_parts(struct mmc_card · line 1415

Quoted 1 line
drivers/mmc/card/block.c +1 -0
+

if mmc_blk_alloc_part() fails for 'if (card->ext_csd.pt1_size)', why would you want to give this code the opportunity to call mmc_blk_alloc_part() again with the next if() below? If mmc_blk_alloc_part() fails, is it a big problem, like kzalloc() failing? If so, I would think you would want to immediately quit this function and report an error (either use errno value or pass the value of ret).

Quoted 4 lines

-> if card->ext_csd.gp1_size is no zero, it means general purpose partition is enable.
and it can set up to 4 partition in specification. so we should check it by next if().

Please document that in your code. Please add a function header to this function.

Quoted 130 lines
Quoted 130 lines
Quoted 113 lines
drivers/mmc/card/block.c +11 -0
+       if (card->ext_csd.gp2_size) {
+               ret = mmc_blk_alloc_part(card, md,
 EXT_CSD_PART_CONFIG_ACC_GP2,
+                                       card->ext_csd.gp2_size>>    9,
+                                       false,
+                                       "gp2");
+               if (ret)
+                       return ret;
+       }
+
+       if (card->ext_csd.gp3_size) {
+               ret = mmc_blk_alloc_part(card, md,

EXT_CSD_PART_CONFIG_ACC_GP3,

drivers/mmc/card/block.c +9 -0
+                                       card->ext_csd.gp3_size>>    9,
+                                       false,
+                                       "gp3");
+               if (ret)
+                       return ret;
+       }
+
+       if (card->ext_csd.gp4_size) {
+               ret = mmc_blk_alloc_part(card, md,

EXT_CSD_PART_CONFIG_ACC_GP4,

drivers/mmc/card/block.c +7 -0
+                                       card->ext_csd.gp4_size>>    9,
+                                       false,
+                                       "gp4");
+               if (ret)
+                       return ret;
+       }
+
        return ret;
  }
drivers/mmc/core/mmc.c +46 -0
index 10f5a19..cc31511 100644
@@ -393,6 +393,48 @@ 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;
                }
+
+               /*
+                * General purpose partition Support
+                */
+
+               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;
+
+                       card->ext_csd.gp1_size =
+                               (ext_csd[145]<<    16) + (ext_csd[144]<<    8)
+
+                               ext_csd[143];
+                       card->ext_csd.gp1_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp1_size<<= 19;
+
+                       card->ext_csd.gp2_size =
+                               (ext_csd[148]<<    16) + (ext_csd[147]<<    8)
+
+                               ext_csd[146];
+                       card->ext_csd.gp2_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                               card->ext_csd.gp2_size<<= 19;
+
+                       card->ext_csd.gp3_size =
+                               (ext_csd[151]<<    16) + (ext_csd[150]<<    8)
+
+                               ext_csd[149];
+                       card->ext_csd.gp3_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp3_size<<= 19;
+
+                       card->ext_csd.gp4_size =
+                               (ext_csd[154]<<    16) + (ext_csd[153]<<    8)
+
+                               ext_csd[152];
+                       card->ext_csd.gp4_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp4_size<<= 19;
+               }
                card->ext_csd.sec_trim_mult =
                        ext_csd[EXT_CSD_SEC_TRIM_MULT];
                card->ext_csd.sec_erase_mult =
include/linux/mmc/card.h +4 -0
index b460fc2..96a98a7 100644
@@ -64,6 +64,10 @@ struct mmc_ext_csd {
        unsigned long long      enhanced_area_offset;   /* Units: Byte */
        unsigned int            enhanced_area_size;     /* Units: KB */
        unsigned int            boot_size;              /* in bytes */
+       unsigned int            gp1_size;               /* in bytes */
+       unsigned int            gp2_size;               /* in bytes */
+       unsigned int            gp3_size;               /* in bytes */
+       unsigned int            gp4_size;               /* in bytes */
        u8                      raw_partition_support;  /* 160 */
        u8                      raw_erased_mem_count;   /* 181 */
        u8                      raw_ext_csd_structure;  /* 194 */
include/linux/mmc/mmc.h +0 -0
index 5a794cb..380720a 100644

include/linux/mmc/mmc.h struct _mmc_csd { · line 312

Quoted 10 lines
include/linux/mmc/mmc.h +4 -0
@@ -303,6 +303,10 @@ struct _mmc_csd {
  #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_PART_CONFIG_ACC_GP1    (0x4)
+#define EXT_CSD_PART_CONFIG_ACC_GP2    (0x5)
+#define EXT_CSD_PART_CONFIG_ACC_GP3    (0x6)
+#define EXT_CSD_PART_CONFIG_ACC_GP4    (0x7)
 
  #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

Signature · 3 lines
J (James/Jay) Freyensee
Storage Technology Group
Intel Corporation
#4 lore raw

2011/9/23 J Freyensee <[email protected]>:

Quoted 59 lines · NamJae Jeon
Quoted 58 lines

2011/9/23 J Freyensee<[email protected]>:

Quoted 55 lines · Namjae Jeon
Quoted 33 lines

It allows general purpose parition in MMC Device. If it is enable, it will
make mmcblk0gp1,gp2,gp3,gp4 partition like this.

Quoted 1 line

cat /proc/paritition

      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

---
 drivers/mmc/card/block.c |   36 ++++++++++++++++++++++++++++++++++++ drivers/mmc/core/mmc.c   |   42
++++++++++++++++++++++++++++++++++++++++++
 include/linux/mmc/card.h |    4 ++++ include/linux/mmc/mmc.h  |    4 ++++

 4 files changed, 86 insertions(+), 0 deletions(-)
drivers/mmc/card/block.c +0 -0
index 9b90726..074ec55 100644
@@ -1402,6 +1402,42 @@ static int mmc_blk_alloc_parts(struct mmc_card
 *card, struct mmc_blk_data *md)
                        return ret;
        }
 

drivers/mmc/card/block.c static int mmc_blk_alloc_parts(struct mmc_card · line 1415

Quoted 10 lines
drivers/mmc/card/block.c +9 -0
+       if (card->ext_csd.gp1_size) {
+               ret = mmc_blk_alloc_part(card, md,
 EXT_CSD_PART_CONFIG_ACC_GP1,
+                                       card->ext_csd.gp1_size>>    9,
+                                       false,
+                                       "gp1");
+               if (ret)
+                       return ret;
+       }
+

if mmc_blk_alloc_part() fails for 'if (card->ext_csd.pt1_size)', why would
you want to give this code the opportunity to call mmc_blk_alloc_part() again with the next if() below?  If mmc_blk_alloc_part() fails, is it a big
problem, like kzalloc() failing?  If so, I would think you would want to immediately quit this function and report an error (either use errno value
or pass the value of ret).

Quoted 7 lines
Quoted 4 lines

->  if card->ext_csd.gp1_size is no zero, it means general purpose partition is enable.
and it can set up to 4 partition in specification. so we should check it by next if().

Please document that in your code.  Please add a function header to this function.

I will add comments at this code. I don't understand why a function header should be added yet.

Quoted 147 lines
Quoted 131 lines
Quoted 131 lines
Quoted 131 lines
drivers/mmc/card/block.c +11 -0
+       if (card->ext_csd.gp2_size) {
+               ret = mmc_blk_alloc_part(card, md,
 EXT_CSD_PART_CONFIG_ACC_GP2,
+                                       card->ext_csd.gp2_size>>    9,
+                                       false,
+                                       "gp2");
+               if (ret)
+                       return ret;
+       }
+
+       if (card->ext_csd.gp3_size) {
+               ret = mmc_blk_alloc_part(card, md,

EXT_CSD_PART_CONFIG_ACC_GP3,
+                                       card->ext_csd.gp3_size>>    9,
+                                       false,
+                                       "gp3");
+               if (ret)
+                       return ret;
+       }
+
+       if (card->ext_csd.gp4_size) {
+               ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP4,
+                                       card->ext_csd.gp4_size>>    9,
+                                       false,
+                                       "gp4");
+               if (ret)
+                       return ret;
+       }
+
       return ret;
 }

drivers/mmc/core/mmc.c +0 -0
index 10f5a19..cc31511 100644
@@ -393,6 +393,48 @@ 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; }

drivers/mmc/core/mmc.c +16 -0
+
+               /*
+                * General purpose partition Support
+                */
+
+               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;
+
+                       card->ext_csd.gp1_size =
+                               (ext_csd[145]<<    16) + (ext_csd[144]<<

   8)
+
+                               ext_csd[143];
+                       card->ext_csd.gp1_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp1_size<<= 19;
+
+                       card->ext_csd.gp2_size =
+                               (ext_csd[148]<<    16) + (ext_csd[147]<<
   8)
+
+                               ext_csd[146];
+                       card->ext_csd.gp2_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                               card->ext_csd.gp2_size<<= 19; +
+                       card->ext_csd.gp3_size =
+                               (ext_csd[151]<<    16) + (ext_csd[150]<<
   8)
+
+                               ext_csd[149];
+                       card->ext_csd.gp3_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp3_size<<= 19;
+
+                       card->ext_csd.gp4_size =
+                               (ext_csd[154]<<    16) + (ext_csd[153]<<
   8)
+
+                               ext_csd[152];
+                       card->ext_csd.gp4_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp4_size<<= 19;
+               }
               card->ext_csd.sec_trim_mult = ext_csd[EXT_CSD_SEC_TRIM_MULT]; card->ext_csd.sec_erase_mult =

include/linux/mmc/card.h +0 -0
index b460fc2..96a98a7 100644
@@ -64,6 +64,10 @@ struct mmc_ext_csd {

       unsigned long long      enhanced_area_offset;   /* Units: Byte */ unsigned int            enhanced_area_size;     /* Units: KB */ unsigned int            boot_size;              /* in bytes */
+       unsigned int            gp1_size;               /* in bytes */
+       unsigned int            gp2_size;               /* in bytes */
+       unsigned int            gp3_size;               /* in bytes */
+       unsigned int            gp4_size;               /* in bytes */ u8                      raw_partition_support;  /* 160 */ u8                      raw_erased_mem_count;   /* 181 */ u8                      raw_ext_csd_structure;  /* 194 */

include/linux/mmc/mmc.h +4 -0
index 5a794cb..380720a 100644
@@ -303,6 +303,10 @@ struct _mmc_csd {
  #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_PART_CONFIG_ACC_GP1    (0x4)
+#define EXT_CSD_PART_CONFIG_ACC_GP2    (0x5)
+#define EXT_CSD_PART_CONFIG_ACC_GP3    (0x6)
+#define EXT_CSD_PART_CONFIG_ACC_GP4    (0x7)
 
Quoted 9 lines
Quoted 9 lines

include/linux/mmc/mmc.h struct _mmc_csd { · line 312

Quoted 2 lines
include/linux/mmc/mmc.h +0 -0
  #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

--
J (James/Jay) Freyensee
Storage Technology Group
Intel Corporation

#5 lore raw
Quoted 65 lines · NamJae Jeon

2011/9/23 J Freyensee<[email protected]>:

Quoted 64 lines · NamJae Jeon
Quoted 62 lines

2011/9/23 J Freyensee<[email protected]>:

Quoted 47 lines · Namjae Jeon
Quoted 33 lines

It allows general purpose parition in MMC Device. If it is enable, it will
make mmcblk0gp1,gp2,gp3,gp4 partition like this.

Quoted 1 line

cat /proc/paritition

       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
---
  drivers/mmc/card/block.c |   36 ++++++++++++++++++++++++++++++++++++
  drivers/mmc/core/mmc.c   |   42
++++++++++++++++++++++++++++++++++++++++++
  include/linux/mmc/card.h |    4 ++++
  include/linux/mmc/mmc.h  |    4 ++++
  4 files changed, 86 insertions(+), 0 deletions(-)
drivers/mmc/card/block.c +0 -0
index 9b90726..074ec55 100644
@@ -1402,6 +1402,42 @@ static int mmc_blk_alloc_parts(struct mmc_card
 *card, struct mmc_blk_data *md)
                        return ret;
        }
 

drivers/mmc/card/block.c static int mmc_blk_alloc_parts(struct mmc_card · line 1415

Quoted 10 lines
drivers/mmc/card/block.c +9 -0
+       if (card->ext_csd.gp1_size) {
+               ret = mmc_blk_alloc_part(card, md,
 EXT_CSD_PART_CONFIG_ACC_GP1,
+                                       card->ext_csd.gp1_size>>      9,
+                                       false,
+                                       "gp1");
+               if (ret)
+                       return ret;
+       }
+

if mmc_blk_alloc_part() fails for 'if (card->ext_csd.pt1_size)', why

Quoted 8 lines

would
you want to give this code the opportunity to call mmc_blk_alloc_part() again with the next if() below? If mmc_blk_alloc_part() fails, is it a big
problem, like kzalloc() failing? If so, I would think you would want to immediately quit this function and report an error (either use errno value
or pass the value of ret).

-> if card->ext_csd.gp1_size is no zero, it means general purpose
partition is enable.
and it can set up to 4 partition in specification. so we should check it by next if().

Quoted 4 lines
Quoted 2 lines

Please document that in your code. Please add a function header to this function.

I will add comments at this code. I don't understand why a function header should be added yet.

One or the other.

but a function comment header should be added at some point. Yes, the mmc subsystem is pretty legacy, but any new work that gets added to the kernel is usually has higher standards for stuff like not just adding function header comments but putting them in a certain format...at least this is what I went through when I had things accepted upstream.

Quoted 148 lines
Quoted 148 lines
Quoted 132 lines
Quoted 132 lines
Quoted 132 lines
drivers/mmc/card/block.c +11 -0
+       if (card->ext_csd.gp2_size) {
+               ret = mmc_blk_alloc_part(card, md,
 EXT_CSD_PART_CONFIG_ACC_GP2,
+                                       card->ext_csd.gp2_size>>      9,
+                                       false,
+                                       "gp2");
+               if (ret)
+                       return ret;
+       }
+
+       if (card->ext_csd.gp3_size) {
+               ret = mmc_blk_alloc_part(card, md,

EXT_CSD_PART_CONFIG_ACC_GP3,

drivers/mmc/card/block.c +9 -0
+                                       card->ext_csd.gp3_size>>      9,
+                                       false,
+                                       "gp3");
+               if (ret)
+                       return ret;
+       }
+
+       if (card->ext_csd.gp4_size) {
+               ret = mmc_blk_alloc_part(card, md,

EXT_CSD_PART_CONFIG_ACC_GP4,

drivers/mmc/card/block.c +7 -0
+                                       card->ext_csd.gp4_size>>      9,
+                                       false,
+                                       "gp4");
+               if (ret)
+                       return ret;
+       }
+
        return ret;
  }
drivers/mmc/core/mmc.c +0 -0
index 10f5a19..cc31511 100644
@@ -393,6 +393,48 @@ 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;
                }
drivers/mmc/core/mmc.c +20 -0
+
+               /*
+                * General purpose partition Support
+                */
+
+               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;
+
+                       card->ext_csd.gp1_size =
+                               (ext_csd[145]<<      16) + (ext_csd[144]<<
    8)
+
+                               ext_csd[143];
+                       card->ext_csd.gp1_size *=
+                               (size_t)(hc_erase_grp_sz *

hc_wp_grp_sz);

drivers/mmc/core/mmc.c +8 -0
+                       card->ext_csd.gp1_size<<= 19;
+
+                       card->ext_csd.gp2_size =
+                               (ext_csd[148]<<      16) + (ext_csd[147]<<
    8)
+
+                               ext_csd[146];
+                       card->ext_csd.gp2_size *=
+                               (size_t)(hc_erase_grp_sz *

hc_wp_grp_sz);

drivers/mmc/core/mmc.c +8 -0
+                               card->ext_csd.gp2_size<<= 19;
+
+                       card->ext_csd.gp3_size =
+                               (ext_csd[151]<<      16) + (ext_csd[150]<<
    8)
+
+                               ext_csd[149];
+                       card->ext_csd.gp3_size *=
+                               (size_t)(hc_erase_grp_sz *

hc_wp_grp_sz);

drivers/mmc/core/mmc.c +8 -0
+                       card->ext_csd.gp3_size<<= 19;
+
+                       card->ext_csd.gp4_size =
+                               (ext_csd[154]<<      16) + (ext_csd[153]<<
    8)
+
+                               ext_csd[152];
+                       card->ext_csd.gp4_size *=
+                               (size_t)(hc_erase_grp_sz *

hc_wp_grp_sz);

drivers/mmc/core/mmc.c +2 -0
+                       card->ext_csd.gp4_size<<= 19;
+               }
                card->ext_csd.sec_trim_mult =
                        ext_csd[EXT_CSD_SEC_TRIM_MULT];
                card->ext_csd.sec_erase_mult =
include/linux/mmc/card.h +4 -0
index b460fc2..96a98a7 100644
@@ -64,6 +64,10 @@ struct mmc_ext_csd {
        unsigned long long      enhanced_area_offset;   /* Units: Byte */
        unsigned int            enhanced_area_size;     /* Units: KB */
        unsigned int            boot_size;              /* in bytes */
+       unsigned int            gp1_size;               /* in bytes */
+       unsigned int            gp2_size;               /* in bytes */
+       unsigned int            gp3_size;               /* in bytes */
+       unsigned int            gp4_size;               /* in bytes */
        u8                      raw_partition_support;  /* 160 */
        u8                      raw_erased_mem_count;   /* 181 */
        u8                      raw_ext_csd_structure;  /* 194 */
include/linux/mmc/mmc.h +4 -0
index 5a794cb..380720a 100644
@@ -303,6 +303,10 @@ struct _mmc_csd {
  #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_PART_CONFIG_ACC_GP1    (0x4)
+#define EXT_CSD_PART_CONFIG_ACC_GP2    (0x5)
+#define EXT_CSD_PART_CONFIG_ACC_GP3    (0x6)
+#define EXT_CSD_PART_CONFIG_ACC_GP4    (0x7)
 
Quoted 9 lines
Quoted 9 lines

include/linux/mmc/mmc.h struct _mmc_csd { · line 312

Quoted 2 lines
include/linux/mmc/mmc.h +0 -0
  #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

--
J (James/Jay) Freyensee
Storage Technology Group
Intel Corporation

Signature · 3 lines
J (James/Jay) Freyensee
Storage Technology Group
Intel Corporation
#6 lore raw

2011/9/23 J Freyensee <[email protected]>

Quoted 72 lines · NamJae Jeon
Quoted 70 lines

2011/9/23 J Freyensee<[email protected]>:

Quoted 67 lines · NamJae Jeon
Quoted 58 lines

2011/9/23 J Freyensee<[email protected]>:

Quoted 47 lines · Namjae Jeon
Quoted 33 lines

It allows general purpose parition in MMC Device. If it is enable, it will
make mmcblk0gp1,gp2,gp3,gp4 partition like this.

Quoted 1 line

cat /proc/paritition

      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

---
 drivers/mmc/card/block.c |   36 ++++++++++++++++++++++++++++++++++++ drivers/mmc/core/mmc.c   |   42
++++++++++++++++++++++++++++++++++++++++++
 include/linux/mmc/card.h |    4 ++++ include/linux/mmc/mmc.h  |    4 ++++

 4 files changed, 86 insertions(+), 0 deletions(-)
drivers/mmc/card/block.c +0 -0
index 9b90726..074ec55 100644
@@ -1402,6 +1402,42 @@ static int mmc_blk_alloc_parts(struct mmc_card
 *card, struct mmc_blk_data *md)
                        return ret;
        }
 

drivers/mmc/card/block.c static int mmc_blk_alloc_parts(struct mmc_card · line 1415

Quoted 10 lines
drivers/mmc/card/block.c +9 -0
+       if (card->ext_csd.gp1_size) {
+               ret = mmc_blk_alloc_part(card, md,
 EXT_CSD_PART_CONFIG_ACC_GP1,
+                                       card->ext_csd.gp1_size>>      9,
+                                       false,
+                                       "gp1");
+               if (ret)
+                       return ret;
+       }
+

if mmc_blk_alloc_part() fails for 'if (card->ext_csd.pt1_size)', why

Quoted 8 lines

would
you want to give this code the opportunity to call mmc_blk_alloc_part() again with the next if() below?  If mmc_blk_alloc_part() fails, is it a big
problem, like kzalloc() failing?  If so, I would think you would want to immediately quit this function and report an error (either use errno value
or pass the value of ret).

Quoted 4 lines

->    if card->ext_csd.gp1_size is no zero, it means general purpose partition is enable.
and it can set up to 4 partition in specification. so we should check it by next if().

Please document that in your code.  Please add a function header to this function.

Quoted 6 lines
Quoted 2 lines

I will add comments at this code.  I don't understand why a function header should be added yet.

One or the other.

but a function comment header should be added at some point.  Yes, the mmc subsystem is pretty legacy, but any new work that gets added to the kernel is usually has higher standards for stuff like not just adding function header comments but putting them in a certain format...at least this is what I went through when I had things accepted upstream.

Okay, I will release patch v2 after adding function header comments again. Thanks for your review.

Quoted 155 lines
Quoted 144 lines
Quoted 144 lines
Quoted 142 lines
Quoted 142 lines
Quoted 125 lines
drivers/mmc/card/block.c +11 -0
+       if (card->ext_csd.gp2_size) {
+               ret = mmc_blk_alloc_part(card, md,
 EXT_CSD_PART_CONFIG_ACC_GP2,
+                                       card->ext_csd.gp2_size>>      9,
+                                       false,
+                                       "gp2");
+               if (ret)
+                       return ret;
+       }
+
+       if (card->ext_csd.gp3_size) {
+               ret = mmc_blk_alloc_part(card, md,

EXT_CSD_PART_CONFIG_ACC_GP3,
+                                       card->ext_csd.gp3_size>>      9,
+                                       false,
+                                       "gp3");
+               if (ret)
+                       return ret;
+       }
+
+       if (card->ext_csd.gp4_size) {
+               ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP4,
+                                       card->ext_csd.gp4_size>>      9,
+                                       false,
+                                       "gp4");
+               if (ret)
+                       return ret;
+       }
+
       return ret;
 }

drivers/mmc/core/mmc.c +0 -0
index 10f5a19..cc31511 100644
@@ -393,6 +393,48 @@ 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; }

drivers/mmc/core/mmc.c +16 -0
+
+               /*
+                * General purpose partition Support
+                */
+
+               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;
+
+                       card->ext_csd.gp1_size =
+                               (ext_csd[145]<<      16) + (ext_csd[144]<<

   8)
+
+                               ext_csd[143];
+                       card->ext_csd.gp1_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp1_size<<= 19;
+
+                       card->ext_csd.gp2_size =
+                               (ext_csd[148]<<      16) + (ext_csd[147]<<
   8)
+
+                               ext_csd[146];
+                       card->ext_csd.gp2_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                               card->ext_csd.gp2_size<<= 19; +
+                       card->ext_csd.gp3_size =
+                               (ext_csd[151]<<      16) + (ext_csd[150]<<
   8)
+
+                               ext_csd[149];
+                       card->ext_csd.gp3_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp3_size<<= 19;
+
+                       card->ext_csd.gp4_size =
+                               (ext_csd[154]<<      16) + (ext_csd[153]<<
   8)
+
+                               ext_csd[152];
+                       card->ext_csd.gp4_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp4_size<<= 19;
+               }
               card->ext_csd.sec_trim_mult = ext_csd[EXT_CSD_SEC_TRIM_MULT]; card->ext_csd.sec_erase_mult =

include/linux/mmc/card.h +0 -0
index b460fc2..96a98a7 100644
@@ -64,6 +64,10 @@ struct mmc_ext_csd {

       unsigned long long      enhanced_area_offset;   /* Units: Byte */ unsigned int            enhanced_area_size;     /* Units: KB */ unsigned int            boot_size;              /* in bytes */
+       unsigned int            gp1_size;               /* in bytes */
+       unsigned int            gp2_size;               /* in bytes */
+       unsigned int            gp3_size;               /* in bytes */
+       unsigned int            gp4_size;               /* in bytes */ u8                      raw_partition_support;  /* 160 */ u8                      raw_erased_mem_count;   /* 181 */ u8                      raw_ext_csd_structure;  /* 194 */

include/linux/mmc/mmc.h +0 -0
index 5a794cb..380720a 100644

include/linux/mmc/mmc.h struct _mmc_csd { · line 312

Quoted 10 lines
include/linux/mmc/mmc.h +4 -0
@@ -303,6 +303,10 @@ struct _mmc_csd {
  #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_PART_CONFIG_ACC_GP1    (0x4)
+#define EXT_CSD_PART_CONFIG_ACC_GP2    (0x5)
+#define EXT_CSD_PART_CONFIG_ACC_GP3    (0x6)
+#define EXT_CSD_PART_CONFIG_ACC_GP4    (0x7)
 
  #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

Quoted 5 lines
Quoted 5 lines

--
J (James/Jay) Freyensee
Storage Technology Group
Intel Corporation

--
J (James/Jay) Freyensee
Storage Technology Group
Intel Corporation

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

2011/9/24 J Freyensee <[email protected]>:

Quoted 55 lines · NamJae Jeon
Quoted 48 lines

2011/9/23 J Freyensee<[email protected]>

Quoted 46 lines · NamJae Jeon
Quoted 44 lines

2011/9/23 J Freyensee<[email protected]>:

Quoted 42 lines · NamJae Jeon
Quoted 40 lines

2011/9/23 J Freyensee<[email protected]>:

Quoted 38 lines · Namjae Jeon
Quoted 36 lines

It allows general purpose parition in MMC Device. If it is enable, it
will
make mmcblk0gp1,gp2,gp3,gp4 partition like this.

Quoted 1 line

cat /proc/paritition

      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

---
 drivers/mmc/card/block.c |   36
++++++++++++++++++++++++++++++++++++
 drivers/mmc/core/mmc.c   |   42
++++++++++++++++++++++++++++++++++++++++++
 include/linux/mmc/card.h |    4 ++++
 include/linux/mmc/mmc.h  |    4 ++++

 4 files changed, 86 insertions(+), 0 deletions(-)
drivers/mmc/card/block.c +0 -0
index 9b90726..074ec55 100644
@@ -1402,6 +1402,42 @@ static int mmc_blk_alloc_parts(struct

mmc_card
*card, struct mmc_blk_data *md)
                       return ret;
       }

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+       if (card->ext_csd.gp1_size) {

Looks like you may need to also incorporate the ideas Adrian Hunter did in a patch that seems similar to yours, mainly also checking mmc_boot_partition_access(card->host) in your if() statement?

Quoted 3 lines

I attached his patch that was sent today.

Jay

I checked attached patch, see the patch v2. I think that adrian may modify his patch base on my patch.
Thanks

Quoted 228 lines
Quoted 214 lines
Quoted 37 lines
Quoted 30 lines
Quoted 30 lines
Quoted 29 lines
Quoted 12 lines
Quoted 11 lines

+               ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP1,
+                                       card->ext_csd.gp1_size>> 9,
+                                       false,
+                                       "gp1");
+               if (ret)
+                       return ret;
+       }
+

Quoted 12 lines

if mmc_blk_alloc_part() fails for 'if (card->ext_csd.pt1_size)', why would
you want to give this code the opportunity to call mmc_blk_alloc_part()
again with the next if() below?  If mmc_blk_alloc_part() fails, is it a
big
problem, like kzalloc() failing?  If so, I would think you would want to
immediately quit this function and report an error (either use errno value
or pass the value of ret).

->      if card->ext_csd.gp1_size is no zero, it means general purpose partition is enable.
and it can set up to 4 partition in specification. so we should check it by next if().

Quoted 6 lines
Quoted 3 lines

Please document that in your code.  Please add a function header to this
function.

I will add comments at this code.  I don't understand why a function header should be added yet.

Quoted 7 lines

One or the other.

but a function comment header should be added at some point.  Yes, the mmc subsystem is pretty legacy, but any new work that gets added to the kernel is usually has higher standards for stuff like not just adding function header comments but putting them in a certain format...at least this is what I went through when I had things accepted upstream.

Okay, I will release patch v2 after adding function header comments again. Thanks for your review.

Quoted 167 lines
Quoted 165 lines
Quoted 165 lines
Quoted 149 lines
Quoted 149 lines
Quoted 149 lines

+       if (card->ext_csd.gp2_size) {
+               ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP2,
+                                       card->ext_csd.gp2_size>> 9,
+                                       false,
+                                       "gp2");
+               if (ret)
+                       return ret;
+       }
+
+       if (card->ext_csd.gp3_size) {
+               ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP3,
+                                       card->ext_csd.gp3_size>> 9,
+                                       false,
+                                       "gp3");
+               if (ret)
+                       return ret;
+       }
+
+       if (card->ext_csd.gp4_size) {
+               ret = mmc_blk_alloc_part(card, md, EXT_CSD_PART_CONFIG_ACC_GP4,
+                                       card->ext_csd.gp4_size>> 9,
+                                       false,
+                                       "gp4");
+               if (ret)
+                       return ret;
+       }
+
       return ret;
 }

drivers/mmc/core/mmc.c +0 -0
index 10f5a19..cc31511 100644
@@ -393,6 +393,48 @@ 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; }

drivers/mmc/core/mmc.c +6 -0
+
+               /*
+                * General purpose partition Support
+                */
+
+               if (ext_csd[EXT_CSD_PARTITION_SUPPORT]&        0x1)

{

drivers/mmc/core/mmc.c +10 -0
+
+                       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;
+
+                       card->ext_csd.gp1_size =
+                               (ext_csd[145]<<        16) +

(ext_csd[144]<<
   8)
+
+                               ext_csd[143];
+                       card->ext_csd.gp1_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp1_size<<= 19; +
+                       card->ext_csd.gp2_size =
+                               (ext_csd[148]<<        16) + (ext_csd[147]<<
   8)
+
+                               ext_csd[146];
+                       card->ext_csd.gp2_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                               card->ext_csd.gp2_size<<= 19; +
+                       card->ext_csd.gp3_size =
+                               (ext_csd[151]<<        16) + (ext_csd[150]<<
   8)
+
+                               ext_csd[149];
+                       card->ext_csd.gp3_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp3_size<<= 19; +
+                       card->ext_csd.gp4_size =
+                               (ext_csd[154]<<        16) + (ext_csd[153]<<
   8)
+
+                               ext_csd[152];
+                       card->ext_csd.gp4_size *=
+                               (size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
+                       card->ext_csd.gp4_size<<= 19;
+               }
               card->ext_csd.sec_trim_mult = ext_csd[EXT_CSD_SEC_TRIM_MULT]; card->ext_csd.sec_erase_mult =

include/linux/mmc/card.h +0 -0
index b460fc2..96a98a7 100644
@@ -64,6 +64,10 @@ struct mmc_ext_csd {

       unsigned long long      enhanced_area_offset;   /* Units:
Byte */
       unsigned int            enhanced_area_size;     /* Units: KB */
       unsigned int            boot_size;              /* in bytes */
+       unsigned int            gp1_size;               /* in bytes */
+       unsigned int            gp2_size;               /* in bytes */
+       unsigned int            gp3_size;               /* in bytes */
+       unsigned int            gp4_size;               /* in bytes */
       u8                      raw_partition_support;  /* 160 */ u8                      raw_erased_mem_count;   /* 181 */ u8                      raw_ext_csd_structure;  /* 194 */

include/linux/mmc/mmc.h +4 -0
index 5a794cb..380720a 100644
@@ -303,6 +303,10 @@ struct _mmc_csd {
  #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_PART_CONFIG_ACC_GP1    (0x4)
+#define EXT_CSD_PART_CONFIG_ACC_GP2    (0x5)
+#define EXT_CSD_PART_CONFIG_ACC_GP3    (0x6)
+#define EXT_CSD_PART_CONFIG_ACC_GP4    (0x7)
 
Quoted 9 lines
Quoted 9 lines

include/linux/mmc/mmc.h struct _mmc_csd { · line 312

Quoted 2 lines
include/linux/mmc/mmc.h +0 -0
  #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

--
J (James/Jay) Freyensee
Storage Technology Group
Intel Corporation

Quoted 7 lines
Quoted 4 lines

--
J (James/Jay) Freyensee
Storage Technology Group
Intel Corporation

N�����r��y���b�X��ǧv�^�)޺{.n�+����{��g"��^n�r��z� ��h����&�� �G���h� (�階�ݢj"�� � m�����z�ޖ���f���h���~�mml==

--
J (James/Jay) Freyensee
Storage Technology Group
Intel Corporation

#9 lore raw
In reply to Namjae Jeon

Hi Namjae,

I scanned over your changes to enable GP partitions, and while I did not yet test your changes, they do appear to be ok.

Please CC me on the next version of your patch so I can give it a spin and Ack on it.

I do suggest at least thinking about ways to improve on this. Back when I added boot partition support, I already didn't like the fact that the block driver had to be aware of the eMMC partitions, with all the code duplication and such. By adding four more partitions, you've compounded the problem and now you have six pieces of code that really look the same.

The core/mmc.c right now scans the size values and stores them
in mmc_card, and the block driver is smart enough to know what
to do with them. Why not make the block code generic at the expense
of keeping an array of structures in mmc_card? The block driver
would then just iterate over these and create the additional devices. The partition switch routine would then operate on these structures, and could then be pulled out of the block driver, making it simpler.

Each physical partition could be described by something like - struct mmc_part {
unsigned int size;
unsigned int cookie; /* for mmc, idx used in mmc_switch, part_type from current mmc_blk_data */
char name[DISK_NAME_LEN];
bool force_ro; /* to make boot parts RO by default */
};

Just an idea. Clearly, if MMC grows by another 4-5 possible partitions, it's not realistic to be copy-pasting the same block of code, nor would it make sense if/when these types of devices support an arbitrary amount of physical partitions.

Thanks,
A

#10 lore raw

2011/9/23 Andrei Warkentin <[email protected]>:

Quoted 31 lines

Hi Namjae,

I scanned over your changes to enable GP partitions, and while I did not yet test your changes, they do appear to be ok.

Please CC me on the next version of your patch so I can give it a spin and Ack on it.

I do suggest at least thinking about ways to improve on this. Back when I added boot partition support, I already didn't like the fact that the block driver had to be aware of the eMMC partitions, with all the code duplication and such. By adding four more partitions, you've compounded the problem and now you have six pieces of code that really look the same.

The core/mmc.c right now scans the size values and stores them
in mmc_card, and the block driver is smart enough to know what
to do with them. Why not make the block code generic at the expense
of keeping an array of structures in mmc_card? The block driver
would then just iterate over these and create the additional devices. The partition switch routine would then operate on these structures, and could then be pulled out of the block driver, making it simpler.

Each physical partition could be described by something like -
struct mmc_part {
   unsigned int size;
   unsigned int cookie;        /* for mmc, idx used in mmc_switch, part_type from current mmc_blk_data */ char name[DISK_NAME_LEN];
   bool force_ro;              /* to make boot parts RO by default */
};

Quoted 7 lines

Just an idea. Clearly, if MMC grows by another 4-5 possible partitions, it's not realistic to be copy-pasting the same block of code, nor would it make sense if/when these types of devices support an arbitrary amount of physical partitions.

Thanks,
A

Okay, I understand what you want. I will try to make patch included your suggestion again.
Thanks for your review.