Skip to content

Commit

Permalink
Merge branch 'remotes/lorenzo/pci/tools'
Browse files Browse the repository at this point in the history
  - 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
  • Loading branch information
bjorn-helgaas committed Oct 20, 2018
2 parents 7e4e958 + 1ce78ce commit 663569d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 19 deletions.
19 changes: 11 additions & 8 deletions Documentation/PCI/endpoint/pci-test-howto.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,20 @@ Note that the devices listed here correspond to the value populated in 1.4 above
2.2 Using Endpoint Test function Device

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

cd <kernel-dir>
make headers_install ARCH=arm
arm-linux-gnueabihf-gcc -Iusr/include tools/pci/pcitest.c -o pcitest
cp pcitest <rootfs>/usr/sbin/
cp tools/pci/pcitest.sh <rootfs>
# cd <kernel-dir>
# make -C tools/pci

or if you desire to compile and install in your system:

# cd <kernel-dir>
# make -C tools/pci install

The tool and script will be located in <rootfs>/usr/bin/

2.2.1 pcitest.sh Output
# ./pcitest.sh
# pcitest.sh
BAR tests

BAR0: OKAY
Expand Down
13 changes: 7 additions & 6 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ help:
@echo ' leds - LEDs tools'
@echo ' liblockdep - user-space wrapper for kernel locking-validator'
@echo ' bpf - misc BPF tools'
@echo ' pci - PCI tools'
@echo ' perf - Linux performance measurement and analysis tool'
@echo ' selftests - various kernel selftests'
@echo ' spi - spi tools'
Expand Down Expand Up @@ -59,7 +60,7 @@ acpi: FORCE
cpupower: FORCE
$(call descend,power/$@)

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

liblockdep: FORCE
Expand Down Expand Up @@ -94,15 +95,15 @@ kvm_stat: FORCE
all: acpi cgroup cpupower gpio hv firewire liblockdep \
perf selftests spi turbostat usb \
virtio vm bpf x86_energy_perf_policy \
tmon freefall iio objtool kvm_stat wmi
tmon freefall iio objtool kvm_stat wmi pci

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

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

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:
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:
$(call descend,$(@:_install=),install)

liblockdep_install:
Expand All @@ -128,15 +129,15 @@ install: acpi_install cgroup_install cpupower_install gpio_install \
perf_install selftests_install turbostat_install usb_install \
virtio_install vm_install bpf_install x86_energy_perf_policy_install \
tmon_install freefall_install objtool_install kvm_stat_install \
wmi_install
wmi_install pci_install

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

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

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:
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:
$(call descend,$(@:_clean=),clean)

liblockdep_clean:
Expand Down Expand Up @@ -174,6 +175,6 @@ clean: acpi_clean cgroup_clean cpupower_clean hv_clean firewire_clean \
perf_clean selftests_clean turbostat_clean spi_clean usb_clean virtio_clean \
vm_clean bpf_clean iio_clean x86_energy_perf_policy_clean tmon_clean \
freefall_clean build_clean libbpf_clean libsubcmd_clean liblockdep_clean \
gpio_clean objtool_clean leds_clean wmi_clean
gpio_clean objtool_clean leds_clean wmi_clean pci_clean

.PHONY: FORCE
1 change: 1 addition & 0 deletions tools/pci/Build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pcitest-y += pcitest.o
53 changes: 53 additions & 0 deletions tools/pci/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# SPDX-License-Identifier: GPL-2.0
include ../scripts/Makefile.include

bindir ?= /usr/bin

ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
endif

# Do not use make's built-in rules
# (this improves performance and avoids hard-to-debug behaviour);
MAKEFLAGS += -r

CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include

ALL_TARGETS := pcitest pcitest.sh
ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))

all: $(ALL_PROGRAMS)

export srctree OUTPUT CC LD CFLAGS
include $(srctree)/tools/build/Makefile.include

#
# We need the following to be outside of kernel tree
#
$(OUTPUT)include/linux/: ../../include/uapi/linux/
mkdir -p $(OUTPUT)include/linux/ 2>&1 || true
ln -sf $(CURDIR)/../../include/uapi/linux/pcitest.h $@

prepare: $(OUTPUT)include/linux/

PCITEST_IN := $(OUTPUT)pcitest-in.o
$(PCITEST_IN): prepare FORCE
$(Q)$(MAKE) $(build)=pcitest
$(OUTPUT)pcitest: $(PCITEST_IN)
$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@

clean:
rm -f $(ALL_PROGRAMS)
rm -rf $(OUTPUT)include/
find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete

install: $(ALL_PROGRAMS)
install -d -m 755 $(DESTDIR)$(bindir); \
for program in $(ALL_PROGRAMS); do \
install $$program $(DESTDIR)$(bindir); \
done

FORCE:

.PHONY: all install clean FORCE prepare
7 changes: 2 additions & 5 deletions tools/pci/pcitest.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <time.h>
#include <unistd.h>

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

static int run_test(struct pci_test *test)
static void run_test(struct pci_test *test)
{
long ret;
int fd;
struct timespec start, end;
double time;

fd = open(test->device, O_RDWR);
if (fd < 0) {
perror("can't open PCI Endpoint Test device");
return fd;
return;
}

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

0 comments on commit 663569d

Please sign in to comment.