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@xxxxxxxxxxxxxx> --- drivers/mci/mci-core.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index b174067a7fbc..92a73c8f1dfe 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; -- 2.29.2 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox