On Sun, 9 Mar 2025, Philippe Mathieu-Daudé wrote:
On 9/3/25 12:43, BALATON Zoltan wrote:
On Sat, 8 Mar 2025, Philippe Mathieu-Daudé wrote:
All TYPE_IMX_USDHC instances use the quirk:
move it to the class layer.
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
---
include/hw/sd/sdhci.h | 3 ++-
hw/sd/sdhci.c | 15 +++++++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
index c4b20db3877..0616ce3aa59 100644
--- a/include/hw/sd/sdhci.h
+++ b/include/hw/sd/sdhci.h
@@ -95,7 +95,6 @@ struct SDHCIState {
/* Configurable properties */
bool pending_insert_quirk; /* Quirk for Raspberry Pi card insert int
*/
- uint32_t quirks;
uint8_t endianness;
uint8_t sd_spec_version;
uint8_t uhs_mode;
@@ -112,6 +111,8 @@ typedef struct SDHCIClass {
PCIDeviceClass pci_parent_class;
SysBusDeviceClass sbd_parent_class;
};
+
+ uint32_t quirks;
} SDHCIClass;
/*
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index 4917a9b3632..2b7eb11a14a 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -345,6 +345,8 @@ static void sdhci_send_command(SDHCIState *s)
rlen = sdbus_do_command(&s->sdbus, &request, response);
if (s->cmdreg & SDHC_CMD_RESPONSE) {
+ SDHCIClass *sc = SYSBUS_SDHCI_GET_CLASS(s);
I don't like this because it introduces a class look up which may be costly
in a function that could be called frequently. Maybe you could just drop
this patch and leave the quirk handling as it is. Changing it does not seem
to improve the model much.
I thought about it and was expecting a such comment.
Initializing a class field in the instance_init is an anti-pattern,
Why? It's not a class field, it's in SDHCIState (we have another quirk for
rpi already there which could also use the same bits). But you could also
init in realize instead if that's better then no need to duplicate it in
class struct just to copy it to every instance.
Regards,
BALATON Zoltan