From patchwork Wed Jul 31 21:25: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: 815676 Delivered-To: patch@linaro.org Received: by 2002:a5d:4acf:0:b0:367:895a:4699 with SMTP id y15csp923067wrs; Wed, 31 Jul 2024 14:26:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX1l1yqTcpLQKJEg2i/2154yRO6IIhGfCNx+Ud0rrYqp0Cr+pcjAV5smgToB6/wQq967SAApO9P5ZtYDbw+MJur X-Google-Smtp-Source: AGHT+IHLddTmzq8No7ogZHJFB+toiQuCkR2voCNJJA0eByf4f4VM95UVK/uYIXh3Zapu1i4VofrU X-Received: by 2002:a05:6830:681a:b0:709:472d:f35a with SMTP id 46e09a7af769-7096b838521mr349721a34.2.1722461184622; Wed, 31 Jul 2024 14:26:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722461184; cv=none; d=google.com; s=arc-20160816; b=1DuUoLKZZkOA9Gl44I4Ij5rCNC22w6cqthrnv/eFHpxKbWtS2/i4FPD1gZK9t6AzCH UYsgX1qKJHyxN22gIh+HRYvnfUecHAifRWapO3nPHfuP3g6el+KpjjA8UH8+Y2hau4V8 7Wu/07pcRKvcqQcILPA3Vx2id9Y4b4aIdvpIav5rI/xtwNoO3dgweINTMaDHu7njB2Zt +gWWohXP9bR4pmdNhrPUM6NSLUomDb9wv+402HY2eK5sXTaMkTaDygmiLV8l0SqvG6uu LHn2GzIPSCJ+0kAuEbNrWs1Z916pRpyf8N+yFTWinTCI9nAJ6Jwka9wdcwwt+vfA0sOz LQdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UExLWm9ddjnMRPI0UADCJZeULFWbdE7wtbj111e1TQ4=; fh=ADixSG9ElpvNvhE8iTAdMizg2dtG0TYj8XBNEB0E9kY=; b=PUSkaXP90Hrx+dHyR5A+dQbN0v8xS8P4rPFZc6SLtyXUIpJSz6Nb9sZxKvUQ3akVvy unW4SUJuO85aXG4W2GCYxDdgkXQ9CjyxdkHIsMsSATZ4U8hGqlCYqP8g6e9pek396F7e tPb1KGTq1GqdLJN+VVonyPuJ/m3oCpJpiOen3pohP5FBf67vjJFqfo8tTPzXvDKwuML4 u5QGd5TrIlDfJfcXc2KfatFGIY+Pcb/ux+xhQ7dvs3eiLylx957A9FtOWvJbQtayfQoZ tN86kI3nNUHKdktYBCDLeZfsEozb3NzPDYWoH2SMP4Trr2NtjPtHYdjx2Tlh1xJeC57b Q3Wg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Guf4mfy+; 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-44fe8137ef3si159417031cf.51.2024.07.31.14.26.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Jul 2024 14:26: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=Guf4mfy+; 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 1sZGp7-0008M0-47; Wed, 31 Jul 2024 17:25: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 1sZGp5-0008LI-ON for qemu-devel@nongnu.org; Wed, 31 Jul 2024 17:25:27 -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 1sZGp4-0002EX-8x for qemu-devel@nongnu.org; Wed, 31 Jul 2024 17:25:27 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-428163f7635so39240965e9.2 for ; Wed, 31 Jul 2024 14:25:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722461124; x=1723065924; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UExLWm9ddjnMRPI0UADCJZeULFWbdE7wtbj111e1TQ4=; b=Guf4mfy+Pa4b4IAfKEe/iv+6c3fe8KtDPXzmyIC1wLKBfri+6rfzM+wRIrUNFbnYU6 23S/wgVHBz/Pbs34WjFTTWaP6N0kAk7xk3zSEidzH+kMKlo8783MeGCq9XufBSs7E1Kc lg2qTtW9OF3ICCrACvYL09Rs3yJtRD5RXQWrPVl6LUElAyYF2qjF/fRVWkSRDvHOMJQj NljPjo7SqBLK2G6XQX7DCum6YcxXDEdyQohrIIIGuHEe2zam5pJtZXEPl8DEjZ+Y4Jh0 mVCy37VPErc5KuYLnL2OHYsugEiBqxqc9i0xIBv9d0wCuu+xLLcxD1Q/bgMxGhmM7ewH pziQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722461124; x=1723065924; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UExLWm9ddjnMRPI0UADCJZeULFWbdE7wtbj111e1TQ4=; b=rQ0KZii78WgQSmDU4zfVn+j+J9EgrguGYFFzMWeFGZ9DosjVKdExl2hR1tkZPRR3pk cUPYH1bylX/Vdje1Hh6/AZPPFA4DNcyYknbxVYoqWClv03A19vxLfp4fvb/6SB7Ofxb9 nr6g6HpOJQ+3cfu9coIA80/slZVjkGSMOO0AzzAS9Ub5HWViyZbUjx+AWwd5TVrWn02/ NRXLuW6GOy019dpa4CQUSV02Zlep5PGkqLjg4gSMfUnzTQBV0vCZ1QHG9Z4JwZAT/A80 3dGq2j3XFW4yiIrUMct1srwgvhdnLA+YFkfeIwvgq9ATzpFF+5ZmVAHfiSLVsbyDMivC jNtQ== X-Gm-Message-State: AOJu0YzIiRUOVeROncAcC/ITwbm+5tKkoP8uXuIZr7KjsN++b+ZHjGHp /Lvq37nhmNz80MgRlMfurXKNG8x/49sfwxVSOjfkWjN9CO+FxW/sQ3h+B0et2xYaR1FRbiwT0vd z X-Received: by 2002:a5d:6701:0:b0:362:c7b3:764c with SMTP id ffacd0b85a97d-36baaf762b8mr227649f8f.48.1722461124140; Wed, 31 Jul 2024 14:25:24 -0700 (PDT) Received: from m1x-phil.lan ([176.176.130.148]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4282baccae2sm34983355e9.30.2024.07.31.14.25.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 31 Jul 2024 14:25:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng Subject: [PATCH-for-9.1? v2 3/4] hw/sd/sdhci: Read ADMA2_64 descriptor with a single dma_memory_read() Date: Wed, 31 Jul 2024 23:25:00 +0200 Message-ID: <20240731212501.44385-4-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731212501.44385-1-philmd@linaro.org> References: <20240731212501.44385-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=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 Instead of 3 consecutive dma_memory_read() calls, use a packed structure to read the descriptor in a single call. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sdhci.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 0a95f49b93..2d8fa3151a 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -740,16 +740,20 @@ static void get_adma_description(SDHCIState *s, ADMADescr *dscr) } case SDHC_CTRL_ADMA2_64: { - dma_memory_read(s->dma_as, entry_addr, &dscr->attr, 1, + struct { + uint8_t attr; + uint8_t pad; + uint16_t length; + uint64_t addr; + } QEMU_PACKED adma2; + QEMU_BUILD_BUG_ON(sizeof(adma2) != 12); + + dma_memory_read(s->dma_as, entry_addr, &adma2, sizeof(adma2), MEMTXATTRS_UNSPECIFIED); - dma_memory_read(s->dma_as, entry_addr + 2, &dscr->length, 2, - MEMTXATTRS_UNSPECIFIED); - dscr->length = le16_to_cpu(dscr->length); - dma_memory_read(s->dma_as, entry_addr + 4, &dscr->addr, 8, - MEMTXATTRS_UNSPECIFIED); - dscr->addr = le64_to_cpu(dscr->addr); - dscr->attr &= (uint8_t) ~0xC0; - dscr->incr = 12; + dscr->length = le16_to_cpu(adma2.length); + dscr->addr = le64_to_cpu(adma2.addr); + dscr->attr = adma2.attr & (uint8_t) ~0xc0; + dscr->incr = sizeof(adma2); trace_adma_description("ADMA2_64", dscr); break; }