Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2598842pxb; Tue, 21 Sep 2021 03:35:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfGurjagJjJiPG+UyU7lqzvZtSscvHfoy0IoGS9fACfbyfOTrJN0sE8IjyW0S5JuHXTQ6W X-Received: by 2002:a17:907:2639:: with SMTP id aq25mr34637446ejc.138.1632220539018; Tue, 21 Sep 2021 03:35:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632220539; cv=none; d=google.com; s=arc-20160816; b=HcDp9+ugbfaFQCPpKC+LYJZVHsucyuI+7S4nl3V65aWS5kgKAS+3tRdhxgsaoP3+2N bS4WBYM3PuGAVH7vprfukZpBkY/JmV1GQ3YQNCL084ddOXjRLyO/wGcdg+go8RndtX/7 lE+dIF3aioq2OatvT5jdXh/bb48hlYt0oKIECb1T0SFNQK3H6Ev1xmS2AZgqLH6zmcwU OHKnd8v9MZpnYJz8s5N7CXfFS4DUP/S2/cDaMcEUtpp05eRKIn4cqh8zEAmfulz7MJR2 AllcQILW4HmO1AEjP8TCtVLT2yKAxUJ6+Xn3m5CYN8ITmQg8bf0GuWHqO0flE6O7ZPrC rpRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=p1LUu/sNrljFN2bJISW0gDVn3mtup8qn36sVDF7Kwes=; b=B2DVYLRpLG1n65EnEDOjRsdBcEJfwTkLSkgpsq4Fm0K6qBzaSDpXJqXTLnUrLs67hU WqtMzKYm2lBwPkCDuvIxeLh0T3UGSoWS/Cta/AQqAd7e11ew/TyzK7y3jUUCsU54hHUU GvjfeHpP01yghHC6Uceo91ojX/gRNpvSXqTP42+7GCO8fjb5/nyyu58NvJ/CkmqRwoQy RcjUy+KXLzGTPYyhV5uGQmlA9z9Lo6i+pNKYx8BB0vcgBGuGaPXUzVQ0LQM+XxaI0ibC OAl0k4TBn5Z/szXR2uHNLIMUHqvumev3Gl2+ddGd24EUPMufxfSNz0ylPTqxpIeblLE9 BYwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w25si20535800ejk.769.2021.09.21.03.35.15; Tue, 21 Sep 2021 03:35:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231898AbhIUKfZ (ORCPT + 99 others); Tue, 21 Sep 2021 06:35:25 -0400 Received: from muru.com ([72.249.23.125]:35518 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231823AbhIUKfY (ORCPT ); Tue, 21 Sep 2021 06:35:24 -0400 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 3FF7E8127; Tue, 21 Sep 2021 10:34:22 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman Cc: Andy Shevchenko , Jiri Slaby , Johan Hovold , Vignesh Raghavendra , linux-serial@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] n_tty: Start making use of -EAGAIN returned from process_output_block() Date: Tue, 21 Sep 2021 13:33:41 +0300 Message-Id: <20210921103346.64824-2-tony@atomide.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210921103346.64824-1-tony@atomide.com> References: <20210921103346.64824-1-tony@atomide.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We check for -EAGAIN in n_tty_write() but never currently get it from process_output_block(). Let's add -EAGAIN handling and break out with 0 bytes processed. Note that if we return -EAGAIN from n_tty_write(), it will be treated as error by the caller rather than a retry. Looking at the patch description for commit 9ef8927f45f2 ("n_tty: check for negative and zero space return from tty_write_room") it looks like we have not made use of -EGAIN from process_output_block() so far, so this does not seem like it's currently needed as a fix. We can use -EAGAIN for serial layer power management changes as we now will make use of write_room() returning 0 for an idled serial port. Signed-off-by: Tony Lindgren --- drivers/tty/n_tty.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -549,6 +549,8 @@ static ssize_t process_output_block(struct tty_struct *tty, space = tty_write_room(tty); if (space <= 0) { mutex_unlock(&ldata->output_lock); + if (!space) + space = -EAGAIN; return space; } if (nr > space) @@ -2287,8 +2289,10 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, while (nr > 0) { ssize_t num = process_output_block(tty, b, nr); if (num < 0) { - if (num == -EAGAIN) - break; + if (num == -EAGAIN) { + retval = 0; + goto break_out; + } retval = num; goto break_out; } -- 2.33.0