[PATCH] x86/head64: micro optimization: use memset instead of for loop
This patch simplifies clearing of page table directories, by the using of the fast memset() from the arch/x86/lib/memset_64.S. Besides this, we 25 bytes is 25 bytes less than original. text data bss dechex filename 9735144 4970776 15474688301806081cc8500 vmlinux.old 9735119 4970776 15474688301805831cc84e7 vmlinux Signed-off-by: Alexander Kuleshov --- arch/x86/kernel/head64.c | 14 +++--- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index f129a9a..4260ac4 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -40,13 +40,8 @@ pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); /* Wipe all early page tables except for the kernel symbol map */ static void __init reset_early_page_tables(void) { - unsigned long i; - - for (i = 0; i < PTRS_PER_PGD-1; i++) - early_level4_pgt[i].pgd = 0; - + memset(early_level4_pgt, 0, sizeof(pgd_t) * (PTRS_PER_PGD-1)); next_early_pgt = 0; - write_cr3(__pa_nodebug(early_level4_pgt)); } @@ -54,7 +49,6 @@ static void __init reset_early_page_tables(void) int __init early_make_pgtable(unsigned long address) { unsigned long physaddr = address - __PAGE_OFFSET; - unsigned long i; pgdval_t pgd, *pgd_p; pudval_t pud, *pud_p; pmdval_t pmd, *pmd_p; @@ -81,8 +75,7 @@ again: } pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++]; - for (i = 0; i < PTRS_PER_PUD; i++) - pud_p[i] = 0; + memset(pud_p, 0, sizeof(pud_p) * PTRS_PER_PUD); *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE; } pud_p += pud_index(address); @@ -97,8 +90,7 @@ again: } pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++]; - for (i = 0; i < PTRS_PER_PMD; i++) - pmd_p[i] = 0; + memset(pmd_p, 0, sizeof(pmd_p) * PTRS_PER_PMD); *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE; } pmd = (physaddr & PMD_MASK) + early_pmd_flags; -- 2.7.0.25.gfc10eb5
Re: [GIT PULL 0/4] perf/urgent fixes
* Arnaldo Carvalho de Melo wrote: > Hi Ingo, > > Please consider pulling, > > - Arnaldo > > The following changes since commit 45c815f06b80031659c63d7b93e580015d6024dd: > > perf: Synchronously free aux pages in case of allocation failure > (2016-01-21 18:54:27 +0100) > > are available in the git repository at: > > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git > tags/perf-urgent-for-mingo > > for you to fetch changes up to 3f416f22d1e21709a631189ba169f76fd267b374: > > perf stat: Do not clean event's private stats (2016-01-26 11:15:11 -0300) > > > perf/urgent fixes: > > User visible: > > - Fix 'perf stat' stddev reporting due to mistakenly cleaning event > private stats (Jiri Olsa) > > - Fix 'perf test CQM' endless loop detected by 'gcc6 -Wmisleading-indentation' > (Markus Trippelsdorf) > > - Fix behaviour of Shift-Tab when nothing is focussed in the annotate TUI > browser, > detected with gcc6 -Wmisleading-indentation (Markus Trippelsdorf) > > - Fix mem data cacheline hists browser width setting for unresolved > addresses (Jiri Olsa) > > Signed-off-by: Arnaldo Carvalho de Melo > > > Jiri Olsa (2): > perf hists: Fix HISTC_MEM_DCACHELINE width setting > perf stat: Do not clean event's private stats > > Markus Trippelsdorf (2): > perf tests: Remove wrong semicolon in while loop in CQM test > perf annotate browser: Fix behaviour of Shift-Tab with nothing focussed > > tools/perf/arch/x86/tests/intel-cqm.c | 2 +- > tools/perf/ui/browsers/annotate.c | 4 ++-- > tools/perf/util/hist.c| 2 ++ > tools/perf/util/stat.c| 1 - > 4 files changed, 5 insertions(+), 4 deletions(-) Pulled, thanks a lot Arnaldo! Ingo
Re: [BUG REPORT] Soft Lockup in smp_call_function_single+0xD8
On 1/25/16, Jeff Merkey wrote: > On 1/25/16, Jeff Merkey wrote: >> On 1/24/16, Jeff Merkey wrote: >>> On 1/24/16, Jeff Merkey wrote: If I single step with either kgdb, kgdb, or mdb kernel debuggers over a sysret instruction anywhere in the OS, the system hard hangs in smp_call_function_single after the debugger releases the system and it resumes normal operation.The specific place the kernel hangs is in the loop below. The softlockup detector will periodically detect this condition when it occurs, but not always, most of the time the system is just hung and unresponsive. (2)> u smp_call_function_single+d8 hard hang in this loop with EDX=3 0x810fce48 8B55E0 movedx,DWORD PTR [rbp-32]=0xCE037DC0 0x810fce4b 83E201 andedx,0x1 0x810fce4e 75F6jne smp_call_function_single+0xd6 (0x810fce46) (up) < 0x810fce50 EBC3jmp smp_call_function_single+0xa5 (0x810fce15) (up) 0x810fce52 8B05E08EC700moveax,[oops_in_progress]=0x0 0x810fce58 85C0test eax,eax 0x810fce5a 7585jne smp_call_function_single+0x71 (0x810fcde1) (up) 0x810fce5c 803D8E0C9D cmp[__warned.20610]=0x00,0x0 0x810fce63 0F8578FFjne smp_call_function_single+0x71 (0x810fcde1) (up) 0x810fce69 BE2401 movesi,0x124 0x810fce6e 48C7C796B08C81 movrdi,0x818cb096 0x810fce75 894DBC movDWORD PTR [rbp-68]=0x0,ecx 0x810fce78 488955C0movQWORD PTR [rbp-64]=0xFF10,rdx 0x810fce7c E8FF21F8FF call warn_slowpath_null 0x810fce81 C605690C9D0001 mov[__warned.20610]=0x00,0x1 0x810fce88 8B4DBC movecx,DWORD PTR [rbp-68]=0x0 0x810fce8b 488B55C0movrdx,QWORD PTR [rbp-64]=0xFF10 0x810fce8f E94DFF jmp smp_call_function_single+0x71 (0x810fcde1) (up) 0x810fce94 E8A71EF8FF call __stack_chk_fail 0x810fce99 0F1F80 nopDWORD PTR [rax]=0x0 (2)> g The stack backtrace when the bug occurs is: smp_call_function_single+0xd8 unmap_page_range+0x613 flush_tlb_func+0x0 smp_call_function_many+215 native_flush_tlb_others+0x118 flush_tlb_mm_range+0x61 tlb_flush_mmu_tlbonly+0x6b tlb_finish_mmu+0x14 unmap_region+0xe2 vma_rb_erase+0x10f do_unmap+0x217 vm_unmap+0x41 SyS_munmap+0x22 entry_SYSCALL_64_fastpath+0x12 I traced through this code a bunch of times in just normal operations without triggering the bug to get a feel for what it normally sees in EDX and it looks like someone has coded a looping function that always has EDX=0 in every case I saw in the except for when this bug occurs. So the exact C code this maps fro objdump of kernel/smp.o is: 469: e8 62 fe ff ff callq 2d0 46e: 8b 55 e0mov-0x20(%rbp),%edx * previous function call. For multi-cpu calls its even more interesting * as we'll have to ensure no other cpu is observing our csd. */ static void csd_lock_wait(struct call_single_data *csd) { while (smp_load_acquire(&csd->flags) & CSD_FLAG_LOCK) 471: 83 e2 01and$0x1,%edx 474: 74 cf je 445 476: f3 90 pause << 478: 8b 55 e0mov-0x20(%rbp),%edx 47b: 83 e2 01and$0x1,%edx 47e: 75 f6 jne476 <<< 480: eb c3 jmp445 * Can deadlock when called with interrupts disabled. * We allow cpu's that are not yet online though, as no one else can * send smp call function interrupt to this cpu and as such deadlocks * can't happen. */ WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled() Each time this bug occurs csd->flags is always set to a value of 3 and never changes. When the system is just running normally, it seems to be 0 the rest of the time. Setting EDX=0 from the debugger console clears the hang condition and the system seems to recover except the system reports this error from the console when you attempt to load programs, indicating the ability of the system to load shared objects is fritzed. # # ls -l /lib64/libc.so.6 version GLI not found << this error and no shared objects will load # # Jeff >>> >>> I am running down a trace of the MSR values for
[tip:perf/urgent] perf hists: Fix HISTC_MEM_DCACHELINE width setting
Commit-ID: 0805909f59e02036a4e2660159f27dbf8b6084ac Gitweb: http://git.kernel.org/tip/0805909f59e02036a4e2660159f27dbf8b6084ac Author: Jiri Olsa AuthorDate: Wed, 20 Jan 2016 12:56:33 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 26 Jan 2016 11:14:55 -0300 perf hists: Fix HISTC_MEM_DCACHELINE width setting Set correct width for unresolved mem_dcacheline addr. Signed-off-by: Jiri Olsa Cc: David Ahern Cc: Don Zickus Cc: Namhyung Kim Cc: Peter Zijlstra Fixes: 9b32ba71ba90 ("perf tools: Add dcacheline sort") Link: http://lkml.kernel.org/r/1453290995-18485-3-git-send-email-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/hist.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index c226303..68a7612 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -131,6 +131,8 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) symlen = unresolved_col_width + 4 + 2; hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, symlen); + hists__new_col_len(hists, HISTC_MEM_DCACHELINE, + symlen); } if (h->mem_info->iaddr.sym) {
[tip:perf/urgent] perf annotate browser: Fix behaviour of Shift-Tab with nothing focussed
Commit-ID: d4913cbd05bab685e49c8174896e563b2487d054 Gitweb: http://git.kernel.org/tip/d4913cbd05bab685e49c8174896e563b2487d054 Author: Markus Trippelsdorf AuthorDate: Mon, 14 Dec 2015 16:44:03 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 26 Jan 2016 11:14:25 -0300 perf annotate browser: Fix behaviour of Shift-Tab with nothing focussed The issue was pointed out by gcc-6's -Wmisleading-indentation. Signed-off-by: Markus Trippelsdorf Acked-by: Ingo Molnar Cc: Ben Hutchings Cc: Matt Fleming Cc: Peter Zijlstra Fixes: c97cf42219b7 ("perf top: Live TUI Annotation") Link: http://lkml.kernel.org/r/20151214154403.GB1409@x4 Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/annotate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index d4d7cc2..718bd46 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -755,11 +755,11 @@ static int annotate_browser__run(struct annotate_browser *browser, nd = browser->curr_hot; break; case K_UNTAB: - if (nd != NULL) + if (nd != NULL) { nd = rb_next(nd); if (nd == NULL) nd = rb_first(&browser->entries); - else + } else nd = browser->curr_hot; break; case K_F1:
[tip:perf/urgent] perf stat: Do not clean event's private stats
Commit-ID: 3f416f22d1e21709a631189ba169f76fd267b374 Gitweb: http://git.kernel.org/tip/3f416f22d1e21709a631189ba169f76fd267b374 Author: Jiri Olsa AuthorDate: Wed, 20 Jan 2016 12:56:34 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 26 Jan 2016 11:15:11 -0300 perf stat: Do not clean event's private stats Mel reported stddev reporting was broken due to following commit: 106a94a0f8c2 ("perf stat: Introduce read_counters function") This commit merged interval and overall counters reading into single read_counters function. The old interval code cleaned the stddev data for some reason (it's never displayed in interval mode) and the mentioned commit kept on cleaning the stddev data in merged function, which resulted in the stddev not being displayed. Removing the wrong stddev data cleanup init_stats call. Reported-and-Tested-by: Mel Gorman Signed-off-by: Jiri Olsa Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: sta...@vger.kernel.org # v4.2+ Fixes: 106a94a0f8c2 ("perf stat: Introduce read_counters function") Link: http://lkml.kernel.org/r/1453290995-18485-4-git-send-email-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/stat.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 2f901d1..2b58edc 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -310,7 +310,6 @@ int perf_stat_process_counter(struct perf_stat_config *config, int i, ret; aggr->val = aggr->ena = aggr->run = 0; - init_stats(ps->res_stats); if (counter->per_pkg) zero_per_pkg(counter);
[tip:perf/urgent] perf tests: Remove wrong semicolon in while loop in CQM test
Commit-ID: cf89813a5b514bff9b3b5e7eaf2090f22fba62e0 Gitweb: http://git.kernel.org/tip/cf89813a5b514bff9b3b5e7eaf2090f22fba62e0 Author: Markus Trippelsdorf AuthorDate: Mon, 14 Dec 2015 16:43:35 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 26 Jan 2016 11:14:06 -0300 perf tests: Remove wrong semicolon in while loop in CQM test The while loop was spinning. Fix by removing a semicolon. The issue was pointed out by gcc-6's -Wmisleading-indentation. Signed-off-by: Markus Trippelsdorf Reviewed-by: Matt Fleming Acked-by: Ingo Molnar Cc: Ben Hutchings Cc: Peter Zijlstra Fixes: 035827e9f2bd ("perf tests: Add Intel CQM test") Link: http://lkml.kernel.org/r/20151214154335.GA1409@x4 Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/x86/tests/intel-cqm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/arch/x86/tests/intel-cqm.c b/tools/perf/arch/x86/tests/intel-cqm.c index 3e89ba8..7f064eb 100644 --- a/tools/perf/arch/x86/tests/intel-cqm.c +++ b/tools/perf/arch/x86/tests/intel-cqm.c @@ -17,7 +17,7 @@ static pid_t spawn(void) if (pid) return pid; - while(1); + while(1) sleep(5); return 0; }
[tip:x86/boot] x86/boot: Micro-optimize reset_early_page_tables()
Commit-ID: 5e9ebbd87a99ecc6abb74325b0ac63c46891f6f3 Gitweb: http://git.kernel.org/tip/5e9ebbd87a99ecc6abb74325b0ac63c46891f6f3 Author: Alexander Kuleshov AuthorDate: Sat, 30 Jan 2016 14:01:12 +0600 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:20:55 +0100 x86/boot: Micro-optimize reset_early_page_tables() Save 25 bytes of code and make the bootup a tiny bit faster: textdata bss dec filename 9735144 4970776 1547468830180608vmlinux.old 9735119 4970776 1547468830180583vmlinux Signed-off-by: Alexander Kuleshov Cc: Alexander Popov Cc: Andrey Ryabinin Cc: Andy Lutomirski Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1454140872-16926-1-git-send-email-kuleshovm...@gmail.com [ Fixed various small details. ] Signed-off-by: Ingo Molnar --- arch/x86/kernel/head64.c | 14 +++--- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index f129a9a..35843ca 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -40,13 +40,8 @@ pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); /* Wipe all early page tables except for the kernel symbol map */ static void __init reset_early_page_tables(void) { - unsigned long i; - - for (i = 0; i < PTRS_PER_PGD-1; i++) - early_level4_pgt[i].pgd = 0; - + memset(early_level4_pgt, 0, sizeof(pgd_t)*(PTRS_PER_PGD-1)); next_early_pgt = 0; - write_cr3(__pa_nodebug(early_level4_pgt)); } @@ -54,7 +49,6 @@ static void __init reset_early_page_tables(void) int __init early_make_pgtable(unsigned long address) { unsigned long physaddr = address - __PAGE_OFFSET; - unsigned long i; pgdval_t pgd, *pgd_p; pudval_t pud, *pud_p; pmdval_t pmd, *pmd_p; @@ -81,8 +75,7 @@ again: } pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++]; - for (i = 0; i < PTRS_PER_PUD; i++) - pud_p[i] = 0; + memset(pud_p, 0, sizeof(pud_p) * PTRS_PER_PUD); *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE; } pud_p += pud_index(address); @@ -97,8 +90,7 @@ again: } pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++]; - for (i = 0; i < PTRS_PER_PMD; i++) - pmd_p[i] = 0; + memset(pmd_p, 0, sizeof(pmd_p) * PTRS_PER_PMD); *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE; } pmd = (physaddr & PMD_MASK) + early_pmd_flags;
Re: [PATCH v2] dm pref-path: provides preferred path load balance policy
On 01/29/2016 06:50 PM, Benjamin Marzinski wrote: On Fri, Jan 29, 2016 at 02:10:52PM +, Nalla, Ravikanth wrote: Hi Mike, Hannes, Ben This seems like a problem that has already been solved with path groups. If the path(s) in your preferred path group are there, multipath will >>> use them. If not, then it will use your less preferred path(s), and >>> load balance across them > how ever you choose with the path_selectors. I admit that we don't have a path prioritizer that does a good job of >>> allowing users to manually pick a specific path to prefer. But it seems >>> to me that there is > >where we should be solving the issue. Yes as mentioned , it appears that we will be able to achieve the same >> result using the above multipath{...} configuration. However as you >> mentioned I felt that it is not that user friendly in specify the path >> to prefer. So when you mentioned about solving the problem there, could >> you please clarify on what you had in mind and is there anything specific >> from our implementation that can be used there ? There are two changes that I'm working on. 1. I'm adding an option for the alua prioritizer so that setting the ALUA TPG Preferred Bit will cause the alau prioritizer to put that path in a group by itself (with the highest priority). Currently if the preferred bit is set for an active/optimized path, and there are other active/optimized paths, they are all grouped together, and there is no way to change that. So, for people with ALUA enabled hardware, they can just enable the option, and set the Preferred Bit. Hmm? I was under the distinct impression that it's exactly the other way round; at least in my code I have this: switch(aas) { case AAS_OPTIMIZED: rc = 50; break; case AAS_NON_OPTIMIZED: rc = 10; break; case AAS_LBA_DEPENDENT: rc = 5; break; case AAS_STANDBY: rc = 1; break; default: rc = 0; } if (priopath && aas != AAS_OPTIMIZED) rc += 80; ie any path with the 'prio' bit set will be getting a differen priority than those without. Consequently they'll be grouped into different priority groups. I'd be surprised if your code is different, but what do I know ... 2. For people that need to be able to control the exact priority, I'm redoing the weighted handler to allow better ways to specify the paths in a presistent manner. It won't be as simple as the alua method, but it will be actually usable, unlike it's current state. That, however, is greatly appreciated :-) Cheers, Hannes -- Dr. Hannes Reinecke zSeries & Storage h...@suse.de +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
Re: [PATCH v2 3/3] vfs: Enable list batching for the superblock's inode list
* Waiman Long wrote: > The inode_sb_list_add() and inode_sb_list_del() functions in the vfs > layer just perform list addition and deletion under lock. So they can > use the new list batching facility to speed up the list operations > when many CPUs are trying to do it simultaneously. > > In particular, the inode_sb_list_del() function can be a performance > bottleneck when large applications with many threads and associated > inodes exit. With an exit microbenchmark that creates a large number > of threads, attachs many inodes to them and then exits. The runtimes > of that microbenchmark with 1000 threads before and after the patch > on a 4-socket Intel E7-4820 v3 system (48 cores, 96 threads) were > as follows: > > KernelElapsed TimeSystem Time > ----- > Vanilla 4.4 65.29s 82m14s > Patched 4.4 45.69s 49m44s > > The elapsed time and the reported system time were reduced by 30% > and 40% respectively. That's pretty impressive! I'm wondering, why are inode_sb_list_add()/del() even called for a presumably reasonably well cached benchmark running on a system with enough RAM? Are these perhaps thousands of temporary files, already deleted, and released when all the file descriptors are closed as part of sys_exit()? If that's the case then I suspect an even bigger win would be not just to batch the (sb-)global list fiddling, but to potentially turn the sb list into a percpu_alloc() managed set of per CPU lists? It's a bigger change, but it could speed up a lot of other temporary file intensive usecases as well, not just batched delete. Thanks, Ingo
Re: [BUG REPORT] Soft Lockup in smp_call_function_single+0xD8
Here is an MDB debugger trace of the code in question. please note that the flags being compared don't match what's in r11 and the comparison bits are wrong. (3)> Break at 0x81680022 due to - Proceed (single step) RAX: 0080 RBX: 0002 RCX: 7FC9877F2A30 RDX: RSI: 8800BFD9BC00 RDI: 88011FCD6C80 RSP: 8800CD6C7F58 RBP: 7FC988119000 R8: 8800CD6C4000 R9: 017C85499D0E R10: 8800C17BB8F0 R11: 0246 << WRONG!!! R12: 7FC987AC6400 R13: 0002 R14: 0001 R15: CS: 0010 DS: ES: FS: GS: SS: 0018 IP: 81680022 FLAGS: 0146 (PF ZF TF) << real flags 0x81680022 49F7C300010100 test r11,0x10100 < comparison bits correct r11 is WRONG!!! (3)> Break at 0x81680029 due to - Proceed (single step) RAX: 0080 RBX: 0002 RCX: 7FC9877F2A30 RDX: RSI: 8800BFD9BC00 RDI: 88011FCD6C80 RSP: 8800CD6C7F58 RBP: 7FC988119000 R8: 8800CD6C4000 R9: 017C85499D0E R10: 8800C17BB8F0 R11: 0246 R12: 7FC987AC6400 R13: 0002 R14: 0001 R15: CS: 0010 DS: ES: FS: GS: SS: 0018 IP: 81680029 FLAGS: 0146 (PF ZF TF) 0x81680029 753Cjneopportunistic_sysret_failed (0x81680067) (down) (3)> Maps to this code in entry_64.S movqR11(%rsp), %r11 << picks up BOGUS flags here cmpq%r11, EFLAGS(%rsp) /* R11 == RFLAGS */ jne opportunistic_sysret_failed /* * SYSRET can't restore RF. SYSRET can restore TF, but unlike IRET, * restoring TF results in a trap from userspace immediately after * SYSRET. This would cause an infinite loop whenever #DB happens * with register state that satisfies the opportunistic SYSRET * conditions. For example, single-stepping this user code: * * movq $stuck_here, %rcx * pushfq * popq %r11 * stuck_here: * * would never get past 'stuck_here'. */ testq $(X86_EFLAGS_RF|X86_EFLAGS_TF), %r11 jnz opportunistic_sysret_failed Anyway, there is your bug. Should andy go back and fix this -- probably. Jeff
[PATCH] serial: zs: Fix a transmit lockup in console output
Transmit interrupts are disabled and the transmit buffer drained in the course of console output so that polled transmission is possible. That however causes a lost transmit interrupt as the TxIP bit in RR3 is only set on a transmit buffer full-to-empty transition and then iff transmit interrupts are enabled at the same time. Consequently if console output disturbs a regular transmission in progress, the TxIP bit is never set again and the transmission locks up waiting for a transmit interrupt. Fix the problem by restarting transmission manually rather than waiting for a transmit interrupt that will never happen. Signed-off-by: Maciej W. Rozycki --- linux-mips-dec-zs-console-transmit.diff Index: linux-20150524-4maxp64/drivers/tty/serial/zs.c === --- linux-20150524-4maxp64.orig/drivers/tty/serial/zs.c +++ linux-20150524-4maxp64/drivers/tty/serial/zs.c @@ -1181,6 +1181,10 @@ static void zs_console_write(struct cons if (txint & TxINT_ENAB) { zport->regs[1] |= TxINT_ENAB; write_zsreg(zport, R1, zport->regs[1]); + + /* Resume any transmission as the TxIP bit won't be set. */ + if (!zport->tx_stopped) + zs_raw_transmit_chars(zport); } spin_unlock_irqrestore(&scc->zlock, flags); }
[PATCH] scripts/sign-file.c: Add support for signing with a raw signature
This commit adds support for signing a kernel module with a raw detached PKCS#7 signature/message. The signature is not converted and is simply appended to the module so it needs to be in the right format. Using openssl, a valid signature can be generated like this: $ openssl smime -sign -nocerts -noattr -binary -in -inkey \ -signer -outform der -out The resulting raw signature from the above command is (more or less) identical to the raw signature that sign-file itself can produce like this: $ scripts/sign-file -d Signed-off-by: Juerg Haefliger --- scripts/sign-file.c | 213 +--- 1 file changed, 135 insertions(+), 78 deletions(-) diff --git a/scripts/sign-file.c b/scripts/sign-file.c index 250a7a6..d23fe70 100755 --- a/scripts/sign-file.c +++ b/scripts/sign-file.c @@ -2,9 +2,11 @@ * * Copyright © 2014-2015 Red Hat, Inc. All Rights Reserved. * Copyright © 2015 Intel Corporation. + * Copyright © 2016 Hewlett Packard Enterprise Development Company, L.P. * * Authors: David Howells * David Woodhouse + * Juerg Haefliger * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -67,6 +69,8 @@ void format(void) { fprintf(stderr, "Usage: scripts/sign-file [-dp] []\n"); + fprintf(stderr, + " scripts/sign-file -s []\n"); exit(2); } @@ -126,26 +130,84 @@ static int pem_pw_cb(char *buf, int len, int w, void *v) return pwlen; } +static EVP_PKEY *read_private_key(char *private_key_name) +{ + EVP_PKEY *private_key; + + if (!strncmp(private_key_name, "pkcs11:", 7)) { + ENGINE *e; + + ENGINE_load_builtin_engines(); + drain_openssl_errors(); + e = ENGINE_by_id("pkcs11"); + ERR(!e, "Load PKCS#11 ENGINE"); + if (ENGINE_init(e)) + drain_openssl_errors(); + else + ERR(1, "ENGINE_init"); + if (key_pass) + ERR(!ENGINE_ctrl_cmd_string(e, "PIN", key_pass, 0), + "Set PKCS#11 PIN"); + private_key = ENGINE_load_private_key(e, private_key_name, + NULL, NULL); + ERR(!private_key, "%s", private_key_name); + } else { + BIO *b; + + b = BIO_new_file(private_key_name, "rb"); + ERR(!b, "%s", private_key_name); + private_key = PEM_read_bio_PrivateKey(b, NULL, pem_pw_cb, + NULL); + ERR(!private_key, "%s", private_key_name); + BIO_free(b); + } + + return private_key; +} + +static X509 *read_x509(char *x509_name) +{ + X509 *x509; + BIO *b; + + b = BIO_new_file(x509_name, "rb"); + ERR(!b, "%s", x509_name); + x509 = d2i_X509_bio(b, NULL); /* Binary encoded X.509 */ + if (!x509) { + ERR(BIO_reset(b) != 1, "%s", x509_name); + x509 = PEM_read_bio_X509(b, NULL, NULL, +NULL); /* PEM encoded X.509 */ + if (x509) + drain_openssl_errors(); + } + BIO_free(b); + ERR(!x509, "%s", x509_name); + + return x509; +} + int main(int argc, char **argv) { struct module_signature sig_info = { .id_type = PKEY_ID_PKCS7 }; char *hash_algo = NULL; - char *private_key_name, *x509_name, *module_name, *dest_name; + char *private_key_name = NULL, *raw_sig_name = NULL; + char *x509_name, *module_name, *dest_name; bool save_sig = false, replace_orig; bool sign_only = false; + bool raw_sig = false; unsigned char buf[4096]; unsigned long module_size, sig_size; unsigned int use_signed_attrs; const EVP_MD *digest_algo; EVP_PKEY *private_key; #ifndef USE_PKCS7 - CMS_ContentInfo *cms; + CMS_ContentInfo *cms = NULL; unsigned int use_keyid = 0; #else - PKCS7 *pkcs7; + PKCS7 *pkcs7 = NULL; #endif X509 *x509; - BIO *b, *bd = NULL, *bm; + BIO *bd, *bm; int opt, n; OpenSSL_add_all_algorithms(); ERR_load_crypto_strings(); @@ -160,8 +222,9 @@ int main(int argc, char **argv) #endif do { - opt = getopt(argc, argv, "dpk"); + opt = getopt(argc, argv, "sdpk"); switch (opt) { + case 's': raw_sig = true; break; case 'p': save_sig = true; break; case 'd': sign_only = true; save_sig = true; break; #ifndef USE_PKCS7 @@ -177,8 +240,13 @@ int main(int argc, char **argv) if (argc < 4 || argc > 5) format(); - hash_algo = a
Re: [PATCH v5] lib/spinlock_debug.c: prevent a recursive cycle in the debug code
* Byungchul Park wrote: > + > + /* > + * If this function is called from printk(), then we should > + * not call printk() more. Or it will cause an infinite > + * recursive cycle! This should be something like: > + * If this function is called from within printk() then we > + * should not call printk() again, or it will recurse > + * infinitely. Thanks, Ingo
[tip:sched/urgent] pid: Fix spelling in comments
Commit-ID: 840d6fe7425ffb6a62d53b2759e01ae6daf90e4e Gitweb: http://git.kernel.org/tip/840d6fe7425ffb6a62d53b2759e01ae6daf90e4e Author: Zhen Lei AuthorDate: Sat, 30 Jan 2016 10:04:17 +0800 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:28:18 +0100 pid: Fix spelling in comments Accidentally discovered this typo when I studied this module. Signed-off-by: Zhen Lei Cc: Hanjun Guo Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Tianhong Ding Cc: Xinwei Hu Cc: Zefan Li Link: http://lkml.kernel.org/r/1454119457-11272-1-git-send-email-thunder.leiz...@huawei.com Signed-off-by: Ingo Molnar --- kernel/pid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/pid.c b/kernel/pid.c index 78b3d9f..e793d09 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -588,7 +588,7 @@ void __init pidhash_init(void) void __init pidmap_init(void) { - /* Veryify no one has done anything silly */ + /* Verify no one has done anything silly: */ BUILD_BUG_ON(PID_MAX_LIMIT >= PIDNS_HASH_ADDING); /* bump default and minimum pid_max based on number of cpus */
[tip:core/resources] resource: Handle resource flags properly
Commit-ID: a3650d53ba16ec412185abb98f231e9ba6bcdc65 Gitweb: http://git.kernel.org/tip/a3650d53ba16ec412185abb98f231e9ba6bcdc65 Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:18 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:56 +0100 resource: Handle resource flags properly I/O resource flags consist of I/O resource types and modifier bits. Therefore, checking an I/O resource type in 'flags' must be performed with a bitwise operation. Fix find_next_iomem_res() and region_intersects() that simply compare 'flags' against a given value. Also change __request_region() to set 'res->flags' from resource_type() and resource_ext_type() of the parent, so that children nodes will inherit the extended I/O resource type. Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dan Williams Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Jakub Sitnicki Cc: Jiang Liu Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Peter Zijlstra Cc: Rafael J. Wysocki Cc: Thomas Gleixner Cc: Toshi Kani Cc: Vinod Koul Cc: linux-a...@vger.kernel.org Cc: linux-mm Link: http://lkml.kernel.org/r/1453841853-11383-3-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- kernel/resource.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index 09c0597..96afc80 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -358,7 +358,7 @@ static int find_next_iomem_res(struct resource *res, char *name, read_lock(&resource_lock); for (p = iomem_resource.child; p; p = next_resource(p, sibling_only)) { - if (p->flags != res->flags) + if ((p->flags & res->flags) != res->flags) continue; if (name && strcmp(p->name, name)) continue; @@ -519,7 +519,8 @@ int region_intersects(resource_size_t start, size_t size, const char *name) read_lock(&resource_lock); for (p = iomem_resource.child; p ; p = p->sibling) { - bool is_type = strcmp(p->name, name) == 0 && p->flags == flags; + bool is_type = strcmp(p->name, name) == 0 && + ((p->flags & flags) == flags); if (start >= p->start && start <= p->end) is_type ? type++ : other++; @@ -1071,7 +1072,7 @@ struct resource * __request_region(struct resource *parent, res->name = name; res->start = start; res->end = start + n - 1; - res->flags = resource_type(parent); + res->flags = resource_type(parent) | resource_ext_type(parent); res->flags |= IORESOURCE_BUSY | flags; write_lock(&resource_lock);
[tip:core/resources] resource: Add System RAM resource type
Commit-ID: 9babd5c8caa6e62c116efc3a64a09f65af4112b0 Gitweb: http://git.kernel.org/tip/9babd5c8caa6e62c116efc3a64a09f65af4112b0 Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:17 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:56 +0100 resource: Add System RAM resource type The IORESOURCE_MEM I/O resource type is used for all types of memory-mapped ranges, ex. System RAM, System ROM, Video RAM, Persistent Memory, PCI Bus, PCI MMCONFIG, ACPI Tables, IOAPIC, reserved, and so on. This requires walk_system_ram_range(), walk_system_ram_res(), and region_intersects() to use strcmp() against string "System RAM" to search for System RAM ranges in the iomem table, which is inefficient. __ioremap_caller() and reserve_memtype() on x86, for instance, call walk_system_ram_range() for every request to check if a given range is in System RAM ranges. However, adding a new I/O resource type for System RAM is not a viable option, see [1]. There are approx. 3800 references to IORESOURCE_MEM in the kernel/drivers, which makes it very difficult to distinguish their usages between new type and IORESOURCE_MEM. The I/O resource types are also used by the PNP subsystem. Therefore, introduce an extended I/O resource type, IORESOURCE_SYSTEM_RAM, which consists of IORESOURCE_MEM and a new modifier flag IORESOURCE_SYSRAM, see [2]. To keep the code 'if (resource_type(r) == IORESOURCE_MEM)' still working for System RAM, resource_ext_type() is added for extracting extended type bits. Link[1]: http://lkml.kernel.org/r/1449168859.9855.54.ca...@hpe.com Link[2]: http://lkml.kernel.org/r/CA+55aFy4WQrWexC4u2LxX9Mw2NVoznw7p3Yh=if4xtf7zkw...@mail.gmail.com Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dan Williams Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Hanjun Guo Cc: Jakub Sitnicki Cc: Jiang Liu Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Peter Zijlstra Cc: Rafael J. Wysocki Cc: Thomas Gleixner Cc: Toshi Kani Cc: linux-a...@vger.kernel.org Cc: linux-mm Link: http://lkml.kernel.org/r/1453841853-11383-2-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- include/linux/ioport.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 24bea08..4b65d94 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -49,12 +49,19 @@ struct resource { #define IORESOURCE_WINDOW 0x0020 /* forwarded by bridge */ #define IORESOURCE_MUXED 0x0040 /* Resource is software muxed */ +#define IORESOURCE_EXT_TYPE_BITS 0x0100/* Resource extended types */ +#define IORESOURCE_SYSRAM 0x0100 /* System RAM (modifier) */ + #define IORESOURCE_EXCLUSIVE 0x0800 /* Userland may not map this resource */ + #define IORESOURCE_DISABLED0x1000 #define IORESOURCE_UNSET 0x2000 /* No address assigned yet */ #define IORESOURCE_AUTO0x4000 #define IORESOURCE_BUSY0x8000 /* Driver has marked this resource busy */ +/* I/O resource extended types */ +#define IORESOURCE_SYSTEM_RAM (IORESOURCE_MEM|IORESOURCE_SYSRAM) + /* PnP IRQ specific bits (IORESOURCE_BITS) */ #define IORESOURCE_IRQ_HIGHEDGE(1<<0) #define IORESOURCE_IRQ_LOWEDGE (1<<1) @@ -170,6 +177,10 @@ static inline unsigned long resource_type(const struct resource *res) { return res->flags & IORESOURCE_TYPE_BITS; } +static inline unsigned long resource_ext_type(const struct resource *res) +{ + return res->flags & IORESOURCE_EXT_TYPE_BITS; +} /* True iff r1 completely contains r2 */ static inline bool resource_contains(struct resource *r1, struct resource *r2) {
[tip:core/resources] x86/e820: Set System RAM type and descriptor
Commit-ID: f33b14a4b96b185634848046f54fb0d5028566a9 Gitweb: http://git.kernel.org/tip/f33b14a4b96b185634848046f54fb0d5028566a9 Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:20 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:57 +0100 x86/e820: Set System RAM type and descriptor Change e820_reserve_resources() to set 'flags' and 'desc' from e820 types. Set E820_RESERVED_KERN and E820_RAM's (System RAM) io resource type to IORESOURCE_SYSTEM_RAM. Do the same for "Kernel data", "Kernel code", and "Kernel bss", which are child nodes of System RAM. I/O resource descriptor is set to 'desc' for entries that are (and will be) target ranges of walk_iomem_res() and region_intersects(). Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Baoquan He Cc: Borislav Petkov Cc: Brian Gerst Cc: Dan Williams Cc: Dave Young Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Jiri Kosina Cc: Joerg Roedel Cc: Juergen Gross Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Mark Salter Cc: Paolo Bonzini Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Tony Luck Cc: Toshi Kani Cc: WANG Chao Cc: linux-a...@vger.kernel.org Cc: linux-mm Link: http://lkml.kernel.org/r/1453841853-11383-5-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- arch/x86/kernel/e820.c | 38 +- arch/x86/kernel/setup.c | 6 +++--- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 569c1e4..837365f 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -925,6 +925,41 @@ static const char *e820_type_to_string(int e820_type) } } +static unsigned long e820_type_to_iomem_type(int e820_type) +{ + switch (e820_type) { + case E820_RESERVED_KERN: + case E820_RAM: + return IORESOURCE_SYSTEM_RAM; + case E820_ACPI: + case E820_NVS: + case E820_UNUSABLE: + case E820_PRAM: + case E820_PMEM: + default: + return IORESOURCE_MEM; + } +} + +static unsigned long e820_type_to_iores_desc(int e820_type) +{ + switch (e820_type) { + case E820_ACPI: + return IORES_DESC_ACPI_TABLES; + case E820_NVS: + return IORES_DESC_ACPI_NV_STORAGE; + case E820_PMEM: + return IORES_DESC_PERSISTENT_MEMORY; + case E820_PRAM: + return IORES_DESC_PERSISTENT_MEMORY_LEGACY; + case E820_RESERVED_KERN: + case E820_RAM: + case E820_UNUSABLE: + default: + return IORES_DESC_NONE; + } +} + static bool do_mark_busy(u32 type, struct resource *res) { /* this is the legacy bios/dos rom-shadow + mmio region */ @@ -967,7 +1002,8 @@ void __init e820_reserve_resources(void) res->start = e820.map[i].addr; res->end = end; - res->flags = IORESOURCE_MEM; + res->flags = e820_type_to_iomem_type(e820.map[i].type); + res->desc = e820_type_to_iores_desc(e820.map[i].type); /* * don't register the region that could be conflicted with diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index d3d80e6..aa52c10 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -152,21 +152,21 @@ static struct resource data_resource = { .name = "Kernel data", .start = 0, .end= 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM }; static struct resource code_resource = { .name = "Kernel code", .start = 0, .end= 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM }; static struct resource bss_resource = { .name = "Kernel bss", .start = 0, .end= 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM };
[tip:core/resources] ia64: Set System RAM type and descriptor
Commit-ID: 03cb525eb25018cf5f3da01d0f1391fc8b37805a Gitweb: http://git.kernel.org/tip/03cb525eb25018cf5f3da01d0f1391fc8b37805a Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:21 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:57 +0100 ia64: Set System RAM type and descriptor Change efi_initialize_iomem_resources() to set 'flags' and 'desc' for EFI memory types. IORESOURCE_SYSRAM, a modifier bit, is set for System RAM as IORESOURCE_MEM is already set. IORESOURCE_SYSTEM_RAM is defined as (IORESOURCE_MEM|IORESOURCE_SYSRAM). I/O resource descriptor is set for "ACPI Non-volatile Storage" and "Persistent Memory". Also set IORESOURCE_SYSTEM_RAM for "Kernel code", "Kernel data", and "Kernel bss". Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Acked-by: Tony Luck Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Matt Fleming Cc: Peter Zijlstra Cc: Rusty Russell Cc: Thomas Gleixner Cc: Toshi Kani Cc: linux-a...@vger.kernel.org Cc: linux-efi Cc: linux-i...@vger.kernel.org Cc: linux-mm Link: http://lkml.kernel.org/r/1453841853-11383-6-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- arch/ia64/kernel/efi.c | 13 ++--- arch/ia64/kernel/setup.c | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c index caae3f4..300dac3 100644 --- a/arch/ia64/kernel/efi.c +++ b/arch/ia64/kernel/efi.c @@ -1178,7 +1178,7 @@ efi_initialize_iomem_resources(struct resource *code_resource, efi_memory_desc_t *md; u64 efi_desc_size; char *name; - unsigned long flags; + unsigned long flags, desc; efi_map_start = __va(ia64_boot_param->efi_memmap); efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size; @@ -1193,6 +1193,8 @@ efi_initialize_iomem_resources(struct resource *code_resource, continue; flags = IORESOURCE_MEM | IORESOURCE_BUSY; + desc = IORES_DESC_NONE; + switch (md->type) { case EFI_MEMORY_MAPPED_IO: @@ -1207,14 +1209,17 @@ efi_initialize_iomem_resources(struct resource *code_resource, if (md->attribute & EFI_MEMORY_WP) { name = "System ROM"; flags |= IORESOURCE_READONLY; - } else if (md->attribute == EFI_MEMORY_UC) + } else if (md->attribute == EFI_MEMORY_UC) { name = "Uncached RAM"; - else + } else { name = "System RAM"; + flags |= IORESOURCE_SYSRAM; + } break; case EFI_ACPI_MEMORY_NVS: name = "ACPI Non-volatile Storage"; + desc = IORES_DESC_ACPI_NV_STORAGE; break; case EFI_UNUSABLE_MEMORY: @@ -1224,6 +1229,7 @@ efi_initialize_iomem_resources(struct resource *code_resource, case EFI_PERSISTENT_MEMORY: name = "Persistent Memory"; + desc = IORES_DESC_PERSISTENT_MEMORY; break; case EFI_RESERVED_TYPE: @@ -1246,6 +1252,7 @@ efi_initialize_iomem_resources(struct resource *code_resource, res->start = md->phys_addr; res->end = md->phys_addr + efi_md_size(md) - 1; res->flags = flags; + res->desc = desc; if (insert_resource(&iomem_resource, res) < 0) kfree(res); diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index 4f118b0..2029a38 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c @@ -80,17 +80,17 @@ unsigned long vga_console_membase; static struct resource data_resource = { .name = "Kernel data", - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM }; static struct resource code_resource = { .name = "Kernel code", - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM }; static struct resource bss_resource = { .name = "Kernel bss", - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM }; unsigned long ia64_max_cacheline_size;
[tip:core/resources] resource: Add I/O resource descriptor
Commit-ID: 43ee493bde78da00deaf5737925365c691a036ad Gitweb: http://git.kernel.org/tip/43ee493bde78da00deaf5737925365c691a036ad Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:19 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:56 +0100 resource: Add I/O resource descriptor walk_iomem_res() and region_intersects() still need to use strcmp() for searching a resource entry by @name in the iomem table. This patch introduces I/O resource descriptor 'desc' in struct resource for the iomem search interfaces. Drivers can assign their unique descriptor to a range when they support the search interfaces. Otherwise, 'desc' is set to IORES_DESC_NONE (0). This avoids changing most of the drivers as they typically allocate resource entries statically, or by calling alloc_resource(), kzalloc(), or alloc_bootmem_low(), which set the field to zero by default. A later patch will address some drivers that use kmalloc() without zero'ing the field. Also change release_mem_region_adjustable() to set 'desc' when its resource entry gets separated. Other resource interfaces are also changed to initialize 'desc' explicitly although alloc_resource() sets it to 0. Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dan Williams Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Jakub Sitnicki Cc: Jiang Liu Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Toshi Kani Cc: linux-a...@vger.kernel.org Cc: linux-mm Link: http://lkml.kernel.org/r/1453841853-11383-4-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- include/linux/ioport.h | 18 ++ kernel/resource.c | 5 + 2 files changed, 23 insertions(+) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 4b65d94..983bea0 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -20,6 +20,7 @@ struct resource { resource_size_t end; const char *name; unsigned long flags; + unsigned long desc; struct resource *parent, *sibling, *child; }; @@ -112,6 +113,22 @@ struct resource { /* PCI control bits. Shares IORESOURCE_BITS with above PCI ROM. */ #define IORESOURCE_PCI_FIXED (1<<4) /* Do not move resource */ +/* + * I/O Resource Descriptors + * + * Descriptors are used by walk_iomem_res_desc() and region_intersects() + * for searching a specific resource range in the iomem table. Assign + * a new descriptor when a resource range supports the search interfaces. + * Otherwise, resource.desc must be set to IORES_DESC_NONE (0). + */ +enum { + IORES_DESC_NONE = 0, + IORES_DESC_CRASH_KERNEL = 1, + IORES_DESC_ACPI_TABLES = 2, + IORES_DESC_ACPI_NV_STORAGE = 3, + IORES_DESC_PERSISTENT_MEMORY= 4, + IORES_DESC_PERSISTENT_MEMORY_LEGACY = 5, +}; /* helpers to define resources */ #define DEFINE_RES_NAMED(_start, _size, _name, _flags) \ @@ -120,6 +137,7 @@ struct resource { .end = (_start) + (_size) - 1, \ .name = (_name),\ .flags = (_flags), \ + .desc = IORES_DESC_NONE,\ } #define DEFINE_RES_IO_NAMED(_start, _size, _name) \ diff --git a/kernel/resource.c b/kernel/resource.c index 96afc80..61512e9 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -949,6 +949,7 @@ static void __init __reserve_region_with_split(struct resource *root, res->start = start; res->end = end; res->flags = IORESOURCE_BUSY; + res->desc = IORES_DESC_NONE; while (1) { @@ -983,6 +984,7 @@ static void __init __reserve_region_with_split(struct resource *root, next_res->start = conflict->end + 1; next_res->end = end; next_res->flags = IORESOURCE_BUSY; + next_res->desc = IORES_DESC_NONE; } } else { res->start = conflict->end + 1; @@ -1074,6 +1076,7 @@ struct resource * __request_region(struct resource *parent, res->end = start + n - 1; res->flags = resource_type(parent) | resource_ext_type(parent); res->flags |= IORESOURCE_BUSY | flags; + res->desc = IORES_DESC_NONE; write_lock(&resource_lock); @@ -1238,6 +1241,7 @@ int release_mem_region_adjustable(struct resource *parent, new_res->start = end + 1; new_res->end = res->end; new_res->flags = res->flags; + new_res->desc = res->desc; new_res->parent = res->pare
[tip:core/resources] arch: Set IORESOURCE_SYSTEM_RAM flag for System RAM
Commit-ID: 35d98e93fe6a7ab612f6b389ce42c1dc135d6eef Gitweb: http://git.kernel.org/tip/35d98e93fe6a7ab612f6b389ce42c1dc135d6eef Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:22 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:57 +0100 arch: Set IORESOURCE_SYSTEM_RAM flag for System RAM Set IORESOURCE_SYSTEM_RAM in flags of resource ranges with "System RAM", "Kernel code", "Kernel data", and "Kernel bss". Note that: - IORESOURCE_SYSRAM (i.e. modifier bit) is set in flags when IORESOURCE_MEM is already set. IORESOURCE_SYSTEM_RAM is defined as (IORESOURCE_MEM|IORESOURCE_SYSRAM). - Some archs do not set 'flags' for children nodes, such as "Kernel code". This patch does not change 'flags' in this case. Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Toshi Kani Cc: linux-a...@vger.kernel.org Cc: linux-arm-ker...@lists.infradead.org Cc: linux-m...@linux-mips.org Cc: linux-mm Cc: linux-par...@vger.kernel.org Cc: linux-s...@vger.kernel.org Cc: linux...@vger.kernel.org Cc: linuxppc-...@lists.ozlabs.org Cc: sparcli...@vger.kernel.org Link: http://lkml.kernel.org/r/1453841853-11383-7-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- arch/arm/kernel/setup.c | 6 +++--- arch/arm64/kernel/setup.c | 6 +++--- arch/avr32/kernel/setup.c | 6 +++--- arch/m32r/kernel/setup.c | 4 ++-- arch/mips/kernel/setup.c | 10 ++ arch/parisc/mm/init.c | 6 +++--- arch/powerpc/mm/mem.c | 2 +- arch/s390/kernel/setup.c | 8 arch/score/kernel/setup.c | 2 +- arch/sh/kernel/setup.c| 8 arch/sparc/mm/init_64.c | 8 arch/tile/kernel/setup.c | 11 --- arch/unicore32/kernel/setup.c | 6 +++--- 13 files changed, 45 insertions(+), 38 deletions(-) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 7d0cba6f..139791e 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -176,13 +176,13 @@ static struct resource mem_res[] = { .name = "Kernel code", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM }, { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM } }; @@ -851,7 +851,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) res->name = "System RAM"; res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; - res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; + res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; request_resource(&iomem_resource, res); diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 8119479..450987d 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -73,13 +73,13 @@ static struct resource mem_res[] = { .name = "Kernel code", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM }, { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM } }; @@ -210,7 +210,7 @@ static void __init request_standard_resources(void) res->name = "System RAM"; res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; - res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; + res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; request_resource(&iomem_resource, res); diff --git a/arch/avr32/kernel/setup.c b/arch/avr32/kernel/setup.c index 209ae5a..e692889 100644 --- a/arch/avr32/kernel/setup.c +++ b/arch/avr32/kernel/setup.c @@ -49,13 +49,13 @@ static struct resource __initdata kernel_data = { .name = "Kernel data", .start = 0, .end= 0, - .flags = IORESOURCE_MEM, + .flags = IORESOURCE_SYSTEM_RAM, }; static struct resource __initdata kernel_code = { .name = "Kernel code", .start = 0, .end= 0, - .flags = IORESOURCE_MEM, + .flags = IORESOURCE_SYSTEM_RAM, .sibling = &kernel_data, }; @@ -134,7 +134,7 @@ add_physical_memory(resource_size_t start, resource_size_t end) new->start = start;
Re: [tip:x86/asm] x86/syscalls: Remove __SYSCALL_COMMON and __SYSCALL_X32
* Andy Lutomirski wrote: > >>>+ if [ "$abi" == "COMMON" -o "$abi" == "64" ]; then > >>>+ # COMMON is the same as 64, except that we don't expect X32 > >>>+ # programs to use it. Our expectation has nothing to do with > >>>+ # any generated code, so treat them the same. > >>>+ emit 64 "$nr" "$entry" "$compat" > >>>+ elif [ "$abi" == "X32" ]; then > >>>+ # X32 is equivalent to 64 on an X32-compatible kernel. > >>>+ echo "#ifdef CONFIG_X86_X32_ABI" > >>>+ emit 64 "$nr" "$entry" "$compat" > >>>+ echo "#endif" > >>>+ elif [ "$abi" == "I386" ]; then > >>>+ emit "$abi" "$nr" "$entry" "$compat" > >>>+ else > >>>+ echo "Unknown abi $abi" >&2 > >>>+ exit 1 > >>>+ fi > No combinatorial explosion, please. We could use __SYSCALL(nr, sym, > abi, qual), though. Mind fixing it, so that we get back the arch-neutral property? Thanks, Ingo
[tip:core/resources] kexec: Set IORESOURCE_SYSTEM_RAM for System RAM
Commit-ID: 1a085d0727afaedb9506f04798516298b1676e11 Gitweb: http://git.kernel.org/tip/1a085d0727afaedb9506f04798516298b1676e11 Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:23 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:57 +0100 kexec: Set IORESOURCE_SYSTEM_RAM for System RAM Set proper ioresource flags and types for crash kernel reservation areas. Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Reviewed-by: Dave Young Cc: Andrew Morton Cc: Andy Lutomirski Cc: Baoquan He Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: HATAYAMA Daisuke Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Minfei Huang Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Toshi Kani Cc: Vivek Goyal Cc: ke...@lists.infradead.org Cc: linux-a...@vger.kernel.org Cc: linux-mm Link: http://lkml.kernel.org/r/1453841853-11383-8-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- kernel/kexec_core.c | 8 +--- kernel/kexec_file.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 8dc6591..8d34308 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -66,13 +66,15 @@ struct resource crashk_res = { .name = "Crash kernel", .start = 0, .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, + .desc = IORES_DESC_CRASH_KERNEL }; struct resource crashk_low_res = { .name = "Crash kernel", .start = 0, .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, + .desc = IORES_DESC_CRASH_KERNEL }; int kexec_should_crash(struct task_struct *p) @@ -959,7 +961,7 @@ int crash_shrink_memory(unsigned long new_size) ram_res->start = end; ram_res->end = crashk_res.end; - ram_res->flags = IORESOURCE_BUSY | IORESOURCE_MEM; + ram_res->flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM; ram_res->name = "System RAM"; crashk_res.end = end - 1; diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 007b791..2bfcdc0 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -525,7 +525,7 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz, /* Walk the RAM ranges and allocate a suitable range for the buffer */ if (image->type == KEXEC_TYPE_CRASH) ret = walk_iomem_res("Crash kernel", -IORESOURCE_MEM | IORESOURCE_BUSY, +IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY, crashk_res.start, crashk_res.end, kbuf, locate_mem_hole_callback); else
[tip:core/resources] xen, mm: Set IORESOURCE_SYSTEM_RAM to System RAM
Commit-ID: 782b86641e5d471e9eb1cf0072c012d2f758e568 Gitweb: http://git.kernel.org/tip/782b86641e5d471e9eb1cf0072c012d2f758e568 Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:24 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:58 +0100 xen, mm: Set IORESOURCE_SYSTEM_RAM to System RAM Set IORESOURCE_SYSTEM_RAM in struct resource.flags of "System RAM" entries. Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Acked-by: David Vrabel # xen Cc: Andrew Banman Cc: Andrew Morton Cc: Andy Lutomirski Cc: Boris Ostrovsky Cc: Borislav Petkov Cc: Brian Gerst Cc: Dan Williams Cc: David Rientjes Cc: Denys Vlasenko Cc: Gu Zheng Cc: H. Peter Anvin Cc: Konrad Rzeszutek Wilk Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Mel Gorman Cc: Naoya Horiguchi Cc: Peter Zijlstra Cc: Tang Chen Cc: Thomas Gleixner Cc: Toshi Kani Cc: linux-a...@vger.kernel.org Cc: linux-mm Cc: xen-de...@lists.xenproject.org Link: http://lkml.kernel.org/r/1453841853-11383-9-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- drivers/xen/balloon.c | 2 +- mm/memory_hotplug.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 12eab50..dc4305b 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -257,7 +257,7 @@ static struct resource *additional_memory_resource(phys_addr_t size) return NULL; res->name = "System RAM"; - res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; + res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; ret = allocate_resource(&iomem_resource, res, size, 0, -1, diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 4af58a3..979b18c 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -138,7 +138,7 @@ static struct resource *register_memory_resource(u64 start, u64 size) res->name = "System RAM"; res->start = start; res->end = start + size - 1; - res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; + res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; if (request_resource(&iomem_resource, res) < 0) { pr_debug("System RAM resource %pR cannot be added\n", res); kfree(res);
[tip:core/resources] resource: Change walk_system_ram() to use System RAM type
Commit-ID: bd7e6cb30ced147292d854a54d4a1f5c5a05d927 Gitweb: http://git.kernel.org/tip/bd7e6cb30ced147292d854a54d4a1f5c5a05d927 Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:26 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:58 +0100 resource: Change walk_system_ram() to use System RAM type Now that all System RAM resource entries have been initialized to IORESOURCE_SYSTEM_RAM type, change walk_system_ram_res() and walk_system_ram_range() to call find_next_iomem_res() by setting @res.flags to IORESOURCE_SYSTEM_RAM and @name to NULL. With this change, they walk through the iomem table to find System RAM ranges without the need to do strcmp() on the resource names. No functional change is made to the interfaces. Signed-off-by: Toshi Kani [ Boris: fixup comments. ] Signed-off-by: Borislav Petkov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dan Williams Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Jakub Sitnicki Cc: Jiang Liu Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Toshi Kani Cc: linux-a...@vger.kernel.org Cc: linux-mm Link: http://lkml.kernel.org/r/1453841853-11383-11-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- kernel/resource.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index 61512e9..994f1e41 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -415,11 +415,11 @@ int walk_iomem_res(char *name, unsigned long flags, u64 start, u64 end, } /* - * This function calls callback against all memory range of "System RAM" - * which are marked as IORESOURCE_MEM and IORESOUCE_BUSY. - * Now, this function is only for "System RAM". This function deals with - * full ranges and not pfn. If resources are not pfn aligned, dealing - * with pfn can truncate ranges. + * This function calls the @func callback against all memory ranges of type + * System RAM which are marked as IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY. + * Now, this function is only for System RAM, it deals with full ranges and + * not PFNs. If resources are not PFN-aligned, dealing with PFNs can truncate + * ranges. */ int walk_system_ram_res(u64 start, u64 end, void *arg, int (*func)(u64, u64, void *)) @@ -430,10 +430,10 @@ int walk_system_ram_res(u64 start, u64 end, void *arg, res.start = start; res.end = end; - res.flags = IORESOURCE_MEM | IORESOURCE_BUSY; + res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; orig_end = res.end; while ((res.start < res.end) && - (!find_next_iomem_res(&res, "System RAM", true))) { + (!find_next_iomem_res(&res, NULL, true))) { ret = (*func)(res.start, res.end, arg); if (ret) break; @@ -446,9 +446,9 @@ int walk_system_ram_res(u64 start, u64 end, void *arg, #if !defined(CONFIG_ARCH_HAS_WALK_MEMORY) /* - * This function calls callback against all memory range of "System RAM" - * which are marked as IORESOURCE_MEM and IORESOUCE_BUSY. - * Now, this function is only for "System RAM". + * This function calls the @func callback against all memory ranges of type + * System RAM which are marked as IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY. + * It is to be used only for System RAM. */ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, void *arg, int (*func)(unsigned long, unsigned long, void *)) @@ -460,10 +460,10 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, res.start = (u64) start_pfn << PAGE_SHIFT; res.end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1; - res.flags = IORESOURCE_MEM | IORESOURCE_BUSY; + res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; orig_end = res.end; while ((res.start < res.end) && - (find_next_iomem_res(&res, "System RAM", true) >= 0)) { + (find_next_iomem_res(&res, NULL, true) >= 0)) { pfn = (res.start + PAGE_SIZE - 1) >> PAGE_SHIFT; end_pfn = (res.end + 1) >> PAGE_SHIFT; if (end_pfn > pfn) @@ -484,7 +484,7 @@ static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) } /* * This generic page_is_ram() returns true if specified address is - * registered as "System RAM" in iomem_resource list. + * registered as System RAM in iomem_resource list. */ int __weak page_is_ram(unsigned long pfn) {
[tip:core/resources] arm/samsung: Change s3c_pm_run_res() to use System RAM type
Commit-ID: 05fee7cfab7fa9d57e71f00bdd8fcff0cf5044a0 Gitweb: http://git.kernel.org/tip/05fee7cfab7fa9d57e71f00bdd8fcff0cf5044a0 Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:27 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:58 +0100 arm/samsung: Change s3c_pm_run_res() to use System RAM type Change s3c_pm_run_res() to check with IORESOURCE_SYSTEM_RAM, instead of strcmp() with "System RAM", to walk through System RAM ranges in the iomem table. No functional change is made to the interface. Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Reviewed-by: Krzysztof Kozlowski Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Kukjin Kim Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Toshi Kani Cc: linux-a...@vger.kernel.org Cc: linux-arm-ker...@lists.infradead.org Cc: linux-mm Cc: linux-samsung-...@vger.kernel.org Link: http://lkml.kernel.org/r/1453841853-11383-12-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- arch/arm/plat-samsung/pm-check.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/plat-samsung/pm-check.c b/arch/arm/plat-samsung/pm-check.c index 04aff2c..70f2f69 100644 --- a/arch/arm/plat-samsung/pm-check.c +++ b/arch/arm/plat-samsung/pm-check.c @@ -53,8 +53,8 @@ static void s3c_pm_run_res(struct resource *ptr, run_fn_t fn, u32 *arg) if (ptr->child != NULL) s3c_pm_run_res(ptr->child, fn, arg); - if ((ptr->flags & IORESOURCE_MEM) && - strcmp(ptr->name, "System RAM") == 0) { + if ((ptr->flags & IORESOURCE_SYSTEM_RAM) + == IORESOURCE_SYSTEM_RAM) { S3C_PMDBG("Found system RAM at %08lx..%08lx\n", (unsigned long)ptr->start, (unsigned long)ptr->end);
[tip:core/resources] memremap: Change region_intersects() to take @flags and @desc
Commit-ID: 1c29f25bf5d6c557017f619b638c619cbbf798c4 Gitweb: http://git.kernel.org/tip/1c29f25bf5d6c557017f619b638c619cbbf798c4 Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:28 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:58 +0100 memremap: Change region_intersects() to take @flags and @desc Change region_intersects() to identify a target with @flags and @desc, instead of @name with strcmp(). Change the callers of region_intersects(), memremap() and devm_memremap(), to set IORESOURCE_SYSTEM_RAM in @flags and IORES_DESC_NONE in @desc when searching System RAM. Also, export region_intersects() so that the ACPI EINJ error injection driver can call this function in a later patch. Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Acked-by: Dan Williams Cc: Andrew Morton Cc: Andy Lutomirski Cc: Ard Biesheuvel Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Jakub Sitnicki Cc: Jan Kara Cc: Jiang Liu Cc: Kees Cook Cc: Kirill A. Shutemov Cc: Konstantin Khlebnikov Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Michal Hocko Cc: Naoya Horiguchi Cc: Peter Zijlstra Cc: Tejun Heo Cc: Thomas Gleixner Cc: Toshi Kani Cc: Vlastimil Babka Cc: linux-a...@vger.kernel.org Cc: linux-mm Link: http://lkml.kernel.org/r/1453841853-11383-13-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- include/linux/mm.h | 3 ++- kernel/memremap.c | 13 +++-- kernel/resource.c | 26 +++--- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index f1cd22f..cd5a300 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -385,7 +385,8 @@ enum { REGION_MIXED, }; -int region_intersects(resource_size_t offset, size_t size, const char *type); +int region_intersects(resource_size_t offset, size_t size, unsigned long flags, + unsigned long desc); /* Support for virtually mapped pages */ struct page *vmalloc_to_page(const void *addr); diff --git a/kernel/memremap.c b/kernel/memremap.c index e517a16..293309c 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -47,7 +47,7 @@ static void *try_ram_remap(resource_size_t offset, size_t size) * being mapped does not have i/o side effects and the __iomem * annotation is not applicable. * - * MEMREMAP_WB - matches the default mapping for "System RAM" on + * MEMREMAP_WB - matches the default mapping for System RAM on * the architecture. This is usually a read-allocate write-back cache. * Morever, if MEMREMAP_WB is specified and the requested remap region is RAM * memremap() will bypass establishing a new mapping and instead return @@ -56,11 +56,12 @@ static void *try_ram_remap(resource_size_t offset, size_t size) * MEMREMAP_WT - establish a mapping whereby writes either bypass the * cache or are written through to memory and never exist in a * cache-dirty state with respect to program visibility. Attempts to - * map "System RAM" with this mapping type will fail. + * map System RAM with this mapping type will fail. */ void *memremap(resource_size_t offset, size_t size, unsigned long flags) { - int is_ram = region_intersects(offset, size, "System RAM"); + int is_ram = region_intersects(offset, size, + IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE); void *addr = NULL; if (is_ram == REGION_MIXED) { @@ -76,7 +77,7 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags) * MEMREMAP_WB is special in that it can be satisifed * from the direct map. Some archs depend on the * capability of memremap() to autodetect cases where -* the requested range is potentially in "System RAM" +* the requested range is potentially in System RAM. */ if (is_ram == REGION_INTERSECTS) addr = try_ram_remap(offset, size); @@ -88,7 +89,7 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags) * If we don't have a mapping yet and more request flags are * pending then we will be attempting to establish a new virtual * address mapping. Enforce that this mapping is not aliasing -* "System RAM" +* System RAM. */ if (!addr && is_ram == REGION_INTERSECTS && flags) { WARN_ONCE(1, "memremap attempted on ram %pa size: %#lx\n", @@ -266,7 +267,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, struct percpu_ref *ref, struct vmem_altmap *altmap) { int is_ram = region_intersects(res->start, resource_size(res), - "System RAM"); + IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE); resource_size_t key, align_start, align_size; struct dev_pagemap *pgmap; struct page_map
[PATCH v2 2/3] [ALSA] portman2x4 - assignment in if
It is not general practice to assign some values inside if statement. Signed-off-by: Sudip Mukherjee --- v2: no change sound/drivers/portman2x4.c | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c index 65b0650..172685d 100644 --- a/sound/drivers/portman2x4.c +++ b/sound/drivers/portman2x4.c @@ -743,7 +743,8 @@ static int snd_portman_probe(struct platform_device *pdev) if (!enable[dev]) return -ENOENT; - if ((err = snd_portman_probe_port(p)) < 0) + err = snd_portman_probe_port(p); + if (err < 0) return err; err = snd_card_new(&pdev->dev, index[dev], id[dev], THIS_MODULE, @@ -770,7 +771,8 @@ static int snd_portman_probe(struct platform_device *pdev) goto __err; } - if ((err = portman_create(card, pardev, &pm)) < 0) { + err = portman_create(card, pardev, &pm); + if (err < 0) { snd_printd("Cannot create main component\n"); parport_unregister_device(pardev); goto __err; @@ -778,7 +780,8 @@ static int snd_portman_probe(struct platform_device *pdev) card->private_data = pm; card->private_free = snd_portman_card_private_free; - if ((err = snd_portman_rawmidi_create(card)) < 0) { + err = snd_portman_rawmidi_create(card); + if (err < 0) { snd_printd("Creating Rawmidi component failed\n"); goto __err; } @@ -792,13 +795,15 @@ static int snd_portman_probe(struct platform_device *pdev) pm->pardev_claimed = 1; /* init device */ - if ((err = portman_device_init(pm)) < 0) + err = portman_device_init(pm); + if (err < 0) goto __err; platform_set_drvdata(pdev, card); /* At this point card will be usable */ - if ((err = snd_card_register(card)) < 0) { + err = snd_card_register(card); + if (err < 0) { snd_printd("Cannot register card\n"); goto __err; } @@ -850,7 +855,8 @@ static int __init snd_portman_module_init(void) { int err; - if ((err = platform_driver_register(&snd_portman_driver)) < 0) + err = platform_driver_register(&snd_portman_driver); + if (err < 0) return err; if (parport_register_driver(&portman_parport_driver) != 0) { -- 1.9.1
[PATCH v2 3/3] [ALSA] portman2x4 - use new parport device model
Modify portman driver to use the new parallel port device model. Signed-off-by: Sudip Mukherjee --- v2: 1. pardev_cb is initialized while declaring, thus removing the use of memset. 2. used pdev->id. 3. v1 did not have the parport probe callback, but we will need the probe callback for binding as the name of the driver and the name of the device is different. 4. in v1 I missed modifying snd_portman_probe_port(). sound/drivers/portman2x4.c | 53 ++ 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c index 172685d..a22f56c 100644 --- a/sound/drivers/portman2x4.c +++ b/sound/drivers/portman2x4.c @@ -650,10 +650,21 @@ static int snd_portman_probe_port(struct parport *p) { struct pardevice *pardev; int res; - - pardev = parport_register_device(p, DRIVER_NAME, -NULL, NULL, NULL, -0, NULL); + struct pardev_cb pdev_cb = { + .preempt = NULL, + .wakeup = NULL, + .private = NULL, + .irq_func = NULL, + .flags = 0, + }; + + /* +* Specify the device number as SNDRV_CARDS + 1 so that the +* device id alloted to this temporary device will never clash +* with an actual device already registered. +*/ + pardev = parport_register_dev_model(p, DRIVER_NAME, &pdev_cb, + SNDRV_CARDS + 1); if (!pardev) return -EIO; @@ -703,10 +714,20 @@ static void snd_portman_detach(struct parport *p) /* nothing to do here */ } +static int snd_portman_dev_probe(struct pardevice *pardev) +{ + if (strcmp(pardev->name, DRIVER_NAME)) + return -ENODEV; + + return 0; +} + static struct parport_driver portman_parport_driver = { - .name = "portman2x4", - .attach = snd_portman_attach, - .detach = snd_portman_detach + .name = "portman2x4", + .probe = snd_portman_dev_probe, + .match_port = snd_portman_attach, + .detach = snd_portman_detach, + .devmodel = true, }; /* @@ -734,6 +755,12 @@ static int snd_portman_probe(struct platform_device *pdev) struct snd_card *card = NULL; struct portman *pm = NULL; int err; + struct pardev_cb portman_cb = { + .preempt = NULL, + .wakeup = NULL, + .irq_func = snd_portman_interrupt, /* ISR */ + .flags = PARPORT_DEV_EXCL, /* flags */ + }; p = platform_get_drvdata(pdev); platform_set_drvdata(pdev, NULL); @@ -758,13 +785,11 @@ static int snd_portman_probe(struct platform_device *pdev) sprintf(card->longname, "%s at 0x%lx, irq %i", card->shortname, p->base, p->irq); - pardev = parport_register_device(p, /* port */ -DRIVER_NAME, /* name */ -NULL, /* preempt */ -NULL, /* wakeup */ -snd_portman_interrupt, /* ISR */ -PARPORT_DEV_EXCL, /* flags */ -(void *)card); /* private */ + portman_cb.private = card; /* private */ + pardev = parport_register_dev_model(p, /* port */ + DRIVER_NAME, /* name */ + &portman_cb, /* callbacks */ + pdev->id); /* device number */ if (pardev == NULL) { snd_printd("Cannot register pardevice\n"); err = -EIO; -- 1.9.1
[tip:core/resources] resource: Kill walk_iomem_res()
Commit-ID: a8fc42530ddd19d7580fe8c9f2ea86220a97e94c Gitweb: http://git.kernel.org/tip/a8fc42530ddd19d7580fe8c9f2ea86220a97e94c Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:32 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:59 +0100 resource: Kill walk_iomem_res() walk_iomem_res_desc() replaced walk_iomem_res() and there is no caller to walk_iomem_res() any more. Kill it. Also remove @name from find_next_iomem_res() as it is no longer used. Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Acked-by: Dave Young Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dan Williams Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Hanjun Guo Cc: Jakub Sitnicki Cc: Jiang Liu Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Toshi Kani Cc: Vinod Koul Cc: linux-a...@vger.kernel.org Cc: linux-mm Link: http://lkml.kernel.org/r/1453841853-11383-17-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- include/linux/ioport.h | 3 --- kernel/resource.c | 49 + 2 files changed, 5 insertions(+), 47 deletions(-) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 2a4a5e8..afb4559 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -270,9 +270,6 @@ walk_system_ram_res(u64 start, u64 end, void *arg, extern int walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, u64 end, void *arg, int (*func)(u64, u64, void *)); -extern int -walk_iomem_res(char *name, unsigned long flags, u64 start, u64 end, void *arg, - int (*func)(u64, u64, void *)); /* True if any part of r1 overlaps r2 */ static inline bool resource_overlaps(struct resource *r1, struct resource *r2) diff --git a/kernel/resource.c b/kernel/resource.c index 37ed2fc..4983430 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -335,13 +335,12 @@ EXPORT_SYMBOL(release_resource); /* * Finds the lowest iomem resource existing within [res->start.res->end). * The caller must specify res->start, res->end, res->flags, and optionally - * desc and "name". If found, returns 0, res is overwritten, if not found, - * returns -1. + * desc. If found, returns 0, res is overwritten, if not found, returns -1. * This function walks the whole tree and not just first level children until * and unless first_level_children_only is true. */ static int find_next_iomem_res(struct resource *res, unsigned long desc, - char *name, bool first_level_children_only) + bool first_level_children_only) { resource_size_t start, end; struct resource *p; @@ -363,8 +362,6 @@ static int find_next_iomem_res(struct resource *res, unsigned long desc, continue; if ((desc != IORES_DESC_NONE) && (desc != p->desc)) continue; - if (name && strcmp(p->name, name)) - continue; if (p->start > end) { p = NULL; break; @@ -411,7 +408,7 @@ int walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, orig_end = res.end; while ((res.start < res.end) && - (!find_next_iomem_res(&res, desc, NULL, false))) { + (!find_next_iomem_res(&res, desc, false))) { ret = (*func)(res.start, res.end, arg); if (ret) @@ -425,42 +422,6 @@ int walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, } /* - * Walks through iomem resources and calls @func with matching resource - * ranges. This walks the whole tree and not just first level children. - * All the memory ranges which overlap start,end and also match flags and - * name are valid candidates. - * - * @name: name of resource - * @flags: resource flags - * @start: start addr - * @end: end addr - * - * NOTE: This function is deprecated and should not be used in new code. - * Use walk_iomem_res_desc(), instead. - */ -int walk_iomem_res(char *name, unsigned long flags, u64 start, u64 end, - void *arg, int (*func)(u64, u64, void *)) -{ - struct resource res; - u64 orig_end; - int ret = -1; - - res.start = start; - res.end = end; - res.flags = flags; - orig_end = res.end; - while ((res.start < res.end) && - (!find_next_iomem_res(&res, IORES_DESC_NONE, name, false))) { - ret = (*func)(res.start, res.end, arg); - if (ret) - break; - res.start = res.end + 1; - res.end = orig_end; - } - return ret; -} - -/* * This function calls the @func callback against all memory ranges of type * System RAM which are marked as IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY. * Now, this function is only for System RAM, it dea
[tip:core/resources] x86/kexec: Remove walk_iomem_res() call with GART type
Commit-ID: f296f2634920d205b93d878b48d87bb7e0a4c256 Gitweb: http://git.kernel.org/tip/f296f2634920d205b93d878b48d87bb7e0a4c256 Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:31 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:59 +0100 x86/kexec: Remove walk_iomem_res() call with GART type There is no longer any driver inserting a "GART" region in the kernel since 707d4eefbdb3 ("Revert "[PATCH] Insert GART region into resource map""). Remove the call to walk_iomem_res() with "GART" type, its callback function, and GART-specific variables set by the callback. Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Reviewed-by: Dave Young Cc: Andrew Morton Cc: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Chun-Yi Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Lee, Chun-Yi Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Minfei Huang Cc: Peter Zijlstra (Intel) Cc: Stephen Rothwell Cc: Takao Indoh Cc: Thomas Gleixner Cc: Toshi Kani Cc: Viresh Kumar Cc: ke...@lists.infradead.org Cc: linux-a...@vger.kernel.org Cc: linux-mm Link: http://lkml.kernel.org/r/1453841853-11383-16-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- arch/x86/kernel/crash.c | 37 + 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 35e152e..9ef978d 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -57,10 +57,9 @@ struct crash_elf_data { struct kimage *image; /* * Total number of ram ranges we have after various adjustments for -* GART, crash reserved region etc. +* crash reserved region, etc. */ unsigned int max_nr_ranges; - unsigned long gart_start, gart_end; /* Pointer to elf header */ void *ehdr; @@ -201,17 +200,6 @@ static int get_nr_ram_ranges_callback(u64 start, u64 end, void *arg) return 0; } -static int get_gart_ranges_callback(u64 start, u64 end, void *arg) -{ - struct crash_elf_data *ced = arg; - - ced->gart_start = start; - ced->gart_end = end; - - /* Not expecting more than 1 gart aperture */ - return 1; -} - /* Gather all the required information to prepare elf headers for ram regions */ static void fill_up_crash_elf_data(struct crash_elf_data *ced, @@ -226,22 +214,6 @@ static void fill_up_crash_elf_data(struct crash_elf_data *ced, ced->max_nr_ranges = nr_ranges; - /* -* We don't create ELF headers for GART aperture as an attempt -* to dump this memory in second kernel leads to hang/crash. -* If gart aperture is present, one needs to exclude that region -* and that could lead to need of extra phdr. -*/ - walk_iomem_res("GART", IORESOURCE_MEM, 0, -1, - ced, get_gart_ranges_callback); - - /* -* If we have gart region, excluding that could potentially split -* a memory range, resulting in extra header. Account for that. -*/ - if (ced->gart_end) - ced->max_nr_ranges++; - /* Exclusion of crash region could split memory ranges */ ced->max_nr_ranges++; @@ -350,13 +322,6 @@ static int elf_header_exclude_ranges(struct crash_elf_data *ced, return ret; } - /* Exclude GART region */ - if (ced->gart_end) { - ret = exclude_mem_range(cmem, ced->gart_start, ced->gart_end); - if (ret) - return ret; - } - return ret; }
[tip:core/resources] x86, kexec, nvdimm: Use walk_iomem_res_desc( ) for iomem search
Commit-ID: f0f4711aa16b82016c0b6e59871934bbd71258da Gitweb: http://git.kernel.org/tip/f0f4711aa16b82016c0b6e59871934bbd71258da Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:30 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:59 +0100 x86, kexec, nvdimm: Use walk_iomem_res_desc() for iomem search Change the callers of walk_iomem_res() scanning for the following resources by name to use walk_iomem_res_desc() instead. "ACPI Tables" "ACPI Non-volatile Storage" "Persistent Memory (legacy)" "Crash kernel" Note, the caller of walk_iomem_res() with "GART" will be removed in a later patch. Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Reviewed-by: Dave Young Cc: Andrew Morton Cc: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Chun-Yi Cc: Dan Williams Cc: Denys Vlasenko Cc: Don Zickus Cc: H. Peter Anvin Cc: Lee, Chun-Yi Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Minfei Huang Cc: Peter Zijlstra (Intel) Cc: Ross Zwisler Cc: Stephen Rothwell Cc: Takao Indoh Cc: Thomas Gleixner Cc: Toshi Kani Cc: ke...@lists.infradead.org Cc: linux-a...@vger.kernel.org Cc: linux-mm Cc: linux-nvd...@lists.01.org Link: http://lkml.kernel.org/r/1453841853-11383-15-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- arch/x86/kernel/crash.c | 4 ++-- arch/x86/kernel/pmem.c | 4 ++-- drivers/nvdimm/e820.c | 2 +- kernel/kexec_file.c | 8 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 58f3431..35e152e 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -599,12 +599,12 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params) /* Add ACPI tables */ cmd.type = E820_ACPI; flags = IORESOURCE_MEM | IORESOURCE_BUSY; - walk_iomem_res("ACPI Tables", flags, 0, -1, &cmd, + walk_iomem_res_desc(IORES_DESC_ACPI_TABLES, flags, 0, -1, &cmd, memmap_entry_callback); /* Add ACPI Non-volatile Storage */ cmd.type = E820_NVS; - walk_iomem_res("ACPI Non-volatile Storage", flags, 0, -1, &cmd, + walk_iomem_res_desc(IORES_DESC_ACPI_NV_STORAGE, flags, 0, -1, &cmd, memmap_entry_callback); /* Add crashk_low_res region */ diff --git a/arch/x86/kernel/pmem.c b/arch/x86/kernel/pmem.c index 14415af..92f7014 100644 --- a/arch/x86/kernel/pmem.c +++ b/arch/x86/kernel/pmem.c @@ -13,11 +13,11 @@ static int found(u64 start, u64 end, void *data) static __init int register_e820_pmem(void) { - char *pmem = "Persistent Memory (legacy)"; struct platform_device *pdev; int rc; - rc = walk_iomem_res(pmem, IORESOURCE_MEM, 0, -1, NULL, found); + rc = walk_iomem_res_desc(IORES_DESC_PERSISTENT_MEMORY_LEGACY, +IORESOURCE_MEM, 0, -1, NULL, found); if (rc <= 0) return 0; diff --git a/drivers/nvdimm/e820.c b/drivers/nvdimm/e820.c index b0045a5..95825b3 100644 --- a/drivers/nvdimm/e820.c +++ b/drivers/nvdimm/e820.c @@ -55,7 +55,7 @@ static int e820_pmem_probe(struct platform_device *pdev) for (p = iomem_resource.child; p ; p = p->sibling) { struct nd_region_desc ndr_desc; - if (strncmp(p->name, "Persistent Memory (legacy)", 26) != 0) + if (p->desc != IORES_DESC_PERSISTENT_MEMORY_LEGACY) continue; memset(&ndr_desc, 0, sizeof(ndr_desc)); diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 2bfcdc0..56b18eb 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -524,10 +524,10 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz, /* Walk the RAM ranges and allocate a suitable range for the buffer */ if (image->type == KEXEC_TYPE_CRASH) - ret = walk_iomem_res("Crash kernel", -IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY, -crashk_res.start, crashk_res.end, kbuf, -locate_mem_hole_callback); + ret = walk_iomem_res_desc(crashk_res.desc, + IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY, + crashk_res.start, crashk_res.end, kbuf, + locate_mem_hole_callback); else ret = walk_system_ram_res(0, -1, kbuf, locate_mem_hole_callback);
[tip:core/resources] ACPI/EINJ: Allow memory error injection to NVDIMM
Commit-ID: 4650bac1fc45d64aef62ab99aa4db93d41dedbd9 Gitweb: http://git.kernel.org/tip/4650bac1fc45d64aef62ab99aa4db93d41dedbd9 Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:33 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:50:00 +0100 ACPI/EINJ: Allow memory error injection to NVDIMM In the case of memory error injection, einj_error_inject() checks if a target address is System RAM. Change this check to allow injecting a memory error into NVDIMM memory by calling region_intersects() with IORES_DESC_PERSISTENT_MEMORY. This enables memory error testing on both System RAM and NVDIMM. In addition, page_is_ram() is replaced with region_intersects() with IORESOURCE_SYSTEM_RAM, so that it can verify a target address range with the requested size. Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Reviewed-by: Dan Williams Acked-by: Tony Luck Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Jarkko Nikula Cc: Len Brown Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Peter Zijlstra Cc: Rafael J. Wysocki Cc: Thomas Gleixner Cc: Toshi Kani Cc: Vishal Verma Cc: linux-a...@vger.kernel.org Cc: linux-a...@vger.kernel.org Cc: linux-mm Cc: linux-nvd...@lists.01.org Link: http://lkml.kernel.org/r/1453841853-11383-18-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- drivers/acpi/apei/einj.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c index 0431883..559c117 100644 --- a/drivers/acpi/apei/einj.c +++ b/drivers/acpi/apei/einj.c @@ -519,7 +519,7 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3, u64 param4) { int rc; - unsigned long pfn; + u64 base_addr, size; /* If user manually set "flags", make sure it is legal */ if (flags && (flags & @@ -545,10 +545,17 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, /* * Disallow crazy address masks that give BIOS leeway to pick * injection address almost anywhere. Insist on page or -* better granularity and that target address is normal RAM. +* better granularity and that target address is normal RAM or +* NVDIMM. */ - pfn = PFN_DOWN(param1 & param2); - if (!page_is_ram(pfn) || ((param2 & PAGE_MASK) != PAGE_MASK)) + base_addr = param1 & param2; + size = ~param2 + 1; + + if (((param2 & PAGE_MASK) != PAGE_MASK) || + ((region_intersects(base_addr, size, IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE) + != REGION_INTERSECTS) && +(region_intersects(base_addr, size, IORESOURCE_MEM, IORES_DESC_PERSISTENT_MEMORY) + != REGION_INTERSECTS))) return -EINVAL; inject:
[PATCH v2 1/3] [ALSA] portman2x4 - whitespace fixes
checkpatch was complaining about trailing whitespace, multiple blank lines and space before tabs. This patch takes care of these issues related to whitespace changes and there was no other change. Signed-off-by: Sudip Mukherjee --- v2: combined 3 patches of v1 series into this patch. sound/drivers/portman2x4.c | 77 ++ 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c index 464385a..65b0650 100644 --- a/sound/drivers/portman2x4.c +++ b/sound/drivers/portman2x4.c @@ -57,7 +57,7 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; -static struct platform_device *platform_devices[SNDRV_CARDS]; +static struct platform_device *platform_devices[SNDRV_CARDS]; static int device_count; module_param_array(index, int, NULL, S_IRUGO); @@ -105,7 +105,7 @@ static int portman_create(struct snd_card *card, *rchip = NULL; pm = kzalloc(sizeof(struct portman), GFP_KERNEL); - if (pm == NULL) + if (pm == NULL) return -ENOMEM; /* Init chip specific data */ @@ -123,24 +123,24 @@ static int portman_create(struct snd_card *card, */ /* Standard PC parallel port status register equates. */ -#definePP_STAT_BSY 0x80/* Busy status. Inverted. */ -#definePP_STAT_ACK 0x40/* Acknowledge. Non-Inverted. */ -#definePP_STAT_POUT0x20/* Paper Out.Non-Inverted. */ -#definePP_STAT_SEL 0x10/* Select. Non-Inverted. */ -#definePP_STAT_ERR 0x08/* Error.Non-Inverted. */ +#definePP_STAT_BSY 0x80/* Busy status. Inverted. */ +#definePP_STAT_ACK 0x40/* Acknowledge. Non-Inverted. */ +#definePP_STAT_POUT0x20/* Paper Out.Non-Inverted. */ +#definePP_STAT_SEL 0x10/* Select. Non-Inverted. */ +#definePP_STAT_ERR 0x08/* Error.Non-Inverted. */ /* Standard PC parallel port command register equates. */ -#definePP_CMD_IEN 0x10/* IRQ Enable. Non-Inverted. */ -#definePP_CMD_SELI 0x08/* Select Input. Inverted. */ -#definePP_CMD_INIT 0x04/* Init Printer. Non-Inverted. */ -#definePP_CMD_FEED 0x02/* Auto Feed.Inverted. */ +#definePP_CMD_IEN 0x10/* IRQ Enable. Non-Inverted. */ +#definePP_CMD_SELI 0x08/* Select Input. Inverted. */ +#definePP_CMD_INIT 0x04/* Init Printer. Non-Inverted. */ +#definePP_CMD_FEED 0x02/* Auto Feed.Inverted. */ #definePP_CMD_STB 0x01/* Strobe. Inverted. */ /* Parallel Port Command Register as implemented by PCP2x4. */ -#defineINT_EN PP_CMD_IEN /* Interrupt enable. */ +#defineINT_EN PP_CMD_IEN /* Interrupt enable. */ #defineSTROBE PP_CMD_STB /* Command strobe. */ -/* The parallel port command register field (b1..b3) selects the +/* The parallel port command register field (b1..b3) selects the * various "registers" within the PC/P 2x4. These are the internal * address of these "registers" that must be written to the parallel * port command register. @@ -148,7 +148,7 @@ static int portman_create(struct snd_card *card, #defineRXDATA0 (0 << 1)/* PCP RxData channel 0. */ #defineRXDATA1 (1 << 1)/* PCP RxData channel 1. */ #defineGEN_CTL (2 << 1)/* PCP General Control Register. */ -#defineSYNC_CTL(3 << 1)/* PCP Sync Control Register. */ +#defineSYNC_CTL(3 << 1)/* PCP Sync Control Register. */ #defineTXDATA0 (4 << 1)/* PCP TxData channel 0. */ #defineTXDATA1 (5 << 1)/* PCP TxData channel 1. */ #defineTXDATA2 (6 << 1)/* PCP TxData channel 2. */ @@ -218,7 +218,7 @@ static inline void portman_write_data(struct portman *pm, u8 value) parport_write_data(pm->pardev->port, value); } -static void portman_write_midi(struct portman *pm, +static void portman_write_midi(struct portman *pm, int port, u8 mididata) { int command = ((port + 4) << 1); @@ -234,20 +234,20 @@ static void portman_write_midi(struct portman *pm, */ command |= INT_EN; - /* Disable interrupts so that the process is not interrupted, then -* write the address associated with the current Tx channel to the + /* Disable interrupts so that the process is not interrupted, then +* write the address associated with the current Tx channel to the * PP Command Reg. Do not set the Strobe signal yet.
[tip:core/resources] resource: Add walk_iomem_res_desc()
Commit-ID: 3f33647c41962401272bb60dce67e6094d14dbf2 Gitweb: http://git.kernel.org/tip/3f33647c41962401272bb60dce67e6094d14dbf2 Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:29 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:59 +0100 resource: Add walk_iomem_res_desc() Add a new interface, walk_iomem_res_desc(), which walks through the iomem table by identifying a target with @flags and @desc. This interface provides the same functionality as walk_iomem_res(), but does not use strcmp() to @name for better efficiency. walk_iomem_res() is deprecated and will be removed in a later patch. Requested-by: Borislav Petkov Signed-off-by: Toshi Kani [ Fixup comments. ] Signed-off-by: Borislav Petkov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dan Williams Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Hanjun Guo Cc: Jakub Sitnicki Cc: Jiang Liu Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Peter Zijlstra Cc: Rafael J. Wysocki Cc: Thomas Gleixner Cc: Toshi Kani Cc: linux-a...@vger.kernel.org Cc: linux-mm Link: http://lkml.kernel.org/r/1453841853-11383-14-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- include/linux/ioport.h | 3 +++ kernel/resource.c | 66 ++ 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 983bea0..2a4a5e8 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -268,6 +268,9 @@ extern int walk_system_ram_res(u64 start, u64 end, void *arg, int (*func)(u64, u64, void *)); extern int +walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, u64 end, + void *arg, int (*func)(u64, u64, void *)); +extern int walk_iomem_res(char *name, unsigned long flags, u64 start, u64 end, void *arg, int (*func)(u64, u64, void *)); diff --git a/kernel/resource.c b/kernel/resource.c index 0041ced..37ed2fc 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -333,14 +333,15 @@ int release_resource(struct resource *old) EXPORT_SYMBOL(release_resource); /* - * Finds the lowest iomem reosurce exists with-in [res->start.res->end) - * the caller must specify res->start, res->end, res->flags and "name". - * If found, returns 0, res is overwritten, if not found, returns -1. - * This walks through whole tree and not just first level children - * until and unless first_level_children_only is true. + * Finds the lowest iomem resource existing within [res->start.res->end). + * The caller must specify res->start, res->end, res->flags, and optionally + * desc and "name". If found, returns 0, res is overwritten, if not found, + * returns -1. + * This function walks the whole tree and not just first level children until + * and unless first_level_children_only is true. */ -static int find_next_iomem_res(struct resource *res, char *name, - bool first_level_children_only) +static int find_next_iomem_res(struct resource *res, unsigned long desc, + char *name, bool first_level_children_only) { resource_size_t start, end; struct resource *p; @@ -360,6 +361,8 @@ static int find_next_iomem_res(struct resource *res, char *name, for (p = iomem_resource.child; p; p = next_resource(p, sibling_only)) { if ((p->flags & res->flags) != res->flags) continue; + if ((desc != IORES_DESC_NONE) && (desc != p->desc)) + continue; if (name && strcmp(p->name, name)) continue; if (p->start > end) { @@ -385,12 +388,55 @@ static int find_next_iomem_res(struct resource *res, char *name, * Walks through iomem resources and calls func() with matching resource * ranges. This walks through whole tree and not just first level children. * All the memory ranges which overlap start,end and also match flags and + * desc are valid candidates. + * + * @desc: I/O resource descriptor. Use IORES_DESC_NONE to skip @desc check. + * @flags: I/O resource flags + * @start: start addr + * @end: end addr + * + * NOTE: For a new descriptor search, define a new IORES_DESC in + * and set it in 'desc' of a target resource entry. + */ +int walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, + u64 end, void *arg, int (*func)(u64, u64, void *)) +{ + struct resource res; + u64 orig_end; + int ret = -1; + + res.start = start; + res.end = end; + res.flags = flags; + orig_end = res.end; + + while ((res.start < res.end) && + (!find_next_iomem_res(&res, desc, NULL, false))) { + + ret = (*func)(res.start, res.end, arg); + if (ret) + break; + + res.start = res.end + 1; + res.end = orig_end; +
[tip:core/resources] drivers: Initialize resource entry to zero
Commit-ID: 9a975bee4b3945b271bcff18a520d4863c210f8b Gitweb: http://git.kernel.org/tip/9a975bee4b3945b271bcff18a520d4863c210f8b Author: Toshi Kani AuthorDate: Tue, 26 Jan 2016 21:57:25 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 09:49:58 +0100 drivers: Initialize resource entry to zero I/O resource descriptor, 'desc' in struct resource, needs to be initialized to zero by default. Some drivers call kmalloc() to allocate a resource entry, but do not initialize it to zero by memset(). Change these drivers to call kzalloc(), instead. Signed-off-by: Toshi Kani Signed-off-by: Borislav Petkov Acked-by: Alexandre Bounine Acked-by: Helge Deller Acked-by: Rafael J. Wysocki Acked-by: Simon Horman Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Toshi Kani Cc: linux-a...@vger.kernel.org Cc: linux-a...@vger.kernel.org Cc: linux-mm Cc: linux-par...@vger.kernel.org Cc: linux-renesas-...@vger.kernel.org Cc: linux...@vger.kernel.org Link: http://lkml.kernel.org/r/1453841853-11383-10-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- drivers/acpi/acpi_platform.c | 2 +- drivers/parisc/eisa_enumerator.c | 4 ++-- drivers/rapidio/rio.c | 8 drivers/sh/superhyway/superhyway.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index 296b7a1..b6f7fa3 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c @@ -62,7 +62,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev) if (count < 0) { return NULL; } else if (count > 0) { - resources = kmalloc(count * sizeof(struct resource), + resources = kzalloc(count * sizeof(struct resource), GFP_KERNEL); if (!resources) { dev_err(&adev->dev, "No memory for resources\n"); diff --git a/drivers/parisc/eisa_enumerator.c b/drivers/parisc/eisa_enumerator.c index a656d9e..21905fe 100644 --- a/drivers/parisc/eisa_enumerator.c +++ b/drivers/parisc/eisa_enumerator.c @@ -91,7 +91,7 @@ static int configure_memory(const unsigned char *buf, for (i=0;iname = name; @@ -183,7 +183,7 @@ static int configure_port(const unsigned char *buf, struct resource *io_parent, for (i=0;iname = board; res->start = get_16(buf+len+1); res->end = get_16(buf+len+1)+(c&HPEE_PORT_SIZE_MASK)+1; diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c index d7b87c6..e220edc 100644 --- a/drivers/rapidio/rio.c +++ b/drivers/rapidio/rio.c @@ -117,7 +117,7 @@ int rio_request_inb_mbox(struct rio_mport *mport, if (mport->ops->open_inb_mbox == NULL) goto out; - res = kmalloc(sizeof(struct resource), GFP_KERNEL); + res = kzalloc(sizeof(struct resource), GFP_KERNEL); if (res) { rio_init_mbox_res(res, mbox, mbox); @@ -185,7 +185,7 @@ int rio_request_outb_mbox(struct rio_mport *mport, if (mport->ops->open_outb_mbox == NULL) goto out; - res = kmalloc(sizeof(struct resource), GFP_KERNEL); + res = kzalloc(sizeof(struct resource), GFP_KERNEL); if (res) { rio_init_mbox_res(res, mbox, mbox); @@ -285,7 +285,7 @@ int rio_request_inb_dbell(struct rio_mport *mport, { int rc = 0; - struct resource *res = kmalloc(sizeof(struct resource), GFP_KERNEL); + struct resource *res = kzalloc(sizeof(struct resource), GFP_KERNEL); if (res) { rio_init_dbell_res(res, start, end); @@ -360,7 +360,7 @@ int rio_release_inb_dbell(struct rio_mport *mport, u16 start, u16 end) struct resource *rio_request_outb_dbell(struct rio_dev *rdev, u16 start, u16 end) { - struct resource *res = kmalloc(sizeof(struct resource), GFP_KERNEL); + struct resource *res = kzalloc(sizeof(struct resource), GFP_KERNEL); if (res) { rio_init_dbell_res(res, start, end); diff --git a/drivers/sh/superhyway/superhyway.c b/drivers/sh/superhyway/superhyway.c index 2d9e7f3..bb1fb771 100644 --- a/drivers/sh/superhyway/superhyway.c +++ b/drivers/sh/superhyway/superhyway.c @@ -66,7 +66,7 @@ int superhyway_add_device(unsigned long base, struct superhyway_device *sdev, superhyway_read_vcr(dev, base, &dev->vcr); if (!dev->resource) { - dev->resource = kmalloc(sizeof(struct resource), GFP_KERNEL); + dev->resource = kzalloc(sizeof(struct resource), GFP_KERNEL); if (!dev->resource) { kfree(dev); return -ENOMEM;
Re: [PATCH] ovl: fix getcwd() failure after unsuccessful rmdir
On Fri, Jan 8, 2016 at 6:09 PM, Rui Wang wrote: > ovl_remove_upper() should do d_drop() only after it successfully > removes the dir, otherwise a subsequent getcwd() system call will > fail, breaking userspace programs. > > This is to fix: https://bugzilla.kernel.org/show_bug.cgi?id=110491 > > Signed-off-by: Rui Wang Reviewed-by: Konstantin Khlebnikov The same problem also in ovl_remove_and_whiteout() - when we remove non-pure dentry. It checks that directory isn't empty before, but I'm sure that vfs_rename which exchanges dentry and whiteout could fail for some reason and we'll end with unhashed dentry when nothing actually has been changed. > --- > fs/overlayfs/dir.c |3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > > diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c > index 692ceda..36d6a5b 100644 > --- a/fs/overlayfs/dir.c > +++ b/fs/overlayfs/dir.c > @@ -618,7 +618,8 @@ static int ovl_remove_upper(struct dentry *dentry, bool > is_dir) > * sole user of this dentry. Too tricky... Just unhash for > * now. > */ > - d_drop(dentry); > + if (!err) > + d_drop(dentry); > mutex_unlock(&dir->i_mutex); > > return err; > -- > 1.7.5.4 >
[PATCH V2] mfd: core: add macro for adding mfd cells
Most of MFD drivers add the mfd sub devices cells as follows: static const struct mfd_cell as3722_devs[] = { { .name = "as3722-pinctrl", }, { .name = "as3722-regulator", }, { .name = "as3722-rtc", .num_resources = ARRAY_SIZE(as3722_rtc_resource), .resources = as3722_rtc_resource, }, { .name = "as3722-adc", .num_resources = ARRAY_SIZE(as3722_adc_resource), .resources = as3722_adc_resource, }, }; Add defines for adding mfd cells so that it can be done in single line as follows: static const struct mfd_cell as3722_devs[] = { DEFINE_MFD_CELL_NAME("as3722-pinctrl"), DEFINE_MFD_CELL_NAME("as3722-regulator"), DEFINE_MFD_CELL_NAME_RESOURCE("as3722-rtc", as3722_rtc_resource), DEFINE_MFD_CELL_NAME_RESOURCE("as3722-adc", as3722_adc_resource), }; Signed-off-by: Laxman Dewangan --- I am sending this patch based on review comment recived on max77620 mfd patch to use/add macro whereever possible. Once this is reviewed and agreed, I will post series of mfd patches to use this macro. Changes from V1: - Missing "_" from argument name which was causing the compilation issue. - This is found when using both macro. include/linux/mfd/core.h | 15 +++ 1 file changed, 15 insertions(+) diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index bc6f7e0..3fa4ab7 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h @@ -14,6 +14,7 @@ #ifndef MFD_CORE_H #define MFD_CORE_H +#include #include struct irq_domain; @@ -81,6 +82,20 @@ struct mfd_cell { int num_parent_supplies; }; +/* Defne mfd cells with name and resource */ +#define DEFINE_MFD_CELL_NAME_RESOURCE(_name, _res) \ + { \ + .name = (_name),\ + .num_resources = ARRAY_SIZE((_res)),\ + .resources = (_res),\ + } + +/* Defne mfd cells with name */ +#define DEFINE_MFD_CELL_NAME(_name)\ + { \ + .name = (_name),\ + } + /* * Convenience functions for clients using shared cells. Refcounting * happens automatically, with the cell's enable/disable callbacks -- 2.1.4
[PATCH v2 1/3] ALSA: mts64: whitespace fixes
checkpatch was complaining about trailing whitespace, multiple blank lines, space before start of a line and a required space before opening brace. This patch takes care of these issues related to whitespace changes and there was no other change. Signed-off-by: Sudip Mukherjee --- v2: combined 3 patches of v1 series into this patch. sound/drivers/mts64.c | 112 -- 1 file changed, 54 insertions(+), 58 deletions(-) diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c index 2a008a9..f7d938d 100644 --- a/sound/drivers/mts64.c +++ b/sound/drivers/mts64.c @@ -1,14 +1,14 @@ -/* +/* * ALSA Driver for Ego Systems Inc. (ESI) Miditerminal 4140 * Copyright (c) 2006 by Matthias König * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of + * 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. * @@ -38,7 +38,7 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; -static struct platform_device *platform_devices[SNDRV_CARDS]; +static struct platform_device *platform_devices[SNDRV_CARDS]; static int device_count; module_param_array(index, int, NULL, S_IRUGO); @@ -92,7 +92,7 @@ static int snd_mts64_create(struct snd_card *card, *rchip = NULL; mts = kzalloc(sizeof(struct mts64), GFP_KERNEL); - if (mts == NULL) + if (mts == NULL) return -ENOMEM; /* Init chip specific data */ @@ -118,9 +118,9 @@ static int snd_mts64_create(struct snd_card *card, /* Control Bits */ #define MTS64_CTL_READOUT 0x08 /* enable readout */ -#define MTS64_CTL_WRITE_CMD0x06 -#define MTS64_CTL_WRITE_DATA 0x02 -#define MTS64_CTL_STROBE 0x01 +#define MTS64_CTL_WRITE_CMD0x06 +#define MTS64_CTL_WRITE_DATA 0x02 +#define MTS64_CTL_STROBE 0x01 /* Command */ #define MTS64_CMD_RESET0xfe @@ -130,7 +130,7 @@ static int snd_mts64_create(struct snd_card *card, #define MTS64_CMD_SMPTE_STOP 0xef #define MTS64_CMD_SMPTE_FPS_24 0xe3 #define MTS64_CMD_SMPTE_FPS_25 0xe2 -#define MTS64_CMD_SMPTE_FPS_2997 0xe4 +#define MTS64_CMD_SMPTE_FPS_2997 0xe4 #define MTS64_CMD_SMPTE_FPS_30D0xe1 #define MTS64_CMD_SMPTE_FPS_30 0xe0 #define MTS64_CMD_COM_OPEN 0xf8 /* setting the communication mode */ @@ -159,7 +159,6 @@ static void mts64_write_command(struct parport *p, u8 c); static void mts64_write_data(struct parport *p, u8 c); static void mts64_write_midi(struct mts64 *mts, u8 c, int midiport); - /* Enables the readout procedure * * Before we can read a midi byte from the device, we have to set @@ -171,10 +170,10 @@ static void mts64_enable_readout(struct parport *p) c = parport_read_control(p); c |= MTS64_CTL_READOUT; - parport_write_control(p, c); + parport_write_control(p, c); } -/* Disables readout +/* Disables readout * * Readout is disabled by clearing bit 3 of control */ @@ -201,9 +200,9 @@ static int mts64_device_ready(struct parport *p) for (i = 0; i < 0x; ++i) { c = parport_read_status(p); c &= MTS64_STAT_BSY; - if (c != 0) + if (c != 0) return 1; - } + } return 0; } @@ -234,7 +233,7 @@ static int mts64_device_init(struct parport *p) return -EIO; } -/* +/* * Opens the device (set communication mode) */ static int mts64_device_open(struct mts64 *mts) @@ -248,7 +247,7 @@ static int mts64_device_open(struct mts64 *mts) return 0; } -/* +/* * Close device (clear communication mode) */ static int mts64_device_close(struct mts64 *mts) @@ -265,14 +264,14 @@ static int mts64_device_close(struct mts64 *mts) } /* map hardware port to substream number - * + * * When reading a byte from the device, the device tells us * on what port the byte is. This HW port has to be mapped to * the midiport (substream number). * substream 0-3 are Midiports 1-4 * substream 4 is SMPTE Tim
[PATCH v2 2/3] ALSA: mts64: assignment in if
It is not general practice to assign some values inside if statement. Signed-off-by: Sudip Mukherjee --- v2: no change sound/drivers/mts64.c | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c index f7d938d..ee6a87f 100644 --- a/sound/drivers/mts64.c +++ b/sound/drivers/mts64.c @@ -943,7 +943,9 @@ static int snd_mts64_probe(struct platform_device *pdev) return -ENODEV; if (!enable[dev]) return -ENOENT; - if ((err = snd_mts64_probe_port(p)) < 0) + + err = snd_mts64_probe_port(p); + if (err < 0) return err; err = snd_card_new(&pdev->dev, index[dev], id[dev], THIS_MODULE, @@ -970,7 +972,8 @@ static int snd_mts64_probe(struct platform_device *pdev) goto __err; } - if ((err = snd_mts64_create(card, pardev, &mts)) < 0) { + err = snd_mts64_create(card, pardev, &mts); + if (err < 0) { snd_printd("Cannot create main component\n"); parport_unregister_device(pardev); goto __err; @@ -978,7 +981,8 @@ static int snd_mts64_probe(struct platform_device *pdev) card->private_data = mts; card->private_free = snd_mts64_card_private_free; - if ((err = snd_mts64_rawmidi_create(card)) < 0) { + err = snd_mts64_rawmidi_create(card); + if (err < 0) { snd_printd("Creating Rawmidi component failed\n"); goto __err; } @@ -992,13 +996,15 @@ static int snd_mts64_probe(struct platform_device *pdev) mts->pardev_claimed = 1; /* init device */ - if ((err = mts64_device_init(p)) < 0) + err = mts64_device_init(p); + if (err < 0) goto __err; platform_set_drvdata(pdev, card); /* At this point card will be usable */ - if ((err = snd_card_register(card)) < 0) { + err = snd_card_register(card); + if (err < 0) { snd_printd("Cannot register card\n"); goto __err; } @@ -1050,7 +1056,8 @@ static int __init snd_mts64_module_init(void) { int err; - if ((err = platform_driver_register(&snd_mts64_driver)) < 0) + err = platform_driver_register(&snd_mts64_driver); + if (err < 0) return err; if (parport_register_driver(&mts64_parport_driver) != 0) { -- 1.9.1
[PATCH v2 3/3] ALSA: mts64: use new parport device model
Modify mts64 driver to use the new parallel port device model. Signed-off-by: Sudip Mukherjee --- v2: 1. pardev_cb is initialized while declaring, thus removing the use of memset. 2. used pdev->id. 3. v1 did not have the parport probe callback, but we will need the probe callback for binding as the name of the driver and the name of the device is different. 4. in v1 I missed modifying snd_mts64_dev_probe(). sound/drivers/mts64.c | 52 ++- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c index ee6a87f..01da990 100644 --- a/sound/drivers/mts64.c +++ b/sound/drivers/mts64.c @@ -851,10 +851,21 @@ static int snd_mts64_probe_port(struct parport *p) { struct pardevice *pardev; int res; + struct pardev_cb pdev_cb = { + .preempt = NULL, + .wakeup = NULL, + .private = NULL, + .irq_func = NULL, + .flags = 0, + }; - pardev = parport_register_device(p, DRIVER_NAME, -NULL, NULL, NULL, -0, NULL); + /* + * Specify the device number as SNDRV_CARDS + 1 so that the + * device id alloted to this temporary device will never clash + * with an actual device already registered. + */ + pardev = parport_register_dev_model(p, DRIVER_NAME, &pdev_cb, + SNDRV_CARDS + 1); if (!pardev) return -EIO; @@ -904,10 +915,20 @@ static void snd_mts64_detach(struct parport *p) /* nothing to do here */ } +static int snd_mts64_dev_probe(struct pardevice *pardev) +{ + if (strcmp(pardev->name, DRIVER_NAME)) + return -ENODEV; + + return 0; +} + static struct parport_driver mts64_parport_driver = { - .name = "mts64", - .attach = snd_mts64_attach, - .detach = snd_mts64_detach + .name = "mts64", + .probe = snd_mts64_dev_probe, + .match_port = snd_mts64_attach, + .detach = snd_mts64_detach, + .devmodel = true, }; /* @@ -935,6 +956,12 @@ static int snd_mts64_probe(struct platform_device *pdev) struct snd_card *card = NULL; struct mts64 *mts = NULL; int err; + struct pardev_cb mts64_cb = { + .preempt = NULL, + .wakeup = NULL, + .irq_func = snd_mts64_interrupt,/* ISR */ + .flags = PARPORT_DEV_EXCL, /* flags */ + }; p = platform_get_drvdata(pdev); platform_set_drvdata(pdev, NULL); @@ -959,13 +986,12 @@ static int snd_mts64_probe(struct platform_device *pdev) sprintf(card->longname, "%s at 0x%lx, irq %i", card->shortname, p->base, p->irq); - pardev = parport_register_device(p, /* port */ -DRIVER_NAME, /* name */ -NULL,/* preempt */ -NULL,/* wakeup */ -snd_mts64_interrupt, /* ISR */ -PARPORT_DEV_EXCL,/* flags */ -(void *)card); /* private */ + mts64_cb.private = card; /* private */ + + pardev = parport_register_dev_model(p, /* port */ + DRIVER_NAME, /* name */ + &mts64_cb, /* callbacks */ + pdev->id); /* device number */ if (pardev == NULL) { snd_printd("Cannot register pardevice\n"); err = -EIO; -- 1.9.1
Re: [RFC PATCH 0/2] avoid external fragmentation related to migration fallback
On 2016/1/30 5:03, Vlastimil Babka wrote: > On 01/29/2016 08:23 PM, ChengYi He wrote: > > [...] > >> Below is the root cause of this external fragmentation which could be >> observed in devices which have only one memory zone, such as some arm64 >> android devices: >> >> 1) In arm64, the first 4GB physical address space is of DMA zone. If the >> size of physical memory is less than 4GB and the whole memory is in the >> first 4GB address space, then the system will have only one DMA zone. >> 2) By default, all pageblocks are Movable. >> 3) Allocators such as slab, ion, graphics preferably allocate pages of >> Unmvoable migration type. It might fallback to allocate Movable pages >> and changes Movable pageblocks into Unmovable ones. >> 4) Movable pagesblocks will become less and less due to above reason. >> However, in android system, AnonPages request is always high. The >> Movable pages will be easily exhausted. >> 5) While Movable pages are exhausted, the Movable allocations will >> frequently fallback to allocate the largest feasiable pages of the other >> migration types. The order-2 and order-3 Unmovable pages will be split >> into smaller ones easily. >> >> This symptom doesn't appear in arm32 android which usually has two >> memory zones including Highmem and Normal. The slab, ion, and graphics >> allocators allocate pages with flag GFP_KERNEL. Only Movable pageblocks >> in Normal zone become less, and the Movable pages in Highmem zone are >> still a lot. Thus, the Movable pages will not be easily exhausted, and >> there will not be frequent fallbacks. > > Hm, this 1 zone vs 2 zones shouldn't make that much difference, unless > a) you use zone reclaim mode, or b) you have an old kernel without fair > zone allocation policy? > Hi Vlastimil, I agree with you. I think if we have a normal zone and a movable zone, then the effect of compaction will be better. e.g. U: unmovable page M: movable page F: free page one zone(DMA): paddr: 0 max ZONE_DMA: U M F U M F ... U M F U M F after compact: U F F U F F ... U M M U M M two zone(DMA and MOVABLE) paddr: 0 max ZONE_DMA: the same as above ZONE_MOVABLE: M F M F M F ... M F M F M F after compact: F F F F F F ... M M M M M M // we get large block than above >> Since the root cause is that fallbacks might frequently split order-2 >> and order-3 pages of the other migration types. This patch tweaks >> fallback mechanism to avoid splitting order-2 and order-3 pages. while >> fallbacks happen, if the largest feasible pages are less than or queal to >> COSTLY_ORDER, i.e. 3, then try to select the smallest feasible pages. The >> reason why fallbacks prefer the largest feasiable pages is to increase >> fallback efficiency since fallbacks are likely to happen again. By >> stealing the largest feasible pages, it could reduce the oppourtunities >> of antoher fallback. Besides, it could make consecutive allocations more >> approximate to each other and make system less fragment. However, if the >> largest feasible pages are less than or equal to order-3, fallbacks might >> split it and make the upcoming order-3 page allocations fail. > > In theory I don't see immediately why preferring smaller pages for > fallback should be a clear win. If it's Unmovable allocations stealing > from Movable pageblocks, the allocations will spread over larger areas > instead of being grouped together. Maybe, for Movable allocations > stealing from Unmovable allocations, preferring smallest might make > sense and be safe, as any extra fragmentation is fixable bycompaction. > Maybe it was already tried (by Joonsoo?) at some point, I'm not sure > right now. > >> My test is against arm64 android devices with kernel 3.10.49. I set the >> same account and install the same applications in both deivces and use >> them synchronously. > > 3.10 is wayy old. There were numerous patches to compaction and > anti-fragmentation since then. IIRC the fallback decisions were quite > suboptimal at that point. I'm not even sure how you could apply your > patches to both recent kernel for posting them, and 3.10 for testing? > Is it possible to test on 4.4? > I think it's hard to update the drivers on android smart phone. Thanks, Xishi Qiu >> >> Test result: >> 1) Test without this patch: >> Most free pages are order-0 Unmovable ones. allocstall and compact_stall >> in /proc/vmstat are relatively high. And most occurances of allocstall >> are due to order-2 and order-3 allocations. >> 2) Test with this patch: >> There are more order-2 and order-3 free pages. allocstall and >> compact_stall in /proc/vmstat are relatively low. And most occurances of >> allocstall are due to order-0 allocations. >> >> Log: >> 1) Test without this patch: >> -- TIME (date) -- >> Fri Jul 3 16:52:55 CST 2015 >> -- UPTIME (uptime) -- >> up time: 2 days, 12:06:52, idle time: 8 days, 14:48:55, sleep time: 16:43:56 >> -- MEMORY INFO
[PATCH] Race between cat /proc/kallsyms and rmmod
Iterating code of /proc/kallsyms calls module_get_kallsym() which grabs and drops module_mutex internally and returns "struct module *", module is removed, aforementioned "struct module *" is used in non-trivial way. So, grab module_mutex for entire operation like /proc/modules does. Steps to reproduce: while true; do modprobe xfs; rmmod xfs; done vs while true; do cat /proc/kallsyms >/dev/null; done ref:http://lkml.iu.edu/hypermail/linux/kernel/0703.1/2582.html https://bugzilla.kernel.org/show_bug.cgi?id=111541 Signed-off-by: Weilong Chen --- kernel/kallsyms.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 3127ad5..aaecf19 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -515,6 +515,7 @@ static void *s_next(struct seq_file *m, void *p, loff_t *pos) static void *s_start(struct seq_file *m, loff_t *pos) { + mutex_lock(&module_mutex); if (!update_iter(m->private, *pos)) return NULL; return m->private; @@ -522,6 +523,7 @@ static void *s_start(struct seq_file *m, loff_t *pos) static void s_stop(struct seq_file *m, void *p) { + mutex_unlock(&module_mutex); } static int s_show(struct seq_file *m, void *p) -- 1.8.3.1
Re: [PATCH v8 3/3] x86, mce: Add __mcsafe_copy()
On Fri, Jan 29, 2016 at 04:35:35PM -0800, Tony Luck wrote: > On Wed, Jan 13, 2016 at 8:39 PM, Borislav Petkov wrote: > > On Wed, Jan 13, 2016 at 03:22:58PM -0800, Tony Luck wrote: > >> Are there some examples of synthetic CPUID bits? > > > > X86_FEATURE_ALWAYS is one. The others got renamed into X86_BUG_* ones, > > the remaining mechanism is the same, though. > > So something like this [gmail will line wrap, but should still be legible] > > Then Dan will be able to use: > > if (cpu_has(c, X86_FEATURE_MCRECOVERY)) > > to decide whether to use the (slightly slower, but recovery capable) > __mcsafe_copy() > or just pick the fastest memcpy() instead. The most optimal way of alternatively calling two functions would be something like this, IMO: alternative_call(memcpy, __mcsafe_copy, X86_FEATURE_MCRECOVERY, ASM_OUTPUT2("=a" (mcsafe_ret.trapnr), "=d" (mcsafe_ret.remain)), "D" (dst), "S" (src), "d" (len)); I hope I've not messed up the calling convention but you want the inputs in %rdi, %rsi, %rdx and the outputs in %rax, %rdx, respectively. Just check the asm gcc generates and do not trust me :) The other thing you probably would need to do is create our own __memcpy() which returns struct mcsafe_ret so that the signatures of both functions match. Yeah, it is a bit of jumping through hoops but this way we do a CALL directly in asm, without any JMPs or NOPs padding the other alternatives methods add. But if you don't care about a small JMP and that is not a hot path, you could do the simpler: if (static_cpu_has(X86_FEATURE_MCRECOVERY)) return __mcsafe_copy(...); return memcpy(); which adds a JMP or a 5-byte NOP depending on the X86_FEATURE_MCRECOVERY setting. > diff --git a/arch/x86/include/asm/cpufeature.h > b/arch/x86/include/asm/cpufeature.h > index 7ad8c9464297..621e05103633 100644 > --- a/arch/x86/include/asm/cpufeature.h > +++ b/arch/x86/include/asm/cpufeature.h > @@ -106,6 +106,7 @@ > #define X86_FEATURE_APERFMPERF ( 3*32+28) /* APERFMPERF */ > #define X86_FEATURE_EAGER_FPU ( 3*32+29) /* "eagerfpu" Non lazy FPU restore > */ > #define X86_FEATURE_NONSTOP_TSC_S3 ( 3*32+30) /* TSC doesn't stop in > S3 state */ > +#define X86_FEATURE_MCRECOVERY ( 3*32+31) /* cpu has recoverable Why not write it out? X86_FEATURE_MCE_RECOVERY > machine checks */ > > /* Intel-defined CPU features, CPUID level 0x0001 (ecx), word 4 */ > #define X86_FEATURE_XMM3 ( 4*32+ 0) /* "pni" SSE-3 */ -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply.
Re: [PATCHv2 1/3] arm64: Drop alloc function from create_mapping
On 30 January 2016 at 00:46, Laura Abbott wrote: > > create_mapping is only used in fixmap_remap_fdt. All the create_mapping > calls need to happen on existing translation table pages without > additional allocations. Rather than have an alloc function be called > and fail, just set it to NULL and catch it's use. Also change s/it's/its/ > the name to create_mapping_noalloc to better capture what exactly is > going on. > > Signed-off-by: Laura Abbott With one nit below: Reviewed-by: Ard Biesheuvel > --- > arch/arm64/mm/mmu.c | 27 ++- > 1 file changed, 18 insertions(+), 9 deletions(-) > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index 7711554..103ebc0 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -116,7 +116,9 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr, > pte_t *pte; > > if (pmd_none(*pmd) || pmd_sect(*pmd)) { > - phys_addr_t pte_phys = pgtable_alloc(); > + phys_addr_t pte_phys; > + BUG_ON(!pgtable_alloc); > + pte_phys = pgtable_alloc(); > pte = pte_set_fixmap(pte_phys); > if (pmd_sect(*pmd)) > split_pmd(pmd, pte); > @@ -158,7 +160,9 @@ static void alloc_init_pmd(pud_t *pud, unsigned long > addr, unsigned long end, > * Check for initial section mappings in the pgd/pud and remove them. > */ > if (pud_none(*pud) || pud_sect(*pud)) { > - phys_addr_t pmd_phys = pgtable_alloc(); > + phys_addr_t pmd_phys; > + BUG_ON(!pgtable_alloc); > + pmd_phys = pgtable_alloc(); > pmd = pmd_set_fixmap(pmd_phys); > if (pud_sect(*pud)) { > /* > @@ -223,7 +227,9 @@ static void alloc_init_pud(pgd_t *pgd, unsigned long > addr, unsigned long end, > unsigned long next; > > if (pgd_none(*pgd)) { > - phys_addr_t pud_phys = pgtable_alloc(); > + phys_addr_t pud_phys; > + BUG_ON(!pgtable_alloc); > + pud_phys = pgtable_alloc(); > __pgd_populate(pgd, pud_phys, PUD_TYPE_TABLE); > } > BUG_ON(pgd_bad(*pgd)); > @@ -312,7 +318,10 @@ static void __create_pgd_mapping(pgd_t *pgdir, > phys_addr_t phys, > init_pgd(pgd_offset_raw(pgdir, virt), phys, virt, size, prot, alloc); > } > > -static void __init create_mapping(phys_addr_t phys, unsigned long virt, > +/* > + * This function is for mapping using existing sections only. Could you improve this comment? 'existing sections' does not quite cover what we expect to deal with imo > + */ > +static void __init create_mapping_noalloc(phys_addr_t phys, unsigned long > virt, > phys_addr_t size, pgprot_t prot) > { > if (virt < VMALLOC_START) { > @@ -321,7 +330,7 @@ static void __init create_mapping(phys_addr_t phys, > unsigned long virt, > return; > } > __create_pgd_mapping(init_mm.pgd, phys, virt, size, prot, > -early_pgtable_alloc); > +NULL); > } > > void __init create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys, > @@ -680,7 +689,7 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys) > /* > * Make sure that the FDT region can be mapped without the need to > * allocate additional translation table pages, so that it is safe > -* to call create_mapping() this early. > +* to call create_mapping_noalloc() this early. > * > * On 64k pages, the FDT will be mapped using PTEs, so we need to > * be in the same PMD as the rest of the fixmap. > @@ -696,8 +705,8 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys) > dt_virt = (void *)dt_virt_base + offset; > > /* map the first chunk so we can read the size from the header */ > - create_mapping(round_down(dt_phys, SWAPPER_BLOCK_SIZE), dt_virt_base, > - SWAPPER_BLOCK_SIZE, prot); > + create_mapping_noalloc(round_down(dt_phys, SWAPPER_BLOCK_SIZE), > + dt_virt_base, SWAPPER_BLOCK_SIZE, prot); > > if (fdt_check_header(dt_virt) != 0) > return NULL; > @@ -707,7 +716,7 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys) > return NULL; > > if (offset + size > SWAPPER_BLOCK_SIZE) > - create_mapping(round_down(dt_phys, SWAPPER_BLOCK_SIZE), > dt_virt_base, > + create_mapping_noalloc(round_down(dt_phys, > SWAPPER_BLOCK_SIZE), dt_virt_base, >round_up(offset + size, SWAPPER_BLOCK_SIZE), > prot); > > memblock_reserve(dt_phys, size); > -- > 2.5.0 >
Re: [RFC PATCH 2/2] mm/page_alloc: avoid splitting pages of order 2 and 3 in migration fallback
On 2016/1/30 3:25, ChengYi He wrote: > While buddy system fallbacks to allocate different migration type pages, > it prefers the largest feasible pages and might split the chosen page > into smalller ones. If the largest feasible pages are less than or equal > to orde-3 and migration fallback happens frequently, then order-2 and > order-3 pages can be exhausted easily. This patch aims to allocate the > smallest feasible pages for the fallback mechanism under this condition. > > Signed-off-by: ChengYi He > --- > mm/page_alloc.c | 19 --- > 1 file changed, 16 insertions(+), 3 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 50c325a..3fcb653 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -1802,9 +1802,22 @@ __rmqueue_fallback(struct zone *zone, unsigned int > order, int start_migratetype) > struct page *page; > > /* Find the largest possible block of pages in the other list */ > - for (current_order = MAX_ORDER-1; > - current_order >= order && current_order <= > MAX_ORDER-1; > - --current_order) { > + for (current_order = MAX_ORDER - 1; > + current_order >= max_t(unsigned int, > PAGE_ALLOC_COSTLY_ORDER + 1, order); > + --current_order) { > + page = __rmqueue_fallback_order(zone, order, start_migratetype, > + current_order); > + > + if (page) > + return page; > + } > + > + /* > + * While current_order <= PAGE_ALLOC_COSTLY_ORDER, find the smallest > + * feasible pages in the other list to avoid splitting high order pages > + */ > + for (current_order = order; current_order <= PAGE_ALLOC_COSTLY_ORDER; > + ++current_order) { > page = __rmqueue_fallback_order(zone, order, start_migratetype, > current_order); > Hi Chengyi, So you mean use the largest block first, if no large block left, the use the smallest block, right? I have an idea, how about set two migrate types(movable and unmovable) when doing init work? The function is memmap_init_zone(). I don't know how to set the ratio, maybe unmovable takes 1/10 memory, and left 9/10 memory to movable? I think this effect is a little like the two zones (normal and movable). Another two ideas https://lkml.org/lkml/2015/8/14/67 7d348b9ea64db0a315d777ce7d4b06697f946503, maybe this patch is not applied on your 3.10 Thanks, Xishi Qiu
Re: [PATCH] Race between cat /proc/kallsyms and rmmod
Hi Weilong, [auto build test ERROR on v4.5-rc1] [also build test ERROR on next-20160129] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Weilong-Chen/Race-between-cat-proc-kallsyms-and-rmmod/20160130-182606 config: i386-randconfig-a0-201604 (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=i386 All errors (new ones prefixed by >>): In file included from include/linux/notifier.h:13:0, from include/linux/memory_hotplug.h:6, from include/linux/mmzone.h:728, from include/linux/gfp.h:5, from include/linux/kmod.h:22, from include/linux/module.h:13, from kernel/kallsyms.c:15: kernel/kallsyms.c: In function 's_start': >> kernel/kallsyms.c:519:14: error: 'module_mutex' undeclared (first use in >> this function) mutex_lock(&module_mutex); ^ include/linux/mutex.h:146:44: note: in definition of macro 'mutex_lock' #define mutex_lock(lock) mutex_lock_nested(lock, 0) ^ kernel/kallsyms.c:519:14: note: each undeclared identifier is reported only once for each function it appears in mutex_lock(&module_mutex); ^ include/linux/mutex.h:146:44: note: in definition of macro 'mutex_lock' #define mutex_lock(lock) mutex_lock_nested(lock, 0) ^ kernel/kallsyms.c: In function 's_stop': kernel/kallsyms.c:527:16: error: 'module_mutex' undeclared (first use in this function) mutex_unlock(&module_mutex); ^ vim +/module_mutex +519 kernel/kallsyms.c 513 return NULL; 514 return p; 515 } 516 517 static void *s_start(struct seq_file *m, loff_t *pos) 518 { > 519 mutex_lock(&module_mutex); 520 if (!update_iter(m->private, *pos)) 521 return NULL; 522 return m->private; --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
[PATCH] mce-inject: use pr_err() instead of printk(KERN_ERR, ...)
Signed-off-by: Chen Yucong Converted printk(KERN_ERR to pr_err. pr_ format is more compact and enable utilizing of pr_fmt macro. --- arch/x86/kernel/cpu/mcheck/mce-inject.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/mcheck/mce-inject.c b/arch/x86/kernel/cpu/mcheck/mce-inject.c index c0b0d77..517619e 100644 --- a/arch/x86/kernel/cpu/mcheck/mce-inject.c +++ b/arch/x86/kernel/cpu/mcheck/mce-inject.c @@ -183,8 +183,7 @@ static void raise_mce(struct mce *m) start = jiffies; while (!cpumask_empty(mce_inject_cpumask)) { if (!time_before(jiffies, start + 2*HZ)) { - printk(KERN_ERR - "Timeout waiting for mce inject %lx\n", + pr_err("Timeout waiting for mce inject %lx\n", *cpumask_bits(mce_inject_cpumask)); break; } -- 1.8.3.1
[PATCHv2 0/3] rdma controller support
This patchset adds support for RDMA cgroup by addressing review comments of [2], [1] and by implementing published RFC [3]. Overview: Currently user space applications can easily take away all the rdma device specific resources such as AH, CQ, QP, MR etc. Due to which other applications in other cgroup or kernel space ULPs may not even get chance to allocate any rdma resources. This results into service unavailibility. RDMA cgroup addresses this issue by allowing resource accounting, limit enforcement on per cgroup, per rdma device basis. Resources are not defined by the RDMA cgroup. Resources are defined by RDMA/IB stack & optionally by HCA vendor device drivers. This allows rdma cgroup to remain constant while RDMA/IB stack can evolve without the need of rdma cgroup update. A new resource can be easily added by the RDMA/IB stack without touching rdma cgroup. RDMA uverbs layer will enforce limits on well defined RDMA verb resources without any HCA vendor device driver involvement. RDMA uverbs layer will not do accounting of hw vendor specific resources. Instead rdma cgroup provides set of APIs through which vendor specific drivers can define their own resources (upto 64) that can be accounted by rdma cgroup. Resource limit enforcement is hierarchical. When process is migrated with active RDMA resources, rdma cgroup continues to uncharge original cgroup for allocated resource. New resource is charged to current process's cgroup, which means if the process is migrated with active resources, for new resources it will be charged to new cgroup and old resources will be correctly uncharged from old cgroup. Changes from v1: * (To address comments from Tejun) a. reduces 3 patches to single patch b. removed resource word from the cgroup configuration files c. changed cgroup configuration file names to match other cgroups d. removed .list file and merged functionality with .max file * Based on comment to merge to single patch for rdma controller; IB/core patches are reduced to single patch. * Removed pid cgroup map and simplified design - Charge/Uncharge caller stack keeps track of the rdmacg for given resource. This removes the need to maintain and perform hash lookup. This also allows little more accurate resource charging/uncharging when process moved from one to other cgroup with active resources and continue to allocate more. * Critical fix: Removed rdma cgroup's dependency on the kernel module header files to avoid crashes when modules are upgraded without kernel upgrade, which is very common due to high amount of changes in IB stack and it is also shipped as individual kernel modules. * uboject extended to keep track of the owner rdma cgroup, so that same rdmacg can be used while uncharging. * Added support functions to hide details of rdmacg device in uverbs modules for cases of cgroup enabled/disabled at compile time. This avoids multiple ifdefs for every API in uverbs layer. * Removed failure counters in first patch, which will be added once initial feature is merged. * Fixed stale rpool access which is getting freed, while doing configuration to rdma.verb.max file. * Fixed rpool resource leak while querying max, current values. Changes from v0: (To address comments from Haggai, Doug, Liran, Tejun, Sean, Jason) * Redesigned to support per device per cgroup limit settings by bringing concept of resource pool. * Redesigned to let IB stack define the resources instead of rdma controller using resource template. * Redesigned to support hw vendor specific limits setting (optional to drivers). * Created new rdma controller instead of piggyback on device cgroup. * Fixed race conditions for multiple tasks sharing rdma resources. * Removed dependency on the task_struct. [1] https://lkml.org/lkml/2016/1/5/632 [2] https://lkml.org/lkml/2015/9/7/476 [3] https://lkml.org/lkml/2015/10/28/144 This patchset is for Tejun's for-4.5 branch. It is not attempted on Doug's rdma tree yet, which I will do once I receive comments for this pathset. Parav Pandit (3): rdmacg: Added rdma cgroup controller. IB/core: added support to use rdma cgroup controller rdmacg: Added documentation for rdma controller Documentation/cgroup-v1/rdma.txt | 122 Documentation/cgroup-v2.txt | 43 ++ drivers/infiniband/core/Makefile |1 + drivers/infiniband/core/cgroup.c | 108 drivers/infiniband/core/core_priv.h | 45 ++ drivers/infiniband/core/device.c |8 + drivers/infiniband/core/uverbs_cmd.c | 209 ++- drivers/infiniband/core/uverbs_main.c | 28 + include/linux/cgroup_rdma.h | 78 +++ include/linux/cgroup_subsys.h |4 + include/rdma/ib_verbs.h | 27 +- init/Kconfig | 12 + kernel/Makefile |1 + kernel/cgroup_rdma.c | 1021 + 14 files changed, 1691
[PATCHv2 3/3] rdmacg: Added documentation for rdma controller
Added documentation for rdma controller to use in legacy mode and using new unified hirerchy. Signed-off-by: Parav Pandit --- Documentation/cgroup-v1/rdma.txt | 122 +++ Documentation/cgroup-v2.txt | 43 ++ 2 files changed, 165 insertions(+) create mode 100644 Documentation/cgroup-v1/rdma.txt diff --git a/Documentation/cgroup-v1/rdma.txt b/Documentation/cgroup-v1/rdma.txt new file mode 100644 index 000..240e34a --- /dev/null +++ b/Documentation/cgroup-v1/rdma.txt @@ -0,0 +1,122 @@ + RDMA Controller + + +Contents + + +1. Overview + 1-1. What is RDMA controller? + 1-2. Why RDMA controller needed? + 1-3. How is RDMA controller implemented? +2. Usage Examples + +1. Overview + +1-1. What is RDMA controller? +- + +RDMA controller allows user to limit RDMA/IB specific resources +that a given set of processes can use. These processes are grouped using +RDMA controller. + +RDMA controller currently allows two different type of resource +pools. +(a) RDMA IB specification level verb resources defined by IB stack +(b) HCA vendor device specific resources + +RDMA controller controller allows maximum of upto 64 resources in +a resource pool which is the internal construct of rdma cgroup explained +at later part of this document. + +1-2. Why RDMA controller needed? + + +Currently user space applications can easily take away all the rdma device +specific resources such as AH, CQ, QP, MR etc. Due to which other applications +in other cgroup or kernel space ULPs may not even get chance to allocate any +rdma resources. This leads to service unavailability. + +Therefore RDMA controller is needed through which resource consumption +of processes can be limited. Through this controller various different rdma +resources described by IB uverbs layer and any HCA vendor driver can be +accounted. + +1-3. How is RDMA controller implemented? + + +RDMA cgroup allows limit configuration of resources. These resources are not +defined by the rdma controller. Instead they are defined by the IB stack +and HCA device drivers(optionally). +This provides great flexibility to allow IB stack to define new resources, +without any changes to rdma cgroup. +Rdma cgroup maintains resource accounting per cgroup, per device, per resource +type using resource pool structure. Each such resource pool is limited up to +64 resources in given resource pool by rdma cgroup, which can be extended +later if required. + +This resource pool object is linked to the cgroup css. Typically there +are 0 to 4 resource pool instances per cgroup, per device in most use cases. +But nothing limits to have it more. At present hundreds of RDMA devices per +single cgroup may not be handled optimally, however there is no known use case +for such configuration either. + +Since RDMA resources can be allocated from any process and can be freed by any +of the child processes which shares the address space, rdma resources are +always owned by the creator cgroup css. This allows process migration from one +to other cgroup without major complexity of transferring resource ownership; +because such ownership is not really present due to shared nature of +rdma resources. Linking resources around css also ensures that cgroups can be +deleted after processes migrated. This allow progress migration as well with +active resources, even though that’s not the primary use case. + +Whenever RDMA resource charing occurs, owner rdma cgroup is returned to +the caller. Same rdma cgroup should be passed while uncharging the resource. +This also allows process migrated with active RDMA resource to charge +to new owner cgroup for new resource. It also allows to uncharge resource of +a process from previously charged cgroup which is migrated to new cgroup, +even though that is not a primary use case. + +Resource pool object is created in following situations. +(a) User sets the limit and no previous resource pool exist for the device +of interest for the cgroup. +(b) No resource limits were configured, but IB/RDMA stack tries to +charge the resource. So that it correctly uncharge them when applications are +running without limits and later on when limits are enforced during uncharging, +otherwise usage count will drop to negative. This is done using default +resource pool. Instead of implementing any sort of time markers, default pool +simplifies the design. + +Resource pool is destroyed if it was of default type (not created +by administrative operation) and it’s the last resource getting +deallocated. Resource pool created as administrative operation is not +deleted, as it’s expected to be used in near future. + +If user setting tries to delete all the resource limit +with active resources per device, RDMA cgroup just marks the pool
[PATCHv2 1/3] rdmacg: Added rdma cgroup controller.
Added rdma cgroup controller that does accounting, limit enforcement on rdma/IB verbs and hw resources. Added rdma cgroup header file which defines its APIs to perform charing/uncharing functionality and device registration which will participate in controller functions of accounting and limit enforcements. It also define rdmacg_device structure to bind IB stack and RDMA cgroup controller. RDMA resources are tracked using resource pool. Resource pool is per device, per cgroup, per resource pool_type entity which allows setting up accounting limits on per device basis. RDMA cgroup returns error when user space applications try to allocate resources more than its configured limit. Rdma cgroup implements resource accounting for two types of resource pools. (a) RDMA IB specification level verb resources defined by IB stack (b) HCA vendor device specific resources defined by vendor device driver Resources are not defined by the RDMA cgroup, instead they are defined by the external module, typically IB stack and optionally by HCA drivers for those RDMA devices which doesn't have one to one mapping of IB verb resource with hardware resource. This allows extending IB stack without changing kernel, which is frequent as IB stack is going through changes and enhancements. Signed-off-by: Parav Pandit --- include/linux/cgroup_rdma.h | 78 include/linux/cgroup_subsys.h |4 + init/Kconfig | 12 + kernel/Makefile |1 + kernel/cgroup_rdma.c | 1021 + 5 files changed, 1116 insertions(+) create mode 100644 include/linux/cgroup_rdma.h create mode 100644 kernel/cgroup_rdma.c diff --git a/include/linux/cgroup_rdma.h b/include/linux/cgroup_rdma.h new file mode 100644 index 000..cdf84af --- /dev/null +++ b/include/linux/cgroup_rdma.h @@ -0,0 +1,78 @@ +#ifndef _CGROUP_RDMA_H +#define _CGROUP_RDMA_H + +#include + +/* + * This file is subject to the terms and conditions of version 2 of the GNU + * General Public License. See the file COPYING in the main directory of the + * Linux distribution for more details. + */ + +enum rdmacg_resource_pool_type { + RDMACG_RESOURCE_POOL_VERB, + RDMACG_RESOURCE_POOL_HW, + RDMACG_RESOURCE_POOL_TYPE_MAX, +}; + +struct rdma_cgroup { + struct cgroup_subsys_state css; + + spinlock_t cg_list_lock; /* protects cgroup resource pool list */ + struct list_head rpool_head;/* head to keep track of all resource +* pools that belongs to this cgroup. +*/ +}; + +#ifdef CONFIG_CGROUP_RDMA +#define RDMACG_MAX_RESOURCE_INDEX (64) + +struct match_token; +struct rdmacg_device; + +struct rdmacg_pool_info { + struct match_token *resource_table; + int resource_count; +}; + +struct rdmacg_resource_pool_ops { + struct rdmacg_pool_info* + (*get_resource_pool_tokens)(struct rdmacg_device *); +}; + +struct rdmacg_device { + struct rdmacg_resource_pool_ops + *rpool_ops[RDMACG_RESOURCE_POOL_TYPE_MAX]; + struct list_headrdmacg_list; + char*name; +}; + +/* APIs for RDMA/IB stack to publish when a device wants to + * participate in resource accounting + */ +void rdmacg_register_device(struct rdmacg_device *device, char *dev_name); +void rdmacg_unregister_device(struct rdmacg_device *device); + +/* APIs for RDMA/IB stack to charge/uncharge pool specific resources */ +int rdmacg_try_charge(struct rdma_cgroup **rdmacg, + struct rdmacg_device *device, + enum rdmacg_resource_pool_type type, + int resource_index, + int num); +void rdmacg_uncharge(struct rdma_cgroup *cg, +struct rdmacg_device *device, +enum rdmacg_resource_pool_type type, +int resource_index, +int num); + +void rdmacg_set_rpool_ops(struct rdmacg_device *device, + enum rdmacg_resource_pool_type pool_type, + struct rdmacg_resource_pool_ops *ops); +void rdmacg_clear_rpool_ops(struct rdmacg_device *device, + enum rdmacg_resource_pool_type pool_type); +int rdmacg_query_limit(struct rdmacg_device *device, + enum rdmacg_resource_pool_type type, + int *limits, int max_count); + +#endif /* CONFIG_CGROUP_RDMA */ +#endif /* _CGROUP_RDMA_H */ diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h index 0df0336a..d0e597c 100644 --- a/include/linux/cgroup_subsys.h +++ b/include/linux/cgroup_subsys.h @@ -56,6 +56,10 @@ SUBSYS(hugetlb) SUBSYS(pids) #endif +#if IS_ENABLED(CONFIG_CGROUP_RDMA) +SUBSYS(rdma) +#endif + /* * The following subsystems are not supported on the default hierarchy. */ diff --git a/init/Kconfig b/init/Kconfig index f8
[PATCHv2 2/3] IB/core: added support to use rdma cgroup controller
Added support APIs for IB core to register/unregister every RDMA device with rdma cgroup for tracking verbs and hw resources. IB core registers with rdma cgroup controller and also defines resources that can be accounted. Added support APIs for uverbs layer to make use of rdma controller. Added uverbs layer to perform resource charge/uncharge functionality. Signed-off-by: Parav Pandit --- drivers/infiniband/core/Makefile | 1 + drivers/infiniband/core/cgroup.c | 108 ++ drivers/infiniband/core/core_priv.h | 45 drivers/infiniband/core/device.c | 8 ++ drivers/infiniband/core/uverbs_cmd.c | 209 +++--- drivers/infiniband/core/uverbs_main.c | 28 + include/rdma/ib_verbs.h | 27 - 7 files changed, 410 insertions(+), 16 deletions(-) create mode 100644 drivers/infiniband/core/cgroup.c diff --git a/drivers/infiniband/core/Makefile b/drivers/infiniband/core/Makefile index d43a899..df40cee 100644 --- a/drivers/infiniband/core/Makefile +++ b/drivers/infiniband/core/Makefile @@ -13,6 +13,7 @@ ib_core-y := packer.o ud_header.o verbs.o sysfs.o \ roce_gid_mgmt.o ib_core-$(CONFIG_INFINIBAND_USER_MEM) += umem.o ib_core-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o umem_rbtree.o +ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o ib_mad-y :=mad.o smi.o agent.o mad_rmpp.o diff --git a/drivers/infiniband/core/cgroup.c b/drivers/infiniband/core/cgroup.c new file mode 100644 index 000..be0a2b8 --- /dev/null +++ b/drivers/infiniband/core/cgroup.c @@ -0,0 +1,108 @@ +#include +#include +#include + +#include "core_priv.h" + +/** + * resource table definition as to be seen by the user. + * Need to add entries to it when more resources are + * added/defined at IB verb/core layer. + */ +static match_table_t resource_tokens = { + {RDMA_VERB_RESOURCE_UCTX, "uctx=%d"}, + {RDMA_VERB_RESOURCE_AH, "ah=%d"}, + {RDMA_VERB_RESOURCE_PD, "pd=%d"}, + {RDMA_VERB_RESOURCE_CQ, "cq=%d"}, + {RDMA_VERB_RESOURCE_MR, "mr=%d"}, + {RDMA_VERB_RESOURCE_MW, "mw=%d"}, + {RDMA_VERB_RESOURCE_SRQ, "srq=%d"}, + {RDMA_VERB_RESOURCE_QP, "qp=%d"}, + {RDMA_VERB_RESOURCE_FLOW, "flow=%d"}, + {-1, NULL} +}; + +/** + * setup table pointers for RDMA cgroup to access. + */ +static struct rdmacg_pool_info verbs_token_info = { + .resource_table = resource_tokens, + .resource_count = + (sizeof(resource_tokens) / sizeof(struct match_token)) - 1, +}; + +static struct rdmacg_pool_info* + rdmacg_get_resource_pool_tokens(struct rdmacg_device *device) +{ + return &verbs_token_info; +} + +static struct rdmacg_resource_pool_ops verbs_pool_ops = { + .get_resource_pool_tokens = &rdmacg_get_resource_pool_tokens, +}; + +/** + * ib_device_register_rdmacg - register with rdma cgroup. + * @device: device to register to participate in resource + * accounting by rdma cgroup. + * + * Register with the rdma cgroup. Should be called before + * exposing rdma device to user space applications to avoid + * resource accounting leak. + * HCA drivers should set resource pool ops first if they wish + * to support hw specific resource accounting before IB core + * registers with rdma cgroup. + */ +void ib_device_register_rdmacg(struct ib_device *device) +{ + rdmacg_set_rpool_ops(&device->cg_device, +RDMACG_RESOURCE_POOL_VERB, +&verbs_pool_ops); + rdmacg_register_device(&device->cg_device, device->name); +} + +/** + * ib_device_unregister_rdmacg - unregister with rdma cgroup. + * @device: device to unregister. + * + * Unregister with the rdma cgroup. Should be called after + * all the resources are deallocated, and after a stage when any + * other resource allocation of user application cannot be done + * for this device to avoid any leak in accounting. + * HCA drivers should clear resource pool ops after ib stack + * unregisters with rdma cgroup. + */ +void ib_device_unregister_rdmacg(struct ib_device *device) +{ + rdmacg_unregister_device(&device->cg_device); + rdmacg_clear_rpool_ops(&device->cg_device, + RDMACG_RESOURCE_POOL_VERB); +} + +int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj, +struct ib_device *device, +enum rdmacg_resource_pool_type type, +int resource_index, int num) +{ + return rdmacg_try_charge(&cg_obj->cg, &device->cg_device, +type, resource_index, num); +} +EXPORT_SYMBOL(ib_rdmacg_try_charge); + +void ib_rdmacg_uncharge(struct ib_rdmacg_object *cg_obj, + struct ib_device *device, + enum rdmacg_resource_pool_type type, + int resource_index, int num) +{ + rdmacg_uncharge(cg_obj->cg, &device->cg_dev
Re: [RFC PATCH 11/19] cpufreq: assert policy->rwsem is held in __cpufreq_governor
On Friday, January 29, 2016 04:33:39 PM Saravana Kannan wrote: > On 01/12/2016 02:20 AM, Viresh Kumar wrote: > > On 11-01-16, 17:35, Juri Lelli wrote: > >> __cpufreq_governor works on policy, so policy->rwsem has to be held. > >> Add assertion for such condition. > >> > >> Cc: "Rafael J. Wysocki" > >> Cc: Viresh Kumar > >> Signed-off-by: Juri Lelli > >> --- > >> drivers/cpufreq/cpufreq.c | 3 +++ > >> 1 file changed, 3 insertions(+) > >> > >> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > >> index f1f9fbc..e7fc5c9 100644 > >> --- a/drivers/cpufreq/cpufreq.c > >> +++ b/drivers/cpufreq/cpufreq.c > >> @@ -1950,6 +1950,9 @@ static int __cpufreq_governor(struct cpufreq_policy > >> *policy, > >>/* Don't start any governor operations if we are entering suspend */ > >>if (cpufreq_suspended) > >>return 0; > >> + > >> + lockdep_assert_held(&policy->rwsem); > >> + > > > > We had an ABBA problem with the EXIT governor callback and so this > > rwsem is dropped just before that from set_policy().. > > > > commit 955ef4833574 ("cpufreq: Drop rwsem lock around > > CPUFREQ_GOV_POLICY_EXIT") > > > > AFAIR, the ABBA issue was between the sysfs lock and the policy lock. > The fix for that issue should not be dropping the lock around > POLICY_EXIT. Right. Dropping the lock is a mistake (which I overlooked, sadly). Thanks, Rafael
[PATCH v3 2/2] dt-bindings: rockchip-pinctrl: Support the RK3399 SoCs compatible
Change-Id: Ic1bdb3dc358837e97d7b48dd58be2f8d9d08d766 --- Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt index 391ef4b..3bb9456 100644 --- a/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt +++ b/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt @@ -22,6 +22,7 @@ Required properties for iomux controller: - compatible: one of "rockchip,rk2928-pinctrl", "rockchip,rk3066a-pinctrl" "rockchip,rk3066b-pinctrl", "rockchip,rk3188-pinctrl" "rockchip,rk3288-pinctrl", "rockchip,rk3368-pinctrl" + "rockchip,rk3399-pinctrl" - rockchip,grf: phandle referencing a syscon providing the "general register files" -- 1.9.1
[PATCH v3 1/2] pinctrl: rockchip: add support for the rk3399
The pinctrl of rk3399 is much different from other's, especially the 3bits of drive strength. Signed-off-by: David Wu --- Change in v3: - use switch-case to distinguish special 3bits width per pin (Heiko) Change in v2: - need spin_unlock_irqrestore for set drive default case drivers/pinctrl/pinctrl-rockchip.c | 372 +++-- 1 file changed, 358 insertions(+), 14 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index a065112..d5c71b0 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -64,6 +64,7 @@ enum rockchip_pinctrl_type { RK3188, RK3288, RK3368, + RK3399, }; /** @@ -86,6 +87,31 @@ struct rockchip_iomux { }; /** + * enum type index corresponding to rockchip_perpin_drv_list arrays index. + */ +enum rockchip_pin_drv_type { + DRV_TYPE_IO_DEFAULT = 0, + DRV_TYPE_IO_1V8_OR_3V0, + DRV_TYPE_IO_1V8_ONLY, + DRV_TYPE_IO_1V8_3V0_AUTO, + DRV_TYPE_IO_3V3_ONLY, + DRV_TYPE_MAX +}; + +/** + * @drv_type: drive strength variant using rockchip_perpin_drv_type + * @offset: if initialized to -1 it will be autocalculated, by specifying + * an initial offset value the relevant source offset can be reset + * to a new value for autocalculating the following drive strength + * registers. if used chips own cal_drv func instead to calculate + * registers offset, the variant could be ignored. + */ +struct rockchip_drv { + enum rockchip_pin_drv_type drv_type; + int offset; +}; + +/** * @reg_base: register base of the gpio bank * @reg_pull: optional separate register for additional pull settings * @clk: clock of the gpio bank @@ -96,6 +122,7 @@ struct rockchip_iomux { * @name: name of the bank * @bank_num: number of the bank, to account for holes * @iomux: array describing the 4 iomux sources of the bank + * @drv: array describing the 4 drive strength sources of the bank * @valid: are all necessary informations present * @of_node: dt node of this bank * @drvdata: common pinctrl basedata @@ -115,6 +142,7 @@ struct rockchip_pin_bank { char*name; u8 bank_num; struct rockchip_iomux iomux[4]; + struct rockchip_drv drv[4]; boolvalid; struct device_node *of_node; struct rockchip_pinctrl *drvdata; @@ -151,6 +179,47 @@ struct rockchip_pin_bank { }, \ } +#define PIN_BANK_DRV_FLAGS(id, pins, label, type0, type1, type2, type3) \ + { \ + .bank_num = id, \ + .nr_pins= pins, \ + .name = label,\ + .iomux = { \ + { .offset = -1 }, \ + { .offset = -1 }, \ + { .offset = -1 }, \ + { .offset = -1 }, \ + }, \ + .drv= { \ + { .drv_type = type0, .offset = -1 },\ + { .drv_type = type1, .offset = -1 },\ + { .drv_type = type2, .offset = -1 },\ + { .drv_type = type3, .offset = -1 },\ + }, \ + } + +#define PIN_BANK_IOMUX_DRV_FLAGS_OFFSET(id, pins, label, iom0, iom1, \ + iom2, iom3, drv0, drv1, drv2, \ + drv3, offset0, offset1, \ + offset2, offset3) \ + { \ + .bank_num = id, \ + .nr_pins= pins, \ + .name = label,\ + .iomux = { \ + { .type = iom0, .offset = -1 }, \ + { .type = iom1, .offset = -1 }, \ + { .type = iom2, .offset = -1 }, \ + { .type = iom3, .offset = -1 }, \ + },
[PATCH v3 0/2] add pinctrl support for rk3399
Test on rk3399 fpga-board David Wu (2): pinctrl: rockchip: add support for the rk3399 dt-bindings: rockchip-pinctrl: Support the RK3399 SoCs compatible .../bindings/pinctrl/rockchip,pinctrl.txt | 1 + drivers/pinctrl/pinctrl-rockchip.c | 372 - 2 files changed, 359 insertions(+), 14 deletions(-) -- 1.9.1
[PATCH] PM: Avoid false-positive warnings in dev_pm_domain_set()
From: Rafael J. Wysocki There is a WARN_ON() in dev_pm_domain_set() that triggers on attempts to set the pm_domain pointer for devices with a driver bound. However, that WARN_ON() triggers on attempts to clear the pointer too and the test it uses is based on checking the device's p->knode_driver pointer which still is set when the device bus type's/driver's ->remove callback has been executed. This leads to false-positive warnings when bus type code calls dev_pm_domain_set() to clear the pm_domain pointer after invoking the driver's ->remove() callback. To avoid those false-positives, make dev_pm_domain_set() check if the pointer passed to it is NULL and skip the warning in that case. Fixes: 989561de9b51 (PM / Domains: add setter for dev.pm_domain) Signed-off-by: Rafael J. Wysocki --- drivers/base/power/common.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-pm/drivers/base/power/common.c === --- linux-pm.orig/drivers/base/power/common.c +++ linux-pm/drivers/base/power/common.c @@ -146,7 +146,7 @@ void dev_pm_domain_set(struct device *de if (dev->pm_domain == pd) return; - WARN(device_is_bound(dev), + WARN(pd && device_is_bound(dev), "PM domains can only be changed for unbound devices\n"); dev->pm_domain = pd; device_pm_check_callbacks(dev);
Re: [PATCH v2] staging: rtl8723au: Fixes unnecessary return warning
On Sat, Jan 30, 2016 at 4:57 PM, Bhaktipriya Shridhar wrote: > This patch fixes checkpatch.pl warning in rtw_mlme_ext.c file. > WARNING: void function return statements are not generally useful > > Signed-off-by: Bhaktipriya Shridhar Looks sane to me. Reviewed-by: Julian Calaby > --- > Changes in v2: >- Removed the unnecessary blank lines. > drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 20 > 1 file changed, 20 deletions(-) > > diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c > b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c > index d28f29a..7cd0052 100644 > --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c > +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c > @@ -2656,8 +2656,6 @@ static void issue_probersp(struct rtw_adapter > *padapter, unsigned char *da) > pattrib->last_txcmdsz = pattrib->pktlen; > > dump_mgntframe23a(padapter, pmgntframe); > - > - return; > } > > static int _issue_probereq(struct rtw_adapter *padapter, > @@ -2957,8 +2955,6 @@ static void issue_auth(struct rtw_adapter *padapter, > struct sta_info *psta, > rtw_wep_encrypt23a(padapter, pmgntframe); > DBG_8723A("%s\n", __func__); > dump_mgntframe23a(padapter, pmgntframe); > - > - return; > } > > #ifdef CONFIG_8723AU_AP_MODE > @@ -3338,8 +3334,6 @@ exit: > } > } else > kfree(pmlmepriv->assoc_req); > - > - return; > } > > /* when wait_ack is true, this function should be called at process context > */ > @@ -4102,8 +4096,6 @@ static void rtw_site_survey(struct rtw_adapter > *padapter) > pmlmeext->chan_scan_time = SURVEY_TO; > pmlmeext->sitesurvey_res.state = SCAN_DISABLE; > } > - > - return; > } > > /* collect bss info from Beacon and Probe request/response frames. */ > @@ -4759,8 +4751,6 @@ void report_survey_event23a(struct rtw_adapter > *padapter, > rtw_enqueue_cmd23a(pcmdpriv, pcmd_obj); > > pmlmeext->sitesurvey_res.bss_cnt++; > - > - return; > } > > void report_surveydone_event23a(struct rtw_adapter *padapter) > @@ -4802,8 +4792,6 @@ void report_surveydone_event23a(struct rtw_adapter > *padapter) > DBG_8723A("survey done event(%x)\n", psurveydone_evt->bss_cnt); > > rtw_enqueue_cmd23a(pcmdpriv, pcmd_obj); > - > - return; > } > > void report_join_res23a(struct rtw_adapter *padapter, int res) > @@ -4850,8 +4838,6 @@ void report_join_res23a(struct rtw_adapter *padapter, > int res) > rtw_joinbss_event_prehandle23a(padapter, (u8 > *)&pjoinbss_evt->network); > > rtw_enqueue_cmd23a(pcmdpriv, pcmd_obj); > - > - return; > } > > void report_del_sta_event23a(struct rtw_adapter *padapter, > @@ -4906,8 +4892,6 @@ void report_del_sta_event23a(struct rtw_adapter > *padapter, > DBG_8723A("report_del_sta_event23a: delete STA, mac_id =%d\n", > mac_id); > > rtw_enqueue_cmd23a(pcmdpriv, pcmd_obj); > - > - return; > } > > void report_add_sta_event23a(struct rtw_adapter *padapter, > @@ -4951,8 +4935,6 @@ void report_add_sta_event23a(struct rtw_adapter > *padapter, > DBG_8723A("report_add_sta_event23a: add STA\n"); > > rtw_enqueue_cmd23a(pcmdpriv, pcmd_obj); > - > - return; > } > > / > @@ -5394,8 +5376,6 @@ static void link_timer_hdl(unsigned long data) > issue_assocreq(padapter); > set_link_timer(pmlmeext, REASSOC_TO); > } > - > - return; > } > > static void addba_timer_hdl(unsigned long data) > -- > 2.1.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-wireless" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Julian Calaby Email: julian.cal...@gmail.com Profile: http://www.google.com/profiles/julian.calaby/
Re: [PATCH] staging: rtl8723au: Fixes unnecessary return warning
Hi Bhakti, On Sat, Jan 30, 2016 at 5:53 PM, Bhakti Priya wrote: > Hi, > > Thank you for your reply. I've just sent version 2 of the patch with > the blank lines removed. > I will be happy to extend checkpatch.pl. As suggested by you, I am > trying to detect such blank lines in a line removal patch by checking > if the line above the deleted line was a blank line and the line > following the deleted line had a closing brace. > Can you please guide me and let me know if I am headed in the right direction. As I understand it, the algorithm needs to work like this: 1. For each patch hunk: 2. Filter out all lines that match /^-/ 3. Remove the first character (" " or "+") 4. Normalise EOL characters: s/\r\n?/\n/ 5. Over the entire hunk, find any case that matches /({|\n)\s*\n\s*(\n|})/ where \s matches all space characters except \n. 6. Report the middle line the preceding regular expression matches to the user. I'm confident I can write it as a shell script, but I don't know enough Perl to add that test to checkpatch.pl Thanks, -- Julian Calaby Email: julian.cal...@gmail.com Profile: http://www.google.com/profiles/julian.calaby/
my subject...
Be informed that Muthoot Finance give out Guarantee Business Loans, Automobile Purchase Loans, House Purchase Loans, Personal Loans at 3% interest rate, for more info email: muthootfinancceh...@gmail.com Estar informado de que Muthoot Finanzas Dar a conocer Garanta de negocios Prstamos, Prstamos de Automviles Compra, Casa Compra prstamos, prstamos personales a tasa de inters del 3%, para obtener ms informacin email: muthootfinancceh...@gmail.com Assunto: meu tema Ser informado de que Muthoot Finance dar empréstimos de Garantia de Negócios, Automobile Os empréstimos Purchase, Casa empréstimos Purchase, empréstimos pessoais na taxa de juros de 3%, para mais informações e-mail: muthootfinancceh...@gmail.com Nous portons à votre connaissance que Muthoot Finance vous donne des prêts d’affaires, pour l’achat des automobiles, des maisons, des prêts personnels, tous pour un taux d'intérêts de 3%, pour plus des détails consultez: muthootfinancceh...@gmail.com Byt informovaný, že Muthoot Financie rozdávat zárucnej podnikatelských úverov, automobilový Nákup pôžiciek, úverov na bývanie, osobné pôžicky vo výške 3% úrokovou sadzbou, pre viac informácií e-mail: muthootfinancceh...@gmail.com Wir teilen mit, dass Muthoot Finance Firmen-Darlehen, Darlehen zur Anschaffung von Kfz-Fahrzeugen, Erwerb von Immobilien sowie persönliche Darlehen zu 3% effektiven Jahreszins anbietet, weitere Informationen erhalten Sie per E-Mail: muthootfinancceh...@gmail.com Det opplyses om at Muthoot Finance gir ut garanti Business lån, Automobile kjøpe lån, hus kjøpe lån, personlige lån på 3% rente, for mer info e-post: muthootfinancceh...@gmail.com --- This email is free from viruses and malware because avast! Antivirus protection is active. https://www.avast.com/antivirus
Re: [PATCH] staging: rtl8723au: Fixes unnecessary return warning
On Sat, 2016-01-30 at 23:02 +1100, Julian Calaby wrote: > Hi Bhakti, > > On Sat, Jan 30, 2016 at 5:53 PM, Bhakti Priya wrote: > > Hi, > > > > Thank you for your reply. I've just sent version 2 of the patch with > > the blank lines removed. > > I will be happy to extend checkpatch.pl. As suggested by you, I am > > trying to detect such blank lines in a line removal patch by checking > > if the line above the deleted line was a blank line and the line > > following the deleted line had a closing brace. > > Can you please guide me and let me know if I am headed in the right > > direction. > > As I understand it, the algorithm needs to work like this: > 1. For each patch hunk: > 2. Filter out all lines that match /^-/ > 3. Remove the first character (" " or "+") > 4. Normalise EOL characters: s/\r\n?/\n/ > 5. Over the entire hunk, find any case that matches > /({|\n)\s*\n\s*(\n|})/ where \s matches all space characters except > \n. > 6. Report the middle line the preceding regular expression matches to the > user. > > I'm confident I can write it as a shell script, but I don't know > enough Perl to add that test to checkpatch.pl That's basically what the $prevline variable in checkpatch does. Likely it's enough to check that. Perhaps Andy Whitcroft knows.
[PATCH] PM / AVS: rockchip-io: add GRF and PMUGRF types to distinguish
As rk3368 contained two separated iodomain areas, this was determined to use which regmap base address. Signed-off-by: David Wu --- drivers/power/avs/rockchip-io-domain.c | 32 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/power/avs/rockchip-io-domain.c b/drivers/power/avs/rockchip-io-domain.c index 8099456..b17aeb7 100644 --- a/drivers/power/avs/rockchip-io-domain.c +++ b/drivers/power/avs/rockchip-io-domain.c @@ -47,6 +47,11 @@ #define RK3368_SOC_CON15_FLASH0BIT(14) #define RK3368_SOC_FLASH_SUPPLY_NUM2 +enum rockchip_iodomain_grf_type { + GRF, + PMUGRF +}; + struct rockchip_iodomain; /** @@ -54,6 +59,7 @@ struct rockchip_iodomain; */ struct rockchip_iodomain_soc_data { int grf_offset; + enum rockchip_iodomain_grf_type type; const char *supply_names[MAX_SUPPLIES]; void (*init)(struct rockchip_iodomain *iod); }; @@ -67,7 +73,7 @@ struct rockchip_iodomain_supply { struct rockchip_iodomain { struct device *dev; - struct regmap *grf; + struct regmap *base; struct rockchip_iodomain_soc_data *soc_data; struct rockchip_iodomain_supply supplies[MAX_SUPPLIES]; }; @@ -86,7 +92,7 @@ static int rockchip_iodomain_write(struct rockchip_iodomain_supply *supply, /* apply hiword-mask */ val |= (BIT(supply->idx) << 16); - ret = regmap_write(iod->grf, iod->soc_data->grf_offset, val); + ret = regmap_write(iod->base, iod->soc_data->grf_offset, val); if (ret) dev_err(iod->dev, "Couldn't write to GRF\n"); @@ -157,7 +163,7 @@ static void rk3288_iodomain_init(struct rockchip_iodomain *iod) * instead of a special gpio. */ val = RK3288_SOC_CON2_FLASH0 | (RK3288_SOC_CON2_FLASH0 << 16); - ret = regmap_write(iod->grf, RK3288_SOC_CON2, val); + ret = regmap_write(iod->base, RK3288_SOC_CON2, val); if (ret < 0) dev_warn(iod->dev, "couldn't update flash0 ctrl\n"); } @@ -176,7 +182,7 @@ static void rk3368_iodomain_init(struct rockchip_iodomain *iod) * instead of a special gpio. */ val = RK3368_SOC_CON15_FLASH0 | (RK3368_SOC_CON15_FLASH0 << 16); - ret = regmap_write(iod->grf, RK3368_SOC_CON15, val); + ret = regmap_write(iod->base, RK3368_SOC_CON15, val); if (ret < 0) dev_warn(iod->dev, "couldn't update flash0 ctrl\n"); } @@ -187,6 +193,7 @@ static void rk3368_iodomain_init(struct rockchip_iodomain *iod) */ static const struct rockchip_iodomain_soc_data soc_data_rk3188 = { .grf_offset = 0x104, + .type = GRF, .supply_names = { NULL, NULL, @@ -209,6 +216,7 @@ static const struct rockchip_iodomain_soc_data soc_data_rk3188 = { static const struct rockchip_iodomain_soc_data soc_data_rk3288 = { .grf_offset = 0x380, + .type = GRF, .supply_names = { "lcdc", /* LCDC_VDD */ "dvp", /* DVPIO_VDD */ @@ -226,6 +234,7 @@ static const struct rockchip_iodomain_soc_data soc_data_rk3288 = { static const struct rockchip_iodomain_soc_data soc_data_rk3368 = { .grf_offset = 0x900, + .type = GRF, .supply_names = { NULL, /* reserved */ "dvp", /* DVPIO_VDD */ @@ -242,6 +251,7 @@ static const struct rockchip_iodomain_soc_data soc_data_rk3368 = { static const struct rockchip_iodomain_soc_data soc_data_rk3368_pmu = { .grf_offset = 0x100, + .type = PMUGRF, .supply_names = { NULL, NULL, @@ -293,10 +303,16 @@ static int rockchip_iodomain_probe(struct platform_device *pdev) match = of_match_node(rockchip_iodomain_match, np); iod->soc_data = (struct rockchip_iodomain_soc_data *)match->data; - iod->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); - if (IS_ERR(iod->grf)) { - dev_err(&pdev->dev, "couldn't find grf regmap\n"); - return PTR_ERR(iod->grf); + if (iod->soc_data->type == PMUGRF) + iod->base = syscon_regmap_lookup_by_phandle( + np, "rockchip,pmugrf"); + else + iod->base = syscon_regmap_lookup_by_phandle( + np, "rockchip,grf"); + if (IS_ERR(iod->base)) { + dev_err(&pdev->dev, "couldn't find %s regmap\n", + (iod->soc_data->type == PMUGRF) ? "pmugrf" : "grf"); + return PTR_ERR(iod->base); } for (i = 0; i < MAX_SUPPLIES; i++) { -- 1.9.1
Re: [PATCH 4/3] mm, oom: drop the last allocation attempt before out_of_memory
Michal Hocko wrote: > > https://lkml.org/lkml/2015/3/25/40 > > > > We could have out_of_memory() wait until the number of outstanding OOM > > victims drops to 0. Then __alloc_pages_may_oom() doesn't relinquish > > the lock until its kill has been finalized: > > > > diff --git a/mm/oom_kill.c b/mm/oom_kill.c > > index 914451a..4dc5b9d 100644 > > --- a/mm/oom_kill.c > > +++ b/mm/oom_kill.c > > @@ -892,7 +892,9 @@ bool out_of_memory(struct oom_control *oc) > > * Give the killed process a good chance to exit before trying > > * to allocate memory again. > > */ > > - schedule_timeout_killable(1); > > + if (!test_thread_flag(TIF_MEMDIE)) > > + wait_event_timeout(oom_victims_wait, > > + !atomic_read(&oom_victims), HZ); > > } > > return true; > > } > > Yes this makes sense to me I think schedule_timeout_killable(1) was used for handling cases where current thread did not get TIF_MEMDIE but got SIGKILL due to sharing the victim's memory. If current thread is blocking TIF_MEMDIE thread, this can become a needless delay. Also, I don't know whether using wait_event_*() helps handling a problem that schedule_timeout_killable(1) can sleep for many minutes with oom_lock held when there are a lot of tasks. Detail is explained in my proposed patch.
Re: [PATCH] Remove ambiguous logging for "Unsupported brightness interface"
On Wed, 27 Jan 2016, Joe Perches wrote: > On Wed, 2016-01-27 at 22:14 +, Eric Curtin wrote: > > Message gets logged on machines that are well supported. > > > > Signed-off-by: Eric Curtin > > --- > > drivers/platform/x86/thinkpad_acpi.c | 1 - > > 1 file changed, 1 deletion(-) > > > > diff --git a/drivers/platform/x86/thinkpad_acpi.c > > b/drivers/platform/x86/thinkpad_acpi.c > > index a268a7a..4eb41aa 100644 > > --- a/drivers/platform/x86/thinkpad_acpi.c > > +++ b/drivers/platform/x86/thinkpad_acpi.c > > @@ -6661,7 +6661,6 @@ static void __init > > tpacpi_detect_brightness_capabilities(void) > > pr_info("detected a 8-level brightness capable > > ThinkPad\n"); > > break; > > default: > > - pr_info("Unsupported brightness interface\n"); > > tp_features.bright_unkfw = 1; > > bright_maxlvl = b - 1; > > } > > Perhaps this should be something like this instead: > --- > drivers/platform/x86/thinkpad_acpi.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/platform/x86/thinkpad_acpi.c > b/drivers/platform/x86/thinkpad_acpi.c > index a268a7a..bd12c71 100644 > --- a/drivers/platform/x86/thinkpad_acpi.c > +++ b/drivers/platform/x86/thinkpad_acpi.c > @@ -6653,18 +6653,16 @@ static void __init > tpacpi_detect_brightness_capabilities(void) > switch (b) { > case 16: > bright_maxlvl = 15; > - pr_info("detected a 16-level brightness capable ThinkPad\n"); > break; > case 8: > case 0: > bright_maxlvl = 7; > - pr_info("detected a 8-level brightness capable ThinkPad\n"); > break; > default: > - pr_info("Unsupported brightness interface\n"); > tp_features.bright_unkfw = 1; > bright_maxlvl = b - 1; > } > + pr_info("detected %u brightness levels\n", bright_maxlvl + 1); > } This can be made pr_debug, since we're touching it... -- "One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
[PATCH net-next] netfilter: nf_conntrack: remove the unneed check for *bucket
In the 'for(...) {}', the *bucket alwasy < net->ct.htable_size, so remove the check Signed-off-by: Weidong Wang --- net/netfilter/nf_conntrack_core.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 3cb3cb8..cd7d5c8 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -1383,14 +1383,12 @@ get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data), lockp = &nf_conntrack_locks[*bucket % CONNTRACK_LOCKS]; local_bh_disable(); spin_lock(lockp); - if (*bucket < net->ct.htable_size) { - hlist_nulls_for_each_entry(h, n, &net->ct.hash[*bucket], hnnode) { - if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL) - continue; - ct = nf_ct_tuplehash_to_ctrack(h); - if (iter(ct, data)) - goto found; - } + hlist_nulls_for_each_entry(h, n, &net->ct.hash[*bucket], hnnode) { + if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL) + continue; + ct = nf_ct_tuplehash_to_ctrack(h); + if (iter(ct, data)) + goto found; } spin_unlock(lockp); local_bh_enable(); -- 2.7.0
[PATCH v4 2/2] dt-bindings: rockchip-pinctrl: Support the RK3399 SoCs compatible
Signed-off-by: David Wu --- Change in v4: - need Signed-off Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt index 391ef4b..3bb9456 100644 --- a/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt +++ b/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt @@ -22,6 +22,7 @@ Required properties for iomux controller: - compatible: one of "rockchip,rk2928-pinctrl", "rockchip,rk3066a-pinctrl" "rockchip,rk3066b-pinctrl", "rockchip,rk3188-pinctrl" "rockchip,rk3288-pinctrl", "rockchip,rk3368-pinctrl" + "rockchip,rk3399-pinctrl" - rockchip,grf: phandle referencing a syscon providing the "general register files" -- 1.9.1
[PATCH v4 0/2] add pinctrl support for rk3399
Test on rk3399 fpga-board David Wu (2): pinctrl: rockchip: add support for the rk3399 dt-bindings: rockchip-pinctrl: Support the RK3399 SoCs compatible .../bindings/pinctrl/rockchip,pinctrl.txt | 1 + drivers/pinctrl/pinctrl-rockchip.c | 372 - 2 files changed, 359 insertions(+), 14 deletions(-) -- 1.9.1
[PATCH v4 1/2] pinctrl: rockchip: add support for the rk3399
The pinctrl of rk3399 is much different from other's, especially the 3bits of drive strength. Signed-off-by: David Wu --- Change in v4: None Change in v3: - use switch-case to distinguish special 3bits width per pin (Heiko) Change in v2: - need spin_unlock_irqrestore for set drive default case drivers/pinctrl/pinctrl-rockchip.c | 372 +++-- 1 file changed, 358 insertions(+), 14 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index a065112..d5c71b0 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -64,6 +64,7 @@ enum rockchip_pinctrl_type { RK3188, RK3288, RK3368, + RK3399, }; /** @@ -86,6 +87,31 @@ struct rockchip_iomux { }; /** + * enum type index corresponding to rockchip_perpin_drv_list arrays index. + */ +enum rockchip_pin_drv_type { + DRV_TYPE_IO_DEFAULT = 0, + DRV_TYPE_IO_1V8_OR_3V0, + DRV_TYPE_IO_1V8_ONLY, + DRV_TYPE_IO_1V8_3V0_AUTO, + DRV_TYPE_IO_3V3_ONLY, + DRV_TYPE_MAX +}; + +/** + * @drv_type: drive strength variant using rockchip_perpin_drv_type + * @offset: if initialized to -1 it will be autocalculated, by specifying + * an initial offset value the relevant source offset can be reset + * to a new value for autocalculating the following drive strength + * registers. if used chips own cal_drv func instead to calculate + * registers offset, the variant could be ignored. + */ +struct rockchip_drv { + enum rockchip_pin_drv_type drv_type; + int offset; +}; + +/** * @reg_base: register base of the gpio bank * @reg_pull: optional separate register for additional pull settings * @clk: clock of the gpio bank @@ -96,6 +122,7 @@ struct rockchip_iomux { * @name: name of the bank * @bank_num: number of the bank, to account for holes * @iomux: array describing the 4 iomux sources of the bank + * @drv: array describing the 4 drive strength sources of the bank * @valid: are all necessary informations present * @of_node: dt node of this bank * @drvdata: common pinctrl basedata @@ -115,6 +142,7 @@ struct rockchip_pin_bank { char*name; u8 bank_num; struct rockchip_iomux iomux[4]; + struct rockchip_drv drv[4]; boolvalid; struct device_node *of_node; struct rockchip_pinctrl *drvdata; @@ -151,6 +179,47 @@ struct rockchip_pin_bank { }, \ } +#define PIN_BANK_DRV_FLAGS(id, pins, label, type0, type1, type2, type3) \ + { \ + .bank_num = id, \ + .nr_pins= pins, \ + .name = label,\ + .iomux = { \ + { .offset = -1 }, \ + { .offset = -1 }, \ + { .offset = -1 }, \ + { .offset = -1 }, \ + }, \ + .drv= { \ + { .drv_type = type0, .offset = -1 },\ + { .drv_type = type1, .offset = -1 },\ + { .drv_type = type2, .offset = -1 },\ + { .drv_type = type3, .offset = -1 },\ + }, \ + } + +#define PIN_BANK_IOMUX_DRV_FLAGS_OFFSET(id, pins, label, iom0, iom1, \ + iom2, iom3, drv0, drv1, drv2, \ + drv3, offset0, offset1, \ + offset2, offset3) \ + { \ + .bank_num = id, \ + .nr_pins= pins, \ + .name = label,\ + .iomux = { \ + { .type = iom0, .offset = -1 }, \ + { .type = iom1, .offset = -1 }, \ + { .type = iom2, .offset = -1 }, \ + { .type = iom3, .offset = -1 }, \ + },
Re: [PATCH V13 09/10] vfio, platform: add support for ACPI while detecting the reset driver
Hi Sinan, [auto build test ERROR on vfio/next] [also build test ERROR on v4.5-rc1 next-20160129] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Sinan-Kaya/dma-add-Qualcomm-Technologies-HIDMA-driver/20160130-064551 base: https://github.com/awilliam/linux-vfio.git next config: arm64-allmodconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=arm64 All errors (new ones prefixed by >>): drivers/vfio/platform/vfio_platform_common.c: In function 'vfio_platform_probe_acpi': >> drivers/vfio/platform/vfio_platform_common.c:558:9: error: invalid >> initializer struct acpi_device adev = ACPI_COMPANION(dev); ^ >> drivers/vfio/platform/vfio_platform_common.c:560:6: error: wrong type >> argument to unary exclamation mark if (!adev) ^ >> drivers/vfio/platform/vfio_platform_common.c:563:18: error: incompatible >> type for argument 1 of 'acpi_device_hid' vdev->acpihid = acpi_device_hid(adev); ^ In file included from include/linux/acpi.h:41:0, from drivers/vfio/platform/vfio_platform_common.c:16: include/acpi/acpi_bus.h:253:13: note: expected 'struct acpi_device *' but argument is of type 'struct acpi_device' const char *acpi_device_hid(struct acpi_device *device); ^ vim +558 drivers/vfio/platform/vfio_platform_common.c 552 }; 553 554 #ifdef CONFIG_ACPI 555 int vfio_platform_probe_acpi(struct vfio_platform_device *vdev, 556 struct device *dev) 557 { > 558 struct acpi_device adev = ACPI_COMPANION(dev); 559 > 560 if (!adev) 561 return -EINVAL; 562 > 563 vdev->acpihid = acpi_device_hid(adev); 564 if (!vdev->acpihid) { 565 pr_err("VFIO: cannot find ACPI HID for %s\n", 566 vdev->name); --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
[PATCH 3/4] netfilter: ipv4: use preferred kernel types
As suggested by checkpatch.pl: CHECK: Prefer kernel type 'uX' over 'uintX_t' Signed-off-by: Lucas Tanure --- net/ipv4/netfilter/ip_tables.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index 79d4a04..dcc61c0 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -1411,7 +1411,7 @@ compat_copy_entry_to_user(struct ipt_entry *e, void __user **dstptr, { struct xt_entry_target *t; struct compat_ipt_entry __user *ce; - u_int16_t target_offset, next_offset; + u16 target_offset, next_offset; compat_uint_t origsize; const struct xt_entry_match *ematch; int ret = 0; @@ -2122,8 +2122,7 @@ EXPORT_SYMBOL(ipt_unregister_table); /* Returns 1 if the type and code is matched by the range, 0 otherwise */ static inline bool -icmp_type_code_match(u_int8_t test_type, u_int8_t min_code, u_int8_t max_code, -u_int8_t type, u_int8_t code, +icmp_type_code_match(u8 test_type, u8 min_code, u8 max_code, u8 type, u8 code, bool invert) { return ((test_type == 0xFF) || -- 2.7.0
[PATCH 1/4] netfilter: ipv4: use linux/uaccess.h
Fix checkpatch warning WARNING: Use #include instead of Signed-off-by: Lucas Tanure --- net/ipv4/netfilter/ip_tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index b99affa..aa0e41e 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include -- 2.7.0
[PATCH 4/4] netfilter: ipv4: spaces preferred around operators
Fix the checkpatch.pl issues: CHECK: spaces preferred around that '&' (ctx:VxV) CHECK: spaces preferred around that '<<' (ctx:VxV) CHECK: spaces preferred around that '-' (ctx:VxV) CHECK: spaces preferred around that '+' (ctx:VxV) Signed-off-by: Lucas Tanure --- net/ipv4/netfilter/ip_tables.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index dcc61c0..6f29382 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -82,9 +82,9 @@ ip_packet_match(const struct iphdr *ip, #define FWINV(bool, invflg) ((bool) ^ !!(ipinfo->invflags & (invflg))) - if (FWINV((ip->saddr&ipinfo->smsk.s_addr) != ipinfo->src.s_addr, + if (FWINV((ip->saddr & ipinfo->smsk.s_addr) != ipinfo->src.s_addr, IPT_INV_SRCIP) || - FWINV((ip->daddr&ipinfo->dmsk.s_addr) != ipinfo->dst.s_addr, + FWINV((ip->daddr & ipinfo->dmsk.s_addr) != ipinfo->dst.s_addr, IPT_INV_DSTIP)) { dprintf("Source or dest mismatch.\n"); @@ -126,7 +126,7 @@ ip_packet_match(const struct iphdr *ip, /* If we have a fragment rule but the packet is not a fragment * then we return zero */ - if (FWINV((ipinfo->flags&IPT_F_FRAG) && !isfrag, IPT_INV_FRAG)) { + if (FWINV((ipinfo->flags & IPT_F_FRAG) && !isfrag, IPT_INV_FRAG)) { dprintf("Fragment rule but not fragment.%s\n", ipinfo->invflags & IPT_INV_FRAG ? " (INV)" : ""); return false; @@ -496,7 +496,7 @@ mark_source_chains(const struct xt_table_info *newinfo, /* Return: backtrack through the last big jump. */ do { - e->comefrom ^= (1comefrom & (1 << NF_INET_NUMHOOKS)) { @@ -981,7 +981,7 @@ copy_entries_to_user(unsigned int total_size, + offsetof(struct xt_entry_match, u.user.name), m->u.kernel.match->name, -strlen(m->u.kernel.match->name)+1) +strlen(m->u.kernel.match->name) + 1) != 0) { ret = -EFAULT; goto free_counters; @@ -993,7 +993,7 @@ copy_entries_to_user(unsigned int total_size, + offsetof(struct xt_entry_target, u.user.name), t->u.kernel.target->name, -strlen(t->u.kernel.target->name)+1) != 0) { +strlen(t->u.kernel.target->name) + 1) != 0) { ret = -EFAULT; goto free_counters; } @@ -1094,7 +1094,7 @@ static int get_info(struct net *net, void __user *user, if (copy_from_user(name, user, sizeof(name)) != 0) return -EFAULT; - name[XT_TABLE_MAXNAMELEN-1] = '\0'; + name[XT_TABLE_MAXNAMELEN - 1] = '\0'; #ifdef CONFIG_COMPAT if (compat) xt_compat_lock(AF_INET); @@ -1270,7 +1270,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) if (tmp.num_counters == 0) return -EINVAL; - tmp.name[sizeof(tmp.name)-1] = 0; + tmp.name[sizeof(tmp.name) - 1] = 0; newinfo = xt_alloc_table_info(tmp.size); if (!newinfo) @@ -1818,7 +1818,7 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) if (tmp.num_counters == 0) return -EINVAL; - tmp.name[sizeof(tmp.name)-1] = 0; + tmp.name[sizeof(tmp.name) - 1] = 0; newinfo = xt_alloc_table_info(tmp.size); if (!newinfo) @@ -2041,7 +2041,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) ret = -EFAULT; break; } - rev.name[sizeof(rev.name)-1] = 0; + rev.name[sizeof(rev.name) - 1] = 0; if (cmd == IPT_SO_GET_REVISION_TARGET) target = 1; @@ -2155,7 +2155,7 @@ icmp_match(const struct sk_buff *skb, struct xt_action_param *par) icmpinfo->code[0], icmpinfo->code[1], ic->type, ic->code, - !!(icmpinfo->invflags&IPT_ICMP_INV)); + !!(icmpinfo->invflags & IPT_ICMP_INV)); } static int icmp_checkentry(const struct xt_mtchk_param *par)
[PATCH 2/4] netfilter: ipv4: EXPORT_SYMBOL should be shortly thereafter the exported function
change made to resolve following checkpatch message: WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable Signed-off-by: Lucas Tanure --- net/ipv4/netfilter/ip_tables.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index aa0e41e..79d4a04 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -442,6 +442,7 @@ ipt_do_table(struct sk_buff *skb, else return verdict; #endif } +EXPORT_SYMBOL(ipt_do_table); /* Figures out from what hook each rule can be called: returns 0 if there are loops. Puts hook bitmask in comefrom. */ @@ -2098,6 +2099,7 @@ out_free: out: return ERR_PTR(ret); } +EXPORT_SYMBOL(ipt_register_table); void ipt_unregister_table(struct net *net, struct xt_table *table) { @@ -2116,6 +2118,7 @@ void ipt_unregister_table(struct net *net, struct xt_table *table) module_put(table_owner); xt_free_table_info(private); } +EXPORT_SYMBOL(ipt_unregister_table); /* Returns 1 if the type and code is matched by the range, 0 otherwise */ static inline bool @@ -2269,8 +2272,5 @@ static void __exit ip_tables_fini(void) unregister_pernet_subsys(&ip_tables_net_ops); } -EXPORT_SYMBOL(ipt_register_table); -EXPORT_SYMBOL(ipt_unregister_table); -EXPORT_SYMBOL(ipt_do_table); module_init(ip_tables_init); module_exit(ip_tables_fini); -- 2.7.0
[tip:x86/asm] x86/cpufeature: Replace the old static_cpu_has() with safe variant
Commit-ID: bc696ca05f5a8927329ec276a892341e006b00ba Gitweb: http://git.kernel.org/tip/bc696ca05f5a8927329ec276a892341e006b00ba Author: Borislav Petkov AuthorDate: Tue, 26 Jan 2016 22:12:05 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 11:22:18 +0100 x86/cpufeature: Replace the old static_cpu_has() with safe variant So the old one didn't work properly before alternatives had run. And it was supposed to provide an optimized JMP because the assumption was that the offset it is jumping to is within a signed byte and thus a two-byte JMP. So I did an x86_64 allyesconfig build and dumped all possible sites where static_cpu_has() was used. The optimization amounted to all in all 12(!) places where static_cpu_has() had generated a 2-byte JMP. Which has saved us a whopping 36 bytes! This clearly is not worth the trouble so we can remove it. The only place where the optimization might count - in __switch_to() - we will handle differently. But that's not subject of this patch. Signed-off-by: Borislav Petkov Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1453842730-28463-6-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- arch/x86/Kconfig.debug | 10 arch/x86/include/asm/cpufeature.h| 100 +++ arch/x86/include/asm/fpu/internal.h | 14 ++--- arch/x86/kernel/apic/apic_numachip.c | 4 +- arch/x86/kernel/cpu/common.c | 12 + arch/x86/kernel/vm86_32.c| 2 +- drivers/cpufreq/intel_pstate.c | 2 +- fs/btrfs/disk-io.c | 2 +- 8 files changed, 21 insertions(+), 125 deletions(-) diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug index 9b18ed9..68a2d1f 100644 --- a/arch/x86/Kconfig.debug +++ b/arch/x86/Kconfig.debug @@ -350,16 +350,6 @@ config DEBUG_IMR_SELFTEST If unsure say N here. -config X86_DEBUG_STATIC_CPU_HAS - bool "Debug alternatives" - depends on DEBUG_KERNEL - ---help--- - This option causes additional code to be generated which - fails if static_cpu_has() is used before alternatives have - run. - - If unsure, say N. - config X86_DEBUG_FPU bool "Debug the x86 FPU code" depends on DEBUG_KERNEL diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 3cce9f3..a261cf2 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -125,103 +125,19 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; #define cpu_has_osxsaveboot_cpu_has(X86_FEATURE_OSXSAVE) #define cpu_has_hypervisor boot_cpu_has(X86_FEATURE_HYPERVISOR) /* - * Do not add any more of those clumsy macros - use static_cpu_has_safe() for + * Do not add any more of those clumsy macros - use static_cpu_has() for * fast paths and boot_cpu_has() otherwise! */ #if __GNUC__ >= 4 && defined(CONFIG_X86_FAST_FEATURE_TESTS) -extern void warn_pre_alternatives(void); -extern bool __static_cpu_has_safe(u16 bit); +extern bool __static_cpu_has(u16 bit); /* * Static testing of CPU features. Used the same as boot_cpu_has(). * These are only valid after alternatives have run, but will statically * patch the target code for additional performance. */ -static __always_inline __pure bool __static_cpu_has(u16 bit) -{ -#ifdef CC_HAVE_ASM_GOTO - -#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS - - /* -* Catch too early usage of this before alternatives -* have run. -*/ - asm_volatile_goto("1: jmp %l[t_warn]\n" -"2:\n" -".section .altinstructions,\"a\"\n" -" .long 1b - .\n" -" .long 0\n" /* no replacement */ -" .word %P0\n" /* 1: do replace */ -" .byte 2b - 1b\n" /* source len */ -" .byte 0\n" /* replacement len */ -" .byte 0\n" /* pad len */ -".previous\n" -/* skipping size check since replacement size = 0 */ -: : "i" (X86_FEATURE_ALWAYS) : : t_warn); - -#endif - - asm_volatile_goto("1: jmp %l[t_no]\n" -"2:\n" -".section .altinstructions,\"a\"\n" -" .long 1b - .\n" -" .long 0\n" /* no replacement */ -" .word %P0\n" /* feature bit */ -" .byte 2b - 1b\n" /* source len */ -" .byte 0\n" /* replacement len */ -" .byte 0\n" /* pad len */ -".previous\n" -
[tip:x86/asm] x86/cpufeature: Get rid of the non-asm goto variant
Commit-ID: a362bf9f5e7dd659b96d01382da7b855f4e5a7a1 Gitweb: http://git.kernel.org/tip/a362bf9f5e7dd659b96d01382da7b855f4e5a7a1 Author: Borislav Petkov AuthorDate: Wed, 27 Jan 2016 09:43:25 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 11:22:19 +0100 x86/cpufeature: Get rid of the non-asm goto variant I can simply quote hpa from the mail: "Get rid of the non-asm goto variant and just fall back to dynamic if asm goto is unavailable. It doesn't make any sense, really, if it is supposed to be safe, and by now the asm goto-capable gcc is in more wide use. (Originally the gcc 3.x fallback to pure dynamic didn't exist, either.)" Booy, am I lazy. Cleanup the whole CC_HAVE_ASM_GOTO ifdeffery too, while at it. Suggested-by: H. Peter Anvin Signed-off-by: Borislav Petkov Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20160127084325.gb30...@pd.tnic Signed-off-by: Ingo Molnar --- arch/x86/include/asm/cpufeature.h | 49 --- 1 file changed, 5 insertions(+), 44 deletions(-) diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index a261cf2..9048c1b 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -129,17 +129,16 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; * fast paths and boot_cpu_has() otherwise! */ -#if __GNUC__ >= 4 && defined(CONFIG_X86_FAST_FEATURE_TESTS) +#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_X86_FAST_FEATURE_TESTS) extern bool __static_cpu_has(u16 bit); /* * Static testing of CPU features. Used the same as boot_cpu_has(). - * These are only valid after alternatives have run, but will statically - * patch the target code for additional performance. + * These will statically patch the target code for additional + * performance. */ static __always_inline __pure bool _static_cpu_has(u16 bit) { -#ifdef CC_HAVE_ASM_GOTO asm_volatile_goto("1: jmp %l[t_dynamic]\n" "2:\n" ".skip -(((5f-4f) - (2b-1b)) > 0) * " @@ -172,45 +171,6 @@ static __always_inline __pure bool _static_cpu_has(u16 bit) return false; t_dynamic: return __static_cpu_has(bit); -#else - u8 flag; - /* Open-coded due to __stringify() in ALTERNATIVE() */ - asm volatile("1: movb $2,%0\n" -"2:\n" -".section .altinstructions,\"a\"\n" -" .long 1b - .\n" /* src offset */ -" .long 3f - .\n" /* repl offset */ -" .word %P2\n" /* always replace */ -" .byte 2b - 1b\n" /* source len */ -" .byte 4f - 3f\n" /* replacement len */ -" .byte 0\n" /* pad len */ -".previous\n" -".section .discard,\"aw\",@progbits\n" -" .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */ -".previous\n" -".section .altinstr_replacement,\"ax\"\n" -"3: movb $0,%0\n" -"4:\n" -".previous\n" -".section .altinstructions,\"a\"\n" -" .long 1b - .\n" /* src offset */ -" .long 5f - .\n" /* repl offset */ -" .word %P1\n" /* feature bit */ -" .byte 4b - 3b\n" /* src len */ -" .byte 6f - 5f\n" /* repl len */ -" .byte 0\n" /* pad len */ -".previous\n" -".section .discard,\"aw\",@progbits\n" -" .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */ -".previous\n" -".section .altinstr_replacement,\"ax\"\n" -"5: movb $1,%0\n" -"6:\n" -".previous\n" -: "=qm" (flag) -: "i" (bit), "i" (X86_FEATURE_ALWAYS)); - return (flag == 2 ? __static_cpu_has(bit) : flag); -#endif /* CC_HAVE_ASM_GOTO */ } #define static_cpu_has(bit)\ @@ -221,7 +181,8 @@ static __always_inline __pure bool _static_cpu_has(u16 bit) ) #else /* - * gcc 3.x is too stupid to do the static test; fall back to dynamic. + * Fall back to dynamic for gcc versions which don't support asm goto. Should be + * a minority now anyw
[tip:x86/asm] x86/cpufeature: Carve out X86_FEATURE_*
Commit-ID: cd4d09ec6f6c12a2cc3db5b7d8876a325a53545b Gitweb: http://git.kernel.org/tip/cd4d09ec6f6c12a2cc3db5b7d8876a325a53545b Author: Borislav Petkov AuthorDate: Tue, 26 Jan 2016 22:12:04 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 11:22:17 +0100 x86/cpufeature: Carve out X86_FEATURE_* Move them to a separate header and have the following dependency: x86/cpufeatures.h <- x86/processor.h <- x86/cpufeature.h This makes it easier to use the header in asm code and not include the whole cpufeature.h and add guards for asm. Suggested-by: H. Peter Anvin Signed-off-by: Borislav Petkov Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1453842730-28463-5-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- Documentation/kernel-parameters.txt| 2 +- arch/x86/boot/cpuflags.h | 2 +- arch/x86/boot/mkcpustr.c | 2 +- arch/x86/crypto/crc32-pclmul_glue.c| 2 +- arch/x86/crypto/crc32c-intel_glue.c| 2 +- arch/x86/crypto/crct10dif-pclmul_glue.c| 2 +- arch/x86/entry/common.c| 1 + arch/x86/entry/entry_32.S | 2 +- arch/x86/entry/vdso/vdso32-setup.c | 1 - arch/x86/entry/vdso/vdso32/system_call.S | 2 +- arch/x86/entry/vdso/vma.c | 1 + arch/x86/include/asm/alternative.h | 6 - arch/x86/include/asm/apic.h| 1 - arch/x86/include/asm/arch_hweight.h| 2 + arch/x86/include/asm/cmpxchg.h | 1 + arch/x86/include/asm/cpufeature.h | 284 + .../include/asm/{cpufeature.h => cpufeatures.h}| 336 + arch/x86/include/asm/fpu/internal.h| 1 + arch/x86/include/asm/irq_work.h| 2 +- arch/x86/include/asm/mwait.h | 2 + arch/x86/include/asm/processor.h | 3 +- arch/x86/include/asm/smap.h| 2 +- arch/x86/include/asm/smp.h | 1 - arch/x86/include/asm/thread_info.h | 2 +- arch/x86/include/asm/tlbflush.h| 1 + arch/x86/include/asm/uaccess_64.h | 2 +- arch/x86/kernel/cpu/Makefile | 2 +- arch/x86/kernel/cpu/centaur.c | 2 +- arch/x86/kernel/cpu/cyrix.c| 1 + arch/x86/kernel/cpu/intel.c| 2 +- arch/x86/kernel/cpu/intel_cacheinfo.c | 2 +- arch/x86/kernel/cpu/match.c| 2 +- arch/x86/kernel/cpu/mkcapflags.sh | 6 +- arch/x86/kernel/cpu/mtrr/main.c| 2 +- arch/x86/kernel/cpu/transmeta.c| 2 +- arch/x86/kernel/e820.c | 1 + arch/x86/kernel/head_32.S | 2 +- arch/x86/kernel/hpet.c | 1 + arch/x86/kernel/msr.c | 2 +- arch/x86/kernel/verify_cpu.S | 2 +- arch/x86/lib/clear_page_64.S | 2 +- arch/x86/lib/copy_page_64.S| 2 +- arch/x86/lib/copy_user_64.S| 2 +- arch/x86/lib/memcpy_64.S | 2 +- arch/x86/lib/memmove_64.S | 2 +- arch/x86/lib/memset_64.S | 2 +- arch/x86/mm/setup_nx.c | 1 + arch/x86/oprofile/op_model_amd.c | 1 - arch/x86/um/asm/barrier.h | 2 +- lib/atomic64_test.c| 2 +- 50 files changed, 54 insertions(+), 658 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 87d40a7..c0c6253 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -666,7 +666,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted. clearcpuid=BITNUM [X86] Disable CPUID feature X for the kernel. See - arch/x86/include/asm/cpufeature.h for the valid bit + arch/x86/include/asm/cpufeatures.h for the valid bit numbers. Note the Linux specific bits are not necessarily stable over kernel options, but the vendor specific ones should be. diff --git a/arch/x86/boot/cpuflags.h b/arch/x86/boot/cpuflags.h index ea97697..4cb404f 100644 --- a/arch/x86/boot/cpuflags.h +++ b/arch/x86/boot/cpuflags.h @@ -1,7 +1,7 @@ #ifndef BOOT_CPUFLAGS_H #define BOOT_CPUFLAGS_H -#include +#include #include
[tip:x86/asm] x86/alternatives: Add an auxilary section
Commit-ID: 337e4cc84021212a87b04b77b6549304909e Gitweb: http://git.kernel.org/tip/337e4cc84021212a87b04b77b6549304909e Author: Borislav Petkov AuthorDate: Tue, 26 Jan 2016 22:12:07 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 11:22:20 +0100 x86/alternatives: Add an auxilary section Add .altinstr_aux for additional instructions which will be used before and/or during patching. All stuff which needs more sophisticated patching should go there. See next patch. Signed-off-by: Borislav Petkov Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1453842730-28463-8-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- arch/x86/kernel/vmlinux.lds.S | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 74e4bf1..92dc211 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -195,6 +195,17 @@ SECTIONS :init #endif + /* +* Section for code used exclusively before alternatives are run. All +* references to such code must be patched out by alternatives, normally +* by using X86_FEATURE_ALWAYS CPU feature bit. +* +* See static_cpu_has() for an example. +*/ + .altinstr_aux : AT(ADDR(.altinstr_aux) - LOAD_OFFSET) { + *(.altinstr_aux) + } + INIT_DATA_SECTION(16) .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
[tip:x86/asm] x86/alternatives: Discard dynamic check after init
Commit-ID: 2476f2fa20568bd5d9e09cd35bcd73e99a6f4cc6 Gitweb: http://git.kernel.org/tip/2476f2fa20568bd5d9e09cd35bcd73e99a6f4cc6 Author: Brian Gerst AuthorDate: Wed, 27 Jan 2016 09:45:25 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 11:22:22 +0100 x86/alternatives: Discard dynamic check after init Move the code to do the dynamic check to the altinstr_aux section so that it is discarded after alternatives have run and a static branch has been chosen. This way we're changing the dynamic branch from C code to assembly, which makes it *substantially* smaller while avoiding a completely unnecessary call to an out of line function. Signed-off-by: Brian Gerst [ Changed it to do TESTB, as hpa suggested. ] Signed-off-by: Borislav Petkov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Andy Lutomirski Cc: Boris Ostrovsky Cc: Borislav Petkov Cc: Dave Young Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Kristen Carlson Accardi Cc: Laura Abbott Cc: Linus Torvalds Cc: Peter Zijlstra (Intel) Cc: Peter Zijlstra Cc: Prarit Bhargava Cc: Ross Zwisler Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1452972124-7380-1-git-send-email-brge...@gmail.com Link: http://lkml.kernel.org/r/20160127084525.gc30...@pd.tnic Signed-off-by: Ingo Molnar --- arch/x86/include/asm/cpufeature.h | 19 --- arch/x86/kernel/cpu/common.c | 6 -- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 9048c1b..9fba7a5 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -130,8 +130,6 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; */ #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_X86_FAST_FEATURE_TESTS) -extern bool __static_cpu_has(u16 bit); - /* * Static testing of CPU features. Used the same as boot_cpu_has(). * These will statically patch the target code for additional @@ -139,7 +137,7 @@ extern bool __static_cpu_has(u16 bit); */ static __always_inline __pure bool _static_cpu_has(u16 bit) { - asm_volatile_goto("1: jmp %l[t_dynamic]\n" + asm_volatile_goto("1: jmp 6f\n" "2:\n" ".skip -(((5f-4f) - (2b-1b)) > 0) * " "((5f-4f) - (2b-1b)),0x90\n" @@ -164,13 +162,20 @@ static __always_inline __pure bool _static_cpu_has(u16 bit) " .byte 0\n" /* repl len */ " .byte 0\n" /* pad len */ ".previous\n" -: : "i" (bit), "i" (X86_FEATURE_ALWAYS) -: : t_dynamic, t_no); +".section .altinstr_aux,\"ax\"\n" +"6:\n" +" testb %[bitnum],%[cap_byte]\n" +" jnz %l[t_yes]\n" +" jmp %l[t_no]\n" +".previous\n" +: : "i" (bit), "i" (X86_FEATURE_ALWAYS), +[bitnum] "i" (1 << (bit & 7)), +[cap_byte] "m" (((const char *)boot_cpu_data.x86_capability)[bit >> 3]) +: : t_yes, t_no); + t_yes: return true; t_no: return false; - t_dynamic: - return __static_cpu_has(bit); } #define static_cpu_has(bit)\ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index ee49981..079d83f 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1475,12 +1475,6 @@ void cpu_init(void) } #endif -inline bool __static_cpu_has(u16 bit) -{ - return boot_cpu_has(bit); -} -EXPORT_SYMBOL_GPL(__static_cpu_has); - static void bsp_resume(void) { if (this_cpu->c_bsp_resume)
[tip:x86/asm] x86/vdso: Use static_cpu_has()
Commit-ID: 8c725306993198f845038dc9e45a1267099867a6 Gitweb: http://git.kernel.org/tip/8c725306993198f845038dc9e45a1267099867a6 Author: Borislav Petkov AuthorDate: Tue, 26 Jan 2016 22:12:09 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 11:22:23 +0100 x86/vdso: Use static_cpu_has() ... and simplify and speed up a tad. Signed-off-by: Borislav Petkov Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1453842730-28463-10-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- arch/x86/entry/vdso/vma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 429d54d..10f7045 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -285,7 +285,7 @@ static void vgetcpu_cpu_init(void *arg) #ifdef CONFIG_NUMA node = cpu_to_node(cpu); #endif - if (cpu_has(&cpu_data(cpu), X86_FEATURE_RDTSCP)) + if (static_cpu_has(X86_FEATURE_RDTSCP)) write_rdtscp_aux((node << 12) | cpu); /*
[tip:x86/boot] x86/boot: Simplify kernel load address alignment check
Commit-ID: a4733143085d6c782ac1e6c85778655b6bac1d4e Gitweb: http://git.kernel.org/tip/a4733143085d6c782ac1e6c85778655b6bac1d4e Author: Alexander Kuleshov AuthorDate: Tue, 26 Jan 2016 22:12:10 +0100 Committer: Ingo Molnar CommitDate: Sat, 30 Jan 2016 11:22:48 +0100 x86/boot: Simplify kernel load address alignment check We are using %rax as temporary register to check the kernel address alignment. We don't really have to since the TEST instruction does not clobber the destination operand. Suggested-by: Brian Gerst Signed-off-by: Alexander Kuleshov Signed-off-by: Borislav Petkov Cc: Alexander Popov Cc: Andrey Ryabinin Cc: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1453531828-19291-1-git-send-email-kuleshovm...@gmail.com Link: http://lkml.kernel.org/r/1453842730-28463-11-git-send-email...@alien8.de Signed-off-by: Ingo Molnar --- arch/x86/kernel/head_64.S | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index ffdc0e8..7c21029 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -76,9 +76,7 @@ startup_64: subq$_text - __START_KERNEL_map, %rbp /* Is the address not 2M aligned? */ - movq%rbp, %rax - andl$~PMD_PAGE_MASK, %eax - testl %eax, %eax + testl $~PMD_PAGE_MASK, %ebp jnz bad_address /*
[PATCH] Restrict read access to private module signing key
The autogenerated module signing key shouldn't be world-readable. Signed-off-by: Luis Ressel --- certs/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/certs/Makefile b/certs/Makefile index 28ac694..7f1f082 100644 --- a/certs/Makefile +++ b/certs/Makefile @@ -49,6 +49,8 @@ $(obj)/signing_key.pem: $(obj)/x509.genkey @echo "### needs to be run as root, and uses a hardware random" @echo "### number generator if one is available." @echo "###" + touch $(obj)/signing_key.pem + chmod 0600 $(obj)/signing_key.pem openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \ -batch -x509 -config $(obj)/x509.genkey \ -outform PEM -out $(obj)/signing_key.pem \ -- 2.7.0
Re: [PATCH] ld-version: fix it on Fedora
On Mon, 25 Jan 2016, Alexander Kapshuk wrote: > > > At the moment, I'm wondering whether we really need to handle more > > > than three version number components. Another thought is that the > > > comparison could be inside ld-version.sh (or a replacement) so that > > > it can compare the array of version components directly instead of > > > using a constructed integer as a proxy. I don't think going beyond three version number components makes sense, to be honest. Any such numbers will be non-standard third-party releases. Upstream binutils use a three-component versioning scheme. Even the third component only makes sense because sometime we may actually rely on a bug fix first available with a maintenance release; these reach single-digit numbers only and hardly ever above 1 actually as another base release is usually made quickly enough (the usual schedule was annual, although as from 2.26, out last Monday, it has been switched to a semi-annual cycle). > I put the latter of the two methods that worked for you it into a > script, shown below: > > #!/usr/bin/awk -f > # extract linker version number from stdin and turn into single number > > /[0-9]+([.]?[0-9]+)+/ && !/not found$/{ > match($0, /[0-9]+([.]?[0-9]+)+/) > ver=substr($0,RSTART,RLENGTH) > split(ver, a, ".") > print a[1]*1000 + a[2]*10 + a[3]*1000 > exit > } > > And tried it out on the following input: > > % echo 2.24.51.20140217 | ld-version.sh > 22451000 So the above version is a non-release snapshot from the development tree as the repository trunk is switched to x.y+1.51 once a release branch for x.y has been made. Then the release branch is switched to x.y-1.90 for prereleases, before settling on x.y or x.y.0 (this hasn't been consistent) for the actual base release. Any subsequent maintenance releases will then have their version set to x.y.1, x.y.2, and so on. We shouldn't ever rely on versions that are not proper releases. > % echo 'GNU ld version 2.25-15.fc23' | ld-version.sh > 2250 So this is a base 2.25 release (obviously with vendor patches, hopefully not breaking what we might rely on). FWIW, Maciej
Re: [PATCH 3/4] netfilter: ipv4: use preferred kernel types
On 30.01, Lucas Tanure wrote: > As suggested by checkpatch.pl: > CHECK: Prefer kernel type 'uX' over 'uintX_t' You might have noticed we have literally hundreds of them spread over 100 files in the netfilter code. We'll gradually change them when the code is touched anyways. > net/ipv4/netfilter/ip_tables.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-)
Re: [PATCHSET 00/10] perf tools: Apply percent-limit to callchains (v2)
Hi Arnaldo, On Sat, Jan 30, 2016 at 6:00 AM, Arnaldo Carvalho de Melo wrote: > Em Thu, Jan 28, 2016 at 08:52:25PM +0100, Jiri Olsa escreveu: >> On Thu, Jan 28, 2016 at 09:24:54PM +0900, Namhyung Kim wrote: >> >> SNIP >> >> > > > > The default limit of hist entries is 0 so it basically shows all >> > > > > entries. But default callchain limit is 0.5% so hist entries under >> > > > > 0.5% won't show callchains. >> > > > >> > > > Btw, I changed it to 0.005% in this patchset. Did you apply all the >> > > > patches and run 'perf report' with default value? >> > > >> > > yep, I had it and then reverted ;-) but I made typo >> > > in the previous email.. what I meant was: >> > > >> > > also I see extra LINE for entries... ;-) >> > >> > Ah, so you meant the blank lines.. The fix would be like following >> >> yep, tested.. works ;-) > > Namhyung, can I try to process this patchkit just by reading these > commends and making the adjustments? Or is there something outstanding > that warrants you to push a v2? It'd great for me if you process this (v1). I cannot work on the v2 for a couple of days.. Thanks, Namhyung
Re: [PATCH v3 2/2] dt-bindings: rockchip-pinctrl: Support the RK3399 SoCs compatible
Hi David, Am Samstag, 30. Januar 2016, 19:31:57 schrieb David Wu: > Change-Id: Ic1bdb3dc358837e97d7b48dd58be2f8d9d08d766 please no Change-Id, it's missing the Signed-off, and as Linus Walleij said, the compatible addition to the documentation can maybe stay in the pinctrl- patch itself. I think both Linus and me overlooked that the binding-doc-addition was already correctly included in your v2 patch at the top :-) Heiko > --- > Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt | 1 + > 1 file changed, 1 insertion(+) > > diff --git > a/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt > b/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt index > 391ef4b..3bb9456 100644 > --- a/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt > +++ b/Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt > @@ -22,6 +22,7 @@ Required properties for iomux controller: >- compatible: one of "rockchip,rk2928-pinctrl", > "rockchip,rk3066a-pinctrl" "rockchip,rk3066b-pinctrl", > "rockchip,rk3188-pinctrl" > "rockchip,rk3288-pinctrl", "rockchip,rk3368-pinctrl" > +"rockchip,rk3399-pinctrl" >- rockchip,grf: phandle referencing a syscon providing the >"general register files"
Re: [PATCH] PM / AVS: rockchip-io: add GRF and PMUGRF types to distinguish
Hi David, Am Samstag, 30. Januar 2016, 20:01:45 schrieb David Wu: > As rk3368 contained two separated iodomain areas, this was > determined to use which regmap base address. > > Signed-off-by: David Wu I don't think we need to specify this on a driver level. Both GRF areas are "General register files" only located in two separate power-domains. So the rockchip,grf property should work for both. Especially as nothing keeps designers from introducing yet another GRF-area somewhere else ;-) >From when I started working on the rk3368, I still have a preliminary patches for that sitting here, so I've attached on how I envisoned that to work. Heiko > --- > drivers/power/avs/rockchip-io-domain.c | 32 > 1 file changed, 24 insertions(+), 8 > deletions(-) > > diff --git a/drivers/power/avs/rockchip-io-domain.c > b/drivers/power/avs/rockchip-io-domain.c index 8099456..b17aeb7 100644 > --- a/drivers/power/avs/rockchip-io-domain.c > +++ b/drivers/power/avs/rockchip-io-domain.c > @@ -47,6 +47,11 @@ > #define RK3368_SOC_CON15_FLASH0 BIT(14) > #define RK3368_SOC_FLASH_SUPPLY_NUM 2 > > +enum rockchip_iodomain_grf_type { > + GRF, > + PMUGRF > +}; > + > struct rockchip_iodomain; > > /** > @@ -54,6 +59,7 @@ struct rockchip_iodomain; > */ > struct rockchip_iodomain_soc_data { > int grf_offset; > + enum rockchip_iodomain_grf_type type; > const char *supply_names[MAX_SUPPLIES]; > void (*init)(struct rockchip_iodomain *iod); > }; > @@ -67,7 +73,7 @@ struct rockchip_iodomain_supply { > > struct rockchip_iodomain { > struct device *dev; > - struct regmap *grf; > + struct regmap *base; > struct rockchip_iodomain_soc_data *soc_data; > struct rockchip_iodomain_supply supplies[MAX_SUPPLIES]; > }; > @@ -86,7 +92,7 @@ static int rockchip_iodomain_write(struct > rockchip_iodomain_supply *supply, /* apply hiword-mask */ > val |= (BIT(supply->idx) << 16); > > - ret = regmap_write(iod->grf, iod->soc_data->grf_offset, val); > + ret = regmap_write(iod->base, iod->soc_data->grf_offset, val); > if (ret) > dev_err(iod->dev, "Couldn't write to GRF\n"); > > @@ -157,7 +163,7 @@ static void rk3288_iodomain_init(struct > rockchip_iodomain *iod) * instead of a special gpio. >*/ > val = RK3288_SOC_CON2_FLASH0 | (RK3288_SOC_CON2_FLASH0 << 16); > - ret = regmap_write(iod->grf, RK3288_SOC_CON2, val); > + ret = regmap_write(iod->base, RK3288_SOC_CON2, val); > if (ret < 0) > dev_warn(iod->dev, "couldn't update flash0 ctrl\n"); > } > @@ -176,7 +182,7 @@ static void rk3368_iodomain_init(struct > rockchip_iodomain *iod) * instead of a special gpio. >*/ > val = RK3368_SOC_CON15_FLASH0 | (RK3368_SOC_CON15_FLASH0 << 16); > - ret = regmap_write(iod->grf, RK3368_SOC_CON15, val); > + ret = regmap_write(iod->base, RK3368_SOC_CON15, val); > if (ret < 0) > dev_warn(iod->dev, "couldn't update flash0 ctrl\n"); > } > @@ -187,6 +193,7 @@ static void rk3368_iodomain_init(struct > rockchip_iodomain *iod) */ > static const struct rockchip_iodomain_soc_data soc_data_rk3188 = { > .grf_offset = 0x104, > + .type = GRF, > .supply_names = { > NULL, > NULL, > @@ -209,6 +216,7 @@ static const struct rockchip_iodomain_soc_data > soc_data_rk3188 = { > > static const struct rockchip_iodomain_soc_data soc_data_rk3288 = { > .grf_offset = 0x380, > + .type = GRF, > .supply_names = { > "lcdc", /* LCDC_VDD */ > "dvp", /* DVPIO_VDD */ > @@ -226,6 +234,7 @@ static const struct rockchip_iodomain_soc_data > soc_data_rk3288 = { > > static const struct rockchip_iodomain_soc_data soc_data_rk3368 = { > .grf_offset = 0x900, > + .type = GRF, > .supply_names = { > NULL, /* reserved */ > "dvp", /* DVPIO_VDD */ > @@ -242,6 +251,7 @@ static const struct rockchip_iodomain_soc_data > soc_data_rk3368 = { > > static const struct rockchip_iodomain_soc_data soc_data_rk3368_pmu = { > .grf_offset = 0x100, > + .type = PMUGRF, > .supply_names = { > NULL, > NULL, > @@ -293,10 +303,16 @@ static int rockchip_iodomain_probe(struct > platform_device *pdev) match = of_match_node(rockchip_iodomain_match, > np); > iod->soc_data = (struct rockchip_iodomain_soc_data *)match->data; > > - iod->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); > - if (IS_ERR(iod->grf)) { > - dev_err(&pdev->dev, "couldn't find grf regmap\n"); > - return PTR_ERR(iod->grf); > + if (iod->soc_data->type == PMUGRF) > + iod->base = syscon_regmap_lookup_by_phandle( > + np, "rockchip,pmugrf"); > + else > + iod->base = syscon_regmap_lookup_by_phandle( > + np, "
Re: [PATCH v4 1/2] pinctrl: rockchip: add support for the rk3399
Hi David, Am Samstag, 30. Januar 2016, 20:20:12 schrieb David Wu: > The pinctrl of rk3399 is much different from other's, > especially the 3bits of drive strength. > > Signed-off-by: David Wu > --- > Change in v4: None you're to fast for me ;-) [...] > @@ -729,8 +924,67 @@ static int rockchip_set_drive_perpin(struct > rockchip_pin_bank *bank, > > spin_lock_irqsave(&bank->slock, flags); > > + switch (drv_type) { > + case DRV_TYPE_IO_1V8_3V0_AUTO: > + case DRV_TYPE_IO_3V3_ONLY: > + rmask_bits = RK3399_DRV_3BITS_PER_PIN; > + switch (bit) { > + case 0 ... 12: > + /* regular case, nothing to do */ > + break; > + case 15: > + /* > + * the bit data[15] contains bit 0 of the value > + * while temp[1:0] contains bits 2 and 1 > + */ I'd think the introductory comment should mode here, so like: /* * drive-strength offset is special, as it is * spread over 2 registers, the bit data[15] contains bit 0 * of the value while temp[1:0] contains bits 2 and 1 */ > + data = (ret & 0x1) << 15; > + temp = (ret >> 0x1) & 0x3; > + > + rmask = BIT(15) | BIT(31); > + data |= BIT(31); > + ret = regmap_update_bits(regmap, reg, rmask, data); > + if (ret) { > + spin_unlock_irqrestore(&bank->slock, flags); > + return ret; > + } > + > + /* > + * drive-strength offset is special, as it is > + * spread over 2 registers > + */ as I wrote, this should probably move a bit higher > + rmask = 0x3 | (0x3 << 16); > + temp |= (0x3 << 16); > + reg += 0x4; > + ret = regmap_update_bits(regmap, reg, rmask, temp); > + > + spin_unlock_irqrestore(&bank->slock, flags); > + return ret; > + case 18 ... 21: > + /* setting fully enclosed in the second register */ > + reg += 4; > + bit -= 16; > + break; > + default: > + spin_unlock_irqrestore(&bank->slock, flags); > + dev_err(info->dev, "unsupported bit: %d for pinctrl > drive type: %d\n", > + bit, drv_type); > + return -EINVAL; > + } > + break; > + case DRV_TYPE_IO_DEFAULT: > + case DRV_TYPE_IO_1V8_OR_3V0: > + case DRV_TYPE_IO_1V8_ONLY: > + rmask_bits = RK3288_DRV_BITS_PER_PIN; > + break; > + default: > + spin_unlock_irqrestore(&bank->slock, flags); > + dev_err(info->dev, "unsupported pinctrl drive type: %d\n", > + drv_type); > + return -EINVAL; > + } > + > /* enable the write to the equivalent lower bits */ > - data = ((1 << RK3288_DRV_BITS_PER_PIN) - 1) << (bit + 16); > + data = ((1 << rmask_bits) - 1) << (bit + 16); > rmask = data | (data >> 16); > data |= (ret << bit); > Otherwise this looks nice to me, so with the comment fixed Reviewed-by: Heiko Stuebner Thanks Heiko
Re: [PATCHv2 2/3] IB/core: added support to use rdma cgroup controller
Hi Parav, [auto build test ERROR on cgroup/for-next] [cannot apply to v4.5-rc1 next-20160129] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Parav-Pandit/rdma-controller-support/20160130-194534 base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next config: m68k-sun3_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=m68k All errors (new ones prefixed by >>): In file included from include/rdma/ib_verbs.h:58:0, from include/rdma/ib_addr.h:47, from include/rdma/rdma_cm.h:39, from net/rds/rds.h:7, from net/rds/af_rds.c:41: >> include/linux/cgroup_rdma.h:19:29: error: field 'css' has incomplete type struct cgroup_subsys_state css; ^ vim +/css +19 include/linux/cgroup_rdma.h f74be9d0 Parav Pandit 2016-01-30 13RDMACG_RESOURCE_POOL_VERB, f74be9d0 Parav Pandit 2016-01-30 14RDMACG_RESOURCE_POOL_HW, f74be9d0 Parav Pandit 2016-01-30 15RDMACG_RESOURCE_POOL_TYPE_MAX, f74be9d0 Parav Pandit 2016-01-30 16 }; f74be9d0 Parav Pandit 2016-01-30 17 f74be9d0 Parav Pandit 2016-01-30 18 struct rdma_cgroup { f74be9d0 Parav Pandit 2016-01-30 @19struct cgroup_subsys_state css; f74be9d0 Parav Pandit 2016-01-30 20 f74be9d0 Parav Pandit 2016-01-30 21spinlock_t cg_list_lock; /* protects cgroup resource pool list */ f74be9d0 Parav Pandit 2016-01-30 22struct list_head rpool_head;/* head to keep track of all resource :: The code at line 19 was first introduced by commit :: f74be9d0a094f209c9b8127317d9ce8d2f5dafea rdmacg: Added rdma cgroup controller. :: TO: Parav Pandit :: CC: 0day robot --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
Re: [PATCH 3/4] netfilter: ipv4: use preferred kernel types
On Sat, Jan 30, 2016 at 11:45 AM, Patrick McHardy wrote: > On 30.01, Lucas Tanure wrote: >> As suggested by checkpatch.pl: >> CHECK: Prefer kernel type 'uX' over 'uintX_t' > > You might have noticed we have literally hundreds of them spread over 100 > files in the netfilter code. We'll gradually change them when the code is > touched anyways. > >> net/ipv4/netfilter/ip_tables.c | 5 ++--- >> 1 file changed, 2 insertions(+), 3 deletions(-) Yes, I checked that. But would be better to change that now? Because: - could take years to anyone to touch the code, as the code already works very well - be more standardized could facilitate reading the code - It's a good way to encourage new people to contribute to the code Thanks!
Re: [PATCH 1/2] staging:iio:adc:added space around '-'
On 24/01/16 17:14, Lars-Peter Clausen wrote: > On 01/24/2016 05:36 PM, Jonathan Cameron wrote: >> On 20/01/16 14:21, Dan Carpenter wrote: >>> On Fri, Jan 15, 2016 at 09:15:52PM +0100, Lars-Peter Clausen wrote: On 01/15/2016 08:42 PM, Bhumika Goyal wrote: > This patch adds apace around '-' operator.Found using checkpatch.pl > > Signed-off-by: Bhumika Goyal > --- > drivers/staging/iio/adc/ad7280a.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/iio/adc/ad7280a.c > b/drivers/staging/iio/adc/ad7280a.c > index f45ebed..0c73bce 100644 > --- a/drivers/staging/iio/adc/ad7280a.c > +++ b/drivers/staging/iio/adc/ad7280a.c > @@ -744,14 +744,14 @@ out: > } > > static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value, > - in_voltage-voltage_thresh_low_value, > + in_voltage - voltage_thresh_low_value, Hi, Thanks for patch. But when sending cleanup patches like this please make sure that you a) understand what the code does and how your change affects it and b) as a bare minimum of testing perform a compile test, if possible also do functional testing. The patch as it is, is neither semantically nor syntactically correct. As an exercise please make sure you understand why. >>> >>> Ugh! >>> >>> It took me a long time to figure out the bug in this patch... Why does >>> that filename have a mix of dashes and underscores? Too late to fix it >>> now... :/ >>> >> Very deliberately. The - is indicating it is a differential channel! >> Literally A minus B. >> >> It's an awfully compact representation for maths ;) >> This is obscured partly in this case as it's specifying an attribute >> shared by a set of differential channels so it's the generalization >> of >> in_voltage0-voltage1_thresh_low_value >> which does begin to slightly stretch the argument that it is nice and >> clear ;( > > One thing we should maybe take a look at is making it explicit that this is > a string so it does not get picked up by checkpatch. Make sense. Patches welcome :) > > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >
Re: [PATCH] staging: iio: ad5933: avoid uninitialized variable in error case
On 25/01/16 15:50, Arnd Bergmann wrote: > The ad5933_i2c_read function returns an error code to indicate > whether it could read data or not. However ad5933_work() ignores > this return code and just accesses the data unconditionally, > which gets detected by gcc as a possible bug: > > drivers/staging/iio/impedance-analyzer/ad5933.c: In function 'ad5933_work': > drivers/staging/iio/impedance-analyzer/ad5933.c:649:16: warning: 'status' may > be used uninitialized in this function [-Wmaybe-uninitialized] > > This adds minimal error handling so we only evaluate the > data if it was correctly read. > > Signed-off-by: Arnd Bergmann Hi Arnd, Thanks for the patch. The handling in here is a little fiddly by the look of things. Lars can you take a look at this when you have a minute? At a very high level, it doesn't make sense to fix this instance and not the one in the context of the patch below. See below... > --- > drivers/staging/iio/impedance-analyzer/ad5933.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c > b/drivers/staging/iio/impedance-analyzer/ad5933.c > index 10c43dda0f5a..304bb464e478 100644 > --- a/drivers/staging/iio/impedance-analyzer/ad5933.c > +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c > @@ -647,6 +647,7 @@ static void ad5933_work(struct work_struct *work) > __be16 buf[2]; > int val[2]; > unsigned char status; > + int ret; > > mutex_lock(&indio_dev->mlock); > if (st->state == AD5933_CTRL_INIT_START_FREQ) { > @@ -658,9 +659,9 @@ static void ad5933_work(struct work_struct *work) > return; > } > > - ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status); > + ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status); > > - if (status & AD5933_STAT_DATA_VALID) { > + if (!ret && (status & AD5933_STAT_DATA_VALID)) { The else is non trivial here as it assumes we will get the data later. If we get such a failure, we probably want to drop out completely rather than paper over the gaps.. > int scan_count = bitmap_weight(indio_dev->active_scan_mask, > indio_dev->masklength); Same issue on the next line - this results in known garbage data being spooled out. > ad5933_i2c_read(st->client, >
[PATCH] x86/head64: define early_idt_ripmsg only if CONFIG_KALLSYMS is enabled
We have definition of the early_idt_ripmsg which represents string header for the output of the kernel symbols during early exception. But it will be used only if CONFIG_KALLSYMS is enabled. Signed-off-by: Alexander Kuleshov --- arch/x86/kernel/head_64.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index ffdc0e8..c713d94 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -433,8 +433,10 @@ early_recursion_flag: #ifdef CONFIG_EARLY_PRINTK early_idt_msg: .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n" +#ifdef CONFIG_KALLSYMS early_idt_ripmsg: .asciz "RIP %s\n" +#endif #endif /* CONFIG_EARLY_PRINTK */ #define NEXT_PAGE(name) \ -- 2.7.0.25.gfc10eb5
Re: [PATCH 2/2] sched,time: call __acct_update_integrals once a jiffy
On Fri, Jan 29, 2016 at 05:43:28PM -0500, Rik van Riel wrote: > On 01/29/2016 05:23 PM, r...@redhat.com wrote: > > From: Rik van Riel > > > This speeds up > > ... ok, that changelog got truncated :( > > Here is the full version: > > > Because __acct_update_integrals does nothing unless the time > interval in question exceeds a jiffy, there is no real reason > to call it more than once a jiffy from the syscall, irq, and > guest entry & exit paths. > > If tasks get rescheduled frequently, the scheduler will still > update their time statistics normally. > > However, longer running tasks with frequent syscall, irq, > or guest entry & exit see a difference with this patch. > > A microbenchmark calling an invalid syscall number 10 million > times in a row speeds up an additional 30% over the numbers > with just the previous patch, for a total speedup of about 40% > over 4.4 and 4.5-rc1. > > Run times for the microbenchmark: > > 4.4 3.8 seconds > 4.5-rc1 3.7 seconds > 4.5-rc1 + first patch 3.3 seconds > 4.5-rc1 + both patches 2.3 seconds Very nice improvement!
Re: Build failure: -Wno-unused-const-variable DNE on old GCC
On Thu, 7 Jan 2016, Brian Norris wrote: > > Perhaps most uses of -Werror without some CONFIG_ guard > > should be removed or replaced by some other mechanism. > > +1000. I'd personally like to see all one-off uses of -Werror removed. > > > $ git grep -E "=\s*\-Werror" | grep -v CONFIG > > [...] > > arch/alpha/lib/Makefile:ccflags-y := -Werror > > arch/alpha/mm/Makefile:ccflags-y := -Werror > > arch/alpha/oprofile/Makefile:ccflags-y := -Werror -Wno-sign-compare > > arch/metag/oprofile/Makefile:ccflags-y += -Werror > > arch/mips/Kbuild:subdir-ccflags-y := -Werror > > ^^ I always patch this one out when build-testing MIPS, since I like to > turn up warning levels (e.g., W=1), but not kill the build entirely. The MIPS port switched on -Werror years ago, because people submitted awful code and couldn't be bothered unless the build crashed. You're welcome to patch your own tree, however I maintain it was a very good decision, and TBH I think -Werror should be on globally. Maciej
Re: [PATCH] iio: ade7753: avoid uninitialized data
On 25/01/16 15:52, Arnd Bergmann wrote: > The ade7753_spi_read_reg_16() will either successfully read a value > from SPI, or return a failure code without delivering data. However, > the ade7753_stop_device() and ade7753_reset() functions use the returned > data without checking for an error condition first. Gcc detects this > as a possible bug and warns about it: > > drivers/staging/iio/meter/ade7753.c: In function 'ade7753_remove': > drivers/staging/iio/meter/ade7753.c:348:6: error: 'val' may be used > uninitialized in this function [-Werror=maybe-uninitialized] > val |= BIT(4); /* AD converters can be turned off */ > ^ > drivers/staging/iio/meter/ade7753.c:345:6: note: 'val' was declared here > u16 val; > ^ > drivers/staging/iio/meter/ade7753.c: In function 'ade7753_probe': > drivers/staging/iio/meter/ade7753.c:222:6: error: 'val' may be used > uninitialized in this function [-Werror=maybe-uninitialized] > > In both cases, we can avoids the warning by checking the return code > before using the data. > > Signed-off-by: Arnd Bergmann Thanks. Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > drivers/staging/iio/meter/ade7753.c | 12 ++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/iio/meter/ade7753.c > b/drivers/staging/iio/meter/ade7753.c > index f129039bece3..69287108f793 100644 > --- a/drivers/staging/iio/meter/ade7753.c > +++ b/drivers/staging/iio/meter/ade7753.c > @@ -217,8 +217,12 @@ error_ret: > static int ade7753_reset(struct device *dev) > { > u16 val; > + int ret; > + > + ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val); > + if (ret) > + return ret; > > - ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val); > val |= BIT(6); /* Software Chip Reset */ > > return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val); > @@ -343,8 +347,12 @@ error_ret: > static int ade7753_stop_device(struct device *dev) > { > u16 val; > + int ret; > + > + ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val); > + if (ret) > + return ret; > > - ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val); > val |= BIT(4); /* AD converters can be turned off */ > > return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val); >
[patch] USB: cxacru: fix an bounds check warning
This is a privileged operation so it doesn't matter much. We use "tmp" as an offset into an array. If it were invalid we could read out of bounds and trigger an oops if the memory is not mapped. Plus it makes static checkers complain. Signed-off-by: Dan Carpenter --- This changes the behavior a little bit because in the original we could give slightly invalid "len" values and the function would still work... Please review it extra carefully to make sure it doesn't break userspace. diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index 1173f9c..0a866e9 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c @@ -476,6 +476,8 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev, return -EINVAL; if (index < 0 || index > 0x7f) return -EINVAL; + if (tmp < 0 || tmp > len - pos) + return -EINVAL; pos += tmp; /* skip trailing newline */
[patch] bfa: use strncpy() instead of memcpy()
BFA_MFG_NAME is "QLogic" which is only 7 bytes, but we are copying 8 bytes. It's harmless because the badding byte is likely zero but it makes static checkers complain. Signed-off-by: Dan Carpenter --- Technically the memset() is not needed because strncpy() will pad the rest of the buffer with zeros but I was worried that people would be paranoid. diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c index 251e2ff..a1ada4a 100644 --- a/drivers/scsi/bfa/bfa_ioc.c +++ b/drivers/scsi/bfa/bfa_ioc.c @@ -2803,7 +2803,7 @@ void bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, char *manufacturer) { memset((void *)manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN); - memcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN); + strncpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN); } void
[patch] crypto: keywrap - memzero the correct memory
We're clearing the wrong memory. The memory corruption is likely harmless because we weren't going to use that stack memory again but not zeroing is a potential information leak. Fixes: e28facde3c39 ('crypto: keywrap - add key wrapping block chaining mode') Signed-off-by: Dan Carpenter diff --git a/crypto/keywrap.c b/crypto/keywrap.c index b1d106c..72014f9 100644 --- a/crypto/keywrap.c +++ b/crypto/keywrap.c @@ -212,7 +212,7 @@ static int crypto_kw_decrypt(struct blkcipher_desc *desc, SEMIBSIZE)) ret = -EBADMSG; - memzero_explicit(&block, sizeof(struct crypto_kw_block)); + memzero_explicit(block, sizeof(struct crypto_kw_block)); return ret; } @@ -297,7 +297,7 @@ static int crypto_kw_encrypt(struct blkcipher_desc *desc, /* establish the IV for the caller to pick up */ memcpy(desc->info, block->A, SEMIBSIZE); - memzero_explicit(&block, sizeof(struct crypto_kw_block)); + memzero_explicit(block, sizeof(struct crypto_kw_block)); return 0; }
[patch] staging: rtl8712: memory corruption in wpa_set_encryption()
->KeyMaterial is declared as a 16 byte array, but we only ever allocate either 5 or 13 bytes of it. The problem is that we memset() all 16 bytes to zero so we're memsetting past the end of the allocated memory. I fixed this in slightly lazy way, by just allocating 16 bytes. This works but there is a lot more cleanup you could do to this code if you wanted. Which is why this code is in staging. Signed-off-by: Dan Carpenter diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index edfc680..db2e31bc 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -398,12 +398,9 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, wep_key_idx = 0; if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; - pwep = kmalloc((u32)(wep_key_len + - FIELD_OFFSET(struct NDIS_802_11_WEP, - KeyMaterial)), GFP_ATOMIC); + pwep = kzalloc(sizeof(*pwep), GFP_ATOMIC); if (pwep == NULL) return -ENOMEM; - memset(pwep, 0, sizeof(struct NDIS_802_11_WEP)); pwep->KeyLength = wep_key_len; pwep->Length = wep_key_len + FIELD_OFFSET(struct NDIS_802_11_WEP,
Re: [PATCH 1/4] sched,time: remove non-power-of-two divides from __acct_update_integrals
On Fri, Jan 29, 2016 at 10:36:02PM -0500, r...@redhat.com wrote: > From: Rik van Riel > > When running a microbenchmark calling an invalid syscall number > in a loop, on a nohz_full CPU, we spend a full 9% of our CPU > time in __acct_update_integrals. > > This function converts cputime_t to jiffies, to a timeval, only to > convert the timeval back to microseconds before discarding it. > > This patch leaves __acct_update_integrals functionally equivalent, > but speeds things up by about 12%, with 10 million calls to an > invalid syscall number dropping from 3.7 to 3.25 seconds. > > Signed-off-by: Rik van Riel > --- > kernel/tsacct.c | 19 +-- > 1 file changed, 9 insertions(+), 10 deletions(-) > > diff --git a/kernel/tsacct.c b/kernel/tsacct.c > index 975cb49e32bf..41667b23dbd0 100644 > --- a/kernel/tsacct.c > +++ b/kernel/tsacct.c > @@ -93,9 +93,9 @@ void xacct_add_tsk(struct taskstats *stats, struct > task_struct *p) > { > struct mm_struct *mm; > > - /* convert pages-usec to Mbyte-usec */ > - stats->coremem = p->acct_rss_mem1 * PAGE_SIZE / MB; > - stats->virtmem = p->acct_vm_mem1 * PAGE_SIZE / MB; > + /* convert pages-nsec/KB to Mbyte-usec, see __acct_update_integrals */ > + stats->coremem = p->acct_rss_mem1 * PAGE_SIZE / (1000 * KB); > + stats->virtmem = p->acct_vm_mem1 * PAGE_SIZE / (1000 * KB); > mm = get_task_mm(p); > if (mm) { > /* adjust to KB unit */ > @@ -125,22 +125,21 @@ static void __acct_update_integrals(struct task_struct > *tsk, > { > if (likely(tsk->mm)) { > cputime_t time, dtime; > - struct timeval value; > unsigned long flags; > u64 delta; > > local_irq_save(flags); > time = stime + utime; > dtime = time - tsk->acct_timexpd; > - jiffies_to_timeval(cputime_to_jiffies(dtime), &value); > - delta = value.tv_sec; > - delta = delta * USEC_PER_SEC + value.tv_usec; > + delta = cputime_to_nsecs(dtime); You might want to add a comment specifying why we don't call cputime_to_usecs() directly (because we optimize if delta < TICK_NSEC). Although this has a good impact on nohz_full, it might have a tiny bad one on !nohz_full because now we first convert jiffies to nsecs (which implies a multiplication by 1000) that we later divide again by 1000. Now this is ok because I plan to convert tsk->utime/stime to nsecs and thus remove most of the cputime_t use and conversions everywhere. > > - if (delta == 0) > + if (delta < TICK_NSEC) > goto out; > + > tsk->acct_timexpd = time; > - tsk->acct_rss_mem1 += delta * get_mm_rss(tsk->mm); > - tsk->acct_vm_mem1 += delta * tsk->mm->total_vm; > + /* The final unit will be Mbyte-usecs, see xacct_add_tsk */ > + tsk->acct_rss_mem1 += delta * get_mm_rss(tsk->mm) / 1024; > + tsk->acct_vm_mem1 += delta * tsk->mm->total_vm / 1024; The use of 1024 and the change on MB above are confusing me. Why are we doing that? Thanks. > out: > local_irq_restore(flags); > } > -- > 2.5.0 >