Skip to content

Commit 663569d

Browse files
committed
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
2 parents 7e4e958 + 1ce78ce commit 663569d

File tree

5 files changed

+74
-19
lines changed

5 files changed

+74
-19
lines changed

Documentation/PCI/endpoint/pci-test-howto.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,20 @@ Note that the devices listed here correspond to the value populated in 1.4 above
9999
2.2 Using Endpoint Test function Device
100100

101101
pcitest.sh added in tools/pci/ can be used to run all the default PCI endpoint
102-
tests. Before pcitest.sh can be used pcitest.c should be compiled using the
103-
following commands.
102+
tests. To compile this tool the following commands should be used:
104103

105-
cd <kernel-dir>
106-
make headers_install ARCH=arm
107-
arm-linux-gnueabihf-gcc -Iusr/include tools/pci/pcitest.c -o pcitest
108-
cp pcitest <rootfs>/usr/sbin/
109-
cp tools/pci/pcitest.sh <rootfs>
104+
# cd <kernel-dir>
105+
# make -C tools/pci
106+
107+
or if you desire to compile and install in your system:
108+
109+
# cd <kernel-dir>
110+
# make -C tools/pci install
111+
112+
The tool and script will be located in <rootfs>/usr/bin/
110113

111114
2.2.1 pcitest.sh Output
112-
# ./pcitest.sh
115+
# pcitest.sh
113116
BAR tests
114117

115118
BAR0: OKAY

tools/Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ help:
2121
@echo ' leds - LEDs tools'
2222
@echo ' liblockdep - user-space wrapper for kernel locking-validator'
2323
@echo ' bpf - misc BPF tools'
24+
@echo ' pci - PCI tools'
2425
@echo ' perf - Linux performance measurement and analysis tool'
2526
@echo ' selftests - various kernel selftests'
2627
@echo ' spi - spi tools'
@@ -59,7 +60,7 @@ acpi: FORCE
5960
cpupower: FORCE
6061
$(call descend,power/$@)
6162

62-
cgroup firewire hv guest spi usb virtio vm bpf iio gpio objtool leds wmi: FORCE
63+
cgroup firewire hv guest spi usb virtio vm bpf iio gpio objtool leds wmi pci: FORCE
6364
$(call descend,$@)
6465

6566
liblockdep: FORCE
@@ -94,15 +95,15 @@ kvm_stat: FORCE
9495
all: acpi cgroup cpupower gpio hv firewire liblockdep \
9596
perf selftests spi turbostat usb \
9697
virtio vm bpf x86_energy_perf_policy \
97-
tmon freefall iio objtool kvm_stat wmi
98+
tmon freefall iio objtool kvm_stat wmi pci
9899

99100
acpi_install:
100101
$(call descend,power/$(@:_install=),install)
101102

102103
cpupower_install:
103104
$(call descend,power/$(@:_install=),install)
104105

105-
cgroup_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:
106+
cgroup_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:
106107
$(call descend,$(@:_install=),install)
107108

108109
liblockdep_install:
@@ -128,15 +129,15 @@ install: acpi_install cgroup_install cpupower_install gpio_install \
128129
perf_install selftests_install turbostat_install usb_install \
129130
virtio_install vm_install bpf_install x86_energy_perf_policy_install \
130131
tmon_install freefall_install objtool_install kvm_stat_install \
131-
wmi_install
132+
wmi_install pci_install
132133

133134
acpi_clean:
134135
$(call descend,power/acpi,clean)
135136

136137
cpupower_clean:
137138
$(call descend,power/cpupower,clean)
138139

139-
cgroup_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:
140+
cgroup_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:
140141
$(call descend,$(@:_clean=),clean)
141142

142143
liblockdep_clean:
@@ -174,6 +175,6 @@ clean: acpi_clean cgroup_clean cpupower_clean hv_clean firewire_clean \
174175
perf_clean selftests_clean turbostat_clean spi_clean usb_clean virtio_clean \
175176
vm_clean bpf_clean iio_clean x86_energy_perf_policy_clean tmon_clean \
176177
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
178179

179180
.PHONY: FORCE

tools/pci/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pcitest-y += pcitest.o

tools/pci/Makefile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
include ../scripts/Makefile.include
3+
4+
bindir ?= /usr/bin
5+
6+
ifeq ($(srctree),)
7+
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
8+
srctree := $(patsubst %/,%,$(dir $(srctree)))
9+
endif
10+
11+
# Do not use make's built-in rules
12+
# (this improves performance and avoids hard-to-debug behaviour);
13+
MAKEFLAGS += -r
14+
15+
CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
16+
17+
ALL_TARGETS := pcitest pcitest.sh
18+
ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
19+
20+
all: $(ALL_PROGRAMS)
21+
22+
export srctree OUTPUT CC LD CFLAGS
23+
include $(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+
32+
prepare: $(OUTPUT)include/linux/
33+
34+
PCITEST_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+
40+
clean:
41+
rm -f $(ALL_PROGRAMS)
42+
rm -rf $(OUTPUT)include/
43+
find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
44+
45+
install: $(ALL_PROGRAMS)
46+
install -d -m 755 $(DESTDIR)$(bindir); \
47+
for program in $(ALL_PROGRAMS); do \
48+
install $$program $(DESTDIR)$(bindir); \
49+
done
50+
51+
FORCE:
52+
53+
.PHONY: all install clean FORCE prepare

tools/pci/pcitest.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <stdio.h>
2424
#include <stdlib.h>
2525
#include <sys/ioctl.h>
26-
#include <time.h>
2726
#include <unistd.h>
2827

2928
#include <linux/pcitest.h>
@@ -48,17 +47,15 @@ struct pci_test {
4847
unsigned long size;
4948
};
5049

51-
static int run_test(struct pci_test *test)
50+
static void run_test(struct pci_test *test)
5251
{
5352
long ret;
5453
int fd;
55-
struct timespec start, end;
56-
double time;
5754

5855
fd = open(test->device, O_RDWR);
5956
if (fd < 0) {
6057
perror("can't open PCI Endpoint Test device");
61-
return fd;
58+
return;
6259
}
6360

6461
if (test->barnum >= 0 && test->barnum <= 5) {

0 commit comments

Comments
 (0)