drivers/accel/habanalabs/common/hldio.h
Source file repositories/reference/linux-study-clean/drivers/accel/habanalabs/common/hldio.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/accel/habanalabs/common/hldio.h- Extension
.h- Size
- 4572 bytes
- Lines
- 147
- Domain
- Driver Families
- Bucket
- drivers/accel
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/fs.hlinux/seq_file.hlinux/ktime.hlinux/delay.hlinux/kernel.hlinux/errno.h
Detected Declarations
struct hl_devicestruct filestruct hl_p2p_regionstruct hl_dio_statsstruct hl_diostruct hl_p2p_regionfunction hl_hldio_debugfs_initfunction hl_dio_ssd2hlfunction hl_p2p_region_fini_allfunction hl_dio_startfunction hl_dio_stopfunction hl_hldio_finifunction hl_hldio_debugfs_initfunction hl_device_supports_nvme
Annotated Snippet
struct hl_p2p_region {
struct page **p2ppages;
void *p2pmem;
u64 device_pa;
u64 bar_offset;
u64 size;
int bar;
};
/**
* struct hl_dio_stats - Direct I/O statistics
* @total_ops: total number of operations attempted
* @successful_ops: number of successful operations
* @failed_ops: number of failed operations
* @bytes_transferred: total bytes successfully transferred
* @last_len_read: length of the last read operation
*/
struct hl_dio_stats {
u64 total_ops;
u64 successful_ops;
u64 failed_ops;
u64 bytes_transferred;
size_t last_len_read;
};
/**
* struct hl_dio - describes habanalabs direct storage interaction interface
* @p2prs: array of p2p regions
* @inflight_ios: percpu counter for inflight ios
* @np2prs: number of elements in p2prs
* @io_enabled: 1 if io is enabled 0 otherwise
*/
struct hl_dio {
struct hl_p2p_region *p2prs;
s64 __percpu *inflight_ios;
u8 np2prs;
u8 io_enabled;
};
int hl_dio_ssd2hl(struct hl_device *hdev, struct hl_ctx *ctx, int fd,
u64 device_va, off_t off_bytes, size_t len_bytes,
size_t *len_read);
void hl_p2p_region_fini_all(struct hl_device *hdev);
int hl_p2p_region_init(struct hl_device *hdev, struct hl_p2p_region *p2pr);
int hl_dio_start(struct hl_device *hdev);
void hl_dio_stop(struct hl_device *hdev);
/* Init/teardown */
int hl_hldio_init(struct hl_device *hdev);
void hl_hldio_fini(struct hl_device *hdev);
/* File operations */
long hl_hldio_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
/* DebugFS hooks */
#ifdef CONFIG_DEBUG_FS
void hl_hldio_debugfs_init(struct hl_device *hdev);
void hl_hldio_debugfs_fini(struct hl_device *hdev);
#else
static inline void hl_hldio_debugfs_init(struct hl_device *hdev) { }
static inline void hl_hldio_debugfs_fini(struct hl_device *hdev) { }
#endif
#else /* !CONFIG_HL_HLDIO */
struct hl_p2p_region;
/* Stubs when HLDIO is disabled */
static inline int hl_dio_ssd2hl(struct hl_device *hdev, struct hl_ctx *ctx, int fd,
u64 device_va, off_t off_bytes, size_t len_bytes,
size_t *len_read)
{ return -EOPNOTSUPP; }
static inline void hl_p2p_region_fini_all(struct hl_device *hdev) {}
static inline int hl_p2p_region_init(struct hl_device *hdev, struct hl_p2p_region *p2pr)
{ return -EOPNOTSUPP; }
static inline int hl_dio_start(struct hl_device *hdev) { return -EOPNOTSUPP; }
static inline void hl_dio_stop(struct hl_device *hdev) {}
static inline int hl_hldio_init(struct hl_device *hdev) { return 0; }
static inline void hl_hldio_fini(struct hl_device *hdev) { }
static inline long hl_hldio_ioctl(struct file *f, unsigned int c,
unsigned long a)
{ return -ENOTTY; }
static inline void hl_hldio_debugfs_init(struct hl_device *hdev) { }
static inline void hl_hldio_debugfs_fini(struct hl_device *hdev) { }
#endif /* CONFIG_HL_HLDIO */
/* Simplified polling macro for HLDIO (no simulator support) */
#define hl_poll_timeout_condition(hdev, cond, sleep_us, timeout_us) \
({ \
Annotation
- Immediate include surface: `linux/types.h`, `linux/fs.h`, `linux/seq_file.h`, `linux/ktime.h`, `linux/delay.h`, `linux/kernel.h`, `linux/errno.h`.
- Detected declarations: `struct hl_device`, `struct file`, `struct hl_p2p_region`, `struct hl_dio_stats`, `struct hl_dio`, `struct hl_p2p_region`, `function hl_hldio_debugfs_init`, `function hl_dio_ssd2hl`, `function hl_p2p_region_fini_all`, `function hl_dio_start`.
- Atlas domain: Driver Families / drivers/accel.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.