Skip to content

Fix hw_context bitstream unlock on client exit - #9957

Merged
chvamshi-xilinx merged 1 commit into
Xilinx:masterfrom
ManojTakasi:petalinux-xrt-v2026.2_06161249
Aug 5, 2026
Merged

Fix hw_context bitstream unlock on client exit#9957
chvamshi-xilinx merged 1 commit into
Xilinx:masterfrom
ManojTakasi:petalinux-xrt-v2026.2_06161249

Conversation

@ManojTakasi

Copy link
Copy Markdown
Collaborator

Problem solved by the commit

https://jira.xilinx.com/browse/CR-1276107 Legacy ctx_list cleanup did not cover xrt::hw_context apps. Add zocl_fini_client_hw_ctxs() in zocl_destroy_client().

Bug / issue (if any) fixed, which PR introduced the bug, how it was discovered

When a host application using the xrt::hw_context API exits on a DFX platform, the hw_context / xclbin is not fully released. Slot 0 remains in-use, so a subsequent run without reboot fails with [drm:zocl_xclbin_read_axlf [zocl]] ERROR Current xclbin is in-use, can't change

How problem was solved, alternative solutions (if any) and why they were rejected

Added zocl_fini_client_hw_ctxs() in zocl_kds.c and call it from zocl_destroy_client() before kds_fini_client(). On client exit this function:

  1. Calls kds_fini_hw_ctx_client() for each entry in client->hw_ctx_list
  2. Cleans up associated AIE graph contexts
  3. Calls kds_free_hw_ctx() to release the hw_context
  4. Unlocks the slot bitstream via zocl_unlock_bitstream() when appropriate
  5. Decrements slot->hwctx_ref_cnt and tears down AIE state when the last reference is dropped

Risks (if any) associated the changes in the commit

low

What has been tested and how, request additional testing if necessary

Tested on vck190 hw.

Documentation impact (if any)

NA

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an edge-driver cleanup gap where applications using xrt::hw_context could exit without fully releasing the slot/xclbin on DFX platforms, leaving the bitstream marked “in-use” and preventing subsequent runs from reloading a new xclbin without reboot.

Changes:

  • Add a zocl_fini_client_hw_ctxs() teardown path to release per-client hw_ctx_list resources on client exit.
  • Invoke the new hw_context teardown from zocl_destroy_client() prior to kds_fini_client().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/runtime_src/core/edge/drm/zocl/common/zocl_kds.c
Signed-off-by: Takasi, Manoj <Manoj.Takasi@amd.com>
@ManojTakasi
ManojTakasi force-pushed the petalinux-xrt-v2026.2_06161249 branch from fd248f3 to e6e3d88 Compare August 5, 2026 11:08
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@chvamshi-xilinx
chvamshi-xilinx merged commit fd8b900 into Xilinx:master Aug 5, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants