#define pr_fmt(fmt) …
#include <uapi/drm/habanalabs_accel.h>
#include "habanalabs.h"
#include <linux/pci.h>
#include <linux/hwmon.h>
#include <linux/vmalloc.h>
#include <drm/drm_accel.h>
#include <drm/drm_drv.h>
#include <trace/events/habanalabs.h>
#define HL_RESET_DELAY_USEC …
#define HL_DEVICE_RELEASE_WATCHDOG_TIMEOUT_SEC …
enum dma_alloc_type { … };
#define MEM_SCRUB_DEFAULT_VAL …
static void hl_device_heartbeat(struct work_struct *work);
static u64 hl_set_dram_bar(struct hl_device *hdev, u64 addr, struct pci_mem_region *region,
u64 *new_bar_region_base)
{ … }
int hl_access_sram_dram_region(struct hl_device *hdev, u64 addr, u64 *val,
enum debugfs_access_type acc_type, enum pci_region region_type, bool set_dram_bar)
{ … }
static void *hl_dma_alloc_common(struct hl_device *hdev, size_t size, dma_addr_t *dma_handle,
gfp_t flag, enum dma_alloc_type alloc_type,
const char *caller)
{ … }
static void hl_asic_dma_free_common(struct hl_device *hdev, size_t size, void *cpu_addr,
dma_addr_t dma_handle, enum dma_alloc_type alloc_type,
const char *caller)
{ … }
void *hl_asic_dma_alloc_coherent_caller(struct hl_device *hdev, size_t size, dma_addr_t *dma_handle,
gfp_t flag, const char *caller)
{ … }
void hl_asic_dma_free_coherent_caller(struct hl_device *hdev, size_t size, void *cpu_addr,
dma_addr_t dma_handle, const char *caller)
{ … }
void *hl_asic_dma_pool_zalloc_caller(struct hl_device *hdev, size_t size, gfp_t mem_flags,
dma_addr_t *dma_handle, const char *caller)
{ … }
void hl_asic_dma_pool_free_caller(struct hl_device *hdev, void *vaddr, dma_addr_t dma_addr,
const char *caller)
{ … }
void *hl_cpu_accessible_dma_pool_alloc(struct hl_device *hdev, size_t size, dma_addr_t *dma_handle)
{ … }
void hl_cpu_accessible_dma_pool_free(struct hl_device *hdev, size_t size, void *vaddr)
{ … }
int hl_dma_map_sgtable_caller(struct hl_device *hdev, struct sg_table *sgt,
enum dma_data_direction dir, const char *caller)
{ … }
int hl_asic_dma_map_sgtable(struct hl_device *hdev, struct sg_table *sgt,
enum dma_data_direction dir)
{ … }
void hl_dma_unmap_sgtable_caller(struct hl_device *hdev, struct sg_table *sgt,
enum dma_data_direction dir, const char *caller)
{ … }
void hl_asic_dma_unmap_sgtable(struct hl_device *hdev, struct sg_table *sgt,
enum dma_data_direction dir)
{ … }
int hl_access_cfg_region(struct hl_device *hdev, u64 addr, u64 *val,
enum debugfs_access_type acc_type)
{ … }
int hl_access_dev_mem(struct hl_device *hdev, enum pci_region region_type,
u64 addr, u64 *val, enum debugfs_access_type acc_type)
{ … }
void hl_engine_data_sprintf(struct engines_data *e, const char *fmt, ...)
{ … }
enum hl_device_status hl_device_status(struct hl_device *hdev)
{ … }
bool hl_device_operational(struct hl_device *hdev,
enum hl_device_status *status)
{ … }
bool hl_ctrl_device_operational(struct hl_device *hdev,
enum hl_device_status *status)
{ … }
static void print_idle_status_mask(struct hl_device *hdev, const char *message,
u64 idle_mask[HL_BUSY_ENGINES_MASK_EXT_SIZE])
{ … }
static void hpriv_release(struct kref *ref)
{ … }
void hl_hpriv_get(struct hl_fpriv *hpriv)
{ … }
int hl_hpriv_put(struct hl_fpriv *hpriv)
{ … }
static void print_device_in_use_info(struct hl_device *hdev,
struct hl_mem_mgr_fini_stats *mm_fini_stats, const char *message)
{ … }
void hl_device_release(struct drm_device *ddev, struct drm_file *file_priv)
{ … }
static int hl_device_release_ctrl(struct inode *inode, struct file *filp)
{ … }
static int __hl_mmap(struct hl_fpriv *hpriv, struct vm_area_struct *vma)
{ … }
int hl_mmap(struct file *filp, struct vm_area_struct *vma)
{ … }
static const struct file_operations hl_ctrl_ops = …;
static void device_release_func(struct device *dev)
{ … }
static int device_init_cdev(struct hl_device *hdev, const struct class *class,
int minor, const struct file_operations *fops,
char *name, struct cdev *cdev,
struct device **dev)
{ … }
static int cdev_sysfs_debugfs_add(struct hl_device *hdev)
{ … }
static void cdev_sysfs_debugfs_remove(struct hl_device *hdev)
{ … }
static void device_hard_reset_pending(struct work_struct *work)
{ … }
static void device_release_watchdog_func(struct work_struct *work)
{ … }
static int device_early_init(struct hl_device *hdev)
{ … }
static void device_early_fini(struct hl_device *hdev)
{ … }
static bool is_pci_link_healthy(struct hl_device *hdev)
{ … }
static void stringify_time_of_last_heartbeat(struct hl_device *hdev, char *time_str, size_t size,
bool is_pq_hb)
{ … }
static bool hl_device_eq_heartbeat_received(struct hl_device *hdev)
{ … }
static void hl_device_heartbeat(struct work_struct *work)
{ … }
static int device_late_init(struct hl_device *hdev)
{ … }
static void device_late_fini(struct hl_device *hdev)
{ … }
int hl_device_utilization(struct hl_device *hdev, u32 *utilization)
{ … }
int hl_device_set_debug_mode(struct hl_device *hdev, struct hl_ctx *ctx, bool enable)
{ … }
static void take_release_locks(struct hl_device *hdev)
{ … }
static void hl_abort_waiting_for_completions(struct hl_device *hdev)
{ … }
static void cleanup_resources(struct hl_device *hdev, bool hard_reset, bool fw_reset,
bool skip_wq_flush)
{ … }
int hl_device_suspend(struct hl_device *hdev)
{ … }
int hl_device_resume(struct hl_device *hdev)
{ … }
static int device_kill_open_processes(struct hl_device *hdev, u32 timeout, bool control_dev)
{ … }
static void device_disable_open_processes(struct hl_device *hdev, bool control_dev)
{ … }
static void send_disable_pci_access(struct hl_device *hdev, u32 flags)
{ … }
static void handle_reset_trigger(struct hl_device *hdev, u32 flags)
{ … }
static void reset_heartbeat_debug_info(struct hl_device *hdev)
{ … }
static inline void device_heartbeat_schedule(struct hl_device *hdev)
{ … }
int hl_device_reset(struct hl_device *hdev, u32 flags)
{ … }
int hl_device_cond_reset(struct hl_device *hdev, u32 flags, u64 event_mask)
{ … }
static void hl_notifier_event_send(struct hl_notifier_event *notifier_event, u64 event_mask)
{ … }
void hl_notifier_event_send_all(struct hl_device *hdev, u64 event_mask)
{ … }
int hl_device_init(struct hl_device *hdev)
{ … }
void hl_device_fini(struct hl_device *hdev)
{ … }
inline u32 hl_rreg(struct hl_device *hdev, u32 reg)
{ … }
inline void hl_wreg(struct hl_device *hdev, u32 reg, u32 val)
{ … }
void hl_capture_razwi(struct hl_device *hdev, u64 addr, u16 *engine_id, u16 num_of_engines,
u8 flags)
{ … }
void hl_handle_razwi(struct hl_device *hdev, u64 addr, u16 *engine_id, u16 num_of_engines,
u8 flags, u64 *event_mask)
{ … }
static void hl_capture_user_mappings(struct hl_device *hdev, bool is_pmmu)
{ … }
void hl_capture_page_fault(struct hl_device *hdev, u64 addr, u16 eng_id, bool is_pmmu)
{ … }
void hl_handle_page_fault(struct hl_device *hdev, u64 addr, u16 eng_id, bool is_pmmu,
u64 *event_mask)
{ … }
static void hl_capture_hw_err(struct hl_device *hdev, u16 event_id)
{ … }
void hl_handle_critical_hw_err(struct hl_device *hdev, u16 event_id, u64 *event_mask)
{ … }
static void hl_capture_fw_err(struct hl_device *hdev, struct hl_info_fw_err_info *fw_info)
{ … }
void hl_handle_fw_err(struct hl_device *hdev, struct hl_info_fw_err_info *info)
{ … }
void hl_capture_engine_err(struct hl_device *hdev, u16 engine_id, u16 error_count)
{ … }
void hl_enable_err_info_capture(struct hl_error_info *captured_err_info)
{ … }
void hl_init_cpu_for_irq(struct hl_device *hdev)
{ … }
void hl_set_irq_affinity(struct hl_device *hdev, int irq)
{ … }
void hl_eq_heartbeat_event_handle(struct hl_device *hdev)
{ … }
void hl_handle_clk_change_event(struct hl_device *hdev, u16 event_type, u64 *event_mask)
{ … }