TW6869 driver fails with -12 (cannot allocate memory) on Jetson TX2 NX - PCIe DMA allocation issue

Hardware:

  • Jetson TX2 NX module

  • RTSO 6002E carrier board

  • RTSV-6911i video capture card (Intersil TW6869 chipset)

Software:

  • L4T 32.7.1 (JetPack 4.6.1)

  • Kernel: 4.9.253-tegra (stock L4T)

  • Driver: TW686x staging driver (built from L4T kernel sources)

Problem:

The driver fails to allocate DMA buffers during probe with error -12 (ENOMEM).

dmesg output:

tw6869: PCI 0000:01:00.0, IRQ 379, MMIO 0x40100000 (memcpy mode)
tw686x 0000:01:00.0: enabling device (0000 -> 0002)
tw686x 0000:01:00.0: dma0: unable to allocate P-buffer
tw686x 0000:01:00.0: can't register video
tw686x: probe of 0000:01:00.0 failed with error -12

What I’ve tried:

  1. Driver as module vs built-in - Both result in same -12 error

  2. Different DMA modes - Default memcpy, sg, contig all fail

  3. Driver source modification:

    • Replaced pci_alloc_consistent with dma_alloc_coherent in tw686x_memcpy_dma_allocfunction. (caused kernel crash)

    • used GFP_DMA instead of GFP_KERNEL in probe function as stated here

  4. Kernel command line parameters: coherent_pool=64M (kernel crash)

Has anyone successfully used a TW686x-based capture card on Jetson TX2/NX/AGX with L4T 32.x?

This is a driver probe failure caused by memory allocation failure.

  • error -12 = ENOMEM

  • The key line is dma0: unable to allocate P-buffer

  • Because that DMA buffer allocation failed, the driver then can’t register video and the probe aborts.

Most likely causes

  1. Not enough contiguous DMA memory available at probe time

  2. CMA too small for the buffer size the tw686x driver wants

  3. DMA mask / IOMMU mismatch with this older PCIe capture card

  4. The driver is trying to allocate too many/too-large buffers

What to check

  • dmesg | grep -i -E "cma|dma|iomm|tw686"

  • cat /proc/meminfo | grep -i cma

  • lspci -vv -s 01:00.0

Common fixes

  • Increase CMA, e.g. boot with:

    • cma=256M

    • or cma=512M

  • If IOMMU is involved, test with it relaxed/disabled temporarily

  • Check whether the driver has module params for buffer count/size

  • Make sure no other video/DMA-heavy drivers grabbed CMA first

Bottom line

The card is detected, but tw686x fails during DMA buffer setup, so this is primarily a memory/CMA/DMA allocation issue, not a PCI enumeration issue.

$ dmesg | grep -i -E β€œcma|dma|iomm|tw686”

[ 0.000000] cma: Reserved 64 MiB at 0x00000000fc000000
[ 0.000000] DMA zone: 8192 pages used for memmap
[ 0.000000] DMA zone: 0 pages reserved
[ 0.000000] DMA zone: 523776 pages, LIFO batch:31
[ 0.000000] Memory: 3156124K/4026368K available (15358K kernel code, 2958K rwdata, 6652K rodata, 8640K init, 610K bss, 116580K reserved, 753664K cma-reserved)
[ 0.391427] arm-smmu 12000000.iommu: probing hardware configuration…
[ 0.391432] arm-smmu 12000000.iommu: SMMUv2 with:
[ 0.391436] arm-smmu 12000000.iommu: stage 1 translation
[ 0.391439] arm-smmu 12000000.iommu: stage 2 translation
[ 0.391442] arm-smmu 12000000.iommu: nested translation
[ 0.391449] arm-smmu 12000000.iommu: stream matching with 128 register groups, mask 0x7f80
[ 0.391454] arm-smmu 12000000.iommu: SMMU address space size (0x800000) differs from mapped region size (0x1000000)!
[ 0.391458] arm-smmu 12000000.iommu: 64 context banks (0 stage-2 only)
[ 0.391463] arm-smmu 12000000.iommu: Stage-1: 39-bit VA β†’ 48-bit IPA
[ 0.391466] arm-smmu 12000000.iommu: Stage-2: 39-bit IPA β†’ 48-bit PA
[ 0.396475] atomic_pool_init():622: DMA: preallocated 1024 KiB pool for atomic allocations
[ 0.401869] iommu: Adding device 3460000.sdhci to group 0
[ 0.403009] iommu: Adding device 3160000.i2c to group 1
[ 0.403398] iommu: Adding device c240000.i2c to group 2
[ 0.403692] iommu: Adding device 3180000.i2c to group 3
[ 0.403972] iommu: Adding device 3190000.i2c to group 4
[ 0.404337] iommu: Adding device 31b0000.i2c to group 5
[ 0.404637] iommu: Adding device 31c0000.i2c to group 6
[ 0.404919] iommu: Adding device c250000.i2c to group 7
[ 0.405247] iommu: Adding device 31e0000.i2c to group 8
[ 0.406688] iommu: Adding device 3210000.spi to group 9
[ 0.406971] iommu: Adding device c260000.spi to group 10
[ 0.407611] iommu: Adding device 3100000.serial to group 11
[ 0.407898] iommu: Adding device 3110000.serial to group 12
[ 0.408185] iommu: Adding device 3130000.serial to group 13
[ 0.409338] iommu: Adding device 2490000.ether_qos to group 14
[ 0.410161] iommu: Adding device b000000.rtcpu to group 15
[ 0.411842] iommu: Adding device 13e10000.host1x to group 16
[ 0.412136] iommu: Adding device 13e10000.host1x:ctx0 to group 17
[ 0.412403] iommu: Adding device 13e10000.host1x:ctx1 to group 18
[ 0.412678] iommu: Adding device 13e10000.host1x:ctx2 to group 19
[ 0.412956] iommu: Adding device 13e10000.host1x:ctx3 to group 20
[ 0.413275] iommu: Adding device 13e10000.host1x:ctx4 to group 21
[ 0.413558] iommu: Adding device 13e10000.host1x:ctx5 to group 22
[ 0.413834] iommu: Adding device 13e10000.host1x:ctx6 to group 23
[ 0.414127] iommu: Adding device 13e10000.host1x:ctx7 to group 24
[ 0.414540] iommu: Adding device 150c0000.nvcsi to group 25
[ 0.415095] iommu: Adding device 15700000.vi to group 26
[ 0.415408] iommu: Adding device 15600000.isp to group 27
[ 0.415621] iommu: Adding device 15200000.dc_common to group 28
[ 0.416109] iommu: Adding device 15200000.nvdisplay to group 29
[ 0.416431] iommu: Adding device 15210000.nvdisplay to group 30
[ 0.416747] iommu: Adding device 15340000.vic to group 31
[ 0.416955] iommu: Adding device 154c0000.nvenc to group 32
[ 0.417178] iommu: Adding device 15480000.nvdec to group 33
[ 0.417486] iommu: Adding device 15380000.nvjpg to group 34
[ 0.417697] iommu: Adding device 15500000.tsec to group 35
[ 0.417890] iommu: Adding device 15100000.tsecb to group 36
[ 0.418800] iommu: Adding device 15810000.se to group 37
[ 0.418998] iommu: Adding device 15820000.se to group 38
[ 0.419192] iommu: Adding device 15830000.se to group 39
[ 0.419389] iommu: Adding device 15840000.se to group 40
[ 0.420163] iommu: Adding device smmu_test to group 41
[ 0.421790] iommu: Adding device 3530000.xhci to group 42
[ 0.422213] iommu: Adding device 3550000.xudc to group 43
[ 0.423338] iommu: Adding device 17000000.gp10b to group 44
[ 0.426210] iommu: Adding device d000000.bpmp to group 45
[ 0.430619] iommu: Adding device 2600000.dma to group 46
[ 0.436979] iommu: Adding device 10003000.pcie-controller to group 47
[ 0.437368] iommu: Adding device sound to group 48
[ 0.437679] iommu: Adding device 3510000.hda to group 49
[ 0.444309] iommu: Adding device c1a0000.aon to group 50
[ 0.548430] dma_declare_coherent_resizable_cma_memory:324: resizable heap=vpr, base=0x00000000c6000000, size=0x2a000000
[ 0.548539] cma: enabled page replacement for spfn=c6000, epfn=f0000
[ 0.548543] dma_declare_coherent_resizable_cma_memory:373: resizable cma heap=vpr create successful
[ 0.551290] tegra-gpcdma 2600000.dma: GPC DMA driver register 32 channels
[ 0.855274] iommu: Adding device aconnect@2a41000:adsp_audio to group 51
[ 0.858885] iommu: Adding device 2993000.adsp to group 52
[ 0.882530] iommu_context_dev 13e10000.host1x:ctx0: initialized (streamid=56)
[ 0.884013] iommu_context_dev 13e10000.host1x:ctx1: initialized (streamid=57)
[ 0.885485] iommu_context_dev 13e10000.host1x:ctx2: initialized (streamid=58)
[ 0.886966] iommu_context_dev 13e10000.host1x:ctx3: initialized (streamid=59)
[ 0.888446] iommu_context_dev 13e10000.host1x:ctx4: initialized (streamid=60)
[ 0.890042] iommu_context_dev 13e10000.host1x:ctx5: initialized (streamid=61)
[ 0.891509] iommu_context_dev 13e10000.host1x:ctx6: initialized (streamid=62)
[ 0.893015] iommu_context_dev 13e10000.host1x:ctx7: initialized (streamid=63)
[ 0.895707] tegradccommon 15200000.dc_common: dma mapping done
[ 0.908286] tegra-adma 2930000.adma: Tegra210 ADMA driver registered 32 channels
[ 1.429685] mmc0: SDHCI controller on 3460000.sdhci [3460000.sdhci] using ADMA 64-bit with 64 bit addr
[ 1.437695] mmc1: SDHCI controller on 3440000.sdhci [3440000.sdhci] using ADMA 64-bit with 64 bit addr
[ 1.546549] tegra-asoc: sound: ADMAIF1 ↔ ADMAIF1 mapping ok
[ 1.546627] tegra-asoc: sound: ADMAIF2 ↔ ADMAIF2 mapping ok
[ 1.546697] tegra-asoc: sound: ADMAIF3 ↔ ADMAIF3 mapping ok
[ 1.546763] tegra-asoc: sound: ADMAIF4 ↔ ADMAIF4 mapping ok
[ 1.546832] tegra-asoc: sound: ADMAIF5 ↔ ADMAIF5 mapping ok
[ 1.546898] tegra-asoc: sound: ADMAIF6 ↔ ADMAIF6 mapping ok
[ 1.546966] tegra-asoc: sound: ADMAIF7 ↔ ADMAIF7 mapping ok
[ 1.547032] tegra-asoc: sound: ADMAIF8 ↔ ADMAIF8 mapping ok
[ 1.547102] tegra-asoc: sound: ADMAIF9 ↔ ADMAIF9 mapping ok
[ 1.547168] tegra-asoc: sound: ADMAIF10 ↔ ADMAIF10 mapping ok
[ 1.547240] tegra-asoc: sound: ADMAIF11 ↔ ADMAIF11 mapping ok
[ 1.547307] tegra-asoc: sound: ADMAIF12 ↔ ADMAIF12 mapping ok
[ 1.547376] tegra-asoc: sound: ADMAIF13 ↔ ADMAIF13 mapping ok
[ 1.547449] tegra-asoc: sound: ADMAIF14 ↔ ADMAIF14 mapping ok
[ 1.547518] tegra-asoc: sound: ADMAIF15 ↔ ADMAIF15 mapping ok
[ 1.547588] tegra-asoc: sound: ADMAIF16 ↔ ADMAIF16 mapping ok
[ 1.547656] tegra-asoc: sound: ADMAIF17 ↔ ADMAIF17 mapping ok
[ 1.547726] tegra-asoc: sound: ADMAIF18 ↔ ADMAIF18 mapping ok
[ 1.547798] tegra-asoc: sound: ADMAIF19 ↔ ADMAIF19 mapping ok
[ 1.547866] tegra-asoc: sound: ADMAIF20 ↔ ADMAIF20 mapping ok
[ 2.255930] iommu: Adding device 0000:00:01.0 to group 53
[ 2.256226] pci 0000:01:00.0: TW686x PCI class overridden (0x000000 β†’ 0x048001)
[ 2.256832] iommu: Adding device 0000:01:00.0 to group 54
[ 2.266527] tw6869: PCI 0000:01:00.0, IRQ 379, MMIO 0x40100000 (memcpy mode)
[ 2.266543] tw686x 0000:01:00.0: enabling device (0000 β†’ 0002)
[ 2.267620] tw686x 0000:01:00.0: dma0: unable to allocate P-buffer
[ 2.274024] tw686x 0000:01:00.0: can’t register video
[ 2.281499] tw686x: probe of 0000:01:00.0 failed with error -12

$ cat /proc/meminfo | grep -i cma
CmaTotal: 753664 kB
CmaFree: 719864 kB

$ sudo lspci -vv -s 01:00.0
01:00.0 Multimedia controller: Intersil Techwell Device 6869 (rev 01)
Control: I/O- Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- SERR- <PERR- INTx-
Interrupt: pin A routed to IRQ 379
Region 0: Memory at 40100000 (32-bit, prefetchable) [size=4K]
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI- D1- D2- AuxCurrent=375mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
Address: 0000000000000000 Data: 0000
Capabilities: [70] Express (v2) Legacy Endpoint, MSI 00
DevCap: MaxPayload 512 bytes, PhantFunc 0, Latency L0s <1us, L1 <8us
ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop-
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, Exit Latency L0s <512ns, L1 <64us
ClockPM+ Surprise- LLActRep- BwNot- ASPMOptComp-
LnkCtl: ASPM L0s Enabled; RCB 64 bytes Disabled- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Not Supported, TimeoutDis+, LTR-, OBFF Not Supported
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [100 v1] 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: 00, GenCap+ CGenEn- ChkCap+ ChkEn-
Capabilities: [140 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed- WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=ff
Status: NegoPending- InProgress-

Currently I’m using GFP_DMA in tw686x_probefunction.
Driver has 2 params dma_intervaland dma_mode. nothing to set buffer size.

how should I check no other video/DMA-heavy drivers grabbed CMA first?

Could you confirm with normal kernel instead of RT kernel.

Thanks

My kernel is standard L4T, not RT. Confirmed with:

$ zcat /proc/config.gz | grep PREEMPT

CONFIG_PREEMPT_RCU=y
# CONFIG_PREEMPT_NONE is not set
# CONFIG_PREEMPT_VOLUNTARY is not set
CONFIG_PREEMPT=y
CONFIG_PREEMPT_COUNT=y
# CONFIG_DEBUG_PREEMPT is not set
# CONFIG_PREEMPTIRQ_EVENTS is not set
# CONFIG_PREEMPT_TRACER is not set

Ok. I contacted Realtime Technologies support and they provided a custom TW6869 driver.