From patchwork Thu Jan 9 12:20:29 2025 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: 855965 Delivered-To: patch@linaro.org Received: by 2002:adf:8b05:0:b0:385:e875:8a9e with SMTP id n5csp1194422wra; Thu, 9 Jan 2025 04:21:01 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVUZl5T81sKr5XIwrZ9POLkeROnHCb5uDh6Wmwtg3ooiklM239wTbjQ4FpOnQQNVvTXOhaBzQ==@linaro.org X-Google-Smtp-Source: AGHT+IGfHQGEK7Xlq1u3OrN4qo0+HolaBybNg8rGKSOCZhUT6bO2e1j6JhvxDoVNlPClTWaVxq50 X-Received: by 2002:a05:622a:15c2:b0:467:6f59:e343 with SMTP id d75a77b69052e-46c7108ef79mr87824601cf.21.1736425261182; Thu, 09 Jan 2025 04:21:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736425261; cv=none; d=google.com; s=arc-20240605; b=WCwvx0gjjLDBJ1u0x63di+OnkwhQg0jOgIfu4WFtiGoR4qvuZ7IxSofURhecBhpnUW 2lwf/LqBgMiqtK+LMp7aQ4GU4o0BT9iZOrwLF/j5rrUSH6Hf1KwuhokoMhZvw40AwaT9 IMTyTw7gt9F1O+Kts9po3coweiwJ5fZioX4VfkEashoK4D/V/Wt9eSdmtvY52ggc/6ZU amyug9K4s0+ht38ShiOlfkothiKP2WRRICB5lblROPi9gQb3EL2jYcaJha//CsohhGKT JkUk+gjA0XjzaLyy6g0XowgtPYShSlf/6hmEgYJ9P/oSvaiQI3eBZxzmog61mo5UaFx9 DkRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=YD5uWlmiXv+X+N/DhIr8lUDqDkhwPiq6v0QtcDmQ27M=; fh=5iK9FysEU4UzQa/NAqe/kiIxjOXqvAa3IxbezgM7eJo=; b=TLm/Ld40FVErXoU6t40AoTgYESlx29T0xaSUGoeCFplGU+c3xOskLN91EYDtpgCmZ5 YUH8NiCDO4chDoN8NnmNWwZGH5qguO6Y97Qjv1X/x9YzhlQ7qdpxiE2BVRrw9VeGfIec 3DUsNNkqFHhWEfb0UoGDTgOfZlJuQ/h3fbWLQuNIkEAQ6oipQERQ8Sh9sKKH9DmJJoS+ nNM9XcVRb7I1KqB77UeV03W9+qLbFdtpn94ge2gPdf2nz0WGoqeJCvSI6BAEfd8s+U/w 4QwHZWRzp2Jh/IfWFSoU+80LUXiYSgJLyN74SVPPZKPN6YxzqlraeVgqfQeEXq0BzYZJ vDRA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mdm2JlQm; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46a3ebc7244si28393221cf.495.2025.01.09.04.21.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Jan 2025 04:21:01 -0800 (PST) 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=Mdm2JlQm; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVrWe-0001Ut-Aj; Thu, 09 Jan 2025 07:20:36 -0500 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 1tVrWd-0001UR-1w for qemu-devel@nongnu.org; Thu, 09 Jan 2025 07:20:35 -0500 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 1tVrWb-0008Pv-FO for qemu-devel@nongnu.org; Thu, 09 Jan 2025 07:20:34 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4361f796586so9153125e9.3 for ; Thu, 09 Jan 2025 04:20:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736425231; x=1737030031; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YD5uWlmiXv+X+N/DhIr8lUDqDkhwPiq6v0QtcDmQ27M=; b=Mdm2JlQmylA1grsgJ9cghgtF5vt0f8J9hhgbYNbxaGenIO2cjden4nVlVzjLXR/YTR 7VYVSMI4TlPArd+bxWP3o966Z4KcXwMPdYDFjWRH3QUpErDEzxCOi1R9WrxpQttsoKi4 S/+0Ql85J2L7Mb4pYYq3sxyIgfualjAZuvJagNaV0SDDtVdUOqoqhTmDhI0uCXhc5g+T 0mzeJvmj+EJB8ywuNqa2UuS70A+kW8mgiwUTsTiLofs3k+M7fj8EnOe5T79PrxCh/yPy c3sE51SBDwES+3ZvxwZBK779sfOQNHRXOUqd4sxdDA9XNswWwimIBJl2GT/CeDsECM7s 5T/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736425231; x=1737030031; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YD5uWlmiXv+X+N/DhIr8lUDqDkhwPiq6v0QtcDmQ27M=; b=mao1mIRl7TtPRyqKeqBQvEVf2pRvAKSEkwBsqLXpINGbdqVJbL07ajZcRCFRS0sLE4 UIXb91wXffcBJjjOmm/kvEYbXhvRIettcb3/COeZZnTFmzviy8sf44yrLHPrpL14ldCt 9GVHVArheMa/FRvnt3zu8+ZBLqRkHoaDxKDBbvst/px9x3/7NgUilvw8qZ8lZQI7OO9l BwuV3AOH90xxZ7zoHz8UGcMedSdpq9b5m1rIVSW+NLdkNrPFNAcytmUq5opAwuX/WJdH RUa/SlOIw7VzMD5dYC9UdTKKXZhO8QrfG7M/36mcmKAcuq9BWL2GGl3kxdGuv1XPBKTq xO5A== X-Gm-Message-State: AOJu0YyjJ0yv+Zp9btAlaByXHcegmciQGzdxQsQVmcDhQkSVmLn7varr n5J4myg+Pa9IVtqjp86LG6l7kkQ7LuaGV/61OteNf6uB6Kdq6WhZM/tDYcTFFrlLy4ikaI5fu4k kids= X-Gm-Gg: ASbGncuDZuwiTakiTbxeQTqlmUyF5oO2jyAs9W5fYlocujusHuNbdybW471DyVvKUYK 6h2kVp7rN4x6MTWSsUzH1axz0xseJgWVqB2lss0ijHMLVnaAuAuhDL3HBg4ZLTelvSlpAujK3FK 5tQ3v2BOnMRSRaUdrhPBn4S70X9mJReQoP2ByKnzEmW8+hwxV6PhCY9D6THMEDSg+o8MN+cIixY MyLjEorxc6Wd4I515DvB1iBPSFhbfXDxVoa/zt8b2pBTSCaWhhcCChEs6hkLEu3LqpOzBqcwEwV r9mzwg15/iJVlUVegkORVt//UODgTl4= X-Received: by 2002:a05:600c:4fc6:b0:436:1baa:de1c with SMTP id 5b1f17b1804b1-436e269793cmr63632635e9.13.1736425231255; Thu, 09 Jan 2025 04:20:31 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e2dc0babsm53570935e9.14.2025.01.09.04.20.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jan 2025 04:20:30 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Bin Meng , =?utf-8?q?Philippe?= =?utf-8?q?_Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH] hw/sd/sdhci: Factor sdhci_sdma_transfer() out Date: Thu, 9 Jan 2025 13:20:29 +0100 Message-ID: <20250109122029.22780-1-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Factor sdhci_sdma_transfer() out of sdhci_data_transfer(). Re-use it in sdhci_write(), so we don't try to run multi block transfer for a single block. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sdhci.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 299cd4bc1b6..332ea13fe55 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -694,6 +694,15 @@ static void sdhci_sdma_transfer_single_block(SDHCIState *s) sdhci_end_transfer(s); } +static void sdhci_sdma_transfer(SDHCIState *s) +{ + if ((s->blkcnt == 1) || !(s->trnmod & SDHC_TRNS_MULTI)) { + sdhci_sdma_transfer_single_block(s); + } else { + sdhci_sdma_transfer_multi_blocks(s); + } +} + typedef struct ADMADescr { hwaddr addr; uint16_t length; @@ -925,12 +934,7 @@ static void sdhci_data_transfer(void *opaque) if (s->trnmod & SDHC_TRNS_DMA) { switch (SDHC_DMA_TYPE(s->hostctl1)) { case SDHC_CTRL_SDMA: - if ((s->blkcnt == 1) || !(s->trnmod & SDHC_TRNS_MULTI)) { - sdhci_sdma_transfer_single_block(s); - } else { - sdhci_sdma_transfer_multi_blocks(s); - } - + sdhci_sdma_transfer(s); break; case SDHC_CTRL_ADMA1_32: if (!(s->capareg & R_SDHC_CAPAB_ADMA1_MASK)) { @@ -1174,11 +1178,7 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) if (!(mask & 0xFF000000) && s->blkcnt && (s->blksize & BLOCK_SIZE_MASK) && SDHC_DMA_TYPE(s->hostctl1) == SDHC_CTRL_SDMA) { - if (s->trnmod & SDHC_TRNS_MULTI) { - sdhci_sdma_transfer_multi_blocks(s); - } else { - sdhci_sdma_transfer_single_block(s); - } + sdhci_sdma_transfer(s); } } break;