From nobody Thu Sep 18 23:31:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15EF2C4332F for ; Fri, 2 Dec 2022 08:57:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232764AbiLBI5F (ORCPT ); Fri, 2 Dec 2022 03:57:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232810AbiLBI4Y (ORCPT ); Fri, 2 Dec 2022 03:56:24 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5744BEC45 for ; Fri, 2 Dec 2022 00:56:05 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id y16so6800949wrm.2 for ; Fri, 02 Dec 2022 00:56:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; 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=h9KBlEE4azsWDdEqHoIw3zf1p218z3Yb8Z5E0IDcw8M=; b=SkUvqcIAd73kDG42S6QB6U76WvXAzT/BOgDjn10hVqfNl12MhimRk/M1zOxlQZs477 gqQlU4L+UDnx94Z8r+153WErEZDY6kPYaj8r12w+JSkFdHulDnoOCnFwEru0Hwa6ddlf DazhVeJimLSunp4EVMYe7N48+yRfBdW+4iLi+1O7S8leBwAdYeYLCVJlcgltc11z7Po6 uPBuADvmfidd8+BknjDWreVMz6I1XvpIoTgB5RM9S35qsSNiWJiILmwxTOrTuIqZNEw5 A6Vf7fmE8IiaF+D9pbCEGsM/6yUQIpRycclDsaDRyfLnYiPjhZZ8m98ydP5fmImtNJEV MTPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=h9KBlEE4azsWDdEqHoIw3zf1p218z3Yb8Z5E0IDcw8M=; b=EIMj2SlG2TZwSDkYvgM85Vz+jHz30LhL5ZKXZKwqNhsX1iumBjN+H65nH7hn1CN7jW yjzzPQxWN0VDAXx5qOY37CJRc2VHmg3o+d+H0eIV5PvxSxdEDJZ4f8THxgIfOudiWLie cHWRtproUzbmjWZU95tiyX5OM7NqAlgo+/HB0Tt3HviYK8MLPlPgjzG4+Dp/Yj48UXWp RbkWB2IUzN0VIv6o4T9yn0EIYC3835w4TWcX+Q9QWqArvLlmCIoEW+81j7Fw6SM0PEBe RAl5xk9+Lf+co3LW8m8BPgLQ7sXS43kwbra6TPHJEvWRBS0DA4LHG/XeSj4Q8dlnkruw wHvA== X-Gm-Message-State: ANoB5pnZs0TBIluu0vXUjQ48xDJ/zXtaIdPnJUO0+crNwmLIpLLjCU6h fG4hHXiNMzSmShXIzSSMAyGZDg== X-Google-Smtp-Source: AA0mqf5b5ms65cPJXa1FoxhdEHJjBXpIj4wTipcyyNx37CsRn0kmBt/StwmPIy2w70s+JS7jPeUPbA== X-Received: by 2002:a5d:4149:0:b0:242:149c:5690 with SMTP id c9-20020a5d4149000000b00242149c5690mr15384879wrq.491.1669971365264; Fri, 02 Dec 2022 00:56:05 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:29a4:6f04:ddb1:1ed7]) by smtp.gmail.com with ESMTPSA id a13-20020adfed0d000000b0024219b1cb1bsm6527517wro.60.2022.12.02.00.56.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 00:56:04 -0800 (PST) From: Bartosz Golaszewski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Greg Kroah-Hartman , Jiri Slaby , Srinivas Kandagatla , Vinod Koul , Alex Elder , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 08/14] tty: serial: qcom-geni-serial: split out the FIFO tx code Date: Fri, 2 Dec 2022 09:55:48 +0100 Message-Id: <20221202085554.59637-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221202085554.59637-1-brgl@bgdev.pl> References: <20221202085554.59637-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski qcom_geni_serial_handle_tx() is pretty big, let's move the code that handles the actual writing of data to a separate function which makes sense in preparation for introducing a dma variant of handle_tx(). Signed-off-by: Bartosz Golaszewski --- drivers/tty/serial/qcom_geni_serial.c | 60 +++++++++++++++------------ 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qco= m_geni_serial.c index 68a1402fbe58..91336d2d20fc 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -704,19 +704,48 @@ static void qcom_geni_serial_start_rx(struct uart_por= t *uport) writel(irq_en, uport->membase + SE_GENI_M_IRQ_EN); } =20 +static int qcom_geni_serial_send_chunk_fifo(struct uart_port *uport, + unsigned int chunk) +{ + struct qcom_geni_serial_port *port =3D to_dev_port(uport); + struct circ_buf *xmit =3D &uport->state->xmit; + size_t remaining =3D chunk; + int i, tail =3D xmit->tail; + + for (i =3D 0; i < chunk; ) { + unsigned int tx_bytes; + u8 buf[sizeof(u32)]; + int c; + + memset(buf, 0, sizeof(buf)); + tx_bytes =3D min_t(size_t, remaining, BYTES_PER_FIFO_WORD); + + for (c =3D 0; c < tx_bytes ; c++) { + buf[c] =3D xmit->buf[tail++]; + tail &=3D UART_XMIT_SIZE - 1; + } + + iowrite32_rep(uport->membase + SE_GENI_TX_FIFOn, buf, 1); + + i +=3D tx_bytes; + uport->icount.tx +=3D tx_bytes; + remaining -=3D tx_bytes; + port->tx_remaining -=3D tx_bytes; + } + + return tail; +} + static void qcom_geni_serial_handle_tx(struct uart_port *uport, bool done, bool active) { struct qcom_geni_serial_port *port =3D to_dev_port(uport); struct circ_buf *xmit =3D &uport->state->xmit; size_t avail; - size_t remaining; size_t pending; - int i; u32 status; u32 irq_en; unsigned int chunk; - int tail; =20 status =3D readl(uport->membase + SE_GENI_TX_FIFO_STATUS); =20 @@ -735,7 +764,6 @@ static void qcom_geni_serial_handle_tx(struct uart_port= *uport, bool done, avail =3D port->tx_fifo_depth - (status & TX_FIFO_WC); avail *=3D BYTES_PER_FIFO_WORD; =20 - tail =3D xmit->tail; chunk =3D min(avail, pending); if (!chunk) goto out_write_wakeup; @@ -750,29 +778,7 @@ static void qcom_geni_serial_handle_tx(struct uart_por= t *uport, bool done, uport->membase + SE_GENI_M_IRQ_EN); } =20 - remaining =3D chunk; - for (i =3D 0; i < chunk; ) { - unsigned int tx_bytes; - u8 buf[sizeof(u32)]; - int c; - - memset(buf, 0, sizeof(buf)); - tx_bytes =3D min_t(size_t, remaining, BYTES_PER_FIFO_WORD); - - for (c =3D 0; c < tx_bytes ; c++) { - buf[c] =3D xmit->buf[tail++]; - tail &=3D UART_XMIT_SIZE - 1; - } - - iowrite32_rep(uport->membase + SE_GENI_TX_FIFOn, buf, 1); - - i +=3D tx_bytes; - uport->icount.tx +=3D tx_bytes; - remaining -=3D tx_bytes; - port->tx_remaining -=3D tx_bytes; - } - - xmit->tail =3D tail; + xmit->tail =3D qcom_geni_serial_send_chunk_fifo(uport, chunk); =20 /* * The tx fifo watermark is level triggered and latched. Though we had --=20 2.37.2