* [PATCH v2 0/2] sd: sdhci: Implement basic vendor specific register support @ 2020-06-03 14:52 Guenter Roeck 2020-06-03 14:52 ` [PATCH v2 1/2] " Guenter Roeck ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Guenter Roeck @ 2020-06-03 14:52 UTC (permalink / raw) To: Peter Maydell Cc: Andrey Smirnov, qemu-devel, Jean-Christophe Dubois, qemu-arm, Philippe Mathieu-Daudé, Guenter Roeck The Linux kernel's IMX code now uses vendor specific commands. This results in endless warnings when booting the Linux kernel. sdhci-esdhc-imx 2194000.usdhc: esdhc_wait_for_card_clock_gate_off: card clock still not gate off in 100us!. Implement support for the vendor specific command implemented in IMX SDHCI hardware to be able to avoid this warning. Patch 1/2 implements vendor specific command support in the SDHCI core code. At this time, only IMX vendor command support is implemented, but the implementation is written with expandability in mind. Patch 2/2 enables IMX SDHCI vendor extensions for all affected emulations. v2: - Added Reviewed-by: and Tested-by: tags to patch 1/2 - Added missing error checks to patch 2/2 - Added Tested-by: tag to patch 2/2 ---------------------------------------------------------------- Guenter Roeck (2): sd: sdhci: Implement basic vendor specific register support hw: arm: Set vendor property for IMX SDHCI emulations hw/arm/fsl-imx25.c | 6 ++++++ hw/arm/fsl-imx6.c | 6 ++++++ hw/arm/fsl-imx6ul.c | 2 ++ hw/arm/fsl-imx7.c | 2 ++ hw/sd/sdhci-internal.h | 5 +++++ hw/sd/sdhci.c | 18 +++++++++++++++++- include/hw/sd/sdhci.h | 5 +++++ 7 files changed, 43 insertions(+), 1 deletion(-) ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] sd: sdhci: Implement basic vendor specific register support 2020-06-03 14:52 [PATCH v2 0/2] sd: sdhci: Implement basic vendor specific register support Guenter Roeck @ 2020-06-03 14:52 ` Guenter Roeck 2020-06-03 14:52 ` [PATCH v2 2/2] hw: arm: Set vendor property for IMX SDHCI emulations Guenter Roeck 2020-06-15 13:18 ` [PATCH v2 0/2] sd: sdhci: Implement basic vendor specific register support Peter Maydell 2 siblings, 0 replies; 7+ messages in thread From: Guenter Roeck @ 2020-06-03 14:52 UTC (permalink / raw) To: Peter Maydell Cc: Andrey Smirnov, qemu-devel, Jean-Christophe Dubois, qemu-arm, Philippe Mathieu-Daudé, Guenter Roeck The Linux kernel's IMX code now uses vendor specific commands. This results in endless warnings when booting the Linux kernel. sdhci-esdhc-imx 2194000.usdhc: esdhc_wait_for_card_clock_gate_off: card clock still not gate off in 100us!. Implement support for the vendor specific command implemented in IMX hardware to be able to avoid this warning. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> --- v2: Added Philippe's Tested-by: and Reviewed-by: tags hw/sd/sdhci-internal.h | 5 +++++ hw/sd/sdhci.c | 18 +++++++++++++++++- include/hw/sd/sdhci.h | 5 +++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/hw/sd/sdhci-internal.h b/hw/sd/sdhci-internal.h index e7c8a523b5..e8c753d6d1 100644 --- a/hw/sd/sdhci-internal.h +++ b/hw/sd/sdhci-internal.h @@ -75,6 +75,7 @@ #define SDHC_CMD_INHIBIT 0x00000001 #define SDHC_DATA_INHIBIT 0x00000002 #define SDHC_DAT_LINE_ACTIVE 0x00000004 +#define SDHC_IMX_CLOCK_GATE_OFF 0x00000080 #define SDHC_DOING_WRITE 0x00000100 #define SDHC_DOING_READ 0x00000200 #define SDHC_SPACE_AVAILABLE 0x00000400 @@ -289,7 +290,10 @@ extern const VMStateDescription sdhci_vmstate; #define ESDHC_MIX_CTRL 0x48 + #define ESDHC_VENDOR_SPEC 0xc0 +#define ESDHC_IMX_FRC_SDCLK_ON (1 << 8) + #define ESDHC_DLL_CTRL 0x60 #define ESDHC_TUNING_CTRL 0xcc @@ -326,6 +330,7 @@ extern const VMStateDescription sdhci_vmstate; #define DEFINE_SDHCI_COMMON_PROPERTIES(_state) \ DEFINE_PROP_UINT8("sd-spec-version", _state, sd_spec_version, 2), \ DEFINE_PROP_UINT8("uhs", _state, uhs_mode, UHS_NOT_SUPPORTED), \ + DEFINE_PROP_UINT8("vendor", _state, vendor, SDHCI_VENDOR_NONE), \ \ /* Capabilities registers provide information on supported * features of this specific host controller implementation */ \ diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 1b75d7bab9..eb2be6529e 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1569,11 +1569,13 @@ static uint64_t usdhc_read(void *opaque, hwaddr offset, unsigned size) } break; + case ESDHC_VENDOR_SPEC: + ret = s->vendor_spec; + break; case ESDHC_DLL_CTRL: case ESDHC_TUNE_CTRL_STATUS: case ESDHC_UNDOCUMENTED_REG27: case ESDHC_TUNING_CTRL: - case ESDHC_VENDOR_SPEC: case ESDHC_MIX_CTRL: case ESDHC_WTMK_LVL: ret = 0; @@ -1596,7 +1598,21 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) case ESDHC_UNDOCUMENTED_REG27: case ESDHC_TUNING_CTRL: case ESDHC_WTMK_LVL: + break; + case ESDHC_VENDOR_SPEC: + s->vendor_spec = value; + switch (s->vendor) { + case SDHCI_VENDOR_IMX: + if (value & ESDHC_IMX_FRC_SDCLK_ON) { + s->prnsts &= ~SDHC_IMX_CLOCK_GATE_OFF; + } else { + s->prnsts |= SDHC_IMX_CLOCK_GATE_OFF; + } + break; + default: + break; + } break; case SDHC_HOSTCTL: diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h index c6868c9699..5d9275f3d6 100644 --- a/include/hw/sd/sdhci.h +++ b/include/hw/sd/sdhci.h @@ -74,6 +74,7 @@ typedef struct SDHCIState { uint16_t acmd12errsts; /* Auto CMD12 error status register */ uint16_t hostctl2; /* Host Control 2 */ uint64_t admasysaddr; /* ADMA System Address Register */ + uint16_t vendor_spec; /* Vendor specific register */ /* Read-only registers */ uint64_t capareg; /* Capabilities Register */ @@ -96,8 +97,12 @@ typedef struct SDHCIState { uint32_t quirks; uint8_t sd_spec_version; uint8_t uhs_mode; + uint8_t vendor; /* For vendor specific functionality */ } SDHCIState; +#define SDHCI_VENDOR_NONE 0 +#define SDHCI_VENDOR_IMX 1 + /* * Controller does not provide transfer-complete interrupt when not * busy. -- 2.17.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] hw: arm: Set vendor property for IMX SDHCI emulations 2020-06-03 14:52 [PATCH v2 0/2] sd: sdhci: Implement basic vendor specific register support Guenter Roeck 2020-06-03 14:52 ` [PATCH v2 1/2] " Guenter Roeck @ 2020-06-03 14:52 ` Guenter Roeck 2020-06-04 6:28 ` Philippe Mathieu-Daudé 2020-06-15 13:18 ` Peter Maydell 2020-06-15 13:18 ` [PATCH v2 0/2] sd: sdhci: Implement basic vendor specific register support Peter Maydell 2 siblings, 2 replies; 7+ messages in thread From: Guenter Roeck @ 2020-06-03 14:52 UTC (permalink / raw) To: Peter Maydell Cc: Andrey Smirnov, qemu-devel, Jean-Christophe Dubois, qemu-arm, Philippe Mathieu-Daudé, Guenter Roeck Set vendor property to IMX to enable IMX specific functionality in sdhci code. Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> --- v2: Added missing error checks Added Philippe's Tested-by: tag hw/arm/fsl-imx25.c | 6 ++++++ hw/arm/fsl-imx6.c | 6 ++++++ hw/arm/fsl-imx6ul.c | 2 ++ hw/arm/fsl-imx7.c | 2 ++ 4 files changed, 16 insertions(+) diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c index cdaa79c26b..a853ffcc00 100644 --- a/hw/arm/fsl-imx25.c +++ b/hw/arm/fsl-imx25.c @@ -274,6 +274,12 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) &err); object_property_set_uint(OBJECT(&s->esdhc[i]), IMX25_ESDHC_CAPABILITIES, "capareg", &err); + object_property_set_uint(OBJECT(&s->esdhc[i]), SDHCI_VENDOR_IMX, + "vendor", &err); + if (err) { + error_propagate(errp, err); + return; + } object_property_set_bool(OBJECT(&s->esdhc[i]), true, "realized", &err); if (err) { error_propagate(errp, err); diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c index f58c85aa8c..29677cfd59 100644 --- a/hw/arm/fsl-imx6.c +++ b/hw/arm/fsl-imx6.c @@ -350,6 +350,12 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) &err); object_property_set_uint(OBJECT(&s->esdhc[i]), IMX6_ESDHC_CAPABILITIES, "capareg", &err); + object_property_set_uint(OBJECT(&s->esdhc[i]), SDHCI_VENDOR_IMX, + "vendor", &err); + if (err) { + error_propagate(errp, err); + return; + } object_property_set_bool(OBJECT(&s->esdhc[i]), true, "realized", &err); if (err) { error_propagate(errp, err); diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c index 3ecb212da6..ce1462927c 100644 --- a/hw/arm/fsl-imx6ul.c +++ b/hw/arm/fsl-imx6ul.c @@ -505,6 +505,8 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) FSL_IMX6UL_USDHC2_IRQ, }; + object_property_set_uint(OBJECT(&s->usdhc[i]), SDHCI_VENDOR_IMX, + "vendor", &error_abort); object_property_set_bool(OBJECT(&s->usdhc[i]), true, "realized", &error_abort); diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c index 89c3b64c06..dbf16b2814 100644 --- a/hw/arm/fsl-imx7.c +++ b/hw/arm/fsl-imx7.c @@ -416,6 +416,8 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) FSL_IMX7_USDHC3_IRQ, }; + object_property_set_uint(OBJECT(&s->usdhc[i]), SDHCI_VENDOR_IMX, + "vendor", &error_abort); object_property_set_bool(OBJECT(&s->usdhc[i]), true, "realized", &error_abort); -- 2.17.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] hw: arm: Set vendor property for IMX SDHCI emulations 2020-06-03 14:52 ` [PATCH v2 2/2] hw: arm: Set vendor property for IMX SDHCI emulations Guenter Roeck @ 2020-06-04 6:28 ` Philippe Mathieu-Daudé 2020-06-15 13:18 ` Peter Maydell 1 sibling, 0 replies; 7+ messages in thread From: Philippe Mathieu-Daudé @ 2020-06-04 6:28 UTC (permalink / raw) To: Guenter Roeck, Peter Maydell Cc: Andrey Smirnov, qemu-arm, qemu-devel, Jean-Christophe Dubois On 6/3/20 4:52 PM, Guenter Roeck wrote: > Set vendor property to IMX to enable IMX specific functionality > in sdhci code. > > Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > Signed-off-by: Guenter Roeck <linux@roeck-us.net> > --- > v2: Added missing error checks > Added Philippe's Tested-by: tag > > hw/arm/fsl-imx25.c | 6 ++++++ > hw/arm/fsl-imx6.c | 6 ++++++ > hw/arm/fsl-imx6ul.c | 2 ++ > hw/arm/fsl-imx7.c | 2 ++ > 4 files changed, 16 insertions(+) > > diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c > index cdaa79c26b..a853ffcc00 100644 > --- a/hw/arm/fsl-imx25.c > +++ b/hw/arm/fsl-imx25.c > @@ -274,6 +274,12 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) > &err); > object_property_set_uint(OBJECT(&s->esdhc[i]), IMX25_ESDHC_CAPABILITIES, > "capareg", &err); > + object_property_set_uint(OBJECT(&s->esdhc[i]), SDHCI_VENDOR_IMX, > + "vendor", &err); > + if (err) { > + error_propagate(errp, err); > + return; > + } > object_property_set_bool(OBJECT(&s->esdhc[i]), true, "realized", &err); > if (err) { > error_propagate(errp, err); > diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c > index f58c85aa8c..29677cfd59 100644 > --- a/hw/arm/fsl-imx6.c > +++ b/hw/arm/fsl-imx6.c > @@ -350,6 +350,12 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) > &err); > object_property_set_uint(OBJECT(&s->esdhc[i]), IMX6_ESDHC_CAPABILITIES, > "capareg", &err); > + object_property_set_uint(OBJECT(&s->esdhc[i]), SDHCI_VENDOR_IMX, > + "vendor", &err); > + if (err) { > + error_propagate(errp, err); > + return; > + } > object_property_set_bool(OBJECT(&s->esdhc[i]), true, "realized", &err); > if (err) { > error_propagate(errp, err); > diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c > index 3ecb212da6..ce1462927c 100644 > --- a/hw/arm/fsl-imx6ul.c > +++ b/hw/arm/fsl-imx6ul.c > @@ -505,6 +505,8 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) > FSL_IMX6UL_USDHC2_IRQ, > }; > > + object_property_set_uint(OBJECT(&s->usdhc[i]), SDHCI_VENDOR_IMX, > + "vendor", &error_abort); > object_property_set_bool(OBJECT(&s->usdhc[i]), true, "realized", > &error_abort); > > diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c > index 89c3b64c06..dbf16b2814 100644 > --- a/hw/arm/fsl-imx7.c > +++ b/hw/arm/fsl-imx7.c > @@ -416,6 +416,8 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) > FSL_IMX7_USDHC3_IRQ, > }; > > + object_property_set_uint(OBJECT(&s->usdhc[i]), SDHCI_VENDOR_IMX, > + "vendor", &error_abort); > object_property_set_bool(OBJECT(&s->usdhc[i]), true, "realized", > &error_abort); > > Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] hw: arm: Set vendor property for IMX SDHCI emulations 2020-06-03 14:52 ` [PATCH v2 2/2] hw: arm: Set vendor property for IMX SDHCI emulations Guenter Roeck 2020-06-04 6:28 ` Philippe Mathieu-Daudé @ 2020-06-15 13:18 ` Peter Maydell 2020-06-15 14:59 ` Guenter Roeck 1 sibling, 1 reply; 7+ messages in thread From: Peter Maydell @ 2020-06-15 13:18 UTC (permalink / raw) To: Guenter Roeck Cc: Andrey Smirnov, qemu-arm, Philippe Mathieu-Daudé, QEMU Developers, Jean-Christophe Dubois On Wed, 3 Jun 2020 at 15:53, Guenter Roeck <linux@roeck-us.net> wrote: > > Set vendor property to IMX to enable IMX specific functionality > in sdhci code. > > Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > Signed-off-by: Guenter Roeck <linux@roeck-us.net> > --- > v2: Added missing error checks > Added Philippe's Tested-by: tag > > hw/arm/fsl-imx25.c | 6 ++++++ > hw/arm/fsl-imx6.c | 6 ++++++ > hw/arm/fsl-imx6ul.c | 2 ++ > hw/arm/fsl-imx7.c | 2 ++ > 4 files changed, 16 insertions(+) > > diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c > index cdaa79c26b..a853ffcc00 100644 > --- a/hw/arm/fsl-imx25.c > +++ b/hw/arm/fsl-imx25.c > @@ -274,6 +274,12 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) > &err); > object_property_set_uint(OBJECT(&s->esdhc[i]), IMX25_ESDHC_CAPABILITIES, > "capareg", &err); > + object_property_set_uint(OBJECT(&s->esdhc[i]), SDHCI_VENDOR_IMX, > + "vendor", &err); > + if (err) { > + error_propagate(errp, err); > + return; > + } The existing error handling in this function is wrong -- for multiple calls that take a pointer to a local Error*, the check-and-error_propagate() has to be done after each call, it can't be rolled up into a single check after all the calls. (see include/qapi/error.h for the patterns that are valid). On the other hand this change is correct-in-itself so I guess it isn't making the problem worse... thanks -- PMM ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] hw: arm: Set vendor property for IMX SDHCI emulations 2020-06-15 13:18 ` Peter Maydell @ 2020-06-15 14:59 ` Guenter Roeck 0 siblings, 0 replies; 7+ messages in thread From: Guenter Roeck @ 2020-06-15 14:59 UTC (permalink / raw) To: Peter Maydell Cc: Andrey Smirnov, qemu-arm, Philippe Mathieu-Daudé, QEMU Developers, Jean-Christophe Dubois On 6/15/20 6:18 AM, Peter Maydell wrote: > On Wed, 3 Jun 2020 at 15:53, Guenter Roeck <linux@roeck-us.net> wrote: >> >> Set vendor property to IMX to enable IMX specific functionality >> in sdhci code. >> >> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> >> Signed-off-by: Guenter Roeck <linux@roeck-us.net> >> --- >> v2: Added missing error checks >> Added Philippe's Tested-by: tag >> >> hw/arm/fsl-imx25.c | 6 ++++++ >> hw/arm/fsl-imx6.c | 6 ++++++ >> hw/arm/fsl-imx6ul.c | 2 ++ >> hw/arm/fsl-imx7.c | 2 ++ >> 4 files changed, 16 insertions(+) >> >> diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c >> index cdaa79c26b..a853ffcc00 100644 >> --- a/hw/arm/fsl-imx25.c >> +++ b/hw/arm/fsl-imx25.c >> @@ -274,6 +274,12 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) >> &err); >> object_property_set_uint(OBJECT(&s->esdhc[i]), IMX25_ESDHC_CAPABILITIES, >> "capareg", &err); >> + object_property_set_uint(OBJECT(&s->esdhc[i]), SDHCI_VENDOR_IMX, >> + "vendor", &err); >> + if (err) { >> + error_propagate(errp, err); >> + return; >> + } > > The existing error handling in this function is wrong -- for multiple > calls that take a pointer to a local Error*, the > check-and-error_propagate() has to be done after each call, it can't > be rolled up into a single check after all the calls. (see > include/qapi/error.h for the patterns that are valid). > A fix for that problem was submitted by Philippe: https://www.mail-archive.com/qemu-devel@nongnu.org/msg695544.html Thanks, Guenter ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] sd: sdhci: Implement basic vendor specific register support 2020-06-03 14:52 [PATCH v2 0/2] sd: sdhci: Implement basic vendor specific register support Guenter Roeck 2020-06-03 14:52 ` [PATCH v2 1/2] " Guenter Roeck 2020-06-03 14:52 ` [PATCH v2 2/2] hw: arm: Set vendor property for IMX SDHCI emulations Guenter Roeck @ 2020-06-15 13:18 ` Peter Maydell 2 siblings, 0 replies; 7+ messages in thread From: Peter Maydell @ 2020-06-15 13:18 UTC (permalink / raw) To: Guenter Roeck Cc: Andrey Smirnov, qemu-arm, Philippe Mathieu-Daudé, QEMU Developers, Jean-Christophe Dubois On Wed, 3 Jun 2020 at 15:53, Guenter Roeck <linux@roeck-us.net> wrote: > > The Linux kernel's IMX code now uses vendor specific commands. > This results in endless warnings when booting the Linux kernel. > > sdhci-esdhc-imx 2194000.usdhc: esdhc_wait_for_card_clock_gate_off: > card clock still not gate off in 100us!. > > Implement support for the vendor specific command implemented in IMX > SDHCI hardware to be able to avoid this warning. > > Patch 1/2 implements vendor specific command support in the SDHCI core > code. At this time, only IMX vendor command support is implemented, > but the implementation is written with expandability in mind. > > Patch 2/2 enables IMX SDHCI vendor extensions for all affected emulations. > > v2: > - Added Reviewed-by: and Tested-by: tags to patch 1/2 > - Added missing error checks to patch 2/2 > - Added Tested-by: tag to patch 2/2 Applied to target-arm.next, thanks. -- PMM ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-06-15 15:01 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-06-03 14:52 [PATCH v2 0/2] sd: sdhci: Implement basic vendor specific register support Guenter Roeck 2020-06-03 14:52 ` [PATCH v2 1/2] " Guenter Roeck 2020-06-03 14:52 ` [PATCH v2 2/2] hw: arm: Set vendor property for IMX SDHCI emulations Guenter Roeck 2020-06-04 6:28 ` Philippe Mathieu-Daudé 2020-06-15 13:18 ` Peter Maydell 2020-06-15 14:59 ` Guenter Roeck 2020-06-15 13:18 ` [PATCH v2 0/2] sd: sdhci: Implement basic vendor specific register support Peter Maydell
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).