* [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes
@ 2013-11-26 1:16 Wolfram Sang
2013-11-26 5:14 ` Jaehoon Chung
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Wolfram Sang @ 2013-11-26 1:16 UTC (permalink / raw)
To: linux-mmc
Cc: Chris Ball, Wolfram Sang, Jaehoon Chung, Kyungmin Park,
H Hartley Sweeten
This reverts and updates commit 77776fd0a4cc541b9a528eacc1d31ca47eb1ae7a
("mmc: sd: fix the maximum au_size for SD3.0"). The au_size for SD3.0
cannot be achieved by a simple bit shift, so this needs to be
implemented differently. Also, don't print the warning in case of 0
since 'not defined' is different from 'invalid'.
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: H Hartley Sweeten <hartleys@visionengravers.com>
---
Only tested with non SD3.0 cards (au = 0 and au = 9). Testers for 3.0 cards
much appreciated.
drivers/mmc/core/sd.c | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 6f42050..3b5ac4d 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -45,6 +45,13 @@ static const unsigned int tacc_mant[] = {
35, 40, 45, 50, 55, 60, 70, 80,
};
+static const unsigned int sd_au_size[] = {
+ 0, SZ_16K / 512, SZ_32K / 512, SZ_64K / 512,
+ SZ_128K / 512, SZ_256K / 512, SZ_512K / 512, SZ_1M / 512,
+ SZ_2M / 512, SZ_4M / 512, SZ_8M / 512, (SZ_8M + SZ_4M) / 512,
+ SZ_16M / 512, (SZ_16M + SZ_8M) / 512, SZ_32M / 512, SZ_64M / 512,
+};
+
#define UNSTUFF_BITS(resp,start,size) \
({ \
const int __size = size; \
@@ -216,7 +223,7 @@ static int mmc_decode_scr(struct mmc_card *card)
static int mmc_read_ssr(struct mmc_card *card)
{
unsigned int au, es, et, eo;
- int err, i, max_au;
+ int err, i;
u32 *ssr;
if (!(card->csd.cmdclass & CCC_APP_SPEC)) {
@@ -240,26 +247,25 @@ static int mmc_read_ssr(struct mmc_card *card)
for (i = 0; i < 16; i++)
ssr[i] = be32_to_cpu(ssr[i]);
- /* SD3.0 increases max AU size to 64MB (0xF) from 4MB (0x9) */
- max_au = card->scr.sda_spec3 ? 0xF : 0x9;
-
/*
* UNSTUFF_BITS only works with four u32s so we have to offset the
* bitfield positions accordingly.
*/
au = UNSTUFF_BITS(ssr, 428 - 384, 4);
- if (au > 0 && au <= max_au) {
- card->ssr.au = 1 << (au + 4);
- es = UNSTUFF_BITS(ssr, 408 - 384, 16);
- et = UNSTUFF_BITS(ssr, 402 - 384, 6);
- eo = UNSTUFF_BITS(ssr, 400 - 384, 2);
- if (es && et) {
- card->ssr.erase_timeout = (et * 1000) / es;
- card->ssr.erase_offset = eo * 1000;
+ if (au) {
+ if (au <= 9 || card->scr.sda_spec3) {
+ card->ssr.au = sd_au_size[au];
+ es = UNSTUFF_BITS(ssr, 408 - 384, 16);
+ et = UNSTUFF_BITS(ssr, 402 - 384, 6);
+ if (es && et) {
+ eo = UNSTUFF_BITS(ssr, 400 - 384, 2);
+ card->ssr.erase_timeout = (et * 1000) / es;
+ card->ssr.erase_offset = eo * 1000;
+ }
+ } else {
+ pr_warning("%s: SD Status: Invalid Allocation Unit size.\n",
+ mmc_hostname(card->host));
}
- } else {
- pr_warning("%s: SD Status: Invalid Allocation Unit "
- "size.\n", mmc_hostname(card->host));
}
out:
kfree(ssr);
--
1.8.4.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes
2013-11-26 1:16 [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes Wolfram Sang
@ 2013-11-26 5:14 ` Jaehoon Chung
2013-11-26 17:06 ` Wolfram Sang
2013-11-26 16:26 ` Hartley Sweeten
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Jaehoon Chung @ 2013-11-26 5:14 UTC (permalink / raw)
To: Wolfram Sang, linux-mmc
Cc: Chris Ball, Jaehoon Chung, Kyungmin Park, H Hartley Sweeten
Hi Wolfram,
Good catch. It's right. Looks good to me.
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Best Regards,
Jaehoon Chung
On 11/26/2013 10:16 AM, Wolfram Sang wrote:
> This reverts and updates commit 77776fd0a4cc541b9a528eacc1d31ca47eb1ae7a
> ("mmc: sd: fix the maximum au_size for SD3.0"). The au_size for SD3.0
> cannot be achieved by a simple bit shift, so this needs to be
> implemented differently. Also, don't print the warning in case of 0
> since 'not defined' is different from 'invalid'.
>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: H Hartley Sweeten <hartleys@visionengravers.com>
>
> ---
>
> Only tested with non SD3.0 cards (au = 0 and au = 9). Testers for 3.0 cards
> much appreciated.
>
> drivers/mmc/core/sd.c | 36 +++++++++++++++++++++---------------
> 1 file changed, 21 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index 6f42050..3b5ac4d 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -45,6 +45,13 @@ static const unsigned int tacc_mant[] = {
> 35, 40, 45, 50, 55, 60, 70, 80,
> };
>
> +static const unsigned int sd_au_size[] = {
> + 0, SZ_16K / 512, SZ_32K / 512, SZ_64K / 512,
> + SZ_128K / 512, SZ_256K / 512, SZ_512K / 512, SZ_1M / 512,
> + SZ_2M / 512, SZ_4M / 512, SZ_8M / 512, (SZ_8M + SZ_4M) / 512,
> + SZ_16M / 512, (SZ_16M + SZ_8M) / 512, SZ_32M / 512, SZ_64M / 512,
> +};
> +
> #define UNSTUFF_BITS(resp,start,size) \
> ({ \
> const int __size = size; \
> @@ -216,7 +223,7 @@ static int mmc_decode_scr(struct mmc_card *card)
> static int mmc_read_ssr(struct mmc_card *card)
> {
> unsigned int au, es, et, eo;
> - int err, i, max_au;
> + int err, i;
> u32 *ssr;
>
> if (!(card->csd.cmdclass & CCC_APP_SPEC)) {
> @@ -240,26 +247,25 @@ static int mmc_read_ssr(struct mmc_card *card)
> for (i = 0; i < 16; i++)
> ssr[i] = be32_to_cpu(ssr[i]);
>
> - /* SD3.0 increases max AU size to 64MB (0xF) from 4MB (0x9) */
> - max_au = card->scr.sda_spec3 ? 0xF : 0x9;
> -
> /*
> * UNSTUFF_BITS only works with four u32s so we have to offset the
> * bitfield positions accordingly.
> */
> au = UNSTUFF_BITS(ssr, 428 - 384, 4);
> - if (au > 0 && au <= max_au) {
> - card->ssr.au = 1 << (au + 4);
> - es = UNSTUFF_BITS(ssr, 408 - 384, 16);
> - et = UNSTUFF_BITS(ssr, 402 - 384, 6);
> - eo = UNSTUFF_BITS(ssr, 400 - 384, 2);
> - if (es && et) {
> - card->ssr.erase_timeout = (et * 1000) / es;
> - card->ssr.erase_offset = eo * 1000;
> + if (au) {
> + if (au <= 9 || card->scr.sda_spec3) {
> + card->ssr.au = sd_au_size[au];
> + es = UNSTUFF_BITS(ssr, 408 - 384, 16);
> + et = UNSTUFF_BITS(ssr, 402 - 384, 6);
> + if (es && et) {
> + eo = UNSTUFF_BITS(ssr, 400 - 384, 2);
> + card->ssr.erase_timeout = (et * 1000) / es;
> + card->ssr.erase_offset = eo * 1000;
> + }
> + } else {
> + pr_warning("%s: SD Status: Invalid Allocation Unit size.\n",
> + mmc_hostname(card->host));
> }
> - } else {
> - pr_warning("%s: SD Status: Invalid Allocation Unit "
> - "size.\n", mmc_hostname(card->host));
> }
> out:
> kfree(ssr);
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes
2013-11-26 1:16 [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes Wolfram Sang
2013-11-26 5:14 ` Jaehoon Chung
@ 2013-11-26 16:26 ` Hartley Sweeten
2013-12-18 12:30 ` Wolfram Sang
2014-01-13 12:41 ` Wolfram Sang
3 siblings, 0 replies; 9+ messages in thread
From: Hartley Sweeten @ 2013-11-26 16:26 UTC (permalink / raw)
To: Wolfram Sang, linux-mmc@vger.kernel.org
Cc: Chris Ball, Jaehoon Chung, Kyungmin Park
On Monday, November 25, 2013 6:16 PM, Wolfram Sang wrote:
> This reverts and updates commit 77776fd0a4cc541b9a528eacc1d31ca47eb1ae7a
> ("mmc: sd: fix the maximum au_size for SD3.0"). The au_size for SD3.0
> cannot be achieved by a simple bit shift, so this needs to be
> implemented differently. Also, don't print the warning in case of 0
> since 'not defined' is different from 'invalid'.
>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: H Hartley Sweeten <hartleys@visionengravers.com>
>
> ---
>
> Only tested with non SD3.0 cards (au = 0 and au = 9). Testers for 3.0 cards
> much appreciated.
This fixes the warning I have been seeing with cards having an au = 0.
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes
2013-11-26 5:14 ` Jaehoon Chung
@ 2013-11-26 17:06 ` Wolfram Sang
0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2013-11-26 17:06 UTC (permalink / raw)
To: Jaehoon Chung; +Cc: linux-mmc, Chris Ball, Kyungmin Park, H Hartley Sweeten
[-- Attachment #1: Type: text/plain, Size: 111 bytes --]
> Good catch. It's right. Looks good to me.
Thanks. Then this patch should probably go to stable as well...
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes
2013-11-26 1:16 [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes Wolfram Sang
2013-11-26 5:14 ` Jaehoon Chung
2013-11-26 16:26 ` Hartley Sweeten
@ 2013-12-18 12:30 ` Wolfram Sang
2014-01-13 12:41 ` Wolfram Sang
3 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2013-12-18 12:30 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, Jaehoon Chung, Kyungmin Park, H Hartley Sweeten
[-- Attachment #1: Type: text/plain, Size: 617 bytes --]
On Tue, Nov 26, 2013 at 02:16:25AM +0100, Wolfram Sang wrote:
> This reverts and updates commit 77776fd0a4cc541b9a528eacc1d31ca47eb1ae7a
> ("mmc: sd: fix the maximum au_size for SD3.0"). The au_size for SD3.0
> cannot be achieved by a simple bit shift, so this needs to be
> implemented differently. Also, don't print the warning in case of 0
> since 'not defined' is different from 'invalid'.
>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: H Hartley Sweeten <hartleys@visionengravers.com>
Ping.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes
2013-11-26 1:16 [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes Wolfram Sang
` (2 preceding siblings ...)
2013-12-18 12:30 ` Wolfram Sang
@ 2014-01-13 12:41 ` Wolfram Sang
2014-01-13 18:04 ` Chris Ball
3 siblings, 1 reply; 9+ messages in thread
From: Wolfram Sang @ 2014-01-13 12:41 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, Jaehoon Chung, Kyungmin Park, H Hartley Sweeten
[-- Attachment #1: Type: text/plain, Size: 726 bytes --]
On Tue, Nov 26, 2013 at 02:16:25AM +0100, Wolfram Sang wrote:
> This reverts and updates commit 77776fd0a4cc541b9a528eacc1d31ca47eb1ae7a
> ("mmc: sd: fix the maximum au_size for SD3.0"). The au_size for SD3.0
> cannot be achieved by a simple bit shift, so this needs to be
> implemented differently. Also, don't print the warning in case of 0
> since 'not defined' is different from 'invalid'.
>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: H Hartley Sweeten <hartleys@visionengravers.com>
>
Ping! Chris are you there? This got reviewed and acked, and I'd even
think this could be suitable for stable.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes
2014-01-13 12:41 ` Wolfram Sang
@ 2014-01-13 18:04 ` Chris Ball
2014-01-13 18:46 ` Wolfram Sang
0 siblings, 1 reply; 9+ messages in thread
From: Chris Ball @ 2014-01-13 18:04 UTC (permalink / raw)
To: Wolfram Sang; +Cc: linux-mmc, Jaehoon Chung, Kyungmin Park, H Hartley Sweeten
Hi Wolfram,
On Mon, Jan 13 2014, Wolfram Sang wrote:
> On Tue, Nov 26, 2013 at 02:16:25AM +0100, Wolfram Sang wrote:
>> This reverts and updates commit 77776fd0a4cc541b9a528eacc1d31ca47eb1ae7a
>> ("mmc: sd: fix the maximum au_size for SD3.0"). The au_size for SD3.0
>> cannot be achieved by a simple bit shift, so this needs to be
>> implemented differently. Also, don't print the warning in case of 0
>> since 'not defined' is different from 'invalid'.
>
> Ping! Chris are you there? This got reviewed and acked, and I'd even
> think this could be suitable for stable.
Sorry about that! I agree, pushed to mmc-next for 3.14 with stable@ tag.
Thanks,
- Chris.
--
Chris Ball <chris@printf.net> <http://printf.net/>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes
2014-01-13 18:04 ` Chris Ball
@ 2014-01-13 18:46 ` Wolfram Sang
2014-01-13 19:14 ` Chris Ball
0 siblings, 1 reply; 9+ messages in thread
From: Wolfram Sang @ 2014-01-13 18:46 UTC (permalink / raw)
To: Chris Ball; +Cc: linux-mmc, Jaehoon Chung, Kyungmin Park, H Hartley Sweeten
[-- Attachment #1: Type: text/plain, Size: 1577 bytes --]
On Mon, Jan 13, 2014 at 06:04:32PM +0000, Chris Ball wrote:
> Hi Wolfram,
>
> On Mon, Jan 13 2014, Wolfram Sang wrote:
> > On Tue, Nov 26, 2013 at 02:16:25AM +0100, Wolfram Sang wrote:
> >> This reverts and updates commit 77776fd0a4cc541b9a528eacc1d31ca47eb1ae7a
> >> ("mmc: sd: fix the maximum au_size for SD3.0"). The au_size for SD3.0
> >> cannot be achieved by a simple bit shift, so this needs to be
> >> implemented differently. Also, don't print the warning in case of 0
> >> since 'not defined' is different from 'invalid'.
> >
> > Ping! Chris are you there? This got reviewed and acked, and I'd even
> > think this could be suitable for stable.
>
> Sorry about that! I agree, pushed to mmc-next for 3.14 with stable@ tag.
Thanks. As buildbot reports, this will probably need another patch for
blackfin :/ Sorry about that!
From: Wolfram Sang <wsa@the-dreams.de>
Subject: [PATCH] mmc: core: add #include to support size defintions
Fixes an error found by buildbot on blackfin after adding the fix for
sd3.0 au sizes:
>> drivers/mmc/core/sd.c:49:5: error: 'SZ_16K' undeclared here (not in a function)
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
drivers/mmc/core/sd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 6f42050..585d44d 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -11,6 +11,7 @@
*/
#include <linux/err.h>
+#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/pm_runtime.h>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes
2014-01-13 18:46 ` Wolfram Sang
@ 2014-01-13 19:14 ` Chris Ball
0 siblings, 0 replies; 9+ messages in thread
From: Chris Ball @ 2014-01-13 19:14 UTC (permalink / raw)
To: Wolfram Sang; +Cc: linux-mmc, Jaehoon Chung, Kyungmin Park, H Hartley Sweeten
Hi,
On Mon, Jan 13 2014, Wolfram Sang wrote:
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index 6f42050..585d44d 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -11,6 +11,7 @@
> */
>
> #include <linux/err.h>
> +#include <linux/sizes.h>
> #include <linux/slab.h>
> #include <linux/stat.h>
> #include <linux/pm_runtime.h>
Thanks, already rebased this change into your original patch, I'll
push the amended version out to mmc-next shortly.
- Chris.
--
Chris Ball <chris@printf.net> <http://printf.net/>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-01-13 19:14 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-26 1:16 [PATCH] mmc: core: sd: implement proper support for sd3.0 au sizes Wolfram Sang
2013-11-26 5:14 ` Jaehoon Chung
2013-11-26 17:06 ` Wolfram Sang
2013-11-26 16:26 ` Hartley Sweeten
2013-12-18 12:30 ` Wolfram Sang
2014-01-13 12:41 ` Wolfram Sang
2014-01-13 18:04 ` Chris Ball
2014-01-13 18:46 ` Wolfram Sang
2014-01-13 19:14 ` Chris Ball
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox