aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2025-01-09 13:12:37 +0100
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2025-01-13 17:16:04 +0100
commit14b1086f92ae8d45fc1e66c837ddc7da79d93f9b (patch)
treeff2ba8ee8375ebaaab5e134c7d2e2c706ce34e77
parent5df50b8e97377d2468bd8759ec3275e747a147bb (diff)
downloadqemu-14b1086f92ae8d45fc1e66c837ddc7da79d93f9b.zip
qemu-14b1086f92ae8d45fc1e66c837ddc7da79d93f9b.tar.gz
qemu-14b1086f92ae8d45fc1e66c837ddc7da79d93f9b.tar.bz2
hw/sd/sdhci: Factor sdhci_sdma_transfer() out
Factor sdhci_sdma_transfer() out of sdhci_data_transfer(). Re-use it in sdhci_write(), so we don't try to run multi block transfer for a single block. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Bernhard Beschow <shentey@gmail.com> Message-Id: <20250109122029.22780-1-philmd@linaro.org>
-rw-r--r--hw/sd/sdhci.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index a958c11..318587f 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -699,6 +699,15 @@ static void sdhci_sdma_transfer_single_block(SDHCIState *s)
sdhci_end_transfer(s);
}
+static void sdhci_sdma_transfer(SDHCIState *s)
+{
+ if ((s->blkcnt == 1) || !(s->trnmod & SDHC_TRNS_MULTI)) {
+ sdhci_sdma_transfer_single_block(s);
+ } else {
+ sdhci_sdma_transfer_multi_blocks(s);
+ }
+}
+
typedef struct ADMADescr {
hwaddr addr;
uint16_t length;
@@ -930,12 +939,7 @@ static void sdhci_data_transfer(void *opaque)
if (s->trnmod & SDHC_TRNS_DMA) {
switch (SDHC_DMA_TYPE(s->hostctl1)) {
case SDHC_CTRL_SDMA:
- if ((s->blkcnt == 1) || !(s->trnmod & SDHC_TRNS_MULTI)) {
- sdhci_sdma_transfer_single_block(s);
- } else {
- sdhci_sdma_transfer_multi_blocks(s);
- }
-
+ sdhci_sdma_transfer(s);
break;
case SDHC_CTRL_ADMA1_32:
if (!(s->capareg & R_SDHC_CAPAB_ADMA1_MASK)) {
@@ -1179,11 +1183,7 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
if (!(mask & 0xFF000000) && s->blkcnt &&
(s->blksize & BLOCK_SIZE_MASK) &&
SDHC_DMA_TYPE(s->hostctl1) == SDHC_CTRL_SDMA) {
- if (s->trnmod & SDHC_TRNS_MULTI) {
- sdhci_sdma_transfer_multi_blocks(s);
- } else {
- sdhci_sdma_transfer_single_block(s);
- }
+ sdhci_sdma_transfer(s);
}
}
break;