From: David Brownell <david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [patch 2.6.27-rc7] i2c: smbalert# support
Date: Sat, 22 Nov 2008 01:48:56 -0800 [thread overview]
Message-ID: <200811220148.57223.david-b@pacbell.net> (raw)
In-Reply-To: <20081122100344.61cf42b7-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
On Saturday 22 November 2008, Jean Delvare wrote:
> Hi David,
>
> On Fri, 21 Nov 2008 13:54:50 -0800, David Brownell wrote:
> > On Friday 21 November 2008, Jean Delvare wrote:
> > > In my case it was an edge-triggered interrupt:
> > >
> > > 7: 8 IO-APIC-edge parport0
> > >
> > > For a level-triggering interrupt, I'd say it is up to the bus driver to
> > > disable it before calling smbus_alert(), as you did in smbus_irq()?
> >
> > Yes, but then ... what would re-enable it? A mechanism
> > seems to be missing; maybe a callback, for bus drivers
> > that just schedule_work(&adapter->alert), or having them
> > call the relevant routine in a task context instead of
> > letting i2c-core provide that context.
>
> Well, if bus->alert_edge_triggered is set to 0 and bus->irq is properly
> set, smbus_alert() is taking care of re-enabling the IRQ, isn't it?
I was mixing up a few issues in my mind. If it's a level-triggered
interrupt, and the device is flaking out and still asserting it even
after it responded to the ARA ... then fault isolation calls for
leaving it disabled. Then how could it ever recover?
> OTOH I admit that I was a little surprised that I had to set
> bus->alert_edge_triggered while while my driver also sets
> bus->do_setup_alert. But as long as it is properly documented, I guess
> this is OK.
I don't see a way around that, until we get to threaded IRQ handlers.
In which case lots of this could just be part of a threaded handler...
which would mask and unmask directly.
It might be worth waiting till Thomas sends the threaded IRQ stuff
for merge. It will make the interface tradeoffs a bit different, and
one notion was to merge that stuff for 2.6.29 ...
> > > The device was behaving as intended, the problem was that I had not yet
> > > implemented the alert() callback in the device driver. The device
> > > (ADM1032) keeps the ALERT# line low as long as the alarm condition
> > > exists, so smbus_alert() would receive the same address over and over
> > > again.
> >
> > Hmm, that "keep ALERT# low" behavior is contrary to what I took away
> > from the SMBus spec: "After acknowledging the slave address the device
> > must disengage its SMBALERT# pulldown." This ADM1032 isn't doing that;
> > it only "disengages" when the alarm condition eventually goes away.
>
> Indeed, this doesn't match the specification. I'm not necessarily
> surprised, as the same ADM1032 also doesn't implement SMBus PEC
> properly. Apparently Analog Devices didn't put too much engineering
> into sticking to the SMBus specification :( At least there is a way to
> mask out the ALERT# output, so this can be addressed in the driver.
> Otherwise the ADM1032 wouldn't be usable at all...
My own SMBALERT# testing involved a TI sensor, which worked like a charm,
and some AVR (ATtiny) firmware, ditto.
> > That would be particularly bad if it was raising an alert but there
> > was no driver for it at all!
>
> True. And obviously this can happen.
Hence the "leave it disabled" thought ...
> > Maybe the fault cases (no alert method, or now driver) in i2c_do_alert()
> > should have special return codes so that the code scanning the bus for
> > alerting devices can be a bit smarter.
>
> I have been thinking about this too. But OTOH, you also want to
> properly handle the case where there is a driver and it has a callback
> but this callback is misbehaving. So in the end I think it's safer to
> focus on the consequence (same slave answering to ARA several times)
> than the multiple possible causes.
That's what I concluded too.
> > > I have now updated the device driver to mask out the ALERT# signal once
> > > it has triggered, until the alarm has worn off, at which point I unmask
> > > the ALERT# signal again. So it works OK now (I'll post the patch in a
> > > minute), but this is a condition that could easily happen for other
> > > devices / developers out there, so I think it's better to make the
> > > i2c-core code robust enough to handle it.
> >
> > Agreed, defend against this misbehavior. But I can't think of a more
> > robust defence than leaving the IRQ disabled when it misbehaves.
>
> Except that you don't necessarily have control over the IRQ in
> question. At least in my case, the i2c-parport driver sets
> bus->alert_edge_triggered to 1 and bus->do_setup_alert to 1, which
> basically means that it is handling the IRQ on its own and i2c-core
> won't touch it. So if you want i2c-core to be more intrusive, you must
> make setting bus->irq mandatory. I have no objection, again as long as
> it is properly documented.
Setting bus->irq won't work on common cases like ICH8, where the
SMBALERT# interrupt is just one more subcase.
- Dave
>
> --
> Jean Delvare
>
>
prev parent reply other threads:[~2008-11-22 9:48 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200804161434.54335.laurentp@cse-semaphore.com>
[not found] ` <20080416153043.02f89554@hyperion.delvare>
[not found] ` <200804161027.49943.david-b@pacbell.net>
[not found] ` <200804161027.49943.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-05-02 11:10 ` [patch 2.6.25-git] i2c: smbalert# support David Brownell
[not found] ` <200805020410.44723.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-05-05 5:56 ` [patch 2.6.265-rc1] " David Brownell
[not found] ` <200805042256.49252.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-09-23 22:32 ` [patch 2.6.27-rc7] " David Brownell
[not found] ` <200809231532.40083.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-09-26 1:07 ` [lm-sensors] " Trent Piepho
[not found] ` <Pine.LNX.4.64.0809251728130.7680-3bmvVOk6DZ+DGx/iekXGtrjh7zpefjiS@public.gmane.org>
2008-09-26 2:01 ` David Brownell
[not found] ` <200809251902.00201.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-09-27 0:29 ` Trent Piepho
[not found] ` <Pine.LNX.4.64.0809261652040.7680-3bmvVOk6DZ+DGx/iekXGtrjh7zpefjiS@public.gmane.org>
2008-10-17 19:04 ` David Brownell
[not found] ` <200810171204.54448.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-10-17 20:43 ` Trent Piepho
2008-11-18 8:15 ` Jean Delvare
[not found] ` <20081118091546.421d6b78-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-11-18 22:01 ` David Brownell
[not found] ` <200811181401.34809.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-11-19 9:51 ` [lm-sensors] " Trent Piepho
[not found] ` <Pine.LNX.4.64.0811190140510.11673-3bmvVOk6DZ+DGx/iekXGtrjh7zpefjiS@public.gmane.org>
2008-11-19 15:16 ` Jean Delvare
[not found] ` <20081119161632.2d0bde9e-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-11-20 22:00 ` Trent Piepho
[not found] ` <Pine.LNX.4.64.0811201354310.11673-3bmvVOk6DZ+DGx/iekXGtrjh7zpefjiS@public.gmane.org>
2008-11-20 22:56 ` David Brownell
[not found] ` <200811201456.36551.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-11-22 0:55 ` Trent Piepho
[not found] ` <Pine.LNX.4.64.0811211621340.18022-3bmvVOk6DZ+DGx/iekXGtrjh7zpefjiS@public.gmane.org>
2008-11-22 2:58 ` David Brownell
2008-11-21 8:42 ` Jean Delvare
[not found] ` <20081121094218.34ecd82a-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-11-22 6:04 ` Trent Piepho
[not found] ` <Pine.LNX.4.64.0811212122370.18022-3bmvVOk6DZ+DGx/iekXGtrjh7zpefjiS@public.gmane.org>
2008-11-22 10:13 ` Jean Delvare
[not found] ` <20081122111340.0bfc2c05-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-11-22 20:28 ` Trent Piepho
[not found] ` <Pine.LNX.4.64.0811221055470.18022-3bmvVOk6DZ+DGx/iekXGtrjh7zpefjiS@public.gmane.org>
2008-11-23 21:45 ` Jean Delvare
2008-11-19 13:57 ` Jean Delvare
[not found] ` <20081119145712.1abaa63f-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-11-19 18:08 ` David Brownell
2008-11-21 14:18 ` Jean Delvare
[not found] ` <20081121151808.324ca78c-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-11-21 16:24 ` David Brownell
[not found] ` <200811210824.55601.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-11-21 19:22 ` Jean Delvare
[not found] ` <20081121202223.0261fb9c-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-11-21 21:54 ` David Brownell
[not found] ` <200811211354.51501.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-11-22 9:03 ` Jean Delvare
[not found] ` <20081122100344.61cf42b7-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-11-22 9:48 ` David Brownell [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=200811220148.57223.david-b@pacbell.net \
--to=david-b-ybekhbn/0ldr7s880joybq@public.gmane.org \
--cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.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