Commit 841cd2d7 authored by Ofir Bitton's avatar Ofir Bitton Committed by Oded Gabbay
Browse files

habanalabs/gaudi2: add PCI revision 2 support



Add support for Gaudi2 Device with PCI revision 2.
Functionality is exactly the same as revision 1, the only difference
is device name exposed to user.

Signed-off-by: default avatarOfir Bitton <obitton@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent 30620698
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -748,6 +748,10 @@ static int device_early_init(struct hl_device *hdev)
		gaudi2_set_asic_funcs(hdev);
		strscpy(hdev->asic_name, "GAUDI2", sizeof(hdev->asic_name));
		break;
	case ASIC_GAUDI2B:
		gaudi2_set_asic_funcs(hdev);
		strscpy(hdev->asic_name, "GAUDI2B", sizeof(hdev->asic_name));
		break;
		break;
	default:
		dev_err(hdev->dev, "Unrecognized ASIC type %d\n",
+2 −0
Original line number Diff line number Diff line
@@ -1192,6 +1192,7 @@ struct hl_dec {
 * @ASIC_GAUDI: Gaudi device (HL-2000).
 * @ASIC_GAUDI_SEC: Gaudi secured device (HL-2000).
 * @ASIC_GAUDI2: Gaudi2 device.
 * @ASIC_GAUDI2B: Gaudi2B device.
 */
enum hl_asic_type {
	ASIC_INVALID,
@@ -1199,6 +1200,7 @@ enum hl_asic_type {
	ASIC_GAUDI,
	ASIC_GAUDI_SEC,
	ASIC_GAUDI2,
	ASIC_GAUDI2B,
};

struct hl_cs_parser;
+18 −8
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#define pr_fmt(fmt)		"habanalabs: " fmt

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

#include <linux/pci.h>
#include <linux/aer.h>
@@ -74,16 +75,17 @@ MODULE_DEVICE_TABLE(pci, ids);
/*
 * get_asic_type - translate device id to asic type
 *
 * @device: id of the PCI device
 * @hdev: pointer to habanalabs device structure.
 *
 * Translate device id to asic type.
 * Translate device id and revision id to asic type.
 * In case of unidentified device, return -1
 */
static enum hl_asic_type get_asic_type(u16 device)
static enum hl_asic_type get_asic_type(struct hl_device *hdev)
{
	enum hl_asic_type asic_type;
	struct pci_dev *pdev = hdev->pdev;
	enum hl_asic_type asic_type = ASIC_INVALID;

	switch (device) {
	switch (pdev->device) {
	case PCI_IDS_GOYA:
		asic_type = ASIC_GOYA;
		break;
@@ -94,10 +96,18 @@ static enum hl_asic_type get_asic_type(u16 device)
		asic_type = ASIC_GAUDI_SEC;
		break;
	case PCI_IDS_GAUDI2:
		switch (pdev->revision) {
		case REV_ID_A:
			asic_type = ASIC_GAUDI2;
			break;
		case REV_ID_B:
			asic_type = ASIC_GAUDI2B;
			break;
		default:
			break;
		}
		break;
	default:
		asic_type = ASIC_INVALID;
		break;
	}

@@ -416,7 +426,7 @@ static int create_hdev(struct hl_device **dev, struct pci_dev *pdev)
	/* First, we must find out which ASIC are we handling. This is needed
	 * to configure the behavior of the driver (kernel parameters)
	 */
	hdev->asic_type = get_asic_type(pdev->device);
	hdev->asic_type = get_asic_type(hdev);
	if (hdev->asic_type == ASIC_INVALID) {
		dev_err(&pdev->dev, "Unsupported ASIC\n");
		rc = -ENODEV;
+4 −2
Original line number Diff line number Diff line
@@ -10,10 +10,11 @@
#include <uapi/misc/habanalabs.h>
#include "habanalabs.h"

#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/vmalloc.h>

static u32 hl_debug_struct_size[HL_DEBUG_OP_TIMESTAMP + 1] = {
@@ -105,6 +106,7 @@ static int hw_ip_info(struct hl_device *hdev, struct hl_info_args *args)
	hw_ip.edma_enabled_mask = prop->edma_enabled_mask;
	hw_ip.server_type = prop->server_type;
	hw_ip.security_enabled = prop->fw_security_enabled;
	hw_ip.revision_id = hdev->pdev->revision;

	return copy_to_user(out, &hw_ip,
		min((size_t) size, sizeof(hw_ip))) ? -EFAULT : 0;
+1 −0
Original line number Diff line number Diff line
@@ -635,6 +635,7 @@ int hl_mmu_if_set_funcs(struct hl_device *hdev)
		hl_mmu_v1_set_funcs(hdev, &hdev->mmu_func[MMU_DR_PGT]);
		break;
	case ASIC_GAUDI2:
	case ASIC_GAUDI2B:
		/* MMUs in Gaudi2 are always host resident */
		hl_mmu_v2_hr_set_funcs(hdev, &hdev->mmu_func[MMU_HR_PGT]);
		break;
Loading