From patchwork Wed Jun 8 11:23:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Govindraj.R" X-Patchwork-Id: 861232 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p58I6rv8010696 for ; Wed, 8 Jun 2011 18:06:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753271Ab1FHLXn (ORCPT ); Wed, 8 Jun 2011 07:23:43 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:40236 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751277Ab1FHLXm (ORCPT ); Wed, 8 Jun 2011 07:23:42 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id p58BNY0p023186 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 8 Jun 2011 06:23:37 -0500 Received: from dbde70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id p58BNWY1012610; Wed, 8 Jun 2011 16:53:34 +0530 (IST) Received: from dbdp31.itg.ti.com (172.24.170.98) by DBDE70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 8.3.106.1; Wed, 8 Jun 2011 16:53:33 +0530 Received: from localhost.localdomain (omapldc12.india.ti.com [172.24.136.100]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p58BNT7q028360; Wed, 8 Jun 2011 16:53:33 +0530 (IST) From: "Govindraj.R" To: , , CC: Tony Lindgren , Kevin Hilman , "Govindraj.R" Subject: [PATCH v3 05/12] OMAP: Serial: Hold console lock for console usage. Date: Wed, 8 Jun 2011 16:53:07 +0530 Message-ID: <1307532194-13039-6-git-send-email-govindraj.raja@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1307532194-13039-1-git-send-email-govindraj.raja@ti.com> References: <1307532194-13039-1-git-send-email-govindraj.raja@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 08 Jun 2011 18:06:58 +0000 (UTC) Acquire console lock before enabling and writing to console-uart to avoid any recursive prints from console write. for ex: --> printk --> uart_console_write --> get_sync --> printk from omap_device enable --> uart_console write Use RPM_SUSPENDING check to avoid below scenario during bootup As during bootup console_lock is not available. --> uart_add_one_port --> console_register --> console_lock --> console_unlock --> call_console_drivers (here yet console_lock is not released) --> uart_console_write Acked-by: Alan Cox Signed-off-by: Govindraj.R --- drivers/tty/serial/omap-serial.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 897416f..ee94291 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -1008,7 +1008,22 @@ serial_omap_console_write(struct console *co, const char *s, struct uart_omap_port *up = serial_omap_console_ports[co->index]; unsigned long flags; unsigned int ier; - int locked = 1; + int console_lock = 0, locked = 1; + + if (console_trylock()) + console_lock = 1; + + /* + * If console_lock is not available and we are in suspending + * state then we can avoid the console usage scenario + * as this may introduce recursive prints. + * Basically this scenario occurs during boot while + * printing debug bootlogs. + */ + + if (!console_lock && + up->pdev->dev.power.runtime_status == RPM_SUSPENDING) + return; local_irq_save(flags); if (up->port.sysrq) @@ -1044,6 +1059,9 @@ serial_omap_console_write(struct console *co, const char *s, if (up->msr_saved_flags) check_modem_status(up); + if (console_lock) + console_unlock(); + serial_omap_port_disable(up); if (locked) spin_unlock(&up->port.lock);