Re: (bisected) Lock up on sh73a0/kzm9g on cpuidle initialization

2014-11-06 Thread Geert Uytterhoeven
Hi Daniel,

On Thu, Nov 6, 2014 at 10:02 PM, Daniel Lezcano
 wrote:
> On 11/06/2014 09:38 PM, Geert Uytterhoeven wrote:
>> When CONFIG_CPU_IDLE=y, the kernel locks up during cpuidle initialization
>> on Renesas sh73a0/kzm9g-reference, which has a dual-core Cortex-A9.
>>
>> Last message is:
>>
>>  DMA: preallocated 256 KiB pool for atomic coherent allocations
>>
>> After this it's supposed to print:
>>
>>  cpuidle: using governor ladder
>>  cpuidle: using governor menu
>>
>> I've bisected this to commit 442bf3aaf55a91ebfec71da46a4ee10a3c905bcc
>> ("sched: Let the scheduler see CPU idle states").
>>
>> Reverting that commit, and commit 83a0a96a5f26d974580fd7251043ff70c8f1823d
>> ("sched/fair: Leverage the idle state info when choosing the "idlest"
>> cpu") which
>> depends on it, fixes the problem.
>>
>> I saw the discussion "lockdep splat in CPU hotplug", so I enabled lockdep
>> debugging, but didn't see a lockdep splat.
>
> Did you try the fix attached ?
>
> https://lkml.org/lkml/2014/10/22/722

Thanks, I didn't try that.

However, this patch seems to be in v3.18-rc3, so I'm already using it.
Hence it doesn't fix the problem for me.

On another board, with a dual Cortex-A15, the problem doesn't show up.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
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 -mm v7 01/13] mm/pagewalk: remove pgd_entry() and pud_entry()

2014-11-06 Thread Naoya Horiguchi
Currently no user of page table walker sets ->pgd_entry() or ->pud_entry(),
so checking their existence in each loop is just wasting CPU cycle.
So let's remove it to reduce overhead.

Signed-off-by: Naoya Horiguchi 
Acked-by: Kirill A. Shutemov 
---
 include/linux/mm.h | 6 --
 mm/pagewalk.c  | 9 ++---
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git mmotm-2014-11-05-16-01.orig/include/linux/mm.h 
mmotm-2014-11-05-16-01/include/linux/mm.h
index 423024a0d3db..ba964aa0282a 100644
--- mmotm-2014-11-05-16-01.orig/include/linux/mm.h
+++ mmotm-2014-11-05-16-01/include/linux/mm.h
@@ -1120,8 +1120,6 @@ void unmap_vmas(struct mmu_gather *tlb, struct 
vm_area_struct *start_vma,
 
 /**
  * mm_walk - callbacks for walk_page_range
- * @pgd_entry: if set, called for each non-empty PGD (top-level) entry
- * @pud_entry: if set, called for each non-empty PUD (2nd-level) entry
  * @pmd_entry: if set, called for each non-empty PMD (3rd-level) entry
  *this handler is required to be able to handle
  *pmd_trans_huge() pmds.  They may simply choose to
@@ -1135,10 +1133,6 @@ void unmap_vmas(struct mmu_gather *tlb, struct 
vm_area_struct *start_vma,
  * (see walk_page_range for more details)
  */
 struct mm_walk {
-   int (*pgd_entry)(pgd_t *pgd, unsigned long addr,
-unsigned long next, struct mm_walk *walk);
-   int (*pud_entry)(pud_t *pud, unsigned long addr,
-unsigned long next, struct mm_walk *walk);
int (*pmd_entry)(pmd_t *pmd, unsigned long addr,
 unsigned long next, struct mm_walk *walk);
int (*pte_entry)(pte_t *pte, unsigned long addr,
diff --git mmotm-2014-11-05-16-01.orig/mm/pagewalk.c 
mmotm-2014-11-05-16-01/mm/pagewalk.c
index ad83195521f2..5d41393260c8 100644
--- mmotm-2014-11-05-16-01.orig/mm/pagewalk.c
+++ mmotm-2014-11-05-16-01/mm/pagewalk.c
@@ -86,9 +86,7 @@ static int walk_pud_range(pgd_t *pgd, unsigned long addr, 
unsigned long end,
break;
continue;
}
-   if (walk->pud_entry)
-   err = walk->pud_entry(pud, addr, next, walk);
-   if (!err && (walk->pmd_entry || walk->pte_entry))
+   if (walk->pmd_entry || walk->pte_entry)
err = walk_pmd_range(pud, addr, next, walk);
if (err)
break;
@@ -234,10 +232,7 @@ int walk_page_range(unsigned long addr, unsigned long end,
pgd++;
continue;
}
-   if (walk->pgd_entry)
-   err = walk->pgd_entry(pgd, addr, next, walk);
-   if (!err &&
-   (walk->pud_entry || walk->pmd_entry || walk->pte_entry))
+   if (walk->pmd_entry || walk->pte_entry)
err = walk_pud_range(pgd, addr, next, walk);
if (err)
break;
-- 
2.2.0.rc0.2.gf745acb
--
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 -mm v7 04/13] smaps: remove mem_size_stats->vma and use walk_page_vma()

2014-11-06 Thread Naoya Horiguchi
pagewalk.c can handle vma in itself, so we don't have to pass vma via
walk->private. And show_smap() walks pages on vma basis, so using
walk_page_vma() is preferable.

Signed-off-by: Naoya Horiguchi 
Acked-by: Kirill A. Shutemov 
---
 fs/proc/task_mmu.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git mmotm-2014-11-05-16-01.orig/fs/proc/task_mmu.c 
mmotm-2014-11-05-16-01/fs/proc/task_mmu.c
index 2ab200d429be..c1b937095625 100644
--- mmotm-2014-11-05-16-01.orig/fs/proc/task_mmu.c
+++ mmotm-2014-11-05-16-01/fs/proc/task_mmu.c
@@ -433,7 +433,6 @@ const struct file_operations proc_tid_maps_operations = {
 
 #ifdef CONFIG_PROC_PAGE_MONITOR
 struct mem_size_stats {
-   struct vm_area_struct *vma;
unsigned long resident;
unsigned long shared_clean;
unsigned long shared_dirty;
@@ -480,7 +479,7 @@ static void smaps_pte_entry(pte_t *pte, unsigned long addr,
struct mm_walk *walk)
 {
struct mem_size_stats *mss = walk->private;
-   struct vm_area_struct *vma = mss->vma;
+   struct vm_area_struct *vma = walk->vma;
pgoff_t pgoff = linear_page_index(vma, addr);
struct page *page = NULL;
 
@@ -512,7 +511,7 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,
struct mm_walk *walk)
 {
struct mem_size_stats *mss = walk->private;
-   struct vm_area_struct *vma = mss->vma;
+   struct vm_area_struct *vma = walk->vma;
struct page *page;
 
/* FOLL_DUMP will return -EFAULT on huge zero page */
@@ -533,8 +532,7 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,
 static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
   struct mm_walk *walk)
 {
-   struct mem_size_stats *mss = walk->private;
-   struct vm_area_struct *vma = mss->vma;
+   struct vm_area_struct *vma = walk->vma;
pte_t *pte;
spinlock_t *ptl;
 
@@ -624,10 +622,8 @@ static int show_smap(struct seq_file *m, void *v, int 
is_pid)
};
 
memset(, 0, sizeof mss);
-   mss.vma = vma;
/* mmap_sem is held in m_start */
-   if (vma->vm_mm && !is_vm_hugetlb_page(vma))
-   walk_page_range(vma->vm_start, vma->vm_end, _walk);
+   walk_page_vma(vma, _walk);
 
show_map_vma(m, vma, is_pid);
 
-- 
2.2.0.rc0.2.gf745acb
--
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 -mm v7 10/13] arch/powerpc/mm/subpage-prot.c: use walk->vma and walk_page_vma()

2014-11-06 Thread Naoya Horiguchi
We don't have to use mm_walk->private to pass vma to the callback function
because of mm_walk->vma. And walk_page_vma() is useful if we walk over a
single vma.

Signed-off-by: Naoya Horiguchi 
Acked-by: Kirill A. Shutemov 
---
 arch/powerpc/mm/subpage-prot.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git mmotm-2014-11-05-16-01.orig/arch/powerpc/mm/subpage-prot.c 
mmotm-2014-11-05-16-01/arch/powerpc/mm/subpage-prot.c
index 6c0b1f5f8d2c..fa9fb5b4c66c 100644
--- mmotm-2014-11-05-16-01.orig/arch/powerpc/mm/subpage-prot.c
+++ mmotm-2014-11-05-16-01/arch/powerpc/mm/subpage-prot.c
@@ -134,7 +134,7 @@ static void subpage_prot_clear(unsigned long addr, unsigned 
long len)
 static int subpage_walk_pmd_entry(pmd_t *pmd, unsigned long addr,
  unsigned long end, struct mm_walk *walk)
 {
-   struct vm_area_struct *vma = walk->private;
+   struct vm_area_struct *vma = walk->vma;
split_huge_page_pmd(vma, addr, pmd);
return 0;
 }
@@ -163,9 +163,7 @@ static void subpage_mark_vma_nohuge(struct mm_struct *mm, 
unsigned long addr,
if (vma->vm_start >= (addr + len))
break;
vma->vm_flags |= VM_NOHUGEPAGE;
-   subpage_proto_walk.private = vma;
-   walk_page_range(vma->vm_start, vma->vm_end,
-   _proto_walk);
+   walk_page_vma(vma, _proto_walk);
vma = vma->vm_next;
}
 }
-- 
2.2.0.rc0.2.gf745acb
--
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 -mm v7 00/13] pagewalk: improve vma handling, apply to new users

2014-11-06 Thread Naoya Horiguchi
This series is ver.7 of page table walker patchset.

I apologize about my long delay since previous version (I have moved to
Japan last month and no machine access for a while.)
I just rebased this onto mmotm-2014-11-05-16-01. I had some conflicts but
the resolution was not hard.
Trinity showed no bug at least in my environment.

Thanks,
Naoya Horiguchi

Tree: g...@github.com:Naoya-Horiguchi/linux.git
Branch: mmotm-2014-11-05-16-01/page_table_walker.ver7
---
Summary:

Kirill A. Shutemov (1):
  mm: /proc/pid/clear_refs: avoid split_huge_page()

Naoya Horiguchi (12):
  mm/pagewalk: remove pgd_entry() and pud_entry()
  pagewalk: improve vma handling
  pagewalk: add walk_page_vma()
  smaps: remove mem_size_stats->vma and use walk_page_vma()
  clear_refs: remove clear_refs_private->vma and introduce 
clear_refs_test_walk()
  pagemap: use walk->vma instead of calling find_vma()
  numa_maps: fix typo in gather_hugetbl_stats
  numa_maps: remove numa_maps->vma
  memcg: cleanup preparation for page table walk
  arch/powerpc/mm/subpage-prot.c: use walk->vma and walk_page_vma()
  mempolicy: apply page table walker on queue_pages_range()
  mincore: apply page table walker on do_mincore()

 arch/powerpc/mm/subpage-prot.c |   6 +-
 fs/proc/task_mmu.c | 206 ++---
 include/linux/mm.h |  22 ++--
 mm/huge_memory.c   |  20 
 mm/memcontrol.c|  49 +++--
 mm/mempolicy.c | 228 +
 mm/mincore.c   | 169 +++---
 mm/pagewalk.c  | 228 -
 8 files changed, 419 insertions(+), 509 deletions(-)--
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 -mm v7 03/13] pagewalk: add walk_page_vma()

2014-11-06 Thread Naoya Horiguchi
Introduces walk_page_vma(), which is useful for the callers which want to
walk over a given vma.  It's used by later patches.

Signed-off-by: Naoya Horiguchi 
Acked-by: Kirill A. Shutemov 
---
ChangeLog v3:
- check walk_page_test's return value instead of walk->skip
---
 include/linux/mm.h |  1 +
 mm/pagewalk.c  | 18 ++
 2 files changed, 19 insertions(+)

diff --git mmotm-2014-11-05-16-01.orig/include/linux/mm.h 
mmotm-2014-11-05-16-01/include/linux/mm.h
index 25a4cf75b575..1022cc27150e 100644
--- mmotm-2014-11-05-16-01.orig/include/linux/mm.h
+++ mmotm-2014-11-05-16-01/include/linux/mm.h
@@ -1157,6 +1157,7 @@ struct mm_walk {
 
 int walk_page_range(unsigned long addr, unsigned long end,
struct mm_walk *walk);
+int walk_page_vma(struct vm_area_struct *vma, struct mm_walk *walk);
 void free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
unsigned long end, unsigned long floor, unsigned long ceiling);
 int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
diff --git mmotm-2014-11-05-16-01.orig/mm/pagewalk.c 
mmotm-2014-11-05-16-01/mm/pagewalk.c
index d9cc3caae802..4c9a653ba563 100644
--- mmotm-2014-11-05-16-01.orig/mm/pagewalk.c
+++ mmotm-2014-11-05-16-01/mm/pagewalk.c
@@ -272,3 +272,21 @@ int walk_page_range(unsigned long start, unsigned long end,
} while (start = next, start < end);
return err;
 }
+
+int walk_page_vma(struct vm_area_struct *vma, struct mm_walk *walk)
+{
+   int err;
+
+   if (!walk->mm)
+   return -EINVAL;
+
+   VM_BUG_ON(!rwsem_is_locked(>mm->mmap_sem));
+   VM_BUG_ON(!vma);
+   walk->vma = vma;
+   err = walk_page_test(vma->vm_start, vma->vm_end, walk);
+   if (err > 0)
+   return 0;
+   if (err < 0)
+   return err;
+   return __walk_page_range(vma->vm_start, vma->vm_end, walk);
+}
-- 
2.2.0.rc0.2.gf745acb
--
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 -mm v7 07/13] numa_maps: fix typo in gather_hugetbl_stats

2014-11-06 Thread Naoya Horiguchi
Just doing s/gather_hugetbl_stats/gather_hugetlb_stats/g, this makes code
grep-friendly.

Signed-off-by: Naoya Horiguchi 
Acked-by: Kirill A. Shutemov 
---
 fs/proc/task_mmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git mmotm-2014-11-05-16-01.orig/fs/proc/task_mmu.c 
mmotm-2014-11-05-16-01/fs/proc/task_mmu.c
index f997734d2b4b..bddae83fbf39 100644
--- mmotm-2014-11-05-16-01.orig/fs/proc/task_mmu.c
+++ mmotm-2014-11-05-16-01/fs/proc/task_mmu.c
@@ -1392,7 +1392,7 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long 
addr,
return 0;
 }
 #ifdef CONFIG_HUGETLB_PAGE
-static int gather_hugetbl_stats(pte_t *pte, unsigned long hmask,
+static int gather_hugetlb_stats(pte_t *pte, unsigned long hmask,
unsigned long addr, unsigned long end, struct mm_walk *walk)
 {
struct numa_maps *md;
@@ -1411,7 +1411,7 @@ static int gather_hugetbl_stats(pte_t *pte, unsigned long 
hmask,
 }
 
 #else
-static int gather_hugetbl_stats(pte_t *pte, unsigned long hmask,
+static int gather_hugetlb_stats(pte_t *pte, unsigned long hmask,
unsigned long addr, unsigned long end, struct mm_walk *walk)
 {
return 0;
@@ -1442,7 +1442,7 @@ static int show_numa_map(struct seq_file *m, void *v, int 
is_pid)
 
md->vma = vma;
 
-   walk.hugetlb_entry = gather_hugetbl_stats;
+   walk.hugetlb_entry = gather_hugetlb_stats;
walk.pmd_entry = gather_pte_stats;
walk.private = md;
walk.mm = mm;
-- 
2.2.0.rc0.2.gf745acb
--
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/


[RFC] ptrace: add generic SET_SYSCALL request

2014-11-06 Thread AKASHI Takahiro
This patch adds a new generic ptrace request, PTRACE_SET_SYSCALL.
It can be used to change a system call number as follows:
ret = ptrace(pid, PTRACE_SET_SYSCALL, null, new_syscall_no);
'new_syscall_no' can be -1 to skip this system call, you need to modify
a register's value, in arch-specific way, as return value though.

Please note that we can't define PTRACE_SET_SYSCALL macro in
uapi/linux/ptrace.h partly because its value on arm, 23, is used as another
request on sparc.

This patch also contains an example of change on arch side, arm.
Only syscall_set_nr() is required to be defined in asm/syscall.h.

Currently only arm has this request, while arm64 would also have it
once my patch series of seccomp for arm64 is merged. It will also be
usable for most of other arches.
See the discussions in lak-ml:
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-November/300167.html

Signed-off-by: AKASHI Takahiro 
---
 arch/arm/include/asm/syscall.h |7 +++
 arch/arm/kernel/ptrace.c   |5 -
 kernel/ptrace.c|6 ++
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h
index e86c985..3e1d9c0 100644
--- a/arch/arm/include/asm/syscall.h
+++ b/arch/arm/include/asm/syscall.h
@@ -24,6 +24,13 @@ static inline int syscall_get_nr(struct task_struct *task,
return task_thread_info(task)->syscall;
 }
 
+static inline int syscall_set_nr(struct task_struct *task,
+struct pt_regs *regs, int syscall)
+{
+   task_thread_info(task)->syscall = syscall;
+   return 0;
+}
+
 static inline void syscall_rollback(struct task_struct *task,
struct pt_regs *regs)
 {
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index ef9119f..908bae8 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -853,11 +853,6 @@ long arch_ptrace(struct task_struct *child, long request,
   datap);
break;
 
-   case PTRACE_SET_SYSCALL:
-   task_thread_info(child)->syscall = data;
-   ret = 0;
-   break;
-
 #ifdef CONFIG_CRUNCH
case PTRACE_GETCRUNCHREGS:
ret = ptrace_getcrunchregs(child, datap);
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 54e7522..d7048fa 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -1001,6 +1001,12 @@ int ptrace_request(struct task_struct *child, long 
request,
break;
}
 #endif
+
+#ifdef PTRACE_SET_SYSCALL
+   case PTRACE_SET_SYSCALL:
+   ret = syscall_set_nr(child, task_pt_regs(child), data);
+   break;
+#endif
default:
break;
}
-- 
1.7.9.5

--
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 0/2] Kernel Live Patching

2014-11-06 Thread Christoph Hellwig
On Thu, Nov 06, 2014 at 09:24:23PM +0100, Vojtech Pavlik wrote:
> One reason is that there are currently at least two generators using
> very different methods of generation (in addition to the option of doing
> the patch module by hand), and neither of them are currently in a state
> where they would be ready for inclusion into the kernel (although the
> kpatch one is clearly closer to that).

So agree on one method and get it into shape, just like we do for other
kernel subsystems.

--
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 0/2] Kernel Live Patching

2014-11-06 Thread Christoph Hellwig
On Thu, Nov 06, 2014 at 02:49:26PM -0500, Steven Rostedt wrote:
> I understand that there is two methods in doing this. Is it possible to
> create a "simple generator" that only does the simple case. Perhaps can
> detect non simple cases where it rejects the change and tells the user
> they need to reboot.

Especially the complicated case needs to be in tree, otherwise we're
almost guaranteed to break it constantly.

--
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 0/2] Kernel Live Patching

2014-11-06 Thread Christoph Hellwig
On Thu, Nov 06, 2014 at 01:34:33PM -0600, Josh Poimboeuf wrote:
> I agree that we should also put kpatch-build (or some converged
> kpatch/kGraft-build tool) into the kernel tree, because of the tight
> interdependencies between it and the kernel.  I think it would make
> development much easier.  Otherwise, for example, it may end up having a
> lot of #ifdef hacks based on what kernel version it's targeting.

Exactly.
--
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: [LKP] [dmi] PANIC: early exception 0e rip 10:ffffffff81899e6b error 9 cr2 ffffffffff240000

2014-11-06 Thread Ard Biesheuvel
On 7 November 2014 08:37, Yuanhan Liu  wrote:
> On Fri, Nov 07, 2014 at 08:17:36AM +0100, Ard Biesheuvel wrote:
>> On 7 November 2014 06:47, LKP  wrote:
>> > FYI, we noticed the below changes on
>> >
>> > https://git.linaro.org/people/ard.biesheuvel/linux-arm efi-for-3.19
>> > commit aacdce6e880894acb57d71dcb2e3fc61b4ed4e96 ("dmi: add support for 
>> > SMBIOS 3.0 64-bit entry point")
>> >
>> >
>> > +---+++
>> > |   | 2fa165a26c | aacdce6e88 |
>> > +---+++
>> > | boot_successes| 20 | 10 |
>> > | early-boot-hang   | 1  ||
>> > | boot_failures | 0  | 5  |
>> > | PANIC:early_exception | 0  | 5  |
>> > +---+++
>> >
>> >
>> > [0.00] BIOS-e820: [mem 0x0001-0x00036fff] 
>> > usable
>> > [0.00] bootconsole [earlyser0] enabled
>> > [0.00] NX (Execute Disable) protection: active
>> > PANIC: early exception 0e rip 10:81899e6b error 9 cr2 
>> > ff24
>> > [0.00] CPU: 0 PID: 0 Comm: swapper Not tainted 3.18.0-rc2-gc5221e6 
>> > #1
>> > [0.00]   82203d30 819f0a6e 
>> > 03f8
>> > [0.00]  ff24 82203e18 823701b0 
>> > 82511401
>> > [0.00]   0ba3  
>> > ff24
>> > [0.00] Call Trace:
>> > [0.00]  [] dump_stack+0x4e/0x68
>> > [0.00]  [] early_idt_handler+0x90/0xb7
>> > [0.00]  [] ? dmi_save_one_device+0x81/0x81
>> > [0.00]  [] ? dmi_table+0x3f/0x94
>> > [0.00]  [] ? dmi_table+0x16/0x94
>> > [0.00]  [] ? dmi_save_one_device+0x81/0x81
>> > [0.00]  [] ? dmi_save_one_device+0x81/0x81
>> > [0.00]  [] dmi_walk_early+0x44/0x69
>> > [0.00]  [] dmi_present+0x180/0x1ff
>> > [0.00]  [] dmi_scan_machine+0x144/0x191
>> > [0.00]  [] ? loglevel+0x31/0x31
>> > [0.00]  [] setup_arch+0x490/0xc73
>> > [0.00]  [] ? printk+0x4d/0x4f
>> > [0.00]  [] start_kernel+0x9c/0x43f
>> > [0.00]  [] ? early_idt_handlers+0x120/0x120
>> > [0.00]  [] x86_64_start_reservations+0x2a/0x2c
>> > [0.00]  [] x86_64_start_kernel+0x13b/0x14a
>> > [0.00] RIP 0x4
>> >
>>
>> This is most puzzling. Could anyone decode the exception?
>> This looks like the non-EFI path through dmi_scan_machine(), which
>> calls dmi_present() /after/ calling dmi_smbios3_present(), which
>> apparently has not found the _SM3_ header tag. Or could the call stack
>> be inaccurate?
>>
>> Anyway, it would be good to know the exact type of the platform,
>
> It's a Nehalem-EP machine, wht 16 CPU and 12G memory.
>
>> and
>> perhaps we could find out if there is an inadvertent _SM3_ tag
>> somewhere in the 0xF - 0xF range?
>
> Sorry, how?
>

That's not a brand new machine, so I suppose there wouldn't be a
SMBIOS 3.0 header lurking in there.

Anyway, if you are in a position to try things, could you apply this

--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -617,7 +617,7 @@ void __init dmi_scan_machine(void)
memset(buf, 0, 16);
for (q = p; q < p + 0x1; q += 16) {
memcpy_fromio(buf + 16, q, 16);
-   if (!dmi_smbios3_present(buf) || !dmi_present(buf)) {
+   if (!dmi_present(buf)) {
dmi_available = 1;
dmi_early_unmap(p, 0x1);
goto out;

and try again? That is the only change that is relevant to the non-EFI
code path which this machine appears to take, so if this fixes things,
that would be valuable information even if it doesn't tell us exactly
what is going wrong.

Thanks,
Ard.
--
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: [LKP] [dmi] PANIC: early exception 0e rip 10:ffffffff81899e6b error 9 cr2 ffffffffff240000

2014-11-06 Thread Yuanhan Liu
On Fri, Nov 07, 2014 at 08:17:36AM +0100, Ard Biesheuvel wrote:
> On 7 November 2014 06:47, LKP  wrote:
> > FYI, we noticed the below changes on
> >
> > https://git.linaro.org/people/ard.biesheuvel/linux-arm efi-for-3.19
> > commit aacdce6e880894acb57d71dcb2e3fc61b4ed4e96 ("dmi: add support for 
> > SMBIOS 3.0 64-bit entry point")
> >
> >
> > +---+++
> > |   | 2fa165a26c | aacdce6e88 |
> > +---+++
> > | boot_successes| 20 | 10 |
> > | early-boot-hang   | 1  ||
> > | boot_failures | 0  | 5  |
> > | PANIC:early_exception | 0  | 5  |
> > +---+++
> >
> >
> > [0.00] BIOS-e820: [mem 0x0001-0x00036fff] usable
> > [0.00] bootconsole [earlyser0] enabled
> > [0.00] NX (Execute Disable) protection: active
> > PANIC: early exception 0e rip 10:81899e6b error 9 cr2 
> > ff24
> > [0.00] CPU: 0 PID: 0 Comm: swapper Not tainted 3.18.0-rc2-gc5221e6 
> > #1
> > [0.00]   82203d30 819f0a6e 
> > 03f8
> > [0.00]  ff24 82203e18 823701b0 
> > 82511401
> > [0.00]   0ba3  
> > ff24
> > [0.00] Call Trace:
> > [0.00]  [] dump_stack+0x4e/0x68
> > [0.00]  [] early_idt_handler+0x90/0xb7
> > [0.00]  [] ? dmi_save_one_device+0x81/0x81
> > [0.00]  [] ? dmi_table+0x3f/0x94
> > [0.00]  [] ? dmi_table+0x16/0x94
> > [0.00]  [] ? dmi_save_one_device+0x81/0x81
> > [0.00]  [] ? dmi_save_one_device+0x81/0x81
> > [0.00]  [] dmi_walk_early+0x44/0x69
> > [0.00]  [] dmi_present+0x180/0x1ff
> > [0.00]  [] dmi_scan_machine+0x144/0x191
> > [0.00]  [] ? loglevel+0x31/0x31
> > [0.00]  [] setup_arch+0x490/0xc73
> > [0.00]  [] ? printk+0x4d/0x4f
> > [0.00]  [] start_kernel+0x9c/0x43f
> > [0.00]  [] ? early_idt_handlers+0x120/0x120
> > [0.00]  [] x86_64_start_reservations+0x2a/0x2c
> > [0.00]  [] x86_64_start_kernel+0x13b/0x14a
> > [0.00] RIP 0x4
> >
> 
> This is most puzzling. Could anyone decode the exception?
> This looks like the non-EFI path through dmi_scan_machine(), which
> calls dmi_present() /after/ calling dmi_smbios3_present(), which
> apparently has not found the _SM3_ header tag. Or could the call stack
> be inaccurate?
> 
> Anyway, it would be good to know the exact type of the platform,

It's a Nehalem-EP machine, wht 16 CPU and 12G memory.

> and
> perhaps we could find out if there is an inadvertent _SM3_ tag
> somewhere in the 0xF - 0xF range?

Sorry, how?

--yliu
--
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 v6 00/29] nios2 Linux kernel port

2014-11-06 Thread LF.Tan
On Mon, Nov 3, 2014 at 6:51 PM, Ley Foon Tan  wrote:
>
> This is the 6th version of patchset adds the Linux kernel port for Nios II
> processor from Altera. All of the feedback from v5 patchseries has been
> addressed. Note, only patch #1, #7 and #21 have non-trivial changes.
> Thanks to all who provided feedback on the previous version.
>
> About Nios II Cores
> ---
> Nios II is a 32-bit embedded-processor architecture designed specifically for 
> the
> Altera family of FPGAs.
> More information is available  at 
> http://www.altera.com/devices/processor/nios2/ni2-index.html
>
> Instruction set and architecture overview documents can be found on the
> following page:
> http://www.altera.com/literature/lit-nio2.jsp
>
> Nios2 GCC port is in mainline and will be in the FSF 4.9 release.
>
> The patchset are based on v3.18-rc3 and can also be found in the following 
> git tree:
> git://git.rocketboards.org/linux-socfpga-next.git  nios2-upstream
>

Hi Stephen

Review for Nios2 port is completed and ready for upstream. Can you
please add nios2 patchset to linux-next?
Thanks.


The following changes since commit 0df1f2487d2f0d04703f142813d53615d62a1da4:

  Linux 3.18-rc3 (2014-11-02 15:01:51 -0800)

are available in the git repository at:

  http://git.rocketboards.org/linux-socfpga-next.git tags/nios2-for-linux-next

for you to fetch changes up to 1b9e67a57ac633f407de11b36d8f996c368a8c66:

  nios2: Build infrastructure (2014-11-06 15:23:37 +0800)


Regards
Ley Foon
--
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] mm/debug-pagealloc: correct freepage accounting and order resetting

2014-11-06 Thread Joonsoo Kim
One thing, I did in this patch, is fixing freepage accounting.
If we clear guard page and link it onto isolate buddy list, we should
not increase freepage count. This patch adds conditional branch to
skip counting in this case. Without this patch, this overcounting
happens frequently if guard order is set and CMA is used.

Another thing fixed in this patch is the target to reset order. In
__free_one_page(), we check the buddy page whether it is a guard page or
not. And, if so, we should clear guard attribute on the buddy page and
reset order of it to 0. But, current code resets original page's order
rather than buddy one's. Maybe, this doesn't have any problem, because
whole merged page's order will be re-assigned soon. But, it is better
to correct code.

Changes from v2:
Rename subject from
"mm/page_alloc: correct to clear guard attribute in DEBUG_PAGEALLOC"
to
"mm/debug-pagealloc: correct freepage accounting and order resetting".
Separate fix and clean-up part.

Cc: 
Acked-by: Vlastimil Babka 
Signed-off-by: Joonsoo Kim 
---
 mm/page_alloc.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e78e3c8..d673f64 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -583,9 +583,11 @@ static inline void __free_one_page(struct page *page,
 */
if (page_is_guard(buddy)) {
clear_page_guard_flag(buddy);
-   set_page_private(page, 0);
-   __mod_zone_freepage_state(zone, 1 << order,
- migratetype);
+   set_page_private(buddy, 0);
+   if (!is_migrate_isolate(migratetype)) {
+   __mod_zone_freepage_state(zone, 1 << order,
+ migratetype);
+   }
} else {
list_del(>lru);
zone->free_area[order].nr_free--;
-- 
1.7.9.5

--
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] mm/debug-pagealloc: cleanup page guard code

2014-11-06 Thread Joonsoo Kim
Page guard is used by debug-pagealloc feature. Currently,
it is open-coded, but, I think that more abstraction of it makes
core page allocator code more readable.

There is no functional difference.

Signed-off-by: Joonsoo Kim 
---
 mm/page_alloc.c |   38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index d673f64..c0dbede 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -440,18 +440,29 @@ static int __init debug_guardpage_minorder_setup(char 
*buf)
 }
 __setup("debug_guardpage_minorder=", debug_guardpage_minorder_setup);
 
-static inline void set_page_guard_flag(struct page *page)
+static inline void set_page_guard(struct zone *zone, struct page *page,
+   unsigned int order, int migratetype)
 {
__set_bit(PAGE_DEBUG_FLAG_GUARD, >debug_flags);
+   INIT_LIST_HEAD(>lru);
+   set_page_private(page, order);
+   /* Guard pages are not available for any usage */
+   __mod_zone_freepage_state(zone, -(1 << order), migratetype);
 }
 
-static inline void clear_page_guard_flag(struct page *page)
+static inline void clear_page_guard(struct zone *zone, struct page *page,
+   unsigned int order, int migratetype)
 {
__clear_bit(PAGE_DEBUG_FLAG_GUARD, >debug_flags);
+   set_page_private(page, 0);
+   if (!is_migrate_isolate(migratetype))
+   __mod_zone_freepage_state(zone, (1 << order), migratetype);
 }
 #else
-static inline void set_page_guard_flag(struct page *page) { }
-static inline void clear_page_guard_flag(struct page *page) { }
+static inline void set_page_guard(struct zone *zone, struct page *page,
+   unsigned int order, int migratetype) {}
+static inline void clear_page_guard(struct zone *zone, struct page *page,
+   unsigned int order, int migratetype) {}
 #endif
 
 static inline void set_page_order(struct page *page, unsigned int order)
@@ -582,12 +593,7 @@ static inline void __free_one_page(struct page *page,
 * merge with it and move up one order.
 */
if (page_is_guard(buddy)) {
-   clear_page_guard_flag(buddy);
-   set_page_private(buddy, 0);
-   if (!is_migrate_isolate(migratetype)) {
-   __mod_zone_freepage_state(zone, 1 << order,
- migratetype);
-   }
+   clear_page_guard(zone, buddy, order, migratetype);
} else {
list_del(>lru);
zone->free_area[order].nr_free--;
@@ -862,23 +868,17 @@ static inline void expand(struct zone *zone, struct page 
*page,
size >>= 1;
VM_BUG_ON_PAGE(bad_range(zone, [size]), [size]);
 
-#ifdef CONFIG_DEBUG_PAGEALLOC
-   if (high < debug_guardpage_minorder()) {
+   if (IS_ENABLED(CONFIG_DEBUG_PAGEALLOC) &&
+   high < debug_guardpage_minorder()) {
/*
 * Mark as guard pages (or page), that will allow to
 * merge back to allocator when buddy will be freed.
 * Corresponding page table entries will not be touched,
 * pages will stay not present in virtual address space
 */
-   INIT_LIST_HEAD([size].lru);
-   set_page_guard_flag([size]);
-   set_page_private([size], high);
-   /* Guard pages are not available for any usage */
-   __mod_zone_freepage_state(zone, -(1 << high),
- migratetype);
+   set_page_guard(zone, [size], high, migratetype);
continue;
}
-#endif
list_add([size].lru, >free_list[migratetype]);
area->nr_free++;
set_page_order([size], high);
-- 
1.7.9.5

--
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: [LKP] [dmi] PANIC: early exception 0e rip 10:ffffffff81899e6b error 9 cr2 ffffffffff240000

2014-11-06 Thread Ard Biesheuvel
On 7 November 2014 06:47, LKP  wrote:
> FYI, we noticed the below changes on
>
> https://git.linaro.org/people/ard.biesheuvel/linux-arm efi-for-3.19
> commit aacdce6e880894acb57d71dcb2e3fc61b4ed4e96 ("dmi: add support for SMBIOS 
> 3.0 64-bit entry point")
>
>
> +---+++
> |   | 2fa165a26c | aacdce6e88 |
> +---+++
> | boot_successes| 20 | 10 |
> | early-boot-hang   | 1  ||
> | boot_failures | 0  | 5  |
> | PANIC:early_exception | 0  | 5  |
> +---+++
>
>
> [0.00] BIOS-e820: [mem 0x0001-0x00036fff] usable
> [0.00] bootconsole [earlyser0] enabled
> [0.00] NX (Execute Disable) protection: active
> PANIC: early exception 0e rip 10:81899e6b error 9 cr2 ff24
> [0.00] CPU: 0 PID: 0 Comm: swapper Not tainted 3.18.0-rc2-gc5221e6 #1
> [0.00]   82203d30 819f0a6e 
> 03f8
> [0.00]  ff24 82203e18 823701b0 
> 82511401
> [0.00]   0ba3  
> ff24
> [0.00] Call Trace:
> [0.00]  [] dump_stack+0x4e/0x68
> [0.00]  [] early_idt_handler+0x90/0xb7
> [0.00]  [] ? dmi_save_one_device+0x81/0x81
> [0.00]  [] ? dmi_table+0x3f/0x94
> [0.00]  [] ? dmi_table+0x16/0x94
> [0.00]  [] ? dmi_save_one_device+0x81/0x81
> [0.00]  [] ? dmi_save_one_device+0x81/0x81
> [0.00]  [] dmi_walk_early+0x44/0x69
> [0.00]  [] dmi_present+0x180/0x1ff
> [0.00]  [] dmi_scan_machine+0x144/0x191
> [0.00]  [] ? loglevel+0x31/0x31
> [0.00]  [] setup_arch+0x490/0xc73
> [0.00]  [] ? printk+0x4d/0x4f
> [0.00]  [] start_kernel+0x9c/0x43f
> [0.00]  [] ? early_idt_handlers+0x120/0x120
> [0.00]  [] x86_64_start_reservations+0x2a/0x2c
> [0.00]  [] x86_64_start_kernel+0x13b/0x14a
> [0.00] RIP 0x4
>

This is most puzzling. Could anyone decode the exception?
This looks like the non-EFI path through dmi_scan_machine(), which
calls dmi_present() /after/ calling dmi_smbios3_present(), which
apparently has not found the _SM3_ header tag. Or could the call stack
be inaccurate?

Anyway, it would be good to know the exact type of the platform, and
perhaps we could find out if there is an inadvertent _SM3_ tag
somewhere in the 0xF - 0xF range?

-- 
Ard.
--
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 v4] Add LTC2941/LTC2943 Battery Gauge Driver

2014-11-06 Thread Pavel Machek
Hi!

> +++ b/drivers/power/ltc2941-battery-gauge.c
> @@ -0,0 +1,547 @@
> +/*
> + * I2C client/driver for the Linear Technology LTC2941 and LTC2943
> + * Battery Gas Gauge IC
> + *
> + * Copyright (C) 2014 Topic Embedded Systems
> + *

NOrmally GPL notice would go here.

> + * Author: Auryn Verwegen
> + * Author: Mike Looijmans
> + */

Do you want to add yourself as a maintainers?

> +{
> + int ret;
> + struct i2c_msg msgs[2] = { };
> + u8 reg_start = reg;
> +
> + msgs[0].addr= client->addr;
> + msgs[0].len = 1;
> + msgs[0].buf = _start;
> +
> + msgs[1].addr= client->addr;
> + msgs[1].len = num_regs;
> + msgs[1].buf = buf;
> + msgs[1].flags   = I2C_M_RD;
> +
> + ret = i2c_transfer(client->adapter, [0], 2);

Here you send byte from kernel stack to i2c device. I'd add msg[0].flags = 0.

> + ret = ltc294x_write_regs(info->client,
> + LTC294X_REG_CONTROL, , 1);
> + if (ret < 0) {
> + dev_err(>client->dev,
> + "Could not write register\n");
> + goto error_exit;

return ret; No need to goto when you have nothing to clean up.

> + }
> + }
> +
> + return 0;
> +
> +error_exit:
> + return ret;
> +}

> + if (info->Qlsb < 0)
> + value += 0x;

q_lsb?

> + dataw[0] = I16_MSB(value);
> + dataw[1] = I16_LSB(value);
> + ret = ltc294x_write_regs(info->client,
> + LTC294X_REG_ACC_CHARGE_MSB, [0], 2);
> + if (ret < 0)
> + goto error_exit;
> + /* Enable analog section */
> +error_exit:

Interesting use of goto... remove?

> + ret = of_property_read_u32(np, "prescaler-exponent", _exp);
> + if (ret < 0) {
> + dev_err(>dev,
> + "PrescalerExponent not in devicetree, assume max\n");

assuming?

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.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: [PATCH 0/4] (CMA_AGGRESSIVE) Make CMA memory be more aggressive about allocation

2014-11-06 Thread Minchan Kim
Hello,

On Tue, Nov 04, 2014 at 10:29:59AM +0100, Vlastimil Babka wrote:
> On 11/04/2014 08:53 AM, Minchan Kim wrote:
> >Hello,
> >
> >On Wed, Oct 29, 2014 at 03:43:33PM +0100, Vlastimil Babka wrote:
> >>On 10/16/2014 10:55 AM, Laura Abbott wrote:
> >>
> >>Hi,
> >>
> >>did anyone try/suggest the following idea?
> >>
> >>- keep CMA as fallback to MOVABLE as is is now, i.e. non-agressive
> >>- when UNMOVABLE (RECLAIMABLE also?) allocation fails and CMA
> >>pageblocks have space, don't OOM immediately, but first try to
> >>migrate some MOVABLE pages to CMA pageblocks, to make space for the
> >>UNMOVABLE allocation in non-CMA pageblocks
> >>- this should keep CMA pageblocks free as long as possible and
> >>useful for CMA allocations, but without restricting the non-MOVABLE
> >>allocations even though there is free memory (but in CMA pageblocks)
> >>- the fact that a MOVABLE page could be successfully migrated to CMA
> >>pageblock, means it was not pinned or otherwise non-migratable, so
> >>there's a good chance it can be migrated back again if CMA
> >>pageblocks need to be used by CMA allocation
> >
> >I suggested exactly same idea long time ago.
> >
> >>- it's more complex, but I guess we have most of the necessary
> >>infrastructure in compaction already :)
> >
> >I agree but still, it doesn't solve reclaim problem(ie, VM doesn't
> >need to reclaim CMA pages when memory pressure of unmovable pages
> >happens). Of course, we could make VM be aware of that via introducing
> >new flag of __isolate_lru_page.
> 
> Well, if it relaims CMA pages, then it has to be followed by the
> migration. Is that better or worse than breaking LRU assumptions by
> reclaiming based on where the page is located? I thought this was
> basically what lumpy reclaim did, and it was removed.

It would work and it might cost for using for CMA because CMA already
can migrate/discard lots of pages, which will hurt LRU assumption.
However, I don't think it's optimal.

> 
> >However, I'd like to think CMA design from the beginning.
> >It made page allocation logic complicated, even very fragile as we
> >had recently and now we need to add new logics to migrate like you said.
> >As well, we need to fix reclaim path, too.
> >
> >It makes mm complicated day by day even though it doesn't do the role
> >enough well(ie, big latency and frequent allocation failure) so I really
> >want to stop making the mess bloated.
> 
> Yeah that would be great.
> 
> >Long time ago, when I saw Joonsoo's CMA agressive allocation patchset
> >(ie, roundrobin allocation between CMA and normal movable pages)
> >it was good to me at a first glance but it needs tweak of allocation
> >path and doesn't solve reclaim path, either. Yes, reclaim path could
> >be solved by another patch but I want to solve it altogether.
> >
> >At that time, I suggested big surgery to Joonsoo in offline that
> >let's move CMA allocation with movable zone allocation. With it,
> >we could make allocation/reclaim path simple but thing is we should
> 
> I'm not sure I understand enough from this. You want to introduce a
> movable zone instead of CMA pageblocks? But how to size it, resize
> it, would it be possible?

Why do we need to care of resizing?
All of CMA pages are reserved by using memblock during boot.
If we can set the zone size after that, maybe we don't need to
resize the zone.

> 
> >make VM be aware of overlapping MOVABLE zone which means some of pages
> >in the zone could be part of another zones but I think we already have
> >logics to handle it when I read comment in isolate_freepages so I think
> >the design should work.
> 
> Why would it overlap in the first place? Just because it wouldn't be
> sized on pageblock boundary? Or to make (re)sizing simpler? Yeah we
> could probably handle that, but it's not completely for free (you
> iterate over blocks/pages uselessly).

Reserved pages for CMA are spread over the system memory.
So zones could overlap each other so we need check that overlapping
like pageblock_pfn_to_page while we need to walk pfn in order.
It's not free but it would add the overhead pfn-order walking
like compaction, which is not hot path.

> 
> >A thing you guys might worry is bigger CMA latency because it makes
> >CMA memory usage ratio higher than the approach you mentioned but
> >anyone couldn't guarantee it once memory is fully utilized.
> >In addition, we have used fair zone allocator policy so it makes
> >round robin allocation automatically so I believe it should be way
> >to go.
> 
> Yeah maybe it could be simpler in the end. Although a new zone type
> could be a disturbing change, with some overhead to per-cpu
> structures etc. The allocations in that zone would be somewhat at
> disadvantage wrt LRU, as CMA allocation would mostly reclaim them
> instead of migrating away (assuming there wouldn't be so much spare
> space for migration as when CMA pageblocks are part of a much larger
> zone). But I guess the same could be said about the DMA zone...

What 

Re: N900 modem support in 3.18-rc1

2014-11-06 Thread Ivaylo Dimitrov



On  7.11.2014 01:01, Pali Rohár wrote:



For voice calls you need:
* kernel driver cmt-speech (or it has some new name)
* cmt-speech userspace library (communication with kernel)
* pulseaudio modules which are using that library

Freemangordon (Ivaylo Dimitrov, CCed) should know more about it,
specially about pulseaudio modules...



I have a patch for cmt-speech on top of nokia-modem driver living 
somewhere on my HDD, but I guess it is better Sebastian to make such a 
patch (Sebastian, no?).


About the pulseaudio stuff - we're still in process of REing it, so far 
there are 2 out of 3 closed Nokia modules ready 
(https://gitorious.org/pulseaudio-nokia), but the last one, which is the 
one used for voice calls is still not ready and will take it a while :).


Regards,
Ivo

--
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] ARM: dts: zynq: Enable PL clocks for Parallella

2014-11-06 Thread Michal Simek
On 11/06/2014 06:22 PM, Andreas Färber wrote:
> The Parallella board comes with a U-Boot bootloader that loads one of
> two predefined FPGA bitstreams before booting the kernel. Both define an
> AXI interface to the on-board Epiphany processor.
> 
> Enable clocks FCLK0..FCLK3 for the Programmable Logic by default.
> 
> Otherwise accessing, e.g., the ESYSRESET register freezes the board,
> as seen with the Epiphany SDK tools e-reset and e-hw-rev, using /dev/mem.
> 
> Cc:  # 3.17.x
> Signed-off-by: Andreas Färber 
> ---
>  Michal/Olof, please consider this trivial patch as a fix for 3.18.

Acked-by: Michal Simek 

Olof, Arnd: Can you please pick this directly?

Thanks,
Michal

--
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] n_tty: Add memory barrier to fix race condition in receive path

2014-11-06 Thread Christian Riesch
[sent again due to stupid HTML mail problems, sorry]

On Thu, Nov 6, 2014 at 11:54 PM, Måns Rullgård  wrote:
> Greg Kroah-Hartman  writes:
>
>> On Thu, Nov 06, 2014 at 10:12:54PM +, Måns Rullgård wrote:
>>> Greg Kroah-Hartman  writes:
>>>
>>> > On Thu, Nov 06, 2014 at 09:38:59PM +, Måns Rullgård wrote:
>>> >> Greg Kroah-Hartman  writes:
>>> >>
>>> >> > On Thu, Nov 06, 2014 at 09:01:36PM +, Måns Rullgård wrote:
>>> >> >> Greg Kroah-Hartman  writes:
>>> >> >>
>>> >> >> > On Thu, Nov 06, 2014 at 08:49:01PM +, Måns Rullgård wrote:
>>> >> >> >> Greg Kroah-Hartman  writes:
>>> >> >> >>
>>> >> >> >> > On Thu, Nov 06, 2014 at 12:39:59PM +0100, Christian Riesch wrote:
>>> >> >> >> >> The current implementation of put_tty_queue() causes a race 
>>> >> >> >> >> condition
>>> >> >> >> >> when re-arranged by the compiler.
>>> >> >> >> >>
>>> >> >> >> >> On my build with gcc 4.8.3, cross-compiling for ARM, the line
>>> >> >> >> >>
>>> >> >> >> >>  *read_buf_addr(ldata, ldata->read_head++) = c;
>>> >> >> >> >>
>>> >> >> >> >> was re-arranged by the compiler to something like
>>> >> >> >> >>
>>> >> >> >> >>  x = ldata->read_head
>>> >> >> >> >>  ldata->read_head++
>>> >> >> >> >>  *read_buf_addr(ldata, x) = c;
>>> >> >> >> >>
>>> >> >> >> >> which causes a race condition. Invalid data is read if data is 
>>> >> >> >> >> read
>>> >> >> >> >> before it is actually written to the read buffer.
>>> >> >> >> >
>>> >> >> >> > Really?  A compiler can rearange things like that and expect 
>>> >> >> >> > things to
>>> >> >> >> > actually work?  How is that valid?
>>> >> >> >>
>>> >> >> >> This is actually required by the C spec.  There is a sequence point
>>> >> >> >> before a function call, after the arguments have been evaluated.  
>>> >> >> >> Thus
>>> >> >> >> all side-effects, such as the post-increment, must be complete 
>>> >> >> >> before
>>> >> >> >> the function is called, just like in the example.
>>> >> >> >>
>>> >> >> >> There is no "re-arranging" here.  The code is simply wrong.
>>> >> >> >
>>> >> >> > Ah, ok, time to dig out the C spec...
>>> >> >> >
>>> >> >> > Anyway, because of this, no need for the wmb() calls, just 
>>> >> >> > rearrange the
>>> >> >> > logic and all should be good, right?  Christian, can you test that
>>> >> >> > instead?
>>> >> >>
>>> >> >> Weakly ordered SMP systems probably need some kind of barrier.  I 
>>> >> >> didn't
>>> >> >> look at it carefully.
>>> >> >
>>> >> > It shouldn't need a barier, as it is a sequence point with the function
>>> >> > call.  Well, it's an inline function, but that "shouldn't" matter here,
>>> >> > right?
>>> >>
>>> >> Sequence points say nothing about the order in which stores become
>>> >> visible to other CPUs.  That's why there are barrier instructions.
>>> >
>>> > Yes, but "order" matters.
>>> >
>>> > If I write code that does:
>>> >
>>> > 100x = ldata->read_head;
>>> > 101>read_head[x & SOME_VALUE] = y;
>>> > 102ldata->read_head++;
>>> >
>>> > the compiler can not reorder lines 102 and 101 just because it feels
>>> > like it, right?  Or is it time to go spend some reading of the C spec
>>> > again...
>>>
>>> The compiler can't.  The hardware can.  All the hardware promises is
>>> that at some unspecified time in the future, both memory locations will
>>> have the correct values.  Another CPU might see 'read_head' updated
>>> before it sees the corresponding data value.  A wmb() between the writes
>>> forces the CPU to complete preceding stores before it begins subsequent
>>> ones.
>>
>> Yes, sorry, I'm not talking about other CPUs and what they see, I'm
>> talking about the local one.  I'm not assuming that this is SMP "safe"
>> at all.  If it is supposed to be, then yes, we do have problems, but
>> there should be a lock _somewhere_ protecting this.
>
> Within the confines of a single CPU + memory, barriers are never needed.
> The moment another CPU or master-capable peripheral enters the mix,
> proper ordering must be enforced somehow.
>
> If the buffer is already protected by a lock of some kind, this will
> provide the necessary barriers, so nothing further is necessary.  If
> it's a lock-less design, there will need to be barriers somewhere.

It was changed to lock-less with 3.12 in commit
6d76bd2618535c581f1673047b8341fd291abc67 ("n_tty: Make N_TTY ldisc
receive
path lockless"). So I will try to read the memory barrier docs again.

Of course my little ARM system is no SMP system, but I guess this
should also be fixed for the SMP case, right?

Thanks,
Christian
--
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 V4 03/14] genirq: Generic chip: Allow irqchip drivers to override irq_reg_{readl,writel}

2014-11-06 Thread Kevin Cernekee
Currently, these I/O accessors always assume little endian 32-bit
registers (readl/writel).  On some systems the IRQ registers need to be
accessed in BE mode or using 16-bit loads/stores, so we will provide a
way to override the default behavior.

Signed-off-by: Kevin Cernekee 
---
 include/linux/irq.h | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index ed1135d..0fecd95 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -686,6 +686,8 @@ struct irq_chip_type {
  * struct irq_chip_generic - Generic irq chip data structure
  * @lock:  Lock to protect register and cache data access
  * @reg_base:  Register base address (virtual)
+ * @reg_readl: Alternate I/O accessor (defaults to readl if NULL)
+ * @reg_writel:Alternate I/O accessor (defaults to writel if 
NULL)
  * @irq_base:  Interrupt base nr for this chip
  * @irq_cnt:   Number of interrupts handled by this chip
  * @mask_cache:Cached mask register shared between all chip 
types
@@ -710,6 +712,8 @@ struct irq_chip_type {
 struct irq_chip_generic {
raw_spinlock_t  lock;
void __iomem*reg_base;
+   u32 (*reg_readl)(void __iomem *addr);
+   void(*reg_writel)(u32 val, void __iomem *addr);
unsigned intirq_base;
unsigned intirq_cnt;
u32 mask_cache;
@@ -818,13 +822,19 @@ static inline void irq_gc_unlock(struct irq_chip_generic 
*gc) { }
 static inline void irq_reg_writel(struct irq_chip_generic *gc,
  u32 val, int reg_offset)
 {
-   writel(val, gc->reg_base + reg_offset);
+   if (gc->reg_writel)
+   gc->reg_writel(val, gc->reg_base + reg_offset);
+   else
+   writel(val, gc->reg_base + reg_offset);
 }
 
 static inline u32 irq_reg_readl(struct irq_chip_generic *gc,
int reg_offset)
 {
-   return readl(gc->reg_base + reg_offset);
+   if (gc->reg_readl)
+   return gc->reg_readl(gc->reg_base + reg_offset);
+   else
+   return readl(gc->reg_base + reg_offset);
 }
 
 #endif /* _LINUX_IRQ_H */
-- 
2.1.1

--
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 V4 04/14] genirq: Generic chip: Add big endian I/O accessors

2014-11-06 Thread Kevin Cernekee
Use io{read,write}32be if the caller specified IRQ_GC_BE_IO when creating
the irqchip.

Signed-off-by: Kevin Cernekee 
---
 include/linux/irq.h   |  2 ++
 kernel/irq/generic-chip.c | 16 
 2 files changed, 18 insertions(+)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 0fecd95..8588e5e 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -738,12 +738,14 @@ struct irq_chip_generic {
  * the parent irq. Usually GPIO implementations
  * @IRQ_GC_MASK_CACHE_PER_TYPE:Mask cache is chip type private
  * @IRQ_GC_NO_MASK:Do not calculate irq_data->mask
+ * @IRQ_GC_BE_IO:  Use big-endian register accesses (default: LE)
  */
 enum irq_gc_flags {
IRQ_GC_INIT_MASK_CACHE  = 1 << 0,
IRQ_GC_INIT_NESTED_LOCK = 1 << 1,
IRQ_GC_MASK_CACHE_PER_TYPE  = 1 << 2,
IRQ_GC_NO_MASK  = 1 << 3,
+   IRQ_GC_BE_IO= 1 << 4,
 };
 
 /*
diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index db458c6..61024e8 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -191,6 +191,16 @@ int irq_gc_set_wake(struct irq_data *d, unsigned int on)
return 0;
 }
 
+static u32 irq_readl_be(void __iomem *addr)
+{
+   return ioread32be(addr);
+}
+
+static void irq_writel_be(u32 val, void __iomem *addr)
+{
+   iowrite32be(val, addr);
+}
+
 static void
 irq_init_generic_chip(struct irq_chip_generic *gc, const char *name,
  int num_ct, unsigned int irq_base,
@@ -300,7 +310,13 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, 
int irqs_per_chip,
dgc->gc[i] = gc = tmp;
irq_init_generic_chip(gc, name, num_ct, i * irqs_per_chip,
  NULL, handler);
+
gc->domain = d;
+   if (gcflags & IRQ_GC_BE_IO) {
+   gc->reg_readl = _readl_be;
+   gc->reg_writel = _writel_be;
+   }
+
raw_spin_lock_irqsave(_lock, flags);
list_add_tail(>list, _list);
raw_spin_unlock_irqrestore(_lock, flags);
-- 
2.1.1

--
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 V4 01/14] sh: Eliminate unused irq_reg_{readl,writel} accessors

2014-11-06 Thread Kevin Cernekee
Defining these macros way down in arch/sh/.../irq.c doesn't cause
kernel/irq/generic-chip.c to use them.  As far as I can tell this code
has no effect.

Signed-off-by: Kevin Cernekee 
---
 arch/sh/boards/mach-se/7343/irq.c | 3 ---
 arch/sh/boards/mach-se/7722/irq.c | 3 ---
 2 files changed, 6 deletions(-)

diff --git a/arch/sh/boards/mach-se/7343/irq.c 
b/arch/sh/boards/mach-se/7343/irq.c
index 7646bf0..1087dba 100644
--- a/arch/sh/boards/mach-se/7343/irq.c
+++ b/arch/sh/boards/mach-se/7343/irq.c
@@ -14,9 +14,6 @@
 #define DRV_NAME "SE7343-FPGA"
 #define pr_fmt(fmt) DRV_NAME ": " fmt
 
-#define irq_reg_readl  ioread16
-#define irq_reg_writel iowrite16
-
 #include 
 #include 
 #include 
diff --git a/arch/sh/boards/mach-se/7722/irq.c 
b/arch/sh/boards/mach-se/7722/irq.c
index f5e2af1..00e6992 100644
--- a/arch/sh/boards/mach-se/7722/irq.c
+++ b/arch/sh/boards/mach-se/7722/irq.c
@@ -11,9 +11,6 @@
 #define DRV_NAME "SE7722-FPGA"
 #define pr_fmt(fmt) DRV_NAME ": " fmt
 
-#define irq_reg_readl  ioread16
-#define irq_reg_writel iowrite16
-
 #include 
 #include 
 #include 
-- 
2.1.1

--
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: netfilter: nf_conntrack: there maybe a bug in __nf_conntrack_confirm, when it race against get_next_corpse

2014-11-06 Thread Bill Bonaparte

On Tue, 6 Nov 2014 21:01:00 
"Jesper"  wrote:
>There is several issues with your submission.  I'll take care of
resubmitting a patch in your name (so you will get credit in the git log).
>
>If you care to know, issues are:
>1. you are not sending to the appropriate mailing lists,  2. patch is as an
attachment (should be inlined),  3. the patch have style and white-space
issues.

Thanks, Jesper. This is my first time to submit a patch, not know much about
the rules.  I will get it soon.

>> if there is a race at operating ct->status, there will be in 
>> alternative
>> case:
>> 1) IPS_DYING bit which set in get_next_corpse override other bits (e.g.
>> IPS_SRC_NAT_DONE_BIT), or
>> 2) other bits (e.g. IPS_SRC_NAT_DONE_BIT) which set in 
>> nf_nat_setup_info override IPS_DYING bit.

> Notice the set_bit() is atomic, so we don't have these issues (of bits
getting overridden).

In most cases, we do the atomic operation on ct->status (with set_bit), but
in function nf_nat_setup_info, we
assume that unconfirmed ct is always holded by current cpu, and has no race
against other cpus, so we don't
use set_bit.  
the following code is extracted from the nf_nat_setup_info:
/* Non-atomic: we own this at the moment. */
  if (maniptype == NF_NAT_MANIP_SRC)
ct->status |= IPS_SRC_NAT;
  else
ct->status |= IPS_DST_NAT;

--
Best regards,
  Bill Bonaparte


--
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 V4 08/14] irqchip: bcm7120-l2: Make sure all register accesses use base+offset

2014-11-06 Thread Kevin Cernekee
A couple of accesses to IRQEN (base+0x00) just used "base" directly, so
they would break if IRQEN ever became nonzero.  Make sure that all
reads/writes specify the register offset constant.

Signed-off-by: Kevin Cernekee 
Acked-by: Florian Fainelli 
---
 drivers/irqchip/irq-bcm7120-l2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-bcm7120-l2.c b/drivers/irqchip/irq-bcm7120-l2.c
index 7086fe0..22d3fa1 100644
--- a/drivers/irqchip/irq-bcm7120-l2.c
+++ b/drivers/irqchip/irq-bcm7120-l2.c
@@ -66,10 +66,10 @@ static void bcm7120_l2_intc_suspend(struct irq_data *d)
 
irq_gc_lock(gc);
/* Save the current mask and the interrupt forward mask */
-   b->saved_mask = __raw_readl(b->base) | b->irq_fwd_mask;
+   b->saved_mask = __raw_readl(b->base + IRQEN) | b->irq_fwd_mask;
if (b->can_wake) {
reg = b->saved_mask | gc->wake_active;
-   __raw_writel(reg, b->base);
+   __raw_writel(reg, b->base + IRQEN);
}
irq_gc_unlock(gc);
 }
@@ -81,7 +81,7 @@ static void bcm7120_l2_intc_resume(struct irq_data *d)
 
/* Restore the saved mask */
irq_gc_lock(gc);
-   __raw_writel(b->saved_mask, b->base);
+   __raw_writel(b->saved_mask, b->base + IRQEN);
irq_gc_unlock(gc);
 }
 
-- 
2.1.1

--
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 V4 12/14] irqchip: bcm7120-l2: Decouple driver from brcmstb-l2

2014-11-06 Thread Kevin Cernekee
Some chips, such as BCM6328, only require bcm7120-l2.  Some BCM7xxx STB
configurations only require brcmstb-l2.  Treat them as two separate
entities, and update the mach-bcm dependencies to reflect the change.

Signed-off-by: Kevin Cernekee 
Acked-by: Arnd Bergmann 
Acked-by: Florian Fainelli 
---
 arch/arm/mach-bcm/Kconfig| 1 +
 drivers/irqchip/Kconfig  | 5 +
 drivers/irqchip/Makefile | 4 ++--
 drivers/irqchip/irq-bcm7120-l2.c | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig
index 2abad74..bf47eb0 100644
--- a/arch/arm/mach-bcm/Kconfig
+++ b/arch/arm/mach-bcm/Kconfig
@@ -125,6 +125,7 @@ config ARCH_BRCMSTB
select HAVE_ARM_ARCH_TIMER
select BRCMSTB_GISB_ARB
select BRCMSTB_L2_IRQ
+   select BCM7120_L2_IRQ
help
  Say Y if you intend to run the kernel on a Broadcom ARM-based STB
  chipset.
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 09c79d1..afdc1f3 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -48,6 +48,11 @@ config ATMEL_AIC5_IRQ
select MULTI_IRQ_HANDLER
select SPARSE_IRQ
 
+config BCM7120_L2_IRQ
+   bool
+   select GENERIC_IRQ_CHIP
+   select IRQ_DOMAIN
+
 config BRCMSTB_L2_IRQ
bool
select GENERIC_IRQ_CHIP
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 173bb5f..f0909d0 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -35,6 +35,6 @@ obj-$(CONFIG_TB10X_IRQC)  += irq-tb10x.o
 obj-$(CONFIG_XTENSA)   += irq-xtensa-pic.o
 obj-$(CONFIG_XTENSA_MX)+= irq-xtensa-mx.o
 obj-$(CONFIG_IRQ_CROSSBAR) += irq-crossbar.o
-obj-$(CONFIG_BRCMSTB_L2_IRQ)   += irq-brcmstb-l2.o \
-  irq-bcm7120-l2.o
+obj-$(CONFIG_BCM7120_L2_IRQ)   += irq-bcm7120-l2.o
+obj-$(CONFIG_BRCMSTB_L2_IRQ)   += irq-brcmstb-l2.o
 obj-$(CONFIG_KEYSTONE_IRQ) += irq-keystone.o
diff --git a/drivers/irqchip/irq-bcm7120-l2.c b/drivers/irqchip/irq-bcm7120-l2.c
index ef4d32c..e53a3a6 100644
--- a/drivers/irqchip/irq-bcm7120-l2.c
+++ b/drivers/irqchip/irq-bcm7120-l2.c
@@ -247,5 +247,5 @@ out_unmap:
kfree(data);
return ret;
 }
-IRQCHIP_DECLARE(brcmstb_l2_intc, "brcm,bcm7120-l2-intc",
+IRQCHIP_DECLARE(bcm7120_l2_intc, "brcm,bcm7120-l2-intc",
bcm7120_l2_intc_of_init);
-- 
2.1.1

--
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 V4 05/14] irqchip: brcmstb-l2: Eliminate dependency on ARM code

2014-11-06 Thread Kevin Cernekee
The irq-brcmstb-l2 driver has a single dependency on the ARM code, the
do_bad_IRQ macro.  Expand this macro in-place so that the driver can be
built on non-ARM platforms.

Signed-off-by: Kevin Cernekee 
Acked-by: Arnd Bergmann 
Acked-by: Florian Fainelli 
---
 drivers/irqchip/irq-brcmstb-l2.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c
index c15c840..c9bdf20 100644
--- a/drivers/irqchip/irq-brcmstb-l2.c
+++ b/drivers/irqchip/irq-brcmstb-l2.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -30,8 +31,6 @@
 #include 
 #include 
 
-#include 
-
 #include "irqchip.h"
 
 /* Register offsets in the L2 interrupt controller */
@@ -63,7 +62,9 @@ static void brcmstb_l2_intc_irq_handle(unsigned int irq, 
struct irq_desc *desc)
~(__raw_readl(b->base + CPU_MASK_STATUS));
 
if (status == 0) {
-   do_bad_IRQ(irq, desc);
+   raw_spin_lock(>lock);
+   handle_bad_irq(irq, desc);
+   raw_spin_unlock(>lock);
goto out;
}
 
-- 
2.1.1

--
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 V4 09/14] irqchip: bcm7120-l2: Fix missing nibble in gc->unused mask

2014-11-06 Thread Kevin Cernekee
This mask should have been 0x_, not 0x0fff_.

The change should not have an effect on current users (STB) because bits
31:27 are unused.

Signed-off-by: Kevin Cernekee 
Acked-by: Arnd Bergmann 
Acked-by: Florian Fainelli 
---
 drivers/irqchip/irq-bcm7120-l2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-bcm7120-l2.c b/drivers/irqchip/irq-bcm7120-l2.c
index 22d3fa1..b70679f8 100644
--- a/drivers/irqchip/irq-bcm7120-l2.c
+++ b/drivers/irqchip/irq-bcm7120-l2.c
@@ -171,7 +171,7 @@ int __init bcm7120_l2_intc_of_init(struct device_node *dn,
}
 
gc = irq_get_domain_generic_chip(data->domain, 0);
-   gc->unused = 0xfff & ~data->irq_map_mask;
+   gc->unused = 0x & ~data->irq_map_mask;
gc->reg_base = data->base;
gc->private = data;
ct = gc->chip_types;
-- 
2.1.1

--
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 V4 06/14] irqchip: bcm7120-l2: Eliminate bad IRQ check

2014-11-06 Thread Kevin Cernekee
This check may be prone to race conditions, e.g.

1) Some external event (e.g. GPIO level) causes an IRQ to become pending
2) Peripheral asserts the L2 IRQ
3) CPU takes an interrupt
4) The event from #1 goes away
5) bcm7120_l2_intc_irq_handle() reads back a 0 status

Unlike the hardware supported by brcmstb-l2, the bcm7120-l2 controller
does not latch the IRQ status.  Bits can change if the inputs to the
controller change.  Also, do_bad_IRQ() is an ARM-specific macro.

So let's just nuke it.

Signed-off-by: Kevin Cernekee 
Acked-by: Florian Fainelli 
---
 drivers/irqchip/irq-bcm7120-l2.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/irqchip/irq-bcm7120-l2.c b/drivers/irqchip/irq-bcm7120-l2.c
index b9f4fb8..7086fe0 100644
--- a/drivers/irqchip/irq-bcm7120-l2.c
+++ b/drivers/irqchip/irq-bcm7120-l2.c
@@ -27,8 +27,6 @@
 
 #include "irqchip.h"
 
-#include 
-
 /* Register offset in the L2 interrupt controller */
 #define IRQEN  0x00
 #define IRQSTAT0x04
@@ -51,19 +49,12 @@ static void bcm7120_l2_intc_irq_handle(unsigned int irq, 
struct irq_desc *desc)
chained_irq_enter(chip, desc);
 
status = __raw_readl(b->base + IRQSTAT);
-
-   if (status == 0) {
-   do_bad_IRQ(irq, desc);
-   goto out;
-   }
-
-   do {
+   while (status) {
irq = ffs(status) - 1;
status &= ~(1 << irq);
generic_handle_irq(irq_find_mapping(b->domain, irq));
-   } while (status);
+   }
 
-out:
chained_irq_exit(chip, desc);
 }
 
-- 
2.1.1

--
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 V4 11/14] irqchip: bcm7120-l2: Extend driver to support 64+ bit controllers

2014-11-06 Thread Kevin Cernekee
Most implementations of the bcm7120-l2 controller only have a single
32-bit enable word + 32-bit status word.  But some instances have added
more enable/status pairs in order to support 64+ IRQs (which are all
ORed into one parent IRQ input).  Make the following changes to allow
the driver to support this:

 - Extend DT bindings so that multiple words can be specified for the
   reg property, various masks, etc.

 - Add loops to the probe/handle functions to deal with each word
   separately

 - Allocate 1 generic-chip for every 32 IRQs, so we can still use the
   clr/set helper functions

 - Update the documentation

This uses one domain per bcm7120-l2 DT node.  If the DT node defines
multiple enable/status pairs (i.e. >=64 IRQs) then the driver will
create a single IRQ domain with 2+ generic chips.  Multiple generic chips
are required because the generic-chip code can only handle one
enable/status register pair per instance.

Signed-off-by: Kevin Cernekee 
---
 .../interrupt-controller/brcm,bcm7120-l2-intc.txt  |  26 ++--
 drivers/irqchip/irq-bcm7120-l2.c   | 144 ++---
 2 files changed, 113 insertions(+), 57 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7120-l2-intc.txt
 
b/Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7120-l2-intc.txt
index ff812a8..bae1f21 100644
--- 
a/Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7120-l2-intc.txt
+++ 
b/Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7120-l2-intc.txt
@@ -13,7 +13,12 @@ Such an interrupt controller has the following hardware 
design:
   or if they will output an interrupt signal at this 2nd level interrupt
   controller, in particular for UARTs
 
-- not all 32-bits within the interrupt controller actually map to an interrupt
+- typically has one 32-bit enable word and one 32-bit status word, but on
+  some hardware may have more than one enable/status pair
+
+- no atomic set/clear operations
+
+- not all bits within the interrupt controller actually map to an interrupt
 
 The typical hardware layout for this controller is represented below:
 
@@ -48,7 +53,9 @@ The typical hardware layout for this controller is 
represented below:
 Required properties:
 
 - compatible: should be "brcm,bcm7120-l2-intc"
-- reg: specifies the base physical address and size of the registers
+- reg: specifies the base physical address and size of the registers;
+  multiple pairs may be specified, with the first pair handling IRQ offsets
+  0..31 and the second pair handling 32..63
 - interrupt-controller: identifies the node as an interrupt controller
 - #interrupt-cells: specifies the number of cells needed to encode an interrupt
   source, should be 1.
@@ -59,18 +66,21 @@ Required properties:
 - brcm,int-map-mask: 32-bits bit mask describing how many and which interrupts
   are wired to this 2nd level interrupt controller, and how they match their
   respective interrupt parents. Should match exactly the number of interrupts
-  specified in the 'interrupts' property.
+  specified in the 'interrupts' property, multiplied by the number of
+  enable/status register pairs implemented by this controller.  For
+  multiple parent IRQs with multiple enable/status words, this looks like:
+  
 
 Optional properties:
 
 - brcm,irq-can-wake: if present, this means the L2 controller can be used as a
   wakeup source for system suspend/resume.
 
-- brcm,int-fwd-mask: if present, a 32-bits bit mask to configure for the
-  interrupts which have a mux gate, typically UARTs. Setting these bits will
-  make their respective interrupts outputs bypass this 2nd level interrupt
-  controller completely, it completely transparent for the interrupt controller
-  parent
+- brcm,int-fwd-mask: if present, a bit mask to configure the interrupts which
+  have a mux gate, typically UARTs. Setting these bits will make their
+  respective interrupt outputs bypass this 2nd level interrupt controller
+  completely; it is completely transparent for the interrupt controller
+  parent. This should have one 32-bit word per enable/status pair.
 
 Example:
 
diff --git a/drivers/irqchip/irq-bcm7120-l2.c b/drivers/irqchip/irq-bcm7120-l2.c
index 9841121..ef4d32c 100644
--- a/drivers/irqchip/irq-bcm7120-l2.c
+++ b/drivers/irqchip/irq-bcm7120-l2.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "irqchip.h"
@@ -31,27 +32,42 @@
 #define IRQEN  0x00
 #define IRQSTAT0x04
 
+#define MAX_WORDS  4
+#define IRQS_PER_WORD  32
+
 struct bcm7120_l2_intc_data {
-   void __iomem *base;
+   unsigned int n_words;
+   void __iomem *base[MAX_WORDS];
struct irq_domain *domain;
bool can_wake;
-   u32 irq_fwd_mask;
-   u32 irq_map_mask;
+   u32 irq_fwd_mask[MAX_WORDS];
+   u32 irq_map_mask[MAX_WORDS];
 };
 
 static void bcm7120_l2_intc_irq_handle(unsigned int irq, struct irq_desc *desc)
 {
struct 

[PATCH V4 07/14] irqchip: bcm7120-l2, brcmstb-l2: Remove ARM Kconfig dependency

2014-11-06 Thread Kevin Cernekee
This can compile for MIPS (or anything else) now.

Signed-off-by: Kevin Cernekee 
Acked-by: Arnd Bergmann 
Acked-by: Florian Fainelli 
---
 drivers/irqchip/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index b21f12f..09c79d1 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -50,7 +50,6 @@ config ATMEL_AIC5_IRQ
 
 config BRCMSTB_L2_IRQ
bool
-   depends on ARM
select GENERIC_IRQ_CHIP
select IRQ_DOMAIN
 
-- 
2.1.1

--
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 V4 14/14] irqchip: brcmstb-l2: Convert driver to use irq_reg_{readl,writel}

2014-11-06 Thread Kevin Cernekee
This effectively converts the __raw_ accessors to the non-__raw_
equivalents.  To handle BE, we pass IRQ_GC_BE_IO, similar to what was
done in irq-bcm7120-l2.c.

Since irq_reg_writel now takes an irq_chip_generic argument, writel must
be used for the initial hardware reset in the probe function.  But that
operation never needs endian swapping, so it's probably not a big deal.

Signed-off-by: Kevin Cernekee 
---
 drivers/irqchip/irq-brcmstb-l2.c | 34 ++
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c
index c9bdf20..4aa653a 100644
--- a/drivers/irqchip/irq-brcmstb-l2.c
+++ b/drivers/irqchip/irq-brcmstb-l2.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -53,13 +54,14 @@ struct brcmstb_l2_intc_data {
 static void brcmstb_l2_intc_irq_handle(unsigned int irq, struct irq_desc *desc)
 {
struct brcmstb_l2_intc_data *b = irq_desc_get_handler_data(desc);
+   struct irq_chip_generic *gc = irq_get_domain_generic_chip(b->domain, 0);
struct irq_chip *chip = irq_desc_get_chip(desc);
u32 status;
 
chained_irq_enter(chip, desc);
 
-   status = __raw_readl(b->base + CPU_STATUS) &
-   ~(__raw_readl(b->base + CPU_MASK_STATUS));
+   status = irq_reg_readl(gc, CPU_STATUS) &
+   ~(irq_reg_readl(gc, CPU_MASK_STATUS));
 
if (status == 0) {
raw_spin_lock(>lock);
@@ -71,7 +73,7 @@ static void brcmstb_l2_intc_irq_handle(unsigned int irq, 
struct irq_desc *desc)
do {
irq = ffs(status) - 1;
/* ack at our level */
-   __raw_writel(1 << irq, b->base + CPU_CLEAR);
+   irq_reg_writel(gc, 1 << irq, CPU_CLEAR);
status &= ~(1 << irq);
generic_handle_irq(irq_find_mapping(b->domain, irq));
} while (status);
@@ -86,12 +88,12 @@ static void brcmstb_l2_intc_suspend(struct irq_data *d)
 
irq_gc_lock(gc);
/* Save the current mask */
-   b->saved_mask = __raw_readl(b->base + CPU_MASK_STATUS);
+   b->saved_mask = irq_reg_readl(gc, CPU_MASK_STATUS);
 
if (b->can_wake) {
/* Program the wakeup mask */
-   __raw_writel(~gc->wake_active, b->base + CPU_MASK_SET);
-   __raw_writel(gc->wake_active, b->base + CPU_MASK_CLEAR);
+   irq_reg_writel(gc, ~gc->wake_active, CPU_MASK_SET);
+   irq_reg_writel(gc, gc->wake_active, CPU_MASK_CLEAR);
}
irq_gc_unlock(gc);
 }
@@ -103,11 +105,11 @@ static void brcmstb_l2_intc_resume(struct irq_data *d)
 
irq_gc_lock(gc);
/* Clear unmasked non-wakeup interrupts */
-   __raw_writel(~b->saved_mask & ~gc->wake_active, b->base + CPU_CLEAR);
+   irq_reg_writel(gc, ~b->saved_mask & ~gc->wake_active, CPU_CLEAR);
 
/* Restore the saved mask */
-   __raw_writel(b->saved_mask, b->base + CPU_MASK_SET);
-   __raw_writel(~b->saved_mask, b->base + CPU_MASK_CLEAR);
+   irq_reg_writel(gc, b->saved_mask, CPU_MASK_SET);
+   irq_reg_writel(gc, ~b->saved_mask, CPU_MASK_CLEAR);
irq_gc_unlock(gc);
 }
 
@@ -119,6 +121,7 @@ int __init brcmstb_l2_intc_of_init(struct device_node *np,
struct irq_chip_generic *gc;
struct irq_chip_type *ct;
int ret;
+   unsigned int flags;
 
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
@@ -132,8 +135,8 @@ int __init brcmstb_l2_intc_of_init(struct device_node *np,
}
 
/* Disable all interrupts by default */
-   __raw_writel(0x, data->base + CPU_MASK_SET);
-   __raw_writel(0x, data->base + CPU_CLEAR);
+   writel(0x, data->base + CPU_MASK_SET);
+   writel(0x, data->base + CPU_CLEAR);
 
data->parent_irq = irq_of_parse_and_map(np, 0);
if (data->parent_irq < 0) {
@@ -149,9 +152,16 @@ int __init brcmstb_l2_intc_of_init(struct device_node *np,
goto out_unmap;
}
 
+   /* MIPS chips strapped for BE will automagically configure the
+* peripheral registers for CPU-native byte order.
+*/
+   flags = 0;
+   if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
+   flags |= IRQ_GC_BE_IO;
+
/* Allocate a single Generic IRQ chip for this node */
ret = irq_alloc_domain_generic_chips(data->domain, 32, 1,
-   np->full_name, handle_edge_irq, clr, 0, 0);
+   np->full_name, handle_edge_irq, clr, 0, flags);
if (ret) {
pr_err("failed to allocate generic irq chip\n");
goto out_free_domain;
-- 
2.1.1

--
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 

[PATCH V4 10/14] irqchip: bcm7120-l2: Use gc->mask_cache to simplify suspend/resume functions

2014-11-06 Thread Kevin Cernekee
The cached value already incorporates irq_fwd_mask, and was saved the
last time an IRQ was enabled/disabled.

Signed-off-by: Kevin Cernekee 
Acked-by: Florian Fainelli 
---
 drivers/irqchip/irq-bcm7120-l2.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/irqchip/irq-bcm7120-l2.c b/drivers/irqchip/irq-bcm7120-l2.c
index b70679f8..9841121 100644
--- a/drivers/irqchip/irq-bcm7120-l2.c
+++ b/drivers/irqchip/irq-bcm7120-l2.c
@@ -37,7 +37,6 @@ struct bcm7120_l2_intc_data {
bool can_wake;
u32 irq_fwd_mask;
u32 irq_map_mask;
-   u32 saved_mask;
 };
 
 static void bcm7120_l2_intc_irq_handle(unsigned int irq, struct irq_desc *desc)
@@ -62,14 +61,11 @@ static void bcm7120_l2_intc_suspend(struct irq_data *d)
 {
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
struct bcm7120_l2_intc_data *b = gc->private;
-   u32 reg;
 
irq_gc_lock(gc);
-   /* Save the current mask and the interrupt forward mask */
-   b->saved_mask = __raw_readl(b->base + IRQEN) | b->irq_fwd_mask;
if (b->can_wake) {
-   reg = b->saved_mask | gc->wake_active;
-   __raw_writel(reg, b->base + IRQEN);
+   __raw_writel(gc->mask_cache | gc->wake_active,
+b->base + IRQEN);
}
irq_gc_unlock(gc);
 }
@@ -77,11 +73,10 @@ static void bcm7120_l2_intc_suspend(struct irq_data *d)
 static void bcm7120_l2_intc_resume(struct irq_data *d)
 {
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
-   struct bcm7120_l2_intc_data *b = gc->private;
 
/* Restore the saved mask */
irq_gc_lock(gc);
-   __raw_writel(b->saved_mask, b->base + IRQEN);
+   __raw_writel(gc->mask_cache, b->base + IRQEN);
irq_gc_unlock(gc);
 }
 
-- 
2.1.1

--
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 V4 13/14] irqchip: bcm7120-l2: Convert driver to use irq_reg_{readl,writel}

2014-11-06 Thread Kevin Cernekee
On BE MIPS systems this needs to use the new IRQ_GC_BE_IO gc_flag.  In
all other cases it will use the standard readl/writel accessors.

The initial irq_fwd_mask setup runs before "gc" is initialized, so it
is unchanged for now.  This could potentially be a problem on an ARM
system that boots in LE mode but runs a BE kernel, but currently none
of the supported ARM platforms are ever expected to run BE.

Signed-off-by: Kevin Cernekee 
---
 drivers/irqchip/irq-bcm7120-l2.c | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/irqchip/irq-bcm7120-l2.c b/drivers/irqchip/irq-bcm7120-l2.c
index e53a3a6..e7c6155 100644
--- a/drivers/irqchip/irq-bcm7120-l2.c
+++ b/drivers/irqchip/irq-bcm7120-l2.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -60,8 +61,7 @@ static void bcm7120_l2_intc_irq_handle(unsigned int irq, 
struct irq_desc *desc)
int hwirq;
 
irq_gc_lock(gc);
-   pending = __raw_readl(b->base[idx] + IRQSTAT) &
- gc->mask_cache;
+   pending = irq_reg_readl(gc, IRQSTAT) & gc->mask_cache;
irq_gc_unlock(gc);
 
for_each_set_bit(hwirq, , IRQS_PER_WORD) {
@@ -79,10 +79,8 @@ static void bcm7120_l2_intc_suspend(struct irq_data *d)
struct bcm7120_l2_intc_data *b = gc->private;
 
irq_gc_lock(gc);
-   if (b->can_wake) {
-   __raw_writel(gc->mask_cache | gc->wake_active,
-gc->reg_base + IRQEN);
-   }
+   if (b->can_wake)
+   irq_reg_writel(gc, gc->mask_cache | gc->wake_active, IRQEN);
irq_gc_unlock(gc);
 }
 
@@ -92,7 +90,7 @@ static void bcm7120_l2_intc_resume(struct irq_data *d)
 
/* Restore the saved mask */
irq_gc_lock(gc);
-   __raw_writel(gc->mask_cache, gc->reg_base + IRQEN);
+   irq_reg_writel(gc, gc->mask_cache, IRQEN);
irq_gc_unlock(gc);
 }
 
@@ -132,7 +130,7 @@ int __init bcm7120_l2_intc_of_init(struct device_node *dn,
const __be32 *map_mask;
int num_parent_irqs;
int ret = 0, len;
-   unsigned int idx, irq;
+   unsigned int idx, irq, flags;
 
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
@@ -195,9 +193,15 @@ int __init bcm7120_l2_intc_of_init(struct device_node *dn,
goto out_unmap;
}
 
+   /* MIPS chips strapped for BE will automagically configure the
+* peripheral registers for CPU-native byte order.
+*/
+   flags = IRQ_GC_INIT_MASK_CACHE;
+   if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
+   flags |= IRQ_GC_BE_IO;
+
ret = irq_alloc_domain_generic_chips(data->domain, IRQS_PER_WORD, 1,
-   dn->full_name, handle_level_irq, clr, 0,
-   IRQ_GC_INIT_MASK_CACHE);
+   dn->full_name, handle_level_irq, clr, 0, flags);
if (ret) {
pr_err("failed to allocate generic irq chip\n");
goto out_free_domain;
-- 
2.1.1

--
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 V4 02/14] genirq: Generic chip: Change irq_reg_{readl,writel} arguments

2014-11-06 Thread Kevin Cernekee
Pass in the irq_chip_generic struct so we can use different readl/writel
settings for each irqchip driver, when appropriate.  Compute
(gc->reg_base + reg_offset) in the helper function because this is pretty
much what all callers want to do anyway.

Compile-tested using the following configurations:

at91_dt_defconfig (CONFIG_ATMEL_AIC_IRQ=y)
sama5_defconfig (CONFIG_ATMEL_AIC5_IRQ=y)
sunxi_defconfig (CONFIG_ARCH_SUNXI=y)

tb10x (ARC) is untested.

Signed-off-by: Kevin Cernekee 
---
 drivers/irqchip/irq-atmel-aic.c  | 40 -
 drivers/irqchip/irq-atmel-aic5.c | 65 +++-
 drivers/irqchip/irq-sunxi-nmi.c  |  4 +--
 drivers/irqchip/irq-tb10x.c  |  4 +--
 include/linux/irq.h  | 20 -
 kernel/irq/generic-chip.c| 20 ++---
 6 files changed, 78 insertions(+), 75 deletions(-)

diff --git a/drivers/irqchip/irq-atmel-aic.c b/drivers/irqchip/irq-atmel-aic.c
index 9a2cf3c..27fdd8c 100644
--- a/drivers/irqchip/irq-atmel-aic.c
+++ b/drivers/irqchip/irq-atmel-aic.c
@@ -65,11 +65,11 @@ aic_handle(struct pt_regs *regs)
u32 irqnr;
u32 irqstat;
 
-   irqnr = irq_reg_readl(gc->reg_base + AT91_AIC_IVR);
-   irqstat = irq_reg_readl(gc->reg_base + AT91_AIC_ISR);
+   irqnr = irq_reg_readl(gc, AT91_AIC_IVR);
+   irqstat = irq_reg_readl(gc, AT91_AIC_ISR);
 
if (!irqstat)
-   irq_reg_writel(0, gc->reg_base + AT91_AIC_EOICR);
+   irq_reg_writel(gc, 0, AT91_AIC_EOICR);
else
handle_domain_irq(aic_domain, irqnr, regs);
 }
@@ -80,7 +80,7 @@ static int aic_retrigger(struct irq_data *d)
 
/* Enable interrupt on AIC5 */
irq_gc_lock(gc);
-   irq_reg_writel(d->mask, gc->reg_base + AT91_AIC_ISCR);
+   irq_reg_writel(gc, d->mask, AT91_AIC_ISCR);
irq_gc_unlock(gc);
 
return 0;
@@ -92,12 +92,12 @@ static int aic_set_type(struct irq_data *d, unsigned type)
unsigned int smr;
int ret;
 
-   smr = irq_reg_readl(gc->reg_base + AT91_AIC_SMR(d->hwirq));
+   smr = irq_reg_readl(gc, AT91_AIC_SMR(d->hwirq));
ret = aic_common_set_type(d, type, );
if (ret)
return ret;
 
-   irq_reg_writel(smr, gc->reg_base + AT91_AIC_SMR(d->hwirq));
+   irq_reg_writel(gc, smr, AT91_AIC_SMR(d->hwirq));
 
return 0;
 }
@@ -108,8 +108,8 @@ static void aic_suspend(struct irq_data *d)
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
 
irq_gc_lock(gc);
-   irq_reg_writel(gc->mask_cache, gc->reg_base + AT91_AIC_IDCR);
-   irq_reg_writel(gc->wake_active, gc->reg_base + AT91_AIC_IECR);
+   irq_reg_writel(gc, gc->mask_cache, AT91_AIC_IDCR);
+   irq_reg_writel(gc, gc->wake_active, AT91_AIC_IECR);
irq_gc_unlock(gc);
 }
 
@@ -118,8 +118,8 @@ static void aic_resume(struct irq_data *d)
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
 
irq_gc_lock(gc);
-   irq_reg_writel(gc->wake_active, gc->reg_base + AT91_AIC_IDCR);
-   irq_reg_writel(gc->mask_cache, gc->reg_base + AT91_AIC_IECR);
+   irq_reg_writel(gc, gc->wake_active, AT91_AIC_IDCR);
+   irq_reg_writel(gc, gc->mask_cache, AT91_AIC_IECR);
irq_gc_unlock(gc);
 }
 
@@ -128,8 +128,8 @@ static void aic_pm_shutdown(struct irq_data *d)
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
 
irq_gc_lock(gc);
-   irq_reg_writel(0x, gc->reg_base + AT91_AIC_IDCR);
-   irq_reg_writel(0x, gc->reg_base + AT91_AIC_ICCR);
+   irq_reg_writel(gc, 0x, AT91_AIC_IDCR);
+   irq_reg_writel(gc, 0x, AT91_AIC_ICCR);
irq_gc_unlock(gc);
 }
 #else
@@ -148,24 +148,24 @@ static void __init aic_hw_init(struct irq_domain *domain)
 * will not Lock out nIRQ
 */
for (i = 0; i < 8; i++)
-   irq_reg_writel(0, gc->reg_base + AT91_AIC_EOICR);
+   irq_reg_writel(gc, 0, AT91_AIC_EOICR);
 
/*
 * Spurious Interrupt ID in Spurious Vector Register.
 * When there is no current interrupt, the IRQ Vector Register
 * reads the value stored in AIC_SPU
 */
-   irq_reg_writel(0x, gc->reg_base + AT91_AIC_SPU);
+   irq_reg_writel(gc, 0x, AT91_AIC_SPU);
 
/* No debugging in AIC: Debug (Protect) Control Register */
-   irq_reg_writel(0, gc->reg_base + AT91_AIC_DCR);
+   irq_reg_writel(gc, 0, AT91_AIC_DCR);
 
/* Disable and clear all interrupts initially */
-   irq_reg_writel(0x, gc->reg_base + AT91_AIC_IDCR);
-   irq_reg_writel(0x, gc->reg_base + AT91_AIC_ICCR);
+   irq_reg_writel(gc, 0x, AT91_AIC_IDCR);
+   irq_reg_writel(gc, 0x, AT91_AIC_ICCR);
 
for (i = 0; i < 32; i++)
-   irq_reg_writel(i, gc->reg_base + AT91_AIC_SVR(i));
+   irq_reg_writel(gc, i, AT91_AIC_SVR(i));
 }
 
 static int 

[PATCH V4 00/14] genirq endian fixes; bcm7120/brcmstb IRQ updates

2014-11-06 Thread Kevin Cernekee
V3->V4:

 - Fix buildbot bisectability warning on patch 02/14 (missing include)

 - Add kernel-doc text for the new reg_{readl,writel} struct members and
   IRQ_GC_BE_IO flag


Kevin Cernekee (14):
  sh: Eliminate unused irq_reg_{readl,writel} accessors
  genirq: Generic chip: Change irq_reg_{readl,writel} arguments
  genirq: Generic chip: Allow irqchip drivers to override
irq_reg_{readl,writel}
  genirq: Generic chip: Add big endian I/O accessors
  irqchip: brcmstb-l2: Eliminate dependency on ARM code
  irqchip: bcm7120-l2: Eliminate bad IRQ check
  irqchip: bcm7120-l2, brcmstb-l2: Remove ARM Kconfig dependency
  irqchip: bcm7120-l2: Make sure all register accesses use base+offset
  irqchip: bcm7120-l2: Fix missing nibble in gc->unused mask
  irqchip: bcm7120-l2: Use gc->mask_cache to simplify suspend/resume
functions
  irqchip: bcm7120-l2: Extend driver to support 64+ bit controllers
  irqchip: bcm7120-l2: Decouple driver from brcmstb-l2
  irqchip: bcm7120-l2: Convert driver to use irq_reg_{readl,writel}
  irqchip: brcmstb-l2: Convert driver to use irq_reg_{readl,writel}

 .../interrupt-controller/brcm,bcm7120-l2-intc.txt  |  26 ++-
 arch/arm/mach-bcm/Kconfig  |   1 +
 arch/sh/boards/mach-se/7343/irq.c  |   3 -
 arch/sh/boards/mach-se/7722/irq.c  |   3 -
 drivers/irqchip/Kconfig|   6 +-
 drivers/irqchip/Makefile   |   4 +-
 drivers/irqchip/irq-atmel-aic.c|  40 ++---
 drivers/irqchip/irq-atmel-aic5.c   |  65 
 drivers/irqchip/irq-bcm7120-l2.c   | 174 +
 drivers/irqchip/irq-brcmstb-l2.c   |  41 +++--
 drivers/irqchip/irq-sunxi-nmi.c|   4 +-
 drivers/irqchip/irq-tb10x.c|   4 +-
 include/linux/irq.h|  32 +++-
 kernel/irq/generic-chip.c  |  36 +++--
 14 files changed, 263 insertions(+), 176 deletions(-)

-- 
2.1.1

--
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: [fuse-devel] [PATCH v5 7/7] add a flag for per-operation O_DSYNC semantics

2014-11-06 Thread Anton Altaparmakov
Hi,

> On 7 Nov 2014, at 07:52, Anand Avati  wrote:
> On Thu, Nov 6, 2014 at 8:22 PM, Anton Altaparmakov  wrote:
> > On 7 Nov 2014, at 01:46, Jeff Moyer  wrote:
> > Minor nit, but I'd rather read something that looks like this:
> >
> >   if (type == READ && (flags & RWF_NONBLOCK))
> >   return -EAGAIN;
> >   else if (type == WRITE && (flags & RWF_DSYNC))
> >   return -EINVAL;
> 
> But your version is less logically efficient for the case where "type == 
> READ" is true and "flags & RWF_NONBLOCK" is false because your version then 
> has to do the "if (type == WRITE" check before discovering it does not need 
> to take that branch either, whilst the original version does not have to do 
> such a test at all.
> 
> Seriously?

Of course seriously.

> Just focus on the code readability/maintainability which makes the code most 
> easily understood/obvious to a new pair of eyes, and leave such 
> micro-optimizations to the compiler..

The original version is more readable (IMO) and this is not a 
micro-optimization.  It is people like you who are responsible for the fact 
that we need faster and faster computers to cope with the inefficient/poor code 
being written more and more...

And I really wouldn't hedge my bets on gcc optimizing something like that.  The 
amount of crap assembly produced from gcc that I have seen over the years 
suggests that it is quite likely it will make a hash of it instead...

Best regards,

Anton

> Thanks

-- 
Anton Altaparmakov  (replace at with @)
University of Cambridge Information Services, Roger Needham Building
7 JJ Thomson Avenue, Cambridge, CB3 0RB, UK

--
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] tty: serial: msm_serial: Use DT aliases

2014-11-06 Thread Frank Rowand
On 11/6/2014 10:40 PM, Frank Rowand wrote:
> From: Frank Rowand 
> 
> Update msm8974 dtsi for msm_serial to reflect msm_serial_probe()
> getting line id from the serial alias.
> 
> Signed-off-by: Frank Rowand 
> ---
>  arch/arm/boot/dts/qcom-msm8974.dtsi |6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> Index: b/arch/arm/boot/dts/qcom-msm8974.dtsi
> ===
> --- a/arch/arm/boot/dts/qcom-msm8974.dtsi
> +++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
> @@ -9,6 +9,10 @@
>   compatible = "qcom,msm8974";
>   interrupt-parent = <>;
>  
> + aliases {
> + serial0 = 
> + };
> +
>   cpus {
>   #address-cells = <1>;
>   #size-cells = <0>;
> @@ -189,7 +193,7 @@
>   reg = <0xfd8c 0x6000>;
>   };
>  
> - serial@f991e000 {
> + serial0: serial@f991e000 {
>   compatible = "qcom,msm-uartdm-v1.4", "qcom,msm-uartdm";
>   reg = <0xf991e000 0x1000>;
>   interrupts = <0 108 0x0>;
> 

This same change is also needed in:

  qcom-ipq8064.dtsi
  qcom-msm8960.dtsi
  qcom-apq8084.dtsi
  qcom-apq8064.dtsi
  qcom-msm8660.dtsi

but I did not want to just blindly apply those changes without testing.

-Frank
--
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/1] ipc/mqueue.c: Drag unneeded code out of locks

2014-11-06 Thread Steven Stewart-Gallus
This shouldn't be too controversial. I simply looked for where there
was a tiny bit of waste in the message queue code.

Signed-off-by: Steven Stewart-Gallus 
---
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 4fcf39a..aa3f903 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -278,16 +278,29 @@ static struct inode *mqueue_get_inode(struct super_block 
*sb,
mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
  info->attr.mq_msgsize);
 
-   spin_lock(_lock);
-   if (u->mq_bytes + mq_bytes < u->mq_bytes ||
-   u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
+   {
+   bool too_many_open_files;
+   long msgqueue_lim;
+   unsigned long u_bytes;
+
+   msgqueue_lim = rlimit(RLIMIT_MSGQUEUE);
+
+   spin_lock(_lock);
+
+   u_bytes = u->mq_bytes;
+   too_many_open_files = u_bytes + mq_bytes < u_bytes ||
+   u_bytes + mq_bytes > msgqueue_lim;
+   if (!too_many_open_files)
+   u->mq_bytes += mq_bytes;
+
spin_unlock(_lock);
+
/* mqueue_evict_inode() releases info->messages */
-   ret = -EMFILE;
-   goto out_inode;
+   if (too_many_open_files) {
+   ret = -EMFILE;
+   goto out_inode;
+   }
}
-   u->mq_bytes += mq_bytes;
-   spin_unlock(_lock);
 
/* all is ok */
info->user = get_uid(u);
@@ -423,44 +436,60 @@ static int mqueue_create(struct inode *dir, struct dentry
*dentry,
umode_t mode, bool excl)
 {
struct inode *inode;
-   struct mq_attr *attr = dentry->d_fsdata;
-   int error;
+   struct mq_attr *attr;
struct ipc_namespace *ipc_ns;
+   int error = 0;
+
+   if (!capable(CAP_SYS_RESOURCE)) {
+   error = -ENOSPC;
+   goto finish;
+   }
+
+   attr = dentry->d_fsdata;
 
spin_lock(_lock);
ipc_ns = __get_ns_from_inode(dir);
if (!ipc_ns) {
error = -EACCES;
-   goto out_unlock;
+   goto unlock_mq;
}
 
-   if (ipc_ns->mq_queues_count >= ipc_ns->mq_queues_max &&
-   !capable(CAP_SYS_RESOURCE)) {
+   if (ipc_ns->mq_queues_count >= ipc_ns->mq_queues_max) {
error = -ENOSPC;
-   goto out_unlock;
+   goto unlock_mq;
}
ipc_ns->mq_queues_count++;
+unlock_mq:
spin_unlock(_lock);
 
+   if (error != 0)
+   goto put_ipc_ns;
+
inode = mqueue_get_inode(dir->i_sb, ipc_ns, mode, attr);
if (IS_ERR(inode)) {
error = PTR_ERR(inode);
+
spin_lock(_lock);
ipc_ns->mq_queues_count--;
-   goto out_unlock;
+   spin_unlock(_lock);
+
+   goto put_ipc_ns;
}
 
-   put_ipc_ns(ipc_ns);
+put_ipc_ns:
+   if (ipc_ns)
+   put_ipc_ns(ipc_ns);
+
+   if (error != 0)
+   goto finish;
+
dir->i_size += DIRENT_SIZE;
dir->i_ctime = dir->i_mtime = dir->i_atime = CURRENT_TIME;
 
d_instantiate(dentry, inode);
dget(dentry);
-   return 0;
-out_unlock:
-   spin_unlock(_lock);
-   if (ipc_ns)
-   put_ipc_ns(ipc_ns);
+
+finish:
return error;
 }
 
@@ -485,26 +514,39 @@ static int mqueue_unlink(struct inode *dir, struct dentry
*dentry)
 static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,
size_t count, loff_t *off)
 {
-   struct mqueue_inode_info *info = MQUEUE_I(file_inode(filp));
-   char buffer[FILENT_SIZE];
ssize_t ret;
+   pid_t notify_owner;
+   unsigned long qsize;
+   struct sigevent notify;
 
-   spin_lock(>lock);
-   snprintf(buffer, sizeof(buffer),
-   "QSIZE:%-10lu NOTIFY:%-5d SIGNO:%-5d NOTIFY_PID:%-6d\n",
-   info->qsize,
-   info->notify_owner ? info->notify.sigev_notify : 0,
-   (info->notify_owner &&
-info->notify.sigev_notify == SIGEV_SIGNAL) ?
-   info->notify.sigev_signo : 0,
-   pid_vnr(info->notify_owner));
-   spin_unlock(>lock);
-   buffer[sizeof(buffer)-1] = '\0';
+   {
+   struct mqueue_inode_info *info = MQUEUE_I(file_inode(filp));
 
-   ret = simple_read_from_buffer(u_data, count, off, buffer,
-   strlen(buffer));
-   if (ret <= 0)
-   return ret;
+   spin_lock(>lock);
+   notify_owner = 

Re: [PATCH] tty: serial: msm_serial: Use DT aliases

2014-11-06 Thread Frank Rowand
From: Frank Rowand 

Update msm8974 dtsi for msm_serial to reflect msm_serial_probe()
getting line id from the serial alias.

Signed-off-by: Frank Rowand 
---
 arch/arm/boot/dts/qcom-msm8974.dtsi |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

Index: b/arch/arm/boot/dts/qcom-msm8974.dtsi
===
--- a/arch/arm/boot/dts/qcom-msm8974.dtsi
+++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
@@ -9,6 +9,10 @@
compatible = "qcom,msm8974";
interrupt-parent = <>;
 
+   aliases {
+   serial0 = 
+   };
+
cpus {
#address-cells = <1>;
#size-cells = <0>;
@@ -189,7 +193,7 @@
reg = <0xfd8c 0x6000>;
};
 
-   serial@f991e000 {
+   serial0: serial@f991e000 {
compatible = "qcom,msm-uartdm-v1.4", "qcom,msm-uartdm";
reg = <0xf991e000 0x1000>;
interrupts = <0 108 0x0>;
--
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] checkpatch: Add test for consecutive string fragments

2014-11-06 Thread Joe Perches
Emit a warning when single line string coalescing occurs.

Code that uses compiler string concatenation on a single line like:
printk("foo" "bar");
is generally better to read concatenated like:
printk("foobar");

Signed-off-by: Joe Perches 
---
 scripts/checkpatch.pl | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 893cbd5..508037a 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4462,6 +4462,12 @@ sub process {
"Concatenated strings should use spaces between 
elements\n" . $herecurr);
}
 
+# uncoalesced string fragments
+   if ($line =~ /"X*"\s*"/) {
+   WARN("STRING_FRAGMENTS",
+"Consecutive strings are generally better as a 
single string\n" . $herecurr);
+   }
+
 # warn about #if 0
if ($line =~ /^.\s*\#\s*if\s+0\b/) {
CHK("REDUNDANT_CODE",


--
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] Add of_path property for all devices with a node

2014-11-06 Thread Benjamin Herrenschmidt
On Fri, 2014-11-07 at 17:33 +1100, Benjamin Herrenschmidt wrote:

> So I came up with this patch, 

And here is the actual patch, which might help :-) It's pretty trivial
and small...

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 20da3ad..dd0ee1b 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "base.h"
 #include "power/power.h"
@@ -454,6 +455,23 @@ static ssize_t online_store(struct device *dev, struct 
device_attribute *attr,
 }
 static DEVICE_ATTR_RW(online);
 
+#ifdef CONFIG_OF
+
+static ssize_t of_path_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   ssize_t s = 0;
+
+   device_lock(dev);
+   if (dev->of_node)
+   s = sprintf(buf, "%s\n", dev->of_node->full_name);
+   device_unlock(dev);
+   return s;
+}
+static DEVICE_ATTR_RO(of_path);
+
+#endif /* CONFIG_OF */
+
 int device_add_groups(struct device *dev, const struct attribute_group 
**groups)
 {
return sysfs_create_groups(>kobj, groups);
@@ -487,15 +505,27 @@ static int device_add_attrs(struct device *dev)
if (error)
goto err_remove_type_groups;
 
+#ifdef CONFIG_OF
+   if (dev->of_node) {
+   error = device_create_file(dev, _attr_of_path);
+   if (error)
+   goto err_remove_dev_groups;
+   }
+#endif /* CONFIG_OF */
+
if (device_supports_offline(dev) && !dev->offline_disabled) {
error = device_create_file(dev, _attr_online);
if (error)
-   goto err_remove_dev_groups;
+   goto err_remove_of_path;
}
 
return 0;
 
+ err_remove_of_path:
+#ifdef CONFIG_OF
+   device_remove_file(dev, _attr_of_path);
  err_remove_dev_groups:
+#endif
device_remove_groups(dev, dev->groups);
  err_remove_type_groups:
if (type)


--
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/


[RFC] Add of_path property for all devices with a node

2014-11-06 Thread Benjamin Herrenschmidt
Hey folks ! This is not (yet) a formal patch submission but...

So I've been annoyed lately with having a bunch of devices such as i2c
eeproms (for use by VPDs, server world !) and other bits and pieces that
I want to be able to identify from userspace, and possibly provide
additional data about from FW.

Basically, it boils down to correlating the sysfs device with the OF
tree device node, so that user space can use device-tree info such as
additional "location" or "label" (or whatever else we can come up with)
propreties to identify a given device, or get some attributes of use
about it, etc...

Now, so far, we've done that in some subsystem in a fairly ad-hoc basis
using "devspec" properties. For example, PCI creates them if it can
correlate the probed device with a DT node. Some powerpc specific busses
do that too.

However, i2c doesn't and it would be nice to have something more generic
since technically any device can have a corresponding device tree node.

So I came up with this patch, it seems to work well for me. I'm adding
an "of_path" attribute to not conflict with the existing "devspec" one
just for the sake of this experiment (plus "devspec" sucks). Long run,
we might want to use of_path and leave a "devspec" symlink to of_path on
the few busses that currently have devspec (pci and some powerpc
specific ones).

Comments ?

Cheers,
Ben.





--
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] [media] solo6x10: clean up properly in stop_streaming

2014-11-06 Thread Dan Carpenter
On Fri, Nov 07, 2014 at 01:06:18AM +0400, Andrey Utkin wrote:
> This fixes warning from drivers/media/v4l2-core/videobuf2-core.c,
> WARN_ON(atomic_read(>owned_by_drv_count)).
> 

Thanks!

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/


Re: [PATCHv2] pinctrl: exynos: Add support for Exynos4415

2014-11-06 Thread Tomasz Figa
Hi Chanwoo,

2014-11-07 15:23 GMT+09:00 Chanwoo Choi :
> Dear Linus,
>
> Could you please review this patch?

I'll take care of this during this weekend.

Sorry for all the delays, but I was in the middle of relocation to
another country and I just didn't have enough time yet to collect all
the patches.

Best regards,
Tomasz
--
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: [LKP] [x86_64,entry] f04e05b81e4: -62.7% time.user_time

2014-11-06 Thread Andy Lutomirski
On Thu, Nov 6, 2014 at 10:00 PM, LKP  wrote:
> FYI, we noticed the below changes on
>
> git://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git x86/entry
> commit f04e05b81e4d9ae88bee379f12176f551a24394a ("x86_64,entry: Use sysret to 
> return to userspace when possible")
>
>
> f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  testbox/testcase/testparams
>   --
>  %stddev %change %stddev
>  \  |\
>  24.09 ±  4% -62.7%   8.99 ±  3%  
> lkp-wsx02/aim9/performance-300s-creat-clo
>  24.09   -62.7%   8.99GEO-MEAN time.user_time
>

I don't really know how to interpret this.  Is this a good thing or a bad thing?

I actually expect this change to be a dramatic speedup for some
workloads.  Any chance you can send me the .config, kernel command
line, and whether you have any tracing features enabled?

--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/


color box, display box, corrugated box, color card, blister card, color sleeve, hang tag, label

2014-11-06 Thread Jinghao Printing - CHINA
Hi, this is David Wu from Shanghai, China.
We are a printing company, we can print color box, corrugated box,
label, hang tag etc.
Please let me know if you need these.

I will send you the website then.

Best regards,
David Wu
--
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: [PATCHv2] pinctrl: exynos: Add support for Exynos4415

2014-11-06 Thread Chanwoo Choi
Dear Linus,

Could you please review this patch?

Best Regards,
Chanwoo Choi

On 10/27/2014 10:21 AM, Chanwoo Choi wrote:
> From: Tomasz Figa 
> 
> The pin controllers of Exynos4415 are similar to Exynos4412, but certain
> differences cause the need to create separate driver data for it. This
> patch adds pin controller and bank descriptor arrays to the driver to
> support the new SoC.
> 
> Cc: Tomasz Figa 
> Cc: Thomas Abraham 
> Cc: Linus Walleij 
> Signed-off-by: Tomasz Figa 
> [cw00.choi: Rebase it on mainline kernel]
> Signed-off-by: Chanwoo Choi 
> Acked-by: Kyungmin Park 
> ---
> Changes from v1:
> - Separate only pinctrl patch from Exynos4415 patchset[1]
>  [1] [PATCH 0/5] Support new Exynos4415 SoC based on Cortex-A9 quad cores
>   : https://lkml.org/lkml/2014/10/19/253
> 
> drivers/pinctrl/samsung/pinctrl-exynos.c  | 78 +++
>  drivers/pinctrl/samsung/pinctrl-samsung.c |  2 +
>  drivers/pinctrl/samsung/pinctrl-samsung.h |  1 +
>  3 files changed, 81 insertions(+)
> 
> diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c 
> b/drivers/pinctrl/samsung/pinctrl-exynos.c
> index d7154ed..065eee0 100644
> --- a/drivers/pinctrl/samsung/pinctrl-exynos.c
> +++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
> @@ -920,6 +920,84 @@ struct samsung_pin_ctrl exynos4x12_pin_ctrl[] = {
>   },
>  };
>  
> +/* pin banks of exynos4415 pin-controller 0 */
> +static struct samsung_pin_bank exynos4415_pin_banks0[] = {
> + EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpa0", 0x00),
> + EXYNOS_PIN_BANK_EINTG(6, 0x020, "gpa1", 0x04),
> + EXYNOS_PIN_BANK_EINTG(8, 0x040, "gpb", 0x08),
> + EXYNOS_PIN_BANK_EINTG(5, 0x060, "gpc0", 0x0c),
> + EXYNOS_PIN_BANK_EINTG(5, 0x080, "gpc1", 0x10),
> + EXYNOS_PIN_BANK_EINTG(4, 0x0A0, "gpd0", 0x14),
> + EXYNOS_PIN_BANK_EINTG(4, 0x0C0, "gpd1", 0x18),
> + EXYNOS_PIN_BANK_EINTG(8, 0x180, "gpf0", 0x30),
> + EXYNOS_PIN_BANK_EINTG(8, 0x1A0, "gpf1", 0x34),
> + EXYNOS_PIN_BANK_EINTG(1, 0x1C0, "gpf2", 0x38),
> +};
> +
> +/* pin banks of exynos4415 pin-controller 1 */
> +static struct samsung_pin_bank exynos4415_pin_banks1[] = {
> + EXYNOS_PIN_BANK_EINTG(8, 0x040, "gpk0", 0x08),
> + EXYNOS_PIN_BANK_EINTG(7, 0x060, "gpk1", 0x0c),
> + EXYNOS_PIN_BANK_EINTG(7, 0x080, "gpk2", 0x10),
> + EXYNOS_PIN_BANK_EINTG(7, 0x0A0, "gpk3", 0x14),
> + EXYNOS_PIN_BANK_EINTG(4, 0x0C0, "gpl0", 0x18),
> + EXYNOS_PIN_BANK_EINTN(6, 0x120, "mp00"),
> + EXYNOS_PIN_BANK_EINTN(4, 0x140, "mp01"),
> + EXYNOS_PIN_BANK_EINTN(6, 0x160, "mp02"),
> + EXYNOS_PIN_BANK_EINTN(8, 0x180, "mp03"),
> + EXYNOS_PIN_BANK_EINTN(8, 0x1A0, "mp04"),
> + EXYNOS_PIN_BANK_EINTN(8, 0x1C0, "mp05"),
> + EXYNOS_PIN_BANK_EINTN(8, 0x1E0, "mp06"),
> + EXYNOS_PIN_BANK_EINTG(8, 0x260, "gpm0", 0x24),
> + EXYNOS_PIN_BANK_EINTG(7, 0x280, "gpm1", 0x28),
> + EXYNOS_PIN_BANK_EINTG(5, 0x2A0, "gpm2", 0x2c),
> + EXYNOS_PIN_BANK_EINTG(8, 0x2C0, "gpm3", 0x30),
> + EXYNOS_PIN_BANK_EINTG(8, 0x2E0, "gpm4", 0x34),
> + EXYNOS_PIN_BANK_EINTW(8, 0xC00, "gpx0", 0x00),
> + EXYNOS_PIN_BANK_EINTW(8, 0xC20, "gpx1", 0x04),
> + EXYNOS_PIN_BANK_EINTW(8, 0xC40, "gpx2", 0x08),
> + EXYNOS_PIN_BANK_EINTW(8, 0xC60, "gpx3", 0x0c),
> +};
> +
> +/* pin banks of exynos4415 pin-controller 2 */
> +static struct samsung_pin_bank exynos4415_pin_banks2[] = {
> + EXYNOS_PIN_BANK_EINTG(7, 0x000, "gpz", 0x00),
> + EXYNOS_PIN_BANK_EINTN(2, 0x000, "etc1"),
> +};
> +
> +/*
> + * Samsung pinctrl driver data for Exynos4415 SoC. Exynos4415 SoC includes
> + * three gpio/pin-mux/pinconfig controllers.
> + */
> +struct samsung_pin_ctrl exynos4415_pin_ctrl[] = {
> + {
> + /* pin-controller instance 0 data */
> + .pin_banks  = exynos4415_pin_banks0,
> + .nr_banks   = ARRAY_SIZE(exynos4415_pin_banks0),
> + .eint_gpio_init = exynos_eint_gpio_init,
> + .suspend= exynos_pinctrl_suspend,
> + .resume = exynos_pinctrl_resume,
> + .label  = "exynos4415-gpio-ctrl0",
> + }, {
> + /* pin-controller instance 1 data */
> + .pin_banks  = exynos4415_pin_banks1,
> + .nr_banks   = ARRAY_SIZE(exynos4415_pin_banks1),
> + .eint_gpio_init = exynos_eint_gpio_init,
> + .eint_wkup_init = exynos_eint_wkup_init,
> + .suspend= exynos_pinctrl_suspend,
> + .resume = exynos_pinctrl_resume,
> + .label  = "exynos4415-gpio-ctrl1",
> + }, {
> + /* pin-controller instance 2 data */
> + .pin_banks  = exynos4415_pin_banks2,
> + .nr_banks   = ARRAY_SIZE(exynos4415_pin_banks2),
> + .eint_gpio_init = exynos_eint_gpio_init,
> + .suspend= exynos_pinctrl_suspend,
> + .resume = exynos_pinctrl_resume,
> + .label  = "exynos4415-gpio-ctrl2",
> + 

[LKP] [x86_64,entry] f04e05b81e4: -62.7% time.user_time

2014-11-06 Thread LKP
FYI, we noticed the below changes on

git://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git x86/entry
commit f04e05b81e4d9ae88bee379f12176f551a24394a ("x86_64,entry: Use sysret to 
return to userspace when possible")


f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  testbox/testcase/testparams
  --  
 %stddev %change %stddev
 \  |\  
 24.09 ±  4% -62.7%   8.99 ±  3%  
lkp-wsx02/aim9/performance-300s-creat-clo
 24.09   -62.7%   8.99GEO-MEAN time.user_time

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
  1571 ±  1% -13.5%   1359 ±  0%  
lkp-wsx02/aim9/performance-300s-creat-clo
  1571   -13.5%   1359GEO-MEAN vmstat.system.cs

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
   276 ±  0%  +5.5%291 ±  0%  
lkp-wsx02/aim9/performance-300s-creat-clo
   276+5.5%291GEO-MEAN time.system_time

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  ---
   430 ± 36% -36.0%275 ± 39%  
lkp-wsx02/aim9/performance-300s-creat-clo
   430   -36.0%275GEO-MEAN 
sched_debug.cpu#38.ttwu_count

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
  52761811 ± 29% -54.7%   23885493 ± 11%  
lkp-wsx02/aim9/performance-300s-creat-clo
  52761811   -54.7%   23885493GEO-MEAN cpuidle.C1E-NHM.time

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
 21939 ±  8% +42.6%  31283 ± 23%  
lkp-wsx02/aim9/performance-300s-creat-clo
 21939   +42.6%  31283GEO-MEAN 
numa-meminfo.node1.SUnreclaim

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
  5484 ±  8% +40.3%   7694 ± 22%  
lkp-wsx02/aim9/performance-300s-creat-clo
  5484   +40.3%   7694GEO-MEAN 
numa-vmstat.node1.nr_slab_unreclaimable

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
 34004 ±  2% +69.9%  57781 ±  4%  
lkp-wsx02/aim9/performance-300s-creat-clo
 34004   +69.9%  57781GEO-MEAN 
slabinfo.kmalloc-256.active_objs

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
  1075 ±  2% +68.8%   1815 ±  4%  
lkp-wsx02/aim9/performance-300s-creat-clo
  1074   +68.8%   1814GEO-MEAN 
slabinfo.kmalloc-256.active_slabs

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
  1075 ±  2% +68.8%   1815 ±  4%  
lkp-wsx02/aim9/performance-300s-creat-clo
  1074   +68.8%   1814GEO-MEAN 
slabinfo.kmalloc-256.num_slabs

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
 34415 ±  2% +68.8%  58099 ±  4%  
lkp-wsx02/aim9/performance-300s-creat-clo
 34415   +68.8%  58099GEO-MEAN 
slabinfo.kmalloc-256.num_objs

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
 32500 ±  7% +31.0%  42586 ± 17%  
lkp-wsx02/aim9/performance-300s-creat-clo
 32500   +31.0%  42586GEO-MEAN numa-meminfo.node1.Slab

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
 73657 ±  1% -23.4%  56388 ±  3%  
lkp-wsx02/aim9/performance-300s-creat-clo
 73657   -23.4%  56388GEO-MEAN softirqs.RCU

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
 10427 ± 14% -16.8%   8675 ±  6%  
lkp-wsx02/aim9/performance-300s-creat-clo
 10427   -16.8%   8675GEO-MEAN 
sched_debug.cfs_rq[0]:/.exec_clock

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
 24242 ±  8% +18.4%  28696 ± 12%  
lkp-wsx02/aim9/performance-300s-creat-clo
 24242   +18.4%  28696GEO-MEAN numa-meminfo.node3.Active

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
  2076 ±  7% +12.1%   2328 ±  2%  
lkp-wsx02/aim9/performance-300s-creat-clo
  2076   +12.1%   2327GEO-MEAN 
numa-meminfo.node2.KernelStack

f2ee9bebb99dd4a4  f04e05b81e4d9ae88bee379f12  
  --  
   1139198 ±  5%  -6.6%1063912 ±  0%  
lkp-wsx02/aim9/performance-300s-creat-clo
   1139198-6.6%1063912GEO-MEAN proc-vmstat.pgfault

lkp-wsx02: Westmere-EX
Memory: 128G




 time.user_time

  26 

Re: [PATCH] sysfs: driver core: Fix glue dir race condition

2014-11-06 Thread Greg KH
On Fri, Nov 07, 2014 at 11:12:19AM +0800, Yijing Wang wrote:
> >> +static DEFINE_MUTEX(gdp_mutex);
> >>
> >>  static struct kobject *get_device_parent(struct device *dev,
> >> struct device *parent)
> >>  {
> >>if (dev->class) {
> >> -  static DEFINE_MUTEX(gdp_mutex);
> >>struct kobject *kobj = NULL;
> >>struct kobject *parent_kobj;
> >>struct kobject *k;
> >> @@ -793,7 +793,9 @@ static void cleanup_glue_dir(struct device *dev, 
> >> struct kobject *glue_dir)
> >>glue_dir->kset != >class->p->glue_dirs)
> >>return;
> >>
> >> +  mutex_lock(_mutex);
> >>kobject_put(glue_dir);
> >> +  mutex_unlock(_mutex);
> >>  }
> >>
> >>  static void cleanup_device_parent(struct device *dev)
> >>
> > 
> > I much prefer this patch over the other one, as it keeps the same
> > behavior as today, and fixes the existing bug.
> > 
> > Have you tested it out to see if it works properly?  If so, can you
> > resend it in a "proper" form so I can apply it?
> 
> Yes, we tested it in our system, I will resend it now, thanks!

Wonderful, thanks for that, and persisting with this.  I'll queue up
that patch tomorrow morning.

greg k-h
--
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/5] input: touchscreen: ti_am335x_tsc: Remove udelay in interrupt handler

2014-11-06 Thread Vignesh R
From: Brad Griffis 

TSC interrupt handler had udelay to avoid reporting of false pen-up
interrupt to user space. This patch implements workaround suggesting in
Advisory 1.0.31 of silicon errata for am335x, thus eliminating udelay
and touchscreen lag. This also improves performance of touchscreen and
eliminates sudden jump of cursor at touch release.

IDLECONFIG and CHARGECONFIG registers are to be configured
with same values in order to eliminate false pen-up events. This
workaround may result in false pen-down to be detected, hence considerable
charge step delay needs to be added. The charge delay is set to 0xB000
(in terms of ADC clock cycles) by default.

TSC steps are disabled at the end of every sampling cycle and EOS bit is
set. Once the EOS bit is set, the TSC steps need to be re-enabled to begin
next sampling cycle.

Signed-off-by: Brad Griffis 
[vigne...@ti.com: Ported the patch from v3.12 to v3.18rc2]

Signed-off-by: Vignesh R 
---
 drivers/input/touchscreen/ti_am335x_tsc.c | 56 ---
 include/linux/mfd/ti_am335x_tscadc.h  |  3 +-
 2 files changed, 24 insertions(+), 35 deletions(-)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c 
b/drivers/input/touchscreen/ti_am335x_tsc.c
index 1aeac9675fe7..483fd97c0e0c 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -173,11 +173,9 @@ static void titsc_step_config(struct titsc *ts_dev)
titsc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY);
}
 
-   /* Charge step configuration */
-   config = ts_dev->bit_xp | ts_dev->bit_yn |
-   STEPCHARGE_RFP_XPUL | STEPCHARGE_RFM_XNUR |
-   STEPCHARGE_INM_AN1 | STEPCHARGE_INP(ts_dev->inp_yp);
+   /* Make CHARGECONFIG same as IDLECONFIG */
 
+   config = titsc_readl(ts_dev, REG_IDLECONFIG);
titsc_writel(ts_dev, REG_CHARGECONFIG, config);
titsc_writel(ts_dev, REG_CHARGEDELAY, CHARGEDLY_OPENDLY);
 
@@ -264,9 +262,26 @@ static irqreturn_t titsc_irq(int irq, void *dev)
unsigned int status, irqclr = 0;
unsigned int x = 0, y = 0;
unsigned int z1, z2, z;
-   unsigned int fsm;
 
-   status = titsc_readl(ts_dev, REG_IRQSTATUS);
+   status = titsc_readl(ts_dev, REG_RAWIRQSTATUS);
+   if (status & IRQENB_HW_PEN) {
+   ts_dev->pen_down = true;
+   titsc_writel(ts_dev, REG_IRQWAKEUP, 0x00);
+   titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN);
+   irqclr |= IRQENB_HW_PEN;
+   }
+
+   if (status & IRQENB_PENUP) {
+   ts_dev->pen_down = false;
+   input_report_key(input_dev, BTN_TOUCH, 0);
+   input_report_abs(input_dev, ABS_PRESSURE, 0);
+   input_sync(input_dev);
+   irqclr |= IRQENB_PENUP;
+   }
+
+   if (status & IRQENB_EOS)
+   irqclr |= IRQENB_EOS;
+
/*
 * ADC and touchscreen share the IRQ line.
 * FIFO1 interrupts are used by ADC. Handle FIFO0 IRQs here only
@@ -297,34 +312,6 @@ static irqreturn_t titsc_irq(int irq, void *dev)
}
irqclr |= IRQENB_FIFO0THRES;
}
-
-   /*
-* Time for sequencer to settle, to read
-* correct state of the sequencer.
-*/
-   udelay(SEQ_SETTLE);
-
-   status = titsc_readl(ts_dev, REG_RAWIRQSTATUS);
-   if (status & IRQENB_PENUP) {
-   /* Pen up event */
-   fsm = titsc_readl(ts_dev, REG_ADCFSM);
-   if (fsm == ADCFSM_STEPID) {
-   ts_dev->pen_down = false;
-   input_report_key(input_dev, BTN_TOUCH, 0);
-   input_report_abs(input_dev, ABS_PRESSURE, 0);
-   input_sync(input_dev);
-   } else {
-   ts_dev->pen_down = true;
-   }
-   irqclr |= IRQENB_PENUP;
-   }
-
-   if (status & IRQENB_HW_PEN) {
-
-   titsc_writel(ts_dev, REG_IRQWAKEUP, 0x00);
-   titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN);
-   }
-
if (irqclr) {
titsc_writel(ts_dev, REG_IRQSTATUS, irqclr);
am335x_tsc_se_set_cache(ts_dev->mfd_tscadc, ts_dev->step_mask);
@@ -417,6 +404,7 @@ static int titsc_probe(struct platform_device *pdev)
}
 
titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO0THRES);
+   titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_EOS);
err = titsc_config_wires(ts_dev);
if (err) {
dev_err(>dev, "wrong i/p wire configuration\n");
diff --git a/include/linux/mfd/ti_am335x_tscadc.h 
b/include/linux/mfd/ti_am335x_tscadc.h
index e2e70053470e..c99be5dc0f5c 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -52,6 +52,7 @@
 
 /* IRQ enable */
 #define IRQENB_HW_PEN  BIT(0)
+#define IRQENB_EOS BIT(1)
 #define 

[PATCH 4/5] ARM: dts: AM335x: Make charge delay a DT parameter for tsc

2014-11-06 Thread Vignesh R
The charge delay value is by default 0xB000. But it can be set to lower
values on some boards as long as false pen-ups are avoided. Lowering the
value increases the sampling rate (though current sampling rate is
sufficient for tsc operation). Hence charge delay has been made a DT
parameter.

Signed-off-by: Vignesh R 
---
 .../devicetree/bindings/input/touchscreen/ti-tsc-adc.txt  | 15 +++
 arch/arm/boot/dts/am335x-evm.dts  |  1 +
 2 files changed, 16 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt 
b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
index 878549ba814d..b87574bae009 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
@@ -28,6 +28,20 @@ Required properties:
ti,adc-channels: List of analog inputs available for ADC.
 AIN0 = 0, AIN1 = 1 and so on till AIN7 = 7.
 
+Optional properties:
+- child "tsc"
+   ti,charge-delay: Length of touch screen charge delay step in terms of
+ADC clock cycles. Charge delay value should be large
+in order to avoid false pen-up events. This value
+affects the overall sampling speed, hence need to be
+kept as low as possible, while avoiding false pen-up
+event. Start from a lower value, say 0x400, and
+increase value until false pen-up events are avoided.
+The pen-up detection happens immediately after the
+charge step, so this does in fact function as a
+hardware knob for adjusting the amount of "settling
+time".
+
 Example:
tscadc: tscadc@44e0d000 {
compatible = "ti,am3359-tscadc";
@@ -36,6 +50,7 @@ Example:
ti,x-plate-resistance = <200>;
ti,coordiante-readouts = <5>;
ti,wire-config = <0x00 0x11 0x22 0x33>;
+   ti,charge-delay = <0xB000>;
};
 
adc {
diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts
index e2156a583de7..80be0462298b 100644
--- a/arch/arm/boot/dts/am335x-evm.dts
+++ b/arch/arm/boot/dts/am335x-evm.dts
@@ -641,6 +641,7 @@
ti,x-plate-resistance = <200>;
ti,coordinate-readouts = <5>;
ti,wire-config = <0x00 0x11 0x22 0x33>;
+   ti,charge-delay = <0xB000>;
};
 
adc {
-- 
1.9.1

--
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 3/5] mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save

2014-11-06 Thread Vignesh R
In one shot mode, sequencer automatically disables all enabled steps at
the end of each cycle. (both ADC steps and TSC steps) Hence these steps
need not be saved in reg_se_cache for clearing these steps at a later
stage.
Also, when ADC wakes up Sequencer should not be busy executing any of the
config steps except for the charge step. Previously charge step was 1 ADC
clock cycle and hence it was ignored.

Signed-off-by: Vignesh R 
---
 drivers/mfd/ti_am335x_tscadc.c   | 7 +--
 include/linux/mfd/ti_am335x_tscadc.h | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index d877e777cce6..94ef8992f46b 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -86,8 +86,12 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev 
*tsadc)
spin_lock_irq(>reg_lock);
finish_wait(>reg_se_wait, );
 
+   /*
+* Sequencer should either be idle or
+* busy applying the charge step.
+*/
reg = tscadc_readl(tsadc, REG_ADCFSM);
-   WARN_ON(reg & SEQ_STATUS);
+   WARN_ON(reg & SEQ_STATUS & (!CHARGE_STEP));
tsadc->adc_waiting = false;
}
tsadc->adc_in_use = true;
@@ -96,7 +100,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev 
*tsadc)
 void am335x_tsc_se_set_once(struct ti_tscadc_dev *tsadc, u32 val)
 {
spin_lock_irq(>reg_lock);
-   tsadc->reg_se_cache |= val;
am335x_tscadc_need_adc(tsadc);
 
tscadc_writel(tsadc, REG_SE, val);
diff --git a/include/linux/mfd/ti_am335x_tscadc.h 
b/include/linux/mfd/ti_am335x_tscadc.h
index c99be5dc0f5c..fcce182e4a35 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -128,6 +128,7 @@
 
 /* Sequencer Status */
 #define SEQ_STATUS BIT(5)
+#define CHARGE_STEP0x11
 
 #define ADC_CLK300
 #define TOTAL_STEPS16
-- 
1.9.1

--
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 5/5] input: touchscreen: ti_am335x_tsc: Use charge delay DT parameter

2014-11-06 Thread Vignesh R
This patch reads charge delay from tsc DT node and writes to
REG_CHARGEDELAY register. If the charge delay is not specified in DT
then default value of 0xB000(CHARGEDLY_OPENDLY) is used.

Signed-off-by: Vignesh R 
---
 drivers/input/touchscreen/ti_am335x_tsc.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c 
b/drivers/input/touchscreen/ti_am335x_tsc.c
index 483fd97c0e0c..20ce76b1b6e7 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -52,6 +52,7 @@ struct titsc {
u32 bit_xp, bit_xn, bit_yp, bit_yn;
u32 inp_xp, inp_xn, inp_yp, inp_yn;
u32 step_mask;
+   u32 charge_delay;
 };
 
 static unsigned int titsc_readl(struct titsc *ts, unsigned int reg)
@@ -177,7 +178,7 @@ static void titsc_step_config(struct titsc *ts_dev)
 
config = titsc_readl(ts_dev, REG_IDLECONFIG);
titsc_writel(ts_dev, REG_CHARGECONFIG, config);
-   titsc_writel(ts_dev, REG_CHARGEDELAY, CHARGEDLY_OPENDLY);
+   titsc_writel(ts_dev, REG_CHARGEDELAY, ts_dev->charge_delay);
 
/* coordinate_readouts + 1 ... coordinate_readouts + 2 is for Z */
config = STEPCONFIG_MODE_HWSYNC |
@@ -361,6 +362,11 @@ static int titsc_parse_dt(struct platform_device *pdev,
if (err < 0)
return err;
 
+   err = of_property_read_u32(node, "ti,charge-delay",
+  _dev->charge_delay);
+   if (err < 0)
+   ts_dev->charge_delay = CHARGEDLY_OPENDLY;
+
return of_property_read_u32_array(node, "ti,wire-config",
ts_dev->config_inp, ARRAY_SIZE(ts_dev->config_inp));
 }
-- 
1.9.1

--
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 0/5] Touchscreen performance related fixes

2014-11-06 Thread Vignesh R
This series of patches fix TSC defects related to lag in touchscreen
performance and cursor jump at touch release. The lag was result of
udelay in TSC interrupt handler. Cursor jump due to false pen-up event.
The patches implement Advisory 1.0.31 in silicon errata of am335x-evm
to avoid false pen-up events and remove udelay. The advisory says to use
steps 1 to 4 for ADC and 5 to 16 for TSC (assuming 4 wire TSC and 4 channel
ADC). Further the X co-ordinate must be the last one to be sampled just
before charge step. The first two patches implement the required changes.

A DT parameter to configure the duration of tsc charge step. It represents
number of ADC clock cycles to wait between applying the step configuration
registers and going back to the IDLE state. The charge delay value can vary
across boards. Configuring correct value of charge delay is important to avoid
false pen-up events. Hence it is necessary to expose charge-delay value as
DT parameter. The pen-up detection happens immediately after the charge step
so this does in fact function as a hardware knob for adjusting the amount of
settling time.

After applying these changes false pen-up events have not be observed and
smooth circles can be drawn on touch screen. The performance is much better
in recognizing quick movement across the screen. No lag or cursor jump is
observed.

Change log:

v2:
 - Addressed comments by Hartmut Knaack
 - patch 2 was split into two as per Lee Jones comment

Brad Griffis (2):
  input: touchscreen: ti_am335x_tsc Interchange touchscreen and ADC
steps
  input: touchscreen: ti_am335x_tsc: Remove udelay in interrupt handler

Vignesh R (3):
  mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache save
  ARM: dts: AM335x: Make charge delay a DT parameter for tsc
  input: touchscreen: ti_am335x_tsc: Use charge delay DT parameter

 .../bindings/input/touchscreen/ti-tsc-adc.txt  |  15 +++
 arch/arm/boot/dts/am335x-evm.dts   |   1 +
 drivers/iio/adc/ti_am335x_adc.c|   5 +-
 drivers/input/touchscreen/ti_am335x_tsc.c  | 106 ++---
 drivers/mfd/ti_am335x_tscadc.c |   7 +-
 include/linux/mfd/ti_am335x_tscadc.h   |   4 +-
 6 files changed, 79 insertions(+), 59 deletions(-)

-- 
1.9.1

--
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/5] input: touchscreen: ti_am335x_tsc Interchange touchscreen and ADC steps

2014-11-06 Thread Vignesh R
From: Brad Griffis 

This patch makes the initial changes required to workaround TSC-false
pen-up interrupts. It is required to implement these changes in order to
remove udelay in the TSC interrupt handler and false pen-up events.
The charge step is to be executed immediately after sampling X+. Hence
TSC is made to use higher numbered steps (steps 5 to 16 for 5 co-ordinate
readouts, 4 wire TSC configuration) and ADC to use lower ones. Further
X co-ordinate readouts must be the last to be sampled, thus co-ordinates
are sampled in the order Y-Z-X.

Signed-off-by: Brad Griffis 
[vigne...@ti.com: Ported the patch from v3.12 to v3.18rc2]

Signed-off-by: Vignesh R 
---
 drivers/iio/adc/ti_am335x_adc.c   |  5 ++--
 drivers/input/touchscreen/ti_am335x_tsc.c | 42 ++-
 2 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index b730864731e8..adba23246474 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -86,19 +86,18 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
 {
struct tiadc_device *adc_dev = iio_priv(indio_dev);
unsigned int stepconfig;
-   int i, steps;
+   int i, steps = 0;
 
/*
 * There are 16 configurable steps and 8 analog input
 * lines available which are shared between Touchscreen and ADC.
 *
-* Steps backwards i.e. from 16 towards 0 are used by ADC
+* Steps forwards i.e. from 0 towards 16 are used by ADC
 * depending on number of input lines needed.
 * Channel would represent which analog input
 * needs to be given to ADC to digitalize data.
 */
 
-   steps = TOTAL_STEPS - adc_dev->channels;
if (iio_buffer_enabled(indio_dev))
stepconfig = STEPCONFIG_AVG_16 | STEPCONFIG_FIFO1
| STEPCONFIG_MODE_SWCNT;
diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c 
b/drivers/input/touchscreen/ti_am335x_tsc.c
index 2ce649520fe0..1aeac9675fe7 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -121,7 +121,7 @@ static void titsc_step_config(struct titsc *ts_dev)
 {
unsigned intconfig;
int i;
-   int end_step;
+   int end_step, first_step, tsc_steps;
u32 stepenable;
 
config = STEPCONFIG_MODE_HWSYNC |
@@ -140,9 +140,11 @@ static void titsc_step_config(struct titsc *ts_dev)
break;
}
 
-   /* 1 … coordinate_readouts is for X */
-   end_step = ts_dev->coordinate_readouts;
-   for (i = 0; i < end_step; i++) {
+   tsc_steps = ts_dev->coordinate_readouts * 2 + 2;
+   first_step = TOTAL_STEPS - tsc_steps;
+   /* Steps 16 to 16-coordinate_readouts is for X */
+   end_step = first_step + tsc_steps;
+   for (i = end_step - ts_dev->coordinate_readouts; i < end_step; i++) {
titsc_writel(ts_dev, REG_STEPCONFIG(i), config);
titsc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY);
}
@@ -164,9 +166,9 @@ static void titsc_step_config(struct titsc *ts_dev)
break;
}
 
-   /* coordinate_readouts … coordinate_readouts * 2 is for Y */
-   end_step = ts_dev->coordinate_readouts * 2;
-   for (i = ts_dev->coordinate_readouts; i < end_step; i++) {
+   /* 1 ... coordinate_readouts is for Y */
+   end_step = first_step + ts_dev->coordinate_readouts;
+   for (i = first_step; i < end_step; i++) {
titsc_writel(ts_dev, REG_STEPCONFIG(i), config);
titsc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY);
}
@@ -179,7 +181,7 @@ static void titsc_step_config(struct titsc *ts_dev)
titsc_writel(ts_dev, REG_CHARGECONFIG, config);
titsc_writel(ts_dev, REG_CHARGEDELAY, CHARGEDLY_OPENDLY);
 
-   /* coordinate_readouts * 2 … coordinate_readouts * 2 + 2 is for Z */
+   /* coordinate_readouts + 1 ... coordinate_readouts + 2 is for Z */
config = STEPCONFIG_MODE_HWSYNC |
STEPCONFIG_AVG_16 | ts_dev->bit_yp |
ts_dev->bit_xn | STEPCONFIG_INM_ADCREFM |
@@ -194,8 +196,11 @@ static void titsc_step_config(struct titsc *ts_dev)
titsc_writel(ts_dev, REG_STEPDELAY(end_step),
STEPCONFIG_OPENDLY);
 
-   /* The steps1 … end and bit 0 for TS_Charge */
-   stepenable = (1 << (end_step + 2)) - 1;
+   /* The steps end ... end - readouts * 2 + 2 and bit 0 for TS_Charge */
+   stepenable = 1;
+   for (i = 0; i < tsc_steps; i++)
+   stepenable |= 1 << (first_step + i + 1);
+
ts_dev->step_mask = stepenable;
am335x_tsc_se_set_cache(ts_dev->mfd_tscadc, ts_dev->step_mask);
 }
@@ -209,6 +214,7 @@ static void titsc_read_coordinates(struct titsc *ts_dev,
unsigned int read, diff;
unsigned int i, channel;
   

Re: [PATCH 2/4] input: touchscreen: ti_am335x_tsc: Remove udelay in interrupt handler

2014-11-06 Thread Vignesh R


On Monday 03 November 2014 08:35 PM, Lee Jones wrote:
> On Mon, 27 Oct 2014, Vignesh R wrote:
>> From: Brad Griffis 
>>
>> TSC interrupt handler had udelay to avoid reporting of false pen-up
>> interrupt to user space. This patch implements workaround suggesting in
>> Advisory 1.0.31 of silicon errata for am335x, thus eliminating udelay
>> and touchscreen lag. This also improves performance of touchscreen and
>> eliminates sudden jump of cursor at touch release.
>>
>> IDLECONFIG and CHARGECONFIG registers are to be configured
>> with same values in order to eliminate false pen-up events. This
>> workaround may result in false pen-down to be detected, hence considerable
>> charge step delay needs to be added. The charge delay is set to 0xB000
>> (in terms of ADC clock cycles) by default.
>>
>> TSC steps are disabled at the end of every sampling cycle and EOS bit is
>> set. Once the EOS bit is set, the TSC steps need to be re-enabled to begin
>> next sampling cycle.
>>
>> In one shot mode, sequencer automatically disables all enabled steps at
>> the end of each cycle. (both ADC steps and TSC steps) Hence these steps
>> need not be saved in reg_se_cache for clearing these steps at a later
>> stage.
>>
>> Signed-off-by: Brad Griffis 
>> [vigne...@ti.com: Ported patch from v3.12 to v3.18rc2]
>> Signed-off-by: Vignesh R 
>> ---
>>  drivers/input/touchscreen/ti_am335x_tsc.c | 56 
>> ---
>>  drivers/mfd/ti_am335x_tscadc.c|  7 ++--
>>  include/linux/mfd/ti_am335x_tscadc.h  |  4 ++-
>>  3 files changed, 30 insertions(+), 37 deletions(-)
> 
> [...]
> 
>> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
>> index d877e777cce6..94ef8992f46b 100644
>> --- a/drivers/mfd/ti_am335x_tscadc.c
>> +++ b/drivers/mfd/ti_am335x_tscadc.c
>> @@ -86,8 +86,12 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev 
>> *tsadc)
>>  spin_lock_irq(>reg_lock);
>>  finish_wait(>reg_se_wait, );
>>  
>> +/*
>> + * Sequencer should either be idle or
>> + * busy applying the charge step.
>> + */
>>  reg = tscadc_readl(tsadc, REG_ADCFSM);
>> -WARN_ON(reg & SEQ_STATUS);
>> +WARN_ON(reg & SEQ_STATUS & (!CHARGE_STEP));
>>  tsadc->adc_waiting = false;
>>  }
>>  tsadc->adc_in_use = true;
>> @@ -96,7 +100,6 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev 
>> *tsadc)
>>  void am335x_tsc_se_set_once(struct ti_tscadc_dev *tsadc, u32 val)
>>  {
>>  spin_lock_irq(>reg_lock);
>> -tsadc->reg_se_cache |= val;
>>  am335x_tscadc_need_adc(tsadc);
>>  
>>  tscadc_writel(tsadc, REG_SE, val);
> 
> I believe all of these changes can, and therefor should live in a
> separate patch.

I will split this patch accordingly.

> 
>> diff --git a/include/linux/mfd/ti_am335x_tscadc.h 
>> b/include/linux/mfd/ti_am335x_tscadc.h
>> index e2e70053470e..fcce182e4a35 100644
>> --- a/include/linux/mfd/ti_am335x_tscadc.h
>> +++ b/include/linux/mfd/ti_am335x_tscadc.h
>> @@ -52,6 +52,7 @@
>>  
>>  /* IRQ enable */
>>  #define IRQENB_HW_PEN   BIT(0)
>> +#define IRQENB_EOS  BIT(1)
>>  #define IRQENB_FIFO0THRES   BIT(2)
>>  #define IRQENB_FIFO0OVRRUN  BIT(3)
>>  #define IRQENB_FIFO0UNDRFLW BIT(4)
>> @@ -107,7 +108,7 @@
>>  /* Charge delay */
>>  #define CHARGEDLY_OPEN_MASK (0x3 << 0)
>>  #define CHARGEDLY_OPEN(val) ((val) << 0)
>> -#define CHARGEDLY_OPENDLY   CHARGEDLY_OPEN(1)
>> +#define CHARGEDLY_OPENDLY   CHARGEDLY_OPEN(0xB000)
>>  
>>  /* Control register */
>>  #define CNTRLREG_TSCSSENB   BIT(0)
>> @@ -127,6 +128,7 @@
>>  
>>  /* Sequencer Status */
>>  #define SEQ_STATUS BIT(5)
>> +#define CHARGE_STEP 0x11
>>  
>>  #define ADC_CLK 300
>>  #define TOTAL_STEPS 16
> 
> The header changes should be split between the two Input and MFD
> patches.
> 
--
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 3/4] arm: boot: dts: am335x-evm: Make charge delay a DT parameter for tsc

2014-11-06 Thread Vignesh R


On Saturday 01 November 2014 02:39 AM, Hartmut Knaack wrote:
> Vignesh R schrieb am 27.10.2014 12:08:
>> The charge delay value is by default 0xB000. But it can be set to lower
>> values on some boards as long as false pen-ups are avoided. Lowering the
>> value increases the sampling rate (though current sampling rate is
>> sufficient for tsc operation). Hence charge delay has been made a DT
>> parameter.
>>
> I would recommend to use a few colons to separate some thoughts. Also, limit 
> to 80 chars per line would be beneficial. See inline.

I will address this in v2

>> Signed-off-by: Vignesh R 
>> ---
>>  .../devicetree/bindings/input/touchscreen/ti-tsc-adc.txt| 13 
>> +
>>  arch/arm/boot/dts/am335x-evm.dts|  1 +
>>  2 files changed, 14 insertions(+)
>>
>> diff --git 
>> a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt 
>> b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
>> index 878549ba814d..ac62769e70e4 100644
>> --- a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
>> +++ b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
>> @@ -28,6 +28,18 @@ Required properties:
>>  ti,adc-channels: List of analog inputs available for ADC.
>>   AIN0 = 0, AIN1 = 1 and so on till AIN7 = 7.
>>  
>> +Optional properties:
>> +- child "tsc"
>> +ti,charge-delay: Length of touch screen charge delay step in terms of
>> + ADC clock cycles. Charge delay value should be large 
>> in order
>> + to avoid false pen-up events. This value affects the 
>> overall
>> + sampling speed hence need to be kept as low as 
>> possible while
> <...> speed, hence needs to be <...>
>> + avoiding false pen-up event. Start from a lower value 
>> say 0x400
> <...> pen-up events. Start from a lower value, like 0x400, and increase <...>
>> + and increase value until false pen-up events are 
>> avoided. The
>> + pen-up detection happens immediately after the charge 
>> step
> <...> charge step, so this <...>
>> + so this does in fact function as a hardware knob for 
>> adjusting
>> + the amount of "settling time".
>> +
>>  Example:
>>  tscadc: tscadc@44e0d000 {
>>  compatible = "ti,am3359-tscadc";
>> @@ -36,6 +48,7 @@ Example:
>>  ti,x-plate-resistance = <200>;
>>  ti,coordiante-readouts = <5>;
>>  ti,wire-config = <0x00 0x11 0x22 0x33>;
>> +ti,charge-delay = <0xB000>;
>>  };
>>  
>>  adc {
>> diff --git a/arch/arm/boot/dts/am335x-evm.dts 
>> b/arch/arm/boot/dts/am335x-evm.dts
>> index e2156a583de7..80be0462298b 100644
>> --- a/arch/arm/boot/dts/am335x-evm.dts
>> +++ b/arch/arm/boot/dts/am335x-evm.dts
>> @@ -641,6 +641,7 @@
>>  ti,x-plate-resistance = <200>;
>>  ti,coordinate-readouts = <5>;
>>  ti,wire-config = <0x00 0x11 0x22 0x33>;
>> +ti,charge-delay = <0xB000>;
>>  };
>>  
>>  adc {
>>
> 
--
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 1/4] input: touchscreen: ti_am335x_tsc Interchange touchscreen and ADC steps

2014-11-06 Thread Vignesh R


On Saturday 01 November 2014 02:33 AM, Hartmut Knaack wrote:
> Vignesh R schrieb am 27.10.2014 12:08:
>> From: Brad Griffis 
>>
>> This patch makes the initial changes required to workaround TSC-false
>> pen-up interrupts. It is required to implement these changes in order to
>> remove udelay in the TSC interrupt handler and false pen-up events.
>> The charge step is to be executed immediately after sampling X+. Hence
>> TSC is made to use higher numbered steps (steps 5 to 16 for 5 co-ordinate
>> readouts, 4 wire TSC configuration) and ADC to use lower ones. Further
>> X co-ordinate readouts must be the last to be sampled, thus co-ordinates
>> are sampled in the order Y-Z-X.
>>
>> Signed-off-by: Brad Griffis 
>> [vigne...@ti.com: Ported the patch from v3.12 to v3.18rc2]
>> Signed-off-by: Vignesh R 
>> ---
>>  drivers/iio/adc/ti_am335x_adc.c   |  2 +-
>>  drivers/input/touchscreen/ti_am335x_tsc.c | 42 
>> ++-
>>  2 files changed, 25 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/iio/adc/ti_am335x_adc.c 
>> b/drivers/iio/adc/ti_am335x_adc.c
>> index b730864731e8..3f530ed6bd80 100644
>> --- a/drivers/iio/adc/ti_am335x_adc.c
>> +++ b/drivers/iio/adc/ti_am335x_adc.c
>> @@ -98,7 +98,7 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
>>   * needs to be given to ADC to digitalize data.
>>   */
>>  
>> -steps = TOTAL_STEPS - adc_dev->channels;
>> +steps = 0;
> You could even initialize it with zero during variable definition. And I 
> think the above comment could need an update now.

Ok, Will update the comment and initialization

>>  if (iio_buffer_enabled(indio_dev))
>>  stepconfig = STEPCONFIG_AVG_16 | STEPCONFIG_FIFO1
>>  | STEPCONFIG_MODE_SWCNT;
>> diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c 
>> b/drivers/input/touchscreen/ti_am335x_tsc.c
>> index 2ce649520fe0..1aeac9675fe7 100644
>> --- a/drivers/input/touchscreen/ti_am335x_tsc.c
>> +++ b/drivers/input/touchscreen/ti_am335x_tsc.c
>> @@ -121,7 +121,7 @@ static void titsc_step_config(struct titsc *ts_dev)
>>  {
>>  unsigned intconfig;
>>  int i;
>> -int end_step;
>> +int end_step, first_step, tsc_steps;
>>  u32 stepenable;
>>  
>>  config = STEPCONFIG_MODE_HWSYNC |
>> @@ -140,9 +140,11 @@ static void titsc_step_config(struct titsc *ts_dev)
>>  break;
>>  }
>>  
>> -/* 1 … coordinate_readouts is for X */
>> -end_step = ts_dev->coordinate_readouts;
>> -for (i = 0; i < end_step; i++) {
>> +tsc_steps = ts_dev->coordinate_readouts * 2 + 2;
>> +first_step = TOTAL_STEPS - tsc_steps;
>> +/* Steps 16 to 16-coordinate_readouts is for X */
>> +end_step = first_step + tsc_steps;
>> +for (i = end_step - ts_dev->coordinate_readouts; i < end_step; i++) {
>>  titsc_writel(ts_dev, REG_STEPCONFIG(i), config);
>>  titsc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY);
>>  }
>> @@ -164,9 +166,9 @@ static void titsc_step_config(struct titsc *ts_dev)
>>  break;
>>  }
>>  
>> -/* coordinate_readouts … coordinate_readouts * 2 is for Y */
>> -end_step = ts_dev->coordinate_readouts * 2;
>> -for (i = ts_dev->coordinate_readouts; i < end_step; i++) {
>> +/* 1 ... coordinate_readouts is for Y */
>> +end_step = first_step + ts_dev->coordinate_readouts;
>> +for (i = first_step; i < end_step; i++) {
>>  titsc_writel(ts_dev, REG_STEPCONFIG(i), config);
>>  titsc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY);
>>  }
>> @@ -179,7 +181,7 @@ static void titsc_step_config(struct titsc *ts_dev)
>>  titsc_writel(ts_dev, REG_CHARGECONFIG, config);
>>  titsc_writel(ts_dev, REG_CHARGEDELAY, CHARGEDLY_OPENDLY);
>>  
>> -/* coordinate_readouts * 2 … coordinate_readouts * 2 + 2 is for Z */
>> +/* coordinate_readouts + 1 ... coordinate_readouts + 2 is for Z */
>>  config = STEPCONFIG_MODE_HWSYNC |
>>  STEPCONFIG_AVG_16 | ts_dev->bit_yp |
>>  ts_dev->bit_xn | STEPCONFIG_INM_ADCREFM |
>> @@ -194,8 +196,11 @@ static void titsc_step_config(struct titsc *ts_dev)
>>  titsc_writel(ts_dev, REG_STEPDELAY(end_step),
>>  STEPCONFIG_OPENDLY);
>>  
>> -/* The steps1 … end and bit 0 for TS_Charge */
>> -stepenable = (1 << (end_step + 2)) - 1;
>> +/* The steps end ... end - readouts * 2 + 2 and bit 0 for TS_Charge */
>> +stepenable = 1;
>> +for (i = 0; i < tsc_steps; i++)
>> +stepenable |= 1 << (first_step + i + 1);
>> +
>>  ts_dev->step_mask = stepenable;
>>  am335x_tsc_se_set_cache(ts_dev->mfd_tscadc, ts_dev->step_mask);
>>  }
>> @@ -209,6 +214,7 @@ static void titsc_read_coordinates(struct titsc *ts_dev,
>>  unsigned int read, diff;
>>  unsigned int i, channel;
>>  unsigned int creads = ts_dev->coordinate_readouts;
>> +unsigned int first_step = TOTAL_STEPS - 

[LKP] [dmi] PANIC: early exception 0e rip 10:ffffffff81899e6b error 9 cr2 ffffffffff240000

2014-11-06 Thread LKP
FYI, we noticed the below changes on

https://git.linaro.org/people/ard.biesheuvel/linux-arm efi-for-3.19
commit aacdce6e880894acb57d71dcb2e3fc61b4ed4e96 ("dmi: add support for SMBIOS 
3.0 64-bit entry point")


+---+++
|   | 2fa165a26c | aacdce6e88 |
+---+++
| boot_successes| 20 | 10 |
| early-boot-hang   | 1  ||
| boot_failures | 0  | 5  |
| PANIC:early_exception | 0  | 5  |
+---+++


[0.00] BIOS-e820: [mem 0x0001-0x00036fff] usable
[0.00] bootconsole [earlyser0] enabled
[0.00] NX (Execute Disable) protection: active
PANIC: early exception 0e rip 10:81899e6b error 9 cr2 ff24
[0.00] CPU: 0 PID: 0 Comm: swapper Not tainted 3.18.0-rc2-gc5221e6 #1
[0.00]   82203d30 819f0a6e 
03f8
[0.00]  ff24 82203e18 823701b0 
82511401
[0.00]   0ba3  
ff24
[0.00] Call Trace:
[0.00]  [] dump_stack+0x4e/0x68
[0.00]  [] early_idt_handler+0x90/0xb7
[0.00]  [] ? dmi_save_one_device+0x81/0x81
[0.00]  [] ? dmi_table+0x3f/0x94
[0.00]  [] ? dmi_table+0x16/0x94
[0.00]  [] ? dmi_save_one_device+0x81/0x81
[0.00]  [] ? dmi_save_one_device+0x81/0x81
[0.00]  [] dmi_walk_early+0x44/0x69
[0.00]  [] dmi_present+0x180/0x1ff
[0.00]  [] dmi_scan_machine+0x144/0x191
[0.00]  [] ? loglevel+0x31/0x31
[0.00]  [] setup_arch+0x490/0xc73
[0.00]  [] ? printk+0x4d/0x4f
[0.00]  [] start_kernel+0x9c/0x43f
[0.00]  [] ? early_idt_handlers+0x120/0x120
[0.00]  [] x86_64_start_reservations+0x2a/0x2c
[0.00]  [] x86_64_start_kernel+0x13b/0x14a
[0.00] RIP 0x4
Decompressing Linux... Parsing ELF... done.
Booting the kernel.
[0.00] Initializing cgroup subsys cpuset
[0.00] Initializing cgroup subsys cpu
[0.00] Linux version 3.18.0-rc2-gc5221e6 (kbuild@xian) (gcc version 
4.9.1 (Debian 4.9.1-11) ) #1 SMP Wed Oct 29 11:52:18 CST 2014
[0.00] Command line: 
BOOT_IMAGE=/kernel/x86_64-lkp/c5221e6c2fcfa2f0f1871b672edbf8ea0f055213/vmlinuz-3.18.0-rc2-gc5221e6
 user=lkp 
job=/lkp/scheduled/lkp-ne04/boot_boot-performance-1-x86_64-lkp-c5221e6c2fcfa2f0f1871b672edbf8ea0f055213-0.yaml
 ARCH=x86_64 
BOOT_IMAGE=/kernel/x86_64-lkp/c5221e6c2fcfa2f0f1871b672edbf8ea0f055213/vmlinuz-3.18.0-rc2-gc5221e6
 kconfig=x86_64-lkp commit=c5221e6c2fcfa2f0f1871b672edbf8ea0f055213 
branch=linux-devel/devel-hourly-2014102911 root=/dev/ram0 max_uptime=3600 
RESULT_ROOT=/result/lkp-ne04/boot/performance-1/debian-x86_64.cgz/x86_64-lkp/c5221e6c2fcfa2f0f1871b672edbf8ea0f055213/0
 ip=lkp-ne04::dhcp earlyprintk=ttyS0,115200 debug apic=debug 
sysrq_always_enabled rcupdate.rcu_cpu_stall_timeout=100 panic=-1 
softlockup_panic=1 nmi_watchdog=panic oops=panic load_ramdisk=2 
prompt_ramdisk=0 console=ttyS0,115200 console=tty0 vga=normal rw
[0.00] e820: BIOS-provided physical RAM map:
[0.00] BIOS-e820: [mem 0x0100-0x0009a3ff] usable
[0.00] BIOS-e820: [mem 0x0009a400-0x0009] reserved
[0.00] BIOS-e820: [mem 0x000e-0x000f] reserved
[0.00] BIOS-e820: [mem 0x0010-0x8c555fff] usable
[0.00] BIOS-e820: [mem 0x8c556000-0x8c628fff] ACPI NVS
[0.00] BIOS-e820: [mem 0x8c629000-0x8c701fff] ACPI data
[0.00] BIOS-e820: [mem 0x8c702000-0x8db01fff] ACPI NVS
[0.00] BIOS-e820: [mem 0x8db02000-0x8f601fff] ACPI data
[0.00] BIOS-e820: [mem 0x8f602000-0x8f64efff] reserved
[0.00] BIOS-e820: [mem 0x8f64f000-0x8f6e5fff] ACPI data
[0.00] BIOS-e820: [mem 0x8f6e6000-0x8f6e] ACPI NVS
[0.00] BIOS-e820: [mem 0x8f6f-0x8f6f1fff] ACPI data
[0.00] BIOS-e820: [mem 0x8f6f2000-0x8f7cefff] ACPI NVS
[0.00] BIOS-e820: [mem 0x8f7cf000-0x8f7f] ACPI data
[0.00] BIOS-e820: [mem 0x8f80-0x8fff] reserved
[0.00] BIOS-e820: [mem 0xa000-0xafff] reserved
[0.00] BIOS-e820: [mem 0xfc00-0xfcff] reserved
[0.00] BIOS-e820: [mem 0xfed1c000-0xfed1] reserved
[0.00] BIOS-e820: [mem 0xff80-0x] reserved
[0.00] BIOS-e820: [mem 0x0001-0x00036fff] usable
[0.00] bootconsole [earlyser0] enabled
[0.00] NX (Execute Disable) protection: active
PANIC: early exception 0e 

[LKP] [AHCI] genirq: Flags mismatch irq 20. 00002080 (ahci) vs. 00000080 (i801_smbus)

2014-11-06 Thread LKP
FYI, we noticed the below changes on

git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git 
fixes-3.18-rc1
commit ef78bbdb4dd6ef84f6d4c670f40ec202fe9807f4 ("AHCI: Fix threaded interrupt 
setup")

2974a1837592b49d  ef78bbdb4dd6ef84f6d4c670f4  testbox/testcase/testparams
  --  ---
   fail:runs  %reproductionfail:runs
   | | |
   :12 100%   5:5 client5/boot/performance-1
   :12 100%   5:5 TOTAL 
dmesg.genirq:Flags_mismatch_irq##(ahci)vs.#(i801_smbus)


client5: cpu: Core, memory: 12G


[   16.143988] ipmi_si 00:07: Found new BMC (man_id: 0x000157, prod_id: 0x0028, 
dev_id: 0x20)
[   16.143995] ipmi_si 00:07: IPMI kcs interface initialized
[   16.163607] ahci :00:1f.2: flags: 64bit ncq pm led pmp slum part 
[   16.170555] genirq: Flags mismatch irq 20. 2080 (ahci) vs. 0080 
(i801_smbus)
[   16.171533] CPU: 1 PID: 369 Comm: modprobe Not tainted 
3.18.0-rc2-wl-ga4fb664 #1
[   16.171533] Hardware name: Intel S5000PAL/S5000PAL0, BIOS 
S5000.86B.10.00.0094.101320081858 10/13/2008
[   16.171533]  88035d539b00 88035d42b988 8187741c 
33c0
[   16.171533]  88032efe5400 88035d42b9e8 810cbbaf 
88035d42b9e8
[   16.171533]  0246 810cbd22 880344fa5800 
88035ca8a0e0
[   16.171533] Call Trace:
[   16.171533]  [] dump_stack+0x4e/0x68
[   16.171533]  [] __setup_irq+0x57f/0x5d0
[   16.171533]  [] ? request_threaded_irq+0x82/0x190
[   16.171533]  [] ? ahci_dev_classify+0x60/0x60 [libahci]
[   16.171533]  [] request_threaded_irq+0xcc/0x190
[   16.171533]  [] ? ahci_dev_classify+0x60/0x60 [libahci]
[   16.171533]  [] ? ahci_port_thread_fn+0x600/0x600 [libahci]
[   16.171533]  [] devm_request_threaded_irq+0x5f/0xc0
[   16.171533]  [] ahci_host_activate+0x80/0x220 [libahci]
[   16.171533]  [] ? pcibios_set_master+0x5a/0x90
[   16.171533]  [] ahci_init_one+0x8c5/0xb60 [ahci]
[   16.171533]  [] local_pci_probe+0x45/0xa0
[   16.171533]  [] ? pci_match_device+0xe5/0x110
[   16.171533]  [] pci_device_probe+0xd1/0x120
[   16.171533]  [] driver_probe_device+0x90/0x3e0
[   16.171533]  [] __driver_attach+0x9b/0xa0
[   16.171533]  [] ? __device_attach+0x40/0x40
[   16.171533]  [] bus_for_each_dev+0x6b/0xb0
[   16.171533]  [] driver_attach+0x1e/0x20
[   16.171533]  [] bus_add_driver+0x180/0x250
[   16.171533]  [] ? 0xa002c000
[   16.171533]  [] driver_register+0x64/0xf0
[   16.171533]  [] __pci_register_driver+0x4c/0x50
[   16.171533]  [] ahci_pci_driver_init+0x1e/0x1000 [ahci]
[   16.171533]  [] do_one_initcall+0xc0/0x1f0
[   16.171533]  [] ? __vunmap+0xa2/0x100
[   16.171533]  [] load_module+0x15c1/0x1a60
[   16.171533]  [] ? store_uevent+0x40/0x40
[   16.171533]  [] SyS_finit_module+0x86/0xb0
[   16.171533]  [] system_call_fastpath+0x12/0x17
[   16.403261] ahci: probe of :00:1f.2 failed with error -16
[   16.409519] EDAC MC0: Giving out device to module i5000_edac.c controller 
I5000: DEV :00:10.0 (POLLED)
[   16.419702] EDAC PCI0: Giving out device to module i5000_edac controller 
EDAC PCI controller: DEV :00:10.0 (POLLED)
[0.00] Initializing cgroup subsys cpuset
[0.00] Initializing cgroup subsys cpu
[0.00] Linux version 3.18.0-rc2-wl-ga4fb664 (kbuild@xian) (gcc version 
4.9.1 (Debian 4.9.1-19) ) #1 SMP Fri Oct 31 23:24:12 CST 2014
[0.00] Command line: user=lkp 
job=/lkp/scheduled/client5/boot_boot-performance-1-x86_64-rhel-a4fb6646dd55a6ba18df37134e9a22088da0a0db-0.yaml
 ARCH=x86_64 
BOOT_IMAGE=/kernel/x86_64-rhel/a4fb6646dd55a6ba18df37134e9a22088da0a0db/vmlinuz-3.18.0-rc2-wl-ga4fb664
 kconfig=x86_64-rhel commit=a4fb6646dd55a6ba18df37134e9a22088da0a0db 
branch=linux-devel/devel-hourly-2014103123 root=/dev/ram0 max_uptime=3600 
RESULT_ROOT=/result/client5/boot/performance-1/debian-x86_64.cgz/x86_64-rhel/a4fb6646dd55a6ba18df37134e9a22088da0a0db/0
 LKP_SERVER=10.239.97.14 ip=client5::dhcp earlyprintk=ttyS0,115200 debug 
apic=debug sysrq_always_enabled rcupdate.rcu_cpu_stall_timeout=100 panic=-1 
softlockup_panic=1 nmi_watchdog=panic oops=panic load_ramdisk=2 
prompt_ramdisk=0 console=ttyS0,115200 console=tty0 vga=normal rw
[0.00] e820: BIOS-provided physical RAM map:
[0.00] BIOS-e820: [mem 0x0100-0x0009ebff] usable
[0.00] BIOS-e820: [mem 0x0009ec00-0x000f] reserved
[0.00] BIOS-e820: [mem 0x0010-0x9e259fff] usable
[0.00] BIOS-e820: [mem 0x9e25a000-0x9e320fff] ACPI NVS
[0.00] BIOS-e820: [mem 0x9e321000-0x9fa31fff] usable
[0.00] BIOS-e820: [mem 0x9fa32000-0x9fa99fff] reserved
[0.00] BIOS-e820: [mem 0x9fa9a000-0x9faa8fff] usable
[0.00] BIOS-e820: [mem 0x9faa9000-0x9fb19fff] ACPI NVS
[0.00] BIOS-e820: [mem 

Re: absurdly high "optimal_io_size" on Seagate SAS disk

2014-11-06 Thread Chris Friesen

On 11/06/2014 07:56 PM, Martin K. Petersen wrote:

"Chris" == Chris Friesen  writes:


Chris,

Chris> For a RAID card I expect it would be related to chunk size or
Chris> stripe width or something...but even then I would expect to be
Chris> able to cap it at 100MB or so.  Or are there storage systems on
Chris> really fast interfaces that could legitimately want a hundred meg
Chris> of data at a time?

Well, there are several devices that report their capacity to indicate
that they don't suffer any performance (RMW) penalties for large
commands regardless of size. I would personally prefer them to report 0
in that case.


I got curious and looked at the spec at 
"http://www.13thmonkey.org/documentation/SCSI/sbc3r25.pdf;.  I'm now 
wondering if maybe linux is misbehaving.


I think there is actually some justification for putting a huge value in 
the "optimal transfer length" field.  That field is described as "the 
optimal transfer length in blocks for a single...command", but then 
later it has "If a device server receives a request with a transfer 
length exceeding this value, then a significant delay in processing the 
request may be incurred."  As written, it is ambiguous.


Looking at "ftp://ftp.t10.org/t10/document.03/03-028r2.pdf; it appears 
that originally that field was the "optimal maximum transfer length", 
not the "optimal transfer length".  It appears that the intent was that 
the device was able to take requests up to the "maximum transfer 
length", but there would be a performance penalty if you went over the 
"optimum maximum transfer length".


Section E.4 in "sbc3r25.pdf" talks about optimizing transfers.  They 
suggest using a transfer length that is a multiple of "optimal transfer 
length granularity", up to a max of either the max or optimal transfer 
lengths depending on the size of the penalty if you exceed the optimal 
transfer length.  This reinforces the idea that the "optimal transfer 
length" is actually the optimal *maximum* length, but any multiple of 
the optimal granularity is fine.


Based on that, I think it would have been clearer if it had been called 
"/sys/block/sdb/queue/optimal_max_io_size".


Also, I think it's wrong for filesystems and userspace to use it for 
alignment.  In E.4 and E.5 in the "sbc3r25.pdf" doc, it looks like they 
use the optimal granularity field for alignment, not the optimal 
transfer length.



So for the ST900MM0006, it had:

# sg_inq --vpd --page=0xb0 /dev/sdb
VPD INQUIRY: Block limits page (SBC)
  Optimal transfer length granularity: 1 blocks
  Maximum transfer length: 0 blocks
  Optimal transfer length: 4294967295 blocks

In this case I think the drive is trying to say that it doesn't require 
any special granularity (can handle alignment on 512-byte blocks), and 
that it can handle any size of transfer without performance penalty.


Chris
--
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 1/4] input: touchscreen: ti_am335x_tsc Interchange touchscreen and ADC steps

2014-11-06 Thread Vignesh R


On Thursday 06 November 2014 07:49 PM, Richard Cochran wrote:
> On Mon, Oct 27, 2014 at 04:38:28PM +0530, Vignesh R wrote:
> 
> ...
> 
>> @@ -209,6 +214,7 @@ static void titsc_read_coordinates(struct titsc *ts_dev,
>>  unsigned int read, diff;
>>  unsigned int i, channel;
>>  unsigned int creads = ts_dev->coordinate_readouts;
>> +unsigned int first_step = TOTAL_STEPS - (creads * 2 + 2);
>>  
>>  *z1 = *z2 = 0;
>>  if (fifocount % (creads * 2 + 2))
>> @@ -226,7 +232,7 @@ static void titsc_read_coordinates(struct titsc *ts_dev,
>>  
>>  channel = (read & 0xf) >> 16;
>>  read &= 0xfff;
>> -if (channel < creads) {
>> +if (channel > first_step + creads + 2) {
>>  diff = abs(read - prev_val_x);
>>  if (diff < prev_diff_x) {
>>  prev_diff_x = diff;
>> @@ -234,19 +240,19 @@ static void titsc_read_coordinates(struct titsc 
>> *ts_dev,
>>  }
>>  prev_val_x = read;
>>  
>> -} else if (channel < creads * 2) {
>> +} else if (channel == first_step + creads + 1) {
>> +*z1 = read;
>> +
>> +} else if (channel == first_step + creads + 2) {
>> +*z2 = read;
>> +
>> +} else if (channel > first_step) {
>>  diff = abs(read - prev_val_y);
>>  if (diff < prev_diff_y) {
>>  prev_diff_y = diff;
>>  *y = read;
> 
> While you are at it, please get rid of the this "delta filter"
> nonsense.

Currently, there is too much noise in the TSC hardware that is being
removed by delta filtering. I tested TSC unit by removing filtering
logic, the performance was not at all satisfactory. The cursor jumps
wayward and smooth circles cannot be drawn. Looks like delta filtering
cannot be removed as of now. May be I will try and address it in future.

Regards
Vignesh

> 
> Thanks,
> Richard
> 
>>  }
>>  prev_val_y = read;
>> -
>> -} else if (channel < creads * 2 + 1) {
>> -*z1 = read;
>> -
>> -} else if (channel < creads * 2 + 2) {
>> -*z2 = read;
>>  }
>>  }
>>  }
>> -- 
>> 1.9.1
>>
>>
>> ___
>> linux-arm-kernel mailing list
>> linux-arm-ker...@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
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 11/13] clk: tegra: Add EMC clock driver

2014-11-06 Thread Alexandre Courbot
On Thu, Nov 6, 2014 at 8:41 PM, Mikko Perttunen
 wrote:
> On 11/06/2014 10:04 AM, Alexandre Courbot wrote:
>>
>> On 10/30/2014 01:22 AM, Tomeu Vizoso wrote:
>>>
>>> From: Mikko Perttunen 
>>>
>>> The driver is currently only tested on Tegra124 Jetson TK1, but should
>>> work with other Tegra124 boards, provided that correct EMC tables are
>>> provided through the device tree. Older chip models have differing
>>> timing change sequences, so they are not currently supported.
>>>
>>> Signed-off-by: Mikko Perttunen 
>>> Signed-off-by: Tomeu Vizoso 
>>>
>>> ---
>>>
>>> v3:* Add some locking to protect the registers that are shared
>>> with the MC
>>>   clock
>>>
>>> v2:* Make sure that the clock is properly registered
>>> * Bail out early from attempts to set the same rate
>>> ---
>>>   drivers/clk/tegra/Makefile   |   2 +-
>>>   drivers/clk/tegra/clk-emc.c  | 470
>>> +++
>>>   drivers/clk/tegra/clk-tegra124.c |   4 +-
>>>   drivers/clk/tegra/clk.h  |   2 +
>>>   4 files changed, 476 insertions(+), 2 deletions(-)
>>>   create mode 100644 drivers/clk/tegra/clk-emc.c
>>>
>>> diff --git a/drivers/clk/tegra/Makefile b/drivers/clk/tegra/Makefile
>>> index f7dfb72..240e5b4 100644
>>> --- a/drivers/clk/tegra/Makefile
>>> +++ b/drivers/clk/tegra/Makefile
>>> @@ -14,4 +14,4 @@ obj-y+= clk-tegra-super-gen4.o
>>>   obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += clk-tegra20.o
>>>   obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += clk-tegra30.o
>>>   obj-$(CONFIG_ARCH_TEGRA_114_SOC)+= clk-tegra114.o
>>> -obj-$(CONFIG_ARCH_TEGRA_124_SOC)+= clk-tegra124.o
>>> +obj-$(CONFIG_ARCH_TEGRA_124_SOC)+= clk-tegra124.o clk-emc.o
>>> diff --git a/drivers/clk/tegra/clk-emc.c b/drivers/clk/tegra/clk-emc.c
>>> new file mode 100644
>>> index 000..182a059
>>> --- /dev/null
>>> +++ b/drivers/clk/tegra/clk-emc.c
>>> @@ -0,0 +1,470 @@
>>> +/*
>>> + * drivers/clk/tegra/clk-emc.c
>>> + *
>>> + * Copyright (c) 2014, NVIDIA CORPORATION.  All rights reserved.
>>> + *
>>> + * Author:
>>> + *Mikko Perttunen 
>>> + *
>>> + * This software is licensed under the terms of the GNU General Public
>>> + * License version 2, as published by the Free Software Foundation, and
>>> + * may be copied, distributed, and modified under those terms.
>>> + *
>>> + * 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 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include 
>>> +#include 
>>> +
>>> +#define CLK_SOURCE_EMC 0x19c
>>> +
>>> +#define CLK_SOURCE_EMC_EMC_2X_CLK_DIVISOR_SHIFT 0
>>> +#define CLK_SOURCE_EMC_EMC_2X_CLK_DIVISOR_MASK 0xff
>>> +#define CLK_SOURCE_EMC_EMC_2X_CLK_DIVISOR(x) (((x) &
>>> CLK_SOURCE_EMC_EMC_2X_CLK_DIVISOR_MASK) << \
>>> +  CLK_SOURCE_EMC_EMC_2X_CLK_DIVISOR_SHIFT)
>>> +
>>> +#define CLK_SOURCE_EMC_EMC_2X_CLK_SRC_SHIFT 29
>>> +#define CLK_SOURCE_EMC_EMC_2X_CLK_SRC_MASK 0x7
>>> +#define CLK_SOURCE_EMC_EMC_2X_CLK_SRC(x) (((x) &
>>> CLK_SOURCE_EMC_EMC_2X_CLK_SRC_MASK) << \
>>> +  CLK_SOURCE_EMC_EMC_2X_CLK_SRC_SHIFT)
>>> +
>>> +const char *emc_parent_clk_names[] = {
>>> +"pll_m", "pll_c", "pll_p", "clk_m", "pll_m_ud",
>>> +"pll_c2", "pll_c3", "pll_c_ud"
>>> +};
>>> +
>>> +/* List of clock sources for various parents the EMC clock can have.
>>> + * When we change the timing to a timing with a parent that has the same
>>> + * clock source as the current parent, we must first change to a backup
>>> + * timing that has a different clock source.
>>> + */
>>
>>
>> Nit: comment style throughout this file.
>>
>>> +
>>> +#define EMC_SRC_PLL_M 0
>>> +#define EMC_SRC_PLL_C 1
>>> +#define EMC_SRC_PLL_P 2
>>> +#define EMC_SRC_CLK_M 3
>>> +#define EMC_SRC_PLL_C2 4
>>> +#define EMC_SRC_PLL_C3 5
>>> +const char emc_parent_clk_sources[] = {
>>> +EMC_SRC_PLL_M, EMC_SRC_PLL_C, EMC_SRC_PLL_P, EMC_SRC_CLK_M,
>>> +EMC_SRC_PLL_M, EMC_SRC_PLL_C2, EMC_SRC_PLL_C3, EMC_SRC_PLL_C
>>> +};
>>> +
>>> +struct emc_timing {
>>> +unsigned long rate, parent_rate;
>>> +u8 parent_index;
>>> +struct clk *parent;
>>> +u32 ram_code;
>>> +};
>>> +
>>> +struct tegra_emc {
>>> +struct clk_hw hw;
>>> +void __iomem *clk_regs;
>>> +struct clk *prev_parent;
>>> +bool changing_timing;
>>> +
>>> +int num_timings;
>>> +struct emc_timing *timings;
>>> +spinlock_t *lock;
>>> +};
>>> +
>>> +/* * * * * * * * * * * * * * * * * * * * * * * * * *
>>> + * Common clock framework callback implementations *
>>> + * * * * * * * * * * * * * * * * * * * * * * * * * */
>>> +
>>> +unsigned long emc_recalc_rate(struct clk_hw *hw, unsigned long
>>> parent_rate)
>>
>>
>> 

[tip:perf/core] perf tools: Add branch type to db export

2014-11-06 Thread tip-bot for Adrian Hunter
Commit-ID:  f2bff007679e7d293cb07bb26e18ccf11cc1c4b2
Gitweb: http://git.kernel.org/tip/f2bff007679e7d293cb07bb26e18ccf11cc1c4b2
Author: Adrian Hunter 
AuthorDate: Thu, 30 Oct 2014 16:09:43 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 3 Nov 2014 18:06:40 -0300

perf tools: Add branch type to db export

Add the ability to export branch types through the database export
facility.

Signed-off-by: Adrian Hunter 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1414678188-14946-3-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/db-export.c | 48 +
 tools/perf/util/db-export.h |  6 ++
 2 files changed, 54 insertions(+)

diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index be128b0..bccb831 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -208,6 +208,15 @@ static int db_ids_from_al(struct db_export *dbe, struct 
addr_location *al,
return 0;
 }
 
+int db_export__branch_type(struct db_export *dbe, u32 branch_type,
+  const char *name)
+{
+   if (dbe->export_branch_type)
+   return dbe->export_branch_type(dbe, branch_type, name);
+
+   return 0;
+}
+
 int db_export__sample(struct db_export *dbe, union perf_event *event,
  struct perf_sample *sample, struct perf_evsel *evsel,
  struct thread *thread, struct addr_location *al)
@@ -268,3 +277,42 @@ int db_export__sample(struct db_export *dbe, union 
perf_event *event,
 
return 0;
 }
+
+static struct {
+   u32 branch_type;
+   const char *name;
+} branch_types[] = {
+   {0, "no branch"},
+   {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL, "call"},
+   {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN, "return"},
+   {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CONDITIONAL, "conditional jump"},
+   {PERF_IP_FLAG_BRANCH, "unconditional jump"},
+   {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_INTERRUPT,
+"software interrupt"},
+   {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_INTERRUPT,
+"return from interrupt"},
+   {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_SYSCALLRET,
+"system call"},
+   {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_SYSCALLRET,
+"return from system call"},
+   {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_ASYNC, "asynchronous branch"},
+   {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_ASYNC |
+PERF_IP_FLAG_INTERRUPT, "hardware interrupt"},
+   {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TX_ABORT, "transaction abort"},
+   {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_BEGIN, "trace begin"},
+   {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_END, "trace end"},
+   {0, NULL}
+};
+
+int db_export__branch_types(struct db_export *dbe)
+{
+   int i, err = 0;
+
+   for (i = 0; branch_types[i].name ; i++) {
+   err = db_export__branch_type(dbe, branch_types[i].branch_type,
+branch_types[i].name);
+   if (err)
+   break;
+   }
+   return err;
+}
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
index b3643e8..e4baa45 100644
--- a/tools/perf/util/db-export.h
+++ b/tools/perf/util/db-export.h
@@ -54,6 +54,8 @@ struct db_export {
  struct machine *machine);
int (*export_symbol)(struct db_export *dbe, struct symbol *sym,
 struct dso *dso);
+   int (*export_branch_type)(struct db_export *dbe, u32 branch_type,
+ const char *name);
int (*export_sample)(struct db_export *dbe, struct export_sample *es);
u64 evsel_last_db_id;
u64 machine_last_db_id;
@@ -79,8 +81,12 @@ int db_export__dso(struct db_export *dbe, struct dso *dso,
   struct machine *machine);
 int db_export__symbol(struct db_export *dbe, struct symbol *sym,
  struct dso *dso);
+int db_export__branch_type(struct db_export *dbe, u32 branch_type,
+  const char *name);
 int db_export__sample(struct db_export *dbe, union perf_event *event,
  struct perf_sample *sample, struct perf_evsel *evsel,
  struct thread *thread, struct addr_location *al);
 
+int db_export__branch_types(struct db_export *dbe);
+
 #endif
--
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/core] perf script perl: Removing event cache as it' s no longer needed

2014-11-06 Thread tip-bot for Jiri Olsa
Commit-ID:  cdae2d1e936457bf72673cb77e7f5f4b9d4c451e
Gitweb: http://git.kernel.org/tip/cdae2d1e936457bf72673cb77e7f5f4b9d4c451e
Author: Jiri Olsa 
AuthorDate: Sun, 26 Oct 2014 23:44:04 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 6 Nov 2014 17:42:47 -0300

perf script perl: Removing event cache as it's no longer needed

We don't need to maintain cache of 'struct event_format' objects.
Currently the 'struct perf_evsel' holds this reference already.

Adding events_defined bitmap to keep track of defined events, which is
much cheaper than array of pointers.

Signed-off-by: Jiri Olsa 
Acked-by: Namhyung Kim 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1414363445-22370-2-git-send-email-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 .../perf/util/scripting-engines/trace-event-perl.c | 29 +-
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c 
b/tools/perf/util/scripting-engines/trace-event-perl.c
index 0a01bac..22ebc46 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "../util.h"
 #include 
@@ -57,7 +58,7 @@ INTERP my_perl;
 #define FTRACE_MAX_EVENT   \
((1 << (sizeof(unsigned short) * 8)) - 1)
 
-struct event_format *events[FTRACE_MAX_EVENT];
+static DECLARE_BITMAP(events_defined, FTRACE_MAX_EVENT);
 
 extern struct scripting_context *scripting_context;
 
@@ -238,35 +239,15 @@ static void define_event_symbols(struct event_format 
*event,
define_event_symbols(event, ev_name, args->next);
 }
 
-static inline struct event_format *find_cache_event(struct perf_evsel *evsel)
-{
-   static char ev_name[256];
-   struct event_format *event;
-   int type = evsel->attr.config;
-
-   if (events[type])
-   return events[type];
-
-   events[type] = event = evsel->tp_format;
-   if (!event)
-   return NULL;
-
-   sprintf(ev_name, "%s::%s", event->system, event->name);
-
-   define_event_symbols(event, ev_name, event->print_fmt.args);
-
-   return event;
-}
-
 static void perl_process_tracepoint(struct perf_sample *sample,
struct perf_evsel *evsel,
struct thread *thread)
 {
+   struct event_format *event = evsel->tp_format;
struct format_field *field;
static char handler[256];
unsigned long long val;
unsigned long s, ns;
-   struct event_format *event;
int pid;
int cpu = sample->cpu;
void *data = sample->raw_data;
@@ -278,7 +259,6 @@ static void perl_process_tracepoint(struct perf_sample 
*sample,
if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
return;
 
-   event = find_cache_event(evsel);
if (!event)
die("ug! no event found for type %" PRIu64, 
(u64)evsel->attr.config);
 
@@ -286,6 +266,9 @@ static void perl_process_tracepoint(struct perf_sample 
*sample,
 
sprintf(handler, "%s::%s", event->system, event->name);
 
+   if (!test_and_set_bit(event->id, events_defined))
+   define_event_symbols(event, handler, event->print_fmt.args);
+
s = nsecs / NSECS_PER_SEC;
ns = nsecs - s * NSECS_PER_SEC;
 
--
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/core] perf evsel: Do not call pevent_free_format when deleting tracepoint

2014-11-06 Thread tip-bot for Jiri Olsa
Commit-ID:  daa01794a4a36a1da1b09a529adec0c8c0b94ab2
Gitweb: http://git.kernel.org/tip/daa01794a4a36a1da1b09a529adec0c8c0b94ab2
Author: Jiri Olsa 
AuthorDate: Tue, 4 Nov 2014 11:55:38 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 6 Nov 2014 17:47:14 -0300

perf evsel: Do not call pevent_free_format when deleting tracepoint

The libtraceevent library's main handle 'struct pevent' holds pointers
of every event that was added to it via functions:

  pevent_parse_format
  pevent_parse_event

We can't release struct event_format (call pevent_free_format)
separately, because that breaks that pointers array mentioned above and
another add_event call could end up with segfault.

All added events are released within the handle cleanup in pevent_free.

Signed-off-by: Jiri Olsa 
Cc: Corey Ashford 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Steven Rostedt 
Link: http://lkml.kernel.org/r/1415098538-1512-1-git-send-email-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/evsel.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 2f9e680..12b4396 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -853,8 +853,6 @@ void perf_evsel__exit(struct perf_evsel *evsel)
perf_evsel__free_id(evsel);
close_cgroup(evsel->cgrp);
zfree(>group_name);
-   if (evsel->tp_format)
-   pevent_free_format(evsel->tp_format);
zfree(>name);
perf_evsel__object.fini(evsel);
 }
--
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/core] perf tools: Add a thread stack for synthesizing call chains

2014-11-06 Thread tip-bot for Adrian Hunter
Commit-ID:  00447ccdf3335ea467841fc3c7d65ffd30748895
Gitweb: http://git.kernel.org/tip/00447ccdf3335ea467841fc3c7d65ffd30748895
Author: Adrian Hunter 
AuthorDate: Thu, 30 Oct 2014 16:09:42 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 3 Nov 2014 17:10:59 -0300

perf tools: Add a thread stack for synthesizing call chains

Add a thread stack for synthesizing call chains from call and return
events.

Signed-off-by: Adrian Hunter 
Acked-by: Jiri Olsa 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1414678188-14946-2-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Makefile.perf   |   2 +
 tools/perf/util/event.h|  26 
 tools/perf/util/thread-stack.c | 172 +
 .../kxcjk_1013.h => tools/perf/util/thread-stack.h |  22 ++-
 tools/perf/util/thread.c   |   3 +
 tools/perf/util/thread.h   |   3 +
 6 files changed, 222 insertions(+), 6 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 3caf7da..0ebcc4a 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -317,6 +317,7 @@ LIB_H += ui/util.h
 LIB_H += ui/ui.h
 LIB_H += util/data.h
 LIB_H += util/kvm-stat.h
+LIB_H += util/thread-stack.h
 
 LIB_OBJS += $(OUTPUT)util/abspath.o
 LIB_OBJS += $(OUTPUT)util/alias.o
@@ -394,6 +395,7 @@ LIB_OBJS += $(OUTPUT)util/srcline.o
 LIB_OBJS += $(OUTPUT)util/data.o
 LIB_OBJS += $(OUTPUT)util/tsc.o
 LIB_OBJS += $(OUTPUT)util/cloexec.o
+LIB_OBJS += $(OUTPUT)util/thread-stack.o
 
 LIB_OBJS += $(OUTPUT)ui/setup.o
 LIB_OBJS += $(OUTPUT)ui/helpline.o
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 8c7fe9d..7be3897 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -143,6 +143,32 @@ struct branch_stack {
struct branch_entry entries[0];
 };
 
+enum {
+   PERF_IP_FLAG_BRANCH = 1ULL << 0,
+   PERF_IP_FLAG_CALL   = 1ULL << 1,
+   PERF_IP_FLAG_RETURN = 1ULL << 2,
+   PERF_IP_FLAG_CONDITIONAL= 1ULL << 3,
+   PERF_IP_FLAG_SYSCALLRET = 1ULL << 4,
+   PERF_IP_FLAG_ASYNC  = 1ULL << 5,
+   PERF_IP_FLAG_INTERRUPT  = 1ULL << 6,
+   PERF_IP_FLAG_TX_ABORT   = 1ULL << 7,
+   PERF_IP_FLAG_TRACE_BEGIN= 1ULL << 8,
+   PERF_IP_FLAG_TRACE_END  = 1ULL << 9,
+   PERF_IP_FLAG_IN_TX  = 1ULL << 10,
+};
+
+#define PERF_BRANCH_MASK   (\
+   PERF_IP_FLAG_BRANCH |\
+   PERF_IP_FLAG_CALL   |\
+   PERF_IP_FLAG_RETURN |\
+   PERF_IP_FLAG_CONDITIONAL|\
+   PERF_IP_FLAG_SYSCALLRET |\
+   PERF_IP_FLAG_ASYNC  |\
+   PERF_IP_FLAG_INTERRUPT  |\
+   PERF_IP_FLAG_TX_ABORT   |\
+   PERF_IP_FLAG_TRACE_BEGIN|\
+   PERF_IP_FLAG_TRACE_END)
+
 struct perf_sample {
u64 ip;
u32 pid, tid;
diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c
new file mode 100644
index 000..85b60d2
--- /dev/null
+++ b/tools/perf/util/thread-stack.c
@@ -0,0 +1,172 @@
+/*
+ * thread-stack.c: Synthesize a thread's stack using call / return events
+ * Copyright (c) 2014, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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 "thread.h"
+#include "event.h"
+#include "util.h"
+#include "debug.h"
+#include "thread-stack.h"
+
+#define STACK_GROWTH 4096
+
+struct thread_stack_entry {
+   u64 ret_addr;
+};
+
+struct thread_stack {
+   struct thread_stack_entry *stack;
+   size_t cnt;
+   size_t sz;
+   u64 trace_nr;
+};
+
+static int thread_stack__grow(struct thread_stack *ts)
+{
+   struct thread_stack_entry *new_stack;
+   size_t sz, new_sz;
+
+   new_sz = ts->sz + STACK_GROWTH;
+   sz = new_sz * sizeof(struct thread_stack_entry);
+
+   new_stack = realloc(ts->stack, sz);
+   if (!new_stack)
+   return -ENOMEM;
+
+   ts->stack = new_stack;
+   ts->sz = new_sz;
+
+   return 0;
+}
+
+static struct thread_stack *thread_stack__new(void)
+{
+   struct thread_stack *ts;
+
+   ts = zalloc(sizeof(struct thread_stack));
+   if (!ts)
+   return NULL;
+
+   if (thread_stack__grow(ts)) {
+   free(ts);
+   return 

[tip:perf/core] perf script python: Removing event cache as it' s no longer needed

2014-11-06 Thread tip-bot for Jiri Olsa
Commit-ID:  adf5bcf39583c4db1bf30069f8957400e61ccb18
Gitweb: http://git.kernel.org/tip/adf5bcf39583c4db1bf30069f8957400e61ccb18
Author: Jiri Olsa 
AuthorDate: Sun, 26 Oct 2014 23:44:05 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 6 Nov 2014 17:44:06 -0300

perf script python: Removing event cache as it's no longer needed

We don't need to maintain cache of 'struct event_format' objects.
Currently the 'struct perf_evsel' holds this reference already.

Adding events_defined bitmap to keep track of defined events, which is
much cheaper than array of pointers.

Signed-off-by: Jiri Olsa 
Acked-by: Namhyung Kim 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1414363445-22370-3-git-send-email-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 .../util/scripting-engines/trace-event-python.c| 34 --
 1 file changed, 6 insertions(+), 28 deletions(-)

diff --git a/tools/perf/util/scripting-engines/trace-event-python.c 
b/tools/perf/util/scripting-engines/trace-event-python.c
index 118bc62..d808a32 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "../../perf.h"
 #include "../debug.h"
@@ -46,7 +47,7 @@ PyMODINIT_FUNC initperf_trace_context(void);
 #define FTRACE_MAX_EVENT   \
((1 << (sizeof(unsigned short) * 8)) - 1)
 
-struct event_format *events[FTRACE_MAX_EVENT];
+static DECLARE_BITMAP(events_defined, FTRACE_MAX_EVENT);
 
 #define MAX_FIELDS 64
 #define N_COMMON_FIELDS7
@@ -255,31 +256,6 @@ static void define_event_symbols(struct event_format 
*event,
define_event_symbols(event, ev_name, args->next);
 }
 
-static inline struct event_format *find_cache_event(struct perf_evsel *evsel)
-{
-   static char ev_name[256];
-   struct event_format *event;
-   int type = evsel->attr.config;
-
-   /*
-* XXX: Do we really need to cache this since now we have 
evsel->tp_format
-* cached already? Need to re-read this "cache" routine that as well 
calls
-* define_event_symbols() :-\
-*/
-   if (events[type])
-   return events[type];
-
-   events[type] = event = evsel->tp_format;
-   if (!event)
-   return NULL;
-
-   sprintf(ev_name, "%s__%s", event->system, event->name);
-
-   define_event_symbols(event, ev_name, event->print_fmt.args);
-
-   return event;
-}
-
 static PyObject *get_field_numeric_entry(struct event_format *event,
struct format_field *field, void *data)
 {
@@ -403,12 +379,12 @@ static void python_process_tracepoint(struct perf_sample 
*sample,
  struct thread *thread,
  struct addr_location *al)
 {
+   struct event_format *event = evsel->tp_format;
PyObject *handler, *context, *t, *obj, *callchain;
PyObject *dict = NULL;
static char handler_name[256];
struct format_field *field;
unsigned long s, ns;
-   struct event_format *event;
unsigned n = 0;
int pid;
int cpu = sample->cpu;
@@ -420,7 +396,6 @@ static void python_process_tracepoint(struct perf_sample 
*sample,
if (!t)
Py_FatalError("couldn't create Python tuple");
 
-   event = find_cache_event(evsel);
if (!event)
die("ug! no event found for type %d", (int)evsel->attr.config);
 
@@ -428,6 +403,9 @@ static void python_process_tracepoint(struct perf_sample 
*sample,
 
sprintf(handler_name, "%s__%s", event->system, event->name);
 
+   if (!test_and_set_bit(event->id, events_defined))
+   define_event_symbols(event, handler_name, 
event->print_fmt.args);
+
handler = get_handler(handler_name);
if (!handler) {
dict = PyDict_New();
--
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/core] perf tools: Make vmlinux short name more like kallsyms short name

2014-11-06 Thread tip-bot for Namhyung Kim
Commit-ID:  96d78059d6d9da45d77078a219924304860497f2
Gitweb: http://git.kernel.org/tip/96d78059d6d9da45d77078a219924304860497f2
Author: Namhyung Kim 
AuthorDate: Tue, 4 Nov 2014 10:14:34 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 5 Nov 2014 10:14:09 -0300

perf tools: Make vmlinux short name more like kallsyms short name

The previous patch changed kernel dso name from '[kernel.kallsyms]' to
vmlinux.  However it might add confusion to old users accustomed to the
old name.  So change the short name to '[kernel.vmlinux]' to reduce such
confusion.

Before:
  # Overhead  Command Shared ObjectSymbol
  #   ..  ...  
...
  #
   9.83%  swapper vmlinux  [k] intel_idle
   4.10%  awk libc-2.20.so [.] __strcmp_sse2
   1.86%  sed libc-2.20.so [.] __strcmp_sse2
   1.78%  netctl-auto libc-2.20.so [.] __strcmp_sse2
   1.23%  netctl-auto libc-2.20.so [.] __mbrtowc
   1.21%  firefox libxul.so[.] 0x024b62bd
   1.20%  swapper vmlinux  [k] cpuidle_enter_state
   1.03%  sleep   vmlinux  [k] 
copy_user_generic_unrolled

After:
  # Overhead  Command Shared ObjectSymbol
  #   ..  ...  
...
  #
   9.83%  swapper [kernel.vmlinux] [k] intel_idle
   4.10%  awk libc-2.20.so [.] __strcmp_sse2
   1.86%  sed libc-2.20.so [.] __strcmp_sse2
   1.78%  netctl-auto libc-2.20.so [.] __strcmp_sse2
   1.23%  netctl-auto libc-2.20.so [.] __mbrtowc
   1.21%  firefox libxul.so[.] 0x024b62bd
   1.20%  swapper [kernel.vmlinux] [k] cpuidle_enter_state
   1.03%  sleep   [kernel.vmlinux] [k] 
copy_user_generic_unrolled

Signed-off-by: Namhyung Kim 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1415063674-17206-9-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/machine.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 53f90e9..52e9490 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1106,6 +1106,9 @@ static int machine__process_kernel_mmap_event(struct 
machine *machine,
if (__machine__create_kernel_maps(machine, kernel) < 0)
goto out_problem;
 
+   if (strstr(dso->long_name, "vmlinux"))
+   dso__set_short_name(dso, "[kernel.vmlinux]", false);
+
machine__set_kernel_mmap_len(machine, event);
 
/*
--
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/core] perf tools: Add test_and_set_bit function

2014-11-06 Thread tip-bot for Jiri Olsa
Commit-ID:  416c419cc3799ddf7ea467c9adcb4cd038bd94a4
Gitweb: http://git.kernel.org/tip/416c419cc3799ddf7ea467c9adcb4cd038bd94a4
Author: Jiri Olsa 
AuthorDate: Sun, 26 Oct 2014 23:44:03 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 6 Nov 2014 17:42:13 -0300

perf tools: Add test_and_set_bit function

Set a bit and return its old value. Stolen from kernel sources, will be
used in next patches.

Signed-off-by: Jiri Olsa 
Acked-by: Namhyung Kim 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1414363445-22370-1-git-send-email-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/include/linux/bitmap.h | 17 +
 tools/perf/util/include/linux/bitops.h |  2 ++
 2 files changed, 19 insertions(+)

diff --git a/tools/perf/util/include/linux/bitmap.h 
b/tools/perf/util/include/linux/bitmap.h
index 01ffd12..40bd214 100644
--- a/tools/perf/util/include/linux/bitmap.h
+++ b/tools/perf/util/include/linux/bitmap.h
@@ -46,4 +46,21 @@ static inline void bitmap_or(unsigned long *dst, const 
unsigned long *src1,
__bitmap_or(dst, src1, src2, nbits);
 }
 
+/**
+ * test_and_set_bit - Set a bit and return its old value
+ * @nr: Bit to set
+ * @addr: Address to count from
+ */
+static inline int test_and_set_bit(int nr, unsigned long *addr)
+{
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old;
+
+   old = *p;
+   *p = old | mask;
+
+   return (old & mask) != 0;
+}
+
 #endif /* _PERF_BITOPS_H */
diff --git a/tools/perf/util/include/linux/bitops.h 
b/tools/perf/util/include/linux/bitops.h
index dadfa7e..c329416 100644
--- a/tools/perf/util/include/linux/bitops.h
+++ b/tools/perf/util/include/linux/bitops.h
@@ -15,6 +15,8 @@
 #define BITS_TO_U64(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64))
 #define BITS_TO_U32(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32))
 #define BITS_TO_BYTES(nr)   DIV_ROUND_UP(nr, BITS_PER_BYTE)
+#define BIT_WORD(nr)((nr) / BITS_PER_LONG)
+#define BIT_MASK(nr)(1UL << ((nr) % BITS_PER_LONG))
 
 #define for_each_set_bit(bit, addr, size) \
for ((bit) = find_first_bit((addr), (size));\
--
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/core] perf tools: Add call information to Python export

2014-11-06 Thread tip-bot for Adrian Hunter
Commit-ID:  6a70307ddcd598c399d55dc44c07816a575f
Gitweb: http://git.kernel.org/tip/6a70307ddcd598c399d55dc44c07816a575f
Author: Adrian Hunter 
AuthorDate: Thu, 30 Oct 2014 16:09:47 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 3 Nov 2014 18:10:06 -0300

perf tools: Add call information to Python export

Add the ability to export detailed information about paired calls and
returns to Python db export and the export-to-postgresql.py script.

Signed-off-by: Adrian Hunter 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1414678188-14946-7-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 .../scripts/python/bin/export-to-postgresql-report | 15 ++--
 tools/perf/scripts/python/export-to-postgresql.py  | 66 -
 .../util/scripting-engines/trace-event-python.c| 84 +-
 3 files changed, 158 insertions(+), 7 deletions(-)

diff --git a/tools/perf/scripts/python/bin/export-to-postgresql-report 
b/tools/perf/scripts/python/bin/export-to-postgresql-report
index a8fdd15..cd335b6 100644
--- a/tools/perf/scripts/python/bin/export-to-postgresql-report
+++ b/tools/perf/scripts/python/bin/export-to-postgresql-report
@@ -1,6 +1,6 @@
 #!/bin/bash
 # description: export perf data to a postgresql database
-# args: [database name] [columns]
+# args: [database name] [columns] [calls]
 n_args=0
 for i in "$@"
 do
@@ -9,11 +9,16 @@ do
 fi
 n_args=$(( $n_args + 1 ))
 done
-if [ "$n_args" -gt 2 ] ; then
-echo "usage: export-to-postgresql-report [database name] [columns]"
+if [ "$n_args" -gt 3 ] ; then
+echo "usage: export-to-postgresql-report [database name] [columns] [calls]"
 exit
 fi
-if [ "$n_args" -gt 1 ] ; then
+if [ "$n_args" -gt 2 ] ; then
+dbname=$1
+columns=$2
+calls=$3
+shift 3
+elif [ "$n_args" -gt 1 ] ; then
 dbname=$1
 columns=$2
 shift 2
@@ -21,4 +26,4 @@ elif [ "$n_args" -gt 0 ] ; then
 dbname=$1
 shift
 fi
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/export-to-postgresql.py 
$dbname $columns
+perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/export-to-postgresql.py 
$dbname $columns $calls
diff --git a/tools/perf/scripts/python/export-to-postgresql.py 
b/tools/perf/scripts/python/export-to-postgresql.py
index bb79aec..4cdafd8 100644
--- a/tools/perf/scripts/python/export-to-postgresql.py
+++ b/tools/perf/scripts/python/export-to-postgresql.py
@@ -40,10 +40,12 @@ sys.path.append(os.environ['PERF_EXEC_PATH'] + \
 #from Core import *
 
 perf_db_export_mode = True
+perf_db_export_calls = False
 
 def usage():
-   print >> sys.stderr, "Usage is: export-to-postgresql.py  
[]"
+   print >> sys.stderr, "Usage is: export-to-postgresql.py  
[] []"
print >> sys.stderr, "where:columns 'all' or 'branches'"
+   print >> sys.stderr, "  calls   'calls' => create calls 
table"
raise Exception("Too few arguments")
 
 if (len(sys.argv) < 2):
@@ -61,6 +63,12 @@ if columns not in ("all", "branches"):
 
 branches = (columns == "branches")
 
+if (len(sys.argv) >= 4):
+   if (sys.argv[3] == "calls"):
+   perf_db_export_calls = True
+   else:
+   usage()
+
 output_dir_name = os.getcwd() + "/" + dbname + "-perf-data"
 os.mkdir(output_dir_name)
 
@@ -170,6 +178,25 @@ else:
'branch_typeinteger,'
'in_tx  boolean)')
 
+if perf_db_export_calls:
+   do_query(query, 'CREATE TABLE call_paths ('
+   'id bigint  NOT NULL,'
+   'parent_id  bigint,'
+   'symbol_id  bigint,'
+   'ip bigint)')
+   do_query(query, 'CREATE TABLE calls ('
+   'id bigint  NOT NULL,'
+   'thread_id  bigint,'
+   'comm_idbigint,'
+   'call_path_id   bigint,'
+   'call_time  bigint,'
+   'return_timebigint,'
+   'branch_count   bigint,'
+   'call_idbigint,'
+   'return_id  bigint,'
+   'parent_call_path_idbigint,'
+   'flags  integer)')
+
 do_query(query, 'CREATE VIEW samples_view AS '
'SELECT '
'id,'
@@ -246,6 +273,9 @@ dso_file= open_output_file("dso_table.bin")
 symbol_file= open_output_file("symbol_table.bin")
 branch_type_file   = open_output_file("branch_type_table.bin")
 sample_file= open_output_file("sample_table.bin")
+if perf_db_export_calls:
+   call_path_file  = open_output_file("call_path_table.bin")
+   call_file   = open_output_file("call_table.bin")
 
 def trace_begin():
print datetime.datetime.today(), "Writing to intermediate files..."
@@ -256,6 +286,9 @@ def 

[tip:perf/core] perf tools: Defer export of comms that were not ' set'

2014-11-06 Thread tip-bot for Adrian Hunter
Commit-ID:  758008b262f70be41104e4e33ba99181ac03775d
Gitweb: http://git.kernel.org/tip/758008b262f70be41104e4e33ba99181ac03775d
Author: Adrian Hunter 
AuthorDate: Thu, 30 Oct 2014 16:09:48 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 3 Nov 2014 18:11:59 -0300

perf tools: Defer export of comms that were not 'set'

Tracing for a workload begins before the comm event is seen, which
results in the initial comm having a string of the form ":" (e.g.
":12345").

In order to export the correct string, defer the export until the new
script 'flush' callback.

Signed-off-by: Adrian Hunter 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1414678188-14946-8-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/db-export.c| 62 +-
 tools/perf/util/db-export.h|  3 ++
 .../util/scripting-engines/trace-event-python.c|  4 +-
 3 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index 017ecbb..c81dae3 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -21,17 +21,74 @@
 #include "comm.h"
 #include "symbol.h"
 #include "event.h"
+#include "util.h"
 #include "thread-stack.h"
 #include "db-export.h"
 
+struct deferred_export {
+   struct list_head node;
+   struct comm *comm;
+};
+
+static int db_export__deferred(struct db_export *dbe)
+{
+   struct deferred_export *de;
+   int err;
+
+   while (!list_empty(>deferred)) {
+   de = list_entry(dbe->deferred.next, struct deferred_export,
+   node);
+   err = dbe->export_comm(dbe, de->comm);
+   list_del(>node);
+   free(de);
+   if (err)
+   return err;
+   }
+
+   return 0;
+}
+
+static void db_export__free_deferred(struct db_export *dbe)
+{
+   struct deferred_export *de;
+
+   while (!list_empty(>deferred)) {
+   de = list_entry(dbe->deferred.next, struct deferred_export,
+   node);
+   list_del(>node);
+   free(de);
+   }
+}
+
+static int db_export__defer_comm(struct db_export *dbe, struct comm *comm)
+{
+   struct deferred_export *de;
+
+   de = zalloc(sizeof(struct deferred_export));
+   if (!de)
+   return -ENOMEM;
+
+   de->comm = comm;
+   list_add_tail(>node, >deferred);
+
+   return 0;
+}
+
 int db_export__init(struct db_export *dbe)
 {
memset(dbe, 0, sizeof(struct db_export));
+   INIT_LIST_HEAD(>deferred);
return 0;
 }
 
+int db_export__flush(struct db_export *dbe)
+{
+   return db_export__deferred(dbe);
+}
+
 void db_export__exit(struct db_export *dbe)
 {
+   db_export__free_deferred(dbe);
call_return_processor__free(dbe->crp);
dbe->crp = NULL;
 }
@@ -115,7 +172,10 @@ int db_export__comm(struct db_export *dbe, struct comm 
*comm,
comm->db_id = ++dbe->comm_last_db_id;
 
if (dbe->export_comm) {
-   err = dbe->export_comm(dbe, comm);
+   if (main_thread->comm_set)
+   err = dbe->export_comm(dbe, comm);
+   else
+   err = db_export__defer_comm(dbe, comm);
if (err)
return err;
}
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
index dd5ac2a..adbd22d 100644
--- a/tools/perf/util/db-export.h
+++ b/tools/perf/util/db-export.h
@@ -17,6 +17,7 @@
 #define __PERF_DB_EXPORT_H
 
 #include 
+#include 
 
 struct perf_evsel;
 struct machine;
@@ -74,9 +75,11 @@ struct db_export {
u64 sample_last_db_id;
u64 call_path_last_db_id;
u64 call_return_last_db_id;
+   struct list_head deferred;
 };
 
 int db_export__init(struct db_export *dbe);
+int db_export__flush(struct db_export *dbe);
 void db_export__exit(struct db_export *dbe);
 int db_export__evsel(struct db_export *dbe, struct perf_evsel *evsel);
 int db_export__machine(struct db_export *dbe, struct machine *machine);
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c 
b/tools/perf/util/scripting-engines/trace-event-python.c
index cb1d960..118bc62 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -1030,7 +1030,9 @@ error:
 
 static int python_flush_script(void)
 {
-   return 0;
+   struct tables *tables = _global;
+
+   return db_export__flush(>dbe);
 }
 
 /*
--
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/core] perf record: Do not save pathname in ./debug/ .build-id directory for vmlinux

2014-11-06 Thread tip-bot for Namhyung Kim
Commit-ID:  00dc865798a31d3d5300dd5d70166a4a85f76a20
Gitweb: http://git.kernel.org/tip/00dc865798a31d3d5300dd5d70166a4a85f76a20
Author: Namhyung Kim 
AuthorDate: Tue, 4 Nov 2014 10:14:32 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 5 Nov 2014 10:14:08 -0300

perf record: Do not save pathname in ./debug/.build-id directory for vmlinux

When perf record finishes a session, it pre-processes samples in order
to write build-id info from DSOs that had samples.

During this process it'll call map__load() for the kernel map, and it
ends up calling dso__load_vmlinux_path() which replaces dso->long_name.

But this function checks kernel's build-id before searching vmlinux path
so it'll end up with a cryptic name, the pathname for the entry in the
~/.debug cache, which can be confusing to users.

This patch adds a flag to skip the build-id check during record, so
that it'll have the original vmlinux path for the kernel dso->long_name,
not the entry in the ~/.debug cache.

Before:
  # perf record -va sleep 3
  mmap size 528384B
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.196 MB perf.data (~8545 samples) ]
  Looking at the vmlinux_path (7 entries long)
  Using 
/home/namhyung/.debug/.build-id/f0/6e17aa50adf4d00b88925e03775de107611551 for 
symbols

After:
  # perf record -va sleep 3
  mmap size 528384B
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.193 MB perf.data (~8432 samples) ]
  Looking at the vmlinux_path (7 entries long)
  Using /lib/modules/3.16.4-1-ARCH/build/vmlinux for symbols

Signed-off-by: Namhyung Kim 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1415063674-17206-7-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-record.c | 11 +++
 tools/perf/util/symbol.c| 11 ++-
 tools/perf/util/symbol.h|  1 +
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 5091a27..582c4da 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -200,6 +200,17 @@ static int process_buildids(struct record *rec)
if (size == 0)
return 0;
 
+   /*
+* During this process, it'll load kernel map and replace the
+* dso->long_name to a real pathname it found.  In this case
+* we prefer the vmlinux path like
+*   /lib/modules/3.16.4/build/vmlinux
+*
+* rather than build-id path (in debug directory).
+*   $HOME/.debug/.build-id/f0/6e17aa50adf4d00b88925e03775de107611551
+*/
+   symbol_conf.ignore_vmlinux_buildid = true;
+
return __perf_session__process_events(session, start,
  size - start,
  size, 
_id__mark_dso_hit_ops);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index c69915c..c24c5b8 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1511,12 +1511,10 @@ int dso__load_vmlinux_path(struct dso *dso, struct map 
*map,
   symbol_filter_t filter)
 {
int i, err = 0;
-   char *filename;
+   char *filename = NULL;
 
-   pr_debug("Looking at the vmlinux_path (%d entries long)\n",
-vmlinux_path__nr_entries + 1);
-
-   filename = dso__build_id_filename(dso, NULL, 0);
+   if (!symbol_conf.ignore_vmlinux_buildid)
+   filename = dso__build_id_filename(dso, NULL, 0);
if (filename != NULL) {
err = dso__load_vmlinux(dso, map, filename, true, filter);
if (err > 0)
@@ -1524,6 +1522,9 @@ int dso__load_vmlinux_path(struct dso *dso, struct map 
*map,
free(filename);
}
 
+   pr_debug("Looking at the vmlinux_path (%d entries long)\n",
+vmlinux_path__nr_entries + 1);
+
for (i = 0; i < vmlinux_path__nr_entries; ++i) {
err = dso__load_vmlinux(dso, map, vmlinux_path[i], false, 
filter);
if (err > 0)
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index eb2c19b..ded3ca7 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -105,6 +105,7 @@ struct symbol_conf {
unsigned short  nr_events;
booltry_vmlinux_path,
ignore_vmlinux,
+   ignore_vmlinux_buildid,
show_kernel_path,
use_modules,
sort_by_name,
--
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/core] perf tools: Fix build-id matching on vmlinux

2014-11-06 Thread tip-bot for Namhyung Kim
Commit-ID:  b837a8bdc48925e6512412973b845c53cbe2b412
Gitweb: http://git.kernel.org/tip/b837a8bdc48925e6512412973b845c53cbe2b412
Author: Namhyung Kim 
AuthorDate: Tue, 4 Nov 2014 10:14:33 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 5 Nov 2014 10:14:08 -0300

perf tools: Fix build-id matching on vmlinux

There's a problem on finding correct kernel symbols when perf report
runs on a different kernel.  Although a part of the problem was solved
by the prior commit 0a7e6d1b6844 ("perf tools: Check recorded kernel
version when finding vmlinux"), there's a remaining problem still.

When perf records samples, it synthesizes the kernel map using
machine__mmap_name() and ref_reloc_sym like "[kernel.kallsyms]_text".
You can easily see it using 'perf report -D' command.

After finishing record, it goes through the recorded events to find
maps/dsos actually used.  And then record build-id info of them.

During this process, it needs to load symbols in a dso and it'd call
dso__load_vmlinux_path() since the default value of the symbol_conf.
try_vmlinux_path is true.  However it changes dso->long_name to a real
path of the vmlinux file (e.g. /lib/modules/3.16.4/build/vmlinux) if one
is running on a custom kernel.

It resulted in that perf report reads the build-id of the vmlinux, but
cannot use it since it only knows about the [kernel.kallsyms] map.  It
then falls back to possible vmlinux paths by using the recorded kernel
version (in case of a recent version) or a running kernel silently.

Even with the recent tools, this still has a possibility of breaking
the result.  As the build directory is a symbolic link, if one built a
new kernel in the same directory with different source/config, the old
link to vmlinux will point the new file.  So it's absolutely needed to
use build-id when finding a kernel image.

In this patch, it's now changed to try to search a kernel dso in the
existing dso list which was constructed during build-id table parsing
so it'll always have a build-id.  If not found, search "[kernel.kallsyms]".

Before:

  $ perf report
  # Children  Self  Command  Shared Object  Symbol
  #     ...  .  
...
  #
  72.15% 0.00%  swapper  [kernel.kallsyms]  [k] set_curr_task_rt
  72.15% 0.00%  swapper  [kernel.kallsyms]  [k] native_calibrate_tsc
  72.15% 0.00%  swapper  [kernel.kallsyms]  [k] 
tsc_refine_calibration_work
  71.87%71.87%  swapper  [kernel.kallsyms]  [k] module_finalize
   ...

After (for the same perf.data):

  72.15% 0.00%  swapper  vmlinux  [k] cpu_startup_entry
  72.15% 0.00%  swapper  vmlinux  [k] arch_cpu_idle
  72.15% 0.00%  swapper  vmlinux  [k] default_idle
  71.87%71.87%  swapper  vmlinux  [k] native_safe_halt
   ...

Signed-off-by: Namhyung Kim 
Acked-by: Ingo Molnar 
Link: http://lkml.kernel.org/r/20140924073356.gb1...@gmail.com
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1415063674-17206-8-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/header.c  |  2 +-
 tools/perf/util/machine.c | 16 ++--
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 3e2c156..76442ca 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1269,7 +1269,7 @@ static int __event_process_build_id(struct build_id_event 
*bev,
 
dso__set_build_id(dso, >build_id);
 
-   if (filename[0] == '[')
+   if (!is_kernel_module(filename, NULL))
dso->kernel = dso_type;
 
build_id__sprintf(dso->build_id, sizeof(dso->build_id),
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 946c7d6..53f90e9 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1085,8 +1085,20 @@ static int machine__process_kernel_mmap_event(struct 
machine *machine,
 * Should be there already, from the build-id table in
 * the header.
 */
-   struct dso *kernel = __dsos__findnew(>kernel_dsos,
-kmmap_prefix);
+   struct dso *kernel = NULL;
+   struct dso *dso;
+
+   list_for_each_entry(dso, >kernel_dsos.head, node) {
+   if (is_kernel_module(dso->long_name, NULL))
+   continue;
+
+   kernel = dso;
+   break;
+   }
+
+   if (kernel == NULL)
+   kernel = __dsos__findnew(>kernel_dsos,
+kmmap_prefix);
if (kernel == NULL)
goto out_problem;
 
--
To 

Re: [PATCH v3 04/13] of: document new emc-timings subnode in nvidia,tegra124-car

2014-11-06 Thread Alexandre Courbot

On 11/07/2014 12:12 AM, Rob Herring wrote:

On Thu, Nov 6, 2014 at 12:37 AM, Alexandre Courbot  wrote:

On 10/30/2014 01:22 AM, Tomeu Vizoso wrote:


The EMC clock needs some extra information for changing its rate.

Signed-off-by: Tomeu Vizoso 
---
   .../bindings/clock/nvidia,tegra124-car.txt | 46
+-
   1 file changed, 44 insertions(+), 2 deletions(-)

diff --git
a/Documentation/devicetree/bindings/clock/nvidia,tegra124-car.txt
b/Documentation/devicetree/bindings/clock/nvidia,tegra124-car.txt
index ded5d62..42e0588 100644
--- a/Documentation/devicetree/bindings/clock/nvidia,tegra124-car.txt
+++ b/Documentation/devicetree/bindings/clock/nvidia,tegra124-car.txt
@@ -19,12 +19,35 @@ Required properties :
 In clock consumers, this cell represents the bit number in the CAR's
 array of CLK_RST_CONTROLLER_RST_DEVICES_* registers.

+The node should contain a "emc-timings" subnode for each supported RAM
type (see
+field RAM_CODE in register PMC_STRAPPING_OPT_A), with its unit address
being its
+RAM_CODE.
+
+Required properties for "emc-timings" nodes :
+- nvidia,ram-code : Should contain the value of RAM_CODE this timing set
+  is used for.
+
+Each "emc-timings" node should contain a "timing" subnode for every
supported
+EMC clock rate. The "timing" subnodes should have the clock rate in Hz as
their
+unit address.



This seems to be a quite liberal use of unit addresses (same in the next
patch) - is this allowed by DT?


No, unit address should match a reg property.


Mmm, would you have any suggestion as to how this can be fixed? Right 
now what I can think of is either to replace the "clock-frequency" 
property by "reg" (which would be confusing), or to use a different 
naming scheme, e.g. timing-1275. IIUC the naming is not essential 
for properly parsing these nodes, so maybe the second solution is the 
way to go?





+
+Required properties for "timing" nodes :
+- clock-frequency : Should contain the memory clock rate to which this
timing
+relates.
+- nvidia,parent-clock-frequency : Should contain the rate at which the
current
+parent of the EMC clock should be running at this timing.
+- clocks : Must contain an entry for each entry in clock-names.
+  See ../clocks/clock-bindings.txt for details.
+- clock-names : Must include the following entries:
+  - emc-parent : the clock that should be the parent of the EMC clock at
this
+timing.
+
   Example SoC include file:

   / {
-   tegra_car: clock {
+   tegra_car: clock@0,60006000 {


The comma here is wrong. Commas should be used when you have something
like PCI bus:dev:func for addressing.


 compatible = "nvidia,tegra124-car";
-   reg = <0x60006000 0x1000>;
+   reg = <0x0 0x60006000 0x0 0x1000>;


The number of cell's is really irrelevant to the example.


 #clock-cells = <1>;
 #reset-cells = <1>;
 };
@@ -60,4 +83,23 @@ Example board file:
 _car {
 clocks = <_32k> <>;
 };
+
+   clock@0,60006000 {
+   emc-timings@3 {
+   nvidia,ram-code = <3>;
+
+   timing@1275 {
+   clock-frequency = <1275>;
+   nvidia,parent-clock-frequency =
<40800>;
+   clocks = <_car TEGRA124_CLK_PLL_P>;
+   clock-names = "emc-parent";


Why do you need both clocks and hardcoded values? clock-frequency is
the desired freq you want to set TEGRA124_CLK_PLL_P to?


That would be nvidia,parent-clock-frequency IIUC, while clock-frequency 
is the resulting EMC clock.




The clocks property really belongs as part of the memory controller
node or a memory device node.


I would tend to agree here. Tomeu, does it make sense to move these 
properties to the EMC driver instead?

--
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/core] perf build-id: Rename dsos__write_buildid_table()

2014-11-06 Thread tip-bot for Namhyung Kim
Commit-ID:  714c9c4a98f722115e10d021ea80600f4427b71e
Gitweb: http://git.kernel.org/tip/714c9c4a98f722115e10d021ea80600f4427b71e
Author: Namhyung Kim 
AuthorDate: Tue, 4 Nov 2014 10:14:29 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 5 Nov 2014 10:14:07 -0300

perf build-id: Rename dsos__write_buildid_table()

The dsos__write_buildid_table() is not use struct dso and it mostly
uses perf_session struct.

So rename it to perf_session__write_buildid_ table() so that it
corresponds to other related functions such as
perf_session__read_build_ids() and perf_session__cache_build_ids().

Signed-off-by: Namhyung Kim 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1415063674-17206-4-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/header.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 0ecf4a3..be8d02e 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -297,10 +297,8 @@ static int machine__write_buildid_table(struct machine 
*machine, int fd)
return err;
 }
 
-static int dsos__write_buildid_table(struct perf_header *header, int fd)
+static int perf_session__write_buildid_table(struct perf_session *session, int 
fd)
 {
-   struct perf_session *session = container_of(header,
-   struct perf_session, header);
struct rb_node *nd;
int err = machine__write_buildid_table(>machines.host, fd);
 
@@ -523,7 +521,7 @@ static int write_build_id(int fd, struct perf_header *h,
if (!perf_session__read_build_ids(session, true))
return -1;
 
-   err = dsos__write_buildid_table(h, fd);
+   err = perf_session__write_buildid_table(session, fd);
if (err < 0) {
pr_debug("failed to write buildid table\n");
return err;
--
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/core] perf build-id: Move build-id related functions to util/build-id.c

2014-11-06 Thread tip-bot for Namhyung Kim
Commit-ID:  e195fac8077f034b0160bf420bdf450ae476701d
Gitweb: http://git.kernel.org/tip/e195fac8077f034b0160bf420bdf450ae476701d
Author: Namhyung Kim 
AuthorDate: Tue, 4 Nov 2014 10:14:30 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 5 Nov 2014 10:14:07 -0300

perf build-id: Move build-id related functions to util/build-id.c

It'd be better managing those functions in a separate place as
util/header.c file is already big.

It now exports following 3 functions to others:

  bool perf_session__read_build_ids(struct perf_session *session, bool 
with_hits);
  int perf_session__write_buildid_table(struct perf_session *session, int fd);
  int perf_session__cache_build_ids(struct perf_session *session);

Signed-off-by: Namhyung Kim 
Acked-by: Adrian Hunter 
Link: http://lkml.kernel.org/r/545733e7.6010...@intel.com
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1415063674-17206-5-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/build-id.c | 334 
 tools/perf/util/build-id.h |  11 ++
 tools/perf/util/header.c   | 337 +
 tools/perf/util/header.h   |   8 +-
 4 files changed, 349 insertions(+), 341 deletions(-)

diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 2e7c68e..dd2a3e5 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -15,6 +15,8 @@
 #include "debug.h"
 #include "session.h"
 #include "tool.h"
+#include "header.h"
+#include "vdso.h"
 
 int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
   union perf_event *event,
@@ -105,3 +107,335 @@ char *dso__build_id_filename(const struct dso *dso, char 
*bf, size_t size)
 build_id_hex, build_id_hex + 2);
return bf;
 }
+
+#define dsos__for_each_with_build_id(pos, head)\
+   list_for_each_entry(pos, head, node)\
+   if (!pos->has_build_id) \
+   continue;   \
+   else
+
+static int write_buildid(const char *name, size_t name_len, u8 *build_id,
+pid_t pid, u16 misc, int fd)
+{
+   int err;
+   struct build_id_event b;
+   size_t len;
+
+   len = name_len + 1;
+   len = PERF_ALIGN(len, NAME_ALIGN);
+
+   memset(, 0, sizeof(b));
+   memcpy(_id, build_id, BUILD_ID_SIZE);
+   b.pid = pid;
+   b.header.misc = misc;
+   b.header.size = sizeof(b) + len;
+
+   err = writen(fd, , sizeof(b));
+   if (err < 0)
+   return err;
+
+   return write_padded(fd, name, name_len + 1, len);
+}
+
+static int __dsos__write_buildid_table(struct list_head *head,
+  struct machine *machine,
+  pid_t pid, u16 misc, int fd)
+{
+   char nm[PATH_MAX];
+   struct dso *pos;
+
+   dsos__for_each_with_build_id(pos, head) {
+   int err;
+   const char *name;
+   size_t name_len;
+
+   if (!pos->hit)
+   continue;
+
+   if (dso__is_vdso(pos)) {
+   name = pos->short_name;
+   name_len = pos->short_name_len + 1;
+   } else if (dso__is_kcore(pos)) {
+   machine__mmap_name(machine, nm, sizeof(nm));
+   name = nm;
+   name_len = strlen(nm) + 1;
+   } else {
+   name = pos->long_name;
+   name_len = pos->long_name_len + 1;
+   }
+
+   err = write_buildid(name, name_len, pos->build_id,
+   pid, misc, fd);
+   if (err)
+   return err;
+   }
+
+   return 0;
+}
+
+static int machine__write_buildid_table(struct machine *machine, int fd)
+{
+   int err;
+   u16 kmisc = PERF_RECORD_MISC_KERNEL,
+   umisc = PERF_RECORD_MISC_USER;
+
+   if (!machine__is_host(machine)) {
+   kmisc = PERF_RECORD_MISC_GUEST_KERNEL;
+   umisc = PERF_RECORD_MISC_GUEST_USER;
+   }
+
+   err = __dsos__write_buildid_table(>kernel_dsos.head, machine,
+ machine->pid, kmisc, fd);
+   if (err == 0)
+   err = __dsos__write_buildid_table(>user_dsos.head,
+ machine, machine->pid, umisc,
+ fd);
+   return err;
+}
+
+int perf_session__write_buildid_table(struct perf_session *session, int fd)
+{
+   struct rb_node *nd;
+   int err = machine__write_buildid_table(>machines.host, fd);
+
+   if (err)
+   return err;
+
+   for (nd = 

[tip:perf/core] perf symbols: Preparation for compressed kernel module support

2014-11-06 Thread tip-bot for Namhyung Kim
Commit-ID:  c00c48fc6e6ef63d83a7417923a06b08089bb34b
Gitweb: http://git.kernel.org/tip/c00c48fc6e6ef63d83a7417923a06b08089bb34b
Author: Namhyung Kim 
AuthorDate: Tue, 4 Nov 2014 10:14:27 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 4 Nov 2014 10:15:53 -0300

perf symbols: Preparation for compressed kernel module support

This patch adds basic support to handle compressed kernel module as some
distro (such as Archlinux) carries on it now.  The actual work using
compression library will be added later.

Signed-off-by: Namhyung Kim 
Acked-by: Jiri Olsa 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1415063674-17206-2-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/dso.c| 75 
 tools/perf/util/dso.h|  7 +
 tools/perf/util/machine.c| 19 ++-
 tools/perf/util/symbol-elf.c | 35 -
 tools/perf/util/symbol.c |  8 -
 5 files changed, 141 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 0247acf..36a607c 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -21,8 +21,10 @@ char dso__symtab_origin(const struct dso *dso)
[DSO_BINARY_TYPE__BUILDID_DEBUGINFO]= 'b',
[DSO_BINARY_TYPE__SYSTEM_PATH_DSO]  = 'd',
[DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE]  = 'K',
+   [DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP] = 'm',
[DSO_BINARY_TYPE__GUEST_KALLSYMS]   = 'g',
[DSO_BINARY_TYPE__GUEST_KMODULE]= 'G',
+   [DSO_BINARY_TYPE__GUEST_KMODULE_COMP]   = 'M',
[DSO_BINARY_TYPE__GUEST_VMLINUX]= 'V',
};
 
@@ -112,11 +114,13 @@ int dso__read_binary_type_filename(const struct dso *dso,
break;
 
case DSO_BINARY_TYPE__GUEST_KMODULE:
+   case DSO_BINARY_TYPE__GUEST_KMODULE_COMP:
path__join3(filename, size, symbol_conf.symfs,
root_dir, dso->long_name);
break;
 
case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE:
+   case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP:
__symbol__join_symfs(filename, size, dso->long_name);
break;
 
@@ -137,6 +141,77 @@ int dso__read_binary_type_filename(const struct dso *dso,
return ret;
 }
 
+static int decompress_dummy(const char *input __maybe_unused,
+   int output __maybe_unused)
+{
+   return -1;
+}
+
+static const struct {
+   const char *fmt;
+   int (*decompress)(const char *input, int output);
+} compressions[] = {
+   { "gz", decompress_dummy },
+   { NULL, },
+};
+
+bool is_supported_compression(const char *ext)
+{
+   unsigned i;
+
+   for (i = 0; compressions[i].fmt; i++) {
+   if (!strcmp(ext, compressions[i].fmt))
+   return true;
+   }
+   return false;
+}
+
+bool is_kmodule_extension(const char *ext)
+{
+   if (strncmp(ext, "ko", 2))
+   return false;
+
+   if (ext[2] == '\0' || (ext[2] == '.' && 
is_supported_compression(ext+3)))
+   return true;
+
+   return false;
+}
+
+bool is_kernel_module(const char *pathname, bool *compressed)
+{
+   const char *ext = strrchr(pathname, '.');
+
+   if (ext == NULL)
+   return false;
+
+   if (is_supported_compression(ext + 1)) {
+   if (compressed)
+   *compressed = true;
+   ext -= 3;
+   } else if (compressed)
+   *compressed = false;
+
+   return is_kmodule_extension(ext + 1);
+}
+
+bool decompress_to_file(const char *ext, const char *filename, int output_fd)
+{
+   unsigned i;
+
+   for (i = 0; compressions[i].fmt; i++) {
+   if (!strcmp(ext, compressions[i].fmt))
+   return !compressions[i].decompress(filename,
+  output_fd);
+   }
+   return false;
+}
+
+bool dso__needs_decompress(struct dso *dso)
+{
+   return dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ||
+   dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
+}
+
 /*
  * Global list of open DSOs and the counter.
  */
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index a316e4a..3782c82 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -22,7 +22,9 @@ enum dso_binary_type {
DSO_BINARY_TYPE__BUILDID_DEBUGINFO,
DSO_BINARY_TYPE__SYSTEM_PATH_DSO,
DSO_BINARY_TYPE__GUEST_KMODULE,
+   DSO_BINARY_TYPE__GUEST_KMODULE_COMP,
DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE,
+   

[tip:perf/core] perf tools: Add branch_type and in_tx to Python export

2014-11-06 Thread tip-bot for Adrian Hunter
Commit-ID:  c29414f5cfd641d956c5287848fdd8f25bb2afa3
Gitweb: http://git.kernel.org/tip/c29414f5cfd641d956c5287848fdd8f25bb2afa3
Author: Adrian Hunter 
AuthorDate: Thu, 30 Oct 2014 16:09:44 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 3 Nov 2014 18:07:34 -0300

perf tools: Add branch_type and in_tx to Python export

Add branch_type and in_tx to Python db export and the
export-to-postgresql.py script.

Signed-off-by: Adrian Hunter 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1414678188-14946-4-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/scripts/python/export-to-postgresql.py  | 32 ++
 .../util/scripting-engines/trace-event-python.c| 30 +++-
 2 files changed, 55 insertions(+), 7 deletions(-)

diff --git a/tools/perf/scripts/python/export-to-postgresql.py 
b/tools/perf/scripts/python/export-to-postgresql.py
index d8f6df0..bb79aec 100644
--- a/tools/perf/scripts/python/export-to-postgresql.py
+++ b/tools/perf/scripts/python/export-to-postgresql.py
@@ -123,6 +123,10 @@ do_query(query, 'CREATE TABLE symbols ('
'sym_endbigint,'
'bindinginteger,'
'name   varchar(2048))')
+do_query(query, 'CREATE TABLE branch_types ('
+   'id integer NOT NULL,'
+   'name   varchar(80))')
+
 if branches:
do_query(query, 'CREATE TABLE samples ('
'id bigint  NOT NULL,'
@@ -139,7 +143,9 @@ if branches:
'to_dso_id  bigint,'
'to_symbol_id   bigint,'
'to_sym_offset  bigint,'
-   'to_ip  bigint)')
+   'to_ip  bigint,'
+   'branch_typeinteger,'
+   'in_tx  boolean)')
 else:
do_query(query, 'CREATE TABLE samples ('
'id bigint  NOT NULL,'
@@ -160,7 +166,9 @@ else:
'period bigint,'
'weight bigint,'
'transactionbigint,'
-   'data_src   bigint)')
+   'data_src   bigint,'
+   'branch_typeinteger,'
+   'in_tx  boolean)')
 
 do_query(query, 'CREATE VIEW samples_view AS '
'SELECT '
@@ -178,7 +186,9 @@ do_query(query, 'CREATE VIEW samples_view AS '
'to_hex(to_ip) AS to_ip_hex,'
'(SELECT name FROM symbols WHERE id = to_symbol_id) AS 
to_symbol,'
'to_sym_offset,'
-   '(SELECT short_name FROM dsos WHERE id = to_dso_id) AS 
to_dso_short_name'
+   '(SELECT short_name FROM dsos WHERE id = to_dso_id) AS 
to_dso_short_name,'
+   '(SELECT name FROM branch_types WHERE id = branch_type) AS 
branch_type_name,'
+   'in_tx'
' FROM samples')
 
 
@@ -234,6 +244,7 @@ comm_file   = open_output_file("comm_table.bin")
 comm_thread_file   = open_output_file("comm_thread_table.bin")
 dso_file   = open_output_file("dso_table.bin")
 symbol_file= open_output_file("symbol_table.bin")
+branch_type_file   = open_output_file("branch_type_table.bin")
 sample_file= open_output_file("sample_table.bin")
 
 def trace_begin():
@@ -257,6 +268,7 @@ def trace_end():
copy_output_file(comm_thread_file,  "comm_threads")
copy_output_file(dso_file,  "dsos")
copy_output_file(symbol_file,   "symbols")
+   copy_output_file(branch_type_file,  "branch_types")
copy_output_file(sample_file,   "samples")
 
print datetime.datetime.today(), "Removing intermediate files..."
@@ -267,6 +279,7 @@ def trace_end():
remove_output_file(comm_thread_file)
remove_output_file(dso_file)
remove_output_file(symbol_file)
+   remove_output_file(branch_type_file)
remove_output_file(sample_file)
os.rmdir(output_dir_name)
print datetime.datetime.today(), "Adding primary keys"
@@ -277,6 +290,7 @@ def trace_end():
do_query(query, 'ALTER TABLE comm_threadsADD PRIMARY KEY (id)')
do_query(query, 'ALTER TABLE dsosADD PRIMARY KEY (id)')
do_query(query, 'ALTER TABLE symbols ADD PRIMARY KEY (id)')
+   do_query(query, 'ALTER TABLE branch_typesADD PRIMARY KEY (id)')
do_query(query, 'ALTER TABLE samples ADD PRIMARY KEY (id)')
 
print datetime.datetime.today(), "Adding foreign keys"
@@ -352,9 +366,15 @@ def symbol_table(symbol_id, dso_id, sym_start, sym_end, 
binding, symbol_name, *x
value = struct.pack(fmt, 6, 8, symbol_id, 8, dso_id, 8, sym_start, 8, 
sym_end, 4, binding, n, symbol_name)
symbol_file.write(value)
 
-def sample_table(sample_id, 

[tip:perf/core] perf tools: Add call information to the database export API

2014-11-06 Thread tip-bot for Adrian Hunter
Commit-ID:  88f50d602f500d206f2f5a9a9751dd45f2d97739
Gitweb: http://git.kernel.org/tip/88f50d602f500d206f2f5a9a9751dd45f2d97739
Author: Adrian Hunter 
AuthorDate: Thu, 30 Oct 2014 16:09:46 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 3 Nov 2014 18:09:33 -0300

perf tools: Add call information to the database export API

Make it possible for the database export API to use the enhanced thread
stack and export detailed information about paired calls and returns.

Signed-off-by: Adrian Hunter 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1414678188-14946-6-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/db-export.c | 52 -
 tools/perf/util/db-export.h | 12 +++
 2 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index bccb831..017ecbb 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -21,6 +21,7 @@
 #include "comm.h"
 #include "symbol.h"
 #include "event.h"
+#include "thread-stack.h"
 #include "db-export.h"
 
 int db_export__init(struct db_export *dbe)
@@ -29,8 +30,10 @@ int db_export__init(struct db_export *dbe)
return 0;
 }
 
-void db_export__exit(struct db_export *dbe __maybe_unused)
+void db_export__exit(struct db_export *dbe)
 {
+   call_return_processor__free(dbe->crp);
+   dbe->crp = NULL;
 }
 
 int db_export__evsel(struct db_export *dbe, struct perf_evsel *evsel)
@@ -270,6 +273,13 @@ int db_export__sample(struct db_export *dbe, union 
perf_event *event,
 _sym_db_id, _offset);
if (err)
return err;
+   if (dbe->crp) {
+   err = thread_stack__process(thread, comm, sample, al,
+   _al, es.db_id,
+   dbe->crp);
+   if (err)
+   return err;
+   }
}
 
if (dbe->export_sample)
@@ -316,3 +326,43 @@ int db_export__branch_types(struct db_export *dbe)
}
return err;
 }
+
+int db_export__call_path(struct db_export *dbe, struct call_path *cp)
+{
+   int err;
+
+   if (cp->db_id)
+   return 0;
+
+   if (cp->parent) {
+   err = db_export__call_path(dbe, cp->parent);
+   if (err)
+   return err;
+   }
+
+   cp->db_id = ++dbe->call_path_last_db_id;
+
+   if (dbe->export_call_path)
+   return dbe->export_call_path(dbe, cp);
+
+   return 0;
+}
+
+int db_export__call_return(struct db_export *dbe, struct call_return *cr)
+{
+   int err;
+
+   if (cr->db_id)
+   return 0;
+
+   err = db_export__call_path(dbe, cr->cp);
+   if (err)
+   return err;
+
+   cr->db_id = ++dbe->call_return_last_db_id;
+
+   if (dbe->export_call_return)
+   return dbe->export_call_return(dbe, cr);
+
+   return 0;
+}
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
index e4baa45..dd5ac2a 100644
--- a/tools/perf/util/db-export.h
+++ b/tools/perf/util/db-export.h
@@ -25,6 +25,9 @@ struct comm;
 struct dso;
 struct perf_sample;
 struct addr_location;
+struct call_return_processor;
+struct call_path;
+struct call_return;
 
 struct export_sample {
union perf_event*event;
@@ -57,6 +60,10 @@ struct db_export {
int (*export_branch_type)(struct db_export *dbe, u32 branch_type,
  const char *name);
int (*export_sample)(struct db_export *dbe, struct export_sample *es);
+   int (*export_call_path)(struct db_export *dbe, struct call_path *cp);
+   int (*export_call_return)(struct db_export *dbe,
+ struct call_return *cr);
+   struct call_return_processor *crp;
u64 evsel_last_db_id;
u64 machine_last_db_id;
u64 thread_last_db_id;
@@ -65,6 +72,8 @@ struct db_export {
u64 dso_last_db_id;
u64 symbol_last_db_id;
u64 sample_last_db_id;
+   u64 call_path_last_db_id;
+   u64 call_return_last_db_id;
 };
 
 int db_export__init(struct db_export *dbe);
@@ -89,4 +98,7 @@ int db_export__sample(struct db_export *dbe, union perf_event 
*event,
 
 int db_export__branch_types(struct db_export *dbe);
 
+int db_export__call_path(struct db_export *dbe, struct call_path *cp);
+int db_export__call_return(struct db_export *dbe, struct call_return *cr);
+
 #endif
--
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  

[tip:perf/core] perf tools: Add gzip decompression support for kernel module

2014-11-06 Thread tip-bot for Namhyung Kim
Commit-ID:  e92ce12ed6a46302f64269d2d406cf04525f0a8f
Gitweb: http://git.kernel.org/tip/e92ce12ed6a46302f64269d2d406cf04525f0a8f
Author: Namhyung Kim 
AuthorDate: Fri, 31 Oct 2014 16:51:38 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 5 Nov 2014 10:11:26 -0300

perf tools: Add gzip decompression support for kernel module

Now my Archlinux box shows module symbols correctly.

Before:
  $ perf report --stdio
  Failed to open /tmp/perf-3477.map, continuing without symbols
  no symbols found in /usr/bin/date, maybe install a debug package?
  No kallsyms or vmlinux with build-id 7b4ea0a49ae2111925857099aaf05c3246ff33e0 
was found
  [drm] with build id 7b4ea0a49ae2111925857099aaf05c3246ff33e0 not found, 
continuing without symbols
  No kallsyms or vmlinux with build-id edd931629094b660ca9dec09a1b635c8d87aa2ee 
was found
  [jbd2] with build id edd931629094b660ca9dec09a1b635c8d87aa2ee not found, 
continuing without symbols
  No kallsyms or vmlinux with build-id a7b1eada671c34933e5610bb920b2ca4945a82c3 
was found
  [ext4] with build id a7b1eada671c34933e5610bb920b2ca4945a82c3 not found, 
continuing without symbols
  No kallsyms or vmlinux with build-id d69511fa3e5840e770336ef45b06c83fef8d74e3 
was found
  [scsi_mod] with build id d69511fa3e5840e770336ef45b06c83fef8d74e3 not found, 
continuing without symbols
  No kallsyms or vmlinux with build-id af0430af13461af058770ee9b87afc07922c2e77 
was found
  [libata] with build id af0430af13461af058770ee9b87afc07922c2e77 not found, 
continuing without symbols
  No kallsyms or vmlinux with build-id aaeedff8160ce631a5f0333591c6ff291201d29f 
was found
  [libahci] with build id aaeedff8160ce631a5f0333591c6ff291201d29f not found, 
continuing without symbols
  No kallsyms or vmlinux with build-id c57907712becaf662dc4981824bb372c0441d605 
was found
  [mac80211] with build id c57907712becaf662dc4981824bb372c0441d605 not found, 
continuing without symbols
  No kallsyms or vmlinux with build-id e0589077cc0ec8c3e4c40eb9f2d9e69d236bee8f 
was found
  [iwldvm] with build id e0589077cc0ec8c3e4c40eb9f2d9e69d236bee8f not found, 
continuing without symbols
  No kallsyms or vmlinux with build-id 2d86086bf136bf374a2f029cf85a48194f9b950b 
was found
  [cfg80211] with build id 2d86086bf136bf374a2f029cf85a48194f9b950b not found, 
continuing without symbols
  No kallsyms or vmlinux with build-id 4493c48599bdb3d91d0f8db5150e0be33fdd9221 
was found
  [iwlwifi] with build id 4493c48599bdb3d91d0f8db5150e0be33fdd9221 not found, 
continuing without symbols
  ...
  #
  # Overhead  Command  Shared ObjectSymbol
  #   ...  ...  

  #
   0.03%  swapper  [ext4]   [k] 0xfe2e
   0.03%  swapper  [kernel.kallsyms][k] 
account_entity_enqueue
   0.03%  swapper  [ext4]   [k] 0xfc2b
   0.03%  irq/50-iwlwifi   [iwlwifi][k] 0x200b
   0.03%  swapper  [kernel.kallsyms][k] ktime_add_safe
   0.03%  swapper  [kernel.kallsyms][k] 
elv_completed_request
   0.03%  swapper  [libata] [k] 0x3997
   0.03%  swapper  [libahci][k] 0x1f25
   0.03%  swapper  [kernel.kallsyms][k] rb_next
   0.03%  swapper  [kernel.kallsyms][k] blk_finish_request
   0.03%  swapper  [ext4]   [k] 0x00010248
   0.00%  perf [kernel.kallsyms][k] 
native_write_msr_safe

After:
  $ perf report --stdio
  Failed to open /tmp/perf-3477.map, continuing without symbols
  no symbols found in /usr/bin/tr, maybe install a debug package?
  ...
  #
  # Overhead  Command  Shared ObjectSymbol
  #   ...  ...  
..
  #

   0.04%  kworker/u16:3[ext4]   [k] 
ext4_read_block_bitmap
   0.03%  kworker/u16:0[mac80211]   [k] 
ieee80211_sta_reset_beacon_monitor
   0.02%  irq/50-iwlwifi   [mac80211]   [k] 
ieee80211_get_bssid
   0.02%  firefox  [e1000e] [k] __ew32_prepare
   0.02%  swapper  [libahci][k] 
ahci_handle_port_interrupt
   0.02%  emacslibglib-2.0.so.0.4000.0  [.] g_mutex_unlock
   0.02%  swapper  [e1000e] [k] 
e1000_clean_tx_irq
   0.02%  dwm  [kernel.kallsyms][k] __schedule
   0.02%  gnome-terminal-  [vdso]   [.] 
__vdso_clock_gettime
   0.02%  swapper  [e1000e] [k] 
e1000_alloc_rx_buffers
   0.02%  irq/50-iwlwifi   [mac80211]   [k] ieee80211_rx
   0.01%  firefox  [vdso]   

[tip:perf/core] perf tools: Enhance the thread stack to output call/return data

2014-11-06 Thread tip-bot for Adrian Hunter
Commit-ID:  92a9e4f7db89a013e1bdef2e548928fc71e9867c
Gitweb: http://git.kernel.org/tip/92a9e4f7db89a013e1bdef2e548928fc71e9867c
Author: Adrian Hunter 
AuthorDate: Thu, 30 Oct 2014 16:09:45 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 3 Nov 2014 17:43:56 -0300

perf tools: Enhance the thread stack to output call/return data

Enhance the thread stack to output detailed information about paired
calls and returns.

The enhanced processing consumes sample information via
thread_stack__process() and outputs information about paired calls /
returns via a call-back.

While the call-back makes it possible for the facility to be used by
arbitrary tools, a subsequent patch will provide the information to
Python scripting via the db-export interface.

An important part of the call/return information is the
call path which provides a structure that defines a context
sensitive call graph.

Note that there are now two ways to use the thread stack.

For simply providing a call stack (like you would get from the perf
record -g option) the interface consists of thread_stack__event() and
thread_stack__sample().

Whereas the enhanced interface consists of call_return_processor__new()
and thread_stack__process().

Signed-off-by: Adrian Hunter 
Acked-by: Jiri Olsa 
Cc: David Ahern 
Cc: Frederic Weisbecker 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paul Mackerras 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/1414678188-14946-5-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/thread-stack.c | 585 -
 tools/perf/util/thread-stack.h |  79 ++
 2 files changed, 659 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c
index 85b60d2..9ed59a4 100644
--- a/tools/perf/util/thread-stack.c
+++ b/tools/perf/util/thread-stack.c
@@ -13,23 +13,96 @@
  *
  */
 
+#include 
+#include 
 #include "thread.h"
 #include "event.h"
+#include "machine.h"
 #include "util.h"
 #include "debug.h"
+#include "symbol.h"
+#include "comm.h"
 #include "thread-stack.h"
 
-#define STACK_GROWTH 4096
+#define CALL_PATH_BLOCK_SHIFT 8
+#define CALL_PATH_BLOCK_SIZE (1 << CALL_PATH_BLOCK_SHIFT)
+#define CALL_PATH_BLOCK_MASK (CALL_PATH_BLOCK_SIZE - 1)
 
+struct call_path_block {
+   struct call_path cp[CALL_PATH_BLOCK_SIZE];
+   struct list_head node;
+};
+
+/**
+ * struct call_path_root - root of all call paths.
+ * @call_path: root call path
+ * @blocks: list of blocks to store call paths
+ * @next: next free space
+ * @sz: number of spaces
+ */
+struct call_path_root {
+   struct call_path call_path;
+   struct list_head blocks;
+   size_t next;
+   size_t sz;
+};
+
+/**
+ * struct call_return_processor - provides a call-back to consume call-return
+ *information.
+ * @cpr: call path root
+ * @process: call-back that accepts call/return information
+ * @data: anonymous data for call-back
+ */
+struct call_return_processor {
+   struct call_path_root *cpr;
+   int (*process)(struct call_return *cr, void *data);
+   void *data;
+};
+
+#define STACK_GROWTH 2048
+
+/**
+ * struct thread_stack_entry - thread stack entry.
+ * @ret_addr: return address
+ * @timestamp: timestamp (if known)
+ * @ref: external reference (e.g. db_id of sample)
+ * @branch_count: the branch count when the entry was created
+ * @cp: call path
+ * @no_call: a 'call' was not seen
+ */
 struct thread_stack_entry {
u64 ret_addr;
+   u64 timestamp;
+   u64 ref;
+   u64 branch_count;
+   struct call_path *cp;
+   bool no_call;
 };
 
+/**
+ * struct thread_stack - thread stack constructed from 'call' and 'return'
+ *   branch samples.
+ * @stack: array that holds the stack
+ * @cnt: number of entries in the stack
+ * @sz: current maximum stack size
+ * @trace_nr: current trace number
+ * @branch_count: running branch count
+ * @kernel_start: kernel start address
+ * @last_time: last timestamp
+ * @crp: call/return processor
+ * @comm: current comm
+ */
 struct thread_stack {
struct thread_stack_entry *stack;
size_t cnt;
size_t sz;
u64 trace_nr;
+   u64 branch_count;
+   u64 kernel_start;
+   u64 last_time;
+   struct call_return_processor *crp;
+   struct comm *comm;
 };
 
 static int thread_stack__grow(struct thread_stack *ts)
@@ -50,7 +123,8 @@ static int thread_stack__grow(struct thread_stack *ts)
return 0;
 }
 
-static struct thread_stack *thread_stack__new(void)
+static struct thread_stack *thread_stack__new(struct thread *thread,
+ struct call_return_processor *crp)
 {
struct thread_stack *ts;
 
@@ -63,6 +137,12 @@ static struct thread_stack *thread_stack__new(void)
return NULL;
}
 
+   if (thread->mg && thread->mg->machine)
+   

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

2014-11-06 Thread Ingo Molnar

* Arnaldo Carvalho de Melo  wrote:

> Hi Ingo,
> 
>   Please consider pulling,
> 
> - Arnaldo
> 
> The following changes since commit daa01794a4a36a1da1b09a529adec0c8c0b94ab2:
> 
>   perf evsel: Do not call pevent_free_format when deleting tracepoint 
> (2014-11-06 17:47:14 -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
> 
> for you to fetch changes up to daa01794a4a36a1da1b09a529adec0c8c0b94ab2:
> 
>   perf evsel: Do not call pevent_free_format when deleting tracepoint 
> (2014-11-06 17:47:14 -0300)
> 
> 
> perf/core improvements and fixes:
> 
> Infrastructure:
> 
> o Add gzip decompression support for kernel modules (Namhyung Kim)
> 
> o More prep patches for Intel PT, including a a thread stack and
>   more stuff made available via the database export mechanism (Adrian Hunter)
> 
> o Optimize checking that tracepoint events are defined in perf script 
> perl/python (Jiri Olsa)
> 
> o Do not free pevent when deleting tracepoint evsel (Jiri Olsa)
> 
> o Fix build-id matching for vmlinux (Namhyung Kim)
> 
> Signed-off-by: Arnaldo Carvalho de Melo 
> 
> 

Pulled, 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 1/3] perf tools: Allow vmlinux to fallback to kallsyms on NO_LIBELF=1

2014-11-06 Thread Namhyung Kim
When libelf is not used, perf cannot not show symbol names since it
doesn't access the ELF symbol table.  But kernel is different as it
can fallback to kallsyms.

It worked w/o libelf, but recent change to use vmlinux for kernel
symbols break it.

With this change, it now can show kernel symbols again:

  # Overhead  Command  Shared Object  Symbol
  #   ...  .  
  #
  34.51%  swapper  [kernel.kallsyms]  [k] intel_idle
  12.54%  perf [kernel.kallsyms]  [k] generic_exec_single
  10.11%  swapper  [kernel.kallsyms]  [k] int_sqrt
   9.83%  swapper  [kernel.kallsyms]  [k] hrtimer_interrupt
   7.25%  emacs[kernel.kallsyms]  [k] __switch_to
   7.06%  sleep[kernel.kallsyms]  [k] find_next_iomem_res
   7.02%  swapper  [kernel.kallsyms]  [k] run_timer_softirq
   2.55%  swapper  [kernel.kallsyms]  [k] _raw_spin_unlock_irq
   1.90%  swapper  [kernel.kallsyms]  [k] lapic_next_deadline
   1.75%  swapper  [kernel.kallsyms]  [k] native_sched_clock
   1.49%  swapper  [kernel.kallsyms]  [k] __schedule
   1.20%  swapper  [kernel.kallsyms]  [k] read_tsc
   1.10%  sleep[kernel.kallsyms]  [k] current_kernel_time
   0.99%  swapper  [kernel.kallsyms]  [k] pick_next_task_rt
   0.36%  swapper  [kernel.kallsyms]  [k] group_sched_in
   0.24%  swapper  [kernel.kallsyms]  [k] x86_pmu_commit_txn
   0.06%  swapper  [kernel.kallsyms]  [k] intel_pmu_enable_all
   0.03%  perf [kernel.kallsyms]  [k] intel_pmu_enable_all

Reported-by: Peter Zijlstra 
Cc: Adrian Hunter 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/symbol-minimal.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c
index c9541fea9514..226cf41ed7e6 100644
--- a/tools/perf/util/symbol-minimal.c
+++ b/tools/perf/util/symbol-minimal.c
@@ -335,6 +335,9 @@ int dso__load_sym(struct dso *dso, struct map *map 
__maybe_unused,
unsigned char *build_id[BUILD_ID_SIZE];
int ret;
 
+   if (dso->kernel)
+   return 0;  /* always use kallsyms */
+
ret = fd__is_64_bit(ss->fd);
if (ret >= 0)
dso->is_64_bit = ret;
-- 
2.1.2

--
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/3] perf symbol: Implement a very simple ELF symbol parser

2014-11-06 Thread Namhyung Kim
It'll be used to show (userspace) symbol names when libelf isn't (or
cannot be) linked.

  # Overhead  Command Shared Object  Symbol
  #   ..  .  .
  #
  37.01%  mem-memcpy  libc-2.17.so   [.] __memcpy_ssse3_back
  24.25%  perfld-2.17.so [.] _dl_relocate_object
  22.16%  perf[kernel.kallsyms]  [k] kmem_cache_alloc
  14.29%  mem-memset  libc-2.17.so   [.] __memset_sse2
   2.21%  perf[kernel.kallsyms]  [k] flush_signal_handlers
   0.07%  perf[kernel.kallsyms]  [k] intel_pmu_enable_all

Cc: Adrian Hunter 
Signed-off-by: Namhyung Kim 
---
 tools/perf/util/symbol-minimal.c | 143 ---
 tools/perf/util/symbol-minimal.h |  64 ++
 tools/perf/util/symbol.h |  10 ++-
 3 files changed, 208 insertions(+), 9 deletions(-)
 create mode 100644 tools/perf/util/symbol-minimal.h

diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c
index 226cf41ed7e6..9da571d83a25 100644
--- a/tools/perf/util/symbol-minimal.c
+++ b/tools/perf/util/symbol-minimal.c
@@ -1,11 +1,13 @@
 #include "symbol.h"
 #include "util.h"
+#include "debug.h"
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 
 static bool check_need_swap(int file_endian)
@@ -242,22 +244,81 @@ int sysfs__read_build_id(const char *filename, void 
*build_id, size_t size)
return ret;
 }
 
+static const char *symsrc__symname(struct symsrc *ss, Elf_Shdr *strsec, int 
idx)
+{
+   return ss->ptr + strsec->sh_offset + idx;
+}
+
 int symsrc__init(struct symsrc *ss, struct dso *dso __maybe_unused,
 const char *name,
 enum dso_binary_type type)
 {
-   int fd = open(name, O_RDONLY);
+   int fd;
+   unsigned i;
+   Elf_Ehdr ehdr;
+   struct stat stbuf;
+   void *ptr;
+
+   fd = open(name, O_RDONLY);
if (fd < 0)
return -1;
 
ss->name = strdup(name);
-   if (!ss->name)
-   goto out_close;
+   if (!ss->name) {
+   close(fd);
+   return -1;
+   }
 
ss->fd = fd;
ss->type = type;
 
+   /* only consider native case (no swap) */
+   if (read(fd, , sizeof(ehdr)) < 0)
+   goto out_close;
+
+   if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) ||
+   ehdr.e_ident[EI_VERSION] != EV_CURRENT)
+   goto out_close;
+
+   if (ehdr.e_ident[EI_CLASS] != ELFCLASS)
+   goto out_close;
+
+   if (check_need_swap(ehdr.e_ident[EI_DATA]))
+   goto out_close;
+
+   if (ehdr.e_shentsize != sizeof(Elf_Shdr))
+   goto out_close;
+
+   if (fstat(fd, ) < 0)
+   goto out_close;
+
+   ptr = mmap(NULL, stbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+   if (ptr == MAP_FAILED)
+   goto out_close;
+
+   ss->ptr = ptr;
+   ss->len = stbuf.st_size;
+   ss->sec = ptr + ehdr.e_shoff;
+
+   ss->symtab = NULL;
+   for (i = 0; i < ehdr.e_shnum; i++) {
+   Elf_Shdr *shdrp = >sec[i];
+   const char *shname;
+
+   shname = symsrc__symname(ss, >sec[ehdr.e_shstrndx],
+shdrp->sh_name);
+
+   if (!strcmp(shname, ".text"))
+   ss->adjust_offset = shdrp->sh_addr - shdrp->sh_offset;
+
+   if (shdrp->sh_type == SHT_SYMTAB) {
+   ss->symtab = shdrp;
+   ss->strtab = >sec[shdrp->sh_link];
+   }
+   }
+
return 0;
+
 out_close:
close(fd);
return -1;
@@ -276,6 +337,7 @@ bool symsrc__has_symtab(struct symsrc *ss __maybe_unused)
 
 void symsrc__destroy(struct symsrc *ss)
 {
+   munmap(ss->ptr, ss->len);
zfree(>name);
close(ss->fd);
 }
@@ -332,7 +394,9 @@ int dso__load_sym(struct dso *dso, struct map *map 
__maybe_unused,
  symbol_filter_t filter __maybe_unused,
  int kmodule __maybe_unused)
 {
-   unsigned char *build_id[BUILD_ID_SIZE];
+   Elf_Ehdr *ehdr = ss->ptr;
+   Elf_Sym *symtab;
+   size_t i, nr_sym;
int ret;
 
if (dso->kernel)
@@ -342,11 +406,74 @@ int dso__load_sym(struct dso *dso, struct map *map 
__maybe_unused,
if (ret >= 0)
dso->is_64_bit = ret;
 
-   if (filename__read_build_id(ss->name, build_id, BUILD_ID_SIZE) > 0) {
-   dso__set_build_id(dso, build_id);
-   return 1;
+   if (dso->has_build_id) {
+   u8 build_id[BUILD_ID_SIZE];
+
+   if (filename__read_build_id(ss->name, build_id, BUILD_ID_SIZE) 
< 0)
+   return -1;
+
+   if (!dso__build_id_equal(dso, build_id))
+   return -1;
}
-   return 0;
+
+   if (map->type != MAP__FUNCTION)
+   return 0;
+
+   if 

[PATCH 3/3] perf tools: Clean up libelf feature support code

2014-11-06 Thread Namhyung Kim
Current EXTLIBS contains -lelf by default and removes it when libelf
is not detected.  This is little bit confusing since we can now build
perf without libelf so there's no need to handle it differently than
other libraries.

Signed-off-by: Namhyung Kim 
---
 tools/perf/Makefile.perf   | 2 --
 tools/perf/config/Makefile | 5 +++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 31a76ee92c93..06cccdceb0ae 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -495,8 +495,6 @@ ifneq ($(OUTPUT),)
 endif
 
 ifdef NO_LIBELF
-EXTLIBS := $(filter-out -lelf,$(EXTLIBS))
-
 # Remove ELF/DWARF dependent codes
 LIB_OBJS := $(filter-out $(OUTPUT)util/symbol-elf.o,$(LIB_OBJS))
 LIB_OBJS := $(filter-out $(OUTPUT)util/dwarf-aux.o,$(LIB_OBJS))
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 79f906c7124e..5d4b039fe1ed 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -150,7 +150,7 @@ CFLAGS += -std=gnu99
 # adding assembler files missing the .GNU-stack linker note.
 LDFLAGS += -Wl,-z,noexecstack
 
-EXTLIBS = -lelf -lpthread -lrt -lm -ldl
+EXTLIBS = -lpthread -lrt -lm -ldl
 
 ifneq ($(OUTPUT),)
   OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
@@ -354,6 +354,7 @@ endif # NO_LIBELF
 
 ifndef NO_LIBELF
   CFLAGS += -DHAVE_LIBELF_SUPPORT
+  EXTLIBS += -lelf
 
   ifeq ($(feature-libelf-mmap), 1)
 CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
@@ -373,7 +374,7 @@ ifndef NO_LIBELF
 else
   CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
   LDFLAGS += $(LIBDW_LDFLAGS)
-  EXTLIBS += -lelf -ldw
+  EXTLIBS += -ldw
 endif # PERF_HAVE_DWARF_REGS
   endif # NO_DWARF
 endif # NO_LIBELF
-- 
2.1.2

--
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: [PATCHv4 4/7] hwspinlock/core: add common OF helpers

2014-11-06 Thread Ohad Ben-Cohen
Hi Suman,

On Thu, Nov 6, 2014 at 8:24 PM, Suman Anna  wrote:
> Ping on this. Can you review the latest series v6 [1] and pick it up for
> 3.19? The MSM spinlock driver is also blocked/dependent on that series.

Sure, it's on my mind, I hope I'll get to it next week.

Thanks,
Ohad.
--
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 net 3/5] fm10k: Implement ndo_gso_check()

2014-11-06 Thread Joe Stringer
On Fri, 07 Nov 2014 14:07:36 Vick, Matthew wrote:
> On 11/6/14, 1:15 PM, "Joe Stringer"  wrote:
> >Oh, I suppose we need to check the gso_type too. More like this?
> >
> >+static bool fm10k_gso_check(struct sk_buff *skb, struct net_device *dev)
> >+{
> >+   if ((skb_shinfo(skb)->gso_type & (SKB_GSO_UDP_TUNNEL |
> >SKB_GSO_GRE)) &&
> >+   !fm10k_tx_encap_offload(skb))
> >+   return false;
> >+
> >+   return true;
> >+}
> 
> It seems like the skb_shinfo(skb)->gso_type check should be in some more
> generic ndo_gso_check that drivers can default to/extend. Then, we could
> end up with something like
> 
> static bool fm10k_gso_check(struct sk_buff *skb, struct net_device *dev)
> {
>   if (skb_gso_check(skb, dev) && !fm10k_tx_encap_offload(skb))
>   return false;
> 
>   return true;
> }
> 
> This could even be simplified and still legible as
> 
> static bool fm10k_gso_check(struct sk_buff *skb, struct net_device *dev)
> {
>   return !(skb_gso_check(skb, dev) && !fm10k_tx_encap_offload(skb));
> }
> 
> What do you think of this approach?

Let's merge both discussions into one thread (pick here or there). We have 
this suggestion or the one which simply checks for tunnels and inner+outer 
header lengths. Do you have a preference between them?

We could introduce an "skb_is_gso_encap()" or similar for this purpose. 
Checking for SKB_GSO_UDP_TUNNEL or SKB_GSO_GRE is pretty closely tied to what 
fm10k_tx_encap_offload() checks for though; it might not even make sense to 
call 
it if some of the other SKB_GSO_* flags are raised.

Joe
--
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 00/14] genirq endian fixes; bcm7120/brcmstb IRQ updates

2014-11-06 Thread Jason Cooper
Kevin,

On Sat, Nov 01, 2014 at 06:03:47PM -0700, Kevin Cernekee wrote:
...
> Kevin Cernekee (14):
>   sh: Eliminate unused irq_reg_{readl,writel} accessors
>   genirq: Generic chip: Change irq_reg_{readl,writel} arguments
>   genirq: Generic chip: Allow irqchip drivers to override
> irq_reg_{readl,writel}
>   genirq: Generic chip: Add big endian I/O accessors
>   irqchip: brcmstb-l2: Eliminate dependency on ARM code
>   irqchip: bcm7120-l2: Eliminate bad IRQ check
>   irqchip: bcm7120-l2, brcmstb-l2: Remove ARM Kconfig dependency
>   irqchip: bcm7120-l2: Make sure all register accesses use base+offset
>   irqchip: bcm7120-l2: Fix missing nibble in gc->unused mask
>   irqchip: bcm7120-l2: Use gc->mask_cache to simplify suspend/resume
> functions
>   irqchip: bcm7120-l2: Extend driver to support 64+ bit controllers
>   irqchip: bcm7120-l2: Decouple driver from brcmstb-l2
>   irqchip: bcm7120-l2: Convert driver to use irq_reg_{readl,writel}
>   irqchip: brcmstb-l2: Convert driver to use irq_reg_{readl,writel}

Patches 2, 3, and 4 applied to irqchip/core with Thomas' and Arnd's Acks
added.  Patches 5-$ added to irqchip/core with Arnd's Ack added where it
was missing.

I've left patch #1 for the sh maintainers.

thx,

Jason.
--
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 v9 0/3] ARM: rk3288: Add PM Domain support

2014-11-06 Thread Caesar Wang
Add power domain drivers based on generic power domain for
Rockchip platform, and support RK3288.

https://chromium-review.googlesource.com/#/c/220253/9
This is the GPU driver, add the following information in DT,
and it can support the PMDOMAIN

gpu: gpu@ffa3 {
compatible = "arm,malit764",
 "arm,malit76x",
 "arm,malit7xx",
 "arm,mali-midgard";
reg = <0xffa3 0x1>;
interrupts = ,
 ,
 ;
interrupt-names = "JOB", "MMU", "GPU";
clocks = < ACLK_GPU>;
clock-names = "aclk_gpu";
operating-points = <
/* KHz uV */
10 80
20 85
30 95
40 100
60 115
>;
power-domains = < RK3288_PD_GPU>;
status = "disabled";
};

Based on:
- [PATCH v1 1/4] PM / clock_ops: Add pm_clk_add_clk()
http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg735599.html

Changes in v9:
- add document decription
- fix v8 changes as follows:
- This reconciles the v2 and v7 code so that we power domain have
  lists of clocks they toggle on and off during power transitions and
  independently from power domains clocks we attach clocks to devices
  comprising power domain and prepare them so they are turn on and off
  by runtime PM.
- add rockchip_pm_add_one_domain() to control domains.
- add pd_start/pd_stop interface to control clocks
- add decription for power-doamin node

Changes in v8:
- document go back to v2
- This reconciles the v2 and v7 code so that we power domain have
  lists of clocks they toggle on and off during power transitions and
  independently from power domains clocks we attach clocks to devices
  comprising power domain and prepare them so they are turn on and off
  by runtime PM.
- DTS go back to v2

Changes in v7:
- Delete unused variables

Changes in v6:
- delete pmu_lock
- modify dev_lock using mutex
- pm_clk_resume(pd->dev) change to pm_clk_resume(ed->dev)
- pm_clk_suspend(pd->dev) change to pm_clk_suspend(ed->dev)
- add devm_kfree(pd->dev, de) in rockchip_pm_domain_detach_dev

Changes in v5:
- delete idle_lock
- add timeout in rockchip_pmu_set_idle_request()

Changes in v4:
- use list storage dev

Changes in v3:
- DT structure has changed
- change use pm_clk_resume() and pm_clk_suspend()
- Decomposition power-controller, changed to multiple controller
(gpu-power-controller, hevc-power-controller)

Changes in v2:
- move clocks to "optional"
- remove the "pd->pd.of_node = np"
- make pd_vio clocks all one entry per line and alphabetize.
- power: power-controller move back to pinctrl: pinctrl.

Caesar Wang (3):
  dt-bindings: add document of Rockchip power domain
  power-domain: rockchip: add power doamin driver
  ARM: dts: add rk3288 power-domain node

 .../bindings/arm/rockchip/power_domain.txt |  48 +++
 arch/arm/boot/dts/rk3288.dtsi  |  66 +++
 arch/arm/mach-rockchip/Kconfig |   1 +
 arch/arm/mach-rockchip/Makefile|   1 +
 arch/arm/mach-rockchip/pm_domains.c| 469 +
 include/dt-bindings/power-domain/rk3288.h  |  11 +
 6 files changed, 596 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/rockchip/power_domain.txt
 create mode 100644 arch/arm/mach-rockchip/pm_domains.c
 create mode 100644 include/dt-bindings/power-domain/rk3288.h

-- 
1.9.1


--
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 v9 2/3] power-domain: rockchip: add power doamin driver

2014-11-06 Thread Caesar Wang
In order to meet high performance and low power requirements, a power
management unit is designed or saving power when RK3288 in low power mode.
The RK3288 PMU is dedicated for managing the power ot the whole chip.

Signed-off-by: Jack Dai 
Signed-off-by: jinkun.hong 
Signed-off-by: Caesar Wang 

---

Changes in v9:
- fix v8 changes as follows:
- This reconciles the v2 and v7 code so that we power domain have
  lists of clocks they toggle on and off during power transitions and
  independently from power domains clocks we attach clocks to devices
  comprising power domain and prepare them so they are turn on and off
  by runtime PM.
- add rockchip_pm_add_one_domain() to control domains.
- add pd_start/pd_stop interface to control clocks

Changes in v8:
- This reconciles the v2 and v7 code so that we power domain have
  lists of clocks they toggle on and off during power transitions and
  independently from power domains clocks we attach clocks to devices
  comprising power domain and prepare them so they are turn on and off
  by runtime PM.

Changes in v7:
- Delete unused variables

Changes in v6:
- delete pmu_lock
- modify dev_lock using mutex
- pm_clk_resume(pd->dev) change to pm_clk_resume(ed->dev)
- pm_clk_suspend(pd->dev) change to pm_clk_suspend(ed->dev)
- add devm_kfree(pd->dev, de) in rockchip_pm_domain_detach_dev

Changes in v5:
- delete idle_lock
- add timeout in rockchip_pmu_set_idle_request()

Changes in v4:
- use list storage dev

Changes in v3:
- change use pm_clk_resume() and pm_clk_suspend()

Changes in v2:
- remove the "pd->pd.of_node = np"

 arch/arm/mach-rockchip/Kconfig|   1 +
 arch/arm/mach-rockchip/Makefile   |   1 +
 arch/arm/mach-rockchip/pm_domains.c   | 469 ++
 include/dt-bindings/power-domain/rk3288.h |  11 +
 4 files changed, 482 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/pm_domains.c
 create mode 100644 include/dt-bindings/power-domain/rk3288.h

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index ac5803c..d033993 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -13,6 +13,7 @@ config ARCH_ROCKCHIP
select DW_APB_TIMER_OF
select ARM_GLOBAL_TIMER
select CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
+   select PM_GENERIC_DOMAINS if PM
help
  Support for Rockchip's Cortex-A9 Single-to-Quad-Core-SoCs
  containing the RK2928, RK30xx and RK31xx series.
diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
index b29d8ea..17ea082 100644
--- a/arch/arm/mach-rockchip/Makefile
+++ b/arch/arm/mach-rockchip/Makefile
@@ -1,4 +1,5 @@
 CFLAGS_platsmp.o := -march=armv7-a
 
 obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip.o
+obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
 obj-$(CONFIG_SMP) += headsmp.o platsmp.o
diff --git a/arch/arm/mach-rockchip/pm_domains.c 
b/arch/arm/mach-rockchip/pm_domains.c
new file mode 100644
index 000..153b22d
--- /dev/null
+++ b/arch/arm/mach-rockchip/pm_domains.c
@@ -0,0 +1,469 @@
+/*
+ * Rockchip Generic power domain support.
+ *
+ * Copyright (c) 2014 ROCKCHIP, Co. Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct rockchip_domain_info {
+   u32 id;
+   int pwr_shift;
+   int status_shift;
+   int req_shift;
+   int idle_shift;
+   int ack_shift;
+};
+
+struct rockchip_pmu_info {
+   u32 pwr_offset;
+   u32 status_offset;
+   u32 req_offset;
+   u32 idle_offset;
+   u32 ack_offset;
+
+   int num_domains;
+   const struct rockchip_domain_info *domain_info;
+};
+
+struct rockchip_pm_domain {
+   struct generic_pm_domain genpd;
+   const struct rockchip_domain_info *info;
+   struct rockchip_pmu *pmu;
+   int num_clks;
+   struct clk *clks[];
+};
+
+struct rockchip_pmu {
+   struct device *dev;
+   struct regmap *regmap;
+   const struct rockchip_pmu_info *info;
+   struct mutex mutex; /* mutex lock for dev_list */
+   int num_domains;
+   struct rockchip_pm_domain *domains[];
+};
+
+#define to_rockchip_pd(gpd) container_of(gpd, struct rockchip_pm_domain, genpd)
+
+#define DOMAIN(_id, _pwr_s, _status_s, _req_s, _idle_s, _ack_s)\
+{  \
+   .id = _id,  \
+   .pwr_shift = _pwr_s,\
+   .status_shift = _status_s,  \
+   .req_shift = _req_s,\
+   .idle_shift = _idle_s,   

[PATCH v9 3/3] ARM: dts: add rk3288 power-domain node

2014-11-06 Thread Caesar Wang
This patch add the needed clocks into power-controller.

why need we do so that?

Firstly, we always be needed turn off clocks to save power when
the system enter suspend.So we need to enumerate the clocks are needed
to switch power doamin no and off.

Secondly, Rk3288 reset circuit should be syncchronous reset and
then sync revoked.so we need to enable clocks of all devices.

Signed-off-by: Jack Dai 
Signed-off-by: jinkun.hong 
Signed-off-by: Caesar Wang 

---

Changes in v9:
- add decription for power-doamin node

Changes in v8:
- DTS go back to v2

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- Decomposition power-controller, changed to multiple controller
(gpu-power-controller, hevc-power-controller)

Changes in v2:
- make pd_vio clocks all one entry per line and alphabetize.
- power: power-controller move back to pinctrl: pinctrl.

 arch/arm/boot/dts/rk3288.dtsi | 66 +++
 1 file changed, 66 insertions(+)

diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index cb18bb4..9cd269a 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -989,4 +989,70 @@
};
};
};
+
+   power: power-controller {
+   compatible = "rockchip,rk3288-power-controller";
+   #power-domain-cells = <1>;
+   rockchip,pmu = <>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   pd_gpu {
+   reg = ;
+   clocks = < ACLK_GPU>;
+   };
+
+   pd_hevc {
+   reg = ;
+   clocks = < ACLK_HEVC>,
+< SCLK_HEVC_CABAC>,
+< SCLK_HEVC_CORE>,
+< HCLK_HEVC>;
+   };
+
+   pd_vio {
+   reg = ;
+   clocks = < ACLK_IEP>,
+< ACLK_ISP>,
+< ACLK_RGA_NIU>,
+< ACLK_RGA>,
+< ACLK_VIO0_NIU>,
+< ACLK_VIO1_NIU>,
+< ACLK_VIP>,
+< ACLK_VOP0>,
+< ACLK_VOP1>,
+< DCLK_VOP0>,
+< DCLK_VOP1>,
+< HCLK_IEP>,
+< HCLK_ISP>,
+< HCLK_RGA>,
+< HCLK_VIO_AHB_ARBI>,
+< HCLK_VIO_NIU>,
+< HCLK_VIO2_H2P>,
+< HCLK_VIP>,
+< HCLK_VOP0>,
+< HCLK_VOP1>,
+< PCLK_EDP_CTRL>,
+< PCLK_HDMI_CTRL>,
+< PCLK_LVDS_PHY>,
+< PCLK_MIPI_CSI>,
+< PCLK_MIPI_DSI0>,
+< PCLK_MIPI_DSI1>,
+< PCLK_VIO2_H2P>,
+< SCLK_EDP_24M>,
+< SCLK_EDP>,
+< SCLK_HDMI_CEC>,
+< SCLK_HDMI_HDCP>,
+< SCLK_ISP_JPE>,
+< SCLK_ISP>,
+< SCLK_RGA>;
+   };
+
+   pd_video {
+   reg = ;
+   /* FIXME: add clocks */
+   clocks = < ACLK_VCODEC>,
+< HCLK_VCODEC>;
+   };
+   };
 };
-- 
1.9.1


--
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 v9 1/3] dt-bindings: add document of Rockchip power domain

2014-11-06 Thread Caesar Wang
This add the necessary binding documentation for the power domain
found on Rockchip Socs.

Signed-off-by: Jack Dai 
Signed-off-by: jinkun.hong 
Signed-off-by: Caesar Wang 

---

Changes in v9:
- add document decription

Changes in v8:
- document go back to v2

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- DT structure has changed

Changes in v2:
- move clocks to "optional"

 .../bindings/arm/rockchip/power_domain.txt | 48 ++
 1 file changed, 48 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/rockchip/power_domain.txt

diff --git a/Documentation/devicetree/bindings/arm/rockchip/power_domain.txt 
b/Documentation/devicetree/bindings/arm/rockchip/power_domain.txt
new file mode 100644
index 000..3e74e6d
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/rockchip/power_domain.txt
@@ -0,0 +1,48 @@
+* Rockchip Power Domains
+
+Rockchip processors include support for multiple power domains which can be
+powered up/down by software based on different application scenes to save 
power.
+
+Required properties for power domain controller:
+- compatible: should be one of the following.
+* rockchip,rk3288-power-controller - for rk3288 type power domain.
+- #power-domain-cells: Number of cells in a power-domain specifier.
+  should be 1.
+- rockchip,pmu: phandle referencing a syscon providing the pmu registers
+- #address-cells: should be 1.
+- #size-cells: should be 0.
+
+Required properties for power domain sub nodes:
+- reg: index of the power domain, should use macros in:
+*  include/dt-bindings/power-domain/rk3288.h - for rk3288 type power 
domain.
+- clocks (optional): phandles to clocks which need to be enabled while power 
domain
+  switches state.
+
+Example:
+
+   power: power-controller {
+  compatible = "rockchip,rk3288-power-controller";
+  #power-domain-cells = <1>;
+  rockchip,pmu = <>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+  pd_gpu {
+  reg = ;
+  clocks = < ACLK_GPU>;
+  };
+   };
+
+Node of a device using power domains must have a power-domains property,
+containing a phandle to the power device node and an index specifying which
+power domain to use.
+The index should use macros in:
+   * include/dt-bindings/power-domain/rk3288.h - for rk3288 type power domain.
+
+Example of the node using power domain:
+
+   node {
+   /* ... */
+   power-domains = < RK3288_PD_GPU>;
+   /* ... */
+   };
-- 
1.9.1


--
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] zram: make rw_page opeartion return 0

2014-11-06 Thread Minchan Kim
Hello Sergey,

On Thu, Nov 06, 2014 at 10:43:42PM +0900, Sergey Senozhatsky wrote:
> Hello,
> 
> On (11/05/14 09:10), Minchan Kim wrote:
> > zram_rw_page returns error code to upper layer with PG_error flag
> > of the page but it should be wrong usage. If submitted IO is
> > hard fail(ie, I/O again will not succeed), we should return 0,
> > indicating that the submission was successful but the IO operation
> > failed.
> > 
> > http://marc.info/?l=linux-mm=141511693112734=2
> > 
> 
> well, `don't return error in case of an error' is a bit misleading.

Yes, it was. It would be better to make it with "boolean"
and return true if sumission was successful. Anyway, it's not out of
the patch.

> 
> apart from zram there seems to be one block driver that does the
> same: brd.c [git grep page_endio]. so I Cc Nick Piggin.
> 
> > This patch fixes below BUG.
> > 
> > [  179.987592] zram0: detected capacity change from 2147483648 to 0
> > [  179.987570] page:ea8d6300 count:2 mapcount:0 
> > mapping:880025348e88 index:0x0
> > [  179.987570] flags: 0x1020002(error|mappedtodisk)
> > [  179.987570] page dumped because: VM_BUG_ON_PAGE(!PageLocked(page))
> > [  179.987570] [ cut here ]
> > [  179.987570] kernel BUG at mm/filemap.c:747!
> > [  179.987570] invalid opcode:  [#1] SMP
> > [  179.987570] Dumping ftrace buffer:
> > [  179.987570](ftrace buffer empty)
> > [  179.987570] Modules linked in:
> > [  179.987570] CPU: 10 PID: 23080 Comm: udisks-part-id Not tainted 
> > 3.18.0-rc2+ #584
> > [  179.987570] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
> > [  179.987570] task: 88001de74200 ti: 88001b22 task.ti: 
> > 88001b22
> > [  179.987570] RIP: 0010:[]  [] 
> > unlock_page+0x82/0x90
> > [  179.987570] RSP: 0018:88001b223998  EFLAGS: 00010246
> > [  179.987570] RAX: 0036 RBX: 88001e009a50 RCX: 
> > 0910090f
> > [  179.987570] RDX: 0910 RSI: 0001 RDI: 
> > 81600a7f
> > [  179.987570] RBP: 88001b223998 R08: 0001 R09: 
> > 0001
> > [  179.987570] R10: 0001 R11:  R12: 
> > 0001
> > [  179.987570] R13: 88001e0099c0 R14: fffb R15: 
> > 88001e0099c0
> > [  179.987570] FS:  7fcb17c73800() GS:880027f4() 
> > knlGS:
> > [  179.987570] CS:  0010 DS:  ES:  CR0: 8005003b
> > [  179.987570] CR2: 7fff1629ebc8 CR3: 1dc4f000 CR4: 
> > 06e0
> > [  179.987570] Stack:
> > [  179.987570]  88001b2239a8 8114afde 88001b2239d8 
> > 811f2e52
> > [  179.987570]  88001e0099c0 fffb  
> > 880025348e88
> > [  179.987570]  88001b223a08 812e9ad3 88001b223a08 
> > 8109b6b3
> > [  179.987570] Call Trace:
> > [  179.987570]  [] page_endio+0x1e/0x80
> > [  179.987570]  [] mpage_end_io+0x42/0x60
> > [  179.987570]  [] bio_endio+0x53/0xa0
> > [  179.987570]  [] ? up_read+0x23/0x40
> > [  179.987570]  [] zram_make_request+0x2a9/0x3c0
> > [  179.987570]  [] generic_make_request+0xc0/0x100
> > [  179.987570]  [] submit_bio+0x75/0x140
> > [  179.987570]  [] ? submit_bio+0x5/0x140
> > [  179.987570]  [] mpage_bio_submit+0x33/0x40
> > [  179.987570]  [] mpage_readpages+0xf5/0x110
> > [  179.987570]  [] ? I_BDEV+0x10/0x10
> > [  179.987570]  [] ? I_BDEV+0x10/0x10
> > [  179.987570]  [] ? ftrace_call+0x5/0x2f
> > [  179.987570]  [] ? ftrace_call+0x5/0x2f
> > [  179.987570]  [] ? blkdev_write_begin+0x30/0x30
> > [  179.987570]  [] ? I_BDEV+0x10/0x10
> > [  179.987570]  [] blkdev_readpages+0x1d/0x20
> > [  179.987570]  [] __do_page_cache_readahead+0x204/0x290
> > [  179.987570]  [] ? __do_page_cache_readahead+0xc9/0x290
> > [  179.987570]  [] ? find_get_entry+0x5/0x130
> > [  179.987570]  [] force_page_cache_readahead+0x7d/0xb0
> > [  179.987570]  [] page_cache_sync_readahead+0x43/0x50
> > [  179.987570]  [] generic_file_read_iter+0x451/0x650
> > [  179.987570]  [] ? ftrace_call+0x5/0x2f
> > [  179.987570]  [] blkdev_read_iter+0x37/0x40
> > [  179.987570]  [] new_sync_read+0x78/0xb0
> > [  179.987570]  [] vfs_read+0xab/0x180
> > [  179.987570]  [] SyS_read+0x52/0xb0
> > [  179.987570]  [] system_call_fastpath+0x12/0x17
> > [  179.987570] Code: 00 4c 8b 82 f8 00 00 00 31 d2 48 d3 ee 48 8d 3c f6 48 
> > 89 c6 49 8d 3c f8 e8 dc 9f f4 ff 5d c3 48 c7 c6 88 2c a0 81 e8 1e a8 02 00 
> > <0f> 0b 66 66 66 2e 0f 1f 84 00 00 00 00 00 e8 bb 83 4b 00 55 48
> > [  179.987570] RIP  [] unlock_page+0x82/0x90
> > [  179.987570]  RSP 
> > [  179.987570] ---[ end trace 39c73c1d9da87ec4 ]---
> > [  180.030327] zram0: detected capacity change from 0 to 2147483648
> > [  180.033795] Adding 2097148k swap on /dev/zram0.  Priority:-1 extents:1 
> > across:2097148k SSFS
> > [  181.978291] zram_kern_compi (2685): drop_caches: 3
> > 
> > Cc: Matthew Wilcox 
> > Cc: Dave Chinner 
> > Cc: Karam Lee 
> > Signed-off-by: 

Re: [linux-nics] [PATCH net 3/5] fm10k: Implement ndo_gso_check()

2014-11-06 Thread Joe Stringer
On Fri, 07 Nov 2014 14:20:08 Vick, Matthew wrote:
> On 11/6/14, 4:55 PM, "Joe Stringer"  wrote:
> >On Thu, Nov 06, 2014 at 11:58:32PM +, Vick, Matthew wrote:
> >> On 11/5/14, 11:36 AM, "Jeff Kirsher" 
> >>
> >>wrote:
> >> Hi Joe, fm10k's hardware is pretty lax about the header size. As long as
> >> the total header length (outer+inner) is 184 bytes or less we're golden,
> >> so if I'm not mistaken that leaves us with a max of 130 bytes beyond the
> >> tunnel header.
> >
> >Oh, okay. To be more explicit, in the case of UDP tunnels I take it that
> >you're talking about L2+L3+(L4+)tunnel+L2+L3+L4 <= 184? (L4 perhaps
> >optional depending on the tunnel protocol used)
> >
> >In that case, the fm10k_gso_check would use something closer to
> >"skb_inner_transport_header(skb) - skb_mac_header(skb) > 184", or
> >perhaps 164 to allow for inner L4 header (?).
> >
> >Joe
> 
> Yes, I'm talking about the full shebang.
> 
> I like the 164 check, personally (with appropriate #define for
> readability).

Thanks for the feedback, I take it that this approach is preferable over the 
other one involving an skb_gso_check() + fm10k_tx_encap_offload() call?
--
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] tty: serial: msm_serial: Use DT aliases

2014-11-06 Thread Frank Rowand
From: Frank Rowand 

Update devicetree binding for msm_serial to reflect msm_serial_probe()
getting line id from the serial alias.

Signed-off-by: Frank Rowand 
---
 Documentation/devicetree/bindings/serial/qcom,msm-uartdm.txt |   15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

Index: b/Documentation/devicetree/bindings/serial/qcom,msm-uartdm.txt
===
--- a/Documentation/devicetree/bindings/serial/qcom,msm-uartdm.txt
+++ b/Documentation/devicetree/bindings/serial/qcom,msm-uartdm.txt
@@ -27,11 +27,18 @@ Optional properties:
 - dmas: Should contain dma specifiers for transmit and receive channels
 - dma-names: Should contain "tx" for transmit and "rx" for receive channels
 
+Additional requirements:
+- Each UART port must have an alias correctly numbered in "aliases" node.
+
 Examples:
 
 A uartdm v1.4 device with dma capabilities.
 
-serial@f991e000 {
+aliases {
+   serial0 = 
+};
+
+serial0: serial@f991e000 {
compatible = "qcom,msm-uartdm-v1.4", "qcom,msm-uartdm";
reg = <0xf991e000 0x1000>;
interrupts = <0 108 0x0>;
@@ -43,7 +50,11 @@ serial@f991e000 {
 
 A uartdm v1.3 device without dma capabilities and part of a GSBI complex.
 
-serial@19c4 {
+aliases {
+   serial0 = 
+};
+
+serial0: serial@19c4 {
compatible = "qcom,msm-uartdm-v1.3", "qcom,msm-uartdm";
reg = <0x19c4 0x1000>,
  <0x19c0 0x1000>;
--
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/5] sched: idle: cpuidle: Check the latency req before idle

2014-11-06 Thread Preeti U Murthy
On 11/06/2014 07:12 PM, Daniel Lezcano wrote:
> 
> Preeti,
> 
> I am wondering if we aren't going to a false debate.
> 
> If the latency_req is 0, we should just poll and not enter in any idle
> state even if one has zero exit latency. With a zero latency req, we
> want full reactivity on the system, not enter an idle state with all the
> computation in the menu governor, no ?
> 
> I agree this patch changes the behavior on PowerPC, but only if the
> latency_req is set to zero. I don't think we are worried about power
> saving when setting this value.
> 
> Couldn't the patch accepted as it is for the sake of consistency on all
> the platform and then we optimize cleanly for the special latency zero
> case ?

Alright Daniel, you can go ahead. I was thinking this patch through and
now realize that, like you point out the logic will only get complicated
with all the additional hack.

But would it be possible to add the weak arch_cpu_idle_loop() call for
the cases where latency requirement is 0 like you had suggested earlier
? This would ensure the polling logic does not break on PowerPC and we
don't bother the governor even. I will add the function in the core
PowerPC code. If arch does not define this function it will fall back to
cpu_idle_loop(). Fair enough?

Regards
Preeti U Murthy

--
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   8   9   10   >