Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp226836ima; Fri, 1 Feb 2019 02:20:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN7a6emQ5eXK9EXQA5lfaw0iM9K561g5+prj0FFJzq0tYM3RdcjGjyw82lJK3ntPJg/FW1S9 X-Received: by 2002:a17:902:e18c:: with SMTP id cd12mr36717512plb.279.1549016419673; Fri, 01 Feb 2019 02:20:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549016419; cv=none; d=google.com; s=arc-20160816; b=gvtTJXYKuQlvwX/IENInQrJ7ToU3uH72YssXdlpFAn69pGZf+oulquWl4+8ivJHWJP qLU5Zi/lEfi+VNEbBmWheu7JrcSpxlIuZDzNaCaa1V6CC7CFnZTx2/29LC/SL+r1+uoP e7nD3xCnlFsfQ97uSVqQ7zkjKEPhQZdc8mrrXIVeBtnzZAynxlTTzYLakeQUBwPXhGKy iYegrHNbnPPTeDAbPpEn4k96pFUe/zsA5QiLW06294m4WbCXyWDR7CqYOeCKYpSih2zR ut/dxDtV/tvrv1T3UEI3jAVlpI/TGU5tFsO167Cg+4Y+JgbtJpeJcKiiEDaBNkya/XK9 JPdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tQss5XY1in0Ch/QSiFhhlFeW8ftdKCddtzhbVyHetU0=; b=CbnHNc99HpDE/idTZcUqIBu+a1w/2+ukbnADz/11jAnR2qVH1/TSkl6N8ESsQSZSBA ueMlSoBBHnU3xWNPqwEy2iqVNzj7pMeprb6wdGVG1MTtxlGy/AvfRIxSdd5Cgk9cSUGD RmgK5Rvid7R1oAs6NZIr8ZWL7UDPlSyBtFWA2K2HVnkqEuPaIP1qBsMkt0pDhKlYCQol KgDMdkW9jFF1KAbrM2lE8RNRK6HLgc0UBlFct3InWzmFwQ3eIe9suKyku9PZYZH1Q3Xl tof1Sy+eKPyWoXeWLx8vF8ricC3ixHAZziGmBKcej4/uebo202gAGfy6HnM7fkgyMLvy +gpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LTbMwTpN; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c11si6797635pgj.255.2019.02.01.02.20.03; Fri, 01 Feb 2019 02:20:19 -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=@gmail.com header.s=20161025 header.b=LTbMwTpN; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729333AbfBAKLC (ORCPT + 99 others); Fri, 1 Feb 2019 05:11:02 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:56184 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726467AbfBAKLB (ORCPT ); Fri, 1 Feb 2019 05:11:01 -0500 Received: by mail-wm1-f65.google.com with SMTP id y139so5422470wmc.5; Fri, 01 Feb 2019 02:11:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=tQss5XY1in0Ch/QSiFhhlFeW8ftdKCddtzhbVyHetU0=; b=LTbMwTpNJLvXx/kUQ2ixglM++Tghi/f5C4rp0sXDrPdYubeRsnIsfXICQnd3WdExtK jWO8gO4h/HviPrwG6EoSCgHaH95mJgG3y9yx4FVXM2RwSVmEp5DoW0CX2dFvWz6/1Q6D FJT5Mj13JqveiDN5193vuZ/qfCdqYuAUbi0WJXPxf8NPR5HPkkj/pc6pbFfJLp0BzPIf 9i6WGZW6GuqaItTZH8s3QA00fbQA69sggtcX/aWNMR2mG87G+YnO4FULMvXmHXZ90bP/ qcWgQNu6guUsLhH/cl63QtllAbtu7nbjf05HYTu7IEXzdPYmTUWyetsCp4wxjLnvdDrh T/tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=tQss5XY1in0Ch/QSiFhhlFeW8ftdKCddtzhbVyHetU0=; b=JXtWFQqqn1YrDnVD1d1gaDAFIQyfgSoEI38w8wvCuq6RKlVrzdGs6RjjY07Vd+OBdg xX7IFRsCTecKTiHvyyLdbowj2uMiMQn7CdfSvE6yxgMl8OY0U70QgPp8TvoduHLVNxBU eEn7pa33Qe4okvwZBw4Mp8K82jhUf/2qd05cgq7WdlHD/jM7jFYPLEIxADbVbfIUZZYF ildScwRHykOh9HQwWpf72B4JR23DSE1/akzjntoagcTQ9OXsL31kyWUgVxUuSniKjrqw BVJmbKLpSwdlX6+FWvvJvz9J4OieLkvRQeUkiOpC6yVElluf6oJmFxdAX7x1QDrO6+VU tC5w== X-Gm-Message-State: AHQUAuZ1tveW17Oid+OpXtV5MjHGq8J+9/wU4jxTR3Rm0/yMQU+Q2+qR +spMg+BZzEiJgqlJ2enTp41Y+Uqo X-Received: by 2002:a1c:2e43:: with SMTP id u64mr1763632wmu.52.1549015859665; Fri, 01 Feb 2019 02:10:59 -0800 (PST) Received: from Red ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id a14sm711892wrr.13.2019.02.01.02.10.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 02:10:58 -0800 (PST) Date: Fri, 1 Feb 2019 11:10:56 +0100 From: Corentin Labbe To: Julien Masson Cc: 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 Message-ID: <20190201101056.GA10039@Red> References: <1549015162-17418-1-git-send-email-jmasson@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1549015162-17418-1-git-send-email-jmasson@baylibre.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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