Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2472727imm; Mon, 24 Sep 2018 05:06:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV62LRCio8JJedYRJ+6Qsxp8fHQ/39D6FLmnXNzOgVH3V2tz23D8oN1FqaTvx0YvWagTHyrS/ X-Received: by 2002:a17:902:290a:: with SMTP id g10-v6mr10416982plb.110.1537790781554; Mon, 24 Sep 2018 05:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537790781; cv=none; d=google.com; s=arc-20160816; b=x0mg6TUC2OLperRfeP5ohvCqI20q3Fp2/a2TiJnpMm3X9gsLYY/NPqe3qMnOoVobOH eNo2DGzmdkX8U9nH5943WjwAyBHsjlOUWfCaF59Wdqk7oLHqOFiBRFWHoAI5aYcZgwtN 44YWRXddHG8AH2J3AV7YTNSwvUBfJlorXaJ7s5OwyNLr9PDm0uIVQPoj7G/SnyUeYEt9 TpXa08vTlnh5Lhn6Lw0AM51iul/nGBUjmKsiLiDjQ2Qx6ejx7KNik3sQ93dmU45dCgUY 9hGku7cCxKVr9/vy2BSGCvleMFMhNpEM13TJ4SSlsgZqZJM36fds+ut0bfRTPF1HAD3n Yq0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=cUEBr502koM5eYz+X6skjEWXwvdeV9WNbmgXPjKE7GA=; b=KDUMSoVjdt2DEZvXPviiFWHl4G0Cwb1MaW+QN4it+/xi/J0BbU24yUTJTso8AkBRYO ykQ0FbSYDY6sERbn0A3mHS7N6HZLggXPw2xwadVpKc5LkrEd04RKGDcC6Am59V+vZ9OX /RV3iKQu0xHeKvQmLRTY1ezF9LanKNkRllgjvWka/XgdCS9gmEp5rSbq1SzcGoE2/b7/ PsooTLnZoljrACib07cG8msgiCHz2u8tAiMEz86t3N24wEuwUgZj+jGkwhOMR8R/0oDi KuI03tJUqwl197kMVd75gi3CUhkUqkJBGPxFNPUVlfxO8TtILkN65GajzxwDomRJ2mtm bXDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u2-v6si2131250pfn.250.2018.09.24.05.06.05; Mon, 24 Sep 2018 05:06:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730929AbeIXSGu (ORCPT + 99 others); Mon, 24 Sep 2018 14:06:50 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53868 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726417AbeIXSGt (ORCPT ); Mon, 24 Sep 2018 14:06:49 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 446791080; Mon, 24 Sep 2018 12:04:58 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mariusz Bialonczyk , Oliver Neukum Subject: [PATCH 4.9 068/111] Revert "cdc-acm: implement put_char() and flush_chars()" Date: Mon, 24 Sep 2018 13:52:35 +0200 Message-Id: <20180924113111.782014315@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.337261320@linuxfoundation.org> References: <20180924113103.337261320@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Oliver Neukum commit df3aa13c7bbb307e172c37f193f9a7aa058d4739 upstream. This reverts commit a81cf9799ad7299b03a4dff020d9685f9ac5f3e0. The patch causes a regression, which I cannot find the reason for. So let's revert for now, as a revert hurts only performance. Original report: I was trying to resolve the problem with Oliver but we don't get any conclusion for 5 months, so I am now sending this to mail list and cdc_acm authors. I am using simple request-response protocol to obtain the boiller parameters in constant intervals. A simple one transaction is: 1. opening the /dev/ttyACM0 2. sending the following 10-bytes request to the device: unsigned char req[] = {0x02, 0xfe, 0x01, 0x05, 0x08, 0x02, 0x01, 0x69, 0xab, 0x03}; 3. reading response (frame of 74 bytes length). 4. closing the descriptor I am doing this transaction with 5 seconds intervals. Before the bad commit everything was working correctly: I've got a requests and a responses in a timely manner. After the bad commit more time I am using the kernel module, more problems I have. The graph [2] is showing the problem. As you can see after module load all seems fine but after about 30 minutes I've got a plenty of EAGAINs when doing read()'s and trying to read back the data. When I rmmod and insmod the cdc_acm module again, then the situation is starting over again: running ok shortly after load, and more time it is running, more EAGAINs I have when calling read(). As a bonus I can see the problem on the device itself: The device is configured as you can see here on this screen [3]. It has two transmision LEDs: TX and RX. Blink duration is set for 100ms. This is a recording before the bad commit when all is working fine: [4] And this is with the bad commit: [5] As you can see the TX led is blinking wrongly long (indicating transmission?) and I have problems doing read() calls (EAGAIN). Reported-by: Mariusz Bialonczyk Signed-off-by: Oliver Neukum Fixes: a81cf9799ad7 ("cdc-acm: implement put_char() and flush_chars()") Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/cdc-acm.c | 73 -------------------------------------------- drivers/usb/class/cdc-acm.h | 1 2 files changed, 74 deletions(-) --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -705,20 +705,9 @@ static int acm_tty_write(struct tty_stru } if (acm->susp_count) { - if (acm->putbuffer) { - /* now to preserve order */ - usb_anchor_urb(acm->putbuffer->urb, &acm->delayed); - acm->putbuffer = NULL; - } usb_anchor_urb(wb->urb, &acm->delayed); spin_unlock_irqrestore(&acm->write_lock, flags); return count; - } else { - if (acm->putbuffer) { - /* at this point there is no good way to handle errors */ - acm_start_wb(acm, acm->putbuffer); - acm->putbuffer = NULL; - } } stat = acm_start_wb(acm, wb); @@ -729,66 +718,6 @@ static int acm_tty_write(struct tty_stru return count; } -static void acm_tty_flush_chars(struct tty_struct *tty) -{ - struct acm *acm = tty->driver_data; - struct acm_wb *cur; - int err; - unsigned long flags; - - spin_lock_irqsave(&acm->write_lock, flags); - - cur = acm->putbuffer; - if (!cur) /* nothing to do */ - goto out; - - acm->putbuffer = NULL; - err = usb_autopm_get_interface_async(acm->control); - if (err < 0) { - cur->use = 0; - acm->putbuffer = cur; - goto out; - } - - if (acm->susp_count) - usb_anchor_urb(cur->urb, &acm->delayed); - else - acm_start_wb(acm, cur); -out: - spin_unlock_irqrestore(&acm->write_lock, flags); - return; -} - -static int acm_tty_put_char(struct tty_struct *tty, unsigned char ch) -{ - struct acm *acm = tty->driver_data; - struct acm_wb *cur; - int wbn; - unsigned long flags; - -overflow: - cur = acm->putbuffer; - if (!cur) { - spin_lock_irqsave(&acm->write_lock, flags); - wbn = acm_wb_alloc(acm); - if (wbn >= 0) { - cur = &acm->wb[wbn]; - acm->putbuffer = cur; - } - spin_unlock_irqrestore(&acm->write_lock, flags); - if (!cur) - return 0; - } - - if (cur->len == acm->writesize) { - acm_tty_flush_chars(tty); - goto overflow; - } - - cur->buf[cur->len++] = ch; - return 1; -} - static int acm_tty_write_room(struct tty_struct *tty) { struct acm *acm = tty->driver_data; @@ -1940,8 +1869,6 @@ static const struct tty_operations acm_o .cleanup = acm_tty_cleanup, .hangup = acm_tty_hangup, .write = acm_tty_write, - .put_char = acm_tty_put_char, - .flush_chars = acm_tty_flush_chars, .write_room = acm_tty_write_room, .ioctl = acm_tty_ioctl, .throttle = acm_tty_throttle, --- a/drivers/usb/class/cdc-acm.h +++ b/drivers/usb/class/cdc-acm.h @@ -94,7 +94,6 @@ struct acm { unsigned long read_urbs_free; struct urb *read_urbs[ACM_NR]; struct acm_rb read_buffers[ACM_NR]; - struct acm_wb *putbuffer; /* for acm_tty_put_char() */ int rx_buflimit; spinlock_t read_lock; int write_used; /* number of non-empty write buffers */