From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michal Simek Subject: [PATCH v2] tty: serial: uartlite: Specify time for sending chars Date: Tue, 6 May 2014 06:46:15 +0200 Message-ID: Content-Type: multipart/signed; boundary="=_mimegpg-monstr-desktop-7379-1399351575-0001"; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from mail-we0-f177.google.com ([74.125.82.177]:41906 "EHLO mail-we0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751041AbaEFEqd (ORCPT ); Tue, 6 May 2014 00:46:33 -0400 Received: by mail-we0-f177.google.com with SMTP id x48so3135401wes.36 for ; Mon, 05 May 2014 21:46:32 -0700 (PDT) Sender: linux-serial-owner@vger.kernel.org List-Id: linux-serial@vger.kernel.org To: linux-kernel@vger.kernel.org Cc: Michal Simek , Michal Simek , Greg Kroah-Hartman , linux-serial@vger.kernel.org, arnd@arndb.de, Peter Korsgaard , Grant Likely , Rob Herring , Jiri Slaby This is a MIME GnuPG-signed message. If you see this text, it means that your E-mail or Usenet software does not support MIME signed messages. The Internet standard for MIME PGP messages, RFC 2015, was published in 1996. To open this message correctly you will need to install E-mail or Usenet software that supports modern Internet standards. --=_mimegpg-monstr-desktop-7379-1399351575-0001 Xilinx MDM (Microblaze Debug Module) also contains uart interface via JTAG which is compatible with uartlite driver. This interface is really slow that's why timeout is setup to 1s. Make this time delay not to be cpu speed dependent. Signed-off-by: Michal Simek Acked-by: Peter Korsgaard --- Changes in v2: - Add Peter's ACK - Extend commentary RFC sent here: https://lkml.org/lkml/2013/9/30/250 I finally got HW design which is just slow to be able to test it. --- drivers/tty/serial/uartlite.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c index 5f90ef24d475..dce27f34937e 100644 --- a/drivers/tty/serial/uartlite.c +++ b/drivers/tty/serial/uartlite.c @@ -418,14 +418,23 @@ static struct uart_ops ulite_ops = { #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE static void ulite_console_wait_tx(struct uart_port *port) { - int i; u8 val; - - /* Spin waiting for TX fifo to have space available */ - for (i = 0; i < 100000; i++) { + unsigned long timeout; + + /* + * Spin waiting for TX fifo to have space available. + * When using the Microblaze Debug Module this can take up to 1s + */ + timeout = jiffies + msecs_to_jiffies(1000); + while (1) { val = uart_in32(ULITE_STATUS, port); if ((val & ULITE_STATUS_TXFULL) == 0) break; + if (time_after(jiffies, timeout)) { + dev_warn(port->dev, + "timeout waiting for TX buffer empty\n"); + break; + } cpu_relax(); } } -- 1.8.2.3 --=_mimegpg-monstr-desktop-7379-1399351575-0001 Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEABECAAYFAlNoaRcACgkQykllyylKDCENEwCfcsU0iMxo8iGmkrcOdnJa/4UO iFQAniTB5hXs/tjFLOmm+cyoQB1zbvd/ =CMoJ -----END PGP SIGNATURE----- --=_mimegpg-monstr-desktop-7379-1399351575-0001--