From patchwork Mon Jun 24 13:14:35 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: 807032 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1877863wrt; Mon, 24 Jun 2024 06:17:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWwDVjTIxde2yP0rxRX+Pe1O5UEEyB1ffyN8IGoyjBQMpBKExpQ6GJ28pjqaFTMYyUpuYE9nYYl2b4V5eJw2sp5 X-Google-Smtp-Source: AGHT+IHHc2nt7qR4PoS4MnP9sL9KxLSzADwcGQ+vnYKGPdJtBVe2UMYiGTqnfK2Ed4nMISyLo4BY X-Received: by 2002:a05:6808:238e:b0:3d2:1be8:5487 with SMTP id 5614622812f47-3d54594d872mr5556747b6e.6.1719235045718; Mon, 24 Jun 2024 06:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235045; cv=none; d=google.com; s=arc-20160816; b=b3jQ3VZYLTM2vCDvcGSg/1SqUzomUgVLAaKXJTpBkP3Yu4t3bG8CFS9m7wXhRaV6Bj zNtZi4+O5q+P4IwmwMrCme0IQrhIgbbV/6xMAs74uQR6T+rQibpcaq48sajG8cWyjhg3 pSRnva00IJlKvGUAYuz6svZVQL5lIPjJgOO8AaK9j9xUf1eIkvQX3712B9irjd0fBCQK 1MiSEP2/zXlnN5G0FdFcZL8epX+KVk+pOgz95s2cY4Z9yVDgPydLnb7M4JJTeTpCPSTj QCu3uRusLL5vPx8NsDJSYvAKM2aeEymtjcKUwBgOknsG1Pq6sq31ebmguZtBAGQc9n6q 3uMA== 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=eqS+9elQ6EjTafFx/IwJ/1Wg3fHnvg3mIfJwf3uEmvY=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=I+I2xkje8aG+UsG30Iym0Im2gx9BouksKYsIilAPoE0nYpcAVFodQwjQY9goKX6Urf FP17iqTmIjiZucvDeP/+m4Nb7CnTMD8riF4wbdHajWhKufam19+sB8Z0bNN2cE+obVG8 f4RfQ6rkOjePhR/fxFkvymZnQglsz1o+hktb8aaTwiHJMXkODXBLhIxQ7xb5DwYheDWJ aUBFvTM+ueXbMNE7z97Nwt1e9vkGX57flOke4AFLWkJPaMWgK6dueNrkrc3hrz3f+Y/+ 23SsaZyIeXutggV2uqFIpmwNDdOqZ70//fWB1AAq0lnWnCDrx/eEC7aDely0oNgXFAZt PCtg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j6LrmzLp; 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-444c2c9f7dcsi81514401cf.733.2024.06.24.06.17.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:17:25 -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=j6LrmzLp; 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 1sLjYc-0004OG-RD; Mon, 24 Jun 2024 09:16:37 -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 1sLjYB-00041k-U7 for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:08 -0400 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjY9-0005Yr-UK for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:03 -0400 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-52cdf4bc083so2683836e87.2 for ; Mon, 24 Jun 2024 06:16:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234959; x=1719839759; 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=eqS+9elQ6EjTafFx/IwJ/1Wg3fHnvg3mIfJwf3uEmvY=; b=j6LrmzLp1nqmfhoMaLu63dcyl+6zSn0FVgkqczhcjradNyZjtfgYDXlFBmS16Xq7ln K5g+H/Cj6U5ubhnOqwMtFxsKfCdoUYAE6qUmhgNb0XSlLr7dcJTuSe4YIe+uH2qgKSe6 OfApWZgt0b7UOHIsZ7DbmaRBvSMDXjguxBXV2ROzlSajGkmgT3wQDczLVZIntbu/3fLh EW8KhBx/LslVM99t/zpDCqOdwfJ52uHHV8yRLFY43WPAZg8IeaymZiS5zag5yogvwYWX YdVNVvVDubysueZryklvPs/4THOfl1F3/04gO1vRwAPlq+IvnT8nR/g1PRLUjWfnXF9U bPAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234959; x=1719839759; 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=eqS+9elQ6EjTafFx/IwJ/1Wg3fHnvg3mIfJwf3uEmvY=; b=jSExQW3aehf609BUqMPzFyM2x1CNpV8NGhaOKOkIC7mrx+HeCrcjNNVjcLBznTDOYc Uw8nu9HoBoiryTRiv12Ra/u2OfouKc4lgA3y4Nzw8AZKhsFtNYi4RztMQfx9z7wZcTWo nWpN0Nc/7JD+BJAD7m0rbkzVoe7ySVfpwMvIzlUoD2pBo3JYbFHhmUh9jms7EZ0irLGS 13GoF2Zb5AnoFc85SA9qix6bE0wWqYD3io9VzpDR4BHAbhXFu7G/MvXj5i5hwK+OhJk1 i2+FJlVW6e77EHuhrwLAZhh/AMoOnzj06ZrJJ4x5kZ4LB4geanmosfyJ3omBnChu5QBB Vh+Q== X-Gm-Message-State: AOJu0Yw7qoe1hVqMxCZ7AaHxgrG9KtHAgCJOCvZbUWwRO3A/J+mLffJY 2hAbtVPjWzAwjgaegBxui36p6oZPJpLiuljYIZ81NwGL7GQDy0PKBHGUYpZ1muvSxBuGuGOY6// F X-Received: by 2002:a05:6512:1050:b0:52c:e012:efad with SMTP id 2adb3069b0e04-52ce0610531mr4941757e87.12.1719234959448; Mon, 24 Jun 2024 06:15:59 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248191116fsm139386125e9.37.2024.06.24.06.15.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:15:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 14/19] hw/sd/sdcard: Only call sd_req_get_rca() where RCA is used Date: Mon, 24 Jun 2024 15:14:35 +0200 Message-ID: <20240624131440.81111-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=philmd@linaro.org; helo=mail-lf1-x12c.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 It will be useful later to assert only AC commands (Addressed point-to-point Commands, defined as the 'sd_ac' enum) extract the RCA value from the command argument. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-16-philmd@linaro.org> --- hw/sd/sd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b909a85d53..912b2f8984 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1105,7 +1105,7 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { - uint16_t rca = sd_req_get_rca(sd, req); + uint16_t rca; uint64_t addr = (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : req.arg; /* CMD55 precedes an ACMD, so we are not interested in tracing it. @@ -1162,6 +1162,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 7: /* CMD7: SELECT/DESELECT_CARD */ + rca = sd_req_get_rca(sd, req); switch (sd->state) { case sd_standby_state: if (sd->rca != rca) @@ -1216,6 +1217,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_r7; case 9: /* CMD9: SEND_CSD */ + rca = sd_req_get_rca(sd, req); switch (sd->state) { case sd_standby_state: if (sd->rca != rca) @@ -1239,6 +1241,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 10: /* CMD10: SEND_CID */ + rca = sd_req_get_rca(sd, req); switch (sd->state) { case sd_standby_state: if (sd->rca != rca) @@ -1279,6 +1282,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 13: /* CMD13: SEND_STATUS */ + rca = sd_req_get_rca(sd, req); switch (sd->mode) { case sd_data_transfer_mode: if (!sd_is_spi(sd) && sd->rca != rca) { @@ -1293,6 +1297,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 15: /* CMD15: GO_INACTIVE_STATE */ + rca = sd_req_get_rca(sd, req); switch (sd->mode) { case sd_data_transfer_mode: if (sd->rca != rca) @@ -1525,6 +1530,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) /* Application specific commands (Class 8) */ case 55: /* CMD55: APP_CMD */ + rca = sd_req_get_rca(sd, req); switch (sd->state) { case sd_ready_state: case sd_identification_state: