Skip to contentSkip to conversation

Cold Reset IGT Test

PATCH Superseded Anshuman Gupta 1 participant 2 messages Nov 23, 2022

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Cold Reset IGT Test

Adding Cold Reset IGT support

v3:
- Address the review comment from Aravind.

Anshuman Gupta (5):
lib/igt_pci: helpers to get PCI capabilities offset lib/igt_pci: Add PCIe slot cap
lib/igt_pm: Refactor get firmware_node fd test/device_reset: Refactor initiate_device_reset tests/device_reset: Add cold reset IGT test

 lib/igt_pci.c        |  44 ++++++++++++
 lib/igt_pci.h        |  35 +++++++++
 lib/igt_pm.c         |  76 +++++++++++++++++---
 lib/igt_pm.h         |   1 +
 lib/meson.build      |   1 +
 tests/device_reset.c | 167 +++++++++++++++++++++++++++++++++++++++----
 6 files changed, 300 insertions(+), 24 deletions(-)
 create mode 100644 lib/igt_pci.c
 create mode 100644 lib/igt_pci.h
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 1/5 lib/igt_pci: helpers to get PCI capabilities offset

Added helper functions to search for PCI capabilities with help of libpciaccess library.

---
 lib/igt_pci.c   | 44 ++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_pci.h   | 32 ++++++++++++++++++++++++++++++++
 lib/meson.build |  1 +
 3 files changed, 77 insertions(+)
 create mode 100644 lib/igt_pci.c
 create mode 100644 lib/igt_pci.h
lib/igt_pci.c new file +44 -0
new file mode 100644
index 0000000000..bc0369341d
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2022 Intel Corporation
+ */
+
+#include <pciaccess.h>
+#include "igt_pci.h"
+
+/**
+ * find_pci_cap_offset:
+ * @dev: pci device
+ * @cap_id: searched capability id, 0 means any capability
+ * @start_offset: offset in config space from which we start searching
+ *
+ * return:
+ * -1 on config read error, 0 if capability is not found,
+ * otherwise offset at which capability with cap_id is found
+ */
+int find_pci_cap_offset_at(struct pci_device *dev, enum pci_cap_id cap_id,
+			   int start_offset)
+{
+	uint8_t offset;
+	uint16_t cap_header;
+	int loop = (PCI_CFG_SPACE_SIZE - PCI_TYPE0_1_HEADER_SIZE)
+			/ sizeof(cap_header);
+
+	if (pci_device_cfg_read_u8(dev, &offset, start_offset))
+		return -1;
+
+	while (loop--) {
+		if (offset < PCI_TYPE0_1_HEADER_SIZE)
+			break;
+
+		if (pci_device_cfg_read_u16(dev, &cap_header, (offset & 0xFC)))
+			return -1;
+
+		if (!cap_id || cap_id == (cap_header & 0xFF))
+			return offset;
+
+		offset = cap_header >> 8;
+	}
+
+	return 0;
+}
lib/igt_pci.h new file +32 -0
new file mode 100644
index 0000000000..68afd2dacb
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2022 Intel Corporation
+ */
+
+#ifndef __IGT_PCI_H__
+#define __IGT_PCI_H__
+
+#include <stdint.h>
+#include <endian.h>
+
+/* forward declaration */
+struct pci_device;
+
+#define PCI_TYPE0_1_HEADER_SIZE 0x40
+#define PCI_CAPS_START 0x34
+#define PCI_CFG_SPACE_SIZE 0x100
+#define PCIE_CFG_SPACE_SIZE 0x1000
+
+enum pci_cap_id {
+	PCI_EXPRESS_CAP_ID = 0x10
+};
+
+int find_pci_cap_offset_at(struct pci_device *dev, enum pci_cap_id cap_id,
+			   int start_offset);
+
+static inline int find_pci_cap_offset(struct pci_device *dev, enum pci_cap_id cap_id)
+{
+	return find_pci_cap_offset_at(dev, cap_id, PCI_CAPS_START);
+}
+
+#endif
lib/meson.build +1 -0
index cef2d0ff3d..e0fb7ddfed 100644
@@ -33,6 +33,7 @@ lib_sources = [
 	'igt_pipe_crc.c',
 	'igt_power.c',
 	'igt_primes.c',
+	'igt_pci.c',
 	'igt_rand.c',
 	'igt_stats.c',
 	'igt_syncobj.c',
Signature · 1 line
2.25.1