From nobody Sat Oct 4 09:41:02 2025 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 912AD340DAE; Mon, 18 Aug 2025 14:03:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755525795; cv=none; b=f22nWSluYflkq3DlGq35bcr4oy14B0V9WnZJMU8uxAf/BzTtCHNmGXR4NQfjOCZj1Km+LYIC/PDytQPXEEVt3nRotyXIyhH6jyZ9DgIIQfbM/fEUXtca9KWhZ5ztOC86SYj16Qnr3Ye3pjvhDLzGGDAtx8Az6hPXVK7w5Dfx3rY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755525795; c=relaxed/simple; bh=Upf/68ziVHah6Rlks/oNHiBue0nYeJly5A97BtbIxys=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gVBaNeGwWTuf4+FvmTxz6lY44lYsjiqfE5TbqUsyf2d/ZaEbpYuXkO0wammdujZ8tW+7cEHYeOV/WpDakROZMtV6L2Fd5G1w31RAqKipotNVxO0/HShmxuEAoVwI4eaHT9Z1ZTRiL++75dlwGQ5g5iVthebDfdX7LZvfo28XlNQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Q4DwIlLQ; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Q4DwIlLQ" Received: by mail.gandi.net (Postfix) with ESMTPSA id B3CB843974; Mon, 18 Aug 2025 14:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1755525789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2K3ECqs8b7BXS3Z8XIsoknOfTvpoi8O6hgk61rndGZg=; b=Q4DwIlLQUdGNk9+8OgINidpKR2icZhPwJbKkER7jBmO4XGHmSe72dp6D+g9GZRwlQnuzrS vdxP5VBBhQnwszE2XbFNZLo1ZSwXlip8gYkelz/RjBeSAyejWRPNjRrHbYPli9n8wZC/wo QdCoXsAMjX8zB/PDvshh7Oy5oBzdiSoWaAdifetHq2SaTM5RIKB7cGzilOQdhQaXQapyk4 aySUUIbyps2NwpMSBF72pumZro4B2VIfjNtSrApj3lkKqa7e54sNav3T9cMYR4OQ/1U1Jp N6K0U3MUv2Zz1/4uxcJ66U4y6AKtdN2rESeUkntTCleKqmlC8lczIOa9/iUGqQ== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Mon, 18 Aug 2025 16:02:46 +0200 Subject: [PATCH v4 1/6] mmc: core: add mmc_card_can_cmd23 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: quoted-printable Message-Id: <20250818-mobileye-emmc-for-upstream-4-v4-1-34ecb3995e96@bootlin.com> References: <20250818-mobileye-emmc-for-upstream-4-v4-0-34ecb3995e96@bootlin.com> In-Reply-To: <20250818-mobileye-emmc-for-upstream-4-v4-0-34ecb3995e96@bootlin.com> To: Ulf Hansson , Adrian Hunter Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , Tawfik Bayouk , Gregory CLEMENT , Thomas Petazzoni , =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduhedvkedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthekredtredtjeenucfhrhhomhepuegvnhhofphtucfoohhnihhnuceosggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpedufefgudfgfffguefhgeeuvdeuhfekkedtleduledvleetleetjeejieetteevtdenucfkphepvdgrtddumegtsgdugeemheehieemjegrtddtmeduheefjeemfhefheemleefiegumegvledvheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvrgdtudemtggsudegmeehheeimeejrgdttdemudehfeejmehffeehmeelfeeiugemvgelvdehpdhhvghloheplgduledvrdduieekrddutddrudekjegnpdhmrghilhhfrhhomhepsggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeelpdhrtghpthhtohepvhhlrgguihhmihhrrdhkohhnughrrghtihgvvhesmhhosghilhgvhigvrdgtohhmpdhrtghpthhtohepthhhohhmrghsrdhpvghtrgiiiihonhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtoheprggurhhirghnrdhhuhhnthgvrhesi hhnthgvlhdrtghomhdprhgtphhtthhopehtrgiffhhikhdrsggrhihouhhksehmohgsihhlvgihvgdrtghomhdprhgtphhtthhopehgrhgvghhorhihrdgtlhgvmhgvnhhtsegsohhothhlihhnrdgtohhmpdhrtghpthhtoheplhhinhhugidqmhhmtgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegsvghnohhithdrmhhonhhinhessghoohhtlhhinhdrtghomhdprhgtphhtthhopehulhhfrdhhrghnshhsohhnsehlihhnrghrohdrohhrgh X-GND-Sasl: benoit.monin@bootlin.com Add a dedicated helper to check for CMD23 support for MMC card, similar to mmc_host_can_cmd23 for the host, as it is easy to get the check wrong. Signed-off-by: Beno=C3=AEt Monin --- drivers/mmc/core/core.c | 9 +++++++++ drivers/mmc/core/core.h | 1 + 2 files changed, 10 insertions(+) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 874c6fe92855e3535ec0ebc0254146f4b96bccc3..88fd231fee1d150b22baebddb7a= d47472c24fb32 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1875,6 +1875,15 @@ bool mmc_card_can_secure_erase_trim(struct mmc_card = *card) } EXPORT_SYMBOL(mmc_card_can_secure_erase_trim); =20 +bool mmc_card_can_cmd23(struct mmc_card *card) +{ + return ((mmc_card_mmc(card) && + card->csd.mmca_vsn >=3D CSD_SPEC_VER_3) || + (mmc_card_sd(card) && !mmc_card_ult_capacity(card) && + card->scr.cmds & SD_SCR_CMD23_SUPPORT)); +} +EXPORT_SYMBOL(mmc_card_can_cmd23); + int mmc_erase_group_aligned(struct mmc_card *card, sector_t from, unsigned int nr) { diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 622085cd766f91334d5b9362cd7b96245af8884d..73f5d3d8c77d5da53795fe09beb= 384f134d6a886 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -123,6 +123,7 @@ bool mmc_card_can_trim(struct mmc_card *card); bool mmc_card_can_discard(struct mmc_card *card); bool mmc_card_can_sanitize(struct mmc_card *card); bool mmc_card_can_secure_erase_trim(struct mmc_card *card); +bool mmc_card_can_cmd23(struct mmc_card *card); int mmc_erase_group_aligned(struct mmc_card *card, sector_t from, unsigned= int nr); unsigned int mmc_calc_max_discard(struct mmc_card *card); =20 --=20 2.50.1 From nobody Sat Oct 4 09:41:02 2025 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18B8731CA48; Mon, 18 Aug 2025 14:03:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755525795; cv=none; b=sD7qcmOl4gW/xl2Pd4XP1T9CayH1O2L0EpYwtjptVKHA/aMc8IVbB1hmx/fbm7cOCw5gLr3g2Uz2qGC1S1owIoIyP6jpGD4mol8yavOLMtlt5r7DGx67OkEj+vg4DOemTCKZ3Al2EIx0RmgM6LhjeW/B9EAO3oSVKhEgMKFrFsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755525795; c=relaxed/simple; bh=u/Mh6QMW/fxl5ex7MvG974k7mfVE7yTG8KRGiyJjEtk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T7OtU1jvpj7ZPqdWhK5LUF3TL9gS0y3V3PP1SnIRF+cGmyVJvw6pJh6ASr+wbLakmH9LagIflUhHtEl+HtTeFqGp6IT2UQ0KUAvj6aqPR5FpKSMSeF6SJpK/4OcCTlk3p5zwjOssAyYRpLkQ4TLGjAzGYYrLVXRNsOIBlYspX9Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=YYyUa0yS; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="YYyUa0yS" Received: by mail.gandi.net (Postfix) with ESMTPSA id 32EE64397C; Mon, 18 Aug 2025 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1755525789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4zMyivun2ZhPaC0c15Jzxv6HXN5r+otqFCrTgy5NlLg=; b=YYyUa0ySBNxGJDxmURFn4kw+zGH7ZzGSx153oSj8Gv8vAjFia9zxYAkwe3aNmicTv1b748 NRsmlGRDnlrEreZGnEbCWzdvp3cZGui1wecojqGMdjvivEpjzhhtaIZVqlMFIBlo0kzh15 qTUio7Jll7pYIRs7rMib5nJGgnfImNHTNVxrMyI7/8O67e++gDWNTQvgdE1lGKZPFQH2DF 7c1a3U/FzcQJKT/BB96c6btpceAC/ogC+u24Yy60tbb5HEN7RMA1C5Kzo60iWFg1dxOrib Sk6AsM0W9c7hSoyaUkGAv8rl7hmItI5tm4q/LeBA0rt2PKntOb7XHXRvhoBIzw== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Mon, 18 Aug 2025 16:02:47 +0200 Subject: [PATCH v4 2/6] mmc: card: add mmc_card_blk_no_cmd23 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: quoted-printable Message-Id: <20250818-mobileye-emmc-for-upstream-4-v4-2-34ecb3995e96@bootlin.com> References: <20250818-mobileye-emmc-for-upstream-4-v4-0-34ecb3995e96@bootlin.com> In-Reply-To: <20250818-mobileye-emmc-for-upstream-4-v4-0-34ecb3995e96@bootlin.com> To: Ulf Hansson , Adrian Hunter Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , Tawfik Bayouk , Gregory CLEMENT , Thomas Petazzoni , =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduhedvkedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthekredtredtjeenucfhrhhomhepuegvnhhofphtucfoohhnihhnuceosggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpedufefgudfgfffguefhgeeuvdeuhfekkedtleduledvleetleetjeejieetteevtdenucfkphepvdgrtddumegtsgdugeemheehieemjegrtddtmeduheefjeemfhefheemleefiegumegvledvheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvrgdtudemtggsudegmeehheeimeejrgdttdemudehfeejmehffeehmeelfeeiugemvgelvdehpdhhvghloheplgduledvrdduieekrddutddrudekjegnpdhmrghilhhfrhhomhepsggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeelpdhrtghpthhtohepvhhlrgguihhmihhrrdhkohhnughrrghtihgvvhesmhhosghilhgvhigvrdgtohhmpdhrtghpthhtohepthhhohhmrghsrdhpvghtrgiiiihonhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtoheprggurhhirghnrdhhuhhnthgvrhesi hhnthgvlhdrtghomhdprhgtphhtthhopehtrgiffhhikhdrsggrhihouhhksehmohgsihhlvgihvgdrtghomhdprhgtphhtthhopehgrhgvghhorhihrdgtlhgvmhgvnhhtsegsohhothhlihhnrdgtohhmpdhrtghpthhtoheplhhinhhugidqmhhmtgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegsvghnohhithdrmhhonhhinhessghoohhtlhhinhdrtghomhdprhgtphhtthhopehulhhfrdhhrghnshhsohhnsehlihhnrghrohdrohhrgh X-GND-Sasl: benoit.monin@bootlin.com Add a helper to check for the missing CMD23 quirk, similar to other quirk helpers. Also reorder the helpers to match the order of the quirk bits defined in include/linux/mmc/card.h. Signed-off-by: Beno=C3=AEt Monin --- drivers/mmc/core/card.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h index 9cbdd240c3a7d42ecbb45cbc52c5562e4664ee35..1200951bab08c2e18ce96becf56= 693e696b9f30b 100644 --- a/drivers/mmc/core/card.h +++ b/drivers/mmc/core/card.h @@ -245,14 +245,19 @@ static inline int mmc_blksz_for_byte_mode(const struc= t mmc_card *c) return c->quirks & MMC_QUIRK_BLKSZ_FOR_BYTE_MODE; } =20 +static inline int mmc_card_nonstd_func_interface(const struct mmc_card *c) +{ + return c->quirks & MMC_QUIRK_NONSTD_FUNC_IF; +} + static inline int mmc_card_disable_cd(const struct mmc_card *c) { return c->quirks & MMC_QUIRK_DISABLE_CD; } =20 -static inline int mmc_card_nonstd_func_interface(const struct mmc_card *c) +static inline int mmc_card_blk_no_cmd23(const struct mmc_card *c) { - return c->quirks & MMC_QUIRK_NONSTD_FUNC_IF; + return c->quirks & MMC_QUIRK_BLK_NO_CMD23; } =20 static inline int mmc_card_broken_byte_mode_512(const struct mmc_card *c) --=20 2.50.1 From nobody Sat Oct 4 09:41:02 2025 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97845340DAD; Mon, 18 Aug 2025 14:03:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755525794; cv=none; b=VXjMSnRvvWjFyBL9MzHnRyYZCNwcgcL1TFL0ZZv/GZPh3up2zCIP8HJAELfBAw9OxwynQoeYS9a9Z6NLXdxknXCAS0yuNfQmL6XAqgY0WXl5zjc8//iGVAZgPwxZKI8xu3om/KPvMAgNsO1uGvmpJiIlkc4gAn3o1NIdBrNah9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755525794; c=relaxed/simple; bh=Ow9KW3YcVSr0/nPhBv9tKtnie2AY1M86cNe3h2YVq1k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=t49Qi47Uro71JYeZDGRsXHH/f/VsXvb+l+LfuEaJ2pVE4EzDImDy0a0y79yENy3wSoXScS2OubZ/j0AFBCE5zvO9w1PI23+4IibIoZN6pC4kUOrhy2X4JMk661ddgc6i7LyKsxDikqaQjT+D5SLHg3U229dYHY59HdFVvFK69/o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=osr04jML; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="osr04jML" Received: by mail.gandi.net (Postfix) with ESMTPSA id A7E6B4397D; Mon, 18 Aug 2025 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1755525790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RLD1DeoM4SdeI+gMUKY34n91PgjQmdYcZNQgzI0w0C0=; b=osr04jML1ESr7OjPB65yybVsVbodHWvlt7muqZURncfGobjkKazoFBaVp17WUmDGrIi5rq TQBN7608NudoHjXuilWsA+h2xWB3BP5J1TmuP6LlrwKBvpI9c6HvqiX7UjwMftcuk5ahVI Gqra+jITvPRfZkcmwRW/h1Sp7LEh/HZbnkmTOssvNm5Leksb00puN9uSgPRVqhSWHR7pd4 PtpKr/18ztpPPNxaNLDkIaXX5q+yP/E+zF2e5pPRC9uyBZ8RHwmSKMQbi/i1L+PHzzPPbY PqdrygZTi1hSNGcC50MfgpMSUsh6HIrs+w1Zxv/tcmX24TCSQFjITVqB6+boRQ== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Mon, 18 Aug 2025 16:02:48 +0200 Subject: [PATCH v4 3/6] mmc: mmc_test: use mmc_card cmd23 helpers 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: quoted-printable Message-Id: <20250818-mobileye-emmc-for-upstream-4-v4-3-34ecb3995e96@bootlin.com> References: <20250818-mobileye-emmc-for-upstream-4-v4-0-34ecb3995e96@bootlin.com> In-Reply-To: <20250818-mobileye-emmc-for-upstream-4-v4-0-34ecb3995e96@bootlin.com> To: Ulf Hansson , Adrian Hunter Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , Tawfik Bayouk , Gregory CLEMENT , Thomas Petazzoni , =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduhedvkedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthekredtredtjeenucfhrhhomhepuegvnhhofphtucfoohhnihhnuceosggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpedufefgudfgfffguefhgeeuvdeuhfekkedtleduledvleetleetjeejieetteevtdenucfkphepvdgrtddumegtsgdugeemheehieemjegrtddtmeduheefjeemfhefheemleefiegumegvledvheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvrgdtudemtggsudegmeehheeimeejrgdttdemudehfeejmehffeehmeelfeeiugemvgelvdehpdhhvghloheplgduledvrdduieekrddutddrudekjegnpdhmrghilhhfrhhomhepsggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeelpdhrtghpthhtohepvhhlrgguihhmihhrrdhkohhnughrrghtihgvvhesmhhosghilhgvhigvrdgtohhmpdhrtghpthhtohepthhhohhmrghsrdhpvghtrgiiiihonhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtoheprggurhhirghnrdhhuhhnthgvrhesi hhnthgvlhdrtghomhdprhgtphhtthhopehtrgiffhhikhdrsggrhihouhhksehmohgsihhlvgihvgdrtghomhdprhgtphhtthhopehgrhgvghhorhihrdgtlhgvmhgvnhhtsegsohhothhlihhnrdgtohhmpdhrtghpthhtoheplhhinhhugidqmhhmtgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegsvghnohhithdrmhhonhhinhessghoohhtlhhinhdrtghomhdprhgtphhtthhopehulhhfrdhhrghnshhsohhnsehlihhnrghrohdrohhrgh X-GND-Sasl: benoit.monin@bootlin.com Use mmc_card_can_cmd23 instead of using a local and partial implementation, and check for the CMD23 quirk with mmc_card_blk_no_cmd23. Signed-off-by: Beno=C3=AEt Monin --- drivers/mmc/core/mmc_test.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c index 80e5d87a5e50bea772c06443bca8f48f042d6ad5..67d4a301895c905bf52776f970b= fc7a8f86a65aa 100644 --- a/drivers/mmc/core/mmc_test.c +++ b/drivers/mmc/core/mmc_test.c @@ -180,20 +180,14 @@ static int mmc_test_set_blksize(struct mmc_test_card = *test, unsigned size) return mmc_set_blocklen(test->card, size); } =20 -static bool mmc_test_card_cmd23(struct mmc_card *card) -{ - return mmc_card_mmc(card) || - (mmc_card_sd(card) && card->scr.cmds & SD_SCR_CMD23_SUPPORT); -} - static void mmc_test_prepare_sbc(struct mmc_test_card *test, struct mmc_request *mrq, unsigned int blocks) { struct mmc_card *card =3D test->card; =20 if (!mrq->sbc || !mmc_host_can_cmd23(card->host) || - !mmc_test_card_cmd23(card) || !mmc_op_multi(mrq->cmd->opcode) || - (card->quirks & MMC_QUIRK_BLK_NO_CMD23)) { + !mmc_card_can_cmd23(card) || !mmc_op_multi(mrq->cmd->opcode) || + mmc_card_blk_no_cmd23(card)) { mrq->sbc =3D NULL; return; } --=20 2.50.1 From nobody Sat Oct 4 09:41:02 2025 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0942340DB3; Mon, 18 Aug 2025 14:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755525798; cv=none; b=DrSlkWHJi2mKT43NWI4PfqZQHO89N3WZ3chBOZMwq9U96PRvyvF+sg/BGHg/KYYaVEfScwz/ATx+ObnhdW0ICc2D/WGiFD75tOot2EO5eFAyrGh5PxAm94qdB5T1R5knPs6ACriX2g9NC0iZF+yjV2vWG0LauAvEFzh89AwrEog= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755525798; c=relaxed/simple; bh=9lyUisWWwoQfSLcEFTWqqvap3ZZX/RoFNkOOQ++A9/4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=spjmqVnl/uZCTZGhjBTj/khum3XJr0Iux1J38zBTDmWXeGivv0mG4LDmq9Pwl5+0qh+4i7jBTMOvptdl7hPGjifvgVdo/q4AWyr+Zbxck3SAoR8YlM8MvgG5n4CQcUxr/bElbLkny7ybau/3t1Q67WjjyxKCzrL7LJg4qF6WH7s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=jcz69+dV; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="jcz69+dV" Received: by mail.gandi.net (Postfix) with ESMTPSA id 21C194397F; Mon, 18 Aug 2025 14:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1755525790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/B0tKSvtjHK+bMw61b+HxOpCHuU5fV5QHVywH58Gsxk=; b=jcz69+dV3xLtemReNmsuP14SVKsxloeO/4pByyCni22aIpD4qelo0ppT33rfPSaiHqo1Q/ wPWu5gRgyJeh8WOeNFfSERy0q9QjO04T1gENHh6apubcZR5/AQF5FbDWahbd3NEepLYMIx gHblto9gRyVu4Q/zWF4xKgsWQ7Z/PuRlIYQFp96CaYjsPYQIDibFbhRtMHFEiVA2NTzEUM pg7Cqq9myUFPZ5h99ZYiQKoa0lGkyUDGjs+uMYWLB+E2JGWZS5XfLDJwnFMGN+LO8iEP0w b565mNayeVz4amyJ+vUQVxgX/JMsrLvYynqqYpNy1AiHxU1ju1R06/7E8yGIWA== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Mon, 18 Aug 2025 16:02:49 +0200 Subject: [PATCH v4 4/6] mmc: block: use mmc_card cmd23 helpers 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: quoted-printable Message-Id: <20250818-mobileye-emmc-for-upstream-4-v4-4-34ecb3995e96@bootlin.com> References: <20250818-mobileye-emmc-for-upstream-4-v4-0-34ecb3995e96@bootlin.com> In-Reply-To: <20250818-mobileye-emmc-for-upstream-4-v4-0-34ecb3995e96@bootlin.com> To: Ulf Hansson , Adrian Hunter Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , Tawfik Bayouk , Gregory CLEMENT , Thomas Petazzoni , =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduhedvkedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthekredtredtjeenucfhrhhomhepuegvnhhofphtucfoohhnihhnuceosggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpedufefgudfgfffguefhgeeuvdeuhfekkedtleduledvleetleetjeejieetteevtdenucfkphepvdgrtddumegtsgdugeemheehieemjegrtddtmeduheefjeemfhefheemleefiegumegvledvheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvrgdtudemtggsudegmeehheeimeejrgdttdemudehfeejmehffeehmeelfeeiugemvgelvdehpdhhvghloheplgduledvrdduieekrddutddrudekjegnpdhmrghilhhfrhhomhepsggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeelpdhrtghpthhtohepvhhlrgguihhmihhrrdhkohhnughrrghtihgvvhesmhhosghilhgvhigvrdgtohhmpdhrtghpthhtohepthhhohhmrghsrdhpvghtrgiiiihonhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtoheprggurhhirghnrdhhuhhnthgvrhesi hhnthgvlhdrtghomhdprhgtphhtthhopehtrgiffhhikhdrsggrhihouhhksehmohgsihhlvgihvgdrtghomhdprhgtphhtthhopehgrhgvghhorhihrdgtlhgvmhgvnhhtsegsohhothhlihhnrdgtohhmpdhrtghpthhtoheplhhinhhugidqmhhmtgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegsvghnohhithdrmhhonhhinhessghoohhtlhhinhdrtghomhdprhgtphhtthhopehulhhfrdhhrghnshhsohhnsehlihhnrghrohdrohhrgh X-GND-Sasl: benoit.monin@bootlin.com Use the dedicated helpers for CMD23 card support. Signed-off-by: Beno=C3=AEt Monin --- drivers/mmc/core/block.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 9cc47bf94804b64a9cc60c7a5d95a0082d546ea9..8fd9891462054da8c00bdbb93e3= 414614441644d 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1768,8 +1768,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *= mqrq, * these, while retaining features like reliable writes. */ if ((md->flags & MMC_BLK_CMD23) && mmc_op_multi(brq->cmd.opcode) && - (do_rel_wr || !(card->quirks & MMC_QUIRK_BLK_NO_CMD23) || - do_data_tag)) { + (do_rel_wr || !mmc_card_blk_no_cmd23(card) || do_data_tag)) { brq->sbc.opcode =3D MMC_SET_BLOCK_COUNT; brq->sbc.arg =3D brq->data.blocks | (do_rel_wr ? (1 << 31) : 0) | @@ -2618,13 +2617,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct= mmc_card *card, */ md->read_only =3D mmc_blk_readonly(card); =20 - if (mmc_host_can_cmd23(card->host)) { - if ((mmc_card_mmc(card) && - card->csd.mmca_vsn >=3D CSD_SPEC_VER_3) || - (mmc_card_sd(card) && !mmc_card_ult_capacity(card) && - card->scr.cmds & SD_SCR_CMD23_SUPPORT)) - md->flags |=3D MMC_BLK_CMD23; - } + if (mmc_host_can_cmd23(card->host) && mmc_card_can_cmd23(card)) + md->flags |=3D MMC_BLK_CMD23; =20 if (md->flags & MMC_BLK_CMD23 && ((card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) || --=20 2.50.1 From nobody Sat Oct 4 09:41:02 2025 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8289E3101B1; Mon, 18 Aug 2025 14:03:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755525795; cv=none; b=RyF1FX1iY2szOrHcjFTbdHZTi7LvtAvJFIGfUEnZu9zl5B2Nq3TADsUAMFUTc7KuMHoZIXz9GlBKqr+WZHf5nbZeFlhyLDCSK747gzbDKmgLXuLwEk1oQrJwnN+0COPVlW9c1RG0nTRL3eixl6U3qQtAMGsIZaZeMdriE0O0W84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755525795; c=relaxed/simple; bh=Nlrhy0jte5jkeG/sxZPldwdBsuqbcUojN+UDctTzlnQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pA4gixJKce502KSqORmRN5mwKE83TDjMnVsgO+Cs8+drP9EbZPiRGeZ0JRdJUpEi1mEl8RXRxXynf6FV85wBSRFi0iLhpt+Lup8SUpZ2VTjV3wYHRElWyYp6FIgkobhf6X11l9xDRD0HBlEgU4GY2i+NqyFLLST+TeUMZAAu7dM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=iANLcW4z; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="iANLcW4z" Received: by mail.gandi.net (Postfix) with ESMTPSA id 891EE4397B; Mon, 18 Aug 2025 14:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1755525790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qSsrNhtOneuyob43kSx1I/jvPLZqPxySlqgoEIUC5JA=; b=iANLcW4zBSCMd1/0MWwjVKTsFelt9v4YeU/lZrgQnvojY3sSoEP6LhmeLDRAXweLtZ1W8P WomfYVwF6/stiV4l+2is4E9byVWlB3LgXKHfJsx0R7R7Bod/VBtxkj6jicFQ5TfhdBqstH pYiClKKsjFqrzjNQzn9bNvhv0eOnc0LK9UYSC6mupFB8jrNkybLp8onVZh2gOppn4lnEqv NCq7HUvMf1QMz5XPRaRgSjxmhzYUTsVuNktZFlKG5P1QF/5Z289xW9hnTYLQg+gnJazTFl LUC1i4M7DnvrOLZpSfi6RjgwBL/3rz5W5CzjUxWvrRc/DS9kjxuIWqvwSSA6DA== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Mon, 18 Aug 2025 16:02:50 +0200 Subject: [PATCH v4 5/6] mmc: core: add mmc_read_tuning 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: quoted-printable Message-Id: <20250818-mobileye-emmc-for-upstream-4-v4-5-34ecb3995e96@bootlin.com> References: <20250818-mobileye-emmc-for-upstream-4-v4-0-34ecb3995e96@bootlin.com> In-Reply-To: <20250818-mobileye-emmc-for-upstream-4-v4-0-34ecb3995e96@bootlin.com> To: Ulf Hansson , Adrian Hunter Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , Tawfik Bayouk , Gregory CLEMENT , Thomas Petazzoni , =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduhedvkedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthekredtredtjeenucfhrhhomhepuegvnhhofphtucfoohhnihhnuceosggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpedufefgudfgfffguefhgeeuvdeuhfekkedtleduledvleetleetjeejieetteevtdenucfkphepvdgrtddumegtsgdugeemheehieemjegrtddtmeduheefjeemfhefheemleefiegumegvledvheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvrgdtudemtggsudegmeehheeimeejrgdttdemudehfeejmehffeehmeelfeeiugemvgelvdehpdhhvghloheplgduledvrdduieekrddutddrudekjegnpdhmrghilhhfrhhomhepsggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeelpdhrtghpthhtohepvhhlrgguihhmihhrrdhkohhnughrrghtihgvvhesmhhosghilhgvhigvrdgtohhmpdhrtghpthhtohepthhhohhmrghsrdhpvghtrgiiiihonhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtoheprggurhhirghnrdhhuhhnthgvrhesi hhnthgvlhdrtghomhdprhgtphhtthhopehtrgiffhhikhdrsggrhihouhhksehmohgsihhlvgihvgdrtghomhdprhgtphhtthhopehgrhgvghhorhihrdgtlhgvmhgvnhhtsegsohhothhlihhnrdgtohhmpdhrtghpthhtoheplhhinhhugidqmhhmtgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegsvghnohhithdrmhhonhhinhessghoohhtlhhinhdrtghomhdprhgtphhtthhopehulhhfrdhhrghnshhsohhnsehlihhnrghrohdrohhrgh X-GND-Sasl: benoit.monin@bootlin.com Provide a function to the MMC hosts to read some blocks of data as part of their tuning. This function only returns the status of the read operation, not the data read. Signed-off-by: Beno=C3=AEt Monin --- drivers/mmc/core/mmc_ops.c | 72 ++++++++++++++++++++++++++++++++++++++++++= ++++ include/linux/mmc/host.h | 1 + 2 files changed, 73 insertions(+) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 66283825513cb4ff993a1b2ec1f0b0cac4e74487..a952cc8265af8f9d9587e4f2188= 4d5f6d2fe0369 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -1077,3 +1077,75 @@ int mmc_sanitize(struct mmc_card *card, unsigned int= timeout_ms) return err; } EXPORT_SYMBOL_GPL(mmc_sanitize); + +/** + * mmc_read_tuning() - read data blocks from the mmc + * @host: mmc host doing the read + * @blksz: data block size + * @blocks: number of blocks to read + * + * Read one or more blocks of data from the beginning of the mmc. This is a + * low-level helper for tuning operation. It is assumed that CMD23 can be = used + * for multi-block read if the host supports it. + * + * Note: Allocate and free a temporary buffer to store the data read. The = data + * is not available outside of the function, only the status of the read + * operation. + * + * Return: 0 in case of success, otherwise -EIO / -ENOMEM / -E2BIG + */ +int mmc_read_tuning(struct mmc_host *host, unsigned int blksz, unsigned in= t blocks) +{ + struct mmc_request mrq =3D {}; + struct mmc_command sbc =3D {}; + struct mmc_command cmd =3D {}; + struct mmc_command stop =3D {}; + struct mmc_data data =3D {}; + struct scatterlist sg; + void *buf; + unsigned int len; + + if (blocks > 1) { + if (mmc_host_can_cmd23(host)) { + mrq.sbc =3D &sbc; + sbc.opcode =3D MMC_SET_BLOCK_COUNT; + sbc.arg =3D blocks; + sbc.flags =3D MMC_RSP_R1 | MMC_CMD_AC; + } + cmd.opcode =3D MMC_READ_MULTIPLE_BLOCK; + mrq.stop =3D &stop; + stop.opcode =3D MMC_STOP_TRANSMISSION; + stop.flags =3D MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; + } else { + cmd.opcode =3D MMC_READ_SINGLE_BLOCK; + } + + mrq.cmd =3D &cmd; + cmd.flags =3D MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC; + + mrq.data =3D &data; + data.flags =3D MMC_DATA_READ; + data.blksz =3D blksz; + data.blocks =3D blocks; + data.blk_addr =3D 0; + data.sg =3D &sg; + data.sg_len =3D 1; + data.timeout_ns =3D 1000000000; + + if (check_mul_overflow(blksz, blocks, &len)) + return -E2BIG; + buf =3D kmalloc(len, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + sg_init_one(&sg, buf, len); + + mmc_wait_for_req(host, &mrq); + kfree(buf); + + if (sbc.error || cmd.error || data.error) + return -EIO; + + return 0; +} +EXPORT_SYMBOL_GPL(mmc_read_tuning); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 68f09a955a902047ac517441b6820fa6e4166a13..5ed5d203de23c1cd503061e0ef6= a8bfd7253c8af 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -743,5 +743,6 @@ int mmc_send_status(struct mmc_card *card, u32 *status); int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error); int mmc_send_abort_tuning(struct mmc_host *host, u32 opcode); int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd); +int mmc_read_tuning(struct mmc_host *host, unsigned int blksz, unsigned in= t blocks); =20 #endif /* LINUX_MMC_HOST_H */ --=20 2.50.1 From nobody Sat Oct 4 09:41:02 2025 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D63A5340DAF; Mon, 18 Aug 2025 14:03:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755525795; cv=none; b=tLi0IMbUewWx+VHhaLxW9D+bmt78tlQp91pvp8qkyOehf/7TIdnU5WXl0F9YrTZRNTK3ZQXP4SnTVVh7HiJwj/jAsRzWC6UH+V1lhLzH0g1DDexp7QyYVrVfOBS02MtVFhwvL9AtNZyGwaP8pn51uAFDIkUpQ6fropaM3XeMZnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755525795; c=relaxed/simple; bh=cqEMvBDIJh7sk0fkOOAjgfqJjUAGTMyPiTk2mzsorz4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I6uEj4jPFWPszpI3C1reh9yLSRH/9clqxPURQxWLkmO2RtWUes0Qk+E5EAvlJEuzKDfpnYzcrXLFM2VYeXZJOQJcEnmJ1Hrrcyfxwpn0zBhxlAPW7co8PkRnzQwQgpx5eNelKHHyFlLo00ewAa6guOgO5ttcewNaR7HDhWU0+o8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=TB/BbVCx; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="TB/BbVCx" Received: by mail.gandi.net (Postfix) with ESMTPSA id 08A1B43977; Mon, 18 Aug 2025 14:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1755525791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uKrzRB/Gdry9CrfnOHOsusIysuNG4TtE8dFjQjPlkg0=; b=TB/BbVCxzzQE/PbTdC2h8/PGF3ZOHi89W61dj13jSBz+LvTWljHBkELKYTr9Qj/5Bu5ePb 2IkKGA2udMB+ZLjnlTCskufFCcnVYmThjzLyq7VTlCm+hQUk51DbHSOSr1nAD0444EDfRk LXPrpf2O+w0iqB/8aiLI34KDuFWCD0Fa4o+OhL04LtzR2v6j5EQlTkZMsdAJM2tS7o5khC gNglfXCfbBIMWrHNoay982mXSJfeDYUzw6kodRO77jiG+cuHoubQm7R/SesqhDP4rt1W6H mAeAuaLlvf8lRZpnBgV9mevnenzG8btGaQdFUlQep3hIXychvxhQ+p7OcKsdGg== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Mon, 18 Aug 2025 16:02:51 +0200 Subject: [PATCH v4 6/6] mmc: sdhci-cadence: implement multi-block read gap tuning 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: quoted-printable Message-Id: <20250818-mobileye-emmc-for-upstream-4-v4-6-34ecb3995e96@bootlin.com> References: <20250818-mobileye-emmc-for-upstream-4-v4-0-34ecb3995e96@bootlin.com> In-Reply-To: <20250818-mobileye-emmc-for-upstream-4-v4-0-34ecb3995e96@bootlin.com> To: Ulf Hansson , Adrian Hunter Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , Tawfik Bayouk , Gregory CLEMENT , Thomas Petazzoni , =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduhedvkedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthekredtredtjeenucfhrhhomhepuegvnhhofphtucfoohhnihhnuceosggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpedufefgudfgfffguefhgeeuvdeuhfekkedtleduledvleetleetjeejieetteevtdenucfkphepvdgrtddumegtsgdugeemheehieemjegrtddtmeduheefjeemfhefheemleefiegumegvledvheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvrgdtudemtggsudegmeehheeimeejrgdttdemudehfeejmehffeehmeelfeeiugemvgelvdehpdhhvghloheplgduledvrdduieekrddutddrudekjegnpdhmrghilhhfrhhomhepsggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeelpdhrtghpthhtohepvhhlrgguihhmihhrrdhkohhnughrrghtihgvvhesmhhosghilhgvhigvrdgtohhmpdhrtghpthhtohepthhhohhmrghsrdhpvghtrgiiiihonhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtoheprggurhhirghnrdhhuhhnthgvrhesi hhnthgvlhdrtghomhdprhgtphhtthhopehtrgiffhhikhdrsggrhihouhhksehmohgsihhlvgihvgdrtghomhdprhgtphhtthhopehgrhgvghhorhihrdgtlhgvmhgvnhhtsegsohhothhlihhnrdgtohhmpdhrtghpthhtoheplhhinhhugidqmhhmtgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegsvghnohhithdrmhhonhhinhessghoohhtlhhinhdrtghomhdprhgtphhtthhopehulhhfrdhhrghnshhsohhnsehlihhnrghrohdrohhrgh X-GND-Sasl: benoit.monin@bootlin.com The controller suspends the clock between blocks when reading from the MMC as part of its flow-control, called read block gap. At higher clock speed and with IO delay between the controller and the MMC, this clock pause can happen too late, during the read of the next block and trigger a read error. To prevent this, the delay can be programmed for each mode via the pair of registers HRS37/38. This delay is obtained during tuning, by trying a multi-block read and increasing the delay until the read succeeds. For now, the tuning is only done in HS200, as the read error has only been observed at that speed. Acked-by: Adrian Hunter Signed-off-by: Beno=C3=AEt Monin --- drivers/mmc/host/sdhci-cadence.c | 63 ++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cade= nce.c index 2d823e158c59844dc7916db6a1d6e3d8b02ea5a0..a2a4a5b0ab964883cef8c5d7f6e= 0c961fe76bc13 100644 --- a/drivers/mmc/host/sdhci-cadence.c +++ b/drivers/mmc/host/sdhci-cadence.c @@ -36,6 +36,24 @@ #define SDHCI_CDNS_HRS06_MODE_MMC_HS400 0x5 #define SDHCI_CDNS_HRS06_MODE_MMC_HS400ES 0x6 =20 +/* Read block gap */ +#define SDHCI_CDNS_HRS37 0x94 /* interface mode select */ +#define SDHCI_CDNS_HRS37_MODE_DS 0x0 +#define SDHCI_CDNS_HRS37_MODE_HS 0x1 +#define SDHCI_CDNS_HRS37_MODE_UDS_SDR12 0x8 +#define SDHCI_CDNS_HRS37_MODE_UDS_SDR25 0x9 +#define SDHCI_CDNS_HRS37_MODE_UDS_SDR50 0xa +#define SDHCI_CDNS_HRS37_MODE_UDS_SDR104 0xb +#define SDHCI_CDNS_HRS37_MODE_UDS_DDR50 0xc +#define SDHCI_CDNS_HRS37_MODE_MMC_LEGACY 0x20 +#define SDHCI_CDNS_HRS37_MODE_MMC_SDR 0x21 +#define SDHCI_CDNS_HRS37_MODE_MMC_DDR 0x22 +#define SDHCI_CDNS_HRS37_MODE_MMC_HS200 0x23 +#define SDHCI_CDNS_HRS37_MODE_MMC_HS400 0x24 +#define SDHCI_CDNS_HRS37_MODE_MMC_HS400ES 0x25 +#define SDHCI_CDNS_HRS38 0x98 /* Read block gap coefficient */ +#define SDHCI_CDNS_HRS38_BLKGAP_MAX 0xf + /* SRS - Slot Register Set (SDHCI-compatible) */ #define SDHCI_CDNS_SRS_BASE 0x200 =20 @@ -251,6 +269,44 @@ static int sdhci_cdns_set_tune_val(struct sdhci_host *= host, unsigned int val) return 0; } =20 +/** + * sdhci_cdns_tune_blkgap() - tune multi-block read gap + * @mmc: MMC host + * + * Tune delay used in multi block read. To do so, + * try sending multi-block read command with incremented gap, unless + * it succeeds. + * + * Return: error code + */ +static int sdhci_cdns_tune_blkgap(struct mmc_host *mmc) +{ + struct sdhci_host *host =3D mmc_priv(mmc); + struct sdhci_pltfm_host *pltfm_host =3D sdhci_priv(host); + struct sdhci_cdns_priv *priv =3D sdhci_pltfm_priv(pltfm_host); + void __iomem *hrs37_reg =3D priv->hrs_addr + SDHCI_CDNS_HRS37; + void __iomem *hrs38_reg =3D priv->hrs_addr + SDHCI_CDNS_HRS38; + int ret; + u32 gap; + u32 hrs37_mode; + + /* Currently only needed in HS200 mode */ + if (host->timing !=3D MMC_TIMING_MMC_HS200) + return 0; + + writel(hrs37_mode, hrs37_reg); + + for (gap =3D 0; gap <=3D SDHCI_CDNS_HRS38_BLKGAP_MAX; gap++) { + writel(gap, hrs38_reg); + ret =3D mmc_read_tuning(mmc, 512, 32); + if (!ret) + break; + } + + dev_dbg(mmc_dev(mmc), "read block gap tune %s, gap %d\n", ret ? "failed" = : "OK", gap); + return ret; +} + /* * In SD mode, software must not use the hardware tuning and instead perfo= rm * an almost identical procedure to eMMC. @@ -261,6 +317,7 @@ static int sdhci_cdns_execute_tuning(struct sdhci_host = *host, u32 opcode) int max_streak =3D 0; int end_of_streak =3D 0; int i; + int ret; =20 /* * Do not execute tuning for UHS_SDR50 or UHS_DDR50. @@ -288,7 +345,11 @@ static int sdhci_cdns_execute_tuning(struct sdhci_host= *host, u32 opcode) return -EIO; } =20 - return sdhci_cdns_set_tune_val(host, end_of_streak - max_streak / 2); + ret =3D sdhci_cdns_set_tune_val(host, end_of_streak - max_streak / 2); + if (ret) + return ret; + + return sdhci_cdns_tune_blkgap(host->mmc); } =20 static void sdhci_cdns_set_uhs_signaling(struct sdhci_host *host, --=20 2.50.1