From patchwork Thu Jun 27 16:22:18 2024 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: 807810 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp889079wrn; Thu, 27 Jun 2024 09:24:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUOxKxc3A+uC7oPh4bpko0oV/Q/a3zN3bbQYJt0iMlCpcLO0Y7V8do8ztySzu4OhIwQPBkfDEZnYnoxCUSYjJfv X-Google-Smtp-Source: AGHT+IHDLhbyvsu/g4mrjLhF6ckR1CcCDTtuIAW79QazieX559XGq3Mz4OD7n+uLI+ElJC5Xk/ld X-Received: by 2002:a9d:5d08:0:b0:6f9:6809:89ea with SMTP id 46e09a7af769-700b12a894amr14584104a34.33.1719505447059; Thu, 27 Jun 2024 09:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505447; cv=none; d=google.com; s=arc-20160816; b=JGAKSs7G3fctRW9o+m2tp/ubKI7zVo3db2scs0NCeB75grqZIcpOaUZzU7LMjyccA5 ObSCIvCgBDVGRMZqM8ltGGKANJQUCHWMpvxN5iRm7q35xiSQMykmJVI6+rxW9mAabJ30 CxXH17fN5gJEV3ZbP7ogJIO4jVRTa2fHfTPhzfYmMZsuP0TIDvuI88oMtQDexAZD123y 1dr8bxFPJ9hHAhG8JvpAgj/xwZxtDuCXM3DyYHybrtt545kWsFEd14MsZeaPfbh2/v1a H0IjlO2I4nzqhwD1ad/SOOuQKP9B6jA23R1sV6w/dMAHcYJxpOKzBCFgEeImNTXX6x9Z EP6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IJEAX/bFYJE8abBHAC9lGeH6fM4rczNBP33ZEV8FrPw=; fh=J5ku+V592sifDRR0DP/LvVzC5VDqkDqR46Xlv8eA1xM=; b=dwcHFpsBE4kWh8UBLGpBKBFRZsoWlZnoCaaRHcDJisMgjgJQcg5QFUm0BpU9iRZS+F HUFt9KZ2fIX2QB3neDkDic7TIUa0FRX1lT5umBf5KRApLDnRQEjofB2lq2SlAXOZcRaf lr+UbH+dxh3WEWCf+DgCwq6MZyL1BfUIvrv5MEwrERF1feNsBsGs9LFP8jbAHlv+zO8q vpbe1RFkDkjpTfieiWt7+r1Jl6xilf3MhkoSptR8EZN3xHCw5XYCuycjgv+dwraDWygi 4ooyQHka+QVrrUBgDiYn3K6CfV0SHyaozSiX4eLSb8VRLIGAezVY62+TXnkdyJacOdb4 6G+g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HKHgSLE5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79d5c8b6944si170465185a.504.2024.06.27.09.24.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:24:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HKHgSLE5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMruH-0003tF-4r; Thu, 27 Jun 2024 12:23:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMruF-0003qv-Hq for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:23:31 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMru9-0007AY-4Z for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:23:31 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3629c517da9so7755826f8f.2 for ; Thu, 27 Jun 2024 09:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505403; x=1720110203; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IJEAX/bFYJE8abBHAC9lGeH6fM4rczNBP33ZEV8FrPw=; b=HKHgSLE5di/lsR19Ec7CadJ/rJa4SR72gUJQL3HFUqf7I+uUTofN9aeFlWjVYpV61s l9YlJnQ8gD0+6N1GhY3m1RK5642WeAy039xzjtPeJ1j7cqEw7BLuCOF0FDYjRhyehxxB 5KUf52zyoJIcZPpE+BSNQBrAS7pzq/2FOn3x0uiiyfTYjBHs3aWpl1RtOi9IPsKvXOnl m8X9ndjuBSDgdJY6cm014y0uT4DnnPTTA7VwPwRalcefQjRXwv2c8GsuzfrDxHaB4i51 qTmDIQIFpwpTYV64aFpwOyACRURJcXK8jWg9YOLiGcCCgvfKM+3YjRbF94rZQpUb0fT2 K4ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505403; x=1720110203; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IJEAX/bFYJE8abBHAC9lGeH6fM4rczNBP33ZEV8FrPw=; b=k8RNCREKeE6ijaEKZpOafO0V9ur+4NFwXHOLwVfabV8wlEYW7edJDo7c3NeQW3+wub avzlkDTkxDcZUp1PBqleTCQf5qE8kl2LqagLumuvB5Faijbb0XBiI/+yAg867VHBKwiX MkDsbkW9RLwK47ComG/zGzjITNUV28nWuu1BmGbcsS42nwysd9N480qWR+QcbkiAemZP WPsXPjYUOgANA1FeYHRMYCuKqnLhGdEWNUEUe1Kt9bOShFYbrsCBD/BFqW2+/3ehf9kP B96hY2akgKGXSKxVV/xK5kSav2k3/Wh7wlliiutQ44ba8iTG/xo6v5B0bbtBAABIY0Dk IbqQ== X-Gm-Message-State: AOJu0YwAGt3xqMFA/suNcz1nrkKgxok99ev7tnQyfKEzQwSPKEIbHr8f h9WiqNqzROZNCafETwZnFTTNN5RF91cIUYZTT0OBBpm1Mqbi6MpJZ9DT9yQEwVfXZeeY95DBzfr RKwE= X-Received: by 2002:a5d:64a3:0:b0:362:4f55:6c43 with SMTP id ffacd0b85a97d-366e937f048mr15617205f8f.0.1719505402204; Thu, 27 Jun 2024 09:23:22 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674357fcb2sm2365842f8f.30.2024.06.27.09.23.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:23:21 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PATCH v3 03/17] hw/sd/sdcard: Track last command used to help logging Date: Thu, 27 Jun 2024 18:22:18 +0200 Message-ID: <20240627162232.80428-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The command is selected on the I/O lines, and further processing might be done on the DAT lines via the sd_read_byte() and sd_write_byte() handlers. Since these methods can't distinct between normal and APP commands, keep the name of the current command in the SDState and use it in the DAT handlers. This fixes a bug that all normal commands were displayed as APP commands. Fixes: 2ed61fb57b ("sdcard: Display command name when tracing CMD/ACMD") Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d0a1d5db18..bc87807793 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -133,6 +133,7 @@ struct SDState { uint32_t pwd_len; uint8_t function_group[6]; uint8_t current_cmd; + const char *last_cmd_name; /* True if we will handle the next command as an ACMD. Note that this does * *not* track the APP_CMD status bit! */ @@ -1154,12 +1155,13 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) uint16_t rca; uint64_t addr; + sd->last_cmd_name = sd_cmd_name(req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. * However there is no ACMD55, so we want to trace this particular case. */ if (req.cmd != 55 || sd->expecting_acmd) { trace_sdcard_normal_command(sd_proto(sd)->name, - sd_cmd_name(req.cmd), req.cmd, + sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); } @@ -1620,7 +1622,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) static sd_rsp_type_t sd_app_command(SDState *sd, SDRequest req) { - trace_sdcard_app_command(sd_proto(sd)->name, sd_acmd_name(req.cmd), + sd->last_cmd_name = sd_acmd_name(req.cmd); + trace_sdcard_app_command(sd_proto(sd)->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); sd->card_status |= APP_CMD; @@ -1913,7 +1916,7 @@ void sd_write_byte(SDState *sd, uint8_t value) return; trace_sdcard_write_data(sd_proto(sd)->name, - sd_acmd_name(sd->current_cmd), + sd->last_cmd_name, sd->current_cmd, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ @@ -2069,7 +2072,7 @@ uint8_t sd_read_byte(SDState *sd) io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; trace_sdcard_read_data(sd_proto(sd)->name, - sd_acmd_name(sd->current_cmd), + sd->last_cmd_name, sd->current_cmd, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ @@ -2214,6 +2217,7 @@ static void sd_instance_init(Object *obj) { SDState *sd = SD_CARD(obj); + sd->last_cmd_name = "UNSET"; sd->enable = true; sd->ocr_power_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sd_ocr_powerup, sd); } From patchwork Thu Jun 27 16:22:19 2024 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: 807811 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp889250wrn; Thu, 27 Jun 2024 09:24:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWDh+fPVPPG3yDe+WQzznWS4BwKNJtffMZrXt+uYGpqlEQIK19ICNsbqpdQCBATkxS2436/2EsWzMWho9BqCYzu X-Google-Smtp-Source: AGHT+IE1PAyjUDiLdaEVqPrTEn1ilVUMKevQK5IdPJZG+SNbPDv8nTSJCDR4OEnt8Boyf0H67tId X-Received: by 2002:a0c:fecb:0:b0:6b4:fea9:ad57 with SMTP id 6a1803df08f44-6b53baaac9fmr127966476d6.18.1719505471997; Thu, 27 Jun 2024 09:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505471; cv=none; d=google.com; s=arc-20160816; b=PKOoQDvH+l4eh3iXKSCAzC3ZrjdD+nhwFGXj/aLrhk/FAGe7FpoPW+JAZu62pYrNGn Y3X+myh4fh6wxWWFuF79/ldmWzPDYFu2CbcuD+Vd3NLQDGO8tCqDz59pEJhPfrmcpZqd U2IVGh4G89wwdGDsYtQ5IRvHLcOLQNEuVQ22i86ZhnQ6rw0+ZD+PLR6lR1n3T043ak6E TZb5/eHEwBc9KWrv7kaKDcb08a7TdsZF0acl65aOeix1MM3Fahc+ZsJq1V/IqEQINKY4 3SKTrNRUhVrqEygJVHSNKmLymy8Y3zJvFkZNqVKI/8wOOmOwdExE8KdvTW8/ro9owOIy 4o0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=C+gseryQhO5/sKrfElbobPrg2sCJZha7vmxA4CmxEms=; fh=J5ku+V592sifDRR0DP/LvVzC5VDqkDqR46Xlv8eA1xM=; b=nNcgc60PkMQb2yrU0VZA1pUVKX5Br6t+pXY5L/1FzuBIjML44SyheHZ5wzfY8N3xrm jiJ9aZlXSNj5FTF5iajLJsgUVUy7ja0iQAMI0hZr3DOPcOZwKi4JtpC0PfoYGJkA5ysP HJdTGefk5EXxDDRnoSp84ClQo20294jhZ3Hbxn7tRbnz6A+iE9AbOkP6ehgV74jroukD 66YgpSx/8K32yIdQzSmi3Ozd4U454U3+sEIlaKF4m1z5WYqnIrdeEx2OGNDISvPM0VE6 PicS6TsTU0JE/y7MY+zT3dK/YLEH7NIDuoibxSO+fu3j6oly2dtAJQTndYRRqvsn9prQ v26w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j0Bwvdo8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e363740si33516d6.81.2024.06.27.09.24.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:24:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j0Bwvdo8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMruh-0004EB-ME; Thu, 27 Jun 2024 12:23:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMruR-0003xh-PL for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:23:49 -0400 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMruL-0007F1-Iq for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:23:42 -0400 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2ed5ac077f5so27788021fa.1 for ; Thu, 27 Jun 2024 09:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505415; x=1720110215; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C+gseryQhO5/sKrfElbobPrg2sCJZha7vmxA4CmxEms=; b=j0Bwvdo8BQYmU/idHE3k2dbgTq4Hy8FkFqmslQq2RD0QaHhePwf4u4qvgfLDPSCivg 4cR49j3/Tq7m8BNhSX+xQ0/Ta2Q69aVOmt4vkLTgl5BLtXz07UaU6e+tyZ2/T19G9TRz pqi7NygErEvF/NE1GDdEpFJIycxyfxh5gMaK5SSgZieC+ZEzADx3FhJrSDuCbV/ujRX0 N/KC1F2gNnzlUAnZhbuP7NRRnG5NVY+zTQVlXZQI1ebYpW6TItnxUCBwcvXzgXkZ59sT rvKO3ACApIKz/SbvDnMEEre6Xi41jMBlWRUquU0WnPps9D5KNHkQXNHPkkOmedmE7kjY 85Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505415; x=1720110215; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C+gseryQhO5/sKrfElbobPrg2sCJZha7vmxA4CmxEms=; b=xNDRcoYbDMMW5I6KIJF9qe1GwA7Pu2yngYfj6oSHs0vBVdOlVwA9jXzeAQoMpcG8E7 gTW+fx9maJMt2qJ8/pdmWmqKfeCQ3B7qMP9FrNdCFDQGryFsfsg6aUZiifOAdj7BJLcU OZt7IHdWPutxVNZmTYLuFJkDjzp7+LwwJunK8AoG7ZrAurjLbAQ66z1aoHrnBCUrcpWe 1mHC/cQzSagArNX9BtyJRCiaRcgaxZl/G1XI8OytSWCnbmVvh/X1eRG8EjXKTlSbigU/ fq1eM3ilm4jz5RbZp6iCZVB8fZosnJmU3oBrWzLan6lj052+Tb8VdeXG/9gs4Z1WuzXB 0TUw== X-Gm-Message-State: AOJu0Yy74rZjAuL1lKIBYgL33Vp7YNiYTEp5F7LQ/RYR60nr3HmFpOqO S3l3skn9w28hfNnYjip/W02M699DBNsYenh4JngZfApEpcIAwP5NYcIL7PrgYHZMkaR/scqagoe a8xA= X-Received: by 2002:a2e:95d4:0:b0:2ec:40ab:694d with SMTP id 38308e7fff4ca-2ec593be836mr88767081fa.1.1719505415060; Thu, 27 Jun 2024 09:23:35 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42564bc4e2csm35641185e9.40.2024.06.27.09.23.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:23:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PATCH v3 04/17] hw/sd/sdcard: Trace block offset in READ/WRITE data accesses Date: Thu, 27 Jun 2024 18:22:19 +0200 Message-ID: <20240627162232.80428-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=philmd@linaro.org; helo=mail-lj1-x234.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-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Useful to detect out of bound accesses. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 4 ++-- hw/sd/trace-events | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bc87807793..090a6fdcdb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1917,7 +1917,7 @@ void sd_write_byte(SDState *sd, uint8_t value) trace_sdcard_write_data(sd_proto(sd)->name, sd->last_cmd_name, - sd->current_cmd, value); + sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ sd->data[sd->data_offset ++] = value; @@ -2073,7 +2073,7 @@ uint8_t sd_read_byte(SDState *sd) trace_sdcard_read_data(sd_proto(sd)->name, sd->last_cmd_name, - sd->current_cmd, io_len); + sd->current_cmd, 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 724365efc3..0eee98a646 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -52,8 +52,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, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d ofs %"PRIu32" value 0x%02x" +sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint32_t length) "%s %20s/ CMD%02d ofs %"PRIu32" len %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" # pxa2xx_mmci.c From patchwork Thu Jun 27 16:22:20 2024 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: 807812 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp889255wrn; Thu, 27 Jun 2024 09:24:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWLnDbryOpiseelIdD7LJRHmegFZBVFRwMaeidyRVOuJMiNFJ7402XIGCEACi8jr43/DtnKactEcrbWKL4PCbII X-Google-Smtp-Source: AGHT+IGJg/JKn5ZA2FWTwvgqm8SJk2x+EyOZLT+ztiN4eKLdkS0h9qjk0h7MHeYFkx8IlHtO8YM7 X-Received: by 2002:a05:6808:1383:b0:3d2:4728:a05e with SMTP id 5614622812f47-3d545a7c5a9mr14853488b6e.44.1719505472358; Thu, 27 Jun 2024 09:24:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505472; cv=none; d=google.com; s=arc-20160816; b=iof7/rGlxhPJVRE8AMZhLmxD1mh5H+cza9xQ3a74EUDPJUHcYCpzOW40TOndtxnRZd GYcN6Eei7/Y/EE8pqof4CHwDCOLtJmfHbBcHyrw+YdtDtBPG1r6IaLd1cO6uh6gjdTHs tKMNOumLkYr3Am9IxJUQwZeeuOw38kU/LDDvxBoIGksgmgcY5WGAqM7TvstK7+r/8GqL Vv+TbBtHiMo2EftSrZ0obVSjvUyl8Kob6HMCTkvmYRhQudn16FAb1WF++DBriGYG2pfH ldrXZ6R84emEwKTH8QZeEwdL+JFEKJJbw/bM4iBnPFmdGbiHRtO/JpJP3CjXRQd9txBZ TTTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2IVH6b/MHuau58htKVq2uNBSYst/d06FDWZAuadlm1c=; fh=BhUQYKXgBpW6j35eAJRQIur6Xmn3o4ALDMZfALggoLM=; b=ic4Jcyt/CxK5VWt/gaDnCOdQZXX6zoBd5QrI/2L5Wk6HmDWu61qGlbUy2vasOxSR1+ X2sxVcQP2TTSqE4mhZTdv55+hIPa75ltPPGyDNCoa8781eY0j2faVoIurqrBAsFGgNfn U2uukmYXSJ0xT4oKlnaVIlEhdrow7nqjwT1yG2Fz09aVEDLS6HbWpWLySiAHWGZkpFsS K0PERj5fOevOh1w+HZvg/IQ7/YLTV7W4zwjW88/54J/eN/l2GR74yCBCxe0UIddzinuY klUwTjzcuRbRewzoB4rpFv9ILC9zNItyq8tddbuN/IPTFPgHKKSQoUdJpcX0nxF6yOG2 P0kQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="GFOnLwS/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4464221bff5si15490021cf.684.2024.06.27.09.24.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:24:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="GFOnLwS/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrul-0004Sf-11; Thu, 27 Jun 2024 12:24:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMruc-000491-MP for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:23:55 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMruX-0007mp-Ua for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:23:54 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-362f62ae4c5so1240577f8f.1 for ; Thu, 27 Jun 2024 09:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505427; x=1720110227; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2IVH6b/MHuau58htKVq2uNBSYst/d06FDWZAuadlm1c=; b=GFOnLwS/ZJHMwEohwVxs98qQPyqcQwstszY1tpzNUowY7VfzvmsO/JyUu1mPIk7x3W daSxS19Cq383cpTAijFiyaq4EuhWov66QPt0umJ21rhtd+N3o4QkJOac76KRsmMwOSqf lsu9Sm37znWURt0g1TMletrSb0VTl/TkSHBvxY/91QZ9V+kG66cGQP4L19n8BZVmWV0O dQEKbPPyFGp8ONfr6JN63TDbat9r0RJHZLqKLqXVtTRcC7xw+1FV8IvfaM+9KVnnbbUo /JNh+r4tXGlCDURO/F/t2c6ddFo9MJSiBRNYU15nsFK2ocXTavWMFX/2DyRG9yCzOqzb IE7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505427; x=1720110227; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2IVH6b/MHuau58htKVq2uNBSYst/d06FDWZAuadlm1c=; b=ujba82oXaWvUP7f1JpAc5eAR92euc3/zpF4gGli8MZc8MrpKUn9E1MxJUDqADQFdJ6 NZwrrfkWBcBwlwA6fstBxXBgotWjyZrCCF0/h0zyRSaZUqIT48PvHxgfb/hwjqXOCR7M tRh5V4fi4PZoeWIoDaAp+QQ2YYvZ7mbwGfAPWMrm21rFuKdVGtMUkm6OcjLsw/1DrzNS Uc4F7PHb7J/js1n5gtex5RS0C4NF2e+ZcbDXoXybb2FkO9fRW+PvihJUi1cTivTGzHIb USYnknAGAbroTV+5LAD33Ff6vEe18gSOKvTM4osRwx5QYW8yqx5SFbHf+ZcW1tmt7ZD6 cpLA== X-Gm-Message-State: AOJu0YwMM5fouyG+UDUeQCkOpOnl5Mr200ImGLHsAEwZONq9PAu8btCy wFt88joXnq/RMCl0++aCl8IspKAiG89ObokGYC3NjGlG5rw2rgNCQ8BqEbtJosG1sfpmHSYo8Tj gTJo= X-Received: by 2002:adf:e54d:0:b0:366:e09c:56be with SMTP id ffacd0b85a97d-3674176ccbcmr2419507f8f.6.1719505427253; Thu, 27 Jun 2024 09:23:47 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367436997a8sm2371409f8f.81.2024.06.27.09.23.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:23:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel Subject: [PATCH v3 05/17] hw/sd/sdcard: Trace requested address computed by sd_req_get_address() Date: Thu, 27 Jun 2024 18:22:20 +0200 Message-ID: <20240627162232.80428-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.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-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 9 +++++++-- hw/sd/trace-events | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 090a6fdcdb..464576751a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -608,10 +608,15 @@ static void sd_response_r7_make(SDState *sd, uint8_t *response) static uint64_t sd_req_get_address(SDState *sd, SDRequest req) { + uint64_t addr; + if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { - return (uint64_t) req.arg << HWBLOCK_SHIFT; + addr = (uint64_t) req.arg << HWBLOCK_SHIFT; + } else { + addr = req.arg; } - return req.arg; + trace_sdcard_req_addr(req.arg, addr); + return addr; } static inline uint64_t sd_addr_to_wpnum(uint64_t addr) diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 0eee98a646..43eaeba149 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -50,6 +50,7 @@ sdcard_ejected(void) "" sdcard_erase(uint32_t first, uint32_t last) "addr first 0x%" PRIx32" last 0x%" PRIx32 sdcard_lock(void) "" sdcard_unlock(void) "" +sdcard_req_addr(uint32_t req_arg, uint64_t addr) "req 0x%" PRIx32 " addr 0x%" PRIx64 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, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d ofs %"PRIu32" value 0x%02x" From patchwork Thu Jun 27 16:22:21 2024 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: 807814 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp889339wrn; Thu, 27 Jun 2024 09:24:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVwF0yIwBC6zXXAVR6mzM0zXpZ3YtvwsE8R41nMyhx5Y/cbJvJPFep1SD9F3nsR4DhfEuEKT+ONUJ3Xcrt81RNH X-Google-Smtp-Source: AGHT+IGKN0BoDdJyp6aBOOuaZhI5QEOip9wMloYzYIiAt1bbQDQxY5AGUczTW4IuFbWIxV77ofys X-Received: by 2002:a05:6830:44a1:b0:6fa:128a:557a with SMTP id 46e09a7af769-700b1213ca6mr20014317a34.20.1719505484633; Thu, 27 Jun 2024 09:24:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505484; cv=none; d=google.com; s=arc-20160816; b=cL+XoZK8jCnJro79lPTnGvKrG2+TH6U9rXKMIvlHdmnJVxZ6ERd4XChlGejLm5Yeui f8+9IYvfLHKwhFgIfNxW3mWlKtq7lkji22cgR0Hh9mZffPN4BiUgy8pO59egqMHXcZXq hV7ATZiUZyrwfpY4iEUsWqhKakzAgza1VCJyRT+BWaxEDOMljXxYpAKJ6Er9fm1Vv9bB g7d1LK4OdMo7rB7qFixf2y7PoJgtzDhsiS8fHZP4hp5horCWEqt5pE05dmIl5t34NCEr aDZ5oX0yfP9HeA7VB3T/Ve6MgciB3UdUUAzjdWptaSr2H9cc4R2cb04/RC3UvNpdMqAm z7OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8X6AtOCpBUXAQ/1xHubY59Be7qdcbmyzPDPReyo42Nc=; fh=5XML3vQt+HMoI5gIGsJOFRukFSQ1eFP2dSC8cWdbehs=; b=SPB4jkQPGVKxX/yJF2Op/hYnyuRHEB0c8L7XJwh7H4PFQqSof8Gio3Cgl6U3hjUtRR cuetxpj0WCIyWis6vNjEh96LPbbU3xa1dmvTcUmjmuV4gAqfxDOmN2SNxGJ6aji7GLCm pQ4/8AOmxw2GOD8QZizWViXDhoJH19sLXqZxVrGsmCNH7nYsFKJEYE2hxuUMIsuV8Wix 0G5rVwvqc83ZwSiGMrCgQMXyS9FLwP0bsZJZGsjEe++z+kxloYWApeoAW73JikoMBhCM kBPeoUF21vs2W8S7DyCPUM4xymcCKwhZ8XbQlF8TgOL/6duXgYg0Qz7hazhtkzgbAbeP upOg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lDZhQmln; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79d5c8cf454si159864685a.681.2024.06.27.09.24.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:24:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lDZhQmln; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMruq-0005DD-NE; Thu, 27 Jun 2024 12:24:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMrun-0004oc-Tg for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:24:06 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMruk-0008PL-J5 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:24:05 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42565cdf99cso8429235e9.3 for ; Thu, 27 Jun 2024 09:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505441; x=1720110241; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8X6AtOCpBUXAQ/1xHubY59Be7qdcbmyzPDPReyo42Nc=; b=lDZhQmlnBgasyBcj7jL/oMVauEXD9X2Y2rsmp+UadHuV97/s1Eh3FHwyp3hgCMuCej SsAALmXkLtX4DC7I5wDGyE5b7PMMbH94WFnUoRFmVudWkw8Ka8FYQ3LiUToVlgLleG2j xgCZww43gkC3dK8tL1sOMOz8qBy7BE//cGvFgGFzOB7CJa03h7G2q8+dCHNy7mIOatHd jrKxlaXiejTZ2C3G+8EMFKQvTyPVkVFENEb1h+lfhnHaDPAre49mEd0nzxdGEFqqVAlu ZXe0N1ZQ7u6FSxW6TyFiFa6zft6vfHILVUA3C8aOSP4KoIkZbCz/RI27oUhOrKUda4Nc DaoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505441; x=1720110241; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8X6AtOCpBUXAQ/1xHubY59Be7qdcbmyzPDPReyo42Nc=; b=bqPf4WsVYqdlA2e12Ft8xTjNABg6ZPfsaUgnHVgqskAVNuPRGBCUgKGqQ3gsVPLCUl RjlUHj7wSgpx4tb5g6Ud9oDIL8m03RhwWnwtAB75GqdZQ1aLvsb0ykXPMPKXgELsP7fc 71Ty6/dKj4osTDk78/iNJUxJNkSYxWj15ml4UEH4QZG0J0l/FKemLZdjj7ndkwgduXc/ PGVNKYLTmu6i2IY61RxRgEMcRTsi9ktbvDL4iHSLlG2WXBo+el8KnGeKZUtd/E0XhJ5V usWKbnXOR52a1QIXeO9VVmMKKyooKUO6ohwEHQtDFnHXPpsXuJWa4j3LgaptQI2I5Ftw /rag== X-Gm-Message-State: AOJu0YxW67/x7+1sBnVXtkUpcJmQOAVI8fCBBZ90gAG/B0LpjveOXpcI PGSVujIEF6FWnxq1fRbgMiqU3Xrn2FeL6kvREOdOyKWI+gnAO+Maqcmmd71Nh0PxeDzlQSE6eJl FgC8= X-Received: by 2002:a05:600c:4f07:b0:421:dd8c:35a3 with SMTP id 5b1f17b1804b1-4248cc586d0mr116166515e9.26.1719505440758; Thu, 27 Jun 2024 09:24:00 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8246b1dsm76798185e9.6.2024.06.27.09.23.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:24:00 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= , Peter Xu , Fabiano Rosas Subject: [PATCH v3 06/17] hw/sd/sdcard: Do not store vendor data on block drive (CMD56) Date: Thu, 27 Jun 2024 18:22:21 +0200 Message-ID: <20240627162232.80428-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org "General command" (GEN_CMD, CMD56) is described as: GEN_CMD is the same as the single block read or write commands (CMD24 or CMD17). The difference is that [...] the data block is not a memory payload data but has a vendor specific format and meaning. Thus this block must not be stored overwriting data block on underlying storage drive. Keep it in a dedicated 'vendor_data[]' array. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- RFC: Is it safe to reuse VMSTATE_UNUSED_V() (which happens to be the same size)? Cc: Peter Xu Cc: Fabiano Rosas --- 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 464576751a..1f3eea6e84 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -142,6 +142,8 @@ struct SDState { uint64_t data_start; uint32_t data_offset; uint8_t data[512]; + uint8_t vendor_data[512]; + qemu_irq readonly_cb; qemu_irq inserted_cb; QEMUTimer *ocr_power_timer; @@ -656,6 +658,7 @@ static void sd_reset(DeviceState *dev) sd->wp_switch = sd->blk ? !blk_is_writable(sd->blk) : false; sd->wp_group_bits = sect; sd->wp_group_bmap = bitmap_new(sd->wp_group_bits); + memset(sd->vendor_data, 0xec, sizeof(sd->vendor_data)); memset(sd->function_group, 0, sizeof(sd->function_group)); sd->erase_start = INVALID_ADDRESS; sd->erase_end = INVALID_ADDRESS; @@ -771,7 +774,7 @@ static const VMStateDescription sd_vmstate = { VMSTATE_UINT64(data_start, SDState), VMSTATE_UINT32(data_offset, SDState), VMSTATE_UINT8_ARRAY(data, SDState, 512), - VMSTATE_UNUSED_V(1, 512), + VMSTATE_UINT8_ARRAY(vendor_data, SDState, 512), VMSTATE_BOOL(enable, SDState), VMSTATE_END_OF_LIST() }, @@ -2029,9 +2032,8 @@ void sd_write_byte(SDState *sd, uint8_t value) break; case 56: /* CMD56: GEN_CMD */ - sd->data[sd->data_offset ++] = value; - if (sd->data_offset >= sd->blk_len) { - APP_WRITE_BLOCK(sd->data_start, sd->data_offset); + sd->vendor_data[sd->data_offset ++] = value; + if (sd->data_offset >= sizeof(sd->vendor_data)) { sd->state = sd_transfer_state; } break; @@ -2165,12 +2167,11 @@ uint8_t sd_read_byte(SDState *sd) break; case 56: /* CMD56: GEN_CMD */ - if (sd->data_offset == 0) - APP_READ_BLOCK(sd->data_start, sd->blk_len); - ret = sd->data[sd->data_offset ++]; + ret = sd->vendor_data[sd->data_offset ++]; - if (sd->data_offset >= sd->blk_len) + if (sd->data_offset >= sizeof(sd->vendor_data)) { sd->state = sd_transfer_state; + } break; default: From patchwork Thu Jun 27 16:22:22 2024 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: 807813 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp889334wrn; Thu, 27 Jun 2024 09:24:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCURlpRROsmYgBrb7wlcLkiHMrydrG8scta8SYGcP1S4BS3i0cF4BrzPdM6gde/5MIIETFUALxVs/d+1rmgVulb7 X-Google-Smtp-Source: AGHT+IGlr117ObDPall+Ae5alF1CMGOeOoFUMh40kjYMC3AwZ/RWYes44yrKqa8TTjVXtZHhKKZS X-Received: by 2002:a05:620a:1a94:b0:79c:a7f:c9e4 with SMTP id af79cd13be357-79d5a257e3emr392172685a.78.1719505485550; Thu, 27 Jun 2024 09:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505485; cv=none; d=google.com; s=arc-20160816; b=T/ngIc4hg4+JYT00zzHizqMfQtZkY0SBeXWxGvD5ivtvlM0nNM/zX5VrHXHL4GTRwH 1cOKYKRvjqm0b3rC8S9URvgW+Lly9yCzzHxbNDoF3YR9EJqU6Jq1eyG2q0VwxwqK0qhv es9G/aIW8mdixebIjwhcevAHrgwdWD5tQ86ZuSGnk7DNAtl0nRvBqFM01FOc1CuzxCpK 5pWPzQOi2uMXDUkynHz0Vnbs1zbbtV1O+lpf/3VlVGg3CMSGCcYq84tct1kGqjJayibc UR1uMjYqQs6pXUhd8gOKjT9GsKxJlojhrhMimylCi7EJ6bKirBBXVMrUkSnq8/AYlkil W2Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+otp2F30HYnVaW0wjGWSRpaE6+qcbVlZ832snl2PQg0=; fh=iT+HNMMHWH1uBS7SWaruLLdu0esErr5oKH2mvOdVPko=; b=rmgtB1CmGzFXW1/S0V4yNXihOKfcxLNKA74i0xDVVsCnCtafYl42k/64RfsOxIpf4z 72N5A09eIT9DoLlFOxOot8vRgqPzsfzAT80nS5P3/A4Jfctc09gHH+oaVz+EaTyXLCPR pOjfIQnTns3bvQlnqd/MGaRWDVd7M/erg5lSeYhMVUSIii9ODzk6XkMTgFIiY0TrgxLZ gveto/t3E25LC997U4RpA0u3t1rlexSPfBbNnqQ/mEiDcKwGsX64x4DaP7vjZisGEXGC N2bKq8fnYz5IoVRy+lCZQXKY0JdXIeppzk8MNxKD/2HkO9fyfVf/l6wl6AxZIvcUg9ke owAQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tvg83VxA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79d5c8bf145si160222385a.529.2024.06.27.09.24.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tvg83VxA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrvL-0007Ik-DH; Thu, 27 Jun 2024 12:24:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMrvD-0006wy-Ou for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:24:31 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrux-0000KB-He for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:24:31 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-424f2b73629so22792345e9.2 for ; Thu, 27 Jun 2024 09:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505454; x=1720110254; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+otp2F30HYnVaW0wjGWSRpaE6+qcbVlZ832snl2PQg0=; b=tvg83VxAmfz2MXCFPVwKzMWas7xr7nH8rvDFpChf1Ki6DdasccECMoNZNQjWdf0QBW rYti6PYgTnhhfqkaPvEM8ixPWSqN4PYu8VMK+3hBTRZpGENTP0ooOFWUp4WokXsdt0+5 Pe7PcWogyIMqTTP2W1lWkg2u4Cp5FF2WUo/D/sAEfpLKWWsPycaMKNmYTRPCFDjhjLoF +De9lCY2j0jfzf2qSf+xu3nSr2VYQpwGD4hcBi1Wy+VSCjzodL71yC0Rw46Vg1xj37JA qfr70cDuDOuavdYnH19mSSrhh+JZr64dLUr21p4G20xAXuzmtYka0fvK1K2LTC9E9aQU P5qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505454; x=1720110254; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+otp2F30HYnVaW0wjGWSRpaE6+qcbVlZ832snl2PQg0=; b=ra2VW0pnlgrR5GakdkkGnT/s62q1yQffwg9DzpySPPwMJiVUj+KZR9CE10QrLkIyT5 B067sI/pfEkmD51FmXH0PcXa4ir1zNrperZYFiAtvbLhyOM+TPe4409X+i6eNyrm/US1 i3Yx7Fh9AoDJxd2FHf+fFU6NrDKbiJkDUxA+a8MwZPcI83hJD3KpxZQLvqTUWvS343o3 1MgJj8oKV+hcF0p+HKF2GEaXq65cULXewizG1O0+facFJEkvEoy2pEWlg6gDceKyxdt6 iJdk1i68QLomSWvEKEHETLApW9d419lIJ/Mahx5E7xKKq9bwTbZYRp3YQCzyb+Xa0fd+ 6M7g== X-Gm-Message-State: AOJu0YylVrHiIqWsVeIU7LpmAKPjFWz9Wy5Dr7MQBIIeOOHvRw3Y03ls ab0Jn0ZL5SqF2tQL1P/CFiC6TlduHVwhjH33qiKqQm8/3jyJN6RMNLjrinX9oaA+BPok4CT8kn7 IEfQ= X-Received: by 2002:a05:600c:6d48:b0:424:a308:1746 with SMTP id 5b1f17b1804b1-424a30817fbmr69581105e9.16.1719505453885; Thu, 27 Jun 2024 09:24:13 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8245d9dsm75125565e9.4.2024.06.27.09.24.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:24:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= , Peter Maydell Subject: [PATCH v3 07/17] hw/sd/sdcard: Send WRITE_PROT bits MSB first (CMD30) Date: Thu, 27 Jun 2024 18:22:22 +0200 Message-ID: <20240627162232.80428-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Per sections 3.6.1 (SD Bus Protocol) and 7.3.2 (Responses): In the CMD line the Most Significant Bit is transmitted first. Use the stl_be_p() helper to store the value in big-endian. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- RFC because I'm surprised this has been unnoticed for 17 years (commit a1bb27b1e9 "initial SD card emulation", April 2007). Cc: Peter Maydell --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1f3eea6e84..4e09640852 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1507,7 +1507,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } sd->state = sd_sendingdata_state; - *(uint32_t *) sd->data = sd_wpbits(sd, req.arg); + stl_be_p(sd->data, sd_wpbits(sd, req.arg)); sd->data_start = addr; sd->data_offset = 0; return sd_r1; From patchwork Thu Jun 27 16:22:23 2024 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: 807816 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp889427wrn; Thu, 27 Jun 2024 09:24:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWPQzkF3E4Lb8G1N4ILWDhrouiC900ogI9OOPLu0nD4N45/5PF8c/0jXhlfcaTQxR8t/Buus697fbI8wRDD2PYp X-Google-Smtp-Source: AGHT+IFuvB3KZcAzqFXtdugJoCTdWdgo0SjwFBMJzH7fyNXrTBqwikLbySIMiQw0oG7AdhKWNW8E X-Received: by 2002:a4a:351b:0:b0:5c2:1a11:e358 with SMTP id 006d021491bc7-5c21a11e3b0mr8503645eaf.2.1719505499199; Thu, 27 Jun 2024 09:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505499; cv=none; d=google.com; s=arc-20160816; b=xjG1REyouuBqaBpReTePdvVxiE5v4EBTJzsoy0hWYTwqAcpBYTf38CMJFsTeTRHB07 If2ULEtcIEvAgCVOf4gQncOX40P9HPi4FzCrxCOl6LHJn4ajKP/O5c9VfBYbyS0SbzJu XVXcPtcCeicnwXbbzaap5unr0Om8MBaiuNwzW4KWCTSOgB5FC41L1Jy7rTwOum4VBbkl UGtqD2T5QMx2GUK1fo9QdW7zWVYJ1Spbg8/ufn9uMfdLlBCcF/DGlBDhEEr+lMlq3Q7I ESXSzp/lBSqn1ceMJywowGaDS5y93CyezuzzDCUjs+bnL/nLaSGvxQhc+q5JpzUQF4DU Eu1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vUpbb+xwTJn80OMiSW9qrPEenBatfvxaYEHBd94Y0+o=; fh=iT+HNMMHWH1uBS7SWaruLLdu0esErr5oKH2mvOdVPko=; b=Pu0BtzU/xMeI2z5MjqlAdXnKllexkug01z5N8EwoA94449VHRC27AMbmQcyXLIlC54 ORZa8C0DtgB5pCimzaK/CaoySUaNJ5wKWZTqQM7qLhh8VwXfD8RmCVrA5dc9X7Xp+1Uk XMx1H0Vda8dWpdjbtxJpVHFFA7FI3AuBAhVKrbnixB2MIVoBiTycKRxGeQdoZnduIGTM Yg5jZcHZNbi+yfBrv4agJtZXZLXILYs1H/4beJpkSZ0iWrmD5JxO/x/tN6zbaKz4qLro ViMHxjITyrtHtc7D0ANNttsQ6yTDfD0Mnvhrs4bCy2sMbAvfiN0pzfhOMIBC6hIRx94s /SjQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T8f37Yzu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79d5cee449fsi152270285a.460.2024.06.27.09.24.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:24:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T8f37Yzu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrvc-0008VA-BY; Thu, 27 Jun 2024 12:24:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMrvQ-0007oD-G3 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:24:44 -0400 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrvA-0000gx-Ri for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:24:44 -0400 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2ee4ae13aabso9346341fa.2 for ; Thu, 27 Jun 2024 09:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505466; x=1720110266; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vUpbb+xwTJn80OMiSW9qrPEenBatfvxaYEHBd94Y0+o=; b=T8f37Yzuh+Rkkz6gi45k+5bkgO7ImEb2laGIZVWd3PTj0uQf+EBXS+S8LzLJiio9hE Th5jushr+e+qu3V/MrN4Iz1v7R9jVgeZWssYPFqT0XS2K5JbPiznYxUC55/ZZ4axhS9k y3sViUmv55vLfdLkFXaVbLYUShY1+hI2hBo3cfupDdlEPP9fVWaUFg90phx1aw8qQUqc 5USdhpHnSXbmU48HTUIN0qaJQDxLDaTxD7hdGbzpR3rDeOKrUETNd3eOuGFzsjQ1bh4M E6b6UYxaGEZ5qgwxk34zUD30lQqZ6wByHR5HY/11EsvwslsVxXsYkx6Ez4454W8DdJdI 2Nkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505466; x=1720110266; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vUpbb+xwTJn80OMiSW9qrPEenBatfvxaYEHBd94Y0+o=; b=CtyoexJoM5ZC8OwdcYO0yNt9twMYv52j8Ll55A2NFIXmuQ+NVSbhUtHZbQGzJRldUY 1wccF7sPszBe0L5Nz4RRMuNyhEumiofeTg9bAxeCkVhGniJxxj3aKXuKrZv9KL/JF0+o 0xnHDbMMHT/WV5826vouQG/tLE3YZw/vxJPpp/8jW1qikRg2e7/Wtxda4waAPOzp8baG M5Cz+ExsCammcmYL3XA5xxrb9NSjinlyxbz1gt6wOkGAWg909rQXdg60LZWPJ+vrOfif UIilTG6H6jWEGXm4PqR2JaHHrWCwR8DpXQ8+B7NX0j7SPuWocvVmofcrMNnQF+5WtN78 l0sA== X-Gm-Message-State: AOJu0YxNpwtIx/em6STYrZo0n1y4tFpJ6kSZj8AsNCerPamwot9PfBF1 x4URQ8bkBEBFUc+meOh7DT6YUSQCbddQbgIlk0z+NO4HeB3roNYu2r10bhJ5ThYyPOz9V4ZB2Pc ZeFA= X-Received: by 2002:a05:651c:1991:b0:2ec:5bb2:c230 with SMTP id 38308e7fff4ca-2ec5bb2c26bmr114074301fa.12.1719505466214; Thu, 27 Jun 2024 09:24:26 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42564a4da40sm36326085e9.5.2024.06.27.09.24.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:24:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= , Peter Maydell Subject: [PATCH v3 08/17] hw/sd/sdcard: Send NUM_WR_BLOCKS bits MSB first (ACMD22) Date: Thu, 27 Jun 2024 18:22:23 +0200 Message-ID: <20240627162232.80428-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=philmd@linaro.org; helo=mail-lj1-x22c.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Per sections 3.6.1 (SD Bus Protocol), 4.3.4 "Data Write" and 7.3.2 (Responses): In the CMD line the Most Significant Bit is transmitted first. Use the stl_be_p() helper to store the value in big-endian. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- RFC because I'm surprised this has been unnoticed for 17 years (commit a1bb27b1e9 "initial SD card emulation", April 2007). Cc: Peter Maydell --- hw/sd/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4e09640852..1f37d9c93a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1668,8 +1668,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd, case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ switch (sd->state) { case sd_transfer_state: - *(uint32_t *) sd->data = sd->blk_written; - + stl_be_p(sd->data, sd->blk_written); sd->state = sd_sendingdata_state; sd->data_start = 0; sd->data_offset = 0; From patchwork Thu Jun 27 16:22:24 2024 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: 807815 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp889426wrn; Thu, 27 Jun 2024 09:24:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXfzszQkWjW9CxqyNc6RJmrCBeuA8wz3c87aZCauLaQLGKhjViJ11+RFfH+6x1wgQb/05w8cVCRglFj/VzLpXMk X-Google-Smtp-Source: AGHT+IF9ptcTxjNyw6rK/DSdAl0Qe86XnDUU+yJwGBRPWRASiGDfvBOhLGX+P9JIAMPbdf5rphS8 X-Received: by 2002:ac8:594a:0:b0:444:a454:8922 with SMTP id d75a77b69052e-444d91a467emr146099891cf.27.1719505499126; Thu, 27 Jun 2024 09:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505499; cv=none; d=google.com; s=arc-20160816; b=b1pzuhcmGokPz9KMh/jRVmDA0mp6TPlUK93ojN28XECfGT+Lt5IxEMZZZPvlvROjq9 g6trOWmh4vwRbUqIbRmJ8gQHSpZz8KSa8z3YOBGoapG64pX1xtGqn6ZTx7qoMGZmiePI YSHKHTQy+0JWXFK55BKKigCsqIwCQwK+/4GPPlg/ZLhIUieL5ErhW9jWcXTFXiYuMr7r yRn4GZedZVYWuqeywIl0Yo3T4FZZhSwXoWN5oKmrZ7NIqFgVWOQeO51utTLmljAh9ViT hzZhIi4WCzORseqIjSBVsTYS5Jao0/RfrJbT6oh8+SHxanluGMvz04pVYNHC/Lmy0ZK9 Ww8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yFkcsEXV8tTNgx1V48/Rdkr/iwnE0vz/gcdrAU/mSc4=; fh=J5ku+V592sifDRR0DP/LvVzC5VDqkDqR46Xlv8eA1xM=; b=sjNeIuZwI4/V1ga5n+MLZoDGIPXRotd8xP/CJRNMR9vr6FCetCmLhAItUsWbNwqMzU lU0/vtE0NQRnkeldzDm9BI9fUDmOj0IhlJ7MLHbHllR7j3ysYcJ4RZ4LPZGaSCjT1aey 6qQoDuPnVyYCFMr7r5ImU3s3prwwaZ11lOPA6zWTDJ4gIUKh2mzmAj/oPMOIwY4tGbXd 3jB1p50jxq7mJeznGOoEmA1Cq3CdDseXwy98Z4yZA7//QF0DfBrV9p+eVm30MNXsxw5H mCJdR+UarM6+Xrhkk64AnOduqsf7oWLeTWDAyTGh0cRgzhru0YnzFQD/8nzKJXr3GLP1 eC3Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OhwhO4zl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-446421fcf27si15613651cf.614.2024.06.27.09.24.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:24:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OhwhO4zl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrvX-0007xj-F1; Thu, 27 Jun 2024 12:24:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMrvO-0007cn-MD for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:24:43 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrvL-00019R-WE for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:24:42 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-424ad289949so19389065e9.2 for ; Thu, 27 Jun 2024 09:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505478; x=1720110278; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yFkcsEXV8tTNgx1V48/Rdkr/iwnE0vz/gcdrAU/mSc4=; b=OhwhO4zlpzZZp/ZCBaTx288a81ZKtKh4ZP1voyhAPw1+8amQ/bvNh0bp7LbqvHYeQv nqwJL1BoSaY32BbIV9yh7DBxSDY9uqBrnCSgRfCF+BtjJnO7pOmujPHIKjCvWyTGzSI4 dn4txEMXhHvcWTmhP0y/zRf0/xkJhAeYLJe39C09pNHkG7eSIjePDcZdyn+qWt+LofDs 1jk/Mfpfmpe5pb7Z+qmZUAIRv1mzCh1wMYf7wJAlcQ+cRJDCXjRBUFOwFOE4sQBKCf5g 2ZxPDlcHhV7CPwnSV6Ofn4P1/Y+og2V0PC+AWEhPtwUD0veYUiOfJdhNDILXfpt0lSZc eugQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505478; x=1720110278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yFkcsEXV8tTNgx1V48/Rdkr/iwnE0vz/gcdrAU/mSc4=; b=pq031KnevTkAXBJVppGvaZC9gKaQ0sAtJMzezUo2LJdzc1vMNXgr/Tnas3kYoFdwa0 Zu8evb+vC4CE5PTRXa7OoQ60MnroILDszv3TrucPfORilYv9gb80goR1gDsMm5LFBvf4 0emwvIPgS2sUGuVzkr3L6py1icsdbUZFygPqwjkvIuOtouiVv/wBkspSLILZjIJB+XFW hYK5NLybipSTnErEv8Dwe40rThzLa4nsyFsudj2eiWklDCrWZVGTar58JuHTPXEpmbHp JpUkdHzYDtSKN7dkQ0pMgZYiYIVJoL9uIPAsfWhCixf+d/jqhtxFJhgLt4HJxyhRB411 /3PA== X-Gm-Message-State: AOJu0Yy+OaSNT5I+CJEEmrqoNiK9u4ECtLGBvCjnsApj6/k0/jWf1wwb pDjixwOnbwBZGKUHBMG1BNMJBIJCM+gpsaV/o8ofk3S9MTcD0r63vEOvxX1PXvYjYlo/hbv9Bbi Mj/E= X-Received: by 2002:a05:600c:55c6:b0:422:4fcd:d4b3 with SMTP id 5b1f17b1804b1-4248b9ecfddmr94205215e9.37.1719505478323; Thu, 27 Jun 2024 09:24:38 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4249b133b44sm71480295e9.0.2024.06.27.09.24.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:24:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PATCH v3 09/17] hw/sd/sdcard: Use READY_FOR_DATA definition instead of magic value Date: Thu, 27 Jun 2024 18:22:24 +0200 Message-ID: <20240627162232.80428-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1f37d9c93a..135b7d2e23 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -561,7 +561,7 @@ FIELD(CSR, OUT_OF_RANGE, 31, 1) static void sd_set_cardstatus(SDState *sd) { - sd->card_status = 0x00000100; + sd->card_status = READY_FOR_DATA; } static void sd_set_sdstatus(SDState *sd) From patchwork Thu Jun 27 16:22:25 2024 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: 807817 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp889596wrn; Thu, 27 Jun 2024 09:25:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUZykQ88eY4fA4K1MT8WYYZhRtzSla1bmQZQL0I0a6bBXsD0qDPKTsPG9z477iTpXDz3e9zf9zf8dTSVrBXhTX3 X-Google-Smtp-Source: AGHT+IGkYRygn1qUYVLkrhb/wqb9AETghFc933N3JAGRMDNj4NgqDgFZhJUv99QXA0ZhEXvLKOFO X-Received: by 2002:a05:6214:5583:b0:6b0:7327:c45b with SMTP id 6a1803df08f44-6b5409c4416mr140060306d6.16.1719505520952; Thu, 27 Jun 2024 09:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505520; cv=none; d=google.com; s=arc-20160816; b=sm4FOHPEhYdmV3S8nPBujPQ5hXw6jfBp28SrcAPvL6FkW1HHp3Tpt14A6nzljuMdek t6sbANvIQShE7og8yIMk+TIxtvpEfaij922ChPw8A8dvH9vJNbl7LYjo+MHlH+Mu8Kor 9cP/xqbyTrTfXKXlzIoGppLwMtnl+S9UW1UmC+8rBDc/H5zwoyXTwk1nD/Q7cV36t70/ zyrW2d85hW0XSlnE2XFbPTuV5L073kC13HYLna528T12pB/omK+lX5Ffzx4+Iq2kHoiU +LiSEOBM+AhWAQyvahTb2EArdBLn1qIdz8WwmNevKz8u/fypZKUyWmomyZFj86HamMFp Njqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JpVotoHspFlZ3BpKrTY/FaOKVvxynyJagKJZJS+6h3k=; fh=J5ku+V592sifDRR0DP/LvVzC5VDqkDqR46Xlv8eA1xM=; b=DFeyvSY8BQqgYbZ8qv8owZOrhXyZlFuChCiezd9n/b/EzGXZTxu8vZo8kur0Ji6MkU WO2vReDJGNtCaKS/yz62bXxSXyE7CHfL0P6OHldu1+karKXofO1EySY7VaATi8crh4pn iAQ1ALA6fzfzHAMdUQe4hJ+hazkqdbgNmg2teoXcbeWq43qeF1bnjw0kQjuy2TdTJehF m8RJzOHtcG/L7bYLZaSS+0V8MD7lnrkeLWxOiPLZbVCqoa/yEPfeh3gAK7hBOA/hYweV EdhDcWuIMnAlDPGg6iBCEzYsgbEiecCkxLJKCuGXGbRDyf4WtOQRV6zgR87lQgbYjLqD TjrA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sAD4SVpe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b5926f1400si15701566d6.454.2024.06.27.09.25.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:25:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sAD4SVpe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrvf-0000cd-Sw; Thu, 27 Jun 2024 12:24:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMrvc-00006j-Df for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:24:56 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrvY-0001NU-Kx for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:24:56 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-424ad991cbbso18631155e9.0 for ; Thu, 27 Jun 2024 09:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505491; x=1720110291; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JpVotoHspFlZ3BpKrTY/FaOKVvxynyJagKJZJS+6h3k=; b=sAD4SVpep7t9QEf0mJp42GPVlhDmfctgRDq9RYjpqQx5fDlAIXk0sPjt6TM6pRX+j9 jpvqFtw6ih9WH0zbmf7LLgYLYAcJxTvJPaFy+I9pKBKj1yn5EnVocFeuaOkDdc1mNH7n wXwX+T6uWYxK5sPP9fZkglyYK2NYeN25xm8+rv6jTU48Yf99i97ZOh1agOZGRcWp2gVc hKp67AFftySEtJWW6Vephc7oQGjRhNF6H+fOeLp9J7iTRdAvFBt+5jTaUtFt4Y3Jpv+q uIeJkYRCJEyu6YSGBeGUC4CiUjPsm2iX2TeR2BWmXV3A//io6u5eYSl3r40gzjqEMAt4 ZuiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505491; x=1720110291; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JpVotoHspFlZ3BpKrTY/FaOKVvxynyJagKJZJS+6h3k=; b=JshIPIhX0xCzKKpk3XispGYa/b1NHU8jCg2RZyesbVV4KsfYo1duL0/b1hE4PdfNHk pM5U/u3nQ0Lxq8MMYHDegbP7I0qnC/6pyI5iU0f62x4mJ07innYY2Hokb0ARE+La+1ha mTvp3H71iGqKlEqTZ7hXDzmd2hObt4zb2CmCS59OzaomliwCDlNrexAOU9KcEVEjvb04 IeK5+uFBDjvh2bPPPa3PIA18GvHdAhVCdqOVOpH8EeOf1VPJgQpIrR1yWqOj4ZxrFK49 SCNLk7wYd+jtckIdH9BeqITmhDXJlkwimNrFaCvAV9o07+1wxnUP7A2zmuz/hKcv+BpD rzcQ== X-Gm-Message-State: AOJu0Yy7EY403T9pNH88qVHOEyeP5Z1aVyiGlU4ux1/cFZm8x1aHwRhN myJ6XPZmZEwYgCWoL4WveNd/2PxTXPkRKqVk6d6eQocTErbhe/ys8so8FVtGzy+IAY5X5ktzoCU 2Isc= X-Received: by 2002:a05:600c:16d4:b0:424:a406:ad52 with SMTP id 5b1f17b1804b1-424a406adb7mr55279375e9.19.1719505491050; Thu, 27 Jun 2024 09:24:51 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36743699c0bsm2349553f8f.70.2024.06.27.09.24.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:24:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PATCH v3 10/17] hw/sd/sdcard: Assign SDCardStates enum values Date: Thu, 27 Jun 2024 18:22:25 +0200 Message-ID: <20240627162232.80428-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org SDCardStates enum values are specified, so assign them correspondingly. It will be useful later when we add states from later specs, which might not be continuous. See CURRENT_STATE bits in section 4.10.1 "Card Status". Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 135b7d2e23..fbdfafa3a6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -75,16 +75,16 @@ enum SDCardModes { }; enum SDCardStates { - sd_inactive_state = -1, - sd_idle_state = 0, - sd_ready_state, - sd_identification_state, - sd_standby_state, - sd_transfer_state, - sd_sendingdata_state, - sd_receivingdata_state, - sd_programming_state, - sd_disconnect_state, + sd_inactive_state = -1, + sd_idle_state = 0, + sd_ready_state = 1, + sd_identification_state = 2, + sd_standby_state = 3, + sd_transfer_state = 4, + sd_sendingdata_state = 5, + sd_receivingdata_state = 6, + sd_programming_state = 7, + sd_disconnect_state = 8, }; typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); From patchwork Thu Jun 27 16:22:26 2024 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: 807818 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp889611wrn; Thu, 27 Jun 2024 09:25:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX61E++vVXAJhlHmZmNB4jDHVoWVmc+0bwJSQ3jhzDJuUdY2QnDsVkgqpISWkynGs9XxPHTOtTo+b85zqzNePlY X-Google-Smtp-Source: AGHT+IHt457mLKrl3h5xM8TeB2Nr5xZEzYcauKSyD8wmlc/KRjtmB9yo47IFZ3hI+a3D6/uGNehb X-Received: by 2002:a05:6808:d48:b0:3d5:1bd8:ab1f with SMTP id 5614622812f47-3d545987072mr16101559b6e.17.1719505522079; Thu, 27 Jun 2024 09:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505522; cv=none; d=google.com; s=arc-20160816; b=k4GC9j11Zt2JzS25Jgh6oaY+yjPoFYSE+me1SdTUYWgNa/zStzCM/KCuGl6+HRczND Y1vxzqmvaYBMimlBskrPiQuKWEoM0mSwM4Qe3ni1YxZDG89RS1s+f+P9pehXVmxyap01 wpqQaf8ratbjKHhhCMLw6b9g575QIBN4EVl+o0DRqb3UQfgt0/+xPXybJPzXKXkWLO7i nZ6grWz8bP3kzfYkoMKCcjlKLQGFcTAu9I1Oy0GoWFlwRis1w2tVl9kkQKkRPYE6YdGg vEiQ+W1yja1RhG9cBxv5cgU92t+CBLibwSi6fajPEk1rGVHS4ExfF3woeRXVD7puvhXR oIjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wrQTXcopwoxdy2+QKjolzASBZvpHRSjsIoJ+STiyvF8=; fh=J5ku+V592sifDRR0DP/LvVzC5VDqkDqR46Xlv8eA1xM=; b=L5IEYTOPLDnn9eIJe64CT//z/nuoi0LJfvpGtxugCZSXEjr5DxPlh45H3ovWkAkRH8 7Cn023UpBs6+aBk/HhkVaipCETGbHAU1IjjMkpnodi5ZViNXAwvfk4+qflGExj2LWseK cN/MTDUYVFrGj8+9YZvIkZjcPR3D5Ih6CCkGgURbT8bS5sLCKm14mJ+hfHl1Dsky6D8T 1+IiS2ZnBU6xeHFx21EfHrrbL/+U+Yx3OUYIg7Y5QLfdKL7y1JJXyLrPTH6mXTPtWS1q CxLOIEd1KRwN2WKFZGloi8em5CspHx2iBgUm36y6epOhgyOTL7VVy3Ueg6jTAiDPi8U4 wkHA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bh02eA8O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4464206a532si15911071cf.477.2024.06.27.09.25.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:25:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bh02eA8O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrvv-0001dR-Uq; Thu, 27 Jun 2024 12:25:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMrvn-0001FP-FE for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:25:08 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrvl-0001sx-C9 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:25:07 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52cdf4bc083so8634359e87.2 for ; Thu, 27 Jun 2024 09:25:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505502; x=1720110302; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wrQTXcopwoxdy2+QKjolzASBZvpHRSjsIoJ+STiyvF8=; b=bh02eA8OoA7i+S3Muf2N4/heA+YwgiwrMGg2FkxAqwtW4/qBuBKQueVTyOG0lpE2IO QuuDCNMRv9pUhdcoKelJbirmrLFzsPtbdUtiqZSmEqayi/WYcyZu0iQr/Pbu95aU+LzP +bSJsArgyeadIfCmiXqoKZ5HIMN+7Spi4rArTs/xnuelLLqhbLqm5mX+UzxZk5JGK8HU qV429Wm99eP/fgsqOEPtzok98RCd6wSywtg8OMfl/7N5LnVDL+vcaa3ynArFCqmfAt+b 4b0O90ZVS1GbryRfzc0bIdMFLNqbHkaKVrgr9DOfDVsWhKBBd7QyeLO/iyRze9WEH1C0 j31w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505502; x=1720110302; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wrQTXcopwoxdy2+QKjolzASBZvpHRSjsIoJ+STiyvF8=; b=VN18+hVfdSQeCAT1xX8MZaBeZz6kouiZnZwieg5PuHs0nbODkwXoNlfsywUSLLWp5u S5LBU16MPpvIgUHy/eMdcsNzqM+aGREUdfIvps1lBzLkINFxFKbpWVXisTwXcKLqoRQ1 SSNCX7ib+WcS4AQZ4QpzcgGycbt6eD8qf2I7RB3CloMbSceCMDijIoZJCa795WtjVt9s LG7eATRMYSBD5J24gMqg5TYLoSBxtj7MDsqyhVKwkCjAWZp791SQJT7AUHZAdPvkqNP9 hORptPRH7Ylf/Bkt3nhu7djOCMSjCimbXu2f6poQhQRA5dAU7IJ7XW9KDmXox5KJlsWt Iqpw== X-Gm-Message-State: AOJu0YxjLexk9gqfhq8tGfvCWmG/qDVsDkCBCPlMP4g+FwDxDMvCm+vk EXNPz4hfbH/Qy3HpkhsYgXxnF4naQxa5JuZtMCgEk4aNiEXgSmsFXeiBvFuRsKTpcr4wgyGIVhM QhJk= X-Received: by 2002:ac2:4c39:0:b0:52c:8c85:cb46 with SMTP id 2adb3069b0e04-52ce064697bmr9932361e87.64.1719505502194; Thu, 27 Jun 2024 09:25:02 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8246297sm76615625e9.8.2024.06.27.09.24.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:25:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PATCH v3 11/17] hw/sd/sdcard: Simplify sd_inactive_state handling Date: Thu, 27 Jun 2024 18:22:26 +0200 Message-ID: <20240627162232.80428-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=philmd@linaro.org; helo=mail-lf1-x129.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Card entering sd_inactive_state powers off, and won't respond anymore. Handle that once when entering sd_do_command(). Remove condition always true in sd_cmd_GO_IDLE_STATE(). Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index fbdfafa3a6..7533a78cf6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1081,10 +1081,8 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) /* CMD0 */ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) { - if (sd->state != sd_inactive_state) { - sd->state = sd_idle_state; - sd_reset(DEVICE(sd)); - } + sd->state = sd_idle_state; + sd_reset(DEVICE(sd)); return sd_is_spi(sd) ? sd_r1 : sd_r0; } @@ -1579,7 +1577,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (sd->state) { case sd_ready_state: case sd_identification_state: - case sd_inactive_state: return sd_illegal; case sd_idle_state: if (rca) { @@ -1800,6 +1797,11 @@ int sd_do_command(SDState *sd, SDRequest *req, return 0; } + if (sd->state == sd_inactive_state) { + rtype = sd_illegal; + goto send_response; + } + if (sd_req_crc_validate(req)) { sd->card_status |= COM_CRC_ERROR; rtype = sd_illegal; From patchwork Thu Jun 27 16:22:27 2024 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: 807819 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp889723wrn; Thu, 27 Jun 2024 09:25:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX8oC7nIf4OStQH1i/yqxosC65fOjcRbB53bISmJCKhGpzz+i4ijnBo09XfqhoUMK+2WR/dy3jp1Cqo2eqgLeS2 X-Google-Smtp-Source: AGHT+IHeDYTU1Il/Yuw97Qkt9pnjs7dPqn6n4HswCOhuhafUMxZO9eCAumvDWz4Zss9gg+rG8gU1 X-Received: by 2002:a05:620a:2903:b0:79d:55f0:d09a with SMTP id af79cd13be357-79d55f0d424mr512907785a.25.1719505538102; Thu, 27 Jun 2024 09:25:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505538; cv=none; d=google.com; s=arc-20160816; b=PpKOpPo84sG1zeiJNwNKyMwSltktqfa7G0MTRT0KOkSVYdyZiCQbq5eKU3DyN0+f1q zlb+WAXPybIvjJsyIjQeW+7u/CNgBuFz+HuEKD84sla0whLOveQQ4IUYLQXS9NuvGACr C3TLIMnFHPSDXUIfC1SeyB3MynXropYWZ2R27NxZj0s4yBBchHrWarow7TmuG5JFNmTN Fkhiz7zE73Qn8xLujEM5uD5aEcGnU2jw84cJ7kGhf7kXJ/Wvld+DAjTgd9SoVHmgyfp/ sgZOC8DwsOdVWGdQdCJ5sbCm7aMIwET14dX8JmL3vDJfPUTmcarQrgk92NysvlfV4OBs SajA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hpSfmrc8id/iTbpDVauIfBux1xBlvB+2LTLQjc6fyJc=; fh=J5ku+V592sifDRR0DP/LvVzC5VDqkDqR46Xlv8eA1xM=; b=JzAAhb0qC0k29Fgy/47Ayapa9belhCnyRHBtb1Y6D9ph2haJgArOIagRpOSv1RI7/m HU30DIbxTOuMtiF3X+MHxrKTWlKtkPJNOlqKTPuynO+hzw1CcJrZrqLtxLQSbYeWX2vy j1Zv1wtoKX5piGasB5HkQ6VC3FVlvxDTiO7CAoxsBgfSzlRw0xMUzaHab5DaLRrxYim+ hJcDmT4JTQ0DbxNXyCPl0gjW1Dx9p311gWu804HUUhaO5Y8fMtgAZ0bpvcjxUK4p3PBS r3thzZWpokUvviSDjityL8E120Q/2B7XvdGI8zd7deubthmWCbAo/1O37+uCv6OESu8v o0Aw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hnptKduC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79d5c8c8155si177718485a.595.2024.06.27.09.25.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:25:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hnptKduC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrw3-0002GF-2y; Thu, 27 Jun 2024 12:25:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMrw0-000249-QI for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:25:20 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrvx-0002QO-9n for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:25:20 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-362b32fbb3bso5188079f8f.2 for ; Thu, 27 Jun 2024 09:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505515; x=1720110315; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hpSfmrc8id/iTbpDVauIfBux1xBlvB+2LTLQjc6fyJc=; b=hnptKduCGVkOFV7ctEM01LltMiXKWxcvAjpmSrHIp0YL8RvUqacvG36iXWUhjDt7hL fjTUl515muzKhBSXT02SVw3kkl5jJ/MOgf8behtfF68lGC9x3230Ai/lMXsvzo57oKrs 3wZTUqf6MjHSGSK8y8ev5e2wRcNJWDujQzi1LlnKqDxZt/uc+By8hlR4sJQqgqWI+aCJ /0J4hZgGv6Ku4SsMktdpNXXX0kD3cF007+lYbjuMZbIdwdmgoJiV9NAFl21Med7UDL+3 ap98wbrVWB5tkXv/rAyqCZDcSECO1XAZO0hJ4GO9ydNdbFlk+Z4d6mvHuXkv5h50CUlX XV3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505515; x=1720110315; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hpSfmrc8id/iTbpDVauIfBux1xBlvB+2LTLQjc6fyJc=; b=tlX5ZOmgadqBa9D8U71yHYWsRsUJ09mRbSfZEpCUycOhd/ntsTruNCCzcSd/zKWAbE Gl5EIiBSQ6aAv1+zn5l5kQ57QYb9fbKvKWj17baxG5qgS+dIb9FPrIB8LP4Uccy81h6L WzP3A38MS9qJmUl9LRQPopyOX11RcT4uzNWytTT/aXicT7bxQpVD5UHJobjWfkE9qNc5 /pzLVfnnX23/4lA2B3Ie10RqzaQmPAPssI4kWVNAdXxKc4Agqj842kfsqhBdTEc0BCtf 6bWdi9ITXqXQuD1C91s3LitYawPbBHpYnhhZayq5d9y676htdYNB5KMR5SQAb8rZFm/Q nGQQ== X-Gm-Message-State: AOJu0YyOwDKhlXChh8svnEcyE7GUccgGKu125WYzbC6fudgEMI8oH7R/ vyl9dIc9RHZrpaPpfvesnAKsA1aOvhvWVZXs6L7JzI33Xra+1duBaEOiiv+CB8pFX4lV36UEP8B 3WDA= X-Received: by 2002:adf:f50d:0:b0:366:e7aa:7fa5 with SMTP id ffacd0b85a97d-366e7aa803amr10705832f8f.1.1719505514940; Thu, 27 Jun 2024 09:25:14 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36743699aecsm2343316f8f.87.2024.06.27.09.25.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:25:14 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PATCH v3 12/17] hw/sd/sdcard: Restrict SWITCH_FUNCTION to sd_transfer_state (CMD6) Date: Thu, 27 Jun 2024 18:22:27 +0200 Message-ID: <20240627162232.80428-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org SWITCH_FUNCTION is only allowed in TRANSFER state (See 4.8 "Card State Transition Table). Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 7533a78cf6..8f441e418c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1205,6 +1205,10 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) if (sd->mode != sd_data_transfer_mode) { return sd_invalid_mode_for_cmd(sd, req); } + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd_function_switch(sd, req.arg); sd->state = sd_sendingdata_state; sd->data_start = 0; From patchwork Thu Jun 27 16:22:28 2024 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: 807820 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp889810wrn; Thu, 27 Jun 2024 09:25:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV+mcTsDcGVnYC7XSXkSDmRDEvIgEWS/Qr+QrwuH80LLyE4VQe3jiYxPUKsD+ca4a1asrEavy63+O15om3uUKkZ X-Google-Smtp-Source: AGHT+IG+UjkaNCpxZM+xWQxGOLMz6rxJ1fnKe7IdKCDQhshrUeI75sdQYn3algQWQ+iD3EM/6jgP X-Received: by 2002:a05:620a:2402:b0:79d:5972:a7f3 with SMTP id af79cd13be357-79d5972ab2fmr405792385a.69.1719505548900; Thu, 27 Jun 2024 09:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505548; cv=none; d=google.com; s=arc-20160816; b=sa22xcM9OC9miE4jkTBOSOMttGAlrGjPR5+0GFxK5wbtKH4jIkFRpWhR+Zaj+duX8g EtYL4Sl3qQ+Wy1rYQactyszP0T7phT2VRuiP+4vVjtFhX75g5FMBkF1fzIxWMEl8roHZ l7hMa5ldo3C5n9tciXpl5XukHYEe5CuTHTXsTc/gLRm1B2rc47zhniaRu5UVKX/UGG60 468ttoX7lJ0G7ZPJp3YBDM0EKD963US71G3xM6r4dWkBre+HYCyc9y7CL0o1zE1aRPId 9HpI5TVWWHOcAOSpyDU0YzZ85yXaqn6XRRaTx/vlwS5CwozRqSwjvBGJgYp9sqw1fAy/ lJ1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zk4YjB9lQI2zLem86by0CBqxXy4bvU8ycOt1g+Y0WQQ=; fh=J5ku+V592sifDRR0DP/LvVzC5VDqkDqR46Xlv8eA1xM=; b=H3H94xfoPluWim5HnILFP62pmVkO/CtTDidTtOHRbZz+DYMhDXBdNDfKfZoDmuI4tP +btDLFzEcl+1TAbbALb6jGqX/jOHHx1MoKFAwJRmT6iz0x+brrAzoDmGl9e7a69qFJki 3z9bR344o4Be0MzrwR8WUuLzyCaljPHELaqxeju67BISYv8ApKfLZxaQaI3Tp26u1FGp co0HjE6l9HjqJCb/DXFbk/1ksxwV/QqDaNxRFs9s+u0xxtAN2/1rvmLFjopx11964ifm +fYWPgVoIca8b8/xc5exyt1seJ6o2eu9QAe0HiKL+SRUmKD9/N8Ha/azYnDmQyDBl5ID TwSg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="h0QES/EN"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79d5c8b6a55si180483085a.388.2024.06.27.09.25.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:25:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="h0QES/EN"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrwM-0003KO-20; Thu, 27 Jun 2024 12:25:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMrwD-0002pk-Ot for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:25:33 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrw9-0002XK-Qe for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:25:33 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2ec0f3b9cfeso97501571fa.0 for ; Thu, 27 Jun 2024 09:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505525; x=1720110325; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zk4YjB9lQI2zLem86by0CBqxXy4bvU8ycOt1g+Y0WQQ=; b=h0QES/EN/cW4hVUVQ+eEtzCkcIu3eEXMWadNgcmK0lrKnArUNHvCE5Kz0E/lasdgoq +HdCtGCts3PDDQkXoEcnV3q7YoZMP8K2oCiu1GBKT8I1NG/eHEdscExni5yPeZbWWAKn mcvQUoo507u0LyBsOdIOvrSIB0EffLJLMpFqaFWZYDgIs7DvNihHAQaxBHaOJce8amej j2YXaknEJTSRfrOv2RI/9FChFvLDZd7Hu8lZW8iFh8uKQJe0inOlSdiDCg8E++AwNM+j xwAdeu1uD+tqbZ6ygMDFoSc3dad8CAtaN5BZSpcAsJPsgWzCyk3luTUU4Ane6hv0tMho aEhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505525; x=1720110325; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zk4YjB9lQI2zLem86by0CBqxXy4bvU8ycOt1g+Y0WQQ=; b=Yv4TiXZz9iEnvH7vfba0kebiz815A3IR8DoNB5r6a0hqELdRXSDM0NhtueuVqXz/4S TDs9S8y9SnOxQQRLvdqEP2VxB9faBJaI9F7eMc0HJDM/yJ1IrQQ2TBq6NmV5LjLZ6Jia wadMBFTiWgIlCok2ZD0TNDj7BMmW5blrqEdsPktsiMEBEwr8Bups0lRZwjnlP/HHR0kw /xvpiD4v+hgM+/yko23W5Gb+ARDkTzO2xge101SLWf97Ie/74QccSGkQ7lThHYqKpOlU +aiVbAIuoc1c00xbYH6E9dDWQ60JEiJEINhFi7zPZuCU5U3yv3WXccAiAeI9JjwHLdxG rtmg== X-Gm-Message-State: AOJu0Yw6S/+ofPnF0GhBu8xAb7TBqhIq6gkIhRqORjOzGovAnuvCj9LW CcCBH4l0JCZCG/VWqw4erEFzQPgi2uyuHkVJr4kjuOvr2y/43EbonZBMoOm4/yAzJssgfEpMuHq yMj4= X-Received: by 2002:a19:7612:0:b0:52c:d639:dd4b with SMTP id 2adb3069b0e04-52ce06442eamr8285193e87.23.1719505523361; Thu, 27 Jun 2024 09:25:23 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42564bc4f70sm36674055e9.39.2024.06.27.09.25.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:25:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PATCH v3 13/17] hw/sd/sdcard: Add direct reference to SDProto in SDState Date: Thu, 27 Jun 2024 18:22:28 +0200 Message-ID: <20240627162232.80428-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=philmd@linaro.org; helo=mail-lj1-x22e.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-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Keep direct reference to SDProto in SDState, remove then unnecessary sd_proto(). Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 8f441e418c..aaa50ab2c5 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -116,6 +116,8 @@ struct SDState { uint8_t spec_version; BlockBackend *blk; + const SDProto *proto; + /* Runtime changeables */ uint32_t mode; /* current card mode, one of SDCardModes */ @@ -154,18 +156,11 @@ struct SDState { static void sd_realize(DeviceState *dev, Error **errp); -static const struct SDProto *sd_proto(SDState *sd) -{ - SDCardClass *sc = SD_CARD_GET_CLASS(sd); - - return sc->proto; -} - static const SDProto sd_proto_spi; static bool sd_is_spi(SDState *sd) { - return sd_proto(sd) == &sd_proto_spi; + return sd->proto == &sd_proto_spi; } static const char *sd_version_str(enum SDPhySpecificationVersion version) @@ -1044,7 +1039,7 @@ static bool address_in_range(SDState *sd, const char *desc, static sd_rsp_type_t sd_invalid_state_for_cmd(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: CMD%i in a wrong state: %s (spec %s)\n", - sd_proto(sd)->name, req.cmd, sd_state_name(sd->state), + sd->proto->name, req.cmd, sd_state_name(sd->state), sd_version_str(sd->spec_version)); return sd_illegal; @@ -1053,7 +1048,7 @@ static sd_rsp_type_t sd_invalid_state_for_cmd(SDState *sd, SDRequest req) static sd_rsp_type_t sd_invalid_mode_for_cmd(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: CMD%i in a wrong mode: %s (spec %s)\n", - sd_proto(sd)->name, req.cmd, sd_mode_name(sd->mode), + sd->proto->name, req.cmd, sd_mode_name(sd->mode), sd_version_str(sd->spec_version)); return sd_illegal; @@ -1062,7 +1057,7 @@ static sd_rsp_type_t sd_invalid_mode_for_cmd(SDState *sd, SDRequest req) static sd_rsp_type_t sd_cmd_illegal(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Unknown CMD%i for spec %s\n", - sd_proto(sd)->name, req.cmd, + sd->proto->name, req.cmd, sd_version_str(sd->spec_version)); return sd_illegal; @@ -1073,7 +1068,7 @@ __attribute__((unused)) static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) { qemu_log_mask(LOG_UNIMP, "%s: CMD%i not implemented\n", - sd_proto(sd)->name, req.cmd); + sd->proto->name, req.cmd); return sd_illegal; } @@ -1166,7 +1161,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) * However there is no ACMD55, so we want to trace this particular case. */ if (req.cmd != 55 || sd->expecting_acmd) { - trace_sdcard_normal_command(sd_proto(sd)->name, + trace_sdcard_normal_command(sd->proto->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); } @@ -1185,8 +1180,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_illegal; } - if (sd_proto(sd)->cmd[req.cmd]) { - return sd_proto(sd)->cmd[req.cmd](sd, req); + if (sd->proto->cmd[req.cmd]) { + return sd->proto->cmd[req.cmd](sd, req); } switch (req.cmd) { @@ -1632,12 +1627,12 @@ static sd_rsp_type_t sd_app_command(SDState *sd, SDRequest req) { sd->last_cmd_name = sd_acmd_name(req.cmd); - trace_sdcard_app_command(sd_proto(sd)->name, sd->last_cmd_name, + trace_sdcard_app_command(sd->proto->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); sd->card_status |= APP_CMD; - if (sd_proto(sd)->acmd[req.cmd]) { - return sd_proto(sd)->acmd[req.cmd](sd, req); + if (sd->proto->acmd[req.cmd]) { + return sd->proto->acmd[req.cmd](sd, req); } switch (req.cmd) { @@ -1928,7 +1923,7 @@ void sd_write_byte(SDState *sd, uint8_t value) if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION)) return; - trace_sdcard_write_data(sd_proto(sd)->name, + trace_sdcard_write_data(sd->proto->name, sd->last_cmd_name, sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { @@ -2083,7 +2078,7 @@ uint8_t sd_read_byte(SDState *sd) io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; - trace_sdcard_read_data(sd_proto(sd)->name, + trace_sdcard_read_data(sd->proto->name, sd->last_cmd_name, sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { @@ -2227,7 +2222,9 @@ static const SDProto sd_proto_sd = { static void sd_instance_init(Object *obj) { SDState *sd = SD_CARD(obj); + SDCardClass *sc = SD_CARD_GET_CLASS(sd); + sd->proto = sc->proto; sd->last_cmd_name = "UNSET"; sd->enable = true; sd->ocr_power_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sd_ocr_powerup, sd); From patchwork Thu Jun 27 16:22:29 2024 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: 807821 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp889833wrn; Thu, 27 Jun 2024 09:25:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUCTS02phYgphZjLPRJOyedesEfkJskLf5N6zlB5PfXTA2YUpAUK8SC+o+AwxcCaR4knmqSmgWL1SE+IaU1u9lL X-Google-Smtp-Source: AGHT+IE9nKkZhoJ+ZEzkl1C+lUjyOqAUDh9+0uV/md9k3Iiurk+MTDhT6xI2X1n8wVEHw5FXWadh X-Received: by 2002:a05:620a:29c3:b0:797:9c76:328d with SMTP id af79cd13be357-79be0d7b664mr1734246785a.61.1719505551285; Thu, 27 Jun 2024 09:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505551; cv=none; d=google.com; s=arc-20160816; b=MRWxmQWRig6p/7jbGLxvWJImD5RhCV5Gg5xRW9Updn1O9/JQnyjzeQdtaNycanEgeL TFPYt/umv1ma47XYVBHF4sUZtfX2EOBkAwWK9x0VqpSNj+SW1uDjJRKHqLKcIAhrHgdn CovTOd5B4RN1Sc8QNoomHuPOOakR8NVsjjZeQzP9cwUfEEdoZoGsDJp/El8DP/3wFYGM TwtEOUqIe0j5O7vYZjwYT2+Y7t/4xGabQjhaFA4lzOGY2DJBmvhwrt02mv4O3afHOzdb +hcvUnWx7ddMqLUFcHhP6XlFe8xfxF7zWrIzFDWFDEe5Uz3TzB/ewcCldb5JKi/BOzVh nL+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DSF5Ro3NaUsJXtCUAFWLr+3NgzU6nFSUILhMkj2n5D4=; fh=8jOvX9DS+px49YFUnSrE9eUhtKcsfZHf0VO2bCskldA=; b=tEHQ53ZPOWEPWdYJTJ3wTtDJWjbdmZZ+b8tDC43OeWbtwqouCQsyBRW1yW5OY8hVTz ibYwXfnIYxCpJLhh8On2oLJX88eyUQ/dM+rZXzITCOIf2aT1edzFvXCft9EErIuHKJsF HQJt2NszBjaeu+B4zD0p23ObLtZScxoXx8VTdjRVnqKQOMjEoct3nZVNwRjxRpXXGgn/ SnG/w7EH+W+6H4hKSpWb0QtEc0buZjHDtHI7G/739E91wp0wUrLJfp/Y7+ag4jD1tDMo 3SMH69KwrdiDp9NK8JL5eO1WT8xPNXn2EtMkG31GKeNYLuMMo+gu+tIcvM+9lqCxFuWS ERRg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VRTLmw2K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79d5c7bd818si161291985a.160.2024.06.27.09.25.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:25:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VRTLmw2K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrwT-0004EN-9Z; Thu, 27 Jun 2024 12:25:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMrwO-0003iz-5W for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:25:44 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrwJ-0002d1-KG for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:25:42 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-363826fbcdeso5900204f8f.0 for ; Thu, 27 Jun 2024 09:25:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505535; x=1720110335; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DSF5Ro3NaUsJXtCUAFWLr+3NgzU6nFSUILhMkj2n5D4=; b=VRTLmw2Kl7Psz2fJJmQvLVcfBWkyXFy7RNqZ2CiL1cd/wxLbsNePqyzT3SatEzCGLq ZOdhDuNshAIun+hWnUpgFP1XrOxY7+BlE7WBpPu7NqwXAuAZW3ls73bh0plkc1xQu35n RnDUSnc452/zeszBtOLdrqe4K8EpfwhRWBRZVFwukNPIwcUYGpwO84lTYkAAIzTLNq6k +k9pPHJePki5DmfklbxS9uJpxuGwsZbpnXxtECvNJORbmS0jbxafDPrvNrQlGeko/rhL 5CPq7Vn8QNAjmR9x9MjI0HzNCSKjlHadeVY4jnrSTgYznvCIuf3dc7EJNVOFL7RnS/lO whrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505535; x=1720110335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DSF5Ro3NaUsJXtCUAFWLr+3NgzU6nFSUILhMkj2n5D4=; b=vAHgYyhiIA1sxjYXsZvLim9iPEJkv7hpkqHBjyYFgQSZ/tkTCfVAJ+s5oOMQvvltxX GzZPI1iaxPsmEXlleVlZ4nhlGM8SiE4I/vQ3fpNwey5QwJj7pKUJFpnTE1EhAUMOyMJ1 qmU2wCIYHQWN5CG7s20cCwjvuXXALyrVAuMK2LqGzHkuoYW6ZxUSYiHn/E41v62qvXt4 iIfc1xsPdmcG8MXnsrLqP7WPs0wad9k+oNYIeYehKC1+x7OaDglcNScxq6jaxpaEFXdi DcaHSMVZght1PD//pzQT3O41/PWcRzhrwxUct5qe2cAiAX+enrplEG+xW1tWrOmAh6uo UrAg== X-Gm-Message-State: AOJu0Yz3wsdEuQFTmBFKWEQg6/N4w+g6nR0VePuLR3LdEnzl7gRT03/0 HNWQ6LqMg5nTNOfPxQJN8T2ZPk8L1q72ofDxEgJf+RJU70QxbjZNi47UNYLyOPjPoTbIY0oLUIh 5/Ns= X-Received: by 2002:a05:6000:2c5:b0:366:e89c:342b with SMTP id ffacd0b85a97d-366e89c34bcmr13353327f8f.52.1719505535283; Thu, 27 Jun 2024 09:25:35 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674369ebaesm2348335f8f.91.2024.06.27.09.25.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:25:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 14/17] hw/sd/sdcard: Extract sd_blk_len() helper Date: Thu, 27 Jun 2024 18:22:29 +0200 Message-ID: <20240627162232.80428-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Extract sd_blk_len() helper, use definitions instead of magic values. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index aaa50ab2c5..5997e13107 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -603,6 +603,14 @@ static void sd_response_r7_make(SDState *sd, uint8_t *response) stl_be_p(response, sd->vhs); } +static uint32_t sd_blk_len(SDState *sd) +{ + if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { + return 1 << HWBLOCK_SHIFT; + } + return sd->blk_len; +} + static uint64_t sd_req_get_address(SDState *sd, SDRequest req) { uint64_t addr; @@ -2076,7 +2084,7 @@ uint8_t sd_read_byte(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_blk_len(sd); trace_sdcard_read_data(sd->proto->name, sd->last_cmd_name, From patchwork Thu Jun 27 16:22:30 2024 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: 807822 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp889912wrn; Thu, 27 Jun 2024 09:26:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVHAVCh3qHI/h62kgRQSRhpIB33mbHAefaSfVyRTTuDFEaGvW3Fp2UlTw98VzDeDdZN6BiAI69tDRqWIwR1EOkK X-Google-Smtp-Source: AGHT+IFRogq4BP2cV+qqDjueEaoP+vBdtkEGxmta288aUzA00aVvgeCd+ccIGXnVpqnMUC89VR1N X-Received: by 2002:a0c:e14a:0:b0:6b0:86ab:fe89 with SMTP id 6a1803df08f44-6b5364489bamr157662306d6.33.1719505562158; Thu, 27 Jun 2024 09:26:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505562; cv=none; d=google.com; s=arc-20160816; b=ZWwzmsYoyDwZH++LeRFg1oqqzLxSU3NSqvoP7SxLGhcCmyogYykPZYgbEwdG/KbdQk EqkZoRG3SkOUDqhNTAwHpNxkEAOIBU6dGib+mDhAt1qu911dThRl62f63QCcDxvLlSJ8 UQIf5wLx3Ht4QJKxEAAj8RBC6MR2idQe1zmsS7/hVyfimEfyssbiHi2vBOOwzw2e12j+ YOUNHuLpEw/AAivh8DmUTNzeJdeV5vJqfQSXAlSNQvHyWufF4+1+dmrpzAh+3+D8z69h W2aXUpBYObZo76aOXKgPV8aJy/Wm2XE2xkkHnK6KRwcVdY2cQYmDZpwh+g0gqP5U5Opo hRNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FRec2147tzGGJgDwnAFCM7MdLQrzjYCwJA0fQ2k29gM=; fh=kmMhhBjA2qEaw6yrRgKNWBFhwDwd8emmmDkErGrPn2M=; b=kqZP3wIq14BcgZA/licfQu3ET5vwD0J9+DdmAEO+5hyiH9rDLf8e4t7UXbGqbqDX+Q ZwGJIczOrBxNdjO51/2IvoFcQIYLzRcZDsxO6rZ5e0LoIIjvPX46jtNFeYY73BrFnXaO k6VUjx7DP5P2+83DUFwJNGpD+6H7lPQvIfx0ZXwrOQA9JoTM2jLXSJaaZFr5dejvQM3B iQbl1F3v8ycH90OAShOgGLISZQ+f0GcKWAcK2EUq8NxP/cYdSJipE6cYvNRcUhA40NOp LU5mOuh2ukWZr8YLjMP6yeuN33XuJnJYqQW2NB4CZS6twzWbw/Q6doxxdKrqkOWkzPUI ylAA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j2bDukah; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e36c664si28386d6.156.2024.06.27.09.26.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:26:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j2bDukah; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrwY-00054d-L9; Thu, 27 Jun 2024 12:25:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMrwW-0004mA-AZ for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:25:52 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrwT-0002fs-2o for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:25:51 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-424acfff613so25445565e9.0 for ; Thu, 27 Jun 2024 09:25:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505547; x=1720110347; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FRec2147tzGGJgDwnAFCM7MdLQrzjYCwJA0fQ2k29gM=; b=j2bDukah92E5GI+Es1yyT9ols8Oga1rWffQYj8kU3o2VANhxXbCuWj+1SXVdPe3KTr geUZ/U67fZE+VFAoDnrWD1wTiYqiYa2q5Z4IwJs5sKMOm6qjWAkNgx/GPBqI0/XDVT/J ywgaes7IvzXol3uLJT7EEAdb9Bg3S6FbJQO4nqBM9Aa3soGKdzxAJjv0KIHf/bo4iF4d Scm4eHZUzHbk5TBt/xFkO+CZXYR6/SfHeOAWh8BQRZ6Opw244uRZomNrrTcv+UqzP7NX SETtnAjcI8f3ULD45a9T+ehVAs8Oh3FkUIYbjt52sWjQODxpQFFXG0wswbPubCOrVLgg 9WVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505547; x=1720110347; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FRec2147tzGGJgDwnAFCM7MdLQrzjYCwJA0fQ2k29gM=; b=YRtsQTzIDrpcjai4Ok2u9KgxvOLQd5IMubkYfYtwyaAA4AJvjhD4o1hbA6upELUexc jw8PDh2z3CaQCyYv3D8eQlBuseLJEQCQfF+H/GeJzfqL3CSUjXTzrqstMxDLt0775NA6 cTa/ghTv3PkkXAAiqLzdDEcjrj3jVEhwa1lNlRUfNFOKYfaT+05EpwLVsuDFq04uJy+h wh8tB4eAM/qxFGfL7PVGFEHME2VR1yd13a8WHQ+hj9F3w+IZMQlBuJ7oXF9LxybqdSfy 0qx4GhkM07z6ESNAbUetYQWKrYA0e1oCDG+rsKfXORJ3z5audVaex76rm/jpxMx6Krpk LtwA== X-Gm-Message-State: AOJu0Ywr6sj8He2pNQD+KCuPw9j2lgFV3QYC3Mv/j7HxjEa3GI6QgPZT mPuO6JVBU3njAqMZ26P1QuhXMaTV2gwtbxnv+qpbEuRw5E+99ufKbmw52E5/Q9f8aP/MGd333+g cyTo= X-Received: by 2002:a05:600c:3b84:b0:425:5f90:ed4a with SMTP id 5b1f17b1804b1-4255f90ede3mr38178775e9.35.1719505547379; Thu, 27 Jun 2024 09:25:47 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8424698sm75979115e9.29.2024.06.27.09.25.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:25:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , Shengtan Mao Subject: [PATCH v3 15/17] tests/qtest: Disable npcm7xx_sdhci tests using hardcoded RCA Date: Thu, 27 Jun 2024 18:22:30 +0200 Message-ID: <20240627162232.80428-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Disable tests using 0x4567 hardcoded RCA otherwise when using random RCA we get: ERROR:../../tests/qtest/npcm7xx_sdhci-test.c:69:write_sdread: assertion failed: (ret == len) not ok /arm/npcm7xx_sdhci/read_sd - ERROR:../../tests/qtest/npcm7xx_sdhci-test.c:69:write_sdread: assertion failed: (ret == len) Bail out! See https://lore.kernel.org/qemu-devel/37f83be9-deb5-42a1-b704-14984351d803@linaro.org/ Signed-off-by: Philippe Mathieu-Daudé --- Cc: Hao Wu Cc: Shengtan Mao Cc: Tyrone Ting --- tests/qtest/npcm7xx_sdhci-test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/qtest/npcm7xx_sdhci-test.c b/tests/qtest/npcm7xx_sdhci-test.c index 5d68540e52..6a42b142ad 100644 --- a/tests/qtest/npcm7xx_sdhci-test.c +++ b/tests/qtest/npcm7xx_sdhci-test.c @@ -44,6 +44,7 @@ static QTestState *setup_sd_card(void) sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0x41200000, 0, (41 << 8)); sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0, 0, SDHC_ALL_SEND_CID); sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0, 0, SDHC_SEND_RELATIVE_ADDR); + g_test_skip("hardcoded 0x4567 card address"); sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0x45670000, 0, SDHC_SELECT_DESELECT_CARD); @@ -76,6 +77,9 @@ static void test_read_sd(void) { QTestState *qts = setup_sd_card(); + g_test_skip("hardcoded 0x4567 card address used in setup_sd_card()"); + return; + write_sdread(qts, "hello world"); write_sdread(qts, "goodbye"); @@ -108,6 +112,9 @@ static void test_write_sd(void) { QTestState *qts = setup_sd_card(); + g_test_skip("hardcoded 0x4567 card address used in setup_sd_card()"); + return; + sdwrite_read(qts, "hello world"); sdwrite_read(qts, "goodbye"); From patchwork Thu Jun 27 16:22:31 2024 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: 807823 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp890151wrn; Thu, 27 Jun 2024 09:26:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV/exX1f7lxuS+5s6T+2ahE7F2ZAW7IVF/CSnOpmNmF/aau1puGD/bp6O3/feJwa2Hd5MhrSXJD9AduTykIGO5U X-Google-Smtp-Source: AGHT+IHSMaQOjlN0UwnfUY747r3+bfoWkFnMHccScmfNYSUCItsOagcRC/QYktXl6mCHOBV7yzvU X-Received: by 2002:a05:6214:1846:b0:6b5:81ac:6b83 with SMTP id 6a1803df08f44-6b58d3ad6c9mr35505716d6.35.1719505588387; Thu, 27 Jun 2024 09:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505588; cv=none; d=google.com; s=arc-20160816; b=vchQOWMVmusijVWHAnlnTH8bQT48RQUI6BYYcLNCu4B/BZWD8NM8DJmLCQzwY+8yTU WmcURgaPKsOideyuFV2yKaouvWamgZrFQSOiAOvWFulWBHPpvWor1ZuAnEztiIE8wOtG ubH1536paCVXw7G1tEjW8vrnYwCTa4RvthKI7OFG+YEu/07eMX/D9c8V/0RQ9j5P76jA PrdDFqKPUXm1lygq2Jz79+LtSLwSa+eNMo7plhETLOyWS4e3yc5bcg9vpLm1xl0vuZAj ublLIZbUxbPXu5yhsWwXQpMHt8gA1s9nmqOhJF+UlGtGEpus1mwWAC9gar8FVi6FC3Ue acDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ra/Td8NG8gR6eO/UQBLHxrI5ovJA5Z/mboPyl147upk=; fh=J5ku+V592sifDRR0DP/LvVzC5VDqkDqR46Xlv8eA1xM=; b=FE01EsFQR88vPse06fNaaL7KAutOOQV6fJ+3FeW9g+yxn0JrXBTQWqNQLjxYjXdDfk ur7YtKwYWmxlwTY6yB3keAzvaZOlUKbfaOCvWLvJd1Ek4NVaOaNr7HqCaE7x/qFU6JEk rC+1LKV0QYzsOaHDelXgjK64NY/o0UHSkIVirX9xpnSGp0+ReXcA7vegN5jiRLMO2A8z 77pKc0e6E2r78gJ2byrId755axhUlkI5mK0A2+hAlqvpdkR8CgsZkd5IlOs8j77cXP4T wd3AnRRTRbWBLsE/TQAXKFZLOgsOfxl+d3sCHGhNfyagkb2v9DXcxFbN5Q2sxqCSxCgm c+Iw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pPa+hjsq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b592651512si15595826d6.209.2024.06.27.09.26.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:26:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pPa+hjsq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrwq-0005tA-1x; Thu, 27 Jun 2024 12:26:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMrwh-0005d6-Un for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:26:05 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrwf-0002j6-PP for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:26:03 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-421bb51d81aso65005565e9.3 for ; Thu, 27 Jun 2024 09:26:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505559; x=1720110359; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ra/Td8NG8gR6eO/UQBLHxrI5ovJA5Z/mboPyl147upk=; b=pPa+hjsqUuQnpThuuiHvwrVcrFZrth8o3ViEH5sY8OQAeJtfHHghD8g+E79GiiNFAp iDZSXyx0cO9MDUXU3VErh/UgwH/qwq3tsrNgU0GoP3iQz0dXLpU0AxYAsCxCaGTaZF/3 KfPIRFpYVD3hJfDmcYHOVWzI+Cyfk6hKAU5/iCcxAbAnP77q0/VM0yoFOXxsuNLH084/ vN04xHepoCyyaueGRHHVH4ZX+57TEXFU2e4eG2A+Joc0+aQQ1SNXx37VoscYzMYpK+Gi E0HDMdPvU8nG3nwhY8Tb/SALzu4nTM9sl40EbEujaFzL7rTs2zYD3LAxV7GxYlM4fNS0 qqaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505559; x=1720110359; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ra/Td8NG8gR6eO/UQBLHxrI5ovJA5Z/mboPyl147upk=; b=jFG91XiZAhQW7mruBLRz/8W3ThulO2bHIOgTh6JOw+oAnBbrW9PGxTNna1rbgmW2IM f/jhyRhuPzWRzXqJNN3RRhoztYWkCuD6+JHPStCYKc7M/ULLOZFl3gAfdU56QVXZGASJ UcsK28/YyHp9gnPiWZwjcjaHrohqWCvrHfn4Pv0k10Gkd6RZfRT3y+CDz/ZstvACPU1l rvGMfohvexR6ncNe/AyknqyCxb9SPhZKulf+C7XwidD87f0J2rp4eRuV7xWGxj9qQbYB 7jL/7XQSp416pGHTmr5BSJn75QzBl9UW3v6eLxGU5j/HOY0a5f4UP2zSz9dCoiH9PjAi Chtw== X-Gm-Message-State: AOJu0YxQt2z6L4457zvgkLGD7Ww7dTb0Rg8llK45Xm+uEvHkPm3T+RKa YkzGo8uA4XjXCB0S8BT+CrY3aJ207IGE+UDq1q146tKHb57uYxY/4+mNC+5wDpJd6vW9gtCr/Pj catI= X-Received: by 2002:a05:600c:3c8d:b0:424:8ef1:816a with SMTP id 5b1f17b1804b1-4248fe36550mr88926515e9.5.1719505559497; Thu, 27 Jun 2024 09:25:59 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c84248afsm72601705e9.31.2024.06.27.09.25.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:25:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PATCH v3 16/17] hw/sd/sdcard: Generate random RCA value Date: Thu, 27 Jun 2024 18:22:31 +0200 Message-ID: <20240627162232.80428-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Rather than using the obscure 0x4567 magic value, use a real random one. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 11 ++++++++--- hw/sd/trace-events | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5997e13107..d85b2906f4 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -46,6 +46,7 @@ #include "qemu/error-report.h" #include "qemu/timer.h" #include "qemu/log.h" +#include "qemu/guest-random.h" #include "qemu/module.h" #include "sdmmc-internal.h" #include "trace.h" @@ -488,9 +489,10 @@ static void sd_set_csd(SDState *sd, uint64_t size) /* Relative Card Address register */ -static void sd_set_rca(SDState *sd) +static void sd_set_rca(SDState *sd, uint16_t value) { - sd->rca += 0x4567; + trace_sdcard_set_rca(value); + sd->rca = value; } static uint16_t sd_req_get_rca(SDState *s, SDRequest req) @@ -1113,11 +1115,14 @@ static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req) /* CMD3 */ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) { + uint16_t random_rca; + switch (sd->state) { case sd_identification_state: case sd_standby_state: sd->state = sd_standby_state; - sd_set_rca(sd); + qemu_guest_getrandom_nofail(&random_rca, sizeof(random_rca)); + sd_set_rca(sd, random_rca); return sd_r6; default: diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 43eaeba149..6a51b0e906 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -43,6 +43,7 @@ sdcard_response(const char *rspdesc, int rsplen) "%s (sz:%d)" sdcard_powerup(void) "" sdcard_inquiry_cmd41(void) "" sdcard_reset(void) "" +sdcard_set_rca(uint16_t value) "new RCA: 0x%04x" sdcard_set_blocklen(uint16_t length) "block len 0x%03x" sdcard_set_block_count(uint32_t cnt) "block cnt 0x%"PRIx32 sdcard_inserted(bool readonly) "read_only: %u" From patchwork Thu Jun 27 16:22:32 2024 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: 807824 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp890279wrn; Thu, 27 Jun 2024 09:26:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXbov0njiYCWYFaOHb9od2hC31kA8sNJqUm+Qvcdk2oB3FUH3BGR0P+FVbpYf78xslEWKtjdb2daJ7DLpCjs2n+ X-Google-Smtp-Source: AGHT+IFr4yPCy3ZZjL90I7tIR2Mt95jniaw5mjFLfyppqIl+m4HMqzQbcL9iwJv4WO6lETOBSwLg X-Received: by 2002:a05:6102:302e:b0:48f:95cd:e601 with SMTP id ada2fe7eead31-48f95cde6b0mr1524554137.25.1719505601590; Thu, 27 Jun 2024 09:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505601; cv=none; d=google.com; s=arc-20160816; b=ayiNo+9m0tp2oxw3mEBJ16G0kT5+Mf2NdkXBWY7IE9xLctZgpLF4FJH8B68RnFOiyq YCzNhDbMWiKKxLRTITXhv/RJRvrgB6hNkelc9u85x785486GbK/iG60+TybBjnsDGGoh kp9G7g5T3zZjIUmXuAX+KfOHpwacp4pDL+x8RTgdMc/Ol8oyQNr/JxNesqq+xrZ4p1J+ cYheSfYRRB0fxTqT3b832RDvtDlDg+gjyRVoukLK8Sm3cbL4KuBJgVtx1baKY6VontRy DZBt5nIdRDSSo9HG0rNvF1FVJh0OgwCEy6rJp1OQna0ZLIZZn1tSVuoR8ol+bGRaPgLZ Rlgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lMFKG2q5UbCp1Dyyq8cGhI62qgCIuzAq7XqP054066E=; fh=J5ku+V592sifDRR0DP/LvVzC5VDqkDqR46Xlv8eA1xM=; b=Pv4z6VzYHx3TJuR9KqEelmMVcKiI3eoXybbYw85RdOQJ16VG4m5igb6J0iZM9oRqVI NWIqXk3J3serP15zy4B2BLOIN/lwG6dXoG5DTxnQVqN+5rfGMwUOExmlImh0uPWHgtmz MHfZcOe/8aPKAs4CjJ8dkjqmVnZyWmsuvGwLF2PJtxwobcq7gxVrrZjpwoYpZUqrP+wR HO7zp8j8xHpjxT2aeavxpXRORzzkpnLglfyIKEbyc+c3fpsHnFs4sAPTa5cKPX4dNBLR 6Sg34DfYOAfjnLS3bS0HrSK67i/JR8b4PqdpP8ByKHQCCfwMo6S88KnCvLtPRwiZlMJW cLOA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FScgS59z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59291c3bfsi16087986d6.565.2024.06.27.09.26.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:26:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FScgS59z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrww-0006fD-L7; Thu, 27 Jun 2024 12:26:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMrwu-0006Pq-Tm for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:26:16 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrws-000343-Mq for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:26:16 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42563a9fa58so9445295e9.0 for ; Thu, 27 Jun 2024 09:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505572; x=1720110372; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lMFKG2q5UbCp1Dyyq8cGhI62qgCIuzAq7XqP054066E=; b=FScgS59ze2BffdTft0IpCZiMhgMvD6fe/hZE0YkksTjOwgDgxcFwtXIjOA2HTg4t6H 9G3ebbC8S9uwFLUiwMjTrebsTbC0Js9xm0hITFDrvLebNommg/BSo+hJJxHGe44NrhdE wXVyCrSkbY0pnMVWH+rNRuYJS9r5FhINGHMMM6e32PL8m0k9USLY9fx4H9deH39Xl5qQ X4cI23ar/UbCIpRRC3Hr9O8VWOh3pTMoeb6inYS/2+e+XxaaJtTYPcNNEuQlJCQFJdol YjKbtW36aB5AHdGxr12emqmpE2HihvZ2z2oeIQ/LcpVZXYZYPbmnt0OTMYE1VfITqgYM /GCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505572; x=1720110372; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lMFKG2q5UbCp1Dyyq8cGhI62qgCIuzAq7XqP054066E=; b=qE0H9LS23KACZd2bI3PxpmIahobqdNOn29BMOUCmcQkd+xLQPwctbQLf5mX00U4xEQ YOReGLxrCYPikvumhq5U2aFaPPEr4Ce2/ATVJpuGQCgBkmGbW9cz1APHoDBc9F+HDCwT AO6edBznWt0+PZYM4RyIAI26pvlRS6K8J5s6r1m2LJ5EAIKVwRqyk9YwebPkxZ2JYZ4z wfbkoMX63EyrdfPJ1oE7zEKCnCAao2Sg7EvEkQO9Fh+TVqEg4gKwMdLRAjGa5sv7ReiE hYfOc6O9sRWrA+rR2ZrwxWRfT4RFu+ApAnOmr0H3se2kKY7iVh39ycHNWrv7JHwGTGZ4 R/cA== X-Gm-Message-State: AOJu0YzqpdoRp2X6MzOYT/AOgudr22WgfxU9zCJThx/mucnTShwZ95sv ibsxIGJ3gheegmDltEDCerQbvKOJ64fvz3BkkUL+3jwkjLrM6dxtICQ5nfKmV0CkD8ti6DI0Vx/ /ZXM= X-Received: by 2002:a5d:526d:0:b0:35f:b7c:5330 with SMTP id ffacd0b85a97d-366e4eddc42mr9294730f8f.31.1719505571937; Thu, 27 Jun 2024 09:26:11 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674357c1c8sm2395796f8f.9.2024.06.27.09.26.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:26:11 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PATCH v3 17/17] hw/sd/sdcard: Introduce definitions for EXT_CSD register Date: Thu, 27 Jun 2024 18:22:32 +0200 Message-ID: <20240627162232.80428-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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, UPPERCASE_50_75=0.008 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Cédric Le Goater Signed-off-by: Cédric Le Goater Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sdmmc-internal.h | 97 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/hw/sd/sdmmc-internal.h b/hw/sd/sdmmc-internal.h index d8bf17d204..306ffa7f53 100644 --- a/hw/sd/sdmmc-internal.h +++ b/hw/sd/sdmmc-internal.h @@ -11,6 +11,103 @@ #ifndef SDMMC_INTERNAL_H #define SDMMC_INTERNAL_H +/* + * EXT_CSD fields + */ + +#define EXT_CSD_CMDQ_MODE_EN 15 /* R/W */ +#define EXT_CSD_FLUSH_CACHE 32 /* W */ +#define EXT_CSD_CACHE_CTRL 33 /* R/W */ +#define EXT_CSD_POWER_OFF_NOTIFICATION 34 /* R/W */ +#define EXT_CSD_PACKED_FAILURE_INDEX 35 /* RO */ +#define EXT_CSD_PACKED_CMD_STATUS 36 /* RO */ +#define EXT_CSD_EXP_EVENTS_STATUS 54 /* RO, 2 bytes */ +#define EXT_CSD_EXP_EVENTS_CTRL 56 /* R/W, 2 bytes */ +#define EXT_CSD_DATA_SECTOR_SIZE 61 /* R */ +#define EXT_CSD_GP_SIZE_MULT 143 /* R/W */ +#define EXT_CSD_PARTITION_SETTING_COMPLETED 155 /* R/W */ +#define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */ +#define EXT_CSD_PARTITION_SUPPORT 160 /* RO */ +#define EXT_CSD_HPI_MGMT 161 /* R/W */ +#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */ +#define EXT_CSD_BKOPS_EN 163 /* R/W */ +#define EXT_CSD_BKOPS_START 164 /* W */ +#define EXT_CSD_SANITIZE_START 165 /* W */ +#define EXT_CSD_WR_REL_PARAM 166 /* RO */ +#define EXT_CSD_RPMB_MULT 168 /* RO */ +#define EXT_CSD_FW_CONFIG 169 /* R/W */ +#define EXT_CSD_BOOT_WP 173 /* R/W */ +#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ +#define EXT_CSD_PART_CONFIG 179 /* R/W */ +#define EXT_CSD_ERASED_MEM_CONT 181 /* RO */ +#define EXT_CSD_BUS_WIDTH 183 /* R/W */ +#define EXT_CSD_STROBE_SUPPORT 184 /* RO */ +#define EXT_CSD_HS_TIMING 185 /* R/W */ +#define EXT_CSD_POWER_CLASS 187 /* R/W */ +#define EXT_CSD_REV 192 /* RO */ +#define EXT_CSD_STRUCTURE 194 /* RO */ +#define EXT_CSD_CARD_TYPE 196 /* RO */ +#define EXT_CSD_DRIVER_STRENGTH 197 /* RO */ +#define EXT_CSD_OUT_OF_INTERRUPT_TIME 198 /* RO */ +#define EXT_CSD_PART_SWITCH_TIME 199 /* RO */ +#define EXT_CSD_PWR_CL_52_195 200 /* RO */ +#define EXT_CSD_PWR_CL_26_195 201 /* RO */ +#define EXT_CSD_PWR_CL_52_360 202 /* RO */ +#define EXT_CSD_PWR_CL_26_360 203 /* RO */ +#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ +#define EXT_CSD_S_A_TIMEOUT 217 /* RO */ +#define EXT_CSD_S_C_VCCQ 219 /* RO */ +#define EXT_CSD_S_C_VCC 220 /* RO */ +#define EXT_CSD_REL_WR_SEC_C 222 /* RO */ +#define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */ +#define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */ +#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ +#define EXT_CSD_ACC_SIZE 225 /* RO */ +#define EXT_CSD_BOOT_MULT 226 /* RO */ +#define EXT_CSD_BOOT_INFO 228 /* RO */ +#define EXT_CSD_SEC_TRIM_MULT 229 /* RO */ +#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ +#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ +#define EXT_CSD_TRIM_MULT 232 /* RO */ +#define EXT_CSD_PWR_CL_200_195 236 /* RO */ +#define EXT_CSD_PWR_CL_200_360 237 /* RO */ +#define EXT_CSD_PWR_CL_DDR_52_195 238 /* RO */ +#define EXT_CSD_PWR_CL_DDR_52_360 239 /* RO */ +#define EXT_CSD_BKOPS_STATUS 246 /* RO */ +#define EXT_CSD_POWER_OFF_LONG_TIME 247 /* RO */ +#define EXT_CSD_GENERIC_CMD6_TIME 248 /* RO */ +#define EXT_CSD_CACHE_SIZE 249 /* RO, 4 bytes */ +#define EXT_CSD_PWR_CL_DDR_200_360 253 /* RO */ +#define EXT_CSD_FIRMWARE_VERSION 254 /* RO, 8 bytes */ +#define EXT_CSD_PRE_EOL_INFO 267 /* RO */ +#define EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A 268 /* RO */ +#define EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B 269 /* RO */ +#define EXT_CSD_CMDQ_DEPTH 307 /* RO */ +#define EXT_CSD_CMDQ_SUPPORT 308 /* RO */ +#define EXT_CSD_SUPPORTED_MODE 493 /* RO */ +#define EXT_CSD_TAG_UNIT_SIZE 498 /* RO */ +#define EXT_CSD_DATA_TAG_SUPPORT 499 /* RO */ +#define EXT_CSD_MAX_PACKED_WRITES 500 /* RO */ +#define EXT_CSD_MAX_PACKED_READS 501 /* RO */ +#define EXT_CSD_BKOPS_SUPPORT 502 /* RO */ +#define EXT_CSD_HPI_FEATURES 503 /* RO */ +#define EXT_CSD_S_CMD_SET 504 /* RO */ + +/* + * EXT_CSD field definitions + */ + +#define EXT_CSD_WR_REL_PARAM_EN (1 << 2) +#define EXT_CSD_WR_REL_PARAM_EN_RPMB_REL_WR (1 << 4) + +#define EXT_CSD_PART_CONFIG_ACC_MASK (0x7) +#define EXT_CSD_PART_CONFIG_ACC_DEFAULT (0x0) +#define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1) + +#define EXT_CSD_PART_CONFIG_EN_MASK (0x7 << 3) +#define EXT_CSD_PART_CONFIG_EN_BOOT0 (0x1 << 3) +#define EXT_CSD_PART_CONFIG_EN_USER (0x7 << 3) + #define SDMMC_CMD_MAX 64 /**