[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 05/25] hw/sd: sd: Drop sd_crc16()
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH v2 05/25] hw/sd: sd: Drop sd_crc16() |
Date: |
Sun, 24 Jan 2021 19:14:08 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 |
On 1/23/21 11:39 AM, Bin Meng wrote:
> From: Bin Meng <bin.meng@windriver.com>
>
> commit f6fb1f9b319f ("sdcard: Correct CRC16 offset in sd_function_switch()")
> changed the 16-bit CRC to be stored at offset 64. In fact, this CRC
> calculation is completely wrong. From the original codes, it wants
> to calculate the CRC16 of the first 64 bytes of sd->data[], however
> passing 64 as the `width` to sd_crc16() actually counts 256 bytes
> starting from the `message` for the CRC16 calculation, which is not
> what we want.
>
> Besides that, it seems existing sd_crc16() algorithm does not match
> the SD spec, which says CRC16 is the CCITT one but the calculation
> does not produce expected result. It turns out the CRC16 was never
> transferred outside the sd core, as in sd_read_byte() we see:
>
> if (sd->data_offset >= 64)
> sd->state = sd_transfer_state;
>
> Given above reasons, let's drop it.
>
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> Reviewed-by: Pragnesh Patel <pragnesh.patel@sifive.com>
> Tested-by: Pragnesh Patel <pragnesh.patel@sifive.com>
>
> ---
>
> Changes in v2:
> - Fix several typos in the commit message
>
> hw/sd/sd.c | 18 ------------------
> 1 file changed, 18 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
- [PATCH v2 00/25] hw/riscv: sifive_u: Add missing SPI support, Bin Meng, 2021/01/23
- [PATCH v2 02/25] hw/block: m25p80: Add various ISSI flash information, Bin Meng, 2021/01/23
- [PATCH v2 01/25] hw/block: m25p80: Add ISSI SPI flash support, Bin Meng, 2021/01/23
- [PATCH v2 03/25] hw/sd: ssi-sd: Fix incorrect card response sequence, Bin Meng, 2021/01/23
- [PATCH v2 04/25] hw/sd: sd: Support CMD59 for SPI mode, Bin Meng, 2021/01/23
- [PATCH v2 07/25] hw/sd: ssi-sd: Suffix a data block with CRC16, Bin Meng, 2021/01/23
- [PATCH v2 05/25] hw/sd: sd: Drop sd_crc16(), Bin Meng, 2021/01/23
- Re: [PATCH v2 05/25] hw/sd: sd: Drop sd_crc16(),
Philippe Mathieu-Daudé <=
- [PATCH v2 06/25] util: Add CRC16 (CCITT) calculation routines, Bin Meng, 2021/01/23
[PATCH v2 12/25] hw/sd: sd: Remove duplicated codes in single/multiple block read/write, Bin Meng, 2021/01/23
[PATCH v2 09/25] hw/sd: ssi-sd: Fix the wrong command index for STOP_TRANSMISSION, Bin Meng, 2021/01/23