Skip to content

dspqueue-based llama.cpp hexagon backend hangs at the first compute round-trip on mainline fastrpc (glymur / X2 Elite) #377

Description

FastRPC version

v1.0.7 (git 228d98b)

DSP firmware version

CDSP.HT.3.3-00304-GLYMUR-1

SoC and device name

Snapdragon X2 Elite (glymur), ASUS Zenbook A16

Kernel version

7.2.0-rc6 (linux-next based, mainline drivers/misc/fastrpc.c)

What happened?

Possibly related to #342

Process bring-up is fine. The unsigned user PD is created, all weight tensors static-map, the HMX clock comes up, and the command queue imports:

dspqueue_import: Queue Monitor supported. Importing Queue 0x38500000000 requires packet_callback

Like #342 I also see the method-3 EUNSUPPORTED on libdspqueue_rpc_skel.so:

Error 0x80000414: remote_handle64_invoke failed for module libdspqueue_rpc_skel.so, ... method 3 on domain 3 (sc 0x3010100)

The hang is one step later, at the first compute round-trip. The host writes the op packet, bumps the request counter, signals the DSP, then blocks in dspqueue_read waiting for RESP_PACKET and never gets it:

#4 wait_signal_locked (signal_no=2, timeout=...) at dspqueue/dspqueue_cpu.c:1335
#5 dspqueue_read (timeout_us=1000000)             at dspqueue/dspqueue_cpu.c:2401
#6 ggml_hexagon_session::flush_pending(bool)      in libggml-hexagon.so
#7 ggml_backend_hexagon_graph_compute
#8 llama_context::graph_compute

The DSP never consumes the request. With FARF turned up (logmask 0x001f001f001f001f) the DSP-side receive path comes up fully and then goes idle:

Initialize dspsignal session ...
Opening signal MQ "sigs5"
dspsignal_create: Signal 0 created ... Signal 3 created
dspsignal_mq_thread: <id>: Reading from MQ 8

After that it just hangs.

Things we (okay mainly claude but I provided moral support) ruled out:

  • Unmodified driver: this is stock drivers/misc/fastrpc.c (nothing added), so it's not a local patch of mine.

  • Poll mode: I enabled it (FASTRPC_IOCTL_SET_OPTION / FASTRPC_POLL_MODE succeeds, kaanapali has poll_mode_supported). Same hang; it only changes the host wait from a timeout loop to a poll spin.

  • Driver signaling: I also backported the dspsignal ioctls to try driver signaling. The 8-byte signal is glink-delivered (rpmsg_send returns 0) but the DSP still doesn't consume the request. Same hang as RPC signaling.

  • Not my build: GenieX bundles its own newer llama.cpp hexagon build (Hexagon Tools 6.6.0.0) and hangs identically on the same kernel:

    #4 wait_signal_locked (signal_no=2)   at dspqueue/dspqueue_cpu.c:1335
    #5 dspqueue_read (timeout_us=1000000) at dspqueue/dspqueue_cpu.c:2401
    #6 ggml_hexagon_session::flush_pending(bool)  in <geniex>/llama_cpp/libggml-hexagon.so
    geniex::LlamaLlm::generate
    

mainline drivers/misc/fastrpc.c on glymur seems to be the issue

I looked at the coherency angle since the Windows driver for this part (qcadsprpc8480.sys) manages the buffer cache in software - it flushes the FastRPC DMA buffers explicitly (KeFlushIoBuffers) and allocates them with an explicit cache type (MmAllocateContiguousMemorySpecifyCache) rather than relying on hardware coherency. glymur.dtsi marks the CDSP compute-cb nodes dma-coherent, so the Linux driver skips cache maintenance on these buffers. But I tested this: I rebuilt the DTB with dma-coherent removed from the CDSP compute-cb nodes. The buffers then map non-cached (confirmed the DSP reads them uncached from DRAM), and it still hangs at the same place. So it isn't a simple stale-read/coherency problem - the DSP monitor doesn't consume the request even when its view of the counter is guaranteed fresh.

Questions:

  1. What does the BSP fastrpc driver do for the dspqueue path on glymur specifically (as opposed to the qcs Dragonwing parts) that mainline drivers/misc/fastrpc.c doesn't? I've matched the invoke and mem_map paths against the qcom-6.18.y driver and they look equivalent for this case, so I suspect the missing piece is glymur-specific.
  2. Is there something beyond the RPC signal / driver signal that the DSP-side queue monitor needs to be armed on glymur (a notification/registration the mainline driver doesn't do)?
  3. Is accel/qda the intended driver for running this on glymur under Linux, or is mainline fastrpc expected to work?

Happy to collect more DSP logs or test patches.

Steps to reproduce

Build fedora 7.2.0-rc6 w/ fastrpc.c on glymur and try to run llama.cpp

GGML_HEXAGON_VERBOSE=1 ./bin/llama-cli -m Llama-3.2-3B-Instruct-Q4_0.gguf --device HTP0 -ngl 99 -p "what is the most popular cookie in the world?" -n 128 -no-cnv

Relevant log output

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions