MMC/eMMC partitioning support.
Subsystems (3)
MMC devices can have boot partitions, as well as a non-replayable
memory block and some general purpose partitions present. As of the moment, these are not accessible from Linux. I'm sending a patch for comments and review to enable the boot partitions.
The MMC partitions are effectively separate devices from the default-accessible user area partition, hence, the extra partitions are exposed as separate block devices.
TOC:
[RFC] MMC: MMC boot partitions support.
Thanks,
A
RFC 1/1 MMC: MMC boot partitions support.
Allows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
--- drivers/mmc/card/Kconfig | 18 +++++ drivers/mmc/card/block.c | 183 ++++++++++++++++++++++++++++++++++---------- drivers/mmc/core/mmc.c | 5 + drivers/mmc/core/mmc_ops.h | 1 - include/linux/mmc/card.h | 2 + include/linux/mmc/core.h | 1 + include/linux/mmc/mmc.h | 6 ++ 7 files changed, 174 insertions(+), 42 deletions(-)
drivers/mmc/card/Kconfig +18 -0
@@ -14,6 +14,24 @@ config MMC_BLOCK mount the filesystem. Almost everyone wishing MMC support should say Y or M here. +config MMC_BLOCK_MMC_PART + tristate "MMC block MMC device partitioning support" + depends on BLOCK + default n + help + Say Y here to enable access to MMC partitions other than + the user area, such as the boot partitions. The other partitions + will appear as separate mmcblk devices. + +config MMC_BLOCK_MMC_PART_BOOT + tristate "MMC block MMC boot partition support" + depends on MMC_BLOCK_MMC_PART + default n + help + Say Y here to enable access to the MMC boot partitions. Boot + partitions are used by some devices to store bootloader information. + The boot partitions will appear as separate mmcblk devices. + config MMC_BLOCK_BOUNCE bool "Use bounce buffer for simple hosts" depends on MMC_BLOCK
drivers/mmc/card/block.c +142 -41
345 lines not on this page · raw message
drivers/mmc/core/mmc.c +5 -0
@@ -284,6 +284,11 @@ static int mmc_read_ext_csd(struct mmc_card *card) ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT ]; card->ext_csd.hc_erase_size = ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE ] <<10 ; + + +/* There are two boot regions of equal size */ + card->ext_csd.part_cfg = ext_csd[EXT_CSD_PCFG ]; + card->ext_csd.boot_size = ext_csd[EXT_CSD_BOOT_MULT ] *SZ_128K ; }if (card->ext_csd.rev >=4 ) {
drivers/mmc/core/mmc_ops.h +0 -1
@@ -20,7 +20,6 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid);int mmc_set_relative_addr (struct mmc_card *card);int mmc_send_csd (struct mmc_card *card,u32 *csd);int mmc_send_ext_csd (struct mmc_card *card,u8 *ext_csd); -int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value);int mmc_send_status (struct mmc_card *card,u32 *status);int mmc_send_cid (struct mmc_host *host,u32 *cid);int mmc_spi_read_ocr (struct mmc_host *host,int highcap,u32 *ocrp);
include/linux/mmc/card.h +2 -0
@@ -45,6 +45,7 @@ struct mmc_ext_csd {u8 rev;u8 erase_group_def;u8 sec_feature_support; +u8 part_cfg;unsigned int sa_timeout;/* Units: 100ns */ unsigned int hs_max_dtr;unsigned int sectors;
@@ -53,6 +54,7 @@ struct mmc_ext_csd {unsigned int sec_trim_mult;/* Secure trim multiplier */ unsigned int sec_erase_mult;/* Secure erase multiplier */ unsigned int trim_timeout;/* In milliseconds */ +unsigned int boot_size;/* in bytes */ };struct sd_scr {
include/linux/mmc/core.h +1 -0
@@ -135,6 +135,7 @@ extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);extern int mmc_wait_for_cmd (struct mmc_host *,struct mmc_command *,int );extern int mmc_wait_for_app_cmd (struct mmc_host *,struct mmc_card *,struct mmc_command *,int ); +extern int mmc_switch (struct mmc_card *,u8 ,u8 ,u8 );#define MMC_ERASE_ARG 0x00000000#define MMC_SECURE_ERASE_ARG 0x80000000
include/linux/mmc/mmc.h +6 -0
@@ -252,6 +252,7 @@ struct _mmc_csd {*/ #define EXT_CSD_ERASE_GROUP_DEF 175/* R/W */ +#define EXT_CSD_PCFG 179/* R/W */ #define EXT_CSD_ERASED_MEM_CONT 181/* RO */ #define EXT_CSD_BUS_WIDTH 183/* R/W */ #define EXT_CSD_HS_TIMING 185/* R/W */
@@ -262,6 +263,7 @@ struct _mmc_csd {#define EXT_CSD_S_A_TIMEOUT 217/* RO */ #define EXT_CSD_ERASE_TIMEOUT_MULT 223/* RO */ #define EXT_CSD_HC_ERASE_GRP_SIZE 224/* RO */ +#define EXT_CSD_BOOT_MULT 226/* RO */ #define EXT_CSD_SEC_TRIM_MULT 229/* RO */ #define EXT_CSD_SEC_ERASE_MULT 230/* RO */ #define EXT_CSD_SEC_FEATURE_SUPPORT 231/* RO */
@@ -271,6 +273,10 @@ struct _mmc_csd {* EXT_CSD field definitions */ +#define EXT_CSD_PCFG_ACC_MASK (0x7) +#define EXT_CSD_PCFG_ACC_BOOT0 (0x1) +#define EXT_CSD_PCFG_ACC_BOOT1 (0x2) +#define EXT_CSD_CMD_SET_NORMAL (1<<0)#define EXT_CSD_CMD_SET_SECURE (1<<1)#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
Signature · 1 line
1.7.0.4
Re: [RFC] MMC: MMC boot partitions support.
Quoted 5 lines · Andrei Warkentin
Allows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
Signed-off-by Andrei Warkentin <[email protected]>
Oops, sorry, sent the wrong commit. Please ignore lack of error checking around mmc_blk_part_switch inside issue_rq :<.
A
PATCH 1/1 MMC: MMC boot partitions support.
In reply to Andrei WarkentinAllows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
--- drivers/mmc/card/Kconfig | 18 ++++ drivers/mmc/card/block.c | 206 +++++++++++++++++++++++++++++++++++--------- drivers/mmc/core/mmc.c | 5 + drivers/mmc/core/mmc_ops.h | 1 - include/linux/mmc/card.h | 2 + include/linux/mmc/core.h | 1 + include/linux/mmc/mmc.h | 6 ++ 7 files changed, 197 insertions(+), 42 deletions(-)
drivers/mmc/card/Kconfig +18 -0
@@ -14,6 +14,24 @@ config MMC_BLOCK mount the filesystem. Almost everyone wishing MMC support should say Y or M here. +config MMC_BLOCK_MMC_PART + tristate "MMC block MMC device partitioning support" + depends on BLOCK + default n + help + Say Y here to enable access to MMC partitions other than + the user area, such as the boot partitions. The other partitions + will appear as separate mmcblk devices. + +config MMC_BLOCK_MMC_PART_BOOT + tristate "MMC block MMC boot partition support" + depends on MMC_BLOCK_MMC_PART + default n + help + Say Y here to enable access to the MMC boot partitions. Boot + partitions are used by some devices to store bootloader information. + The boot partitions will appear as separate mmcblk devices. + config MMC_BLOCK_BOUNCE bool "Use bounce buffer for simple hosts" depends on MMC_BLOCK
drivers/mmc/card/block.c +165 -41
369 lines not on this page · raw message
drivers/mmc/core/mmc.c +5 -0
@@ -284,6 +284,11 @@ static int mmc_read_ext_csd(struct mmc_card *card) ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT ]; card->ext_csd.hc_erase_size = ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE ] <<10 ; + + +/* There are two boot regions of equal size */ + card->ext_csd.part_cfg = ext_csd[EXT_CSD_PCFG ]; + card->ext_csd.boot_size = ext_csd[EXT_CSD_BOOT_MULT ] *SZ_128K ; }if (card->ext_csd.rev >=4 ) {
drivers/mmc/core/mmc_ops.h +0 -1
@@ -20,7 +20,6 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid);int mmc_set_relative_addr (struct mmc_card *card);int mmc_send_csd (struct mmc_card *card,u32 *csd);int mmc_send_ext_csd (struct mmc_card *card,u8 *ext_csd); -int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value);int mmc_send_status (struct mmc_card *card,u32 *status);int mmc_send_cid (struct mmc_host *host,u32 *cid);int mmc_spi_read_ocr (struct mmc_host *host,int highcap,u32 *ocrp);
include/linux/mmc/card.h +2 -0
@@ -45,6 +45,7 @@ struct mmc_ext_csd {u8 rev;u8 erase_group_def;u8 sec_feature_support; +u8 part_cfg;unsigned int sa_timeout;/* Units: 100ns */ unsigned int hs_max_dtr;unsigned int sectors;
@@ -53,6 +54,7 @@ struct mmc_ext_csd {unsigned int sec_trim_mult;/* Secure trim multiplier */ unsigned int sec_erase_mult;/* Secure erase multiplier */ unsigned int trim_timeout;/* In milliseconds */ +unsigned int boot_size;/* in bytes */ };struct sd_scr {
include/linux/mmc/core.h +1 -0
@@ -135,6 +135,7 @@ extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);extern int mmc_wait_for_cmd (struct mmc_host *,struct mmc_command *,int );extern int mmc_wait_for_app_cmd (struct mmc_host *,struct mmc_card *,struct mmc_command *,int ); +extern int mmc_switch (struct mmc_card *,u8 ,u8 ,u8 );#define MMC_ERASE_ARG 0x00000000#define MMC_SECURE_ERASE_ARG 0x80000000
include/linux/mmc/mmc.h +6 -0
@@ -252,6 +252,7 @@ struct _mmc_csd {*/ #define EXT_CSD_ERASE_GROUP_DEF 175/* R/W */ +#define EXT_CSD_PCFG 179/* R/W */ #define EXT_CSD_ERASED_MEM_CONT 181/* RO */ #define EXT_CSD_BUS_WIDTH 183/* R/W */ #define EXT_CSD_HS_TIMING 185/* R/W */
@@ -262,6 +263,7 @@ struct _mmc_csd {#define EXT_CSD_S_A_TIMEOUT 217/* RO */ #define EXT_CSD_ERASE_TIMEOUT_MULT 223/* RO */ #define EXT_CSD_HC_ERASE_GRP_SIZE 224/* RO */ +#define EXT_CSD_BOOT_MULT 226/* RO */ #define EXT_CSD_SEC_TRIM_MULT 229/* RO */ #define EXT_CSD_SEC_ERASE_MULT 230/* RO */ #define EXT_CSD_SEC_FEATURE_SUPPORT 231/* RO */
@@ -271,6 +273,10 @@ struct _mmc_csd {* EXT_CSD field definitions */ +#define EXT_CSD_PCFG_ACC_MASK (0x7) +#define EXT_CSD_PCFG_ACC_BOOT0 (0x1) +#define EXT_CSD_PCFG_ACC_BOOT1 (0x2) +#define EXT_CSD_CMD_SET_NORMAL (1<<0)#define EXT_CSD_CMD_SET_SECURE (1<<1)#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
Signature · 1 line
1.7.0.4
PATCH v3 1/1 MMC: MMC boot partitions support.
In reply to Andrei WarkentinAllows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
--- drivers/mmc/card/Kconfig | 18 ++++ drivers/mmc/card/block.c | 208 +++++++++++++++++++++++++++++++++++--------- drivers/mmc/core/mmc.c | 5 + drivers/mmc/core/mmc_ops.h | 1 - include/linux/mmc/card.h | 2 + include/linux/mmc/core.h | 1 + include/linux/mmc/mmc.h | 6 ++ 7 files changed, 199 insertions(+), 42 deletions(-)
drivers/mmc/card/Kconfig +18 -0
@@ -14,6 +14,24 @@ config MMC_BLOCK mount the filesystem. Almost everyone wishing MMC support should say Y or M here. +config MMC_BLOCK_MMC_PART + tristate "MMC block MMC device partitioning support" + depends on BLOCK + default n + help + Say Y here to enable access to MMC partitions other than + the user area, such as the boot partitions. The other partitions + will appear as separate mmcblk devices. + +config MMC_BLOCK_MMC_PART_BOOT + tristate "MMC block MMC boot partition support" + depends on MMC_BLOCK_MMC_PART + default n + help + Say Y here to enable access to the MMC boot partitions. Boot + partitions are used by some devices to store bootloader information. + The boot partitions will appear as separate mmcblk devices. + config MMC_BLOCK_BOUNCE bool "Use bounce buffer for simple hosts" depends on MMC_BLOCK
drivers/mmc/card/block.c +167 -41
371 lines not on this page · raw message
drivers/mmc/core/mmc.c +5 -0
@@ -284,6 +284,11 @@ static int mmc_read_ext_csd(struct mmc_card *card) ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT ]; card->ext_csd.hc_erase_size = ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE ] <<10 ; + + +/* There are two boot regions of equal size */ + card->ext_csd.part_cfg = ext_csd[EXT_CSD_PCFG ]; + card->ext_csd.boot_size = ext_csd[EXT_CSD_BOOT_MULT ] *SZ_128K ; }if (card->ext_csd.rev >=4 ) {
drivers/mmc/core/mmc_ops.h +0 -1
@@ -20,7 +20,6 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid);int mmc_set_relative_addr (struct mmc_card *card);int mmc_send_csd (struct mmc_card *card,u32 *csd);int mmc_send_ext_csd (struct mmc_card *card,u8 *ext_csd); -int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value);int mmc_send_status (struct mmc_card *card,u32 *status);int mmc_send_cid (struct mmc_host *host,u32 *cid);int mmc_spi_read_ocr (struct mmc_host *host,int highcap,u32 *ocrp);
include/linux/mmc/card.h +2 -0
@@ -45,6 +45,7 @@ struct mmc_ext_csd {u8 rev;u8 erase_group_def;u8 sec_feature_support; +u8 part_cfg;unsigned int sa_timeout;/* Units: 100ns */ unsigned int hs_max_dtr;unsigned int sectors;
@@ -53,6 +54,7 @@ struct mmc_ext_csd {unsigned int sec_trim_mult;/* Secure trim multiplier */ unsigned int sec_erase_mult;/* Secure erase multiplier */ unsigned int trim_timeout;/* In milliseconds */ +unsigned int boot_size;/* in bytes */ };struct sd_scr {
include/linux/mmc/core.h +1 -0
@@ -135,6 +135,7 @@ extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);extern int mmc_wait_for_cmd (struct mmc_host *,struct mmc_command *,int );extern int mmc_wait_for_app_cmd (struct mmc_host *,struct mmc_card *,struct mmc_command *,int ); +extern int mmc_switch (struct mmc_card *,u8 ,u8 ,u8 );#define MMC_ERASE_ARG 0x00000000#define MMC_SECURE_ERASE_ARG 0x80000000
include/linux/mmc/mmc.h +6 -0
@@ -252,6 +252,7 @@ struct _mmc_csd {*/ #define EXT_CSD_ERASE_GROUP_DEF 175/* R/W */ +#define EXT_CSD_PCFG 179/* R/W */ #define EXT_CSD_ERASED_MEM_CONT 181/* RO */ #define EXT_CSD_BUS_WIDTH 183/* R/W */ #define EXT_CSD_HS_TIMING 185/* R/W */
@@ -262,6 +263,7 @@ struct _mmc_csd {#define EXT_CSD_S_A_TIMEOUT 217/* RO */ #define EXT_CSD_ERASE_TIMEOUT_MULT 223/* RO */ #define EXT_CSD_HC_ERASE_GRP_SIZE 224/* RO */ +#define EXT_CSD_BOOT_MULT 226/* RO */ #define EXT_CSD_SEC_TRIM_MULT 229/* RO */ #define EXT_CSD_SEC_ERASE_MULT 230/* RO */ #define EXT_CSD_SEC_FEATURE_SUPPORT 231/* RO */
@@ -271,6 +273,10 @@ struct _mmc_csd {* EXT_CSD field definitions */ +#define EXT_CSD_PCFG_ACC_MASK (0x7) +#define EXT_CSD_PCFG_ACC_BOOT0 (0x1) +#define EXT_CSD_PCFG_ACC_BOOT1 (0x2) +#define EXT_CSD_CMD_SET_NORMAL (1<<0)#define EXT_CSD_CMD_SET_SECURE (1<<1)#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
Signature · 1 line
1.7.0.4
MMC partitions support (4th revision)
In reply to Andrei WarkentinThis is the 4th iteration of the MMC partitions support, which also adds boot partition support and slight cleanup of probe/remove/issue_rq code.
I've rebased this on top of linux-next, but I haven't run tested because linux-next doesn't have support for my platform yet. Tested on K36. Can anyone try :)?
PATCH v4 1/1 MMC: MMC boot partitions support.
In reply to Andrei WarkentinAllows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
--- drivers/mmc/card/Kconfig | 18 ++++ drivers/mmc/card/block.c | 212 +++++++++++++++++++++++++++++++++++--------- drivers/mmc/core/mmc.c | 5 + drivers/mmc/core/mmc_ops.h | 1 - include/linux/mmc/card.h | 2 + include/linux/mmc/core.h | 1 + include/linux/mmc/mmc.h | 6 ++ 7 files changed, 203 insertions(+), 42 deletions(-)
drivers/mmc/card/Kconfig +18 -0
@@ -32,6 +32,24 @@ config MMC_BLOCK_MINORS If unsure, say 8 here. +config MMC_BLOCK_MMC_PART + tristate "MMC block MMC device partitioning support" + depends on BLOCK + default n + help + Say Y here to enable access to MMC partitions other than + the user area, such as the boot partitions. The other partitions + will appear as separate mmcblk devices. + +config MMC_BLOCK_MMC_PART_BOOT + tristate "MMC block MMC boot partition support" + depends on MMC_BLOCK_MMC_PART + default n + help + Say Y here to enable access to the MMC boot partitions. Boot + partitions are used by some devices to store bootloader information. + The boot partitions will appear as separate mmcblk devices. + config MMC_BLOCK_BOUNCE bool "Use bounce buffer for simple hosts" depends on MMC_BLOCK
drivers/mmc/card/block.c +171 -41
364 lines not on this page · raw message
drivers/mmc/core/mmc.c +5 -0
@@ -299,6 +299,11 @@ static int mmc_read_ext_csd(struct mmc_card *card) ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT ]; card->ext_csd.hc_erase_size = ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE ] <<10 ; + + +/* There are two boot regions of equal size */ + card->ext_csd.part_cfg = ext_csd[EXT_CSD_PCFG ]; + card->ext_csd.boot_size = ext_csd[EXT_CSD_BOOT_MULT ] *SZ_128K ; }if (card->ext_csd.rev >=4 ) {
drivers/mmc/core/mmc_ops.h +0 -1
@@ -20,7 +20,6 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid);int mmc_set_relative_addr (struct mmc_card *card);int mmc_send_csd (struct mmc_card *card,u32 *csd);int mmc_send_ext_csd (struct mmc_card *card,u8 *ext_csd); -int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value);int mmc_send_status (struct mmc_card *card,u32 *status);int mmc_send_cid (struct mmc_host *host,u32 *cid);int mmc_spi_read_ocr (struct mmc_host *host,int highcap,u32 *ocrp);
include/linux/mmc/card.h +2 -0
@@ -45,6 +45,7 @@ struct mmc_ext_csd {u8 rev;u8 erase_group_def;u8 sec_feature_support; +u8 part_cfg;unsigned int sa_timeout;/* Units: 100ns */ unsigned int hs_max_dtr;unsigned int sectors;
@@ -57,6 +58,7 @@ 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 */ };struct sd_scr {
include/linux/mmc/core.h +1 -0
@@ -135,6 +135,7 @@ extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);extern int mmc_wait_for_cmd (struct mmc_host *,struct mmc_command *,int );extern int mmc_wait_for_app_cmd (struct mmc_host *,struct mmc_card *,struct mmc_command *,int ); +extern int mmc_switch (struct mmc_card *,u8 ,u8 ,u8 );#define MMC_ERASE_ARG 0x00000000#define MMC_SECURE_ERASE_ARG 0x80000000
include/linux/mmc/mmc.h +6 -0
@@ -256,6 +256,7 @@ struct _mmc_csd {#define EXT_CSD_PARTITION_ATTRIBUTE 156/* R/W */ #define EXT_CSD_PARTITION_SUPPORT 160/* RO */ #define EXT_CSD_ERASE_GROUP_DEF 175/* R/W */ +#define EXT_CSD_PCFG 179/* R/W */ #define EXT_CSD_ERASED_MEM_CONT 181/* RO */ #define EXT_CSD_BUS_WIDTH 183/* R/W */ #define EXT_CSD_HS_TIMING 185/* R/W */
@@ -267,6 +268,7 @@ struct _mmc_csd {#define EXT_CSD_HC_WP_GRP_SIZE 221/* RO */ #define EXT_CSD_ERASE_TIMEOUT_MULT 223/* RO */ #define EXT_CSD_HC_ERASE_GRP_SIZE 224/* RO */ +#define EXT_CSD_BOOT_MULT 226/* RO */ #define EXT_CSD_SEC_TRIM_MULT 229/* RO */ #define EXT_CSD_SEC_ERASE_MULT 230/* RO */ #define EXT_CSD_SEC_FEATURE_SUPPORT 231/* RO */
@@ -276,6 +278,10 @@ struct _mmc_csd {* EXT_CSD field definitions */ +#define EXT_CSD_PCFG_ACC_MASK (0x7) +#define EXT_CSD_PCFG_ACC_BOOT0 (0x1) +#define EXT_CSD_PCFG_ACC_BOOT1 (0x2) +#define EXT_CSD_CMD_SET_NORMAL (1<<0)#define EXT_CSD_CMD_SET_SECURE (1<<1)#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
Signature · 1 line
1.7.0.4
Re: [PATCHv4] MMC: MMC boot partitions support.
Quoted 4 lines · Andrei Warkentin
Allows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
Anyone has any opinions on these changes as being good or bad? Anything I should do differently? Or does everyone like this?
Thanks ahead,
A
Re: [PATCHv4] MMC: MMC boot partitions support.
Quoted 8 lines · Andrei Warkentin
Quoted 4 lines · Andrei Warkentin
Allows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
Anyone has any opinions on these changes as being good or bad? Anything I should do differently? Or does everyone like this?
I have no objections to the code, but I don't completely understand what it does. Maybe you can elaborate more in the patch description.
A few questions from me that I suppose should be answered by the description:
* Is each of the MMC partitions in turn a partitionable device like the user partition with its mmcblk0p1/p2/p3... devices?
* Will this patch impact device naming? Suppose you have an existing machine with mmcblk0 and mmcblk1 on two physical eMMC devices. When you show the partitions as new block devices, could it happen that the names are now different as you get additional devices inbetween? That would need to be documented carefully, as it could break existing setups.
* What devices specifically have these new partitions? Only eMMC 4.4 or also other versions?
* Would the same method work to support the secure partition on SD cards?
* How does a user identify which hardware partition corresponds to a given block device and vice versa?
Arnd
Re: [PATCHv4] MMC: MMC boot partitions support.
Hi Arnd,
Quoted 3 lines · Arnd Bergmann
I have no objections to the code, but I don't completely understand what it does. Maybe you can elaborate more in the patch description.
Sorry, will make it more concrete. This patch allows "device partitions" to be accessed. Device partitions provide their own address space - hence, you cannot access the boot partition data at all unless you specifically switch to the partition using MMC_SWITCH.
Quoted 6 lines
A few questions from me that I suppose should be answered by the description:
* Is each of the MMC partitions in turn a partitionable device like the user partition with its mmcblk0p1/p2/p3... devices?
Potentially yes. The current patch adds only the boot partitions, which generally are just some binary blobs specific to the ROM bootloaders found on embedded platforms.
Since eMMC 4.41, you can create "general purpose" partitions (up to 4), which will be carved out of the user partition, and can be used in any way possible, thus potentially holding file system partitions.
There is also the "Replay Protected Memory Block" device partition, which is not able to host a file system in the normal sense (because layer over the MMC block transfer protocol is a "replay protected transaction" protocol, which could be used by a user-mode application directly reading/writing from /dev/block/mmcblkXXX).
Quoted 7 lines
* Will this patch impact device naming? Suppose you have an existing machine with mmcblk0 and mmcblk1 on two physical eMMC devices. When you show the partitions as new block devices, could it happen that the names are now different as you get additional devices inbetween? That would need to be documented carefully, as it could break existing setups.
Unfortunately yes, although I am open for suggestions. An idea I considered is to add a postfix for device partitions. So, for card 0, the user area will remain mmcblk0, while boot partitions will be mmcblk0b0 and mmcblk0b1, generic partitions will be mmcblk0g0, and so on.
Quoted 3 lines
* What devices specifically have these new partitions? Only eMMC 4.4 or also other versions?
Boot partitions are available in 4.3. The other ones (4 general purpose ones, rpmb since 4.41).
Quoted 3 lines
* Would the same method work to support the secure partition on SD cards?
Most of the generic changes inside block.c apply. I specifically made the code easy to extend for SD boot partitions. You would just need the right changes for mmc_blk_part_switch (it already checks for mmc_card_mmc) and in mmc_blk_alloc_parts.
Unfortunately, since the SD spec is proprietary, I have no way of confirming whether the SD device partitioning (AFAIK there is a concept of boot partitions for eSD) works the same way or not, so I was maximally safe in supporting MMC device partitioning.
Quoted 2 lines
* How does a user identify which hardware partition corresponds to a given block device and vice versa?
Right now, you would just need to know. With postfixes like mmcblk0b0/mmcblk0g0 you would be able to tell the device partitions apart from the main mmcblk0.
Thanks for the feedback,
A
Re: [PATCHv4] MMC: MMC boot partitions support.
Hi Andrei,
Quoted 5 lines · Andrei Warkentin
Unfortunately yes, although I am open for suggestions. An idea I considered is to add a postfix for device partitions. So, for card 0, the user area will remain mmcblk0, while boot partitions will be mmcblk0b0 and mmcblk0b1, generic partitions will be mmcblk0g0, and so on.
Like Arnd, my main concern was around naming, breaking boot setups, and freaking people out by telling them that their cards have block devices that they can't usually see and not making it obvious where they came from. :)
Your "b/g" postfix solution appears to fix all of these, so I like it. We still have to think about where we expect users wondering what the "b" and "g" mean to go in order to find out..
Thanks!
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [PATCHv4] MMC: MMC boot partitions support.
Hi,
Quoted 9 lines · Chris Ball
Hi Andrei,
Quoted 5 lines · Andrei Warkentin
Unfortunately yes, although I am open for suggestions. An idea I considered is to add a postfix for device partitions. So, for card 0, the user area will remain mmcblk0, while boot partitions will be mmcblk0b0 and mmcblk0b1, generic partitions will be mmcblk0g0, and so on.
Quoted 8 lines
Like Arnd, my main concern was around naming, breaking boot setups, and freaking people out by telling them that their cards have block devices that they can't usually see and not making it obvious where they came from. :)
Your "b/g" postfix solution appears to fix all of these, so I like it. We still have to think about where we expect users wondering what the "b" and "g" mean to go in order to find out..
Oh, one more thing -- if we go with the b/g postfix, what's the intuition for requiring a Kconfig entry to turn this on? Is there any good argument against just turning it on for everyone, as long as it's not affecting mmcblk*p* naming?
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [PATCHv4] MMC: MMC boot partitions support.
Quoted 21 lines · Chris Ball
Hi,
Quoted 17 lines · Chris Ball
Hi Andrei,
Quoted 5 lines · Andrei Warkentin
Unfortunately yes, although I am open for suggestions. An idea I considered is to add a postfix for device partitions. So, for card 0, the user area will remain mmcblk0, while boot partitions will be mmcblk0b0 and mmcblk0b1, generic partitions will be mmcblk0g0, and so on.
Like Arnd, my main concern was around naming, breaking boot setups, and freaking people out by telling them that their cards have block devices that they can't usually see and not making it obvious where they came from. :)
Your "b/g" postfix solution appears to fix all of these, so I like it. We still have to think about where we expect users wondering what the "b" and "g" mean to go in order to find out..
Ok, I'll add that in. I'll add the documentation changes as well.
Quoted 5 lines
Oh, one more thing -- if we go with the b/g postfix, what's the intuition for requiring a
Kconfigentry to turn this on? Is there any good argument against just turning it on for everyone, as long as it's not affecting mmcblk*p* naming?
The boot partition support (and any other XYZ partition support in the future) so far in the patch is a Kconfig entry. So you have to want it to get it.
The argument against turning it on by default is that someone might figure that mke2fs-ing the boot partitions is a good way to reclaim 4MB on their rooted device,
and if they didn't realize the data was necessary for boot-up, they will brick the device. That and people might freak out when they see more mmcblk entries than they expected :-).
A
Re: [PATCHv4] MMC: MMC boot partitions support.
Hi,
Quoted 5 lines · Andrei Warkentin
The argument against turning it on by default is that someone might figure that mke2fs-ing the boot partitions is a good way to reclaim 4MB on their rooted device,
and if they didn't realize the data was necessary for boot-up, they will brick the device.
Ah. Ugh, that sucks; I can totally see that happening. Now I'm wondering if we should just be hardcoding boot devices as always read-only and just refusing to write to them.
What do others think? Is there an acceptable tradeoff somewhere? It's not clear to me that Kconfig entries are sufficient to obtain consent to present r/w mounts of the boot partitions; the user writing the "dd" line usually isn't the person who made the Kconfig selection, and the person who made the Kconfig selection is often a distro maintainer who just turns on new Kconfig symbols without reading closely.
Quoted 2 lines
That and people might freak out when they see
more mmcblk entries than they expected :-).
I'm not worried about this one, as long as they have the postfixes.
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [PATCHv4] MMC: MMC boot partitions support.
Quoted 13 lines · Chris Ball
Hi,
Quoted 5 lines · Andrei Warkentin
The argument against turning it on by default is that someone might figure that mke2fs-ing the boot partitions is a good way to reclaim 4MB on their rooted device,
and if they didn't realize the data was necessary for boot-up, they will brick the device.Ah. Ugh, that sucks; I can totally see that happening. Now I'm wondering if we should just be hardcoding boot devices as always read-only and just refusing to write to them.
Quoted 8 lines
What do others think? Is there an acceptable tradeoff somewhere? It's not clear to me that
Kconfigentries are sufficient to obtain consent to present r/w mounts of the boot partitions; the user writing the "dd" line usually isn't the person who made theKconfigselection, and the person who made theKconfigselection is often a distro maintainer who just turns on newKconfigsymbols without reading closely.
Well, there are less esoteric ways of turning something into a paperweight =). No, the whole point of adding the device partition support is so you don't have to go through hoops to read and write them.
The scenario where it matters (embedded Linux devices booting through boot partitions) are such, that if you went through sufficient hoops to get root access, and can build and boot a kernel to enable these options for that device, then you must know what you're doing, and a warning message in the Kconfig help is sufficient. The generic case of people sticking cards into a PCI SDHCI controller under Ubuntu is such that you can do no real damage.
A
Re: [PATCHv4] MMC: MMC boot partitions support.
Quoted 4 lines · Andrei Warkentin
Well, there are less esoteric ways of turning something into a paperweight =). No, the whole point of adding the device partition support is so you don't have to go through hoops to read and write them.
Agreed.
Quoted 7 lines
The scenario where it matters (embedded Linux devices booting through boot partitions) are such, that if you went through sufficient hoops to get root access, and can build and boot a kernel to enable these options for that device, then you must know what you're doing, and a warning message in the
Kconfighelp is sufficient. The generic case of people sticking cards into a PCI SDHCI controller under Ubuntu is such that you can do no real damage.
One possible way of dealing with this would be to make the boot partition a character device instead of a block device. That would still allow you to overwrite it, but make it very obvious that you cannot mount or partition it.
On the other hand, it would be a rather esoteric interface, since the hardware is still fundamentally block based, we just use it in a different way.
Arnd
Re: [PATCHv4] MMC: MMC boot partitions support.
Quoted 16 lines · Arnd Bergmann
Quoted 4 lines · Andrei Warkentin
Well, there are less esoteric ways of turning something into a paperweight =). No, the whole point of adding the device partition support is so you don't have to go through hoops to read and write them.
Agreed.
Quoted 7 lines
The scenario where it matters (embedded Linux devices booting through boot partitions) are such, that if you went through sufficient hoops to get root access, and can build and boot a kernel to enable these options for that device, then you must know what you're doing, and a warning message in the
Kconfighelp is sufficient. The generic case of people sticking cards into a PCI SDHCI controller under Ubuntu is such that you can do no real damage.
Quoted 9 lines
One possible way of dealing with this would be to make the boot partition a character device instead of a block device. That would still allow you to overwrite it, but make it very obvious that you cannot mount or partition it.
On the other hand, it would be a rather esoteric interface, since the hardware is still fundamentally block based, we just use it in a different way.
Plus what if you do intend to have a file system there? Other than complexity and non-obvious usage, I don't see
anything gained by this. I wouldn't worry about ways of misusing this. As I've said, in the only case it matters (some embedded device booting from the boot partition), the user would have to gain root access, build a kernel giving access to the boot partitions and be able to boot into it. So a warning in Kconfig is sufficient.
If you guys feel concerned, then we can add another Kconfig option that will allow write access to the boot partitions.
A
Re: [PATCHv4] MMC: MMC boot partitions support.
Hi,
Quoted 10 lines · Andrei Warkentin
Plus what if you do intend to have a file system there? Other than complexity and non-obvious usage, I don't see
anything gained by this. I wouldn't worry about ways of misusing this. As I've said, in the only case it matters (some embedded device booting from the boot partition), the user would have to gain root access, build a kernel giving access to the boot partitions and be able to boot into it. So a warning inKconfigis sufficient.If you guys feel concerned, then we can add another
Kconfigoption that will allow write access to the boot partitions.
I'm willing to come around to saying that the risk is acceptable, and that people who overwrite /dev/mmcblk0b0 on their rooted Android phones won't blame us (at least, not deservedly) for it.
But I'm still concerned after your Kconfig options are added, because I'm just not reassured by Kconfig options in principle, because of the case where *the person who built the kernel* is not the same as the *user who is running commands*. Imagine that CyanogenMod (or even Qualcomm!) distributes a kernel with this Kconfig option turned on -- because they don't realize how dangerous it is, perhaps, or because they had a use for it during development -- to see where I'm coming from.
Now, the presence of block devices that brick machines when overwritten isn't a new phenomenon, so we've got a fair amount of precedence behind us if we simply expose what we see and expect that users won't do something unrecoverable. But I'm trying to think about if there's anything we can do to *minimize* that risk, and have people know what's going on before they do something they shouldn't. (I think I like Arnd's suggestion of explicitly having "boot" in the device name rather than just "b", because that does lend a feeling of "this partition is really important".)
Does that help clarify my position? Would be happy to hear any other suggestions on what the right affordance to shoot for is.
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [PATCHv4] MMC: MMC boot partitions support.
Hi,
Quoted 7 lines · Chris Ball
But I'm still concerned after your
Kconfigoptions are added, because I'm just not reassured byKconfigoptions in principle, because of the case where *the person who built the kernel* is not the same as the *user who is running commands*. Imagine that CyanogenMod (or even Qualcomm!) distributes a kernel with thisKconfigoption turned on -- because they don't realize how dangerous it is, perhaps, or because they had a use for it during development -- to see where I'm coming from.
Another strawman, after brainstorming a bit on IRC -- how about the block device itself comes up read-only, until you use a module parameter/sysfs entry to make it read-write. As a strawman:
echo 1 > /sys/module/mmc_block/boot_partitions_are_writeable
(That way people who write to it regularly can throw the module parameter in their boot environment, and the rooting enthusiasts who didn't compile the kernel are safe until they learn enough to be really dangerous..)
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [PATCHv4] MMC: MMC boot partitions support.
Quoted 15 lines · Chris Ball
Hi,
Quoted 7 lines · Chris Ball
But I'm still concerned after your
Kconfigoptions are added, because I'm just not reassured byKconfigoptions in principle, because of the case where *the person who built the kernel* is not the same as the *user who is running commands*. Imagine that CyanogenMod (or even Qualcomm!) distributes a kernel with thisKconfigoption turned on -- because they don't realize how dangerous it is, perhaps, or because they had a use for it during development -- to see where I'm coming from.Another strawman, after brainstorming a bit on IRC -- how about the block device itself comes up read-only, until you use a module parameter/sysfs entry to make it read-write. As a strawman:
Quoted 5 lines
echo 1 >
/sys/module/mmc_block/boot_partitions_are_writeable(That way people who write to it regularly can throw the module parameter in their boot environment, and the rooting enthusiasts who didn't compile the kernel are safe until they learn enough to be really dangerous..)
Sure, I like this, I'll do it.
A
Re: [PATCHv4] MMC: MMC boot partitions support.
Quoted 11 lines · Andrei Warkentin
Quoted 9 lines
Another strawman, after brainstorming a bit on IRC -- how about the block device itself comes up read-only, until you use a module parameter/sysfs entry to make it read-write. As a strawman:
echo 1 >
/sys/module/mmc_block/boot_partitions_are_writeable(That way people who write to it regularly can throw the module parameter in their boot environment, and the rooting enthusiasts who didn't compile the kernel are safe until they learn enough to be really dangerous..)
Sure, I like this, I'll do it.
I don't think it's even needed, but it sounds much more useful than a Kconfig option, so no objections from me.
Arnd
Re: [PATCHv4] MMC: MMC boot partitions support.
Hi,
Quoted 2 lines · Arnd Bergmann
I don't think it's even needed, but it sounds much more useful than a
Kconfigoption, so no objections from me.
Cool, thanks. By the way, I'm pretty neutral on whether there need to be any Kconfig entries for any of this at all after the module parameter goes in, so feel free to take them out of the patch.
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [PATCHv4] MMC: MMC boot partitions support.
In reply to Chris BallQuoted 26 lines · Chris Ball
Hi,
Quoted 10 lines · Andrei Warkentin
Plus what if you do intend to have a file system there? Other than complexity and non-obvious usage, I don't see
anything gained by this. I wouldn't worry about ways of misusing this. As I've said, in the only case it matters (some embedded device booting from the boot partition), the user would have to gain root access, build a kernel giving access to the boot partitions and be able to boot into it. So a warning inKconfigis sufficient.If you guys feel concerned, then we can add another
Kconfigoption that will allow write access to the boot partitions.I'm willing to come around to saying that the risk is acceptable, and that people who overwrite
/dev/mmcblk0b0on their rooted Android phones won't blame us (at least, not deservedly) for it.But I'm still concerned after your
Kconfigoptions are added, because I'm just not reassured byKconfigoptions in principle, because of the case where *the person who built the kernel* is not the same as the *user who is running commands*. Imagine that CyanogenMod (or even Qualcomm!) distributes a kernel with thisKconfigoption turned on -- because they don't realize how dangerous it is, perhaps, or because they had a use for it during development -- to see where I'm coming from.
Quoted 9 lines
Now, the presence of block devices that brick machines when overwritten isn't a new phenomenon, so we've got a fair amount of precedence behind us if we simply expose what we see and expect that users won't do something unrecoverable. But I'm trying to think about if there's anything we can do to *minimize* that risk, and have people know what's going on before they do something they shouldn't. (I think I like Arnd's suggestion of explicitly having "boot" in the device name rather than just "b", because that does lend a feeling of "this partition is really important".)
Yup I think having 'boot' in there (as in mmcblk0boot0) is a good idea. I also think having boot write support as a separate configuration option is also a good idea,
so I'll add that in. I think that should help minimize the risk.
A
Re: [PATCHv4] MMC: MMC boot partitions support.
In reply to Andrei WarkentinQuoted 7 lines · Andrei Warkentin
Plus what if you do intend to have a file system there? Other than complexity and non-obvious usage, I don't see
anything gained by this. I wouldn't worry about ways of misusing this. As I've said, in the only case it matters (some embedded device booting from the boot partition), the user would have to gain root access, build a kernel giving access to the boot partitions and be able to boot into it.
The character device (or sysfs_bin_file actually) would only make sense if we know that there is no reason to put a file system on it. The idea of that is that we intentionally treat it like a firmware flash, not like a block device because that is how it's used.
If there is a reasonable chance that people actually want to have a file system in the boot partition, it should by all means be a block device.
Arnd
Re: [PATCHv4] MMC: MMC boot partitions support.
In reply to Andrei WarkentinQuoted 4 lines · Andrei Warkentin
On Wed, Mar 30, 2011 at 7:03 AM, Arnd Bergmann <[email protected]> wrote:
Since eMMC 4.41, you can create "general purpose" partitions (up to 4), which will be carved out of the user partition, and can be used in any way possible, thus potentially holding file system partitions.
My feeling is that these should be separate from the boot partition. It could probably be done using a new fs/partitions/mmc.c file that directly interacts with the mmc layer instead of looking at the MS-DOS master boot record. That way, you could define the same partitions (mmcblk0p1, ...) using a different method.
It also requires a user interface that a new mmc-fdisk tool can talk to, in order to modify the partition table, not sure if it's possible to use the BLKPG ioctl for this.
Quoted 5 lines
There is also the "Replay Protected Memory Block" device partition, which is not able to host a file system in the normal sense (because layer over the MMC block transfer protocol is a "replay protected transaction" protocol, which could be used by a user-mode application directly reading/writing from
/dev/block/mmcblkXXX).
Ok. That sounds like a use case for an ioctl interface then, if we even want to expose it.
Quoted 6 lines
Quoted 3 lines
* What devices specifically have these new partitions? Only eMMC 4.4 or also other versions?
Boot partitions are available in 4.3. The other ones (4 general purpose ones, rpmb since 4.41).
ok.
Quoted 4 lines
Unfortunately, since the SD spec is proprietary, I have no way of confirming whether the SD device partitioning (AFAIK there is a concept of boot partitions for eSD) works the same way or not, so I was maximally safe in supporting MMC device partitioning.
The public parts of the SD standard specifically require MS-DOS partitioning to be used, so I assume that there is no internal method in addition. They also describe the presence of a "secure area" that can only be accessed after authentication. This could use a similar method as the boot partition, but it's unclear to me whether that is something that anyone is interested in.
Quoted 6 lines
Quoted 2 lines
* How does a user identify which hardware partition corresponds to a given block device and vice versa?
Right now, you would just need to know. With postfixes like mmcblk0b0/mmcblk0g0 you would be able to tell the device partitions apart from the main mmcblk0.
Regarding the naming, I would not use a trailing zero, but it's probably a subjective thing. The other names I could imagine for the boot partition of mmc 0 are mmcboot0, mmcblk0b or mmcblk0boot.
I also mentioned the character device option. Yet another way would be to add a sysfs_bin_attribute that corresponds to the boot partition and can be accessed using read/write, like we do for PCI resources.
Arnd
Re: [PATCHv4] MMC: MMC boot partitions support.
Quoted 7 lines · Arnd Bergmann
My feeling is that these should be separate from the boot partition. It could probably be done using a new
fs/partitions/mmc.cfile that directly interacts with the mmc layer instead of looking at the MS-DOS master boot record. That way, you could define the same partitions (mmcblk0p1, ...) using a different method.
Nope. The device partitions are one time programmable (partition once), so you definitely don't want to expose them as regular partitions. The point
behind the GP partitions is that they can be implemented with enhanced features (such as better reliability), and so like the enhanced area, are meant as a complement, not a replacement for file system partitions.
I don't think there is a need to over complicate this. It's just going to get more confusing and involve more changes. The device partitioning support is pretty orthogonal right now.
Quoted 10 lines
Quoted 6 lines
There is also the "Replay Protected Memory Block" device partition, which is not able to host a file system in the normal sense (because layer over the MMC block transfer protocol is a "replay protected transaction" protocol, which could be used by a user-mode application directly reading/writing from
/dev/block/mmcblkXXX).Ok. That sounds like a use case for an ioctl interface then, if we even want to expose it.
Pretty much.
Quoted 4 lines
Regarding the naming, I would not use a trailing zero, but it's probably a subjective thing. The other names I could imagine for the boot partition of mmc 0 are mmcboot0, mmcblk0b or mmcblk0boot.
Since we have two boot partitions and 4 GP ones, for mmcblk0 I'd stick with something like
mmcblk0boot0, mmcblk0boot1, mmcblk0gp0-mmcblk0gp4. I'd want to keep the first mmcblk0, so that
a user can easily associate the actual card the device partitions are for.
Quoted 3 lines
I also mentioned the character device option. Yet another way would be to add a
sysfs_bin_attributethat corresponds to the boot partition and can be accessed using read/write, like we do for PCI resources.
I don't think this gains anything, other than a separate path for performing I/O, inability to use existing tools (filesystems, dd, etc) more code and a even less obvious way of bricking something =).
A
Re: [PATCHv4] MMC: MMC boot partitions support.
Quoted 16 lines · Andrei Warkentin
Quoted 6 lines · Arnd Bergmann
My feeling is that these should be separate from the boot partition. It could probably be done using a new
fs/partitions/mmc.cfile that directly interacts with the mmc layer instead of looking at the MS-DOS master boot record. That way, you could define the same partitions (mmcblk0p1, ...) using a different method.Nope. The device partitions are one time programmable (partition once), so you definitely don't want to expose them as regular partitions. The point
behind the GP partitions is that they can be implemented with enhanced features (such as better reliability), and so like the enhanced area, are meant as a complement, not a replacement for file system partitions.
Quoted 3 lines
I don't think there is a need to over complicate this. It's just going to get more confusing and involve more changes. The device partitioning support is pretty orthogonal right now.
Even if they are write-once, wouldn't we still need to provide an interface to write them once?
The question if GP should be used together or instead of MS-DOS partitions depends on the possible use cases. If you don't want to partition a GP any further in software, exposing them directly as mmcblk0pX would be a very nice and simple interface, but it completely prevents you from creating subpartitions.
The other alternative is to allow each GP to contain a partition table, but then you need a either a three-level naming (mmcblk0gp1p2) or make each GP a device by itself (mmcblk0, mmcblk1) that can in turn be partitioned.
Quoted 10 lines
Quoted 4 lines
Regarding the naming, I would not use a trailing zero, but it's probably a subjective thing. The other names I could imagine for the boot partition of mmc 0 are mmcboot0, mmcblk0b or mmcblk0boot.
Since we have two boot partitions and 4 GP ones, for mmcblk0 I'd stick with something like
mmcblk0boot0, mmcblk0boot1, mmcblk0gp0-mmcblk0gp4. I'd want to keep the first mmcblk0, so that
a user can easily associate the actual card the device partitions are for.
I would find it rather confusing if the device can be partitioned in software but the GP devices could not be.
Arnd
Re: [PATCHv4] MMC: MMC boot partitions support.
Quoted 4 lines · Arnd Bergmann
Even if they are write-once, wouldn't we still need to provide an interface to write them once?
True. I first wanted to provide access to them. It would have to be a special ioctl. There are a number of interesting MMC operations that don't fit any other way - for example, password protection.
Quoted 11 lines
The question if GP should be used together or instead of MS-DOS partitions depends on the possible use cases. If you don't want to partition a GP any further in software, exposing them directly as mmcblk0pX would be a very nice and simple interface, but it completely prevents you from creating subpartitions.
The other alternative is to allow each GP to contain a partition table, but then you need a either a three-level naming (mmcblk0gp1p2) or make each GP a device by itself (mmcblk0, mmcblk1) that can in turn be partitioned.
Right now they are exposed as separate devices. This lets the user pick whatever usage they
see fit (can format it directly, or can partition it), while the naming (mmcblk0boot0, mmcblk0boot1, mmcblkgp0p1 for first partition on gp0, for example) conveys that the entries are for device partitions.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Regarding the naming, I would not use a trailing zero, but it's probably a subjective thing. The other names I could imagine for the boot partition of mmc 0 are mmcboot0, mmcblk0b or mmcblk0boot.
Quoted 9 lines
Quoted 5 lines
Since we have two boot partitions and 4 GP ones, for mmcblk0 I'd stick with something like
mmcblk0boot0, mmcblk0boot1, mmcblk0gp0-mmcblk0gp4. I'd want to keep the first mmcblk0, so that
a user can easily associate the actual card the device partitions are for.I would find it rather confusing if the device can be partitioned in software but the GP devices could not be.
Right now you can partition the device partitions, because effectively, they are separate devices.
A
Re: [PATCHv4] MMC: MMC boot partitions support.
Quoted 5 lines · On Friday 01 April 2011 20:42:36 Andrei Warkentin wrote:
Right now they are exposed as separate devices. This lets the user pick whatever usage they
see fit (can format it directly, or can partition it), while the naming (mmcblk0boot0, mmcblk0boot1, mmcblkgp0p1 for first partition on gp0, for example) conveys that the entries are for device partitions.
Ok, sounds good. How do they show up in sysfs then? I think ideally a gp device should be a child of the regular device, just like a partition, and then it can have further children. That way, a user application can easily find out which ones belong together.
Arnd
Re: [PATCHv4] MMC: MMC boot partitions support.
Quoted 11 lines · Arnd Bergmann
Quoted 5 lines · On Friday 01 April 2011 20:42:36 Andrei Warkentin wrote:
Right now they are exposed as separate devices. This lets the user pick whatever usage they
see fit (can format it directly, or can partition it), while the naming (mmcblk0boot0, mmcblk0boot1, mmcblkgp0p1 for first partition on gp0, for example) conveys that the entries are for device partitions.Ok, sounds good. How do they show up in sysfs then? I think ideally a gp device should be a child of the regular device, just like a partition, and then it can have further children. That way, a user application can easily find out which ones belong together.
Right now, it shows up on the same level as mmcblk0, but I'll fix that (this is why I wanted the first portion to contain actual device name, e.g. mmcblk0boot0, but you're right, I should fix the inheritance)
A
PATCH 1/1 MMC: MMC boot partitions support.
Allows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
--- Documentation/mmc/00-INDEX | 2 + Documentation/mmc/mmc-dev-attrs.txt | 10 ++ Documentation/mmc/mmc-dev-parts.txt | 26 +++ drivers/mmc/card/block.c | 305 +++++++++++++++++++++++++++++------ drivers/mmc/core/mmc.c | 35 +++-- drivers/mmc/core/mmc_ops.c | 16 ++- drivers/mmc/core/mmc_ops.h | 1 - include/linux/mmc/card.h | 4 +- include/linux/mmc/core.h | 1 + include/linux/mmc/mmc.h | 8 +- 10 files changed, 341 insertions(+), 67 deletions(-) create mode 100644 Documentation/mmc/mmc-dev-parts.txt
Documentation/mmc/00-INDEX +2 -0
@@ -2,3 +2,5 @@ - this file mmc-dev-attrs.txt - info on SD and MMC device attributes +mmc-dev-parts.txt + - info on SD and MMC device partitions
Documentation/mmc/mmc-dev-attrs.txt +10 -0
@@ -1,3 +1,13 @@ +SD and MMC Block Device Attributes +================================== + +These attributes are defined for the block devices associated with the +SD or MMC device. + +The following attributes are read/write. + + force_ro Enforce read-only access even if write protect switch is off. + SD and MMC Device Attributes ============================
Documentation/mmc/mmc-dev-parts.txt new file +26 -0
@@ -0,0 +1,26 @@ +SD and MMC Device Partitions +============================ + +Device partitions are additional logical block devices present +on the SD/MMC device. + +As of this writing, MMC boot partitions as supported and exposed as +/dev/mmcblkXboot0 and /dev/mmcblkXboot1, where X is the index of the +parent /dev/mmcblkX. + +MMC Boot Partitions +=================== + +Read and write access is provided to the two MMC boot partitions. Due +to the sensitive nature of the boot partition contents, which often store +a bootloader or bootloader configuration tables crucial to booting the platform, +write access is by default disabled to reduce the chance of accidental bricking. + +To enable write access to /dev/mmcblkXbootY, disable the forced read-only +access: + +echo 0 > /sys/block/mmcblkXbootY/force_ro + +To re-enable read-only access: + +echo 1 > /sys/block/mmcblkXbootY/force_ro
drivers/mmc/card/block.c +252 -53
482 lines not on this page · raw message
drivers/mmc/core/mmc.c +25 -10
@@ -288,7 +288,10 @@ static int mmc_read_ext_csd(struct mmc_card *card)if (card->ext_csd.rev >=3 ) {u8 sa_shift = ext_csd[EXT_CSD_S_A_TIMEOUT ]; - card->ext_csd.bootconfig = ext_csd[EXT_CSD_BOOT_CONFIG ]; + card->ext_csd.part_config = ext_csd[EXT_CSD_PART_CONFIG ]; + +/* EXT_CSD value is in units of 10ms, but we store in ms */ + card->ext_csd.part_time =10 * ext_csd[EXT_CSD_PART_SWITCH_TIME ];/* Sleep / awake timeout in 100ns units */ if (sa_shift >0 && sa_shift <=0x17 )
@@ -302,6 +305,12 @@ static int mmc_read_ext_csd(struct mmc_card *card) ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE ] <<10 ; card->ext_csd.rel_sectors = ext_csd[EXT_CSD_REL_WR_SEC_C ]; + +/* +* 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 ; }if (card->ext_csd.rev >=4 ) {
@@ -548,7 +557,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,*/ if (card->ext_csd.enhanced_area_en) { err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_ERASE_GROUP_DEF ,1 ); +EXT_CSD_ERASE_GROUP_DEF ,1 , +0 );if (err && err != -EBADMSG ) goto free_card;
@@ -576,10 +586,13 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,/* * Ensure eMMC user default partition is enabled */ -if (card->ext_csd.bootconfig &0x7 ) { - card->ext_csd.bootconfig &= ~0x7 ; -mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_BOOT_CONFIG , - card->ext_csd.bootconfig); +if (card->ext_csd.part_config &EXT_CSD_PART_CONFIG_ACC_MASK ) { + card->ext_csd.part_config &= ~EXT_CSD_PART_CONFIG_ACC_MASK ; + err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_PART_CONFIG , + card->ext_csd.part_config, + card->ext_csd.part_time); +if (err && err != -EBADMSG ) + goto free_card; }/*
@@ -588,7 +601,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,if ((card->ext_csd.hs_max_dtr !=0 ) && (host->caps &MMC_CAP_MMC_HIGHSPEED )) { err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_HS_TIMING ,1 ); +EXT_CSD_HS_TIMING ,1 ,0 );if (err && err != -EBADMSG ) goto free_card;
@@ -655,7 +668,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, ddr =0 ;/* no DDR for 1-bit width */ err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_BUS_WIDTH , - ext_csd_bits[idx][0 ]); + ext_csd_bits[idx][0 ], +0 );if (!err) {mmc_set_bus_width_ddr (card->host, bus_width,MMC_SDR_MODE );
@@ -674,8 +688,9 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,if (!err && ddr) { err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_BUS_WIDTH , - ext_csd_bits[idx][1 ]); +EXT_CSD_BUS_WIDTH , + ext_csd_bits[idx][1 ], +0 ); }if (err) { printk(KERN_WARNING "%s: switch to bus width %d ddr %d "
drivers/mmc/core/mmc_ops.c +15 -1
@@ -387,7 +387,18 @@ int mmc_spi_set_crc(struct mmc_host *host, int use_crc)return err; } -int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value) +/** +* mmc_switch - modify EXT_CSD register +* @card: the MMC card associated with the data transfer +* @set: cmd set values +* @index: EXT_CSD register index +* @value: value to program into EXT_CSD register +* @timeout: timeout for operation performed by register write +* +* Modifies the EXT_CSD register for selected card. +*/ +int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value, +unsigned int timeout) {int err;struct mmc_command cmd;
@@ -404,6 +415,7 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value) (value <<8 ) | set; cmd.flags =MMC_RSP_SPI_R1B |MMC_RSP_R1B |MMC_CMD_AC ; + cmd.cmd_timeout = timeout; err =mmc_wait_for_cmd (card->host, &cmd,MMC_CMD_RETRIES );if (err)
@@ -434,6 +446,8 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value)return 0 ; } +EXPORT_SYMBOL (mmc_switch); +int mmc_send_status (struct mmc_card *card,u32 *status) {int err;
drivers/mmc/core/mmc_ops.h +0 -1
@@ -20,7 +20,6 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid);int mmc_set_relative_addr (struct mmc_card *card);int mmc_send_csd (struct mmc_card *card,u32 *csd);int mmc_send_ext_csd (struct mmc_card *card,u8 *ext_csd); -int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value);int mmc_send_status (struct mmc_card *card,u32 *status);int mmc_send_cid (struct mmc_host *host,u32 *cid);int mmc_spi_read_ocr (struct mmc_host *host,int highcap,u32 *ocrp);
include/linux/mmc/card.h +3 -1
@@ -47,7 +47,8 @@ struct mmc_ext_csd {u8 sec_feature_support;u8 rel_sectors;u8 rel_param; -u8 bootconfig; +u8 part_config; +unsigned int part_time;/* Units: ms */ unsigned int sa_timeout;/* Units: 100ns */ unsigned int hs_max_dtr;unsigned int sectors;
@@ -60,6 +61,7 @@ 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 */ };struct sd_scr {
include/linux/mmc/core.h +1 -0
@@ -135,6 +135,7 @@ extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);extern int mmc_wait_for_cmd (struct mmc_host *,struct mmc_command *,int );extern int mmc_wait_for_app_cmd (struct mmc_host *,struct mmc_card *,struct mmc_command *,int ); +extern int mmc_switch (struct mmc_card *,u8 ,u8 ,u8 ,unsigned int );#define MMC_ERASE_ARG 0x00000000#define MMC_SECURE_ERASE_ARG 0x80000000
include/linux/mmc/mmc.h +7 -1
@@ -257,19 +257,21 @@ struct _mmc_csd {#define EXT_CSD_PARTITION_SUPPORT 160/* RO */ #define EXT_CSD_WR_REL_PARAM 166/* RO */ #define EXT_CSD_ERASE_GROUP_DEF 175/* R/W */ -#define EXT_CSD_BOOT_CONFIG 179/* R/W */ +#define EXT_CSD_PART_CONFIG 179/* R/W */ #define EXT_CSD_ERASED_MEM_CONT 181/* RO */ #define EXT_CSD_BUS_WIDTH 183/* R/W */ #define EXT_CSD_HS_TIMING 185/* R/W */ #define EXT_CSD_REV 192/* RO */ #define EXT_CSD_STRUCTURE 194/* RO */ #define EXT_CSD_CARD_TYPE 196/* RO */ +#define EXT_CSD_PART_SWITCH_TIME 199/* RO */ #define EXT_CSD_SEC_CNT 212/* RO, 4 bytes */ #define EXT_CSD_S_A_TIMEOUT 217/* RO */ #define EXT_CSD_REL_WR_SEC_C 222/* RO */ #define EXT_CSD_HC_WP_GRP_SIZE 221/* RO */ #define EXT_CSD_ERASE_TIMEOUT_MULT 223/* RO */ #define EXT_CSD_HC_ERASE_GRP_SIZE 224/* RO */ +#define EXT_CSD_BOOT_MULT 226/* RO */ #define EXT_CSD_SEC_TRIM_MULT 229/* RO */ #define EXT_CSD_SEC_ERASE_MULT 230/* RO */ #define EXT_CSD_SEC_FEATURE_SUPPORT 231/* RO */
@@ -281,6 +283,10 @@ 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)#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
Signature · 1 line
1.7.0.4
Re: [PATCH] MMC: MMC boot partitions support.
Quoted 5 lines · Andrei Warkentin
Allows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
Signed-off-by Andrei Warkentin <[email protected]>
+Chris
+Arnd
This version is different from the previous one in the following ways:
- Rebased on top reliable writes support (because it's in to make merging easier) + modified MMC: enable TRIM/ERASE caps for SDHCI host patch that I sent out earlier today
(because I need to be able to set timeout appropriately for CMD6 and
have it honored by SDHCI)
- Fixes compile error with block support built as module (mmc_switch wasn't exported)
- Let's mmc_switch be supplied a timeout value. Default of 0 does a max timeout which is the only valid thing to do for register modifications where the timeout is not specified by the JEDEC spec or EXT_CSD values.
- Switching partition timeout is now honored (byte 199 of EXT_CSD)
- Fixes compile error with getting built on architectures where SZ_128K isn't defined (most of them)
- Fixes naming as discussed - boot partitions are called mmcblkXbootY
- Fixes device parent/child relationship - added disks for boot partitions are children of main mmc block disk
- Adds "force_ro" block device attribute, which is set by default to "1" for boot partitions/
- Adds documentation.
Thanks,
A
PATCH v3 1/4 MMC: Rename erase_timeout to cmd_timeout_ms.
Renames erase_timeout to cmd_timeout_ms inside struct mmc_command. First step to making host honor timeouts for non-data-transfer commands. Cleans up erase timeout code.
--- drivers/mmc/core/core.c | 39 +++++++++++++++++++++------------------ include/linux/mmc/core.h | 2 +- 2 files changed, 22 insertions(+), 19 deletions(-)
drivers/mmc/core/core.c +21 -18
@@ -1187,9 +1187,8 @@ void mmc_init_erase(struct mmc_card *card) } } -static void mmc_set_mmc_erase_timeout (struct mmc_card *card, -struct mmc_command *cmd, -unsigned int arg,unsigned int qty) +static unsigned int mmc_mmc_erase_timeout (struct mmc_card *card, +unsigned int arg,unsigned int qty) {unsigned int erase_timeout;
@@ -1246,38 +1245,42 @@ static void mmc_set_mmc_erase_timeout(struct mmc_card *card,if (mmc_host_is_spi (card->host) && erase_timeout <1000 ) erase_timeout =1000 ; - cmd->erase_timeout = erase_timeout; +return erase_timeout; } -static void mmc_set_sd_erase_timeout (struct mmc_card *card, -struct mmc_command *cmd,unsigned int arg, -unsigned int qty) +static unsigned int mmc_sd_erase_timeout (struct mmc_card *card, +unsigned int arg, +unsigned int qty) { +unsigned int erase_timeout; +if (card->ssr.erase_timeout) {/* Erase timeout specified in SD Status Register (SSR) */ - cmd->erase_timeout = card->ssr.erase_timeout * qty + - card->ssr.erase_offset; + erase_timeout = card->ssr.erase_timeout * qty + + card->ssr.erase_offset; }else {/* * Erase timeout not specified in SD Status Register (SSR) so * use 250ms per write block. */ - cmd->erase_timeout =250 * qty; + erase_timeout =250 * qty; }/* Must not be less than 1 second */ -if (cmd->erase_timeout <1000 ) - cmd->erase_timeout =1000 ; +if (erase_timeout <1000 ) + erase_timeout =1000 ; + +return erase_timeout; } -static void mmc_set_erase_timeout (struct mmc_card *card, -struct mmc_command *cmd,unsigned int arg, -unsigned int qty) +static unsigned int mmc_erase_timeout (struct mmc_card *card, +unsigned int arg, +unsigned int qty) {if (mmc_card_sd (card)) -mmc_set_sd_erase_timeout (card, cmd, arg, qty); +return mmc_sd_erase_timeout (card, arg, qty);else -mmc_set_mmc_erase_timeout (card, cmd, arg, qty); +return mmc_mmc_erase_timeout (card, arg, qty); } static int mmc_do_erase(struct mmc_card *card, unsigned int from,
@@ -1351,7 +1354,7 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from, cmd.opcode =MMC_ERASE ; cmd.arg = arg; cmd.flags =MMC_RSP_SPI_R1B |MMC_RSP_R1B |MMC_CMD_AC ; -mmc_set_erase_timeout (card, &cmd, arg, qty); + cmd.cmd_timeout_ms =mmc_erase_timeout (card, arg, qty); err =mmc_wait_for_cmd (card->host, &cmd,0 );if (err) { printk(KERN_ERR "mmc_erase: erase error %d, status %#x\n",
include/linux/mmc/core.h +1 -1
@@ -92,7 +92,7 @@ struct mmc_command {* actively failing requests */ -unsigned int erase_timeout;/* in milliseconds */ +unsigned int cmd_timeout_ms;/* in milliseconds */ struct mmc_data *data;/* data segment associated with cmd */ struct mmc_request *mrq;/* associated request */
Signature · 1 line
1.7.0.4
PATCH v3 2/4 MMC: SDHCI R1B command handling + MMC_CAP_ERASE.
In reply to Andrei WarkentinERASE command needs R1B response, so fix R1B-type command handling for SDHCI controller. For non-DAT commands using a busy reponse, the cmd->cmd_timeout_ms (in ms) field is used for timeout calculations.
Based on patch by Chuanxiao Dong <[email protected]>
--- drivers/mmc/host/sdhci.c | 43 +++++++++++++++++++++++++++---------------- 1 files changed, 27 insertions(+), 16 deletions(-)
drivers/mmc/host/sdhci.c +27 -16
@@ -40,7 +40,6 @@static unsigned int debug_quirks =0 ; -static void sdhci_prepare_data (struct sdhci_host *,struct mmc_data *);static void sdhci_finish_data (struct sdhci_host *);static void sdhci_send_command (struct sdhci_host *,struct mmc_command *);
@@ -591,9 +590,10 @@ static void sdhci_adma_table_post(struct sdhci_host *host, data->sg_len, direction); } -static u8 sdhci_calc_timeout (struct sdhci_host *host,struct mmc_data *data) +static u8 sdhci_calc_timeout (struct sdhci_host *host,struct mmc_command *cmd) {u8 count; +struct mmc_data *data = cmd->data;unsigned target_timeout, current_timeout;/*
@@ -605,12 +605,16 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data)if (host->quirks &SDHCI_QUIRK_BROKEN_TIMEOUT_VAL )return 0xE ; -/* timeout in us */ - target_timeout = data->timeout_ns /1000 + - data->timeout_clks / host->clock; +/* Unspecified timeout, assume max */ +if (!data && !cmd->cmd_timeout_ms) +return 0xE ; -if (host->quirks &SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK ) - host->timeout_clk = host->clock /1000 ; +/* timeout in us */ +if (!data) + target_timeout = cmd->cmd_timeout_ms *1000 ; +else + target_timeout = data->timeout_ns /1000 + + data->timeout_clks / host->clock;/* * Figure out needed cycles.
@@ -632,8 +636,9 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data) }if (count >=0xF ) { -printk (KERN_WARNING "%s: Too large timeout requested!\n" , -mmc_hostname (host->mmc)); +printk (KERN_WARNING "%s: Too large timeout requested for CMD%d!\n" , +mmc_hostname (host->mmc), + cmd->opcode); count =0xE ; }
@@ -651,15 +656,21 @@ static void sdhci_set_transfer_irqs(struct sdhci_host *host)sdhci_clear_set_irqs (host, dma_irqs, pio_irqs); } -static void sdhci_prepare_data (struct sdhci_host *host,struct mmc_data *data) +static void sdhci_prepare_data (struct sdhci_host *host,struct mmc_command *cmd) {u8 count;u8 ctrl; +struct mmc_data *data = cmd->data;int ret;WARN_ON (host->data); -if (data ==NULL ) +if (data || (cmd->flags &MMC_RSP_BUSY )) { + count =sdhci_calc_timeout (host, cmd); +sdhci_writeb (host, count,SDHCI_TIMEOUT_CONTROL ); + } + +if (!data)return ;/* Sanity checks */
@@ -670,9 +681,6 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) host->data = data; host->data_early =0 ; - count =sdhci_calc_timeout (host, data); -sdhci_writeb (host, count,SDHCI_TIMEOUT_CONTROL ); -if (host->flags & (SDHCI_USE_SDMA |SDHCI_USE_ADMA )) host->flags |=SDHCI_REQ_USE_DMA ;
@@ -920,7 +928,7 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) host->cmd = cmd; -sdhci_prepare_data (host, cmd->data); +sdhci_prepare_data (host, cmd);sdhci_writel (host, cmd->arg,SDHCI_ARGUMENT );
@@ -1867,6 +1875,9 @@ int sdhci_add_host(struct sdhci_host *host)if (caps &SDHCI_TIMEOUT_CLK_UNIT ) host->timeout_clk *=1000 ; +if (host->quirks &SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK ) + host->timeout_clk = host->clock /1000 ; +/* * Set host parameters. */
@@ -1879,7 +1890,7 @@ int sdhci_add_host(struct sdhci_host *host) mmc->f_min = host->max_clk /SDHCI_MAX_DIV_SPEC_200 ; mmc->f_max = host->max_clk; - mmc->caps |=MMC_CAP_SDIO_IRQ ; + mmc->caps |=MMC_CAP_SDIO_IRQ |MMC_CAP_ERASE ;/* * A controller may support 8-bit width, but the board itself
Signature · 1 line
1.7.0.4
RE: [patchv3 2/4] MMC: SDHCI R1B command handling + MMC_CAP_ERASE.
Quoted 48 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Andrei Warkentin
Sent: Tuesday, April 12, 2011 5:14 AM
To: [email protected]
Cc: [email protected]; [email protected]; Andrei Warkentin
Subject: [patchv3 2/4] MMC: SDHCI R1B command handling +MMC_CAP_ERASE.ERASE command needs R1B response, so fix R1B-type command handling for SDHCI controller. For non-DAT commands using a busy reponse, the
cmd->cmd_timeout_ms(in ms) field is used for timeout calculations.Based on patch by Chuanxiao Dong <[email protected]>
Signed-off-by Andrei Warkentin <[email protected]>--- drivers/mmc/host/sdhci.c | 43 +++++++++++++++++++++++++++---------------- 1 files changed, 27 insertions(+), 16 deletions(-)drivers/mmc/host/sdhci.c +2
-2@@ -40,7 +40,6 @@static unsigned int debug_quirks =0 ; -static void sdhci_prepare_data (struct sdhci_host *,struct mmc_data *);static void sdhci_finish_data (struct sdhci_host *);static void sdhci_send_command (struct sdhci_host *,struct mmc_command *);@@ -591,9 +590,10 @@ static void sdhci_adma_table_post(struct sdhci_host *host, data->sg_len, direction); } -static u8 sdhci_calc_timeout (struct sdhci_host *host,struct mmc_data *data) +static u8 sdhci_calc_timeout (struct sdhci_host *host,struct mmc_command *cmd) {u8 count; +struct mmc_data *data = cmd->data;unsigned target_timeout, current_timeout;drivers/mmc/host/sdhci.c +0
-0/*
drivers/mmc/host/sdhci.c static u8 sdhci_calc_timeout(struct sdhci_host *host, · line 611
Quoted 10 lines
drivers/mmc/host/sdhci.c +3
-3@@ -605,12 +605,16 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data)if (host->quirks &SDHCI_QUIRK_BROKEN_TIMEOUT_VAL )return 0xE ; -/* timeout in us */ - target_timeout = data->timeout_ns /1000 + - data->timeout_clks / host->clock; +/* Unspecified timeout, assume max */ +if (!data && !cmd->cmd_timeout_ms) +return 0xE ;
Just a inline question here. I noticed cmd_timeout_ms only be set for the ERASE command and SWITCH command, for other types of commands, this value is left not initialized. Cmd_timeout_ms may not be zero and also not be initialized. And next, driver will use this value to calculate the timeout. So I think using an uninitialized value here doesn't make sense. If we want to use it, we have to make sure at this point, this value is already initialized.
drivers/mmc/host/sdhci.c static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data) · line 614
Quoted 6 lines
drivers/mmc/host/sdhci.c +3
-2-if (host->quirks &SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK ) - host->timeout_clk = host->clock /1000 ; +/* timeout in us */ +if (!data) + target_timeout = cmd->cmd_timeout_ms *1000 ;
That is where I concerned about the uninitialized cmd_timeout_ms.
Quoted 93 lines
drivers/mmc/host/sdhci.c +6
-2+else + target_timeout = data->timeout_ns /1000 + + data->timeout_clks / host->clock;/* * Figure out needed cycles. @@ -632,8 +636,9 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data) }if (count >=0xF ) { -printk (KERN_WARNING "%s: Too large timeout requested!\n" , -mmc_hostname (host->mmc)); + printk(KERN_WARNING "%s: Too large timeout requested for CMD%d!\n", + mmc_hostname(host->mmc), + cmd->opcode); count =0xE ;drivers/mmc/host/sdhci.c +8
-2}@@ -651,15 +656,21 @@ static void sdhci_set_transfer_irqs(struct sdhci_host *host)sdhci_clear_set_irqs (host, dma_irqs, pio_irqs); } -static void sdhci_prepare_data (struct sdhci_host *host,struct mmc_data *data) +static void sdhci_prepare_data (struct sdhci_host *host,struct mmc_command *cmd) {u8 count;u8 ctrl; +struct mmc_data *data = cmd->data;int ret;WARN_ON (host->data); -if (data ==NULL ) +if (data || (cmd->flags &MMC_RSP_BUSY )) { + count =sdhci_calc_timeout (host, cmd); +sdhci_writeb (host, count,SDHCI_TIMEOUT_CONTROL ); + } + +if (!data)return ;drivers/mmc/host/sdhci.c +5
-6/* Sanity checks */ @@ -670,9 +681,6 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) host->data = data; host->data_early =0 ; - count =sdhci_calc_timeout (host, data); -sdhci_writeb (host, count,SDHCI_TIMEOUT_CONTROL ); -if (host->flags & (SDHCI_USE_SDMA |SDHCI_USE_ADMA )) host->flags |=SDHCI_REQ_USE_DMA ;@@ -920,7 +928,7 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) host->cmd = cmd; -sdhci_prepare_data (host, cmd->data); +sdhci_prepare_data (host, cmd);sdhci_writel (host, cmd->arg,SDHCI_ARGUMENT );@@ -1867,6 +1875,9 @@ int sdhci_add_host(struct sdhci_host *host)if (caps &SDHCI_TIMEOUT_CLK_UNIT ) host->timeout_clk *=1000 ; +if (host->quirks &SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK ) + host->timeout_clk = host->clock /1000 ; +/* * Set host parameters. */ @@ -1879,7 +1890,7 @@ int sdhci_add_host(struct sdhci_host *host) mmc->f_min = host->max_clk /SDHCI_MAX_DIV_SPEC_200 ; mmc->f_max = host->max_clk; - mmc->caps |=MMC_CAP_SDIO_IRQ ; + mmc->caps |=MMC_CAP_SDIO_IRQ |MMC_CAP_ERASE ;/* * A controller may support 8-bit width, but the board itself -- 1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patchv3 2/4] MMC: SDHCI R1B command handling + MMC_CAP_ERASE.
Quoted 52 lines · Chuanxiao
Quoted 52 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Andrei Warkentin
Sent: Tuesday, April 12, 2011 5:14 AM
To: [email protected]
Cc: [email protected]; [email protected]; Andrei Warkentin
Subject: [patchv3 2/4] MMC: SDHCI R1B command handling +MMC_CAP_ERASE.ERASE command needs R1B response, so fix R1B-type command handling for SDHCI controller. For non-DAT commands using a busy reponse, the
cmd->cmd_timeout_ms(in ms) field is used for timeout calculations.Based on patch by Chuanxiao Dong <[email protected]>
Signed-off-by Andrei Warkentin <[email protected]>---
drivers/mmc/host/sdhci.c | 43 +++++++++++++++++++++++++++----------------1 files changed, 27 insertions(+), 16 deletions(-)drivers/mmc/host/sdhci.c +2
-2@@ -40,7 +40,6 @@ static unsigned int debug_quirks = 0; -static void sdhci_prepare_data (struct sdhci_host *,struct mmc_data *); static void sdhci_finish_data(struct sdhci_host *); static void sdhci_send_command(struct sdhci_host *, struct mmc_command *);@@ -591,9 +590,10 @@ static void sdhci_adma_table_post(struct sdhci_host *host, data->sg_len, direction); } -static u8 sdhci_calc_timeout (struct sdhci_host *host,struct mmc_data *data) +static u8 sdhci_calc_timeout (struct sdhci_host *host,struct mmc_command *cmd) { u8 count; + struct mmc_data *data = cmd->data; unsigned target_timeout, current_timeout;/*
drivers/mmc/host/sdhci.c +0
-0@@ -605,12 +605,16 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data) if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL) return 0xE;
Quoted 7 lines
drivers/mmc/host/sdhci.c static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data) · line 610
Quoted 6 lines
drivers/mmc/host/sdhci.c +3
-3- /* timeout in us */ - target_timeout = data->timeout_ns / 1000 + - data->timeout_clks / host->clock; + /* Unspecified timeout, assume max */ + if (!data && !cmd->cmd_timeout_ms) + return 0xE;Just a inline question here. I noticed
cmd_timeout_msonly be set for the ERASE command and SWITCH command, for other types of commands, this value is left not initialized.Cmd_timeout_msmay not be zero and also not be initialized. And next, driver will use this value to calculate the timeout. So I think using an uninitialized value here doesn't make sense. If we want to use it, we have to make sure at this point, this value is already initialized.
First, cmd_timeout only has meaning for non-DAT-transfer commands using DAT as a busy indicator. This is exactly why the cmd_timeout_ms affects the "data timeout" on the host. Hence - cmd_timeout_ms only makes sense for R1b commands. (R5b too, but that's SDIO land and I don't want to push support for something I can't verify) Second - if it's not initialized, it is zero (look in block.c, the entire brq is cleared to 0, look in mmc_ops, sd_ops, sdio_ops).
Remember, if !data and !cmd_timeout, then this must be a busy-wait command with no timeout specified, we pick the safe maximum of 0xE. Also again, this timeout has any meaning (and is only calculated) only if the command actually leverages the DAT line.
What commands are you interested in? There are not a lot of R1b commands. This patch addressed missing DAT timeout for R1b commands like erase, switch, etc.
Quoted 8 lines
drivers/mmc/host/sdhci.c static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data) · line 614
Quoted 7 lines
drivers/mmc/host/sdhci.c +3
-2- if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) - host->timeout_clk = host->clock / 1000; + /* timeout in us */ + if (!data) + target_timeout = cmd->cmd_timeout_ms * 1000;That is where I concerned about the uninitialized
cmd_timeout_ms.
You claim it's uninitialized, but it is zero because all consumers of mmc_command memset the structure to 0.
Quoted 95 lines
Quoted 94 lines
drivers/mmc/host/sdhci.c +6
-2+ else + target_timeout = data->timeout_ns / 1000 + + data->timeout_clks / host->clock; /** Figure out needed cycles. @@ -632,8 +636,9 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data) } if (count >= 0xF) { - printk(KERN_WARNING "%s: Too large timeout requested!\n", - mmc_hostname(host->mmc)); + printk(KERN_WARNING "%s: Too large timeout requested for CMD%d!\n", + mmc_hostname(host->mmc), + cmd->opcode); count = 0xE;}
drivers/mmc/host/sdhci.c +8
-2@@ -651,15 +656,21 @@ static void sdhci_set_transfer_irqs(struct sdhci_host *host) sdhci_clear_set_irqs(host, dma_irqs, pio_irqs); } -static void sdhci_prepare_data (struct sdhci_host *host,struct mmc_data *data) +static void sdhci_prepare_data (struct sdhci_host *host,struct mmc_command *cmd) { u8 count; u8 ctrl; + struct mmc_data *data = cmd->data; int ret; WARN_ON(host->data); - if (data == NULL) + if (data || (cmd->flags & MMC_RSP_BUSY)) { + count = sdhci_calc_timeout(host, cmd); + sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL); + } + + if (!data) return;/* Sanity checks */
drivers/mmc/host/sdhci.c +5
-6@@ -670,9 +681,6 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) host->data = data; host->data_early = 0; - count = sdhci_calc_timeout(host, data); - sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL); - if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) host->flags |= SDHCI_REQ_USE_DMA;@@ -920,7 +928,7 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) host->cmd = cmd; - sdhci_prepare_data(host, cmd->data); + sdhci_prepare_data(host, cmd); sdhci_writel(host, cmd->arg, SDHCI_ARGUMENT);@@ -1867,6 +1875,9 @@ int sdhci_add_host(struct sdhci_host *host) if (caps & SDHCI_TIMEOUT_CLK_UNIT) host->timeout_clk *= 1000; + if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) + host->timeout_clk = host->clock / 1000; + /** Set host parameters. */ @@ -1879,7 +1890,7 @@ int sdhci_add_host(struct sdhci_host *host) mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200; mmc->f_max = host->max_clk; - mmc->caps |= MMC_CAP_SDIO_IRQ; + mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE; /** A controller may support 8-bit width, but the board itself -- 1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [patchv3 2/4] MMC: SDHCI R1B command handling + MMC_CAP_ERASE.
Quoted 104 lines
-----Original Message-----
From: Andrei Warkentin [mailto:[email protected]]
Sent: Wednesday, April 13, 2011 2:05 AM
To: Dong, Chuanxiao
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [patchv3 2/4] MMC: SDHCI R1B command handling +MMC_CAP_ERASE.Quoted 9 lines · Chuanxiao
Quoted 9 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Andrei Warkentin
Sent: Tuesday, April 12, 2011 5:14 AM
To: [email protected]
Cc: [email protected]; [email protected]; Andrei Warkentin
Subject: [patchv3 2/4] MMC: SDHCI R1B command handling +
MMC_CAP_ERASE.Quoted 10 lines
Quoted 10 lines
ERASE command needs R1B response, so fix R1B-type command handling for SDHCI controller. For non-DAT commands using a busy reponse, the
cmd->cmd_timeout_ms(in ms) field is used for timeout calculations.Based on patch by Chuanxiao Dong <[email protected]>
Signed-off-by Andrei Warkentin <[email protected]>---
drivers/mmc/host/sdhci.c | 43+++++++++++++++++++++++++++----------------
Quoted 8 lines
Quoted 8 lines
1 files changed, 27 insertions(+), 16 deletions(-)drivers/mmc/host/sdhci.c +0
-0@@ -40,7 +40,6 @@Quoted 6 lines
Quoted 6 lines
drivers/mmc/host/sdhci.c +0
-1static unsigned int debug_quirks = 0; -static void sdhci_prepare_data (struct sdhci_host *,struct mmc_data *); static void sdhci_finish_data(struct sdhci_host *);static void sdhci_send_command(struct
sdhci_host*, structmmc_command*);
Quoted 19 lines
Quoted 19 lines
drivers/mmc/host/sdhci.c +2
-1@@ -591,9 +590,10 @@ static void sdhci_adma_table_post(struct sdhci_host *host, data->sg_len, direction); } -static u8 sdhci_calc_timeout (struct sdhci_host *host,struct mmc_data *data) +static u8 sdhci_calc_timeout (struct sdhci_host *host,struct mmc_command *cmd) { u8 count; + struct mmc_data *data = cmd->data; unsigned target_timeout, current_timeout;/*
drivers/mmc/host/sdhci.c +0
-0@@ -605,12 +605,16 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data) if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL) return 0xE;Quoted 7 lines
drivers/mmc/host/sdhci.c static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data) · line 610
Quoted 6 lines
drivers/mmc/host/sdhci.c +3
-3- /* timeout in us */ - target_timeout = data->timeout_ns / 1000 + - data->timeout_clks / host->clock; + /* Unspecified timeout, assume max */ + if (!data && !cmd->cmd_timeout_ms) + return 0xE;Just a inline question here. I noticed
cmd_timeout_msonly be set for the ERASEcommand and SWITCH command, for other types of commands, this value is left not initialized.
Cmd_timeout_msmay not be zero and also not be initialized. And next, driver will use this value to calculate the timeout. So I think using an uninitialized value here doesn't make sense. If we want to use it, we have to make sure at this point, this value is already initialized.First,
cmd_timeoutonly has meaning for non-DAT-transfer commands using DAT as a busy indicator. This is exactly why thecmd_timeout_msaffects the "data timeout" on the host. Hence -cmd_timeout_msonly makes sense for R1b commands. (R5b too, but that's SDIO land and I don't want to push support for something I can't verify) Second - if it's not initialized, it is zero (look inblock.c, the entire brq is cleared to 0, look inmmc_ops,sd_ops,sdio_ops).Remember, if !data and !cmd_timeout, then this must be a busy-wait command with no timeout specified, we pick the safe maximum of
0xE. Also again, this timeout has any meaning (and is only calculated) only if the command actually leverages the DAT line.What commands are you interested in? There are not a lot of R1b commands. This patch addressed missing DAT timeout for R1b commands like erase, switch, etc.
Quoted 7 lines
Quoted 7 lines
drivers/mmc/host/sdhci.c +3
-2- if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) - host->timeout_clk = host->clock / 1000; + /* timeout in us */ + if (!data) + target_timeout = cmd->cmd_timeout_ms * 1000;
Quoted 4 lines
Quoted 1 line
That is where I concerned about the uninitialized
cmd_timeout_ms.You claim it's uninitialized, but it is zero because all consumers of
mmc_commandmemset the structure to 0.
Yes, if all the consumers of mmc_command memset the structure to 0, there will be no problem. But just reviewed the code, and found mmc_app_cmd() (in sd_ops.c) didn't memset the command structure. So I think if we can make sure all the command structures will be initialized before using it, that would be better.
Quoted 98 lines
Quoted 22 lines
Quoted 22 lines
drivers/mmc/host/sdhci.c +6
-2+ else + target_timeout = data->timeout_ns / 1000 + + data->timeout_clks / host->clock; /** Figure out needed cycles. @@ -632,8 +636,9 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data) } if (count >= 0xF) { - printk(KERN_WARNING "%s: Too large timeout requested!\n", - mmc_hostname(host->mmc)); + printk(KERN_WARNING "%s: Too large timeout requested for CMD%d!\n", + mmc_hostname(host->mmc), + cmd->opcode); count = 0xE;}
Quoted 6 lines
drivers/mmc/host/sdhci.c static void sdhci_set_transfer_irqs(struct sdhci_host · line 655
Quoted 6 lines
drivers/mmc/host/sdhci.c +0
-1@@ -651,15 +656,21 @@ static void sdhci_set_transfer_irqs(struct sdhci_host *host) sdhci_clear_set_irqs(host, dma_irqs, pio_irqs); } -static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data*data)
Quoted 25 lines
Quoted 25 lines
drivers/mmc/host/sdhci.c +8
-1+static void sdhci_prepare_data (struct sdhci_host *host,struct mmc_command *cmd) { u8 count; u8 ctrl; + struct mmc_data *data = cmd->data; int ret; WARN_ON(host->data); - if (data == NULL) + if (data || (cmd->flags & MMC_RSP_BUSY)) { + count = sdhci_calc_timeout(host, cmd); + sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL); + } + + if (!data) return;/* Sanity checks */
drivers/mmc/host/sdhci.c +0
-0@@ -670,9 +681,6 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) host->data = data; host->data_early = 0;Quoted 7 lines
drivers/mmc/host/sdhci.c static void sdhci_send_command(struct sdhci_host
Quoted 7 lines
drivers/mmc/host/sdhci.c +0
-3- count = sdhci_calc_timeout(host, data); - sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL); - if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) host->flags |= SDHCI_REQ_USE_DMA;@@ -920,7 +928,7 @@ static void sdhci_send_command(struct sdhci_host*host,
Quoted 36 lines
Quoted 35 lines
drivers/mmc/host/sdhci.c +5
-3struct mmc_command *cmd) host->cmd = cmd; - sdhci_prepare_data(host, cmd->data); + sdhci_prepare_data(host, cmd); sdhci_writel(host, cmd->arg, SDHCI_ARGUMENT);@@ -1867,6 +1875,9 @@ int sdhci_add_host(struct sdhci_host *host) if (caps & SDHCI_TIMEOUT_CLK_UNIT) host->timeout_clk *= 1000; + if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) + host->timeout_clk = host->clock / 1000; + /** Set host parameters. */ @@ -1879,7 +1890,7 @@ int sdhci_add_host(struct sdhci_host *host) mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200; mmc->f_max = host->max_clk; - mmc->caps |= MMC_CAP_SDIO_IRQ; + mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE; /** A controller may support 8-bit width, but the board itself -- 1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patchv3 2/4] MMC: SDHCI R1B command handling + MMC_CAP_ERASE.
Quoted 1 line · Chuanxiao
Yes, if all the consumers of
mmc_commandmemset the structure to 0, there will be no problem. But just reviewed the code, and foundmmc_app_cmd()(insd_ops.c) didn't memset the command structure. So I think if we can make sure all the command structures will be initialized before using it, that would be better.
I would say that CMD55 is not a command that utilizes the DAT line, again, so not setting cmd_timeout itself is not a problem.
However, using uninitialized data is nasty, and can lead to problems if cmd->data ever happens to be not NULL.
I'll send a patch for this tomorrow. Thanks for catching this. I'm curious if this is the reason behind Cyril's problem.
Cyril can you try modifying mmc_app_cmd like this? Does that do anything for you?
static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card)
{
int err;
struct mmc_command cmd;
BUG_ON(!host);
BUG_ON(card && (card->host != host));+ memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = MMC_APP_CMD;A
Re: [patchv3 2/4] MMC: SDHCI R1B command handling + MMC_CAP_ERASE.
Hi!
Quoted 25 lines
Quoted 5 lines
Yes, if all the consumers of
mmc_commandmemset the structure to 0, there will be no problem. But just reviewed the code, and foundmmc_app_cmd()(insd_ops.c) didn't memset the command structure. So I think if we can make sure all the command structures will be initialized before using it, that would be better.I would say that CMD55 is not a command that utilizes the DAT line, again, so not setting
cmd_timeoutitself is not a problem.However, using uninitialized data is nasty, and can lead to problems if
cmd->dataever happens to be not NULL.
I'll send a patch for this tomorrow. Thanks for catching this. I'm curious if this is the reason behind Cyril's problem.Cyril can you try modifying
mmc_app_cmdlike this? Does that do anything for you?static int
mmc_app_cmd(struct mmc_host *host, struct mmc_card *card){ int err; struct mmc_command cmd; BUG_ON(!host); BUG_ON(card && (card->host != host));
Quoted 3 lines
+ memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = MMC_APP_CMD;Not really, it behaves same regardless the memset().
Signature · 1 line
metan
Re: [patchv3 2/4] MMC: SDHCI R1B command handling + MMC_CAP_ERASE.
In reply to Andrei WarkentinHi Andrei,
Quoted 7 lines · Andrei Warkentin
ERASE command needs R1B response, so fix R1B-type command handling for SDHCI controller. For non-DAT commands using a busy reponse, the
cmd->cmd_timeout_ms(in ms) field is used for timeout calculations.Based on patch by Chuanxiao Dong <[email protected]>
Signed-off-by Andrei Warkentin <[email protected]>
Looks like this patch has been implicated in causing IO errors on ThinkPads with a Ricoh device -- please could you take a look at
https://bugzilla.kernel.org/show_bug.cgi?id=38922 ?
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
PATCH v3 3/4 MMC: Allow setting CMD timeout for CMD6 (SWITCH).
In reply to Andrei WarkentinCMD6 is R1B-type command, where DAT is used as busy. Depending on register written using CMD6, timeout value can be different as per spec.
--- drivers/mmc/core/mmc.c | 14 ++++++++------ drivers/mmc/core/mmc_ops.c | 17 ++++++++++++++++- drivers/mmc/core/mmc_ops.h | 1 - include/linux/mmc/core.h | 1 + 4 files changed, 25 insertions(+), 8 deletions(-)
drivers/mmc/core/mmc.c +8 -6
@@ -548,7 +548,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,*/ if (card->ext_csd.enhanced_area_en) { err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_ERASE_GROUP_DEF ,1 ); +EXT_CSD_ERASE_GROUP_DEF ,1 ,0 );if (err && err != -EBADMSG ) goto free_card;
@@ -579,7 +579,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,if (card->ext_csd.bootconfig &0x7 ) { card->ext_csd.bootconfig &= ~0x7 ;mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_BOOT_CONFIG , - card->ext_csd.bootconfig); + card->ext_csd.bootconfig,0 ); }/*
@@ -588,7 +588,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,if ((card->ext_csd.hs_max_dtr !=0 ) && (host->caps &MMC_CAP_MMC_HIGHSPEED )) { err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_HS_TIMING ,1 ); +EXT_CSD_HS_TIMING ,1 ,0 );if (err && err != -EBADMSG ) goto free_card;
@@ -655,7 +655,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, ddr =0 ;/* no DDR for 1-bit width */ err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_BUS_WIDTH , - ext_csd_bits[idx][0 ]); + ext_csd_bits[idx][0 ], +0 );if (!err) {mmc_set_bus_width_ddr (card->host, bus_width,MMC_SDR_MODE );
@@ -674,8 +675,9 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,if (!err && ddr) { err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_BUS_WIDTH , - ext_csd_bits[idx][1 ]); +EXT_CSD_BUS_WIDTH , + ext_csd_bits[idx][1 ], +0 ); }if (err) { printk(KERN_WARNING "%s: switch to bus width %d ddr %d "
drivers/mmc/core/mmc_ops.c +16 -1
@@ -387,7 +387,19 @@ int mmc_spi_set_crc(struct mmc_host *host, int use_crc)return err; } -int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value) +/** +* mmc_switch - modify EXT_CSD register +* @card: the MMC card associated with the data transfer +* @set: cmd set values +* @index: EXT_CSD register index +* @value: value to program into EXT_CSD register +* @timeout_ms: timeout (ms) for operation performed by register write, +* timeout of zero implies maximum possible timeout +* +* Modifies the EXT_CSD register for selected card. +*/ +int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value, +unsigned int timeout_ms) {int err;struct mmc_command cmd;
@@ -404,6 +416,7 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value) (value <<8 ) | set; cmd.flags =MMC_RSP_SPI_R1B |MMC_RSP_R1B |MMC_CMD_AC ; + cmd.cmd_timeout_ms = timeout_ms; err =mmc_wait_for_cmd (card->host, &cmd,MMC_CMD_RETRIES );if (err)
@@ -434,6 +447,8 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value)return 0 ; } +EXPORT_SYMBOL (mmc_switch); +int mmc_send_status (struct mmc_card *card,u32 *status) {int err;
drivers/mmc/core/mmc_ops.h +0 -1
@@ -20,7 +20,6 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid);int mmc_set_relative_addr (struct mmc_card *card);int mmc_send_csd (struct mmc_card *card,u32 *csd);int mmc_send_ext_csd (struct mmc_card *card,u8 *ext_csd); -int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value);int mmc_send_status (struct mmc_card *card,u32 *status);int mmc_send_cid (struct mmc_host *host,u32 *cid);int mmc_spi_read_ocr (struct mmc_host *host,int highcap,u32 *ocrp);
include/linux/mmc/core.h +1 -0
@@ -135,6 +135,7 @@ extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);extern int mmc_wait_for_cmd (struct mmc_host *,struct mmc_command *,int );extern int mmc_wait_for_app_cmd (struct mmc_host *,struct mmc_card *,struct mmc_command *,int ); +extern int mmc_switch (struct mmc_card *,u8 ,u8 ,u8 ,unsigned int );#define MMC_ERASE_ARG 0x00000000#define MMC_SECURE_ERASE_ARG 0x80000000
Signature · 1 line
1.7.0.4
PATCH v3 4/4 MMC: MMC boot partitions support.
In reply to Andrei WarkentinAllows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
--- Documentation/mmc/00-INDEX | 2 + Documentation/mmc/mmc-dev-attrs.txt | 10 ++ Documentation/mmc/mmc-dev-parts.txt | 26 +++ drivers/mmc/card/block.c | 305 +++++++++++++++++++++++++++++------ drivers/mmc/core/mmc.c | 22 ++- include/linux/mmc/card.h | 4 +- include/linux/mmc/mmc.h | 8 +- 7 files changed, 317 insertions(+), 60 deletions(-) create mode 100644 Documentation/mmc/mmc-dev-parts.txt
Documentation/mmc/00-INDEX +2 -0
@@ -2,3 +2,5 @@ - this file mmc-dev-attrs.txt - info on SD and MMC device attributes +mmc-dev-parts.txt + - info on SD and MMC device partitions
Documentation/mmc/mmc-dev-attrs.txt +10 -0
@@ -1,3 +1,13 @@ +SD and MMC Block Device Attributes +================================== + +These attributes are defined for the block devices associated with the +SD or MMC device. + +The following attributes are read/write. + + force_ro Enforce read-only access even if write protect switch is off. + SD and MMC Device Attributes ============================
Documentation/mmc/mmc-dev-parts.txt new file +26 -0
@@ -0,0 +1,26 @@ +SD and MMC Device Partitions +============================ + +Device partitions are additional logical block devices present +on the SD/MMC device. + +As of this writing, MMC boot partitions as supported and exposed as +/dev/mmcblkXboot0 and /dev/mmcblkXboot1, where X is the index of the +parent /dev/mmcblkX. + +MMC Boot Partitions +=================== + +Read and write access is provided to the two MMC boot partitions. Due +to the sensitive nature of the boot partition contents, which often store +a bootloader or bootloader configuration tables crucial to booting the platform, +write access is by default disabled to reduce the chance of accidental bricking. + +To enable write access to /dev/mmcblkXbootY, disable the forced read-only +access: + +echo 0 > /sys/block/mmcblkXbootY/force_ro + +To re-enable read-only access: + +echo 1 > /sys/block/mmcblkXbootY/force_ro
drivers/mmc/card/block.c +252 -53
482 lines not on this page · raw message
drivers/mmc/core/mmc.c +17 -5
@@ -288,7 +288,10 @@ static int mmc_read_ext_csd(struct mmc_card *card)if (card->ext_csd.rev >=3 ) {u8 sa_shift = ext_csd[EXT_CSD_S_A_TIMEOUT ]; - card->ext_csd.bootconfig = ext_csd[EXT_CSD_BOOT_CONFIG ]; + card->ext_csd.part_config = ext_csd[EXT_CSD_PART_CONFIG ]; + +/* EXT_CSD value is in units of 10ms, but we store in ms */ + card->ext_csd.part_time =10 * ext_csd[EXT_CSD_PART_SWITCH_TIME ];/* Sleep / awake timeout in 100ns units */ if (sa_shift >0 && sa_shift <=0x17 )
@@ -302,6 +305,12 @@ static int mmc_read_ext_csd(struct mmc_card *card) ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE ] <<10 ; card->ext_csd.rel_sectors = ext_csd[EXT_CSD_REL_WR_SEC_C ]; + +/* +* 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 ; }if (card->ext_csd.rev >=4 ) {
@@ -576,10 +585,13 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,/* * Ensure eMMC user default partition is enabled */ -if (card->ext_csd.bootconfig &0x7 ) { - card->ext_csd.bootconfig &= ~0x7 ; -mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_BOOT_CONFIG , - card->ext_csd.bootconfig,0 ); +if (card->ext_csd.part_config &EXT_CSD_PART_CONFIG_ACC_MASK ) { + card->ext_csd.part_config &= ~EXT_CSD_PART_CONFIG_ACC_MASK ; + err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_PART_CONFIG , + card->ext_csd.part_config, + card->ext_csd.part_time); +if (err && err != -EBADMSG ) + goto free_card; }/*
include/linux/mmc/card.h +3 -1
@@ -47,7 +47,8 @@ struct mmc_ext_csd {u8 sec_feature_support;u8 rel_sectors;u8 rel_param; -u8 bootconfig; +u8 part_config; +unsigned int part_time;/* Units: ms */ unsigned int sa_timeout;/* Units: 100ns */ unsigned int hs_max_dtr;unsigned int sectors;
@@ -60,6 +61,7 @@ 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 */ };struct sd_scr {
include/linux/mmc/mmc.h +7 -1
@@ -257,19 +257,21 @@ struct _mmc_csd {#define EXT_CSD_PARTITION_SUPPORT 160/* RO */ #define EXT_CSD_WR_REL_PARAM 166/* RO */ #define EXT_CSD_ERASE_GROUP_DEF 175/* R/W */ -#define EXT_CSD_BOOT_CONFIG 179/* R/W */ +#define EXT_CSD_PART_CONFIG 179/* R/W */ #define EXT_CSD_ERASED_MEM_CONT 181/* RO */ #define EXT_CSD_BUS_WIDTH 183/* R/W */ #define EXT_CSD_HS_TIMING 185/* R/W */ #define EXT_CSD_REV 192/* RO */ #define EXT_CSD_STRUCTURE 194/* RO */ #define EXT_CSD_CARD_TYPE 196/* RO */ +#define EXT_CSD_PART_SWITCH_TIME 199/* RO */ #define EXT_CSD_SEC_CNT 212/* RO, 4 bytes */ #define EXT_CSD_S_A_TIMEOUT 217/* RO */ #define EXT_CSD_REL_WR_SEC_C 222/* RO */ #define EXT_CSD_HC_WP_GRP_SIZE 221/* RO */ #define EXT_CSD_ERASE_TIMEOUT_MULT 223/* RO */ #define EXT_CSD_HC_ERASE_GRP_SIZE 224/* RO */ +#define EXT_CSD_BOOT_MULT 226/* RO */ #define EXT_CSD_SEC_TRIM_MULT 229/* RO */ #define EXT_CSD_SEC_ERASE_MULT 230/* RO */ #define EXT_CSD_SEC_FEATURE_SUPPORT 231/* RO */
@@ -281,6 +283,10 @@ 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)#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
Signature · 1 line
1.7.0.4
Re: [patchv3 4/4] MMC: MMC boot partitions support.
Hi Andrei,
Quoted 6 lines · Andrei Warkentin
Allows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
Acked-by Arnd Bergmann <[email protected]>Signed-off-by Andrei Warkentin <[email protected]>
Looks fine, but would you mind breaking out the {claim,release}_host changes around mmc_blk_issue_rq() into a separate patch? It doesn't look like they're obviously related to the partitioning support, but maybe I'm missing something.
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [patchv3 4/4] MMC: MMC boot partitions support.
Quoted 7 lines · Chris Ball
Hi Andrei,
Quoted 4 lines · Andrei Warkentin
Allows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
Quoted 8 lines
Quoted 2 lines
Acked-by Arnd Bergmann <[email protected]>Signed-off-by Andrei Warkentin <[email protected]>Looks fine, but would you mind breaking out the {claim,release}_host changes around
mmc_blk_issue_rq()into a separate patch? It doesn't look like they're obviously related to the partitioning support, but maybe I'm missing something.
So it was one of the two -
a) stick mmc_bkl_part_switch into mmc_blk_issue_secdiscard_rq, mmc_blk_issue_discard_rq, and mmc_blk_issue_rw_rq.
b) Move claim/release into mmc_blk_issue_rq and put partition switch code into one place.
(b) is cleaner. What do you think?
A
Re: [patchv3 4/4] MMC: MMC boot partitions support.
Hi Andrei,
Quoted 7 lines · Andrei Warkentin
So it was one of the two -
a) stickmmc_bkl_part_switchintommc_blk_issue_secdiscard_rq,mmc_blk_issue_discard_rq, andmmc_blk_issue_rw_rq.
b) Move claim/release intommc_blk_issue_rqand put partition switch code into one place.(b) is cleaner. What do you think?
Thanks, I see.
(b) is definitely fine -- I'm suggesting one patch to push claim/release up into mmc_blk_issue_rq() (which should have no other side-effects), and then a second patch to add partitioning support and also insert the single mmc_blk_part_switch() into the right place. Does that make sense?
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [patchv3 4/4] MMC: MMC boot partitions support.
Quoted 9 lines · Chris Ball
Hi Andrei,
Quoted 6 lines · Andrei Warkentin
So it was one of the two -
a) stickmmc_bkl_part_switchintommc_blk_issue_secdiscard_rq,mmc_blk_issue_discard_rq, andmmc_blk_issue_rw_rq.
b) Move claim/release intommc_blk_issue_rqand put partition switch code into one place.
Quoted 9 lines
Quoted 1 line
(b) is cleaner. What do you think?
Thanks, I see.
(b) is definitely fine -- I'm suggesting one patch to push claim/release up into
mmc_blk_issue_rq()(which should have no other side-effects), and then a second patch to add partitioning support and also insert the singlemmc_blk_part_switch()into the right place. Does that make sense?
Ok, great! Will do.
A
PATCH v4 1/2 MMC: block.c cleanup for host claim/release.
Move host claim/release into mmc_blk_issue_rq.
--- drivers/mmc/card/block.c | 31 +++++++++++++------------------ 1 files changed, 13 insertions(+), 18 deletions(-)
drivers/mmc/card/block.c +13 -18
@@ -273,8 +273,6 @@ static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)unsigned int from, nr, arg;int err =0 ; -mmc_claim_host (card->host); -if (!mmc_can_erase (card)) { err = -EOPNOTSUPP ; goto out;
@@ -294,8 +292,6 @@ out:__blk_end_request (req, err,blk_rq_bytes (req));spin_unlock_irq (&md->lock); -mmc_release_host (card->host); -return err ?0 :1 ; }
@@ -307,8 +303,6 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,unsigned int from, nr, arg;int err =0 ; -mmc_claim_host (card->host); -if (!mmc_can_secure_erase_trim (card)) { err = -EOPNOTSUPP ; goto out;
@@ -330,8 +324,6 @@ out:__blk_end_request (req, err,blk_rq_bytes (req));spin_unlock_irq (&md->lock); -mmc_release_host (card->host); -return err ?0 :1 ; }
@@ -402,8 +394,6 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req) (rq_data_dir (req) ==WRITE ) &&REL_WRITES_SUPPORTED (card); -mmc_claim_host (card->host); - do { struct mmc_command cmd; u32 readcmd, writecmd, status = 0;
@@ -589,8 +579,6 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)spin_unlock_irq (&md->lock); }while (ret); -mmc_release_host (card->host); -return 1 ; cmd_err:
@@ -617,8 +605,6 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)spin_unlock_irq (&md->lock); } -mmc_release_host (card->host); -spin_lock_irq (&md->lock);while (ret) ret =__blk_end_request (req, -EIO ,blk_rq_cur_bytes (req));
@@ -629,16 +615,25 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)static int mmc_blk_issue_rq (struct mmc_queue *mq,struct request *req) { +int ret; +struct mmc_blk_data *md = mq->data; +struct mmc_card *card = md->queue.card; + +mmc_claim_host (card->host); +if (req->cmd_flags &REQ_DISCARD ) {if (req->cmd_flags &REQ_SECURE ) -return mmc_blk_issue_secdiscard_rq (mq, req); + ret =mmc_blk_issue_secdiscard_rq (mq, req);else -return mmc_blk_issue_discard_rq (mq, req); + ret =mmc_blk_issue_discard_rq (mq, req); }else if (req->cmd_flags &REQ_FLUSH ) { -return mmc_blk_issue_flush (mq, req); + ret =mmc_blk_issue_flush (mq, req); }else { -return mmc_blk_issue_rw_rq (mq, req); + ret =mmc_blk_issue_rw_rq (mq, req); } + +mmc_release_host (card->host); +return ret; }static inline int mmc_blk_readonly (struct mmc_card *card)
Signature · 1 line
1.7.0.4
PATCH v4 2/2 MMC: MMC boot partitions support.
In reply to Andrei WarkentinAllows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
--- Documentation/mmc/00-INDEX | 2 + Documentation/mmc/mmc-dev-attrs.txt | 10 ++ Documentation/mmc/mmc-dev-parts.txt | 26 ++++ drivers/mmc/card/block.c | 274 ++++++++++++++++++++++++++++++----- drivers/mmc/core/mmc.c | 22 ++- include/linux/mmc/card.h | 4 +- include/linux/mmc/mmc.h | 8 +- 7 files changed, 304 insertions(+), 42 deletions(-) create mode 100644 Documentation/mmc/mmc-dev-parts.txt
Documentation/mmc/00-INDEX +2 -0
@@ -2,3 +2,5 @@ - this file mmc-dev-attrs.txt - info on SD and MMC device attributes +mmc-dev-parts.txt + - info on SD and MMC device partitions
Documentation/mmc/mmc-dev-attrs.txt +10 -0
@@ -1,3 +1,13 @@ +SD and MMC Block Device Attributes +================================== + +These attributes are defined for the block devices associated with the +SD or MMC device. + +The following attributes are read/write. + + force_ro Enforce read-only access even if write protect switch is off. + SD and MMC Device Attributes ============================
Documentation/mmc/mmc-dev-parts.txt new file +26 -0
@@ -0,0 +1,26 @@ +SD and MMC Device Partitions +============================ + +Device partitions are additional logical block devices present +on the SD/MMC device. + +As of this writing, MMC boot partitions as supported and exposed as +/dev/mmcblkXboot0 and /dev/mmcblkXboot1, where X is the index of the +parent /dev/mmcblkX. + +MMC Boot Partitions +=================== + +Read and write access is provided to the two MMC boot partitions. Due +to the sensitive nature of the boot partition contents, which often store +a bootloader or bootloader configuration tables crucial to booting the platform, +write access is by default disabled to reduce the chance of accidental bricking. + +To enable write access to /dev/mmcblkXbootY, disable the forced read-only +access: + +echo 0 > /sys/block/mmcblkXbootY/force_ro + +To re-enable read-only access: + +echo 1 > /sys/block/mmcblkXbootY/force_ro
drivers/mmc/card/block.c +239 -35
409 lines not on this page · raw message
drivers/mmc/core/mmc.c +17 -5
@@ -288,7 +288,10 @@ static int mmc_read_ext_csd(struct mmc_card *card)if (card->ext_csd.rev >=3 ) {u8 sa_shift = ext_csd[EXT_CSD_S_A_TIMEOUT ]; - card->ext_csd.bootconfig = ext_csd[EXT_CSD_BOOT_CONFIG ]; + card->ext_csd.part_config = ext_csd[EXT_CSD_PART_CONFIG ]; + +/* EXT_CSD value is in units of 10ms, but we store in ms */ + card->ext_csd.part_time =10 * ext_csd[EXT_CSD_PART_SWITCH_TIME ];/* Sleep / awake timeout in 100ns units */ if (sa_shift >0 && sa_shift <=0x17 )
@@ -302,6 +305,12 @@ static int mmc_read_ext_csd(struct mmc_card *card) ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE ] <<10 ; card->ext_csd.rel_sectors = ext_csd[EXT_CSD_REL_WR_SEC_C ]; + +/* +* 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 ; }if (card->ext_csd.rev >=4 ) {
@@ -576,10 +585,13 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,/* * Ensure eMMC user default partition is enabled */ -if (card->ext_csd.bootconfig &0x7 ) { - card->ext_csd.bootconfig &= ~0x7 ; -mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_BOOT_CONFIG , - card->ext_csd.bootconfig,0 ); +if (card->ext_csd.part_config &EXT_CSD_PART_CONFIG_ACC_MASK ) { + card->ext_csd.part_config &= ~EXT_CSD_PART_CONFIG_ACC_MASK ; + err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_PART_CONFIG , + card->ext_csd.part_config, + card->ext_csd.part_time); +if (err && err != -EBADMSG ) + goto free_card; }/*
include/linux/mmc/card.h +3 -1
@@ -48,7 +48,8 @@ struct mmc_ext_csd {u8 sec_feature_support;u8 rel_sectors;u8 rel_param; -u8 bootconfig; +u8 part_config; +unsigned int part_time;/* Units: ms */ unsigned int sa_timeout;/* Units: 100ns */ unsigned int hs_max_dtr;unsigned int sectors;
@@ -61,6 +62,7 @@ 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 */ };struct sd_scr {
include/linux/mmc/mmc.h +7 -1
@@ -257,19 +257,21 @@ struct _mmc_csd {#define EXT_CSD_PARTITION_SUPPORT 160/* RO */ #define EXT_CSD_WR_REL_PARAM 166/* RO */ #define EXT_CSD_ERASE_GROUP_DEF 175/* R/W */ -#define EXT_CSD_BOOT_CONFIG 179/* R/W */ +#define EXT_CSD_PART_CONFIG 179/* R/W */ #define EXT_CSD_ERASED_MEM_CONT 181/* RO */ #define EXT_CSD_BUS_WIDTH 183/* R/W */ #define EXT_CSD_HS_TIMING 185/* R/W */ #define EXT_CSD_REV 192/* RO */ #define EXT_CSD_STRUCTURE 194/* RO */ #define EXT_CSD_CARD_TYPE 196/* RO */ +#define EXT_CSD_PART_SWITCH_TIME 199/* RO */ #define EXT_CSD_SEC_CNT 212/* RO, 4 bytes */ #define EXT_CSD_S_A_TIMEOUT 217/* RO */ #define EXT_CSD_REL_WR_SEC_C 222/* RO */ #define EXT_CSD_HC_WP_GRP_SIZE 221/* RO */ #define EXT_CSD_ERASE_TIMEOUT_MULT 223/* RO */ #define EXT_CSD_HC_ERASE_GRP_SIZE 224/* RO */ +#define EXT_CSD_BOOT_MULT 226/* RO */ #define EXT_CSD_SEC_TRIM_MULT 229/* RO */ #define EXT_CSD_SEC_ERASE_MULT 230/* RO */ #define EXT_CSD_SEC_FEATURE_SUPPORT 231/* RO */
@@ -281,6 +283,10 @@ 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)#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
Signature · 1 line
1.7.0.4
Re: [patchv3 4/4] MMC: MMC boot partitions support.
In reply to Andrei WarkentinHi Andrei,
Quoted 1 line · Andrei Warkentin
Ok, great! Will do.
Great, thanks. I've just merged:
mmc: quirks: Extends card quirks with MMC/SD quirks matching the CID. [patchv3 1/4] MMC: Rename erase_timeout to cmd_timeout_ms. [patchv3 2/4] MMC: SDHCI R1B command handling + MMC_CAP_ERASE. [patchv3 3/4] MMC: Allow setting CMD timeout for CMD6 (SWITCH). [patchv4 1/2] MMC: block.c cleanup for host claim/release. [patchv4 2/2] MMC: MMC boot partitions support.
[PATCH 1/2] MMC: Support for block quirks.
^ this had a merge conflict with the partitions patch, easily resolved.
[PATCH 2/2] MMC: Fix erase/trim for certain SanDisk cards.
in that order, and will push out to mmc-next for .40 after a little testing. Let me know if anything's been missed or applied in the wrong order there.
Thanks very much,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [patchv3 4/4] MMC: MMC boot partitions support.
Quoted 17 lines · Chris Ball
Hi Andrei,
Quoted 1 line · Andrei Warkentin
Ok, great! Will do.
Great, thanks. I've just merged:
mmc: quirks: Extends card quirks with MMC/SD quirks matching the CID. [patchv3 1/4] MMC: Rename
erase_timeouttocmd_timeout_ms. [patchv3 2/4] MMC: SDHCI R1B command handling +MMC_CAP_ERASE. [patchv3 3/4] MMC: Allow setting CMD timeout for CMD6 (SWITCH). [patchv4 1/2] MMC:block.ccleanup for host claim/release. [patchv4 2/2] MMC: MMC boot partitions support.
[PATCH 1/2] MMC: Support for block quirks.
^ this had a merge conflict with the partitions patch, easily resolved. [PATCH 2/2] MMC: Fix erase/trim for certain SanDisk cards.
Quoted 3 lines
in that order, and will push out to mmc-next for .40 after a little testing. Let me know if anything's been missed or applied in the wrong order there.
Should be alright.
Thanks,
A
Re: [patchv3 4/4] MMC: MMC boot partitions support.
In reply to Andrei WarkentinHi Andrei,
Quoted 3 lines · Andrei Warkentin
Allows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
Booted this with a Sandisk SEM04G eMMC:
[ 2.469921] mmcblk0boot0: mmc2:0001 SEM04G partition 1 1.00 MiB [ 2.475905] mmcblk0boot1: mmc2:0001 SEM04G partition 2 1.00 MiB [ 2.489403] mmcblk0boot1: unknown partition table [ 2.495921] mmcblk0boot0: unknown partition table
I haven't set up any boot partitions explicitly, so I guess the two 1MiB boot partitions might be the factory-default setting. Out of curiosity, does that match your experience with Sandisk eMMCs?
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [patchv3 4/4] MMC: MMC boot partitions support.
Hi,
Quoted 7 lines · Chris Ball
Quoted 3 lines · Andrei Warkentin
Allows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
Booted this with a Sandisk SEM04G eMMC:
Quoted 8 lines
[ 2.469921] mmcblk0boot0: mmc2:0001 SEM04G partition 1 1.00 MiB [ 2.475905] mmcblk0boot1: mmc2:0001 SEM04G partition 2 1.00 MiB [ 2.489403] mmcblk0boot1: unknown partition table [ 2.495921] mmcblk0boot0: unknown partition tableI haven't set up any boot partitions explicitly, so I guess the two 1MiB boot partitions might be the factory-default setting. Out of curiosity, does that match your experience with Sandisk eMMCs?
Also, on inserting an external SD card I see:
[ 2.485079] mmcblk0: mmc2:0001 SEM04G 3.68 GiB [ 2.489681] mmcblk0boot0: mmc2:0001 SEM04G partition 1 1.00 MiB [ 2.495681] mmcblk0boot1: mmc2:0001 SEM04G partition 2 1.00 MiB [ 2.503756] mmcblk0: p1 p2 [ 2.509303] mmcblk0boot1: unknown partition table [ 2.515343] mmcblk0boot0: unknown partition table [ 4.828326] EXT3-fs (mmcblk0p2): warning: maximal mount count reached, running e2fsc k is recommended [ 4.845214] EXT3-fs (mmcblk0p2): using internal journal [ 4.845223] EXT3-fs (mmcblk0p2): recovery complete [ 4.857131] EXT3-fs (mmcblk0p2): mounted filesystem with ordered data mode [ 20.886514] mmc0: new high speed SDHC card at address d555 [ 20.904282] mmcblk3: mmc0:d555 SD04G 3.79 GiB [ 20.906926] mmcblk3: p1
But I would have expected this to be mmcblk1 -- might the boot partitions be using up mmcblk1/2 somehow?
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [patchv3 4/4] MMC: MMC boot partitions support.
Chris,
I have also seen this on mmc-next.
Quoted 2 lines
Quoted 2 lines
[ 2.489403] mmcblk0boot1: unknown partition table [ 2.495921] mmcblk0boot0: unknown partition table
Aren't these the "hidden" partitions ? Only available at boot time?
I need to apply my patch to reset the boot partition -- or is that now in mmc-next to see if the problem still happens.
Philip
Quoted 49 lines · Chris Ball
Hi,
Quoted 7 lines · Chris Ball
Quoted 3 lines · Andrei Warkentin
Allows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
Booted this with a Sandisk SEM04G eMMC:
Quoted 8 lines
[ 2.469921] mmcblk0boot0: mmc2:0001 SEM04G partition 1 1.00 MiB [ 2.475905] mmcblk0boot1: mmc2:0001 SEM04G partition 2 1.00 MiB [ 2.489403] mmcblk0boot1: unknown partition table [ 2.495921] mmcblk0boot0: unknown partition tableI haven't set up any boot partitions explicitly, so I guess the two 1MiB boot partitions might be the factory-default setting. Out of curiosity, does that match your experience with Sandisk eMMCs?
Also, on inserting an external SD card I see:
[ 2.485079] mmcblk0: mmc2:0001 SEM04G 3.68 GiB [ 2.489681] mmcblk0boot0: mmc2:0001 SEM04G partition 1 1.00 MiB [ 2.495681] mmcblk0boot1: mmc2:0001 SEM04G partition 2 1.00 MiB [ 2.503756] mmcblk0: p1 p2 [ 2.509303] mmcblk0boot1: unknown partition table [ 2.515343] mmcblk0boot0: unknown partition table [ 4.828326] EXT3-fs (mmcblk0p2): warning: maximal mount count reached, running e2fsc k is recommended [ 4.845214] EXT3-fs (mmcblk0p2): using internal journal [ 4.845223] EXT3-fs (mmcblk0p2): recovery complete [ 4.857131] EXT3-fs (mmcblk0p2): mounted filesystem with ordered data mode [ 20.886514] mmc0: new high speed SDHC card at address d555 [ 20.904282] mmcblk3: mmc0:d555 SD04G 3.79 GiB [ 20.906926] mmcblk3: p1But I would have expected this to be mmcblk1 -- might the boot partitions be using up mmcblk1/2 somehow?
Thanks,
- Chris.
Signature · 6 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patchv3 4/4] MMC: MMC boot partitions support.
Hi,
Quoted 1 line · Philip Rakity
Aren't these the "hidden" partitions ? Only available at boot time?
Yes, it's the previously-hidden boot partitions -- Andrei's patch exposes them to Linux.
Quoted 2 lines
I need to apply my patch to reset the boot partition -- or is that now in mmc-next
Your patch is in mmc-next.
Quoted 1 line
to see if the problem still happens.
Well, there isn't a problem per se, the system still boots fine -- the boot partitions are being exposed as the patch intends them to. I'm just curious whether it's normal for two 1MiB partitions to be created as a factory default.
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [patchv3 4/4] MMC: MMC boot partitions support.
Quoted 11 lines · Chris Ball
Hi,
Quoted 1 line · Philip Rakity
Aren't these the "hidden" partitions ? Only available at boot time?
Yes, it's the previously-hidden boot partitions -- Andrei's patch exposes them to Linux.
Quoted 2 lines
I need to apply my patch to reset the boot partition -- or is that now in mmc-next
Quoted 9 lines
Your patch is in mmc-next.
Quoted 1 line
to see if the problem still happens.
Well, there isn't a problem per se, the system still boots fine -- the boot partitions are being exposed as the patch intends them to. I'm just curious whether it's normal for two 1MiB partitions to be created as a factory default.
Chris, the partitions are always present and are a feature of the card.
I ptofusely apologize for the dev_idx issue, I should have caught that immediately. A dev_idx is till assigned even though the name doesn't reflect the actual assigned dev_idx for hardware partitions. That effectively means you need to track a name_idx per main mmc_blk_data that is only used to form the naming for the device.
I will send a patch in about 30 mins...
A
RFC 1/1 MMC: Block: Ensure hardware partitions don't mess with mmcblk device naming.
With the hardware partitions support (which represent additional logical devices present on MMC), devidx does not correspond with index used to form /dev/mmcblkX names. So use an additional allocated index for device names.
--- drivers/mmc/card/block.c | 24 +++++++++++++++++------- 1 files changed, 17 insertions(+), 7 deletions(-)
drivers/mmc/card/block.c +17 -7
@@ -75,6 +75,7 @@ static int max_devices;/* 256 minors, so at most 256 separate devices */ static DECLARE_BITMAP(dev_use, 256); +static DECLARE_BITMAP(name_use, 256);/* * There is one mmc_blk_data per slot.
@@ -88,6 +89,7 @@ struct mmc_blk_data {unsigned int usage;unsigned int read_only;unsigned int part_type; +unsigned int name_idx;/* * Only set in main mmc_blk_data associated
@@ -776,6 +778,18 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, }/* +* !subname implies we are creating main mmc_blk_data that will be +* associated with mmc_card with mmc_set_drvdata. Due to device partitions, +* devidx will not coincide with a per-physical card index anymore +* so we keep track of a name index. +*/ +if (!subname) + md->name_idx =find_first_zero_bit (name_use, max_devices); +else + md->name_idx = ((struct mmc_blk_data *) +dev_to_disk (parent)->private_data)->name_idx; + +/* * Set the read-only status based on the supported commands * and the write protect switch. */
@@ -820,13 +834,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,* messages to tell when the card is present. */ -if (subname) -snprintf (md->disk->disk_name,sizeof (md->disk->disk_name), -"mmcblk%d%s" , -mmc_get_devidx (dev_to_disk (parent)), subname); -else -snprintf (md->disk->disk_name,sizeof (md->disk->disk_name), -"mmcblk%d" , devidx); +snprintf (md->disk->disk_name,sizeof (md->disk->disk_name), +"mmcblk%d%s" , md->name_idx, subname ? subname :"" );blk_queue_logical_block_size (md->queue.queue,512 );set_capacity (md->disk, size);
@@ -953,6 +962,7 @@ static void mmc_blk_remove_parts(struct mmc_card *card,struct list_head *pos, *q;struct mmc_blk_data *part_md; +__clear_bit (md->name_idx, name_use);list_for_each_safe (pos, q, &md->part) { part_md = list_entry(pos, struct mmc_blk_data, part);list_del (pos);
Signature · 1 line
1.7.0.4
Re: [RFC] MMC: Block: Ensure hardware partitions don't mess with mmcblk device naming.
Quoted 8 lines · Andrei Warkentin
With the hardware partitions support (which represent additional logical devices present on MMC), devidx does not correspond with index used to form
/dev/mmcblkXnames. So use an additional allocated index for device names.Signed-off-by Andrei Warkentin <[email protected]>---
drivers/mmc/card/block.c | 24 +++++++++++++++++-------1 files changed, 17 insertions(+), 7 deletions(-)
The alternative is to borrow from a previous suggestion by Stephen Warren, but instead of using card->host->index in place of devidx, use card->host->index in place of an additional name_index used to form /dev/mmcblkX device names.
Using card->host->index for devidx doesn't work when you have multiple logical devices per host (because MMC card contains HW partitions).
Chris, unfortunately I am working OOF for next couple of days(I am happy I took my eMMC board with me), so I was not able to test second card (laptop only has 1 slot). Tested on your mmc tree with SDHCI and my MMC08G card. Would you mind testing above RFC change? Sorry again for the regression, grrrr.
A
Re: [RFC] MMC: Block: Ensure hardware partitions don't mess with mmcblk device naming.
Hi Andrei,
Quoted 5 lines · Andrei Warkentin
Chris, unfortunately I am working OOF for next couple of days(I am happy I took my eMMC board with me), so I was not able to test second card (laptop only has 1 slot). Tested on your mmc tree with SDHCI and my MMC08G card. Would you mind testing above RFC change? Sorry again for the regression, grrrr.
Sure, happy to test. No need to feel too bad about the regression, we're very early on in preparation for .40.
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [RFC] MMC: Block: Ensure hardware partitions don't mess with mmcblk device naming.
In reply to Andrei WarkentinHi Andrei,
Quoted 65 lines · Andrei Warkentin
With the hardware partitions support (which represent additional logical devices present on MMC), devidx does not correspond with index used to form
/dev/mmcblkXnames. So use an additional allocated index for device names.Signed-off-by Andrei Warkentin <[email protected]>--- drivers/mmc/card/block.c | 24 +++++++++++++++++------- 1 files changed, 17 insertions(+), 7 deletions(-)drivers/mmc/card/block.c +16
-7@@ -75,6 +75,7 @@ static int max_devices;/* 256 minors, so at most 256 separate devices */ static DECLARE_BITMAP(dev_use, 256); +static DECLARE_BITMAP(name_use, 256);/* * There is one mmc_blk_data per slot. @@ -88,6 +89,7 @@ struct mmc_blk_data {unsigned int usage;unsigned int read_only;unsigned int part_type; +unsigned int name_idx;/* * Only set in main mmc_blk_data associated @@ -776,6 +778,18 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, }/* +* !subname implies we are creating main mmc_blk_data that will be +* associated with mmc_card with mmc_set_drvdata. Due to device partitions, +* devidx will not coincide with a per-physical card index anymore +* so we keep track of a name index. +*/ +if (!subname) + md->name_idx =find_first_zero_bit (name_use, max_devices); +else + md->name_idx = ((struct mmc_blk_data *) +dev_to_disk (parent)->private_data)->name_idx; + +/* * Set the read-only status based on the supported commands * and the write protect switch. */ @@ -820,13 +834,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,* messages to tell when the card is present. */ -if (subname) -snprintf (md->disk->disk_name,sizeof (md->disk->disk_name), -"mmcblk%d%s" , -mmc_get_devidx (dev_to_disk (parent)), subname); -else -snprintf (md->disk->disk_name,sizeof (md->disk->disk_name), -"mmcblk%d" , devidx); +snprintf (md->disk->disk_name,sizeof (md->disk->disk_name), +"mmcblk%d%s" , md->name_idx, subname ? subname :"" );blk_queue_logical_block_size (md->queue.queue,512 );set_capacity (md->disk, size);
drivers/mmc/card/block.c static void mmc_blk_remove_parts(struct mmc_card *card, · line 968
Quoted 7 lines
drivers/mmc/card/block.c +1
-0@@ -953,6 +962,7 @@ static void mmc_blk_remove_parts(struct mmc_card *card,struct list_head *pos, *q;struct mmc_blk_data *part_md; +__clear_bit (md->name_idx, name_use);list_for_each_safe (pos, q, &md->part) { part_md = list_entry(pos, struct mmc_blk_data, part);list_del (pos);
This is crashing for me on insertion of the external card after boot:
[ 2.479319] mmc2: new high speed MMC card at address 0001 [ 2.485055] mmcblk0: mmc2:0001 SEM04G 3.68 GiB [ 2.489656] mmcblk0boot0: mmc2:0001 SEM04G partition 1 1.00 MiB [ 2.495850] mmcblk0boot1: mmc2:0001 SEM04G partition 2 1.00 MiB [ 2.503984] mmcblk0: p1 p2 [ 2.509273] mmcblk0boot1: unknown partition table [ 2.515308] mmcblk0boot0: unknown partition table [ 2.524044] psmouse.c: Failed to enable mouse on ec touchpad (phys) [ 2.532834] EXT3-fs: barriers not enabled [ 4.996102] EXT3-fs (mmcblk0p2): warning: maximal mount count reached, running e2fsck is recommended [ 5.007285] kjournald starting. Commit interval 5 seconds [ 5.014595] EXT3-fs (mmcblk0p2): using internal journal [ 5.019791] EXT3-fs (mmcblk0p2): recovery complete [ 5.026713] EXT3-fs (mmcblk0p2): mounted filesystem with ordered data mode [ 5.026725] VFS: Mounted root (ext3 filesystem) on device 179:2. [ 5.039565] Freeing init memory: 116K
[olpc@localhost ~]$
[ 33.642250] Unable to handle kernel NULL pointer dereference at virtual address 00000021 [ 33.653175] pgd = c0004000 [ 33.656119] [00000021] *pgd=00000000 [ 33.659673] Internal error: Oops: 17 [#1] PREEMPT [ 33.659673] last sysfs file: /sys/devices/platform/sdhci-pxa.0/mmc_host/mmc0/mmc0:d555/serial [ 33.672798] Modules linked in: [ 33.675826] CPU: 0 Tainted: G W (2.6.39-rc4-00194-ge20de60-dirty #4) [ 33.675826] PC is at sysfs_create_dir+0x24/0xd4 [ 33.683258] LR is at kobject_add_internal+0x134/0x224 [ 33.687761] pc : [<c00f9880>] lr : [<c01b2600>] psr: a0000013 [ 33.692773] sp : dc131db8 ip : 00000000 fp : 00000000 [ 33.704168] r10: dcfe41fc r9 : c05571e0 r8 : dc205408 [ 33.704168] r7 : dcc61c68 r6 : 00000000 r5 : dcc61c68 r4 : dcf441b0 [ 33.709357] r3 : dcc61c68 r2 : 00000000 r1 : 0000002f r0 : dcf441b0 [ 33.715834] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel [ 33.722316] Control: 10c5387d Table: 1cc44019 DAC: 00000015 [ 33.729568] Process kworker/u:1 (pid: 27, stack limit = 0xdc1302f8) [ 33.735271] Stack: (0xdc131db8 to 0xdc132000) [ 33.745818] 1da0: dcf441b0 0000002f [ 33.745818] 1dc0: 00000000 dc3317a0 dcf441b0 dcc61c68 dcc61c68 c01b2600 dcf441b0 0000002f [ 33.753939] 1de0: 00000000 00000001 dcf441b0 dcc61c68 00000000 dcc61c68 dc205408 c01b2a00 [ 33.762063] 1e00: dcf441b0 dc131e1c dcf441b0 dcf44040 dcc61c68 c01a3a40 c04bbab4 c04d3ef1 [ 33.770188] 1e20: 00000011 dcc61c00 dcf44040 00000000 dcc61c68 c01a89ac c01a79a4 dcc61c00 [ 33.778311] 1e40: c05571e0 0b300018 07d8000a dcec6b60 dcec6b60 00000000 dc131e86 c036b964 [ 33.786436] 1e60: 00000800 dc205400 dcec6b60 c02a3c30 dc131e86 c04fa28d dcd873f8 00000000 [ 33.794560] 1e80: c0557388 2e335408 47203937 00004269 dc205408 c0557388 c01f3d8c 00000000 [ 33.802685] 1ea0: 00000000 c029b51c c029b508 c01f3be4 c0557388 dc205408 dc205408 dc131ec8 [ 33.818934] 1ec0: c01f3d8c c01f2994 dc070aa8 dcfe74b4 dc205408 dc205408 dc20543c dcfe4008 [ 33.827056] 1ee0: 00000000 c01f3a24 dc205408 dc205410 dcfe4008 c01f322c 00000002 c01f1114 [ 33.827056] 1f00: da21ecdc dc20551c da21ed38 dc205400 da21ed38 00000000 00061a80 dc205400 [ 33.843305] 1f20: dc205408 00000000 00061a80 c0417c28 c05692b4 dcfe41fc 00000000 c029b898 [ 33.851429] 1f40: c04ed29d 0000d555 00000002 dcfe4000 00000000 c029e9e8 dcfe4000 00ff8000 [ 33.859554] 1f60: dc131f18 dcfe41fc dcfe4000 c029b144 dcfdef20 dc068a00 00000000 c029ae9c [ 33.859554] 1f80: dc068a05 c0053978 dc068a05 dcfdef20 dc130000 c05692ac c05692b4 dcfdef30 [ 33.875802] 1fa0: 00000089 c05692b4 00000000 c0054450 dc03df30 dcfdef20 c0054284 00000013 [ 33.883925] 1fc0: 00000000 00000000 00000000 c0057cf0 00000000 00000000 dcfdef20 00000000 [ 33.892053] 1fe0: dc131fe0 dc131fe0 dc03df30 c0057c74 c002bc34 c002bc34 ffffffff ffffffff [ 33.900184] [<c00f9880>] (sysfs_create_dir+0x24/0xd4) from [<c01b2600>] (kobject_add_internal+0x134/0x224) [ 33.900184] [<c01b2600>] (kobject_add_internal+0x134/0x224) from [<c01b2a00>] (kobject_add+0x68/0x8c) [ 33.918942] [<c01b2a00>] (kobject_add+0x68/0x8c) from [<c01a3a40>] (blk_register_queue+0x48/0xa8) [ 33.927759] [<c01a3a40>] (blk_register_queue+0x48/0xa8) from [<c01a89ac>] (add_disk+0xe8/0x230) [ 33.936404] [<c01a89ac>] (add_disk+0xe8/0x230) from [<c036b964>] (mmc_add_disk+0x10/0x64) [ 33.936404] [<c036b964>] (mmc_add_disk+0x10/0x64) from [<c02a3c30>] (mmc_blk_probe+0x184/0x1f4) [ 33.953174] [<c02a3c30>] (mmc_blk_probe+0x184/0x1f4) from [<c029b51c>] (mmc_bus_probe+0x14/0x18) [ 33.953174] [<c029b51c>] (mmc_bus_probe+0x14/0x18) from [<c01f3be4>] (driver_probe_device+0x144/0x268) [ 33.961904] [<c01f3be4>] (driver_probe_device+0x144/0x268) from [<c01f2994>] (bus_for_each_drv+0x4c/0x84) [ 33.971152] [<c01f2994>] (bus_for_each_drv+0x4c/0x84) from [<c01f3a24>] (device_attach+0x64/0x90) [ 33.989466] [<c01f3a24>] (device_attach+0x64/0x90) from [<c01f322c>] (bus_probe_device+0x24/0x40) [ 33.998281] [<c01f322c>] (bus_probe_device+0x24/0x40) from [<c01f1114>] (device_add+0x3c8/0x54c) [ 34.007007] [<c01f1114>] (device_add+0x3c8/0x54c) from [<c029b898>] (mmc_add_card+0x110/0x158) [ 34.007007] [<c029b898>] (mmc_add_card+0x110/0x158) from [<c029e9e8>] (mmc_attach_sd+0x160/0x1e0) [ 34.024376] [<c029e9e8>] (mmc_attach_sd+0x160/0x1e0) from [<c029b144>] (mmc_rescan+0x2a8/0x314) [ 34.024376] [<c029b144>] (mmc_rescan+0x2a8/0x314) from [<c0053978>] (process_one_work+0x208/0x360) [ 34.041930] [<c0053978>] (process_one_work+0x208/0x360) from [<c0054450>] (worker_thread+0x1cc/0x2ec) [ 34.051097] [<c0054450>] (worker_thread+0x1cc/0x2ec) from [<c0057cf0>] (kthread+0x7c/0x84) [ 34.051097] [<c0057cf0>] (kthread+0x7c/0x84) from [<c002bc34>] (kernel_thread_exit+0x0/0x8) [ 34.059303] Code: e594300c e3530000 15936018 059f60a8 (e5d65021) [ 34.076293] ---[ end trace 9dee957cd2bd872b ]---
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
PATCH 1/1 MMC: Block: Ensure hardware partitions don't mess with mmcblk device naming.
With the hardware partitions support (which represent additional logical devices present on MMC), devidx does not correspond with index used to form /dev/mmcblkX names. So use an additional allocated index for device names.
--- drivers/mmc/card/block.c | 26 +++++++++++++++++++------- 1 files changed, 19 insertions(+), 7 deletions(-)
drivers/mmc/card/block.c +19 -7
@@ -75,6 +75,7 @@ static int max_devices;/* 256 minors, so at most 256 separate devices */ static DECLARE_BITMAP(dev_use, 256); +static DECLARE_BITMAP(name_use, 256);/* * There is one mmc_blk_data per slot.
@@ -88,6 +89,7 @@ struct mmc_blk_data {unsigned int usage;unsigned int read_only;unsigned int part_type; +unsigned int name_idx;/* * Only set in main mmc_blk_data associated
@@ -776,6 +778,20 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, }/* +* !subname implies we are creating main mmc_blk_data that will be +* associated with mmc_card with mmc_set_drvdata. Due to device partitions, +* devidx will not coincide with a per-physical card index anymore +* so we keep track of a name index. +*/ +if (!subname) { + md->name_idx =find_first_zero_bit (name_use, max_devices); +__set_bit (md->name_idx, name_use); + } +else + md->name_idx = ((struct mmc_blk_data *) +dev_to_disk (parent)->private_data)->name_idx; + +/* * Set the read-only status based on the supported commands * and the write protect switch. */
@@ -820,13 +836,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,* messages to tell when the card is present. */ -if (subname) -snprintf (md->disk->disk_name,sizeof (md->disk->disk_name), -"mmcblk%d%s" , -mmc_get_devidx (dev_to_disk (parent)), subname); -else -snprintf (md->disk->disk_name,sizeof (md->disk->disk_name), -"mmcblk%d" , devidx); +snprintf (md->disk->disk_name,sizeof (md->disk->disk_name), +"mmcblk%d%s" , md->name_idx, subname ? subname :"" );blk_queue_logical_block_size (md->queue.queue,512 );set_capacity (md->disk, size);
@@ -953,6 +964,7 @@ static void mmc_blk_remove_parts(struct mmc_card *card,struct list_head *pos, *q;struct mmc_blk_data *part_md; +__clear_bit (md->name_idx, name_use);list_for_each_safe (pos, q, &md->part) { part_md = list_entry(pos, struct mmc_blk_data, part);list_del (pos);
Signature · 1 line
1.7.0.4
Re: [PATCH] MMC: Block: Ensure hardware partitions don't mess with mmcblk device naming.
Quoted 5 lines · Andrei Warkentin
With the hardware partitions support (which represent additional logical devices present on MMC), devidx does not correspond with index used to form
/dev/mmcblkXnames. So use an additional allocated index for device names.Signed-off-by Andrei Warkentin <[email protected]>
That should be good :-/. Sorry.
A
Re: [PATCH] MMC: Block: Ensure hardware partitions don't mess with mmcblk device naming.
In reply to Andrei WarkentinHi Andrei,
Quoted 5 lines · Andrei Warkentin
With the hardware partitions support (which represent additional logical devices present on MMC), devidx does not correspond with index used to form
/dev/mmcblkXnames. So use an additional allocated index for device names.Signed-off-by Andrei Warkentin <[email protected]>
Thanks, pushed to mmc-next for .40, looks good:
[ 659.127819] mmc0: new high speed SDHC card at address d555 [ 659.141704] mmcblk1: mmc0:d555 SD04G 3.79 GiB [ 659.147453] mmcblk1: p1
(I re-wrapped the commit message and comment to <80 chars.)
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [patchv3 4/4] MMC: MMC boot partitions support.
In reply to Chris BallHi Chris.
Quoted 9 lines · Chris Ball
Hi Andrei,
Quoted 3 lines · Andrei Warkentin
Allows device MMC boot partitions to be accessed. MMC partitions are treated effectively as separate block devices on the same MMC card.
Booted this with a Sandisk SEM04G eMMC:
Quoted 8 lines
[ 2.469921] mmcblk0boot0: mmc2:0001 SEM04G partition 1 1.00 MiB [ 2.475905] mmcblk0boot1: mmc2:0001 SEM04G partition 2 1.00 MiB [ 2.489403] mmcblk0boot1: unknown partition table [ 2.495921] mmcblk0boot0: unknown partition tableI haven't set up any boot partitions explicitly, so I guess the two 1MiB boot partitions might be the factory-default setting. Out of curiosity, does that match your experience with Sandisk eMMCs?
in my experience, Sandisk set up boot partition with each 1MiB. (default setting)
Regards,
Jaehoon Chung
Quoted 2 lines
- Chris.