Matroxfb dualhead dies

From: David Woodhouse (dwmw2@infradead.org)
Date: Mon Mar 06 2000 - 12:48:33 EST


On my G400, the Maven client is detected on both the 'ddc1' and 'maven' i2c
busses.

Because of the horribly ugly pointer arithmetic which maven_init_client does to
get back to the primary head of the G400, this causes the driver to oops and
die.

The following patch fixes this problem for me. Now all I need to do is work
out how to attach a text console to /dev/fb1 :)

The card is an AGP G400 Max:

01:00.0 VGA compatible controller: Matrox Graphics, Inc.: Unknown device 0525 (rev 04)
        Subsystem: Unknown device 102b:217d
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
        Status: Cap+ 66Mhz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
        Latency: 16 min, 32 max, 32 set, cache line size 08
        Interrupt: pin A routed to IRQ 0
        Region 0: Memory at d8000000 (32-bit, prefetchable)
        Region 1: Memory at d4000000 (32-bit, non-prefetchable)
        Region 2: Memory at d5000000 (32-bit, non-prefetchable)
        Capabilities: [dc] Power Management version 2
                Flags: PMEClk- AuxPwr- DSI+ D1- D2- PME-
                Status: D0 PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [f0] AGP version 2.0
                Status: RQ=31 SBA+ 64bit- FW- Rate=21
                Command: RQ=31 SBA+ AGP- 64bit- FW- Rate=21
00: 2b 10 25 05 07 00 90 02 04 00 00 03 08 20 00 00
10: 08 00 00 d8 00 00 00 d4 00 00 00 d5 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 2b 10 7d 21
30: 00 00 00 00 dc 00 00 00 00 00 00 00 ff 01 10 20

Index: drivers/video/matrox/i2c-matroxfb.c
===================================================================
RCS file: /cvs/linux/drivers/video/matrox/Attic/i2c-matroxfb.c,v
retrieving revision 1.1.2.1
diff -u -w -r1.1.2.1 i2c-matroxfb.c
--- drivers/video/matrox/i2c-matroxfb.c 2000/03/01 13:20:15 1.1.2.1
+++ drivers/video/matrox/i2c-matroxfb.c 2000/03/06 17:42:06
@@ -287,6 +287,9 @@
         matroxfb_DAC_unlock_irqrestore(flags);
 
         memset(m2info, 0, sizeof(*m2info));
+ m2info->maven.minfo = m2info;
+ m2info->ddc1.minfo = m2info;
+ m2info->ddc2.minfo = m2info;
         m2info->primary_dev = minfo;
 
         if (ACCESS_FBINFO(devflags.accelerator) == FB_ACCEL_MATROX_MGA2064W ||
Index: drivers/video/matrox/matroxfb_maven.c
===================================================================
RCS file: /cvs/linux/drivers/video/matrox/Attic/matroxfb_maven.c,v
retrieving revision 1.1.2.1
diff -u -w -r1.1.2.1 matroxfb_maven.c
--- drivers/video/matrox/matroxfb_maven.c 2000/03/01 13:20:15 1.1.2.1
+++ drivers/video/matrox/matroxfb_maven.c 2000/03/06 17:42:06
@@ -893,8 +893,7 @@
 static int maven_init_client(struct i2c_client* clnt) {
         struct i2c_adapter* a = clnt->adapter;
         /* data are set to primary head... maybe I should change it */
- struct matroxfb_dh_maven_info* m2info =
- (struct matroxfb_dh_maven_info*)(((u_int8_t*)a) - offsetof(struct matroxfb_dh_maven_info, maven.adapter));
+ struct matroxfb_dh_maven_info* m2info = ((struct i2c_bit_adapter*)a)->minfo;
         struct maven_data* md = clnt->data;
         /* add some checks that m2info is matroxfb_dh_fb_info here... */
         struct matrox_fb_info* minfo = m2info->primary_dev;
Index: drivers/video/matrox/matroxfb_maven.h
===================================================================
RCS file: /cvs/linux/drivers/video/matrox/Attic/matroxfb_maven.h,v
retrieving revision 1.1.2.1
diff -u -w -r1.1.2.1 matroxfb_maven.h
--- drivers/video/matrox/matroxfb_maven.h 2000/03/01 13:20:15 1.1.2.1
+++ drivers/video/matrox/matroxfb_maven.h 2000/03/06 17:42:06
@@ -6,10 +6,13 @@
 #include <linux/i2c-algo-bit.h>
 #include "matroxfb_base.h"
 
+struct matroxfb_dh_maven_info;
+
 struct i2c_bit_adapter {
         struct i2c_adapter adapter;
         int initialized;
         struct i2c_algo_bit_data bac;
+ struct matroxfb_dh_maven_info *minfo;
 };
 
 struct matroxfb_dh_maven_info {

kernel output:

matroxfb: Matrox unknown G400 (AGP) detected
matroxfb: MTRR's turned on
matroxfb: 640x480x8bpp (virtual: 640x26208)
matroxfb: framebuffer at 0xD8000000, mapped to 0xc8805000, size 33554432
Console: switching to colour frame buffer device 80x30
fb0: MATROX VGA frame buffer device

i2c-core.o: i2c core module
i2c-algo-bit.o: i2c bit algorithm module
i2c-core.o: adapter DDC:fb0 #0 on i2c-matroxfb registered as adapter 0.
i2c-core.o: adapter DDC:fb0 #1 on i2c-matroxfb registered as adapter 1.
i2c-core.o: adapter MAVEN:fb0 on i2c-matroxfb registered as adapter 2.
i2c-core.o: driver maven registered.
i2c-core.o: client [maven client] registered to adapter [DDC:fb0 #1 on i2c-matroxfb](pos. 0).
i2c-core.o: client [maven client] registered to adapter [MAVEN:fb0 on i2c-matroxfb](pos. 0).
matroxfb_crtc2: secondary head of fb0 was registered as fb1

--
dwmw2

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Mar 07 2000 - 21:00:20 EST