Skip to content

softbkl: replace hardware k0lock with software ticket lock (SOFT_BKL)#77

Open
Erich Plondke (eplondke) wants to merge 1 commit into
masterfrom
dev/ejp/softlock
Open

softbkl: replace hardware k0lock with software ticket lock (SOFT_BKL)#77
Erich Plondke (eplondke) wants to merge 1 commit into
masterfrom
dev/ejp/softlock

Conversation

@eplondke

Copy link
Copy Markdown
Contributor

Introduce SOFT_BKL compile-time flag that redirects all BKL lock/unlock sites from the hardware k0lock instruction to an in-memory ticket spinlock.

  • BKL_LOCK/BKL_UNLOCK macros in hw.h dispatch to H2K_spinlock_{lock,unlock} when SOFT_BKL is set, k0lock/k0unlock otherwise
  • ASM_BKL_LOCK/ASM_BKL_UNLOCK macros in asm_std.h wrap the LL/SC ticket lock for .S files; K0LOCK/K0UNLOCK (bypass poison) otherwise
  • Makefile poisons bare k0lock/k0unlock in .S files to enforce macro use
  • H2K_spinlock_t bkl field added to H2K_kg_t under SOFT_BKL
  • All 20 .S files converted from bare k0lock/k0unlock to ASM_BKL_LOCK/UNLOCK
  • ticket lock: 32-bit packed (upper 16 = next, lower 16 = now_serving), strictly fair FIFO, removes dccleana from acquire path
  • h2_init() sets H2K_gp (r28) so INC_KERNEL tests work without per-test change
  • boot.ref.S adds call 1f to establish r31 before first ASM_BKL_LOCK

make testall SOFT_BKL=1: 1224 passed, 0 failed

Introduce SOFT_BKL compile-time flag that redirects all BKL lock/unlock
sites from the hardware k0lock instruction to an in-memory ticket spinlock.

- BKL_LOCK/BKL_UNLOCK macros in hw.h dispatch to H2K_spinlock_{lock,unlock}
  when SOFT_BKL is set, k0lock/k0unlock otherwise
- ASM_BKL_LOCK/ASM_BKL_UNLOCK macros in asm_std.h wrap the LL/SC ticket lock
  for .S files; K0LOCK/K0UNLOCK (bypass poison) otherwise
- Makefile poisons bare k0lock/k0unlock in .S files to enforce macro use
- H2K_spinlock_t bkl field added to H2K_kg_t under SOFT_BKL
- All 20 .S files converted from bare k0lock/k0unlock to ASM_BKL_LOCK/UNLOCK
- ticket lock: 32-bit packed (upper 16 = next, lower 16 = now_serving),
  strictly fair FIFO, removes dccleana from acquire path
- h2_init() sets H2K_gp (r28) so INC_KERNEL tests work without per-test change
- boot.ref.S adds call 1f to establish r31 before first ASM_BKL_LOCK

make testall SOFT_BKL=1: 1224 passed, 0 failed

Signed-off-by: Erich Plondke <erich@qti.qualcomm.com>
@eplondke
Erich Plondke (eplondke) marked this pull request as ready for review July 13, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

untested Mark untested PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant