Skip to content

Commit 8cbacc9

Browse files
ksinyukKobyElbaz
authored andcommitted
accel/habanalabs: add NVMe Direct I/O (HLDIO) infrastructure
Introduce NVMe Direct I/O (HLDIO) infrastructure to support peer‑to‑peer DMA in the habanalabs driver. This adds internal helpers and data structures to enable direct transfers between NVMe storage and device memory. The feature is built only when CONFIG_HL_HLDIO is enabled. A debugfs interface is also provided for functional validation. Signed-off-by: Konstantin Sinyuk <[email protected]> Reviewed-by: Farah Kassabri <[email protected]> Reviewed-by: Koby Elbaz <[email protected]> Signed-off-by: Koby Elbaz <[email protected]>
1 parent 513024d commit 8cbacc9

File tree

6 files changed

+624
-2
lines changed

6 files changed

+624
-2
lines changed

drivers/accel/habanalabs/Kconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,26 @@ config DRM_ACCEL_HABANALABS
2727

2828
To compile this driver as a module, choose M here: the
2929
module will be called habanalabs.
30+
31+
if DRM_ACCEL_HABANALABS
32+
33+
config HL_HLDIO
34+
bool "Habanalabs NVMe Direct I/O (HLDIO)"
35+
depends on PCI_P2PDMA
36+
depends on BLOCK
37+
help
38+
Enable NVMe peer-to-peer direct I/O support for Habanalabs AI
39+
accelerators.
40+
41+
This allows direct data transfers between NVMe storage devices
42+
and Habanalabs accelerators without involving system memory,
43+
using PCI peer-to-peer DMA capabilities.
44+
45+
Requirements:
46+
- CONFIG_PCI_P2PDMA=y
47+
- NVMe device and Habanalabs accelerator under same PCI root complex
48+
- IOMMU disabled or in passthrough mode
49+
- Hardware supporting PCI P2P DMA
50+
51+
If unsure, say N
52+
endif # DRM_ACCEL_HABANALABS

drivers/accel/habanalabs/common/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ HL_COMMON_FILES := common/habanalabs_drv.o common/device.o common/context.o \
1313
common/command_submission.o common/firmware_if.o \
1414
common/security.o common/state_dump.o \
1515
common/memory_mgr.o common/decoder.o
16+
17+
# Conditionally add HLDIO support
18+
ifdef CONFIG_HL_HLDIO
19+
HL_COMMON_FILES += common/hldio.o
20+
endif

drivers/accel/habanalabs/common/debugfs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,7 @@ void hl_debugfs_device_fini(struct hl_device *hdev)
18911891
vfree(entry->state_dump[i]);
18921892

18931893
kfree(entry->entry_arr);
1894+
18941895
}
18951896

18961897
void hl_debugfs_add_device(struct hl_device *hdev)
@@ -1903,6 +1904,7 @@ void hl_debugfs_add_device(struct hl_device *hdev)
19031904

19041905
if (!hdev->asic_prop.fw_security_enabled)
19051906
add_secured_nodes(dev_entry, dev_entry->root);
1907+
19061908
}
19071909

19081910
void hl_debugfs_add_file(struct hl_fpriv *hpriv)
@@ -2035,3 +2037,4 @@ void hl_debugfs_set_state_dump(struct hl_device *hdev, char *data,
20352037

20362038
up_write(&dev_entry->state_dump_sem);
20372039
}
2040+

drivers/accel/habanalabs/common/habanalabs.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ struct hl_hints_range {
704704
* @supports_advanced_cpucp_rc: true if new cpucp opcodes are supported.
705705
* @supports_engine_modes: true if changing engines/engine_cores modes is supported.
706706
* @support_dynamic_resereved_fw_size: true if we support dynamic reserved size for fw.
707+
* @supports_nvme: indicates whether the asic supports NVMe P2P DMA.
707708
*/
708709
struct asic_fixed_properties {
709710
struct hw_queue_properties *hw_queues_props;
@@ -824,6 +825,7 @@ struct asic_fixed_properties {
824825
u8 supports_advanced_cpucp_rc;
825826
u8 supports_engine_modes;
826827
u8 support_dynamic_resereved_fw_size;
828+
u8 supports_nvme;
827829
};
828830

829831
/**
@@ -2276,6 +2278,9 @@ struct hl_vm {
22762278
u8 init_done;
22772279
};
22782280

2281+
#ifdef CONFIG_HL_HLDIO
2282+
#include "hldio.h"
2283+
#endif
22792284

22802285
/*
22812286
* DEBUG, PROFILING STRUCTURE
@@ -2346,7 +2351,6 @@ struct hl_fpriv {
23462351
struct mutex ctx_lock;
23472352
};
23482353

2349-
23502354
/*
23512355
* DebugFS
23522356
*/
@@ -2374,6 +2378,7 @@ struct hl_debugfs_entry {
23742378
struct hl_dbg_device_entry *dev_entry;
23752379
};
23762380

2381+
23772382
/**
23782383
* struct hl_dbg_device_entry - ASIC specific debugfs manager.
23792384
* @root: root dentry.
@@ -3334,6 +3339,7 @@ struct eq_heartbeat_debug_info {
33343339
* @captured_err_info: holds information about errors.
33353340
* @reset_info: holds current device reset information.
33363341
* @heartbeat_debug_info: counters used to debug heartbeat failures.
3342+
* @hldio: describes habanalabs direct storage interaction interface.
33373343
* @irq_affinity_mask: mask of available CPU cores for user and decoder interrupt handling.
33383344
* @stream_master_qid_arr: pointer to array with QIDs of master streams.
33393345
* @fw_inner_major_ver: the major of current loaded preboot inner version.
@@ -3527,7 +3533,9 @@ struct hl_device {
35273533
struct hl_reset_info reset_info;
35283534

35293535
struct eq_heartbeat_debug_info heartbeat_debug_info;
3530-
3536+
#ifdef CONFIG_HL_HLDIO
3537+
struct hl_dio hldio;
3538+
#endif
35313539
cpumask_t irq_affinity_mask;
35323540

35333541
u32 *stream_master_qid_arr;

0 commit comments

Comments
 (0)