Hi Lyude, Danilo, and Nouveau developers,

While testing an actively cooled, display-less NVIDIA Tesla P4 (GP104,
PCI 10de:1bb3) behind a USB4 PCIe tunnel on an arm64 Snapdragon X Elite
host (Linux v7.3.6, no x86 BIOS / UEFI GOP POST), we hit two interacting
defects in nvkm that leave GDDR5 uninitialized and wrap the VRAM heap
calculation.

1. nvkm_devinit_disable() unconditionally returns 0, defeating
   gf100_devinit_preinit()'s display-disabled guard

In drivers/gpu/drm/nouveau/nvkm/subdev/devinit/base.c:

    u64
    nvkm_devinit_disable(struct nvkm_devinit *init)
    {
        if (init && init->func->disable)
            init->func->disable(init);

        return 0;
    }

In drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gf100.c:

    if (base->post) {
        u64 disable = nvkm_devinit_disable(base);
        if (!(disable & (1ULL << NVKM_ENGINE_DISP))) {
            if (nvkm_rdvgac(device, 0, 0x00) ||
                nvkm_rdvgac(device, 0, 0x1a)) {
                base->post = false;
            }
        }
    }

Because nvkm_devinit_disable() always returns 0, the display-disabled
check !(disable & (1ULL << NVKM_ENGINE_DISP)) is always true even after
gm107_devinit_disable() calls nvkm_subdev_disable(device,
NVKM_ENGINE_DISP, 0).

On our un-POSTed Tesla P4 (clean BAR0 baseline, D0, bus mastering off,
zero PCIe/AER errors):
  - BAR0+0x000000 = 0x134000a1 (GP104)
  - BAR0+0x02240c = 0x00000000 (bit 1 clear -> base->post starts true)
  - BAR0+0x021c04 = 0x00000001 (bit 0 set -> display engine fused off)
  - BAR0+0x100ce0 = 0x00000000 (gp102_fb_vidmem_size() returns 0)

We ran an isolated, decision-only diagnostic module executing stock
gf100_devinit_preinit() + gm107_devinit_disable() + the indexed VGA
reads (returning before VGA unlock, firmware upload, FB init, or bus
mastering):
  - nvkm_devinit_disable() read fuses 0x0 / 0x1, disabled DISP, and
    returned 0.
  - nvkm_rdvgac(device, 0, 0x00) returned 0x13 from the absent display
    block.
  - gf100_devinit_preinit() flipped base->post to false, skipping VBIOS
    DEVINIT and leaving GDDR5 uninitialized ("fb: 0 MiB GDDR5").

2. Unsigned underflow in gp102_ram_new() when VRAM size < 1.25 MiB

In drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgp102.c:

    const u32 rsvd_head = ( 256 * 1024); /* vga memory */
    const u32 rsvd_tail = (1024 * 1024); /* vbios etc */
    u64 size = fb->func->vidmem.size(fb);
    ...
    return nvkm_mm_init(&(*pram)->vram, NVKM_RAM_MM_NORMAL,
                        rsvd_head >> NVKM_RAM_MM_SHIFT,
                        (size - rsvd_head - rsvd_tail) >> NVKM_RAM_MM_SHIFT,
                        1);

When gp102_fb_vidmem_size() returns 0 (or any value smaller than
rsvd_head + rsvd_tail + one NVKM_RAM_MM_SHIFT page), the unsigned
subtraction wraps (or yields 0 pages at the exact boundary).

On a stock Nouveau probe of this card, Nouveau logged "fb: 0 MiB GDDR5"
and the host reset during probe (no pstore/journal backtrace captured,
so we do not claim the wrap itself was the sole cause of the reset). On
the same card and slot, NVIDIA R580.196.11 initialized the card (7.5 GiB
NVML) and completed 6,127 verified CUDA launches over 90 seconds.

Suggested fix directions:
  - In gf100_devinit_preinit() / nvkm_devinit_disable(): check whether
    NVKM_ENGINE_DISP was actually disabled (e.g. via
    nvkm_subdev_disabled() / device->disable_mask) instead of relying on
    nvkm_devinit_disable()'s constant 0 return, so headless GPUs skip
    the VGA CRTC heuristic.
  - In gp102_ram_new(): reject size < rsvd_head + rsvd_tail +
    (1ULL << NVKM_RAM_MM_SHIFT) with -EINVAL and an nvkm_error() before
    calling nvkm_ram_new_().

Scope note: we have not yet tested a forced-POST
(nouveau.config=NvForcePost=1) probe on this card, so we cannot confirm
whether gm200_devinit_post() brings up GDDR5 once base->post stays true.

Full write-up and register readbacks:
https://github.com/fidecastro/surface-laptop-7-15in-facts/blob/main/upstream-reports/nouveau-gp104-headless-post.md

Happy to run targeted diagnostic checks or test patches on this card if
helpful.

Best regards,
Felipe Infante de Castro

Signed-off-by: Felipe Infante de Castro <[email protected]>

Reply via email to