From patchwork Sat Sep 22 20:11:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Herzog X-Patchwork-Id: 10611551 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 0ADF25A4 for ; Sat, 22 Sep 2018 20:11:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E40F22AE7C for ; Sat, 22 Sep 2018 20:11:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D45982AE7F; Sat, 22 Sep 2018 20:11:32 +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=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, 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 53D4E2AE7C for ; Sat, 22 Sep 2018 20:11:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727299AbeIWCGR (ORCPT ); Sat, 22 Sep 2018 22:06:17 -0400 Received: from mout.gmx.net ([212.227.17.21]:33829 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726464AbeIWCGR (ORCPT ); Sat, 22 Sep 2018 22:06:17 -0400 Received: from eddi-vb.fritz.box ([87.123.147.0]) by mail.gmx.com (mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MQeET-1gE1tX1qAv-00U5IZ; Sat, 22 Sep 2018 22:11:22 +0200 From: Tobias Herzog To: oneukum@suse.com Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] cdc-acm: do not reset notification buffer index upon urb unlinking Date: Sat, 22 Sep 2018 22:11:10 +0200 Message-Id: <1537647071-2691-1-git-send-email-t-herzog@gmx.de> X-Mailer: git-send-email 2.1.4 X-Provags-ID: V03:K1:QhsEh3wA1+3v7LtrNvHxKCikbMPc7ivodPrGkhh9Dxm8Acc/kZO DCtBMBhiAY1OqDu6v574pFyyCNAb2P2vz7KRuK54GFKbQAp4NUCjHGKFkKiLcfnGV5IHy26 NM/bz3tCaw+HG9h9BFb6M7XERQj540/hfvQEc+/yd14cZGGgg5HtbndaY4dzNvaRKZySSoQ i9EDdhEEmhPwXBJ8ynZ1g== X-UI-Out-Filterresults: notjunk:1;V01:K0:dHWl2n3aPdg=:Ccm6O6dNuyPtCUIK5ylcrw dKVxPZY6uobb/V8qv9dcc4+2zYYthVM5d8zDx66ETTbZ7qKbDMUhWxcRc1GKsFl1J3fl58cF4 VWsdx6hiWpDRqI8o/+5x2uQA+PhL7ZqFu2SV5XyBeM03WlZx8SipRxq3aBvN2EQJ7FLbez/6c OgqmHa1PzoqIeXJT7Uu3SxLgC+jX883QnsKcbUbO+61BPh/1ekov2UiFVgZYLmN0ZR+UgUj0e 068P3gb44qG1Rm4IeiTOwQ/7l42Vl88gD+Muj0dhAXUvIbZ4BNu6YIlU9kS+rdXXVoD01t+og SaywC3EBQI9Xhr2jhlukI+1b4bRsX/pshxbws7mse+iQTlL7UaTKMAd+c+lLGvh53bIMgSngT 1mQ2rmoOPV4WQ6BRvW7S03iY12i0vjZcDaP1iXy1lKDoLb18hw9pubqR2us1Yb3A/igJxnKC8 e+7D76CLNfVDU1fMSeJO7T8Mv8DQRLbWUnYdgEPtFNgbMtBlDAyg3ZxyfikAYKx2asvZnneez IDFJ486fz0Dw7dNaUDY4nBO+u5zatqJl8NxCnxc7Vs2BO433yq0W8qBkveRRtlpFh44w8VuJ7 0UBvDnS89IyEtdwZpwyGdLGLnaAPEaAsURg50cc5sPcO/gN4CpwKeBiDGgESjsNRiyzbv2QGq DyKE6LRFmRAJ937i9Z19XSSaX7PMG8s4mDGxvFUIaI1gWwb+V/5l3oQj5Pyp0p1Nt0HI5PJ6R i3jaVzt4IO5wWxxJHIy/Kx521YQ8efEn76JucZHZWl7EtDWtLxwr38LYxyaP5Fx03U029YM9t zK/SSMSj3k/eKdCeRiWsnbkeepmNQ== 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 Resetting the write index of the notification buffer on urb unlink (e.g. closing a cdc-acm device from userspace) may lead to wrong interpretation of further received notifications, in case the index is not 0 when urb unlink happens (i.e. when parts of a notification already have been transferred). On the device side there is no "reset" of the notification transimission and thus we would get out of sync with the device. Signed-off-by: Tobias Herzog Acked-by: Oliver Neukum --- drivers/usb/class/cdc-acm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 27346d6..50339ca 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -355,7 +355,6 @@ static void acm_ctrl_irq(struct urb *urb) case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ - acm->nb_index = 0; dev_dbg(&acm->control->dev, "%s - urb shutting down with status: %d\n", __func__, status); From patchwork Sat Sep 22 20:11:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Herzog X-Patchwork-Id: 10611553 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 AFDE05A4 for ; Sat, 22 Sep 2018 20:11:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FD9B2AE7C for ; Sat, 22 Sep 2018 20:11:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93FF42AE7F; Sat, 22 Sep 2018 20:11:39 +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=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, 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 3FC852AE7C for ; Sat, 22 Sep 2018 20:11:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728005AbeIWCGR (ORCPT ); Sat, 22 Sep 2018 22:06:17 -0400 Received: from mout.gmx.net ([212.227.17.21]:33705 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726530AbeIWCGR (ORCPT ); Sat, 22 Sep 2018 22:06:17 -0400 Received: from eddi-vb.fritz.box ([87.123.147.0]) by mail.gmx.com (mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id 0Lu3J4-1fbfCu2kkQ-011UNM; Sat, 22 Sep 2018 22:11:22 +0200 From: Tobias Herzog To: oneukum@suse.com Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] cdc-acm: correct counting of UART states in serial state notification Date: Sat, 22 Sep 2018 22:11:11 +0200 Message-Id: <1537647071-2691-2-git-send-email-t-herzog@gmx.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1537647071-2691-1-git-send-email-t-herzog@gmx.de> References: <1537647071-2691-1-git-send-email-t-herzog@gmx.de> X-Provags-ID: V03:K1:gc6QyhSN4lrE2w2RWYzmeku1QWXlsgnwM2F57BhUxmEAw6Z2H/U y5u76mHGq+HfHdWAnSEaur/sT3gNsByc6SCbnTpicHgN/bUfQIu9RevqT4zv5HRkOVtZ9G/ mkoULQKsrO9RZB8ZfnYpw101yMfdWXNnk5g7KiNiilVO64YQKur9LQWGQrEnpcqsChjD67y ML7yHd4IGejzQhHuOhW1A== X-UI-Out-Filterresults: notjunk:1;V01:K0:0Dn1hDfOdGY=:S+OAmYK7zq6snhfY9boi1l FDWuO7zFzMhI7jN0g5nELj9REJa+G0TwHGdXUf0IVXw7kF8ZTxga0wW9sr9AEurVuiUcrIt6r 8Rb9YcfyYXoltkrCOqF3nwfstUo99TWck+WkIAJSqe4xol2O6n4xSJI+kw+v/oi1Mcqs5K5R5 a7O8bQDw6OUYeHjttsF5uo0CP7CE8gfIDYsiLkXjrx+P64SDLly/WLSkEC2NyqoWDCih6d72H fTvunYilb8q9Rc4VRtzCQJRFh4ZsZRR+oM42AaN5oirau7Ofop1vXmaQ4qDPforKoeAHiFJcZ MpAK3cyybNEsAwitB2lLg6Yw5G6kfEgW28sy0wFB6mxe9coaTsTAFQmUbFFjFGZQthGIryWIb 589H/iRsPrCKCBYXaijdvM5OYzPKi2hWVs4o5o14efSIkXBE6AYPZqA2JUfoZ1pRixhuyuiLk EUhbOcZtW7qTsegeb8Y1S/HOSwOfWubE44UuQi5/QQVok6AsvRD8P/rxnvBiX9WaeXrvQtsEV rss2PvguE5u3wRMxy/i8j0CyZyiWxv0qn7ZWtsGfbs7GLJrdHJhgD/I6ufGZ4Utn1CWGscQAg tbf+9YVdd1lMowsbEk8NQMpx1NsmhbrMLkXFLDgNMhlE0cguy2GTpAaSkGA1jiWalirt/K8n2 mZsyFIzes7fjVd+PhkXT8wkPIhjW5DnGt5GhEDBM1I7dtEhlE8WSH8alCOfioQE0aftYziU// o9x9QgRsub7Fpj+4zDHYR8YM76j1lCWih0uR6ASiB/CxrjRHKbXXpb+lazpQyBNrblTxwYUjm WRDh5mZQghU+ZW+AJR6X7+Q88hc9w== 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 The usb standard ("Universal Serial Bus Class Definitions for Communication Devices") distiguishes between "consistent signals" (DSR, DCD), and "irregular signals" (break, ring, parity error, framing error, overrun). The bits of "irregular signals" are set, if this error/event occurred on the device side and are immeadeatly unset, if the serial state notification was sent. Like other drivers of real serial ports do, just the occurence of those events should be counted in serial_icounter_struct (but no 1->0 transitions). Signed-off-by: Tobias Herzog Acked-by: Oliver Neukum --- drivers/usb/class/cdc-acm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 50339ca..187f386 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -310,17 +310,17 @@ static void acm_process_notification(struct acm *acm, unsigned char *buf) if (difference & ACM_CTRL_DSR) acm->iocount.dsr++; - if (difference & ACM_CTRL_BRK) - acm->iocount.brk++; - if (difference & ACM_CTRL_RI) - acm->iocount.rng++; if (difference & ACM_CTRL_DCD) acm->iocount.dcd++; - if (difference & ACM_CTRL_FRAMING) + if (newctrl & ACM_CTRL_BRK) + acm->iocount.brk++; + if (newctrl & ACM_CTRL_RI) + acm->iocount.rng++; + if (newctrl & ACM_CTRL_FRAMING) acm->iocount.frame++; - if (difference & ACM_CTRL_PARITY) + if (newctrl & ACM_CTRL_PARITY) acm->iocount.parity++; - if (difference & ACM_CTRL_OVERRUN) + if (newctrl & ACM_CTRL_OVERRUN) acm->iocount.overrun++; spin_unlock_irqrestore(&acm->read_lock, flags);