mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 4/6] PCI Express Advanced Error Reporting Driver
@ 2005-03-12  0:15 long
  0 siblings, 0 replies; only message in thread
From: long @ 2005-03-12  0:15 UTC (permalink / raw)
  To: linux-kernel, linux-pci; +Cc: greg, tom.l.nguyen

This patch includes the source code of Root callback-handle component
of PCI Express Advanced Error Reporting driver.

Signed-off-by: T. Long Nguyen <tom.l.nguyen@intel.com>

--------------------------------------------------------------------
diff -urpN linux-2.6.11-rc5/drivers/pci/pcie/aer/aerdrv_rpc_handle.c patch-2.6.11-rc5-aerc3-split4/drivers/pci/pcie/aer/aerdrv_rpc_handle.c
--- linux-2.6.11-rc5/drivers/pci/pcie/aer/aerdrv_rpc_handle.c	1969-12-31 19:00:00.000000000 -0500
+++ patch-2.6.11-rc5-aerc3-split4/drivers/pci/pcie/aer/aerdrv_rpc_handle.c	2005-03-09 13:25:36.000000000 -0500
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2005 Intel
+ * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
+ *
+ */
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/kernel.h>
+
+#include "aerdrv.h"
+
+static int aer_root_notify(unsigned short requestor_id, union aer_error *error);
+static int aer_root_get_header(unsigned short requestor_id, 
+	union aer_error *error, struct header_log_regs *log);
+
+/* AER callback handle data structure */
+struct pcie_aer_handle aer_root_handle = {
+	.notify 			= aer_root_notify,
+	.get_header 			= aer_root_get_header,
+};
+
+/**
+ * aer_root_notify - process an error being notified by AER Root driver
+ * @requestor_id: an identification
+ * @error: pointer to an error data structure
+ *
+ * Invoked when AER Root Port itself generates error messages.
+ **/
+static int aer_root_notify(unsigned short requestor_id, union aer_error *error)
+{
+	struct pci_dev *pdev = get_root_pci_dev(requestor_id);
+	int pos, retval = -EINVAL;
+	u32 status;
+	u16 reg16;
+	
+	if (error->type == AER_CORRECTABLE) {
+		pci_read_config_dword(pdev, 
+			CORRECTABLE_ERROR_STATUS_REG, &status);
+		if (status & ERR_CORRECTABLE_ERROR_MASK) {
+			pci_write_config_dword(pdev, 
+				CORRECTABLE_ERROR_STATUS_REG, status);
+			error->source.type = AER_CORRECTABLE;
+			error->source.status = status;
+			retval = 0;
+		}		
+	} else {
+		pci_read_config_dword(pdev, 
+			UNCORRECTABLE_ERROR_STATUS_REG, &status);
+		if (status & ERR_UNCORRECTABLE_ERROR_MASK) {
+			u32 severity;
+
+			pci_read_config_dword(pdev, 
+				UNCORRECTABLE_ERROR_SEVERITY_REG, &severity);
+			pci_write_config_dword(pdev, 
+				UNCORRECTABLE_ERROR_STATUS_REG, status);
+			if (status & severity)
+				error->source.type = AER_FATAL;
+			else
+				error->source.type = AER_NONFATAL;
+			error->source.status = status;
+			retval = 0;
+		}
+	}
+	
+	/* Clean up Root device status */
+	pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
+	pci_read_config_word(pdev, pos + PCIE_CAP_DEVICE_STATUS_REG_OFF,&reg16);
+	pci_write_config_word(pdev, pos + PCIE_CAP_DEVICE_STATUS_REG_OFF,reg16);
+
+	return retval;
+}
+
+/**
+ * aer_root_get_header - provide TLP header
+ * @requestor_id: an identification
+ * @error: pointer to a TLP header data structure
+ *
+ * Invoked when AER Root Port logs the header of TLP associated with an error.
+ **/
+static int aer_root_get_header(unsigned short requestor_id, 
+	union aer_error *error, struct header_log_regs *log)
+{
+	struct pci_dev *pdev = get_root_pci_dev(requestor_id);
+
+	if (error->type == AER_CORRECTABLE || 
+		!(error->source.status & AER_LOG_TLP_MASKS))
+		return AER_UNSUCCESS;
+		
+	pci_read_config_dword(pdev, HEADER_LOG_REG, &log->dw0);
+	pci_read_config_dword(pdev, HEADER_LOG_REG + 4, &log->dw1);
+	pci_read_config_dword(pdev, HEADER_LOG_REG + 8, &log->dw2);
+	pci_read_config_dword(pdev, HEADER_LOG_REG + 12, &log->dw3);
+
+	return AER_SUCCESS;
+}
+

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-03-11 23:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-12  0:15 [PATCH 4/6] PCI Express Advanced Error Reporting Driver long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®