All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Jan Kiszka <jan.kiszka@siemens.com>, Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Daniel Mack <daniel@zonque.org>,
	Haojian Zhuang <haojian.zhuang@gmail.com>,
	Robert Jarzmik <robert.jarzmik@free.fr>,
	linux-kernel@vger.kernel.org,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Jarkko Nikula <jarkko.nikula@linux.intel.com>
Subject: Re: [PATCH v2 2/3] spi: pxa2xx: Prepare for edge-triggered interrupts
Date: Mon, 16 Jan 2017 21:07:17 +0200	[thread overview]
Message-ID: <1484593637.2133.152.camel@linux.intel.com> (raw)
In-Reply-To: <7b15a0910a3ad861fd32161c72559bafa7b71e29.1484592296.git.jan.kiszka@siemens.com>

On Mon, 2017-01-16 at 19:44 +0100, Jan Kiszka wrote:
> When using the a device with edge-triggered interrupts, such as MSIs,
> the interrupt handler has to ensure that there is a point in time
> during
> its execution where all interrupts sources are silent so that a new
> event can trigger a new interrupt again.
> 
> This is achieved here by looping over SSSR evaluation. We need to take
> into account that SSCR1 may be changed by the transfer handler, thus
> we
> need to redo the mask calculation, at least regarding the volatile
> interrupt enable bit (TIE).
> 

So, more comments/questions below.

>  
>  	sccr1_reg = pxa2xx_spi_read(drv_data, SSCR1);
>  
> -	/* Ignore possible writes if we don't need to write */
> -	if (!(sccr1_reg & SSCR1_TIE))
> -		mask &= ~SSSR_TFS;
> -
>  	/* Ignore RX timeout interrupt if it is disabled */
>  	if (!(sccr1_reg & SSCR1_TINTE))
>  		mask &= ~SSSR_TINT;
>  
> -	if (!(status & mask))
> -		return IRQ_NONE;
> +	while (1) {

Can we switch to do-while and move previous block here? Btw, can TINTE
bit be set again during a loop?

> +		/* Ignore possible writes if we don't need to write
> */
> +		if (!(sccr1_reg & SSCR1_TIE))
> +			mask &= ~SSSR_TFS;
>  
> -	if (!drv_data->master->cur_msg) {
> -		handle_bad_msg(drv_data);
> -		/* Never fail */
> -		return IRQ_HANDLED;
> -	}
> +		if (!(status & mask))
> +			return ret;
> +
> +		if (!drv_data->master->cur_msg) {
> +			handle_bad_msg(drv_data);
> +			/* Never fail */
> +			return IRQ_HANDLED;
> +		}
> +

> +		ret |= drv_data->transfer_handler(drv_data);

So, we might call handler several times. This needs to be commented in
the code why you do so.

>  
> -	return drv_data->transfer_handler(drv_data);
> +		status = pxa2xx_spi_read(drv_data, SSSR);

Would it be possible to get all 1:s from the register
(something/autosuspend just powered off it by timeout?) ?

> +		sccr1_reg = pxa2xx_spi_read(drv_data, SSCR1);
> +	}
>  }
>  
>  /*

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

WARNING: multiple messages have this Message-ID (diff)
From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Jan Kiszka <jan.kiszka-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Daniel Mack <daniel-cYrQPVfZoowdnm+yROfE0A@public.gmane.org>,
	Haojian Zhuang
	<haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Robert Jarzmik <robert.jarzmik-GANU6spQydw@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Mika Westerberg
	<mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	Jarkko Nikula
	<jarkko.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Subject: Re: [PATCH v2 2/3] spi: pxa2xx: Prepare for edge-triggered interrupts
Date: Mon, 16 Jan 2017 21:07:17 +0200	[thread overview]
Message-ID: <1484593637.2133.152.camel@linux.intel.com> (raw)
In-Reply-To: <7b15a0910a3ad861fd32161c72559bafa7b71e29.1484592296.git.jan.kiszka-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>

On Mon, 2017-01-16 at 19:44 +0100, Jan Kiszka wrote:
> When using the a device with edge-triggered interrupts, such as MSIs,
> the interrupt handler has to ensure that there is a point in time
> during
> its execution where all interrupts sources are silent so that a new
> event can trigger a new interrupt again.
> 
> This is achieved here by looping over SSSR evaluation. We need to take
> into account that SSCR1 may be changed by the transfer handler, thus
> we
> need to redo the mask calculation, at least regarding the volatile
> interrupt enable bit (TIE).
> 

So, more comments/questions below.

>  
>  	sccr1_reg = pxa2xx_spi_read(drv_data, SSCR1);
>  
> -	/* Ignore possible writes if we don't need to write */
> -	if (!(sccr1_reg & SSCR1_TIE))
> -		mask &= ~SSSR_TFS;
> -
>  	/* Ignore RX timeout interrupt if it is disabled */
>  	if (!(sccr1_reg & SSCR1_TINTE))
>  		mask &= ~SSSR_TINT;
>  
> -	if (!(status & mask))
> -		return IRQ_NONE;
> +	while (1) {

Can we switch to do-while and move previous block here? Btw, can TINTE
bit be set again during a loop?

> +		/* Ignore possible writes if we don't need to write
> */
> +		if (!(sccr1_reg & SSCR1_TIE))
> +			mask &= ~SSSR_TFS;
>  
> -	if (!drv_data->master->cur_msg) {
> -		handle_bad_msg(drv_data);
> -		/* Never fail */
> -		return IRQ_HANDLED;
> -	}
> +		if (!(status & mask))
> +			return ret;
> +
> +		if (!drv_data->master->cur_msg) {
> +			handle_bad_msg(drv_data);
> +			/* Never fail */
> +			return IRQ_HANDLED;
> +		}
> +

> +		ret |= drv_data->transfer_handler(drv_data);

So, we might call handler several times. This needs to be commented in
the code why you do so.

>  
> -	return drv_data->transfer_handler(drv_data);
> +		status = pxa2xx_spi_read(drv_data, SSSR);

Would it be possible to get all 1:s from the register
(something/autosuspend just powered off it by timeout?) ?

> +		sccr1_reg = pxa2xx_spi_read(drv_data, SSCR1);
> +	}
>  }
>  
>  /*

-- 
Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Intel Finland Oy
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: andriy.shevchenko@linux.intel.com (Andy Shevchenko)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/3] spi: pxa2xx: Prepare for edge-triggered interrupts
Date: Mon, 16 Jan 2017 21:07:17 +0200	[thread overview]
Message-ID: <1484593637.2133.152.camel@linux.intel.com> (raw)
In-Reply-To: <7b15a0910a3ad861fd32161c72559bafa7b71e29.1484592296.git.jan.kiszka@siemens.com>

On Mon, 2017-01-16 at 19:44 +0100, Jan Kiszka wrote:
> When using the a device with edge-triggered interrupts, such as MSIs,
> the interrupt handler has to ensure that there is a point in time
> during
> its execution where all interrupts sources are silent so that a new
> event can trigger a new interrupt again.
> 
> This is achieved here by looping over SSSR evaluation. We need to take
> into account that SSCR1 may be changed by the transfer handler, thus
> we
> need to redo the mask calculation, at least regarding the volatile
> interrupt enable bit (TIE).
> 

So, more comments/questions below.

> ?
> ?	sccr1_reg = pxa2xx_spi_read(drv_data, SSCR1);
> ?
> -	/* Ignore possible writes if we don't need to write */
> -	if (!(sccr1_reg & SSCR1_TIE))
> -		mask &= ~SSSR_TFS;
> -
> ?	/* Ignore RX timeout interrupt if it is disabled */
> ?	if (!(sccr1_reg & SSCR1_TINTE))
> ?		mask &= ~SSSR_TINT;
> ?
> -	if (!(status & mask))
> -		return IRQ_NONE;
> +	while (1) {

Can we switch to do-while and move previous block here? Btw, can TINTE
bit be set again during a loop?

> +		/* Ignore possible writes if we don't need to write
> */
> +		if (!(sccr1_reg & SSCR1_TIE))
> +			mask &= ~SSSR_TFS;
> ?
> -	if (!drv_data->master->cur_msg) {
> -		handle_bad_msg(drv_data);
> -		/* Never fail */
> -		return IRQ_HANDLED;
> -	}
> +		if (!(status & mask))
> +			return ret;
> +
> +		if (!drv_data->master->cur_msg) {
> +			handle_bad_msg(drv_data);
> +			/* Never fail */
> +			return IRQ_HANDLED;
> +		}
> +

> +		ret |= drv_data->transfer_handler(drv_data);

So, we might call handler several times. This needs to be commented in
the code why you do so.

> ?
> -	return drv_data->transfer_handler(drv_data);
> +		status = pxa2xx_spi_read(drv_data, SSSR);

Would it be possible to get all 1:s from the register
(something/autosuspend just powered off it by timeout?) ?

> +		sccr1_reg = pxa2xx_spi_read(drv_data, SSCR1);
> +	}
> ?}
> ?
> ?/*

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

  reply	other threads:[~2017-01-16 19:11 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16 18:44 [PATCH v2 0/3] spi: pca2xx: Prepare for and enable MSI support Jan Kiszka
2017-01-16 18:44 ` Jan Kiszka
2017-01-16 18:44 ` Jan Kiszka
2017-01-16 18:44 ` [PATCH v2 1/3] spi: pxa2xx: Factor out handle_bad_msg Jan Kiszka
2017-01-16 18:44   ` Jan Kiszka
2017-01-16 18:44   ` Jan Kiszka
2017-01-17 11:18   ` Jarkko Nikula
2017-01-17 11:18     ` Jarkko Nikula
2017-01-17 11:18     ` Jarkko Nikula
2017-01-17 18:46   ` Applied "spi: pxa2xx: Factor out handle_bad_msg" to the spi tree Mark Brown
2017-01-17 18:46     ` Mark Brown
2017-01-17 18:46     ` Mark Brown
2017-01-16 18:44 ` [PATCH v2 2/3] spi: pxa2xx: Prepare for edge-triggered interrupts Jan Kiszka
2017-01-16 18:44   ` Jan Kiszka
2017-01-16 19:07   ` Andy Shevchenko [this message]
2017-01-16 19:07     ` Andy Shevchenko
2017-01-16 19:07     ` Andy Shevchenko
2017-01-16 19:46     ` Jan Kiszka
2017-01-16 19:46       ` Jan Kiszka
2017-01-16 19:46       ` Jan Kiszka
2017-01-17 18:52       ` Jan Kiszka
2017-01-17 18:52         ` Jan Kiszka
2017-01-17 18:52         ` Jan Kiszka
2017-01-17  7:54   ` Robert Jarzmik
2017-01-17  7:54     ` Robert Jarzmik
2017-01-17  7:54     ` Robert Jarzmik
2017-01-17  8:05     ` Jan Kiszka
2017-01-17  8:05       ` Jan Kiszka
2017-01-17  8:05       ` Jan Kiszka
2017-01-18  8:21       ` Robert Jarzmik
2017-01-18  8:21         ` Robert Jarzmik
2017-01-18  8:21         ` Robert Jarzmik
2017-01-18  9:33         ` Jan Kiszka
2017-01-18  9:33           ` Jan Kiszka
2017-01-18  9:33           ` Jan Kiszka
2017-01-18 12:46           ` Mark Brown
2017-01-18 12:46             ` Mark Brown
2017-01-19 15:34             ` Jan Kiszka
2017-01-19 15:34               ` Jan Kiszka
2017-01-19 15:34               ` Jan Kiszka
2017-01-19 19:37               ` [PATCH v3 " Jan Kiszka
2017-01-19 19:37                 ` Jan Kiszka
2017-01-19 19:37                 ` Jan Kiszka
2017-01-19 19:57                 ` Mark Brown
2017-01-19 19:57                   ` Mark Brown
2017-01-19 19:57                   ` Mark Brown
2017-01-19 20:04                   ` Andy Shevchenko
2017-01-19 20:04                     ` Andy Shevchenko
2017-01-19 20:04                     ` Andy Shevchenko
2017-01-20 12:21                     ` Mark Brown
2017-01-20 12:21                       ` Mark Brown
2017-01-20 15:29                       ` Jan Kiszka
2017-01-20 15:29                         ` Jan Kiszka
2017-01-20 15:29                         ` Jan Kiszka
2017-01-20 16:14                         ` Mark Brown
2017-01-20 16:14                           ` Mark Brown
2017-01-20 16:14                           ` Mark Brown
2017-01-20  7:42                 ` Robert Jarzmik
2017-01-20  7:42                   ` Robert Jarzmik
2017-01-20  7:42                   ` Robert Jarzmik
2017-01-24 18:39               ` Applied "spi: pxa2xx: Prepare for edge-triggered interrupts" to the spi tree Mark Brown
2017-01-24 18:39                 ` Mark Brown
2017-01-17  7:58   ` [PATCH v2 2/3] spi: pxa2xx: Prepare for edge-triggered interrupts Robert Jarzmik
2017-01-17  7:58     ` Robert Jarzmik
2017-01-17  7:58     ` Robert Jarzmik
2017-01-17  8:10     ` Jan Kiszka
2017-01-17  8:10       ` Jan Kiszka
2017-01-17  8:10       ` Jan Kiszka
2017-01-17 13:11       ` Jarkko Nikula
2017-01-17 13:11         ` Jarkko Nikula
2017-01-17 14:43         ` Jan Kiszka
2017-01-17 14:43           ` Jan Kiszka
2017-01-17 14:43           ` Jan Kiszka
2017-01-16 18:44 ` [PATCH v2 3/3] spi: pca2xx-pci: Allow MSI Jan Kiszka
2017-01-16 18:44   ` Jan Kiszka
2017-01-16 18:44   ` Jan Kiszka
2017-01-16 19:08   ` Andy Shevchenko
2017-01-16 19:08     ` Andy Shevchenko
2017-01-16 19:08     ` Andy Shevchenko
2017-01-17 11:18     ` Jarkko Nikula
2017-01-17 11:18       ` Jarkko Nikula
2017-01-24 18:39   ` Applied "spi: pca2xx-pci: Allow MSI" to the spi tree Mark Brown
2017-01-24 18:39     ` Mark Brown
2017-01-24 18:39     ` Mark Brown

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=1484593637.2133.152.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=daniel@zonque.org \
    --cc=haojian.zhuang@gmail.com \
    --cc=jan.kiszka@siemens.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=robert.jarzmik@free.fr \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.