Bug 6385 - powermac/low_i2c.c: keywest i2c IRQ failure
Summary: powermac/low_i2c.c: keywest i2c IRQ failure
Status: CLOSED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: I2C (show other bugs)
Hardware: i386 Linux
: P2 normal
Assignee: Benjamin Herrenschmidt
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-13 22:45 UTC by Timothy Stotts
Modified: 2006-11-16 14:45 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.16.4
Subsystem:
Regression: ---
Bisected commit-id:


Attachments
Config of kernel used for diagnostics (41.24 KB, text/plain)
2006-04-13 22:51 UTC, Timothy Stotts
Details
kernel logs of keywest failure (130.84 KB, text/plain)
2006-04-13 23:01 UTC, Timothy Stotts
Details
kernel logs of old keywest success (21.35 KB, text/plain)
2006-04-14 00:23 UTC, Timothy Stotts
Details
Config of kernel with old keywest success (2.6.15.0) (40.54 KB, text/plain)
2006-04-14 00:25 UTC, Timothy Stotts
Details
Rework kw low i2c to better match what was done before (3.40 KB, patch)
2006-04-14 17:33 UTC, Benjamin Herrenschmidt
Details | Diff

Description Timothy Stotts 2006-04-13 22:45:32 UTC
Most recent kernel where this bug did not occur: 2.6.15.x
Distribution:  Gentoo, with vanilla kernel
Hardware Environment:  Powerbook5,2 1.25Ghz (1st-gen Albook 15'' ADB keyboard)
Software Environment:  runlevel 1 console
Problem Description:   keywest I2C bus driver prints IRQ errors to kernel log 
when accessed by user-space software

Steps to reproduce:
(1) boot into 2.6.16.x kernel (all 2.6.16.x affected)
(2) load i2c modules if applicable not compiled-in (i2c-dev, i2c-powermac, 
etc.)
(3) scan all /dev/i2c-X with initialization of pbbuttonsd, looking for ambient 
light sensors and keyboard backlight control
(4) access of keywest i2c devices produces kernel error messages. sample 
messages:

KW: wrong state. Got KW_I2C_IRQ_ADDR, state: state_stop (isr: 02)
KW: wrong state. Got KW_I2C_IRQ_ADDR, state: state_stop (isr: 02)
KW: wrong state. Got KW_I2C_IRQ_STOP, state: state_read (isr: 04)

Diagnosis:
  - first time for keywest failure on this system since near 2.6.9
  - identical results if entire I2C subsystem as modules or all compiled-in
  - source:  arch/powerpc/platforms/powermac/low_i2c.c
  - probably a bug in Ben's driver rewrite of Keywest into low-level code
  - other I2C code in kernel: ATI Radeon framebuffer, laptop thermal (?)
Comment 1 Timothy Stotts 2006-04-13 22:51:24 UTC
Created attachment 7865 [details]
Config of kernel used for diagnostics

I don't actually use this exact kernel config for anything but testing of this
issue.
Comment 2 Timothy Stotts 2006-04-13 23:01:02 UTC
Created attachment 7866 [details]
kernel logs of keywest failure

some bootup and service init logs, including pbbuttonsd

one boot with vanilla, i2c debugging on
one boot with custom (but no i2c patching), i2c debugging off
Comment 3 Timothy Stotts 2006-04-13 23:09:42 UTC
Additional notes:
  - respective i2c hardware works with Mac OS X
  - respective i2c hardware works with 2.6.13.x to 2.6.15.x, any version of 
pbbuttonsd
  - system kernel headers (for glibc, etc) are linux-2.6.11
  - pbbuttonsd uses its own i2c-dev.h header, could be mutual fault
Comment 4 Benjamin Herrenschmidt 2006-04-13 23:25:34 UTC
Must be a problem with the low level i2c getting into some wrong state when a
device doesn't reply... I'll try to find out when I find 5 minutes, in the
meantime, you are welcome to compare the old i2c-keywest code with the
implementation now in arch/powerpc/platforms/powermac/low_i2c.c ...
Comment 5 Jean Delvare 2006-04-14 00:11:50 UTC
Benjamin, what is the state of powermac/low_i2c.c with regards to i2c-core? The
header comment suggests that you have your own i2c implementation, but if your
bus is visible through i2c-dev, this means that you have somehow registered with
i2c-core. Please explain.
Comment 6 Benjamin Herrenschmidt 2006-04-14 00:15:57 UTC
low_i2c is my own low level i2c interface, mostly bcs i2c core one isn't
suitable for some of my needs by low level code. drivers/i2c/busses/i2c-powermac
"exposes" all the busses detected by that low level interface to i2c core for
higher level drivers or userland.
Comment 7 Timothy Stotts 2006-04-14 00:23:53 UTC
Created attachment 7868 [details]
kernel logs of old keywest success

a boot log, running pbbuttonsd, etc., on vanilla 2.6.15.0

sorry, no I2C debugging enabled for this log.  will have to recompile a new
image at a later date
Comment 8 Timothy Stotts 2006-04-14 00:25:51 UTC
Created attachment 7869 [details]
Config of kernel with old keywest success (2.6.15.0)
Comment 9 Timothy Stotts 2006-04-14 00:31:21 UTC
Only notable differences betwen 2.6.15 adn 2.6.16 bootup and execution of 
pbbuttonsd (without I2C debug enabled):

   - 2.6.16 causes said kernel error messages
   - different number of identified bus channels at bootup, with different 
ordering of /dev/ entries loading

      2.6.15.0:
        Found KeyWest i2c on "uni-n", 2 channels, stepping: 4 bits
        Found KeyWest i2c on "mac-io", 1 channel, stepping: 4 bits
        ...
        i2c /dev entries driver

      2.6.16.4:
        i2c /dev entries driver
        PowerMac i2c bus pmu 2 registered
        PowerMac i2c bus pmu 1 registered
        PowerMac i2c bus mac-io 0 registered
        PowerMac i2c bus uni-n 1 registered
        PowerMac i2c bus uni-n 0 registered
Comment 10 Timothy Stotts 2006-04-14 00:42:57 UTC
Benjamin,

Any diagnoses / patch trials; just ask.
However, as my production (only) laptop, I'll have a long latency (maybe days) 
in recompiling and testing kernels.

I miss my glowing keyboard enough to have diagnosed it through the night.

Regards.
Comment 11 Benjamin Herrenschmidt 2006-04-14 17:33:19 UTC
Created attachment 7876 [details]
Rework kw low i2c to better match what was done before

Please let me know if that patch helps
Comment 12 Timothy Stotts 2006-04-14 19:41:51 UTC
Response to Comment #11:

Yes, the patch seems to bring the I2C behavior back to normal.
Tested vanilla 2.6.16.4 and heavily patched variant also.

The Albook sensors/backlight talk with pbbuttonsd, and no error messages, with 
or without I2C debugging on.

No issues with hardware suspend/resume (but doubt this the driver could affect 
that anyway).
Comment 13 Timothy Stotts 2006-06-13 21:31:11 UTC
Just a note: the I2C appears to work fine with 2.6.17-rc6 vanilla.
Comment 14 Adrian Bunk 2006-11-16 14:45:31 UTC
The patch from this bug was included in kernel 2.6.17.

Note You need to log in before you can comment on or make changes to this bug.