From nobody Thu Sep 19 01:01:51 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719505522; cv=none; d=zohomail.com; s=zohoarc; b=DSuxJRzmJo7beLN3U/9wby6tAjXFo/eIUA3DbYrfh2r+4ZPu7bpB2v+f32N/KK2iqR40dw7rbC3PtP5ctpnXPJL6/qp0tRxUm1IN3QNkmJnss4MJg6JOT/dud5pisF4k0vwaIoY/9wwkJkKG7rOEBAbvjLQpYiLa11titK+95Mk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719505522; 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=wrQTXcopwoxdy2+QKjolzASBZvpHRSjsIoJ+STiyvF8=; b=FccAeXZ0lPtVGXOgeSY3mzUuRuwiYigvRT1nOyzb7bdveKXbD2YiZIH/t3Has5ABnsuIIL/PV1hMQoyxeqUFeSyL2Fi14ASjYEoZaLDHR7P8j1BMQOOvDducFF80QkBFXemW+Xet6BL+r5Ikm/5zr1SeydCsucnVYq6c7q83uAM= 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+importer2=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 17195055227925.211237211604157; Thu, 27 Jun 2024 09:25:22 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IFVInSIcNR0npaDmYdZJoWs9nn7TsAQUx5OMi6YRV4gIMxIMMyPzvzt7Lc2dm6YTqERnTJvAQ== 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= 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 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719505524465100005 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=C3=A9 Tested-by: C=C3=A9dric 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 *s= d, SDRequest req) /* CMD0 */ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) { - if (sd->state !=3D sd_inactive_state) { - sd->state =3D sd_idle_state; - sd_reset(DEVICE(sd)); - } + sd->state =3D sd_idle_state; + sd_reset(DEVICE(sd)); =20 return sd_is_spi(sd) ? sd_r1 : sd_r0; } @@ -1579,7 +1577,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest 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; } =20 + if (sd->state =3D=3D sd_inactive_state) { + rtype =3D sd_illegal; + goto send_response; + } + if (sd_req_crc_validate(req)) { sd->card_status |=3D COM_CRC_ERROR; rtype =3D sd_illegal; --=20 2.41.0