diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2024-04-23 08:04:35 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2024-04-23 08:26:00 +0200 |
commit | b986aad24ab85b386b3884ccb047f011ebb9847f (patch) | |
tree | 7e0dcd0528abf4c7da2c9ad154098c505f5acf16 /drivers/mci/mci-core.c | |
parent | ed8dad10eac8c158469d6012ac0316ca4aaed0d1 (diff) | |
download | barebox-b986aad24ab85b386b3884ccb047f011ebb9847f.tar.gz barebox-b986aad24ab85b386b3884ccb047f011ebb9847f.tar.xz |
mci: core: allocate memory used for DMA with dma_alloc
Memory allocated by normal malloc may not fulfill the alignment
requirements for DMA.
This fixes memory corruption observed on the i.MX8MP when the
DMA-enabled eSDHC driver attempts to probe an eMMC.
This issues always existed, but only after commit 65ef5d885263
("ARM64: let 'end' point after the range in cache functions"), the whole
512 bytes were getting invalidated, which corrupted the TLSF malloc
header of the block after it.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240423060435.1514644-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mci/mci-core.c')
-rw-r--r-- | drivers/mci/mci-core.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index a3b25ea01a..083d2f4ed1 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -545,12 +545,12 @@ u8 *mci_get_ext_csd(struct mci *mci) u8 *ext_csd; int ret; - ext_csd = xmalloc(512); + ext_csd = dma_alloc(512); ret = mci_send_ext_csd(mci, ext_csd); if (ret) { printf("Failure to read EXT_CSD register\n"); - free(ext_csd); + dma_free(ext_csd); return ERR_PTR(-EIO); } @@ -666,7 +666,7 @@ static int mmc_change_freq(struct mci *mci) char cardtype; int err; - mci->ext_csd = xmalloc(512); + mci->ext_csd = dma_alloc(512); mci->card_caps = 0; /* Only version 4 supports high-speed */ @@ -1124,7 +1124,7 @@ static int mmc_compare_ext_csds(struct mci *mci, enum mci_bus_width bus_width) if (bus_width == MMC_BUS_WIDTH_1) return 0; - bw_ext_csd = xmalloc(512); + bw_ext_csd = dma_alloc(512); err = mci_send_ext_csd(mci, bw_ext_csd); if (err) { dev_info(&mci->dev, "mci_send_ext_csd failed with %d\n", err); @@ -1173,7 +1173,7 @@ static int mmc_compare_ext_csds(struct mci *mci, enum mci_bus_width bus_width) 0 : -EINVAL; out: - free(bw_ext_csd); + dma_free(bw_ext_csd); return err; } @@ -2220,7 +2220,7 @@ static int mci_get_partition_setting_completed(struct mci *mci) ret = ext_csd[EXT_CSD_PARTITION_SETTING_COMPLETED]; - free(ext_csd); + dma_free(ext_csd); return ret; } |