From nobody Thu May 8 14:39:30 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1579802208; cv=none; d=zohomail.com; s=zohoarc; b=AifNLKioSlFnvBI2GzEAUHKzEWE1cA5C6KTKtvosi18O+SJjximyVfvK1Gro3nM45E7FrtOdBXuz1oPc/TjDYfmGuezayFiqPq9Dh8OvHNI0GA1vOgottXmj0HnC8dU3eBbj1ZX1pLA3vagRcuDeaZOBKH1hHxnSWt95diTSx9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579802208; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N4iqzc8HVW3cMRomMguzId5zTp6jmQsqn0qSxi9wOqY=; b=n0/mnmb0A1YohqSnynCV/LdyJu6hW+oaK24NDb3Wken+zUKvWBuowUno8N4sDlH6GJ5+lcYORerwj8QnFfdhYRN18OlriD5h55g2X9b4Y08ra3qnGh5mSvEA+DnHFvIFq7bmuMea9CKyUhfKIYdo3lVd5dpKnva7eVZ3XmZJ3ic= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from=<peter.maydell@linaro.org> (p=none dis=none) header.from=<peter.maydell@linaro.org> Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579802208407425.2647252479974; Thu, 23 Jan 2020 09:56:48 -0800 (PST) Received: from localhost ([::1]:34086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1iugik-0004xz-SG for importer@patchew.org; Thu, 23 Jan 2020 12:56:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48532) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <peter.maydell@linaro.org>) id 1iueRr-0000We-3E for qemu-devel@nongnu.org; Thu, 23 Jan 2020 10:31:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <peter.maydell@linaro.org>) id 1iueRn-0003zO-2F for qemu-devel@nongnu.org; Thu, 23 Jan 2020 10:31:10 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:40248) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <peter.maydell@linaro.org>) id 1iueRl-0003y5-Ht for qemu-devel@nongnu.org; Thu, 23 Jan 2020 10:31:06 -0500 Received: by mail-wr1-x42c.google.com with SMTP id c14so3537800wrn.7 for <qemu-devel@nongnu.org>; Thu, 23 Jan 2020 07:31:05 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id s139sm2903592wme.35.2020.01.23.07.31.02 for <qemu-devel@nongnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 07:31:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=N4iqzc8HVW3cMRomMguzId5zTp6jmQsqn0qSxi9wOqY=; b=BeXWbyXpEAyK9bGvke2mOF6uegOfthWlX5Vw6rTf4cMobJpXiKVfvMdGRZ0Nnti32j hnES5yhNH4vSemege2ITAkv27l2pVay/RF/MJCTHQ9xsxBkke1pAggTwD8MGPDrRtui5 SabIU8JOgQ+AXuVls/RRzEzaLTMhzrw7rXuf2Dw4oWowuny3g9jLMAwCJrK3diNkYbM6 Y6YFUc9EK7h4dYWhvRYwrDy60FAlS69+m4L8BF1SopTlt6xgyJP3LUx4vix/UL+Ad0U7 HLyykPGH7x+b9hqnSmbISNJzlO2kWzIOEwQTDP2G8mcCjfiJHUoF1lQ/tf/Ei1r8nPb1 ZRxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N4iqzc8HVW3cMRomMguzId5zTp6jmQsqn0qSxi9wOqY=; b=qC6xtQt84GgMCe80hQjeyoT2UyyaRgjOatWeIpzY5gKdmBQEvAt3/ZxqZcesi3tq/B J2vrpuS35sGd2ild2Fmna1MiaHI2E4qqkOy4OoZUzENxsXqEcUn35RQfCyb+CqLjpjsD YIRel6hjIkUU27czoaY2H0piSFuypmW+RDOrMTxrFCDsjIROXQIJa0NNUw5aa10Rekbq LQLJ/c4oEpr7AMaAOVUV2ouxvzanzNg5eCZWQEV/21GNB6TjeDdAiCCRxswKx/JNlAUY tlrVW4oP/Xy4NbsCf88vc/MipphSHhft0lvhLp+ezkaP/LRtjm4WAgQT0sIAxOHi7dfa Qmtw== X-Gm-Message-State: APjAAAVDxi5dfAfoqmbO2KJjAL+IuXxr5ylnAltK9eatb1Jwo/fRpEHc XkD/VMFV51fI7d0/ISNTF0hUZd4yJeU4sw== X-Google-Smtp-Source: APXvYqy5sND+rDFSvdkAF2iacc5J7qxNBavfyY0t/Cy0uxGJgih1BrSOLw7nh0IMYlsB5v/H3BFr8w== X-Received: by 2002:a5d:540f:: with SMTP id g15mr17459446wrv.86.1579793463792; Thu, 23 Jan 2020 07:31:03 -0800 (PST) From: Peter Maydell <peter.maydell@linaro.org> To: qemu-devel@nongnu.org Subject: [PULL 19/20] hw/char/exynos4210_uart: Add receive DMA support Date: Thu, 23 Jan 2020 15:30:40 +0000 Message-Id: <20200123153041.4248-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200123153041.4248-1-peter.maydell@linaro.org> References: <20200123153041.4248-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Guenter Roeck <linux@roeck-us.net> To support receive DMA, we need to inform the DMA controller if receive data is available. Otherwise the DMA controller keeps requesting data, causing receive errors. Implement this using an interrupt line. The instantiating code then needs to connect the interrupt with the matching DMA controller GPIO pin. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Message-id: 20200123052540.6132-8-linux@roeck-us.net Signed-off-by: Peter Maydell <peter.maydell@linaro.org> --- hw/char/exynos4210_uart.c | 24 ++++++++++++++++++++++++ hw/char/trace-events | 2 ++ 2 files changed, 26 insertions(+) diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c index 363393cc753..20d85091072 100644 --- a/hw/char/exynos4210_uart.c +++ b/hw/char/exynos4210_uart.c @@ -154,6 +154,7 @@ typedef struct Exynos4210UartState { =20 CharBackend chr; qemu_irq irq; + qemu_irq dmairq; =20 uint32_t channel; =20 @@ -261,6 +262,24 @@ exynos4210_uart_Rx_FIFO_trigger_level(const Exynos4210= UartState *s) return exynos4210_uart_FIFO_trigger_level(s->channel, reg); } =20 +/* + * Update Rx DMA busy signal if Rx DMA is enabled. For simplicity, + * mark DMA as busy if DMA is enabled and the receive buffer is empty. + */ +static void exynos4210_uart_update_dmabusy(Exynos4210UartState *s) +{ + bool rx_dma_enabled =3D (s->reg[I_(UCON)] & 0x03) =3D=3D 0x02; + uint32_t count =3D fifo_elements_number(&s->rx); + + if (rx_dma_enabled && !count) { + qemu_irq_raise(s->dmairq); + trace_exynos_uart_dmabusy(s->channel); + } else { + qemu_irq_lower(s->dmairq); + trace_exynos_uart_dmaready(s->channel); + } +} + static void exynos4210_uart_update_irq(Exynos4210UartState *s) { /* @@ -282,10 +301,12 @@ static void exynos4210_uart_update_irq(Exynos4210Uart= State *s) count =3D fifo_elements_number(&s->rx); if ((count && !(s->reg[I_(UCON)] & 0x80)) || count >=3D exynos4210_uart_Rx_FIFO_trigger_level(s)) { + exynos4210_uart_update_dmabusy(s); s->reg[I_(UINTSP)] |=3D UINTSP_RXD; timer_del(s->fifo_timeout_timer); } } else if (s->reg[I_(UTRSTAT)] & UTRSTAT_Rx_BUFFER_DATA_READY) { + exynos4210_uart_update_dmabusy(s); s->reg[I_(UINTSP)] |=3D UINTSP_RXD; } =20 @@ -311,6 +332,7 @@ static void exynos4210_uart_timeout_int(void *opaque) (s->reg[I_(UCON)] & (1 << 11))) { s->reg[I_(UINTSP)] |=3D UINTSP_RXD; s->reg[I_(UTRSTAT)] |=3D UTRSTAT_Rx_TIMEOUT; + exynos4210_uart_update_dmabusy(s); exynos4210_uart_update_irq(s); } } @@ -495,6 +517,7 @@ static uint64_t exynos4210_uart_read(void *opaque, hwad= dr offset, s->reg[I_(UTRSTAT)] &=3D ~UTRSTAT_Rx_BUFFER_DATA_READY; res =3D s->reg[I_(URXH)]; } + exynos4210_uart_update_dmabusy(s); trace_exynos_uart_read(s->channel, offset, exynos4210_uart_regname(offset), res); return res; @@ -661,6 +684,7 @@ static void exynos4210_uart_init(Object *obj) sysbus_init_mmio(dev, &s->iomem); =20 sysbus_init_irq(dev, &s->irq); + sysbus_init_irq(dev, &s->dmairq); } =20 static void exynos4210_uart_realize(DeviceState *dev, Error **errp) diff --git a/hw/char/trace-events b/hw/char/trace-events index cb73fee6a9d..6f938301d98 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -79,6 +79,8 @@ nrf51_uart_read(uint64_t addr, uint64_t r, unsigned int s= ize) "addr 0x%" PRIx64 nrf51_uart_write(uint64_t addr, uint64_t value, unsigned int size) "addr 0= x%" PRIx64 " value 0x%" PRIx64 " size %u" =20 # exynos4210_uart.c +exynos_uart_dmabusy(uint32_t channel) "UART%d: DMA busy (Rx buffer empty)" +exynos_uart_dmaready(uint32_t channel) "UART%d: DMA ready" exynos_uart_irq_raised(uint32_t channel, uint32_t reg) "UART%d: IRQ raised= : 0x%08"PRIx32 exynos_uart_irq_lowered(uint32_t channel) "UART%d: IRQ lowered" exynos_uart_update_params(uint32_t channel, int speed, uint8_t parity, int= data, int stop, uint64_t wordtime) "UART%d: speed: %d, parity: %c, data bi= ts: %d, stop bits: %d wordtime: %"PRId64"ns" --=20 2.20.1