powerpc: Fix ide-pmac sysfs entry
PATCH 1/1 powerpc: Fix ide-pmac sysfs entry
It looks like the generic ide code now wants ide_init_hwif_ports() to set the parent struct device into the ide_hw structure (new field ?). Without this, the mac ide code can cause the ide probing code to explode in flames in sysfs registration due to what looks like a stale pointer in there (happens when removing/re-inserting one of the hotswap media bays on some laptops).
---
Andew: That's a 2.6.17 candidate
drivers/ide/ppc/pmac.c +2 -0
@@ -553,6 +553,8 @@if (irq !=NULL ) *irq = pmac_ide[ix].irq; + + hw->dev = &pmac_ide[ix].mdev->ofdev.dev; }#define PMAC_IDE_REG (x) ((void __iomem *)(IDE_DATA_REG+(x)))
Quoted 8 lines · Benjamin Herrenschmidt
It looks like the generic ide code now wants
ide_init_hwif_ports()to set the parent struct device into theide_hwstructure (new field ?). Without this, the mac ide code can cause the ide probing code to explode in flames in sysfs registration due to what looks like a stale pointer in there (happens when removing/re-inserting one of the hotswap media bays on some laptops).
You don't sound very confident.
Quoted 10 lines
---
Andew: That's a 2.6.17 candidate
Index:
linux-work/drivers/ide/ppc/pmac.c
===================================================================
drivers/ide/ppc/pmac.c line 560
Quoted 8 lines
drivers/ide/ppc/pmac.c +2
-0@@ -553,6 +553,8 @@if (irq !=NULL ) *irq = pmac_ide[ix].irq; + + hw->dev = &pmac_ide[ix].mdev->ofdev.dev; }#define PMAC_IDE_REG (x) ((void __iomem *)(IDE_DATA_REG+(x)))
afaict things went bad in October last year. hw_regs_t.dev was added here:
but that only converted one driver to initialse ->dev.
How come things didn't break then? Did some later change cause the problems?
Quoted 11 lines · Andrew Morton
Quoted 8 lines · Benjamin Herrenschmidt
It looks like the generic ide code now wants
ide_init_hwif_ports()to set the parent struct device into theide_hwstructure (new field ?). Without this, the mac ide code can cause the ide probing code to explode in flames in sysfs registration due to what looks like a stale pointer in there (happens when removing/re-inserting one of the hotswap media bays on some laptops).You don't sound very confident.
Well, the problem is fixed with my change, I'd like to have Bart confirmation that's its the right approach. It looks like it is but that code is fairly intricated :)
Quoted 8 lines
afaict things went bad in October last year. hw_regs_t.dev was added here:
but that only converted one driver to initialse ->dev.
How come things didn't break then? Did some later change cause the problems?
Well, for one, very few drivers cause ide_unregister nor rely on those old mecanism... it seems that the way I initialize things at boot works fine, it's when I unregister/re-register via the hotswap bay that things go bunk.
It's possible that it got broken back then and not noticed since ... or another change actually made _use_ of that field... not sure, Bart might confirm. The Mac laptops with those hotswap bays are fairly old and I haven't tested for some time. I just did after getting user reports, and users of old machines like that tend to use stable distro kernels which tend to be fairly old...
Ben.
Quoted 31 lines · Benjamin Herrenschmidt
Quoted 11 lines · Andrew Morton
Quoted 8 lines · Benjamin Herrenschmidt
It looks like the generic ide code now wants
ide_init_hwif_ports()to set the parent struct device into theide_hwstructure (new field ?). Without this, the mac ide code can cause the ide probing code to explode in flames in sysfs registration due to what looks like a stale pointer in there (happens when removing/re-inserting one of the hotswap media bays on some laptops).You don't sound very confident.
Well, the problem is fixed with my change, I'd like to have Bart confirmation that's its the right approach. It looks like it is but that code is fairly intricated :)
Quoted 8 lines
afaict things went bad in October last year. hw_regs_t.dev was added here:
but that only converted one driver to initialse ->dev.
How come things didn't break then? Did some later change cause the problems?
Well, for one, very few drivers cause
ide_unregisternor rely on those old mecanism... it seems that the way I initialize things at boot works fine, it's when I unregister/re-register via the hotswap bay that things go bunk.
Quoted 6 lines
It's possible that it got broken back then and not noticed since ... or another change actually made _use_ of that field... not sure, Bart might confirm. The Mac laptops with those hotswap bays are fairly old and I haven't tested for some time. I just did after getting user reports, and users of old machines like that tend to use stable distro kernels which tend to be fairly old...
Actually I have one of these, and regularly use it and update the kernel to the latest git once or twice per month, but I typically have two batteries and have not swapped in the media bay under Linux for a long time.
If you are interested, I could test the patch when I find some time (not today: my 8 year old son went to the hospital for an emergency last Thursday, he is cured now and should come out today).
Regards,
Gabriel
Quoted 10 lines
Actually I have one of these, and regularly use it and update the kernel to the latest git once or twice per month, but I typically have two batteries and have not swapped in the media bay under Linux for a long time.
If you are interested, I could test the patch when I find some time (not today: my 8 year old son went to the hospital for an emergency last Thursday, he is cured now and should come out today).
Any test is welcome, glad to know your son is well !
Cheers,
Ben.
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 6 lines
Actually I have one of these, and regularly use it and update the kernel to the latest git once or twice per month, but I typically have two batteries and have not swapped in the media bay under Linux for a long time.
Quoted 6 lines
Quoted 4 lines
If you are interested, I could test the patch when I find some time (not today: my 8 year old son went to the hospital for an emergency last Thursday, he is cured now and should come out today).
Any test is welcome, glad to know your son is well !
The one liner works here, I can no more solidly hang the machine. There is still a bunch of error messages on drive removal though:
mediabay0: switching to 7
mediabay0: powering down
media bay 0 is empty Unregistering mb 0 ide, index:2
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: DMA disabled
hde: ATAPI reset complete
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: ATAPI reset complete
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: ATAPI reset complete
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: ATAPI reset complete
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
mediabay0: end of power down
On insertion there are also a few messages but they seem normal:
mediabay0: switching to 3
mediabay0: powering up
mediabay0: enabling (kind:3)
mediabay0: waiting reset (kind:3)
mediabay0: waiting IDE reset (kind:3)
mediabay0: waiting IDE ready (kind:3) mediabay 0, registering IDE...
Probing IDE interface ide2...
hde: LG DVD-ROM DRN-8080B, ATAPI CD/DVD-ROM drive
hde: Enabling MultiWord DMA 2
ide2 at 0xf1022000-0xf1022007,0xf1022160 on irq 20
hde: ATAPI 24X DVD-ROM drive, 512kB Cache, DMA media-bay 0 is ide2
mediabay 0 IDE ready
Regards,
Gabriel
Quoted 12 lines · Gabriel Paubert
Quoted 11 lines · Benjamin Herrenschmidt
Quoted 10 lines
Actually I have one of these, and regularly use it and update the kernel to the latest git once or twice per month, but I typically have two batteries and have not swapped in the media bay under Linux for a long time.
If you are interested, I could test the patch when I find some time (not today: my 8 year old son went to the hospital for an emergency last Thursday, he is cured now and should come out today).
Quoted 5 lines
Quoted 1 line
Any test is welcome, glad to know your son is well !
The one liner works here, I can no more solidly hang the machine. There is still a bunch of error messages on drive removal though:
Yes, I noticed those. Looks like the IDE driver is trying to much around with the drive when unregistered. In our case, it's not a very good idea as we unregister it after we detect it's been physically removed :) Seems harmless so far though.
Ben.
Quoted 67 lines
mediabay0: switching to 7
mediabay0: powering down
media bay 0 is empty Unregistering mb 0 ide, index:2
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: DMA disabled
hde: ATAPI reset complete
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: ATAPI reset complete
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: ATAPI reset complete
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
hde: ATAPI reset complete
hde: status error: status=0x00 { }
ide: failed opcode was: unknown
mediabay0: end of power downOn insertion there are also a few messages but they seem normal:
mediabay0: switching to 3
mediabay0: powering up
mediabay0: enabling (kind:3)
mediabay0: waiting reset (kind:3)
mediabay0: waiting IDE reset (kind:3)
mediabay0: waiting IDE ready (kind:3) mediabay 0, registering IDE...
Probing IDE interface ide2...
hde: LG DVD-ROM DRN-8080B, ATAPI CD/DVD-ROM drive
hde: Enabling MultiWord DMA 2
ide2 at 0xf1022000-0xf1022007,0xf1022160 on irq 20
hde: ATAPI 24X DVD-ROM drive, 512kB Cache, DMA media-bay 0 is ide2
mediabay 0 IDE readyRegards,
Gabriel