Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1003586rdb; Fri, 16 Feb 2024 02:13:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXVkRB2P97PKnctvS7hErEiDI5S7Xt2tDUSHbt65tQoY34mj6KNSUnTSSiRAnA7WTnNuYKqesAWTxyismxc+S2NUKGNqBbmLcLL5AX29w== X-Google-Smtp-Source: AGHT+IECpzG+Vuxf2+VbV8dG+TkuUQVZMnr9Kuadll/xK0wVUPq/n1d6Jrt1r7zQOZJ1oq7Ula8f X-Received: by 2002:a05:6402:5518:b0:561:ee53:504f with SMTP id fi24-20020a056402551800b00561ee53504fmr7374321edb.5.1708078385395; Fri, 16 Feb 2024 02:13:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708078385; cv=pass; d=google.com; s=arc-20160816; b=X/boustcGzynGt9BhE5gsDrumou6YSuupFFRa3r6N/I4gfw+aQwU3sJ2ngB70MI9+p OGoYcmORFFHFfKZQrUE5P5yd/MzDK0DgnsW3F1B2LVpKl8hUCJz4w4TJ8Vajv7/wynwq sBD70H95V+HaQUcdwoO0/b6wWXynnM26Y3xI/ThlhfxcH4qUU81f/BbEfqcmje0zu1ta ndYTgvOOAG3eGywQrFowpY9C5JWUAmq+Ji5mw0ImK9IKBaTQftfAh/3wfdILkK6jBmoY rkp0hlpFRLNbofRXdgdB8WhlF7kFwHEm3zLMib8VuHdnu7PhE47RROPyLUltI/sbJRy3 RmYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:date:from :dkim-signature; bh=pmFs0E/QRVxmjKUGNu5hXV/5QVFU+qRQAN9tPwVw50M=; fh=cOj0fwV46MSBZ8KvbLWr60X1fb5G/aQCYqkfLmYq6gQ=; b=h6xP3qJasplECktDL7TcjzSBdX5ueVj0PeVVnp/gZz/28fPBZt4jG99VTwjDI3L6JE okJx3OcFbk+LJY88y+9hOD6tBZ8x9gI3tEVVeeU13p5PnUCYmSLrtYnxvBvgo5C6/b1b Xo6OWzXB1Vqo1s18OJ+trkOk3GMdAEUEZjjSqVczzHRc+K/DIOT4cfCGBtKfbr+3EATp NadNoq0+kpBvnLk6ApBxDR8MClRy8takw6mGMAYetFNZOtVUQzDGHuxmFNV/BVrmKNJ3 xAKJvs0lIOjfhrP02a1SLvH/qLvUl7GilbL+HqPqvYVvb8v5VceMLY+vzzJF7e1lVpge yDUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mH+Z5ojf; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-68425-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68425-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id be26-20020a0564021a3a00b00563e0884b03si650363edb.669.2024.02.16.02.13.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 02:13:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68425-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mH+Z5ojf; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-68425-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68425-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F09BC1F217F8 for ; Fri, 16 Feb 2024 10:13:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D56BE1C691; Fri, 16 Feb 2024 10:12:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mH+Z5ojf" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 914E71C2AD; Fri, 16 Feb 2024 10:12:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708078376; cv=none; b=Mminsbmh9kco8DL6U9vMHmXFHDNAgKA6sRIfBNzzNV8VQGKJBIixhzeIRlEENJp3PXgTsoBGFiA6LYEc9ZLOGo6dOLz0rKQW3gW13u8iyNuXxwdAih5T9ORD1IrWPm8FMSaD0MmDG1VrMLiczeBPumVnl+GVKGd3lwtEnTjZzz8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708078376; c=relaxed/simple; bh=pD+T+OI+k9DeYvh40FmpgO7ATobiBnn71HQgox1KK0s=; h=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=m5rdDRl8DFMd+YHzLcC3ARdCghl/WZB4fTvjyNB/BFP5g/34oZduMZ3dhShq3Byo2g22Ur8Y776G1juC2cveEApfvrwTdT1IdEAEPLVRfr+QJjWK3kEOMG7JUChRIyiUh5b/wHNwhsfHZXsmHo6dATBUK2uF3ZHGiJI9SVKjqLE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=mH+Z5ojf; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708078375; x=1739614375; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=pD+T+OI+k9DeYvh40FmpgO7ATobiBnn71HQgox1KK0s=; b=mH+Z5ojfT3F34ZbPiK5FdqpascKE2BfkVv5lx4ZyKOfqWJD287n+jA4v UQOHb/xuao12j7/rmra1j3kl842kGSOx/nREkEOyM03Bj943ZGWnnZOYg SJl70uT2LyqgrSzfvsTkXsoOAJdahbJCsFOY6D12v9PV5ooUFeJOmTCPs Fym4LdFY3jpXjxUyvoFxWLaNfy7MA++p5Ske5fzsEJtrqhDN/y/Q0+9En qLAqJh1DM7oUJDFJrv7yQBriZXRTO9VnpK5Kaap7dfiu66fahHPNqdTMg zSbEvRAdBAc+wqKew9i8BW4lGFbguCQNFDXuMmwB6FL442ZX4B7hWTzAC g==; X-IronPort-AV: E=McAfee;i="6600,9927,10985"; a="2069396" X-IronPort-AV: E=Sophos;i="6.06,164,1705392000"; d="scan'208";a="2069396" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2024 02:12:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,164,1705392000"; d="scan'208";a="8404669" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.94.248.234]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2024 02:12:49 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Fri, 16 Feb 2024 12:12:44 +0200 (EET) To: Leonardo Bras cc: Greg Kroah-Hartman , Jiri Slaby , Thomas Gleixner , Tony Lindgren , Andy Shevchenko , John Ogness , =?ISO-8859-15?Q?Uwe_Kleine-K=F6nig?= , Florian Fainelli , Shanker Donthineni , LKML , linux-serial Subject: Re: [RFC PATCH v2 4/4] tty/serial8250: Make use of IRQ_HANDLED_MANY interface In-Reply-To: <20240216075948.131372-6-leobras@redhat.com> Message-ID: <8c080e51-6ae5-0e8a-69f6-ca3666164248@linux.intel.com> References: <20240216075948.131372-2-leobras@redhat.com> <20240216075948.131372-6-leobras@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Fri, 16 Feb 2024, Leonardo Bras wrote: > For every TX byte an IRQ is requested. > On threaded IRQs, the handler calls serial8250_tx_chars can send multiple > bytes, limited to it's queue size (tx_loadsz). Perhaps I'm missing something here but I don't understand what this tries to say. - 8250 driver gets TX empty IRQ - We write x bytes to FIFO - UART blasts those bits to wire, eventually emptying FIFO - We get the next TX empty IRQ What in this makes "for every TX byte an IRQ is requested" true? There's one IRQ only for every x bytes TX'ed as far as I can tell!?! -- i. > When this happens, the handler return IRQ_HANDLED with reduces the > unhandled IRQ counter only by 1, even though many requests have been > handled at once. > > This causes the unhandled IRQ counter to go up until it reaches the maximum > and causes the registered IRQ to be disabled, thus breaking the serial > console. > > Make use of the newly introduced IRQ_HANDLED_MANY interface to return the > number of requests handled, so the unhandled IRQ counter can get decreased > accordingly. > > Signed-off-by: Leonardo Bras > --- > include/linux/serial_8250.h | 2 +- > drivers/tty/serial/8250/8250_core.c | 13 ++++++++----- > drivers/tty/serial/8250/8250_port.c | 16 ++++++++++------ > 3 files changed, 19 insertions(+), 12 deletions(-) > > diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h > index ec46e3b49ee99..c9d4271b71d70 100644 > --- a/include/linux/serial_8250.h > +++ b/include/linux/serial_8250.h > @@ -200,7 +200,7 @@ int fsl8250_handle_irq(struct uart_port *port); > int serial8250_handle_irq(struct uart_port *port, unsigned int iir); > u16 serial8250_rx_chars(struct uart_8250_port *up, u16 lsr); > void serial8250_read_char(struct uart_8250_port *up, u16 lsr); > -void serial8250_tx_chars(struct uart_8250_port *up); > +int serial8250_tx_chars(struct uart_8250_port *up); > unsigned int serial8250_modem_status(struct uart_8250_port *up); > void serial8250_init_port(struct uart_8250_port *up); > void serial8250_set_defaults(struct uart_8250_port *up); > diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c > index ae637155fe7cd..2fab9102eec45 100644 > --- a/drivers/tty/serial/8250/8250_core.c > +++ b/drivers/tty/serial/8250/8250_core.c > @@ -110,7 +110,7 @@ static irqreturn_t serial8250_interrupt(int irq, void *dev_id) > { > struct irq_info *i = dev_id; > struct list_head *l, *end = NULL; > - int pass_counter = 0, handled = 0; > + int pass_counter = 0, handled_total = 0; > > pr_debug("%s(%d): start\n", __func__, irq); > > @@ -120,15 +120,18 @@ static irqreturn_t serial8250_interrupt(int irq, void *dev_id) > do { > struct uart_8250_port *up; > struct uart_port *port; > + int handled; > > up = list_entry(l, struct uart_8250_port, list); > port = &up->port; > > - if (port->handle_irq(port)) { > - handled = 1; > + handled = port->handle_irq(port); > + if (handled) { > + handled_total += handled; > end = NULL; > - } else if (end == NULL) > + } else if (end == NULL) { > end = l; > + } > > l = l->next; > > @@ -140,7 +143,7 @@ static irqreturn_t serial8250_interrupt(int irq, void *dev_id) > > pr_debug("%s(%d): end\n", __func__, irq); > > - return IRQ_RETVAL(handled); > + return IRQ_RETVAL_MANY(handled_total); > } > > /* > diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c > index f799c34f1603c..74d53507a73d4 100644 > --- a/drivers/tty/serial/8250/8250_port.c > +++ b/drivers/tty/serial/8250/8250_port.c > @@ -1802,7 +1802,7 @@ u16 serial8250_rx_chars(struct uart_8250_port *up, u16 lsr) > } > EXPORT_SYMBOL_GPL(serial8250_rx_chars); > > -void serial8250_tx_chars(struct uart_8250_port *up) > +int serial8250_tx_chars(struct uart_8250_port *up) > { > struct uart_port *port = &up->port; > struct circ_buf *xmit = &port->state->xmit; > @@ -1810,15 +1810,15 @@ void serial8250_tx_chars(struct uart_8250_port *up) > > if (port->x_char) { > uart_xchar_out(port, UART_TX); > - return; > + return 0; > } > if (uart_tx_stopped(port)) { > serial8250_stop_tx(port); > - return; > + return 0; > } > if (uart_circ_empty(xmit)) { > __stop_tx(up); > - return; > + return 0; > } > > count = up->tx_loadsz; > @@ -1858,6 +1858,9 @@ void serial8250_tx_chars(struct uart_8250_port *up) > */ > if (uart_circ_empty(xmit) && !(up->capabilities & UART_CAP_RPM)) > __stop_tx(up); > + > + /* Return number of chars sent */ > + return up->tx_loadsz - count; > } > EXPORT_SYMBOL_GPL(serial8250_tx_chars); > > @@ -1923,6 +1926,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) > bool skip_rx = false; > unsigned long flags; > u16 status; > + int handled = 0; > > if (iir & UART_IIR_NO_INT) > return 0; > @@ -1956,14 +1960,14 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) > serial8250_modem_status(up); > if ((status & UART_LSR_THRE) && (up->ier & UART_IER_THRI)) { > if (!up->dma || up->dma->tx_err) > - serial8250_tx_chars(up); > + handled = serial8250_tx_chars(up); > else if (!up->dma->tx_running) > __stop_tx(up); > } > > uart_unlock_and_check_sysrq_irqrestore(port, flags); > > - return 1; > + return handled ? : 1; > } > EXPORT_SYMBOL_GPL(serial8250_handle_irq); > >