linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Mark Brown <broonie@kernel.org>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>,
	linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Daniel Mack <daniel@zonque.org>,
	Haojian Zhuang <haojian.zhuang@gmail.com>,
	linux-kernel@vger.kernel.org,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Jarkko Nikula <jarkko.nikula@linux.intel.com>,
	Sascha Weisenberger <sascha.weisenberger@siemens.com>
Subject: Re: [PATCH v2 2/3] spi: pxa2xx: Prepare for edge-triggered interrupts
Date: Thu, 19 Jan 2017 16:34:31 +0100	[thread overview]
Message-ID: <7e5fb21d-35bd-6ac3-9e6f-cffed656997f@siemens.com> (raw)
In-Reply-To: <20170118124645.6ugjwbfeq5vsh2to@sirena.org.uk>


[-- Attachment #1.1: Type: text/plain, Size: 3180 bytes --]

On 2017-01-18 13:46, Mark Brown wrote:
> On Wed, Jan 18, 2017 at 10:33:07AM +0100, Jan Kiszka wrote:
>> On 2017-01-18 09:21, Robert Jarzmik wrote:
> 
>>>>>> +	while (1) {
> 
>>>>> This bit worries me a bit, as this can be either :
>>>>>  - hogging the SoC's CPU, endlessly running
>>>>>  - or even worse, blocking the CPU for ever
> 
>>>>> The question behind is, should this be done in a top-half, or moved to a irq
>>>>> thread ?
> 
>>>> Every device with a broken interrupt source can hog CPUs, nothing
>>>> special with this one. If you don't close the loop in the handler
>>>> itself, you close it over the hardware retriggering the interrupt over
>>>> and over again.
> 
>>> I'm not speaking of a broken interrupt source, I'm speaking of a broken code,
>>> such as in the handler, or broken status readback, or lack of understanding on
>>> the status register which may imply the while(1) to loop forever.
> 
>>>> So, I don't see a point in offloading to a thread. The normal case is
>>>> some TX done (FIFO available) event followed by an RX event, then the
>>>> transfer is complete, isn't it?
> 
>>> The point is if you stay forever in the while(1) loop, you can at least have a
>>> print a backtrace (LOCKUP_DETECTOR).
> 
>> I won't consider "debugability" as a good reason to move interrupt
>> handlers into threads. There should be real workload that requires
>> offloading or specific prioritization.
> 
> It's failure mitigation - you're translating a hard lockup into
> something that will potentially allow the system to soldier on which is
> likely to be less severe for the user as well as making things easier to
> figure out.  If we're doing something like this I'd at least have a
> limit on how long we allow the interrupt to scream.
> 

OK, OK, if that is the biggest worry, I can change the pattern from
loop-based to SCCR1-based, i.e. mask all interrupt sources once per
interrupt so that we enforce a falling edge. Fine.

But now I'm looking at the driver, wondering who all is fiddling under
which conditions with SCCR1. There are a lot of RMW patterns, but I do
not see the locking pattern behind that. Are all RMW accesses run only
in the interrupt handler context? Unlikely, at least with the dmaengine
in the loop.

Closing my eyes regarding this potential issue for now, the patch could
become as simple as

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index 0d10090..f9c2329 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -785,6 +785,9 @@ static irqreturn_t ssp_int(int irq, void *dev_id)
 	if (!(status & mask))
 		return IRQ_NONE;
 
+	pxa2xx_spi_write(drv_data, SSCR1, sccr1_reg & ~drv_data->int_cr1);
+	pxa2xx_spi_write(drv_data, SSCR1, sccr1_reg);
+
 	if (!drv_data->master->cur_msg) {
 		handle_bad_msg(drv_data);
 		/* Never fail */

Not efficient /wrt register accesses, but that's apparently not yet
a design goal anyway (I stumbled over the SSCR1 locking while
considering to introduce a cache for that reg).

Jan

-- 
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

Thread overview: 30+ 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 ` [PATCH v2 1/3] spi: pxa2xx: Factor out handle_bad_msg Jan Kiszka
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-16 18:44 ` [PATCH v2 2/3] spi: pxa2xx: Prepare for edge-triggered interrupts Jan Kiszka
2017-01-16 19:07   ` Andy Shevchenko
2017-01-16 19:46     ` Jan Kiszka
2017-01-17 18:52       ` Jan Kiszka
2017-01-17  7:54   ` Robert Jarzmik
2017-01-17  8:05     ` Jan Kiszka
2017-01-18  8:21       ` Robert Jarzmik
2017-01-18  9:33         ` Jan Kiszka
2017-01-18 12:46           ` Mark Brown
2017-01-19 15:34             ` Jan Kiszka [this message]
2017-01-19 19:37               ` [PATCH v3 " Jan Kiszka
2017-01-19 19:57                 ` Mark Brown
2017-01-19 20:04                   ` Andy Shevchenko
2017-01-20 12:21                     ` Mark Brown
2017-01-20 15:29                       ` Jan Kiszka
2017-01-20 16:14                         ` Mark Brown
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-17  7:58   ` [PATCH v2 2/3] spi: pxa2xx: Prepare for edge-triggered interrupts Robert Jarzmik
2017-01-17  8:10     ` Jan Kiszka
2017-01-17 13:11       ` Jarkko Nikula
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 19:08   ` Andy Shevchenko
2017-01-17 11:18     ` Jarkko Nikula
2017-01-24 18:39   ` Applied "spi: pca2xx-pci: Allow MSI" to the spi tree 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=7e5fb21d-35bd-6ac3-9e6f-cffed656997f@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=daniel@zonque.org \
    --cc=haojian.zhuang@gmail.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 \
    --cc=sascha.weisenberger@siemens.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;
as well as URLs for NNTP newsgroup(s).