linux/drivers/accel/habanalabs/common/habanalabs_drv.c

// SPDX-License-Identifier: GPL-2.0

/*
 * Copyright 2016-2021 HabanaLabs, Ltd.
 * All Rights Reserved.
 *
 */

#define pr_fmt(fmt)

#include "habanalabs.h"
#include "../include/hw_ip/pci/pci_general.h"

#include <linux/pci.h>
#include <linux/module.h>
#include <linux/vmalloc.h>
#include <linux/version.h>

#include <drm/drm_accel.h>
#include <drm/drm_drv.h>
#include <drm/drm_ioctl.h>

#define CREATE_TRACE_POINTS
#include <trace/events/habanalabs.h>

#define HL_DRIVER_AUTHOR

#define HL_DRIVER_DESC

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

static int hl_major;
static DEFINE_IDR(hl_devs_idr);
static DEFINE_MUTEX(hl_devs_idr_lock);

#define HL_DEFAULT_TIMEOUT_LOCKED
#define GAUDI_DEFAULT_TIMEOUT_LOCKED

static int timeout_locked =;
static int reset_on_lockup =;
static int memory_scrub;
static ulong boot_error_status_mask =;

module_param(timeout_locked, int, 0444);
MODULE_PARM_DESC();

module_param(reset_on_lockup, int, 0444);
MODULE_PARM_DESC();

module_param(memory_scrub, int, 0444);
MODULE_PARM_DESC();

module_param(boot_error_status_mask, ulong, 0444);
MODULE_PARM_DESC();

#define PCI_IDS_GOYA
#define PCI_IDS_GAUDI
#define PCI_IDS_GAUDI_SEC

#define PCI_IDS_GAUDI2

static const struct pci_device_id ids[] =;
MODULE_DEVICE_TABLE(pci, ids);

static const struct drm_ioctl_desc hl_drm_ioctls[] =;

static const struct file_operations hl_fops =;

static const struct drm_driver hl_driver =;

/*
 * get_asic_type - translate device id to asic type
 *
 * @hdev: pointer to habanalabs device structure.
 *
 * Translate device id and revision id to asic type.
 * In case of unidentified device, return -1
 */
static enum hl_asic_type get_asic_type(struct hl_device *hdev)
{}

static bool is_asic_secured(enum hl_asic_type asic_type)
{}

/*
 * hl_device_open() - open function for habanalabs device.
 * @ddev: pointer to DRM device structure.
 * @file: pointer to DRM file private data structure.
 *
 * Called when process opens an habanalabs device.
 */
int hl_device_open(struct drm_device *ddev, struct drm_file *file_priv)
{}

int hl_device_open_ctrl(struct inode *inode, struct file *filp)
{}

static void set_driver_behavior_per_device(struct hl_device *hdev)
{}

static void copy_kernel_module_params_to_device(struct hl_device *hdev)
{}

static void fixup_device_params_per_asic(struct hl_device *hdev, int timeout)
{}

static int fixup_device_params(struct hl_device *hdev)
{}

static int allocate_device_id(struct hl_device *hdev)
{}

/**
 * create_hdev - create habanalabs device instance
 *
 * @dev: will hold the pointer to the new habanalabs device structure
 * @pdev: pointer to the pci device
 *
 * Allocate memory for habanalabs device and initialize basic fields
 * Identify the ASIC type
 * Allocate ID (minor) for the device (only for real devices)
 */
static int create_hdev(struct hl_device **dev, struct pci_dev *pdev)
{}

/*
 * destroy_hdev - destroy habanalabs device instance
 *
 * @dev: pointer to the habanalabs device structure
 *
 */
static void destroy_hdev(struct hl_device *hdev)
{}

static int hl_pmops_suspend(struct device *dev)
{}

static int hl_pmops_resume(struct device *dev)
{}

/**
 * hl_pci_probe - probe PCI habanalabs devices
 *
 * @pdev: pointer to pci device
 * @id: pointer to pci device id structure
 *
 * Standard PCI probe function for habanalabs device.
 * Create a new habanalabs device and initialize it according to the
 * device's type
 */
static int hl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{}

/*
 * hl_pci_remove - remove PCI habanalabs devices
 *
 * @pdev: pointer to pci device
 *
 * Standard PCI remove function for habanalabs device
 */
static void hl_pci_remove(struct pci_dev *pdev)
{}

/**
 * hl_pci_err_detected - a PCI bus error detected on this device
 *
 * @pdev: pointer to pci device
 * @state: PCI error type
 *
 * Called by the PCI subsystem whenever a non-correctable
 * PCI bus error is detected
 */
static pci_ers_result_t
hl_pci_err_detected(struct pci_dev *pdev, pci_channel_state_t state)
{}

/**
 * hl_pci_err_resume - resume after a PCI slot reset
 *
 * @pdev: pointer to pci device
 *
 */
static void hl_pci_err_resume(struct pci_dev *pdev)
{}

/**
 * hl_pci_err_slot_reset - a PCI slot reset has just happened
 *
 * @pdev: pointer to pci device
 *
 * Determine if the driver can recover from the PCI slot reset
 */
static pci_ers_result_t hl_pci_err_slot_reset(struct pci_dev *pdev)
{}

static void hl_pci_reset_prepare(struct pci_dev *pdev)
{}

static void hl_pci_reset_done(struct pci_dev *pdev)
{}

static const struct dev_pm_ops hl_pm_ops =;

static const struct pci_error_handlers hl_pci_err_handler =;

static struct pci_driver hl_pci_driver =;

/*
 * hl_init - Initialize the habanalabs kernel driver
 */
static int __init hl_init(void)
{}

/*
 * hl_exit - Release all resources of the habanalabs kernel driver
 */
static void __exit hl_exit(void)
{}

module_init();
module_exit(hl_exit);