RIP: 0010:g84_gr_tlb_flush+0x2eb/0x300 [nouveau]

2020-10-20 Thread Mathieu Malaterre
Hi there,

Could someone please comment on the following hard-lock (*). Staring
at the code, I see `nvkm_rd32` calls are enclosed in a timeout
detection, except one.

drivers/gpu/drm/nouveau/nvkm/engine/gr/g84.c#L171
...
nvkm_msec(device, 2000,
  if (!(nvkm_rd32(device, 0x100c80) & 0x0001))
  break;
);
...

Would it make sense to also enclose this in the do/while loop ?

Full ref:
* https://gitlab.freedesktop.org/xorg/driver/xf86-video-nouveau/-/issues/536

Thanks

(*)
Oct 20 08:44:13 vostrodell kernel: [55669.783436] [ cut
here ]
Oct 20 08:44:13 vostrodell kernel: [55669.783446] nouveau :01:00.0: timeout
Oct 20 08:44:13 vostrodell kernel: [55669.783527] WARNING: CPU: 1 PID:
7812 at drivers/gpu/drm/nouveau/nvkm/engine/gr/g84.c:171
g84_gr_tlb_flush+0x2eb/0x300 [nouveau]
Oct 20 08:44:13 vostrodell kernel: [55669.783527] Modules linked in:
cdc_acm(OE) fuse md4 sha512_ssse3 sha512_generic cmac nls_utf8 cifs
dns_resolver fscache libdes intel_rapl_msr intel_rapl_common
x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm ath9k
irqbypass ath9k_common ath9k_hw crc32_pclmul ath
snd_hda_codec_conexant ghash_clmulni_intel snd_hda_codec_generic
snd_hda_codec_hdmi ledtrig_audio mac80211 snd_hda_intel
snd_intel_dspcfg aesni_intel libaes crypto_simd snd_hda_codec
snd_hda_core cryptd snd_hwdep cfg80211 glue_helper dcdbas snd_pcm rapl
iTCO_wdt snd_timer intel_pmc_bxt mei_me intel_cstate rfkill
iTCO_vendor_support snd intel_uncore dell_smm_hwmon mei serio_raw
soundcore watchdog libarc4 at24 sg pcspkr evdev binfmt_misc ip_tables
x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic sd_mod sr_mod
t10_pi cdrom crc_t10dif crct10dif_generic hid_generic usbhid hid uas
ata_generic usb_storage nouveau mxm_wmi wmi ata_piix crct10dif_pclmul
crct10dif_common video i2c_algo_bit libata ttm crc32c_intel
Oct 20 08:44:13 vostrodell kernel: [55669.783551]  drm_kms_helper
psmouse scsi_mod i2c_i801 i2c_smbus cec lpc_ich ehci_pci ehci_hcd drm
usbcore r8169 realtek libphy usb_common button [last unloaded:
cdc_acm]
Oct 20 08:44:13 vostrodell kernel: [55669.783558] CPU: 1 PID: 7812
Comm: kworker/1:0 Tainted: G   OE 5.8.0-0.bpo.2-amd64 #1
Debian 5.8.10-1~bpo10+1
Oct 20 08:44:13 vostrodell kernel: [55669.783559] Hardware name: Dell
Inc. Vostro 260   /0GDG8Y   , BIOS A10 02/22/2013
Oct 20 08:44:13 vostrodell kernel: [55669.783595] Workqueue: events
nouveau_cli_work [nouveau]
Oct 20 08:44:13 vostrodell kernel: [55669.783631] RIP:
0010:g84_gr_tlb_flush+0x2eb/0x300 [nouveau]
Oct 20 08:44:13 vostrodell kernel: [55669.783633] Code: 8b 40 10 48 8b
78 10 4c 8b 67 50 4d 85 e4 75 03 4c 8b 27 e8 87 e7 ab e7 4c 89 e2 48
c7 c7 6c 43 63 c0 48 89 c6 e8 30 af 58 e7 <0f> 0b e9 44 ff ff ff e8 d9
d7 cf e7 66 0f 1f 84 00 00 00 00 00 66
Oct 20 08:44:13 vostrodell kernel: [55669.783634] RSP:
0018:ae76c66db998 EFLAGS: 00010082
Oct 20 08:44:13 vostrodell kernel: [55669.783634] RAX:
 RBX: 9dc2450f8c00 RCX: 0027
Oct 20 08:44:13 vostrodell kernel: [55669.783635] RDX:
0027 RSI: 9dc277498ac0 RDI: 9dc277498ac8
Oct 20 08:44:13 vostrodell kernel: [55669.783636] RBP:
 R08: 04df R09: 0004
Oct 20 08:44:13 vostrodell kernel: [55669.783636] R10:
 R11: 0001 R12: 9dc26fc42290
Oct 20 08:44:13 vostrodell kernel: [55669.783637] R13:
32a15d0363a0 R14: 9dc277560580 R15: 0001
Oct 20 08:44:13 vostrodell kernel: [55669.783638] FS:
() GS:9dc27748()
knlGS:
Oct 20 08:44:13 vostrodell kernel: [55669.783639] CS:  0010 DS: 
ES:  CR0: 80050033
Oct 20 08:44:13 vostrodell kernel: [55669.783639] CR2:
7f72949e5000 CR3: 00020480a001 CR4: 000606e0
Oct 20 08:44:13 vostrodell kernel: [55669.783640] Call Trace:
Oct 20 08:44:13 vostrodell kernel: [55669.783648]  ?
enqueue_task_fair+0x8e/0x690
Oct 20 08:44:13 vostrodell kernel: [55669.783683]  ?
nv04_timer_read+0x42/0x60 [nouveau]
Oct 20 08:44:13 vostrodell kernel: [55669.831715]
nv50_vmm_flush+0x1f1/0x220 [nouveau]
Oct 20 08:44:13 vostrodell kernel: [55669.831719]  ?
refcount_dec_and_mutex_lock+0x26/0x60
Oct 20 08:44:13 vostrodell kernel: [55669.831751]
nvkm_vmm_iter.constprop.10+0x364/0x820 [nouveau]
Oct 20 08:44:13 vostrodell kernel: [55669.831783]  ?
nvkm_vmm_map_choose+0xa0/0xa0 [nouveau]
Oct 20 08:44:13 vostrodell kernel: [55669.831815]  ?
nv44_vmm_new+0xe0/0xe0 [nouveau]
Oct 20 08:44:13 vostrodell kernel: [55669.831847]
nvkm_vmm_ptes_unmap_put+0x2c/0x40 [nouveau]
Oct 20 08:44:13 vostrodell kernel: [55669.831885]  ?
nvkm_vmm_map_choose+0xa0/0xa0 [nouveau]
Oct 20 08:44:13 vostrodell kernel: [55669.831922]  ?
nv44_vmm_new+0xe0/0xe0 [nouveau]
Oct 20 08:44:13 vostrodell kernel: [55669.831968]
nvkm_vmm_put_locked+0x203/0x240 [nouveau]
Oct 20 08:44:13 vostrodell kernel: [55669.832000]
nvkm_uvmm_mthd+0x249/0x710 [nouveau]
Oct 20 08:44:13 vostrodell kernel: [55669.832022]

Re: [PATCH] video: fbdev: radeon: Fix memleak in radeonfb_pci_register

2020-08-25 Thread Mathieu Malaterre
On Tue, Aug 25, 2020 at 9:27 AM Dinghao Liu  wrote:
>
> When radeon_kick_out_firmware_fb() fails, info should be
> freed just like the subsequent error paths.
>
> Fixes: 069ee21a82344 ("fbdev: Fix loading of module radeonfb on PowerMac")
> Signed-off-by: Dinghao Liu 
> ---
>  drivers/video/fbdev/aty/radeon_base.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/video/fbdev/aty/radeon_base.c 
> b/drivers/video/fbdev/aty/radeon_base.c
> index 3fe509cb9b87..13bd2bd5c043 100644
> --- a/drivers/video/fbdev/aty/radeon_base.c
> +++ b/drivers/video/fbdev/aty/radeon_base.c
> @@ -2307,7 +2307,7 @@ static int radeonfb_pci_register(struct pci_dev *pdev,
>
> ret = radeon_kick_out_firmware_fb(pdev);
> if (ret)
> -   return ret;
> +   goto err_release_fb;

Good catch ! Thanks

Reviewed-by: Mathieu Malaterre 

> /* request the mem regions */
> ret = pci_request_region(pdev, 0, "radeonfb framebuffer");
> --
> 2.17.1
>


Re: Help: Regression in v4.19 : do_IRQ: 0.37 No irq handler for vector

2019-07-19 Thread Mathieu Malaterre
On Fri, Jul 19, 2019 at 1:32 PM Mathieu Malaterre  wrote:
>
> [cc me please]
>
> Hi there,
>
> I recently upgraded my desktop to Debian/buster. Now when I start my
> xfce session I can hear the system bell, and my dmesg is filled with
> numerous:
>
> [  920.728347] do_IRQ: 0.37 No irq handler for vector
>
> The symptoms seems to be gone using git/master:
>
> 3a1d5384b7decbff6519daa9c65a35665e227323
>
> Could someone suggest a method/tool to track down which commit needs
> backport to v4.19 (other than a git bisect).
>
> For reference:
> * this is bug Debian #932304
> * I can boot in recovery mode without any issue. It seems to be
> related to an event in single mode

s/single mode/default mode/

In other word: it occurs when I 'ctrl+d' from the rescue mode into the
default mode.

> Thanks much,


Help: Regression in v4.19 : do_IRQ: 0.37 No irq handler for vector

2019-07-19 Thread Mathieu Malaterre
[cc me please]

Hi there,

I recently upgraded my desktop to Debian/buster. Now when I start my
xfce session I can hear the system bell, and my dmesg is filled with
numerous:

[  920.728347] do_IRQ: 0.37 No irq handler for vector

The symptoms seems to be gone using git/master:

3a1d5384b7decbff6519daa9c65a35665e227323

Could someone suggest a method/tool to track down which commit needs
backport to v4.19 (other than a git bisect).

For reference:
* this is bug Debian #932304
* I can boot in recovery mode without any issue. It seems to be
related to an event in single mode

Thanks much,


Re: [RFC PATCH v1 11/13] powerpc/ptrace: create ppc_gethwdinfo()

2019-06-25 Thread Mathieu Malaterre
On Tue, Jun 25, 2019 at 1:22 PM Christophe Leroy
 wrote:
>
> Create ippc_gethwdinfo() to handle PPC_PTRACE_GETHWDBGINFO and

s/ippc_gethwdinfo/ppc_gethwdinfo/

> reduce ifdef mess
>
> Signed-off-by: Christophe Leroy 
> ---
>  arch/powerpc/kernel/ptrace/ptrace-adv.c   | 15 +++
>  arch/powerpc/kernel/ptrace/ptrace-decl.h  |  1 +
>  arch/powerpc/kernel/ptrace/ptrace-noadv.c | 20 +++
>  arch/powerpc/kernel/ptrace/ptrace.c   | 32 
> +--
>  4 files changed, 37 insertions(+), 31 deletions(-)
>
> diff --git a/arch/powerpc/kernel/ptrace/ptrace-adv.c 
> b/arch/powerpc/kernel/ptrace/ptrace-adv.c
> index dcc765940344..f5f334484ebc 100644
> --- a/arch/powerpc/kernel/ptrace/ptrace-adv.c
> +++ b/arch/powerpc/kernel/ptrace/ptrace-adv.c
> @@ -83,6 +83,21 @@ void user_disable_single_step(struct task_struct *task)
> clear_tsk_thread_flag(task, TIF_SINGLESTEP);
>  }
>
> +void ppc_gethwdinfo(struct ppc_debug_info *dbginfo)

Would it be possible to rename it to `ppc_gethwdbginfo`, I find it
easier to read.

> +{
> +   dbginfo->version = 1;
> +   dbginfo->num_instruction_bps = CONFIG_PPC_ADV_DEBUG_IACS;
> +   dbginfo->num_data_bps = CONFIG_PPC_ADV_DEBUG_DACS;
> +   dbginfo->num_condition_regs = CONFIG_PPC_ADV_DEBUG_DVCS;
> +   dbginfo->data_bp_alignment = 4;
> +   dbginfo->sizeof_condition = 4;
> +   dbginfo->features = PPC_DEBUG_FEATURE_INSN_BP_RANGE |
> +   PPC_DEBUG_FEATURE_INSN_BP_MASK;
> +   if (IS_ENABLED(CONFIG_PPC_ADV_DEBUG_DAC_RANGE))
> +   dbginfo->features |= PPC_DEBUG_FEATURE_DATA_BP_RANGE |
> +PPC_DEBUG_FEATURE_DATA_BP_MASK;
> +}
> +
>  int ptrace_get_debugreg(struct task_struct *child, unsigned long addr,
> unsigned long __user *datalp)
>  {
> diff --git a/arch/powerpc/kernel/ptrace/ptrace-decl.h 
> b/arch/powerpc/kernel/ptrace/ptrace-decl.h
> index cd5b8256ba56..2404b987b23c 100644
> --- a/arch/powerpc/kernel/ptrace/ptrace-decl.h
> +++ b/arch/powerpc/kernel/ptrace/ptrace-decl.h
> @@ -141,6 +141,7 @@ int tm_cgpr32_set(struct task_struct *target, const 
> struct user_regset *regset,
>  extern const struct user_regset_view user_ppc_native_view;
>
>  /* ptrace-(no)adv */
> +void ppc_gethwdinfo(struct ppc_debug_info *dbginfo);
>  int ptrace_get_debugreg(struct task_struct *child, unsigned long addr,
> unsigned long __user *datalp);
>  int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, 
> unsigned long data);
> diff --git a/arch/powerpc/kernel/ptrace/ptrace-noadv.c 
> b/arch/powerpc/kernel/ptrace/ptrace-noadv.c
> index 985cca136f85..426fedd7ab6c 100644
> --- a/arch/powerpc/kernel/ptrace/ptrace-noadv.c
> +++ b/arch/powerpc/kernel/ptrace/ptrace-noadv.c
> @@ -64,6 +64,26 @@ void user_disable_single_step(struct task_struct *task)
> clear_tsk_thread_flag(task, TIF_SINGLESTEP);
>  }
>
> +void ppc_gethwdinfo(struct ppc_debug_info *dbginfo)
> +{
> +   dbginfo->version = 1;
> +   dbginfo->num_instruction_bps = 0;
> +   if (ppc_breakpoint_available())
> +   dbginfo->num_data_bps = 1;
> +   else
> +   dbginfo->num_data_bps = 0;
> +   dbginfo->num_condition_regs = 0;
> +   dbginfo->data_bp_alignment = sizeof(long);
> +   dbginfo->sizeof_condition = 0;
> +   if (IS_ENABLED(CONFIG_HAVE_HW_BREAKPOINT)) {
> +   dbginfo->features = PPC_DEBUG_FEATURE_DATA_BP_RANGE;
> +   if (dawr_enabled())
> +   dbginfo->features |= PPC_DEBUG_FEATURE_DATA_BP_DAWR;
> +   } else {
> +   dbginfo->features = 0;
> +   }
> +}
> +
>  int ptrace_get_debugreg(struct task_struct *child, unsigned long addr,
> unsigned long __user *datalp)
>  {
> diff --git a/arch/powerpc/kernel/ptrace/ptrace.c 
> b/arch/powerpc/kernel/ptrace/ptrace.c
> index e789afae6f56..31e8c5a9171e 100644
> --- a/arch/powerpc/kernel/ptrace/ptrace.c
> +++ b/arch/powerpc/kernel/ptrace/ptrace.c
> @@ -159,37 +159,7 @@ long arch_ptrace(struct task_struct *child, long request,
> case PPC_PTRACE_GETHWDBGINFO: {
> struct ppc_debug_info dbginfo;
>
> -   dbginfo.version = 1;
> -#ifdef CONFIG_PPC_ADV_DEBUG_REGS
> -   dbginfo.num_instruction_bps = CONFIG_PPC_ADV_DEBUG_IACS;
> -   dbginfo.num_data_bps = CONFIG_PPC_ADV_DEBUG_DACS;
> -   dbginfo.num_condition_regs = CONFIG_PPC_ADV_DEBUG_DVCS;
> -   dbginfo.data_bp_alignment = 4;
> -   dbginfo.sizeof_condition = 4;
> -   dbginfo.features = PPC_DEBUG_FEATURE_INSN_BP_RANGE |
> -  PPC_DEBUG_FEATURE_INSN_BP_MASK;
> -#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE
> -   dbginfo.features |=
> -  PPC_DEBUG_FEATURE_DATA_BP_RANGE |
> -  PPC_DEBUG_FEATURE_DATA_BP_MASK;
> -#endif
> 

[PATCH v2] lib/mpi: fix build with clang

2019-06-21 Thread Mathieu Malaterre
Remove superfluous casts on output operands to avoid warnings on the
following macros:

* add_ss(sh, sl, ah, al, bh, bl)
* sub_ddmmss(sh, sl, ah, al, bh, bl)
* umul_ppmm(ph, pl, m0, m1)

Special care has been taken to keep the diff as minimal as possible from
the original header file `longlong.h` from gcc, only importing the
minimal change to make the compilation with clang pass.

Silence the following warnings triggered using W=1:

CC  lib/mpi/generic_mpih-mul1.o
  ../lib/mpi/generic_mpih-mul1.c:37:13: error: invalid use of a cast in a 
inline asm context requiring an l-value: remove the cast or build with
-fheinous-gnu-extensions
  umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
  ~~^~~~
  ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
  : "=r" ((USItype) ph) \
  ~~^~

and

CC  lib/mpi/generic_mpih-mul2.o
  ../lib/mpi/generic_mpih-mul2.c:36:13: error: invalid use of a cast in a 
inline asm context requiring an l-value: remove the cast or build with
-fheinous-gnu-extensions
  umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
  ~~^~~~
  ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
  : "=r" ((USItype) ph) \
  ~~^~

  1 warning generated.
CC  lib/mpi/generic_mpih-mul3.o
  ../lib/mpi/generic_mpih-mul3.c:36:13: error: invalid use of a cast in a 
inline asm context requiring an l-value: remove the cast or build with
-fheinous-gnu-extensions
  umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
  ~~^~~~
  ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
  : "=r" ((USItype) ph) \
  ~~^~

Or even:

  ../lib/mpi/mpih-div.c:99:16: error: invalid use of a cast in a inline asm 
context requiring an l-value: remove the cast or build with 
-fheinous-gnu-extensions
  sub_ddmmss(n1, n0, n1, n0, d1, d0);
  ~~~^~~

Inspiration is taken from commit b682c8692442 ("powerpc/math-emu: Update
macros from GCC").

Suggested-by: Joel Stanley 
Cc: Segher Boessenkool 
Signed-off-by: Mathieu Malaterre 
---
v2: Instead of passing compat flag to clang to behave as gcc, remove the 
superfluous cast

 lib/mpi/longlong.h | 105 +++--
 1 file changed, 35 insertions(+), 70 deletions(-)

diff --git a/lib/mpi/longlong.h b/lib/mpi/longlong.h
index 08c60d10747f..f5503dfa42ed 100644
--- a/lib/mpi/longlong.h
+++ b/lib/mpi/longlong.h
@@ -753,79 +753,44 @@ do {  
\
***/
 #if (defined(_ARCH_PPC) || defined(_IBMR2)) && W_TYPE_SIZE == 32
 #define add_ss(sh, sl, ah, al, bh, bl) \
-do { \
-   if (__builtin_constant_p(bh) && (bh) == 0) \
-   __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
-   : "=r" ((USItype)(sh)), \
-   "=" ((USItype)(sl)) \
-   : "%r" ((USItype)(ah)), \
-   "%r" ((USItype)(al)), \
-   "rI" ((USItype)(bl))); \
-   else if (__builtin_constant_p(bh) && (bh) == ~(USItype) 0) \
-   __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
-   : "=r" ((USItype)(sh)), \
-   "=" ((USItype)(sl)) \
-   : "%r" ((USItype)(ah)), \
-   "%r" ((USItype)(al)), \
-   "rI" ((USItype)(bl))); \
-   else \
-   __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
-   : "=r" ((USItype)(sh)), \
-   "=" ((USItype)(sl)) \
-   : "%r" ((USItype)(ah)), \
-   "r" ((USItype)(bh)), \
-   "%r" ((USItype)(al)), \
-   "rI" ((USItype)(bl))); \
-} while (0)
+  do { \
+if (__builtin_constant_p (bh) && (bh) == 0)
\
+  __asm__ ("add%I4c %1,%3,%4\n\taddze %0,%2"   \
+: "=r" (sh), "=" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
+else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0)
\
+  __asm__ ("add%I4c %1,%3,%4\n\taddme %0,%2"   \
+: "=r" (sh), "=" (sl) : "r" (ah), "%r" (al), "rI" (bl))

[PATCH] powerpc/lib/xor_vmx: Relax frame size for clang

2019-06-21 Thread Mathieu Malaterre
When building with clang-8 the frame size limit is hit:

  ../arch/powerpc/lib/xor_vmx.c:119:6: error: stack frame size of 1200 bytes in 
function '__xor_altivec_5' [-Werror,-Wframe-larger-than=]

Follow the same approach as commit 9c87156cce5a ("powerpc/xmon: Relax
frame size for clang") until a proper fix is implemented upstream in
clang and relax requirement for clang.

Link: https://github.com/ClangBuiltLinux/linux/issues/563
Cc: Joel Stanley 
Signed-off-by: Mathieu Malaterre 
---
 arch/powerpc/lib/Makefile | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index c55f9c27bf79..b3f7d64caaf0 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -58,5 +58,9 @@ obj-$(CONFIG_FTR_FIXUP_SELFTEST) += feature-fixups-test.o
 
 obj-$(CONFIG_ALTIVEC)  += xor_vmx.o xor_vmx_glue.o
 CFLAGS_xor_vmx.o += -maltivec $(call cc-option,-mabi=altivec)
+ifdef CONFIG_CC_IS_CLANG
+# See https://github.com/ClangBuiltLinux/linux/issues/563
+CFLAGS_xor_vmx.o += -Wframe-larger-than=4096
+endif
 
 obj-$(CONFIG_PPC64) += $(obj64-y)
-- 
2.20.1



Re: [PATCH] crypto: Fix build for clang

2019-06-21 Thread Mathieu Malaterre
Joel,

On Fri, Jun 21, 2019 at 9:30 AM Joel Stanley  wrote:
>
> On Fri, 21 Jun 2019 at 07:13, Mathieu Malaterre  wrote:
> >
> > The header file `longlong.h` makes uses of GNU extensions, this trigger
> > an error when compiling this code with clang. Add a special flag to make
> > clang tolerate this syntax.
>
> Another old copy of longlong.h in the kernel!
>
> This looks similar to another clang related warnings I fixed in the
> powerpc math-emu code. There's an updated version of these macros in
> GCC, and we updated the kernel version to match the GCC version. Can
> you see if a similar change would work here?
>
> https://lore.kernel.org/linuxppc-dev/43bcrq6zqdz9...@ozlabs.org/
> https://git.kernel.org/torvalds/c/b682c8692442711684befe413cf93cf01c5324ea

Great ! Thanks for the pointer. Looks like a much bettter solution in
the long term. Will try asap.

> Cheers,
>
> Joel
>
> >
> > Silence the following warnings triggered using W=1:
> >
> > CC  lib/mpi/generic_mpih-mul1.o
> >   ../lib/mpi/generic_mpih-mul1.c:37:13: error: invalid use of a cast in a 
> > inline asm context requiring an l-value: remove the cast or build with
> > -fheinous-gnu-extensions
> >   umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
> >   ~~^~~~
> >   ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
> >   : "=r" ((USItype) ph) \
> >   ~~^~
> >
> > and
> >
> > CC  lib/mpi/generic_mpih-mul2.o
> >   ../lib/mpi/generic_mpih-mul2.c:36:13: error: invalid use of a cast in a 
> > inline asm context requiring an l-value: remove the cast or build with
> > -fheinous-gnu-extensions
> >   umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
> >   ~~^~~~
> >   ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
> >   : "=r" ((USItype) ph) \
> >   ~~^~
> >
> >   1 warning generated.
> > CC  lib/mpi/generic_mpih-mul3.o
> >   ../lib/mpi/generic_mpih-mul3.c:36:13: error: invalid use of a cast in a 
> > inline asm context requiring an l-value: remove the cast or build with
> > -fheinous-gnu-extensions
> >   umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
> >   ~~^~~~
> >   ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
> >   : "=r" ((USItype) ph) \
> >   ~~^~
> >
> > Or even:
> >
> >   ../lib/mpi/mpih-div.c:99:16: error: invalid use of a cast in a inline asm 
> > context requiring an l-value: remove the cast or build with 
> > -fheinous-gnu-extensions
> >   sub_ddmmss(n1, n0, n1, n0, d1, d0);
> >   ~~~^~~
> >
> > Cc: Joel Stanley 
> > Cc: Masahiro Yamada 
> > Signed-off-by: Mathieu Malaterre 
> > ---
> >  lib/mpi/Makefile | 7 +++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/lib/mpi/Makefile b/lib/mpi/Makefile
> > index d5874a7f5ff9..de4d96e988a3 100644
> > --- a/lib/mpi/Makefile
> > +++ b/lib/mpi/Makefile
> > @@ -5,6 +5,13 @@
> >
> >  obj-$(CONFIG_MPILIB) = mpi.o
> >
> > +ifdef CONFIG_CC_IS_CLANG
> > +CFLAGS_generic_mpih-mul1.o  += -fheinous-gnu-extensions
> > +CFLAGS_generic_mpih-mul2.o  += -fheinous-gnu-extensions
> > +CFLAGS_generic_mpih-mul3.o  += -fheinous-gnu-extensions
> > +CFLAGS_mpih-div.o  += -fheinous-gnu-extensions
> > +endif
> > +
> >  mpi-y = \
> > generic_mpih-lshift.o   \
> > generic_mpih-mul1.o \
> > --
> > 2.20.1
> >


[PATCH] crypto: Fix build for clang

2019-06-21 Thread Mathieu Malaterre
The header file `longlong.h` makes uses of GNU extensions, this trigger
an error when compiling this code with clang. Add a special flag to make
clang tolerate this syntax.

Silence the following warnings triggered using W=1:

CC  lib/mpi/generic_mpih-mul1.o
  ../lib/mpi/generic_mpih-mul1.c:37:13: error: invalid use of a cast in a 
inline asm context requiring an l-value: remove the cast or build with
-fheinous-gnu-extensions
  umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
  ~~^~~~
  ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
  : "=r" ((USItype) ph) \
  ~~^~

and

CC  lib/mpi/generic_mpih-mul2.o
  ../lib/mpi/generic_mpih-mul2.c:36:13: error: invalid use of a cast in a 
inline asm context requiring an l-value: remove the cast or build with
-fheinous-gnu-extensions
  umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
  ~~^~~~
  ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
  : "=r" ((USItype) ph) \
  ~~^~

  1 warning generated.
CC  lib/mpi/generic_mpih-mul3.o
  ../lib/mpi/generic_mpih-mul3.c:36:13: error: invalid use of a cast in a 
inline asm context requiring an l-value: remove the cast or build with
-fheinous-gnu-extensions
  umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
  ~~^~~~
  ../lib/mpi/longlong.h:824:20: note: expanded from macro 'umul_ppmm'
  : "=r" ((USItype) ph) \
  ~~^~

Or even:

  ../lib/mpi/mpih-div.c:99:16: error: invalid use of a cast in a inline asm 
context requiring an l-value: remove the cast or build with 
-fheinous-gnu-extensions
  sub_ddmmss(n1, n0, n1, n0, d1, d0);
  ~~~^~~

Cc: Joel Stanley 
Cc: Masahiro Yamada 
Signed-off-by: Mathieu Malaterre 
---
 lib/mpi/Makefile | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/lib/mpi/Makefile b/lib/mpi/Makefile
index d5874a7f5ff9..de4d96e988a3 100644
--- a/lib/mpi/Makefile
+++ b/lib/mpi/Makefile
@@ -5,6 +5,13 @@
 
 obj-$(CONFIG_MPILIB) = mpi.o
 
+ifdef CONFIG_CC_IS_CLANG
+CFLAGS_generic_mpih-mul1.o  += -fheinous-gnu-extensions
+CFLAGS_generic_mpih-mul2.o  += -fheinous-gnu-extensions
+CFLAGS_generic_mpih-mul3.o  += -fheinous-gnu-extensions
+CFLAGS_mpih-div.o  += -fheinous-gnu-extensions
+endif
+
 mpi-y = \
generic_mpih-lshift.o   \
generic_mpih-mul1.o \
-- 
2.20.1



Re: [PATCH] powerpc: enable a 30-bit ZONE_DMA for 32-bit pmac

2019-06-19 Thread Mathieu Malaterre
On Wed, Jun 19, 2019 at 4:18 PM Benjamin Herrenschmidt
 wrote:
>
> On Wed, 2019-06-19 at 22:32 +1000, Michael Ellerman wrote:
> > Christoph Hellwig  writes:
> > > Any chance this could get picked up to fix the regression?
> >
> > Was hoping Ben would Ack it. He's still powermac maintainer :)
> >
> > I guess he OK'ed it in the other thread, will add it to my queue.
>
> Yeah ack. If I had written it myself, I would have made the DMA bits a
> variable and only set it down to 30 if I see that device in the DT
> early on, but I can't be bothered now, if it works, ship it :-)
>
> Note: The patch affects all ppc32, though I don't think it will cause
> any significant issue on those who don't need it.

Thanks, that answer my earlier question.

> Cheers,
> Ben.
>
> > cheers
> >
> > > On Thu, Jun 13, 2019 at 10:24:46AM +0200, Christoph Hellwig wrote:
> > > > With the strict dma mask checking introduced with the switch to
> > > > the generic DMA direct code common wifi chips on 32-bit
> > > > powerbooks
> > > > stopped working.  Add a 30-bit ZONE_DMA to the 32-bit pmac builds
> > > > to allow them to reliably allocate dma coherent memory.
> > > >
> > > > Fixes: 65a21b71f948 ("powerpc/dma: remove
> > > > dma_nommu_dma_supported")
> > > > Reported-by: Aaro Koskinen 
> > > > Signed-off-by: Christoph Hellwig 
> > > > ---
> > > >  arch/powerpc/include/asm/page.h | 7 +++
> > > >  arch/powerpc/mm/mem.c   | 3 ++-
> > > >  arch/powerpc/platforms/powermac/Kconfig | 1 +
> > > >  3 files changed, 10 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/arch/powerpc/include/asm/page.h
> > > > b/arch/powerpc/include/asm/page.h
> > > > index b8286a2013b4..0d52f57fca04 100644
> > > > --- a/arch/powerpc/include/asm/page.h
> > > > +++ b/arch/powerpc/include/asm/page.h
> > > > @@ -319,6 +319,13 @@ struct vm_area_struct;
> > > >  #endif /* __ASSEMBLY__ */
> > > >  #include 
> > > >
> > > > +/*
> > > > + * Allow 30-bit DMA for very limited Broadcom wifi chips on many
> > > > powerbooks.
> > > > + */
> > > > +#ifdef CONFIG_PPC32
> > > > +#define ARCH_ZONE_DMA_BITS 30
> > > > +#else
> > > >  #define ARCH_ZONE_DMA_BITS 31
> > > > +#endif
> > > >
> > > >  #endif /* _ASM_POWERPC_PAGE_H */
> > > > diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
> > > > index cba29131bccc..2540d3b2588c 100644
> > > > --- a/arch/powerpc/mm/mem.c
> > > > +++ b/arch/powerpc/mm/mem.c
> > > > @@ -248,7 +248,8 @@ void __init paging_init(void)
> > > >  (long int)((top_of_ram - total_ram) >> 20));
> > > >
> > > >  #ifdef CONFIG_ZONE_DMA
> > > > - max_zone_pfns[ZONE_DMA] = min(max_low_pfn, 0x7fffUL
> > > > >> PAGE_SHIFT);
> > > > + max_zone_pfns[ZONE_DMA] = min(max_low_pfn,
> > > > + ((1UL << ARCH_ZONE_DMA_BITS) - 1) >>
> > > > PAGE_SHIFT);
> > > >  #endif
> > > >   max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
> > > >  #ifdef CONFIG_HIGHMEM
> > > > diff --git a/arch/powerpc/platforms/powermac/Kconfig
> > > > b/arch/powerpc/platforms/powermac/Kconfig
> > > > index f834a19ed772..c02d8c503b29 100644
> > > > --- a/arch/powerpc/platforms/powermac/Kconfig
> > > > +++ b/arch/powerpc/platforms/powermac/Kconfig
> > > > @@ -7,6 +7,7 @@ config PPC_PMAC
> > > >   select PPC_INDIRECT_PCI if PPC32
> > > >   select PPC_MPC106 if PPC32
> > > >   select PPC_NATIVE
> > > > + select ZONE_DMA if PPC32
> > > >   default y
> > > >
> > > >  config PPC_PMAC64
> > > > --
> > > > 2.20.1
> > >
> > > ---end quoted text---
>


[tip:timers/core] clocksource: Move inline keyword to the beginning of function declarations

2019-06-14 Thread tip-bot for Mathieu Malaterre
Commit-ID:  0f48b41f597e3b62b649abbf796e1e72901f9df3
Gitweb: https://git.kernel.org/tip/0f48b41f597e3b62b649abbf796e1e72901f9df3
Author: Mathieu Malaterre 
AuthorDate: Fri, 24 May 2019 12:33:39 +0200
Committer:  Thomas Gleixner 
CommitDate: Fri, 14 Jun 2019 17:04:03 +0200

clocksource: Move inline keyword to the beginning of function declarations

The inline keyword was not at the beginning of the function declarations.
Fix the following warnings triggered when using W=1:

  kernel/time/clocksource.c:108:1: warning: 'inline' is not at beginning of 
declaration [-Wold-style-declaration]
  kernel/time/clocksource.c:113:1: warning: 'inline' is not at beginning of 
declaration [-Wold-style-declaration]

Signed-off-by: Mathieu Malaterre 
Signed-off-by: Thomas Gleixner 
Cc: triv...@kernel.org
Cc: kernel-janit...@vger.kernel.org
Cc: John Stultz 
Cc: Stephen Boyd 
Link: https://lkml.kernel.org/r/20190524103339.28787-1-ma...@debian.org

---
 kernel/time/clocksource.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 3bcc19ceb073..fff5f64981c6 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -105,12 +105,12 @@ static DEFINE_SPINLOCK(watchdog_lock);
 static int watchdog_running;
 static atomic_t watchdog_reset_pending;
 
-static void inline clocksource_watchdog_lock(unsigned long *flags)
+static inline void clocksource_watchdog_lock(unsigned long *flags)
 {
spin_lock_irqsave(_lock, *flags);
 }
 
-static void inline clocksource_watchdog_unlock(unsigned long *flags)
+static inline void clocksource_watchdog_unlock(unsigned long *flags)
 {
spin_unlock_irqrestore(_lock, *flags);
 }


[tip:x86/cleanups] x86/tsc: Move inline keyword to the beginning of function declarations

2019-06-14 Thread tip-bot for Mathieu Malaterre
Commit-ID:  83e837269e87436fda1cbf82214a5494fb6b35b1
Gitweb: https://git.kernel.org/tip/83e837269e87436fda1cbf82214a5494fb6b35b1
Author: Mathieu Malaterre 
AuthorDate: Fri, 24 May 2019 12:32:51 +0200
Committer:  Thomas Gleixner 
CommitDate: Fri, 14 Jun 2019 17:02:09 +0200

x86/tsc: Move inline keyword to the beginning of function declarations

The inline keyword was not at the beginning of the function declarations.
Fix the following warnings triggered when using W=1:

  arch/x86/kernel/tsc.c:62:1: warning: 'inline' is not at beginning of 
declaration [-Wold-style-declaration]
  arch/x86/kernel/tsc.c:79:1: warning: 'inline' is not at beginning of 
declaration [-Wold-style-declaration]

Signed-off-by: Mathieu Malaterre 
Signed-off-by: Thomas Gleixner 
Cc: triv...@kernel.org
Cc: kernel-janit...@vger.kernel.org
Cc: Peter Zijlstra 
Cc: Borislav Petkov 
Cc: "H. Peter Anvin" 
Link: https://lkml.kernel.org/r/20190524103252.28575-1-ma...@debian.org

---
 arch/x86/kernel/tsc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 0b29e58f288e..75a41bddbc9d 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -59,7 +59,7 @@ struct cyc2ns {
 
 static DEFINE_PER_CPU_ALIGNED(struct cyc2ns, cyc2ns);
 
-void __always_inline cyc2ns_read_begin(struct cyc2ns_data *data)
+__always_inline void cyc2ns_read_begin(struct cyc2ns_data *data)
 {
int seq, idx;
 
@@ -76,7 +76,7 @@ void __always_inline cyc2ns_read_begin(struct cyc2ns_data 
*data)
} while (unlikely(seq != this_cpu_read(cyc2ns.seq.sequence)));
 }
 
-void __always_inline cyc2ns_read_end(void)
+__always_inline void cyc2ns_read_end(void)
 {
preempt_enable_notrace();
 }


Re: [PATCH] powerpc: enable a 30-bit ZONE_DMA for 32-bit pmac

2019-06-14 Thread Mathieu Malaterre
On Thu, Jun 13, 2019 at 10:27 AM Christoph Hellwig  wrote:
>
> With the strict dma mask checking introduced with the switch to
> the generic DMA direct code common wifi chips on 32-bit powerbooks
> stopped working.  Add a 30-bit ZONE_DMA to the 32-bit pmac builds
> to allow them to reliably allocate dma coherent memory.
>
> Fixes: 65a21b71f948 ("powerpc/dma: remove dma_nommu_dma_supported")
> Reported-by: Aaro Koskinen 
> Signed-off-by: Christoph Hellwig 
> ---
>  arch/powerpc/include/asm/page.h | 7 +++
>  arch/powerpc/mm/mem.c   | 3 ++-
>  arch/powerpc/platforms/powermac/Kconfig | 1 +
>  3 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
> index b8286a2013b4..0d52f57fca04 100644
> --- a/arch/powerpc/include/asm/page.h
> +++ b/arch/powerpc/include/asm/page.h
> @@ -319,6 +319,13 @@ struct vm_area_struct;
>  #endif /* __ASSEMBLY__ */
>  #include 
>
> +/*
> + * Allow 30-bit DMA for very limited Broadcom wifi chips on many powerbooks.

nit: would it be possible to mention explicit reference to b43-legacy.
Using b43 on my macmini g4 never showed those symptoms (using
5.2.0-rc2+)

$ dmesg | grep b43
[   14.327189] bus: 'pci': add driver b43-pci-bridge
[   14.345354] bus: 'pci': driver_probe_device: matched device
0001:10:12.0 with driver b43-pci-bridge
[   14.380110] bus: 'pci': really_probe: probing driver b43-pci-bridge
with device 0001:10:12.0
[   14.440295] b43-pci-bridge 0001:10:12.0: enabling device (0004 -> 0006)
[   14.637223] b43-pci-bridge 0001:10:12.0: Sonics Silicon Backplane
found on PCI device 0001:10:12.0
[   14.644858] driver: 'b43-pci-bridge': driver_bound: bound to device
'0001:10:12.0'
[   14.743341] bus: 'pci': really_probe: bound device 0001:10:12.0 to
driver b43-pci-bridge
[   18.724343] bus: 'bcma': add driver b43
[   18.728635] bus: 'ssb': add driver b43
[   18.734305] bus: 'ssb': driver_probe_device: matched device ssb0:0
with driver b43
[   18.743155] bus: 'ssb': really_probe: probing driver b43 with device ssb0:0
[   18.747782] b43-phy0: Broadcom 4306 WLAN found (core revision 5)
[   18.767439] b43-phy0: Found PHY: Analog 2, Type 2 (G), Revision 2
[   18.771759] b43-phy0: Found Radio: Manuf 0x17F, ID 0x2050, Revision
2, Version 0
[   18.795467] driver: 'b43': driver_bound: bound to device 'ssb0:0'
[   18.801533] bus: 'ssb': really_probe: bound device ssb0:0 to driver b43
[   22.143084] b43-phy0: Loading firmware version 666.2 (2011-02-23 01:15:07)
[   25.133011] b43 ssb0:0 wlan0: disabling HT as WMM/QoS is not
supported by the AP
[   25.140221] b43 ssb0:0 wlan0: disabling VHT as WMM/QoS is not
supported by the AP


> + */
> +#ifdef CONFIG_PPC32
> +#define ARCH_ZONE_DMA_BITS 30
> +#else
>  #define ARCH_ZONE_DMA_BITS 31
> +#endif
>
>  #endif /* _ASM_POWERPC_PAGE_H */
> diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
> index cba29131bccc..2540d3b2588c 100644
> --- a/arch/powerpc/mm/mem.c
> +++ b/arch/powerpc/mm/mem.c
> @@ -248,7 +248,8 @@ void __init paging_init(void)
>(long int)((top_of_ram - total_ram) >> 20));
>
>  #ifdef CONFIG_ZONE_DMA
> -   max_zone_pfns[ZONE_DMA] = min(max_low_pfn, 0x7fffUL >> 
> PAGE_SHIFT);
> +   max_zone_pfns[ZONE_DMA] = min(max_low_pfn,
> +   ((1UL << ARCH_ZONE_DMA_BITS) - 1) >> PAGE_SHIFT);
>  #endif
> max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
>  #ifdef CONFIG_HIGHMEM
> diff --git a/arch/powerpc/platforms/powermac/Kconfig 
> b/arch/powerpc/platforms/powermac/Kconfig
> index f834a19ed772..c02d8c503b29 100644
> --- a/arch/powerpc/platforms/powermac/Kconfig
> +++ b/arch/powerpc/platforms/powermac/Kconfig
> @@ -7,6 +7,7 @@ config PPC_PMAC
> select PPC_INDIRECT_PCI if PPC32
> select PPC_MPC106 if PPC32
> select PPC_NATIVE
> +   select ZONE_DMA if PPC32
> default y
>
>  config PPC_PMAC64
> --
> 2.20.1
>


Re: [PATCH] powerpc/32s: fix booting with CONFIG_PPC_EARLY_DEBUG_BOOTX

2019-06-07 Thread Mathieu Malaterre
On Wed, Jun 5, 2019 at 1:32 PM Mathieu Malaterre  wrote:
>
> On Mon, Jun 3, 2019 at 3:00 PM Christophe Leroy  
> wrote:
> >
> > When booting through OF, setup_disp_bat() does nothing because
> > disp_BAT are not set. By change, it used to work because BOOTX
> > buffer is mapped 1:1 at address 0x8100 by the bootloader, and
> > btext_setup_display() sets virt addr same as phys addr.
> >
> > But since commit 215b823707ce ("powerpc/32s: set up an early static
> > hash table for KASAN."), a temporary page table overrides the
> > bootloader mapping.
> >
> > This 0x8100 is also problematic with the newly implemented
> > Kernel Userspace Access Protection (KUAP) because it is within user
> > address space.
> >
> > This patch fixes those issues by properly setting disp_BAT through
> > a call to btext_prepare_BAT(), allowing setup_disp_bat() to
> > properly setup BAT3 for early bootx screen buffer access.
> >
> > Reported-by: Mathieu Malaterre 
> > Fixes: 215b823707ce ("powerpc/32s: set up an early static hash table for 
> > KASAN.")
> > Signed-off-by: Christophe Leroy 
>
> The patch below does fix the symptoms I reported. Tested with CONFIG_KASAN=n :
>
> Tested-by: Mathieu Malaterre 

Link: https://bugzilla.kernel.org/show_bug.cgi?id=203699

>
> Thanks !
>
> > ---
> >  arch/powerpc/include/asm/btext.h   | 4 
> >  arch/powerpc/kernel/prom_init.c| 1 +
> >  arch/powerpc/kernel/prom_init_check.sh | 2 +-
> >  3 files changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/powerpc/include/asm/btext.h 
> > b/arch/powerpc/include/asm/btext.h
> > index 3ffad030393c..461b0f193864 100644
> > --- a/arch/powerpc/include/asm/btext.h
> > +++ b/arch/powerpc/include/asm/btext.h
> > @@ -13,7 +13,11 @@ extern void btext_update_display(unsigned long phys, int 
> > width, int height,
> >  int depth, int pitch);
> >  extern void btext_setup_display(int width, int height, int depth, int 
> > pitch,
> > unsigned long address);
> > +#ifdef CONFIG_PPC32
> >  extern void btext_prepare_BAT(void);
> > +#else
> > +static inline void btext_prepare_BAT(void) { }
> > +#endif
> >  extern void btext_map(void);
> >  extern void btext_unmap(void);
> >
> > diff --git a/arch/powerpc/kernel/prom_init.c 
> > b/arch/powerpc/kernel/prom_init.c
> > index 3555cad7bdde..ed446b7ea164 100644
> > --- a/arch/powerpc/kernel/prom_init.c
> > +++ b/arch/powerpc/kernel/prom_init.c
> > @@ -2336,6 +2336,7 @@ static void __init prom_check_displays(void)
> > prom_printf("W=%d H=%d LB=%d addr=0x%x\n",
> > width, height, pitch, addr);
> > btext_setup_display(width, height, 8, pitch, addr);
> > +   btext_prepare_BAT();
> > }
> >  #endif /* CONFIG_PPC_EARLY_DEBUG_BOOTX */
> > }
> > diff --git a/arch/powerpc/kernel/prom_init_check.sh 
> > b/arch/powerpc/kernel/prom_init_check.sh
> > index 518d416971c1..160bef0d553d 100644
> > --- a/arch/powerpc/kernel/prom_init_check.sh
> > +++ b/arch/powerpc/kernel/prom_init_check.sh
> > @@ -24,7 +24,7 @@ fi
> >  WHITELIST="add_reloc_offset __bss_start __bss_stop copy_and_flush
> >  _end enter_prom $MEM_FUNCS reloc_offset __secondary_hold
> >  __secondary_hold_acknowledge __secondary_hold_spinloop __start
> > -logo_linux_clut224
> > +logo_linux_clut224 btext_prepare_BAT
> >  reloc_got2 kernstart_addr memstart_addr linux_banner _stext
> >  __prom_init_toc_start __prom_init_toc_end btext_setup_display TOC."
> >
> > --
> > 2.13.3
> >


[PATCH] powerpc/32: Add .data..LASAN* sections explicitly

2019-06-05 Thread Mathieu Malaterre
When both `CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y` and `CONFIG_KASAN=y`
are set, link step typically produce numberous warnings about orphan
section:

  powerpc-linux-gnu-ld: warning: orphan section `.data..LASAN0' from 
`net/core/filter.o' being placed in section `.data..LASAN0'
  powerpc-linux-gnu-ld: warning: orphan section `.data..LASANLOC1' from 
`net/core/filter.o' being placed in section `.data..LASANLOC1'

This commit remove those warnings produced at W=1.

Reported-by: Christophe Leroy 
Signed-off-by: Mathieu Malaterre 
---
 arch/powerpc/kernel/vmlinux.lds.S | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index 060a1acd7c6d..c74f4cb6ec3a 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -307,6 +307,9 @@ SECTIONS
 #ifdef CONFIG_PPC32
.data : AT(ADDR(.data) - LOAD_OFFSET) {
DATA_DATA
+#ifdef CONFIG_KASAN
+   *(.data..LASAN*)
+#endif
 #ifdef CONFIG_UBSAN
*(.data..Lubsan_data*)
*(.data..Lubsan_type*)
-- 
2.20.1



Re: [PATCH] powerpc/32s: fix booting with CONFIG_PPC_EARLY_DEBUG_BOOTX

2019-06-05 Thread Mathieu Malaterre
On Mon, Jun 3, 2019 at 3:00 PM Christophe Leroy  wrote:
>
> When booting through OF, setup_disp_bat() does nothing because
> disp_BAT are not set. By change, it used to work because BOOTX
> buffer is mapped 1:1 at address 0x8100 by the bootloader, and
> btext_setup_display() sets virt addr same as phys addr.
>
> But since commit 215b823707ce ("powerpc/32s: set up an early static
> hash table for KASAN."), a temporary page table overrides the
> bootloader mapping.
>
> This 0x8100 is also problematic with the newly implemented
> Kernel Userspace Access Protection (KUAP) because it is within user
> address space.
>
> This patch fixes those issues by properly setting disp_BAT through
> a call to btext_prepare_BAT(), allowing setup_disp_bat() to
> properly setup BAT3 for early bootx screen buffer access.
>
> Reported-by: Mathieu Malaterre 
> Fixes: 215b823707ce ("powerpc/32s: set up an early static hash table for 
> KASAN.")
> Signed-off-by: Christophe Leroy 

The patch below does fix the symptoms I reported. Tested with CONFIG_KASAN=n :

Tested-by: Mathieu Malaterre 

Thanks !

> ---
>  arch/powerpc/include/asm/btext.h   | 4 
>  arch/powerpc/kernel/prom_init.c| 1 +
>  arch/powerpc/kernel/prom_init_check.sh | 2 +-
>  3 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/include/asm/btext.h 
> b/arch/powerpc/include/asm/btext.h
> index 3ffad030393c..461b0f193864 100644
> --- a/arch/powerpc/include/asm/btext.h
> +++ b/arch/powerpc/include/asm/btext.h
> @@ -13,7 +13,11 @@ extern void btext_update_display(unsigned long phys, int 
> width, int height,
>  int depth, int pitch);
>  extern void btext_setup_display(int width, int height, int depth, int pitch,
> unsigned long address);
> +#ifdef CONFIG_PPC32
>  extern void btext_prepare_BAT(void);
> +#else
> +static inline void btext_prepare_BAT(void) { }
> +#endif
>  extern void btext_map(void);
>  extern void btext_unmap(void);
>
> diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
> index 3555cad7bdde..ed446b7ea164 100644
> --- a/arch/powerpc/kernel/prom_init.c
> +++ b/arch/powerpc/kernel/prom_init.c
> @@ -2336,6 +2336,7 @@ static void __init prom_check_displays(void)
> prom_printf("W=%d H=%d LB=%d addr=0x%x\n",
> width, height, pitch, addr);
> btext_setup_display(width, height, 8, pitch, addr);
> +   btext_prepare_BAT();
> }
>  #endif /* CONFIG_PPC_EARLY_DEBUG_BOOTX */
> }
> diff --git a/arch/powerpc/kernel/prom_init_check.sh 
> b/arch/powerpc/kernel/prom_init_check.sh
> index 518d416971c1..160bef0d553d 100644
> --- a/arch/powerpc/kernel/prom_init_check.sh
> +++ b/arch/powerpc/kernel/prom_init_check.sh
> @@ -24,7 +24,7 @@ fi
>  WHITELIST="add_reloc_offset __bss_start __bss_stop copy_and_flush
>  _end enter_prom $MEM_FUNCS reloc_offset __secondary_hold
>  __secondary_hold_acknowledge __secondary_hold_spinloop __start
> -logo_linux_clut224
> +logo_linux_clut224 btext_prepare_BAT
>  reloc_got2 kernstart_addr memstart_addr linux_banner _stext
>  __prom_init_toc_start __prom_init_toc_end btext_setup_display TOC."
>
> --
> 2.13.3
>


[PATCH] hfsplus: Replace strncpy with memcpy

2019-05-29 Thread Mathieu Malaterre
Function strncpy was used to copy a fixed size buffer. Since
NUL-terminating string is not required here, prefer a memcpy function.
The generated code (ppc32) remains the same.

Silence the following warning triggered using W=1:

  fs/hfsplus/xattr.c:410:3: warning: 'strncpy' output truncated before 
terminating nul copying 4 bytes from a string of the same length 
[-Wstringop-truncation]

Signed-off-by: Mathieu Malaterre 
---
 fs/hfsplus/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
index d5403b4004c9..bb0b27d88e50 100644
--- a/fs/hfsplus/xattr.c
+++ b/fs/hfsplus/xattr.c
@@ -407,7 +407,7 @@ static int copy_name(char *buffer, const char *xattr_name, 
int name_len)
int offset = 0;
 
if (!is_known_namespace(xattr_name)) {
-   strncpy(buffer, XATTR_MAC_OSX_PREFIX, XATTR_MAC_OSX_PREFIX_LEN);
+   memcpy(buffer, XATTR_MAC_OSX_PREFIX, XATTR_MAC_OSX_PREFIX_LEN);
offset += XATTR_MAC_OSX_PREFIX_LEN;
len += XATTR_MAC_OSX_PREFIX_LEN;
}
-- 
2.20.1



[PATCH] kbuild: Remove -Waggregate-return from scripts/Makefile.extrawarn

2019-05-29 Thread Mathieu Malaterre
It makes little sense to pass -Waggregate-return these days since large
part of the linux kernel rely on returning struct(s). For instance:

  ../include/linux/timekeeping.h: In function 'show_uptime':
  ../include/linux/ktime.h:91:34: error: function call has aggregate value 
[-Werror=aggregate-return]
   #define ktime_to_timespec64(kt)  ns_to_timespec64((kt))
^~
  ../include/linux/timekeeping.h:166:8: note: in expansion of macro 
'ktime_to_timespec64'
*ts = ktime_to_timespec64(ktime_get_coarse_boottime());

Remove this warning from W=2 completely.

Signed-off-by: Mathieu Malaterre 
---
 scripts/Makefile.extrawarn | 1 -
 1 file changed, 1 deletion(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 3ab8d1a303cd..98081ab300e5 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -34,7 +34,6 @@ warning-1 += $(call cc-option, -Wstringop-truncation)
 warning-1 += -Wno-missing-field-initializers
 warning-1 += -Wno-sign-compare
 
-warning-2 := -Waggregate-return
 warning-2 += -Wcast-align
 warning-2 += -Wdisabled-optimization
 warning-2 += -Wnested-externs
-- 
2.20.1



Re: [PATCH v2] powerpc/32: sstep: Move variable `rc` within CONFIG_PPC64 sentinels

2019-05-28 Thread Mathieu Malaterre
On Tue, May 28, 2019 at 1:40 PM Michael Ellerman  wrote:
>
> Mathieu Malaterre  writes:
>
> > Fix warnings treated as errors with W=1:
> >
> >   arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used 
> > [-Werror=unused-but-set-variable]
> >
> > Suggested-by: Christophe Leroy 
> > Signed-off-by: Mathieu Malaterre 
> > ---
> > v2: as suggested prefer CONFIG_PPC64 sentinel instead of unused keyword
>
> I'd rather avoid adding more ifdefs if we can.
>
> I think this works?

It does ! ;)

Reviewed-by: Mathieu Malaterre 

> cheers
>
> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> index 3d33fb509ef4..600b036ddfda 100644
> --- a/arch/powerpc/lib/sstep.c
> +++ b/arch/powerpc/lib/sstep.c
> @@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long 
> v2)
>  int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>   unsigned int instr)
>  {
> -   unsigned int opcode, ra, rb, rc, rd, spr, u;
> +   unsigned int opcode, ra, rb, rd, spr, u;
> unsigned long int imm;
> unsigned long int val, val2;
> unsigned int mb, me, sh;
> @@ -1292,7 +1292,6 @@ int analyse_instr(struct instruction_op *op, const 
> struct pt_regs *regs,
> rd = (instr >> 21) & 0x1f;
> ra = (instr >> 16) & 0x1f;
> rb = (instr >> 11) & 0x1f;
> -   rc = (instr >> 6) & 0x1f;
>
> switch (opcode) {
>  #ifdef __powerpc64__
> @@ -1307,10 +1306,14 @@ int analyse_instr(struct instruction_op *op, const 
> struct pt_regs *regs,
> return 1;
>
>  #ifdef __powerpc64__
> -   case 4:
> +   case 4: {
> +   unsigned int rc;
> +
> if (!cpu_has_feature(CPU_FTR_ARCH_300))
> return -1;
>
> +   rc = (instr >> 6) & 0x1f;
> +
> switch (instr & 0x3f) {
> case 48:/* maddhd */
> asm volatile(PPC_MADDHD(%0, %1, %2, %3) :
> @@ -1336,6 +1339,7 @@ int analyse_instr(struct instruction_op *op, const 
> struct pt_regs *regs,
>  * primary opcode which do not have emulation support yet.
>  */
> return -1;
> +   }
>  #endif
>
> case 7: /* mulli */


[PATCH v2] powerpc/power: Expose pfn_is_nosave prototype

2019-05-24 Thread Mathieu Malaterre
The declaration for pfn_is_nosave is only available in
kernel/power/power.h. Since this function can be override in arch,
expose it globally. Having a prototype will make sure to avoid warning
(sometime treated as error with W=1) such as:

  arch/powerpc/kernel/suspend.c:18:5: error: no previous prototype for 
'pfn_is_nosave' [-Werror=missing-prototypes]

This moves the declaration into a globally visible header file and add
missing include to avoid a warning on powerpc. Also remove the
duplicated prototypes since not required anymore.

Cc: Christophe Leroy 
Signed-off-by: Mathieu Malaterre 
---
v2: As suggestion by christophe remove duplicates prototypes

 arch/powerpc/kernel/suspend.c | 1 +
 arch/s390/kernel/entry.h  | 1 -
 include/linux/suspend.h   | 1 +
 kernel/power/power.h  | 2 --
 4 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/suspend.c b/arch/powerpc/kernel/suspend.c
index a531154cc0f3..9e1b6b894245 100644
--- a/arch/powerpc/kernel/suspend.c
+++ b/arch/powerpc/kernel/suspend.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h
index 20420c2b8a14..b2956d49b6ad 100644
--- a/arch/s390/kernel/entry.h
+++ b/arch/s390/kernel/entry.h
@@ -63,7 +63,6 @@ void __init startup_init(void);
 void die(struct pt_regs *regs, const char *str);
 int setup_profiling_timer(unsigned int multiplier);
 void __init time_init(void);
-int pfn_is_nosave(unsigned long);
 void s390_early_resume(void);
 unsigned long prepare_ftrace_return(unsigned long parent, unsigned long sp, 
unsigned long ip);
 
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 6b3ea9ea6a9e..e8b8a7bede90 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -395,6 +395,7 @@ extern bool system_entering_hibernation(void);
 extern bool hibernation_available(void);
 asmlinkage int swsusp_save(void);
 extern struct pbe *restore_pblist;
+int pfn_is_nosave(unsigned long pfn);
 #else /* CONFIG_HIBERNATION */
 static inline void register_nosave_region(unsigned long b, unsigned long e) {}
 static inline void register_nosave_region_late(unsigned long b, unsigned long 
e) {}
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 9e58bdc8a562..44bee462ff57 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -75,8 +75,6 @@ static inline void hibernate_reserved_size_init(void) {}
 static inline void hibernate_image_size_init(void) {}
 #endif /* !CONFIG_HIBERNATION */
 
-extern int pfn_is_nosave(unsigned long);
-
 #define power_attr(_name) \
 static struct kobj_attribute _name##_attr = {  \
.attr   = { \
-- 
2.20.1



[PATCH] clocksource: Move inline keyword to the beginning of function declarations

2019-05-24 Thread Mathieu Malaterre
The inline keyword was not at the beginning of the function declarations.
Fix the following warnings triggered when using W=1:

  kernel/time/clocksource.c:108:1: warning: 'inline' is not at beginning of 
declaration [-Wold-style-declaration]
  kernel/time/clocksource.c:113:1: warning: 'inline' is not at beginning of 
declaration [-Wold-style-declaration]

Signed-off-by: Mathieu Malaterre 
---
 kernel/time/clocksource.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 3bcc19ceb073..fff5f64981c6 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -105,12 +105,12 @@ static DEFINE_SPINLOCK(watchdog_lock);
 static int watchdog_running;
 static atomic_t watchdog_reset_pending;
 
-static void inline clocksource_watchdog_lock(unsigned long *flags)
+static inline void clocksource_watchdog_lock(unsigned long *flags)
 {
spin_lock_irqsave(_lock, *flags);
 }
 
-static void inline clocksource_watchdog_unlock(unsigned long *flags)
+static inline void clocksource_watchdog_unlock(unsigned long *flags)
 {
spin_unlock_irqrestore(_lock, *flags);
 }
-- 
2.20.1



[PATCH] x86/tsc: Move inline keyword to the beginning of function declarations

2019-05-24 Thread Mathieu Malaterre
The inline keyword was not at the beginning of the function declarations.
Fix the following warnings triggered when using W=1:

  arch/x86/kernel/tsc.c:62:1: warning: 'inline' is not at beginning of 
declaration [-Wold-style-declaration]
  arch/x86/kernel/tsc.c:79:1: warning: 'inline' is not at beginning of 
declaration [-Wold-style-declaration]

Cc: Peter Zijlstra 
Signed-off-by: Mathieu Malaterre 
---
 arch/x86/kernel/tsc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 0b29e58f288e..75a41bddbc9d 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -59,7 +59,7 @@ struct cyc2ns {
 
 static DEFINE_PER_CPU_ALIGNED(struct cyc2ns, cyc2ns);
 
-void __always_inline cyc2ns_read_begin(struct cyc2ns_data *data)
+__always_inline void cyc2ns_read_begin(struct cyc2ns_data *data)
 {
int seq, idx;
 
@@ -76,7 +76,7 @@ void __always_inline cyc2ns_read_begin(struct cyc2ns_data 
*data)
} while (unlikely(seq != this_cpu_read(cyc2ns.seq.sequence)));
 }
 
-void __always_inline cyc2ns_read_end(void)
+__always_inline void cyc2ns_read_end(void)
 {
preempt_enable_notrace();
 }
-- 
2.20.1



Re: [PATCH v2] powerpc/32: sstep: Move variable `rc` within CONFIG_PPC64 sentinels

2019-05-23 Thread Mathieu Malaterre
ping ?

On Tue, Mar 12, 2019 at 10:23 PM Mathieu Malaterre  wrote:
>
> Fix warnings treated as errors with W=1:
>
>   arch/powerpc/lib/sstep.c:1172:31: error: variable 'rc' set but not used 
> [-Werror=unused-but-set-variable]
>
> Suggested-by: Christophe Leroy 
> Signed-off-by: Mathieu Malaterre 
> ---
> v2: as suggested prefer CONFIG_PPC64 sentinel instead of unused keyword
>
>  arch/powerpc/lib/sstep.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> index 3d33fb509ef4..9996dc7a0b46 100644
> --- a/arch/powerpc/lib/sstep.c
> +++ b/arch/powerpc/lib/sstep.c
> @@ -1169,7 +1169,10 @@ static nokprobe_inline int trap_compare(long v1, long 
> v2)
>  int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
>   unsigned int instr)
>  {
> -   unsigned int opcode, ra, rb, rc, rd, spr, u;
> +   unsigned int opcode, ra, rb, rd, spr, u;
> +#ifdef CONFIG_PPC64
> +   unsigned int rc;
> +#endif
> unsigned long int imm;
> unsigned long int val, val2;
> unsigned int mb, me, sh;
> @@ -1292,7 +1295,9 @@ int analyse_instr(struct instruction_op *op, const 
> struct pt_regs *regs,
> rd = (instr >> 21) & 0x1f;
> ra = (instr >> 16) & 0x1f;
> rb = (instr >> 11) & 0x1f;
> +#ifdef CONFIG_PPC64
> rc = (instr >> 6) & 0x1f;
> +#endif
>
> switch (opcode) {
>  #ifdef __powerpc64__
> --
> 2.20.1
>


[PATCH] powerpc/power: Expose pfn_is_nosave prototype

2019-05-23 Thread Mathieu Malaterre
The declaration for pfn_is_nosave is only available in
kernel/power/power.h. Since this function can be override in arch,
expose it globally. Having a prototype will make sure to avoid warning
(sometime treated as error with W=1) such as:

  arch/powerpc/kernel/suspend.c:18:5: error: no previous prototype for 
'pfn_is_nosave' [-Werror=missing-prototypes]

This moves the declaration into a globally visible header file and add
missing include to avoid a warning in powerpc.

Signed-off-by: Mathieu Malaterre 
---
 arch/powerpc/kernel/suspend.c | 1 +
 include/linux/suspend.h   | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/powerpc/kernel/suspend.c b/arch/powerpc/kernel/suspend.c
index a531154cc0f3..9e1b6b894245 100644
--- a/arch/powerpc/kernel/suspend.c
+++ b/arch/powerpc/kernel/suspend.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 3f529ad9a9d2..2660bbdf5230 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -395,6 +395,7 @@ extern bool system_entering_hibernation(void);
 extern bool hibernation_available(void);
 asmlinkage int swsusp_save(void);
 extern struct pbe *restore_pblist;
+int pfn_is_nosave(unsigned long pfn);
 #else /* CONFIG_HIBERNATION */
 static inline void register_nosave_region(unsigned long b, unsigned long e) {}
 static inline void register_nosave_region_late(unsigned long b, unsigned long 
e) {}
-- 
2.20.1



[PATCH] powerpc: Remove variable ‘path’ since not used

2019-05-23 Thread Mathieu Malaterre
In commit eab00a208eb6 ("powerpc: Move `path` variable inside
DEBUG_PROM") DEBUG_PROM sentinels were added to silence a warning
(treated as error with W=1):

  arch/powerpc/kernel/prom_init.c:1388:8: error: variable ‘path’ set but not 
used [-Werror=unused-but-set-variable]

Rework the original patch and simplify the code, by removing the
variable ‘path’ completely. Fix line over 90 characters.

Suggested-by: Michael Ellerman 
Signed-off-by: Mathieu Malaterre 
---
 arch/powerpc/kernel/prom_init.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 7edb23861162..f6df4ddebb82 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -1566,9 +1566,6 @@ static void __init reserve_mem(u64 base, u64 size)
 static void __init prom_init_mem(void)
 {
phandle node;
-#ifdef DEBUG_PROM
-   char *path;
-#endif
char type[64];
unsigned int plen;
cell_t *p, *endp;
@@ -1590,9 +1587,6 @@ static void __init prom_init_mem(void)
prom_debug("root_size_cells: %x\n", rsc);
 
prom_debug("scanning memory:\n");
-#ifdef DEBUG_PROM
-   path = prom_scratch;
-#endif
 
for (node = 0; prom_next_node(); ) {
type[0] = 0;
@@ -1617,9 +1611,10 @@ static void __init prom_init_mem(void)
endp = p + (plen / sizeof(cell_t));
 
 #ifdef DEBUG_PROM
-   memset(path, 0, sizeof(prom_scratch));
-   call_prom("package-to-path", 3, 1, node, path, 
sizeof(prom_scratch) - 1);
-   prom_debug("  node %s :\n", path);
+   memset(prom_scratch, 0, sizeof(prom_scratch));
+   call_prom("package-to-path", 3, 1, node, prom_scratch,
+ sizeof(prom_scratch) - 1);
+   prom_debug("  node %s :\n", prom_scratch);
 #endif /* DEBUG_PROM */
 
while ((endp - p) >= (rac + rsc)) {
-- 
2.20.1



[PATCH] powerpc/32s: Include header file to fix a warning

2019-05-23 Thread Mathieu Malaterre
In commit 2edb16efc899 ("powerpc/32: Add KASAN support") support for
KASAN has been added. However building it as module leads to (warning
treated as error with W=1):

  arch/powerpc/mm/kasan/kasan_init_32.c:135:7: error: no previous prototype for 
'module_alloc' [-Werror=missing-prototypes]

Make sure to include  to provide the following
prototype: module_alloc.

Signed-off-by: Mathieu Malaterre 
---
 arch/powerpc/mm/kasan/kasan_init_32.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c 
b/arch/powerpc/mm/kasan/kasan_init_32.c
index 0d62be3cba47..0c31e440d094 100644
--- a/arch/powerpc/mm/kasan/kasan_init_32.c
+++ b/arch/powerpc/mm/kasan/kasan_init_32.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.20.1



[PATCH v2] powerpc: silence a -Wcast-function-type warning in dawr_write_file_bool

2019-05-15 Thread Mathieu Malaterre
In commit c1fe190c0672 ("powerpc: Add force enable of DAWR on P9
option") the following piece of code was added:

   smp_call_function((smp_call_func_t)set_dawr, _brk, 0);

Since GCC 8 this triggers the following warning about incompatible
function types:

  arch/powerpc/kernel/hw_breakpoint.c:408:21: error: cast between incompatible 
function types from 'int (*)(struct arch_hw_breakpoint *)' to 'void (*)(void 
*)' [-Werror=cast-function-type]

Since the warning is there for a reason, and should not be hidden behind
a cast, provide an intermediate callback function to avoid the warning.

Fixes: c1fe190c0672 ("powerpc: Add force enable of DAWR on P9 option")
Suggested-by: Christoph Hellwig 
Cc: Michael Neuling 
Signed-off-by: Mathieu Malaterre 
---
v2: do not hide warning using a hack

 arch/powerpc/kernel/hw_breakpoint.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/hw_breakpoint.c 
b/arch/powerpc/kernel/hw_breakpoint.c
index f70fb89dbf60..969092d84a2f 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -386,6 +386,11 @@ void hw_breakpoint_pmu_read(struct perf_event *bp)
 bool dawr_force_enable;
 EXPORT_SYMBOL_GPL(dawr_force_enable);
 
+static void set_dawr_cb(void *info)
+{
+   set_dawr(info);
+}
+
 static ssize_t dawr_write_file_bool(struct file *file,
const char __user *user_buf,
size_t count, loff_t *ppos)
@@ -405,7 +410,7 @@ static ssize_t dawr_write_file_bool(struct file *file,
 
/* If we are clearing, make sure all CPUs have the DAWR cleared */
if (!dawr_force_enable)
-   smp_call_function((smp_call_func_t)set_dawr, _brk, 0);
+   smp_call_function(set_dawr_cb, _brk, 0);
 
return rc;
 }
-- 
2.20.1



Re: [PATCH] powerpc: silence a -Wcast-function-type warning in dawr_write_file_bool

2019-05-15 Thread Mathieu Malaterre
Hi Christoph,

On Wed, May 15, 2019 at 3:14 PM Christoph Hellwig  wrote:
>
> On Wed, May 15, 2019 at 02:09:42PM +0200, Mathieu Malaterre wrote:
> > In commit c1fe190c0672 ("powerpc: Add force enable of DAWR on P9
> > option") the following piece of code was added:
> >
> >smp_call_function((smp_call_func_t)set_dawr, _brk, 0);
> >
> > Since GCC 8 this trigger the following warning about incompatible
> > function types:
>
> And the warning is there for a reason, and should not be hidden
> behind a cast.  This should instead be fixed by something like this:


OK, thanks for the quick feedback, will send a v2 asap.

> diff --git a/arch/powerpc/kernel/hw_breakpoint.c 
> b/arch/powerpc/kernel/hw_breakpoint.c
> index da307dd93ee3..a26b67a1be83 100644
> --- a/arch/powerpc/kernel/hw_breakpoint.c
> +++ b/arch/powerpc/kernel/hw_breakpoint.c
> @@ -384,6 +384,12 @@ void hw_breakpoint_pmu_read(struct perf_event *bp)
>  bool dawr_force_enable;
>  EXPORT_SYMBOL_GPL(dawr_force_enable);
>
> +
> +static void set_dawr_cb(void *info)
> +{
> +   set_dawr(info);
> +}
> +
>  static ssize_t dawr_write_file_bool(struct file *file,
> const char __user *user_buf,
> size_t count, loff_t *ppos)
> @@ -403,7 +409,7 @@ static ssize_t dawr_write_file_bool(struct file *file,
>
> /* If we are clearing, make sure all CPUs have the DAWR cleared */
> if (!dawr_force_enable)
> -   smp_call_function((smp_call_func_t)set_dawr, _brk, 0);
> +   smp_call_function(set_dawr_cb, _brk, 0);
>
> return rc;
>  }


[PATCH] powerpc: Include header file to fix a warning

2019-05-15 Thread Mathieu Malaterre
Make sure to include  to provide the following prototype:
__find_linux_pte.

Remove the following warning treated as error (W=1):

  arch/powerpc/mm/pgtable.c:316:8: error: no previous prototype for 
'__find_linux_pte' [-Werror=missing-prototypes]

Fixes: 0caed4de502c ("powerpc/mm: move __find_linux_pte() out of hugetlbpage.c")
Cc: Christophe Leroy 
Signed-off-by: Mathieu Malaterre 
---
 arch/powerpc/mm/pgtable.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
index db4a6253df92..2aa042193ace 100644
--- a/arch/powerpc/mm/pgtable.c
+++ b/arch/powerpc/mm/pgtable.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static inline int is_exec_fault(void)
 {
-- 
2.20.1



[PATCH] powerpc: silence a -Wcast-function-type warning in dawr_write_file_bool

2019-05-15 Thread Mathieu Malaterre
In commit c1fe190c0672 ("powerpc: Add force enable of DAWR on P9
option") the following piece of code was added:

   smp_call_function((smp_call_func_t)set_dawr, _brk, 0);

Since GCC 8 this trigger the following warning about incompatible
function types:

  arch/powerpc/kernel/hw_breakpoint.c:408:21: error: cast between incompatible 
function types from 'int (*)(struct arch_hw_breakpoint *)' to 'void (*)(void 
*)' [-Werror=cast-function-type]

Cast the function to an intermediate (void*) to make the compiler loose
knowledge about actual type.

Fixes: c1fe190c0672 ("powerpc: Add force enable of DAWR on P9 option")
Cc: Michael Neuling 
Signed-off-by: Mathieu Malaterre 
---
 arch/powerpc/kernel/hw_breakpoint.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/hw_breakpoint.c 
b/arch/powerpc/kernel/hw_breakpoint.c
index f70fb89dbf60..baeb4c58de3b 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -405,7 +405,8 @@ static ssize_t dawr_write_file_bool(struct file *file,
 
/* If we are clearing, make sure all CPUs have the DAWR cleared */
if (!dawr_force_enable)
-   smp_call_function((smp_call_func_t)set_dawr, _brk, 0);
+   smp_call_function((smp_call_func_t)(void *)set_dawr,
+ _brk, 0);
 
return rc;
 }
-- 
2.20.1



Re: [PATCH 1/7] rtc: jz4740: set range

2019-04-26 Thread Mathieu Malaterre
On Thu, Apr 18, 2019 at 12:01 PM Alexandre Belloni
 wrote:
>
> RTC_SEC is a 32-bit seconds counter.

For the entire series:

Tested-by: Mathieu Malaterre 

Arch is MIPS Creator CI20

>
> Signed-off-by: Alexandre Belloni 
> ---
>  drivers/rtc/rtc-jz4740.c | 12 ++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
> index d0a891777f44..079469627bd7 100644
> --- a/drivers/rtc/rtc-jz4740.c
> +++ b/drivers/rtc/rtc-jz4740.c
> @@ -348,10 +348,18 @@ static int jz4740_rtc_probe(struct platform_device 
> *pdev)
>
> device_init_wakeup(>dev, 1);
>
> -   rtc->rtc = devm_rtc_device_register(>dev, pdev->name,
> -   _rtc_ops, THIS_MODULE);
> +   rtc->rtc = devm_rtc_allocate_device(>dev);
> if (IS_ERR(rtc->rtc)) {
> ret = PTR_ERR(rtc->rtc);
> +   dev_err(>dev, "Failed to allocate rtc device: %d\n", 
> ret);
> +   return ret;
> +   }
> +
> +   rtc->rtc->ops = _rtc_ops;
> +   rtc->rtc->range_max = U32_MAX;
> +
> +   ret = rtc_register_device(rtc->rtc);
> +   if (ret) {
> dev_err(>dev, "Failed to register rtc device: %d\n", 
> ret);
> return ret;
> }
> --
> 2.20.1
>


Re: [PATCH 2/7] rtc: jz4740: switch to rtc_time64_to_tm/rtc_tm_to_time64

2019-04-26 Thread Mathieu Malaterre
On Thu, Apr 18, 2019 at 12:00 PM Alexandre Belloni
 wrote:
>
> Call the 64bit versions of rtc_tm time conversion now that the range is
> enforced by the core.
>
> Signed-off-by: Alexandre Belloni 
> ---
>  drivers/rtc/rtc-jz4740.c | 8 +++-
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
> index 079469627bd7..15b6832f3931 100644
> --- a/drivers/rtc/rtc-jz4740.c
> +++ b/drivers/rtc/rtc-jz4740.c
> @@ -171,7 +171,7 @@ static int jz4740_rtc_read_time(struct device *dev, 
> struct rtc_time *time)
> if (timeout == 0)
> return -EIO;
>
> -   rtc_time_to_tm(secs, time);
> +   rtc_time64_to_tm(secs, time);
>
> return 0;
>  }
> @@ -196,7 +196,7 @@ static int jz4740_rtc_read_alarm(struct device *dev, 
> struct rtc_wkalrm *alrm)
> alrm->enabled = !!(ctrl & JZ_RTC_CTRL_AE);
> alrm->pending = !!(ctrl & JZ_RTC_CTRL_AF);
>
> -   rtc_time_to_tm(secs, >time);
> +   rtc_time64_to_tm(secs, >time);
>
> return rtc_valid_tm(>time);
>  }
> @@ -205,9 +205,7 @@ static int jz4740_rtc_set_alarm(struct device *dev, 
> struct rtc_wkalrm *alrm)
>  {
> int ret;
> struct jz4740_rtc *rtc = dev_get_drvdata(dev);
> -   unsigned long secs;
> -
> -   rtc_tm_to_time(>time, );
> +   unsigned long secs = rtc_tm_to_time64(>time);

nitpick: all other declarations are done with uint32_t, so to make it
clear (maybe) with something like:

uint32_t secs = lower_32_bits(rtc_tm_to_time64(>time));

Technically I would have stored the full time64_t here and put a
WARN_ON(secs > U32_MAX) but I am not sure what other driver are
supposed to do in this case.

>
> ret = jz4740_rtc_reg_write(rtc, JZ_REG_RTC_SEC_ALARM, secs);
> if (!ret)
> --
> 2.20.1
>


Re: mmc: core: fix possible use after free of host

2019-04-26 Thread Mathieu Malaterre
On Wed, Apr 17, 2019 at 10:28 AM Pan Bian  wrote:
>
> In the function mmc_alloc_host, the function put_device is called to
> release allocated resources when mmc_gpio_alloc fails. Finally, the
> function pointed by host->class_dev.class->dev_release (i.e.,
> mmc_host_classdev_release) is used to release resources including the
> host structure. However, after put_device, host is used and released
> again. Resulting in a use-after-free bug.
>
> Fixes: 1ed21719448("mmc: core: fix error path in mmc_host_alloc")

The original commit 1ed21719448 looks correct to me (see
mmc_host_classdev_release).

> Signed-off-by: Pan Bian 
> ---
>  drivers/mmc/core/host.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 3a4402a..f8ac567 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -429,8 +429,6 @@ struct mmc_host *mmc_alloc_host(int extra, struct device 
> *dev)
>
> if (mmc_gpio_alloc(host)) {
> put_device(>class_dev);
> -   ida_simple_remove(_host_ida, host->index);
> -   kfree(host);
> return NULL;
> }
>
> --
> 2.7.4
>
>


[PATCH v3] lib/siphash.c: annotate implicit fall throughs

2019-03-13 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
these places in the code produced warnings (W=1). Fix them up.

This commit remove the following warnings:

  lib/siphash.c:71:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:72:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:73:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:75:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:108:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:109:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:110:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:112:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:434:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:462:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Move the break statement onto the next line to match the fall-through
comment pattern. Also move the trailing statement onto the next line to
pass checkpatch verification.

Acked-by: "Gustavo A. R. Silva" 
Signed-off-by: Mathieu Malaterre 
---
v3: move break statements onto next line and please checkpatch
v2: some cases were missed in v1, update missing ones

 lib/siphash.c | 76 +--
 1 file changed, 56 insertions(+), 20 deletions(-)

diff --git a/lib/siphash.c b/lib/siphash.c
index 3ae58b4edad6..f459e0f4a14e 100644
--- a/lib/siphash.c
+++ b/lib/siphash.c
@@ -68,13 +68,26 @@ u64 __siphash_aligned(const void *data, size_t len, const 
siphash_key_t *key)
  bytemask_from_count(left)));
 #else
switch (left) {
-   case 7: b |= ((u64)end[6]) << 48;
-   case 6: b |= ((u64)end[5]) << 40;
-   case 5: b |= ((u64)end[4]) << 32;
-   case 4: b |= le32_to_cpup(data); break;
-   case 3: b |= ((u64)end[2]) << 16;
-   case 2: b |= le16_to_cpup(data); break;
-   case 1: b |= end[0];
+   case 7:
+   b |= ((u64)end[6]) << 48;
+   /* fall through */
+   case 6:
+   b |= ((u64)end[5]) << 40;
+   /* fall through */
+   case 5:
+   b |= ((u64)end[4]) << 32;
+   /* fall through */
+   case 4:
+   b |= le32_to_cpup(data);
+   break;
+   case 3:
+   b |= ((u64)end[2]) << 16;
+   /* fall through */
+   case 2:
+   b |= le16_to_cpup(data);
+   break;
+   case 1:
+   b |= end[0];
}
 #endif
POSTAMBLE
@@ -101,13 +114,26 @@ u64 __siphash_unaligned(const void *data, size_t len, 
const siphash_key_t *key)
  bytemask_from_count(left)));
 #else
switch (left) {
-   case 7: b |= ((u64)end[6]) << 48;
-   case 6: b |= ((u64)end[5]) << 40;
-   case 5: b |= ((u64)end[4]) << 32;
-   case 4: b |= get_unaligned_le32(end); break;
-   case 3: b |= ((u64)end[2]) << 16;
-   case 2: b |= get_unaligned_le16(end); break;
-   case 1: b |= end[0];
+   case 7:
+   b |= ((u64)end[6]) << 48;
+   /* fall through */
+   case 6:
+   b |= ((u64)end[5]) << 40;
+   /* fall through */
+   case 5:
+   b |= ((u64)end[4]) << 32;
+   /* fall through */
+   case 4:
+   b |= get_unaligned_le32(end);
+   break;
+   case 3:
+   b |= ((u64)end[2]) << 16;
+   /* fall through */
+   case 2:
+   b |= get_unaligned_le16(end);
+   break;
+   case 1:
+   b |= end[0];
}
 #endif
POSTAMBLE
@@ -431,9 +457,14 @@ u32 __hsiphash_aligned(const void *data, size_t len, const 
hsiphash_key_t *key)
v0 ^= m;
}
switch (left) {
-   case 3: b |= ((u32)end[2]) << 16;
-   case 2: b |= le16_to_cpup(data); break;
-   case 1: b |= end[0];
+   case 3:
+   b |= ((u32)end[2]) << 16;
+   /* fall through */
+   case 2:
+   b |= le16_to_cpup(data);
+   break;
+   case 1:
+   b |= end[0];
}
HPOSTAMBLE
 }
@@ -454,9 +485,14 @@ u32 __hsiphash_unaligned(const void *data, size_t len,
v0 ^= m;
}
switch (left) {
-   case 3: b |= ((u32)end[2]) << 16;
-   case 2: b |= get_unaligned_le16(end); break;
-   case 1: b |= end[0];
+   case 3:
+   b |= ((u32)end[2]) << 16;
+   /* fall through */
+   case 2:
+   

Re: [PATCH v2] lib/siphash.c: annotate implicit fall throughs

2019-03-13 Thread Mathieu Malaterre
On Wed, Mar 13, 2019 at 9:34 PM Jason A. Donenfeld  wrote:
>
> Conceptually this seems pretty reasonable. Though, style-wise, perhaps
> you might want to put those breaks on the next line too, i.e. s/;
> break;/;\n\t\tbreak;/?

Good point. This needs some more love since checkpatch complains now with:

ERROR: trailing statements should be on next line
#42: FILE: lib/siphash.c:77:
+ case 4: b |= le32_to_cpup(data);

Let me merge all that and send a v2.

Thanks


Re: [PATCH 1/2] firewire: annotate implicit fall through

2019-03-13 Thread Mathieu Malaterre
On Wed, Mar 13, 2019 at 9:39 PM Gustavo A. R. Silva
 wrote:
>
> Mathieu,
>
> On 3/13/19 3:28 PM, Mathieu Malaterre wrote:
> > ping ?
> >
>
> I have sent the following patch to address all these warnings in
> firewire:
>
> https://lore.kernel.org/patchwork/patch/1040737/
>
> and, as this is being ignored, I'll add it to my tree for 5.2.

Good ! I was only starring at -next

Thanks

> Thanks
> --
> Gustavo
>
> > On Mon, Jan 14, 2019 at 9:42 PM Mathieu Malaterre  wrote:
> >>
> >> There is a plan to build the kernel with -Wimplicit-fallthrough and
> >> this place in the code produced a warning (W=1).
> >>
> >> In this particular case rewrote the comment to start with the string "fall
> >> through", so as to match the regular expression expected by GCC.
> >>
> >> This commit remove the following warning:
> >>
> >>   drivers/firewire/core-iso.c:308:7: warning: this statement may fall 
> >> through [-Wimplicit-fallthrough=]
> >>
> >> Signed-off-by: Mathieu Malaterre 
> >> ---
> >>  drivers/firewire/core-iso.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c
> >> index 35e784cffc23..d2d50bda5a5f 100644
> >> --- a/drivers/firewire/core-iso.c
> >> +++ b/drivers/firewire/core-iso.c
> >> @@ -308,7 +308,7 @@ static int manage_channel(struct fw_card *card, int 
> >> irm_id, int generation,
> >> if ((data[0] & bit) == (data[1] & bit))
> >> continue;
> >>
> >> -   /* 1394-1995 IRM, fall through to retry. */
> >> +   /* fall through - 1394-1995 IRM to retry. */
> >> default:
> >> if (retry) {
> >> retry--;
> >> --
> >> 2.19.2
> >>


Re: [PATCH 1/2] firewire: annotate implicit fall through

2019-03-13 Thread Mathieu Malaterre
ping ?

On Mon, Jan 14, 2019 at 9:42 PM Mathieu Malaterre  wrote:
>
> There is a plan to build the kernel with -Wimplicit-fallthrough and
> this place in the code produced a warning (W=1).
>
> In this particular case rewrote the comment to start with the string "fall
> through", so as to match the regular expression expected by GCC.
>
> This commit remove the following warning:
>
>   drivers/firewire/core-iso.c:308:7: warning: this statement may fall through 
> [-Wimplicit-fallthrough=]
>
> Signed-off-by: Mathieu Malaterre 
> ---
>  drivers/firewire/core-iso.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c
> index 35e784cffc23..d2d50bda5a5f 100644
> --- a/drivers/firewire/core-iso.c
> +++ b/drivers/firewire/core-iso.c
> @@ -308,7 +308,7 @@ static int manage_channel(struct fw_card *card, int 
> irm_id, int generation,
> if ((data[0] & bit) == (data[1] & bit))
> continue;
>
> -   /* 1394-1995 IRM, fall through to retry. */
> +   /* fall through - 1394-1995 IRM to retry. */
> default:
> if (retry) {
> retry--;
> --
> 2.19.2
>


Re: [PATCH] signal: annotate implicit fall through

2019-03-13 Thread Mathieu Malaterre
ping ?

On Mon, Jan 14, 2019 at 9:35 PM Mathieu Malaterre  wrote:
>
> There is a plan to build the kernel with -Wimplicit-fallthrough and
> this place in the code produced a warning (W=1).
>
> This commit remove the following warning:
>
>   kernel/signal.c:795:13: warning: this statement may fall through 
> [-Wimplicit-fallthrough=]
>
> Signed-off-by: Mathieu Malaterre 
> ---
>  kernel/signal.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/kernel/signal.c b/kernel/signal.c
> index e1d7ad8e6ab1..aa7a507757d7 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -794,6 +794,7 @@ static int check_kill_permission(int sig, struct 
> kernel_siginfo *info,
>  */
> if (!sid || sid == task_session(current))
> break;
> +   /* fall through */
> default:
> return -EPERM;
> }
> --
> 2.19.2
>


Re: [PATCH] blkcg: annotate implicit fall through

2019-03-13 Thread Mathieu Malaterre
ping ?

On Mon, Jan 14, 2019 at 9:31 PM Mathieu Malaterre  wrote:
>
> There is a plan to build the kernel with -Wimplicit-fallthrough and
> this place in the code produced a warning (W=1).
>
> This commit remove the following warning:
>
>   kernel/trace/blktrace.c:725:9: warning: this statement may fall through 
> [-Wimplicit-fallthrough=]
>
> Signed-off-by: Mathieu Malaterre 
> ---
>  kernel/trace/blktrace.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
> index fac0ddf8a8e2..e1c6d79fb4cc 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -723,6 +723,7 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned 
> cmd, char __user *arg)
>  #endif
> case BLKTRACESTART:
> start = 1;
> +   /* fall through */
> case BLKTRACESTOP:
> ret = __blk_trace_startstop(q, start);
> break;
> --
> 2.19.2
>


[PATCH v2] lib/siphash.c: annotate implicit fall throughs

2019-03-13 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
these places in the code produced warnings (W=1). Fix them up.

This commit remove the following warnings:

  lib/siphash.c:71:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:72:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:73:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:75:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:108:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:109:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:110:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:112:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:434:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  lib/siphash.c:462:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Cc: "Gustavo A. R. Silva" 
Signed-off-by: Mathieu Malaterre 
---
v2: some cases were missed in v1, update missing ones

 lib/siphash.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/lib/siphash.c b/lib/siphash.c
index 3ae58b4edad6..f4f778d28660 100644
--- a/lib/siphash.c
+++ b/lib/siphash.c
@@ -69,10 +69,14 @@ u64 __siphash_aligned(const void *data, size_t len, const 
siphash_key_t *key)
 #else
switch (left) {
case 7: b |= ((u64)end[6]) << 48;
+   /* fall through */
case 6: b |= ((u64)end[5]) << 40;
+   /* fall through */
case 5: b |= ((u64)end[4]) << 32;
+   /* fall through */
case 4: b |= le32_to_cpup(data); break;
case 3: b |= ((u64)end[2]) << 16;
+   /* fall through */
case 2: b |= le16_to_cpup(data); break;
case 1: b |= end[0];
}
@@ -102,10 +106,14 @@ u64 __siphash_unaligned(const void *data, size_t len, 
const siphash_key_t *key)
 #else
switch (left) {
case 7: b |= ((u64)end[6]) << 48;
+   /* fall through */
case 6: b |= ((u64)end[5]) << 40;
+   /* fall through */
case 5: b |= ((u64)end[4]) << 32;
+   /* fall through */
case 4: b |= get_unaligned_le32(end); break;
case 3: b |= ((u64)end[2]) << 16;
+   /* fall through */
case 2: b |= get_unaligned_le16(end); break;
case 1: b |= end[0];
}
@@ -432,6 +440,7 @@ u32 __hsiphash_aligned(const void *data, size_t len, const 
hsiphash_key_t *key)
}
switch (left) {
case 3: b |= ((u32)end[2]) << 16;
+   /* fall through */
case 2: b |= le16_to_cpup(data); break;
case 1: b |= end[0];
}
@@ -455,6 +464,7 @@ u32 __hsiphash_unaligned(const void *data, size_t len,
}
switch (left) {
case 3: b |= ((u32)end[2]) << 16;
+   /* fall through */
case 2: b |= get_unaligned_le16(end); break;
case 1: b |= end[0];
}
-- 
2.20.1



[PATCH] kbuild: deb-pkg: set executable bit for debian/rules

2019-03-13 Thread Mathieu Malaterre
This will remove the warning:

  dpkg-buildpackage: warning: debian/rules is not executable; fixing that

Signed-off-by: Mathieu Malaterre 
---
 scripts/package/mkdebian | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
index f030961c5165..3c6c82f28cac 100755
--- a/scripts/package/mkdebian
+++ b/scripts/package/mkdebian
@@ -221,5 +221,6 @@ clean:
 
 binary: binary-arch
 EOF
+chmod +x debian/rules
 
 exit 0
-- 
2.20.1



[PATCH] kernel/workqueue: Use __printf markup to silence compiler in function 'alloc_workqueue'

2019-03-12 Thread Mathieu Malaterre
Silence warnings (triggered at W=1) by adding relevant __printf attributes.

  kernel/workqueue.c:4249:2: warning: function 'alloc_workqueue' might be a 
candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

Signed-off-by: Mathieu Malaterre 
---
 kernel/workqueue.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 4026d1871407..56b7cf898f10 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4208,6 +4208,7 @@ static int init_rescuer(struct workqueue_struct *wq)
return 0;
 }
 
+__printf(1, 4)
 struct workqueue_struct *alloc_workqueue(const char *fmt,
 unsigned int flags,
 int max_active, ...)
-- 
2.20.1



Re: [PATCH] powerpc: use $(origin ARCH) to select KBUILD_DEFCONFIG

2019-02-15 Thread Mathieu Malaterre
On Fri, Feb 15, 2019 at 10:41 AM Masahiro Yamada
 wrote:
>
> I often test all Kconfig commands for all architectures. To ease my
> workflow, I want 'make defconfig' at least working without any cross
> compiler.
>
> Currently, arch/powerpc/Makefile checks CROSS_COMPILE to decide the
> default defconfig source.
>
> If CROSS_COMPILE is unset, it is likely to be the native build, so
> 'uname -m' is useful to choose the defconfig. If CROSS_COMPILE is set,
> the user is cross-building (i.e. 'uname -m' is probably x86_64), so
> it falls back to ppc64_defconfig. Yup, make sense.
>
> However, I want to run 'make ARCH=* defconfig' without setting
> CROSS_COMPILE for each architecture.
>
> My suggestion is to check $(origin ARCH).
>
> When you cross-compile the kernel, you need to set ARCH from your
> environment or from the command line.
>
> For the native build, you do not need to set ARCH. The default in
> the top Makefile is used:
>
>   ARCH?= $(SUBARCH)
>
> Hence, $(origin ARCH) returns 'file'.
>
> Before this commit, 'make ARCH=powerpc defconfig' failed:

In case you have not seen it, please check:

http://patchwork.ozlabs.org/patch/1037835/

>   $ make ARCH=powerpc defconfig
>   *** Default configuration is based on target 'x86_64_defconfig'
>   ***
>   *** Can't find default configuration 
> "arch/powerpc/configs/x86_64_defconfig"!
>   ***
>
> After this commit, it will succeed:
>
>   $ make ARCH=powerpc defconfig
>   *** Default configuration is based on 'ppc64_defconfig'
>   #
>   # configuration written to .config
>   #
>
> Signed-off-by: Masahiro Yamada 
> ---
>
>  arch/powerpc/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index ac03334..f989979 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -34,7 +34,7 @@ ifdef CONFIG_PPC_BOOK3S_32
>  KBUILD_CFLAGS  += -mcpu=powerpc
>  endif
>
> -ifeq ($(CROSS_COMPILE),)
> +ifeq ($(origin ARCH), file)
>  KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
>  else
>  KBUILD_DEFCONFIG := ppc64_defconfig
> --
> 2.7.4
>


Re: [PATCH] powerpc/ptrace: Add prototype for function pt_regs_check

2019-02-15 Thread Mathieu Malaterre
On Fri, Feb 15, 2019 at 9:21 AM Christophe Leroy
 wrote:
>
>
>
> Le 15/02/2019 à 09:11, Mathieu Malaterre a écrit :
> > On Sat, Dec 8, 2018 at 4:46 PM Mathieu Malaterre  wrote:
> >>
> >> `pt_regs_check` is a dummy function, its purpose is to break the build
> >> if struct pt_regs and struct user_pt_regs don't match.
> >>
> >> This function has no functionnal purpose, and will get eliminated at
> >> link time or after init depending on CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
> >>
> >> This commit adds a prototype to fix warning at W=1:
> >>
> >>arch/powerpc/kernel/ptrace.c:3339:13: error: no previous prototype for 
> >> ‘pt_regs_check’ [-Werror=missing-prototypes]
> >>
> >> Suggested-by: Christophe Leroy 
> >> Signed-off-by: Mathieu Malaterre 
> >> ---
> >>   arch/powerpc/kernel/ptrace.c | 4 
> >>   1 file changed, 4 insertions(+)
> >>
> >> diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
> >> index a398999d0770..341c0060b4c8 100644
> >> --- a/arch/powerpc/kernel/ptrace.c
> >> +++ b/arch/powerpc/kernel/ptrace.c
> >> @@ -3338,6 +3338,10 @@ void do_syscall_trace_leave(struct pt_regs *regs)
> >>  user_enter();
> >>   }
> >>
> >> +void __init pt_regs_check(void);
> >> +/* dummy function, its purpose is to break the build if struct pt_regs and
> >> + * struct user_pt_regs don't match.
> >> + */
> >
> > Another trick which seems to work with GCC is:
> >
> > -void __init pt_regs_check(void)
> > +static inline void __init pt_regs_check(void)
>
> Does this really work ? Did you test to ensure that the BUILD_BUG_ON
> still detect mismatch between struct pt_regs and struct user_pt_regs ?
>

My bad, I was unaware of GCC behavior for static inline in this case.
Sorry for the noise.
Original ugly patch does work though.
>
> >
> >>   void __init pt_regs_check(void)
> >>   {
> >>  BUILD_BUG_ON(offsetof(struct pt_regs, gpr) !=
> >> --
> >> 2.19.2
> >>


Re: [PATCH] powerpc/ptrace: Add prototype for function pt_regs_check

2019-02-15 Thread Mathieu Malaterre
On Sat, Dec 8, 2018 at 4:46 PM Mathieu Malaterre  wrote:
>
> `pt_regs_check` is a dummy function, its purpose is to break the build
> if struct pt_regs and struct user_pt_regs don't match.
>
> This function has no functionnal purpose, and will get eliminated at
> link time or after init depending on CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
>
> This commit adds a prototype to fix warning at W=1:
>
>   arch/powerpc/kernel/ptrace.c:3339:13: error: no previous prototype for 
> ‘pt_regs_check’ [-Werror=missing-prototypes]
>
> Suggested-by: Christophe Leroy 
> Signed-off-by: Mathieu Malaterre 
> ---
>  arch/powerpc/kernel/ptrace.c | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
> index a398999d0770..341c0060b4c8 100644
> --- a/arch/powerpc/kernel/ptrace.c
> +++ b/arch/powerpc/kernel/ptrace.c
> @@ -3338,6 +3338,10 @@ void do_syscall_trace_leave(struct pt_regs *regs)
> user_enter();
>  }
>
> +void __init pt_regs_check(void);
> +/* dummy function, its purpose is to break the build if struct pt_regs and
> + * struct user_pt_regs don't match.
> + */

Another trick which seems to work with GCC is:

-void __init pt_regs_check(void)
+static inline void __init pt_regs_check(void)

>  void __init pt_regs_check(void)
>  {
> BUILD_BUG_ON(offsetof(struct pt_regs, gpr) !=
> --
> 2.19.2
>


[PATCH] Move static keyword at beginning of declaration

2019-02-02 Thread Mathieu Malaterre
Move the static keyword around to remove the following warnings (W=1):

  arch/powerpc/platforms/ps3/os-area.c:212:1: error: 'static' is not at 
beginning of declaration [-Werror=old-style-declaration]
  arch/powerpc/platforms/ps3/system-bus.c:45:1: error: 'static' is not at 
beginning of declaration [-Werror=old-style-declaration]

Signed-off-by: Mathieu Malaterre 
---
 arch/powerpc/platforms/ps3/os-area.c| 4 ++--
 arch/powerpc/platforms/ps3/system-bus.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/os-area.c 
b/arch/powerpc/platforms/ps3/os-area.c
index f5387ad82279..4d65c5380020 100644
--- a/arch/powerpc/platforms/ps3/os-area.c
+++ b/arch/powerpc/platforms/ps3/os-area.c
@@ -205,11 +205,11 @@ static const struct os_area_db_id os_area_db_id_rtc_diff 
= {
  *  3) The number of seconds from 1970 to 2000.
  */
 
-struct saved_params {
+static struct saved_params {
unsigned int valid;
s64 rtc_diff;
unsigned int av_multi_out;
-} static saved_params;
+} saved_params;
 
 static struct property property_rtc_diff = {
.name = "linux,rtc_diff",
diff --git a/arch/powerpc/platforms/ps3/system-bus.c 
b/arch/powerpc/platforms/ps3/system-bus.c
index 5cc35d6b94b6..7c227e784247 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -37,12 +37,12 @@ static struct device ps3_system_bus = {
 };
 
 /* FIXME: need device usage counters! */
-struct {
+static struct {
struct mutex mutex;
int sb_11; /* usb 0 */
int sb_12; /* usb 0 */
int gpu;
-} static usage_hack;
+} usage_hack;
 
 static int ps3_is_device(struct ps3_system_bus_device *dev, u64 bus_id,
 u64 dev_id)
-- 
2.19.2



[PATCH] powerpc: Remove trailing semicolon after curly brace

2019-02-02 Thread Mathieu Malaterre
There is not point in having a trailing semicolon after a closing curly
brace. Remove it.

Signed-off-by: Mathieu Malaterre 
---
 arch/powerpc/sysdev/tsi108_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/sysdev/tsi108_dev.c b/arch/powerpc/sysdev/tsi108_dev.c
index 1fd0717ade02..1f1af12f23e2 100644
--- a/arch/powerpc/sysdev/tsi108_dev.c
+++ b/arch/powerpc/sysdev/tsi108_dev.c
@@ -51,7 +51,7 @@ phys_addr_t get_csrbase(void)
const void *prop = of_get_property(tsi, "reg", );
tsi108_csr_base = of_translate_address(tsi, prop);
of_node_put(tsi);
-   };
+   }
return tsi108_csr_base;
 }
 
-- 
2.19.2



Re: [PATCH] writeback: tracing: Copy only up to 31 characters in strncpy() calls

2019-01-31 Thread Mathieu Malaterre
Nick,

On Fri, Jan 25, 2019 at 6:06 PM Kees Cook  wrote:
>
> On Fri, Jan 25, 2019 at 9:18 PM Mathieu Malaterre  wrote:
> >
> > On Fri, Jan 25, 2019 at 5:26 AM Nick Desaulniers
> >  wrote:
> > >
> > > On Fri, Jan 18, 2019 at 11:32 AM Mathieu Malaterre  
> > > wrote:
> > > >
> > > > In the past an attempt was made to remove a set of warnings triggered by
> > > > gcc 8.x and W=1 by changing calls to strncpy() into strlcpy(). This was
> > > > rejected as one of the desired behavior is to keep initializing the rest
> > > > of the destination string whenever the source string is less than the
> > > > size.
> > > >
> > > > However the code makes it clear that this is not a desired behavior to
> > > > copy the entire 32 characters into the destination buffer, since it is
> > > > expected that the string is NUL terminated. So change the maximum number
> > > > of characters to be copied to be the size of the destination buffer
> > > > minus 1.
> > > >
> > > > Break long lines and make this patch go through `checkpatch --strict` 
> > > > with
> > > > no errors.
> > > >
> > > > This commit removes the following warnings:
> > > >
> > > >   include/trace/events/writeback.h:69:3: warning: 'strncpy' specified 
> > > > bound 32 equals destination size [-Wstringop-truncation]
> > > >   include/trace/events/writeback.h:99:3: warning: 'strncpy' specified 
> > > > bound 32 equals destination size [-Wstringop-truncation]
> > > >   include/trace/events/writeback.h:179:3: warning: 'strncpy' specified 
> > > > bound 32 equals destination size [-Wstringop-truncation]
> > > >   include/trace/events/writeback.h:223:3: warning: 'strncpy' specified 
> > > > bound 32 equals destination size [-Wstringop-truncation]
> > > >   include/trace/events/writeback.h:277:3: warning: 'strncpy' specified 
> > > > bound 32 equals destination size [-Wstringop-truncation]
> > > >   include/trace/events/writeback.h:299:3: warning: 'strncpy' specified 
> > > > bound 32 equals destination size [-Wstringop-truncation]
> > > >   include/trace/events/writeback.h:324:3: warning: 'strncpy' specified 
> > > > bound 32 equals destination size [-Wstringop-truncation]
> > > >   include/trace/events/writeback.h:375:3: warning: 'strncpy' specified 
> > > > bound 32 equals destination size [-Wstringop-truncation]
> > > >   include/trace/events/writeback.h:586:3: warning: 'strncpy' specified 
> > > > bound 32 equals destination size [-Wstringop-truncation]
> > > >   include/trace/events/writeback.h:660:3: warning: 'strncpy' specified 
> > > > bound 32 equals destination size [-Wstringop-truncation]
> > > >
> > > > Cc: Nick Desaulniers 
> > > > Link: https://lore.kernel.org/patchwork/patch/910830/
> > > > Signed-off-by: Mathieu Malaterre 
> > > > ---
> > > >  include/trace/events/writeback.h | 30 --
> > > >  1 file changed, 20 insertions(+), 10 deletions(-)
> > > >
> > > > diff --git a/include/trace/events/writeback.h 
> > > > b/include/trace/events/writeback.h
> > > > index 32db72c7c055..7bc58980f84f 100644
> > > > --- a/include/trace/events/writeback.h
> > > > +++ b/include/trace/events/writeback.h
> > > > @@ -67,7 +67,8 @@ TRACE_EVENT(writeback_dirty_page,
> > > >
> > > > TP_fast_assign(
> > > > strncpy(__entry->name,
> > > > -   mapping ? 
> > > > dev_name(inode_to_bdi(mapping->host)->dev) : "(unknown)", 32);
> > > > +   mapping ? 
> > > > dev_name(inode_to_bdi(mapping->host)->dev) :
> > > > +   "(unknown)", sizeof(__entry->name) - 1);
> > >
> > > Does strncpy guarantee that destination will be NULL terminated if
> > > (sizeof(src) > sizeof(dst)) || (32 > sizeof(dst))?
> >
> > No, that's the point here:
> >
> > https://www.kernel.org/doc/htmldocs/kernel-api/API-strncpy.html
> >
> > ...
> > The result is not NUL-terminated if the source exceeds count bytes.
> >
> > In the case where the length of src is less than that of count, the
> > remainder of dest will be padded with NUL.
> > ...
> >
> > One should use strlcpy for the use case you describe:
> >
> > https://www.kernel.org/doc/htmldocs/kernel-api/API-strlcpy.html
>
> Please use strspy() -- strlcpy() will read the source beyond the length limit.
> https://www.kernel.org/doc/htmldocs/kernel-api/API-strscpy.html

Quoting your previous attempt:

> Eric points out this wont initialize the rest of the dest if src if
> less than size.

Could you include 'Eric' in the thread ? I'd like to know his opinion
on a patch with strspy + memset or if strspy is enough here.

> --
> Kees Cook


Re: [PATCH v8 00/26] Ingenic TCU patchset v8

2019-01-25 Thread Mathieu Malaterre
Paul,

On Thu, Jan 24, 2019 at 10:41 PM Paul Cercueil  wrote:
>
> Hi Mathieu,
>
> Le jeu. 24 janv. 2019 à 18:26, Mathieu Malaterre  a
> écrit :
> > Paul,
> >
> > On Wed, Dec 12, 2018 at 11:09 PM Paul Cercueil 
> > wrote:
> >>
> >>  Hi,
> >>
> >>  Here's the version 8 and hopefully final version of my patchset,
> >> which
> >>  adds support for the Timer/Counter Unit found in JZ47xx SoCs from
> >>  Ingenic.
> >
> > I can no longer boot my MIPS Creator CI20 with this series (merged
> > opendingux/for-upstream-timer-v8).
> >
> > Using screen+ttyUSB, I can see messages stopping at:
> >
> > ...
> > [  OK  ] Started Cgroup management daemon.
> >  Starting Regular background program processing daemon...
> > [  OK  ] Started Regular background program processing daemon.
> >  Starting System Logging Service...
> >  Starting Provide limited super user privileges to specific
> > users...
> >  Starting Restore /etc/resolv.conf if the system cras...s
> > shut down
> >  Starting WPA supplicant...
> >  Starting D-Bus System Message Bus...
> > [  OK  ] Started D-Bus System Message Bus.
> >
> > Nothing really stands out in the error messages. Could you suggest
> > things to try out to get into a bootable state ?
>
> I'm debugging it right now on jz4740, it seems to happen when the
> clocksource
> from the ingenic-timer driver is used. Is it your case? It should not
> happen
> if you have CONFIG_INGENIC_OST set.

Here is what I see:

$ grep CONFIG_INGENIC_OST arch/mips/configs/ci20_defconfig
CONFIG_INGENIC_OST=y
$ make O=ci20 ARCH=mips CROSS_COMPILE=mipsel-linux-gnu- ci20_defconfig
$ grep CONFIG_INGENIC_OST ci20/.config
CONFIG_INGENIC_OST=y

The setting is coming from your commit:

8f66e6b9c98f MIPS: CI20: defconfig: enable OST driver

In an attempt to solve the symptoms I even played with the clock rates
with no success:

 {
/* 3 MHz for the system timer and clocksource */
assigned-clocks = < TCU_CLK_TIMER0>, < TCU_CLK_TIMER1>;
assigned-clock-rates = <75>, <75>;
};


> >>  The big change is that the timer driver has been simplified. The
> >> code to
> >>  dynamically update the system timer or clocksource to a new channel
> >> has
> >>  been removed. Now, the system timer and clocksource are provided as
> >>  children nodes in the devicetree, and the TCU channel to use for
> >> these
> >>  is deduced from their respective memory resource. The PWM driver
> >> will
> >>  also deduce from its memory resources whether a given PWM channel
> >> can be
> >>  used, or is reserved for the system timers.
> >>
> >>  Kind regards,
> >>  - Paul Cercueil
> >>
>


Re: [PATCH] writeback: tracing: Copy only up to 31 characters in strncpy() calls

2019-01-25 Thread Mathieu Malaterre
On Fri, Jan 25, 2019 at 5:26 AM Nick Desaulniers
 wrote:
>
> On Fri, Jan 18, 2019 at 11:32 AM Mathieu Malaterre  wrote:
> >
> > In the past an attempt was made to remove a set of warnings triggered by
> > gcc 8.x and W=1 by changing calls to strncpy() into strlcpy(). This was
> > rejected as one of the desired behavior is to keep initializing the rest
> > of the destination string whenever the source string is less than the
> > size.
> >
> > However the code makes it clear that this is not a desired behavior to
> > copy the entire 32 characters into the destination buffer, since it is
> > expected that the string is NUL terminated. So change the maximum number
> > of characters to be copied to be the size of the destination buffer
> > minus 1.
> >
> > Break long lines and make this patch go through `checkpatch --strict` with
> > no errors.
> >
> > This commit removes the following warnings:
> >
> >   include/trace/events/writeback.h:69:3: warning: 'strncpy' specified bound 
> > 32 equals destination size [-Wstringop-truncation]
> >   include/trace/events/writeback.h:99:3: warning: 'strncpy' specified bound 
> > 32 equals destination size [-Wstringop-truncation]
> >   include/trace/events/writeback.h:179:3: warning: 'strncpy' specified 
> > bound 32 equals destination size [-Wstringop-truncation]
> >   include/trace/events/writeback.h:223:3: warning: 'strncpy' specified 
> > bound 32 equals destination size [-Wstringop-truncation]
> >   include/trace/events/writeback.h:277:3: warning: 'strncpy' specified 
> > bound 32 equals destination size [-Wstringop-truncation]
> >   include/trace/events/writeback.h:299:3: warning: 'strncpy' specified 
> > bound 32 equals destination size [-Wstringop-truncation]
> >   include/trace/events/writeback.h:324:3: warning: 'strncpy' specified 
> > bound 32 equals destination size [-Wstringop-truncation]
> >   include/trace/events/writeback.h:375:3: warning: 'strncpy' specified 
> > bound 32 equals destination size [-Wstringop-truncation]
> >   include/trace/events/writeback.h:586:3: warning: 'strncpy' specified 
> > bound 32 equals destination size [-Wstringop-truncation]
> >   include/trace/events/writeback.h:660:3: warning: 'strncpy' specified 
> > bound 32 equals destination size [-Wstringop-truncation]
> >
> > Cc: Nick Desaulniers 
> > Link: https://lore.kernel.org/patchwork/patch/910830/
> > Signed-off-by: Mathieu Malaterre 
> > ---
> >  include/trace/events/writeback.h | 30 --
> >  1 file changed, 20 insertions(+), 10 deletions(-)
> >
> > diff --git a/include/trace/events/writeback.h 
> > b/include/trace/events/writeback.h
> > index 32db72c7c055..7bc58980f84f 100644
> > --- a/include/trace/events/writeback.h
> > +++ b/include/trace/events/writeback.h
> > @@ -67,7 +67,8 @@ TRACE_EVENT(writeback_dirty_page,
> >
> > TP_fast_assign(
> > strncpy(__entry->name,
> > -   mapping ? 
> > dev_name(inode_to_bdi(mapping->host)->dev) : "(unknown)", 32);
> > +   mapping ? 
> > dev_name(inode_to_bdi(mapping->host)->dev) :
> > +   "(unknown)", sizeof(__entry->name) - 1);
>
> Does strncpy guarantee that destination will be NULL terminated if
> (sizeof(src) > sizeof(dst)) || (32 > sizeof(dst))?

No, that's the point here:

https://www.kernel.org/doc/htmldocs/kernel-api/API-strncpy.html

...
The result is not NUL-terminated if the source exceeds count bytes.

In the case where the length of src is less than that of count, the
remainder of dest will be padded with NUL.
...

One should use strlcpy for the use case you describe:

https://www.kernel.org/doc/htmldocs/kernel-api/API-strlcpy.html

> > __entry->ino = mapping ? mapping->host->i_ino : 0;
> > __entry->index = page->index;
> > ),
> > @@ -97,7 +98,8 @@ DECLARE_EVENT_CLASS(writeback_dirty_inode_template,
> >
> > /* may be called for files on pseudo FSes w/ unregistered 
> > bdi */
> > strncpy(__entry->name,
> > -   bdi->dev ? dev_name(bdi->dev) : "(unknown)", 32);
> > +   bdi->dev ? dev_name(bdi->dev) : "(unknown)",
> > +   sizeof(__entry->name) - 1);
> > __entry->ino= inode->i_ino;
> > __entry->state  = inode->i_state;
> > __entry->flags  = flags;
> > @@

Re: [PATCH 2/2] Bluetooth: Correctly annotate implicit fall through in __rfcomm_dlc_close

2019-01-25 Thread Mathieu Malaterre
On Thu, Jan 24, 2019 at 7:07 PM Mathieu Malaterre  wrote:
>
> There is a plan to build the kernel with -Wimplicit-fallthrough and
> this place in the code produced a warning (W=1).
>
> In this particular case put the fall through comment on a separate line so
> as to match the regular expression expected by GCC.
>
> This commit removes the following warning:
>
>   net/bluetooth/rfcomm/core.c:479:6: warning: this statement may fall through 
> [-Wimplicit-fallthrough=]

Please discard, already fixed by :

6317950c1b9c Bluetooth: Mark expected switch fall-throughs

> Cc: Peter Hurley 
> Signed-off-by: Mathieu Malaterre 
> ---
>  net/bluetooth/rfcomm/core.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
> index 1a635df80643..caaae6accafa 100644
> --- a/net/bluetooth/rfcomm/core.c
> +++ b/net/bluetooth/rfcomm/core.c
> @@ -480,9 +480,8 @@ static int __rfcomm_dlc_close(struct rfcomm_dlc *d, int 
> err)
> __rfcomm_dlc_disconn(d);
> break;
> }
> -   /* if closing a dlc in a session that hasn't been started,
> -* just close and unlink the dlc
> -*/
> +   /* fall through - if closing a dlc in a session that hasn't */
> +   /* been started, just close and unlink the dlc */
>
> default:
> rfcomm_dlc_clear_timer(d);
> --
> 2.19.2
>


Re: [PATCH 1/2] Bluetooth: Annotate implicit fall through in l2cap_config_rsp

2019-01-25 Thread Mathieu Malaterre
On Fri, Jan 25, 2019 at 8:56 AM Marcel Holtmann  wrote:
>
> Hi Mathieu,
>
> > There is a plan to build the kernel with -Wimplicit-fallthrough and
> > this place in the code produced a warning (W=1).
> >
> > This commit removes the following warning:
> >
> >  net/bluetooth/l2cap_core.c:4223:6: warning: this statement may fall 
> > through [-Wimplicit-fallthrough=]
> >
> > Cc: Gustavo Padovan 
> > Signed-off-by: Mathieu Malaterre 
> > ---
> > net/bluetooth/l2cap_core.c | 1 +
> > 1 file changed, 1 insertion(+)
>
> the patches don’t apply cleanly against bluetooth-next tree. Please fix it up 
> and resend.

Never mind, both warnings are already fixed by:

6317950c1b9c Bluetooth: Mark expected switch fall-throughs

Sorry for the noise

> Regards
>
> Marcel
>


Re: [PATCH v8 00/26] Ingenic TCU patchset v8

2019-01-24 Thread Mathieu Malaterre
Paul,

On Wed, Dec 12, 2018 at 11:09 PM Paul Cercueil  wrote:
>
> Hi,
>
> Here's the version 8 and hopefully final version of my patchset, which
> adds support for the Timer/Counter Unit found in JZ47xx SoCs from
> Ingenic.

I can no longer boot my MIPS Creator CI20 with this series (merged
opendingux/for-upstream-timer-v8).

Using screen+ttyUSB, I can see messages stopping at:

...
[  OK  ] Started Cgroup management daemon.
 Starting Regular background program processing daemon...
[  OK  ] Started Regular background program processing daemon.
 Starting System Logging Service...
 Starting Provide limited super user privileges to specific users...
 Starting Restore /etc/resolv.conf if the system cras...s shut down
 Starting WPA supplicant...
 Starting D-Bus System Message Bus...
[  OK  ] Started D-Bus System Message Bus.

Nothing really stands out in the error messages. Could you suggest
things to try out to get into a bootable state ?


> The big change is that the timer driver has been simplified. The code to
> dynamically update the system timer or clocksource to a new channel has
> been removed. Now, the system timer and clocksource are provided as
> children nodes in the devicetree, and the TCU channel to use for these
> is deduced from their respective memory resource. The PWM driver will
> also deduce from its memory resources whether a given PWM channel can be
> used, or is reserved for the system timers.
>
> Kind regards,
> - Paul Cercueil
>


[PATCH v2] mac80211: Add attribute aligned(2) to struct 'action'

2019-01-24 Thread Mathieu Malaterre
During refactor in commit 9e478066eae4 ("mac80211: fix MU-MIMO
follow-MAC mode") a new struct 'action' was declared with packed
attribute as:

  struct {
  struct ieee80211_hdr_3addr hdr;
  u8 category;
  u8 action_code;
  } __packed action;

But since struct 'ieee80211_hdr_3addr' is declared with an aligned
keyword as:

  struct ieee80211_hdr {
__le16 frame_control;
__le16 duration_id;
u8 addr1[ETH_ALEN];
u8 addr2[ETH_ALEN];
u8 addr3[ETH_ALEN];
__le16 seq_ctrl;
u8 addr4[ETH_ALEN];
  } __packed __aligned(2);

Solve the ambiguity of placing aligned structure in a packed one by
adding the aligned(2) attribute to struct 'action'. This seems to be the
behavior of gcc anyway, since the following is still compiling:

  BUILD_BUG_ON(sizeof(action) != IEEE80211_MIN_ACTION_SIZE + 1);

This removes the following warning (W=1):

  net/mac80211/rx.c:234:2: warning: alignment 1 of 'struct ' is less 
than 2 [-Wpacked-not-aligned]

Cc: Johannes Berg 
Suggested-by: Johannes Berg 
Signed-off-by: Mathieu Malaterre 
---
v2: It was suggested by Johannes that an arch actually need the pack attribute 
(alpha).

 net/mac80211/rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 45aad3d3108c..885df250b67e 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -231,7 +231,7 @@ static void ieee80211_handle_mu_mimo_mon(struct 
ieee80211_sub_if_data *sdata,
struct ieee80211_hdr_3addr hdr;
u8 category;
u8 action_code;
-   } __packed action;
+   } __packed __aligned(2) action;
 
if (!sdata)
return;
-- 
2.19.2



Re: [PATCH] mac80211: Remove attribute packed from struct 'action'

2019-01-24 Thread Mathieu Malaterre
On Thu, Jan 24, 2019 at 7:08 PM Johannes Berg  wrote:
>
> On Thu, 2019-01-24 at 19:05 +0100, Mathieu Malaterre wrote:
> > During refactor in commit 9e478066eae4 ("mac80211: fix MU-MIMO
> > follow-MAC mode") a new struct 'action' was declared with packed
> > attribute as:
> >
> >   struct {
> >   struct ieee80211_hdr_3addr hdr;
> >   u8 category;
> >   u8 action_code;
> >   } __packed action;
> >
> > But since struct 'ieee80211_hdr_3addr' is declared with an aligned
> > keyword as:
> >
> >   struct ieee80211_hdr {
> >   __le16 frame_control;
> >   __le16 duration_id;
> >   u8 addr1[ETH_ALEN];
> >   u8 addr2[ETH_ALEN];
> >   u8 addr3[ETH_ALEN];
> >   __le16 seq_ctrl;
> >   u8 addr4[ETH_ALEN];
> >   } __packed __aligned(2);
> >
> > Solve the ambiguity of placing aligned structure in a packed one by
> > removing the packed attribute from struct. This seems to be the behavior
> > of gcc anyway, since the following is still compiling:
> >
> >   BUILD_BUG_ON(sizeof(action) != IEEE80211_MIN_ACTION_SIZE + 1);
>
> I'm not sure this will work on all platforms, didn't something like
> alpha pad out u8's to u32 when not requiring packing?

I was not aware of that.

> I guess I'd feel better about using __packed __aligned(2) here as well,
> which should solve the warning too?

Indeed, I will re-spin a v2 then.


[PATCH 2/2] Bluetooth: Correctly annotate implicit fall through in __rfcomm_dlc_close

2019-01-24 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

In this particular case put the fall through comment on a separate line so
as to match the regular expression expected by GCC.

This commit removes the following warning:

  net/bluetooth/rfcomm/core.c:479:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Cc: Peter Hurley 
Signed-off-by: Mathieu Malaterre 
---
 net/bluetooth/rfcomm/core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 1a635df80643..caaae6accafa 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -480,9 +480,8 @@ static int __rfcomm_dlc_close(struct rfcomm_dlc *d, int err)
__rfcomm_dlc_disconn(d);
break;
}
-   /* if closing a dlc in a session that hasn't been started,
-* just close and unlink the dlc
-*/
+   /* fall through - if closing a dlc in a session that hasn't */
+   /* been started, just close and unlink the dlc */
 
default:
rfcomm_dlc_clear_timer(d);
-- 
2.19.2



[PATCH 1/2] Bluetooth: Annotate implicit fall through in l2cap_config_rsp

2019-01-24 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

This commit removes the following warning:

  net/bluetooth/l2cap_core.c:4223:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Cc: Gustavo Padovan 
Signed-off-by: Mathieu Malaterre 
---
 net/bluetooth/l2cap_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 2a7fb517d460..a5b76e24940a 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -4244,6 +4244,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn 
*conn,
goto done;
break;
}
+   /* fall through */
 
default:
l2cap_chan_set_err(chan, ECONNRESET);
-- 
2.19.2



[PATCH] regmap: Remove attribute packed from struct 'regcache_rbtree_node'

2019-01-24 Thread Mathieu Malaterre
On one hand commit 28644c809f44 ("regmap: Add the rbtree cache support")
added 'regcache_rbtree_node' as packed structure, while on the other hand
commit e977145aeaad ("[RBTREE] Add explicit alignment to sizeof(long)
for struct rb_node.") declared struct 'rb_node' as aligned.

Solve the ambiguity of placing aligned structure in a packed one by
removing the packed attribute from struct. This seems to be the behavior
of gcc anyway.

This removes the following warning (W=1):

  drivers/base/regmap/regcache-rbtree.c:36:1: warning: alignment 1 of 'struct 
regcache_rbtree_node' is less than 4 [-Wpacked-not-aligned]

Cc: Dimitris Papastamos 
Cc: David Woodhouse 
Signed-off-by: Mathieu Malaterre 
---
 drivers/base/regmap/regcache-rbtree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regcache-rbtree.c 
b/drivers/base/regmap/regcache-rbtree.c
index 2e8f0144f9ab..9cbb4b0cd01b 100644
--- a/drivers/base/regmap/regcache-rbtree.c
+++ b/drivers/base/regmap/regcache-rbtree.c
@@ -33,7 +33,7 @@ struct regcache_rbtree_node {
unsigned int blklen;
/* the actual rbtree node holding this block */
struct rb_node node;
-} __attribute__ ((packed));
+};
 
 struct regcache_rbtree_ctx {
struct rb_root root;
-- 
2.19.2



[PATCH] mac80211: Remove attribute packed from struct 'action'

2019-01-24 Thread Mathieu Malaterre
During refactor in commit 9e478066eae4 ("mac80211: fix MU-MIMO
follow-MAC mode") a new struct 'action' was declared with packed
attribute as:

  struct {
  struct ieee80211_hdr_3addr hdr;
  u8 category;
  u8 action_code;
  } __packed action;

But since struct 'ieee80211_hdr_3addr' is declared with an aligned
keyword as:

  struct ieee80211_hdr {
__le16 frame_control;
__le16 duration_id;
u8 addr1[ETH_ALEN];
u8 addr2[ETH_ALEN];
u8 addr3[ETH_ALEN];
__le16 seq_ctrl;
u8 addr4[ETH_ALEN];
  } __packed __aligned(2);

Solve the ambiguity of placing aligned structure in a packed one by
removing the packed attribute from struct. This seems to be the behavior
of gcc anyway, since the following is still compiling:

  BUILD_BUG_ON(sizeof(action) != IEEE80211_MIN_ACTION_SIZE + 1);

This removes the following warning (W=1):

  net/mac80211/rx.c:234:2: warning: alignment 1 of 'struct ' is less 
than 2 [-Wpacked-not-aligned]

Cc: Johannes Berg 
Signed-off-by: Mathieu Malaterre 
---
 net/mac80211/rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 45aad3d3108c..709359650149 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -231,7 +231,7 @@ static void ieee80211_handle_mu_mimo_mon(struct 
ieee80211_sub_if_data *sdata,
struct ieee80211_hdr_3addr hdr;
u8 category;
u8 action_code;
-   } __packed action;
+   } action;
 
if (!sdata)
return;
-- 
2.19.2



[PATCH] ext2: Annotate implicit fall through in __ext2_truncate_blocks

2019-01-24 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
these places in the code produced warnings (W=1).

This commit removes the following warnings:

  fs/ext2/inode.c:1237:7: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  fs/ext2/inode.c:1244:7: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 fs/ext2/inode.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index e4bb9386c045..e64029b1bd50 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1239,6 +1239,7 @@ static void __ext2_truncate_blocks(struct inode *inode, 
loff_t offset)
mark_inode_dirty(inode);
ext2_free_branches(inode, , +1, 1);
}
+   /* fall through */
case EXT2_IND_BLOCK:
nr = i_data[EXT2_DIND_BLOCK];
if (nr) {
@@ -1246,6 +1247,7 @@ static void __ext2_truncate_blocks(struct inode *inode, 
loff_t offset)
mark_inode_dirty(inode);
ext2_free_branches(inode, , +1, 2);
}
+   /* fall through */
case EXT2_DIND_BLOCK:
nr = i_data[EXT2_TIND_BLOCK];
if (nr) {
-- 
2.19.2



[PATCH] drivers: base: Use __printf markup to silence compiler

2019-01-23 Thread Mathieu Malaterre
Silence warnings (triggered at W=1) by adding relevant __printf
attributes.

  drivers/base/cpu.c:432:2: warning: function '__cpu_device_create' might be a 
candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

Signed-off-by: Mathieu Malaterre 
---
 drivers/base/cpu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index eb9443d5bae1..de74d7d93558 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -409,6 +409,7 @@ static void device_create_release(struct device *dev)
kfree(dev);
 }
 
+__printf(4, 0)
 static struct device *
 __cpu_device_create(struct device *parent, void *drvdata,
const struct attribute_group **groups,
-- 
2.19.2



[PATCH] ASoC: Use __printf markup to silence compiler

2019-01-23 Thread Mathieu Malaterre
Silence warnings (triggered at W=1) by adding relevant __printf
attributes.

  sound/soc/soc-dapm.c:149:2: warning: function 'pop_dbg' might be a candidate 
for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

Signed-off-by: Mathieu Malaterre 
---
 sound/soc/soc-dapm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index a5178845065b..92a2e7dab5fe 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -133,6 +133,7 @@ static void pop_wait(u32 pop_time)
schedule_timeout_uninterruptible(msecs_to_jiffies(pop_time));
 }
 
+__printf(3, 4)
 static void pop_dbg(struct device *dev, u32 pop_time, const char *fmt, ...)
 {
va_list args;
-- 
2.19.2



Re: [PATCH v8 05/26] clocksource: Add driver for the Ingenic JZ47xx OST

2019-01-23 Thread Mathieu Malaterre
On Wed, Dec 12, 2018 at 11:09 PM Paul Cercueil  wrote:
>
> From: Maarten ter Huurne 
>
> OST is the OS Timer, a 64-bit timer/counter with buffered reading.
>
> SoCs before the JZ4770 had (if any) a 32-bit OST; the JZ4770 and
> JZ4780 have a 64-bit OST.
>
> This driver will register both a clocksource and a sched_clock to the
> system.
>
> Signed-off-by: Maarten ter Huurne 
> Signed-off-by: Paul Cercueil 
> ---
>
> Notes:
>  v5: New patch
>
>  v6: - Get rid of SoC IDs; pass pointer to ingenic_ost_soc_info as
>devicetree match data instead.
>  - Use device_get_match_data() instead of the of_* variant
>  - Handle error of dev_get_regmap() properly
>
>  v7: Fix section mismatch by using builtin_platform_driver_probe()
>
>  v8: builtin_platform_driver_probe() does not work anymore in
>  4.20-rc6? The probe function won't be called. Work around this
>  for now by using late_initcall.
>
>  drivers/clocksource/Kconfig   |   8 ++
>  drivers/clocksource/Makefile  |   1 +
>  drivers/clocksource/ingenic-ost.c | 215 
> ++
>  3 files changed, 224 insertions(+)
>  create mode 100644 drivers/clocksource/ingenic-ost.c
>
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 4e69af15c3e7..e0646878b0de 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -648,4 +648,12 @@ config INGENIC_TIMER
> help
>   Support for the timer/counter unit of the Ingenic JZ SoCs.
>
> +config INGENIC_OST
> +   bool "Ingenic JZ47xx Operating System Timer"
> +   depends on MIPS || COMPILE_TEST
> +   depends on COMMON_CLK
> +   select INGENIC_TIMER
> +   help
> + Support for the OS Timer of the Ingenic JZ4770 or similar SoC.
> +
>  endmenu
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index 7c8f790dcf67..7faa8108574a 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -75,6 +75,7 @@ obj-$(CONFIG_ASM9260_TIMER)   += asm9260_timer.o
>  obj-$(CONFIG_H8300_TMR8)   += h8300_timer8.o
>  obj-$(CONFIG_H8300_TMR16)  += h8300_timer16.o
>  obj-$(CONFIG_H8300_TPU)+= h8300_tpu.o
> +obj-$(CONFIG_INGENIC_OST)  += ingenic-ost.o
>  obj-$(CONFIG_INGENIC_TIMER)+= ingenic-timer.o
>  obj-$(CONFIG_CLKSRC_ST_LPC)+= clksrc_st_lpc.o
>  obj-$(CONFIG_X86_NUMACHIP) += numachip.o
> diff --git a/drivers/clocksource/ingenic-ost.c 
> b/drivers/clocksource/ingenic-ost.c
> new file mode 100644
> index ..cc0fee3efd29
> --- /dev/null
> +++ b/drivers/clocksource/ingenic-ost.c
> @@ -0,0 +1,215 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * JZ47xx SoCs TCU Operating System Timer driver
> + *
> + * Copyright (C) 2016 Maarten ter Huurne 
> + * Copyright (C) 2018 Paul Cercueil 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "ingenic-timer.h"
> +
> +#define TCU_OST_TCSR_MASK  0xc0
> +#define TCU_OST_TCSR_CNT_MDBIT(15)
> +
> +#define TCU_OST_CHANNEL15
> +
> +struct ingenic_ost_soc_info {
> +   bool is64bit;
> +};
> +
> +struct ingenic_ost {
> +   struct regmap *map;
> +   struct clk *clk;
> +
> +   struct clocksource cs;
> +};
> +
> +static u64 notrace ingenic_ost_read_cntl(void)
> +{
> +   /* Bypass the regmap here as we must return as soon as possible */
> +   return readl(ingenic_tcu_base + TCU_REG_OST_CNTL);
> +}
> +
> +static u64 notrace ingenic_ost_read_cnth(void)
> +{
> +   /* Bypass the regmap here as we must return as soon as possible */
> +   return readl(ingenic_tcu_base + TCU_REG_OST_CNTH);
> +}
> +
> +static u64 notrace ingenic_ost_clocksource_read(struct clocksource *cs)
> +{
> +   u32 val1, val2;
> +   u64 count, recount;
> +   s64 diff;
> +
> +   /*
> +* The buffering of the upper 32 bits of the timer prevents wrong
> +* results from the bottom 32 bits overflowing due to the timer 
> ticking
> +* along. However, it does not prevent wrong results from simultaneous
> +* reads of the timer, which could reset the buffer mid-read.
> +* Since this kind of wrong read can happen only when the bottom bits
> +* overflow, there will be minutes between wrong reads, so if we read
> +* twice in succession, at least one of the reads will be correct.
> +*/
> +
> +   /* Bypass the regmap here as we must return as soon as possible */
> +   val1 = readl(ingenic_tcu_base + TCU_REG_OST_CNTL);
> +   val2 = readl(ingenic_tcu_base + TCU_REG_OST_CNTHBUF);
> +   count = (u64)val1 | (u64)val2 << 32;
> +
> +   val1 = readl(ingenic_tcu_base + TCU_REG_OST_CNTL);
> +   val2 = readl(ingenic_tcu_base + TCU_REG_OST_CNTHBUF);
> +   recount = (u64)val1 | (u64)val2 << 32;
> +
> +   

Re: [PATCH] video/hdmi: Change strncpy() into memcpy() in hdmi_spd_infoframe_init

2019-01-18 Thread Mathieu Malaterre
On Fri, Jan 18, 2019 at 8:51 PM Joe Perches  wrote:
>
> On Fri, 2019-01-18 at 20:32 +0100, Mathieu Malaterre wrote:
> > Using strncpy() is less than perfect since the destination buffers do not
> > need to be NUL terminated. Replace strncpy() with memcpy() to address a
> > warning triggered by gcc using W=1 and optimize the code a bit.
> >
> > This commit removes the following warnings:
> >
> >   drivers/video/hdmi.c:234:2: warning: 'strncpy' specified bound 8 equals 
> > destination size [-Wstringop-truncation]
> >   drivers/video/hdmi.c:235:2: warning: 'strncpy' specified bound 16 equals 
> > destination size [-Wstringop-truncation]
> []
> > diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
> []
> > @@ -231,8 +231,8 @@ int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe 
> > *frame,
> >   frame->version = 1;
> >   frame->length = HDMI_SPD_INFOFRAME_SIZE;
> >
> > - strncpy(frame->vendor, vendor, sizeof(frame->vendor));
> > - strncpy(frame->product, product, sizeof(frame->product));
> > + memcpy(frame->vendor, vendor, sizeof(frame->vendor));
> > + memcpy(frame->product, product, sizeof(frame->product));
>
> This is not good.
>
> vendor can be any location and shorter than sizeof(frame->vendor)
> so this can copy from invalid memory locations.

Ah right. I did not realize that and know I see the call with "Intel",
will re-spin.

> You probably want strscpy.

Right.

> This is called with at least "mediatek" and "broadcom", so perhaps
> it's better still to change the struct vendor size to something a
> bit larger.  Maybe change vendor[8] to vendor[16];

Looks like 8 bytes is required for call like hdmi_spd_infoframe_unpack()

> include/linux/hdmi.h:struct hdmi_spd_infoframe {
> include/linux/hdmi.h-   enum hdmi_infoframe_type type;
> include/linux/hdmi.h-   unsigned char version;
> include/linux/hdmi.h-   unsigned char length;
> include/linux/hdmi.h-   char vendor[8];
> include/linux/hdmi.h-   char product[16];
> include/linux/hdmi.h-   enum hdmi_spd_sdi sdi;
> include/linux/hdmi.h-};
>
>


[PATCH] writeback: tracing: Copy only up to 31 characters in strncpy() calls

2019-01-18 Thread Mathieu Malaterre
In the past an attempt was made to remove a set of warnings triggered by
gcc 8.x and W=1 by changing calls to strncpy() into strlcpy(). This was
rejected as one of the desired behavior is to keep initializing the rest
of the destination string whenever the source string is less than the
size.

However the code makes it clear that this is not a desired behavior to
copy the entire 32 characters into the destination buffer, since it is
expected that the string is NUL terminated. So change the maximum number
of characters to be copied to be the size of the destination buffer
minus 1.

Break long lines and make this patch go through `checkpatch --strict` with
no errors.

This commit removes the following warnings:

  include/trace/events/writeback.h:69:3: warning: 'strncpy' specified bound 32 
equals destination size [-Wstringop-truncation]
  include/trace/events/writeback.h:99:3: warning: 'strncpy' specified bound 32 
equals destination size [-Wstringop-truncation]
  include/trace/events/writeback.h:179:3: warning: 'strncpy' specified bound 32 
equals destination size [-Wstringop-truncation]
  include/trace/events/writeback.h:223:3: warning: 'strncpy' specified bound 32 
equals destination size [-Wstringop-truncation]
  include/trace/events/writeback.h:277:3: warning: 'strncpy' specified bound 32 
equals destination size [-Wstringop-truncation]
  include/trace/events/writeback.h:299:3: warning: 'strncpy' specified bound 32 
equals destination size [-Wstringop-truncation]
  include/trace/events/writeback.h:324:3: warning: 'strncpy' specified bound 32 
equals destination size [-Wstringop-truncation]
  include/trace/events/writeback.h:375:3: warning: 'strncpy' specified bound 32 
equals destination size [-Wstringop-truncation]
  include/trace/events/writeback.h:586:3: warning: 'strncpy' specified bound 32 
equals destination size [-Wstringop-truncation]
  include/trace/events/writeback.h:660:3: warning: 'strncpy' specified bound 32 
equals destination size [-Wstringop-truncation]

Cc: Nick Desaulniers 
Link: https://lore.kernel.org/patchwork/patch/910830/
Signed-off-by: Mathieu Malaterre 
---
 include/trace/events/writeback.h | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index 32db72c7c055..7bc58980f84f 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -67,7 +67,8 @@ TRACE_EVENT(writeback_dirty_page,
 
TP_fast_assign(
strncpy(__entry->name,
-   mapping ? dev_name(inode_to_bdi(mapping->host)->dev) : 
"(unknown)", 32);
+   mapping ? dev_name(inode_to_bdi(mapping->host)->dev) :
+   "(unknown)", sizeof(__entry->name) - 1);
__entry->ino = mapping ? mapping->host->i_ino : 0;
__entry->index = page->index;
),
@@ -97,7 +98,8 @@ DECLARE_EVENT_CLASS(writeback_dirty_inode_template,
 
/* may be called for files on pseudo FSes w/ unregistered bdi */
strncpy(__entry->name,
-   bdi->dev ? dev_name(bdi->dev) : "(unknown)", 32);
+   bdi->dev ? dev_name(bdi->dev) : "(unknown)",
+   sizeof(__entry->name) - 1);
__entry->ino= inode->i_ino;
__entry->state  = inode->i_state;
__entry->flags  = flags;
@@ -177,7 +179,8 @@ DECLARE_EVENT_CLASS(writeback_write_inode_template,
 
TP_fast_assign(
strncpy(__entry->name,
-   dev_name(inode_to_bdi(inode)->dev), 32);
+   dev_name(inode_to_bdi(inode)->dev),
+   sizeof(__entry->name) - 1);
__entry->ino= inode->i_ino;
__entry->sync_mode  = wbc->sync_mode;
__entry->cgroup_ino = __trace_wbc_assign_cgroup(wbc);
@@ -221,7 +224,8 @@ DECLARE_EVENT_CLASS(writeback_work_class,
),
TP_fast_assign(
strncpy(__entry->name,
-   wb->bdi->dev ? dev_name(wb->bdi->dev) : "(unknown)", 
32);
+   wb->bdi->dev ? dev_name(wb->bdi->dev) : "(unknown)",
+   sizeof(__entry->name) - 1);
__entry->nr_pages = work->nr_pages;
__entry->sb_dev = work->sb ? work->sb->s_dev : 0;
__entry->sync_mode = work->sync_mode;
@@ -274,7 +278,8 @@ DECLARE_EVENT_CLASS(writeback_class,
__field(unsigned int, cgroup_ino)
),
TP_fast_assign(
-   strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
+   strncpy(__entry->name, dev_name(w

[PATCH] video/hdmi: Change strncpy() into memcpy() in hdmi_spd_infoframe_init

2019-01-18 Thread Mathieu Malaterre
Using strncpy() is less than perfect since the destination buffers do not
need to be NUL terminated. Replace strncpy() with memcpy() to address a
warning triggered by gcc using W=1 and optimize the code a bit.

This commit removes the following warnings:

  drivers/video/hdmi.c:234:2: warning: 'strncpy' specified bound 8 equals 
destination size [-Wstringop-truncation]
  drivers/video/hdmi.c:235:2: warning: 'strncpy' specified bound 16 equals 
destination size [-Wstringop-truncation]

Signed-off-by: Mathieu Malaterre 
---
 drivers/video/hdmi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 799ae49774f5..553c39ac8f9e 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -231,8 +231,8 @@ int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe 
*frame,
frame->version = 1;
frame->length = HDMI_SPD_INFOFRAME_SIZE;
 
-   strncpy(frame->vendor, vendor, sizeof(frame->vendor));
-   strncpy(frame->product, product, sizeof(frame->product));
+   memcpy(frame->vendor, vendor, sizeof(frame->vendor));
+   memcpy(frame->product, product, sizeof(frame->product));
 
return 0;
 }
-- 
2.19.2



[PATCH v2] drm: radeon: add a missing break in evergreen_cs_handle_reg

2019-01-17 Thread Mathieu Malaterre
In commit dd220a00e8bd ("drm/radeon/kms: add support for streamout v7")
case statements were added without a terminating break statement. This
commit adds the missing break. This was discovered during a compilation
with W=1.

This commit removes the following warning:

  drivers/gpu/drm/radeon/evergreen_cs.c:1301:11: warning: this statement may 
fall through [-Wimplicit-fallthrough=]

Suggested-by: Alex Deucher 
Fixes: dd220a00e8bd ("drm/radeon/kms: add support for streamout v7")
Signed-off-by: Mathieu Malaterre 
---
v2: Add missing break statement, instead of marking it as fall through

 drivers/gpu/drm/radeon/evergreen_cs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/radeon/evergreen_cs.c 
b/drivers/gpu/drm/radeon/evergreen_cs.c
index f471537c852f..1e14c6921454 100644
--- a/drivers/gpu/drm/radeon/evergreen_cs.c
+++ b/drivers/gpu/drm/radeon/evergreen_cs.c
@@ -1299,6 +1299,7 @@ static int evergreen_cs_handle_reg(struct 
radeon_cs_parser *p, u32 reg, u32 idx)
return -EINVAL;
}
ib[idx] += (u32)((reloc->gpu_offset >> 8) & 0x);
+   break;
case CB_TARGET_MASK:
track->cb_target_mask = radeon_get_ib_value(p, idx);
track->cb_dirty = true;
-- 
2.19.2



[PATCH] mmc: Annotate implicit fall through in jz_mmc_irq_worker

2019-01-16 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
these places in the code produced warnings (W=1).

This commit removes the following warnings:

  drivers/mmc/host/jz4740_mmc.c:745:3: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  drivers/mmc/host/jz4740_mmc.c:779:3: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 drivers/mmc/host/jz4740_mmc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
index 33215d66afa2..a1df8bc0b964 100644
--- a/drivers/mmc/host/jz4740_mmc.c
+++ b/drivers/mmc/host/jz4740_mmc.c
@@ -743,6 +743,7 @@ static irqreturn_t jz_mmc_irq_worker(int irq, void *devid)
break;
 
jz_mmc_prepare_data_transfer(host);
+   /* fall through */
 
case JZ4740_MMC_STATE_TRANSFER_DATA:
if (host->use_dma) {
@@ -777,6 +778,7 @@ static irqreturn_t jz_mmc_irq_worker(int irq, void *devid)
break;
}
jz4740_mmc_write_irq_reg(host, JZ_MMC_IRQ_DATA_TRAN_DONE);
+   /* fall through */
 
case JZ4740_MMC_STATE_SEND_STOP:
if (!req->stop)
-- 
2.19.2



[PATCH 1/2] mtd: Annotate implicit fall through in nand_command/nand_command_lp

2019-01-16 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
these places in the code produced warnings (W=1).

This commit removes the following warnings:

  drivers/mtd/nand/raw/nand_legacy.c:332:6: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
  drivers/mtd/nand/raw/nand_legacy.c:483:3: warning: this statement may fall 
through [-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 drivers/mtd/nand/raw/nand_legacy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/nand_legacy.c 
b/drivers/mtd/nand/raw/nand_legacy.c
index 43575943f13b..f2526ec616a6 100644
--- a/drivers/mtd/nand/raw/nand_legacy.c
+++ b/drivers/mtd/nand/raw/nand_legacy.c
@@ -331,6 +331,7 @@ static void nand_command(struct nand_chip *chip, unsigned 
int command,
 */
if (column == -1 && page_addr == -1)
return;
+   /* fall through */
 
default:
/*
@@ -483,7 +484,7 @@ static void nand_command_lp(struct nand_chip *chip, 
unsigned int command,
chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE,
  NAND_NCE | NAND_CTRL_CHANGE);
 
-   /* This applies to read commands */
+   /* fall through - This applies to read commands */
default:
/*
 * If we don't have access to the busy pin, we apply the given
-- 
2.19.2



[PATCH 2/2] mtd: Annotate implicit fall through in nand_scan_tail

2019-01-16 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
these places in the code produced warnings (W=1).

This commit removes the following warnings:

  drivers/mtd/nand/raw/nand_base.c:5556:6: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
  drivers/mtd/nand/raw/nand_base.c:5575:6: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
  drivers/mtd/nand/raw/nand_base.c:5613:13: warning: this statement may fall 
through [-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 drivers/mtd/nand/raw/nand_base.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index cca4b24d2ffa..da344c276088 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -,6 +,7 @@ static int nand_scan_tail(struct nand_chip *chip)
}
if (!ecc->read_page)
ecc->read_page = nand_read_page_hwecc_oob_first;
+   /* fall through */
 
case NAND_ECC_HW:
/* Use standard hwecc read page function? */
@@ -5574,6 +5575,7 @@ static int nand_scan_tail(struct nand_chip *chip)
ecc->read_subpage = nand_read_subpage;
if (!ecc->write_subpage && ecc->hwctl && ecc->calculate)
ecc->write_subpage = nand_write_subpage_hwecc;
+   /* fall through */
 
case NAND_ECC_HW_SYNDROME:
if ((!ecc->calculate || !ecc->correct || !ecc->hwctl) &&
@@ -5611,6 +5613,7 @@ static int nand_scan_tail(struct nand_chip *chip)
ecc->size, mtd->writesize);
ecc->mode = NAND_ECC_SOFT;
ecc->algo = NAND_ECC_HAMMING;
+   /* fall through */
 
case NAND_ECC_SOFT:
ret = nand_set_ecc_soft_ops(chip);
-- 
2.19.2



[PATCH] davicom: Annotate implicit fall through in dm9000_set_io

2019-01-16 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

This commit removes the following warning:

  include/linux/device.h:1480:5: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  drivers/net/ethernet/davicom/dm9000.c:397:3: note: in expansion of macro 
'dev_dbg'
  drivers/net/ethernet/davicom/dm9000.c:398:2: note: here

Signed-off-by: Mathieu Malaterre 
---
 drivers/net/ethernet/davicom/dm9000.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/davicom/dm9000.c 
b/drivers/net/ethernet/davicom/dm9000.c
index 0a82fcf16d35..c2586f44c29d 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -395,6 +395,7 @@ static void dm9000_set_io(struct board_info *db, int 
byte_width)
 
case 3:
dev_dbg(db->dev, ": 3 byte IO, falling back to 16bit\n");
+   /* fall through */
case 2:
db->dumpblk = dm9000_dumpblk_16bit;
db->outblk  = dm9000_outblk_16bit;
-- 
2.19.2



[PATCH v2 2/2] bpf: Correctly annotate implicit fall through in bpf_base_func_proto

2019-01-16 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warnings (W=1).

To preserve as much of the existing comment only change a ‘:’ into a ‘,’.
This is enough change, to match the regular expression expected by GCC.

This commit remove the following warning:

  net/core/filter.c:5310:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
v2: reword the patch subject, remove a typo

 net/core/filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index 2b3b436ef545..d9076e609fca 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5309,7 +5309,7 @@ bpf_base_func_proto(enum bpf_func_id func_id)
case BPF_FUNC_trace_printk:
if (capable(CAP_SYS_ADMIN))
return bpf_get_trace_printk_proto();
-   /* else: fall through */
+   /* else, fall through */
default:
return NULL;
}
-- 
2.19.2



[PATCH v2 1/2] bpf: Annotate implicit fall through in cgroup_dev_func_proto

2019-01-16 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warnings (W=1).

This commit remove the following warning:

  kernel/bpf/cgroup.c:719:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
v2: Reword the patch subject

 kernel/bpf/cgroup.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
index 9425c2fb872f..ab612fe9862f 100644
--- a/kernel/bpf/cgroup.c
+++ b/kernel/bpf/cgroup.c
@@ -718,6 +718,7 @@ cgroup_dev_func_proto(enum bpf_func_id func_id, const 
struct bpf_prog *prog)
case BPF_FUNC_trace_printk:
if (capable(CAP_SYS_ADMIN))
return bpf_get_trace_printk_proto();
+   /* fall through */
default:
return NULL;
}
-- 
2.19.2



[PATCH v2 1/2] bpf: Annotate implicit fall through in cgroup_dev_func_proto

2019-01-16 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warnings (W=1).

This commit remove the following warning:

  kernel/bpf/cgroup.c:719:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 kernel/bpf/cgroup.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
index 9425c2fb872f..ab612fe9862f 100644
--- a/kernel/bpf/cgroup.c
+++ b/kernel/bpf/cgroup.c
@@ -718,6 +718,7 @@ cgroup_dev_func_proto(enum bpf_func_id func_id, const 
struct bpf_prog *prog)
case BPF_FUNC_trace_printk:
if (capable(CAP_SYS_ADMIN))
return bpf_get_trace_printk_proto();
+   /* fall through */
default:
return NULL;
}
-- 
2.19.2



[PATCH] bpf: Make function btf_name_offset_valid static

2019-01-16 Thread Mathieu Malaterre
Initially in commit 69b693f0aefa ("bpf: btf: Introduce BPF Type Format
(BTF)") the function 'btf_name_offset_valid' was introduced as static
function it was later on changed to a non-static one, and then finally
in commit c454a46b5efd ("bpf: Add bpf_line_info support") the function
prototype was removed.

Revert back to original implementation and make the function static.
Remove warning triggered with W=1:

  kernel/bpf/btf.c:470:6: warning: no previous prototype for 
'btf_name_offset_valid' [-Wmissing-prototypes]

Signed-off-by: Mathieu Malaterre 
---
 kernel/bpf/btf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index a2f53642592b..befe570be5ba 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -467,7 +467,7 @@ static const struct btf_kind_operations *btf_type_ops(const 
struct btf_type *t)
return kind_ops[BTF_INFO_KIND(t->info)];
 }
 
-bool btf_name_offset_valid(const struct btf *btf, u32 offset)
+static bool btf_name_offset_valid(const struct btf *btf, u32 offset)
 {
return BTF_STR_OFFSET_VALID(offset) &&
offset < btf->hdr.str_len;
-- 
2.19.2



Re: [PATCH] mount: Make function to_mnt_ns static

2019-01-16 Thread Mathieu Malaterre
ping ?

On Fri, Dec 7, 2018 at 9:43 PM Mathieu Malaterre  wrote:
>
> In commit 58be28256d98 ("make mntns ->get()/->put()/->install()/->inum()
> work with _ns->ns"), a new function `to_mnt_ns` was introduced.
> Since this function can be made static, make it so.
>
> Fix warning when compiling with W=1:
>
>   fs/namespace.c:1693:23: warning: no previous prototype for ‘to_mnt_ns’ 
> [-Wmissing-prototypes]
>
> Signed-off-by: Mathieu Malaterre 
> ---
>  fs/namespace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/namespace.c b/fs/namespace.c
> index a7f91265ea67..f0cf252d9aa3 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -1690,7 +1690,7 @@ static bool is_mnt_ns_file(struct dentry *dentry)
>dentry->d_fsdata == _operations;
>  }
>
> -struct mnt_namespace *to_mnt_ns(struct ns_common *ns)
> +static struct mnt_namespace *to_mnt_ns(struct ns_common *ns)
>  {
> return container_of(ns, struct mnt_namespace, ns);
>  }
> --
> 2.19.2
>


Re: [PATCH] kbuild: mark prepare0 as PHONY to fix external module build

2019-01-15 Thread Mathieu Malaterre
On Tue, Jan 15, 2019 at 8:22 AM Masahiro Yamada
 wrote:
>
> Commit c3ff2a5193fa ("powerpc/32: add stack protector support")
> caused kernel panic on PowerPC if an external module is used with
> CONFIG_STACKPROTECTOR because the 'prepare' target was not executed
> for the external module build.
>
> Commit e07db28eea38 ("kbuild: fix single target build for external
> module") turned it into a build error because the 'prepare' target is
> now executed but the 'prepare0' target is missing for the external
> module build.
>
> External module on arm/arm64 with CONFIG_STACKPROTECTOR_PER_TASK is
> also broken in the same way.
>
> Move 'PHONY += prepare0' to the common place. Make is fine with missing
> rule for phony targets.
>
> I minimize the change so it can be easily backported to 4.20.x
>
> To fix v4.20 for external modules of PowerPC, please backport
> e07db28eea38 ("kbuild: fix single target build for external module"),
> and then this commit.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=201891
> Fixes: e07db28eea38 ("kbuild: fix single target build for external module")
> Fixes: c3ff2a5193fa ("powerpc/32: add stack protector support")
> Fixes: 189af4657186 ("ARM: smp: add support for per-task stack canaries")
> Fixes: 0a1213fa7432 ("arm64: enable per-task stack canaries")
> Cc: linux-stable  # v4.20
> Reported-by: Samuel Holland 
> Reported-by: Alexey Kardashevskiy 
> Signed-off-by: Masahiro Yamada 
> ---
>
>  Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 499b968..789b332 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -955,6 +955,7 @@ ifdef CONFIG_STACK_VALIDATION
>endif
>  endif
>
> +PHONY += prepare0
>
>  ifeq ($(KBUILD_EXTMOD),)
>  core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
> @@ -1061,8 +1062,7 @@ scripts: scripts_basic scripts_dtc
>  # archprepare is used in arch Makefiles and when processed asm symlink,
>  # version.h and scripts_basic is processed / created.
>
> -# Listed in dependency order

The above comment may need to be tweaked a bit

> -PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
> +PHONY += prepare archprepare prepare1 prepare2 prepare3
>
>  # prepare3 is used to check if we are building in a separate output 
> directory,
>  # and if so do:
> --
> 2.7.4
>


[tip:irq/core] genirq: Correctly annotate implicit fall through

2019-01-15 Thread tip-bot for Mathieu Malaterre
Commit-ID:  01cdfa912f1004c463586f52f1dfcbec1274b1f2
Gitweb: https://git.kernel.org/tip/01cdfa912f1004c463586f52f1dfcbec1274b1f2
Author: Mathieu Malaterre 
AuthorDate: Mon, 14 Jan 2019 21:36:33 +0100
Committer:  Thomas Gleixner 
CommitDate: Tue, 15 Jan 2019 10:40:53 +0100

genirq: Correctly annotate implicit fall through

There is a plan to build the kernel with -Wimplicit-fallthrough. The
fallthrough in __handle_irq_event_percpu() has a fallthrough annotation
which is followed by an additional comment and is not recognized by GCC.

Separate the 'fall through' and the rest of the comment with a dash so the
regular expression used by GCC matches.

Signed-off-by: Mathieu Malaterre 
Signed-off-by: Thomas Gleixner 
Link: https://lkml.kernel.org/r/20190114203633.18557-1-ma...@debian.org
---
 kernel/irq/handle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 38554bc35375..6df5ddfdb0f8 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -166,7 +166,7 @@ irqreturn_t __handle_irq_event_percpu(struct irq_desc 
*desc, unsigned int *flags
 
__irq_wake_thread(desc, action);
 
-   /* Fall through to add to randomness */
+   /* Fall through - to add to randomness */
case IRQ_HANDLED:
*flags |= action->flags;
break;


[tip:irq/core] genirq: Annotate implicit fall through

2019-01-15 Thread tip-bot for Mathieu Malaterre
Commit-ID:  44133f7eaebec227d1381868d642e3c64023520f
Gitweb: https://git.kernel.org/tip/44133f7eaebec227d1381868d642e3c64023520f
Author: Mathieu Malaterre 
AuthorDate: Mon, 14 Jan 2019 21:31:54 +0100
Committer:  Thomas Gleixner 
CommitDate: Tue, 15 Jan 2019 10:40:34 +0100

genirq: Annotate implicit fall through

There is a plan to build the kernel with -Wimplicit-fallthrough. The
fallthrough in __irq_set_trigger() lacks an annotation. Add it.

Signed-off-by: Mathieu Malaterre 
Signed-off-by: Thomas Gleixner 
Link: https://lkml.kernel.org/r/20190114203154.17125-1-ma...@debian.org

---
 kernel/irq/manage.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index a4888ce4667a..1ca39dc4538d 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -723,6 +723,7 @@ int __irq_set_trigger(struct irq_desc *desc, unsigned long 
flags)
case IRQ_SET_MASK_OK_DONE:
irqd_clear(>irq_data, IRQD_TRIGGER_MASK);
irqd_set(>irq_data, flags);
+   /* fall through */
 
case IRQ_SET_MASK_OK_NOCOPY:
flags = irqd_get_trigger_type(>irq_data);


[PATCH] nvram: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

This commit remove the following warning:

  drivers/char/generic_nvram.c:83:3: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 drivers/char/generic_nvram.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c
index ff5394f47587..53123c110f7b 100644
--- a/drivers/char/generic_nvram.c
+++ b/drivers/char/generic_nvram.c
@@ -81,6 +81,7 @@ static int nvram_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
 #ifdef CONFIG_PPC_PMAC
case OBSOLETE_PMAC_NVRAM_GET_OFFSET:
printk(KERN_WARNING "nvram: Using obsolete 
PMAC_NVRAM_GET_OFFSET ioctl\n");
+   /* fall through */
case IOC_NVRAM_GET_OFFSET: {
int part, offset;
 
-- 
2.19.2



[PATCH] firewire: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

This commit remove the following warning:

  drivers/firewire/core-topology.c:69:23: warning: this statement may fall 
through [-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 drivers/firewire/core-topology.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/firewire/core-topology.c b/drivers/firewire/core-topology.c
index 7db234d3fbdd..82c67e900aad 100644
--- a/drivers/firewire/core-topology.c
+++ b/drivers/firewire/core-topology.c
@@ -67,6 +67,7 @@ static u32 *count_ports(u32 *sid, int *total_port_count, int 
*child_port_count)
switch (port_type) {
case SELFID_PORT_CHILD:
(*child_port_count)++;
+   /* fall through */
case SELFID_PORT_PARENT:
case SELFID_PORT_NCONN:
(*total_port_count)++;
-- 
2.19.2



[PATCH 1/2] firewire: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

In this particular case rewrote the comment to start with the string "fall
through", so as to match the regular expression expected by GCC.

This commit remove the following warning:

  drivers/firewire/core-iso.c:308:7: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 drivers/firewire/core-iso.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c
index 35e784cffc23..d2d50bda5a5f 100644
--- a/drivers/firewire/core-iso.c
+++ b/drivers/firewire/core-iso.c
@@ -308,7 +308,7 @@ static int manage_channel(struct fw_card *card, int irm_id, 
int generation,
if ((data[0] & bit) == (data[1] & bit))
continue;
 
-   /* 1394-1995 IRM, fall through to retry. */
+   /* fall through - 1394-1995 IRM to retry. */
default:
if (retry) {
retry--;
-- 
2.19.2



[PATCH 2/2] firewire: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

In this particular case add a ‘-’ so as to match the regular expression
expected by GCC.

This commit remove the following warning:

/drivers/firewire/core-device.c: In function 'set_broadcast_channel':
../drivers/firewire/core-device.c:969:7: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
if (data & cpu_to_be32(1 << 31)) {

Signed-off-by: Mathieu Malaterre 
---
 drivers/firewire/core-device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index 7c2eed76011e..e41d55b04940 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -970,7 +970,7 @@ static void set_broadcast_channel(struct fw_device *device, 
int generation)
device->bc_implemented = BC_IMPLEMENTED;
break;
}
-   /* else fall through to case address error */
+   /* else fall through - to case address error */
case RCODE_ADDRESS_ERROR:
device->bc_implemented = BC_UNIMPLEMENTED;
}
-- 
2.19.2



[PATCH] mmc: core: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

In this particular case rewrote the comment to start with the string "fall
through", so as to match the regular expression expected by GCC. Truncate
the comment slightly to fit the max line length of 80 characters.

This commit remove the following warning:

  drivers/mmc/core/host.c:196:14: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 drivers/mmc/core/host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index f57f5de54206..0052d6fed7c8 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -194,7 +194,7 @@ int mmc_of_parse(struct mmc_host *host)
switch (bus_width) {
case 8:
host->caps |= MMC_CAP_8_BIT_DATA;
-   /* Hosts capable of 8-bit transfers can also do 4 bits */
+   /* fall through - Hosts capable of 8-bit can also do 4 bits */
case 4:
host->caps |= MMC_CAP_4_BIT_DATA;
break;
-- 
2.19.2



[PATCH 1/2] PCI: annotate implicit fall throughs

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
these places in the code produced warnings (W=1). Fix them up.

In this particular case change a ‘:’ with either a ‘-’ or a ‘,’
so as to match the regular expression expected by GCC.

This commit remove the following warnings:

  drivers/pci/pci.c:861:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  drivers/pci/pci.c:2261:7: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 drivers/pci/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index c9d8e3c837de..94069fc35e91 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -861,7 +861,7 @@ static int pci_raw_set_power_state(struct pci_dev *dev, 
pci_power_t state)
if ((pmcsr & PCI_PM_CTRL_STATE_MASK) == PCI_D3hot
 && !(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET))
need_restore = true;
-   /* Fall-through: force to D0 */
+   /* Fall-through - force to D0 */
default:
pmcsr = 0;
break;
@@ -2260,7 +2260,7 @@ static pci_power_t pci_target_state(struct pci_dev *dev, 
bool wakeup)
case PCI_D2:
if (pci_no_d1d2(dev))
break;
-   /* else: fall through */
+   /* else, fall through */
default:
target_state = state;
}
-- 
2.19.2



[PATCH 2/2] PCI: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

In this particular case change a ‘:’ with a ‘,’ so as to match the
regular expression expected by GCC.

This commit remove the following warning:

  drivers/pci/quirks.c:2138:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 drivers/pci/quirks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index b0a413f3f7ca..9fabcef345ed 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2138,7 +2138,7 @@ static void quirk_netmos(struct pci_dev *dev)
if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM &&
dev->subsystem_device == 0x0299)
return;
-   /* else: fall through */
+   /* else, fall through */
case PCI_DEVICE_ID_NETMOS_9735:
case PCI_DEVICE_ID_NETMOS_9745:
case PCI_DEVICE_ID_NETMOS_9845:
-- 
2.19.2



[PATCH] vt: annotate implicit fall throughs

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
these places in the code produced warnings (W=1). Fix them up.

This commit remove the following warning:

  drivers/tty/vt/vt.c:2112:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  drivers/tty/vt/vt.c:2237:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 drivers/tty/vt/vt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 41ec8e5010f3..e4f8caed26af 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -2111,6 +2111,7 @@ static void do_con_trol(struct tty_struct *tty, struct 
vc_data *vc, int c)
lf(vc);
if (!is_kbd(vc, lnm))
return;
+   /* fall through */
case 13:
cr(vc);
return;
@@ -2236,6 +2237,7 @@ static void do_con_trol(struct tty_struct *tty, struct 
vc_data *vc, int c)
vc->vc_ques = (c == '?');
if (vc->vc_ques)
return;
+   /* fall through */
case ESgetpars:
if (c == ';' && vc->vc_npar < NPAR - 1) {
vc->vc_npar++;
-- 
2.19.2



[PATCH] video: offb: annotate implicit fall throughs

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
these places in the code produced warnings (W=1). Fix them up.

This commit remove the following warnings:

  drivers/video/fbdev/offb.c:211:5: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  drivers/video/fbdev/offb.c:142:3: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 drivers/video/fbdev/offb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/fbdev/offb.c b/drivers/video/fbdev/offb.c
index 31f769d67195..e0f0c5351306 100644
--- a/drivers/video/fbdev/offb.c
+++ b/drivers/video/fbdev/offb.c
@@ -141,6 +141,7 @@ static int offb_setcolreg(u_int regno, u_int red, u_int 
green, u_int blue,
/* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */
out_le32(par->cmap_adr + 0x58,
 in_le32(par->cmap_adr + 0x58) & ~0x20);
+   /* fall through */
case cmap_r128:
/* Set palette index & data */
out_8(par->cmap_adr + 0xb0, regno);
@@ -210,6 +211,7 @@ static int offb_blank(int blank, struct fb_info *info)
/* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */
out_le32(par->cmap_adr + 0x58,
 in_le32(par->cmap_adr + 0x58) & ~0x20);
+   /* fall through */
case cmap_r128:
/* Set palette index & data */
out_8(par->cmap_adr + 0xb0, i);
-- 
2.19.2



[PATCH 2/2] ext4: annotate implicit fall throughs

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
these places in the code produced warnings (W=1). Fix them up.

This commit remove the following warnings:

  fs/ext4/indirect.c:1182:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  fs/ext4/indirect.c:1188:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  fs/ext4/indirect.c:1432:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  fs/ext4/indirect.c:1440:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 fs/ext4/indirect.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index bf7fa1507e81..c2225f0d31b5 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -1183,18 +1183,21 @@ void ext4_ind_truncate(handle_t *handle, struct inode 
*inode)
ext4_free_branches(handle, inode, NULL, , +1, 1);
i_data[EXT4_IND_BLOCK] = 0;
}
+   /* fall through */
case EXT4_IND_BLOCK:
nr = i_data[EXT4_DIND_BLOCK];
if (nr) {
ext4_free_branches(handle, inode, NULL, , +1, 2);
i_data[EXT4_DIND_BLOCK] = 0;
}
+   /* fall through */
case EXT4_DIND_BLOCK:
nr = i_data[EXT4_TIND_BLOCK];
if (nr) {
ext4_free_branches(handle, inode, NULL, , +1, 3);
i_data[EXT4_TIND_BLOCK] = 0;
}
+   /* fall through */
case EXT4_TIND_BLOCK:
;
}
@@ -1433,6 +1436,7 @@ int ext4_ind_remove_space(handle_t *handle, struct inode 
*inode,
ext4_free_branches(handle, inode, NULL, , +1, 1);
i_data[EXT4_IND_BLOCK] = 0;
}
+   /* fall through */
case EXT4_IND_BLOCK:
if (++n >= n2)
return 0;
@@ -1441,6 +1445,7 @@ int ext4_ind_remove_space(handle_t *handle, struct inode 
*inode,
ext4_free_branches(handle, inode, NULL, , +1, 2);
i_data[EXT4_DIND_BLOCK] = 0;
}
+   /* fall through */
case EXT4_DIND_BLOCK:
if (++n >= n2)
return 0;
@@ -1449,6 +1454,7 @@ int ext4_ind_remove_space(handle_t *handle, struct inode 
*inode,
ext4_free_branches(handle, inode, NULL, , +1, 3);
i_data[EXT4_TIND_BLOCK] = 0;
}
+   /* fall through */
case EXT4_TIND_BLOCK:
;
}
-- 
2.19.2



[PATCH 1/2] ext4: annotate implicit fall throughs

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
these places in the code produced warnings (W=1). Fix them up.

This commit remove the following warnings:

  fs/ext4/hash.c:233:15: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  fs/ext4/hash.c:246:15: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 fs/ext4/hash.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/ext4/hash.c b/fs/ext4/hash.c
index e22dcfab308b..46b24da33a28 100644
--- a/fs/ext4/hash.c
+++ b/fs/ext4/hash.c
@@ -231,6 +231,7 @@ int ext4fs_dirhash(const char *name, int len, struct 
dx_hash_info *hinfo)
break;
case DX_HASH_HALF_MD4_UNSIGNED:
str2hashbuf = str2hashbuf_unsigned;
+   /* fall through */
case DX_HASH_HALF_MD4:
p = name;
while (len > 0) {
@@ -244,6 +245,7 @@ int ext4fs_dirhash(const char *name, int len, struct 
dx_hash_info *hinfo)
break;
case DX_HASH_TEA_UNSIGNED:
str2hashbuf = str2hashbuf_unsigned;
+   /* fall through */
case DX_HASH_TEA:
p = name;
while (len > 0) {
-- 
2.19.2



[PATCH 3/3] fs/fcntl: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

In this particular case change a ‘:’ with a ‘-’ so as to match the
regular expression expected by GCC.

This commit remove the following warning:

  fs/fcntl.c:770:7: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 fs/fcntl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fcntl.c b/fs/fcntl.c
index 083185174c6d..3d40771e8e7c 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -769,7 +769,7 @@ static void send_sigio_to_task(struct task_struct *p,
si.si_fd= fd;
if (!do_send_sig_info(signum, , p, type))
break;
-   /* fall-through: fall back on the old plain SIGIO signal */
+   /* fall-through - fall back on the old plain SIGIO signal */
case 0:
do_send_sig_info(SIGIO, SEND_SIG_PRIV, p, type);
}
-- 
2.19.2



[PATCH 2/3] fs: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

In this particular case remove a ‘:’ so as to match the regular
expression expected by GCC.

This commit remove the following warning:

  fs/locks.c:1473:16: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 fs/locks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/locks.c b/fs/locks.c
index ff6af2c32601..d958c3863b4b 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1471,7 +1471,7 @@ static void lease_clear_pending(struct file_lock *fl, int 
arg)
switch (arg) {
case F_UNLCK:
fl->fl_flags &= ~FL_UNLOCK_PENDING;
-   /* fall through: */
+   /* fall through */
case F_RDLCK:
fl->fl_flags &= ~FL_DOWNGRADE_PENDING;
}
-- 
2.19.2



[PATCH 1/3] fs: annotate implicit fall throughs

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
these places in the code produced warnings (W=1). Fix them up.

This commit remove the following warnings:

  fs/libfs.c:148:11: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
  fs/libfs.c:150:7: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 fs/libfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/libfs.c b/fs/libfs.c
index 0fb590d79f30..9efb647917e0 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -146,9 +146,11 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, 
int whence)
switch (whence) {
case 1:
offset += file->f_pos;
+   /* fall through */
case 0:
if (offset >= 0)
break;
+   /* fall through */
default:
return -EINVAL;
}
-- 
2.19.2



[PATCH] seq_file: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

This commit remove the following warning:

  fs/seq_file.c:319:10: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 fs/seq_file.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/seq_file.c b/fs/seq_file.c
index 1dea7a8a5255..abe27ec43176 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -317,6 +317,7 @@ loff_t seq_lseek(struct file *file, loff_t offset, int 
whence)
switch (whence) {
case SEEK_CUR:
offset += file->f_pos;
+   /* fall through */
case SEEK_SET:
if (offset < 0)
break;
-- 
2.19.2



[PATCH] fs/signalfd: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

This commit remove the following warning:

  fs/signalfd.c:178:7: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 fs/signalfd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/signalfd.c b/fs/signalfd.c
index 757afc7c5895..44b6845b071c 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -176,6 +176,7 @@ static ssize_t signalfd_dequeue(struct signalfd_ctx *ctx, 
kernel_siginfo_t *info
if (!nonblock)
break;
ret = -EAGAIN;
+   /* fall through */
default:
spin_unlock_irq(>sighand->siglock);
return ret;
-- 
2.19.2



[PATCH] irq: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

In this particular case add a ‘-’ so as to match the regular expression
expected by GCC.

This commit remove the following warning:

  kernel/irq/handle.c:167:4: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 kernel/irq/handle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 38554bc35375..6df5ddfdb0f8 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -166,7 +166,7 @@ irqreturn_t __handle_irq_event_percpu(struct irq_desc 
*desc, unsigned int *flags
 
__irq_wake_thread(desc, action);
 
-   /* Fall through to add to randomness */
+   /* Fall through - to add to randomness */
case IRQ_HANDLED:
*flags |= action->flags;
break;
-- 
2.19.2



[PATCH] perf/core: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

This commit remove the following warning:

  kernel/events/core.c:8945:11: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 kernel/events/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 3cd13a30f732..11bf8bf606ee 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -8943,6 +8943,7 @@ perf_event_parse_addr_filter(struct perf_event *event, 
char *fstr,
case IF_SRC_KERNELADDR:
case IF_SRC_KERNEL:
kernel = 1;
+   /* fall through */
 
case IF_SRC_FILEADDR:
case IF_SRC_FILE:
-- 
2.19.2



[PATCH] ipc: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

This commit remove the following warning:

  ipc/sem.c:1683:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 ipc/sem.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ipc/sem.c b/ipc/sem.c
index 745dc6187e84..0307012ab343 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1682,6 +1682,7 @@ long ksys_semctl(int semid, int semnum, int cmd, unsigned 
long arg)
case IPC_SET:
if (copy_semid_from_user(, p, version))
return -EFAULT;
+   /* fall through */
case IPC_RMID:
return semctl_down(ns, semid, cmd, );
default:
-- 
2.19.2



[PATCH] signal: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

This commit remove the following warning:

  kernel/signal.c:795:13: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 kernel/signal.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/signal.c b/kernel/signal.c
index e1d7ad8e6ab1..aa7a507757d7 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -794,6 +794,7 @@ static int check_kill_permission(int sig, struct 
kernel_siginfo *info,
 */
if (!sid || sid == task_session(current))
break;
+   /* fall through */
default:
return -EPERM;
}
-- 
2.19.2



[PATCH] kernel/sys: annotate implicit fall through

2019-01-14 Thread Mathieu Malaterre
There is a plan to build the kernel with -Wimplicit-fallthrough and
this place in the code produced a warning (W=1).

This commit remove the following warning:

  kernel/sys.c:1748:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]

Signed-off-by: Mathieu Malaterre 
---
 kernel/sys.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/sys.c b/kernel/sys.c
index f7eb62eceb24..dc5d9e636d48 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1747,6 +1747,7 @@ void getrusage(struct task_struct *p, int who, struct 
rusage *r)
 
if (who == RUSAGE_CHILDREN)
break;
+   /* fall through */
 
case RUSAGE_SELF:
thread_group_cputime_adjusted(p, , );
-- 
2.19.2



  1   2   3   4   5   6   7   8   >