Commit 839c4803 authored by Oded Gabbay's avatar Oded Gabbay Committed by Greg Kroah-Hartman

habanalabs: add basic Goya h/w initialization

This patch adds the basic part of Goya's H/W initialization. It adds code
that initializes Goya's internal CPU, various registers that are related to
internal routing, scrambling, workarounds for H/W bugs, etc.

It also initializes Goya's security scheme that prevents the user from
abusing Goya to steal data from the host, crash the host, change
Goya's F/W, etc.
Reviewed-by: default avatarMike Rapoport <rppt@linux.ibm.com>
Signed-off-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent be5d926b
......@@ -319,6 +319,15 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass)
goto release_ctx;
}
rc = hdev->asic_funcs->hw_init(hdev);
if (rc) {
dev_err(hdev->dev, "failed to initialize the H/W\n");
rc = 0;
goto out_disabled;
}
hdev->disabled = false;
dev_notice(hdev->dev,
"Successfully added device to habanalabs driver\n");
......@@ -370,6 +379,9 @@ void hl_device_fini(struct hl_device *hdev)
if ((hdev->kernel_ctx) && (hl_ctx_put(hdev->kernel_ctx) != 1))
dev_err(hdev->dev, "kernel ctx is still alive\n");
/* Reset the H/W. It will be in idle state after this returns */
hdev->asic_funcs->hw_fini(hdev, true);
/* Call ASIC S/W finalize function */
hdev->asic_funcs->sw_fini(hdev);
......
subdir-ccflags-y += -I$(src)
HL_GOYA_FILES := goya/goya.o
HL_GOYA_FILES := goya/goya.o goya/goya_security.o
This diff is collapsed.
......@@ -10,7 +10,9 @@
#include <uapi/misc/habanalabs.h>
#include "habanalabs.h"
#include "include/hl_boot_if.h"
#include "include/goya/goya.h"
#include "include/goya/goya_fw_if.h"
#define NUMBER_OF_CMPLT_QUEUES 5
#define NUMBER_OF_EXT_HW_QUEUES 5
......@@ -149,4 +151,6 @@ struct goya_device {
u32 hw_cap_initialized;
};
void goya_init_security(struct hl_device *hdev);
#endif /* GOYAP_H_ */
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -8,14 +8,19 @@
#ifndef HABANALABSP_H_
#define HABANALABSP_H_
#include "include/armcp_if.h"
#define pr_fmt(fmt) "habanalabs: " fmt
#include <linux/cdev.h>
#include <linux/iopoll.h>
#define HL_NAME "habanalabs"
#define HL_MMAP_CB_MASK (0x8000000000000000ull >> PAGE_SHIFT)
#define HL_DEVICE_TIMEOUT_USEC 1000000 /* 1 s */
#define HL_MAX_QUEUES 128
struct hl_device;
......@@ -24,6 +29,8 @@ struct hl_fpriv;
/**
* struct asic_fixed_properties - ASIC specific immutable properties.
* @uboot_ver: F/W U-boot version.
* @preboot_ver: F/W Preboot version.
* @sram_base_address: SRAM physical start address.
* @sram_end_address: SRAM physical end address.
* @sram_user_base_address - SRAM physical start address for user access.
......@@ -52,6 +59,8 @@ struct hl_fpriv;
* @tpc_enabled_mask: which TPCs are enabled.
*/
struct asic_fixed_properties {
char uboot_ver[VERSION_MAX_LEN];
char preboot_ver[VERSION_MAX_LEN];
u64 sram_base_address;
u64 sram_end_address;
u64 sram_user_base_address;
......@@ -149,6 +158,8 @@ enum hl_asic_type {
* @early_fini: tears down what was done in early_init.
* @sw_init: sets up driver state, does not configure H/W.
* @sw_fini: tears down driver state, does not configure H/W.
* @hw_init: sets up the H/W state.
* @hw_fini: tears down the H/W state.
* @suspend: handles IP specific H/W or SW changes for suspend.
* @resume: handles IP specific H/W or SW changes for resume.
* @mmap: mmap function, does nothing.
......@@ -167,6 +178,8 @@ struct hl_asic_funcs {
int (*early_fini)(struct hl_device *hdev);
int (*sw_init)(struct hl_device *hdev);
int (*sw_fini)(struct hl_device *hdev);
int (*hw_init)(struct hl_device *hdev);
void (*hw_fini)(struct hl_device *hdev, bool hard_reset);
int (*suspend)(struct hl_device *hdev);
int (*resume)(struct hl_device *hdev);
int (*mmap)(struct hl_fpriv *hpriv, struct vm_area_struct *vma);
......@@ -343,7 +356,10 @@ struct hl_device {
u8 disabled;
/* Parameters for bring-up */
u8 cpu_enable;
u8 reset_pcilink;
u8 fw_loading;
u8 pldm;
};
......
......@@ -167,7 +167,14 @@ int create_hdev(struct hl_device **dev, struct pci_dev *pdev,
hdev->major = hl_major;
/* Parameters for bring-up - set them to defaults */
hdev->cpu_enable = 1;
hdev->reset_pcilink = 0;
hdev->fw_loading = 1;
hdev->pldm = 0;
/* If CPU is disabled, no point in loading FW */
if (!hdev->cpu_enable)
hdev->fw_loading = 0;
hdev->disabled = true;
hdev->pdev = pdev; /* can be NULL in case of simulator device */
......
/* SPDX-License-Identifier: GPL-2.0
*
* Copyright 2016-2018 HabanaLabs, Ltd.
* All Rights Reserved.
*
*/
#ifndef ARMCP_IF_H
#define ARMCP_IF_H
#include <linux/types.h>
/*
* ArmCP info
*/
#define VERSION_MAX_LEN 128
#endif /* ARMCP_IF_H */
/* SPDX-License-Identifier: GPL-2.0
*
* Copyright 2016-2018 HabanaLabs, Ltd.
* All Rights Reserved.
*
*/
#ifndef GOYA_FW_IF_H
#define GOYA_FW_IF_H
#define CPU_BOOT_ADDR 0x7FF8040000ull
#define UBOOT_FW_OFFSET 0x100000 /* 1MB in SRAM */
#define LINUX_FW_OFFSET 0x800000 /* 8MB in DDR */
enum goya_pll_index {
CPU_PLL = 0,
IC_PLL,
MC_PLL,
MME_PLL,
PCI_PLL,
EMMC_PLL,
TPC_PLL
};
#define GOYA_PLL_FREQ_LOW 50000000 /* 50 MHz */
#endif /* GOYA_FW_IF_H */
/* SPDX-License-Identifier: GPL-2.0
*
* Copyright 2018 HabanaLabs, Ltd.
* All Rights Reserved.
*
*/
#ifndef HL_BOOT_IF_H
#define HL_BOOT_IF_H
enum cpu_boot_status {
CPU_BOOT_STATUS_NA = 0, /* Default value after reset of chip */
CPU_BOOT_STATUS_IN_WFE,
CPU_BOOT_STATUS_DRAM_RDY,
CPU_BOOT_STATUS_SRAM_AVAIL,
CPU_BOOT_STATUS_IN_BTL, /* BTL is H/W FSM */
CPU_BOOT_STATUS_IN_PREBOOT,
CPU_BOOT_STATUS_IN_SPL,
CPU_BOOT_STATUS_IN_UBOOT,
CPU_BOOT_STATUS_DRAM_INIT_FAIL,
CPU_BOOT_STATUS_FIT_CORRUPTED
};
enum kmd_msg {
KMD_MSG_NA = 0,
KMD_MSG_GOTO_WFE,
KMD_MSG_FIT_RDY
};
#endif /* HL_BOOT_IF_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment