From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f226.google.com (mail-pf1-f226.google.com [209.85.210.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6DB62E06EA for ; Wed, 22 Apr 2026 20:51:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.226 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776891089; cv=none; b=Yo25O2JY8/oVbLvbEKSbvfwsK0hgdyOqT7HCgTiGU4dvbuCZ7rglBOZ1GldBMlCQVstkfgLTFyk9+5a3sNjJs3JUYtzuebUswMvH0xXBybwmStcOtvhYfut/9ib53Q+4F1qZHpFDgXSX52BI2b1Edk2A+YhA9Z5vPfUAGQ5Y/zo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776891089; c=relaxed/simple; bh=1GMiI8COB+BglJJihwQr7e8bXjaXq6zK8yFVARs3Q/g=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=NZd5a5GUJW9BFlTpVe1OkK9pkyhh64RpFyQMF9vImKkaeVeRUuBwQWr887/QhNvOn7lB+r7Ms1nBS9s1M3swlMBbvrA2ME47rJ3MW0kQ4PPtiW2ucBqLyFr+qmgyf+lWsrORg9gY33WnEgAP/dtwYUPnw13f49jy8ELcqMlw29E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=B+Cea5Q0; arc=none smtp.client-ip=209.85.210.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="B+Cea5Q0" Received: by mail-pf1-f226.google.com with SMTP id d2e1a72fcca58-82fbf5d4dc2so2813247b3a.1 for ; Wed, 22 Apr 2026 13:51:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776891087; x=1777495887; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AXZnxNybTo7ztMKi330f3Bpew5CPkTtcRTpNIozXPrQ=; b=kYoMt4BZ+E5j3QsLph75ci7EyOuD4TeYCZ8oA7LA5tghfRqWuVPrjleHV1uUQda18l 23rGrj467GonwR12yFEH2JBNVUJyMga/wqnZKTuhlm8gLE4gTQLieiOZnrh6FR5xC3tb a5ANKo3BCzxlGjkriOZq0w/fmayRga54oAixvke8J2q2Qbo/0Gn0Cp3/WnioQ9hqgnQL JEl+IaXHonNlW+4glsHPqFYmiP2FKnP84a+L9nX0N0oetM/jGHgIaNYjAzyFDtcVcsyJ uhG031tkH4xJcJTFfykbd9qTAUKMpaJgC6JOXdyNxOeKxihK2nE2Tiv2/rWx0Epnv6B/ 0/Og== X-Forwarded-Encrypted: i=1; AFNElJ+MIVUN+pfxMplcDWwCjCoewEyeo0IveMD1Guj+yE5hIWc1q4lo+CczksCY4rvzciqPaSHgWWYLY6LGXCU=@vger.kernel.org X-Gm-Message-State: AOJu0YwtIqPszfZZ+aCx0T85k6M9iVVDub7HFMTt0VVFV50rr//alHnT TJyLIXdW4c8s4Zf5gM6es6OI/KOfYmJBA9hEAMWWEtRfdaV9ikWCqzLcrS4HVQFnq4AFnQZo6Oh bp6CAUJeKA3gYOLAThF6wFJFnpmPPQfbP22Vgr4jQwD8ErZKQLE0ik63J0oYnmELy2aSC3uklKE yUsvOgySC3jokC5sNLMy8PtjZ+H3Gzsrr8vYduI84axHqsZ7Nq6592FGr7QznwEzWwM4Q12L/Mn XMQ6Ll72Mz9Bz5Y X-Gm-Gg: AeBDieuMvN2no5Bfkw56lFWekrNxdPr2RdsZRyCmZesbbMhoWjMH6DhxmzFdDVBOubY TNx+LcOv5Rn5m0YORvrrTkGXtrYvgBMuadjFI8dDM8wQQhy9XCgINTVDV3YEWV8pikz8k8NeRVv TlDWs/hjrsMKQDRnIbUkUIVZIiT+uZU93Z4+Ah80FWzW+Um8jkAnguFaGhZH8zQ7ND7RfYN4Sbs 9fK4pE5SDb2Z+0ZDID6/0NDyvEBhgSQX5S1p576japtU8HOuxzRP8UJGC8WA+ziGxI+BNMkVXLM mzJv8XOucEH79k0p5tDSv6d/WcbtQCUiAVajJGA8/ng6Ze7aj39Bod/UV5pZud+BMyAbjKZsg8D jJfKHBh80Z+tInzZmSJ7PcO2mn1lCWRrrLzx+BX2PYj+MwloekTTJ2NOnX1jnV+kJxLZsoB1uL8 EcfODxAwS34HO5//tOvcsfa74MeRjotKhh5vpOS9qmK+/GeAirSGXQdfhuwI3Kirm4c1M= X-Received: by 2002:a05:6a00:994:b0:82f:193f:807c with SMTP id d2e1a72fcca58-82f8c7deca2mr25558936b3a.2.1776891087188; Wed, 22 Apr 2026 13:51:27 -0700 (PDT) Received: from smtp-us-east1-p01-i01-si01.dlp.protect.broadcom.com (address-144-49-247-119.dlp.protect.broadcom.com. [144.49.247.119]) by smtp-relay.gmail.com with ESMTPS id d2e1a72fcca58-82f8e965820sm1330416b3a.2.2026.04.22.13.51.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2026 13:51:27 -0700 (PDT) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-8acd145817dso74975716d6.3 for ; Wed, 22 Apr 2026 13:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1776891086; x=1777495886; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=AXZnxNybTo7ztMKi330f3Bpew5CPkTtcRTpNIozXPrQ=; b=B+Cea5Q0Rb1fhDNEzGgN6jT2kjT/AEP+vzZMhFM3Pwz3Wh5746cjWbSwC2rfwpjYfZ XijSFwVFjEZca2kAmJHv2qqyXdBZCFl9Z8Yzrt4eekn+nwmsumgjYCjrrxAiTEflOcTT kYoFGitr9LwO0ITy4Uw46tDXNXkMUAJjKZjEM= X-Forwarded-Encrypted: i=1; AFNElJ8TljQhsNmazivHF53J8qicCeF9YaV7pafKi0m2rVkX2+8xWtwu/SkvgBHCYZqq/eMyVkBWuwZsCL+NpR8=@vger.kernel.org X-Received: by 2002:a05:6214:598c:b0:8ac:a4f9:da76 with SMTP id 6a1803df08f44-8b0280cdc7bmr381919326d6.26.1776891085781; Wed, 22 Apr 2026 13:51:25 -0700 (PDT) X-Received: by 2002:a05:6214:598c:b0:8ac:a4f9:da76 with SMTP id 6a1803df08f44-8b0280cdc7bmr381917916d6.26.1776891084078; Wed, 22 Apr 2026 13:51:24 -0700 (PDT) Received: from mail.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae88d5fsm171453486d6.39.2026.04.22.13.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2026 13:51:23 -0700 (PDT) From: Kamal Dasu To: Ulf Hansson Cc: Adrian Hunter , Kees Cook , Tony Luck , "Guilherme G . Piccoli" , Florian Fainelli , Arend van Spriel , William Zhang , bcm-kernel-feedback-list@broadcom.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Kamal Dasu Subject: [PATCH v5 0/4] mmc: Add pstore backend for crash dump storage on eMMC Date: Wed, 22 Apr 2026 16:50:49 -0400 Message-Id: <20260422205053.3392395-1-kamal.dasu@broadcom.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-DetectorID-Processed: b00c1d49-9d2e-4205-b15f-d015386d3d5e This series adds mmcpstore, a pstore backend driver that enables persistent storage of kernel crash logs on eMMC devices. When the kernel panics, pstore captures the kmsg dump and writes it directly to a dedicated MMC partition using polled I/O with interrupts disabled. Changes since v4 (addresses Ulf Hansson's feedback on the v4 panic host path, linux-mmc): - mmc_panic_claim_host(): log claimed, runtime suspend, and ongoing_mrq before claim; always call panic_prepare() when implemented so the host can drain or gracefully terminate in-flight requests, then force-claim. Vendor controllers may supply their own panic_prepare for platform-specific cases (1/4). - SDHCI: reference panic_prepare implementation; longer drain/reset timeouts; document panic helper return values in kernel-doc (2/4). - mmcpstore: single prepare/claim path; panic_complete() after panic_poll_completion() on panic writes (4/4). Changes since v3: - Fixed kernel-doc warnings reported by kernel test robot: - Added missing @param descriptions for sdhci_panic_prepare(), sdhci_panic_poll_completion(), sdhci_panic_complete() (patch 2) - Added missing @sect_offset param doc for mmcpstore_do_request_internal() (patch 4) - Fixed kernel-doc function name mismatch: mmcpstore_read() -> mmcpstore_read_zone() (patch 4) - Added missing @disk param doc for mmcpstore_card_add() (patch 4) - Removed unused 'offset_bytes' variable in mmcpstore_register_for_card() (patch 4) Changes since v2 (RFC): - Rebased onto v7.0-rc — no longer reverts any existing MMC core or SDHCI changes (v1/v2 accidentally reverted recent upstream commits due to being based on an older tree) - Removed all erase/bitmap tracking logic — MMC/eMMC is managed flash and does not need erase-before-write; the pstore_zone framework handles zone management internally - Uses standard MMC core request path (mmc_start_request) instead of hand-building mmc_request structs; panic-context I/O is handled through proper mmc_host_ops callbacks rather than ad-hoc code in the driver - Added panic-context ops to mmc_host_ops and sdhci_ops for clean separation of panic and normal I/O paths - Fixed deadlocks caused by spinlock contention during panic (lockless mmc_panic_claim_host using WRITE_ONCE) - Fixed data corruption in pstore recovery (zlib_inflate failures) by letting the normal sdhci_request() path run instead of a custom panic request handler - Added PM suspend/resume support with eMMC re-initialization - Supports module loading or builtin loading of the driver - Added MAINTAINERS entry - Split into 4-patch series for reviewability The series is structured as follows: Patch 1 adds panic-context operations to struct mmc_host_ops and a lockless mmc_panic_claim_host() for use during kernel panic when other CPUs are stopped and may hold locks. Host drivers may replace panic_prepare with vendor-specific code where needed. Patch 2 implements the SDHCI reference panic_prepare (graceful termination of in-flight work, then polled completion paths); other MMC host drivers use the same mmc_host_ops hooks with their own panic_prepare where the hardware differs. Patch 3 adds mmc_blk_get_card_by_name() helper to look up an mmc_card from a block device name, used by the mmcpstore module path for card discovery. Patch 4 adds the mmcpstore driver itself, which registers with the pstore_blk framework and handles panic writes, PM suspend/resume, and dual-path registration (direct probe hook for builtin, mmc_blk_get_card_by_name() for module). Also adds probe/remove hooks in block.c and declarations in block.h for the builtin path. Tested on Broadcom STB platforms (ARM64) with SDHCI controllers, verified panic dump recovery across multiple panic/reboot cycles with kmsg, pmsg, and console pstore; also tested with concurrent I/O stress before panic. Previous submissions and related work: RFC v1: https://lore.kernel.org/linux-mmc/20221216212738.7928-1-kdasu.kdev@gmail.com/ RFC v2: https://lore.kernel.org/linux-mmc/20221222185948.12717-1-kdasu.kdev@gmail.com/ v3: https://lore.kernel.org/linux-mmc/20260319185705.1516950-1-kamal.dasu@broadcom.com/ v4: linux-mmc (same thread as v3; superseded by this v5) Marvell MMC pstore attempt (2020): https://lore.kernel.org/linux-mmc/20201207115753.21728-1-bbudiredla@marvell.com/ pstore/blk documentation: https://www.kernel.org/doc/html/latest/admin-guide/pstore-blk.html Kamal Dasu (4): mmc: core: Add panic-context host operations for pstore backends mmc: sdhci: Implement panic-context write support mmc: block: Add helper to look up mmc_card by device name mmc: core: Add MMC pstore backend driver MAINTAINERS | 6 + drivers/mmc/core/Kconfig | 12 + drivers/mmc/core/Makefile | 1 + drivers/mmc/core/block.c | 56 ++ drivers/mmc/core/block.h | 18 + drivers/mmc/core/core.c | 54 ++ drivers/mmc/core/mmcpstore.c | 1511 ++++++++++++++++++++++++++++++++++ drivers/mmc/host/sdhci.c | 173 +++- drivers/mmc/host/sdhci.h | 6 + include/linux/mmc/host.h | 12 + 10 files changed, 1845 insertions(+), 4 deletions(-) create mode 100644 drivers/mmc/core/mmcpstore.c -- 2.34.1