318bd191f64ef4f53bb0d21dfb793eed8f3a70d4
[openwrt/staging/wigyori.git] /
1 From b16e3d359b99c5771f9a22f74cbd193c7f14f895 Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.com>
3 Date: Tue, 26 Mar 2024 14:58:58 +0000
4 Subject: [PATCH 0997/1085] drivers: mmc: handle 1024-byte SD General Info
5 lengths
6
7 The spec allows for up to two 512-byte pages to be allocated for the
8 Extension Register General Info block, so allocate accordingly.
9
10 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
11 ---
12 drivers/mmc/core/sd.c | 19 ++++++++++++++-----
13 1 file changed, 14 insertions(+), 5 deletions(-)
14
15 --- a/drivers/mmc/core/sd.c
16 +++ b/drivers/mmc/core/sd.c
17 @@ -1176,7 +1176,7 @@ static int mmc_sd_read_ext_regs(struct m
18 if (!(card->scr.cmds & SD_SCR_CMD48_SUPPORT))
19 return 0;
20
21 - gen_info_buf = kzalloc(512, GFP_KERNEL);
22 + gen_info_buf = kzalloc(1024, GFP_KERNEL);
23 if (!gen_info_buf)
24 return -ENOMEM;
25
26 @@ -1207,14 +1207,23 @@ static int mmc_sd_read_ext_regs(struct m
27 num_ext = gen_info_buf[4];
28
29 /*
30 - * We only support revision 0 and limit it to 512 bytes for simplicity.
31 + * We only support revision 0 and up to the spec-defined maximum of 1K.
32 * No matter what, let's return zero to allow us to continue using the
33 * card, even if we can't support the features from the SD function
34 * extensions registers.
35 */
36 - if (rev != 0 || len > 512) {
37 - pr_warn("%s: non-supported SD ext reg layout\n",
38 - mmc_hostname(card->host));
39 + if (rev != 0 || len > 1024) {
40 + pr_warn("%s: non-supported SD ext reg layout rev %u length %u\n",
41 + mmc_hostname(card->host), rev, len);
42 + goto out;
43 + }
44 +
45 + /* If the General Information block spills into the next page, read the rest */
46 + if (len > 512)
47 + err = mmc_sd_read_ext_reg(card, 0, 1, 0, 512, &gen_info_buf[512]);
48 + if (err) {
49 + pr_err("%s: error %d reading page 1 of general info of SD ext reg\n",
50 + mmc_hostname(card->host), err);
51 goto out;
52 }
53