mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Tapio Reijonen <tapio.reijonen@vaisala.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alexander Shiyan <shc_work@mail.ru>,
	Hugo Villeneuve <hvilleneuve@dimonoff.com>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH v2] serial: max310x: improve interrupt handling
Date: Fri, 5 Sep 2025 11:04:02 +0200	[thread overview]
Message-ID: <3e80ed12-1d47-46f3-968d-c9246c4949c5@kernel.org> (raw)
In-Reply-To: <20250905-master-max310x-improve-interrupt-handling-v2-1-7387651a5ed2@vaisala.com>

On 05. 09. 25, 10:54, Tapio Reijonen wrote:
> When there is a heavy load of receiving characters to all
> four UART's, the warning 'Hardware RX FIFO overrun' is
> sometimes detected.
> The current implementation always service first the highest UART
> until no more interrupt and then service another UART
> (ex: UART3 will be serviced for as long as there are interrupts
> for it, then UART2, etc).
> 
> This commit handle all individual interrupt sources before
> reading the global IRQ register again.
> 
> This commit has also a nice side-effect of improving the efficiency
> of the driver by reducing the number of reads of the global
> IRQ register.
> 
> Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>
> ---
> Changes in v2:
> - Improve content of the commit message
> - Fix a line indention in prevoius patch
> - According review comments, changed to use for_each_clear_bit
>    to simplify serve all IRQs in a loop.
>    NOTE: When a bit in IRQ[n] is set 0 the associated UART’s
>    internal IRQ is generated.
> - Link to v1: https://lore.kernel.org/r/20250903-master-max310x-improve-interrupt-handling-v1-1-bfb44829e760@vaisala.com
> ---
>   drivers/tty/serial/max310x.c | 18 ++++++++++++++----
>   1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
> index ce260e9949c3c268e706b2615d6fc01adc21e49b..464f2828bd304198d79046e79b2a8a0893e5cd77 100644
> --- a/drivers/tty/serial/max310x.c
> +++ b/drivers/tty/serial/max310x.c
> @@ -825,14 +825,24 @@ static irqreturn_t max310x_ist(int irq, void *dev_id)
>   	if (s->devtype->nr > 1) {
>   		do {
>   			unsigned int val = ~0;
> +			unsigned long irq;
> +			unsigned long port;
> +			bool done = true;
>   
>   			WARN_ON_ONCE(regmap_read(s->regmap,
>   						 MAX310X_GLOBALIRQ_REG, &val));
> -			val = ((1 << s->devtype->nr) - 1) & ~val;
> -			if (!val)
> +
> +			irq = val;
> +
> +			for_each_clear_bit(port, &irq, s->devtype->nr) {

port can be uint, no need for ulong.

> +				done = false;
> +
> +				if (max310x_port_irq(s, port) == IRQ_HANDLED)
> +					handled = true;
> +			}

Hey, this looks to be the order of magnitude saner!

> +
> +			if (done)
>   				break;
> -			if (max310x_port_irq(s, fls(val) - 1) == IRQ_HANDLED)
> -				handled = true;
>   		} while (1);

So now, this should perhaps be "while (!done)"?

thanks,
-- 
js
suse labs

      reply	other threads:[~2025-09-05  9:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05  8:54 Tapio Reijonen
2025-09-05  9:04 ` Jiri Slaby [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3e80ed12-1d47-46f3-968d-c9246c4949c5@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hvilleneuve@dimonoff.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=shc_work@mail.ru \
    --cc=tapio.reijonen@vaisala.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®