7390813f30425a6ce89a7ae16fc223da582d5b45
[openwrt/staging/blocktrron.git] /
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
5 recovery
6
7 See https://github.com/raspberrypi/linux/issues/5019
8
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().
14
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.
18
19 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
20 ---
21 drivers/mmc/core/block.c | 6 +++++-
22 1 file changed, 5 insertions(+), 1 deletion(-)
23
24 --- a/drivers/mmc/core/block.c
25 +++ b/drivers/mmc/core/block.c
26 @@ -1875,7 +1875,11 @@ static void mmc_blk_mq_rw_recovery(struc
27 return;
28 }
29
30 - if (rq_data_dir(req) == READ && brq->data.blocks >
31 + /*
32 + * XXX: don't do single-sector reads, as it leaks a SG DMA
33 + * mapping when reusing the still-pending req.
34 + */
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);