Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp607605imj; Thu, 7 Feb 2019 09:06:30 -0800 (PST) X-Google-Smtp-Source: AHgI3IaPcS5LtjjZ/cBxRSmdXERCoGLnMqxo1ZItadg+u8c329hY0StqtqJhGPa14SDWpijsGWku X-Received: by 2002:a63:83:: with SMTP id 125mr15391164pga.343.1549559190343; Thu, 07 Feb 2019 09:06:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549559190; cv=none; d=google.com; s=arc-20160816; b=kQTtsiZNTJaIRaoAdfsGRR/zmJl9wvgQ5HXN+doXdwCjzH7t71r1w2dfYD2ttBzzds X1bQMf8kRHynlkXto5KyaQ0hkR5l08aJbSitEsFnjsslwFg+6e1jmXqhI+jTUsgPG1Zk cK6+taXd22CWzeuW3itPFbXA1aiRGgsbzi5Fj3vF93J08UygFsUXI5m0nRN3c6TVLqI6 roct5hk8VmWJC7FktWG5K+FoO8RJ0tpc5UrqgWd9CaOGGdV2T6vu4yI2uZH7FiI7JcVG u4oFnZc5lYFV91tEmByB0oqxpMT1LOzMxKGpdQGXXhCItNyFDdv/oiaqul2SG8vBnFG+ 7LHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:in-reply-to :subject:cc:to:from:user-agent:references:dkim-signature; bh=bfb6XdLQBuwV8OQUhWtqHzyKLHZ6Wl3/PspPxQktHO4=; b=Xt776+epPw8nFnv80GZUgLTVIM27mbIqtXGiGlnL50DdlL/qRd3e3l/xhNdL+H1qzI 59/MXhda363ZGhO68Lx+hOkOKie72YWeI7CtSn2CMe0Mv9ajWnHZx2cPc9P1dU/Vdw6Q vDGYxrzIGrRvLPHB+ZKiAdHCHvYM7Uwu4j9KhgbCzg4oS2ygQjKF4R75rweOVE7ScuCe Jdv1mpHbd7CoQw/ow40RKnIJ3+94KtzC8Bv+vEoemu9YW8pSTyEu66MT5cUJ4BwGec+i mw4sQmSNq8YuTORFJ9KkKm2gg2szjm43aFJBhexCKNoclHeLr7zL3wu/CaA+CxuoXBKB mmxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=E1cC3KC5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si9618066pld.71.2019.02.07.09.06.07; Thu, 07 Feb 2019 09:06:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=E1cC3KC5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726775AbfBGREl (ORCPT + 99 others); Thu, 7 Feb 2019 12:04:41 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39850 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbfBGREk (ORCPT ); Thu, 7 Feb 2019 12:04:40 -0500 Received: by mail-wr1-f66.google.com with SMTP id t27so628410wra.6 for ; Thu, 07 Feb 2019 09:04:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=bfb6XdLQBuwV8OQUhWtqHzyKLHZ6Wl3/PspPxQktHO4=; b=E1cC3KC5QRuzfMjm1loXWevDg4KYVtgl3C0NpApKqGDrPpTX+j6U8q4W2Gru3QJgMi KbWkVGm25qOxJkitEwOi2Adso7QZat2OA4xqSR66ywHFhgAxKVYi340a56QJiS6Mh5oK 7OCp+o77YsLTMqyv8/p3/eU8XHoBm3Nbb9jsFGnhg+z0a6mpU5dMP0V4ZkDRdVHLMdxr 0s5CnDv6H+TPcYldNp3dcHf8DX0rsyvfvSn6fDTh6rFzb5UVAuhNY7pvQAJPNOB6azz4 +ulsoy72uQhm+MW7BRqD169R2LzOcM2/ERBAo54dPVjmpk/iNoT9XAkSTAmArloFUd6I MOrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=bfb6XdLQBuwV8OQUhWtqHzyKLHZ6Wl3/PspPxQktHO4=; b=cTBM4mEThgWXLzLrlbPQTvvOlzg+pfwTmZbLmuq5Ls649opzxYIlbFGTFCsnH35Kw5 9UDApArTnIC4NibtBTvILqrbeoDUGOnckmJutHJsQPtvE8iTTBbyEnjQNP9knvMxOEfo kD6oTsqIVbNRsoxrEvQWpRSoMr9ssR++YkOldSLTao2chS3agkVk/UP4a6LjYyow4t72 XirTnGWKRP47apOUJ2hX1EhmSqL/RU74qZlLy+U/Tc5lM0KrChK5hcVZPzVUOAvBWBRD 24JL/KfYLBZorXditJAj+QSpd/5Ng7ARXrd+xf7Ghf9eIx0gt0jl4pEvGGUgB7mcZ3nY FJ9w== X-Gm-Message-State: AHQUAuajlrwVxpqCyQboTbL9NpnlKjvw5Ndx+ZyyhBc8+cdk49yoc6// 0wuFb+wF3UIzYPVw1xj43h/rhg== X-Received: by 2002:a5d:558a:: with SMTP id i10mr12577380wrv.287.1549559079224; Thu, 07 Feb 2019 09:04:39 -0800 (PST) Received: from localhost ([2620:10d:c092:180::1:a0f9]) by smtp.gmail.com with ESMTPSA id g67sm38726172wmd.38.2019.02.07.09.04.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Feb 2019 09:04:38 -0800 (PST) References: <1549015162-17418-1-git-send-email-jmasson@baylibre.com> <20190201101056.GA10039@Red> User-agent: mu4e 1.1.0; emacs 26.1.50 From: "Masson\, Julien" To: Corentin Labbe Cc: Julien Masson , Greg Kroah-Hartman , Kevin Hilman , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Jiri Slaby , linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] tty: serial: meson_uart: Add support for kernel debugger In-reply-to: <20190201101056.GA10039@Red> Date: Thu, 07 Feb 2019 18:04:36 +0100 Message-ID: <86lg2rv8bf.fsf@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 01 Feb 2019 at 11:10, Corentin Labbe wrote: > On Fri, Feb 01, 2019 at 10:59:22AM +0100, Julien Masson wrote: >> The kgdb invokes the poll_put_char and poll_get_char when communicating >> with the host. This patch implement the serial polling hooks for the >> meson_uart to be used for KGDB debugging over serial line. >> >> Signed-off-by: Julien Masson >> --- >> It has been tested on "Le Potato" board: >> https://libre.computer/products/boards/aml-s905x-cc/ >> >> Kernel command line arguments: >> kgdboc=ttyAML0,115200 kgdbretry=4 nokaslr kgdbcon >> >> Kernel modules: >> CONFIG_DEBUG_INFO=y >> CONFIG_DEBUG_KERNEL=y >> CONFIG_FRAME_POINTER=y >> CONFIG_KGDB=y >> CONFIG_KGDB_SERIAL_CONSOLE=y >> >> Warning: for single step instruction I had to apply this patch: >> https://lore.kernel.org/patchwork/patch/562423/ >> >> drivers/tty/serial/meson_uart.c | 46 +++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 46 insertions(+) >> >> diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c >> index 8a84259..49b20da 100644 >> --- a/drivers/tty/serial/meson_uart.c >> +++ b/drivers/tty/serial/meson_uart.c >> @@ -426,6 +426,48 @@ static void meson_uart_config_port(struct uart_port *port, int flags) >> } >> } >> >> +#ifdef CONFIG_CONSOLE_POLL >> +/* >> + * Console polling routines for writing and reading from the uart while >> + * in an interrupt or debug context (i.e. kgdb). >> + */ >> + >> +static int meson_uart_poll_get_char(struct uart_port *port) >> +{ >> + u32 c; >> + unsigned long flags; >> + >> + spin_lock_irqsave(&port->lock, flags); >> + >> + if (readl(port->membase + AML_UART_STATUS) & AML_UART_RX_EMPTY) >> + c = NO_POLL_CHAR; >> + else >> + c = readl(port->membase + AML_UART_RFIFO); >> + >> + spin_unlock_irqrestore(&port->lock, flags); >> + >> + return c; >> +} >> + >> +static void meson_uart_poll_put_char(struct uart_port *port, unsigned char c) >> +{ >> + unsigned long flags; >> + >> + spin_lock_irqsave(&port->lock, flags); >> + >> + while (!(readl(port->membase + AML_UART_STATUS) & AML_UART_TX_EMPTY)) >> + cpu_relax(); > > Hello > > Perhaps you could use read_poll_timeout() ? > This will also permit to handle the timeout case. > > Regards Thanks for the tips Corentin. I tested with a poll of 5 usec and 1 msec of timeout. I had to use readl_poll_timeout_atomic(...) since I'm in atomic context (spinlock). I'll send a v2 of this patch. Regards