From nobody Thu Dec 18 17:53:14 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1532357174039427.286839533882; Mon, 23 Jul 2018 07:46:14 -0700 (PDT) Received: from localhost ([::1]:34997 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhc6G-0002Hb-Ua for importer@patchew.org; Mon, 23 Jul 2018 10:46:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhc2B-0007XK-1c for qemu-devel@nongnu.org; Mon, 23 Jul 2018 10:42:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhc29-00083O-QK for qemu-devel@nongnu.org; Mon, 23 Jul 2018 10:41:59 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:43684) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fhc29-00081L-Ho for qemu-devel@nongnu.org; Mon, 23 Jul 2018 10:41:57 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1fhc26-0007iC-RZ for qemu-devel@nongnu.org; Mon, 23 Jul 2018 15:41:54 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:41:49 +0100 Message-Id: <20180723144152.13885-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723144152.13885-1-peter.maydell@linaro.org> References: <20180723144152.13885-1-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 2/5] hw/sd/bcm2835_sdhost: Fix PIO mode writes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Guenter Roeck Writes in PIO mode have two requirements: - A data interrupt must be generated after a write command has been issued to indicate that the chip is ready to receive data. - A block interrupt must be generated after each block to indicate that the chip is ready to receive the next data block. Rearrange the code to make this happen. Tested on raspi3 (in PIO mode) and raspi2 (in DMA mode). Signed-off-by: Guenter Roeck Message-id: 1531779837-20557-1-git-send-email-linux@roeck-us.net Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/sd/bcm2835_sdhost.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/hw/sd/bcm2835_sdhost.c b/hw/sd/bcm2835_sdhost.c index 4df4de7d675..1b760b2a7c1 100644 --- a/hw/sd/bcm2835_sdhost.c +++ b/hw/sd/bcm2835_sdhost.c @@ -179,9 +179,11 @@ static void bcm2835_sdhost_fifo_run(BCM2835SDHostState= *s) uint32_t value =3D 0; int n; int is_read; + int is_write; =20 is_read =3D (s->cmd & SDCMD_READ_CMD) !=3D 0; - if (s->datacnt !=3D 0 && (!is_read || sdbus_data_ready(&s->sdbus))) { + is_write =3D (s->cmd & SDCMD_WRITE_CMD) !=3D 0; + if (s->datacnt !=3D 0 && (is_write || sdbus_data_ready(&s->sdbus))) { if (is_read) { n =3D 0; while (s->datacnt && s->fifo_len < BCM2835_SDHOST_FIFO_LEN) { @@ -201,8 +203,11 @@ static void bcm2835_sdhost_fifo_run(BCM2835SDHostState= *s) if (n !=3D 0) { bcm2835_sdhost_fifo_push(s, value); s->status |=3D SDHSTS_DATA_FLAG; + if (s->config & SDHCFG_DATA_IRPT_EN) { + s->status |=3D SDHSTS_SDIO_IRPT; + } } - } else { /* write */ + } else if (is_write) { /* write */ n =3D 0; while (s->datacnt > 0 && (s->fifo_len > 0 || n > 0)) { if (n =3D=3D 0) { @@ -223,11 +228,18 @@ static void bcm2835_sdhost_fifo_run(BCM2835SDHostStat= e *s) s->edm &=3D ~SDEDM_FSM_MASK; s->edm |=3D SDEDM_FSM_DATAMODE; trace_bcm2835_sdhost_edm_change("datacnt 0", s->edm); - - if ((s->cmd & SDCMD_WRITE_CMD) && + } + if (is_write) { + /* set block interrupt at end of each block transfer */ + if (s->hbct && s->datacnt % s->hbct =3D=3D 0 && (s->config & SDHCFG_BLOCK_IRPT_EN)) { s->status |=3D SDHSTS_BLOCK_IRPT; } + /* set data interrupt after each transfer */ + s->status |=3D SDHSTS_DATA_FLAG; + if (s->config & SDHCFG_DATA_IRPT_EN) { + s->status |=3D SDHSTS_SDIO_IRPT; + } } } =20 --=20 2.17.1