From: Wolfgang Grandegger <wg@grandegger.com>
To: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: Stephane Grosjean <s.grosjean@peak-system.com>,
Marc Kleine-Budde <mkl@pengutronix.de>,
linux-can Mailing List <linux-can@vger.kernel.org>
Subject: Re: [PATCH v3] can/sja1000: add support for PEAK-System PCMCIA card
Date: Wed, 15 Feb 2012 09:37:27 +0100 [thread overview]
Message-ID: <4F3B6EC7.2090400@grandegger.com> (raw)
In-Reply-To: <4F3B6755.7080602@hartkopp.net>
On 02/15/2012 09:05 AM, Oliver Hartkopp wrote:
> On 15.02.2012 08:03, Wolfgang Grandegger wrote:
>
>> Hi Oliver,
>>
>> we start paving common code to partially cure pcmcia related problems,
>> that's exactly what I do not like.
>
>
> It's PCMCIA and PCIeC and Parallel port, etc. Any pluggable sja1000 hardware.
>
>>
>> On 02/14/2012 05:41 PM, Oliver Hartkopp wrote:
>>> On 14.02.2012 11:16, Stephane Grosjean wrote:
>>>
>>>>
>>>> Le 14/02/2012 10:59, Oliver Hartkopp a écrit :
>>>>
>>>>> @@ -492,6 +492,9 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
>>>>> while ((isrc = priv->read_reg(priv, REG_IR))&& (n< SJA1000_MAX_IRQ)) {
>>
>> In case of unplug, already the above read may return 0xff.
>
>
> Right. But it does not get a bad effect as we quit from this bad condition
> three lines later. No previously retrieved isrc variable is referenced then.
> Please re-check the patched sja1000_interrupt() as a whole.
>
>>
>>>>> n++;
>>>>> status = priv->read_reg(priv, REG_SR);
>>>>> + /* check for absent controller due to hw unplug */
>>>>> + if (status == 0xFF&& !sja1000_probe_chip(dev))
>>>>> + break;
>>
>> Once...
>>
>>>>> if (isrc& IRQ_WUI)
>>>>> netdev_warn(dev, "wakeup interrupt\n");
>>>>> @@ -508,6 +511,9 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
>>>>> while (status& SR_RBS) {
>>>>> sja1000_rx(dev);
>>>>> status = priv->read_reg(priv, REG_SR);
>>>>> + /* check for absent controller */
>>>>> + if (status == 0xFF&& !sja1000_probe_chip(dev))
>>>>> + break;
>>
>> ... twice... What about the other accesses?
>
>
> Which ones do you have in mind?
>
> The really only thing that could happen, that exactly ONE CAN frame can be
> damaged on read while accessing the SJA1000 registers. This can not be solved
> unless you check for sja1000_probe_chip() at the end of reading the frame and
> before pushing the skbuff to the rx queue.
>
> But this would add indeed a new ioport access each time we read a CAN frame.
>
> I don't think that we should do this additional effort - even if it's probably
> the right(TM) thing to do 8-)
Well, see my comment below.
>
> My patch doesn't do any additional ioport accesses in a 'good' condition.
>
> (..)
>
>>> But indeed both drivers (PEAK/EMS PCMCIA) do no need priv->pre_irq ...
>>>
>
>>> So if we add the 'return IRQ_NONE' to the above patch the private check for
>>> present hardware becomes obsolete as the private ISRs terminate properly when
>>> they get an IRQ_NONE.
>>>
>>> Right?
>>
>> If it's clear that the interrupt came from that device, we should return
>> IRQ_HANDLED otherwise it's treated as spurious.
>
>
> Can this usually happen in the case of unplugging devices?
>
> Or we need some kind of wrapper for the sja1000 isr that returns
>
> IRQ_NONE
> IRQ_HANDLED
> IRQ_PLUGOUT
>
> while HANDLED & PLUGOUT would lead to IRQ_HANDLED on the top level.
>
>> I would accept *one* "if
>> (status == 0xFF ..." check in a good place.
>
>
> Sorry but you need an additional check within the while statement.
> There are two potential occurrences where we read the status. Why checking
> only one time? As i wrote above: Please re-check the entire patched function.
Why do we care so much about improper handling of the hardware. It is
*illegal* to unplug the device while it's under operation and if it
happens we cannot guarantee valid behavior and data anyway. The system
should not hang, of course, everything else is not that dramatic, I
think. Mark, what is your opinion?
Wolfgang.
next prev parent reply other threads:[~2012-02-15 8:37 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-06 15:56 [PATCH v3] can/sja1000: add support for PEAK-System PCMCIA card Stephane Grosjean
2012-02-13 9:14 ` Marc Kleine-Budde
2012-02-13 10:01 ` Stephane Grosjean
2012-02-13 10:14 ` Wolfgang Grandegger
2012-02-13 10:41 ` Oliver Hartkopp
2012-02-13 11:02 ` Wolfgang Grandegger
2012-02-13 11:06 ` Marc Kleine-Budde
2012-02-13 11:08 ` Wolfgang Grandegger
2012-02-13 19:55 ` Oliver Hartkopp
2012-02-13 20:23 ` Wolfgang Grandegger
2012-02-14 9:14 ` Stephane Grosjean
2012-02-14 9:30 ` Wolfgang Grandegger
2012-02-14 9:59 ` Oliver Hartkopp
2012-02-14 10:16 ` Stephane Grosjean
2012-02-14 16:41 ` Oliver Hartkopp
2012-02-15 7:03 ` Wolfgang Grandegger
2012-02-15 8:05 ` Oliver Hartkopp
2012-02-15 8:37 ` Wolfgang Grandegger [this message]
2012-02-15 19:32 ` Oliver Hartkopp
2012-02-15 11:52 ` Stephane Grosjean
2012-02-15 15:06 ` Wolfgang Grandegger
2012-02-15 16:00 ` Stephane Grosjean
2012-02-15 19:46 ` Oliver Hartkopp
2012-02-13 10:46 ` Stephane Grosjean
2012-02-13 10:56 ` Wolfgang Grandegger
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=4F3B6EC7.2090400@grandegger.com \
--to=wg@grandegger.com \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=s.grosjean@peak-system.com \
--cc=socketcan@hartkopp.net \
/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).