Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp652660ybm; Fri, 29 May 2020 08:59:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBT2qCdqGXcHBGzqy5o7soB3aHeqGzgpXl3jx96OpFA5h21TzPm4wr4HyfEBs1YhQefpTW X-Received: by 2002:a05:6402:17a3:: with SMTP id j3mr9319146edy.137.1590767949120; Fri, 29 May 2020 08:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590767949; cv=none; d=google.com; s=arc-20160816; b=wY6vTgJpsBy0zOwgIcPq6vbjlZ4D0y3rwFILkaLHSH9hMUCX2CBABe9SRgXCv7wAgf 8eHE/3TLgbHiA/gDioaxaCV8vJQx6uMK6dN95KPHz6TUDVNfrotGEylRaYpHd0mmMfmX wxNsSRlAGnTXzUgaiYSE6FvZD2cn8jesk97uxVejKwukgM46dXmGMz+v1b7WShCw+AaM PAs4JdlHDu1SNcvXTJvAUDcgKVxwtKh8Z1nfDmhvb8PxDw71vffjxP8egC09l6CJmBJv SA/7kPGzB37q6ufRWAzkbl/0WLkaiRZAUIXjLeL8xRFF2gmdcbI41FwT4FpXILXqotT3 rOog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=xcuMHREdERpFsOPo0aMF2ppE8bx68pyxfsDlWXOE7+w=; b=vwO86BHkTuYqXLUVuMTCh37TwZzCd4yebSGdxiPoK59UV7i4JPoqqolCxKGb2CU209 b4stRKPi26nWe8YPDueFriWhY7v9/pN4EhwnyYva3eVEGkXjjDvKWaGNBvBhqAj2h8H4 CwmrM93j/8etaI2WzyLc93VFt5HZEpZUhI8lsAHM15+Z/KjWLHcixtFWpwz+/E63eMxC ELZ6jSPy/+WSopPDrlCmmwWNM3/QLVOkwdr6vFsjVUS8Ug9v+Eu/pjJAX4gjV1yNWINh nMyy/2w9dSqoz7edjXJzJBvPPXco+Ny9xrk0aCCIOm17Cx/qPNY/cy7U896XUoGGkQaw VEQA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n6si6271118eda.5.2020.05.29.08.58.45; Fri, 29 May 2020 08:59:09 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727851AbgE2P4v (ORCPT + 99 others); Fri, 29 May 2020 11:56:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:53090 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbgE2P4v (ORCPT ); Fri, 29 May 2020 11:56:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9CCE2ACB8; Fri, 29 May 2020 15:56:48 +0000 (UTC) Subject: Re: [PATCH 1/1] tty: serial: owl: Add support for kernel debugger To: Cristian Ciocaltea Cc: Manivannan Sadhasivam , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-actions@lists.infradead.org References: <6ee88060c129715980592a1ae33c93923916a14b.1590766726.git.cristian.ciocaltea@gmail.com> From: =?UTF-8?Q?Andreas_F=c3=a4rber?= Organization: SUSE Software Solutions Germany GmbH Message-ID: <16ff435f-9172-e01d-dfe6-7aa8575c4bd6@suse.de> Date: Fri, 29 May 2020 17:56:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <6ee88060c129715980592a1ae33c93923916a14b.1590766726.git.cristian.ciocaltea@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Am 29.05.20 um 17:50 schrieb Cristian Ciocaltea: > Implement poll_put_char and poll_get_char callbacks in struct uart_ops > that enables OWL UART to be used for KGDB debugging over serial line. > > Signed-off-by: Cristian Ciocaltea > --- > drivers/tty/serial/owl-uart.c | 45 ++++++++++++++++++++++++++++++----- > 1 file changed, 39 insertions(+), 6 deletions(-) > > diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c > index c2fa2f15d50a..26dcc374dec5 100644 > --- a/drivers/tty/serial/owl-uart.c > +++ b/drivers/tty/serial/owl-uart.c > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -20,13 +21,13 @@ > #include > #include > > -#define OWL_UART_PORT_NUM 7 > -#define OWL_UART_DEV_NAME "ttyOWL" > +#define OWL_UART_PORT_NUM 7 > +#define OWL_UART_DEV_NAME "ttyOWL" > > -#define OWL_UART_CTL 0x000 > -#define OWL_UART_RXDAT 0x004 > -#define OWL_UART_TXDAT 0x008 > -#define OWL_UART_STAT 0x00c > +#define OWL_UART_CTL 0x000 > +#define OWL_UART_RXDAT 0x004 > +#define OWL_UART_TXDAT 0x008 > +#define OWL_UART_STAT 0x00c Please do not unnecessarily re-indent kernel code. You can do so when you're actually adding something new. > > #define OWL_UART_CTL_DWLS_MASK GENMASK(1, 0) > #define OWL_UART_CTL_DWLS_5BITS (0x0 << 0) > @@ -461,6 +462,34 @@ static void owl_uart_config_port(struct uart_port *port, int flags) > } > } > > +#ifdef CONFIG_CONSOLE_POLL > + > +static int owl_uart_poll_get_char(struct uart_port *port) > +{ > + u32 c = NO_POLL_CHAR; > + > + if (!(owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_RFEM)) > + c = owl_uart_read(port, OWL_UART_RXDAT); > + > + return c; > +} > + > +static void owl_uart_poll_put_char(struct uart_port *port, unsigned char c) > +{ > + /* Wait while TX FIFO is full */ > + while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU) > + cpu_relax(); > + > + /* Send the character out */ > + owl_uart_write(port, c, OWL_UART_TXDAT); > + > + /* Wait for transmitter to become empty */ > + while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TRFL_MASK) > + cpu_relax(); > +} How is this different from earlycon? I dislike that this is being open-coded. Please try to reuse existing functions for this. Regards, Andreas > + > +#endif /* CONFIG_CONSOLE_POLL */ > + > static const struct uart_ops owl_uart_ops = { > .set_mctrl = owl_uart_set_mctrl, > .get_mctrl = owl_uart_get_mctrl, > @@ -476,6 +505,10 @@ static const struct uart_ops owl_uart_ops = { > .request_port = owl_uart_request_port, > .release_port = owl_uart_release_port, > .verify_port = owl_uart_verify_port, > +#ifdef CONFIG_CONSOLE_POLL > + .poll_get_char = owl_uart_poll_get_char, > + .poll_put_char = owl_uart_poll_put_char, > +#endif > }; > > #ifdef CONFIG_SERIAL_OWL_CONSOLE > -- SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer HRB 36809 (AG Nürnberg)