Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLB resource management #43

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

joelsmithTT
Copy link
Contributor

Introduce TLB resource management to KMD.

https://tenstorrent.atlassian.net/wiki/spaces/syseng/pages/537100642/Inbound+PCIe+TLBs

Key features:

  • TLB window allocation: ioctl interface for allocating windows of specific sizes
  • TLB window configuration: ioctl interface for configuring TLB windows with NOC routing parameters
  • TLB window mapping: mmap interface for mapping windows to userspace with either UC or WC caching attributes

Implementation details:

  • Core management interfaces in tlb.h / tlb.c
  • Extended device class structure with TLB specific capabilities
  • Extended memory mapping logic to support TLB windows
  • Added support for Blackhole (Wormhole/Grayskull are not implemented)

Future work:

  • Wormhole support
  • Check NOC window parameters for validity

This is the first part of moving TLB window management into the driver.
Add the necessary interfaces and data structures for TLB window
allocation, configuration, and ownership tracking:

- Add bitmap and refcount tracking in chardev_private for per-fd TLB
  ownership
- Define new IOCTLs for TLB allocation, freeing, and configuration
- Add TLB management callback interfaces to device class
- Add tlb.h
Implement the TLB management interfaces introduced in the previous
commit:

- Add TLB allocation logic using bitmap tracking at the device level
- Add TLB allocation, freeing, and configuration IOCTL handlers
- Add cleanup of TLBs on file descriptor close
- Extend mmap offset space to accommodate TLB windows
- Add tlb.c implementing core TLB management functions

The allocation strategy supports multiple TLB kinds of different sizes,
selecting the smallest TLB that can accommodate the requested size.  The
actual TLB configuration is delegated to device-specific implementations
via the device class callbacks.
Implement memory mapping support for TLB windows:

- Add map_tlb_window function to handle TLB-specific mmap requests
- Add vma_close() handler to track TLB mapping reference counts
- Wire up TLB window mapping in tenstorrent_mmap()

The implementation uses reference counting to track active mappings of
each TLB window, ensuring we don't free TLBs that are still mapped into
user address spaces.  Window mappings are backed by PCI BAR regions.
- Support both 2M and 4G window sizes
- Add separate configuration handlers for each size
- Add TLB descriptor implementation
- Convert kernel TLB window usage to new interface

The Blackhole chip provides 202 2M windows and 8 4G windows, mapped
through BAR0 and BAR4 respectively.
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.

1 participant