Message ID | 20231026075230.414685-1-dominique.martinet@atmark-techno.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp499346vqb; Thu, 26 Oct 2023 00:59:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHvG2UYZYXmwiRADUsPqIuJFaTdfUsCby2ukXSkOcZqYPOpUDhZd5eKVLi+X3TfZDFI1nf X-Received: by 2002:a0d:f387:0:b0:586:9ce4:14e8 with SMTP id c129-20020a0df387000000b005869ce414e8mr13271829ywf.52.1698307147920; Thu, 26 Oct 2023 00:59:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698307147; cv=none; d=google.com; s=arc-20160816; b=Yncc1UodI6iSU3dBmVqRTOIJ6q0fD16D/4Q8z5pF1+AmNah2KfObd+pDXGiknsGl8i FtWcfBg5dwMfCpCNd+9Nc6WcAvXmbZpBBzkQQFaYZuFq0to8R5PGvt/YrOK720i3yTSU i64TlUTRjaF2rMJ4Z0/YOVCQYMUup3IgFKIuHdFqgJX+vyzwqIZITVAeV3bMiS82octQ u6U4ZMDMjp4o89qLnnZ0lUR0llt8lnzB2+DVcESJMAw8DtS0zrhTK2K0OKCSEpmElxn3 jWqb8P1TCO86Wl7BAT8BkYymxW+1mPXImG3Ru5zrTspTKWJ7lJI5Q7HyeJzY6/k5KA0w v1og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from; bh=+lAIq6u9pTYK8uuKU3nuhyjh5nuKNcKCButdhJ6GhKA=; fh=LMsYRtgDhVRgxwfvBX0DyrA0+o8OtWYhujKGLA/2tCo=; b=cdzvb2wEDHLJ4OR0n1sdAVU6F0dKE7Zs770p0NFvVaKaAjkaYyoTTEnhx8AvSKUpWB V0db/5Tgk2dtcRFumPyhcpMKzvMUtWuiEV4cs2OdoEyB82HXWTGgYWW/NTPNnaHF3xfI IEoHe0bla8ZZi6cBB4qaOHOQf1cw1t4NMHa0qo3mzZn8ETzGIZjRH0rVnmf1EdO6JRuG Fdd4cBhRagmabCRoiHpc0VPSVKlWjordnZIAtq7EPwrYKvNITCWD76Zmb2uS4FV+CJCh OmSxwM41Xidp8L6i7HHfWVrvP/vDpoiwDGGOVyXjFz8JXJBWOUJrTF6KVxfKL4WJF7su fSXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id k1-20020a819301000000b0059f7c69d4d7si15567221ywg.371.2023.10.26.00.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 00:59:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2841C80DA9B4; Thu, 26 Oct 2023 00:59:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344448AbjJZH65 (ORCPT <rfc822;aposhian.dev@gmail.com> + 26 others); Thu, 26 Oct 2023 03:58:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229882AbjJZH6x (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 26 Oct 2023 03:58:53 -0400 X-Greylist: delayed 360 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 26 Oct 2023 00:58:51 PDT Received: from gw.atmark-techno.com (gw.atmark-techno.com [13.115.124.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2601518D for <linux-kernel@vger.kernel.org>; Thu, 26 Oct 2023 00:58:50 -0700 (PDT) Received: from gw.atmark-techno.com (localhost [127.0.0.1]) by gw.atmark-techno.com (Postfix) with ESMTP id E895360136 for <linux-kernel@vger.kernel.org>; Thu, 26 Oct 2023 16:52:48 +0900 (JST) Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by gw.atmark-techno.com (Postfix) with ESMTPS id 5DFB760127 for <linux-kernel@vger.kernel.org>; Thu, 26 Oct 2023 16:52:48 +0900 (JST) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-27d56564684so593040a91.2 for <linux-kernel@vger.kernel.org>; Thu, 26 Oct 2023 00:52:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698306767; x=1698911567; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+lAIq6u9pTYK8uuKU3nuhyjh5nuKNcKCButdhJ6GhKA=; b=MIwOf0ChEczT4bWVhYJuMl9ANsGRdsuViyuzLORcDHpzcG1Ff2JkuoTjnTuJpa6owm cSQYvoDCjbPSdFdQIDjtXwk2tV4iZV2Ma6EIpWVcJ99LM+Ht7HPNDp627S85hpHWeBfn ZVpVhaDTI6TXAeSV2htAPTKbSlY2kOcIJ8LbTwRax2q2L3q6hn3wMVTuSiO9h3lY6iaT /C6xyVZP9wvM781PPeCAAEbPJ2wkKhd2i2k5wWK+YYIYwkwl33xootfxNOpDq1dLEuPP QGCGakWqs27j5ofuxWVzsO3TsCAn4eipn/qxKSsYKrXnD/b5CkTx6IHwMBQf7ruOUnsr 4Wpg== X-Gm-Message-State: AOJu0YyXVdZH2ZFmfzGVxCBH/pg4qE9lwoMD53YRrVHA23OE3tPuwl8o w0opx6avMaQWwLCpSkGcqxepFb56y4Su+8+ums7zS+zf6ad4dCS6nklWNmE+lbxD827YcG7v3Ke LJzVNFedhTURq1IG1wMSArzWQcS0+ X-Received: by 2002:a17:90a:5308:b0:27d:1521:11a1 with SMTP id x8-20020a17090a530800b0027d152111a1mr18119157pjh.31.1698306767112; Thu, 26 Oct 2023 00:52:47 -0700 (PDT) X-Received: by 2002:a17:90a:5308:b0:27d:1521:11a1 with SMTP id x8-20020a17090a530800b0027d152111a1mr18119145pjh.31.1698306766820; Thu, 26 Oct 2023 00:52:46 -0700 (PDT) Received: from pc-zest.atmarktech (76.125.194.35.bc.googleusercontent.com. [35.194.125.76]) by smtp.gmail.com with ESMTPSA id g19-20020a170902869300b001b9e86e05b7sm10417565plo.0.2023.10.26.00.52.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Oct 2023 00:52:46 -0700 (PDT) Received: from [::1] (helo=pc-zest.atmark.tech) by pc-zest.atmarktech with esmtp (Exim 4.96) (envelope-from <dominique.martinet@atmark-techno.com>) id 1qvvAb-001jsj-13; Thu, 26 Oct 2023 16:52:45 +0900 From: Dominique Martinet <dominique.martinet@atmark-techno.com> 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 Message-Id: <20231026075230.414685-1-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 26 Oct 2023 00:59:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780804116318100662 X-GMAIL-MSGID: 1780804116318100662 |
Series |
mmc: truncate quirks' oemid to 8 bits
|
|
Commit Message
Dominique Martinet
Oct. 26, 2023, 7:52 a.m. UTC
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(-)
Comments
> 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> Reviewed-by: Avri Altman <avri.altman@wdc.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. To me, your fix is clean, elegant and does the job. I would let the quirk owners to fix that hard-coded bogus oemid - should they choose to. I guess Sandisk would need to do that as well. Thanks, Avri > > 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 >
Avri Altman wrote on Thu, Oct 26, 2023 at 10:16:53AM +0000: > Reviewed-by: Avri Altman <avri.altman@wdc.com> Thanks for the review! > > --- > > 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. > To me, your fix is clean, elegant and does the job. > I would let the quirk owners to fix that hard-coded bogus oemid - should they choose to. > I guess Sandisk would need to do that as well. Yes, this was exactly my intention - leave the workaround in place for a while while owners fix their quirks then eventually fix types and remove this when it is no longer needed. Meanwhile, all stable kernels including the newly released 6.6 have many broken quirks and at the very least the MMC I have here would periodically hang when issuing a flush, so as a selfish user I'd appreciate if this (or something equivalent) could be making its way towards Linus' tree. Ulf, would you have a bit of time to move this forward, or should I ask Greg to temporarily revert Avri's "mmc: core: Capture correct oemid-bits for eMMC cards" commit in stable trees until the way forward is decided? Thanks!
On Thu, 26 Oct 2023 at 09:52, Dominique Martinet <dominique.martinet@atmark-techno.com> wrote: > > 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. Huh, thanks for spotting this! > > 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") I wonder if the quirk approach is really the correct thing to do. I had a closer look around what has changed along the new versions of the MMC/eMMC specs, the below is what I found. Before v4.3: OID [119:104] 16-bits. Between v4.3-v5.1: OID [111:104] 8-bits, CBX [113:112] 2-bits, reserved [119:114] 6-bits. Beyond v5.1A: OID [111:104] 8-bits, CBX [113:112] 2-bits, BIN [119:114] 6-bits. OID: OEM/Application ID CBX: Device/BGA BIN: Bank Index Number It looks to me that the offending commit (84ee19bffc93) should be reverted instead of trying to introduce some weird parsing of the card quirks. In fact, up until v5.1 it seems not to be a problem to use 16-bits for the OID, as the CBX and the reserved bits are probably just given some fixed values by the vendors, right? Beyond v5.1A, we may have a problem as the BIN may actually be used for something valuable. Maybe Avri knows more here? That said, if the offending commit is really needed to fix a problem, we need to figure out exactly what that problem is. The EXT_CSD_REV doesn't provide us with the exact version that the card is supporting, but at least we know if v5.1 and onwards is supported, so perhaps that can be used to fixup/improve the OID/CBX/BIN parsing. Kind regards Uffe > 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 > >
> On Thu, 26 Oct 2023 at 09:52, Dominique Martinet > <dominique.martinet@atmark-techno.com> wrote: > > > > 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. > > Huh, thanks for spotting this! > > > > > 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") > > I wonder if the quirk approach is really the correct thing to do. I had a closer > look around what has changed along the new versions of the MMC/eMMC > specs, the below is what I found. > > Before v4.3: OID [119:104] 16-bits. > Between v4.3-v5.1: OID [111:104] 8-bits, CBX [113:112] 2-bits, reserved > [119:114] 6-bits. > Beyond v5.1A: OID [111:104] 8-bits, CBX [113:112] 2-bits, BIN [119:114] 6- > bits. > > OID: OEM/Application ID > CBX: Device/BGA > BIN: Bank Index Number > > It looks to me that the offending commit (84ee19bffc93) should be reverted > instead of trying to introduce some weird parsing of the card quirks. Agreed. > > In fact, up until v5.1 it seems not to be a problem to use 16-bits for the OID, > as the CBX and the reserved bits are probably just given some fixed values by > the vendors, right? Or some random garbage... > > Beyond v5.1A, we may have a problem as the BIN may actually be used for > something valuable. Maybe Avri knows more here? AFAIK, we don't use it. But I can ask around. Yeah, I think its best just to revert it. If an eMMC vendor has an issue with this 16bits bogus oemid (Sandisk does) - they can handle their oemid-specific quirks - I know I will. Please note that it was picked by stable as well. Thanks, Avri > > That said, if the offending commit is really needed to fix a problem, we need > to figure out exactly what that problem is. The EXT_CSD_REV doesn't provide > us with the exact version that the card is supporting, but at least we know if > v5.1 and onwards is supported, so perhaps that can be used to fixup/improve > the OID/CBX/BIN parsing. > > Kind regards > Uffe > > > 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 > > > >
Ulf Hansson wrote on Thu, Nov 02, 2023 at 02:25:09PM +0100: > > Fixes: 84ee19bffc93 ("mmc: core: Capture correct oemid-bits for eMMC cards") > > [...] > > It looks to me that the offending commit (84ee19bffc93) should be > reverted instead of trying to introduce some weird parsing of the card > quirks. I agree that's better -- that's what I did on our stable tree until the dust settles down, I probably should have sent that instead. As Avri pointed out the offending commit was picked up to stable, but the revert should apply cleanly so if we send Greg a mail after Linus picked it up it can be reverted on all stable branches quickly. There's little value in me resending this as a revert, but process-wise I guess it's easier if someone sends it as a mail so I'll whip up a commit message and send that now. > In fact, up until v5.1 it seems not to be a problem to use 16-bits for > the OID, as the CBX and the reserved bits are probably just given some > fixed values by the vendors, right? Right, it's possible that using 8 bits here would apply the quirks to more devices than what was intended if the other 8 bits made a difference... Unfortunately that's something only vendors would know. > Beyond v5.1A, we may have a problem as the BIN may actually be used > for something valuable. Maybe Avri knows more here? > > That said, if the offending commit is really needed to fix a problem, > we need to figure out exactly what that problem is. The EXT_CSD_REV > doesn't provide us with the exact version that the card is supporting, > but at least we know if v5.1 and onwards is supported, so perhaps that > can be used to fixup/improve the OID/CBX/BIN parsing. Keep filling the full 16 bits unless rev is higher, in which case we read half? At this point (mmc_decode_cid) we can use card's ext_csd.rev so if v5.1A bumped it then it's a possibility; I don't have access to the jedec standard to check right now.
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,