From patchwork Fri Jun 28 07:00:37 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: 808149 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp221474wrr; Fri, 28 Jun 2024 00:03:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWCLLdTvOXm1e5ccEr9ktU/GnYX4lLhCsfaG3YwUXHq7GJzGEHg9x6ReRiDHgMD8MctWzHmACYa2O+mq5Bvh4us X-Google-Smtp-Source: AGHT+IH9hKZQplMjavaW9c/QtnB9EILjad7Uzm9FFy/py07F5lxeuvNoFpVRHviFEw8Cx6XhZzA6 X-Received: by 2002:a0c:e387:0:b0:6b2:d51f:f53 with SMTP id 6a1803df08f44-6b5409a5024mr154509166d6.5.1719558206492; Fri, 28 Jun 2024 00:03:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558206; cv=none; d=google.com; s=arc-20160816; b=tLv3xlz9Hbg5O+OPifp7ziGhC91RVOiLdHL6gz252AXN4h8v4S4r7ATYQ6d+1y+GOJ dS25h7TqMEfjRayp7NN2mMfwiJFmZ6dg7Tmh/Ie3TRd4JwCBzSQ/UuSNXTz70lNi4CeY GOCRjjMSnvzcT+MYDq5qnz1e5zoC/3RD7v8xdwBjZuqki5BX8b+yaBAk4+ZYBmrTorpv fmK8BOlBiQhM2aHLqZQ7xI3Y3DPodNo2dHTHWHdTBHkELBvFcFjnQUsbhOHbNSlPi3Ly uMRrWSqschwVxk9n/XMqXpsXTiz9WFCYjXBa/BmTy73IVrjLyLdDMytL0Cgm8iEd8qdI 77pA== 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:to:from :dkim-signature; bh=FehxPMt54YZs4mKlk2O0dDcvxQwBqAiau0Ry18uuTzM=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=YuTN3CZiNCXElCasH6tGwaNAzUNAyF0u4PqJWUL3WXTIFX//A6UIbY7sZeBItzZE2Y m4I1mdiMXDRZGdGBjqJmyeUm1DyoSKad7sRuXR+2PSnRC0E+1KictNAa72CEYDlxNCEk fq4t9JPsMWHKR8O2xegwQW+nDg7J9ow1VUCSo4XgiriPbDg+E2SXvRPm8MZ1h3+nZX77 z2YDZoa6KpF3crfvTy7U5G6j/O7xnALNY523FdV8j3GjcAg3BLR1byCJ+pPPtWKgOFX0 a+ntBZvvaXCSQ0RXjsdPJZ+mF5iOXwS72RPp0fCYD0GXPJqihwxm1ADvTOCwRfc6ocRx JS+Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YkdUKSZv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e5f0ab9si13499976d6.415.2024.06.28.00.03.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:03:26 -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=YkdUKSZv; 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 1sN5cr-0008PJ-Jo; Fri, 28 Jun 2024 03:02:29 -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 1sN5cq-0008P9-AA for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:02:28 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5co-0006b0-Lw for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:02:28 -0400 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-52cd717ec07so323065e87.0 for ; Fri, 28 Jun 2024 00:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558144; x=1720162944; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=FehxPMt54YZs4mKlk2O0dDcvxQwBqAiau0Ry18uuTzM=; b=YkdUKSZvBxlzCL2FhxtSNN1rZURbqWmgiKM6w2CnlmdIEiWBz5wg/FPY9/eUEZO9aI ilVUequ2ML/u42GoPc9uXGYJpOSr0AZWsdUY+Kdx+rIEQyC2C9G1UOnHdTUFzz7sZYZy BwIRHZJ75pwd6+hBulZbpowuD6bRNkq8aSJC67c8InhZGSW3oX5LeEOSKeOv+e2RuXm4 M9M3C1wSEaxVrzyHEXhDkhbzFrik0Ml0MOVQXQM+DVHsr2C7eKmbEa3iLCIpUVPAXqSx zbaP4hCNFZPAV5u27XfsU8uqKshSJy46ow7aWW7DtiFzRdzUynY4kbUhy9ilcm7R8W5K gTBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558144; x=1720162944; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FehxPMt54YZs4mKlk2O0dDcvxQwBqAiau0Ry18uuTzM=; b=m085V92FtKpdiqv0acxqdp17zUCvCPTUFdsvoM/Be/G2y5MJ88iU/FK+CcoU3+zNX9 uzunD26FsdAWF963GYlmmEiNlCoDcCn9v0dq8j6pOuAfyMoEUqhbdElj17K0QmWKJF+V DcdIgkXLour+G/Ic/U3PNpEMkzfPZHCCL7x5qUB7iit/nc3w82rUxV/RKkNbIna+kVXm 8XjrP8NiPvJLVJVD3jDyp23iBJOcTicqHKghecrTf4iq+9O5Y8SUoyGfzdB2Kz4wcz81 lQzLp2Hv6za5uWrBD/u3alSzoz3Nb2Pgm+FxNZF4GiIaQ+6Q3fzTJiLAD5L3lKnJqu2C x4FA== X-Gm-Message-State: AOJu0YwFzbXj1Kfsw5geQ+BOSw1ljrN8HyAc/lihGQurM6/rjpMdH4aX iqqCcx2cKGNb+XhnFB8B7PaDf9bTsSCDwduk+X8Tq2QsX21lTSm5ssjl9GfymnAemGviWwp0WNO tR5g= X-Received: by 2002:a05:6512:a8c:b0:52e:7496:596f with SMTP id 2adb3069b0e04-52e74965ac0mr1875211e87.60.1719558144165; Fri, 28 Jun 2024 00:02:24 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b097bcbsm21297625e9.35.2024.06.28.00.02.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:02:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 01/98] hw/sd/sdcard: Deprecate support for spec v1.10 Date: Fri, 28 Jun 2024 09:00:37 +0200 Message-ID: <20240628070216.92609-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=philmd@linaro.org; helo=mail-lf1-x12e.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 We use the v2.00 spec by default since commit 2f0939c234 ("sdcard: Add a 'spec_version' property, default to Spec v2.00"). Time to deprecate the v1.10 which doesn't bring much, and is not tested. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- docs/about/deprecated.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index ff3da68208..02cdef14aa 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -362,6 +362,12 @@ recommending to switch to their stable counterparts: - "Zve64f" should be replaced with "zve64f" - "Zve64d" should be replaced with "zve64d" +``-device sd-card,spec_version=1`` (since 9.1) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +SD physical layer specification v2.00 supersedes the v1.10 one. +v2.00 is the default since QEMU 3.0.0. + Block device options '''''''''''''''''''' From patchwork Fri Jun 28 07:00:38 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: 808146 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp221362wrr; Fri, 28 Jun 2024 00:03:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXNa8uPz9a8GcI5R+4IoGKqpmJO2zuxLZEmdbcSpFa7fS+IdlI96RjbHP1SsCL1zweGIt+YX+ZLQBAqTEk7sYKK X-Google-Smtp-Source: AGHT+IFOW0/ZC0ey3s157/4HvkmEimsNInwVE98jBPGacxPYxi/KhfimY2jm+1FSA59Qp57/sW9w X-Received: by 2002:a05:622a:10d:b0:446:57c7:4761 with SMTP id d75a77b69052e-44657c748cfmr4382911cf.1.1719558189307; Fri, 28 Jun 2024 00:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558189; cv=none; d=google.com; s=arc-20160816; b=qxTY7T97ColLUkYMb4ZyYYXh00F7JH8I1X/mUWxFsIl9K8WozATfpiQLQlKui9EpY5 gJ8dhjC1EFSVTQjYVjZ9Ogh3zVBQfZMa8b3x8McL9clRhc+1X+wrkNLyeSWrc1O0t8B9 uAKdITwVHuKMj6nrKXftRBlBTDIUOC3qhhSfL2S0YjRmD5R26fe+pr0CQixo9DSi7Tik 67p9evDef3EERQ9CzgbyBZIJqVk0UIsLh+mD4CIwArvyU2EvrHe3eAQmNmuq+IFfQVhm IpjA78KZWSJwDj2oe+lMWtlyLL7dGRpSl4ksHVhbIbZ64mCQbt9EAsZaNR/xboQrSypk lrHA== 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:to:from :dkim-signature; bh=q0dLi7LJeAuLomgAe/dqexun4vtTcne+GTOKHsnzMSk=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=oIpJ3KqddEvpAsSRqPNBVx4zxXip7QcoanKNLqmBqgY5pxFF2MKNGszmSVO1Fp1daC rDboZF7ael3X541HeHOF6kt3yAha8BlAYk3z4rWFvwsn8xRQ4SyxphJ6YaNUGS6IBLhj QyBwTMBv6MeoWbt2qGSmcqy6j5rmeExKurkTiZwWzveHdLFmfyLXfzy/K27g7SxWFmHd rkip9UxLaUpy1Rt2KCMPTA/P2pi4ywKQp4ipkf9/AtndWXoJhdvDTEWAuKgQHOSrsjk8 Kckm2asBEOoKjBZe9/oqVhX8bRzeiyYFu3AV8rZqSwYxaQrkIrDn1YfYTyYipSZEScRE 2CaQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tttvOkKk; 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-446512cc64bsi13268451cf.62.2024.06.28.00.03.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:03:09 -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=tttvOkKk; 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 1sN5cw-0008QU-BQ; Fri, 28 Jun 2024 03:02:34 -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 1sN5cu-0008QC-PY for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:02:32 -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 1sN5ct-0006ba-7D for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:02:32 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4255fc43f1cso1816605e9.0 for ; Fri, 28 Jun 2024 00:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558149; x=1720162949; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=q0dLi7LJeAuLomgAe/dqexun4vtTcne+GTOKHsnzMSk=; b=tttvOkKkM0YNKxITtkKYISKHX3E3Pi2s6ZpEMes4nr6WsuEDNHAmcXZY41JRAEk/d8 JhM9g+JGdV0ULkGnR/+doLG5/ab8uwrdHeNkCfA0r+9hg1NP2FANSn1lPmSmk94edSaG 3OkzHlD24wkWNL+CGb1LMcq4xqkc6PsjzM8A2MoL48XYgbSZbYQnynduGIk8sCsrkSbJ pFR+R9ARKUyjOJUKw1BRa4moWfkJQ4V597TwdsjO8FFRLr1OvN8H7+DalUbyuc8YR1SZ FrLLHYfo9ycr6q/mdPK+U8X8hMYdFvcVn6ayGjP+dt1KyxSwgbMhUSokvYUK8TvfKTot 5U9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558149; x=1720162949; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q0dLi7LJeAuLomgAe/dqexun4vtTcne+GTOKHsnzMSk=; b=A7lJuPUf9cTcEIlsi6s1xbG9HSHitVtyRhS9hXrYVwNleBEIU0wkVE69uVObBSsl9u Blzzdf8M1bwOibuvBzxzjfr1+Kr7lp5k1tqVvWQN44s8Smv1UkZF3Ke5SFBumCqB9rx5 R+qIEnTv4BiMQ14M71GHdrWYo1Hr49wRWwLnLL094ThWGxP988EowrcjMycMOWHCBxDk FhcLYChRCsRrrTe7wXLMIcP01FSm3clXX43ut0mt0tKqLaTEO5qWv1DZ6jgUSdF+IV6u jUZ/oh6Udtkj//EHtwP3Xh40Js0++0azoUsWMqYdSHuIRwGH2fcYmmh0nqwasGet2dXN ta/w== X-Gm-Message-State: AOJu0YwJiEreABIAjxGa/ed8762yBKHh/SjVEfSKLvcKC7jFyhDqBWBX e03FLoyQjKe4v9WcLIQll0Y22QaICvXl9OtWiykX/e952bMJUjgDWwXeoEXM75GZGyq8isG/cFV XROc= X-Received: by 2002:a05:600c:470d:b0:422:7eca:db41 with SMTP id 5b1f17b1804b1-4248cc18101mr123481815e9.2.1719558149429; Fri, 28 Jun 2024 00:02:29 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424a2abc2desm95968775e9.1.2024.06.28.00.02.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:02:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 02/98] hw/sd/sdcard: Use spec v3.01 by default Date: Fri, 28 Jun 2024 09:00:38 +0200 Message-ID: <20240628070216.92609-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Recent SDHCI expect cards to support the v3.01 spec to negociate lower I/O voltage. Select it by default. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a48010cfc1..d0a1d5db18 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2280,7 +2280,7 @@ static void sd_realize(DeviceState *dev, Error **errp) static Property sd_properties[] = { DEFINE_PROP_UINT8("spec_version", SDState, - spec_version, SD_PHY_SPECv2_00_VERS), + spec_version, SD_PHY_SPECv3_01_VERS), DEFINE_PROP_DRIVE("drive", SDState, blk), /* We do not model the chip select pin, so allow the board to select * whether card should be in SSI or MMC/SD mode. It is also up to the From patchwork Fri Jun 28 07:00:39 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: 808147 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp221363wrr; Fri, 28 Jun 2024 00:03:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX8rAMrWqI1s+ZJS/RgEODWcb/y2xkH+TLdR6ZQ3SLA/fDPzx0uenCnZDgQeKVzAPReGCCazkHDkeXihVykD2C0 X-Google-Smtp-Source: AGHT+IF42/iG6oEsnezbvmgpnkmmBdcm6/Dh0FbFd4WLGSWRsb0/hzJpT64dBaRcZy/wme2x3LXl X-Received: by 2002:a05:6830:d5:b0:700:d627:a3db with SMTP id 46e09a7af769-700d627a92dmr6619016a34.36.1719558189505; Fri, 28 Jun 2024 00:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558189; cv=none; d=google.com; s=arc-20160816; b=CarmIgaI9md29QKvFjU27U/F46DTGvKOwvQ8EFTe8DX6dyjL8+EN/ihlthSWQcLDif 8Xjx3S617V8ILWvyOrPkD6DUoP7iZjAkDJYVwA22sI+B15Pn2AHdRTuExT07sF3c0Szr DExYv41/gn8s6ZWPw9ebMlj2r0uE4J6PG9N/OotdR07VAuiXwmmcjGBQb+XhO+0s8bP3 IPpyi0iQ5OzsIigLcdcIPj8evMChy2Hqc3lkiYZLMXDNd6qQZ5JPYsXNtUtIi8bjAn3F /sT8GmK/C2NYKgSgapGQwxJzMQ+JW+1BnrbIJyyb9/pe80JGYUHUJpzne8e6Tzh0h289 dMUg== 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:to:from :dkim-signature; bh=IJEAX/bFYJE8abBHAC9lGeH6fM4rczNBP33ZEV8FrPw=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=RWAM3l4lbTfq6/b1jh+bjEyArk5Oab15dGUNYnGLrAJJ7m6y/ULmvTaINb5wu1NQRj U9aelxg4kXK0f+cM4jwQShGsQa9nD3OBeHleZRr4+mRMT2fEfY0ZsCxXmHtHyly9yBUX nXCDHP37l3kfVLtgUhfj5Y8au6FuR2zBdRr789w965YqioEOGxKMKtgywqjFjHq0f3r+ nFF95h3DOqDnx9RM2FVyDI1UbD5SyoXXlhB0RLUJzD9ddkL2uNDhzHQlPycwZe/qi9Yn UlqrS/qRKrNU/K41onfj2LOOJezLk8nTg9RwEcDsI2JQUfPbvrQ776mvgU2YJd1HWAT6 0qAw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lY6AscQS; 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-79d69261520si135794385a.65.2024.06.28.00.03.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:03:09 -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=lY6AscQS; 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 1sN5d2-0008Sy-Kw; Fri, 28 Jun 2024 03:02:40 -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 1sN5d0-0008R8-Ni for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:02:38 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5cy-0006cB-ID for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:02:38 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42565697036so8309185e9.1 for ; Fri, 28 Jun 2024 00:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558154; x=1720162954; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=IJEAX/bFYJE8abBHAC9lGeH6fM4rczNBP33ZEV8FrPw=; b=lY6AscQSNN2A7oWWJjiUoAX6C9QG3kDzbTtSd1lZ7bFqM6u/bhRwJ8AtjtUKrQpEfY 1tWSBJBPTmKWXCpGkxxjytwFtSt/kHy3o+ejWdsH0akC6cMsMTmpHUj1Gg6OMVE/qzbm 8b6tyct3oFo4tqdBpwBOJpGh5i0/JA1iCUIPO3ijR8BEK0uqSn6u43+Vac9L8oxvCHN5 lbZz22WcCuXiIBu4m91NEySAaYHNGIE1PU2+cBEB9pWx7fl3F1EKFWC9RH9S1T8f7K15 VjHsH7rF/OXGRXR51HsBuLb3PQVfm+PWkIpm0tP6D/9nVkk/QbF479BmBHbSfXBraXcX Fc7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558154; x=1720162954; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IJEAX/bFYJE8abBHAC9lGeH6fM4rczNBP33ZEV8FrPw=; b=iE2ZF9Wnh3h9D0kObCufQSIxJBEwiP/SUWLHltepjpO3NYhdTpzdrJe1oKi+eI6knB nA3oGShyw8eHGH5GMat/Fg+RmgLDDkObEIMgp+bLzR9TDaa4E7MJhV4pzb229MM0fotm q/YPjTDLIJJfzg4eS+sGyjW3vKqrtI1oPYfCVwqGdrhQP6j3PFuyxkmCChQtdE9x1npz mi646zo8kvOhNABbNkd841yWIn2M+wMvLWaeMLWhAo5xYFevr/2D7KSvdJIO8jNftOsl O8kn+Ox0aB2ywCYmD9E52MBt69da1PmOGybOPtkyk35pNS6S+fFTxMnPZHdMqhMRrIjA xajA== X-Gm-Message-State: AOJu0Yy/DTZqhAxjG1c6aX88/HzSzfNFsQrTcISrLr/3IaPluFUNA5ty RoECY8o7873FeZQwKizIdFMMRtzZY45r299OPiAqcr8lY7PNMo95qvsrgdNNiVLYGoNR2TKUeoF VO+4= X-Received: by 2002:a05:600c:4ecf:b0:421:347a:f0a6 with SMTP id 5b1f17b1804b1-4256d4c1d7cmr5222785e9.3.1719558154671; Fri, 28 Jun 2024 00:02:34 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b099c7dsm21584795e9.38.2024.06.28.00.02.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:02:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 03/98] hw/sd/sdcard: Track last command used to help logging Date: Fri, 28 Jun 2024 09:00:39 +0200 Message-ID: <20240628070216.92609-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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 The command is selected on the I/O lines, and further processing might be done on the DAT lines via the sd_read_byte() and sd_write_byte() handlers. Since these methods can't distinct between normal and APP commands, keep the name of the current command in the SDState and use it in the DAT handlers. This fixes a bug that all normal commands were displayed as APP commands. Fixes: 2ed61fb57b ("sdcard: Display command name when tracing CMD/ACMD") Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d0a1d5db18..bc87807793 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -133,6 +133,7 @@ struct SDState { uint32_t pwd_len; uint8_t function_group[6]; uint8_t current_cmd; + const char *last_cmd_name; /* True if we will handle the next command as an ACMD. Note that this does * *not* track the APP_CMD status bit! */ @@ -1154,12 +1155,13 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) uint16_t rca; uint64_t addr; + sd->last_cmd_name = sd_cmd_name(req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. * However there is no ACMD55, so we want to trace this particular case. */ if (req.cmd != 55 || sd->expecting_acmd) { trace_sdcard_normal_command(sd_proto(sd)->name, - sd_cmd_name(req.cmd), req.cmd, + sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); } @@ -1620,7 +1622,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) static sd_rsp_type_t sd_app_command(SDState *sd, SDRequest req) { - trace_sdcard_app_command(sd_proto(sd)->name, sd_acmd_name(req.cmd), + sd->last_cmd_name = sd_acmd_name(req.cmd); + trace_sdcard_app_command(sd_proto(sd)->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); sd->card_status |= APP_CMD; @@ -1913,7 +1916,7 @@ void sd_write_byte(SDState *sd, uint8_t value) return; trace_sdcard_write_data(sd_proto(sd)->name, - sd_acmd_name(sd->current_cmd), + sd->last_cmd_name, sd->current_cmd, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ @@ -2069,7 +2072,7 @@ uint8_t sd_read_byte(SDState *sd) io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; trace_sdcard_read_data(sd_proto(sd)->name, - sd_acmd_name(sd->current_cmd), + sd->last_cmd_name, sd->current_cmd, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ @@ -2214,6 +2217,7 @@ static void sd_instance_init(Object *obj) { SDState *sd = SD_CARD(obj); + sd->last_cmd_name = "UNSET"; sd->enable = true; sd->ocr_power_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sd_ocr_powerup, sd); } From patchwork Fri Jun 28 07:00:40 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: 808179 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223226wrr; Fri, 28 Jun 2024 00:08:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWe+j9bAu2HzrFPXpiBY4W0JakSGlNuzE3zqYR3h2QgBq2z9ksQuVCx/Xl4oWnew+BxQ6YZ/dzp1HDOCwoztVXO X-Google-Smtp-Source: AGHT+IHQPxG4ukkQCB447TAQkTK/OryBUYiSV8t+xitLiZcvZ4hMP4Z1uaJE3xUk3XekJroKL/It X-Received: by 2002:a05:622a:7a8d:b0:444:fe6e:5879 with SMTP id d75a77b69052e-444fe6e59eamr113046311cf.1.1719558499857; Fri, 28 Jun 2024 00:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558499; cv=none; d=google.com; s=arc-20160816; b=utT4Oi5nmDk9qMtkhmZPQ/N/C0hmAah3a4gaNzLPWq7XgyEISvUvenfhB7oBQrYuro VYa9hgzAmpeyJ5bx84DU9/QgZXcTOWk9KBeiYqKnO5Ypri3pUbVn1X3zydTMgxqgKZT+ QqYSV4TKi19EeYKyGgisZ9HOCNy1Hhhd83YIYtnLw8vaP/fCG/nBurgzBI8IaZ9ex7GL wL3Lll4yajSL1NyBmuifPeWZ9AI0L9WlpuTKnfpqQVfHweaT6VeQPTA9RUAHH5MLKqkq 33dNKeWzm3QQRcPYwRNQW6dvvuiLAdFEmg+pC9Iy9+aqrh/M5syla583pwOOf0DT4AJs lz4Q== 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:to:from :dkim-signature; bh=C+gseryQhO5/sKrfElbobPrg2sCJZha7vmxA4CmxEms=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=v9s5xzOjoYP359w0ApQwpOz8JNIiDkvMAZTvNw/JwMLHH2UTDCgIV/1joSTRzwUON0 IxN+ZLvoXzb8/LsB4P/DLqi8PYGUCEg8PuX3rGjp6TTwuy8VQEZ9w96VPqdPmCGCJidN HxqUFRLOrRdlRM6+ceFMW3tYFysIUS2JrB44KqpZnePhRsXOzsP6vLiibHt1oDTlTdMD JiKkT4vTelC7mo8WlXaumDF0pKrICFDlIRe7WTsA9B+8Fie4hqV1GoRHKwjuzCbIezMg 10SUnb6O/R+1SmBE81dCNWLniLGJ92h5Vlr4XbEUeJptUbzbz6qfU2aPtUYI8ezSUB64 AYSA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mprTAIf5; 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-446514e7701si12514641cf.772.2024.06.28.00.08.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:08:19 -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=mprTAIf5; 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 1sN5dA-0008Tq-BM; Fri, 28 Jun 2024 03:02:48 -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 1sN5d9-0008Th-MO for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:02:47 -0400 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5d6-0006eI-Ro for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:02:47 -0400 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2ec50d4e47bso2313581fa.2 for ; Fri, 28 Jun 2024 00:02:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558160; x=1720162960; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=C+gseryQhO5/sKrfElbobPrg2sCJZha7vmxA4CmxEms=; b=mprTAIf5AvZXiCUS4sCmLIp78IfjXn3/0OUo+Zq/CXgQVSTMF2Kez/CtkNojkdMyXi 3Ff8+XpPWif2Lh7w1ygJUXgkbXhWrUgB/4ibR5DYb1QTvk/qeqK3HIv/UT+fdvnLYRIA 56Vfw/7LHUJZ5FNT0ymxuL8gks9mfTH7bi+z2uCVcMpY4O7vjU5gXh2wrk8AT+qHJMPG LKu6Orf3wZpRHfpMUm+5jNl2Bxl2k/zbYfEnW47OAJ9QN+M7TSAPPJNB+aOqAt+GZOEI qcaq7uezGHHCxYh3Mz5HU6bR3fCnn0yOzXWTez5obvxpTGnGw9RCTvpwSsv2PT0K77Eq 71IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558160; x=1720162960; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C+gseryQhO5/sKrfElbobPrg2sCJZha7vmxA4CmxEms=; b=nKY8j0zyju65iHKrK1TBGXyrkKIhFHWFceL6cfOAdl/iH5f8V7xQGubyEct2p3ZEFJ Fct3EZlDRU+2Yguqxbn+loTQ5ls1x/O3GK3R0DH1iAZnEIMZEmMaB+JQiMXlA9UMzr3K 1OdId2b7W58BB2K4XCGiaGphhsgZovgT+jFbjgrR8tAgZgR/p+aFHO/xxNZ7cSsU8L25 urasZoR5V13cFAyyIQX1TfkuDNVABlQtaKUe3tieUxxUikgR+TWxeQsaMLCE+UM0tAA6 2Qi7Z458QIV3ctYqJgDzsPbgvMDuLc4cAEtVniSb7ygIzgb8vEU/YvA+gDrocYwXBy8K 8dDA== X-Gm-Message-State: AOJu0YzrA66anlXrW5XdLYRaVoKV5PZdA+tRS0OH8Zba+KliUW7Sxae6 FWtRg+S0Xs1b9T1WER52GnV58ZDf+ZlKRqFvj+ov3ES8V+wbpc5dOb7e5ncAY76FBftjLKOa+zB RyOQ= X-Received: by 2002:a2e:7c0a:0:b0:2ed:136b:755b with SMTP id 38308e7fff4ca-2ed136b79d4mr44953791fa.53.1719558160027; Fri, 28 Jun 2024 00:02:40 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0676a3sm21176865e9.28.2024.06.28.00.02.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:02:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 04/98] hw/sd/sdcard: Trace block offset in READ/WRITE data accesses Date: Fri, 28 Jun 2024 09:00:40 +0200 Message-ID: <20240628070216.92609-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=philmd@linaro.org; helo=mail-lj1-x22c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 Useful to detect out of bound accesses. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 4 ++-- hw/sd/trace-events | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bc87807793..090a6fdcdb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1917,7 +1917,7 @@ void sd_write_byte(SDState *sd, uint8_t value) trace_sdcard_write_data(sd_proto(sd)->name, sd->last_cmd_name, - sd->current_cmd, value); + sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ sd->data[sd->data_offset ++] = value; @@ -2073,7 +2073,7 @@ uint8_t sd_read_byte(SDState *sd) trace_sdcard_read_data(sd_proto(sd)->name, sd->last_cmd_name, - sd->current_cmd, io_len); + sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ ret = sd->data[sd->data_offset ++]; diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 724365efc3..0eee98a646 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -52,8 +52,8 @@ sdcard_lock(void) "" sdcard_unlock(void) "" sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" -sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint8_t value) "%s %20s/ CMD%02d value 0x%02x" -sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t length) "%s %20s/ CMD%02d len %" PRIu32 +sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d ofs %"PRIu32" value 0x%02x" +sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint32_t length) "%s %20s/ CMD%02d ofs %"PRIu32" len %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" # pxa2xx_mmci.c From patchwork Fri Jun 28 07:00:41 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: 808150 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp221627wrr; Fri, 28 Jun 2024 00:03:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVX7YvJ8FM9Q50h4EBTYIq36izBMu8wr/WB+le+uLAMfZkH9FtpEa52TXKSCmGibp+a+2mPwYsx53Bsqbsahx5c X-Google-Smtp-Source: AGHT+IEhH9pLl226dft8mAoNE49riNqSKKOqb7ykjfPcTkB7HuPSBVO0pxvBl2VLXlYjKSg3ufN0 X-Received: by 2002:a05:6214:acc:b0:6b4:fd24:95f9 with SMTP id 6a1803df08f44-6b5409e1427mr210323036d6.38.1719558230161; Fri, 28 Jun 2024 00:03:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558230; cv=none; d=google.com; s=arc-20160816; b=AthN3KF30Z3dlwsYxiXeqpL8uU+T6RimZns4VcxCG1rdYLOyYtsOutt0jEW0b3yaEk IR+MJ22nLuRoJOqHIzf+fxAYQGTPIs0z6OVugr94OwfwrxiCpOiJFFS65qW2sRGWvU1Q AbfHzBgw+Pr9XvtVggM2GoqFcT5cRaisn6dn5UuqS4cldziSMAIdmlsziBzdnnNyVlK8 egXIwnyLdbsO5bPPE3YsI8/94zCg4Q+N3TRwmf4mkgPi5VybuqgpU7oEBCMKpNjKNf/l iP2Z484CQSeOLV11gbEXzLzit/8iZuMK2GNhmW/ZYvjSaDOem/hQxiIza9pMNoJ7kS8D RFoA== 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:to:from :dkim-signature; bh=2IVH6b/MHuau58htKVq2uNBSYst/d06FDWZAuadlm1c=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=ZEcfb2XF9fkIsmKbvHnRx1cPp2j5/9AMPe1i89uuTHcVOBv6efJI/V4gfgqCH27/18 QYgrRNK0J+vSd1ApqgiHjVsuotfHwQRcy8J2GMKFrVhZtuI/F1qM4wE0MJS9J1cLvwDZ cQjQTZhqwMkGBpvcv8jtJkxRQurUdGp3K/KkfmU1UzXoAExBN6YtWslatwXhhfBeglHz EXDN0VcN2/LLw0wjgdQVo82wR7eab+3kkA6vmXt60WrigSwX/7j+GYcyUrImFwJwLFsP H0i8OfvG4oW2b1EtrbBSmYDc/iPXMEaULlFpTwnKEYACMuhWK9FPfptjmmoS1n8hcD88 Cu8w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b+4D0E8Y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e5aea9esi13741056d6.247.2024.06.28.00.03.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:03:50 -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=b+4D0E8Y; 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 1sN5dC-0008UM-4h; Fri, 28 Jun 2024 03:02:50 -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 1sN5dB-0008U6-D5 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:02:49 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5d9-0006eo-Mo for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:02:49 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2ebed33cb65so2526401fa.2 for ; Fri, 28 Jun 2024 00:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558165; x=1720162965; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=2IVH6b/MHuau58htKVq2uNBSYst/d06FDWZAuadlm1c=; b=b+4D0E8YsZ35s5XIjBX0Ux4GDovRa/u7ocdwfiyqTB2NHFf/XTvcDD3efN7ink9WAl 9hUxYzaHEZmQvUA+QAHVdJKBCBl8sCyqwr2NWucKV5IpBPsS+yoDRl+kXLl3Ul8o8fR/ GGOu3uqutFsSYoi/5CSEPzeIveaY0VWVpqmtvpDmb4HZEhiacJlfHV6WYIDvHu8InmnY nLSKPVlcniqV8VmTsgUnTEqphArEwIKNJv8Vzq4UTWEDAFHCWQHP+vNFGvXK2CaMHK/1 Cf6WYphGWKYtxnz90jdTAx86DgRq0ysuutpzqWNz1ThRonWOZbfCRX+2z/40TSHHNtgS f5gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558165; x=1720162965; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2IVH6b/MHuau58htKVq2uNBSYst/d06FDWZAuadlm1c=; b=q44iuEKf85uMG2EgNGjQMKHcC+uIbmwuRBMSaQeAKDmdx2SzhcbW1P1gDGb7aMwqXb 07+t4Q2bcwoBTbwrLWcoQp6lICikZW8BT3JwjP0Vh1mekJZfEbp897CA8THpDunXGog9 LREm+YE7oU8RFrLPEAxZDPq+sMoexBHv1ZYg7mfjCOGlneuD2k3GpIH+N8q+TjfTZuMY Z4bTjanCTPS5keNKhypFzZ4rJLeYB2XXD7bgx19Qu78Da0bPZwBBHNRpQ1wUdCx85CcT KNEBjCxCiggY4W/LcupOFQlzzw3YLUxL0CpjdIih4MHuliEdG5tKclCEFPlgFIcItxFX Jsig== X-Gm-Message-State: AOJu0YxftjVD3xOboxibFASAYIR1y9w8kqNh50N36Mm94AoSTX8UoWBW HbQOdVIrU1a/Puj6RCIPQmwwfxyta1VrYMxY4qu7FoOGXCitorxOvsLyUBVKbsCnFVJJCNrHoAO 1knQ= X-Received: by 2002:a2e:9e59:0:b0:2ec:5518:9550 with SMTP id 38308e7fff4ca-2ec5930fdbcmr113733731fa.10.1719558165435; Fri, 28 Jun 2024 00:02:45 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0642acsm21683805e9.25.2024.06.28.00.02.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:02:45 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 05/98] hw/sd/sdcard: Trace requested address computed by sd_req_get_address() Date: Fri, 28 Jun 2024 09:00:41 +0200 Message-ID: <20240628070216.92609-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=philmd@linaro.org; helo=mail-lj1-x22a.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Luc Michel Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 9 +++++++-- hw/sd/trace-events | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 090a6fdcdb..464576751a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -608,10 +608,15 @@ static void sd_response_r7_make(SDState *sd, uint8_t *response) static uint64_t sd_req_get_address(SDState *sd, SDRequest req) { + uint64_t addr; + if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { - return (uint64_t) req.arg << HWBLOCK_SHIFT; + addr = (uint64_t) req.arg << HWBLOCK_SHIFT; + } else { + addr = req.arg; } - return req.arg; + trace_sdcard_req_addr(req.arg, addr); + return addr; } static inline uint64_t sd_addr_to_wpnum(uint64_t addr) diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 0eee98a646..43eaeba149 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -50,6 +50,7 @@ sdcard_ejected(void) "" sdcard_erase(uint32_t first, uint32_t last) "addr first 0x%" PRIx32" last 0x%" PRIx32 sdcard_lock(void) "" sdcard_unlock(void) "" +sdcard_req_addr(uint32_t req_arg, uint64_t addr) "req 0x%" PRIx32 " addr 0x%" PRIx64 sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d ofs %"PRIu32" value 0x%02x" From patchwork Fri Jun 28 07:00:42 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: 808154 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp221903wrr; Fri, 28 Jun 2024 00:04:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXtndkeY5D4QBX2DKtohxW4aGkYZIGjBz/RGlEGuAXENTGkZ/u1CEEkA++fB7qCgSfQG10Bc3aBFdoeTGI2MRKl X-Google-Smtp-Source: AGHT+IEDZ+lb4eALrlvp49XU9u512/XITdAqV0LFs7/Ct/Tcd2iIiW6JFDyQjX1ETOFr30+mi4lI X-Received: by 2002:a9d:758d:0:b0:700:cada:9949 with SMTP id 46e09a7af769-700cada9c3emr12339414a34.5.1719558271604; Fri, 28 Jun 2024 00:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558271; cv=none; d=google.com; s=arc-20160816; b=rpNgiRpVnlmYrZ3Q+RRB1prZhdbC5V0wdOjFvWXRGFb44xomVphOTEJsnUNq7388Kz biO1rbPyM4EEpFB8xTxgiu8esOVzyJgpsQDFzKRh84mcBhMiRlkedEtWKgm4iyj6sZ7T 7oTEV255DkcxDVO5w3WhAkeBlApkyl2kJYffaaIiKvEHF71LMBAMHyHfDHZkS6YmpVh4 OZ96OpOA1z8pbbzRrdjE1eyjb07gZ7YYPbwcORiyUNvKW6KCq8ILTy29pOimKST3argj Ih3tcsAB5lV0E+4y6j4CGlLOlAtnAIc++ydjJfwltI4UZkWJWMKJ4vpPRSb5zs8mVmQb r8cg== 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:to:from :dkim-signature; bh=8X6AtOCpBUXAQ/1xHubY59Be7qdcbmyzPDPReyo42Nc=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=kQ5DF6bLXdX0dLsyGoZw3j02BqemM+V+vkonBvs1we4smidN35Iepz80TpwfpCFhsU +lgX0buvZE0bk2UVxBjOZ6ICMMA4JiU8/HJrrUcZZBbghWdU7bcWrnrAIfs1ngQL8TyT GZ4lc7TDSEcRWIIoXgVPP/y0sDk85Ik1KhAKKsdrMp2pPDrmRf62MqKPIZQFeOjMQuOI Yj23G1JEKT8ghQG9IxDK+dUWDvo9UiyYBmCy0LMg8mD4g378N3Gdv0ksdw3MblQDsh51 RypQeflmvH0GVpvPOrWJj/QKZ64/9DGmX40+pw5hapBxVfrShGxNn5/pQLjCeAIHG9P8 cE9A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jRs8BBga; 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-79d692f0671si129568685a.279.2024.06.28.00.04.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:04:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jRs8BBga; 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 1sN5dK-0008VH-Pj; Fri, 28 Jun 2024 03:02:58 -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 1sN5dI-0008Uo-7j for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:02:57 -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 1sN5dE-0006fh-HR for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:02:54 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42563a9fa58so2468575e9.0 for ; Fri, 28 Jun 2024 00:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558171; x=1720162971; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=8X6AtOCpBUXAQ/1xHubY59Be7qdcbmyzPDPReyo42Nc=; b=jRs8BBgaAomubPxiCGqFKrVaB0820B5fps78bESQRRqA4YqszkkcU8l6nBfYcZdX5L Yw3pmqSjJ4D9IrDk/gnyh4pKsaqCLcirHqgw6z9dIqY7SRtT8zsVayaYsALud6PcOlD/ nfL93ljqafB9SymBkdU0cmOCTqAY8qsCFKJh1N6bf0RRjabKUU7eSZI98naoyPBaDs4Y te9q0sSO3h0TyPJoxB1615sSFIQaHyzPczFFAm6EP2qztvg6wWORDXaF2AMrEdjJhsb9 QP1lkLUvGbiPF3aNZBabko3UcjBDA1/Ftnu1Ru9AJoU1lRxYGbUNmV2gLB85fBDAK5k4 56JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558171; x=1720162971; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8X6AtOCpBUXAQ/1xHubY59Be7qdcbmyzPDPReyo42Nc=; b=SXuLjaZq3UuJtipWmug10xftgwrTBMuQ4uJqrf9Zx1tyuQ65N/97jPoSJSXm37JUOI Yvoi2zBwhji7ZaLQSODIitjKww4DQulnvo+AwGxo44NC+e+OjGsW4N6pTXVZ9qVMe0Nf gUO0jPcZGIYrdebeYIS3H1EIn9jRUv4dZq8V/VTgNecWU9HQ1gQdx0F76QbX9Qc8qDy5 SM0XBEqrqQMIUsHDR5jbswTyWSBEgkS+emQl9cRoiKqtIsn+cXigE1EfjWJCcwGwAInb 4ciyA14vUh/C2CnVrP84H+dq599NSV+pFv7yU7q+eF0iBIKUMdK1lcvZ4SHZ7UJENFR4 ljsw== X-Gm-Message-State: AOJu0YyJ2gdoZ1Ty2KIiqR0JhKjipbJKDAk1FLhCXpDdVAkIwxLrb+MS whRHxjCblkmbqa95MXMygUYWmYiUQEye4U5P+QdpsU28L+w6I7sQjPTB9q6f2pYsFuUSUrNo4Lk Aci8= X-Received: by 2002:a05:600c:1c1e:b0:425:692d:c728 with SMTP id 5b1f17b1804b1-425692dd38dmr15098215e9.28.1719558170871; Fri, 28 Jun 2024 00:02:50 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256aed2263sm22708705e9.0.2024.06.28.00.02.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:02:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 06/98] hw/sd/sdcard: Do not store vendor data on block drive (CMD56) Date: Fri, 28 Jun 2024 09:00:42 +0200 Message-ID: <20240628070216.92609-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 "General command" (GEN_CMD, CMD56) is described as: GEN_CMD is the same as the single block read or write commands (CMD24 or CMD17). The difference is that [...] the data block is not a memory payload data but has a vendor specific format and meaning. Thus this block must not be stored overwriting data block on underlying storage drive. Keep it in a dedicated 'vendor_data[]' array. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- RFC: Is it safe to reuse VMSTATE_UNUSED_V() (which happens to be the same size)? Cc: Peter Xu Cc: Fabiano Rosas --- hw/sd/sd.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 464576751a..1f3eea6e84 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -142,6 +142,8 @@ struct SDState { uint64_t data_start; uint32_t data_offset; uint8_t data[512]; + uint8_t vendor_data[512]; + qemu_irq readonly_cb; qemu_irq inserted_cb; QEMUTimer *ocr_power_timer; @@ -656,6 +658,7 @@ static void sd_reset(DeviceState *dev) sd->wp_switch = sd->blk ? !blk_is_writable(sd->blk) : false; sd->wp_group_bits = sect; sd->wp_group_bmap = bitmap_new(sd->wp_group_bits); + memset(sd->vendor_data, 0xec, sizeof(sd->vendor_data)); memset(sd->function_group, 0, sizeof(sd->function_group)); sd->erase_start = INVALID_ADDRESS; sd->erase_end = INVALID_ADDRESS; @@ -771,7 +774,7 @@ static const VMStateDescription sd_vmstate = { VMSTATE_UINT64(data_start, SDState), VMSTATE_UINT32(data_offset, SDState), VMSTATE_UINT8_ARRAY(data, SDState, 512), - VMSTATE_UNUSED_V(1, 512), + VMSTATE_UINT8_ARRAY(vendor_data, SDState, 512), VMSTATE_BOOL(enable, SDState), VMSTATE_END_OF_LIST() }, @@ -2029,9 +2032,8 @@ void sd_write_byte(SDState *sd, uint8_t value) break; case 56: /* CMD56: GEN_CMD */ - sd->data[sd->data_offset ++] = value; - if (sd->data_offset >= sd->blk_len) { - APP_WRITE_BLOCK(sd->data_start, sd->data_offset); + sd->vendor_data[sd->data_offset ++] = value; + if (sd->data_offset >= sizeof(sd->vendor_data)) { sd->state = sd_transfer_state; } break; @@ -2165,12 +2167,11 @@ uint8_t sd_read_byte(SDState *sd) break; case 56: /* CMD56: GEN_CMD */ - if (sd->data_offset == 0) - APP_READ_BLOCK(sd->data_start, sd->blk_len); - ret = sd->data[sd->data_offset ++]; + ret = sd->vendor_data[sd->data_offset ++]; - if (sd->data_offset >= sd->blk_len) + if (sd->data_offset >= sizeof(sd->vendor_data)) { sd->state = sd_transfer_state; + } break; default: From patchwork Fri Jun 28 07:00:43 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: 808148 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp221473wrr; Fri, 28 Jun 2024 00:03:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX2oQotq/L/IuCXC2n+L9rSh2Y7y1+xZAJOsQqyecp7uSp2SRFicALQXT6bQEKUTlm/OfSBt3eVB2ClAFspUyNF X-Google-Smtp-Source: AGHT+IFTsCc8WUQeGk2HhM50i0gLinjaXuJB1mw3h93Sx2riGGpC4dMBjRzDvToxRII8ncCfHbQq X-Received: by 2002:a81:fe04:0:b0:64b:3246:cc24 with SMTP id 00721157ae682-64b3246db8amr3090627b3.29.1719558206431; Fri, 28 Jun 2024 00:03:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558206; cv=none; d=google.com; s=arc-20160816; b=xTwM8NSM0o0ZW6Y+yJ4JV/rOHErLwchlLA0fV8DKqky0GUfOdLqNnrymKhijMgP541 tV9c58tW5g4kS2e1uzJNt859BUQPD3drvI/QBE8nO8WfURaCGky2d7a+bwkKmxSQ7cz0 CkuNecsiWfG3Y612FOZgWK+0EikcdQO12Y69jHtlP+4o+UpVguzoEZO9xx7l/Af5VhwY tuuwnDIDux4vE59RZ+qYyPyB84Zn7IXIWk1vPvNn9thHW5N3xAiDwNws7bhaEPpCTW0V Vz885LfNwMD27gTjWgYZCF4uAyl56tlBYaY7zZBdqD78O2cJgnoSJDhoLQk5iR3Diz51 MUOw== 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:to:from :dkim-signature; bh=+otp2F30HYnVaW0wjGWSRpaE6+qcbVlZ832snl2PQg0=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=dW2Vwt3U9kHZpIPb29+Fup0pAloaMLTfqoNfA9AIMARl47o1nqspm4y9KKKUlY4Myb XpRSrsFinN1or1NpbToB6JKF3Ms4uUlYcV5sAal7sEUDPFfuamIgR25D3gkvTCBdqS3u CeHAatQTuV1v0NcKgPPFLxobiPvzzeAp9o0rcJGRhIfalhRNpVN9v571XjvfLTF+Gifo MPp+yGZiz3darm/g1zG0s0MGiirS9X6GU7BSF2Uhbl4avdB8MkebaPvajGLwkikUKDw7 z02HinA69zhsBcY3jw+RXG5ihn5oyz+sO1IPPkGSc5HPf0cPLiCjqsUHzUcjuTl5rjsQ Bhew==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wCkloADm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e5ae17esi13715266d6.270.2024.06.28.00.03.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:03:26 -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=wCkloADm; 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 1sN5dP-0008W4-Mj; Fri, 28 Jun 2024 03:03:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5dN-0008Va-6P for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:01 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5dK-0006gL-ND for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:00 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-366e70d0330so222888f8f.1 for ; Fri, 28 Jun 2024 00:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558176; x=1720162976; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+otp2F30HYnVaW0wjGWSRpaE6+qcbVlZ832snl2PQg0=; b=wCkloADm0pPloudzt7dnxonITj/Qg2stcHTytdguwXTnu9LMzcW9WGERZE4B0cdIm/ Ln12+/S5tZwINLDPri2awlQn5yb0stpZSZ4ZDq30x1dLGy7OPP7zsh3ar/gkc8rcmbL7 KQxReWQlanf6HNeE7ixlfL4fdHAGDIJfafUHkV+AwaFBaOMIxPuXB11zGq7upa2bDkyJ Z0PjZy4hVaRNqBk1HGbq2IpP02tkRnzsknU8opRHa2ZXAvECJaDZuOWD+N9tMUAB+lcg plu9sBJNqQ/zLXCrzQHmIsCnaURqU1AKlAcTv+CPZKAOpniJqGN19KgEk9QX8DhVWQpH tJJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558176; x=1720162976; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+otp2F30HYnVaW0wjGWSRpaE6+qcbVlZ832snl2PQg0=; b=j2sn1V4X2ogNPOlnpw8pfQFEHSxHnKfTZSJezFhyvKkkx14szO0eU3Qq/ZfuVkCtOw Vw+uvKnykKQl7vvLfY66WcgQNMb+EsaSuerlflNABCFRVHK/x3P7sUmyuVDsaeafVx76 VIg7LLsfVH35q2ZCzlP20YF/GUk4vUDGd7t1BynB6qXbLTmwnGVycDFZlQkfJ/ccBK8V juvJs4HSrFiV1RkzHkDtDH/bjQUPudPCo1UV6aKZXKXf4yUrs9R1HgSMM/URt7u9AAcx f/6kROmFceUBY18eYD2Zb/M1lLPU0k5iAVSHq0yU5+PK0LLA8SoKWdnwSoHEgQU3DYP1 3Tng== X-Gm-Message-State: AOJu0YynXzqHzM/4C2RNPpbo7c59MDfiJzZfjkeLfKceX6R1NcHRNm5t H4Rl7mxxGK1Mb1sezr5XEBWL95GSzvhrx/nCNXKPDj7TZkhKVPD2JRHYLWiLvBvhYTOwVBdTFgR OsQU= X-Received: by 2002:a5d:6dd0:0:b0:367:43af:5b8c with SMTP id ffacd0b85a97d-36743af5d8fmr2506909f8f.53.1719558176379; Fri, 28 Jun 2024 00:02:56 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb973sm1317253f8f.67.2024.06.28.00.02.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:02:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 07/98] hw/sd/sdcard: Send WRITE_PROT bits MSB first (CMD30) Date: Fri, 28 Jun 2024 09:00:43 +0200 Message-ID: <20240628070216.92609-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Per sections 3.6.1 (SD Bus Protocol) and 7.3.2 (Responses): In the CMD line the Most Significant Bit is transmitted first. Use the stl_be_p() helper to store the value in big-endian. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Peter Maydell --- RFC because I'm surprised this has been unnoticed for 17 years (commit a1bb27b1e9 "initial SD card emulation", April 2007). Cc: Peter Maydell --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1f3eea6e84..4e09640852 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1507,7 +1507,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } sd->state = sd_sendingdata_state; - *(uint32_t *) sd->data = sd_wpbits(sd, req.arg); + stl_be_p(sd->data, sd_wpbits(sd, req.arg)); sd->data_start = addr; sd->data_offset = 0; return sd_r1; From patchwork Fri Jun 28 07:00:44 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: 808158 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222346wrr; Fri, 28 Jun 2024 00:05:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWA0fEqQBcM0TyYrW9KQaYNavTrkVkm0xrtep64UIK+tAx+khVpJzNmpZx8OkcJY+fjgj2y/8hPd6tvzSKh4IqW X-Google-Smtp-Source: AGHT+IE3Lnfk2NuJghLVpEH6tC6qHezK+V+OkoVRvh2qHZFCg9Hh+y2tG6QFuteD4w+e7J08KbER X-Received: by 2002:a05:6122:4f97:b0:4ef:58d4:7106 with SMTP id 71dfb90a1353d-4ef6635fea5mr16000871e0c.5.1719558345366; Fri, 28 Jun 2024 00:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558345; cv=none; d=google.com; s=arc-20160816; b=l9P3UvDRZ/TnwzSvKgWmD+lF/xa2WDrz/iJWaYzcjzcycxhVdKGk7dC20LFwIHJlUE 2ZNzdYbnIZjQeUjgWkwTddyr2Gy8wKD1WtltMFssH8RVkcOAcjklFRMCbNT3ONrnreXM SU01vbTp2MJQrjFykE7l1MIkOpY3SFAL3f85VH2k7qRGXmB3R5wro5upureKhFFGb+IY x+edbknBR40YyJizl7DUkVxMb5Hwp3g29QyxIBcD5Xt/qlcMO3U/agqq/FySlu+8IEz2 +fDbDvwf1xobgkID8U4/3vOh2e8cdeW+MtlvgITAGe+Q8OW1CAY39QOIORPxx3kGhUnH MM1g== 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:to:from :dkim-signature; bh=vUpbb+xwTJn80OMiSW9qrPEenBatfvxaYEHBd94Y0+o=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=s73BMM4LOThM+RlSxw7oZrqMmGxGZwVMnk3u2uf8439fGh+6IA36Y1UivyidzZxOh5 vWSt42tGqS8F7RIwG8b0z1xgH19VlULcrYPH+J+W3YAtIFYa2QkC+3BZxNzmL2dfWcaG VssflHFiRMRxrzpCv1p9nlQZnTQKlwiDjv/ouFdtDjrERQtCbkjo0uNvAjvTQsz89P2u oHckliBF3T/BHf6Xy6qMx4n7kQ4Z+YyGS7tDpmLlDTtkLJIk0LVwcwBbMaQKP//BbC11 h9HJHNwcB4CE81sumfrkvLGM9hz/WvBz0RUDOnDW/2kvNUhKO4/bVAiu36AM5Gn2IL6p 8Qqw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lQZsuHz4; 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-79d6934efcbsi116274285a.785.2024.06.28.00.05.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:05:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lQZsuHz4; 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 1sN5dU-000052-0l; Fri, 28 Jun 2024 03:03: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 1sN5dR-0008WO-NT for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:05 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5dP-0006h3-Ny for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:05 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-36532d177a0so184140f8f.2 for ; Fri, 28 Jun 2024 00:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558181; x=1720162981; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vUpbb+xwTJn80OMiSW9qrPEenBatfvxaYEHBd94Y0+o=; b=lQZsuHz4Ro9YM7u+zMnaNtkwXOvAY2d66NHxev0OUD2ZXsjNiYXcjg5C2Xm48611NG GEQUO6DubIXqlY8cDrpyoxEAJXL6uS3A1ilG9g/YdpfEi8uz+7hHD7SUeaTlJEyzBEGR 9h2dDsDdbgISA0r2/aHVGM/CAV6mNwr64S203e0DgC6ZrROSnIY9g6eqzVGdbiJVvfAe ZDkJJ+dD4teM12O4IUwBKmyB2Z+4f6YP+NZfWMYbTTFCMp54DNx7j4qUsuvK38y8f6h4 iIMTBv14Nxh+zStEaN+gutP2Y0knQFK4+qQ0mg8Kw28qKdwbbGstZSwT+X/A5usKI/rP yaJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558181; x=1720162981; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vUpbb+xwTJn80OMiSW9qrPEenBatfvxaYEHBd94Y0+o=; b=A16cFvp439sVNSf+c61Wx22Tsw6PEOJKYbTM8RdWkBMqOJS2hd22EardEcDCLLR2mF ZTKMzj5bLzxlH5Koqoo+OYr/s89BbXPfk467P6a40q8iqPA4Ea2Na2OwBgu2Hu26T41N O1TXEkvvBgfv5u6g++LDT6ZQb5vJaT/tysAIoGmOGajC7qU92hug+c5t9K3XGnA+TJdY QxzzBBrEyzjvQFXuO5VKL8mqqvtfK23gYDZRlwEe3RjeNRsiRxE7IgnHQIt1G89o3T3e zm50DMfQUtp6jrMnNWRYEWsimnjQVkmBDCL4tfe1/nlFtRjCVbxIlCzRKXh46cwBbLkJ PHZQ== X-Gm-Message-State: AOJu0YwBbMY1olkdmfrIjL5cHsGTT5gZAZHNfwwdGIc9jCRu7mWlWt0W oLlHR6QmZSOT36UGrZZcyw1gpIzmJ4kA4Z8BOnw/J540CljP4GIx6zr5g/o8Tj+k1/mo0L0Xuw0 Wx6c= X-Received: by 2002:a5d:598a:0:b0:366:eeea:c4d1 with SMTP id ffacd0b85a97d-366eeeb3980mr12256450f8f.35.1719558181679; Fri, 28 Jun 2024 00:03:01 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10307bsm1312973f8f.94.2024.06.28.00.03.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:03:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 08/98] hw/sd/sdcard: Send NUM_WR_BLOCKS bits MSB first (ACMD22) Date: Fri, 28 Jun 2024 09:00:44 +0200 Message-ID: <20240628070216.92609-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.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 Per sections 3.6.1 (SD Bus Protocol), 4.3.4 "Data Write" and 7.3.2 (Responses): In the CMD line the Most Significant Bit is transmitted first. Use the stl_be_p() helper to store the value in big-endian. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Peter Maydell --- RFC because I'm surprised this has been unnoticed for 17 years (commit a1bb27b1e9 "initial SD card emulation", April 2007). Cc: Peter Maydell --- hw/sd/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4e09640852..1f37d9c93a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1668,8 +1668,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd, case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ switch (sd->state) { case sd_transfer_state: - *(uint32_t *) sd->data = sd->blk_written; - + stl_be_p(sd->data, sd->blk_written); sd->state = sd_sendingdata_state; sd->data_start = 0; sd->data_offset = 0; From patchwork Fri Jun 28 07:00:45 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: 808153 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp221904wrr; Fri, 28 Jun 2024 00:04:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXCk7lHeg6FFgZk/2Auhh2uztIb5WY8DDHVpctK2/PX2cE8RT7Eu+15v41Iw7pK8WHfZbvbPNnzIKvJg7rRuTFi X-Google-Smtp-Source: AGHT+IFn7USx6J9+jGQdLFW9vvyAziijIC7qOeaN0UyYNKfckcVr8w81aiTXn80LiS7wS0YxC5TZ X-Received: by 2002:a05:620a:24cf:b0:795:5896:f842 with SMTP id af79cd13be357-79be701d03cmr1720536485a.76.1719558271633; Fri, 28 Jun 2024 00:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558271; cv=none; d=google.com; s=arc-20160816; b=mhHILSK6jOY/1+53qZIUsbltJJBHLws0KKqwmOCBhy20ViWRJH/GXDI3dk1vJyF/5A 0bCKE1uv2j6IwrAYZRqDJj+FWAGeplYkSoeWqomUlFaHJSrzJeLjDFK5cKtZ2Z49DSaP 4v07sFUQJ3FdZkIuaXvV8CRLZyMEEJacO4gYYRHLIpN+RGXOAnROw32Ix9xbEo5yJf31 agxUgi4QqUbPRKNGQBB/tVwpJSXToWZWzoCTpoWmgEKXf0QQfNycK9YC61v78n3fM480 9yC9AxjfkOPq1Cmf1ZchBrIW0ZWpKBF5as1KWuzzoVKdefp6hMl/iJUoMN+JE2umT1f3 Vmog== 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:to:from :dkim-signature; bh=yFkcsEXV8tTNgx1V48/Rdkr/iwnE0vz/gcdrAU/mSc4=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=mVebdXnAgGq1ou09eJ3y+V9mESkPBkzmgjF3hK+ixiKQxBZPPRpLxzoUMzWvSzb2So PRMlaXRKOWVsYoRryStSl4ic8eQJZzJT73bf0ss75qQ1ROLGH7h+37H4gGNSpUFAm87h UHW8G0yE1ei2xRLeBJbuwa5zL31Oh37kXnp/eG8HdeDF65lhazhgnzLmZZAPsSpeRMz+ i197URdkcxKh9nRWGIo7OVoGqptA/1BXyeVx28T505h8+zH28deGYVBqvy54Es85Mmez Gd0j+m+O9BZ52tuBWgaH2A/s05BPrKYEENVLCsHnPBUYGF3iSkg7ZdDu+lDwBFprZmW8 cGsg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xhlO9C06; 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-79d693397bbsi130485785a.584.2024.06.28.00.04.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:04:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xhlO9C06; 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 1sN5dj-0000L4-SJ; Fri, 28 Jun 2024 03:03: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 1sN5dZ-0000G9-IG for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:15 -0400 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5dV-0006hK-AK for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:11 -0400 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2ec4eefbaf1so2272381fa.1 for ; Fri, 28 Jun 2024 00:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558187; x=1720162987; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=yFkcsEXV8tTNgx1V48/Rdkr/iwnE0vz/gcdrAU/mSc4=; b=xhlO9C06MKTW9dRT4RdhV0lzKi0PIF/EsR9aKVt1zCtS5isFp8wZ7l50SwAlZhGG3E WMnnKvPRtkJ+JYL8mQ2H84e5lCLTxKIHPP+90m7C/TT+lxcZjsm63MXy0f+hf4PjVMZo UTxmAcPYlTTDmxIhAiUTK9cbi2xvCAXMf66wkh1uEK1T7ZkxRirCt++38FHcOlipbQw2 OzpkMqqGnq4prCLM4dybWy/CufuEdyuBBjIczIychabw3alI6Fqq6lgPnAVONPTdGMJj SnhfNi7D4ZNERrjXqvEsrQgq3fJQnZf6Qel3P18a1Vcf9Uk/paoA/ls0T9Jd0ji/nHAh 1RpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558187; x=1720162987; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yFkcsEXV8tTNgx1V48/Rdkr/iwnE0vz/gcdrAU/mSc4=; b=jwKJM+hFpQ9/egA6+9e/QP/fmkRNk0L9pt6jU5vTmti2o0nq/N5TqHRZR5raYCRO9N 6iX6X7d2c7rzb3L7pNvnm0yg6rBZSS6RBlSDUuAQw9dUt4IwnupwkxiLObv3XAl5AfZc zfKowlut3ZAk1Y9VX0sYQ8RdnIHrYrNV16Wdw1NuxQbE2D9zVv89oEXTXTvBlGGm0gJn l2uKIdWnGvNh+Hx1L5u54kI1YdDAHFTP+ozyXcsR5aBYo8s4FhXu8hxwMAD5FiIAQKvr RQWZ3xaMJU5ZqfCAf3FLS90RD2OuUkhvIxkMXTEKuP9GU/9Mz/2XAuojdV9ki99hekMV Ix2w== X-Gm-Message-State: AOJu0YxYUf0C/dxEo+8aHNWOsLWaJ6fz/aPv8xfxIFlFRse8gcv2P2ju pwWh+nl7U4NP8fYrYEOOicACOBuK+YVfA3p+o39jlec1B296yL+PyEK9pIVfGziBlBehJT2/q3n LZrI= X-Received: by 2002:a05:651c:220e:b0:2ec:5e2e:39a8 with SMTP id 38308e7fff4ca-2ec5e2e3aaamr112507221fa.3.1719558186886; Fri, 28 Jun 2024 00:03:06 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256d664052sm10481355e9.27.2024.06.28.00.03.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:03:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 09/98] hw/sd/sdcard: Use READY_FOR_DATA definition instead of magic value Date: Fri, 28 Jun 2024 09:00:45 +0200 Message-ID: <20240628070216.92609-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=philmd@linaro.org; helo=mail-lj1-x232.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 Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1f37d9c93a..135b7d2e23 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -561,7 +561,7 @@ FIELD(CSR, OUT_OF_RANGE, 31, 1) static void sd_set_cardstatus(SDState *sd) { - sd->card_status = 0x00000100; + sd->card_status = READY_FOR_DATA; } static void sd_set_sdstatus(SDState *sd) From patchwork Fri Jun 28 07:00:46 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: 808152 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp221848wrr; Fri, 28 Jun 2024 00:04:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVdukRM+tzaCS6CuE4aYbBJnlEqOEvvooRprjGRXhjAFlq8/ajK4ilvFl8CuMQx4R05+SeqRwotWQsSbL7R1bAe X-Google-Smtp-Source: AGHT+IG+zE9U83Rmxf9eUhyb6E0Jx2zOACK0+f0yHKCdN/tbYKWQlwDmUC2mu3PoSFiKB8AG/8Ns X-Received: by 2002:a05:620a:4554:b0:79d:7246:ea63 with SMTP id af79cd13be357-79d7246edd0mr1493185a.49.1719558263784; Fri, 28 Jun 2024 00:04:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558263; cv=none; d=google.com; s=arc-20160816; b=WCtzOR50FnEAkdaBDJMVqjVQhJPBsPTqES8DXPVSQMwYVfcrcLswaUgFLNKZiNc6TS v8a74lKgLV4NNFjYaYpBGiRxE6CCTyTnzzRwc3267oJVW75dOJlq4WUMhPyczFUNkVZq Yksol/fqjEZ2BzAQecX3VrYXvYezY7fTPy2UQ7RzjHEEZDs4oPz9ghFm8HyxxVuPXKou I3T+Z/XvfZzEGKyFq8R9M8FJlUwprW4YAgXZIr1evuDAsUsmpQ8neMSSRGMpxhmfwA84 stNBVxH1JBfWQZ2VgcRhR37QVaIH/cc57R3YaY2LqsQNPRlsSXs5gvRJK/1UBAiA5E/F YWsg== 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:to:from :dkim-signature; bh=JpVotoHspFlZ3BpKrTY/FaOKVvxynyJagKJZJS+6h3k=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=rv93GO2i1AoAYbDyXoVZ5ZNaujRb9Qjj8L79MySpVIxpn60AK/Sgl1tMCW9UY1EisQ QTdgx9jm5t2fhIMwiwaDrxkSORaOxjYMhCuiXEJ4CSUElgJYdfka/aMGXtaYLxgq0Vc+ bYhFgoFrW5G2s5c10lFkMR/SUjuLxOg7IZNT1X5h7VH91/92A+qDuZ2AL7GchENnSWB7 VCzFgIWwVg4U7ad7gp+Oc/+vpj3jj8BCLyHyXn38fny83+rIvexuKbKo+Q7XAvVGNP9K ilzMX1UKTYsuemsbYg4kCwiHqlLD9iVkCUnR7rQ6Ajgq5b1qn8tnGzJlZcoB+7g1+LsM zLRA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dbO0HjE7; 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-446514875dbsi13329261cf.243.2024.06.28.00.04.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:04:23 -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=dbO0HjE7; 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 1sN5dm-0000Lc-Jb; Fri, 28 Jun 2024 03:03: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 1sN5dd-0000Hf-Aa for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:18 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5da-0006ik-Eu for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:16 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2eaea28868dso3184441fa.3 for ; Fri, 28 Jun 2024 00:03:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558192; x=1720162992; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=JpVotoHspFlZ3BpKrTY/FaOKVvxynyJagKJZJS+6h3k=; b=dbO0HjE7Lo7Xo1HZggB4F7WgZIaNFTWwD/bPtr+sK+PD6MNwMGeQYsnCUXR0vBzgLm qImMVpyGIPJlz32DblgajCObsSxg1utkrGPyV/eQPIUuj/Vn44yhQMZSk0ID9+DBDkdm 8pIK/Z5JtzE8F5+W2OQmZB2HI1uiDlu3/QW0cF5yDyd20ZAkqcB2IWohuopwUUlbe90Q d6gpSHa0JkeF915lNzVTUM598LZwtE0ehmLi8z6z0WhDNB5BlzPIIvrB8HbQKXdXUzrV 0LxATLCxSXHS/QYw2Pt6apXfDwZGUOwG+4V5XiQr49APUrgUL+jKDGAyvMk3j0tsFYCP q8NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558192; x=1720162992; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JpVotoHspFlZ3BpKrTY/FaOKVvxynyJagKJZJS+6h3k=; b=QNRWi6TX+gz4i1s65seKg449iCUKiN3E/s2CcwUN0Yf3OUYnWOMf/IYskLHXvGyqTq utmmOHq6j4dODKqrogM0824GRzH2pWu6dAWAarGWz+5KrkxrPBb0uyMiQmoH9A7wyvur 5rLDIO54+E25TZGRuMx2SY9TFFA1RySuLDgELmMyr70iptkB8tiBBuhUIykJDOWEEcnJ jzmPzCgeSL4f+4sj6m1dEveiQZoSE64KJAumyDpRbCk767kyqBjkPI080OEpCgkEAkvU NQvJC9R0UnZIjtWalFX34EVl/kJ1lgQxFCSbP9Taowoa+OCATCu9a4OLVI39OE2gQWvP bJUg== X-Gm-Message-State: AOJu0YzRfwlDXd/nUno4Y8ecsyOUBP+cKyYO1OUfjdIjVqGJFGI1gIUH v05INdeL8vOSp4+PdI3zECqvzA1Qcu4taMYW0/Cvgna0SG/4RIGNV26C5VxW6cWevoGjbMJOlW8 4Sq0= X-Received: by 2002:a2e:8746:0:b0:2ec:5685:f061 with SMTP id 38308e7fff4ca-2ec5b2d6313mr123829411fa.21.1719558192057; Fri, 28 Jun 2024 00:03:12 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c19eesm21186555e9.45.2024.06.28.00.03.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:03:11 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 10/98] hw/sd/sdcard: Assign SDCardStates enum values Date: Fri, 28 Jun 2024 09:00:46 +0200 Message-ID: <20240628070216.92609-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=philmd@linaro.org; helo=mail-lj1-x22e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 SDCardStates enum values are specified, so assign them correspondingly. It will be useful later when we add states from later specs, which might not be continuous. See CURRENT_STATE bits in section 4.10.1 "Card Status". Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 135b7d2e23..fbdfafa3a6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -75,16 +75,16 @@ enum SDCardModes { }; enum SDCardStates { - sd_inactive_state = -1, - sd_idle_state = 0, - sd_ready_state, - sd_identification_state, - sd_standby_state, - sd_transfer_state, - sd_sendingdata_state, - sd_receivingdata_state, - sd_programming_state, - sd_disconnect_state, + sd_inactive_state = -1, + sd_idle_state = 0, + sd_ready_state = 1, + sd_identification_state = 2, + sd_standby_state = 3, + sd_transfer_state = 4, + sd_sendingdata_state = 5, + sd_receivingdata_state = 6, + sd_programming_state = 7, + sd_disconnect_state = 8, }; typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); From patchwork Fri Jun 28 07:00:47 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: 808169 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222901wrr; Fri, 28 Jun 2024 00:07:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVD3JtV4D5LNjkDD4bWLS3YjKLZim9/qnX/ZjUQhT3XWFdfkZXtKmuT3Orf/bbBApq6CTahw9dhKSqYRxWvM/QT X-Google-Smtp-Source: AGHT+IFu3Fvr3aD7Ny8y1YlOPMr4coW59Jnq+fn98R1YoUg9f9L8V6O3vjkqohV9JW3QpE3uRFBj X-Received: by 2002:a05:620a:430d:b0:798:1dd6:b6f6 with SMTP id af79cd13be357-79be7047736mr1392040485a.76.1719558443951; Fri, 28 Jun 2024 00:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558443; cv=none; d=google.com; s=arc-20160816; b=t8tbGsg4/qb9DJqoJmC/Q3VB8q02iMN/u1AJh2/HAgscmxMPTK9SHSW9fXYt8B5Bu/ CWZDFRgjcwV5YlDKmaF1DeC3COmYEgBjfWAa2iBoT/R+cM6Gjy5ixHBKovvwSZRVQqxF 4a8soq0hn8kRkmb6V6H6YEyiObnGqkEh1LpuCS9pMBqf/RatMqg+iovCZO4WzYIO/6pr 8MopceJhnMJMrQTX11/KWA1u31QdR8qYdbKHoIB6h4tu6ymp0bg6Aat8sU2LjyxoQPLX TYiIl4h1KGY6cScD2LIl+VhhA5zW0YsTJ3x1J/He7Yw8/Qgyj0JxAu3oWW1TAh3T+bx8 g98w== 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:to:from :dkim-signature; bh=wrQTXcopwoxdy2+QKjolzASBZvpHRSjsIoJ+STiyvF8=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=AV6pE1mw8fXxtsSuLDhEjOYhHfUFP/pyIK6Q+FSQzqBS9vyS+eFvsq00jBbldhwr4A fegsees3AyPXtSHIRkK+mlJkbFFGVwiR0VJCiYdyfXV3iNA/P3qvxVpzU6ednPk/dGNW jYmAsSAfG9eGvJ41QN/7+1kFEmzH1QZy2DDMxZTsL7wfB1/VlqrGBCyPB3yjSzb759Se NOcK3dbNnr6REuFc7YD0lgY5Mf/BfMqeeIWSZNeCJYQd1OXZMEhwb3phYdnfVmIx/8VB ruWA/EaXGLRebDyCygwSk3OU6nvr89yrBQDTu1EdsalsN/dsiSKurSC3QT6G/F1LBHHV IIsg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LoB9XCW+; 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-79d69262d1asi131101085a.5.2024.06.28.00.07.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:07:23 -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=LoB9XCW+; 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 1sN5e6-0000qP-Vh; Fri, 28 Jun 2024 03:03:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5dj-0000Ld-CE for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:23 -0400 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5df-0006jG-Vj for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:22 -0400 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2ec50a5e230so2316481fa.0 for ; Fri, 28 Jun 2024 00:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558197; x=1720162997; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wrQTXcopwoxdy2+QKjolzASBZvpHRSjsIoJ+STiyvF8=; b=LoB9XCW+JhMGw7rC3LBCM7D8Csjqx7yuWLihE/466MM6cpUtt+a4SfezSMy8SreN5v iVsuEDZ+Cv3yWgEoW9fltFB4OxqIJsfZCS7TSNKV0TvIDSWo4/47c0B7WJkIx+KAfyvh w2hstY35HD0AMXvw3yslJpnGL72UAOU7F6a/yiHBBzf4bD8CKeum+qWKvfB3DxwD3azN VUSDUbte7YqlqZ8bWbLPO5utx5EAYooDhRNrNL3j8gDAmjPXfpRVlaEyYTTDA+HwyrYT v9rXFVsuJeIyBDZn+vm2iR/ZYSX8hvWqni1jqTH9SA1r+ShOJjALbnWzPPRpKuWVl74e jGwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558197; x=1720162997; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wrQTXcopwoxdy2+QKjolzASBZvpHRSjsIoJ+STiyvF8=; b=EEAsUj87pV/ADNHTA1eu/oxQNJrhmmJa8AxGinjmkiiq1K8z0wSf7JBFuXIh4gmPTE cHZQhisXutSS9bEmAzX3l1DlCC49nwBYPoiuJUzsKIPDwmgEkuhwNfD+o6+LDQX9q0VG kv7kMZdyL3C2xVy4eC1oSf20AjOdoUKfzMhU56kjxqSk32DuIiNnkaoU1zSuNggn0K1W GHNXlXsAOnQ1VY9NczIRmYQKg9pgoSFERaprQWoetwgrPqXVLz09Pk4Cr/ubVgo/kRKr xzmX6TrEdpKC+cdMswUn0tb0B4uYceJ3EQefHVwGXxOD0kTK+/TmmOyn9S3VPjmqukFT nfLQ== X-Gm-Message-State: AOJu0YyE6nNYjY5hkTm6ygNOeechf2Q3Aokq0AvUzp+dRfhPMVGkJpUZ oXx8KdCzC33caT3dwPAzOUSFxqqmfNCAI7cNmdUuDDBP0p+0YfcaVknBOsBmhg6I0SBTUkgBODx bhS8= X-Received: by 2002:a2e:8242:0:b0:2ec:50ed:b59f with SMTP id 38308e7fff4ca-2ec5b2dd950mr90208531fa.34.1719558197248; Fri, 28 Jun 2024 00:03:17 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c0fb3sm21184995e9.40.2024.06.28.00.03.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:03:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 11/98] hw/sd/sdcard: Simplify sd_inactive_state handling Date: Fri, 28 Jun 2024 09:00:47 +0200 Message-ID: <20240628070216.92609-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=philmd@linaro.org; helo=mail-lj1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Card entering sd_inactive_state powers off, and won't respond anymore. Handle that once when entering sd_do_command(). Remove condition always true in sd_cmd_GO_IDLE_STATE(). Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index fbdfafa3a6..7533a78cf6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1081,10 +1081,8 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) /* CMD0 */ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) { - if (sd->state != sd_inactive_state) { - sd->state = sd_idle_state; - sd_reset(DEVICE(sd)); - } + sd->state = sd_idle_state; + sd_reset(DEVICE(sd)); return sd_is_spi(sd) ? sd_r1 : sd_r0; } @@ -1579,7 +1577,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (sd->state) { case sd_ready_state: case sd_identification_state: - case sd_inactive_state: return sd_illegal; case sd_idle_state: if (rca) { @@ -1800,6 +1797,11 @@ int sd_do_command(SDState *sd, SDRequest *req, return 0; } + if (sd->state == sd_inactive_state) { + rtype = sd_illegal; + goto send_response; + } + if (sd_req_crc_validate(req)) { sd->card_status |= COM_CRC_ERROR; rtype = sd_illegal; From patchwork Fri Jun 28 07:00:48 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: 808151 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp221647wrr; Fri, 28 Jun 2024 00:03:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW4pA/X+0X3A/rIoLuGwMhG63KUi092foAiclLAzffy3v9K8AfP0YGQz+RsYKfJf8/zY2EQQx2J2kfAYjfSxKF3 X-Google-Smtp-Source: AGHT+IE3sOvx99o/pa3X9HrokhKonRP60CavlPnECGeKpo1Gza38Puhzs4US7BS1N26j5RKGrrse X-Received: by 2002:a81:fe0a:0:b0:64a:3d7c:2782 with SMTP id 00721157ae682-64a3d7c27bdmr27807097b3.41.1719558233852; Fri, 28 Jun 2024 00:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558233; cv=none; d=google.com; s=arc-20160816; b=OVHjebHEJi/a7kMt/9rqurxn+4v1hTB+KVL5TkPtQ83XlmZCl7/zgptnPwV+8HdhRh mXBFkbuvtlF6ShDXvDJPbG8rrnPfmxLsjnltvMI/gkbrvUVjjRN0NDGGyLGR8TCf0dxB 2g8XBm3n/LNXndmMSQ0BUaagn4m3HnS2+FECpLFwNVnuXQUFH/ipbxkgnRrm0by+Ad1h yVKcriOv7EtmcYLQV46ZfHMlMO3jVHvu3RWuZXXTkd3K6d3nb/wqQghfQd+MMrLXAb2w zZOgDGApbLHOFxY87Yni2fQgsjUa1zzR6mBLbf5Y1/3KUXRCVViLz9xDryOJqDaVOHQC ChFA== 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:to:from :dkim-signature; bh=hpSfmrc8id/iTbpDVauIfBux1xBlvB+2LTLQjc6fyJc=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=bOW7aIpIlsGwrtj+3/TVhdJgQ9d/4mgyfkFnBi0tB3+rapOduwqK2TALbfH8Xr05fZ lT+zkaXyIg48xPHHoCirDsi5rybBt71gJtqw7/EQlLFnWu/z2ZA61rO8TYG6TBsQ17wB inDOU+4mZoZjVRQj8IniR3RLF0Nz6Ah9rDASaiSATY9U6gX3DF1r5T1kDiWBRte3w9qW rZ4TJX2UHUworni/ZYkU6cUJ2jX1us7CWXgX9H/V4hzvrPrI9eEHtUQtEXjk2IvKFz/v mnHBwK9OUjLU9HVD31FhzAI7MJDtYIAxXgupk10aG0azPtHc7MXojRO01A/NYRzuE1gk qBFg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=umBIWf2q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e36bb97si14095086d6.135.2024.06.28.00.03.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:03:53 -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=umBIWf2q; 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 1sN5dz-0000cp-G0; Fri, 28 Jun 2024 03:03:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5do-0000WZ-Bc for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:28 -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 1sN5dk-0006jj-95 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:28 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4256aee6d4fso2160365e9.3 for ; Fri, 28 Jun 2024 00:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558202; x=1720163002; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=hpSfmrc8id/iTbpDVauIfBux1xBlvB+2LTLQjc6fyJc=; b=umBIWf2q3tgEATs1LnzunEnL0/wpkT8aeFxGBI5LEMthZG7qHnmjIBNYraGlqQRVg4 dCGESMzQfw36wQT7ktIbEfiiOoRzcPob2NkUHRXWKTmhcgVMl3Cx577n5Ae0CBMmGDum e6wmI2qckNFTsiZFiVtI1gvHFI9ik33e9moXouYZJ9vIxRp/qOcAJ+LjpnCsqfJlQ55o pVha9VAt/Nm5fpMGOpVO2HOaFAYKQWRn1hnEhtjQT7/v2ywOu1qonM1bIhhQle4bEWyD vBlseFjt95efKdBPjQbehfK7knYN6j2+Go0E+KoL77NwB7TdQdhSaKoSszinl6Y0vyZQ 3SQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558202; x=1720163002; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hpSfmrc8id/iTbpDVauIfBux1xBlvB+2LTLQjc6fyJc=; b=OnN0akbeJXiUemdG/8vFggUM11tVGYbqhucgQuHwFb4SRb1l8BmONra/fyHUhnPkJy 0phLO6erA/neNVCkw8eUsSHl7GzmYeWGvkwsguTrLHD58VvnmxZRt2gKP4zJWUrax9oN WBMEbmUu3E58fQOJX0M0CVqKcIIn7KX4ilYflIG0rNhpnJjzPemLNp0EkemIPbKjQmRE guPubyqDldL9XUKsIgnOVXnybGyUTcW3TDn7+YQJmU9IZc19uqQBHuT3ipAhExWB5AYS Kf9ddvZPq4wwWzNZ46UP1db6Mm9qZFZ1lfHJTRx+2QFp931+z2hvOLPCwnoD3/FulZAR ztzA== X-Gm-Message-State: AOJu0Yw9uzddKwre3C2emGESSNxy0PP773EwkvKG6EX+VXYuGyz6AVI0 +85w88YWaxmlEYmapz4LJocpw5w6s34VuBJUKJvyAVlr00+bG8fM5jxHR1+WwmlIrbjBRYdcRBr X3rA= X-Received: by 2002:a05:600c:5816:b0:41a:c86e:a4db with SMTP id 5b1f17b1804b1-4248cc2b729mr98474885e9.9.1719558202491; Fri, 28 Jun 2024 00:03:22 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b061006sm21174525e9.22.2024.06.28.00.03.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:03:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 12/98] hw/sd/sdcard: Restrict SWITCH_FUNCTION to sd_transfer_state (CMD6) Date: Fri, 28 Jun 2024 09:00:48 +0200 Message-ID: <20240628070216.92609-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 SWITCH_FUNCTION is only allowed in TRANSFER state (See 4.8 "Card State Transition Table). Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 7533a78cf6..8f441e418c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1205,6 +1205,10 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) if (sd->mode != sd_data_transfer_mode) { return sd_invalid_mode_for_cmd(sd, req); } + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd_function_switch(sd, req.arg); sd->state = sd_sendingdata_state; sd->data_start = 0; From patchwork Fri Jun 28 07:00:49 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: 808159 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222399wrr; Fri, 28 Jun 2024 00:05:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVbQ0l1d+XinVaL3g5Uf1RWyio4H+LvvAMH75z9q4NbgUbe+yqQZ5+/jduPaMt0W4LQewwUfXWqsslpkWJprrEk X-Google-Smtp-Source: AGHT+IEnt96S0/zubqRgWSEWdGvYeJ58OHp2WPApKKtKgtdNxaA70FSU3qQ4LUDJ+lsNJmqsbq2o X-Received: by 2002:a05:620a:1987:b0:79c:10f6:39b with SMTP id af79cd13be357-79c10f6068fmr1034724485a.66.1719558355653; Fri, 28 Jun 2024 00:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558355; cv=none; d=google.com; s=arc-20160816; b=mVk+kdJA9auhGjadlAYOeO/CcPk3sIJFNWWs9hS5UmXuZNVF0/bucTTNVGy6qZXcAW jcUrMKeOo0aaj0dzqPfAXbXenL/XnEFucMqFGjBz2aYrIgFDMSOJ85Up1lYIx6u3bGP2 27nyod9sK6BG1GuZ5hrlNEspy+JDtb46hryhvXWhxWnrs+CJXlbDJIu+wQXUnJEQta+2 t8c1kB/bxLDPfySuGBafSklVqSZ1D46E7bueQqizC3O0I2bNwqqU7sqy69WQ1AE5T3u6 udqALzZVmjDEItTVbZApyEyHBqVY9D+c0heL7fEHEiFDfwGiYzbOzlN0HZopomWm/dI2 EdDQ== 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:to:from :dkim-signature; bh=zk4YjB9lQI2zLem86by0CBqxXy4bvU8ycOt1g+Y0WQQ=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=cUZiTiYVkU89wCR+TU5FjzX2Cswk+Ft1HGsFkbmxNb5/AhepP5HiZDFnEFMCdE5WvK MuRnk+JpC7dKCYlRxADcPagdcQWDSdsoxicUiO+glnXgBuz1IaJPEniTMCPq43uxGx/0 zf4xQEW30R8huRfMQpmJFr4qq8O8E8ukRCWgqlZ8k0D2D5gu8lSShUA5nPihQde8luxF 1i0B59HM5LL0EIO5n0/3OiYL0RRd2KxULqwVWCDk2SlbmGf57kvdZWj2RQoMeFe0dwyH pKTA1R4PWkabTl92MVSEQ/2GF1nkGeYyFK9QU9qnqWFkmO2k2TmskHhefutgzBCCJ6CI DGmQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GqfC6Bku; 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-79d69260a67si138067385a.40.2024.06.28.00.05.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:05:55 -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=GqfC6Bku; 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 1sN5eM-0001K3-5b; Fri, 28 Jun 2024 03:04:02 -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 1sN5dt-0000cz-Hn for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:35 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5dp-0006k4-QL for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:32 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-36743abace4so847240f8f.1 for ; Fri, 28 Jun 2024 00:03:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558208; x=1720163008; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=zk4YjB9lQI2zLem86by0CBqxXy4bvU8ycOt1g+Y0WQQ=; b=GqfC6Bku+LvwCck3GyfEwZ/DmqcSGf55z6AtBhEQFttvTfvW3J1g5uE+a58StfINnU pvhziLw93zLEvPzz59l16OWK8wKVOfTsV159WtpO7KZ2ZovfgCuy3yRNpOCO31/FGJlj fEtA/umO2L2vpzTDXBfbfkDcjhKpt86Jp48HJQDkHblVoC89cy3E0p9StvoJmzjBPbnZ B0cFBjJYhst/FYHsmJ9/LQYn5qsj9C6KjTAstSsuEpLryrNIaOPKCsNKKPA1nVfZC63S y5/F+TFYEkou6rDc0k/ed6JnKW59Cxv1tCzWIotbw8tcRUsGrfZlay0cFr/rRsCcIzur GCRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558208; x=1720163008; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zk4YjB9lQI2zLem86by0CBqxXy4bvU8ycOt1g+Y0WQQ=; b=XnD7aHhQDtLkARzIpDhE/YAEo26dUU6DAg+AIOfZ/uovB2BnK2y2aw1uPj58ndjjkF yYYh2uu3sLKA6C4loIx5Gx8ymHREVbswbAfETDDbEZpUcKX3SeVgi4krHhRDoCHquyRb gv4xB/E6m8hAtAio7IYomSz2yATIcGkmE1lxdieo+lBwkGz7O2U4ZfXMCVHy0Ahq8EmS sZGfPNAa0tHkLn/4Wia8AhTSZk1JoV4z8T3vIDs8SZkpQp63moGKO6rWMfqDGgkHXW+E MQZEfiOIjqiKvNhE2VuGsIhA9jLHlpZ6qAW7DCJqHYc0ku1zp54VU2vV1cp0PioYNS2O /A9w== X-Gm-Message-State: AOJu0Yy+o6oOFQ/Sez0lLELFWCwfuasTGud4hWYgLdr235jv3gVPNPno Z6yDC/I2wRRBOFaEXGaf3zdzUS91zsXUspvlxhM22dkFHLKzsFyOXfoYRKtj9GAF+qg24Yun+hP i4kM= X-Received: by 2002:a5d:5f4d:0:b0:366:e45b:9fae with SMTP id ffacd0b85a97d-36760a6aadbmr744534f8f.6.1719558207789; Fri, 28 Jun 2024 00:03:27 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0e16a8sm1326385f8f.64.2024.06.28.00.03.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:03:27 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 13/98] hw/sd/sdcard: Add direct reference to SDProto in SDState Date: Fri, 28 Jun 2024 09:00:49 +0200 Message-ID: <20240628070216.92609-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Keep direct reference to SDProto in SDState, remove then unnecessary sd_proto(). Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 8f441e418c..aaa50ab2c5 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -116,6 +116,8 @@ struct SDState { uint8_t spec_version; BlockBackend *blk; + const SDProto *proto; + /* Runtime changeables */ uint32_t mode; /* current card mode, one of SDCardModes */ @@ -154,18 +156,11 @@ struct SDState { static void sd_realize(DeviceState *dev, Error **errp); -static const struct SDProto *sd_proto(SDState *sd) -{ - SDCardClass *sc = SD_CARD_GET_CLASS(sd); - - return sc->proto; -} - static const SDProto sd_proto_spi; static bool sd_is_spi(SDState *sd) { - return sd_proto(sd) == &sd_proto_spi; + return sd->proto == &sd_proto_spi; } static const char *sd_version_str(enum SDPhySpecificationVersion version) @@ -1044,7 +1039,7 @@ static bool address_in_range(SDState *sd, const char *desc, static sd_rsp_type_t sd_invalid_state_for_cmd(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: CMD%i in a wrong state: %s (spec %s)\n", - sd_proto(sd)->name, req.cmd, sd_state_name(sd->state), + sd->proto->name, req.cmd, sd_state_name(sd->state), sd_version_str(sd->spec_version)); return sd_illegal; @@ -1053,7 +1048,7 @@ static sd_rsp_type_t sd_invalid_state_for_cmd(SDState *sd, SDRequest req) static sd_rsp_type_t sd_invalid_mode_for_cmd(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: CMD%i in a wrong mode: %s (spec %s)\n", - sd_proto(sd)->name, req.cmd, sd_mode_name(sd->mode), + sd->proto->name, req.cmd, sd_mode_name(sd->mode), sd_version_str(sd->spec_version)); return sd_illegal; @@ -1062,7 +1057,7 @@ static sd_rsp_type_t sd_invalid_mode_for_cmd(SDState *sd, SDRequest req) static sd_rsp_type_t sd_cmd_illegal(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Unknown CMD%i for spec %s\n", - sd_proto(sd)->name, req.cmd, + sd->proto->name, req.cmd, sd_version_str(sd->spec_version)); return sd_illegal; @@ -1073,7 +1068,7 @@ __attribute__((unused)) static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) { qemu_log_mask(LOG_UNIMP, "%s: CMD%i not implemented\n", - sd_proto(sd)->name, req.cmd); + sd->proto->name, req.cmd); return sd_illegal; } @@ -1166,7 +1161,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) * However there is no ACMD55, so we want to trace this particular case. */ if (req.cmd != 55 || sd->expecting_acmd) { - trace_sdcard_normal_command(sd_proto(sd)->name, + trace_sdcard_normal_command(sd->proto->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); } @@ -1185,8 +1180,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_illegal; } - if (sd_proto(sd)->cmd[req.cmd]) { - return sd_proto(sd)->cmd[req.cmd](sd, req); + if (sd->proto->cmd[req.cmd]) { + return sd->proto->cmd[req.cmd](sd, req); } switch (req.cmd) { @@ -1632,12 +1627,12 @@ static sd_rsp_type_t sd_app_command(SDState *sd, SDRequest req) { sd->last_cmd_name = sd_acmd_name(req.cmd); - trace_sdcard_app_command(sd_proto(sd)->name, sd->last_cmd_name, + trace_sdcard_app_command(sd->proto->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); sd->card_status |= APP_CMD; - if (sd_proto(sd)->acmd[req.cmd]) { - return sd_proto(sd)->acmd[req.cmd](sd, req); + if (sd->proto->acmd[req.cmd]) { + return sd->proto->acmd[req.cmd](sd, req); } switch (req.cmd) { @@ -1928,7 +1923,7 @@ void sd_write_byte(SDState *sd, uint8_t value) if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION)) return; - trace_sdcard_write_data(sd_proto(sd)->name, + trace_sdcard_write_data(sd->proto->name, sd->last_cmd_name, sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { @@ -2083,7 +2078,7 @@ uint8_t sd_read_byte(SDState *sd) io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; - trace_sdcard_read_data(sd_proto(sd)->name, + trace_sdcard_read_data(sd->proto->name, sd->last_cmd_name, sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { @@ -2227,7 +2222,9 @@ static const SDProto sd_proto_sd = { static void sd_instance_init(Object *obj) { SDState *sd = SD_CARD(obj); + SDCardClass *sc = SD_CARD_GET_CLASS(sd); + sd->proto = sc->proto; sd->last_cmd_name = "UNSET"; sd->enable = true; sd->ocr_power_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sd_ocr_powerup, sd); From patchwork Fri Jun 28 07:00: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: 808160 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222401wrr; Fri, 28 Jun 2024 00:05:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUjjruP/aGwqlYobtnTxSrwapHVahYbvftxFrx86mLghHeUBy1ZRcBU5xM0w0w2234bzS8B6QFbJo9VRPdgezEW X-Google-Smtp-Source: AGHT+IFDu+AQ1HB6wxBMUOSCU4whLFstI7I2PLwe9wn+SSzdxquM9LvgMxLOXXUWzwTXaNGEG7SP X-Received: by 2002:a05:620a:4489:b0:79d:58ac:914c with SMTP id af79cd13be357-79d58ac9324mr682154685a.12.1719558356159; Fri, 28 Jun 2024 00:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558356; cv=none; d=google.com; s=arc-20160816; b=agNFt7Du2hHY+dEUR+t973d8FkyFcsN5fXgevwToF4SCeucml5WF6BfypNjvCT8BPn MAJjfzYWqqJHuRuqOqDtjdfNC4QJHvZE7CURylAb+ld6PpXxvOUfpdkai64z7L856saO ta9oFgC+gxWZNAh+ap9S/Aakk3BDRvAqKFwPk//TEUrIEbky6EXBXjHvfwgxCAot5aah HTZDcnHlZF2TKpMV9jHCDOTk9Wm9IvMLrekOBnAYSFkCZ49qw/cXWsIMAOF7sHEFMksC XWnfHcWw/wkuqWz2L+58+DBEv0w0H+JAq9YntkRtxu76jJa1FLHMN4LMAoWz4VnYheJG 5P7g== 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:to:from :dkim-signature; bh=DSF5Ro3NaUsJXtCUAFWLr+3NgzU6nFSUILhMkj2n5D4=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=ay2hai32u6hWzQC3Eua2K5Or4gyQ90wiW2kP61a879cjoRlWGjZzu+9DsWmUhiL5Zo EJqP5/PeXauSDUeiOYQX4QR+p5xK7NkBZ+l4o+u3gPgzRLbRYkoXO4oa7mJjCgwBnGHQ B/x5fG7w98+kh3YBiGARserMyBT8cQmCUIATPiMEO/4iyqGaFKp22GLCaxJlsO5IFeQ4 iFlVjIziN4A3bfl9Ah/McMrTFlYM9y4T/gsGaYR2+oAy/Rcpoo83vkOCPksgeJEHNXBw hnmW3JiHszbYAYwTdxBRk9fic2z4ostoRV1pkDHL10vCU9OmoAJzrdgY9Pqy0WPiSxuA iy4w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gnMPtFqf; 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-79d692f0671si129782585a.279.2024.06.28.00.05.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:05:56 -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=gnMPtFqf; 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 1sN5eM-0001JI-29; Fri, 28 Jun 2024 03:04:02 -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 1sN5dy-0000mQ-0Z for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:42 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5dv-0006kM-FI for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:36 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4256eec963eso1420405e9.1 for ; Fri, 28 Jun 2024 00:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558213; x=1720163013; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=DSF5Ro3NaUsJXtCUAFWLr+3NgzU6nFSUILhMkj2n5D4=; b=gnMPtFqf3o5nkRflbjUo1euMOFrmj+D9XYpfzacDrLZOjAIKWLFnYcV/80AIHO7sTb nT/8TE8DTUf0ANoNGuFUDA2jHMcltKJeKXJr8HMreYzozef1zqUc11hF9UV79tJElnom MpWaTzDrw6Rdfa35wxpmqgRm1HVPL6xtQEXsXw66xJIap8HzT13J0O2jLFKgiOM/7HnI hRDvK7ko01dZwRk9ncEPL0FGcz7XtFhqJBzQRSBCj4Be/GlWR2kSt81Y0NYvuHRoOo0D pkTBkt/+HTwRa9STXskvtZkVRkH7qxpQESlsk9i0wyMI9XeGD3X6icDqEsXcUmvFAYKC ECug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558213; x=1720163013; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DSF5Ro3NaUsJXtCUAFWLr+3NgzU6nFSUILhMkj2n5D4=; b=qPpqs/KzoAJjunE44wQNH7/3T2HnANkAP/LPfU8vTFLw1JRhm9QkNdNxmCvQ529cVS +hbCxc6lE/qoDf05f9uHtqoz4V15ipLwIaymBzOUCqlABhCcBeQgN2aBEMRtvdhwz+KV x+Oe7IFvmP/vATxXNAEaznRsM4WhleDaCRXry0vLBOsjLnrh8kJeSMBSF5BWvhkto9hY pcqCoA5nMLmMOB0c+ZgBxE24yFs2tLhUMn6UA+KshPYtB4i/Q0yyV9GSFjIW9aZsNrg1 m3AUBd9IFLWFerZLmjQgPZHYjJQG9cVqTg6h5hfg4Kc2UO4nbmzy5nZ+MlHQfw7tL5Hi eYTw== X-Gm-Message-State: AOJu0Yz9f2HOVUo+sVtzIVB/PjExQT2ddMBZctNl586FTF4e4jBXbI2u fhuqYctyb4W7It9UDzY67SYKw3fbX5BaNa0RsIIWXTF/u5jw0Z76WpKJpLDUPCOvU9YLVRiGRwk ttzY= X-Received: by 2002:a05:600c:4889:b0:425:5a26:a12c with SMTP id 5b1f17b1804b1-42564510fffmr26402755e9.13.1719558212877; Fri, 28 Jun 2024 00:03:32 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fc58esm1333986f8f.72.2024.06.28.00.03.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:03:32 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 14/98] hw/sd/sdcard: Extract sd_blk_len() helper Date: Fri, 28 Jun 2024 09:00:50 +0200 Message-ID: <20240628070216.92609-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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 From: Philippe Mathieu-Daudé Extract sd_blk_len() helper, use definitions instead of magic values. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index aaa50ab2c5..5997e13107 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -603,6 +603,14 @@ static void sd_response_r7_make(SDState *sd, uint8_t *response) stl_be_p(response, sd->vhs); } +static uint32_t sd_blk_len(SDState *sd) +{ + if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { + return 1 << HWBLOCK_SHIFT; + } + return sd->blk_len; +} + static uint64_t sd_req_get_address(SDState *sd, SDRequest req) { uint64_t addr; @@ -2076,7 +2084,7 @@ uint8_t sd_read_byte(SDState *sd) if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION)) return 0x00; - io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; + io_len = sd_blk_len(sd); trace_sdcard_read_data(sd->proto->name, sd->last_cmd_name, From patchwork Fri Jun 28 07:00:51 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: 808157 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222263wrr; Fri, 28 Jun 2024 00:05:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVAnULtVoLUYYs/FisMyB9SD+nhTZ+oC2VssQ0tVAlsvb/HFKkfghE7O4FW1MhCIpy8lhM3dSygVK42whMILEpb X-Google-Smtp-Source: AGHT+IFESXtpqLgIY726i6e2plTXm/uPfYe1CoeqPpBIVRBY69DMASCGs7OTFqiOySlo6YCjrAHo X-Received: by 2002:a0c:e844:0:b0:6b5:ef1:72b with SMTP id 6a1803df08f44-6b540a83552mr144846286d6.50.1719558327484; Fri, 28 Jun 2024 00:05:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558327; cv=none; d=google.com; s=arc-20160816; b=ZWcuQBBYcOsggmKLtNcjCMEOJa5DvUcji8NwvZs+q6fiSdRFTGLS7RYLSgT8l9wbUJ NcASDtld6+txZO11bA0cSABRP9zlTf+FK4EQn9gQ02zWo8ZE3x+H/5EIb/qb07oNuNlg vBvL94Dg5DJ2yn++aEQwwsn5g8vvYGe7hAf3OuJ7HC+SrzV0yN27CDiT2P0R3077+XwR Hye+rC6jDUJ9Smuiwtvzuv1jYGhUjser1ksvbfCrptypDUPEPdudj848i/qAe+RRTXYY GaMxP4Tvk/VlcqMI+7Skthievmdq2u6bwH8LPExrL7hRCt2tJ2EU99hGnKI+q/7HTUGK o16w== 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:to:from :dkim-signature; bh=J3wthznmbxomPepKTD+GJx+mK9dnEa8WgXWlEO2pfXs=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=OwPH9NsUAcxf65gPhkYwDGftAwym2PTYLprjVpVSJbcP6I89X3O+pwdqZyxRce5/jS pox0LNXRspTTfYM2Bd3XkafFG+HgjuEs1Wgh6JVqZmZeF5icPgRH8NWN83w3M4EeR8w+ rxdmQluBxZF2P5g2okcwx70lCqiegL8g+qBDubYxbIr/eZm4pnvAb3hyJGqGDnP6U6le u4a7fKaAYaHOXX0aGlokzs4MHhLML9kyAeTrXFyYq47vCfDbrKGnbkTqej+Q66SkBCuI kf78POL9v5EBXKvcjga93fbvAz/WEbYJdMs7Rdw+GdEKBjzkiCWqsDgb2i4nt5Ooah+5 PuRQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="q/MT49pa"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e36b504si14118796d6.124.2024.06.28.00.05.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:05:27 -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="q/MT49pa"; 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 1sN5eM-0001Kf-6t; Fri, 28 Jun 2024 03:04:02 -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 1sN5e3-0000qR-Qf for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:44 -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 1sN5dz-0006kx-U9 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:43 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-424f2b73629so3116285e9.2 for ; Fri, 28 Jun 2024 00:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558218; x=1720163018; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=J3wthznmbxomPepKTD+GJx+mK9dnEa8WgXWlEO2pfXs=; b=q/MT49paNwk9DCE0NiN4cyqbIotR6b5MQFtHhs/OH5F0BU0ETLAirFUl8hCLUzOsGj PEiWcbl8k5+Ir1gR0g26YzcX7CpboreGEcc7XAZINa8P/Rh3KntRQ5W4gxfHXyvCfp1K Rtw4szqt6FoKv0CEHpmVbVBDd+9SUWPed+PL/GBOGCXPDLyHXuMn/wIXmdOOlbTokydh F2UruHfnD9iDe7VeGSvZgYBtkduB7c9NAu1bw+DlsbJojzzEZwXkydNy+peMgLyV/jvk gsfQh/L1sniIPccU7b/zETdfnW35v2/qbjyeZ/jbGNc0aCaQXI1lw4ZQLlA8Y7D6q4eh 7GnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558218; x=1720163018; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J3wthznmbxomPepKTD+GJx+mK9dnEa8WgXWlEO2pfXs=; b=XX6UpRAc11stt7uhTRNibCxCME9fg6YdgC6tqFPG93wIZdoDsWx9Xi0CNeU4pgqZe4 Os2LiBhkWMDfihMFToi+ff5r6Y1FpIU35W/dWn9gxOBQ1UJjwlPzAgXQG5Gt5fCIh9ww FO4INEEew2IiAxXk0cugEprHyROEiYBffZNDJ0qjw7pCx8ovi776MweCrP987I6Fj2MC d8bg9Dxg+j2ocnvzuHEf717XW7e7J/UViXstWz3DEfi8SKgDoxf5GW6Hqh/GQ64aHEQR 1MUk8RR+tC19wVBpFef9aVqv+j/QYYUX4cW22f47LHPO14Lvp5LFwfNuslneVbM5cLkc XwRg== X-Gm-Message-State: AOJu0Yw64i9JH9uAV6goZBgwRNCjFG9I2SCJC0KgQ+B5dyOhbxQNW48e MnI+JPAxD/NYnxrrcA3TykagT/fLc+Mo3io0TrCv3VV2u+H9zyjPtBsEk472ITmrMjk3zeKysQM JQH0= X-Received: by 2002:a05:600c:48a4:b0:424:addc:c7ae with SMTP id 5b1f17b1804b1-424addcc946mr62733785e9.28.1719558218171; Fri, 28 Jun 2024 00:03:38 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af5ba67sm21352435e9.19.2024.06.28.00.03.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:03:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [NOTFORMERGE PATCH v42 15/98] tests/qtest: Disable npcm7xx_sdhci tests using hardcoded RCA Date: Fri, 28 Jun 2024 09:00:51 +0200 Message-ID: <20240628070216.92609-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 Disable tests using 0x4567 hardcoded RCA otherwise when using random RCA we get: ERROR:../../tests/qtest/npcm7xx_sdhci-test.c:69:write_sdread: assertion failed: (ret == len) not ok /arm/npcm7xx_sdhci/read_sd - ERROR:../../tests/qtest/npcm7xx_sdhci-test.c:69:write_sdread: assertion failed: (ret == len) Bail out! See https://lore.kernel.org/qemu-devel/37f83be9-deb5-42a1-b704-14984351d803@linaro.org/ Signed-off-by: Philippe Mathieu-Daudé --- Cc: Hao Wu Cc: Shengtan Mao Cc: Tyrone Ting See also discussion with Thomas: https://lore.kernel.org/qemu-devel/484dce48-286a-4a2b-9040-98c45bcfb563@linaro.org/ --- tests/qtest/npcm7xx_sdhci-test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/qtest/npcm7xx_sdhci-test.c b/tests/qtest/npcm7xx_sdhci-test.c index 5d68540e52..6a42b142ad 100644 --- a/tests/qtest/npcm7xx_sdhci-test.c +++ b/tests/qtest/npcm7xx_sdhci-test.c @@ -44,6 +44,7 @@ static QTestState *setup_sd_card(void) sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0x41200000, 0, (41 << 8)); sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0, 0, SDHC_ALL_SEND_CID); sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0, 0, SDHC_SEND_RELATIVE_ADDR); + g_test_skip("hardcoded 0x4567 card address"); sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0x45670000, 0, SDHC_SELECT_DESELECT_CARD); @@ -76,6 +77,9 @@ static void test_read_sd(void) { QTestState *qts = setup_sd_card(); + g_test_skip("hardcoded 0x4567 card address used in setup_sd_card()"); + return; + write_sdread(qts, "hello world"); write_sdread(qts, "goodbye"); @@ -108,6 +112,9 @@ static void test_write_sd(void) { QTestState *qts = setup_sd_card(); + g_test_skip("hardcoded 0x4567 card address used in setup_sd_card()"); + return; + sdwrite_read(qts, "hello world"); sdwrite_read(qts, "goodbye"); From patchwork Fri Jun 28 07:00:52 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: 808155 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp221932wrr; Fri, 28 Jun 2024 00:04:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWYEGerThyAEJBABS9yVUI0+JydDVRaMrjZkUDk9UARzBdJrgItbfO07E89LkysFxWVQfaEL3NMmhPj9n5v3Tde X-Google-Smtp-Source: AGHT+IFRx86MWf4MUdVbKRJdr5lrh7u8cwqE/lYUWcduXi+IFtpHHkstYYsiyChk4Eqd0ZsEDyH5 X-Received: by 2002:a05:620a:2495:b0:79d:5524:dc70 with SMTP id af79cd13be357-79d5524e1bamr836604485a.37.1719558276148; Fri, 28 Jun 2024 00:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558276; cv=none; d=google.com; s=arc-20160816; b=Fw40fp+BOKUQWFOSfbwSanmeggWpI8NXOBsXzu5I4bgACeaW6Y5TqGOMLKFk3lDPiG XPB4xwoXF6ywrWXIFBuqNl45S8KSGaGYsBmPobty7ws9oytljwnjEIcSTPKqK8WeUcY6 STk7gNbrhgmMhqdmRhR+iXA/TnMSO1K+v4BGX28q6Yca2RhKWONtZbQeCe4/D+MIuJ6F rUqC7quy8VECznmIWeFPN0gwML9WADjxLPwB3277AkktcLsRvdyzBXSP8/bcd8QspmaW 8JnrnUSLXUtjV5nPLEyQBdFvwOR1bLJSgO6gy0m59l6PqqN0z16xNUkNO1tYptnC5Tbj EU5A== 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:to:from :dkim-signature; bh=Ra/Td8NG8gR6eO/UQBLHxrI5ovJA5Z/mboPyl147upk=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=i3t5OQul/VOB7qqMzwYxmQts2gWef854IJCsoKovcUaLS+JbndSek+nw4Fu9mAlVQl r7gvobB/RAnXOvICWhY7xpFSDpcbQthymXMlwcXQJsr4W1J1RXc0pj7DYyZuG/xKkG96 09k53o1R5FisRfzbjCYW9I4CkKyAP9Xl1b6pnLc50of+PwsZsW5UMYtZv7aHlwf2i7JX fYLscwlW6KyFCfrR64TLluQmLwGnPuiA/AHhnlHsHdJaZO1V6MfGQTy4F2etwIhWmNZW caMuZ4cNzsqXP0G3x5OAet6SpOS5nELcYGcKp113FYxr7Oyu2kAPfalMM0g2avW1dzJ3 0k1A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QOi3dwCN; 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-79d69308b72si119386385a.472.2024.06.28.00.04.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:04:36 -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=QOi3dwCN; 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 1sN5eQ-0001aV-NB; Fri, 28 Jun 2024 03:04:06 -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 1sN5e8-0000t6-T6 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:50 -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 1sN5e5-0006mk-5P for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:03:48 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42563a9fa58so2473335e9.0 for ; Fri, 28 Jun 2024 00:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558223; x=1720163023; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Ra/Td8NG8gR6eO/UQBLHxrI5ovJA5Z/mboPyl147upk=; b=QOi3dwCNnD9a3DCjeQEVhrciS46U2rYCzSt3BxgbDGB7q+gsjpP1lihBOinUH+VQpv T09eX100C7GZKMpBRcIDeWh1/HJFYAiySwKGysA2i9jH/f6UVCUp9XUaJxjtFOTAPbEA JtdMg6zA9Wj0QbfCQyBLTCA7OBQCVXAhq8DPLj1PkNTtNHRIkmIBVS4pqwzQwBkGssIi h8OegKsWqG9EqBzlNL7mjS/Kp4ZU3yuHGKA+8+HXbLuAQIVy63DgADUaX64+TWbGrg1w vJFZDIc2jug2vbsB0UwXDqskVFQcJfahXdF/kx6Cqki0Dvo37wJBoqiu+JApqN2+G6U7 Tu4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558223; x=1720163023; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ra/Td8NG8gR6eO/UQBLHxrI5ovJA5Z/mboPyl147upk=; b=LVn+Ypb8DMLtWRUPm7ww5ByeGaE64daE/7i7+d15P+C3OIoYqHsWYEnRTYhxKERPjW ToO7x7q0RkFkN9JqhOPX2661Qo3j1WPOQFqyOcmgsPoy1VMAnZLBRAYu/bTkiwgwZoER w0ybzjtjuUJZjn0xZH087CQTTcRwEaOUrDy02GMQNpHtIx7FTA3XxuzUi15E5amwB8ZS 8wWX94vJGlPLsSMZq0ZCroHrNMfY3KEXEVXyZqkR17/SHLZmp8FYbSs+tMSYKjpD3YT3 40Mm5zaqrG+SjNYevu7u9gg3Pik/2yXWTqYmffemjFwk3nvDhJWXhl2wfKhlUhawfDVo uGsg== X-Gm-Message-State: AOJu0Yzm6+sovqz0hu3Eth3wm70F7mMfJSJMRUGWEcHEugpvHVaYp8NY 6G3vqFcpC46TdLXnzsZAbeZKZlwy4c8AN5jt/8ZZfBFTPrWAtjgzEc/yenNAWmCiqwdO084+YU0 pR/Y= X-Received: by 2002:a5d:58ed:0:b0:362:f291:6f97 with SMTP id ffacd0b85a97d-366e4ed2eb5mr10668832f8f.18.1719558223252; Fri, 28 Jun 2024 00:03:43 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fba4fsm1324067f8f.85.2024.06.28.00.03.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:03:42 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 16/98] hw/sd/sdcard: Generate random RCA value Date: Fri, 28 Jun 2024 09:00:52 +0200 Message-ID: <20240628070216.92609-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Rather than using the obscure 0x4567 magic value, use a real random one. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 11 ++++++++--- hw/sd/trace-events | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5997e13107..d85b2906f4 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -46,6 +46,7 @@ #include "qemu/error-report.h" #include "qemu/timer.h" #include "qemu/log.h" +#include "qemu/guest-random.h" #include "qemu/module.h" #include "sdmmc-internal.h" #include "trace.h" @@ -488,9 +489,10 @@ static void sd_set_csd(SDState *sd, uint64_t size) /* Relative Card Address register */ -static void sd_set_rca(SDState *sd) +static void sd_set_rca(SDState *sd, uint16_t value) { - sd->rca += 0x4567; + trace_sdcard_set_rca(value); + sd->rca = value; } static uint16_t sd_req_get_rca(SDState *s, SDRequest req) @@ -1113,11 +1115,14 @@ static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req) /* CMD3 */ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) { + uint16_t random_rca; + switch (sd->state) { case sd_identification_state: case sd_standby_state: sd->state = sd_standby_state; - sd_set_rca(sd); + qemu_guest_getrandom_nofail(&random_rca, sizeof(random_rca)); + sd_set_rca(sd, random_rca); return sd_r6; default: diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 43eaeba149..6a51b0e906 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -43,6 +43,7 @@ sdcard_response(const char *rspdesc, int rsplen) "%s (sz:%d)" sdcard_powerup(void) "" sdcard_inquiry_cmd41(void) "" sdcard_reset(void) "" +sdcard_set_rca(uint16_t value) "new RCA: 0x%04x" sdcard_set_blocklen(uint16_t length) "block len 0x%03x" sdcard_set_block_count(uint32_t cnt) "block cnt 0x%"PRIx32 sdcard_inserted(bool readonly) "read_only: %u" From patchwork Fri Jun 28 07:00:53 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: 808156 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222071wrr; Fri, 28 Jun 2024 00:04:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUkA5Eh94EqTGDxu8SrRaawOYn4MNke3KlMURwBMpu5Oe3vR6DMzl76LA74sLe5B0sUMmDiS8QQ49g1vmEaz521 X-Google-Smtp-Source: AGHT+IF6TCtIkxPJC9Pfo5a5Q31bxBjiuLV21yuqAKp5kxFWCz9pxUhFgUnwx38sB9jGqq6TovTq X-Received: by 2002:ad4:5de7:0:b0:6b0:8fa9:6cac with SMTP id 6a1803df08f44-6b540aab627mr220157456d6.57.1719558295978; Fri, 28 Jun 2024 00:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558295; cv=none; d=google.com; s=arc-20160816; b=fvTJpPqBkO5KDG1zKAYX4+vVQaIO3Bpi7zsP4PcxG8ImYEcLArPQVG8GPW3yHjsJEg DVqqqKMFpaToYfR+4Tm+Pkuu34hB7FTbeWqZHjONwpCvR9KKweS4/EpIjnNy1TXmZ3HA YX3izJBrNszyUe7DkESn5psJsdrSl2CnXkX3NvBfyMBTlahKkABy+AsSLT5smalleGPv EbN4RJEx+2KJtkPADHv3GRPb/ivkfh86Jg2T3K5cPJBzIHzNEmTadunwhcBu5k3ArQHo aW+E+vTv9HkPUV2VeDA4ckMpPkSqL92J0eFA8PRBjDcKm7l18yvqN5TeOZVeP3F3vhGz 2dJA== 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:to:from :dkim-signature; bh=lMFKG2q5UbCp1Dyyq8cGhI62qgCIuzAq7XqP054066E=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=z5qp078yKXXlwtGZa99DmbRcooTSZeSZsHp4m0kXnibvNH9SJILnxw08P33oXrTgKs 3dhE8KM+if7vPE58nUbz6NOLiQWUr/zQq43z5OzehaU2vvvqACz+FhSvVJrBxhiFl33g Rq602LmCrNN3SCkdqJxM1/TU93P9UUskuB6hFe2oAOLJGDNiJwTM9M+enofu906E40MS Qv2P07wBf5nEotO32PmPpx27iJEC/74UJVI40a0LEkbvUTi5OFG8KYp9CHrl2OqoWqOf x5Sv5NCQLGpCRFaCg33eTNgFZk6PDb62DhdXvuKFVEnap7EGAvKqzuNGJkTPUInGi+fG aJSQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LMKGSIv9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e363467si13796116d6.17.2024.06.28.00.04.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:04:55 -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=LMKGSIv9; 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 1sN5en-0002Qe-9Z; Fri, 28 Jun 2024 03:04:29 -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 1sN5eg-00024b-Kj for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:24 -0400 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5ee-0006oC-Oz for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:22 -0400 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-52e764bb3fbso331482e87.3 for ; Fri, 28 Jun 2024 00:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558258; x=1720163058; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=lMFKG2q5UbCp1Dyyq8cGhI62qgCIuzAq7XqP054066E=; b=LMKGSIv9Nekb8cxZ4VZ9e/yLypMsrHRkn/89+ZcHumEe2I+4JBA9wUyuh6E+GVksq5 lBXEL0JGWb8ZDpQXRoyZke9oPVP/APKBr1pE18E4Hc0JHFAHVOp5+Pd2GytfzglrXkEq QrjS+uWZPlSGobaCKnpPEpzNQmkYowyTpbBDZBrLd0yr4XY1LfkT4CO1ZjOLASbCUWHc zJtgIidz47JqRKII100cqejO0Dd49Oc97SLwHfSv/dFDoyeAAs48QORN55TJhrSoR9Ha rOmGni2EVNLCXDQANX898QyV8dokENGKOhez7JsURPXQbnavmCHL9ggUHm6Ebzp4jIxz HW1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558258; x=1720163058; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lMFKG2q5UbCp1Dyyq8cGhI62qgCIuzAq7XqP054066E=; b=u/n3E1+uS9+WfOgcuYK9QOj9U2JPxYui+TDpu1yzVFreaYXEkcGB9qdxZjzn/U4d6+ 3LziTROr5O1VU0AgL+Wt5VaoA/iGpa24XEXsymIAGLYvR8Ug/OI0PHtFnIpqbZU5E7Es 1PTVxG/kTMxh3lxdccwVU0PClfJm55ZWA48U3auzxnXKEvbNAMISTlFYY1JTzqEdzgtR /AiGGO3rMgnVIlQJXw7Sm7q5eKHRH9arFYlhmDUaJTOsfAWs7kgDTa/xU/J5WURueK8I zPYfdt3Xjkn0KFHYeO4slt8N9cRw+wbZEhyGSFHR98ubkrghuEDoEqPJKI/PIHUtzRjQ kDdQ== X-Gm-Message-State: AOJu0YyxB4WTNGQh6hb5BO0eaPC9/TOXyOmv+t6JCGOJdMj0QM4bLgh7 pBk+GXH9twDsTHff0dVLsvXmxj5cpEK6rM1jQSKLn5NWjbD4BgIklk6Vq3Ww45wXN8XImPh4ToB tBuQ= X-Received: by 2002:a05:6512:3988:b0:52c:ea28:8442 with SMTP id 2adb3069b0e04-52cea288ea1mr10217264e87.20.1719558228488; Fri, 28 Jun 2024 00:03:48 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af557fesm21849705e9.11.2024.06.28.00.03.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:03:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 17/98] hw/sd/sdcard: Introduce definitions for EXT_CSD register Date: Fri, 28 Jun 2024 09:00:53 +0200 Message-ID: <20240628070216.92609-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::130; envelope-from=philmd@linaro.org; helo=mail-lf1-x130.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UPPERCASE_50_75=0.008 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Cédric Le Goater Signed-off-by: Cédric Le Goater Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sdmmc-internal.h | 97 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/hw/sd/sdmmc-internal.h b/hw/sd/sdmmc-internal.h index d8bf17d204..306ffa7f53 100644 --- a/hw/sd/sdmmc-internal.h +++ b/hw/sd/sdmmc-internal.h @@ -11,6 +11,103 @@ #ifndef SDMMC_INTERNAL_H #define SDMMC_INTERNAL_H +/* + * EXT_CSD fields + */ + +#define EXT_CSD_CMDQ_MODE_EN 15 /* R/W */ +#define EXT_CSD_FLUSH_CACHE 32 /* W */ +#define EXT_CSD_CACHE_CTRL 33 /* R/W */ +#define EXT_CSD_POWER_OFF_NOTIFICATION 34 /* R/W */ +#define EXT_CSD_PACKED_FAILURE_INDEX 35 /* RO */ +#define EXT_CSD_PACKED_CMD_STATUS 36 /* RO */ +#define EXT_CSD_EXP_EVENTS_STATUS 54 /* RO, 2 bytes */ +#define EXT_CSD_EXP_EVENTS_CTRL 56 /* R/W, 2 bytes */ +#define EXT_CSD_DATA_SECTOR_SIZE 61 /* R */ +#define EXT_CSD_GP_SIZE_MULT 143 /* R/W */ +#define EXT_CSD_PARTITION_SETTING_COMPLETED 155 /* R/W */ +#define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */ +#define EXT_CSD_PARTITION_SUPPORT 160 /* RO */ +#define EXT_CSD_HPI_MGMT 161 /* R/W */ +#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */ +#define EXT_CSD_BKOPS_EN 163 /* R/W */ +#define EXT_CSD_BKOPS_START 164 /* W */ +#define EXT_CSD_SANITIZE_START 165 /* W */ +#define EXT_CSD_WR_REL_PARAM 166 /* RO */ +#define EXT_CSD_RPMB_MULT 168 /* RO */ +#define EXT_CSD_FW_CONFIG 169 /* R/W */ +#define EXT_CSD_BOOT_WP 173 /* R/W */ +#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ +#define EXT_CSD_PART_CONFIG 179 /* R/W */ +#define EXT_CSD_ERASED_MEM_CONT 181 /* RO */ +#define EXT_CSD_BUS_WIDTH 183 /* R/W */ +#define EXT_CSD_STROBE_SUPPORT 184 /* RO */ +#define EXT_CSD_HS_TIMING 185 /* R/W */ +#define EXT_CSD_POWER_CLASS 187 /* R/W */ +#define EXT_CSD_REV 192 /* RO */ +#define EXT_CSD_STRUCTURE 194 /* RO */ +#define EXT_CSD_CARD_TYPE 196 /* RO */ +#define EXT_CSD_DRIVER_STRENGTH 197 /* RO */ +#define EXT_CSD_OUT_OF_INTERRUPT_TIME 198 /* RO */ +#define EXT_CSD_PART_SWITCH_TIME 199 /* RO */ +#define EXT_CSD_PWR_CL_52_195 200 /* RO */ +#define EXT_CSD_PWR_CL_26_195 201 /* RO */ +#define EXT_CSD_PWR_CL_52_360 202 /* RO */ +#define EXT_CSD_PWR_CL_26_360 203 /* RO */ +#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ +#define EXT_CSD_S_A_TIMEOUT 217 /* RO */ +#define EXT_CSD_S_C_VCCQ 219 /* RO */ +#define EXT_CSD_S_C_VCC 220 /* RO */ +#define EXT_CSD_REL_WR_SEC_C 222 /* RO */ +#define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */ +#define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */ +#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ +#define EXT_CSD_ACC_SIZE 225 /* RO */ +#define EXT_CSD_BOOT_MULT 226 /* RO */ +#define EXT_CSD_BOOT_INFO 228 /* RO */ +#define EXT_CSD_SEC_TRIM_MULT 229 /* RO */ +#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ +#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ +#define EXT_CSD_TRIM_MULT 232 /* RO */ +#define EXT_CSD_PWR_CL_200_195 236 /* RO */ +#define EXT_CSD_PWR_CL_200_360 237 /* RO */ +#define EXT_CSD_PWR_CL_DDR_52_195 238 /* RO */ +#define EXT_CSD_PWR_CL_DDR_52_360 239 /* RO */ +#define EXT_CSD_BKOPS_STATUS 246 /* RO */ +#define EXT_CSD_POWER_OFF_LONG_TIME 247 /* RO */ +#define EXT_CSD_GENERIC_CMD6_TIME 248 /* RO */ +#define EXT_CSD_CACHE_SIZE 249 /* RO, 4 bytes */ +#define EXT_CSD_PWR_CL_DDR_200_360 253 /* RO */ +#define EXT_CSD_FIRMWARE_VERSION 254 /* RO, 8 bytes */ +#define EXT_CSD_PRE_EOL_INFO 267 /* RO */ +#define EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A 268 /* RO */ +#define EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B 269 /* RO */ +#define EXT_CSD_CMDQ_DEPTH 307 /* RO */ +#define EXT_CSD_CMDQ_SUPPORT 308 /* RO */ +#define EXT_CSD_SUPPORTED_MODE 493 /* RO */ +#define EXT_CSD_TAG_UNIT_SIZE 498 /* RO */ +#define EXT_CSD_DATA_TAG_SUPPORT 499 /* RO */ +#define EXT_CSD_MAX_PACKED_WRITES 500 /* RO */ +#define EXT_CSD_MAX_PACKED_READS 501 /* RO */ +#define EXT_CSD_BKOPS_SUPPORT 502 /* RO */ +#define EXT_CSD_HPI_FEATURES 503 /* RO */ +#define EXT_CSD_S_CMD_SET 504 /* RO */ + +/* + * EXT_CSD field definitions + */ + +#define EXT_CSD_WR_REL_PARAM_EN (1 << 2) +#define EXT_CSD_WR_REL_PARAM_EN_RPMB_REL_WR (1 << 4) + +#define EXT_CSD_PART_CONFIG_ACC_MASK (0x7) +#define EXT_CSD_PART_CONFIG_ACC_DEFAULT (0x0) +#define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1) + +#define EXT_CSD_PART_CONFIG_EN_MASK (0x7 << 3) +#define EXT_CSD_PART_CONFIG_EN_BOOT0 (0x1 << 3) +#define EXT_CSD_PART_CONFIG_EN_USER (0x7 << 3) + #define SDMMC_CMD_MAX 64 /** From patchwork Fri Jun 28 07:00:54 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: 808163 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222548wrr; Fri, 28 Jun 2024 00:06:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWN0q8zuB3wZ7jRqWh28ewprGXabIF3MrA7ywjmP2JvAIYaMTa7OUtzaA1N0kHxy1BP+gNBSIwsW2sGdtFllXRO X-Google-Smtp-Source: AGHT+IF1KDJDU5dM+2k6BpgaoOIV/O/MwzOv6P74cF5XSg5uh8vYS5SAVJ/waYcQkCBQ3xvRoyZP X-Received: by 2002:a05:620a:25c8:b0:79b:ff3c:7955 with SMTP id af79cd13be357-79bff3c799dmr1197889785a.53.1719558379477; Fri, 28 Jun 2024 00:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558379; cv=none; d=google.com; s=arc-20160816; b=y/7xWKTB8UtgTiVKybG0PDypuCBres03GiL7LpN3Khr07Ec2633uTTY3s3BdPDq3WC 5m/nqLXyAhsQYE8vcashWMRcyHKvHLZ/mXIUFehLDg67g98iuxBT3xCmuDw91yxoehQq /Q8xHE6KtdVtAGaoP/RD0I70KStm00k+b9vI/HfFDbExwf3YSdkqLoHx4lHpYnK7wH+M ly5YuxkSsUSXHn1Rweg0HlXJu8yK2AdNYclNtMvAy4hQ7kvohFNxd9YE99H8o3vwG5vV 4VDpWyQeuJOnY53mJ3vUlLXfQGm3m3Qa2ea2yYuu7rezad4yyPnEnVNXvls4Kb08k+hd MeIg== 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:to:from :dkim-signature; bh=/dkdp8a0v1eDrwEVEV8e/ROv9nmNjtoGPC9rjoBe3Zg=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=ZicyCYI18ZJ9XVrQMlRq7EC0UKPSYkc2IUo/QaAheMfPsF66N4yAFW+VeCuAWeO89f 9JA2+wHKtjmQap9y11u6zGZAMWmT/jlSCbybpu/VRQDpJTgETbV1amQZnr0Ke4ymBiqY dlqN2GiDAfq/OnnbhCL37iClGHyY417/d6bC2HZdZdtjfI4242Wq1INnMKiIcapwza3c avmksr/sHLZTtxOQksBlh0uWlYjd3qTPt3N1XPy9ZauMlTmqExrlBoxmbt9i2jYABMDV XORAxQNEgEPaaRX50OZRmxc6eMvTWgAwxmFGtwAaRzNQtPbba3O2255XTxZP8PK8eRMt fsEA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mJLjo3cQ; 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-79d6933851asi126737385a.597.2024.06.28.00.06.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:06:19 -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=mJLjo3cQ; 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 1sN5ep-0002ix-3l; Fri, 28 Jun 2024 03:04:31 -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 1sN5el-0002BD-LN for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:27 -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 1sN5ej-0006oh-Lj for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:27 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52cdf579dd2so266624e87.3 for ; Fri, 28 Jun 2024 00:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558263; x=1720163063; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/dkdp8a0v1eDrwEVEV8e/ROv9nmNjtoGPC9rjoBe3Zg=; b=mJLjo3cQ2EIa8sWyLFnEbyAbd5JwkzS+E3vW0fvop9ZHV8zELsai+3nRygEXitMBLt oykR7EiNVlyGLHHNB14LCGs3nW+FvNMXnBXLctMZH3NmKMOCnH6y/2rP/chHJG5VSH9K DYUaikNrj/ji9NtZ2YrGO40jG2PxckdW1h2LJ1QTNfXoQ7eIiAjTnPBxmiz/7Sg2i4SV fjwvs61CFx5V0CYi29IJj7UO+hhWRkKl3JIeTbARK2E8nVAwL2t+vMgnX7YwGDGuLNnB cv0HH9DZRcrIQfBnEQMdwaolSdkjE00x2Zl4AbX+XgGxxUUNwSuEkAxPK16teVY4GCad JBLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558263; x=1720163063; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/dkdp8a0v1eDrwEVEV8e/ROv9nmNjtoGPC9rjoBe3Zg=; b=UGH8nl9Ha8RHfxRWL2NKymBlXKkYveRD1Z3fOP5zNqqFpqg7ul+dgWBbj/fSOv2iRm YotGhE9aCg+TrnoCBg6kY/aN6tx1hoN3y2lL8lSKOoSQkwPjKgHMJARopLThMJoyYZmn M3/B2hEMdnBBDslpVDOsaxslppUyY2A7isxQDNAJ7o34M0b99VPYTG9y3UwwV/yZ5t0G 5+acVt8KimCapB+EvQWJSszSIhORejxK+KQzXV1WhKgflqVXRyMBhS0dKE/64Z5QyqaM G14JA1CtO1VLN69seDW9Q5CxAeA8xM9tWDB2CSitThFvALGDTG/nwr9joNEQKO/sqcJg iaVQ== X-Gm-Message-State: AOJu0Yy1blZTH8Hy5ULBrf3BeDqFblp+PmcN494ge3Mn9G3Hfi16TskV nlAuOZeiScfppJquaW2k4W2EHdbl9bVI648ToSRNUqDV5bZEBcQIhTwt8XahwQhmW+3XAMvcykd n6ZU= X-Received: by 2002:ac2:5dcd:0:b0:52c:9824:2780 with SMTP id 2adb3069b0e04-52cdf82618dmr10265867e87.64.1719558263542; Fri, 28 Jun 2024 00:04:23 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256f55c4b5sm5365505e9.43.2024.06.28.00.04.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:04:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 18/98] hw/sd/sdcard: Introduce sd_cmd_to_sendingdata and sd_generic_read_byte Date: Fri, 28 Jun 2024 09:00:54 +0200 Message-ID: <20240628070216.92609-19-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 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=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 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é Reviewed-by: Cédric Le Goater --- 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]; @@ -1083,6 +1085,29 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) return sd_illegal; } +/* 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 != sd_transfer_state) { + sd_invalid_state_for_cmd(sd, req); + } + + sd->state = sd_sendingdata_state; + sd->data_start = start; + sd->data_offset = 0; + if (data) { + assert(size); + memcpy(sd->data, data, size); + } + if (size) { + sd->data_size = 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; } +/* Return true when buffer is consumed. Configured by sd_cmd_to_sendingdata() */ +__attribute__((unused)) +static bool sd_generic_read_byte(SDState *sd, uint8_t *value) +{ + *value = sd->data[sd->data_offset]; + + if (++sd->data_offset >= sd->data_size) { + sd->state = sd_transfer_state; + return true; + } + + return false; +} + void sd_write_byte(SDState *sd, uint8_t value) { int i; From patchwork Fri Jun 28 07:00:55 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: 808197 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224506wrr; Fri, 28 Jun 2024 00:12:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUBH543F7OkfdkrvRzpPGo53K63RnXYhpw4zI66EQmV8++e6lQEQy9xhDDGyLWjDZX/BzwewGH4FhNdfzvJQOs3 X-Google-Smtp-Source: AGHT+IHdUi3GMJKs83gmx2PwAfF0NKoz5KhNLHUc0i2v8IoLd9CipDSJdyFMNiw8IgylqrhtiNDJ X-Received: by 2002:a05:620a:170f:b0:79a:2fcb:ed5a with SMTP id af79cd13be357-79be0bfd6f3mr1880748185a.11.1719558750573; Fri, 28 Jun 2024 00:12:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558750; cv=none; d=google.com; s=arc-20160816; b=O7xKyjlZg2dh/BKSz7xN9Q4rOdHx6QDACsuO6BhhiwrMlWqOAkcDdYMRFzyubxFFJt XfLfE1f8D9NEuNmyB1db4kEGCykyXYNSSvkLzZ6/3xaRB5f6qO3SceBTIk/owwt8vjv7 iHJso586mSs9AdwkN+FAEifQMiJ+tC5gb9Ix4TSw8Ejk3+HlG5vmW5HMUU4NvRECvgcN bFAqS8ilzk4xUETPEJQkLnYBTZebsUSlHdGIvCMrbY5NUpDPVG2IXNXwsipTLVwicf8G jfaqq+8OF7XeKvbMLmg3PPGJifK3ef4qHbD/2el7S1AGHd6IozvjVlcsgUReCv3fazgV JGJQ== 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:to:from :dkim-signature; bh=PCAoLc7mb3MX2dHo327SeM2P71tXBpRF4C3PP6PydTI=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=mbE/IjNgyylvuq87oZMrPro4p+yKkEWOdVCD585g/zW5Tdf0VSxeCgncsu84sjpwYO Rz8vEjGewRcENpSXyThqwhw4Wq0Bydn9ga0+Og+kqocchRS0X/yLO0d61FBzilrVibJv Px1owj6L5O5qtYQ8ZhozNwTgdOKW+Sj/UjHqdbLuGnzDM/bO7Grf42i8b2H00YRiSen6 slTO5O10eLHSH7Kx5m2UoABT5reriwvbUQmESYA5Cv7Kx5DjbzBVDMNWdCOaJLp+HnxI poKafW2mZgd8/olDl3fyL0G8f/A4ne78z76NsV1thqziuWGB8JTbE/cLOzZdIbe5WrRG mLZA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uyST5QjO; 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-79d69308be7si123070585a.483.2024.06.28.00.12.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:12:30 -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=uyST5QjO; 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 1sN5f0-0003cU-8M; Fri, 28 Jun 2024 03:04: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 1sN5er-0003BC-NF for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:33 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5ep-0006os-O5 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:33 -0400 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2ebe785b234so2318601fa.1 for ; Fri, 28 Jun 2024 00:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558269; x=1720163069; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PCAoLc7mb3MX2dHo327SeM2P71tXBpRF4C3PP6PydTI=; b=uyST5QjOvsb0ykQQbMbLyz7804TLtHu+9ngoUUkScDsOwfAOfn8K4G2OTM0baekBr2 LLzhRmVLAuSUzuTWB8RCFIz74E5zs4eFmgcixdyBogJue6pAhYZkmsmma9eJM7jLsaz9 qJFPHMv7gKABKvZuIAffy4dB0LWlM7yzkskDFhoPm55cA20uJhhG2lcBkC2453cN21GJ RNErL/koobew35lq0FZBzfc8Vraw+SeMAy8GMo3lmIBYz1RP0AeJdzRFi+ZgKmpwC7c8 ryjJMvWDMoGRatfpENThMpev0m0tPkR6wk8OYWn20hzK8sU9FBVBswN+iUfVE2jf58rV K4ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558269; x=1720163069; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PCAoLc7mb3MX2dHo327SeM2P71tXBpRF4C3PP6PydTI=; b=FP797Rv0V/DfiuhZp61WKbjP4pUADaWtddBCburoNFUp/EY7vUI56DohX9H+PRtfuD g2c/vsss5u6X5flFfWVCidH9uLBnetbNBiACyFUK0C/5qyyLe9BgRPDlCGmyGWMpzwps JYtOyMZ5Aq6iCY0EHbj97QlzKYYAxM+lw/dddKqDjKaMTzXQjZ38LrcXu3NPa3v2jOTg IsKG3TyValvuu/tQl6KBiX7HN2LXM6C3DtHcycBc0SRUHnqEFPPMSLKp5dAGIRsJywJX e5Z07HCY24MLUegCfy41dm58EL9lgEKKygU2hzGfqGIVnZurtFh6fBhZR3ATouXKeAsy qz2Q== X-Gm-Message-State: AOJu0Yy6TsOMaGKbGBu1KF32oOLxvoPLTafaIrs7WOr8IwF9SnHpBR3h QRn73kRs5IVmn1V8Al20JTyWjxeE9KBLj0GHy9B7sKp3g5VZeVtyDZRq2LFBqsDFCKd40Odp6QD cw0Y= X-Received: by 2002:a2e:9886:0:b0:2ec:57b4:1c6a with SMTP id 38308e7fff4ca-2ec5936fa52mr112080041fa.42.1719558268964; Fri, 28 Jun 2024 00:04:28 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c0fbesm20400065e9.43.2024.06.28.00.04.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:04:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 19/98] hw/sd/sdcard: Convert SWITCH_FUNCTION to generic_read_byte (CMD6) Date: Fri, 28 Jun 2024 09:00:55 +0200 Message-ID: <20240628070216.92609-20-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=philmd@linaro.org; helo=mail-lj1-x236.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Reviewed-by: Cédric Le Goater --- 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) } /* 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) } sd_function_switch(sd, req.arg); - sd->state = sd_sendingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); case 7: /* CMD7: SELECT/DESELECT_CARD */ rca = sd_req_get_rca(sd, req); @@ -1946,7 +1942,6 @@ send_response: } /* Return true when buffer is consumed. Configured by sd_cmd_to_sendingdata() */ -__attribute__((unused)) static bool sd_generic_read_byte(SDState *sd, uint8_t *value) { *value = 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 = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 64) - sd->state = sd_transfer_state; + sd_generic_read_byte(sd, &ret); break; case 9: /* CMD9: SEND_CSD */ From patchwork Fri Jun 28 07:00:56 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: 808174 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223033wrr; Fri, 28 Jun 2024 00:07:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXziALEGUm1BCc1BdVeUo2TFi4xJtAsphN0FqNIOnLjXds3kPwUqH7FmMr3+RJEFokhcTpCiZVhbsX/vqdEMMQ1 X-Google-Smtp-Source: AGHT+IH5n5DWazgaZzPBijwaXPNqDfE814QSVo/e8IZwxr5QT8kVdezzhzgUgpUB8O1mQzH0h+WT X-Received: by 2002:a05:622a:19a3:b0:440:5275:d435 with SMTP id d75a77b69052e-444d922ade0mr184541501cf.30.1719558463373; Fri, 28 Jun 2024 00:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558463; cv=none; d=google.com; s=arc-20160816; b=Y0pVw6bFC2hyPG3t3Ad3qkeXuV7VD9Y0XIluQ5RZ3vF9Gd9tu2HvSPlW0bNquNdWtb QHqk9U/WCs7pbwoVOehkEDdk7cXlmn94UqtEZYG9pPQT3eJFhEbWjUQg6zLuRrKGzN3O 59TIa0lsa12UQfT3cDc2ywukkbJSqwFBPBPnjHU0TQRadwUzGurc/O9mjVTGitfgfdWc DajLt3oX1amMpGcALVflOgnUMucDrdqgXBDE2JrVhqN3xRU7jS8wyKrL5V9ZOb6Y8zBL IYx7oCER8mzXIa/eNZJqRhyzLE4R0FgLqnPwW9irlOre15v/jvlUE72lb7tu/YNu/PGq LAAw== 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:to:from :dkim-signature; bh=IMgFwh1ILCldQYzDAsSnCsrKfQsCDMsdI1Fnj4dwB/k=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=g9KqtFlsOEthl+okeo9bfvatXiPvjCWjJDV5oXQyZeDscYOjWB1ZHuXF8NcjsO35VA +V/qGA1SAYWib2EWNWG6ziiYVZxMJoipHcO4/CZLOx8pHgR4S8B7bnMJNpOJ8mW+vBi9 +vkpM6G4eSUUBS4d0I3ca0ffVlRq/e4fdSgtSkyRlIox9+vNwoW74ZDDEX3WJ8kO8Zx1 S/3tLa0aKGjYW8YieY1l9cSZRFs44SK2CGxYDDzWY7IBGELcq9tQj2tilosQ6veOIxGi Dsop//O/PlN5CSPMVgn1iiXHjX/UgGu58fDVxIOebhCnWTOQNk2s5HvDq8Kyw0JFcfwR Fmpg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EPBdaDQr; 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-446512cc5b6si13213141cf.106.2024.06.28.00.07.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:07: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=EPBdaDQr; 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 1sN5fD-0004NM-Hd; Fri, 28 Jun 2024 03:04:55 -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 1sN5ew-0003p2-Jy for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:40 -0400 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5eu-0007Ac-9V for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:37 -0400 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-52ccc40e72eso230025e87.3 for ; Fri, 28 Jun 2024 00:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558274; x=1720163074; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=IMgFwh1ILCldQYzDAsSnCsrKfQsCDMsdI1Fnj4dwB/k=; b=EPBdaDQr766xiiVG2RZhY1wvuoupD0fx4WQ4NLiv72wlKmKwisnXn/z2Fz71MFN5UT NFSOqdLyqUhxBsc2JMk7YB4El9D8B3pQJ0yIMJJgkZkkXAz6hjy3j+827Ac9cD3NULSk GdnwZgEi7g5SJHyGYVmuiDKRMpevJPd8JPIJ75Yn5lVIQXWnl2AGMTBYgJl6T4gdaXjR Ay/4j1bafxc01CobRTamX/MFq4NrZFb5ZRXM7Gy3tV2lF0J/ZdL8GgVRM8ZPdXnGHq/s g1oDLaVh9soQt82nPEzOt9oaJG/9a2hT+p/TTqKOgugu4J83cPPAlrTpd3FM7DvQZWdk zW+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558274; x=1720163074; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IMgFwh1ILCldQYzDAsSnCsrKfQsCDMsdI1Fnj4dwB/k=; b=TUpB9k4dtIzd72oRAUxH+GTTvcYxfdIH8AfGQV2z8s256XKL4SlfPPZeIYASr1QBmU I/C6Zj9EeuI2/roo52zH+FvxUnoX0L9+7+FbBrbEanrYEAVanW5rjP1Q5aRawX8/8l/4 xhloNwABSK6TbuqvmpdLiiSrCJZWfYV9iftEMe4HsxffU+WCrZ6P6Ai+Jv8PvxOHK3nA AWYmFNZ3wVJ2utIr2Z+JWBwIGwzYKzskqW0I/OFw8jGFEQUeinDiOV76DgTDczCdbcio 9uEGVPC3xv/sUD5EfTQnTWwIp6HyU7pYhzyOAokZ3oFQnxrMTXOOqevXhWAZkaPfmOto rknQ== X-Gm-Message-State: AOJu0YzlYHpfvzC3rQ+Rsvonnw0ag+eK8mQL+G4HJleeSInH+6gi51h/ 7z0bu2Ahm534gCrMQbQWrtxBwXVqtacRe2hStcpSBX8yBfBOyhMsFx0dfGTFzAOeVjRecYwhO8N VQEo= X-Received: by 2002:a05:6512:1154:b0:52c:9942:b008 with SMTP id 2adb3069b0e04-52ce18325femr14285825e87.2.1719558274074; Fri, 28 Jun 2024 00:04:34 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af5a3b0sm21459575e9.13.2024.06.28.00.04.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:04:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 20/98] hw/sd/sdcard: Convert SEND_CSD/SEND_CID to generic_read_byte (CMD9 & 10) Date: Fri, 28 Jun 2024 09:00:56 +0200 Message-ID: <20240628070216.92609-21-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::130; envelope-from=philmd@linaro.org; helo=mail-lf1-x130.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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- 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 = sd_sendingdata_state; - memcpy(sd->data, sd->csd, 16); - sd->data_start = sd_req_get_address(sd, req); - sd->data_offset = 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), + sd->csd, 16); 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 = sd_sendingdata_state; - memcpy(sd->data, sd->cid, 16); - sd->data_start = sd_req_get_address(sd, req); - sd->data_offset = 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), + sd->cid, 16); 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 = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 16) - sd->state = sd_transfer_state; + case 10: /* CMD10: SEND_CID */ + sd_generic_read_byte(sd, &ret); break; case 13: /* ACMD13: SD_STATUS */ From patchwork Fri Jun 28 07:00:57 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: 808177 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223083wrr; Fri, 28 Jun 2024 00:07:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUDuERcctBvUwhJBjLI4IKmrrPr/b2l/rpt+exs9LZc268CjXqNKq1f3aycoQkArBOCK6zB6Dt19JZDWoRoHbhQ X-Google-Smtp-Source: AGHT+IFiBmno5pl3Hn3cVOeHfDTOgTxzR25mrSYHELMpdJMb2UG7ugQpX3ejDAZhqVNDTvGAQ9tf X-Received: by 2002:ac8:598d:0:b0:446:568a:f9a2 with SMTP id d75a77b69052e-446568afb07mr5640201cf.5.1719558475002; Fri, 28 Jun 2024 00:07:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558474; cv=none; d=google.com; s=arc-20160816; b=IuaJ3JoV+7hQGrtq9v0aV1oGDrmoHm2JvDkVMMRjk/OgXYljmphtaFsRuqLdbJ36mE JP37nmhEEXiMBf9EY0jaciiokhikG0xS0ShZVRpf0aPUiKxj3Tu/nK6ME0m3JL4BdUm3 QSnLYisllt6tt7r40E/3WF83CG3PNHnu0Hq5BOnwyXqwvWljQzmZuQ9Zq26zWDoC8tC+ t4E9v/fcgMg1u+Naf3KHGmJj85xh/NyedFMFtKyzMRQjbaOxdzjtgk3rShN9hrL6CKKV ddtuHYpjYJAIlGx09CoumNJdz8kzmrUIHNLaFHFWTSRLd8mSe0co8YCp00wz3Q3eph6j ezBg== 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:to:from :dkim-signature; bh=Nu8acyjpOBs616osR1RalX8TR2/NJv3m9AnCQgylDWw=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=H5KA/VZTLUpjk6vYk+hrlSX4QtZx0/YqzuCKZ98mgyBZEQlvgB73vCuj5b7wXbyy4+ 8JEBdn8NX32LsYS4ipAYVwOV+EXfx6sZpQfWRNKWETnYybs299tubZgJe3zG5/EGXfV2 GJR/uPrh57CJTzB8lsyhDsV3A3lbqbIZPwPMq0YPHt4Y0Unoz3maBd/YiFuRts02X/rV rmF0qoyhr/PKoh4HQwtkkJzRNg2A2VtYzyBAyD0Nxy0C1U9rpJFkAFrzP4I3RW5riEdP wNYHZxP+dAvcobbdFgmlTz4fgtgLuX63EfulF3LXsXsXJhXWOPtnmBeB0ENPOYcLqV/L y8dQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HrSXvBRp; 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-446514a20d0si13278141cf.400.2024.06.28.00.07.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:07:54 -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=HrSXvBRp; 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 1sN5fD-0004MZ-8t; Fri, 28 Jun 2024 03:04:55 -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 1sN5f0-0003xF-VX for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:45 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5ez-0007Wb-A6 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:42 -0400 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2eaea28868dso3202961fa.3 for ; Fri, 28 Jun 2024 00:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558279; x=1720163079; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Nu8acyjpOBs616osR1RalX8TR2/NJv3m9AnCQgylDWw=; b=HrSXvBRpueaEImtmpIHPFXJBV+LE2gVunaOQcGkdo1qCzPCsMEnrC0eNLXC8P+O7cn NTVPe+02vYa35fah4jhXFRy4Yl4XrtAcCpswNlNfn44r99LEWdlT+cGHphOdE+f1vn8O hB+FRWQMaR1XHlPkdZ7RgWarxqXcxO+MX/M6a1IGsh/nw5FrruAmsJ9bthrQ9m5e7BEg Blr7qcd4zCI+br0L8T+iz2lPYcesuOjqAxYkEsHbrGxRAw9uXU9EUkb0tSo9VBIuaYD/ crM3WGHox4GLt8HOhEZngKcv8wi3a4guoOz+pcmmQqUw0Bt2egkPyV4J51AEVZqBLJrD jugw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558279; x=1720163079; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nu8acyjpOBs616osR1RalX8TR2/NJv3m9AnCQgylDWw=; b=rT6fXRkluEpEuc7NxEsLhPyD3NpIxrrVo5QdALV7u0JGyEOvMPnLZwf++CwHSmWqLf shVg+0zn87fztPeoYt6DBRP8/Twwd/uQjCpYMbgnolgGOWhJVLLBp+fNAQO10ZxD96QO CmiFplQ2hsfpWeW4wJ9ATZXVGX7N/Or0m7vsi+vjbdD4nUi5EEIGCSjaamNRBXk5RNja aiq+SHSbjY6WyWzMLh2W5m3LtLVURryMdiTap0PKpyAx3tcn/r1zzUQvavztPlTkGHrG wijzXDrji5Nwo6XwdWL/TUt8qTkX7uMNammk6FPYBjXZSg5URY52bO9FSHr/3xoarhgu HPEQ== X-Gm-Message-State: AOJu0Yzvuev8xEvmXMBpCEAZB5pjdSs7Ba8G3ewm01febaAshoWMSpmJ 016PX7AHymcYYfDUPphRFxvvln+5YZOYF33NA9fInji8knG94RGDZTFELWRRw5izDGTiINOi3PH cRHk= X-Received: by 2002:a2e:7c07:0:b0:2ec:4f0c:36f9 with SMTP id 38308e7fff4ca-2ec5b31d140mr128811921fa.36.1719558279382; Fri, 28 Jun 2024 00:04:39 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3b8c0sm21387495e9.2.2024.06.28.00.04.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:04:38 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 21/98] hw/sd/sdcard: Duplicate READ_SINGLE_BLOCK / READ_MULTIPLE_BLOCK cases Date: Fri, 28 Jun 2024 09:00:57 +0200 Message-ID: <20240628070216.92609-22-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=philmd@linaro.org; helo=mail-lj1-x236.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 In order to modify the READ_SINGLE_BLOCK case in the next commit, duplicate it first. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- 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; case 17: /* CMD17: READ_SINGLE_BLOCK */ + addr = sd_req_get_address(sd, req); + switch (sd->state) { + case sd_transfer_state: + + if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_len)) { + return sd_r1; + } + + sd->state = sd_sendingdata_state; + sd->data_start = addr; + sd->data_offset = 0; + return sd_r1; + + default: + break; + } + break; + case 18: /* CMD18: READ_MULTIPLE_BLOCK */ addr = sd_req_get_address(sd, req); switch (sd->state) { From patchwork Fri Jun 28 07:00:58 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: 808225 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225856wrr; Fri, 28 Jun 2024 00:17:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVYMfCK7Y3nQSfQWarYyDEOZ0XFiNJ7YdV7t++iMVMumT3qzV0+tBDvPzAIftDmxpaEnqkIQL2wAYso6PHpOp/8 X-Google-Smtp-Source: AGHT+IE97ONiqE8F3XCLVjoses5lVeUxteBYUTzjTswpIUtdsR/wnnVn4YCFB5oAK0LG6SLLPCnN X-Received: by 2002:ac8:57d5:0:b0:441:1617:9841 with SMTP id d75a77b69052e-444d399ad1dmr203461431cf.33.1719559028334; Fri, 28 Jun 2024 00:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559028; cv=none; d=google.com; s=arc-20160816; b=sDQ6XKU21p0D0ehYmebALuoHNFZVB0kwOPsbKH5rcPLFfMIm7I3Q/OR3O1Un0J45SU pArH0j152yOkJjuHknpvf7HYsjFWL6MtEt5Rx2qxJEH2kMDOGhft0nuaEAzAGZJYbDMe uA904Qg+thIZRzIJMNTjIde6jKHFi7n9k1g0Fhd7h4EEBOO+0CEC5/mFgEfPa+FgWvEG up07j8e4dv/h3phWFBKaiQyb0v2yoFQavgQpF9YMgUPhDylM2QNyDTcub4eUi7DVb+cC CUDmhP8FFAkh7j1FIBqGsUaC5kq2WZo94I3pMIeFs8Ov7XgqlJVus6w1qFsiSvTkzeAI 3Ubg== 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:to:from :dkim-signature; bh=/+wPveokxEozPxxjAOxGefSnu5ni7iF2jFqdZAnOYY0=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=jUce+tf0YXVgEks5nw3tnhpnvV2+YPIlUsOUrzS9W5eG/0MEPDU/M/jKBOU7OwweO6 MzijnLILRWCb47nQeaLbcExo112wH6IhO0yOE41ljumyTqlP1R1l2l5wLAkCSM88n7sc nA18wXjyM3snXRC/hldrP2bJF894G9i7PkmQZLVHjRDNtQoXH6CMrW18qL7CieGOD4Np xHkmzVSx3haOzr6OQz3KdUgB/CGvfc9dYD5hr8/mdIkniM9goemPVyaDlRfCdv3C1ra8 ya+OnNAyWT/33qTFMiXQROPGShrUysuEgTU2KrmZUb+D4nd8NWx/1YXqFactJQkSm0PK FQ2A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jT9BuGRP; 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-446514a02a8si13223901cf.407.2024.06.28.00.17.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:17:08 -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=jT9BuGRP; 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 1sN5fX-0004r0-FW; Fri, 28 Jun 2024 03:05: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 1sN5f6-000464-UL for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:51 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5f4-0007o0-Rq for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:48 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-356c4e926a3so183213f8f.1 for ; Fri, 28 Jun 2024 00:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558284; x=1720163084; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/+wPveokxEozPxxjAOxGefSnu5ni7iF2jFqdZAnOYY0=; b=jT9BuGRP9Pze08TyYB6ORGYUa8sIfX8QLhdn0JYaDHHf/bCmwlu5WXkJk5AniovYkY flCL7g5Wd5XjERMwJfTFTHbIexUVG8iuUUOeownAXEmVjFsUzM7VtLnEzx7QqlcXlHIV uezVWmCy7zxVcth3svm12i7kxZETlZJhZ4GX6+N+VLyIq9D9e2eP5Z02SQ0G+D5ZP84Q VN8fv7N0xZxjNkhBfzWuJsfQOcUARt+aFSPv0PBjjAE2k8JLjLdLZVSm2+x6kPlviSzP dHnF9w6eh534gNO9W5yARK8ac3ODJPEnEdlqmWomYkD5qnDcHy+J0O20YXoPWaMUURSu fJng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558284; x=1720163084; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/+wPveokxEozPxxjAOxGefSnu5ni7iF2jFqdZAnOYY0=; b=SMGyozakxVxDLM2x/Dahwp//LL9ZeM1wxDOX1jgMPwaD+yeIzqFP3yMjN5m52dj04T JtIP/1W8lcVOFYwL4kUpbr5+rtlVniVzvAHcM5FsPP6+4sa4LbUtksZlGYM0gIghxsBy 6oTZuOBIq23cilSv8YnN0U9UAEtk14yvDWa3rnUnsk0rIHXaFDWPeOGn+inP/0t6dWMb ry+sSCgrZ2SYOUOH9fpp4L+Jx3u8WOV9yGPOvWgHCUVxl31E823xWMoIvDDLWDfcRi6E RsW4hKP6CEXpBA2UJcDH2AqskHSr6qVTPa6gF0QMZsUqB0zh2DhCGR5x5QemChlCFGDX w6fQ== X-Gm-Message-State: AOJu0Yw6lqnrkhym1yP/NVvCdqeNn/vuQ4VNq21QAuPJCulnp+4TfaxD h+ZcxJVsqCBb8rTzzc3MftoEG/ZMBGYMS41hAWf5ZOrxzEd3RL8sLdDesAt9Z1bYN/k60DxI3ij g7Og= X-Received: by 2002:adf:ce0c:0:b0:361:d3ec:1031 with SMTP id ffacd0b85a97d-366e94d152emr9964234f8f.31.1719558284590; Fri, 28 Jun 2024 00:04:44 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd623sm1334871f8f.16.2024.06.28.00.04.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:04:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 22/98] hw/sd/sdcard: Convert READ_SINGLE_BLOCK to generic_read_byte (CMD17) Date: Fri, 28 Jun 2024 09:00:58 +0200 Message-ID: <20240628070216.92609-23-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- 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_len)) { return sd_r1; } - - sd->state = sd_sendingdata_state; - sd->data_start = addr; - sd->data_offset = 0; - return sd_r1; + sd_blk_read(sd, addr, sd->blk_len); + return sd_cmd_to_sendingdata(sd, req, addr, NULL, sd->blk_len); 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; @@ -2154,16 +2152,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state = sd_transfer_state; break; - case 17: /* CMD17: READ_SINGLE_BLOCK */ - if (sd->data_offset == 0) { - sd_blk_read(sd, sd->data_start, io_len); - } - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= io_len) - sd->state = sd_transfer_state; - break; - case 18: /* CMD18: READ_MULTIPLE_BLOCK */ if (sd->data_offset == 0) { if (!address_in_range(sd, "READ_MULTIPLE_BLOCK", From patchwork Fri Jun 28 07:00:59 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: 808161 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222461wrr; Fri, 28 Jun 2024 00:06:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW7uUeaQ7YcSN/er9A/VSxxFfqc4xet5G6WCwfnkXdP51085H8Ha6BMHdQFKXRo/lgZ5m5eek3BnkfC9FXkmzpD X-Google-Smtp-Source: AGHT+IFqu6VZLABN2PboR+klfhlF60VLFO4NNV6psqIYwvruks6o5Madv1r1jhk7QJo+AnOE7VxC X-Received: by 2002:a05:620a:70db:b0:79d:70c7:6992 with SMTP id af79cd13be357-79d70c76e61mr23928185a.47.1719558365326; Fri, 28 Jun 2024 00:06:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558365; cv=none; d=google.com; s=arc-20160816; b=M3S0N4JMXJ3pVU2CHahXpo8YwKQYRG0wbLgCTCRLReD8e61TziAs0KmsVNoEE1QM9K /MkmGp8zbiUoI2pMFix8kqAsZgwNn43P/BRGtdCA2LdbETk8r0fboOTYrTrM/ccAuXdi PJofmOD1b1GKZlwp2gcFZhjQbO0OhdlIBBxK05DkiyblzSTP7L/9en6C8Jb0/flQuL1b NTIWiyPW0wJor8IP6SFnktvo5yUkHaQwFx9ICvGmWMi5eUx4gzx5z+sqHWh/PsI05KSW cNyixUQl5IAZmy9yh0vfk22sTCveTRWFb6ZrhW6W5LSGAyXnJufDhD9xLDRLk36X4cUL 4IzA== 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:to:from :dkim-signature; bh=tJt3SUxGAHgfMAGlqAtpQu/ZRYvhhIYidzvQ2esYug0=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=YXTkHKmK2g5jf0zvqhD6LggOIxfzbgxDBlrPPZJkovgyjf7C/0YrEYScmXhrvp0g+e QSqEauEG4dEshIZIHTXdq2BOFOrUcs1LvKTVe84mih5JqobfuGceYcwMofQCMjXI8WRo Vmfz8iUhO7iEbgavtVyAHeP+OfPyPsmLYED2zs02t3esNb2r6R5RFhNC+dnYzcI4juA1 EgWD3/pDwxj92OI1Q6QoxdtX6SJtMYhD2puLVCSSxtksLSpPzrKpUNZOEnVyw/z6NXI4 X/WgX21wMhBptQ1qOG5aGuGFILXX9xMWP/SkrbAJG/d0Ry3Klif47D67NXlJvVzBrLNU 5p4Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rzKX9oza; 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-446514d6396si12994531cf.670.2024.06.28.00.06.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:06:05 -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=rzKX9oza; 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 1sN5fR-0004Wa-9d; Fri, 28 Jun 2024 03:05:13 -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 1sN5fB-0004BD-J6 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:53 -0400 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5f9-0008Ab-NC for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:53 -0400 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2ec5fad1984so3505941fa.0 for ; Fri, 28 Jun 2024 00:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558290; x=1720163090; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=tJt3SUxGAHgfMAGlqAtpQu/ZRYvhhIYidzvQ2esYug0=; b=rzKX9ozaCM2NqD9Rn1NPODQq519fzx3uZmVeQ+heO0cFeztr8zKpaoKnyhf5tQ5OBo peWvGp7cIeyXFVBJ1cD0WXrK6818h/DPmQDWkiAdHcH/W6+9ft0JXvfaLOuoZSZGOOF7 wfzxa72xeFvPigGAleOssbGvf+jCtg+s353IwQBO1kLxLjRQ+qhYG8IkL2aWPNDABwTW f/S1vF1bazYIxv70BwnbfHEiH7MvN1TDbTtzKNVTfC2llr/vB2KN2wi3GpExkT2G280Y fCHPHqzPLZ6fm4XGZFsbb5bh1gfoFFg8EeyVer4jP4gTN/7+jYeX2sNErV4brXsl0IWb T6mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558290; x=1720163090; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tJt3SUxGAHgfMAGlqAtpQu/ZRYvhhIYidzvQ2esYug0=; b=Qnin1uyajq8X/QnDa2yk2+nwHvVTyGfQHWpJOc6OVK1moxUcQghtcnUf4/oiBNyRiF Z4jANCsjFOUPMS/UzHXkUhFbG3fB81L9/J002dcBjQRn3SQu+rycT+sP48ZUjkMCJkep Q3mOt4wCh/OmVboulLkCZnfDyPadz41vcNB2Ki4YKQA1SsA606NwHqYPOJT0KTPAETGs Vdo4UvncPQ9hjPouVhfdKH6LKlfcmJ92riNcu6YJGUby1bDyHs2J2TygmEMH+FkmdJyj T6hCChGGfOhW5u9+uHlObD8PJPYGmox07s4lJb40pNO8nyl8YXE5EDhQSIdo1opruYjO NQOg== X-Gm-Message-State: AOJu0Yyr/et330P+GsEAJ2FOq3WrUh7oJo+Tw1V2rrt77ecXJSHubr8f nq5WflzRp8zIS7pRx9dQLXpBH7ppBvnjmkCJqFtc1oWTLiD3xW0u1ZF3h2UGIiQ4wLAg+dSH/nx hzJs= X-Received: by 2002:a2e:7c07:0:b0:2ec:4e99:92 with SMTP id 38308e7fff4ca-2ec5b31d156mr120127401fa.29.1719558289688; Fri, 28 Jun 2024 00:04:49 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c0f99sm21193455e9.41.2024.06.28.00.04.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:04:49 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 23/98] hw/sd/sdcard: Convert SEND_TUNING_BLOCK to generic_read_byte (CMD19) Date: Fri, 28 Jun 2024 09:00:59 +0200 Message-ID: <20240628070216.92609-24-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22b; envelope-from=philmd@linaro.org; helo=mail-lj1-x22b.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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- 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); } +static const uint8_t sd_tuning_block_pattern4[64] = { + /* + * 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(SDState *sd, SDRequest req) return sd_cmd_illegal(sd, req); } - if (sd->state != sd_transfer_state) { - return sd_invalid_state_for_cmd(sd, req); - } - - sd->state = sd_sendingdata_state; - sd->data_offset = 0; - - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, + sd_tuning_block_pattern4, + sizeof(sd_tuning_block_pattern4)); } /* CMD23 */ @@ -2100,20 +2110,6 @@ void sd_write_byte(SDState *sd, uint8_t value) } } -#define SD_TUNING_BLOCK_SIZE 64 - -static const uint8_t sd_tuning_block_pattern[SD_TUNING_BLOCK_SIZE] = { - /* 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; @@ -2176,13 +2173,6 @@ uint8_t sd_read_byte(SDState *sd) } break; - case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ - if (sd->data_offset >= SD_TUNING_BLOCK_SIZE - 1) { - sd->state = sd_transfer_state; - } - ret = sd_tuning_block_pattern[sd->data_offset++]; - break; - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ ret = sd->data[sd->data_offset ++]; From patchwork Fri Jun 28 07:01:00 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: 808175 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223038wrr; Fri, 28 Jun 2024 00:07:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUIkJLIAS77pp1Qu1Ly363hPqXugEk3IxywqMpZv4CuqCTm6bCWL3tsMrRDQZ2Wzi5uJHboOJOk6NvE5WGQxyUO X-Google-Smtp-Source: AGHT+IG8KcCL0FpT8Xe/VJTdSToMmrVWcSGsEPR2oMPKg+5JoP4lL+woGzsWiWHXT3A3jUfQr0Jv X-Received: by 2002:a0c:f741:0:b0:6b5:3eb:6cf6 with SMTP id 6a1803df08f44-6b53bff425fmr164658836d6.40.1719558464512; Fri, 28 Jun 2024 00:07:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558464; cv=none; d=google.com; s=arc-20160816; b=HmQaYyMPE0MEOeNjmEmW30NKEhsz8wk+T89h/yzTC1jXPWcXTN9EmCEdJURkRMarDc RJoWs3MHuWst4oguvtifKJ5Uuld3JwpPxo0OwLK8vJzDGnm08ydRYgs7FCysBH99KqC3 6yYFwr7SBzM2fIWtRHLLHOV6hToWPijtbyaGICuG+aCQKZXm483TLuohK5mpXWhpm3oj hJat7ph47eBMr8VDOu6k4kNiSiIJba9ArHBzrOmkLhuVVGPMm1aACJcBdLg0Ldox5GSg qB1PD532yIQFJ7JArWrqiN6VE0TlOPiLjI6yGDp8EwwGbpk/MJqVUmSAHzmLewRoYN1g HnBw== 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:to:from :dkim-signature; bh=cXnvSPEQ0479Kw/NHZLng3szLmllyhp62LGUqGmd/0w=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=m6pdhphEGDVSg5AEvvm4lnpZNtvaQgM1a/9mKojLSY9fR4hOtIilMaKrdN7Fhm9TZ/ kdAPzrvTG6/IH4Z5cG6lAS31soBQDyXvnua5T+r+5GDUqDmPjEOolzufFmqUHlnWWeiV YfeCvdukud0jpGF2UHfPtKb3y2/111IQAkVKt18eYsTbTQTT+h8DNnCM6NnSjhZGExkR i6OeWcsXsdo42Otd9gTzOYTfn9PXvl6LqwijsMwo6g0OycMqVX56YXI4fzNKNeFtU3pq w3DCbgYWJWveCuxmDAdhEra8BsfOE7lBvQXSBkE9cM8J+zTKRtZDr9YW5y52f1pkDzjG X7Zw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KESPM39m; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e61a68esi13457656d6.592.2024.06.28.00.07.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:07:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KESPM39m; 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 1sN5fa-0005LT-U1; Fri, 28 Jun 2024 03:05:19 -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 1sN5fK-0004dI-0K for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:05 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5fE-0008W9-GH for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:00 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-367339bd00aso229112f8f.3 for ; Fri, 28 Jun 2024 00:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558295; x=1720163095; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cXnvSPEQ0479Kw/NHZLng3szLmllyhp62LGUqGmd/0w=; b=KESPM39ma/WMVuuwvO4sUfIZuFRc1bDRa65DFOPJVlSF9oeeNPx4mB8FfhuKS3Fu0L BoJR+RUPT0GIHC1rbZ1mh2UbYVy5CDRrwLfw0ndiidEQX8yeU6KNhAb6F1/E18GdHrxg v8ofHYbB/tr4Kc1VNYFY4wQN/+Mdvo9ZonRHv50SIRY5qGtvj195GzGvjJ1ggVnFqhp1 hR2/BJHigQdee5UJWSpleFoG8fm3JoNOX6sn6s4szK0ObWTSn2M5QnDZKvQnHBZxxHvZ AHUb52btzVjMjgISNX+0Lf3PnzoQxsCn2AQbb3degHMZnkjTZpWlti5Oc+Jf6wqTrPCV 4RFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558295; x=1720163095; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cXnvSPEQ0479Kw/NHZLng3szLmllyhp62LGUqGmd/0w=; b=hJzMRkJUyEinSSFWv5UuydeuUugpFaUhHM+wPmSVpend3gsWOmg4KpAg/ehkZrPKBp h2Oeu79nzmPbSqn9n3px6gNTks6ifYEuBWcd1sxreNi02R3sXcQqmrDQl3BgQEU0XKrL pRAg88hoh7lTwwFGjUBNQI76g7hQda+HULQAzzJ4ltnzAJphggqvw1RprxPDsBmWDj8r ANohuWoh72/NS83z2/PE7r4cI7cnSr+tub9h9orkDfcfA4Xx5JbsAcggAtNkXw+nm+O6 0Vt5sjlL2r25cKgF9XS4EeYADMokV6RFhURqdG/5KiuqptcEI+7fs8qUcuYcLJN/PWGR 9rVw== X-Gm-Message-State: AOJu0Yy9kxHe6q0cjWV6KYoXoZHJOFH6qZ5A/YwCVsVSNg7+4sI22dxl +LuD1eTc8uumo1f1cLzogjt1I7NwhVlFPNqzbhse6SIqAhRwAGSONsEtBE9PrD+8S4n5l75r0fw S7ek= X-Received: by 2002:a05:6000:156a:b0:367:434f:ca9a with SMTP id ffacd0b85a97d-367434fcca3mr3584916f8f.0.1719558294741; Fri, 28 Jun 2024 00:04:54 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a1069cfsm1316272f8f.91.2024.06.28.00.04.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:04:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 24/98] hw/sd/sdcard: Convert SEND_WRITE_PROT to generic_read_byte (CMD30) Date: Fri, 28 Jun 2024 09:01:00 +0200 Message-ID: <20240628070216.92609-25-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- 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, SDRequest req) { uint16_t rca; uint64_t addr; + uint32_t data; sd->last_cmd_name = 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 = sd_sendingdata_state; - stl_be_p(sd->data, sd_wpbits(sd, req.arg)); - sd->data_start = addr; - sd->data_offset = 0; - return sd_r1; + data = sd_wpbits(sd, req.arg); + return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data)); 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; @@ -2180,13 +2178,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state = sd_transfer_state; break; - case 30: /* CMD30: SEND_WRITE_PROT */ - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 4) - sd->state = sd_transfer_state; - break; - case 51: /* ACMD51: SEND_SCR */ ret = sd->scr[sd->data_offset ++]; From patchwork Fri Jun 28 07:01:01 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: 808164 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222598wrr; Fri, 28 Jun 2024 00:06:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWYSJRbNY3Xc1QjpuXdppSfVuV8P0Vlfy2whkpGXYx50CCUHIGrjkysF8uyWCj5/YggPDkuTdlIgP+MVLswyXkQ X-Google-Smtp-Source: AGHT+IGXBzZheXq6JUdU+LxFl3iizCLrwROB0bk0nim81Ps7JznWOyq5DsWulDuDQgulB4jdeO9p X-Received: by 2002:a05:622a:1b8d:b0:440:761e:3bc9 with SMTP id d75a77b69052e-444d654d8c4mr215604331cf.63.1719558391593; Fri, 28 Jun 2024 00:06:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558391; cv=none; d=google.com; s=arc-20160816; b=v0/iGhMCHkwVKBABbtaBbX3jyqb1PpO9XvzPLGmSRZFI4nxlL46vAME/MTbIgh1RTW IciVE4ywZCHiKkBzHfQCZlBG8g2diRi/IiyBduqbcrpUvgoVEAmuKbiG+Skswz025StY eXPSRYj5xKPOsU23m31kbq2Szl4lFwVJ8gaJcpDUpfNBUgSe8M/qyPJO0rdDuJSunCim A/tJJj8Hfi8hun8SA+GY/NbZQALzLH/UvtHXGPkF+SsAw8IY5iBvNcw1rMoE5F6/RCXq yYsxCRTyOQFWwvgFbXYCRn/hXypcGDJJgaTVTcgiSBCu1FH7uoQ7vm9Gy9RPCmR3nc0B ZRBw== 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:to:from :dkim-signature; bh=IlTxhpvzZWvkbW0VpI4omM+WCLHLk77/0zlyk24X1aE=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=k0ptSkdT5vkLYhfNxyDe2hiIQ6a43sU21Nw/asc3W4j0Rp1/mOmzYHIIIheFZhTR26 5+xU8W+8CVYrFiihapaNJDIUPQGwhLCUaEkRg+P5+c5EzxOGdQ0JXmIaRhgsXbhxk+xJ N+zQg1qmtrmkFLrMacXgJo8sE7LbGpd9Rgc9UrKgfQX0TbSBR+ZV9cVCxdO3U230sTyx r0lLj6Q/j2ZQIGWFcWivLPOsnJtBSouhoEx3prYpcvT6d+T1tAUxPi3evHWZIBOL2sG1 MMpkcgkQESPU/IaLiEHC3ppUMyORQw3senPvEOwUNfd4trp6ZAITyNvchwBTKqprwexb Fkng==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=thWkcIzM; 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-44651485bf2si12891131cf.355.2024.06.28.00.06.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:06:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=thWkcIzM; 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 1sN5fa-0005DY-2Y; Fri, 28 Jun 2024 03:05:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5fM-0004eB-5Z for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:06 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5fK-0000I9-7i for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:03 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3636c572257so239853f8f.0 for ; Fri, 28 Jun 2024 00:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558300; x=1720163100; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=IlTxhpvzZWvkbW0VpI4omM+WCLHLk77/0zlyk24X1aE=; b=thWkcIzMoz96tW9QOly6jjBETWrN2poA5vCM+vMOj/481Doirk+yVIMRXXRlHpVf69 YP0ANHChMiT/qCBfY88yuroVoK7YOiNgenNOrg1s6AF2+IyBR+O9jCbfk/3zwZy4P2v4 CfY4QSrJpPKg0g/L6Jvig3InkYXVFPp0PnG6wFu8hb/Z4w1rjlHQaGzAQEVvS03RvDHW aHtB4qIkPHyPsqbnaDbugjkK/To+kaJFdqh4Heia53f7qaTdkl2hh7A1lpwxe9AP8yNx RDptmSVebVbE6amAZb52g4FPKcgTvuTQhLy7l2rqwJo6AbOQPWL+CrgRWw5CHa3Balk/ 20/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558300; x=1720163100; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IlTxhpvzZWvkbW0VpI4omM+WCLHLk77/0zlyk24X1aE=; b=DkBybdT89Z3MxEDgdGinXtrlaPLxyEvBUtQHQqZoy5/ysy7DoW2Bx3J21B2YpmhFmL RWvn2+nzO8K5tczjLq6Ffe/XZyNQMwgrAmLtiIDO67xlrZFcnt+qE0/qKCSct9umz/KQ Y0r3y8hfPXTBdsPrrR/kRPR/asIKmwSrsojhMy9HOFSoei01qIpsnwU2pl1YNC6H0ulT pBT4M/M5jLxp6FBACbmm+01V0/A/ljApTycFX+T4EcXUltnZlYx5703Xvz6tnkiyp0yG uJ7FOXHzm/J9DscLej09OG06s0TqsRHYUjewWE2iXuxyKkGAPb0OPvLAheUqfn2ph3S+ ZjBA== X-Gm-Message-State: AOJu0YzH88nRpYqGn12n0/AB2TehVJqUPi5P1S0kukqbj8xeaBSJMTKf hkJJy8jGNxWt9KEyQVR3s2KZJKCSWIwjB+JYDnwzyyVn7rwLUk2OSdCzl0Fo+WHjR1nGtuDKj5h UWfA= X-Received: by 2002:a5d:628b:0:b0:35f:16c9:a5bd with SMTP id ffacd0b85a97d-366e949a664mr12647407f8f.23.1719558300072; Fri, 28 Jun 2024 00:05:00 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0d9ca8sm1333096f8f.43.2024.06.28.00.04.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:04:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 25/98] hw/sd/sdcard: Convert GEN_CMD to generic_read_byte (CMD56) Date: Fri, 28 Jun 2024 09:01:01 +0200 Message-ID: <20240628070216.92609-26-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- 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 = 0; - if (req.arg & 1) - sd->state = sd_sendingdata_state; - else - sd->state = sd_receivingdata_state; + if (req.arg & 1) { + return sd_cmd_to_sendingdata(sd, req, 0, + sd->vendor_data, + sizeof(sd->vendor_data)); + } + sd->state = sd_receivingdata_state; return sd_r1; 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; @@ -2185,14 +2188,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state = sd_transfer_state; break; - case 56: /* CMD56: GEN_CMD */ - ret = sd->vendor_data[sd->data_offset ++]; - - if (sd->data_offset >= sizeof(sd->vendor_data)) { - sd->state = sd_transfer_state; - } - break; - default: qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__); return 0x00; From patchwork Fri Jun 28 07:01:02 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: 808204 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224560wrr; Fri, 28 Jun 2024 00:12:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU6WOtTMM+5pTKdEszimSb8zvBWMJBFZY9KbUSBwceMY9UW44khnUxRsCWe7iAwk2J11LSh84zWJLVKJoe/QHpW X-Google-Smtp-Source: AGHT+IFBaaL0xpcJsg5w57EEt/VD8c8FAtTJjsu4pBOY7dO2oIUN9v5mUaQJfL6rHFnmYqk++P07 X-Received: by 2002:ac8:5d8e:0:b0:444:f5f1:af3e with SMTP id d75a77b69052e-444f5f1b5abmr152039171cf.32.1719558757948; Fri, 28 Jun 2024 00:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558757; cv=none; d=google.com; s=arc-20160816; b=ErxTbAR/7TF/v5EMW5ooDh/UfU8gRjHGu8Xo1mlzm0cf4UsTuTxf+6Tl84hQ2RGBX+ FH0kyCEQAjkz/ZH5gNrerro/Myl1QFLUya8i95IyzXXQc/NPzAFW4KDcWSdMmE1L+4vN e/4Bii52D96EAI0uUWnviqnDytPKMxqZH8wtxSZERfUF7VmHDoC0sImPhsq4FfUYIJg0 qKc4slc9RtTpbzzzEhYMVXVAgoVHF8ZysBypA9M8mL5SvLXO3M14Adbg0mhM+odDUm+N kcGE7VuM6Lf6197srBQ3nnwaRzMgjd0lziX4juwzon6R63NcBDsVtdJZCFqtIAj1YqT9 qSPQ== 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:to:from :dkim-signature; bh=vHrlK0ssSPoiMv6JdxaV3fer0W42cR0Lk/0TJKW1fyM=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=ktXlvsGxcrqWtA+C0Dyn5/2l18uvRlO85SwLJO8AgZx021GUMvCLeMnyMcahuTAbgv DOjhKt+35uva8P/m7shGWrddCEhcoz1vfBulPLT79dEPNWotlZ6L1CNCCRHptrjB84BM AtXogKJIwlBDPvmyKlDAaV7nyH9a7VWfBbwt9BiBVjJnzF5ZAIFEt76swoBBnATWTmst oK6aF6AxGBExCHKGdvFfw2LU7LKHS6+CQTEX145XaDDPMSvYoyESudkuRfEXlm5I/E1t 2NBqBBJ6fPV5QWVaz+h9DeBvaeuIfFHQkRbP653MjB6hD7LqN23sM9GWWXRVRtGEpQc7 W1Xg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v+LyBQ2u; 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-446514c2632si12584781cf.550.2024.06.28.00.12.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:12:37 -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=v+LyBQ2u; 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 1sN5fc-0005Um-Um; Fri, 28 Jun 2024 03:05:21 -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 1sN5fR-0004fv-L7 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:13 -0400 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5fP-0000tL-Hf for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:09 -0400 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2eaa89464a3so2279001fa.3 for ; Fri, 28 Jun 2024 00:05:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558305; x=1720163105; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vHrlK0ssSPoiMv6JdxaV3fer0W42cR0Lk/0TJKW1fyM=; b=v+LyBQ2ujnCM/IWL39NRPfLWAWv24mpi7J0dIQBpHeqgJuXcqthH3XUNvunWaIhuqw yt/eWkJE86qcL6VNRrhyyCkgT/Y3gLmZnAmYq4kNebnmcm9mtqjZ/87v9+J2H/OiYtaX mE14S/essPEif7yKaY7ENoFUPmSN70o57/vQblu472psovJ7OnxQl0NBI8nZODdUlk0O WDKQPQpNr3O4/CZQSDyJkpbSyxjLhNxRJhgu7pMfxLfydc1ewS1MXgwaot0foE+eP4Az LB2hchnt7vVFtEmXCn0618xz0vdamtQgOehWP6vFRYs/QfNZZl8G6UEGNb33ozIOdeqK wusA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558305; x=1720163105; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vHrlK0ssSPoiMv6JdxaV3fer0W42cR0Lk/0TJKW1fyM=; b=LYhkHQc+nz8RVsxnMCZMgqAKBoUTn+TA3rBQuAweqFPkQA3qdrhS5aJyMHjjzI2XMx tDGa2h31jtdhqLzRe7bj6ZhsVMiz4Gh22ChjiQbfwoM5egAaOa5ZIU1pXv/A2ADC2Bnw QVxWf9BVDG7Fh5Af03NxASTiqCmc2fDM0RH71Q4GFfGj+O9NkusvFDxb2LSE+GY0b/kx O4iz+31NyZbtuS30w2nwhvMBnd3/3crxt30N0+xhLluWmpvm23A9zwgi4ID4XDqPCPgI s4OEck2VdRDjQoKIY5tTILDkZ+N5UHQv+QGNZf4WyXFeAeX8mUipCHCtAvbNVYhf7KnY R07g== X-Gm-Message-State: AOJu0YxxuO/wf+rPjYt86tM4QnN7mIRjsc5/n50MMlcJZy5/JqSZzaKV 6Oyv5X3/IwbFWYqsv4S3DgwFN3cMFcrnWGZjsHrE3r6nUTENtNt4vySkKc8zmnh/DWMwQbYOYXT S/Rs= X-Received: by 2002:a2e:3c03:0:b0:2ec:4529:9690 with SMTP id 38308e7fff4ca-2ec57967b72mr91283161fa.3.1719558305105; Fri, 28 Jun 2024 00:05:05 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3b8c0sm21400365e9.2.2024.06.28.00.05.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:05:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 26/98] hw/sd/sdcard: Convert SD_STATUS to generic_read_byte (ACMD13) Date: Fri, 28 Jun 2024 09:01:02 +0200 Message-ID: <20240628070216.92609-27-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=philmd@linaro.org; helo=mail-lj1-x231.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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- 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 = sd_sendingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, + sd->sd_status, + sizeof(sd->sd_status)); 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; - case 13: /* ACMD13: SD_STATUS */ - ret = sd->sd_status[sd->data_offset ++]; - - if (sd->data_offset >= sizeof(sd->sd_status)) - sd->state = sd_transfer_state; - break; - case 18: /* CMD18: READ_MULTIPLE_BLOCK */ if (sd->data_offset == 0) { if (!address_in_range(sd, "READ_MULTIPLE_BLOCK", From patchwork Fri Jun 28 07:01:03 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: 808165 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222716wrr; Fri, 28 Jun 2024 00:06:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXEpWLMU9H8tGvyi3E06FNKN8jnj6RwpWfIQy5Hdx4RvUoTb5xiFrvLyjpDCaRX6IcIZRGh5LEH1ZgCjUHiHZTr X-Google-Smtp-Source: AGHT+IGezIR++C8MRluZ7sAYwmufc9Oubwvd1CYfzMLtLq26Ppj7QCOwjxgZanlCQAc853GgswYK X-Received: by 2002:a05:620a:4248:b0:79b:f567:8672 with SMTP id af79cd13be357-79bf567884bmr1448589485a.3.1719558408890; Fri, 28 Jun 2024 00:06:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558408; cv=none; d=google.com; s=arc-20160816; b=to3CfAAC7Yq2wJ4AS2vmWJgZU5qNrdFGOaKSt/QciF3v822l2L04rX6/GyiJHRdQcF mMhZGlrBzQMnV9RzVSCn+aijx6enr1x+qfdk9THT6wldyBNc3dPmFxTNKjZKmTcXZtuB Ya0tEgcDdbeMCE3c1rb9VJHuIYAZ53ekTMG88zSeMkNoBPMpr5CSXsNtHdHuYqyrsMyz 2O09gTSNEplxhQpbQ1ZHLHCZtKQ+50LzbXPhDXsJUwYIhbAQzYiyQUQ2x1t0v9Yw3r0O t9tllAbNYbZT9lE7HBUV9JK2guISS6ZAfd7fDvxvvhOVDlx7lRXfYkzgKiY6tQTkqeGk 3LuA== 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:to:from :dkim-signature; bh=sU/k2Rks1jINZkUZw0aLSNYbtB22cqllnIk+1At/gmc=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=w7p+xyG+v/olqcX86qMziDrMoXwUwSlGYEUtC9wCvHlilDt14TApgwdA/Xhv9GX4n/ TJimcacEoBdtEByJkBVaUu6kLmVy/Q1jNQAa7tW+J89t7gCIwEJeqWrbJMBy5G93Kaje l6MGQubD5BC0/CFy+k2YsrmcBPnTNtKYxeCzoGQju9fHVHdmwV1cg4EUbUmFV7BWgpYn Baqd0VCgyfvCZITpK4y0NCSHhqNA1bovqlYtQtwVAb4XLAGKp6bvh29RWkHx1Wiaglaf HeGfO9hu8AEIyIR+HHxgmB9HST5JJEY1R4UYGALxLxhag0GlqfZXTvbB6su5tiS+ZdJz kNFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t1pDEPLO; 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-79d69339a84si120193185a.621.2024.06.28.00.06.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:06:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t1pDEPLO; 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 1sN5fg-0005sV-Cb; Fri, 28 Jun 2024 03:05:24 -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 1sN5fV-0004ji-S4 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:14 -0400 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5fU-00015h-5q for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:13 -0400 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-52cdf9f934fso247212e87.1 for ; Fri, 28 Jun 2024 00:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558310; x=1720163110; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=sU/k2Rks1jINZkUZw0aLSNYbtB22cqllnIk+1At/gmc=; b=t1pDEPLO9zAY6dxvMFWvedYvkixfny8a2Eo/5gfixIIwpnv/3+mMlFgAhePQi6JdNg us2jcym73qsNtzTKj6HEyZy6UYjSdBi1Yj/ws6zi7xeaUSKyV5nhKu4mdOAmPbTZQoNQ KGdwHxvB2B9HZKz/W1kGURcoxYBPSFmc4++WdQsR3J+mWFmb6tCZVAFNAG27sQ0+0GtY bxjydW12iurciJZ1r9H8m4Eb1orcIKFkvgzBaSk47fv3cg6YsRfk9HMHl4pLXeWOPlqv 4f6+f6mDf/iYEgAg9mycBgGo1Nd8QShIZ0r3SHcMKyOWV+rhaip8oLEQbTh/EqLcwjPO j5lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558310; x=1720163110; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sU/k2Rks1jINZkUZw0aLSNYbtB22cqllnIk+1At/gmc=; b=F8tnVkRWBm6jIill88FCccWbLwSTYW7UTA6hnXqySu5FBwpD+UnbbJE3SvoAudSVG9 usYW251TCM4oUCeKaT9bYEsaFOqIUkE94+sxfpPmnoJ8YorTL6i/BtR+cxfBpDjSsELX 4TQ507hgvSmsY5cCi4sPEUejtGDpmAEVZBZ2PsAzV7Q8+ar2J3d4Nl8KqluyXVzfPLi1 njHyIjEW6GNFi0+gHp0NpKqC+v+XV9Qv/uyJcTldOg4U0Pm9n1wzpN51rCVSvqPm6Y6s 9q4uop5LOdgtw0miqiT8tIfEjFBn+6EA2NFgqkD2Q87ySD0nTPbUlEhfiTHO71B+rC5o WThg== X-Gm-Message-State: AOJu0YyMG03RPKfua68P8A2upFV8j+k9lxyavXIcL20LvuZAenyVhw26 KuZMa2kE7LYJG/Kciyl9zBWQro9xgyPgG6/gjA7Ysr60NsWFkDAVZbdWsLcjdGqsfKL+9t40Cr3 woIk= X-Received: by 2002:a05:6512:715:b0:52c:b008:3db8 with SMTP id 2adb3069b0e04-52ce064f483mr7976797e87.38.1719558310111; Fri, 28 Jun 2024 00:05:10 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fbbd4sm1327324f8f.84.2024.06.28.00.05.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:05:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 27/98] hw/sd/sdcard: Convert SEND_NUM_WR_BLOCKS to generic_read_byte (ACMD22) Date: Fri, 28 Jun 2024 09:01:03 +0200 Message-ID: <20240628070216.92609-28-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::135; envelope-from=philmd@linaro.org; helo=mail-lf1-x135.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- 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 = sd_sendingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, + &sd->blk_written, + sizeof(sd->blk_written)); 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; - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 4) - sd->state = sd_transfer_state; - break; - case 51: /* ACMD51: SEND_SCR */ ret = sd->scr[sd->data_offset ++]; From patchwork Fri Jun 28 07:01:04 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: 808167 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222786wrr; Fri, 28 Jun 2024 00:07:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU44MDUQNrDZSjszeQbCXaiIP1OlLBophdH7QyA3mCBVFN3QXuK74KZdAvpTJgyhdvAQF/4NnMqYSbv0WOp8Hvr X-Google-Smtp-Source: AGHT+IFQkDYTr9c/DDQjbKbXcxt3ERT9VETQL2mn1S/lh9TLLc2KiiLFG4xxDWOJVkfeAGyHUdZ4 X-Received: by 2002:ac8:5d0c:0:b0:446:4032:e2bb with SMTP id d75a77b69052e-4464032f610mr47188121cf.30.1719558423516; Fri, 28 Jun 2024 00:07:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558423; cv=none; d=google.com; s=arc-20160816; b=bgUP7lvH+UNOlh6ABQJqDU+RWcjY9jIVqPBiLHUYFK+a+Z+lVyRkTN0GT+ucIlzQRg QdzZ/LBTKlDx7oM4WHri3jT9c23n0kcNgOB9JjCLfcLyJqc+NxSuDpd+i2XKO3VDQDN8 Uu59bRzqcWrLf+T/4oVtIaJ3e8Wo7e5ERDcV7NVenHmJRkgda+ya1hTmu8Ln58h2uFEo 5S7E068byvzuqvYv3B5DAMIl4iyGyPS05F2Km4n2E1GZc0QhVs3fpgdN1cNR5gAv4psj djZu2lEWr70YQlZDJgzvK6MjB1al7nsrC8I9XcXap5kAd4ARFHxnvB+NsLEclh2iDfBj BCcA== 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:to:from :dkim-signature; bh=u+jyXabwo5N3Lda8MVmtADSx82chlrXIi1rMmDBEsbc=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=H1sHsEUEL1D6Pp1lnSvmEBQ0SsOdT4g7meRLk3t7eUTYThP92XNsYrQO/VibyzC9EN kUPgi9FVVgC8WExPROL/IHhWsUJtEVUgwYisgD/R/Aea2FJdoAU012HsQFTqXAiGL8uH T1RCLH3yrYP8+ci2z7RLkWMcgInnL/JaKL/+HN7KHvPRncfXQROw/TqqO/TWAgku4xq0 IqzGiQSixqzwcr0AzWieQlHtBFubRWMBTOObGz5hUPh9ZsJC9ggRoBwzAVKB/bWcgEPO f8VUFE5xgw6bkw1LzRjzMtcDbn8UskieLMktn5JHzS6Nhm7FLAX+cY7Yq3EtgBJCnL+T VIqw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="X9zNV/E+"; 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-446514e55bcsi12912321cf.767.2024.06.28.00.07.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:07:03 -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="X9zNV/E+"; 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 1sN5fg-0005pL-1Z; Fri, 28 Jun 2024 03:05:24 -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 1sN5fb-0005Rv-Dh for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:20 -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 1sN5fZ-0001Iw-Fa for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:19 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-424acfff613so3323635e9.0 for ; Fri, 28 Jun 2024 00:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558315; x=1720163115; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=u+jyXabwo5N3Lda8MVmtADSx82chlrXIi1rMmDBEsbc=; b=X9zNV/E+K2ff9RA7RxiqeELnRHPxKWL8Bi79GFWVXVPPHvM7ucV7sRYDmGFWHK6Ww4 hOgEceuy3n7edOwiDhyFmsjxlHkKOa/PNbivPIeR6dq+hdoASVZWYI+zh5t+TW8coRKx APaf+xZEQnpzX3IEFz0SgnkD9daeY7oss6paU8zW7K3CT3m2j8ERkHP7u6VWl4jWb/3k NzE27v8tRiFe+MlohkMmtlhP0/30yynX3H9XBSe0TtzrHm/cH/jNx1/THxpc23pZeaH/ z0dVN8ags60vvT+jX663z2bQppYN3ubYL0RN/hN/ncZuxxDVrggG0C0gnZlygXJsqzIt rlbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558315; x=1720163115; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u+jyXabwo5N3Lda8MVmtADSx82chlrXIi1rMmDBEsbc=; b=dDQANBHTL4APaRR40NPk0TG6uVztIygHm4Lvpc1S6j1DSodenHenXsbCv0ykU7zq9P V8d+seDt37T+eonWFsrHP4tfSzDfYflVzxjYmlAmlWDUjFYr2KJuboYSRU26in5u2K9m CeGrtvbjH9iOjB+4CZbNU2Z1LjA3C/rgukEX6nfClb0COdd3GMUp9zzNb8xDkfF/XkPA UcFkpyylBzPlGKK7/rJOkI0prABMvVgMSzRFoeQaq7GuhcJ1OSOaOI7d7Rs+9rKZjU3A ZfYWaqzAOh38Ng3TLOHuX/6tnmR/oJ9AirVkyqrqbML5JP/ZVNpZKG5s6Pz3botSQKuX n9PA== X-Gm-Message-State: AOJu0YxCpsh5WKWyq79/wbIg1ZwTJVCvCdeuVB0MeuooAO2Q+3T1iWJX Pnvpxh1J3FiU4V0lZZoplNqvhmZtgNMe8dhI4RaE+8vvJ6r5A1Lve++p2GtLsvoudOCO4wusVm1 mfcc= X-Received: by 2002:a05:600c:4306:b0:424:aa86:cc2a with SMTP id 5b1f17b1804b1-424aa86cc80mr73450845e9.20.1719558315336; Fri, 28 Jun 2024 00:05:15 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0e146bsm1326610f8f.57.2024.06.28.00.05.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:05:14 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 28/98] hw/sd/sdcard: Convert SEND_SCR to generic_read_byte (ACMD51) Date: Fri, 28 Jun 2024 09:01:04 +0200 Message-ID: <20240628070216.92609-29-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- 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 = sd_sendingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, sd->scr, sizeof(sd->scr)); 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; - case 51: /* ACMD51: SEND_SCR */ - ret = sd->scr[sd->data_offset ++]; - - if (sd->data_offset >= sizeof(sd->scr)) - sd->state = sd_transfer_state; - break; - default: qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__); return 0x00; From patchwork Fri Jun 28 07:01:05 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: 808184 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223630wrr; Fri, 28 Jun 2024 00:09:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVC0wx2O5tlnynz14g5i/DA3rV0i9hIejJaUxMWX4T4aqIaCHn1oLpttbTbwuaRo9Bg5A9e+RJadozg0BYuhHvb X-Google-Smtp-Source: AGHT+IGEpbE2iGVrnAnr7Uy7CVpPJy/pUUvV8C+b5T7/ybwLL0pIME5TBNgmvupR5VOzBABNLqk0 X-Received: by 2002:ad4:4506:0:b0:6b2:9c0d:4849 with SMTP id 6a1803df08f44-6b53b24846amr163026066d6.0.1719558573539; Fri, 28 Jun 2024 00:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558573; cv=none; d=google.com; s=arc-20160816; b=f0eb7UubCHaV2AoGAV0B1S2GPvJqRTuHVQUdDTRlWPgj7aNL8384ZbuNsIWfRhEV2Q aFzfZZcHSwilEIIJSIiGA/303y5N7acZeJQhgeP1WuRA+uFQgkBInZw2gy6WIPzOz4vn 2ekPxTGXk/BJO4NXfU5uStUEBwah7MqOKv0TYGgkb2Nv5CcrnPXIhTiTfkmqcHxvYrp2 VOB7sP9/rIGtOgNZeEz9fVqzbi8qadp46u7heMpRqtE2T03BPGumcvSDO1ZlfQH2X9kr 9Ne7V81+auhY9yNxa110tPfphxOvUJfojfZFpbZUF3VjUNMX3MM7aZ/bJYvC0u+xQaAb 893A== 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:to:from :dkim-signature; bh=dnn8g/1r/IDbgXO0nM+fG6kuhQufIGWzDGBB4WRk/v4=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=XaZbIEpDtDJnNJdxqwnQ+RGB1blpJdMU9/MSEoc4Gv8JmH8WpFC/615IcgGiylf2qE ZZtgeZ8mPuE3RCla5GVlqNp0YzqnhkW/VHE9VSLhLnjt1PYtkVkYM/B5h4lRxRi8dLjS LK3qHDz+gfe/mBIFdLDmefCJUcflDWdN2SBI3nszj6EM3etP7D1A6WVNyJ9rOElONU+S Ta5skD+iZWQDZq975kHUA1aFn2yV54wedjQZtqwJw4rex8msbZXVOZHUhruGNLOvs6h8 tZxC0kBt/Hou4rd+aIY1azEWbxWmw/Bapb5Tsu8HOZob1AQeFhUj+i9Se22ueL+pQi9c qa9g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PsvxjtiP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e5ad7d7si13341526d6.225.2024.06.28.00.09.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:09:33 -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=PsvxjtiP; 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 1sN5g2-0006S3-Gv; Fri, 28 Jun 2024 03:05:46 -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 1sN5fg-0005yp-Nv for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:26 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5fe-0001gH-Iq for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:24 -0400 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ebe40673d8so2882421fa.3 for ; Fri, 28 Jun 2024 00:05:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558320; x=1720163120; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=dnn8g/1r/IDbgXO0nM+fG6kuhQufIGWzDGBB4WRk/v4=; b=PsvxjtiPrNH0Onp7y7vWtIG6aDN/0h4oyHnMTVPNEnuOwOqBspjX8LnQN/TrjD3rQt aWfvEXo1MnB0zEt5KyjNCOMz8nmC5aRKHCE8C54x/enAvWYGmOWAz5afZYborj0CN5Pj 9W6mAZV5Vwb9eumVPgely/VmQqxshbOU3GEMXyJBiGDpcAcnT06svSAvXuTXEBNIjeQz kdVofZ6YD4WJsBPEM0IDSTEw+wyw9N9YpYmJF4d92yQqPfeYVyMXGrPmYeJRjQEYDyhV G6g48mEVVRb7FWp0D/S332VzBAilVOp/5o+5AK0n7JRgIa2+AJsLNW4nksl9Hz4K4DUA mhfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558320; x=1720163120; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dnn8g/1r/IDbgXO0nM+fG6kuhQufIGWzDGBB4WRk/v4=; b=ckVRDOEBheUyzlpyXg7ZZo6Akqr0KpKeGMJjUggFLvzH8NnaBQC6rTo0/D5Riuteb5 AVZ9fpxZqrJQC8AUH323D/0HW2OxnXKH+ZpOfb4QYHr3cppFyYjhr4M9mtmZpnSvr5Wr FQ428WmB4/fhkSPptHLd1J1BGoxsRQwodq4WynAQG0juhdjuXcwjrOTQsNQe+8A+ZnVx F0IVwGDueW6769/f6pNDHr+znjmpZEanMcYyRmkwCGd57pRKL2vwsj6sRCogJS5yrCAA +tLGI1dfvWG4FGAoxpeCaq3++7+Ox3P254jAd6FVZJRoPvUUkvXJ72bGZqNirTAVqa6Z FmfQ== X-Gm-Message-State: AOJu0YybLAmFFPXJjTg5LilXBQHahWt7N9vckNrjJ2JcvtJm75sK+a8d duTEBKZZnSszKiO7T798rTmSFcqwgM6FgbbXWynNDzAHQcV71Y/rbVfLLMv8aWTGux0jHrFi+KX sbx8= X-Received: by 2002:a2e:97c7:0:b0:2eb:e787:47ea with SMTP id 38308e7fff4ca-2ec5b333198mr90628471fa.12.1719558320484; Fri, 28 Jun 2024 00:05:20 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a1108b0sm1313092f8f.114.2024.06.28.00.05.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:05:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 29/98] hw/sd/sdcard: Introduce sd_cmd_to_receivingdata / sd_generic_write_byte Date: Fri, 28 Jun 2024 09:01:05 +0200 Message-ID: <20240628070216.92609-30-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=philmd@linaro.org; helo=mail-lj1-x22f.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 All commands switching from TRANSFER state to (receiving)DATA do the same: receive stream of data from the DAT lines. Instead of duplicating the same code many times, introduce 2 helpers: - sd_cmd_to_receivingdata() on the I/O line setup the data to be received on the data[] buffer, - sd_generic_write_byte() on the DAT lines to push the data. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index cd308e9a89..690a3f275e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1100,6 +1100,22 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) return sd_illegal; } +/* Configure fields for following sd_generic_write_byte() calls */ +__attribute__((unused)) +static sd_rsp_type_t sd_cmd_to_receivingdata(SDState *sd, SDRequest req, + uint64_t start, size_t size) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd->state = sd_receivingdata_state; + sd->data_start = start; + sd->data_offset = 0; + /* sd->data[] used as receive buffer */ + sd->data_size = size ?: sizeof(sd->data); + return sd_r1; +} + /* Configure fields for following sd_generic_read_byte() calls */ static sd_rsp_type_t sd_cmd_to_sendingdata(SDState *sd, SDRequest req, uint64_t start, @@ -1953,6 +1969,19 @@ send_response: return rsplen; } +/* Return true if buffer is consumed. Configured by sd_cmd_to_receivingdata() */ +__attribute__((unused)) +static bool sd_generic_write_byte(SDState *sd, uint8_t value) +{ + sd->data[sd->data_offset] = value; + + if (++sd->data_offset >= sd->data_size) { + sd->state = sd_transfer_state; + return true; + } + return false; +} + /* Return true when buffer is consumed. Configured by sd_cmd_to_sendingdata() */ static bool sd_generic_read_byte(SDState *sd, uint8_t *value) { From patchwork Fri Jun 28 07:01:06 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: 808181 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223252wrr; Fri, 28 Jun 2024 00:08:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUwvJvBIXUGdWTe3Uq3jv1nTTJG2Bt4UzaLodrtONgtFJI6o6D3tP3MiHf/ee6ppPaS32SYZ1sH6zIXBkcpGViQ X-Google-Smtp-Source: AGHT+IEjlvKQHzMvYcehcZWx+jmD5qYdxJz2VH/hHQ+HENzY/3hKFOoKiJpu+6bqVwsZQb37OR8e X-Received: by 2002:a05:6102:3025:b0:48f:8b56:6c12 with SMTP id ada2fe7eead31-48f8b566cdfmr5231092137.13.1719558503072; Fri, 28 Jun 2024 00:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558503; cv=none; d=google.com; s=arc-20160816; b=06szaOz5Q2QFDq9GXOY++nhMzFro58n4PFmp+O3VIktphac9yUnBT7pNHcmKkaAEZq W9rY3Sjld7/ECYd4aZUENzIy0SxMOUmzc2R5iOuFSOEgqhnCLkynRpsAGD8+2db/YLWZ UU/SS+gCli7LOEM5kGFlkhFL6gMZ0o97GqdqZMUa/R1kBWBmGHRGlZ9IyhPPckkgbId3 MFLveqTmBqfuyTwHYR0BxMhxRVYykRvkTBR/iZKcAA1i2B6JSCiTraPeA+3ESlcSg/8W NeDu+EcJyfBc15UwPa3fPSfnrqr68yHnV62JUe05RQkj1gBgHBvf+Hg1Q/nIqZ5JHN1J TXuA== 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:to:from :dkim-signature; bh=3vBMoM//nVZe9CjYveKRdhPX/dFzNyrTxzPZ8neKDDk=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=Nb1vSYbK5OpD4RFqgO1S557EuR0z5W/JYGGhUglOpOHukEMk+JyfWsKbzC0X4gc+h1 e5Mt9HfU8+2uI/xzC+T68S9vLX/WGAL6EFOFJd3zbLjrrNyxveW3H5Mobh0agylHgnbB v4nR/WLgGCT1bIokx4GR9a5rdijgN+tIEuMBEBmM7r2f8I6ulxT3ruxG40BbyszXvOrJ zjSioFexxHkKmuVleE8BMOJqi4p5RRA7NDWBXTPQRej/eT5VgH/ZTizmgp5qCmnMBuwv XwIk+uvxTrblgPho2YxsBOuRuEXzNPIE30zMhx58xfGfYPMDN0SPKeF4m9fF97CyS9wj pIeA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YduicTpr; 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-79d69261294si119214385a.100.2024.06.28.00.08.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:08:23 -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=YduicTpr; 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 1sN5g4-0006od-AL; Fri, 28 Jun 2024 03:05:48 -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 1sN5fo-0006Dc-Ne for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:37 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5fn-0001un-1N for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:32 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-424ad289912so2323675e9.2 for ; Fri, 28 Jun 2024 00:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558325; x=1720163125; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3vBMoM//nVZe9CjYveKRdhPX/dFzNyrTxzPZ8neKDDk=; b=YduicTprbv7khCd6BPiWu4JgWdy68LuMiQM3x+4D+vXsroRobVuQRPlxhMVBnUaLQc mRDOexQ7gBSx+q2czexA2Vh760O6UtFoiffpQfsoFmEgURYXMAY3pr4Jvr4Qbu9EVPJQ jpj5AqibxNwe63f762J3ggAI1cVthMAXXiOWt2MS8Udsvc2waSWeZGecowgOddmT7DFd s2vmxvdcyqs3dgL1TtgU7v0hKqV3kzboItGhsJiapwidIhthMAOHtbmfDLTrwnT6/wdQ yIec5XISojC/TluvsOsxGhMcYT8YUZzGch2eGXmGavncllz9eMI1zv/lN9Q8LrgDUkse T9Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558325; x=1720163125; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3vBMoM//nVZe9CjYveKRdhPX/dFzNyrTxzPZ8neKDDk=; b=Mhg/MnE/7+5mdh9+JEqyx4db38gpgu5dXYAJgL+VKYM8NnFXpK92ylkRwJDRS5QMn4 Iopibwe5gxz5hWyAzWIc6ipkBQBnAVovYiFnFgztWTSCN1MVvnJlfnsZNkTFs3ZCr5Xg /SrZBjkckPh3ohIIVndIAM/+LJ6YVlPIrKI9FlAg5e/abTBX57J85ibNG/7bDopG/5NV I6arrEfwWmgArT5LuAlR1Vn22KKdHtCAl+segNrH89erOHTXyE0UhTGSsDIsBHoDFy34 s+VtRJ1Sq30yiA5g7s33p8suL9Kqu1rOAKrF9US7obusnBJadEVP0IKp4/jhszmjD+k+ lMiQ== X-Gm-Message-State: AOJu0Yxf4x8sNpY2KS2Vjq7pR7PYU5cSMB0alOLLTl6IvZbJxAMdVzpG nO9A6/mES1AuUmxNlfSMVc8LDhJWeAOSPWl1jKEZjzR8N+R0lhQKbZGmMxqgsx+0SGllVEVuqvu 5cFY= X-Received: by 2002:a7b:c84d:0:b0:424:ad7c:273b with SMTP id 5b1f17b1804b1-424ad7c281emr49665125e9.32.1719558325555; Fri, 28 Jun 2024 00:05:25 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c0fbesm20427305e9.43.2024.06.28.00.05.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:05:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 30/98] hw/sd/sdcard: Duplicate WRITE_SINGLE_BLOCK / WRITE_MULTIPLE_BLOCK cases Date: Fri, 28 Jun 2024 09:01:06 +0200 Message-ID: <20240628070216.92609-31-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 In order to modify the WRITE_SINGLE_BLOCK case in the next commit, duplicate it first. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 690a3f275e..5dbfc8000b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1461,6 +1461,35 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) /* Block write commands (Class 4) */ case 24: /* CMD24: WRITE_SINGLE_BLOCK */ + addr = sd_req_get_address(sd, req); + switch (sd->state) { + case sd_transfer_state: + + if (!address_in_range(sd, "WRITE_SINGLE_BLOCK", addr, + sd->blk_len)) { + return sd_r1; + } + + sd->state = sd_receivingdata_state; + sd->data_start = addr; + sd->data_offset = 0; + + if (sd->size <= SDSC_MAX_CAPACITY) { + if (sd_wp_addr(sd, sd->data_start)) { + sd->card_status |= WP_VIOLATION; + } + } + if (sd->csd[14] & 0x30) { + sd->card_status |= WP_VIOLATION; + } + sd->blk_written = 0; + return sd_r1; + + default: + break; + } + break; + case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */ addr = sd_req_get_address(sd, req); switch (sd->state) { From patchwork Fri Jun 28 07:01:07 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: 808178 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223177wrr; Fri, 28 Jun 2024 00:08:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX3zOKxVKIE7969EzDIRaiTyAxEUDUllwI6Y4wpiKZS3SS2QtsMTdwUX/myb/TPfLtISXL6+i96qayRMPDtBYs5 X-Google-Smtp-Source: AGHT+IF9gyq5gPF8sEsIpslVWmrvc0tGmNLYX+jzC31Fjcwhh271E8Sz/bWduJRmWNGI+XTmhh1K X-Received: by 2002:a05:620a:45a6:b0:79d:6670:e5af with SMTP id af79cd13be357-79d6670e773mr319520485a.50.1719558491162; Fri, 28 Jun 2024 00:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558491; cv=none; d=google.com; s=arc-20160816; b=SWoOVhBGR+45MHvCeXjm0QiwrfdsNj0y2L5NKebAOKnVekA9cvHJxJO3WSrZBpkjKw 8mndfmrXupL2ocYAeSOcgWoWNi5YwwHO+sqx98L8SCde9iF4MDXXXcnPfKNE9gsf/cpi 63I+o3WIv8Tv7I8KWORs2eNCi3qLF0z5UleH+oEugZ26WvtGRdhrgq4lf2lUBgovukYA wjFRGi4aMFMpjHiNf25XSUNqHb9tZRIG6LL3IP81JKX2/Inx6iGafQcCSwGqJoOo3RWM ai7/hzaJmYpCW5WiLPfK9VNllkRHigLlY3pqTCSrHE6mo1els+C7L9hFfy5ZxUSJtvwm d4Rg== 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:to:from :dkim-signature; bh=5jx92qB67I10buO/mjgytlSWd5fIkq6vABNEGHlhvFk=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=EIB34iBapfH/Q1+lgv9MbK5159rqAxO8lEUKQpDdWEqa/xk1CiOCqeg14k+p/bTmqq Myd0HcN8Lbc/q40BA8rA7CXkgeNqwE36DhxWc0kiMdryxwZhtaFXXH/8SEz64waxAZIA r3zerH36r0/zR843BwKtb+tEPXT6EKocZKwXXdtiMxlqkjlXPU1kdq4kN+Acsda3HrZ9 yvSFI71XDyjjJXUlovIbrnodjzQ0GKNexgb228d2ptqr14zEcwYdWy+Q43jter5A+neF jpL5iasu1KysSaWgD158GTNIEyJzaFcnMBxMH85wU9lRYkx2szH9xchCUWgGQf99gzRf 2RAw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cJ6ZYU1C; 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-79d69260d4asi119086885a.76.2024.06.28.00.08.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:08:11 -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=cJ6ZYU1C; 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 1sN5g6-0007B4-PG; Fri, 28 Jun 2024 03:05:50 -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 1sN5fp-0006Dd-UY for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:37 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5fo-0002Dv-A5 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:33 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-36279cf6414so167714f8f.3 for ; Fri, 28 Jun 2024 00:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558330; x=1720163130; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=5jx92qB67I10buO/mjgytlSWd5fIkq6vABNEGHlhvFk=; b=cJ6ZYU1Cs8pgNrvoNujsuuNvnM0Ru4dSbVtEw2voQXkHti6+BnuV870e4J84eYRnzf xkOrMkdfXLWlXjP4Z362oTbjhT06607da43IFdk07cx1Z8+eCCFUWbDs0aHtLCYgmoqG 82y4gQxMGQmovjGbr87ziWkaR/DDXsSy1MWvyNhgPKy668qRB4yqRGvItTEEzH1nm/ou ucMvrpt8pc4K2MdtQAoS100K9G3tTTrYHt6Kcxvndc5TdTMOuJbpOGniqcb0hj34Zi// S+pkffnD9vkKjCsGvS7kNQhOKNtbrSvMlLodBkGp0NkW7wxJ7l8Iigy1nYTqPsXLJhHa VZ6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558330; x=1720163130; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5jx92qB67I10buO/mjgytlSWd5fIkq6vABNEGHlhvFk=; b=eUdX9Fcu3Anz/c41HlrJMQ0Sq5UzN4qYE1veFZk2Cx3AZgge3UxQdl/fNxC4bo3bHZ srvXh0DDbS4UjDPe/y2k7SJa7SnbG5rKkmktj0Jjom6RR02JfTgbD9P75M6jZMgAkMmE bqJdo0zea2OFs+PvkoIRJAAgEF6BPt6fqv4/LRoIwwYuxLl6HhR/d0mlitb/wl6ZqmD+ +jvXT8hzsCk24TfEwx/OKBYxEjNp4SWaQDe5jO4fuONOptJj+CN8uur/e9OnL+gXeavs MJDv+UlnSPVYcClIGXxmCH8bFb2NBHJdoJ8ZlPYHIO2z0m4nYn5n3JnNy3YwG3t10/W4 B4pw== X-Gm-Message-State: AOJu0YzsrN2GXPSUCgwi+sfwN7agHwFY5A40nmMuamfLlblvJfyETLF7 emGYSRfmfhzOL9GFUAiiN6yBlHz5S45Jokxn2+JAmU8c6w4KVzC2qJtqcW60ApMi9mzWnwOb6WS dea4= X-Received: by 2002:a05:6000:4020:b0:366:e991:b9ac with SMTP id ffacd0b85a97d-366e991ba88mr11685612f8f.14.1719558330539; Fri, 28 Jun 2024 00:05:30 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fc4c9sm1322270f8f.86.2024.06.28.00.05.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:05:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 31/98] hw/sd/sdcard: Convert WRITE_SINGLE_BLOCK to generic_write_byte (CMD24) Date: Fri, 28 Jun 2024 09:01:07 +0200 Message-ID: <20240628070216.92609-32-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5dbfc8000b..4a03f41086 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1101,7 +1101,6 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) } /* Configure fields for following sd_generic_write_byte() calls */ -__attribute__((unused)) static sd_rsp_type_t sd_cmd_to_receivingdata(SDState *sd, SDRequest req, uint64_t start, size_t size) { @@ -1470,10 +1469,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_r1; } - sd->state = sd_receivingdata_state; - sd->data_start = addr; - sd->data_offset = 0; - if (sd->size <= SDSC_MAX_CAPACITY) { if (sd_wp_addr(sd, sd->data_start)) { sd->card_status |= WP_VIOLATION; @@ -1483,7 +1478,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) sd->card_status |= WP_VIOLATION; } sd->blk_written = 0; - return sd_r1; + return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); default: break; @@ -1999,7 +1994,6 @@ send_response: } /* Return true if buffer is consumed. Configured by sd_cmd_to_receivingdata() */ -__attribute__((unused)) static bool sd_generic_write_byte(SDState *sd, uint8_t value) { sd->data[sd->data_offset] = value; @@ -2045,8 +2039,7 @@ void sd_write_byte(SDState *sd, uint8_t value) sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ - sd->data[sd->data_offset ++] = value; - if (sd->data_offset >= sd->blk_len) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state = sd_programming_state; sd_blk_write(sd, sd->data_start, sd->data_offset); From patchwork Fri Jun 28 07:01:08 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: 808162 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222482wrr; Fri, 28 Jun 2024 00:06:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVbhWXtcwYUFtdwJ6AKSXqdqplI3dpXMfoajWTa/45JAcMSvq8hSqc7soshhvtkkEGofBTO87gYWGUr/lpOSDop X-Google-Smtp-Source: AGHT+IHBFRT6PpZ/qk9B4cRIXfQ24Cp8dEbO44Uy31zIjPCX3oynExf2S/859nt2UNkvF2jcNcfk X-Received: by 2002:a05:620a:170c:b0:797:8ee4:46a1 with SMTP id af79cd13be357-79be6cdc68amr1774363185a.10.1719558367978; Fri, 28 Jun 2024 00:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558367; cv=none; d=google.com; s=arc-20160816; b=Pvx82DF/0een1zFKdXc+CjjEb2/ZVGpvIUGVWLTkds+GA0CPfHXVp8wRqe/652HLrR no3Vfq1YVNgLAKQtpBqig1Euj294DZUCsD5EY2juSN+tZNc05s/nS8GZ5DbP4RoXhjjT jzLK7LA9IVY2LiVaibI6gnHw+cdFTETINalHRsorW4WT5zkzD2o5joe/C+cuwNwgRD8j 5Sa9CEOo6S0uPMWS9uCsrZ2SUGwj1mQHHV6v/jKAka3Hiq+XpBH/NVTRF1/6Pqd+tTiZ lhjDr8e87NflI2NINxwEMhoL+hswXDYc4w9Hd5a4yqzzwntsKL4wL8lySsDdyhQnfYoX Lzpw== 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:to:from :dkim-signature; bh=D1iaio/bW9b4zqPLpqdHkFVAWGPPP4QqHttJbqr0UPY=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=q8SOGu0Sz4jK6Vw8wX1bB2Jw05K1K1c/YKPsAJYVtafONfDEpojDITt+yAouxL3C44 wSbeKSqiD3/vK+abI7Q+0D6JG+LC00i42CMP+QPMJw9hrjlv+FL7iYVtt4FKy7yTpJhx saRPhULLeEoOS6reQ5OCBerxKtPityp6NJNnBKz2N2Rs+AG6NG+Cp+yMq9+pqQbuzXPA +ErGeUe9X5GqhjdDFVYRnXxHoZJ6z36TBRuMJkS6jYRWCZZh8MmhIAZ2SyTpATQGOJsh PY8UYLhCF3gQaK0TSUgiWs4ksbyxJlQSCRK6p1ck2cIDUFjLyU7n4B0peul14gRcATq1 mCSw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PBCDwgxt; 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-79d69260df5si121548885a.110.2024.06.28.00.06.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PBCDwgxt; 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 1sN5g5-00074y-QO; Fri, 28 Jun 2024 03:05:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5fw-0006Ho-Rz for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:42 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5ft-0002RY-CI for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:38 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-421f4d1c057so2192745e9.3 for ; Fri, 28 Jun 2024 00:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558335; x=1720163135; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=D1iaio/bW9b4zqPLpqdHkFVAWGPPP4QqHttJbqr0UPY=; b=PBCDwgxtpLwNQWHm8Pm5p1cECNVmer2RN18tTTqaRBUbOq0+lT2x6a0sss9lHUdiAH n88+WBEAhmLV5E4Q0ZTj8BG9Cm/6WoXI5811Higd4wtFiIoG+zCUfW7YYswQv0vZvLgC Epwd0Fr+BSAEeY3H4wakTSMGyAPRUmJyD82+lxxJfyQio77NwMZ/ySygWsI1uIwFHg04 nD4Cs639t3hWImsPfANcOxAt0lqLuTDJakeiGVMS6GLu1ncrlJ8gRlf2JlAIvT8a0Yz8 EPDgR/Hm0l7PNRlcaXxykV0hIIXFCDewN2lG7RJuuEcGpnj9wofjWrICgRCVk1IbysZ8 xDzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558335; x=1720163135; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D1iaio/bW9b4zqPLpqdHkFVAWGPPP4QqHttJbqr0UPY=; b=HxDxS/X+AP0UY2h8XsSOfrQbfC2HIROd92XqjjwEViBvBltOHQdT0331ZnixoEu9bh Ua4f89HfTY6b9wWFog2JY26ddj1mBL0xOa1ryhilrq1tc+LckKwhcP8BVLyxNCwiGcXA 8XTYSv++g4dG1nYZOZXRm/6fYLJdUiCQOy6LZ5xb9R73xQfCVObmknVlovtVBMY7tNda ul66gMvV5gg+PK14Bq+G8Z07wCrpX7hcV76Gr4oDCoBHtOT4q9XYmMEt8zkR0fv03fl4 doaTUZlACjf2M4gdwXDTCIspqCG/9xl2NMBAeBD0md7wSRCdTEn20n51OAhS8aJDmcvp /IUg== X-Gm-Message-State: AOJu0Yz2SDgvCNWdgYoKq3Z2EKSjIwQQ36jX5CjU6vxJI0sq679jD2Sp 3uJ4doQTGm6LiCbFVpm2akr4BEVd0WbACp+adoUnt8kVxT2Anb2RfF7XdF5ET8rb7Ci4fvCxNv8 L43k= X-Received: by 2002:a05:600c:548d:b0:425:6d00:3572 with SMTP id 5b1f17b1804b1-4256d003730mr6381475e9.6.1719558335593; Fri, 28 Jun 2024 00:05:35 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3912asm21893325e9.10.2024.06.28.00.05.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:05:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 32/98] hw/sd/sdcard: Convert PROGRAM_CID to generic_write_byte (CMD26) Date: Fri, 28 Jun 2024 09:01:08 +0200 Message-ID: <20240628070216.92609-33-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4a03f41086..b9c72a0128 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1515,17 +1515,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 26: /* CMD26: PROGRAM_CID */ - switch (sd->state) { - case sd_transfer_state: - sd->state = sd_receivingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; - - default: - break; - } - break; + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); case 27: /* CMD27: PROGRAM_CSD */ switch (sd->state) { @@ -2088,8 +2078,7 @@ void sd_write_byte(SDState *sd, uint8_t value) break; case 26: /* CMD26: PROGRAM_CID */ - sd->data[sd->data_offset ++] = value; - if (sd->data_offset >= sizeof(sd->cid)) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state = sd_programming_state; for (i = 0; i < sizeof(sd->cid); i ++) From patchwork Fri Jun 28 07:01:09 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: 808166 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222742wrr; Fri, 28 Jun 2024 00:06:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWUjEwun/5eiW3h+ENrawFeDsLA3IJBjl2m2Yj5OA/GhbB3AIYO++zs+imSPgaTPI0SYwR+DlGgkQ0DA2qwAg/N X-Google-Smtp-Source: AGHT+IGBcZRfpn40/PCtXC9Tlo4UyQLOVSyABzH+U15WE37QizolXFrNfy1QpS2FJohffIXoucyp X-Received: by 2002:a67:e356:0:b0:48f:4778:929d with SMTP id ada2fe7eead31-48f52b9ace6mr16379731137.27.1719558414973; Fri, 28 Jun 2024 00:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558414; cv=none; d=google.com; s=arc-20160816; b=QaJS2YJ3T4Sj7yju13M85VEMTJFArJXlmmLOObuqVEqO+3m3sRfi1+WAVIu0sawnA4 7jqVliTePAhzxBuK+38nzLFoYRhG5Rm5tV6GkXLAEhcASLR0HayqxQqt3thQcvz1+zS6 WG+6e23hXIxMIq8JzK66j3G0sK8EBRjX/JOey8Y/CfK8I/ijIquDGQd4Iy/IiWLcoQ+d pIL/nhSZVWQrDPIJamt22epAduDghCMlVTAgQtcDWkaenRNY5Noo7+i9ASritO3MeA3s vCULjiT19bMwWS54MjLk+XJiALo7Iny8fKLUnAg3ubCO+hq1IVR5wbn+8ov74n4gDcD9 r7Uw== 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:to:from :dkim-signature; bh=R6Piulxoj8zPwW1Yv8YFFcFYZqBjXPSZ0pu/dRDGp6Y=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=ySEpJt1uKNFjEPQdk3+K5GBqbR49S5G/7ZfOioMcDtNFzKi5tVD59xWOxoxONMzw/T Okw6wbsBRToqVzkRnRVU+GowXun4Za/QC34ihSi0JXO/aCob0dvtpNGn5mVxmgnKI50U rc6loDMbjgtLGd+uMt400nJFXg++xo6hZ79c4evXlS886H+6aKw33DEmVkhhp5yY0rWU NSt8Gfk/NjoUDRyGEcRJBIU5tVYqIwq9dzLBjBE1c6ZutLv8Kq7rFBgDHDvyv9wyzyp0 0xskzOuFDQO26VtuOAFUdIdT0iNNK2dzNP9U8MhghKXjccF9saZWWhike9DaYznFH6v0 Nntw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hCzbBxeD; 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-4465368c5e4si10644911cf.127.2024.06.28.00.06.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:06:54 -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=hCzbBxeD; 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 1sN5g3-0006j9-Sg; Fri, 28 Jun 2024 03:05:47 -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 1sN5g0-0006Ni-0C for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:44 -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 1sN5fy-0002m4-65 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:43 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-424a3ccd0c0so2791445e9.1 for ; Fri, 28 Jun 2024 00:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558340; x=1720163140; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=R6Piulxoj8zPwW1Yv8YFFcFYZqBjXPSZ0pu/dRDGp6Y=; b=hCzbBxeDhfd8dlPIEWryRCNgCFyUGhCskfLFY4Kdv1PkZNEZ/OQTcDFaIpbJHWTjam Zrwh8Mr4bOIaX5GyezYq5un9fodN7LGxaykUauD0/ggxqHRTCwyoeJoLI48Fh3lbz/Gu SJr8uYkEd01XSn15oswptcXYqDRUa3drXcQ8MZdNPNl1sMrZvlBE7Toi1PxioYCvAFiT QVGmAuFMCE3Gby82oe4KHB+/vdnePHXhEQSco+9I6Uhmfj2+5ASJ/U79FN1WzlM+XiqR wlkqzocUflHYQMDxr9i/j0U2Vfvu1Th7sfrw9F37M3ffXvxrZQ3iGlbu1j3xc3iakCJq OJ2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558340; x=1720163140; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R6Piulxoj8zPwW1Yv8YFFcFYZqBjXPSZ0pu/dRDGp6Y=; b=fqQgp4MR59DYrvsu20inJie4f4woQ4lYkzVxlpwiwWAAVcKxCbNErI3J0OyltUJ6eD dXzRr+E008vHXKgHX0iA7PQNfasaDH+k7js+OeJjZbBv2h+vwGv0BdZoAeYZlXpp1ngF rcbENtSNMhUfXK0NU4mPVfBA0HzRd6WfCp3d8yj30mMxX3bejIg6VqJPK9tvjZik/Yie p80OML+9p4JKLAna01mZHfiI7t+p1dB7siRWpXcBLMvb1uOMWh2pmqKM5InDPZByss62 ebZSCZ8xHWWUTkKbIbgP5gtGwnUrhSBpUGNr01oMf2gxKuB6Axc93DdigT0ZeNBCkEqw C4hg== X-Gm-Message-State: AOJu0YxqW4KWM2meIMfVK+WcmNRYCdnLEkW6a/aATsUhjqCXDKtWlefr LylHVEqKuyp1AZ4nsmeY3YepOMTUCoZnx73OmSFCnEPuh6pgBeJd6tmDRaodST6GqI+64WmMz4A t7yo= X-Received: by 2002:adf:9799:0:b0:367:40cc:ac2 with SMTP id ffacd0b85a97d-36740cc0c8fmr2527052f8f.48.1719558340498; Fri, 28 Jun 2024 00:05:40 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd72asm1334859f8f.10.2024.06.28.00.05.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:05:40 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 33/98] hw/sd/sdcard: Convert PROGRAM_CSD to generic_write_byte (CMD27) Date: Fri, 28 Jun 2024 09:01:09 +0200 Message-ID: <20240628070216.92609-34-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b9c72a0128..bdd5f3486a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1518,17 +1518,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); case 27: /* CMD27: PROGRAM_CSD */ - switch (sd->state) { - case sd_transfer_state: - sd->state = sd_receivingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; - - default: - break; - } - break; + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->csd)); /* Write protection (Class 6) */ case 28: /* CMD28: SET_WRITE_PROT */ @@ -2096,8 +2086,7 @@ void sd_write_byte(SDState *sd, uint8_t value) break; case 27: /* CMD27: PROGRAM_CSD */ - sd->data[sd->data_offset ++] = value; - if (sd->data_offset >= sizeof(sd->csd)) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state = sd_programming_state; for (i = 0; i < sizeof(sd->csd); i ++) From patchwork Fri Jun 28 07:01:10 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: 808170 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222909wrr; Fri, 28 Jun 2024 00:07:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW/hcXbFlDWYfJg8HeyluBhBoVYOsHk9p7tKiknhE3Uwni2ZrrQ8zojYSodwreGZp+/Q4nFh3rWHJkg8gX5BqNw X-Google-Smtp-Source: AGHT+IEnqEz1gOQQHKdeJhGCKFbcATOQ3cabulUayq3cxG8qD7J/zikyNiXN+m6IQ/0Rh0G4oqyi X-Received: by 2002:ac8:7f43:0:b0:444:a34d:900b with SMTP id d75a77b69052e-444d393a35emr183119111cf.1.1719558444665; Fri, 28 Jun 2024 00:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558444; cv=none; d=google.com; s=arc-20160816; b=zyHPXo5lyayM1g9YYrxoOsKp/ARXbNxFnUxsxT22XqvhbDIY1XC18MLeOqmQgAqHtk jq2HyGnAXVt9NaYCmPVcHFIT4uNyogBcfXSvVh6+1FK3q21NVtpn+Jvkupjk/xHB0vNg l3UALxPXJc9Of8jgxHiUTq+ZBQDGh9Wb6z7dRAelAAfMOAYhRNBg8KFbtOvPi46f1ws+ 4Ta95Prtpd+IYCif5lxyLrUeyeqBf9gfFYyChnntSlxZg0cXt0h9atLarVzmnvMGZ64d jq0jG0ah20oGhIDWQ9qXAC70OvPLeI4cK8OeIpeBIIowTtRjBNJ2dUpPFc6jAv4CaGYc kxnA== 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:to:from :dkim-signature; bh=a+swjnqxsHD9ZmAL3ZynjQXwZx/kNtJr6qmfanG6zVA=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=MBPE2q7vPpNGkkZmqVily6YfKrQRHJsnrOu3XJa3NHGwHMMXhfcDYeuqELJXYIOsst qQ9145/iOouaQbRF/kf6p3TYpt680Mx3zMYqal2rr6tvNjSjTu02TayNRDFZFWEdyxO6 HLBmNy4PRCCLpONG2orGnLBKjRRUVY9fVgSBRgdLZhTX8GoiAkFKFPRKvBI5usVvdsx9 tLPVuM0NkhwTHT4K8zkxDkYkBpAvdi1X6aueGcH0qxOBo5qrebvyr53kOiLnq5uug/52 ETmCob6abnf+dmlsW/An8ec36UDtWagtKYRwplhORJJPGUTpMGdI3ZJeTMd51t3HebjH Z35Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c9PARPRo; 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-446514c66c9si12856461cf.618.2024.06.28.00.07.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:07:24 -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=c9PARPRo; 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 1sN5g8-0007Kl-8Z; Fri, 28 Jun 2024 03:05:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5g5-00070C-BB for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:49 -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 1sN5g3-00037p-BW for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:49 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4217c7eb6b4so2619765e9.2 for ; Fri, 28 Jun 2024 00:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558345; x=1720163145; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=a+swjnqxsHD9ZmAL3ZynjQXwZx/kNtJr6qmfanG6zVA=; b=c9PARPRod/MFBb6AB0FGgcCvKZ/yfygLfp+YjMl7hVzm2INYYV2OzdJFjyRmsZXIi+ VQFhEl9mICd7gd+VfywFAmnEr5fTsusWyFIR4u+YDz8XU3ZCFq4OUUMQcTdhrOpCoqgR xq+m7FOeLgc0puVghMqzF9zu2fDfjFcEfVZjjiPremLoEsaNQpV5u0BY+4Z7CYMG0DEs yCVNt9XJIJKhnDVy3/FNpMweqbE9BOMevbxgOdWkhVX7MgmUi4M8YRt+lvpRnDFBtl1z x9qwkeCHekJ2HhsQtDNgV/fPYk4y9BV0ordfgLgbsITbXNxDEXKzXyQVRvBr19tWWyCb ru2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558345; x=1720163145; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a+swjnqxsHD9ZmAL3ZynjQXwZx/kNtJr6qmfanG6zVA=; b=wG1MOlQ03y4wChfE8Z7SIpCXq0d+4iyNl8QIVPNt3tb0REVhNhbsdkev5AKLmKWLz7 YD91+SEST0VhdVVd8TsASEB7LibdruQ3x51r20RlRTT3dHbOQ3nprn1ad+B9J8s4MumH V3rt8LpuYyB4BH0ffVu8Crz3ex5tTx0p75DecpLNYT41hZR0A/HKvukVWPDjwNYsMzcQ YTfd5ornIKQCtwJ3GptV2+tWmCb7f2Qxw8IKTUAHNrqnNS8qUys93ckNv3k/v0ZMwrDV F1du5X5JiZoEjC9cnosLOTDsaxR05tgHfdeo39GEipU3QtkrUYWkYG2z4QE9iGGt3noO FQFw== X-Gm-Message-State: AOJu0YxjzYMo6srMaGHphddI7Cgdk/Iz6dGahsprjoIvqNmdQkWwbeDD vYqunWvdLrOP21Rd/jyTKziHFT0m9qB9NO6iYU2QsnevtvuIBiZ8I603kJQH+4DvZraIpLQYzTO FOwc= X-Received: by 2002:a05:600c:2192:b0:424:bb45:cdea with SMTP id 5b1f17b1804b1-424bb45cedbmr51828945e9.22.1719558345582; Fri, 28 Jun 2024 00:05:45 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c16bfsm21109305e9.39.2024.06.28.00.05.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:05:45 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 34/98] hw/sd/sdcard: Convert LOCK_UNLOCK to generic_write_byte (CMD42) Date: Fri, 28 Jun 2024 09:01:10 +0200 Message-ID: <20240628070216.92609-35-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bdd5f3486a..0cb528b0b2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1628,17 +1628,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) /* Lock card commands (Class 7) */ case 42: /* CMD42: LOCK_UNLOCK */ - switch (sd->state) { - case sd_transfer_state: - sd->state = sd_receivingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; - - default: - break; - } - break; + return sd_cmd_to_receivingdata(sd, req, 0, 0); /* Application specific commands (Class 8) */ case 55: /* CMD55: APP_CMD */ @@ -2109,8 +2099,7 @@ void sd_write_byte(SDState *sd, uint8_t value) break; case 42: /* CMD42: LOCK_UNLOCK */ - sd->data[sd->data_offset ++] = value; - if (sd->data_offset >= sd->blk_len) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state = sd_programming_state; sd_lock_command(sd); From patchwork Fri Jun 28 07:01:11 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: 808172 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222979wrr; Fri, 28 Jun 2024 00:07:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXS7U+xcr8nqIEZx9RPICkmL9P9b5/41csnGAvyvSH4gmA7pM0xC+6q9s2E62a9lwraPRmkOvIy/15Pzz4u4/5e X-Google-Smtp-Source: AGHT+IEjGqOTb75YmBuHn1xn7eOK+GpLut5RljNQTi+OnvtOXARhOwo3oEC09ybZgD4y79nibPV7 X-Received: by 2002:a05:6830:a52:b0:701:f8e0:9997 with SMTP id 46e09a7af769-701f8e09e28mr1580567a34.16.1719558455442; Fri, 28 Jun 2024 00:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558455; cv=none; d=google.com; s=arc-20160816; b=G5kJW+4yidAIPGLK4sWBHAPCk7R2Q8FvOXH/YUzRkpaow5QpF/DY6TpepzMR4pdWTN XBW+dxuQ81J213LY5uJIAJ0X/OS6KbU1kOVQqfC+VZRU6rTWlafjCxC9TMJ/hW9fOV9V t+S6R/GWLwijUE/RU78YOvFke2QYoPOU5CI+EGAgiPIP5wSN0B7CIwwx0ui5CsWjykJ2 02ikZ9eTBF1FnmlfxqhjorgWmu15gD07ug1MgPoUiGrLv00DsrR0NUQXhM/ZKn8FVSHI 1K199B3x0Ud5HUEKDPrPzuD5aLplNzybA4OOtwStC9vuoycPBtqRmWWZNCNjh8EZK7gV TqRg== 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:to:from :dkim-signature; bh=lRVCvBojEsyxAg7JZRES3P5o6lr6YCg7S7r2PnPDGt0=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=yH2ZQmVSc3+gMa8yL66wqPdkBolMA+vd+SEKorYaD6Lh2PAQc93E3QFz0N1HQBrDCU 1s+KxHhYT1kOOOeTZr3+yJjdhjOQAizOUYxWU3j7ERhK0tJ0Va03umSSNNFa7NOFso2M h/kBKxFyWFC6/pfl9tq9g0jPTRWq00tJ4ogjW9DO4eMHk44DuOt3qoyue7vfFJM5TAzQ ISJ06kTMQScEJrWq9JS6cw9vz8yutEYYR06jP6GuO7anCIoXq6bWRnc04WGVIvhs5MdM hIJupsPar3WA53uYTt+ZXm/kttJO3zancQvfbewCCfeGDDsY13JBkxQRl7hBFArgJ0ma grog==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="X9QapbV/"; 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-79d69260b63si134214485a.14.2024.06.28.00.07.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:07:35 -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="X9QapbV/"; 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 1sN5gG-0000Bw-1W; Fri, 28 Jun 2024 03:06:00 -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 1sN5gB-0007rZ-RA for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:57 -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 1sN5g9-0003Cp-6s for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:54 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-366df217347so208912f8f.0 for ; Fri, 28 Jun 2024 00:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558350; x=1720163150; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=lRVCvBojEsyxAg7JZRES3P5o6lr6YCg7S7r2PnPDGt0=; b=X9QapbV/e5yFZDq9ITff/b+khrLeetST0d/GdlsCYMaPe+Btu3m7Ppy1mCBdqMLgHd sibK1ZWE87dDGSruNI8jzXosiVKWypZJ1B8QQHUQ+Na13wekQ+3a3Yt42h22Vm/ypFsA FTtLK5yrMiXPc2F0TID3FWKS7x5522L59e+fSFX9E4dBnHRJLiCdW3RGjvEhhHgpjA5B 57mf3dOpCFlZvsbInB5lBecISjBK1S1xPu8Jeqem3j5WGQ67LnjCpEB0uOBbmdSDYjRQ H8QCKA/a0BhbC6AGzzzRmPGQfg+Ak4vptShTWxY1jQZ+q8VE3wWPLmPqOgM8KJYbv2WZ DJ4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558350; x=1720163150; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lRVCvBojEsyxAg7JZRES3P5o6lr6YCg7S7r2PnPDGt0=; b=Ynn4VlmNsIiY3Sg/H3YMp7e4UGx/kxvVhVt2PFMdacqjcdkF0TS6mWuzoZD21Nq2hU xuMVbmne9sWA5c3DLzAsTkMKFyNhn9W4DmEshWa96IJoZpxRH7cEC0XwcSkjxuYeV3q1 p12nuIz2ZqaFiSXwb/UqINqvBiZuA+C6o52xfoDI2z/lfw9LC3EYMfx/0Cj8Kf0GQmQX 3lbYUl2Rq0wzX3olOh2k6O7lDMcwjtGEjQ/+pXF1TX2YEbO8AJILerSRvFUxgnFhgXSE wfMIQP4BErTElc96/Pkiqs4TlqliHqCFzUFYdEarlhouP+1kxlOhn4c4lbBbjtdO3dcO 9OfQ== X-Gm-Message-State: AOJu0YxLc+dPMkDS9NNAhsrkzrjecPS5ApEUffuvzsiYXmOKPaL7tVsn 668cWORpL2rbZXaZjsiHa4hmScOjT0DW7psFiMo+G3r3s/RuRXEjpyb3mMyXcHC07A1O9TtTQIe rmcY= X-Received: by 2002:adf:f98c:0:b0:360:73b0:e58e with SMTP id ffacd0b85a97d-366e9492ca0mr9116033f8f.26.1719558350581; Fri, 28 Jun 2024 00:05:50 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd784sm1348789f8f.7.2024.06.28.00.05.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:05:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 35/98] hw/sd/sdcard: Convert GEN_CMD to generic_write_byte (CMD56) Date: Fri, 28 Jun 2024 09:01:11 +0200 Message-ID: <20240628070216.92609-36-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 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=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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0cb528b0b2..f9708064d0 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1657,14 +1657,12 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 56: /* CMD56: GEN_CMD */ switch (sd->state) { case sd_transfer_state: - sd->data_offset = 0; if (req.arg & 1) { return sd_cmd_to_sendingdata(sd, req, 0, sd->vendor_data, sizeof(sd->vendor_data)); } - sd->state = sd_receivingdata_state; - return sd_r1; + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->vendor_data)); default: break; @@ -2109,9 +2107,8 @@ void sd_write_byte(SDState *sd, uint8_t value) break; case 56: /* CMD56: GEN_CMD */ - sd->vendor_data[sd->data_offset ++] = value; - if (sd->data_offset >= sizeof(sd->vendor_data)) { - sd->state = sd_transfer_state; + if (sd_generic_write_byte(sd, value)) { + memcpy(sd->vendor_data, sd->data, sizeof(sd->vendor_data)); } break; From patchwork Fri Jun 28 07:01:12 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: 808201 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224544wrr; Fri, 28 Jun 2024 00:12:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUWWeprAyqq4KFFBWBokTC1ljspNJwO0WHwpeNEwefooSueJyJm61zLXYyBpJHXLcuiOKZUxgsGxKuYmbaIqaab X-Google-Smtp-Source: AGHT+IHi8OeouspGovmwciNYYuaGtx7Kr0mE9MSWIGAaG70jGBmKKG4RivaeRbxr+w8mDWSwbNC7 X-Received: by 2002:a05:622a:15cd:b0:444:cc00:84db with SMTP id d75a77b69052e-4465567bd20mr10765921cf.19.1719558756380; Fri, 28 Jun 2024 00:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558756; cv=none; d=google.com; s=arc-20160816; b=gjQN3MMCAJE5XnmxepUpVmoDb4jT1dNhCCffdi9ZmYq1ptTdLYsTGX9bbB0INlapsp tpp3RAztm/Ysq2hMCBHM1qKiL2G239QIw3BIgiNFGdZd3Brj7XuoKLHtgwYxdq8GLm0d dK0Bw17CWjJUZjnDy3yINzNVJxJXsMa0E7EFs4L1h8eTZAZkbFZ3QSUBZ5Eq1EhcIHX6 KJEdfW21wiRk7b37t0DN8UlJKAZAHLdDe9ynjWyV1BHVICKV+m2VOj0YxLGSVAi5OumH /yaG3/9X94zY9JZe60aTbqVdyycvNaXCvtrxlSasBmbo3DAFvAV40J2I5hZpBpXvunsW b5Vw== 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:to:from :dkim-signature; bh=bHvyGuDRbuJRmw1vnphLPFr0BQjrkrSSL7KeWPzCQwM=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=eWha5+oN1X4uTmlpQXecZjloXGilrveXL7FcGiSoySeP6bFqXPOVh/UMwDPwEiK366 41E6t/YAljXdBsaJNJ4PDa/bb+7BE8sswxGvFRbIv+ai9EeEnBSvCcpnD+ZGcjamomNZ UMZQr8UIt6U2WFQrU2fMqdThrIDJkDMr9A+H+NZXHOBsSCpy9jyraF4bjRHYkuKQ7SDS gWdfnXx0Whxn5daRjw4TwmLPm1tgNzHDRGZqHfMn4TxVLwzG/PZr/VpQUwETvG/WmYCz 7f/lfbZVdWDN3OYOlztx+EVt+VLILzgAbkh539CyTsE9lKdQUYreh71xzv3njCdjvxMr bTJA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hkQrUBLo; 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-446513c1bc7si13134391cf.68.2024.06.28.00.12.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:12:36 -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=hkQrUBLo; 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 1sN5gH-0000Qo-7h; Fri, 28 Jun 2024 03:06: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 1sN5gF-0000AX-Nk for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:59 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5gD-0003DQ-AN for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:59 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4248ff53f04so2334915e9.0 for ; Fri, 28 Jun 2024 00:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558355; x=1720163155; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=bHvyGuDRbuJRmw1vnphLPFr0BQjrkrSSL7KeWPzCQwM=; b=hkQrUBLomPLqznOG6RnPnRuXFYEfb00ulmd7fw49TpFaOy2Mmm4npfqJu92TcITui7 +5WV10c18QlXekQ79c6UcqZEIcUdSBRXKC8kJnvNruO+nWxqQg6E559Ztk6C1i9nqNTY gmiOrGyO7H9KXe38swl5QmxAwyDsF31Y99P9IfP+wMCeVy+JmXKOQKYFUxRx7GJr16Ia pkruTyrv1sQN7fiXXcjw1J7CfpuHv92ihaupYz1Vuji8/GLjBnmP0uWRbMF5Fi3w5Wrz R8YNwsJQPJu/QpxRH56xUmuRcr6TTG7JqInk1i9nAjg3C/p0kuMjti2yYsdLuISXAESN 2HLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558355; x=1720163155; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bHvyGuDRbuJRmw1vnphLPFr0BQjrkrSSL7KeWPzCQwM=; b=UJKQazjExV6ohWKH2eV678E09SyxcsY9OWCaU98GP0MjTS/WuP0kzbYLRJFMBt+Kz6 7+TRiYiGDfE1QQdtjuviPiF/6fxP/x/1NFvVeDoTFLl2S2mdgItx5HmRHfoB4guaUwdh mkSGx1bq3XzFUFwSbUmKNXDLeCvVfgzpmKMv+GS8semt1JStqp23v5hQ4jdMGXEfciUy /mXZv6XoTpwM0gGFoS+VVM4Peyga+1frIx9pIlIYxAZybRdyCGs58DlyYQIbvS821qQ8 nwj38iEL2IIU4x3jx9E8qLGPL4YfXj9mU0mubIU+wpbk35j4FRyRZnzW7ix39x5Qtxbj C9FQ== X-Gm-Message-State: AOJu0YyaBTouHFH0JgpQy9fGfLMcvAYMLp6G8aVwX7Iy4HBSEJ9clBNP /dwOaPzJqCZp7wBoyJubYiCOIURojSzeHZ0GmMeG8pVO2808MaxJpsB2at12WTBexaFP3a6HNjU Qdyw= X-Received: by 2002:a05:600c:3b1d:b0:425:6dce:8c54 with SMTP id 5b1f17b1804b1-4256dce8cd3mr4395505e9.33.1719558355577; Fri, 28 Jun 2024 00:05:55 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c18cfsm21369195e9.45.2024.06.28.00.05.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:05:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 36/98] hw/sd/sdcard: Move sd_[a]cmd_name() methods to sd.c Date: Fri, 28 Jun 2024 09:01:12 +0200 Message-ID: <20240628070216.92609-37-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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 Merge sdmmc-internal.c into sd.c by moving sd_cmd_name() and sd_acmd_name() and updating meson.build. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sdmmc-internal.h | 26 --------------- hw/sd/sd.c | 62 ++++++++++++++++++++++++++++++++++++ hw/sd/sdmmc-internal.c | 72 ------------------------------------------ hw/sd/meson.build | 2 +- 4 files changed, 63 insertions(+), 99 deletions(-) delete mode 100644 hw/sd/sdmmc-internal.c diff --git a/hw/sd/sdmmc-internal.h b/hw/sd/sdmmc-internal.h index 306ffa7f53..20d85aea6d 100644 --- a/hw/sd/sdmmc-internal.h +++ b/hw/sd/sdmmc-internal.h @@ -108,30 +108,4 @@ #define EXT_CSD_PART_CONFIG_EN_BOOT0 (0x1 << 3) #define EXT_CSD_PART_CONFIG_EN_USER (0x7 << 3) -#define SDMMC_CMD_MAX 64 - -/** - * sd_cmd_name: - * @cmd: A SD "normal" command, up to SDMMC_CMD_MAX. - * - * Returns a human-readable name describing the command. - * The return value is always a static string which does not need - * to be freed after use. - * - * Returns: The command name of @cmd or "UNKNOWN_CMD". - */ -const char *sd_cmd_name(uint8_t cmd); - -/** - * sd_acmd_name: - * @cmd: A SD "Application-Specific" command, up to SDMMC_CMD_MAX. - * - * Returns a human-readable name describing the application command. - * The return value is always a static string which does not need - * to be freed after use. - * - * Returns: The application command name of @cmd or "UNKNOWN_ACMD". - */ -const char *sd_acmd_name(uint8_t cmd); - #endif diff --git a/hw/sd/sd.c b/hw/sd/sd.c index f9708064d0..93a4a4e1b4 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -88,6 +88,8 @@ enum SDCardStates { sd_disconnect_state = 8, }; +#define SDMMC_CMD_MAX 64 + typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); typedef struct SDProto { @@ -231,6 +233,66 @@ static const char *sd_response_name(sd_rsp_type_t rsp) return response_name[rsp]; } +static const char *sd_cmd_name(uint8_t cmd) +{ + static const char *cmd_abbrev[SDMMC_CMD_MAX] = { + [0] = "GO_IDLE_STATE", [1] = "SEND_OP_COND", + [2] = "ALL_SEND_CID", [3] = "SEND_RELATIVE_ADDR", + [4] = "SET_DSR", [5] = "IO_SEND_OP_COND", + [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", + [8] = "SEND_IF_COND", [9] = "SEND_CSD", + [10] = "SEND_CID", [11] = "VOLTAGE_SWITCH", + [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", + [15] = "GO_INACTIVE_STATE", + [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", + [18] = "READ_MULTIPLE_BLOCK", [19] = "SEND_TUNING_BLOCK", + [20] = "SPEED_CLASS_CONTROL", [21] = "DPS_spec", + [23] = "SET_BLOCK_COUNT", + [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", + [26] = "MANUF_RSVD", [27] = "PROGRAM_CSD", + [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", + [30] = "SEND_WRITE_PROT", + [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", + [34] = "SW_FUNC_RSVD", [35] = "SW_FUNC_RSVD", + [36] = "SW_FUNC_RSVD", [37] = "SW_FUNC_RSVD", + [38] = "ERASE", + [40] = "DPS_spec", + [42] = "LOCK_UNLOCK", [43] = "Q_MANAGEMENT", + [44] = "Q_TASK_INFO_A", [45] = "Q_TASK_INFO_B", + [46] = "Q_RD_TASK", [47] = "Q_WR_TASK", + [48] = "READ_EXTR_SINGLE", [49] = "WRITE_EXTR_SINGLE", + [50] = "SW_FUNC_RSVD", + [52] = "IO_RW_DIRECT", [53] = "IO_RW_EXTENDED", + [54] = "SDIO_RSVD", [55] = "APP_CMD", + [56] = "GEN_CMD", [57] = "SW_FUNC_RSVD", + [58] = "READ_EXTR_MULTI", [59] = "WRITE_EXTR_MULTI", + [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", + [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", + }; + return cmd_abbrev[cmd] ? cmd_abbrev[cmd] : "UNKNOWN_CMD"; +} + +static const char *sd_acmd_name(uint8_t cmd) +{ + static const char *acmd_abbrev[SDMMC_CMD_MAX] = { + [6] = "SET_BUS_WIDTH", + [13] = "SD_STATUS", + [14] = "DPS_spec", [15] = "DPS_spec", + [16] = "DPS_spec", + [18] = "SECU_spec", + [22] = "SEND_NUM_WR_BLOCKS", [23] = "SET_WR_BLK_ERASE_COUNT", + [41] = "SD_SEND_OP_COND", + [42] = "SET_CLR_CARD_DETECT", + [51] = "SEND_SCR", + [52] = "SECU_spec", [53] = "SECU_spec", + [54] = "SECU_spec", + [56] = "SECU_spec", [57] = "SECU_spec", + [58] = "SECU_spec", [59] = "SECU_spec", + }; + + return acmd_abbrev[cmd] ? acmd_abbrev[cmd] : "UNKNOWN_ACMD"; +} + static uint8_t sd_get_dat_lines(SDState *sd) { return sd->enable ? sd->dat_lines : 0; diff --git a/hw/sd/sdmmc-internal.c b/hw/sd/sdmmc-internal.c deleted file mode 100644 index c1d5508ae6..0000000000 --- a/hw/sd/sdmmc-internal.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SD/MMC cards common helpers - * - * Copyright (c) 2018 Philippe Mathieu-Daudé - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "qemu/osdep.h" -#include "sdmmc-internal.h" - -const char *sd_cmd_name(uint8_t cmd) -{ - static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [0] = "GO_IDLE_STATE", [1] = "SEND_OP_COND", - [2] = "ALL_SEND_CID", [3] = "SEND_RELATIVE_ADDR", - [4] = "SET_DSR", [5] = "IO_SEND_OP_COND", - [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", - [8] = "SEND_IF_COND", [9] = "SEND_CSD", - [10] = "SEND_CID", [11] = "VOLTAGE_SWITCH", - [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", - [15] = "GO_INACTIVE_STATE", - [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", - [18] = "READ_MULTIPLE_BLOCK", [19] = "SEND_TUNING_BLOCK", - [20] = "SPEED_CLASS_CONTROL", [21] = "DPS_spec", - [23] = "SET_BLOCK_COUNT", - [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", - [26] = "MANUF_RSVD", [27] = "PROGRAM_CSD", - [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", - [30] = "SEND_WRITE_PROT", - [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", - [34] = "SW_FUNC_RSVD", [35] = "SW_FUNC_RSVD", - [36] = "SW_FUNC_RSVD", [37] = "SW_FUNC_RSVD", - [38] = "ERASE", - [40] = "DPS_spec", - [42] = "LOCK_UNLOCK", [43] = "Q_MANAGEMENT", - [44] = "Q_TASK_INFO_A", [45] = "Q_TASK_INFO_B", - [46] = "Q_RD_TASK", [47] = "Q_WR_TASK", - [48] = "READ_EXTR_SINGLE", [49] = "WRITE_EXTR_SINGLE", - [50] = "SW_FUNC_RSVD", - [52] = "IO_RW_DIRECT", [53] = "IO_RW_EXTENDED", - [54] = "SDIO_RSVD", [55] = "APP_CMD", - [56] = "GEN_CMD", [57] = "SW_FUNC_RSVD", - [58] = "READ_EXTR_MULTI", [59] = "WRITE_EXTR_MULTI", - [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", - [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", - }; - return cmd_abbrev[cmd] ? cmd_abbrev[cmd] : "UNKNOWN_CMD"; -} - -const char *sd_acmd_name(uint8_t cmd) -{ - static const char *acmd_abbrev[SDMMC_CMD_MAX] = { - [6] = "SET_BUS_WIDTH", - [13] = "SD_STATUS", - [14] = "DPS_spec", [15] = "DPS_spec", - [16] = "DPS_spec", - [18] = "SECU_spec", - [22] = "SEND_NUM_WR_BLOCKS", [23] = "SET_WR_BLK_ERASE_COUNT", - [41] = "SD_SEND_OP_COND", - [42] = "SET_CLR_CARD_DETECT", - [51] = "SEND_SCR", - [52] = "SECU_spec", [53] = "SECU_spec", - [54] = "SECU_spec", - [56] = "SECU_spec", [57] = "SECU_spec", - [58] = "SECU_spec", [59] = "SECU_spec", - }; - - return acmd_abbrev[cmd] ? acmd_abbrev[cmd] : "UNKNOWN_ACMD"; -} diff --git a/hw/sd/meson.build b/hw/sd/meson.build index abfac9e461..bbb75af0c9 100644 --- a/hw/sd/meson.build +++ b/hw/sd/meson.build @@ -1,5 +1,5 @@ system_ss.add(when: 'CONFIG_PL181', if_true: files('pl181.c')) -system_ss.add(when: 'CONFIG_SD', if_true: files('sd.c', 'core.c', 'sdmmc-internal.c')) +system_ss.add(when: 'CONFIG_SD', if_true: files('sd.c', 'core.c')) system_ss.add(when: 'CONFIG_SDHCI', if_true: files('sdhci.c')) system_ss.add(when: 'CONFIG_SDHCI_PCI', if_true: files('sdhci-pci.c')) system_ss.add(when: 'CONFIG_SSI_SD', if_true: files('ssi-sd.c')) From patchwork Fri Jun 28 07:01:13 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: 808192 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224123wrr; Fri, 28 Jun 2024 00:11:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWt+6D8yfI3SJZ/tquqXJ5wpejRMZClYoEI67V9VnXKXX9enRynyX6JPO8SsvaOwMvrNVA41rk0DndjZ7l8umd8 X-Google-Smtp-Source: AGHT+IG2WhuFxYhui+SRhqV9D/a27xzprtRrelpZ9UFxeDlhwR6Z3v4hwtoHoTXg7S3ahsfeS4nD X-Received: by 2002:ad4:51d1:0:b0:6b5:6c27:642e with SMTP id 6a1803df08f44-6b58d36d088mr57037746d6.14.1719558669353; Fri, 28 Jun 2024 00:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558669; cv=none; d=google.com; s=arc-20160816; b=LIW/l+oaeSIQiQCQrqYd/QF/s3QaFGodSZsYTm79l2Ipv+1W6tLAfZU3s4Doy4K6ts q/0OXchPuwAnxaQ6w0eqU+y4w8VPVK8essqdu1JdrsohJLUun3sKSvDNT6mRkxJ301Rg Xw1GVqtgiRpUv/zHQcbAF+IrbhdIONY59l4gUwrH4aEQm7AdZDbsVZvYOryQpoF1Mm+Q Z0rYX9ohmMmmeCXqe6JBIxcX5KjP7z0nhPPqeEvKyG9HYD4RvkBBp2CVdbJXR32oe6vm kfLKACJw+QvCbA8N2h6w1AqVbcBwkpgUJP3/p8NmRAoR4sspBLSMJHfoLXWDvIP0oJZi +M/w== 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:to:from :dkim-signature; bh=0hugKoDWkNwghwH1h1z7n8tbSuuJya6Cw/1S35GizWg=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=fXJx12RsxUtkN1CiATG2YRyS3Jn9xcK1qhK+PafRB2pgeXHZ3gKZ6HIEtp4RAO9mBY F2SvPuqszSPRSOO1fNbbmgzvVmMDabDaDDX0tp0uC+Oo/ScMi+t9KV3bdyHh5HDhx4H/ 8AlSEiaYtIGqHwVrNL9V8Wtl8VHdVTZ2wdQMihbmy4TWXyFN5ia1hhtURR693o/u5KQ1 skVrfChfNiXFgs+rLCCq1YPI7JZUUx3qpHlTRFnO7W47/ux9NT8NClTla0zT1Ocfsc3N y1JrydQz5WyZqGKx4lp+I9g5jHqkLrJAMZo1ApjSeeGc24UVMbXUBHTZTuoE+r5L8FA8 Dqig==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cRbm9ftM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e5ea61csi13504226d6.316.2024.06.28.00.11.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:11:09 -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=cRbm9ftM; 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 1sN5gM-000153-DW; Fri, 28 Jun 2024 03:06:06 -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 1sN5gK-0000rv-EX for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:04 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5gI-0003EU-NI for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:04 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-424ad991cbbso2790895e9.0 for ; Fri, 28 Jun 2024 00:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558361; x=1720163161; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0hugKoDWkNwghwH1h1z7n8tbSuuJya6Cw/1S35GizWg=; b=cRbm9ftMDYVRnJz+b3/hAHqI86esAAZBfX6+mdzwrrNSZO+MBABY/K5DE50e0baKQz eS+gtfpan1qe+szqLnvnIoZJIMcJnfQauApX7HFmteOxhd9cP7JQ99e4KatATCNWYCen auHVU1Vf4EMNSIStgmmn1y7GJihT7TGUMbaCFYF5whZ1WADffcA2Dxq0xHBpMKjJapDJ KhFtXBEOkuzlmzK3M/J/DCsP72O1U0INz9o1F3TBlh4naIzj1HgsPus7nXzirWltbOjF QbChvgwmpw2hvG6qxiC2luApgjl5t7L57q3iL4iskXEk7ECahNQfO+m4ZeTtDelf7bOa T3aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558361; x=1720163161; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0hugKoDWkNwghwH1h1z7n8tbSuuJya6Cw/1S35GizWg=; b=ThF41dRUu3pYL/zXWf4BKK/t+cYy720xRrX/a89G6mMJQWXoynYSVBydJG+mCU2Ghs wchjhUtYueS5z+zkK7Eijhi5HJeXiQzzxjunCXMp4EsHuo8BoGt/YXTisy7cpaoFSqXY PxpnhTI1+d63OFz444HALue1LiUqrSx1wrYFCnJXxlriLbO2Lv3ZoVTSqj/wdh+HoiXF 6o3O9dukvnw1v0U+hFx7/bXMQozMx4aLfBQrhT4au7yNFJ2p6f8Ut99TEf5gh24lUv6K L8jDTw5X9EpqTvpwn/+2/NO1HNDLDnAlJmEdaLEH4X1AzCUO0t6+PjKRgwRsz0ZVjuu6 cEbQ== X-Gm-Message-State: AOJu0Yxy4WWQSfSjlzXTzpy+111fxTqnGTfkM8W6okj+/cxS0XKWx3PW 8kzDSFu/lIg+/NBC+0HhyyibOcf1lODi2CnzPxWzi7BKV9pUSSA4YCDS6f7tW/lIuK7sVHRtBtC wi3o= X-Received: by 2002:a05:6000:481e:b0:366:f994:33c with SMTP id ffacd0b85a97d-366f99403eamr9080089f8f.56.1719558360773; Fri, 28 Jun 2024 00:06:00 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a103d62sm1319479f8f.105.2024.06.28.00.05.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:06:00 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 37/98] hw/sd/sdcard: Pass SDState as argument to sd_[a]cmd_name() Date: Fri, 28 Jun 2024 09:01:13 +0200 Message-ID: <20240628070216.92609-38-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 In order to access SDState::SDProto from sd_[a]cmd_name(), pass SDState as argument. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 93a4a4e1b4..f4bdd12b26 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -233,7 +233,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) return response_name[rsp]; } -static const char *sd_cmd_name(uint8_t cmd) +static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { [0] = "GO_IDLE_STATE", [1] = "SEND_OP_COND", @@ -272,7 +272,7 @@ static const char *sd_cmd_name(uint8_t cmd) return cmd_abbrev[cmd] ? cmd_abbrev[cmd] : "UNKNOWN_CMD"; } -static const char *sd_acmd_name(uint8_t cmd) +static const char *sd_acmd_name(SDState *sd, uint8_t cmd) { static const char *acmd_abbrev[SDMMC_CMD_MAX] = { [6] = "SET_BUS_WIDTH", @@ -1281,7 +1281,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) uint64_t addr; uint32_t data; - sd->last_cmd_name = sd_cmd_name(req.cmd); + sd->last_cmd_name = sd_cmd_name(sd, req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. * However there is no ACMD55, so we want to trace this particular case. */ @@ -1748,7 +1748,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) static sd_rsp_type_t sd_app_command(SDState *sd, SDRequest req) { - sd->last_cmd_name = sd_acmd_name(req.cmd); + sd->last_cmd_name = sd_acmd_name(sd, req.cmd); trace_sdcard_app_command(sd->proto->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); sd->card_status |= APP_CMD; From patchwork Fri Jun 28 07:01:14 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: 808195 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224375wrr; Fri, 28 Jun 2024 00:11:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVZZYdCB4SzrWGtgC/kIgzBLQQ2VCgeDJf9Dh37v7s9G3zhxIAv86oo/L271EYyunSSpuF0WTnstfZpjQRdnGl/ X-Google-Smtp-Source: AGHT+IG0bEisqnKwVPSN20WGG9U9ToqEOk/d9bQD1vidbVvPi5jl5C83um+fzrDy3WxC60d3w16F X-Received: by 2002:ac8:570d:0:b0:441:2a9:4d12 with SMTP id d75a77b69052e-444d648230fmr204057681cf.23.1719558718979; Fri, 28 Jun 2024 00:11:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558718; cv=none; d=google.com; s=arc-20160816; b=yxINQFDhJY9DU4xYdcm6yFwVwPfoWSQvyE2Cf/ky+lcj58ClaierOOlEgcr/Dukw4G PPZg4rgNhD5sY5nsy1NhNweAg0sYBErespWiMZDqT4VGT+niX4cO2Ea3htO3gnQIcKDI ZQGXqb8+od5VqsI71gXqxJCvpa3qdmDtPyj8DGUmdybx8GoFrRXFG7RhQ1oXmTWLiqJj SPKWJTUu2JyUcXAJhhWzQDg7ac23FePb7ieF6aNnkEXsQVVtiFmrYZlS6Xg8R0CtW25e 8SsVBQl9OWGcUTLX9e9+ImvYF1iWfD4RKUhenk+k1L3J4IF1/VhEL+9lS9ucuQpsI6dd 5AlA== 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:to:from :dkim-signature; bh=/ayYPHbFG82day0p5Ydj8QW5gkkALIElfBxZi1L4r4c=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=0jWpQbVHy1jfjewhKdx3KtByIHwRG+chgDZn0DmnM1Xxs1+ShXGEL3whzQgrGfq5eh Rseh3EmI2a7g0uaf1hHl1d/x07y7t8IipAe7rXtEUQlqsF6qMFHifVuUzdu1flPjsYZe 5f3oMB53QWsbjTwwO5UBGyCiGCQIJlptWaZCeubpjxQpQZOvEYeifVRYpzuXLyBjEImP jRFZfIbXTCjC8pL4CoPtyNdGwyOXS22MLlyXI8yVfgfLYlc5ooJWgNNl388ULPV1M4tm qFUfaAoGaF0W57Fxvm6PiFwSOkYc/a+HsDh2WWd/CkXR8pwLk2K/jxyXqqw+p8vJHDo0 41xw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S1LhNJAP; 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-446514e2324si13114291cf.711.2024.06.28.00.11.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:11:58 -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=S1LhNJAP; 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 1sN5gR-0001sx-D4; Fri, 28 Jun 2024 03:06:11 -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 1sN5gP-0001aL-De for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:09 -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 1sN5gN-0003Eu-Hq for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:09 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4217c7eb6b4so2621925e9.2 for ; Fri, 28 Jun 2024 00:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558366; x=1720163166; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/ayYPHbFG82day0p5Ydj8QW5gkkALIElfBxZi1L4r4c=; b=S1LhNJAPhNNqx3GkHfS1D0O7ub0hDsYWKJP5EC7VbPbcR3DMuf/tZjz8AXTeHuvrzN wJ410RKo0macjOs3MU4rranuXRqSD3LaGYIBXVLdg6wBF3GDUUDAsKhUn909EbZyp81a xFQ8Bsx2A+gWBJ34cl/gURArbxL4Di/XndfcQk4Zmlrj/8mBwJd6JHYLEzW4hNc8/6YA S+m87tqccCTIuWVPV7b3w6DbEryStF328oWXY8Snag4UIxrtcaogSZpiOD9+sbEowYo1 Qo30iS99DoaeHV6Wgb6BcyYWv9qUnROBpPcXX+s+3ktLjlicQd//jibOMumEfBcR0wg5 TaIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558366; x=1720163166; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/ayYPHbFG82day0p5Ydj8QW5gkkALIElfBxZi1L4r4c=; b=xC6HG+DwOS9SBUt2Ntsv1SxkJFZ6BIxaYYCLB0+CGDwcdvOlnA9LL0WfqinHml/7UC pNpc3FUrDNdsxHB8qXM3dOWW9jx3xD7UnyWQ/xxwiYuvawUW3g3qZScfzyV+h+irP3KI hbJGprlpxhUJy3GlZm1QgwFB5Wj+o9VSOnEXQ6FsAHRwb5vMH7HINgX6aH2vcRhrY7eO wTmpo1YqJvmbYd83m8VAY9YyYzKxCmdwkUD94S16JE5vV+UNTEMBxnD5vz8aqQthTKt6 iQodEZ1bQ6idZ8yeNDpYH/WCEYtTvoPv5RXRodhtBIgA7OOPHHR/xEpeQg67F13ZKIsP +vKg== X-Gm-Message-State: AOJu0YzXJvCGrhNnF682BSo8gKUqtIGspw+02/Co2AmBIvIH/YQMLu9D YDJAZinDGRQvO5fO8lLl+48ICLX+cYm90jdJMlRgUjP/ybj1IwZN9u1GSnDJ/7yN1Z3YGdRQ4Xs h0ro= X-Received: by 2002:a05:600c:12c5:b0:425:5fe5:f273 with SMTP id 5b1f17b1804b1-4255fe5f3d0mr44347045e9.26.1719558365759; Fri, 28 Jun 2024 00:06:05 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09a681sm21184815e9.30.2024.06.28.00.06.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:06:05 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 38/98] hw/sd/sdcard: Prepare SDProto to contain more fields Date: Fri, 28 Jun 2024 09:01:14 +0200 Message-ID: <20240628070216.92609-39-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Convert array of command handlers to array of structures. The structure contains the command handler. No logical change intended. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index f4bdd12b26..558c39419d 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -94,8 +94,9 @@ typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); typedef struct SDProto { const char *name; - sd_cmd_handler cmd[SDMMC_CMD_MAX]; - sd_cmd_handler acmd[SDMMC_CMD_MAX]; + struct { + sd_cmd_handler handler; + } cmd[SDMMC_CMD_MAX], acmd[SDMMC_CMD_MAX]; } SDProto; struct SDState { @@ -1305,8 +1306,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_illegal; } - if (sd->proto->cmd[req.cmd]) { - return sd->proto->cmd[req.cmd](sd, req); + if (sd->proto->cmd[req.cmd].handler) { + return sd->proto->cmd[req.cmd].handler(sd, req); } switch (req.cmd) { @@ -1753,8 +1754,8 @@ static sd_rsp_type_t sd_app_command(SDState *sd, req.cmd, req.arg, sd_state_name(sd->state)); sd->card_status |= APP_CMD; - if (sd->proto->acmd[req.cmd]) { - return sd->proto->acmd[req.cmd](sd, req); + if (sd->proto->acmd[req.cmd].handler) { + return sd->proto->acmd[req.cmd].handler(sd, req); } switch (req.cmd) { @@ -2267,22 +2268,22 @@ void sd_enable(SDState *sd, bool enable) static const SDProto sd_proto_spi = { .name = "SPI", .cmd = { - [0] = sd_cmd_GO_IDLE_STATE, - [1] = spi_cmd_SEND_OP_COND, + [0] = {sd_cmd_GO_IDLE_STATE}, + [1] = {spi_cmd_SEND_OP_COND}, }, .acmd = { - [41] = spi_cmd_SEND_OP_COND, + [41] = {spi_cmd_SEND_OP_COND}, }, }; static const SDProto sd_proto_sd = { .name = "SD", .cmd = { - [0] = sd_cmd_GO_IDLE_STATE, - [2] = sd_cmd_ALL_SEND_CID, - [3] = sd_cmd_SEND_RELATIVE_ADDR, - [19] = sd_cmd_SEND_TUNING_BLOCK, - [23] = sd_cmd_SET_BLOCK_COUNT, + [0] = {sd_cmd_GO_IDLE_STATE}, + [2] = {sd_cmd_ALL_SEND_CID}, + [3] = {sd_cmd_SEND_RELATIVE_ADDR}, + [19] = {sd_cmd_SEND_TUNING_BLOCK}, + [23] = {sd_cmd_SET_BLOCK_COUNT}, }, }; From patchwork Fri Jun 28 07:01:15 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: 808182 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223418wrr; Fri, 28 Jun 2024 00:08:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX822Ka3cbIwH3XtYN0RvgDpLdvqiaOQNU5IXy5LRliOLdggS4wi7zguNrzQtjjBcBTg6hIYsNNFZFygY3JCP6k X-Google-Smtp-Source: AGHT+IFcbiTa2vRzzFXSfCtLgRQ/s8zDxZ0XyEXSk0BUoKse4+j9UEdmSkjptuUCo6NjGLEIDkZo X-Received: by 2002:a25:ae49:0:b0:de6:dcd:20ae with SMTP id 3f1490d57ef6-e0303f7d1d1mr15876758276.27.1719558535331; Fri, 28 Jun 2024 00:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558535; cv=none; d=google.com; s=arc-20160816; b=kwLNNi5ADyu1Tb/tWhXjJugZB9nYkyeNO9NDvO2fnaa9LPR3p28HJQMVmofR1/IinL XzVBTF6FCSHwwbDI0IBATjXESBXJY4ZdkFFcYMm5SumFK6z2u2MW7PaMFYNxe7V10AK+ uIFgnjxpmWaq5CxUtVsqvpztsxsvVeKWIcVE5TcgmJHcXh3Uhkga3VuKSxOR0xnhgjO0 jsW9dKbtKf5cAFcf9nEoPvfcQuzgpwzAgPW+tfcqxy8gaFXEjOb48PoN3wOKGrOzssyV 1wa6KxEf9s7ajgBbHYIhj1xYohExXSzSLnbmQP/Pt2eDCB6bS6C/TMvkUhq54xGiVCEX 667g== 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:to:from :dkim-signature; bh=YXDu/2edCnmMgqMgCJOWOkUUywr5VZFDkGviAHlkFf4=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=ekbN2oP5qNLD5g0Wo5K7V4XR8mvbvksWMoKOR0rZVFIQPg13LhcMrlk2eMnO2wB+RO sQkpdOOhdqarIfn9kdeVHWCH9MN98SqgvGF92a5vGxStVolozthZ4KsGi6BAuDiynjuv AhgaC/CyhjcFoAYoS41Vuq6f6twP3wn6Jx7+sumJISDFt/7uc/Wdsx0znNAP7JgHun2q u265W7AFUxgclU8sGYFXyffluaOrpiJoNiKoUaoeVVWgK+1kO/qQ17kSAIrcRSbH/CnM QThtwDs9ULNacoez2M0uBsNR11JiTUdcyCgDAsV2pOsgJFUnSghWEemVKawCfoOkjWzs vDkg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t7i690C6; 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-44651485bf2si12921621cf.355.2024.06.28.00.08.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:08:55 -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=t7i690C6; 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 1sN5ge-0002IW-9E; Fri, 28 Jun 2024 03:06:26 -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 1sN5gU-0002DG-Di for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:14 -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 1sN5gS-0003FA-HX for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:14 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-424ad991c1cso3220925e9.1 for ; Fri, 28 Jun 2024 00:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558371; x=1720163171; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=YXDu/2edCnmMgqMgCJOWOkUUywr5VZFDkGviAHlkFf4=; b=t7i690C67proAEGDgD8xqjwOXctJ/El611+/kU+nH5vEMfn1HBs0ix4Nsyaky3Qs9H 1MHEk/x6/5/6A5csVd0TRpxGLnollQyzo1L+o09+Y/thI+4Ce0DJzw5iFZ/w7evZxphu l+HwA1utOwcShPDg6AzcAsuZ6uipGVCPt6rh9JIEC1WguwoQ6YIdNFXEKmeccrxrCHWG 3CuWCTdVEhfX4exob8aWhHMaiu18F0YCdd6aOFva8pctss5plOcAqm8MVfRRsU28kEfN jrsDyzuNExjzyXMoE+P8iBLBE6lTyhHMj4TZ5+N9EGe+jahsCtVjUfBapp5zSxcHKYHa NL2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558371; x=1720163171; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YXDu/2edCnmMgqMgCJOWOkUUywr5VZFDkGviAHlkFf4=; b=T2UCOwrSOnsSWZjztGGBAK7lSLzHqqzGBHQ8QDhLlekoSR7HqgoqMDhXhT3TzYBRov +1gvh3x8Xs6ITVO1uZ6+3CuJj2u+7HaJf/HBPkxNnUAkoOxqYBYXwLgvSzygQWW0lctD DUXhZYb3TAfwmLMbDpops+mYTwOsIPfMk4FxPr1u8xur51j2M2R9uXKz9tmNHUr3ni9d uzKEoNXHu6QE/7qoQikNcDR935YMx0vNVUCSMlxdFh4OuqvhixZzbSBHgKXEM8Qg2GC8 iW/J0mGhclVbFVEtCCJ5aGBnBbPhScT2TNrv5plHU07V1hTLayMYgXB4iY2BHzSkVu7c pokg== X-Gm-Message-State: AOJu0YxSQ2KYuuueWVr2/G60pUUtVVtO6fmwG6aTP8woiIEsXcNso5ct +QsyZRJE1OXK8Tgdv8d5krlFcIk/4kKb/vZrRbu0TOwtjmF59w4gPrBCguEpZ+wWYcR3EZoyOcx en0k= X-Received: by 2002:a05:600c:3386:b0:424:aa35:9fb9 with SMTP id 5b1f17b1804b1-424aa35a106mr70402335e9.2.1719558370775; Fri, 28 Jun 2024 00:06:10 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3cf90sm21615535e9.5.2024.06.28.00.06.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:06:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 39/98] hw/sd/sdcard: Store command name in SDProto Date: Fri, 28 Jun 2024 09:01:15 +0200 Message-ID: <20240628070216.92609-40-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 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=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 We already have a const array where command handlers are listed. Store the command name there too. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 558c39419d..97fb3785ee 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -95,6 +95,7 @@ typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); typedef struct SDProto { const char *name; struct { + const char *name; sd_cmd_handler handler; } cmd[SDMMC_CMD_MAX], acmd[SDMMC_CMD_MAX]; } SDProto; @@ -237,8 +238,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [0] = "GO_IDLE_STATE", [1] = "SEND_OP_COND", - [2] = "ALL_SEND_CID", [3] = "SEND_RELATIVE_ADDR", [4] = "SET_DSR", [5] = "IO_SEND_OP_COND", [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", [8] = "SEND_IF_COND", [9] = "SEND_CSD", @@ -246,9 +245,8 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", - [18] = "READ_MULTIPLE_BLOCK", [19] = "SEND_TUNING_BLOCK", + [18] = "READ_MULTIPLE_BLOCK", [20] = "SPEED_CLASS_CONTROL", [21] = "DPS_spec", - [23] = "SET_BLOCK_COUNT", [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", [27] = "PROGRAM_CSD", [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", @@ -270,6 +268,12 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", }; + const SDProto *sdp = sd->proto; + + if (sdp->cmd[cmd].handler) { + assert(!cmd_abbrev[cmd]); + return sdp->cmd[cmd].name; + } return cmd_abbrev[cmd] ? cmd_abbrev[cmd] : "UNKNOWN_CMD"; } @@ -282,7 +286,6 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [16] = "DPS_spec", [18] = "SECU_spec", [22] = "SEND_NUM_WR_BLOCKS", [23] = "SET_WR_BLK_ERASE_COUNT", - [41] = "SD_SEND_OP_COND", [42] = "SET_CLR_CARD_DETECT", [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", @@ -290,6 +293,12 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [56] = "SECU_spec", [57] = "SECU_spec", [58] = "SECU_spec", [59] = "SECU_spec", }; + const SDProto *sdp = sd->proto; + + if (sdp->acmd[cmd].handler) { + assert(!acmd_abbrev[cmd]); + return sdp->acmd[cmd].name; + } return acmd_abbrev[cmd] ? acmd_abbrev[cmd] : "UNKNOWN_ACMD"; } @@ -2268,22 +2277,22 @@ void sd_enable(SDState *sd, bool enable) static const SDProto sd_proto_spi = { .name = "SPI", .cmd = { - [0] = {sd_cmd_GO_IDLE_STATE}, - [1] = {spi_cmd_SEND_OP_COND}, + [0] = { "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [1] = { "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, .acmd = { - [41] = {spi_cmd_SEND_OP_COND}, + [41] = { "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; static const SDProto sd_proto_sd = { .name = "SD", .cmd = { - [0] = {sd_cmd_GO_IDLE_STATE}, - [2] = {sd_cmd_ALL_SEND_CID}, - [3] = {sd_cmd_SEND_RELATIVE_ADDR}, - [19] = {sd_cmd_SEND_TUNING_BLOCK}, - [23] = {sd_cmd_SET_BLOCK_COUNT}, + [0] = { "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [2] = { "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [3] = { "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, + [19] = { "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, + [23] = { "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, }, }; From patchwork Fri Jun 28 07:01:16 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: 808190 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223805wrr; Fri, 28 Jun 2024 00:10:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVvXHumYeqjwX1neeOfoe55Jk2GguePyKfd/ZruHydumTc5T+6XL/QWQa2IwvD5E1mCdl++1tCxB25NDblfm2OM X-Google-Smtp-Source: AGHT+IFRUnmMuK5Y6SEpQLsQFoUiedhN3NAT+h47zthG1z2ssClf55IIuJHbgAiVkTcG1VouWxLu X-Received: by 2002:a05:6214:242e:b0:6b5:5687:8f7a with SMTP id 6a1803df08f44-6b5a545b318mr13862086d6.21.1719558605499; Fri, 28 Jun 2024 00:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558605; cv=none; d=google.com; s=arc-20160816; b=uqQ8cCU3U70U7CMaQXqv/d0LhlbnYZOuiBdClYK+SAM+xCrQqbEnhyYuhgijq5sTcc aruM4LcSj0l99Zw3EnQMxoX0DVvcWbTlOAVO3eKMKBhpHb4Rl5AFszNFruUUx4eobCoL 59TMz6rIzhnDxcJ32FZ+r8miewUjSlX/Ewn1ZB9zTw0/Dk0fetkJ9CXAwlejCVy73OvT jJzYS4Th7x74YRTqv9rRW9QpgaV76LZxjwhL5SMAOo806ozcBrOjb6tM7JhbX2s7Q+kR +fDBw9jfuhz+gnfWfUYGV53fGMS4bmH3M6EUU7KQGJ59NWzK3VtidobBJjLJwZjXkim4 4pCA== 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:to:from :dkim-signature; bh=FQYmSrnXt5mY866BTgrOijDYx76JFvHs12wH0ygKj7I=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=FcERBfsZSd5wMqz260rLB0fZac3XwZjBUMp24M6hrpk5ZUaj1bTGoWpjhnECCUrbel LOtNgmqh2+JWM73aphBo4ugvqCOD0icC67/byCFBDZvHhA0pGbfu1asPf8N0QFvwqJLB X06DYL5iSeP+k3iPdoG6p2ADDXhmCzWvyAHaC0I/RuzNO1fAK1QtXWEFFJgRZMJjEwBf C6iFxPriZIztpms6zW1MPZJo2bjjaZm/Xg8SPK1Ad2kTQISZ5WribFBcFpAEuXHAf97X 6R/5pUftRZHm7G2FrCQl8YEorzX1VWRpaWD0pJmoiYG4N3ovMcLycbodf0Whl36x+fHX 3+qw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TZxUyhwA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e618646si13702706d6.583.2024.06.28.00.10.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:10:05 -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=TZxUyhwA; 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 1sN5go-0002i7-V0; Fri, 28 Jun 2024 03:06: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 1sN5ga-0002KM-A4 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:22 -0400 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5gY-0003Fk-Cb for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:20 -0400 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2ec10324791so2203441fa.1 for ; Fri, 28 Jun 2024 00:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558376; x=1720163176; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=FQYmSrnXt5mY866BTgrOijDYx76JFvHs12wH0ygKj7I=; b=TZxUyhwATKwfwTVrYupmg4bwOOQyQkP0CjqetVsvXTlAs5RuZzXfMRUjCh2IS1u2eY 2wGPCg5JxZtjgiHnZ7Rh6/OpmtOSyVunb2eEKhJI8lVQYRIxOUEitRaLDrrsVa6Laq7S 5zwk5nAWI8gHE5u1fpWSBOsZgKtagixvKLLhtoVNhKs+Qhe7yZyp4jjUqnZVKl+kKoOt 41S4wIwhHnEsUjQWFPIGj2DPiDRp53XeAndV601sDdXbm+OjooVl5fX9+M+xPxdmTazn Ab8+VGtKGRCePxawpypRejx0x4I9soAUGUZMueVu+mUMv1LxOzvuX5TgW61nsTj5+m8Q 7I5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558376; x=1720163176; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FQYmSrnXt5mY866BTgrOijDYx76JFvHs12wH0ygKj7I=; b=GII1PvAYbti2jIKUBHTyo7ab4wStBHGhMd1K8GfuAITX5xBVUmQLOwD2FpPKSL+mRK ib6Wh8oEOUlF/wlEuBZ1V77lnlhpgq0/85cgWLDE6vglFfhmamLlEFhyVOLwkEciryoa k3gdMjB8pCmB7stM03+Ag8nuv2LChwar9r1iHIHaRQ4QsTrFGwI+M2dIUspe2lHZfbVg ENMJAyYOKqf49JzRfeL9erlhIqDxLTmXAEtFFpABXLn6vILVz3gk1oxyqR5eStzk/4L+ i+gWPaoHMm/32/dW88HaEGKM2O0bFuBzxBWVRPix0220zhYyxxArD/x9ZVtq/UEWFMcf 6jNA== X-Gm-Message-State: AOJu0YzNxEsFL4tdXfTd5rDQRMNVz+/hC6vTc2Sm8h6UoNio55CtYUZw tzzBIBtT8cZYvw90Yruqw93qRb9kzpA6vjuaQLQWYyC4l0A0CD5EIfS9xzsiJingrSCQQnd3Iey Rpk0= X-Received: by 2002:a2e:9985:0:b0:2ec:5128:1850 with SMTP id 38308e7fff4ca-2ec5b27e720mr92735051fa.13.1719558375878; Fri, 28 Jun 2024 00:06:15 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09a2bcsm21072595e9.36.2024.06.28.00.06.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:06:15 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 40/98] hw/sd/sdcard: Store command type in SDProto Date: Fri, 28 Jun 2024 09:01:16 +0200 Message-ID: <20240628070216.92609-41-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=philmd@linaro.org; helo=mail-lj1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Store the command type altogether with the command handler and name. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- include/hw/sd/sd.h | 5 +++-- hw/sd/sd.c | 44 ++++++++++++++++++++------------------------ 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index 2c8748fb9b..29c76935a0 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -76,8 +76,9 @@ typedef enum { } sd_uhs_mode_t; typedef enum { - sd_none = -1, - sd_bc = 0, /* broadcast -- no response */ + sd_none = 0, + sd_spi, + sd_bc, /* broadcast -- no response */ sd_bcr, /* broadcast with response */ sd_ac, /* addressed -- no data transfer */ sd_adtc, /* addressed with data transfer */ diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 97fb3785ee..c4cc48926d 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -95,6 +95,7 @@ typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); typedef struct SDProto { const char *name; struct { + const sd_cmd_type_t type; const char *name; sd_cmd_handler handler; } cmd[SDMMC_CMD_MAX], acmd[SDMMC_CMD_MAX]; @@ -351,20 +352,6 @@ static void sd_set_mode(SDState *sd) } } -static const sd_cmd_type_t sd_cmd_type[SDMMC_CMD_MAX] = { - sd_bc, sd_none, sd_bcr, sd_bcr, sd_none, sd_none, sd_none, sd_ac, - sd_bcr, sd_ac, sd_ac, sd_adtc, sd_ac, sd_ac, sd_none, sd_ac, - /* 16 */ - sd_ac, sd_adtc, sd_adtc, sd_none, sd_none, sd_none, sd_none, sd_none, - sd_adtc, sd_adtc, sd_adtc, sd_adtc, sd_ac, sd_ac, sd_adtc, sd_none, - /* 32 */ - sd_ac, sd_ac, sd_none, sd_none, sd_none, sd_none, sd_ac, sd_none, - sd_none, sd_none, sd_bc, sd_none, sd_none, sd_none, sd_none, sd_none, - /* 48 */ - sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_ac, - sd_adtc, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, -}; - static const int sd_cmd_class[SDMMC_CMD_MAX] = { 0, 0, 0, 0, 0, 9, 10, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 6, 6, 6, 6, @@ -571,10 +558,19 @@ static void sd_set_rca(SDState *sd, uint16_t value) static uint16_t sd_req_get_rca(SDState *s, SDRequest req) { - if (sd_cmd_type[req.cmd] == sd_ac || sd_cmd_type[req.cmd] == sd_adtc) { + switch (s->proto->cmd[req.cmd].type) { + case sd_none: + /* Called from legacy code not ported to SDProto array */ + assert(!s->proto->cmd[req.cmd].handler); + /* fall-through */ + case sd_ac: + case sd_adtc: return req.arg >> 16; + case sd_spi: + g_assert_not_reached(); + default: + return 0; } - return 0; } /* Card Status register */ @@ -2277,22 +2273,22 @@ void sd_enable(SDState *sd, bool enable) static const SDProto sd_proto_spi = { .name = "SPI", .cmd = { - [0] = { "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, - [1] = { "SEND_OP_COND", spi_cmd_SEND_OP_COND}, + [0] = { sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [1] = { sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, .acmd = { - [41] = { "SEND_OP_COND", spi_cmd_SEND_OP_COND}, + [41] = { sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; static const SDProto sd_proto_sd = { .name = "SD", .cmd = { - [0] = { "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, - [2] = { "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, - [3] = { "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, - [19] = { "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, - [23] = { "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [0] = { sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [2] = { sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [3] = { sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, + [19] = { sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, + [23] = { sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, }, }; From patchwork Fri Jun 28 07:01:17 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: 808180 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223234wrr; Fri, 28 Jun 2024 00:08:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW+Krq36WAs+K1JfKkXmgEBG7btdxUXXT2o6ourb3GCjpzx1dBRHwHcvxuTHIUQaW//xFnjCVvxwZT6FreMA+5e X-Google-Smtp-Source: AGHT+IESHD6b3vduvJIWCuxFqWrVy38a699vlZAXYmabUdUOxhKj4sGD4iS7Axht/gwqid+6Uf4J X-Received: by 2002:a05:622a:11c1:b0:441:788:908 with SMTP id d75a77b69052e-444d922e72cmr152348551cf.66.1719558501174; Fri, 28 Jun 2024 00:08:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558501; cv=none; d=google.com; s=arc-20160816; b=R+PdoT0Hqprdn1BpqIHQwjpNgES/34imFDsZvG21lL/Hs/vnAHNPJc2izgzfHLiys+ w6cNBJGxPmsKklJYASatzxHHZpg/Dz6ZhkKBcPeLmV+ElRLsJ2aZ08IXvauCoG6oEwPX lh5Yzo4LQ7VqmY7NNp3WSBXreUlZB3Xw73nhY+cq+mOncxPvfD8VPnKRm/gbgiMJJSjU 2CKEdS4/y48q0/UlqGcMYiMvc1OzqJTIU2pihNrTjk/3F9lg6z245FoR6FC0YOHXI3Ah Qcib302+KXYPR5Dg7FAaB2LQluw5zP4Kft2Vv/8Hk+wY7ssBWVlhetwSI/8PtyXRG1Ze MwIg== 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:to:from :dkim-signature; bh=O7w8iWHuHLj1qqdMh1OWVQD6LygpPO88gA0me6KT8+s=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=Ri/7GAzFxdFGdcHsERpmZb6PzLKO1Fn2vHjcxrU9rvQl6nmwROT1XpnUEQDfnpRGy5 LRWTq4TOaTpiIJKWV+SkCwtWivnTidFRHgIdIg59cqOsmxIBPpVDMnxhe74WE0+nB3qF KJRKayH1BO++faefFDipZa/uyyCwgY+VA4mQCTHZuqRzchL6OKk9MrJkmpdc1/dqJ6Go j9K3RAlzDWEzy7OOyFpy6hnO1NzZZYOy6w4BpxsNlmPm7DgQzcG5sDOrhejIQ8gJdsC9 urIsX3tuZOkVd9vjMgLxRLPnd44o6NhH8cphfo3JBpLc3kJoceOWsunQAeTlA67yu8jK xhuw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n0eXICH0; 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-446514c25e6si13062301cf.594.2024.06.28.00.08.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:08:21 -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=n0eXICH0; 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 1sN5gq-0002sX-4V; Fri, 28 Jun 2024 03:06:36 -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 1sN5ge-0002RQ-JN for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:28 -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 1sN5gc-0003G5-QW for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:24 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-42565cdf99cso3113145e9.3 for ; Fri, 28 Jun 2024 00:06:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558381; x=1720163181; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=O7w8iWHuHLj1qqdMh1OWVQD6LygpPO88gA0me6KT8+s=; b=n0eXICH0enTkWnUWUIxa9zf1R6DYYIqtxcqFUSyR+JiE1Oq8eozcXW1XxhPyRbRpJ3 KOPzlWr7HkhFur1EGdly2s0dWVf6EezoquLpYI1RJgo2gQPAbTh9T6z1Cz4+nCiTJw+v s4Cwg26LO8fEtYcrw9ISFmcfqWOcL+wc0MqYteImW+Ib5gFvleuE1m9saNYFB95ziD3+ hSfHRdS9oo5TBUpupdlk3PLgGCs4lSOeuMzX6OVLlUY2RqbPKDTFST0cfiwl6A0ti6Ax 5nxtNr+49uLegYjqkvomscqIsSbkNoNYVEgOFeEIrEw9ZgTib4k37a0Z67oBN4LA70j7 dJpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558381; x=1720163181; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O7w8iWHuHLj1qqdMh1OWVQD6LygpPO88gA0me6KT8+s=; b=irkfeqAoGQM+Eq0VI6Ne7Kw4saIBeFmACPDhHhZ9uHAfEK4f6jMrdWewhdHIKfSk9I tGArufWOGlyIpZkLvq0vzZBkWYrbG1mUlm6KHicaGhisE7cwHPrIlrwDSZFh0VM1bDFi sGrq2l0SDiqJ9AQHl4OsIjBVRbrMex4aJoyJZWln9LJ3PaLIQfh3AjS+NPBG2qL7qSe8 1Kt+9feHVZYWRmEapqwDYJjiM91t05SfIPn4PkVan3KamZutxBPzKuc1d1Lz1WkhhtMh Y4nZlbwAHsGfplznMEu9mSCpZe5fZZcqFIga9+5GkLJexTI9akDUG49ZX8FCLGRAI4vN vOBA== X-Gm-Message-State: AOJu0YyveYxksYzt9uwGAfKS6jbB+e5Cs/k4YORU9Kl0dmbj//U8yU8u x4/pdm6c3g/tcTnhQOlbs9Pi11rAkzBgWS+Rbb0TT313sGoQws6BygO/7pDkzLCQo70zwKjd2AE 2wRI= X-Received: by 2002:a05:600c:5713:b0:421:29cd:5c95 with SMTP id 5b1f17b1804b1-4248cc27143mr136281765e9.10.1719558381026; Fri, 28 Jun 2024 00:06:21 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af376f5sm21696125e9.6.2024.06.28.00.06.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:06:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 41/98] hw/sd/sdcard: Store command class in SDProto Date: Fri, 28 Jun 2024 09:01:17 +0200 Message-ID: <20240628070216.92609-42-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Store the command class altogether with the other command fields (handler, name and type). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index c4cc48926d..a816493d37 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -95,6 +95,7 @@ typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); typedef struct SDProto { const char *name; struct { + const unsigned class; const sd_cmd_type_t type; const char *name; sd_cmd_handler handler; @@ -352,13 +353,6 @@ static void sd_set_mode(SDState *sd) } } -static const int sd_cmd_class[SDMMC_CMD_MAX] = { - 0, 0, 0, 0, 0, 9, 10, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 6, 6, 6, 6, - 5, 5, 10, 10, 10, 10, 5, 9, 9, 9, 7, 7, 7, 7, 7, 7, - 7, 7, 10, 7, 9, 9, 9, 8, 8, 10, 8, 8, 8, 8, 8, 8, -}; - static uint8_t sd_crc7(const void *message, size_t width) { int i, bit; @@ -1306,7 +1300,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) sd->multi_blk_cnt = 0; } - if (sd_cmd_class[req.cmd] == 6 && FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { + if (sd->proto->cmd[req.cmd].class == 6 && FIELD_EX32(sd->ocr, OCR, + CARD_CAPACITY)) { /* Only Standard Capacity cards support class 6 commands */ return sd_illegal; } @@ -1891,6 +1886,8 @@ static sd_rsp_type_t sd_app_command(SDState *sd, static bool cmd_valid_while_locked(SDState *sd, unsigned cmd) { + unsigned cmd_class; + /* Valid commands in locked state: * basic class (0) * lock card class (7) @@ -1905,7 +1902,12 @@ static bool cmd_valid_while_locked(SDState *sd, unsigned cmd) if (cmd == 16 || cmd == 55) { return true; } - return sd_cmd_class[cmd] == 0 || sd_cmd_class[cmd] == 7; + if (!sd->proto->cmd[cmd].handler) { + return false; + } + cmd_class = sd->proto->cmd[cmd].class; + + return cmd_class == 0 || cmd_class == 7; } int sd_do_command(SDState *sd, SDRequest *req, @@ -2273,22 +2275,22 @@ void sd_enable(SDState *sd, bool enable) static const SDProto sd_proto_spi = { .name = "SPI", .cmd = { - [0] = { sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, - [1] = { sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, + [0] = {0, sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [1] = {0, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, .acmd = { - [41] = { sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, + [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; static const SDProto sd_proto_sd = { .name = "SD", .cmd = { - [0] = { sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, - [2] = { sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, - [3] = { sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, - [19] = { sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, - [23] = { sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [3] = {0, sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, + [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, + [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, }, }; From patchwork Fri Jun 28 07:01:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808168 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222887wrr; Fri, 28 Jun 2024 00:07:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU8fXq6qaoCAp96TIBWaQsZzXvoaCwenw7pMenVKal5yLV4PPS8QZnnfhyC/paq5TPO+rtpYCzOVQwxTYmpFwpO X-Google-Smtp-Source: AGHT+IGUEoiF7p/f5eHq4T39HI5HPegZdIPoR7LIUz/POu9wpyrTfs2DF4JZd8JL9h0XeOUZng9i X-Received: by 2002:a05:622a:594:b0:446:3e00:52c8 with SMTP id d75a77b69052e-4463e0064e8mr59995511cf.21.1719558441299; Fri, 28 Jun 2024 00:07:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558441; cv=none; d=google.com; s=arc-20160816; b=HpiQYsUZBao5siE7viuyqsDyk2H4TwtDKaOILYl5YwffngyfiV1JLcwPGxxmxd/sPf KjTS0wW4jSJA1ge2f4x+GdQEmtIJjG3nXqOpmhnnRkmEioTFrpomahMMob7RFers1AXL +9NV1vRPRjOT+RhG43UL88uch4Y3QlBvXWsKbtw0Uup1QbML2FXV/Jw1JicXVm9PLmYR 4kcMvtmthojX8Vik/vI7jA+BqYACiEUmz3yQU4+NIn3y5yrj1Dzq6fL5ihofhoEr9y7t nhc3y0wQfruGLNN3rdXFy5Ep8PzyTOUoGBnOlFa7qHi0fkvoMkRpQ4pIzvqCozw3rOcu 8A6w== 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:to:from :dkim-signature; bh=W8MZ6mDUZDTzEHMhB6amOhsFMea88t3Iug/OVUXgLHk=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=z4jfOOQJybsRtt0r3HJLzDyZUHGm6cw3OhR1oXGjBDXAzDlY+RNn60zyINPGRGO9AH GcukQZ445WfEze0shGXApj5eqeAx27SECLkw0KQtiRWjPHSdsCj5XnKKcMLgUogLkIjZ ft6aSDxSciKH5eWgXSg1MpD2VB2Wm3XNYnSCnX/TMLoGMPu82ZLoy8D2YCWhL8xj26YJ FtTuqiK1ak7sXAkwUJGFXqneuDkiNaJoSKChXBKpQ7KWtHDLPFmxSWr9F60GYRepCwbJ 1/VnTLHSAVV9Bxw1fTPIjS0BVcLzq4UpJw3lx03hKp3augRTOOnOFq22mObk4q0bvmXs N0vQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nCfxMW8n; 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-446513c121dsi13302771cf.145.2024.06.28.00.07.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:07:21 -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=nCfxMW8n; 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 1sN5gq-0002x9-EW; Fri, 28 Jun 2024 03:06:36 -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 1sN5gn-0002X7-BM for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:33 -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 1sN5gi-0003GH-HZ for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:33 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52cdf579dd2so268453e87.3 for ; Fri, 28 Jun 2024 00:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558386; x=1720163186; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=W8MZ6mDUZDTzEHMhB6amOhsFMea88t3Iug/OVUXgLHk=; b=nCfxMW8nGlIedU12Wva6XOVhr02OSp/97twpqlJ3e4Zy29yC6WBztyEJp6QKjlVBKv qvjYtuzs8nwhKK5TXk29MPemeafaP+znRU4H4tHQ+j9bcHEOYaa+GZda9UWK8Z4FfA7Y EIFK8aoI3+GNndELIriaCYm0tnJqCfavR8RFOUZbnlpcgcZowxucvK3YKUeWpq9TpCI3 UlWNQiPyUnOQ6UE23psRlzBttTp3cdbbAiAxUtWHir/qFffZQeCOj/LEjJms9FNk3rfT jI4HtDwUD9t8rxhgo/U7WGtoAVu+8tSszuWUDqNTaIYzsMD97KtIjZyAL+txxEbbLYCe /jYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558386; x=1720163186; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W8MZ6mDUZDTzEHMhB6amOhsFMea88t3Iug/OVUXgLHk=; b=SNEFxYpyv0p+4rojpGK7tPFN8VbFM2aBAnxYBo4LesT9vjjjtbTFuvqjI9T7NbHrt7 sYuqP6Jk7nd64uyb3brf+v+jhAQRcZGwhZvVqel0h9sCFuFFxyL2w9weHQ7+1PpklFFK kc357yN1VWDQLK5UzefZwCGTUR+ZUR0S4JCWwqU5MUNtHVQS3bfYljCii/cwRD4fRAIg ontJYwOAb4UAIGUNxVn6XlJpRWLQYbF4iQ3B2zl146d3iQOphCAO0B5kOi8lhFc7cjTo dNAuPppPzKWH89LPytoWO1+HhA7OW563GI4OzEMsFX9Px4lK1DOOghS16ugzeJtxq73M 1wPw== X-Gm-Message-State: AOJu0YzlLvY5w/tJXHyjKZHLO0Qic8fyZivcZpg0VG4LHCsg7cRwqi9s Sx1jSRK9eAYfLXVa2XB8qyI2LicIqk4zC2dq/Y9yt60Gi3LqSA614Y9S3TZaUOMVgfnKGvnOFuG YYmE= X-Received: by 2002:ac2:43ce:0:b0:52c:da39:e40d with SMTP id 2adb3069b0e04-52cdf7f1581mr9240334e87.26.1719558386164; Fri, 28 Jun 2024 00:06:26 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424a2abcfd0sm62312855e9.1.2024.06.28.00.06.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:06:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 42/98] hw/sd/sdcard: Remove SEND_DSR dead case (CMD4) Date: Fri, 28 Jun 2024 09:01:18 +0200 Message-ID: <20240628070216.92609-43-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-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 The CSD::CSR_IMP bit defines whether the Driver Stage Register (DSR) is implemented or not. We do not set this bit in CSD: static void sd_set_csd(SDState *sd, uint64_t size) { ... if (size <= SDSC_MAX_CAPACITY) { /* Standard Capacity SD */ ... sd->csd[6] = 0xe0 | /* Partial block for read allowed */ ((csize >> 10) & 0x03); ... } else { /* SDHC */ ... sd->csd[6] = 0x00; ... } ... } The sd_normal_command() switch case for the SEND_DSR command do nothing and fallback to "illegal command". Since the command is mandatory (although the register isn't...) call the sd_cmd_unimplemented() handler. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a816493d37..097cb0f2e2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [4] = "SET_DSR", [5] = "IO_SEND_OP_COND", + [5] = "IO_SEND_OP_COND", [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", [8] = "SEND_IF_COND", [9] = "SEND_CSD", [10] = "SEND_CID", [11] = "VOLTAGE_SWITCH", @@ -1153,7 +1153,6 @@ static sd_rsp_type_t sd_cmd_illegal(SDState *sd, SDRequest req) } /* Commands that are recognised but not yet implemented. */ -__attribute__((unused)) static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) { qemu_log_mask(LOG_UNIMP, "%s: CMD%i not implemented\n", @@ -1312,16 +1311,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 4: /* CMD4: SEND_DSR */ - switch (sd->state) { - case sd_standby_state: - break; - - default: - break; - } - break; - case 6: /* CMD6: SWITCH_FUNCTION */ if (sd->mode != sd_data_transfer_mode) { return sd_invalid_mode_for_cmd(sd, req); @@ -2289,6 +2278,7 @@ static const SDProto sd_proto_sd = { [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, [3] = {0, sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, + [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, }, From patchwork Fri Jun 28 07:01:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808176 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223079wrr; Fri, 28 Jun 2024 00:07:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXKldY71LJa9sSGcyVIyFOO1Zc9IOpuoipkFzoe5ET6cjg3WC2uokl/EOYniTCyl68bI7d/e3tDA0k02/9p5NK9 X-Google-Smtp-Source: AGHT+IFWkc30hpJO6vM92jMPemT3kJojXY2m3iucp218odLjcd7Cy2R3vp+81Y6dilCKyZHxwL/d X-Received: by 2002:a05:620a:40cb:b0:795:570a:b9e3 with SMTP id af79cd13be357-79be46fdba7mr1804702885a.34.1719558472957; Fri, 28 Jun 2024 00:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558472; cv=none; d=google.com; s=arc-20160816; b=vrBd8/NdHBGI6K9r7w5CInv+GRZ6CeG0/RDfMC9EXwP6fXkgmSiNn47J4d/ptPCK3/ ZLQM5QEEiqaIfC9CNUVrt/GRzjWr6TDhnbXtK6IJJ47fNUyn6ElgoJk0T94ShAs3qi02 ToVfBmN617OD2pPzzV4gjaMRogMlharaUbPuqd+pQy4paJMMWSuyy0Zvf3czA8c2rvkW gDH0plZQxqLTnR3RIDQRLCIiw/ImDiWq+pEojEz8/qJgW9f23YpEkXQEDJgQj9uKnxHs seqDMojtVMnN6t56iEIXJWMM9VSJl2ooi0ISPmO6RMIFxA+XZia5BMvVBX3rB1GPDg9d pQIw== 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:to:from :dkim-signature; bh=Kx/xpSwqNNbWf+vNm/3cxS62PiRf/NP5lc+BI6XCrgc=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=kx+apnpzreXUBs7m2jpoWv/Pj6QrEGwFAcN5+oAsMj77bwUWsQeROhuCtXfRUKxn5V 5uw59CKkNr3oCUxn7GjlT77vIiB7jOQE1JZFESCQo8V5d09d88us4L1At11reBMKnjUT BD/RL7VGjH5KxNhggEaCU28Bw4YpNC2okUH+gFC/3vmcdepa7cM/OJKgpfv61kqmUVcE JgNBe15LAmyxFEp+UMQ0MJLWn8LXmEJjxYlpVlfmd4T8OlHBSk6txnxDUCO+0Ts5kPhc 39CAQgSTlppP520zbH3hPHBPHXIqF0izXRHhOnS+bbIwnH3qKn2XLuw/9IH+Hv8uLmwp Nqlg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WV3Ee0wY; 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-79d6928997fsi117574485a.197.2024.06.28.00.07.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:07:52 -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=WV3Ee0wY; 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 1sN5gr-00034t-F7; Fri, 28 Jun 2024 03:06: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 1sN5go-0002eF-Fa for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:34 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5gm-0003Gi-Q3 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:34 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-421f4d1c057so2197715e9.3 for ; Fri, 28 Jun 2024 00:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558391; x=1720163191; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Kx/xpSwqNNbWf+vNm/3cxS62PiRf/NP5lc+BI6XCrgc=; b=WV3Ee0wY06oNpxu2snE2EnIB/aF71IOeiY3Uft5UldoNW4c4inGsoz+n5H9FQ1Vmdr JWkoc9QA/Kh+UL4Jx3J40fDVNZfhQCYRfc9ELxhiNXOb8eXJqzJmQScqbG/4Kt7DP18z T1P7Qx4BW3gMIosqN4u0GNQUP2gHJNYWjemALyMKEQtwmICNK8g7kodOQ3kCAb0pWaVY rqfKL+fJtIyzQOFN9Z8jwp037KIY/SHkd7GH/16dwLdTY7fsRVUHr2tMWkbbA1DxoUAR waQ71rzSVizn18zEa/hD6WA+3iT/DU4PQDbZxt85IPXU0b/54zMl97R7dBmvOMQtmRx5 A6wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558391; x=1720163191; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Kx/xpSwqNNbWf+vNm/3cxS62PiRf/NP5lc+BI6XCrgc=; b=QriRraooiyCqkImxVQvxJLKcIH1H/0bUVlUS3MKRODzRdTGxKa8d7lyMF7YotQwFhM I5NNpExXlJX4RVCFlIUmCmHbG5W4sprZDKsh+UCCVY1Tg2t43mduQUVeikgWVeaqZMxM Xh/BFuPf2RDE9I3ZOrpGPs71dXvReZyQsO0YHheJU+Hie9QranBY0DRdUkrt/WXUSq6n esC3DmIuLtaXFFEaA9Hg+9S/vZIjlT8myq7RRXUB5T5G3ufjAkHPADt3IijwrS6bno1c rE4S1+NunHC/4CnDzcgtP4nA6D1FVBVgbqMJHKFHP/kDtTQWSYqZGrpcQfgcBLSqbJAZ WjTg== X-Gm-Message-State: AOJu0Yy+aQgkfbKwhJUcyrqDcZZdDX4eQnwIPjyZBBqh4I+RRHd3VLhW 4fSdrfB7vqQZzOpCicu1i3qzUsQg8VcWjQSax50ur8DTm1fpLtGpjD2Pb6SFHTuO9RpnZ3MZ06n COqc= X-Received: by 2002:a05:600c:4889:b0:425:5a26:a12c with SMTP id 5b1f17b1804b1-42564510fffmr26456725e9.13.1719558391212; Fri, 28 Jun 2024 00:06:31 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a103e5esm1325302f8f.108.2024.06.28.00.06.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:06:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 43/98] hw/sd/sdcard: Register generic optional handlers (CMD11 and CMD20) Date: Fri, 28 Jun 2024 09:01:19 +0200 Message-ID: <20240628070216.92609-44-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 097cb0f2e2..74aa38a442 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -243,12 +243,12 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [5] = "IO_SEND_OP_COND", [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", [8] = "SEND_IF_COND", [9] = "SEND_CSD", - [10] = "SEND_CID", [11] = "VOLTAGE_SWITCH", + [10] = "SEND_CID", [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", - [20] = "SPEED_CLASS_CONTROL", [21] = "DPS_spec", + [21] = "DPS_spec", [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", [27] = "PROGRAM_CSD", [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", @@ -1161,6 +1161,14 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) return sd_illegal; } +static sd_rsp_type_t sd_cmd_optional(SDState *sd, SDRequest req) +{ + qemu_log_mask(LOG_UNIMP, "%s: Optional CMD%i not implemented\n", + sd->proto->name, req.cmd); + + return sd_illegal; +} + /* Configure fields for following sd_generic_write_byte() calls */ static sd_rsp_type_t sd_cmd_to_receivingdata(SDState *sd, SDRequest req, uint64_t start, size_t size) @@ -2279,7 +2287,9 @@ static const SDProto sd_proto_sd = { [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, [3] = {0, sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, + [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, + [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, }, }; From patchwork Fri Jun 28 07:01:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808221 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225739wrr; Fri, 28 Jun 2024 00:16:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXveHwxqiSsiKMsQaqD1NWRZXCSO9dNy/fbs0/7J7G4lkZF/Za05f5Kz24CD9XoMegNDCWmLgkWHV2K+FKqSB88 X-Google-Smtp-Source: AGHT+IFmnxS1QFSMqUmWp/gHAc8Xr2QvEmhn2BtzKLroE4dyyynh7rc8YqsmMHPyQUDJhlJIvUoU X-Received: by 2002:a0c:f788:0:b0:6b0:7e55:22b5 with SMTP id 6a1803df08f44-6b58d3aec57mr53929746d6.14.1719559003372; Fri, 28 Jun 2024 00:16:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559003; cv=none; d=google.com; s=arc-20160816; b=nizr/rIJHOUmiflN0GK/3+A2LH0/Goo2rAvMg2YKWmilKXdg0rMqsBJYi2iKC4oEim cnw7XErAYudCEdYTtO1SlQ25ZrYqEXhpEFKDqXC1Rc039g+0g8skWKb1JJXYOZxC+DDd bFFpPUndtKZ3iA45a1S6NBxBTJ0PNQjK588jj2pJy5JVE/sjJtAeVVWpKBQ9ACASaG5x vDV08drbucDwhxpGOlAe/3/pp4fLLqNzlspjnBusjcIO7vMb3/1TiPy5vnd0DXZp65MF BdkoEoxog5UyFeS6jNK8oGWGObJw27Yy46aVJkiz4AfCBwk8qBT3kbkD/HTlLBM722GY c/rw== 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:to:from :dkim-signature; bh=HjpgRXrOQ8bkyegxRpfboHEk5IA653f08nTp/+XGbbA=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=CkA6T0ektwagBHwq3UXqfnfLZNmaEsiN5nPKhpOuIBMf7ZUnreSmf11oIp/E+zMOD8 ZtLPwGcKbLW5qKStQYdUR0hNS5RihIVlNwcqm5fW4Cgww019Hvav1khYTHnl97zZ9j7x FxMRwtr2vBGTnvlPFUj8QHZ8iVVQffC2vwY0WOWEl2ZjFCTxjDHhivv+7ZZOv6nHISYs Ezc5jhe56vH7uZd76Ns+spv320rUq+/ZEeZ913gMybmF5/1NTM8dQVbJnq64wvhVJmcs 9ldWTEtvgbenAR5hriq+vvgaKnaL85cHj9MpmuY/69TnGhX61fNK22D3vf9dvqOJvXcE 29eQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O7YvU14M; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e5ee1d6si14078376d6.403.2024.06.28.00.16.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:16: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=O7YvU14M; 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 1sN5gv-0003WF-Al; Fri, 28 Jun 2024 03:06:41 -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 1sN5gt-0003Gv-Fj for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:39 -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 1sN5gr-0003Hf-QV for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:39 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-42565670e20so8341295e9.0 for ; Fri, 28 Jun 2024 00:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558396; x=1720163196; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HjpgRXrOQ8bkyegxRpfboHEk5IA653f08nTp/+XGbbA=; b=O7YvU14Mjf2V/s5cEpuocxep1uw03LrTVYBvaaZ962BLHF+IgGr2sfvTX2x5bvImUl b4YkN0VLlNOcauZG/yddgVy/uORi8ux8rlIkkXCJwg0LBFINh+PAUeXljXAOsmZHOC7e z9OlPBcYsmUiCcHbkqzXkj0rQMkmCGSa9j49dJV9HpkPuyGqfE3IHh9JZCGt2gQaaLds Em3PQvIXPPyNMe32qDOQIduKvTsmvUDt3+H/JeNJC4+46gzHZyf7s3ddAxqkljMiSK1t rg++yo35/u40uW2QWQkHb7rF6y9ekjdN307DGLa6ECNW6ZGB64df3ADL9zJbp5HcdTMg Bz+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558396; x=1720163196; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HjpgRXrOQ8bkyegxRpfboHEk5IA653f08nTp/+XGbbA=; b=tcFikYPIiFmdMO7i8g9aGMYlT77MBoZAuuL9l1PpknNxe1YIzlzsaV32nnVTtpKD0g /rimhy6S+Knnp6N2PRTY6pqrLuuKUGjY9UZ9tF9xPaM8j58Tm/5f2WLa0qB5SEUm5/Kz UyUbgG3XACjLpEirqTBMC/BQYEfQ+ksOJj7fYoKoxRwaN4UwNe9hhuXJgC6WTouqSX3f cJFXZIfZghbJslwBwPmdpylDZeW9ZP7Z/a4RPwWme8kjbdv0xtkxjGx9NuqfvSaMD+MT El7nmuni1+izMvtHnqJ6hjTT9wMIc+qfRCMipYqkP6NyQ81PsE6OkNHRdCdvPfUayl4i pcZg== X-Gm-Message-State: AOJu0YzS3YFfWYmD2Y5OKNs5W6RZnvGdUGwBgAbmK4yNAyyPUk6JrUTp P/nX2wnYdkK9TAcfz1RNoPCD2tJnTWpu5JGPSyB9y99InwsBSy9iMkkSoKoGQ90h3I2OdJMtwzT OHq0= X-Received: by 2002:a05:600c:3d09:b0:424:8be4:f2c with SMTP id 5b1f17b1804b1-4256d4c3ed1mr6547415e9.2.1719558396146; Fri, 28 Jun 2024 00:06:36 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a1108b0sm1315803f8f.114.2024.06.28.00.06.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:06:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 44/98] hw/sd/sdcard: Register optional handlers from spec v6.00 Date: Fri, 28 Jun 2024 09:01:20 +0200 Message-ID: <20240628070216.92609-45-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 74aa38a442..406fadb3b4 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -258,15 +258,11 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [36] = "SW_FUNC_RSVD", [37] = "SW_FUNC_RSVD", [38] = "ERASE", [40] = "DPS_spec", - [42] = "LOCK_UNLOCK", [43] = "Q_MANAGEMENT", - [44] = "Q_TASK_INFO_A", [45] = "Q_TASK_INFO_B", - [46] = "Q_RD_TASK", [47] = "Q_WR_TASK", - [48] = "READ_EXTR_SINGLE", [49] = "WRITE_EXTR_SINGLE", + [42] = "LOCK_UNLOCK", [50] = "SW_FUNC_RSVD", [52] = "IO_RW_DIRECT", [53] = "IO_RW_EXTENDED", [54] = "SDIO_RSVD", [55] = "APP_CMD", [56] = "GEN_CMD", [57] = "SW_FUNC_RSVD", - [58] = "READ_EXTR_MULTI", [59] = "WRITE_EXTR_MULTI", [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", }; @@ -2291,6 +2287,15 @@ static const SDProto sd_proto_sd = { [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [43] = {1, sd_ac, "Q_MANAGEMENT", sd_cmd_optional}, + [44] = {1, sd_ac, "Q_TASK_INFO_A", sd_cmd_optional}, + [45] = {1, sd_ac, "Q_TASK_INFO_B", sd_cmd_optional}, + [46] = {1, sd_adtc, "Q_RD_TASK", sd_cmd_optional}, + [47] = {1, sd_adtc, "Q_WR_TASK", sd_cmd_optional}, + [48] = {1, sd_adtc, "READ_EXTR_SINGLE", sd_cmd_optional}, + [49] = {1, sd_adtc, "WRITE_EXTR_SINGLE", sd_cmd_optional}, + [58] = {11, sd_adtc, "READ_EXTR_MULTI", sd_cmd_optional}, + [59] = {11, sd_adtc, "WRITE_EXTR_MULTI", sd_cmd_optional}, }, }; From patchwork Fri Jun 28 07:01:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808191 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224124wrr; Fri, 28 Jun 2024 00:11:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWz8a+4xQtbIoBUqGiLZDOF5lty3tfpssnENEYsguwLEYxafmGFtUB+LV66AQKwmB4PFrXYWl5cZ0UXctlmlu+e X-Google-Smtp-Source: AGHT+IEABL8DIxX5WbI4rxV2N2RyH0DlAeJONDecXTghjNwy9DEOGVUzrKykVvbIEK7LdvkLxZLe X-Received: by 2002:a05:6102:2821:b0:48f:3977:2ac1 with SMTP id ada2fe7eead31-48f529592c4mr15562218137.1.1719558669478; Fri, 28 Jun 2024 00:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558669; cv=none; d=google.com; s=arc-20160816; b=ukEEaIAkf1pkCaKIg+kEgIXjAicmtE4MNiyX4/aB9Fxd9RJuKJPJheunzgqY4dESla oooFm0ukzGSsaDrYqNDAD4S0ZPFeYj+gBwcVe7N0LLMBp2f6eTxvflNzrevZCmeO6uDb IRD7/bqRYPSHOr6SHQTa6he1m7QZukrMwqeAwNsKiLHO0ClPF4QjsMbFRLTTF5QR2BzI er8szxog9yNzdKnukL6WJ1n33YKKMXQGhqqZrrR1ib9ZpZYkVhjdpXcEStKWzmaiFfT8 PBsDtXQcd4MJAWrDny9E8ehz+pB6tF3+ciZUhwm9zevUMCH4CRt6ST0GYgLJdfae9Bew hxwA== 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:to:from :dkim-signature; bh=ESvyw3GYgt7hOD38NPh8gyks0iX0X2xZyRHCeLbcWRk=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=Q1xPzH7J0GMji7KyOqsBuF1C/UZ2OXStW94iGo0qB1czmP/cJ3FhWbXLZeMj9hkN2z rzIILcuIede6/h48s0PMPxj9mnsaYm9OMF2T9GI2uqSiW4kTlq8pHJNSqAMMp6/2SZ9W c3vAaTqe5DVwPjDEyo+tUjleeGlXSi0SQwoujoK8/0eZw+zEy1Kfo28Te9Chg0tUOJRc c5cllw2/IyBjtBO6Ev73z6VLmt+N20jsQhUDn7/Q7PpXzDY6eznSzjtmzjoulGBPIfEy z8cfy6S4gaZovL7/DhityK24b8Fzn0DrrjPeRbuSi6lr8JffKKADMH77hUkKaX8pdWFu y6JQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wp6guBI7; 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-79d6933b17esi122431985a.640.2024.06.28.00.11.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:11:09 -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=wp6guBI7; 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 1sN5h0-0004DM-LH; Fri, 28 Jun 2024 03:06:46 -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 1sN5gy-0003zJ-M5 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:44 -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 1sN5gw-0003JL-OY for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:44 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-424ad289949so2336685e9.2 for ; Fri, 28 Jun 2024 00:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558401; x=1720163201; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ESvyw3GYgt7hOD38NPh8gyks0iX0X2xZyRHCeLbcWRk=; b=wp6guBI7GHGEm83qsEmmGqp0P5S0sxW61xQVswBOKDD3ubKvitaiG5vFCy+I0RW1Z5 OLTWlK00H3EA1kDSzWQA3xl2VExRPc4E2PgSrOiHmkCllHukLxRRq+fDCpA9cJVdDKQ5 pOwCbykaRH7weF2MWTWztaohgGZW5fjh1FoDgq+ItAsNOP2GynaXJg7eY0wSysrkdlqe 6WBp8n8HAtNdJmcOhdtYnS21LCf1HWaR3aRInooN3tZHkLnUl9UnACzUQYK57YKqgtZs KN9m4TAMx0+bCx3hV3TkHvi9jjuvWzYSzGx1Xo8oEV0WBcCNQDcKwTxUp5YSVgQlQTDx IaFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558401; x=1720163201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ESvyw3GYgt7hOD38NPh8gyks0iX0X2xZyRHCeLbcWRk=; b=n9rvFABEYK5U5ExNwkRE0FxqQio+ozwRq4euJiSzpX4KQIRIsNerg1cZ+QqK/prWs3 wbUUB3jnlAMfxdjBiA4jB4v6j3pvrt2uv4WuxFMElbfHkSYMYYNoELmfageukZABiTIQ IDF6DZRLOHNDqttUzaFixpK5egjjZY/JFvNZQhf2madMoQOsaiPujVkZeyDvYFWWBjbu c3sjC6PUQSYd2pMhVDO6HoUCE13PsFSJnHeu1sC7MLueZdJ2gSvIH0JuUVfEk3ROQloG naPHo4bDEFVWXTSwtPhsISEXfgbx028j5aalbj3OQACBKIQn4fVtj3PDTKsBnk22REct jSTg== X-Gm-Message-State: AOJu0Yz3gQeUycO/D+aXvY0GgChb2awHrEA1dCl0CBqVZiz5lCKUv43W FNWBhuHUj5hK6yHJKthgwN/xIZhcrNgFiJq/VLYammOjMSEpWZ24CYXZUm9yU0nbOwFMk/huwkw vfWo= X-Received: by 2002:a05:600c:4a05:b0:424:9f28:22ff with SMTP id 5b1f17b1804b1-4249f28238emr68998575e9.5.1719558401129; Fri, 28 Jun 2024 00:06:41 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3f14csm21672955e9.6.2024.06.28.00.06.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:06:40 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 45/98] hw/sd/sdcard: Register SDIO optional handlers Date: Fri, 28 Jun 2024 09:01:21 +0200 Message-ID: <20240628070216.92609-46-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 See "SD Input/Output Card Specification" v1.00. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 406fadb3b4..87bfd0fd56 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [5] = "IO_SEND_OP_COND", [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", [8] = "SEND_IF_COND", [9] = "SEND_CSD", [10] = "SEND_CID", @@ -260,7 +259,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [40] = "DPS_spec", [42] = "LOCK_UNLOCK", [50] = "SW_FUNC_RSVD", - [52] = "IO_RW_DIRECT", [53] = "IO_RW_EXTENDED", [54] = "SDIO_RSVD", [55] = "APP_CMD", [56] = "GEN_CMD", [57] = "SW_FUNC_RSVD", [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", @@ -2270,6 +2268,9 @@ static const SDProto sd_proto_spi = { .cmd = { [0] = {0, sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [1] = {0, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, + [5] = {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, + [52] = {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, + [53] = {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, }, .acmd = { [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, @@ -2283,6 +2284,7 @@ static const SDProto sd_proto_sd = { [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, [3] = {0, sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, + [5] = {9, sd_bc, "IO_SEND_OP_COND", sd_cmd_optional}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, @@ -2294,6 +2296,8 @@ static const SDProto sd_proto_sd = { [47] = {1, sd_adtc, "Q_WR_TASK", sd_cmd_optional}, [48] = {1, sd_adtc, "READ_EXTR_SINGLE", sd_cmd_optional}, [49] = {1, sd_adtc, "WRITE_EXTR_SINGLE", sd_cmd_optional}, + [52] = {9, sd_bc, "IO_RW_DIRECT", sd_cmd_optional}, + [53] = {9, sd_bc, "IO_RW_EXTENDED", sd_cmd_optional}, [58] = {11, sd_adtc, "READ_EXTR_MULTI", sd_cmd_optional}, [59] = {11, sd_adtc, "WRITE_EXTR_MULTI", sd_cmd_optional}, }, From patchwork Fri Jun 28 07:01:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808187 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223766wrr; Fri, 28 Jun 2024 00:10:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX4Vxalo1hWoX/pGXItywI/NHkRsXqs1Odqi9wVgmS8+bYgYWzoq5P4rqSPvPAySPKWawgBwAhqkKQ1Nza0awDh X-Google-Smtp-Source: AGHT+IHGBZ5c8kY/pjrJAOr5rY7MWOH58dz2wnoC6ct+PWN6Ow7fHNubXP3tLVUCaAzwgEZU9zkL X-Received: by 2002:a05:6214:e4b:b0:6b5:4249:7c5 with SMTP id 6a1803df08f44-6b542491231mr218994856d6.36.1719558599798; Fri, 28 Jun 2024 00:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558599; cv=none; d=google.com; s=arc-20160816; b=mjrtALj4ItubuVPVmCaW8ME+dixDGmi9L4IbT3lubmuT7gDTTtVi47R2Utd9fh8yaK ZMI1NIXkgOG93dFeFPRvdRHTmJgmCp7G4rJbv0nQHRLTeUGlK7GGGIPn3ntbHFZ1tjS/ 6+Zi/UGNiHYsp3hJr4Ej2SYLf0Lb9bfeRJIey1eyFjIfmgq3VXjx7YWGHfg9h2/jIXzc xBZnsKTu4rL8MMWYgt3dgvyw2B4n4SPMkpKLOAtuuEWKrBu1Y08kH62iRbgX2bV4+LyY qyr9Pw4ldkj9iT9/Nc0SO9ERlhRIC9AmhlIfJf2zWPuc6VhxoypLILf4xY7DakW//aOC r8Bg== 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:to:from :dkim-signature; bh=1fY9Hw86o5iLpIx4cOdBUGuwKgpX9A8Bw42XBcw/lnQ=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=FxmcgE2lQFI9jx28Klxr1WpNj6+9/1a+O6cePKASBP1IhZFK7OFtEK/XqDRDzZzfCc YKZTB8Ys0W78/INqCY0cjwf+z0yJbxfSyt/D51v/Q4Oj4X+TcdSTV30yAqOP9vueYMFC agf1uHC+Wu3JMtZEdvgfKvzTATrG6f84V3NLIGFwbVnHiQI31F1NoqjAik7TenqNolvc OYSApIpIDdwiIwqHkNCnAFcTK/n64riCw9wHdvnYJLZCff38Z6X3zCsltjfPGkl/bIo9 O5xLaXS6sewqO3X2JMJX1WIHufvNtGibzajfRF1ail2VKqshKrA2MwekP1y9451gbK2j zidg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KUjcXS86; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e6103e4si13763926d6.518.2024.06.28.00.09.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:09:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KUjcXS86; 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 1sN5h5-0004wv-Ic; Fri, 28 Jun 2024 03:06:51 -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 1sN5h4-0004mb-1u for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:50 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5h2-0003K0-4W for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:49 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-42562e4b5d1so2396675e9.1 for ; Fri, 28 Jun 2024 00:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558406; x=1720163206; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1fY9Hw86o5iLpIx4cOdBUGuwKgpX9A8Bw42XBcw/lnQ=; b=KUjcXS86NSJFSfFwmwNDUCO9MFGEVHf9JQU5D+cXqL33mzk+FD8nKtwnKFdsGQQw+A zxjc/GbsownBFMw3DLtFOMDpm2rPoRf/J0cSfQ0HU8ST1lS6wqIg76V4JstbhM+8fATB wu8mjojWOLUoe7cgpyY4OZgWdIoWQgziBo+k8cJuVwVv9wNAzFvEM+T4/33hyjoenljb PQtkZRDvLPrlZVSiLu4kA79DakcWp9htJbxOIyF+RKHkFb/RK6PShb58a73R+iQHK6q1 HHfJe6XwIllF84FPHY5tM59bYCl/VlOFuuiacpJuitl/zHKnqPC+kyDEkWY6Fc7DtV+m WvXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558406; x=1720163206; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1fY9Hw86o5iLpIx4cOdBUGuwKgpX9A8Bw42XBcw/lnQ=; b=wozvhbtIZ4YIbTU9F/me+pgFLBhMU56icG1odyOpEQl7KuThWy70cTgQ47nU1QxsaY tDQHElqNWKee71nRkYy7f6nDdn6Prh5XyMjjng/P3RBNcx+wZxg1TtFfPHjcr8+CmuJ3 WOVk/6ud9K+twtZrWKDDqhgeI9RUSEoV8ag0ji58T6pnfEfUSbQ7gwAirbzJHrggIciT XE0mKRGoLEujoGDY28PZTugkqymo9j1od5ZuVHzOHiuovXR/YShIs2j5xPYdClEEIugY nYXcD8jbCufxDOCcl//fENysN6i891AdSG31W1+M+yKaeqZBysQ/8CcfJFF2/ePrNeTO HL4A== X-Gm-Message-State: AOJu0Yy+RFfZK+j3T2Zmk5fkaWCgtmAMldOtdeWKzaca8a3HjF/WvnAY KXCJb4c29IN6t8yZ9C94Vuv0sHHNmf3qjDLeyZXVoQirVZUMIvKaTFYOm6rRQxyBY9832pJmyTw a0Dk= X-Received: by 2002:a05:600c:257:b0:424:a3d7:2a7b with SMTP id 5b1f17b1804b1-424a3d72b68mr67863365e9.5.1719558406114; Fri, 28 Jun 2024 00:06:46 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af552bbsm21664795e9.13.2024.06.28.00.06.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:06:45 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 46/98] hw/sd/sdcard: Register Security Extension optional handlers Date: Fri, 28 Jun 2024 09:01:22 +0200 Message-ID: <20240628070216.92609-47-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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 See "Advanced Security SD Extension Specification" v2.00. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 87bfd0fd56..e4941cfdab 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -253,14 +253,11 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", [30] = "SEND_WRITE_PROT", [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", - [34] = "SW_FUNC_RSVD", [35] = "SW_FUNC_RSVD", - [36] = "SW_FUNC_RSVD", [37] = "SW_FUNC_RSVD", [38] = "ERASE", [40] = "DPS_spec", [42] = "LOCK_UNLOCK", - [50] = "SW_FUNC_RSVD", [54] = "SDIO_RSVD", [55] = "APP_CMD", - [56] = "GEN_CMD", [57] = "SW_FUNC_RSVD", + [56] = "GEN_CMD", [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", }; @@ -2269,8 +2266,14 @@ static const SDProto sd_proto_spi = { [0] = {0, sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [1] = {0, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, [5] = {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, + [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, + [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, + [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, + [37] = {10, sd_spi, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, + [50] = {10, sd_spi, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] = {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, + [57] = {10, sd_spi, "DIRECT_SECURE_WRITE", sd_cmd_optional}, }, .acmd = { [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, @@ -2289,6 +2292,10 @@ static const SDProto sd_proto_sd = { [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [34] = {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, + [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, + [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, + [37] = {10, sd_ac, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, [43] = {1, sd_ac, "Q_MANAGEMENT", sd_cmd_optional}, [44] = {1, sd_ac, "Q_TASK_INFO_A", sd_cmd_optional}, [45] = {1, sd_ac, "Q_TASK_INFO_B", sd_cmd_optional}, @@ -2296,8 +2303,10 @@ static const SDProto sd_proto_sd = { [47] = {1, sd_adtc, "Q_WR_TASK", sd_cmd_optional}, [48] = {1, sd_adtc, "READ_EXTR_SINGLE", sd_cmd_optional}, [49] = {1, sd_adtc, "WRITE_EXTR_SINGLE", sd_cmd_optional}, + [50] = {10, sd_adtc, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] = {9, sd_bc, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_bc, "IO_RW_EXTENDED", sd_cmd_optional}, + [57] = {10, sd_adtc, "DIRECT_SECURE_WRITE", sd_cmd_optional}, [58] = {11, sd_adtc, "READ_EXTR_MULTI", sd_cmd_optional}, [59] = {11, sd_adtc, "WRITE_EXTR_MULTI", sd_cmd_optional}, }, From patchwork Fri Jun 28 07:01:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808186 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223746wrr; Fri, 28 Jun 2024 00:09:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWB1qqM2bEVggxbp9xsmdV/QCzWZ1wrQEMfgTuYI49TSzLYcLZO03KX5Drmm3e4+vHffZJVPOTR5jDGvx8HalcS X-Google-Smtp-Source: AGHT+IFH3hhiSMlspV5PQPN8FwRJP3Why8D5xnaVcUH0uaZ8UySxmDBSLNfapxy+Yi9in9NqtgEh X-Received: by 2002:a05:622a:1314:b0:446:43e1:ae49 with SMTP id d75a77b69052e-44643e1b2e9mr38756401cf.57.1719558595140; Fri, 28 Jun 2024 00:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558595; cv=none; d=google.com; s=arc-20160816; b=sXiyqBJTT3+V3cWfm5NOgqkJpqk7KB0FqkqhNqyEsPjBh73i219C2fuMkxKicY58b3 3DceLsAV2qLlZlzvB5r60P4s8HoM3BQDrbZEX+jLryBc0ac3IMyTvyeKdHXzTsog2Ttt ReAy/V1ekr9P9nX4tNIxWdNGlxR1yt8dsJWLR2uFCmIgcEKgM25IKbkdHf5u1RkDm29j r44otldYIlTWP7WVCZqlqiSD9oMm+pRApT1DJRDAc4pcUVMhpnTYuUIr6EL9HugOZRGh w2WMGgFLXTQgG3uYQPuayYyGg3+lcCa8KRL2ZRHqyIc75Mc4+AGuYQ6G81ViF6jiaKum u8dQ== 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:to:from :dkim-signature; bh=slgYteJmLjr8pI8aCW+CqOWuh6a3YgyVMIwY4xDIlZ4=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=TJ+xfdoJb+bS08oBHZ13b7KhrNEN4rd+Nf75C0BcuYZxgRMTVHzqFNpvpLwSU1E7Ei Gj/F2Z6lgmRHxVD4FXW0yL17xsX3Ax+dur+i/dzb0g1y7G18NK/mDcQJeEcz48j01EM4 LjOGXdQriR7QIrWwhA336u9Y7x9FsdVl/iU5/WVrNsc+dL0/CKnHzwtOKp01/HPabhOC Y640kZBSvdN3PpbMWLlLXfqxm/hDculGJy+PWcSI67+j7rBiy/ZfQpdLcHkVrCDjpuTx FS+mrFn8W235Y1AbhRZjJCEUCJ8ezHS/WlGm4z3boyFYg3JqSfsrkfl7i6V7QOEbnBXF ah7w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S23vbEg+; 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-446515eff4asi12789051cf.798.2024.06.28.00.09.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:09:55 -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=S23vbEg+; 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 1sN5hA-0005b2-OQ; Fri, 28 Jun 2024 03:06:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5h9-0005Rn-Jr for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:55 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5h7-0003LJ-MM for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:55 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-52cd628f21cso267719e87.3 for ; Fri, 28 Jun 2024 00:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558411; x=1720163211; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=slgYteJmLjr8pI8aCW+CqOWuh6a3YgyVMIwY4xDIlZ4=; b=S23vbEg+XdRW0wj99fkHeskBPIiq98fmQTR1eJRcg3kakmUIxWTqdY/KBa9VoRb2tJ NlbepcIR+VNg72+9S+5ORWetZAOxLg4clvWFc0NZ7bQ9YJy8TrAhH+RW6UhYoxHqelke MnCEdV3lFWqoocYEReUf78wWq+Wvs8Qk0EbwFBZGSkUz9uTAUr3XqbAifc7HW2NVbVAW xA5CEvfAbRHnEMaVuPlw0E4VbcCgYlPP4C1KXu+osFTbVngjzIk6o/SgIQFspr2eN4pd LORd8e0F4md4NWkqbDCwGOKokm58PVwF/ZWlFzVRNMTYWcWcjTDZy/NFarK44UWSTXWP H25g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558411; x=1720163211; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=slgYteJmLjr8pI8aCW+CqOWuh6a3YgyVMIwY4xDIlZ4=; b=RQh4+tpY7CMgg2ZLAfkgKQQPLex1WlD9DvsN1n5XIB0ZrFZcLRgH8DPFG7275AHEA0 DWXlwMz/ncPhqJoj2rEKMQvmzjNgqYt9OWGpWc3kHVQ5ockrBh/1sfn6BWBQpa2uzDYr c+5PAiAPWeuNUFuzqWIZfRmk98Rklv6cFuD6tk5c+ZJG08IClzcWvpxtAEfsdLKgqgKE d3sKZ0OmsgepGN0Os/OmgLw2UWtucwZDdK2XE26L4OQqLU0Z+E6U44RUsEATSS9X6N0v xes4ppQCHX6Y3epBece4fAqspAWO9sb5HsV92OXXhVglUevTAGaovNJmilfvFayIoBcT 5kyg== X-Gm-Message-State: AOJu0YxBid5tzw8UpCq6v0/x0lQwbJgbeQfeG3CnW0rvjsHMwvVuaTdo fk8vS1jB6Cd/tRTpbptY0DpWbKMn+58U+lCJrQWDJNB0ECp144ZFSvSM/gt8BCFI18P7SGCS8GD h6PM= X-Received: by 2002:ac2:4437:0:b0:52c:c9d1:ad32 with SMTP id 2adb3069b0e04-52ce1835a80mr10135394e87.22.1719558411281; Fri, 28 Jun 2024 00:06:51 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09890dsm21401375e9.36.2024.06.28.00.06.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:06:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 47/98] hw/sd/sdcard: Add sd_cmd_SWITCH_FUNCTION handler (CMD6) Date: Fri, 28 Jun 2024 09:01:23 +0200 Message-ID: <20240628070216.92609-48-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=philmd@linaro.org; helo=mail-lf1-x132.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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e4941cfdab..61c9aff2fb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", + [7] = "SELECT/DESELECT_CARD", [8] = "SEND_IF_COND", [9] = "SEND_CSD", [10] = "SEND_CID", [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", @@ -1244,6 +1244,20 @@ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) } } +/* CMD6 */ +static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState *sd, SDRequest req) +{ + if (sd->mode != sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); + } + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + sd_function_switch(sd, req.arg); + return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1310,17 +1324,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 6: /* CMD6: SWITCH_FUNCTION */ - if (sd->mode != sd_data_transfer_mode) { - return sd_invalid_mode_for_cmd(sd, req); - } - if (sd->state != sd_transfer_state) { - return sd_invalid_state_for_cmd(sd, req); - } - - sd_function_switch(sd, req.arg); - return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); - case 7: /* CMD7: SELECT/DESELECT_CARD */ rca = sd_req_get_rca(sd, req); switch (sd->state) { @@ -2266,6 +2269,7 @@ static const SDProto sd_proto_spi = { [0] = {0, sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [1] = {0, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, [5] = {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, + [6] = {10, sd_spi, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2288,6 +2292,7 @@ static const SDProto sd_proto_sd = { [3] = {0, sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [5] = {9, sd_bc, "IO_SEND_OP_COND", sd_cmd_optional}, + [6] = {10, sd_adtc, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, From patchwork Fri Jun 28 07:01:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808171 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp222933wrr; Fri, 28 Jun 2024 00:07:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVoB5bXSQVVPGheis7QD53qdjkf04aGzJ+FiWW7I7LhDc4o+yYikY2f4HAM+HqvDDAFHesuZwJnZhJ/XLbTC9jH X-Google-Smtp-Source: AGHT+IF6DFgJv2F6wHFnki9I/4JlCuYIhINw8BDjh5Gz9ZC+/pg+Ai96J6fTsMNc+ViU5SODdmg6 X-Received: by 2002:a05:6214:411e:b0:6b5:2f57:1a63 with SMTP id 6a1803df08f44-6b5a54496a7mr11837946d6.21.1719558448220; Fri, 28 Jun 2024 00:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558448; cv=none; d=google.com; s=arc-20160816; b=V8L5AUj5WyyhAgtkA9EuQBbO7OMCzwOvofUmzAKK4JGO74yaRiGg2nCO0mnN48jrou z5abfmUnM5nmbgKl1uWbUAbrD2we3cOvLK81b7BE99YTRvvjwA7m3fkF+cpkJE4RVCdT jZ9IfBjM9pav/lKOMfbovPd7Cnnm1lI3+kL8amQBg5nrQJwVhefqMVz6ZWqaAAO18zgH nGZEb3QVdFFeLafoRVio8UkhmMdMEf6nfQFl0cg+E+fZcXhyjiEejxTTGwbFNJpG23cm RYvqWMQX7KQ+lo3o9uZQR/EAFP8wfDP5cLtJ6BHcWJvFTG2L8FtSW0sJR4sxh0ZVR43P djAQ== 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:to:from :dkim-signature; bh=Jc7tRSVNH3DRf6qJ+0mDK79EZ4kJyviqTLrANC5etLY=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=e91EVwqNexVp1QVq+49DTlg0xIl1j+8EVL2fkScwv4VH023KEYG326AnTgIpH3IZtc xO/ZaSbUi1YnVVF787ExtTWHLaIuxDAz+8zkfBLD4etmicbpes+34XW40wAg5yOONYk6 x7f49Lz89ETWMn3yBhRP9KLHn4WDDCElqluumHjZBOydK6h8RktTfDpb732Z+BOorbDZ xve4KBnwkFlsXzj+BvkfXyzd0X18hHfuoyJ0WPNF9+0lIvfa0STDWpbjvMCpVxz8Conk nL1sMFIa8GWQq54So09UqLZe+ILz6GInlQDSdWVcUUzN/085KR4tXwvwQ8GfYoPZ2RTK LwxA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CLZ7MwrV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e363139si14950116d6.4.2024.06.28.00.07.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:07:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CLZ7MwrV; 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 1sN5hG-0005zv-Mp; Fri, 28 Jun 2024 03:07:02 -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 1sN5hE-0005uM-5E for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:07:00 -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 1sN5hC-0003LW-A5 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:59 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-364cdfdaf91so199383f8f.1 for ; Fri, 28 Jun 2024 00:06:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558416; x=1720163216; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Jc7tRSVNH3DRf6qJ+0mDK79EZ4kJyviqTLrANC5etLY=; b=CLZ7MwrVsWTKgGY6+qcJodqzdaDfOrC3SoeSH5q9SjpkIGwYx1oHNsoGmIWpSyxH3V O4WxF7Tsd6v7RH5KgqSE0mzDx/6rGjuzpD5h+eSt6jaZLgrc6AW8N6baVVkJd8k/0/IG N52rtPRacRomG+C/CHWPwN8YvtEXJejn3Wis7KQ2geGNDC1luD3EBgla8tdU8SYiSWsH Q6PQnC/1Z/hhEW3VRT+WAWr5jyLChII/4nYL/zYwgW7tORHn37NOmrrVgw1pNyAbHm2y IYdXSrTAsyG2XAhsiSH1HIhQ4oCXYTAybyeWgcLi9jyV47obTcdWwwHObvLv1+3v7KP7 ajog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558416; x=1720163216; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Jc7tRSVNH3DRf6qJ+0mDK79EZ4kJyviqTLrANC5etLY=; b=XwWLO221NPqHqqV5uxeQshUzejDqpd7xmEkwyh91KjVfsOX/Pypx9c8JrzqmmTXtCx U8QTu2h/VHKlz94KwcJg60N3sdrNekmvDECQmI2liW4VNICLmX4XgoIs15oKftawUTKE Q3Mu9p0/XjyTqL47qggNunn0QJM80IjYXz4yd+HPdFZUbrCxxKaDsKpDOiHAWLXTo+hD tkXtY1BxeMHf65K/63w5fYGLtOeHH6E510yWvMSBRBhlTkYJUUkijAtZxZ/w+DryBNEo Gv0D9UUeuGAktB1XbnKu5cGOasoNCw+Rz1b6pNzmFLbXztOgSfX3uNlScz4epqz75Sk/ 6zLQ== X-Gm-Message-State: AOJu0Yx/YUHxXApWnEzy7fln4JWOajjAgLHzyDy1srMNtan0umeXSPeM mTstBEPZhrx0kLZsGwSA2k9fi0VGKBorhRm1sudRRRcftxaQt53n4B8MT6Q0x+V53O85loGv9v6 tOi0= X-Received: by 2002:a5d:43c7:0:b0:362:a5b2:b62a with SMTP id ffacd0b85a97d-366e9573b02mr8500792f8f.33.1719558416294; Fri, 28 Jun 2024 00:06:56 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fba2dsm1335705f8f.73.2024.06.28.00.06.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:06:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 48/98] hw/sd/sdcard: Add sd_cmd_DE/SELECT_CARD handler (CMD7) Date: Fri, 28 Jun 2024 09:01:24 +0200 Message-ID: <20240628070216.92609-49-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 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=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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 85 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 61c9aff2fb..6ad98db981 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [7] = "SELECT/DESELECT_CARD", [8] = "SEND_IF_COND", [9] = "SEND_CSD", [10] = "SEND_CID", [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", @@ -558,6 +557,11 @@ static uint16_t sd_req_get_rca(SDState *s, SDRequest req) } } +static bool sd_req_rca_same(SDState *s, SDRequest req) +{ + return sd_req_get_rca(s, req) == s->rca; +} + /* Card Status register */ FIELD(CSR, AKE_SEQ_ERROR, 3, 1) @@ -1258,6 +1262,47 @@ static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState *sd, SDRequest req) return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); } +/* CMD7 */ +static sd_rsp_type_t sd_cmd_DE_SELECT_CARD(SDState *sd, SDRequest req) +{ + bool same_rca = sd_req_rca_same(sd, req); + + switch (sd->state) { + case sd_standby_state: + if (!same_rca) { + return sd_r0; + } + sd->state = sd_transfer_state; + return sd_r1b; + + case sd_transfer_state: + case sd_sendingdata_state: + if (same_rca) { + break; + } + sd->state = sd_standby_state; + return sd_r1b; + + case sd_disconnect_state: + if (!same_rca) { + return sd_r0; + } + sd->state = sd_programming_state; + return sd_r1b; + + case sd_programming_state: + if (same_rca) { + break; + } + sd->state = sd_disconnect_state; + return sd_r1b; + + default: + break; + } + return sd_invalid_state_for_cmd(sd, req); +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1324,43 +1369,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 7: /* CMD7: SELECT/DESELECT_CARD */ - rca = sd_req_get_rca(sd, req); - switch (sd->state) { - case sd_standby_state: - if (sd->rca != rca) - return sd_r0; - - sd->state = sd_transfer_state; - return sd_r1b; - - case sd_transfer_state: - case sd_sendingdata_state: - if (sd->rca == rca) - break; - - sd->state = sd_standby_state; - return sd_r1b; - - case sd_disconnect_state: - if (sd->rca != rca) - return sd_r0; - - sd->state = sd_programming_state; - return sd_r1b; - - case sd_programming_state: - if (sd->rca == rca) - break; - - sd->state = sd_disconnect_state; - return sd_r1b; - - default: - break; - } - break; - case 8: /* CMD8: SEND_IF_COND */ if (sd->spec_version < SD_PHY_SPECv2_00_VERS) { break; @@ -2293,6 +2301,7 @@ static const SDProto sd_proto_sd = { [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [5] = {9, sd_bc, "IO_SEND_OP_COND", sd_cmd_optional}, [6] = {10, sd_adtc, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, + [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, From patchwork Fri Jun 28 07:01:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808196 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224376wrr; Fri, 28 Jun 2024 00:11:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUR5f5za4dDt/LXBG9i2NCozrvQ3OiklnWFNfpiVE5HI34DY4j/N/yAoK4Dtj68d8Yji1qNFqnqZbk5siMc96k6 X-Google-Smtp-Source: AGHT+IGHxkQRiWOn/n20Bac02oD0e8z7O6TfXagidppeijRdvReBzi+AeiHNuuJb7P1tBwQj+1w9 X-Received: by 2002:a05:6214:194d:b0:6b5:7f19:e61d with SMTP id 6a1803df08f44-6b5a540a315mr13329596d6.6.1719558719006; Fri, 28 Jun 2024 00:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558718; cv=none; d=google.com; s=arc-20160816; b=mIOVmmDoKG1l7EXVu731hQhw7f24QI2yW4a7mFk72G06G+fo/MSrebuNBq1q3dfpfH CoO+lZ2Azqj4llsDYzWGvV2WclMlHi9Tz0blHvwIEbnAMv89UH+5dpGiCuZkcByc4lyP rFP6nQ8wj6eNJEnRmtx7gRihF5AQ4UuNv/pZ6VgWm7rGfqhVLBVn4nSati8aP2J8QHsr 4+AARg1qdxzEcvk5qxAJrruu87JToZ5ibzBDDQaH8FT8c7UBcJmsxNAIZz1aYvWfcweX 3PLSVCHuatFieXs0JjnP6EwMGWgCtZkisZQYl+wmoUaeteSmrBNUXw39dHNM1z57JS3z RQzw== 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:to:from :dkim-signature; bh=stDFUWod5392Ne89qirOgTqrrl6jkkp2/YnCFIJD5bc=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=BzQdPekvrOs/7ONb7dUy1McdaT8p+0GXIYdkRQtfExSbLN57V9HBrjDj0lPdrObvHV Q32p2anzt59aCPKn3f6FhpvjO7cL768G0IHqlfvsgLVT/hvnm2DV6AkEwHGtOZyi5yT2 nZpp0G5iKg1uwP3CoSuUFrzxNVxi4aBriP/54LjV+ggIv4BQEo1xI8egpOPnDVx2s9ql gzhbCfMylbC20Zfpl7vkQ1LHyK3yCDdIXkOMs60nH59mMe0aG6/YLUmqC98iGYin6ahU y1xrh9YycwX4ROpuFZYFjbCSjDsgDiR+2X69BfvzZ4emGfxNqmrGMnQimhtpFFzfhXSB u2Pg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IGh4WdiW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e5ae76dsi14787986d6.253.2024.06.28.00.11.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:11:58 -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=IGh4WdiW; 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 1sN5hp-0001Ri-Ao; Fri, 28 Jun 2024 03:07: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 1sN5hn-00018x-Ej for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:07:35 -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 1sN5hl-0003N8-Ez for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:07:35 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52ce6c8db7bso414747e87.1 for ; Fri, 28 Jun 2024 00:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558451; x=1720163251; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=stDFUWod5392Ne89qirOgTqrrl6jkkp2/YnCFIJD5bc=; b=IGh4WdiWtf6Eswub15uNZXUMbx65jLZv1GPLpv83tJX8/JPNqBMSG/BUdUyFh7aAMl GBgtys7jYirpXPZ6Jh4wfnZsYa9Wfz6lS6zYuGsc2f/6nLIgSvmoWimIlu5a0Jdqyx60 Htzuwn9DhNykxZZOacqBkWO9knD3AQnGJa4WmsbQ/yxqPQsn670V5tQBP4vtq7T3pOuy 8LC8vbXj9vbzRrpy+j9oX1B8JcowTjJ0qTYZN28jSx0DvT/uktmPd9ReqAb+Ua2KYqda cbxlxgxTUvoxDsPyNxWNdRdV+GdoIcZbNvrRedQiyZyVs/ga1RbVRtjS9aQVGiDKBySM 8LaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558451; x=1720163251; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=stDFUWod5392Ne89qirOgTqrrl6jkkp2/YnCFIJD5bc=; b=mQGvoDSQIUXiO/Lz3AejuE1bdNidwIsqhB4AGCJAXOprT3G7AhiTckCzJPZAEnJNuy OkSel2dSOSsugoAmZdEcL1Plzl7erQZ98TwbScUAPTdpOba6QhF0UBwnCwnts1yUKkeq KB6t/2GeChmoQ7m/h9QERaVAzIHshwzF81W6M1T6OHsQXDBNERWOwT8qhIxDUGRCMCPR EgE7dGkprQZ4yHrpr8xJMVxNMPbXejKDaJ9LL0yv7/Tpo+ru6T/qhNbO51QrH5Ay58Vs fAhWobgcRBZZKZdBOlj96md45qdYawx6hmJdWKDpqSwzBGoKnXtNN95IUws3PsuQZuXh JtLw== X-Gm-Message-State: AOJu0YxV02v/quRSM/VchbMxL7/Nqqnkwjw2knWlGWOdPn+QUvsHXoc/ FgfkZqaOKU4oss9v9ui0fgmIX4PxOCykba+o+8aqZaGxoFCyTbUHDdxIZAqsgUAk+L6kET5ceF6 3f9U= X-Received: by 2002:ac2:5dd1:0:b0:52c:df86:68c6 with SMTP id 2adb3069b0e04-52ce183517dmr9419984e87.16.1719558421421; Fri, 28 Jun 2024 00:07:01 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fc41esm1337522f8f.78.2024.06.28.00.07.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:07:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 49/98] hw/sd/sdcard: Add sd_cmd_SEND_IF_COND handler (CMD8) Date: Fri, 28 Jun 2024 09:01:25 +0200 Message-ID: <20240628070216.92609-50-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 6ad98db981..e2f7e99ea2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [8] = "SEND_IF_COND", [9] = "SEND_CSD", + [9] = "SEND_CSD", [10] = "SEND_CID", [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", [15] = "GO_INACTIVE_STATE", @@ -1303,6 +1303,27 @@ static sd_rsp_type_t sd_cmd_DE_SELECT_CARD(SDState *sd, SDRequest req) return sd_invalid_state_for_cmd(sd, req); } +/* CMD8 */ +static sd_rsp_type_t sd_cmd_SEND_IF_COND(SDState *sd, SDRequest req) +{ + if (sd->spec_version < SD_PHY_SPECv2_00_VERS) { + return sd_cmd_illegal(sd, req); + } + if (sd->state != sd_idle_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd->vhs = 0; + + /* No response if not exactly one VHS bit is set. */ + if (!(req.arg >> 8) || (req.arg >> (ctz32(req.arg & ~0xff) + 1))) { + return sd_is_spi(sd) ? sd_r7 : sd_r0; + } + + /* Accept. */ + sd->vhs = req.arg; + return sd_r7; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1369,24 +1390,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 8: /* CMD8: SEND_IF_COND */ - if (sd->spec_version < SD_PHY_SPECv2_00_VERS) { - break; - } - if (sd->state != sd_idle_state) { - break; - } - sd->vhs = 0; - - /* No response if not exactly one VHS bit is set. */ - if (!(req.arg >> 8) || (req.arg >> (ctz32(req.arg & ~0xff) + 1))) { - return sd_is_spi(sd) ? sd_r7 : sd_r0; - } - - /* Accept. */ - sd->vhs = req.arg; - return sd_r7; - case 9: /* CMD9: SEND_CSD */ rca = sd_req_get_rca(sd, req); switch (sd->state) { @@ -2278,6 +2281,7 @@ static const SDProto sd_proto_spi = { [1] = {0, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, [5] = {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, [6] = {10, sd_spi, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, + [8] = {0, sd_spi, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2302,6 +2306,7 @@ static const SDProto sd_proto_sd = { [5] = {9, sd_bc, "IO_SEND_OP_COND", sd_cmd_optional}, [6] = {10, sd_adtc, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, + [8] = {0, sd_bcr, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, From patchwork Fri Jun 28 07:01:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808223 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225813wrr; Fri, 28 Jun 2024 00:17:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXDkmukhKl6zlr3bZtair/vQ9Ok80+xER5cv+BzUcwlcSOXoK7Jp5oXRr20nKhvOfQWBKf5LPt/oRDl5tKskBqS X-Google-Smtp-Source: AGHT+IFry005JaPPRTooCzVsA7DRCs563mFSQMDwWhERIV0jnzNcD6Il5ci0c0l9YW0Q476dHPfj X-Received: by 2002:ad4:594b:0:b0:6b5:2062:dd5c with SMTP id 6a1803df08f44-6b5a5412ba9mr12085196d6.8.1719559021277; Fri, 28 Jun 2024 00:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559021; cv=none; d=google.com; s=arc-20160816; b=IeWpRMNETr74zyhRREJrG3BX1L4ix5w63zbLduFs/JU5aHYFb1hsPLDWqyo9sIehsY DHD30MPBoHTBch90BJOtT4jCvX62v0+Lecl/NDAan6ikRK6mu1qcA2q40z5mR5eYbzeg S6KnWaaNlyxrdxDYiI/na+0lQ/7ZdWse/F0f3VCGQSuJyZfbE4rBsdS60bkeGYBBKneE O3ZzRKVN2vatRiawfwYW0OOxj+y8e00Tm+li1QpmQzOcI4qku8f49SJzsNiIUNfCh3Vc eeI5DpMDMW3IXa9IQ3MkRVoVzB8XYPWL/MEbv/KF7GBAQz9A/hWcCFHkH9iJ6Gy90wPv stQQ== 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:to:from :dkim-signature; bh=XRCv4iSMQzY9gbLa0i76FE3UzK8b0j6S+r+3bKGRI48=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=D6ONU+JGhkP++Z7iPnXL8jViAoqVpjByWx+5YH8JFCNF2GLeZcc+dU/6OwNUyaOz7N 6ebsjy3cgmTFw2QAUotIqKeNXLRdUkC4MWWtdhfEmtenfTroCspXbkVqEdHExBuPT+M/ xZtBQfFPngcfLr/Ae53YXK02kz+rHtPplm64OWbAMofpEsS7xDbg6Ms7pYdIkt5q3YMs gzPHhk4yD41rRebQ3wU+Bl7T9SC5tGzWsBjzLZmVLFTuNGvWk2eTo5xGnz++ZIPT73Zy reByng/1wV6Bq+lU+MYUEHpQr+rNygwjKRwRkzuZYFY2ueuyXt9oQfjTxF745FYFa+6t 7WBQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZL8cUdtz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e618651si12819966d6.585.2024.06.28.00.17.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:17:01 -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=ZL8cUdtz; 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 1sN5hu-0002AY-DI; Fri, 28 Jun 2024 03:07:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5hs-0001pY-7D for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:07:40 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5hq-0003Nc-7N for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:07:39 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4255fa23f7bso2459845e9.2 for ; Fri, 28 Jun 2024 00:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558456; x=1720163256; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=XRCv4iSMQzY9gbLa0i76FE3UzK8b0j6S+r+3bKGRI48=; b=ZL8cUdtz33+OwEurvP/8DR4sgSPT3BTHrDQSd2nYVhaLa7uqK51daucDwKEj7JgoJb n8w0MpikwlwCdGp1aVs+q46U6PauhZHNhYZt1XqKkNbwbz8DnHGOnALKZ7qAXdhuafo8 NHOT58HTk3Zn+qKDuossDfcItwA99fVjm9DdAfKmENerQ4Qa8HqLqweT3nptXiyRk8P5 a12LVAyyKkptevfF2YIUUZ6pAfHj/Tetp1ICPqwZ2migJRgfKD2E7fvsn1Xpi64pnFQc x7wTG3ptMaiSPLGyMJdBtxFmU9Vp0tBcJSnvrSYkQZlXR78edA+JR2VMDk1PkTOSxRvO UU7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558456; x=1720163256; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XRCv4iSMQzY9gbLa0i76FE3UzK8b0j6S+r+3bKGRI48=; b=ZPer5+47r+r/31SYWTr0Rg/5CxQIsWoHamcNzqnSoeBULMFz4aJlVrdCHJEaNFd4Jq KcQwKCaaLvsJrolipCfEDRdld9HYB0A5o79MRBV980zp2kl/lzTGsc5u+wfTWG9johD0 tdV3gsIPbXDRAbIaFj8c1gfrSKV5QqSBqiGIgfad6TgAvOG5UIMlxgzJlr5AT6ixWLx4 atNFRiynQ6EmvMtjmM8U34P8bkZTCqDAL+V92611uPvBpy0+mTyLJqMQio4ums8Zm503 HIFTqjHRKni8DnUC0WkLey689mtg0UoEpA4s7ILztI5KbIl3dZ9SPx7l+ikqoP9sDo2s WMDg== X-Gm-Message-State: AOJu0YxC/qPlUEf646OB6AJmc4b83W5MJ5GosM38RsEnba5ooF6ZCSdV /eJxCPiKST8b58VdlS4s54TOZ53BF5fnGmj6ExapsN+SJkSVQ1NLtrJ69RLfcOvtb61TWxjOLWi FLmI= X-Received: by 2002:a05:600c:16c4:b0:425:5ec3:570b with SMTP id 5b1f17b1804b1-4255ec35786mr42332155e9.35.1719558456450; Fri, 28 Jun 2024 00:07:36 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b099c72sm21095405e9.37.2024.06.28.00.07.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:07:36 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 50/98] hw/sd/sdcard: Add sd_cmd_SEND_CSD/CID handlers (CMD9 & CMD10) Date: Fri, 28 Jun 2024 09:01:26 +0200 Message-ID: <20240628070216.92609-51-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e2f7e99ea2..bd7c7cf518 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,8 +240,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [9] = "SEND_CSD", - [10] = "SEND_CID", [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", @@ -1324,6 +1322,26 @@ static sd_rsp_type_t sd_cmd_SEND_IF_COND(SDState *sd, SDRequest req) return sd_r7; } +/* CMD9 */ +static sd_rsp_type_t sd_cmd_SEND_CSD(SDState *sd, SDRequest req) +{ + if (sd->state != sd_standby_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + return sd_req_rca_same(sd, req) ? sd_r2_s : sd_r0; +} + +/* CMD10 */ +static sd_rsp_type_t sd_cmd_SEND_CID(SDState *sd, SDRequest req) +{ + if (sd->state != sd_standby_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + return sd_req_rca_same(sd, req) ? sd_r2_i : sd_r0; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1393,12 +1411,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 9: /* CMD9: SEND_CSD */ rca = sd_req_get_rca(sd, req); switch (sd->state) { - case sd_standby_state: - if (sd->rca != rca) - return sd_r0; - - return sd_r2_s; - case sd_transfer_state: if (!sd_is_spi(sd)) { break; @@ -1414,12 +1426,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 10: /* CMD10: SEND_CID */ rca = sd_req_get_rca(sd, req); switch (sd->state) { - case sd_standby_state: - if (sd->rca != rca) - return sd_r0; - - return sd_r2_i; - case sd_transfer_state: if (!sd_is_spi(sd)) { break; @@ -2307,6 +2313,8 @@ static const SDProto sd_proto_sd = { [6] = {10, sd_adtc, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [8] = {0, sd_bcr, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, + [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, + [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, From patchwork Fri Jun 28 07:01:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808207 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224685wrr; Fri, 28 Jun 2024 00:13:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU0SKnmgTOC8M8ZtmtBShmNNVyH0Hw4g41zyDtL1/UrHDCGWKuCPWcLBX6+dT3a/yP5Yuy1AoTcoB/vt+APQcnU X-Google-Smtp-Source: AGHT+IFtDBmCzrEUNszpJENEL7E5IgEARz9BqDzNr25pSb89xk4s9hMBDcs/6wxqdKJOoU19DUbl X-Received: by 2002:a25:b227:0:b0:e02:6e8b:af87 with SMTP id 3f1490d57ef6-e0300f3f988mr17460814276.20.1719558781295; Fri, 28 Jun 2024 00:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558781; cv=none; d=google.com; s=arc-20160816; b=Mfpqt7W1cFTC7vButwrehJuf894mv5FLUnzLStAORX3NgG7k8eb4I0iM45Hsk/OM9V BXhoaKAReELTLgbGnR5ix1umAoHTSDUnanPIrpP6SWKyPY4b3mr3uEQql7LTwPW6P6CC +KGePSoR660NNqWSS5tZ6eqnoKkSjMIz7rq07ufLB7sjvv5HPb68k77Z7vJ7zgKcpmrg 1Dls8zMinBdmZGyQxN6kMzTE5OejeF7MZ4x+22GKCIgpIMCIDnIuboaAXjs8YXi+FLRc TATQR4+/jebMxVPyJ9XLQlWyujd8ZV7YMM3QbTea+lf2nJh7eu5YRbwE2ZdfcKhdt84z PNvA== 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:to:from :dkim-signature; bh=H/Bi9vrwnFZ+zmmMgAN2Gfm5YG78pw+o1VPUAn34pig=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=SL3LZHXuwqxmvYqSmN/WDEX6lLEkL9PzjLqoNP/Ed47Rn59HziP67sxyEPAFAL/K3r UGs4xeA7oXPOpJeWd3LR2tV7FrCFFNQbq6lsEvMhXT+8QyHaLqKBvCXzED1fpybGf8Vo h+Knkw5vTaX9Ff29jRUWnJarWsbf1SqrGMgCIChrch9mhoHsw/x2qAogkjGnJnM3GaHa RgRabH76yFhIest2juNREYsqSPC8OM4wbsxpOHa4Hs7Uw4GzIB/mPSLDEcpiG6x+XR1H V+kzXveFK7q9Ec1jidgGlGG7Z0t/1BWX63uJIBzFEmVG/WZpVSr8wv2EwnZra8O4IvMw RDIA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OumoNjBu; 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-44651485c38si13145501cf.354.2024.06.28.00.13.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:13:01 -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=OumoNjBu; 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 1sN5hy-0002dx-Tk; Fri, 28 Jun 2024 03:07:46 -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 1sN5hx-0002YB-JD for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:07:45 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5hv-0003P9-EP for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:07:45 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-42565cdf99cso3122075e9.3 for ; Fri, 28 Jun 2024 00:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558461; x=1720163261; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=H/Bi9vrwnFZ+zmmMgAN2Gfm5YG78pw+o1VPUAn34pig=; b=OumoNjBuTL0ciK60xAaLS72RoPpaf/cShmQhC1RCobdbouKlywMVpyyj8PvAwUAMBG +1QCtatHKjQ31v/JIRFFXr4q1bW+Z8+Si8HWIATnNXpxT2uBudmMCtKhsbqlRAn/AbO1 D5n/hMmo3TBUa/5G1kSo7mwU+8y6O7KS1hXsEiI2NUgmfMu6u6pM32EZZGg1bmxVRkXf HrrVxcVdIANTVfRwItziwl6JbBVEfgD2r2/JT+wo3fvhHvy66wNcrUsZpVweL5N8V5iq VGaPMiMKsAgRoKbmYi15jAGzrEQcHX5M9aFWOBgyrCIGhFMqKlNVc/NtVDEJXF1EsQos ATVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558461; x=1720163261; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H/Bi9vrwnFZ+zmmMgAN2Gfm5YG78pw+o1VPUAn34pig=; b=snf8zKCEI4eMDn7ctJ2gnA88AzqrFXa1NUzokcNMWivXNfngjol7msJEqHWqlA8oTE 8N9WE8ARkp5n/OHwCdk16fbF8Mh4+yiszS3nTdO59ZnUTFW9E4HE7ozvqQ3erA9jwv8w gryxt7giSD0n8nC4fADY+vrViygW5iCTwmGMc1b7tA2WRjjaXlxtZd7fSIyqM6D3Tnuh TS9To/Mv6rI/bwGdkhKClnPIcywvSEMzXWYVj/3KETz+IOPPSq3pMRqpSZdT77sd7UDL IfZjjk03E3n+cc1UGNt1qE8iaBazBonkAzTwENZz+UKWOkihw2/BP2dlIfNESZkd6ARK 6W7Q== X-Gm-Message-State: AOJu0YwpYvSjHTYNPGGz6eocQDniw09Zsj1YLNWEHmlV65tA2Z2K9CLR KioxLpPalSR0nlw2Zxb/zKxiwmKOPkz8kjO+Y9asTDJOnCoTyaOEjvBSyU16aICiV7es0EgYLAZ qDPM= X-Received: by 2002:a05:600c:681:b0:424:a578:fcc with SMTP id 5b1f17b1804b1-424a5781102mr73259085e9.7.1719558461500; Fri, 28 Jun 2024 00:07:41 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0e1688sm1332840f8f.60.2024.06.28.00.07.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:07:41 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 51/98] hw/sd/sdcard: Add spi_cmd_SEND_CSD/CID handlers (CMD9 & CMD10) Date: Fri, 28 Jun 2024 09:01:27 +0200 Message-ID: <20240628070216.92609-52-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bd7c7cf518..564e08709b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1323,6 +1323,15 @@ static sd_rsp_type_t sd_cmd_SEND_IF_COND(SDState *sd, SDRequest req) } /* CMD9 */ +static sd_rsp_type_t spi_cmd_SEND_CSD(SDState *sd, SDRequest req) +{ + if (sd->state != sd_standby_state) { + return sd_invalid_state_for_cmd(sd, req); + } + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), + sd->csd, 16); +} + static sd_rsp_type_t sd_cmd_SEND_CSD(SDState *sd, SDRequest req) { if (sd->state != sd_standby_state) { @@ -1333,6 +1342,15 @@ static sd_rsp_type_t sd_cmd_SEND_CSD(SDState *sd, SDRequest req) } /* CMD10 */ +static sd_rsp_type_t spi_cmd_SEND_CID(SDState *sd, SDRequest req) +{ + if (sd->state != sd_standby_state) { + return sd_invalid_state_for_cmd(sd, req); + } + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), + sd->cid, 16); +} + static sd_rsp_type_t sd_cmd_SEND_CID(SDState *sd, SDRequest req) { if (sd->state != sd_standby_state) { @@ -1408,36 +1426,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 9: /* CMD9: SEND_CSD */ - rca = sd_req_get_rca(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!sd_is_spi(sd)) { - break; - } - return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), - sd->csd, 16); - - default: - break; - } - break; - - case 10: /* CMD10: SEND_CID */ - rca = sd_req_get_rca(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!sd_is_spi(sd)) { - break; - } - return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), - sd->cid, 16); - - default: - break; - } - break; - case 12: /* CMD12: STOP_TRANSMISSION */ switch (sd->state) { case sd_sendingdata_state: @@ -2288,6 +2276,8 @@ static const SDProto sd_proto_spi = { [5] = {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, [6] = {10, sd_spi, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [8] = {0, sd_spi, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, + [9] = {0, sd_spi, "SEND_CSD", spi_cmd_SEND_CSD}, + [10] = {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, From patchwork Fri Jun 28 07:01:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808188 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223774wrr; Fri, 28 Jun 2024 00:10:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX8RupeJVaZTjGxMe465I0cz8We+sM/Q3O4b9RI9e2OpbGAmlSBP/TinQ2TYMoXJoOU8KWCZ0qsQnyhK3Ni4nWd X-Google-Smtp-Source: AGHT+IF74bBCuz7w2mUqieD1LfTf44E9OHSzGmkimgLXx2oZBLYV2N4lTtbf2oJEdQT8OK4Bc/8N X-Received: by 2002:a05:620a:1723:b0:79b:e8ca:860b with SMTP id af79cd13be357-79be8ca8786mr1671985085a.67.1719558601415; Fri, 28 Jun 2024 00:10:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558601; cv=none; d=google.com; s=arc-20160816; b=dsTNerzcORBT+DM2eNkJDXB1q2HhswATwz7KaHa4aj1y/ObRk35fW2mnk91dFPvpqg Jh3f0Sseq4Sox/YfqTphBOZmUoUvy+THozVKvg28pyP4Kn5IBv0VbLO7U9EQoY+j6McQ hKnWZWmQQBJds62Xgy6UJQJWu3He3xVzSAQcNMjF0aNAhNfk3/Iqu1otAgA+YzQvrDt3 nK4Ibg5bCoLZ/42fTfewAg1dCZKsuzf+cE9pQUPEzEVDUd5/8BYlsuG3JtxjbimC1Goa uhbXddJxs2n2mp2rl+VxUO88DhjNAmdfmz0PbFgROGpqvuX4P8D7+qbfHCaKjbCE2Nn6 RGNQ== 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:to:from :dkim-signature; bh=FsxLv41oI+lmhCr+srqJP++Hluvz2oWQHhnQB9fyk4M=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=hzf6hpVmAcm3UHlQQWCcT82iq8qMZXh13jezneiptPTAdMZspr7/Xsrd3QCvxJQQYK OAukgLB5G7iGpdHUUPzTiArdh6/OxKsjVe1Uw7OR4FkUwADarI/WpjMS5eyzaC7ZpdZd QFOINHxQyMwDJ5Vu1Bwzrq9iK638Oa4XTL/gYaIpvmp29Bkxspe847d7gn3pbgdPFjpv yxDqc/Vl9vFCTgjIO8eaQXvHROZMdgVUcBglol3M2Hz+1FToaJVl2oBHRsBdDU3cdT9s mMRFxw88NyNJvRcbj0hWtrGXfoyqJIHVqiDAGd6YVqnJmsNBHIJUKdYxozGl5TM1JY3s HRaw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=egvnj1Lz; 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-79d6933b3c0si121674885a.684.2024.06.28.00.10.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:10:01 -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=egvnj1Lz; 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 1sN5i7-00035Z-0V; Fri, 28 Jun 2024 03:07:55 -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 1sN5i3-0002uU-D5 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:07:52 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5i0-0003PK-8C for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:07:50 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-424720e73e1so2530725e9.1 for ; Fri, 28 Jun 2024 00:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558466; x=1720163266; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=FsxLv41oI+lmhCr+srqJP++Hluvz2oWQHhnQB9fyk4M=; b=egvnj1Lz+31lcbWw+AURd5JLyHP3GyqW9bN9MScXbChHNO22jRr1lObNxotM/xQ5f6 qRU5v1iqw/e43pt0YwNJUKGJ68f64P0CWBKUWjfe97vXN+pmmo5EA4k7ZtMi2PYDDjXO Rox0lUhRRx4I2cbDlCkOl2+G0F7rBzQ1wEc7eEnj3knyH97d9HWyv+0K/1w+JylHryOn aAKU1trKyPjNW9Bouy7ZFxP2jFyoP+NDIebv1EJ70DzRAQIhzs+r6icvdwLRALrsub1M xSm5KFpjmYRheKxjGpTbzT3XPpc3U2zsiOMaCZ41DVkIPkvu4NBz+i/M7/o8aQwqyIul a5Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558466; x=1720163266; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FsxLv41oI+lmhCr+srqJP++Hluvz2oWQHhnQB9fyk4M=; b=kx+zT1rSgk4OlHNnAZoZVN+i9ev51vzhGvoGT0atftVvb5NQkQbKMOMC8rU5l6XrZ0 iGMxxdo4GuRR8mg7qLMAtQh+PAgAcbwhb7IlbwiRcaggWg3yAcn/9vNBBux2r7SOLoT1 2bMAOfR+5h34u3Yn4iZ35QRh0CRZgPt7vFJoo48blnZCBRxxUarczk8gd5QmWR3OwE66 2daD1S+5hW/hwMcA5s6zK3cHJgGDKV23z5SvpncpFOPaFLX17/s95FGzOQLnC/+xoAMh N9QVZRsxwhh+juHUz8Src7I2CemFiVPWX/M0sx9Lloe+OgI8LGvQTn07OMU6QMkxuuHt 9MaQ== X-Gm-Message-State: AOJu0YwC4uraSdg+YjvLoIL1vc0I7hkg6Vz5D4KD5o69phgl0bBMSJSJ td+Pxl524Hpbi4oSJnLzS4S83fYBSKlpPEyd8w6cjuqf9ld2kdE/CVwsEvEPXrHrSpqZFnekapJ xz2M= X-Received: by 2002:a05:600c:1c29:b0:424:a5df:b998 with SMTP id 5b1f17b1804b1-424a5dfba38mr58706555e9.9.1719558466561; Fri, 28 Jun 2024 00:07:46 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3cfc3sm21796845e9.3.2024.06.28.00.07.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:07:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 52/98] hw/sd/sdcard: Add sd_cmd_STOP_TRANSMISSION handler (CMD12) Date: Fri, 28 Jun 2024 09:01:28 +0200 Message-ID: <20240628070216.92609-53-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 564e08709b..1c092ab43c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", + [13] = "SEND_STATUS", [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", @@ -1360,6 +1360,23 @@ static sd_rsp_type_t sd_cmd_SEND_CID(SDState *sd, SDRequest req) return sd_req_rca_same(sd, req) ? sd_r2_i : sd_r0; } +/* CMD12 */ +static sd_rsp_type_t sd_cmd_STOP_TRANSMISSION(SDState *sd, SDRequest req) +{ + switch (sd->state) { + case sd_sendingdata_state: + sd->state = sd_transfer_state; + return sd_r1b; + case sd_receivingdata_state: + sd->state = sd_programming_state; + /* Bzzzzzzztt .... Operation complete. */ + sd->state = sd_transfer_state; + return sd_r1; + default: + return sd_invalid_state_for_cmd(sd, req); + } +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1426,23 +1443,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 12: /* CMD12: STOP_TRANSMISSION */ - switch (sd->state) { - case sd_sendingdata_state: - sd->state = sd_transfer_state; - return sd_r1b; - - case sd_receivingdata_state: - sd->state = sd_programming_state; - /* Bzzzzzzztt .... Operation complete. */ - sd->state = sd_transfer_state; - return sd_r1b; - - default: - break; - } - break; - case 13: /* CMD13: SEND_STATUS */ rca = sd_req_get_rca(sd, req); if (sd->mode != sd_data_transfer_mode) { @@ -2278,6 +2278,7 @@ static const SDProto sd_proto_spi = { [8] = {0, sd_spi, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, [9] = {0, sd_spi, "SEND_CSD", spi_cmd_SEND_CSD}, [10] = {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, + [12] = {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2306,6 +2307,7 @@ static const SDProto sd_proto_sd = { [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, + [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, From patchwork Fri Jun 28 07:01:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808206 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224684wrr; Fri, 28 Jun 2024 00:13:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWvLtPIKM6Z9HkwzUn1IrlncKhOIk0CMAyf8OwP7WNNk+1owD5QtqHy5ujgAFJ8FBbRgDijskhmIuVOWu5/9qHX X-Google-Smtp-Source: AGHT+IETwRRZpbi0m4LjrNZKLjBWuHIhS2skhhC7XL+Qx09UL5Ju+1YEvY9hKzrM/yHl5eG1d427 X-Received: by 2002:a05:620a:2494:b0:79c:119e:2b36 with SMTP id af79cd13be357-79c119e5e31mr915150085a.29.1719558781064; Fri, 28 Jun 2024 00:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558781; cv=none; d=google.com; s=arc-20160816; b=vlk87ySoi+GR0Y+RcBHWUp1B0ko02NmWaUhvaNgPw2EPnMvdRaoxEMaw8VlJ+W8Nel 0wbU30bxb5ZZd0lyekARHrCULCQ+Y88VATQvOSHWQj3hqshpNVSTsHP4y8+c73elb7Zs 6XjteEokwo83ZL6DZPhzOFp55vspahNO/feVe8k4gyHrRGx2VynBxnBo68wCvRoDjjPk jei8N5pR3nE4HWKCIwdJuRnhw4q1neTxsEQX6ewXWCkcI5Cjh8HTUHbeIt4qYSkh91Kf SWjnm8+EEErR7U8gBiAaV/tEB78G8gi0/Tb2IwdWNAwnIdq9jiY3DSKQMUf86no/pD4R YOyA== 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:to:from :dkim-signature; bh=4nsIUIKAxv1jJ77cujJiWISIWdMZfiLK/guukYvkLv0=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=Z7DisqBVoIM6NuWbis65DS3dS9OtaB4vDdpc4zk9i+iSpCiPlvJ4hMzW4Q2r5T0gFm BL0y6HujNC4OCMoE3I/2v4W4NVrk1y5rZLgajmrJX3wlBVugLN/p7mzbI4vy5tuisHPW LLxb5/ULAGfaaufem1FpQzkDu4UK2tejUgSqND4042lomEIIjJ3KiMZPs7n85uW8fetM pv+ovOR8sKHxL1UpbQTEcSPINrjqH+tBQosLkhphJ5Q67orVTif8pxs/h2KLh0/ihPhJ nCMdOd5dwwxZX9h4LmVRlPGRZjuWnIDyz0SaHvutuA3WwmmAfxf9olywAl070tyO7iA1 bzkQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q9vjo1Uo; 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-79d69264b55si122816185a.85.2024.06.28.00.13.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:13:01 -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=q9vjo1Uo; 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 1sN5iB-0003GY-Uz; Fri, 28 Jun 2024 03:08:02 -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 1sN5i9-0003Am-1D for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:07:57 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5i5-0003Q0-Mb for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:07:56 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-362f62ae4c5so138207f8f.1 for ; Fri, 28 Jun 2024 00:07:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558471; x=1720163271; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4nsIUIKAxv1jJ77cujJiWISIWdMZfiLK/guukYvkLv0=; b=q9vjo1UoOac/xLcjpH3EGY1j3jl2tMm6hQ7yV/a0z0tsooqehb6iVWNWLHVt04D/q9 SoNvmJrnqFSP810Zo+NCgPK0HkHrJbnU62yqBmqZUPx6eUqwNgrXIN7DowuySIsHSNso /LkDnf/ilrmuiWVUtXFlOSbP79FAxhWjILHV9XPUc7qOAVm/r5v2xGUa3ppGinhwzi6A RZRAd65fDHT0z1z3vLOR9I8DSilApuhAbcGLbWsMBVdeSGoatiL5UyzPmZPErthjBfeM 9UB7uZ8tJmPXPz/nSOD1XiL+l1cA56zbCeBskW/3e/2tuPJ4+OlPxLXscJv9H6opOoZu 7F5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558471; x=1720163271; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4nsIUIKAxv1jJ77cujJiWISIWdMZfiLK/guukYvkLv0=; b=d1IjzxomfKwiAXVJX/pOpM5JYE7cXCgSKn9e60D5nC9ZBdlCu9Wpc3CT5/5tIGFKCc kLEyWl/7TYRYINr2RI5bs0do4Fu5hd5kUjjnnrIuGSIZkEHgBOaU7hIvZvhFRkB/HjA+ /zc5bGEGVEG4WPjS0O3jPyWANpFXY7eA1IooKvGRIrzkeVS7zWkZuvVT8AFvGDAfI57v y1Dk4IrtpXhkeoJ8/K2ef7i6bt5Z19EVoqLnPlgucTq36oFEJegHHNU8Fe+Tdg1O/xAX IDSj01lFE3WVSm3VIv+erIwCO2M/TuBg8b/vgPNunzcc//ptal2qvH0hwwjZ/HpMzmU4 KurQ== X-Gm-Message-State: AOJu0YzYvM6GHyfqwGE+RsE8lRXemPiiGld3vYMPywt3ULnGzn/1aXjn ZvagwftEMus08RapRKzeOrZ4gpANX8N8tjhPfFfrUcE+FarPyLSD56J46/pHYrmLa85IzPmOIJW RlfM= X-Received: by 2002:a5d:63d1:0:b0:362:4679:b5a with SMTP id ffacd0b85a97d-36760a7832cmr575548f8f.16.1719558471647; Fri, 28 Jun 2024 00:07:51 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd72asm1339592f8f.10.2024.06.28.00.07.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:07:51 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 53/98] hw/sd/sdcard: Add sd_cmd_SEND_STATUS handler (CMD13) Date: Fri, 28 Jun 2024 09:01:29 +0200 Message-ID: <20240628070216.92609-54-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1c092ab43c..bb80d11f87 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [13] = "SEND_STATUS", [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", @@ -1377,6 +1376,32 @@ static sd_rsp_type_t sd_cmd_STOP_TRANSMISSION(SDState *sd, SDRequest req) } } +/* CMD13 */ +static sd_rsp_type_t sd_cmd_SEND_STATUS(SDState *sd, SDRequest req) +{ + if (sd->mode != sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); + } + + switch (sd->state) { + case sd_standby_state: + case sd_transfer_state: + case sd_sendingdata_state: + case sd_receivingdata_state: + case sd_programming_state: + case sd_disconnect_state: + break; + default: + return sd_invalid_state_for_cmd(sd, req); + } + + if (sd_is_spi(sd)) { + return sd_r2_s; + } + + return sd_req_rca_same(sd, req) ? sd_r1 : sd_r0; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1443,17 +1468,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 13: /* CMD13: SEND_STATUS */ - rca = sd_req_get_rca(sd, req); - if (sd->mode != sd_data_transfer_mode) { - return sd_invalid_mode_for_cmd(sd, req); - } - if (!sd_is_spi(sd) && sd->rca != rca) { - return sd_r0; - } - - return sd_r1; - case 15: /* CMD15: GO_INACTIVE_STATE */ if (sd->mode != sd_data_transfer_mode) { return sd_invalid_mode_for_cmd(sd, req); @@ -2279,6 +2293,7 @@ static const SDProto sd_proto_spi = { [9] = {0, sd_spi, "SEND_CSD", spi_cmd_SEND_CSD}, [10] = {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, [12] = {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, + [13] = {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2308,6 +2323,7 @@ static const SDProto sd_proto_sd = { [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, + [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, From patchwork Fri Jun 28 07:01:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808219 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225478wrr; Fri, 28 Jun 2024 00:15:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX9x4ZPtP6zx+tYiCc/t6YwrWYb9Epej3KkS91wgcQX3MJb9Oqd+PzBeAGxR10ql2um+lD3ey/2QY4S555V+5uT X-Google-Smtp-Source: AGHT+IFYphbzHejs56szXV7Rga0M98d/3UTP5DaUDqtCloxagsz1MTCGSQCkvWKCFHqiufhvfcpP X-Received: by 2002:a05:620a:2a02:b0:79b:ee4e:8362 with SMTP id af79cd13be357-79d6b6d0fd6mr137105985a.0.1719558947045; Fri, 28 Jun 2024 00:15:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558947; cv=none; d=google.com; s=arc-20160816; b=eXgJylyF0fxb8Q4o3++thZ/xHPgnKmb3XNVmfzb+StsGxUaEicEet0xHiyYnQkGItD AJP2TTT46DHOJLzhK2l2EgGqTEj3YmpQnuiIOET8cKUgSVuLx6RtxrT8xdcPWPC/zBEs hKO8SDnFRvbhSiZKt972hBJM0bMYNcWxzf5bbgaRPUKIcpt0JzjCD4+zFenG2Mg/KYXR oksspXLi9srikCoRv8T0mqn8RYXuI4hXS2Fvca4K/N2CjBVjedALnf3fyrOLhaetgVwy w0H3GtAnEgGjMX2B6ES/fCbwYMZeY1lJ2qUndxlRJ7EoicwDsePuxfciLZ01yIrgf7Tc Nzeg== 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:to:from :dkim-signature; bh=wED9lVuSIJVna4+aCIAwx+9S/4ApkNiJ+n4u5rDB9Rw=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=uA6B9ZmBKviffko8y2Wo6Cl5dPviailOWcrlt/8hptg+TCs2T/Y7Qt+CAi/hOIxOJR jkvfISfvApnPa214DtS+OFi9oxnAPPmX/yJMnegA8SS68ZDxT497AArLpLYe+JSRCCCS XO1GkLRUn+mYyqg/CBZ4y5jR0ziYfHrLDmkk9/LZYJ/nu8IlKoHwBbwQsKTsXTbiF1On Uu2GY7rlEeCrIfLyGu2sq0JXGE+nKlOgwWuXpK/zwMOB8pxltr/qmKv/RTXufqNdsOAF 8WC3cAyYSYBfDo0IQynCH1CvQcw5aA9LZn1zjKyMGLC7SmwnZle5pgdQr+FNgqq5TvHh CXvg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BXFniOJt; 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-446514c1f37si13116791cf.568.2024.06.28.00.15.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:15:47 -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=BXFniOJt; 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 1sN5iJ-0003V9-Fc; Fri, 28 Jun 2024 03:08:07 -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 1sN5iG-0003O5-Rc for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:05 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5iA-0003QM-N2 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:01 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-42561c16ffeso2618265e9.3 for ; Fri, 28 Jun 2024 00:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558476; x=1720163276; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wED9lVuSIJVna4+aCIAwx+9S/4ApkNiJ+n4u5rDB9Rw=; b=BXFniOJtGwTowF1Wb42HmNOEjT011/k4PffiB29z91IzNdzH3FAHm6VCDBy364oym3 LTY7v+W+OQkvl5+YISHAslr8VJ/i/vGHzJt5UqHZzThpgniad2sFrC+Dq4lKzcLmJWdJ 9mK1/iP0p6aP/cLTaZxeR+jjhSSDEm+JtVLN87PdTQ6FEDkYfCmQluHaBaHVfFG6KWuX sli4eq3+vn5htW92VNgpIg24gsABKYpK0svkj5awXrPx6yTKA19DbbdAsVbYsjSh12nd KiAmFKtnSep7KqHlwXrIG1brPUm9fad4lQVhxU8kbl/1XdNVAso1OEL4BcsNCd7k/cG3 FvzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558476; x=1720163276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wED9lVuSIJVna4+aCIAwx+9S/4ApkNiJ+n4u5rDB9Rw=; b=PCLCDlgFBQap6cAT9v/JC8RpMoxuqiFwudGGVwEfY03Jvn83TZO7s7Gw1KNsbElBo0 el5B/mDM8A/t0DZd0HnP1M4ajTuRIJ99A8WVk+Pxs1inn0Z7oTh3KkAi6d9zyAJ6B4VM TGagtFlZWSn2G6oAlizIqkiOVTkJZePJnah2G5+Q9P3jw9SN4Fv2lS7uyIMdcJ5QKNZQ COWhWBLc1tTRA58ZZRXDTStt57qA05Qh+sppqhL6WfeuRe8qwEg+j4eqZTXVTxPDoJpA JkXbtuRwSqgv7yVoIym+YQ/8dJ/DRzGrjP/Q2O5Q440xbOuuxLKB0TH6XhAHcYY2VMqW hiQg== X-Gm-Message-State: AOJu0YzrjPWt4ZO0tN7CKnQn+jspaMEGhBd20m4JBAVi9RdhxjhiHstN jYM0rD1YNDmjA7STOnPuIr4v6wTLmoAi5T0zD846JM5hf7di1DlC8Ya8tljypJWbKifC9OX3F+R dBVk= X-Received: by 2002:a05:600c:4fcd:b0:425:672a:768e with SMTP id 5b1f17b1804b1-425672a7849mr22553215e9.4.1719558476632; Fri, 28 Jun 2024 00:07:56 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fc623sm1328893f8f.87.2024.06.28.00.07.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:07:56 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 54/98] hw/sd/sdcard: Add sd_cmd_GO_INACTIVE_STATE handler (CMD15) Date: Fri, 28 Jun 2024 09:01:30 +0200 Message-ID: <20240628070216.92609-55-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bb80d11f87..d7ed8aee73 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", [21] = "DPS_spec", @@ -1402,6 +1401,30 @@ static sd_rsp_type_t sd_cmd_SEND_STATUS(SDState *sd, SDRequest req) return sd_req_rca_same(sd, req) ? sd_r1 : sd_r0; } +/* CMD15 */ +static sd_rsp_type_t sd_cmd_GO_INACTIVE_STATE(SDState *sd, SDRequest req) +{ + if (sd->mode != sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); + } + switch (sd->state) { + case sd_standby_state: + case sd_transfer_state: + case sd_sendingdata_state: + case sd_receivingdata_state: + case sd_programming_state: + case sd_disconnect_state: + break; + default: + return sd_invalid_state_for_cmd(sd, req); + } + if (sd_req_rca_same(sd, req)) { + sd->state = sd_inactive_state; + } + + return sd_r0; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1467,17 +1490,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } switch (req.cmd) { - /* Basic commands (Class 0 and Class 1) */ - case 15: /* CMD15: GO_INACTIVE_STATE */ - if (sd->mode != sd_data_transfer_mode) { - return sd_invalid_mode_for_cmd(sd, req); - } - rca = sd_req_get_rca(sd, req); - if (sd->rca == rca) { - sd->state = sd_inactive_state; - } - return sd_r0; - /* Block read commands (Class 2) */ case 16: /* CMD16: SET_BLOCKLEN */ switch (sd->state) { @@ -2324,6 +2336,7 @@ static const SDProto sd_proto_sd = { [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [15] = {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STATE}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, From patchwork Fri Jun 28 07:01:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808183 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223428wrr; Fri, 28 Jun 2024 00:08:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVm4AVcDZWwU6NEetxXImkD5QsoZeHqeDHAa+VRZBRwsyZMeZ6ZZ9mYHWK6MeSty8EVxJeMzK+erqBRgDfZDG67 X-Google-Smtp-Source: AGHT+IHVjDJmLtyidZn50oLvY7rRU1+WK71jH6Bqm4cgtmSjZlgKyvLHQtnIltY18u+wVj7G14/I X-Received: by 2002:a05:620a:19a9:b0:79d:598e:1f96 with SMTP id af79cd13be357-79d598e2374mr579156185a.61.1719558537008; Fri, 28 Jun 2024 00:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558536; cv=none; d=google.com; s=arc-20160816; b=0aIEB+iblayV5WrkDqRebE2uuRmyEMkio+cH8Vw720SoTi3Igk4IyeS5rmC/Z2yAaa lR2DqSmo6NH3hrnEe63kSd6IIDt9qF6cst+so5fRGKFtIE+dJ9FvUlnQMD4QtGOyBtlW iPpyn75vamhH8vbzk450jMPtUP/KaPYey7gFhaezt8lN1uasat1SuxAKAXDSHRddW4DF OROEkpqCK6AhKid17Z6x0gLAv+EjwE/muRckA6rnVAwffU/17TvCUdM4E4jqIPW0Jp6T f/eAKbhqiVt6w3rBR4y1R9czBFiFUUos2/yPW1wncvvAbhgoFQtkdDhyfrW3+pjRRGmo APgA== 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:to:from :dkim-signature; bh=/x47xZoGwEv6OAz6MBmyY9zpVBzbWRJPcmwD+bMVYlw=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=N19UoYt5vTYonS3XXqjaN9DSz0IfEuJl7sfEKn1lNKpDrUXOVsG7K8mW8ej8KLVO46 3NjedZzauRcwlOrb7K9rJC2fQ6GUkuwT+IGoiyXbQOoqCkebD2iH0cEvZJfhnMRgDeME OJHdiYKKTfUl/5WupRrgoMuMRbQ97bNdEwltC9qEnJt9fVPX0/5DrJzADPPBz8Z62kKc rFSEB11IKdOW2joxPj52twcBrwcS13/OPZ569CcdonC4CQaEqz6tQ+izRSeK8LypBlBV +zoWd6nYdVKk38BynS+62kc+dNUmi0ucGm1Npx8PQgpf1YLMZTZy6SBoy/ayZBeW9FZl WLzA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sa1JGnia; 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-79d692f0c92si122610985a.232.2024.06.28.00.08.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:08:56 -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=sa1JGnia; 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 1sN5iS-0003ib-Av; Fri, 28 Jun 2024 03:08: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 1sN5iJ-0003VY-D1 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:07 -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 1sN5iG-0003fI-JP for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:06 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52ce6a9fd5cso265548e87.3 for ; Fri, 28 Jun 2024 00:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558481; x=1720163281; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/x47xZoGwEv6OAz6MBmyY9zpVBzbWRJPcmwD+bMVYlw=; b=sa1JGniaYicBLzcik/xnkD/uQGKIq1omdDeL1GJXblgsrJ3qgRE2RalbUsFOqgnTVm caQPRxfkXogr+rAlV4KPuC5xoWhidev89536ffebAtF3efnK9HoNNPXNQdtoZ191NkXw hRWns0bLi4LpagK+jehz1QfLq5jI/6gUT1sXuaw7Rq8YeycKzuGv1xRRLPB7C52QRilr hblir5XPJPzpYcBRGYPKbm7w0SXZuMfSV9EBEv0rBsgt5rqOz3YmBJmEr0gf2IJR1+Rj TFF87ReYnJdvW5FSiYUf7GnUfeFW13uUoSqUsZihmohNm9nehpaglHsoRQ6ydkDmaKwh sFWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558481; x=1720163281; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/x47xZoGwEv6OAz6MBmyY9zpVBzbWRJPcmwD+bMVYlw=; b=eiAaTusgzE3kDAF0iEQpH2Sj1rz2A5gFuLP8PB5LKt+JscoTjehlFbZDvYCSpy/KWQ r8vVQnRy04DkHuDSDmTiyesWK3MTr0RGmu16ksl1DHDBEvospnsUIX4vlaJGCedRzY9e 80EGNNhJSPJyusol5vMK3I/6NHklDwDzGGfbrVvWW4c4KQCpozbGGUirItwdUG6ftFC2 OFh4PBuOSoO+Z1u3iIny7s2AV8RT0J0zFtkXXyOIqp90AoggODcNtSWNf6ZUl2FqvM4A vuBDSR6JdM9YprNBv1Srlpz5ydMgwqJRvfTKvzdTf0rZqcUPnIqzrLMFMbsNUB7Jwz3n 1ufA== X-Gm-Message-State: AOJu0YzoybJynZeNy/E4YNQ+wSWRDQKAW2fVc2sxyslhqrdDT2u34Mnv gVBs0OsxQkAhxZHsqxte9dQ2ZhWDEg3BMhGVpg3et57Y6TgLv3h9Q0vB8igNTcaJgjQ2fu2eWNX S21Y= X-Received: by 2002:a19:6b03:0:b0:52c:8339:d09b with SMTP id 2adb3069b0e04-52ce18327b5mr9879299e87.1.1719558481672; Fri, 28 Jun 2024 00:08:01 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd778sm1355702f8f.5.2024.06.28.00.08.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:08:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 55/98] hw/sd/sdcard: Add sd_cmd_SET_BLOCKLEN handler (CMD16) Date: Fri, 28 Jun 2024 09:01:31 +0200 Message-ID: <20240628070216.92609-56-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d7ed8aee73..d731c3df58 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", + [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", [21] = "DPS_spec", [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", @@ -1425,6 +1425,22 @@ static sd_rsp_type_t sd_cmd_GO_INACTIVE_STATE(SDState *sd, SDRequest req) return sd_r0; } +/* CMD16 */ +static sd_rsp_type_t sd_cmd_SET_BLOCKLEN(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + if (req.arg > (1 << HWBLOCK_SHIFT)) { + sd->card_status |= BLOCK_LEN_ERROR; + } else { + trace_sdcard_set_blocklen(req.arg); + sd->blk_len = req.arg; + } + + return sd_r1; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1491,23 +1507,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Block read commands (Class 2) */ - case 16: /* CMD16: SET_BLOCKLEN */ - switch (sd->state) { - case sd_transfer_state: - if (req.arg > (1 << HWBLOCK_SHIFT)) { - sd->card_status |= BLOCK_LEN_ERROR; - } else { - trace_sdcard_set_blocklen(req.arg); - sd->blk_len = req.arg; - } - - return sd_r1; - - default: - break; - } - break; - case 17: /* CMD17: READ_SINGLE_BLOCK */ addr = sd_req_get_address(sd, req); switch (sd->state) { @@ -2306,6 +2305,7 @@ static const SDProto sd_proto_spi = { [10] = {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, [12] = {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [16] = {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2337,6 +2337,7 @@ static const SDProto sd_proto_sd = { [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, [15] = {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STATE}, + [16] = {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, From patchwork Fri Jun 28 07:01:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808205 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224619wrr; Fri, 28 Jun 2024 00:12:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCULBQFIYGisvfx+XK4uRfLnlIOcElvfXvJ/4HkyvUPUo7HrSjPQAHeNGfS7mkL08OL1kjGHhQKWrnX0Gp8B6adS X-Google-Smtp-Source: AGHT+IH5Gllc2O1ZhqK/nkFiBKiITKUALZvU+iLK04YBJBYCMZBkvYYJuRB7Y5B5WJzcNL9EqyIE X-Received: by 2002:a05:620a:2915:b0:79d:6ad0:d7db with SMTP id af79cd13be357-79d6ad0ddbdmr88805585a.43.1719558766992; Fri, 28 Jun 2024 00:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558766; cv=none; d=google.com; s=arc-20160816; b=u2HpSZq4XukCHViX5PQmtt9xMHX14XIzUYus0N8HbqRfRMvyeFe8fYVl0De0pKag4k sLeoju1kKaZ5TpOmmHcyoar7X12DpjkWPWeeIKcQECLe+JYkKRZjDV0J3gpXs9ai2eLB BvfwY29cKNnBLIKDnQXlSs7KluuZKcml173JP28+NqELnl1q0k852REbbb4IdiRZh+cd d4tRDefsJqwEYXwpJeD77bGuizIxGO0zTmYUTt3nW5J1ZOuFZjEiWJyI4OOkvlt7zJOt s9YgZa4j29fzug5tHLh1BCXeodw25BcnqDT0gFuB4e0RQeI6Io3WpdIeNCHOCpnnobCI Mfmw== 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:to:from :dkim-signature; bh=vajGPnoCMySfBXhKCpWI2G0uKNcFQdTzNyXEs7BknL8=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=weBCVYEdpWAU/S9rTD8vUcpG0VqDCPBHA0e4CoY322W7HiZxyeQkOseiBp0ZmRl0XA Tw6l7Ky7uJosit4XJfU1nD6sVPa58UL9tigD0TV8agZLMNBkCAXULRiiEARyGTaevzwu R/gFAu63yyRF3MuXTxK8Cw/a7QupPoXCOujXjWN/zNXjy9MyQBln0bEvbWiQqWWz0UyF 2Ru+lyEStGIZFSvJZnUt125joZnHthIG3vQDt5+OO2Wdar2/P2DyRlsZ1CLkwmO2aoK4 qZieP3mWvnHlCJaRRZOyw758bqEZIcC6fxTiYtsBonuYkstftsvLUgoyZlHpoe5NQNeR f8NA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="REsP/mOA"; 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-79d6934bdfasi118267585a.713.2024.06.28.00.12.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:12:46 -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="REsP/mOA"; 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 1sN5iY-0004Ux-3c; Fri, 28 Jun 2024 03:08:22 -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 1sN5iU-00043o-Qm for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:19 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5iS-00043v-Fk for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:18 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-42567ddf099so2321025e9.3 for ; Fri, 28 Jun 2024 00:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558487; x=1720163287; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vajGPnoCMySfBXhKCpWI2G0uKNcFQdTzNyXEs7BknL8=; b=REsP/mOAJMUta8qK0S8faM+Vx62fyMDUi0x+qqj+BqBo1huRPVw5RnukRKh0p+f/L3 V4hGmGOTnSppAotac0NWA5d5EHRkE+KsoZqNxblVzOMA0qSZPVlCVaOMRgMvxgS3/E7c OOrDxDWDMC5LAvVrOim03g016Hcz77JXi3PdfjeVDmZL+0OeMD0jlpPRVGkCMC0RWJBJ pYXusC+67Mfkme5oOPQh5ut8/vLIjLZHIeDGLGdjpH9cVZDKUpTXbHXbUFgjWrJIezRB FBQKk2FeyCEHyf/4i+xJSCDzjhqPzTmPK4hxAjYNRp26i+lyIJjgFCvMLWu30XoMrRgc A/oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558487; x=1720163287; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vajGPnoCMySfBXhKCpWI2G0uKNcFQdTzNyXEs7BknL8=; b=JzKvlMwpQm/e/BV6QJezeFrRT/lcIl9psZg62+XO/mdqW4CBOTLxmDge0nnq/E3dNf pFnrDta2H+PKfLrW0J8fxNuCP206dGjx8rpGLvywFGS2Gt3+QQmKLpyD8lPk7T8fBH+V jiGmZ4TsysFH6XG4MhfJ7AgXf5FONN/VavevM4TteZrljlSz7xaAxK25r7ZU+wnZtb8r zgRs6LtdHqTH7Fi9Fj6ljMu/Hj3UcsR7oQ5zJyGzGLXYIggDKIXI98evemAw4bAcQw2L aWKrcnyvln4SnQlJaDG/AP2mIVvjhBgP3rIAfE6FxVLJ7lLx4duEUzg2mNszyyjTYZ8H GyeA== X-Gm-Message-State: AOJu0YzvlnDgWqYv6d0Le0DUv5xwU30esOhgKKNRbkm7d4ld6qIcyak7 vb29A6nhXXsm09x7PWHuYPckB+5AF8U5yZkgO6lMD2FACyWVJ1ZQot/A9NckkA0oEyoqU18ygsC /K/M= X-Received: by 2002:a05:600c:138e:b0:424:7bcf:2486 with SMTP id 5b1f17b1804b1-42489e3708fmr108897145e9.4.1719558487163; Fri, 28 Jun 2024 00:08:07 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af37734sm22770345e9.10.2024.06.28.00.08.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:08:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 56/98] hw/sd/sdcard: Add sd_cmd_READ_SINGLE_BLOCK handler (CMD17) Date: Fri, 28 Jun 2024 09:01:32 +0200 Message-ID: <20240628070216.92609-57-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d731c3df58..e2a7ed8b45 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", [21] = "DPS_spec", [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", @@ -1441,6 +1440,24 @@ static sd_rsp_type_t sd_cmd_SET_BLOCKLEN(SDState *sd, SDRequest req) return sd_r1; } +/* CMD17 */ +static sd_rsp_type_t sd_cmd_READ_SINGLE_BLOCK(SDState *sd, SDRequest req) +{ + uint64_t addr; + + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + addr = sd_req_get_address(sd, req); + if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_len)) { + return sd_r1; + } + + sd_blk_read(sd, addr, sd->blk_len); + return sd_cmd_to_sendingdata(sd, req, addr, NULL, sd->blk_len); +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1507,22 +1524,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Block read commands (Class 2) */ - case 17: /* CMD17: READ_SINGLE_BLOCK */ - addr = sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - - if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_len)) { - return sd_r1; - } - sd_blk_read(sd, addr, sd->blk_len); - return sd_cmd_to_sendingdata(sd, req, addr, NULL, sd->blk_len); - - default: - break; - } - break; - case 18: /* CMD18: READ_MULTIPLE_BLOCK */ addr = sd_req_get_address(sd, req); switch (sd->state) { @@ -2306,6 +2307,7 @@ static const SDProto sd_proto_spi = { [12] = {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, [16] = {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, + [17] = {2, sd_spi, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2338,6 +2340,7 @@ static const SDProto sd_proto_sd = { [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, [15] = {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STATE}, [16] = {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, + [17] = {2, sd_adtc, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, From patchwork Fri Jun 28 07:01:33 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: 808236 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226464wrr; Fri, 28 Jun 2024 00:18:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWolkEq6IU1iCc19CvDu5eAPb36J8iaw/pFkUobYwLemgkvJMQP7DrxEiyZ8QdoG6V8jmcJhMxlJNXShl66xR08 X-Google-Smtp-Source: AGHT+IH7LewMT4ZEEeET1QauaD35haJEmW3j/Hc8QNDycD+OO1nSgsAK2Q2zXCQ6Ficun53ANbLB X-Received: by 2002:a81:9192:0:b0:646:53ce:b365 with SMTP id 00721157ae682-64653ceb36bmr117022757b3.42.1719559137747; Fri, 28 Jun 2024 00:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559137; cv=none; d=google.com; s=arc-20160816; b=tlpNWtDnBQ8MncQOFPwHaTEBXBJqzsWopFmtSm+Nm6I+unQsrO/5qYBMEhS2+hp22t 05nC1LV7+In78FtDyQDqGJNs5FuvNaYALqke4iXTAXZ7uqh+RTVD4oi2ISm+teN3olZ+ UENJvAYWlq/NXjWQykEIa5iV4iB9uTvJMSsf9+j2oiAF8EL7Acugmfhub9Mnvz+I7ey2 Aaz9WUm5GGtsSPDgyZYNve9Rauw0y1LnGNkO5E2W1Yt0SGPWgEzYJtncjag9hxP4vtUG cNgjELQyGco/787U3MX4ObrIsCPApdssYaydjf2rMlXrg0ej9TCAgmbQ24XTOal+RDc2 QTWw== 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:to:from :dkim-signature; bh=QJ6b4+TolgSwbj9JxT9jbN1DwNz8KwrcgVlUMC5kG7c=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=yNcWLV7pGbdc3LlOxtDstLsqAo/apkLmE9vr5ljjb27gx9C5144uptL5RogUb8YqC9 1wskplqGxV3OWNbwQxOfVX2aZ4cl6+7GxG2Edu0hdGRxJFjm8Dnj9Pi0puGYGws0Tuwi bIk5Jak813gvC5Xy3e7GO7UGQTTNSE0fSvGyteZIIeBRMV9P9dksvVhEJPQ1B4yWLJfE 1wKW2Vd5rHvpLHZOWVqIyzxL2wXkDJNnR+HhfzYEBcqc4AlftG8mmZ5qbU0ZY+RlZqmm pmnycAQZmiAo1+X1/Q0xP3j2nkMobc32XU/GINKzqpESqbm07fkhg6LZkcuL/7e+mzuE m54Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yF1LgLyc; 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-44651485f56si13225311cf.390.2024.06.28.00.18.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:18:57 -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=yF1LgLyc; 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 1sN5iW-0004JN-DV; Fri, 28 Jun 2024 03:08:20 -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 1sN5iU-00043z-SZ for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:19 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5iS-0004Mr-HS for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:18 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-36743a79dceso862856f8f.0 for ; Fri, 28 Jun 2024 00:08:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558492; x=1720163292; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=QJ6b4+TolgSwbj9JxT9jbN1DwNz8KwrcgVlUMC5kG7c=; b=yF1LgLycPUkPkjC23NTg/Kw3PQnWYW7TW+raxudZ1SYEGn3wNAaHEh+iFzV6R+vp+x /d7k2z/4tWfRycuc+RUO1B9xWQwkomNlMoSmKLX388yjf62H1Tcoq6Kzv1RbsE0b06n/ NOMWF1AN1LnBvds6W09cNDq/vzO5Ve3nXDpzIK4JjkT2MghI0SW93UXVHqBPm1tM9FEf n2ubpn1DL3M8z4aEMafVqGFjsweC/gdHHYvUHsyb8Aqk718CpbRtSTVgtIEDUvOGStUf 6PnCt3Uuz6HCzkDAtJnc/15fajsIpu+QOCjCtZL2ivkGKjsk9KUwEdg9WRMjCdIEziPT 1W0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558492; x=1720163292; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QJ6b4+TolgSwbj9JxT9jbN1DwNz8KwrcgVlUMC5kG7c=; b=ZOe+ElfUa9dOqiCRicAEhJLIGSuXvL2Nw3wVhYF6aIOJcUeYNDMwhBkR2hspH5gVGC am0TcocrR2cmTLp3r/JjSxJTojARSN4OAmHdNauuPxcEVgteG1mDdT7KBfOVWFLv2njP 81nHlHav9vdFWWf5WWU1WIw25wkVyp0tGNL0gJhxKPtLzn3Pxq9ZPVpLkFoJUiJYbVGE dnZzDNiBGkXKEiHe84IQFnHCcuf0daqyjrBfA81gj+vJ1MLPNHFuRI7tRJHnjkqrixr4 76qZoWGqn9iDcl/DrjyytIU4lw/ugR51dGCgGgINQ3Qni49AgBufYl/KmBQvUh7RRp7Y fDCQ== X-Gm-Message-State: AOJu0YzI70EZXu7r21rOPHvYAh7lN8zWXWpTpCX6L6HrJf/orSC4J5tp haRNxl3HmrsRNtemcekVzG+fN8jzWp/5UXx6anSkcg4REttM0gGaYJgGmKcKWDGJ2xWQtJy46Yt rHIc= X-Received: by 2002:a5d:554b:0:b0:366:ee81:b87c with SMTP id ffacd0b85a97d-36760a7dd7cmr624079f8f.15.1719558492192; Fri, 28 Jun 2024 00:08:12 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a1030dfsm1320674f8f.100.2024.06.28.00.08.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:08:11 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 57/98] hw/sd/sdcard: Add sd_cmd_WRITE_SINGLE_BLOCK handler (CMD24) Date: Fri, 28 Jun 2024 09:01:33 +0200 Message-ID: <20240628070216.92609-58-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 57 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e2a7ed8b45..4650d20ee7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -242,7 +242,7 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) static const char *cmd_abbrev[SDMMC_CMD_MAX] = { [18] = "READ_MULTIPLE_BLOCK", [21] = "DPS_spec", - [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", + [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", [27] = "PROGRAM_CSD", [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", [30] = "SEND_WRITE_PROT", @@ -1487,6 +1487,33 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) return sd_r1; } +/* CMD24 */ +static sd_rsp_type_t sd_cmd_WRITE_SINGLE_BLOCK(SDState *sd, SDRequest req) +{ + uint64_t addr; + + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + addr = sd_req_get_address(sd, req); + if (!address_in_range(sd, "WRITE_SINGLE_BLOCK", addr, sd->blk_len)) { + return sd_r1; + } + + if (sd->size <= SDSC_MAX_CAPACITY) { + if (sd_wp_addr(sd, addr)) { + sd->card_status |= WP_VIOLATION; + } + } + if (sd->csd[14] & 0x30) { + sd->card_status |= WP_VIOLATION; + } + + sd->blk_written = 0; + return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1544,32 +1571,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; /* Block write commands (Class 4) */ - case 24: /* CMD24: WRITE_SINGLE_BLOCK */ - addr = sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - - if (!address_in_range(sd, "WRITE_SINGLE_BLOCK", addr, - sd->blk_len)) { - return sd_r1; - } - - if (sd->size <= SDSC_MAX_CAPACITY) { - if (sd_wp_addr(sd, sd->data_start)) { - sd->card_status |= WP_VIOLATION; - } - } - if (sd->csd[14] & 0x30) { - sd->card_status |= WP_VIOLATION; - } - sd->blk_written = 0; - return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); - - default: - break; - } - break; - case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */ addr = sd_req_get_address(sd, req); switch (sd->state) { @@ -2308,6 +2309,7 @@ static const SDProto sd_proto_spi = { [13] = {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, [16] = {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [17] = {2, sd_spi, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, + [24] = {4, sd_spi, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2344,6 +2346,7 @@ static const SDProto sd_proto_sd = { [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, [34] = {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, From patchwork Fri Jun 28 07:01:34 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: 808185 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223726wrr; Fri, 28 Jun 2024 00:09:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUr3Yyi3hG0c3ZROxgyYRNNVS3gcmAMbTrwAlBE74o7ZaaLzliPFELk+2OqWMCbOqXRNWMbPbaoXD+ddJQ8+RvK X-Google-Smtp-Source: AGHT+IGz1hG8b6NHIaZNYq4ijVl2ftXBwBhMg+6YVZa3ZqCY5b9ZYj3Bhunu2S611+gguTeqchZJ X-Received: by 2002:a0d:e843:0:b0:62f:3278:a635 with SMTP id 00721157ae682-64a754bfc88mr22789727b3.20.1719558591782; Fri, 28 Jun 2024 00:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558591; cv=none; d=google.com; s=arc-20160816; b=kMmUOQrmc4tXvxnplYANSLP1IvkZ5lH8YM8VX92Cu+ycy9D1hOeiwg64SHHtDKGHd4 favP4jmGcW+RbvPDBS8FQzWxUKRfYt0vAhL1JllMK/L18Vqu5xiNlraSuk7Hzsd8RLOf NvrO5CDg15sJFG36E7huW1yWUeFtOEwWGdy9Ar46pqLwuyaOKAvpt5cZqH0Bhih6f5fm gyAGnci9MflOOUSUFq+3mT5/SElIE/s5tHqUfNy6gmv5JzM96uyUuIaNPb2Bn2er827Q ZAaNgjPLPVrCteIHj8tJjqH2BeVcm8D2X5MoMy5XePIcfAE0KU97NNqWJMIrxKCYLWYN 5Enw== 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:to:from :dkim-signature; bh=e77sqfrLYi9SLwpkQhHOa0XqG0+lUrwsgw9mW5fMvkQ=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=KPJLtU4RAEb2p3t360p2b5Qs12WhoCRtr96XwrhLtFc7oJC9dDUgxuqumRWTcborJ+ nN8aQzgt4+LoNfJD80hMdRwnVMhopihBKjJqWElDO4sUhkYJuoHdPOiIO2EW8lIvbmPe eek+iF0xHhBEdjoWDO4r2XykcnwkJbhOWX2iXlAokHCG2lY319I85JZgFeBXx54kHpz5 r4wIS6yv8NZOi8eIZ7V5OQ5JAG8d4xfrP2le4AbuXxju1UDnZZicyPYAeyM8E/AJA2X/ 2M7av/rbXwXAsegLQmcYL9JlnPn80PzfkOefpKoOi+/hVGFQDIg3wdSxxzTLntkgN5rq 8UwQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r1pZeVsd; 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-446514c0f0esi13076281cf.556.2024.06.28.00.09.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:09:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r1pZeVsd; 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 1sN5if-0005AA-99; Fri, 28 Jun 2024 03:08: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 1sN5iX-0004W2-TL for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:22 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5iV-0004Oa-JP for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:21 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4255fa23f7bso2463835e9.2 for ; Fri, 28 Jun 2024 00:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558497; x=1720163297; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=e77sqfrLYi9SLwpkQhHOa0XqG0+lUrwsgw9mW5fMvkQ=; b=r1pZeVsdLEnbf+OsYvCtFvw8TkEJKTI+in9OZNfapSp77NvSvOe02Wi2fuWMTIWRWj HoY6oJGHO3lrlLq7TKmDilBN8225JgxJ3+CXa6q6qkCfo/diWX1ZULDEAKClE4AM3y9s irYdVzzOZaHO/uxhfrkK4NvRdUcTfydP/hifLnSgU8CLzFMp94l8w/ZdFr6ogrO73KSW iq9sSmPs3BqY2q7uFeq8whTDDDAdtTjqGZ98SzaMXMAcoUCz4EpSrAlP/vtgB7d/8rzV R8O4ZG4Yaa4kwSWOSdSu51seDUXR70Ka27djn2WvOja/d0b76oMysdzaw6B6Xt+DqtmV 2DKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558497; x=1720163297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e77sqfrLYi9SLwpkQhHOa0XqG0+lUrwsgw9mW5fMvkQ=; b=SbK4bNPUxTL1hO+/NMgx+HWeCyZrEW1o4h+HDGkTNMcasrkuX5rnEugU+MEFMXQcbi n0m3b19+UQ8v/ycvUM0zdbLSZFZr41+sgdYEsk8sKarh4/36/lPvl/dw2mFdTQeIXmTZ K9KSfD2jbPDbZPZf2a0+OXxHIlAweAcoCP+r/Oo54cuMtS4EONqknU4ECxhpSO7vKhyB odN4gamPSyglbXSjlJhqhoHG1X80f5vPJuyMujBtP05Ke5SBGBo/WHapDiLwOOoGgj2N gXNSlZ1zgui2ViKEuDQiDILBUVEfoRZ8ccUxAHVAKKDlmdbdK5xzNsoYREvwYBjFvezh kzBw== X-Gm-Message-State: AOJu0Yy9wFwCxJHnb/uCkjctB2EOWlq4qbDNx3XY3a8pvk+lXVNucsS6 UdKbw9K3DBvKwMf0ZcxLbMSfq8AsWqC5bV4DzVg8xniuoQBnpwyQgDJeg/sW90MQVdTc3OqNv45 UoSA= X-Received: by 2002:a05:600c:a:b0:424:ad14:6b79 with SMTP id 5b1f17b1804b1-424ad146e41mr45810345e9.8.1719558497356; Fri, 28 Jun 2024 00:08:17 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb97esm1328884f8f.89.2024.06.28.00.08.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:08:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 58/98] hw/sd/sdcard: Add sd_cmd_PROGRAM_CSD handler (CMD27) Date: Fri, 28 Jun 2024 09:01:34 +0200 Message-ID: <20240628070216.92609-59-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4650d20ee7..9d33113f11 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -243,7 +243,7 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [18] = "READ_MULTIPLE_BLOCK", [21] = "DPS_spec", [25] = "WRITE_MULTIPLE_BLOCK", - [26] = "MANUF_RSVD", [27] = "PROGRAM_CSD", + [26] = "MANUF_RSVD", [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", [30] = "SEND_WRITE_PROT", [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", @@ -1514,6 +1514,12 @@ static sd_rsp_type_t sd_cmd_WRITE_SINGLE_BLOCK(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); } +/* CMD27 */ +static sd_rsp_type_t sd_cmd_PROGRAM_CSD(SDState *sd, SDRequest req) +{ + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->csd)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1603,9 +1609,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 26: /* CMD26: PROGRAM_CID */ return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); - case 27: /* CMD27: PROGRAM_CSD */ - return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->csd)); - /* Write protection (Class 6) */ case 28: /* CMD28: SET_WRITE_PROT */ if (sd->size > SDSC_MAX_CAPACITY) { @@ -2310,6 +2313,7 @@ static const SDProto sd_proto_spi = { [16] = {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [17] = {2, sd_spi, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, [24] = {4, sd_spi, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, + [27] = {4, sd_spi, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2347,6 +2351,7 @@ static const SDProto sd_proto_sd = { [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, + [27] = {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [34] = {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, From patchwork Fri Jun 28 07:01: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: 808209 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224698wrr; Fri, 28 Jun 2024 00:13:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU+E3MYwIytLiwBsy2R9o8Ka5tln/LdMxyoGwcdkgbbJxQLBXkRQ5wsSXaiHvbg9qIFmqlmLVC6De65MYYuS6US X-Google-Smtp-Source: AGHT+IH3NSK0osI4mZcf5Qb5aOutL+3/4ElJAZ+GA+4l59re4qscCdHsr8AM9aCK9EFewH7nVjUq X-Received: by 2002:a05:622a:6fce:b0:446:5965:9550 with SMTP id d75a77b69052e-446596595c3mr1940991cf.40.1719558784833; Fri, 28 Jun 2024 00:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558784; cv=none; d=google.com; s=arc-20160816; b=zAWBYTBcFkUsPEj659xYNp9L5cbjqumUCQyM619LcX9IYnz0oaw02bD0H6NmtU8We1 K02g4S9PaHWhVRaAZQiy0QYzwt4SWlffrmPMOt3g9Hmtt7Ub6rbeY55XET/+cNDfRuPB 4Yliawu3GqDxtcNBsuZ5XOW/Nh3U5N0j+3xOWqhSglOpSAmvLz5+hq/y4pYOovBl2EvY inMm4d+1yGszXvv2m+yO599GsPS2PZxr44czy7QdriJyg/uVhVYxSSBJP5vyJ6/xtRCA x/QG3PPHSeeQxsiznxHuYkwG1S8d7IqK+ORaUZIUMm13UtWj+MhgWFwv6rzPjMdfgRbs C2BA== 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:to:from :dkim-signature; bh=F6oigTn0Q2A4tjfIsZSpx2Wne2arec43lvnPbuSKAbM=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=zW5e+XvoZKqAUiMEa/zNrzgf3HbK2TLrG2qFoliI3RvBlm+o9/msZbul6ymq5qTSAH SLcJg+9qKtLlJIPAHppIOkMhqFFlCKfq+dVQdP0u6MMK4QCW0YB6rahU4olM3bxlB2dR dNdrvLY0piA7QLimU+Av6GF/F8pAxHIfQ+ACl2wCB5yd+2CNX65kFZc2UrM5xm17GPLq DnhUbQ4uuhIC/q8gLv50tLfUlGOHPP424IQsS/GCuygv1e+q5dRlzf5x0Ko06ExeDg4/ K5yjo28n987OkQgZqCwxuD8Vg785EW/edGEAtjnQd7DUtQs/zdk70Xd2cdCz8tKKcQUN TOUA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OnJjYbSp; 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-446514e6a74si12893431cf.779.2024.06.28.00.13.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:13:04 -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=OnJjYbSp; 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 1sN5iw-0005Zy-J2; Fri, 28 Jun 2024 03:08:46 -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 1sN5ic-00059a-6W for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:27 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5ia-0004Pi-Ap for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:25 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-424ad289949so2345635e9.2 for ; Fri, 28 Jun 2024 00:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558502; x=1720163302; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=F6oigTn0Q2A4tjfIsZSpx2Wne2arec43lvnPbuSKAbM=; b=OnJjYbSpN+VMgPgu0odyyb7Co8YDrJHKlzfMm1CDOE2SPAb5ZcGf6gcLPrkX2j9iu3 hkLP1eVRCT1+4xeaIg4Ay0jtT3dOWirIDhicTiuF02kPe+0D6hUGArAtwWncW1AxxdFD +r6px/gMfLZ77hsvJMEhKnpmksFHS1/AMhgtBXsgmTDz7eHbALsZlmcsL3dW1WF7l78q rQBVEHnMYoqwUut3PR+CTc+O3FQM3JH4NyexwsDlCAGgkkZpqEIcLPOIrNQ5uVfAEg4W 0DOZDrS4fHl6W8qk8vI2H7DxcyQEyomvq6uGFeT9k+sRRGvTzJI+JMs3Om5FgysDSpR9 DhBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558502; x=1720163302; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F6oigTn0Q2A4tjfIsZSpx2Wne2arec43lvnPbuSKAbM=; b=vI4xm/AXUknbjIIYSO2sQdH+dIM+4qHPgyfhMY6ST7sJ0xdiLPPAJGczCx295oN7Kn PyV7gPJMtJM7rsJs7vRolfjyKuWjkS/npDoB6D8LW/gWn9uXR0smExe3j+qNv2vmIhtI +Zf1KCkYrUgpI5S/Omcva+NIpN0rMhWB0PD5Xjx05bJwoenfPG9fYvW0En2FAttYCS86 xiuS9xEu3k+h4EgLHZ/QgmHrD5lTfhd/XcJ9ScTzDnbWVehCaBEjjX0Krh1xAipNoUjl /Yf8JHqv6eYKgpMrWYYEmVllL4Db/R/+TVfeKIeVIV03Ve7wRI5p0LBR5E8GmFx9E1S7 Kz2A== X-Gm-Message-State: AOJu0Yx8wCfVkyThGARmHeDILBsCIMrpcyiVfdql6vLS10u+ANJ1YJy0 wjBwqeFSIxWnKbfRBNerreKJVn26pZVaMv8de0SCnUDNOS2PgYQ6wZ2pebyr0azaVyaZXh1wAe2 vK00= X-Received: by 2002:a05:600c:1c90:b0:424:eeca:6bd0 with SMTP id 5b1f17b1804b1-424eeca6c69mr44430225e9.13.1719558502449; Fri, 28 Jun 2024 00:08:22 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd72asm1340694f8f.10.2024.06.28.00.08.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:08:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 59/98] hw/sd/sdcard: Add sd_cmd_SET/CLR_WRITE_PROT handler (CMD28 & CMD29) Date: Fri, 28 Jun 2024 09:01:35 +0200 Message-ID: <20240628070216.92609-60-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 91 +++++++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 9d33113f11..a63213613b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -244,7 +244,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [21] = "DPS_spec", [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", - [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", [30] = "SEND_WRITE_PROT", [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", [38] = "ERASE", @@ -1520,6 +1519,48 @@ static sd_rsp_type_t sd_cmd_PROGRAM_CSD(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->csd)); } +static sd_rsp_type_t sd_cmd_SET_CLR_WRITE_PROT(SDState *sd, SDRequest req, + bool is_write) +{ + uint64_t addr; + + if (sd->size > SDSC_MAX_CAPACITY) { + return sd_illegal; + } + + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + addr = sd_req_get_address(sd, req); + if (!address_in_range(sd, is_write ? "SET_WRITE_PROT" : "CLR_WRITE_PROT", + addr, 1)) { + return sd_r1b; + } + + sd->state = sd_programming_state; + if (is_write) { + set_bit(sd_addr_to_wpnum(addr), sd->wp_group_bmap); + } else { + clear_bit(sd_addr_to_wpnum(addr), sd->wp_group_bmap); + } + /* Bzzzzzzztt .... Operation complete. */ + sd->state = sd_transfer_state; + return sd_r1; +} + +/* CMD28 */ +static sd_rsp_type_t sd_cmd_SET_WRITE_PROT(SDState *sd, SDRequest req) +{ + return sd_cmd_SET_CLR_WRITE_PROT(sd, req, true); +} + +/* CMD29 */ +static sd_rsp_type_t sd_cmd_CLR_WRITE_PROT(SDState *sd, SDRequest req) +{ + return sd_cmd_SET_CLR_WRITE_PROT(sd, req, false); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1610,50 +1651,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); /* Write protection (Class 6) */ - case 28: /* CMD28: SET_WRITE_PROT */ - if (sd->size > SDSC_MAX_CAPACITY) { - return sd_illegal; - } - addr = sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!address_in_range(sd, "SET_WRITE_PROT", addr, 1)) { - return sd_r1b; - } - - sd->state = sd_programming_state; - set_bit(sd_addr_to_wpnum(addr), sd->wp_group_bmap); - /* Bzzzzzzztt .... Operation complete. */ - sd->state = sd_transfer_state; - return sd_r1b; - - default: - break; - } - break; - - case 29: /* CMD29: CLR_WRITE_PROT */ - if (sd->size > SDSC_MAX_CAPACITY) { - return sd_illegal; - } - addr = sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!address_in_range(sd, "CLR_WRITE_PROT", addr, 1)) { - return sd_r1b; - } - - sd->state = sd_programming_state; - clear_bit(sd_addr_to_wpnum(addr), sd->wp_group_bmap); - /* Bzzzzzzztt .... Operation complete. */ - sd->state = sd_transfer_state; - return sd_r1b; - - default: - break; - } - break; - case 30: /* CMD30: SEND_WRITE_PROT */ if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; @@ -2314,6 +2311,8 @@ static const SDProto sd_proto_spi = { [17] = {2, sd_spi, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, [24] = {4, sd_spi, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, [27] = {4, sd_spi, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, + [28] = {6, sd_spi, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, + [29] = {6, sd_spi, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2352,6 +2351,8 @@ static const SDProto sd_proto_sd = { [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, [27] = {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, + [28] = {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, + [29] = {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [34] = {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, From patchwork Fri Jun 28 07:01:36 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: 808217 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225439wrr; Fri, 28 Jun 2024 00:15:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWillG74xzQOugWG/zYoYkEAS3l7iQFk2yT8BHq/Llz57MM2VPDf5iQ+AyynQhIMwUj7DKgg7bl5oLY1RpblIkM X-Google-Smtp-Source: AGHT+IH7YfSoixDamjvzEygzaFxYhKZBNgZNctPZLAQTddmpXAwiq7WG7pw6sp+LoRCrzBsByQWs X-Received: by 2002:a05:690c:6889:b0:648:857c:1530 with SMTP id 00721157ae682-648857c15ffmr79049657b3.34.1719558939869; Fri, 28 Jun 2024 00:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558939; cv=none; d=google.com; s=arc-20160816; b=Q3wTrQlTxC+jTlXP+bWFQBCpTGoinpHhfm7qHintHLRhekfeCbT3jtR7CaIe0BaMoL CgWMGbP3Yog+01UmV8UT6dhOvCBOiDTHv2eGaoYdpwPkH+oaE3U5zEUo4U+HSt3Juafq YSoDohyPigfLRJCXm0bwh6XXA7Q1d0EmS0esvSODSY6pjemABt8RpEsMjywJ5hDTDZnq 7Q4khfs/YNi5G0F6/o3aZXkDk2353XgtHWYT92SeuoPDzMipYJW8aHCKY+nzEbSne3Zj 6zmbzG1cLE447+zxpbw7iO6KC3seykuWgLn7354XEoPApiNMJbUJAWaa4NyNILIpN4R6 JkbA== 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:to:from :dkim-signature; bh=PF/YVa5FANPMIRP5k1k++097xYJKGaWnEtemmw/L2o0=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=UWQd6b4HZuA2hQb440ITvUbBxJUlYb/cLPIIV9F66zvA5yrvNfoBZ7N0D/UcqFcQ8X 4T3djYyGEuJknBF/2vxaVTKgmV2ycwiGEXX3mvoAFyJdzA/BDJ1MzOz8kGYrYmQBuirc cgLM0Zv8UXU6tG5KtXawnafQmsxJG1d44ouVwBjYXaqfwVn4tGJqmA2rTWtkiKJgZYm2 HGB+axWfZnlemwINvQQPjh3oQSSeTAFf4tbzbVCvWHyM4aajFXoeBfceHuRH8EX5OwpP 8rMeQWkZhZrnokzj/Fe5A7+ryMjK4Uw+BhYCt4SyWnZpec1MDqfDlwji9lCeoDBl+pET ji4g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VKLV4Qu3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e36c26esi13994796d6.148.2024.06.28.00.15.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:15:39 -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=VKLV4Qu3; 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 1sN5iv-0005Yn-Uj; Fri, 28 Jun 2024 03:08:46 -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 1sN5ih-0005Ee-9l for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:34 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5if-0004Q7-5K for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:30 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4256f102e89so1273295e9.0 for ; Fri, 28 Jun 2024 00:08:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558507; x=1720163307; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PF/YVa5FANPMIRP5k1k++097xYJKGaWnEtemmw/L2o0=; b=VKLV4Qu3G/9NEeDZbMn/OtGgeEkYVijO+7ME8dVoz3Z4qO1oIzqfKN8f9O16J42A+1 i3mQu2BUJGMZNdM7XShf64JkD8VtYA2Bc0qEZsgiKtYe0I0zPXKBWdB0VyCJochoNXaQ wL1wagk5AS6wdh11wo6S36jSAWvWwOxh9JX20/aNugTd7HuvJnogJg7Z8UT5mG5DEsqD +BJW8r2zmUn9RLdPN8R/UJAdBOBqdEWm2jVimO3gtJl0K5VB4gQad1GZvDTabaT1s7RL nwDux9w1N2Sx9MnCDezkkZ4NBOkiiqGvTOPz/lml5dIDcRK4mR52IV3QMhLKzutd7lcS 9vPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558507; x=1720163307; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PF/YVa5FANPMIRP5k1k++097xYJKGaWnEtemmw/L2o0=; b=Ge5eDoHAo6M55qRKO5RjxG/4xI7Snwn8LOTV5NTVd5v5soOKbSytTPvNc/Jn+3/8d0 XXmGa3vPT+c9C4z9SuM1R9cMyYJqc8NCUP6zJG9FDuZu8W05HTbdRHviVSdEOymYVnPt yinpVPVO2LJ70W0jzT0NzDKPZ3Vb2pJHUIDlJDMfjhL80DVsQyF/uo1vNmTuVo80FU82 7Nlr6ZjK2NPwBpYzm1aYj2vi476NfnIHqF7GiHxASPrYGFJz6AIlePfu9dGzpMwy0aSv 9vbOX+gBtvxq6iQuH3tXloeyWHnl+O6T15HZjddwMmnG4UVevYTWf5sw4zlgKC5H9J8u e6DA== X-Gm-Message-State: AOJu0Yy3dTL0wYijVjhS9zi4g3+OO9J1xIAAGB3rLl59X/rfziMTvNQM Fj/AOpPx3CgrNEeNWPWkqtFyTWIOmmWv4KllcDWHFbajWYEmnb3KixEdzPGulSFLuNgnZNkzwsd chSE= X-Received: by 2002:a05:600c:4881:b0:424:aa41:4c15 with SMTP id 5b1f17b1804b1-424aa414d2bmr59229035e9.22.1719558507565; Fri, 28 Jun 2024 00:08:27 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af55e61sm21452605e9.20.2024.06.28.00.08.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:08:27 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 60/98] hw/sd/sdcard: Add sd_cmd_SEND_WRITE_PROT handler (CMD30) Date: Fri, 28 Jun 2024 09:01:36 +0200 Message-ID: <20240628070216.92609-61-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a63213613b..bf9975e9b1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -244,7 +244,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [21] = "DPS_spec", [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", - [30] = "SEND_WRITE_PROT", [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", [38] = "ERASE", [40] = "DPS_spec", @@ -1561,11 +1560,33 @@ static sd_rsp_type_t sd_cmd_CLR_WRITE_PROT(SDState *sd, SDRequest req) return sd_cmd_SET_CLR_WRITE_PROT(sd, req, false); } +/* CMD30 */ +static sd_rsp_type_t sd_cmd_SEND_WRITE_PROT(SDState *sd, SDRequest req) +{ + uint64_t addr; + uint32_t data; + + if (sd->size > SDSC_MAX_CAPACITY) { + return sd_illegal; + } + + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + addr = sd_req_get_address(sd, req); + if (!address_in_range(sd, "SEND_WRITE_PROT", addr, sd->blk_len)) { + return sd_r1; + } + + data = sd_wpbits(sd, req.arg); + return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; uint64_t addr; - uint32_t data; sd->last_cmd_name = sd_cmd_name(sd, req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. @@ -1650,26 +1671,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 26: /* CMD26: PROGRAM_CID */ return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); - /* Write protection (Class 6) */ - case 30: /* CMD30: SEND_WRITE_PROT */ - if (sd->size > SDSC_MAX_CAPACITY) { - return sd_illegal; - } - addr = sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!address_in_range(sd, "SEND_WRITE_PROT", - req.arg, sd->blk_len)) { - return sd_r1; - } - data = sd_wpbits(sd, req.arg); - return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data)); - - default: - break; - } - break; - /* Erase commands (Class 5) */ case 32: /* CMD32: ERASE_WR_BLK_START */ switch (sd->state) { @@ -2313,6 +2314,7 @@ static const SDProto sd_proto_spi = { [27] = {4, sd_spi, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [28] = {6, sd_spi, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] = {6, sd_spi, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, + [30] = {6, sd_spi, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2353,6 +2355,7 @@ static const SDProto sd_proto_sd = { [27] = {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [28] = {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] = {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, + [30] = {6, sd_adtc, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, [34] = {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, From patchwork Fri Jun 28 07:01:37 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: 808203 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224559wrr; Fri, 28 Jun 2024 00:12:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX7l6oIxnbIf/4C0hIw1i2fyaChGO/Ttc/NLDXUOUF9ImPK67UoY2NKvo/L4vHmxUaTM9YxaEpg0H2Q/l/uFYay X-Google-Smtp-Source: AGHT+IETamzY9BH2rP5AK+obnF6pZKJHbYRu2viD6EFjbRAiVt/SyttJscsqTBOXu3uS6hBMekES X-Received: by 2002:a05:620a:941:b0:79d:5414:68e6 with SMTP id af79cd13be357-79d6ba40399mr113169685a.1.1719558757848; Fri, 28 Jun 2024 00:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558757; cv=none; d=google.com; s=arc-20160816; b=Kq0zbv3fOmYxucPezGhWoidfI7xog5KywzXDAZsCRAU7ypjR3q7mLLKO6Jzw2E0HqF eXUvWJK1SucbrK/A1c4l60eQtrgonsyNFHoDKrLNWivvWiEzWTFfNG7iPHVejkWBsTde kvB4OrJNqCH19Vr9oPGJUp9RE1M051Yava8t+9edBocVKmbRSbUi7Rp5d/bLcIR5lLA6 tZKCwt12KJe4XptLoE8wA1BWA0Q+218Mc/Gd/0Z2NgzWqSnr46vR3i+MKw7lICXeLLpK wraDVGxEuOpbZraV1fCoinxFM7QND4lLRKmQdoxg4nRI60L6KYmJi5d3Ru4jCGHaYxAd Yl2A== 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:to:from :dkim-signature; bh=HkQna1pAjg6GCvSqtEv1yfUmIYCR6WFUzViVX0SSBYo=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=rXXFiEtl6LaUdB6sO3Pf0J91cQI5xcGU3ehHkmhKgfao2gSCn7opatmvLsn0YUEzpO aySrjE1e324sxLNMaTKnwEEGZwaQW3GVauTbcjklx/VxzFl+acimqH21hZ/jZgYPZs47 XzFQ5UWFsCoPsHwCSnNw/x6VmrvIwix5fvQH7PEFz5/N1LC6PhdLAZCFF/DkfpWNzxMb aHh48ragLrmy07XIu6TqvqVamJ3LCREYfz4NAMCHz1ud52/19PsPlCdap1LOj+zJzuv5 /drETLm6h3O+9UE4/zQUGQ+IAG2LNjK9muYFW9Yc5eFJv99ViycXrhqbNb+O5hTnFRHW 5llw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TNcgBl3o; 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-79d692f0632si120368685a.264.2024.06.28.00.12.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:12:37 -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=TNcgBl3o; 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 1sN5iz-0005nF-67; Fri, 28 Jun 2024 03:08:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5im-0005FN-12 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:37 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5ik-0004Qj-AE for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:35 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-363bd55bcc2so170087f8f.2 for ; Fri, 28 Jun 2024 00:08:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558512; x=1720163312; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HkQna1pAjg6GCvSqtEv1yfUmIYCR6WFUzViVX0SSBYo=; b=TNcgBl3oDtNMsBpwS1eubTx9jz0uokT7mDPIvho096kmSEdvDGD8CQDTxvHEx9xiQk oVPFQhPGxSb8lC2w8Itw7FircD/IOLActUtDdJ4X6toObS0WSh2S5WK6gjuNCtPLVmm0 zn74+EX2EVFQUxpKTXxP+eD5av5oexcN8UpNSYB1j1AlyVdH7vIYxAm7u8gQ59+gM+/J nGiJJqXK0+iRew9FeHciUiXH92KRxdn63kGW7nnoteRRGlJXIRhDJeoxjD6AZfYFBEE6 6yOzfvi2Zbl3yT7U/QvuFDZYOnEkr1do8f0k6HdR1oYk8C3UzM/nBbyMkm1qc1cI3DXW 9mvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558512; x=1720163312; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HkQna1pAjg6GCvSqtEv1yfUmIYCR6WFUzViVX0SSBYo=; b=lmQnT3JfKqlKEn2Ajm7FJ7s86YVjrBkv8g3ngvXM3DydzwcU1WfysXfllJv5K+jdeB TrKJ8MxVDFkwAW/3FzZe7tdGrBoEEejV10108BYfbgpx6Gc0yzVnPyZbMGfKSX7Pd+Ri vlh+gimXLgh1TnDHB+RaIFG+DpmTy+Dvu+m8JCHzDE7EIkrz+yQAH1Ryq0VyQCskw66c cvWy+buU74BUhdJtIRI2ZD7I/8dxzZzncUL/qRGjYqaB0x90rrWK4A2pBbHhcSVxFyBp ybdr+U454lk4ftsuTdV8iRhaHk9Z/5/10DJ22ugoJ9aoIb57/g3FRVRwLSiUlIGzqafc b8Vw== X-Gm-Message-State: AOJu0YzX2V7yFtRtLvbcRHRK1XkrcDQjMZ5rfkGYWxZBSFyUDPoE2/W4 O4ulL9KwdJliAFvZFVFbKD5lHmqKkBHmN5+wZgipii3rJuelyWJ7mhniALHbDVxw+0ApIYtqBZo y84I= X-Received: by 2002:a5d:648e:0:b0:367:6440:ea89 with SMTP id ffacd0b85a97d-3676440eb88mr425282f8f.65.1719558512601; Fri, 28 Jun 2024 00:08:32 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0d90d5sm1343537f8f.31.2024.06.28.00.08.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:08:32 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 61/98] hw/sd/sdcard: Add sd_cmd_ERASE_WR_BLK_START/END handlers (CMD32 & CMD33) Date: Fri, 28 Jun 2024 09:01:37 +0200 Message-ID: <20240628070216.92609-62-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bf9975e9b1..4e31dfe18f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -244,7 +244,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [21] = "DPS_spec", [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", - [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", [38] = "ERASE", [40] = "DPS_spec", [42] = "LOCK_UNLOCK", @@ -1583,6 +1582,26 @@ static sd_rsp_type_t sd_cmd_SEND_WRITE_PROT(SDState *sd, SDRequest req) return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data)); } +/* CMD32 */ +static sd_rsp_type_t sd_cmd_ERASE_WR_BLK_START(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd->erase_start = req.arg; + return sd_r1; +} + +/* CMD33 */ +static sd_rsp_type_t sd_cmd_ERASE_WR_BLK_END(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd->erase_end = req.arg; + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1672,28 +1691,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); /* Erase commands (Class 5) */ - case 32: /* CMD32: ERASE_WR_BLK_START */ - switch (sd->state) { - case sd_transfer_state: - sd->erase_start = req.arg; - return sd_r1; - - default: - break; - } - break; - - case 33: /* CMD33: ERASE_WR_BLK_END */ - switch (sd->state) { - case sd_transfer_state: - sd->erase_end = req.arg; - return sd_r1; - - default: - break; - } - break; - case 38: /* CMD38: ERASE */ switch (sd->state) { case sd_transfer_state: @@ -2315,6 +2312,8 @@ static const SDProto sd_proto_spi = { [28] = {6, sd_spi, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] = {6, sd_spi, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [30] = {6, sd_spi, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, + [32] = {5, sd_spi, "ERASE_WR_BLK_START", sd_cmd_ERASE_WR_BLK_START}, + [33] = {5, sd_spi, "ERASE_WR_BLK_END", sd_cmd_ERASE_WR_BLK_END}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2356,6 +2355,8 @@ static const SDProto sd_proto_sd = { [28] = {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] = {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [30] = {6, sd_adtc, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, + [32] = {5, sd_ac, "ERASE_WR_BLK_START", sd_cmd_ERASE_WR_BLK_START}, + [33] = {5, sd_ac, "ERASE_WR_BLK_END", sd_cmd_ERASE_WR_BLK_END}, [34] = {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, From patchwork Fri Jun 28 07:01:38 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: 808210 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224710wrr; Fri, 28 Jun 2024 00:13:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUN6TD4pEFXQD2jjMEnl7+DCE9dkffBIlDMsCZocF6UZTpEa/545YYbpHbgbhVNmL5DLnx4MH5gdKql7HIw9ssV X-Google-Smtp-Source: AGHT+IGrSobyHzjCNwhtKOoYYANHIIwbmyqc0SVz7irwgwkd8pY4uhwExSkntYCZm3bmyyeNSNBz X-Received: by 2002:a0d:d047:0:b0:61d:fcf7:3377 with SMTP id 00721157ae682-64343efc76dmr137142187b3.44.1719558786955; Fri, 28 Jun 2024 00:13:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558786; cv=none; d=google.com; s=arc-20160816; b=DXC/VxaA77P+Nhde+EdpaaqTwJfWp/vKn922pULr4vD4CNiRMqAHYAmVIU/ifxw6u1 OkluOs1odIlRBiCZfEQgtqyUH4UGbqtBk4+kMdEFJcXfPxod2YfxAQ4WKCraDkUsRZyu m3km/ooUGOsre/3vP3tAxPxh8QZaRPfq5WJRtqOy3RCvkRT0Mtv6+UPLWoxAuc+iVWIh Jl0wV0hbrUHMWMIC+THPzE1gu5Zu7Ui/HE956wkLb3kpdfC4hA4o87/zFUlyk8cZQlfw LqPP+cDrT4gTt4dYLS32ICXXyJgXtXF8yIHIvQRTe92Dd/lV6WK36X96i7k492PezfIn feMg== 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:to:from :dkim-signature; bh=CoQCzUzxa0YFMI6eXkkGrxD2M8eC5JzJPZMXnDtnM4A=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=sQSlklSR4fe2sZ9C8F6dxpJMkO7s6dJ5KgpcwDf7QFdaV71DLQ9KNpL6prDyfvKxIt gVCNTSdtIZOpzB1OszjwTZgGyCdfAINoyOQIemXyNB8byVnIw9zcWmForQlw4WT1GNJL 5ohLJ5cDag+zuUYof0l9uSlO4w5Xz0PT3W86vxpFNhvxnCTYpKk3IgrdqgBwTAsTi+A6 jJUStAFxzDIQO9h+9AiDhD6nTXuFumrN8LnmuY/HvLV/NyrgVQBH6NrVzG7Qh+s74pF2 YMOltiIxRofxk9CXNETeG0aYaPul6pdRp7txFO4Ul4gPXzFMV7/UE0lNIjJgF8rHTWvG aJ2w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="zwhWvm//"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e607fa8si13605786d6.457.2024.06.28.00.13.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:13:06 -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="zwhWvm//"; 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 1sN5jP-0006Qm-4V; Fri, 28 Jun 2024 03:09: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 1sN5j0-0005rK-1B for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:50 -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 1sN5iv-0004R1-9o for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:49 -0400 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2e72224c395so2718601fa.3 for ; Fri, 28 Jun 2024 00:08:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558517; x=1720163317; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=CoQCzUzxa0YFMI6eXkkGrxD2M8eC5JzJPZMXnDtnM4A=; b=zwhWvm//t2eZUI9ihqJ7OKPfEBXpxEIMn9tA3fs1Fx6uDzHxnvVrJDvHinafL2hHEI D7yW1jd1Ch1PpUvJfJ7M+qWuJLmI9VHz3u5iRcRsJIz85m9XJPwQJG+VNuDKhDWAQQJl UF0oHrVaxKKIWlMSxO4FaqsSiudUR3iH9PL6GxdwBD+N/TafF0LDvULOdvfmFOpbn96i pCH+g8WmSFaOAFoSRjdvxkEnSCm5uu3daUDn7uInp7sxhaQ/Xzx+ubxqRiqqEOQshUna YpXE38/KtdKYQ9i4e3dK4IGC1pQ22y2x1o5ZSME7bk98X3Ad5weFZjcRs8RqVBV/4C3A Pl1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558517; x=1720163317; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CoQCzUzxa0YFMI6eXkkGrxD2M8eC5JzJPZMXnDtnM4A=; b=POUE0bWi3tfAT9Mn/cPWKHWStxyDMXRfyH+iAdVvQMkVYk1qL2wPJMOT1xRpd64tVB J9rvP6I/omr8l8r1gv1wH+zYh/BWC3XgxTj+Q8cDDTrkI+D6ZkYOtUaB3NPpVYgLQeqx AyZ6fb6eI3+5RlmwNvvL52rePFYAJYHb3rwBzp5DsEmFcnluwqGzGBNN1l8Y6Y2WVyiV YM/n4LuAVI/Xbce0M+uUYS+e/eekXtbF/1A5L1KbGjn5VX66Oblf6yyvzi7zm8SNMmjn vy+bXzNn/d/8rKcxcvpS/JYly9v3IQzRhUjX3xLmtEF8ztT6ge4Pxuj7n0tKFz0P3aRM KDYg== X-Gm-Message-State: AOJu0YwuEhh10duwozMmXv3QPm9BGu7Qh4vBhbsVuQzKblhpRJlgtA+R Ae5CidOJkSs1+oOrP9dgKoATEaeEi7oBhHL16pn9CgiG8lo8eDDcTrYs50Tqh/QigwSFgyx7g/A QqpA= X-Received: by 2002:a05:651c:1a2a:b0:2ee:4dc6:fe28 with SMTP id 38308e7fff4ca-2ee4dc70179mr23313811fa.40.1719558517642; Fri, 28 Jun 2024 00:08:37 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af55d0fsm21566625e9.19.2024.06.28.00.08.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:08:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 62/98] hw/sd/sdcard: Add sd_cmd_ERASE handler (CMD38) Date: Fri, 28 Jun 2024 09:01:38 +0200 Message-ID: <20240628070216.92609-63-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 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=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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4e31dfe18f..17fec612eb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -244,7 +244,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [21] = "DPS_spec", [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", - [38] = "ERASE", [40] = "DPS_spec", [42] = "LOCK_UNLOCK", [54] = "SDIO_RSVD", [55] = "APP_CMD", @@ -1602,6 +1601,24 @@ static sd_rsp_type_t sd_cmd_ERASE_WR_BLK_END(SDState *sd, SDRequest req) return sd_r1; } +/* CMD38 */ +static sd_rsp_type_t sd_cmd_ERASE(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + if (sd->csd[14] & 0x30) { + sd->card_status |= WP_VIOLATION; + return sd_r1b; + } + + sd->state = sd_programming_state; + sd_erase(sd); + /* Bzzzzzzztt .... Operation complete. */ + sd->state = sd_transfer_state; + return sd_r1b; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1690,26 +1707,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 26: /* CMD26: PROGRAM_CID */ return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); - /* Erase commands (Class 5) */ - case 38: /* CMD38: ERASE */ - switch (sd->state) { - case sd_transfer_state: - if (sd->csd[14] & 0x30) { - sd->card_status |= WP_VIOLATION; - return sd_r1b; - } - - sd->state = sd_programming_state; - sd_erase(sd); - /* Bzzzzzzztt .... Operation complete. */ - sd->state = sd_transfer_state; - return sd_r1b; - - default: - break; - } - break; - /* Lock card commands (Class 7) */ case 42: /* CMD42: LOCK_UNLOCK */ return sd_cmd_to_receivingdata(sd, req, 0, 0); @@ -2318,6 +2315,7 @@ static const SDProto sd_proto_spi = { [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, [37] = {10, sd_spi, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, + [38] = {5, sd_spi, "ERASE", sd_cmd_ERASE}, [50] = {10, sd_spi, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] = {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, @@ -2361,6 +2359,7 @@ static const SDProto sd_proto_sd = { [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, [37] = {10, sd_ac, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, + [38] = {5, sd_ac, "ERASE", sd_cmd_ERASE}, [43] = {1, sd_ac, "Q_MANAGEMENT", sd_cmd_optional}, [44] = {1, sd_ac, "Q_TASK_INFO_A", sd_cmd_optional}, [45] = {1, sd_ac, "Q_TASK_INFO_B", sd_cmd_optional}, From patchwork Fri Jun 28 07:01:39 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: 808198 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224534wrr; Fri, 28 Jun 2024 00:12:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXUny5iKTdoHbz7RS8apxnqNGijiYCaWp40lBSRDjfpa18LZyr2xV7m59JOPrLonbGO/rJXHFLn1Lr0/Ra0BZAS X-Google-Smtp-Source: AGHT+IEhTnHS7mdUpjJ5kjjuOoYMG1s2MR8lYscQluJAS1uYUj8dX942ltsM0fLvJrFA9JnXvY/Y X-Received: by 2002:a05:622a:285:b0:444:e5c0:656e with SMTP id d75a77b69052e-444e5c06608mr142577261cf.65.1719558755320; Fri, 28 Jun 2024 00:12:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558755; cv=none; d=google.com; s=arc-20160816; b=avod71YewztkJxmZr+4OwgYjnj1AiuIBR+tZRv3tLhj3BGuF1PRgMGrezbIG4qTrUK qtJC/iixYsiOExqsnpNweecr8IGhi78txbYGG8VWWdziFD+2T5umCOM0rosjXMsTkMEF dt3+ma7/dDEkHeXR+/7A+w6azZSoZpUvH0H5J4ugvJPuFG7VGWK5Lc/p8r0vR8I30QHH R8UqEoPKeLOfHsHE6Dy+0twlnb3/RQU5NZdV2p9qCFCACtYHZj2HQRSdXXKlRSeiTyn+ D2wJ3X5iZ3NsWKRnQ8wAT/juU9xhnqXLyGFAfFURnk7jObumr8VDom/+lzui3W6lkcr2 fv2w== 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:to:from :dkim-signature; bh=HYHB8+xaBcVQbVKgp+p9kpTdDb0kmp4G0ZMulayNcv0=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=xuBcMvQlnK4okHfK5hs2zNEYB/c74jvR4IbNDlAZTGKzS5FiNzoN4kOJstmkTS1GW3 a47swdJEnfvjYQWh8T3iBKP8YKu97nzHEkfWRlB4d6tEQCQ44IC0QK+V9ebN3xXzgOfe h/8QdzGJU9dkFTv+p+xRaBscRGjMTUX83Z632MoFbqjzXOt0xNilFLGiU+cGlU7w46uG I4vz57nUUhggrQcQp3E6rtjVT6l/I9OTvh4nkIcnnJtL78NBRn/iXwIqZ6jDUU7jpYUO d9bBZDFjVC+o2s60VTJfoChmPC5PbYvHieBD8gJ+5gJ9Tq0JF3EMRqvkhL7gA2jLY3lA Lg3g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wDY4IrsY; 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-4465148593dsi13117001cf.288.2024.06.28.00.12.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:12:35 -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=wDY4IrsY; 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 1sN5j5-0005vw-Vu; Fri, 28 Jun 2024 03:08:57 -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 1sN5iy-0005kq-9i for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:48 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5iv-0004Sb-AD for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:47 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42565cdf99cso3129315e9.3 for ; Fri, 28 Jun 2024 00:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558523; x=1720163323; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HYHB8+xaBcVQbVKgp+p9kpTdDb0kmp4G0ZMulayNcv0=; b=wDY4IrsYyPo/ipwhh25uCdAgg1pBE5hrx+pZGDh/hSBo/ZM6tlmbWIq/OSndt+zo1w V+LU10A4TPgzRXFBD1sfg3pp5MAAxK/4XxVRD1O7RkcdB7zMc5kRqG265Z0oFMamRulv qNUFDgBAnYk8YkigUGs8OARepKUMgbvj8UV/ukptEiVFJE1zz+NttO3oEZnEHNFJB2G7 KyaXvz0t9v/LdveLKhjoJqmhqlve2HcUAq8fFHeuUnDVJQkXTwx8TEuwqmOs2Zk4f++c oXo87IGZ88D6Vqh0Qg97VJ9xGtOwZ23lKNNSc1Bfi1of00XwEdtrSJ3U9HfzrtxHBMVx oKUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558523; x=1720163323; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HYHB8+xaBcVQbVKgp+p9kpTdDb0kmp4G0ZMulayNcv0=; b=L3+GavpEo5UV/4DEtY6oStTnOcQzGxtziLWJiI9wbJUDbeNA3bnkJsEuV7sXPa+dmi aEBB2RsNc6ZqlbKSKgsxWNt1WJ2YGZWRmx6FABvXvTTZprOAgnSHMBFLwYxxewb6w4Bw 2QJxo9pk5N7QXu0Fea8kTDM6wIB+Ww2BkoO4CwwWKth31JpqyJGIz6eZyMikOucaY/LS KUCFAW6oKXfaszVRSax5g8BZprEjUhDguucsmbm6SxHDK7UG0AF8P0SdJzMquwPOpaVa bEPHogNI4bccGqvbqCRsq3y59mv7ozkx9y44gyZTwkq4HHl2Loz7XTxehnfwE0iFJQhH 51YA== X-Gm-Message-State: AOJu0Yw6nN3+8Rv7XNSD9zD8RuNlZZRa6swUros5iQgi5TCkRMTKW5Cu M4iNi5q9e1nKJI/GQXO8NfN5LxpraG+WFH/C57KNciOdSPUvXAby2EMmWFYAagtZqNFbhuUgQPM GjL8= X-Received: by 2002:a05:600c:511e:b0:424:a587:4392 with SMTP id 5b1f17b1804b1-424a5874419mr76692675e9.18.1719558522777; Fri, 28 Jun 2024 00:08:42 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3cf9bsm21895665e9.8.2024.06.28.00.08.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:08:42 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 63/98] hw/sd/sdcard: Add sd_cmd_LOCK_UNLOCK handler (CMD42) Date: Fri, 28 Jun 2024 09:01:39 +0200 Message-ID: <20240628070216.92609-64-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 17fec612eb..4d78ac5b59 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -245,7 +245,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", [40] = "DPS_spec", - [42] = "LOCK_UNLOCK", [54] = "SDIO_RSVD", [55] = "APP_CMD", [56] = "GEN_CMD", [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", @@ -1619,6 +1618,12 @@ static sd_rsp_type_t sd_cmd_ERASE(SDState *sd, SDRequest req) return sd_r1b; } +/* CMD42 */ +static sd_rsp_type_t sd_cmd_LOCK_UNLOCK(SDState *sd, SDRequest req) +{ + return sd_cmd_to_receivingdata(sd, req, 0, 0); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1707,10 +1712,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 26: /* CMD26: PROGRAM_CID */ return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); - /* Lock card commands (Class 7) */ - case 42: /* CMD42: LOCK_UNLOCK */ - return sd_cmd_to_receivingdata(sd, req, 0, 0); - /* Application specific commands (Class 8) */ case 55: /* CMD55: APP_CMD */ rca = sd_req_get_rca(sd, req); @@ -2316,6 +2317,7 @@ static const SDProto sd_proto_spi = { [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, [37] = {10, sd_spi, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, [38] = {5, sd_spi, "ERASE", sd_cmd_ERASE}, + [42] = {7, sd_spi, "LOCK_UNLOCK", sd_cmd_LOCK_UNLOCK}, [50] = {10, sd_spi, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] = {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, @@ -2360,6 +2362,7 @@ static const SDProto sd_proto_sd = { [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, [37] = {10, sd_ac, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, [38] = {5, sd_ac, "ERASE", sd_cmd_ERASE}, + [42] = {7, sd_adtc, "LOCK_UNLOCK", sd_cmd_LOCK_UNLOCK}, [43] = {1, sd_ac, "Q_MANAGEMENT", sd_cmd_optional}, [44] = {1, sd_ac, "Q_TASK_INFO_A", sd_cmd_optional}, [45] = {1, sd_ac, "Q_TASK_INFO_B", sd_cmd_optional}, From patchwork Fri Jun 28 07:01:40 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: 808234 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226367wrr; Fri, 28 Jun 2024 00:18:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW/hSEBPf/TYRjHfazcL2XEqiEjLcD+gq3fdN+VDWAnEsGcfjPGY2VJAzYOS6zXkErW3cqlV/mhn49n8sjOSxWp X-Google-Smtp-Source: AGHT+IGOyP71g1GzQRqqTAX57MKYzrrMqH03sGURf9ohgxezHjyzFrVfz5cerW4wUVDAWgmw/RDD X-Received: by 2002:a05:620a:4083:b0:79c:8a71:fd38 with SMTP id af79cd13be357-79c8a720063mr824330185a.15.1719559124206; Fri, 28 Jun 2024 00:18:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559124; cv=none; d=google.com; s=arc-20160816; b=CiAjT4km81UJdhpXRKCWMnfiZbdJozialIrdYpFJPZIEIjFYXJGmXqDMAqSPRP15YQ 1Xku1E74kG4XpXDFFRnr69TfFx++d1juyNo1mTXp8DrIX3Bwf2j7ZhqHOyLhGIUoobF5 U8XuUTZWo+w6sTqlX80U3qIlfANttTWMYJhDMVdkQoEWiScbGEJlieB9meLnf7yYuJt4 dtZoJEZhhK1JrOTnzXNw+tJ9dP2tWlwaZnqncnfwq7RU/7Ci9TH1KXvVs+VWV+TpXyQf WBJAHw+3b+uQY2p6kyaWsuQx+AdB0SrFpz0nEMtMBh2i39LhSftnGMqCHqtCtFk1lI9y aD0g== 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:to:from :dkim-signature; bh=jmktXx8YFnfnnA13QTx+BBHRiUUuhl67+QJQQVhLdE0=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=n/B1qO3nC7ghA+/zVq3y3+Iz1pDhZuOofhK5R2Ce3exfL8hWeYa72WDnVikFV4hezL dVbz3FTThQugEjL8e9b8ZI683SYCPhL3/yMxgEPg7aAG2FqOwu643GScVqeqcjX923id YCoFnqo2ICatFB1Co3UAZ6ZFto8ZHbGXGVHB+iYd5+Qu+9afDM8NWNEk+pwRMKbatjXR FPiIdWPH21LduQVh1jEeqe7FhVi/n4QC+1LNZHixP9MlASezURwpCr1sVAnRrWmSo58q xedx09+ywtl3g9YibIBi2geETvZ3JrtIDkTtntZI350peC4c0zK5k+nDm4XaU/3QvM9r IrJg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ahiRMwIw; 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-79d69339b98si119610185a.589.2024.06.28.00.18.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:18:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ahiRMwIw; 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 1sN5jS-0006WQ-Iy; Fri, 28 Jun 2024 03:09:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5j3-0005xM-KY for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:55 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5j0-0004TL-TN for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:53 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-42565cdf99cso3130005e9.3 for ; Fri, 28 Jun 2024 00:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558528; x=1720163328; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jmktXx8YFnfnnA13QTx+BBHRiUUuhl67+QJQQVhLdE0=; b=ahiRMwIw3aERPlYCuXQSXbYylhgdavHJXon7bKbnahtGKcuGixUv0pnTuWqyw6OxKc RkAoD4G3rhPguAPus7y2QSfg1EPzgoIz2/TKGfOdEqcm2QfgsPbTamMlR9c6DiEtErZi 0UNUIVM+f6RP71zvhLYA2CWRSBj1inSOBojSfxgMZSA4bDPf/+PpPvvR6LmKA0tzbzHZ s+FiR07SajeSVf323YNwzX71O5pCZrXsNujdgiMed5cMbbv6SPvK2+sSmfAYh+K5TyF3 zNhlsOylQtq09x8KoT73FJeAOF0g/oqG3CkoEPuPqC+gy5Eqk69Mvzb7AH76r8tiEL83 dK/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558528; x=1720163328; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jmktXx8YFnfnnA13QTx+BBHRiUUuhl67+QJQQVhLdE0=; b=Z15GAhIqQgb9oTYmqD6Bza1Ak2fsZVm99ciVe2lTeWWUmO56rcRED9EDfc779/10jR 9W60QIOaKDREDcO0VgDIzNm65xJfjTNnIP7y8WSAB3JiXk0vBT1WyklbHXi6hfJX+BGC mQEuXmpTF/DHnWDof85oYx6wSRjCy766dxOj/eP8exonUgtCrToTXJG6hfC2u3/6dpTm kpfGDW5TMgrQbOGNpmqw6iXZIeVTyzd1XCibDW0vcBpOj6Muq/BYBPiPo4LxF6Gi59aw OkpuoVT1vIJbrPrdrbr2NSoc/mYEEPICjG6vfoOnmpCTND/2bLjbyQ7a3AB8hwa3ARc4 COrA== X-Gm-Message-State: AOJu0YyTdRbAMoanAqaReO4aFnFlbSSo90Q/92nueQfE3VTcbRf6tPC8 /Acus7pdoR9/CTKiRpGbtF728WFWm+OA9J1/uORVuwAYM6lvdXqb/PCajKcL1GPDIdGGX30IZ4d duLw= X-Received: by 2002:a5d:59ac:0:b0:366:f74f:abf0 with SMTP id ffacd0b85a97d-366f74faceamr14448624f8f.16.1719558527904; Fri, 28 Jun 2024 00:08:47 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd71esm1346641f8f.21.2024.06.28.00.08.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:08:47 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 64/98] hw/sd/sdcard: Add sd_cmd_APP_CMD handler (CMD55) Date: Fri, 28 Jun 2024 09:01:40 +0200 Message-ID: <20240628070216.92609-65-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4d78ac5b59..5461e56e17 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -245,7 +245,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", [40] = "DPS_spec", - [54] = "SDIO_RSVD", [55] = "APP_CMD", [56] = "GEN_CMD", [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", @@ -1624,9 +1623,34 @@ static sd_rsp_type_t sd_cmd_LOCK_UNLOCK(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, 0); } +/* CMD55 */ +static sd_rsp_type_t sd_cmd_APP_CMD(SDState *sd, SDRequest req) +{ + switch (sd->state) { + case sd_ready_state: + case sd_identification_state: + case sd_inactive_state: + return sd_invalid_state_for_cmd(sd, req); + case sd_idle_state: + if (!sd_is_spi(sd) && sd_req_get_rca(sd, req) != 0x0000) { + qemu_log_mask(LOG_GUEST_ERROR, + "SD: illegal RCA 0x%04x for APP_CMD\n", req.cmd); + } + /* fall-through */ + default: + break; + } + if (!sd_is_spi(sd) && !sd_req_rca_same(sd, req)) { + return sd_r0; + } + sd->expecting_acmd = true; + sd->card_status |= APP_CMD; + + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { - uint16_t rca; uint64_t addr; sd->last_cmd_name = sd_cmd_name(sd, req.cmd); @@ -1713,29 +1737,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); /* 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: - return sd_illegal; - case sd_idle_state: - if (rca) { - qemu_log_mask(LOG_GUEST_ERROR, - "SD: illegal RCA 0x%04x for APP_CMD\n", req.cmd); - } - default: - break; - } - if (!sd_is_spi(sd)) { - if (sd->rca != rca) { - return sd_r0; - } - } - sd->expecting_acmd = true; - sd->card_status |= APP_CMD; - return sd_r1; - case 56: /* CMD56: GEN_CMD */ switch (sd->state) { case sd_transfer_state: @@ -2321,6 +2322,7 @@ static const SDProto sd_proto_spi = { [50] = {10, sd_spi, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] = {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, + [55] = {8, sd_spi, "APP_CMD", sd_cmd_APP_CMD}, [57] = {10, sd_spi, "DIRECT_SECURE_WRITE", sd_cmd_optional}, }, .acmd = { @@ -2373,6 +2375,7 @@ static const SDProto sd_proto_sd = { [50] = {10, sd_adtc, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] = {9, sd_bc, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_bc, "IO_RW_EXTENDED", sd_cmd_optional}, + [55] = {8, sd_ac, "APP_CMD", sd_cmd_APP_CMD}, [57] = {10, sd_adtc, "DIRECT_SECURE_WRITE", sd_cmd_optional}, [58] = {11, sd_adtc, "READ_EXTR_MULTI", sd_cmd_optional}, [59] = {11, sd_adtc, "WRITE_EXTR_MULTI", sd_cmd_optional}, From patchwork Fri Jun 28 07:01:41 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: 808212 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225014wrr; Fri, 28 Jun 2024 00:14:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUB0ROedX+nNyfwRsQ0ziJ7WkBWNCt9s1hnS1g1pt2JFimwCTu6HaJZN53dH2qKe+Rrl7C9qPPWdaM728g7ER9x X-Google-Smtp-Source: AGHT+IG0nOT1ZDcEcr2oZ3EsTwXPuEb8YQjJc+oCpyfGfB2UBz+OG9j1o25g7E77J4PFh+HmSDV9 X-Received: by 2002:a05:6122:1827:b0:4ef:5b2c:df25 with SMTP id 71dfb90a1353d-4ef6d8094eemr15657479e0c.6.1719558856204; Fri, 28 Jun 2024 00:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558856; cv=none; d=google.com; s=arc-20160816; b=swyKd076iCXO12KKGZpPBlBUjXDh5spGiZ6d6Xi8CEqP0oZw4JSecow6FbC2KjF1oh OEOfuFK2Z6Jda7xKQWOjvaOwkLF/wkbeWP6z01kRAeiG9evx4Gp7ZgvZlOQ+ghktSW0u /YIX81l8Xpz1D2UKGXvCsbY3D0pZ3oaCkuTdgIatC3XvfzNNGNRiPbZByU2bL98qN+b2 meX2+YwDon8/jis6W0rscDgN78E0Eb8FPfSR5rMxez2aGgMawFcw2sycNctGLl0IvYpD IyyoitilPr3EFIyEZpsRrUF+pIAB7MBwhD1GRh4VzwsO1fWtHV9Zufsi0tOsDTXTy5Ys 1WFA== 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:to:from :dkim-signature; bh=h6DmY6CGyXMJfzQtpsncnrmxkBN2T3nvO/hOHeba5R0=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=w1VFVtN60HgKioyRxXnZVf4Psgl5bi3GigHCZ3GddcZubJc/xWnaf5ukwwnYLPuHaR YMUPTXtydSPyCFIiT4P97f1P8M+cGa0Li3eCBLvoxyqeqjYj72gB0LkyfyO8nFeSe+HQ IqsarnT8kLCU6AjlsasbbaOTSg14GHU4EcK5bvsuMgYcOVHY87AX1HzxIZsDzcbOLK4A kIBgX5XBLJQMOZnBV6UMPa1/gjZLJCVjR15eqifPhFS+rY58KcP5HeMlSaTzOe2LsbwQ WDXadjWpPtOaCbnkL9jng7dMoQ6S/x9b+Qj/36Kay/EbpnnwD3SDg9pQW2jMtXKdi7Ek YA7A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pdiP6xIa; 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-79d69308a59si120380985a.444.2024.06.28.00.14.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:14:16 -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=pdiP6xIa; 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 1sN5jO-0006Nz-01; Fri, 28 Jun 2024 03:09:14 -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 1sN5j9-00066U-MY for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:01 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5j7-0004Tj-3L for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:59 -0400 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-52cdcd26d61so269891e87.2 for ; Fri, 28 Jun 2024 00:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558533; x=1720163333; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=h6DmY6CGyXMJfzQtpsncnrmxkBN2T3nvO/hOHeba5R0=; b=pdiP6xIaJ326veRXGCoJjdhnMFWn7DtPh5GlW9mlz46TzMh8NILNBQX11RLBZqG5ve 4YdnMpvFH+Ye4OnCpW0LHKhIHRr/vSuAXPkgCHnEKYMLKqiywzL04BlgB0RAO7ziuOKn nGTgcdAlh6udRFwAAIsTC+JVWfv2BGBWtS4NakerhW3QzMsXzLkoEgb2uE/69YKYO8An D4Hnlw85uoJIru673AQfXSx4SPd42D2t/F6K6jFUXkjVn0QATaen4/wIRoHxKgGZ2yXo rUu/osB99iGgBURozb08oM615FZZwP2JSA0NXNfLowijJBxqoXJco+i6DIOak2x/PN+I VYcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558533; x=1720163333; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h6DmY6CGyXMJfzQtpsncnrmxkBN2T3nvO/hOHeba5R0=; b=ixskX+oWDtc+21Og7NC1RNDgf+i4zqiyTl8HM9KBa6P6Z20ZWSxaXXRmQ2mGwiEIC3 VCb4YPE/2olroV66zSyFvA8HmtcfaLO4zIVV39sz+oLrWgqjEcJFrkkI6GcmmMvVhwY/ QPPHkODiUGSRlTLCY4YznzPYJXTlmC2WOxgnT78V2zd2GnkjcaBb0FyWXks5lTnPBa9W IBK9m1zTETJ63RijcxuG9QrVtC/zHCjq8M/Fj8rSLGwewqWGs01vuyEaGYEhFhuoAO5h Goddgdb9OA0VyNT7SR3rpoNZznlkyogf5QKeAEb7f0QudbeIVUFUSFXN9DdPwaWWuLOf Tvcw== X-Gm-Message-State: AOJu0YxmZ/x5PFsTgBghM/dOPsoBNJlfEjTNK4c1e4LiJt0HX4hYJ+ui 4hZJSpvWPwVG+xfwAJDyTf3KMoemFky3DXmMsGuGQG5tua/5N98PcXZ6ZNbAVd15Hz3OXbt+yu4 /T0k= X-Received: by 2002:ac2:5f79:0:b0:52c:e3af:7c5c with SMTP id 2adb3069b0e04-52ce3af7c8amr8324604e87.34.1719558532966; Fri, 28 Jun 2024 00:08:52 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b097c2asm21502445e9.38.2024.06.28.00.08.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:08:52 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 65/98] hw/sd/sdcard: Add sd_cmd_GEN_CMD handler (CMD56) Date: Fri, 28 Jun 2024 09:01:41 +0200 Message-ID: <20240628070216.92609-66-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=philmd@linaro.org; helo=mail-lf1-x12e.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5461e56e17..50cee5ac40 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -245,7 +245,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", [40] = "DPS_spec", - [56] = "GEN_CMD", [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", }; @@ -910,9 +909,6 @@ static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len) } } -#define APP_READ_BLOCK(a, len) memset(sd->data, 0xec, len) -#define APP_WRITE_BLOCK(a, len) - static void sd_erase(SDState *sd) { uint64_t erase_start = sd->erase_start; @@ -1649,6 +1645,21 @@ static sd_rsp_type_t sd_cmd_APP_CMD(SDState *sd, SDRequest req) return sd_r1; } +/* CMD56 */ +static sd_rsp_type_t sd_cmd_GEN_CMD(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + if (req.arg & 1) { + return sd_cmd_to_sendingdata(sd, req, 0, + sd->vendor_data, sizeof(sd->vendor_data)); + } else { + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->vendor_data)); + } +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1737,21 +1748,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); /* Application specific commands (Class 8) */ - case 56: /* CMD56: GEN_CMD */ - switch (sd->state) { - case sd_transfer_state: - if (req.arg & 1) { - return sd_cmd_to_sendingdata(sd, req, 0, - sd->vendor_data, - sizeof(sd->vendor_data)); - } - return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->vendor_data)); - - default: - break; - } - break; - case 58: /* CMD58: READ_OCR (SPI) */ return sd_r3; @@ -2323,6 +2319,7 @@ static const SDProto sd_proto_spi = { [52] = {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, [55] = {8, sd_spi, "APP_CMD", sd_cmd_APP_CMD}, + [56] = {8, sd_spi, "GEN_CMD", sd_cmd_GEN_CMD}, [57] = {10, sd_spi, "DIRECT_SECURE_WRITE", sd_cmd_optional}, }, .acmd = { @@ -2376,6 +2373,7 @@ static const SDProto sd_proto_sd = { [52] = {9, sd_bc, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_bc, "IO_RW_EXTENDED", sd_cmd_optional}, [55] = {8, sd_ac, "APP_CMD", sd_cmd_APP_CMD}, + [56] = {8, sd_adtc, "GEN_CMD", sd_cmd_GEN_CMD}, [57] = {10, sd_adtc, "DIRECT_SECURE_WRITE", sd_cmd_optional}, [58] = {11, sd_adtc, "READ_EXTR_MULTI", sd_cmd_optional}, [59] = {11, sd_adtc, "WRITE_EXTR_MULTI", sd_cmd_optional}, From patchwork Fri Jun 28 07:01:42 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: 808242 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226684wrr; Fri, 28 Jun 2024 00:19:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWEv/KfERKeNqZe2uBRVqOlgWSArhvq8FeQ/2sCRIaI6TvPl5dvE/J9sR/VRspvxC+p+9ZoGehCJ6VY4Y/QVsbB X-Google-Smtp-Source: AGHT+IHd/UF9ep6AN5zwYxBnlSDZMjKCx6PY978aM5UFRKck9b75jF9LPdXCbyiFujU2LHBnqJib X-Received: by 2002:a0c:e611:0:b0:6b4:fea8:6bfc with SMTP id 6a1803df08f44-6b53635d67amr177212496d6.10.1719559188221; Fri, 28 Jun 2024 00:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559188; cv=none; d=google.com; s=arc-20160816; b=QOCaTyH+J3BMqM06YYCmsRWE5tTHqejmSNgeztkL7fgosLUo2RpvboizL/T8Kw5kBL swbZsKM7rW7SdG9dr2ytf4qMDHuK2D739QVGta1ZWB8I2aAqG6ukcTFU3+mUORUuQg/G yBFCB77/LyWp2VfGyknf5dXg30YA0ARYN+ncrcCQ4JcT3ClEMcTNludDgoRdCUrzpLQP 9ck3QWGMuSAMz34E1CYA2CYowLIZQ9AUE0Mdb6oAXJrTeVzcjWO//QEIHnDHO4QlQx4Y Q9FG+QdOHOuvKDzmx1/iQ5VHGArqBtBQxM3AHBgZxAj9yl3Gf1/teiP2DGGsDE8vrLYv 0W3g== 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:to:from :dkim-signature; bh=K1hpuhYvD8c8zKzHH2qCf+bpB7ESZQppXpuiPvi8zTE=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=EhNDAzynVwrLSMOR4Lazu0/M0yi6LONC3bJ2t2RnvLA8oyVjSbbupJNmOjv16q5yTV q9l2QwAO9ljs55xAxbdo+FwyBAgAJRoNIT5RsvHmc+Nl4pt5a11c84nubIrLiuM4appr iZL7H8QUSAGpqqNcUrIvcqXRAUa6aGJAOOC7TWDRMw5EmVbJBWxx//bmiLIfPTUMNjI3 K0f4YuvDrsbrldyzwcMgmToLni7yJItnzo+V1rcspQEeELAERKlRIoeh/rni0ZwmHJD6 OsmO2aFcuH/glt+M3VY2k1aFzMh7foYeq1UfGBSmlQJauHUb66t7y6WIijzF4KHd9tvH 0o8Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XaPqiwVC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e36b4f9si14833786d6.126.2024.06.28.00.19.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:19:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XaPqiwVC; 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 1sN5jm-0006mZ-CL; Fri, 28 Jun 2024 03:09:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5jF-0006Ce-Ae for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:06 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5jB-0004UF-B8 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:04 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4256788e13bso2228135e9.2 for ; Fri, 28 Jun 2024 00:09:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558538; x=1720163338; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=K1hpuhYvD8c8zKzHH2qCf+bpB7ESZQppXpuiPvi8zTE=; b=XaPqiwVCc4p+ls1P3cIggpfhJe524M30oXzIjI4GJRO+f6qU3R8Aw/LxWkxzl0F85w Kvgb/IKO/1zaE6amCCct4ndyEBqqqpulXpmRJZP4Dcn/UMvFKivjRqOvxDuEpVVgs4dn 6MtCJLd9s2U9xn8kxEWqbmLcSIwFrnGif/GT/1lWV8u/AhpvIrcHdMEdNoJ0z0WMyIP+ 0skaHqYnYyt0nOW9Q+JaB1SeLd+2fYmnGGDMlWDqy/LAgicGSika1O5CV0OJexj8t9JB uFrd7LycRBb2cTfHvF8Gf11II/duMF1nf+g9LMvwsyYURtf75Vwvfe6IdMUFo/M+W8rM awPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558538; x=1720163338; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K1hpuhYvD8c8zKzHH2qCf+bpB7ESZQppXpuiPvi8zTE=; b=lAAG+FJU7mtHxp8GmD3cdgu6ZD6DzuSn1JErqiM73DXC7J8rH5t1u0HiQRdZApzQae wWhlsvjfG9uVj1d6eIOvs37ufSJ7iHnSbIawOpPyBFjiHISkHNP4PKqlnMx/pvsmq+DL an9mkMXyMzVaMRt4YhdvJXZQxFmkogSdwjiEnwpnwcjTKUq2+bgr2yAVLmwPjuC2OKub QMMThEQqr3M9QrOIkZok9aU9ruEsPJZ8Lvr4WSc9KFDV2vCqgyvplrkxoRNaZZNF80sV ou2MbcNnZYoJkVU8r3WY5v1CvC7OlxBHpcH2n8qZ+ERl3+Wx0rO0nWb9UaRM/SfseQpW /OMA== X-Gm-Message-State: AOJu0YzRvf6fD+vZsOz0sM9uwfwxdNP+6u1md2Yj64v1nwKOUWeQ53Pu i9p0uWrzlENs5Jhta0U5aRmsKyy8epO3VY/K9DhosBegHZrt5rC5s0z1SI0QhYSVPX4GX607Z0o +qOE= X-Received: by 2002:a05:6000:184f:b0:366:ee84:6a79 with SMTP id ffacd0b85a97d-366ee846c15mr14263981f8f.51.1719558538098; Fri, 28 Jun 2024 00:08:58 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a103d18sm1325820f8f.106.2024.06.28.00.08.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:08:57 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 66/98] hw/sd/sdcard: Add spi_cmd_READ_OCR handler (CMD58) Date: Fri, 28 Jun 2024 09:01:42 +0200 Message-ID: <20240628070216.92609-67-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 50cee5ac40..b3b4cd5a3a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1660,6 +1660,12 @@ static sd_rsp_type_t sd_cmd_GEN_CMD(SDState *sd, SDRequest req) } } +/* CMD58 */ +static sd_rsp_type_t spi_cmd_READ_OCR(SDState *sd, SDRequest req) +{ + return sd_r3; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1748,9 +1754,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); /* Application specific commands (Class 8) */ - case 58: /* CMD58: READ_OCR (SPI) */ - return sd_r3; - case 59: /* CMD59: CRC_ON_OFF (SPI) */ return sd_r1; @@ -2321,6 +2324,7 @@ static const SDProto sd_proto_spi = { [55] = {8, sd_spi, "APP_CMD", sd_cmd_APP_CMD}, [56] = {8, sd_spi, "GEN_CMD", sd_cmd_GEN_CMD}, [57] = {10, sd_spi, "DIRECT_SECURE_WRITE", sd_cmd_optional}, + [58] = {0, sd_spi, "READ_OCR", spi_cmd_READ_OCR}, }, .acmd = { [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, From patchwork Fri Jun 28 07:01:43 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: 808235 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226437wrr; Fri, 28 Jun 2024 00:18:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXGoFaJFXCKC2ru+wPattAOiT6aFu00EkKEi7M8305Srm4AYFx3uFGg/H4f2/cYG2vD+q1LhnjOAbkCCyi4j8Br X-Google-Smtp-Source: AGHT+IGd2bgjWtkrbU5O2wb0Ydg48FOZnS9HCdvubI20Zd7hmZYEuZwYNMTYAZ/GE9XoAOdNQkUE X-Received: by 2002:a67:f8c8:0:b0:48c:3497:7389 with SMTP id ada2fe7eead31-48f52a65ed0mr13496968137.17.1719559133885; Fri, 28 Jun 2024 00:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559133; cv=none; d=google.com; s=arc-20160816; b=F1XB5zb0m3A6fG1Apoy1+AzF1SLINPSRRIYCP5cZ4lvUgephU6kcnukNP4QkX5gFs/ LVpvwloFtML5IYFZ99AvoYS3qmJLPIrXVLcU0L1u5+Jln+M5Ub1ufjA2t2IQiHI7ZTMR FNwo2OrNHjbZ7KeJq3rWI2x1e1sTyuolVJJDOCBCCYU4ZH1D+TTT1GJaoRf95Ij6NXPe byn2PpQqyzqwqjvn5492gyqMYVONmWvNfqM/qRN/XkUs0y49vbklb5Q3MgmP0zxp1xeD bmWiQ3jsTkJeWlPh2M7jTaZxodIUXEwTfpJlEb2RQgvgc6vQlA+5bfEUNSia9DRjXUj+ 2ebg== 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:to:from :dkim-signature; bh=Z4eT6ls1VgCOfFdDFeq72C/Jkjo1k0Xm3Q4yUyOE478=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=0QMk6QOg7RYnoHiKwrtoQ6pxtyi6jgvguPWAn+FRSPa+mbeul2jaeWpX7KBs5riQPn tE+p9PcZrgbYvtcD+cYFHX+FOlRqSUv2bVL7ImHugdKkTIM94wFFZ6G3mlSki1bAIDTY nOEAwvaP199qiZM6bvAL3DQinGC5shcF8j+PRiwZjVN+CFbbRjAzCM3phlSWh4NFjk1Y L3Ikuvq7ONrR+E37MCrDmceaC2LJ4GN+I6PeQsab9v0e8p3Hwms3PIrtPeKK6ePi/OsI AlitL23dNrdxNfJdLxqk5Y3jlM9MZs7XS0Vc8fK32hvGFQXElMWoMqWHj2cCRP03ldHe KMEA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BixIGmhE; 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-79d6934ca4csi121081985a.747.2024.06.28.00.18.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:18:53 -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=BixIGmhE; 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 1sN5jS-0006VM-1l; Fri, 28 Jun 2024 03:09:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5jJ-0006L8-MI for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:12 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5jH-0004Ub-FI for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:09 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-42566fb8302so2506675e9.0 for ; Fri, 28 Jun 2024 00:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558543; x=1720163343; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Z4eT6ls1VgCOfFdDFeq72C/Jkjo1k0Xm3Q4yUyOE478=; b=BixIGmhEcBTlBj3jz+uh91vv/znbeC8eK2knbgu59sDV3mfUO9P2GAJdegX2A6G3nr cCRg+n79GzEydLofoEbjnA2T2UIxp4huW5kFUsffyMGWv+TLK17UPf7AC1pqNXMnt2c6 U9PnmItbaFipV8GKRc7+C+e2xGvffsngUs+SraZHLcRy+fMcWcawb1c5/7N6FfucL4eq MGXr3xJ6HA4keveeqMYpiihTriMFsE3Nz/74GcfaFCKK6ToCvJJXl2jVYCYWGg73/K/8 LIU/4eMTiA8s2JsCe4ekKx8H1AMdkoyEIEKvuiMW0+9fae/5m6NKdP0UDx1WgYt8wHpN H5zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558543; x=1720163343; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z4eT6ls1VgCOfFdDFeq72C/Jkjo1k0Xm3Q4yUyOE478=; b=PM+Xt7YLtlpTsoQsWzkkdl+A+HsRS/zfIJyqxM240TPRL+BUZ7v7ZcPFBPYIL+olGR QsGmpT+dhodMPQ9p2bYJijXSCeATuZxt5ySzSTeg28Y/cu9wksLVmZx8pu/PcF5SPZ4/ lsptewXss36ewwWEjjyJAZnnJra3xVc6UawY9R8y3SS2+XHniejVj70VzxQTRg9rlCes DZPWyK+coDZwmYhioY5YQh+AErknSiG/Ln3iabMCwh41SBpQG40lnN0/7YhOjqcYBXvA /vrZBvOfmY5NB2qhx18hkprQkCe/VSh7X/g7MCI9fvDXRjwqNzIoMBC4cJAOZ+jffuFs CqDQ== X-Gm-Message-State: AOJu0YyktcAJNoMKiYx35jrR0exXYTfx/jNfXHYBKTJlyCCq9SSQenZH rTEqJqoVBYq/nMs7waRGV7r/HSqVr87dJ6v/Ra4g0x26r6B/GuCc6km46BdCiKvT/9rr8U2cZFG 4eo8= X-Received: by 2002:a05:600c:35c1:b0:425:6726:ab25 with SMTP id 5b1f17b1804b1-4256726ae12mr22849835e9.4.1719558543442; Fri, 28 Jun 2024 00:09:03 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b097b77sm20856555e9.33.2024.06.28.00.09.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:09:03 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 67/98] hw/sd/sdcard: Add spi_cmd_CRC_ON_OFF handler (CMD59) Date: Fri, 28 Jun 2024 09:01:43 +0200 Message-ID: <20240628070216.92609-68-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b3b4cd5a3a..2f853a89d1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1666,6 +1666,12 @@ static sd_rsp_type_t spi_cmd_READ_OCR(SDState *sd, SDRequest req) return sd_r3; } +/* CMD59 */ +static sd_rsp_type_t spi_cmd_CRC_ON_OFF(SDState *sd, SDRequest req) +{ + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1753,10 +1759,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 26: /* CMD26: PROGRAM_CID */ return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); - /* Application specific commands (Class 8) */ - case 59: /* CMD59: CRC_ON_OFF (SPI) */ - return sd_r1; - default: qemu_log_mask(LOG_GUEST_ERROR, "SD: Unknown CMD%i\n", req.cmd); return sd_illegal; @@ -2325,6 +2327,7 @@ static const SDProto sd_proto_spi = { [56] = {8, sd_spi, "GEN_CMD", sd_cmd_GEN_CMD}, [57] = {10, sd_spi, "DIRECT_SECURE_WRITE", sd_cmd_optional}, [58] = {0, sd_spi, "READ_OCR", spi_cmd_READ_OCR}, + [59] = {0, sd_spi, "CRC_ON_OFF", spi_cmd_CRC_ON_OFF}, }, .acmd = { [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, From patchwork Fri Jun 28 07:01:44 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: 808232 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226293wrr; Fri, 28 Jun 2024 00:18:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXcd0Ehg/tdbAjDN7lI5wneeAq4/cUirZU/UVLhGvuE7BWTmQ+E9p0LpJNnr4WYQQ8R176hT3h6QgfBsIXbYP6h X-Google-Smtp-Source: AGHT+IFcARudjJK+osw9l4N8KvSip5WFfeuZLa7iqjMHfimCX215z7+VwjvAlQR5DBhS047gOOta X-Received: by 2002:a05:6102:d8b:b0:48f:9836:12ef with SMTP id ada2fe7eead31-48f983618efmr3331996137.7.1719559108563; Fri, 28 Jun 2024 00:18:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559108; cv=none; d=google.com; s=arc-20160816; b=v3+yFOsAPvJetMMeDFTQ1DSxCiY1yW+idNfBPnc5OCPsjg5rAQrhb2ky0T6qHbEkpY S6mS4EDw37EOX+by6f6XB00Eb1mFWa2EY+ymCY8bC8Hi5a3SDudxktWZW6bllqtsbnwy F6aBsk2qHx+SmPaX9VsQvrJPeOeUjjCL/c5JA97O5j/p5cqY/sU5XCd/6RUDPsdlooe6 z06RPTvhtUM5Xa2uhppOJTmtYat0LLQwHuNCkjqrwm8f9P9kWz30tQBtTRrl/n/ISJ6/ BbQ7qB4LGRx1wAqFJhmmxx8KVQznNAQS1I62vkhv/QEUTOb6V3/w9NHiMDQ8ajr8ECpl 35/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=1Ij5pjsDB8qqEoSZ8JFKxxVUAdb9cjcc9vXzXqWT+4A=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=iWy0HB712bhAIDwXLA1LhrrhJaiU5/aNBQsRmDa4n+/0Qo03xDJEoLkqvR307vl5Sd YbcosXmR0G8/p5Ot/8hDv69HZ5tbw0weKu5ti2s1kf6nT3A2jm/W01/2OeA73m8WVutO dxAX5O87ngQrB8Sl4m74TbO8fMUrX+w8WBzAbELu8LXqPRneuSYNvZqZEyOmcvdBWc+h 5j55hI5GAq79S+OQ64/iZ3gyTk0cwbu21a4w7P3ek0o7+Mw7mjRAJhCYjbm6RMUuQFmp uzwNK/74E5Buw2gi1UdDv5svOYE8Uzi3U3vAGOmv8SQLHZHrXc2mg0FpqKSjb7e1+las cj3g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YSSVVsps; 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-79d692f0126si133822385a.328.2024.06.28.00.18.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:18:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YSSVVsps; 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 1sN5jq-0006w2-Bk; Fri, 28 Jun 2024 03:09:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5jP-0006SE-R2 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:15 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5jL-0004Uu-1K for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:14 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-361785bfa71so247274f8f.2 for ; Fri, 28 Jun 2024 00:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558548; x=1720163348; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1Ij5pjsDB8qqEoSZ8JFKxxVUAdb9cjcc9vXzXqWT+4A=; b=YSSVVsps4rooW9wzr5BbqAvhACRp0P1t+yaSXQ3Nd3/81wSKPNRZxWfpu59wFWn0K5 St9FUU/AWUs4/LHA//LcI3yQ/Jo34ZB+S/JsKtBTtd8bif7jHkjUmKuEaRLkzdhKeryc CsUkvMeuf3HoHQutknPmmITcDQEcQMrMgMc2pOVAlw9E3m6LtmzfgO33gUdca4CVxYw6 xfXpo+fU3yW0jCaI33JhHXDGfD6XZi5IanXcYod5hNR0oyX9TuIQ8BthOdsoJ8geAP6J eVTq1goAti3MJa3z13CTxmieGvzqFQ38oN9kUuTT9n43VRyTSH+uIa5mc2+x1OjAU74P mP5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558548; x=1720163348; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1Ij5pjsDB8qqEoSZ8JFKxxVUAdb9cjcc9vXzXqWT+4A=; b=iti1GxJYxBVM3Wx1z0kjQg6tCjTirag2HNMya9a9Wn4j2e0iv/e0DKwGFa0YPfY9qx 0tadRcG8zo5/qABlaDDs2GaZMtjWH7UoJI8QbVKDevPc2IAtFWgoLxjOLxE52UcUD905 s2vqGSFTjVe6VyuA2gMs7m/rLRQ/tj8D9s8JhVfrUUJdZLkZfJYkp3VlTkMm7P7rxhFK Hj08nl0F6YyZeLcrP1cOT5z/BJ0hiKjHrMDCO0cSjPnUw+GDKcWyetzjlLBqvvH5yJmO Kzu32F3meFZ7uESmceKZldoThysJeEgaGFyzHqr06IK2rEj4hO6gdccQ5QJ7S2Cb4pts Fk4Q== X-Gm-Message-State: AOJu0YyFh2f5I3Y0Rg7nIuCqlDV254dEGv4cQDWNNcaCHlBE/wG+TPkB m9ovOBOZrS8zAm0PWrjzlZcqNSSO7KR8sF6ASR4gVXuhBtjG0X3PbNhwIIL+6S0mQyVNyr+iC29 sMH0= X-Received: by 2002:adf:ec49:0:b0:367:4dbb:ed4e with SMTP id ffacd0b85a97d-3674dbbee7bmr2581759f8f.0.1719558548547; Fri, 28 Jun 2024 00:09:08 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a103d18sm1326195f8f.106.2024.06.28.00.09.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:09:08 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 68/98] hw/sd/sdcard: Add sd_acmd_SET_BUS_WIDTH handler (ACMD6) Date: Fri, 28 Jun 2024 09:01:44 +0200 Message-ID: <20240628070216.92609-69-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2f853a89d1..0310a5a3a1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -260,7 +260,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) static const char *sd_acmd_name(SDState *sd, uint8_t cmd) { static const char *acmd_abbrev[SDMMC_CMD_MAX] = { - [6] = "SET_BUS_WIDTH", [13] = "SD_STATUS", [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", @@ -1672,6 +1671,18 @@ static sd_rsp_type_t spi_cmd_CRC_ON_OFF(SDState *sd, SDRequest req) return sd_r1; } +/* ACMD6 */ +static sd_rsp_type_t sd_acmd_SET_BUS_WIDTH(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + sd->sd_status[0] &= 0x3f; + sd->sd_status[0] |= (req.arg & 0x03) << 6; + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1780,18 +1791,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 6: /* ACMD6: SET_BUS_WIDTH */ - switch (sd->state) { - case sd_transfer_state: - sd->sd_status[0] &= 0x3f; - sd->sd_status[0] |= (req.arg & 0x03) << 6; - return sd_r1; - - default: - break; - } - break; - case 13: /* ACMD13: SD_STATUS */ switch (sd->state) { case sd_transfer_state: @@ -2385,6 +2384,9 @@ static const SDProto sd_proto_sd = { [58] = {11, sd_adtc, "READ_EXTR_MULTI", sd_cmd_optional}, [59] = {11, sd_adtc, "WRITE_EXTR_MULTI", sd_cmd_optional}, }, + .acmd = { + [6] = {8, sd_ac, "SET_BUS_WIDTH", sd_acmd_SET_BUS_WIDTH}, + }, }; static void sd_instance_init(Object *obj) From patchwork Fri Jun 28 07:01:45 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: 808213 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225037wrr; Fri, 28 Jun 2024 00:14:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU3fr580bZWZxX8o8mqj/krFFNtVqmDG7VO2QajEkuxTWq8HvKN1I90iZjYTg4UbyC1l92rB1Xxj/6B/M2Rcx1l X-Google-Smtp-Source: AGHT+IG5IE08xv2sp3tr7BZwfHDdU+ALFtz7+R5KtfMLDkM+NTkA6oAaVDVLBlXLyJFTdHf3SCqX X-Received: by 2002:a05:622a:114:b0:446:598d:3016 with SMTP id d75a77b69052e-446598d311emr1325451cf.31.1719558859283; Fri, 28 Jun 2024 00:14:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558859; cv=none; d=google.com; s=arc-20160816; b=kUz/zNfy/EGut6eaGZgTdUZvpMIK1ZJhaQtz4k8kRNElmEgXccpvm4Et3CjNABJVmY pahRng7zKB2OD+0ouhbmTd9CTWEwnpiAMPsXwaN0n2v7CKc3ECaIw/aU/3thKZhoLNXj LxW0tmp88kmiCI6jVm/f4XRjFY42fVzd6CYcq6a7cTQDZlJdjri7R5wGVQDw9tDgb5IM E0npXOaFIPoK9lZIedSxvH90CXb7EF+KcBw/JGGvCXFp0hXZ9lBBT0vxuPJf76lQxiNS GIzJaZ1vrhGUJT2a6LxDa0Vq2dxbnEw80mOTHnYh7I+Fz9LHeaVDsgysTAGXDUGEkzfg NlHg== 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:to:from :dkim-signature; bh=9vrkGwBcqZVZMukUtGlLs/nHFLle6eNwrj7janh4+hs=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=E5LPEgIdTAJ6iYvAat9TPA3EKX1J4SsCYpiCdDxqK13YRgZzCeavcLMUQ926reF8xA 8K/X8fpGBQ8SH2mEzSwNBXYEEW2sj/dRSIgVr+pCT1avtyLsBMMw3sB0IYI9L2uo+Luc 69vv2iIjoG4ZzFS8Xqk8jjRvJE2uFV1NL2AJpi+jvj07lA9A8OVXEVgpj10bpDmMf7QO JV33bVoY2AezNcSY19zUf9Ulwl1bW2fwYiVCDXkaDWMU1/ioBydCgO69ecXdhv8+k6Bb VcFoVZft6u7FudWkMuTRFDbsHlPPzrwlmeK6sc/+4pmFpQBPNZtGArMY7FTAAbq4BIx2 +D+Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p+Y7zEMl; 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-44651487054si14553241cf.236.2024.06.28.00.14.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:14:19 -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=p+Y7zEMl; 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 1sN5jl-0006ea-8U; Fri, 28 Jun 2024 03:09: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 1sN5jR-0006Vi-R0 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:17 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5jP-0004VK-Vf for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:17 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-52cdd03d6aaso311825e87.0 for ; Fri, 28 Jun 2024 00:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558553; x=1720163353; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=9vrkGwBcqZVZMukUtGlLs/nHFLle6eNwrj7janh4+hs=; b=p+Y7zEMlQRTIhRhM81alr2pWYJCYsoQH1cT9PO8aiJx/dX99qTOe8tX6cweQ4aVfHc 8IXGjg9RVL1pSTA6+2NqoN9GQE17emTRMAEpNXulEQJ9DDiWE90Y+Yu11un7lL40f5OS LfjLk2LYyMkEcIjM0DD2IS7POT2+f4xJf68tE876pmo4aG3RJmpEha8xf0L5lBqbae6P eFEDSa7cd+hAdEe6BqcFr1JD4HbgkifqosOxicdWtE8xLiR55jL16ayZGEA80mpVcfYY uxTy9nijb9bi6rgWpEFMO8O5xuNgvz1ZKz3SE4Dt4geyF9JhgiPMc3ikgkLP7AQvS+w4 k/+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558553; x=1720163353; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9vrkGwBcqZVZMukUtGlLs/nHFLle6eNwrj7janh4+hs=; b=I3A9JKdTcao+tyYuMDfcJl4rpcOONJ1889w70EnEFrvmcse+WUb5lq3sXxVAj7aIpM jL9dcagtFCo8VnSAcaI8X6Hk/jtNR8VqUtPqtoJe3YYYjLmej25DKhCLPE/yP2d24uNJ 9d4DoBvV8CEeufgBmy8beJfRGj4+8ZBwMfO7Cw6sLgifl9PJzfGRO70/N6L1IqSJ+ErR zszVlXclkBioPKIBVRRutFARAzAW6M2j7fi7o7hPrUaSzxGuNMs5Zonr1Hf0VEocWqlY m44Ym1dgm8F6k3irDbKlA8Q91BzZnQlrNkSu5xfAbH46RAtre1YCJdrfFjkQqFfSb2bT JQgw== X-Gm-Message-State: AOJu0Ywcr2oiHEyzJXa9skn7k7Zr2pnXTVLmQzoNA/Wn8ZVjIh+H05ZQ sbs+wg9Meiu5WluQxX9c/+KwyLcIcChXZ7u2RW+eIwfcfYGp5WmZBPoqpLtII27loAWzrc1kbTr zm9Y= X-Received: by 2002:a05:6512:118e:b0:52c:ab83:d783 with SMTP id 2adb3069b0e04-52ce063d63emr12759506e87.6.1719558553571; Fri, 28 Jun 2024 00:09:13 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb92fsm1335266f8f.88.2024.06.28.00.09.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:09:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 69/98] hw/sd/sdcard: Add sd_acmd_SD_STATUS handler (ACMD13) Date: Fri, 28 Jun 2024 09:01:45 +0200 Message-ID: <20240628070216.92609-70-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=philmd@linaro.org; helo=mail-lf1-x136.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0310a5a3a1..5323a42df2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -260,7 +260,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) static const char *sd_acmd_name(SDState *sd, uint8_t cmd) { static const char *acmd_abbrev[SDMMC_CMD_MAX] = { - [13] = "SD_STATUS", [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", @@ -1683,6 +1682,13 @@ static sd_rsp_type_t sd_acmd_SET_BUS_WIDTH(SDState *sd, SDRequest req) return sd_r1; } +/* ACMD13 */ +static sd_rsp_type_t sd_acmd_SD_STATUS(SDState *sd, SDRequest req) +{ + return sd_cmd_to_sendingdata(sd, req, 0, + sd->sd_status, sizeof(sd->sd_status)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1791,18 +1797,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 13: /* ACMD13: SD_STATUS */ - switch (sd->state) { - case sd_transfer_state: - return sd_cmd_to_sendingdata(sd, req, 0, - sd->sd_status, - sizeof(sd->sd_status)); - - default: - break; - } - break; - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ switch (sd->state) { case sd_transfer_state: @@ -2329,6 +2323,7 @@ static const SDProto sd_proto_spi = { [59] = {0, sd_spi, "CRC_ON_OFF", spi_cmd_CRC_ON_OFF}, }, .acmd = { + [13] = {8, sd_spi, "SD_STATUS", sd_acmd_SD_STATUS}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; @@ -2386,6 +2381,7 @@ static const SDProto sd_proto_sd = { }, .acmd = { [6] = {8, sd_ac, "SET_BUS_WIDTH", sd_acmd_SET_BUS_WIDTH}, + [13] = {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS}, }, }; From patchwork Fri Jun 28 07:01:46 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: 808189 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223789wrr; Fri, 28 Jun 2024 00:10:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXUIqYfPwDBKisCVMurZyec4mVzBmNTMzrp0gldZLvgEBT3ci13iUALPIPyKrcNOm/E7C+K8Mg3y8Wd3aeyHGOQ X-Google-Smtp-Source: AGHT+IGilOqT+ou38vKdzJ3VPg7rbM/5QC0wao1Xjgl8tX8wmchUPHBQyCuCZhCcEtLgbcTK6pjk X-Received: by 2002:ad4:5d4b:0:b0:6b5:9375:97bc with SMTP id 6a1803df08f44-6b593759c8bmr65233826d6.43.1719558603657; Fri, 28 Jun 2024 00:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558603; cv=none; d=google.com; s=arc-20160816; b=LM1ZAYovGw6BeVis2bPtSbKKQhApO7G+xvtdLvhxNYR/x4aGBPEZOFfFiRqVVwHB68 gNp84D/9t0usPn7VnEUriWdQHvmV3UL4JskcfXvC+9SHzo/r7+dGI4FjUX9AhFAKYOIz tgW482WXUpf6AZPcA09kR/2gP7Lf8jflB7ypKtKNIarbsYuuZZS5Ar6JyMUFZRBs4fb9 JAJY3/mcopEZTAYXRJq7NgRe9LaZy1i2hGsS1RFdFYlAQ4/aZJzSw3pSW3+AN9YmV1pt ZDBT/yeRscCKFSNsJyIbIVDr42yvm7MQd/bBkEbHE2b7IDC1HVPXEnNNt+8DJWXyEhQi cSDA== 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:to:from :dkim-signature; bh=JLfOaKjryvDgm8/tAb2iA3e2u5r9x8cBXXCm9JQWcag=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=aynA8LnPjfRsXsYIwPaRUCgMjIjLsgN5NOaC99xV5zHbcE1Q64bbEGy8uEruxsuz+O 5T4+M4IPKkoC6NUWWfCtq57NhpcQoA4ulHeasLSlt9+ut8fyv5qjRc5JEYxbXZFbOQMO +wq2DWMwbKOdharj6hPP4ctrwCFqb2FqiCJNDvQzAGho//fCiMIxFjpNCijPvm78kkOR MLB18AGmIBQnbLr+GcqRMurh+U4Q0wWirB8FyYHvEWuXf6Oqc1O7AsE5xdqi6aCZU9YY QZmHGxBEVZSqctEIeWiQwVuRxgYabFtT1n6KzpQyCEPeRjl/+UiJZrBwQmq6c72/HzAZ wLQg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ux03+hN1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e36c40esi13887756d6.172.2024.06.28.00.10.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:10:03 -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=Ux03+hN1; 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 1sN5jo-0006rO-5V; Fri, 28 Jun 2024 03:09:40 -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 1sN5jX-0006bC-6B for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:26 -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 1sN5jV-0004Vd-7i for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:22 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-36703b0f914so172885f8f.0 for ; Fri, 28 Jun 2024 00:09:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558558; x=1720163358; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=JLfOaKjryvDgm8/tAb2iA3e2u5r9x8cBXXCm9JQWcag=; b=Ux03+hN1ZtWU/gSoD7ZOEx7TXMudkX7MctjdrjSEfQ8HN+shCGtYYr4cVDG7M+szVJ 8MpsKlU0CDqu/h8PUBq0t+kEFz/8BVYjw0rdziHPcYXZQU1Su3w2LpKXd/l28TXX2xYQ b9Oq45GXiLfhXVuoC4S5f7b+t5bKIGqkpc3RTrrr7w1j4TNlLs2HKPkqKE/NlT74ce3S a0D4x9wAMlOeq24Q7b7+9ZeuvLnFXKCTrhz6DB4lg8RSXU+AyiqJe0opk8CGxNZURSEK 3gfeMab7qLDONWYAEjKdoWUtlKws4ssfQ7cKX79snF9EWfOZ37s9jg3dRZH6t8QTnI5o +LyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558558; x=1720163358; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JLfOaKjryvDgm8/tAb2iA3e2u5r9x8cBXXCm9JQWcag=; b=wHV0EJ1JD3t+EhehBJw/ruD/8e/4qkhstPoJSj4UQY2QEk47d+t26CujQxvcy7x8QN cuXhyKEb8g7pScQB8dqhgSAx4dzsdjyu3+Qh8h2Dkl9AuGkTmXlFatBq9kUqJXPCR/xu ps4iep7+jk9SQIRXY2YxUhMxDvTElAq+Kj2I4WZVQxTY+0KcdnkdUR/m4BP4AusM+S+6 7O/XcYbW9/4U93+h5FaWsH0XcdbGie5x4+NkUPSbyXfJ7+Qc0o9JFrn2zDlRIz6h5L6R EQ0pV1YZiZHe+92VHOLH+9EpQXW/QuSXiAqmVYHG0+EWK9XmA+b8zGkKthehuVrvaGFY MxBA== X-Gm-Message-State: AOJu0YyRD7YRCsXALPT3eSanA0zs6vgGWq9tkPzrPLO3Jz9L7cAkbFtG Rwz24M5hjP+0h0eOf4/W7hYTDYpBto2hkaEOsyIADXjpFcD7z46b/ON7z5XjsKI21inleYK6p2b ruLU= X-Received: by 2002:a5d:47a8:0:b0:366:ee84:6a77 with SMTP id ffacd0b85a97d-36760a63045mr718077f8f.3.1719558558689; Fri, 28 Jun 2024 00:09:18 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09a94csm21291405e9.33.2024.06.28.00.09.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:09:18 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 70/98] hw/sd/sdcard: Add sd_acmd_SEND_NUM_WR_BLOCKS handler (ACMD22) Date: Fri, 28 Jun 2024 09:01:46 +0200 Message-ID: <20240628070216.92609-71-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 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=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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5323a42df2..9d66c3715a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -263,7 +263,7 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", - [22] = "SEND_NUM_WR_BLOCKS", [23] = "SET_WR_BLK_ERASE_COUNT", + [23] = "SET_WR_BLK_ERASE_COUNT", [42] = "SET_CLR_CARD_DETECT", [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", @@ -1689,6 +1689,13 @@ static sd_rsp_type_t sd_acmd_SD_STATUS(SDState *sd, SDRequest req) sd->sd_status, sizeof(sd->sd_status)); } +/* ACMD22 */ +static sd_rsp_type_t sd_acmd_SEND_NUM_WR_BLOCKS(SDState *sd, SDRequest req) +{ + return sd_cmd_to_sendingdata(sd, req, 0, + &sd->blk_written, sizeof(sd->blk_written)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1797,18 +1804,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ - switch (sd->state) { - case sd_transfer_state: - return sd_cmd_to_sendingdata(sd, req, 0, - &sd->blk_written, - sizeof(sd->blk_written)); - - default: - break; - } - break; - case 23: /* ACMD23: SET_WR_BLK_ERASE_COUNT */ switch (sd->state) { case sd_transfer_state: @@ -2324,6 +2319,7 @@ static const SDProto sd_proto_spi = { }, .acmd = { [13] = {8, sd_spi, "SD_STATUS", sd_acmd_SD_STATUS}, + [22] = {8, sd_spi, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; @@ -2382,6 +2378,7 @@ static const SDProto sd_proto_sd = { .acmd = { [6] = {8, sd_ac, "SET_BUS_WIDTH", sd_acmd_SET_BUS_WIDTH}, [13] = {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS}, + [22] = {8, sd_adtc, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, }, }; From patchwork Fri Jun 28 07:01:47 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: 808237 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226471wrr; Fri, 28 Jun 2024 00:19:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU85T54C3ABUwyEFxwmZuuMhlbDqWv9pacJj0qhMV4Rs0jG4KQtvu4DxbJzEJme8409cVBFj/U8PHQjfanwmZvD X-Google-Smtp-Source: AGHT+IGQV2bUJDyIQaEAkE0sr0QCIMrNjoIF0n/75u01+jlAB1DBu75paZwMxZAJljIX1Ezd0x4e X-Received: by 2002:a05:622a:ca:b0:446:5568:a6de with SMTP id d75a77b69052e-4465568a8e9mr10880161cf.48.1719559141288; Fri, 28 Jun 2024 00:19:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559141; cv=none; d=google.com; s=arc-20160816; b=TIqBfrrn04QYMgByUXmsBsno456hlzQEQTnhJOmLmfPD4frqoge3rG5UYIiGI4x/tZ Q6j8jWw6Y/Sy0v5K1hPWJA/THUTDJqSlHktjRX3HxQ/WelLFNZgH/5/8+WLI5oLxxOz5 Zh3Hx0PZrJpRkJrDNQNMOfqAIKor1Dv5w00BE7VPswv54fNtjR9KsSnXgS1MZoEr7A9/ Rc8AENUe/GpWsHOhuoPXAY8zzOqkRW07qqqM2QqjloUz/u8CBw4u+cq9CNiNLyknVMQN FxN2eYddkSYB8oYjt/Wm+wMrdVhNVEJA+BM/9TyBDCGdyZzD6vDR10bS2Ej6FNOs4yPg 1ohw== 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:to:from :dkim-signature; bh=if+k3pC7/tUCTUn2xmGg3zarIgu5LY5GHs2T467fbqI=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=SjjsiXxBdefk5vhVt0ISgcprHcPMGGfLEvdfhc0ESL01X7KNwWD5ahNhpSwGP4bS4z KGiJ1vkFLTjWUKvFM8YxSyp6tjX7Sk/PoWy/dXYNnFEpByeEvcH/oflp2aieHuJNXD9d rDUyUEaWfQxrjBZntKZBi13b2aU9bTCX+ulvqeDgRVqaF/HpdeDK0nkU7GRadrnz3Z/R WSRsBb8e9008edw3mlxUel/LxXKIEbMUgID3N/NKgG/3SfYizr5bMP/zstpo+1oTphcm e9zIx/0RP+TpVRS6ux1j0SF2yxCtFPqzkEnrJTL2pfEoAs1DIuF6h7UfjCZSJVgp3PXq YwQg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RQrPWzeK; 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-446514da664si13109821cf.687.2024.06.28.00.19.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:19:01 -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=RQrPWzeK; 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 1sN5jt-00074Q-3Y; Fri, 28 Jun 2024 03:09: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 1sN5jc-0006eY-Fv for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:33 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5ja-0004Vs-6p for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:28 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-42122ac2f38so1534595e9.1 for ; Fri, 28 Jun 2024 00:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558563; x=1720163363; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=if+k3pC7/tUCTUn2xmGg3zarIgu5LY5GHs2T467fbqI=; b=RQrPWzeKrxgUy+ZYVNpVACIc72t2AhgelClWyO0cVZfWapJDkPPwjCBw4qPYSHds5c Ic5StwTv7RLSm1qZawywpBcjChCcE+9q3qhuUSdsWZf7bU70j4ALb0C6VbbjqG0vnQ/D yRao4BzKw0nAW9rpuFAjfKQIEFssiZQ2r1SGag7o+Gl9ZmaRVhQiYIRB3fUAKtD3K0/Y 87t2uSiehUHXfB77diBgeZxI4OYutPPqXuwREm2B0VTAFxTLjHiHja6QeuXg3YFG4T+I 8mlkOYXIQc0zTnd3fbTzECLb1rVNFrICRN4oh+th67TzIOecVWGWuDKRre/6B8tITUWQ IHjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558563; x=1720163363; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=if+k3pC7/tUCTUn2xmGg3zarIgu5LY5GHs2T467fbqI=; b=kDUgjNDciyRlLiYyKMaip5ErkPrNy+BvGUIbkAeG1T1Ck2kChWp6p7tsvGgq8mhvdL f/8oQFEuQarukWdgUfn2ExBZTbLFAA6S2ofyvsxTUq67ERA7lbMfvyCnlrJDFhvYox14 Y+8ReYV65pWdjLmjurCTk8o6IyBYOjX2f7nB+sxP9KLzJp04ySgUgsmjhq+STBJrdz7w d2/o5jicJjeLcHroQg/Kb8xjGD7lH2nlOx8plCBmpjSFh7NzayK3cn6ZBcw2iZHsQa5y DizE70DhDlErntIv1xQ+d8XrUx/vPyWBCTdDfmmoPPokrE5ef63H7X5hfHJXZ0pBOfTL ycYA== X-Gm-Message-State: AOJu0YwHq8Xo4kx33PlI++P5qVFyjiHwXx+zr+WAKlBm6bhzgKaPKfPp 4yGh69bTV3hUsRpuNvLWCUbIcjNPHCjifhIAbqTdZG19kA8LttG2h8mwWlsZEmbf6WeZaqQotmd A6Cg= X-Received: by 2002:a05:600c:5114:b0:424:895c:b84b with SMTP id 5b1f17b1804b1-4256d4c3f40mr6269645e9.4.1719558563723; Fri, 28 Jun 2024 00:09:23 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb97esm1331280f8f.89.2024.06.28.00.09.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:09:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 71/98] hw/sd/sdcard: Add sd_acmd_SET_WR_BLK_ERASE_COUNT handler (ACMD23) Date: Fri, 28 Jun 2024 09:01:47 +0200 Message-ID: <20240628070216.92609-72-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 9d66c3715a..cd207a3090 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -263,7 +263,6 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", - [23] = "SET_WR_BLK_ERASE_COUNT", [42] = "SET_CLR_CARD_DETECT", [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", @@ -1696,6 +1695,15 @@ static sd_rsp_type_t sd_acmd_SEND_NUM_WR_BLOCKS(SDState *sd, SDRequest req) &sd->blk_written, sizeof(sd->blk_written)); } +/* ACMD23 */ +static sd_rsp_type_t sd_acmd_SET_WR_BLK_ERASE_COUNT(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1804,16 +1812,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 23: /* ACMD23: SET_WR_BLK_ERASE_COUNT */ - switch (sd->state) { - case sd_transfer_state: - return sd_r1; - - default: - break; - } - break; - case 41: /* ACMD41: SD_APP_OP_COND */ if (sd->state != sd_idle_state) { break; @@ -2320,6 +2318,7 @@ static const SDProto sd_proto_spi = { .acmd = { [13] = {8, sd_spi, "SD_STATUS", sd_acmd_SD_STATUS}, [22] = {8, sd_spi, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, + [23] = {8, sd_spi, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; @@ -2379,6 +2378,7 @@ static const SDProto sd_proto_sd = { [6] = {8, sd_ac, "SET_BUS_WIDTH", sd_acmd_SET_BUS_WIDTH}, [13] = {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS}, [22] = {8, sd_adtc, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, + [23] = {8, sd_ac, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, }, }; From patchwork Fri Jun 28 07:01:48 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: 808208 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224693wrr; Fri, 28 Jun 2024 00:13:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWz2YSgSsm7x8DMurU9Pv8v4QhIIOdAHs0WyJAuBzP5IVd9oI4yMBJ9ZYuDXS/FIwZOTm5nd0e5uJC1TsAe8Pzn X-Google-Smtp-Source: AGHT+IF/syvXm1oR/e+nZpTJDQAM+xDJakRi6ClrF+ABT6UxL0W2OE8u94+20p/OH2lCVLbXGvZS X-Received: by 2002:a05:620a:240f:b0:795:5115:5ae3 with SMTP id af79cd13be357-79be47b7035mr1816002885a.50.1719558783627; Fri, 28 Jun 2024 00:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558783; cv=none; d=google.com; s=arc-20160816; b=CQnrmrExGLkgr+fXaWl3/8rOsrXfq2eKIDJEDjAR21WbrSQ4n6uxKiux20y0ht4ypr 0XJtC+o8AV092twfuPemZHToulRlVd3bei/G+5pefUTFeMc9FDVN9N0Kzd2tOGWmbt+H nCPt9Vr5DwfxnyCvM48hyTH9mtiApylDv/OmBfMoOogAZw6fr3BIiLgD/Fvph8Qjniuz Hv/rK9nlelMfrOGtijtyuKKkGMAeGZh24CKLV6Q/framTmtYN7fYrUK5tUZy3L2tSgzq jg3vRMH48ieclpHic1f3zcj0zmvsrNY8qolodjM38gW3FSANuqwd3Bs7iMcpdTX2F10+ Vsng== 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:to:from :dkim-signature; bh=bYEYJ2Wwx71dNKsAcy31SFsnrP/uSxrEAbuXlnudJVY=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=kSKdatmLreZAZsAlz3BzEulbyLFf3hQooPAlcKAhJEA9wYFx85RP7PPXKudabJDZv8 s3cfKtci3a468jNcQkzXLSYgc8l08BETAwIoIT+6M/hEGWEIPPHFPzQ/BKGtH54v3578 /UG6uVNmhIFW/bpDLG3k9HB4lC0UP3FLfqOK/tfvxt5qjBlW7cCNZYx6H7gQ4JJEeEOX clCk/UWyIB4JW8m/9Lq1APUNWhcIUjWE1Ug9qUChAKO2R9veAPQdSLshqtMNrDPzsJ8W NK6EPHQ6Jc8TweUdy10nx85g2d+96EdrWz5Hhsqnn9eBkygXLzaY/agYjE90BRv3BIP7 DVoA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b6fK9nKJ; 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-446513c2066si12935851cf.110.2024.06.28.00.13.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:13:03 -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=b6fK9nKJ; 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 1sN5jr-000707-Mh; Fri, 28 Jun 2024 03:09:43 -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 1sN5jg-0006gJ-UE for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:36 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5jf-0004W5-7a for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:32 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-36743abace4so850647f8f.1 for ; Fri, 28 Jun 2024 00:09:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558568; x=1720163368; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=bYEYJ2Wwx71dNKsAcy31SFsnrP/uSxrEAbuXlnudJVY=; b=b6fK9nKJAQuVa+5JRMI1sbIDNE0oZhKdSvfg/Xoz5CYCE00lKzV3UdAuR1bYppHhEa LX3aUVYLGuCca4tW3zqm4dlcqFR2QCKe4N0MJNHn5hhvjmnHg3C70hmM9yvULpbS3gQb NeBgelRDroMS3+7ZF65jgiQmw2sFKSc494SBKkrfZl8NxnXxZQt8PhCyp+3Y1JvF+uzE ZeCkET7qiVbH6rJ5owrYpNnLUIlf6ZJsGUOXA3RQ96Pn16PHPkZjJ6hetbPuPfiiHyLl WM2s1yFRaQucpoPyltiLRixDH06WgGcxbx+7SY+dsCtgnhIGSn3Bk/4k37mytuj98Ywh yY5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558568; x=1720163368; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bYEYJ2Wwx71dNKsAcy31SFsnrP/uSxrEAbuXlnudJVY=; b=THKkoFtT4htcpkWSTG/tNLxwjnXZUid/oFjnxvHbeYRh3pHHqb+puIA2qL9UWj1ivt 6vhkMokz+8Czc4akEZnHjZ+oVPCFLM3n49GaYnplwtfxFVL8QXp5Yox/BlZU3sacxHMd 11RIuT8/8nljJS+66LOECAgH16+/DIrc0poAov0D4/LJEBGsFZQ8NJlRjNBNsBx0eun1 YCni50UEBbTcDyo9mwe7iOOh6pEb2vfN+qRHh5rqDJNvpgFhr/yDbpPIFRC8AEsSGQPQ 93gHVd14buORNe73T0Uz1Xw0MOtKJOi4jwhTF3i3a9/C4leiPhy1CfP0FXvQDpd632/z VhDA== X-Gm-Message-State: AOJu0Yx7ak8qd69Zra0cGaBNa1NpgAHHtvyvv6ygDIYF9yhPwx+ZlmHW Zo2vhzufKRu7XfEae6kh3U0LRVtzDEodpwO+bofQ7iZvxSGKThgYpLgQUV4o9vx+EMn1RJauBD5 7EGk= X-Received: by 2002:a5d:64ea:0:b0:366:ea4a:17ec with SMTP id ffacd0b85a97d-3676096eb0emr802635f8f.2.1719558568647; Fri, 28 Jun 2024 00:09:28 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c19eesm21379325e9.45.2024.06.28.00.09.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:09:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 72/98] hw/sd/sdcard: Add sd_acmd_SD_APP_OP_COND handler (ACMD41) Date: Fri, 28 Jun 2024 09:01:48 +0200 Message-ID: <20240628070216.92609-73-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 82 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index cd207a3090..167e1c517a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1704,6 +1704,50 @@ static sd_rsp_type_t sd_acmd_SET_WR_BLK_ERASE_COUNT(SDState *sd, SDRequest req) return sd_r1; } +/* ACMD41 */ +static sd_rsp_type_t sd_acmd_SD_APP_OP_COND(SDState *sd, SDRequest req) +{ + if (sd->state != sd_idle_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + /* + * If it's the first ACMD41 since reset, we need to decide + * whether to power up. If this is not an enquiry ACMD41, + * we immediately report power on and proceed below to the + * ready state, but if it is, we set a timer to model a + * delay for power up. This works around a bug in EDK2 + * UEFI, which sends an initial enquiry ACMD41, but + * assumes that the card is in ready state as soon as it + * sees the power up bit set. + */ + if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) { + if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { + timer_del(sd->ocr_power_timer); + sd_ocr_powerup(sd); + } else { + trace_sdcard_inquiry_cmd41(); + if (!timer_pending(sd->ocr_power_timer)) { + timer_mod_ns(sd->ocr_power_timer, + (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + + OCR_POWER_DELAY_NS)); + } + } + } + + if (FIELD_EX32(sd->ocr & req.arg, OCR, VDD_VOLTAGE_WINDOW)) { + /* + * We accept any voltage. 10000 V is nothing. + * + * Once we're powered up, we advance straight to ready state + * unless it's an enquiry ACMD41 (bits 23:0 == 0). + */ + sd->state = sd_ready_state; + } + + return sd_r3; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1812,43 +1856,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 41: /* ACMD41: SD_APP_OP_COND */ - if (sd->state != sd_idle_state) { - break; - } - /* If it's the first ACMD41 since reset, we need to decide - * whether to power up. If this is not an enquiry ACMD41, - * we immediately report power on and proceed below to the - * ready state, but if it is, we set a timer to model a - * delay for power up. This works around a bug in EDK2 - * UEFI, which sends an initial enquiry ACMD41, but - * assumes that the card is in ready state as soon as it - * sees the power up bit set. */ - if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) { - if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { - timer_del(sd->ocr_power_timer); - sd_ocr_powerup(sd); - } else { - trace_sdcard_inquiry_cmd41(); - if (!timer_pending(sd->ocr_power_timer)) { - timer_mod_ns(sd->ocr_power_timer, - (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - + OCR_POWER_DELAY_NS)); - } - } - } - - if (FIELD_EX32(sd->ocr & req.arg, OCR, VDD_VOLTAGE_WINDOW)) { - /* We accept any voltage. 10000 V is nothing. - * - * Once we're powered up, we advance straight to ready state - * unless it's an enquiry ACMD41 (bits 23:0 == 0). - */ - sd->state = sd_ready_state; - } - - return sd_r3; - case 42: /* ACMD42: SET_CLR_CARD_DETECT */ switch (sd->state) { case sd_transfer_state: @@ -2379,6 +2386,7 @@ static const SDProto sd_proto_sd = { [13] = {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS}, [22] = {8, sd_adtc, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, [23] = {8, sd_ac, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, + [41] = {8, sd_bcr, "SD_APP_OP_COND", sd_acmd_SD_APP_OP_COND}, }, }; From patchwork Fri Jun 28 07:01:49 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: 808220 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225596wrr; Fri, 28 Jun 2024 00:16:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUvk+beH1GGoHMjB4dXp2dKaN/6pgqyAzReNrZwZVg0esBlYYnwxP+88UReiTXURp77kspQfVPuOUtQCJoHJt21 X-Google-Smtp-Source: AGHT+IG4heHqV+eaFpv4zwqBSOkULvOIYYEAeU3Ke2fNbrNHPgak1IfYEcBvrGg81c+SNG8iYxfA X-Received: by 2002:a05:622a:15c1:b0:440:5ac6:af6c with SMTP id d75a77b69052e-444d9371ff2mr198032591cf.63.1719558972064; Fri, 28 Jun 2024 00:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558972; cv=none; d=google.com; s=arc-20160816; b=QgqNpEPXy2OgtdjyNQvkUggX7Y4DgqSK0tKpgEU1g0Oo0ViH/fwCGxceSvxvhEtiWA guFMGLDz7XAE6EgbkNVbgvEtI22aVwy2tio5R4G+2yFhbTeMI1Qdk/uRmQwrhscH93GY fIQEEZugLDY385w+kOfbNFqxTOd7eQP6P7j0o76WXCtpMlKsiHSUClNta4uZIR/87sKP zXaWbat6Hljoyqm0+FnyKFyHdpQtzec/FbpaBo2tBB9rtfo2QZj+5uHV9jXt7AZs5F6p eUvK0iAcdZpX8mKrQPc9z4710tGIb0jZ34oP48glN6pOb7wZ0IPLPa8iqsDcLDgXje6x XaKw== 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:to:from :dkim-signature; bh=V0gZMlOJcmhezdd4Yk1lqkQI7yCyPoJydtauFHQrfjI=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=kwxaESRN1d/AnffQx3M9UNU1vGqGOI5BcpozYtvbnvO9I6fb4ekH5jTE0dr2LRncWv vFI5hsBVTIIu8NxPnXKaPhIlrwAcv05Ugg+GUaXAN8iAn6RdjsCL5Q3CybFqAo1/9Sij kQYVbnatnWQ7zbb4H/Q5/NX8fnJnSzsk5NCx3JBXErqBKduLlrNG1AdtNFIrzFJTcFTt NuO0y6sXBE3oIee8el1tqKdusBfaU2cu8Xx50o7w/euqf2PBxsR5qcoVuTyABUUEChjq XbiZID0FCYflnjIKXeSA58vs4IN5dWRsSq8A2p/Jv4g3vPbJ6h0ETQuaONo7hJErCtC5 YXMQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CW+drjv7; 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-446514da641si12945291cf.708.2024.06.28.00.16.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:16:12 -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=CW+drjv7; 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 1sN5jv-0007Fo-Ra; Fri, 28 Jun 2024 03:09:47 -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 1sN5jl-0006mR-SM for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:38 -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 1sN5jj-0004Wp-CW for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:37 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4217c7eb6b4so2642955e9.2 for ; Fri, 28 Jun 2024 00:09:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558573; x=1720163373; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=V0gZMlOJcmhezdd4Yk1lqkQI7yCyPoJydtauFHQrfjI=; b=CW+drjv7FLwyqRmrTHriOIWDwIcnY4YW63Nyl3YykARkCJMvP6n4w0Sj+E0jT4efdK qLXSw6Gm0FSg41SB1sIkpH+xWxF8EzTMpubDpzTVWbSVDoaKSeXGoJWzxTC/IF8gdOKw bIRkoo1gUpGvQ0GuN8BgxG4OEw2ScLB/vrcMb+u7L2KWBFgbIavv8/H4UR0PdjazTGgl 6B7q11h96y5AVoS7Og7B+Ldlc8DStnas8yXgL4sL/W1jUap4jBq2AjKOiwOdHUER+Op1 6WKuwTwpZo1MC6M4B6JTIRtCNsZ5MHOwr+Q8OOifKwJTBrVmc4wpfnfzMq7qP6IAuJc7 6vIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558573; x=1720163373; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V0gZMlOJcmhezdd4Yk1lqkQI7yCyPoJydtauFHQrfjI=; b=jwLXC7rKJHgBtWE8CytjXznH1BLLvO4+qat1TNZOzlnhibbI7pdH+wtbERXPYj4ilM 7zEXev7w3FabtnvJ5CilpkXl9jNaF4hLT0DO9utibJq3m6qotJjFKujKPynU119gK4eS adCo9lb9tK/um4UcwcykudCvKxEZvW+KVG15XL9mXnpCiR5sbuoauPFvq/Iz8E8wvG8z sq6+To/TLm9HjBol9nhOIRUpqk1iELA3vuUe9t8KsY3rBlU5+2CDIEUPyUPgFdGstTPo 5WhmXEP21eDE7hbWCZEQugzABQdOEx99XjNJY3YKZQFw8PXD+Mx+uVNn29JCeX15Lxao NCxg== X-Gm-Message-State: AOJu0YxT+qO2p470oCKvHczdWclOdP9eE227uq8GqyocjS8Y3uq8RF+B BTv1LXguZ7octFxPZqa7S/r4mXLWVEmQ+99LOpNoAL/Dp/aZy6YMvCX2YRu62bmguTenx1XqNcy 8yTo= X-Received: by 2002:a05:600c:829:b0:425:61be:c911 with SMTP id 5b1f17b1804b1-42561bec952mr38622705e9.21.1719558573732; Fri, 28 Jun 2024 00:09:33 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0676a3sm21385085e9.28.2024.06.28.00.09.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:09:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 73/98] hw/sd/sdcard: Add sd_acmd_SET_CLR_CARD_DETECT handler (ACMD42) Date: Fri, 28 Jun 2024 09:01:49 +0200 Message-ID: <20240628070216.92609-74-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 167e1c517a..a27a7e0f24 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -263,7 +263,6 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", - [42] = "SET_CLR_CARD_DETECT", [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", [54] = "SECU_spec", @@ -1748,6 +1747,17 @@ static sd_rsp_type_t sd_acmd_SD_APP_OP_COND(SDState *sd, SDRequest req) return sd_r3; } +/* ACMD42 */ +static sd_rsp_type_t sd_acmd_SET_CLR_CARD_DETECT(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + /* Bringing in the 50KOhm pull-up resistor... Done. */ + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1856,17 +1866,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 42: /* ACMD42: SET_CLR_CARD_DETECT */ - switch (sd->state) { - case sd_transfer_state: - /* Bringing in the 50KOhm pull-up resistor... Done. */ - return sd_r1; - - default: - break; - } - break; - case 51: /* ACMD51: SEND_SCR */ switch (sd->state) { case sd_transfer_state: @@ -2327,6 +2326,7 @@ static const SDProto sd_proto_spi = { [22] = {8, sd_spi, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, [23] = {8, sd_spi, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, + [42] = {8, sd_spi, "SET_CLR_CARD_DETECT", sd_acmd_SET_CLR_CARD_DETECT}, }, }; @@ -2387,6 +2387,7 @@ static const SDProto sd_proto_sd = { [22] = {8, sd_adtc, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, [23] = {8, sd_ac, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_bcr, "SD_APP_OP_COND", sd_acmd_SD_APP_OP_COND}, + [42] = {8, sd_ac, "SET_CLR_CARD_DETECT", sd_acmd_SET_CLR_CARD_DETECT}, }, }; From patchwork Fri Jun 28 07:01: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: 808239 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226531wrr; Fri, 28 Jun 2024 00:19:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUYlK8x0QVYPluFfrP6YhlFCtvZXIg7Ibci3uNvWogJpcvqMYg22X8lOMs5d70HZ6Jz+BE/ieFAmnlIqcEXagbj X-Google-Smtp-Source: AGHT+IH+08O21QNFvuALHU/7TBN3ghFsbkt0gzJu5PGJeuqe1CckTMiNFKZy+7p/g4TqSG+uCEOY X-Received: by 2002:a05:620a:2915:b0:79d:6ad0:d7db with SMTP id af79cd13be357-79d6ad0ddbdmr89827985a.43.1719559153158; Fri, 28 Jun 2024 00:19:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559153; cv=none; d=google.com; s=arc-20160816; b=zGVGi59kGtHywY7MytiB58JCu10GH099DJHHQveMMprDwomkgyxIl9CfWeqrqXad2l rOU6zZT8sdguaHsrM9Tf9foQe9yDlrp9sL6n9uk+TEsmFt9jhvxaFNhpfCd7Wt8nl4po 9inWxk76itw7lQez+M/Gje8wkTL9aG62uUE8Erhf5wVWA+e7yapbTbIjglxYfP4/4azE CaIMvmu9oXs93ozQ8fAq53wTJq+mVjNLK4WGfsUB1YNwCKtMYP7QsHA780HXPbyaepor ulbLwLIw1EvFxVvxaBzhckiJlyfMzBdtaYmX5ihh9I2FuUMftChNRZUx2EWYh534Avke SD/w== 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:to:from :dkim-signature; bh=eSwX8/t3OMl0d9bqgd19YFhdT5y/t7Myi2nZ/gwkh2s=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=HE8GfG+3BgUMVDgqzMywyZIhS869ZjoSi+KWuw8luEHPug2N3MvCl7kOF1qeZHVggU saaaoYfFchmdeLHtlCBGTE7Qrms4ZCemjdt9hpl9g/6NYiePrM/2JyLU/WHetaTg8tCE CuWXT3J7Ur+mVnFgKTF75iSZuBiTtvgf9sYcZnYpwjEneK98212HvqmH5CPiCfMrfznO 8M3Rn7Z7VqRgqjlDC95QHFkwkdUCWRNeFpUZj+Z0HhxFPkchJljOj4Y+mhrepJ967W8p acMPXpceQKABr30wx1iiS0TOYWXA0dVg14v3au73W0SjZzB9hB2U5DL3ohvkDXyk7trT IRgg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q0cFbwPl; 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-446514e6072si13114411cf.768.2024.06.28.00.19.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:19:13 -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=Q0cFbwPl; 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 1sN5jt-00077u-T5; Fri, 28 Jun 2024 03:09:47 -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 1sN5jq-0006xt-R3 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:42 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5jo-0004XF-Oc for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:42 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-424acfff613so3353735e9.0 for ; Fri, 28 Jun 2024 00:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558579; x=1720163379; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=eSwX8/t3OMl0d9bqgd19YFhdT5y/t7Myi2nZ/gwkh2s=; b=Q0cFbwPlWccYJPV8388DFAxCK3F4WIPyrtYh+rgOE9pKxZE9GYQQA6bZssh7VjwstW AJLlBN3IYV9VHhLMSz92AQ+3BZNNAxYZA8Spw5KDm9u3dxBdsN2USDRr0LZBC9LxO6Ed AJNwtIAFitK5j1tgiiSfQKEqLXPALB8u6VKzL/skb1620zZabbOqTDaQ02cKchA43hS+ ljFAaVEm7JG1aY/LXhrsctR6/VXshZMD1e64D6LyDhgKoDQ/pP85Ty/82z9G2p6uVgbf QHh/gBEpkV/NzN642yUuNpEC2s2qxtaTZS31cdIHbYG6zelfCMvqwpU+2N0+w9vgvj3h JM7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558579; x=1720163379; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eSwX8/t3OMl0d9bqgd19YFhdT5y/t7Myi2nZ/gwkh2s=; b=v/Ym3y0n7eZ5luHfrOJdj8HRad+CP4MUQSkTCTGArqhsN8xDMXY3QRrKx8Df5dIyUT bjRZZFW7tQfU6il59jgkmTq1qJo0oEL0hdBhxf2JyIDmGdwL/2svZ0pkVxDkPzEiMIr8 kUZxKnSj1TqCqinXElIVsKgerzdNzOGqTAHxIlayEMWBO5x+JBDeuWOfN40rgd84y3mL 4+WBQ8H2prYQNuIN9fAsCJwOtj1kEYGAuc9Fu4tdBkHjUy6s8jg/Zj/ylLnR+l7EDOGc vlV6vHFlniTFOEKpGlXCbmEGIyOo/xjHPRIetP+uTP3jKthXagmwWm5Tqkw/yA9p21Le 6qsQ== X-Gm-Message-State: AOJu0YwlFW7TlfaKTGqHkaTwP6k5WL4xkg4jbspORkRjbeBP3IJKS5bs 7tCmfpjDd8zv9NWy3vPU4GwaacTgmiJBLwilU+iEr1msV361VdNpx8c+y8BbEoqk0+4SAuE+ZVR vUgQ= X-Received: by 2002:a05:600c:1d2a:b0:425:185c:7a55 with SMTP id 5b1f17b1804b1-425185c7b75mr54184025e9.40.1719558578763; Fri, 28 Jun 2024 00:09:38 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09a828sm21423535e9.37.2024.06.28.00.09.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:09:38 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 74/98] hw/sd/sdcard: Add sd_acmd_SEND_SCR handler (ACMD51) Date: Fri, 28 Jun 2024 09:01:50 +0200 Message-ID: <20240628070216.92609-75-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a27a7e0f24..6a9d611429 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -263,7 +263,6 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", - [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", [54] = "SECU_spec", [56] = "SECU_spec", [57] = "SECU_spec", @@ -1758,6 +1757,12 @@ static sd_rsp_type_t sd_acmd_SET_CLR_CARD_DETECT(SDState *sd, SDRequest req) return sd_r1; } +/* ACMD51 */ +static sd_rsp_type_t sd_acmd_SEND_SCR(SDState *sd, SDRequest req) +{ + return sd_cmd_to_sendingdata(sd, req, 0, sd->scr, sizeof(sd->scr)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1866,16 +1871,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 51: /* ACMD51: SEND_SCR */ - switch (sd->state) { - case sd_transfer_state: - return sd_cmd_to_sendingdata(sd, req, 0, sd->scr, sizeof(sd->scr)); - - default: - break; - } - break; - case 18: /* Reserved for SD security applications */ case 25: case 26: @@ -2327,6 +2322,7 @@ static const SDProto sd_proto_spi = { [23] = {8, sd_spi, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, [42] = {8, sd_spi, "SET_CLR_CARD_DETECT", sd_acmd_SET_CLR_CARD_DETECT}, + [51] = {8, sd_spi, "SEND_SCR", sd_acmd_SEND_SCR}, }, }; @@ -2388,6 +2384,7 @@ static const SDProto sd_proto_sd = { [23] = {8, sd_ac, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_bcr, "SD_APP_OP_COND", sd_acmd_SD_APP_OP_COND}, [42] = {8, sd_ac, "SET_CLR_CARD_DETECT", sd_acmd_SET_CLR_CARD_DETECT}, + [51] = {8, sd_adtc, "SEND_SCR", sd_acmd_SEND_SCR}, }, }; From patchwork Fri Jun 28 07:01:51 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: 808238 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226500wrr; Fri, 28 Jun 2024 00:19:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWaqNYKn74M7P8pe8lwNv4NS8zj9kgylyd1hwcW1CoTQwqwnnx2JIcJaIcaXN4QQu0Cwbgsc167xLkT2xEKP2at X-Google-Smtp-Source: AGHT+IG25KphWg4OyFsCYRu/+FWdNwzqe2v8aUiGUiia7veUDXAjVfX1+UxFJvY5q8oDGFS8JKIZ X-Received: by 2002:ac8:7e90:0:b0:43a:f4ce:121b with SMTP id d75a77b69052e-444d654376cmr204043181cf.41.1719559147265; Fri, 28 Jun 2024 00:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559147; cv=none; d=google.com; s=arc-20160816; b=BVn1/GdAovHUYQt2mLAkw9vNIIi1nnRIyDAoR65wYv1uGfGlylSww1zQWtwH/ba8sH /7CkTgP9GOJL2ofMynsL1BZS6YEqo9eqJ3eTHW4utRgb2RY2R4gzsCXFgI5W79UZikk5 Hh2JErSYz25kWkWrGiA1QigU1+ddFzcz0MwQ7EUCj2VwkVTOOGfxeF6NfA2qiYGhDBmE SGM5URL8Iz5azXtcKF2pmPmFjpQEGPF9KW5Y2IbiJlMraejVF6wXZ3BGmnsyFGDpy05c sv208qt6vYP+AVx7tl8KD8NvaSgXHyeFZHUg1OCeGcqnoYU0yEe3WYyrGpgS3EsLO/8D tixw== 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:to:from :dkim-signature; bh=l1JW4AJQQbgrb8lXxKMuM1qRbY1uuDZlLJblyEzxQh4=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=UsuLfyp2hdLrcYy4Y/NhlIOfblavviH06FElxq13zrytuuoTopOgkH+sjXOyJ10U5/ 5TK/Q8H6eoUDCc8ZQ2jjj32Hygcdkl09+WTagzmtAcQtrdot0in9+rjl1/LaM4OmN8wp 33K8fFU7WeD1QbzjIHuRVIn2xRs1CdkEHGbTRS09ICuKbO4E/OOaE6F7+bjQSQ3diQHd SnAk2hrNLN1MJznzpF+X0HMuYl/FTrshDEZ210NOgJleISgpj1GaVlzS7VilFCOsN0ki qW1tmFMoUO2DdEEJA5Eve1Sgf1FGtAEqMbzDUa4N/Pv6LnLUfxClG4bYnw9ZpPYCBHcj uvjw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PpZWD/+i"; 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-446513e5072si13350391cf.181.2024.06.28.00.19.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:19:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PpZWD/+i"; 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 1sN5k1-0007ea-1c; Fri, 28 Jun 2024 03:09: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 1sN5jw-0007IV-MI for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:48 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5jt-0004Ys-Mp for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:47 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-36743a79dceso863598f8f.0 for ; Fri, 28 Jun 2024 00:09:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558584; x=1720163384; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=l1JW4AJQQbgrb8lXxKMuM1qRbY1uuDZlLJblyEzxQh4=; b=PpZWD/+iLDmHqauQUg9sIQngn+ofCv5s3DypOxDmNqiWA9F0OYrjNPC2PI5OaCx1PK GFglA/px8tDaM764WlegNRY7wZFceoB9up1x9x519+4OyyQBlNzOaW/YKN0bgxv554rB Ogi8MeFVOO3irYMl0jyeoj+LWeWAjI4/kJBDKM8XKkmwRxgLAvAlFsiDqnfIN7fCGXI0 Vngu1RR7cwDwFqq3g/HMf/KAjhI0ulDljEwYkDTHAqAAiAo3wKMJSFHw839V/WPBynXB f8HRpBTDlBNB/GVfYoh2ix+j0E+h5ynYaQXw8IW8x1sdLr8JXAJazPkkIOh27Ql4FJ0+ p1YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558584; x=1720163384; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l1JW4AJQQbgrb8lXxKMuM1qRbY1uuDZlLJblyEzxQh4=; b=wBk+zYhJhrHSUbBJkczdvFyKjiYKSyVZ/TMDE+stqtoqsISRnZ0/y/1CVWtJr40L1H F33ykxmI/5t18c3Wzz74bau5FlssgjBYSZ7XSwt01brMKnBM13/YK684E1zQt1+dG6ci 74n7E5a/YRrxRNWuAi3rSIyJeG0vKz+WhvDiPV7milcFk76p5U9aNZAttKky1WiRnLLD 2bDdP1CeLF29tarqg/Qq7kmEi4Iqjn9YfmZFhGOSCEH6aIy8G+YFzMzk/GzfF/+5Llbw tocTF3V/7e+pJ31LNwqtrllTgC0qgfeRyDXKoIqIdKbPKZ0LWiiIrB8KxPrZ7A1j7y+q 99GQ== X-Gm-Message-State: AOJu0Ywj4z5nigTfBOIQLN2BdknBX6xoVzWyxV7WRhbjwfQot4aPhEn5 JOCt5UEf5/zJv7bplmLFQB03PqqtOBkFRlNzoxaqasundP9Cs0bqHB8d5SmKLf8C1EgF6u73WYa olws= X-Received: by 2002:a5d:64ca:0:b0:362:ff95:5697 with SMTP id ffacd0b85a97d-36760aa2b8cmr640206f8f.28.1719558584023; Fri, 28 Jun 2024 00:09:44 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c19eesm21387115e9.45.2024.06.28.00.09.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:09:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 75/98] hw/sd/sdcard: Remove sd_none enum from sd_cmd_type_t Date: Fri, 28 Jun 2024 09:01:51 +0200 Message-ID: <20240628070216.92609-76-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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 All handlers using the 'sd_none' enum got converted, remove it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- include/hw/sd/sd.h | 1 - hw/sd/sd.c | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index 29c76935a0..c1a35ab420 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -76,7 +76,6 @@ typedef enum { } sd_uhs_mode_t; typedef enum { - sd_none = 0, sd_spi, sd_bc, /* broadcast -- no response */ sd_bcr, /* broadcast with response */ diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 6a9d611429..7f93d363c7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -526,17 +526,12 @@ static void sd_set_rca(SDState *sd, uint16_t value) static uint16_t sd_req_get_rca(SDState *s, SDRequest req) { switch (s->proto->cmd[req.cmd].type) { - case sd_none: - /* Called from legacy code not ported to SDProto array */ - assert(!s->proto->cmd[req.cmd].handler); - /* fall-through */ case sd_ac: case sd_adtc: return req.arg >> 16; case sd_spi: - g_assert_not_reached(); default: - return 0; + g_assert_not_reached(); } } From patchwork Fri Jun 28 07:01:52 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: 808226 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226041wrr; Fri, 28 Jun 2024 00:17:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUSWUfXUcSq7IC43H6kagrOMG8l0JRecOtCEQySsH9oC5qVT2b812Fx2CkeFLWC2xJAtSsPAMrusgWT5K2+XT9C X-Google-Smtp-Source: AGHT+IEkv+CE7Yp97JMseMqJkKanAVgAAyUKUProAuLGBgb+Skk6fzWNnrPKBD7RJy0/wTjNVySd X-Received: by 2002:a05:6122:1790:b0:4ed:145:348f with SMTP id 71dfb90a1353d-4ef6d8ad6cfmr16227455e0c.12.1719559059784; Fri, 28 Jun 2024 00:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559059; cv=none; d=google.com; s=arc-20160816; b=wQm+IU+efA4EgNtWQz3mKyMiNcAVo4eAsy27xYUnZzARqsIOla3wQahg/ZMaszd1gI LJIRiiqzOlQ8dTYpCf18TerjO3+uuiNLc9NR7luMl1QGLezMeamcXunFmtQhw/yTBr5W gA8WkTIQXM0rxIr+VmVmb5lLkyJZZQm20P3se5y7Mr3eb/RuFoFO4+JPmN8/VdUutAOZ DTuJ7SUhRvye63Lu/w3KE2B8QSNYIdCn26+4S6TgmBAQBbfWlPZh6mjt+xEpQ5nS3sOv 4KjG0IhXBHRSoF+KYDuXJmH/uvzszq/UqsR7d19pyHuyGqTDo22eTwz5R/fXdLkPKwI3 iv7w== 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:to:from :dkim-signature; bh=KLGQaIGJKgcmO8Q0mlDn8rOb//ZdpOwWSY8cFandEdQ=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=qQrvdH2/LTfg/o1d3eXnWccIfuHck711uMevRZzwm5e8PfPaOFcqq/lAJUDe315WDE yVIDSh1afmxQ67cs9SiLulM02fUzL0wvCiHeBnkeLzygnjVtOnatUVqIYJgsBVL0rciQ S/A4l4FaFMYnsioYfu+kquN4Xbp+cD/QIySyZeS5HrLBybTast+R4jkOrdI3qdZ4ZwI/ aQ0wRsSomCr+QX7hcJe+zp/KXs8CNG1XAbDx0u8Gv7BHwKPHfmkvOOluuooPQlICF8A+ n2zEquthRcXD/M34ZP6LCu86ddnh8oBA0QUaqExgrHWZPfC1rwsAV0fT3AsHywe51Qmq AK0Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UcJAqT1o; 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-79d69260bf7si133869085a.140.2024.06.28.00.17.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:17:39 -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=UcJAqT1o; 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 1sN5k3-00084T-10; Fri, 28 Jun 2024 03:09:55 -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 1sN5k0-0007mT-HN for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:52 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5jz-0004ZH-1b for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:52 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42567ddf099so2329635e9.3 for ; Fri, 28 Jun 2024 00:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558589; x=1720163389; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=KLGQaIGJKgcmO8Q0mlDn8rOb//ZdpOwWSY8cFandEdQ=; b=UcJAqT1oPpAD++RPxZGtLkREnChaPGoDTh+6R7PZA394OpCC6+PzTzKQs3mKhmpA0i 8CTXQPGrHfNi6SLNAwhebgU0Xc6uL/zPF4mG1vfbSxySGtSKx/73+EboO/jTRbgr/CIc 81uhWhcNZb5aC0KK1YYv/KUNOpsDD6zlfGIue6yn8aNeUSYCW65CsIu3luHOCL6A8Yq3 zZn063lTsZ54B3nkUUVBTGiYIF7gPEbCZFQop70YwRiLK15og7+hg/BqZV5H4/DFB/Y7 5ARSLi/5sKr1D19DJi2OH3ZGPYRISQlxXmjoYUXthn4+hbXCTDH7NWcLkxc1bBzkZEL/ tDZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558589; x=1720163389; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KLGQaIGJKgcmO8Q0mlDn8rOb//ZdpOwWSY8cFandEdQ=; b=nGg3s6Pes8DjvFghYbx4kKyUWQ8uBFUkbhLNYZp3VrB1NIhmYly2cE1oYb6cwq2cB5 A8WGxKw3fw4mG6OLtGsElczWWcyJdYk8tyrFHQ1iXTKHSJorhFfRnpBnp5lmLd85bsR4 vI4zXjbD+k6nRCwPsJAxI+aGXQoNOwKg4tGKfdjJvzSfxJfLf/F3Kn3eszQvZr56yTN7 G1Ev1nl6TSXC8j8sMy/213Fm/6ATQiIM1YtYmiRJRAZG1Sw6MXNLZJaAVq2M2UkWmkUq pHn8m/QWVIpW8m+1Qxiw4t6pvT6JAoqJgF+O60QH0Xdej3hdsiCNdtjEGlZWVk2f8CEu 36gg== X-Gm-Message-State: AOJu0YxLZgLDg9N9AdIVU5Ale5H1RTcXa0/beWjfFM5tNsSW6r7DUb0r hrgrsUGzsrfAHHQ/qDz5eqb0WD0jNK3Hw+Zq5tAXSmJ9Pm87eXciCBirpGptYoBzV6MVnfRmX+B XYEg= X-Received: by 2002:a05:600c:1c8f:b0:425:5eff:7182 with SMTP id 5b1f17b1804b1-4255eff7411mr44231665e9.31.1719558589218; Fri, 28 Jun 2024 00:09:49 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3f14csm21768485e9.6.2024.06.28.00.09.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:09:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 76/98] hw/sd/sdcard: Remove noise from sd_acmd_name() Date: Fri, 28 Jun 2024 09:01:52 +0200 Message-ID: <20240628070216.92609-77-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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 These ACMD names weren't really useful, "UNKNOWN_ACMD" is simpler. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 7f93d363c7..19322c558f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -259,23 +259,13 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) static const char *sd_acmd_name(SDState *sd, uint8_t cmd) { - static const char *acmd_abbrev[SDMMC_CMD_MAX] = { - [14] = "DPS_spec", [15] = "DPS_spec", - [16] = "DPS_spec", - [18] = "SECU_spec", - [52] = "SECU_spec", [53] = "SECU_spec", - [54] = "SECU_spec", - [56] = "SECU_spec", [57] = "SECU_spec", - [58] = "SECU_spec", [59] = "SECU_spec", - }; const SDProto *sdp = sd->proto; if (sdp->acmd[cmd].handler) { - assert(!acmd_abbrev[cmd]); return sdp->acmd[cmd].name; } - return acmd_abbrev[cmd] ? acmd_abbrev[cmd] : "UNKNOWN_ACMD"; + return "UNKNOWN_ACMD"; } static uint8_t sd_get_dat_lines(SDState *sd) From patchwork Fri Jun 28 07:01:53 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: 808202 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224558wrr; Fri, 28 Jun 2024 00:12:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXoPVEGMrLRHCc2FfPj2HaQUQNJIHFcztegEhJBxK8OBz12++ETDG1bwWLoGun0ZpfsFMdc3tpq0Lk8WkjBVdpI X-Google-Smtp-Source: AGHT+IHEvFgyXyAP8CpZR69V+Ts7wWNQi2oyM13XfWUoG/5Sxf/SFFntCBq5jIcjfpgC1FgMlH/6 X-Received: by 2002:a05:6102:3b94:b0:48f:959f:7ce9 with SMTP id ada2fe7eead31-48f959f7d8fmr3432309137.30.1719558757801; Fri, 28 Jun 2024 00:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558757; cv=none; d=google.com; s=arc-20160816; b=EmAaMDRdwnABqMe3cuKm9s8paTVYWzhiifqb5s+IjyOPmwfZPCPN0NNcKEyiv2zlHi S++h8emopKpNqrAcq+B2P9WLY6eNQm8aYujBDlVjM/KZjdjjyqBR523SHjKXYqzEDFZl 5/1I73R90YgkcE8h6WpMDXcfPlKwjLfeq68En8kY6PHMxEygHYIh8U/KHK+jmCxFaeWT k6+mOLiLH+8FVgLJZ/7KgKw3ltwB4cvq0A75xJLto0UONm2Ef03W3WCkGhp5aydT5KqN OCfI+lTBWV1rPc/F5BZAQ2rqcGkTjHL3DDhn+OGiY5XmWAcu1lIzoPcPDuKlNY0VSNAQ Klog== 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:to:from :dkim-signature; bh=Qw+zxMHTEIwsFcpzBJxdUQmKFi6OrynqizbQoSQ84sA=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=YI2OGgoLCDApF6+1Jfyamn8pcRjjSzxYsOm4QcaFjTwKl+t/mVtSuwS0V4rSD0tVhc OVVGOMdicKlbPFxLCGo4N7a9D6buEabwusQb3d359Z783gfCrP67ZbEVZ61whTzDdL6e h9e+nP+HrZ+WjWhZzScK+lQ7/G5LK3ZOg6CZNZcf/q8yjuhnou+ILQosKOZFW9kKeZvL kuF6VKlxCycKTs7mVuFI3vfeNHNFSzxXqA8w1hS1wBKuWU6dGaJpBHvgivfepheU/xcG 20DX/HvXE1Zpopi5xabL6rnEotvDGFnfk//8HzBBnC6QjRK0m2qZ0Yd+iehm+lBAt1lz aWyQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QOvRiwjr; 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-79d693090a6si116892085a.513.2024.06.28.00.12.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:12:37 -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=QOvRiwjr; 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 1sN5kI-0000iq-Pk; Fri, 28 Jun 2024 03:10:10 -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 1sN5k5-0008RF-Tf for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:57 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5k4-0004ZX-2M for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:09:57 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-42122ac2f38so1537735e9.1 for ; Fri, 28 Jun 2024 00:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558594; x=1720163394; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Qw+zxMHTEIwsFcpzBJxdUQmKFi6OrynqizbQoSQ84sA=; b=QOvRiwjroRJuE1a8fsquD0KLYEyflOD1M1UKk6Oc5v9r53viVXQvsee/s84goIPl8H muqBxx3PbuMHO0/y4Gu1bCvsV7SgLQsQfrmHlZKjDou137e2hhXZ+7G+bTVwNSZ7gpej Tc0gDLZIv7mkDurc6xB5AThxPAfwx30S52AVqoYvMVe+ANL7hT5YRCQq8gSfg16GrCFM vTPQbL4jknbkMuSV7ewDWh7f1czo/58F/od2yGxw0CfWC0ARshkgRyDo6c4rYFRMKAfr IBNVekDdBn4ccBpMkvU+X1jBbtODpukm0Vndf3TSmqCo5T5naEUTadUYUbLxs16bRsW1 7f6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558594; x=1720163394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qw+zxMHTEIwsFcpzBJxdUQmKFi6OrynqizbQoSQ84sA=; b=TfxX+aPA+Rq7YqPUf/rKd92MoG2Xzm+AI5cexKf4HVpK5PzyzF//DB3lTFvF2Cjfz/ JUT4z/lQQGRipbE9oRg8O/7E6KdMFtnthwd7awVZkT7vozcPzaepTqmj61Q8MGGMlwma DT/f4UI1Bc/cu04z4Fqxn7Hme9j3kTkjEXB64LSAKSWP20d4OhN6rbEbTWuXziz3C7ly Zm286rJRQCU74biW77nvbt8vJHMEjfKgEzjNx67I3uigrzPrnT/qM7KHIDJHSjQZiKiM c5KYUsiBSHtD4x7+iA223wVizBHff1zyHnZGc+m5kUwQBTaWGYUnfuTWd5EsJ51miKvM Tj/w== X-Gm-Message-State: AOJu0Ywtwz2X51lSiylCQ8MunWG2UVy0/TY0OjG7rmQ8tLeNf0Zsu7Py A1aeYHdrAmP4awi7iJn4VVof/BtPGtQrvp/sUY96eTChfao2DQRwwyxjABW2VgbD/AeaZ/itslK D5R4= X-Received: by 2002:a05:600c:4509:b0:425:61cf:947a with SMTP id 5b1f17b1804b1-4256d50efefmr5351985e9.12.1719558594316; Fri, 28 Jun 2024 00:09:54 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af5901dsm21620825e9.14.2024.06.28.00.09.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:09:53 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 77/98] hw/sd/sdcard: Remove noise from sd_cmd_name() Date: Fri, 28 Jun 2024 09:01:53 +0200 Message-ID: <20240628070216.92609-78-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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 These CMD names weren't really useful, "UNKNOWN_CMD" is simpler. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 19322c558f..0a7b422b2c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -241,12 +241,7 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { [18] = "READ_MULTIPLE_BLOCK", - [21] = "DPS_spec", [25] = "WRITE_MULTIPLE_BLOCK", - [26] = "MANUF_RSVD", - [40] = "DPS_spec", - [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", - [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", }; const SDProto *sdp = sd->proto; From patchwork Fri Jun 28 07:01:54 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: 808194 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224205wrr; Fri, 28 Jun 2024 00:11:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVNY0fuLQ3Vr/OSL931hZKG+rHovJ66e8tUciOt3t/PSAeH64GNq0MqpS3et+qpyw9N9EtP1G60ymaUMZN1CDVO X-Google-Smtp-Source: AGHT+IFK9VaadHGE0AVoawH6IDUlXT+Hxf1z1/KpkHkYjCUcvWtInE/IuY01hEQmb6kgwkSGLk/9 X-Received: by 2002:a05:620a:a58:b0:79d:6a0f:e127 with SMTP id af79cd13be357-79d6ba6993bmr124837785a.17.1719558684734; Fri, 28 Jun 2024 00:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558684; cv=none; d=google.com; s=arc-20160816; b=hXt0VSO9j7nVxH/CcvhurD6Dx1GqsOzSA5YRleVchVf9aOZHxkaIKQQpLNLhvHwocR aoUfIvvUmIO9lkgsQTVC0mjmD8n/AbZZgAvm+antmsNpk2R/9gQ+F8PbsLHiCZ2tyPxM Wliu85YfjLgVkuEeHRFwZ/4OIXF1vPsW/Yf/YEkDPYub6obLg/KpUMQnns01Y8WjDy2Q +kY7V/jsBBNCZxM7jWx+7bJ2wo1mopkXJqkWDLfitc+QIjU+AFjyDwrQkV4YWt+jswrk HU0LPjsLS4KJGEfQPZabofajD0VM/qji7VXbz1hW2QdBbnCgjivGIAmpD42ce1e8EGfs PP2A== 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:to:from :dkim-signature; bh=t05HoVB9l7/y3jswyRpww8YiOUTnZmazAh4RttVAsxI=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=FRZTdKPa0u2Rge3tQnBH4RNKXr7h9mN8C4QPcYTEljOh2LtvVx1/LQiS7M5FVhHeCA T0rvmJcyBwbNwB2MUQjlYBJsxgvopQ4HycZWPAMkn0994djh9syZ+BBNx8oJ+KZ5F/iR krN8vPtxPNN+y496zg1UMLBEHEYDOKCp298YVNEzkLOFFrcsteW1byY3rzfwbjFdk1ZJ lnLEKpdSEfRappAlE4B8N6IG8g7ZScaINJn6LUXnYZ0gA+xQENa55fCe3g21m7tUIQ1R UNCfREiq1SwOGIliKwfBnjUvc9QUOO9dARKP5evEYaK0XgfuGtKUATRXS9eQWhVZQT/O g8aw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bft+f3/r"; 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-79d69261294si119597685a.100.2024.06.28.00.11.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:11:24 -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="bft+f3/r"; 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 1sN5kP-0000yf-0N; Fri, 28 Jun 2024 03:10:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5kC-0000q5-CU for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:08 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5kA-0004Zr-6K for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:03 -0400 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2eaea28868dso3274731fa.3 for ; Fri, 28 Jun 2024 00:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558599; x=1720163399; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=t05HoVB9l7/y3jswyRpww8YiOUTnZmazAh4RttVAsxI=; b=bft+f3/rNWVof/h482ThKrPnXCwN1atrYGMxO/ML2UDjZ3XHcopv4mirm+zB6szMTk 0Q4H5cTUm0dGeSCPBmS2D1SBBI0CFAjFi4vakcCSdHPSajUYYfxhGIn08LWbkDx6Vh6Y Rv5mzCMrmTu2gQI36f/jpge6mdytXDf3cUQpeeMQCNRFrn/rTdYXHx06a8HcP3p3XjaR L/NmloamhtXC19pre+wrawq8SRYU8G9NE5GlSh9qKjk+ZuGnazNdb0rYnOd+m5Mok+Go A6TtBqUcatJXuCxqkzRg+vHNt3MSQNfGCgNBaXKbKbs3oor5X1crz4Hi1iqb7xLihaco xzrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558599; x=1720163399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t05HoVB9l7/y3jswyRpww8YiOUTnZmazAh4RttVAsxI=; b=KOpRIR7PRvIGQ05bM7JQJECli1QU5NF3h42a5sUhqkCj5FDRnYf24JYSsU7YRutQ8g Yt5lJU6X6CdGgjgX8mqdNOLqZp2sRfQvAAazu9l4d/fOuYXgsMWJ2lpLO1jRiQC6kXEU 6NQm7cv0rv1a+5ztHmhzQGu0xkaBAWsKENttQJRB0YTrx/YM58p7SVhIw8GYLdgZEgoQ 7mecZsCcrbSAwTuHijisAij16B4+m02bDexil4BrlF3evN9QGvUaMlPX7QkdxqbdrlO3 t3dVHUjGUhjXJjzimtNS5ou/Ic5KAxAMgA17ITJNdxWvWXYRFYkZ5/wYyC6cG76bXubO bsbA== X-Gm-Message-State: AOJu0YwEIwrL4WAdsH38o5aodt99Yh1kxE4+1GzFlIZp6ZmzCCd3rXy2 zNkIuIfB4QzciMstIcAEoEk4LLlvvqBW/DihFLikddogsTiIGHe25GeBHiCPTh4TeBsFUMZ1ny9 4KjY= X-Received: by 2002:a2e:a17a:0:b0:2ec:4093:ec7 with SMTP id 38308e7fff4ca-2ec5b2e7238mr119455091fa.30.1719558599421; Fri, 28 Jun 2024 00:09:59 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3c272sm22262955e9.8.2024.06.28.00.09.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:09:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 78/98] hw/sd/sdcard: Remove default case in read/write on DAT lines Date: Fri, 28 Jun 2024 09:01:54 +0200 Message-ID: <20240628070216.92609-79-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=philmd@linaro.org; helo=mail-lj1-x236.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 All read/write on DAT lines are explicitly handled. Reaching this point would be a programming error: replace by an assertion. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0a7b422b2c..64621d4340 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1951,7 +1951,6 @@ int sd_do_command(SDState *sd, SDRequest *req, /* Valid command, we can update the 'state before command' bits. * (Do this now so they appear in r1 responses.) */ - sd->current_cmd = req->cmd; sd->card_status = FIELD_DP32(sd->card_status, CSR, CURRENT_STATE, last_state); } @@ -2016,6 +2015,8 @@ send_response: qemu_hexdump(stderr, "Response", response, rsplen); #endif + sd->current_cmd = rtype == sd_illegal ? 0 : req->cmd; + return rsplen; } @@ -2171,8 +2172,7 @@ void sd_write_byte(SDState *sd, uint8_t value) break; default: - qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__); - break; + g_assert_not_reached(); } } @@ -2238,8 +2238,7 @@ uint8_t sd_read_byte(SDState *sd) break; default: - qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__); - return 0x00; + g_assert_not_reached(); } return ret; From patchwork Fri Jun 28 07:01:55 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: 808230 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226290wrr; Fri, 28 Jun 2024 00:18:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVDYa6OeAj7DGEYVBYOXKBiq3SdEi0VRDlALeZP0SrqpKPgTNPp+bPaEGzdaGcQ4jTTvm1iQOJWHZKFWF/oiyph X-Google-Smtp-Source: AGHT+IExP3QQ/ymIgoJZzuj5qIkmee1v0DWW1b7SNTkt4zEWFA65E2cOnJFFbf0ftMGyTt9XfspA X-Received: by 2002:a05:620a:190e:b0:795:5750:cef7 with SMTP id af79cd13be357-79d6ba991cfmr138380585a.36.1719559107781; Fri, 28 Jun 2024 00:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559107; cv=none; d=google.com; s=arc-20160816; b=l3sBC1+jaCz9MNVrwzy0OGVYrAh+MFFi4+gBy5uQ5hOW9L/bjYsMR18clPrZ6jC/PA As7dK1f0NsFcqg8uj8H2smsDFKVdhyhyZ97XqJnae6x0bNyzR6cFHvtr7XQ3/Kzobe+5 pW/2ptna5WDpjlpj/OJBauo/sVnSWwOFyBDPzBhP4RpkDqwYlC6eZ/sLzWplnSjepkCc WhZzMbqsb0pp4B5YXbC5xjjKmVdfLPoTbwm1wG95tTJwXDmIS3V16zYLeGtNSDb8hray g/oE/NXhHrEZpbqD5tNIOpDjYj49Wj3hQT79aYCrScdfxWxW7eq9Jq5A0xWfoQ4knqyJ 3U4A== 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:to:from :dkim-signature; bh=G214GiZ6GoHQbuSVeY1gM0sNgUJBhdD0Klfne+Cmhik=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=stXw9HZBXwV3n0kU06F1SmFqcKh+TWdn2pTuG6VS8tFc076ZIe421bQIoAIijJ2ACi ac706jHO6Tso62e16lwJMve3jnYkLESNsyKym502d09Lo2IHzehqc616H2Qu4lHlpfzl i5wbNPF96wLk7jtQFMSDPs5CQxxPwY/Q/PtTCvYHFRalyqSlZV/qNEKmXLK3zSFNdALP qHOeq8KjRx4lQlH61MXxY3riODS1wfdt/H1jQKWzlKl9MnGkLEnVIBidT0LFo8yiSkef jRq0eHcWYwQhP3QS/m9AXnrv2NsY5zgTUNn2euazqDEWDO1Wz5mhjMgkEja41j1zq8b/ vPbg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s5ob1wo1; 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-79d6933b2afsi118462885a.644.2024.06.28.00.18.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:18:27 -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=s5ob1wo1; 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 1sN5kS-00012b-AC; Fri, 28 Jun 2024 03:10:20 -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 1sN5kJ-0000s6-4t for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:11 -0400 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5kG-0004lW-5o for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:10 -0400 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-52e7693c369so357328e87.3 for ; Fri, 28 Jun 2024 00:10:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558604; x=1720163404; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=G214GiZ6GoHQbuSVeY1gM0sNgUJBhdD0Klfne+Cmhik=; b=s5ob1wo1rcjBVUI+MwK8M7IDrplaaVmMsWErNK49mdlw4BVqLz+uD53JlcNEhTes2J H2H7xKhWNl0B9kaJsfBix4TIJWCHrOHef8EMAyzNv3q4GRDGZqTwoUeL0sJReW14GaOr 5VnEwmSm/iAEEWIlRn9DRAtI4iTZDkE6MGY5kaMe9vjAiENEaWisYnO83E5whlsOqFGn RWLz/o+2EaYmcEEKiBmz+wEhmny1FiHVFRPjl/bcW+Sz+Uj2CgARyMBWukf5JaDL1QUV Eu3UGUf+jqv8z5tzekvYTLg03/B+ADGDioLrvxRxEt7l9vYQawujgtKM/HGkrvjiC6N1 Q/yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558604; x=1720163404; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G214GiZ6GoHQbuSVeY1gM0sNgUJBhdD0Klfne+Cmhik=; b=dLZHB4c/5GdfgsS3kzIBG9++ma1pQXYVxEqBA3xn844A2YYA/RF7srMuKBIop8jOxm 3+lH515/3a72cfxn71guH45sfa48AX0hHMLd/fHvvdMYuJyVBErT4Bh06HJ0WSQEDcUu QxZNTEN7qTtDl1cwss47+SgNqtRvkPvu5aP+YtaU0lTC7R9CNKef3wAI2NeXvHDPWLON Qb90oc40nJAXNhPdyUTBgc7M7+ueg2r4M0sx+ENbW219lRiKVnyzYGll5Hl9vZNngRF7 DlpU6rAi3ZX65Fg4mA11xmPGl5eRe3KZF0AErUIgcLtu0Qp7gm94d1DnMeNMMvp3vJIQ dEIQ== X-Gm-Message-State: AOJu0Yx7hcna7PV45zusciM1II2VNjWvDJl0OZEC59kZhm+qzaa6DpOj btizCzIAtOwOWlEFmCjE8abHnzVAx2KT5W4uM44NvLuQBtfkXLUgiJyT2KgR1a/jj15+tVFWM/m QlNU= X-Received: by 2002:ac2:44da:0:b0:52c:dc6f:75a3 with SMTP id 2adb3069b0e04-52ce062007bmr11514448e87.40.1719558604560; Fri, 28 Jun 2024 00:10:04 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd5fcsm1344377f8f.11.2024.06.28.00.10.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:10:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 79/98] hw/sd/sdcard: Trace length of data read on DAT lines Date: Fri, 28 Jun 2024 09:01:55 +0200 Message-ID: <20240628070216.92609-80-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=philmd@linaro.org; helo=mail-lf1-x12f.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 Some commands expect less than BLOCK_LENGTH. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 4 ++-- hw/sd/trace-events | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 64621d4340..a0da06e017 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2197,8 +2197,8 @@ uint8_t sd_read_byte(SDState *sd) io_len = sd_blk_len(sd); trace_sdcard_read_data(sd->proto->name, - sd->last_cmd_name, - sd->current_cmd, sd->data_offset, io_len); + sd->last_cmd_name, sd->current_cmd, + sd->data_offset, sd->data_size, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ case 9: /* CMD9: SEND_CSD */ diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 6a51b0e906..5dfe6be7b7 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -55,7 +55,7 @@ sdcard_req_addr(uint32_t req_arg, uint64_t addr) "req 0x%" PRIx32 " addr 0x%" PR sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d ofs %"PRIu32" value 0x%02x" -sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint32_t length) "%s %20s/ CMD%02d ofs %"PRIu32" len %" PRIu32 +sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint64_t size, uint32_t blklen) "%s %20s/ CMD%02d ofs %"PRIu32" size %"PRIu64" blklen %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" # pxa2xx_mmci.c From patchwork Fri Jun 28 07:01:56 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: 808218 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225440wrr; Fri, 28 Jun 2024 00:15:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXhkmaf0cvwAOfLOvShWUE+ar50w9qDZBFAhESAnuCh2keSrfc+DtDk20lf/muS6vOcC0jPl8UdY/XancojPLaY X-Google-Smtp-Source: AGHT+IFMB0GZFBqJ4/4MKU2VDrNfHOw1QneOEe8B6Q/+5zFrQHp397OXHVLKh5oMIbcYW0QazvHE X-Received: by 2002:a05:6214:519d:b0:6b5:45cd:daac with SMTP id 6a1803df08f44-6b545cddcc9mr195713046d6.48.1719558939943; Fri, 28 Jun 2024 00:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558939; cv=none; d=google.com; s=arc-20160816; b=P+1OEChjIydEz+geHlXYJcMS02wSSGHyRJtAC7AY4INmsKr3dkOjMt+BO9axz1X+6G eiM79WjcbtbvJEAJHYAlPB+IRS4Y8+dIaUbCR21Pe0EayqUZFVQJVZh2TmtgJj47uMtL lF+UVkaHd9Pj67m1WDxvX4HjjBqNMdkO/LNUTB05rsVZKrW7RT04z2nb57+kiH6kF4dY Ij9+5k4s8j0PK+J3blEX0M72SBno6EnvUcZYu/dFhfj0r0aGVYTO22mmx3wxYmrmKIbg 7pVzo/afo3IaI/bFJEjaHzzrOHNsFUh8X9b0dSjdEV6Se+QJW3NUdOQ0ug12OqT2al1p 2P1w== 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:to:from :dkim-signature; bh=DS5w/rOHX5RjJWkmyFPsFftFPu5c4nwaKlj59xhrXaU=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=BG32HURw2MauVVKlp+vaghmjY2vboh9fZCKxDSWGtOeS2Xi9QEzeb7aBffmsochzC1 tifxl1NHtnLQa795RGqOi9MhnWPzvPlS1d27zLVDyCKeG3RJpbBi2VLOLFCMhSwVXrer elhYKtHJPJUmx6EO3lDEB2yZbXVoNTrSAqA/CTWXZYhEEH1KPn1Eq2WkD3yzavjZS0rI q/bKW6SDbmjJO3SQSL+5Qkjrr+K22IW2zoTAxXspfFxkS7UZYivFqeOBacR/TuYyf4jr kpvyUB1QRXaEMIq47AKCNkpIP+92IE5G048jFovsR098GMLPjX59UXI+PFh/p7QZZQU7 ShLw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CDSj3NT6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e60a211si14354116d6.478.2024.06.28.00.15.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:15:39 -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=CDSj3NT6; 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 1sN5kU-0001EQ-G5; Fri, 28 Jun 2024 03:10:22 -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 1sN5kM-0000yd-0g for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:16 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5kK-0004md-B1 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:13 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-363826fbcdeso217155f8f.0 for ; Fri, 28 Jun 2024 00:10:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558610; x=1720163410; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=DS5w/rOHX5RjJWkmyFPsFftFPu5c4nwaKlj59xhrXaU=; b=CDSj3NT6P+VVs/CY9mPoepzDmo/l6jZpeMcjrJX62Sw2ZWOr9/wCmS4BAJCjVq/crV wIqgbY2n0OXemiypjPuk7GzKJ1JtdW1K6VUqUaSts91LqWCJ3N3nwWJ//LoTZRwO8nx0 o+vagoML+KfEU7nIzvlyICenWWsmWLlSTAEncDlKDrzIwyGYlXGBR6Vx9jnimkZCfj3w lvInTp0UKVzEz8QiK7pxVVnqaul44hF7qBBu2iO3pwFnm6UpcfpNQ18+aNy0LI0hxJXb gl1jp9Ts843C7HTR6/v8JYkbrdaTj3SLO6TYAmbUfT9HE5bcxCKsFvAX6gsB7rrPjM9r /76g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558610; x=1720163410; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DS5w/rOHX5RjJWkmyFPsFftFPu5c4nwaKlj59xhrXaU=; b=ilNQnru5nhWPfChdhzIXZlepLlTFuTKfdoG53jnX0pbd4STXPp0FFHPFaA2LzH9cws 3ibC5+TBsSEEyzccqSfKp6eHROqCcDFOY4tcPnZxeIMTde/YrcsAfY+X83SVmY0AlXk2 o8cYSA8rk+euY1kh/p2utNZ1IOs1+6iG5klK2C1XNaz3jFgfQpPFEuM+uRkJuJVFj2QU /l0n/JK6U6mIEjRld5vC5aeyQiUBj8JzNDb79w/UEPKJRUoTjYW4mtjL4BA1Kye6JTlD 6Sl+VQymt9FzIuvFfZ+iVKQhx6/YWBsoQqjd2BOSR1aJTEr8DVX5/0I37IFrUK2RELg0 JK1A== X-Gm-Message-State: AOJu0YzfnsIynYoYS+bFBSvqDlU07zjuXxKg4DSbrOs9LLxsNP9GuYh8 6hGM29ej7tSIiyA0FraRZgQ5Gb/hLEL7h8ipWwdBHeFXzEqCAEERVwIDWcbblgTzCfXnzzgveas iNWo= X-Received: by 2002:a05:6000:178f:b0:366:ee52:28bf with SMTP id ffacd0b85a97d-366ee522954mr12776879f8f.59.1719558609677; Fri, 28 Jun 2024 00:10:09 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0e143csm1340442f8f.59.2024.06.28.00.10.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:10:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 80/98] hw/sd/sdcard: Introduce set_csd/set_cid handlers Date: Fri, 28 Jun 2024 09:01:56 +0200 Message-ID: <20240628070216.92609-81-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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 In preparation of introducing eMMC support which have different CSD/CID structures, introduce a pair of handlers in SDCardClass. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- include/hw/sd/sd.h | 2 ++ hw/sd/sd.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index c1a35ab420..0d6d9e452b 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -127,6 +127,8 @@ struct SDCardClass { void (*enable)(SDState *sd, bool enable); bool (*get_inserted)(SDState *sd); bool (*get_readonly)(SDState *sd); + void (*set_cid)(SDState *sd); + void (*set_csd)(SDState *sd, uint64_t size); const struct SDProto *proto; }; diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a0da06e017..b0ef252001 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -671,6 +671,7 @@ static inline uint64_t sd_addr_to_wpnum(uint64_t addr) static void sd_reset(DeviceState *dev) { SDState *sd = SD_CARD(dev); + SDCardClass *sc = SD_CARD_GET_CLASS(sd); uint64_t size; uint64_t sect; @@ -691,8 +692,8 @@ static void sd_reset(DeviceState *dev) sd->size = size; sd_set_ocr(sd); sd_set_scr(sd); - sd_set_cid(sd); - sd_set_csd(sd, size); + sc->set_cid(sd); + sc->set_csd(sd, size); sd_set_cardstatus(sd); sd_set_sdstatus(sd); @@ -2472,6 +2473,8 @@ static void sd_class_init(ObjectClass *klass, void *data) sc->enable = sd_enable; sc->get_inserted = sd_get_inserted; sc->get_readonly = sd_get_readonly; + sc->set_cid = sd_set_cid; + sc->set_csd = sd_set_csd; sc->proto = &sd_proto_sd; } From patchwork Fri Jun 28 07:01:57 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: 808233 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226348wrr; Fri, 28 Jun 2024 00:18:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXf0j9us6+lVK9ZWlpTAJ32MA93RnyQoku0yQN4z/hPokNpRZ8GB96V3fnyGanhnD6CdsEY6hxeCOtBU3BImfqg X-Google-Smtp-Source: AGHT+IEdeO7K9kclrn0ZU8OlAScapgWRrBNnv+MWN0bdEkzFfU+Mt1P9Lt/kEXAgoux/kFtAHOcA X-Received: by 2002:a25:2b48:0:b0:df7:887b:abfb with SMTP id 3f1490d57ef6-e0300f40017mr17821083276.15.1719559119591; Fri, 28 Jun 2024 00:18:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559119; cv=none; d=google.com; s=arc-20160816; b=H3JNfHrsHOYr88I2lZWZ38hP3HhW3DNE97z0xz2R52DMRo8pDsPv8Av4wdXWx8Nznl OM7l2bMIZ2FPlLhMMgzlOKzCLJGPKKW17gCCBzINPzjgPcQ7Clwnpm7uNwg3sk0oVzb4 uI4dOqPM9Ng3QC5wm2c6z90hO7PjvbZkGakIE7Yu6wU2OJBOfzrvCTZSWD7CVNSTKcil pcfdNLWUyMMWb+5WpDujSg/QSTW7tOeGWOv6BcTdFCLHjxCaQi9I44E4865/EdbTg+mp +BDWSmHTJ8KszHLdNYrYORsLyD5FJGzSiCNQLCdZSmmwia1CegqDvwPHq2AnGlokEZCM Vnlw== 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:to:from :dkim-signature; bh=l5dk8XRtaZNYeklBLa17/11yculQIx4J+IHrxLfyvgU=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=U+eKY3iuw8in1SgTk24NKR+n4BqVl4ZVirAGSAPqC6p7FC1QSp9iLrKaUY451IQGyq wd79GD5f0swynGf7PUm9ZrBI/hegYtAMzoRPWPG230EmnPWBEeHx3rNRLzKGWw95Qrm8 kRNoz74kTK3DgU8X45BmwlgqblXs4/Yx5UPJWdYbyXaqlVKA74jZXl3+CvxrKxCf1hRY 9JVB89orDmdk0VjiI8B85/6MYONlX9iNRqGiNq3o8SOwP+PJHHtYckJ/PVbfOJoLgwqY PuNPKVqEcbptDcIE30ZzWfRUyWCkSyNWRXH0troc8BOq0+Z8GHBQ4hx/P8Vd7JsBcrPJ L0Wg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ud+Yv6NE; 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-446513df9f0si13434991cf.166.2024.06.28.00.18.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:18:39 -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=ud+Yv6NE; 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 1sN5kV-0001Fk-7Y; Fri, 28 Jun 2024 03:10:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5kS-00014S-GG for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:20 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5kO-0004nK-N4 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:20 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-424acf3226fso2720005e9.1 for ; Fri, 28 Jun 2024 00:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558614; x=1720163414; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=l5dk8XRtaZNYeklBLa17/11yculQIx4J+IHrxLfyvgU=; b=ud+Yv6NEPylVbiw7RCSHgx0Kh8Nc0yFH0tz9A73yBOoj8ZjtRxqc5GAU2rvUBtu3iz 8g0XLK6NKiHjEfbYHKsN4jmZATMzTN2A4nGIfcZtktHSkpZ3+YsHLPBFGBsHWx3WwIyw Ca5pGhAi5vpqHcR1ofCJQ1zum4HYs+E9CaR6w6+yxtjj3dtDDgBvsNgF9dZ7ePTaKSbd TVz11RAjytq6HxpgL+iJXOSRr8UU4Op2UgRFi+HTRhpsa6KWD1WucVuYuJKPtcm4Sg/l d5py76TtJcAdl/3Nbjb0KSQj3S7gIGnv+DgH3NZ2UQJqsIDrD32t8zF9vxruYlHDcD+L Oftw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558614; x=1720163414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l5dk8XRtaZNYeklBLa17/11yculQIx4J+IHrxLfyvgU=; b=vnAVZ8NwhLKC1xZTDsdiuaJs0I89+Is3RNT8ByZNFeTH9fiw0T86QSMa8OZoYQXL0S euzGah+x2NUJbOINT+qv5/3EVlua/CCaWu+/R7RrvEd3yciQ/QWZuUTPB0tVGksiPSW0 j/FWh8DLGVpYq5P2Tz2gSOV8JlUwqeRfQP7mM87gQ5y4SkNEK7GpciPE+DVWQ3mDtjxp 4ouWCpK3vmMkC8fVpZIIWw8X6JHdbDxPmVN7kuiJ0xYjRr6v3Rh3loZWFq9MbNA3tYE6 fN+ZZOeCazCd4XLHsTOUYQlikFThifEONnn3EJKnMSoHSO0iC+9I2tWFMMwM7wRm4gVW oK1w== X-Gm-Message-State: AOJu0Yzby0MRKa96Aa3KPPGipF68fNRH/doCnI2RWHWhNGHK9F/Hk8R7 dXgSI7GOQXYUZ5pb2Uz+3eXivnjNa9dv6nJ6W4hUVORLNBeznls6Oi8XBK/M9W9Fd1hRhGWCgAP kTVs= X-Received: by 2002:a5d:6c6c:0:b0:366:eb2f:4f81 with SMTP id ffacd0b85a97d-366eb2f4fd1mr12335290f8f.45.1719558614647; Fri, 28 Jun 2024 00:10:14 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10307bsm1328372f8f.94.2024.06.28.00.10.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:10:14 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 81/98] hw/sd/sdcard: Cover more SDCardStates Date: Fri, 28 Jun 2024 09:01:57 +0200 Message-ID: <20240628070216.92609-82-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 So far eMMC will only use sd_sleep_state, but all all states specified for completeness. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b0ef252001..92ac57a648 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -76,7 +76,9 @@ enum SDCardModes { }; enum SDCardStates { + sd_waitirq_state = -2, /* emmc */ sd_inactive_state = -1, + sd_idle_state = 0, sd_ready_state = 1, sd_identification_state = 2, @@ -86,6 +88,9 @@ enum SDCardStates { sd_receivingdata_state = 6, sd_programming_state = 7, sd_disconnect_state = 8, + sd_bus_test_state = 9, /* emmc */ + sd_sleep_state = 10, /* emmc */ + sd_io_state = 15 /* sd */ }; #define SDMMC_CMD_MAX 64 @@ -205,13 +210,19 @@ static const char *sd_state_name(enum SDCardStates state) [sd_standby_state] = "standby", [sd_transfer_state] = "transfer", [sd_sendingdata_state] = "sendingdata", + [sd_bus_test_state] = "bus-test", [sd_receivingdata_state] = "receivingdata", [sd_programming_state] = "programming", [sd_disconnect_state] = "disconnect", + [sd_sleep_state] = "sleep", + [sd_io_state] = "i/o" }; if (state == sd_inactive_state) { return "inactive"; } + if (state == sd_waitirq_state) { + return "wait-irq"; + } assert(state < ARRAY_SIZE(state_name)); return state_name[state]; } From patchwork Fri Jun 28 07:01:58 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: 808211 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224943wrr; Fri, 28 Jun 2024 00:14:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUQhpuL4mPV9TYQlG32pPhgUWffE9BX6LFG/55uXcXlF7LsRQG385tVnFN+NDasCcZxdXTUDGCq6bdfk6jWyOCh X-Google-Smtp-Source: AGHT+IEQqm8+lOmWkaZS63m1O6cILZndMbzRM9IYQCcfEmnVl5I+7FzhirdvEZf3pAcgTn5H92sA X-Received: by 2002:a05:622a:8290:b0:444:f6d2:be7d with SMTP id d75a77b69052e-444f6d2c0e4mr120541661cf.49.1719558842158; Fri, 28 Jun 2024 00:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558842; cv=none; d=google.com; s=arc-20160816; b=Nf8y1MhbKdSpBVP+9Hs+I1hXXIl/i/T87OZTQnJxllMNvgjJrXc+qvDN+HqlqgeLf4 jd55ttb0colxyapU1VNeTSIID5d2/DTDa8NgZqEv5454XgMDY2JqPIB+QHRyPhOpSiaq 7QXhLBEOoE5CUSGgaOw5H0Ieo51Lo+0XEYETZlWftdAsKTa7XDR/h1+mvoAzPZMKfkIh o50LxuNb8SkQl0ArqINqb+iWGJ9xTt/I1u+aMfY6twrxw1njK+1YgX5FukryLmOXyJxU dJYSAHAKEn1P/ChlqClBhVPMEHuwRSb4V2u4s6HBq4XfVeo+zJqxf3Kc+3Tda4CMNk4m RG9g== 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:to:from :dkim-signature; bh=ioHSbst/hdtxzaxEjer3G8zRk1miiDF0UJMnrrURsps=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=tDirDK6qfbJxSGf5Iv494iAKyfql/OkSu7Wv0bPsnRJqAC+UfFmgtU/l8BulH2M9Hc J1+S/GzOC/tp/fKboJKamG2gOiaiACFt5FcXG6g4JSl+v7iusSTwxl6soDNhh1zRdZRu ZaaojoT9hptdJRZI4SZvAF3PpWMUB8nOsO2Ftal/zuS+8KjeqZyfo6vwq7ZMRzpdvr+M 6qlntvwebM0bWr4tk1W5Dq79JyUO8n6zswEIKfQe8xYLxrfoVA03WsUd17oxKN3r7kqI 75pVvVq5o/4WbF2TDaY1AcbIu1nj8KryCPP1LxhgzTRZMOclxm7FAOhJ0ikF7dtkjdFV Jv7g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d9dKS1RO; 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-4465148759csi13073871cf.285.2024.06.28.00.14.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:14:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d9dKS1RO; 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 1sN5kY-0001NQ-AJ; Fri, 28 Jun 2024 03:10:26 -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 1sN5kV-0001GJ-9B for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:23 -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 1sN5kT-0004nn-Gh for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:22 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-424ad991c1cso3249135e9.1 for ; Fri, 28 Jun 2024 00:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558619; x=1720163419; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ioHSbst/hdtxzaxEjer3G8zRk1miiDF0UJMnrrURsps=; b=d9dKS1RO+hn2g7Lc+xoRmtdilEh+L+oWbUWUtCkyhTLek/TxvB2Q0eLk8ulXBjoVBC C1yjV/UQQ50BlAD3BfCZuLf3KJAiFrzaOtWAYCWAAlVz5LiVmiRcDLQl4+62I/0HR7iT co/TqO4MKy5MnfMBGnPCFZ/CmeKHa6imbe6MCvNaoPTwJtT5T9CGNNacxNmYQ1Qds/E0 XwwHUWhpP2WrTtJlcBoXkY7ILilihIA92+s1u43P5sNMVDPpJCeh/+S7/tfjYHTdZ9nI pR6Nu0ts3U5sHXT2rzHXEweiJED2vpNGmLlcWaQVGlZYCJfco6U4ZhL4+SbnSne1BL1T ACxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558619; x=1720163419; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ioHSbst/hdtxzaxEjer3G8zRk1miiDF0UJMnrrURsps=; b=mHPVT6L2cIx+quioNwqm1Er+XDNOSySmH8R1nYYlxCou46PZrY882iuzZAAogTyuWt HZRgEr7/5p6WeFZAJWwGPLWcP9vnBzLiP9Qw2T0lREh4I139M3JTFYfZLp8IOjTyd9Am I9o/XWy2Dpgja/s7yg7zqG2Gv1ELfq+9Y6kp05brR4jkUNf4gyzRlHP7xa8qpZKH5Edr q9uHKjw145eqfaZazKV+FLDrNj3fiyb1HE/AgN2QDklZCR84Rz2UCbL5GVkIcWDSNi+H ogbNdmUMoY2PCMhCiGRxUbSb2u12h1p3Zc+LuQJlw3x7o4uIvA7xM0eimZGpMGIRp+6D YiNQ== X-Gm-Message-State: AOJu0Yx+6wnaQCV6frXxIE006p68YX0TTx3TeNZdiIsOyJsl8IKu8aoP wyxbJoSkE/FudqH9dEqOL3+BdO/qZrsiOHDs30HGKLYHVseb6+Rtv8h5wRGdE56tcg+cKsPuI9F ukPA= X-Received: by 2002:a05:600c:4f07:b0:421:dd8c:35a3 with SMTP id 5b1f17b1804b1-4248cc586d0mr133713535e9.26.1719558619753; Fri, 28 Jun 2024 00:10:19 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a103d62sm1328689f8f.105.2024.06.28.00.10.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:10:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 82/98] hw/sd/sdcard: Basis for eMMC support Date: Fri, 28 Jun 2024 09:01:58 +0200 Message-ID: <20240628070216.92609-83-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- include/hw/sd/sd.h | 3 +++ hw/sd/sd.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index 0d6d9e452b..d35a839f5e 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -96,6 +96,9 @@ OBJECT_DECLARE_TYPE(SDState, SDCardClass, SD_CARD) #define TYPE_SD_CARD_SPI "sd-card-spi" DECLARE_INSTANCE_CHECKER(SDState, SD_CARD_SPI, TYPE_SD_CARD_SPI) +#define TYPE_EMMC "emmc" +DECLARE_INSTANCE_CHECKER(SDState, EMMC, TYPE_EMMC) + struct SDCardClass { /*< private >*/ DeviceClass parent_class; diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 92ac57a648..249fad0468 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2379,6 +2379,13 @@ static const SDProto sd_proto_sd = { }, }; +static const SDProto sd_proto_emmc = { + /* Only v4.5 is supported */ + .name = "eMMC", + .cmd = { + }, +}; + static void sd_instance_init(Object *obj) { SDState *sd = SD_CARD(obj); @@ -2504,6 +2511,28 @@ static void sd_spi_class_init(ObjectClass *klass, void *data) sc->proto = &sd_proto_spi; } +static void emmc_realize(DeviceState *dev, Error **errp) +{ + SDState *sd = SD_CARD(dev); + + if (sd->spec_version == SD_PHY_SPECv2_00_VERS) { + error_setg(errp, "eMMC can not use spec v2.00"); + return; + } + + sd_realize(dev, errp); +} + +static void emmc_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + SDCardClass *sc = SD_CARD_CLASS(klass); + + dc->desc = "eMMC"; + dc->realize = emmc_realize; + sc->proto = &sd_proto_emmc; +} + static const TypeInfo sd_types[] = { { .name = TYPE_SD_CARD, @@ -2519,6 +2548,11 @@ static const TypeInfo sd_types[] = { .parent = TYPE_SD_CARD, .class_init = sd_spi_class_init, }, + { + .name = TYPE_EMMC, + .parent = TYPE_SD_CARD, + .class_init = emmc_class_init, + }, }; DEFINE_TYPES(sd_types) From patchwork Fri Jun 28 07:01:59 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: 808240 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226608wrr; Fri, 28 Jun 2024 00:19:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWC/PMHAurnckFS4PqU8mmJrcKccGE/R+xuMzyH9p/u40rCQcDhW8v0t/tPn3xWqyLxYwSunEbkyqTafNF8XP6j X-Google-Smtp-Source: AGHT+IHMQ8ECQYOCiAtjy3uOjIztYrIksK+F3LH3yrO7E3i/3WUq9pVtP4TQgG7KQCDgDCb6n5gQ X-Received: by 2002:a05:620a:1723:b0:796:436a:bd6a with SMTP id af79cd13be357-79be6f19b16mr1729787985a.50.1719559169077; Fri, 28 Jun 2024 00:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559169; cv=none; d=google.com; s=arc-20160816; b=v0wuriKf8h8J69OPyG7VjXYi925orAwQu5lflgBpeZz9NRFOPMnMzc3Zdyg1yD6HuQ lkZzOpmz1+v3nk0sr4dvZKlHBo6GwUNXKBnObRj8pUN0IJpd4Zlk7R3nTWCtDI2x0Orj CK3UOzJ9S4gxLMsIc2+JzL9UQhjSlns9s21IAYk8hUrillK+Fz9o/N0JilH/eBOHnvvG lg4YkjQK1H3GvupoajS47xkwYpg1MZ4cszh5pmSUog3lLq3rRpF/QD4c9HlC6e8X3J8/ PrYtystmMJCyrS4Nyz28Dz0F5UgJbFpjaOFoE+V8rOuJPrYSvKnXQzaaeMmmjMhDhjzq OMGA== 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:to:from :dkim-signature; bh=0++Ogxou44hWy9HUie+kN/Bmub/+XHfRbLoibWWU/Qg=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=ewAUOs1/FULRYR3sTIAULqFlwSwX+XXucFvo9HkRCEhZV8DvHSAiU2pHGguCIxgnjN bpUIeYoWNGwffFDBIMWvgMCB41hz4Ka4kNUsy7Wkvl/8aWBiPO0qCnoZzMhS1DwRtdAC n8iq1gJjLtvOMC7+3dkT8WWK2UwicEFt+ggH3A1FIHvDHWx8tyrLFsRfWCuO3TTTmWcC WEN5Bfs4uSp2gbDk5xV97piEJYZiuNWPIp2KSGWvmZnSA6+W4HmOPDxMTw5vLLTXnaUw 6Y9gTRuqbhBEJ+/PmuRBAQJrTwYp0XvO9ul7YRlCe5wcLhz/SG0M9llQ7nPZ36cefNRY rd6w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a7kOqS0h; 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-79d69262aacsi120449885a.75.2024.06.28.00.19.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:19:29 -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=a7kOqS0h; 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 1sN5kd-0001Ws-DE; Fri, 28 Jun 2024 03:10:31 -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 1sN5ka-0001Q5-Hn for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:28 -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 1sN5kY-0004o6-MJ for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:28 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-42122ac2f38so1540575e9.1 for ; Fri, 28 Jun 2024 00:10:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558625; x=1720163425; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0++Ogxou44hWy9HUie+kN/Bmub/+XHfRbLoibWWU/Qg=; b=a7kOqS0hmVjM+ZumUhnocgWKmxftbpo9+fsPyizfuJHSouCCvB728uxLmVeHRYt1sY /mPLJUk1NEh13o2hOxbbf0pnqd9smk10Z3rXShWalh5yVAA4YpHu+7Dzx9gz5hDeWQNw Er4qWh5z/+8etCvNBDPReEcw8wFdRWYCJ9LqaadzVr+q6AEAWEk9Vj8BFbSf6+tka+xT alJoK6iaImTUwr13CiO/KroRGMoHFBOXKn6oy4vQsCm1zzMbCP+2jvPojiQgUSw06edb fgF8OLDjKQJP/zyZC7CcTVdpz8kiq6QaZ9bbTYEhB0lfF+hBISaw0+wWCog+KmdnHlsj DSUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558625; x=1720163425; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0++Ogxou44hWy9HUie+kN/Bmub/+XHfRbLoibWWU/Qg=; b=mkZazjtTGgNyXfcsKyq/5dHhQUxPz4fjTZG33wuxUx2i9iGBTEvkJLy/LguoHJU6Qq W9/ic3h1yy7yoP6SqTWyH/jaiensgMHYCv7yyaVCHtN3a0Dg1lJiXMb4Wmv8/wd1BTRk Fy5BWW0uLhXSxhu8Swz2i5aumHfu/BLZ1RlxF0neksFtxVovU9rwjrtcvorQYIBvgWXA dUrULREGHY53ObpdnwRNY7tWg6pbsizV9VtzMAxuxE7hfmOQzjE50NFgNeXwYeE1myY9 t2EmeqhFbK6xSzQghMSprbuuB8SEuZ/FMqeCF7OGNxA12kQvVDj51rVcPClGlPOm4eZx ZzSQ== X-Gm-Message-State: AOJu0Yw2HKK1BQ2vV6meMyRooWIFEarPyctpCC1YAAU4hZCGaDhIuXgp yNfxIB2lzz9Tvj135FnOop4K48WNdabQ0YLW6ni/ZIi14Wfw7sgjhP5OkX5krm39wAifTChFr28 yoe4= X-Received: by 2002:a05:600c:3595:b0:424:8743:86b4 with SMTP id 5b1f17b1804b1-4256d4d35a7mr5558185e9.6.1719558624866; Fri, 28 Jun 2024 00:10:24 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424a2abcfd0sm62364015e9.1.2024.06.28.00.10.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:10:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 83/98] hw/sd/sdcard: Register generic command handlers Date: Fri, 28 Jun 2024 09:01:59 +0200 Message-ID: <20240628070216.92609-84-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 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=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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 249fad0468..ebcd8c1e43 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2383,6 +2383,28 @@ static const SDProto sd_proto_emmc = { /* Only v4.5 is supported */ .name = "eMMC", .cmd = { + [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, + [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, + [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, + [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, + [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [15] = {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STATE}, + [16] = {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, + [17] = {2, sd_adtc, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, + [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, + [27] = {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, + [28] = {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, + [29] = {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, + [30] = {6, sd_adtc, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, + [35] = {5, sd_ac, "ERASE_WR_BLK_START", sd_cmd_ERASE_WR_BLK_START}, + [36] = {5, sd_ac, "ERASE_WR_BLK_END", sd_cmd_ERASE_WR_BLK_END}, + [38] = {5, sd_ac, "ERASE", sd_cmd_ERASE}, + [42] = {7, sd_adtc, "LOCK_UNLOCK", sd_cmd_LOCK_UNLOCK}, + [55] = {8, sd_ac, "APP_CMD", sd_cmd_APP_CMD}, + [56] = {8, sd_adtc, "GEN_CMD", sd_cmd_GEN_CMD}, }, }; From patchwork Fri Jun 28 07:02:00 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: 808193 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224199wrr; Fri, 28 Jun 2024 00:11:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUAcshxrn04TYnHMTVxGFj3Z4HJ3hJrK77yE8z8qd+pFbnYBTWKSiWqFFGsrCZ4Bt8dsJRMTMxAAaKPN+KbOAsk X-Google-Smtp-Source: AGHT+IFNyJ+EUdEtp6oCU9aafRpHBvwWA3z4Zlv1AhWlXWJMEGrFhi4t8W/oq3P7MtpRMKUh73Pg X-Received: by 2002:a05:620a:31a8:b0:79c:10dc:67d8 with SMTP id af79cd13be357-79c10dc6d47mr897035285a.71.1719558683408; Fri, 28 Jun 2024 00:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558683; cv=none; d=google.com; s=arc-20160816; b=UutdaNkJlGrPtbFduicOf2P1meU3YstDP1oX/3rfpGLpI+oA5pym3hWjitkKN9OVL0 X5/yVse+ZT+rnU16ztOzXIwxKazOlJGo4TOakpPhnUdUkkvRELe/VAL8S5dQmGWaCm+l SgvqoDyln8dOeeoGfXOqKq2qdBivh24q3i0SFBbb6elyHHOina7y+OuB4aFGhrzpCB6E AhLovuQjrzxXTPXrLoMSNXZvmHHBcNWiwEYPWeNKDg2yzmX5Qzul+qPfnSiC+GQX3icy Yh4e+58eAJ2JuTT+frMUGVAP8PXtX6R4dEuO/YyJxvLoqP/v1cLq231tdPS0RdK0KKcM slPQ== 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:to:from :dkim-signature; bh=UmLMWLzqSVJb3i4hpxGU8DfPCxonGkzeRg9cK3jhrKk=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=czZk0ixO/qveLq9moxkZ921CldE0iSOGMKBLFDmvPE3t7D0L/Xtmw10sbYcTn+nlUp 7W+7h2wMDvLbBE2xHG0amOtCccNPFDz7lA97fVIonNwalsu9dieWqDE60cS/WoShtbLU 4lajoMgv0GwYlMMPx192X0XqItiYXfPsS3EOfADBEMk29Jep+YzoGTLV+LI+DXgZUxeK 509QZuA9UuCCw1n/d7knXHfnfOckyv3pw0vwqEYNB0B7lYwRfARYOqyWTTm7hf3A0Pog qMrQVZuqaozuKuW4tpayzM+y/wA1JiRpn0EldQmnU9YPDqq21PF9i4lgJYJKpx29+Dwz ITyw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gle7YFHV; 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-79d69262de0si136662685a.49.2024.06.28.00.11.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:11:23 -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=gle7YFHV; 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 1sN5kj-0001du-3v; Fri, 28 Jun 2024 03:10: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 1sN5kf-0001an-Ts for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:33 -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 1sN5ke-0004oG-0j for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:33 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-424ad289949so2356075e9.2 for ; Fri, 28 Jun 2024 00:10:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558630; x=1720163430; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=UmLMWLzqSVJb3i4hpxGU8DfPCxonGkzeRg9cK3jhrKk=; b=gle7YFHVHnN8fzx/OoqwuWCmUV7ficAJMEJJGXfUlhPUxWG0QHH6Ry5xC86PS5v1BS cVlvBPevbQVV3WtLmEmgHeR8+zIPpDezhegdWJ0q2okRDNJEgttpHOoO7AQpAn5XtgC6 Lb+3frzjXu12RY8Wmqsi+CjsoNS1jA3fy2AJ5rAH6nBnaHHsGlI0CqICQMQdriORWIuD NDMU0dskfL8iPhP4djKDSi4bV2DPTTEcvadz8OxXVuwSiehB1BgQshc/pEiSRN5s9LMX Md7CpBXpLUqTlc2WYySpQTPNw3wLaRxqA49K+ylrprCFrIkz1DBWAQ7LFwmLQCJy0Oxc F34A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558630; x=1720163430; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UmLMWLzqSVJb3i4hpxGU8DfPCxonGkzeRg9cK3jhrKk=; b=OXGpWuggw74Nw+62oOzh9Kji9PDRTuIL4+qwILYnrlqDE9qrAMxgv+W502N0bkS7kw PkjgzxxSKoMB9qurxs9h1g0QNmtU7xrebtMqJcbfyQwC8XRnWu4N8eVRjTK8HUjf5uWM t1RMSy7Y6MqPXZGOgiqRvMAIjFquaYsDcWu2f2xR0kiAUYfGDfyTLmTsw/HE6v1BLyf/ RWa9i4Ifj85OguAvyUb/272sthZOmXbMgJBHtXDczqdwQ1aTTl1Yy3Jr2hG/rxr17JfX kE83UBhDLtggJD+qoPTR1YgcXjMyJ/f5GY2281uYOLyDaYJc35cZq3f766IazPsNcdEZ NUtA== X-Gm-Message-State: AOJu0YzixmNbILfzR+1b+0haQfpI7WRaoeCbXENxi3Yl7XyGM5VWWbhv vr29qea1nNTN3dNFZJQ3duVwn7cprCpx098wDpuG9oaZEbNFoPtplWHghijV0i104kLjYNxYoqb CDHw= X-Received: by 2002:a05:6000:2ab:b0:366:ec2c:8642 with SMTP id ffacd0b85a97d-366ec2c867dmr11327181f8f.10.1719558630329; Fri, 28 Jun 2024 00:10:30 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0e16b3sm1337514f8f.61.2024.06.28.00.10.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:10:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 84/98] hw/sd/sdcard: Register unimplemented command handlers Date: Fri, 28 Jun 2024 09:02:00 +0200 Message-ID: <20240628070216.92609-85-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 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=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 Per the spec v4.5 these commands are mandatory, but we don't implement them. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index ebcd8c1e43..9a2bfeaab6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2385,24 +2385,30 @@ static const SDProto sd_proto_emmc = { .cmd = { [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [14] = {0, sd_adtc, "BUSTEST_R", sd_cmd_unimplemented}, [15] = {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STATE}, [16] = {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [17] = {2, sd_adtc, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, + [19] = {0, sd_adtc, "BUSTEST_W", sd_cmd_unimplemented}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, [27] = {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [28] = {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] = {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [30] = {6, sd_adtc, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, + [31] = {6, sd_adtc, "SEND_WRITE_PROT_TYPE", sd_cmd_unimplemented}, [35] = {5, sd_ac, "ERASE_WR_BLK_START", sd_cmd_ERASE_WR_BLK_START}, [36] = {5, sd_ac, "ERASE_WR_BLK_END", sd_cmd_ERASE_WR_BLK_END}, [38] = {5, sd_ac, "ERASE", sd_cmd_ERASE}, + [39] = {9, sd_ac, "FAST_IO", sd_cmd_unimplemented}, [42] = {7, sd_adtc, "LOCK_UNLOCK", sd_cmd_LOCK_UNLOCK}, + [49] = {0, sd_adtc, "SET_TIME", sd_cmd_unimplemented}, [55] = {8, sd_ac, "APP_CMD", sd_cmd_APP_CMD}, [56] = {8, sd_adtc, "GEN_CMD", sd_cmd_GEN_CMD}, }, From patchwork Fri Jun 28 07:02:01 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: 808199 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224539wrr; Fri, 28 Jun 2024 00:12:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWjfRH9xSCS6eE0Dklhac8wvdzTATNvCDKATEUmiHlnlJt2FYVOn/hj9u/ulnKSSctTDCi8bPCqzyk5apYloXFg X-Google-Smtp-Source: AGHT+IESBTlTjDMlUWtPAxUo5FC0/ENmLXQQln/7Kn3vVXuEWwSdcKBU3rHC5T9Lg1PrvScFQlDa X-Received: by 2002:a05:620a:288b:b0:79c:486:43cb with SMTP id af79cd13be357-79c04864bf5mr1056578285a.43.1719558755921; Fri, 28 Jun 2024 00:12:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558755; cv=none; d=google.com; s=arc-20160816; b=JdHNWv93pJb25U6+NjWumQraorjQFshbq9hM7SRYFmwhmPZKCDkLgmx3lTwhA5cZMM tW84yStb8LeRCAZkBL3H/Al1/BzbFhXT3X5iWt0d0N4NE7n+nxih7Sh1yUkm7PlShkse P2FGeGLF8VA/N+ArBYSZVoyncd/hQAAFLjPgaGUSD1PAN94NSM28N5xCDIu22dORYjIa KEX2Q3iXjaW8y8+6tBu3+Qkmjsa76j9wcFbZdis6XcG88yp4KIVNChjJXQ/qFc/bS023 STlmcCu+mZ6kE7xxzQeqEWH+8PjvS8Zc42pjgA4vO4aZCFAjaDKxd9wZhKKxPJD+OD8i c6jA== 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:to:from :dkim-signature; bh=/hWIFWqzHiq8lN1HtcaO+N2xCOE2TizGkz4ySULbbEQ=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=yxcCfxIihlxKsIOoFSu0pa9WSSq065Y0kTwOuuwIBI5kIDr6rX3wgbkGK7pvCjJUvg rUsDmnp9Aauj7tO4GeWruzDRvxsbimo7Ry3KisScyht7TRfrEUun6Jr1MiW2LEMjXqy5 HSYUpJp6t9Dm6Wi8eWH64C79gW5Te6+D/+V914+gUpAQlQr0d9NxhjNcLiaUFi0vlL3X wmvVJZj5i7g/qLVS4Ahm3+Fe1LyHQkATKHc6q6Bqi9w5c8NM86/lRUZW/oalSvGQ4KUY GEPZobhhkRfTCKfu2wagUYR5jcHqHK+1vzb2n2oFnzoD5XoDfi+w1hcLVHNaGfPgSWHy p3+A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qxvvD6OG; 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-79d69308ea8si117926585a.534.2024.06.28.00.12.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:12:35 -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=qxvvD6OG; 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 1sN5kn-0001jy-O1; Fri, 28 Jun 2024 03:10:41 -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 1sN5kk-0001gI-TB for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:38 -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 1sN5kj-0004oi-3y for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:38 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-42564a0d3ceso2332935e9.0 for ; Fri, 28 Jun 2024 00:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558635; x=1720163435; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/hWIFWqzHiq8lN1HtcaO+N2xCOE2TizGkz4ySULbbEQ=; b=qxvvD6OGb/JnLANXV1CdeJKSrpamTn96sQribsoSgJDS4FyUXip7bJ20y6G0J9aAuE TJaBdGtMbBlnmmQyOhYcEn3DqSjYmoizg37Dly4KABLEYSgOzvFJNfPsfiuwC4BT5tDF G9d3EUOMsH1s+BsmD+RRuryV4MFYUkqJvYlc9TT/Qsu3zJUTRY3wEcKQBFR6bzTtVtII kGuPQXrg7Q3y7hxCjPeGUPRKuipucW8S71qTqss7xLGOq80pE/Fe4rD4txuj+yGsI1+5 o+fdNhTY+9KkzXCYM5HPE4TQoU28wj85RGokCnwNv3s0OMDwqPggPHJLW870EtEG1w++ CgsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558635; x=1720163435; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/hWIFWqzHiq8lN1HtcaO+N2xCOE2TizGkz4ySULbbEQ=; b=wyVoqMyoGCTA3KWHfIJ3Yk2CgfpE5z9LMRaL8wI2D4crEIYPg9RnpJyCY0ohN6P27x jd629oALTHlz0Dv8QZMt0dN5uwgj2T+Eon+79HD63MXD6A7YufTbUdAggmg15n9cJ59D vJolHnEyeS4XGzOZy4hv381CRQcRtpcOEMd51hMa1xtZ3exQjEOxZZTxuE/NZRkfPj6z xLUbJTcRqRbzo75hkrmnHf+23UJ5n89Q9gYexqe74nRUBph741qGUCcXh6NZMLRqqs1h zbo8G3j/cJfYR1j1T4gG1vb+0mGKzCPbvA8dsxCZKlmpzAzTDoV2B/fvlxmx0b9RcOPh 0dfQ== X-Gm-Message-State: AOJu0Yy7lucr1FyArUSpfKbQArLQwsT+TFx+pfwRaheaL0UPATeTOkkM qzxfY8T2uoPyK9B5y8gIfwleHB5Bup9IjWCsRvwVR8Xf2758B50rwl+P6RONsF9U3io3xVca5Fa S4a4= X-Received: by 2002:a05:600c:4f4b:b0:421:1dde:cb5a with SMTP id 5b1f17b1804b1-4248cc66ad1mr99631135e9.35.1719558635518; Fri, 28 Jun 2024 00:10:35 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09aa32sm21717835e9.34.2024.06.28.00.10.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:10:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 85/98] hw/sd/sdcard: Add emmc_cmd_SET_RELATIVE_ADDR() handler Date: Fri, 28 Jun 2024 09:02:01 +0200 Message-ID: <20240628070216.92609-86-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 9a2bfeaab6..c6e5c93acb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1220,6 +1220,20 @@ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) } } +static sd_rsp_type_t emmc_cmd_SET_RELATIVE_ADDR(SDState *sd, SDRequest req) +{ + switch (sd->state) { + case sd_identification_state: + case sd_standby_state: + sd->state = sd_standby_state; + sd_set_rca(sd, req.arg >> 16); + return sd_r1; + + default: + return sd_invalid_state_for_cmd(sd, req); + } +} + /* CMD6 */ static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState *sd, SDRequest req) { @@ -2385,6 +2399,7 @@ static const SDProto sd_proto_emmc = { .cmd = { [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [3] = {0, sd_ac, "SET_RELATIVE_ADDR", emmc_cmd_SET_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, From patchwork Fri Jun 28 07:02:02 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: 808241 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226669wrr; Fri, 28 Jun 2024 00:19:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXwkIycFT4ybIknQKx26GNpMeQHwThYimn1y55ispsKpKDca2olQIgmMI5VB2Fixwfc7A5XpS1HMWH1giIICpZ5 X-Google-Smtp-Source: AGHT+IEt7ZRCjpuV1fyGbSgtVs0BeGcISGSYBUuvrB5QofWeIoYCz4FUSjt6khL+SrgvmpuSKwVt X-Received: by 2002:a05:620a:430d:b0:792:c2e7:6b41 with SMTP id af79cd13be357-79be6d47712mr1834347785a.22.1719559183538; Fri, 28 Jun 2024 00:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559183; cv=none; d=google.com; s=arc-20160816; b=Fo65+vsJLoGY5gcEzBTQ0yXL39dLl4HMEX0c962JXdrabXEzYa8mkxcL4I5yf+/YCQ Mdf1hNrzDVD9neIkjFiLGCMTZH6H3ftXtFGjyzn3s8opAmujPo8MAfazE/fESDnCOXIF 2ebCMTL2oJNhtJoDTefO/grIIxvuDRjlCm2oSF5onrgDpGLakUtSVnilQWu46MSEcw+l nuv6M5HE0mU4Ew8LWG825lPX5fdsPQp93zjUVoaTlbOlgGxkNDFfDvT1rjZ2V+y+seLY hQ8WtKSPjI9G4BoQxQ5pT6vzEST0Vvg6GBAQbSvRktA+Z9mNlijtvFtLO0hXUfeOIzL6 pM9g== 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:to:from :dkim-signature; bh=z9Lv5oRHhagfJkOeTGJdPKagMg6fgJmQOzE+waR1EWA=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=JDjVg0azVFoFIPHgJAKf1y8ah958xqRZdTYnZm/zKu/1FuKZheh6PWU4FGS9ChPgik YVBy5LkDhrrqSmiyVAHmgZcUHmvfPLK/tAJ2CRypRstfoi9vV8LH/kBL41BZMvj2jnkV Rl/0f5Me8QQLOEZExdTVB7dE816IwKk9dI11N8+KF+TazhNA0mDxXUJZ10b5XSm506on YLBzwOQ1j3Caq4z2AJuUsnt104UMNm25jG5YqHZqVhjd7L42StVFccZMbX5hn+TnWJWe Mw/hJ1Loa1Ezjh204H/hODzc82gF7MgO/smkKkC21ZZrEPIvFx3JBE4HsYxo+4dh2jmE VYaA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T98JedF6; 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-79d69260ddcsi124604085a.37.2024.06.28.00.19.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:19: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=T98JedF6; 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 1sN5ks-0001ra-Bn; Fri, 28 Jun 2024 03:10:46 -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 1sN5kq-0001oC-BF for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:44 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5ko-0004qP-L7 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:43 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-425680b1d3aso1788715e9.2 for ; Fri, 28 Jun 2024 00:10:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558640; x=1720163440; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=z9Lv5oRHhagfJkOeTGJdPKagMg6fgJmQOzE+waR1EWA=; b=T98JedF6nwFPQAHKVNQ+26D8R7WkAIvDVxJpEdBL4Idg2vTwQsCJpMwawmmxNnZxHH YMwsM8+e02MWUvH1kI9l4m7+lSntnX1NVraQzQ0SJR6GCGLgLGyJv3y3z6SfORJHvyCG yzvMlfB6f9BtQ7XAvT86oDVTZ0SPfJl0Q2XBs7pkP5M95z0mJm5PPOO3yxh5L+4ePM6Y n7FNd45i77zsqePHYzRNQlVyk9S/kW++Pz331pkBaEYL6ldyFqlXORV6exPHOYao7v0p aULwE15PUXzLWffk0jcd5TKqLduhsE9KXj++GGzlotggdDdt4Xp5ddJXPe/sWFCQRMW6 rd1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558640; x=1720163440; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z9Lv5oRHhagfJkOeTGJdPKagMg6fgJmQOzE+waR1EWA=; b=gWGxqyxACSWK6cpCPMosEGGDFe4oxC2AXOjn80o8Nk0yD47nUEXyktCx1kUfthUuQU 4xZY37JthHTKzdSEZ+iW+NMPNT7sI3WdwAIrIWrkszYfHU/IjVgYj2DbnxYnrJtVlcD2 KZNwwOpiAryr0VZ1XOFLXjyDwasggSWoupi4N+OPJXtsZRQ+G+pWGEtMFimGih2Umc/1 voJxxkTgiIIx0lGR1vLwgjT+xHEavh8hpiBioa1qT4eoskeTD+DsKXqr6lyQCnDyUVmo 7aJqSGjOw0Vw9Ae1jMBJX98zKtAbxE/aXs36DQxnM/muUBlNrjHf7xrZRvvECds6LorH d0kw== X-Gm-Message-State: AOJu0YxUBylwzXSnxfMlpq0gf8kP3o9lerp+ugFoA4MSIklhvNG5+LZF 0VvxR1lWzMEb0wEIOZoTo3GYEbWOllRV5JlaDA/WOszkLZi8qZZaB1uFHXIyFCZvnUOUB/1M+4o y4hQ= X-Received: by 2002:a05:600c:484f:b0:424:ac60:3a1 with SMTP id 5b1f17b1804b1-424ac6005afmr59414605e9.20.1719558640648; Fri, 28 Jun 2024 00:10:40 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0642acsm21930665e9.25.2024.06.28.00.10.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:10:40 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [RFC PATCH v42 86/98] hw/sd/sdcard: Add emmc_cmd_SEND_OP_COND handler (CMD1) Date: Fri, 28 Jun 2024 09:02:02 +0200 Message-ID: <20240628070216.92609-87-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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 From: Sai Pavan Boddu Add support to Power up the card and send response r3 in case of MMC. Signed-off-by: Sai Pavan Boddu Signed-off-by: Edgar E. Iglesias Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index c6e5c93acb..2dc0209482 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1190,6 +1190,12 @@ static sd_rsp_type_t spi_cmd_SEND_OP_COND(SDState *sd, SDRequest req) return sd_r1; } +static sd_rsp_type_t emmc_cmd_SEND_OP_COND(SDState *sd, SDRequest req) +{ + sd_ocr_powerup(sd); + return sd->state == sd_idle_state ? sd_r3 : sd_r0; +} + /* CMD2 */ static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req) { @@ -2398,6 +2404,7 @@ static const SDProto sd_proto_emmc = { .name = "eMMC", .cmd = { [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [1] = {0, sd_bcr, "SEND_OP_COND", emmc_cmd_SEND_OP_COND}, [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, [3] = {0, sd_ac, "SET_RELATIVE_ADDR", emmc_cmd_SET_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, From patchwork Fri Jun 28 07:02:03 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: 808231 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226291wrr; Fri, 28 Jun 2024 00:18:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWB/krm4ofQxvxHkeAfLItXKEkkMNrD4KGPhTMr+huywEKjAKQY6UciH42J3VYo3kPftkwaKZ+15tn8TvnmvYUR X-Google-Smtp-Source: AGHT+IEL5NjGQOiUtpLPUrzatoMSQmw8pF40oEJ6VOIohByrxx1ylJalzZRjCrfZHABwtvG/hpkX X-Received: by 2002:a05:6102:5fc:b0:48f:147f:c022 with SMTP id ada2fe7eead31-48f4ef4c9a6mr14658505137.4.1719559107935; Fri, 28 Jun 2024 00:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559107; cv=none; d=google.com; s=arc-20160816; b=eHjbYQZaVqfwew5FDjLuy97DJv3zphgqgO721QARntcDx7BV0Q8YpjfELH0rm3CkaW 3a1KjxSvDLVi0v80yv8FvlNF6FvBHDh2bdGL7bY46JH49klXv1J/CWyKRy8ukJLD4+wp K/KOVLH2SbzY1rFogMIRyzfiE54DBpmM687Ut0POC6UAPEeEsSCqJjj+Rq5EjAU/24wv L42N4SWZw71QFCAk7xutKQw2Mc/7DQzAo8nrZ8RhaTAhAmpzoTbAePS5aD+xee/79KvV IvE96goXL5FWCJzxQZ2DyrXzCZFMuSIEEJzAgM6VFHPDXfAK3rkDztu/9U4LvCrsIKcp 9CPw== 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:to:from :dkim-signature; bh=tQQUBf2F5gPlbKVK01VAnUB30JlRnWbK2EOrpmfwvjQ=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=FECCn2YJkl8KswFpo4aHE8q750zC8C7vgMJwjQfx4HfxB4Ht7SRw1VlZgmF16MMBiX PXWy9M1dwrN/+U7qJ8z8WpdFh+1rOG480fXvx3BTuc34eJWi99qmusYRZ5kyHB4ni9rb B4w/xQY5f4Yd1I+dcT53Vr6Xys7U80VDa8m2CTqsnjnwGigElLQa+bdfku35qEAZH8YQ t5LykyStEELce/3/WN4RBNyoj97fO7nhR0H7ev63yFLupnSpnY4NLdehVu/Ez69/R35C EqXFhIGMpGlhtPTcm62uO4l0U5atD1C4tz1hehhci0wQoG+GLgCdSra+/B79J5V9vF5i I3fg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p61dGOnn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e5ea5e0si14017936d6.319.2024.06.28.00.18.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:18:27 -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=p61dGOnn; 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 1sN5kx-0001yC-49; Fri, 28 Jun 2024 03:10:51 -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 1sN5kv-0001vg-8M for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:49 -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 1sN5kt-0004qg-Fe for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:48 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-42561c16ffeso2634965e9.3 for ; Fri, 28 Jun 2024 00:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558646; x=1720163446; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=tQQUBf2F5gPlbKVK01VAnUB30JlRnWbK2EOrpmfwvjQ=; b=p61dGOnnnzVL+prLyzdv7hPaL7+sumEbP9wERl+KilYBSRd+54EX2cLWg3TPlxlBRK uu4e4naZb4JPgEcCyy7fTMVJTuSZL889XM1G/GjaxitYOS+aTTi+X/jAeCWZYLXNGaAV xeYfbhX7qpdM1qz+2AKtuIXr2TPa4b+kuoorZruO6wJpZBJH1BqvscSWWSiuLxUBt3+p XYaSAT4vNd+F2aJiemZsHA5cG1N3MylWg6kIOD5EIw9wyhpfne/UJW5J498zMsoArXeB fqr+B13xgwGETAQM0BMCScE+sUfXyduJjB5ecNIQdHV8UU5tOaZFCbQYToLkayxfMlB8 2YZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558646; x=1720163446; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tQQUBf2F5gPlbKVK01VAnUB30JlRnWbK2EOrpmfwvjQ=; b=BIY8pS2jMLrS/mRnwxfWyBnwBrvkmcM9qiXK+roRad3eHukzO+a+uAUxpUd99V3AfZ +ssMh7FTaNuGvjxbHL8VEPiUKLmf7wxofcSeosdgoXv/RaWrf04OMaQWFmAJicd2L2M8 2nr2eeSyoe6t8Sge069dIhmIOFXcTkb8uvd/lKzqPIV4x0xI2QAL2toqHNrV/LIj4tuI xVmLZslYmyFXz86FsVsmyU7ED/Zo0G9CIMcVJBHtxXcDBhr7XO+N5UdvP6nkveJmsTpH pBAzXpOBfTgouTHJFKYI1O3ZmN9ZCu5juOovvTaPgbl/6taevh6501z6II4NdUaBXRDC NvJQ== X-Gm-Message-State: AOJu0YxLCq0cZCWnbSVO+7b3XP4HmTWXlUO7QCCzPMsLI18eyeiO9Lcv rxoiBB9Q77443lAJGDWYbQFCWBacS+dEY6gCfU70J8rxbuzgZjncFyy7AAby/B8BMaT9zvPbcju cSNc= X-Received: by 2002:a05:600c:17d7:b0:424:a49a:ff0a with SMTP id 5b1f17b1804b1-424a49affc2mr70916865e9.15.1719558645706; Fri, 28 Jun 2024 00:10:45 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09a94csm21336575e9.33.2024.06.28.00.10.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:10:45 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 87/98] hw/sd/sdcard: Fix SET_BLOCK_COUNT command argument on eMMC (CMD23) Date: Fri, 28 Jun 2024 09:02:03 +0200 Message-ID: <20240628070216.92609-88-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 From: Cédric Le Goater The number of blocks is defined in the lower bits [15:0]. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2dc0209482..7c6f5ccc72 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -171,12 +171,18 @@ struct SDState { static void sd_realize(DeviceState *dev, Error **errp); static const SDProto sd_proto_spi; +static const SDProto sd_proto_emmc; static bool sd_is_spi(SDState *sd) { return sd->proto == &sd_proto_spi; } +static bool sd_is_emmc(SDState *sd) +{ + return sd->proto == &sd_proto_emmc; +} + static const char *sd_version_str(enum SDPhySpecificationVersion version) { static const char *sdphy_version[] = { @@ -1479,6 +1485,9 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) } sd->multi_blk_cnt = req.arg; + if (sd_is_emmc(sd)) { + sd->multi_blk_cnt &= 0xffff; + } trace_sdcard_set_block_count(sd->multi_blk_cnt); return sd_r1; From patchwork Fri Jun 28 07:02:04 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: 808200 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224541wrr; Fri, 28 Jun 2024 00:12:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU2gNW2zgr6Fjlod4zGlsQJ/Y/PqDGpDvju6P10KxsRGTFhQkO4w0CdVvl+q4/BWAW80orApGRL9kHvj+Q0jOfo X-Google-Smtp-Source: AGHT+IF96t6sygpCu6SE2YAoWH90WRhVf379a4hSCfHiR2YwadoZBLIjPIYtiit+KbG1690YBV/y X-Received: by 2002:a05:6214:4215:b0:6b0:75ad:a61e with SMTP id 6a1803df08f44-6b5409c363emr164975626d6.25.1719558756039; Fri, 28 Jun 2024 00:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558756; cv=none; d=google.com; s=arc-20160816; b=wuCvI0Zb/8mAkAK9c9kqI9jH96nuiJTk0QgFxWohyQ6vcmVU0kP03vEngUrOSCrIl8 L8HRSkhmsIujgI1wVUTqi3PzfAuzauduog1PWmlWKlsLrQ0mbVekazNLfyCfbfaEhNRf QkfQ8064utEgQczjdVzgRKtYdxVPH5/+bv6lmVNhr5JDUNBR2VDzrYRBmLxLcO00o7FK zFLSe8XoxzL4m/jT6zrYBXnGQMhEJHAJ8SY/Ct0wPFgYQMg4dhaYYO4mQ5KhLsZ48aUD AtrqHqn20+3U58uJz1na3wZyt5edScJm0FXSEbAPtvhHe4rjlkFakM6LRB2GPK2mcyzN 9rCQ== 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:to:from :dkim-signature; bh=CppPyHBGnGyh+KeMhLUUfKK62hbBIjgp+PC1jB0KmHY=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=wtIBGIrCQd05EiDYm+/TzN2sNZByHEdRETEdvUO6LbKaYxK1eB8Z6ySpBXrgZj2MDP BKqaXavQY6I6RvnoZAjqlsfsiq89OfsJOojzseLkdRGeVKC4zR8/ked0vTkDmN3cz8WN IMxn49evINP7ZwH97FAk46G8uIVCQYO261ZMhdXU/2nZs4sPebw5JHBnvDpoBGOEsbue NkhbxRxBd5OBrJqnZawBkoq6UKXcP3Bpv+VsXAjwFvmzDKxzxE5Z8upBpTpIQ9Ecuv6l wR5/I0309EJTlMz6qmHpfvYr7iXw+S8XlQlCPvqE1Jw3gm70gwUYaoybQS83YoLqzqnM CzEQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PVZQAHVs; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e625c77si13886136d6.605.2024.06.28.00.12.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:12:36 -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=PVZQAHVs; 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 1sN5l4-00027F-Rr; Fri, 28 Jun 2024 03:10:58 -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 1sN5l0-00023K-QR for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:55 -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 1sN5ky-0004rC-Qg for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:54 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-421f4d1c057so2222885e9.3 for ; Fri, 28 Jun 2024 00:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558651; x=1720163451; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=CppPyHBGnGyh+KeMhLUUfKK62hbBIjgp+PC1jB0KmHY=; b=PVZQAHVsrg0+QA2EhMrTnLRi30TJfH1Ej8R3KDr2PF6LPgChUk8UpLARO21EOPHe4v ehAgji34leJqfUg8HW0btwRwOsoIMPQZaKOesjHRA1mUBrIbe9ruwiU6kJe9xOrPosrK hbV4d4+nkuk8BxXMA9TdVLO6JrhASsMJV6z2t4vMxe0auNWUOh6/gr2BV8Rtq9eFP10j 13dOkkoWiEt/L07cqUD+kuNjttaj5YGVoq89+uMeDyhmjB0wavj1f0MO4MJ+K9TbAxte +00IOw3taO1kQ+47fPdwGXhqRf/GVEmYVA+5VriW9yiiDoO4rjtXOOsZWCaujaG/hhV5 +ULg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558651; x=1720163451; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CppPyHBGnGyh+KeMhLUUfKK62hbBIjgp+PC1jB0KmHY=; b=wkZ1jh8FX3J72seVjgbjAhVLn7IPKYhM3NeMm0PZsRKOL6RPXfQ9Z8pwkHyGJ6vXRy dZyEJw8iBo9rWxPqAjwsj1B6YA1MPOks36Qbiocky/njCDdgk8FiyIAeJPtAwB3BVmey Tv1Pg8dF526nHh9bVTd7DfOpoxmfc8vRNr+aSXjXgz+AXme8jUhKXmu/Dmbl+vxQkOda f0/v+Lj7j23HrBiW+F21+9lShgMtmNovoV7U99+a6DjuJml8chAsRRgMT0pNBJFWJFCI /+SPZfVK3QWyN27QuzvB7SPb382ybKXcenVXkbuXkyNlrCUpsdCTO2VOf03yZNfg9OwD 1VgQ== X-Gm-Message-State: AOJu0YwRLmDZTgib0TYGPd2Pn4qKB5SCqrWlX4gqatNippUL4vxXPMD3 hUwg3526NQDhATxXCuYNs25bFyq87K1YsM6C9hXDlBieIXQdIKXir+ROKia7p2cw9VY1J18FByQ 0LWE= X-Received: by 2002:a05:600c:3216:b0:424:9f28:22fc with SMTP id 5b1f17b1804b1-4249f2823a4mr69757575e9.2.1719558650733; Fri, 28 Jun 2024 00:10:50 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c17e6sm21500175e9.42.2024.06.28.00.10.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:10:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 88/98] hw/sd/sdcard: Add mmc_cmd_PROGRAM_CID handler (CMD26) Date: Fri, 28 Jun 2024 09:02:04 +0200 Message-ID: <20240628070216.92609-89-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 7c6f5ccc72..0f9bab105e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1520,6 +1520,12 @@ static sd_rsp_type_t sd_cmd_WRITE_SINGLE_BLOCK(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); } +/* CMD26 */ +static sd_rsp_type_t mmc_cmd_PROGRAM_CID(SDState *sd, SDRequest req) +{ + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); +} + /* CMD27 */ static sd_rsp_type_t sd_cmd_PROGRAM_CSD(SDState *sd, SDRequest req) { @@ -1868,9 +1874,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } break; - case 26: /* CMD26: PROGRAM_CID */ - return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); - default: qemu_log_mask(LOG_GUEST_ERROR, "SD: Unknown CMD%i\n", req.cmd); return sd_illegal; @@ -2429,6 +2432,7 @@ static const SDProto sd_proto_emmc = { [19] = {0, sd_adtc, "BUSTEST_W", sd_cmd_unimplemented}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, + [26] = {4, sd_adtc, "PROGRAM_CID", mmc_cmd_PROGRAM_CID}, [27] = {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [28] = {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] = {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, From patchwork Fri Jun 28 07:02:05 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: 808243 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226687wrr; Fri, 28 Jun 2024 00:19:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVNoveEuEZ7AsyfUoygpi3ihTTHfq7r3JgiPHW4gwsbEJKOfk0HOhr7r1qKAox87HXzZEgFwxIpqsB3CcsPXoYa X-Google-Smtp-Source: AGHT+IGMBLrurdGFjXPKJXHxLlRaG34shdOe4sW1ziI7Uer/zmQrgYtEs4FwivW4nc/ZG/MgZmIH X-Received: by 2002:ac8:57c5:0:b0:446:4a66:bf23 with SMTP id d75a77b69052e-4464a66cdd7mr33202231cf.1.1719559188389; Fri, 28 Jun 2024 00:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559188; cv=none; d=google.com; s=arc-20160816; b=rU4nmQgsukyfmdVLaTFK4uZ8bEFbp5SEXrN7BG7JrSTI199Gac/P8VrjfkJIXcfMX9 mzBzaquZPK7CuSYvFOEodHhHXEKl76opUlg+RAyXaJMXxty34GjQfm+6uWrr7eyDk2Nq Te9LIsUFByHs8dtg+yeRelxe5LAmksEfIVIGfgmHyGEkdgPeSVtln+MMb9g/ffHAlj5t U3wB6/MVd1DaaUbW60W9AZaxNZ5UYrV1AEjnmx1anqJHX6YlVyH+MI9E5RxSVB45G4H3 pppV4YuBYvrWXCLWbuW/DcXMOaZoJq7vLE9eLH3RApsh81PMDyAQCAaKE8VecVCA2JnQ dNMQ== 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:to:from :dkim-signature; bh=wa9xIcQNODSrwCgxGYM1DSrbhUURwxNAmEEY/4Qlivk=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=t0WVSzK+c/Xio7tyCexxhl+Z1nN34+h33Cft3qdm50sISHsudHCnSTuQJKAMN8hH/U E1hpPeX/1jkZBvExU199/Ut+l2mKsq6gfj50lhCIhDAxyNFPIy9VDN4/mzDoUGExya88 mSfVATFRhUBQZ1t7gOBP4aJLNCFUKFMD/f1eCcxeGxDerFLMyMuIbj7Wx5akfpbf7a5m ADyIMRoQvove7mGaFLEnQ9TNPZTyzVVq78SYSbli1zvdfKpfksPk9wvlba+oaW2Em9MB unaphbtl0XkGi3DBad8uMCdGt+Tf29vYo98p4iwzchpHegGs2ZOxwXK/dd2sRIIhl68i iEEQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vBFKZg9y; 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-446514a1f18si12722671cf.459.2024.06.28.00.19.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:19:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vBFKZg9y; 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 1sN5l6-0002BC-Qx; Fri, 28 Jun 2024 03:11: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 1sN5l5-00028I-57 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:59 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5l3-0004rL-Ar for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:10:58 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4217c7eb6b4so2651725e9.2 for ; Fri, 28 Jun 2024 00:10:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558656; x=1720163456; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wa9xIcQNODSrwCgxGYM1DSrbhUURwxNAmEEY/4Qlivk=; b=vBFKZg9yWrwn9UklzAlj1ewb5WKrhLJ67KIiLiI0uSUDhOBGMLqbnZoYClxyk0q2np QM+DNdHHd3AqmjBxSPdJnQTUVmVnsedPEhh3RXLpyPCX4k1z6t5RirVzE54W3whFd6A0 WUMxO7jBpON7fZq0i+E4lg+hl2bGQXxmnSwlGEtGRLv33ue/O2j9GwvTPFZVGOMGQXnZ xFW89DkfZHK6irWAFU1WhAgB/edlzcpw456zb46A5mKZqAF4rT0t8I0UKZseI9RaIBX/ c63kfoJ9nY6mei3lOgrdv5d+NTvTaYH0x1Hwzm4Ao/qZEnT4j5gTPQoOkn1WwbJHEflE PIgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558656; x=1720163456; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wa9xIcQNODSrwCgxGYM1DSrbhUURwxNAmEEY/4Qlivk=; b=L3Cbu0g2ljWC201SAdzKk2vAtmmsN6jsZhJKAj3UfG68J1ky4woa9M8/2ZaWdRgc+T +oHPkqM6IRd0hLoFAXfuDRik8pJBen6YOjEdr2zh98I2H4xkZOWRduIFRQsOEl5p0WMi zSTo0mLpYBjNPy6qSk2gcRo4Vk9n7v5+f80CyEKrXedS5a9WkfqxuXVBPsCQR5UO6mNn WManyVdSQ/toAMZUwrGJ09YmXlIENebxNk+IuIrrpW0Deoq0iM17ODPa4UrNfFLdIUcz 3yGqPOcMhuuQ4CdLOBwv7hgYkjuFnEbqXWxWTsCP4AvWkxR6DtigbdzbQ/qsr5/KMu22 mFOw== X-Gm-Message-State: AOJu0YyZBBl5E5qDqYjkQuRMknCeFqJGJ9yBUdwinqD8fQW4TAqulqq6 adP4+ozCcAqJxksTzj641yF3fr3XZPiuqXd/ot9wqpTZWYDIWTsI40T7ejhbheVn6evKawxH7FJ 0KrY= X-Received: by 2002:a05:6000:8f:b0:362:d382:2569 with SMTP id ffacd0b85a97d-366e95d7df8mr9578972f8f.44.1719558655726; Fri, 28 Jun 2024 00:10:55 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0d9286sm1343699f8f.35.2024.06.28.00.10.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:10:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 89/98] hw/sd/sdcard: Implement eMMC sleep state (CMD5) Date: Fri, 28 Jun 2024 09:02:05 +0200 Message-ID: <20240628070216.92609-90-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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 From: Luc Michel The JEDEC standards specifies a sleep state where the eMMC won't answer any command appart from RESET and WAKEUP and go to low power state. Implement this state and the corresponding command number 5. Signed-off-by: Luc Michel Signed-off-by: Francisco Iglesias Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- hw/sd/sd.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0f9bab105e..bd77853419 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1182,8 +1182,19 @@ static sd_rsp_type_t sd_cmd_to_sendingdata(SDState *sd, SDRequest req, /* CMD0 */ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) { - sd->state = sd_idle_state; - sd_reset(DEVICE(sd)); + if (sd->state == sd_sleep_state) { + switch (req.arg) { + case 0x00000000: + case 0xf0f0f0f0: + break; + default: + return sd_r0; + } + } + if (sd->state != sd_inactive_state) { + sd->state = sd_idle_state; + sd_reset(DEVICE(sd)); + } return sd_is_spi(sd) ? sd_r1 : sd_r0; } @@ -1246,6 +1257,30 @@ static sd_rsp_type_t emmc_cmd_SET_RELATIVE_ADDR(SDState *sd, SDRequest req) } } +/* CMD5 */ +static sd_rsp_type_t emmc_cmd_sleep_awake(SDState *sd, SDRequest req) +{ + bool do_sleep = extract32(req.arg, 15, 1); + + switch (sd->state) { + case sd_sleep_state: + if (!do_sleep) { + /* Awake */ + sd->state = sd_standby_state; + } + return sd_r1b; + + case sd_standby_state: + if (do_sleep) { + sd->state = sd_sleep_state; + } + return sd_r1b; + + default: + return sd_invalid_state_for_cmd(sd, req); + } +} + /* CMD6 */ static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState *sd, SDRequest req) { @@ -1648,6 +1683,7 @@ static sd_rsp_type_t sd_cmd_APP_CMD(SDState *sd, SDRequest req) case sd_ready_state: case sd_identification_state: case sd_inactive_state: + case sd_sleep_state: return sd_invalid_state_for_cmd(sd, req); case sd_idle_state: if (!sd_is_spi(sd) && sd_req_get_rca(sd, req) != 0x0000) { @@ -1969,6 +2005,12 @@ int sd_do_command(SDState *sd, SDRequest *req, req->cmd &= 0x3f; } + if (sd->state == sd_sleep_state && req->cmd) { + qemu_log_mask(LOG_GUEST_ERROR, "SD: Card is sleeping\n"); + rtype = sd_r0; + goto send_response; + } + if (sd->card_status & CARD_IS_LOCKED) { if (!cmd_valid_while_locked(sd, req->cmd)) { sd->card_status |= ILLEGAL_COMMAND; @@ -2420,6 +2462,7 @@ static const SDProto sd_proto_emmc = { [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, [3] = {0, sd_ac, "SET_RELATIVE_ADDR", emmc_cmd_SET_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, + [5] = {0, sd_ac, "SLEEP/AWAKE", emmc_cmd_sleep_awake}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, From patchwork Fri Jun 28 07:02:06 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: 808227 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226053wrr; Fri, 28 Jun 2024 00:17:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXh3TeDnpLc/th4otnzTxryM6Pz1anJRG8OGlfRayyq923zBYNirYYTqfLc8uqKD1f7tpWgGDUaB62ARGlALWHu X-Google-Smtp-Source: AGHT+IF5t6UMHcmB+dIQW7vUM8tU4UBWDJxyZZwdUzFvWJsLyr5i1WtIBGd4KYDU+p9f9F6uDLug X-Received: by 2002:a05:620a:8128:b0:79c:11e5:52d0 with SMTP id af79cd13be357-79d6ba69acfmr110738085a.18.1719559062136; Fri, 28 Jun 2024 00:17:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559062; cv=none; d=google.com; s=arc-20160816; b=qIOQIfsxkb69fK3+v3H0Xenu5FO21UFD4b7/m6JUBj4yslRySVZeMO7dPSOwqOPPDC dHL1jsVVIZ/qf6cwj3VSWQpgQtRKSp/I0lsP883BerZkr1BgKz+bARTM66mpElLCzzfI G7zyYzNj5BYI6GlRgN/0D6CT858BumT9lP4dnRb4ojErM//bBe8U14Ca113XBdOemS04 zqtWpSAB0POCf7i+sBWkJ8j9sN6z3PSrbNTuwp8MIdWkEEQib2Ia5U4vw4vAc5c9OUe/ ozk5fXaEK7dq54W/rBAzke1+9uZ4Q32AUr5phpKYFvJ29Tw06YXWIxa+bfk8oqaOK7IJ vqkA== 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:to:from :dkim-signature; bh=v3emiqbeR1uOJll/QBrY7vV5cW8ivGXHg4omZJGkoiU=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=L8MA+ufMc5uHeV/yyNYJh1cY2qGK0c2YzF/W+e1tW6U9xzCuZEyj/v4SYRuyXMwSm2 IRTLHqBy0ImKCsb5bjzCSl/VfThQRwvRIb6gnP9iVUJpkCWcOhDBW0PNOLvCgWMmSaFv qm+8vvFsgVvib/ZAD0LgTWXemA+/vKtPmxH14DlgdXFfrZx7+5EWN1ToPrxLfe7anri0 dCgF7Uqut1iJTTM7lfWpKkFeL1hE7THaMAg1ckQNaxyLUybUDbYQDP152aUQ9y0jIyFW pcb2SBxhUP3Obj6g1crdfQLBlJTSlDC3EFY9fR1LMRMJXTVa7KHEpzAuMAop+fYJRA+A Wn2g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ObJbkQV7; 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-79d692f0851si121848485a.342.2024.06.28.00.17.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:17:42 -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=ObJbkQV7; 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 1sN5lD-0002Lf-8e; Fri, 28 Jun 2024 03:11:07 -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 1sN5lA-0002Hq-5s for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:04 -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 1sN5l8-0004rk-Es for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:03 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42564316479so2215605e9.2 for ; Fri, 28 Jun 2024 00:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558661; x=1720163461; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=v3emiqbeR1uOJll/QBrY7vV5cW8ivGXHg4omZJGkoiU=; b=ObJbkQV71TS2FhfZcmI1Yk0BNETUwetZb/2L81g/Q2LKHYcaK+N0Sw8VTNwB+TxGX4 0gUzFHRx+9Hbxro7qNjfFrExstHSZJaQBr2D0n7dPe31TC3B4RnCLBHQbp75Zj5dpt4Y T1SD/iRlzdRr3z+EXyVApIPzkbE6NSTqMCUgMsvgxoTn+xflxyRkAlB/jzNSV3waVW71 /6Yp3fhEnWdh+09rxkszv8+AlKjLnsfQvh+8n2Y1G4Qfu6MQYZvTufiuUu191blWiJIk /f4hTU+SNwYh1XV4npezWGSS4PuKCXZWazdoaQlS56+x6bwPc7ON2A+2l4H7TF25eaN/ dhVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558661; x=1720163461; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v3emiqbeR1uOJll/QBrY7vV5cW8ivGXHg4omZJGkoiU=; b=QDSXxsUnG68/s2HDqs4aUwb2rR5m2h/MA+AaaB1VKKDlbR5LO8u2rgDGOGsJ24n8PB 1ks2iePQ5Zi6B97VeaNJeh2PYUSZnDQP+SpKhzGzzWC8IdUpugnZJ/Gd2TaKtvzrUHTT x8MrLHTVlFZrIWm6DGcvsycrqUetzi/3YUrkhCyUXQQBWZbAWni0XYV8GE91bUVlyE7t PB0tVAs2YJnvY/XN16XmCXYGsdBeVZ+K+svL0vr3csXbhpwbm3BONcO17edMQ3e+lDY4 xwuKcHFAGH+qmhEIGh7xnf9uNEqPY1wn8G9O24kag4Bj1mpAp+lCV1bDEQGTItSr85Ou /Wtg== X-Gm-Message-State: AOJu0YxbQufnl8CAzgmpIomRyGPzCFV4W0kSwZ00ve9CAvi9yav35xmp br7f5bausspQfIDbtCu00b4UMu1DtAAmGO1sX0n71md75tU+ZbtTKJMtNkbXh8cMwVQLfPdXD/o IcyU= X-Received: by 2002:adf:9785:0:b0:360:74b3:260f with SMTP id ffacd0b85a97d-366e948fa74mr9341702f8f.21.1719558660788; Fri, 28 Jun 2024 00:11:00 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd4a1sm1345327f8f.23.2024.06.28.00.10.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:11:00 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [RFC PATCH v42 90/98] hw/sd/sdcard: Add experimental 'x-aspeed-emmc-kludge' property Date: Fri, 28 Jun 2024 09:02:06 +0200 Message-ID: <20240628070216.92609-91-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 When booting U-boot/Linux on Aspeed boards via eMMC, some commands don't behave as expected from the spec. Add the 'x-aspeed-emmc-kludge' property to allow non standard uses until we figure out the reasons. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bd77853419..dc692fe1fa 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -127,6 +127,7 @@ struct SDState { uint8_t spec_version; BlockBackend *blk; + bool aspeed_emmc_kludge; const SDProto *proto; @@ -2567,6 +2568,8 @@ static Property sd_properties[] = { DEFINE_PROP_UINT8("spec_version", SDState, spec_version, SD_PHY_SPECv3_01_VERS), DEFINE_PROP_DRIVE("drive", SDState, blk), + DEFINE_PROP_BOOL("x-aspeed-emmc-kludge", SDState, + aspeed_emmc_kludge, false), /* We do not model the chip select pin, so allow the board to select * whether card should be in SSI or MMC/SD mode. It is also up to the * board to ensure that ssi transfers only occur when the chip select From patchwork Fri Jun 28 07:02:07 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: 808244 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226959wrr; Fri, 28 Jun 2024 00:20:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWEnpoDv8MqQq0DJLUEsJLFqVRW2+I7MBXifK4TjfXKe/UQ1y4a+s6iQAtwhvYx/DHUk4xKGapna9yDXJleT+pd X-Google-Smtp-Source: AGHT+IG/w7SVoYCk00fSn5iv2hMrEMoUMIChdV/86C3zw5x34Y5sgrKNo86ox4Gc/a5i05Uhj+Bb X-Received: by 2002:a05:620a:40d0:b0:79d:55f7:2536 with SMTP id af79cd13be357-79d55f74581mr690099585a.71.1719559235344; Fri, 28 Jun 2024 00:20:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559235; cv=none; d=google.com; s=arc-20160816; b=AkK02/YzsR4+aTubxUNwW99rBeXKpEc05L5hdmhzXXmaL8IK0H5ejywSlUQnvDxYHL 1G+0AnVRIOFzMtwF7hkPty360CStVh6+1qX6bZw5MlKszGYkOb2jsjbWxK+NFXp+AYeS V5f3jpbKiqLSp+xpL+Pdf0MHV7ZX+2Wq/IZyqIOJ68auUwk7dqEVwPotJLaINF63RnM0 GZJe4r9K1NOkmmXC0j+i/pjdvdhChVqevZ40I4NpOEkMNWocOFFBLubNqhsRXIbkm/AB v7rxkDR1b85Hoei35rOq26X1KuASsbTjAXPKE1/lGPwaa3SMo3uCwVJ0E0zdKv6X8p7w cdPg== 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:to:from :dkim-signature; bh=rhSRW4lnt4/3qEqJkcY7/by3NHero7LaTXmV3ByZHOM=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=EfIsOVanWHh6nw7BTHMVl2HFmG51bQHL9MbAmpi+DADzEf2o6SvG7W3tW6zZ0pnxx+ TcR6oOE8uVWcE8tUdLF1b6fuKECTt8VU2mlh37w09LuTtf5luOGrCkJJ5eYqI/vEWsMe uvciPhHnVHsJtLYihxvzCiDVBNc9ZkTvaD3RxNnrVASoP9fqy4WfDRmpE09PVBrk9KeN IWWAQP3LYDJlQ7PRRtg/c9zsbHuvvaylo/OyY85LfZxf4D/k6tmTGeHiZDHMKlXquZ4i i+sx5+eeV0O2vCCauuDYtfQkJa1zTClC+b30UsuipK68vaUkheBDDiw4FirYn9TaIDKs hewA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ERj0+eIa; 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-79d69262c62si125759285a.52.2024.06.28.00.20.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:20:35 -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=ERj0+eIa; 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 1sN5lH-0002UW-4v; Fri, 28 Jun 2024 03:11:11 -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 1sN5lF-0002Rk-D7 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:09 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5lD-0004s5-LZ for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:09 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42565cdf99cso3145635e9.3 for ; Fri, 28 Jun 2024 00:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558666; x=1720163466; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=rhSRW4lnt4/3qEqJkcY7/by3NHero7LaTXmV3ByZHOM=; b=ERj0+eIaKqiVzbHELASp0pWif0JkmmljjxNJxVxoGLNMIRQhcKN2VVWyz/XO0Gp6o5 hkaVo24tWV/Bnb2b0R6ltRNYYAwO+gV7QtkgjuSKOM3kdQXEEdJFvVbxnJONxFXXFFBh tLAqLHYHmjt7F1uZYduaNeGOyuAuM7+7f2EdJlOcdBW8YywHxctUKXVPUKV3lRvTC7/R Mm/UcHLTfm1fhX236Jfwyhx4u7gcI7B8ACrKJvaS/G/MUdBX3KNHVEGXR8z5xaU+VsjI FgTiyrmVlTgpyNQUzEUok6DK8kRJYPfx2QhyyWNb4DJ8rnLNgXcwQGR3obV6Z/R2111P hiKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558666; x=1720163466; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rhSRW4lnt4/3qEqJkcY7/by3NHero7LaTXmV3ByZHOM=; b=oDjeX6IBZtZnMtS/5UkJP6skgXTQHCNxbgKgcRBmQLHAQVVDQkvASLYesy81OE/VQ3 kgyWNKq4qHn8qVV9oQ+cVBnQYiENVjEWHBZ/lHs7MmJYSYTn3MBHc9OB3z9V4pq65WWC TU1MS07FSFdX85VfzQ0TrLoGwLeS/mNHvA7rtqxpCx3fObRJXOGP95JWzkM9EMmiaYTH I+8LluYRTpkCeduCE/QuhxHw6CwLgu5vSGER6XuhSfNH1yu3dYxiYkvrL/3Wf7aBHFAP /2l06lat28cskzC+q4L5bSIMz/1hpau0B44bh3rljLbdN2Bpn2312cwaXnMsYGVKB17z /ejg== X-Gm-Message-State: AOJu0YwGyda1rZpbScziKjhckXLPEb35BHeH4Sd+TYI1hAdeC5+BiJso jJr7R2UnjvG+7UQpeLjfC8fXj3gupszzcSMJIkdyUbsgis27/32LIN3p9FWStY+V1gLeIZpe/lD Odus= X-Received: by 2002:a05:600c:68cc:b0:425:5eec:bb84 with SMTP id 5b1f17b1804b1-4255eecc517mr65763395e9.36.1719558665800; Fri, 28 Jun 2024 00:11:05 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af557fesm22071075e9.11.2024.06.28.00.11.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:11:05 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [RFC PATCH v42 91/98] hw/sd/sdcard: Adapt sd_cmd_ALL_SEND_CID handler for eMMC (CMD2) Date: Fri, 28 Jun 2024 09:02:07 +0200 Message-ID: <20240628070216.92609-92-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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 From: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Cédric Le Goater [PMD: Use aspeed_emmc_kludge] Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index dc692fe1fa..f875fcd741 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1218,7 +1218,13 @@ static sd_rsp_type_t emmc_cmd_SEND_OP_COND(SDState *sd, SDRequest req) static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req) { switch (sd->state) { + case sd_idle_state: + if (!sd->aspeed_emmc_kludge) { + return sd_invalid_state_for_cmd(sd, req); + } + /* fall-through */ case sd_ready_state: + /* Bus always won */ sd->state = sd_identification_state; return sd_r2_i; default: From patchwork Fri Jun 28 07:02:08 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: 808228 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226136wrr; Fri, 28 Jun 2024 00:17:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVkJheaD3M3gJwjAX34fMyYv36RmiovO3vFUm/Onli5t7XrBgCTl43RjJA225ov/KNKJ05UBtzG4QkCrderZbaK X-Google-Smtp-Source: AGHT+IHbaqrdDWAbTngSpOG8UIkWEpIbYeJmqi9TJINImfkuyemr3/Ka5XAcbMoLTv/cIMmOMDnS X-Received: by 2002:ad4:5d4c:0:b0:6b5:8fdd:baa6 with SMTP id 6a1803df08f44-6b58fddbc5cmr57427476d6.51.1719559075996; Fri, 28 Jun 2024 00:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559075; cv=none; d=google.com; s=arc-20160816; b=0bc6rTDE9SPPqqrN80Ne2la5FTtqzPWLCl/jSyj4c7q1PUWKt1ZPwiflHeVHgbStDl aTtzizYnmYscm1j7jPHsLVNZRSdyL9CtS/XCtFAdLDZuXWWWcyVLsTkFCgr7bJnnUgBD jRdJHehIZMjDP+4rqnCmMaipkoTIDL7upY8b0/v+fJ0wv7R3ztoi3F+5WOrHhV9hEuOg O60VyKCs0LgNzbNHKEMjCAQ7KLVFAe9fAZ+3F7kYMaQXVI9f/F+llpBjPkDxQG54PwfF 6587uW9syAsD9H89ddbOcfCo42EPxgBmO7131opBp4i6cUd47s6I8JwqveIB50/gVmHN 7DQg== 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:to:from :dkim-signature; bh=ojivM3IaWwWzglQz4g05HwWNW+Y8YVh/DQQ1yO/B8Js=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=Kj0alhpIk13aWTH0oIeh1XWX9D1lNZWcyx1Bb3EZXs8PRGiE65Zk9roPxDbWqb7Jub EtF/xlhqzmz8U1GCOGZBlthCGdd7oTryr7+P3YVhzjN8sHLJzXUtcr/pJybrTUPGffSs bJHywRSb4BYaYQinXnZeiO0Lb8F8jqmFCkuuEetBHT4bhzjwHoq2CJkUet1KxDDMwkgq BiF1OT5atVyd1GYa/89NZBNjYjd653FjhwpxAujH1t3C4sE3lDQxzRlZ0k+trmNAZ65o Be1yEEpklq+sFIOEul4h+qhpTGnE87BT5fndmfPHodbmHlZKbQph7M3E0sszBTBvZVVU SbIg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gRpHobt0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e5f460dsi13796356d6.430.2024.06.28.00.17.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:17:55 -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=gRpHobt0; 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 1sN5lN-0002fi-2f; Fri, 28 Jun 2024 03:11:17 -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 1sN5lK-0002d2-On for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:14 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5lJ-0004sM-03 for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:14 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4256f102e89so1287155e9.0 for ; Fri, 28 Jun 2024 00:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558671; x=1720163471; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ojivM3IaWwWzglQz4g05HwWNW+Y8YVh/DQQ1yO/B8Js=; b=gRpHobt0fg9khKD4RVG24jp6wuVZwOKC6cqlx7qDGRr7NlHfsMugQAzjzK4xAdltID Z9pVrAAp9CmOwKAC3s3rlcrJfQZ56mC9tr7XQEVx6+9RUBA7LhnIa9VIn2+GA34T9KUA lJCPHQGwnn8BMrWeYHCSxA5WcQTqhlmnzXvjjJ+yIfinN68gac29fDb6XQLOd3RFypFP PF2PMfykUG6Wxw46reVioF+6CUH6eZe02WHVlKpL2jBWgazkJz1nLMh4mtQiXfqctS0V e4XmK67an7OklKCcM7IUKNKUaFOPsdc5wzyoXDXTUivejc7IucLK3zBuFNKhomrxjdeC qXxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558671; x=1720163471; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ojivM3IaWwWzglQz4g05HwWNW+Y8YVh/DQQ1yO/B8Js=; b=l3FxAAdlICLLU17Xr/9iLwopo+VF7HqsHFjngIt2NMlIlCpteWhamIWIU6f+/QFqNg gi31bYMQ4NyhUhTKi8Jrm0areQxnKFzvSOeeBwPuS06GhzjHGGyNayirw1GZhzP/UOad 5Yq8CzUoLArYLCFAssWxLPQNFVUjLpDRikzi8mulrf/16vNJkXheogT3ocsJOnOqVYPy eFI6BiibTCWVI+c7lG/8/7gv5lTIgNvG4eWartQWOqNaaJAU+QGoIJlbfWvhcOIcGnDn 2z8jrCWnfEQNtRY5cD8IBdLurRNNdn2sEbT9zodOFgCZ+Yv3ijmDgpTLE3GKX/u8j4jX BhUw== X-Gm-Message-State: AOJu0YwhPPeboc3DH+spektx0RRyCB8dkQWfeJ1cicqN5mS9HGZfv7Q8 GW0PffqiX1UOPORID2UOV1T8zNeRf0yfEsG1Lf/fIfJqBnk7h0xdf4vnQPDUPEZclObcZhBufwm OC1o= X-Received: by 2002:a05:600c:929:b0:425:65c5:79b4 with SMTP id 5b1f17b1804b1-42565c57b9amr28625005e9.26.1719558670999; Fri, 28 Jun 2024 00:11:10 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424a2abcfd0sm62373955e9.1.2024.06.28.00.11.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:11:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [RFC PATCH v42 92/98] hw/sd/sdcard: Adapt sd_cmd_APP_CMD handler for eMMC (CMD55) Date: Fri, 28 Jun 2024 09:02:08 +0200 Message-ID: <20240628070216.92609-93-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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 From: Cédric Le Goater Signed-off-by: Cédric Le Goater [PMD: Use aspeed_emmc_kludge] Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index f875fcd741..82e0b5838f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1693,6 +1693,9 @@ static sd_rsp_type_t sd_cmd_APP_CMD(SDState *sd, SDRequest req) case sd_sleep_state: return sd_invalid_state_for_cmd(sd, req); case sd_idle_state: + if (sd_is_emmc(sd)) { + return sd_invalid_state_for_cmd(sd, req); + } if (!sd_is_spi(sd) && sd_req_get_rca(sd, req) != 0x0000) { qemu_log_mask(LOG_GUEST_ERROR, "SD: illegal RCA 0x%04x for APP_CMD\n", req.cmd); @@ -1707,7 +1710,7 @@ static sd_rsp_type_t sd_cmd_APP_CMD(SDState *sd, SDRequest req) sd->expecting_acmd = true; sd->card_status |= APP_CMD; - return sd_r1; + return sd->aspeed_emmc_kludge ? sd_r0 : sd_r1; } /* CMD56 */ From patchwork Fri Jun 28 07:02:09 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: 808222 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225809wrr; Fri, 28 Jun 2024 00:17:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUqcLVDurT0l9EFC1XkKUV2QJl46SWEXHtrQfp4MyoQGR7uSm8m2YLQZTVmPqDFdOkjawCWNl3CwfK6cdCMtqhh X-Google-Smtp-Source: AGHT+IH+BaD5vHE3/D0SLK8gQnb+Obja01gCOc8eatosytVV0tfOYutJP9WYDctoLVruRKjCXo86 X-Received: by 2002:ac8:5e11:0:b0:444:b2ae:97ac with SMTP id d75a77b69052e-444d6506d6bmr187552501cf.50.1719559019823; Fri, 28 Jun 2024 00:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559019; cv=none; d=google.com; s=arc-20160816; b=RMde5qaBJuUdb7TA2ot7TQ3VRaqYg5SPRduNDhLj9bZCMTndadoNE7FsUVFtNtOOyK RF9nbo+dG7LsOCUfMUAH8gA/lljMJMOxFFIYCcJx1UGCCoAriVj7HgIjdHu+9nnBqFHU FDFXb9ar9AI5ORy9cYW/KimAk2AlJj2eH+kNuDOKpQRSAAZiXo3Qt3XrXIIxt4hznNEI iVS0Qd7UilWZBAZrFoPP7Y3Pdomr5ZUDtbvAODUELuiplBMYprMgM2aGKwWlwazkHfKF QomlaZxwH4xHVu3lpLtW5sZmncnAYJJ9dy9wSQAPs7oAaa1FDOx6pYvX4oyl8+8H7u72 K+JQ== 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:to:from :dkim-signature; bh=O1uKT3cac0wmROcR+mzv/OARkq5bGqfifIlHFoP/L2c=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=rxn95zgqpl8XCw32jIen2izPd97yXRHAr2nXVvq9AKyhaBIP9WP92MMjnQQ/726aAC PhUIOTM8Y1TVI0BXuijRp78dLAaHx/5dm7RgvQQ0BVV2uWaS8q6iPOoM85dv+UwEZamM sC69OMdoSGfeCJoIfljt6DRIrp7BntTqpHHQ0pEUT9dYv77MgbrjdynywEpT5EsEGuGh K6HCLha+6DY5/1GI164pd3pUdClQ8uuRAyL3qigcVu6IixllCfrfPPRP1pJYOVy5+o9A dnz5+Z3QXrr/4PleiBynRAp/RFBzf1OLUsMArdN9QgYH5bjALyShOUrtIAAM3t+Xmnt/ RLlw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IJD8sMiQ; 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-446514a2686si13407571cf.437.2024.06.28.00.16.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:16:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IJD8sMiQ; 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 1sN5lS-00035j-UO; Fri, 28 Jun 2024 03:11:22 -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 1sN5lR-0002wR-9h for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:21 -0400 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5lO-0004t1-Ts for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:20 -0400 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-52cdf2c7454so490009e87.1 for ; Fri, 28 Jun 2024 00:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558676; x=1720163476; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=O1uKT3cac0wmROcR+mzv/OARkq5bGqfifIlHFoP/L2c=; b=IJD8sMiQRu1MiNtdEsXbjGqRKjcnF8jFpxl/icunh4J9BXteDh70FJxODeDInxTnk2 bOgBlrK/ff2rujFjwlAq1gGRJolUjjwt+7bV/DJ9zQ03GmjP6Hi5cWUnnA0Nxlhg4ene BIqxvQUa7ErECigxI6reYFXQBhHvasaWdoUIl/RzTh/ZcuoLov6qP7vDYruK+XbDQe6B G5Y6g3GP3ExMtGV8yK4vkSTgAjW2H+ROLJN+rtHP0muXMs1GADTCC8CFb7Zwcs0h94rU th48orZPSUIj6yB+uziPIzXW65pbNTdoBJfvvMUa2oIjBRXqmGe8Nt1M6PQiKpNsEgww j1Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558676; x=1720163476; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O1uKT3cac0wmROcR+mzv/OARkq5bGqfifIlHFoP/L2c=; b=GWEJ4nLLGvP7HCh8twwXpm51oNTUjLSUep1iMp4KpDtEGBhx72q/AFGsAcy+N059fu SzVxntmOFvsiJqOqAv2FoZqGC7B5ob5zh31QKHf/EyRjLWOEyrT17MKhKcky4LFc7P7g OEKmMpq5mAfniK0KoF3vGymT4BTwybWvzPG+iCMhxjhW4GYjbPD0j+4VEwna012wbKNr h//MIbG0zSdgcg1LEkPGYOzofBFiQgmPWMOb3eBk86uLAHxE27urVzrFRheAsF1DQikn sb+IJXeAY0ZlCpmcyeT5Qf8SoOdNYKxbxe9x7ZFt8/wdXLaFC1K4s+YyTEZzdB06Hrkw SSYw== X-Gm-Message-State: AOJu0Yx/ZxW3EzGtmMsWmcTdoaHvpr8A37YILzVmP2FB5WHQoH8S7bpY AzNK2ZRaFMpfaSVIvbDjXfr3pUGZMiZMXxaifRPcZdjLoYPj5/wqK0kwiKfzK6AtjF1tsa8ETp+ dkZQ= X-Received: by 2002:a05:6512:78e:b0:52c:a20e:4da4 with SMTP id 2adb3069b0e04-52ce185ca1amr11570128e87.57.1719558676598; Fri, 28 Jun 2024 00:11:16 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3cff9sm21738595e9.3.2024.06.28.00.11.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:11:15 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [RFC PATCH v42 93/98] hw/sd/sdcard: Add emmc_cmd_SEND_EXT_CSD handler (CMD8) Date: Fri, 28 Jun 2024 09:02:09 +0200 Message-ID: <20240628070216.92609-94-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::131; envelope-from=philmd@linaro.org; helo=mail-lf1-x131.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 From: Vincent Palatin The parameters mimick a real 4GB eMMC, but it can be set to various sizes. Initially from Vincent Palatin eMMC CSD is similar to SD with an option to refer EXT_CSD for larger devices. Signed-off-by: Vincent Palatin Signed-off-by: Cédric Le Goater Signed-off-by: Sai Pavan Boddu Signed-off-by: Edgar E. Iglesias Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- TODO simplify params, see: https://lore.kernel.org/qemu-devel/54bc25fd-acea-44a3-b696-c261e7e9706d@kaod.org/ --- hw/sd/sd.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 82e0b5838f..0561079eff 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -122,6 +122,7 @@ struct SDState { uint16_t rca; uint32_t card_status; uint8_t sd_status[64]; + uint8_t ext_csd[512]; /* Static properties */ @@ -460,6 +461,82 @@ static const uint8_t sd_csd_rw_mask[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe, }; +static void mmc_set_ext_csd(SDState *sd, uint64_t size) +{ + uint32_t sectcount = size >> HWBLOCK_SHIFT; + + memset(sd->ext_csd, 0, sizeof(sd->ext_csd)); + + sd->ext_csd[EXT_CSD_S_CMD_SET] = 0x1; /* supported command sets */ + sd->ext_csd[EXT_CSD_HPI_FEATURES] = 0x3; /* HPI features */ + sd->ext_csd[EXT_CSD_BKOPS_SUPPORT] = 0x1; /* Background operations */ + sd->ext_csd[241] = 0xA; /* 1st initialization time after partitioning */ + sd->ext_csd[EXT_CSD_TRIM_MULT] = 0x1; /* Trim multiplier */ + sd->ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT] = 0x15; /* Secure feature */ + sd->ext_csd[EXT_CSD_SEC_ERASE_MULT] = 0x96; /* Secure erase support */ + sd->ext_csd[EXT_CSD_SEC_TRIM_MULT] = 0x96; /* Secure TRIM multiplier */ + sd->ext_csd[EXT_CSD_BOOT_INFO] = 0x7; /* Boot information */ + sd->ext_csd[EXT_CSD_BOOT_MULT] = 0x8; /* Boot partition size. 128KB unit */ + sd->ext_csd[EXT_CSD_ACC_SIZE] = 0x6; /* Access size */ + sd->ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] = 0x4; /* HC Erase unit size */ + sd->ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT] = 0x1; /* HC erase timeout */ + sd->ext_csd[EXT_CSD_REL_WR_SEC_C] = 0x1; /* Reliable write sector count */ + sd->ext_csd[EXT_CSD_HC_WP_GRP_SIZE] = 0x4; /* HC write protect group size */ + sd->ext_csd[EXT_CSD_S_C_VCC] = 0x8; /* Sleep current VCC */ + sd->ext_csd[EXT_CSD_S_C_VCCQ] = 0x7; /* Sleep current VCCQ */ + sd->ext_csd[EXT_CSD_S_A_TIMEOUT] = 0x11; /* Sleep/Awake timeout */ + sd->ext_csd[215] = (sectcount >> 24) & 0xff; /* Sector count */ + sd->ext_csd[214] = (sectcount >> 16) & 0xff; /* ... */ + sd->ext_csd[213] = (sectcount >> 8) & 0xff; /* ... */ + sd->ext_csd[EXT_CSD_SEC_CNT] = (sectcount & 0xff); /* ... */ + sd->ext_csd[210] = 0xa; /* Min write perf for 8bit@52Mhz */ + sd->ext_csd[209] = 0xa; /* Min read perf for 8bit@52Mhz */ + sd->ext_csd[208] = 0xa; /* Min write perf for 4bit@52Mhz */ + sd->ext_csd[207] = 0xa; /* Min read perf for 4bit@52Mhz */ + sd->ext_csd[206] = 0xa; /* Min write perf for 4bit@26Mhz */ + sd->ext_csd[205] = 0xa; /* Min read perf for 4bit@26Mhz */ + sd->ext_csd[EXT_CSD_PART_SWITCH_TIME] = 0x1; + sd->ext_csd[EXT_CSD_OUT_OF_INTERRUPT_TIME] = 0x1; + sd->ext_csd[EXT_CSD_CARD_TYPE] = 0x7; + sd->ext_csd[EXT_CSD_STRUCTURE] = 0x2; + sd->ext_csd[EXT_CSD_REV] = 0x5; + sd->ext_csd[EXT_CSD_RPMB_MULT] = 0x1; /* RPMB size */ + sd->ext_csd[EXT_CSD_PARTITION_SUPPORT] = 0x3; + sd->ext_csd[159] = 0x00; /* Max enhanced area size */ + sd->ext_csd[158] = 0x00; /* ... */ + sd->ext_csd[157] = 0xEC; /* ... */ +} + +static void sd_emmc_set_csd(SDState *sd, uint64_t size) +{ + sd->csd[0] = 0xd0; + sd->csd[1] = 0x0f; + sd->csd[2] = 0x00; + sd->csd[3] = 0x32; + sd->csd[4] = 0x0f; + if (size <= 2 * GiB) { + /* use 1k blocks */ + uint32_t csize1k = (size >> (CMULT_SHIFT + 10)) - 1; + sd->csd[5] = 0x5a; + sd->csd[6] = 0x80 | ((csize1k >> 10) & 0xf); + sd->csd[7] = (csize1k >> 2) & 0xff; + } else { /* >= 2GB : size stored in ext CSD, block addressing */ + sd->csd[5] = 0x59; + sd->csd[6] = 0x8f; + sd->csd[7] = 0xff; + sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_CAPACITY, 1); + } + sd->csd[8] = 0xff; + sd->csd[9] = 0xff; + sd->csd[10] = 0xf7; + sd->csd[11] = 0xfe; + sd->csd[12] = 0x49; + sd->csd[13] = 0x10; + sd->csd[14] = 0x00; + sd->csd[15] = (sd_crc7(sd->csd, 15) << 1) | 1; + mmc_set_ext_csd(sd, size); +} + static void sd_set_csd(SDState *sd, uint64_t size) { int hwblock_shift = HWBLOCK_SHIFT; @@ -1364,6 +1441,17 @@ static sd_rsp_type_t sd_cmd_SEND_IF_COND(SDState *sd, SDRequest req) return sd_r7; } +/* CMD8 */ +static sd_rsp_type_t emmc_cmd_SEND_EXT_CSD(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), + sd->ext_csd, sizeof(sd->ext_csd)); +} + /* CMD9 */ static sd_rsp_type_t spi_cmd_SEND_CSD(SDState *sd, SDRequest req) { @@ -2297,6 +2385,7 @@ uint8_t sd_read_byte(SDState *sd) sd->data_offset, sd->data_size, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ + case 8: /* CMD8: SEND_EXT_CSD */ case 9: /* CMD9: SEND_CSD */ case 10: /* CMD10: SEND_CID */ case 13: /* ACMD13: SD_STATUS */ @@ -2474,6 +2563,7 @@ static const SDProto sd_proto_emmc = { [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [5] = {0, sd_ac, "SLEEP/AWAKE", emmc_cmd_sleep_awake}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, + [8] = {0, sd_adtc, "SEND_EXT_CSD", emmc_cmd_SEND_EXT_CSD}, [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, @@ -2649,6 +2739,7 @@ static void emmc_class_init(ObjectClass *klass, void *data) dc->desc = "eMMC"; dc->realize = emmc_realize; sc->proto = &sd_proto_emmc; + sc->set_csd = sd_emmc_set_csd; } static const TypeInfo sd_types[] = { From patchwork Fri Jun 28 07:02:10 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: 808224 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225855wrr; Fri, 28 Jun 2024 00:17:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXnxjvNC2DUMGebZdqU39VNKMcejWbMSGCIg7FDvsAW5t8fuxqYzHUk/IN4Dd/wuXBDH7RKqAOxSK/e4GOToczU X-Google-Smtp-Source: AGHT+IEmvtAzFDkrIry+kK1eP6M8HBE3ya4Z9k1vhzUr3YJGUhwYzpTfqeJ12ViIWkIfWJQ3xuaV X-Received: by 2002:ad4:5aa7:0:b0:6af:7b2e:1868 with SMTP id 6a1803df08f44-6b5a544180emr13563376d6.18.1719559028184; Fri, 28 Jun 2024 00:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559028; cv=none; d=google.com; s=arc-20160816; b=ZNTV+JPdu2qGDS/12pWBBMmipDgekJKQREHjMjDCe75YesvXzbsNYAwfHcdihlT7Zo wq722T52TS90XSWr5B0np00Kn3E6ik/Ut0CA1DPAy80z1C8kpsp5zfrYqAlPM/w2v6lC JhJ6nHhywja0pob1nXZT7yIvNHNoSBLfNaQOE3i35PpxpN2ZuRvGptjVdrkKz3FhEPpF VSBvfU8YIhf7Pkmzo2kEZAfrIfFrJa/rDqyXEgA6IO5KkAPaYoy5U++A9DJA5fGunCc1 U3kFt/7cqR1qZZRFbRA+Gy0B/bqJ3PAvD5HnG1dgD5SLSeHts8ZNo76P8qWy1bURj/Lk yybw== 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:to:from :dkim-signature; bh=SnL/FPFYEQkll60HqwiRh6fnqmVJNFRbyEObo/B5eRw=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=yguH4cqdiy6zdUTXVQRrlUqTrUfQY22P9blyhScbvAn/+tGQcB0g4zmKx/Xz1GnHB8 uzf6Ao3H+45M1NsZZLCjABRvnZnZyFedRo73R9jbfKOht17QBWL2U//nispCNAh137mg GNI0oATCT07GScrLTbMe8gZxDDcgAeU4TW5HIB/mYkKTLcJ+IhWSXMolLjsXSJrgISr4 p0bbeq2l+MipuqxJgx1ihv2A1Wkj+KhH8K7V9WnYmi95YG4SV0VITy4OEV0vAxPGck1C s/CJV+5Cd+oO5xJfwXlHN/agwTl+NMOJteshDaa4lQktWzPvS7u1iftPzB8jHn8FX4W7 pT/g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ujEncbw9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e60b0fcsi13971146d6.511.2024.06.28.00.17.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:17:08 -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=ujEncbw9; 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 1sN5lc-0003hD-EZ; Fri, 28 Jun 2024 03:11:32 -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 1sN5lV-0003KN-Jz for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:26 -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 1sN5lT-0004tJ-CF for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:25 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-36733f09305so157204f8f.3 for ; Fri, 28 Jun 2024 00:11:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558681; x=1720163481; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=SnL/FPFYEQkll60HqwiRh6fnqmVJNFRbyEObo/B5eRw=; b=ujEncbw9XmjkuHZ7xGVWWM6IaX6oL7YVGHu89ayP473fgitrueG2tYjTWiWgxl6YBo kUjXiuGvP3iNZyIWF4lPGwT5xIREnvrnr3rSgreJfRuwE6dghvSn3ZftXujfGlETeof2 dW1AMxnovWm0OsEmlq8ck2LSlS0+HvarSPSCZA5f+f02mjSELC6Zs6tjy+YmvI2ViQiO JJK7J109YVRWkf72P12vXGBt+gvZefkgO1QdZYtfxAU6POasDvccwsV/qYac+rf25+UE ce46ngnKk2dSDlNyNIdTsbroosLMbbLpWcjMLTMwzt+6yQ8F+2zUoBdBlKhvi/THiemU qWtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558681; x=1720163481; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SnL/FPFYEQkll60HqwiRh6fnqmVJNFRbyEObo/B5eRw=; b=hhOF5rTJvAxeifH8GOb9+VyK1pNhKAyRsJbdta/rsws51Vsp0Ok36dNbvxJeYfgmTv t2Ejh6s1HA9RkkRYxVXGbE5cP1NtCXgEQ/1BG1k87OhG4yssiLH3iy1PtUTEXYr3h1ru qGOJiQVnuur6jBM9qiwjXWDD5PjK7RmgmnbA7xfxOTwPpICsaFvzIQ49m+gqczZA5cT9 fB7y2q2Ij0FgmR7GVuJ07ZVKKo5H2O7OLGQ82sCX2B5IUSBHd3pcdrbgFFf7tNX8tkHw oNwX+HSZTF/tLWtQ7Ub9d6dEVV6XSeA2IrpkPTAVucNTKcPH2l0R51ie4y/d3YEpHd5I /fyg== X-Gm-Message-State: AOJu0YzAcUWrXZMoz/tbzAtLeA3sQ0tSVMAFkB1npV2F7DHVty/OpLOl /QrLW26X1sI4a7HgxGbQl4/yd06KBPEkukGZPx930bcPu1ifwmAJz/EjPYw2mXDuxiZCcoenpvb I2sw= X-Received: by 2002:a05:6000:154d:b0:366:e7b5:3b49 with SMTP id ffacd0b85a97d-366e7b540a8mr15072878f8f.54.1719558681726; Fri, 28 Jun 2024 00:11:21 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd6e5sm1352576f8f.4.2024.06.28.00.11.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:11:21 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 94/98] hw/sd/sdcard: add emmc_cmd_SEND_TUNING_BLOCK handler (CMD21) Date: Fri, 28 Jun 2024 09:02:10 +0200 Message-ID: <20240628070216.92609-95-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 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=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 From: Sai Pavan Boddu MMC cards support different tuning sequence for entering HS200 mode. Signed-off-by: Sai Pavan Boddu Signed-off-by: Edgar E. Iglesias Signed-off-by: Cédric Le Goater Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sdmmc-internal.h | 3 +++ hw/sd/sd.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/hw/sd/sdmmc-internal.h b/hw/sd/sdmmc-internal.h index 20d85aea6d..a2769a80aa 100644 --- a/hw/sd/sdmmc-internal.h +++ b/hw/sd/sdmmc-internal.h @@ -108,4 +108,7 @@ #define EXT_CSD_PART_CONFIG_EN_BOOT0 (0x1 << 3) #define EXT_CSD_PART_CONFIG_EN_USER (0x7 << 3) +#define EXT_CSD_BUS_WIDTH_8_MASK 0x4 +#define EXT_CSD_BUS_WIDTH_4_MASK 0x2 + #endif diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0561079eff..ae5e73175e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -698,6 +698,25 @@ static const uint8_t sd_tuning_block_pattern4[64] = { 0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde }; +static const uint8_t mmc_tuning_block_pattern8[128] = { + 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, + 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, 0xcc, + 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, 0xff, + 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, 0xff, + 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, 0xdd, + 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, + 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff, + 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, 0xff, + 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, + 0x00, 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, + 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, + 0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, + 0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, + 0xdd, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, + 0xbb, 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, + 0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee +}; + static int sd_req_crc_validate(SDRequest *req) { uint8_t buffer[5]; @@ -1603,6 +1622,26 @@ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) sizeof(sd_tuning_block_pattern4)); } +/* CMD21 */ +static sd_rsp_type_t emmc_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) +{ + const uint8_t *buf; + size_t size; + + if (sd->state != sd_transfer_state) { + sd_invalid_state_for_cmd(sd, req); + } + + if (sd->ext_csd[EXT_CSD_BUS_WIDTH] & EXT_CSD_BUS_WIDTH_8_MASK) { + buf = mmc_tuning_block_pattern8; + size = sizeof(mmc_tuning_block_pattern8); + } else { + buf = sd_tuning_block_pattern4; + size = sizeof(sd_tuning_block_pattern4); + } + return sd_cmd_to_sendingdata(sd, req, 0, buf, size); +} + /* CMD23 */ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) { @@ -2391,6 +2430,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 21: /* CMD21: SEND_TUNING_BLOCK (MMC) */ case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ case 30: /* CMD30: SEND_WRITE_PROT */ case 51: /* ACMD51: SEND_SCR */ @@ -2573,6 +2613,7 @@ static const SDProto sd_proto_emmc = { [16] = {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [17] = {2, sd_adtc, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, [19] = {0, sd_adtc, "BUSTEST_W", sd_cmd_unimplemented}, + [21] = {2, sd_adtc, "SEND_TUNING_BLOCK", emmc_cmd_SEND_TUNING_BLOCK}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, [26] = {4, sd_adtc, "PROGRAM_CID", mmc_cmd_PROGRAM_CID}, From patchwork Fri Jun 28 07:02:11 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: 808215 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225384wrr; Fri, 28 Jun 2024 00:15:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWtoKCZWdmil7JlL5kVpCLkG5U9DKu2XqdYnq+7Nf8IDc5FEXPgWAiXP+42V633gRbjSOLeILI6x8+gimARE76J X-Google-Smtp-Source: AGHT+IGWNzqI8kmVWxavxMFNRHcOdjlA1rN3V6CIfg54tenLIEPn1GYL/jj7nju7rEDigITeR97a X-Received: by 2002:a0c:e611:0:b0:6b5:4e07:2a55 with SMTP id 6a1803df08f44-6b54e072a6cmr127598156d6.29.1719558930525; Fri, 28 Jun 2024 00:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558930; cv=none; d=google.com; s=arc-20160816; b=Xn70nVvLwaUraM6NktZWNrbN+P/IBzWQRUCG5Dp0p7eivkFsoYHrC7mB35NnJMxxjQ BBhsy2mlaOiRDZ81OJvAt59jc5oY33MJj8NlpwZPFA+rYiP7gXW08X+lKc56+sqCU7DA IddlpYDpmNDwT3QFfGUXY7AQ6eA0VGtSz90fUKyBeftDeN9oCoLtuGw45e8zyoH2vqpp a2N7g3vmb+/d5tpmotLIOtfgreVsB2qU6uFSSTcYuCaFWtPJgHwv9l6WwuaP/IxQhF5G bgAP7RMNca8l8AQfRQ4n3vWcRtWv0brguTb/ydlClbBY+jfRiVj1I90czpHmBTHkrYEE GyYw== 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:to:from :dkim-signature; bh=L+wEPWvr7kf9AKn0k2ofydQW0/V6lPt4e04Ilr1xeQw=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=MhUuptK3NsL3MSi5HhpOXWlA4QLL76PzQ2ZUziFBvsHFkJnppd6ofFjEOviFAue/PX E73eK84Ag3/NVC7IObx0tbSq3vqxuA0mlpOPU05nZ7i5oNwpKVHXsEkp74fR8V6yxXEk Yr/ZtQBtxtldLtMOWuvXGOpD83vjCyTX53eHp2CCx7pH5y8hA4KR6BHZ0pfDZPUK45ck 4h/OC1jYw3CGyU5jHKWIw3YtS6/beEFHE4eSTtEtGHysNnAUkXB3NBRHp1vZqC+doIn8 rblNucX20ShVfm4c738VO+gRnOUxcY1KXRk1Z4enPQBYIs2G7AzAfq5IAuw1/IZOqZQI szjQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A8Dhj5ms; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e61863asi13059246d6.578.2024.06.28.00.15.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:15:30 -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=A8Dhj5ms; 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 1sN5ll-0003xR-Vj; Fri, 28 Jun 2024 03:11:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5lc-0003h9-5A for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:32 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5lY-0004tp-GU for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:30 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-425680b1d3aso1793285e9.2 for ; Fri, 28 Jun 2024 00:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558687; x=1720163487; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=L+wEPWvr7kf9AKn0k2ofydQW0/V6lPt4e04Ilr1xeQw=; b=A8Dhj5msEjl6dmyPvn37jj5MgVfJNYozDxhzqxXL5WY29ABuCgQOFX932KMrfcQybp 1PwMAZtsEWW7wwoLGPlWo06uLu9nxerEsB6g9kZ0QCsTgBabKZg3yIwDXmzCJta7rRaB e2J0l5QrleND+BTzxQfyVs4SzodPFgLbfG01OMySDkhh5lh3c/IGCnjB5GaBjcjntX3I fsz/hFYfgmOg8kMh8KPQ5hd41/SA7c5M60Ndki58XAxK8PTaetcorgCdxWAFBo4Q0BUA tE3TMwgxydqYfpbQKJtMqCDJUb7Q08JCWBj2p3sVJqqfAmD0lYav+fcUTMIo8HwCIILs Sp9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558687; x=1720163487; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L+wEPWvr7kf9AKn0k2ofydQW0/V6lPt4e04Ilr1xeQw=; b=e8w5pvUdP+jCOlkbuwD5nEN47n+1o3EkxlAyxyb90mQGD2uLOFtnRY/XntbEEoGtwF 9WS4kW5vFyLq/XS2mT1dn5611mVewLe2fK6zLn8LLsqOecFfQ+c+WznIxPB7CG3O1HW7 PDtEPouSyZzQXmeE9T1jbp19LMnMTVcEx39SRro0KAzNt4+1MPM7Y441MaBukaC3FiGp 6Yu2j/sxbj7RxoD4sKB8zZ7szw+4u7A/vekaeO4xHie12S/Sehe4Dq1PyiJeYtFNCwWw Jv6//MiZuaJQB1ulsdExW3bv7pnejMdLegdWDifx+oyi/Vu4ixHSMaXBai7KU0AxY1h0 Tt4g== X-Gm-Message-State: AOJu0YwQBWJzhWQlV2mVRmlj8+YtYYuz6yv4lFTBLGIwxjThEqQtsE/1 u7zhTWcXFxdDnBPxUUgI1XG1IgaAsuhr/tDzeA4s+LNcMsUJ7BbWy+y2ZHtFFPVTRO3GzXXIvds 8lUg= X-Received: by 2002:a05:600c:6d84:b0:425:65be:3477 with SMTP id 5b1f17b1804b1-42565be39e0mr26810505e9.18.1719558686804; Fri, 28 Jun 2024 00:11:26 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af5b626sm21513825e9.15.2024.06.28.00.11.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:11:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 95/98] hw/sd/sdcard: Add mmc SWITCH function support (CMD6) Date: Fri, 28 Jun 2024 09:02:11 +0200 Message-ID: <20240628070216.92609-96-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 From: Sai Pavan Boddu switch operation in mmc cards, updated the ext_csd register to request changes in card operations. Here we implement similar sequence but requests are mostly dummy and make no change. Implement SWITCH_ERROR if the write operation offset goes beyond length of ext_csd. Signed-off-by: Sai Pavan Boddu Signed-off-by: Edgar E. Iglesias Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index ae5e73175e..e7d8b9c0fb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -625,6 +625,7 @@ static bool sd_req_rca_same(SDState *s, SDRequest req) FIELD(CSR, AKE_SEQ_ERROR, 3, 1) FIELD(CSR, APP_CMD, 5, 1) FIELD(CSR, FX_EVENT, 6, 1) +FIELD(CSR, SWITCH_ERROR, 7, 1) FIELD(CSR, READY_FOR_DATA, 8, 1) FIELD(CSR, CURRENT_STATE, 9, 4) FIELD(CSR, ERASE_RESET, 13, 1) @@ -1075,6 +1076,43 @@ static uint32_t sd_wpbits(SDState *sd, uint64_t addr) return ret; } +enum { + MMC_CMD6_ACCESS_COMMAND_SET = 0, + MMC_CMD6_ACCESS_SET_BITS, + MMC_CMD6_ACCESS_CLEAR_BITS, + MMC_CMD6_ACCESS_WRITE_BYTE, +}; + +static void mmc_function_switch(SDState *sd, uint32_t arg) +{ + uint32_t access = extract32(arg, 24, 2); + uint32_t index = extract32(arg, 16, 8); + uint32_t value = extract32(arg, 8, 8); + uint8_t b = sd->ext_csd[index]; + + switch (access) { + case MMC_CMD6_ACCESS_COMMAND_SET: + qemu_log_mask(LOG_UNIMP, "MMC Command set switching not supported\n"); + return; + case MMC_CMD6_ACCESS_SET_BITS: + b |= value; + break; + case MMC_CMD6_ACCESS_CLEAR_BITS: + b &= ~value; + break; + case MMC_CMD6_ACCESS_WRITE_BYTE: + b = value; + break; + } + + if (index >= 192) { + sd->card_status |= R_CSR_SWITCH_ERROR_MASK; + return; + } + + sd->ext_csd[index] = b; +} + static void sd_function_switch(SDState *sd, uint32_t arg) { int i, mode, new_func; @@ -1398,6 +1436,19 @@ static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState *sd, SDRequest req) return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); } +static sd_rsp_type_t emmc_cmd_SWITCH(SDState *sd, SDRequest req) +{ + switch (sd->state) { + case sd_transfer_state: + sd->state = sd_programming_state; + mmc_function_switch(sd, req.arg); + sd->state = sd_transfer_state; + return sd_r1b; + default: + return sd_invalid_state_for_cmd(sd, req); + } +} + /* CMD7 */ static sd_rsp_type_t sd_cmd_DE_SELECT_CARD(SDState *sd, SDRequest req) { @@ -2602,6 +2653,7 @@ static const SDProto sd_proto_emmc = { [3] = {0, sd_ac, "SET_RELATIVE_ADDR", emmc_cmd_SET_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [5] = {0, sd_ac, "SLEEP/AWAKE", emmc_cmd_sleep_awake}, + [6] = {10, sd_adtc, "SWITCH", emmc_cmd_SWITCH}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [8] = {0, sd_adtc, "SEND_EXT_CSD", emmc_cmd_SEND_EXT_CSD}, [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, From patchwork Fri Jun 28 07:02:12 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: 808214 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225374wrr; Fri, 28 Jun 2024 00:15:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUsLBt9/uCCX+aEj8vfzUkT2/i4wuIOGOC0gCOCa7j8yoCc+w15n+zoNrNo2zxZp50skl/Sd4eI39GCH4i8iBQW X-Google-Smtp-Source: AGHT+IGMFaoW0DytGbbNg09sReqpyKxmrUkchORXHvKubLiiUOUQCPEuxkHVXgVzPSdAZX4PyGJS X-Received: by 2002:a67:f1d8:0:b0:48f:46ff:7b64 with SMTP id ada2fe7eead31-48f4eef0dacmr13655045137.9.1719558928717; Fri, 28 Jun 2024 00:15:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558928; cv=none; d=google.com; s=arc-20160816; b=aJKKUlBh77z4CWRnNMPcR2jjbqQpKc/wNDuOOeZbZn87IGamS9xq0gP2nNS4DPr48r LcPJeFi91Tt66VfFoJM5q5HabeeEuf6FLsba7KaWy6rWjWeAB+Ff3Aj6c7HvCDZlkzIQ VBHYvoYTdeHyY2nCpKasE1AFC++/KnV8pFgR9WJeOEGoT2T/jz7b853zSLFvL/sW01rk DD6uYuTX6RudCqxr1BKyP562HrawvO824smIgLwIR4KqQfM2WhL5vHQ9SU+b57qedMXc iiZp8lohPufb2MktAiPhevrFpL0TUWTAdNBd15IKPxF1aBYARfanmPtBAldRFrPJRj3+ vKtA== 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:to:from :dkim-signature; bh=cc2phwHICPbHNDUMxZA6a+9UcWAynLl1hqKHKReAlY0=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=xmzvjHmD/CZonUNNFECyN74/3CD0cgZAhAkPQmrmvHplMBmtLRfJkMtuqsQkRvipIQ MgCNedLd3psGQ+5KUca0QdHy3arq3N24BOzn1BodKO3rpUXMzvwfEIXBkXwiBaIzdtLS KOHyNaXgfhC2Fk07Qf++IDGx/tAWXWGSNvhhEqKXaZJci7bIiUeRmt54kgbLgRHjikWK ka0L92dHtaJrBxeLemsXv401i2UokPRQz9g2qAUp83UoOc9dLYIKCqX3r77C+arfVrnN ISMNWR03neHUdrhOdccmLvNlkiVezxkwN8m2WxeJK7Jgzehy545kzuVe1wXbZGrCiXCN 3lPw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Szb2It4p; 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-79d6933d40csi119889485a.670.2024.06.28.00.15.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:15:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Szb2It4p; 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 1sN5lq-0004DF-09; Fri, 28 Jun 2024 03:11:46 -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 1sN5lj-0003x0-9N for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:39 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5le-0004xh-PA for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:36 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4248ea53493so1787455e9.3 for ; Fri, 28 Jun 2024 00:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558692; x=1720163492; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cc2phwHICPbHNDUMxZA6a+9UcWAynLl1hqKHKReAlY0=; b=Szb2It4pksVK/1SYB6AxRhN1oymqeuzwCqLIBfqZxi8eUCdWF+FAQTBwnUgRKIxGKC cNdH3/dxx0wrRnajRfdAJ1W4JVp734Qu9LB0UcZiLsfmolucVdkWM6Yv4Ash2QM8Bsfj DG4P4EG/mLIKMQ5FjOgV5sPUAh31+t9IBJxrNBqTNkGFhjf2dRbwiDYHFhm4rkxM8plI OnEfoHdmRb3KbmmOTPhHNv91lVNtINodMg4K6G5ivUdAhg6hU0BQiP+lyMx3rz3E0Jbo rWP32HVUr2p2/Zfix0rtOqrpNpXDsosI9PFPQ3i0m7qpdE7Rvz4CXgGnNbmCjZRLbIc2 zn9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558692; x=1720163492; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cc2phwHICPbHNDUMxZA6a+9UcWAynLl1hqKHKReAlY0=; b=NjrUivHNw4aVSCRe8irlxysUhvLEA9MFiYpx757zZlWiFh6P7F2DlOqPP1RMGniCSA LlkyW55gQwzlajUhBe5SKr442TOL9YM3H4aphGQUnZarOX9VWRsj7zlqVCENp4/LsDbx b9eUV+fMnloaMInt3BbbSwtNX0CYRBRZesPGNxe3kj0hZQa0gHWTG3K/XHG4L+4NrtEO G0ez8+jbAfkG8ttyUr7DBQJmy1L+q/+O3VR/HxwlH9Nw293acUYTjwQ/ByDYgccN6Dbc 0N3klRONLgnvRlEq4doTc54hIbHphRpxSSDrcoJcESoSBY+VOxCDsVnjqi9Znb7TQIpx GseA== X-Gm-Message-State: AOJu0YyyS81o0Jj3fSBNHOlzvTCBJAPuC0ohaT5iEU1pgocgicynLb6H GqMCDo2Gr/h+XOLyAypP5GwuaC5VWDi+TW+t9xtgSdQyVLfeZIaAQCs9CeepQ/YfD6mfGb6Brs8 d40Q= X-Received: by 2002:a05:600c:470d:b0:422:7eca:db41 with SMTP id 5b1f17b1804b1-4248cc18101mr123694015e9.2.1719558692742; Fri, 28 Jun 2024 00:11:32 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0e16a8sm1343948f8f.64.2024.06.28.00.11.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:11:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [RFC PATCH v42 96/98] hw/sd/sdcard: Support boot area in emmc image Date: Fri, 28 Jun 2024 09:02:12 +0200 Message-ID: <20240628070216.92609-97-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 From: Joel Stanley This assumes a specially constructed image: dd if=/dev/zero of=mmc-bootarea.img count=2 bs=1M dd if=u-boot-spl.bin of=mmc-bootarea.img conv=notrunc dd if=u-boot.bin of=mmc-bootarea.img conv=notrunc count=64 bs=1K cat mmc-bootarea.img obmc-phosphor-image.wic > mmc.img truncate --size 16GB mmc.img truncate --size 128MB mmc-bootarea.img For now this still requires a mtd image to load the SPL: qemu-system-arm -M tacoma-bmc -nographic \ -global driver=sd-card,property=emmc,value=true \ -drive file=mmc.img,if=sd,index=2 \ -drive file=mmc-bootarea.img,if=mtd,format=raw Signed-off-by: Joel Stanley Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- include/hw/sd/sd.h | 1 + hw/sd/sd.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index d35a839f5e..07435d2e17 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -132,6 +132,7 @@ struct SDCardClass { bool (*get_readonly)(SDState *sd); void (*set_cid)(SDState *sd); void (*set_csd)(SDState *sd, uint64_t size); + uint32_t (*bootpart_offset)(SDState *sd); const struct SDProto *proto; }; diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e7d8b9c0fb..2d49be61f6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -783,6 +783,12 @@ static inline uint64_t sd_addr_to_wpnum(uint64_t addr) return addr >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT); } + +static unsigned sd_boot_capacity_bytes(SDState *sd) +{ + return sd->ext_csd[EXT_CSD_BOOT_MULT] << 17; +} + static void sd_reset(DeviceState *dev) { SDState *sd = SD_CARD(dev); @@ -984,9 +990,40 @@ void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert) qemu_set_irq(insert, sd->blk ? blk_is_inserted(sd->blk) : 0); } +/* + * This requires a disk image that has two boot partitions inserted at the + * beginning of it. The size of the boot partitions are configured in the + * ext_csd structure, which is hardcoded in qemu. They are currently set to + * 1MB each. + */ +static uint32_t sd_emmc_bootpart_offset(SDState *sd) +{ + unsigned int access = sd->ext_csd[EXT_CSD_PART_CONFIG] & + EXT_CSD_PART_CONFIG_ACC_MASK; + unsigned int boot_capacity = sd_boot_capacity_bytes(sd); + + switch (access) { + case EXT_CSD_PART_CONFIG_ACC_DEFAULT: + return boot_capacity * 2; + case EXT_CSD_PART_CONFIG_ACC_BOOT0: + return 0; + case EXT_CSD_PART_CONFIG_ACC_BOOT0 + 1: + return boot_capacity * 1; + default: + g_assert_not_reached(); + } +} + +static uint32_t sd_bootpart_offset(SDState *sd) +{ + SDCardClass *sc = SD_CARD_GET_CLASS(sd); + return sc->bootpart_offset ? sc->bootpart_offset(sd) : 0; +} + static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len) { trace_sdcard_read_block(addr, len); + addr += sd_bootpart_offset(sd); if (!sd->blk || blk_pread(sd->blk, addr, len, sd->data, 0) < 0) { fprintf(stderr, "sd_blk_read: read error on host side\n"); } @@ -995,6 +1032,7 @@ static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len) static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len) { trace_sdcard_write_block(addr, len); + addr += sd_bootpart_offset(sd); if (!sd->blk || blk_pwrite(sd->blk, addr, len, sd->data, 0) < 0) { fprintf(stderr, "sd_blk_write: write error on host side\n"); } @@ -2833,6 +2871,7 @@ static void emmc_class_init(ObjectClass *klass, void *data) dc->realize = emmc_realize; sc->proto = &sd_proto_emmc; sc->set_csd = sd_emmc_set_csd; + sc->bootpart_offset = sd_emmc_bootpart_offset; } static const TypeInfo sd_types[] = { From patchwork Fri Jun 28 07:02:13 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: 808216 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp225397wrr; Fri, 28 Jun 2024 00:15:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVHxby5DPa0nq5rhsvizlACQt2SQec34ISLqzntQtsWzf6ZX2zrT9/Min/E2eHF2xNMVgCNmncAuWkPFZu7lju1 X-Google-Smtp-Source: AGHT+IEUg1Q7z6t0acfMASSID30PErOPHKrbisggbcdi+XBMkwD2CERztqhdKYo2ZdG5JcAj2zPR X-Received: by 2002:ac8:7f89:0:b0:441:545c:bdb6 with SMTP id d75a77b69052e-444d92036aemr170548121cf.24.1719558933024; Fri, 28 Jun 2024 00:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558933; cv=none; d=google.com; s=arc-20160816; b=ITBKvnU5OJi2a1scOUXuaAxcV3qX1N+nbYMrBcHZTjVTU9VDACoMuhBG3buoY1FLtE 4crttV8ExtBIyaqxlbKLx91Zw4iyGQhunZxxStYshNl8C8G8vjota8FMzKrqjoFhRgWM HtLGCfDHws/I3P+Qva+yOZ2WRpN1zVTKlnlrOTz+AnUyTXvvkhFnduiFPhbG5uvrC3gy cf1gihrqMYldb0gVRzxcyO63ossrJsDtM/osrKhpTFLTL2arWoZXGGRaC+Rr3+dLYtJs x2UJZikkgn+7J0gNtthZ5eqdYtVJKtbKauVM49K0/dQHBEcHuetSA5LacN6bmwIKtKaq 40yg== 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:to:from :dkim-signature; bh=avuRrMAF6rH/sTJFTAsB7oMGZ0jZuIMfuK+mEn/O+u4=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=t2++yf+KJkKKkbudaxOF6QURNsW08Fm/cBlwN1eQizHKop1dY9oL8n5GOrpIwUXn6T UATH4rIM7nB2K96NF+O9KygSuEnRUHwyUVlZ25kt6ZE2Hx8UZqwiw/fba8Ba+ZWk6JHY UrRvUVC2SKFWgmxC9/zlMCGtpC0xYLEGGOYtb7RByts3KxtLrKVgVu9TAsuxOZsT6Gym J2p6eVajz1q1g275vtA5xlIYqVMFTjpBv+PPCK4fcwxjhP6zH3xeJRXYLeUeO1OvLMSi gqw2yMt2eB5HAr9N9uTOhm4+k3MZEqksq0TLOHWeqQ2HP3hVnbHbu7svzjXzG0P07m4R 4yBQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AIfHn9jR; 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-446513e01c3si13316311cf.172.2024.06.28.00.15.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:15:33 -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=AIfHn9jR; 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 1sN5lo-000497-4N; Fri, 28 Jun 2024 03:11:44 -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 1sN5lm-00043m-FD for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:42 -0400 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5lk-0005G9-Dw for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:42 -0400 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5295e488248so365188e87.2 for ; Fri, 28 Jun 2024 00:11:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558698; x=1720163498; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=avuRrMAF6rH/sTJFTAsB7oMGZ0jZuIMfuK+mEn/O+u4=; b=AIfHn9jRFNfKwFJ4vlAIjTd7dsJ5WGVk+aiFDw3pILmWHjHF3g0R4+hxL3sQigUldZ cy7DLBTUCeTf6eeMBotvrTGnZWkxNaz/tn5blFn5LVe2Qmrzo7zGPkBB1pPhwUlGWf6L 4mPgAv4TDmYl8Cln3iuGHS/j//XtbM85CIJYuvFMfkJmHaN4GnQ2XVhIObg76nPxNOhM GaOtIKJWRsW67kQt+fsKCCBq+3J6D2uXNOh9N4BwTaFJxruIG5ha/qjfi5UJv+YpSAot OGPiY8BXCl4smZBlrZUFINHUW+BIwKG+Mg5uYbWXrEMBJ9RiahQIHY/xPJe3UkrdmvyM 3Ddg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558698; x=1720163498; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=avuRrMAF6rH/sTJFTAsB7oMGZ0jZuIMfuK+mEn/O+u4=; b=cZ0ggTlBOJuRvts0l7FVY0eVy198KaI4WcRtAgkEjwXZ8TN/uBiOgM90TEDq/uurfG 49qyIFH/WWuWi2HeBAzn2RvdpmSdzfOWCPj+t2CU8sEzCWMI/AIUlAvi2R8UJpZ8JIdg UW06LBfmvQ5R1sgz617MUQr3i1hRMv3ULWDRNIrcMbYlWxYptEWTMMeP3Ls5/9v5HItl My/to06oFtEn/dnW+1G748rq0opYbVp5B+8RZa1DewwpcuXRXcsAHU+Ik4Pubzn5VB2I /l1tqrcjuXmdyBb1DKXvMSlz2B3etBWnablRYSmSSHTRtAshrfqqMKVW1mQDJwNxMXK0 ItXA== X-Gm-Message-State: AOJu0YzhML6v3h6iVfyTtTz0VJANvWzXLLHQmRyAwtzMp4lB1rjaC0OP shZliwYFMw1bJf4Bf8fl7iyRBlSLmbXXtioAgpN+Z2umR3Ya/CV/fmGplwLTXrScHhAiZDa6OZ7 p+g8= X-Received: by 2002:a05:6512:2394:b0:52c:d84c:1182 with SMTP id 2adb3069b0e04-52ce1862c12mr11635231e87.64.1719558697985; Fri, 28 Jun 2024 00:11:37 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c17e6sm21525025e9.42.2024.06.28.00.11.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:11:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [RFC PATCH v42 97/98] hw/sd/sdcard: Subtract bootarea size from blk Date: Fri, 28 Jun 2024 09:02:13 +0200 Message-ID: <20240628070216.92609-98-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12b; envelope-from=philmd@linaro.org; helo=mail-lf1-x12b.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 From: Joel Stanley The userdata size is derived from the file the user passes on the command line, but we must take into account the boot areas. Signed-off-by: Joel Stanley Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2d49be61f6..bbf054ea1e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -804,6 +804,10 @@ static void sd_reset(DeviceState *dev) } size = sect << HWBLOCK_SHIFT; + if (sc->bootpart_offset) { + size -= sd_boot_capacity_bytes(sd) * 2; + } + sect = sd_addr_to_wpnum(size) + 1; sd->state = sd_idle_state; From patchwork Fri Jun 28 07:02:14 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: 808229 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp226277wrr; Fri, 28 Jun 2024 00:18:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVfF2bFdUOu1ADvxrVbuNR2euiJcNhg53hnJahnSJwgdSoUwxiXWZSrzK7IYdOXBCt5BA9xVoW9SWL+EDAD3HDU X-Google-Smtp-Source: AGHT+IFOWs5pUWNm2KlKq2sqBXj0wpBxSzQyV7L8FOkMb5YVU55BIrtR1o+3oKFbRD+M3CkkTON4 X-Received: by 2002:a05:620a:3906:b0:79d:5597:15c with SMTP id af79cd13be357-79d5597023bmr828314585a.29.1719559105948; Fri, 28 Jun 2024 00:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719559105; cv=none; d=google.com; s=arc-20160816; b=OSwFk7a3ZkMs3ljpl1lhP1+0gxLfHRezbxszgHyL8nhQ29MsSBATgynN1cTk/2uivx BBy8IinR/dyd0+RBghOdTh0TLELEMwCa3Jy8AYCL9nL47cMI7nwUjY8L/3N4jMS7B1Jr 0Yd6wCBorXXjFJ0p2IDMi1sD2oG6uUEVYKzUhr5zpnq2R2Y8XS3VE2nHA6CltAtqNJnu Exol9cmV7GyZfpqqNNCkaf6qyzXFv1TGBHmrLhoIhin7jaJdfffkC+G0yW1tLrzVYb4N VtnVmEaSTr1E61A8gBxJx5G0x9605ae6w+aeaIp8HNzblE0d3oN1/DnP8yC6janbhDRD aZ8Q== 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:to:from :dkim-signature; bh=wfOV4Z9kH5/WWEkygPAPJDC+UN3xtUZojvL70U9kebo=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=fG9Eb4XID8nOX4yaqx3xrVJE9bMjgbpVpBFA1whdY998/AVbDXt9gPXG0FFRWGHfYd +mJiOjo+J/kbAjbmsk18hTLSqQOOpt9AX4u+WYOugOQR61jNbQ2MFl9/HKmF7wQmY2Ti gIM872XP9/38KjLNiWAIYgrxPEXhkodsECDAY5c2/BMce1yX+Eh/BpyJoJGEB2EzUWg1 MLa7XpuVjaPmZcYWgKjU72d/V2cTuguYA2fmnuLjRMc4uEQA+DRtR3Xafr3H/VF5RK5q vDWzEMyRbgqwW//JN8Mmgt+PZ2B1ZEuK0ZBo5h83G8hOpn3MGxQb7VMQJj3CwlrSGTrM 9Jsw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qH6m3otI; 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-79d6933a9f2si121073185a.606.2024.06.28.00.18.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:18: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=qH6m3otI; 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 1sN5lt-0004Kg-AW; Fri, 28 Jun 2024 03:11:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sN5lq-0004G3-Qz for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:46 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5lp-0005ZH-0N for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:11:46 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3651ee582cfso132782f8f.2 for ; Fri, 28 Jun 2024 00:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558703; x=1720163503; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wfOV4Z9kH5/WWEkygPAPJDC+UN3xtUZojvL70U9kebo=; b=qH6m3otIN1V6wX6W7FwmY3sfY1CQQGM9vlwq5Cb32jAuHifqm5jIzkiZEi1Izys/Dd Bj7eMv3KYmGFerZ97l1tWcQRMcK18YtMBkOjfs7GUzj8V8ladw6cnwRv5gNTrD8E0kZn R97iTQOobh7FupgchJ0aT0irJwqr4Z02nriNcVjrS1Eb6mvHi7WYoYbgbR5CniTzJ/U8 s71pzHG6p2d/lxYMn6Z/gO+CGCw9UFD40e7thjZByTIqNPQcn1YBi4z8MtVwFAUiGqQi Z6luuMAIMrajAnnCJ/Vv6l5X+Uckv3AabzZfrYzdFJZU7sxmza+Z36Ctz/OesJXrItfe zE+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558703; x=1720163503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wfOV4Z9kH5/WWEkygPAPJDC+UN3xtUZojvL70U9kebo=; b=G84hP2lmQK2wirL75tH3tq1CNbwim1CWPGLxiv5ORA5/JGHJ3fne4pEzGDeH7Cg3t9 eSjtiSOp1U+TljIKw94XD932mvyM8owspPNDpz0cgIWwxCcR5jwGi8l22vbi2VRkGDyN KXIJiVtmMX5IN3D3S3BIr9EyKQn+UnEkfpWutQ4cp55Y6unqdoEhuCdK9spiiEtlzWnC aMpvQ5uTbXDXsb4yVj9tjvQmYBxsF+J1PAWASay8IoQGX4mYsoY/RX1a5LvbkpQ0XHLL gpARnHJy4KAJfx0dk5NiYsn8wnymUKRq1cwU7fcVUTr6fZUBatym5Rl2rqZ7sKeHeev0 Dd4Q== X-Gm-Message-State: AOJu0YxLyCr9xN/vHG4/T2DtnYjNNliMEMNrTt7X+YUY4HCCSLC//4d4 T1IW6Ul08Vge4qalhNpLxcj1d3qRQaEXa10dR8qfZQDT432ZjY+nL9C0RDve3utd/76kQOg0wmc DreM= X-Received: by 2002:adf:e811:0:b0:35f:fa0:cf82 with SMTP id ffacd0b85a97d-366e9632621mr9952233f8f.68.1719558703350; Fri, 28 Jun 2024 00:11:43 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd562sm1350541f8f.15.2024.06.28.00.11.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:11:42 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [RFC PATCH v42 98/98] hw/sd/sdcard: Add boot config support Date: Fri, 28 Jun 2024 09:02:14 +0200 Message-ID: <20240628070216.92609-99-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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 From: Joel Stanley Introduced "boot-config" property to set CSD 179, the boot config register. With this correctly set we can use the enable bit to detect if partition support is enabled. Signed-off-by: Joel Stanley Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bbf054ea1e..b598974bbf 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -129,6 +129,7 @@ struct SDState { uint8_t spec_version; BlockBackend *blk; bool aspeed_emmc_kludge; + uint8_t boot_config; const SDProto *proto; @@ -505,6 +506,8 @@ static void mmc_set_ext_csd(SDState *sd, uint64_t size) sd->ext_csd[159] = 0x00; /* Max enhanced area size */ sd->ext_csd[158] = 0x00; /* ... */ sd->ext_csd[157] = 0xEC; /* ... */ + + sd->ext_csd[EXT_CSD_PART_CONFIG] = sd->boot_config; } static void sd_emmc_set_csd(SDState *sd, uint64_t size) @@ -1004,8 +1007,14 @@ static uint32_t sd_emmc_bootpart_offset(SDState *sd) { unsigned int access = sd->ext_csd[EXT_CSD_PART_CONFIG] & EXT_CSD_PART_CONFIG_ACC_MASK; + unsigned int enable = sd->ext_csd[EXT_CSD_PART_CONFIG] & + EXT_CSD_PART_CONFIG_EN_MASK; unsigned int boot_capacity = sd_boot_capacity_bytes(sd); + if (!enable) { + return 0; + } + switch (access) { case EXT_CSD_PART_CONFIG_ACC_DEFAULT: return boot_capacity * 2; @@ -2808,6 +2817,7 @@ static Property sd_properties[] = { * whether card should be in SSI or MMC/SD mode. It is also up to the * board to ensure that ssi transfers only occur when the chip select * is asserted. */ + DEFINE_PROP_UINT8("boot-config", SDState, boot_config, 0x0), DEFINE_PROP_END_OF_LIST() };