From patchwork Mon Jun 28 23:29:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 468023 Delivered-To: patch@linaro.org Received: by 2002:a17:906:71d0:0:0:0:0 with SMTP id i16csp4599377ejk; Mon, 28 Jun 2021 16:32:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxY5iMsn4LGB+Y/RVvUX02bRISZt0vOK705T7XoJZoCfjxw1BZm7/cL2l1D6ry3Tsp+0zW X-Received: by 2002:a05:6e02:1be3:: with SMTP id y3mr13356791ilv.142.1624923136221; Mon, 28 Jun 2021 16:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624923136; cv=none; d=google.com; s=arc-20160816; b=zKPZS3iHCWhbKkWwYEBHdC7ujaEVvOqrqXj71xadABk25KTY7ojSJIyyuBXVeYtb61 ORzsUH/B0VW3zE6RsZpht8ZDt4V2PdAWIbBTjYuuIC3lNi+4O9TcNTxXvsxOfj0kNMxi WEkuNu6QB8STHuFzMSvIJt9zsuNldcQlEzipGvIhxSpWshXPpLQrMeFrQCbe++qdt53U P/1Trz8mrtL7T6m9QDGxIsQ0VkTn6vMWt6fK44J93VNCPmPl4Ne07IBOeVePjvOXpHZK XKMUABZxFXCbnmfLN7GebG/Y4axTE0/3xZZ5f0c/ld1gCTIPibDu1lClXKYnroixZHuq 1F8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=kLrPJPzrw+zAIGl8nSTJBfgBHgjvUBIJcNiPK6FAFU4=; b=Q+9w7NiLqGhHWCGulgp1yfc2CuqoOVP6hxtGZ3lvHFJvKM5z4sGcdvfz8KjePVXUYS V3KyWO9Rt4OWabO70eMKjzM3k/znHS10EI9lFHj/xuDlAsELKakeYUExQygL89w8nmXb TTdHEq0E37LzyonRNlrrVrpVglq7pLAIljJanmCVNVdKmTH77zfxZaIdlx04JVOxqsVe MWxGbB15gl5WVpeZ3Cr1raS3xVJvfB1y2J4eERCHFxY0pLmm3DD+Jn/H6XwKc2CFjIO6 8JPgtWXjE2PpSst6V5C54Sw+zeKO2RO6A9KPHGhASNeSKxtvXEEfPUMUrAG9YqBWtSwm LQxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NHX7fKB7; spf=pass (google.com: domain of linux-mmc-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z17si3406098jal.97.2021.06.28.16.32.15; Mon, 28 Jun 2021 16:32:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-mmc-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NHX7fKB7; spf=pass (google.com: domain of linux-mmc-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233000AbhF1Xei (ORCPT + 4 others); Mon, 28 Jun 2021 19:34:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233465AbhF1Xeh (ORCPT ); Mon, 28 Jun 2021 19:34:37 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFB5BC061760 for ; Mon, 28 Jun 2021 16:32:09 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id h15so35707448lfv.12 for ; Mon, 28 Jun 2021 16:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kLrPJPzrw+zAIGl8nSTJBfgBHgjvUBIJcNiPK6FAFU4=; b=NHX7fKB7ANNICrPZXzlYB7ZsgAOViQSz3LOvFyyChxVpsbqNhUgqaZSiqsYxQr+f19 t8wn1SnHcRDi2icOxqGSOHkRL5dqT2c7OEM8O8Rwxw3pQEJi3OzrHDhCGQRcca+njEbm dANMWrs8olk7uqY8Mg4IWFtoltEiOob+xZ/vISc0yVpxy6qOR4pcA4DQA9Hz2mDXDhyW iRxB48uaaQM57hLHocnpeZV+unbEysaCUVWHqnRN15zV0U4SwDFKAKucq1WE/eeXR2eW PgSDqlpa+JR4QWmOIktG8bXrCTwLLKb5s48vNjDqeFYJz0IXBpuskBDXeEejwz6aXoo8 8A+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kLrPJPzrw+zAIGl8nSTJBfgBHgjvUBIJcNiPK6FAFU4=; b=DlvBM0pxQujXan/4WSCcDzItCdM1mY822tqDyZVfYAiNqCIr/d6ly13X+2epUj/F3O fXQnCLrK5H+m0LrP4bk5VLLdqpTRKoXDHLihG5jfajTiDmA+v/Pgd9jLAJWES+9UG5j6 YefzCLGRhSa4qOyGnosxwKxqaFz0E8czfRIDM70TQ9Dzr3SWp/HahrKvx5f98Qj4L/l8 JTBd5qUB5yuRiFdVjB+a16IxN+twK1WnICXR7j5IJR4gglyCV3SLs7SmnMFxzNulfZt5 NWbDbqGZp+KnIOFsHP7u09HIfd5YFCJRzUxAZ0ozaaDLq0Y0YHrtUE9f/ZwV0TvBMO41 IZOA== X-Gm-Message-State: AOAM533kPxchY1VazRzr2OFwlCUPsJKU0fSoiqueBGvNHmBWusQ7C1Cl y7VbvfJNDscMaUrSwwBrFtLaC+xVH3PI/w== X-Received: by 2002:ac2:4e06:: with SMTP id e6mr8373411lfr.449.1624923127533; Mon, 28 Jun 2021 16:32:07 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id p40sm1434020lfa.171.2021.06.28.16.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jun 2021 16:32:07 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij , phone-devel@vger.kernel.org, Stephan Gerhold , newbyte@disroot.org Subject: [PATCH] mmc: core: Add a card quirk for broken boot partitions Date: Tue, 29 Jun 2021 01:29:55 +0200 Message-Id: <20210628232955.3327484-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Some boot partitions on the Samsung 4GB KLM4G1YE4C "4YMD1R" card appear broken when accessed randomly. CMD6 to switch back to the main partition randomly stalls after CMD18 access to the boot partition 1, and the card never comes back online. The accesses to the boot partitions work several times before this happens. I tried using only single blocks with CMD17 on the boot partitions with the result that it crashed even faster. The card may survive on older kernels, but this seems to be because recent kernel partition parsers are accessing the boot partitions more, and we get more block traffic to the boot partitions during kernel startup. My only conclusion is that the boot partitions are somehow broken on this card, and we add a quirk for this. After applying this patch, the main partition can be accessed and mounted without problems. This eMMC card is found in the Samsung GT-S7710 mobile phone. Cc: phone-devel@vger.kernel.org Cc: Stephan Gerhold Reported-by: newbyte@disroot.org Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 6 ++++++ drivers/mmc/core/quirks.h | 7 +++++++ include/linux/mmc/card.h | 1 + 3 files changed, 14 insertions(+) -- 2.31.1 Signed-off-by: Ulf Hansson Signed-off-by: Ulf Hansson diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 689eb9afeeed..e6cde68cda0e 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -2621,6 +2621,12 @@ static int mmc_blk_alloc_parts(struct mmc_card *card, struct mmc_blk_data *md) card->part[idx].name); if (ret) return ret; + } else if((card->part[idx].area_type & MMC_BLK_DATA_AREA_BOOT) && + (card->quirks & MMC_QUIRK_BROKEN_BOOT_PARTITIONS)) { + pr_info("%s: skipping broken boot partition %s\n", + mmc_hostname(card->host), + card->part[idx].name); + continue; } else if (card->part[idx].size) { ret = mmc_blk_alloc_part(card, md, card->part[idx].part_cfg, diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h index d68e6e513a4f..aa4060c10aa9 100644 --- a/drivers/mmc/core/quirks.h +++ b/drivers/mmc/core/quirks.h @@ -99,6 +99,13 @@ static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = { MMC_FIXUP("V10016", CID_MANFID_KINGSTON, CID_OEMID_ANY, add_quirk_mmc, MMC_QUIRK_TRIM_BROKEN), + /* + * Some Samsung eMMCs have broken boot partitions, accessing them + * randomly will make the device lock up and crash. + */ + MMC_FIXUP("4YMD1R", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc, + MMC_QUIRK_BROKEN_BOOT_PARTITIONS), + END_FIXUP }; diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index f9ad35dd6012..4006736f59dd 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -259,6 +259,7 @@ struct mmc_card { /* for byte mode */ #define MMC_QUIRK_NONSTD_SDIO (1<<2) /* non-standard SDIO card attached */ /* (missing CIA registers) */ +#define MMC_QUIRK_BROKEN_BOOT_PARTITIONS (1<<3) /* Disable broken boot partitions */ #define MMC_QUIRK_NONSTD_FUNC_IF (1<<4) /* SDIO card has nonstd function interfaces */ #define MMC_QUIRK_DISABLE_CD (1<<5) /* disconnect CD/DAT[3] resistor */ #define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */