Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp728835ybt; Fri, 10 Jul 2020 10:49:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJze+bLAVbzKzuVMBOWvts9eFRQew8FUGXjZNjaYJLUJSumBkTbAZ5YAOfQG/sXmAImqyBFR X-Received: by 2002:a17:906:4dcc:: with SMTP id f12mr64146515ejw.401.1594403375322; Fri, 10 Jul 2020 10:49:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594403375; cv=none; d=google.com; s=arc-20160816; b=fB9Wy35I8qtkBm4FWXba4Ta3m/VzDE9KDRu/5su8bcnLQ7SzsUTSZFZjRmPTCm7Mqe qWMom2LdyXUqkUDsFPDR6nyqZq7kWQOy5l4GHh+gulBtNR+WMI16BbT616g0zn/eTZJ0 ZilfogSjd1mKjG9sCkU6Sw+hOB+UJqFVJAJRcS3wzGul6E2hBRQjTVsgGPPGmmgA4WX2 kNsKooeqMTd3VmHu4ibaafVdGJ5FM2kzrQGxSJVLlF7qxC4DTG0yTZCmxiC0ZqSIVv6O SPvFP8PZpAxR5XUKOQxXK3wCsMmn4iyjUSljHwTb7OnLLSk1F7XgEDZobmaRdeD6HXH/ emGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=m/CMHk4w6+cNFzgYJXIzp3UU76Y8y9UeHEGOkUVbXTU=; b=0Dw0RzWm+AteTvhC6dJ2A054ihgIHjMdSjPYY15NM1mOi5MZKqKMVXDIvVYfuT3UVQ pd4OlN72BncPDK0XXdn6j0QoPrZh2GsfiLdGVWfnLQspjGUh//CMqil2iSwg/hRpK/c+ Cb4J31NXEfMf77Q0Mnc7EHU5WfhWkKvBN52kpyJcIgytlJwn8S2Di3UuR0hLHnCbLno4 mr2sFDuZAbBGIOt+lnWWm8eDCraGQmF2XqsNzIfZ8YXqdlyjZ/JVlNYBlUrSZjoLIRXv 6S0llrnTzkJVj6z3t5cL9fOu8TXZU4qTdhXPpL9FZ9NDBam6z34rpEiRaX4d+MVeqlaD jqGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ILDYVm0L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g26si4565145edv.376.2020.07.10.10.49.12; Fri, 10 Jul 2020 10:49:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ILDYVm0L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727085AbgGJRrB (ORCPT + 99 others); Fri, 10 Jul 2020 13:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726820AbgGJRrB (ORCPT ); Fri, 10 Jul 2020 13:47:01 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07FB1C08C5DC for ; Fri, 10 Jul 2020 10:47:01 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id t9so3677796lfl.5 for ; Fri, 10 Jul 2020 10:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=m/CMHk4w6+cNFzgYJXIzp3UU76Y8y9UeHEGOkUVbXTU=; b=ILDYVm0LcXLZZrfmAxtURkQprTX9skjAShvhFipQKJAKbFGyoFEeZfJniL4uh1sJtQ 6GQsddyIJ/M36EE7v0/XiEEynwtBixNj1dz7zWXkp46lP3Sbmpdp/lJneh5gVSnuRIoP uDZ95SWe4tPPb6v31ajhDIGF2FUlWNiVlWd+8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=m/CMHk4w6+cNFzgYJXIzp3UU76Y8y9UeHEGOkUVbXTU=; b=rl3Cu49tVxkL9WOTXYkVAcObu5RjIRQKg/LNai6ojRrKujAo/PAuDQ1dYwCkg5sYjU SXor94IQt01WpFz657ieCExxJrD6S3IHXqnWYNwA3h2QnD//SPsF4HFt/uNcG8G8ynb1 8vfEDAkUq/eiPv9QwvHLngae7oqvvHRb2MuVz9Tul5rfX8hS0ytu8A/Stg2Js15wYRri qf4g6uWz5Sdu9kdY3fFLXpI+irQXfGjLiMtR8FyK/3XoO1lTv3vwSLkUUZtaPfJ7BLGX baPLw1oErXQrwzqGIeRPRI29kMCXc9RjBPmIzT4fSCFBUZE3b3xAX2o1RoA39ocE+4N7 OLbg== X-Gm-Message-State: AOAM5306LkAIuXDY5vr8ZjKozxK072ui3n2X7HlQ0M8aWqZ2bIXOqPQW dNFSOQPUzgHb6QX/qK6uTpjq91t8UX8= X-Received: by 2002:a19:83c7:: with SMTP id f190mr44731849lfd.14.1594403219184; Fri, 10 Jul 2020 10:46:59 -0700 (PDT) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com. [209.85.208.169]) by smtp.gmail.com with ESMTPSA id e10sm2101663ljb.118.2020.07.10.10.46.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jul 2020 10:46:58 -0700 (PDT) Received: by mail-lj1-f169.google.com with SMTP id h19so7364747ljg.13 for ; Fri, 10 Jul 2020 10:46:58 -0700 (PDT) X-Received: by 2002:ac2:44b2:: with SMTP id c18mr42517426lfm.99.1594402767378; Fri, 10 Jul 2020 10:39:27 -0700 (PDT) MIME-Version: 1.0 References: <20200626200033.1528052-1-dianders@chromium.org> <20200626125844.2.Iabd56347670b9e4e916422773aba5b27943d19ee@changeid> In-Reply-To: <20200626125844.2.Iabd56347670b9e4e916422773aba5b27943d19ee@changeid> From: Evan Green Date: Fri, 10 Jul 2020 10:38:50 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] serial: qcom_geni_serial: Always use 4 bytes per TX FIFO word To: Douglas Anderson Cc: Greg Kroah-Hartman , daniel.thompson@linaro.org, Akash Asthana , Stephen Boyd , kgdb-bugreport@lists.sourceforge.net, linux-arm-msm , sumit.garg@linaro.org, Vivek Gautam , Andy Gross , Bjorn Andersson , Jiri Slaby , LKML , linux-serial@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 26, 2020 at 1:01 PM Douglas Anderson wrote: > > The geni serial driver had a rule that we'd only use 1 byte per FIFO > word for the TX FIFO if we were being used for the serial console. > This is ugly and a bit of a pain. It's not too hard to fix, so fix > it. > > Signed-off-by: Douglas Anderson > --- > > drivers/tty/serial/qcom_geni_serial.c | 57 +++++++++++++++++---------- > 1 file changed, 37 insertions(+), 20 deletions(-) > > diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c > index 4610e391e886..583d903321b5 100644 > --- a/drivers/tty/serial/qcom_geni_serial.c > +++ b/drivers/tty/serial/qcom_geni_serial.c > @@ -103,12 +103,18 @@ > #define DEFAULT_IO_MACRO_IO2_IO3_MASK GENMASK(15, 4) > #define IO_MACRO_IO2_IO3_SWAP 0x4640 > > +/* We always configure 4 bytes per FIFO word */ > +#define BYTES_PER_FIFO_WORD 4 > + > struct qcom_geni_private_data { > /* NOTE: earlycon port will have NULL here */ > struct uart_driver *drv; > > u32 poll_cached_bytes; > unsigned int poll_cached_bytes_cnt; > + > + u32 write_cached_bytes; > + unsigned int write_cached_bytes_cnt; > }; > > struct qcom_geni_serial_port { > @@ -121,8 +127,6 @@ struct qcom_geni_serial_port { > bool setup; > int (*handle_rx)(struct uart_port *uport, u32 bytes, bool drop); > unsigned int baud; > - unsigned int tx_bytes_pw; > - unsigned int rx_bytes_pw; > void *rx_fifo; > u32 loopback; > bool brk; > @@ -390,13 +394,25 @@ static void qcom_geni_serial_poll_put_char(struct uart_port *uport, > #ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE > static void qcom_geni_serial_wr_char(struct uart_port *uport, int ch) > { > - writel(ch, uport->membase + SE_GENI_TX_FIFOn); > + struct qcom_geni_private_data *private_data = uport->private_data; > + > + private_data->write_cached_bytes = > + (private_data->write_cached_bytes >> 8) | (ch << 24); > + private_data->write_cached_bytes_cnt++; > + > + if (private_data->write_cached_bytes_cnt == BYTES_PER_FIFO_WORD) { > + writel(private_data->write_cached_bytes, > + uport->membase + SE_GENI_TX_FIFOn); > + private_data->write_cached_bytes_cnt = 0; > + } > } > > static void > __qcom_geni_serial_console_write(struct uart_port *uport, const char *s, > unsigned int count) > { > + struct qcom_geni_private_data *private_data = uport->private_data; > + > int i; > u32 bytes_to_send = count; > > @@ -431,6 +447,15 @@ __qcom_geni_serial_console_write(struct uart_port *uport, const char *s, > SE_GENI_M_IRQ_CLEAR); > i += chars_to_write; > } > + > + if (private_data->write_cached_bytes_cnt) { > + private_data->write_cached_bytes >>= BITS_PER_BYTE * > + (BYTES_PER_FIFO_WORD - private_data->write_cached_bytes_cnt); > + writel(private_data->write_cached_bytes, > + uport->membase + SE_GENI_TX_FIFOn); > + private_data->write_cached_bytes_cnt = 0; > + } How does this not end up sending stray zeros? In other words, how does the hardware know which bytes of this word are valid?