diff mbox series

mmc: Capture correct oemid

Message ID 20230923173728.1781844-1-avri.altman@wdc.com
State Superseded
Headers show
Series mmc: Capture correct oemid | expand

Commit Message

Avri Altman Sept. 23, 2023, 5:37 p.m. UTC
The OEMID is an 8-bit binary number that identifies the Device OEM
and/or the Device contents (when used as a distribution media either on
ROM or FLASH Devices).  It occupies bits [111:104] in the CID register:
see the eMMC spec JESD84-B51 paragraph 7.2.3.

So it is 8 bits, and has been so since ever - this bug is so ancients I
couldn't even find its source.  The furthest I could go is to commit
335eadf2ef6a (sd: initialize SD cards) but its already was wrong.  Could
be because in SD its indeed 16 bits (a 2-characters ASCII string).

It is important to fix it because we are using it as one of our quirk's
token, as well as other tools, e.g. the LVFS
(https://github.com/fwupd/fwupd/).

Signed-off-by: Avri Altman <avri.altman@wdc.com>
---
 drivers/mmc/core/mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ulf Hansson Sept. 26, 2023, 2:57 p.m. UTC | #1
+ Alex

On Sat, 23 Sept 2023 at 19:38, Avri Altman <avri.altman@wdc.com> wrote:
>
> The OEMID is an 8-bit binary number that identifies the Device OEM
> and/or the Device contents (when used as a distribution media either on
> ROM or FLASH Devices).  It occupies bits [111:104] in the CID register:
> see the eMMC spec JESD84-B51 paragraph 7.2.3.
>
> So it is 8 bits, and has been so since ever - this bug is so ancients I
> couldn't even find its source.  The furthest I could go is to commit
> 335eadf2ef6a (sd: initialize SD cards) but its already was wrong.  Could
> be because in SD its indeed 16 bits (a 2-characters ASCII string).

As pointed out by Alex (offlist), it seems like this comes from the
legacy MMC specs (v3.31 and before). That probably doesn't matter as I
guess the oemid isn't that important to use for these old devices.

However, it would be nice if you could add some of this information to
the commit msg, to make this clear.

>
> It is important to fix it because we are using it as one of our quirk's
> token, as well as other tools, e.g. the LVFS
> (https://github.com/fwupd/fwupd/).
>
> Signed-off-by: Avri Altman <avri.altman@wdc.com>

Kind regards
Uffe

> ---
>  drivers/mmc/core/mmc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 89cd48fcec79..4a4bab9aa726 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -104,7 +104,7 @@ static int mmc_decode_cid(struct mmc_card *card)
>         case 3: /* MMC v3.1 - v3.3 */
>         case 4: /* MMC v4 */
>                 card->cid.manfid        = UNSTUFF_BITS(resp, 120, 8);
> -               card->cid.oemid         = UNSTUFF_BITS(resp, 104, 16);
> +               card->cid.oemid         = UNSTUFF_BITS(resp, 104, 8);
>                 card->cid.prod_name[0]  = UNSTUFF_BITS(resp, 96, 8);
>                 card->cid.prod_name[1]  = UNSTUFF_BITS(resp, 88, 8);
>                 card->cid.prod_name[2]  = UNSTUFF_BITS(resp, 80, 8);
> --
> 2.42.0
>
Avri Altman Sept. 27, 2023, 6:58 a.m. UTC | #2
> + Alex
> 
> On Sat, 23 Sept 2023 at 19:38, Avri Altman <avri.altman@wdc.com> wrote:
> >
> > The OEMID is an 8-bit binary number that identifies the Device OEM
> > and/or the Device contents (when used as a distribution media either
> > on ROM or FLASH Devices).  It occupies bits [111:104] in the CID register:
> > see the eMMC spec JESD84-B51 paragraph 7.2.3.
> >
> > So it is 8 bits, and has been so since ever - this bug is so ancients
> > I couldn't even find its source.  The furthest I could go is to commit
> > 335eadf2ef6a (sd: initialize SD cards) but its already was wrong.
> > Could be because in SD its indeed 16 bits (a 2-characters ASCII string).
> 
> As pointed out by Alex (offlist), it seems like this comes from the legacy MMC
> specs (v3.31 and before). That probably doesn't matter as I guess the oemid
> isn't that important to use for these old devices.
> 
> However, it would be nice if you could add some of this information to the
> commit msg, to make this clear.
Will do.
Also, need to add this to stable as well.

Thanks,
Avri

> 
> >
> > It is important to fix it because we are using it as one of our
> > quirk's token, as well as other tools, e.g. the LVFS
> > (https://github.com/fwupd/fwupd/).
> >
> > Signed-off-by: Avri Altman <avri.altman@wdc.com>
> 
> Kind regards
> Uffe
> 
> > ---
> >  drivers/mmc/core/mmc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index
> > 89cd48fcec79..4a4bab9aa726 100644
> > --- a/drivers/mmc/core/mmc.c
> > +++ b/drivers/mmc/core/mmc.c
> > @@ -104,7 +104,7 @@ static int mmc_decode_cid(struct mmc_card
> *card)
> >         case 3: /* MMC v3.1 - v3.3 */
> >         case 4: /* MMC v4 */
> >                 card->cid.manfid        = UNSTUFF_BITS(resp, 120, 8);
> > -               card->cid.oemid         = UNSTUFF_BITS(resp, 104, 16);
> > +               card->cid.oemid         = UNSTUFF_BITS(resp, 104, 8);
> >                 card->cid.prod_name[0]  = UNSTUFF_BITS(resp, 96, 8);
> >                 card->cid.prod_name[1]  = UNSTUFF_BITS(resp, 88, 8);
> >                 card->cid.prod_name[2]  = UNSTUFF_BITS(resp, 80, 8);
> > --
> > 2.42.0
> >
diff mbox series

Patch

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 89cd48fcec79..4a4bab9aa726 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -104,7 +104,7 @@  static int mmc_decode_cid(struct mmc_card *card)
 	case 3: /* MMC v3.1 - v3.3 */
 	case 4: /* MMC v4 */
 		card->cid.manfid	= UNSTUFF_BITS(resp, 120, 8);
-		card->cid.oemid		= UNSTUFF_BITS(resp, 104, 16);
+		card->cid.oemid		= UNSTUFF_BITS(resp, 104, 8);
 		card->cid.prod_name[0]	= UNSTUFF_BITS(resp, 96, 8);
 		card->cid.prod_name[1]	= UNSTUFF_BITS(resp, 88, 8);
 		card->cid.prod_name[2]	= UNSTUFF_BITS(resp, 80, 8);