From nobody Sun Nov 24 23:08:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719505694; cv=none; d=zohomail.com; s=zohoarc; b=nQbfzaefzPVgjT8PEOr+K2Zo32JrF5yqWbY9wIFAJEH6Pa6y3b4DRRBNQ41iZbwS/dCH94vpWHhpDuZ+y6FQYAO/54u6+g3JfBYxMOoIPK1reQqIzywNb3C44XXNEnqF5/GJmfjGkUoSu4s8mLLDj6sDbPq+SYmkbE3rOWd5Rj8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719505694; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/dkdp8a0v1eDrwEVEV8e/ROv9nmNjtoGPC9rjoBe3Zg=; b=VA0cO1yceQIHKnWH2WbTGqrA1er814bY+1H+lCydX8cNBl25ZJQQdyVI2vhydo5BU5JVnvg/9+yGx/DWaGJigYS/wrKYSRuyxnWMzXEM8mFGLPhigZHH4ny0UvGm+zK0u0rN3IaPFGJGxj+u6fbNfL4aCW8h9bBq9FNWF3TB5Wg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719505694144825.2573579391898; Thu, 27 Jun 2024 09:28:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMryT-0000YW-NI; Thu, 27 Jun 2024 12:27:53 -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 1sMryR-0000Vy-58 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:27:51 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMryO-0003Le-JW for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:27:50 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-36743a79dceso553688f8f.0 for ; Thu, 27 Jun 2024 09:27:48 -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-3674357fcb2sm2379487f8f.30.2024.06.27.09.27.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505667; x=1720110467; 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=/dkdp8a0v1eDrwEVEV8e/ROv9nmNjtoGPC9rjoBe3Zg=; b=QEeCDpnnxzodhiI+YlDudza8dfO+H9e5eSCLHeZz59J+MHjRKF4sWK3se+ydq8Or2C WEUuYsatW0ekNd7OhYsx9d9Rc82dVtc7dLywp0nBVSCeO+hFm6YxxJmcVWaxENWToTr2 3megdtH1bibyKptzl2IOTpeUhivUn3Tn3P3ydNS1b/19FUTyK3Ie1QabYEZkT4QynO8i KPESup6Uzhi0Hs06df7W2FRGIDt48Phu0DhnO9/4gHn0hdq2dpA/cErr5MF8heRFDkZl P4R7SkBUrgp5lYb3OlqhjWbZUowAaV3bf210uzkhL0YgNrIKcq+HpjNVhUeAJBA41XwE AWpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505667; x=1720110467; 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=/dkdp8a0v1eDrwEVEV8e/ROv9nmNjtoGPC9rjoBe3Zg=; b=sgrGIlhSPTT1iTP8GHtYyg1uGAJAoCe48lauuXAru4xGDJvs/C0wgQPJyqFPkliGEF ZNUECC/0BuexGCutMjA5ZBcNZ+oJNxRC0PbAJIVpyqaRuFdd38UrAcN/q5juEPVg/tas OMpVzeziD2yB7wIpe8VDsdBk0VNg4jKucV3Sgca/vg2I0r6Dw68hrJktOaVs1Hcapg06 n5erdQNyMkPgzb1UeLereTJqUsZV990b4BWkUaSNgwQoYew6KW1UhuFVblFGwvwUDM5s k91o25UWf3+n0kPAtL4IjWblXgD2BCGnoIVaS/Fidm4Yk0Kz3hAXsmhTTwgESJCPFX07 gHBg== X-Gm-Message-State: AOJu0YyuoUPIH7PJ1uY6MwLK7C1zzPxv5wyiiwz/Sv0X3jsKgJdJEXgf joXIhld2k/IP4LVTnxKquDwNTSn/UcrbaOBZVDeb+oFZjzH/fgRg91a/kB1LM4bjUc7bXt805KD pAgM= X-Google-Smtp-Source: AGHT+IHCB+/h2ET78YOzpZ+NRyipA37XIDAbT/u+5fHeiLNTenDopHbhsbXtYUCQI5xpnyyhKio5LA== X-Received: by 2002:a05:6000:1748:b0:362:363a:9594 with SMTP id ffacd0b85a97d-3674178975cmr2208517f8f.11.1719505666928; Thu, 27 Jun 2024 09:27:46 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 01/11] hw/sd/sdcard: Introduce sd_cmd_to_sendingdata and sd_generic_read_byte Date: Thu, 27 Jun 2024 18:27:19 +0200 Message-ID: <20240627162729.80909-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719505695665100003 All commands switching from TRANSFER state to (sending)DATA do the same: send stream of data on the DAT lines. Instead of duplicating the same code many times, introduce 2 helpers: - sd_cmd_to_sendingdata() on the I/O line setup the data to be transferred, - sd_generic_read_byte() on the DAT lines to fetch the data. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d85b2906f4..1a8d06804d 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -142,8 +142,10 @@ struct SDState { */ bool expecting_acmd; uint32_t blk_written; + uint64_t data_start; uint32_t data_offset; + size_t data_size; uint8_t data[512]; uint8_t vendor_data[512]; =20 @@ -1083,6 +1085,29 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *s= d, SDRequest req) return sd_illegal; } =20 +/* Configure fields for following sd_generic_read_byte() calls */ +__attribute__((unused)) +static sd_rsp_type_t sd_cmd_to_sendingdata(SDState *sd, SDRequest req, + uint64_t start, + const void *data, size_t size) +{ + if (sd->state !=3D sd_transfer_state) { + sd_invalid_state_for_cmd(sd, req); + } + + sd->state =3D sd_sendingdata_state; + sd->data_start =3D start; + sd->data_offset =3D 0; + if (data) { + assert(size); + memcpy(sd->data, data, size); + } + if (size) { + sd->data_size =3D size; + } + return sd_r1; +} + /* CMD0 */ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) { @@ -1920,6 +1945,20 @@ send_response: return rsplen; } =20 +/* Return true when buffer is consumed. Configured by sd_cmd_to_sendingdat= a() */ +__attribute__((unused)) +static bool sd_generic_read_byte(SDState *sd, uint8_t *value) +{ + *value =3D sd->data[sd->data_offset]; + + if (++sd->data_offset >=3D sd->data_size) { + sd->state =3D sd_transfer_state; + return true; + } + + return false; +} + void sd_write_byte(SDState *sd, uint8_t value) { int i; --=20 2.41.0 From nobody Sun Nov 24 23:08:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719505702; cv=none; d=zohomail.com; s=zohoarc; b=C42f9IVSzLs+gTIbTtfo+VxPZheaRYdHIXg/6Ny6VDPW6gRLJDpXLqDO9fUKwaHmNnPCpuf7e6RvdpXj6wZWesdEF5FpBkt/r945JT+voQkqAO2nuJzs3zs04snmuVOx3ZhCSglZOvVoaycpq2SKfLWCXGb2Ukvr3w6eLG6ujxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719505702; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PCAoLc7mb3MX2dHo327SeM2P71tXBpRF4C3PP6PydTI=; b=iAgKsxSJtHVcC0p9HXCPS32A4BPFCpsGMwg/pfZAD1KbaZM5Su5XR4A0K+CF/SLcZwI015iSYobeCguDy6fzcWpT6r2Wu9ofxRmDz4Ds+uPHwV3IzyXPxUo23An5n/StmOUzQCAN4/20yZPjb05Luy5hprDICHT+cmvbBPFdqIM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719505702022571.410763599078; Thu, 27 Jun 2024 09:28:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMryi-0000lW-PN; Thu, 27 Jun 2024 12:28: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 1sMryg-0000j0-Ls for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:06 -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 1sMrya-0003OO-FN for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:06 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4256788e13bso4423195e9.2 for ; Thu, 27 Jun 2024 09:27: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-424c8424606sm73979315e9.30.2024.06.27.09.27.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:27:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505678; x=1720110478; 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=PCAoLc7mb3MX2dHo327SeM2P71tXBpRF4C3PP6PydTI=; b=Ow85t6zGoMZL5rfAibEj2gYXtKbN8uiqbfc3odrqkW27S4g1qyYAOr/o4s8wmZFVv8 OsaM82RjZirRqE7l9PmoKGOtauUOoP1z/J+zh/ln2pKgkIVfKhoHLfpFeT7M9Wj6ibv/ Ohm788b80Qt38XaL6uUjfuhEye96VyAu0CmtBdrQz5n9E+jKCvN6g6d6DD7ecRJNyty1 4k5m4TJltj5NfMHegpDlzKqjBrCBUBkgGkzNkzuvy96e0UUQt9T8lOY030ffjcbsS6gr ofwWydo1HaLzbfkWOx2Uo4BUUkHFAtiwzB6/9Ldf7Q3r//3A+kiXlD2jOiwFcXzOFlWo 0Pog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505678; x=1720110478; 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=PCAoLc7mb3MX2dHo327SeM2P71tXBpRF4C3PP6PydTI=; b=dw0MQaE3GgxrCithlXL2vHgEcyj5Nivnch1FPY9hCNz0PG+97+XHc+g3BSw2lsvkEF 4kvDboZvyVHbpPfiLlnrw9CfOzK1/aKmaZJeaxyOYMH/YSAL5pBn1EUL4CF6PW6UcXsw q7abs66FcJ7jRlPupxXqSmkiD4E33rK0VRN2gyife1JBwrLYtY1oirN0nFTfTMvzVJ45 DAmyn+DxRzYGMwkP5t+sEAxLxV2waFwINBfxPSoS9pB4kzbMEhsle/CH4JzgBWnzUOqW ozh/qh6JAXyvW7bppPf04zUD3zV4xqBtn5I4FldC5UCM4C8ivJVzhVy5o9RF6GDOYXLm DmGA== X-Gm-Message-State: AOJu0YyXJyGG756VfHr/YA7Yxd7CeM1D9oJjtJ4cVONYHuRAOLK8uUld zyyK3/2UGoDE+LvgFoGaASm0e5V0Mob6cr4tWw1Sdm1q6w9mB5YWD1zyIp1JQnMNiTR5Rj9ujUu tV8o= X-Google-Smtp-Source: AGHT+IHyN7cEXOLfqrWwo2hBDF13kWgH0mkcLdXed+YMylS9xaoPovfoxzhtUmk3JFbGdFR+cPUFkg== X-Received: by 2002:a05:600c:1d01:b0:425:6927:5f6a with SMTP id 5b1f17b1804b1-4256927620cmr3528425e9.19.1719505678287; Thu, 27 Jun 2024 09:27:58 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 02/11] hw/sd/sdcard: Convert SWITCH_FUNCTION to generic_read_byte (CMD6) Date: Thu, 27 Jun 2024 18:27:20 +0200 Message-ID: <20240627162729.80909-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719505703749100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1a8d06804d..f7735c39a8 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1086,7 +1086,6 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd= , SDRequest req) } =20 /* Configure fields for following sd_generic_read_byte() calls */ -__attribute__((unused)) static sd_rsp_type_t sd_cmd_to_sendingdata(SDState *sd, SDRequest req, uint64_t start, const void *data, size_t size) @@ -1243,10 +1242,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) } =20 sd_function_switch(sd, req.arg); - sd->state =3D sd_sendingdata_state; - sd->data_start =3D 0; - sd->data_offset =3D 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); =20 case 7: /* CMD7: SELECT/DESELECT_CARD */ rca =3D sd_req_get_rca(sd, req); @@ -1946,7 +1942,6 @@ send_response: } =20 /* Return true when buffer is consumed. Configured by sd_cmd_to_sendingdat= a() */ -__attribute__((unused)) static bool sd_generic_read_byte(SDState *sd, uint8_t *value) { *value =3D sd->data[sd->data_offset]; @@ -2135,10 +2130,7 @@ uint8_t sd_read_byte(SDState *sd) sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ - ret =3D sd->data[sd->data_offset ++]; - - if (sd->data_offset >=3D 64) - sd->state =3D sd_transfer_state; + sd_generic_read_byte(sd, &ret); break; =20 case 9: /* CMD9: SEND_CSD */ --=20 2.41.0 From nobody Sun Nov 24 23:08:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719505707; cv=none; d=zohomail.com; s=zohoarc; b=VBF8g29jH1hP74Z3SBdO6/409yFVekv2eg8721/c9YJYVUfN4+33TmI5opg9lMjBfmR5I+PggBM1oty5jyIlAE9mhV0g+W/ahslZoY81L30kBuDh+M2bKvadKvr8K3Kd7B4hpr83INRNAOTw/HSNGHHOg9q6SQQce/WRr7t11jU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719505707; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=L78DEkAbiZk4g5l5bieI9G3pq1quTielmVGwRkKOrNQ=; b=OfBtTSmh/7tBUavqKtC249FGxxUfK9wQv7Xu+2HR8KB2aXhhp4VdQI/KOGQ4SpFoVdvFe+4MAK0MNL+SV5D3EaWiDJqsCxhvg6soIo9dYlvI6sLZsgoxsQDeU1tKqzij0h5twHh3e8TXCNGlj1t6MV5sVUtm1ROk+ApTpq5vpBo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719505707373414.2664391937976; Thu, 27 Jun 2024 09:28:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMryp-0001Dp-Vs; Thu, 27 Jun 2024 12:28:16 -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 1sMrym-000183-U8 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:12 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMryl-0003QO-5j for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:12 -0400 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2ebe40673e8so91455771fa.3 for ; Thu, 27 Jun 2024 09:28:10 -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-424c8424554sm73694685e9.37.2024.06.27.09.28.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505688; x=1720110488; 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=L78DEkAbiZk4g5l5bieI9G3pq1quTielmVGwRkKOrNQ=; b=TPYZ0s4pa17D9zpVItFqHQSK1/KG3cvEIvhXDIYGa+7CVF0iCq0V+SrACcwIMkolGq aUJLz/ZQy1z5JDaa/HOes8WNFGWDr9YBAj3IzkmFhjkdEoBZpB92epRiuaaMwEj+Ilub iE+sb9BISjJ2p4SQ6dSCU7Nh9kQLAnfkB6WJd47TB+v3slERjb8vO+JltZy6Zv1kZevX IXveoUE1TJaUJX5lWQOTJ0O5TYqHkUwx3FjK+4zxeFzcv4ATkFrFlRCqO8JEhQvAgab7 m5L/4CQLd+o0q9jE0CB6d/a6kkwf2At5HEDhUaF0+1spBCJwAlXwfYD2F04n2reyq905 Zl6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505688; x=1720110488; 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=L78DEkAbiZk4g5l5bieI9G3pq1quTielmVGwRkKOrNQ=; b=BrSXnWJLfxivwY9B3QeJFVnDh8rZFS5F7r0TiQHy0GUR1tEI0G0rChr4xTzrTka2g0 pH9MJeQv93KNCgPOiH0oSRiXxoBIYUVC07qltUhMG36267RBCGsJF7R9guOyYkACiPG7 tDVnfc7qeGFQrsrVAHcwu21fI90LMHZa0WdgnlT2IgXvowb1p3mCDGdjBH6ViMDR40fw jtwXrPivCjVhy1WyRkuJdzwSg/YLGmoP9aSO4eU9I8oaBkPKQdub7uLM6p1pM509HNf5 4cVZ7WAwXfkV3JhnXBOktlmlK+fhNxOaN7vU+32mYCHCHguczdcRSPloN/40VSMk2xyH sQfw== X-Gm-Message-State: AOJu0YwcFhRR/E7yIJRVyrso/IQ7tA/DCNlmZHw8oPRm11iueZszIuaH 1NRxwmAqHTqEGsHHleTRA9ZIWQvY4eTmBApWiIxS12ayofbN1Ujp/QFxibvYk4UuiL3O5cijxUa Y94I= X-Google-Smtp-Source: AGHT+IGjgpggEaOBrJTqK6x7e8bO8FhKBflrOfQmF8hBfvQtpMOqC//z62WvkKdyxsGvcffbqu0pyA== X-Received: by 2002:a2e:9895:0:b0:2eb:e177:14f8 with SMTP id 38308e7fff4ca-2ec5b38ac24mr80911641fa.27.1719505688107; Thu, 27 Jun 2024 09:28:08 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 03/11] hw/sd/sdcard: Convert SEND_CSD/SEND_CID to generic_read_byte (CMD9 & 10) Date: Thu, 27 Jun 2024 18:27:21 +0200 Message-ID: <20240627162729.80909-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=philmd@linaro.org; helo=mail-lj1-x22d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719505707696100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index f7735c39a8..8201f3245c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1312,11 +1312,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) if (!sd_is_spi(sd)) { break; } - sd->state =3D sd_sendingdata_state; - memcpy(sd->data, sd->csd, 16); - sd->data_start =3D sd_req_get_address(sd, req); - sd->data_offset =3D 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, r= eq), + sd->csd, 16); =20 default: break; @@ -1336,11 +1333,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) if (!sd_is_spi(sd)) { break; } - sd->state =3D sd_sendingdata_state; - memcpy(sd->data, sd->cid, 16); - sd->data_start =3D sd_req_get_address(sd, req); - sd->data_offset =3D 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, r= eq), + sd->cid, 16); =20 default: break; @@ -2130,15 +2124,9 @@ uint8_t sd_read_byte(SDState *sd) sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ - sd_generic_read_byte(sd, &ret); - break; - case 9: /* CMD9: SEND_CSD */ - case 10: /* CMD10: SEND_CID */ - ret =3D sd->data[sd->data_offset ++]; - - if (sd->data_offset >=3D 16) - sd->state =3D sd_transfer_state; + case 10: /* CMD10: SEND_CID */ + sd_generic_read_byte(sd, &ret); break; =20 case 13: /* ACMD13: SD_STATUS */ --=20 2.41.0 From nobody Sun Nov 24 23:08:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719505722; cv=none; d=zohomail.com; s=zohoarc; b=hAJzAxynSlzill/BVlNhx5A/yY/0ezgH5JJxAG16uNGn6vBjX1o5fnYRK1JBGSJx86/kx3rciw4ubtQ4bSy7LbRSu7IREHrYUv4jzngmcZUgKqotA7uNHG0ffR4rYSUgwqLXpBQq/69ETKDPXJmg77gcc0wBf4bTmvh+mMz9sdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719505722; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Nu8acyjpOBs616osR1RalX8TR2/NJv3m9AnCQgylDWw=; b=IUFlv/nTn8dd7a/3qaXqLJWQbMF/O71Hj6xyH9UvqUE1i/1fMkMciNcIO/JgEkWzMoMP4OGY4xA13SB30Js6wqJbZ5trCeEyUmiSiOuIVfCBVTMVbq693XJg6Qo3XZnFu6JgzV81NsRCM9ueJZXY44Y9oYl9W2NV7dRg/HZSy9g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719505722464384.3399052543234; Thu, 27 Jun 2024 09:28:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrz1-00026J-Fq; Thu, 27 Jun 2024 12:28:27 -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 1sMryz-0001zt-A1 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:25 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMryu-0003RW-Gx for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:25 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52ce6a9fd5cso5040659e87.3 for ; Thu, 27 Jun 2024 09:28:20 -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-424c8245e87sm76229945e9.9.2024.06.27.09.28.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505698; x=1720110498; 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=Nu8acyjpOBs616osR1RalX8TR2/NJv3m9AnCQgylDWw=; b=kbq85n7ApPOGi9S5wvgOjM4bpa9bC6cpI56kHkVC7EUJPmVsVmJZ2BI6Rmvq45h1JO uD1mGAgAHFjskqrenjCXup5o84H53Lalv/JGz8CN225rRS1It8ldpW9ZMd61d1jJ1UY2 UkX7LukTWpwj2INhuXXHTVY1pDu4VKkT1dljG07eA/0Aj3oalK7thOUMoSKmlr4j6p50 0RLUH/rkn6fvMomc25qOk3nCPbxWH0KjmYYByn4W6UIz0PLalVIysPDoV+DACLvdHEVP GmClgJWbhgqc3rxxEPmGALBL2aMjuBeLzq7mbb4sAYpaW7fwWngTCpo/0/Yrtr8HZnCD Gwjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505698; x=1720110498; 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=Nu8acyjpOBs616osR1RalX8TR2/NJv3m9AnCQgylDWw=; b=WzMAmvWGP4i63f2nvBwivQu8/AJ7Oek5CWuWHYvX2+rotx05s1to+y6S7/QyHeRbmf HHXcq+2OCOvfduHuFryFEUnDr00ocICdbkkxMGGflCnsMkDo77RoCDGkDboVNgdnUXLj RNA1kVBcyhwwkpFRitONFx38qf2dDxAXfRtvWcDRTmuxkoJkahENai/COg/e2l8s5F7j e+g3Vr71g76x97vzEoa7q5bAv5LZqD+OfxajXJQHxM8PgPrSm5gWk4dS060+28nNM767 dvfeuwFmvoXwmt1BSVpUVTYXgCIJnoUpns+oWKWYZdfzTW5QlX1dhbfxOpj0E3CD+d43 hfWQ== X-Gm-Message-State: AOJu0Yzxk2VKiqb4hcUCQhiEHdLLsg62IzNxhdHlu4COe6k71gAbFapH 2uLlIdwzvMpglArE8uo6Nzy3b7159LHiBx98QPB2ZMoU59UTKego7yY0PdnzYzQpxbLuw8O0NeO 0tfI= X-Google-Smtp-Source: AGHT+IGq3CiDQeS8+/xyTZfwPjEr64B/Qna+T+BMaosaC1ZtFyMqrrgmafTsJzwie2K0PFiQskKcBg== X-Received: by 2002:ac2:5490:0:b0:52c:9e51:c3f with SMTP id 2adb3069b0e04-52ce185cfb0mr9045412e87.42.1719505698287; Thu, 27 Jun 2024 09:28:18 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 04/11] hw/sd/sdcard: Duplicate READ_SINGLE_BLOCK / READ_MULTIPLE_BLOCK cases Date: Thu, 27 Jun 2024 18:27:22 +0200 Message-ID: <20240627162729.80909-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=philmd@linaro.org; helo=mail-lf1-x134.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719505723709100001 In order to modify the READ_SINGLE_BLOCK case in the next commit, duplicate it first. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 8201f3245c..dfcb213aa9 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1398,6 +1398,24 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) break; =20 case 17: /* CMD17: READ_SINGLE_BLOCK */ + addr =3D sd_req_get_address(sd, req); + switch (sd->state) { + case sd_transfer_state: + + if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_l= en)) { + return sd_r1; + } + + sd->state =3D sd_sendingdata_state; + sd->data_start =3D addr; + sd->data_offset =3D 0; + return sd_r1; + + default: + break; + } + break; + case 18: /* CMD18: READ_MULTIPLE_BLOCK */ addr =3D sd_req_get_address(sd, req); switch (sd->state) { --=20 2.41.0 From nobody Sun Nov 24 23:08:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719505726; cv=none; d=zohomail.com; s=zohoarc; b=PZF3AFXGI1/Ih59wHRYEi3IUeQVF6+jh1oJ865CqOY0qjz1DYsh9KRHkEbe1wtghf8QBa6ITMS1qctWpko718sGQiIntzXVEbSguFu7w2E6qbhuTMbr54rMsfZo0G/Y0XMylCepcFtI0PqtgR9aBxmtS4TE2C1D6CoYgo6SjEDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719505726; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2/Nk+VBMPqpf8y4oh8kBjAzH+GIdB3yLjf9fq0VMabc=; b=Wgt2jkXO3aRjYSNZS+F5DsEkTk+DG6upaQqk90VjziYYnjNCFGN/QEGL6mpmSiQ6vzP5m09/Juu4ykmJomP4T8wvbZCV3sOn++hUlCOSGkGgR7nsUBB4EUDRSxtQDhCRmwiCjbqzckyKC+N2LrorDfLeonP5sdt/O/854ZUcdCk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719505726457335.7800142657021; Thu, 27 Jun 2024 09:28:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrz9-0002Ry-6H; Thu, 27 Jun 2024 12:28:35 -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 1sMrz6-0002Kw-Uw for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:33 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrz4-0003Sz-6v for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:31 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-364a3d5d901so5382498f8f.0 for ; Thu, 27 Jun 2024 09:28:29 -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-3674357c1c8sm2402704f8f.9.2024.06.27.09.28.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505708; x=1720110508; 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=2/Nk+VBMPqpf8y4oh8kBjAzH+GIdB3yLjf9fq0VMabc=; b=p6VBLk6SzLc8jyl2mIYxsz2jOv2+5CE/LYekPRKVsWZuP60H+BdfPdClSvhU3JiN9T JonknX+PHpwWPGIyID01yIMfKG78veT/p89nNV9QONccS9pc+le66sZIw6M4+YiQhp9O eyV+BdB4vw7z7NjNJX6FWmE1csT31aeQOhZ6BCBqIAisjqnMqqpeDPUKlIhXWi+HuLCQ n3sueN1gM3fjkeNUMJcmhhop9u1XrTNezOf2MVUnrqfucEUH1i72pSzABeHouCSNqj+5 P9nF6GV7ND++q1lXujpJkWZGpZdhsS8UY7tsJTDT+LkKWEpa9C83CSW0zbU+4XG1yF1k J0xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505708; x=1720110508; 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=2/Nk+VBMPqpf8y4oh8kBjAzH+GIdB3yLjf9fq0VMabc=; b=sDfVuayQqjTEFRV0utCUlv1PCYuq7lQMxtLKJOUc0pRkcA8zt4INVj6pid8CfWTYV1 NeARguE9/PJ9NQmCDeogZ8NVoYIca0ObEPKeuEF8nIDpHnKRSXoq0cKX9mAdX7k8UMQi nQtUDL2YyiW7+nDHftr5P+iz8RatNzDKABGxAyc5V2rq3Iea3TRdNfU87OGWG3ik8K/z Om/jkeE9KGcOcga3p80zKEqdrnj2feLw+wr0IXvMZ+6aOV320EZy6LGaPtICqLFIkLYr TqxPCEhIetVaJBg055dMzxJ8K2JnGmhfWX8bfW+aVxal1hPtqsd0/ksqPkl3D17pEkBh W0fA== X-Gm-Message-State: AOJu0YzXfY77Ksl6FIPsdQb8TT5eLvPBwpkhfdxOXJOwtHKp3+QbT4HT BCVhNLLZBCa3L6ta6D0gGlNmtz1CN3nHiA977lIgxyn84eVTpjBsHRHQhtbY1IPOjbj224GW12x CUwM= X-Google-Smtp-Source: AGHT+IG5j628L1vcPdAI1MoYubsqkIH0JzyX+mAL7YdndTp8skPmwkj7xE2UXVzslZPHek7/3pa35g== X-Received: by 2002:a5d:58c7:0:b0:362:69f1:a08 with SMTP id ffacd0b85a97d-366e948fa96mr9537647f8f.19.1719505708589; Thu, 27 Jun 2024 09:28:28 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 05/11] hw/sd/sdcard: Convert READ_SINGLE_BLOCK to generic_read_byte (CMD17) Date: Thu, 27 Jun 2024 18:27:23 +0200 Message-ID: <20240627162729.80909-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719505727739100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index dfcb213aa9..605269163d 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1405,11 +1405,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_l= en)) { return sd_r1; } - - sd->state =3D sd_sendingdata_state; - sd->data_start =3D addr; - sd->data_offset =3D 0; - return sd_r1; + sd_blk_read(sd, addr, sd->blk_len); + return sd_cmd_to_sendingdata(sd, req, addr, NULL, sd->blk_len); =20 default: break; @@ -2144,6 +2141,7 @@ uint8_t sd_read_byte(SDState *sd) case 6: /* CMD6: SWITCH_FUNCTION */ case 9: /* CMD9: SEND_CSD */ case 10: /* CMD10: SEND_CID */ + case 17: /* CMD17: READ_SINGLE_BLOCK */ sd_generic_read_byte(sd, &ret); break; =20 @@ -2154,16 +2152,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state =3D sd_transfer_state; break; =20 - case 17: /* CMD17: READ_SINGLE_BLOCK */ - if (sd->data_offset =3D=3D 0) { - sd_blk_read(sd, sd->data_start, io_len); - } - ret =3D sd->data[sd->data_offset ++]; - - if (sd->data_offset >=3D io_len) - sd->state =3D sd_transfer_state; - break; - case 18: /* CMD18: READ_MULTIPLE_BLOCK */ if (sd->data_offset =3D=3D 0) { if (!address_in_range(sd, "READ_MULTIPLE_BLOCK", --=20 2.41.0 From nobody Sun Nov 24 23:08:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719505744; cv=none; d=zohomail.com; s=zohoarc; b=fQHIBOT3Ogh+xGP2S59gNV3DK+qCtLr8Pf0G8aTHyjtGXno8/LlSUt9lzZjaVuh6i12S0YosXGPCWXhZtLA48E0GOHQlBul7xePQDKHdNTCJVbyKWZ8tIIJuTx+c80vs2ZF22Y/4I0joq9pZrGk53yvDfqbgf0CqgZreFmE7xjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719505744; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Xyhvw/6qmXFus9eORwXzq1Iu5gU3BghWHGLoDUVW4O4=; b=aKnIiWASQLyLH4x6Zp8BR/t8Xx8HXM2bnCHufw4dGOy1lWSgG7c04jdneQKeIRfHtrxwUIdwhnqft/InTcOjc4FatiohZegoZ/Q7GZPf7f6YSFQTBQ50fZmuA9EPGB0wnrxgliz17/gwzHDa90yV9Junm4XHW1YFrr8Hh6NS13Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719505744401115.13420767307207; Thu, 27 Jun 2024 09:29:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrzI-0002lX-R5; Thu, 27 Jun 2024 12:28:45 -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 1sMrzD-0002fK-2J for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:39 -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 1sMrzB-0003UK-BL for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:38 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4248ff53f04so35300975e9.0 for ; Thu, 27 Jun 2024 09:28:36 -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-424c8246828sm76479825e9.5.2024.06.27.09.28.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505715; x=1720110515; 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=Xyhvw/6qmXFus9eORwXzq1Iu5gU3BghWHGLoDUVW4O4=; b=G7uzp2qrNIcGqlouSW4SF+VIDuGX6y1EmnUeCs3txzGzI2//5IRpo67FvokbnB0Fs8 6NxCybFLaT/4R0rXbv2ZBo45E0GF1UrKcQtosQ8DKGQZw2rmtsnJ07QwBIEQFv/2jyb5 mtZEmNmUgsi/E+WJvboTV/+bdjGrUzeGdDssc7OWGVLkioTGQedmRZfmiOO+m6RxrBfR UllzfeIr482v3SSEdCrSNzhrhm2ee2ALsA62yzpXqkqKBgdrA7z7QZVOnujo52mo1O86 KQC2HK5UTpNmMMIdciIjWDXbNUmB0iA2UDTDdb0VEKPuuR/hDnIuIbcT9GtAzTOYKSUl 1ltw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505715; x=1720110515; 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=Xyhvw/6qmXFus9eORwXzq1Iu5gU3BghWHGLoDUVW4O4=; b=M39DxUq9ufK4J/qJWo6ID3BIX3hqOC4VARmKy1tpH2RAT+vsGRR148H1OdHL4c0L68 2W9bMfaX0vdtofKVS6RbJ0j9ta2Q5cehIIa8hCv5VeBgBxBXlGfbTAuODs4yOCeQzW75 jBAy8xmPDzAgJhaZKU5U9PkzcQHGqTr3Zlrqj5yIeA57N2N5YOBD/XefM/fVrza0/0wQ YkDNF52ppiJJbPslM7UIzdtOiimoAAV+y/L67XOia6xggyS8ET8TSrG6FZas+d3bEYUB Yyz9qr35yRUUTOQYaznTrZtFz6g/F4tDP3l+3jvykFlFxXMmCj6VBGkSoQgzaJMH9x5s m/zA== X-Gm-Message-State: AOJu0Yyi5DVSIJBmVX7gGc8NhG3lnP3zYsynJEutQuOdf/QkVSfNxYXS 1QwGkc1zIo2LNWTJsq1PFH2NiTj5GGtMnZa3cboo9YbQkR8Du/A6W4tS1QO+6QvWQCa1vX/K+T/ V2xE= X-Google-Smtp-Source: AGHT+IFBWugtaTy3dsO2ravo7MU6jX9ArF5ah+iYrFysZYWQ/RB1Gfy2NEUOVv7mW2UzWj67lIF6og== X-Received: by 2002:a05:600c:25a:b0:425:6001:6637 with SMTP id 5b1f17b1804b1-4256001679fmr30535685e9.1.1719505715590; Thu, 27 Jun 2024 09:28:35 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 06/11] hw/sd/sdcard: Convert SEND_TUNING_BLOCK to generic_read_byte (CMD19) Date: Thu, 27 Jun 2024 18:27:24 +0200 Message-ID: <20240627162729.80909-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719505745878100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 605269163d..eece33194a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -568,6 +568,21 @@ static void sd_set_sdstatus(SDState *sd) memset(sd->sd_status, 0, 64); } =20 +static const uint8_t sd_tuning_block_pattern4[64] =3D { + /* + * See: Physical Layer Simplified Specification Version 3.01, + * Table 4-2. + */ + 0xff, 0x0f, 0xff, 0x00, 0x0f, 0xfc, 0xc3, 0xcc, + 0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef, + 0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb, + 0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef, + 0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c, + 0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee, + 0xff, 0xfd, 0xff, 0xfd, 0xdf, 0xff, 0xbf, 0xff, + 0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde +}; + static int sd_req_crc_validate(SDRequest *req) { uint8_t buffer[5]; @@ -1161,14 +1176,9 @@ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDStat= e *sd, SDRequest req) return sd_cmd_illegal(sd, req); } =20 - if (sd->state !=3D sd_transfer_state) { - return sd_invalid_state_for_cmd(sd, req); - } - - sd->state =3D sd_sendingdata_state; - sd->data_offset =3D 0; - - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, + sd_tuning_block_pattern4, + sizeof(sd_tuning_block_pattern4)); } =20 /* CMD23 */ @@ -2100,20 +2110,6 @@ void sd_write_byte(SDState *sd, uint8_t value) } } =20 -#define SD_TUNING_BLOCK_SIZE 64 - -static const uint8_t sd_tuning_block_pattern[SD_TUNING_BLOCK_SIZE] =3D { - /* See: Physical Layer Simplified Specification Version 3.01, Table 4-= 2 */ - 0xff, 0x0f, 0xff, 0x00, 0x0f, 0xfc, 0xc3, 0xcc, - 0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef, - 0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb, - 0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef, - 0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c, - 0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee, - 0xff, 0xfd, 0xff, 0xfd, 0xdf, 0xff, 0xbf, 0xff, - 0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde, -}; - uint8_t sd_read_byte(SDState *sd) { /* TODO: Append CRCs */ @@ -2142,6 +2138,7 @@ uint8_t sd_read_byte(SDState *sd) case 9: /* CMD9: SEND_CSD */ case 10: /* CMD10: SEND_CID */ case 17: /* CMD17: READ_SINGLE_BLOCK */ + case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ sd_generic_read_byte(sd, &ret); break; =20 @@ -2176,13 +2173,6 @@ uint8_t sd_read_byte(SDState *sd) } break; =20 - case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ - if (sd->data_offset >=3D SD_TUNING_BLOCK_SIZE - 1) { - sd->state =3D sd_transfer_state; - } - ret =3D sd_tuning_block_pattern[sd->data_offset++]; - break; - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ ret =3D sd->data[sd->data_offset ++]; =20 --=20 2.41.0 From nobody Sun Nov 24 23:08:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719505747; cv=none; d=zohomail.com; s=zohoarc; b=hqYyxPg1Ww9JEPVoiuggeKcTshFxzyp93n42Fl3EPVzSH9rXYQT6aMlv9cfCBLfiESY85xt0ewVfIl5s4nScARoxANCddC2f9y2D/ZWfs+hjkij0hJx0RU5Me0rA3R4V4XLhC7qZzIbpqTW4XSRL5K0JtdNldfDR+02XYg34ZM4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719505747; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cXnvSPEQ0479Kw/NHZLng3szLmllyhp62LGUqGmd/0w=; b=H0p/AakrHDrYGwYZUFuwBmfVY09QXi3FAKLpmu4o+AvwC0YktofV2VEI1ouGgvJpdqbMFiqnHVa3YcyPz1dLDX3didSaqTwQMexAVOcJE9SoFJjRjTMnkC/SxJcLopcJjtaUgMohYd1U+r2uvj1ylGcJ/2c1+lS0KLsHpHht/UI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719505747867610.2614020137946; Thu, 27 Jun 2024 09:29:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrzS-0003LZ-1q; Thu, 27 Jun 2024 12:28: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 1sMrzO-00037o-5z for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:50 -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 1sMrzK-0003VJ-LO for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:48 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-424f2b73629so22835875e9.2 for ; Thu, 27 Jun 2024 09:28:45 -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-3674357c1fcsm2379809f8f.20.2024.06.27.09.28.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505724; x=1720110524; 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=cXnvSPEQ0479Kw/NHZLng3szLmllyhp62LGUqGmd/0w=; b=OFKGwD0ivlbZnWH7p/QMvodQqcn6r59QTHglZw5G+H8SurDq5B73ZHRwEIihVMtvfG odkgMD7Rip0OlN88IJDuQWtGRlhGYaGNQwJhroJHlz9QEQhvDiT3eHxJTXNLdKEyEcwW E0arsNdaBXJB6HFxp0u0SsGil4eNx1TvRA9cmeTlUHx5u3Av7/JLKT3gnQtPRQVDevbe N9i7Fbrp42xkX4XiWgrxNwxWJaKInwWHi7xPtP3vwKifK2yxZ/ycPV//DTzPM4DywPYh UC1h6YzmWtRwSqfqaCfdrrIbexY/VqQMKOQ08mVtZtLjEr4U/oGKz0bMiNCS/i7QhpRR qgEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505724; x=1720110524; 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=cXnvSPEQ0479Kw/NHZLng3szLmllyhp62LGUqGmd/0w=; b=mXQwGsRYYPwKi2cARDHoyoquTkPd3QCF+WUCn/7Y2Uyk8HtzI/U/uIwpnE7bIitO8J l61Gm38oFMZ8ba9BMzw7zx3RVQMlHwkaEFxzP7yMhkPUu9DTYxS/EfzvfnZmd7qaZuVn Y973GUjAIbGynfwyg/MZmA+LPkd/Z985K0R6sMu6BqAulwTQZBNZTWn5k2hCQzlhXlMg WOqdpruq/mhJ5vYJWtEbE+VD7zQzsIqTffVbS+eFVQZxFQ5tK7CdlDNRPPsSqBJEnQVr 8K+cG0YilJZG7qednVVts0lCyy/x2qjrjYDx8Sf9YmQy4SWeyZ1qTdXFn6Yz+w9zuuqQ enuA== X-Gm-Message-State: AOJu0YwzEqZJ/l6bvVI/PEO1VZVM1CClJIsfgL5VXsNSeMfB5e6+K7LU +sZ29f9642iuzmsEJdaNxxiAtcGme24WeJtuMLqYk7UK/Tcw2OSvUs6BPcDQcCU//Hr1XMctqDh M1Cs= X-Google-Smtp-Source: AGHT+IHgatHNEdIT25HZ/RzZ9g+vd7DOOS0h5YFs6HuHyLRsEZAHibyf8Ejb+ifokMpP6CXTLVMFBA== X-Received: by 2002:a05:6000:2ab:b0:366:eb00:9ddf with SMTP id ffacd0b85a97d-366eb009e92mr13900341f8f.3.1719505723851; Thu, 27 Jun 2024 09:28:43 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 07/11] hw/sd/sdcard: Convert SEND_WRITE_PROT to generic_read_byte (CMD30) Date: Thu, 27 Jun 2024 18:27:25 +0200 Message-ID: <20240627162729.80909-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719505749868100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index eece33194a..bf922da2cc 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1202,6 +1202,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) { uint16_t rca; uint64_t addr; + uint32_t data; =20 sd->last_cmd_name =3D sd_cmd_name(req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. @@ -1555,12 +1556,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) req.arg, sd->blk_len)) { return sd_r1; } - - sd->state =3D sd_sendingdata_state; - stl_be_p(sd->data, sd_wpbits(sd, req.arg)); - sd->data_start =3D addr; - sd->data_offset =3D 0; - return sd_r1; + data =3D sd_wpbits(sd, req.arg); + return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data= )); =20 default: break; @@ -2139,6 +2136,7 @@ uint8_t sd_read_byte(SDState *sd) case 10: /* CMD10: SEND_CID */ case 17: /* CMD17: READ_SINGLE_BLOCK */ case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ + case 30: /* CMD30: SEND_WRITE_PROT */ sd_generic_read_byte(sd, &ret); break; =20 @@ -2180,13 +2178,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state =3D sd_transfer_state; break; =20 - case 30: /* CMD30: SEND_WRITE_PROT */ - ret =3D sd->data[sd->data_offset ++]; - - if (sd->data_offset >=3D 4) - sd->state =3D sd_transfer_state; - break; - case 51: /* ACMD51: SEND_SCR */ ret =3D sd->scr[sd->data_offset ++]; =20 --=20 2.41.0 From nobody Sun Nov 24 23:08:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719505756; cv=none; d=zohomail.com; s=zohoarc; b=iq1roN1yCscZi25FNUwfCJ/3dRYlrzfhbj+HpNMTt4Mg7sPc1uA1K4BHd8kDGiJXHkpxS++Fr5zImpOKEpTPsfUYu1etL0K89IKbH6dELpCML+KVto8v+EtJ3UPFt/Kc4huVoYxSXnetiyChharkAi70ZUfKN8ZYVT2/zovUEMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719505756; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=K0OGAnFsplarXOIRkfzB/tBQTFE1QX5yc3lFvHsUa30=; b=QAK41/4dqF02yr3k6ISBW2+HsNNNwSear64OKipVJ3LMrG2UOdj+oPAwfhCnkE8+STBsOKrz5YPZWRZnAARtO3ersSQMMf3AIlFH8uUSwAkyoJGjNh3a9FTxKRlQDip8tuTEif8Lz5lnBnMLW7hHY26rHAHhGEd/OBF51PfowK0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719505756852226.25831044793313; Thu, 27 Jun 2024 09:29:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrzZ-0004Ft-1C; Thu, 27 Jun 2024 12:29:01 -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 1sMrzX-00042I-7W for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:59 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrzT-0003W4-0f for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:57 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-42122ac2f38so12999345e9.1 for ; Thu, 27 Jun 2024 09:28:54 -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-42564bc59f5sm35576815e9.42.2024.06.27.09.28.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505733; x=1720110533; 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=K0OGAnFsplarXOIRkfzB/tBQTFE1QX5yc3lFvHsUa30=; b=NkximAbfHZwrsZZoe9aAeCHIaepMoqrCaL2jukDcY5odVc5+ojfRdJzRY36C+BJJ2m iN332BWvqs3VM+Ii6/lwYsI8Q94jnu1aL1kA4aoPqDSEyuXqfI04MrNo+SwqKqh+km1M 7pYuoo8fSON8WYWoCxsq1s+pggqRgXWnuWIyrBENLXKQxsk9PfSjEG28HrqGPwKAdwmN KsJDAJHlfWW3h94bkD3aa/FyLEckTQQ80V2Zti5Z6FNGLu7tuBcsha+gEzhUoWxjkAEP /onhrHWa0le9XOUGWeDCk1tFEG34OMGJ/Fffo+khIPW6dlpbZjoxVGl3PLESZbaFrILY Ljzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505733; x=1720110533; 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=K0OGAnFsplarXOIRkfzB/tBQTFE1QX5yc3lFvHsUa30=; b=tpFi2lPqiKp2S4jBeICmq08F09/yqfTnPhSreg7GF2+wIcUAKUMNHjkW28mn7uoJMT SVV7ZMcCU99e7IoVJzy60CeG/8i8/XysQICEWMLWKxbw41lIFVIH1ZUjSCrBdeFLDcF7 PFUkfTQktH7T5FMSkWYlWo5EMHHA8YwEWGNG00HEnPMSXkEEWOwzaRa/wsvaQ1cbprTR FTrc86PWGXTJwD28Ss68WDEZoOiHG3aOWDwV0esUHmRFGGOkT1qTlXa4spWieotoyRfR TI8fpaXXFOg6UQaJVBEXSpv68m442EP+IDhsq+K3ZWCXKGOCoBIkjW8mSeBPwor+aPlZ nElA== X-Gm-Message-State: AOJu0YyvjlEOZcE86GIDTj5oCLMPc55j4JqHpBKyok5FLQWrEF9ftHCM /I+q90xF9x9kwgg51sjUdM9rUiCWx9a2TxIkog1+8LpPTxU5VT9+P4w5RQv7GHFmqb+KKGivY1E AatQ= X-Google-Smtp-Source: AGHT+IFgBCoSuF6W5LssKnAsW241RIRXJsXCJ1FBJZp91YGpujY4cOx+ivs697wMPeGswdTDWmMIZQ== X-Received: by 2002:a05:600c:5104:b0:424:8836:310c with SMTP id 5b1f17b1804b1-42564316399mr24158445e9.5.1719505733307; Thu, 27 Jun 2024 09:28:53 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 08/11] hw/sd/sdcard: Convert GEN_CMD to generic_read_byte (CMD56) Date: Thu, 27 Jun 2024 18:27:26 +0200 Message-ID: <20240627162729.80909-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719505757872100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bf922da2cc..ccf81b9e59 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1648,10 +1648,12 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) switch (sd->state) { case sd_transfer_state: sd->data_offset =3D 0; - if (req.arg & 1) - sd->state =3D sd_sendingdata_state; - else - sd->state =3D sd_receivingdata_state; + if (req.arg & 1) { + return sd_cmd_to_sendingdata(sd, req, 0, + sd->vendor_data, + sizeof(sd->vendor_data)); + } + sd->state =3D sd_receivingdata_state; return sd_r1; =20 default: @@ -2137,6 +2139,7 @@ uint8_t sd_read_byte(SDState *sd) case 17: /* CMD17: READ_SINGLE_BLOCK */ case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ case 30: /* CMD30: SEND_WRITE_PROT */ + case 56: /* CMD56: GEN_CMD */ sd_generic_read_byte(sd, &ret); break; =20 @@ -2185,14 +2188,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state =3D sd_transfer_state; break; =20 - case 56: /* CMD56: GEN_CMD */ - ret =3D sd->vendor_data[sd->data_offset ++]; - - if (sd->data_offset >=3D sizeof(sd->vendor_data)) { - sd->state =3D sd_transfer_state; - } - break; - default: qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__); return 0x00; --=20 2.41.0 From nobody Sun Nov 24 23:08:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719505761; cv=none; d=zohomail.com; s=zohoarc; b=K/PJDG7eWBw0y0sYKe/ev0HKI206yh97YbCDgDZWhdCKNhKFdl2l5W5fKgflc6GczvUe3pVwCBYiyokvEvHywkZz9aWjbYHNFFpTZCJlD8cK2JKPC36y8vMHOY5JPlMKAQvLgMo7YY/ugJ3Eqw8bF2R50eviRVcbqULiwQNd6so= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719505761; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1KciARHbIYi2vnj7HB8fhMsqIK9cJrPhhDCahh6cG1M=; b=j4a6zf1ZgW0pYTRctST+GUPsguR8MwmT43vsE02xNNDctWtCDWX8Rgu/eqzQ5bX5fRSEWS+5FmZsJ4RPs6YKND28qcX/be0QNmaWZ5I2rcHB3VMuKCUiqv4OV5+LxG62b7TSdfeFlKIt6OXtwhidUgMolzTgyn97CWPtIIQfcBQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171950576104671.60650061903357; Thu, 27 Jun 2024 09:29:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrzg-0004yX-6M; Thu, 27 Jun 2024 12:29: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 1sMrze-0004sE-Uz for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:29:06 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrzd-0003ZC-7C for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:29:06 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-424720e73e1so65536935e9.1 for ; Thu, 27 Jun 2024 09:29:04 -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-367436998fbsm2359860f8f.84.2024.06.27.09.28.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:29:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505743; x=1720110543; 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=1KciARHbIYi2vnj7HB8fhMsqIK9cJrPhhDCahh6cG1M=; b=qvke0LxHfA+oPmBvXwOWvEECPBfNBGeoJPSfT13JCrK0MbyDQAWGiVpCvPwqkQnBpy gdyMcIQMh2vo8xCEz8Gq7tJ3s7aUdXN2UkC9/6Q9dWXcMhSH69WfHTY8FLEuypzWudM8 zfwtzMDF5slvINtAAV/nZj1bUTb/2NRF/uLHqv9YbYNqPr3OMi0TU3OlId8V6pgkEAXY qUNyopUNeH8XUieIu/SrjFyR10DvZgNQGU+UDrsgPYin8CCCLtXQi/Kyvnbb2n/YABde Yf1mnIl076USdpYDqgSzp5vR9JrEZtWI0o760f/+RvpzmqRzxiXNiSqCEbytrple5YBt Paow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505743; x=1720110543; 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=1KciARHbIYi2vnj7HB8fhMsqIK9cJrPhhDCahh6cG1M=; b=b0vmKCK8y89errjVjrzMdS4s6IFzcq50o6+1Dv/6CntCEXD0QxHff/fuBmcTfBTKTK RKrcmjNi58I1hm26MnLnFAjoIXTT0njxpilLCuUQ5g4rl8pAoueBLBUeSxoXYOzDydPe 9Gf/npzeL7GnzjiASNk3WYm6R4KNarkTlb7HHTiMec7UBaGbC5IvKIAteILZXF4YlBBW ESo9MN7G7oxnnwBEpGG6ZvuNhie1jtndl1vQxoegx3FJ0ylUvnuNMDFtVB4HyuOB+Upr zYq4QExkEDZ1JA7bpe94B/ahvshgqo9DarXTQBpx0AXE3QBbeolXTRdywM20wuFFB5kE 9+OQ== X-Gm-Message-State: AOJu0YzV71LhTxNQG1jCA9yJbtcsCbKR8sNxNcpEkgMmGjzqhT5oeFpJ yvSHJcBKYF/76yeUwlDh+kHZ8BRy86AJvdSOZBAGR8812v0tPipkPZghouWtaexbOu7M4Ua6mlD /S/8= X-Google-Smtp-Source: AGHT+IELHvFW1v2c51jkk/RXNS2D976Wv3sjgb1oJRMwcKe7jcEHwhDP/QkL0XSPsXDAPYJB3OW6aA== X-Received: by 2002:a05:600c:a:b0:424:ad14:6b79 with SMTP id 5b1f17b1804b1-424ad146e41mr34288125e9.8.1719505743684; Thu, 27 Jun 2024 09:29:03 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 09/11] hw/sd/sdcard: Convert SD_STATUS to generic_read_byte (ACMD13) Date: Thu, 27 Jun 2024 18:27:27 +0200 Message-ID: <20240627162729.80909-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719505761871100009 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index ccf81b9e59..1c4811f410 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1703,10 +1703,9 @@ static sd_rsp_type_t sd_app_command(SDState *sd, case 13: /* ACMD13: SD_STATUS */ switch (sd->state) { case sd_transfer_state: - sd->state =3D sd_sendingdata_state; - sd->data_start =3D 0; - sd->data_offset =3D 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, + sd->sd_status, + sizeof(sd->sd_status)); =20 default: break; @@ -2136,6 +2135,7 @@ uint8_t sd_read_byte(SDState *sd) case 6: /* CMD6: SWITCH_FUNCTION */ case 9: /* CMD9: SEND_CSD */ case 10: /* CMD10: SEND_CID */ + case 13: /* ACMD13: SD_STATUS */ case 17: /* CMD17: READ_SINGLE_BLOCK */ case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ case 30: /* CMD30: SEND_WRITE_PROT */ @@ -2143,13 +2143,6 @@ uint8_t sd_read_byte(SDState *sd) sd_generic_read_byte(sd, &ret); break; =20 - case 13: /* ACMD13: SD_STATUS */ - ret =3D sd->sd_status[sd->data_offset ++]; - - if (sd->data_offset >=3D sizeof(sd->sd_status)) - sd->state =3D sd_transfer_state; - break; - case 18: /* CMD18: READ_MULTIPLE_BLOCK */ if (sd->data_offset =3D=3D 0) { if (!address_in_range(sd, "READ_MULTIPLE_BLOCK", --=20 2.41.0 From nobody Sun Nov 24 23:08:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719505768; cv=none; d=zohomail.com; s=zohoarc; b=MfwJ4jl6qa9PLtruJgiWI70WwJF2cD8wpV5mpHrMEO7e/GWhSeT3P0qJV1Kgk8gcPVnFwd6AlBmaPpQdftCCQ72MwuXsq2ciBMuNllQpcHxi5sRskYQ8V6HGfHqNodep3JVrzAJkOjcfp9pVGqvjIuwFHWUVpogBUXJDZ1D2ly8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719505768; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sU/k2Rks1jINZkUZw0aLSNYbtB22cqllnIk+1At/gmc=; b=dDj9IgjqhcQh1j9/hs3Cu1t2k9RxoFZ2hmTYD3HNB1DBKZj0A1VV0qUU4HvhQx4Uj/KymgA47MAgkz2YlWRrYtrOxos41Ga6Fqno88tSZk5vy3iEn3Jo2Yi4sh/sOfxQ4R86YiNDSpb+ZHrHu08e8dUWPs7bR2X9KEqXwgYouUg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171950576874285.53596088809957; Thu, 27 Jun 2024 09:29:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrzz-0006vI-00; Thu, 27 Jun 2024 12:29:27 -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 1sMrzx-0006q2-IO for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:29:25 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrzq-0003aI-4W for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:29:25 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52ce01403f6so5520727e87.0 for ; Thu, 27 Jun 2024 09:29:17 -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-3674357c089sm2415473f8f.7.2024.06.27.09.29.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:29:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505756; x=1720110556; 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=sU/k2Rks1jINZkUZw0aLSNYbtB22cqllnIk+1At/gmc=; b=TqP9ojXbJFcm1yNC/pr4FP1p946PY4m1Y+0dm6be54VvGs9u8DRH3Rtb646ouGkBZC 0nq2k9Ih4/zo2Di3frvKD3Wh07Ej7FGWQziQr3tZ7E2br43uQMhqg3DkucFYWDaQGbiS 2NDPdrZ6MDItKWc4Fx/he1vWKb/w7ycvkkzW33J4zh2QHyihwoAw2VoLLIIMsYs6sOvK DDyWECjZS0CtkR5tzsGJeaQX014PNh2Ke/hLx4E5q6iBnsIfRw01W8iVg1PMNCzEusBj zPyGedHcy5ZgkUb73TAWx0W6wXcJna7xFk/dQh74y7hWe5CkzFB2ZS0iEmJex8TJjgrt 21Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505756; x=1720110556; 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=sU/k2Rks1jINZkUZw0aLSNYbtB22cqllnIk+1At/gmc=; b=xJkzD9g35yl77afFrrYVQndkyIG85TsFGzWQ+6mGbSa/69lLnJkYNOcuEx7TLmoj4t lfONqZ5FWBmIqxOikGFlSagp3M2eTk47HISxwL3C3U/+8ENd0OU95m6Q/tPCv40PL743 F5a/6Z4za3j7sCa4tvNyBpoA+t7w41usR8ep0btnsRODwYIiudbkndGnC75DdUB/xUIz pd3xjZFlCmh71Mf9kwgCgZGqBvjMvhMVZd+Z/O8Ai/fy+uClgTjM/C+yV5yhLRZzXFbg nFLuNjo+ZKu8QOcu+o8TNx5b002dr/BFPvmv07aoj5g9YfT7QY/b9YHhGfj59s+2zCwt m6PQ== X-Gm-Message-State: AOJu0YzziWd6rMMXJEwWFUwAbiaoNmsNGOeQ5S65pvCEBLEnruhQQHLY UkFGWJIZ96zfOoe1y4ETOe6D7pnG6ewDMq1rxQ1RczPYYe2kO1bsi6O3MpH6hhH1jqs3w3oxrnk qMkU= X-Google-Smtp-Source: AGHT+IHVx04c6zs3uE+wkMDQmBW/+FLRPc3iuxJ3WbDGxnyqNrR5Vx9zRuGSaTsFTsXAzpnK9r3xOQ== X-Received: by 2002:a05:6512:2509:b0:52d:b0a5:cf3c with SMTP id 2adb3069b0e04-52db0a5e327mr5459783e87.40.1719505755838; Thu, 27 Jun 2024 09:29:15 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 10/11] hw/sd/sdcard: Convert SEND_NUM_WR_BLOCKS to generic_read_byte (ACMD22) Date: Thu, 27 Jun 2024 18:27:28 +0200 Message-ID: <20240627162729.80909-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=philmd@linaro.org; helo=mail-lf1-x133.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719505769958100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1c4811f410..8d02cd9a26 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1715,11 +1715,9 @@ static sd_rsp_type_t sd_app_command(SDState *sd, case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ switch (sd->state) { case sd_transfer_state: - stl_be_p(sd->data, sd->blk_written); - sd->state =3D sd_sendingdata_state; - sd->data_start =3D 0; - sd->data_offset =3D 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, + &sd->blk_written, + sizeof(sd->blk_written)); =20 default: break; @@ -2138,6 +2136,7 @@ uint8_t sd_read_byte(SDState *sd) case 13: /* ACMD13: SD_STATUS */ case 17: /* CMD17: READ_SINGLE_BLOCK */ case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ + case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ case 30: /* CMD30: SEND_WRITE_PROT */ case 56: /* CMD56: GEN_CMD */ sd_generic_read_byte(sd, &ret); @@ -2167,13 +2166,6 @@ uint8_t sd_read_byte(SDState *sd) } break; =20 - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ - ret =3D sd->data[sd->data_offset ++]; - - if (sd->data_offset >=3D 4) - sd->state =3D sd_transfer_state; - break; - case 51: /* ACMD51: SEND_SCR */ ret =3D sd->scr[sd->data_offset ++]; =20 --=20 2.41.0 From nobody Sun Nov 24 23:08:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719505775; cv=none; d=zohomail.com; s=zohoarc; b=cuRyYup2MzvPRdwuRubnvuARzuWFza1UaYSh+kZHAvF9PURpqE2mHEiKlnqttqkKL6ZPpQ+fT7ajYjjzz9C0tELvmVqnVWx2p7ls/XmcftcF0Siu6j8dkvSOUPQWYbkQd6GmTAyaycTvxXqohi9QGze8mxlJU/8fimtq2R/ozSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719505775; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SsWzBaT42Pcps68Pqu01vvv+C6po3s8FyjpSWrBt7mI=; b=dC7Q1QRWNojjVQOVsazgWSFklc0wUH6ZPrQ89v3bxOM/NI1Cp+vXK0M65dkPrLoh6nYi70xDyqTeAOecqr7PF/tHD6eOBUiXZib+XMOR40XE1ELk1vFVxh7YRl9+VYYHAOd5tL4gSdd/J/vlV3uNsG3LgcqTMpQojD8U+GDYjYI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719505775832111.31037592722771; Thu, 27 Jun 2024 09:29:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMs02-0007AM-Sg; Thu, 27 Jun 2024 12:29:30 -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 1sMs01-00074B-1n for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:29:29 -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 1sMrzz-0003bX-HC for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:29:28 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-424a3ccd0c0so27143405e9.1 for ; Thu, 27 Jun 2024 09:29:27 -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-424c82515a1sm74222825e9.12.2024.06.27.09.29.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505766; x=1720110566; 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=SsWzBaT42Pcps68Pqu01vvv+C6po3s8FyjpSWrBt7mI=; b=Dcfd+7nlE+ewoAwUDSjc/r/mqsb3XPO8/+oXQ56IWGPFPKdqLhRvqHmYl8CcTXo4ak yHUWHtg7JaMIB3SR5j78jMboWsk0hBPyHUoQGYQi1f3/V18M2XfdNpHdfjZklHjfsEGh lNzCxsgjOEtkfudVR16vfmWCieT1QmrKQQOt7Ivbcth2xxVVf6vZBqZlEXiZRs7M+YCA R2H8k+MtfdEC9sb/IuHcPx20wItTZX0WuKDJiGntrX+r449qJ072cMKg5Tar52y74/ql xf/iHAENHPfumpn/2Eg1djK7y5EV14nm+rHUEvUqBbBgYRFkLAbcRyfqo849l/hpfx1P iZcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505766; x=1720110566; 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=SsWzBaT42Pcps68Pqu01vvv+C6po3s8FyjpSWrBt7mI=; b=fp5+N7emuU5Zj/vdrOGoOhrE1wxHVAE5zUYKLEZ4LPdM+6r7FLvSS18OmzEog1QvLE rrqiF+d430wGKF/Szm+r5Uc/xNK6HeAroZwXLoDIPsaUh5V9EiOI6SL5frZnjQohYR53 nJw3AvVfG4nGeE+Cns2aBldjmC1X2n9TrhpDcchG6ksB2PIpQ13oKWm+J2pwZntgDdxd rSqHHmdq3Q/hTTZlJSOvKjRrLWgGiipdt+jl9Vh0pglR6Vrfn6DjlYtG+zuJWjmb8b7L a+UHfnfmkR+g4eR5zeH4L6j9POXTf22qY6IO5/u4WFQaCj8PGfXtT/oIeYEsGJRAUpR9 qAlQ== X-Gm-Message-State: AOJu0Yz2yh9L+ZBo+4tLnUc6gtg3SunhiBAQ9nNpNJYoKcDKbf1ag3O2 fun3trwgklWh39B8RNx7TO95Y5qjLm6ysTDSeZdLVGz15ShBEiZrm69XTdmFQWbYOHxRF7wlteM lt1w= X-Google-Smtp-Source: AGHT+IFgCdL0TqWPSgt/xNLI4B03zvFMb/iuY8G0yTEcPxIfljbMakW/wbaqjlPJ0laXuuVoA7D9OQ== X-Received: by 2002:a05:600c:3b8b:b0:425:69b7:3361 with SMTP id 5b1f17b1804b1-42569b7352bmr1511495e9.18.1719505765858; Thu, 27 Jun 2024 09:29:25 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 11/11] hw/sd/sdcard: Convert SEND_SCR to generic_read_byte (ACMD51) Date: Thu, 27 Jun 2024 18:27:29 +0200 Message-ID: <20240627162729.80909-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719505778016100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 8d02cd9a26..cd308e9a89 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1785,10 +1785,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd, case 51: /* ACMD51: SEND_SCR */ switch (sd->state) { case sd_transfer_state: - sd->state =3D sd_sendingdata_state; - sd->data_start =3D 0; - sd->data_offset =3D 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, sd->scr, sizeof(sd->s= cr)); =20 default: break; @@ -2138,6 +2135,7 @@ uint8_t sd_read_byte(SDState *sd) case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ case 30: /* CMD30: SEND_WRITE_PROT */ + case 51: /* ACMD51: SEND_SCR */ case 56: /* CMD56: GEN_CMD */ sd_generic_read_byte(sd, &ret); break; @@ -2166,13 +2164,6 @@ uint8_t sd_read_byte(SDState *sd) } break; =20 - case 51: /* ACMD51: SEND_SCR */ - ret =3D sd->scr[sd->data_offset ++]; - - if (sd->data_offset >=3D sizeof(sd->scr)) - sd->state =3D sd_transfer_state; - break; - default: qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__); return 0x00; --=20 2.41.0