All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dominique Martinet <dominique.martinet@atmark-techno.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Dominique Martinet <asmadeus@codewreck.org>,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Dominique Martinet <dominique.martinet@atmark-techno.com>,
	stable@vger.kernel.org, Avri Altman <avri.altman@wdc.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Alex Fetters <Alex.Fetters@garmin.com>
Subject: [PATCH] mmc: truncate quirks' oemid to 8 bits
Date: Thu, 26 Oct 2023 16:52:30 +0900	[thread overview]
Message-ID: <20231026075230.414685-1-dominique.martinet@atmark-techno.com> (raw)

We now only capture 8 bits for oemid in card->cid.oemid, so quirks that
were filling up the full 16 bits up till now would no longer apply.

Work around the problem by only checking for the bottom 8 bits when
checking if quirks should be applied

Fixes: 84ee19bffc93 ("mmc: core: Capture correct oemid-bits for eMMC cards")
Link: https://lkml.kernel.org/r/ZToJsSLHr8RnuTHz@codewreck.org
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
Cc: stable@vger.kernel.org
Cc: Avri Altman <avri.altman@wdc.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Alex Fetters <Alex.Fetters@garmin.com>
---
Notes:
 - mmc_fixup_device() was rewritten in 5.17, so older stable kernels
   will need a separate patch... I suppose I can send it to stable
   after this is merged if we go this way
 - struct mmc_cid's and mmc_fixup's oemid fields are unsigned shorts,
   we probably just want to make them unsigned char instead in which
   case we don't need that check anymore?
   But it's kind of nice to have a wider type so CID_OEMID_ANY can never
   be a match.... Which unfortunately my patch makes moot as
   ((unsigned short)-1) & 0xff will be 0xff which can match anything...
 - this could also be worked around in the _FIXUP_EXT macro that builds
   the fixup structs, but we're getting ugly here... Or we can just go
   for the big boom and try to fix all MMC_FIXUP() users in tree and
   call it a day, but that'll also be fun to backport.

 drivers/mmc/core/quirks.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h
index 32b64b564fb1..27e0349e176d 100644
--- a/drivers/mmc/core/quirks.h
+++ b/drivers/mmc/core/quirks.h
@@ -211,8 +211,9 @@ static inline void mmc_fixup_device(struct mmc_card *card,
 		if (f->manfid != CID_MANFID_ANY &&
 		    f->manfid != card->cid.manfid)
 			continue;
+		/* Only the bottom 8bits are valid in JESD84-B51 */
 		if (f->oemid != CID_OEMID_ANY &&
-		    f->oemid != card->cid.oemid)
+		     (f->oemid & 0xff) != (card->cid.oemid & 0xff))
 			continue;
 		if (f->name != CID_NAME_ANY &&
 		    strncmp(f->name, card->cid.prod_name,
-- 
2.39.2



             reply	other threads:[~2023-10-26  7:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26  7:52 Dominique Martinet [this message]
2023-10-26 10:16 ` [PATCH] mmc: truncate quirks' oemid to 8 bits Avri Altman
2023-11-01  4:37   ` Dominique Martinet
2023-11-02 13:25 ` Ulf Hansson
2023-11-02 13:37   ` Avri Altman
2023-11-03  0:33   ` Dominique Martinet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231026075230.414685-1-dominique.martinet@atmark-techno.com \
    --to=dominique.martinet@atmark-techno.com \
    --cc=Alex.Fetters@garmin.com \
    --cc=asmadeus@codewreck.org \
    --cc=avri.altman@wdc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.