bvnc/<bvnc>/seq.c — Per-GPU sequences

Each GPU implements the functions of bvnc_seq.h — Per-BVNC hardware sequences (and dust_power) in its own src/bvnc/<b.v.n.c>/seq.c, from its own specification only. The two files use the same function names, so each is documented under its own C namespace.

BXE-2-32 (36.29.52.182)

Hardware sequences of the BXE-2-32 (36.29.52.182, SpacemiT K1), from docsClean/BXE-2-32 only: the functions of bvnc_seq.h, plus dust_power().

CR_TPU_FILTER_MODE

TPU filter/truncation mode (boot-gpu-init.md step 9).

CR_MULTICORE_COMPUTE_CTRL

Multicore compute control (MULTICORE_COMPUTE_CTRL_COMMON).

CR_ISP_RENDER

ISP_RENDER (public).

CR_PIXEL_LAUNCH

Pixel-pipe launch (no public name).

CR_TA_CACHE_INIT_FIRST

PM trigger of the first geometry kick (no public name, E043).

SOFT_RESET_HWR_LO

CR_SOFT_RESET low word, first stage of the HWR reset: every GPU unit except the MIPS and MTS wrapper.

SOFT_RESET_HWR_HI

CR_SOFT_RESET high word, first stage.

SOFT_RESET_HWR_LO2

Low-word bits added in the second stage.

SOFT_RESET_HWR_HI2

High-word bits added in the second stage.

bool dust_power(bool on)

Request a dust power-island transition.

Powering up first marks the dusts active. The request is written, then the firmware waits (10 ms at most) for POWER_COMPLETE.

Parameters:
  • on – Power the dusts up (true) or down.

Returns:

true when the transition completed without POWER_ABORT.

bool bvnc_units_init(struct sysinit *si)

Initialise the GPU units (boot-gpu-init.md section A, steps 3-10).

Configures the SLC bypass, pulses the unit reset, sets the PDS and USC execution bases, writes the unit defaults before and after the init-done handshakes, and sets the TPU filter mode and the TPU, PBE, ISP and TE defaults.

Parameters:
  • si – The host’s sysinit.

Returns:

true when both init-done polls completed.

bool bvnc_hwr_reset(void)

Reset part of a recovery (hardware-recovery.md, answer to Q29b item 4): stall the BIF and wait for it and the SLC to drain, invalidate the MMU caches, disable partial renders, two-stage soft reset (every unit except the MIPS and MTS wrapper, then the second-stage bits, 10 us, release), re-initialise the units, unstall the BIF, TPU clean-up, SLC flush.

Returns:

a failed poll is traced and the recovery goes on.

Return type:

true

void bvnc_reg_cfg_apply(void)

No register-override list in the BXE-2-32 specification (REGCONFIG is “not sent by mainline”).

bool bvnc_mmu_cache_inval(uint32_t bif_bits, bool pm_tlb)

MMUCACHE (E015): flush and invalidate the SLC first, so that the MMU does not walk stale lines, then the MMU caches, then the PM TLB.

Parameters:
  • bif_bits – CR_BIF_CTRL_INVAL bits.

  • pm_tlb – Also invalidate the PM TLB.

Returns:

failed polls are only traced.

Return type:

true

bool bvnc_kick_admit(uint32_t dm, const struct fwcommoncontext *ctx, uint32_t cmd_id, const void *payload)

Every task is admitted when its data master is idle: the overlap rules of scheduler.md are not implemented for this GPU yet (the mainline host on the K1 sets no DISABLE_DM_OVERLAP; Mesa sends equal priorities).

Returns:

true.

void bvnc_gp_events(uint32_t ev)

Nothing: the BXE-2-32 specification gives no handling for GPIO_REQ or USC_TRIGGER (routed to DM0, never seen on the K1).

Parameters:
  • ev – The CR_EVENT_STATUS bits that were set.

void bvnc_pow_off(void)

Nothing beyond the shared state teardown (power-management.md).

void bvnc_dm_cache_flush(uint32_t dm)

Per-job cache flush on completion, before the command is retired.

Follows kick-compute-and-3d.md “Completion: per-job cache flush” (answer to Q14; geometry values from Q19b): front end, USC, PDS and TPU flushes, the MCU fence for the data master, then an SLC flush. Data masters other than geometry, fragment and compute only flush the SLC.

Parameters:
  • dm – The data master that finished.

void bvnc_tq_launch(uint32_t isp_render)

Start a TQ_3D: ISP_RENDER, then 0x0F00 = 1 as the last write (answer to Q14).

Parameters:
  • isp_render – The ISP_RENDER value (without the resume bit).

void bvnc_cdm_multicore_ctrl(const struct cmd_compute *cmd)

MULTICORE_COMPUTE_CTRL_COMMON = (execute_count << 8) | 1 (one core).

Parameters:
  • cmd – The compute command.

void bvnc_frag_end_sync(uint32_t ev)

Nothing to wait for: the BXE-2-32 specification has no end-of-render sync.

Parameters:
  • ev – The events seen (unused).

void bvnc_geom_first_kick_pm(void)

First geometry kick: PM trigger 0x0258 and its poll (E043).

BXM-4-64 (36.56.104.183)

Hardware sequences of the BXM-4-64 (36.56.104.183, SpacemiT K3), from docsClean/BXM-4-64 only: the functions of bvnc_seq.h, plus dust_power(). Nothing here has run on a K3 yet.

CR_CORE_INDEX_COMPUTE

Per-core compute and fragment core-index registers (boot-gpu-init.md section 5.1).

CR_CORE_BANK_STRIDE

Stride between the register banks of two cores.

CR_MAX_CORE_BANKS

Core banks reachable in the wired register window: the broadcast bank starts at 4 strides (0xCFA00000).

CR_MULTICORE_COMPUTE_CTRL

Multicore compute control (MULTICORE_COMPUTE_CTRL_COMMON).

CR_ISP_RENDER

ISP_RENDER (public).

CR_PIXEL_LAUNCH

ISP_START_RENDER trigger (no public name).

CR_ISP_ZLSCTL

ISP_ZLSCTL.

ZLSCTL_STORE_EN

ISP_ZLSCTL bit 2: a Z/S store is enabled.

COMPUTE_FLAG_SINGLE_CORE

ROGUE_COMPUTE_FLAG_SINGLE_CORE (pvr_rogue_fwif_client.h).

EV_ISP_ZLS_END

CR_EVENT_STATUS bit 14: end of the Z/S store (ISP_ZLS_END).

SOFT_RESET_HWR_LO

CR_SOFT_RESET first stage of the HWR reset: the “standard” assert value 0xFFEFFFF8F3FFFC1D (power-management.md section 2.2, hardware-recovery.md step 9; see open point 7 of bvnc.h).

SOFT_RESET_HWR_HI

High word of the first stage.

SOFT_RESET_HWR_LO2

Low-word bits ORed in: FB_TLCACHE, FBDC, FBC, BIF.

SOFT_RESET_HWR_HI2

High-word bits ORed in: PBE, TPU.

CR_CLK_CTRL

ROGUE_CR_CLK_CTRL (64-bit).

CR_CLK_CTRL_AUX

Auxiliary clock control (no public name).

INICFG_DISABLE_CLKGATING_EN

ROGUE_FWIF_INICFG_DISABLE_CLKGATING_EN (pvr_rogue_fwif.h).

POWER_REQ_ON

CR_POWER_REQ bit 0: power on.

POWER_REQ_TRIGGER

CR_POWER_REQ bit 1: trigger.

POWER_REQ_ALL

CR_POWER_REQ bit 9: present in every observed request.

POWER_REQ_DUST_SHIFT

CR_POWER_REQ bits [24 + d]: dust mask.

EV_POWER_DONE

Completion bits of a power request in CR_EVENT_STATUS.

POWER_REQ_TRIES

Attempts of a power request that ends in POWER_ABORT (a finite limit; the value is ours).

HWR_RESET_TRIES

Attempts of the reset of one core in a recovery (hardware-recovery.md section 2.2: “e.g., 3”).

REG_CFG_TYPE_PWR_ON

ROGUE_FWIF_REG_CFG_TYPE_PWR_ON: index of its count in num_regs_type.

REG_CFG_RECORDS

Offset of reg_configs[] (num_regs_type[8], 8-byte aligned).

REG_CFG_RECORD_SIZE

Size of a rogue_fwif_reg_cfg_rec (sddr, mask, value).

REG_CFG_MAX_SIZE

ROGUE_FWIF_REG_CFG_MAX_SIZE.

INIT_SET

Operation of a BVNC_INIT_POST_POLL entry: write the value.

INIT_OR

Operation of a BVNC_INIT_POST_POLL entry: OR the value into the register.

static uint32_t num_cores(void)

Number of cores (ROGUE_CR_MULTICORE_SYSTEM), as the per-core loops of the specification use it.

Returns:

The core count, or 1 when it reads 0 or more than the register window holds.

static void timer_tick(void)

Wait for ROGUE_CR_TIMER to advance by one tick (at most 1 ms).

static void clock_gating(void)

Force the clocks on when the host asks for it (boot-gpu-init.md section 2.1, DISABLE_CLKGATING_EN).

static uint32_t power_request(uint32_t req)

One power request (power-management.md section 2.3, steps 1-10).

Holds the GPU blocks in reset except those the request needs, writes the mask, then the trigger one timer tick later, waits for POWER_COMPLETE or POWER_ABORT, releases the reset, clears the request and the events.

Parameters:
  • req – The request without the trigger bit.

Returns:

timeout).

Return type:

The EV_POWER_COMPLETE / EV_POWER_ABORT bits seen (0

bool dust_power(bool on)

Request a dust power-island transition (power-management.md section 2.3).

Powering up first forces the clocks on when asked (section 2.1) and marks the dusts active. The request is DIR | ALL | units | dusts << 24; a POWER_ABORT is retried. The unit mask is BVNC_POWER_UNITS_MASK: the specification does not give the number of units (open point 6 of bvnc.h).

Parameters:
  • on – Power the dusts up (true) or down.

Returns:

true when the transition completed without POWER_ABORT.

static void slc_bypass_from_size(void)

Set the SLC bypass from the SLC size the hardware reports.

boot-gpu-init.md section 2.3: with SLC_SIZE_CONFIGURABLE the size in KiB is read from BVNC_SLC_SIZE_REG. A small SLC (32 KiB or less, or 0) sets both bypass bits, a medium one sets only the low bit, and 128 KiB or more (the K3) clears both.

static void core_indices(void)

Number the cores and open the broadcast to all of them.

boot-gpu-init.md section 5.1: core i gets index i in its compute and fragment core-index registers, then XPU_BROADCAST selects every core. A core count of 0, or one beyond the register window, is treated as one core.

bool bvnc_units_init(struct sysinit *si)

Initialise the GPU units.

boot-gpu-init.md sections 2.2 to 5.1, after the dusts are powered: MMU cache invalidation, SLC bypass from the SLC size, PDS and USC execution bases, 0x6000 = 0, PDS and TPU defaults, the init-done handshakes, the per-unit defaults (plain and ORed writes) with the PBE state table cleared, and the core indices.

Not written: the USC and PDS overalloc controls (0x4050, 0x06D8), whose values the specification does not give (open point 3 of the BVNC header); they keep their reset values, as on the BXE-2-32.

Parameters:
  • si – The host’s sysinit.

Returns:

true when every poll completed.

bool bvnc_hwr_reset(void)

Reset part of a recovery (hardware-recovery.md section 2.2, then section 2.3 step 1 and the 0x0338 part of step 3).

For each core, up to HWR_RESET_TRIES times while a poll fails: select the core, stall the BIF and wait for the PM MMU and external reads to drain, invalidate the MMU caches, drain the wrapper, wait for the sidekick and the SLC to go idle, soft reset (standard value, then the extra bits ORed in), release, run the whole unit initialisation, unstall the BIF, post-HWR TPU/USC block reset, SLC flush. Then the broadcast mask is restored and partial renders are disabled.

Returns:

false on a fatal failure (MMU invalidation or SLC idle) or when the polls still fail after the last attempt.

void bvnc_reg_cfg_apply(void)

Apply the PWR_ON group of the host’s register overrides (boot-gpu-init.md section 6 step 1, sysinit.reg_cfg_fw_addr).

The list is struct rogue_fwif_reg_cfg (pvr_rogue_fwif.h): a count per type, then the records grouped by type, PWR_ON first. Each record writes value under mask (read-modify-write, a 32-bit word at a time, skipping a word whose mask is 0) to the register at offset sddr. The mainline host never sets the address.

bool bvnc_mmu_cache_inval(uint32_t bif_bits, bool pm_tlb)

MMUCACHE (kernel-ccb.md section 3): SLC flush and invalidate (0x10), the MMU caches, the PM/BIF memory when asked (0x1348), each polled, then the wrapper drain.

Parameters:
  • bif_bits – CR_BIF_CTRL_INVAL bits (flags & 0xF).

  • pm_tlb – flags & 0x10: also invalidate the PM/BIF memory.

Returns:

false when a poll timed out (the host then sees POLL_FAILURE).

INICFG_DISABLE_DM_OVERLAP_BIT

ROGUE_FWIF_INICFG_DISABLE_DM_OVERLAP (sysdata.config_flags bit 19).

FRAG_FLAG_PREVENT_CDM_OVERLAP

ROGUE_FRAG_FLAGS_PREVENT_CDM_OVERLAP (pvr_rogue_fwif_client.h).

COMPUTE_FLAG_PREVENT_ALL_OVERLAP

ROGUE_COMPUTE_FLAG_PREVENT_ALL_OVERLAP (pvr_rogue_fwif_client.h): the public flag mapped to the compute exclusivity bits of scheduler.md 5.3.

CMD_FRAG_FLAGS

Offset of flags in rogue_fwif_cmd_frag.

static bool frag_prevents_cdm

The running 3D task asked to keep compute out (PREVENT_CDM_OVERLAP).

bool bvnc_kick_admit(uint32_t dm, const struct fwcommoncontext *ctx, uint32_t cmd_id, const void *payload)

Kick admission test (scheduler.md section 5).

  • Serialised mode (DISABLE_DM_OVERLAP): no other data master may run, except a geometry held by an out-of-memory (SPM).

  • Overlapped mode: on one core every data master shares the core, so a task waits while another data master runs a context of strictly higher priority; a 3D task with PREVENT_CDM_OVERLAP keeps compute out, and a compute task with PREVENT_ALL_OVERLAP runs alone.

Not implemented: the core partitioning of several cores and the global parameter-buffer check of geometry (one core, one buffer on the K3).

Parameters:
  • dm – The data master the task needs (its own is idle).

  • ctx – The task’s context.

  • cmd_id – The command type.

  • payload – The command.

Returns:

false to keep the task queued for now.

void bvnc_gp_events(uint32_t ev)

USC_TRIGGER (event bit 15, observed-sequences.md section 4): clear it and interrupt the host (notify_host() increments the interrupt counter and writes CR[0x08A8] = 1). GPIO_REQ (bit 12) is left alone: its handler is not specified.

Parameters:
  • ev – The CR_EVENT_STATUS bits that were set.

void bvnc_pow_off(void)

POW_OFF hardware steps (power-management.md section 3, steps 2-3): power the dusts down, flush the SLC and wait for it to go idle.

void bvnc_dm_cache_flush(uint32_t dm)

Per-job cache flush on completion, before the command is retired.

Follows data-masters.md section 4.1: front end, USC, PDS and TPU flushes, the 3D-only internal caches (0x1470/0x1478/0x1480), the MCU fence for the data master, the wrapper barrier, then an SLC flush. Data masters other than geometry, fragment and compute only flush the SLC.

Parameters:
  • dm – The data master that finished.

void bvnc_tq_launch(uint32_t isp_render)

Start a TQ_3D: 0x0F00 = 1, then ISP_RENDER (kick-compute-and-3d.md section 3.1 step 13).

Parameters:
  • isp_render – The ISP_RENDER value (without the resume bit).

void bvnc_cdm_multicore_ctrl(const struct cmd_compute *cmd)

MULTICORE_COMPUTE_CTRL_COMMON (kick-compute-and-3d.md section 1.1.1): (execute_count << 8) | core_mask when the command may use several cores and there are several, 1 otherwise.

Parameters:
  • cmd – The compute command.

void bvnc_frag_end_sync(uint32_t ev)

With a Z/S store enabled (ISP_ZLSCTL bit 2), wait for ISP_ZLS_END and clear it (kick-compute-and-3d.md section 2.2 step 3). The interrupt task clears every event it sees, so an ISP_ZLS_END that came with the end of render is taken from ev.

Parameters:
  • ev – The CR_EVENT_STATUS bits the interrupt task saw.

void bvnc_geom_first_kick_pm(void)

Nothing beyond the shared PM steps: 0x0258 is not used (kick-geometry-ta.md section 3.1, correction of 2026-11-28).