RE: powerpc/corenet: enable eSDHC
Hi Scott, Now the patch below has been merged on git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git. This issue should have been resolved. Thanks. commit 5fd26c7ecb32082745b0bd33c8e35badd1cb5a91 Author: Ulf Hansson ulf.hans...@linaro.org Date: Fri Jun 5 11:40:08 2015 +0200 mmc: sdhci: Restore behavior while creating OCR mask -Original Message- From: Wood Scott-B07421 Sent: Tuesday, June 09, 2015 4:31 AM To: Lu Yangbo-B47093 Cc: linuxppc-dev@lists.ozlabs.org; linux-...@vger.kernel.org Subject: Re: powerpc/corenet: enable eSDHC On Mon, 2015-06-08 at 05:12 -0500, Lu Yangbo-B47093 wrote: Thanks a lot, Scott. And now a patch was merged on git://git.linaro.org/people/ulf.hansson/mmc.git next branch to fix this issue. It should be no problem. Assuming that patch fixes it and gets pulled for 4.2, this config patch can go in for 4.3. That said, it would be nice if, apart from fixing the problem itself, the MMC code failed more gracefully instead of endlessly repeating and filling up the log/console. -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v4 0/6] powernv: cpufreq: Report frequency throttle by OCC
On 13-07-15, 19:39, Shilpasri G Bhat wrote: This patchset intends to add frequency throttle reporting mechanism to powernv-cpufreq driver when OCC throttles the frequency. OCC is an On-Chip-Controller which takes care of the power and thermal safety of the chip. The CPU frequency can be throttled during an OCC reset or when OCC tries to limit the max allowed frequency. The patchset will report such conditions so as to keep the user informed about reason for the drop in performance of workloads when frequency is throttled. Changes from v3: - Rebased on top of 4.2-rc1 - Minor changes in patch 2,3,4,6 this does not change the functionality of the code - 594fcb9ec9e powerpc/powernv: Expose OPAL APIs required by PRD interface , this patch fixes the build error due to which this series was initially dropped ERROR: .opal_message_notifier_register drivers/cpufreq/powernv-cpufreq.ko] undefined! I have already Acked v3 of this and that applies to this one as well.. -- viresh ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 6/6] cputime: Introduce cputime_to_timespec64()/timespec64_to_cputime()
On 15 July 2015 at 19:55, Thomas Gleixner t...@linutronix.de wrote: On Wed, 15 Jul 2015, Baolin Wang wrote: On 15 July 2015 at 18:31, Thomas Gleixner t...@linutronix.de wrote: On Wed, 15 Jul 2015, Baolin Wang wrote: The cputime_to_timespec() and timespec_to_cputime() functions are not year 2038 safe on 32bit systems due to that the struct timepsec will overflow in 2038 year. And how is this relevant? cputime is not based on wall clock time at all. So what has 2038 to do with cputime? We want proper explanations WHY we need such a change. When converting the posix-cpu-timers, it call the cputime_to_timespec() function. Thus it need a conversion for this function. There is no requirement to convert posix-cpu-timers on their own. We need to adopt the posix cpu timers code because it shares syscalls with the other posix timers, but that still does not explain why we need these functions. In posix-cpu-timers, it also defined some 'k_clock struct' variables, and we need to convert the callbacks of the 'k_clock struct' which are not year 2038 safe on 32bit systems. Some callbacks which need to convert call the cputime_to_timespec() function, thus we also want to convert the cputime_to_timespec() function to a year 2038 safe function to make all them ready for the year 2038 issue. You can see that conversion in patch posix-cpu-timers: Convert to y2038 safe callbacks from https://git.linaro.org/people/baolin.wang/upstream_0627.git. I do not care about your random git tree. I care about proper changelogs. Your changelogs are just a copied boilerplate full of errors. Thanks, tglx -- Baolin.wang Best Regards ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [3/3] IRQ: Print unexpected IRQ messages consistently across architectures
On Mon, 2015-07-13 at 13:35 -0500, Bjorn Helgaas wrote: On Sun, Jul 12, 2015 at 10:23 PM, Michael Ellerman m...@ellerman.id.au wrote: On Sun, 2015-12-07 at 22:02:11 UTC, Bjorn Helgaas wrote: Many architectures use a variant of unexpected IRQ trap at vector %x to log unexpected IRQs. This is confusing because (a) it prints the Linux IRQ number, but vector more often refers to a CPU vector number, and (b) it prints the IRQ number in hex with no base indication, while Linux IRQ numbers are usually printed in decimal. Print the same text (unexpected IRQ %d) across all architectures. No functional change other than the output text. There's already a fallback version in asm-generic, so shouldn't you instead just delete all the versions that are identical to that? eg. on powerpc we have: static inline void ack_bad_irq(unsigned int irq) { - printk(KERN_CRIT unexpected IRQ trap at vector %02x\n, irq); + printk(KERN_CRIT unexpected IRQ %d\n, irq); } And the generic version is: #ifndef ack_bad_irq static inline void ack_bad_irq(unsigned int irq) { - printk(KERN_CRIT unexpected IRQ trap at vector %02x\n, irq); + printk(KERN_CRIT unexpected IRQ %d\n, irq); } #endif So we can just delete the powerpc version? Wow, I really didn't do my homework here. Not only is there a generic version already, but there's also print_irq_desc(), which prints way more information than any of the ack_bad_irq() implementations. Even better :) I'll try again :) Thanks. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH v2] powerpc/dts: Add and fix 1588 timer node for eTSEC
Any comments? Thanks. -Original Message- From: Yangbo Lu [mailto:yangbo...@freescale.com] Sent: Thursday, May 07, 2015 11:29 AM To: linuxppc-dev@lists.ozlabs.org; linux-ker...@vger.kernel.org; Wood Scott-B07421 Cc: Lu Yangbo-B47093 Subject: [PATCH v2] powerpc/dts: Add and fix 1588 timer node for eTSEC Add 1588 timer node in files: arch/powerpc/boot/dts/bsc9131rdb.dtsi arch/powerpc/boot/dts/bsc9132qds.dtsi arch/powerpc/boot/dts/p1010rdb.dtsi arch/powerpc/boot/dts/p1020rdb-pd.dts arch/powerpc/boot/dts/p1021rdb-pc.dtsi arch/powerpc/boot/dts/p1022ds.dtsi arch/powerpc/boot/dts/p1025twr.dtsi Fix 1588 timer node in file: arch/powerpc/boot/dts/p2020rdb-pc.dtsi Signed-off-by: Yangbo Lu yangbo...@freescale.com --- Changes for v2: - Changed hex value to decimal value in dts - Modified commit message - Modified 1588 node in p2020rdb-pc.dtsi --- arch/powerpc/boot/dts/bsc9131rdb.dtsi | 12 arch/powerpc/boot/dts/bsc9132qds.dtsi | 12 arch/powerpc/boot/dts/p1010rdb.dtsi| 12 arch/powerpc/boot/dts/p1020rdb-pd.dts | 12 arch/powerpc/boot/dts/p1021rdb-pc.dtsi | 12 arch/powerpc/boot/dts/p1022ds.dtsi | 12 arch/powerpc/boot/dts/p1025twr.dtsi| 12 arch/powerpc/boot/dts/p2020rdb-pc.dtsi | 12 ++-- 8 files changed, 90 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/boot/dts/bsc9131rdb.dtsi b/arch/powerpc/boot/dts/bsc9131rdb.dtsi index 45efcba..a6d533e 100644 --- a/arch/powerpc/boot/dts/bsc9131rdb.dtsi +++ b/arch/powerpc/boot/dts/bsc9131rdb.dtsi @@ -80,6 +80,18 @@ status = disabled; }; + ptp_clock@b0e00 { + compatible = fsl,etsec-ptp; + reg = 0xb0e00 0xb0; + interrupts = 68 2 0 0 69 2 0 0; + fsl,tclk-period = 5; + fsl,tmr-prsc= 2; + fsl,tmr-add = 3435973837; + fsl,tmr-fiper1 = 5; + fsl,tmr-fiper2 = 0; + fsl,max-adj = 24999; + }; + enet0: ethernet@b { phy-handle = phy0; phy-connection-type = rgmii-id; diff --git a/arch/powerpc/boot/dts/bsc9132qds.dtsi b/arch/powerpc/boot/dts/bsc9132qds.dtsi index af8e888..ef75804 100644 --- a/arch/powerpc/boot/dts/bsc9132qds.dtsi +++ b/arch/powerpc/boot/dts/bsc9132qds.dtsi @@ -87,6 +87,18 @@ }; }; + ptp_clock@b0e00 { + compatible = fsl,etsec-ptp; + reg = 0xb0e00 0xb0; + interrupts = 68 2 0 0 69 2 0 0; + fsl,tclk-period = 5; + fsl,tmr-prsc= 2; + fsl,tmr-add = 3435973837; + fsl,tmr-fiper1 = 5; + fsl,tmr-fiper2 = 0; + fsl,max-adj = 24999; + }; + enet0: ethernet@b { phy-handle = phy0; tbi-handle = tbi0; diff --git a/arch/powerpc/boot/dts/p1010rdb.dtsi b/arch/powerpc/boot/dts/p1010rdb.dtsi index ea534ef..1613678 100644 --- a/arch/powerpc/boot/dts/p1010rdb.dtsi +++ b/arch/powerpc/boot/dts/p1010rdb.dtsi @@ -186,6 +186,18 @@ }; }; + ptp_clock@b0e00 { + compatible = fsl,etsec-ptp; + reg = 0xb0e00 0xb0; + interrupts = 68 2 0 0 69 2 0 0; + fsl,tclk-period = 10; + fsl,tmr-prsc= 2; + fsl,tmr-add = 2147483670; + fsl,tmr-fiper1 = 0; + fsl,tmr-fiper2 = 0; + fsl,max-adj = 1; + }; + enet0: ethernet@b { phy-handle = phy0; phy-connection-type = rgmii-id; diff --git a/arch/powerpc/boot/dts/p1020rdb-pd.dts b/arch/powerpc/boot/dts/p1020rdb-pd.dts index 987017e..52e8fe8 100644 --- a/arch/powerpc/boot/dts/p1020rdb-pd.dts +++ b/arch/powerpc/boot/dts/p1020rdb-pd.dts @@ -225,6 +225,18 @@ }; }; + ptp_clock@b0e00 { + compatible = fsl,etsec-ptp; + reg = 0xb0e00 0xb0; + interrupts = 68 2 0 0 69 2 0 0; + fsl,tclk-period = 10; + fsl,tmr-prsc= 2; + fsl,tmr-add = 2147483670; + fsl,tmr-fiper1 = 0; + fsl,tmr-fiper2 = 0; + fsl,max-adj = 1; + }; + enet0: ethernet@b { fixed-link = 1 1 1000 0 0; phy-connection-type = rgmii-id; diff --git a/arch/powerpc/boot/dts/p1021rdb-pc.dtsi b/arch/powerpc/boot/dts/p1021rdb-pc.dtsi index d6274c5..a29c84a 100644 --- a/arch/powerpc/boot/dts/p1021rdb-pc.dtsi +++ b/arch/powerpc/boot/dts/p1021rdb-pc.dtsi @@ -224,6 +224,18 @@ }; }; + ptp_clock@b0e00 { +
Re: [RFC PATCH 11/12] selftests/seccomp: Make seccomp tests work on big endian
On Wed, 2015-07-15 at 08:16 -0700, Kees Cook wrote: On Wed, Jul 15, 2015 at 12:37 AM, Michael Ellerman m...@ellerman.id.au wrote: diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index b2374c131340..51adb9afb511 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -82,7 +82,13 @@ struct seccomp_data { }; #endif +#if __BYTE_ORDER == __LITTLE_ENDIAN #define syscall_arg(_n) (offsetof(struct seccomp_data, args[_n])) +#elif __BYTE_ORDER == __BIG_ENDIAN +#define syscall_arg(_n) (offsetof(struct seccomp_data, args[_n]) + sizeof(__u32)) +#else +#error wut? +#endif Ah-ha! Yes, thanks. Could you change the #error to something that describes the particular (impossible) failure condition? wut? Unknown __BYTE_ORDER?!. Not a huge deal, but I always like verbose errors. :) Especially for impossible situations. :) Yeah sorry that was a quick hack which got promoted into an actual patch. Fixed to use your message. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [patch 00/20] powerpc: Interrupt cleanups and API change preparation
On Mon, 2015-07-13 at 20:50 +, Thomas Gleixner wrote: The following patch series contains the following changes: - Consolidation of chained interrupt handler setup/removal - Switch to functions which avoid a redundant interrupt descriptor lookup - Preparation of interrupt flow handlers for the 'irq' argument removal The series has no dependencies ... But I assume you have work that will depend on it? So you're going to merge it via your tree at least I assume? ... and is also available as a git branch for your convenience: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/arm I can't find this. Did you mean irq/ppc or irq/powerpc maybe? I can't find those either. If you want me to carry the patches in the irq/core branch of tip, please let me know. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH net-next] ibmveth: add support for TSO6
From: Thomas Falcon tlfal...@linux.vnet.ibm.com Date: Tue, 14 Jul 2015 10:51:51 -0500 This patch adds support for a new method of signalling the firmware that TSO packets are being sent. The new method removes the need to alter the ip and tcp checksums and allows TSO6 support. Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com Applied. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 09/12] powerpc/kernel: Add SIG_SYS support for compat tasks
On Wed, 2015-07-15 at 08:12 -0700, Kees Cook wrote: On Wed, Jul 15, 2015 at 12:37 AM, Michael Ellerman m...@ellerman.id.au wrote: diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index c5abe7fd7590..b2374c131340 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -645,6 +645,10 @@ static struct siginfo TRAP_info; static volatile int TRAP_nr; static void TRAP_action(int nr, siginfo_t *info, void *void_context) { + fprintf(stderr, in TRAP_action\n); + fprintf(stderr, info-si_call_addr %p\n, info-si_call_addr); + fprintf(stderr, info-si_syscall %u\n, info-si_syscall); + fprintf(stderr, info-si_arch %u\n, info-si_arch); memcpy(TRAP_info, info, sizeof(TRAP_info)); TRAP_nr = nr; } This chunk looks like left-over debugging? Urgh yep, that's ugly. Thanks for noticing. Will remove before merging :) cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RESEND,v3] powerpc/pseries: Limit EPOW reset event warnings
On Wed, 2015-15-07 at 04:22:06 UTC, Kamalesh Babulal wrote: Kernel prints respective warnings about various EPOW events for user information/action after parsing EPOW interrupts.Prompting user to take action depending upon the severity of the event. At times EPOW reset event warning, such as below could flood kernel log, over a period of time. May 25 03:46:34 alp kernel: Non critical power or cooling issue cleared May 25 03:46:52 alp kernel: Non critical power or cooling issue cleared May 25 03:53:48 alp kernel: Non critical power or cooling issue cleared May 25 03:55:46 alp kernel: Non critical power or cooling issue cleared May 25 03:56:34 alp kernel: Non critical power or cooling issue cleared May 25 03:59:04 alp kernel: Non critical power or cooling issue cleared May 25 04:02:01 alp kernel: Non critical power or cooling issue cleared May 25 04:04:24 alp kernel: Non critical power or cooling issue cleared May 25 04:07:18 alp kernel: Non critical power or cooling issue cleared May 25 04:13:04 alp kernel: Non critical power or cooling issue cleared May 25 04:22:04 alp kernel: Non critical power or cooling issue cleared May 25 04:22:26 alp kernel: Non critical power or cooling issue cleared May 25 04:22:36 alp kernel: Non critical power or cooling issue cleared This patch avoids these multiple EPOW reset warnings by using a boolean flag. This flag is initialized to false and is set to true upon arrival of EPOW event. This same flag is checked and reset during EPOW_RESET scenario to filter out valid EPOW reset events and avoid multiple warning logs. Why are we even getting these reset events when nothing has happened? Also, merged adjacent pr_err/pr_emerg into single one to reduce the number of lines printed per warning. Suggested-by: Vipin K Parashar vi...@linux.vnet.ibm.com [Vipin: edited the changelog] Cc: Anshuman Khandual khand...@linux.vnet.ibm.com Cc: Anton Blanchard an...@samba.org Cc: Michael Ellerman m...@ellerman.id.au Signed-off-by: Kamalesh Babulal kamal...@linux.vnet.ibm.com --- v3 Changes: - Limit warning printed by EPOW RESET event, by guarding it with bool flag. Instead of rate limiting all the EPOW events. v2 Changes: - Merged multiple adjacent pr_err/pr_emerg into single line to reduce multi-line warnings, based on Michael's comments. arch/powerpc/platforms/pseries/ras.c | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c index 02e4a17..b30396a 100644 --- a/arch/powerpc/platforms/pseries/ras.c +++ b/arch/powerpc/platforms/pseries/ras.c @@ -40,6 +40,9 @@ static int ras_check_exception_token; #define EPOW_SENSOR_TOKEN9 #define EPOW_SENSOR_INDEX0 +/* Flag to limit EPOW RESET warning. */ +static bool epow_state; This name is terrible, it doesn't give me any hint to what it means. But really it should be a counter, not a boolean. We could have multiple EPOW events come in and then later get the reset events for them, couldn't we? So what about: static unsigned epow_event_depth; And then below: @@ -145,21 +148,27 @@ static void rtas_parse_epow_errlog(struct rtas_error_log *log) epow_event_depth++; switch (action_code) { case EPOW_RESET: if (epow_event_depth) epow_event_depth--; if (epow_event_depth) + pr_err(Non critical power or cooling issue cleared); break; And that's all you need. case EPOW_WARN_COOLING: - pr_err(Non critical cooling issue reported by firmware); - pr_err(Check RTAS error log for details); + pr_err(Non critical cooling issue reported by firmware, +Check RTAS error log for details); This should be: pr_err(Non-critical cooling issue reported by firmware, check RTAS error log for details.\n); But that's too long, so how about: pr_err(Non-critical cooling issue reported, check RTAS error log for details.\n); And if it's non-critical it shouldn't be pr_err(), it should be pr_info(). Similarly for all the other messages. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RFC PATCH 03/12] powerpc/kernel: Change the do_syscall_trace_enter() API
The API for calling do_syscall_trace_enter() is currently sensible enough, it just returns the (modified) syscall number. However once we enable seccomp filter it will get more complicated. When seccomp filter runs, the seccomp kernel code (via SECCOMP_RET_ERRNO), or a ptracer (via SECCOMP_RET_TRACE), may reject the syscall and *may* or may *not* set a return value in r3. That means the assembler that calls do_syscall_trace_enter() can not blindly return ENOSYS, it needs to only return ENOSYS if a return value has not already been set. There is no way to implement that logic with the current API. So change the do_syscall_trace_enter() API to make it deal with the return code juggling, and the assembler can then just return whatever return code it is given. Signed-off-by: Michael Ellerman m...@ellerman.id.au --- arch/powerpc/kernel/entry_32.S | 4 arch/powerpc/kernel/entry_64.S | 23 ++-- arch/powerpc/kernel/ptrace.c | 48 -- 3 files changed, 58 insertions(+), 17 deletions(-) diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S index 67ecdf61f4e3..2405631e91a2 100644 --- a/arch/powerpc/kernel/entry_32.S +++ b/arch/powerpc/kernel/entry_32.S @@ -458,6 +458,10 @@ syscall_dotrace: lwz r7,GPR7(r1) lwz r8,GPR8(r1) REST_NVGPRS(r1) + + cmplwi r0,NR_syscalls + /* Return code is already in r3 thanks to do_syscall_trace_enter() */ + bge-ret_from_syscall b syscall_dotrace_cont syscall_exit_work: diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index 8292581a42f1..41f8fcf615d7 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S @@ -151,8 +151,7 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR) CURRENT_THREAD_INFO(r11, r1) ld r10,TI_FLAGS(r11) andi. r11,r10,_TIF_SYSCALL_DOTRACE - bne syscall_dotrace -.Lsyscall_dotrace_cont: + bne syscall_dotrace /* does not return */ cmpldi 0,r0,NR_syscalls bge-syscall_enosys @@ -248,22 +247,34 @@ syscall_dotrace: /* Get pt_regs into r3 */ mr r3, r9 bl do_syscall_trace_enter + /* -* Restore argument registers possibly just changed. -* We use the return value of do_syscall_trace_enter -* for the call number to look up in the table (r0). +* We use the return value of do_syscall_trace_enter() as the syscall +* number. If the syscall was rejected for any reason do_syscall_trace_enter() +* returns an invalid syscall number and the test below against +* NR_syscalls will fail. */ mr r0,r3 + + /* Restore argument registers just clobbered and/or possibly changed. */ ld r3,GPR3(r1) ld r4,GPR4(r1) ld r5,GPR5(r1) ld r6,GPR6(r1) ld r7,GPR7(r1) ld r8,GPR8(r1) + + /* Repopulate r9 and r10 for the system_call path */ addir9,r1,STACK_FRAME_OVERHEAD CURRENT_THREAD_INFO(r10, r1) ld r10,TI_FLAGS(r10) - b .Lsyscall_dotrace_cont + + cmpldi r0,NR_syscalls + blt+system_call + + /* Return code is already in r3 thanks to do_syscall_trace_enter() */ + b .Lsyscall_exit + syscall_enosys: li r3,-ENOSYS diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index f21897b42057..7484221bb3f8 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -1762,26 +1762,42 @@ long arch_ptrace(struct task_struct *child, long request, return ret; } -/* - * We must return the syscall number to actually look up in the table. - * This can be -1L to skip running any syscall at all. +/** + * do_syscall_trace_enter() - Do syscall tracing on kernel entry. + * @regs: the pt_regs of the task to trace (current) + * + * Performs various types of tracing on syscall entry. This includes seccomp, + * ptrace, syscall tracepoints and audit. + * + * The pt_regs are potentially visible to userspace via ptrace, so their + * contents is ABI. + * + * One or more of the tracers may modify the contents of pt_regs, in particular + * to modify arguments or even the syscall number itself. + * + * It's also possible that a tracer can choose to reject the system call. In + * that case this function will return an illegal syscall number, and will put + * an appropriate return value in regs-r3. + * + * Return: the (possibly changed) syscall number. */ long do_syscall_trace_enter(struct pt_regs *regs) { - long ret = 0; + bool abort = false; user_exit(); secure_computing_strict(regs-gpr[0]); - if (test_thread_flag(TIF_SYSCALL_TRACE) - tracehook_report_syscall_entry(regs)) + if (test_thread_flag(TIF_SYSCALL_TRACE)) { /* -
[RFC PATCH 05/12] powerpc: Don't negate error in syscall_set_return_value()
Currently the only caller of syscall_set_return_value() is seccomp filter, which is not enabled on powerpc. This means we have not noticed that our implementation of syscall_set_return_value() negates error, even though the value passed in is already negative. So remove the negation in syscall_set_return_value(), and expect the caller to do it like all other implementations do. Also add a comment about the ccr handling. Signed-off-by: Michael Ellerman m...@ellerman.id.au --- arch/powerpc/include/asm/syscall.h | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h index c6239dabcfb1..cabe90133e69 100644 --- a/arch/powerpc/include/asm/syscall.h +++ b/arch/powerpc/include/asm/syscall.h @@ -44,9 +44,15 @@ static inline void syscall_set_return_value(struct task_struct *task, struct pt_regs *regs, int error, long val) { + /* +* In the general case it's not obvious that we must deal with CCR +* here, as the syscall exit path will also do that for us. However +* there are some places, eg. the signal code, which check ccr to +* decide if the value in r3 is actually an error. +*/ if (error) { regs-ccr |= 0x1000L; - regs-gpr[3] = -error; + regs-gpr[3] = error; } else { regs-ccr = ~0x1000L; regs-gpr[3] = val; -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RFC PATCH 11/12] selftests/seccomp: Make seccomp tests work on big endian
The seccomp_bpf test uses BPF_LD|BPF_W|BPF_ABS to load 32-bit values from seccomp_data-args. On big endian machines this will load the high word of the argument, which is not what the test wants. Borrow a hack from samples/seccomp/bpf-helper.h which changes the offset on big endian to account for this. Signed-off-by: Michael Ellerman m...@ellerman.id.au --- tools/testing/selftests/seccomp/seccomp_bpf.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index b2374c131340..51adb9afb511 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -82,7 +82,13 @@ struct seccomp_data { }; #endif +#if __BYTE_ORDER == __LITTLE_ENDIAN #define syscall_arg(_n) (offsetof(struct seccomp_data, args[_n])) +#elif __BYTE_ORDER == __BIG_ENDIAN +#define syscall_arg(_n) (offsetof(struct seccomp_data, args[_n]) + sizeof(__u32)) +#else +#error wut? +#endif #define SIBLING_EXIT_UNKILLED 0xbadbeef #define SIBLING_EXIT_FAILURE 0xbadface -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RFC PATCH 10/12] powerpc/kernel: Enable seccomp filter
This commit enables seccomp filter on powerpc, now that we have all the necessary pieces in place. To support seccomp's desire to modify the syscall return value under some circumstances, we use a different ABI to the ptrace ABI. That is we use r3 as the syscall return value, and orig_gpr3 is the first syscall parameter. This means the seccomp code, or a ptracer via SECCOMP_RET_TRACE, will see -ENOSYS preloaded in r3. This is identical to the behaviour on x86, and allows seccomp or the ptracer to either leave the -ENOSYS or change it to something else, as well as rejecting or not the syscall by modifying r0. If seccomp does not reject the syscall, we restore the register state to match what ptrace and audit expect, ie. r3 is the first syscall parameter again. We do this restore using orig_gpr3, which may have been modified by seccomp, which allows seccomp to modify the first syscall paramater and allow the syscall to proceed. Signed-off-by: Michael Ellerman m...@ellerman.id.au --- arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/ptrace.c | 28 +++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 5ef27113b898..b6cb6a87b7a2 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -155,6 +155,7 @@ config PPC select HAVE_PERF_EVENTS_NMI if PPC64 select EDAC_SUPPORT select EDAC_ATOMIC_SCRUB + select HAVE_ARCH_SECCOMP_FILTER config GENERIC_CSUM def_bool CPU_LITTLE_ENDIAN diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 7484221bb3f8..de79eb5218c6 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -1787,7 +1787,33 @@ long do_syscall_trace_enter(struct pt_regs *regs) user_exit(); - secure_computing_strict(regs-gpr[0]); + if (test_thread_flag(TIF_SECCOMP)) { + /* +* The ABI we present to seccomp tracers is that r3 contains +* the syscall return value and orig_gpr3 contains the first +* syscall parameter. This is different to the ptrace ABI where +* both r3 and orig_gpr3 contain the first syscall parameter. +*/ + regs-gpr[3] = -ENOSYS; + + /* +* We use the __ version here because we have already checked +* TIF_SECCOMP. If this fails, there is nothing left to do, we +* have already loaded -ENOSYS into r3, or seccomp has put +* something else in r3 (via SECCOMP_RET_ERRNO/TRACE). +*/ + if (__secure_computing()) + return -1; + + /* +* The syscall was allowed by seccomp, restore the register +* state to what ptrace and audit expect. +* Note that we use orig_gpr3, which means a seccomp tracer can +* modify the first syscall parameter (in orig_gpr3) and also +* allow the syscall to proceed. +*/ + regs-gpr[3] = regs-orig_gpr3; + } if (test_thread_flag(TIF_SYSCALL_TRACE)) { /* -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RFC PATCH 08/12] powerpc: Change syscall_get_nr() to return int
The documentation for syscall_get_nr() in asm-generic says: Note this returns int even on 64-bit machines. Only 32 bits of system call number can be meaningful. If the actual arch value is 64 bits, this truncates to 32 bits so 0x means -1. However our implementation was never updated to reflect this. Generally it's not important, but there is once case where it matters. For seccomp filter with SECCOMP_RET_TRACE, the tracer will set regs-gpr[0] to -1 to reject the syscall. When the task is a compat task, this means we end up with 0x in r0 because ptrace will zero extend the 32-bit value. If syscall_get_nr() returns an unsigned long, then a 64-bit kernel will see a positive value in r0 and will incorrectly allow the syscall through seccomp. Signed-off-by: Michael Ellerman m...@ellerman.id.au --- arch/powerpc/include/asm/syscall.h | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h index 8d79a87c0511..ab9f3f0a8637 100644 --- a/arch/powerpc/include/asm/syscall.h +++ b/arch/powerpc/include/asm/syscall.h @@ -22,10 +22,15 @@ extern const unsigned long sys_call_table[]; #endif /* CONFIG_FTRACE_SYSCALLS */ -static inline long syscall_get_nr(struct task_struct *task, - struct pt_regs *regs) +static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs) { - return TRAP(regs) == 0xc00 ? regs-gpr[0] : -1L; + /* +* Note that we are returning an int here. That means 0x, ie. +* 32-bit negative 1, will be interpreted as -1 on a 64-bit kernel. +* This is important for seccomp so that compat tasks can set r0 = -1 +* to reject the syscall. +*/ + return TRAP(regs) == 0xc00 ? regs-gpr[0] : -1; } static inline void syscall_rollback(struct task_struct *task, -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RFC PATCH 07/12] powerpc: Use orig_gpr3 in syscall_get_arguments()
Currently syscall_get_arguments() is used by syscall tracepoints, and collect_syscall() which is used in some debugging as well as /proc/pid/syscall. The current implementation just copies regs-gpr[3 .. 5] out, which is fine for all the current use cases. When we enable seccomp filter, that will also start using syscall_get_arguments(). However for seccomp filter we want to use r3 as the return value of the syscall, and orig_gpr3 as the first parameter. This will allow seccomp to modify the return value in r3. To support this we need to modify syscall_get_arguments() to return orig_gpr3 instead of r3. This is safe for all uses because orig_gpr3 always contains the r3 value that was passed to the syscall. We store it in the syscall entry path and never modify it. Update syscall_set_arguments() while we're here, even though it's never used. Signed-off-by: Michael Ellerman m...@ellerman.id.au --- arch/powerpc/include/asm/syscall.h | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h index 403e2303fe18..8d79a87c0511 100644 --- a/arch/powerpc/include/asm/syscall.h +++ b/arch/powerpc/include/asm/syscall.h @@ -64,7 +64,7 @@ static inline void syscall_get_arguments(struct task_struct *task, unsigned int i, unsigned int n, unsigned long *args) { - unsigned long mask = -1UL; + unsigned long val, mask = -1UL; BUG_ON(i + n 6); @@ -72,8 +72,14 @@ static inline void syscall_get_arguments(struct task_struct *task, if (test_tsk_thread_flag(task, TIF_32BIT)) mask = 0x; #endif - while (n--) - args[n] = regs-gpr[3 + i + n] mask; + while (n--) { + if (n == 0 i == 0) + val = regs-orig_gpr3; + else + val = regs-gpr[3 + i + n]; + + args[n] = val mask; + } } static inline void syscall_set_arguments(struct task_struct *task, @@ -83,6 +89,10 @@ static inline void syscall_set_arguments(struct task_struct *task, { BUG_ON(i + n 6); memcpy(regs-gpr[3 + i], args, n * sizeof(args[0])); + + /* Also copy the first argument into orig_gpr3 */ + if (i == 0 n 0) + regs-orig_gpr3 = args[0]; } static inline int syscall_get_arch(void) -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH][v2] powerpc/fsl-booke: Add T1040D4RDB/T1042D4RDB board support
T1040D4RDB/T1042D4RDB are Freescale Reference Design Board which can support T1040/T1042 QorIQ Power Architecture™ processor respectively T1040D4RDB/T1042D4RDB board Overview - - SERDES Connections, 8 lanes supporting: - PCI - SGMII - SATA 2.0 - QSGMII(only for T1040D4RDB) - DDR Controller - Supports rates of up to 1600 MHz data-rate - Supports one DDR4 UDIMM -IFC/Local Bus - NAND flash: 1GB 8-bit NAND flash - NOR: 128MB 16-bit NOR Flash - Ethernet - Two on-board RGMII 10/100/1G ethernet ports. - PHY #0 remains powered up during deep-sleep - CPLD - Clocks - System and DDR clock (SYSCLK, “DDRCLK”) - SERDES clocks - Power Supplies - USB - Supports two USB 2.0 ports with integrated PHYs - Two type A ports with 5V@1.5A per port. - SDHC - SDHC/SDXC connector - SPI - On-board 64MB SPI flash - I2C - Devices connected: EEPROM, thermal monitor, VID controller - Other IO - Two Serial ports - ProfiBus port Add support for T1040/T1042D4RDB board: -add device tree -Add entry in corenet_generic.c Signed-off-by: Priyanka Jain priyanka.j...@freescale.com --- Changes for v2: Incorporated Scott's comments on device tree arch/powerpc/boot/dts/t1040d4rdb.dts | 46 ++ arch/powerpc/boot/dts/t1042d4rdb.dts | 53 +++ arch/powerpc/boot/dts/t104xd4rdb.dtsi | 196 + arch/powerpc/platforms/85xx/corenet_generic.c |2 + 4 files changed, 297 insertions(+), 0 deletions(-) create mode 100644 arch/powerpc/boot/dts/t1040d4rdb.dts create mode 100644 arch/powerpc/boot/dts/t1042d4rdb.dts create mode 100644 arch/powerpc/boot/dts/t104xd4rdb.dtsi diff --git a/arch/powerpc/boot/dts/t1040d4rdb.dts b/arch/powerpc/boot/dts/t1040d4rdb.dts new file mode 100644 index 000..2d1315a --- /dev/null +++ b/arch/powerpc/boot/dts/t1040d4rdb.dts @@ -0,0 +1,46 @@ +/* + * T1040D4RDB Device Tree Source + * + * Copyright 2015 Freescale Semiconductor Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Freescale Semiconductor nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License (GPL) as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor AS IS AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/include/ fsl/t104xsi-pre.dtsi +/include/ t104xd4rdb.dtsi + +/ { + model = fsl,T1040D4RDB; + compatible = fsl,T1040D4RDB; + #address-cells = 2; + #size-cells = 2; + interrupt-parent = mpic; +}; + +/include/ fsl/t1040si-post.dtsi diff --git a/arch/powerpc/boot/dts/t1042d4rdb.dts b/arch/powerpc/boot/dts/t1042d4rdb.dts new file mode 100644 index 000..846f8c8 --- /dev/null +++ b/arch/powerpc/boot/dts/t1042d4rdb.dts @@ -0,0 +1,53 @@ +/* + * T1042D4RDB Device Tree Source + * + * Copyright 2015 Freescale Semiconductor Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided
[PATCH v2 2/3] KVM: PPC: Book3S HV: Use need_resched() instead of should_resched()
Function should_resched() is equal to (!preempt_count() need_resched()). In preemptive kernel preempt_count here is non-zero because of vc-lock. Signed-off-by: Konstantin Khlebnikov khlebni...@yandex-team.ru --- arch/powerpc/kvm/book3s_hv.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 68d067ad4222..a9f753fb73a8 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -2178,7 +2178,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) vc-runner = vcpu; if (n_ceded == vc-n_runnable) { kvmppc_vcore_blocked(vc); - } else if (should_resched()) { + } else if (need_resched()) { vc-vcore_state = VCORE_PREEMPT; /* Let something else run */ cond_resched_lock(vc-lock); ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 3/3] sched/preempt: fix cond_resched_lock() and cond_resched_softirq()
These functions check should_resched() before unlocking spinlock/bh-enable: preempt_count always non-zero = should_resched() always returns false. cond_resched_lock() worked iff spin_needbreak is set. This patch adds argument preempt_offset to should_resched(). preempt_count offset constants for that: PREEMPT_DISABLE_OFFSET - offset after preempt_disable() PREEMPT_LOCK_OFFSET - offset after spin_lock() SOFTIRQ_DISABLE_OFFSET - offset after local_bh_distable() SOFTIRQ_LOCK_OFFSET - offset after spin_lock_bh() Signed-off-by: Konstantin Khlebnikov khlebni...@yandex-team.ru --- arch/x86/include/asm/preempt.h |4 ++-- include/asm-generic/preempt.h |5 +++-- include/linux/preempt.h| 19 ++- include/linux/sched.h |6 -- kernel/sched/core.c|6 +++--- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h index dca71714f860..b12f81022a6b 100644 --- a/arch/x86/include/asm/preempt.h +++ b/arch/x86/include/asm/preempt.h @@ -90,9 +90,9 @@ static __always_inline bool __preempt_count_dec_and_test(void) /* * Returns true when we need to resched and can (barring IRQ state). */ -static __always_inline bool should_resched(void) +static __always_inline bool should_resched(int preempt_offset) { - return unlikely(!raw_cpu_read_4(__preempt_count)); + return unlikely(raw_cpu_read_4(__preempt_count) == preempt_offset); } #ifdef CONFIG_PREEMPT diff --git a/include/asm-generic/preempt.h b/include/asm-generic/preempt.h index d0a7a4753db2..0bec580a4885 100644 --- a/include/asm-generic/preempt.h +++ b/include/asm-generic/preempt.h @@ -71,9 +71,10 @@ static __always_inline bool __preempt_count_dec_and_test(void) /* * Returns true when we need to resched and can (barring IRQ state). */ -static __always_inline bool should_resched(void) +static __always_inline bool should_resched(int preempt_offset) { - return unlikely(!preempt_count() tif_need_resched()); + return unlikely(preempt_count() == preempt_offset + tif_need_resched()); } #ifdef CONFIG_PREEMPT diff --git a/include/linux/preempt.h b/include/linux/preempt.h index 84991f185173..bea8dd8ff5e0 100644 --- a/include/linux/preempt.h +++ b/include/linux/preempt.h @@ -84,13 +84,21 @@ */ #define in_nmi() (preempt_count() NMI_MASK) +/* + * The preempt_count offset after preempt_disable(); + */ #if defined(CONFIG_PREEMPT_COUNT) -# define PREEMPT_DISABLE_OFFSET 1 +# define PREEMPT_DISABLE_OFFSETPREEMPT_OFFSET #else -# define PREEMPT_DISABLE_OFFSET 0 +# define PREEMPT_DISABLE_OFFSET0 #endif /* + * The preempt_count offset after spin_lock() + */ +#define PREEMPT_LOCK_OFFSETPREEMPT_DISABLE_OFFSET + +/* * The preempt_count offset needed for things like: * * spin_lock_bh() @@ -103,7 +111,7 @@ * * Work as expected. */ -#define SOFTIRQ_LOCK_OFFSET (SOFTIRQ_DISABLE_OFFSET + PREEMPT_DISABLE_OFFSET) +#define SOFTIRQ_LOCK_OFFSET (SOFTIRQ_DISABLE_OFFSET + PREEMPT_LOCK_OFFSET) /* * Are we running in atomic context? WARNING: this macro cannot @@ -124,7 +132,8 @@ #if defined(CONFIG_DEBUG_PREEMPT) || defined(CONFIG_PREEMPT_TRACER) extern void preempt_count_add(int val); extern void preempt_count_sub(int val); -#define preempt_count_dec_and_test() ({ preempt_count_sub(1); should_resched(); }) +#define preempt_count_dec_and_test() \ + ({ preempt_count_sub(1); should_resched(0); }) #else #define preempt_count_add(val) __preempt_count_add(val) #define preempt_count_sub(val) __preempt_count_sub(val) @@ -184,7 +193,7 @@ do { \ #define preempt_check_resched() \ do { \ - if (should_resched()) \ + if (should_resched(0)) \ __preempt_schedule(); \ } while (0) diff --git a/include/linux/sched.h b/include/linux/sched.h index ae21f1591615..a8e9b17acdee 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2885,12 +2885,6 @@ extern int _cond_resched(void); extern int __cond_resched_lock(spinlock_t *lock); -#ifdef CONFIG_PREEMPT_COUNT -#define PREEMPT_LOCK_OFFSETPREEMPT_OFFSET -#else -#define PREEMPT_LOCK_OFFSET0 -#endif - #define cond_resched_lock(lock) ({ \ ___might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET);\ __cond_resched_lock(lock); \ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 78b4bad10081..d9a4d93dc879 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4492,7 +4492,7 @@ SYSCALL_DEFINE0(sched_yield) int __sched _cond_resched(void) { - if (should_resched()) { + if (should_resched(0)) { preempt_schedule_common(); return 1; } @@ -4510,7 +4510,7 @@ EXPORT_SYMBOL(_cond_resched); */ int __cond_resched_lock(spinlock_t *lock) { - int resched = should_resched(); + int resched =
[PATCH v2 1/3] drivers/xen/preempt: use need_resched() instead of should_resched()
This code is used only when CONFIG_PREEMPT=n and only in non-atomic context: xen_in_preemptible_hcall is set only in privcmd_ioctl_hypercall(). Thus preempt_count is zero and should_resched() is equal to need_resched(). Signed-off-by: Konstantin Khlebnikov khlebni...@yandex-team.ru --- drivers/xen/preempt.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/xen/preempt.c b/drivers/xen/preempt.c index a1800c150839..08cb419eb4e6 100644 --- a/drivers/xen/preempt.c +++ b/drivers/xen/preempt.c @@ -31,7 +31,7 @@ EXPORT_SYMBOL_GPL(xen_in_preemptible_hcall); asmlinkage __visible void xen_maybe_preempt_hcall(void) { if (unlikely(__this_cpu_read(xen_in_preemptible_hcall) - should_resched())) { + need_resched())) { /* * Clear flag as we may be rescheduled on a different * cpu. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RFC PATCH 06/12] powerpc: Rework syscall_get_arguments() so there is only one loop
Currently syscall_get_arguments() has two loops, one for compat and one for regular tasks. In prepartion for the next patch, which changes which registers we use, switch it to only have one loop, so we only have one place to update. Signed-off-by: Michael Ellerman m...@ellerman.id.au --- arch/powerpc/include/asm/syscall.h | 19 --- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h index cabe90133e69..403e2303fe18 100644 --- a/arch/powerpc/include/asm/syscall.h +++ b/arch/powerpc/include/asm/syscall.h @@ -64,19 +64,16 @@ static inline void syscall_get_arguments(struct task_struct *task, unsigned int i, unsigned int n, unsigned long *args) { + unsigned long mask = -1UL; + BUG_ON(i + n 6); -#ifdef CONFIG_PPC64 - if (test_tsk_thread_flag(task, TIF_32BIT)) { - /* -* Zero-extend 32-bit argument values. The high bits are -* garbage ignored by the actual syscall dispatch. -*/ - while (n-- 0) - args[n] = (u32) regs-gpr[3 + i + n]; - return; - } + +#ifdef CONFIG_COMPAT + if (test_tsk_thread_flag(task, TIF_32BIT)) + mask = 0x; #endif - memcpy(args, regs-gpr[3 + i], n * sizeof(args[0])); + while (n--) + args[n] = regs-gpr[3 + i + n] mask; } static inline void syscall_set_arguments(struct task_struct *task, -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RFC PATCH 12/12] selftests/seccomp: Add powerpc support
Wire up the syscall number and regs so the tests work on powerpc. Signed-off-by: Michael Ellerman m...@ellerman.id.au --- tools/testing/selftests/seccomp/seccomp_bpf.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 51adb9afb511..05fcdb974df6 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -14,6 +14,7 @@ #include linux/filter.h #include sys/prctl.h #include sys/ptrace.h +#include sys/types.h #include sys/user.h #include linux/prctl.h #include linux/ptrace.h @@ -1209,6 +1210,10 @@ TEST_F(TRACE_poke, getpid_runs_normally) # define ARCH_REGS struct user_pt_regs # define SYSCALL_NUM regs[8] # define SYSCALL_RET regs[0] +#elif defined(__powerpc__) +# define ARCH_REGS struct pt_regs +# define SYSCALL_NUM gpr[0] +# define SYSCALL_RET gpr[3] #else # error Do not know how to find your architecture's registers and syscalls #endif @@ -1242,7 +1247,7 @@ void change_syscall(struct __test_metadata *_metadata, ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, iov); EXPECT_EQ(0, ret); -#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) +#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || defined(__powerpc__) { regs.SYSCALL_NUM = syscall; } @@ -1406,6 +1411,8 @@ TEST_F(TRACE_syscall, syscall_dropped) # define __NR_seccomp 383 # elif defined(__aarch64__) # define __NR_seccomp 277 +# elif defined(__powerpc__) +# define __NR_seccomp 358 # else # warning seccomp syscall number unknown for this architecture # define __NR_seccomp 0x -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] spi: mpc512x-psc: add support for Freescale MPC5125
On Tue, Jul 14, 2015 at 10:54:42AM +0100, Mark Brown wrote: On Tue, Jul 14, 2015 at 11:19:56AM +0200, Uwe Kleine-König wrote: static const struct of_device_id mpc512x_psc_spi_of_match[] = { - { .compatible = fsl,mpc5121-psc-spi, }, + { .compatible = fsl,mpc5121-psc-spi, .data = (void *)TYPE_MPC5121 }, + { .compatible = fsl,mpc5125-psc-spi, .data = (void *)TYPE_MPC5125 }, {}, The code seems fine but this should update the binding document to include the new compatible string. I don't find fsl,mpc5121-psc-spi documented either. The best I found is ocumentation/devicetree/bindings/powerpc/fsl/mpc5121-psc.txt which describes fsl,mpc5121-psc-uart and fsl,mpc5121-psc. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König| Industrial Linux Solutions | http://www.pengutronix.de/ | ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RFC PATCH 04/12] powerpc: Drop unused syscall_get_error()
syscall_get_error() is unused, and never has been. It's also probably wrong, as it negates r3 before returning it, but that depends on what the caller is expecting. It also doesn't deal with compat, and doesn't deal with TIF_NOERROR. Although we could fix those, until it has a caller and it's clear what semantics the caller wants it's just untested code. So drop it. Signed-off-by: Michael Ellerman m...@ellerman.id.au --- arch/powerpc/include/asm/syscall.h | 6 -- 1 file changed, 6 deletions(-) diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h index ff21b7a2f0cc..c6239dabcfb1 100644 --- a/arch/powerpc/include/asm/syscall.h +++ b/arch/powerpc/include/asm/syscall.h @@ -34,12 +34,6 @@ static inline void syscall_rollback(struct task_struct *task, regs-gpr[3] = regs-orig_gpr3; } -static inline long syscall_get_error(struct task_struct *task, -struct pt_regs *regs) -{ - return (regs-ccr 0x1000) ? -regs-gpr[3] : 0; -} - static inline long syscall_get_return_value(struct task_struct *task, struct pt_regs *regs) { -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RFC PATCH 02/12] powerpc/kernel: Switch to using MAX_ERRNO
Currently on powerpc we have our own #define for the highest (negative) errno value, called _LAST_ERRNO. This is defined to be 516, for reasons which are not clear. The generic code, and x86, use MAX_ERRNO, which is defined to be 4095. In particular seccomp uses MAX_ERRNO to restrict the value that a seccomp filter can return. Currently with the mismatch between _LAST_ERRNO and MAX_ERRNO, a seccomp tracer wanting to return 600, expecting it to be seen as an error, would instead find on powerpc that userspace sees a successful syscall with a return value of 600. To avoid this inconsistency, switch powerpc to use MAX_ERRNO. We are somewhat confident that generic syscalls that can return a non-error value above negative MAX_ERRNO have already been updated to use force_successful_syscall_return(). I have also checked all the powerpc specific syscalls, and believe that none of them expect to return a non-error value between -MAX_ERRNO and -516. So this change should be safe ... Signed-off-by: Michael Ellerman m...@ellerman.id.au --- arch/powerpc/include/uapi/asm/errno.h | 2 -- arch/powerpc/kernel/entry_32.S| 3 ++- arch/powerpc/kernel/entry_64.S| 5 +++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/uapi/asm/errno.h b/arch/powerpc/include/uapi/asm/errno.h index 8c145fd17d86..e8b6b5f7de7c 100644 --- a/arch/powerpc/include/uapi/asm/errno.h +++ b/arch/powerpc/include/uapi/asm/errno.h @@ -6,6 +6,4 @@ #undef EDEADLOCK #defineEDEADLOCK 58 /* File locking deadlock error */ -#define _LAST_ERRNO516 - #endif /* _ASM_POWERPC_ERRNO_H */ diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S index 46fc0f4d8982..67ecdf61f4e3 100644 --- a/arch/powerpc/kernel/entry_32.S +++ b/arch/powerpc/kernel/entry_32.S @@ -20,6 +20,7 @@ */ #include linux/errno.h +#include linux/err.h #include linux/sys.h #include linux/threads.h #include asm/reg.h @@ -354,7 +355,7 @@ ret_from_syscall: SYNC MTMSRD(r10) lwz r9,TI_FLAGS(r12) - li r8,-_LAST_ERRNO + li r8,-MAX_ERRNO andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK) bne-syscall_exit_work cmplw 0,r3,r8 diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index 0796c487d3db..8292581a42f1 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S @@ -19,6 +19,7 @@ */ #include linux/errno.h +#include linux/err.h #include asm/unistd.h #include asm/processor.h #include asm/page.h @@ -207,7 +208,7 @@ system_call:/* label this so stack traces look sane */ #endif /* CONFIG_PPC_BOOK3E */ ld r9,TI_FLAGS(r12) - li r11,-_LAST_ERRNO + li r11,-MAX_ERRNO andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK) bne-syscall_exit_work cmpld r3,r11 @@ -279,7 +280,7 @@ syscall_exit_work: beq+0f REST_NVGPRS(r1) b 2f -0: cmpld r3,r11 /* r10 is -LAST_ERRNO */ +0: cmpld r3,r11 /* r11 is -MAX_ERRNO */ blt+1f andi. r0,r9,_TIF_NOERROR bne-1f -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RFC PATCH 09/12] powerpc/kernel: Add SIG_SYS support for compat tasks
SIG_SYS was added in commit a0727e8ce513 signal, x86: add SIGSYS info and make it synchronous. Because we use the asm-generic struct siginfo, we got support for SIG_SYS for free as part of that commit. However there was no compat handling added for powerpc. That means we've been advertising the existence of signfo._sifields._sigsys to compat tasks, but not actually filling in the fields correctly. Luckily it looks like no one has noticed, presumably because the only user of SIGSYS in the kernel is seccomp filter, which we don't support yet. So before we enable seccomp filter, add compat handling for SIGSYS. Signed-off-by: Michael Ellerman m...@ellerman.id.au --- arch/powerpc/include/asm/compat.h | 7 +++ arch/powerpc/kernel/signal_32.c | 5 + tools/testing/selftests/seccomp/seccomp_bpf.c | 4 3 files changed, 16 insertions(+) diff --git a/arch/powerpc/include/asm/compat.h b/arch/powerpc/include/asm/compat.h index b142b8e0ed9e..4f2df589ec1d 100644 --- a/arch/powerpc/include/asm/compat.h +++ b/arch/powerpc/include/asm/compat.h @@ -174,6 +174,13 @@ typedef struct compat_siginfo { int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ int _fd; } _sigpoll; + + /* SIGSYS */ + struct { + unsigned int _call_addr; /* calling insn */ + int _syscall;/* triggering system call number */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall */ + } _sigsys; } _sifields; } compat_siginfo_t; diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c index d3a831ac0f92..77f97284124e 100644 --- a/arch/powerpc/kernel/signal_32.c +++ b/arch/powerpc/kernel/signal_32.c @@ -949,6 +949,11 @@ int copy_siginfo_to_user32(struct compat_siginfo __user *d, const siginfo_t *s) err |= __put_user(s-si_overrun, d-si_overrun); err |= __put_user(s-si_int, d-si_int); break; + case __SI_SYS 16: + err |= __put_user(ptr_to_compat(s-si_call_addr), d-si_call_addr); + err |= __put_user(s-si_syscall, d-si_syscall); + err |= __put_user(s-si_arch, d-si_arch); + break; case __SI_RT 16: /* This is not generated by the kernel as of now. */ case __SI_MESGQ 16: err |= __put_user(s-si_int, d-si_int); diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index c5abe7fd7590..b2374c131340 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -645,6 +645,10 @@ static struct siginfo TRAP_info; static volatile int TRAP_nr; static void TRAP_action(int nr, siginfo_t *info, void *void_context) { + fprintf(stderr, in TRAP_action\n); + fprintf(stderr, info-si_call_addr %p\n, info-si_call_addr); + fprintf(stderr, info-si_syscall %u\n, info-si_syscall); + fprintf(stderr, info-si_arch %u\n, info-si_arch); memcpy(TRAP_info, info, sizeof(TRAP_info)); TRAP_nr = nr; } -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 01/46] usb: gadget: encapsulate endpoint claiming mechanism
So far it was necessary for usb functions to set ep-driver_data in endpoint obtained from autoconfig to non-null value, to indicate that endpoint is claimed by function (in autoconfig it was checked if endpoint has set this field to non-null value, and if it has, it was assumed that it is claimed). It could cause bugs becouse if some function doesn't set this field autoconfig could return the same endpoint more than one time. To help to avoid such bugs this patch adds claimed flag to struct usb_ep, and encapsulates endpoint claiming mechanism inside usb_ep_autoconfig_ss() and usb_ep_autoconfig_reset(), so now usb functions don't need to perform any additional actions to mark endpoint obtained from autoconfig as claimed. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 11 ++- include/linux/usb/gadget.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 919cdfd..8e00ca7 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -53,7 +53,7 @@ ep_matches ( int num_req_streams = 0; /* endpoint already claimed? */ - if (NULL != ep-driver_data) + if (ep-claimed) return 0; /* only support ep0 for portable CONTROL traffic */ @@ -240,7 +240,7 @@ find_ep (struct usb_gadget *gadget, const char *name) * updated with the assigned number of streams if it is * different from the original value. To prevent the endpoint * from being returned by a later autoconfig call, claim it by - * assigning ep-driver_data to some non-null value. + * assigning ep-claimed to true. * * On failure, this returns a null endpoint descriptor. */ @@ -323,6 +323,7 @@ struct usb_ep *usb_ep_autoconfig_ss( found_ep: ep-desc = NULL; ep-comp_desc = NULL; + ep-claimed = true; return ep; } EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); @@ -354,7 +355,7 @@ EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value * is initialized as if the endpoint were used at full speed. To prevent * the endpoint from being returned by a later autoconfig call, claim it - * by assigning ep-driver_data to some non-null value. + * by assigning ep-claimed to true. * * On failure, this returns a null endpoint descriptor. */ @@ -373,7 +374,7 @@ EXPORT_SYMBOL_GPL(usb_ep_autoconfig); * * Use this for devices where one configuration may need to assign * endpoint resources very differently from the next one. It clears - * state such as ep-driver_data and the record of assigned endpoints + * state such as ep-claimed and the record of assigned endpoints * used by usb_ep_autoconfig(). */ void usb_ep_autoconfig_reset (struct usb_gadget *gadget) @@ -381,7 +382,7 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget) struct usb_ep *ep; list_for_each_entry (ep, gadget-ep_list, ep_list) { - ep-driver_data = NULL; + ep-claimed = false; } gadget-in_epnum = 0; gadget-out_epnum = 0; diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 4f3dfb7..fcb0a4e 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -173,6 +173,7 @@ struct usb_ep { const char *name; const struct usb_ep_ops *ops; struct list_headep_list; + boolclaimed; unsignedmaxpacket:16; unsignedmaxpacket_limit:16; unsignedmax_streams:16; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 04/46] staging: emxx_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Fixed typo in epc-nulk to epc-bulk. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/staging/emxx_udc/emxx_udc.c | 60 ++--- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 3b7aa36..0d64bee 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -3153,36 +3153,33 @@ static const struct usb_gadget_ops nbu2ss_gadget_ops = { .ioctl = nbu2ss_gad_ioctl, }; -static const char g_ep0_name[] = ep0; -static const char g_ep1_name[] = ep1-bulk; -static const char g_ep2_name[] = ep2-bulk; -static const char g_ep3_name[] = ep3in-int; -static const char g_ep4_name[] = ep4-iso; -static const char g_ep5_name[] = ep5-iso; -static const char g_ep6_name[] = ep6-bulk; -static const char g_ep7_name[] = ep7-bulk; -static const char g_ep8_name[] = ep8in-int; -static const char g_ep9_name[] = ep9-iso; -static const char g_epa_name[] = epa-iso; -static const char g_epb_name[] = epb-bulk; -static const char g_epc_name[] = epc-nulk; -static const char g_epd_name[] = epdin-int; - -static const char *gp_ep_name[NUM_ENDPOINTS] = { - g_ep0_name, - g_ep1_name, - g_ep2_name, - g_ep3_name, - g_ep4_name, - g_ep5_name, - g_ep6_name, - g_ep7_name, - g_ep8_name, - g_ep9_name, - g_epa_name, - g_epb_name, - g_epc_name, - g_epd_name, +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info[NUM_ENDPOINTS] = { +#define EP_INFO(_name, _type, _dir) \ + { \ + .name = _name, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \ + USB_EP_CAPS_DIR_ ## _dir), \ + } + + EP_INFO(ep0, CONTROL, ALL), + EP_INFO(ep1-bulk, BULK, ALL), + EP_INFO(ep2-bulk, BULK, ALL), + EP_INFO(ep3in-int,INT,IN), + EP_INFO(ep4-iso, INT,ALL), + EP_INFO(ep5-iso, ISO,ALL), + EP_INFO(ep6-bulk, ISO,ALL), + EP_INFO(ep7-bulk, BULK, ALL), + EP_INFO(ep8in-int,INT,IN), + EP_INFO(ep9-iso, ISO,ALL), + EP_INFO(epa-iso, ISO,ALL), + EP_INFO(epb-bulk, BULK, ALL), + EP_INFO(epc-bulk, BULK, ALL), + EP_INFO(epdin-int,INT,IN), + +#undef EP_INFO }; /*-*/ @@ -3200,7 +3197,8 @@ static void __init nbu2ss_drv_ep_init(struct nbu2ss_udc *udc) ep-desc = NULL; ep-ep.driver_data = NULL; - ep-ep.name = gp_ep_name[i]; + ep-ep.name = ep_info[i].name; + ep-ep.caps = ep_info[i].caps; ep-ep.ops = nbu2ss_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 08/46] usb: gadget: amd5536udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/amd5536udc.c | 57 ++--- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/drivers/usb/gadget/udc/amd5536udc.c b/drivers/usb/gadget/udc/amd5536udc.c index de7e5e2..1a1d91c 100644 --- a/drivers/usb/gadget/udc/amd5536udc.c +++ b/drivers/usb/gadget/udc/amd5536udc.c @@ -138,15 +138,51 @@ static DECLARE_TASKLET(disconnect_tasklet, udc_tasklet_disconnect, /* endpoint names used for print */ static const char ep0_string[] = ep0in; -static const char *const ep_string[] = { - ep0_string, - ep1in-int, ep2in-bulk, ep3in-bulk, ep4in-bulk, ep5in-bulk, - ep6in-bulk, ep7in-bulk, ep8in-bulk, ep9in-bulk, ep10in-bulk, - ep11in-bulk, ep12in-bulk, ep13in-bulk, ep14in-bulk, - ep15in-bulk, ep0out, ep1out-bulk, ep2out-bulk, ep3out-bulk, - ep4out-bulk, ep5out-bulk, ep6out-bulk, ep7out-bulk, - ep8out-bulk, ep9out-bulk, ep10out-bulk, ep11out-bulk, - ep12out-bulk, ep13out-bulk, ep14out-bulk, ep15out-bulk +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info[] = { +#define EP_INFO(_name, _type, _dir) \ + { \ + .name = _name, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \ + USB_EP_CAPS_DIR_ ## _dir), \ + } + + EP_INFO(ep0_string, CONTROL, IN), + EP_INFO(ep1in-int,BULK, IN), + EP_INFO(ep2in-bulk, BULK, IN), + EP_INFO(ep3in-bulk, BULK, IN), + EP_INFO(ep4in-bulk, BULK, IN), + EP_INFO(ep5in-bulk, BULK, IN), + EP_INFO(ep6in-bulk, BULK, IN), + EP_INFO(ep7in-bulk, BULK, IN), + EP_INFO(ep8in-bulk, BULK, IN), + EP_INFO(ep9in-bulk, BULK, IN), + EP_INFO(ep10in-bulk, BULK, IN), + EP_INFO(ep11in-bulk, BULK, IN), + EP_INFO(ep12in-bulk, BULK, IN), + EP_INFO(ep13in-bulk, BULK, IN), + EP_INFO(ep14in-bulk, BULK, IN), + EP_INFO(ep15in-bulk, BULK, IN), + EP_INFO(ep0out, CONTROL, OUT), + EP_INFO(ep1out-bulk, BULK, OUT), + EP_INFO(ep2out-bulk, BULK, OUT), + EP_INFO(ep3out-bulk, BULK, OUT), + EP_INFO(ep4out-bulk, BULK, OUT), + EP_INFO(ep5out-bulk, BULK, OUT), + EP_INFO(ep6out-bulk, BULK, OUT), + EP_INFO(ep7out-bulk, BULK, OUT), + EP_INFO(ep8out-bulk, BULK, OUT), + EP_INFO(ep9out-bulk, BULK, OUT), + EP_INFO(ep10out-bulk, BULK, OUT), + EP_INFO(ep11out-bulk, BULK, OUT), + EP_INFO(ep12out-bulk, BULK, OUT), + EP_INFO(ep13out-bulk, BULK, OUT), + EP_INFO(ep14out-bulk, BULK, OUT), + EP_INFO(ep15out-bulk, BULK, OUT), + +#undef EP_INFO }; /* DMA usage flag */ @@ -1517,7 +1553,8 @@ static void udc_setup_endpoints(struct udc *dev) for (tmp = 0; tmp UDC_EP_NUM; tmp++) { ep = dev-ep[tmp]; ep-dev = dev; - ep-ep.name = ep_string[tmp]; + ep-ep.name = ep_info[tmp].name; + ep-ep.caps = ep_info[tmp].caps; ep-num = tmp; /* txfifo size is calculated at enable time */ ep-txfifo = dev-txfifo; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 14/46] usb: gadget: fsl_qe_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/fsl_qe_udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c index e0822f1..5fb6f8b 100644 --- a/drivers/usb/gadget/udc/fsl_qe_udc.c +++ b/drivers/usb/gadget/udc/fsl_qe_udc.c @@ -2417,6 +2417,17 @@ static int qe_ep_config(struct qe_udc *udc, unsigned char pipe_num) strcpy(ep-name, ep_name[pipe_num]); ep-ep.name = ep_name[pipe_num]; + if (pipe_num == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; + ep-ep.ops = qe_ep_ops; ep-stopped = 1; usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 13/46] usb: gadget: fotg210-udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/fotg210-udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index e547ea7..960c70c 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -1153,6 +1153,17 @@ static int fotg210_udc_probe(struct platform_device *pdev) ep-ep.name = fotg210_ep_name[i]; ep-ep.ops = fotg210_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(fotg210-ep[0]-ep, 0x40); fotg210-gadget.ep0 = fotg210-ep[0]-ep; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 15/46] usb: gadget: fsl_udc_core: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/fsl_udc_core.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c index c60022b..aab5221 100644 --- a/drivers/usb/gadget/udc/fsl_udc_core.c +++ b/drivers/usb/gadget/udc/fsl_udc_core.c @@ -2313,6 +2313,19 @@ static int struct_ep_setup(struct fsl_udc *udc, unsigned char index, ep-ep.ops = fsl_ep_ops; ep-stopped = 0; + if (index == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + if (index 1) + ep-ep.caps.dir_in = true; + else + ep-ep.caps.dir_out = true; + /* for ep0: maxP defined in desc * for other eps, maxP is set by epautoconfig() called by gadget layer */ -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 19/46] usb: gadget: lpc32xx_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/lpc32xx_udc.c | 32 1 file changed, 32 insertions(+) diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c index 3b6a785..00b5006 100644 --- a/drivers/usb/gadget/udc/lpc32xx_udc.c +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c @@ -2575,6 +2575,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep0, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 0, @@ -2586,6 +2588,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep1-int, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 2, @@ -2597,6 +2601,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep2-bulk, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 4, @@ -2608,6 +2614,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep3-iso, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 1023, .hwep_num_base = 6, @@ -2619,6 +2627,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep4-int, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 8, @@ -2630,6 +2640,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep5-bulk, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 10, @@ -2641,6 +2653,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep6-iso, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 1023, .hwep_num_base = 12, @@ -2652,6 +2666,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep7-int, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 14, @@ -2663,6 +2679,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep8-bulk, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 16, @@ -2674,6 +2692,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep9-iso, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 1023, .hwep_num_base = 18, @@ -2685,6 +2705,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep10-int, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_ALL), },
[PATCH v3 18/46] usb: gadget: gr_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/gr_udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c index c886887..8aa2593 100644 --- a/drivers/usb/gadget/udc/gr_udc.c +++ b/drivers/usb/gadget/udc/gr_udc.c @@ -2018,12 +2018,23 @@ static int gr_ep_init(struct gr_udc *dev, int num, int is_in, u32 maxplimit) usb_ep_set_maxpacket_limit(ep-ep, MAX_CTRL_PL_SIZE); ep-bytes_per_buffer = MAX_CTRL_PL_SIZE; + + ep-ep.caps.type_control = true; } else { usb_ep_set_maxpacket_limit(ep-ep, (u16)maxplimit); list_add_tail(ep-ep.ep_list, dev-gadget.ep_list); + + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; } list_add_tail(ep-ep_list, dev-ep_list); + if (is_in) + ep-ep.caps.dir_in = true; + else + ep-ep.caps.dir_out = true; + ep-tailbuf = dma_alloc_coherent(dev-dev, ep-ep.maxpacket_limit, ep-tailbuf_paddr, GFP_ATOMIC); if (!ep-tailbuf) -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 22/46] usb: gadget: mv_udc_core: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/mv_udc_core.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c index d32160d..306a7ff 100644 --- a/drivers/usb/gadget/udc/mv_udc_core.c +++ b/drivers/usb/gadget/udc/mv_udc_core.c @@ -1257,6 +1257,9 @@ static int eps_init(struct mv_udc *udc) ep-wedge = 0; ep-stopped = 0; usb_ep_set_maxpacket_limit(ep-ep, EP0_MAX_PKT_SIZE); + ep-ep.caps.type_control = true; + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; ep-ep_num = 0; ep-ep.desc = mv_ep0_desc; INIT_LIST_HEAD(ep-queue); @@ -1269,14 +1272,20 @@ static int eps_init(struct mv_udc *udc) if (i % 2) { snprintf(name, sizeof(name), ep%din, i / 2); ep-direction = EP_DIR_IN; + ep-ep.caps.dir_in = true; } else { snprintf(name, sizeof(name), ep%dout, i / 2); ep-direction = EP_DIR_OUT; + ep-ep.caps.dir_out = true; } ep-udc = udc; strncpy(ep-name, name, sizeof(ep-name)); ep-ep.name = ep-name; + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + ep-ep.ops = mv_ep_ops; ep-stopped = 0; usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 30/46] usb: gadget: s3c-hsudc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/s3c-hsudc.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/usb/gadget/udc/s3c-hsudc.c b/drivers/usb/gadget/udc/s3c-hsudc.c index 85a712a..e9def42 100644 --- a/drivers/usb/gadget/udc/s3c-hsudc.c +++ b/drivers/usb/gadget/udc/s3c-hsudc.c @@ -1005,6 +1005,21 @@ static void s3c_hsudc_initep(struct s3c_hsudc *hsudc, hsep-stopped = 0; hsep-wedge = 0; + if (epnum == 0) { + hsep-ep.caps.type_control = true; + hsep-ep.caps.dir_in = true; + hsep-ep.caps.dir_out = true; + } else { + hsep-ep.caps.type_iso = true; + hsep-ep.caps.type_bulk = true; + hsep-ep.caps.type_int = true; + } + + if (epnum 1) + hsep-ep.caps.dir_in = true; + else + hsep-ep.caps.dir_out = true; + set_index(hsudc, epnum); writel(hsep-ep.maxpacket, hsudc-regs + S3C_MPR); } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 36/46] usb: gadget: atmel_usba_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/atmel_usba_udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index 37d414e..267d84f 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c @@ -2067,6 +2067,17 @@ static struct usba_ep * usba_udc_pdata(struct platform_device *pdev, ep-can_dma = pdata-ep[i].can_dma; ep-can_isoc = pdata-ep[i].can_isoc; + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = ep-can_isoc; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; + if (i) list_add_tail(ep-ep.ep_list, udc-gadget.ep_list); } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 42/46] usb: gadget: move ep_matches() from epautoconf to udc-core
Move ep_matches() function to udc-core and rename it to usb_gadget_ep_match_desc(). This function can be used by UDC drivers in 'match_ep' callback to avoid writing lots of repetitive code. Replace all calls of ep_matches() with usb_gadget_ep_match_desc(). Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 95 +-- drivers/usb/gadget/udc/udc-core.c | 69 include/linux/usb/gadget.h| 8 3 files changed, 88 insertions(+), 84 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 1b1fee0..3f0a380 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -22,82 +22,6 @@ #include gadget_chips.h -static int -ep_matches ( - struct usb_gadget *gadget, - struct usb_ep *ep, - struct usb_endpoint_descriptor *desc, - struct usb_ss_ep_comp_descriptor *ep_comp -) -{ - u8 type; - u16 max; - int num_req_streams = 0; - - /* endpoint already claimed? */ - if (ep-claimed) - return 0; - - type = usb_endpoint_type(desc); - max = 0x7ff usb_endpoint_maxp(desc); - - if (usb_endpoint_dir_in(desc) !ep-caps.dir_in) - return 0; - else if (!ep-caps.dir_out) - return 0; - - if (max ep-maxpacket_limit) - return 0; - - /* high bandwidth works only at high speed */ - if (!gadget_is_dualspeed(gadget) usb_endpoint_maxp(desc) (311)) - return 0; - - switch (type) { - case USB_ENDPOINT_XFER_CONTROL: - /* only support ep0 for portable CONTROL traffic */ - return 0; - case USB_ENDPOINT_XFER_ISOC: - if (!ep-caps.type_iso) - return 0; - /* ISO: limit 1023 bytes full speed, -* 1024 high/super speed -*/ - if (!gadget_is_dualspeed(gadget) max 1023) - return 0; - break; - case USB_ENDPOINT_XFER_BULK: - if (!ep-caps.type_bulk) - return 0; - if (ep_comp gadget_is_superspeed(gadget)) { - /* Get the number of required streams from the -* EP companion descriptor and see if the EP -* matches it -*/ - num_req_streams = ep_comp-bmAttributes 0x1f; - if (num_req_streams ep-max_streams) - return 0; - } - break; - case USB_ENDPOINT_XFER_INT: - /* Bulk endpoints handle interrupt transfers, -* except the toggle-quirky iso-synch kind -*/ - if (!ep-caps.type_int !ep-caps.type_bulk) - return 0; - /* INT: limit 64 bytes full speed, -* 1024 high/super speed -*/ - if (!gadget_is_dualspeed(gadget) max 64) - return 0; - break; - } - - /* MATCH!! */ - - return 1; -} - static struct usb_ep * find_ep (struct usb_gadget *gadget, const char *name) { @@ -180,10 +104,12 @@ struct usb_ep *usb_ep_autoconfig_ss( if (type == USB_ENDPOINT_XFER_INT) { /* ep-e, ep-f are PIO with only 64 byte fifos */ ep = find_ep(gadget, ep-e); - if (ep ep_matches(gadget, ep, desc, ep_comp)) + if (ep usb_gadget_ep_match_desc(gadget, + ep, desc, ep_comp)) goto found_ep; ep = find_ep(gadget, ep-f); - if (ep ep_matches(gadget, ep, desc, ep_comp)) + if (ep usb_gadget_ep_match_desc(gadget, + ep, desc, ep_comp)) goto found_ep; } @@ -191,20 +117,21 @@ struct usb_ep *usb_ep_autoconfig_ss( snprintf(name, sizeof(name), ep%d%s, usb_endpoint_num(desc), usb_endpoint_dir_in(desc) ? in : out); ep = find_ep(gadget, name); - if (ep ep_matches(gadget, ep, desc, ep_comp)) + if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; } else if (gadget_is_goku (gadget)) { if (USB_ENDPOINT_XFER_INT == type) { /* single buffering is enough */ ep = find_ep(gadget, ep3-bulk); - if (ep ep_matches(gadget, ep, desc, ep_comp)) + if (ep usb_gadget_ep_match_desc(gadget, +
[PATCH v3 39/46] usb: gadget: epautoconf: remove ep and desc configuration from ep_matches()
As function ep_matches() is used to match endpoint with usb descriptor it's highly unintuitive that it modifies endpoint and descriptor structures fields. This patch moves code configuring ep and desc from ep_matches() to usb_ep_autoconfig_ss(), so now function ep_matches() does nothing more than its name suggests. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 66 + 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 4f66e9d73..7bb28f1 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -82,13 +82,6 @@ ep_matches ( } - /* -* If the protocol driver hasn't yet decided on wMaxPacketSize -* and wants to know the maximum possible, provide the info. -*/ - if (desc-wMaxPacketSize == 0) - desc-wMaxPacketSize = cpu_to_le16(ep-maxpacket_limit); - /* endpoint maxpacket size is an input parameter, except for bulk * where it's an output parameter representing the full speed limit. * the usb spec fixes high speed bulk maxpacket at 512 bytes. @@ -119,31 +112,6 @@ ep_matches ( /* MATCH!! */ - /* report address */ - desc-bEndpointAddress = USB_DIR_IN; - if (isdigit (ep-name [2])) { - u8 num = simple_strtoul (ep-name [2], NULL, 10); - desc-bEndpointAddress |= num; - } else if (desc-bEndpointAddress USB_DIR_IN) { - if (++gadget-in_epnum 15) - return 0; - desc-bEndpointAddress = USB_DIR_IN | gadget-in_epnum; - } else { - if (++gadget-out_epnum 15) - return 0; - desc-bEndpointAddress |= gadget-out_epnum; - } - - /* report (variable) full speed bulk maxpacket */ - if ((USB_ENDPOINT_XFER_BULK == type) !ep_comp) { - int size = ep-maxpacket_limit; - - /* min() doesn't work on bitfields with gcc-3.5 */ - if (size 64) - size = 64; - desc-wMaxPacketSize = cpu_to_le16(size); - } - ep-address = desc-bEndpointAddress; return 1; } @@ -280,6 +248,40 @@ struct usb_ep *usb_ep_autoconfig_ss( /* Fail */ return NULL; found_ep: + + /* +* If the protocol driver hasn't yet decided on wMaxPacketSize +* and wants to know the maximum possible, provide the info. +*/ + if (desc-wMaxPacketSize == 0) + desc-wMaxPacketSize = cpu_to_le16(ep-maxpacket_limit); + + /* report address */ + desc-bEndpointAddress = USB_DIR_IN; + if (isdigit(ep-name[2])) { + u8 num = simple_strtoul(ep-name[2], NULL, 10); + desc-bEndpointAddress |= num; + } else if (desc-bEndpointAddress USB_DIR_IN) { + if (++gadget-in_epnum 15) + return 0; + desc-bEndpointAddress = USB_DIR_IN | gadget-in_epnum; + } else { + if (++gadget-out_epnum 15) + return 0; + desc-bEndpointAddress |= gadget-out_epnum; + } + + /* report (variable) full speed bulk maxpacket */ + if ((type == USB_ENDPOINT_XFER_BULK) !ep_comp) { + int size = ep-maxpacket_limit; + + /* min() doesn't work on bitfields with gcc-3.5 */ + if (size 64) + size = 64; + desc-wMaxPacketSize = cpu_to_le16(size); + } + + ep-address = desc-bEndpointAddress; ep-desc = NULL; ep-comp_desc = NULL; ep-claimed = true; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RESEND PATCH v3] powerpc/pseries: Limit EPOW reset event warnings
On 07/15/2015 09:52 AM, Kamalesh Babulal wrote: Kernel prints respective warnings about various EPOW events for user information/action after parsing EPOW interrupts. Prompting user to take action depending upon the severity of the event. Second line probably isn't needed. Also below line can be merged with first one as both are in same context to describe problem. At times EPOW reset event warning, such as below could flood kernel log, over a period of time. May 25 03:46:34 alp kernel: Non critical power or cooling issue cleared May 25 03:46:52 alp kernel: Non critical power or cooling issue cleared May 25 03:53:48 alp kernel: Non critical power or cooling issue cleared May 25 03:55:46 alp kernel: Non critical power or cooling issue cleared May 25 03:56:34 alp kernel: Non critical power or cooling issue cleared May 25 03:59:04 alp kernel: Non critical power or cooling issue cleared May 25 04:02:01 alp kernel: Non critical power or cooling issue cleared May 25 04:04:24 alp kernel: Non critical power or cooling issue cleared May 25 04:07:18 alp kernel: Non critical power or cooling issue cleared May 25 04:13:04 alp kernel: Non critical power or cooling issue cleared May 25 04:22:04 alp kernel: Non critical power or cooling issue cleared May 25 04:22:26 alp kernel: Non critical power or cooling issue cleared May 25 04:22:36 alp kernel: Non critical power or cooling issue cleared This patch avoids these multiple EPOW reset warnings by using a boolean flag. This flag is initialized to false and is set to true upon arrival of EPOW event. This same flag is checked and reset during EPOW_RESET scenario to filter out valid EPOW reset events and avoid multiple warning logs. Also, merged adjacent pr_err/pr_emerg into single one to reduce the number of lines printed per warning. Suggested-by: Vipin K Parashar vi...@linux.vnet.ibm.com [Vipin: edited the changelog] This probably should go to change summary below. Cc: Anshuman Khandual khand...@linux.vnet.ibm.com Cc: Anton Blanchard an...@samba.org Cc: Michael Ellerman m...@ellerman.id.au Signed-off-by: Kamalesh Babulal kamal...@linux.vnet.ibm.com --- v3 Changes: - Limit warning printed by EPOW RESET event, by guarding it with bool flag. Instead of rate limiting all the EPOW events. v2 Changes: - Merged multiple adjacent pr_err/pr_emerg into single line to reduce multi-line warnings, based on Michael's comments. arch/powerpc/platforms/pseries/ras.c | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c index 02e4a17..b30396a 100644 --- a/arch/powerpc/platforms/pseries/ras.c +++ b/arch/powerpc/platforms/pseries/ras.c @@ -40,6 +40,9 @@ static int ras_check_exception_token; #define EPOW_SENSOR_TOKEN 9 #define EPOW_SENSOR_INDEX 0 +/* Flag to limit EPOW RESET warning. */ +static bool epow_state; + static irqreturn_t ras_epow_interrupt(int irq, void *dev_id); static irqreturn_t ras_error_interrupt(int irq, void *dev_id); @@ -145,21 +148,27 @@ static void rtas_parse_epow_errlog(struct rtas_error_log *log) switch (action_code) { case EPOW_RESET: - pr_err(Non critical power or cooling issue cleared); + if (epow_state) { + pr_err(Non critical power or cooling issue cleared); + epow_state = false; + } break; case EPOW_WARN_COOLING: - pr_err(Non critical cooling issue reported by firmware); - pr_err(Check RTAS error log for details); + pr_err(Non critical cooling issue reported by firmware, + Check RTAS error log for details); + epow_state = true; break; case EPOW_WARN_POWER: - pr_err(Non critical power issue reported by firmware); - pr_err(Check RTAS error log for details); + pr_err(Non critical power issue reported by firmware, + Check RTAS error log for details); + epow_state = true; break; case EPOW_SYSTEM_SHUTDOWN: handle_system_shutdown(epow_log-event_modifier); + epow_state = true; break; case EPOW_SYSTEM_HALT: @@ -169,9 +178,8 @@ static void rtas_parse_epow_errlog(struct rtas_error_log *log) case EPOW_MAIN_ENCLOSURE: case EPOW_POWER_OFF: - pr_emerg(Critical power/cooling issue reported by firmware); - pr_emerg(Check RTAS error log for details); - pr_emerg(Immediate power off); + pr_emerg(Critical power/cooling issue reported by firmware, +Check RTAS error log for details. Immediate power off.); emergency_sync(); kernel_power_off(); break; @@ -179,6 +187,7 @@ static void
Re: [PATCH v4 3/6] cpufreq: powernv: Register for OCC related opal_message notification
Hello, On Mon, 2015-07-13 at 19:39 +0530, Shilpasri G Bhat wrote: diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index d0c18c9..1f59958 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -414,6 +415,71 @@ static struct notifier_block powernv_cpufreq_reboot_nb = { .notifier_call = powernv_cpufreq_reboot_notifier, }; +static char throttle_reason[][30] = { + No throttling, + Power Cap, + Processor Over Temperature, + Power Supply Failure, + Over Current, + OCC Reset + }; + +static int powernv_cpufreq_occ_msg(struct notifier_block *nb, +unsigned long msg_type, void *_msg) +{ + struct opal_msg *msg = _msg; + struct opal_occ_msg omsg; + + if (msg_type != OPAL_MSG_OCC) + return 0; + + memcpy(omsg, msg-params, sizeof(omsg)); You need to ensure the of the members of struct opal_occ_msg are in the correct byte order when copying them over. Have you tested this code with in a little endian configuration? Do the messages you're sending make sense for a system that has a BMC instead of a FSP? Cheers, Joel + + switch (omsg.type) { ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 11/46] usb: gadget: bdc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/bdc/bdc_ep.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c index b04980c..f9a8f57 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_ep.c +++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c @@ -1952,12 +1952,18 @@ static int init_ep(struct bdc *bdc, u32 epnum, u32 dir) ep-bdc = bdc; ep-dir = dir; + if (dir) + ep-usb_ep.caps.dir_in = true; + else + ep-usb_ep.caps.dir_out = true; + /* ep-ep_num is the index inside bdc_ep */ if (epnum == 1) { ep-ep_num = 1; bdc-bdc_ep_array[ep-ep_num] = ep; snprintf(ep-name, sizeof(ep-name), ep%d, epnum - 1); usb_ep_set_maxpacket_limit(ep-usb_ep, EP0_MAX_PKT_SIZE); + ep-usb_ep.caps.type_control = true; ep-comp_desc = NULL; bdc-gadget.ep0 = ep-usb_ep; } else { @@ -1971,6 +1977,9 @@ static int init_ep(struct bdc *bdc, u32 epnum, u32 dir) dir 1 ? in : out); usb_ep_set_maxpacket_limit(ep-usb_ep, 1024); + ep-usb_ep.caps.type_iso = true; + ep-usb_ep.caps.type_bulk = true; + ep-usb_ep.caps.type_int = true; ep-usb_ep.max_streams = 0; list_add_tail(ep-usb_ep.ep_list, bdc-gadget.ep_list); } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 10/46] usb: gadget: bcm63xx_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/bcm63xx_udc.c | 25 + 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c index 9db968b..c5e0894 100644 --- a/drivers/usb/gadget/udc/bcm63xx_udc.c +++ b/drivers/usb/gadget/udc/bcm63xx_udc.c @@ -44,9 +44,25 @@ #define DRV_MODULE_NAMEbcm63xx_udc static const char bcm63xx_ep0name[] = ep0; -static const char *const bcm63xx_ep_name[] = { - bcm63xx_ep0name, - ep1in-bulk, ep2out-bulk, ep3in-int, ep4out-int, + +static const struct { + const char *name; + const struct usb_ep_caps caps; +} bcm63xx_ep_info[] = { +#define EP_INFO(_name, _type, _dir) \ + { \ + .name = _name, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \ + USB_EP_CAPS_DIR_ ## _dir), \ + } + + EP_INFO(bcm63xx_ep0name, CONTROL, ALL), + EP_INFO(ep1in-bulk, BULK, IN), + EP_INFO(ep2out-bulk, BULK, OUT), + EP_INFO(ep3in-int,INT,IN), + EP_INFO(ep4out-int, INT,OUT), + +#undef EP_INFO }; static bool use_fullspeed; @@ -943,7 +959,8 @@ static int bcm63xx_init_udc_hw(struct bcm63xx_udc *udc) for (i = 0; i BCM63XX_NUM_EP; i++) { struct bcm63xx_ep *bep = udc-bep[i]; - bep-ep.name = bcm63xx_ep_name[i]; + bep-ep.name = bcm63xx_ep_info[i].name; + bep-ep.caps = bcm63xx_ep_info[i].caps; bep-ep_num = i; bep-ep.ops = bcm63xx_udc_ep_ops; list_add_tail(bep-ep.ep_list, udc-gadget.ep_list); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 12/46] usb: gadget: dummy-hcd: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/dummy_hcd.c | 65 +- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index 181112c..69fd29a 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c @@ -127,23 +127,57 @@ static inline struct dummy_request *usb_request_to_dummy_request static const char ep0name[] = ep0; -static const char *const ep_name[] = { - ep0name,/* everyone has ep0 */ +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info[] = { +#define EP_INFO(_name, _type, _dir) \ + { \ + .name = _name, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \ + USB_EP_CAPS_DIR_ ## _dir), \ + } + /* everyone has ep0 */ + EP_INFO(ep0name,CONTROL, ALL), /* act like a pxa250: fifteen fixed function endpoints */ - ep1in-bulk, ep2out-bulk, ep3in-iso, ep4out-iso, ep5in-int, - ep6in-bulk, ep7out-bulk, ep8in-iso, ep9out-iso, ep10in-int, - ep11in-bulk, ep12out-bulk, ep13in-iso, ep14out-iso, - ep15in-int, - + EP_INFO(ep1in-bulk, BULK, IN), + EP_INFO(ep2out-bulk, BULK, OUT), + EP_INFO(ep3in-iso,ISO,IN), + EP_INFO(ep4out-iso, ISO,OUT), + EP_INFO(ep5in-int,INT,IN), + EP_INFO(ep6in-bulk, BULK, IN), + EP_INFO(ep7out-bulk, BULK, OUT), + EP_INFO(ep8in-iso,ISO,IN), + EP_INFO(ep9out-iso, ISO,OUT), + EP_INFO(ep10in-int, INT,IN), + EP_INFO(ep11in-bulk, BULK, IN), + EP_INFO(ep12out-bulk, BULK, OUT), + EP_INFO(ep13in-iso, ISO,IN), + EP_INFO(ep14out-iso, ISO,OUT), + EP_INFO(ep15in-int, INT,IN), /* or like sa1100: two fixed function endpoints */ - ep1out-bulk, ep2in-bulk, - + EP_INFO(ep1out-bulk, BULK, OUT), + EP_INFO(ep2in-bulk, BULK, IN), /* and now some generic EPs so we have enough in multi config */ - ep3out, ep4in, ep5out, ep6out, ep7in, ep8out, ep9in, - ep10out, ep11out, ep12in, ep13out, ep14in, ep15out, + EP_INFO(ep3out, ALL,OUT), + EP_INFO(ep4in,ALL,IN), + EP_INFO(ep5out, ALL,OUT), + EP_INFO(ep6out, ALL,OUT), + EP_INFO(ep7in,ALL,IN), + EP_INFO(ep8out, ALL,OUT), + EP_INFO(ep9in,ALL,IN), + EP_INFO(ep10out, ALL,OUT), + EP_INFO(ep11out, ALL,OUT), + EP_INFO(ep12in, ALL,IN), + EP_INFO(ep13out, ALL,OUT), + EP_INFO(ep14in, ALL,IN), + EP_INFO(ep15out, ALL,OUT), + +#undef EP_INFO }; -#define DUMMY_ENDPOINTSARRAY_SIZE(ep_name) + +#define DUMMY_ENDPOINTSARRAY_SIZE(ep_info) /*-*/ @@ -938,9 +972,10 @@ static void init_dummy_udc_hw(struct dummy *dum) for (i = 0; i DUMMY_ENDPOINTS; i++) { struct dummy_ep *ep = dum-ep[i]; - if (!ep_name[i]) + if (!ep_info[i].name) break; - ep-ep.name = ep_name[i]; + ep-ep.name = ep_info[i].name; + ep-ep.caps = ep_info[i].caps; ep-ep.ops = dummy_ep_ops; list_add_tail(ep-ep.ep_list, dum-gadget.ep_list); ep-halted = ep-wedged = ep-already_seen = @@ -1684,7 +1719,7 @@ static void dummy_timer(unsigned long _dum_hcd) } for (i = 0; i DUMMY_ENDPOINTS; i++) { - if (!ep_name[i]) + if (!ep_info[i].name) break; dum-ep[i].already_seen = 0; } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 20/46] usb: gadget: m66592-udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/m66592-udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/m66592-udc.c b/drivers/usb/gadget/udc/m66592-udc.c index 309706f..e404553 100644 --- a/drivers/usb/gadget/udc/m66592-udc.c +++ b/drivers/usb/gadget/udc/m66592-udc.c @@ -1644,6 +1644,17 @@ static int m66592_probe(struct platform_device *pdev) ep-ep.name = m66592_ep_name[i]; ep-ep.ops = m66592_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, 512); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(m66592-ep[0].ep, 64); m66592-ep[0].pipenum = 0; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 28/46] usb: gadget: pxa27x_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/pxa27x_udc.h | 33 ++--- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/udc/pxa27x_udc.h b/drivers/usb/gadget/udc/pxa27x_udc.h index 11e1423..ded058c 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.h +++ b/drivers/usb/gadget/udc/pxa27x_udc.h @@ -234,25 +234,28 @@ /* * Endpoint definition helpers */ -#define USB_EP_DEF(addr, bname, dir, type, maxpkt) \ -{ .usb_ep = { .name = bname, .ops = pxa_ep_ops, .maxpacket = maxpkt, }, \ +#define USB_EP_DEF(addr, bname, dir, type, maxpkt, ctype, cdir) \ +{ .usb_ep = { .name = bname, .ops = pxa_ep_ops, .maxpacket = maxpkt, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## ctype, \ + USB_EP_CAPS_DIR_ ## cdir), }, \ .desc = {.bEndpointAddress = addr | (dir ? USB_DIR_IN : 0), \ - .bmAttributes = type, \ + .bmAttributes = USB_ENDPOINT_XFER_ ## type, \ .wMaxPacketSize = maxpkt, }, \ .dev = memory \ } -#define USB_EP_BULK(addr, bname, dir) \ - USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_BULK, BULK_FIFO_SIZE) -#define USB_EP_ISO(addr, bname, dir) \ - USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_ISOC, ISO_FIFO_SIZE) -#define USB_EP_INT(addr, bname, dir) \ - USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_INT, INT_FIFO_SIZE) -#define USB_EP_IN_BULK(n) USB_EP_BULK(n, ep #n in-bulk, 1) -#define USB_EP_OUT_BULK(n) USB_EP_BULK(n, ep #n out-bulk, 0) -#define USB_EP_IN_ISO(n) USB_EP_ISO(n, ep #n in-iso, 1) -#define USB_EP_OUT_ISO(n) USB_EP_ISO(n, ep #n out-iso, 0) -#define USB_EP_IN_INT(n) USB_EP_INT(n, ep #n in-int, 1) -#define USB_EP_CTRLUSB_EP_DEF(0, ep0, 0, 0, EP0_FIFO_SIZE) +#define USB_EP_BULK(addr, bname, dir, cdir) \ + USB_EP_DEF(addr, bname, dir, BULK, BULK_FIFO_SIZE, BULK, cdir) +#define USB_EP_ISO(addr, bname, dir, cdir) \ + USB_EP_DEF(addr, bname, dir, ISOC, ISO_FIFO_SIZE, ISO, cdir) +#define USB_EP_INT(addr, bname, dir, cdir) \ + USB_EP_DEF(addr, bname, dir, INT, INT_FIFO_SIZE, INT, cdir) +#define USB_EP_IN_BULK(n) USB_EP_BULK(n, ep #n in-bulk, 1, IN) +#define USB_EP_OUT_BULK(n) USB_EP_BULK(n, ep #n out-bulk, 0, OUT) +#define USB_EP_IN_ISO(n) USB_EP_ISO(n, ep #n in-iso, 1, IN) +#define USB_EP_OUT_ISO(n) USB_EP_ISO(n, ep #n out-iso, 0, OUT) +#define USB_EP_IN_INT(n) USB_EP_INT(n, ep #n in-int, 1, IN) +#define USB_EP_CTRLUSB_EP_DEF(0, ep0, 0, CONTROL, \ + EP0_FIFO_SIZE, CONTROL, ALL) #define PXA_EP_DEF(_idx, _addr, dir, _type, maxpkt, _config, iface, altset) \ { \ -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 27/46] usb: gadget: pxa25x_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/pxa25x_udc.c | 32 1 file changed, 32 insertions(+) diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c index f6cbe66..1301e29 100644 --- a/drivers/usb/gadget/udc/pxa25x_udc.c +++ b/drivers/usb/gadget/udc/pxa25x_udc.c @@ -1821,6 +1821,8 @@ static struct pxa25x_udc memory = { .name = ep0name, .ops= pxa25x_ep_ops, .maxpacket = EP0_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .reg_udccs = UDCCS0, @@ -1833,6 +1835,8 @@ static struct pxa25x_udc memory = { .name = ep1in-bulk, .ops= pxa25x_ep_ops, .maxpacket = BULK_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = BULK_FIFO_SIZE, @@ -1846,6 +1850,8 @@ static struct pxa25x_udc memory = { .name = ep2out-bulk, .ops= pxa25x_ep_ops, .maxpacket = BULK_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_OUT), }, .dev= memory, .fifo_size = BULK_FIFO_SIZE, @@ -1861,6 +1867,8 @@ static struct pxa25x_udc memory = { .name = ep3in-iso, .ops= pxa25x_ep_ops, .maxpacket = ISO_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = ISO_FIFO_SIZE, @@ -1874,6 +1882,8 @@ static struct pxa25x_udc memory = { .name = ep4out-iso, .ops= pxa25x_ep_ops, .maxpacket = ISO_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_OUT), }, .dev= memory, .fifo_size = ISO_FIFO_SIZE, @@ -1888,6 +1898,8 @@ static struct pxa25x_udc memory = { .name = ep5in-int, .ops= pxa25x_ep_ops, .maxpacket = INT_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = INT_FIFO_SIZE, @@ -1903,6 +1915,8 @@ static struct pxa25x_udc memory = { .name = ep6in-bulk, .ops= pxa25x_ep_ops, .maxpacket = BULK_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = BULK_FIFO_SIZE, @@ -1916,6 +1930,8 @@ static struct pxa25x_udc memory = { .name = ep7out-bulk, .ops= pxa25x_ep_ops, .maxpacket = BULK_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_OUT), }, .dev= memory, .fifo_size = BULK_FIFO_SIZE, @@ -1930,6 +1946,8 @@ static struct pxa25x_udc memory = { .name = ep8in-iso, .ops= pxa25x_ep_ops, .maxpacket = ISO_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = ISO_FIFO_SIZE, @@ -1943,6 +1961,8 @@ static struct pxa25x_udc memory = { .name = ep9out-iso, .ops= pxa25x_ep_ops, .maxpacket = ISO_FIFO_SIZE, +
[PATCH v3 34/46] usb: musb: gadget: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/musb/musb_gadget.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 625d482f..043248a 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1729,6 +1729,7 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) INIT_LIST_HEAD(ep-end_point.ep_list); if (!epnum) { usb_ep_set_maxpacket_limit(ep-end_point, 64); + ep-end_point.caps.type_control = true; ep-end_point.ops = musb_g_ep0_ops; musb-g.ep0 = ep-end_point; } else { @@ -1736,9 +1737,20 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) usb_ep_set_maxpacket_limit(ep-end_point, hw_ep-max_packet_sz_tx); else usb_ep_set_maxpacket_limit(ep-end_point, hw_ep-max_packet_sz_rx); + ep-end_point.caps.type_iso = true; + ep-end_point.caps.type_bulk = true; + ep-end_point.caps.type_int = true; ep-end_point.ops = musb_ep_ops; list_add_tail(ep-end_point.ep_list, musb-g.ep_list); } + + if (!epnum || hw_ep-is_shared_fifo) { + ep-end_point.caps.dir_in = true; + ep-end_point.caps.dir_out = true; + } else if (is_in) + ep-end_point.caps.dir_in = true; + else + ep-end_point.caps.dir_out = true; } /* -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 32/46] usb: gadget: udc-xilinx: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/udc-xilinx.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c index 1f24274..1cbb0ac 100644 --- a/drivers/usb/gadget/udc/udc-xilinx.c +++ b/drivers/usb/gadget/udc/udc-xilinx.c @@ -1317,12 +1317,21 @@ static void xudc_eps_init(struct xusb_udc *udc) snprintf(ep-name, EPNAME_SIZE, ep%d, ep_number); ep-ep_usb.name = ep-name; ep-ep_usb.ops = xusb_ep_ops; + + ep-ep_usb.caps.type_iso = true; + ep-ep_usb.caps.type_bulk = true; + ep-ep_usb.caps.type_int = true; } else { ep-ep_usb.name = ep0name; usb_ep_set_maxpacket_limit(ep-ep_usb, EP0_MAX_PACKET); ep-ep_usb.ops = xusb_ep0_ops; + + ep-ep_usb.caps.type_control = true; } + ep-ep_usb.caps.dir_in = true; + ep-ep_usb.caps.dir_out = true; + ep-udc = udc; ep-epnumber = ep_number; ep-desc = NULL; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 43/46] usb: gadget: move find_ep() from epautoconf to gadget.h
Move find_ep() function to gadget.h, rename it to gadget_find_ep_by_name() and make it static inline. It can be used in UDC drivers, especially in 'match_ep' callback after moving chip-specific endpoint matching logic from epautoconf to UDC drivers. Replace all calls of find_ep() function with gadget_find_ep_by_name(). Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 30 +- include/linux/usb/gadget.h | 18 ++ 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 3f0a380..cc0b084 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -22,18 +22,6 @@ #include gadget_chips.h -static struct usb_ep * -find_ep (struct usb_gadget *gadget, const char *name) -{ - struct usb_ep *ep; - - list_for_each_entry (ep, gadget-ep_list, ep_list) { - if (0 == strcmp (ep-name, name)) - return ep; - } - return NULL; -} - /** * usb_ep_autoconfig_ss() - choose an endpoint matching the ep * descriptor and ep companion descriptor @@ -103,11 +91,11 @@ struct usb_ep *usb_ep_autoconfig_ss( if (type == USB_ENDPOINT_XFER_INT) { /* ep-e, ep-f are PIO with only 64 byte fifos */ - ep = find_ep(gadget, ep-e); + ep = gadget_find_ep_by_name(gadget, ep-e); if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; - ep = find_ep(gadget, ep-f); + ep = gadget_find_ep_by_name(gadget, ep-f); if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; @@ -116,20 +104,20 @@ struct usb_ep *usb_ep_autoconfig_ss( /* USB3380: use same address for usb and hardware endpoints */ snprintf(name, sizeof(name), ep%d%s, usb_endpoint_num(desc), usb_endpoint_dir_in(desc) ? in : out); - ep = find_ep(gadget, name); + ep = gadget_find_ep_by_name(gadget, name); if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; } else if (gadget_is_goku (gadget)) { if (USB_ENDPOINT_XFER_INT == type) { /* single buffering is enough */ - ep = find_ep(gadget, ep3-bulk); + ep = gadget_find_ep_by_name(gadget, ep3-bulk); if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; } else if (USB_ENDPOINT_XFER_BULK == type (USB_DIR_IN desc-bEndpointAddress)) { /* DMA may be available */ - ep = find_ep(gadget, ep2-bulk); + ep = gadget_find_ep_by_name(gadget, ep2-bulk); if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; @@ -140,14 +128,14 @@ struct usb_ep *usb_ep_autoconfig_ss( if ((USB_ENDPOINT_XFER_BULK == type) || (USB_ENDPOINT_XFER_ISOC == type)) { if (USB_DIR_IN desc-bEndpointAddress) - ep = find_ep (gadget, ep5in); + ep = gadget_find_ep_by_name(gadget, ep5in); else - ep = find_ep (gadget, ep6out); + ep = gadget_find_ep_by_name(gadget, ep6out); } else if (USB_ENDPOINT_XFER_INT == type) { if (USB_DIR_IN desc-bEndpointAddress) - ep = find_ep(gadget, ep1in); + ep = gadget_find_ep_by_name(gadget, ep1in); else - ep = find_ep(gadget, ep2out); + ep = gadget_find_ep_by_name(gadget, ep2out); } else ep = NULL; if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 77e2c1e..42e951b 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -629,6 +629,24 @@ static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev) #define gadget_for_each_ep(tmp, gadget) \ list_for_each_entry(tmp, (gadget)-ep_list, ep_list) +/** + * gadget_find_ep_by_name - returns ep whose name is the same as sting passed + * in second parameter or NULL if
[RFC PATCH 01/12] powerpc/kernel: Get pt_regs from r9 before calling do_syscall_trace_enter()
To call do_syscall_trace_enter() we need pt_regs in r3, but we don't need to recalculate it based on r1, it's already in r9. Signed-off-by: Michael Ellerman m...@ellerman.id.au --- arch/powerpc/kernel/entry_64.S | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index 579e0f9a2d57..0796c487d3db 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S @@ -243,7 +243,9 @@ syscall_error: /* Traced system call support */ syscall_dotrace: bl save_nvgprs - addir3,r1,STACK_FRAME_OVERHEAD + + /* Get pt_regs into r3 */ + mr r3, r9 bl do_syscall_trace_enter /* * Restore argument registers possibly just changed. -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 07/46] usb: dwc3: gadget: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/dwc3/gadget.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 333a7c0..8d1f768 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1713,6 +1713,19 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc, return ret; } + if (epnum == 0) { + dep-endpoint.caps.type_control = true; + } else { + dep-endpoint.caps.type_iso = true; + dep-endpoint.caps.type_bulk = true; + dep-endpoint.caps.type_int = true; + } + + if (epnum 1) + dep-endpoint.caps.dir_in = true; + else + dep-endpoint.caps.dir_out = true; + INIT_LIST_HEAD(dep-request_list); INIT_LIST_HEAD(dep-req_queued); } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 17/46] usb: gadget: goku_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/goku_udc.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c index 9e8d842..46b8d14 100644 --- a/drivers/usb/gadget/udc/goku_udc.c +++ b/drivers/usb/gadget/udc/goku_udc.c @@ -1257,6 +1257,14 @@ static void udc_reinit (struct goku_udc *dev) INIT_LIST_HEAD (ep-queue); ep_reset(NULL, ep); + + if (i == 0) + ep-ep.caps.type_control = true; + else + ep-ep.caps.type_bulk = true; + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } dev-ep[0].reg_mode = NULL; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 24/46] usb: gadget: net2280: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/net2280.c | 50 ++-- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 2bee912..0295cf7 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -74,19 +74,41 @@ static const char driver_desc[] = DRIVER_DESC; static const u32 ep_bit[9] = { 0, 17, 2, 19, 4, 1, 18, 3, 20 }; static const char ep0name[] = ep0; -static const char *const ep_name[] = { - ep0name, - ep-a, ep-b, ep-c, ep-d, - ep-e, ep-f, ep-g, ep-h, -}; -/* Endpoint names for usb3380 advance mode */ -static const char *const ep_name_adv[] = { - ep0name, - ep1in, ep2out, ep3in, ep4out, - ep1out, ep2in, ep3out, ep4in, +#define EP_INFO(_name, _type, _dir) \ + { \ + .name = _name, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \ + USB_EP_CAPS_DIR_ ## _dir), \ + } + +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info_dft[] = { /* Default endpoint configuration */ + EP_INFO(ep0name, CONTROL, ALL), + EP_INFO(ep-a, ALL,ALL), + EP_INFO(ep-b, ALL,ALL), + EP_INFO(ep-c, ALL,ALL), + EP_INFO(ep-d, ALL,ALL), + EP_INFO(ep-e, ALL,ALL), + EP_INFO(ep-f, ALL,ALL), + EP_INFO(ep-g, ALL,ALL), + EP_INFO(ep-h, ALL,ALL), +}, ep_info_adv[] = { /* Endpoints for usb3380 advance mode */ + EP_INFO(ep0name, CONTROL, ALL), + EP_INFO(ep1in,ALL,IN), + EP_INFO(ep2out, ALL,OUT), + EP_INFO(ep3in,ALL,IN), + EP_INFO(ep4out, ALL,OUT), + EP_INFO(ep1out, ALL,OUT), + EP_INFO(ep2in,ALL,IN), + EP_INFO(ep3out, ALL,OUT), + EP_INFO(ep4in,ALL,IN), }; +#undef EP_INFO + /* mode 0 == ep-{a,b,c,d} 1K fifo each * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable * mode 2 == ep-a 2K fifo, ep-{b,c} 1K each, ep-d unavailable @@ -2055,7 +2077,8 @@ static void usb_reinit_228x(struct net2280 *dev) for (tmp = 0; tmp 7; tmp++) { struct net2280_ep *ep = dev-ep[tmp]; - ep-ep.name = ep_name[tmp]; + ep-ep.name = ep_info_dft[tmp].name; + ep-ep.caps = ep_info_dft[tmp].caps; ep-dev = dev; ep-num = tmp; @@ -2095,7 +2118,10 @@ static void usb_reinit_338x(struct net2280 *dev) for (i = 0; i dev-n_ep; i++) { struct net2280_ep *ep = dev-ep[i]; - ep-ep.name = dev-enhanced_mode ? ep_name_adv[i] : ep_name[i]; + ep-ep.name = dev-enhanced_mode ? ep_info_adv[i].name : + ep_info_dft[i].name; + ep-ep.caps = dev-enhanced_mode ? ep_info_adv[i].caps : + ep_info_dft[i].caps; ep-dev = dev; ep-num = i; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 33/46] usb: isp1760: udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/isp1760/isp1760-udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/isp1760/isp1760-udc.c b/drivers/usb/isp1760/isp1760-udc.c index 3699962..1c3d0fd 100644 --- a/drivers/usb/isp1760/isp1760-udc.c +++ b/drivers/usb/isp1760/isp1760-udc.c @@ -1383,13 +1383,24 @@ static void isp1760_udc_init_eps(struct isp1760_udc *udc) */ if (ep_num == 0) { usb_ep_set_maxpacket_limit(ep-ep, 64); + ep-ep.caps.type_control = true; + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; ep-maxpacket = 64; udc-gadget.ep0 = ep-ep; } else { usb_ep_set_maxpacket_limit(ep-ep, 512); + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; ep-maxpacket = 0; list_add_tail(ep-ep.ep_list, udc-gadget.ep_list); } + + if (is_in) + ep-ep.caps.dir_in = true; + else + ep-ep.caps.dir_out = true; } } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 37/46] usb: gadget: epautoconf: add endpoint capabilities flags verification
Introduce endpoint matching mechanism basing on endpoint capabilities flags. We check if endpoint supports transfer type and direction requested in ep descriptor. Since we have this new endpoint matching mechanism there is no need to have old code guessing endpoint capabilities basing on its name, so we are getting rid of it. Remove also the obsolete comment. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 96 + 1 file changed, 30 insertions(+), 66 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 8e00ca7..af4b10a 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -22,22 +22,6 @@ #include gadget_chips.h -/* - * This should work with endpoints from controller drivers sharing the - * same endpoint naming convention. By example: - * - * - ep1, ep2, ... address is fixed, not direction or type - * - ep1in, ep2out, ... address and direction are fixed, not type - * - ep1-bulk, ep2-bulk, ... address and type are fixed, not direction - * - ep1in-bulk, ep2out-iso, ... all three are fixed - * - ep-* ... no functionality restrictions - * - * Type suffixes are -bulk, -iso, or -int. Numbers are decimal. - * Less common restrictions are implied by gadget_is_*(). - * - * NOTE: each endpoint is unidirectional, as specified by its USB - * descriptor; and isn't specific to a configuration or altsetting. - */ static int ep_matches ( struct usb_gadget *gadget, @@ -47,7 +31,6 @@ ep_matches ( ) { u8 type; - const char *tmp; u16 max; int num_req_streams = 0; @@ -56,58 +39,39 @@ ep_matches ( if (ep-claimed) return 0; - /* only support ep0 for portable CONTROL traffic */ type = usb_endpoint_type(desc); - if (USB_ENDPOINT_XFER_CONTROL == type) - return 0; - - /* some other naming convention */ - if ('e' != ep-name[0]) + switch (type) { + case USB_ENDPOINT_XFER_CONTROL: + /* only support ep0 for portable CONTROL traffic */ return 0; + case USB_ENDPOINT_XFER_ISOC: + if (!ep-caps.type_iso) + return 0; + break; + case USB_ENDPOINT_XFER_BULK: + if (!ep-caps.type_bulk) + return 0; + break; + case USB_ENDPOINT_XFER_INT: + /* bulk endpoints handle interrupt transfers, +* except the toggle-quirky iso-synch kind +*/ + if (!ep-caps.type_int !ep-caps.type_bulk) + return 0; + /* for now, avoid PXA interrupt-in; +* it's documented as never using DATA1. +*/ + if (gadget_is_pxa(gadget) ep-caps.type_int) + return 0; + break; + } - /* type-restriction: -iso, -bulk, or -int. -* direction-restriction: in, out. -*/ - if ('-' != ep-name[2]) { - tmp = strrchr (ep-name, '-'); - if (tmp) { - switch (type) { - case USB_ENDPOINT_XFER_INT: - /* bulk endpoints handle interrupt transfers, -* except the toggle-quirky iso-synch kind -*/ - if ('s' == tmp[2]) // == -iso - return 0; - /* for now, avoid PXA interrupt-in; -* it's documented as never using DATA1. -*/ - if (gadget_is_pxa (gadget) -'i' == tmp [1]) - return 0; - break; - case USB_ENDPOINT_XFER_BULK: - if ('b' != tmp[1]) // != -bulk - return 0; - break; - case USB_ENDPOINT_XFER_ISOC: - if ('s' != tmp[2]) // != -iso - return 0; - } - } else { - tmp = ep-name + strlen (ep-name); - } - - /* direction-restriction: ..in-.., out-.. */ - tmp--; - if (!isdigit (*tmp)) { - if (desc-bEndpointAddress USB_DIR_IN) { - if ('n' != *tmp) - return 0; - } else { - if ('t' != *tmp) - return 0; -
[PATCH v3 38/46] usb: gadget: epautoconf: remove pxa quirk from ep_matches()
The same effect can be achieved by using capabilities flags, so now we can get rid of handling of hardware specific limitations in generic code. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 5 - drivers/usb/gadget/udc/pxa25x_udc.c | 9 +++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index af4b10a..4f66e9d73 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -58,11 +58,6 @@ ep_matches ( */ if (!ep-caps.type_int !ep-caps.type_bulk) return 0; - /* for now, avoid PXA interrupt-in; -* it's documented as never using DATA1. -*/ - if (gadget_is_pxa(gadget) ep-caps.type_int) - return 0; break; } diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c index 1301e29..f53e526 100644 --- a/drivers/usb/gadget/udc/pxa25x_udc.c +++ b/drivers/usb/gadget/udc/pxa25x_udc.c @@ -1898,8 +1898,7 @@ static struct pxa25x_udc memory = { .name = ep5in-int, .ops= pxa25x_ep_ops, .maxpacket = INT_FIFO_SIZE, - .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, - USB_EP_CAPS_DIR_IN), + .caps = USB_EP_CAPS(0, 0), }, .dev= memory, .fifo_size = INT_FIFO_SIZE, @@ -1977,8 +1976,7 @@ static struct pxa25x_udc memory = { .name = ep10in-int, .ops= pxa25x_ep_ops, .maxpacket = INT_FIFO_SIZE, - .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, - USB_EP_CAPS_DIR_IN), + .caps = USB_EP_CAPS(0, 0), }, .dev= memory, .fifo_size = INT_FIFO_SIZE, @@ -2056,8 +2054,7 @@ static struct pxa25x_udc memory = { .name = ep15in-int, .ops= pxa25x_ep_ops, .maxpacket = INT_FIFO_SIZE, - .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, - USB_EP_CAPS_DIR_IN), + .caps = USB_EP_CAPS(0, 0), }, .dev= memory, .fifo_size = INT_FIFO_SIZE, -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 00/46] usb: gadget: rework ep matching and claiming mechanism
Hello, This patch series reworks endpoint matching and claiming mechanism in epautoconf. From v2 there are couple of new patches adding 'ep_match' to usb_gadget_ops and removing chip-specific quirk handling from generic code of autoconfig. I'm not sure if this patch set isn't too long, as it has 46 patches, but I decided to send it as single series to avoid problems with patch applying order. The aim of whole patchset is to rework epautoconf code to get rid of things like name-based endpoint matching and UDC name-based quirks in generic code. These needed to do some modifications in framework like adding 'endpoint capabilities flags' feature or adding 'match_ep'. Following paragraphs contain brief description of what modifications are done by particular parts of this patch set: Patch (1) introduces new safer endpoint claiming method, basing on new 'claimed' flag. It was discussed here [1]. I proposed this solution over year ago and it was accepted, but I apparently forgot to send the final version of my patch. Patches (2-3) add the 'capabilities flags' structure and helper macros. This solution is inspired by the 'feature flags' originally proposed by Felipe Balbi in 2013 [2], but unfortunately implementation of this feature has never been completed. Patches (4-36) add' capabilites flags' support to all UDC drivers present in the kernel tree. It's needed to be done before replacing old endpoint matching mechanism, otherwise UDC drivers which doesn't set 'capabilities flags' won't work with new matching function. Patch (37) finally replaces old endpoint matching method with the new one basing on capabilities flags. These changes aims to get rid of code, which guesses endpoint capabilities basing on it's name, and introduce new better replacement. In result we have better way to describe types and directions supported by each endpoint. For example the old name-based method didn't allow to have endpoint supporing two types of transfers - there were only ability to support one or all of endpoint types. The 'capabilities flags' feature supply precise, flexible and extensible mechanism of description of endpoint hardware limitations, which is desired for proper endpoint matching. Patch (38) removes chip-specific quirk from ep_matches() function. Patches (39-40) remove code modifying endpoint and descriptor structures from ep_matches() function and cleans it up to make it simpler and more readable. Patch (41) add 'match_ep' callback to usb_gadget_ops and make use of it in epautoconf. This callback allows UDC drivers to supply non-standard endpoint matching algorithms. Patches (42-43) move ep_matches() and find_ep() functions outside epautoconf and rename them to usb_gadget_ep_match_desc() and gadget_find_ep_by_name(). It's because they may be useful in 'match_ep' callbacks in UDC drivers to avoid writing repetitive code. Patches (44-46) move chip-specific enpoint matching algorithms from generic code of usb_ep_autoconfig_ss() function to UDC controller drivers using 'match_ep' callback. In the result we have epautoconf source free of chip-specific code, plus two new mechanisms allowing to handle non-standard hardware limitations. [1] https://lkml.org/lkml/2014/6/16/94 [2] http://www.spinics.net/lists/linux-usb/msg99662.html Best regards, Robert Baldyga Changelog: v3: - addressed comments from Sergei Shtylyov v2: https://lkml.org/lkml/2015/7/14/172 - remove PXA quirk from ep_matches() function without behaviour change using ep capabilities flags - separate ep and desc configuration code from ep_match() function - add 'ep_match' to usb_gadget_ops and move chip-specific endpoint matching algorithms from generic code to UDC controller drivers v1: https://lkml.org/lkml/2015/7/8/436 Robert Baldyga (46): usb: gadget: encapsulate endpoint claiming mechanism usb: gadget: add endpoint capabilities flags usb: gadget: add endpoint capabilities helper macros staging: emxx_udc: add ep capabilities support usb: chipidea: udc: add ep capabilities support usb: dwc2: gadget: add ep capabilities support usb: dwc3: gadget: add ep capabilities support usb: gadget: amd5536udc: add ep capabilities support usb: gadget: at91_udc: add ep capabilities support usb: gadget: bcm63xx_udc: add ep capabilities support usb: gadget: bdc: add ep capabilities support usb: gadget: dummy-hcd: add ep capabilities support usb: gadget: fotg210-udc: add ep capabilities support usb: gadget: fsl_qe_udc: add ep capabilities support usb: gadget: fsl_udc_core: add ep capabilities support usb: gadget: fusb300_udc: add ep capabilities support usb: gadget: goku_udc: add ep capabilities support usb: gadget: gr_udc: add ep capabilities support usb: gadget: lpc32xx_udc: add ep capabilities support usb: gadget: m66592-udc: add ep capabilities support usb: gadget: mv_u3d_core: add ep capabilities support usb: gadget: mv_udc_core: add ep capabilities support usb: gadget: net2272: add ep
[PATCH v3 16/46] usb: gadget: fusb300_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/fusb300_udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/fusb300_udc.c b/drivers/usb/gadget/udc/fusb300_udc.c index 3970f45..948845c 100644 --- a/drivers/usb/gadget/udc/fusb300_udc.c +++ b/drivers/usb/gadget/udc/fusb300_udc.c @@ -1450,6 +1450,17 @@ static int fusb300_probe(struct platform_device *pdev) ep-ep.name = fusb300_ep_name[i]; ep-ep.ops = fusb300_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, HS_BULK_MAX_PACKET_SIZE); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(fusb300-ep[0]-ep, HS_CTL_MAX_PACKET_SIZE); fusb300-ep[0]-epnum = 0; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 21/46] usb: gadget: mv_u3d_core: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/mv_u3d_core.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c index ea35a24..4c48969 100644 --- a/drivers/usb/gadget/udc/mv_u3d_core.c +++ b/drivers/usb/gadget/udc/mv_u3d_core.c @@ -1324,6 +1324,9 @@ static int mv_u3d_eps_init(struct mv_u3d *u3d) ep-ep.ops = mv_u3d_ep_ops; ep-wedge = 0; usb_ep_set_maxpacket_limit(ep-ep, MV_U3D_EP0_MAX_PKT_SIZE); + ep-ep.caps.type_control = true; + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; ep-ep_num = 0; ep-ep.desc = mv_u3d_ep0_desc; INIT_LIST_HEAD(ep-queue); @@ -1339,14 +1342,20 @@ static int mv_u3d_eps_init(struct mv_u3d *u3d) if (i 1) { snprintf(name, sizeof(name), ep%din, i 1); ep-direction = MV_U3D_EP_DIR_IN; + ep-ep.caps.dir_in = true; } else { snprintf(name, sizeof(name), ep%dout, i 1); ep-direction = MV_U3D_EP_DIR_OUT; + ep-ep.caps.dir_out = true; } ep-u3d = u3d; strncpy(ep-name, name, sizeof(ep-name)); ep-ep.name = ep-name; + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + ep-ep.ops = mv_u3d_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0); ep-ep_num = i / 2; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 26/46] usb: gadget: pch_ud: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/pch_udc.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c index 613547f..cc8fb3c 100644 --- a/drivers/usb/gadget/udc/pch_udc.c +++ b/drivers/usb/gadget/udc/pch_udc.c @@ -2895,11 +2895,21 @@ static void pch_udc_pcd_reinit(struct pch_udc_dev *dev) ep-in = ~i 1; ep-ep.name = ep_string[i]; ep-ep.ops = pch_udc_ep_ops; - if (ep-in) + if (ep-in) { ep-offset_addr = ep-num * UDC_EP_REG_SHIFT; - else + ep-ep.caps.dir_in = true; + } else { ep-offset_addr = (UDC_EPINT_OUT_SHIFT + ep-num) * UDC_EP_REG_SHIFT; + ep-ep.caps.dir_out = true; + } + if (i == UDC_EP0IN_IDX || i == UDC_EP0OUT_IDX) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } /* need to set ep-ep.maxpacket and set Default Configuration?*/ usb_ep_set_maxpacket_limit(ep-ep, UDC_BULK_MAX_PKT_SIZE); list_add_tail(ep-ep.ep_list, dev-gadget.ep_list); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 25/46] usb: gadget: omap_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/omap_udc.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/drivers/usb/gadget/udc/omap_udc.c b/drivers/usb/gadget/udc/omap_udc.c index e2fcdb8..9b7d394 100644 --- a/drivers/usb/gadget/udc/omap_udc.c +++ b/drivers/usb/gadget/udc/omap_udc.c @@ -2579,6 +2579,28 @@ omap_ep_setup(char *name, u8 addr, u8 type, ep-double_buf = dbuf; ep-udc = udc; + switch (type) { + case USB_ENDPOINT_XFER_CONTROL: + ep-ep.caps.type_control = true; + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; + break; + case USB_ENDPOINT_XFER_ISOC: + ep-ep.caps.type_iso = true; + break; + case USB_ENDPOINT_XFER_BULK: + ep-ep.caps.type_bulk = true; + break; + case USB_ENDPOINT_XFER_INT: + ep-ep.caps.type_int = true; + break; + }; + + if (addr USB_DIR_IN) + ep-ep.caps.dir_in = true; + else + ep-ep.caps.dir_out = true; + ep-ep.name = ep-name; ep-ep.ops = omap_ep_ops; ep-maxpacket = maxp; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 35/46] usb: renesas: gadget: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/renesas_usbhs/mod_gadget.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index dc2aa32..ed8d890 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c @@ -1041,12 +1041,18 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv) if (usbhsg_is_dcp(uep)) { gpriv-gadget.ep0 = uep-ep; usb_ep_set_maxpacket_limit(uep-ep, 64); + uep-ep.caps.type_control = true; } /* init normal pipe */ else { usb_ep_set_maxpacket_limit(uep-ep, 512); + uep-ep.caps.type_iso = true; + uep-ep.caps.type_bulk = true; + uep-ep.caps.type_int = true; list_add_tail(uep-ep.ep_list, gpriv-gadget.ep_list); } + uep-ep.caps.dir_in = true; + uep-ep.caps.dir_out = true; } ret = usb_add_gadget_udc(dev, gpriv-gadget); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 45/46] usb: gadget: goku_udc: add goku_match_ep() function
Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching process. Function does the same that was done by chip-specific code inside of epautoconf. Now this code can be removed from there to separate generic code from platform specific logic. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 20 ++-- drivers/usb/gadget/udc/goku_udc.c | 25 + 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index d41fd82..da45371 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -86,24 +86,8 @@ struct usb_ep *usb_ep_autoconfig_ss( /* First, apply chip-specific best usage knowledge. * This might make a good usb_gadget_ops hook ... */ - if (gadget_is_goku (gadget)) { - if (USB_ENDPOINT_XFER_INT == type) { - /* single buffering is enough */ - ep = gadget_find_ep_by_name(gadget, ep3-bulk); - if (ep usb_gadget_ep_match_desc(gadget, - ep, desc, ep_comp)) - goto found_ep; - } else if (USB_ENDPOINT_XFER_BULK == type -(USB_DIR_IN desc-bEndpointAddress)) { - /* DMA may be available */ - ep = gadget_find_ep_by_name(gadget, ep2-bulk); - if (ep usb_gadget_ep_match_desc(gadget, - ep, desc, ep_comp)) - goto found_ep; - } - #ifdef CONFIG_BLACKFIN - } else if (gadget_is_musbhdrc(gadget)) { + if (gadget_is_musbhdrc(gadget)) { if ((USB_ENDPOINT_XFER_BULK == type) || (USB_ENDPOINT_XFER_ISOC == type)) { if (USB_DIR_IN desc-bEndpointAddress) @@ -119,8 +103,8 @@ struct usb_ep *usb_ep_autoconfig_ss( ep = NULL; if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; -#endif } +#endif /* Second, look at endpoints until an unclaimed one looks usable */ list_for_each_entry (ep, gadget-ep_list, ep_list) { diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c index 46b8d14..d5a93ea 100644 --- a/drivers/usb/gadget/udc/goku_udc.c +++ b/drivers/usb/gadget/udc/goku_udc.c @@ -990,6 +990,30 @@ static int goku_get_frame(struct usb_gadget *_gadget) return -EOPNOTSUPP; } +static struct usb_ep *goku_match_ep(struct usb_gadget *g, + struct usb_endpoint_descriptor *desc, + struct usb_ss_ep_comp_descriptor *ep_comp) +{ + struct goku_udc *dev = to_goku_udc(g); + struct usb_ep *ep; + u8 type = usb_endpoint_type(desc); + + if (type == USB_ENDPOINT_XFER_INT) { + /* single buffering is enough */ + ep = dev-ep[3].ep; + if (ep usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) + return ep; + } else if (type == USB_ENDPOINT_XFER_BULK +usb_endpoint_dir_in(desc)) { + /* DMA may be available */ + ep = dev-ep[2].ep; + if (ep usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) + return ep; + } + + return NULL; +} + static int goku_udc_start(struct usb_gadget *g, struct usb_gadget_driver *driver); static int goku_udc_stop(struct usb_gadget *g); @@ -998,6 +1022,7 @@ static const struct usb_gadget_ops goku_ops = { .get_frame = goku_get_frame, .udc_start = goku_udc_start, .udc_stop = goku_udc_stop, + .match_ep = goku_match_ep, // no remote wakeup // not selfpowered }; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 44/46] usb: gadget: net2280: add net2280_match_ep() function
Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching process. Function does the same that was done by chip-specific code inside of epautoconf. Now this code can be removed from there to separate generic code from platform specific logic. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 23 +-- drivers/usb/gadget/udc/net2280.c | 31 +++ 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index cc0b084..d41fd82 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -86,28 +86,7 @@ struct usb_ep *usb_ep_autoconfig_ss( /* First, apply chip-specific best usage knowledge. * This might make a good usb_gadget_ops hook ... */ - if (gadget_is_net2280(gadget)) { - char name[8]; - - if (type == USB_ENDPOINT_XFER_INT) { - /* ep-e, ep-f are PIO with only 64 byte fifos */ - ep = gadget_find_ep_by_name(gadget, ep-e); - if (ep usb_gadget_ep_match_desc(gadget, - ep, desc, ep_comp)) - goto found_ep; - ep = gadget_find_ep_by_name(gadget, ep-f); - if (ep usb_gadget_ep_match_desc(gadget, - ep, desc, ep_comp)) - goto found_ep; - } - - /* USB3380: use same address for usb and hardware endpoints */ - snprintf(name, sizeof(name), ep%d%s, usb_endpoint_num(desc), - usb_endpoint_dir_in(desc) ? in : out); - ep = gadget_find_ep_by_name(gadget, name); - if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) - goto found_ep; - } else if (gadget_is_goku (gadget)) { + if (gadget_is_goku (gadget)) { if (USB_ENDPOINT_XFER_INT == type) { /* single buffering is enough */ ep = gadget_find_ep_by_name(gadget, ep3-bulk); diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 0295cf7..41e6568 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -1533,6 +1533,36 @@ static int net2280_pullup(struct usb_gadget *_gadget, int is_on) return 0; } +static struct usb_ep *net2280_match_ep(struct usb_gadget *_gadget, + struct usb_endpoint_descriptor *desc, + struct usb_ss_ep_comp_descriptor *ep_comp) +{ + char name[8]; + struct usb_ep *ep; + u8 type; + + type = usb_endpoint_type(desc); + + if (type == USB_ENDPOINT_XFER_INT) { + /* ep-e, ep-f are PIO with only 64 byte fifos */ + ep = gadget_find_ep_by_name(_gadget, ep-e); + if (ep usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp)) + return ep; + ep = gadget_find_ep_by_name(_gadget, ep-f); + if (ep usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp)) + return ep; + } + + /* USB3380: use same address for usb and hardware endpoints */ + snprintf(name, sizeof(name), ep%d%s, usb_endpoint_num(desc), + usb_endpoint_dir_in(desc) ? in : out); + ep = gadget_find_ep_by_name(_gadget, name); + if (ep usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp)) + return ep; + + return NULL; +} + static int net2280_start(struct usb_gadget *_gadget, struct usb_gadget_driver *driver); static int net2280_stop(struct usb_gadget *_gadget); @@ -1544,6 +1574,7 @@ static const struct usb_gadget_ops net2280_ops = { .pullup = net2280_pullup, .udc_start = net2280_start, .udc_stop = net2280_stop, + .match_ep = net2280_match_ep, }; /*-*/ -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 6/6] cputime: Introduce cputime_to_timespec64()/timespec64_to_cputime()
The cputime_to_timespec() and timespec_to_cputime() functions are not year 2038 safe on 32bit systems due to that the struct timepsec will overflow in 2038 year. This patch introduces cputime_to_timespec64() and timespec64_to_cputime() functions which use struct timespec64. And converts arch specific implementations in arch/s390 and arch/powerpc. Signed-off-by: Baolin Wang baolin.w...@linaro.org --- arch/powerpc/include/asm/cputime.h|6 +++--- arch/s390/include/asm/cputime.h |8 include/asm-generic/cputime_jiffies.h | 10 +- include/asm-generic/cputime_nsecs.h |6 +++--- include/linux/cputime.h | 16 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h index e245255..5dda5c0 100644 --- a/arch/powerpc/include/asm/cputime.h +++ b/arch/powerpc/include/asm/cputime.h @@ -154,9 +154,9 @@ static inline cputime_t secs_to_cputime(const unsigned long sec) } /* - * Convert cputime - timespec + * Convert cputime - timespec64 */ -static inline void cputime_to_timespec(const cputime_t ct, struct timespec *p) +static inline void cputime_to_timespec64(const cputime_t ct, struct timespec64 *p) { u64 x = (__force u64) ct; unsigned int frac; @@ -168,7 +168,7 @@ static inline void cputime_to_timespec(const cputime_t ct, struct timespec *p) p-tv_nsec = x; } -static inline cputime_t timespec_to_cputime(const struct timespec *p) +static inline cputime_t timespec64_to_cputime(const struct timespec64 *p) { u64 ct; diff --git a/arch/s390/include/asm/cputime.h b/arch/s390/include/asm/cputime.h index 221b454..3319b51 100644 --- a/arch/s390/include/asm/cputime.h +++ b/arch/s390/include/asm/cputime.h @@ -81,16 +81,16 @@ static inline cputime_t secs_to_cputime(const unsigned int s) } /* - * Convert cputime to timespec and back. + * Convert cputime to timespec64 and back. */ -static inline cputime_t timespec_to_cputime(const struct timespec *value) +static inline cputime_t timespec64_to_cputime(const struct timespec64 *value) { unsigned long long ret = value-tv_sec * CPUTIME_PER_SEC; return (__force cputime_t)(ret + __div(value-tv_nsec * CPUTIME_PER_USEC, NSEC_PER_USEC)); } -static inline void cputime_to_timespec(const cputime_t cputime, - struct timespec *value) +static inline void cputime_to_timespec64(const cputime_t cputime, +struct timespec64 *value) { unsigned long long __cputime = (__force unsigned long long) cputime; value-tv_nsec = (__cputime % CPUTIME_PER_SEC) * NSEC_PER_USEC / CPUTIME_PER_USEC; diff --git a/include/asm-generic/cputime_jiffies.h b/include/asm-generic/cputime_jiffies.h index fe386fc..54e034c 100644 --- a/include/asm-generic/cputime_jiffies.h +++ b/include/asm-generic/cputime_jiffies.h @@ -44,12 +44,12 @@ typedef u64 __nocast cputime64_t; #define secs_to_cputime(sec) jiffies_to_cputime((sec) * HZ) /* - * Convert cputime to timespec and back. + * Convert cputime to timespec64 and back. */ -#define timespec_to_cputime(__val) \ - jiffies_to_cputime(timespec_to_jiffies(__val)) -#define cputime_to_timespec(__ct,__val)\ - jiffies_to_timespec(cputime_to_jiffies(__ct),__val) +#define timespec64_to_cputime(__val) \ + jiffies_to_cputime(timespec64_to_jiffies(__val)) +#define cputime_to_timespec64(__ct,__val) \ + jiffies_to_timespec64(cputime_to_jiffies(__ct),__val) /* * Convert cputime to timeval and back. diff --git a/include/asm-generic/cputime_nsecs.h b/include/asm-generic/cputime_nsecs.h index 0419485..c0cafc0 100644 --- a/include/asm-generic/cputime_nsecs.h +++ b/include/asm-generic/cputime_nsecs.h @@ -71,14 +71,14 @@ typedef u64 __nocast cputime64_t; (__force cputime_t)((__secs) * NSEC_PER_SEC) /* - * Convert cputime - timespec (nsec) + * Convert cputime - timespec64 (nsec) */ -static inline cputime_t timespec_to_cputime(const struct timespec *val) +static inline cputime_t timespec64_to_cputime(const struct timespec64 *val) { u64 ret = val-tv_sec * NSEC_PER_SEC + val-tv_nsec; return (__force cputime_t) ret; } -static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val) +static inline void cputime_to_timespec64(const cputime_t ct, struct timespec64 *val) { u32 rem; diff --git a/include/linux/cputime.h b/include/linux/cputime.h index f2eb2ee..cd638a0 100644 --- a/include/linux/cputime.h +++ b/include/linux/cputime.h @@ -13,4 +13,20 @@ usecs_to_cputime((__nsecs) / NSEC_PER_USEC) #endif +static inline cputime_t timespec_to_cputime(const struct timespec *ts) +{ + struct timespec64 ts64 = timespec_to_timespec64(*ts); + + return timespec64_to_cputime(ts64); +} + +static inline void cputime_to_timespec(const cputime_t cputime, +
[PATCH v3 02/46] usb: gadget: add endpoint capabilities flags
Introduce struct usb_ep_caps which contains information about capabilities of usb endpoints - supported transfer types and directions. This structure should be filled by UDC driver for each of its endpoints, and will be used in epautoconf in new ep matching mechanism which will replace ugly guessing of endpoint capabilities basing on its name. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- include/linux/usb/gadget.h | 21 + 1 file changed, 21 insertions(+) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index fcb0a4e..6f3e0fb 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -141,10 +141,29 @@ struct usb_ep_ops { }; /** + * struct usb_ep_caps - endpoint capabilities description + * @type_control:Endpoint supports control type (reserved for ep0). + * @type_iso:Endpoint supports isochronous transfers. + * @type_bulk:Endpoint supports bulk transfers. + * @type_int:Endpoint supports interrupt transfers. + * @dir_in:Endpoint supports IN direction. + * @dir_out:Endpoint supports OUT direction. + */ +struct usb_ep_caps { + unsigned type_control:1; + unsigned type_iso:1; + unsigned type_bulk:1; + unsigned type_int:1; + unsigned dir_in:1; + unsigned dir_out:1; +}; + +/** * struct usb_ep - device side representation of USB endpoint * @name:identifier for the endpoint, such as ep-a or ep9in-bulk * @ops: Function pointers used to access hardware-specific operations. * @ep_list:the gadget's ep_list holds all of its endpoints + * @caps:The structure describing types and directions supported by endoint. * @maxpacket:The maximum packet size used on this endpoint. The initial * value can sometimes be reduced (hardware allowing), according to * the endpoint descriptor used to configure the endpoint. @@ -167,12 +186,14 @@ struct usb_ep_ops { * gadget-ep_list. the control endpoint (gadget-ep0) is not in that list, * and is accessed only in response to a driver setup() callback. */ + struct usb_ep { void*driver_data; const char *name; const struct usb_ep_ops *ops; struct list_headep_list; + struct usb_ep_caps caps; boolclaimed; unsignedmaxpacket:16; unsignedmaxpacket_limit:16; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 05/46] usb: chipidea: udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/chipidea/udc.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 764f668..eff7cfb 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1624,6 +1624,20 @@ static int init_eps(struct ci_hdrc *ci) hwep-ep.name = hwep-name; hwep-ep.ops = usb_ep_ops; + + if (i == 0) { + hwep-ep.caps.type_control = true; + } else { + hwep-ep.caps.type_iso = true; + hwep-ep.caps.type_bulk = true; + hwep-ep.caps.type_int = true; + } + + if (j == TX) + hwep-ep.caps.dir_in = true; + else + hwep-ep.caps.dir_out = true; + /* * for ep0: maxP defined in desc, for other * eps, maxP is set by epautoconfig() called -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 06/46] usb: dwc2: gadget: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/dwc2/gadget.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 4d47b7c..8771b66 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3289,6 +3289,19 @@ static void s3c_hsotg_initep(struct dwc2_hsotg *hsotg, usb_ep_set_maxpacket_limit(hs_ep-ep, epnum ? 1024 : EP0_MPS_LIMIT); hs_ep-ep.ops = s3c_hsotg_ep_ops; + if (epnum == 0) { + hs_ep-ep.caps.type_control = true; + } else { + hs_ep-ep.caps.type_iso = true; + hs_ep-ep.caps.type_bulk = true; + hs_ep-ep.caps.type_int = true; + } + + if (dir_in) + hs_ep-ep.caps.dir_in = true; + else + hs_ep-ep.caps.dir_out = true; + /* * if we're using dma, we need to set the next-endpoint pointer * to be something valid. -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 23/46] usb: gadget: net2272: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/net2272.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c index 195baf3..34ec1ec 100644 --- a/drivers/usb/gadget/udc/net2272.c +++ b/drivers/usb/gadget/udc/net2272.c @@ -1404,6 +1404,17 @@ net2272_usb_reinit(struct net2272 *dev) else ep-fifo_size = 64; net2272_ep_reset(ep); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(dev-ep[0].ep, 64); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 31/46] usb: gadget: s3c2410_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/s3c2410_udc.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c index 5d9aa81..eb3571e 100644 --- a/drivers/usb/gadget/udc/s3c2410_udc.c +++ b/drivers/usb/gadget/udc/s3c2410_udc.c @@ -1691,6 +1691,8 @@ static struct s3c2410_udc memory = { .name = ep0name, .ops= s3c2410_ep_ops, .maxpacket = EP0_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, }, @@ -1702,6 +1704,8 @@ static struct s3c2410_udc memory = { .name = ep1-bulk, .ops= s3c2410_ep_ops, .maxpacket = EP_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .fifo_size = EP_FIFO_SIZE, @@ -1714,6 +1718,8 @@ static struct s3c2410_udc memory = { .name = ep2-bulk, .ops= s3c2410_ep_ops, .maxpacket = EP_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .fifo_size = EP_FIFO_SIZE, @@ -1726,6 +1732,8 @@ static struct s3c2410_udc memory = { .name = ep3-bulk, .ops= s3c2410_ep_ops, .maxpacket = EP_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .fifo_size = EP_FIFO_SIZE, @@ -1738,6 +1746,8 @@ static struct s3c2410_udc memory = { .name = ep4-bulk, .ops= s3c2410_ep_ops, .maxpacket = EP_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .fifo_size = EP_FIFO_SIZE, -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 29/46] usb: gadget: r8a66597-udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/r8a66597-udc.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c index 0293f71..baa0609 100644 --- a/drivers/usb/gadget/udc/r8a66597-udc.c +++ b/drivers/usb/gadget/udc/r8a66597-udc.c @@ -1935,6 +1935,16 @@ static int r8a66597_probe(struct platform_device *pdev) ep-ep.name = r8a66597_ep_name[i]; ep-ep.ops = r8a66597_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, 512); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(r8a66597-ep[0].ep, 64); r8a66597-ep[0].pipenum = 0; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 40/46] usb: gadget: epautoconf: rework ep_matches() function
Rework ep_matches() function to make it shorter and more readable. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 87 + 1 file changed, 35 insertions(+), 52 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 7bb28f1..4fa6f5d 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -30,16 +30,29 @@ ep_matches ( struct usb_ss_ep_comp_descriptor *ep_comp ) { - u8 type; - u16 max; - - int num_req_streams = 0; + u8 type; + u16 max; + int num_req_streams = 0; /* endpoint already claimed? */ if (ep-claimed) return 0; type = usb_endpoint_type(desc); + max = 0x7ff usb_endpoint_maxp(desc); + + if (usb_endpoint_dir_in(desc) !ep-caps.dir_in) + return 0; + else if (!ep-caps.dir_out) + return 0; + + if (max ep-maxpacket_limit) + return 0; + + /* high bandwidth works only at high speed */ + if (!gadget_is_dualspeed(gadget) usb_endpoint_maxp(desc) (311)) + return 0; + switch (type) { case USB_ENDPOINT_XFER_CONTROL: /* only support ep0 for portable CONTROL traffic */ @@ -47,66 +60,36 @@ ep_matches ( case USB_ENDPOINT_XFER_ISOC: if (!ep-caps.type_iso) return 0; + /* ISO: limit 1023 bytes full speed, +* 1024 high/super speed +*/ + if (!gadget_is_dualspeed(gadget) max 1023) + return 0; break; case USB_ENDPOINT_XFER_BULK: if (!ep-caps.type_bulk) return 0; + if (ep_comp gadget_is_superspeed(gadget)) { + /* Get the number of required streams from the +* EP companion descriptor and see if the EP +* matches it +*/ + num_req_streams = ep_comp-bmAttributes 0x1f; + if (num_req_streams ep-max_streams) + return 0; + } break; case USB_ENDPOINT_XFER_INT: - /* bulk endpoints handle interrupt transfers, + /* Bulk endpoints handle interrupt transfers, * except the toggle-quirky iso-synch kind */ if (!ep-caps.type_int !ep-caps.type_bulk) return 0; - break; - } - - if (usb_endpoint_dir_in(desc)) { - if (!ep-caps.dir_in) - return 0; - } else { - if (!ep-caps.dir_out) - return 0; - } - - /* -* Get the number of required streams from the EP companion -* descriptor and see if the EP matches it -*/ - if (usb_endpoint_xfer_bulk(desc)) { - if (ep_comp gadget-max_speed = USB_SPEED_SUPER) { - num_req_streams = ep_comp-bmAttributes 0x1f; - if (num_req_streams ep-max_streams) - return 0; - } - - } - - /* endpoint maxpacket size is an input parameter, except for bulk -* where it's an output parameter representing the full speed limit. -* the usb spec fixes high speed bulk maxpacket at 512 bytes. -*/ - max = 0x7ff usb_endpoint_maxp(desc); - switch (type) { - case USB_ENDPOINT_XFER_INT: - /* INT: limit 64 bytes full speed, 1024 high/super speed */ + /* INT: limit 64 bytes full speed, +* 1024 high/super speed +*/ if (!gadget_is_dualspeed(gadget) max 64) return 0; - /* FALLTHROUGH */ - - case USB_ENDPOINT_XFER_ISOC: - /* ISO: limit 1023 bytes full speed, 1024 high/super speed */ - if (ep-maxpacket_limit max) - return 0; - if (!gadget_is_dualspeed(gadget) max 1023) - return 0; - - /* BOTH: high bandwidth works only at high speed */ - if ((desc-wMaxPacketSize cpu_to_le16(311))) { - if (!gadget_is_dualspeed(gadget)) - return 0; - /* configure your hardware with enough buffering!! */ - } break; } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 41/46] usb: gadget: add 'ep_match' callback to usb_gadget_ops
Add callback that is called by epautoconf to allow UDC driver match the best endpoint for specific descriptor. It's intended to supply mechanism which allows to get rid of chip-specific endpoint matching code from epautoconf. If gadget has set 'ep_match' callback we prefer to call it first, and if it fails to find matching endpoint, then we try to use default matching algorithm. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 6 ++ include/linux/usb/gadget.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 4fa6f5d..1b1fee0 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -165,6 +165,12 @@ struct usb_ep *usb_ep_autoconfig_ss( type = desc-bmAttributes USB_ENDPOINT_XFERTYPE_MASK; + if (gadget-ops-match_ep) { + ep = gadget-ops-match_ep(gadget, desc, ep_comp); + if (ep) + goto found_ep; + } + /* First, apply chip-specific best usage knowledge. * This might make a good usb_gadget_ops hook ... */ diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index e6cbc25..0041bb9 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -534,6 +534,9 @@ struct usb_gadget_ops { int (*udc_start)(struct usb_gadget *, struct usb_gadget_driver *); int (*udc_stop)(struct usb_gadget *); + struct usb_ep *(*match_ep)(struct usb_gadget *, + struct usb_endpoint_descriptor *, + struct usb_ss_ep_comp_descriptor *); }; /** -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 46/46] usb: musb: gadget: add musb_match_ep() function
Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching process. Function does the same that was done by chip-specific code inside of epautoconf. Now this code can be removed from there to separate generic code from platform specific logic. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 23 --- drivers/usb/musb/musb_gadget.c | 34 ++ 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index da45371..254ece7 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -83,29 +83,6 @@ struct usb_ep *usb_ep_autoconfig_ss( goto found_ep; } - /* First, apply chip-specific best usage knowledge. -* This might make a good usb_gadget_ops hook ... -*/ -#ifdef CONFIG_BLACKFIN - if (gadget_is_musbhdrc(gadget)) { - if ((USB_ENDPOINT_XFER_BULK == type) || - (USB_ENDPOINT_XFER_ISOC == type)) { - if (USB_DIR_IN desc-bEndpointAddress) - ep = gadget_find_ep_by_name(gadget, ep5in); - else - ep = gadget_find_ep_by_name(gadget, ep6out); - } else if (USB_ENDPOINT_XFER_INT == type) { - if (USB_DIR_IN desc-bEndpointAddress) - ep = gadget_find_ep_by_name(gadget, ep1in); - else - ep = gadget_find_ep_by_name(gadget, ep2out); - } else - ep = NULL; - if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) - goto found_ep; - } -#endif - /* Second, look at endpoints until an unclaimed one looks usable */ list_for_each_entry (ep, gadget-ep_list, ep_list) { if (usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 043248a..3a64cf2 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1684,6 +1684,39 @@ static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on) return 0; } +#ifdef CONFIG_BLACKFIN +static struct usb_ep *musb_match_ep(struct usb_gadget *g, + struct usb_endpoint_descriptor *desc, + struct usb_ss_ep_comp_descriptor *ep_comp) +{ + struct usb_ep *ep = NULL; + u8 type = usb_endpoint_type(desc); + + switch(type) { + case USB_ENDPOINT_XFER_ISOC: + case USB_ENDPOINT_XFER_BULK: + if (usb_endpoint_dir_in(desc)) + ep = gadget_find_ep_by_name(g, ep5in); + else + ep = gadget_find_ep_by_name(g, ep6out); + break; + case USB_ENDPOINT_XFER_INT: + if (usb_endpoint_dir_in(desc)) + ep = gadget_find_ep_by_name(g, ep1in); + else + ep = gadget_find_ep_by_name(g, ep2out); + default: + } + + if (ep usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) + return ep; + + return NULL; +} +#else +#define musb_match_ep NULL +#endif + static int musb_gadget_start(struct usb_gadget *g, struct usb_gadget_driver *driver); static int musb_gadget_stop(struct usb_gadget *g); @@ -1697,6 +1730,7 @@ static const struct usb_gadget_ops musb_gadget_operations = { .pullup = musb_gadget_pullup, .udc_start = musb_gadget_start, .udc_stop = musb_gadget_stop, + .match_ep = musb_match_ep, }; /* --- */ -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH][v2] powerpc/fsl-booke: Add T1040D4RDB/T1042D4RDB board support
On Wed, 2015-07-15 at 15:00 +0530, Priyanka Jain wrote: T1040D4RDB/T1042D4RDB are Freescale Reference Design Board which can support T1040/T1042 QorIQ Power Architecture™ processor respectively T1040D4RDB/T1042D4RDB board Overview - - SERDES Connections, 8 lanes supporting: - PCI - SGMII - SATA 2.0 - QSGMII(only for T1040D4RDB) - DDR Controller - Supports rates of up to 1600 MHz data-rate - Supports one DDR4 UDIMM -IFC/Local Bus - NAND flash: 1GB 8-bit NAND flash - NOR: 128MB 16-bit NOR Flash - Ethernet - Two on-board RGMII 10/100/1G ethernet ports. - PHY #0 remains powered up during deep-sleep - CPLD - Clocks - System and DDR clock (SYSCLK, “DDRCLK”) - SERDES clocks - Power Supplies - USB - Supports two USB 2.0 ports with integrated PHYs - Two type A ports with 5V@1.5Aper port. - SDHC - SDHC/SDXC connector - SPI - On-board 64MB SPI flash - I2C - Devices connected: EEPROM, thermal monitor, VID controller - Other IO - Two Serial ports - ProfiBus port Add support for T1040/T1042D4RDB board: -add device tree -Add entry in corenet_generic.c Signed-off-by: Priyanka Jain priyanka.j...@freescale.com --- Changes for v2: Incorporated Scott's comments on device tree You didn't respond to the comments on the CPLD node. +i2c@118100{ + mux@77{ + compatible = nxp,pca9546; + reg = 0x77; + #address-cells = 1; + #size-cells = 0; + }; + }; A mux with no nodes under it (and yet it has #address-cells/#size-cells)? What is it multiplexing? -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v4 3/6] cpufreq: powernv: Register for OCC related opal_message notification
Hi Joel, On 07/15/2015 11:47 AM, Joel Stanley wrote: Hello, On Mon, 2015-07-13 at 19:39 +0530, Shilpasri G Bhat wrote: diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index d0c18c9..1f59958 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -414,6 +415,71 @@ static struct notifier_block powernv_cpufreq_reboot_nb = { .notifier_call = powernv_cpufreq_reboot_notifier, }; +static char throttle_reason[][30] = { +No throttling, +Power Cap, +Processor Over Temperature, +Power Supply Failure, +Over Current, +OCC Reset + }; + +static int powernv_cpufreq_occ_msg(struct notifier_block *nb, + unsigned long msg_type, void *_msg) +{ +struct opal_msg *msg = _msg; +struct opal_occ_msg omsg; + +if (msg_type != OPAL_MSG_OCC) +return 0; + +memcpy(omsg, msg-params, sizeof(omsg)); You need to ensure the of the members of struct opal_occ_msg are in the correct byte order when copying them over. Have you tested this code with in a little endian configuration? Ah yes this wont work in LE. I tested the below diff in both BE/LE configuration on Power8 box which has FSP. - memcpy(omsg, msg-params, sizeof(omsg)); + omsg.type = be64_to_cpu(msg-params[0]); + omsg.chip = be64_to_cpu(msg-params[1]); + omsg.throttle_status = be64_to_cpu(msg-params[2]); Do the messages you're sending make sense for a system that has a BMC instead of a FSP? For a system with BMC, only OCC_THROTTLE will be received by the host. The remaining two (OCC_RESET and OCC_LOAD) are sent only in FSP based systems. OCC_THROTTLE is sent by opal which polls on the throttle_status byte in the OPAL-OCC shared memory region. Cheers, Joel Thanks and Regards, Shilpa ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 6/6] cputime: Introduce cputime_to_timespec64()/timespec64_to_cputime()
On 15 July 2015 at 18:31, Thomas Gleixner t...@linutronix.de wrote: On Wed, 15 Jul 2015, Baolin Wang wrote: The cputime_to_timespec() and timespec_to_cputime() functions are not year 2038 safe on 32bit systems due to that the struct timepsec will overflow in 2038 year. And how is this relevant? cputime is not based on wall clock time at all. So what has 2038 to do with cputime? We want proper explanations WHY we need such a change. When converting the posix-cpu-timers, it call the cputime_to_timespec() function. Thus it need a conversion for this function. You can see that conversion in patch posix-cpu-timers: Convert to y2038 safe callbacks from https://git.linaro.org/people/baolin.wang/upstream_0627.git. And I also will explain this in the changelog. Thanks for your comments. Thanks, tglx -- Baolin.wang Best Regards ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v2 3/3] sched/preempt: fix cond_resched_lock() and cond_resched_softirq()
On Wed, 2015-07-15 at 12:52 +0300, Konstantin Khlebnikov wrote: These functions check should_resched() before unlocking spinlock/bh-enable: preempt_count always non-zero = should_resched() always returns false. cond_resched_lock() worked iff spin_needbreak is set. Interesting, this definitely used to work (linux-3.11) Any idea of which commit broke things ? ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 6/6] cputime: Introduce cputime_to_timespec64()/timespec64_to_cputime()
On Wed, 15 Jul 2015, Baolin Wang wrote: The cputime_to_timespec() and timespec_to_cputime() functions are not year 2038 safe on 32bit systems due to that the struct timepsec will overflow in 2038 year. And how is this relevant? cputime is not based on wall clock time at all. So what has 2038 to do with cputime? We want proper explanations WHY we need such a change. Thanks, tglx ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 1/3] panic: Disable crash_kexec_post_notifiers if kdump is not available
(2015/07/15 0:40), Vivek Goyal wrote: On Tue, Jul 14, 2015 at 03:34:30PM +, dwal...@fifo99.com wrote: On Tue, Jul 14, 2015 at 11:02:08AM -0400, Vivek Goyal wrote: On Tue, Jul 14, 2015 at 01:59:19PM +, dwal...@fifo99.com wrote: On Mon, Jul 13, 2015 at 08:19:45PM -0500, Eric W. Biederman wrote: dwal...@fifo99.com writes: On Fri, Jul 10, 2015 at 08:41:28AM -0500, Eric W. Biederman wrote: Hidehiro Kawai hidehiro.kawai...@hitachi.com writes: You can call panic notifiers and kmsg dumpers before kdump by specifying crash_kexec_post_notifiers as a boot parameter. However, it doesn't make sense if kdump is not available. In that case, disable crash_kexec_post_notifiers boot parameter so that you can't change the value of the parameter. Nacked-by: Eric W. Biederman ebied...@xmission.com I think it would make sense if he just replaced kdump with kexec. It would be less insane, however it still makes no sense as without kexec on panic support crash_kexec is a noop. So the value of the seeting makes no difference. Can you explain more, I don't really understand what you mean. Are you suggesting the whole crash_kexec_post_notifiers feature has no value ? Daniel, BTW, why are you using crash_kexec_post_notifiers commandline? Why not without it? It was explained in the prior thread but to rehash, the notifiers are used to do a switch over from the crashed machine to another redundant machine. So why not detect failure using polling or issue notifications from second kernel. Polling is not sufficient because some kernel parts may be alive even if the responder of the polling is dead. We want to notify the failure after stopping other CPUs. Notifying from second kernel needs to wait for the kernel booted up and device initialization if needed, and this is not applicable if we want to do fast switchover. Notifying just before second kernel, as Eric stated, is one of the reliable option although we can't do complicate things there. For example, we can notify the failure by writing some specific I/O registers in purgatory codes provided by kexec command. Since the purgatory codes are currently embedded into kexec command, so we might need to modify the mechanism to be pluggable because how to notify will differ among vendors. Anyway, this is the case of switchover use case. If we want to save minimal information before kdump, notifiers or kmsg_dump() can be used. IOW, expecting that a crashed machine will be able to deliver notification reliably is falwed to begin with, IMHO. I think it depends on what callback is used. Most of panic notifiers just do memory copy or I/O register access. Of course, there are relatively complicate notifiers too, and I'm preparing patch sets for hardening for that case. Regards, Hidehiro Kawai ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 6/6] cputime: Introduce cputime_to_timespec64()/timespec64_to_cputime()
On Wed, 15 Jul 2015, Baolin Wang wrote: On 15 July 2015 at 18:31, Thomas Gleixner t...@linutronix.de wrote: On Wed, 15 Jul 2015, Baolin Wang wrote: The cputime_to_timespec() and timespec_to_cputime() functions are not year 2038 safe on 32bit systems due to that the struct timepsec will overflow in 2038 year. And how is this relevant? cputime is not based on wall clock time at all. So what has 2038 to do with cputime? We want proper explanations WHY we need such a change. When converting the posix-cpu-timers, it call the cputime_to_timespec() function. Thus it need a conversion for this function. There is no requirement to convert posix-cpu-timers on their own. We need to adopt the posix cpu timers code because it shares syscalls with the other posix timers, but that still does not explain why we need these functions. You can see that conversion in patch posix-cpu-timers: Convert to y2038 safe callbacks from https://git.linaro.org/people/baolin.wang/upstream_0627.git. I do not care about your random git tree. I care about proper changelogs. Your changelogs are just a copied boilerplate full of errors. Thanks, tglx ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: BUG: sleeping function called from ras_epow_interrupt context
On 07/15/2015 09:35 AM, Thomas Huth wrote: On 07/14/2015 11:22 PM, Benjamin Herrenschmidt wrote: On Tue, 2015-07-14 at 20:43 +0200, Thomas Huth wrote: Any suggestions how to fix this? Simply revert 587f83e8dd50d? Use mdelay() instead of msleep() in rtas_busy_delay()? Something more fancy? A proper fix would be more fancy, the get_sensor should happen in a kernel thread instead. I'm not very familiar with this stuff, but isn't the EPOW interrupt something that is very time-critical? Moving parts of the handler into a kernel thread then does not sound like a very good idea to me... Another question: Can it happen at all that this get-sensor call results in a sleep condition? Looking at commit ID 81b73dd92b97423b8f5324a59044da478c04f4c4 (Fix might-sleep warning on removing cpus), which apparently fixed a similar issue for CPU hot-plugging, indicates that at least some of the rtas calls are never returning the busy code? In that case we could fix this by introducing a similar rtas_get_sensor_fast() function? (or simply revert 587f83e8dd50d which would be quite similar, I think) Looking at the PAPR, the get-sensor-state rtas call for the EPOW sensor is listed as a fast call and should not return a busy indication. I'm curious as to why we're getting a busy return indication when making this call. -Nathan ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 1/2] powerpc/numa: fix cpu_to_node() usage during boot
On 15.07.2015 [16:35:16 -0400], Tejun Heo wrote: Hello, On Thu, Jul 02, 2015 at 04:02:02PM -0700, Nishanth Aravamudan wrote: we currently emit at boot: [0.00] pcpu-alloc: [0] 0 1 2 3 [0] 4 5 6 7 After this commit, we correctly emit: [0.00] pcpu-alloc: [0] 0 1 2 3 [1] 4 5 6 7 JFYI, the numbers in the brackets aren't NUMA node numbers but percpu allocation group numbers and they're not split according to nodes but percpu allocation units. In both cases, there are two units each serving 0-3 and 4-7. In the above case, because it wasn't being fed the correct NUMA information, both got assigned to the same group. In the latter, they got assigned to different ones but even then if the group numbers match NUMA node numbers, that's just a coincidence. Ok, thank you for clarifying! From a correctness perspective, even if the numbers don't match NUMA nodes, should we expect the grouping to be split along NUMA topology? -Nish ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 1/2] powerpc/numa: fix cpu_to_node() usage during boot
Hello, On Wed, Jul 15, 2015 at 03:43:51PM -0700, Nishanth Aravamudan wrote: Ok, thank you for clarifying! From a correctness perspective, even if the numbers don't match NUMA nodes, should we expect the grouping to be split along NUMA topology? Yeap, the groups get formed according to the node distances. Nodes which are not at LOCAL_DISTANCE are always put in different groups. Thanks. -- tejun ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC,1/2] powerpc/numa: fix cpu_to_node() usage during boot
Hello, On Fri, Jul 10, 2015 at 09:15:47AM -0700, Nishanth Aravamudan wrote: On 08.07.2015 [16:16:23 -0700], Nishanth Aravamudan wrote: On 08.07.2015 [14:00:56 +1000], Michael Ellerman wrote: On Thu, 2015-02-07 at 23:02:02 UTC, Nishanth Aravamudan wrote: Much like on x86, now that powerpc is using USE_PERCPU_NUMA_NODE_ID, we have an ordering issue during boot with early calls to cpu_to_node(). now that .. implies we changed something and broke this. What commit was it that changed the behaviour? Well, that's something I'm trying to still unearth. In the commits before and after adding USE_PERCPU_NUMA_NODE_ID (8c272261194d powerpc/numa: Enable USE_PERCPU_NUMA_NODE_ID), the dmesg reports: pcpu-alloc: [0] 0 1 2 3 4 5 6 7 Ok, I did a bisection, and it seems like prior to commit 1a4d76076cda69b0abf15463a8cebc172406da25 (percpu: implement asynchronous chunk population), we emitted the above, e.g.: pcpu-alloc: [0] 0 1 2 3 4 5 6 7 And after that commit, we emitted: pcpu-alloc: [0] 0 1 2 3 [0] 4 5 6 7 I'm not exactly sure why that changed, but I'm still reading/understanding the commit. Tejun might be able to explain. Tejun, for reference, I noticed on Power systems since the above-mentioned commit, pcpu-alloc is not reflecting the topology of the system correctly -- that is, the pcpu areas are all on node 0 unconditionally (based up on pcpu-alloc's output). Prior to that, there was just one group, it seems like, which completely ignored the NUMA topology. Is this just an ordering thing that changed with the introduction of the async code? It's just each unit growing and percpu allocator deciding to split them into separate allocation units. Before it was serving all cpus in a single alloc unit as they looked like they belong to the same NUMA node and small enough to fit into one alloc unit. In the latter, the async one added more reserve space, so the allocator is deciding to split them into two alloc units while assigning them to the same group as the NUMA info wasn't still there. Thanks. -- tejun ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 1/2] powerpc/numa: fix cpu_to_node() usage during boot
Hello, On Thu, Jul 02, 2015 at 04:02:02PM -0700, Nishanth Aravamudan wrote: we currently emit at boot: [0.00] pcpu-alloc: [0] 0 1 2 3 [0] 4 5 6 7 After this commit, we correctly emit: [0.00] pcpu-alloc: [0] 0 1 2 3 [1] 4 5 6 7 JFYI, the numbers in the brackets aren't NUMA node numbers but percpu allocation group numbers and they're not split according to nodes but percpu allocation units. In both cases, there are two units each serving 0-3 and 4-7. In the above case, because it wasn't being fed the correct NUMA information, both got assigned to the same group. In the latter, they got assigned to different ones but even then if the group numbers match NUMA node numbers, that's just a coincidence. Thanks. -- tejun ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: BUG: sleeping function called from ras_epow_interrupt context
On 07/14/2015 11:22 PM, Benjamin Herrenschmidt wrote: On Tue, 2015-07-14 at 20:43 +0200, Thomas Huth wrote: Any suggestions how to fix this? Simply revert 587f83e8dd50d? Use mdelay() instead of msleep() in rtas_busy_delay()? Something more fancy? A proper fix would be more fancy, the get_sensor should happen in a kernel thread instead. I'm not very familiar with this stuff, but isn't the EPOW interrupt something that is very time-critical? Moving parts of the handler into a kernel thread then does not sound like a very good idea to me... Another question: Can it happen at all that this get-sensor call results in a sleep condition? Looking at commit ID 81b73dd92b97423b8f5324a59044da478c04f4c4 (Fix might-sleep warning on removing cpus), which apparently fixed a similar issue for CPU hot-plugging, indicates that at least some of the rtas calls are never returning the busy code? In that case we could fix this by introducing a similar rtas_get_sensor_fast() function? (or simply revert 587f83e8dd50d which would be quite similar, I think) Thomas signature.asc Description: OpenPGP digital signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 5/6] [RFC] crypto/testmgr: add null test for 842 algorithm
On Mon, Jul 13, 2015 at 8:05 PM, Nishanth Aravamudan n...@linux.vnet.ibm.com wrote: On 13.07.2015 [17:05:36 -0700], Nishanth Aravamudan wrote: On 04.07.2015 [15:24:53 +0800], Herbert Xu wrote: On Thu, Jul 02, 2015 at 03:41:19PM -0700, Nishanth Aravamudan wrote: Currently, when the nx-842-pseries driver loads, the following message is emitted: alg: No test for 842 (842-nx) It seems like the simplest way to fix this message (other than adding a proper test) is to just insert the null test into the list in the testmgr. Signed-off-by: Nishanth Aravamudan n...@linux.vnet.ibm.com Please add some real test vectors instead. Apologies, hit send too fast. I'll work with Dan on this when he gets back from vacation. Back from vacation! :-) I originally didn't add any test vector for NX 842 because the main driver was loading before the platform (pseries/powernv) drivers, and the test couldn't run as the platform driver hadn't loaded yet. That's now fixed so we should be able to add a real test for NX 842 now, I can work on that patch. -Nish -- To unsubscribe from this list: send the line unsubscribe linux-crypto in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 6/6] nx-842-platform: if NX842 platform drivers are not modules, don't try to load them
On Mon, Jul 6, 2015 at 1:07 PM, Nishanth Aravamudan n...@linux.vnet.ibm.com wrote: On 06.07.2015 [16:13:07 +0800], Herbert Xu wrote: On Thu, Jul 02, 2015 at 03:42:26PM -0700, Nishanth Aravamudan wrote: Based off the CONFIG_SPU_FS_MODULE code, only attempt to load platform modules if the nx-842 pseries/powernv drivers are built as modules. Otherwise, if CONFIG_DEV_NX_COMPRESS=y, CONFIG_DEV_NX_COMPRESS_PSERIES=y, CONFIG_DEV_NX_POWERNV=y, the following message is emitted at boot: nx_compress: no nx842 driver found. even though the drivers successfully loads. This is because in the =y case, the module_init() calls get converted to initcalls and the nx842_init() runs before the platform driver nx842_pseries_init() or nx842_powernv_init() functions, which are what normally set the static platform driver. Signed-off-by: Nishanth Aravamudan n...@linux.vnet.ibm.com Cc: Dan Streetman ddstr...@us.ibm.com Cc: Herbert Xu herb...@gondor.apana.org.au Cc: David S. Miller da...@davemloft.net Cc: linux-cry...@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Ugh, I think this whole thing is redundant. The whole point of the crypto API is to allow the coexistence of multiple underlying implementations. Sure, that makes sense -- sorry, I was picking this up while Dan was on vacation. Will provide a better v2. Please get rid of nx-842-platform.c completely and move the crypto registration into the individual platform drivers. That is, powernv and pseries should each register their own crypto driver. They can of course share a common set of crypto code which can live in its own module. There should be no need for mucking with module reference counts at all. Will do, thanks! Yep, I originally did it this way because I didn't realize crypto could register different drivers with the same alg name (but different driver names). I have some patches already to start doing this but they weren't ready enough to send before I left for vacation; I'll finish them up and send them. -Nish -- To unsubscribe from this list: send the line unsubscribe linux-crypto in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 03/46] usb: gadget: add endpoint capabilities helper macros
Add macros useful while initializing array of endpoint capabilities structures. These macros makes structure initialization more compact to decrease number of code lines and increase readability of code. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- include/linux/usb/gadget.h | 20 1 file changed, 20 insertions(+) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 6f3e0fb..e6cbc25 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -158,6 +158,26 @@ struct usb_ep_caps { unsigned dir_out:1; }; +#define USB_EP_CAPS_TYPE_CONTROL 0x01 +#define USB_EP_CAPS_TYPE_ISO 0x02 +#define USB_EP_CAPS_TYPE_BULK0x04 +#define USB_EP_CAPS_TYPE_INT 0x08 +#define USB_EP_CAPS_TYPE_ALL \ + (USB_EP_CAPS_TYPE_ISO | USB_EP_CAPS_TYPE_BULK | USB_EP_CAPS_TYPE_INT) +#define USB_EP_CAPS_DIR_IN 0x01 +#define USB_EP_CAPS_DIR_OUT 0x02 +#define USB_EP_CAPS_DIR_ALL (USB_EP_CAPS_DIR_IN | USB_EP_CAPS_DIR_OUT) + +#define USB_EP_CAPS(_type, _dir) \ + { \ + .type_control = !!(_type USB_EP_CAPS_TYPE_CONTROL), \ + .type_iso = !!(_type USB_EP_CAPS_TYPE_ISO), \ + .type_bulk = !!(_type USB_EP_CAPS_TYPE_BULK), \ + .type_int = !!(_type USB_EP_CAPS_TYPE_INT), \ + .dir_in = !!(_dir USB_EP_CAPS_DIR_IN), \ + .dir_out = !!(_dir USB_EP_CAPS_DIR_OUT), \ + } + /** * struct usb_ep - device side representation of USB endpoint * @name:identifier for the endpoint, such as ep-a or ep9in-bulk -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 09/46] usb: gadget: at91_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/at91_udc.c | 33 - 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c index fc42264..a04b073 100644 --- a/drivers/usb/gadget/udc/at91_udc.c +++ b/drivers/usb/gadget/udc/at91_udc.c @@ -59,15 +59,29 @@ #defineDRIVER_VERSION 3 May 2006 static const char driver_name [] = at91_udc; -static const char * const ep_names[] = { - ep0, - ep1, - ep2, - ep3-int, - ep4, - ep5, + +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info[] = { +#define EP_INFO(_name, _type, _dir) \ + { \ + .name = _name, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \ + USB_EP_CAPS_DIR_ ## _dir), \ + } + + EP_INFO(ep0, CONTROL, ALL), + EP_INFO(ep1, ALL,ALL), + EP_INFO(ep2, ALL,ALL), + EP_INFO(ep3-int, INT,ALL), + EP_INFO(ep4, ALL,ALL), + EP_INFO(ep5, ALL,ALL), + +#undef EP_INFO }; -#define ep0nameep_names[0] + +#define ep0nameep_info[0].name #define VBUS_POLL_TIMEOUT msecs_to_jiffies(1000) @@ -1830,7 +1844,8 @@ static int at91udc_probe(struct platform_device *pdev) for (i = 0; i NUM_ENDPOINTS; i++) { ep = udc-ep[i]; - ep-ep.name = ep_names[i]; + ep-ep.name = ep_info[i].name; + ep-ep.caps = ep_info[i].caps; ep-ep.ops = at91_ep_ops; ep-udc = udc; ep-int_mask = BIT(i); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v2 3/3] sched/preempt: fix cond_resched_lock() and cond_resched_softirq()
On Wed, Jul 15, 2015 at 03:52:34PM +0300, Konstantin Khlebnikov wrote: On 15.07.2015 15:16, Eric Dumazet wrote: On Wed, 2015-07-15 at 12:52 +0300, Konstantin Khlebnikov wrote: These functions check should_resched() before unlocking spinlock/bh-enable: preempt_count always non-zero = should_resched() always returns false. cond_resched_lock() worked iff spin_needbreak is set. Interesting, this definitely used to work (linux-3.11) Any idea of which commit broke things ? Searching... done This one: bdb43806589096ac4272fe1307e789846ac08d7c in v3.13 before -static inline int should_resched(void) -{ - return need_resched() !(preempt_count() PREEMPT_ACTIVE); -} after +static __always_inline bool should_resched(void) +{ + return unlikely(!*preempt_count_ptr()); +} Argh, indeed! So, Fixes: bdb438065890 (sched: Extract the basic add/sub preempt_count modifiers) Thanks! ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v2 3/3] sched/preempt: fix cond_resched_lock() and cond_resched_softirq()
On 15.07.2015 15:16, Eric Dumazet wrote: On Wed, 2015-07-15 at 12:52 +0300, Konstantin Khlebnikov wrote: These functions check should_resched() before unlocking spinlock/bh-enable: preempt_count always non-zero = should_resched() always returns false. cond_resched_lock() worked iff spin_needbreak is set. Interesting, this definitely used to work (linux-3.11) Any idea of which commit broke things ? Searching... done This one: bdb43806589096ac4272fe1307e789846ac08d7c in v3.13 before -static inline int should_resched(void) -{ - return need_resched() !(preempt_count() PREEMPT_ACTIVE); -} after +static __always_inline bool should_resched(void) +{ + return unlikely(!*preempt_count_ptr()); +} So, Fixes: bdb438065890 (sched: Extract the basic add/sub preempt_count modifiers) -- Konstantin ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 09/12] powerpc/kernel: Add SIG_SYS support for compat tasks
On Wed, Jul 15, 2015 at 12:37 AM, Michael Ellerman m...@ellerman.id.au wrote: SIG_SYS was added in commit a0727e8ce513 signal, x86: add SIGSYS info and make it synchronous. Because we use the asm-generic struct siginfo, we got support for SIG_SYS for free as part of that commit. However there was no compat handling added for powerpc. That means we've been advertising the existence of signfo._sifields._sigsys to compat tasks, but not actually filling in the fields correctly. Luckily it looks like no one has noticed, presumably because the only user of SIGSYS in the kernel is seccomp filter, which we don't support yet. So before we enable seccomp filter, add compat handling for SIGSYS. Signed-off-by: Michael Ellerman m...@ellerman.id.au --- arch/powerpc/include/asm/compat.h | 7 +++ arch/powerpc/kernel/signal_32.c | 5 + tools/testing/selftests/seccomp/seccomp_bpf.c | 4 3 files changed, 16 insertions(+) diff --git a/arch/powerpc/include/asm/compat.h b/arch/powerpc/include/asm/compat.h index b142b8e0ed9e..4f2df589ec1d 100644 --- a/arch/powerpc/include/asm/compat.h +++ b/arch/powerpc/include/asm/compat.h @@ -174,6 +174,13 @@ typedef struct compat_siginfo { int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ int _fd; } _sigpoll; + + /* SIGSYS */ + struct { + unsigned int _call_addr; /* calling insn */ + int _syscall;/* triggering system call number */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall */ + } _sigsys; } _sifields; } compat_siginfo_t; diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c index d3a831ac0f92..77f97284124e 100644 --- a/arch/powerpc/kernel/signal_32.c +++ b/arch/powerpc/kernel/signal_32.c @@ -949,6 +949,11 @@ int copy_siginfo_to_user32(struct compat_siginfo __user *d, const siginfo_t *s) err |= __put_user(s-si_overrun, d-si_overrun); err |= __put_user(s-si_int, d-si_int); break; + case __SI_SYS 16: + err |= __put_user(ptr_to_compat(s-si_call_addr), d-si_call_addr); + err |= __put_user(s-si_syscall, d-si_syscall); + err |= __put_user(s-si_arch, d-si_arch); + break; case __SI_RT 16: /* This is not generated by the kernel as of now. */ case __SI_MESGQ 16: err |= __put_user(s-si_int, d-si_int); diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index c5abe7fd7590..b2374c131340 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -645,6 +645,10 @@ static struct siginfo TRAP_info; static volatile int TRAP_nr; static void TRAP_action(int nr, siginfo_t *info, void *void_context) { + fprintf(stderr, in TRAP_action\n); + fprintf(stderr, info-si_call_addr %p\n, info-si_call_addr); + fprintf(stderr, info-si_syscall %u\n, info-si_syscall); + fprintf(stderr, info-si_arch %u\n, info-si_arch); memcpy(TRAP_info, info, sizeof(TRAP_info)); TRAP_nr = nr; } This chunk looks like left-over debugging? -Kees -- 2.1.0 -- Kees Cook Chrome OS Security ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 11/12] selftests/seccomp: Make seccomp tests work on big endian
On Wed, Jul 15, 2015 at 12:37 AM, Michael Ellerman m...@ellerman.id.au wrote: The seccomp_bpf test uses BPF_LD|BPF_W|BPF_ABS to load 32-bit values from seccomp_data-args. On big endian machines this will load the high word of the argument, which is not what the test wants. Borrow a hack from samples/seccomp/bpf-helper.h which changes the offset on big endian to account for this. Signed-off-by: Michael Ellerman m...@ellerman.id.au --- tools/testing/selftests/seccomp/seccomp_bpf.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index b2374c131340..51adb9afb511 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -82,7 +82,13 @@ struct seccomp_data { }; #endif +#if __BYTE_ORDER == __LITTLE_ENDIAN #define syscall_arg(_n) (offsetof(struct seccomp_data, args[_n])) +#elif __BYTE_ORDER == __BIG_ENDIAN +#define syscall_arg(_n) (offsetof(struct seccomp_data, args[_n]) + sizeof(__u32)) +#else +#error wut? +#endif Ah-ha! Yes, thanks. Could you change the #error to something that describes the particular (impossible) failure condition? wut? Unknown __BYTE_ORDER?!. Not a huge deal, but I always like verbose errors. :) Especially for impossible situations. :) -Kees #define SIBLING_EXIT_UNKILLED 0xbadbeef #define SIBLING_EXIT_FAILURE 0xbadface -- 2.1.0 -- Kees Cook Chrome OS Security ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 12/12] selftests/seccomp: Add powerpc support
On Wed, Jul 15, 2015 at 12:37 AM, Michael Ellerman m...@ellerman.id.au wrote: Wire up the syscall number and regs so the tests work on powerpc. Signed-off-by: Michael Ellerman m...@ellerman.id.au Acked-by: Kees Cook keesc...@chromium.org -Kees --- tools/testing/selftests/seccomp/seccomp_bpf.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 51adb9afb511..05fcdb974df6 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -14,6 +14,7 @@ #include linux/filter.h #include sys/prctl.h #include sys/ptrace.h +#include sys/types.h #include sys/user.h #include linux/prctl.h #include linux/ptrace.h @@ -1209,6 +1210,10 @@ TEST_F(TRACE_poke, getpid_runs_normally) # define ARCH_REGS struct user_pt_regs # define SYSCALL_NUM regs[8] # define SYSCALL_RET regs[0] +#elif defined(__powerpc__) +# define ARCH_REGS struct pt_regs +# define SYSCALL_NUM gpr[0] +# define SYSCALL_RET gpr[3] #else # error Do not know how to find your architecture's registers and syscalls #endif @@ -1242,7 +1247,7 @@ void change_syscall(struct __test_metadata *_metadata, ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, iov); EXPECT_EQ(0, ret); -#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) +#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || defined(__powerpc__) { regs.SYSCALL_NUM = syscall; } @@ -1406,6 +1411,8 @@ TEST_F(TRACE_syscall, syscall_dropped) # define __NR_seccomp 383 # elif defined(__aarch64__) # define __NR_seccomp 277 +# elif defined(__powerpc__) +# define __NR_seccomp 358 # else # warning seccomp syscall number unknown for this architecture # define __NR_seccomp 0x -- 2.1.0 -- Kees Cook Chrome OS Security ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev