Re: [GIT PULL] x86/mm changes for v4.4

2015-11-07 Thread Ard Biesheuvel
On 8 November 2015 at 07:58, Kees Cook  wrote:
> On Fri, Nov 6, 2015 at 11:39 PM, Ard Biesheuvel
>  wrote:
>> On 7 November 2015 at 08:09, Ingo Molnar  wrote:
>>>
>>> * Matt Fleming  wrote:
>>>
 On Fri, 06 Nov, at 07:55:50AM, Ingo Molnar wrote:
 >
 >  3) We should fix the EFI permission problem without relying on the 
 > firmware: it
 > appears we could just mark everything R-X optimistically, and if a 
 > write fault
 > happens (it's pretty rare in fact, only triggers when we write to an 
 > EFI
 > variable and so), we can mark the faulting page RW- on the fly, 
 > because it
 > appears that writable EFI sections, while not enumerated very well 
 > in 'old'
 > firmware, are still supposed to be page granular. (Even 'new' 
 > firmware I
 > wouldn't automatically trust to get the enumeration right...)

 Sorry, this isn't true. I misled you with one of my earlier posts on
 this topic. Let me try and clear things up...

 Writing to EFI regions has to do with every invocation of the EFI
 runtime services - it's not limited to when you read/write/delete EFI
 variables. In fact, EFI variables really have nothing to do with this
 discussion, they're a completely opaque concept to the OS, we have no
 idea how the firmware implements them. Everything is done via the EFI
 boot/runtime services.

 The firmware itself will attempt to write to EFI regions when we
 invoke the EFI services because that's where the PE/COFF ".data" and
 ".bss" sections live along with the heap. There's even some relocation
 fixups that occur as SetVirtualAddressMap() time so it'll write to
 ".text" too.

 Now, the above PE/COFF sections are usually (always?) contained within
 EFI regions of type EfiRuntimeServicesCode. We know this is true
 because the firmware folks have told us so, and because stopping that
 is the motivation behind the new EFI_PROPERTIES_TABLE feature in UEFI
 V2.5.

 The data sections within the region are also *not* guaranteed to be
 page granular because work was required in Tianocore for emitting
 sections with 4k alignment as part of the EFI_PROPERTIES_TABLE
 support.

 Ultimately, what this means is that if you were to attempt to
 dynamically fixup those regions that required write permission, you'd
 have to modify the mappings for the majority of the EFI regions
 anyway. And if you're blindly allowing write permission as a fixup,
 there's not much security to be had.
>>>
>>> I think you misunderstood my suggestion: the 'fixup' would be changing it 
>>> from R-X
>>> to RW-, i.e. it would add 'write' permission but remove 'execute' 
>>> permission.
>>>
>>> Note that there would be no 'RWX' permission at any given moment - which is 
>>> the
>>> dangerous combination.
>>>
>>
>> The problem with that is that /any/ page in the UEFI runtime region
>> may intersect with both .text and .data of any of the PE/COFF images
>> that make up the runtime firmware (since the PE/COFF sections are not
>> necessarily page aligned). Such pages require RWX permissions. The
>> UEFI memory map does not provide the information to identify those
>> pages a priori (the entire region containing several PE/COFF images
>> could be covered by a single entry) so it is hard to guess which pages
>> should be allowed these RWX permissions.
>
> I'm sad that UEFI was designed without even the most basic of memory
> protections in mind. UEFI _itself_ should be setting up protective
> page mappings. :(
>

Well, the 4 KB alignment of sections was considered prohibitive at the
time from code size pov. But this was a long time ago, obviously.

> For a boot firmware, it seems to me that safe page table layout would
> be a top priority bug. The "reporting issues" page for TianoCore
> doesn't actually seem to link to the "Project Tracker":
> https://github.com/tianocore/tianocore.github.io/wiki/Reporting-Issues
>
> Does anyone know how to get this correctly reported so future UEFI
> releases don't suffer from this?
>

Ugh. Don't get me started on that topic. I have been working with the
UEFI forum since July to get a fundamentally broken implementation of
memory protections fixed. UEFI v2.5 defines a memory protection scheme
that is based on splitting PE/COFF images into separate memory regions
so that R-X and RW- permissions can be applied. Unfortunately, that
broke every OS in existence (including Windows 8), since the OS is
allowed to reorder memory regions when it lays out the virtual
remapping of the UEFI regions, resulting in PE/COFF .data and .text
potentially appearing out of order.

The good news is that we fixed it for the upcoming release (v2.6). I
can't disclose any specifics, though :-(

-- 
Ard.


 > If that 'supposed to be' turns out to be 'not true' (not unheard of 
 > in
 > firmware land), then plan B would 

[PATCH] tpm: fix compat 'ppi' link handling in tpm_chip_register()

2015-11-07 Thread Jarkko Sakkinen
__compat_only_sysfs_link_entry_to_kobj() was unconditionally called for
TPM1 chips, which caused crash on Acer C720 laptop where DSM for the
ACPI object did not exist.

There are two reasons for unwanted behavior:

* The code did not check whether
  __compat_only_sysfs_link_entry_to_kobj() returned -ENOENT. This is
  OK. It just meanst that ppi is not available.
* The code did not clean up properly. Compat link should added only
  after all other init is done.

This patch sorts out these issues.

Fixes: 9b774d5cf2db
Reported-by: Jeremiah Mahler 
Signed-off-by: Jarkko Sakkinen 
Tested-by: Jeremiah Mahler 
---
 drivers/char/tpm/tpm-chip.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index a5cdce7..45cc39a 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -226,14 +226,6 @@ int tpm_chip_register(struct tpm_chip *chip)
if (rc)
goto out_err;
 
-   if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
-   rc = __compat_only_sysfs_link_entry_to_kobj(>pdev->kobj,
-   >dev.kobj,
-   "ppi");
-   if (rc)
-   goto out_err;
-   }
-
/* Make the chip available. */
spin_lock(_lock);
list_add_tail_rcu(>list, _chip_list);
@@ -241,6 +233,16 @@ int tpm_chip_register(struct tpm_chip *chip)
 
chip->flags |= TPM_CHIP_FLAG_REGISTERED;
 
+   if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
+   rc = __compat_only_sysfs_link_entry_to_kobj(>pdev->kobj,
+   >dev.kobj,
+   "ppi");
+   if (rc && rc != -ENOENT) {
+   tpm_chip_unregister(chip);
+   return rc;
+   }
+   }
+
return 0;
 out_err:
tpm1_chip_unregister(chip);
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [BUG, PATCH 03/10] sysfs: added __compat_only_sysfs_link_entry_to_kobj()

2015-11-07 Thread Jarkko Sakkinen
On Sat, Nov 07, 2015 at 07:04:04PM -0800, Jeremiah Mahler wrote:
> Jarkko,
> 
> On Sun, Nov 08, 2015 at 02:49:06AM +0200, Jarkko Sakkinen wrote:
> > On Sat, Nov 07, 2015 at 03:11:47PM -0800, Jeremiah Mahler wrote:
> > > Jarkko,
> > > 
> [...]
> > > 
> > > It sounds like you have the problem figured out and have a good fix.
> > > If I can do anything else to help let me know :-)
> > 
> > Turns out that after all the second issue that I described was also
> > because of this patch.
> > 
> > Clean up was not done properly when that function. I revised my fix.
> > 
> > If you want to help, check that the revised patch works I'll add
> > Tested-by to the patch. Thank you!
> > 
> > > -- 
> > > - Jeremiah Mahler
> > 
> > /Jarkko
> 
> I tested the patch (link below) and it works with one small caveat.
> The patch would not apply because line 231 uses list_add_tail_rcu
> instead of list_add_rcu.  I am working from commit 9b774d5cf2d where
> the problem started.  Your repo likely has other changes involved.
> 
> https://github.com/jsakkine/linux-tpmdd/commit/73ea7e0b8045f9610c3274bcefaf89b7a05ee781

Yes, that branch also fix that changes one list_add_rcu() to
list_add_tail_rcu(). I'll add Tested-by to the commit message. Thanks
again for the good work.

> -- 
> - Jeremiah Mahler

/Jarkko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] dma: fix returnvar.cocci warnings

2015-11-07 Thread Julia Lawall
 Remove unneeded variable used to store return value.

Generated by: scripts/coccinelle/misc/returnvar.cocci

CC: Sinan Kaya 
Signed-off-by: Fengguang Wu 
---

 hidma_ll.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

--- a/drivers/dma/qcom/hidma_ll.c
+++ b/drivers/dma/qcom/hidma_ll.c
@@ -567,14 +567,13 @@ int hidma_ll_resume(struct hidma_lldev *

 static int hidma_ll_hw_start(struct hidma_lldev *lldev)
 {
-   int rc = 0;
unsigned long irqflags;

spin_lock_irqsave(>lock, irqflags);
writel(lldev->tre_write_offset, lldev->trca + TRCA_DOORBELL_OFFSET);
spin_unlock_irqrestore(>lock, irqflags);

-   return rc;
+   return 0;
 }

 bool hidma_ll_isenabled(struct hidma_lldev *lldev)
@@ -600,7 +599,6 @@ bool hidma_ll_isenabled(struct hidma_lld
 int hidma_ll_queue_request(struct hidma_lldev *lldev, u32 tre_ch)
 {
struct hidma_tre *tre;
-   int rc = 0;
unsigned long flags;

tre = >trepool[tre_ch];
@@ -618,7 +616,7 @@ int hidma_ll_queue_request(struct hidma_
lldev->tre_write_offset = (lldev->tre_write_offset + TRE_SIZE)
% lldev->tre_ring_size;
spin_unlock_irqrestore(>lock, flags);
-   return rc;
+   return 0;
 }

 int hidma_ll_start(struct hidma_lldev *lldev)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf test: Add 'perf test BPF'

2015-11-07 Thread tip-bot for Wang Nan
Commit-ID:  ba1fae431e74bb427a699187434142fd3fe98390
Gitweb: http://git.kernel.org/tip/ba1fae431e74bb427a699187434142fd3fe98390
Author: Wang Nan 
AuthorDate: Fri, 6 Nov 2015 13:49:43 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 6 Nov 2015 17:50:03 -0300

perf test: Add 'perf test BPF'

This patch adds BPF testcase for testing BPF event filtering.

By utilizing the result of 'perf test LLVM', this patch compiles the
eBPF sample program then test its ability. The BPF script in 'perf test
LLVM' lets only 50% samples generated by epoll_pwait() to be captured.
This patch runs that system call for 111 times, so the result should
contain 56 samples.

Signed-off-by: Wang Nan 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Alexei Starovoitov 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1446817783-86722-8-git-send-email-wangn...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/Build  |   1 +
 tools/perf/tests/bpf.c  | 209 
 tools/perf/tests/builtin-test.c |   4 +
 tools/perf/tests/tests.h|   1 +
 tools/perf/util/bpf-loader.c|  24 -
 tools/perf/util/bpf-loader.h|  10 ++
 6 files changed, 248 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index a47b211..f41ebf8 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -32,6 +32,7 @@ perf-y += parse-no-sample-id-all.o
 perf-y += kmod-path.o
 perf-y += thread-map.o
 perf-y += llvm.o llvm-src-base.o llvm-src-kbuild.o
+perf-y += bpf.o
 perf-y += topology.o
 
 $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
new file mode 100644
index 000..ec16f78
--- /dev/null
+++ b/tools/perf/tests/bpf.c
@@ -0,0 +1,209 @@
+#include 
+#include 
+#include 
+#include 
+#include "tests.h"
+#include "llvm.h"
+#include "debug.h"
+#define NR_ITERS   111
+
+#ifdef HAVE_LIBBPF_SUPPORT
+
+static int epoll_pwait_loop(void)
+{
+   int i;
+
+   /* Should fail NR_ITERS times */
+   for (i = 0; i < NR_ITERS; i++)
+   epoll_pwait(-(i + 1), NULL, 0, 0, NULL);
+   return 0;
+}
+
+static struct {
+   enum test_llvm__testcase prog_id;
+   const char *desc;
+   const char *name;
+   const char *msg_compile_fail;
+   const char *msg_load_fail;
+   int (*target_func)(void);
+   int expect_result;
+} bpf_testcase_table[] = {
+   {
+   LLVM_TESTCASE_BASE,
+   "Test basic BPF filtering",
+   "[basic_bpf_test]",
+   "fix 'perf test LLVM' first",
+   "load bpf object failed",
+   _pwait_loop,
+   (NR_ITERS + 1) / 2,
+   },
+};
+
+static int do_test(struct bpf_object *obj, int (*func)(void),
+  int expect)
+{
+   struct record_opts opts = {
+   .target = {
+   .uid = UINT_MAX,
+   .uses_mmap = true,
+   },
+   .freq = 0,
+   .mmap_pages   = 256,
+   .default_interval = 1,
+   };
+
+   char pid[16];
+   char sbuf[STRERR_BUFSIZE];
+   struct perf_evlist *evlist;
+   int i, ret = TEST_FAIL, err = 0, count = 0;
+
+   struct parse_events_evlist parse_evlist;
+   struct parse_events_error parse_error;
+
+   bzero(_error, sizeof(parse_error));
+   bzero(_evlist, sizeof(parse_evlist));
+   parse_evlist.error = _error;
+   INIT_LIST_HEAD(_evlist.list);
+
+   err = parse_events_load_bpf_obj(_evlist, _evlist.list, obj);
+   if (err || list_empty(_evlist.list)) {
+   pr_debug("Failed to add events selected by BPF\n");
+   if (!err)
+   return TEST_FAIL;
+   }
+
+   snprintf(pid, sizeof(pid), "%d", getpid());
+   pid[sizeof(pid) - 1] = '\0';
+   opts.target.tid = opts.target.pid = pid;
+
+   /* Instead of perf_evlist__new_default, don't add default events */
+   evlist = perf_evlist__new();
+   if (!evlist) {
+   pr_debug("No ehough memory to create evlist\n");
+   return TEST_FAIL;
+   }
+
+   err = perf_evlist__create_maps(evlist, );
+   if (err < 0) {
+   pr_debug("Not enough memory to create thread/cpu maps\n");
+   goto out_delete_evlist;
+   }
+
+   perf_evlist__splice_list_tail(evlist, _evlist.list);
+   evlist->nr_groups = parse_evlist.nr_groups;
+
+   perf_evlist__config(evlist, );
+
+   err = perf_evlist__open(evlist);
+   if (err < 0) {
+   pr_debug("perf_evlist__open: %s\n",
+strerror_r(errno, sbuf, sizeof(sbuf)));
+   goto out_delete_evlist;
+   }
+
+   err = perf_evlist__mmap(evlist, opts.mmap_pages, false);
+   if (err < 0) {
+   pr_debug("perf_evlist__mmap: %s\n",

[tip:perf/urgent] perf test: Do not be case sensitive when searching for matching tests

2015-11-07 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  345c99a303e1d97b407bf99190314a878d59ca92
Gitweb: http://git.kernel.org/tip/345c99a303e1d97b407bf99190314a878d59ca92
Author: Arnaldo Carvalho de Melo 
AuthorDate: Fri, 6 Nov 2015 17:03:38 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 6 Nov 2015 17:50:04 -0300

perf test: Do not be case sensitive when searching for matching tests

Before:

  # perf test llvm
  # perf test LLVM
  35: Test LLVM searching and compiling: Ok
  #

After

  # perf test llvm
  35: Test LLVM searching and compiling: Ok
  #

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: http://lkml.kernel.org/n/tip-c1u05npqbf6epse17ovfe...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/builtin-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 7b0120a..80c442e 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -196,7 +196,7 @@ static bool perf_test__matches(struct test *test, int curr, 
int argc, const char
continue;
}
 
-   if (strstr(test->desc, argv[i]))
+   if (strcasestr(test->desc, argv[i]))
return true;
}
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf test: Enhance the LLVM tests: add kbuild test

2015-11-07 Thread tip-bot for Wang Nan
Commit-ID:  7af3f3d55b80cce40ad94b6b8e173dccedaf25e6
Gitweb: http://git.kernel.org/tip/7af3f3d55b80cce40ad94b6b8e173dccedaf25e6
Author: Wang Nan 
AuthorDate: Fri, 6 Nov 2015 13:49:42 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 6 Nov 2015 17:49:50 -0300

perf test: Enhance the LLVM tests: add kbuild test

This patch adds a kbuild testcase to check whether kernel headers can be
correctly found.

For example:
  # mv /lib/modules/4.3.0-rc5{,.bak}
  # perf test LLVM

38: Test LLVM searching and compiling: Skip

  # perf test -v LLVM
  ...
  :11:10: fatal error: 'uapi/linux/fs.h' file not found
  #include 
  ^
  1 error generated.
  ERROR:unable to compile -
  Hint: Check error message shown above.
  Hint: You can also pre-compile it into .o using:
 clang -target bpf -O2 -c -
 with proper -I and -D options.
  Failed to compile test case: 'Test kbuild searching'
  test child finished with -2

Signed-off-by: Wang Nan 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1446817783-86722-7-git-send-email-wangn...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/Build|  9 -
 tools/perf/tests/bpf-script-test-kbuild.c | 21 +
 tools/perf/tests/llvm.c   |  4 
 tools/perf/tests/llvm.h   |  2 ++
 4 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 6c095b3..a47b211 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -31,7 +31,7 @@ perf-y += sample-parsing.o
 perf-y += parse-no-sample-id-all.o
 perf-y += kmod-path.o
 perf-y += thread-map.o
-perf-y += llvm.o llvm-src-base.o
+perf-y += llvm.o llvm-src-base.o llvm-src-kbuild.o
 perf-y += topology.o
 
 $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c
@@ -41,6 +41,13 @@ $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c
$(Q)sed -e 's/"/\\"/g' -e 's/\(.*\)/"\1\\n"/g' $< >> $@
$(Q)echo ';' >> $@
 
+$(OUTPUT)tests/llvm-src-kbuild.c: tests/bpf-script-test-kbuild.c
+   $(call rule_mkdir)
+   $(Q)echo '#include ' > $@
+   $(Q)echo 'const char test_llvm__bpf_test_kbuild_prog[] =' >> $@
+   $(Q)sed -e 's/"/\\"/g' -e 's/\(.*\)/"\1\\n"/g' $< >> $@
+   $(Q)echo ';' >> $@
+
 ifeq ($(ARCH),$(filter $(ARCH),x86 arm arm64))
 perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
 endif
diff --git a/tools/perf/tests/bpf-script-test-kbuild.c 
b/tools/perf/tests/bpf-script-test-kbuild.c
new file mode 100644
index 000..3626924
--- /dev/null
+++ b/tools/perf/tests/bpf-script-test-kbuild.c
@@ -0,0 +1,21 @@
+/*
+ * bpf-script-test-kbuild.c
+ * Test include from kernel header
+ */
+#ifndef LINUX_VERSION_CODE
+# error Need LINUX_VERSION_CODE
+# error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" 
into llvm section of ~/.perfconfig'
+#endif
+#define SEC(NAME) __attribute__((section(NAME), used))
+
+#include 
+#include 
+
+SEC("func=vfs_llseek")
+int bpf_func__vfs_llseek(void *ctx)
+{
+   return 0;
+}
+
+char _license[] SEC("license") = "GPL";
+int _version SEC("version") = LINUX_VERSION_CODE;
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index 05683c5..bc4cf50 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -40,6 +40,10 @@ static struct {
.source = test_llvm__bpf_base_prog,
.desc = "Basic BPF llvm compiling test",
},
+   [LLVM_TESTCASE_KBUILD] = {
+   .source = test_llvm__bpf_test_kbuild_prog,
+   .desc = "Test kbuild searching",
+   },
 };
 
 
diff --git a/tools/perf/tests/llvm.h b/tools/perf/tests/llvm.h
index bd63cee..d91d8f4 100644
--- a/tools/perf/tests/llvm.h
+++ b/tools/perf/tests/llvm.h
@@ -5,9 +5,11 @@
 #include  /* for bool */
 
 extern const char test_llvm__bpf_base_prog[];
+extern const char test_llvm__bpf_test_kbuild_prog[];
 
 enum test_llvm__testcase {
LLVM_TESTCASE_BASE,
+   LLVM_TESTCASE_KBUILD,
__LLVM_TESTCASE_MAX,
 };
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] staging: sm750fb: add spaces around operator

2015-11-07 Thread Othmar Pasteka
On Sun, Nov 08, 2015 at 09:35:08AM +0300, Dan Carpenter wrote:
> If it's a one line fix then just send it as a single patch.

It was two things, hence I made it a two-parter.

Should I send a new version or is it a note for next time?

Thanks,
Othmar Pasteka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf test: Enhance the LLVM test: update basic BPF test program

2015-11-07 Thread tip-bot for Wang Nan
Commit-ID:  b31de018a6284a25e0fdfeb028e724f8417ec3b1
Gitweb: http://git.kernel.org/tip/b31de018a6284a25e0fdfeb028e724f8417ec3b1
Author: Wang Nan 
AuthorDate: Fri, 6 Nov 2015 13:49:41 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 6 Nov 2015 17:49:24 -0300

perf test: Enhance the LLVM test: update basic BPF test program

This patch replaces the original toy BPF program with the previously
introduced bpf-script-example.c. Dynamically embeddeding it into
'llvm-src-base.c'.

The newly introduced BPF program attaches a BPF program to
'sys_epoll_pwait()'. perf itself never use that syscall, so further test
can verify their result with it. The program would generate 1 sample in
every 2 calls of epoll_pwait() system call.

Since the resulting BPF object is useful per se for further tests,
test_llvm__fetch_bpf_obj() is introduced for creating BPF objects from
source. The LLVM test was rewritten to use it.

Committer note:

Running it:

  [root@zoo wb]# perf test -v LLVM
  35: Test LLVM searching and compiling:
  --- start ---
  test child forked, pid 17740
  Kernel build dir is set to /lib/modules/4.3.0-rc1+/build
  set env: KBUILD_DIR=/lib/modules/4.3.0-rc1+/build
  unset env: KBUILD_OPTS
  include option is set to  -nostdinc -isystem 
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/include 
-I/home/git/linux/arch/x86/include -Iarch/x86/include/generated/uapi 
-Iarch/x86/include/generated  -I/home/git/linux/include -Iinclude 
-I/home/git/linux/arch/x86/include/uapi -Iarch/x86/include/generated/uapi 
-I/home/git/linux/include/uapi -Iinclude/generated/uapi -include 
/home/git/linux/include/linux/kconfig.h
  set env: NR_CPUS=4
  set env: LINUX_VERSION_CODE=0x40300
  set env: CLANG_EXEC=/usr/libexec/icecc/bin/clang
  set env: CLANG_OPTIONS=-xc
  set env: KERNEL_INC_OPTIONS= -nostdinc -isystem 
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/include 
-I/home/git/linux/arch/x86/include -Iarch/x86/include/generated/uapi 
-Iarch/x86/include/generated  -I/home/git/linux/include -Iinclude 
-I/home/git/linux/arch/x86/include/uapi -Iarch/x86/include/generated/uapi 
-I/home/git/linux/include/uapi -Iinclude/generated/uapi -include 
/home/git/linux/include/linux/kconfig.h
  set env: WORKING_DIR=/lib/modules/4.3.0-rc1+/build
  set env: CLANG_SOURCE=-
  llvm compiling command template: echo '/*
   * bpf-script-example.c
   * Test basic LLVM building
   */
  #ifndef LINUX_VERSION_CODE
  # error Need LINUX_VERSION_CODE
  # error Example: for 4.2 kernel, put 
'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig'
  #endif
  #define BPF_ANY 0
  #define BPF_MAP_TYPE_ARRAY 2
  #define BPF_FUNC_map_lookup_elem 1
  #define BPF_FUNC_map_update_elem 2

  static void *(*bpf_map_lookup_elem)(void *map, void *key) =
  (void *) BPF_FUNC_map_lookup_elem;
  static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int 
flags) =
  (void *) BPF_FUNC_map_update_elem;

  struct bpf_map_def {
  unsigned int type;
  unsigned int key_size;
  unsigned int value_size;
  unsigned int max_entries;
  };

  #define SEC(NAME) __attribute__((section(NAME), used))
  struct bpf_map_def SEC("maps") flip_table = {
  .type = BPF_MAP_TYPE_ARRAY,
  .key_size = sizeof(int),
  .value_size = sizeof(int),
  .max_entries = 1,
  };

  SEC("func=sys_epoll_pwait")
  int bpf_func__sys_epoll_pwait(void *ctx)
  {
  int ind =0;
  int *flag = bpf_map_lookup_elem(_table, );
  int new_flag;
  if (!flag)
  return 0;
  /* flip flag and store back */
  new_flag = !*flag;
  bpf_map_update_elem(_table, , _flag, BPF_ANY);
  return new_flag;
  }
  char _license[] SEC("license") = "GPL";
  int _version SEC("version") = LINUX_VERSION_CODE;
  ' | $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS 
-DLINUX_VERSION_CODE=$LINUX_VERSION_CODE $CLANG_OPTIONS $KERNEL_INC_OPTIONS 
-Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c 
"$CLANG_SOURCE" -target bpf -O2 -o -
  test child finished with 0
   end 
  Test LLVM searching and compiling: Ok
  [root@zoo wb]#

Signed-off-by: Wang Nan 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1446817783-86722-6-git-send-email-wangn...@huawei.com
Signed-off-by: He Kuang 
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/Build|   9 ++-
 tools/perf/tests/bpf-script-example.c |   4 ++
 tools/perf/tests/llvm.c   | 131 ++
 tools/perf/tests/llvm.h   |  16 +
 4 files changed, 129 insertions(+), 31 deletions(-)

diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 50de225..6c095b3 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -31,9 +31,16 @@ perf-y += sample-parsing.o
 perf-y += parse-no-sample-id-all.o
 perf-y += 

[tip:perf/urgent] perf tools: Make fetch_kernel_version() publicly available

2015-11-07 Thread tip-bot for Wang Nan
Commit-ID:  07bc5c699a3d8fe5e26dbcd72e4103c7988055ba
Gitweb: http://git.kernel.org/tip/07bc5c699a3d8fe5e26dbcd72e4103c7988055ba
Author: Wang Nan 
AuthorDate: Fri, 6 Nov 2015 13:55:35 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 6 Nov 2015 15:57:18 -0300

perf tools: Make fetch_kernel_version() publicly available

There are 2 places in llvm-utils.c which find kernel version information
through uname. This patch extracts the uname related code into a
fetch_kernel_version() function and puts it into util.h so it can be
reused.

Signed-off-by: Wang Nan 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1446818135-87310-1-git-send-email-wangn...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/llvm-utils.c | 49 +++-
 tools/perf/util/util.c   | 30 +++
 tools/perf/util/util.h   |  3 +++
 3 files changed, 49 insertions(+), 33 deletions(-)

diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
index 8ee25be..00724d4 100644
--- a/tools/perf/util/llvm-utils.c
+++ b/tools/perf/util/llvm-utils.c
@@ -4,7 +4,6 @@
  */
 
 #include 
-#include 
 #include "util.h"
 #include "debug.h"
 #include "llvm-utils.h"
@@ -216,18 +215,19 @@ static int detect_kbuild_dir(char **kbuild_dir)
const char *suffix_dir = "";
 
char *autoconf_path;
-   struct utsname utsname;
 
int err;
 
if (!test_dir) {
-   err = uname();
-   if (err) {
-   pr_warning("uname failed: %s\n", strerror(errno));
+   /* _UTSNAME_LENGTH is 65 */
+   char release[128];
+
+   err = fetch_kernel_version(NULL, release,
+  sizeof(release));
+   if (err)
return -EINVAL;
-   }
 
-   test_dir = utsname.release;
+   test_dir = release;
prefix_dir = "/lib/modules/";
suffix_dir = "/build";
}
@@ -325,38 +325,18 @@ get_kbuild_opts(char **kbuild_dir, char 
**kbuild_include_opts)
pr_debug("include option is set to %s\n", *kbuild_include_opts);
 }
 
-static unsigned long
-fetch_kernel_version(void)
-{
-   struct utsname utsname;
-   int version, patchlevel, sublevel, err;
-
-   if (uname())
-   return 0;
-
-   err = sscanf(utsname.release, "%d.%d.%d",
-, , );
-
-   if (err != 3) {
-   pr_debug("Unablt to get kernel version from uname '%s'\n",
-utsname.release);
-   return 0;
-   }
-
-   return (version << 16) + (patchlevel << 8) + sublevel;
-}
-
 int llvm__compile_bpf(const char *path, void **p_obj_buf,
  size_t *p_obj_buf_sz)
 {
+   size_t obj_buf_sz;
+   void *obj_buf = NULL;
int err, nr_cpus_avail;
-   char clang_path[PATH_MAX], nr_cpus_avail_str[64];
+   unsigned int kernel_version;
char linux_version_code_str[64];
const char *clang_opt = llvm_param.clang_opt;
-   const char *template = llvm_param.clang_bpf_cmd_template;
+   char clang_path[PATH_MAX], nr_cpus_avail_str[64];
char *kbuild_dir = NULL, *kbuild_include_opts = NULL;
-   void *obj_buf = NULL;
-   size_t obj_buf_sz;
+   const char *template = llvm_param.clang_bpf_cmd_template;
 
if (!template)
template = CLANG_BPF_CMD_DEFAULT_TEMPLATE;
@@ -388,8 +368,11 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
snprintf(nr_cpus_avail_str, sizeof(nr_cpus_avail_str), "%d",
 nr_cpus_avail);
 
+   if (fetch_kernel_version(_version, NULL, 0))
+   kernel_version = 0;
+
snprintf(linux_version_code_str, sizeof(linux_version_code_str),
-"0x%lx", fetch_kernel_version());
+"0x%x", kernel_version);
 
force_set_env("NR_CPUS", nr_cpus_avail_str);
force_set_env("LINUX_VERSION_CODE", linux_version_code_str);
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index cd12c25..47b1e36 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -3,6 +3,7 @@
 #include "debug.h"
 #include 
 #include 
+#include 
 #ifdef HAVE_BACKTRACE_SUPPORT
 #include 
 #endif
@@ -665,3 +666,32 @@ bool find_process(const char *name)
closedir(dir);
return ret ? false : true;
 }
+
+int
+fetch_kernel_version(unsigned int *puint, char *str,
+size_t str_size)
+{
+   struct utsname utsname;
+   int version, patchlevel, sublevel, err;
+
+   if (uname())
+   return -1;
+
+   if (str && str_size) {
+   strncpy(str, utsname.release, str_size);
+   str[str_size - 1] = '\0';
+   }
+
+   err = sscanf(utsname.release, "%d.%d.%d",
+, , );
+
+   if (err != 3) {
+ 

[tip:perf/urgent] bpf tools: Add new API bpf_object__get_kversion ()

2015-11-07 Thread tip-bot for Wang Nan
Commit-ID:  45825d8ab8ef6287f5d05aea141419d8d4278852
Gitweb: http://git.kernel.org/tip/45825d8ab8ef6287f5d05aea141419d8d4278852
Author: Wang Nan 
AuthorDate: Fri, 6 Nov 2015 13:49:38 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 6 Nov 2015 15:56:41 -0300

bpf tools: Add new API bpf_object__get_kversion()

bpf_object__get_kversion() can be used to fetch value of object's
'version' section. Following patch will use it for error reporting.

Signed-off-by: Wang Nan 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1446817783-86722-3-git-send-email-wangn...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/bpf/libbpf.c | 8 
 tools/lib/bpf/libbpf.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 07b492d..e176bad 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1055,6 +1055,14 @@ bpf_object__get_name(struct bpf_object *obj)
return obj->path;
 }
 
+unsigned int
+bpf_object__get_kversion(struct bpf_object *obj)
+{
+   if (!obj)
+   return 0;
+   return obj->kern_version;
+}
+
 struct bpf_program *
 bpf_program__next(struct bpf_program *prev, struct bpf_object *obj)
 {
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 30a40e9..c9a9aef 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -56,6 +56,7 @@ void bpf_object__close(struct bpf_object *object);
 int bpf_object__load(struct bpf_object *obj);
 int bpf_object__unload(struct bpf_object *obj);
 const char *bpf_object__get_name(struct bpf_object *obj);
+unsigned int bpf_object__get_kversion(struct bpf_object *obj);
 
 struct bpf_object *bpf_object__next(struct bpf_object *prev);
 #define bpf_object__for_each_safe(pos, tmp)\
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf bpf: Improve BPF related error messages

2015-11-07 Thread tip-bot for Wang Nan
Commit-ID:  d3e0ce393057cfa907a0c4fe7b1ff56d5c30cca5
Gitweb: http://git.kernel.org/tip/d3e0ce393057cfa907a0c4fe7b1ff56d5c30cca5
Author: Wang Nan 
AuthorDate: Fri, 6 Nov 2015 13:58:09 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 6 Nov 2015 17:14:20 -0300

perf bpf: Improve BPF related error messages

A series of bpf loader related error codes were introduced to help error
reporting. Functions were improved to return these new error codes.

Functions which return pointers were adjusted to encode error codes into
return value using the ERR_PTR() interface.

bpf_loader_strerror() was improved to convert these error messages to
strings. It checks the error codes and calls libbpf_strerror() and
strerror_r() accordingly, so caller don't need to consider checking the
range of the error code.

In bpf__strerror_load(), print kernel version of running kernel and the
object's 'version' section to notify user how to fix his/her program.

v1 -> v2:
 Use macro for error code.

 Fetch error message based on array index, eliminate for-loop.

 Print version strings.

Before:

  # perf record -e ./test_kversion_nomatch_program.o sleep 1
  event syntax error: './test_kversion_nomatch_program.o'
   \___ Failed to load program: Validate your program and 
check 'license'/'version' sections in your object
  SKIP

  After:

  # perf record -e ./test_kversion_nomatch_program.o ls
  event syntax error: './test_kversion_nomatch_program.o'
   \___ 'version' (4.4.0) doesn't match running kernel 
(4.3.0)
  SKIP

Signed-off-by: Wang Nan 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1446818289-87444-1-git-send-email-wangn...@huawei.com
[ Add 'static inline' to bpf__strerror_prepare_load() when LIBBPF is disabled ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/bpf-loader.c   | 88 --
 tools/perf/util/bpf-loader.h   | 23 +++
 tools/perf/util/parse-events.c |  7 ++--
 tools/perf/util/util.h |  5 +++
 4 files changed, 108 insertions(+), 15 deletions(-)

diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index c46256b..e3afa1b 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -53,7 +53,7 @@ struct bpf_object *bpf__prepare_load(const char *filename, 
bool source)
 
err = llvm__compile_bpf(filename, _buf, _buf_sz);
if (err)
-   return ERR_PTR(err);
+   return ERR_PTR(-BPF_LOADER_ERRNO__COMPILE);
obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, filename);
free(obj_buf);
} else
@@ -113,14 +113,14 @@ config_bpf_program(struct bpf_program *prog)
if (err < 0) {
pr_debug("bpf: '%s' is not a valid config string\n",
 config_str);
-   err = -EINVAL;
+   err = -BPF_LOADER_ERRNO__CONFIG;
goto errout;
}
 
if (pev->group && strcmp(pev->group, PERF_BPF_PROBE_GROUP)) {
pr_debug("bpf: '%s': group for event is set and not '%s'.\n",
 config_str, PERF_BPF_PROBE_GROUP);
-   err = -EINVAL;
+   err = -BPF_LOADER_ERRNO__GROUP;
goto errout;
} else if (!pev->group)
pev->group = strdup(PERF_BPF_PROBE_GROUP);
@@ -132,9 +132,9 @@ config_bpf_program(struct bpf_program *prog)
}
 
if (!pev->event) {
-   pr_debug("bpf: '%s': event name is missing\n",
+   pr_debug("bpf: '%s': event name is missing. Section name should 
be 'key=value'\n",
 config_str);
-   err = -EINVAL;
+   err = -BPF_LOADER_ERRNO__EVENTNAME;
goto errout;
}
pr_debug("bpf: config '%s' is ok\n", config_str);
@@ -285,7 +285,7 @@ int bpf__foreach_tev(struct bpf_object *obj,
(void **));
if (err || !priv) {
pr_debug("bpf: failed to get private field\n");
-   return -EINVAL;
+   return -BPF_LOADER_ERRNO__INTERNAL;
}
 
pev = >pev;
@@ -308,6 +308,18 @@ int bpf__foreach_tev(struct bpf_object *obj,
return 0;
 }
 
+#define ERRNO_OFFSET(e)((e) - __BPF_LOADER_ERRNO__START)
+#define ERRCODE_OFFSET(c)  ERRNO_OFFSET(BPF_LOADER_ERRNO__##c)
+#define NR_ERRNO   (__BPF_LOADER_ERRNO__END - __BPF_LOADER_ERRNO__START)
+
+static const char *bpf_loader_strerror_table[NR_ERRNO] = {
+   [ERRCODE_OFFSET(CONFIG)]= "Invalid config string",
+   [ERRCODE_OFFSET(GROUP)] = "Invalid group name",
+   [ERRCODE_OFFSET(EVENTNAME)] = "No event name found in config 
string",
+   [ERRCODE_OFFSET(INTERNAL)]  = "BPF loader internal 

[tip:perf/urgent] bpf tools: Improve libbpf error reporting

2015-11-07 Thread tip-bot for Wang Nan
Commit-ID:  6371ca3b541c82d8aa6a9002bd52d92bcdda5944
Gitweb: http://git.kernel.org/tip/6371ca3b541c82d8aa6a9002bd52d92bcdda5944
Author: Wang Nan 
AuthorDate: Fri, 6 Nov 2015 13:49:37 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 6 Nov 2015 15:52:41 -0300

bpf tools: Improve libbpf error reporting

In this patch, a series of libbpf specific error numbers and
libbpf_strerror() are introduced to help reporting errors.

Functions are updated to pass correct the error number through the
CHECK_ERR() macro.

All users of bpf_object__open{_buffer}() and bpf_program__title() in
perf are modified accordingly. In addition, due to the error codes
changing, bpf__strerror_load() is also modified to use them.

bpf__strerror_head() is also changed accordingly so it can parse libbpf
errors. bpf_loader_strerror() is introduced for that purpose, and will
be improved by the following patch.

load_program() is improved not to dump log buffer if it is empty. log
buffer is also used to deduce whether the error was caused by an invalid
program or other problem.

v1 -> v2:

 - Using macro for error code.

 - Fetch error message based on array index, eliminate for-loop.

 - Use log buffer to detect the reason of failure. 3 new error code
   are introduced to replace LIBBPF_ERRNO__LOAD.

In v1:

  # perf record -e ./test_ill_program.o ls
  event syntax error: './test_ill_program.o'
   \___ Failed to load program: Validate your program and 
check 'license'/'version' sections in your object
  SKIP

  # perf record -e ./test_kversion_nomatch_program.o ls
  event syntax error: './test_kversion_nomatch_program.o'
   \___ Failed to load program: Validate your program and 
check 'license'/'version' sections in your object
  SKIP

  # perf record -e ./test_big_program.o ls
  event syntax error: './test_big_program.o'
   \___ Failed to load program: Validate your program and 
check 'license'/'version' sections in your object
  SKIP

  In v2:

  # perf record -e ./test_ill_program.o ls
  event syntax error: './test_ill_program.o'
   \___ Kernel verifier blocks program loading
  SKIP

  # perf record -e ./test_kversion_nomatch_program.o
  event syntax error: './test_kversion_nomatch_program.o'
   \___ Incorrect kernel version
  SKIP
  (Will be further improved by following patches)

  # perf record -e ./test_big_program.o
  event syntax error: './test_big_program.o'
   \___ Program too big
  SKIP

Signed-off-by: Wang Nan 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1446817783-86722-2-git-send-email-wangn...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/bpf/libbpf.c | 159 -
 tools/lib/bpf/libbpf.h |  20 ++
 tools/perf/tests/llvm.c|   2 +-
 tools/perf/util/bpf-loader.c   |  33 +++--
 tools/perf/util/parse-events.c |   4 +-
 5 files changed, 159 insertions(+), 59 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 9f3c8cf..07b492d 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -61,6 +61,60 @@ void libbpf_set_print(libbpf_print_fn_t warn,
__pr_debug = debug;
 }
 
+#define STRERR_BUFSIZE  128
+
+#define ERRNO_OFFSET(e)((e) - __LIBBPF_ERRNO__START)
+#define ERRCODE_OFFSET(c)  ERRNO_OFFSET(LIBBPF_ERRNO__##c)
+#define NR_ERRNO   (__LIBBPF_ERRNO__END - __LIBBPF_ERRNO__START)
+
+static const char *libbpf_strerror_table[NR_ERRNO] = {
+   [ERRCODE_OFFSET(LIBELF)]= "Something wrong in libelf",
+   [ERRCODE_OFFSET(FORMAT)]= "BPF object format invalid",
+   [ERRCODE_OFFSET(KVERSION)]  = "'version' section incorrect or lost",
+   [ERRCODE_OFFSET(ENDIAN)]= "Endian missmatch",
+   [ERRCODE_OFFSET(INTERNAL)]  = "Internal error in libbpf",
+   [ERRCODE_OFFSET(RELOC)] = "Relocation failed",
+   [ERRCODE_OFFSET(VERIFY)]= "Kernel verifier blocks program 
loading",
+   [ERRCODE_OFFSET(PROG2BIG)]  = "Program too big",
+   [ERRCODE_OFFSET(KVER)]  = "Incorrect kernel version",
+};
+
+int libbpf_strerror(int err, char *buf, size_t size)
+{
+   if (!buf || !size)
+   return -1;
+
+   err = err > 0 ? err : -err;
+
+   if (err < __LIBBPF_ERRNO__START) {
+   int ret;
+
+   ret = strerror_r(err, buf, size);
+   buf[size - 1] = '\0';
+   return ret;
+   }
+
+   if (err < __LIBBPF_ERRNO__END) {
+   const char *msg;
+
+   msg = libbpf_strerror_table[ERRNO_OFFSET(err)];
+   snprintf(buf, size, "%s", msg);
+   buf[size - 1] = '\0';
+   return 0;
+   }
+
+   snprintf(buf, size, "Unknown libbpf error %d", err);
+   buf[size - 1] = 

[tip:perf/urgent] perf probe: Cleanup find_perf_probe_point_from_map to reduce redundancy

2015-11-07 Thread tip-bot for Masami Hiramatsu
Commit-ID:  0a62f6869f2768687af2c94d97f3b2fcf5b73367
Gitweb: http://git.kernel.org/tip/0a62f6869f2768687af2c94d97f3b2fcf5b73367
Author: Masami Hiramatsu 
AuthorDate: Fri, 6 Nov 2015 17:30:03 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 6 Nov 2015 10:47:33 -0300

perf probe: Cleanup find_perf_probe_point_from_map to reduce redundancy

In find_perf_probe_point_from_map(), the 'ret' variable is initialized
with -ENOENT but overwritten by the return code of
kernel_get_symbol_address_by_name(), and after that it is re-initialized
with -ENOENT again.

Setting ret=-ENOENT twice looks a bit redundant. This avoids the
overwriting and just returns -ENOENT if some error happens to simplify
the code.

Signed-off-by: Masami Hiramatsu 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Cc: Zefan Li 
Link: http://lkml.kernel.org/n/tip-ufp1zgbktzmttcputozne...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/probe-event.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index e659c4f..03875f9 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1895,9 +1895,8 @@ static int find_perf_probe_point_from_map(struct 
probe_trace_point *tp,
sym = map__find_symbol(map, addr, NULL);
} else {
if (tp->symbol && !addr) {
-   ret = kernel_get_symbol_address_by_name(tp->symbol,
-   , true, false);
-   if (ret < 0)
+   if (kernel_get_symbol_address_by_name(tp->symbol,
+   , true, false) < 0)
goto out;
}
if (addr) {
@@ -1906,8 +1905,6 @@ static int find_perf_probe_point_from_map(struct 
probe_trace_point *tp,
}
}
 
-   /* ret may has be overwritten so reset it */
-   ret = -ENOENT;
if (!sym)
goto out;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf annotate: Inform the user about objdump failures in --stdio

2015-11-07 Thread tip-bot for Andi Kleen
Commit-ID:  62ec9b3f02a9bccaf699bd4691db98f779c3075f
Gitweb: http://git.kernel.org/tip/62ec9b3f02a9bccaf699bd4691db98f779c3075f
Author: Andi Kleen 
AuthorDate: Thu, 5 Nov 2015 19:06:07 -0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 6 Nov 2015 10:20:48 -0300

perf annotate: Inform the user about objdump failures in --stdio

When the browser fails to annotate it is difficult for users to find out
what went wrong.

Add some errors for objdump failures that are displayed in the UI.

Note it would be even better to handle these errors smarter, like
falling back to the binary when the debug info is somehow corrupted. But
for now just giving a better error is an improvement.

Committer note:

This works for --stdio, where errors just scroll by the screen:

  # perf annotate --stdio intel_idle
  Failure running objdump  --start-address=0x81418290 
--stop-address=0x814183ae -l -d --no-show-raw -S -C 
/root/.debug/.build-id/28/2777c262e6b3c0451375163c9a81c893218ab1 
2>/dev/null|grep -v 
/root/.debug/.build-id/28/2777c262e6b3c0451375163c9a81c893218ab1|expand
   Percent |  Source code & Disassembly of vmlinux for cycles:pp
  --

And with that one can use that command line to try to find out more about what
happened instead of getting a blank screen, an improvement.

We need tho to improve this further to get it to work with other UIs, like
--tui and --gtk, where it continues showing a blank screen, no messages, as
the pr_err() used is enough just for --stdio.

Signed-off-by: Andi Kleen 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: 
http://lkml.kernel.org/r/1446779167-18949-1-git-send-email-a...@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 0fc8d7a..f2974da 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1084,6 +1084,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, 
size_t privsize)
struct kcore_extract kce;
bool delete_extract = false;
int lineno = 0;
+   int nline;
 
if (filename)
symbol__join_symfs(symfs_filename, filename);
@@ -1179,6 +1180,9 @@ fallback:
 
ret = decompress_to_file(m.ext, symfs_filename, fd);
 
+   if (ret)
+   pr_err("Cannot decompress %s %s\n", m.ext, 
symfs_filename);
+
free(m.ext);
close(fd);
 
@@ -1204,13 +1208,25 @@ fallback:
pr_debug("Executing: %s\n", command);
 
file = popen(command, "r");
-   if (!file)
+   if (!file) {
+   pr_err("Failure running %s\n", command);
+   /*
+* If we were using debug info should retry with
+* original binary.
+*/
goto out_remove_tmp;
+   }
 
-   while (!feof(file))
+   nline = 0;
+   while (!feof(file)) {
if (symbol__parse_objdump_line(sym, map, file, privsize,
) < 0)
break;
+   nline++;
+   }
+
+   if (nline == 0)
+   pr_err("No output from %s\n", command);
 
/*
 * kallsyms does not have symbol sizes so there may a nop at the end.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf trace: Fix documentation for -i

2015-11-07 Thread tip-bot for Peter Feiner
Commit-ID:  956959f6b7a982b2e789a7a8fa1de437074a5eb9
Gitweb: http://git.kernel.org/tip/956959f6b7a982b2e789a7a8fa1de437074a5eb9
Author: Peter Feiner 
AuthorDate: Wed, 4 Nov 2015 09:21:46 -0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 5 Nov 2015 12:47:51 -0300

perf trace: Fix documentation for -i

The -i flag was incorrectly listed as a short flag for --no-inherit.  It
should have only been listed as a short flag for --input.

This documentation error has existed since the --input flag was
introduced in 6810fc915f7a89d8134edb3996dbbf8eac386c26 (perf trace: Add
option to analyze events in a file versus live).

Signed-off-by: Peter Feiner 
Cc: David Ahern 
Link: 
http://lkml.kernel.org/r/1446657706-14518-1-git-send-email-pfei...@google.com
Fixes: 6810fc915f7a ("perf trace: Add option to analyze events in a file versus 
live")
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-trace.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-trace.txt 
b/tools/perf/Documentation/perf-trace.txt
index 7ea0786..13293de 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -62,7 +62,6 @@ OPTIONS
 --verbose=::
 Verbosity level.
 
--i::
 --no-inherit::
Child tasks do not inherit counters.
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf stat: Make stat options global

2015-11-07 Thread tip-bot for Jiri Olsa
Commit-ID:  e0547311133159bf95f7998726e4e4932d78d8ce
Gitweb: http://git.kernel.org/tip/e0547311133159bf95f7998726e4e4932d78d8ce
Author: Jiri Olsa 
AuthorDate: Thu, 5 Nov 2015 15:40:45 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 5 Nov 2015 17:54:34 -0300

perf stat: Make stat options global

So they can be used in perf stat record command in following patch.

Signed-off-by: Jiri Olsa 
Tested-by: Kan Liang 
Cc: David Ahern 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1446734469-11352-2-git-send-email-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-stat.c | 163 +++---
 1 file changed, 82 insertions(+), 81 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index b74ee0f..e77880b 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -122,6 +122,9 @@ static bool forever 
= false;
 static struct timespec ref_time;
 static struct cpu_map  *aggr_map;
 static aggr_get_id_t   aggr_get_id;
+static boolappend_file;
+static const char  *output_name;
+static int output_fd;
 
 static volatile int done = 0;
 
@@ -927,6 +930,67 @@ static int stat__set_big_num(const struct option *opt 
__maybe_unused,
return 0;
 }
 
+static const struct option stat_options[] = {
+   OPT_BOOLEAN('T', "transaction", _run,
+   "hardware transaction statistics"),
+   OPT_CALLBACK('e', "event", _list, "event",
+"event selector. use 'perf list' to list available events",
+parse_events_option),
+   OPT_CALLBACK(0, "filter", _list, "filter",
+"event filter", parse_filter),
+   OPT_BOOLEAN('i', "no-inherit", _inherit,
+   "child tasks do not inherit counters"),
+   OPT_STRING('p', "pid", , "pid",
+  "stat events on existing process id"),
+   OPT_STRING('t', "tid", , "tid",
+  "stat events on existing thread id"),
+   OPT_BOOLEAN('a', "all-cpus", _wide,
+   "system-wide collection from all CPUs"),
+   OPT_BOOLEAN('g', "group", ,
+   "put the counters into a counter group"),
+   OPT_BOOLEAN('c', "scale", _config.scale, "scale/normalize 
counters"),
+   OPT_INCR('v', "verbose", ,
+   "be more verbose (show counter open errors, etc)"),
+   OPT_INTEGER('r', "repeat", _count,
+   "repeat command and print average + stddev (max: 100, 
forever: 0)"),
+   OPT_BOOLEAN('n', "null", _run,
+   "null run - dont start any counters"),
+   OPT_INCR('d', "detailed", _run,
+   "detailed run - start a lot of events"),
+   OPT_BOOLEAN('S', "sync", _run,
+   "call sync() before starting a run"),
+   OPT_CALLBACK_NOOPT('B', "big-num", NULL, NULL,
+  "print large numbers with thousands\' separators",
+  stat__set_big_num),
+   OPT_STRING('C', "cpu", _list, "cpu",
+   "list of cpus to monitor in system-wide"),
+   OPT_SET_UINT('A', "no-aggr", _config.aggr_mode,
+   "disable CPU count aggregation", AGGR_NONE),
+   OPT_STRING('x', "field-separator", _sep, "separator",
+  "print counts with custom separator"),
+   OPT_CALLBACK('G', "cgroup", _list, "name",
+"monitor event in cgroup name only", parse_cgroups),
+   OPT_STRING('o', "output", _name, "file", "output file name"),
+   OPT_BOOLEAN(0, "append", _file, "append to the output file"),
+   OPT_INTEGER(0, "log-fd", _fd,
+   "log output to fd, instead of stderr"),
+   OPT_STRING(0, "pre", _cmd, "command",
+   "command to run prior to the measured command"),
+   OPT_STRING(0, "post", _cmd, "command",
+   "command to run after to the measured command"),
+   OPT_UINTEGER('I', "interval-print", _config.interval,
+   "print counts at regular interval in ms (>= 10)"),
+   OPT_SET_UINT(0, "per-socket", _config.aggr_mode,
+"aggregate counts per processor socket", AGGR_SOCKET),
+   OPT_SET_UINT(0, "per-core", _config.aggr_mode,
+"aggregate counts per physical processor core", AGGR_CORE),
+   OPT_SET_UINT(0, "per-thread", _config.aggr_mode,
+"aggregate counts per thread", AGGR_THREAD),
+   OPT_UINTEGER('D', "delay", _delay,
+"ms to wait before starting measurement after program 
start"),
+   OPT_END()
+};
+
 static int perf_stat__get_socket(struct cpu_map *map, int cpu)
 {
return cpu_map__get_socket(map, cpu, NULL);
@@ -1174,69 +1238,6 @@ static int add_default_attributes(void)
 
 int cmd_stat(int argc, const char **argv, 

[tip:perf/urgent] perf sched latency: Fix thread pid reuse issue

2015-11-07 Thread tip-bot for Jiri Olsa
Commit-ID:  0014de172d228e450377d1fd079d94e67128d27f
Gitweb: http://git.kernel.org/tip/0014de172d228e450377d1fd079d94e67128d27f
Author: Jiri Olsa 
AuthorDate: Mon, 2 Nov 2015 12:10:25 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 5 Nov 2015 12:51:00 -0300

perf sched latency: Fix thread pid reuse issue

The latency subcommand holds a tree of working atoms sorted by thread's
pid/tid. If there's new thread with same pid and tid, the old working atom is
found and assert bug condition is hit in search function:

  thread_atoms_search: Assertion `!(thread != atoms->thread)' failed

Changing the sort function to use thread object pointers together with pid and
tid check. This way new thread will never find old one with same pid/tid.

Link: http://lkml.kernel.org/n/tip-o4doazhhv0zax5zshkg8h...@git.kernel.org
Reported-by: Mohit Agrawal 
Signed-off-by: Jiri Olsa 
Acked-by: Namhyung Kim 
Cc: David Ahern 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1446462625-15807-1-git-send-email-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-sched.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 0ee6d90..e3d3e32 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1203,12 +1203,13 @@ static void output_lat_thread(struct perf_sched *sched, 
struct work_atoms *work_
 
 static int pid_cmp(struct work_atoms *l, struct work_atoms *r)
 {
+   if (l->thread == r->thread)
+   return 0;
if (l->thread->tid < r->thread->tid)
return -1;
if (l->thread->tid > r->thread->tid)
return 1;
-
-   return 0;
+   return (int)(l->thread - r->thread);
 }
 
 static int avg_cmp(struct work_atoms *l, struct work_atoms *r)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf tools: Fix find_perf_probe_point_from_map( ) which incorrectly returns success

2015-11-07 Thread tip-bot for Wang Nan
Commit-ID:  98d3b258ede2cdac31a2728543f652964e597e79
Gitweb: http://git.kernel.org/tip/98d3b258ede2cdac31a2728543f652964e597e79
Author: Wang Nan 
AuthorDate: Thu, 5 Nov 2015 13:19:25 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 5 Nov 2015 12:47:52 -0300

perf tools: Fix find_perf_probe_point_from_map() which incorrectly returns 
success

It is possible that find_perf_probe_point_from_map() fails to find a
symbol but still returns 0 because of an small error when coding:
find_perf_probe_point_from_map() set 'ret' to error code at first, but
also use it to hold return value of kernel_get_symbol_address_by_name().

This patch resets 'ret' to error even kernel_get_symbol_address_by_name()
success, so if !sym, the whole function returns error correctly.

Signed-off-by: Wang Nan 
Cc: Jiri Olsa 
Cc: Masami Hiramatsu 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1446729565-27592-3-git-send-email-wangn...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/probe-event.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index b51a8bf..e659c4f 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1905,6 +1905,9 @@ static int find_perf_probe_point_from_map(struct 
probe_trace_point *tp,
sym = __find_kernel_function(addr, );
}
}
+
+   /* ret may has be overwritten so reset it */
+   ret = -ENOENT;
if (!sym)
goto out;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf llvm: Pass LINUX_VERSION_CODE to BPF program when compiling

2015-11-07 Thread tip-bot for Wang Nan
Commit-ID:  4a4f66a1a7031675745812729ade94ad1caf1db6
Gitweb: http://git.kernel.org/tip/4a4f66a1a7031675745812729ade94ad1caf1db6
Author: Wang Nan 
AuthorDate: Wed, 4 Nov 2015 11:20:05 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 5 Nov 2015 12:47:50 -0300

perf llvm: Pass LINUX_VERSION_CODE to BPF program when compiling

Arnaldo suggests to make LINUX_VERSION_CODE works like __func__ and
__FILE__ so user don't need to care setting right linux version too
much. In this patch, perf llvm transfers LINUX_VERSION_CODE macro
through clang cmdline.

[1] http://lkml.kernel.org/r/20151029223744.gk2...@kernel.org

Committer notes:

Before, forgetting to update the version:

  # uname -r
  4.3.0-rc1+
  # cat bpf.c
  __attribute__((section("fork=_do_fork"), used))
  int fork(void *ctx)
  {
  return 1;
  }

  char _license[] __attribute__((section("license"), used)) = "GPL";
  int _version __attribute__((section("version"), used)) = 0x40200;
  #
  # perf record -e bpf.c sleep 1
  event syntax error: 'bpf.c'
   \___ Invalid argument: Are you root and runing a 
CONFIG_BPF_SYSCALL kernel?

  (add -v to see detail)
  Run 'perf list' for a list of valid events

   Usage: perf record [] []
  or: perf record [] --  []

  -e, --eventevent selector. use 'perf list' to list available 
events
 #

After:

  # grep version bpf.c
  int _version __attribute__((section("version"), used)) = LINUX_VERSION_CODE;
  # perf record -e bpf.c sleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.017 MB perf.data ]
  # perf evlist -v
  perf_bpf_probe:fork: type: 2, size: 112, config: 0x5ee, { sample_period,
  sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW, disabled: 1,
  inherit: 1, mmap: 1, comm: 1, enable_on_exec: 1, task: 1, sample_id_all:
  1, exclude_guest: 1, mmap2: 1, comm_exec: 1
  #

Suggested-and-Tested-by: Arnaldo Carvalho de Melo 
Signed-off-by: Wang Nan 
Cc: Alexei Starovoitov 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1446636007-239722-3-git-send-email-wangn...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/llvm-utils.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
index 80eecef..8ee25be 100644
--- a/tools/perf/util/llvm-utils.c
+++ b/tools/perf/util/llvm-utils.c
@@ -12,6 +12,7 @@
 
 #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \
"$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\
+   "-DLINUX_VERSION_CODE=$LINUX_VERSION_CODE " \
"$CLANG_OPTIONS $KERNEL_INC_OPTIONS "   \
"-Wno-unused-value -Wno-pointer-sign "  \
"-working-directory $WORKING_DIR "  \
@@ -324,11 +325,33 @@ get_kbuild_opts(char **kbuild_dir, char 
**kbuild_include_opts)
pr_debug("include option is set to %s\n", *kbuild_include_opts);
 }
 
+static unsigned long
+fetch_kernel_version(void)
+{
+   struct utsname utsname;
+   int version, patchlevel, sublevel, err;
+
+   if (uname())
+   return 0;
+
+   err = sscanf(utsname.release, "%d.%d.%d",
+, , );
+
+   if (err != 3) {
+   pr_debug("Unablt to get kernel version from uname '%s'\n",
+utsname.release);
+   return 0;
+   }
+
+   return (version << 16) + (patchlevel << 8) + sublevel;
+}
+
 int llvm__compile_bpf(const char *path, void **p_obj_buf,
  size_t *p_obj_buf_sz)
 {
int err, nr_cpus_avail;
char clang_path[PATH_MAX], nr_cpus_avail_str[64];
+   char linux_version_code_str[64];
const char *clang_opt = llvm_param.clang_opt;
const char *template = llvm_param.clang_bpf_cmd_template;
char *kbuild_dir = NULL, *kbuild_include_opts = NULL;
@@ -365,7 +388,11 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
snprintf(nr_cpus_avail_str, sizeof(nr_cpus_avail_str), "%d",
 nr_cpus_avail);
 
+   snprintf(linux_version_code_str, sizeof(linux_version_code_str),
+"0x%lx", fetch_kernel_version());
+
force_set_env("NR_CPUS", nr_cpus_avail_str);
+   force_set_env("LINUX_VERSION_CODE", linux_version_code_str);
force_set_env("CLANG_EXEC", clang_path);
force_set_env("CLANG_OPTIONS", clang_opt);
force_set_env("KERNEL_INC_OPTIONS", kbuild_include_opts);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] tools lib bpf: Change FEATURE-DUMP to FEATURE-DUMP.libbpf

2015-11-07 Thread tip-bot for Yunlong Song
Commit-ID:  0c77c04aa9c2b3a154f5cb0559feaee3fb7a6935
Gitweb: http://git.kernel.org/tip/0c77c04aa9c2b3a154f5cb0559feaee3fb7a6935
Author: Yunlong Song 
AuthorDate: Thu, 5 Nov 2015 14:56:34 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 5 Nov 2015 12:47:51 -0300

tools lib bpf: Change FEATURE-DUMP to FEATURE-DUMP.libbpf

Commit ed63f34c026e9a60d17fa750ecdfe3f600d49393 ("perf tools: Make perf
depend on libbpf") triggers the build of libbpf when building the perf
tools, dynamically creating FEATURE-DUMP.libbpf.

It failed to update the tools/lib/bpf/.gitignore file to have that
prefix, fix it.

Signed-off-by: Yunlong Song 
Cc: Adrian Hunter 
Cc: Alexei Starovoitov 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Kan Liang 
Cc: Masami Hiramatsu 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Wang Nan 
Fixes: 65f041bee783 ("tools lib bpf: Use FEATURE_USER to allow building in the 
same dir as perf")
Link: 
http://lkml.kernel.org/r/1446706594-4142-1-git-send-email-yunlong.s...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/bpf/.gitignore | 2 +-
 tools/lib/bpf/Makefile   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/lib/bpf/.gitignore b/tools/lib/bpf/.gitignore
index 812aeed..f81e549 100644
--- a/tools/lib/bpf/.gitignore
+++ b/tools/lib/bpf/.gitignore
@@ -1,2 +1,2 @@
 libbpf_version.h
-FEATURE-DUMP
+FEATURE-DUMP.libbpf
diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index fc9af57..a3caaf3 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -180,7 +180,7 @@ config-clean:
 clean:
$(call QUIET_CLEAN, libbpf) $(RM) *.o *~ $(TARGETS) *.a *.so 
$(VERSION_FILES) .*.d \
$(RM) LIBBPF-CFLAGS
-   $(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP
+   $(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf
 
 
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf llvm: Pass number of configured CPUs to clang compiler

2015-11-07 Thread tip-bot for Wang Nan
Commit-ID:  59f41af980f95cbd556a6dc2e064b412abc439cf
Gitweb: http://git.kernel.org/tip/59f41af980f95cbd556a6dc2e064b412abc439cf
Author: Wang Nan 
AuthorDate: Wed, 4 Nov 2015 11:20:04 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 5 Nov 2015 12:47:02 -0300

perf llvm: Pass number of configured CPUs to clang compiler

This patch introduces a new macro "__NR_CPUS__" to perf's embedded clang
compiler, which represent the number of configured CPUs in this system.
BPF programs can use this macro to create a map with the same number of
system CPUs. For example:

 struct bpf_map_def SEC("maps") pmu_map = {
 .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
 .key_size = sizeof(int),
 .value_size = sizeof(u32),
 .max_entries = __NR_CPUS__,
 };

Signed-off-by: Wang Nan 
Cc: Alexei Starovoitov 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1446636007-239722-2-git-send-email-wangn...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/llvm-utils.c | 24 ++--
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
index 4f6a478..80eecef 100644
--- a/tools/perf/util/llvm-utils.c
+++ b/tools/perf/util/llvm-utils.c
@@ -11,10 +11,11 @@
 #include "cache.h"
 
 #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \
-   "$CLANG_EXEC -D__KERNEL__ $CLANG_OPTIONS "  \
-   "$KERNEL_INC_OPTIONS -Wno-unused-value "\
-   "-Wno-pointer-sign -working-directory " \
-   "$WORKING_DIR -c \"$CLANG_SOURCE\" -target bpf -O2 -o -"
+   "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\
+   "$CLANG_OPTIONS $KERNEL_INC_OPTIONS "   \
+   "-Wno-unused-value -Wno-pointer-sign "  \
+   "-working-directory $WORKING_DIR "  \
+   "-c \"$CLANG_SOURCE\" -target bpf -O2 -o -"
 
 struct llvm_param llvm_param = {
.clang_path = "clang",
@@ -326,8 +327,8 @@ get_kbuild_opts(char **kbuild_dir, char 
**kbuild_include_opts)
 int llvm__compile_bpf(const char *path, void **p_obj_buf,
  size_t *p_obj_buf_sz)
 {
-   int err;
-   char clang_path[PATH_MAX];
+   int err, nr_cpus_avail;
+   char clang_path[PATH_MAX], nr_cpus_avail_str[64];
const char *clang_opt = llvm_param.clang_opt;
const char *template = llvm_param.clang_bpf_cmd_template;
char *kbuild_dir = NULL, *kbuild_include_opts = NULL;
@@ -354,6 +355,17 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
 */
get_kbuild_opts(_dir, _include_opts);
 
+   nr_cpus_avail = sysconf(_SC_NPROCESSORS_CONF);
+   if (nr_cpus_avail <= 0) {
+   pr_err(
+"WARNING:\tunable to get available CPUs in this system: %s\n"
+"\tUse 128 instead.\n", strerror(errno));
+   nr_cpus_avail = 128;
+   }
+   snprintf(nr_cpus_avail_str, sizeof(nr_cpus_avail_str), "%d",
+nr_cpus_avail);
+
+   force_set_env("NR_CPUS", nr_cpus_avail_str);
force_set_env("CLANG_EXEC", clang_path);
force_set_env("CLANG_OPTIONS", clang_opt);
force_set_env("KERNEL_INC_OPTIONS", kbuild_include_opts);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf tools: Allow shuffling the build tests

2015-11-07 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  98916392a0bdfd71668b711fd93915791f45df02
Gitweb: http://git.kernel.org/tip/98916392a0bdfd71668b711fd93915791f45df02
Author: Arnaldo Carvalho de Melo 
AuthorDate: Wed, 4 Nov 2015 16:25:32 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 5 Nov 2015 11:39:54 -0300

perf tools: Allow shuffling the build tests

Those tests take a long time and sometimes we stop it, so allow randomly
shuffling the tests so that we have a better chance of running more of
them in partial 'make build-test' runs.

Using it just on the 'build-test' target, i.e.:

   make -C tools/perf build-test

Is equivalent to:

   make SHUF=1 -C tools/perf -f tests/make

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: http://lkml.kernel.org/n/tip-ey7461i9q4k8u0987j8gu...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Makefile   | 2 +-
 tools/perf/tests/make | 5 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 480546d..dcd9a70 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -78,7 +78,7 @@ clean:
 # The build-test target is not really parallel, don't print the jobs info:
 #
 build-test:
-   @$(MAKE) -f tests/make --no-print-directory
+   @$(MAKE) SHUF=1 -f tests/make --no-print-directory
 
 #
 # All other targets get passed through:
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 2cbd0c6..8ea3dff 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -221,6 +221,11 @@ test_O = $(if $(test_$1),$(test_$1),$(test_default_O))
 
 all:
 
+ifdef SHUF
+run := $(shell shuf -e $(run))
+run_O := $(shell shuf -e $(run_O))
+endif
+
 ifdef DEBUG
 d := $(info run   $(run))
 d := $(info run_O $(run_O))
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf tools: Insert split maps correctly into origin group

2015-11-07 Thread tip-bot for Jiri Olsa
Commit-ID:  cb8382e05817a8104ea0edb63b8e37b8fbecd14c
Gitweb: http://git.kernel.org/tip/cb8382e05817a8104ea0edb63b8e37b8fbecd14c
Author: Jiri Olsa 
AuthorDate: Wed, 4 Nov 2015 15:08:11 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 5 Nov 2015 11:39:38 -0300

perf tools: Insert split maps correctly into origin group

When new maps are cloned out of split map they are added into origin
map's group, but their groups pointer is not updated.

This could lead to a segfault, because map->groups is expected to be
always set as reported by Markus:

  __map__is_kernel (map=map@entry=0x1abb7a0) at util/map.c:238
  238 return __machine__kernel_map(map->groups->machine, map->type) 
=
  (gdb) bt
  #0  __map__is_kernel (map=map@entry=0x1abb7a0) at util/map.c:238
  #1  0x004393e4 in symbol_filter (map=map@entry=0x1abb7a0, 
sym=sym@entry
  #2  0x004fcd4d in dso__load_sym (dso=dso@entry=0x166dae0, 
map=map@entry
  #3  0x004a64e0 in dso__load (dso=0x166dae0, map=map@entry=0x1abb7a0, 
fi
  #4  0x004b941f in map__load (filter=0x4393c0 , 
map=groups pointer update. It takes no lock as opposed to existing
map_groups__insert, as maps__fixup_overlappings(), where it is being
called, already has the necessary lock held.

Using __map_groups__insert to add new maps after map split.

Reported-by: Markus Trippelsdorf 
Signed-off-by: Jiri Olsa 
Tested-by: Markus Trippelsdorf 
Cc: Andrew Morton 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/20151104140811.ga32...@krava.brq.redhat.com
Fixes: cfc5acd4c80b ("perf top: Filter symbols based on __map__is_kernel(map)")
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/map.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 4e38c39..afc6b56 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -644,6 +644,12 @@ size_t map_groups__fprintf(struct map_groups *mg, FILE *fp)
return printed;
 }
 
+static void __map_groups__insert(struct map_groups *mg, struct map *map)
+{
+   __maps__insert(>maps[map->type], map);
+   map->groups = mg;
+}
+
 static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE 
*fp)
 {
struct rb_root *root;
@@ -682,7 +688,7 @@ static int maps__fixup_overlappings(struct maps *maps, 
struct map *map, FILE *fp
}
 
before->end = map->start;
-   __maps__insert(maps, before);
+   __map_groups__insert(pos->groups, before);
if (verbose >= 2)
map__fprintf(before, fp);
}
@@ -696,7 +702,7 @@ static int maps__fixup_overlappings(struct maps *maps, 
struct map *map, FILE *fp
}
 
after->start = map->end;
-   __maps__insert(maps, after);
+   __map_groups__insert(pos->groups, after);
if (verbose >= 2)
map__fprintf(after, fp);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf stat: Use common printout function to avoid duplicated code

2015-11-07 Thread tip-bot for Andi Kleen
Commit-ID:  eedfcb4bc5f0185a14fc9e1e5a9770ad833ea5a4
Gitweb: http://git.kernel.org/tip/eedfcb4bc5f0185a14fc9e1e5a9770ad833ea5a4
Author: Andi Kleen 
AuthorDate: Mon, 2 Nov 2015 17:50:21 -0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 4 Nov 2015 15:12:04 -0300

perf stat: Use common printout function to avoid duplicated code

Instead of every caller deciding whether to call abs or nsec printout
do it all in a single central function. No functional changes.

Signed-off-by: Andi Kleen 
Acked-by: Jiri Olsa 
Link: 
http://lkml.kernel.org/r/1446515428-7450-3-git-send-email-a...@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-stat.c | 57 +--
 1 file changed, 20 insertions(+), 37 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 8a78895..b74ee0f 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -493,7 +493,6 @@ static void nsec_printout(int id, int nr, struct perf_evsel 
*evsel, double avg)
double msecs = avg / 1e6;
const char *fmt_v, *fmt_n;
char name[25];
-   int cpu = cpu_map__id_to_cpu(id);
 
fmt_v = csv_output ? "%.6f%s" : "%18.6f%s";
fmt_n = csv_output ? "%s" : "%-25s";
@@ -514,12 +513,6 @@ static void nsec_printout(int id, int nr, struct 
perf_evsel *evsel, double avg)
 
if (evsel->cgrp)
fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
-
-   if (csv_output || stat_config.interval)
-   return;
-
-   perf_stat__print_shadow_stats(output, evsel, avg, cpu,
- stat_config.aggr_mode);
 }
 
 static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
@@ -527,7 +520,6 @@ static void abs_printout(int id, int nr, struct perf_evsel 
*evsel, double avg)
FILE *output = stat_config.output;
double sc =  evsel->scale;
const char *fmt;
-   int cpu = cpu_map__id_to_cpu(id);
 
if (csv_output) {
fmt = sc != 1.0 ?  "%.2f%s" : "%.0f%s";
@@ -540,9 +532,6 @@ static void abs_printout(int id, int nr, struct perf_evsel 
*evsel, double avg)
 
aggr_printout(evsel, id, nr);
 
-   if (stat_config.aggr_mode == AGGR_GLOBAL)
-   cpu = 0;
-
fprintf(output, fmt, avg, csv_sep);
 
if (evsel->unit)
@@ -554,12 +543,24 @@ static void abs_printout(int id, int nr, struct 
perf_evsel *evsel, double avg)
 
if (evsel->cgrp)
fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
+}
 
-   if (csv_output || stat_config.interval)
-   return;
+static void printout(int id, int nr, struct perf_evsel *counter, double uval)
+{
+   int cpu = cpu_map__id_to_cpu(id);
+
+   if (stat_config.aggr_mode == AGGR_GLOBAL)
+   cpu = 0;
+
+   if (nsec_counter(counter))
+   nsec_printout(id, nr, counter, uval);
+   else
+   abs_printout(id, nr, counter, uval);
 
-   perf_stat__print_shadow_stats(output, evsel, avg, cpu,
- stat_config.aggr_mode);
+   if (!csv_output && !stat_config.interval)
+   perf_stat__print_shadow_stats(stat_config.output, counter,
+ uval, cpu,
+ stat_config.aggr_mode);
 }
 
 static void print_aggr(char *prefix)
@@ -615,12 +616,7 @@ static void print_aggr(char *prefix)
continue;
}
uval = val * counter->scale;
-
-   if (nsec_counter(counter))
-   nsec_printout(id, nr, counter, uval);
-   else
-   abs_printout(id, nr, counter, uval);
-
+   printout(id, nr, counter, uval);
if (!csv_output)
print_noise(counter, 1.0);
 
@@ -651,11 +647,7 @@ static void print_aggr_thread(struct perf_evsel *counter, 
char *prefix)
fprintf(output, "%s", prefix);
 
uval = val * counter->scale;
-
-   if (nsec_counter(counter))
-   nsec_printout(thread, 0, counter, uval);
-   else
-   abs_printout(thread, 0, counter, uval);
+   printout(thread, 0, counter, uval);
 
if (!csv_output)
print_noise(counter, 1.0);
@@ -705,11 +697,7 @@ static void print_counter_aggr(struct perf_evsel *counter, 
char *prefix)
}
 
uval = avg * counter->scale;
-
-   if (nsec_counter(counter))
-   nsec_printout(-1, 0, counter, uval);
-   else
-   abs_printout(-1, 0, counter, uval);
+   printout(-1, 0, counter, uval);
 
print_noise(counter, avg);
 
@@ -762,12 +750,7 @@ static void print_counter(struct perf_evsel *counter, char 

[tip:perf/urgent] perf stat: Move sw clock metrics printout to stat-shadow

2015-11-07 Thread tip-bot for Andi Kleen
Commit-ID:  4579ecc8b3e0c611b5c8f6ca7f7b07d1412d8a7b
Gitweb: http://git.kernel.org/tip/4579ecc8b3e0c611b5c8f6ca7f7b07d1412d8a7b
Author: Andi Kleen 
AuthorDate: Mon, 2 Nov 2015 17:50:20 -0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 4 Nov 2015 15:11:41 -0300

perf stat: Move sw clock metrics printout to stat-shadow

The sw clock metrics printing was missed in the earlier move to
stat-shadow of all the other metric printouts. Move it too.

v2: Fix metrics printing in this version to make bisect safe.

Signed-off-by: Andi Kleen 
Acked-by: Jiri Olsa 
Link: 
http://lkml.kernel.org/r/1446515428-7450-2-git-send-email-a...@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-stat.c | 8 +++-
 tools/perf/util/stat-shadow.c | 5 +
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 2f438f7..8a78895 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -493,6 +493,7 @@ static void nsec_printout(int id, int nr, struct perf_evsel 
*evsel, double avg)
double msecs = avg / 1e6;
const char *fmt_v, *fmt_n;
char name[25];
+   int cpu = cpu_map__id_to_cpu(id);
 
fmt_v = csv_output ? "%.6f%s" : "%18.6f%s";
fmt_n = csv_output ? "%s" : "%-25s";
@@ -517,11 +518,8 @@ static void nsec_printout(int id, int nr, struct 
perf_evsel *evsel, double avg)
if (csv_output || stat_config.interval)
return;
 
-   if (perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK))
-   fprintf(output, " # %8.3f CPUs utilized  ",
-   avg / avg_stats(_nsecs_stats));
-   else
-   fprintf(output, "   ");
+   perf_stat__print_shadow_stats(output, evsel, avg, cpu,
+ stat_config.aggr_mode);
 }
 
 static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 2a5d8d7..6ac0314 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -413,6 +413,11 @@ void perf_stat__print_shadow_stats(FILE *out, struct 
perf_evsel *evsel,
ratio = total / avg;
 
fprintf(out, " # %8.0f cycles / elision   ", ratio);
+   } else if (perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK)) {
+   if ((ratio = avg_stats(_nsecs_stats)) != 0)
+   fprintf(out, " # %8.3f CPUs utilized  ", avg / 
ratio);
+   else
+   fprintf(out, "   ");
} else if (runtime_nsecs_stats[cpu].n != 0) {
char unit = 'M';
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf test: Keep test result clean if '-v' not set

2015-11-07 Thread tip-bot for Wang Nan
Commit-ID:  597bdeb4ab7396c43935eded15f82e3e100b3ff3
Gitweb: http://git.kernel.org/tip/597bdeb4ab7396c43935eded15f82e3e100b3ff3
Author: Wang Nan 
AuthorDate: Tue, 3 Nov 2015 10:44:42 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Nov 2015 11:45:40 -0300

perf test: Keep test result clean if '-v' not set

According to [1], 'perf test' should avoid output too much information
if '-v' is not set, only 'Ok', 'FAIL' or 'Skip' need to be printed.

This patch removes several messages sent directly to stderr to make
the output clean.

Before this patch:

  # perf test dummy
  23: Test using a dummy software event to keep tracking   : (not 
supported) Ok

After this patch:

  # perf test dummy
  23: Test using a dummy software event to keep tracking   : Skip

[1] http://lkml.kernel.org/r/20151020134155.ge4...@redhat.com

Signed-off-by: Wang Nan 
Acked-by: Namhyung Kim 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1446547486-229499-2-git-send-email-wangn...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/attr.c|  3 +--
 tools/perf/tests/code-reading.c|  8 
 tools/perf/tests/keep-tracking.c   |  4 ++--
 tools/perf/tests/llvm.c| 11 ---
 tools/perf/tests/switch-tracking.c |  4 ++--
 5 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index 2dfc9ad..638875a 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -171,6 +171,5 @@ int test__attr(void)
!lstat(path_perf, ))
return run_dir(path_dir, path_perf);
 
-   fprintf(stderr, " (omitted)");
-   return 0;
+   return TEST_SKIP;
 }
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 49b1959..a767a64 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -613,16 +613,16 @@ int test__code_reading(void)
case TEST_CODE_READING_OK:
return 0;
case TEST_CODE_READING_NO_VMLINUX:
-   fprintf(stderr, " (no vmlinux)");
+   pr_debug("no vmlinux\n");
return 0;
case TEST_CODE_READING_NO_KCORE:
-   fprintf(stderr, " (no kcore)");
+   pr_debug("no kcore\n");
return 0;
case TEST_CODE_READING_NO_ACCESS:
-   fprintf(stderr, " (no access)");
+   pr_debug("no access\n");
return 0;
case TEST_CODE_READING_NO_KERNEL_OBJ:
-   fprintf(stderr, " (no kernel obj)");
+   pr_debug("no kernel obj\n");
return 0;
default:
return -1;
diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c
index 4d4b983..a2e2269 100644
--- a/tools/perf/tests/keep-tracking.c
+++ b/tools/perf/tests/keep-tracking.c
@@ -90,8 +90,8 @@ int test__keep_tracking(void)
evsel->attr.enable_on_exec = 0;
 
if (perf_evlist__open(evlist) < 0) {
-   fprintf(stderr, " (not supported)");
-   err = 0;
+   pr_debug("Unable to open dummy and cycles event\n");
+   err = TEST_SKIP;
goto out_err;
}
 
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index 52d5597..512d362 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -36,7 +36,7 @@ static int test__bpf_parsing(void *obj_buf, size_t obj_buf_sz)
 static int test__bpf_parsing(void *obj_buf __maybe_unused,
 size_t obj_buf_sz __maybe_unused)
 {
-   fprintf(stderr, " (skip bpf parsing)");
+   pr_debug("Skip bpf parsing\n");
return 0;
 }
 #endif
@@ -55,7 +55,7 @@ int test__llvm(void)
 * and clang is not found in $PATH, and this is not perf test -v
 */
if (verbose == 0 && !llvm_param.user_set_param && llvm__search_clang()) 
{
-   fprintf(stderr, " (no clang, try 'perf test -v LLVM')");
+   pr_debug("No clang and no verbosive, skip this test\n");
return TEST_SKIP;
}
 
@@ -86,11 +86,8 @@ int test__llvm(void)
err = llvm__compile_bpf("-", _buf, _buf_sz);
 
verbose = old_verbose;
-   if (err) {
-   if (!verbose)
-   fprintf(stderr, " (use -v to see error message)");
-   return -1;
-   }
+   if (err)
+   return TEST_FAIL;
 
err = test__bpf_parsing(obj_buf, obj_buf_sz);
free(obj_buf);
diff --git a/tools/perf/tests/switch-tracking.c 
b/tools/perf/tests/switch-tracking.c
index e698742..a02af50 100644
--- a/tools/perf/tests/switch-tracking.c
+++ b/tools/perf/tests/switch-tracking.c
@@ -366,7 +366,7 @@ int test__switch_tracking(void)
 
/* Third event */
if (!perf_evlist__can_select_event(evlist, sched_switch)) {
-   fprintf(stderr, " (no sched_switch)");
+   

[tip:perf/urgent] tools lib bpf: Fix compiler warning on CentOS 6

2015-11-07 Thread tip-bot for Namhyung Kim
Commit-ID:  715f8db9102f1ab40ea4a87bedfe86399323698f
Gitweb: http://git.kernel.org/tip/715f8db9102f1ab40ea4a87bedfe86399323698f
Author: Namhyung Kim 
AuthorDate: Tue, 3 Nov 2015 20:21:05 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Nov 2015 12:13:31 -0300

tools lib bpf: Fix compiler warning on CentOS 6

CC   libbpf.o
  cc1: warnings being treated as errors
  libbpf.c: In function 'bpf_program__title':
  libbpf.c:1037: error: declaration of 'dup' shadows a global declaration
  /usr/include/unistd.h:528: error: shadowed declaration is here
  mv: cannot stat `./.libbpf.o.tmp': No such file or directory
  make[3]: *** [libbpf.o] Error 1
  make[2]: *** [libbpf-in.o] Error 2
  make[1]: *** [/linux/tools/lib/bpf/libbpf.a] Error 2
  make[1]: *** Waiting for unfinished jobs

Signed-off-by: Namhyung Kim 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Cc: Wang Nan 
Link: 
http://lkml.kernel.org/r/1446549665-2342-1-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/bpf/libbpf.c | 4 ++--
 tools/lib/bpf/libbpf.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 4252fc2..9f3c8cf 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1034,12 +1034,12 @@ int bpf_program__get_private(struct bpf_program *prog, 
void **ppriv)
return 0;
 }
 
-const char *bpf_program__title(struct bpf_program *prog, bool dup)
+const char *bpf_program__title(struct bpf_program *prog, bool needs_copy)
 {
const char *title;
 
title = prog->section_name;
-   if (dup) {
+   if (needs_copy) {
title = strdup(title);
if (!title) {
pr_warning("failed to strdup program title\n");
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index f16170c..bc80af0 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -63,7 +63,7 @@ int bpf_program__set_private(struct bpf_program *prog, void 
*priv,
 int bpf_program__get_private(struct bpf_program *prog,
 void **ppriv);
 
-const char *bpf_program__title(struct bpf_program *prog, bool dup);
+const char *bpf_program__title(struct bpf_program *prog, bool needs_copy);
 
 int bpf_program__fd(struct bpf_program *prog);
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/urgent] perf bpf: Mute libbpf when '-v' not set

2015-11-07 Thread tip-bot for Wang Nan
Commit-ID:  7a0119468c9c2deff24ef24e1b4d2c1bd1523fd5
Gitweb: http://git.kernel.org/tip/7a0119468c9c2deff24ef24e1b4d2c1bd1523fd5
Author: Wang Nan 
AuthorDate: Tue, 3 Nov 2015 10:44:43 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Nov 2015 12:06:04 -0300

perf bpf: Mute libbpf when '-v' not set

According to [1], libbpf should be muted. This patch reset info and
warning message level to ensure libbpf doesn't output anything even
if error happened.

[1] http://lkml.kernel.org/r/20151020151255.gf5...@kernel.org

Committer note:

Before:

Testing it with an incompatible kernel version in the .c file that
generated foo.o:

  [root@zoo ~]# perf record -e /tmp/foo.o sleep 1
  libbpf: load bpf program failed: Invalid argument
  libbpf: -- BEGIN DUMP LOG ---
  libbpf:

  libbpf: -- END LOG --
  libbpf: failed to load program 'fork=_do_fork'
  libbpf: failed to load object '/tmp/foo.o'
  event syntax error: '/tmp/foo.o'
   \___ Invalid argument: Are you root and runing a 
CONFIG_BPF_SYSCALL kernel?

  (add -v to see detail)
  Run 'perf list' for a list of valid events

   Usage: perf record [] []
  or: perf record [] --  []

  -e, --eventevent selector. use 'perf list' to list available 
events
  [root@zoo ~]#

After:

  [root@zoo ~]# perf record -e /tmp/foo.o sleep 1
  event syntax error: '/tmp/foo.o'
   \___ Invalid argument: Are you root and runing a 
CONFIG_BPF_SYSCALL kernel?

  (add -v to see detail)
  Run 'perf list' for a list of valid events

   Usage: perf record [] []
  or: perf record [] --  []

  -e, --eventevent selector. use 'perf list' to list available 
events
  [root@zoo ~]#

This, BTW, need fixing to emit a proper message by validating the
version in the foo.o "version" ELF section against the running kernel,
warning the user instead of asking the kernel to load a binary that it
will refuse due to unmatching kernel version.

Signed-off-by: Wang Nan 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1446547486-229499-3-git-send-email-wangn...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/bpf-loader.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index ba6f752..0c5d174 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -26,8 +26,8 @@ static int libbpf_##name(const char *fmt, ...)\
return ret; \
 }
 
-DEFINE_PRINT_FN(warning, 0)
-DEFINE_PRINT_FN(info, 0)
+DEFINE_PRINT_FN(warning, 1)
+DEFINE_PRINT_FN(info, 1)
 DEFINE_PRINT_FN(debug, 1)
 
 struct bpf_prog_priv {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL 00/11] perf/core improvements and fixes

2015-11-07 Thread Ingo Molnar

* Arnaldo Carvalho de Melo  wrote:

> Hi Ingo,
> 
>   Please consider pulling, this is on top of the perf-core-for-mingo tag,
> that is outstanding.
> 
> Best regards,
> 
> - Arnaldo
> 
> The following changes since commit 0014de172d228e450377d1fd079d94e67128d27f:
> 
>   perf sched latency: Fix thread pid reuse issue (2015-11-05 12:51:00 -0300)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git 
> tags/perf-core-for-mingo-2
> 
> for you to fetch changes up to 345c99a303e1d97b407bf99190314a878d59ca92:
> 
>   perf test: Do not be case sensitive when searching for matching tests 
> (2015-11-06 17:50:04 -0300)
> 
> 
> perf/core improvements and fixes:
> 
> - libbpf error reporting improvements, using a strerror interface to
>   more precisely tell the user about problems with the provided
>   scriptlet, be it in C or as a ready made object file (Wang Nan)
> 
> - Do not be case sensitive when searching for matching 'perf test'
>   entries (Arnaldo Carvalho de Melo)
> 
> - Inform the user about objdump failures in 'perf annotate' (Andi Kleen)
> 
> Infrastructure:
> 
> - Improve the LLVM 'perf test' entry, introduce new ones for
>   BPF and kbuild to check the environment used by clang to
>   compile .c scriptlets (Wang Nan)
> 
> Signed-off-by: Arnaldo Carvalho de Melo 
> 
> 
> Andi Kleen (1):
>   perf annotate: Inform the user about objdump failures in --stdio
> 
> Arnaldo Carvalho de Melo (1):
>   perf test: Do not be case sensitive when searching for matching tests
> 
> Jiri Olsa (1):
>   perf stat: Make stat options global
> 
> Masami Hiramatsu (1):
>   perf probe: Cleanup find_perf_probe_point_from_map to reduce redundancy
> 
> Wang Nan (7):
>   bpf tools: Improve libbpf error reporting
>   bpf tools: Add new API bpf_object__get_kversion()
>   perf tools: Make fetch_kernel_version() publicly available
>   perf bpf: Improve BPF related error messages
>   perf test: Enhance the LLVM test: update basic BPF test program
>   perf test: Enhance the LLVM tests: add kbuild test
>   perf test: Add 'perf test BPF'
> 
>  tools/lib/bpf/libbpf.c| 167 +---
>  tools/lib/bpf/libbpf.h|  21 +++
>  tools/perf/builtin-stat.c | 163 +++
>  tools/perf/tests/Build|  17 ++-
>  tools/perf/tests/bpf-script-example.c |   4 +
>  tools/perf/tests/bpf-script-test-kbuild.c |  21 +++
>  tools/perf/tests/bpf.c| 209 
> ++
>  tools/perf/tests/builtin-test.c   |   6 +-
>  tools/perf/tests/llvm.c   | 137 +++-
>  tools/perf/tests/llvm.h   |  18 +++
>  tools/perf/tests/tests.h  |   1 +
>  tools/perf/util/annotate.c|  20 ++-
>  tools/perf/util/bpf-loader.c  | 139 +---
>  tools/perf/util/bpf-loader.h  |  33 +
>  tools/perf/util/llvm-utils.c  |  49 +++
>  tools/perf/util/parse-events.c|  11 +-
>  tools/perf/util/probe-event.c |   7 +-
>  tools/perf/util/util.c|  30 +
>  tools/perf/util/util.h|   8 ++
>  19 files changed, 836 insertions(+), 225 deletions(-)
>  create mode 100644 tools/perf/tests/bpf-script-test-kbuild.c
>  create mode 100644 tools/perf/tests/bpf.c
>  create mode 100644 tools/perf/tests/llvm.h

Pulled into perf/urgent, thanks a lot Arnaldo!

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 12/12] staging: rtl8188eu: remove unused RTW_STATUS_CODE function

2015-11-07 Thread Ivan Safonov
This driver is only for the Linux kernel.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/include/osdep_service.h |  2 --
 drivers/staging/rtl8188eu/os_dep/osdep_service.c  | 11 ---
 2 files changed, 13 deletions(-)

diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h 
b/drivers/staging/rtl8188eu/include/osdep_service.h
index 22de53d..194e56d 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -75,8 +75,6 @@ static inline int rtw_netif_queue_stopped(struct net_device 
*pnetdev)
netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3));
 }
 
-int RTW_STATUS_CODE(int error_code);
-
 #define rtw_update_mem_stat(flag, sz) do {} while (0)
 u8 *_rtw_malloc(u32 sz);
 #define rtw_malloc(sz) _rtw_malloc((sz))
diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c 
b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index d87b547..9606214 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -28,17 +28,6 @@
 #include 
 #include 
 
-/*
-* Translate the OS dependent @param error_code to OS independent 
RTW_STATUS_CODE
-* @return: one of RTW_STATUS_CODE
-*/
-inline int RTW_STATUS_CODE(int error_code)
-{
-   if (error_code >= 0)
-   return _SUCCESS;
-   return _FAIL;
-}
-
 u8 *_rtw_malloc(u32 sz)
 {
u8  *pbuf = NULL;
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 10/12] staging: rtl8188eu: reg_macid variable removed in hw_var_set_macaddr

2015-11-07 Thread Ivan Safonov
The reg_macid variable used only once. Also idx renamed to i and Adapter to 
adapter.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/usb_halinit.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c 
b/drivers/staging/rtl8188eu/hal/usb_halinit.c
index 5789e1e..e1d6632 100644
--- a/drivers/staging/rtl8188eu/hal/usb_halinit.c
+++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c
@@ -1253,15 +1253,12 @@ static void hw_var_set_opmode(struct adapter *Adapter, 
u8 variable, u8 *val)
}
 }
 
-static void hw_var_set_macaddr(struct adapter *Adapter, u8 variable, u8 *val)
+static void hw_var_set_macaddr(struct adapter *adapter, u8 variable, u8 *val)
 {
-   u8 idx = 0;
-   u32 reg_macid;
-
-   reg_macid = REG_MACID;
+   int i;
 
-   for (idx = 0; idx < 6; idx++)
-   usb_write8(Adapter, (reg_macid+idx), val[idx]);
+   for (i = 0; i < 6; i++)
+   usb_write8(adapter, REG_MACID + i, val[i]);
 }
 
 static void hw_var_set_bssid(struct adapter *Adapter, u8 variable, u8 *val)
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 11/12] staging: rtl8188eu: reg_bssid variable removed in hw_var_set_bssid

2015-11-07 Thread Ivan Safonov
The reg_bssid variable used only once. Also idx renamed to i and Adapter to 
adapter.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/usb_halinit.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c 
b/drivers/staging/rtl8188eu/hal/usb_halinit.c
index e1d6632..01b0026 100644
--- a/drivers/staging/rtl8188eu/hal/usb_halinit.c
+++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c
@@ -1261,15 +1261,12 @@ static void hw_var_set_macaddr(struct adapter *adapter, 
u8 variable, u8 *val)
usb_write8(adapter, REG_MACID + i, val[i]);
 }
 
-static void hw_var_set_bssid(struct adapter *Adapter, u8 variable, u8 *val)
+static void hw_var_set_bssid(struct adapter *adapter, u8 variable, u8 *val)
 {
-   u8 idx = 0;
-   u32 reg_bssid;
-
-   reg_bssid = REG_BSSID;
+   int i;
 
-   for (idx = 0; idx < 6; idx++)
-   usb_write8(Adapter, (reg_bssid+idx), val[idx]);
+   for (i = 0; i < 6; i++)
+   usb_write8(adapter, REG_BSSID + i, val[i]);
 }
 
 static void hw_var_set_bcn_func(struct adapter *Adapter, u8 variable, u8 *val)
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 09/12] staging: rtl8188eu: remove redundant spases

2015-11-07 Thread Ivan Safonov
They are not needed.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 62f83ab..0e2528a 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -468,7 +468,7 @@ static int wpa_set_encryption(struct net_device *dev, 
struct ieee_param *param,
 
rtw_setstakey_cmd(padapter, (unsigned 
char *)psta, true);
} else { /* group key */
-   
memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey,  
param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16 ));
+   
memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, 
param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16));

memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, 
&(param->u.crypt.key[16]), 8);

memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, 
&(param->u.crypt.key[24]), 8);
padapter->securitypriv.binstallGrpkey = 
true;
@@ -486,7 +486,7 @@ static int wpa_set_encryption(struct net_device *dev, 
struct ieee_param *param,
pbcmc_sta->ieee8021x_blocked = false;
 
if ((padapter->securitypriv.ndisencryptstatus 
== Ndis802_11Encryption2Enabled) ||
-   (padapter->securitypriv.ndisencryptstatus 
==  Ndis802_11Encryption3Enabled))
+   (padapter->securitypriv.ndisencryptstatus 
== Ndis802_11Encryption3Enabled))
pbcmc_sta->dot118021XPrivacy = 
padapter->securitypriv.dot11PrivacyAlgrthm;
}
}
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 08/12] staging: rtl8188eu: if (a) ; else {...} replaced by if (!a) {...}

2015-11-07 Thread Ivan Safonov
It is looks bit better.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 7c79774..62f83ab 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -447,9 +447,7 @@ static int wpa_set_encryption(struct net_device *dev, 
struct ieee_param *param,
 
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | 
WIFI_MP_STATE)) { /* sta mode */
psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv));
-   if (psta == NULL) {
-   ;
-   } else {
+   if (psta) {
if (strcmp(param->u.crypt.alg, "none") != 0)
psta->ieee8021x_blocked = false;
 
@@ -482,9 +480,7 @@ static int wpa_set_encryption(struct net_device *dev, 
struct ieee_param *param,
}
}
pbcmc_sta = rtw_get_bcmc_stainfo(padapter);
-   if (pbcmc_sta == NULL) {
-   ;
-   } else {
+   if (pbcmc_sta) {
/* Jeff: don't disable ieee8021x_blocked while 
clearing key */
if (strcmp(param->u.crypt.alg, "none") != 0)
pbcmc_sta->ieee8021x_blocked = false;
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 06/12] staging: rtl8188eu: use memset instead of for loop

2015-11-07 Thread Ivan Safonov
memset clearer than the for loop.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 7f1df4d..298e3e8 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -77,12 +77,12 @@ static void _rtl88e_fw_block_write(struct adapter *adapt,
 
 static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
 {
-   u32 i;
+   u32 remain = round_up(pfwlen, 4) - pfwlen;
 
-   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
-   pfwbuf[i] = 0;
+   if (remain)
+   memset(pfwbuf, 0, remain);
 
-   return i;
+   return pfwlen + remain;
 }
 
 static void _rtl88e_fw_page_write(struct adapter *adapt,
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 07/12] staging: rtl8188eu: sets the error code in wpa_set_encryption

2015-11-07 Thread Ivan Safonov
Most likely it is missed here.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index a076ede..7c79774 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -407,6 +407,7 @@ static int wpa_set_encryption(struct net_device *dev, 
struct ieee_param *param,
pwep = (struct ndis_802_11_wep 
*)rtw_malloc(wep_total_len);
if (pwep == NULL) {
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, 
(" wpa_set_encryption: pwep allocate fail !!!\n"));
+   ret = -ENOMEM;
goto exit;
}
memset(pwep, 0, wep_total_len);
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 05/12] staging: rtl8188eu: kzalloc replaced by kmalloc

2015-11-07 Thread Ivan Safonov
_rtl88e_fill_dummy fills the array elemets with zeros if necessary.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 1d8930a..7f1df4d 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -189,7 +189,7 @@ int rtl88eu_download_fw(struct adapter *adapt)
return -EFBIG;
}
 
-   pfwdata = kzalloc(FW_8188E_SIZE, GFP_KERNEL);
+   pfwdata = kmalloc(FW_8188E_SIZE, GFP_KERNEL);
if (!pfwdata)
return -ENOMEM;
 
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 04/12] staging: rtl8188eu: remove unused hal_data_8188e members

2015-11-07 Thread Ivan Safonov
u8 *pfirmware and u32 fwsize of hal_data_8188e structure not used.

The pfwdata variable used to store a pointer to the buffer
in rtl88eu_download_fw and the pfwbody variable points to the body
of the firmware (without header).

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c   | 16 
 drivers/staging/rtl8188eu/include/rtl8188e_hal.h |  2 --
 drivers/staging/rtl8188eu/os_dep/os_intfs.c  |  4 
 3 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 3e354eb..1d8930a 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -170,13 +170,12 @@ exit:
 
 int rtl88eu_download_fw(struct adapter *adapt)
 {
-   struct hal_data_8188e *rtlhal = GET_HAL_DATA(adapt);
struct dvobj_priv *dvobj = adapter_to_dvobj(adapt);
struct device *device = dvobj_to_dev(dvobj);
const struct firmware *fw;
const char fw_name[] = "rtlwifi/rtl8188eufw.bin";
struct rtl92c_firmware_header *pfwheader = NULL;
-   u8 *pfwdata;
+   u8 *pfwdata, *pfwbody;
u32 fwsize;
 
if (request_firmware(, fw_name, device)) {
@@ -194,17 +193,17 @@ int rtl88eu_download_fw(struct adapter *adapt)
if (!pfwdata)
return -ENOMEM;
 
-   rtlhal->pfirmware = pfwdata;
-   memcpy(rtlhal->pfirmware, fw->data, fw->size);
-   rtlhal->fwsize = fw->size;
+   memcpy(pfwdata, fw->data, fw->size);
+   fwsize = fw->size;
release_firmware(fw);
 
-   fwsize = rtlhal->fwsize;
pfwheader = (struct rtl92c_firmware_header *)pfwdata;
 
if (IS_FW_HEADER_EXIST(pfwheader)) {
-   pfwdata = pfwdata + 32;
+   pfwbody = pfwdata + 32;
fwsize = fwsize - 32;
+   } else {
+   pfwbody = pfwdata;
}
 
if (usb_read8(adapt, REG_MCUFWDL) & RAM_DL_SEL) {
@@ -213,8 +212,9 @@ int rtl88eu_download_fw(struct adapter *adapt)
}
_rtl88e_enable_fw_download(adapt, true);
usb_write8(adapt, REG_MCUFWDL, usb_read8(adapt, REG_MCUFWDL) | 
FWDL_ChkSum_rpt);
-   _rtl88e_write_fw(adapt, pfwdata, fwsize);
+   _rtl88e_write_fw(adapt, pfwbody, fwsize);
_rtl88e_enable_fw_download(adapt, false);
 
+   kfree(pfwdata);
return _rtl88e_fw_free_to_go(adapt);
 }
diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h 
b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
index cbad364..9f5050e 100644
--- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
+++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
@@ -191,8 +191,6 @@ struct txpowerinfo24g {
 struct hal_data_8188e {
struct HAL_VERSION  VersionID;
u16 CustomerID;
-   u8 *pfirmware;
-   u32 fwsize;
u16 FirmwareVersion;
u16 FirmwareVersionRev;
u16 FirmwareSubVersion;
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c 
b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index 9201b94..2cca5d2 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -1157,7 +1157,6 @@ int pm_netdev_open(struct net_device *pnetdev, u8 bnormal)
 static int netdev_close(struct net_device *pnetdev)
 {
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
-   struct hal_data_8188e *rtlhal = GET_HAL_DATA(padapter);
 
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - drv_close\n"));
 
@@ -1190,9 +1189,6 @@ static int netdev_close(struct net_device *pnetdev)
rtw_led_control(padapter, LED_CTL_POWER_OFF);
}
 
-   kfree(rtlhal->pfirmware);
-   rtlhal->pfirmware = NULL;
-
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - drv_close\n"));
DBG_88E("-88eu_drv - drv_close, bup =%d\n", padapter->bup);
return 0;
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 03/12] staging: rtl8188eu: change error code from -1 to -EFBIG

2015-11-07 Thread Ivan Safonov
-EFBIG more sutiable then -1

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 5b569ef..3e354eb 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -187,7 +187,7 @@ int rtl88eu_download_fw(struct adapter *adapt)
if (fw->size > FW_8188E_SIZE) {
dev_err(device, "Firmware size exceed 0x%X. Check it.\n",
 FW_8188E_SIZE);
-   return -1;
+   return -EFBIG;
}
 
pfwdata = kzalloc(FW_8188E_SIZE, GFP_KERNEL);
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 02/12] staging: rtl8188eu: return value and argument types changed in _rtl88e_write_fw function

2015-11-07 Thread Ivan Safonov
Ideally the function should not change the variables outside of its body.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 4d72537..5b569ef 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -75,14 +75,14 @@ static void _rtl88e_fw_block_write(struct adapter *adapt,
usb_write8(adapt, write_address, byte_buffer[i]);
 }
 
-static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
+static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
 {
u32 i;
 
-   for (i = *pfwlen; i < roundup(*pfwlen, 4); i++)
+   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
pfwbuf[i] = 0;
 
-   *pfwlen = i;
+   return i;
 }
 
 static void _rtl88e_fw_page_write(struct adapter *adapt,
@@ -103,7 +103,7 @@ static void _rtl88e_write_fw(struct adapter *adapt, u8 
*buffer, u32 size)
u32 page_no, remain;
u32 page, offset;
 
-   _rtl88e_fill_dummy(buf_ptr, );
+   size = _rtl88e_fill_dummy(buf_ptr, size);
 
page_no = size / FW_8192C_PAGE_SIZE;
remain = size % FW_8192C_PAGE_SIZE;
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 01/12] staging: rtl8188eu: if/else replaced by min_t

2015-11-07 Thread Ivan Safonov
Duplicated code removed.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/core/rtw_cmd.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c 
b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index 433b926..69f8744d9 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -442,10 +442,8 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
wlan_network *pnetwork)
 
psecuritypriv->authenticator_ie[0] = (unsigned 
char)psecnetwork->IELength;
 
-   if ((psecnetwork->IELength-12) < (256-1))
-   memcpy(>authenticator_ie[1], 
>IEs[12], psecnetwork->IELength-12);
-   else
-   memcpy(>authenticator_ie[1], 
>IEs[12], (256-1));
+   memcpy(>authenticator_ie[1], >IEs[12],
+  min_t(size_t, psecnetwork->IELength - 12, 256 - 1));
 
psecnetwork->IELength = 0;
/*  Added by Albert 2009/02/18 */
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 12/12] staging: rtl8188eu: remove unused RTW_STATUS_CODE function

2015-11-07 Thread Ivan Safonov

On 11/08/2015 01:53 PM, Ivan Safonov wrote:

This driver is only for the Linux kernel.

Signed-off-by: Ivan Safonov 
---
  drivers/staging/rtl8188eu/include/osdep_service.h |  2 --
  drivers/staging/rtl8188eu/os_dep/osdep_service.c  | 11 ---
  2 files changed, 13 deletions(-)

diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h 
b/drivers/staging/rtl8188eu/include/osdep_service.h
index 22de53d..194e56d 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -75,8 +75,6 @@ static inline int rtw_netif_queue_stopped(struct net_device 
*pnetdev)
netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3));
  }
  
-int RTW_STATUS_CODE(int error_code);

-
  #define rtw_update_mem_stat(flag, sz) do {} while (0)
  u8 *_rtw_malloc(u32 sz);
  #define rtw_malloc(sz)_rtw_malloc((sz))
diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c 
b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index d87b547..9606214 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -28,17 +28,6 @@
  #include 
  #include 
  
-/*

-* Translate the OS dependent @param error_code to OS independent 
RTW_STATUS_CODE
-* @return: one of RTW_STATUS_CODE
-*/
-inline int RTW_STATUS_CODE(int error_code)
-{
-   if (error_code >= 0)
-   return _SUCCESS;
-   return _FAIL;
-}
-
  u8 *_rtw_malloc(u32 sz)
  {
u8  *pbuf = NULL;


Oops, I am sorry.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/12] staging: rtl8188eu: kzalloc replaced by kmalloc

2015-11-07 Thread Ivan Safonov
_rtl88e_fill_dummy fills the array elemets with zeros if necessary.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 1d8930a..7f1df4d 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -189,7 +189,7 @@ int rtl88eu_download_fw(struct adapter *adapt)
return -EFBIG;
}
 
-   pfwdata = kzalloc(FW_8188E_SIZE, GFP_KERNEL);
+   pfwdata = kmalloc(FW_8188E_SIZE, GFP_KERNEL);
if (!pfwdata)
return -ENOMEM;
 
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/13] staging: rtl8188eu: change error code from -1 to -EFBIG

2015-11-07 Thread Ivan Safonov
-EFBIG more sutiable then -1

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 5b569ef..3e354eb 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -187,7 +187,7 @@ int rtl88eu_download_fw(struct adapter *adapt)
if (fw->size > FW_8188E_SIZE) {
dev_err(device, "Firmware size exceed 0x%X. Check it.\n",
 FW_8188E_SIZE);
-   return -1;
+   return -EFBIG;
}
 
pfwdata = kzalloc(FW_8188E_SIZE, GFP_KERNEL);
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/13] staging: rtl8188eu: remove unused hal_data_8188e members

2015-11-07 Thread Ivan Safonov
u8 *pfirmware and u32 fwsize of hal_data_8188e structure not used.

The pfwdata variable used to store a pointer to the buffer
and the pfwbody variable points to the firmware body (firmware without
header).

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c   | 16 
 drivers/staging/rtl8188eu/include/rtl8188e_hal.h |  2 --
 drivers/staging/rtl8188eu/os_dep/os_intfs.c  |  4 
 3 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 3e354eb..1d8930a 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -170,13 +170,12 @@ exit:
 
 int rtl88eu_download_fw(struct adapter *adapt)
 {
-   struct hal_data_8188e *rtlhal = GET_HAL_DATA(adapt);
struct dvobj_priv *dvobj = adapter_to_dvobj(adapt);
struct device *device = dvobj_to_dev(dvobj);
const struct firmware *fw;
const char fw_name[] = "rtlwifi/rtl8188eufw.bin";
struct rtl92c_firmware_header *pfwheader = NULL;
-   u8 *pfwdata;
+   u8 *pfwdata, *pfwbody;
u32 fwsize;
 
if (request_firmware(, fw_name, device)) {
@@ -194,17 +193,17 @@ int rtl88eu_download_fw(struct adapter *adapt)
if (!pfwdata)
return -ENOMEM;
 
-   rtlhal->pfirmware = pfwdata;
-   memcpy(rtlhal->pfirmware, fw->data, fw->size);
-   rtlhal->fwsize = fw->size;
+   memcpy(pfwdata, fw->data, fw->size);
+   fwsize = fw->size;
release_firmware(fw);
 
-   fwsize = rtlhal->fwsize;
pfwheader = (struct rtl92c_firmware_header *)pfwdata;
 
if (IS_FW_HEADER_EXIST(pfwheader)) {
-   pfwdata = pfwdata + 32;
+   pfwbody = pfwdata + 32;
fwsize = fwsize - 32;
+   } else {
+   pfwbody = pfwdata;
}
 
if (usb_read8(adapt, REG_MCUFWDL) & RAM_DL_SEL) {
@@ -213,8 +212,9 @@ int rtl88eu_download_fw(struct adapter *adapt)
}
_rtl88e_enable_fw_download(adapt, true);
usb_write8(adapt, REG_MCUFWDL, usb_read8(adapt, REG_MCUFWDL) | 
FWDL_ChkSum_rpt);
-   _rtl88e_write_fw(adapt, pfwdata, fwsize);
+   _rtl88e_write_fw(adapt, pfwbody, fwsize);
_rtl88e_enable_fw_download(adapt, false);
 
+   kfree(pfwdata);
return _rtl88e_fw_free_to_go(adapt);
 }
diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h 
b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
index cbad364..9f5050e 100644
--- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
+++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
@@ -191,8 +191,6 @@ struct txpowerinfo24g {
 struct hal_data_8188e {
struct HAL_VERSION  VersionID;
u16 CustomerID;
-   u8 *pfirmware;
-   u32 fwsize;
u16 FirmwareVersion;
u16 FirmwareVersionRev;
u16 FirmwareSubVersion;
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c 
b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index 9201b94..2cca5d2 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -1157,7 +1157,6 @@ int pm_netdev_open(struct net_device *pnetdev, u8 bnormal)
 static int netdev_close(struct net_device *pnetdev)
 {
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
-   struct hal_data_8188e *rtlhal = GET_HAL_DATA(padapter);
 
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - drv_close\n"));
 
@@ -1190,9 +1189,6 @@ static int netdev_close(struct net_device *pnetdev)
rtw_led_control(padapter, LED_CTL_POWER_OFF);
}
 
-   kfree(rtlhal->pfirmware);
-   rtlhal->pfirmware = NULL;
-
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - drv_close\n"));
DBG_88E("-88eu_drv - drv_close, bup =%d\n", padapter->bup);
return 0;
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 09/12] staging: rtl8188eu: remove redundant spases

2015-11-07 Thread Ivan Safonov
They are not needed.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 62f83ab..0e2528a 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -468,7 +468,7 @@ static int wpa_set_encryption(struct net_device *dev, 
struct ieee_param *param,
 
rtw_setstakey_cmd(padapter, (unsigned 
char *)psta, true);
} else { /* group key */
-   
memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey,  
param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16 ));
+   
memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, 
param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16));

memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, 
&(param->u.crypt.key[16]), 8);

memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, 
&(param->u.crypt.key[24]), 8);
padapter->securitypriv.binstallGrpkey = 
true;
@@ -486,7 +486,7 @@ static int wpa_set_encryption(struct net_device *dev, 
struct ieee_param *param,
pbcmc_sta->ieee8021x_blocked = false;
 
if ((padapter->securitypriv.ndisencryptstatus 
== Ndis802_11Encryption2Enabled) ||
-   (padapter->securitypriv.ndisencryptstatus 
==  Ndis802_11Encryption3Enabled))
+   (padapter->securitypriv.ndisencryptstatus 
== Ndis802_11Encryption3Enabled))
pbcmc_sta->dot118021XPrivacy = 
padapter->securitypriv.dot11PrivacyAlgrthm;
}
}
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/12] staging: rtl8188eu: sets the error code in wpa_set_encryption

2015-11-07 Thread Ivan Safonov
Most likely it is missed here.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index a076ede..7c79774 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -407,6 +407,7 @@ static int wpa_set_encryption(struct net_device *dev, 
struct ieee_param *param,
pwep = (struct ndis_802_11_wep 
*)rtw_malloc(wep_total_len);
if (pwep == NULL) {
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, 
(" wpa_set_encryption: pwep allocate fail !!!\n"));
+   ret = -ENOMEM;
goto exit;
}
memset(pwep, 0, wep_total_len);
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 11/12] staging: rtl8188eu: reg_bssid variable removed in hw_var_set_bssid

2015-11-07 Thread Ivan Safonov
The reg_bssid variable used only once. Also idx renamed to i and Adapter to 
adapter.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/usb_halinit.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c 
b/drivers/staging/rtl8188eu/hal/usb_halinit.c
index e1d6632..01b0026 100644
--- a/drivers/staging/rtl8188eu/hal/usb_halinit.c
+++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c
@@ -1261,15 +1261,12 @@ static void hw_var_set_macaddr(struct adapter *adapter, 
u8 variable, u8 *val)
usb_write8(adapter, REG_MACID + i, val[i]);
 }
 
-static void hw_var_set_bssid(struct adapter *Adapter, u8 variable, u8 *val)
+static void hw_var_set_bssid(struct adapter *adapter, u8 variable, u8 *val)
 {
-   u8 idx = 0;
-   u32 reg_bssid;
-
-   reg_bssid = REG_BSSID;
+   int i;
 
-   for (idx = 0; idx < 6; idx++)
-   usb_write8(Adapter, (reg_bssid+idx), val[idx]);
+   for (i = 0; i < 6; i++)
+   usb_write8(adapter, REG_BSSID + i, val[i]);
 }
 
 static void hw_var_set_bcn_func(struct adapter *Adapter, u8 variable, u8 *val)
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/13] staging: rtl8188eu: if/else replaced by min_t

2015-11-07 Thread Ivan Safonov
Duplicated code removed.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/core/rtw_cmd.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c 
b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index 433b926..69f8744d9 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -442,10 +442,8 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
wlan_network *pnetwork)
 
psecuritypriv->authenticator_ie[0] = (unsigned 
char)psecnetwork->IELength;
 
-   if ((psecnetwork->IELength-12) < (256-1))
-   memcpy(>authenticator_ie[1], 
>IEs[12], psecnetwork->IELength-12);
-   else
-   memcpy(>authenticator_ie[1], 
>IEs[12], (256-1));
+   memcpy(>authenticator_ie[1], >IEs[12],
+  min_t(size_t, psecnetwork->IELength - 12, 256 - 1));
 
psecnetwork->IELength = 0;
/*  Added by Albert 2009/02/18 */
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 10/12] staging: rtl8188eu: reg_macid variable removed in hw_var_set_macaddr

2015-11-07 Thread Ivan Safonov
The reg_macid variable used only once. Also idx renamed to i and Adapter to 
adapter.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/usb_halinit.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c 
b/drivers/staging/rtl8188eu/hal/usb_halinit.c
index 5789e1e..e1d6632 100644
--- a/drivers/staging/rtl8188eu/hal/usb_halinit.c
+++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c
@@ -1253,15 +1253,12 @@ static void hw_var_set_opmode(struct adapter *Adapter, 
u8 variable, u8 *val)
}
 }
 
-static void hw_var_set_macaddr(struct adapter *Adapter, u8 variable, u8 *val)
+static void hw_var_set_macaddr(struct adapter *adapter, u8 variable, u8 *val)
 {
-   u8 idx = 0;
-   u32 reg_macid;
-
-   reg_macid = REG_MACID;
+   int i;
 
-   for (idx = 0; idx < 6; idx++)
-   usb_write8(Adapter, (reg_macid+idx), val[idx]);
+   for (i = 0; i < 6; i++)
+   usb_write8(adapter, REG_MACID + i, val[i]);
 }
 
 static void hw_var_set_bssid(struct adapter *Adapter, u8 variable, u8 *val)
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL] x86/mm changes for v4.4

2015-11-07 Thread Kees Cook
On Fri, Nov 6, 2015 at 11:39 PM, Ard Biesheuvel
 wrote:
> On 7 November 2015 at 08:09, Ingo Molnar  wrote:
>>
>> * Matt Fleming  wrote:
>>
>>> On Fri, 06 Nov, at 07:55:50AM, Ingo Molnar wrote:
>>> >
>>> >  3) We should fix the EFI permission problem without relying on the 
>>> > firmware: it
>>> > appears we could just mark everything R-X optimistically, and if a 
>>> > write fault
>>> > happens (it's pretty rare in fact, only triggers when we write to an 
>>> > EFI
>>> > variable and so), we can mark the faulting page RW- on the fly, 
>>> > because it
>>> > appears that writable EFI sections, while not enumerated very well in 
>>> > 'old'
>>> > firmware, are still supposed to be page granular. (Even 'new' 
>>> > firmware I
>>> > wouldn't automatically trust to get the enumeration right...)
>>>
>>> Sorry, this isn't true. I misled you with one of my earlier posts on
>>> this topic. Let me try and clear things up...
>>>
>>> Writing to EFI regions has to do with every invocation of the EFI
>>> runtime services - it's not limited to when you read/write/delete EFI
>>> variables. In fact, EFI variables really have nothing to do with this
>>> discussion, they're a completely opaque concept to the OS, we have no
>>> idea how the firmware implements them. Everything is done via the EFI
>>> boot/runtime services.
>>>
>>> The firmware itself will attempt to write to EFI regions when we
>>> invoke the EFI services because that's where the PE/COFF ".data" and
>>> ".bss" sections live along with the heap. There's even some relocation
>>> fixups that occur as SetVirtualAddressMap() time so it'll write to
>>> ".text" too.
>>>
>>> Now, the above PE/COFF sections are usually (always?) contained within
>>> EFI regions of type EfiRuntimeServicesCode. We know this is true
>>> because the firmware folks have told us so, and because stopping that
>>> is the motivation behind the new EFI_PROPERTIES_TABLE feature in UEFI
>>> V2.5.
>>>
>>> The data sections within the region are also *not* guaranteed to be
>>> page granular because work was required in Tianocore for emitting
>>> sections with 4k alignment as part of the EFI_PROPERTIES_TABLE
>>> support.
>>>
>>> Ultimately, what this means is that if you were to attempt to
>>> dynamically fixup those regions that required write permission, you'd
>>> have to modify the mappings for the majority of the EFI regions
>>> anyway. And if you're blindly allowing write permission as a fixup,
>>> there's not much security to be had.
>>
>> I think you misunderstood my suggestion: the 'fixup' would be changing it 
>> from R-X
>> to RW-, i.e. it would add 'write' permission but remove 'execute' permission.
>>
>> Note that there would be no 'RWX' permission at any given moment - which is 
>> the
>> dangerous combination.
>>
>
> The problem with that is that /any/ page in the UEFI runtime region
> may intersect with both .text and .data of any of the PE/COFF images
> that make up the runtime firmware (since the PE/COFF sections are not
> necessarily page aligned). Such pages require RWX permissions. The
> UEFI memory map does not provide the information to identify those
> pages a priori (the entire region containing several PE/COFF images
> could be covered by a single entry) so it is hard to guess which pages
> should be allowed these RWX permissions.

I'm sad that UEFI was designed without even the most basic of memory
protections in mind. UEFI _itself_ should be setting up protective
page mappings. :(

For a boot firmware, it seems to me that safe page table layout would
be a top priority bug. The "reporting issues" page for TianoCore
doesn't actually seem to link to the "Project Tracker":
https://github.com/tianocore/tianocore.github.io/wiki/Reporting-Issues

Does anyone know how to get this correctly reported so future UEFI
releases don't suffer from this?

-Kees

>
>>> > If that 'supposed to be' turns out to be 'not true' (not unheard of in
>>> > firmware land), then plan B would be to mark pages that generate 
>>> > write faults
>>> > RWX as well, to not break functionality. (This 'mark it RWX' is not 
>>> > something
>>> > that exploits would have easy access to, and we could also generate a 
>>> > warning
>>> > [after the EFI call has finished] if it ever triggers.)
>>> >
>>> > Admittedly this approach might not be without its own complications, 
>>> > but it
>>> > looks reasonably simple (I don't think we need per EFI call page 
>>> > tables,
>>> > etc.), and does not assume much about the firmware being able to 
>>> > enumerate its
>>> > permissions properly. Were we to merge EFI support today I'd have 
>>> > insisted on
>>> > trying such an approach from day 1 on.
>>>
>>> We already have separate EFI page tables, though with the caveat that
>>> we share some of swapper_pg_dir's PGD entries. The best solution would
>>> be to stop sharing entries and isolate the EFI mappings from every
>>> other page table structure, so 

[PATCH 03/12] staging: rtl8188eu: change error code from -1 to -EFBIG

2015-11-07 Thread Ivan Safonov
-EFBIG more sutiable then -1

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 5b569ef..3e354eb 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -187,7 +187,7 @@ int rtl88eu_download_fw(struct adapter *adapt)
if (fw->size > FW_8188E_SIZE) {
dev_err(device, "Firmware size exceed 0x%X. Check it.\n",
 FW_8188E_SIZE);
-   return -1;
+   return -EFBIG;
}
 
pfwdata = kzalloc(FW_8188E_SIZE, GFP_KERNEL);
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/12] staging: rtl8188eu: remove unused hal_data_8188e members

2015-11-07 Thread Ivan Safonov
u8 *pfirmware and u32 fwsize of hal_data_8188e structure not used.

The pfwdata variable used to store a pointer to the buffer
in rtl88eu_download_fw and the pfwbody variable points to the body
of the firmware (without header).

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c   | 16 
 drivers/staging/rtl8188eu/include/rtl8188e_hal.h |  2 --
 drivers/staging/rtl8188eu/os_dep/os_intfs.c  |  4 
 3 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 3e354eb..1d8930a 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -170,13 +170,12 @@ exit:
 
 int rtl88eu_download_fw(struct adapter *adapt)
 {
-   struct hal_data_8188e *rtlhal = GET_HAL_DATA(adapt);
struct dvobj_priv *dvobj = adapter_to_dvobj(adapt);
struct device *device = dvobj_to_dev(dvobj);
const struct firmware *fw;
const char fw_name[] = "rtlwifi/rtl8188eufw.bin";
struct rtl92c_firmware_header *pfwheader = NULL;
-   u8 *pfwdata;
+   u8 *pfwdata, *pfwbody;
u32 fwsize;
 
if (request_firmware(, fw_name, device)) {
@@ -194,17 +193,17 @@ int rtl88eu_download_fw(struct adapter *adapt)
if (!pfwdata)
return -ENOMEM;
 
-   rtlhal->pfirmware = pfwdata;
-   memcpy(rtlhal->pfirmware, fw->data, fw->size);
-   rtlhal->fwsize = fw->size;
+   memcpy(pfwdata, fw->data, fw->size);
+   fwsize = fw->size;
release_firmware(fw);
 
-   fwsize = rtlhal->fwsize;
pfwheader = (struct rtl92c_firmware_header *)pfwdata;
 
if (IS_FW_HEADER_EXIST(pfwheader)) {
-   pfwdata = pfwdata + 32;
+   pfwbody = pfwdata + 32;
fwsize = fwsize - 32;
+   } else {
+   pfwbody = pfwdata;
}
 
if (usb_read8(adapt, REG_MCUFWDL) & RAM_DL_SEL) {
@@ -213,8 +212,9 @@ int rtl88eu_download_fw(struct adapter *adapt)
}
_rtl88e_enable_fw_download(adapt, true);
usb_write8(adapt, REG_MCUFWDL, usb_read8(adapt, REG_MCUFWDL) | 
FWDL_ChkSum_rpt);
-   _rtl88e_write_fw(adapt, pfwdata, fwsize);
+   _rtl88e_write_fw(adapt, pfwbody, fwsize);
_rtl88e_enable_fw_download(adapt, false);
 
+   kfree(pfwdata);
return _rtl88e_fw_free_to_go(adapt);
 }
diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h 
b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
index cbad364..9f5050e 100644
--- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
+++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
@@ -191,8 +191,6 @@ struct txpowerinfo24g {
 struct hal_data_8188e {
struct HAL_VERSION  VersionID;
u16 CustomerID;
-   u8 *pfirmware;
-   u32 fwsize;
u16 FirmwareVersion;
u16 FirmwareVersionRev;
u16 FirmwareSubVersion;
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c 
b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index 9201b94..2cca5d2 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -1157,7 +1157,6 @@ int pm_netdev_open(struct net_device *pnetdev, u8 bnormal)
 static int netdev_close(struct net_device *pnetdev)
 {
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
-   struct hal_data_8188e *rtlhal = GET_HAL_DATA(padapter);
 
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - drv_close\n"));
 
@@ -1190,9 +1189,6 @@ static int netdev_close(struct net_device *pnetdev)
rtw_led_control(padapter, LED_CTL_POWER_OFF);
}
 
-   kfree(rtlhal->pfirmware);
-   rtlhal->pfirmware = NULL;
-
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - drv_close\n"));
DBG_88E("-88eu_drv - drv_close, bup =%d\n", padapter->bup);
return 0;
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/12] staging: rtl8188eu: remove unused RTW_STATUS_CODE function

2015-11-07 Thread Ivan Safonov
This driver is only for the Linux kernel.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/include/osdep_service.h |  2 --
 drivers/staging/rtl8188eu/os_dep/osdep_service.c  | 11 ---
 2 files changed, 13 deletions(-)

diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h 
b/drivers/staging/rtl8188eu/include/osdep_service.h
index 22de53d..194e56d 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -75,8 +75,6 @@ static inline int rtw_netif_queue_stopped(struct net_device 
*pnetdev)
netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3));
 }
 
-int RTW_STATUS_CODE(int error_code);
-
 #define rtw_update_mem_stat(flag, sz) do {} while (0)
 u8 *_rtw_malloc(u32 sz);
 #define rtw_malloc(sz) _rtw_malloc((sz))
diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c 
b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index d87b547..9606214 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -28,17 +28,6 @@
 #include 
 #include 
 
-/*
-* Translate the OS dependent @param error_code to OS independent 
RTW_STATUS_CODE
-* @return: one of RTW_STATUS_CODE
-*/
-inline int RTW_STATUS_CODE(int error_code)
-{
-   if (error_code >= 0)
-   return _SUCCESS;
-   return _FAIL;
-}
-
 u8 *_rtw_malloc(u32 sz)
 {
u8  *pbuf = NULL;
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/13] staging: rtl8188eu: return value and argument types changed in _rtl88e_write_fw function

2015-11-07 Thread Ivan Safonov
Ideally the function should not change the variables outside of its body.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 4d72537..5b569ef 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -75,14 +75,14 @@ static void _rtl88e_fw_block_write(struct adapter *adapt,
usb_write8(adapt, write_address, byte_buffer[i]);
 }
 
-static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
+static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
 {
u32 i;
 
-   for (i = *pfwlen; i < roundup(*pfwlen, 4); i++)
+   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
pfwbuf[i] = 0;
 
-   *pfwlen = i;
+   return i;
 }
 
 static void _rtl88e_fw_page_write(struct adapter *adapt,
@@ -103,7 +103,7 @@ static void _rtl88e_write_fw(struct adapter *adapt, u8 
*buffer, u32 size)
u32 page_no, remain;
u32 page, offset;
 
-   _rtl88e_fill_dummy(buf_ptr, );
+   size = _rtl88e_fill_dummy(buf_ptr, size);
 
page_no = size / FW_8192C_PAGE_SIZE;
remain = size % FW_8192C_PAGE_SIZE;
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/12] staging: rtl8188eu: if/else replaced by min_t

2015-11-07 Thread Ivan Safonov
Duplicated code removed.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/core/rtw_cmd.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c 
b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index 433b926..69f8744d9 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -442,10 +442,8 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
wlan_network *pnetwork)
 
psecuritypriv->authenticator_ie[0] = (unsigned 
char)psecnetwork->IELength;
 
-   if ((psecnetwork->IELength-12) < (256-1))
-   memcpy(>authenticator_ie[1], 
>IEs[12], psecnetwork->IELength-12);
-   else
-   memcpy(>authenticator_ie[1], 
>IEs[12], (256-1));
+   memcpy(>authenticator_ie[1], >IEs[12],
+  min_t(size_t, psecnetwork->IELength - 12, 256 - 1));
 
psecnetwork->IELength = 0;
/*  Added by Albert 2009/02/18 */
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/12] staging: rtl8188eu: return value and argument types changed in _rtl88e_write_fw function

2015-11-07 Thread Ivan Safonov
Ideally the function should not change the variables outside of its body.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 4d72537..5b569ef 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -75,14 +75,14 @@ static void _rtl88e_fw_block_write(struct adapter *adapt,
usb_write8(adapt, write_address, byte_buffer[i]);
 }
 
-static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
+static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
 {
u32 i;
 
-   for (i = *pfwlen; i < roundup(*pfwlen, 4); i++)
+   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
pfwbuf[i] = 0;
 
-   *pfwlen = i;
+   return i;
 }
 
 static void _rtl88e_fw_page_write(struct adapter *adapt,
@@ -103,7 +103,7 @@ static void _rtl88e_write_fw(struct adapter *adapt, u8 
*buffer, u32 size)
u32 page_no, remain;
u32 page, offset;
 
-   _rtl88e_fill_dummy(buf_ptr, );
+   size = _rtl88e_fill_dummy(buf_ptr, size);
 
page_no = size / FW_8192C_PAGE_SIZE;
remain = size % FW_8192C_PAGE_SIZE;
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 06/12] staging: rtl8188eu: use memset instead of for loop

2015-11-07 Thread Ivan Safonov
memset clearer than the for loop.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 7f1df4d..298e3e8 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -77,12 +77,12 @@ static void _rtl88e_fw_block_write(struct adapter *adapt,
 
 static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
 {
-   u32 i;
+   u32 remain = round_up(pfwlen, 4) - pfwlen;
 
-   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
-   pfwbuf[i] = 0;
+   if (remain)
+   memset(pfwbuf, 0, remain);
 
-   return i;
+   return pfwlen + remain;
 }
 
 static void _rtl88e_fw_page_write(struct adapter *adapt,
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 08/12] staging: rtl8188eu: if (a) ; else {...} replaced by if (!a) {...}

2015-11-07 Thread Ivan Safonov
It is looks bit better.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 7c79774..62f83ab 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -447,9 +447,7 @@ static int wpa_set_encryption(struct net_device *dev, 
struct ieee_param *param,
 
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | 
WIFI_MP_STATE)) { /* sta mode */
psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv));
-   if (psta == NULL) {
-   ;
-   } else {
+   if (psta) {
if (strcmp(param->u.crypt.alg, "none") != 0)
psta->ieee8021x_blocked = false;
 
@@ -482,9 +480,7 @@ static int wpa_set_encryption(struct net_device *dev, 
struct ieee_param *param,
}
}
pbcmc_sta = rtw_get_bcmc_stainfo(padapter);
-   if (pbcmc_sta == NULL) {
-   ;
-   } else {
+   if (pbcmc_sta) {
/* Jeff: don't disable ieee8021x_blocked while 
clearing key */
if (strcmp(param->u.crypt.alg, "none") != 0)
pbcmc_sta->ieee8021x_blocked = false;
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] staging: sm750fb: add spaces around operator

2015-11-07 Thread Dan Carpenter
If it's a one line fix then just send it as a single patch.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


This is our second e-mail notice to you (€950,000.00)

2015-11-07 Thread Qatar Foundation
Dear Recipient,

You have been selected to receive €950,000.00 Euros, from Qatar Foundation 
award. Kindly contact Mr. Rashid Al-Naimi, for more information through e-mail 
at: qfor...@gmail.com

Yours sincerely,
Mr. Rashid Al-Naimi.
Contact e-mail: qfor...@gmail.com

Chief Executive Officer of Qatar Foundation Endowment.

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tree wide: Use kvfree() than conditional kfree()/vfree()

2015-11-07 Thread Sergey Senozhatsky
On (11/08/15 14:04), Tetsuo Handa wrote:
[..]
> Also, we might want to add a helper that does vmalloc() when
> kmalloc() failed because locations that do
> 
>   ptr = kmalloc(size, GFP_NOFS);
>   if (!ptr)
>   ptr = vmalloc(size); /* Wrong because GFP_KERNEL is used implicitly */
> 
> are found.


ext4 does something like that.


void *ext4_kvmalloc(size_t size, gfp_t flags)
{
void *ret;

ret = kmalloc(size, flags | __GFP_NOWARN);
if (!ret)
ret = __vmalloc(size, flags, PAGE_KERNEL);
return ret;
}

-ss
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V3 3/4] dmaselftest: add memcpy selftest support functions

2015-11-07 Thread Timur Tabi

Sinan Kaya wrote:


+static int dma_selftest_sg(struct dma_device *dmadev,
+   struct dma_chan *dma_chanptr, u64 size,
+   unsigned long flags)
+{
+   dma_addr_t src_dma, dest_dma, dest_dma_it;
+   u8 *dest_buf;
+   u32 i, j = 0;
+   dma_cookie_t cookie;
+   struct dma_async_tx_descriptor *tx;
+   int err = 0;
+   int ret;
+   struct sg_table sg_table;
+   struct scatterlist  *sg;
+   int nents = 10, count;
+   bool free_channel = 1;


Booleans are either 'true' or 'false'.


+static int dma_selftest_mapsngle(struct device *dev)
+{
+   u32 buf_size = 256;
+   char *src;
+   int ret = -ENOMEM;
+   dma_addr_t dma_src;
+
+   src = kmalloc(buf_size, GFP_KERNEL);
+   if (!src)
+   return -ENOMEM;
+
+   strcpy(src, "hello world");


kstrdup()?

And why kmalloc anyway?  Why not leave it on the stack?

char src[] = "hello world";

?


--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 00/20] Fix handling of compat_siginfo_t

2015-11-07 Thread Andy Lutomirski
On Wed, Nov 4, 2015 at 4:50 PM, Amanieu d'Antras  wrote:
> One issue that isn't resolved in this series is sending signals between a 
> 32-bit
> process and 64-bit process. Sending a si_int will work correctly, but a si_ptr
> value will likely get corrupted due to the different layouts of the 32-bit and
> 64-bit siginfo_t structures.

This is so screwed up it's not even funny.

A 64-bit big-endian compat calls rt_sigqueueinfo.  It passes in (among
other things) a sigval_t.  The kernel can choose to interpret it as a
pointer (call it p) or an integer (call it i).  Then (unsigned long)p
= (i<<32) | [something].  If the number was an integer to begin with
*and* user code zeroed out the mess first, then [something] will be 0.
Regardless, p != i unless they're both zero.

If the result gets delivered to a signalfd, then it's plausible that
everything could work.  If it gets delivered to a 64-bit siginfo, then
all is well because it's in exactly the same screwed up state it was
in when the signal gets sent.

If, however, it's delivered to a compat task, wtf is the kernel
supposed to do?  We're effectively supposed to convert a 64-bit
sigval_t to a 32-bit sigval_t.  On a little-endian architecture, we
can fudge it because it doesn't really matter whether we consider the
pointer or the int to be authoritative.  I think that, on big-endian,
we're screwed.

BTW, x86 has its own set of screwups here.  Somehow cr2 and error_code
ended up as part of ucontext instead of siginfo, which makes
absolutely no sense to me and bloats task_struct.

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V3 2/4] dma: add Qualcomm Technologies HIDMA management driver

2015-11-07 Thread Timur Tabi

Sinan Kaya wrote:

+   val = val & ~(MAX_BUS_REQ_LEN_MASK << MAX_BUS_WR_REQ_BIT_POS);
+   val = val | (mgmtdev->max_write_request << MAX_BUS_WR_REQ_BIT_POS);
+   val = val & ~(MAX_BUS_REQ_LEN_MASK);
+   val = val | (mgmtdev->max_read_request);


val &= ~MAX_BUS_REQ_LEN_MASK << MAX_BUS_WR_REQ_BIT_POS;
val |= mgmtdev->max_write_request << MAX_BUS_WR_REQ_BIT_POS;
val &= ~MAX_BUS_REQ_LEN_MASK;
val |= mgmtdev->max_read_request;


+static const struct of_device_id hidma_mgmt_match[] = {
+   { .compatible = "qcom,hidma-mgmt", },
+   { .compatible = "qcom,hidma-mgmt-1.0", },
+   { .compatible = "qcom,hidma-mgmt-1.1", },
+   {},
+};


I thought Rob said that he did NOT want to use version numbers in 
compatible strings.  And what's the difference between these three 
versions anyway?


--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] jbd2: get rid of superfluous __GFP_REPEAT

2015-11-07 Thread Theodore Ts'o
On Sat, Nov 07, 2015 at 10:22:55AM +0900, Tetsuo Handa wrote:
> All jbd2_alloc() callers seem to pass GFP_NOFS. Therefore, use of
> vmalloc() which implicitly passes GFP_KERNEL | __GFP_HIGHMEM can cause
> deadlock, can't it? This vmalloc(size) call needs to be replaced with
> __vmalloc(size, flags).

jbd2_alloc is only passed in the bh->b_size, which can't be >
PAGE_SIZE, so the code path that calls vmalloc() should never get
called.  When we conveted jbd2_alloc() to suppor sub-page size
allocations in commit d2eecb039368, there was an assumption that it
could be called with a size greater than PAGE_SIZE, but that's
certaily not true today.

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tree wide: Use kvfree() than conditional kfree()/vfree()

2015-11-07 Thread Tetsuo Handa
Andy Shevchenko wrote:
> Like Joe noticed you have left few places like
> void my_func_kvfree(arg)
> {
> kvfree(arg);
> }
>
> Might make sense to remove them completely, especially in case when
> you have changed the callers.

I think we should stop at

#define my_func_kvfree(arg) kvfree(arg)

in case someone want to add some code in future.

Also, we might want to add a helper that does vmalloc() when
kmalloc() failed because locations that do

  ptr = kmalloc(size, GFP_NOFS);
  if (!ptr)
  ptr = vmalloc(size); /* Wrong because GFP_KERNEL is used implicitly */

are found.

> One more thought. Might be good to provide a coccinelle script for
> such places? Julia?

Welcome. I'm sure I'm missing some locations.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V3 1/4] dma: qcom_bam_dma: move to qcom directory

2015-11-07 Thread Timur Tabi

Sinan Kaya wrote:

Creating a QCOM directory for all QCOM DMA
source files.

Signed-off-by: Sinan Kaya 
---
  drivers/dma/Kconfig|   13 +-
  drivers/dma/Makefile   |2 +-
  drivers/dma/qcom/Kconfig   |9 +
  drivers/dma/qcom/Makefile  |1 +
  drivers/dma/qcom/bam_dma.c | 1259 
  drivers/dma/qcom_bam_dma.c | 1259 
  6 files changed, 1273 insertions(+), 1270 deletions(-)
  create mode 100644 drivers/dma/qcom/Kconfig
  create mode 100644 drivers/dma/qcom/Makefile
  create mode 100644 drivers/dma/qcom/bam_dma.c
  delete mode 100644 drivers/dma/qcom_bam_dma.c

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index b458475..d17d9ec 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -320,7 +320,7 @@ config MOXART_DMA
select DMA_VIRTUAL_CHANNELS
help
  Enable support for the MOXA ART SoC DMA controller.
-
+


Unrelated whitespace change.


diff --git a/drivers/dma/qcom/Makefile b/drivers/dma/qcom/Makefile
new file mode 100644
index 000..f612ae3
--- /dev/null
+++ b/drivers/dma/qcom/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_QCOM_BAM_DMA) += bam_dma.o
diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
new file mode 100644
index 000..5359234


Please use "git format-patch -M" when creating patches for files that 
have moved.




--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V3 2/4] dma: add Qualcomm Technologies HIDMA management driver

2015-11-07 Thread Sinan Kaya
The Qualcomm Technologies HIDMA device has been designed
to support virtualization technology. The driver has been
divided into two to follow the hardware design.

1. HIDMA Management driver
2. HIDMA Channel driver

Each HIDMA HW consists of multiple channels. These channels
share some set of common parameters. These parameters are
initialized by the management driver during power up.
Same management driver is used for monitoring the execution
of the channels. Management driver can change the performance
behavior dynamically such as bandwidth allocation and
prioritization in the future.

The management driver is executed in hypervisor context and
is the main management entity for all channels provided by
the device.

Signed-off-by: Sinan Kaya 
---
 .../devicetree/bindings/dma/qcom_hidma_mgmt.txt|  62 
 drivers/dma/qcom/Kconfig   |  11 +
 drivers/dma/qcom/Makefile  |   1 +
 drivers/dma/qcom/hidma_mgmt.c  | 315 +
 drivers/dma/qcom/hidma_mgmt.h  |  38 +++
 drivers/dma/qcom/hidma_mgmt_sys.c  | 232 +++
 6 files changed, 659 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
 create mode 100644 drivers/dma/qcom/hidma_mgmt.c
 create mode 100644 drivers/dma/qcom/hidma_mgmt.h
 create mode 100644 drivers/dma/qcom/hidma_mgmt_sys.c

diff --git a/Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt 
b/Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
new file mode 100644
index 000..b906170
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
@@ -0,0 +1,62 @@
+Qualcomm Technologies HIDMA Management interface
+
+The Qualcomm Technologies HIDMA device has been designed
+to support virtualization technology. The driver has been
+divided into two to follow the hardware design. The management
+driver is executed in hypervisor context and is the main
+management entity for all channels provided by the device.
+
+Each HIDMA HW consists of multiple channels. These channels
+share some set of common parameters. These parameters are
+initialized by the management driver during power up.
+Same management driver is used for monitoring the execution
+of the channels. Management driver can change the performance
+behavior dynamically such as bandwidth allocation and
+prioritization.
+
+All channel devices get probed in the hypervisor
+context during power up. They show up as DMA engine
+DMA channels. Then, before starting the virtualization; each
+channel device is unbound from the hypervisor by VFIO
+and assign to the guest machine for control.
+
+This management driver will  be used by the system
+admin to monitor/reset the execution state of the DMA
+channels. This will be the management interface.
+
+
+Required properties:
+- compatible: must contain one of these.
+  "qcom,hidma-mgmt-1.1", "qcom,hidma-mgmt-1.0", "qcom,hidma-mgmt";
+- reg: Address range for DMA device
+- dma-channels: Number of channels supported by this DMA controller.
+- max-write-burst-bytes: Maximum write burst in bytes. A memcpy requested is
+  fragmented to multiples of this amount.
+- max-read-burst-bytes: Maximum read burst in bytes. A memcpy request is
+  fragmented to multiples of this amount.
+- max-write-transactions: Maximum write transactions to perform in a burst
+- max-read-transactions: Maximum read transactions to perform in a burst
+- channel-reset-timeout-cycles: Channel reset timeout in cycles for this SOC.
+- channel-priority: Priority of the channel.
+  Each dma channel share the same HW bandwidth with other dma channels.
+  If two requests reach to the HW at the same time from a low priority and
+  high priority channel, high priority channel will claim the bus.
+  0=low priority, 1=high priority
+- channel-weight: Round robin weight of the channel
+  Since there are only two priority levels supported, scheduling among
+  the equal priority channels is done via weights.
+
+Example:
+
+   hidma-mgmt@f9984000 = {
+   compatible = "qcom,hidma-mgmt-1.0";
+   reg = <0xf9984000 0x15000>;
+   dma-channels = 6;
+   max-write-burst-bytes = 1024;
+   max-read-burst-bytes = 1024;
+   max-write-transactions = 31;
+   max-read-transactions = 31;
+   channel-reset-timeout-cycles = 0x500;
+   channel-priority = < 1 1 0 0 0 0>;
+   channel-weight = < 1 13 10 3 4 5>;
+   };
diff --git a/drivers/dma/qcom/Kconfig b/drivers/dma/qcom/Kconfig
index 17545df..f3e2d4c 100644
--- a/drivers/dma/qcom/Kconfig
+++ b/drivers/dma/qcom/Kconfig
@@ -7,3 +7,14 @@ config QCOM_BAM_DMA
  Enable support for the QCOM BAM DMA controller.  This controller
  provides DMA capabilities for a variety of on-chip devices.
 
+config QCOM_HIDMA_MGMT
+   tristate "Qualcomm Technologies HIDMA Management support"
+   

[PATCH V3 4/4] dma: add Qualcomm Technologies HIDMA channel driver

2015-11-07 Thread Sinan Kaya
This patch adds support for hidma engine. The driver
consists of two logical blocks. The DMA engine interface
and the low-level interface. The hardware only supports
memcpy/memset and this driver only support memcpy
interface. HW and driver doesn't support slave interface.

Signed-off-by: Sinan Kaya 
---
 .../devicetree/bindings/dma/qcom_hidma.txt |  18 +
 drivers/dma/qcom/Kconfig   |   9 +
 drivers/dma/qcom/Makefile  |   2 +
 drivers/dma/qcom/hidma.c   | 743 
 drivers/dma/qcom/hidma.h   | 157 
 drivers/dma/qcom/hidma_dbg.c   | 225 +
 drivers/dma/qcom/hidma_ll.c| 944 +
 7 files changed, 2098 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma.txt
 create mode 100644 drivers/dma/qcom/hidma.c
 create mode 100644 drivers/dma/qcom/hidma.h
 create mode 100644 drivers/dma/qcom/hidma_dbg.c
 create mode 100644 drivers/dma/qcom/hidma_ll.c

diff --git a/Documentation/devicetree/bindings/dma/qcom_hidma.txt 
b/Documentation/devicetree/bindings/dma/qcom_hidma.txt
new file mode 100644
index 000..c9fb2d44
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/qcom_hidma.txt
@@ -0,0 +1,18 @@
+Qualcomm Technologies HIDMA Channel driver
+
+Required properties:
+- compatible: must contain "qcom,hidma"
+- reg: Addresses for the transfer and event channel
+- interrupts: Should contain the event interrupt
+- desc-count: Number of asynchronous requests this channel can handle
+- event-channel: The HW event channel completions will be delivered.
+Example:
+
+   hidma_24: dma-controller@0x5c05 {
+   compatible = "qcom,hidma-1.0";
+   reg = <0 0x5c05 0x0 0x1000>,
+ <0 0x5c0b 0x0 0x1000>;
+   interrupts = <0 389 0>;
+   desc-count = <10>;
+   event-channel = <4>;
+   };
diff --git a/drivers/dma/qcom/Kconfig b/drivers/dma/qcom/Kconfig
index f3e2d4c..5588e1c 100644
--- a/drivers/dma/qcom/Kconfig
+++ b/drivers/dma/qcom/Kconfig
@@ -18,3 +18,12 @@ config QCOM_HIDMA_MGMT
  the guest OS would run QCOM_HIDMA channel driver and the
  hypervisor would run the QCOM_HIDMA_MGMT management driver.
 
+config QCOM_HIDMA
+   tristate "Qualcomm Technologies HIDMA Channel support"
+   select DMA_ENGINE
+   help
+ Enable support for the Qualcomm Technologies HIDMA controller.
+ The HIDMA controller supports optimized buffer copies
+ (user to kernel, kernel to kernel, etc.).  It only supports
+ memcpy interface. The core is not intended for general
+ purpose slave DMA.
diff --git a/drivers/dma/qcom/Makefile b/drivers/dma/qcom/Makefile
index 1a5a96d..2b68c9c 100644
--- a/drivers/dma/qcom/Makefile
+++ b/drivers/dma/qcom/Makefile
@@ -1,2 +1,4 @@
 obj-$(CONFIG_QCOM_BAM_DMA) += bam_dma.o
 obj-$(CONFIG_QCOM_HIDMA_MGMT) += hidma_mgmt.o hidma_mgmt_sys.o
+obj-$(CONFIG_QCOM_HIDMA) +=  hdma.o
+hdma-objs:= hidma_ll.o hidma.o hidma_dbg.o ../dmaselftest.o
diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c
new file mode 100644
index 000..dadc289
--- /dev/null
+++ b/drivers/dma/qcom/hidma.c
@@ -0,0 +1,743 @@
+/*
+ * Qualcomm Technologies HIDMA DMA engine interface
+ *
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+/*
+ * Copyright (C) Freescale Semicondutor, Inc. 2007, 2008.
+ * Copyright (C) Semihalf 2009
+ * Copyright (C) Ilya Yanok, Emcraft Systems 2010
+ * Copyright (C) Alexander Popov, Promcontroller 2014
+ *
+ * Written by Piotr Ziecik . Hardware description
+ * (defines, structures and comments) was taken from MPC5121 DMA driver
+ * written by Hongjun Chen .
+ *
+ * Approved as OSADL project by a majority of OSADL members and funded
+ * by OSADL membership fees in 2009;  for details see www.osadl.org.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * The full GNU General Public License is included 

[PATCH V3 1/4] dma: qcom_bam_dma: move to qcom directory

2015-11-07 Thread Sinan Kaya
Creating a QCOM directory for all QCOM DMA
source files.

Signed-off-by: Sinan Kaya 
---
 drivers/dma/Kconfig|   13 +-
 drivers/dma/Makefile   |2 +-
 drivers/dma/qcom/Kconfig   |9 +
 drivers/dma/qcom/Makefile  |1 +
 drivers/dma/qcom/bam_dma.c | 1259 
 drivers/dma/qcom_bam_dma.c | 1259 
 6 files changed, 1273 insertions(+), 1270 deletions(-)
 create mode 100644 drivers/dma/qcom/Kconfig
 create mode 100644 drivers/dma/qcom/Makefile
 create mode 100644 drivers/dma/qcom/bam_dma.c
 delete mode 100644 drivers/dma/qcom_bam_dma.c

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index b458475..d17d9ec 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -320,7 +320,7 @@ config MOXART_DMA
select DMA_VIRTUAL_CHANNELS
help
  Enable support for the MOXA ART SoC DMA controller.
- 
+
  Say Y here if you enabled MMP ADMA, otherwise say N.
 
 config MPC512X_DMA
@@ -408,15 +408,6 @@ config PXA_DMA
  16 to 32 channels for peripheral to memory or memory to memory
  transfers.
 
-config QCOM_BAM_DMA
-   tristate "QCOM BAM DMA support"
-   depends on ARCH_QCOM || (COMPILE_TEST && OF && ARM)
-   select DMA_ENGINE
-   select DMA_VIRTUAL_CHANNELS
-   ---help---
- Enable support for the QCOM BAM DMA controller.  This controller
- provides DMA capabilities for a variety of on-chip devices.
-
 config SIRF_DMA
tristate "CSR SiRFprimaII/SiRFmarco DMA support"
depends on ARCH_SIRF
@@ -527,6 +518,8 @@ config ZX_DMA
 # driver files
 source "drivers/dma/bestcomm/Kconfig"
 
+source "drivers/dma/qcom/Kconfig"
+
 source "drivers/dma/dw/Kconfig"
 
 source "drivers/dma/hsu/Kconfig"
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index 7711a71..8dba90d 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -52,7 +52,6 @@ obj-$(CONFIG_PCH_DMA) += pch_dma.o
 obj-$(CONFIG_PL330_DMA) += pl330.o
 obj-$(CONFIG_PPC_BESTCOMM) += bestcomm/
 obj-$(CONFIG_PXA_DMA) += pxa_dma.o
-obj-$(CONFIG_QCOM_BAM_DMA) += qcom_bam_dma.o
 obj-$(CONFIG_RENESAS_DMA) += sh/
 obj-$(CONFIG_SIRF_DMA) += sirf-dma.o
 obj-$(CONFIG_STE_DMA40) += ste_dma40.o ste_dma40_ll.o
@@ -66,4 +65,5 @@ obj-$(CONFIG_TI_EDMA) += edma.o
 obj-$(CONFIG_XGENE_DMA) += xgene-dma.o
 obj-$(CONFIG_ZX_DMA) += zx296702_dma.o
 
+obj-y += qcom/
 obj-y += xilinx/
diff --git a/drivers/dma/qcom/Kconfig b/drivers/dma/qcom/Kconfig
new file mode 100644
index 000..17545df
--- /dev/null
+++ b/drivers/dma/qcom/Kconfig
@@ -0,0 +1,9 @@
+config QCOM_BAM_DMA
+   tristate "QCOM BAM DMA support"
+   depends on ARCH_QCOM || (COMPILE_TEST && OF && ARM)
+   select DMA_ENGINE
+   select DMA_VIRTUAL_CHANNELS
+   ---help---
+ Enable support for the QCOM BAM DMA controller.  This controller
+ provides DMA capabilities for a variety of on-chip devices.
+
diff --git a/drivers/dma/qcom/Makefile b/drivers/dma/qcom/Makefile
new file mode 100644
index 000..f612ae3
--- /dev/null
+++ b/drivers/dma/qcom/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_QCOM_BAM_DMA) += bam_dma.o
diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
new file mode 100644
index 000..5359234
--- /dev/null
+++ b/drivers/dma/qcom/bam_dma.c
@@ -0,0 +1,1259 @@
+/*
+ * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+/*
+ * QCOM BAM DMA engine driver
+ *
+ * QCOM BAM DMA blocks are distributed amongst a number of the on-chip
+ * peripherals on the MSM 8x74.  The configuration of the channels are 
dependent
+ * on the way they are hard wired to that specific peripheral.  The peripheral
+ * device tree entries specify the configuration of each channel.
+ *
+ * The DMA controller requires the use of external memory for storage of the
+ * hardware descriptors for each channel.  The descriptor FIFO is accessed as a
+ * circular buffer and operations are managed according to the offset within 
the
+ * FIFO.  After pipe/channel reset, all of the pipe registers and internal 
state
+ * are back to defaults.
+ *
+ * During DMA operations, we write descriptors to the FIFO, being careful to
+ * handle wrapping and then write the last FIFO offset to that channel's
+ * P_EVNT_REG register to kick off the transaction.  The P_SW_OFSTS register
+ * indicates the current FIFO offset that is being processed, so there is some
+ * indication of where the hardware is currently working.
+ */
+
+#include 

[PATCH V3 3/4] dmaselftest: add memcpy selftest support functions

2015-11-07 Thread Sinan Kaya
This patch adds supporting utility functions
for selftest. The intention is to share the self
test code between different drivers.

Supported test cases include:
1. dma_map_single
2. streaming DMA
3. coherent DMA
4. scatter-gather DMA

Signed-off-by: Sinan Kaya 
---
 drivers/dma/dmaengine.h   |   2 +
 drivers/dma/dmaselftest.c | 669 ++
 2 files changed, 671 insertions(+)
 create mode 100644 drivers/dma/dmaselftest.c

diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h
index 17f983a..05b5a84 100644
--- a/drivers/dma/dmaengine.h
+++ b/drivers/dma/dmaengine.h
@@ -86,4 +86,6 @@ static inline void dma_set_residue(struct dma_tx_state 
*state, u32 residue)
state->residue = residue;
 }
 
+int dma_selftest_memcpy(struct dma_device *dmadev);
+
 #endif
diff --git a/drivers/dma/dmaselftest.c b/drivers/dma/dmaselftest.c
new file mode 100644
index 000..324f7c4
--- /dev/null
+++ b/drivers/dma/dmaselftest.c
@@ -0,0 +1,669 @@
+/*
+ * DMA self test code borrowed from Qualcomm Technologies HIDMA driver
+ *
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct test_result {
+   atomic_t counter;
+   wait_queue_head_t wq;
+   struct dma_device *dmadev;
+};
+
+static void dma_selftest_complete(void *arg)
+{
+   struct test_result *result = arg;
+   struct dma_device *dmadev = result->dmadev;
+
+   atomic_inc(>counter);
+   wake_up(>wq);
+   dev_dbg(dmadev->dev, "self test transfer complete :%d\n",
+   atomic_read(>counter));
+}
+
+/*
+ * Perform a transaction to verify the HW works.
+ */
+static int dma_selftest_sg(struct dma_device *dmadev,
+   struct dma_chan *dma_chanptr, u64 size,
+   unsigned long flags)
+{
+   dma_addr_t src_dma, dest_dma, dest_dma_it;
+   u8 *dest_buf;
+   u32 i, j = 0;
+   dma_cookie_t cookie;
+   struct dma_async_tx_descriptor *tx;
+   int err = 0;
+   int ret;
+   struct sg_table sg_table;
+   struct scatterlist  *sg;
+   int nents = 10, count;
+   bool free_channel = 1;
+   u8 *src_buf;
+   int map_count;
+   struct test_result result;
+
+   init_waitqueue_head();
+   atomic_set(, 0);
+   result.dmadev = dmadev;
+
+   if (!dma_chanptr)
+   return -ENOMEM;
+
+   if (dmadev->device_alloc_chan_resources(dma_chanptr) < 1)
+   return -ENODEV;
+
+   if (!dma_chanptr->device || !dmadev->dev) {
+   dmadev->device_free_chan_resources(dma_chanptr);
+   return -ENODEV;
+   }
+
+   ret = sg_alloc_table(_table, nents, GFP_KERNEL);
+   if (ret) {
+   err = ret;
+   goto sg_table_alloc_failed;
+   }
+
+   for_each_sg(sg_table.sgl, sg, nents, i) {
+   u64 alloc_sz;
+   void *cpu_addr;
+
+   alloc_sz = round_up(size, nents);
+   do_div(alloc_sz, nents);
+   cpu_addr = kmalloc(alloc_sz, GFP_KERNEL);
+
+   if (!cpu_addr) {
+   err = -ENOMEM;
+   goto sg_buf_alloc_failed;
+   }
+
+   dev_dbg(dmadev->dev, "set sg buf[%d] :%p\n", i, cpu_addr);
+   sg_set_buf(sg, cpu_addr, alloc_sz);
+   }
+
+   dest_buf = kmalloc(round_up(size, nents), GFP_KERNEL);
+   if (!dest_buf) {
+   err = -ENOMEM;
+   goto dst_alloc_failed;
+   }
+   dev_dbg(dmadev->dev, "dest:%p\n", dest_buf);
+
+   /* Fill in src buffer */
+   count = 0;
+   for_each_sg(sg_table.sgl, sg, nents, i) {
+   src_buf = sg_virt(sg);
+   dev_dbg(dmadev->dev,
+   "set src[%d, %d, %p] = %d\n", i, j, src_buf, count);
+
+   for (j = 0; j < sg_dma_len(sg); j++)
+   src_buf[j] = count++;
+   }
+
+   /* dma_map_sg cleans and invalidates the cache in arm64 when
+* DMA_TO_DEVICE is selected for src. That's why, we need to do
+* the mapping after the data is copied.
+*/
+   map_count = dma_map_sg(dmadev->dev, sg_table.sgl, nents,
+   DMA_TO_DEVICE);
+   if (!map_count) {
+   err =  -EINVAL;
+   goto src_map_failed;
+   }
+
+   dest_dma = dma_map_single(dmadev->dev, dest_buf,
+   size, 

Re: [RFC PATCH 00/28] Linux Kernel Library

2015-11-07 Thread Octavian Purdila
On Sat, Nov 7, 2015 at 2:35 AM, Richard Weinberger  wrote:
> Am 04.11.2015 um 15:15 schrieb Octavian Purdila:
>> We could redefine the syscalls/libc symbols to call lkl_sys_ functions
>> in launch-lkl, e.g.:
>>
>> int opendir(const char *path)
>> {
>>return lkl_opendir(new_path)
>> }
>
> To get a better feeling how LKL behaves I've started with a tool
> to mount any Linux filesystem by FUSE.
> I.e. such that we can finally automount without root and bugs in filesystem
> code won't hurt that much.
>

Hi Richard,

I finished coding mine up yesterday :) I've just pushed it to github
if you want to take a look at it (together with some small fixes).

> lkl_sys_fstatat64() uses the type struct lkl_stat64. Where is it defined?
> git grep is unable to locate it.
> At least it seems to be incompatible with my local struct stat.
>

When doing the build in tools/lkl the LKL headers are installed in
include/lkl. You should find it in there:

$:~/src/linux/tools/lkl$ find include/ -type f | xargs grep lkl_stat64
include/lkl/asm-generic/stat.h:struct lkl_stat64 {

> And why is there no lkl_sys_openat() syscall?
>

Didn't get to test it hence I didn't add it to the API yet, as many
other system calls.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC PATCH 00/28] Linux Kernel Library

2015-11-07 Thread Octavian Purdila
On Sat, Nov 7, 2015 at 2:35 AM, Richard Weinberger  wrote:
> Am 04.11.2015 um 15:15 schrieb Octavian Purdila:
>> We could redefine the syscalls/libc symbols to call lkl_sys_ functions
>> in launch-lkl, e.g.:
>>
>> int opendir(const char *path)
>> {
>>return lkl_opendir(new_path)
>> }
>
> To get a better feeling how LKL behaves I've started with a tool
> to mount any Linux filesystem by FUSE.
> I.e. such that we can finally automount without root and bugs in filesystem
> code won't hurt that much.
>
> lkl_sys_fstatat64() uses the type struct lkl_stat64. Where is it defined?
> git grep is unable to locate it.
> At least it seems to be incompatible with my local struct stat.
>
> And why is there no lkl_sys_openat() syscall?
>
> Thanks,
> //richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC PATCH 19/28] lkl tools: host lib: virtio block device

2015-11-07 Thread Octavian Purdila
On Sat, Nov 7, 2015 at 2:24 PM, Richard Weinberger
 wrote:
> On Tue, Nov 3, 2015 at 9:20 PM, Octavian Purdila
>  wrote:
>> Host independent implementation for virtio block devices. The host
>> dependent part of the host library must provide an implementation for
>> lkl_dev_block_ops.
>>
>> Disks can be added to the LKL configuration via lkl_disk_add(), a new
>> LKL application API.
>>
>> Signed-off-by: Octavian Purdila 
>> ---
>>  tools/lkl/include/lkl.h  |  20 
>>  tools/lkl/include/lkl_host.h |  21 
>>  tools/lkl/lib/virtio_blk.c   | 116 
>> +++
>>  3 files changed, 157 insertions(+)
>>  create mode 100644 tools/lkl/lib/virtio_blk.c
>

Hi Richard,

> Can you please outline what the differences between this driver and
> UML's block driver are?
>

LKL actually uses the standard virtio block driver, it does not
implement a new (Linux kernel) driver.

This patch is the implementation for the host side device (in virtio's
spec lingo).

Or maybe I misunderstood your question?

> While UML and LKL have different goals they could at least share some drivers.
> UML also has networking drivers you could reuse.
> Maybe it would make sense to integrate LKL completely into arch/um if
> we find a nice way
> to combine them.
> CONFIG_UML_LIBRARY, hmm?
> Would be a nice opportunity to clear away some dung from arch/um and
> refactor it. :-)
>

Yeah, that would be nice :) I think the key part is to define the
right host operations (in LKL terms) that can support UML. I'll have
to spend some time to study UML's internals a bit to see if that would
be doable.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


ERROR: "spmi_register_read" [drivers/base/regmap/regmap-spmi.ko] undefined!

2015-11-07 Thread kbuild test robot
Hi Eduardo,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   ce5c2d2c256a4c8b523036537cd6be2d6af8f69d
commit: cb7fb4d342023d03070fcc1ed73fcd43682973d7 thermal: qcom_spmi: allow 
compile test
date:   8 weeks ago
config: x86_64-randconfig-s0-11081112 (attached as .config)
reproduce:
git checkout cb7fb4d342023d03070fcc1ed73fcd43682973d7
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> ERROR: "spmi_register_read" [drivers/base/regmap/regmap-spmi.ko] undefined!
>> ERROR: "spmi_register_zero_write" [drivers/base/regmap/regmap-spmi.ko] 
>> undefined!
>> ERROR: "spmi_ext_register_write" [drivers/base/regmap/regmap-spmi.ko] 
>> undefined!
>> ERROR: "spmi_register_write" [drivers/base/regmap/regmap-spmi.ko] undefined!
>> ERROR: "spmi_ext_register_readl" [drivers/base/regmap/regmap-spmi.ko] 
>> undefined!
>> ERROR: "spmi_ext_register_read" [drivers/base/regmap/regmap-spmi.ko] 
>> undefined!
>> ERROR: "spmi_ext_register_writel" [drivers/base/regmap/regmap-spmi.ko] 
>> undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [RFC PATCH 21/28] lkl tools: host lib: posix host operations

2015-11-07 Thread Octavian Purdila
On Sun, Nov 8, 2015 at 1:16 AM, Arnd Bergmann  wrote:
> On Tuesday 03 November 2015 22:20:52 Octavian Purdila wrote:
>> +struct pthread_sem {
>> + pthread_mutex_t lock;
>> + int count;
>> + pthread_cond_t cond;
>> +};
>> +
>> +static void *sem_alloc(int count)
>> +{
>> + struct pthread_sem *sem;
>> +
>> + sem = malloc(sizeof(*sem));
>> + if (!sem)
>> + return NULL;
>> +
>> + pthread_mutex_init(>lock, NULL);
>> + sem->count = count;
>> + pthread_cond_init(>cond, NULL);
>> +
>> + return sem;
>> +}
>
> What is the reason to have generalized semaphores in the
> host API rather than a simple mutex?
>

Currently waking up from idle after an IRQ event requires a semaphore.
I'll see if we can use a simple mutex for this.

>> +static unsigned long long time_ns(void)
>> +{
>> + struct timeval tv;
>> +
>> + gettimeofday(, NULL);
>> +
>> + return tv.tv_sec * 10ULL + tv.tv_usec * 1000ULL;
>> +}
>
> clock_gettime() has been around since POSIX.1-2001 and provides the
> nanosecond resolution you use in the interface.
>

Good point, I will change it to clock_gettime.

Thanks for the review Arnd !
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC PATCH 08/28] lkl: system call interface and application API

2015-11-07 Thread Octavian Purdila
On Sun, Nov 8, 2015 at 1:24 AM, Arnd Bergmann  wrote:
> On Tuesday 03 November 2015 22:20:39 Octavian Purdila wrote:
>> +
>> +/*
>> + * Unsupported system calls due to lack of support in LKL (e.g. related to
>> + * virtual memory, signal, user processes). We also only support 64bit 
>> version
>> + * of system calls where we have two version to keep the same APi across 32 
>> and
>> + * 64 bit hosts.
>> + */
>> +#define __NR_restart_syscall 0
>> +#define __NR_exit 0
>> +#define __NR_fork 0
>> +#define __NR_execve 0
>> +#define __NR_ptrace 0
>> +#define __NR_alarm 0
>> +#define __NR_pause 0
>
> Why are these not #undef?
>
>> diff --git a/arch/lkl/include/uapi/asm/unistd.h 
>> b/arch/lkl/include/uapi/asm/unistd.h
>> new file mode 100644
>> index 000..68b5423
>> --- /dev/null
>> +++ b/arch/lkl/include/uapi/asm/unistd.h
>> @@ -0,0 +1,256 @@
>> +#ifndef _ASM_UAPI_LKL_UNISTD_H
>> +#define _ASM_UAPI_LKL_UNISTD_H
>> +
>> +#ifdef __KERNEL__
>> +#define __NR_ni_syscall  0
>> +#define __NR_reboot  1
>> +#endif
>> +#define __NR_getpid  2
>> +#define __NR_write   3
>> +#define __NR_close   4
>> +#define __NR_unlink  5
>> +#define __NR_open6
>> +#define __NR_poll7
>
> Could you use the standard numbers from include/uapi/asm-generic/unistd.h?
> Maybe include that header and then #undef the ones you don't support?
> That would avoid having to assign a new number of each future syscall
> that gets added.

It would be nice to do that but if we undef them warnings will be
generated during the build (e.g. "warning: #warning syscall pause not
implemented"). Is there a way to disable those warnings?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [BUG, PATCH 03/10] sysfs: added __compat_only_sysfs_link_entry_to_kobj()

2015-11-07 Thread Jeremiah Mahler
Jarkko,

On Sun, Nov 08, 2015 at 02:49:06AM +0200, Jarkko Sakkinen wrote:
> On Sat, Nov 07, 2015 at 03:11:47PM -0800, Jeremiah Mahler wrote:
> > Jarkko,
> > 
[...]
> > 
> > It sounds like you have the problem figured out and have a good fix.
> > If I can do anything else to help let me know :-)
> 
> Turns out that after all the second issue that I described was also
> because of this patch.
> 
> Clean up was not done properly when that function. I revised my fix.
> 
> If you want to help, check that the revised patch works I'll add
> Tested-by to the patch. Thank you!
> 
> > -- 
> > - Jeremiah Mahler
> 
> /Jarkko

I tested the patch (link below) and it works with one small caveat.
The patch would not apply because line 231 uses list_add_tail_rcu
instead of list_add_rcu.  I am working from commit 9b774d5cf2d where
the problem started.  Your repo likely has other changes involved.

https://github.com/jsakkine/linux-tpmdd/commit/73ea7e0b8045f9610c3274bcefaf89b7a05ee781

-- 
- Jeremiah Mahler
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] bpf: doc: correct arch list for supported eBPF JIT

2015-11-07 Thread Alexei Starovoitov
On Fri, Nov 06, 2015 at 09:38:58PM -0800, Yang Shi wrote:
> aarch64 and s390x support eBPF JIT too, correct document to reflect this and
> avoid any confusion.
> 
> Signed-off-by: Yang Shi 

Thanks
Acked-by: Alexei Starovoitov 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arm64: bpf: fix JIT stack setup

2015-11-07 Thread Alexei Starovoitov
On Fri, Nov 06, 2015 at 09:36:17PM -0800, Yang Shi wrote:
> ARM64 JIT used FP (x29) as eBPF fp register, but FP is subjected to
> change during function call so it may cause the BPF prog stack base address
> change too. Whenever, it pointed to the bottom of BPF prog stack instead of
> the top.
> 
> So, when copying data via bpf_probe_read, it will be copied to (SP - offset),
> then it may overwrite the saved FP/LR.
> 
> Use x25 to replace FP as BPF stack base register (fp). Since x25 is callee
> saved register, so it will keep intact during function call.
> It is initialized in BPF prog prologue when BPF prog is started to run
> everytime. When BPF prog exits, it could be just tossed.
> 
> Other than this the BPf prog stack base need to be setup before function
> call stack.
> 
> So, the BPF stack layout looks like:
> 
>  high
>  original A64_SP =>   0:+-+ BPF prologue
> | | FP/LR and callee saved registers
>  BPF fp register => +64:+-+
> | |
> | ... | BPF prog stack
> | |
> | |
>  current A64_SP =>  +-+
> | |
> | ... | Function call stack
> | |
> +-+
>   low
> 
> Signed-off-by: Yang Shi 
> CC: Zi Shen Lim 
> CC: Xi Wang 

Thanks for tracking it down.
That looks like fundamental bug in arm64 jit. I'm surprised function calls 
worked at all.
Zi please review.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC] namei: prevent sgid-hardlinks for unmapped gids

2015-11-07 Thread Theodore Ts'o
On Fri, Nov 06, 2015 at 09:05:57PM -0800, Kees Cook wrote:
>  They're certainly not used early enough -- we need to remove suid when
>  the page becomes writable via mmap (wp_page_shared), not when
>  writeback happens, or at least not only when writeback happens.
> >>>
> >>> Well, I'm shy about the change there. For example, we don't strip in
> >>> on open(RDWR), just on write().
> >>
> >> I take it back. Hooking wp_page_shared looks expensive. :) Maybe we do
> >> need to hook the mmap?
> >
> > But file_update_time already pokes at the same (or nearby) cachelines,
> > I think -- why would it be expensive?  The whole thing could be
> > guarded by if (unlikely(is setuid)), right?
> 
> Yeah, true. I added file_remove_privs calls near all the
> file_update_time calls, to no effect. Added to wp_page_shared too,
> nothing. Hmmm.

Why not put the the should_remove_suid() call in
filemap_page_mkwrite(), or maybe do_page_mkwrite()?

Cheers,

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] staging: sm750fb: move opening brace to previous line

2015-11-07 Thread Othmar Pasteka
Fixes the checkpatch.pl error:
ERROR: that open brace { should be on the previous line

Signed-off-by: Othmar Pasteka 
---
 drivers/staging/sm750fb/sm750_cursor.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_cursor.c 
b/drivers/staging/sm750fb/sm750_cursor.c
index 3b7ce92..cab891c 100644
--- a/drivers/staging/sm750fb/sm750_cursor.c
+++ b/drivers/staging/sm750fb/sm750_cursor.c
@@ -143,8 +143,7 @@ void hw_cursor_setData(struct lynx_cursor *cursor,
iowrite16(data, pbuffer);
 
/* assume pitch is 1,2,4,8,...*/
-   if ((i+1) % pitch == 0)
-   {
+   if ((i+1) % pitch == 0) {
/* need a return */
pstart += offset;
pbuffer = pstart;
-- 
2.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] staging: sm750fb: add spaces around operator

2015-11-07 Thread Othmar Pasteka
checkpatch.pl says: CHECK: spaces preferred around that '+' (ctx:VxV)

Signed-off-by: Othmar Pasteka 
---
 drivers/staging/sm750fb/sm750_cursor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/sm750fb/sm750_cursor.c 
b/drivers/staging/sm750fb/sm750_cursor.c
index cab891c..0a41585 100644
--- a/drivers/staging/sm750fb/sm750_cursor.c
+++ b/drivers/staging/sm750fb/sm750_cursor.c
@@ -143,7 +143,7 @@ void hw_cursor_setData(struct lynx_cursor *cursor,
iowrite16(data, pbuffer);
 
/* assume pitch is 1,2,4,8,...*/
-   if ((i+1) % pitch == 0) {
+   if ((i + 1) % pitch == 0) {
/* need a return */
pstart += offset;
pbuffer = pstart;
-- 
2.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] bpf: doc: correct arch list for supported eBPF JIT

2015-11-07 Thread Daniel Borkmann

On 11/07/2015 06:38 AM, Yang Shi wrote:

aarch64 and s390x support eBPF JIT too, correct document to reflect this and
avoid any confusion.

Signed-off-by: Yang Shi 


Acked-by: Daniel Borkmann 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [BUG, PATCH 03/10] sysfs: added __compat_only_sysfs_link_entry_to_kobj()

2015-11-07 Thread Jarkko Sakkinen
On Sat, Nov 07, 2015 at 03:11:47PM -0800, Jeremiah Mahler wrote:
> Jarkko,
> 
> On Sun, Nov 08, 2015 at 12:31:09AM +0200, Jarkko Sakkinen wrote:
> > On Sat, Nov 07, 2015 at 10:08:56AM -0800, Jeremiah Mahler wrote:
> > > Jarkko,
> > > 
> > > On Sat, Nov 07, 2015 at 01:41:37PM +0200, Jarkko Sakkinen wrote:
> > > > On Sat, Nov 07, 2015 at 12:55:43PM +0200, Jarkko Sakkinen wrote:
> > > > > On Fri, Nov 06, 2015 at 06:55:18PM -0800, Jeremiah Mahler wrote:
> > > > > > Jarkko,
> > > > > > 
> [...]
> > > > I pushed a fix over here:
> > > > 
> > > > https://github.com/jsakkine/linux-tpmdd/tree/fixes
> > > > 
> > > This fix does work since it effectively avoids the call to
> > > __compat_only_sysfs_link_entry_to_kobj().
> > > 
> > > Have you tested cases where __compat_only_sysfs_link_entry_to_kobj()
> > > is actually used?
> > 
> > Yes, of course I have. And I checked your DSDT and my assumption was
> > correct. There was no DSM in the ACPI object.
> > 
> > However, there is probably another regression but it is caused by some
> > patch that was added earlier. I strongly believe it is not caused by any
> > of my 4.4 patches.
> > 
> > I think what was happening with you was that
> > __compat_only_sysfs_link_entry_to_kobj() was returning -ENOENT, which it
> > should do when target is not found. This was propagated to tpm_tis and
> > it probably messes up clean up somehow.
> > 
> > I have to test my hypothesis as soon as possible. The fix that I pushed
> > is still valid no matter which way the things are.
> > 
> > > [...]
> > > 
> > > -- 
> > > - Jeremiah Mahler
> > 
> > /Jarkko
> 
> It sounds like you have the problem figured out and have a good fix.
> If I can do anything else to help let me know :-)

Turns out that after all the second issue that I described was also
because of this patch.

Clean up was not done properly when that function. I revised my fix.

If you want to help, check that the revised patch works I'll add
Tested-by to the patch. Thank you!

> -- 
> - Jeremiah Mahler

/Jarkko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: ERROR: "crc32c" [drivers/md/raid456.ko] undefined!

2015-11-07 Thread Guenter Roeck
On Sun, Nov 08, 2015 at 07:41:31AM +0800, kbuild test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
> master
> head:   ad804a0b2a769a0eed29015c53fe395449c09d13
> commit: 5cb2fbd6ea0d151dcb12d98c06c8761eedfed2ee raid5-cache: use crc32c 
> checksum
> date:   7 days ago
> config: arm-sa1100 (attached as .config)
> reproduce:
> wget 
> https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
>  -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> git checkout 5cb2fbd6ea0d151dcb12d98c06c8761eedfed2ee
> # save the attached .config to linux build tree
> make.cross ARCH=arm 
> 
> All errors (new ones prefixed by >>):
> 
> >> ERROR: "crc32c" [drivers/md/raid456.ko] undefined!
> 

Patch: https://lkml.org/lkml/2015/11/6/461

Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


BUSINESS PROPOSAL!

2015-11-07 Thread zhongjun
Good day,
 
I need a foreign partner for a mutual business  proposal ,which relates to the 
transfer of a large sum of money to a 
foreign account, as the recipient of the funds. Everything about this  
transaction will be done legally without any bridge of financial 
authority both in my Country and yours.I wil indulge you to observe utmost 
discretion in all matters relating to this issue. If you are 
interested, please reply back via my private email address written below,I will 
give you more information about myself with the financial 
institution I represented and actual amounts involves regarding the project as 
soon as I receive your positive response.
 
Private email:fu.zh...@fuzhongjun.net
 
Friendly greeting,
 
Executive Director.
 
China Bank.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 04/19] irqchip: add nps Internal and external irqchips

2015-11-07 Thread Thomas Gleixner
Noam,

On Sat, 7 Nov 2015, Noam Camus wrote:
> >From: Thomas Gleixner 
> >> + write_aux_reg(AUX_IENABLE, ienb);
> 
> >I can see how that works for per cpu interrupts, but what happens if
> >two cpus run that concurrent for two different interrupts?
> 
> Each CPU got its own HW copy of auxiliary register IENABLE, so
> concurrent access won't be a trouble.

Please put a comment into the code explaining it.

Thanks,

tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[GIT PULL] IO poll support

2015-11-07 Thread Jens Axboe
Hi Linus,

Various groups have been doing experimentation around IO polling for
(really) fast devices. The code has been reviewed and has been sitting
on the side for a few releases, but this is now good enough for
coordinated benchmarking and further experimentation.

Currently O_DIRECT sync read/write are supported. A framework is in the
works that allows scalable stats tracking so we can auto-tune this. And
we'll add libaio support as well soon. Fow now, it's an opt-in feature
for test purposes.

Please pull!


  git://git.kernel.dk/linux-block.git for-4.4/io-poll



Jens Axboe (5):
  block: change ->make_request_fn() and users to return a queue cookie
  blk-mq: return tag/queue combo in the make_request_fn handlers
  block: add block polling support
  NVMe: add blk polling support
  directio: add block polling support

 arch/m68k/emu/nfblock.c |  3 +-
 arch/powerpc/sysdev/axonram.c   |  5 ++-
 arch/xtensa/platforms/iss/simdisk.c |  3 +-
 block/blk-core.c| 67 -
 block/blk-mq-sysfs.c| 10 +
 block/blk-mq.c  | 59 +++--
 block/blk-sysfs.c   | 35 +++
 drivers/block/brd.c |  5 ++-
 drivers/block/drbd/drbd_int.h   |  2 +-
 drivers/block/drbd/drbd_req.c   |  3 +-
 drivers/block/null_blk.c|  3 +-
 drivers/block/pktcdvd.c |  9 ++--
 drivers/block/ps3vram.c |  6 ++-
 drivers/block/rsxx/dev.c|  5 ++-
 drivers/block/umem.c|  4 +-
 drivers/block/zram/zram_drv.c   |  5 ++-
 drivers/lightnvm/rrpc.c |  9 ++--
 drivers/md/bcache/request.c | 11 +++--
 drivers/md/dm.c |  6 +--
 drivers/md/md.c |  8 ++--
 drivers/nvdimm/blk.c|  3 +-
 drivers/nvdimm/btt.c|  3 +-
 drivers/nvdimm/pmem.c   |  3 +-
 drivers/nvme/host/pci.c | 32 --
 drivers/s390/block/dcssblk.c|  8 ++--
 drivers/s390/block/xpram.c  |  5 ++-
 drivers/staging/lustre/lustre/llite/lloop.c |  5 ++-
 fs/direct-io.c  | 14 --
 include/linux/blk-mq.h  | 10 +
 include/linux/blk_types.h   | 24 +++
 include/linux/blkdev.h  |  7 ++-
 include/linux/fs.h  |  2 +-
 include/linux/lightnvm.h|  2 +-
 33 files changed, 286 insertions(+), 90 deletions(-)

-- 
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


ERROR: "crc32c" [drivers/md/raid456.ko] undefined!

2015-11-07 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   ad804a0b2a769a0eed29015c53fe395449c09d13
commit: 5cb2fbd6ea0d151dcb12d98c06c8761eedfed2ee raid5-cache: use crc32c 
checksum
date:   7 days ago
config: arm-sa1100 (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 5cb2fbd6ea0d151dcb12d98c06c8761eedfed2ee
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

>> ERROR: "crc32c" [drivers/md/raid456.ko] undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: GSO with udp_tunnel_xmit_skb

2015-11-07 Thread Maciej Żenczykowski
> What I was thinking about is this: My driver receives a super-packet.
> By calling skb_gso_segment(), I'm given a list of equal sized packets
> (of gso_size each), except for the last one which is either the same
> size or smaller than the rest. Let's say calling skb_gso_segment()
> gives me a list of 1300 byte packets.

This isn't particularly efficient.  This is basically equivalent to doing
GSO before the superpacket reaches your driver (you might get some
savings by not bothering to look at the packet headers of the second
and on packets, but that's most likely minimal savings).

In particular you're allocating a new skb and clearing it for each of those
1300 byte packets (and deallocating the superpacket skb).  And then you
are presumably deallocating all those freshly allocated skbs - since
I'm guessing
you are creating new skbs for transmit.

What you really want to do (although of course it's much harder)
is not call skb_gso_segment() at all for packet formats you know how
to handle (ideally you can handle anything you claim to be able to
handle via the features bits)
and instead reach directly into the skb and grab the right portions
of it and handle them directly.  This way you only ever have the one
incoming skb,
but yes it requires considerable effort.

This should get you a fair bit of savings.

> Next, I do a particular
> transformation to the packet. Let's say I encrypt it somehow, and I
> add on some additional information. Now all those 1300 byte packets
> yield new 1400 byte packets. It is time to send those 1400 byte
> packets to a particular destination.

Are you in control of the receiver?  Can you modify packet format?

> Since they're all children of the
> same skb_gso_segment()ified packet, they're all destined for the same
> destination. So, one solution is to do this:
>
> for each skb in list:
> udp_tunnel_xmit_skb(dst, skb);
>
> But this does not perform how I'd like it to perform. The reason is
> that now each and every one of these packets has to traverse the whole
> networking stack, including various netfilter postrouting hooks and
> such, but most importantly, it means the ethernet driver that's
> sending the physical packet has to process each and every one.

Theoretically you could manually add the proper headers to each
of the new packets, and create a chain and send that, although
honestly I'm not sure if the stack is at all capable of dealing with
that atm.

Alternatively instead of sending through the stack, put on full ethernet
headers and send straight to the nic via the nic's xmit function.

> My hope was that instead of doing the `for each` above, I could
> instead do something like:
>
> superpacket->gso_size = 1400
> for each skb in list:
> add_to_superpacket_as_ufo(skb, superpacket);
> udp_tunnel_xmit_skb(dst, superpacket);

UFO = UDP Fragmentation Offload = really meaning 'UDP transmit
checksum offload + IP fragmentation offload'

so when you send that out you get ip fragments of 1 udp packet, not
many individual udp packets.

> And that way, the superpacket would only have to traverse the
> networking stack once, leaving it either to the final ethernet driver
> to send in a big chunk to the ethernet card, or to the
> skb_gso_segment() call in core.c's validate_xmit_skb().

> Is this conceptually okay? What you wrote would seem to indicate it
> doesn't make sense conceptually, but I'm not sure.

This definitely doesn't make sense with UFO.

---

It is possible some hardware (possibly some intel nics, maybe bnx2x)
could be tricked into doing udp segmentation with their tcp segmentation
engine.  Theoretically (based on having glanced at the datasheets) the
intel nic segmentation is pretty generic, and it would appear at first
glance that with the right driver hacks (populating the transmit descriptor
correctly) it could be made to work.  I mention bnx2x because
they managed to make tcp segmentation work with tunnels,
so it's possible that the support is generic enough for it to be possible (with
driver changes).  Who knows.

It may or may not require putting on a fake 20 byte TCP header.
There's some tunnel spec that basically does that (should be able to find
an RFC online [perhaps I'm thinking of STT - Stateless Transport Tunneling].

I don't think there is currently any way to setup a linux skb with the
right metadata for it to just happen though.

It does seem like something that could be potentially worth adding though.

> So you mean to say UFO is mostly useful for just IP fragmentation?
> Don't some NICs also generate individual UDP packets when you pass it
> a big buffer of multiple pieces of data all at once?

I'm not actually aware of any nics doing that.  It's possible if you
take an IP/TCP TSO
superpacket and stuff an extra IP/UDP header on it the existing tunnel offload
stuff in the kernel might make that happen with some nics.  Unsure though
(as in unsure whether IP/UDP tunneling is currently supported, I know
IP/GRE is).
--
To unsubscribe 

Re: [RFC PATCH 08/28] lkl: system call interface and application API

2015-11-07 Thread Arnd Bergmann
On Tuesday 03 November 2015 22:20:39 Octavian Purdila wrote:
> +
> +/*
> + * Unsupported system calls due to lack of support in LKL (e.g. related to
> + * virtual memory, signal, user processes). We also only support 64bit 
> version
> + * of system calls where we have two version to keep the same APi across 32 
> and
> + * 64 bit hosts.
> + */
> +#define __NR_restart_syscall 0
> +#define __NR_exit 0
> +#define __NR_fork 0
> +#define __NR_execve 0
> +#define __NR_ptrace 0
> +#define __NR_alarm 0
> +#define __NR_pause 0

Why are these not #undef?

> diff --git a/arch/lkl/include/uapi/asm/unistd.h 
> b/arch/lkl/include/uapi/asm/unistd.h
> new file mode 100644
> index 000..68b5423
> --- /dev/null
> +++ b/arch/lkl/include/uapi/asm/unistd.h
> @@ -0,0 +1,256 @@
> +#ifndef _ASM_UAPI_LKL_UNISTD_H
> +#define _ASM_UAPI_LKL_UNISTD_H
> +
> +#ifdef __KERNEL__
> +#define __NR_ni_syscall  0
> +#define __NR_reboot  1
> +#endif
> +#define __NR_getpid  2
> +#define __NR_write   3
> +#define __NR_close   4
> +#define __NR_unlink  5
> +#define __NR_open6
> +#define __NR_poll7

Could you use the standard numbers from include/uapi/asm-generic/unistd.h?
Maybe include that header and then #undef the ones you don't support?
That would avoid having to assign a new number of each future syscall
that gets added.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/4] Crypto: Crypto driver support aes/des/des3 for rk3288

2015-11-07 Thread Heiko Stuebner
Hi Zain,

looks like my comment on v1 came later than your v2 submission,
so here it is again :-)

Am Freitag, 6. November 2015, 09:17:21 schrieb Zain Wang:
> The names registered are:
> ecb(aes) cbc(aes) ecb(des) cbc(des) ecb(des3_ede) cbc(des3_ede)
> You can alloc tags above in your case.
> 
> And other algorithms and platforms will be added later on.
> 
> Signed-off-by: Zain Wang 
> ---
> 

[...]

> diff --git a/drivers/crypto/rockchip/rk3288_crypto.c 
> b/drivers/crypto/rockchip/rk3288_crypto.c
> new file mode 100644
> index 000..c2a419b
> --- /dev/null
> +++ b/drivers/crypto/rockchip/rk3288_crypto.c

[...]

> +static int rk_crypto_probe(struct platform_device *pdev)
> +{
> + int err = 0;
> + struct resource *res;
> + struct device *dev = >dev;
> + struct crypto_info_t *crypto_info;
> +

rk3288 chromebooks use the crypto-engine to validate the boot images and
seem to leave it in a half-on state. This results in an irq pending
during probe and thus a null-pointer dereference in the irq-handler, as
it runs before the crypto-device is fully initialized.

resetting the crypto block, successfull fixed that issue, so I did the
following change:

---
diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index 121b6d5..e978fb2 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -182,6 +182,8 @@
  "hclk",
  "sclk",
  "apb_pclk";
+   resets = < SRST_CRYPTO>;
+   reset-names = "crypto";
status = "okay";
};
 
diff --git a/drivers/crypto/rockchip/rk3288_crypto.c 
b/drivers/crypto/rockchip/rk3288_crypto.c
index 02830f2..2245d3d 100644
--- a/drivers/crypto/rockchip/rk3288_crypto.c
+++ b/drivers/crypto/rockchip/rk3288_crypto.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct crypto_info_t *crypto_p;
 
@@ -266,6 +267,15 @@ static int rk_crypto_probe(struct platform_device *pdev)
struct resource *res;
struct device *dev = >dev;
struct crypto_info_t *crypto_info;
+   struct reset_control *rst;
+
+   /* reset the block to remove any pending actions */
+   rst = devm_reset_control_get(dev, "crypto");
+   if (!IS_ERR(rst)) {
+   reset_control_assert(rst);
+   usleep_range(10, 20);
+   reset_control_deassert(rst);
+   }
 
crypto_info = devm_kzalloc(>dev,
sizeof(*crypto_info), GFP_KERNEL);
---


> + crypto_info = devm_kzalloc(>dev,
> +sizeof(*crypto_info), GFP_KERNEL);
> + if (!crypto_info)
> + return -ENOMEM;
> +
> + spin_lock_init(_info->lock);
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + crypto_info->reg = devm_ioremap_resource(>dev, res);
> + if (IS_ERR(crypto_info->reg)) {
> + err = PTR_ERR(crypto_info->reg);
> + goto err_ioremap;
> + }
> +
> + crypto_info->aclk = devm_clk_get(>dev, "aclk");
> + if (IS_ERR(crypto_info->aclk)) {
> + err = PTR_ERR(crypto_info->aclk);
> + goto err_ioremap;
> + }
> +
> + crypto_info->hclk = devm_clk_get(>dev, "hclk");
> + if (IS_ERR(crypto_info->hclk)) {
> + err = PTR_ERR(crypto_info->hclk);
> + goto err_ioremap;
> + }
> +
> + crypto_info->sclk = devm_clk_get(>dev, "sclk");
> + if (IS_ERR(crypto_info->sclk)) {
> + err = PTR_ERR(crypto_info->sclk);
> + goto err_ioremap;
> + }
> +
> + crypto_info->dmaclk = devm_clk_get(>dev, "apb_pclk");
> + if (IS_ERR(crypto_info->dmaclk)) {
> + err = PTR_ERR(crypto_info->dmaclk);
> + goto err_ioremap;
> + }
> +
> + crypto_info->irq = platform_get_irq(pdev, 0);
> + if (crypto_info->irq < 0) {
> + dev_warn(crypto_info->dev,
> +  "control Interrupt is not available.\n");
> + err = crypto_info->irq;
> + goto err_ioremap;
> + }
> +
> + err = devm_request_irq(>dev, crypto_info->irq, crypto_irq_handle,
> +IRQF_SHARED, "rk-crypto", pdev);
> +
> + if (err) {
> + dev_err(crypto_info->dev, "irq request failed.\n");
> + goto err_ioremap;
> + }
> +
> + crypto_info->dev = >dev;
> + platform_set_drvdata(pdev, crypto_info);
> + crypto_p = crypto_info;
> +
> + tasklet_init(_info->crypto_tasklet,
> +  rk_crypto_tasklet_cb, (unsigned long)crypto_info);
> + crypto_init_queue(_info->queue, 50);
> +
> + crypto_info->enable_clk = rk_crypto_enable_clk;
> + crypto_info->disable_clk = rk_crypto_disable_clk;
> + crypto_info->load_data = rk_load_data;
> + crypto_info->unload_data = rk_unload_data;
> +
> + err = rk_crypto_register();
> + if (err) {
> + 

Re: [RFC PATCH 21/28] lkl tools: host lib: posix host operations

2015-11-07 Thread Arnd Bergmann
On Tuesday 03 November 2015 22:20:52 Octavian Purdila wrote:
> +struct pthread_sem {
> + pthread_mutex_t lock;
> + int count;
> + pthread_cond_t cond;
> +};
> +
> +static void *sem_alloc(int count)
> +{
> + struct pthread_sem *sem;
> +
> + sem = malloc(sizeof(*sem));
> + if (!sem)
> + return NULL;
> +
> + pthread_mutex_init(>lock, NULL);
> + sem->count = count;
> + pthread_cond_init(>cond, NULL);
> +
> + return sem;
> +}

What is the reason to have generalized semaphores in the
host API rather than a simple mutex?

> +static unsigned long long time_ns(void)
> +{
> + struct timeval tv;
> +
> + gettimeofday(, NULL);
> +
> + return tv.tv_sec * 10ULL + tv.tv_usec * 1000ULL;
> +}

clock_gettime() has been around since POSIX.1-2001 and provides the
nanosecond resolution you use in the interface.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 0/9] Better compatible for the rockchip thermal and support RK3368 SoCs

2015-11-07 Thread Heiko Stuebner
Hi Caesar,

Am Samstag, 7. November 2015, 23:53:30 schrieb Caesar Wang:
> 在 2015年11月07日 03:03, Heiko Stuebner 写道:[]
> 
> []
> 
> > I call dibs on the devicetree patches :-) .
> >
> > Code and dt parts are very much separate, so I'd like to take the dt parts
> > though my tree and arm-soc to keep further dts changes together.
> > Of course only once you are ok with the code parts :-)
> >
> > Devicetree parts themselfs look ok to me.
> 
> Many thanks, I guess that I don't need send the dts patch again.;-)
> the Code is still a bit change for thermal driver.

I think you should still send the dts patches with next revisions. I can
only take the patches, once Eduardo is satisfied with the code changes
that include the new binding, and while I hope that this will be in v3, it
will be hard if we get to v5 or so, to grep through the older revisions,
trying to find the dts changes :-).


Heiko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [BUG, PATCH 03/10] sysfs: added __compat_only_sysfs_link_entry_to_kobj()

2015-11-07 Thread Jeremiah Mahler
Jarkko,

On Sun, Nov 08, 2015 at 12:31:09AM +0200, Jarkko Sakkinen wrote:
> On Sat, Nov 07, 2015 at 10:08:56AM -0800, Jeremiah Mahler wrote:
> > Jarkko,
> > 
> > On Sat, Nov 07, 2015 at 01:41:37PM +0200, Jarkko Sakkinen wrote:
> > > On Sat, Nov 07, 2015 at 12:55:43PM +0200, Jarkko Sakkinen wrote:
> > > > On Fri, Nov 06, 2015 at 06:55:18PM -0800, Jeremiah Mahler wrote:
> > > > > Jarkko,
> > > > > 
[...]
> > > I pushed a fix over here:
> > > 
> > > https://github.com/jsakkine/linux-tpmdd/tree/fixes
> > > 
> > This fix does work since it effectively avoids the call to
> > __compat_only_sysfs_link_entry_to_kobj().
> > 
> > Have you tested cases where __compat_only_sysfs_link_entry_to_kobj()
> > is actually used?
> 
> Yes, of course I have. And I checked your DSDT and my assumption was
> correct. There was no DSM in the ACPI object.
> 
> However, there is probably another regression but it is caused by some
> patch that was added earlier. I strongly believe it is not caused by any
> of my 4.4 patches.
> 
> I think what was happening with you was that
> __compat_only_sysfs_link_entry_to_kobj() was returning -ENOENT, which it
> should do when target is not found. This was propagated to tpm_tis and
> it probably messes up clean up somehow.
> 
> I have to test my hypothesis as soon as possible. The fix that I pushed
> is still valid no matter which way the things are.
> 
> > [...]
> > 
> > -- 
> > - Jeremiah Mahler
> 
> /Jarkko

It sounds like you have the problem figured out and have a good fix.
If I can do anything else to help let me know :-)

-- 
- Jeremiah Mahler
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: GSO with udp_tunnel_xmit_skb

2015-11-07 Thread Jason A. Donenfeld
Hi Maciej,

Thanks for your reply. Some interesting things to consider here... See
inline below.

On Sat, Nov 7, 2015 at 6:19 PM, Maciej Żenczykowski
 wrote:
>
> UFO will never collapse multiple (UDP) packets.
>
> It would be incorrect to do so, since UDP has to maintain packet
> framing boundaries, and the only way to mark that on the wire is via
> individual appropriately sized packets.

What I was thinking about is this: My driver receives a super-packet.
By calling skb_gso_segment(), I'm given a list of equal sized packets
(of gso_size each), except for the last one which is either the same
size or smaller than the rest. Let's say calling skb_gso_segment()
gives me a list of 1300 byte packets. Next, I do a particular
transformation to the packet. Let's say I encrypt it somehow, and I
add on some additional information. Now all those 1300 byte packets
yield new 1400 byte packets. It is time to send those 1400 byte
packets to a particular destination. Since they're all children of the
same skb_gso_segment()ified packet, they're all destined for the same
destination. So, one solution is to do this:

for each skb in list:
udp_tunnel_xmit_skb(dst, skb);

But this does not perform how I'd like it to perform. The reason is
that now each and every one of these packets has to traverse the whole
networking stack, including various netfilter postrouting hooks and
such, but most importantly, it means the ethernet driver that's
sending the physical packet has to process each and every one.

My hope was that instead of doing the `for each` above, I could
instead do something like:

superpacket->gso_size = 1400
for each skb in list:
add_to_superpacket_as_ufo(skb, superpacket);
udp_tunnel_xmit_skb(dst, superpacket);

And that way, the superpacket would only have to traverse the
networking stack once, leaving it either to the final ethernet driver
to send in a big chunk to the ethernet card, or to the
skb_gso_segment() call in core.c's validate_xmit_skb().

Is this conceptually okay? What you wrote would seem to indicate it
doesn't make sense conceptually, but I'm not sure.
I started to write some code to do that, which isn't really working,
and I outlined it here [1].


> UFO prevents the need to do IP fragmentation on overly large
> *singular* UDP packets.
>
> The case where UFO (should) help is if you are taking a TCP TSO
> segment of 10k and adding UDP headers and sending it out as an
> 20+8+10k UDP packet.
> Without UFO this would now need to be software (potentially
> checksummed and) ip fragmented into (8+10k)/(1500-20) packets
> (assuming 1500 mtu), with UFO hw offload the nic deals with that (it
> does the checksumming and it does the ip fragmentation).

So you mean to say UFO is mostly useful for just IP fragmentation?
Don't some NICs also generate individual UDP packets when you pass it
a big buffer of multiple pieces of data all at once?

Thanks,
Jason

[1] http://www.spinics.net/lists/netdev/msg351400.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [BUG, PATCH 03/10] sysfs: added __compat_only_sysfs_link_entry_to_kobj()

2015-11-07 Thread Jarkko Sakkinen
On Sat, Nov 07, 2015 at 10:08:56AM -0800, Jeremiah Mahler wrote:
> Jarkko,
> 
> On Sat, Nov 07, 2015 at 01:41:37PM +0200, Jarkko Sakkinen wrote:
> > On Sat, Nov 07, 2015 at 12:55:43PM +0200, Jarkko Sakkinen wrote:
> > > On Fri, Nov 06, 2015 at 06:55:18PM -0800, Jeremiah Mahler wrote:
> > > > Jarkko,
> > > > 
> [...]
> > > > > + entry = kernfs_find_and_get(target_kobj->sd, target_name);
> > > > > + if (!entry) {
> > > > > + kernfs_put(target);
> > > > > + return -ENOENT;
> > > > > + }
> > > > > +
> > > > 
> > > > On an Acer C720 this call to kernfs_find_and_get fails resulting in
> > > > a failed resume after suspend.
> > > > 
> > > > Apparently it can't find an object for the name "ppi".
> > > > 
> > > > This bug does not appear until the next patch is applied which
> > > > calls __compat_only_sysfs_link_entry_to_kobj.
> > > 
> > > I think I might have found something thanks to your help
> > > 
> > > First I found this old bug:
> > > 
> > > https://bugzilla.redhat.com/show_bug.cgi?id=1096511
> > > 
> > > What is happening is that DSM is not found and therefore tpm_add_ppi()
> > > does not add ppi to sysfs groups array.
> > > 
> > > __compat_only_sysfs_link_entry_to_kobj() is called after tpm_add_ppi
> > > unconditionally for TPM1.
> > > 
> > > I'll implement a fix for this ASAP.
> > > 
> > > Thank you for great effort on finding tis!
> > 
> > I pushed a fix over here:
> > 
> > https://github.com/jsakkine/linux-tpmdd/tree/fixes
> > 
> This fix does work since it effectively avoids the call to
> __compat_only_sysfs_link_entry_to_kobj().
> 
> Have you tested cases where __compat_only_sysfs_link_entry_to_kobj()
> is actually used?

Yes, of course I have. And I checked your DSDT and my assumption was
correct. There was no DSM in the ACPI object.

However, there is probably another regression but it is caused by some
patch that was added earlier. I strongly believe it is not caused by any
of my 4.4 patches.

I think what was happening with you was that
__compat_only_sysfs_link_entry_to_kobj() was returning -ENOENT, which it
should do when target is not found. This was propagated to tpm_tis and
it probably messes up clean up somehow.

I have to test my hypothesis as soon as possible. The fix that I pushed
is still valid no matter which way the things are.

> [...]
> 
> -- 
> - Jeremiah Mahler

/Jarkko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   >