From patchwork Tue Jul 9 15:25:50 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: 811452 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp346093wrn; Tue, 9 Jul 2024 08:28:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVMGEwrkyfe8vYXIGbsZXmGMT7nnK67OPjDmall0RzikgkplhZONnUsmEfUYW2RNqsp1r3iZlvhQaZgAhZGo6xY X-Google-Smtp-Source: AGHT+IFwTRujSwBk0kmP7oknyX1Up7ENu6JB+AmNc7PWqCB4DP6ZdVTsdbd6YIHfzf40ZazK+Tyu X-Received: by 2002:a05:620a:5642:b0:79e:fef3:ba3 with SMTP id af79cd13be357-79f19a3738cmr276671885a.3.1720538923032; Tue, 09 Jul 2024 08:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538923; cv=none; d=google.com; s=arc-20160816; b=xf88Lfcf5LlxGCqM2e4CipzFUzZ4ys0JuS2ILpOhspDjBCZ1oLoEO8YKRoz2xz8ReD a+FdVo2eozGzcC5ZqwMjlWIFJzNe/6E6tESiU1iI8zHi9pU2ACP3MRov1/Rz4iUVCwt6 r8GMpvdgO5Oh+tGxd9pwsctQM9TMGsSSSwQNidzjdItB1NQKLByrcPFYOx9LbzC58EAa rnRO5QRti74cvS5jw8IxWRU3mX8aOVNL3DkTOYxF3EvmEFJAqXzo9+F9cCmuOV2jIdLp cTc3MQANC7pBxiNMfaMcHixye1+kRa5+i/2nXSYGBJGdQYkKN6FwlgODizG9L+Pzifm1 DwlQ== 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=PiXvczI/K3L/YAxv9emlFnk584vxqItosgTLQuNQXtQ=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=tGDKp1qA9KJ2sIjtd3gy7pV0wlSCm2NKONqqnA26qbsPaz/BtE0Oq0yEHG+dEJOEGh eabWfDIPB+Xugm5YPldA82JHXRCyfkb3BWuxXBB8Bq69cnyE/tz8DiCesAHNVcAR3QO5 kNYLL+IdpOvqk7mAY2uxipviw0KkgpZtf/c/1TUbs/k73+Aw0mErTjjQJDKYuB6cpN+4 n2rRA4DX21DDt+cZwl64G6VUtG9DpQavYmqyL6fA5V+s7gTps/DX+7L+ivFJhYdMTxfY Ct7rd0NGxF9Fo2OikYksPTCH6nhi3DZy11gngVqPEFokbmr+Vp8S8IOeZ0bL5aZkoWQw T3xg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pH3AEk9+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79f1900e973si227732685a.65.2024.07.09.08.28.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:28:43 -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=pH3AEk9+; 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 1sRCkX-0008Kv-Mz; Tue, 09 Jul 2024 11:27:25 -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 1sRCkW-00086K-DP for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:24 -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 1sRCkU-0006P5-Jl for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:24 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52e9c55febcso6912840e87.2 for ; Tue, 09 Jul 2024 08:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538840; x=1721143640; 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=PiXvczI/K3L/YAxv9emlFnk584vxqItosgTLQuNQXtQ=; b=pH3AEk9+8CnSYWfSBZbiBgmEJcvi5aWFN8nrFWu6D86kbWrDIxBHb9lUGqp88x/aYn 4ZlnIO2v8ZgXil08ppfuXWHcUy56j9rcznUs8JPU22BhQ0iOXZWOcwWqh48uYX3KxxmJ iXU95s9/UXsdIp091jewSPF/tiETWTxS52WC74Sp4xzwzqgPDJgBVjKRLsOX6TmF6Xvx DSW84vErpXK+DA0RfCcwz1WqnW0C4LjXOOW6JLT3Vo9Ck08mWNn8LlKSf59icCQA8Rg2 Y0pvYt0UnEUE4LFRcAVVTtPH1rtM/41vx1RV4ei+GUA2BTWIh6ppbbwWMyfieePDncAr pCwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538840; x=1721143640; 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=PiXvczI/K3L/YAxv9emlFnk584vxqItosgTLQuNQXtQ=; b=k/41gYokfg1aZu4n8MuRxGC1xBWBKvbnTFJeQ1UYnGJAYAj9BiE1J9N+OTnG/ReMtU 1SDCenijNMyHhSe+As5GrXPZZfIrdUtxsHw8W0KEzPxtx4AKkcG6sjmkfSbVIy+KrQBh eJa+e7oI494RlqJp/CuEV7v4OnnQWlhJeUk3TGiVH9xj/xRtwztAdK9Ry5xrWOTi7juT C/e7Xa2SbeCcj5bp27RSBzsSypGhgwQy3eTxuWyFleRVagk0RVuLznsylfDT/j3b3S9D IXcGMt9VUteuwQ8NK5v//Pu6JnbI86bym8z+SVw0Ok4B/v/r04LNdn1bJvlQrN4RLMMp AllA== X-Gm-Message-State: AOJu0YwTWpXSYup/j5VeHWcwREK2MwZ0KPLGXKy1Y1SePB5dZWQwJ31c CWjiinfWXlMahh3jdUzyzxr2NrA7ruvYOTyMO/5rbe/1mQIj/pVXjRdKN2P6AtNG5KhsspJar4n 2 X-Received: by 2002:a19:f80d:0:b0:52e:97dc:f5c4 with SMTP id 2adb3069b0e04-52eb999b36cmr1551519e87.25.1720538840211; Tue, 09 Jul 2024 08:27:20 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427270238a6sm12811475e9.20.2024.07.09.08.27.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:27:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [PATCH v47 13/19] hw/sd/sdcard: Migrate ExtCSD 'modes' register Date: Tue, 9 Jul 2024 17:25:50 +0200 Message-ID: <20240709152556.52896-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=philmd@linaro.org; helo=mail-lf1-x129.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Spec v4.3, chapter 8.4 "Extended CSD register": The Extended CSD register defines the card properties and selected modes. It is 512 bytes long. The most significant 320 bytes are the Properties segment, which defines the card capabilities and cannot be modified by the host. The lower 192 bytes are the Modes segment, which defines the configuration the card is working in. Only migrate the Modes segment (192 lower bytes). Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2a687977d1..a391f12b2a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -124,7 +124,13 @@ struct SDState { uint16_t rca; uint32_t card_status; uint8_t sd_status[64]; - uint8_t ext_csd[512]; + union { + uint8_t ext_csd[512]; + struct { + uint8_t ext_csd_rw[192]; /* Modes segment */ + uint8_t ext_csd_ro[320]; /* Properties segment */ + }; + }; /* Static properties */ @@ -881,6 +887,24 @@ static const VMStateDescription sd_ocr_vmstate = { }, }; +static bool vmstate_needed_for_emmc(void *opaque) +{ + SDState *sd = opaque; + + return sd_is_emmc(sd); +} + +static const VMStateDescription emmc_extcsd_vmstate = { + .name = "sd-card/ext_csd_modes-state", + .version_id = 1, + .minimum_version_id = 1, + .needed = vmstate_needed_for_emmc, + .fields = (const VMStateField[]) { + VMSTATE_UINT8_ARRAY(ext_csd_rw, SDState, 192), + VMSTATE_END_OF_LIST() + }, +}; + static int sd_vmstate_pre_load(void *opaque) { SDState *sd = opaque; @@ -928,6 +952,7 @@ static const VMStateDescription sd_vmstate = { }, .subsections = (const VMStateDescription * const []) { &sd_ocr_vmstate, + &emmc_extcsd_vmstate, NULL }, };