[PATCH 02/10] mci: mmc_send_tuning: actually point data.dest at the buffer
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon May 11 05:49:17 PDT 2026
Hello Sascha,
On 5/11/26 2:07 PM, Sascha Hauer wrote:
> mmc_send_tuning() allocates a tuning-block-sized buffer with calloc()
> but never assigns it to data.dest, so the host transfers the tuning
> block to wherever data.dest happened to be (uninitialised — typically
> NULL). The subsequent memcmp against the expected pattern then always
> mismatches, so any caller would observe -EIO regardless of the
> controller actually receiving the block correctly.
>
> Fix by setting data.dest to the buffer.
>
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
But ouch. Apparently, I had added this, but it remained unused until
Steffen added cadence-sdhci as first user.
I recall there were issues with that driver, so Cc'ing Steffen and
Michael to make them aware of this change.
Cheers,
Ahmad
> ---
> drivers/mci/mci-core.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index 33934a6a35..23b9117869 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -1684,6 +1684,7 @@ int mmc_send_tuning(struct mci *mci, u32 opcode)
> mci_setup_cmd(&cmd, opcode, 0, MMC_RSP_R1 | MMC_CMD_ADTC);
>
> cmd.data = xzalloc(sizeof(struct mci_data));
> + cmd.data->dest = data_buf;
> cmd.data->blocksize = size;
> cmd.data->blocks = 1;
> cmd.data->flags = MMC_DATA_READ;
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list