aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2018-10-20 12:45:56 -0400
committerBjorn Helgaas <bhelgaas@google.com>2018-10-20 12:45:56 -0400
commit663569db6476795c7955289529ea0154e3d768bf (patch)
tree160897e225b4efd73a023ed5cda1b5c633747785
parent7e4e95897663595323f3bbcf5b75d5bcaf5c1401 (diff)
parent1ce78ce09430a5ffb987015ab2e24d145690b9a3 (diff)
Merge branch 'remotes/lorenzo/pci/tools'
- Convert pcitest build process to that used by other tools (iio, perf, etc) (Gustavo Pimentel) * remotes/lorenzo/pci/tools: tools: PCI: Change pcitest compiling process tools: PCI: Fix compilation warnings
-rw-r--r--Documentation/PCI/endpoint/pci-test-howto.txt19
-rw-r--r--tools/Makefile13
-rw-r--r--tools/pci/Build1
-rw-r--r--tools/pci/Makefile53
-rw-r--r--tools/pci/pcitest.c7
5 files changed, 74 insertions, 19 deletions
diff --git a/Documentation/PCI/endpoint/pci-test-howto.txt b/Documentation/PCI/endpoint/pci-test-howto.txt
index e40cf0fb58d7..040479f437a5 100644
--- a/Documentation/PCI/endpoint/pci-test-howto.txt
+++ b/Documentation/PCI/endpoint/pci-test-howto.txt
@@ -99,17 +99,20 @@ Note that the devices listed here correspond to the value populated in 1.4 above
992.2 Using Endpoint Test function Device 992.2 Using Endpoint Test function Device
100 100
101pcitest.sh added in tools/pci/ can be used to run all the default PCI endpoint 101pcitest.sh added in tools/pci/ can be used to run all the default PCI endpoint
102tests. Before pcitest.sh can be used pcitest.c should be compiled using the 102tests. To compile this tool the following commands should be used:
103following commands.
104 103
105 cd <kernel-dir> 104 # cd <kernel-dir>
106 make headers_install ARCH=arm 105 # make -C tools/pci
107 arm-linux-gnueabihf-gcc -Iusr/include tools/pci/pcitest.c -o pcitest 106
108 cp pcitest <rootfs>/usr/sbin/ 107or if you desire to compile and install in your system:
109 cp tools/pci/pcitest.sh <rootfs> 108
109 # cd <kernel-dir>
110 # make -C tools/pci install
111
112The tool and script will be located in <rootfs>/usr/bin/
110 113
1112.2.1 pcitest.sh Output 1142.2.1 pcitest.sh Output
112 # ./pcitest.sh 115 # pcitest.sh
113 BAR tests 116 BAR tests
114 117
115 BAR0: OKAY 118 BAR0: OKAY
diff --git a/tools/Makefile b/tools/Makefile
index be02c8b904db..abb358a70ad0 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -21,6 +21,7 @@ help:
21 @echo ' leds - LEDs tools' 21 @echo ' leds - LEDs tools'
22 @echo ' liblockdep - user-space wrapper for kernel locking-validator' 22 @echo ' liblockdep - user-space wrapper for kernel locking-validator'
23 @echo ' bpf - misc BPF tools' 23 @echo ' bpf - misc BPF tools'
24 @echo ' pci - PCI tools'
24 @echo ' perf - Linux performance measurement and analysis tool' 25 @echo ' perf - Linux performance measurement and analysis tool'
25 @echo ' selftests - various kernel selftests' 26 @echo ' selftests - various kernel selftests'
26 @echo ' spi - spi tools' 27 @echo ' spi - spi tools'
@@ -59,7 +60,7 @@ acpi: FORCE
59cpupower: FORCE 60cpupower: FORCE
60 $(call descend,power/$@) 61 $(call descend,power/$@)
61 62
62cgroup firewire hv guest spi usb virtio vm bpf iio gpio objtool leds wmi: FORCE 63cgroup firewire hv guest spi usb virtio vm bpf iio gpio objtool leds wmi pci: FORCE
63 $(call descend,$@) 64 $(call descend,$@)
64 65
65liblockdep: FORCE 66liblockdep: FORCE
@@ -94,7 +95,7 @@ kvm_stat: FORCE
94all: acpi cgroup cpupower gpio hv firewire liblockdep \ 95all: acpi cgroup cpupower gpio hv firewire liblockdep \
95 perf selftests spi turbostat usb \ 96 perf selftests spi turbostat usb \
96 virtio vm bpf x86_energy_perf_policy \ 97 virtio vm bpf x86_energy_perf_policy \
97 tmon freefall iio objtool kvm_stat wmi 98 tmon freefall iio objtool kvm_stat wmi pci
98 99
99acpi_install: 100acpi_install:
100 $(call descend,power/$(@:_install=),install) 101 $(call descend,power/$(@:_install=),install)
@@ -102,7 +103,7 @@ acpi_install:
102cpupower_install: 103cpupower_install:
103 $(call descend,power/$(@:_install=),install) 104 $(call descend,power/$(@:_install=),install)
104 105
105cgroup_install firewire_install gpio_install hv_install iio_install perf_install spi_install usb_install virtio_install vm_install bpf_install objtool_install wmi_install: 106cgroup_install firewire_install gpio_install hv_install iio_install perf_install spi_install usb_install virtio_install vm_install bpf_install objtool_install wmi_install pci_install:
106 $(call descend,$(@:_install=),install) 107 $(call descend,$(@:_install=),install)
107 108
108liblockdep_install: 109liblockdep_install:
@@ -128,7 +129,7 @@ install: acpi_install cgroup_install cpupower_install gpio_install \
128 perf_install selftests_install turbostat_install usb_install \ 129 perf_install selftests_install turbostat_install usb_install \
129 virtio_install vm_install bpf_install x86_energy_perf_policy_install \ 130 virtio_install vm_install bpf_install x86_energy_perf_policy_install \
130 tmon_install freefall_install objtool_install kvm_stat_install \ 131 tmon_install freefall_install objtool_install kvm_stat_install \
131 wmi_install 132 wmi_install pci_install
132 133
133acpi_clean: 134acpi_clean:
134 $(call descend,power/acpi,clean) 135 $(call descend,power/acpi,clean)
@@ -136,7 +137,7 @@ acpi_clean:
136cpupower_clean: 137cpupower_clean:
137 $(call descend,power/cpupower,clean) 138 $(call descend,power/cpupower,clean)
138 139
139cgroup_clean hv_clean firewire_clean spi_clean usb_clean virtio_clean vm_clean wmi_clean bpf_clean iio_clean gpio_clean objtool_clean leds_clean: 140cgroup_clean hv_clean firewire_clean spi_clean usb_clean virtio_clean vm_clean wmi_clean bpf_clean iio_clean gpio_clean objtool_clean leds_clean pci_clean:
140 $(call descend,$(@:_clean=),clean) 141 $(call descend,$(@:_clean=),clean)
141 142
142liblockdep_clean: 143liblockdep_clean:
@@ -174,6 +175,6 @@ clean: acpi_clean cgroup_clean cpupower_clean hv_clean firewire_clean \
174 perf_clean selftests_clean turbostat_clean spi_clean usb_clean virtio_clean \ 175 perf_clean selftests_clean turbostat_clean spi_clean usb_clean virtio_clean \
175 vm_clean bpf_clean iio_clean x86_energy_perf_policy_clean tmon_clean \ 176 vm_clean bpf_clean iio_clean x86_energy_perf_policy_clean tmon_clean \
176 freefall_clean build_clean libbpf_clean libsubcmd_clean liblockdep_clean \ 177 freefall_clean build_clean libbpf_clean libsubcmd_clean liblockdep_clean \
177 gpio_clean objtool_clean leds_clean wmi_clean 178 gpio_clean objtool_clean leds_clean wmi_clean pci_clean
178 179
179.PHONY: FORCE 180.PHONY: FORCE
diff --git a/tools/pci/Build b/tools/pci/Build
new file mode 100644
index 000000000000..c375aea21790
--- /dev/null
+++ b/tools/pci/Build
@@ -0,0 +1 @@
pcitest-y += pcitest.o
diff --git a/tools/pci/Makefile b/tools/pci/Makefile
new file mode 100644
index 000000000000..46e4c2f318c9
--- /dev/null
+++ b/tools/pci/Makefile
@@ -0,0 +1,53 @@
1# SPDX-License-Identifier: GPL-2.0
2include ../scripts/Makefile.include
3
4bindir ?= /usr/bin
5
6ifeq ($(srctree),)
7srctree := $(patsubst %/,%,$(dir $(CURDIR)))
8srctree := $(patsubst %/,%,$(dir $(srctree)))
9endif
10
11# Do not use make's built-in rules
12# (this improves performance and avoids hard-to-debug behaviour);
13MAKEFLAGS += -r
14
15CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
16
17ALL_TARGETS := pcitest pcitest.sh
18ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
19
20all: $(ALL_PROGRAMS)
21
22export srctree OUTPUT CC LD CFLAGS
23include $(srctree)/tools/build/Makefile.include
24
25#
26# We need the following to be outside of kernel tree
27#
28$(OUTPUT)include/linux/: ../../include/uapi/linux/
29 mkdir -p $(OUTPUT)include/linux/ 2>&1 || true
30 ln -sf $(CURDIR)/../../include/uapi/linux/pcitest.h $@
31
32prepare: $(OUTPUT)include/linux/
33
34PCITEST_IN := $(OUTPUT)pcitest-in.o
35$(PCITEST_IN): prepare FORCE
36 $(Q)$(MAKE) $(build)=pcitest
37$(OUTPUT)pcitest: $(PCITEST_IN)
38 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
39
40clean:
41 rm -f $(ALL_PROGRAMS)
42 rm -rf $(OUTPUT)include/
43 find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
44
45install: $(ALL_PROGRAMS)
46 install -d -m 755 $(DESTDIR)$(bindir); \
47 for program in $(ALL_PROGRAMS); do \
48 install $$program $(DESTDIR)$(bindir); \
49 done
50
51FORCE:
52
53.PHONY: all install clean FORCE prepare
diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c
index af146bb03b4d..ec4d51f3308b 100644
--- a/tools/pci/pcitest.c
+++ b/tools/pci/pcitest.c
@@ -23,7 +23,6 @@
23#include <stdio.h> 23#include <stdio.h>
24#include <stdlib.h> 24#include <stdlib.h>
25#include <sys/ioctl.h> 25#include <sys/ioctl.h>
26#include <time.h>
27#include <unistd.h> 26#include <unistd.h>
28 27
29#include <linux/pcitest.h> 28#include <linux/pcitest.h>
@@ -48,17 +47,15 @@ struct pci_test {
48 unsigned long size; 47 unsigned long size;
49}; 48};
50 49
51static int run_test(struct pci_test *test) 50static void run_test(struct pci_test *test)
52{ 51{
53 long ret; 52 long ret;
54 int fd; 53 int fd;
55 struct timespec start, end;
56 double time;
57 54
58 fd = open(test->device, O_RDWR); 55 fd = open(test->device, O_RDWR);
59 if (fd < 0) { 56 if (fd < 0) {
60 perror("can't open PCI Endpoint Test device"); 57 perror("can't open PCI Endpoint Test device");
61 return fd; 58 return;
62 } 59 }
63 60
64 if (test->barnum >= 0 && test->barnum <= 5) { 61 if (test->barnum >= 0 && test->barnum <= 5) {