Re: CHECKPATCH: missing a warning soon after include files decl -c

2021-03-21 Thread Greg KH
On Sat, Mar 20, 2021 at 03:49:12PM +0100, Fabio Aiuto wrote:
> On Sat, Mar 20, 2021 at 11:59:44AM +0100, Greg KH wrote:
> > On Sat, Mar 20, 2021 at 11:54:24AM +0100, Fabio Aiuto wrote:
> > > Hi,
> > > 
> > > here's an issue in checkpatch.pl
> > > 
> > > $ perl script/checkpatch.pl -f drivers/staging/rtl8723bs/core/rtw_ap.c
> > > 
> > > I get three warning related to an extern declaration
> > > 
> > > WARNING: externs should be avoided in .c files
> > > #14: FILE: drivers/staging/rtl8723bs/core/rtw_ap.c:14:
> > > +extern unsigned char WMM_OUI[];
> > > --
> > > WARNING: externs should be avoided in .c files
> > > #15: FILE: drivers/staging/rtl8723bs/core/rtw_ap.c:15:
> > > +extern unsigned char WPS_OUI[];
> > > --
> > > WARNING: externs should be avoided in .c files
> > > #16: FILE: drivers/staging/rtl8723bs/core/rtw_ap.c:16:
> > > +extern unsigned char P2P_OUI[];
> > > --
> > > 
> > > but the file checked has 4 extern declaration:
> > > -
> > > #define _RTW_AP_C_
> > > 
> > > #include 
> > > #include 
> > > #include 
> > > 
> > > extern unsigned char RTW_WPA_OUI[];
> > > extern unsigned char WMM_OUI[];
> > > extern unsigned char WPS_OUI[];
> > > extern unsigned char P2P_OUI[];
> > > 
> > > void init_mlme_ap_info(struct adapter *padapter)
> > > ---
> > > 
> > > If I add a ';' this way:
> > > 
> > > #define _RTW_AP_C_
> > > 
> > > #include 
> > > #include 
> > > #include 
> > > ;
> > > extern unsigned char RTW_WPA_OUI[];
> > > extern unsigned char WMM_OUI[];
> > > extern unsigned char WPS_OUI[];
> > > extern unsigned char P2P_OUI[];
> > > 
> > > void init_mlme_ap_info(struct adapter *padapter)
> > > 
> > 
> > Wait, why would you do the above?
> > 
> > Don't try to trick a perl script that has a hard time parsing C files,
> > try to resolve the original issue here.
> > 
> > And that is that the above definitions should be in a .h file somewhere.
> > If you make that move then all should be fine.
> > 
> > thanks,
> > 
> > greg k-h
> 
> that's another issue
> 
> WARNING: externs should be avoided in .c files
> #35: FILE: drivers/staging/rtl8723bs/core/rtw_efuse.c:35:
> +bool
> 
> CHECK: Lines should not end with a '('
> #36: FILE: drivers/staging/rtl8723bs/core/rtw_efuse.c:36:
> ---
> 
> but that's what I see in line 35
> 
> 
> #define REG_EFUSE_CTRL0x0030
> #define EFUSE_CTRLREG_EFUSE_CTRL  /*  E-Fuse 
> Control. */
> 
> bool<- line 35
> Efuse_Read1ByteFromFakeContent(
>   struct adapter *padapter,
>   u16 Offset,
>   u8 *Value);
> bool
> Efuse_Read1ByteFromFakeContent(
>   struct adapter *padapter,


That's some horrid code formatting, just clean it up to look normal and
all will be fine.

> another one...
> 
> WARNING: externs should be avoided in .c files
> #40: FILE: drivers/staging/rtl8723bs/core/rtw_ioctl_set.c:40:
> +u8 rtw_do_join(struct adapter *padapter); < do I miss 
>   something about extern keyword?

Having a global function prototype in a .c file is not a good idea.
Again, fix it up and all will be fine.

thanks,

greg k-h


Re: Linux 5.10.25

2021-03-21 Thread Greg Kroah-Hartman
On Sat, Mar 20, 2021 at 09:31:55PM +, Jamie Heilman wrote:
> [ugh, resent with the lkml headers unbroken, sorry about the dupe]
> 
> Greg Kroah-Hartman wrote:
> > J. Bruce Fields (2):
> >   Revert "nfsd4: remove check_conflicting_opens warning"
> >   Revert "nfsd4: a client's own opens needn't prevent delegations"
> 
> Hrm, just got this when I udpated my nfs server (32bit Via EPIA system)
> from 5.10.20 to 5.10.25:
> 
> [   49.225914] NFSD: Using UMH upcall client tracking operations.
> [   49.231919] NFSD: starting 90-second grace period (net f036)
> [   50.036973] [ cut here ]
> [   50.041771] WARNING: CPU: 0 PID: 2284 at fs/nfsd/nfs4state.c:4968 
> nfsd4_process_open2+0xf9c/0x1170 [nfsd]
> [   50.051434] Modules linked in: md5 cpufreq_conservative cpufreq_userspace 
> cpufreq_powersave cpufreq_ondemand autofs4 quota_v2 quota_tree nfsd 
> auth_rpcgss nfs lockd grace nfs_ssc fscache sunrpc xt_mark cls_fw sch_htb 
> iptable_nat xt_nat nf_nat ipt_REJECT nf_reject_ipv4 xt_tcpudp xt_multiport 
> iptable_mangle xt_state xt_conntrack nf_conntrack nf_defrag_ipv4 nf_log_ipv4 
> nf_log_common xt_LOG xt_limit iptable_filter ip_tables x_tables nhpoly1305 
> chacha_generic libchacha adiantum libpoly1305 dm_crypt dm_mod 
> snd_hda_codec_via snd_hda_codec_generic snd_hda_intel snd_intel_dspcfg 
> snd_hda_codec snd_hwdep snd_hda_core snd_pcm snd_timer snd via_rhine psmouse 
> soundcore mii via_agp sg via_velocity evdev agpgart
> [   50.113386] CPU: 0 PID: 2284 Comm: nfsd Tainted: GT 
> 5.10.25 #1
> [   50.120669] Hardware name: To Be Filled By O.E.M. To Be Filled By 
> O.E.M./To be filled by O.E.M., BIOS 080014  06/01/2009
> [   50.131652] EIP: nfsd4_process_open2+0xf9c/0x1170 [nfsd]
> [   50.137036] Code: 04 88 45 a4 88 07 8b 45 a0 8d 78 49 8b 45 84 8d 70 01 e9 
> 2b f8 ff ff c7 45 9c 00 00 00 00 31 ff bb 00 00 27 67 e9 04 f6 ff ff <0f> 0b 
> e9 a0 f5 ff ff 0f b6 d4 0f a3 15 94 3f 23 f8 0f 83 b1 fd ff
> [   50.155866] EAX:  EBX: 82da25b0 ECX: 830c0920 EDX: 
> [   50.162187] ESI: 82da25b0 EDI: 82da55a0 EBP: 8310be68 ESP: 8310bddc
> [   50.168507] DS: 007b ES: 007b FS:  GS: 00e0 SS: 0068 EFLAGS: 00010246
> [   50.175338] CR0: 80050033 CR2: 00551e50 CR3: 03222000 CR4: 06b0
> [   50.181654] Call Trace:
> [   50.184165]  ? inode_permission+0x17/0xc0
> [   50.188289]  nfsd4_open+0x429/0x910 [nfsd]
> [   50.192483]  ? nfsd4_encode_operation+0x185/0x1e0 [nfsd]
> [   50.197900]  ? nfsd4_rename+0x1a0/0x1a0 [nfsd]
> [   50.202439]  nfsd4_proc_compound+0x457/0x6c0 [nfsd]
> [   50.207419]  nfsd_dispatch+0xdc/0x1a0 [nfsd]
> [   50.211816]  svc_process_common+0x38a/0x650 [sunrpc]
> [   50.216880]  ? svc_xprt_do_enqueue+0xd7/0xe0 [sunrpc]
> [   50.222017]  ? svc_xprt_received+0x5d/0xf0 [sunrpc]
> [   50.227000]  ? nfsd_svc+0x300/0x300 [nfsd]
> [   50.231190]  svc_process+0xa9/0xf0 [sunrpc]
> [   50.235468]  nfsd+0xcd/0x120 [nfsd]
> [   50.239025]  kthread+0xe1/0x100
> [   50.242259]  ? nfsd_destroy+0x50/0x50 [nfsd]
> [   50.246588]  ? kthread_create_on_node+0x30/0x30
> [   50.251165]  ret_from_fork+0x1c/0x28
> [   50.254789] ---[ end trace 171bde4774bc9795 ]---
> 
> Can't readily reproduce it though, so likely a race condition or
> something that requires more state buildup than I have after a few
> minutes of uptime.  Kernel config at
> http://audible.transient.net/~jamie/k/nfsd.config-5.10.25 in case you
> think this worth more investigation.

Do you also have this issue in Linus's tree and the latest 5.11.y
release?

thanks,

greg k-h


Re: [PATCH 5.4 00/18] 5.4.107-rc1 review

2021-03-21 Thread Samuel Zou




On 2021/3/19 20:18, Greg Kroah-Hartman wrote:

This is the start of the stable review cycle for the 5.4.107 release.
There are 18 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Sun, 21 Mar 2021 12:17:37 +.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:

https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.107-rc1.gz
or in the git tree and branch at:

git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
linux-5.4.y
and the diffstat can be found below.

thanks,

greg k-h



Tested on arm64 and x86 for 5.4.107-rc1,

Kernel repo:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Branch: linux-5.4.y
Version: 5.4.107-rc1
Commit: 8a800acdf26f05d289c05e416591b6b18917b044
Compiler: gcc version 7.3.0 (GCC)

arm64:

Testcase Result Summary:
total: 4729
passed: 4729
failed: 0
timeout: 0


x86:

Testcase Result Summary:
total: 4729
passed: 4729
failed: 0
timeout: 0


Tested-by: Hulk Robot 


Re: [PATCH v5 24/27] mm/filemap: Convert wait_on_page_bit to wait_on_folio_bit

2021-03-21 Thread kernel test robot
Hi "Matthew,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20210319]
[cannot apply to linux/master linus/master hnaz-linux-mm/master v5.12-rc3 
v5.12-rc2 v5.12-rc1 v5.12-rc3]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Matthew-Wilcox-Oracle/Memory-Folios/20210320-134732
base:f00397ee41c79b6155b9b44abd0055b2c0621349
config: x86_64-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# 
https://github.com/0day-ci/linux/commit/39199d654ac6a6bbaba1620337574ec74adee8fe
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Matthew-Wilcox-Oracle/Memory-Folios/20210320-134732
git checkout 39199d654ac6a6bbaba1620337574ec74adee8fe
# save the attached .config to linux build tree
make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   fs/afs/write.c: In function 'afs_page_mkwrite':
>> fs/afs/write.c:849:6: error: implicit declaration of function 
>> 'wait_on_page_bit_killable'; did you mean 'wait_on_folio_bit_killable'? 
>> [-Werror=implicit-function-declaration]
 849 |  wait_on_page_bit_killable(page, PG_fscache) < 0)
 |  ^
 |  wait_on_folio_bit_killable
   cc1: some warnings being treated as errors


vim +849 fs/afs/write.c

9b3f26c9110dce David Howells   2009-04-03  827  
9b3f26c9110dce David Howells   2009-04-03  828  /*
9b3f26c9110dce David Howells   2009-04-03  829   * notification that a 
previously read-only page is about to become writable
9b3f26c9110dce David Howells   2009-04-03  830   * - if it returns an 
error, the caller will deliver a bus error signal
9b3f26c9110dce David Howells   2009-04-03  831   */
0722f186205976 Souptick Joarder2018-08-23  832  vm_fault_t 
afs_page_mkwrite(struct vm_fault *vmf)
9b3f26c9110dce David Howells   2009-04-03  833  {
721597fd1aa668 David Howells   2020-10-20  834  struct page 
*page = thp_head(vmf->page);
1cf7a1518aefa6 David Howells   2017-11-02  835  struct file 
*file = vmf->vma->vm_file;
1cf7a1518aefa6 David Howells   2017-11-02  836  struct inode 
*inode = file_inode(file);
1cf7a1518aefa6 David Howells   2017-11-02  837  struct 
afs_vnode *vnode = AFS_FS_I(inode);
1cf7a1518aefa6 David Howells   2017-11-02  838  unsigned long 
priv;
9b3f26c9110dce David Howells   2009-04-03  839  
721597fd1aa668 David Howells   2020-10-20  840  
_enter("{{%llx:%llu}},{%lx}", vnode->fid.vid, vnode->fid.vnode, page->index);
9b3f26c9110dce David Howells   2009-04-03  841  
1cf7a1518aefa6 David Howells   2017-11-02  842  
sb_start_pagefault(inode->i_sb);
9b3f26c9110dce David Howells   2009-04-03  843  
1cf7a1518aefa6 David Howells   2017-11-02  844  /* Wait for the 
page to be written to the cache before we allow it to
1cf7a1518aefa6 David Howells   2017-11-02  845   * be modified. 
 We then assume the entire page will need writing back.
1cf7a1518aefa6 David Howells   2017-11-02  846   */
77837f50249aa4 David Howells   2020-02-06  847  #ifdef 
CONFIG_AFS_FSCACHE
721597fd1aa668 David Howells   2020-10-20  848  if 
(PageFsCache(page) &&
721597fd1aa668 David Howells   2020-10-20 @849  
wait_on_page_bit_killable(page, PG_fscache) < 0)
77837f50249aa4 David Howells   2020-02-06  850  return 
VM_FAULT_RETRY;
77837f50249aa4 David Howells   2020-02-06  851  #endif
9b3f26c9110dce David Howells   2009-04-03  852  
5dc1af598f0274 Matthew Wilcox (Oracle  2021-03-20  853) if 
(wait_on_folio_writeback_killable(page_folio(page)))
1cf7a1518aefa6 David Howells   2017-11-02  854  return 
VM_FAULT_RETRY;
1cf7a1518aefa6 David Howells   2017-11-02  855  
721597fd1aa668 David Howells   2020-10-20  856  if 
(lock_page_killable(page) < 0)
1cf7a1518aefa6 David Howells   2017-11-02  857  return 
VM_FAULT_RETRY;
1cf7a1518aefa6 David Howells   2017-11-02  858  
1cf7a1518aefa6 David Howells   2017-11-02  859  /* We mustn't 
change page->private until writeback is complete as that
1cf7a1518aefa6 David Howells   2017-11-02  860   * details the 
portion of the page we need to write back and we might
1cf7a1518aefa6 David Howells   2017-11-02  861   * need to 
redirty the page if there's a problem.
1cf7a1518aefa6 David Howells   2017-

Re: Linux 5.10.25

2021-03-21 Thread Jamie Heilman
Greg Kroah-Hartman wrote:
> On Sat, Mar 20, 2021 at 09:31:55PM +, Jamie Heilman wrote:
> > [ugh, resent with the lkml headers unbroken, sorry about the dupe]
> > 
> > Greg Kroah-Hartman wrote:
> > > J. Bruce Fields (2):
> > >   Revert "nfsd4: remove check_conflicting_opens warning"
> > >   Revert "nfsd4: a client's own opens needn't prevent delegations"
> > 
> > Hrm, just got this when I udpated my nfs server (32bit Via EPIA system)
> > from 5.10.20 to 5.10.25:
> > 
> > [   49.225914] NFSD: Using UMH upcall client tracking operations.
> > [   49.231919] NFSD: starting 90-second grace period (net f036)
> > [   50.036973] [ cut here ]
> > [   50.041771] WARNING: CPU: 0 PID: 2284 at fs/nfsd/nfs4state.c:4968 
> > nfsd4_process_open2+0xf9c/0x1170 [nfsd]
> > [   50.051434] Modules linked in: md5 cpufreq_conservative 
> > cpufreq_userspace cpufreq_powersave cpufreq_ondemand autofs4 quota_v2 
> > quota_tree nfsd auth_rpcgss nfs lockd grace nfs_ssc fscache sunrpc xt_mark 
> > cls_fw sch_htb iptable_nat xt_nat nf_nat ipt_REJECT nf_reject_ipv4 
> > xt_tcpudp xt_multiport iptable_mangle xt_state xt_conntrack nf_conntrack 
> > nf_defrag_ipv4 nf_log_ipv4 nf_log_common xt_LOG xt_limit iptable_filter 
> > ip_tables x_tables nhpoly1305 chacha_generic libchacha adiantum libpoly1305 
> > dm_crypt dm_mod snd_hda_codec_via snd_hda_codec_generic snd_hda_intel 
> > snd_intel_dspcfg snd_hda_codec snd_hwdep snd_hda_core snd_pcm snd_timer snd 
> > via_rhine psmouse soundcore mii via_agp sg via_velocity evdev agpgart
> > [   50.113386] CPU: 0 PID: 2284 Comm: nfsd Tainted: GT 
> > 5.10.25 #1
> > [   50.120669] Hardware name: To Be Filled By O.E.M. To Be Filled By 
> > O.E.M./To be filled by O.E.M., BIOS 080014  06/01/2009
> > [   50.131652] EIP: nfsd4_process_open2+0xf9c/0x1170 [nfsd]
> > [   50.137036] Code: 04 88 45 a4 88 07 8b 45 a0 8d 78 49 8b 45 84 8d 70 01 
> > e9 2b f8 ff ff c7 45 9c 00 00 00 00 31 ff bb 00 00 27 67 e9 04 f6 ff ff 
> > <0f> 0b e9 a0 f5 ff ff 0f b6 d4 0f a3 15 94 3f 23 f8 0f 83 b1 fd ff
> > [   50.155866] EAX:  EBX: 82da25b0 ECX: 830c0920 EDX: 
> > [   50.162187] ESI: 82da25b0 EDI: 82da55a0 EBP: 8310be68 ESP: 8310bddc
> > [   50.168507] DS: 007b ES: 007b FS:  GS: 00e0 SS: 0068 EFLAGS: 00010246
> > [   50.175338] CR0: 80050033 CR2: 00551e50 CR3: 03222000 CR4: 06b0
> > [   50.181654] Call Trace:
> > [   50.184165]  ? inode_permission+0x17/0xc0
> > [   50.188289]  nfsd4_open+0x429/0x910 [nfsd]
> > [   50.192483]  ? nfsd4_encode_operation+0x185/0x1e0 [nfsd]
> > [   50.197900]  ? nfsd4_rename+0x1a0/0x1a0 [nfsd]
> > [   50.202439]  nfsd4_proc_compound+0x457/0x6c0 [nfsd]
> > [   50.207419]  nfsd_dispatch+0xdc/0x1a0 [nfsd]
> > [   50.211816]  svc_process_common+0x38a/0x650 [sunrpc]
> > [   50.216880]  ? svc_xprt_do_enqueue+0xd7/0xe0 [sunrpc]
> > [   50.222017]  ? svc_xprt_received+0x5d/0xf0 [sunrpc]
> > [   50.227000]  ? nfsd_svc+0x300/0x300 [nfsd]
> > [   50.231190]  svc_process+0xa9/0xf0 [sunrpc]
> > [   50.235468]  nfsd+0xcd/0x120 [nfsd]
> > [   50.239025]  kthread+0xe1/0x100
> > [   50.242259]  ? nfsd_destroy+0x50/0x50 [nfsd]
> > [   50.246588]  ? kthread_create_on_node+0x30/0x30
> > [   50.251165]  ret_from_fork+0x1c/0x28
> > [   50.254789] ---[ end trace 171bde4774bc9795 ]---
> > 
> > Can't readily reproduce it though, so likely a race condition or
> > something that requires more state buildup than I have after a few
> > minutes of uptime.  Kernel config at
> > http://audible.transient.net/~jamie/k/nfsd.config-5.10.25 in case you
> > think this worth more investigation.
> 
> Do you also have this issue in Linus's tree and the latest 5.11.y
> release?

Haven't tried it, but like I said, I couldn't even reproduce it again
with 5.10.25, or booting between 5.10.20 to 5.10.25 again ... I'll
give the others a shot and see if I can repro it there.

-- 
Jamie Heilman http://audible.transient.net/~jamie/


Re: [ANNOUNCE] v5.12-rc3-rt3

2021-03-21 Thread Mike Galbraith
On Sat, 2021-03-20 at 09:18 +0100, Mike Galbraith wrote:
> On Fri, 2021-03-19 at 23:33 +0100, Sebastian Andrzej Siewior wrote:
> > Dear RT folks!
> >
> > I'm pleased to announce the v5.12-rc3-rt3 patch set.
>
> My little rpi4b is fairly unhappy with 5.12-rt, whereas 5.11-rt works
> fine on it.  The below spew is endless, making boot endless.  I turned
> it into a WARN_ON_ONCE to see if the thing would finish boot, and
> surprisingly, it seems perfectly fine with that bad idea. Having not
> the foggiest clue what I'm doing down in arm arch-land, bug is in no
> immediate danger :)

Actually, it looks like a defenseless little buglet, and this gripe
simply wants to be disabled for RT.

arm64: disable arch_faults_on_old_pte() preemptible() warning for RT

arch_faults_on_old_pte() was never called in < 5.12-rt, but 5.12 added
arch_wants_old_prefaulted_pte(), which is a wrapper thereof, and thus
finish_fault() -> do_set_pte() -> arch_wants_old_prefaulted_pte() now
calls it, in preemptible context, and a flood of complaints ensues.

Kill it for RT.

Signed-off-by: Mike Galbraith 
---
 arch/arm64/include/asm/pgtable.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -979,7 +979,7 @@ static inline void update_mmu_cache(stru
  */
 static inline bool arch_faults_on_old_pte(void)
 {
-   WARN_ON(preemptible());
+   WARN_ON(!IS_ENABLED(CONFIG_PREEMPT_RT) && preemptible());

return !cpu_has_hw_af();
 }

>
> [2.216913] WARNING: CPU: 0 PID: 1 at arch/arm64/include/asm/pgtable.h:982 
> do_set_pte+0x1cc/0x1d4
> [2.216949] Modules linked in:
> [2.216961] CPU: 0 PID: 1 Comm: init Not tainted 5.12.0.g425ed5a-v8-rt #33
> [2.216973] Hardware name: Raspberry Pi 4 Model B Rev 1.4 (DT)
> [2.216979] pstate: 2005 (nzCv daif -PAN -UAO -TCO BTYPE=--)
> [2.216990] pc : do_set_pte+0x1cc/0x1d4
> [2.217004] lr : filemap_map_pages+0x178/0x380
> [2.217016] sp : ffc01153bbb0
> [2.217020] x29: ffc01153bbb0 x28: fffe07d93080
> [2.217033] x27:  x26: ff8101c9e000
> [2.217044] x25: ff8101b40fd8 x24: 
> [2.217054] x23: ff8101674170 x22: 007fb1b4b000
> [2.217064] x21: fffe07d93080 x20: ffc01153bcf0
> [2.217073] x19: 0021f64c2fc3 x18: 
> [2.217082] x17:  x16: 
> [2.217091] x15:  x14: 
> [2.217100] x13:  x12: 
> [2.217108] x11:  x10: 
> [2.217117] x9 : ffc010209068 x8 : 000f
> [2.217126] x7 : ff8101e87c68 x6 : fffe
> [2.217135] x5 : 00101e8b x4 : ff8101e880a8
> [2.217144] x3 : 00200fc3 x2 : 
> [2.217153] x1 :  x0 : 
> [2.217162] Call trace:
> [2.217166]  do_set_pte+0x1cc/0x1d4
> [2.217181]  filemap_map_pages+0x178/0x380
> [2.217189]  __handle_mm_fault+0x75c/0x930
> [2.217202]  handle_mm_fault+0x178/0x25c
> [2.217214]  do_page_fault+0x16c/0x470
> [2.217233]  do_translation_fault+0xbc/0xd8
> [2.217244]  do_mem_abort+0x4c/0xbc
> [2.217259]  el0_ia+0x68/0xcc
> [2.217272]  el0_sync_handler+0x180/0x1b0
> [2.217284]  el0_sync+0x170/0x180



[PATCH net-next] net: lapb: Make "lapb_t1timer_running" able to detect an already running timer

2021-03-21 Thread Xie He
Problem:

The "lapb_t1timer_running" function in "lapb_timer.c" is used in only
one place: in the "lapb_kick" function in "lapb_out.c". "lapb_kick" calls
"lapb_t1timer_running" to check if the timer is already pending, and if
it is not, schedule it to run.

However, if the timer has already fired and is running, and is waiting to
get the "lapb->lock" lock, "lapb_t1timer_running" will not detect this,
and "lapb_kick" will then schedule a new timer, which causes the old
timer to be aborted.

I think this is not right. The purpose of "lapb_kick" should be ensuring
that the actual work of the timer function is scheduled to be done.
If the timer function is already running but waiting for the lock,
"lapb_kick" should not abort and reschedule it.

Changes made:

I added a new field "t1timer_running" in "struct lapb_cb" for
"lapb_t1timer_running" to use. "t1timer_running" will accurately reflect
whether the actual work of the timer is pending. If the timer has fired
but is still waiting for the lock, "t1timer_running" will still correctly
reflect whether the actual work is waiting to be done.

The old "t1timer_stop" field, whose only responsibility is to ask a timer
(that is already running but waiting for the lock) to abort, is no longer
needed, because the new "t1timer_running" field can fully take over its
responsibility. Therefore "t1timer_stop" is deleted.

"t1timer_running" is not simply a negation of the old "t1timer_stop".
At the end of the timer function, if it does not reschedule itself,
"t1timer_running" is set to false to indicate that the timer is stopped.

For consistency of the code, I also added "t2timer_running" and deleted
"t2timer_stop".

Signed-off-by: Xie He 
---
 include/net/lapb.h|  2 +-
 net/lapb/lapb_iface.c |  4 ++--
 net/lapb/lapb_timer.c | 19 ---
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/include/net/lapb.h b/include/net/lapb.h
index eee73442a1ba..124ee122f2c8 100644
--- a/include/net/lapb.h
+++ b/include/net/lapb.h
@@ -92,7 +92,7 @@ struct lapb_cb {
unsigned short  n2, n2count;
unsigned short  t1, t2;
struct timer_list   t1timer, t2timer;
-   boolt1timer_stop, t2timer_stop;
+   boolt1timer_running, t2timer_running;
 
/* Internal control information */
struct sk_buff_head write_queue;
diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c
index 0511bbe4af7b..1078e14f1acf 100644
--- a/net/lapb/lapb_iface.c
+++ b/net/lapb/lapb_iface.c
@@ -122,8 +122,8 @@ static struct lapb_cb *lapb_create_cb(void)
 
timer_setup(&lapb->t1timer, NULL, 0);
timer_setup(&lapb->t2timer, NULL, 0);
-   lapb->t1timer_stop = true;
-   lapb->t2timer_stop = true;
+   lapb->t1timer_running = false;
+   lapb->t2timer_running = false;
 
lapb->t1  = LAPB_DEFAULT_T1;
lapb->t2  = LAPB_DEFAULT_T2;
diff --git a/net/lapb/lapb_timer.c b/net/lapb/lapb_timer.c
index 0230b272b7d1..5be68869064d 100644
--- a/net/lapb/lapb_timer.c
+++ b/net/lapb/lapb_timer.c
@@ -40,7 +40,7 @@ void lapb_start_t1timer(struct lapb_cb *lapb)
lapb->t1timer.function = lapb_t1timer_expiry;
lapb->t1timer.expires  = jiffies + lapb->t1;
 
-   lapb->t1timer_stop = false;
+   lapb->t1timer_running = true;
add_timer(&lapb->t1timer);
 }
 
@@ -51,25 +51,25 @@ void lapb_start_t2timer(struct lapb_cb *lapb)
lapb->t2timer.function = lapb_t2timer_expiry;
lapb->t2timer.expires  = jiffies + lapb->t2;
 
-   lapb->t2timer_stop = false;
+   lapb->t2timer_running = true;
add_timer(&lapb->t2timer);
 }
 
 void lapb_stop_t1timer(struct lapb_cb *lapb)
 {
-   lapb->t1timer_stop = true;
+   lapb->t1timer_running = false;
del_timer(&lapb->t1timer);
 }
 
 void lapb_stop_t2timer(struct lapb_cb *lapb)
 {
-   lapb->t2timer_stop = true;
+   lapb->t2timer_running = false;
del_timer(&lapb->t2timer);
 }
 
 int lapb_t1timer_running(struct lapb_cb *lapb)
 {
-   return timer_pending(&lapb->t1timer);
+   return lapb->t1timer_running;
 }
 
 static void lapb_t2timer_expiry(struct timer_list *t)
@@ -79,13 +79,14 @@ static void lapb_t2timer_expiry(struct timer_list *t)
spin_lock_bh(&lapb->lock);
if (timer_pending(&lapb->t2timer)) /* A new timer has been set up */
goto out;
-   if (lapb->t2timer_stop) /* The timer has been stopped */
+   if (!lapb->t2timer_running) /* The timer has been stopped */
goto out;
 
if (lapb->condition & LAPB_ACK_PENDING_CONDITION) {
lapb->condition &= ~LAPB_ACK_PENDING_CONDITION;
lapb_timeout_response(lapb);
}
+   lapb->t2timer_running = false;
 
 out:
spin_unlock_bh(&lapb->lock);
@@ -98,7 +99,7 @@ static void lapb_t1timer_expiry(struct timer_list *t)
spin_lock_bh(&lapb->lock);
if (timer_pending(&lapb->t1timer)) /* A new timer 

[PATCH] media: cx25821: switch from 'pci_' to 'dma_' API

2021-03-21 Thread Christophe JAILLET
The wrappers in include/linux/pci-dma-compat.h should go away.

The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.

When memory is allocated in 'cx25821_riscmem_alloc()' GFP_KERNEL can be
used because either this flag is already used in the call chain, or it is
called from a 'buf_prepare' function.

The call chains are:
  vb2_ops.buf_prepare  (in cx25821-video.c)
cx25821_buffer_prepare (in cx25821-video.c)
  cx25821_risc_buffer
cx25821_riscmem_alloc

  snd_cx25821_hw_params(in cx25821-alsa.c) <-- use GFP_KERNEL
cx25821_risc_databuffer_audio
  cx25821_riscmem_alloc


@@
@@
-PCI_DMA_BIDIRECTIONAL
+DMA_BIDIRECTIONAL

@@
@@
-PCI_DMA_TODEVICE
+DMA_TO_DEVICE

@@
@@
-PCI_DMA_FROMDEVICE
+DMA_FROM_DEVICE

@@
@@
-PCI_DMA_NONE
+DMA_NONE

@@
expression e1, e2, e3;
@@
-pci_alloc_consistent(e1, e2, e3)
+dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3;
@@
-pci_zalloc_consistent(e1, e2, e3)
+dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3, e4;
@@
-pci_free_consistent(e1, e2, e3, e4)
+dma_free_coherent(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-pci_map_single(e1, e2, e3, e4)
+dma_map_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-pci_unmap_single(e1, e2, e3, e4)
+dma_unmap_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4, e5;
@@
-pci_map_page(e1, e2, e3, e4, e5)
+dma_map_page(&e1->dev, e2, e3, e4, e5)

@@
expression e1, e2, e3, e4;
@@
-pci_unmap_page(e1, e2, e3, e4)
+dma_unmap_page(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-pci_map_sg(e1, e2, e3, e4)
+dma_map_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-pci_unmap_sg(e1, e2, e3, e4)
+dma_unmap_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-pci_dma_sync_single_for_device(e1, e2, e3, e4)
+dma_sync_single_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2;
@@
-pci_dma_mapping_error(e1, e2)
+dma_mapping_error(&e1->dev, e2)

@@
expression e1, e2;
@@
-pci_set_dma_mask(e1, e2)
+dma_set_mask(&e1->dev, e2)

@@
expression e1, e2;
@@
-pci_set_consistent_dma_mask(e1, e2)
+dma_set_coherent_mask(&e1->dev, e2)

Signed-off-by: Christophe JAILLET 
---
If needed, see post from Christoph Hellwig on the kernel-janitors ML:
   https://marc.info/?l=kernel-janitors&m=158745678307186&w=4
---
 drivers/media/pci/cx25821/cx25821-alsa.c |  2 +-
 drivers/media/pci/cx25821/cx25821-core.c | 10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/cx25821/cx25821-alsa.c 
b/drivers/media/pci/cx25821/cx25821-alsa.c
index 8797d85a6b0a..438fdcec6eac 100644
--- a/drivers/media/pci/cx25821/cx25821-alsa.c
+++ b/drivers/media/pci/cx25821/cx25821-alsa.c
@@ -402,7 +402,7 @@ static int dsp_buffer_free(struct cx25821_audio_dev *chip)
dprintk(2, "Freeing buffer\n");
cx25821_alsa_dma_unmap(chip);
cx25821_alsa_dma_free(chip->buf);
-   pci_free_consistent(chip->pci, risc->size, risc->cpu, risc->dma);
+   dma_free_coherent(&chip->pci->dev, risc->size, risc->cpu, risc->dma);
kfree(chip->buf);
 
chip->buf = NULL;
diff --git a/drivers/media/pci/cx25821/cx25821-core.c 
b/drivers/media/pci/cx25821/cx25821-core.c
index 07b6d0c49bbf..40c10ca94def 100644
--- a/drivers/media/pci/cx25821/cx25821-core.c
+++ b/drivers/media/pci/cx25821/cx25821-core.c
@@ -977,11 +977,11 @@ int cx25821_riscmem_alloc(struct pci_dev *pci,
dma_addr_t dma = 0;
 
if (risc->cpu && risc->size < size) {
-   pci_free_consistent(pci, risc->size, risc->cpu, risc->dma);
+   dma_free_coherent(&pci->dev, risc->size, risc->cpu, risc->dma);
risc->cpu = NULL;
}
if (NULL == risc->cpu) {
-   cpu = pci_zalloc_consistent(pci, size, &dma);
+   cpu = dma_alloc_coherent(&pci->dev, size, &dma, GFP_KERNEL);
if (NULL == cpu)
return -ENOMEM;
risc->cpu  = cpu;
@@ -1202,8 +1202,8 @@ void cx25821_free_buffer(struct cx25821_dev *dev, struct 
cx25821_buffer *buf)
 {
if (WARN_ON(buf->risc.size == 0))
return;
-   pci_free_consistent(dev->pci,
-   buf->risc.size, buf->risc.cpu, buf->risc.dma);
+   dma_free_coherent(&dev->pci->dev, buf->risc.size, buf->risc.cpu,
+ buf->risc.dma);

[PATCH] clk: renesas: Couple of spelling fixes

2021-03-21 Thread Bhaskar Chowdhury


s/suposed/supposed/
s/concurent/concurrent/

Signed-off-by: Bhaskar Chowdhury 
---
 drivers/clk/renesas/r9a06g032-clocks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/renesas/r9a06g032-clocks.c 
b/drivers/clk/renesas/r9a06g032-clocks.c
index 892e91b92f2c..1fe166e7f8bd 100644
--- a/drivers/clk/renesas/r9a06g032-clocks.c
+++ b/drivers/clk/renesas/r9a06g032-clocks.c
@@ -279,7 +279,7 @@ static const struct r9a06g032_clkdesc r9a06g032_clocks[] = {
/*
 * These are not hardware clocks, but are needed to handle the special
 * case where we have a 'selector bit' that doesn't just change the
-* parent for a clock, but also the gate it's suposed to use.
+* parent for a clock, but also the gate it's supposed to use.
 */
{
.index = R9A06G032_UART_GROUP_012,
@@ -311,7 +311,7 @@ static const struct r9a06g032_clkdesc r9a06g032_clocks[] = {

 struct r9a06g032_priv {
struct clk_onecell_data data;
-   spinlock_t lock; /* protects concurent access to gates */
+   spinlock_t lock; /* protects concurrent access to gates */
void __iomem *reg;
 };

--
2.30.1



Re: [PATCH v2 0/3] ALSA: hdsp and hdspm, don't disable device if not enabled

2021-03-21 Thread Takashi Iwai
On Sat, 20 Mar 2021 23:23:33 +0100,
Tong Zhang wrote:
> 
> This series fixes issues in hdsp and hdspm. The drivers in question want
> to disable a device that is not enabled on error path.
> 
> v2: add fix to rme9652
> 
> Tong Zhang (3):
>   ALSA: hdsp: don't disable if not enabled
>   ALSA: hdspm: don't disable if not enabled
>   ALSA: rme9652: don't disable if not enabled

Thanks for the patches.

IMO, a safer way for this is to add pci_is_enabled() check in *_free()
functions around the call of pci_disable_device().  The point is that
*_free() is the sole destructor function that manages all stuff, hence
it's better to do all there.  And, of course, it'll be less changes.

Care to resend v3 patches with that?


thanks,

Takashi


Re: [PATCH net-next v2 2/2] net: ipa: fix IPA validation

2021-03-21 Thread Leon Romanovsky
On Sat, Mar 20, 2021 at 09:17:29AM -0500, Alex Elder wrote:
> There are blocks of IPA code that sanity-check various values, at
> compile time where possible.  Most of these checks can be done once
> during development but skipped for normal operation.  These checks
> permit the driver to make certain assumptions, thereby avoiding the
> need for runtime error checking.
> 
> The checks are defined conditionally, but not consistently.  In
> some cases IPA_VALIDATION enables the optional checks, while in
> others IPA_VALIDATE is used.
> 
> Fix this by using IPA_VALIDATION consistently.
> 
> Signed-off-by: Alex Elder 
> ---
>  drivers/net/ipa/Makefile   | 2 +-
>  drivers/net/ipa/gsi_trans.c| 8 
>  drivers/net/ipa/ipa_cmd.c  | 4 ++--
>  drivers/net/ipa/ipa_cmd.h  | 6 +++---
>  drivers/net/ipa/ipa_endpoint.c | 6 +++---
>  drivers/net/ipa/ipa_main.c | 6 +++---
>  drivers/net/ipa/ipa_mem.c  | 6 +++---
>  drivers/net/ipa/ipa_table.c| 6 +++---
>  drivers/net/ipa/ipa_table.h| 6 +++---
>  9 files changed, 25 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/net/ipa/Makefile b/drivers/net/ipa/Makefile
> index afe5df1e6..014ae36ac6004 100644
> --- a/drivers/net/ipa/Makefile
> +++ b/drivers/net/ipa/Makefile
> @@ -1,5 +1,5 @@
>  # Un-comment the next line if you want to validate configuration data
> -#ccflags-y   +=  -DIPA_VALIDATE
> +# ccflags-y  +=  -DIPA_VALIDATION

Maybe netdev folks think differently here, but general rule that dead
code and closed code is such, is not acceptable to in Linux kernel.

<...>

>  
> -#ifdef IPA_VALIDATE
> +#ifdef IPA_VALIDATION
>   if (!size || size % 8)
>   return -EINVAL;
>   if (count < max_alloc)
>   return -EINVAL;
>   if (!max_alloc)
>   return -EINVAL;
> -#endif /* IPA_VALIDATE */
> +#endif /* IPA_VALIDATION */

If it is possible to supply those values, the check should be always and
not only under some closed config option.

>  
>   /* By allocating a few extra entries in our pool (one less
>* than the maximum number that will be requested in a
> @@ -140,14 +140,14 @@ int gsi_trans_pool_init_dma(struct device *dev, struct 
> gsi_trans_pool *pool,
>   dma_addr_t addr;
>   void *virt;
>  
> -#ifdef IPA_VALIDATE
> +#ifdef IPA_VALIDATION
>   if (!size || size % 8)
>   return -EINVAL;
>   if (count < max_alloc)
>   return -EINVAL;
>   if (!max_alloc)
>   return -EINVAL;
> -#endif /* IPA_VALIDATE */
> +#endif /* IPA_VALIDATION */

Same

<...>

>  {
> -#ifdef IPA_VALIDATE
> +#ifdef IPA_VALIDATION
>   /* At one time we assumed a 64-bit build, allowing some do_div()
>* calls to be replaced by simple division or modulo operations.
>* We currently only perform divide and modulo operations on u32,
> @@ -768,7 +768,7 @@ static void ipa_validate_build(void)
>   BUILD_BUG_ON(!ipa_aggr_granularity_val(IPA_AGGR_GRANULARITY));
>   BUILD_BUG_ON(ipa_aggr_granularity_val(IPA_AGGR_GRANULARITY) >
>   field_max(AGGR_GRANULARITY_FMASK));
> -#endif /* IPA_VALIDATE */
> +#endif /* IPA_VALIDATION */

BUILD_BUG_ON()s are checked during compilation and not during runtime
like IPA_VALIDATION promised.

IMHO, the issue here is that this IPA code isn't release quality but
some debug drop variant and it is far from expected from submitted code.

Thanks


Re: [PATCH] net: make unregister netdev warning timeout configurable

2021-03-21 Thread Leon Romanovsky
On Sat, Mar 20, 2021 at 03:28:51PM +0100, Dmitry Vyukov wrote:
> netdev_wait_allrefs() issues a warning if refcount does not drop to 0
> after 10 seconds. While 10 second wait generally should not happen
> under normal workload in normal environment, it seems to fire falsely
> very often during fuzzing and/or in qemu emulation (~10x slower).
> At least it's not possible to understand if it's really a false
> positive or not. Automated testing generally bumps all timeouts
> to very high values to avoid flake failures.
> Make the timeout configurable for automated testing systems.
> Lowering the timeout may also be useful for e.g. manual bisection.
> The default value matches the current behavior.
> 
> Signed-off-by: Dmitry Vyukov 
> Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=211877
> Cc: net...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  net/Kconfig| 12 
>  net/core/dev.c |  4 +++-
>  2 files changed, 15 insertions(+), 1 deletion(-)
> 

Our verification team would like to see this change too.

Thanks,
Reviewed-by: Leon Romanovsky 


[PATCH v2 2/3] drm/tilcdc: fix LCD pixel clock setting

2021-03-21 Thread Dario Binacchi
The tilcdc_pclk_diff() compares the requested pixel clock rate to the
real one, so passing it clk_rate instead of clk_rate / clkdiv caused
it to fail even if the clk_rate was properly set. Adding the
real_pclk_rate variable makes the code more readable.

Signed-off-by: Dario Binacchi 

---

Changes in v2:
- Rename clk_div_rate to real_pclk_rate.
- Provide pixel clock rate to tilcdc_pclk_diff().

 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index aeec5786617d..ac6228cb04d9 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -203,7 +203,7 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
struct drm_device *dev = crtc->dev;
struct tilcdc_drm_private *priv = dev->dev_private;
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
-   unsigned long clk_rate, real_rate, pclk_rate;
+   unsigned long clk_rate, real_rate, real_pclk_rate, pclk_rate;
unsigned int clkdiv;
int ret;
 
@@ -214,7 +214,8 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
 
ret = clk_set_rate(priv->clk, pclk_rate * clkdiv);
clk_rate = clk_get_rate(priv->clk);
-   if (ret < 0 || tilcdc_pclk_diff(pclk_rate, clk_rate) > 5) {
+   real_pclk_rate = clk_rate / clkdiv;
+   if (ret < 0 || tilcdc_pclk_diff(pclk_rate, real_pclk_rate) > 5) {
/*
 * If we fail to set the clock rate (some architectures don't
 * use the common clock framework yet and may not implement
-- 
2.17.1



[PATCH v2 3/3] drm/tilcdc: fix pixel clock setting warning message

2021-03-21 Thread Dario Binacchi
The warning message did not printed the LCD pixel clock rate but the LCD
clock divisor input rate. As a consequence, the required and real pixel
clock rates are now passed to the tilcdc_pclk_diff().

Signed-off-by: Dario Binacchi 

---

Changes in v2:
- The patch has been added in version 2.

 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index ac6228cb04d9..c0792c52dc02 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -203,7 +203,7 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
struct drm_device *dev = crtc->dev;
struct tilcdc_drm_private *priv = dev->dev_private;
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
-   unsigned long clk_rate, real_rate, real_pclk_rate, pclk_rate;
+   unsigned long clk_rate, real_pclk_rate, pclk_rate;
unsigned int clkdiv;
int ret;
 
@@ -239,12 +239,12 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
 * 5% is an arbitrary value - LCDs are usually quite tolerant
 * about pixel clock rates.
 */
-   real_rate = clkdiv * pclk_rate;
+   real_pclk_rate = clk_rate / clkdiv;
 
-   if (tilcdc_pclk_diff(clk_rate, real_rate) > 5) {
+   if (tilcdc_pclk_diff(pclk_rate, real_pclk_rate) > 5) {
dev_warn(dev->dev,
 "effective pixel clock rate (%luHz) differs 
from the calculated rate (%luHz)\n",
-clk_rate, real_rate);
+pclk_rate, real_pclk_rate);
}
}
 
-- 
2.17.1



[PATCH v2 0/3] drm/tilcdc: fix LCD pixel clock setting

2021-03-21 Thread Dario Binacchi


The series was born from a patch to fix the LCD pixel clock setting.
Two additional patches have been added to this. One renames a misleading
variable name that was probably the cause of the bug and the other fixes
a warning message.


Changes in v2:
- The patch has been added in version 2.
- Rename clk_div_rate to real_pclk_rate.
- Provide pixel clock rate to tilcdc_pclk_diff().
- The patch has been added in version 2.

Dario Binacchi (3):
  drm/tilcdc: rename req_rate to pclk_rate
  drm/tilcdc: fix LCD pixel clock setting
  drm/tilcdc: fix pixel clock setting warning message

 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

-- 
2.17.1



[PATCH v2 1/3] drm/tilcdc: rename req_rate to pclk_rate

2021-03-21 Thread Dario Binacchi
The req_rate name is a little misleading, so let's rename to pclk_rate
(pixel clock rate).

Signed-off-by: Dario Binacchi 

---

Changes in v2:
- The patch has been added in version 2.

 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 30213708fc99..aeec5786617d 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -203,18 +203,18 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
struct drm_device *dev = crtc->dev;
struct tilcdc_drm_private *priv = dev->dev_private;
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
-   unsigned long clk_rate, real_rate, req_rate;
+   unsigned long clk_rate, real_rate, pclk_rate;
unsigned int clkdiv;
int ret;
 
clkdiv = 2; /* first try using a standard divider of 2 */
 
/* mode.clock is in KHz, set_rate wants parameter in Hz */
-   req_rate = crtc->mode.clock * 1000;
+   pclk_rate = crtc->mode.clock * 1000;
 
-   ret = clk_set_rate(priv->clk, req_rate * clkdiv);
+   ret = clk_set_rate(priv->clk, pclk_rate * clkdiv);
clk_rate = clk_get_rate(priv->clk);
-   if (ret < 0 || tilcdc_pclk_diff(req_rate, clk_rate) > 5) {
+   if (ret < 0 || tilcdc_pclk_diff(pclk_rate, clk_rate) > 5) {
/*
 * If we fail to set the clock rate (some architectures don't
 * use the common clock framework yet and may not implement
@@ -229,7 +229,7 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
return;
}
 
-   clkdiv = DIV_ROUND_CLOSEST(clk_rate, req_rate);
+   clkdiv = DIV_ROUND_CLOSEST(clk_rate, pclk_rate);
 
/*
 * Emit a warning if the real clock rate resulting from the
@@ -238,7 +238,7 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
 * 5% is an arbitrary value - LCDs are usually quite tolerant
 * about pixel clock rates.
 */
-   real_rate = clkdiv * req_rate;
+   real_rate = clkdiv * pclk_rate;
 
if (tilcdc_pclk_diff(clk_rate, real_rate) > 5) {
dev_warn(dev->dev,
-- 
2.17.1



Re: [PATCH 2/2] media: radio: RDA5807: Added driver

2021-03-21 Thread Hans Verkuil
Hi Maarten,

Thank you for this patch.

Before I can accept this driver I have to see the output of v4l2-compliance -r 
/dev/radioX.

That utility is part of the v4l-utils git repo:

git://linuxtv.org/v4l-utils.git

Compile it from the master branch of that repo, don't rely on the version
distributed by distros since that's typically too old.

The compliance test must pass without failures and preferably without warnings.

Some more comments below:

On 02/03/2021 15:42, Paul Cercueil wrote:
> From: Maarten ter Huurne 
> 
> Add a driver to support the RDA5807 FM radio I2C chip from Unisoc
> Communications.
> 
> Tested and working with fmtools 2.x.
> 
> Signed-off-by: Maarten ter Huurne 
> Signed-off-by: Paul Cercueil 
> ---
>  drivers/media/radio/Kconfig |  12 +
>  drivers/media/radio/Makefile|   1 +
>  drivers/media/radio/radio-rda5807.c | 920 
>  3 files changed, 933 insertions(+)
>  create mode 100644 drivers/media/radio/radio-rda5807.c
> 
> diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
> index d29e29645e04..323faa7d3d52 100644
> --- a/drivers/media/radio/Kconfig
> +++ b/drivers/media/radio/Kconfig
> @@ -81,6 +81,18 @@ config RADIO_MAXIRADIO
> To compile this driver as a module, choose M here: the
> module will be called radio-maxiradio.
>  
> +config RADIO_RDA5807
> + tristate "RDA5807 I2C FM radio support"
> + depends on I2C && VIDEO_V4L2
> + select REGMAP_I2C
> + select PM
> + help
> +   Say Y here if you want to use the RDA5807 FM receiver connected to
> +   an I2C bus.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called radio-rda5807.
> +
>  config RADIO_SHARK
>   tristate "Griffin radioSHARK USB radio receiver"
>   depends on USB
> diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
> index 53c7ae135460..a85ccab640b0 100644
> --- a/drivers/media/radio/Makefile
> +++ b/drivers/media/radio/Makefile
> @@ -26,6 +26,7 @@ obj-$(CONFIG_RADIO_SI4713) += si4713/
>  obj-$(CONFIG_USB_MR800) += radio-mr800.o
>  obj-$(CONFIG_USB_KEENE) += radio-keene.o
>  obj-$(CONFIG_USB_MA901) += radio-ma901.o
> +obj-$(CONFIG_RADIO_RDA5807) += radio-rda5807.o
>  obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
>  obj-$(CONFIG_RADIO_SAA7706H) += saa7706h.o
>  obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
> diff --git a/drivers/media/radio/radio-rda5807.c 
> b/drivers/media/radio/radio-rda5807.c
> new file mode 100644
> index ..0f7796ca2575
> --- /dev/null
> +++ b/drivers/media/radio/radio-rda5807.c
> @@ -0,0 +1,920 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * radio-rda5807.c - Driver for using the RDA5807 FM tuner chip via I2C
> + *
> + * Copyright (c) 2011 Maarten ter Huurne 
> + * Copyright (c) 2021 Paul Cercueil 
> + *
> + * Many thanks to Jérôme Veres for his command line radio application that
> + * demonstrates how the chip can be controlled via I2C.
> + *
> + * Also thanks to Marcos Paulo de Souza for several patches to this driver.
> + *
> + * The RDA5807 has three ways of accessing registers:
> + * - I2C address 0x10: sequential access, RDA5800 style
> + * - I2C address 0x11: random access
> + * - I2C address 0x60: sequential access, TEA5767 compatible
> + *
> + * This driver only supports random access to the registers.
> + */
> +
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +
> +enum rda5807_reg {
> + RDA5807_REG_CHIPID  = 0x00,
> + RDA5807_REG_CTRL= 0x02,
> + RDA5807_REG_CHAN= 0x03,
> + RDA5807_REG_IOCFG   = 0x04,
> + RDA5807_REG_INPUT   = 0x05,
> + RDA5807_REG_BAND= 0x07,
> + RDA5807_REG_SEEKRES = 0x0A,
> + RDA5807_REG_SIGNAL  = 0x0B,
> +};
> +
> +#define RDA5807_CTRL_DHIZBIT(15)
> +#define RDA5807_CTRL_DMUTE   BIT(14)
> +#define RDA5807_CTRL_MONOBIT(13)
> +#define RDA5807_CTRL_BASSBIT(12)
> +#define RDA5807_CTRL_SEEKUP  BIT(9)
> +#define RDA5807_CTRL_SEEKBIT(8)
> +#define RDA5807_CTRL_SKMODE  BIT(7)
> +#define RDA5807_CTRL_CLKMODE GENMASK(6, 4)
> +#define RDA5807_CTRL_SOFTRESET   BIT(1)
> +#define RDA5807_CTRL_ENABLE  BIT(0)
> +
> +#define RDA5807_CHAN_WRCHAN  GENMASK(15, 6)
> +#define RDA5807_CHAN_TUNEBIT(4)
> +#define RDA5807_CHAN_BANDGENMASK(3, 2)
> +#define RDA5807_CHAN_SPACE   GENMASK(1, 0)
> +
> +#define RDA5807_IOCFG_DEEMPHASIS BIT(11)
> +#define RDA5807_IOCFG_I2S_EN BIT(6)
> +
> +#define RDA5807_INPUT_LNA_PORT   GENMASK(7, 6)
> +#define RDA5807_INPUT_LNA_ICSEL  GENMASK(5, 4)
> +#define RDA5807_INPUT_VOLUME GENMASK(3, 0)
> +
> +#define RDA5807_BAND_65M

Re: [PATCH 4/4] PCI/sysfs: Allow userspace to query and set device reset mechanism

2021-03-21 Thread Leon Romanovsky
On Sat, Mar 20, 2021 at 08:59:42AM -0600, Alex Williamson wrote:
> On Sat, 20 Mar 2021 11:10:08 +0200
> Leon Romanovsky  wrote:
> > On Fri, Mar 19, 2021 at 10:23:13AM -0600, Alex Williamson wrote: 
> > > 
> > > What if we taint the kernel or pci_warn() for cases where either all
> > > the reset methods are disabled, ie. 'echo none > reset_method', or any
> > > time a device specific method is disabled?  
> > 
> > What does it mean "none"? Does it mean nothing supported? If yes, I think 
> > that
> > pci_warn() will be enough. At least for me, taint is usable during debug 
> > stages,
> > probably if device doesn't crash no one will look to see 
> > /proc/sys/kernel/tainted.
> 
> "none" as implemented in this patch, clearing the enabled function
> reset methods.

It is far from intuitive, the empty string will be easier to understand,
because "none" means no reset at all.

> 
> > > I'd almost go so far as to prevent disabling a device specific reset
> > > altogether, but for example should a device specific reset that fixes
> > > an aspect of FLR behavior prevent using a bus reset?  I'd prefer in that
> > > case if direct FLR were disabled via a device flag introduced with the
> > > quirk and the remaining resets can still be selected by preference.  
> > 
> > I don't know enough to discuss the PCI details, but you raised good point.
> > This sysfs is user visible API that is presented as is from device point
> > of view. It can be easily run into problems if PCI/core doesn't work with
> > user's choice.
> > 
> > > 
> > > Theoretically all the other reset methods work and are available, it's
> > > only a policy decision which to use, right?  
> > 
> > But this patch was presented as a way to overcome situations where
> > supported != working and user magically knows which reset type to set.
> 
> It's not magic, the new sysfs attributes expose which resets are
> enabled and the order that they're used, the user can simply select the
> next one.  Being able to bypass a broken reset method is a helpful side
> effect of getting to select a preferred reset method.

Magic in a sense that user has no idea what those resets mean, the
expectation is that he will blindly iterate till something works.

> 
> > If you want to take this patch to be policy decision tool,
> > it will need to accept "reset_type1,reset_type2,..." sort of input,
> > so fallback will work natively.
> 
> I don't see that as a requirement.  We have fall-through support in the
> kernel, but for a given device we're really only ever going to make use
> of one of those methods.  If a user knows enough about a device to have
> a preference, I think it can be singular.  That also significantly
> simplifies the interface and supporting code.  Thanks,

I'm struggling to get requirements from this thread. You talked about
policy decision to overtake fallback mechanism, Amey wanted to avoid
quirks.

Do you have an example of such devices or we are talking about
theoretical case?

And I don't see why simple line parser with loop iterator over strchr()
suddenly becomes complicated code.

Thanks

> 
> Alex
> 


Re: [PATCH 1/2] media: v4l2-core: ignore native time32 ioctls on 64-bit

2021-03-21 Thread Hans Verkuil
Hi Arnd,

On 18/03/2021 14:43, Arnd Bergmann wrote:
> From: Arnd Bergmann 
> 
> Syzbot found that passing ioctl command 0xc0505609 into a 64-bit
> kernel from a 32-bit process causes uninitialized kernel memory to
> get passed to drivers instead of the user space data:
> 
> BUG: KMSAN: uninit-value in check_array_args 
> drivers/media/v4l2-core/v4l2-ioctl.c:3041 [inline]
> BUG: KMSAN: uninit-value in video_usercopy+0x1631/0x3d30 
> drivers/media/v4l2-core/v4l2-ioctl.c:3315
> CPU: 0 PID: 19595 Comm: syz-executor.4 Not tainted 5.11.0-rc7-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS 
> Google 01/01/2011
> Call Trace:
>  __dump_stack lib/dump_stack.c:79 [inline]
>  dump_stack+0x21c/0x280 lib/dump_stack.c:120
>  kmsan_report+0xfb/0x1e0 mm/kmsan/kmsan_report.c:118
>  __msan_warning+0x5f/0xa0 mm/kmsan/kmsan_instr.c:197
>  check_array_args drivers/media/v4l2-core/v4l2-ioctl.c:3041 [inline]
>  video_usercopy+0x1631/0x3d30 drivers/media/v4l2-core/v4l2-ioctl.c:3315
>  video_ioctl2+0x9f/0xb0 drivers/media/v4l2-core/v4l2-ioctl.c:3391
>  v4l2_ioctl+0x255/0x290 drivers/media/v4l2-core/v4l2-dev.c:360
>  v4l2_compat_ioctl32+0x2c6/0x370 
> drivers/media/v4l2-core/v4l2-compat-ioctl32.c:1248
>  __do_compat_sys_ioctl fs/ioctl.c:842 [inline]
>  __se_compat_sys_ioctl+0x53d/0x1100 fs/ioctl.c:793
>  __ia32_compat_sys_ioctl+0x4a/0x70 fs/ioctl.c:793
>  do_syscall_32_irqs_on arch/x86/entry/common.c:79 [inline]
>  __do_fast_syscall_32+0x102/0x160 arch/x86/entry/common.c:141
>  do_fast_syscall_32+0x6a/0xc0 arch/x86/entry/common.c:166
>  do_SYSENTER_32+0x73/0x90 arch/x86/entry/common.c:209
>  entry_SYSENTER_compat_after_hwframe+0x4d/0x5c
> 
> The time32 commands are defined but were never meant to be called on
> 64-bit machines, as those have always used time64 interfaces.  I missed
> this in my patch that introduced the time64 handling on 32-bit platforms.
> 
> The problem in this case is the mismatch of one function checking for
> the numeric value of the command and another function checking for the
> type of process (native vs compat) instead, with the result being that
> for this combination, nothing gets copied into the buffer at all.
> 
> Avoid this by only trying to convert the time32 commands when running
> on a 32-bit kernel where these are defined in a meaningful way.
> 
> Fixes: 577c89b0ce72 ("media: v4l2-core: fix v4l2_buffer handling for time64 
> ABI")
> Reported-by: syzbot+142888ffec98ab194...@syzkaller.appspotmail.com
> Tested-by: Hans Verkuil 
> Signed-off-by: Arnd Bergmann 
> ---
> This patch adds two more changes than the version that Hans tested
> ---
>  drivers/media/v4l2-core/v4l2-ioctl.c  | 6 +++---
>  drivers/media/v4l2-core/v4l2-subdev.c | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
> b/drivers/media/v4l2-core/v4l2-ioctl.c
> index 31d1342e61e8..2b1bb68dc27f 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -3115,7 +3115,7 @@ static int check_array_args(unsigned int cmd, void 
> *parg, size_t *array_size,
>  static unsigned int video_translate_cmd(unsigned int cmd)
>  {
>   switch (cmd) {
> -#ifdef CONFIG_COMPAT_32BIT_TIME
> +#if !defined(CONFIG_64BIT) && defined(CONFIG_COMPAT_32BIT_TIME)
>   case VIDIOC_DQEVENT_TIME32:
>   return VIDIOC_DQEVENT;
>   case VIDIOC_QUERYBUF_TIME32:
> @@ -3169,7 +3169,7 @@ static int video_get_user(void __user *arg, void *parg,
>   err = v4l2_compat_get_user(arg, parg, cmd);
>   } else {
>   switch (cmd) {
> -#ifdef CONFIG_COMPAT_32BIT_TIME
> +#if !defined(CONFIG_64BIT) && defined(CONFIG_COMPAT_32BIT_TIME)
>   case VIDIOC_QUERYBUF_TIME32:
>   case VIDIOC_QBUF_TIME32:
>   case VIDIOC_DQBUF_TIME32:
> @@ -3224,7 +3224,7 @@ static int video_put_user(void __user *arg, void *parg,
>   return v4l2_compat_put_user(arg, parg, cmd);
>  
>   switch (cmd) {
> -#ifdef CONFIG_COMPAT_32BIT_TIME
> +#if !defined(CONFIG_64BIT) && defined(CONFIG_COMPAT_32BIT_TIME)
>   case VIDIOC_DQEVENT_TIME32: {
>   struct v4l2_event *ev = parg;
>   struct v4l2_event_time32 ev32;
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
> b/drivers/media/v4l2-core/v4l2-subdev.c
> index 336133dbc759..9f5573d3b857 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -428,7 +428,7 @@ static long subdev_do_ioctl(struct file *file, unsigned 
> int cmd, void *arg)
>  
>   return v4l2_event_dequeue(vfh, arg, file->f_flags & O_NONBLOCK);
>  
> -#ifdef CONFIG_COMPAT_32BIT_TIME
> +#if !defined(CONFIG_64BIT) && defined(CONFIG_COMPAT_32BIT_TIME)
>   case VIDIOC_DQEVENT_TIME32: {
>   struct v4l2_event_time32 *ev32 = arg;
>   struct v4l2_event ev = { };
> 

This chunk doesn't apply since there is no '#ifdef CONFIG_COMPAT_32BIT_TIME' in
either the mainline

[PATCH] drm/amdkfd: Fix cat debugfs hang_hws file causes system crash bug

2021-03-21 Thread Qu Huang
Here is the system crash log:
[ 1272.884438] BUG: unable to handle kernel NULL pointer dereference at
(null)
[ 1272.88] IP: [<  (null)>]   (null)
[ 1272.884447] PGD 825b09067 PUD 8267c8067 PMD 0
[ 1272.884452] Oops: 0010 [#1] SMP
[ 1272.884509] CPU: 13 PID: 3485 Comm: cat Kdump: loaded Tainted: G
[ 1272.884515] task: 9a38dbd4d140 ti: 9a37cd3b8000 task.ti:
9a37cd3b8000
[ 1272.884517] RIP: 0010:[<>]  [<  (null)>]
(null)
[ 1272.884520] RSP: 0018:9a37cd3bbe68  EFLAGS: 00010203
[ 1272.884522] RAX:  RBX:  RCX:
00014d5f
[ 1272.884524] RDX: fff4 RSI: 0001 RDI:
9a38aca4d200
[ 1272.884526] RBP: 9a37cd3bbed0 R08: 9a38dcd5f1a0 R09:
9a31ffc07300
[ 1272.884527] R10: 9a31ffc07300 R11: addd5e9d R12:
9a38b4e0fb00
[ 1272.884529] R13: 0001 R14: 9a37cd3bbf18 R15:
9a38aca4d200
[ 1272.884532] FS:  7feccaa67740() GS:9a38dcd4()
knlGS:
[ 1272.884534] CS:  0010 DS:  ES:  CR0: 80050033
[ 1272.884536] CR2:  CR3: 0008267c CR4:
003407e0
[ 1272.884537] Call Trace:
[ 1272.884544]  [] ? seq_read+0x130/0x440
[ 1272.884548]  [] vfs_read+0x9f/0x170
[ 1272.884552]  [] SyS_read+0x7f/0xf0
[ 1272.884557]  [] system_call_fastpath+0x22/0x27
[ 1272.884558] Code:  Bad RIP value.
[ 1272.884562] RIP  [<  (null)>]   (null)
[ 1272.884564]  RSP 
[ 1272.884566] CR2: 

Signed-off-by: Qu Huang 
---
 drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
index 511712c..673d5e3 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
@@ -33,6 +33,11 @@ static int kfd_debugfs_open(struct inode *inode, struct file 
*file)

return single_open(file, show, NULL);
 }
+static int kfd_debugfs_hang_hws_read(struct seq_file *m, void *data)
+{
+   seq_printf(m, "echo gpu_id > hang_hws\n");
+   return 0;
+}

 static ssize_t kfd_debugfs_hang_hws_write(struct file *file,
const char __user *user_buf, size_t size, loff_t *ppos)
@@ -94,7 +99,7 @@ void kfd_debugfs_init(void)
debugfs_create_file("rls", S_IFREG | 0444, debugfs_root,
kfd_debugfs_rls_by_device, &kfd_debugfs_fops);
debugfs_create_file("hang_hws", S_IFREG | 0200, debugfs_root,
-   NULL, &kfd_debugfs_hang_hws_fops);
+   kfd_debugfs_hang_hws_read, 
&kfd_debugfs_hang_hws_fops);
 }

 void kfd_debugfs_fini(void)
--
1.8.3.1



Re: [syzbot] KMSAN: uninit-value in skb_trim

2021-03-21 Thread syzbot
syzbot has found a reproducer for the following issue on:

HEAD commit:29ad81a1 arch/x86: add missing include to sparsemem.h
git tree:   https://github.com/google/kmsan.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=16b7e7b2d0
kernel config:  https://syzkaller.appspot.com/x/.config?x=9c7da2160236454
dashboard link: https://syzkaller.appspot.com/bug?extid=e4534e8c1c382508312c
compiler:   Debian clang version 11.0.1-2
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=12897ef6d0
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=143ee4aad0

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+e4534e8c1c3825083...@syzkaller.appspotmail.com

=
BUG: KMSAN: uninit-value in skb_trim+0x1fa/0x280 net/core/skbuff.c:1927
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.11.0-rc7-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
Call Trace:
 
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x21c/0x280 lib/dump_stack.c:120
 kmsan_report+0xfb/0x1e0 mm/kmsan/kmsan_report.c:118
 __msan_warning+0x5f/0xa0 mm/kmsan/kmsan_instr.c:197
 skb_trim+0x1fa/0x280 net/core/skbuff.c:1927
 ath9k_htc_rx_msg+0x631/0x1f30 drivers/net/wireless/ath/ath9k/htc_hst.c:455
 ath9k_hif_usb_rx_stream drivers/net/wireless/ath/ath9k/hif_usb.c:647 [inline]
 ath9k_hif_usb_rx_cb+0x184e/0x1d20 drivers/net/wireless/ath/ath9k/hif_usb.c:680
 __usb_hcd_giveback_urb+0x6ff/0x930 drivers/usb/core/hcd.c:1656
 usb_hcd_giveback_urb+0x1cb/0x730 drivers/usb/core/hcd.c:1726
 dummy_timer+0xda7/0x74f0 drivers/usb/gadget/udc/dummy_hcd.c:1971
 call_timer_fn+0x7d/0x450 kernel/time/timer.c:1417
 expire_timers+0x328/0x6c0 kernel/time/timer.c:1462
 __run_timers+0x624/0x9e0 kernel/time/timer.c:1731
 run_timer_softirq+0x2d/0x50 kernel/time/timer.c:1744
 __do_softirq+0x1b9/0x715 kernel/softirq.c:343
 asm_call_irq_on_stack+0xf/0x20
 
 __run_on_irqstack arch/x86/include/asm/irq_stack.h:26 [inline]
 run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:77 [inline]
 do_softirq_own_stack+0x6e/0x90 arch/x86/kernel/irq_64.c:77
 invoke_softirq kernel/softirq.c:226 [inline]
 __irq_exit_rcu+0x22f/0x280 kernel/softirq.c:420
 irq_exit_rcu+0xe/0x10 kernel/softirq.c:432
 sysvec_apic_timer_interrupt+0x106/0x130 arch/x86/kernel/apic/apic.c:1100
 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:647
RIP: 0010:native_irq_disable arch/x86/include/asm/irqflags.h:49 [inline]
RIP: 0010:arch_local_irq_disable arch/x86/include/asm/irqflags.h:89 [inline]
RIP: 0010:acpi_safe_halt drivers/acpi/processor_idle.c:111 [inline]
RIP: 0010:acpi_idle_do_entry drivers/acpi/processor_idle.c:516 [inline]
RIP: 0010:acpi_idle_enter+0x61d/0x760 drivers/acpi/processor_idle.c:647
Code: f7 d3 44 21 e3 48 85 db 0f 84 ec 00 00 00 4d 85 e4 0f 85 f4 00 00 00 e9 
0c 00 00 00 e8 1c b5 3a fb 0f 00 2d 5f e7 5d 09 fb f4  e9 e0 00 00 00 84 c0 
8b 7d b8 0f 45 7d 98 e8 8f 3b bc fb e9 e5
RSP: 0018:91403b70 EFLAGS: 0246
RAX:  RBX:  RCX: 00023eaec040
RDX: 91431040 RSI:  RDI: 
RBP: 91403c08 R08: 86809bde R09: 88813fffa000
R10: 0002 R11: 91431040 R12: 
R13: 888102fa0064 R14:  R15: 91431ab8
 cpuidle_enter_state+0x99e/0x1750 drivers/cpuidle/cpuidle.c:237
 cpuidle_enter+0xe3/0x170 drivers/cpuidle/cpuidle.c:351
 call_cpuidle kernel/sched/idle.c:158 [inline]
 cpuidle_idle_call kernel/sched/idle.c:239 [inline]
 do_idle+0x5df/0x790 kernel/sched/idle.c:299
 cpu_startup_entry+0x45/0x50 kernel/sched/idle.c:396
 rest_init+0x1c8/0x1f0 init/main.c:721
 arch_call_rest_init+0x13/0x15
 start_kernel+0xa17/0xbd8 init/main.c:1064
 x86_64_start_reservations+0x2a/0x2c arch/x86/kernel/head64.c:525
 x86_64_start_kernel+0x86/0x89 arch/x86/kernel/head64.c:506
 secondary_startup_64_no_verify+0xb0/0xbb

Uninit was created at:
 kmsan_save_stack_with_flags mm/kmsan/kmsan.c:121 [inline]
 kmsan_internal_poison_shadow+0x5c/0xf0 mm/kmsan/kmsan.c:104
 kmsan_slab_alloc+0x8d/0xe0 mm/kmsan/kmsan_hooks.c:76
 slab_alloc_node mm/slub.c:2907 [inline]
 __kmalloc_node_track_caller+0xa37/0x1430 mm/slub.c:4527
 __kmalloc_reserve net/core/skbuff.c:142 [inline]
 __alloc_skb+0x2f8/0xb30 net/core/skbuff.c:210
 __netdev_alloc_skb+0x450/0x7f0 net/core/skbuff.c:446
 __dev_alloc_skb include/linux/skbuff.h:2839 [inline]
 ath9k_hif_usb_rx_stream drivers/net/wireless/ath/ath9k/hif_usb.c:629 [inline]
 ath9k_hif_usb_rx_cb+0xe58/0x1d20 drivers/net/wireless/ath/ath9k/hif_usb.c:680
 __usb_hcd_giveback_urb+0x6ff/0x930 drivers/usb/core/hcd.c:1656
 usb_hcd_giveback_urb+0x1cb/0x730 drivers/usb/core/hcd.c:1726
 dummy_timer+0xda7/0x74f0 drivers/usb/gadget/udc/dummy_hcd.c:1971
 call_timer_fn+0x7d/0x450 kernel/time/timer.c:1417
 expire_timers+0x328/0x6c0 kernel/time/timer.c:1462
 __run_timers+0x624/0x9e0 

Re: linux-next: manual merge of the net tree with Linus' tree

2021-03-21 Thread Leon Romanovsky
On Sat, Mar 20, 2021 at 12:42:06PM -0700, Linus Torvalds wrote:
> On Sat, Mar 20, 2021 at 12:28 PM Marc Kleine-Budde  
> wrote:
> >
> > Good idea. I'll send a pull request to David and Jakub.
> 
> I don't think the revert is necessary. The conflict is so trivial that
> it doesn't really matter.

<...>

> But something like this that just removes the
> MODULE_SUPPORTED_DEVICE() thing that basically never gets touched
> anyway, and we happened to be unlucky in *one* file? Not a worry at
> all.

For me this specific revert is a way to reduce the overhead from the maintainer
when they prepare PRs. At least for me, PRs are most time consuming tasks.

No patch - no conflict - less worries.

Thanks


[PATCH] sound: remove unnecessary blank

2021-03-21 Thread Fengfei Xi
Remove unnecessary blank when calling kmalloc_array().

Signed-off-by: Fengfei Xi 
---
 sound/oss/dmasound/dmasound_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/oss/dmasound/dmasound_core.c 
b/sound/oss/dmasound/dmasound_core.c
index 49679aa86..78bb9dfe2 100644
--- a/sound/oss/dmasound/dmasound_core.c
+++ b/sound/oss/dmasound/dmasound_core.c
@@ -421,7 +421,7 @@ static int sq_allocate_buffers(struct sound_queue *sq, int 
num, int size)
return 0;
sq->numBufs = num;
sq->bufSize = size;
-   sq->buffers = kmalloc_array (num, sizeof(char *), GFP_KERNEL);
+   sq->buffers = kmalloc_array(num, sizeof(char *), GFP_KERNEL);
if (!sq->buffers)
return -ENOMEM;
for (i = 0; i < num; i++) {
-- 
2.17.1



Re: [PATCH] media/pci: Assign value when defining variables

2021-03-21 Thread Hans Verkuil
Hi zuoqilin,

On 17/03/2021 04:08, zuoqil...@163.com wrote:
> From: zuoqilin 
> 
> When defining variables and assigning values can be done at the same time.

For future reference: add the name of the driver to the prefix. Saying
'media/pci:' suggests that you patch multiple PCI drivers in that directory.
But 'media/pci/pt1:' indicates that you patch only the pt1 driver.

I've updated the subject, so no need to repost, but remember this for next
time :-)

Regards,

Hans

> 
> Signed-off-by: zuoqilin 
> ---
>  drivers/media/pci/pt1/pt1.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c
> index 72b191c..f2aa368 100644
> --- a/drivers/media/pci/pt1/pt1.c
> +++ b/drivers/media/pci/pt1/pt1.c
> @@ -334,8 +334,7 @@ static int pt1_sync(struct pt1 *pt1)
>  static u64 pt1_identify(struct pt1 *pt1)
>  {
>   int i;
> - u64 id;
> - id = 0;
> + u64 id = 0;
>   for (i = 0; i < 57; i++) {
>   id |= (u64)(pt1_read_reg(pt1, 0) >> 30 & 1) << i;
>   pt1_write_reg(pt1, 0, 0x0008);
> @@ -1122,8 +1121,7 @@ static int pt1_i2c_end(struct pt1 *pt1, int addr)
>  
>  static void pt1_i2c_begin(struct pt1 *pt1, int *addrp)
>  {
> - int addr;
> - addr = 0;
> + int addr = 0;
>  
>   pt1_i2c_emit(pt1, addr, 0, 0, 1, 1, addr /* itself */);
>   addr = addr + 1;
> 



Re: remove the legacy ide driver

2021-03-21 Thread John Paul Adrian Glaubitz
Hello Christoph!

On 3/18/21 5:56 AM, Christoph Hellwig wrote:
> libata mostly covers all hardware supported by the legacy ide driver.
> There are three mips drivers that are not supported, but the linux-mips
> list could not identify any users of those.  There also are two m68k
> drivers that do not have libata equivalents, which might or might not
> have users, so we'll need some input and possibly help from the m68k
> community here.

I think those drivers were the Q60 driver and the MacIDE driver, weren't they?

Either way, I have so far been unsuccessful in obtaining access to these 
machines
but I assume once we gain access to such machines, Bartlomiej could convert the
drivers the same way he already converted the falcon, gayle and buddha drivers,
for example.

One could also just convert the drivers to libata and include them untested, the
conversion itself seems pretty little work for someone experienced with libata.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913



[PATCH net-next v2] net: lapb: Make "lapb_t1timer_running" able to detect an already running timer

2021-03-21 Thread Xie He
Problem:

The "lapb_t1timer_running" function in "lapb_timer.c" is used in only
one place: in the "lapb_kick" function in "lapb_out.c". "lapb_kick" calls
"lapb_t1timer_running" to check if the timer is already pending, and if
it is not, schedule it to run.

However, if the timer has already fired and is running, and is waiting to
get the "lapb->lock" lock, "lapb_t1timer_running" will not detect this,
and "lapb_kick" will then schedule a new timer. The old timer will then
abort when it sees a new timer pending.

I think this is not right. The purpose of "lapb_kick" should be ensuring
that the actual work of the timer function is scheduled to be done.
If the timer function is already running but waiting for the lock,
"lapb_kick" should not abort and reschedule it.

Changes made:

I added a new field "t1timer_running" in "struct lapb_cb" for
"lapb_t1timer_running" to use. "t1timer_running" will accurately reflect
whether the actual work of the timer is pending. If the timer has fired
but is still waiting for the lock, "t1timer_running" will still correctly
reflect whether the actual work is waiting to be done.

The old "t1timer_stop" field, whose only responsibility is to ask a timer
(that is already running but waiting for the lock) to abort, is no longer
needed, because the new "t1timer_running" field can fully take over its
responsibility. Therefore "t1timer_stop" is deleted.

"t1timer_running" is not simply a negation of the old "t1timer_stop".
At the end of the timer function, if it does not reschedule itself,
"t1timer_running" is set to false to indicate that the timer is stopped.

For consistency of the code, I also added "t2timer_running" and deleted
"t2timer_stop".

Signed-off-by: Xie He 
---

Change from v1:
Small improvement to the commit message.

---
 include/net/lapb.h|  2 +-
 net/lapb/lapb_iface.c |  4 ++--
 net/lapb/lapb_timer.c | 19 ---
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/include/net/lapb.h b/include/net/lapb.h
index eee73442a1ba..124ee122f2c8 100644
--- a/include/net/lapb.h
+++ b/include/net/lapb.h
@@ -92,7 +92,7 @@ struct lapb_cb {
unsigned short  n2, n2count;
unsigned short  t1, t2;
struct timer_list   t1timer, t2timer;
-   boolt1timer_stop, t2timer_stop;
+   boolt1timer_running, t2timer_running;
 
/* Internal control information */
struct sk_buff_head write_queue;
diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c
index 0511bbe4af7b..1078e14f1acf 100644
--- a/net/lapb/lapb_iface.c
+++ b/net/lapb/lapb_iface.c
@@ -122,8 +122,8 @@ static struct lapb_cb *lapb_create_cb(void)
 
timer_setup(&lapb->t1timer, NULL, 0);
timer_setup(&lapb->t2timer, NULL, 0);
-   lapb->t1timer_stop = true;
-   lapb->t2timer_stop = true;
+   lapb->t1timer_running = false;
+   lapb->t2timer_running = false;
 
lapb->t1  = LAPB_DEFAULT_T1;
lapb->t2  = LAPB_DEFAULT_T2;
diff --git a/net/lapb/lapb_timer.c b/net/lapb/lapb_timer.c
index 0230b272b7d1..5be68869064d 100644
--- a/net/lapb/lapb_timer.c
+++ b/net/lapb/lapb_timer.c
@@ -40,7 +40,7 @@ void lapb_start_t1timer(struct lapb_cb *lapb)
lapb->t1timer.function = lapb_t1timer_expiry;
lapb->t1timer.expires  = jiffies + lapb->t1;
 
-   lapb->t1timer_stop = false;
+   lapb->t1timer_running = true;
add_timer(&lapb->t1timer);
 }
 
@@ -51,25 +51,25 @@ void lapb_start_t2timer(struct lapb_cb *lapb)
lapb->t2timer.function = lapb_t2timer_expiry;
lapb->t2timer.expires  = jiffies + lapb->t2;
 
-   lapb->t2timer_stop = false;
+   lapb->t2timer_running = true;
add_timer(&lapb->t2timer);
 }
 
 void lapb_stop_t1timer(struct lapb_cb *lapb)
 {
-   lapb->t1timer_stop = true;
+   lapb->t1timer_running = false;
del_timer(&lapb->t1timer);
 }
 
 void lapb_stop_t2timer(struct lapb_cb *lapb)
 {
-   lapb->t2timer_stop = true;
+   lapb->t2timer_running = false;
del_timer(&lapb->t2timer);
 }
 
 int lapb_t1timer_running(struct lapb_cb *lapb)
 {
-   return timer_pending(&lapb->t1timer);
+   return lapb->t1timer_running;
 }
 
 static void lapb_t2timer_expiry(struct timer_list *t)
@@ -79,13 +79,14 @@ static void lapb_t2timer_expiry(struct timer_list *t)
spin_lock_bh(&lapb->lock);
if (timer_pending(&lapb->t2timer)) /* A new timer has been set up */
goto out;
-   if (lapb->t2timer_stop) /* The timer has been stopped */
+   if (!lapb->t2timer_running) /* The timer has been stopped */
goto out;
 
if (lapb->condition & LAPB_ACK_PENDING_CONDITION) {
lapb->condition &= ~LAPB_ACK_PENDING_CONDITION;
lapb_timeout_response(lapb);
}
+   lapb->t2timer_running = false;
 
 out:
spin_unlock_bh(&lapb->lock);
@@ -98,7 +99,7 @@ static void lapb_t1timer_expiry(struct timer_list *t)

RE: [PATCH v29 4/4] scsi: ufs: Add HPB 2.0 support

2021-03-21 Thread Avri Altman

> +static int ufshpb_execute_umap_req(struct ufshpb_lu *hpb,
> +  struct ufshpb_req *umap_req,
> +  struct ufshpb_region *rgn)
> +{
> +   struct request *req;
> +   struct scsi_request *rq;
> +
> +   req = umap_req->req;
> +   req->timeout = 0;
> +   req->end_io_data = (void *)umap_req;
> +   rq = scsi_req(req);
> +   ufshpb_set_unmap_cmd(rq->cmd, rgn);
> +   rq->cmd_len = HPB_WRITE_BUFFER_CMD_LENGTH;
> +
> +   blk_execute_rq_nowait(NULL, req, 1, ufshpb_umap_req_compl_fn);
Typo? Forgot the struct request_queue *q?

> +
> +   return 0;
> +}
> +
>  static int ufshpb_execute_map_req(struct ufshpb_lu *hpb,
>   struct ufshpb_req *map_req, bool last)
>  {
> @@ -533,12 +878,12 @@ static int ufshpb_execute_map_req(struct ufshpb_lu
> *hpb,
> 
> q = hpb->sdev_ufs_lu->request_queue;
> for (i = 0; i < hpb->pages_per_srgn; i++) {
> -   ret = bio_add_pc_page(q, map_req->bio, 
> map_req->mctx->m_page[i],
> +   ret = bio_add_pc_page(q, map_req->bio, map_req->rb.mctx-
> >m_page[i],
>   PAGE_SIZE, 0);
> if (ret != PAGE_SIZE) {
> dev_err(&hpb->sdev_ufs_lu->sdev_dev,
>"bio_add_pc_page fail %d - %d\n",
> -  map_req->rgn_idx, map_req->srgn_idx);
> +  map_req->rb.rgn_idx, map_req->rb.srgn_idx);
> return ret;
> }
> }
> @@ -554,8 +899,8 @@ static int ufshpb_execute_map_req(struct ufshpb_lu
> *hpb,
> if (unlikely(last))
> mem_size = hpb->last_srgn_entries * HPB_ENTRY_SIZE;
> 
> -   ufshpb_set_read_buf_cmd(rq->cmd, map_req->rgn_idx,
> -   map_req->srgn_idx, mem_size);
> +   ufshpb_set_read_buf_cmd(rq->cmd, map_req->rb.rgn_idx,
> +   map_req->rb.srgn_idx, mem_size);
> rq->cmd_len = HPB_READ_BUFFER_CMD_LENGTH;
> 
> blk_execute_rq_nowait(NULL, req, 1, ufshpb_map_req_compl_fn);
Ditto


Thanks,
Avri


[GIT PULL] EFI fixes

2021-03-21 Thread Ingo Molnar
Linus,

Please pull the latest efi/urgent git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
efi-urgent-2021-03-21

   # HEAD: 429257a430a0e81e9979256e0db718e35e7d9cee Merge tag 
'efi-urgent-for-v5.12-rc3' of 
git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi into efi/urgent

EFI fixes:

 - another missing RT_PROP table related fix, to ensure that the efivarfs
   pseudo filesystem fails gracefully if variable services are unsupported,
 - use the correct alignment for literal EFI GUIDs,
 - fix a use after unmap issue in the memreserve code

 Thanks,

Ingo

-->
Ard Biesheuvel (1):
  efi: use 32-bit alignment for efi_guid_t literals

Lv Yunlong (1):
  firmware/efi: Fix a use after bug in efi_mem_reserve_persistent

Shawn Guo (1):
  efivars: respect EFI_UNSUPPORTED return from firmware


 drivers/firmware/efi/efi.c  | 3 ++-
 drivers/firmware/efi/vars.c | 4 
 include/linux/efi.h | 6 --
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index df3f9bcab581..4b7ee3fa9224 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -927,7 +927,7 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 
size)
}
 
/* first try to find a slot in an existing linked list entry */
-   for (prsv = efi_memreserve_root->next; prsv; prsv = rsv->next) {
+   for (prsv = efi_memreserve_root->next; prsv; ) {
rsv = memremap(prsv, sizeof(*rsv), MEMREMAP_WB);
index = atomic_fetch_add_unless(&rsv->count, 1, rsv->size);
if (index < rsv->size) {
@@ -937,6 +937,7 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 
size)
memunmap(rsv);
return efi_mem_reserve_iomem(addr, size);
}
+   prsv = rsv->next;
memunmap(rsv);
}
 
diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
index 41c1d00bf933..abdc8a6a3963 100644
--- a/drivers/firmware/efi/vars.c
+++ b/drivers/firmware/efi/vars.c
@@ -484,6 +484,10 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, 
unsigned long, void *),
}
}
 
+   break;
+   case EFI_UNSUPPORTED:
+   err = -EOPNOTSUPP;
+   status = EFI_NOT_FOUND;
break;
case EFI_NOT_FOUND:
break;
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 8710f5710c1d..6b5d36babfcc 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -72,8 +72,10 @@ typedef void *efi_handle_t;
  */
 typedef guid_t efi_guid_t __aligned(__alignof__(u32));
 
-#define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
-   GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)
+#define EFI_GUID(a, b, c, d...) (efi_guid_t){ {
\
+   (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff,  
\
+   (b) & 0xff, ((b) >> 8) & 0xff,  
\
+   (c) & 0xff, ((c) >> 8) & 0xff, d } }
 
 /*
  * Generic EFI table header


[PATCH] nfs_common: modify the comments for locks_end_grace and locks_in_grace

2021-03-21 Thread Fengfei Xi
This patch moves the comment for the @net parameter to the right place.

Signed-off-by: Fengfei Xi 
---
 fs/nfs_common/grace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs_common/grace.c b/fs/nfs_common/grace.c
index 26f2a50ec..9b1a5c7d3 100644
--- a/fs/nfs_common/grace.c
+++ b/fs/nfs_common/grace.c
@@ -42,7 +42,6 @@ EXPORT_SYMBOL_GPL(locks_start_grace);
 
 /**
  * locks_end_grace
- * @net: net namespace that this lock manager belongs to
  * @lm: who this grace period is for
  *
  * Call this function to state that the given lock manager is ready to
@@ -82,6 +81,7 @@ __state_in_grace(struct net *net, bool open)
 
 /**
  * locks_in_grace
+ * @net: net namespace that this lock manager belongs to
  *
  * Lock managers call this function to determine when it is OK for them
  * to answer ordinary lock requests, and when they should accept only
-- 
2.17.1



[GIT PULL] locking fixes

2021-03-21 Thread Ingo Molnar
Linus,

Please pull the latest locking/urgent git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
locking-urgent-2021-03-21

   # HEAD: 38c93587375053c5b9ef093f4a5ea754538cba32 static_call: Fix 
static_call_update() sanity check

Locking fixes:

- Get static calls & modules right. Hopefully.
- WW mutex fixes

 Thanks,

Ingo

-->
Peter Zijlstra (3):
  static_call: Fix static_call_set_init()
  static_call: Align static_call_is_init() patching condition
  static_call: Fix static_call_update() sanity check

Waiman Long (2):
  locking/ww_mutex: Simplify use_ww_ctx & ww_ctx handling
  locking/ww_mutex: Fix acquire/release imbalance in 
ww_acquire_init()/ww_acquire_fini()


 include/linux/ww_mutex.h |  5 +++--
 kernel/jump_label.c  |  8 
 kernel/locking/mutex.c   | 25 ++---
 kernel/static_call.c | 42 --
 4 files changed, 49 insertions(+), 31 deletions(-)

diff --git a/include/linux/ww_mutex.h b/include/linux/ww_mutex.h
index 850424e5d030..6ecf2a0220db 100644
--- a/include/linux/ww_mutex.h
+++ b/include/linux/ww_mutex.h
@@ -173,9 +173,10 @@ static inline void ww_acquire_done(struct ww_acquire_ctx 
*ctx)
  */
 static inline void ww_acquire_fini(struct ww_acquire_ctx *ctx)
 {
-#ifdef CONFIG_DEBUG_MUTEXES
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
mutex_release(&ctx->dep_map, _THIS_IP_);
-
+#endif
+#ifdef CONFIG_DEBUG_MUTEXES
DEBUG_LOCKS_WARN_ON(ctx->acquired);
if (!IS_ENABLED(CONFIG_PROVE_LOCKING))
/*
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index c6a39d662935..ba39fbb1f8e7 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -407,6 +407,14 @@ static bool jump_label_can_update(struct jump_entry 
*entry, bool init)
return false;
 
if (!kernel_text_address(jump_entry_code(entry))) {
+   /*
+* This skips patching built-in __exit, which
+* is part of init_section_contains() but is
+* not part of kernel_text_address().
+*
+* Skipping built-in __exit is fine since it
+* will never be executed.
+*/
WARN_ONCE(!jump_entry_is_init(entry),
  "can't patch jump_label at %pS",
  (void *)jump_entry_code(entry));
diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
index adb935090768..622ebdfcd083 100644
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -626,7 +626,7 @@ static inline int mutex_can_spin_on_owner(struct mutex 
*lock)
  */
 static __always_inline bool
 mutex_optimistic_spin(struct mutex *lock, struct ww_acquire_ctx *ww_ctx,
- const bool use_ww_ctx, struct mutex_waiter *waiter)
+ struct mutex_waiter *waiter)
 {
if (!waiter) {
/*
@@ -702,7 +702,7 @@ mutex_optimistic_spin(struct mutex *lock, struct 
ww_acquire_ctx *ww_ctx,
 #else
 static __always_inline bool
 mutex_optimistic_spin(struct mutex *lock, struct ww_acquire_ctx *ww_ctx,
- const bool use_ww_ctx, struct mutex_waiter *waiter)
+ struct mutex_waiter *waiter)
 {
return false;
 }
@@ -922,6 +922,9 @@ __mutex_lock_common(struct mutex *lock, long state, 
unsigned int subclass,
struct ww_mutex *ww;
int ret;
 
+   if (!use_ww_ctx)
+   ww_ctx = NULL;
+
might_sleep();
 
 #ifdef CONFIG_DEBUG_MUTEXES
@@ -929,7 +932,7 @@ __mutex_lock_common(struct mutex *lock, long state, 
unsigned int subclass,
 #endif
 
ww = container_of(lock, struct ww_mutex, base);
-   if (use_ww_ctx && ww_ctx) {
+   if (ww_ctx) {
if (unlikely(ww_ctx == READ_ONCE(ww->ctx)))
return -EALREADY;
 
@@ -946,10 +949,10 @@ __mutex_lock_common(struct mutex *lock, long state, 
unsigned int subclass,
mutex_acquire_nest(&lock->dep_map, subclass, 0, nest_lock, ip);
 
if (__mutex_trylock(lock) ||
-   mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx, NULL)) {
+   mutex_optimistic_spin(lock, ww_ctx, NULL)) {
/* got the lock, yay! */
lock_acquired(&lock->dep_map, ip);
-   if (use_ww_ctx && ww_ctx)
+   if (ww_ctx)
ww_mutex_set_context_fastpath(ww, ww_ctx);
preempt_enable();
return 0;
@@ -960,7 +963,7 @@ __mutex_lock_common(struct mutex *lock, long state, 
unsigned int subclass,
 * After waiting to acquire the wait_lock, try again.
 */
if (__mutex_trylock(lock)) {
-   if (use_ww_ctx && ww_ctx)
+   if (ww_ctx)
__ww_mutex_check_waiters(lock, ww_ctx);
 
goto skip_wait;
@@ -1013,7 +1016,7 @@ __mutex_lock_common(struct mutex *lock, long state, 
unsigned int subclass,

Re: [PATCH v4 02/28] mm: Add an unlock function for PG_private_2/PG_fscache

2021-03-21 Thread Matthew Wilcox
On Wed, Mar 10, 2021 at 04:54:49PM +, David Howells wrote:
> Add a function, unlock_page_private_2(), to unlock PG_private_2 analogous
> to that of PG_lock.  Add a kerneldoc banner to that indicating the example
> usage case.

One of the things which confused me about this was ... where's the other
side?  Where's lock_page_private_2()?  Then I found this:

#ifdef CONFIG_AFS_FSCACHE
if (PageFsCache(page) &&
wait_on_page_bit_killable(page, PG_fscache) < 0)
return VM_FAULT_RETRY;
#endif

Please respect the comment!

/*
 * This is exported only for wait_on_page_locked/wait_on_page_writeback, etc.,
 * and should not be used directly.
 */
extern void wait_on_page_bit(struct page *page, int bit_nr);
extern int wait_on_page_bit_killable(struct page *page, int bit_nr);

I think we need the exported API to be wait_on_page_private_2(), and
AFS needs to not tinker in the guts of filemap.  Otherwise you miss
out on bugfixes like c2407cf7d22d0c0d94cf20342b3b8f06f1d904e7 (see also
https://lore.kernel.org/linux-fsdevel/20210320054104.1300774-4-wi...@infradead.org/T/#u
).

That also brings up that there is no set_page_private_2().  I think
that's OK -- you only set PageFsCache() immediately after reading the
page from the server.  But I feel this "unlock_page_private_2" is actually
"clear_page_private_2" -- ie it's equivalent to writeback, not to lock.

> +++ b/mm/filemap.c
> @@ -1432,6 +1432,26 @@ void unlock_page(struct page *page)
>  }
>  EXPORT_SYMBOL(unlock_page);
>  
> +/**
> + * unlock_page_private_2 - Unlock a page that's locked with PG_private_2
> + * @page: The page
> + *
> + * Unlocks a page that's locked with PG_private_2 and wakes up sleepers in
> + * wait_on_page_private_2().
> + *
> + * This is, for example, used when a netfs page is being written to a local
> + * disk cache, thereby allowing writes to the cache for the same page to be
> + * serialised.
> + */
> +void unlock_page_private_2(struct page *page)
> +{
> + page = compound_head(page);
> + VM_BUG_ON_PAGE(!PagePrivate2(page), page);
> + clear_bit_unlock(PG_private_2, &page->flags);
> + wake_up_page_bit(page, PG_private_2);
> +}
> +EXPORT_SYMBOL(unlock_page_private_2);
> +
>  /**


[GIT PULL] perf fixes

2021-03-21 Thread Ingo Molnar
Linus,

Please pull the latest perf/urgent git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
perf-urgent-2021-03-21

   # HEAD: 2dc0572f2cef87425147658698dce2600b799bd3 perf/x86/intel: Fix 
unchecked MSR access error caused by VLBR_EVENT

Boundary condition fixes for bugs unearthed by the perf fuzzer.

 Thanks,

Ingo

-->
Kan Liang (2):
  perf/x86/intel: Fix a crash caused by zero PEBS status
  perf/x86/intel: Fix unchecked MSR access error caused by VLBR_EVENT


 arch/x86/events/intel/core.c | 3 +++
 arch/x86/events/intel/ds.c   | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 7bbb5bb98d8c..37ce38403cb8 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3659,6 +3659,9 @@ static int intel_pmu_hw_config(struct perf_event *event)
return ret;
 
if (event->attr.precise_ip) {
+   if ((event->attr.config & INTEL_ARCH_EVENT_MASK) == 
INTEL_FIXED_VLBR_EVENT)
+   return -EINVAL;
+
if (!(event->attr.freq || (event->attr.wakeup_events && 
!event->attr.watermark))) {
event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD;
if (!(event->attr.sample_type &
diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
index 7ebae1826403..d32b302719fe 100644
--- a/arch/x86/events/intel/ds.c
+++ b/arch/x86/events/intel/ds.c
@@ -2010,7 +2010,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs 
*iregs, struct perf_sample_d
 */
if (!pebs_status && cpuc->pebs_enabled &&
!(cpuc->pebs_enabled & (cpuc->pebs_enabled-1)))
-   pebs_status = cpuc->pebs_enabled;
+   pebs_status = p->status = cpuc->pebs_enabled;
 
bit = find_first_bit((unsigned long *)&pebs_status,
x86_pmu.max_pebs_events);


[GIT PULL] x86/urgent for v5.12-rc4

2021-03-21 Thread Borislav Petkov
Hi Linus,

please pull the freshest pile of shiny x86/urgent fixes for 5.12.

Thx.

---

The following changes since commit 1e28eed17697bcf343c6743f0028cc3b5dd88bf0:

  Linux 5.12-rc3 (2021-03-14 14:41:02 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
tags/x86_urgent_for_v5.12-rc4

for you to fetch changes up to dd926880da8dbbe409e709c1d3c1620729a94732:

  x86/apic/of: Fix CPU devicetree-node lookups (2021-03-19 23:01:49 +0100)


- Add the arch-specific mapping between physical and logical CPUs to fix
devicetree-node lookups.

- Restore the IRQ2 ignore logic

- Fix get_nr_restart_syscall() to return the correct restart syscall number.
Split in a 4-patches set to avoid kABI breakage when backporting to dead
kernels.


Johan Hovold (1):
  x86/apic/of: Fix CPU devicetree-node lookups

Oleg Nesterov (4):
  kernel, fs: Introduce and use set_restart_fn() and arch_set_restart_data()
  x86: Move TS_COMPAT back to asm/thread_info.h
  x86: Introduce TS_COMPAT_RESTART to fix get_nr_restart_syscall()
  x86: Introduce restart_block->arch_data to remove TS_COMPAT_RESTART

Thomas Gleixner (1):
  x86/ioapic: Ignore IRQ2 again

 arch/x86/include/asm/processor.h   |  9 -
 arch/x86/include/asm/thread_info.h | 15 ++-
 arch/x86/kernel/apic/apic.c|  5 +
 arch/x86/kernel/apic/io_apic.c | 10 ++
 arch/x86/kernel/signal.c   | 24 +---
 fs/select.c| 10 --
 include/linux/restart_block.h  |  1 +
 include/linux/thread_info.h| 13 +
 kernel/futex.c |  3 +--
 kernel/time/alarmtimer.c   |  2 +-
 kernel/time/hrtimer.c  |  2 +-
 kernel/time/posix-cpu-timers.c |  2 +-
 12 files changed, 52 insertions(+), 44 deletions(-)

-- 
Regards/Gruss,
Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG 
Nürnberg


Re: [RFC PATCH v2 00/11] bfq: introduce bfq.ioprio for cgroup

2021-03-21 Thread Paolo Valente



> Il giorno 12 mar 2021, alle ore 12:08, brookxu  ha 
> scritto:
> 
> From: Chunguang Xu 
> 

Hi Chunguang,

> Tasks in the production environment can be roughly divided into
> three categories: emergency tasks, ordinary tasks and offline
> tasks. Emergency tasks need to be scheduled in real time, such
> as system agents. Offline tasks do not need to guarantee QoS,
> but can improve system resource utilization during system idle
> periods, such as background tasks. The above requirements need
> to achieve IO preemption. At present, we can use weights to
> simulate IO preemption, but since weights are more of a shared
> concept, they cannot be simulated well. For example, the weights
> of emergency tasks and ordinary tasks cannot be determined well,
> offline tasks (with the same weight) actually occupy different
> resources on disks with different performance, and the tail
> latency caused by offline tasks cannot be well controlled. Using
> ioprio's concept of preemption, we can solve the above problems
> very well. Since ioprio will eventually be converted to weight,
> using ioprio alone can also achieve weight isolation within the
> same class. But we can still use bfq.weight to control resource,
> achieving better IO Qos control.
> 
> However, currently the class of bfq_group is always be class, and
> the ioprio class of the task can only be reflected in a single
> cgroup. We cannot guarantee that real-time tasks in a cgroup are
> scheduled in time. Therefore, we introduce bfq.ioprio, which
> allows us to configure ioprio class for cgroup. In this way, we
> can ensure that the real-time tasks of a cgroup can be scheduled
> in time. Similarly, the processing of offline task groups can
> also be simpler.
> 

I find this contribution very interesting.  Anyway, given the
relevance of such a contribution, I'd like to hear from relevant
people (Jens, Tejun, ...?), before revising individual patches.

Yet I already have a general question.  How does this mechanism comply
with per-process ioprios and ioprio classes?  For example, what
happens if a process belongs to BE-class group according to your
mechanism, but to a RT class according to its ioprio?  Does the
pre-group class dominate the per-process class?  Is all clean and
predictable?

> The bfq.ioprio interface now is available for cgroup v1 and cgroup
> v2. Users can configure the ioprio for cgroup through this interface,
> as shown below:
> 
> echo "1 2"> blkio.bfq.ioprio

Wouldn't it be nicer to have acronyms for classes (RT, BE, IDLE),
instead of numbers?

Thank you very much for this improvement proposal,
Paolo

> 
> The above two values respectively represent the values of ioprio
> class and ioprio for cgroup. The ioprio of tasks within the cgroup
> is uniformly equal to the ioprio of the cgroup. If the ioprio of
> the cgroup is disabled, the ioprio of the task remains the same,
> usually from io_context.
> 
> When testing, using fio and fio_generate_plots we can clearly see
> that the IO delay of the task satisfies RT> BE> IDLE. When RT is
> running, BE and IDLE are guaranteed minimum bandwidth. When used
> with bfq.weight, we can also isolate the resource within the same
> class.
> 
> The test process is as follows:
> # prepare data disk
> mount /dev/sdb /data1
> 
> # create cgroup v1 hierarchy
> cd /sys/fs/cgroup/blkio
> mkdir rt be idle
> echo "1 0" > rt/blkio.bfq.ioprio
> echo "2 0" > be/blkio.bfq.ioprio
> echo "3 0" > idle/blkio.bfq.ioprio
> 
> # run fio test
> fio fio.ini
> 
> # generate svg graph
> fio_generate_plots res
> 
> The contents of fio.ini are as follows:
> [global]
> ioengine=libaio
> group_reporting=1
> log_avg_msec=500
> direct=1
> time_based=1
> iodepth=16
> size=100M
> rw=write
> bs=1M
> [rt]
> name=rt
> write_bw_log=rt
> write_lat_log=rt
> write_iops_log=rt
> filename=/data1/rt.bin
> cgroup=rt
> runtime=30s
> nice=-10
> [be]
> name=be
> new_group
> write_bw_log=be
> write_lat_log=be
> write_iops_log=be
> filename=/data1/be.bin
> cgroup=be
> runtime=60s
> [idle]
> name=idle
> new_group
> write_bw_log=idle
> write_lat_log=idle
> write_iops_log=idle
> filename=/data1/idle.bin
> cgroup=idle
> runtime=90s
> 
> V2:
> 1. Optmise bfq_select_next_class().
> 2. Introduce bfq_group [] to track the number of groups for each CLASS.
> 3. Optimse IO injection, EMQ and Idle mechanism for CLASS_RT.
> 
> Chunguang Xu (11):
>  bfq: introduce bfq_entity_to_bfqg helper method
>  bfq: limit the IO depth of idle_class to 1
>  bfq: keep the minimun bandwidth for be_class
>  bfq: expire other class if CLASS_RT is waiting
>  bfq: optimse IO injection for CLASS_RT
>  bfq: disallow idle if CLASS_RT waiting for service
>  bfq: disallow merge CLASS_RT with other class
>  bfq: introduce bfq.ioprio for cgroup
>  bfq: convert the type of bfq_group.bfqd to bfq_data*
>  bfq: remove unnecessary initialization logic
>  bfq: optimize the calculation of bfq_weight_to_ioprio()
> 
> block/bfq-cgroup.c  |  99 +++
> block/bfq-iosched.

[tip: perf/urgent] lockdep: Add a missing initialization hint to the "INFO: Trying to register non-static key" message

2021-03-21 Thread tip-bot2 for Tetsuo Handa
The following commit has been merged into the perf/urgent branch of tip:

Commit-ID: 3a85969e9d912d5dd85362ee37b5f81266e00e77
Gitweb:
https://git.kernel.org/tip/3a85969e9d912d5dd85362ee37b5f81266e00e77
Author:Tetsuo Handa 
AuthorDate:Sun, 21 Mar 2021 15:49:13 +09:00
Committer: Ingo Molnar 
CommitterDate: Sun, 21 Mar 2021 11:59:57 +01:00

lockdep: Add a missing initialization hint to the "INFO: Trying to register 
non-static key" message

Since this message is printed when dynamically allocated spinlocks (e.g.
kzalloc()) are used without initialization (e.g. spin_lock_init()),
suggest to developers to check whether initialization functions for objects
were called, before making developers wonder what annotation is missing.

[ mingo: Minor tweaks to the message. ]

Signed-off-by: Tetsuo Handa 
Signed-off-by: Ingo Molnar 
Link: 
https://lore.kernel.org/r/20210321064913.4619-1-penguin-ker...@i-love.sakura.ne.jp
Signed-off-by: Ingo Molnar 
---
 kernel/locking/lockdep.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index c6d0c1d..c30eb88 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -930,7 +930,8 @@ static bool assign_lock_key(struct lockdep_map *lock)
/* Debug-check: all keys must be persistent! */
debug_locks_off();
pr_err("INFO: trying to register non-static key.\n");
-   pr_err("the code is fine but needs lockdep annotation.\n");
+   pr_err("The code is fine but needs lockdep annotation, or 
maybe\n");
+   pr_err("you didn't initialize this object before use?\n");
pr_err("turning off the locking correctness validator.\n");
dump_stack();
return false;


Re: [PATCH v1 2/2] iio: temperature: add driver support for ti tmp117

2021-03-21 Thread Andy Shevchenko
(Seems it didn't make mailing list)

On Sat, Mar 20, 2021 at 10:55 PM Andy Shevchenko
 wrote:
>
>
>
> On Saturday, March 20, 2021, Puranjay Mohan  wrote:
>>
>> TMP117 is a Digital temperature sensor with integrated NV memory.
>>
>> Add support for tmp117 driver in iio subsystem.
>>
>> Datasheet:-https://www.ti.com/lit/gpn/tmp117
>>
>
> No blank line is needed here
>
>
>>
>> Signed-off-by: Puranjay Mohan 
>> ---
>>  drivers/iio/temperature/Kconfig  |  10 ++
>>  drivers/iio/temperature/Makefile |   1 +
>>  drivers/iio/temperature/tmp117.c | 182 +++
>>  3 files changed, 193 insertions(+)
>>  create mode 100644 drivers/iio/temperature/tmp117.c
>>
>> diff --git a/drivers/iio/temperature/Kconfig 
>> b/drivers/iio/temperature/Kconfig
>> index f1f2a1499..c5482983f 100644
>> --- a/drivers/iio/temperature/Kconfig
>> +++ b/drivers/iio/temperature/Kconfig
>> @@ -97,6 +97,16 @@ config TMP007
>>   This driver can also be built as a module. If so, the module will
>>   be called tmp007.
>>
>> +config TMP117
>> +   tristate "TMP117 Digital temperature sensor with integrated NV 
>> memory"
>> +   depends on I2C
>> +   help
>> + If you say yes here you get support for the Texas Instruments
>> + TMP117 Digital temperature sensor with integrated NV memory.
>> +
>> + This driver can also be built as a module. If so, the module will
>> + be called tmp117.
>> +
>>  config TSYS01
>> tristate "Measurement Specialties TSYS01 temperature sensor using 
>> I2C bus connection"
>> depends on I2C
>> diff --git a/drivers/iio/temperature/Makefile 
>> b/drivers/iio/temperature/Makefile
>> index 90c113115..e3392c4b2 100644
>> --- a/drivers/iio/temperature/Makefile
>> +++ b/drivers/iio/temperature/Makefile
>> @@ -12,5 +12,6 @@ obj-$(CONFIG_MLX90614) += mlx90614.o
>>  obj-$(CONFIG_MLX90632) += mlx90632.o
>>  obj-$(CONFIG_TMP006) += tmp006.o
>>  obj-$(CONFIG_TMP007) += tmp007.o
>> +obj-$(CONFIG_TMP117) += tmp117.o
>>  obj-$(CONFIG_TSYS01) += tsys01.o
>>  obj-$(CONFIG_TSYS02D) += tsys02d.o
>> diff --git a/drivers/iio/temperature/tmp117.c 
>> b/drivers/iio/temperature/tmp117.c
>> new file mode 100644
>> index 0..194820700
>> --- /dev/null
>> +++ b/drivers/iio/temperature/tmp117.c
>> @@ -0,0 +1,182 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * tmp117.c - Digital temperature sensor with integrated NV memory
>
>
> File name inside the file is redundant, remove it
>
>>
>> + *
>> + * Copyright (c) 2021 Puranjay Mohan 
>> + *
>> + * Driver for the Texas Instruments TMP117 Temperature Sensor
>> + *
>> + * (7-bit I2C slave address (0x48 - 0x4B), changeable via ADD pins)
>> + *
>> + * Note: This driver assumes that the sensor has been calibrated beforehand.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>
>
>>
>> +#include 
>
>
> You should use mod_devicetable.h rather than of.h.
>
>>
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>
>
> Can you consider to use constants and /or formulas from units.h?
>
>>
>> +#define TMP117_REG_TEMP0x0
>> +#define TMP117_REG_CFGR0x1
>> +#define TMP117_REG_HIGH_LIM0x2
>> +#define TMP117_REG_LOW_LIM 0x3
>> +#define TMP117_REG_EEPROM_UL   0x4
>> +#define TMP117_REG_EEPROM1 0x5
>> +#define TMP117_REG_EEPROM2 0x6
>> +#define TMP117_REG_TEMP_OFFSET 0x7
>> +#define TMP117_REG_EEPROM3 0x8
>> +#define TMP117_REG_DEVICE_ID   0xF
>> +
>> +#define TMP117_SCALE   7812500   /* in uCelsius*/
>> +#define TMP117_RESOLUTION  78125
>> +#define TMP117_DEVICE_ID   0x0117
>> +
>> +struct tmp117_data {
>> +   struct i2c_client *client;
>> +   struct mutex lock;
>> +};
>> +
>> +static int tmp117_read_reg(struct tmp117_data *data, u8 reg)
>> +{
>> +   return i2c_smbus_read_word_swapped(data->client, reg);
>> +}
>> +
>> +static int tmp117_write_reg(struct tmp117_data *data, u8 reg, int val)
>> +{
>> +   return i2c_smbus_write_word_swapped(data->client, reg, val);
>> +}
>> +
>> +static int tmp117_read_raw(struct iio_dev *indio_dev,
>> +   struct iio_chan_spec const *channel, int *val,
>> +   int *val2, long mask)
>> +{
>> +   struct tmp117_data *data = iio_priv(indio_dev);
>> +   u16 tmp, off;
>> +
>> +   switch (mask) {
>> +   case IIO_CHAN_INFO_RAW:
>> +   tmp = tmp117_read_reg(data, TMP117_REG_TEMP);
>> +   *val = tmp;
>> +   return IIO_VAL_INT;
>> +
>> +   case IIO_CHAN_INFO_CALIBBIAS:
>> +   off = tmp117_read_reg(data, TMP117_REG_TEMP_OFFSET);
>> +   *val = ((int16_t)off * (int32_t)TMP117_RESOLUTION) / 
>> 1000;
>> +   *val2 = ((int16_t)off * (int32_t)TMP117_RESOLUTION) % 
>> 1000;
>
>
> Often when you do explicit casting it means something was not well thought 
> through. 

[PATCH] perf tools: Fix various typos in comments

2021-03-21 Thread Ingo Molnar


Fix ~81 single-word typos in the perf tooling code - accumulated over the years.

Signed-off-by: Ingo Molnar 
---
 tools/perf/Documentation/perf-buildid-cache.txt |  2 +-
 tools/perf/Documentation/perf-report.txt|  2 +-
 tools/perf/Documentation/perf-top.txt   |  2 +-
 tools/perf/arch/arm/util/cs-etm.c   |  2 +-
 tools/perf/arch/arm64/util/perf_regs.c  |  2 +-
 tools/perf/arch/powerpc/util/kvm-stat.c |  2 +-
 tools/perf/arch/powerpc/util/utils_header.h |  2 +-
 tools/perf/arch/x86/tests/bp-modify.c   |  2 +-
 tools/perf/arch/x86/util/perf_regs.c|  4 ++--
 tools/perf/bench/epoll-wait.c   |  4 ++--
 tools/perf/bench/numa.c |  2 +-
 tools/perf/builtin-annotate.c   |  2 +-
 tools/perf/builtin-diff.c   |  2 +-
 tools/perf/builtin-lock.c   |  2 +-
 tools/perf/builtin-sched.c  |  2 +-
 tools/perf/builtin-script.c |  4 ++--
 tools/perf/builtin-stat.c   |  4 ++--
 tools/perf/builtin-top.c|  2 +-
 tools/perf/jvmti/jvmti_agent.c  |  4 ++--
 tools/perf/scripts/python/netdev-times.py   |  2 +-
 tools/perf/tests/bp_signal.c|  4 ++--
 tools/perf/tests/code-reading.c |  2 +-
 tools/perf/tests/hists_cumulate.c   |  4 ++--
 tools/perf/tests/parse-metric.c |  2 +-
 tools/perf/tests/topology.c |  2 +-
 tools/perf/trace/beauty/include/linux/socket.h  |  2 +-
 tools/perf/ui/browsers/annotate.c   |  2 +-
 tools/perf/ui/browsers/hists.c  |  2 +-
 tools/perf/util/call-path.h |  2 +-
 tools/perf/util/callchain.c |  2 +-
 tools/perf/util/cs-etm-decoder/cs-etm-decoder.c |  2 +-
 tools/perf/util/cs-etm.c|  8 
 tools/perf/util/cs-etm.h|  2 +-
 tools/perf/util/data-convert-bt.c   |  2 +-
 tools/perf/util/demangle-java.c |  2 +-
 tools/perf/util/dwarf-aux.c |  6 +++---
 tools/perf/util/dwarf-aux.h |  2 +-
 tools/perf/util/events_stats.h  |  2 +-
 tools/perf/util/evlist.c|  2 +-
 tools/perf/util/evsel.c |  2 +-
 tools/perf/util/expr.h  |  2 +-
 tools/perf/util/header.c|  2 +-
 tools/perf/util/levenshtein.c   |  2 +-
 tools/perf/util/libunwind/arm64.c   |  2 +-
 tools/perf/util/libunwind/x86_32.c  |  2 +-
 tools/perf/util/llvm-utils.c|  2 +-
 tools/perf/util/machine.c   |  6 +++---
 tools/perf/util/mem-events.h|  2 +-
 tools/perf/util/metricgroup.c   |  2 +-
 tools/perf/util/parse-events.c  |  6 +++---
 tools/perf/util/pmu.c   |  2 +-
 tools/perf/util/probe-event.c   |  4 ++--
 tools/perf/util/probe-finder.c  |  4 ++--
 tools/perf/util/s390-cpumsf.c   | 10 +-
 tools/perf/util/session.c   |  2 +-
 tools/perf/util/symbol-elf.c|  2 +-
 tools/perf/util/synthetic-events.c  |  4 ++--
 tools/perf/util/unwind-libunwind-local.c|  2 +-
 58 files changed, 81 insertions(+), 81 deletions(-)

diff --git a/tools/perf/Documentation/perf-buildid-cache.txt 
b/tools/perf/Documentation/perf-buildid-cache.txt
index bb167e32a1d7..cd8ce6e8ec12 100644
--- a/tools/perf/Documentation/perf-buildid-cache.txt
+++ b/tools/perf/Documentation/perf-buildid-cache.txt
@@ -57,7 +57,7 @@ OPTIONS
 -u::
 --update=::
Update specified file of the cache. Note that this doesn't remove
-   older entires since those may be still needed for annotating old
+   older entries since those may be still needed for annotating old
(or remote) perf.data. Only if there is already a cache which has
exactly same build-id, that is replaced by new one. It can be used
to update kallsyms and kernel dso to vmlinux in order to support
diff --git a/tools/perf/Documentation/perf-report.txt 
b/tools/perf/Documentation/perf-report.txt
index f546b5e9db05..d2d2a8d8f8f5 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -472,7 +472,7 @@ OPTIONS
but probably we'll make the default not to show the switch-on/off events
 on the --group mode and if there is only one event besides the off/on 
ones,
go straight to the histogram browser, just like 'perf report' with no 
events
-   explicitely specified does.
+   explicitly specified does.
 
 --itrace::
Options for decoding instruction tracing data. The options are:
diff --git a/tools/perf/Documentation/perf-top.txt 
b/tools/

[GIT PULL] IRQ updates & fixes

2021-03-21 Thread Ingo Molnar
Linus,

Please pull the latest irq/urgent git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
irq-urgent-2021-03-21

   # HEAD: 81e2073c175b887398e5bca6c004efa89983f58d genirq: Disable interrupts 
for force threaded handlers

A change to robustify force-threaded IRQ handlers to always disable interrupts,
plus a DocBook fix.

[ Note: the force-threaded IRQ handler change has been accelerated 
  from the normal schedule of such a change to keep the bad 
  pattern/workaround of spin_lock_irqsave() in handlers or 
  IRQF_NOTHREAD as a kludge from spreading. ]

 Thanks,

Ingo

-->
Andy Shevchenko (1):
  genirq/irq_sim: Fix typos in kernel doc (fnode -> fwnode)

Thomas Gleixner (1):
  genirq: Disable interrupts for force threaded handlers


 kernel/irq/irq_sim.c | 4 ++--
 kernel/irq/manage.c  | 4 
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c
index 48006608baf0..40880c350b95 100644
--- a/kernel/irq/irq_sim.c
+++ b/kernel/irq/irq_sim.c
@@ -159,7 +159,7 @@ static const struct irq_domain_ops irq_sim_domain_ops = {
  * irq_domain_create_sim - Create a new interrupt simulator irq_domain and
  * allocate a range of dummy interrupts.
  *
- * @fnode:  struct fwnode_handle to be associated with this domain.
+ * @fwnode: struct fwnode_handle to be associated with this domain.
  * @num_irqs:   Number of interrupts to allocate.
  *
  * On success: return a new irq_domain object.
@@ -228,7 +228,7 @@ static void devm_irq_domain_release_sim(struct device *dev, 
void *res)
  *  a managed device.
  *
  * @dev:Device to initialize the simulator object for.
- * @fnode:  struct fwnode_handle to be associated with this domain.
+ * @fwnode: struct fwnode_handle to be associated with this domain.
  * @num_irqs:   Number of interrupts to allocate
  *
  * On success: return a new irq_domain object.
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index dec3f73e8db9..21ea370fccda 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1142,11 +1142,15 @@ irq_forced_thread_fn(struct irq_desc *desc, struct 
irqaction *action)
irqreturn_t ret;
 
local_bh_disable();
+   if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+   local_irq_disable();
ret = action->thread_fn(action->irq, action->dev_id);
if (ret == IRQ_HANDLED)
atomic_inc(&desc->threads_handled);
 
irq_finalize_oneshot(desc, action);
+   if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+   local_irq_enable();
local_bh_enable();
return ret;
 }


Re: arm64 syzbot instances

2021-03-21 Thread Arnd Bergmann
On Sat, Mar 20, 2021 at 9:43 PM Peter Maydell  wrote:
>
> On Fri, 12 Mar 2021 at 09:16, Arnd Bergmann  wrote:
> > So it's probably qemu that triggers the 'synchronous external
> > abort' when accessing the PCI I/O space, which in turn hints
> > towards a bug in qemu. Presumably it only returns data from
> > I/O ports that are actually mapped to a device when real hardware
> > is supposed to return 0x when reading from unused I/O ports.
>
> Do you have a reference to the bit of the PCI spec that mandates
> this -1/discard behaviour for attempted access to places where
> there isn't actually a PCI device mapped ? The spec is pretty
> long and hard to read...
>
> (Knowing to what extent this behaviour is mandatory for all
> PCI systems/host controllers vs just "it would be nice if the
> gpex host controller worked this way" would help in figuring
> out where in QEMU to change.)

Sorry, I don't. I can probably find something in there myself,
but in the end it comes down to Linux drivers relying on this
behavior for ISA devices since the start. On an old-style x86
PC, this is the only method for finding out if a device is present
or not, since there is no description in the firmware that lists them.

PCIe devices remain backwards compatible with the old ISA
bus, so the old behavior must generally be kept possible.
I don't think a specification for the ISA bus exists at all, and
I found nothing in the related LPC specification about reading
from an unknown device.

https://tldp.org/HOWTO/Plug-and-Play-HOWTO-6.html#ss6.12
states the behavior of the ISA I/O ports and how Linux drivers rely
on that. Is that enough for you?

  Arnd


Re: arm64 syzbot instances

2021-03-21 Thread Arnd Bergmann
On Sun, Mar 21, 2021 at 12:52 PM Arnd Bergmann  wrote:
> On Sat, Mar 20, 2021 at 9:43 PM Peter Maydell  
> wrote:

> https://tldp.org/HOWTO/Plug-and-Play-HOWTO-6.html#ss6.12
> states the behavior of the ISA I/O ports and how Linux drivers rely
> on that. Is that enough for you?

Actually it only mentions it very indirectly, by saying that if a present
device has 0xFF in a register, the detection may fail since it looks like
a missing device.

 Arnd


Re: [PATCH v6 1/5] dt-bindings:drm/bridge:anx7625:add vendor define flags

2021-03-21 Thread Laurent Pinchart
Hi Xin,

Thank you for the patch.

On Fri, Mar 19, 2021 at 02:32:39PM +0800, Xin Ji wrote:
> Add 'bus-type' and 'data-lanes' define for port0. Define DP tx lane0,
> lane1 swing register array define, and audio enable flag.
> 
> Signed-off-by: Xin Ji 
> ---
>  .../display/bridge/analogix,anx7625.yaml  | 58 ++-
>  1 file changed, 57 insertions(+), 1 deletion(-)
> 
> diff --git 
> a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
> b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> index c789784efe30..3f54d5876982 100644
> --- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> +++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> @@ -34,6 +34,26 @@ properties:
>  description: used for reset chip control, RESET_N pin B7.
>  maxItems: 1
>  
> +  analogix,lane0-swing:
> +$ref: /schemas/types.yaml#/definitions/uint32-array
> +minItems: 1
> +maxItems: 20
> +description:
> +  an array of swing register setting for DP tx lane0 PHY, please don't
> +  add this property, or contact vendor.

DT properties need to be documented. Contacting the vendor doesn't count
as documentation I'm afraid.

> +
> +  analogix,lane1-swing:
> +$ref: /schemas/types.yaml#/definitions/uint32-array
> +minItems: 1
> +maxItems: 20
> +description:
> +  an array of swing register setting for DP tx lane1 PHY, please don't
> +  add this property, or contact vendor.
> +
> +  analogix,audio-enable:
> +type: boolean
> +description: let the driver enable audio HDMI codec function or not.
> +
>ports:
>  $ref: /schemas/graph.yaml#/properties/ports
>  
> @@ -41,13 +61,43 @@ properties:
>port@0:
>  $ref: /schemas/graph.yaml#/properties/port
>  description:
> -  Video port for MIPI DSI input.
> +  MIPI DSI/DPI input.
> +
> +properties:
> +  endpoint:
> +$ref: /schemas/media/video-interfaces.yaml#
> +type: object
> +additionalProperties: false
> +
> +properties:
> +  remote-endpoint: true
> +  bus-type: true
> +  data-lanes: true
> +
> +required:
> +  - remote-endpoint
> +
> +required:
> +  - endpoint
> +
>  
>port@1:
>  $ref: /schemas/graph.yaml#/properties/port
>  description:
>Video port for panel or connector.
>  
> +properties:
> +  endpoint:
> +$ref: /schemas/media/video-interfaces.yaml#
> +type: object
> +additionalProperties: false
> +
> +properties:
> +  remote-endpoint: true
> +
> +required:
> +  - remote-endpoint
> +
>  required:
>- port@0
>- port@1
> @@ -73,6 +123,10 @@ examples:
>  enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
>  reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
>  
> +analogix,audio-enable;
> +analogix,lane0-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 0x5b>;
> +analogix,lane1-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 0x5b>;
> +
>  ports {
>  #address-cells = <1>;
>  #size-cells = <0>;
> @@ -81,6 +135,8 @@ examples:
>  reg = <0>;
>  anx7625_in: endpoint {
>  remote-endpoint = <&mipi_dsi>;
> +bus-type = <5>;
> +data-lanes = <0 1 2 3>;
>  };
>  };
>  

-- 
Regards,

Laurent Pinchart


Re: [syzbot] KASAN: use-after-free Read in firmware_fallback_sysfs

2021-03-21 Thread syzbot
syzbot has found a reproducer for the following issue on:

HEAD commit:a1e6f641 Revert "net: dsa: sja1105: Clear VLAN filtering o..
git tree:   net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1637614ed0
kernel config:  https://syzkaller.appspot.com/x/.config?x=c2371621441fef8b
dashboard link: https://syzkaller.appspot.com/bug?extid=de271708674e2093097b
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=17bc70bed0
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=148b5fe6d0

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+de271708674e20930...@syzkaller.appspotmail.com

platform regulatory.0: Falling back to sysfs fallback for: regulatory.db
==
BUG: KASAN: use-after-free in __list_add_valid+0x81/0xa0 lib/list_debug.c:23
Read of size 8 at addr 888034b802c8 by task syz-executor067/9770

CPU: 0 PID: 9770 Comm: syz-executor067 Not tainted 5.12.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x141/0x1d7 lib/dump_stack.c:120
 print_address_description.constprop.0.cold+0x5b/0x2f8 mm/kasan/report.c:232
 __kasan_report mm/kasan/report.c:399 [inline]
 kasan_report.cold+0x7c/0xd8 mm/kasan/report.c:416
 __list_add_valid+0x81/0xa0 lib/list_debug.c:23
 __list_add include/linux/list.h:67 [inline]
 list_add include/linux/list.h:86 [inline]
 fw_load_sysfs_fallback drivers/base/firmware_loader/fallback.c:516 [inline]
 fw_load_from_user_helper drivers/base/firmware_loader/fallback.c:581 [inline]
 firmware_fallback_sysfs+0x455/0xe20 drivers/base/firmware_loader/fallback.c:657
 _request_firmware+0xa80/0xe80 drivers/base/firmware_loader/main.c:831
 request_firmware+0x32/0x50 drivers/base/firmware_loader/main.c:875
 reg_reload_regdb+0x7a/0x240 net/wireless/reg.c:1095
 genl_family_rcv_msg_doit+0x228/0x320 net/netlink/genetlink.c:739
 genl_family_rcv_msg net/netlink/genetlink.c:783 [inline]
 genl_rcv_msg+0x328/0x580 net/netlink/genetlink.c:800
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2502
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:811
 netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1338
 netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1927
 sock_sendmsg_nosec net/socket.c:654 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:674
 sys_sendmsg+0x6e8/0x810 net/socket.c:2350
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2404
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2433
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x4499f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 01 16 00 00 90 48 89 f8 48 89 f7 48 
89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 
c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:7f657d03e318 EFLAGS: 0246 ORIG_RAX: 002e
RAX: ffda RBX: 004d5288 RCX: 004499f9
RDX:  RSI: 23c0 RDI: 0003
RBP: 004d5280 R08:  R09: 
R10:  R11: 0246 R12: 0031313230386c6e
R13: 7ffd24e61cff R14: 7f657d03e400 R15: 00022000

Allocated by task 9764:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:427 [inline]
 kasan_kmalloc mm/kasan/common.c:506 [inline]
 kasan_kmalloc mm/kasan/common.c:465 [inline]
 __kasan_kmalloc+0x99/0xc0 mm/kasan/common.c:515
 kmalloc include/linux/slab.h:554 [inline]
 kzalloc include/linux/slab.h:684 [inline]
 __allocate_fw_priv drivers/base/firmware_loader/main.c:186 [inline]
 alloc_lookup_fw_priv drivers/base/firmware_loader/main.c:250 [inline]
 _request_firmware_prepare drivers/base/firmware_loader/main.c:744 [inline]
 _request_firmware+0x2de/0xe80 drivers/base/firmware_loader/main.c:806
 request_firmware+0x32/0x50 drivers/base/firmware_loader/main.c:875
 reg_reload_regdb+0x7a/0x240 net/wireless/reg.c:1095
 genl_family_rcv_msg_doit+0x228/0x320 net/netlink/genetlink.c:739
 genl_family_rcv_msg net/netlink/genetlink.c:783 [inline]
 genl_rcv_msg+0x328/0x580 net/netlink/genetlink.c:800
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2502
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:811
 netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1338
 netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1927
 sock_sendmsg_nosec net/socket.c:654 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:674
 sys_sendmsg+0x6e8/0x810 net/socket.c:2350
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2404
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2433
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 9764:
 kas

Re: [PATCH v2 02/14] x86/alternatives: Optimize optimize_nops()

2021-03-21 Thread Borislav Petkov
On Thu, Mar 18, 2021 at 06:11:05PM +0100, Peter Zijlstra wrote:
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -345,19 +345,39 @@ recompute_jump(struct alt_instr *a, u8 *
>  static void __init_or_module noinline optimize_nops(struct alt_instr *a, u8 
> *instr)
>  {
>   unsigned long flags;
> - int i;
> + int nops = 0, i = 0;
> + struct insn insn;
> + u8 *nop = NULL;
>  
> - for (i = 0; i < a->padlen; i++) {
> - if (instr[i] != 0x90)
> + do {
> + if (insn_decode_kernel(&insn, &instr[i]))
>   return;
> - }
>  
> - local_irq_save(flags);
> - add_nops(instr + (a->instrlen - a->padlen), a->padlen);
> - local_irq_restore(flags);
> + if (insn.length == 1 && insn.opcode.bytes[0] == 0x90) {
> + if (!nop) {
> + nop = &instr[i];
> + nops = 1;
> + } else {
> + nops++;
> + }
> + }
> + i += insn.length;
> +
> + if ((insn.length != 1 || i == a->instrlen) && nop) {
> +
> + local_irq_save(flags);
> + add_nops(nop, nops);
> + local_irq_restore(flags);
> +
> + DUMP_BYTES(instr, a->instrlen, "%px: [%d:%d) optimized 
> NOPs: ",
> +instr, (int)(unsigned long)(nop-instr), 
> nops);
> +
> + nop = NULL;
> + }
>  
> - DUMP_BYTES(instr, a->instrlen, "%px: [%d:%d) optimized NOPs: ",
> -instr, a->instrlen - a->padlen, a->padlen);
> + } while (i < a->instrlen);
> +
> + WARN_ON_ONCE(nop);
>  }

I think I've made this simpler; pasting the whole function and not the
diff because former is easier to read:

/*
 * "noinline" to cause control flow change and thus invalidate I$ and
 * cause refetch after modification.
 *
 * Jump over the non-NOP insns, the remaining bytes must be single-byte NOPs,
 * optimize them.
 */
static void __init_or_module noinline optimize_nops(struct alt_instr *a, u8 
*instr)
{
unsigned long flags;
struct insn insn;
int i = 0, j;

/* Skip preceding non-NOP instructions. */
do {
if (insn_decode_kernel(&insn, &instr[i]))
return;

if (insn.length == 1 && insn.opcode.bytes[0] == 0x90)
break;

i += insn.length;

} while (i < a->instrlen);

if (i >= a->instrlen - 1)
return;

/* Verify rest is NOPs - should not fire(tm) */
for (j = i; j < a->instrlen - 1; j++) {
if (WARN(instr[j] != 0x90, "Wrong insn byte 0x%hx at 0x%px\n",
 instr[j], &instr[j]))
return;
}

local_irq_save(flags);
add_nops(&instr[i], a->instrlen - i);
local_irq_restore(flags);

DUMP_BYTES(instr, a->instrlen, "%px: [%d:%d) optimized NOPs: ",
   instr, i, a->instrlen);
}

-- 
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette


[PATCH] crypto: amcc: fix incorrect kernel-doc comment syntax in files

2021-03-21 Thread Aditya Srivastava
The opening comment mark '/**' is used for highlighting the beginning of
kernel-doc comments.
There are certain files in drivers/crypto/amcc, which follow this syntax,
but the content inside does not comply with kernel-doc.
Such lines were probably not meant for kernel-doc parsing, but are parsed
due to the presence of kernel-doc like comment syntax(i.e, '/**'), which
causes unexpected warnings from kernel-doc.

E.g., presence of kernel-doc like comment in
drivers/crypto/amcc/crypto4xx_alg.c at header, and some other lines,
causes these warnings by kernel-doc:

"warning: expecting prototype for AMCC SoC PPC4xx Crypto Driver(). Prototype 
was for set_dynamic_sa_command_0() instead"
"warning: Function parameter or member 'dir' not described in 
'set_dynamic_sa_command_0'"
etc..

Provide a simple fix by replacing such occurrences with general comment
format, i.e. '/*', to prevent kernel-doc from parsing it.

Signed-off-by: Aditya Srivastava 
---
 drivers/crypto/amcc/crypto4xx_alg.c | 12 ++--
 drivers/crypto/amcc/crypto4xx_core.c| 18 +-
 drivers/crypto/amcc/crypto4xx_core.h|  4 ++--
 drivers/crypto/amcc/crypto4xx_reg_def.h |  8 
 drivers/crypto/amcc/crypto4xx_sa.h  | 18 +-
 drivers/crypto/amcc/crypto4xx_trng.h|  2 +-
 6 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/drivers/crypto/amcc/crypto4xx_alg.c 
b/drivers/crypto/amcc/crypto4xx_alg.c
index a3fa849b139a..ded732242732 100644
--- a/drivers/crypto/amcc/crypto4xx_alg.c
+++ b/drivers/crypto/amcc/crypto4xx_alg.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
-/**
+/*
  * AMCC SoC PPC4xx Crypto Driver
  *
  * Copyright (c) 2008 Applied Micro Circuits Corporation.
@@ -115,7 +115,7 @@ int crypto4xx_decrypt_iv_block(struct skcipher_request *req)
return crypto4xx_crypt(req, AES_IV_SIZE, true, true);
 }
 
-/**
+/*
  * AES Functions
  */
 static int crypto4xx_setkey_aes(struct crypto_skcipher *cipher,
@@ -374,7 +374,7 @@ static int crypto4xx_aead_setup_fallback(struct 
crypto4xx_ctx *ctx,
return crypto_aead_setkey(ctx->sw_cipher.aead, key, keylen);
 }
 
-/**
+/*
  * AES-CCM Functions
  */
 
@@ -489,7 +489,7 @@ int crypto4xx_setauthsize_aead(struct crypto_aead *cipher,
return crypto_aead_setauthsize(ctx->sw_cipher.aead, authsize);
 }
 
-/**
+/*
  * AES-GCM Functions
  */
 
@@ -617,7 +617,7 @@ int crypto4xx_decrypt_aes_gcm(struct aead_request *req)
return crypto4xx_crypt_aes_gcm(req, true);
 }
 
-/**
+/*
  * HASH SHA1 Functions
  */
 static int crypto4xx_hash_alg_init(struct crypto_tfm *tfm,
@@ -711,7 +711,7 @@ int crypto4xx_hash_digest(struct ahash_request *req)
  ctx->sa_len, 0, NULL);
 }
 
-/**
+/*
  * SHA1 Algorithm
  */
 int crypto4xx_sha1_alg_init(struct crypto_tfm *tfm)
diff --git a/drivers/crypto/amcc/crypto4xx_core.c 
b/drivers/crypto/amcc/crypto4xx_core.c
index 8d1b918a0533..8278d98074e9 100644
--- a/drivers/crypto/amcc/crypto4xx_core.c
+++ b/drivers/crypto/amcc/crypto4xx_core.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
-/**
+/*
  * AMCC SoC PPC4xx Crypto Driver
  *
  * Copyright (c) 2008 Applied Micro Circuits Corporation.
@@ -44,7 +44,7 @@
 
 #define PPC4XX_SEC_VERSION_STR "0.5"
 
-/**
+/*
  * PPC4xx Crypto Engine Initialization Routine
  */
 static void crypto4xx_hw_init(struct crypto4xx_device *dev)
@@ -159,7 +159,7 @@ void crypto4xx_free_sa(struct crypto4xx_ctx *ctx)
ctx->sa_len = 0;
 }
 
-/**
+/*
  * alloc memory for the gather ring
  * no need to alloc buf for the ring
  * gdr_tail, gdr_head and gdr_count are initialized by this function
@@ -268,7 +268,7 @@ static u32 crypto4xx_put_pd_to_pdr(struct crypto4xx_device 
*dev, u32 idx)
return tail;
 }
 
-/**
+/*
  * alloc memory for the gather ring
  * no need to alloc buf for the ring
  * gdr_tail, gdr_head and gdr_count are initialized by this function
@@ -346,7 +346,7 @@ static inline struct ce_gd *crypto4xx_get_gdp(struct 
crypto4xx_device *dev,
return &dev->gdr[idx];
 }
 
-/**
+/*
  * alloc memory for the scatter ring
  * need to alloc buf for the ring
  * sdr_tail, sdr_head and sdr_count are initialized by this function
@@ -930,7 +930,7 @@ int crypto4xx_build_pd(struct crypto_async_request *req,
return is_busy ? -EBUSY : -EINPROGRESS;
 }
 
-/**
+/*
  * Algorithm Registration Functions
  */
 static void crypto4xx_ctx_init(struct crypto4xx_alg *amcc_alg,
@@ -1097,7 +1097,7 @@ static void crypto4xx_bh_tasklet_cb(unsigned long data)
} while (head != tail);
 }
 
-/**
+/*
  * Top Half of isr.
  */
 static inline irqreturn_t crypto4xx_interrupt_handler(int irq, void *data,
@@ -1186,7 +1186,7 @@ static int crypto4xx_prng_seed(struct crypto_rng *tfm, 
const u8 *seed,
return 0;
 }
 
-/**
+/*
  * Supported Crypto Algorithms
  */
 static struct crypto4xx_alg_common crypto4xx_alg[] = {
@@ -1369,7 +1369,7 @@ static struct crypto4xx_alg_common crypto4xx_alg[] = {
} }

[PATCH] crypto: ux500: fix incorrect kernel-doc comment syntax

2021-03-21 Thread Aditya Srivastava
The opening comment mark '/**' is used for highlighting the beginning of
kernel-doc comments.
There are certain files in drivers/crypto/ux500, which follow this syntax,
but the content inside does not comply with kernel-doc.
Such lines were probably not meant for kernel-doc parsing, but are parsed
due to the presence of kernel-doc like comment syntax(i.e, '/**'), which
causes unexpected warnings from kernel-doc.

E.g., presence of kernel-doc like comment in the header lines for
drivers/crypto/ux500/cryp/cryp.h at header causes this warning:

"warning: expecting prototype for ST(). Prototype was for _CRYP_H_() instead"

Similarly for other files too.

Provide a simple fix by replacing such occurrences with general comment
format, i.e. '/*', to prevent kernel-doc from parsing it.

Signed-off-by: Aditya Srivastava 
---
 drivers/crypto/ux500/cryp/cryp.c  |  2 +-
 drivers/crypto/ux500/cryp/cryp.h  |  2 +-
 drivers/crypto/ux500/cryp/cryp_core.c |  2 +-
 drivers/crypto/ux500/cryp/cryp_irq.c  |  2 +-
 drivers/crypto/ux500/cryp/cryp_irq.h  |  4 ++--
 drivers/crypto/ux500/cryp/cryp_irqp.h |  4 ++--
 drivers/crypto/ux500/cryp/cryp_p.h| 14 +++---
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/crypto/ux500/cryp/cryp.c b/drivers/crypto/ux500/cryp/cryp.c
index 9866c2a5e9a7..2b9436723d57 100644
--- a/drivers/crypto/ux500/cryp/cryp.c
+++ b/drivers/crypto/ux500/cryp/cryp.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
  * Copyright (C) ST-Ericsson SA 2010
  * Author: Shujuan Chen  for ST-Ericsson.
  * Author: Jonas Linde  for ST-Ericsson.
diff --git a/drivers/crypto/ux500/cryp/cryp.h b/drivers/crypto/ux500/cryp/cryp.h
index 8da7f87b339b..db5713d7c940 100644
--- a/drivers/crypto/ux500/cryp/cryp.h
+++ b/drivers/crypto/ux500/cryp/cryp.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-/**
+/*
  * Copyright (C) ST-Ericsson SA 2010
  * Author: Shujuan Chen  for ST-Ericsson.
  * Author: Jonas Linde  for ST-Ericsson.
diff --git a/drivers/crypto/ux500/cryp/cryp_core.c 
b/drivers/crypto/ux500/cryp/cryp_core.c
index c3adeb2e5823..df68b7bd0a7a 100644
--- a/drivers/crypto/ux500/cryp/cryp_core.c
+++ b/drivers/crypto/ux500/cryp/cryp_core.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
  * Copyright (C) ST-Ericsson SA 2010
  * Author: Shujuan Chen  for ST-Ericsson.
  * Author: Joakim Bech  for ST-Ericsson.
diff --git a/drivers/crypto/ux500/cryp/cryp_irq.c 
b/drivers/crypto/ux500/cryp/cryp_irq.c
index 7ebde69e8c76..6d2f07bec98a 100644
--- a/drivers/crypto/ux500/cryp/cryp_irq.c
+++ b/drivers/crypto/ux500/cryp/cryp_irq.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
  * Copyright (C) ST-Ericsson SA 2010
  * Author: Shujuan Chen  for ST-Ericsson.
  * Author: Jonas Linde  for ST-Ericsson.
diff --git a/drivers/crypto/ux500/cryp/cryp_irq.h 
b/drivers/crypto/ux500/cryp/cryp_irq.h
index 1984f30100ff..da90029ea141 100644
--- a/drivers/crypto/ux500/cryp/cryp_irq.h
+++ b/drivers/crypto/ux500/cryp/cryp_irq.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-/**
+/*
  * Copyright (C) ST-Ericsson SA 2010
  * Author: Shujuan Chen  for ST-Ericsson.
  * Author: Jonas Linde  for ST-Ericsson.
@@ -19,7 +19,7 @@ enum cryp_irq_src_id {
CRYP_IRQ_SRC_ALL = 0x3
 };
 
-/**
+/*
  * M0 Funtions
  */
 void cryp_enable_irq_src(struct cryp_device_data *device_data, u32 irq_src);
diff --git a/drivers/crypto/ux500/cryp/cryp_irqp.h 
b/drivers/crypto/ux500/cryp/cryp_irqp.h
index 879ed68a12d7..4981a3f461e5 100644
--- a/drivers/crypto/ux500/cryp/cryp_irqp.h
+++ b/drivers/crypto/ux500/cryp/cryp_irqp.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-/**
+/*
  * Copyright (C) ST-Ericsson SA 2010
  * Author: Shujuan Chen  for ST-Ericsson.
  * Author: Jonas Linde  for ST-Ericsson.
@@ -13,7 +13,7 @@
 
 #include "cryp_irq.h"
 
-/**
+/*
  *
  * CRYP Registers - Offset mapping
  * +-+
diff --git a/drivers/crypto/ux500/cryp/cryp_p.h 
b/drivers/crypto/ux500/cryp/cryp_p.h
index 0df84eaa8531..ba17b1ffd94d 100644
--- a/drivers/crypto/ux500/cryp/cryp_p.h
+++ b/drivers/crypto/ux500/cryp/cryp_p.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-/**
+/*
  * Copyright (C) ST-Ericsson SA 2010
  * Author: Shujuan Chen  for ST-Ericsson.
  * Author: Jonas Linde  for ST-Ericsson.
@@ -17,7 +17,7 @@
 #include "cryp.h"
 #include "cryp_irqp.h"
 
-/**
+/*
  * Generic Macros
  */
 #define CRYP_SET_BITS(reg_name, mask) \
@@ -34,7 +34,7 @@
writel_relaxed(((readl_relaxed(reg) & ~(mask)) | \
(((u32)val << shift) & (mask))), reg)
 
-/**
+/*
  * CRYP specific Macros
  */
 #define CRYP_PERIPHERAL_ID00xE3
@@ -48,7 +48,7 @@
 #define CRYP_PCELL_ID2 0x05
 #define CRYP_PCELL_ID3 0xB1
 
-/**
+/*
  * CRYP register default values
  */
 #define MAX_DEVICE_SUPPORT 2
@@ -62,7 +62,7 @@
 #define CRYP_KEY_DEFAULT   0x0
 #define CRYP_INIT_VECT_DEFAUL

[net-next PATCH 0/8] configuration support for switch headers & phy

2021-03-21 Thread Hariprasad Kelam
This series of patches add support for parsing switch headers and
configuration support for phy modulation type(NRZ or PAM4).

PHYs that support changing modulation type ,user can configure it
through private flags pam4.

Marvell switches support DSA(distributed switch architecture) with
different switch headers like FDSA and EDSA. This patch series adds
private flags to enable user to configure interface in fdsa/edsa
mode such that flow steering (forwading packets to pf/vf depending on
switch header fields) and packet parsing can be acheived.

Also adds support for HIGIG2 protocol, user can configure interface
in higig mode through higig private flage, such that packet classification
and flow sterring achieved on packets with higig header


Felix Manlunas (2):
  octeontx2-af: Add new CGX_CMDs to set and get PHY modulation type
  octeontx2-pf: Add ethtool priv flag to control PAM4 on/off

Hariprasad Kelam (6):
  octeontx2-af: Support for parsing pkts with switch headers
  octeontx2-af: Do not allow VFs to overwrite PKIND config
  octeontx2-af: Put CGX LMAC also in Higig2 mode
  octeontx2-pf: Support to enable EDSA/Higig2 pkts parsing
  octeontx2-af: Add flow steering support for FDSA tag
  octeontx2-pf: Add ntuple filter support for FDSA

 .../net/ethernet/marvell/octeontx2/af/cgx.c   | 177 -
 .../net/ethernet/marvell/octeontx2/af/cgx.h   |  19 +-
 .../ethernet/marvell/octeontx2/af/cgx_fw_if.h |   6 +
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |  39 ++-
 .../net/ethernet/marvell/octeontx2/af/npc.h   |  14 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   9 +
 .../ethernet/marvell/octeontx2/af/rvu_cgx.c   | 103 +++-
 .../marvell/octeontx2/af/rvu_debugfs.c|   3 +-
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   |  44 +++-
 .../ethernet/marvell/octeontx2/af/rvu_npc.c   |  76 ++
 .../marvell/octeontx2/af/rvu_npc_fs.c |  14 +-
 .../marvell/octeontx2/nic/otx2_common.c   |   2 +
 .../marvell/octeontx2/nic/otx2_common.h   |  36 ++-
 .../marvell/octeontx2/nic/otx2_ethtool.c  | 244 ++
 .../marvell/octeontx2/nic/otx2_flows.c|  58 -
 .../ethernet/marvell/octeontx2/nic/otx2_pf.c  |  21 +-
 .../marvell/octeontx2/nic/otx2_txrx.c |   1 +
 .../ethernet/marvell/octeontx2/nic/otx2_vf.c  |  10 +
 18 files changed, 832 insertions(+), 44 deletions(-)

--
2.17.1


[net-next PATCH 2/8] octeontx2-pf: Add ethtool priv flag to control PAM4 on/off

2021-03-21 Thread Hariprasad Kelam
From: Felix Manlunas 

For PHYs that support changing modulation type (NRZ or PAM4), enable these
commands:

ethtool --set-priv-flags  ethX pam4 on
ethtool --set-priv-flags  ethX pam4 off# means NRZ modulation
ethtool --show-priv-flags ethX

Signed-off-by: Felix Manlunas 
Signed-off-by: Hariprasad Kelam 
Signed-off-by: Sunil Goutham 
---
 .../marvell/octeontx2/nic/otx2_ethtool.c  | 62 +++
 1 file changed, 62 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c 
b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
index f4962a97a07..552ecae1dbe 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
@@ -22,6 +22,11 @@
 #define DRV_NAME   "octeontx2-nicpf"
 #define DRV_VF_NAME"octeontx2-nicvf"
 
+static const char otx2_priv_flags_strings[][ETH_GSTRING_LEN] = {
+#define OTX2_PRIV_FLAGS_PAM4 BIT(0)
+   "pam4",
+};
+
 struct otx2_stat {
char name[ETH_GSTRING_LEN];
unsigned int index;
@@ -112,6 +117,12 @@ static void otx2_get_strings(struct net_device *netdev, 
u32 sset, u8 *data)
struct otx2_nic *pfvf = netdev_priv(netdev);
int stats;
 
+   if (sset == ETH_SS_PRIV_FLAGS) {
+   memcpy(data, otx2_priv_flags_strings,
+  ARRAY_SIZE(otx2_priv_flags_strings) * ETH_GSTRING_LEN);
+   return;
+   }
+
if (sset != ETH_SS_STATS)
return;
 
@@ -250,6 +261,9 @@ static int otx2_get_sset_count(struct net_device *netdev, 
int sset)
struct otx2_nic *pfvf = netdev_priv(netdev);
int qstats_count;
 
+   if (sset == ETH_SS_PRIV_FLAGS)
+   return ARRAY_SIZE(otx2_priv_flags_strings);
+
if (sset != ETH_SS_STATS)
return -EINVAL;
 
@@ -1219,6 +1233,52 @@ static int otx2_set_link_ksettings(struct net_device 
*netdev,
return err;
 }
 
+static int otx2_set_priv_flags(struct net_device *netdev, u32 priv_flags)
+{
+   struct otx2_nic *pfvf = netdev_priv(netdev);
+   struct cgx_phy_mod_type *req;
+   struct cgx_fw_data *fwd;
+   int rc = -ENOMEM;
+
+   fwd = otx2_get_fwdata(pfvf);
+   if (IS_ERR(fwd))
+   return PTR_ERR(fwd);
+
+   /* ret here if phy does not support this feature */
+   if (!fwd->fwdata.phy.misc.can_change_mod_type)
+   return -EOPNOTSUPP;
+
+   mutex_lock(&pfvf->mbox.lock);
+   req = otx2_mbox_alloc_msg_cgx_set_phy_mod_type(&pfvf->mbox);
+   if (!req)
+   goto end;
+
+   req->mod = priv_flags & OTX2_PRIV_FLAGS_PAM4;
+   if (!otx2_sync_mbox_msg(&pfvf->mbox))
+   rc = 0;
+
+end:
+   mutex_unlock(&pfvf->mbox.lock);
+   return rc;
+}
+
+static u32 otx2_get_priv_flags(struct net_device *netdev)
+{
+   struct otx2_nic *pfvf = netdev_priv(netdev);
+   struct cgx_fw_data *rsp;
+   u32 priv_flags = 0;
+
+   rsp = otx2_get_fwdata(pfvf);
+
+   if (IS_ERR(rsp))
+   return 0;
+
+   if (rsp->fwdata.phy.misc.mod_type)
+   priv_flags |= OTX2_PRIV_FLAGS_PAM4;
+
+   return priv_flags;
+}
+
 static const struct ethtool_ops otx2_ethtool_ops = {
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
 ETHTOOL_COALESCE_MAX_FRAMES,
@@ -1250,6 +1310,8 @@ static const struct ethtool_ops otx2_ethtool_ops = {
.set_fecparam   = otx2_set_fecparam,
.get_link_ksettings = otx2_get_link_ksettings,
.set_link_ksettings = otx2_set_link_ksettings,
+   .set_priv_flags = otx2_set_priv_flags,
+   .get_priv_flags = otx2_get_priv_flags,
 };
 
 void otx2_set_ethtool_ops(struct net_device *netdev)
-- 
2.17.1



[net-next PATCH 1/8] octeontx2-af: Add new CGX_CMDs to set and get PHY modulation type

2021-03-21 Thread Hariprasad Kelam
From: Felix Manlunas 

Implement commands to set and get PHY line-side modulation type
(NRZ or PAM4) from firmware.

Signed-off-by: Felix Manlunas 
Signed-off-by: Hariprasad Kelam 
Signed-off-by: Sunil Goutham 
---
 .../net/ethernet/marvell/octeontx2/af/cgx.c   | 29 +
 .../net/ethernet/marvell/octeontx2/af/cgx.h   |  2 ++
 .../ethernet/marvell/octeontx2/af/cgx_fw_if.h |  6 
 .../net/ethernet/marvell/octeontx2/af/mbox.h  | 10 +-
 .../ethernet/marvell/octeontx2/af/rvu_cgx.c   | 31 +++
 5 files changed, 77 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c 
b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
index 68deae529bc..294e7d12f15 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
@@ -1072,6 +1072,35 @@ int cgx_get_phy_fec_stats(void *cgxd, int lmac_id)
return cgx_fwi_cmd_generic(req, &resp, cgx, lmac_id);
 }
 
+int cgx_set_phy_mod_type(int mod, void *cgxd, int lmac_id)
+{
+   struct cgx *cgx = cgxd;
+   u64 req = 0, resp;
+
+   if (!cgx)
+   return -ENODEV;
+
+   req = FIELD_SET(CMDREG_ID, CGX_CMD_SET_PHY_MOD_TYPE, req);
+   req = FIELD_SET(CMDSETPHYMODTYPE, mod, req);
+   return cgx_fwi_cmd_generic(req, &resp, cgx, lmac_id);
+}
+
+int cgx_get_phy_mod_type(void *cgxd, int lmac_id)
+{
+   struct cgx *cgx = cgxd;
+   u64 req = 0, resp;
+   int err;
+
+   if (!cgx)
+   return -ENODEV;
+
+   req = FIELD_SET(CMDREG_ID, CGX_CMD_GET_PHY_MOD_TYPE, req);
+   err = cgx_fwi_cmd_generic(req, &resp, cgx, lmac_id);
+   if (!err)
+   return FIELD_GET(RESP_GETPHYMODTYPE, resp);
+   return err;
+}
+
 static int cgx_fwi_link_change(struct cgx *cgx, int lmac_id, bool enable)
 {
u64 req = 0;
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.h 
b/drivers/net/ethernet/marvell/octeontx2/af/cgx.h
index 12521262164..10b5611a3b4 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.h
@@ -165,4 +165,6 @@ u8 cgx_get_lmacid(void *cgxd, u8 lmac_index);
 unsigned long cgx_get_lmac_bmap(void *cgxd);
 void cgx_lmac_write(int cgx_id, int lmac_id, u64 offset, u64 val);
 u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset);
+int cgx_set_phy_mod_type(int mod, void *cgxd, int lmac_id);
+int cgx_get_phy_mod_type(void *cgxd, int lmac_id);
 #endif /* CGX_H */
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx_fw_if.h 
b/drivers/net/ethernet/marvell/octeontx2/af/cgx_fw_if.h
index aa4e42f78f1..6bde02c8e4b 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx_fw_if.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx_fw_if.h
@@ -264,4 +264,10 @@ struct cgx_lnk_sts {
 #define CMDMODECHANGE_PORT GENMASK_ULL(21, 14)
 #define CMDMODECHANGE_FLAGSGENMASK_ULL(63, 22)
 
+/* command argument to be passed for cmd ID - CGX_CMD_SET_PHY_MOD_TYPE */
+#define CMDSETPHYMODTYPE   GENMASK_ULL(8, 8)
+
+/* response to cmd ID - RESP_GETPHYMODTYPE */
+#define RESP_GETPHYMODTYPE GENMASK_ULL(9, 9)
+
 #endif /* __CGX_FW_INTF_H__ */
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h 
b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index 3af4d0ffcf7..66ab320b845 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -162,7 +162,10 @@ M(CGX_SET_LINK_MODE,   0x214, cgx_set_link_mode, 
cgx_set_link_mode_req,\
 M(CGX_FEATURES_GET,0x215, cgx_features_get, msg_req,   \
   cgx_features_info_msg)   \
 M(RPM_STATS,   0x216, rpm_stats, msg_req, rpm_stats_rsp)   \
- /* NPA mbox IDs (range 0x400 - 0x5FF) */  \
+M(CGX_GET_PHY_MOD_TYPE, 0x217, cgx_get_phy_mod_type, msg_req,  \
+  cgx_phy_mod_type)\
+M(CGX_SET_PHY_MOD_TYPE, 0x218, cgx_set_phy_mod_type, cgx_phy_mod_type, \
+  msg_rsp) \
 /* NPA mbox IDs (range 0x400 - 0x5FF) */   \
 M(NPA_LF_ALLOC,0x400, npa_lf_alloc,
\
npa_lf_alloc_req, npa_lf_alloc_rsp) \
@@ -510,6 +513,11 @@ struct rpm_stats_rsp {
u64 tx_stats[RPM_TX_STATS_COUNT];
 };
 
+struct cgx_phy_mod_type {
+   struct mbox_msghdr hdr;
+   int mod;
+};
+
 /* NPA mbox message formats */
 
 /* NPA mailbox error codes
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
index e668e482383..b78e48d18f6 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
@@ -939,3 +939,34 @@ int rvu_mbox_handler_cgx_set_link_mode(struct rvu *rvu,
rsp->status = cgx_set_link_mode(cgxd, req->args, cgx_idx, lmac);

[net-next PATCH 3/8] octeontx2-af: Support for parsing pkts with switch headers

2021-03-21 Thread Hariprasad Kelam
Switch headers are designed to support better flow control and
loadbalancing etc. When switch headers like EDSA, Higig2 etc are
present in ingress or egress pkts default iKPU index (or PKIND)
used by NPC to parse pkts will not work as there are additional
headers appended to the pkt. Hence a separate Pkind is chosen on
Rx and/or Tx sides to tell to KPU to parse the pkts accordingly.

Signed-off-by: Hariprasad Kelam 
Signed-off-by: Geetha sowjanya 
Signed-off-by: Sunil Goutham 
---
 .../net/ethernet/marvell/octeontx2/af/mbox.h  | 14 +
 .../net/ethernet/marvell/octeontx2/af/npc.h   |  6 ++-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |  4 ++
 .../ethernet/marvell/octeontx2/af/rvu_cgx.c   |  2 +-
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   |  4 ++
 .../ethernet/marvell/octeontx2/af/rvu_npc.c   | 54 +++
 6 files changed, 82 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h 
b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index 66ab320b845..1ce22782260 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -222,6 +222,8 @@ M(NPC_MCAM_READ_BASE_RULE, 0x6011, 
npc_read_base_steer_rule,\
 M(NPC_MCAM_GET_STATS, 0x6012, npc_mcam_entry_stats, \
   npc_mcam_get_stats_req,  \
   npc_mcam_get_stats_rsp)  \
+M(NPC_SET_PKIND,  0x6013, npc_set_pkind,\
+  npc_set_pkind, msg_rsp)   \
 /* NIX mbox IDs (range 0x8000 - 0x) */ \
 M(NIX_LF_ALLOC,0x8000, nix_lf_alloc,   
\
 nix_lf_alloc_req, nix_lf_alloc_rsp)\
@@ -475,6 +477,18 @@ struct cgx_fw_data {
struct cgx_lmac_fwdata_s fwdata;
 };
 
+struct npc_set_pkind {
+   struct mbox_msghdr hdr;
+#define OTX2_PRIV_FLAGS_DEFAULT  BIT_ULL(0)
+#define OTX2_PRIV_FLAGS_EDSA BIT_ULL(1)
+#define OTX2_PRIV_FLAGS_HIGIGBIT_ULL(2)
+#define OTX2_PRIV_FLAGS_CUSTOM   BIT_ULL(63)
+   u64 mode;
+#define PKIND_TX   BIT_ULL(0)
+#define PKIND_RX   BIT_ULL(1)
+   u8 dir;
+   u8 pkind; /* valid only in case custom flag */
+};
 struct cgx_set_link_mode_args {
u32 speed;
u8 duplex;
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/npc.h 
b/drivers/net/ethernet/marvell/octeontx2/af/npc.h
index 1e012e78726..e60f1fa2d55 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/npc.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/npc.h
@@ -146,7 +146,11 @@ enum npc_kpu_lh_ltype {
  * Ethernet interfaces, LBK interfaces, etc.
  */
 enum npc_pkind_type {
-   NPC_TX_DEF_PKIND = 63ULL,   /* NIX-TX PKIND */
+   NPC_TX_HIGIG_PKIND = 60ULL,
+   NPC_RX_HIGIG_PKIND,
+   NPC_RX_EDSA_PKIND,
+   NPC_TX_DEF_PKIND,
+
 };
 
 /* list of known and supported fields in packet header and
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index baaba01bd8c..2b31ecd3d21 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -616,6 +616,8 @@ void rvu_cgx_enadis_rx_bp(struct rvu *rvu, int pf, bool 
enable);
 int rvu_cgx_start_stop_io(struct rvu *rvu, u16 pcifunc, bool start);
 int rvu_cgx_nix_cuml_stats(struct rvu *rvu, void *cgxd, int lmac_id, int index,
   int rxtxflag, u64 *stat);
+bool is_cgx_config_permitted(struct rvu *rvu, u16 pcifunc);
+
 /* NPA APIs */
 int rvu_npa_init(struct rvu *rvu);
 void rvu_npa_freemem(struct rvu *rvu);
@@ -682,6 +684,8 @@ void npc_read_mcam_entry(struct rvu *rvu, struct npc_mcam 
*mcam,
 u8 *intf, u8 *ena);
 bool is_mac_feature_supported(struct rvu *rvu, int pf, int feature);
 u32  rvu_cgx_get_fifolen(struct rvu *rvu);
+int rvu_npc_set_parse_mode(struct rvu *rvu, u16 pcifunc, u64 mode, u8 dir,
+  u64 pkind);
 
 int npc_get_nixlf_mcam_index(struct npc_mcam *mcam, u16 pcifunc, int nixlf,
 int type);
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
index b78e48d18f6..992e53e56c3 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
@@ -396,7 +396,7 @@ int rvu_cgx_exit(struct rvu *rvu)
  * VF's of mapped PF and other PFs are not allowed. This fn() checks
  * whether a PFFUNC is permitted to do the config or not.
  */
-static bool is_cgx_config_permitted(struct rvu *rvu, u16 pcifunc)
+bool is_cgx_config_permitted(struct rvu *rvu, u16 pcifunc)
 {
if ((pcifunc & RVU_PFVF_FUNC_MASK) ||
!is_pf_cgxmapped(rvu, rvu_get_pf(pcifunc)))
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/

[net-next PATCH 4/8] octeontx2-af: Do not allow VFs to overwrite PKIND config

2021-03-21 Thread Hariprasad Kelam
When switch headers like EDSA, Higig2 etc are present in ingress
or egress packets the packet parsing done by NPC needs to take additional
headers into account. KPU profile handles these using specific
PKINDs (the iKPU index) to  parse these packets differently.

AF writes these pkinds to HW upon receiving NPC_SET_PKIND mbox request.
But in nix_lf_alloc mbox request from VF, AF writes default RX/TX
pkinds to HW. Since PF and its VFs share same CGX/LMAC pair, earlier
configuration is getting overwritten. Ideally VF should not override PF
configuration. This patch adds proper validation to ensure the same.

Signed-off-by: Hariprasad Kelam 
Signed-off-by: Sunil Goutham 
---
 .../net/ethernet/marvell/octeontx2/af/cgx.c   | 12 +++
 .../net/ethernet/marvell/octeontx2/af/cgx.h   |  1 +
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |  1 +
 .../ethernet/marvell/octeontx2/af/rvu_cgx.c   | 36 +++
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   | 14 +---
 5 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c 
b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
index 294e7d12f15..aa86691885d 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
@@ -231,6 +231,18 @@ int cgx_set_pkind(void *cgxd, u8 lmac_id, int pkind)
return 0;
 }
 
+int cgx_get_pkind(void *cgxd, u8 lmac_id, int *pkind)
+{
+   struct cgx *cgx = cgxd;
+
+   if (!is_lmac_valid(cgx, lmac_id))
+   return -ENODEV;
+
+   *pkind = cgx_read(cgx, lmac_id, CGXX_CMRX_RX_ID_MAP);
+   *pkind = *pkind & 0x3F;
+   return 0;
+}
+
 static u8 cgx_get_lmac_type(void *cgxd, int lmac_id)
 {
struct cgx *cgx = cgxd;
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.h 
b/drivers/net/ethernet/marvell/octeontx2/af/cgx.h
index 10b5611a3b4..237a91b801e 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.h
@@ -167,4 +167,5 @@ void cgx_lmac_write(int cgx_id, int lmac_id, u64 offset, 
u64 val);
 u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset);
 int cgx_set_phy_mod_type(int mod, void *cgxd, int lmac_id);
 int cgx_get_phy_mod_type(void *cgxd, int lmac_id);
+int cgx_get_pkind(void *cgxd, u8 lmac_id, int *pkind);
 #endif /* CGX_H */
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index 2b31ecd3d21..292351bad5b 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -617,6 +617,7 @@ int rvu_cgx_start_stop_io(struct rvu *rvu, u16 pcifunc, 
bool start);
 int rvu_cgx_nix_cuml_stats(struct rvu *rvu, void *cgxd, int lmac_id, int index,
   int rxtxflag, u64 *stat);
 bool is_cgx_config_permitted(struct rvu *rvu, u16 pcifunc);
+bool rvu_cgx_is_pkind_config_permitted(struct rvu *rvu, u16 pcifunc);
 
 /* NPA APIs */
 int rvu_npa_init(struct rvu *rvu);
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
index 992e53e56c3..9c30692070b 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
@@ -970,3 +970,39 @@ int rvu_mbox_handler_cgx_get_phy_mod_type(struct rvu *rvu, 
struct msg_req *req,
return rsp->mod;
return 0;
 }
+
+/* Dont allow cgx mapped VFs to overwrite PKIND config
+ * incase of special PKINDs are configured like (HIGIG/EDSA)
+ */
+bool rvu_cgx_is_pkind_config_permitted(struct rvu *rvu, u16 pcifunc)
+{
+   int rc, pf, rxpkind;
+   u8 cgx_id, lmac_id;
+
+   pf = rvu_get_pf(pcifunc);
+
+   /* Ret here for PFs or non cgx interfaces */
+   if (!(pcifunc & RVU_PFVF_FUNC_MASK))
+   return true;
+
+   if (!is_pf_cgxmapped(rvu, pf))
+   return true;
+
+   rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
+
+   rc = cgx_get_pkind(rvu_cgx_pdata(cgx_id, rvu), lmac_id, &rxpkind);
+   if (rc)
+   return false;
+
+   switch (rxpkind) {
+   /* Add here specific pkinds reserved for pkt parsing */
+   case NPC_RX_HIGIG_PKIND:
+   case NPC_RX_EDSA_PKIND:
+   rc = false;
+   break;
+   default:
+   rc = true;
+   }
+
+   return rc;
+}
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 42cc443e6e8..ed96ebc4022 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -239,8 +239,12 @@ static int nix_interface_init(struct rvu *rvu, u16 
pcifunc, int type, int nixlf)
pfvf->tx_chan_base = pfvf->rx_chan_base;
pfvf->rx_chan_cnt = 1;
pfvf->tx_chan_cnt = 1;
-   cgx_set_pkind(rvu_cgx_pdata(cgx_id, rvu), lm

[net-next PATCH 6/8] octeontx2-pf: Support to enable EDSA/Higig2 pkts parsing

2021-03-21 Thread Hariprasad Kelam
When switch headers like EDSA, Higig2 etc are present in ingress
or egress pkts the pkt parsing done by NPC needs to take additional
headers into account. KPU profile handles these using specific PKINDs
(the iKPU index) to start parsing pkts differently.

This patch enables user to configure these PKINDs into hardware for
proper pkt parsing. Patch also handles changes to max frame size due to
additional headers in pkt.

higig2:
ethtool --set-priv-flags eth0 higig2 on/off
edsa:
ethtool --set-priv-flags eth0 edsa on/off

Signed-off-by: Hariprasad Kelam 
Signed-off-by: Sunil Goutham 
---
 .../marvell/octeontx2/nic/otx2_common.c   |   2 +
 .../marvell/octeontx2/nic/otx2_common.h   |  22 +++
 .../marvell/octeontx2/nic/otx2_ethtool.c  | 153 +-
 .../ethernet/marvell/octeontx2/nic/otx2_pf.c  |   8 +
 .../marvell/octeontx2/nic/otx2_txrx.c |   1 +
 .../ethernet/marvell/octeontx2/nic/otx2_vf.c  |  10 ++
 6 files changed, 188 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c 
b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
index cf7875d51d8..b9a5cd35061 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
@@ -230,6 +230,8 @@ int otx2_hw_set_mtu(struct otx2_nic *pfvf, int mtu)
return -ENOMEM;
}
 
+   /* Add EDSA/HIGIG2 header len to maxlen */
+   pfvf->max_frs = mtu + OTX2_ETH_HLEN + pfvf->addl_mtu;
req->maxlen = pfvf->max_frs;
 
err = otx2_sync_mbox_msg(&pfvf->mbox);
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h 
b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
index 45730d0d92f..73e927a7843 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
@@ -303,6 +303,7 @@ struct otx2_nic {
struct net_device   *netdev;
struct dev_hw_ops   *hw_ops;
void*iommu_domain;
+   u16 xtra_hdr;
u16 max_frs;
u16 rbsize; /* Receive buffer size */
 
@@ -345,6 +346,25 @@ struct otx2_nic {
struct refill_work  *refill_wrk;
struct workqueue_struct *otx2_wq;
struct work_struct  rx_mode_work;
+
+#define OTX2_PRIV_FLAG_PAM4BIT(0)
+#define OTX2_PRIV_FLAG_EDSA_HDRBIT(1)
+#define OTX2_PRIV_FLAG_HIGIG2_HDR  BIT(2)
+#define OTX2_PRIV_FLAG_DEF_MODEBIT(3)
+#define OTX2_IS_EDSA_ENABLED(flags)((flags) &  \
+OTX2_PRIV_FLAG_EDSA_HDR)
+#define OTX2_IS_HIGIG2_ENABLED(flags)  ((flags) &  \
+OTX2_PRIV_FLAG_HIGIG2_HDR)
+#define OTX2_IS_DEF_MODE_ENABLED(flags)((flags) &  
\
+OTX2_PRIV_FLAG_DEF_MODE)
+   u32 ethtool_flags;
+
+   /* extended DSA and EDSA  header lengths are 8/16 bytes
+* so take max length 16 bytes here
+*/
+#define OTX2_EDSA_HDR_LEN  16
+#define OTX2_HIGIG2_HDR_LEN16
+   u32 addl_mtu;
struct otx2_mac_table   *mac_table;
 
/* Ethtool stuff */
@@ -796,6 +816,8 @@ int otx2_open(struct net_device *netdev);
 int otx2_stop(struct net_device *netdev);
 int otx2_set_real_num_queues(struct net_device *netdev,
 int tx_queues, int rx_queues);
+int otx2_set_npc_parse_mode(struct otx2_nic *pfvf, bool unbind);
+
 /* MCAM filter related APIs */
 int otx2_mcam_flow_init(struct otx2_nic *pf);
 int otx2_alloc_mcam_entries(struct otx2_nic *pfvf);
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c 
b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
index 552ecae1dbe..c1405611489 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
@@ -23,8 +23,9 @@
 #define DRV_VF_NAME"octeontx2-nicvf"
 
 static const char otx2_priv_flags_strings[][ETH_GSTRING_LEN] = {
-#define OTX2_PRIV_FLAGS_PAM4 BIT(0)
"pam4",
+   "edsa",
+   "higig2",
 };
 
 struct otx2_stat {
@@ -1233,7 +1234,7 @@ static int otx2_set_link_ksettings(struct net_device 
*netdev,
return err;
 }
 
-static int otx2_set_priv_flags(struct net_device *netdev, u32 priv_flags)
+static int otx2_set_phy_mod_type(struct net_device *netdev, bool enable)
 {
struct otx2_nic *pfvf = netdev_priv(netdev);
struct cgx_phy_mod_type *req;
@@ -1253,7 +1254,7 @@ static int otx2_set_priv_flags(struct net_device *netdev, 
u32 priv_flags)
if (!req)
goto end;
 
-   req->mod = priv_flags & OTX2_PRIV_FLAGS_PA

[net-next PATCH 8/8] octeontx2-pf: Add ntuple filter support for FDSA

2021-03-21 Thread Hariprasad Kelam
Marvell switches support FDSA (Forward DSA). FDSA has
4 bytes length and it contains Src port and vlan field.
KPU profile is updated to parse  FDSA packet and extract Src port.
The extracted Src port is placed in vlan field of KEX key.

This patch adds ntuple filter support to FDSA tag.
So that user can send traffic to either PF or VF based on
Src port or Vlan id. All rules installed for FDSA has default
action as RSS. Upon enabling FDSA , vf vlan rules will be disabled.

To enable fdsa tag
ethtool --set-priv-flags eth0 fdsa on

To send traffic with Srcport 30 to PF
ethtool -U eth0 flow-type ether  user-def 0x1e

To send traffic with vlan id 30 to PF
ethtool -U eth0 flow-type ether  dst xx vlan 30 m 0xf000

To send traffic with Srcport 20 to vf 0
ethtool -U eth0 flow-type ether vf 0 user-def 0x14

Signed-off-by: Hariprasad Kelam 
Signed-off-by: Sunil Goutham 
---
 .../marvell/octeontx2/nic/otx2_common.h   | 16 -
 .../marvell/octeontx2/nic/otx2_ethtool.c  | 49 +++-
 .../marvell/octeontx2/nic/otx2_flows.c| 58 ---
 .../ethernet/marvell/octeontx2/nic/otx2_pf.c  | 13 -
 4 files changed, 121 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h 
b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
index 73e927a7843..3aa61125f84 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
@@ -223,6 +223,12 @@ struct otx2_hw {
u64 *nix_lmt_base;
 };
 
+struct vfvlan {
+   u16 vlan;
+   __be16 proto;
+   u8 qos;
+};
+
 struct otx2_vf_config {
struct otx2_nic *pf;
struct delayed_work link_event_work;
@@ -230,6 +236,7 @@ struct otx2_vf_config {
u8 mac[ETH_ALEN];
u16 vlan;
int tx_vtag_idx;
+   struct vfvlan rule;
 };
 
 struct flr_work {
@@ -350,7 +357,9 @@ struct otx2_nic {
 #define OTX2_PRIV_FLAG_PAM4BIT(0)
 #define OTX2_PRIV_FLAG_EDSA_HDRBIT(1)
 #define OTX2_PRIV_FLAG_HIGIG2_HDR  BIT(2)
-#define OTX2_PRIV_FLAG_DEF_MODEBIT(3)
+#define OTX2_PRIV_FLAG_FDSA_HDRBIT(3)
+#define OTX2_INTF_MOD_MASK GENMASK(3, 1)
+#define OTX2_PRIV_FLAG_DEF_MODEBIT(4)
 #define OTX2_IS_EDSA_ENABLED(flags)((flags) &  \
 OTX2_PRIV_FLAG_EDSA_HDR)
 #define OTX2_IS_HIGIG2_ENABLED(flags)  ((flags) &  \
@@ -364,6 +373,7 @@ struct otx2_nic {
 */
 #define OTX2_EDSA_HDR_LEN  16
 #define OTX2_HIGIG2_HDR_LEN16
+#define OTX2_FDSA_HDR_LEN  4
u32 addl_mtu;
struct otx2_mac_table   *mac_table;
 
@@ -831,14 +841,14 @@ int otx2_get_all_flows(struct otx2_nic *pfvf,
 int otx2_add_flow(struct otx2_nic *pfvf,
  struct ethtool_rxnfc *nfc);
 int otx2_remove_flow(struct otx2_nic *pfvf, u32 location);
-int otx2_prepare_flow_request(struct ethtool_rx_flow_spec *fsp,
- struct npc_install_flow_req *req);
 void otx2_rss_ctx_flow_del(struct otx2_nic *pfvf, int ctx_id);
 int otx2_del_macfilter(struct net_device *netdev, const u8 *mac);
 int otx2_add_macfilter(struct net_device *netdev, const u8 *mac);
 int otx2_enable_rxvlan(struct otx2_nic *pf, bool enable);
 int otx2_install_rxvlan_offload_flow(struct otx2_nic *pfvf);
 u16 otx2_get_max_mtu(struct otx2_nic *pfvf);
+int otx2_do_set_vf_vlan(struct otx2_nic *pf, int vf, u16 vlan, u8 qos,
+   __be16 proto);
 /* tc support */
 int otx2_init_tc(struct otx2_nic *nic);
 void otx2_shutdown_tc(struct otx2_nic *nic);
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c 
b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
index c1405611489..523bb089b9e 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
@@ -26,6 +26,7 @@ static const char otx2_priv_flags_strings[][ETH_GSTRING_LEN] 
= {
"pam4",
"edsa",
"higig2",
+   "fdsa",
 };
 
 struct otx2_stat {
@@ -1286,6 +1287,9 @@ int otx2_set_npc_parse_mode(struct otx2_nic *pfvf, bool 
unbind)
} else if (OTX2_IS_EDSA_ENABLED(pfvf->ethtool_flags)) {
req->mode = OTX2_PRIV_FLAGS_EDSA;
interface_mode = OTX2_PRIV_FLAG_EDSA_HDR;
+   } else if (pfvf->ethtool_flags & OTX2_PRIV_FLAG_FDSA_HDR) {
+   req->mode = OTX2_PRIV_FLAGS_FDSA;
+   interface_mode = OTX2_PRIV_FLAG_FDSA_HDR;
} else {
req->mode = OTX2_PRIV_FLAGS_DEFAULT;
interface_mode = OTX2_PRIV_FLAG_DEF_MODE;
@@ -1364,6 +1368,28 @@ static int otx2_enable_addl_header(struct net_device 
*netdev, int bitpos,
return 0;
 }
 
+/* This

[net-next PATCH 7/8] octeontx2-af: Add flow steering support for FDSA tag

2021-03-21 Thread Hariprasad Kelam
Marvell switches support distributed switch architecture (DSA) by
implementing FORWARD(FDSA). Special pkind 62 is reserved to parse
this tag.

This patch adds support to configure pkind and flow steering for
the same. To distribute fdsa packets among PF/VF , one can
specify NPC_FDSA_VAL in mcam features .Rx vtag Type 6 is reserved
to strip FDSA tag.

Signed-off-by: Hariprasad Kelam 
Signed-off-by: Sunil Goutham 
---
 drivers/net/ethernet/marvell/octeontx2/af/mbox.h   |  1 +
 drivers/net/ethernet/marvell/octeontx2/af/npc.h|  8 
 drivers/net/ethernet/marvell/octeontx2/af/rvu.h|  1 +
 .../ethernet/marvell/octeontx2/af/rvu_debugfs.c|  3 ++-
 .../net/ethernet/marvell/octeontx2/af/rvu_nix.c|  9 +++--
 .../net/ethernet/marvell/octeontx2/af/rvu_npc.c| 10 +-
 .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 14 --
 7 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h 
b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index a1f71ee9e98..8e0d1e47876 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -482,6 +482,7 @@ struct npc_set_pkind {
 #define OTX2_PRIV_FLAGS_DEFAULT  BIT_ULL(0)
 #define OTX2_PRIV_FLAGS_EDSA BIT_ULL(1)
 #define OTX2_PRIV_FLAGS_HIGIGBIT_ULL(2)
+#define OTX2_PRIV_FLAGS_FDSA BIT_ULL(3)
 #define OTX2_PRIV_FLAGS_CUSTOM   BIT_ULL(63)
u64 mode;
 #define PKIND_TX   BIT_ULL(0)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/npc.h 
b/drivers/net/ethernet/marvell/octeontx2/af/npc.h
index e60f1fa2d55..059de54a4dd 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/npc.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/npc.h
@@ -179,6 +179,7 @@ enum key_fields {
NPC_DPORT_UDP,
NPC_SPORT_SCTP,
NPC_DPORT_SCTP,
+   NPC_FDSA_VAL,
NPC_HEADER_FIELDS_MAX,
NPC_CHAN = NPC_HEADER_FIELDS_MAX, /* Valid when Rx */
NPC_PF_FUNC, /* Valid when Tx */
@@ -208,6 +209,13 @@ enum key_fields {
NPC_KEY_FIELDS_MAX,
 };
 
+enum npc_interface_type {
+   NPC_INTF_MODE_DEF,
+   NPC_INTF_MODE_EDSA,
+   NPC_INTF_MODE_HIGIG,
+   NPC_INTF_MODE_FDSA,
+};
+
 struct npc_kpu_profile_cam {
u8 state;
u8 state_mask;
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index ae51937ee46..f9fd443a34d 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -239,6 +239,7 @@ struct rvu_pfvf {
u8  nix_blkaddr; /* BLKADDR_NIX0/1 assigned to this PF */
u8  nix_rx_intf; /* NIX0_RX/NIX1_RX interface to NPC */
u8  nix_tx_intf; /* NIX0_TX/NIX1_TX interface to NPC */
+   int intf_mode;
 };
 
 struct nix_txsch {
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
index 741da112fdf..791eaf5e2ca 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
@@ -2002,7 +2002,8 @@ static void rvu_dbg_npc_mcam_show_flows(struct seq_file 
*s,
seq_printf(s, "mask 0x%x\n", ntohs(rule->mask.etype));
break;
case NPC_OUTER_VID:
-   seq_printf(s, "0x%x ", ntohs(rule->packet.vlan_tci));
+   case NPC_FDSA_VAL:
+   seq_printf(s, "%d ", ntohs(rule->packet.vlan_tci));
seq_printf(s, "mask 0x%x\n",
   ntohs(rule->mask.vlan_tci));
break;
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 56ade799011..8959f03867f 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -1217,6 +1217,11 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,
rvu_write64(rvu, blkaddr,
NIX_AF_LFX_RX_VTAG_TYPEX(nixlf, NIX_AF_LFX_RX_VTAG_TYPE7),
VTAGSIZE_T4 | VTAG_STRIP);
+   /* Configure RX VTAG Type 6 (strip) for fdsa */
+   rvu_write64(rvu, blkaddr,
+   NIX_AF_LFX_RX_VTAG_TYPEX(nixlf, NIX_AF_LFX_RX_VTAG_TYPE6),
+   VTAGSIZE_T4 | VTAG_STRIP | VTAG_CAPTURE);
+
 
goto exit;
 
@@ -2016,8 +2021,8 @@ static int nix_rx_vtag_cfg(struct rvu *rvu, int nixlf, 
int blkaddr,
req->vtag_size > VTAGSIZE_T8)
return -EINVAL;
 
-   /* RX VTAG Type 7 reserved for vf vlan */
-   if (req->rx.vtag_type == NIX_AF_LFX_RX_VTAG_TYPE7)
+   /* RX VTAG Type 7,6 are reserved for vf vlan& FDSA tag strip */
+   if (req->rx.vtag_type >= NIX_AF_LFX_RX_VTAG_TYPE6)
return NIX_AF_ERR_RX_VTAG_INUSE;
 
if (req->rx.capture_vtag)
diff

[net-next PATCH 5/8] octeontx2-af: Put CGX LMAC also in Higig2 mode

2021-03-21 Thread Hariprasad Kelam
Currently upon user request to enable Higig2 mode, only NPC packet
parsing related settings are done. This patch adds config to put
CGX LMAC also in Higig2 mode. Actual hardware config is done by firmware,
so send a request to firmware to get the config done.

Adds support for higig2 pause frames such that when user enables
higig2, 802.3 pause frames are disabled and higig2 pause frames
are enabled vice versa.

Other changes
- CGX HW doesn't support timestamping when in Higig2 mode, so
  made PTP and Higig2 settings mutually exclusive.

Signed-off-by: Hariprasad Kelam 
Signed-off-by: Sunil Goutham 
---
 .../net/ethernet/marvell/octeontx2/af/cgx.c   | 136 --
 .../net/ethernet/marvell/octeontx2/af/cgx.h   |  16 ++-
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |  14 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   3 +
 .../ethernet/marvell/octeontx2/af/rvu_cgx.c   |  34 +
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   |  17 +++
 .../ethernet/marvell/octeontx2/af/rvu_npc.c   |  14 ++
 7 files changed, 214 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c 
b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
index aa86691885d..1cbd1ffe039 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
@@ -460,18 +460,32 @@ int cgx_lmac_tx_enable(void *cgxd, int lmac_id, bool 
enable)
return !!(last & DATA_PKT_TX_EN);
 }
 
-static int cgx_lmac_get_pause_frm_status(void *cgxd, int lmac_id,
-u8 *tx_pause, u8 *rx_pause)
+static int cgx_lmac_get_higig2_pause_frm_status(void *cgxd, int lmac_id,
+   u8 *tx_pause, u8 *rx_pause)
 {
struct cgx *cgx = cgxd;
u64 cfg;
 
-   if (is_dev_rpm(cgx))
-   return 0;
+   cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_HG2_CONTROL);
+
+   *rx_pause = !!(cfg & CGXX_SMUX_HG2_CONTROL_RX_ENABLE);
+   *tx_pause = !!(cfg & CGXX_SMUX_HG2_CONTROL_TX_ENABLE);
+   return 0;
+}
+
+int cgx_lmac_get_pause_frm_status(void *cgxd, int lmac_id,
+ u8 *tx_pause, u8 *rx_pause)
+{
+   struct cgx *cgx = cgxd;
+   u64 cfg;
 
if (!is_lmac_valid(cgx, lmac_id))
return -ENODEV;
 
+   if (is_higig2_enabled(cgxd, lmac_id))
+   return cgx_lmac_get_higig2_pause_frm_status(cgxd, lmac_id,
+   tx_pause, rx_pause);
+
cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL);
*rx_pause = !!(cfg & CGX_SMUX_RX_FRM_CTL_CTL_BCK);
 
@@ -480,17 +494,51 @@ static int cgx_lmac_get_pause_frm_status(void *cgxd, int 
lmac_id,
return 0;
 }
 
-static int cgx_lmac_enadis_pause_frm(void *cgxd, int lmac_id,
-u8 tx_pause, u8 rx_pause)
+static int cgx_lmac_enadis_higig2_pause_frm(void *cgxd, int lmac_id,
+   u8 tx_pause, u8 rx_pause)
 {
struct cgx *cgx = cgxd;
u64 cfg;
 
-   if (is_dev_rpm(cgx))
-   return 0;
+   cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_HG2_CONTROL);
+   cfg &= ~CGXX_SMUX_HG2_CONTROL_RX_ENABLE;
+   cfg |= rx_pause ? CGXX_SMUX_HG2_CONTROL_RX_ENABLE : 0x0;
+   cgx_write(cgx, lmac_id, CGXX_SMUX_HG2_CONTROL, cfg);
 
-   if (!is_lmac_valid(cgx, lmac_id))
-   return -ENODEV;
+   /* Forward PAUSE information to TX block */
+   cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL);
+   cfg &= ~CGX_SMUX_RX_FRM_CTL_CTL_BCK;
+   cfg |= rx_pause ? CGX_SMUX_RX_FRM_CTL_CTL_BCK : 0x0;
+   cgx_write(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL, cfg);
+
+   cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_HG2_CONTROL);
+   cfg &= ~CGXX_SMUX_HG2_CONTROL_TX_ENABLE;
+   cfg |= tx_pause ? CGXX_SMUX_HG2_CONTROL_TX_ENABLE : 0x0;
+   cgx_write(cgx, lmac_id, CGXX_SMUX_HG2_CONTROL, cfg);
+
+   /* allow intra packet hg2 generation */
+   cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_TX_PAUSE_PKT_INTERVAL);
+   cfg &= ~CGXX_SMUX_TX_PAUSE_PKT_HG2_INTRA_EN;
+   cfg |= tx_pause ? CGXX_SMUX_TX_PAUSE_PKT_HG2_INTRA_EN : 0x0;
+   cgx_write(cgx, lmac_id, CGXX_SMUX_TX_PAUSE_PKT_INTERVAL, cfg);
+
+   cfg = cgx_read(cgx, 0, CGXX_CMR_RX_OVR_BP);
+   if (tx_pause) {
+   cfg &= ~CGX_CMR_RX_OVR_BP_EN(lmac_id);
+   } else {
+   cfg |= CGX_CMR_RX_OVR_BP_EN(lmac_id);
+   cfg &= ~CGX_CMR_RX_OVR_BP_BP(lmac_id);
+   }
+
+   cgx_write(cgx, 0, CGXX_CMR_RX_OVR_BP, cfg);
+   return 0;
+}
+
+static int cgx_lmac_enadis_8023_pause_frm(void *cgxd, int lmac_id,
+ u8 tx_pause, u8 rx_pause)
+{
+   struct cgx *cgx = cgxd;
+   u64 cfg;
 
cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL);
cfg &= ~CGX_SMUX_RX_FRM_CTL_CTL_BCK;
@@ -513,6 +561,22 @@ static int cgx_lmac_enadis_pause_frm(void *cgxd, in

[PATCH v2] arm64: dts: msm8916: Enable CoreSight STM component

2021-03-21 Thread Leo Yan
Add DT binding for CoreSight System Trace Macrocell (STM) on msm8916,
which can benefit the CoreSight development on DB410c.

Signed-off-by: Georgi Djakov 
Signed-off-by: Leo Yan 
---

Changes from v1:
* alphabetically and address ordering for DT node; pad addresses with
* zeroes (Stephan Gerhold).

 arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi |  1 +
 arch/arm64/boot/dts/qcom/msm8916.dtsi | 27 +++
 2 files changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi 
b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
index 3a9538e1ec97..2165b7415add 100644
--- a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
+++ b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
@@ -410,6 +410,7 @@ &wcd_codec {
 &funnel0 { status = "okay"; };
 &funnel1 { status = "okay"; };
 &replicator { status = "okay"; };
+&stm { status = "okay"; };
 &tpiu { status = "okay"; };
 
 &smd_rpm_regulators {
diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi 
b/arch/arm64/boot/dts/qcom/msm8916.dtsi
index 402e891a84ab..f02b976480d5 100644
--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
@@ -489,6 +489,26 @@ snoc: interconnect@58 {
 <&rpmcc RPM_SMD_SNOC_A_CLK>;
};
 
+   stm: stm@802000 {
+   compatible = "arm,coresight-stm", "arm,primecell";
+   reg = <0x00802000 0x1000>,
+ <0x0928 0x18>;
+   reg-names = "stm-base", "stm-stimulus-base";
+
+   clocks = <&rpmcc RPM_QDSS_CLK>, <&rpmcc RPM_QDSS_A_CLK>;
+   clock-names = "apb_pclk", "atclk";
+
+   status = "disabled";
+
+   out-ports {
+   port {
+   stm_out: endpoint {
+   remote-endpoint = 
<&funnel0_in7>;
+   };
+   };
+   };
+   };
+
/* System CTIs */
/* CTI 0 - TMC connections */
cti0: cti@81 {
@@ -562,6 +582,13 @@ funnel0_in4: endpoint {
remote-endpoint = 
<&funnel1_out>;
};
};
+
+   port@7 {
+   reg = <7>;
+   funnel0_in7: endpoint {
+   remote-endpoint = <&stm_out>;
+   };
+   };
};
 
out-ports {
-- 
2.25.1



Re: [PATCH v4 2/2] staging: Add driver for XillyUSB (Xillybus variant for USB)

2021-03-21 Thread Greg KH
On Thu, Mar 11, 2021 at 11:50:33AM +0200, eli.billa...@gmail.com wrote:
> From: Eli Billauer 
> 
> The XillyUSB driver is the USB variant for the Xillybus FPGA IP core.
> Even though it presents a nearly identical API on the FPGA and host,
> it's almost a complete rewrite of the driver: The framework for exchanging
> data on a USB bus is fundamentally different from doing the same with a
> PCIe interface, which leaves very little in common between the existing
> driver and the new one for XillyUSB.
> 
> Signed-off-by: Eli Billauer 
> ---
> 
> Notes:
> Changelog:
> v4:
>   (No changes)
> 
> v3:
>   - Move to staging
>   - Rely on xillybus_class for device file operations
>   - Fix no return value bug in xillyusb_discovery()
>   - Add module parameters for URB buffer size and count

Don't move to staging, let's do this right the first time, it will just
take too much work to get this out of staging instead of the correct way
now.


> 
> v2:
>   - Add comment in Kconfig file, saying XILLYUSB really doesn't depend
> on XILLYBUS (following comment by Randy Dunlap)
>   - Use SEEK_* predefined constants instead of numbers
> 
>  MAINTAINERS |1 +
>  drivers/staging/Kconfig |2 +
>  drivers/staging/Makefile|1 +
>  drivers/staging/xillyusb/Kconfig|   20 +
>  drivers/staging/xillyusb/Makefile   |6 +
>  drivers/staging/xillyusb/TODO   |   13 +
>  drivers/staging/xillyusb/xillyusb.c | 2184 +++
>  7 files changed, 2227 insertions(+)
>  create mode 100644 drivers/staging/xillyusb/Kconfig
>  create mode 100644 drivers/staging/xillyusb/Makefile
>  create mode 100644 drivers/staging/xillyusb/TODO
>  create mode 100644 drivers/staging/xillyusb/xillyusb.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index d92f85ca831d..1bf73b132e31 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -19749,6 +19749,7 @@ M:Eli Billauer 
>  L:   linux-kernel@vger.kernel.org
>  S:   Supported
>  F:   drivers/char/xillybus/
> +F:   drivers/staging/xillyusb/
>  
>  XLP9XX I2C DRIVER
>  M:   George Cherian 
> diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
> index b22f73d7bfc4..6fcbc6f90224 100644
> --- a/drivers/staging/Kconfig
> +++ b/drivers/staging/Kconfig
> @@ -114,4 +114,6 @@ source "drivers/staging/wfx/Kconfig"
>  
>  source "drivers/staging/hikey9xx/Kconfig"
>  
> +source "drivers/staging/xillyusb/Kconfig"
> +
>  endif # STAGING
> diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
> index 2245059e69c7..42dfd6a4ca28 100644
> --- a/drivers/staging/Makefile
> +++ b/drivers/staging/Makefile
> @@ -47,3 +47,4 @@ obj-$(CONFIG_QLGE)  += qlge/
>  obj-$(CONFIG_WIMAX)  += wimax/
>  obj-$(CONFIG_WFX)+= wfx/
>  obj-y+= hikey9xx/
> +obj-$(CONFIG_XILLYUSB)   += xillyusb/
> diff --git a/drivers/staging/xillyusb/Kconfig 
> b/drivers/staging/xillyusb/Kconfig
> new file mode 100644
> index ..af7251104b42
> --- /dev/null
> +++ b/drivers/staging/xillyusb/Kconfig
> @@ -0,0 +1,20 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# XillyUSB devices
> +#
> +
> +config XILLYUSB
> + tristate "Xillybus generic FPGA interface for USB"
> + depends on USB
> + select CRC32
> + select XILLYBUS_CLASS

Depend on it, don't select it.

> + help
> +   XillyUSB is the Xillybus variant which uses USB for communicating
> +   with the FPGA.
> +
> +   Xillybus is a generic interface for peripherals designed on
> +   programmable logic (FPGA). The driver probes the hardware for
> +   its capabilities, and creates device files accordingly.
> +
> +   Set to M if you want Xillybus to use USB for communicating with
> +   the FPGA.

Module name?

> diff --git a/drivers/staging/xillyusb/Makefile 
> b/drivers/staging/xillyusb/Makefile
> new file mode 100644
> index ..1b45211992f5
> --- /dev/null
> +++ b/drivers/staging/xillyusb/Makefile
> @@ -0,0 +1,6 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# Makefile for XillyUSB driver
> +#
> +
> +obj-$(CONFIG_XILLYUSB)   += xillyusb.o
> diff --git a/drivers/staging/xillyusb/TODO b/drivers/staging/xillyusb/TODO
> new file mode 100644
> index ..0cb6a005ada4
> --- /dev/null
> +++ b/drivers/staging/xillyusb/TODO
> @@ -0,0 +1,13 @@
> +XillyUSB driver
> +===
> +
> +This driver is the USB counterpart for the driver at drivers/char/xillybus/.
> +See Documentation/driver-api/xillybus.rst.
> +
> +TODO
> +
> +  - Enhance code reuse with the existing Xillybus driver.
> +
> +  - General code review.

Both should not be a reason for staging.

> +
> +Patches to: Eli Billauer 
> \ No newline at end of file
> diff --git a/drivers/staging/xillyusb/xillyusb.c 
> b/drivers/staging/xillyusb/xillyusb.c
> new file mode 100644
> index ..bcf55c1a380d
> --- /dev/null
> +++ b/drivers/st

Re: [PATCH v4 1/2] char: xillybus: Move class-related functions to new xillybus_class.c

2021-03-21 Thread Greg KH
On Thu, Mar 11, 2021 at 11:50:32AM +0200, eli.billa...@gmail.com wrote:
> From: Eli Billauer 
> 
> This patch is a preparation for adding another related driver, XillyUSB.
> In order to share some code between the existing Xillybus driver and the
> one to be added, some functions are moved to xillybus_class.c
> 
> The header file, xillybus_class.h, is temporarily placed in include/linux/,
> because the new XillyUSB driver is intended as a staging driver for the
> time being.
> 
> Signed-off-by: Eli Billauer 
> ---
> 
> Notes:
> Changelog:
> 
> v4:
>   - Fix error code return value bugs in xillybus_init_chrdev() as 
> detected by
> Smatch test robot, and reported by Dan Carpenter.
> 
> This patch did not exist prior to v3.
> 
>  drivers/char/xillybus/Kconfig  |   4 +
>  drivers/char/xillybus/Makefile |   1 +
>  drivers/char/xillybus/xillybus.h   |  10 +-
>  drivers/char/xillybus/xillybus_class.c | 263 +
>  drivers/char/xillybus/xillybus_core.c  | 181 +++--
>  include/linux/xillybus_class.h |  30 +++
>  6 files changed, 322 insertions(+), 167 deletions(-)
>  create mode 100644 drivers/char/xillybus/xillybus_class.c
>  create mode 100644 include/linux/xillybus_class.h
> 
> diff --git a/drivers/char/xillybus/Kconfig b/drivers/char/xillybus/Kconfig
> index 130dbdce858f..e7800f025249 100644
> --- a/drivers/char/xillybus/Kconfig
> +++ b/drivers/char/xillybus/Kconfig
> @@ -3,10 +3,14 @@
>  # Xillybus devices
>  #
>  
> +config XILLYBUS_CLASS
> + tristate
> +
>  config XILLYBUS
>   tristate "Xillybus generic FPGA interface"
>   depends on PCI || OF
>   select CRC32
> + select XILLYBUS_CLASS

depends on, do not select.



Re: [PATCH v4 1/2] char: xillybus: Move class-related functions to new xillybus_class.c

2021-03-21 Thread Greg KH
On Thu, Mar 11, 2021 at 11:50:32AM +0200, eli.billa...@gmail.com wrote:
> +EXPORT_SYMBOL(xillybus_init_chrdev);

Given the license for this code, perhaps EXPORT_SYMBOL_GPL()?

I have to ask :)

thanks,

greg k-h


[PATCH] crypto: nx: fix incorrect kernel-doc comment syntax in files

2021-03-21 Thread Aditya Srivastava
The opening comment mark '/**' is used for highlighting the beginning of
kernel-doc comments.
There are certain files in drivers/crypto/nx, which follow this syntax,
but the content inside does not comply with kernel-doc.
Such lines were probably not meant for kernel-doc parsing, but are parsed
due to the presence of kernel-doc like comment syntax(i.e, '/**'), which
causes unexpected warnings from kernel-doc.

E.g., presence of kernel-doc like comment in the header lines for
drivers/crypto/nx/nx-sha256.c at header causes these warnings:
"warning: Function parameter or member 'tfm' not described in 
'nx_crypto_ctx_sha256_init'"
"warning: expecting prototype for SHA(). Prototype was for 
nx_crypto_ctx_sha256_init() instead"

Similarly for other files too.

Provide a simple fix by replacing such occurrences with general comment
format, i.e. '/*', to prevent kernel-doc from parsing it.

Signed-off-by: Aditya Srivastava 
---
* Applies perfectly on next-20210319

 drivers/crypto/nx/nx-aes-cbc.c  | 2 +-
 drivers/crypto/nx/nx-aes-ccm.c  | 2 +-
 drivers/crypto/nx/nx-aes-ctr.c  | 2 +-
 drivers/crypto/nx/nx-aes-ecb.c  | 2 +-
 drivers/crypto/nx/nx-aes-gcm.c  | 2 +-
 drivers/crypto/nx/nx-aes-xcbc.c | 2 +-
 drivers/crypto/nx/nx-sha256.c   | 2 +-
 drivers/crypto/nx/nx-sha512.c   | 2 +-
 drivers/crypto/nx/nx.c  | 2 +-
 drivers/crypto/nx/nx_debugfs.c  | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/crypto/nx/nx-aes-cbc.c b/drivers/crypto/nx/nx-aes-cbc.c
index 92e921eceed7..d6314ea9ae89 100644
--- a/drivers/crypto/nx/nx-aes-cbc.c
+++ b/drivers/crypto/nx/nx-aes-cbc.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
  * AES CBC routines supporting the Power 7+ Nest Accelerators driver
  *
  * Copyright (C) 2011-2012 International Business Machines Inc.
diff --git a/drivers/crypto/nx/nx-aes-ccm.c b/drivers/crypto/nx/nx-aes-ccm.c
index 4c9362eebefd..e7384d107573 100644
--- a/drivers/crypto/nx/nx-aes-ccm.c
+++ b/drivers/crypto/nx/nx-aes-ccm.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
  * AES CCM routines supporting the Power 7+ Nest Accelerators driver
  *
  * Copyright (C) 2012 International Business Machines Inc.
diff --git a/drivers/crypto/nx/nx-aes-ctr.c b/drivers/crypto/nx/nx-aes-ctr.c
index 6d5ce1a66f1e..13f518802343 100644
--- a/drivers/crypto/nx/nx-aes-ctr.c
+++ b/drivers/crypto/nx/nx-aes-ctr.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
  * AES CTR routines supporting the Power 7+ Nest Accelerators driver
  *
  * Copyright (C) 2011-2012 International Business Machines Inc.
diff --git a/drivers/crypto/nx/nx-aes-ecb.c b/drivers/crypto/nx/nx-aes-ecb.c
index 77e338dc33f1..7a729dc2bc17 100644
--- a/drivers/crypto/nx/nx-aes-ecb.c
+++ b/drivers/crypto/nx/nx-aes-ecb.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
  * AES ECB routines supporting the Power 7+ Nest Accelerators driver
  *
  * Copyright (C) 2011-2012 International Business Machines Inc.
diff --git a/drivers/crypto/nx/nx-aes-gcm.c b/drivers/crypto/nx/nx-aes-gcm.c
index 19c6ed5baea4..fc9baca13920 100644
--- a/drivers/crypto/nx/nx-aes-gcm.c
+++ b/drivers/crypto/nx/nx-aes-gcm.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
  * AES GCM routines supporting the Power 7+ Nest Accelerators driver
  *
  * Copyright (C) 2012 International Business Machines Inc.
diff --git a/drivers/crypto/nx/nx-aes-xcbc.c b/drivers/crypto/nx/nx-aes-xcbc.c
index 48dc1c98ca52..eb5c8f689360 100644
--- a/drivers/crypto/nx/nx-aes-xcbc.c
+++ b/drivers/crypto/nx/nx-aes-xcbc.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
  * AES XCBC routines supporting the Power 7+ Nest Accelerators driver
  *
  * Copyright (C) 2011-2012 International Business Machines Inc.
diff --git a/drivers/crypto/nx/nx-sha256.c b/drivers/crypto/nx/nx-sha256.c
index 90d9a37a57f6..b0ad665e4bda 100644
--- a/drivers/crypto/nx/nx-sha256.c
+++ b/drivers/crypto/nx/nx-sha256.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
  * SHA-256 routines supporting the Power 7+ Nest Accelerators driver
  *
  * Copyright (C) 2011-2012 International Business Machines Inc.
diff --git a/drivers/crypto/nx/nx-sha512.c b/drivers/crypto/nx/nx-sha512.c
index eb8627a0f317..c29103a1a0b6 100644
--- a/drivers/crypto/nx/nx-sha512.c
+++ b/drivers/crypto/nx/nx-sha512.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
  * SHA-512 routines supporting the Power 7+ Nest Accelerators driver
  *
  * Copyright (C) 2011-2012 International Business Machines Inc.
diff --git a/drivers/crypto/nx/nx.c b/drivers/crypto/nx/nx.c
index 1d0e8a1ba160..13bb705ba6a4 100644
--- a/drivers/crypto/nx/nx.c
+++ b/drivers/crypto/nx/nx.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
  * Routines supporting the Power 7+ Nest Accelerators driver
  *
  * Copyright (C) 2011-2012 International Business Machines Inc.
diff --git a/drivers/crypto/nx/nx_debugfs.c b/drivers

Re: linux-next: Tree for Mar 19

2021-03-21 Thread Michael Ellerman
Miguel Ojeda  writes:
> On Sat, Mar 20, 2021 at 7:49 AM Miguel Ojeda
>  wrote:
>>
>> Reproduced on s390. However, under defconfig, one also needs to revert
>> kernel/livepatch/core.c to avoid triggering the assert, i.e.:
>
> Stephen: I will put this in rust-next so that others don't see
> problems on their side and test it with a allmodconfig for powerpc and
> s390 -- is it Monday the next round, right?

Yes. But Monday in UTC+11 :)

cheers


Re: [PATCH 00/14] Initial support for Nuvoton WPCM450 BMC SoC

2021-03-21 Thread Jonathan Neuschäfer
On Sun, Mar 21, 2021 at 01:07:53PM +0200, Tomer Maimon wrote:
> Hi Jonathan,
> 
> Thanks a lot for trying to add WPCM450.
> 
> Hoever WPCM450 is in EOL for several years and we are not supporting this
> product anymore.
> As you said it is only available in the secondary market.
> 
> Due to it is better not to add the WPCM450 under Nuvoton maintenance.

I understand. I will instead add a new, separate section for WPCM450 to
the MAINTAINERS file.

> Again we highly appreciate your support and time on NPCM750 patches.

I expect there will be some more cooperation, because the SoCs share
some architectural similarity, for example the 100Mbit Ethernet
controller.


Best regards,
Jonathan


signature.asc
Description: PGP signature


[GIT PULL] USB/Thunderbolt driver fixes for 5.12-rc4

2021-03-21 Thread Greg KH
The following changes since commit 1e28eed17697bcf343c6743f0028cc3b5dd88bf0:

  Linux 5.12-rc3 (2021-03-14 14:41:02 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git tags/usb-5.12-rc4

for you to fetch changes up to 2b8c956ea6ba896ec18ae36c2684ecfa04c1f479:

  usb: typec: tcpm: Skip sink_cap query only when VDM sm is busy (2021-03-18 
09:47:47 +0100)


USB / Thunderbolt driver fixes for 5.12-rc4

Here are some small Thunderbolt and USB driver fixes for some reported
issues:
- thunderbolt fixes for minor problems
- typec fixes for power issues
- usb-storage quirk addition
- usbip bugfix
- dwc3 bugfix when stopping transfers
- cdnsp bugfix for isoc transfers
- gadget use-after-free fix

All have been in linux-next this week with no reported issues.

Signed-off-by: Greg Kroah-Hartman 


Alan Stern (1):
  usb-storage: Add quirk to defeat Kindle's automatic unload

Badhri Jagan Sridharan (2):
  usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy-
  usb: typec: tcpm: Skip sink_cap query only when VDM sm is busy

Colin Ian King (1):
  usbip: Fix incorrect double assignment to udc->ud.tcp_rx

Elias Rudberg (1):
  usb: typec: Remove vdo[3] part of tps6598x_rx_identity_reg struct

Greg Kroah-Hartman (2):
  Merge tag 'thunderbolt-for-v5.12-rc4' of 
git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-linus
  Merge tag 'usb-v5.12-rc4' of 
git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb into usb-linus

Jim Lin (1):
  usb: gadget: configfs: Fix KASAN use-after-free

Mika Westerberg (2):
  thunderbolt: Initialize HopID IDAs in tb_switch_alloc()
  thunderbolt: Increase runtime PM reference count on DP tunnel discovery

Pawel Laszczak (1):
  usb: cdnsp: Fixes incorrect value in ISOC TRB

Wesley Cheng (1):
  usb: dwc3: gadget: Prevent EP queuing while stopping transfers

 drivers/thunderbolt/switch.c   | 18 --
 drivers/thunderbolt/tb.c   |  4 
 drivers/usb/cdns3/cdnsp-ring.c |  5 -
 drivers/usb/dwc3/gadget.c  | 11 +--
 drivers/usb/gadget/configfs.c  | 14 ++
 drivers/usb/storage/transport.c|  7 +++
 drivers/usb/storage/unusual_devs.h | 12 
 drivers/usb/typec/tcpm/tcpm.c  | 11 +--
 drivers/usb/typec/tps6598x.c   |  1 -
 drivers/usb/usbip/vudc_sysfs.c |  2 +-
 include/linux/usb_usual.h  |  2 ++
 11 files changed, 62 insertions(+), 25 deletions(-)


[GIT PULL] Staging/IIO driver fixes for 5.12-rc4

2021-03-21 Thread Greg KH
The following changes since commit 1e28eed17697bcf343c6743f0028cc3b5dd88bf0:

  Linux 5.12-rc3 (2021-03-14 14:41:02 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
tags/staging-5.12-rc4

for you to fetch changes up to 2cafd46a714af1e55354bc6dcea9dcc13f9475b5:

  staging: vt665x: fix alignment constraints (2021-03-18 10:21:46 +0100)


Staging/IIO driver fixes for 5.12-rc4

Here are some small staging and IIO driver fixes for 5.12-rc4.

They include:
- MAINTAINERS changes for the move of the staging mailing list
- comedi driver fixes to get request_irq() to work correctly
- counter driver fixes for reported issues with iio devices
- tiny iio driver fixes for reported issues.

All of these have been in linux-next with no reported problems.

Signed-off-by: Greg Kroah-Hartman 


Alexandru Ardelean (1):
  iio: adc: adi-axi-adc: add proper Kconfig dependencies

Dan Carpenter (1):
  iio: adis16400: Fix an error code in adis16400_initial_setup()

Dinghao Liu (1):
  iio: gyro: mpu3050: Fix error handling in mpu3050_trigger_handler

Edmundo Carmona Antoranz (1):
  staging: vt665x: fix alignment constraints

Fabrice Gasnier (2):
  counter: stm32-timer-cnt: fix ceiling write max value
  counter: stm32-timer-cnt: fix ceiling miss-alignment with reload register

Greg Kroah-Hartman (3):
  Merge tag 'iio-fixes-for-5.12a' of 
https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus
  MAINTAINERS: move some real subsystems off of the staging mailing list
  MAINTAINERS: move the staging subsystem to lists.linux.dev

Jonathan Albrieux (1):
  iio:adc:qcom-spmi-vadc: add default scale to LR_MUX2_BAT_ID channel

Jonathan Cameron (1):
  iio:adc:stm32-adc: Add HAS_IOMEM dependency

Linus Walleij (1):
  iio: adc: ab8500-gpadc: Fix off by 10 to 3

Tong Zhang (2):
  staging: comedi: cb_pcidas: fix request_irq() warn
  staging: comedi: cb_pcidas64: fix request_irq() warn

Wilfried Wessner (1):
  iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask

William Breathitt Gray (1):
  counter: stm32-timer-cnt: Report count function when SLAVE_MODE_DISABLED

Ye Xiang (3):
  iio: hid-sensor-prox: Fix scale not correct issue
  iio: hid-sensor-humidity: Fix alignment issue of timestamp channel
  iio: hid-sensor-temperature: Fix issues of timestamp channel

 MAINTAINERS  |  7 ++-
 drivers/counter/stm32-timer-cnt.c| 55 ++--
 drivers/iio/adc/Kconfig  |  3 ++
 drivers/iio/adc/ab8500-gpadc.c   |  2 +-
 drivers/iio/adc/ad7949.c |  2 +-
 drivers/iio/adc/qcom-spmi-vadc.c |  2 +-
 drivers/iio/gyro/mpu3050-core.c  |  2 +
 drivers/iio/humidity/hid-sensor-humidity.c   | 12 +++---
 drivers/iio/imu/adis16400.c  |  3 +-
 drivers/iio/light/hid-sensor-prox.c  | 13 +-
 drivers/iio/temperature/hid-sensor-temperature.c | 14 +++---
 drivers/staging/comedi/drivers/cb_pcidas.c   |  2 +-
 drivers/staging/comedi/drivers/cb_pcidas64.c |  2 +-
 drivers/staging/vt6655/rxtx.h|  4 +-
 14 files changed, 75 insertions(+), 48 deletions(-)


Re: [PATCH v2] memory: tegra20: Add debug statistics

2021-03-21 Thread Krzysztof Kozlowski
On Fri, 19 Mar 2021 16:09:33 +0300, Dmitry Osipenko wrote:
> Add debug statistics collection support. The statistics is available
> via debugfs in '/sys/kernel/debug/mc/stats', it shows percent of memory
> controller utilization for each memory client. This information is
> intended to help with debugging of memory performance issues, it already
> was proven to be useful by helping to improve memory bandwidth management
> of the display driver.

Applied, thanks!

[1/1] memory: tegra20: Add debug statistics
  commit: 1ca59ca0afde17b75adc519858ccc30375cfad1d

Best regards,
-- 
Krzysztof Kozlowski 


Re: [syzbot] KASAN: use-after-free Read in disk_part_iter_next (2)

2021-03-21 Thread syzbot
syzbot has bisected this issue to:

commit a33df75c6328bf40078b35f2040d8e54d574c357
Author: Christoph Hellwig 
Date:   Sun Jan 24 10:02:41 2021 +

block: use an xarray for disk->part_tbl

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=17989906d0
start commit:   1c273e10 Merge tag 'zonefs-5.12-rc4' of git://git.kernel.o..
git tree:   upstream
final oops: https://syzkaller.appspot.com/x/report.txt?x=14589906d0
console output: https://syzkaller.appspot.com/x/log.txt?x=10589906d0
kernel config:  https://syzkaller.appspot.com/x/.config?x=6abda3336c698a07
dashboard link: https://syzkaller.appspot.com/bug?extid=8fede7e30c7cee0de139
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=13dfe8bed0
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=155a117cd0

Reported-by: syzbot+8fede7e30c7cee0de...@syzkaller.appspotmail.com
Fixes: a33df75c6328 ("block: use an xarray for disk->part_tbl")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection


[PATCH net-next 1/2] net: socket: use BIT() for MSG_*

2021-03-21 Thread menglong8 . dong
From: Menglong Dong 

The bit mask for MSG_* seems a little confused here. Replace it
with BIT() to make it clear to understand.

Signed-off-by: Menglong Dong 
---
 include/linux/socket.h | 71 ++
 1 file changed, 37 insertions(+), 34 deletions(-)

diff --git a/include/linux/socket.h b/include/linux/socket.h
index 385894b4a8bb..d5ebfe30d96b 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -283,42 +283,45 @@ struct ucred {
Added those for 1003.1g not all are supported yet
  */
 
-#define MSG_OOB1
-#define MSG_PEEK   2
-#define MSG_DONTROUTE  4
-#define MSG_TRYHARD 4   /* Synonym for MSG_DONTROUTE for DECnet */
-#define MSG_CTRUNC 8
-#define MSG_PROBE  0x10/* Do not send. Only probe path f.e. for MTU */
-#define MSG_TRUNC  0x20
-#define MSG_DONTWAIT   0x40/* Nonblocking io*/
-#define MSG_EOR 0x80   /* End of record */
-#define MSG_WAITALL0x100   /* Wait for a full request */
-#define MSG_FIN 0x200
-#define MSG_SYN0x400
-#define MSG_CONFIRM0x800   /* Confirm path validity */
-#define MSG_RST0x1000
-#define MSG_ERRQUEUE   0x2000  /* Fetch message from error queue */
-#define MSG_NOSIGNAL   0x4000  /* Do not generate SIGPIPE */
-#define MSG_MORE   0x8000  /* Sender will send more */
-#define MSG_WAITFORONE 0x1 /* recvmmsg(): block until 1+ packets avail */
-#define MSG_SENDPAGE_NOPOLICY 0x1 /* sendpage() internal : do no apply 
policy */
-#define MSG_SENDPAGE_NOTLAST 0x2 /* sendpage() internal : not the last 
page */
-#define MSG_BATCH  0x4 /* sendmmsg(): more messages coming */
-#define MSG_EOF MSG_FIN
-#define MSG_NO_SHARED_FRAGS 0x8 /* sendpage() internal : page frags are 
not shared */
-#define MSG_SENDPAGE_DECRYPTED 0x10 /* sendpage() internal : page may carry
- * plain text and require encryption
- */
-
-#define MSG_ZEROCOPY   0x400   /* Use user data in kernel path */
-#define MSG_FASTOPEN   0x2000  /* Send data in TCP SYN */
-#define MSG_CMSG_CLOEXEC 0x4000/* Set close_on_exec for file
-  descriptor received through
-  SCM_RIGHTS */
+#define MSG_OOBBIT(0)
+#define MSG_PEEK   BIT(1)
+#define MSG_DONTROUTE  BIT(2)
+#define MSG_TRYHARDBIT(2)  /* Synonym for MSG_DONTROUTE for DECnet 
*/
+#define MSG_CTRUNC BIT(3)
+#define MSG_PROBE  BIT(4)  /* Do not send. Only probe path f.e. for MTU
*/
+#define MSG_TRUNC  BIT(5)
+#define MSG_DONTWAIT   BIT(6)  /* Nonblocking io   */
+#define MSG_EORBIT(7)  /* End of record*/
+#define MSG_WAITALLBIT(8)  /* Wait for a full request  */
+#define MSG_FINBIT(9)
+#define MSG_SYNBIT(10)
+#define MSG_CONFIRMBIT(11) /* Confirm path validity*/
+#define MSG_RSTBIT(12)
+#define MSG_ERRQUEUE   BIT(13) /* Fetch message from error queue */
+#define MSG_NOSIGNAL   BIT(14) /* Do not generate SIGPIPE  */
+#define MSG_MORE   BIT(15) /* Sender will send more*/
+#define MSG_WAITFORONE BIT(16) /* recvmmsg(): block until 1+ packets avail */
+#define MSG_SENDPAGE_NOPOLICY  BIT(16) /* sendpage() internal : do no apply 
policy */
+#define MSG_SENDPAGE_NOTLAST   BIT(17) /* sendpage() internal : not the last 
page  */
+#define MSG_BATCH  BIT(18) /* sendmmsg(): more messages coming */
+#define MSG_EOFMSG_FIN
+#define MSG_NO_SHARED_FRAGSBIT(19) /* sendpage() internal : page frags
+* are not shared
+*/
+#define MSG_SENDPAGE_DECRYPTED BIT(20) /* sendpage() internal : page may carry
+* plain text and require encryption
+*/
+
+#define MSG_ZEROCOPY   BIT(26) /* Use user data in kernel path */
+#define MSG_FASTOPEN   BIT(29) /* Send data in TCP SYN */
+#define MSG_CMSG_CLOEXEC   BIT(30) /* Set close_on_exec for file
+* descriptor received through
+* SCM_RIGHTS
+*/
 #if defined(CONFIG_COMPAT)
-#define MSG_CMSG_COMPAT0x8000  /* This message needs 32 bit 
fixups */
+#define MSG_CMSG_COMPATBIT(31) /* This message needs 32 bit 
fixups */
 #else
-#define MSG_CMSG_COMPAT0   /* We never have 32 bit fixups 
*/
+#define MSG_CMSG_COMPAT0   /* We never have 32 bit fixups 
*/
 #endif
 
 
-- 
2.30.2



[PATCH v3] arm64: dts: msm8916: Enable CoreSight STM component

2021-03-21 Thread Leo Yan
From: Georgi Djakov 

Add DT binding for CoreSight System Trace Macrocell (STM) on msm8916,
which can benefit the CoreSight development on DB410c.

Signed-off-by: Georgi Djakov 
Signed-off-by: Leo Yan 
---

Changes from v2:
* Correct for author name.

Changes from v1:
* alphabetically and address ordering for DT node; pad addresses with
  zeroes (Stephan Gerhold).

 arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi |  1 +
 arch/arm64/boot/dts/qcom/msm8916.dtsi | 27 +++
 2 files changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi 
b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
index 3a9538e1ec97..2165b7415add 100644
--- a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
+++ b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
@@ -410,6 +410,7 @@ &wcd_codec {
 &funnel0 { status = "okay"; };
 &funnel1 { status = "okay"; };
 &replicator { status = "okay"; };
+&stm { status = "okay"; };
 &tpiu { status = "okay"; };
 
 &smd_rpm_regulators {
diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi 
b/arch/arm64/boot/dts/qcom/msm8916.dtsi
index 402e891a84ab..f02b976480d5 100644
--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
@@ -489,6 +489,26 @@ snoc: interconnect@58 {
 <&rpmcc RPM_SMD_SNOC_A_CLK>;
};
 
+   stm: stm@802000 {
+   compatible = "arm,coresight-stm", "arm,primecell";
+   reg = <0x00802000 0x1000>,
+ <0x0928 0x18>;
+   reg-names = "stm-base", "stm-stimulus-base";
+
+   clocks = <&rpmcc RPM_QDSS_CLK>, <&rpmcc RPM_QDSS_A_CLK>;
+   clock-names = "apb_pclk", "atclk";
+
+   status = "disabled";
+
+   out-ports {
+   port {
+   stm_out: endpoint {
+   remote-endpoint = 
<&funnel0_in7>;
+   };
+   };
+   };
+   };
+
/* System CTIs */
/* CTI 0 - TMC connections */
cti0: cti@81 {
@@ -562,6 +582,13 @@ funnel0_in4: endpoint {
remote-endpoint = 
<&funnel1_out>;
};
};
+
+   port@7 {
+   reg = <7>;
+   funnel0_in7: endpoint {
+   remote-endpoint = <&stm_out>;
+   };
+   };
};
 
out-ports {
-- 
2.25.1



[PATCH net-next 0/2] net: socket: use BIT() for MSG_* and fix MSG_CMSG_COMPAT

2021-03-21 Thread menglong8 . dong
From: Menglong Dong 

In the first patch, I use BIT() for MSG_* to make the code tidier.

Directly use BIT() for MSG_* will be a bit problematic, because
'msg_flags' is defined as 'int' somewhere, and MSG_CMSG_COMPAT
will make it become negative, just like what Guenter Roeck
reported here:

https://lore.kernel.org/netdev/20210317013758.ga134...@roeck-us.net

So in the second patch, I change MSG_CMSG_COMPAT to BIT(21), as
David Laight suggested. MSG_CMSG_COMPAT is an internal value,
which is't used in userspace, so this change works.


Menglong Dong (2):
  net: socket: use BIT() for MSG_*
  net: socket: change MSG_CMSG_COMPAT to BIT(21)

 include/linux/socket.h | 72 ++
 1 file changed, 38 insertions(+), 34 deletions(-)

-- 
2.31.0



[PATCH net-next 2/2] net: socket: change MSG_CMSG_COMPAT to BIT(21)

2021-03-21 Thread menglong8 . dong
From: Menglong Dong 

Currently, MSG_CMSG_COMPAT is defined as '1 << 31'. However, 'msg_flags'
is defined with type of 'int' somewhere, such as 'packet_recvmsg' and
other recvmsg functions:

static int packet_recvmsg(struct socket *sock, struct msghdr *msg,
  size_t len,
  int flags)

If MSG_CMSG_COMPAT is set in 'flags', it's value will be negative.
Once it perform bit operations with MSG_*, the upper 32 bits of
the result will be set, just like what Guenter Roeck explained
here:

https://lore.kernel.org/netdev/20210317013758.ga134...@roeck-us.net

As David Laight suggested, fix this by change MSG_CMSG_COMPAT to
some value else. MSG_CMSG_COMPAT is an internal value, which is't
used in userspace, so this change works.

Reported-by: Guenter Roeck 
Signed-off-by: Menglong Dong 
---
 include/linux/socket.h | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/linux/socket.h b/include/linux/socket.h
index d5ebfe30d96b..317b2933f499 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -312,17 +312,18 @@ struct ucred {
 * plain text and require encryption
 */
 
+#if defined(CONFIG_COMPAT)
+#define MSG_CMSG_COMPATBIT(21) /* This message needs 32 bit 
fixups */
+#else
+#define MSG_CMSG_COMPAT0   /* We never have 32 bit fixups 
*/
+#endif
+
 #define MSG_ZEROCOPY   BIT(26) /* Use user data in kernel path */
 #define MSG_FASTOPEN   BIT(29) /* Send data in TCP SYN */
 #define MSG_CMSG_CLOEXEC   BIT(30) /* Set close_on_exec for file
 * descriptor received through
 * SCM_RIGHTS
 */
-#if defined(CONFIG_COMPAT)
-#define MSG_CMSG_COMPATBIT(31) /* This message needs 32 bit 
fixups */
-#else
-#define MSG_CMSG_COMPAT0   /* We never have 32 bit fixups 
*/
-#endif
 
 
 /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
-- 
2.31.0



Re: [PATCH v2] arm64: dts: msm8916: Enable CoreSight STM component

2021-03-21 Thread Leo Yan
On Sun, Mar 21, 2021 at 08:11:05PM +0800, Leo Yan wrote:
> Add DT binding for CoreSight System Trace Macrocell (STM) on msm8916,
> which can benefit the CoreSight development on DB410c.
> 
> Signed-off-by: Georgi Djakov 
> Signed-off-by: Leo Yan 

When I rebased this patch, I didn't know why the patch auther's name was
changed unexpectly.  So have sent patch v3 to correct it.

Sorry for spamming.
Leo


Re: [PATCH net-next 2/2] net: socket: change MSG_CMSG_COMPAT to BIT(21)

2021-03-21 Thread Herbert Xu
On Sun, Mar 21, 2021 at 08:39:29PM +0800, menglong8.d...@gmail.com wrote:
>
> diff --git a/include/linux/socket.h b/include/linux/socket.h
> index d5ebfe30d96b..317b2933f499 100644
> --- a/include/linux/socket.h
> +++ b/include/linux/socket.h
> @@ -312,17 +312,18 @@ struct ucred {
>* plain text and require encryption
>*/
>  
> +#if defined(CONFIG_COMPAT)
> +#define MSG_CMSG_COMPAT  BIT(21) /* This message needs 32 bit 
> fixups */
> +#else
> +#define MSG_CMSG_COMPAT  0   /* We never have 32 bit fixups 
> */
> +#endif
> +
>  #define MSG_ZEROCOPY BIT(26) /* Use user data in kernel path */
>  #define MSG_FASTOPEN BIT(29) /* Send data in TCP SYN */
>  #define MSG_CMSG_CLOEXEC BIT(30) /* Set close_on_exec for file
>* descriptor received through
>* SCM_RIGHTS
>*/
> -#if defined(CONFIG_COMPAT)
> -#define MSG_CMSG_COMPAT  BIT(31) /* This message needs 32 bit 
> fixups */
> -#else
> -#define MSG_CMSG_COMPAT  0   /* We never have 32 bit fixups 
> */
> -#endif

Shouldn't you add some comment here to stop people from trying to
use BIT(31) in the future?

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH -tip v3 08/11] kprobes: Setup instruction pointer in __kretprobe_trampoline_handler

2021-03-21 Thread Masami Hiramatsu
On Fri, 19 Mar 2021 21:23:12 +0900
Masami Hiramatsu  wrote:

> To simplify the stacktrace with pt_regs from kretprobe handler,
> set the correct return address to the instruction pointer in
> the pt_regs before calling kretprobe handlers.
> 

Oops, now I also find this breaks kretprobe for arm. It seems
not enough registers stores. I need to fix the arm kprobe code
too.

In arch/arm/include/uapi/asm/ptrace.h,

---
#define ARM_pc  uregs[15]
---

And in arch/arm/probes/kprobes/core.c,

---
/*
 * When a retprobed function returns, trampoline_handler() is called,
 * calling the kretprobe's handler. We construct a struct pt_regs to
 * give a view of registers r0-r11 to the user return-handler.  This is
 * not a complete pt_regs structure, but that should be plenty sufficient
 * for kretprobe handlers which should normally be interested in r0 only
 * anyway.
 */
void __naked __kprobes kretprobe_trampoline(void)
{
__asm__ __volatile__ (
"stmdb  sp!, {r0 - r11} \n\t"
---

So, changing regs->ARM_pc will break a stack entry. I need to expand
it to r15.

Thanks,

> Suggested-by: Josh Poimboeuf 
> Signed-off-by: Masami Hiramatsu 
> ---
>  Changes in v3:
>   - Cast the correct_ret_addr to unsigned long.
> ---
>  kernel/kprobes.c |3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index cf19edc038e4..4ce3e6f5d28d 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1914,6 +1914,9 @@ unsigned long __kretprobe_trampoline_handler(struct 
> pt_regs *regs,
>   BUG_ON(1);
>   }
>  
> + /* Set the instruction pointer to the correct address */
> + instruction_pointer_set(regs, (unsigned long)correct_ret_addr);
> +
>   /* Run them. */
>   first = current->kretprobe_instances.first;
>   while (first) {
> 


-- 
Masami Hiramatsu 


Re: [PATCH 8/9] vfio/pci: export nvlink2 support into vendor vfio_pci drivers

2021-03-21 Thread Jason Gunthorpe
On Fri, Mar 19, 2021 at 10:40:28PM -0600, Alex Williamson wrote:

> > Well, today we don't, but Max here adds id_table's to the special
> > devices and a MODULE_DEVICE_TABLE would come too if we do the flavours
> > thing below.
> 
> I think the id_tables are the wrong approach for IGD and NVLink
> variants.

I really disagree with this. Checking for some random bits in firmware
and assuming that every device made forever into the future works with
this check is not a good way to do compatibility. Christoph made the
same point.

We have good processes to maintain id tables, I don't see this as a
problem.

> > As-is driver_override seems dangerous as overriding the matching table
> > could surely allow root userspace to crash the machine. In situations
> > with trusted boot/signed modules this shouldn't be.
> 
> When we're dealing with meta-drivers that can bind to anything, we
> shouldn't rely on the match, but should instead verify the driver is
> appropriate in the probe callback.  Even without driver_override,
> there's the new_id mechanism.  Either method allows the root user to
> break driver binding.  Greg has previously stated something to the
> effect that users get to keep all the pieces when they break something
> by manipulating driver binding.

Yes, but that is a view where root is allowed to break the kernel, we
now have this optional other world where that is not allowed and root
access to lots of dangerous things are now disabled.

new_id and driver_override should probably be in that disable list
too..

> > While that might not seem too bad with these simple drivers, at least
> > the mlx5 migration driver will have a large dependency tree and pull
> > in lots of other modules. Even Max's sample from v1 pulls in mlx5_core.ko
> > and a bunch of other stuff in its orbit.
> 
> Luckily the mlx5 driver doesn't need to be covered by compatibility
> support, so we don't need to set a softdep for it and the module could
> be named such that a wildcard driver_override of vfio_pci* shouldn't
> logically include that driver.  Users can manually create their own
> modprobe.d softdep entry if they'd like to include it.  Otherwise
> userspace would need to know to bind to it specifically.

But now you are giving up on the whole point, which was to
automatically load the correct specific module without special admin
involvement!

> > This is why I want to try for fine grained autoloading first. It
> > really is the elegant solution if we can work it out.
> 
> I just don't see how we create a manageable change to userspace.

I'm not sure I understand. Even if we add a new sysfs to set some
flavour then that is a pretty trivial change for userspace to move
from driver_override?

> > I don't think we should over-focus on these two firmware triggered
> > examples. I looked at the Intel GPU driver and it already only reads
> > the firmware thing for certain PCI ID's, we can absolutely generate a
> > narrow match table for it. Same is true for the NVIDIA GPU.
> 
> I'm not sure we can make this assertion, both only care about the type
> of device and existence of associated firmware tables.  

Well, I read through the Intel GPU driver and this is how I felt it
works. It doesn't even check the firmware bit unless certain PCI IDs
are matched first.

For NVIDIA GPU Max checked internally and we saw it looks very much
like how Intel GPU works. Only some PCI IDs trigger checking on the
feature the firmware thing is linked to.

My point is: the actual *drivers* consuming these firmware features do
*not* blindly match every PCI device and check for the firmware
bit. They all have narrow matches and further only try to use the
firmware thing for some subset of PCI IDs that the entire driver
supports.

Given that the actual drivers work this way there is no technical
reason vfio-pci can't do this as well.

We don't have to change them of course, they can stay as is if people
feel really strongly.

> > Even so, I'm not *so* worried about "over matching" - if IGD or the
> > nvidia stuff load on a wide set of devices then they can just not
> > enable their extended stuff. It wastes some kernel memory, but it is
> > OK.
> 
> I'd rather they bind to the base vfio-pci driver if their extended
> features are not available.

Sure it would be nice, but functionally it is no different.

> > And if some driver *really* gets stuck here the true answer is to
> > improve the driver core match capability.
> > 
> > > devices in the deny-list and non-endpoint devices.  Many drivers
> > > clearly place implicit trust in their id_table, others don't.  In the
> > > case of meta drivers, I think it's fair to make use of the latter
> > > approach.  
> > 
> > Well, AFAIK, the driver core doesn't have a 'try probe, if it fails
> > then try another driver' approach. One device, one driver. Am I
> > missing something?
> 
> If the driver probe callback fails, really_probe() returns 0 with the
> comment:
> 
> /*
>  * Ignore errors ret

DID YOU RECEIVE MY MAIL?

2021-03-21 Thread Abdwabbo Maddah
-- 
Dear,
I had sent you a mail but i don't think you received it that's why am
writing you again.It is important you get back to me as soon as you
can.
Abd-Wabbo Maddah


[PATCH] MAINTAINERS: Combine "QLOGIC QLGE 10Gb ETHERNET DRIVER" sections into one

2021-03-21 Thread Jonathan Neuschäfer
There ended up being two sections with the same title. Combine the two
into one section.

Signed-off-by: Jonathan Neuschäfer 
Cc: Manish Chopra 
Cc: Coiby Xu 
---
 MAINTAINERS | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index d92f85ca831d3..a922afdf080d9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14708,15 +14708,11 @@ F:drivers/net/ethernet/qlogic/qlcnic/
 QLOGIC QLGE 10Gb ETHERNET DRIVER
 M: Manish Chopra 
 M: gr-linux-nic-...@marvell.com
-L: net...@vger.kernel.org
-S: Supported
-F: drivers/staging/qlge/
-
-QLOGIC QLGE 10Gb ETHERNET DRIVER
 M: Coiby Xu 
 L: net...@vger.kernel.org
-S: Maintained
+S: Supported
 F: Documentation/networking/device_drivers/qlogic/qlge.rst
+F: drivers/staging/qlge/

 QM1D1B0004 MEDIA DRIVER
 M: Akihiro Tsukada 
--
2.30.2



Re: [PATCH V3] exit: trigger panic when global init has exited

2021-03-21 Thread qianli zhao
Hi,Oleg

> How? Perhaps I missed something again, but I don't think this is possible.

> zap_pid_ns_processes() simply won't be called, find_child_reaper() will
> see the !PF_EXITING thread which calls panic().

> So I think this should be documented somehow, at least in the changelog.

This problem occurs when both two init threads enter the do_exit,
One of the init thread is syscall sys_exit_group,and set SIGNAL_GROUP_EXIT
The other init thread perform ret_to_user()->get_signal() and found
SIGNAL_GROUP_EXIT is set,then do_group_exit()->do_exit(),since there
are no alive init threads it finally goes to
zap_pid_ns_processes() and BUG().

Please refer to the sequence diagram below(that has been written into
the changelog),and callstack is also below:
kernel log:
[   24.705376] Kernel panic - not syncing: Attempted to kill init!
exitcode=0x7f00
[   24.705382] CPU: 4 PID: 552 Comm: init Tainted: G S O
4.14.180-perf-g4483caa8ae80-dirty #1
[   24.705390] kernel BUG at include/linux/pid_namespace.h:98!

PID: 1  TASK: ffc973126900  CPU: 7   COMMAND: "init"
 #0 [ff800805ba60] perf_trace_kernel_panic_late at ff99ac0bcbcc
 #1 [ff800805bac0] die at ff99ac08dc64
 #2 [ff800805bb10] bug_handler at ff99ac08e398
 #3 [ff800805bbc0] brk_handler at ff99ac08529c
 #4 [ff800805bc80] do_debug_exception at ff99ac0814e4
->exception

/home/work/courbet-r-stable-build/kernel/msm-4.14/include/linux/pid_namespace.h:
98
96static inline void zap_pid_ns_processes(struct pid_namespace *ns)
97{
98 BUG();
99}
 #5 [ff800805bdf0] el1_dbg at ff99ac083298
 #6 [ff800805be20] do_exit at ff99ac0c22e8
 #7 [ff800805be80] do_group_exit at ff99ac0c2658
 #8 [ff800805beb0] sys_exit_group at ff99ac0c266c
 #9 [ff800805bff0] el0_svc_naked at ff99ac083cfc

PID: 552TASK: ffc9613c8f00  CPU: 4   COMMAND: "init"
 #0 [ff801455b870] __delay at ff99ad32cc14
 #1 [ff801455b8b0] __const_udelay at ff99ad32cd10
 #2 [ff801455b8c0] msm_trigger_wdog_bite at ff99ac5d5be0
 #3 [ff801455b980] do_msm_restart at ff99a3f8
 #4 [ff801455b9b0] machine_restart at ff99ac085dd0
 #5 [ff801455b9d0] emergency_restart at ff99ac0eb6dc
 #6 [ff801455baf0] panic at ff99ac0bd008
   > /home/work/courbet-r-stable-build/kernel/msm-4.14/kernel/exit.c:
842
836 if (group_dead) {
837 /*
838 * If the last thread of global init has exited, panic
839 * immediately to get a useable coredump.
840 */
841 if (unlikely(is_global_init(tsk)))
842 panic("Attempted to kill init! exitcode=0x%08x\n",
843 tsk->signal->group_exit_code ?: (int)code);

 #7 [ff801455bb70] do_exit at ff99ac0c257c
#8 [ff801455bbd0] do_group_exit at ff99ac0c2644
#9 [ff801455bcc0] get_signal at ff99ac0d1384
#10 [ff801455be60] do_notify_resume at ff99ac08b2a8
#11 [ff801455bff0] work_pending at ff99ac083b8c

core4  core7
... sys_exit_group()
do_group_exit()
  - sig->flags = SIGNAL_GROUP_EXIT
  - zap_other_threads()
   do_exit() //PF_EXITING is set
ret_to_user()
do_notify_resume()
get_signal()
- signal_group_exit
- goto fatal;
do_group_exit()
do_exit() //PF_EXITING is set
- panic("Attempted to kill init! exitcode=0x%08x\n")
exit_notify()
find_alive_thread() //no alive
sub-threads
   zap_pid_ns_processes()
//CONFIG_PID_NS is not set
   BUG()

Oleg Nesterov  于2021年3月20日周六 上午12:32写道:
>
> On 03/19, qianli zhao wrote:
> >
> > > But then I don't understand the SIGNAL_GROUP_EXIT check added by your
> > > patch. Do we really need it if we want to avoid zap_pid_ns_processes()
> > > when the global init exits?
> >
> > I think check SIGNAL_GROUP_EXIT is necessary,or panic() will happen
> > after all init sub-threads do_exit(),so the following two situations
> > will happen:
> > 1.According to the timing in the changelog,
> > zap_pid_ns_processes()->BUG() maybe happened.
>
> How? Perhaps I missed something again, but I don't think this is possible.
>
> zap_pid_ns_processes() simply won't be called, find_child_reaper() will
> see the !PF_EXITING thread which calls panic().
>
> So I think this should be documented somehow, at least in the changelog.
>
> Oleg.
>


Re: [PATCH v5 3/3] ARM: imx7d-remarkable2.dts: Initial device tree for reMarkable2

2021-03-21 Thread Fabio Estevam
Hi Alistair,

On Mon, Mar 15, 2021 at 11:27 PM Alistair Francis
 wrote:
>
> The reMarkable2 (https://remarkable.com) is an e-ink tablet based on
> the imx7d SoC.
>
> This commit is based on the DTS provide by reMarkable but ported to the
> latest kernel (instead of 4.14). I have removed references to
> non-upstream devices and have changed the UART so that the console can
> be accessed without having to open up the device via the OTG pogo pins.
>
> Currently the kernel boots, but there is no support for the display.
>
> WiFi is untested (no dispaly or UART RX makes it hard to test), but

"display"

> +   memory {
> +   reg = <0x8000 0x4000>;
> +   };

This should be:

memory@8000 {
 device_type = "memory";
 reg = <0x8000 0x4000>;
};

> +&crypto {
> +   status = "disabled";
> +};

Why do you need to disable this node?

> +&dma_apbh {
> +   status = "disabled";
> +};

Same here.

> +&sdma {
> +   status = "okay";
> +};

No need to enable it in the board file.

> +&iomuxc_lpsr {
> +   pinctrl_digitizer_reg: digitizerreggrp {

This is not referenced from anywhere.


Re: Bootconfig ..too many deep level of header file

2021-03-21 Thread Masami Hiramatsu
Hi Bhaskar,

On Sun, 21 Mar 2021 08:38:56 +0530
Bhaskar Chowdhury  wrote:

>  Hey, Masami
> 
>  I was wondering why so many level of "deep nesting" of a particualr header
>  file like this one :
> 
>  ✔ ~/git-linux/linux/tools/bootconfig/include/linux [patch L|✔]
> 08:34 $ cat bootconfig.h
> /* SPDX-License-Identifier: GPL-2.0 */
> #ifndef _BOOTCONFIG_LINUX_BOOTCONFIG_H
> #define _BOOTCONFIG_LINUX_BOOTCONFIG_H
> 
> #include "../../../../include/linux/bootconfig.h"
> 
> #endif
> 
> I am surely missing some basic stuff...but...anyway, I have taken a peek on 
> other files in the same dir and none have the nesting like that(the include 
> ../ ...line)
> 
> Any specific reason? OR did you thought of keeping all the header file in one 
> paplace(wildly guessing) ...

If you carefully check the number of ../, you can find that it refers the
 /include/linux/bootconfig.h.
Since the bootconfig library code needs bootconfig.h but I don't like to make
a copy of the bootconfig.h under the tools directory, I made a dummy header
file which links to the kernel's bootconfig.h.

Thank you,

-- 
Masami Hiramatsu 


[PATCH] MIPS: generic: Support linking with LLVM ld.lld

2021-03-21 Thread Paul Cercueil
LLVM's ld.lld chokes on the 64-bit sign-extended load addresses. Use
32-bit addresses if the linker is LLVM's ld.lld.

Signed-off-by: Paul Cercueil 
---
 arch/mips/generic/Platform | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/generic/Platform b/arch/mips/generic/Platform
index b871af16b5b6..19b7d92a4ca7 100644
--- a/arch/mips/generic/Platform
+++ b/arch/mips/generic/Platform
@@ -12,8 +12,8 @@
 cflags-$(CONFIG_MACH_INGENIC_SOC)  += 
-I$(srctree)/arch/mips/include/asm/mach-ingenic
 cflags-$(CONFIG_MIPS_GENERIC)  += 
-I$(srctree)/arch/mips/include/asm/mach-generic
 
-load-$(CONFIG_MIPS_GENERIC)+= 0x8010
-zload-$(CONFIG_MIPS_GENERIC)   += 0x8100
+load-$(CONFIG_MIPS_GENERIC)+= $(if 
$(CONFIG_LD_IS_LLD),0x8010,0x8010)
+zload-$(CONFIG_MIPS_GENERIC)   += $(if 
$(CONFIG_LD_IS_LLD),0x8100,0x8100)
 all-$(CONFIG_MIPS_GENERIC) := vmlinux.gz.itb
 
 its-y  := vmlinux.its.S
-- 
2.30.2



Re: [PATCH net-next v2 2/2] net: ipa: fix IPA validation

2021-03-21 Thread Alex Elder

On 3/21/21 3:21 AM, Leon Romanovsky wrote:

On Sat, Mar 20, 2021 at 09:17:29AM -0500, Alex Elder wrote:

There are blocks of IPA code that sanity-check various values, at
compile time where possible.  Most of these checks can be done once
during development but skipped for normal operation.  These checks
permit the driver to make certain assumptions, thereby avoiding the
need for runtime error checking.

The checks are defined conditionally, but not consistently.  In
some cases IPA_VALIDATION enables the optional checks, while in
others IPA_VALIDATE is used.

Fix this by using IPA_VALIDATION consistently.

Signed-off-by: Alex Elder 
---
  drivers/net/ipa/Makefile   | 2 +-
  drivers/net/ipa/gsi_trans.c| 8 
  drivers/net/ipa/ipa_cmd.c  | 4 ++--
  drivers/net/ipa/ipa_cmd.h  | 6 +++---
  drivers/net/ipa/ipa_endpoint.c | 6 +++---
  drivers/net/ipa/ipa_main.c | 6 +++---
  drivers/net/ipa/ipa_mem.c  | 6 +++---
  drivers/net/ipa/ipa_table.c| 6 +++---
  drivers/net/ipa/ipa_table.h| 6 +++---
  9 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ipa/Makefile b/drivers/net/ipa/Makefile
index afe5df1e6..014ae36ac6004 100644
--- a/drivers/net/ipa/Makefile
+++ b/drivers/net/ipa/Makefile
@@ -1,5 +1,5 @@
  # Un-comment the next line if you want to validate configuration data
-#ccflags-y +=  -DIPA_VALIDATE
+# ccflags-y+=  -DIPA_VALIDATION


Maybe netdev folks think differently here, but general rule that dead
code and closed code is such, is not acceptable to in Linux kernel.

<...>


What is the purpose of CONFIG_KGDB?  Or CONFIG_DEBUG_KERNEL?
Would you prefer I expose this through a kconfig option?  I
intentionally did not do that, because I really intended it
to be only for development, so defined it in the Makefile.
But I have no objection to making it configurable that way.


-#ifdef IPA_VALIDATE
+#ifdef IPA_VALIDATION
if (!size || size % 8)
return -EINVAL;
if (count < max_alloc)
return -EINVAL;
if (!max_alloc)
return -EINVAL;
-#endif /* IPA_VALIDATE */
+#endif /* IPA_VALIDATION */


If it is possible to supply those values, the check should be always and
not only under some closed config option.


These are assertions.

There is no need to test them for working code.  If
I run the code successfully with these tests enabled
exactly once, and they are satisfied, then every time
the code is run thereafter they will pass.  So I want
to check them when debugging/developing only.  That
way there is a mistake, it gets caught, but otherwise
there's no pointless argument checking done.

I'll explain the first check; the others have similar
explanation.

In the current code, the passed size is sizeof(struct)
for three separate structures.
  - If the structure size changes, I want to be
sure the constraint is still honored
  - The code will break of someone happens
to pass a size of 0.  I don't expect that to
ever happen, but this states that requirement.

This is an optimization, basically, but one that
allows the assumed conditions to be optionally
verified.


/* By allocating a few extra entries in our pool (one less
 * than the maximum number that will be requested in a
@@ -140,14 +140,14 @@ int gsi_trans_pool_init_dma(struct device *dev, struct 
gsi_trans_pool *pool,
dma_addr_t addr;
void *virt;
  
-#ifdef IPA_VALIDATE

+#ifdef IPA_VALIDATION
if (!size || size % 8)
return -EINVAL;
if (count < max_alloc)
return -EINVAL;
if (!max_alloc)
return -EINVAL;
-#endif /* IPA_VALIDATE */
+#endif /* IPA_VALIDATION */


Same

<...>


  {
-#ifdef IPA_VALIDATE
+#ifdef IPA_VALIDATION
/* At one time we assumed a 64-bit build, allowing some do_div()
 * calls to be replaced by simple division or modulo operations.
 * We currently only perform divide and modulo operations on u32,
@@ -768,7 +768,7 @@ static void ipa_validate_build(void)
BUILD_BUG_ON(!ipa_aggr_granularity_val(IPA_AGGR_GRANULARITY));
BUILD_BUG_ON(ipa_aggr_granularity_val(IPA_AGGR_GRANULARITY) >
field_max(AGGR_GRANULARITY_FMASK));
-#endif /* IPA_VALIDATE */
+#endif /* IPA_VALIDATION */


BUILD_BUG_ON()s are checked during compilation and not during runtime
like IPA_VALIDATION promised.


So I should update the description.  But I'm not sure where
you are referring to.  Here is the first line of the patch
description:
  There are blocks of IPA code that sanity-check various
  values, at compile time where possible.


IMHO, the issue here is that this IPA code isn't release quality but
some debug drop variant and it is far from expected from submitted code.


Doesn't sound very humble, IMHO.

This code was found acceptable and merged for mainline a
year ago.  At that time it supported IPA on the SDM845 SoC
(IPA v3.5.1).  Had it not bee

Re: [PATCH v2 2/2] arm64: dts: imx: Add i.mx8mm Gateworks gw7901 dts support

2021-03-21 Thread Fabio Estevam
Hi Tim,

On Fri, Mar 19, 2021 at 5:50 PM Tim Harvey  wrote:
>
> The Gateworks GW7901 is an ARM based single board computer (SBC)
> featuring:
>  - i.MX8M Mini SoC
>  - LPDDR4 DRAM
>  - eMMC FLASH
>  - SPI FRAM
>  - Gateworks System Controller (GSC)
>  - Atmel ATECC Crypto Authentication
>  - USB 2.0
>  - Microchip GbE Switch
>  - Multiple multi-protocol RS232/RS485/RS422 Serial ports
>  - onboard 802.11ac WiFi / BT
>  - microSD socket
>  - miniPCIe socket with PCIe, USB 2.0 and dual SIM sockets
>  - Wide range DC power input
>  - 802.3at PoE
>
> Signed-off-by: Tim Harvey 

Reviewed-by: Fabio Estevam 


Re: [PATCH v2 1/2] dt-bindings: arm: imx: add imx8mm gw7901 support

2021-03-21 Thread Fabio Estevam
On Fri, Mar 19, 2021 at 5:50 PM Tim Harvey  wrote:
>
> The Gateworks GW7901 is an ARM based single board computer (SBC)
> featuring:
>  - i.MX8M Mini SoC
>  - LPDDR4 DRAM
>  - eMMC FLASH
>  - SPI FRAM
>  - Gateworks System Controller (GSC)
>  - Atmel ATECC Crypto Authentication
>  - USB 2.0
>  - Microchip GbE Switch
>  - Multiple multi-protocol RS232/RS485/RS422 Serial ports
>  - onboard 802.11ac WiFi / BT
>  - microSD socket
>  - miniPCIe socket with PCIe, USB 2.0 and dual SIM sockets
>  - Wide range DC power input
>  - 802.3at PoE
>
> Acked-by: Rob Herring 
> Signed-off-by: Tim Harvey 

Reviewed-by: Fabio Estevam 


Re: [PATCH] drm/radeon: don't evict if not initialized

2021-03-21 Thread Christian König




Am 20.03.21 um 21:10 schrieb Tong Zhang:

TTM_PL_VRAM may not initialized at all when calling
radeon_bo_evict_vram(). We need to check before doing eviction.

[2.160837] BUG: kernel NULL pointer dereference, address: 0020
[2.161212] #PF: supervisor read access in kernel mode
[2.161490] #PF: error_code(0x) - not-present page
[2.161767] PGD 0 P4D 0
[2.163088] RIP: 0010:ttm_resource_manager_evict_all+0x70/0x1c0 [ttm]
[2.168506] Call Trace:
[2.168641]  radeon_bo_evict_vram+0x1c/0x20 [radeon]
[2.168936]  radeon_device_fini+0x28/0xf9 [radeon]
[2.169224]  radeon_driver_unload_kms+0x44/0xa0 [radeon]
[2.169534]  radeon_driver_load_kms+0x174/0x210 [radeon]
[2.169843]  drm_dev_register+0xd9/0x1c0 [drm]
[2.170104]  radeon_pci_probe+0x117/0x1a0 [radeon]

Signed-off-by: Tong Zhang 
---
  drivers/gpu/drm/radeon/radeon_object.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_object.c 
b/drivers/gpu/drm/radeon/radeon_object.c
index 9b81786782de..04e9a8118b0e 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -384,7 +384,9 @@ int radeon_bo_evict_vram(struct radeon_device *rdev)
}
  #endif
man = ttm_manager_type(bdev, TTM_PL_VRAM);
-   return ttm_resource_manager_evict_all(bdev, man);
+   if (man)
+   return ttm_resource_manager_evict_all(bdev, man);
+   return 0;


You should probably code this the other way around, e.g.

If (!man)
    return 0;
...

Apart from that looks good to me.

Christian.


  }
  
  void radeon_bo_force_delete(struct radeon_device *rdev)




Re: [PATCH net-next 2/2] net: socket: change MSG_CMSG_COMPAT to BIT(21)

2021-03-21 Thread Menglong Dong
On Sun, Mar 21, 2021 at 8:49 PM Herbert Xu  wrote:
>
...
>
> Shouldn't you add some comment here to stop people from trying to
> use BIT(31) in the future?
>
> Thanks,

Yeah, I think it's necessary. Thank you for your reminder~

With Regards,
Menglong Dong


Re: [PATCH 1/6] sched: migration changes for core scheduling

2021-03-21 Thread Li, Aubrey
Hi Peter,

On 2021/3/20 23:34, Peter Zijlstra wrote:
> On Fri, Mar 19, 2021 at 04:32:48PM -0400, Joel Fernandes (Google) wrote:
>> @@ -7530,8 +7543,9 @@ int can_migrate_task(struct task_struct *p, struct 
>> lb_env *env)
>>   * We do not migrate tasks that are:
>>   * 1) throttled_lb_pair, or
>>   * 2) cannot be migrated to this CPU due to cpus_ptr, or
>> - * 3) running (obviously), or
>> - * 4) are cache-hot on their current CPU.
>> + * 3) task's cookie does not match with this CPU's core cookie
>> + * 4) running (obviously), or
>> + * 5) are cache-hot on their current CPU.
>>   */
>>  if (throttled_lb_pair(task_group(p), env->src_cpu, env->dst_cpu))
>>  return 0;
>> @@ -7566,6 +7580,13 @@ int can_migrate_task(struct task_struct *p, struct 
>> lb_env *env)
>>  return 0;
>>  }
>>  
>> +/*
>> + * Don't migrate task if the task's cookie does not match
>> + * with the destination CPU's core cookie.
>> + */
>> +if (!sched_core_cookie_match(cpu_rq(env->dst_cpu), p))
>> +return 0;
>> +
>>  /* Record that we found atleast one task that could run on dst_cpu */
>>  env->flags &= ~LBF_ALL_PINNED;
>>  
> 
> This one is too strong.. persistent imbalance should be able to override
> it.
> 

IIRC, this change can avoid the following scenario:

One sysbench cpu thread(cookieA) and sysbench mysql thread(cookieB) running
on the two siblings of core_1, the other sysbench cpu thread(cookieA) and
sysbench mysql thread(cookieB) running on the two siblings of core2, which
causes 50% force idle.

This is not an imbalance case.

Thanks,
-Aubrey


[PATCH v2 net-next 1/2] net: socket: use BIT() for MSG_*

2021-03-21 Thread menglong8 . dong
From: Menglong Dong 

The bit mask for MSG_* seems a little confused here. Replace it
with BIT() to make it clear to understand.

Signed-off-by: Menglong Dong 
---
 include/linux/socket.h | 71 ++
 1 file changed, 37 insertions(+), 34 deletions(-)

diff --git a/include/linux/socket.h b/include/linux/socket.h
index 385894b4a8bb..d5ebfe30d96b 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -283,42 +283,45 @@ struct ucred {
Added those for 1003.1g not all are supported yet
  */
 
-#define MSG_OOB1
-#define MSG_PEEK   2
-#define MSG_DONTROUTE  4
-#define MSG_TRYHARD 4   /* Synonym for MSG_DONTROUTE for DECnet */
-#define MSG_CTRUNC 8
-#define MSG_PROBE  0x10/* Do not send. Only probe path f.e. for MTU */
-#define MSG_TRUNC  0x20
-#define MSG_DONTWAIT   0x40/* Nonblocking io*/
-#define MSG_EOR 0x80   /* End of record */
-#define MSG_WAITALL0x100   /* Wait for a full request */
-#define MSG_FIN 0x200
-#define MSG_SYN0x400
-#define MSG_CONFIRM0x800   /* Confirm path validity */
-#define MSG_RST0x1000
-#define MSG_ERRQUEUE   0x2000  /* Fetch message from error queue */
-#define MSG_NOSIGNAL   0x4000  /* Do not generate SIGPIPE */
-#define MSG_MORE   0x8000  /* Sender will send more */
-#define MSG_WAITFORONE 0x1 /* recvmmsg(): block until 1+ packets avail */
-#define MSG_SENDPAGE_NOPOLICY 0x1 /* sendpage() internal : do no apply 
policy */
-#define MSG_SENDPAGE_NOTLAST 0x2 /* sendpage() internal : not the last 
page */
-#define MSG_BATCH  0x4 /* sendmmsg(): more messages coming */
-#define MSG_EOF MSG_FIN
-#define MSG_NO_SHARED_FRAGS 0x8 /* sendpage() internal : page frags are 
not shared */
-#define MSG_SENDPAGE_DECRYPTED 0x10 /* sendpage() internal : page may carry
- * plain text and require encryption
- */
-
-#define MSG_ZEROCOPY   0x400   /* Use user data in kernel path */
-#define MSG_FASTOPEN   0x2000  /* Send data in TCP SYN */
-#define MSG_CMSG_CLOEXEC 0x4000/* Set close_on_exec for file
-  descriptor received through
-  SCM_RIGHTS */
+#define MSG_OOBBIT(0)
+#define MSG_PEEK   BIT(1)
+#define MSG_DONTROUTE  BIT(2)
+#define MSG_TRYHARDBIT(2)  /* Synonym for MSG_DONTROUTE for DECnet 
*/
+#define MSG_CTRUNC BIT(3)
+#define MSG_PROBE  BIT(4)  /* Do not send. Only probe path f.e. for MTU
*/
+#define MSG_TRUNC  BIT(5)
+#define MSG_DONTWAIT   BIT(6)  /* Nonblocking io   */
+#define MSG_EORBIT(7)  /* End of record*/
+#define MSG_WAITALLBIT(8)  /* Wait for a full request  */
+#define MSG_FINBIT(9)
+#define MSG_SYNBIT(10)
+#define MSG_CONFIRMBIT(11) /* Confirm path validity*/
+#define MSG_RSTBIT(12)
+#define MSG_ERRQUEUE   BIT(13) /* Fetch message from error queue */
+#define MSG_NOSIGNAL   BIT(14) /* Do not generate SIGPIPE  */
+#define MSG_MORE   BIT(15) /* Sender will send more*/
+#define MSG_WAITFORONE BIT(16) /* recvmmsg(): block until 1+ packets avail */
+#define MSG_SENDPAGE_NOPOLICY  BIT(16) /* sendpage() internal : do no apply 
policy */
+#define MSG_SENDPAGE_NOTLAST   BIT(17) /* sendpage() internal : not the last 
page  */
+#define MSG_BATCH  BIT(18) /* sendmmsg(): more messages coming */
+#define MSG_EOFMSG_FIN
+#define MSG_NO_SHARED_FRAGSBIT(19) /* sendpage() internal : page frags
+* are not shared
+*/
+#define MSG_SENDPAGE_DECRYPTED BIT(20) /* sendpage() internal : page may carry
+* plain text and require encryption
+*/
+
+#define MSG_ZEROCOPY   BIT(26) /* Use user data in kernel path */
+#define MSG_FASTOPEN   BIT(29) /* Send data in TCP SYN */
+#define MSG_CMSG_CLOEXEC   BIT(30) /* Set close_on_exec for file
+* descriptor received through
+* SCM_RIGHTS
+*/
 #if defined(CONFIG_COMPAT)
-#define MSG_CMSG_COMPAT0x8000  /* This message needs 32 bit 
fixups */
+#define MSG_CMSG_COMPATBIT(31) /* This message needs 32 bit 
fixups */
 #else
-#define MSG_CMSG_COMPAT0   /* We never have 32 bit fixups 
*/
+#define MSG_CMSG_COMPAT0   /* We never have 32 bit fixups 
*/
 #endif
 
 
-- 
2.30.2



[PATCH v2 net-next 0/2] net: socket: use BIT() for MSG_* and fix MSG_CMSG_COMPAT

2021-03-21 Thread menglong8 . dong
From: Menglong Dong 

In the first patch, I use BIT() for MSG_* to make the code tidier.

Directly use BIT() for MSG_* will be a bit problematic, because
'msg_flags' is defined as 'int' somewhere, and MSG_CMSG_COMPAT
will make it become negative, just like what Guenter Roeck
reported here:

https://lore.kernel.org/netdev/20210317013758.ga134...@roeck-us.net

So in the second patch, I change MSG_CMSG_COMPAT to BIT(21), as
David Laight suggested. MSG_CMSG_COMPAT is an internal value,
which is't used in userspace, so this change works.

In version 2, some comment is added in patch 2 to stop people
from using BIT(31) for MSG_* in the feature, as Herbert Xu
suggested.


Menglong Dong (2):
  net: socket: use BIT() for MSG_*
  net: socket: change MSG_CMSG_COMPAT to BIT(21)

 include/linux/socket.h | 75 +++---
 1 file changed, 41 insertions(+), 34 deletions(-)

-- 
2.31.0



[PATCH v2 net-next 2/2] net: socket: change MSG_CMSG_COMPAT to BIT(21)

2021-03-21 Thread menglong8 . dong
From: Menglong Dong 

Currently, MSG_CMSG_COMPAT is defined as '1 << 31'. However, 'msg_flags'
is defined with type of 'int' somewhere, such as 'packet_recvmsg' and
other recvmsg functions:

static int packet_recvmsg(struct socket *sock, struct msghdr *msg,
  size_t len,
  int flags)

If MSG_CMSG_COMPAT is set in 'flags', it's value will be negative.
Once it perform bit operations with MSG_*, the upper 32 bits of
the result will be set, just like what Guenter Roeck explained
here:

https://lore.kernel.org/netdev/20210317013758.ga134...@roeck-us.net

As David Laight suggested, fix this by change MSG_CMSG_COMPAT to
some value else. MSG_CMSG_COMPAT is an internal value, which is't
used in userspace, so this change works.

Reported-by: Guenter Roeck 
Signed-off-by: Menglong Dong 
---
v2:
- add comment to stop people from trying to use BIT(31)
---
 include/linux/socket.h | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/include/linux/socket.h b/include/linux/socket.h
index d5ebfe30d96b..61b2694d68dd 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -312,17 +312,21 @@ struct ucred {
 * plain text and require encryption
 */
 
+#if defined(CONFIG_COMPAT)
+#define MSG_CMSG_COMPATBIT(21) /* This message needs 32 bit 
fixups */
+#else
+#define MSG_CMSG_COMPAT0   /* We never have 32 bit fixups 
*/
+#endif
+
 #define MSG_ZEROCOPY   BIT(26) /* Use user data in kernel path */
 #define MSG_FASTOPEN   BIT(29) /* Send data in TCP SYN */
 #define MSG_CMSG_CLOEXEC   BIT(30) /* Set close_on_exec for file
 * descriptor received through
 * SCM_RIGHTS
 */
-#if defined(CONFIG_COMPAT)
-#define MSG_CMSG_COMPATBIT(31) /* This message needs 32 bit 
fixups */
-#else
-#define MSG_CMSG_COMPAT0   /* We never have 32 bit fixups 
*/
-#endif
+/* Attention: Don't use BIT(31) for MSG_*, as 'msg_flags' is defined
+ * as 'int' somewhere and BIT(31) will make it become negative.
+ */
 
 
 /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
-- 
2.31.0



[PATCH v3 0/1] Allow drivers to modify dql.min_limit value

2021-03-21 Thread Vincent Mailhol
Abstract: would like to directly set dql.min_limit value inside a
driver to improve BQL performances of a CAN USB driver.

CAN packets have a small PDU: for classical CAN maximum size is
roughly 16 bytes (8 for payload and 8 for arbitration, CRC and
others).

I am writing an CAN driver for an USB interface. To compensate the
extra latency introduced by the USB, I want to group several CAN
frames and do one USB bulk send. To this purpose, I implemented BQL in
my driver.

However, the BQL algorithms can take time to adjust, especially if
there are small bursts.

The best way I found is to directly modify the dql.min_limit and set
it to some empirical values. This way, even during small burst events
I can have a good throughput. Slightly increasing the dql.min_limit
has no measurable impact on the latency as long as frames fit in the
same USB packet (i.e. BQL overheard is negligible compared to USB
overhead).

The BQL was not designed for USB nor was it designed for CAN's small
PDUs which probably explains why I am the first one to ever have
thought of using dql.min_limit within the driver.

The code I wrote looks like:

> #ifdef CONFIG_BQL
>   netdev_get_tx_queue(netdev, 0)->dql.min_limit = ;
> #endif

Using #ifdef to set up some variables is not a best practice. I am
sending this RFC to see if we can add a function to set this
dql.min_limit in a more pretty way.

For your reference, this RFQ is a follow-up of a discussion on the
linux-can mailing list:
https://lore.kernel.org/linux-can/20210309125708.ei75tr5vp2san...@pengutronix.de/

Thank you for your comments.

Yours sincerely,
Vincent

** Changelog **

RFC v2 -> v3
  - More verbose commit description.
  - Fix kernel documentation.

RFC v1 -> RFC v2
  - Fix incorect #ifdef use.
Reference: 
https://lore.kernel.org/linux-can/20210309153547.q7zspf46k6ter...@pengutronix.de/

Link to RFC v1:
https://lore.kernel.org/linux-can/20210309152354.95309-1-mailhol.vinc...@wanadoo.fr/T/#t

Vincent Mailhol (1):
  netdev: add netdev_queue_set_dql_min_limit()

 include/linux/netdevice.h | 18 ++
 1 file changed, 18 insertions(+)

-- 
2.26.2



Re: [PATCH net-next v2 2/2] net: ipa: fix IPA validation

2021-03-21 Thread Leon Romanovsky
On Sun, Mar 21, 2021 at 08:21:24AM -0500, Alex Elder wrote:
> On 3/21/21 3:21 AM, Leon Romanovsky wrote:
> > On Sat, Mar 20, 2021 at 09:17:29AM -0500, Alex Elder wrote:
> > > There are blocks of IPA code that sanity-check various values, at
> > > compile time where possible.  Most of these checks can be done once
> > > during development but skipped for normal operation.  These checks
> > > permit the driver to make certain assumptions, thereby avoiding the
> > > need for runtime error checking.
> > > 
> > > The checks are defined conditionally, but not consistently.  In
> > > some cases IPA_VALIDATION enables the optional checks, while in
> > > others IPA_VALIDATE is used.
> > > 
> > > Fix this by using IPA_VALIDATION consistently.
> > > 
> > > Signed-off-by: Alex Elder 
> > > ---
> > >   drivers/net/ipa/Makefile   | 2 +-
> > >   drivers/net/ipa/gsi_trans.c| 8 
> > >   drivers/net/ipa/ipa_cmd.c  | 4 ++--
> > >   drivers/net/ipa/ipa_cmd.h  | 6 +++---
> > >   drivers/net/ipa/ipa_endpoint.c | 6 +++---
> > >   drivers/net/ipa/ipa_main.c | 6 +++---
> > >   drivers/net/ipa/ipa_mem.c  | 6 +++---
> > >   drivers/net/ipa/ipa_table.c| 6 +++---
> > >   drivers/net/ipa/ipa_table.h| 6 +++---
> > >   9 files changed, 25 insertions(+), 25 deletions(-)
> > > 
> > > diff --git a/drivers/net/ipa/Makefile b/drivers/net/ipa/Makefile
> > > index afe5df1e6..014ae36ac6004 100644
> > > --- a/drivers/net/ipa/Makefile
> > > +++ b/drivers/net/ipa/Makefile
> > > @@ -1,5 +1,5 @@
> > >   # Un-comment the next line if you want to validate configuration data
> > > -#ccflags-y   +=  -DIPA_VALIDATE
> > > +# ccflags-y  +=  -DIPA_VALIDATION
> > 
> > Maybe netdev folks think differently here, but general rule that dead
> > code and closed code is such, is not acceptable to in Linux kernel.
> > 
> > <...>
> 
> What is the purpose of CONFIG_KGDB?  Or CONFIG_DEBUG_KERNEL?
> Would you prefer I expose this through a kconfig option?  I
> intentionally did not do that, because I really intended it
> to be only for development, so defined it in the Makefile.
> But I have no objection to making it configurable that way.

I prefer you to follow netdev/linux kernel rules of development.
The upstream repository and drivers/net/* folder especially are not
the place to put code used for the development.

> 
> > > -#ifdef IPA_VALIDATE
> > > +#ifdef IPA_VALIDATION
> > >   if (!size || size % 8)
> > >   return -EINVAL;
> > >   if (count < max_alloc)
> > >   return -EINVAL;
> > >   if (!max_alloc)
> > >   return -EINVAL;
> > > -#endif /* IPA_VALIDATE */
> > > +#endif /* IPA_VALIDATION */
> > 
> > If it is possible to supply those values, the check should be always and
> > not only under some closed config option.
> 
> These are assertions.
> 
> There is no need to test them for working code.  If
> I run the code successfully with these tests enabled
> exactly once, and they are satisfied, then every time
> the code is run thereafter they will pass.  So I want
> to check them when debugging/developing only.  That
> way there is a mistake, it gets caught, but otherwise
> there's no pointless argument checking done.
> 
> I'll explain the first check; the others have similar
> explanation.
> 
> In the current code, the passed size is sizeof(struct)
> for three separate structures.
>   - If the structure size changes, I want to be
> sure the constraint is still honored
>   - The code will break of someone happens
> to pass a size of 0.  I don't expect that to
> ever happen, but this states that requirement.
> 
> This is an optimization, basically, but one that
> allows the assumed conditions to be optionally
> verified.

Everything above as an outcome of attempting to mix constant vs. run-time
checks. If "size" is constant, the use of BUILD_BIG_ON() will help not only
you but other developers to catch the errors too. The assumption that you alone
are working on this code, can or can't be correct.

If "size" is not constant, you should check it always.

> 
> > >   /* By allocating a few extra entries in our pool (one less
> > >* than the maximum number that will be requested in a
> > > @@ -140,14 +140,14 @@ int gsi_trans_pool_init_dma(struct device *dev, 
> > > struct gsi_trans_pool *pool,
> > >   dma_addr_t addr;
> > >   void *virt;
> > > -#ifdef IPA_VALIDATE
> > > +#ifdef IPA_VALIDATION
> > >   if (!size || size % 8)
> > >   return -EINVAL;
> > >   if (count < max_alloc)
> > >   return -EINVAL;
> > >   if (!max_alloc)
> > >   return -EINVAL;
> > > -#endif /* IPA_VALIDATE */
> > > +#endif /* IPA_VALIDATION */
> > 
> > Same
> > 
> > <...>
> > 
> > >   {
> > > -#ifdef IPA_VALIDATE
> > > +#ifdef IPA_VALIDATION
> > >   /* At one time we assumed a 64-bit build, allowing some do_div()
> > > 

[PATCH v3 1/1] netdev: add netdev_queue_set_dql_min_limit()

2021-03-21 Thread Vincent Mailhol
Add a function to set the dynamic queue limit minimum value.

Some specific drivers might have legitimate reasons to configure
dql.min_limit to a given value. Typically, this is the case when the
PDU of the protocol is smaller than the packet size to used to
carry those frames to the device.

Concrete example: a CAN (Control Area Network) device with an USB 2.0
interface.  The PDU of classical CAN protocol are roughly 16 bytes but
the USB packet size (which is used to carry the CAN frames to the
device) might be up to 512 bytes.  Wen small traffic burst occurs, BQL
algorithm is not able to immediately adjust and this would result in
having to send many small USB packets (i.e packet of 16 bytes for each
CAN frame). Filling up the USB packet with CAN frames is relatively
fast (small latency issue) but the gain of not having to send several
small USB packets is huge (big throughput increase). In this case,
forcing dql.min_limit to a given value that would allow to stuff the
USB packet is always a win.

This function is to be used by network drivers which are able to prove
through a rationale and through empirical tests on several environment
(with other applications, heavy context switching, virtualization...),
that they constantly reach better performances with a specific
predefined dql.min_limit value with no noticeable latency impact.

Signed-off-by: Vincent Mailhol 
---
 include/linux/netdevice.h | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ddf4cfc12615..c3511263b15a 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3389,6 +3389,24 @@ netif_xmit_frozen_or_drv_stopped(const struct 
netdev_queue *dev_queue)
return dev_queue->state & QUEUE_STATE_DRV_XOFF_OR_FROZEN;
 }
 
+/**
+ * netdev_queue_set_dql_min_limit - set dql minimum limit
+ * @dev_queue: pointer to transmit queue
+ * @min_limit: dql minimum limit
+ *
+ * Forces xmit_more() to return true until the minimum threshold
+ * defined by @min_limit is reached (or until the tx queue is
+ * empty). Warning: to be use with care, misuse will impact the
+ * latency.
+ */
+static inline void netdev_queue_set_dql_min_limit(struct netdev_queue 
*dev_queue,
+ unsigned int min_limit)
+{
+#ifdef CONFIG_BQL
+   dev_queue->dql.min_limit = min_limit;
+#endif
+}
+
 /**
  * netdev_txq_bql_enqueue_prefetchw - prefetch bql data for write
  * @dev_queue: pointer to transmit queue
-- 
2.26.2



[RESEND PATCH v1] checkpatch: exclude four preprocessor sub-expressions from MACRO_ARG_REUSE

2021-03-21 Thread Vincent Mailhol
__must_be_array, offsetof, sizeof_field and __stringify are all
preprocessor macros and do not evaluate their arguments. As such, it
is safe not to warn when arguments are being reused in those four
sub-expressions.

Exclude those so that they can pass checkpatch.

Signed-off-by: Vincent Mailhol 
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index df8b23dc1eb0..25ee4fd5b118 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5736,7 +5736,7 @@ sub process {
next if ($arg =~ /\.\.\./);
next if ($arg =~ /^type$/i);
my $tmp_stmt = $define_stmt;
-   $tmp_stmt =~ 
s/\b(sizeof|typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g;
+   $tmp_stmt =~ 
s/\b(__must_be_array|offsetof|sizeof|sizeof_field|__stringify|typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g;
$tmp_stmt =~ s/\#+\s*$arg\b//g;
$tmp_stmt =~ s/\b$arg\s*\#\#//g;
my $use_cnt = () = $tmp_stmt =~ /\b$arg\b/g;
-- 
2.26.2



[PATCH v3 0/9] Add Wacom I2C support to rM2

2021-03-21 Thread Alistair Francis
From: Alistair Francis 

Add support to the reMarkable2 (rM2) for the Wacom I2C device.

This is based on the reMarkable Linux fork and with this series I am
able to probe the Wacom digitiser.

Alistair Francis (9):
  dt-bindings: Add Wacom to vendor bindings
  dt-bindings: touchscreen: Initial commit of wacom,generic
  Input: wacom_i2c - Add device tree support to wacom_i2c
  Input: wacom_i2c - Add touchscren properties
  Input: wacom_i2c - Add support for distance and tilt x/y
  Input: wacom_i2c - Clean up the query device fields
  Input: wacom_i2c - Add support for vdd regulator
  ARM: imx_v6_v7_defconfig: Enable Wacom I2C
  ARM: dts: imx7d: remarkable2: add wacom digitizer device

 .../input/touchscreen/wacom,generic.yaml  |  48 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 arch/arm/boot/dts/imx7d-remarkable2.dts   |  52 +++
 arch/arm/configs/imx_v6_v7_defconfig  |   1 +
 drivers/input/touchscreen/wacom_i2c.c | 129 +++---
 5 files changed, 210 insertions(+), 22 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml

-- 
2.30.1



[PATCH v3 2/9] dt-bindings: touchscreen: Initial commit of wacom,generic

2021-03-21 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 .../input/touchscreen/wacom,generic.yaml  | 48 +++
 1 file changed, 48 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml

diff --git 
a/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml 
b/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml
new file mode 100644
index ..19bbfc55ed76
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/touchscreen/wacom,generic.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Wacom I2C Controller
+
+maintainers:
+  - Alistair Francis 
+
+allOf:
+  - $ref: touchscreen.yaml#
+
+properties:
+  compatible:
+const: wacom,generic
+
+  reg:
+maxItems: 1
+
+  interrupts:
+maxItems: 1
+
+  vdd-supply:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+#include "dt-bindings/interrupt-controller/irq.h"
+i2c {
+#address-cells = <1>;
+#size-cells = <0>;
+digitiser@9 {
+compatible = "wacom,generic";
+reg = <0x9>;
+interrupt-parent = <&gpio1>;
+interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
+vdd-supply = <®_touch>;
+};
+};
-- 
2.30.1



[PATCH v3 3/9] Input: wacom_i2c - Add device tree support to wacom_i2c

2021-03-21 Thread Alistair Francis
Allow the wacom-i2c device to be exposed via device tree.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 1afc6bde2891..fc0bf583d33b 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define WACOM_CMD_QUERY0   0x04
@@ -262,10 +263,17 @@ static const struct i2c_device_id wacom_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, wacom_i2c_id);
 
+static const struct of_device_id wacom_i2c_of_match_table[] __maybe_unused = {
+   { .compatible = "wacom,generic" },
+   {}
+};
+MODULE_DEVICE_TABLE(of, wacom_i2c_of_match_table);
+
 static struct i2c_driver wacom_i2c_driver = {
.driver = {
.name   = "wacom_i2c",
.pm = &wacom_i2c_pm,
+   .of_match_table = of_match_ptr(wacom_i2c_of_match_table),
},
 
.probe  = wacom_i2c_probe,
-- 
2.30.1



[PATCH v3 6/9] Input: wacom_i2c - Clean up the query device fields

2021-03-21 Thread Alistair Francis
Improve the query device fields to be more verbose.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 71 +++
 1 file changed, 51 insertions(+), 20 deletions(-)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 929680dce9cf..7aa0d1c3dbc9 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -13,15 +13,32 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
-#define WACOM_CMD_QUERY0   0x04
-#define WACOM_CMD_QUERY1   0x00
-#define WACOM_CMD_QUERY2   0x33
-#define WACOM_CMD_QUERY3   0x02
-#define WACOM_CMD_THROW0   0x05
-#define WACOM_CMD_THROW1   0x00
+// Registers
+#define WACOM_COMMAND_LSB   0x04
+#define WACOM_COMMAND_MSB   0x00
+
+#define WACOM_DATA_LSB  0x05
+#define WACOM_DATA_MSB  0x00
+
+// Report types
+#define REPORT_FEATURE  0x30
+
+// Requests / operations
+#define OPCODE_GET_REPORT   0x02
+
+// Power settings
+#define POWER_ON0x00
+#define POWER_SLEEP 0x01
+
+// Input report ids
+#define WACOM_PEN_DATA_REPORT   2
+#define WACOM_SHINONOME_REPORT  26
+
+#define WACOM_QUERY_REPORT 3
 #define WACOM_QUERY_SIZE   22
 
 struct wacom_features {
@@ -48,31 +65,41 @@ static int wacom_query_device(struct i2c_client *client,
  struct wacom_features *features)
 {
int ret;
-   u8 cmd1[] = { WACOM_CMD_QUERY0, WACOM_CMD_QUERY1,
-   WACOM_CMD_QUERY2, WACOM_CMD_QUERY3 };
-   u8 cmd2[] = { WACOM_CMD_THROW0, WACOM_CMD_THROW1 };
u8 data[WACOM_QUERY_SIZE];
+   struct reset_control *rstc;
+
+   u8 get_query_data_cmd[] = {
+   WACOM_COMMAND_LSB,
+   WACOM_COMMAND_MSB,
+   REPORT_FEATURE | WACOM_QUERY_REPORT,
+   OPCODE_GET_REPORT,
+   WACOM_DATA_LSB,
+   WACOM_DATA_MSB,
+   };
+
struct i2c_msg msgs[] = {
+   // Request reading of feature ReportID: 3 (Pen Query Data)
{
.addr = client->addr,
.flags = 0,
-   .len = sizeof(cmd1),
-   .buf = cmd1,
-   },
-   {
-   .addr = client->addr,
-   .flags = 0,
-   .len = sizeof(cmd2),
-   .buf = cmd2,
+   .len = sizeof(get_query_data_cmd),
+   .buf = get_query_data_cmd,
},
+   // Read 21 bytes
{
.addr = client->addr,
.flags = I2C_M_RD,
-   .len = sizeof(data),
+   .len = WACOM_QUERY_SIZE - 1,
.buf = data,
},
};
 
+   rstc = devm_reset_control_get_optional_exclusive(&client->dev, NULL);
+   if (IS_ERR(rstc))
+   dev_err(&client->dev, "Failed to get reset control before 
init\n");
+   else
+   reset_control_reset(rstc);
+
ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
if (ret < 0)
return ret;
@@ -89,9 +116,13 @@ static int wacom_query_device(struct i2c_client *client,
features->tilt_y_max = get_unaligned_le16(&data[19]);
 
dev_dbg(&client->dev,
-   "x_max:%d, y_max:%d, pressure:%d, fw:%d\n",
+   "x_max:%d, y_max:%d, pressure:%d, fw:%d, "
+   "distance: %d, phys distance: %d, "
+   "tilt_x_max: %d, tilt_y_max: %d\n",
features->x_max, features->y_max,
-   features->pressure_max, features->fw_version);
+   features->pressure_max, features->fw_version,
+   features->distance_max, features->distance_physical_max,
+   features->tilt_x_max, features->tilt_y_max);
 
return 0;
 }
-- 
2.30.1



[PATCH v3 8/9] ARM: imx_v6_v7_defconfig: Enable Wacom I2C

2021-03-21 Thread Alistair Francis
Enable the Wacom I2C in the imx defconfig as it is used by the
reMarkable2 tablet.

Signed-off-by: Alistair Francis 
---
 arch/arm/configs/imx_v6_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index 70928cc48939..cd80e85d37cf 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -174,6 +174,7 @@ CONFIG_TOUCHSCREEN_DA9052=y
 CONFIG_TOUCHSCREEN_EGALAX=y
 CONFIG_TOUCHSCREEN_GOODIX=y
 CONFIG_TOUCHSCREEN_ILI210X=y
+CONFIG_TOUCHSCREEN_WACOM_I2C=y
 CONFIG_TOUCHSCREEN_MAX11801=y
 CONFIG_TOUCHSCREEN_IMX6UL_TSC=y
 CONFIG_TOUCHSCREEN_EDT_FT5X06=y
-- 
2.30.1



[PATCH v3 1/9] dt-bindings: Add Wacom to vendor bindings

2021-03-21 Thread Alistair Francis
Signed-off-by: Alistair Francis 
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml 
b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index a8e1e8d2ef20..996f4de2fff5 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1216,6 +1216,8 @@ patternProperties:
 description: Vision Optical Technology Co., Ltd.
   "^vxt,.*":
 description: VXT Ltd
+  "^wacom,.*":
+description: Wacom Co., Ltd
   "^wand,.*":
 description: Wandbord (Technexion)
   "^waveshare,.*":
-- 
2.30.1



[PATCH v3 7/9] Input: wacom_i2c - Add support for vdd regulator

2021-03-21 Thread Alistair Francis
Add support for a VDD regulator. This allows the kernel to prove the
Wacom-I2C device on the rM2.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index 7aa0d1c3dbc9..00db516fa3de 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -56,6 +57,7 @@ struct wacom_i2c {
struct i2c_client *client;
struct input_dev *input;
struct touchscreen_properties props;
+   struct regulator *vdd;
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
@@ -203,11 +205,29 @@ static int wacom_i2c_probe(struct i2c_client *client,
struct wacom_features features = { 0 };
int error;
 
+   wac_i2c = kzalloc(sizeof(*wac_i2c), GFP_KERNEL);
+   if (!wac_i2c)
+   return -ENOMEM;
+
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_err(&client->dev, "i2c_check_functionality error\n");
return -EIO;
}
 
+   wac_i2c->vdd = regulator_get(&client->dev, "vdd");
+   if (IS_ERR(wac_i2c->vdd)) {
+   error = PTR_ERR(wac_i2c->vdd);
+   kfree(wac_i2c);
+   return error;
+   }
+
+   error = regulator_enable(wac_i2c->vdd);
+   if (error) {
+   regulator_put(wac_i2c->vdd);
+   kfree(wac_i2c);
+   return error;
+   }
+
error = wacom_query_device(client, &features);
if (error)
return error;
@@ -275,6 +295,8 @@ static int wacom_i2c_probe(struct i2c_client *client,
 err_free_irq:
free_irq(client->irq, wac_i2c);
 err_free_mem:
+   regulator_disable(wac_i2c->vdd);
+   regulator_put(wac_i2c->vdd);
input_free_device(input);
kfree(wac_i2c);
 
-- 
2.30.1



[PATCH v3 4/9] Input: wacom_i2c - Add touchscren properties

2021-03-21 Thread Alistair Francis
Connect touchscreen properties to the wacom_i2c.

Signed-off-by: Alistair Francis 
---
 drivers/input/touchscreen/wacom_i2c.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/input/touchscreen/wacom_i2c.c 
b/drivers/input/touchscreen/wacom_i2c.c
index fc0bf583d33b..9b2ed0463d09 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -33,6 +34,7 @@ struct wacom_features {
 struct wacom_i2c {
struct i2c_client *client;
struct input_dev *input;
+   struct touchscreen_properties props;
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
@@ -188,6 +190,7 @@ static int wacom_i2c_probe(struct i2c_client *client,
__set_bit(BTN_STYLUS2, input->keybit);
__set_bit(BTN_TOUCH, input->keybit);
 
+   touchscreen_parse_properties(input, true, &wac_i2c->props);
input_set_abs_params(input, ABS_X, 0, features.x_max, 0, 0);
input_set_abs_params(input, ABS_Y, 0, features.y_max, 0, 0);
input_set_abs_params(input, ABS_PRESSURE,
-- 
2.30.1



  1   2   3   4   5   6   7   >