drivers/pci/controller/pcie-hisi-error.c

Source file repositories/reference/linux-study-clean/drivers/pci/controller/pcie-hisi-error.c

File Facts

System
Linux kernel
Corpus path
drivers/pci/controller/pcie-hisi-error.c
Extension
.c
Size
8893 bytes
Lines
315
Domain
Representative Device Path
Bucket
PCIe NVMe Storage Path
Inferred role
Representative Device Path: implementation source
Status
source implementation candidate

Why This File Exists

Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.

Dependency Surface

Detected Declarations

Annotated Snippet

struct hisi_pcie_error_data {
	u64	val_bits;
	u8	version;
	u8	soc_id;
	u8	socket_id;
	u8	nimbus_id;
	u8	sub_module_id;
	u8	core_id;
	u8	port_id;
	u8	err_severity;
	u16	err_type;
	u8	reserv[2];
	u32	err_misc[HISI_PCIE_ERR_MISC_REGS];
};

struct hisi_pcie_error_private {
	struct notifier_block	nb;
	struct device *dev;
};

enum hisi_pcie_submodule_id {
	HISI_PCIE_SUB_MODULE_ID_AP,
	HISI_PCIE_SUB_MODULE_ID_TL,
	HISI_PCIE_SUB_MODULE_ID_MAC,
	HISI_PCIE_SUB_MODULE_ID_DL,
	HISI_PCIE_SUB_MODULE_ID_SDI,
};

static const char * const hisi_pcie_sub_module[] = {
	[HISI_PCIE_SUB_MODULE_ID_AP]	= "AP Layer",
	[HISI_PCIE_SUB_MODULE_ID_TL]	= "TL Layer",
	[HISI_PCIE_SUB_MODULE_ID_MAC]	= "MAC Layer",
	[HISI_PCIE_SUB_MODULE_ID_DL]	= "DL Layer",
	[HISI_PCIE_SUB_MODULE_ID_SDI]	= "SDI Layer",
};

enum hisi_pcie_err_severity {
	HISI_PCIE_ERR_SEV_RECOVERABLE,
	HISI_PCIE_ERR_SEV_FATAL,
	HISI_PCIE_ERR_SEV_CORRECTED,
	HISI_PCIE_ERR_SEV_NONE,
};

static const char * const hisi_pcie_error_sev[] = {
	[HISI_PCIE_ERR_SEV_RECOVERABLE]	= "recoverable",
	[HISI_PCIE_ERR_SEV_FATAL]	= "fatal",
	[HISI_PCIE_ERR_SEV_CORRECTED]	= "corrected",
	[HISI_PCIE_ERR_SEV_NONE]	= "none",
};

static const char *hisi_pcie_get_string(const char * const *array,
					size_t n, u32 id)
{
	u32 index;

	for (index = 0; index < n; index++) {
		if (index == id && array[index])
			return array[index];
	}

	return "unknown";
}

static int hisi_pcie_port_reset(struct platform_device *pdev,
				u32 chip_id, u32 port_id)
{
	struct device *dev = &pdev->dev;
	acpi_handle handle = ACPI_HANDLE(dev);
	union acpi_object arg[3];
	struct acpi_object_list arg_list;
	acpi_status s;
	unsigned long long data = 0;

	arg[0].type = ACPI_TYPE_INTEGER;
	arg[0].integer.value = chip_id;
	arg[1].type = ACPI_TYPE_INTEGER;
	arg[1].integer.value = HISI_PCIE_CORE_ID(port_id);
	arg[2].type = ACPI_TYPE_INTEGER;
	arg[2].integer.value = HISI_PCIE_CORE_PORT_ID(port_id);

	arg_list.count = 3;
	arg_list.pointer = arg;

	s = acpi_evaluate_integer(handle, "RST", &arg_list, &data);
	if (ACPI_FAILURE(s)) {
		dev_err(dev, "No RST method\n");
		return -EIO;
	}

	if (data) {

Annotation

Implementation Notes