* [U-Boot] [RFC PATCH 1/1] Read mmc device memory capacity from EXT_CSD if memory is addressed by sector
@ 2016-11-23 13:04 ` Tomas Melin
2016-11-24 1:55 ` Jaehoon Chung
0 siblings, 1 reply; 5+ messages in thread
From: Tomas Melin @ 2016-11-23 13:04 UTC (permalink / raw)
To: u-boot
Hi,
We have successfully been using this patch to fix the problem mentioned in the
original message. Could this be picked up upstream?
BR,
Tomas
On Wed Feb 5 21:00:42 CET 2014, Frank Bormann wrote:
>Hello Everyone,
>
>I believe, there is a bug in the mmc driver code pertaining to how u-boot
>detects memory size of an mmc device. However, I am not 100% sure, my solution
>conforms to the JEDEC standard. So I am putting it up for discussion.
>
>Previously, sector count indicated by mmc devices in the EXT_CSD
>would only be used in u-boot if the size indicated is greater than
>2 GB. This seems to be incorrect. I am working with a 4 GB Micron
>eMMC device that after partition configuration and setting the
>user data area to enhanced mode has a remaining capacity of less
>than 2 GB for the user data area. JESD84-B50 explicitly states in
>6.2.4 that for these devices SEC_CNT from the EXT_CSD is still
>valid even if the memory size for that device has dropped below
>2 GB by the partition configuration applied. The access mode bits
>from the OCR register seem to provide a better way to decide
>whether to use the CSD-based C_SIZE & C_MULT or the EXT_CSD-based
>SEC_CNT information when determining the device's capacity.
>
>In particular, this fixes a bug where u-boot SPL would assign 0 to
>mmc->block_dev.lba later on in the mmc_startup() function and
>subsequently fail to load u-boot from that mmc due to the original
>C_SIZE & C_MULT code assigning a 4 TB size to mmc->capacity, that
>incorrect capacity never being overwritten by the SEC_CNT capacity
>calculation (due to its size being less than 2 GB) and then finally
>lldiv(mmc->capacity, mmc->read_bl_len) exceeding the 32-bit result
>data type of mmc->block_dev.lba.
>
>Signed-off-by: Frank Bormann <fbormann@yahoo.com>
>---
> drivers/mmc/mmc.c | 10 +++++-----
> include/mmc.h | 1 +
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>index c6a1c23..c5d1efc 100644
>--- a/drivers/mmc/mmc.c
>+++ b/drivers/mmc/mmc.c
>@@ -935,19 +935,19 @@ static int mmc_startup(struct mmc *mmc)
> if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) {
> /* check ext_csd version and capacity */
> err = mmc_send_ext_csd(mmc, ext_csd);
>- if (!err && (ext_csd[EXT_CSD_REV] >= 2)) {
>+ if (!err && (ext_csd[EXT_CSD_REV] >= 2) &&
>+ (mmc->ocr & OCR_ACCESS_MODE) == OCR_ACCESS_BY_SECTOR) {
> /*
> * According to the JEDEC Standard, the value of
>- * ext_csd's capacity is valid if the value is more
>- * than 2GB
>+ * ext_csd's capacity is valid if the device addresses
>+ * its memory by sector
> */
> capacity = ext_csd[EXT_CSD_SEC_CNT] << 0
> | ext_csd[EXT_CSD_SEC_CNT + 1] << 8
> | ext_csd[EXT_CSD_SEC_CNT + 2] << 16
> | ext_csd[EXT_CSD_SEC_CNT + 3] << 24;
> capacity *= MMC_MAX_BLOCK_LEN;
>- if ((capacity >> 20) > 2 * 1024)
>- mmc->capacity_user = capacity;
>+ mmc->capacity_user = capacity;
> }
>
> switch (ext_csd[EXT_CSD_REV]) {
>diff --git a/include/mmc.h b/include/mmc.h
>index e1060b9..816b580 100644
>--- a/include/mmc.h
>+++ b/include/mmc.h
>@@ -104,6 +104,7 @@
> #define OCR_HCS 0x40000000
> #define OCR_VOLTAGE_MASK 0x007FFF80
> #define OCR_ACCESS_MODE 0x60000000
>+#define OCR_ACCESS_BY_SECTOR (1 << 30)
>
> #define SECURE_ERASE 0x80000000
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [RFC PATCH 1/1] Read mmc device memory capacity from EXT_CSD if memory is addressed by sector
2016-11-23 13:04 ` [U-Boot] [RFC PATCH 1/1] Read mmc device memory capacity from EXT_CSD if memory is addressed by sector Tomas Melin
@ 2016-11-24 1:55 ` Jaehoon Chung
2016-11-25 7:56 ` Tomas Melin
0 siblings, 1 reply; 5+ messages in thread
From: Jaehoon Chung @ 2016-11-24 1:55 UTC (permalink / raw)
To: u-boot
Hi Tomas,
On 11/23/2016 10:04 PM, Tomas Melin wrote:
> Hi,
>
> We have successfully been using this patch to fix the problem mentioned in the
> original message. Could this be picked up upstream?
Sorry. I didn't see this patch..Could you again send the patch without RFC?
Then it's helpful to me for checking this.
Best Regards,
Jaehoon Chung
>
> BR,
> Tomas
>
> On Wed Feb 5 21:00:42 CET 2014, Frank Bormann wrote:
>> Hello Everyone,
>>
>> I believe, there is a bug in the mmc driver code pertaining to how u-boot
>> detects memory size of an mmc device. However, I am not 100% sure, my solution
>> conforms to the JEDEC standard. So I am putting it up for discussion.
>>
>> Previously, sector count indicated by mmc devices in the EXT_CSD
>> would only be used in u-boot if the size indicated is greater than
>> 2 GB. This seems to be incorrect. I am working with a 4 GB Micron
>> eMMC device that after partition configuration and setting the
>> user data area to enhanced mode has a remaining capacity of less
>> than 2 GB for the user data area. JESD84-B50 explicitly states in
>> 6.2.4 that for these devices SEC_CNT from the EXT_CSD is still
>> valid even if the memory size for that device has dropped below
>> 2 GB by the partition configuration applied. The access mode bits
>>from the OCR register seem to provide a better way to decide
>> whether to use the CSD-based C_SIZE & C_MULT or the EXT_CSD-based
>> SEC_CNT information when determining the device's capacity.
>>
>> In particular, this fixes a bug where u-boot SPL would assign 0 to
>> mmc->block_dev.lba later on in the mmc_startup() function and
>> subsequently fail to load u-boot from that mmc due to the original
>> C_SIZE & C_MULT code assigning a 4 TB size to mmc->capacity, that
>> incorrect capacity never being overwritten by the SEC_CNT capacity
>> calculation (due to its size being less than 2 GB) and then finally
>> lldiv(mmc->capacity, mmc->read_bl_len) exceeding the 32-bit result
>> data type of mmc->block_dev.lba.
>>
>> Signed-off-by: Frank Bormann <fbormann@yahoo.com>
>> ---
>> drivers/mmc/mmc.c | 10 +++++-----
>> include/mmc.h | 1 +
>> 2 files changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>> index c6a1c23..c5d1efc 100644
>> --- a/drivers/mmc/mmc.c
>> +++ b/drivers/mmc/mmc.c
>> @@ -935,19 +935,19 @@ static int mmc_startup(struct mmc *mmc)
>> if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) {
>> /* check ext_csd version and capacity */
>> err = mmc_send_ext_csd(mmc, ext_csd);
>> - if (!err && (ext_csd[EXT_CSD_REV] >= 2)) {
>> + if (!err && (ext_csd[EXT_CSD_REV] >= 2) &&
>> + (mmc->ocr & OCR_ACCESS_MODE) == OCR_ACCESS_BY_SECTOR) {
>> /*
>> * According to the JEDEC Standard, the value of
>> - * ext_csd's capacity is valid if the value is more
>> - * than 2GB
>> + * ext_csd's capacity is valid if the device addresses
>> + * its memory by sector
>> */
>> capacity = ext_csd[EXT_CSD_SEC_CNT] << 0
>> | ext_csd[EXT_CSD_SEC_CNT + 1] << 8
>> | ext_csd[EXT_CSD_SEC_CNT + 2] << 16
>> | ext_csd[EXT_CSD_SEC_CNT + 3] << 24;
>> capacity *= MMC_MAX_BLOCK_LEN;
>> - if ((capacity >> 20) > 2 * 1024)
>> - mmc->capacity_user = capacity;
>> + mmc->capacity_user = capacity;
>> }
>>
>> switch (ext_csd[EXT_CSD_REV]) {
>> diff --git a/include/mmc.h b/include/mmc.h
>> index e1060b9..816b580 100644
>> --- a/include/mmc.h
>> +++ b/include/mmc.h
>> @@ -104,6 +104,7 @@
>> #define OCR_HCS 0x40000000
>> #define OCR_VOLTAGE_MASK 0x007FFF80
>> #define OCR_ACCESS_MODE 0x60000000
>> +#define OCR_ACCESS_BY_SECTOR (1 << 30)
>>
>> #define SECURE_ERASE 0x80000000
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [RFC PATCH 1/1] Read mmc device memory capacity from EXT_CSD if memory is addressed by sector
2016-11-24 1:55 ` Jaehoon Chung
@ 2016-11-25 7:56 ` Tomas Melin
2016-11-25 9:18 ` Jaehoon Chung
0 siblings, 1 reply; 5+ messages in thread
From: Tomas Melin @ 2016-11-25 7:56 UTC (permalink / raw)
To: u-boot
Hi Jaehoon,
On 11/24/2016 03:55 AM, Jaehoon Chung wrote:
> Hi Tomas,
>
> On 11/23/2016 10:04 PM, Tomas Melin wrote:
>> Hi,
>>
>> We have successfully been using this patch to fix the problem mentioned in the
>> original message. Could this be picked up upstream?
>
> Sorry. I didn't see this patch..Could you again send the patch without RFC?
> Then it's helpful to me for checking this.
Reposted the original RFC as a patch. Note that it was a rather old patch dating back to 2014.
BR,
Tomas
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [RFC PATCH 1/1] Read mmc device memory capacity from EXT_CSD if memory is addressed by sector
2016-11-25 7:56 ` Tomas Melin
@ 2016-11-25 9:18 ` Jaehoon Chung
0 siblings, 0 replies; 5+ messages in thread
From: Jaehoon Chung @ 2016-11-25 9:18 UTC (permalink / raw)
To: u-boot
On 11/25/2016 04:56 PM, Tomas Melin wrote:
>
> Hi Jaehoon,
>
> On 11/24/2016 03:55 AM, Jaehoon Chung wrote:
>> Hi Tomas,
>>
>> On 11/23/2016 10:04 PM, Tomas Melin wrote:
>>> Hi,
>>>
>>> We have successfully been using this patch to fix the problem mentioned in the
>>> original message. Could this be picked up upstream?
>>
>> Sorry. I didn't see this patch..Could you again send the patch without RFC?
>> Then it's helpful to me for checking this.
>
> Reposted the original RFC as a patch. Note that it was a rather old patch dating back to 2014.
Yep, it was too old..So i can't find the any comments for other guys..
And if this is correct, i wonder why didn't apply at that time..
So, i will check the Spec documentation in more detail.
Best Regards,
Jaehoon Chung
>
> BR,
> Tomas
>
>
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [RFC PATCH 1/1] Read mmc device memory capacity from EXT_CSD if memory is addressed by sector
@ 2014-02-05 20:00 Frank Bormann
0 siblings, 0 replies; 5+ messages in thread
From: Frank Bormann @ 2014-02-05 20:00 UTC (permalink / raw)
To: u-boot
Hello Everyone,
I believe, there is a bug in the mmc driver code pertaining to how u-boot
detects memory size of an mmc device. However, I am not 100% sure, my solution
conforms to the JEDEC standard. So I am putting it up for discussion.
Previously, sector count indicated by mmc devices in the EXT_CSD
would only be used in u-boot if the size indicated is greater than
2 GB. This seems to be incorrect. I am working with a 4 GB Micron
eMMC device that after partition configuration and setting the
user data area to enhanced mode has a remaining capacity of less
than 2 GB for the user data area. JESD84-B50 explicitly states in
6.2.4 that for these devices SEC_CNT from the EXT_CSD is still
valid even if the memory size for that device has dropped below
2 GB by the partition configuration applied. The access mode bits
from the OCR register seem to provide a better way to decide
whether to use the CSD-based C_SIZE & C_MULT or the EXT_CSD-based
SEC_CNT information when determining the device's capacity.
In particular, this fixes a bug where u-boot SPL would assign 0 to
mmc->block_dev.lba later on in the mmc_startup() function and
subsequently fail to load u-boot from that mmc due to the original
C_SIZE & C_MULT code assigning a 4 TB size to mmc->capacity, that
incorrect capacity never being overwritten by the SEC_CNT capacity
calculation (due to its size being less than 2 GB) and then finally
lldiv(mmc->capacity, mmc->read_bl_len) exceeding the 32-bit result
data type of mmc->block_dev.lba.
Signed-off-by: Frank Bormann <fbormann@yahoo.com>
---
drivers/mmc/mmc.c | 10 +++++-----
include/mmc.h | 1 +
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index c6a1c23..c5d1efc 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -935,19 +935,19 @@ static int mmc_startup(struct mmc *mmc)
if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) {
/* check ext_csd version and capacity */
err = mmc_send_ext_csd(mmc, ext_csd);
- if (!err && (ext_csd[EXT_CSD_REV] >= 2)) {
+ if (!err && (ext_csd[EXT_CSD_REV] >= 2) &&
+ (mmc->ocr & OCR_ACCESS_MODE) == OCR_ACCESS_BY_SECTOR) {
/*
* According to the JEDEC Standard, the value of
- * ext_csd's capacity is valid if the value is more
- * than 2GB
+ * ext_csd's capacity is valid if the device addresses
+ * its memory by sector
*/
capacity = ext_csd[EXT_CSD_SEC_CNT] << 0
| ext_csd[EXT_CSD_SEC_CNT + 1] << 8
| ext_csd[EXT_CSD_SEC_CNT + 2] << 16
| ext_csd[EXT_CSD_SEC_CNT + 3] << 24;
capacity *= MMC_MAX_BLOCK_LEN;
- if ((capacity >> 20) > 2 * 1024)
- mmc->capacity_user = capacity;
+ mmc->capacity_user = capacity;
}
switch (ext_csd[EXT_CSD_REV]) {
diff --git a/include/mmc.h b/include/mmc.h
index e1060b9..816b580 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -104,6 +104,7 @@
#define OCR_HCS 0x40000000
#define OCR_VOLTAGE_MASK 0x007FFF80
#define OCR_ACCESS_MODE 0x60000000
+#define OCR_ACCESS_BY_SECTOR (1 << 30)
#define SECURE_ERASE 0x80000000
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-11-25 9:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20161123130522epcas2p4bc96c43b6349b39d5bf69083e4dae044@epcas2p4.samsung.com>
2016-11-23 13:04 ` [U-Boot] [RFC PATCH 1/1] Read mmc device memory capacity from EXT_CSD if memory is addressed by sector Tomas Melin
2016-11-24 1:55 ` Jaehoon Chung
2016-11-25 7:56 ` Tomas Melin
2016-11-25 9:18 ` Jaehoon Chung
2014-02-05 20:00 Frank Bormann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.