qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Bernhard Beschow <shentey@gmail.com>, qemu-devel@nongnu.org
Cc: Guenter Roeck <linux@roeck-us.net>,
	qemu-block@nongnu.org, Bin Meng <bin.meng@windriver.com>
Subject: Re: [PATCH] hw/sd/sdhci: Do not force sdhci_mmio_*_ops onto all SD controllers
Date: Mon, 10 Jul 2023 12:16:35 +0200	[thread overview]
Message-ID: <52b5a36a-5744-0ac9-a3f5-0dbd247410ed@linaro.org> (raw)
In-Reply-To: <20230709080950.92489-1-shentey@gmail.com>

On 9/7/23 10:09, Bernhard Beschow wrote:
> Since commit c0a55a0c9da2 "hw/sd/sdhci: Support big endian SD host controller
> interfaces" sdhci_common_realize() forces all SD card controllers to use either
> sdhci_mmio_le_ops or sdhci_mmio_be_ops, depending on the "endianness" property.
> However, there are device models which use different MMIO ops: TYPE_IMX_USDHC
> uses usdhc_mmio_ops and TYPE_S3C_SDHCI uses sdhci_s3c_mmio_ops.
> 
> Forcing sdhci_mmio_le_ops breaks SD card handling on the "sabrelite" board, for
> example. Fix this by defaulting the io_ops to little endian and switch to big
> endian in sdhci_common_realize() only if there is a matchig big endian variant
> available.
> 
> Fixes: c0a55a0c9da2 ("hw/sd/sdhci: Support big endian SD host controller
> interfaces")
> 
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
>   hw/sd/sdhci.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
> index 6811f0f1a8..362c2c86aa 100644
> --- a/hw/sd/sdhci.c
> +++ b/hw/sd/sdhci.c
> @@ -1382,6 +1382,8 @@ void sdhci_initfn(SDHCIState *s)
>   
>       s->insert_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_raise_insertion_irq, s);
>       s->transfer_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_data_transfer, s);
> +
> +    s->io_ops = &sdhci_mmio_le_ops;
>   }
>   
>   void sdhci_uninitfn(SDHCIState *s)
> @@ -1399,9 +1401,13 @@ void sdhci_common_realize(SDHCIState *s, Error **errp)
>   

What about simply keeping the same code guarded with 'if (!s->io_ops)'?

>       switch (s->endianness) {
>       case DEVICE_LITTLE_ENDIAN:
> -        s->io_ops = &sdhci_mmio_le_ops;
> +        /* s->io_ops is little endian by default */
>           break;
>       case DEVICE_BIG_ENDIAN:
> +        if (s->io_ops != &sdhci_mmio_le_ops) {
> +            error_setg(errp, "SD controller doesn't support big endianness");
> +            return;
> +        }
>           s->io_ops = &sdhci_mmio_be_ops;
>           break;
>       default:



  parent reply	other threads:[~2023-07-10 10:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-09  8:09 [PATCH] hw/sd/sdhci: Do not force sdhci_mmio_*_ops onto all SD controllers Bernhard Beschow
2023-07-09 16:59 ` Guenter Roeck
2023-07-10 10:16 ` Philippe Mathieu-Daudé [this message]
2023-07-10 13:44   ` Guenter Roeck
2023-07-10 16:01   ` Bernhard Beschow
2023-07-16 19:53     ` Bernhard Beschow
2023-07-24  7:18       ` Bernhard Beschow
2023-07-24 13:44         ` Guenter Roeck
2023-07-24 13:59           ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52b5a36a-5744-0ac9-a3f5-0dbd247410ed@linaro.org \
    --to=philmd@linaro.org \
    --cc=bin.meng@windriver.com \
    --cc=linux@roeck-us.net \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shentey@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).