2009-03-12 23:36:18

by Christian P. Schmidt

[permalink] [raw]
Subject: How can PCI resource allocation fail?

Hi all,

I'm toying with the alsa-driver for the Creative Labs X-Fi. I'm working on the PCI Express version of this card, though, which is
the same as the PCI version plus a PCIe to PCI bridge but has a different ID:

+-1c.2-[0000:03-04]----00.0-[0000:04]----00.0 1102:0009

03:00.0 PCI bridge: Creative Labs Device 7006
04:00.0 Audio device: Creative Labs [SB X-Fi Xtreme Audio] CA0110-IBG

Now, after adding the ID, the driver fails:

[46833.487579] CA0106 0000:04:00.0: PCI INT A -> GSI 18 (level, low) -> IRQ 18
[46833.487586] CA0106 0000:04:00.0: PCI INT A disabled
[46833.487588] cannot allocate the port
[46833.487594] CA0106: probe of 0000:04:00.0 failed with error -16

The actual error is occurring in

chip->port = pci_resource_start(pci, 0);
chip->res_port = request_region(chip->port, pci_resource_len(pci,0), "snd_ca0106");
if (!chip->res_port) {
snd_ca0106_free(chip);
printk(KERN_ERR "cannot allocate the port\n");
return -EBUSY;
}

This from /proc/iomem:

f9f00000-f9ffffff : PCI Bus 0000:03
f9f00000-f9ffffff : PCI Bus 0000:04
f9ffc000-f9ffffff : 0000:04:00.0

Some additional debug output tells me that the code is actually trying to allocate 16k starting from f9ffc000. What could be
potential reasons for the failure? Do I have to do something with the bridge before I can try to request the region?

Regards,
Christian

PS: lcpci -vv output afterwards, can't see anything special here.

03:00.0 PCI bridge: Creative Labs Device 7006 (prog-if 00 [Normal decode])
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV+ VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 32 bytes
Bus: primary=03, secondary=04, subordinate=04, sec-latency=64
Memory behind bridge: f9f00000-f9ffffff
Secondary status: 66MHz- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort+ <SERR- <PERR-
BridgeCtl: Parity+ SERR+ NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [50] Power Management version 3
Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
Status: D0 PME-Enable- DSel=0 DScale=0 PME-
Bridge: PM- B3+
Capabilities: [60] MSI: Mask- 64bit+ Count=1/16 Enable-
Address: 0000000000000000 Data: 0000
Capabilities: [80] Subsystem: Creative Labs Device 0010
Capabilities: [90] Express (v1) PCI/PCI-X Bridge, MSI 00
DevCap: MaxPayload 512 bytes, PhantFunc 0, Latency L0s <4us, L1 <64us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop+ BrConfRtry-
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr+ FatalErr- UnsuppReq+ AuxPwr- TransPend-
LnkCap: Port #0, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency L0 <512ns, L1 <16us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; Disabled- Retrain- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
Capabilities: [100] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq+ ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES- TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
AERCap: First Error Pointer: 14, GenCap+ CGenEn- ChkCap+ ChkEn-

04:00.0 Audio device: Creative Labs [SB X-Fi Xtreme Audio] CA0110-IBG
Subsystem: Creative Labs Device 0018
Control: I/O- Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Interrupt: pin A routed to IRQ 18
Region 0: Memory at f9ffc000 (32-bit, non-prefetchable) [size=16K]
Capabilities: [dc] Power Management version 3
Flags: PMEClk- DSI+ D1+ D2+ AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
Status: D0 PME-Enable- DSel=0 DScale=0 PME-
Kernel modules: snd-ca0106


2009-03-13 02:38:50

by Robert Hancock

[permalink] [raw]
Subject: Re: How can PCI resource allocation fail?

Christian P. Schmidt wrote:
> Hi all,
>
> I'm toying with the alsa-driver for the Creative Labs X-Fi. I'm working on the PCI Express version of this card, though, which is
> the same as the PCI version plus a PCIe to PCI bridge but has a different ID:
>
> +-1c.2-[0000:03-04]----00.0-[0000:04]----00.0 1102:0009
>
> 03:00.0 PCI bridge: Creative Labs Device 7006
> 04:00.0 Audio device: Creative Labs [SB X-Fi Xtreme Audio] CA0110-IBG
>
> Now, after adding the ID, the driver fails:
>
> [46833.487579] CA0106 0000:04:00.0: PCI INT A -> GSI 18 (level, low) -> IRQ 18
> [46833.487586] CA0106 0000:04:00.0: PCI INT A disabled
> [46833.487588] cannot allocate the port
> [46833.487594] CA0106: probe of 0000:04:00.0 failed with error -16
>
> The actual error is occurring in
>
> chip->port = pci_resource_start(pci, 0);
> chip->res_port = request_region(chip->port, pci_resource_len(pci,0), "snd_ca0106");
> if (!chip->res_port) {
> snd_ca0106_free(chip);
> printk(KERN_ERR "cannot allocate the port\n");
> return -EBUSY;
> }
>
> This from /proc/iomem:
>
> f9f00000-f9ffffff : PCI Bus 0000:03
> f9f00000-f9ffffff : PCI Bus 0000:04
> f9ffc000-f9ffffff : 0000:04:00.0
>
> Some additional debug output tells me that the code is actually trying to allocate 16k starting from f9ffc000. What could be
> potential reasons for the failure? Do I have to do something with the bridge before I can try to request the region?

request_region is requesting IO ports. The PCI BAR on the card is MMIO
memory, not IO ports, so request_mem_region has to be used. It's
possible that this driver isn't set up to handle MMIO space.

2009-03-13 07:44:38

by Clemens Ladisch

[permalink] [raw]
Subject: Re: [alsa-devel] How can PCI resource allocation fail?

Christian P. Schmidt wrote:
> I'm toying with the alsa-driver for the Creative Labs X-Fi. I'm working
> on the PCI Express version of this card,

... which isn't supported ...

> [46833.487588] cannot allocate the port
> [46833.487594] CA0106: probe of 0000:04:00.0 failed with error -16
> ...
> Region 0: Memory at f9ffc000 (32-bit, non-prefetchable) [size=16K]

... because this I/O range is memory-mapped; the driver knows only about
models with regular I/O ports. (This has nothing to do with the PCI-E
bridge; the X-Fi chip itself is a different model.)


Best regards,
Clemens

2009-03-13 08:24:42

by Takashi Iwai

[permalink] [raw]
Subject: Re: [alsa-devel] How can PCI resource allocation fail?

At Fri, 13 Mar 2009 08:44:26 +0100,
Clemens Ladisch wrote:
>
> Christian P. Schmidt wrote:
> > I'm toying with the alsa-driver for the Creative Labs X-Fi. I'm working
> > on the PCI Express version of this card,
>
> ... which isn't supported ...

You can try sound-unstable tree. If your device is a Vista-compatible
model, it may work with snd-hda-intel (with a luck).

git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-unstable-2.6.git

The corresponding alsa-driver snapshot is:
ftp://ftp.kernel.org/pub/linux/kernel/people/tiwai/snapshot/alsa-driver-unstable-snapshot.tar.gz

If it's no Vista-compatible (i.e. HD-audio compatible) model, you can
try topic/sbxfi branch of the sound unstable tree above. Just
pull/merge the branch after cloning.


Takashi

2009-03-13 10:30:42

by Vedran Miletić

[permalink] [raw]
Subject: Re: [alsa-devel] How can PCI resource allocation fail?

On Fri, Mar 13, 2009 at 9:24 AM, Takashi Iwai <[email protected]> wrote:
> At Fri, 13 Mar 2009 08:44:26 +0100,
> Clemens Ladisch wrote:
>>
>> Christian P. Schmidt wrote:
>> > I'm toying with the alsa-driver for the Creative Labs X-Fi. I'm working
>> > on the PCI Express version of this card,
>>
>> ... which isn't supported ...
>
> You can try sound-unstable tree.  If your device is a Vista-compatible
> model, it may work with snd-hda-intel (with a luck).
>
>   git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-unstable-2.6.git
>
> The corresponding alsa-driver snapshot is:
>   ftp://ftp.kernel.org/pub/linux/kernel/people/tiwai/snapshot/alsa-driver-unstable-snapshot.tar.gz
>
> If it's no Vista-compatible (i.e. HD-audio compatible) model, you can
> try topic/sbxfi branch of the sound unstable tree above.  Just
> pull/merge the branch after cloning.
>
>
> Takashi
> _______________________________________________
> Alsa-devel mailing list
> [email protected]
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>

IIRC, all PCI-E X-Fi cards are UAA (this part I'm pretty certain
about), and all UAA X-Fi cards are PCI-E (I saw at some point some OEM
X-Fi card that had two chips, one on the front and other on the rear,
so not totally sure about this one).

Vedran