From patchwork Thu May 29 08:48:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 31107 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f197.google.com (mail-ig0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F295120068 for ; Thu, 29 May 2014 08:49:08 +0000 (UTC) Received: by mail-ig0-f197.google.com with SMTP id hn18sf399895igb.0 for ; Thu, 29 May 2014 01:49:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=un5NFJcRwHJdLMG+ygyVKtHghllZH69a8Wq4rGALY9g=; b=A2TUTDwbpGVcSE4xxd5gIKHVXMNVDC17oEZ+jhIMMCVfVyrN2UmKVdmWxetuiG9hrV EpuwgWkY4OMDDMBe+pdEKN2q8tFdyd0iZl35JapTleYTCOZ2c97m5cSjcmIhwGfoEWC7 eSa1YGHWH/xUCAtDtkkPfLulJ+bY4SgN7/YkSNW5dvQksZQTpB5mpjfAuRwfiziBSkVW ZuGRfM8cqwzsbSUqp1SDuVB/bdlui2cgmO28A0woy8/PnwY0+8NdE+1hP0YoYhPGP9EK IF7JSdbM4FqQk9cqNXOaOOapVrDabPfF2LpkEcUcXIhJ+pVazXfmbAsa3Y40Fl4EVVZx iZ2Q== X-Gm-Message-State: ALoCoQmnxpeqD5UQDe246ZmVZ3gL6RBHSB3fR1MlOMK50P3JnklkUAUxHXKae5yuEOgB/1Y70vr1 X-Received: by 10.182.33.66 with SMTP id p2mr2542390obi.8.1401353348370; Thu, 29 May 2014 01:49:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.34.196 with SMTP id l62ls147559qgl.35.gmail; Thu, 29 May 2014 01:49:08 -0700 (PDT) X-Received: by 10.220.69.72 with SMTP id y8mr5010839vci.21.1401353348268; Thu, 29 May 2014 01:49:08 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id 3si3228vcs.47.2014.05.29.01.49.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 01:49:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id id10so30337vcb.6 for ; Thu, 29 May 2014 01:49:08 -0700 (PDT) X-Received: by 10.58.28.205 with SMTP id d13mr20850veh.55.1401353348193; Thu, 29 May 2014 01:49:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp11320vcb; Thu, 29 May 2014 01:49:07 -0700 (PDT) X-Received: by 10.180.19.37 with SMTP id b5mr32836865wie.16.1401353347280; Thu, 29 May 2014 01:49:07 -0700 (PDT) Received: from mail-we0-f170.google.com (mail-we0-f170.google.com [74.125.82.170]) by mx.google.com with ESMTPS id gf2si723983wib.79.2014.05.29.01.49.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 01:49:05 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 74.125.82.170 as permitted sender) client-ip=74.125.82.170; Received: by mail-we0-f170.google.com with SMTP id u57so37214wes.15 for ; Thu, 29 May 2014 01:49:04 -0700 (PDT) X-Received: by 10.194.179.9 with SMTP id dc9mr8418279wjc.74.1401353344825; Thu, 29 May 2014 01:49:04 -0700 (PDT) Received: from sundance.lan (cpc4-aztw19-0-0-cust157.18-1.cable.virginm.net. [82.33.25.158]) by mx.google.com with ESMTPSA id k2sm40794wjq.20.2014.05.29.01.49.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 May 2014 01:49:03 -0700 (PDT) From: Daniel Thompson To: Greg Kroah-Hartman Cc: Daniel Thompson , linux-serial@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, John Stultz , Anton Vorontsov , Colin Cross , kernel-team@android.com, Jason Wessel , kgdb-bugreport@lists.sourceforge.net, Jiri Slaby , Dirk Behme Subject: [PATCH tty-next v2 3/4] serial: kgdb_nmi: Switch from tasklets to real timers Date: Thu, 29 May 2014 09:48:45 +0100 Message-Id: <1401353326-14148-4-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1401353326-14148-1-git-send-email-daniel.thompson@linaro.org> References: <20140528200344.GA2750@kroah.com> <1401353326-14148-1-git-send-email-daniel.thompson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.thompson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , kgdb_nmi uses tasklets on the assumption they will not be scheduled until the next timer tick. This assumption is invalid and can lead to live lock, continually servicing the kgdb_nmi tasklet. This is fixed by using the timer API instead. Signed-off-by: Daniel Thompson --- drivers/tty/serial/kgdb_nmi.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c index d51b2a1..20d21d0 100644 --- a/drivers/tty/serial/kgdb_nmi.c +++ b/drivers/tty/serial/kgdb_nmi.c @@ -80,24 +80,10 @@ static struct console kgdb_nmi_console = { struct kgdb_nmi_tty_priv { struct tty_port port; - struct tasklet_struct tlet; + struct timer_list timer; STRUCT_KFIFO(char, KGDB_NMI_FIFO_SIZE) fifo; }; -/* - * Our debugging console is polled in a tasklet, so we'll check for input - * every tick. In HZ-less mode, we should program the next tick. We have - * to use the lowlevel stuff as no locks should be grabbed. - */ -#ifdef CONFIG_HIGH_RES_TIMERS -static void kgdb_tty_poke(void) -{ - tick_program_event(ktime_get(), 0); -} -#else -static inline void kgdb_tty_poke(void) {} -#endif - static struct tty_port *kgdb_nmi_port; static void kgdb_tty_recv(int ch) @@ -108,14 +94,13 @@ static void kgdb_tty_recv(int ch) if (!kgdb_nmi_port || ch < 0) return; /* - * Can't use port->tty->driver_data as tty might be not there. Tasklet + * Can't use port->tty->driver_data as tty might be not there. Timer * will check for tty and will get the ref, but here we don't have to * do that, and actually, we can't: we're in NMI context, no locks are * possible. */ priv = container_of(kgdb_nmi_port, struct kgdb_nmi_tty_priv, port); kfifo_in(&priv->fifo, &c, 1); - kgdb_tty_poke(); } static int kgdb_nmi_poll_one_knock(void) @@ -199,7 +184,8 @@ static void kgdb_nmi_tty_receiver(unsigned long data) struct kgdb_nmi_tty_priv *priv = (void *)data; char ch; - tasklet_schedule(&priv->tlet); + priv->timer.expires = jiffies + (HZ/100); + add_timer(&priv->timer); if (likely(!kgdb_nmi_tty_enabled || !kfifo_len(&priv->fifo))) return; @@ -215,7 +201,9 @@ static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty) container_of(port, struct kgdb_nmi_tty_priv, port); kgdb_nmi_port = port; - tasklet_schedule(&priv->tlet); + priv->timer.expires = jiffies + (HZ/100); + add_timer(&priv->timer); + return 0; } @@ -224,7 +212,7 @@ static void kgdb_nmi_tty_shutdown(struct tty_port *port) struct kgdb_nmi_tty_priv *priv = container_of(port, struct kgdb_nmi_tty_priv, port); - tasklet_kill(&priv->tlet); + del_timer(&priv->timer); kgdb_nmi_port = NULL; } @@ -243,7 +231,7 @@ static int kgdb_nmi_tty_install(struct tty_driver *drv, struct tty_struct *tty) return -ENOMEM; INIT_KFIFO(priv->fifo); - tasklet_init(&priv->tlet, kgdb_nmi_tty_receiver, (unsigned long)priv); + setup_timer(&priv->timer, kgdb_nmi_tty_receiver, (unsigned long)priv); tty_port_init(&priv->port); priv->port.ops = &kgdb_nmi_tty_port_ops; tty->driver_data = priv;