Skip to content

Commit bda6cfa

Browse files
committed
Merge tag 'mmc-v6.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson: "MMC core: - Fix potential resource leaks in SDIO card detection error path MMC host: - jz4740: Decrease maximum clock rate to workaround bug on JZ4760(B) - meson-gx: Fix SDIO support to get some WiFi modules to work again - mmc_spi: Fix error handling in ->probe()" * tag 'mmc-v6.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: jz4740: Work around bug on JZ4760(B) mmc: mmc_spi: fix error handling in mmc_spi_probe() mmc: sdio: fix possible resource leaks in some error paths mmc: meson-gx: fix SDIO mode if cap_sdio_irq isn't set
2 parents 64e0253 + 3f18c50 commit bda6cfa

File tree

5 files changed

+41
-29
lines changed

5 files changed

+41
-29
lines changed

drivers/mmc/core/sdio_bus.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ static void sdio_release_func(struct device *dev)
294294
if (!(func->card->quirks & MMC_QUIRK_NONSTD_SDIO))
295295
sdio_free_func_cis(func);
296296

297+
/*
298+
* We have now removed the link to the tuples in the
299+
* card structure, so remove the reference.
300+
*/
301+
put_device(&func->card->dev);
302+
297303
kfree(func->info);
298304
kfree(func->tmpbuf);
299305
kfree(func);
@@ -324,6 +330,12 @@ struct sdio_func *sdio_alloc_func(struct mmc_card *card)
324330

325331
device_initialize(&func->dev);
326332

333+
/*
334+
* We may link to tuples in the card structure,
335+
* we need make sure we have a reference to it.
336+
*/
337+
get_device(&func->card->dev);
338+
327339
func->dev.parent = &card->dev;
328340
func->dev.bus = &sdio_bus_type;
329341
func->dev.release = sdio_release_func;
@@ -377,10 +389,9 @@ int sdio_add_func(struct sdio_func *func)
377389
*/
378390
void sdio_remove_func(struct sdio_func *func)
379391
{
380-
if (!sdio_func_present(func))
381-
return;
392+
if (sdio_func_present(func))
393+
device_del(&func->dev);
382394

383-
device_del(&func->dev);
384395
of_node_put(func->dev.of_node);
385396
put_device(&func->dev);
386397
}

drivers/mmc/core/sdio_cis.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,6 @@ int sdio_read_func_cis(struct sdio_func *func)
403403
if (ret)
404404
return ret;
405405

406-
/*
407-
* Since we've linked to tuples in the card structure,
408-
* we must make sure we have a reference to it.
409-
*/
410-
get_device(&func->card->dev);
411-
412406
/*
413407
* Vendor/device id is optional for function CIS, so
414408
* copy it from the card structure as needed.
@@ -434,11 +428,5 @@ void sdio_free_func_cis(struct sdio_func *func)
434428
}
435429

436430
func->tuples = NULL;
437-
438-
/*
439-
* We have now removed the link to the tuples in the
440-
* card structure, so remove the reference.
441-
*/
442-
put_device(&func->card->dev);
443431
}
444432

drivers/mmc/host/jz4740_mmc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,16 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
10531053
mmc->ops = &jz4740_mmc_ops;
10541054
if (!mmc->f_max)
10551055
mmc->f_max = JZ_MMC_CLK_RATE;
1056+
1057+
/*
1058+
* There seems to be a problem with this driver on the JZ4760 and
1059+
* JZ4760B SoCs. There, when using the maximum rate supported (50 MHz),
1060+
* the communication fails with many SD cards.
1061+
* Until this bug is sorted out, limit the maximum rate to 24 MHz.
1062+
*/
1063+
if (host->version == JZ_MMC_JZ4760 && mmc->f_max > JZ_MMC_CLK_RATE)
1064+
mmc->f_max = JZ_MMC_CLK_RATE;
1065+
10561066
mmc->f_min = mmc->f_max / 128;
10571067
mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
10581068

drivers/mmc/host/meson-gx-mmc.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,8 @@ static int meson_mmc_clk_init(struct meson_host *host)
435435
clk_reg |= FIELD_PREP(CLK_CORE_PHASE_MASK, CLK_PHASE_180);
436436
clk_reg |= FIELD_PREP(CLK_TX_PHASE_MASK, CLK_PHASE_0);
437437
clk_reg |= FIELD_PREP(CLK_RX_PHASE_MASK, CLK_PHASE_0);
438-
clk_reg |= CLK_IRQ_SDIO_SLEEP(host);
438+
if (host->mmc->caps & MMC_CAP_SDIO_IRQ)
439+
clk_reg |= CLK_IRQ_SDIO_SLEEP(host);
439440
writel(clk_reg, host->regs + SD_EMMC_CLOCK);
440441

441442
/* get the mux parents */
@@ -948,16 +949,18 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id)
948949
{
949950
struct meson_host *host = dev_id;
950951
struct mmc_command *cmd;
951-
u32 status, raw_status;
952+
u32 status, raw_status, irq_mask = IRQ_EN_MASK;
952953
irqreturn_t ret = IRQ_NONE;
953954

955+
if (host->mmc->caps & MMC_CAP_SDIO_IRQ)
956+
irq_mask |= IRQ_SDIO;
954957
raw_status = readl(host->regs + SD_EMMC_STATUS);
955-
status = raw_status & (IRQ_EN_MASK | IRQ_SDIO);
958+
status = raw_status & irq_mask;
956959

957960
if (!status) {
958961
dev_dbg(host->dev,
959-
"Unexpected IRQ! irq_en 0x%08lx - status 0x%08x\n",
960-
IRQ_EN_MASK | IRQ_SDIO, raw_status);
962+
"Unexpected IRQ! irq_en 0x%08x - status 0x%08x\n",
963+
irq_mask, raw_status);
961964
return IRQ_NONE;
962965
}
963966

@@ -1204,6 +1207,11 @@ static int meson_mmc_probe(struct platform_device *pdev)
12041207
goto free_host;
12051208
}
12061209

1210+
mmc->caps |= MMC_CAP_CMD23;
1211+
1212+
if (mmc->caps & MMC_CAP_SDIO_IRQ)
1213+
mmc->caps2 |= MMC_CAP2_SDIO_IRQ_NOTHREAD;
1214+
12071215
host->data = (struct meson_mmc_data *)
12081216
of_device_get_match_data(&pdev->dev);
12091217
if (!host->data) {
@@ -1277,11 +1285,6 @@ static int meson_mmc_probe(struct platform_device *pdev)
12771285

12781286
spin_lock_init(&host->lock);
12791287

1280-
mmc->caps |= MMC_CAP_CMD23;
1281-
1282-
if (mmc->caps & MMC_CAP_SDIO_IRQ)
1283-
mmc->caps2 |= MMC_CAP2_SDIO_IRQ_NOTHREAD;
1284-
12851288
if (host->dram_access_quirk) {
12861289
/* Limit segments to 1 due to low available sram memory */
12871290
mmc->max_segs = 1;

drivers/mmc/host/mmc_spi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,15 +1437,15 @@ static int mmc_spi_probe(struct spi_device *spi)
14371437

14381438
status = mmc_add_host(mmc);
14391439
if (status != 0)
1440-
goto fail_add_host;
1440+
goto fail_glue_init;
14411441

14421442
/*
14431443
* Index 0 is card detect
14441444
* Old boardfiles were specifying 1 ms as debounce
14451445
*/
14461446
status = mmc_gpiod_request_cd(mmc, NULL, 0, false, 1000);
14471447
if (status == -EPROBE_DEFER)
1448-
goto fail_add_host;
1448+
goto fail_gpiod_request;
14491449
if (!status) {
14501450
/*
14511451
* The platform has a CD GPIO signal that may support
@@ -1460,7 +1460,7 @@ static int mmc_spi_probe(struct spi_device *spi)
14601460
/* Index 1 is write protect/read only */
14611461
status = mmc_gpiod_request_ro(mmc, NULL, 1, 0);
14621462
if (status == -EPROBE_DEFER)
1463-
goto fail_add_host;
1463+
goto fail_gpiod_request;
14641464
if (!status)
14651465
has_ro = true;
14661466

@@ -1474,7 +1474,7 @@ static int mmc_spi_probe(struct spi_device *spi)
14741474
? ", cd polling" : "");
14751475
return 0;
14761476

1477-
fail_add_host:
1477+
fail_gpiod_request:
14781478
mmc_remove_host(mmc);
14791479
fail_glue_init:
14801480
mmc_spi_dma_free(host);

0 commit comments

Comments
 (0)