aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/arch/x86/include/asm/cpufeatures.h2
-rw-r--r--tools/objtool/arch/x86/decode.c9
-rw-r--r--tools/objtool/builtin-check.c68
-rw-r--r--tools/perf/jvmti/Makefile2
-rw-r--r--tools/perf/ui/browsers/hists.c51
-rw-r--r--tools/perf/util/header.c2
-rw-r--r--tools/perf/util/hist.c12
-rw-r--r--tools/perf/util/parse-events.l4
-rw-r--r--tools/power/acpi/Makefile.config23
-rw-r--r--tools/power/acpi/Makefile.rules40
-rw-r--r--tools/power/acpi/tools/acpidbg/Makefile4
-rw-r--r--tools/power/acpi/tools/acpidbg/acpidbg.c8
-rw-r--r--tools/power/acpi/tools/acpidump/Makefile12
-rw-r--r--tools/power/cpupower/utils/cpufreq-set.c7
-rw-r--r--tools/spi/spidev_test.c2
-rw-r--r--tools/testing/nvdimm/Kbuild1
-rw-r--r--tools/testing/nvdimm/test/iomap.c23
-rw-r--r--tools/testing/nvdimm/test/nfit.c236
-rw-r--r--tools/testing/nvdimm/test/nfit_test.h8
-rw-r--r--tools/virtio/ringtest/Makefile4
-rw-r--r--tools/virtio/ringtest/main.c20
-rw-r--r--tools/virtio/ringtest/main.h4
-rw-r--r--tools/virtio/ringtest/noring.c6
-rw-r--r--tools/virtio/ringtest/ptr_ring.c22
-rw-r--r--tools/virtio/ringtest/ring.c18
-rw-r--r--tools/virtio/ringtest/virtio_ring_0_9.c64
26 files changed, 462 insertions, 190 deletions
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
index 1188bc849ee3..a39629206864 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -194,6 +194,8 @@
194#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */ 194#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */
195 195
196#define X86_FEATURE_INTEL_PT ( 7*32+15) /* Intel Processor Trace */ 196#define X86_FEATURE_INTEL_PT ( 7*32+15) /* Intel Processor Trace */
197#define X86_FEATURE_AVX512_4VNNIW (7*32+16) /* AVX-512 Neural Network Instructions */
198#define X86_FEATURE_AVX512_4FMAPS (7*32+17) /* AVX-512 Multiply Accumulation Single precision */
197 199
198/* Virtualization flags: Linux defined, word 8 */ 200/* Virtualization flags: Linux defined, word 8 */
199#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */ 201#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index c0c0b265e88e..5e0dea2cdc01 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -98,6 +98,15 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
98 *type = INSN_FP_SETUP; 98 *type = INSN_FP_SETUP;
99 break; 99 break;
100 100
101 case 0x8d:
102 if (insn.rex_prefix.nbytes &&
103 insn.rex_prefix.bytes[0] == 0x48 &&
104 insn.modrm.nbytes && insn.modrm.bytes[0] == 0x2c &&
105 insn.sib.nbytes && insn.sib.bytes[0] == 0x24)
106 /* lea %(rsp), %rbp */
107 *type = INSN_FP_SETUP;
108 break;
109
101 case 0x90: 110 case 0x90:
102 *type = INSN_NOP; 111 *type = INSN_NOP;
103 break; 112 break;
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index 143b6cdd7f06..e8a1f699058a 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -97,6 +97,19 @@ static struct instruction *next_insn_same_sec(struct objtool_file *file,
97 return next; 97 return next;
98} 98}
99 99
100static bool gcov_enabled(struct objtool_file *file)
101{
102 struct section *sec;
103 struct symbol *sym;
104
105 list_for_each_entry(sec, &file->elf->sections, list)
106 list_for_each_entry(sym, &sec->symbol_list, list)
107 if (!strncmp(sym->name, "__gcov_.", 8))
108 return true;
109
110 return false;
111}
112
100#define for_each_insn(file, insn) \ 113#define for_each_insn(file, insn) \
101 list_for_each_entry(insn, &file->insn_list, list) 114 list_for_each_entry(insn, &file->insn_list, list)
102 115
@@ -713,6 +726,7 @@ static struct rela *find_switch_table(struct objtool_file *file,
713 struct instruction *insn) 726 struct instruction *insn)
714{ 727{
715 struct rela *text_rela, *rodata_rela; 728 struct rela *text_rela, *rodata_rela;
729 struct instruction *orig_insn = insn;
716 730
717 text_rela = find_rela_by_dest_range(insn->sec, insn->offset, insn->len); 731 text_rela = find_rela_by_dest_range(insn->sec, insn->offset, insn->len);
718 if (text_rela && text_rela->sym == file->rodata->sym) { 732 if (text_rela && text_rela->sym == file->rodata->sym) {
@@ -733,10 +747,16 @@ static struct rela *find_switch_table(struct objtool_file *file,
733 747
734 /* case 3 */ 748 /* case 3 */
735 func_for_each_insn_continue_reverse(file, func, insn) { 749 func_for_each_insn_continue_reverse(file, func, insn) {
736 if (insn->type == INSN_JUMP_UNCONDITIONAL || 750 if (insn->type == INSN_JUMP_DYNAMIC)
737 insn->type == INSN_JUMP_DYNAMIC)
738 break; 751 break;
739 752
753 /* allow small jumps within the range */
754 if (insn->type == INSN_JUMP_UNCONDITIONAL &&
755 insn->jump_dest &&
756 (insn->jump_dest->offset <= insn->offset ||
757 insn->jump_dest->offset > orig_insn->offset))
758 break;
759
740 text_rela = find_rela_by_dest_range(insn->sec, insn->offset, 760 text_rela = find_rela_by_dest_range(insn->sec, insn->offset,
741 insn->len); 761 insn->len);
742 if (text_rela && text_rela->sym == file->rodata->sym) 762 if (text_rela && text_rela->sym == file->rodata->sym)
@@ -1034,34 +1054,6 @@ static int validate_branch(struct objtool_file *file,
1034 return 0; 1054 return 0;
1035} 1055}
1036 1056
1037static bool is_gcov_insn(struct instruction *insn)
1038{
1039 struct rela *rela;
1040 struct section *sec;
1041 struct symbol *sym;
1042 unsigned long offset;
1043
1044 rela = find_rela_by_dest_range(insn->sec, insn->offset, insn->len);
1045 if (!rela)
1046 return false;
1047
1048 if (rela->sym->type != STT_SECTION)
1049 return false;
1050
1051 sec = rela->sym->sec;
1052 offset = rela->addend + insn->offset + insn->len - rela->offset;
1053
1054 list_for_each_entry(sym, &sec->symbol_list, list) {
1055 if (sym->type != STT_OBJECT)
1056 continue;
1057
1058 if (offset >= sym->offset && offset < sym->offset + sym->len)
1059 return (!memcmp(sym->name, "__gcov0.", 8));
1060 }
1061
1062 return false;
1063}
1064
1065static bool is_kasan_insn(struct instruction *insn) 1057static bool is_kasan_insn(struct instruction *insn)
1066{ 1058{
1067 return (insn->type == INSN_CALL && 1059 return (insn->type == INSN_CALL &&
@@ -1083,9 +1075,6 @@ static bool ignore_unreachable_insn(struct symbol *func,
1083 if (insn->type == INSN_NOP) 1075 if (insn->type == INSN_NOP)
1084 return true; 1076 return true;
1085 1077
1086 if (is_gcov_insn(insn))
1087 return true;
1088
1089 /* 1078 /*
1090 * Check if this (or a subsequent) instruction is related to 1079 * Check if this (or a subsequent) instruction is related to
1091 * CONFIG_UBSAN or CONFIG_KASAN. 1080 * CONFIG_UBSAN or CONFIG_KASAN.
@@ -1146,6 +1135,19 @@ static int validate_functions(struct objtool_file *file)
1146 ignore_unreachable_insn(func, insn)) 1135 ignore_unreachable_insn(func, insn))
1147 continue; 1136 continue;
1148 1137
1138 /*
1139 * gcov produces a lot of unreachable
1140 * instructions. If we get an unreachable
1141 * warning and the file has gcov enabled, just
1142 * ignore it, and all other such warnings for
1143 * the file.
1144 */
1145 if (!file->ignore_unreachables &&
1146 gcov_enabled(file)) {
1147 file->ignore_unreachables = true;
1148 continue;
1149 }
1150
1149 WARN_FUNC("function has unreachable instruction", insn->sec, insn->offset); 1151 WARN_FUNC("function has unreachable instruction", insn->sec, insn->offset);
1150 warnings++; 1152 warnings++;
1151 } 1153 }
diff --git a/tools/perf/jvmti/Makefile b/tools/perf/jvmti/Makefile
index 5ce61a1bda9c..df14e6b67b63 100644
--- a/tools/perf/jvmti/Makefile
+++ b/tools/perf/jvmti/Makefile
@@ -36,7 +36,7 @@ SOLIBEXT=so
36# The following works at least on fedora 23, you may need the next 36# The following works at least on fedora 23, you may need the next
37# line for other distros. 37# line for other distros.
38ifneq (,$(wildcard /usr/sbin/update-java-alternatives)) 38ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
39JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | cut -d ' ' -f 3) 39JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
40else 40else
41 ifneq (,$(wildcard /usr/sbin/alternatives)) 41 ifneq (,$(wildcard /usr/sbin/alternatives))
42 JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g') 42 JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index fb8e42c7507a..a53fef0c673b 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -601,7 +601,8 @@ int hist_browser__run(struct hist_browser *browser, const char *help)
601 u64 nr_entries; 601 u64 nr_entries;
602 hbt->timer(hbt->arg); 602 hbt->timer(hbt->arg);
603 603
604 if (hist_browser__has_filter(browser)) 604 if (hist_browser__has_filter(browser) ||
605 symbol_conf.report_hierarchy)
605 hist_browser__update_nr_entries(browser); 606 hist_browser__update_nr_entries(browser);
606 607
607 nr_entries = hist_browser__nr_entries(browser); 608 nr_entries = hist_browser__nr_entries(browser);
@@ -1336,8 +1337,8 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
1336 } 1337 }
1337 1338
1338 if (first) { 1339 if (first) {
1339 ui_browser__printf(&browser->b, "%c", folded_sign); 1340 ui_browser__printf(&browser->b, "%c ", folded_sign);
1340 width--; 1341 width -= 2;
1341 first = false; 1342 first = false;
1342 } else { 1343 } else {
1343 ui_browser__printf(&browser->b, " "); 1344 ui_browser__printf(&browser->b, " ");
@@ -1360,8 +1361,10 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
1360 width -= hpp.buf - s; 1361 width -= hpp.buf - s;
1361 } 1362 }
1362 1363
1363 ui_browser__write_nstring(&browser->b, "", hierarchy_indent); 1364 if (!first) {
1364 width -= hierarchy_indent; 1365 ui_browser__write_nstring(&browser->b, "", hierarchy_indent);
1366 width -= hierarchy_indent;
1367 }
1365 1368
1366 if (column >= browser->b.horiz_scroll) { 1369 if (column >= browser->b.horiz_scroll) {
1367 char s[2048]; 1370 char s[2048];
@@ -1380,7 +1383,13 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
1380 } 1383 }
1381 1384
1382 perf_hpp_list__for_each_format(entry->hpp_list, fmt) { 1385 perf_hpp_list__for_each_format(entry->hpp_list, fmt) {
1383 ui_browser__write_nstring(&browser->b, "", 2); 1386 if (first) {
1387 ui_browser__printf(&browser->b, "%c ", folded_sign);
1388 first = false;
1389 } else {
1390 ui_browser__write_nstring(&browser->b, "", 2);
1391 }
1392
1384 width -= 2; 1393 width -= 2;
1385 1394
1386 /* 1395 /*
@@ -1554,10 +1563,11 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
1554 int indent = hists->nr_hpp_node - 2; 1563 int indent = hists->nr_hpp_node - 2;
1555 bool first_node, first_col; 1564 bool first_node, first_col;
1556 1565
1557 ret = scnprintf(buf, size, " "); 1566 ret = scnprintf(buf, size, " ");
1558 if (advance_hpp_check(&dummy_hpp, ret)) 1567 if (advance_hpp_check(&dummy_hpp, ret))
1559 return ret; 1568 return ret;
1560 1569
1570 first_node = true;
1561 /* the first hpp_list_node is for overhead columns */ 1571 /* the first hpp_list_node is for overhead columns */
1562 fmt_node = list_first_entry(&hists->hpp_formats, 1572 fmt_node = list_first_entry(&hists->hpp_formats,
1563 struct perf_hpp_list_node, list); 1573 struct perf_hpp_list_node, list);
@@ -1572,12 +1582,16 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
1572 ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, " "); 1582 ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, " ");
1573 if (advance_hpp_check(&dummy_hpp, ret)) 1583 if (advance_hpp_check(&dummy_hpp, ret))
1574 break; 1584 break;
1585
1586 first_node = false;
1575 } 1587 }
1576 1588
1577 ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "%*s", 1589 if (!first_node) {
1578 indent * HIERARCHY_INDENT, ""); 1590 ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "%*s",
1579 if (advance_hpp_check(&dummy_hpp, ret)) 1591 indent * HIERARCHY_INDENT, "");
1580 return ret; 1592 if (advance_hpp_check(&dummy_hpp, ret))
1593 return ret;
1594 }
1581 1595
1582 first_node = true; 1596 first_node = true;
1583 list_for_each_entry_continue(fmt_node, &hists->hpp_formats, list) { 1597 list_for_each_entry_continue(fmt_node, &hists->hpp_formats, list) {
@@ -2075,8 +2089,21 @@ void hist_browser__init(struct hist_browser *browser,
2075 browser->b.use_navkeypressed = true; 2089 browser->b.use_navkeypressed = true;
2076 browser->show_headers = symbol_conf.show_hist_headers; 2090 browser->show_headers = symbol_conf.show_hist_headers;
2077 2091
2078 hists__for_each_format(hists, fmt) 2092 if (symbol_conf.report_hierarchy) {
2093 struct perf_hpp_list_node *fmt_node;
2094
2095 /* count overhead columns (in the first node) */
2096 fmt_node = list_first_entry(&hists->hpp_formats,
2097 struct perf_hpp_list_node, list);
2098 perf_hpp_list__for_each_format(&fmt_node->hpp, fmt)
2099 ++browser->b.columns;
2100
2101 /* add a single column for whole hierarchy sort keys*/
2079 ++browser->b.columns; 2102 ++browser->b.columns;
2103 } else {
2104 hists__for_each_format(hists, fmt)
2105 ++browser->b.columns;
2106 }
2080 2107
2081 hists__reset_column_width(hists); 2108 hists__reset_column_width(hists);
2082} 2109}
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 85dd0db0a127..2f3eded54b0c 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1895,7 +1895,6 @@ static int process_numa_topology(struct perf_file_section *section __maybe_unuse
1895 if (ph->needs_swap) 1895 if (ph->needs_swap)
1896 nr = bswap_32(nr); 1896 nr = bswap_32(nr);
1897 1897
1898 ph->env.nr_numa_nodes = nr;
1899 nodes = zalloc(sizeof(*nodes) * nr); 1898 nodes = zalloc(sizeof(*nodes) * nr);
1900 if (!nodes) 1899 if (!nodes)
1901 return -ENOMEM; 1900 return -ENOMEM;
@@ -1932,6 +1931,7 @@ static int process_numa_topology(struct perf_file_section *section __maybe_unuse
1932 1931
1933 free(str); 1932 free(str);
1934 } 1933 }
1934 ph->env.nr_numa_nodes = nr;
1935 ph->env.numa_nodes = nodes; 1935 ph->env.numa_nodes = nodes;
1936 return 0; 1936 return 0;
1937 1937
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index b02992efb513..a69f027368ef 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1600,18 +1600,18 @@ static void hists__hierarchy_output_resort(struct hists *hists,
1600 if (prog) 1600 if (prog)
1601 ui_progress__update(prog, 1); 1601 ui_progress__update(prog, 1);
1602 1602
1603 hists->nr_entries++;
1604 if (!he->filtered) {
1605 hists->nr_non_filtered_entries++;
1606 hists__calc_col_len(hists, he);
1607 }
1608
1603 if (!he->leaf) { 1609 if (!he->leaf) {
1604 hists__hierarchy_output_resort(hists, prog, 1610 hists__hierarchy_output_resort(hists, prog,
1605 &he->hroot_in, 1611 &he->hroot_in,
1606 &he->hroot_out, 1612 &he->hroot_out,
1607 min_callchain_hits, 1613 min_callchain_hits,
1608 use_callchain); 1614 use_callchain);
1609 hists->nr_entries++;
1610 if (!he->filtered) {
1611 hists->nr_non_filtered_entries++;
1612 hists__calc_col_len(hists, he);
1613 }
1614
1615 continue; 1615 continue;
1616 } 1616 }
1617 1617
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 9f43fda2570f..660fca05bc93 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -136,8 +136,8 @@ do { \
136group [^,{}/]*[{][^}]*[}][^,{}/]* 136group [^,{}/]*[{][^}]*[}][^,{}/]*
137event_pmu [^,{}/]+[/][^/]*[/][^,{}/]* 137event_pmu [^,{}/]+[/][^/]*[/][^,{}/]*
138event [^,{}/]+ 138event [^,{}/]+
139bpf_object .*\.(o|bpf) 139bpf_object [^,{}]+\.(o|bpf)
140bpf_source .*\.c 140bpf_source [^,{}]+\.c
141 141
142num_dec [0-9]+ 142num_dec [0-9]+
143num_hex 0x[a-fA-F0-9]+ 143num_hex 0x[a-fA-F0-9]+
diff --git a/tools/power/acpi/Makefile.config b/tools/power/acpi/Makefile.config
index a538ff44b108..a1883bbb0144 100644
--- a/tools/power/acpi/Makefile.config
+++ b/tools/power/acpi/Makefile.config
@@ -8,18 +8,19 @@
8# as published by the Free Software Foundation; version 2 8# as published by the Free Software Foundation; version 2
9# of the License. 9# of the License.
10 10
11include ../../../../scripts/Makefile.include 11ifeq ($(srctree),)
12 12srctree := $(patsubst %/,%,$(dir $(shell pwd)))
13OUTPUT=./ 13srctree := $(patsubst %/,%,$(dir $(srctree)))
14ifeq ("$(origin O)", "command line") 14#$(info Determined 'srctree' to be $(srctree))
15 OUTPUT := $(O)/
16endif 15endif
17 16
18ifneq ($(OUTPUT),) 17include $(srctree)/../../scripts/Makefile.include
19# check that the output directory actually exists 18
20OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd) 19OUTPUT=$(srctree)/
21$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) 20ifeq ("$(origin O)", "command line")
21 OUTPUT := $(O)/power/acpi/
22endif 22endif
23#$(info Determined 'OUTPUT' to be $(OUTPUT))
23 24
24# --- CONFIGURATION BEGIN --- 25# --- CONFIGURATION BEGIN ---
25 26
@@ -70,8 +71,8 @@ WARNINGS := -Wall
70WARNINGS += $(call cc-supports,-Wstrict-prototypes) 71WARNINGS += $(call cc-supports,-Wstrict-prototypes)
71WARNINGS += $(call cc-supports,-Wdeclaration-after-statement) 72WARNINGS += $(call cc-supports,-Wdeclaration-after-statement)
72 73
73KERNEL_INCLUDE := ../../../include 74KERNEL_INCLUDE := $(OUTPUT)include
74ACPICA_INCLUDE := ../../../drivers/acpi/acpica 75ACPICA_INCLUDE := $(srctree)/../../../drivers/acpi/acpica
75CFLAGS += -D_LINUX -I$(KERNEL_INCLUDE) -I$(ACPICA_INCLUDE) 76CFLAGS += -D_LINUX -I$(KERNEL_INCLUDE) -I$(ACPICA_INCLUDE)
76CFLAGS += $(WARNINGS) 77CFLAGS += $(WARNINGS)
77 78
diff --git a/tools/power/acpi/Makefile.rules b/tools/power/acpi/Makefile.rules
index ec87a9e562c0..373738338f51 100644
--- a/tools/power/acpi/Makefile.rules
+++ b/tools/power/acpi/Makefile.rules
@@ -8,28 +8,42 @@
8# as published by the Free Software Foundation; version 2 8# as published by the Free Software Foundation; version 2
9# of the License. 9# of the License.
10 10
11$(OUTPUT)$(TOOL): $(TOOL_OBJS) FORCE 11objdir := $(OUTPUT)tools/$(TOOL)/
12 $(ECHO) " LD " $@ 12toolobjs := $(addprefix $(objdir),$(TOOL_OBJS))
13 $(QUIET) $(LD) $(CFLAGS) $(LDFLAGS) $(TOOL_OBJS) -L$(OUTPUT) -o $@ 13$(OUTPUT)$(TOOL): $(toolobjs) FORCE
14 $(ECHO) " LD " $(subst $(OUTPUT),,$@)
15 $(QUIET) $(LD) $(CFLAGS) $(LDFLAGS) $(toolobjs) -L$(OUTPUT) -o $@
16 $(ECHO) " STRIP " $(subst $(OUTPUT),,$@)
14 $(QUIET) $(STRIPCMD) $@ 17 $(QUIET) $(STRIPCMD) $@
15 18
16$(OUTPUT)%.o: %.c 19$(KERNEL_INCLUDE):
17 $(ECHO) " CC " $@ 20 $(ECHO) " MKDIR " $(subst $(OUTPUT),,$@)
21 $(QUIET) mkdir -p $(KERNEL_INCLUDE)
22 $(ECHO) " CP " $(subst $(OUTPUT),,$@)
23 $(QUIET) cp -rf $(srctree)/../../../include/acpi $(KERNEL_INCLUDE)/
24
25$(objdir)%.o: %.c $(KERNEL_INCLUDE)
26 $(ECHO) " CC " $(subst $(OUTPUT),,$@)
18 $(QUIET) $(CC) -c $(CFLAGS) -o $@ $< 27 $(QUIET) $(CC) -c $(CFLAGS) -o $@ $<
19 28
20all: $(OUTPUT)$(TOOL) 29all: $(OUTPUT)$(TOOL)
21clean: 30clean:
22 -find $(OUTPUT) \( -not -type d \) \ 31 $(ECHO) " RMOBJ " $(subst $(OUTPUT),,$(objdir))
23 -and \( -name '*~' -o -name '*.[oas]' \) \ 32 $(QUIET) find $(objdir) \( -not -type d \)\
24 -type f -print \ 33 -and \( -name '*~' -o -name '*.[oas]' \)\
25 | xargs rm -f 34 -type f -print | xargs rm -f
26 -rm -f $(OUTPUT)$(TOOL) 35 $(ECHO) " RM " $(TOOL)
36 $(QUIET) rm -f $(OUTPUT)$(TOOL)
37 $(ECHO) " RMINC " $(subst $(OUTPUT),,$(KERNEL_INCLUDE))
38 $(QUIET) rm -rf $(KERNEL_INCLUDE)
27 39
28install-tools: 40install-tools:
29 $(INSTALL) -d $(DESTDIR)${sbindir} 41 $(ECHO) " INST " $(TOOL)
30 $(INSTALL_PROGRAM) $(OUTPUT)$(TOOL) $(DESTDIR)${sbindir} 42 $(QUIET) $(INSTALL) -d $(DESTDIR)$(sbindir)
43 $(QUIET) $(INSTALL_PROGRAM) $(OUTPUT)$(TOOL) $(DESTDIR)$(sbindir)
31uninstall-tools: 44uninstall-tools:
32 - rm -f $(DESTDIR)${sbindir}/$(TOOL) 45 $(ECHO) " UNINST " $(TOOL)
46 $(QUIET) rm -f $(DESTDIR)$(sbindir)/$(TOOL)
33 47
34install: all install-tools $(EXTRA_INSTALL) 48install: all install-tools $(EXTRA_INSTALL)
35uninstall: uninstall-tools $(EXTRA_UNINSTALL) 49uninstall: uninstall-tools $(EXTRA_UNINSTALL)
diff --git a/tools/power/acpi/tools/acpidbg/Makefile b/tools/power/acpi/tools/acpidbg/Makefile
index 352df4b41ae9..f2d06e773eb4 100644
--- a/tools/power/acpi/tools/acpidbg/Makefile
+++ b/tools/power/acpi/tools/acpidbg/Makefile
@@ -17,9 +17,7 @@ vpath %.c \
17 ../../os_specific/service_layers\ 17 ../../os_specific/service_layers\
18 . 18 .
19CFLAGS += -DACPI_APPLICATION -DACPI_SINGLE_THREAD -DACPI_DEBUGGER\ 19CFLAGS += -DACPI_APPLICATION -DACPI_SINGLE_THREAD -DACPI_DEBUGGER\
20 -I.\ 20 -I.
21 -I../../../../../drivers/acpi/acpica\
22 -I../../../../../include
23LDFLAGS += -lpthread 21LDFLAGS += -lpthread
24TOOL_OBJS = \ 22TOOL_OBJS = \
25 acpidbg.o 23 acpidbg.o
diff --git a/tools/power/acpi/tools/acpidbg/acpidbg.c b/tools/power/acpi/tools/acpidbg/acpidbg.c
index a88ac45b7756..4308362d7068 100644
--- a/tools/power/acpi/tools/acpidbg/acpidbg.c
+++ b/tools/power/acpi/tools/acpidbg/acpidbg.c
@@ -12,10 +12,16 @@
12#include <acpi/acpi.h> 12#include <acpi/acpi.h>
13 13
14/* Headers not included by include/acpi/platform/aclinux.h */ 14/* Headers not included by include/acpi/platform/aclinux.h */
15#include <unistd.h>
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19#include <error.h>
15#include <stdbool.h> 20#include <stdbool.h>
16#include <fcntl.h> 21#include <fcntl.h>
17#include <assert.h> 22#include <assert.h>
18#include <linux/circ_buf.h> 23#include <sys/select.h>
24#include "../../../../../include/linux/circ_buf.h"
19 25
20#define ACPI_AML_FILE "/sys/kernel/debug/acpi/acpidbg" 26#define ACPI_AML_FILE "/sys/kernel/debug/acpi/acpidbg"
21#define ACPI_AML_SEC_TICK 1 27#define ACPI_AML_SEC_TICK 1
diff --git a/tools/power/acpi/tools/acpidump/Makefile b/tools/power/acpi/tools/acpidump/Makefile
index 04b5db7c7c0b..f7c7af1f9258 100644
--- a/tools/power/acpi/tools/acpidump/Makefile
+++ b/tools/power/acpi/tools/acpidump/Makefile
@@ -19,9 +19,7 @@ vpath %.c \
19 ./\ 19 ./\
20 ../../common\ 20 ../../common\
21 ../../os_specific/service_layers 21 ../../os_specific/service_layers
22CFLAGS += -DACPI_DUMP_APP -I.\ 22CFLAGS += -DACPI_DUMP_APP -I.
23 -I../../../../../drivers/acpi/acpica\
24 -I../../../../../include
25TOOL_OBJS = \ 23TOOL_OBJS = \
26 apdump.o\ 24 apdump.o\
27 apfiles.o\ 25 apfiles.o\
@@ -49,7 +47,9 @@ TOOL_OBJS = \
49 47
50include ../../Makefile.rules 48include ../../Makefile.rules
51 49
52install-man: ../../man/acpidump.8 50install-man: $(srctree)/man/acpidump.8
53 $(INSTALL_DATA) -D $< $(DESTDIR)${mandir}/man8/acpidump.8 51 $(ECHO) " INST " acpidump.8
52 $(QUIET) $(INSTALL_DATA) -D $< $(DESTDIR)$(mandir)/man8/acpidump.8
54uninstall-man: 53uninstall-man:
55 - rm -f $(DESTDIR)${mandir}/man8/acpidump.8 54 $(ECHO) " UNINST " acpidump.8
55 $(QUIET) rm -f $(DESTDIR)$(mandir)/man8/acpidump.8
diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c
index b4bf76971dc9..1eef0aed6423 100644
--- a/tools/power/cpupower/utils/cpufreq-set.c
+++ b/tools/power/cpupower/utils/cpufreq-set.c
@@ -296,7 +296,7 @@ int cmd_freq_set(int argc, char **argv)
296 struct cpufreq_affected_cpus *cpus; 296 struct cpufreq_affected_cpus *cpus;
297 297
298 if (!bitmask_isbitset(cpus_chosen, cpu) || 298 if (!bitmask_isbitset(cpus_chosen, cpu) ||
299 cpupower_is_cpu_online(cpu)) 299 cpupower_is_cpu_online(cpu) != 1)
300 continue; 300 continue;
301 301
302 cpus = cpufreq_get_related_cpus(cpu); 302 cpus = cpufreq_get_related_cpus(cpu);
@@ -316,10 +316,7 @@ int cmd_freq_set(int argc, char **argv)
316 cpu <= bitmask_last(cpus_chosen); cpu++) { 316 cpu <= bitmask_last(cpus_chosen); cpu++) {
317 317
318 if (!bitmask_isbitset(cpus_chosen, cpu) || 318 if (!bitmask_isbitset(cpus_chosen, cpu) ||
319 cpupower_is_cpu_online(cpu)) 319 cpupower_is_cpu_online(cpu) != 1)
320 continue;
321
322 if (cpupower_is_cpu_online(cpu) != 1)
323 continue; 320 continue;
324 321
325 printf(_("Setting cpu: %d\n"), cpu); 322 printf(_("Setting cpu: %d\n"), cpu);
diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c
index f046b77cfefe..816f119c9b7b 100644
--- a/tools/spi/spidev_test.c
+++ b/tools/spi/spidev_test.c
@@ -315,7 +315,7 @@ static void transfer_file(int fd, char *filename)
315 pabort("can't stat input file"); 315 pabort("can't stat input file");
316 316
317 tx_fd = open(filename, O_RDONLY); 317 tx_fd = open(filename, O_RDONLY);
318 if (fd < 0) 318 if (tx_fd < 0)
319 pabort("can't open input file"); 319 pabort("can't open input file");
320 320
321 tx = malloc(sb.st_size); 321 tx = malloc(sb.st_size);
diff --git a/tools/testing/nvdimm/Kbuild b/tools/testing/nvdimm/Kbuild
index 582db95127ed..405212be044a 100644
--- a/tools/testing/nvdimm/Kbuild
+++ b/tools/testing/nvdimm/Kbuild
@@ -14,6 +14,7 @@ ldflags-y += --wrap=devm_memremap_pages
14ldflags-y += --wrap=insert_resource 14ldflags-y += --wrap=insert_resource
15ldflags-y += --wrap=remove_resource 15ldflags-y += --wrap=remove_resource
16ldflags-y += --wrap=acpi_evaluate_object 16ldflags-y += --wrap=acpi_evaluate_object
17ldflags-y += --wrap=acpi_evaluate_dsm
17 18
18DRIVERS := ../../../drivers 19DRIVERS := ../../../drivers
19NVDIMM_SRC := $(DRIVERS)/nvdimm 20NVDIMM_SRC := $(DRIVERS)/nvdimm
diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c
index 3ccef732fce9..64cae1a5deff 100644
--- a/tools/testing/nvdimm/test/iomap.c
+++ b/tools/testing/nvdimm/test/iomap.c
@@ -26,14 +26,17 @@ static LIST_HEAD(iomap_head);
26 26
27static struct iomap_ops { 27static struct iomap_ops {
28 nfit_test_lookup_fn nfit_test_lookup; 28 nfit_test_lookup_fn nfit_test_lookup;
29 nfit_test_evaluate_dsm_fn evaluate_dsm;
29 struct list_head list; 30 struct list_head list;
30} iomap_ops = { 31} iomap_ops = {
31 .list = LIST_HEAD_INIT(iomap_ops.list), 32 .list = LIST_HEAD_INIT(iomap_ops.list),
32}; 33};
33 34
34void nfit_test_setup(nfit_test_lookup_fn lookup) 35void nfit_test_setup(nfit_test_lookup_fn lookup,
36 nfit_test_evaluate_dsm_fn evaluate)
35{ 37{
36 iomap_ops.nfit_test_lookup = lookup; 38 iomap_ops.nfit_test_lookup = lookup;
39 iomap_ops.evaluate_dsm = evaluate;
37 list_add_rcu(&iomap_ops.list, &iomap_head); 40 list_add_rcu(&iomap_ops.list, &iomap_head);
38} 41}
39EXPORT_SYMBOL(nfit_test_setup); 42EXPORT_SYMBOL(nfit_test_setup);
@@ -367,4 +370,22 @@ acpi_status __wrap_acpi_evaluate_object(acpi_handle handle, acpi_string path,
367} 370}
368EXPORT_SYMBOL(__wrap_acpi_evaluate_object); 371EXPORT_SYMBOL(__wrap_acpi_evaluate_object);
369 372
373union acpi_object * __wrap_acpi_evaluate_dsm(acpi_handle handle, const u8 *uuid,
374 u64 rev, u64 func, union acpi_object *argv4)
375{
376 union acpi_object *obj = ERR_PTR(-ENXIO);
377 struct iomap_ops *ops;
378
379 rcu_read_lock();
380 ops = list_first_or_null_rcu(&iomap_head, typeof(*ops), list);
381 if (ops)
382 obj = ops->evaluate_dsm(handle, uuid, rev, func, argv4);
383 rcu_read_unlock();
384
385 if (IS_ERR(obj))
386 return acpi_evaluate_dsm(handle, uuid, rev, func, argv4);
387 return obj;
388}
389EXPORT_SYMBOL(__wrap_acpi_evaluate_dsm);
390
370MODULE_LICENSE("GPL v2"); 391MODULE_LICENSE("GPL v2");
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index c9a6458cb63e..71620fa95953 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -23,6 +23,7 @@
23#include <linux/sizes.h> 23#include <linux/sizes.h>
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <nd-core.h>
26#include <nfit.h> 27#include <nfit.h>
27#include <nd.h> 28#include <nd.h>
28#include "nfit_test.h" 29#include "nfit_test.h"
@@ -1506,6 +1507,225 @@ static int nfit_test_blk_do_io(struct nd_blk_region *ndbr, resource_size_t dpa,
1506 return 0; 1507 return 0;
1507} 1508}
1508 1509
1510static unsigned long nfit_ctl_handle;
1511
1512union acpi_object *result;
1513
1514static union acpi_object *nfit_test_evaluate_dsm(acpi_handle handle,
1515 const u8 *uuid, u64 rev, u64 func, union acpi_object *argv4)
1516{
1517 if (handle != &nfit_ctl_handle)
1518 return ERR_PTR(-ENXIO);
1519
1520 return result;
1521}
1522
1523static int setup_result(void *buf, size_t size)
1524{
1525 result = kmalloc(sizeof(union acpi_object) + size, GFP_KERNEL);
1526 if (!result)
1527 return -ENOMEM;
1528 result->package.type = ACPI_TYPE_BUFFER,
1529 result->buffer.pointer = (void *) (result + 1);
1530 result->buffer.length = size;
1531 memcpy(result->buffer.pointer, buf, size);
1532 memset(buf, 0, size);
1533 return 0;
1534}
1535
1536static int nfit_ctl_test(struct device *dev)
1537{
1538 int rc, cmd_rc;
1539 struct nvdimm *nvdimm;
1540 struct acpi_device *adev;
1541 struct nfit_mem *nfit_mem;
1542 struct nd_ars_record *record;
1543 struct acpi_nfit_desc *acpi_desc;
1544 const u64 test_val = 0x0123456789abcdefULL;
1545 unsigned long mask, cmd_size, offset;
1546 union {
1547 struct nd_cmd_get_config_size cfg_size;
1548 struct nd_cmd_ars_status ars_stat;
1549 struct nd_cmd_ars_cap ars_cap;
1550 char buf[sizeof(struct nd_cmd_ars_status)
1551 + sizeof(struct nd_ars_record)];
1552 } cmds;
1553
1554 adev = devm_kzalloc(dev, sizeof(*adev), GFP_KERNEL);
1555 if (!adev)
1556 return -ENOMEM;
1557 *adev = (struct acpi_device) {
1558 .handle = &nfit_ctl_handle,
1559 .dev = {
1560 .init_name = "test-adev",
1561 },
1562 };
1563
1564 acpi_desc = devm_kzalloc(dev, sizeof(*acpi_desc), GFP_KERNEL);
1565 if (!acpi_desc)
1566 return -ENOMEM;
1567 *acpi_desc = (struct acpi_nfit_desc) {
1568 .nd_desc = {
1569 .cmd_mask = 1UL << ND_CMD_ARS_CAP
1570 | 1UL << ND_CMD_ARS_START
1571 | 1UL << ND_CMD_ARS_STATUS
1572 | 1UL << ND_CMD_CLEAR_ERROR,
1573 .module = THIS_MODULE,
1574 .provider_name = "ACPI.NFIT",
1575 .ndctl = acpi_nfit_ctl,
1576 },
1577 .dev = &adev->dev,
1578 };
1579
1580 nfit_mem = devm_kzalloc(dev, sizeof(*nfit_mem), GFP_KERNEL);
1581 if (!nfit_mem)
1582 return -ENOMEM;
1583
1584 mask = 1UL << ND_CMD_SMART | 1UL << ND_CMD_SMART_THRESHOLD
1585 | 1UL << ND_CMD_DIMM_FLAGS | 1UL << ND_CMD_GET_CONFIG_SIZE
1586 | 1UL << ND_CMD_GET_CONFIG_DATA | 1UL << ND_CMD_SET_CONFIG_DATA
1587 | 1UL << ND_CMD_VENDOR;
1588 *nfit_mem = (struct nfit_mem) {
1589 .adev = adev,
1590 .family = NVDIMM_FAMILY_INTEL,
1591 .dsm_mask = mask,
1592 };
1593
1594 nvdimm = devm_kzalloc(dev, sizeof(*nvdimm), GFP_KERNEL);
1595 if (!nvdimm)
1596 return -ENOMEM;
1597 *nvdimm = (struct nvdimm) {
1598 .provider_data = nfit_mem,
1599 .cmd_mask = mask,
1600 .dev = {
1601 .init_name = "test-dimm",
1602 },
1603 };
1604
1605
1606 /* basic checkout of a typical 'get config size' command */
1607 cmd_size = sizeof(cmds.cfg_size);
1608 cmds.cfg_size = (struct nd_cmd_get_config_size) {
1609 .status = 0,
1610 .config_size = SZ_128K,
1611 .max_xfer = SZ_4K,
1612 };
1613 rc = setup_result(cmds.buf, cmd_size);
1614 if (rc)
1615 return rc;
1616 rc = acpi_nfit_ctl(&acpi_desc->nd_desc, nvdimm, ND_CMD_GET_CONFIG_SIZE,
1617 cmds.buf, cmd_size, &cmd_rc);
1618
1619 if (rc < 0 || cmd_rc || cmds.cfg_size.status != 0
1620 || cmds.cfg_size.config_size != SZ_128K
1621 || cmds.cfg_size.max_xfer != SZ_4K) {
1622 dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
1623 __func__, __LINE__, rc, cmd_rc);
1624 return -EIO;
1625 }
1626
1627
1628 /* test ars_status with zero output */
1629 cmd_size = offsetof(struct nd_cmd_ars_status, address);
1630 cmds.ars_stat = (struct nd_cmd_ars_status) {
1631 .out_length = 0,
1632 };
1633 rc = setup_result(cmds.buf, cmd_size);
1634 if (rc)
1635 return rc;
1636 rc = acpi_nfit_ctl(&acpi_desc->nd_desc, NULL, ND_CMD_ARS_STATUS,
1637 cmds.buf, cmd_size, &cmd_rc);
1638
1639 if (rc < 0 || cmd_rc) {
1640 dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
1641 __func__, __LINE__, rc, cmd_rc);
1642 return -EIO;
1643 }
1644
1645
1646 /* test ars_cap with benign extended status */
1647 cmd_size = sizeof(cmds.ars_cap);
1648 cmds.ars_cap = (struct nd_cmd_ars_cap) {
1649 .status = ND_ARS_PERSISTENT << 16,
1650 };
1651 offset = offsetof(struct nd_cmd_ars_cap, status);
1652 rc = setup_result(cmds.buf + offset, cmd_size - offset);
1653 if (rc)
1654 return rc;
1655 rc = acpi_nfit_ctl(&acpi_desc->nd_desc, NULL, ND_CMD_ARS_CAP,
1656 cmds.buf, cmd_size, &cmd_rc);
1657
1658 if (rc < 0 || cmd_rc) {
1659 dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
1660 __func__, __LINE__, rc, cmd_rc);
1661 return -EIO;
1662 }
1663
1664
1665 /* test ars_status with 'status' trimmed from 'out_length' */
1666 cmd_size = sizeof(cmds.ars_stat) + sizeof(struct nd_ars_record);
1667 cmds.ars_stat = (struct nd_cmd_ars_status) {
1668 .out_length = cmd_size - 4,
1669 };
1670 record = &cmds.ars_stat.records[0];
1671 *record = (struct nd_ars_record) {
1672 .length = test_val,
1673 };
1674 rc = setup_result(cmds.buf, cmd_size);
1675 if (rc)
1676 return rc;
1677 rc = acpi_nfit_ctl(&acpi_desc->nd_desc, NULL, ND_CMD_ARS_STATUS,
1678 cmds.buf, cmd_size, &cmd_rc);
1679
1680 if (rc < 0 || cmd_rc || record->length != test_val) {
1681 dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
1682 __func__, __LINE__, rc, cmd_rc);
1683 return -EIO;
1684 }
1685
1686
1687 /* test ars_status with 'Output (Size)' including 'status' */
1688 cmd_size = sizeof(cmds.ars_stat) + sizeof(struct nd_ars_record);
1689 cmds.ars_stat = (struct nd_cmd_ars_status) {
1690 .out_length = cmd_size,
1691 };
1692 record = &cmds.ars_stat.records[0];
1693 *record = (struct nd_ars_record) {
1694 .length = test_val,
1695 };
1696 rc = setup_result(cmds.buf, cmd_size);
1697 if (rc)
1698 return rc;
1699 rc = acpi_nfit_ctl(&acpi_desc->nd_desc, NULL, ND_CMD_ARS_STATUS,
1700 cmds.buf, cmd_size, &cmd_rc);
1701
1702 if (rc < 0 || cmd_rc || record->length != test_val) {
1703 dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
1704 __func__, __LINE__, rc, cmd_rc);
1705 return -EIO;
1706 }
1707
1708
1709 /* test extended status for get_config_size results in failure */
1710 cmd_size = sizeof(cmds.cfg_size);
1711 cmds.cfg_size = (struct nd_cmd_get_config_size) {
1712 .status = 1 << 16,
1713 };
1714 rc = setup_result(cmds.buf, cmd_size);
1715 if (rc)
1716 return rc;
1717 rc = acpi_nfit_ctl(&acpi_desc->nd_desc, nvdimm, ND_CMD_GET_CONFIG_SIZE,
1718 cmds.buf, cmd_size, &cmd_rc);
1719
1720 if (rc < 0 || cmd_rc >= 0) {
1721 dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
1722 __func__, __LINE__, rc, cmd_rc);
1723 return -EIO;
1724 }
1725
1726 return 0;
1727}
1728
1509static int nfit_test_probe(struct platform_device *pdev) 1729static int nfit_test_probe(struct platform_device *pdev)
1510{ 1730{
1511 struct nvdimm_bus_descriptor *nd_desc; 1731 struct nvdimm_bus_descriptor *nd_desc;
@@ -1516,6 +1736,12 @@ static int nfit_test_probe(struct platform_device *pdev)
1516 union acpi_object *obj; 1736 union acpi_object *obj;
1517 int rc; 1737 int rc;
1518 1738
1739 if (strcmp(dev_name(&pdev->dev), "nfit_test.0") == 0) {
1740 rc = nfit_ctl_test(&pdev->dev);
1741 if (rc)
1742 return rc;
1743 }
1744
1519 nfit_test = to_nfit_test(&pdev->dev); 1745 nfit_test = to_nfit_test(&pdev->dev);
1520 1746
1521 /* common alloc */ 1747 /* common alloc */
@@ -1639,11 +1865,13 @@ static __init int nfit_test_init(void)
1639{ 1865{
1640 int rc, i; 1866 int rc, i;
1641 1867
1642 nfit_test_dimm = class_create(THIS_MODULE, "nfit_test_dimm"); 1868 nfit_test_setup(nfit_test_lookup, nfit_test_evaluate_dsm);
1643 if (IS_ERR(nfit_test_dimm))
1644 return PTR_ERR(nfit_test_dimm);
1645 1869
1646 nfit_test_setup(nfit_test_lookup); 1870 nfit_test_dimm = class_create(THIS_MODULE, "nfit_test_dimm");
1871 if (IS_ERR(nfit_test_dimm)) {
1872 rc = PTR_ERR(nfit_test_dimm);
1873 goto err_register;
1874 }
1647 1875
1648 for (i = 0; i < NUM_NFITS; i++) { 1876 for (i = 0; i < NUM_NFITS; i++) {
1649 struct nfit_test *nfit_test; 1877 struct nfit_test *nfit_test;
diff --git a/tools/testing/nvdimm/test/nfit_test.h b/tools/testing/nvdimm/test/nfit_test.h
index c281dd2e5e2d..f54c0032c6ff 100644
--- a/tools/testing/nvdimm/test/nfit_test.h
+++ b/tools/testing/nvdimm/test/nfit_test.h
@@ -31,11 +31,17 @@ struct nfit_test_resource {
31 void *buf; 31 void *buf;
32}; 32};
33 33
34union acpi_object;
35typedef void *acpi_handle;
36
34typedef struct nfit_test_resource *(*nfit_test_lookup_fn)(resource_size_t); 37typedef struct nfit_test_resource *(*nfit_test_lookup_fn)(resource_size_t);
38typedef union acpi_object *(*nfit_test_evaluate_dsm_fn)(acpi_handle handle,
39 const u8 *uuid, u64 rev, u64 func, union acpi_object *argv4);
35void __iomem *__wrap_ioremap_nocache(resource_size_t offset, 40void __iomem *__wrap_ioremap_nocache(resource_size_t offset,
36 unsigned long size); 41 unsigned long size);
37void __wrap_iounmap(volatile void __iomem *addr); 42void __wrap_iounmap(volatile void __iomem *addr);
38void nfit_test_setup(nfit_test_lookup_fn lookup); 43void nfit_test_setup(nfit_test_lookup_fn lookup,
44 nfit_test_evaluate_dsm_fn evaluate);
39void nfit_test_teardown(void); 45void nfit_test_teardown(void);
40struct nfit_test_resource *get_nfit_res(resource_size_t resource); 46struct nfit_test_resource *get_nfit_res(resource_size_t resource);
41#endif 47#endif
diff --git a/tools/virtio/ringtest/Makefile b/tools/virtio/ringtest/Makefile
index 877a8a4721b6..c012edbdb13b 100644
--- a/tools/virtio/ringtest/Makefile
+++ b/tools/virtio/ringtest/Makefile
@@ -3,8 +3,8 @@ all:
3all: ring virtio_ring_0_9 virtio_ring_poll virtio_ring_inorder ptr_ring noring 3all: ring virtio_ring_0_9 virtio_ring_poll virtio_ring_inorder ptr_ring noring
4 4
5CFLAGS += -Wall 5CFLAGS += -Wall
6CFLAGS += -pthread -O2 -ggdb 6CFLAGS += -pthread -O2 -ggdb -flto -fwhole-program
7LDFLAGS += -pthread -O2 -ggdb 7LDFLAGS += -pthread -O2 -ggdb -flto -fwhole-program
8 8
9main.o: main.c main.h 9main.o: main.c main.h
10ring.o: ring.c main.h 10ring.o: ring.c main.h
diff --git a/tools/virtio/ringtest/main.c b/tools/virtio/ringtest/main.c
index 147abb452a6c..f31353fac541 100644
--- a/tools/virtio/ringtest/main.c
+++ b/tools/virtio/ringtest/main.c
@@ -96,7 +96,13 @@ void set_affinity(const char *arg)
96 assert(!ret); 96 assert(!ret);
97} 97}
98 98
99static void run_guest(void) 99void poll_used(void)
100{
101 while (used_empty())
102 busy_wait();
103}
104
105static void __attribute__((__flatten__)) run_guest(void)
100{ 106{
101 int completed_before; 107 int completed_before;
102 int completed = 0; 108 int completed = 0;
@@ -141,7 +147,7 @@ static void run_guest(void)
141 assert(completed <= bufs); 147 assert(completed <= bufs);
142 assert(started <= bufs); 148 assert(started <= bufs);
143 if (do_sleep) { 149 if (do_sleep) {
144 if (enable_call()) 150 if (used_empty() && enable_call())
145 wait_for_call(); 151 wait_for_call();
146 } else { 152 } else {
147 poll_used(); 153 poll_used();
@@ -149,7 +155,13 @@ static void run_guest(void)
149 } 155 }
150} 156}
151 157
152static void run_host(void) 158void poll_avail(void)
159{
160 while (avail_empty())
161 busy_wait();
162}
163
164static void __attribute__((__flatten__)) run_host(void)
153{ 165{
154 int completed_before; 166 int completed_before;
155 int completed = 0; 167 int completed = 0;
@@ -160,7 +172,7 @@ static void run_host(void)
160 172
161 for (;;) { 173 for (;;) {
162 if (do_sleep) { 174 if (do_sleep) {
163 if (enable_kick()) 175 if (avail_empty() && enable_kick())
164 wait_for_kick(); 176 wait_for_kick();
165 } else { 177 } else {
166 poll_avail(); 178 poll_avail();
diff --git a/tools/virtio/ringtest/main.h b/tools/virtio/ringtest/main.h
index 16917acb0ade..34e63cc4c572 100644
--- a/tools/virtio/ringtest/main.h
+++ b/tools/virtio/ringtest/main.h
@@ -56,15 +56,15 @@ void alloc_ring(void);
56int add_inbuf(unsigned, void *, void *); 56int add_inbuf(unsigned, void *, void *);
57void *get_buf(unsigned *, void **); 57void *get_buf(unsigned *, void **);
58void disable_call(); 58void disable_call();
59bool used_empty();
59bool enable_call(); 60bool enable_call();
60void kick_available(); 61void kick_available();
61void poll_used();
62/* host side */ 62/* host side */
63void disable_kick(); 63void disable_kick();
64bool avail_empty();
64bool enable_kick(); 65bool enable_kick();
65bool use_buf(unsigned *, void **); 66bool use_buf(unsigned *, void **);
66void call_used(); 67void call_used();
67void poll_avail();
68 68
69/* implemented by main */ 69/* implemented by main */
70extern bool do_sleep; 70extern bool do_sleep;
diff --git a/tools/virtio/ringtest/noring.c b/tools/virtio/ringtest/noring.c
index eda2f4824130..b8d1c1daac7c 100644
--- a/tools/virtio/ringtest/noring.c
+++ b/tools/virtio/ringtest/noring.c
@@ -24,8 +24,9 @@ void *get_buf(unsigned *lenp, void **bufp)
24 return "Buffer"; 24 return "Buffer";
25} 25}
26 26
27void poll_used(void) 27bool used_empty()
28{ 28{
29 return false;
29} 30}
30 31
31void disable_call() 32void disable_call()
@@ -54,8 +55,9 @@ bool enable_kick()
54 assert(0); 55 assert(0);
55} 56}
56 57
57void poll_avail(void) 58bool avail_empty()
58{ 59{
60 return false;
59} 61}
60 62
61bool use_buf(unsigned *lenp, void **bufp) 63bool use_buf(unsigned *lenp, void **bufp)
diff --git a/tools/virtio/ringtest/ptr_ring.c b/tools/virtio/ringtest/ptr_ring.c
index bd2ad1d3b7a9..635b07b4fdd3 100644
--- a/tools/virtio/ringtest/ptr_ring.c
+++ b/tools/virtio/ringtest/ptr_ring.c
@@ -133,18 +133,9 @@ void *get_buf(unsigned *lenp, void **bufp)
133 return datap; 133 return datap;
134} 134}
135 135
136void poll_used(void) 136bool used_empty()
137{ 137{
138 void *b; 138 return (tailcnt == headcnt || __ptr_ring_full(&array));
139
140 do {
141 if (tailcnt == headcnt || __ptr_ring_full(&array)) {
142 b = NULL;
143 barrier();
144 } else {
145 b = "Buffer\n";
146 }
147 } while (!b);
148} 139}
149 140
150void disable_call() 141void disable_call()
@@ -173,14 +164,9 @@ bool enable_kick()
173 assert(0); 164 assert(0);
174} 165}
175 166
176void poll_avail(void) 167bool avail_empty()
177{ 168{
178 void *b; 169 return !__ptr_ring_peek(&array);
179
180 do {
181 barrier();
182 b = __ptr_ring_peek(&array);
183 } while (!b);
184} 170}
185 171
186bool use_buf(unsigned *lenp, void **bufp) 172bool use_buf(unsigned *lenp, void **bufp)
diff --git a/tools/virtio/ringtest/ring.c b/tools/virtio/ringtest/ring.c
index c25c8d248b6b..747c5dd47be8 100644
--- a/tools/virtio/ringtest/ring.c
+++ b/tools/virtio/ringtest/ring.c
@@ -163,12 +163,11 @@ void *get_buf(unsigned *lenp, void **bufp)
163 return datap; 163 return datap;
164} 164}
165 165
166void poll_used(void) 166bool used_empty()
167{ 167{
168 unsigned head = (ring_size - 1) & guest.last_used_idx; 168 unsigned head = (ring_size - 1) & guest.last_used_idx;
169 169
170 while (ring[head].flags & DESC_HW) 170 return (ring[head].flags & DESC_HW);
171 busy_wait();
172} 171}
173 172
174void disable_call() 173void disable_call()
@@ -180,13 +179,11 @@ void disable_call()
180 179
181bool enable_call() 180bool enable_call()
182{ 181{
183 unsigned head = (ring_size - 1) & guest.last_used_idx;
184
185 event->call_index = guest.last_used_idx; 182 event->call_index = guest.last_used_idx;
186 /* Flush call index write */ 183 /* Flush call index write */
187 /* Barrier D (for pairing) */ 184 /* Barrier D (for pairing) */
188 smp_mb(); 185 smp_mb();
189 return ring[head].flags & DESC_HW; 186 return used_empty();
190} 187}
191 188
192void kick_available(void) 189void kick_available(void)
@@ -213,20 +210,17 @@ void disable_kick()
213 210
214bool enable_kick() 211bool enable_kick()
215{ 212{
216 unsigned head = (ring_size - 1) & host.used_idx;
217
218 event->kick_index = host.used_idx; 213 event->kick_index = host.used_idx;
219 /* Barrier C (for pairing) */ 214 /* Barrier C (for pairing) */
220 smp_mb(); 215 smp_mb();
221 return !(ring[head].flags & DESC_HW); 216 return avail_empty();
222} 217}
223 218
224void poll_avail(void) 219bool avail_empty()
225{ 220{
226 unsigned head = (ring_size - 1) & host.used_idx; 221 unsigned head = (ring_size - 1) & host.used_idx;
227 222
228 while (!(ring[head].flags & DESC_HW)) 223 return !(ring[head].flags & DESC_HW);
229 busy_wait();
230} 224}
231 225
232bool use_buf(unsigned *lenp, void **bufp) 226bool use_buf(unsigned *lenp, void **bufp)
diff --git a/tools/virtio/ringtest/virtio_ring_0_9.c b/tools/virtio/ringtest/virtio_ring_0_9.c
index 761866212aac..bbc3043b2fb1 100644
--- a/tools/virtio/ringtest/virtio_ring_0_9.c
+++ b/tools/virtio/ringtest/virtio_ring_0_9.c
@@ -194,24 +194,16 @@ void *get_buf(unsigned *lenp, void **bufp)
194 return datap; 194 return datap;
195} 195}
196 196
197void poll_used(void) 197bool used_empty()
198{ 198{
199 unsigned short last_used_idx = guest.last_used_idx;
199#ifdef RING_POLL 200#ifdef RING_POLL
200 unsigned head = (ring_size - 1) & guest.last_used_idx; 201 unsigned short head = last_used_idx & (ring_size - 1);
202 unsigned index = ring.used->ring[head].id;
201 203
202 for (;;) { 204 return (index ^ last_used_idx ^ 0x8000) & ~(ring_size - 1);
203 unsigned index = ring.used->ring[head].id;
204
205 if ((index ^ guest.last_used_idx ^ 0x8000) & ~(ring_size - 1))
206 busy_wait();
207 else
208 break;
209 }
210#else 205#else
211 unsigned head = guest.last_used_idx; 206 return ring.used->idx == last_used_idx;
212
213 while (ring.used->idx == head)
214 busy_wait();
215#endif 207#endif
216} 208}
217 209
@@ -224,22 +216,11 @@ void disable_call()
224 216
225bool enable_call() 217bool enable_call()
226{ 218{
227 unsigned short last_used_idx; 219 vring_used_event(&ring) = guest.last_used_idx;
228
229 vring_used_event(&ring) = (last_used_idx = guest.last_used_idx);
230 /* Flush call index write */ 220 /* Flush call index write */
231 /* Barrier D (for pairing) */ 221 /* Barrier D (for pairing) */
232 smp_mb(); 222 smp_mb();
233#ifdef RING_POLL 223 return used_empty();
234 {
235 unsigned short head = last_used_idx & (ring_size - 1);
236 unsigned index = ring.used->ring[head].id;
237
238 return (index ^ last_used_idx ^ 0x8000) & ~(ring_size - 1);
239 }
240#else
241 return ring.used->idx == last_used_idx;
242#endif
243} 224}
244 225
245void kick_available(void) 226void kick_available(void)
@@ -266,36 +247,21 @@ void disable_kick()
266 247
267bool enable_kick() 248bool enable_kick()
268{ 249{
269 unsigned head = host.used_idx; 250 vring_avail_event(&ring) = host.used_idx;
270
271 vring_avail_event(&ring) = head;
272 /* Barrier C (for pairing) */ 251 /* Barrier C (for pairing) */
273 smp_mb(); 252 smp_mb();
274#ifdef RING_POLL 253 return avail_empty();
275 {
276 unsigned index = ring.avail->ring[head & (ring_size - 1)];
277
278 return (index ^ head ^ 0x8000) & ~(ring_size - 1);
279 }
280#else
281 return head == ring.avail->idx;
282#endif
283} 254}
284 255
285void poll_avail(void) 256bool avail_empty()
286{ 257{
287 unsigned head = host.used_idx; 258 unsigned head = host.used_idx;
288#ifdef RING_POLL 259#ifdef RING_POLL
289 for (;;) { 260 unsigned index = ring.avail->ring[head & (ring_size - 1)];
290 unsigned index = ring.avail->ring[head & (ring_size - 1)]; 261
291 if ((index ^ head ^ 0x8000) & ~(ring_size - 1)) 262 return ((index ^ head ^ 0x8000) & ~(ring_size - 1));
292 busy_wait();
293 else
294 break;
295 }
296#else 263#else
297 while (ring.avail->idx == head) 264 return head == ring.avail->idx;
298 busy_wait();
299#endif 265#endif
300} 266}
301 267