1 From b70da899940777d92338d8f83f7a6236818ad08a Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.com>
3 Date: Mon, 16 May 2022 10:28:27 +0100
4 Subject: [PATCH] mmc: block: Don't do single-sector reads during
7 See https://github.com/raspberrypi/linux/issues/5019
9 If an SD card has degraded performance such that IO operations time out
10 then the MMC block layer will leak SG DMA mappings in the swiotlb during
11 recovery. It retries the same SG and this causes the leak, as it is
12 mapped twice - once in sdhci_pre_req() and again during single-block
13 reads in sdhci_prepare_data().
15 Resetting the card (including power-cycling if a regulator for vmmc is
16 present) ought to be enough to recover a stuck state, so for now don't
17 try single-block reads in the recovery path.
19 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
21 drivers/mmc/core/block.c | 6 +++++-
22 1 file changed, 5 insertions(+), 1 deletion(-)
24 --- a/drivers/mmc/core/block.c
25 +++ b/drivers/mmc/core/block.c
26 @@ -1870,7 +1870,11 @@ static void mmc_blk_mq_rw_recovery(struc
29 /* FIXME: Missing single sector read for large sector size */
30 - if (!mmc_large_sector(card) && rq_data_dir(req) == READ &&
32 + * XXX: don't do single-sector reads, as it leaks a SG DMA
33 + * mapping when reusing the still-pending req.
35 + if (0 && !mmc_large_sector(card) && rq_data_dir(req) == READ &&
36 brq->data.blocks > 1) {
37 /* Read one sector at a time */
38 mmc_blk_read_single(mq, req);