From patchwork Wed Feb 27 07:48:58 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: 10831367 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 174B51399 for ; Wed, 27 Feb 2019 07:49:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 059A42A356 for ; Wed, 27 Feb 2019 07:49:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE3732B69D; Wed, 27 Feb 2019 07:49:02 +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 9441E2A356 for ; Wed, 27 Feb 2019 07:49:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729617AbfB0HtB (ORCPT ); Wed, 27 Feb 2019 02:49:01 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:14433 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729604AbfB0HtB (ORCPT ); Wed, 27 Feb 2019 02:49:01 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 448STC2322zXN; Wed, 27 Feb 2019 08:47:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1551253663; bh=jfnixvYi/8kJFn56+3WvroUDhhzp0/AeB5LXPLwz44o=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=PyaWIudhiZiN4BKxU5am+9YLe0OmrRfyajPuCDIUuSz+wOw+P9Jox5Wyb4N+0/Al4 nUNyAqW9J2uCtBrhYuAjbaDoBoTJH7lhpSTwAJfXGFQ97Byae91JhrMUW40uqSKEFY ZGyb8i52XOPFDCJBmzJ5ptfNauqrWptqkZBQx0YxQ6w8BIm+Nqo6uPkf49TB+Fi7vP hOHTVc7BA2kFBpmN4gh8k8cpM13BO+LwZsC//24yBygTT8TfhQbU3nBfj93I+rnz/W M8ASW6eJJcUSU/nOYFc++xzPb8dq3qh9d8jCxtYDmPuN7BHDnXlhZmXvmWjndzw1/5 ZHWDWNrRHECBw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.2 at mail Date: Wed, 27 Feb 2019 08:48:58 +0100 Message-Id: <78e9b2c9313dea8a35f5b6f2a2c285c5f2f5ecbb.1551253561.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 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 instead of making console output glued together when drops happen. Signed-off-by: Michał Mirosław --- 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 7b719c166517..f025cb958362 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);