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 @@ -1888,7 +1888,11 @@ static void mmc_blk_mq_rw_recovery(struc
30 - if (rq_data_dir(req) == READ && brq->data.blocks >
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 && rq_data_dir(req) == READ && brq->data.blocks >
36 queue_physical_block_size(mq->queue) >> 9) {
37 /* Read one (native) sector at a time */
38 mmc_blk_read_single(mq, req);