From patchwork Wed Feb 27 09:29:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 10831465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D9B917E9 for ; Wed, 27 Feb 2019 09:29:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0ADD62C7AE for ; Wed, 27 Feb 2019 09:29:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3A532C7D6; Wed, 27 Feb 2019 09:29:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5ECA2C7AE for ; Wed, 27 Feb 2019 09:29:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728802AbfB0J3l (ORCPT ); Wed, 27 Feb 2019 04:29:41 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:29549 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726194AbfB0J3l (ORCPT ); Wed, 27 Feb 2019 04:29:41 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 448VjM3vf6zTr; Wed, 27 Feb 2019 10:28:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1551259703; bh=SBmdNJ/ke98aztVt5z1/IbD4bp6aeZzWxcxzHz2jyDs=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=JAdElhmmFwGpC6jEnUmrQNK7Esa5pBWO1TcLn5wH2b5BTJueRbqGXhen9ik+B4KeD P3iWKy7gy/pfHTcXTflAMNw3fDFtww3b23YF6ybLcg3v5SnmDQ7PDpxENGskZroe8q JJFa7uxaPjMELLBkqtXW8TIf0HbF/uSQMNUkvNX+v28A3JYHUwCX8nfhqA7t0gdygc TAVkDF1V7gksarJn1nRNG+s7NQDXKhgPPQweb6eLCoyhnEI5djiHOvHz9cWqMFhCyM 0BraQqSo0OTdVJbRIpO+V8WEs/pjQCAtPU4WymRSheujkfrxTsFvrcUTthTT9ksjG6 cuW7xDP40P7CA== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.2 at mail Date: Wed, 27 Feb 2019 10:29:39 +0100 Message-Id: <2b2b9a11dd8d68df4523eb4f20c3e0eba1e3be8e.1551259482.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v2 5/5] usb: gadget: u_serial: diagnose missed console messages MIME-Version: 1.0 To: linux-usb@vger.kernel.org Cc: Felipe Balbi , Greg Kroah-Hartman Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Insert markers in console stream marking places where data is missing. This makes the hole in the data stand out clearly instead of glueing together unrelated messages. Signed-off-by: Michał Mirosław --- v2: commit message massage --- drivers/usb/gadget/function/u_serial.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index 604e187fadb7..66518aba58c2 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -88,6 +88,7 @@ struct gs_console { spinlock_t lock; struct usb_request *req; struct kfifo buf; + size_t missed; }; /* @@ -930,6 +931,15 @@ static void __gs_console_push(struct gs_console *cons) if (!size) return; + if (cons->missed && ep->maxpacket >= 64) { + char buf[64]; + size_t len; + + len = sprintf(buf, "\n[MISSED %zu bytes]\n", cons->missed); + kfifo_in(&cons->buf, buf, len); + cons->missed = 0; + } + req->length = size; if (usb_ep_queue(ep, req, GFP_ATOMIC)) req->length = 0; @@ -951,10 +961,13 @@ static void gs_console_write(struct console *co, { struct gs_console *cons = container_of(co, struct gs_console, console); unsigned long flags; + size_t n; spin_lock_irqsave(&cons->lock, flags); - kfifo_in(&cons->buf, buf, count); + n = kfifo_in(&cons->buf, buf, count); + if (n < count) + cons->missed += count - n; if (cons->req && !cons->req->length) schedule_work(&cons->work);