arch/s390/pci/pci_report.c

Source file repositories/reference/linux-study-clean/arch/s390/pci/pci_report.c

File Facts

System
Linux kernel
Corpus path
arch/s390/pci/pci_report.c
Extension
.c
Size
4359 bytes
Lines
158
Domain
Architecture Layer
Bucket
arch/s390
Inferred role
Architecture Layer: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

struct pci_driver *driver = NULL;
	struct pci_dev *pdev = NULL;
	char *buf, *end;
	int ret;

	if (!zdev || !zdev->zbus)
		return -ENODEV;

	/* Protected virtualization hosts get nothing from us */
	if (prot_virt_guest)
		return -ENODATA;

	report = (void *)get_zeroed_page(GFP_KERNEL);
	if (!report)
		return -ENOMEM;
	if (zdev->zbus->bus)
		pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);
	if (pdev)
		driver = to_pci_driver(pdev->dev.driver);

	buf = report->data.log_data;
	end = report->data.log_data + ZPCI_REPORT_DATA_SIZE;
	buf += scnprintf(buf, end - buf, "report: %s\n", operation);
	buf += scnprintf(buf, end - buf, "status: %s\n", status);
	buf += scnprintf(buf, end - buf, "state: %s\n",
			 (pdev) ? zpci_state_str(pdev->error_state) : "n/a");
	buf += scnprintf(buf, end - buf, "driver: %s\n", (driver) ? driver->name : "n/a");
	ret = debug_dump(pci_debug_msg_id, &debug_log_view, buf, end - buf, true);
	if (ret < 0)
		pr_err("Reading PCI debug messages failed with code %d\n", ret);
	else
		buf += ret;

	report->header.version = 1;
	report->header.action = SCLP_ERRNOTIFY_AQ_INFO_LOG;
	report->header.length = buf - (char *)&report->data;
	report->data.timestamp = ktime_get_clocktai_seconds();
	report->data.err_log_id = ZPCI_ERR_LOG_ID_KERNEL_REPORT;

	ret = sclp_pci_report(&report->header, zdev->fh, zdev->fid);
	if (ret)
		pr_err("Reporting PCI status failed with code %d\n", ret);
	else
		pr_info("Reported PCI device status\n");

	free_page((unsigned long)report);

	return ret;
}

Annotation

Implementation Notes