commands: mmc_extcsd: print_field: fix 32 bit overflow
PATCH 1/5 commands: mmc_extcsd: print_field: fix 32 bit overflow
--- commands/mmc_extcsd.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
commands/mmc_extcsd.c +15 -8
@@ -11,6 +11,7 @@#include <mci.h> #include <getopt.h> #include <fs.h> +#include <linux/sizes.h> #define EXT_CSD_BLOCKSIZE 512
@@ -1142,7 +1143,7 @@ static int print_field(u8 *reg, int index)return 1 ;case EXT_CSD_SEC_COUNT : - tmp64 = val *512 ; + tmp64 *=512 ;printf ("\tDevice density: %llu B\n" , tmp64);return 1 ;
@@ -1232,7 +1233,7 @@ static int print_field(u8 *reg, int index)case EXT_CSD_HC_ERASE_GRP_SIZE : val =get_field_val (EXT_CSD_HC_ERASE_GRP_SIZE ,0 ,0xFF ); - val = val *524288 ; + val = val *SZ_512K ;if (val) str =basprintf ("Erase-unit size: %u" , val);else
@@ -1342,7 +1343,8 @@ static int print_field(u8 *reg, int index)case EXT_CSD_ENH_SIZE_MULT : tmp =get_field_val (EXT_CSD_HC_WP_GRP_SIZE ,0 ,0xFF ); tmp = tmp +get_field_val (EXT_CSD_HC_ERASE_GRP_SIZE ,0 ,0xFF ); - tmp64 = val * tmp *524288 ; + tmp64 *= tmp; + tmp64 *=SZ_512K ;printf ("\tEnhanced User Data Area %i Size: %llu B\n" , index -EXT_CSD_ENH_SIZE_MULT , tmp64);return 1 ;
@@ -1350,28 +1352,32 @@ static int print_field(u8 *reg, int index)case EXT_CSD_GP_SIZE_MULT3 : tmp =get_field_val (EXT_CSD_HC_WP_GRP_SIZE ,0 ,0xFF ); tmp = tmp +get_field_val (EXT_CSD_HC_ERASE_GRP_SIZE ,0 ,0xFF ); - tmp64 = val * tmp *524288 ; + tmp64 *= tmp; + tmp64 *=SZ_512K ;printf ("\tGeneral_Purpose_Partition_3 Size: %llu B\n" , tmp64);return 1 ;case EXT_CSD_GP_SIZE_MULT2 : tmp =get_field_val (EXT_CSD_HC_WP_GRP_SIZE ,0 ,0xFF ); tmp = tmp +get_field_val (EXT_CSD_HC_ERASE_GRP_SIZE ,0 ,0xFF ); - tmp64 = val * tmp *524288 ; + tmp64 *= tmp; + tmp64 *=SZ_512K ;printf ("\tGeneral_Purpose_Partition_2 Size: %llu B\n" , tmp64);return 1 ;case EXT_CSD_GP_SIZE_MULT1 : tmp =get_field_val (EXT_CSD_HC_WP_GRP_SIZE ,0 ,0xFF ); tmp = tmp +get_field_val (EXT_CSD_HC_ERASE_GRP_SIZE ,0 ,0xFF ); - tmp64 = val * tmp *524288 ; + tmp64 *= tmp; + tmp64 *=SZ_512K ;printf ("\tGeneral_Purpose_Partition_1 Size: %llu B\n" , tmp64);return 1 ;case EXT_CSD_GP_SIZE_MULT0 : tmp =get_field_val (EXT_CSD_HC_WP_GRP_SIZE ,0 ,0xFF ); tmp = tmp +get_field_val (EXT_CSD_HC_ERASE_GRP_SIZE ,0 ,0xFF ); - tmp64 = val * tmp *524288 ; + tmp64 *= tmp; + tmp64 *=SZ_512K ;printf ("\tGeneral_Purpose_Partition_0 Size: %llu B\n" , tmp64);return 1 ;
@@ -1422,7 +1428,8 @@ static int print_field(u8 *reg, int index)case EXT_CSD_MAX_ENH_SIZE_MULT : tmp =get_field_val (EXT_CSD_HC_WP_GRP_SIZE ,0 ,0xFF ); tmp = tmp +get_field_val (EXT_CSD_HC_ERASE_GRP_SIZE ,0 ,0xFF ); - tmp64 = val * tmp *524288 ; + tmp64 *= tmp; + tmp64 *=SZ_512K ;printf ("\tMax Enhanced Area: %llu B\n" , tmp64);return 1 ;
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/5 commands: mmc_extcsd: print_field: fix layout
--- commands/mmc_extcsd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
commands/mmc_extcsd.c +1 -1
@@ -2163,7 +2163,7 @@ static int print_field(u8 *reg, int index) str ="FIFO policy for cache" ; else str ="not provided" ; -printf ("\t[0] Device flushing: %s" , str); +printf ("\t[0] Device flushing: %s\n" , str);return 1 ;case EXT_CSD_OPTIMAL_READ_SIZE :
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/5 mci: mci-core: fix long lasting FIXMEs
In reply to Juergen Borleis--- drivers/mci/mci-core.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
drivers/mci/mci-core.c +13 -9
@@ -361,9 +361,9 @@ static int mmc_send_op_cond(struct mci *mci) }/** -* FIXME -* @param mci MCI instance -* @param ext_csd Buffer for a 512 byte sized extended CSD +* Read-in the card's whole extended CSD configuration area +* @param[in] mci MCI instance +* @param[out] ext_csd Buffer for an #EXT_CSD_BLOCKSIZE byte sized extended CSD * @return Transaction status (0 on success) * * Note: Only cards newer than Version 1.1 (Physical Layer Spec) support
@@ -379,19 +379,23 @@ int mci_send_ext_csd(struct mci *mci, char *ext_csd) data.dest = ext_csd; data.blocks =1 ; - data.blocksize =512 ; + data.blocksize =EXT_CSD_BLOCKSIZE ; data.flags =MMC_DATA_READ ;return mci_send_cmd (mci, &cmd, &data); }/** -* FIXME -* @param mci MCI instance -* @param set FIXME -* @param index FIXME -* @param value FIXME +* Write a byte into the card's extended CSD configuration area +* @param[in] mci MCI instance +* @param[in] index Byte index in the extended CSD configuration area +* @param[in] value Byte to write at index into the extended CSD configuration area * @return Transaction status (0 on success) +* +* This sends a CMD6 (aka SWITCH) to the card and writes @b value at extended CSD @b index. +* +* @note It always writes a full byte, the alternatives 'bit set' and +* 'bit clear' aren't supported. */ int mci_switch (struct mci *mci,unsigned index,unsigned value) {
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 3/5] mci: mci-core: fix long lasting FIXMEs
Hello Juergen,
Quoted 23 lines · Juergen Borleis
Signed-off-by Juergen Borleis <[email protected]>--- drivers/mci/mci-core.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)drivers/mci/mci-core.c +3
-3@@ -361,9 +361,9 @@ static int mmc_send_op_cond(struct mci *mci) }/** -* FIXME -* @param mci MCI instance -* @param ext_csd Buffer for a 512 byte sized extended CSD +* Read-in the card's whole extended CSD configuration area +* @param[in] mci MCI instance +* @param[out] ext_csd Buffer for an #EXT_CSD_BLOCKSIZE byte sized extended CSD * @return Transaction status (0 on success) * * Note: Only cards newer than Version 1.1 (Physical Layer Spec) support
drivers/mci/mci-core.c int mci_send_ext_csd(struct mci *mci, char *ext_csd) · line 382
Quoted 5 lines
drivers/mci/mci-core.c +1
-1@@ -379,19 +379,23 @@ int mci_send_ext_csd(struct mci *mci, char *ext_csd) data.dest = ext_csd; data.blocks =1 ; - data.blocksize =512 ; + data.blocksize =EXT_CSD_BLOCKSIZE ;
This breaks the build; EXT_CSD_BLOCKSIZE is undeclared in mci-core.c. Did you forget a prerequisite patch?
Quoted 25 lines
drivers/mci/mci-core.c +9
-5data.flags =MMC_DATA_READ ;return mci_send_cmd (mci, &cmd, &data); }/** -* FIXME -* @param mci MCI instance -* @param set FIXME -* @param index FIXME -* @param value FIXME +* Write a byte into the card's extended CSD configuration area +* @param[in] mci MCI instance +* @param[in] index Byte index in the extended CSD configuration area +* @param[in] value Byte to write at index into the extended CSD configuration area * @return Transaction status (0 on success) +* +* This sends a CMD6 (aka SWITCH) to the card and writes @b value at extended CSD @b index. +* +* @note It always writes a full byte, the alternatives 'bit set' and +* 'bit clear' aren't supported. */ int mci_switch (struct mci *mci,unsigned index,unsigned value) {
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 3/5] mci: mci-core: fix long lasting FIXMEs
Quoted 27 lines · Ahmad Fatoum
Hello Juergen,
Quoted 24 lines · Juergen Borleis
Signed-off-by Juergen Borleis <[email protected]>--- drivers/mci/mci-core.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)drivers/mci/mci-core.c +3
-3@@ -361,9 +361,9 @@ static int mmc_send_op_cond(struct mci *mci) }/** -* FIXME -* @param mci MCI instance -* @param ext_csd Buffer for a 512 byte sized extended CSD +* Read-in the card's whole extended CSD configuration area +* @param[in] mci MCI instance +* @param[out] ext_csd Buffer for an #EXT_CSD_BLOCKSIZE byte sized extended CSD * @return Transaction status (0 on success) * * Note: Only cards newer than Version 1.1 (Physical Layer Spec) support @@ -379,19 +379,23 @@ int mci_send_ext_csd(struct mci *mci, char *ext_csd)
Quoted 7 lines
drivers/mci/mci-core.c int mci_send_ext_csd(struct mci *mci, char *ext_csd) · line 382
Quoted 4 lines
drivers/mci/mci-core.c +1
-1data.dest = ext_csd; data.blocks =1 ; - data.blocksize =512 ; + data.blocksize =EXT_CSD_BLOCKSIZE ;This breaks the build;
EXT_CSD_BLOCKSIZEis undeclared inmci-core.c. Did you forget a prerequisite patch?
Dropped the patch for now.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 3/5] mci: mci-core: fix long lasting FIXMEs
In reply to Ahmad FatoumHi Ahmad,
Am Montag, den 14.09.2020, 16:58 +0200 schrieb Ahmad Fatoum:
Quoted 10 lines
[…]
drivers/mci/mci-core.c int mci_send_ext_csd(struct mci *mci, char *ext_csd) · line 382
Quoted 6 lines
drivers/mci/mci-core.c +1
-1@@ -379,19 +379,23 @@ int mci_send_ext_csd(struct mci *mci, char *ext_csd) data.dest = ext_csd; data.blocks =1 ; - data.blocksize =512 ; + data.blocksize =EXT_CSD_BLOCKSIZE ;This breaks the build;
EXT_CSD_BLOCKSIZEis undeclared inmci-core.c. Did you forget a prerequisite patch?
Branch confusion in my repo... I will send a different branch without this special change.
Thanks
Juergen
Signature · 10 lines
Pengutronix e.K. | Juergen Borleis | Steuerwalder Str. 21 | https://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-128 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/1 mci: mci-core: fix long lasting FIXMEs
In reply to Juergen Borleis--- drivers/mci/mci-core.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/mci/mci-core.c +12 -8
@@ -362,9 +362,9 @@ static int mmc_send_op_cond(struct mci *mci) }/** -* FIXME -* @param mci MCI instance -* @param ext_csd Buffer for a 512 byte sized extended CSD +* Read-in the card's whole extended CSD configuration area +* @param[in] mci MCI instance +* @param[out] ext_csd Buffer for an #EXT_CSD_BLOCKSIZE byte sized extended CSD * @return Transaction status (0 on success) * * Note: Only cards newer than Version 1.1 (Physical Layer Spec) support
@@ -387,12 +387,16 @@ int mci_send_ext_csd(struct mci *mci, char *ext_csd) }/** -* FIXME -* @param mci MCI instance -* @param set FIXME -* @param index FIXME -* @param value FIXME +* Write a byte into the card's extended CSD configuration area +* @param[in] mci MCI instance +* @param[in] index Byte index in the extended CSD configuration area +* @param[in] value Byte to write at index into the extended CSD configuration area * @return Transaction status (0 on success) +* +* This sends a CMD6 (aka SWITCH) to the card and writes @b value at extended CSD @b index. +* +* @note It always writes a full byte, the alternatives 'bit set' and +* 'bit clear' aren't supported. */ int mci_switch (struct mci *mci,unsigned index,unsigned value) {
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedRe: [PATCH v2] mci: mci-core: fix long lasting FIXMEs
Quoted 4 lines · Juergen Borleis
Signed-off-by Juergen Borleis <[email protected]>--- drivers/mci/mci-core.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
Applied, thanks
Sascha
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/5 mci: kconfig: explain what boot partitions are
In reply to Juergen Borleis--- drivers/mci/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mci/Kconfig +7 -0
@@ -34,6 +34,13 @@ config MCI_WRITE config MCI_MMC_BOOT_PARTITIONS bool "support MMC boot partitions" + help + Provide access to the 'boot partitions' of devices of type 'MMC'. + These so called 'hardware partitions' act like an independent memory + device and thus, need special handling. + + Note: only 'MMC' have 'boot partitions'. So, if you don't use an + 'MMC' device, you don't need this support. comment "--- MCI host drivers ---"
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 5/5 mci: mci-core: add GPP support
In reply to Juergen BorleisGeneral Purpose Partitions (GPP) are hardware partitions like the boot partitions. And like the boot partitions they are limited to MMCs only. Most applications running an eMMC do not use GPPs, so this feature can be disabled.
--- drivers/mci/Kconfig | 13 ++++++++ drivers/mci/mci-core.c | 76 ++++++++++++++++++++++++++++++++++++++++-- include/mci.h | 1 + 3 files changed, 88 insertions(+), 2 deletions(-)
drivers/mci/Kconfig +13 -0
@@ -42,6 +42,19 @@ config MCI_MMC_BOOT_PARTITIONS Note: only 'MMC' have 'boot partitions'. So, if you don't use an 'MMC' device, you don't need this support. +config MCI_MMC_GPP_PARTITIONS + bool "support MMC general purpose partitions (GPP)" + help + Provide access to the 'general purpose partitions' of devices of type + 'MMC'. These so called 'hardware partitions' act like an independent + memory device and thus, need special handling. + + Note: only 'MMC' devices have 'general purpose partitions'. So, if + you don't use an 'MMC' device, you don't need this support. + + Note: by default, 'MMC' devices have no 'general purpose partitions', + it requires a special one-time configuration step to enable them. + comment "--- MCI host drivers ---" config MCI_DW
drivers/mci/mci-core.c +74 -2
111 lines not on this page · raw message
include/mci.h +1 -0
@@ -277,6 +277,7 @@*/ #define EXT_CSD_PART_CONFIG_ACC_MASK (0x7)#define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1) +#define EXT_CSD_PART_CONFIG_ACC_GPP0 (0x4)#define EXT_CSD_CMD_SET_NORMAL (1<<0)#define EXT_CSD_CMD_SET_SECURE (1<<1)
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 4 lines · Juergen Borleis
Signed-off-by Juergen Borleis <[email protected]>--- commands/mmc_extcsd.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
Applied, thanks
Sascha
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox