Re: [BUG] cannot access IO ports in CMI8738 sound chip.

Katsuya MATSUBARA
2008-01-30T05:27:49Z

Hi Paul,

From: Paul Mundt <lethal@linux-sh.org>
Date: Mon, 21 Jan 2008 18:37:03 +0900

> On Mon, Jan 21, 2008 at 04:39:04PM +0900, Katsuya MATSUBARA wrote:
> > [ 0.305614] Autoconfig PCI channel 0x8c22001c
> > [ 0.310461] Scanning bus 00, I/O 0xfe240000:0xfe280000, Mem 0xfd000000:0xfe000000
> > [ 0.318774] 00:00.0 Class 0401: 13f6:0111 (rev 10)
> > [ 0.324051] I/O at 0xfe240000 [size=0x100]
> > [ 0.329356] 00:01.0 Class 0200: 10ec:8139 (rev 10)
> > [ 0.334619] I/O at 0xfe240100 [size=0x100]
> > [ 0.339911] Mem at 0xfd000000 [size=0x100]
> > [ 0.345214] 00:02.0 Class 0607: 104c:ac55 (rev 01)
> > [ 0.350470] CARDBUS Bridge: primary\0, secondary\x01
> > [ 0.356192] PCI Autoconfig: Found CardBus bridge, device 2 function 0
> > [ 0.363240] Mem at 0xfd001000 [size=0x1000]
> > [ 0.368611] Scanning sub bus 01, I/O 0xfe240200, Mem 0xfd002000
> > [ 0.375162] Back to bus 00, sub_bus is 1
> > [ 0.379501] 00:02.1 Class 0607: 104c:ac55 (rev 01)
> > [ 0.384758] CARDBUS Bridge: primary\0, secondary\x02
> > [ 0.390480] PCI Autoconfig: Found CardBus bridge, device 2 function 1
> > [ 0.397526] Mem at 0xfd003000 [size=0x1000]
> > [ 0.402923] Scanning sub bus 02, I/O 0xfe240204, Mem 0xfd004000
> > [ 0.409474] Back to bus 00, sub_bus is 2
> > [ 0.413821] 00:03.0 Class 0200: 10ec:8139 (rev 10)
> > [ 0.419112] I/O at 0xfe240300 [size=0x100]
> > [ 0.424373] Mem at 0xfd005000 [size=0x100]
> [snip]
> > [ 1.203222] PCI: Device 0000:00:01.0 not available because of resource collisions
> > [ 1.222452] Trying to free nonexistent resource <0000000000002000-00000000000020ff>
> > [ 1.242071] Trying to free nonexistent resource <0000000000000000-00000000000000ff>
> > [ 1.261898] 8139too: probe of 0000:00:01.0 failed with error -22
> > [ 1.274109] PCI: Device 0000:00:03.0 not available because of resource collisions
> > [ 1.295385] Trying to free nonexistent resource <0000000000000000-00000000000000ff>
> > [ 1.317670] Trying to free nonexistent resource <0000000000000000-00000000000000ff>
> > [ 1.340581] 8139too: probe of 0000:00:03.0 failed with error -22
>
> On Mon, Jan 21, 2008 at 06:18:16PM +0900, Katsuya MATSUBARA wrote:
> > In the current kernel, pci_enable_device() get an errror
> > with the following message;
> >
> > "PCI: Device .. not available because of resource collisions."
> >
> > pcibios_enable_device() in arch/sh/drivers/pci/pci.c shows
> > the message if dev->resource[]->start is 0.
> > In the case of my CMI8738 driver code, the failure of
> > updating the BAR causes the condition.
>
> Apparently we're having a bit of a miscommunication.

I am sorry for the confusion.

> Either the BAR values are sane or they aren't. If the initial BAR
> values that are reported in that scan are sane, then you can disable
> the BAR update like the Dreamcast does, and pass the existing values
> down. If you can handle the BARs being updated, then you should not
> enable this, and you should let pci-auto find sane mappings for
> you. If you have to have fixed BARs, then you need to make sure your
> board specific fixup code does the right thing when doing device
> fixups. Presently this is not implemented for R2D, as it was assumed
> that we could update the BAR values in a reasonable fashion.

Thank you for the description.
I understood I could not disable PCI_AUTO_UPDATE_RESOURCES
for my case.

> Regardless, your driver always has to use pci_iomap() for getting at
> the BAR itself. sound/pci/cmipci.c presently does not. Your
> board-specific I/O base change seems to be specifically to
> compensate for the fact that a driver hasn't performed a remap on
> the resource start.

I see. My R2D I/O base change must be in a misguided way.

In my understanding, pci_iomap() output an address where
a device resouce is mmaped. But it seems to be that
the current pci_iomap() outout the BAR value without
any offsets even if the resource is io port.
Is it correct behavior?