From patchwork Tue Jun 30 10:03:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279046 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=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 F1136C433E0 for ; Tue, 30 Jun 2020 10:12:24 +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 B869D2073E for ; Tue, 30 Jun 2020 10:12:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IEKL2LMZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B869D2073E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqDFX-0001xD-Vg for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 06:12:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqD7I-0002P3-2L; Tue, 30 Jun 2020 06:03:52 -0400 Received: from mail-ej1-x643.google.com ([2a00:1450:4864:20::643]:42538) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqD7G-0004cn-D8; Tue, 30 Jun 2020 06:03:51 -0400 Received: by mail-ej1-x643.google.com with SMTP id i14so19906888ejr.9; Tue, 30 Jun 2020 03:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i3AX6k9zJcs7ntcPjDjs5EOqKiW+/SX/Gp5bwn7hkCA=; b=IEKL2LMZH0/frLWh99/3r5wwdykr2VKNm1Wa0MgHcETnX10XHnjCRRenK2whSolssw 9/LsfjZ99vJYdJ4j2n/JjD0PXoahwoljYFP0Ot9FnZVpdqIO1WkkJSZ8utwxe5hfdY1b jbPRxAjthFs/itv5YuyOc+by8mtqvOHhQ434+h8YduQ5wFHzFHml45cPH7DAYN4j02FS uNRZSmWqlB25KkLuwnXOSJv3VPnI22WV+Z0g++Ma6wOA6UJCQgNx/F5QajoNu4WmUySU zJh8XAOXdkCLFd22y0YL6Ce/aVbT/Heyi//Ro2BTKq6PiUM2BpoxJ+S6SRNrEKzr5b+Z A07w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=i3AX6k9zJcs7ntcPjDjs5EOqKiW+/SX/Gp5bwn7hkCA=; b=ZKl+IE1gVWLShQ2v/fg5WCElI378Ia7DYgtVQ39XqeKt4EamsQvk5VI9EaWGnLyLLt E0bZa9TXKy6lgNnNQkpcCqYFDr9Ht/vI036LcgoQdIaqX6hBbqCj8Dol5ejDBfGJAbjM d4V647FM74yQ/p4PRB62/uNKEDQUbcq17WIQNzzkybPEeAKJ76nH+W2lIuaILN7tPdHX ES0A9lqycBTtSPPBmL6gvW9Z0ctxGjqEZqLWSE5QYjjNsGQPbvNBwZ2ph1dy9kuK8uYk x7xvrZzI6QpWv2vX6hXqLNdGpYKPJWKFEH0zuYBx4sl5DXLs20hl4YegC/lt+O8OVEGq xclQ== X-Gm-Message-State: AOAM533gEfHU43qX4Eo0wRLQxG9Na/ukhJR2lewGMBoIM90A2i34Jrce RI0Wp8MZ6hRQO7ZNwikDPPQyvse6Yc4= X-Google-Smtp-Source: ABdhPJzHnfqUeAgd+c1AOgg8ja274FnZFBqR0ujPY7o0XxBRBrtq/1+c+OFyVIzaknIIbLth/3w4cw== X-Received: by 2002:a17:907:a92:: with SMTP id by18mr18590748ejc.116.1593511428544; Tue, 30 Jun 2020 03:03:48 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id h2sm2304697edk.54.2020.06.30.03.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 03:03:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 04/15] hw/sd/sdcard: Use the HWBLOCK_SIZE definition Date: Tue, 30 Jun 2020 12:03:31 +0200 Message-Id: <20200630100342.27625-5-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630100342.27625-1-f4bug@amsat.org> References: <20200630100342.27625-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::643; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x643.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: Peter Maydell , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Replace the following different uses of the same value by the same HWBLOCK_SIZE definition: - 512 (magic value) - 0x200 (magic value) - 1 << HWBLOCK_SHIFT Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4816b4a462..04451fdad2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -81,6 +81,7 @@ enum SDCardStates { }; #define HWBLOCK_SHIFT 9 /* 512 bytes */ +#define HWBLOCK_SIZE (1 << HWBLOCK_SHIFT) #define SECTOR_SHIFT 5 /* 16 kilobytes */ #define WPGROUP_SHIFT 7 /* 2 megs */ #define CMULT_SHIFT 9 /* 512 times HWBLOCK_SIZE */ @@ -129,7 +130,7 @@ struct SDState { uint32_t blk_written; uint64_t data_start; uint32_t data_offset; - uint8_t data[512]; + uint8_t data[HWBLOCK_SIZE]; qemu_irq readonly_cb; qemu_irq inserted_cb; QEMUTimer *ocr_power_timer; @@ -410,7 +411,7 @@ static void sd_set_csd(SDState *sd, uint64_t size) ((HWBLOCK_SHIFT << 6) & 0xc0); sd->csd[14] = 0x00; /* File format group */ } else { /* SDHC */ - size /= 512 * KiB; + size /= HWBLOCK_SIZE * KiB; size -= 1; sd->csd[0] = 0x40; sd->csd[1] = 0x0e; @@ -574,7 +575,7 @@ static void sd_reset(DeviceState *dev) sd->erase_start = 0; sd->erase_end = 0; sd->size = size; - sd->blk_len = 0x200; + sd->blk_len = HWBLOCK_SIZE; sd->pwd_len = 0; sd->expecting_acmd = false; sd->dat_lines = 0xf; @@ -685,7 +686,7 @@ static const VMStateDescription sd_vmstate = { VMSTATE_UINT32(blk_written, SDState), VMSTATE_UINT64(data_start, SDState), VMSTATE_UINT32(data_offset, SDState), - VMSTATE_UINT8_ARRAY(data, SDState, 512), + VMSTATE_UINT8_ARRAY(data, SDState, HWBLOCK_SIZE), VMSTATE_UNUSED_V(1, 512), VMSTATE_BOOL(enable, SDState), VMSTATE_END_OF_LIST() @@ -754,8 +755,8 @@ static void sd_erase(SDState *sd) if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { /* High capacity memory card: erase units are 512 byte blocks */ - erase_start *= 512; - erase_end *= 512; + erase_start *= HWBLOCK_SIZE; + erase_end *= HWBLOCK_SIZE; } erase_start = sd_addr_to_wpnum(erase_start); @@ -1149,7 +1150,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 16: /* CMD16: SET_BLOCKLEN */ switch (sd->state) { case sd_transfer_state: - if (req.arg > (1 << HWBLOCK_SHIFT)) { + if (req.arg > HWBLOCK_SIZE) { sd->card_status |= BLOCK_LEN_ERROR; } else { trace_sdcard_set_blocklen(req.arg); @@ -1961,7 +1962,7 @@ uint8_t sd_read_data(SDState *sd) if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION)) return 0x00; - io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; + io_len = (sd->ocr & (1 << 30)) ? HWBLOCK_SIZE : sd->blk_len; trace_sdcard_read_data(sd->proto_name, sd_acmd_name(sd->current_cmd), From patchwork Tue Jun 30 10:03:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279049 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=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 D6AC5C433DF for ; Tue, 30 Jun 2020 10:09:19 +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 9E4F22073E for ; Tue, 30 Jun 2020 10:09:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CZc2yj3r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E4F22073E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqDCY-00047O-Re for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 06:09:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqD7K-0002Tn-Aw; Tue, 30 Jun 2020 06:03:54 -0400 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]:37885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqD7I-0004dI-Lj; Tue, 30 Jun 2020 06:03:53 -0400 Received: by mail-ej1-x641.google.com with SMTP id lx13so1241187ejb.4; Tue, 30 Jun 2020 03:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2FehWZv489g7gLp1IpuJgAw0ELgG4HGTfqwfreEPxtg=; b=CZc2yj3rRHmUKsdZ8q5lEUQ9/BSmJRv4oTy85kFlRGlTFpmcKj7Gl9WJGTKGAKAbu0 UPrINk+k2ucWASQo6917Lqnwm2e+lsnkJkv32Fed6JfV9eJWdwivnWiihMNTn+znAteQ oITiMFz1ct6B/s4jSRyhtpRte4t5oym1sqAp0YKV0tou4BEZ3Hz0KLpb3QWzk6ExspjT CP3lIUY1p0dPiWgJgTxAt5t8g+e2+hM3lgd88vRV6W0aR/0STnI9VjTmYoFFzt5Uktja KJhnjRNEiYHSjXIdsg8YrjAfKEUmBqgarvqSICAfILK3oug6nROK4lv+xmEA5W7lR/H5 0BPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=2FehWZv489g7gLp1IpuJgAw0ELgG4HGTfqwfreEPxtg=; b=BB3LVOfSeCeadDuMTC1egTyMTALlZSl0t8gC6tjxTUNgdolkT3ibq9byRpqQD7CQwn hXKi/mHJZenPb7tnHR1Asvz2/80lInDNMhTYLOptW0gnLYz/zAn+FnCnvlBVpPo45GvF Vxh0d4IPv9JuORRcicHGCazcoTBzoMIInPXELeeXK0zljEGPuKPK1UF9Ie/zH9zjlP4A LIgL2juZ/3EKdaf3JCEAH+TZqoXMq4EtK2e7ut4S8MVNL6RD0KToY6/jej0GOMauc4IL jtvNtYSm9MT4KInyAb0T+PYIiToQpYRLoKZvonZDzA9GqaC8HvXooTpZW5Vp0NKVdD6j +Faw== X-Gm-Message-State: AOAM530jSB8PlKdLj2/TPFCea+yBfsLh9VLgneLF/03b3kyLPflX0mzE mrOOlQ4BrrIL8bICRMACoBRCoKdJmpY= X-Google-Smtp-Source: ABdhPJzCL+AIs9+afEjc2reah4gGN0cmZG8vo2l/C6RU1HKPjXu6wemJ0JbVRICYCyOpiDqf8Lf6gg== X-Received: by 2002:a17:907:1059:: with SMTP id oy25mr18817818ejb.90.1593511430847; Tue, 30 Jun 2020 03:03:50 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id h2sm2304697edk.54.2020.06.30.03.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 03:03:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 06/15] hw/sd/sdcard: Restrict Class 6 commands to SCSD cards Date: Tue, 30 Jun 2020 12:03:33 +0200 Message-Id: <20200630100342.27625-7-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630100342.27625-1-f4bug@amsat.org> References: <20200630100342.27625-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::641; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x641.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: Peter Maydell , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Only SCSD cards support Class 6 (Block Oriented Write Protection) commands. "SD Specifications Part 1 Physical Layer Simplified Spec. v3.01" 4.3.14 Command Functional Difference in Card Capacity Types * Write Protected Group SDHC and SDXC do not support write-protected groups. Issuing CMD28, CMD29 and CMD30 generates the ILLEGAL_COMMAND error. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 7e0d684aca..871c30a67f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -922,6 +922,11 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) sd->multi_blk_cnt = 0; } + if (sd_cmd_class[req.cmd] == 6 && FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { + /* Only Standard Capacity cards support class 6 commands */ + return sd_illegal; + } + switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ case 0: /* CMD0: GO_IDLE_STATE */ From patchwork Tue Jun 30 10:03:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279047 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=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 DAAB4C433DF for ; Tue, 30 Jun 2020 10:11:06 +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 A49F72073E for ; Tue, 30 Jun 2020 10:11:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D4Ior0JK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A49F72073E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqDEH-0007qa-SE for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 06:11:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqD7L-0002X9-GN; Tue, 30 Jun 2020 06:03:55 -0400 Received: from mail-ej1-x644.google.com ([2a00:1450:4864:20::644]:33017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqD7J-0004dl-PH; Tue, 30 Jun 2020 06:03:55 -0400 Received: by mail-ej1-x644.google.com with SMTP id n26so5957483ejx.0; Tue, 30 Jun 2020 03:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/hBqILuvbq8GQVmvRRiNXAXWPYKiP9RUKThJFiSA5Mw=; b=D4Ior0JKJLdE58frgVDMp4O58wPgI545KyzfaQ2SJN4DE6qxQD9Yn9rKhNMCsN5PtL BhpR3rHMIf8FeXoaBDJPINzcfastr+QCwhgJYs/ZxOV4REDl6leob4FnkfrXsfNZuLy8 GwAQPvtGpdac9F8/G+jj1ScOofZKG8MLZJG9a7BRu88d4F1MugdZ2z/N0YHm//DqTJMO 8nApzv+XKMHVY9oIWZQ+kM5FBYhjLlcnice6/wh0zVOpacBFaP62OofmJnvctpEIcA0C G4erwbGP/nfrRI3KbpbebM0vzkOLu+UuXlLOUYXTpR4D5xS0F4ArNju6plHBZQhwB2Ga IFdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=/hBqILuvbq8GQVmvRRiNXAXWPYKiP9RUKThJFiSA5Mw=; b=K07Ue4JfpzWEip9nsDHMmRBU9myraAtyC2g4euanjekLlfdPDAEXhL2mmrdezlajiy ln5GI42cBPXC7jrJOSl/nNUq3Lyc7Pr8DBMuP/EHXgkhKtLOcIvoK/7m8dqP9dRNj9hp Go5uWEW+UQRtVfp+ehK4mPSj66ye1h2RsY0qiq3fN+B1SWy79Cf5KB1Tlt9IVQx6hiTm sg/g+e/rlhgkUODzylhQp+HyDM7TVPCQ03hJT7bOx2PjwRId/B1tDNIIFHP1NucOpdIM +OGr8V+y0wnXZUlygF1uL3oLpnecVqhtjTlH2PrCU6znz6GfS/I7m4LatTRbmhqFcKuS ZDWg== X-Gm-Message-State: AOAM532fLsU5MCEmwnhmW+NkQCZ7AXVjxrPiEC4ONWRpO0DpsN3qBcvB JTOPZuJXJy0k2Upg+gcEs7NVDW80Q0Q= X-Google-Smtp-Source: ABdhPJyA1/k2iECKdcUDWrEk+iyVzPSsLrYsMW5862+Qv8L7X00qh3DqHwC8VzWm4NReEdRcRQ1aYw== X-Received: by 2002:a17:906:c943:: with SMTP id fw3mr17284014ejb.55.1593511431873; Tue, 30 Jun 2020 03:03:51 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id h2sm2304697edk.54.2020.06.30.03.03.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 03:03:51 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 07/15] hw/sd/sdcard: Initialize constant values first Date: Tue, 30 Jun 2020 12:03:34 +0200 Message-Id: <20200630100342.27625-8-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630100342.27625-1-f4bug@amsat.org> References: <20200630100342.27625-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::644; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x644.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: Peter Maydell , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reorder initialization code, constant values first. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 871c30a67f..22392e5084 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -556,22 +556,6 @@ static void sd_reset(DeviceState *dev) } size = sect << 9; - sect = sd_addr_to_wpnum(size) + 1; - - sd->state = sd_idle_state; - sd->rca = 0x0000; - sd_set_ocr(sd); - sd_set_scr(sd); - sd_set_cid(sd); - sd_set_csd(sd, size); - sd_set_cardstatus(sd); - sd_set_sdstatus(sd); - - g_free(sd->wp_groups); - sd->wp_switch = sd->blk ? blk_is_read_only(sd->blk) : false; - sd->wpgrps_size = sect; - sd->wp_groups = bitmap_new(sd->wpgrps_size); - memset(sd->function_group, 0, sizeof(sd->function_group)); sd->erase_start = 0; sd->erase_end = 0; sd->size = size; @@ -581,6 +565,22 @@ static void sd_reset(DeviceState *dev) sd->dat_lines = 0xf; sd->cmd_line = true; sd->multi_blk_cnt = 0; + sd->state = sd_idle_state; + sd->rca = 0x0000; + + sd_set_ocr(sd); + sd_set_scr(sd); + sd_set_cid(sd); + sd_set_csd(sd, size); + sd_set_cardstatus(sd); + sd_set_sdstatus(sd); + + sect = sd_addr_to_wpnum(size) + 1; + g_free(sd->wp_groups); + sd->wp_switch = sd->blk ? blk_is_read_only(sd->blk) : false; + sd->wpgrps_size = sect; + sd->wp_groups = bitmap_new(sd->wpgrps_size); + memset(sd->function_group, 0, sizeof(sd->function_group)); } static bool sd_get_inserted(SDState *sd) From patchwork Tue Jun 30 10:03:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279043 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=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 9F1F3C433DF for ; Tue, 30 Jun 2020 10:18:29 +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 680A12073E for ; Tue, 30 Jun 2020 10:18:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GIK5puHW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 680A12073E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqDLQ-0001Sf-KU for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 06:18:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqD7N-0002cx-Pa; Tue, 30 Jun 2020 06:03:57 -0400 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]:40178) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqD7M-0004fO-5k; Tue, 30 Jun 2020 06:03:57 -0400 Received: by mail-ej1-x641.google.com with SMTP id o18so15461285eje.7; Tue, 30 Jun 2020 03:03:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rpSMNc4ANWfLw4/zrjH+Quy+g4jLa++YxrzfC8zwAh8=; b=GIK5puHWMXKbQyRd3mJWceDXdlQzJMwQToYFhff5x8/05wI0MKDNwqfA50DIctuo6A rD+pm/CgxfUFHqbh7i2L2XOHGscBGIAgZYeOXWtCl9Mi1yKccFRPKiPuGSu8R9zPOz4L SxAtARY1fY/9KS1OunSAF+VW9/ar1aclji4Aj+9dwaW3DIjSMm6MDBGlDVF55nc5oVRk kNpqxo3juu56qSswh02b5GClhhE3Li51X6lsyU35MPYlQZFgurQkSdHsy8RIu4Q1tmVk 6vHbD2CUea3QocZgqui0GUNrhoh2Wra/dmIMDKm5u14S6V/VbMoJh1yh4wARodEoAjmw VXHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=rpSMNc4ANWfLw4/zrjH+Quy+g4jLa++YxrzfC8zwAh8=; b=ospbKRsYZtTnn9LQo+7VHPbpgX12p4aBw7PXn0iP7FrAWZdDBpcEFXqQjHno+yMcBQ ZLUy5fjIN9TqTeen8uQ4P73ZHoOU4LfL2k0qCPeWA7ZeJV0EPWJ5W+3bveD1faUPZTbK Vj1daIcNajJgIL0+6I7+2c5rW5Wq6KFtu4fk5Z+Rkoq8ssZzxO5PffWx+SsKR4lXxKqx Om7+r5yBJy4cWwKrmSle89qOV2EWaU2teatQ1UgLThudK/rQxjZ5I5vG9VRjTKHqkGVC x3KT75QUElDv3084FZYHQ8yAJNsgyGXivS4qNrmjdg8fxMXb50BdyUt2Ay7u5zjtuYBk 8e4w== X-Gm-Message-State: AOAM531k6sktvgciJN77GI75WMHQijmd2o/s6/BaBbEuezBXKwj4yVfH cT8etQJXQsWpWosoR7QIdnZF8wK+D64= X-Google-Smtp-Source: ABdhPJyubHHFBRyrFVYKIz3khfhcrZfhXn62qvN+OBjLe1JElmxyMapIEUTJln4LzeNkytOgtcA62g== X-Received: by 2002:a17:906:2786:: with SMTP id j6mr17236358ejc.216.1593511434449; Tue, 30 Jun 2020 03:03:54 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id h2sm2304697edk.54.2020.06.30.03.03.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 03:03:53 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 09/15] hw/sd/sdcard: Update the SDState documentation Date: Tue, 30 Jun 2020 12:03:36 +0200 Message-Id: <20200630100342.27625-10-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630100342.27625-1-f4bug@amsat.org> References: <20200630100342.27625-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::641; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x641.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: Peter Maydell , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add more descriptive comments to keep a clear separation between static property vs runtime changeable. Suggested-by: Peter Maydell Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index c6742c884d..ba4d0e0597 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -103,11 +103,14 @@ struct SDState { uint32_t card_status; uint8_t sd_status[64]; - /* Configurable properties */ + /* Static properties */ + uint8_t spec_version; BlockBackend *blk; bool spi; + /* Runtime changeables */ + uint32_t mode; /* current card mode, one of SDCardModes */ int32_t state; /* current card state, one of SDCardStates */ uint32_t vhs; From patchwork Tue Jun 30 10:03:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279045 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=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 0FE32C433DF for ; Tue, 30 Jun 2020 10:14:31 +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 CB0BE2073E for ; Tue, 30 Jun 2020 10:14:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L/QBaD4b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB0BE2073E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqDHa-0004g2-4R for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 06:14:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqD7Q-0002j4-E0; Tue, 30 Jun 2020 06:04:00 -0400 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]:40861) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqD7O-0004gw-Hp; Tue, 30 Jun 2020 06:04:00 -0400 Received: by mail-ed1-x541.google.com with SMTP id b15so15592149edy.7; Tue, 30 Jun 2020 03:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2ZlGPgi7od1igTsibD2VHPnVNk265O0B7uO3V2hd4Vk=; b=L/QBaD4bTUY7TmvoRIw9n7fcQ0OJezIYkC/ZEMJ2WNbCWRcu+XOCi41AZ7Bs4Itnpl mMk6jv6sKGqLPt0dI89uMkeEACNiA4FMzd0IgagLDpXT4Xcgc0Z2gXQkJspoywR/G4d0 X5vSyJYxlW3/L33dNsgYvO2aDBOZYcxA7miTGEwgWICQZEs5l0+x+C2CpF/9zq5IvEOh ZQw6qVvhjjeW2KSdH7zGGdk5dAvs5LT2wK95dLqGm/QL980xO3F5KJ9vNskeOk/MmBS+ bFhiv0JvYvXi+ECqkPn+3bVnH1EMPuMaij9XUSjPHaV9FtPBuoz52ybJwfkTVLT95Chx V9qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=2ZlGPgi7od1igTsibD2VHPnVNk265O0B7uO3V2hd4Vk=; b=twc+VoTXFfNgfJCZFu8HWAeXU/12o85Vy+S5tMl61f8Uz4x/SRvwPn4ibNBgZvnqpL y9nN26CNM9UMJTTG/sJ0N5zBLGTri5FBrXbmmKiC+MiWi254VhDfvmxNFrqQqOeJqjnb p21egZJLeiZGyCSj1v5E5oQJ5znHPLMR6Vj+TTCMeyXoGpA9Q4rqRsJH1cTL44aklfMA V+MOBSo/Qt68QX3qVrCRjqAjjomEoqhsbIHgw60nkHwylIh0qL6PtUPmkgyxka8VjTqT HB1QquZ3dSUUfzoGBnZ2+OQEleltcqk0orBiLQpddZtlHmN46yX+D66eFiyy7WTTK12X FUBQ== X-Gm-Message-State: AOAM5330XKrxqW7ZUkJldCUNN+uDFl8bbEejpdROUdAcCN70O9+ztKOe lJmvuwXUzhoAfxsCcn8+0D5EbqawqHo= X-Google-Smtp-Source: ABdhPJxp0b7NNidoORXjX8MN+PbkzwU5/dXUGSNc4uUDmIhnKJhW6k8nYj7GHgpAORo9Q6PcJI13Sg== X-Received: by 2002:a50:bb48:: with SMTP id y66mr18948579ede.147.1593511436570; Tue, 30 Jun 2020 03:03:56 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id h2sm2304697edk.54.2020.06.30.03.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 03:03:56 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 11/15] hw/sd/sdcard: Constify sd_crc*()'s message argument Date: Tue, 30 Jun 2020 12:03:38 +0200 Message-Id: <20200630100342.27625-12-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630100342.27625-1-f4bug@amsat.org> References: <20200630100342.27625-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::541; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-x541.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: Peter Maydell , Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" CRC functions don't modify the buffer argument, make it const. Reviewed-by: Alistair Francis Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0fd672357c..2238ba066d 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -255,11 +255,11 @@ static const int sd_cmd_class[SDMMC_CMD_MAX] = { 7, 7, 10, 7, 9, 9, 9, 8, 8, 10, 8, 8, 8, 8, 8, 8, }; -static uint8_t sd_crc7(void *message, size_t width) +static uint8_t sd_crc7(const void *message, size_t width) { int i, bit; uint8_t shift_reg = 0x00; - uint8_t *msg = (uint8_t *) message; + const uint8_t *msg = (const uint8_t *)message; for (i = 0; i < width; i ++, msg ++) for (bit = 7; bit >= 0; bit --) { @@ -271,11 +271,11 @@ static uint8_t sd_crc7(void *message, size_t width) return shift_reg; } -static uint16_t sd_crc16(void *message, size_t width) +static uint16_t sd_crc16(const void *message, size_t width) { int i, bit; uint16_t shift_reg = 0x0000; - uint16_t *msg = (uint16_t *) message; + const uint16_t *msg = (const uint16_t *)message; width <<= 1; for (i = 0; i < width; i ++, msg ++) From patchwork Tue Jun 30 10:03:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279042 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=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT 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 A7B11C433DF for ; Tue, 30 Jun 2020 10:19:51 +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 6F66F20760 for ; Tue, 30 Jun 2020 10:19:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GG84reCw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F66F20760 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqDMk-0003Q2-O7 for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 06:19:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqD7R-0002kH-CW; Tue, 30 Jun 2020 06:04:02 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:46802) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqD7P-0004hB-Ji; Tue, 30 Jun 2020 06:04:01 -0400 Received: by mail-ej1-x62d.google.com with SMTP id p20so19862916ejd.13; Tue, 30 Jun 2020 03:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zGHpga6H2Rh60b+shqZXMAR/68CCrter5/aFoJNoNjw=; b=GG84reCwLGmxirJzTSDZ1TKY//DM9x7P0UHiGXRCZc5yE7j5u0qqXLdru62rlGqm6x HXPWnek0NfZmiXu4OwwOJWit0/NACsqMSBaKiplcy4+pI58GKMid5CZ+VHWMNlwdYClc gkYPgDMCXZWuBy9tHxhVzTs17TjVcDxzE2jMNEMzIOBp0phSX8Ayvq6+ID176zcY+eIF Kc92Gf+eqm8XWF4/xEZZfIUzLx/P+piu0Hv1OVrCrhY3FpREj8/IDXykRbT6qKFX2TzF x37xSKRAEM6EyjKTGcdC+9UVXVuvnQIVHW9mjcPTI5BrQHRAHAih8sjxOVvhL3RbOGNe 2m4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=zGHpga6H2Rh60b+shqZXMAR/68CCrter5/aFoJNoNjw=; b=bAg9eK2diTJSReP0DcAUjkEVUVxES96JzBP+LdK2CFVIMF88M+Zak4l1SRO132P7jj iK/hESwkfCHkLKrEN8yaJyiJhRn9P0nRDUK3Vf9EMHyGf7EpVDfybvW/mUvpQ0roWefo qWEQBgI4ZUh90bK/H7eB4zbtV7au633K41meOM7qnNPmMlru/es5LGcTLY08FqT82Br+ tlAEsAnGYHc6Iw8yy5ULLU2z1V6ksExiELQCoxF4yb2bjS4epeg9zbHjlknoGnAx0J9N XMxlpJtsZw8PBxts2d3ySSwd2c9n9iIHYM+NSLiAepCiNQf4cXvidupg/KKztfC6XXvX kxqg== X-Gm-Message-State: AOAM533LASxCfDu67X09CgqmraCHq7mWaW8MRJRyRh+xHY6kYdJfVcA3 3N5yy8qYn7icZhr3DKLfN71Mgs17+28= X-Google-Smtp-Source: ABdhPJy7f71t6+HMDAMJQupy69MxORznFBGbe62ASB8xFozccU9HcUc5dIrRLS3l+iKH/KjE1J1AtA== X-Received: by 2002:a17:907:4240:: with SMTP id oi24mr17051034ejb.23.1593511437547; Tue, 30 Jun 2020 03:03:57 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id h2sm2304697edk.54.2020.06.30.03.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 03:03:57 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 12/15] hw/sd/sdcard: Make iolen unsigned Date: Tue, 30 Jun 2020 12:03:39 +0200 Message-Id: <20200630100342.27625-13-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630100342.27625-1-f4bug@amsat.org> References: <20200630100342.27625-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x62d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: Peter Maydell , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé I/O request length can not be negative. Signed-off-by: Philippe Mathieu-Daudé --- v4: Use uint32_t (pm215) --- hw/sd/sd.c | 2 +- hw/sd/trace-events | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2238ba066d..504228198e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1967,7 +1967,7 @@ uint8_t sd_read_data(SDState *sd) { /* TODO: Append CRCs */ uint8_t ret; - int io_len; + uint32_t io_len; if (!sd->blk || !blk_is_inserted(sd->blk) || !sd->enable) return 0x00; diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 5f09d32eb2..d0cd7c6ec4 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -52,7 +52,7 @@ sdcard_unlock(void) "" sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint8_t value) "%s %20s/ CMD%02d value 0x%02x" -sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, int length) "%s %20s/ CMD%02d len %d" +sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t length) "%s %20s/ CMD%02d len %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" # milkymist-memcard.c From patchwork Tue Jun 30 10:03:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279044 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=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 CD5BBC433E0 for ; Tue, 30 Jun 2020 10:16:03 +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 95E9020760 for ; Tue, 30 Jun 2020 10:16:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QWiXplJb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95E9020760 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqDJ4-0006YS-No for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 06:16:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqD7S-0002kL-3Z; Tue, 30 Jun 2020 06:04:02 -0400 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]:34124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqD7Q-0004iW-Ht; Tue, 30 Jun 2020 06:04:01 -0400 Received: by mail-ed1-x543.google.com with SMTP id a8so14393323edy.1; Tue, 30 Jun 2020 03:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z/EZxVt2E3A6jt6L/KxP/rTE9weJvxlOwG4iw6dyfbk=; b=QWiXplJbI/URaKRP9pw689O73qPEwYUGPfAMXoorVNbDHe6LogbMgQKGEd6n2/zhQf adw6jFT6dsSORXyJgAkxKVFzAqEK9pxPUXC4eX9PIon8qlBnwsLknBu/Gj/hKwNjfySl F2HV6quoAgXKnXlmmLwTAQdpAAgtNeHHe1/IbQJBSO30ZVbXcYbSw24EWDaQdd4ZoeYz Q6BxPDsLdtN9HmDsNIF//MNdDXbWlFwfpZ5WKv2pXvZ2j261REr51zHmOFCT7vNEc4Pp Nw53tYjBgYy6PtZo2/x+KDu5Wh9J4tRhwcRkvU81rhqGypJyoWBDKornMUVrFL6vC4bp lojA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Z/EZxVt2E3A6jt6L/KxP/rTE9weJvxlOwG4iw6dyfbk=; b=FbIm7C1EnjqiEvekqrXc+8WT15MhoSCwS/Gr7swfIcOpYB2y89zFCW25LO6C7nxvrK jmgCZQ0kSkEWnAXeJVDcqoiDgJdADqfXUwfB2FdGsDzEtxO02rgStIYa2hO8d1tFEoQK n/GkFDDhGs4FT07Xl6iOt449Cg19DeXm8Bvee55u28lPK4lkQyyxI9IbPsRgWsljAh6B qimeaqi9AHAhqIJer87avL472+R53kw9qSvb2jiZyWcqrGyZaEBJAZVGoxwNhpq6cBxU uZL4jNLZgLWYybAWoO4oUja3B4my8UVi4PhkFwm6Yx39v0TxsIb5sg7wcwTD4SkUmHOM b5QA== X-Gm-Message-State: AOAM531js5unr9qSqNX+zJKx4LJJOePZXBdFx2ztstUjXS8kb+3sDYtK ZyPK+iTrVzj1ZB+pieZYGVlRZrxqeHk= X-Google-Smtp-Source: ABdhPJzVmMIxh8hIO0/AJBnb8fF4vHAWlEcO0TpZSx9IJvmFmFFAE75BNE9ZonaLMMObgsxKNpBOgA== X-Received: by 2002:a50:ee07:: with SMTP id g7mr6485568eds.320.1593511438592; Tue, 30 Jun 2020 03:03:58 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id h2sm2304697edk.54.2020.06.30.03.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 03:03:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 13/15] hw/sd/sdcard: Correctly display the command name in trace events Date: Tue, 30 Jun 2020 12:03:40 +0200 Message-Id: <20200630100342.27625-14-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630100342.27625-1-f4bug@amsat.org> References: <20200630100342.27625-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::543; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-x543.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: Peter Maydell , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Some ACMD were incorrectly displayed. Fix by remembering if we are processing a ACMD (with current_cmd_is_acmd) and add the sd_current_cmd_name() helper, which display to correct name regardless it is a CMD or ACMD. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 504228198e..de194841a7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -125,6 +125,7 @@ struct SDState { uint8_t pwd[16]; uint32_t pwd_len; uint8_t function_group[6]; + bool current_cmd_is_acmd; uint8_t current_cmd; /* True if we will handle the next command as an ACMD. Note that this does * *not* track the APP_CMD status bit! @@ -1704,6 +1705,8 @@ int sd_do_command(SDState *sd, SDRequest *req, req->cmd); req->cmd &= 0x3f; } + sd->current_cmd = req->cmd; + sd->current_cmd_is_acmd = sd->expecting_acmd; if (sd->card_status & CARD_IS_LOCKED) { if (!cmd_valid_while_locked(sd, req->cmd)) { @@ -1731,7 +1734,6 @@ int sd_do_command(SDState *sd, SDRequest *req, /* Valid command, we can update the 'state before command' bits. * (Do this now so they appear in r1 responses.) */ - sd->current_cmd = req->cmd; sd->card_status &= ~CURRENT_STATE; sd->card_status |= (last_state << 9); } @@ -1792,6 +1794,15 @@ send_response: return rsplen; } +static const char *sd_current_cmd_name(SDState *sd) +{ + if (sd->current_cmd_is_acmd) { + return sd_acmd_name(sd->current_cmd); + } else { + return sd_cmd_name(sd->current_cmd); + } +} + static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len) { trace_sdcard_read_block(addr, len); @@ -1830,7 +1841,7 @@ void sd_write_data(SDState *sd, uint8_t value) return; trace_sdcard_write_data(sd->proto_name, - sd_acmd_name(sd->current_cmd), + sd_current_cmd_name(sd), sd->current_cmd, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ @@ -1984,7 +1995,7 @@ uint8_t sd_read_data(SDState *sd) io_len = (sd->ocr & (1 << 30)) ? HWBLOCK_SIZE : sd->blk_len; trace_sdcard_read_data(sd->proto_name, - sd_acmd_name(sd->current_cmd), + sd_current_cmd_name(sd), sd->current_cmd, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ From patchwork Tue Jun 30 10:03:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 279041 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=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 75582C433E0 for ; Tue, 30 Jun 2020 10:21:36 +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 3D97820760 for ; Tue, 30 Jun 2020 10:21:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="opem8ZSb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D97820760 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqDOR-0005hc-I1 for qemu-devel@archiver.kernel.org; Tue, 30 Jun 2020 06:21:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqD7W-0002pJ-HS; Tue, 30 Jun 2020 06:04:06 -0400 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]:33016) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqD7R-0004il-Ay; Tue, 30 Jun 2020 06:04:06 -0400 Received: by mail-ej1-x641.google.com with SMTP id n26so5957808ejx.0; Tue, 30 Jun 2020 03:04:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JRZNazdov+ee3WL2ncAzmR+/lQC5nrG6ZQMKrWySSrg=; b=opem8ZSbKmF91giGiCi7MDWnSBjvr5NhKBZu3dLGJzSwKth19+fxzUM8nxyNaKhDka 3kSw3F0+hxAvBEKoxBvlSXb6HuYPQQHmji0/+ISPKYQIS5mzO8qkqLFHNoGMA4mxyeHQ ZTi9uT3tcgfmyl4LVHZOjVnDMRJbwr/a8w1aMojJqNn+0eddxeuViqVeE+bXXgd7atYO s6f6akl9r+xOJMUP8XI3EM2jMv6VEiIZAY0jWyEJd4g8F87Z+EoMenWZl+BiA84LoLY1 92j4C/3EVaBZ2hHM0xHPxwWUqdg3CdDiXa9ZTtFsIWyhpTuwzxXaAQLoUNXzWdf1IDyR zrdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=JRZNazdov+ee3WL2ncAzmR+/lQC5nrG6ZQMKrWySSrg=; b=PpZRkjMxhD9j2S5tt9Q2aMSXDJ6UkjK70VhbRnrZQNDHSxUQsGoOImMV6G9P2Fh3rQ y2yvIbYMJ9xnmhj0KB+zSl8Gcf22ENdrA3Edke0A4H1UXoOnAwEaXntFUWQnVrx6sih+ Fwb8zBLsgt9olcoZX2KEfzZxXsd7EnSskLIgjKTaOpeUREdCee8zD+UZw54TZPWi5ujf nU68lk9IsEyqPJlgbGY2+vmOmgIDyaTN43G/Of6zVjiDzfpV54iQG1/5oRJBNdYFhogv LT0PIvllUQcMNec5DVEscqYW1BkEs3IlBiVSSfPPNH1+G1zAKxfp/V9WRk/feyvzYB75 pwXw== X-Gm-Message-State: AOAM5301EGlL3RpybjvDthSRvDpKvhPKn6Uf931CFfXWnSIKLxz1R16g ejUyGqVYULCoAoFmjRiPe0FFdVm7x8E= X-Google-Smtp-Source: ABdhPJwmYGAmIHsHUQXZQT2Ou3B9aIXP3KImTenN0WBqFnhgt3Z+6Iog1FuicQOK6txP6o1JxsCX4w== X-Received: by 2002:a17:907:7294:: with SMTP id dt20mr17178564ejc.355.1593511439610; Tue, 30 Jun 2020 03:03:59 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id h2sm2304697edk.54.2020.06.30.03.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 03:03:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 14/15] hw/sd/sdcard: Display offset in read/write_data() trace events Date: Tue, 30 Jun 2020 12:03:41 +0200 Message-Id: <20200630100342.27625-15-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200630100342.27625-1-f4bug@amsat.org> References: <20200630100342.27625-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::641; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x641.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: Peter Maydell , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Having 'base address' and 'relative offset' displayed separately is more helpful than the absolute address. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 8 ++++---- hw/sd/trace-events | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index de194841a7..7f973f6763 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1841,8 +1841,8 @@ void sd_write_data(SDState *sd, uint8_t value) return; trace_sdcard_write_data(sd->proto_name, - sd_current_cmd_name(sd), - sd->current_cmd, value); + sd_current_cmd_name(sd), sd->current_cmd, + sd->data_start, sd->data_offset, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ sd->data[sd->data_offset ++] = value; @@ -1995,8 +1995,8 @@ uint8_t sd_read_data(SDState *sd) io_len = (sd->ocr & (1 << 30)) ? HWBLOCK_SIZE : sd->blk_len; trace_sdcard_read_data(sd->proto_name, - sd_current_cmd_name(sd), - sd->current_cmd, io_len); + sd_current_cmd_name(sd), sd->current_cmd, + sd->data_start, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ ret = sd->data[sd->data_offset ++]; diff --git a/hw/sd/trace-events b/hw/sd/trace-events index d0cd7c6ec4..946923223b 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -51,8 +51,8 @@ sdcard_lock(void) "" sdcard_unlock(void) "" sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" -sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint8_t value) "%s %20s/ CMD%02d value 0x%02x" -sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t length) "%s %20s/ CMD%02d len %" PRIu32 +sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint64_t address, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d addr 0x%" PRIx64 " ofs 0x%" PRIx32 " val 0x%02x" +sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint64_t address, uint32_t offset, uint32_t length) "%s %20s/ CMD%02d addr 0x%" PRIx64 " ofs 0x%" PRIx32 " len %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" # milkymist-memcard.c