summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-06-19 06:50:44 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-06-24 08:53:47 +0200
commit3a62463a4954a26ac3ec92550308ed3cbc3b3e05 (patch)
treefaa6b24c6626136d9858cfa51ed4d1bb83967ed3 /drivers
parent9b37931ab8457417938c2f0981d616b08afde45d (diff)
downloadbarebox-3a62463a4954a26ac3ec92550308ed3cbc3b3e05.tar.gz
barebox-3a62463a4954a26ac3ec92550308ed3cbc3b3e05.tar.xz
mci: allocate sector_buf on demand
The MCI core uses a common bounce buffer for unaligned block reads/writes as well as sd_change_freq. This buffer is allocated at device initcall level, same as the MMC drivers themselves. For CONFIG_MCI_STARTUP=y configurations this seems to imply that sd_change_freq could attempt writing the NULL page. Avoid this by just allocating the buffer when the first MMC device is registered. This doesn't solve all issues; so add a comment noting that. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619045055.779-19-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mci/mci-core.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index b174067a7f..92a73c8f1d 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1790,6 +1790,11 @@ static int mci_card_probe(struct mci *mci)
mci->cdevname = basprintf("disk%d", disknum);
}
+ if (!sector_buf)
+ sector_buf = dma_alloc(SECTOR_SIZE);
+
+ /* FIXME we don't check sector_buf against the device dma mask here */
+
rc = mci_startup(mci);
if (rc) {
dev_warn(&mci->dev, "Card's startup fails with %d\n", rc);
@@ -1851,15 +1856,6 @@ static int mci_set_probe(struct param_d *param, void *priv)
return 0;
}
-static int mci_init(void)
-{
- sector_buf = dma_alloc(SECTOR_SIZE);
-
- return 0;
-}
-
-device_initcall(mci_init);
-
int mci_detect_card(struct mci_host *host)
{
int rc;