From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCC3EC433E0 for ; Sat, 2 Jan 2021 14:29:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 63D3022482 for ; Sat, 2 Jan 2021 14:29:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63D3022482 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kvhuX-0007oD-Fr for qemu-devel@archiver.kernel.org; Sat, 02 Jan 2021 09:29:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvhLK-00018T-DH for qemu-devel@nongnu.org; Sat, 02 Jan 2021 08:53:18 -0500 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]:45525) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kvhLH-0004BO-On for qemu-devel@nongnu.org; Sat, 02 Jan 2021 08:53:18 -0500 Received: by mail-ej1-x631.google.com with SMTP id qw4so30497727ejb.12 for ; Sat, 02 Jan 2021 05:53:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4h4CzpHASV+CdAekwQaUgBD7hx+1FXnti+a1XA5oAJU=; b=PRZW2wqpX7MoSBdUIhJQvz1yRCMUhRDE6Fp8iwJ6pLnyrbeFacI5+3y6x950tlDceD 2pT/qJsMbQGDNqoP8pZIyn/bbHG4F+SECV0Rx8nsekGDkjr6sJ3HXmNgOEYdZLLgttCE o6jokymiNi4zmboHPROXGTra1BykOrbznhb/uxxKUZaC3ZfDzpTu3A8Ebn8gjZQesRXc qH7k7s/Xk5o8tbjVqA10GgqToHkDZZ/+kQBpxeEJZxbxTZUfTN9XG3nYhi7k1SUHoJw2 Fvxh/KlWY0qG3NY2E+E5HHCz0JCtsnSAUm4bCnpMhPyeSyO7PWUhG9B30vJcwd3BWXJ5 Y5rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4h4CzpHASV+CdAekwQaUgBD7hx+1FXnti+a1XA5oAJU=; b=X3MR7dAPQEg3dcs6W7m9SyGRyTC0T6Ysx7UuYF1xgV9suzx/1zzf55WNnLxHxnZVcO iIjTT+qr9MzrQpJaTwzQboEPfMWUGqNwBnKucbmPfe5P45WrlB8BjPp/ZaaKlFcFFk2g RSTdgZzYkcPSzcqsr0chQzpnutAkfNxD4qEUN+w0Sko+388uSNu5+JXlRvJffSSfOdf9 JffiZmzpnkIS8Um+zFWPRlhQxtlBdQhGC7KHdtUwXJOXF5Qk+20pcW5ZCZ+x0JMfpZz1 JkyDxlUeAg8bmpuni2dBrrnQbTOAiaDgH+k+79yYKp2MYYDng+yIJIjOcl2CSHk/qMs7 PyBg== X-Gm-Message-State: AOAM532/iE2sXhvI0QA9aeXmuoi/Cve0g94hkLuoVbgnt7bl2aPshZU4 9jYzTCDQAvSs8vhkhVgnRccDDH7ZFfAosopyZaVm9w== X-Google-Smtp-Source: ABdhPJzIEytmZQxMuyrWUWYZ0gs48Wzh4UPMDH7wzPi02jHynq4gEVF/ktXcp2sW0bP5uXbhchFodoUT2yhBS2n5V4w= X-Received: by 2002:a17:906:9888:: with SMTP id zc8mr58998283ejb.42.1609595594188; Sat, 02 Jan 2021 05:53:14 -0800 (PST) MIME-Version: 1.0 References: <20201231113010.27108-1-bmeng.cn@gmail.com> <20201231113010.27108-6-bmeng.cn@gmail.com> In-Reply-To: <20201231113010.27108-6-bmeng.cn@gmail.com> From: Pragnesh Patel Date: Sat, 2 Jan 2021 19:23:02 +0530 Message-ID: Subject: Re: [PATCH 05/22] hw/sd: sd: Drop sd_crc16() To: Bin Meng Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=pragnesh.patel@sifive.com; helo=mail-ej1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 02 Jan 2021 09:24:39 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:RISC-V" , Qemu-block , Bin Meng , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , "qemu-devel@nongnu.org Developers" , Alistair Francis Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Thu, Dec 31, 2020 at 5:04 PM Bin Meng wrote: > > From: Bin Meng > > 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 exisitng 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 > transfered outside the sd core, as in sd_read_byte() we see: > > if (sd->data_offset >= 64) > sd->state = sd_transfer_state; > > Given above reaons, let's drop it. > > Signed-off-by: Bin Meng > --- > > hw/sd/sd.c | 18 ------------------ > 1 file changed, 18 deletions(-) Reviewed-by: Pragnesh Patel Tested-by: Pragnesh Patel From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kvhLL-00018g-ME for mharc-qemu-riscv@gnu.org; Sat, 02 Jan 2021 08:53:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvhLJ-00018M-N1 for qemu-riscv@nongnu.org; Sat, 02 Jan 2021 08:53:17 -0500 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]:43500) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kvhLH-0004BQ-OC for qemu-riscv@nongnu.org; Sat, 02 Jan 2021 08:53:17 -0500 Received: by mail-ej1-x62a.google.com with SMTP id jx16so30483879ejb.10 for ; Sat, 02 Jan 2021 05:53:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4h4CzpHASV+CdAekwQaUgBD7hx+1FXnti+a1XA5oAJU=; b=PRZW2wqpX7MoSBdUIhJQvz1yRCMUhRDE6Fp8iwJ6pLnyrbeFacI5+3y6x950tlDceD 2pT/qJsMbQGDNqoP8pZIyn/bbHG4F+SECV0Rx8nsekGDkjr6sJ3HXmNgOEYdZLLgttCE o6jokymiNi4zmboHPROXGTra1BykOrbznhb/uxxKUZaC3ZfDzpTu3A8Ebn8gjZQesRXc qH7k7s/Xk5o8tbjVqA10GgqToHkDZZ/+kQBpxeEJZxbxTZUfTN9XG3nYhi7k1SUHoJw2 Fvxh/KlWY0qG3NY2E+E5HHCz0JCtsnSAUm4bCnpMhPyeSyO7PWUhG9B30vJcwd3BWXJ5 Y5rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4h4CzpHASV+CdAekwQaUgBD7hx+1FXnti+a1XA5oAJU=; b=DAyvCpgOqt7zUmHJ4Wfgk3pz+GpI+7Tp7nVkH1Zwx/BxCimJE0iTnQeLO0ik+++Wte ByrUlq1HPw5mrrk5iz2v6P3bD+sOrOA7ZGok0V3mYS0WtGrvuhdeogrrYilW981zJkAz fGakZjQdiVpVhbiZ7GF7Ajzd3R9zLSmjJlcPdmzDsVpseJaqpBLj807rCQ2xvkPtvf5A efkFw8c/jDervqrK7chJtnnSjStxqjhf6U4iPKeKNXct9liCwR6zfCVQVHiSp1njLhzJ WFl5nKWpbn6oA+sNf8fCTxPh6UUXORMlpCqOA0SgiC+UisQjsl5pLi1vxwwf2N3ylMlS Amuw== X-Gm-Message-State: AOAM533UuCXeSoC/YgA+85tlavJJZHqdAaHvLeI/dyEFokSxX80wN5vX vEjNw9JN6fa5NXBg0vsKUtwsHYpLNlTs6uSFra2SMw== X-Google-Smtp-Source: ABdhPJzIEytmZQxMuyrWUWYZ0gs48Wzh4UPMDH7wzPi02jHynq4gEVF/ktXcp2sW0bP5uXbhchFodoUT2yhBS2n5V4w= X-Received: by 2002:a17:906:9888:: with SMTP id zc8mr58998283ejb.42.1609595594188; Sat, 02 Jan 2021 05:53:14 -0800 (PST) MIME-Version: 1.0 References: <20201231113010.27108-1-bmeng.cn@gmail.com> <20201231113010.27108-6-bmeng.cn@gmail.com> In-Reply-To: <20201231113010.27108-6-bmeng.cn@gmail.com> From: Pragnesh Patel Date: Sat, 2 Jan 2021 19:23:02 +0530 Message-ID: Subject: Re: [PATCH 05/22] hw/sd: sd: Drop sd_crc16() To: Bin Meng Cc: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , Alistair Francis , Qemu-block , "open list:RISC-V" , "qemu-devel@nongnu.org Developers" , Bin Meng Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=pragnesh.patel@sifive.com; helo=mail-ej1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-riscv@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Jan 2021 13:53:17 -0000 On Thu, Dec 31, 2020 at 5:04 PM Bin Meng wrote: > > From: Bin Meng > > 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 exisitng 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 > transfered outside the sd core, as in sd_read_byte() we see: > > if (sd->data_offset >= 64) > sd->state = sd_transfer_state; > > Given above reaons, let's drop it. > > Signed-off-by: Bin Meng > --- > > hw/sd/sd.c | 18 ------------------ > 1 file changed, 18 deletions(-) Reviewed-by: Pragnesh Patel Tested-by: Pragnesh Patel