diff mbox series

mmc: core: Fix init of SD cards reporting an invalid VDD range

Message ID 20190827081043.15443-1-ulf.hansson@linaro.org
State New
Headers show
Series mmc: core: Fix init of SD cards reporting an invalid VDD range | expand

Commit Message

Ulf Hansson Aug. 27, 2019, 8:10 a.m. UTC
The OCR register defines the supported range of VDD voltages for SD cards.
However, it has turned out that some SD cards reports an invalid voltage
range, for example having bit7 set.

When a host supports MMC_CAP2_FULL_PWR_CYCLE and some of the voltages from
the invalid VDD range, this triggers the core to run a power cycle of the
card to try to initialize it at the lowest common supported voltage.
Obviously this fails, since the card can't support it.

Let's fix this problem, by clearing invalid bits from the read OCR register
for SD cards, before proceeding with the VDD voltage negotiation.

Cc: stable@vger.kernel.org
Reported-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

---
 drivers/mmc/core/sd.c | 6 ++++++
 1 file changed, 6 insertions(+)

-- 
2.17.1

Comments

Philip Langdale Aug. 28, 2019, 1:15 a.m. UTC | #1
On Tue, 27 Aug 2019 10:10:43 +0200
Ulf Hansson <ulf.hansson@linaro.org> wrote:

> The OCR register defines the supported range of VDD voltages for SD

> cards. However, it has turned out that some SD cards reports an

> invalid voltage range, for example having bit7 set.

> 

> When a host supports MMC_CAP2_FULL_PWR_CYCLE and some of the voltages

> from the invalid VDD range, this triggers the core to run a power

> cycle of the card to try to initialize it at the lowest common

> supported voltage. Obviously this fails, since the card can't support

> it.

> 

> Let's fix this problem, by clearing invalid bits from the read OCR

> register for SD cards, before proceeding with the VDD voltage

> negotiation.

> 

> Cc: stable@vger.kernel.org

> Reported-by: Philip Langdale <philipl@overt.org>

> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

> ---

>  drivers/mmc/core/sd.c | 6 ++++++

>  1 file changed, 6 insertions(+)

> 

> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c

> index d681e8aaca83..fe914ff5f5d6 100644

> --- a/drivers/mmc/core/sd.c

> +++ b/drivers/mmc/core/sd.c

> @@ -1292,6 +1292,12 @@ int mmc_attach_sd(struct mmc_host *host)

>  			goto err;

>  	}

>  

> +	/*

> +	 * Some SD cards claims an out of spec VDD voltage range.

> Let's treat

> +	 * these bits as being in-valid and especially also bit7.

> +	 */

> +	ocr &= ~0x7FFF;

> +

>  	rocr = mmc_select_voltage(host, ocr);

>  

>  	/*


Looks right. Tried it out and worked as expected.

Reviewed-by: Philip Langdale <philipl@overt.org>


--phil
Ulf Hansson Aug. 28, 2019, 10:07 a.m. UTC | #2
On Wed, 28 Aug 2019 at 03:15, Philip Langdale <philipl@overt.org> wrote:
>

> On Tue, 27 Aug 2019 10:10:43 +0200

> Ulf Hansson <ulf.hansson@linaro.org> wrote:

>

> > The OCR register defines the supported range of VDD voltages for SD

> > cards. However, it has turned out that some SD cards reports an

> > invalid voltage range, for example having bit7 set.

> >

> > When a host supports MMC_CAP2_FULL_PWR_CYCLE and some of the voltages

> > from the invalid VDD range, this triggers the core to run a power

> > cycle of the card to try to initialize it at the lowest common

> > supported voltage. Obviously this fails, since the card can't support

> > it.

> >

> > Let's fix this problem, by clearing invalid bits from the read OCR

> > register for SD cards, before proceeding with the VDD voltage

> > negotiation.

> >

> > Cc: stable@vger.kernel.org

> > Reported-by: Philip Langdale <philipl@overt.org>

> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

> > ---

> >  drivers/mmc/core/sd.c | 6 ++++++

> >  1 file changed, 6 insertions(+)

> >

> > diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c

> > index d681e8aaca83..fe914ff5f5d6 100644

> > --- a/drivers/mmc/core/sd.c

> > +++ b/drivers/mmc/core/sd.c

> > @@ -1292,6 +1292,12 @@ int mmc_attach_sd(struct mmc_host *host)

> >                       goto err;

> >       }

> >

> > +     /*

> > +      * Some SD cards claims an out of spec VDD voltage range.

> > Let's treat

> > +      * these bits as being in-valid and especially also bit7.

> > +      */

> > +     ocr &= ~0x7FFF;

> > +

> >       rocr = mmc_select_voltage(host, ocr);

> >

> >       /*

>

> Looks right. Tried it out and worked as expected.

>

> Reviewed-by: Philip Langdale <philipl@overt.org>


Thanks! I add your tested-by tag as well!

Kind regards
Uffe
Manuel Presnitz Aug. 29, 2019, 5:23 p.m. UTC | #3
Thanks for your efforts and the patch!

I tested it on my "Fujitsu Celsius H760" notebook running kernel version 5.2.7 (Arch). It has a "Realtek Semiconductor Co., Ltd. RTS524A PCI Express Card Reader" using the "rtsx_pci" module.

Without the patch my "SanDisk Extreme SD-XC UHS-I" card (128GB) had thrown the error "mmc0: error -110 whilst initialising SD card", but with the patch the very same card is recognized and is working flawlessly!

Regards,
Manuel.
Manuel Presnitz Aug. 29, 2019, 5:38 p.m. UTC | #4
Thanks for your efforts and the patch!

I tested it on my "Fujitsu Celsius H760" notebook running kernel version 5.2.7 (Arch). It has a "Realtek Semiconductor Co., Ltd. RTS524A PCI Express Card Reader" using the "rtsx_pci" module.

Without the patch my "SanDisk Extreme SD-XC UHS-I" card (128GB) had thrown the error "mmc0: error -110 whilst initialising SD card", but with the patch the very same card is recognized and is working flawlessly.

Regards,
Manuel.
Ulf Hansson Aug. 30, 2019, 7:19 a.m. UTC | #5
On Thu, 29 Aug 2019 at 19:42, Manuel Presnitz <mail@mpy.de> wrote:
>

> Thanks for your efforts and the patch!

>

> I tested it on my "Fujitsu Celsius H760" notebook running kernel version 5.2.7 (Arch). It has a "Realtek Semiconductor Co., Ltd. RTS524A PCI Express Card Reader" using the "rtsx_pci" module.

>

> Without the patch my "SanDisk Extreme SD-XC UHS-I" card (128GB) had thrown the error "mmc0: error -110 whilst initialising SD card", but with the patch the very same card is recognized and is working flawlessly!


That's great news, thanks for testing and reporting back!

I all a tested-by tag from you, thanks!

Kind regards
Uffe
diff mbox series

Patch

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index d681e8aaca83..fe914ff5f5d6 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -1292,6 +1292,12 @@  int mmc_attach_sd(struct mmc_host *host)
 			goto err;
 	}
 
+	/*
+	 * Some SD cards claims an out of spec VDD voltage range. Let's treat
+	 * these bits as being in-valid and especially also bit7.
+	 */
+	ocr &= ~0x7FFF;
+
 	rocr = mmc_select_voltage(host, ocr);
 
 	/*