[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/46] hw/sd/sdhci: Block Size Register bits [14:12] is lost
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 10/46] hw/sd/sdhci: Block Size Register bits [14:12] is lost |
Date: |
Thu, 19 Oct 2023 23:17:35 +0200 |
From: Lu Gao <lu.gao@verisilicon.com>
Block Size Register bits [14:12] is SDMA Buffer Boundary, it is missed
in register write, but it is needed in SDMA transfer. e.g. it will be
used in sdhci_sdma_transfer_multi_blocks to calculate boundary_ variables.
Missing this field will cause wrong operation for different SDMA Buffer
Boundary settings.
Fixes: d7dfca0807 ("hw/sdhci: introduce standard SD host controller")
Fixes: dfba99f17f ("hw/sdhci: Fix DMA Transfer Block Size field")
Signed-off-by: Lu Gao <lu.gao@verisilicon.com>
Signed-off-by: Jianxian Wen <jianxian.wen@verisilicon.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-ID: <20220321055618.4026-1-lu.gao@verisilicon.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sd/sdhci.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index 5564765a9b..40473b0db0 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -321,6 +321,8 @@ static void sdhci_poweron_reset(DeviceState *dev)
static void sdhci_data_transfer(void *opaque);
+#define BLOCK_SIZE_MASK (4 * KiB - 1)
+
static void sdhci_send_command(SDHCIState *s)
{
SDRequest request;
@@ -371,7 +373,8 @@ static void sdhci_send_command(SDHCIState *s)
sdhci_update_irq(s);
- if (!timeout && s->blksize && (s->cmdreg & SDHC_CMD_DATA_PRESENT)) {
+ if (!timeout && (s->blksize & BLOCK_SIZE_MASK) &&
+ (s->cmdreg & SDHC_CMD_DATA_PRESENT)) {
s->data_count = 0;
sdhci_data_transfer(s);
}
@@ -406,7 +409,6 @@ static void sdhci_end_transfer(SDHCIState *s)
/*
* Programmed i/o data transfer
*/
-#define BLOCK_SIZE_MASK (4 * KiB - 1)
/* Fill host controller's read buffer with BLKSIZE bytes of data from card */
static void sdhci_read_block_from_card(SDHCIState *s)
@@ -1154,7 +1156,8 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val,
unsigned size)
s->sdmasysad = (s->sdmasysad & mask) | value;
MASKED_WRITE(s->sdmasysad, mask, value);
/* Writing to last byte of sdmasysad might trigger transfer */
- if (!(mask & 0xFF000000) && s->blkcnt && s->blksize &&
+ 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);
@@ -1168,7 +1171,11 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val,
unsigned size)
if (!TRANSFERRING_DATA(s->prnsts)) {
uint16_t blksize = s->blksize;
- MASKED_WRITE(s->blksize, mask, extract32(value, 0, 12));
+ /*
+ * [14:12] SDMA Buffer Boundary
+ * [11:00] Transfer Block Size
+ */
+ MASKED_WRITE(s->blksize, mask, extract32(value, 0, 15));
MASKED_WRITE(s->blkcnt, mask >> 16, value >> 16);
/* Limit block size to the maximum buffer size */
--
2.41.0
- [PULL 00/46] Misc HW/UI patches for 2023-10-19, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 02/46] MAINTAINERS: Split vt82c686 out of fuloong2e, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 01/46] mailmap: update email addresses for Luc Michel, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 03/46] MAINTAINERS: Add hw/input/lasips2.c to the HPPA machine section, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 04/46] MAINTAINERS: Add include/hw/intc/loongson_liointc.h to the Loongson-3 virt section, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 05/46] MAINTAINERS: Add include/hw/openrisc/ to the OpenRISC section, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 06/46] cutils: Fix get_relocated_path on Windows, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 07/46] buildsys: Only display Objective-C information when Objective-C is used, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 08/46] memory: drop needless argument, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 09/46] memory: follow Error API guidelines, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 10/46] hw/sd/sdhci: Block Size Register bits [14:12] is lost,
Philippe Mathieu-Daudé <=
- [PULL 11/46] hw/mips/malta: Use sdram_type enum from 'hw/i2c/smbus_eeprom.h', Philippe Mathieu-Daudé, 2023/10/19
- [PULL 12/46] hw/mips: Merge 'hw/mips/cpudevs.h' with 'target/mips/cpu.h', Philippe Mathieu-Daudé, 2023/10/19
- [PULL 13/46] hw/misc/mips_itu: Declare itc_reconfigure() in 'hw/misc/mips_itu.h', Philippe Mathieu-Daudé, 2023/10/19
- [PULL 14/46] hw/misc/mips_itu: Make MIPSITUState target agnostic, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 15/46] hw/pci-host/sh_pcic: Declare CPU QOM types using DEFINE_TYPES() macro, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 16/46] hw/pci-host/sh_pcic: Correct PCI host / devfn#0 function names, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 17/46] hw/pci-host/sh_pcic: Replace magic value by proper definition, Philippe Mathieu-Daudé, 2023/10/19
- [PULL 18/46] hw/sparc64/ebus: Access memory regions via pci_address_space_io(), Philippe Mathieu-Daudé, 2023/10/19
- [PULL 19/46] hw/acpi/pcihp: Clean up global variable shadowing in acpi_pcihp_init(), Philippe Mathieu-Daudé, 2023/10/19
- [PULL 20/46] hw/pci: Clean up global variable shadowing of address_space_io variable, Philippe Mathieu-Daudé, 2023/10/19