mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-25 18:45:06 +07:00
fb4da215ed
-----BEGIN PGP SIGNATURE----- iQJIBAABCgAyFiEEgMe7l+5h9hnxdsnuWYigwDrT+vwFAl0siFoUHGJoZWxnYWFz QGdvb2dsZS5jb20ACgkQWYigwDrT+vzi9A//S4jRyyZrgUr88Az0GbgMhE4b3yqc uL7om/Sf+443gG6C+aKkZSM/IE9hrbyIKuYq7GGxDkzZ/HkucZo2yIuAHkPgG4ik QQYJ8fJsmMq1bUht87c1ZZwGP0++Deq/Ns2+VNy/WBYqKLulnV0DvEEaJgPs9C5D ppwccGdo6UghiujBTpE4ddUBjFjjURWqT6wSnMRDQ4EGwfUhG0MWwwHKI4hbBuaL N6refuggdYyUUX5FeUOHa6VF6uTnSSAQ75k+40n4nljdayqoumHLskst77o9q5ZI oXjdpwgmuEqYhfp03HEA4Xo/bBxiRj76NuTiEMKvPokxjpanwbLrdV0GhF0OIlM0 rp1NOI1w+vppFrU+rc2gtq+7hYXFmvdhjS29hFLeD91PP36N5d29jW5NVFpm7GCm n4TMGAOsu8RB+bNua6ZbZVcDk2EnPgQeIcM0ZPoBtPK19Fg/rScdEU4u/aFE1Y0Q C+Ks7D1qCvFpHzl/xAg0oo9v/jFsWef3qnQWOzot964Zz4W4NSVvB9Ox6Vbfj6C4 v331LJmlPxG8fxBNA3q28FrTxcG1NW6sgo3WY9VoSp/vc0aqaPKhm7sbraTt5IrI TwqA/WhnAHv90MQCGFcofANyYTkjPkKk2QBFK6b0suoAmVdwVWWELi1WaZ+HdvgQ JP7YpmC2cXcQBPk= =ZGxL -----END PGP SIGNATURE----- Merge tag 'pci-v5.3-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci Pull PCI updates from Bjorn Helgaas: "Enumeration changes: - Evaluate PCI Boot Configuration _DSM to learn if firmware wants us to preserve its resource assignments (Benjamin Herrenschmidt) - Simplify resource distribution (Nicholas Johnson) - Decode 32 GT/s link speed (Gustavo Pimentel) Virtualization: - Fix incorrect caching of VF config space size (Alex Williamson) - Fix VF driver probing sysfs knobs (Alex Williamson) Peer-to-peer DMA: - Fix dma_virt_ops check (Logan Gunthorpe) Altera host bridge driver: - Allow building as module (Ley Foon Tan) Armada 8K host bridge driver: - add PHYs support (Miquel Raynal) DesignWare host bridge driver: - Export APIs to support removable loadable module (Vidya Sagar) - Enable Relaxed Ordering erratum workaround only on Tegra20 & Tegra30 (Vidya Sagar) Hyper-V host bridge driver: - Fix use-after-free in eject (Dexuan Cui) Mobiveil host bridge driver: - Clean up and fix many issues, including non-identify mapped windows, 64-bit windows, multi-MSI, class code, INTx clearing (Hou Zhiqiang) Qualcomm host bridge driver: - Use clk bulk API for 2.4.0 controllers (Bjorn Andersson) - Add QCS404 support (Bjorn Andersson) - Assert PERST for at least 100ms (Niklas Cassel) R-Car host bridge driver: - Add r8a774a1 DT support (Biju Das) Tegra host bridge driver: - Add support for Gen2, opportunistic UpdateFC and ACK (PCIe protocol details) AER, GPIO-based PERST# (Manikanta Maddireddy) - Fix many issues, including power-on failure cases, interrupt masking in suspend, UPHY settings, AFI dynamic clock gating, pending DLL transactions (Manikanta Maddireddy) Xilinx host bridge driver: - Fix NWL Multi-MSI programming (Bharat Kumar Gogada) Endpoint support: - Fix 64bit BAR support (Alan Mikhak) - Fix pcitest build issues (Alan Mikhak, Andy Shevchenko) Bug fixes: - Fix NVIDIA GPU multi-function power dependencies (Abhishek Sahu) - Fix NVIDIA GPU HDA enablement issue (Lukas Wunner) - Ignore lockdep for sysfs "remove" (Marek Vasut) Misc: - Convert docs to reST (Changbin Du, Mauro Carvalho Chehab)" * tag 'pci-v5.3-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (107 commits) PCI: Enable NVIDIA HDA controllers tools: PCI: Fix installation when `make tools/pci_install` PCI: dwc: pci-dra7xx: Fix compilation when !CONFIG_GPIOLIB PCI: Fix typos and whitespace errors PCI: mobiveil: Fix INTx interrupt clearing in mobiveil_pcie_isr() PCI: mobiveil: Fix infinite-loop in the INTx handling function PCI: mobiveil: Move PCIe PIO enablement out of inbound window routine PCI: mobiveil: Add upper 32-bit PCI base address setup in inbound window PCI: mobiveil: Add upper 32-bit CPU base address setup in outbound window PCI: mobiveil: Mask out hardcoded bits in inbound/outbound windows setup PCI: mobiveil: Clear the control fields before updating it PCI: mobiveil: Add configured inbound windows counter PCI: mobiveil: Fix the valid check for inbound and outbound windows PCI: mobiveil: Clean-up program_{ib/ob}_windows() PCI: mobiveil: Remove an unnecessary return value check PCI: mobiveil: Fix error return values PCI: mobiveil: Refactor the MEM/IO outbound window initialization PCI: mobiveil: Make some register updates more readable PCI: mobiveil: Reformat the code for readability dt-bindings: PCI: mobiveil: Change gpio_slave and apb_csr to optional ...
223 lines
5.0 KiB
C
223 lines
5.0 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/**
|
|
* Userspace PCI Endpoint Test Module
|
|
*
|
|
* Copyright (C) 2017 Texas Instruments
|
|
* Author: Kishon Vijay Abraham I <kishon@ti.com>
|
|
*/
|
|
|
|
#include <errno.h>
|
|
#include <fcntl.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/ioctl.h>
|
|
#include <unistd.h>
|
|
|
|
#include <linux/pcitest.h>
|
|
|
|
#define BILLION 1E9
|
|
|
|
static char *result[] = { "NOT OKAY", "OKAY" };
|
|
static char *irq[] = { "LEGACY", "MSI", "MSI-X" };
|
|
|
|
struct pci_test {
|
|
char *device;
|
|
char barnum;
|
|
bool legacyirq;
|
|
unsigned int msinum;
|
|
unsigned int msixnum;
|
|
int irqtype;
|
|
bool set_irqtype;
|
|
bool get_irqtype;
|
|
bool read;
|
|
bool write;
|
|
bool copy;
|
|
unsigned long size;
|
|
};
|
|
|
|
static int run_test(struct pci_test *test)
|
|
{
|
|
int ret = -EINVAL;
|
|
int fd;
|
|
|
|
fd = open(test->device, O_RDWR);
|
|
if (fd < 0) {
|
|
perror("can't open PCI Endpoint Test device");
|
|
return -ENODEV;
|
|
}
|
|
|
|
if (test->barnum >= 0 && test->barnum <= 5) {
|
|
ret = ioctl(fd, PCITEST_BAR, test->barnum);
|
|
fprintf(stdout, "BAR%d:\t\t", test->barnum);
|
|
if (ret < 0)
|
|
fprintf(stdout, "TEST FAILED\n");
|
|
else
|
|
fprintf(stdout, "%s\n", result[ret]);
|
|
}
|
|
|
|
if (test->set_irqtype) {
|
|
ret = ioctl(fd, PCITEST_SET_IRQTYPE, test->irqtype);
|
|
fprintf(stdout, "SET IRQ TYPE TO %s:\t\t", irq[test->irqtype]);
|
|
if (ret < 0)
|
|
fprintf(stdout, "FAILED\n");
|
|
else
|
|
fprintf(stdout, "%s\n", result[ret]);
|
|
}
|
|
|
|
if (test->get_irqtype) {
|
|
ret = ioctl(fd, PCITEST_GET_IRQTYPE);
|
|
fprintf(stdout, "GET IRQ TYPE:\t\t");
|
|
if (ret < 0)
|
|
fprintf(stdout, "FAILED\n");
|
|
else
|
|
fprintf(stdout, "%s\n", irq[ret]);
|
|
}
|
|
|
|
if (test->legacyirq) {
|
|
ret = ioctl(fd, PCITEST_LEGACY_IRQ, 0);
|
|
fprintf(stdout, "LEGACY IRQ:\t");
|
|
if (ret < 0)
|
|
fprintf(stdout, "TEST FAILED\n");
|
|
else
|
|
fprintf(stdout, "%s\n", result[ret]);
|
|
}
|
|
|
|
if (test->msinum > 0 && test->msinum <= 32) {
|
|
ret = ioctl(fd, PCITEST_MSI, test->msinum);
|
|
fprintf(stdout, "MSI%d:\t\t", test->msinum);
|
|
if (ret < 0)
|
|
fprintf(stdout, "TEST FAILED\n");
|
|
else
|
|
fprintf(stdout, "%s\n", result[ret]);
|
|
}
|
|
|
|
if (test->msixnum > 0 && test->msixnum <= 2048) {
|
|
ret = ioctl(fd, PCITEST_MSIX, test->msixnum);
|
|
fprintf(stdout, "MSI-X%d:\t\t", test->msixnum);
|
|
if (ret < 0)
|
|
fprintf(stdout, "TEST FAILED\n");
|
|
else
|
|
fprintf(stdout, "%s\n", result[ret]);
|
|
}
|
|
|
|
if (test->write) {
|
|
ret = ioctl(fd, PCITEST_WRITE, test->size);
|
|
fprintf(stdout, "WRITE (%7ld bytes):\t\t", test->size);
|
|
if (ret < 0)
|
|
fprintf(stdout, "TEST FAILED\n");
|
|
else
|
|
fprintf(stdout, "%s\n", result[ret]);
|
|
}
|
|
|
|
if (test->read) {
|
|
ret = ioctl(fd, PCITEST_READ, test->size);
|
|
fprintf(stdout, "READ (%7ld bytes):\t\t", test->size);
|
|
if (ret < 0)
|
|
fprintf(stdout, "TEST FAILED\n");
|
|
else
|
|
fprintf(stdout, "%s\n", result[ret]);
|
|
}
|
|
|
|
if (test->copy) {
|
|
ret = ioctl(fd, PCITEST_COPY, test->size);
|
|
fprintf(stdout, "COPY (%7ld bytes):\t\t", test->size);
|
|
if (ret < 0)
|
|
fprintf(stdout, "TEST FAILED\n");
|
|
else
|
|
fprintf(stdout, "%s\n", result[ret]);
|
|
}
|
|
|
|
fflush(stdout);
|
|
return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int c;
|
|
struct pci_test *test;
|
|
|
|
test = calloc(1, sizeof(*test));
|
|
if (!test) {
|
|
perror("Fail to allocate memory for pci_test\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
/* since '0' is a valid BAR number, initialize it to -1 */
|
|
test->barnum = -1;
|
|
|
|
/* set default size as 100KB */
|
|
test->size = 0x19000;
|
|
|
|
/* set default endpoint device */
|
|
test->device = "/dev/pci-endpoint-test.0";
|
|
|
|
while ((c = getopt(argc, argv, "D:b:m:x:i:Ilhrwcs:")) != EOF)
|
|
switch (c) {
|
|
case 'D':
|
|
test->device = optarg;
|
|
continue;
|
|
case 'b':
|
|
test->barnum = atoi(optarg);
|
|
if (test->barnum < 0 || test->barnum > 5)
|
|
goto usage;
|
|
continue;
|
|
case 'l':
|
|
test->legacyirq = true;
|
|
continue;
|
|
case 'm':
|
|
test->msinum = atoi(optarg);
|
|
if (test->msinum < 1 || test->msinum > 32)
|
|
goto usage;
|
|
continue;
|
|
case 'x':
|
|
test->msixnum = atoi(optarg);
|
|
if (test->msixnum < 1 || test->msixnum > 2048)
|
|
goto usage;
|
|
continue;
|
|
case 'i':
|
|
test->irqtype = atoi(optarg);
|
|
if (test->irqtype < 0 || test->irqtype > 2)
|
|
goto usage;
|
|
test->set_irqtype = true;
|
|
continue;
|
|
case 'I':
|
|
test->get_irqtype = true;
|
|
continue;
|
|
case 'r':
|
|
test->read = true;
|
|
continue;
|
|
case 'w':
|
|
test->write = true;
|
|
continue;
|
|
case 'c':
|
|
test->copy = true;
|
|
continue;
|
|
case 's':
|
|
test->size = strtoul(optarg, NULL, 0);
|
|
continue;
|
|
case 'h':
|
|
default:
|
|
usage:
|
|
fprintf(stderr,
|
|
"usage: %s [options]\n"
|
|
"Options:\n"
|
|
"\t-D <dev> PCI endpoint test device {default: /dev/pci-endpoint-test.0}\n"
|
|
"\t-b <bar num> BAR test (bar number between 0..5)\n"
|
|
"\t-m <msi num> MSI test (msi number between 1..32)\n"
|
|
"\t-x <msix num> \tMSI-X test (msix number between 1..2048)\n"
|
|
"\t-i <irq type> \tSet IRQ type (0 - Legacy, 1 - MSI, 2 - MSI-X)\n"
|
|
"\t-I Get current IRQ type configured\n"
|
|
"\t-l Legacy IRQ test\n"
|
|
"\t-r Read buffer test\n"
|
|
"\t-w Write buffer test\n"
|
|
"\t-c Copy buffer test\n"
|
|
"\t-s <size> Size of buffer {default: 100KB}\n"
|
|
"\t-h Print this help message\n",
|
|
argv[0]);
|
|
return -EINVAL;
|
|
}
|
|
|
|
return run_test(test);
|
|
}
|