diff mbox series

[U-Boot,v1,1/2] mmc: Fix bug in sd_set_card_speed()

Message ID 1518174568-12404-2-git-send-email-jjhiblot@ti.com
State Accepted
Commit a0276f3eeed539cbc5ecba694030519dcd1fe308
Delegated to: Jaehoon Chung
Headers show
Series [U-Boot,v1,1/2] mmc: Fix bug in sd_set_card_speed() | expand

Commit Message

Jean-Jacques Hiblot Feb. 9, 2018, 11:09 a.m. UTC
After settings the speed of the sd with the switch command, a check is
done to make sure that the new speed has been set. The current check has a
masking error: speed are encoded on 4 bits only.
Fix it by masking the upper bits.

This fixes a problem seen with QEmu emulating a vexpress-a15.

Reported-by: Jonathan Gray <jsg@jsg.id.au>
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>

---

 drivers/mmc/mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jonathan Gray Feb. 9, 2018, 10:52 p.m. UTC | #1
On Fri, Feb 09, 2018 at 12:09:27PM +0100, Jean-Jacques Hiblot wrote:
> After settings the speed of the sd with the switch command, a check is
> done to make sure that the new speed has been set. The current check has a
> masking error: speed are encoded on 4 bits only.
> Fix it by masking the upper bits.
> 
> This fixes a problem seen with QEmu emulating a vexpress-a15.
> 
> Reported-by: Jonathan Gray <jsg@jsg.id.au>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>

With this change the emulated mmc controller can be accessed again here.

Tested-by: Jonathan Gray <jsg@jsg.id.au>

> 
> ---
> 
>  drivers/mmc/mmc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 255310a..31614dd 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1333,7 +1333,7 @@ static int sd_set_card_speed(struct mmc *mmc, enum bus_mode mode)
>  	if (err)
>  		return err;
>  
> -	if ((__be32_to_cpu(switch_status[4]) >> 24) != speed)
> +	if (((__be32_to_cpu(switch_status[4]) >> 24) & 0xF) != speed)
>  		return -ENOTSUPP;
>  
>  	return 0;
> -- 
> 1.9.1
>
Jaehoon Chung Feb. 12, 2018, 10:43 a.m. UTC | #2
On 02/10/2018 07:52 AM, Jonathan Gray wrote:
> On Fri, Feb 09, 2018 at 12:09:27PM +0100, Jean-Jacques Hiblot wrote:
>> After settings the speed of the sd with the switch command, a check is
>> done to make sure that the new speed has been set. The current check has a
>> masking error: speed are encoded on 4 bits only.
>> Fix it by masking the upper bits.
>>
>> This fixes a problem seen with QEmu emulating a vexpress-a15.
>>
>> Reported-by: Jonathan Gray <jsg@jsg.id.au>
>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> 
> With this change the emulated mmc controller can be accessed again here.
> 
> Tested-by: Jonathan Gray <jsg@jsg.id.au>

Thanks for testing. I will pick this. When i apply to u-boot-mmc, i will notice.

Best Regards,
Jaehoon Chung

> 
>>
>> ---
>>
>>  drivers/mmc/mmc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>> index 255310a..31614dd 100644
>> --- a/drivers/mmc/mmc.c
>> +++ b/drivers/mmc/mmc.c
>> @@ -1333,7 +1333,7 @@ static int sd_set_card_speed(struct mmc *mmc, enum bus_mode mode)
>>  	if (err)
>>  		return err;
>>  
>> -	if ((__be32_to_cpu(switch_status[4]) >> 24) != speed)
>> +	if (((__be32_to_cpu(switch_status[4]) >> 24) & 0xF) != speed)
>>  		return -ENOTSUPP;
>>  
>>  	return 0;
>> -- 
>> 1.9.1
>>
> 
> 
>
Jaehoon Chung Feb. 19, 2018, 11:23 a.m. UTC | #3
On 02/09/2018 08:09 PM, Jean-Jacques Hiblot wrote:
> After settings the speed of the sd with the switch command, a check is
> done to make sure that the new speed has been set. The current check has a
> masking error: speed are encoded on 4 bits only.
> Fix it by masking the upper bits.
> 
> This fixes a problem seen with QEmu emulating a vexpress-a15.
> 
> Reported-by: Jonathan Gray <jsg@jsg.id.au>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>

Applied to u-boot-mmc. Thanks!

Best Regards,
Jaehoon Chung

> 
> ---
> 
>  drivers/mmc/mmc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 255310a..31614dd 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1333,7 +1333,7 @@ static int sd_set_card_speed(struct mmc *mmc, enum bus_mode mode)
>  	if (err)
>  		return err;
>  
> -	if ((__be32_to_cpu(switch_status[4]) >> 24) != speed)
> +	if (((__be32_to_cpu(switch_status[4]) >> 24) & 0xF) != speed)
>  		return -ENOTSUPP;
>  
>  	return 0;
>
diff mbox series

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 255310a..31614dd 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1333,7 +1333,7 @@  static int sd_set_card_speed(struct mmc *mmc, enum bus_mode mode)
 	if (err)
 		return err;
 
-	if ((__be32_to_cpu(switch_status[4]) >> 24) != speed)
+	if (((__be32_to_cpu(switch_status[4]) >> 24) & 0xF) != speed)
 		return -ENOTSUPP;
 
 	return 0;