linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maarten Brock <m.brock@vanmierlo.com>
To: Daniel Mack <daniel@zonque.org>
Cc: devicetree@vger.kernel.org, linux-serial@vger.kernel.org,
	gregkh@linuxfoundation.org, robh+dt@kernel.org, jslaby@suse.com,
	pascal.huerst@gmail.com, linux-serial-owner@vger.kernel.org
Subject: Re: [PATCH 4/4] sc16is7xx: Use threaded IRQ
Date: Sat, 09 May 2020 14:55:17 +0200	[thread overview]
Message-ID: <61fdcf12976c924fd86c5203aba673a7@vanmierlo.com> (raw)
In-Reply-To: <20200508143757.2609740-5-daniel@zonque.org>

On 2020-05-08 16:37, Daniel Mack wrote:
> Use a threaded IRQ handler to get rid of the irq_work kthread.
> This also allows for the driver to use interrupts generated by
> a threaded controller.
> 
> Signed-off-by: Daniel Mack <daniel@zonque.org>
> ---
>  drivers/tty/serial/sc16is7xx.c | 18 +++++-------------
>  1 file changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/tty/serial/sc16is7xx.c 
> b/drivers/tty/serial/sc16is7xx.c
> index 0997a5cac02a..e3c5b9501764 100644
> --- a/drivers/tty/serial/sc16is7xx.c
> +++ b/drivers/tty/serial/sc16is7xx.c
> @@ -328,7 +328,6 @@ struct sc16is7xx_port {
>  	unsigned char			buf[SC16IS7XX_FIFO_SIZE];
>  	struct kthread_worker		kworker;
>  	struct task_struct		*kworker_task;
> -	struct kthread_work		irq_work;
>  	struct mutex			efr_lock;
>  	struct sc16is7xx_one		p[0];
>  };
> @@ -711,9 +710,9 @@ static bool sc16is7xx_port_irq(struct
> sc16is7xx_port *s, int portno)
>  	return true;
>  }
> 
> -static void sc16is7xx_ist(struct kthread_work *ws)
> +static irqreturn_t sc16is7xx_irq(int irq, void *dev_id)
>  {
> -	struct sc16is7xx_port *s = to_sc16is7xx_port(ws, irq_work);
> +	struct sc16is7xx_port *s = (struct sc16is7xx_port *)dev_id;
> 
>  	mutex_lock(&s->efr_lock);
> 
> @@ -728,13 +727,6 @@ static void sc16is7xx_ist(struct kthread_work *ws)
>  	}
> 
>  	mutex_unlock(&s->efr_lock);
> -}
> -
> -static irqreturn_t sc16is7xx_irq(int irq, void *dev_id)
> -{
> -	struct sc16is7xx_port *s = (struct sc16is7xx_port *)dev_id;
> -
> -	kthread_queue_work(&s->kworker, &s->irq_work);
> 
>  	return IRQ_HANDLED;
>  }
> @@ -1230,7 +1222,6 @@ static int sc16is7xx_probe(struct device *dev,
>  	mutex_init(&s->efr_lock);
> 
>  	kthread_init_worker(&s->kworker);
> -	kthread_init_work(&s->irq_work, sc16is7xx_ist);
>  	s->kworker_task = kthread_run(kthread_worker_fn, &s->kworker,
>  				      "sc16is7xx");
>  	if (IS_ERR(s->kworker_task)) {
> @@ -1317,8 +1308,9 @@ static int sc16is7xx_probe(struct device *dev,
>  	}
> 
>  	/* Setup interrupt */
> -	ret = devm_request_irq(dev, irq, sc16is7xx_irq,
> -			       IRQF_TRIGGER_FALLING, dev_name(dev), s);
> +	ret = devm_request_threaded_irq(dev, irq, NULL, sc16is7xx_irq,
> +					IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> +					dev_name(dev), s);
>  	if (!ret)
>  		return 0;

Since UART0 is first handled completely in the for loop before UART1 is
handled, a new interrupt may arise on UART0 while UART1 is being 
handled.
The result is a missed interrupt since the IRQ line might not *FALL* 
again.

Therefor I suggest to change IRQF_TRIGGER_FALLING to IRQF_TRIGGER_LOW. 
This
way the thread will be retriggered after IRQ_HANDLED is returned.

Maarten


  reply	other threads:[~2020-05-09 12:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08 14:37 [PATCH 0/4] sc16is7xx: Add IrDA mode and threaded IRQ Daniel Mack
2020-05-08 14:37 ` [PATCH 1/4] dt-bindings: sc16is7xx: Add flag to activate IrDA mode Daniel Mack
2020-05-18 18:08   ` Rob Herring
2020-05-18 18:41     ` Daniel Mack
2020-05-19 12:01       ` Maarten Brock
2020-05-08 14:37 ` [PATCH 2/4] " Daniel Mack
2020-05-08 14:37 ` [PATCH 3/4] sc16is7xx: Always use falling edge IRQ Daniel Mack
2020-05-09 12:41   ` Maarten Brock
2020-05-08 14:37 ` [PATCH 4/4] sc16is7xx: Use threaded IRQ Daniel Mack
2020-05-09 12:55   ` Maarten Brock [this message]
2020-05-17 20:44     ` Daniel Mack
2020-05-18 11:14       ` Maarten Brock
2020-05-18 16:57         ` Daniel Mack
2020-05-19 16:32           ` Maarten Brock
2020-05-19 17:37             ` Daniel Mack

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=61fdcf12976c924fd86c5203aba673a7@vanmierlo.com \
    --to=m.brock@vanmierlo.com \
    --cc=daniel@zonque.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-serial-owner@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=pascal.huerst@gmail.com \
    --cc=robh+dt@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).