Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp376703rdb; Thu, 2 Nov 2023 06:26:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiDa4hHGI3t/w+ZTHdKKfML0XGX+QiXRhpKNtLzmIvOw56Um89GGgw9u01wIfpFWi0/4yy X-Received: by 2002:a92:d68c:0:b0:359:4c9a:9a93 with SMTP id p12-20020a92d68c000000b003594c9a9a93mr2967427iln.31.1698931601011; Thu, 02 Nov 2023 06:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698931600; cv=none; d=google.com; s=arc-20160816; b=ijdzrdVM1kSwXVkcgUyl1ssX/WRBJO5TAPGTDl9SwGr9k9oAbdmT6sqWpNEO81M6I7 2hG2a4LY9DJExgbzCrr8o8JxIVoaOd8mnVSxrrInqvP0wFN5sCPBVQbZceIQ8mgIijoa 25vBN28OxdQAJgckFrLsY7NEANmYK5GYbnIsPMAbM0JDV7bZKgbfqBDQI3IRRca7KSKo u4qu+xaGtPfuqyHZBqtMoAJNuFcoNMoaIo0G4vmEoI2pMiZkh3+R1MZaiexPZ9IVtWlW Igq2P4EWa58ylWav+H+wZyzp+dPM+mtMPdsx8AZtZC0bABevchPRNoLxHkY4wreGazPe c6eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=JT2WiqrUWiKdMUK5Gi6pkMsSfdNk0yg7yzJZhitgBsA=; fh=+2wiGDqipVWlWy9AbpZMBHxEtxRmbahDZGmW74iwKPU=; b=qi6ZWIWe+YIvDUCtarIp7nqSJJ5xYNpL+9c7rpEBfl/GhLROVQniT7mAzXWlxzzJXT mthGHyvjokWILFQNMbxaVaNHP0v7g2qJ0TD4X0SqVMS2lhb5Ft/rk2TkK+hi47qryA8/ zX8UPMVZjYKp79Fps8D4ktCiCKV0Nezi3ZLuRKGDfN37FmbR9pEvcgTGUNgXmeXL3SnJ kWL/a//J7fDXa1Tz9yWVezUYqg8Nz6Q5EkM1LLOCHtl7C/ZwGcN6p1YLhwuKgwcF3eyh 5DMqw6Z2Qqkegfor2ljt0hrmfTSohzx2r6WafqhgsazhcddzR8Rz8/Hby2FutoQA6DMd FlUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xj51gx7K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y5-20020a655285000000b0057d7cff25besi1837003pgp.829.2023.11.02.06.26.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 06:26:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xj51gx7K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CE85D80A1860; Thu, 2 Nov 2023 06:26:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376414AbjKBNZz (ORCPT + 99 others); Thu, 2 Nov 2023 09:25:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376495AbjKBNZx (ORCPT ); Thu, 2 Nov 2023 09:25:53 -0400 Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80CF41A3 for ; Thu, 2 Nov 2023 06:25:46 -0700 (PDT) Received: by mail-yb1-xb30.google.com with SMTP id 3f1490d57ef6-d9beb863816so947184276.1 for ; Thu, 02 Nov 2023 06:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698931545; x=1699536345; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=JT2WiqrUWiKdMUK5Gi6pkMsSfdNk0yg7yzJZhitgBsA=; b=xj51gx7KwSodbO9MrV0la61ZtLySF2U28ZO6nJHEHxEjtA0o9k1+tj0U0CMzff2EI8 dXRlyyfz2Fd6Le5hILECRe1wUJmxlEWcLPoyHvW5OcpFmxTOJsTSrMGLpjWLFMyX+E53 XBDxog39SjamvhEL0sV6JpCk9IftoSHX3UaKfsq1ryAmH4Tm7xuscJBEQuAYx6t1kw5b TyLtBWaPk6/haIr35DwGfeSpUgMIsNwxpUpm0kuj78Vxu6N3huiepR22z8Hzp/sinfUl xvq0isGYJOthog1MmTrRU+GGuQktS9TOmD3OhMvJ6oqdE28/9IEPROS4GZDG0sh4h/yR 1mgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698931545; x=1699536345; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JT2WiqrUWiKdMUK5Gi6pkMsSfdNk0yg7yzJZhitgBsA=; b=ApF4cCZpKuGHWI9/epKjjAiH8g8IYYQFUXbGuXcTdj8rDasjJXw78uRSaUv8fdiMQ8 Ei+3qGSVLdExDJHCqFCA3nvcqqcN+1zsqCs/8Koft9tfMqlCwUbNpNuzad7rpSA9ffZJ sXh9U8t66EBkSg+pXg6hJKwh/Xsmv+0GAr6rwWZa1Hw+Ja1GtKt2PInQXs9a7A5SAirU QCVG+7oVDHO5Dp2oVN78wS2F2XTdbEk2l43/syBe+zAFr/h7+gVEOpuj1nFaUp6oFXqS 9jVGT9Rccq80wnfyIRJwchR6/MiKtjLtawmSFfvzXmA+VHe+xvlx2yOTRc8X7E1Ugj04 9FyQ== X-Gm-Message-State: AOJu0YzatpHLX0QCc8gU1u6PilikNDTj2pkZ4aww2a02zRS5KCs3TSjz KyB9bpZJfLgUeJKiMOlAJhLB+OhOAtop4z1OIFQTdA== X-Received: by 2002:a25:8485:0:b0:d9a:c5f7:f848 with SMTP id v5-20020a258485000000b00d9ac5f7f848mr14839901ybk.63.1698931545478; Thu, 02 Nov 2023 06:25:45 -0700 (PDT) MIME-Version: 1.0 References: <20231026075230.414685-1-dominique.martinet@atmark-techno.com> In-Reply-To: <20231026075230.414685-1-dominique.martinet@atmark-techno.com> From: Ulf Hansson Date: Thu, 2 Nov 2023 14:25:09 +0100 Message-ID: Subject: Re: [PATCH] mmc: truncate quirks' oemid to 8 bits To: Avri Altman , Dominique Martinet Cc: Dominique Martinet , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Alex Fetters Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 02 Nov 2023 06:26:12 -0700 (PDT) On Thu, 26 Oct 2023 at 09:52, Dominique Martinet 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 > Cc: stable@vger.kernel.org > Cc: Avri Altman > Cc: Ulf Hansson > Cc: Alex Fetters > --- > 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 > >