qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé via" <qemu-devel@nongnu.org>
To: Lu Gao <lu.gao@verisilicon.com>, qemu-devel@nongnu.org
Cc: Jianxian Wen <jianxian.wen@verisilicon.com>,
	Bin Meng <bin.meng@windriver.com>,
	"open list:SD (Secure Card)" <qemu-block@nongnu.org>,
	Alexander Bulekov <alxndr@bu.edu>,
	Prasad J Pandit <pjp@fedoraproject.org>
Subject: Re: [PATCH] hw/sd/sdhci: Block Size Register bits [14:12] is lost
Date: Tue, 31 May 2022 12:08:39 +0200	[thread overview]
Message-ID: <f15d8c9a-2a6f-1126-785f-0176eb78c3ec@amsat.org> (raw)
In-Reply-To: <20220321055618.4026-1-lu.gao@verisilicon.com>

On 21/3/22 06:56, Lu Gao wrote:
> 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")

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> Signed-off-by: Lu Gao <lu.gao@verisilicon.com>
> Signed-off-by: Jianxian Wen <jianxian.wen@verisilicon.com>
> ---
>   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 e0bbc90344..350ceb487d 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)
> @@ -1137,7 +1139,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);
> @@ -1151,7 +1154,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 */



  parent reply	other threads:[~2022-05-31 10:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21  5:56 [PATCH] hw/sd/sdhci: Block Size Register bits [14:12] is lost Lu Gao
2022-04-25  1:34 ` 答复: " Gao, Lu
2022-05-10  2:38 ` Gao, Lu
2022-05-31 10:08 ` Philippe Mathieu-Daudé via [this message]
2022-12-22  8:54   ` Gao, Lu
2023-09-22 10:29     ` 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=f15d8c9a-2a6f-1126-785f-0176eb78c3ec@amsat.org \
    --to=qemu-devel@nongnu.org \
    --cc=alxndr@bu.edu \
    --cc=bin.meng@windriver.com \
    --cc=f4bug@amsat.org \
    --cc=jianxian.wen@verisilicon.com \
    --cc=lu.gao@verisilicon.com \
    --cc=pjp@fedoraproject.org \
    --cc=qemu-block@nongnu.org \
    /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).