All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap
@ 2021-05-26 18:45 kernel test robot
  2021-05-26 18:45 ` [PATCH] usb: host: xhci: fix call_kern.cocci warnings kernel test robot
  0 siblings, 1 reply; 11+ messages in thread
From: kernel test robot @ 2021-05-26 18:45 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 1690 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210526130037.856068-22-lee.jones@linaro.org>
References: <20210526130037.856068-22-lee.jones@linaro.org>
TO: Lee Jones <lee.jones@linaro.org>
TO: lee.jones(a)linaro.org
CC: linux-kernel(a)vger.kernel.org
CC: Mathias Nyman <mathias.nyman@intel.com>
CC: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
CC: linux-usb(a)vger.kernel.org

Hi Lee,

I love your patch! Perhaps something to improve:

[auto build test WARNING on peter.chen-usb/for-usb-next]
[also build test WARNING on usb/usb-testing v5.13-rc3]
[cannot apply to balbi-usb/testing/next]
[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/Lee-Jones/Rid-W-1-warnings-from-USB/20210526-210403
base:   https://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.git for-usb-next
:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago
config: riscv-randconfig-c004-20210526 (attached as .config)
compiler: riscv64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>


cocci warnings: (new ones prefixed by >>)
>> drivers/usb/host/xhci.c:2791:48-58: ERROR: function xhci_reserve_bandwidth called on line 2911 inside lock on line 2885 but uses GFP_KERNEL

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 27732 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] usb: host: xhci: fix call_kern.cocci warnings
  2021-05-26 18:45 [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap kernel test robot
@ 2021-05-26 18:45 ` kernel test robot
  0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2021-05-26 18:45 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 1793 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210526130037.856068-22-lee.jones@linaro.org>
References: <20210526130037.856068-22-lee.jones@linaro.org>
TO: Lee Jones <lee.jones@linaro.org>
TO: lee.jones(a)linaro.org
CC: linux-kernel(a)vger.kernel.org
CC: Mathias Nyman <mathias.nyman@intel.com>
CC: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
CC: linux-usb(a)vger.kernel.org

From: kernel test robot <lkp@intel.com>

drivers/usb/host/xhci.c:2791:48-58: ERROR: function xhci_reserve_bandwidth called on line 2911 inside lock on line 2885 but uses GFP_KERNEL

 Find functions that refer to GFP_KERNEL but are called with locks held.

Semantic patch information:
 The proposed change of converting the GFP_KERNEL is not necessarily the
 correct one.  It may be desired to unlock the lock, or to not call the
 function under the lock in the first place.

Generated by: scripts/coccinelle/locks/call_kern.cocci

CC: Lee Jones <lee.jones@linaro.org>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---

url:    https://github.com/0day-ci/linux/commits/Lee-Jones/Rid-W-1-warnings-from-USB/20210526-210403
base:   https://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.git for-usb-next
:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago

Please take the patch only if it's a positive warning. Thanks!

 xhci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -2788,7 +2788,7 @@ static int xhci_reserve_bandwidth(struct
 		return -ENOMEM;
 	}
 
-	ep_bw_info = kzalloc(sizeof(*ep_bw_info) * 31, GFP_KERNEL);
+	ep_bw_info = kzalloc(sizeof(*ep_bw_info) * 31, GFP_ATOMIC);
 	if (!ep_bw_info)
 		return -ENOMEM;
 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap
  2021-06-22 10:47               ` Lee Jones
@ 2021-06-22 11:32                 ` Mathias Nyman
  0 siblings, 0 replies; 11+ messages in thread
From: Mathias Nyman @ 2021-06-22 11:32 UTC (permalink / raw)
  To: Lee Jones
  Cc: Sergei Shtylyov, linux-kernel, Mathias Nyman, Greg Kroah-Hartman,
	linux-usb

On 22.6.2021 13.47, Lee Jones wrote:
> On Tue, 01 Jun 2021, Lee Jones wrote:
> 
>> On Thu, 27 May 2021, Mathias Nyman wrote:
>>
>>> On 26.5.2021 18.28, Lee Jones wrote:
>>>> On Wed, 26 May 2021, Sergei Shtylyov wrote:
>>>>
>>>>> On 5/26/21 5:44 PM, Lee Jones wrote:
>>>>>
>>>>> [...]
>>>>>>>> Fixes the following W=1 kernel build warning(s):
>>>>>>>>
>>>>>>>>  drivers/usb/host/xhci.c: In function ‘xhci_reserve_bandwidth’:
>>>>>>>>  drivers/usb/host/xhci.c:2859:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>>>>>>>
>>>>>>>> Cc: Mathias Nyman <mathias.nyman@intel.com>
>>>>>>>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>>>>>>>> Cc: linux-usb@vger.kernel.org
>>>>>>>> Signed-off-by: Lee Jones <lee.jones@linaro.org>
>>>>>>>> ---
>>>>>>>>  drivers/usb/host/xhci.c | 8 +++++++-
>>>>>>>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>>>>>>>
>>>>>>>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
>>>>>>>> index ac2a7d4288883..40ce4b4eb12ad 100644
>>>>>>>> --- a/drivers/usb/host/xhci.c
>>>>>>>> +++ b/drivers/usb/host/xhci.c
>>>>>>> [...]
>>>>>>>> @@ -2788,6 +2788,10 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
>>>>>>>>  		return -ENOMEM;
>>>>>>>>  	}
>>>>>>>>  
>>>>>>>> +	ep_bw_info = kzalloc(sizeof(*ep_bw_info) * 31, GFP_KERNEL);
>>>
>>> GFP_KERNEL might not be suitable for all cases.
>>>
>>> xhci_reserve_bandwidth() is called from xhci_configure_endpoint(), which again
>>> is called from a lot of places.
>>> For example from xhci_update_hub_device() which can be called with GFP_NOIO mem_flags.
>>
>> What do you suggest as an alternative?
> 
> Just working on rectifying this now.
> 
> Which Get Free Page flag do you suggest here please?
> 

xhci_reserve_bandwidth() is called with spin lock held, so probably GFP_ATOMIC

But that whole function would need more attention.
It's always consuming  31 * sizeof(*ep_bw_info) bytes to store fallback values.
Normal use case is that just one, or a couple endpoints are changing, and we know which ones do.

-Mathias


just one enpoint changing. 



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap
  2021-06-01  9:25             ` Lee Jones
@ 2021-06-22 10:47               ` Lee Jones
  2021-06-22 11:32                 ` Mathias Nyman
  0 siblings, 1 reply; 11+ messages in thread
From: Lee Jones @ 2021-06-22 10:47 UTC (permalink / raw)
  To: Mathias Nyman
  Cc: Sergei Shtylyov, linux-kernel, Mathias Nyman, Greg Kroah-Hartman,
	linux-usb

On Tue, 01 Jun 2021, Lee Jones wrote:

> On Thu, 27 May 2021, Mathias Nyman wrote:
> 
> > On 26.5.2021 18.28, Lee Jones wrote:
> > > On Wed, 26 May 2021, Sergei Shtylyov wrote:
> > > 
> > >> On 5/26/21 5:44 PM, Lee Jones wrote:
> > >>
> > >> [...]
> > >>>>> Fixes the following W=1 kernel build warning(s):
> > >>>>>
> > >>>>>  drivers/usb/host/xhci.c: In function ‘xhci_reserve_bandwidth’:
> > >>>>>  drivers/usb/host/xhci.c:2859:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> > >>>>>
> > >>>>> Cc: Mathias Nyman <mathias.nyman@intel.com>
> > >>>>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > >>>>> Cc: linux-usb@vger.kernel.org
> > >>>>> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > >>>>> ---
> > >>>>>  drivers/usb/host/xhci.c | 8 +++++++-
> > >>>>>  1 file changed, 7 insertions(+), 1 deletion(-)
> > >>>>>
> > >>>>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> > >>>>> index ac2a7d4288883..40ce4b4eb12ad 100644
> > >>>>> --- a/drivers/usb/host/xhci.c
> > >>>>> +++ b/drivers/usb/host/xhci.c
> > >>>> [...]
> > >>>>> @@ -2788,6 +2788,10 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
> > >>>>>  		return -ENOMEM;
> > >>>>>  	}
> > >>>>>  
> > >>>>> +	ep_bw_info = kzalloc(sizeof(*ep_bw_info) * 31, GFP_KERNEL);
> > 
> > GFP_KERNEL might not be suitable for all cases.
> > 
> > xhci_reserve_bandwidth() is called from xhci_configure_endpoint(), which again
> > is called from a lot of places.
> > For example from xhci_update_hub_device() which can be called with GFP_NOIO mem_flags.
> 
> What do you suggest as an alternative?

Just working on rectifying this now.

Which Get Free Page flag do you suggest here please?

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap
  2021-05-27 11:36           ` Mathias Nyman
@ 2021-06-01  9:25             ` Lee Jones
  2021-06-22 10:47               ` Lee Jones
  0 siblings, 1 reply; 11+ messages in thread
From: Lee Jones @ 2021-06-01  9:25 UTC (permalink / raw)
  To: Mathias Nyman
  Cc: Sergei Shtylyov, linux-kernel, Mathias Nyman, Greg Kroah-Hartman,
	linux-usb

On Thu, 27 May 2021, Mathias Nyman wrote:

> On 26.5.2021 18.28, Lee Jones wrote:
> > On Wed, 26 May 2021, Sergei Shtylyov wrote:
> > 
> >> On 5/26/21 5:44 PM, Lee Jones wrote:
> >>
> >> [...]
> >>>>> Fixes the following W=1 kernel build warning(s):
> >>>>>
> >>>>>  drivers/usb/host/xhci.c: In function ‘xhci_reserve_bandwidth’:
> >>>>>  drivers/usb/host/xhci.c:2859:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> >>>>>
> >>>>> Cc: Mathias Nyman <mathias.nyman@intel.com>
> >>>>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >>>>> Cc: linux-usb@vger.kernel.org
> >>>>> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> >>>>> ---
> >>>>>  drivers/usb/host/xhci.c | 8 +++++++-
> >>>>>  1 file changed, 7 insertions(+), 1 deletion(-)
> >>>>>
> >>>>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> >>>>> index ac2a7d4288883..40ce4b4eb12ad 100644
> >>>>> --- a/drivers/usb/host/xhci.c
> >>>>> +++ b/drivers/usb/host/xhci.c
> >>>> [...]
> >>>>> @@ -2788,6 +2788,10 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
> >>>>>  		return -ENOMEM;
> >>>>>  	}
> >>>>>  
> >>>>> +	ep_bw_info = kzalloc(sizeof(*ep_bw_info) * 31, GFP_KERNEL);
> 
> GFP_KERNEL might not be suitable for all cases.
> 
> xhci_reserve_bandwidth() is called from xhci_configure_endpoint(), which again
> is called from a lot of places.
> For example from xhci_update_hub_device() which can be called with GFP_NOIO mem_flags.

What do you suggest as an alternative?

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap
  2021-05-26 15:28         ` Lee Jones
@ 2021-05-27 11:36           ` Mathias Nyman
  2021-06-01  9:25             ` Lee Jones
  0 siblings, 1 reply; 11+ messages in thread
From: Mathias Nyman @ 2021-05-27 11:36 UTC (permalink / raw)
  To: Lee Jones, Sergei Shtylyov
  Cc: linux-kernel, Mathias Nyman, Greg Kroah-Hartman, linux-usb

On 26.5.2021 18.28, Lee Jones wrote:
> On Wed, 26 May 2021, Sergei Shtylyov wrote:
> 
>> On 5/26/21 5:44 PM, Lee Jones wrote:
>>
>> [...]
>>>>> Fixes the following W=1 kernel build warning(s):
>>>>>
>>>>>  drivers/usb/host/xhci.c: In function ‘xhci_reserve_bandwidth’:
>>>>>  drivers/usb/host/xhci.c:2859:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>>>>
>>>>> Cc: Mathias Nyman <mathias.nyman@intel.com>
>>>>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>>>>> Cc: linux-usb@vger.kernel.org
>>>>> Signed-off-by: Lee Jones <lee.jones@linaro.org>
>>>>> ---
>>>>>  drivers/usb/host/xhci.c | 8 +++++++-
>>>>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
>>>>> index ac2a7d4288883..40ce4b4eb12ad 100644
>>>>> --- a/drivers/usb/host/xhci.c
>>>>> +++ b/drivers/usb/host/xhci.c
>>>> [...]
>>>>> @@ -2788,6 +2788,10 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
>>>>>  		return -ENOMEM;
>>>>>  	}
>>>>>  
>>>>> +	ep_bw_info = kzalloc(sizeof(*ep_bw_info) * 31, GFP_KERNEL);

GFP_KERNEL might not be suitable for all cases.

xhci_reserve_bandwidth() is called from xhci_configure_endpoint(), which again
is called from a lot of places.
For example from xhci_update_hub_device() which can be called with GFP_NOIO mem_flags.

-Mathias


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap
  2021-05-26 14:59       ` Sergei Shtylyov
@ 2021-05-26 15:28         ` Lee Jones
  2021-05-27 11:36           ` Mathias Nyman
  0 siblings, 1 reply; 11+ messages in thread
From: Lee Jones @ 2021-05-26 15:28 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: linux-kernel, Mathias Nyman, Greg Kroah-Hartman, linux-usb

On Wed, 26 May 2021, Sergei Shtylyov wrote:

> On 5/26/21 5:44 PM, Lee Jones wrote:
> 
> [...]
> >>> Fixes the following W=1 kernel build warning(s):
> >>>
> >>>  drivers/usb/host/xhci.c: In function ‘xhci_reserve_bandwidth’:
> >>>  drivers/usb/host/xhci.c:2859:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> >>>
> >>> Cc: Mathias Nyman <mathias.nyman@intel.com>
> >>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >>> Cc: linux-usb@vger.kernel.org
> >>> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> >>> ---
> >>>  drivers/usb/host/xhci.c | 8 +++++++-
> >>>  1 file changed, 7 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> >>> index ac2a7d4288883..40ce4b4eb12ad 100644
> >>> --- a/drivers/usb/host/xhci.c
> >>> +++ b/drivers/usb/host/xhci.c
> >> [...]
> >>> @@ -2788,6 +2788,10 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
> >>>  		return -ENOMEM;
> >>>  	}
> >>>  
> >>> +	ep_bw_info = kzalloc(sizeof(*ep_bw_info) * 31, GFP_KERNEL);
> >>
> >>    Why not kcalloc()?
> > 
> > No particular reason.  Muscle memory I guess.
> > 
> > Happy either way.
> 
>     kcalloc( is designed for allocatiung arrays and clearing them, like calloc(),
> so let's stick wuth it...

No problem.  Will fix.

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap
  2021-05-26 14:44     ` Lee Jones
@ 2021-05-26 14:59       ` Sergei Shtylyov
  2021-05-26 15:28         ` Lee Jones
  0 siblings, 1 reply; 11+ messages in thread
From: Sergei Shtylyov @ 2021-05-26 14:59 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, Mathias Nyman, Greg Kroah-Hartman, linux-usb

On 5/26/21 5:44 PM, Lee Jones wrote:

[...]
>>> Fixes the following W=1 kernel build warning(s):
>>>
>>>  drivers/usb/host/xhci.c: In function ‘xhci_reserve_bandwidth’:
>>>  drivers/usb/host/xhci.c:2859:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>>
>>> Cc: Mathias Nyman <mathias.nyman@intel.com>
>>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>>> Cc: linux-usb@vger.kernel.org
>>> Signed-off-by: Lee Jones <lee.jones@linaro.org>
>>> ---
>>>  drivers/usb/host/xhci.c | 8 +++++++-
>>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
>>> index ac2a7d4288883..40ce4b4eb12ad 100644
>>> --- a/drivers/usb/host/xhci.c
>>> +++ b/drivers/usb/host/xhci.c
>> [...]
>>> @@ -2788,6 +2788,10 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
>>>  		return -ENOMEM;
>>>  	}
>>>  
>>> +	ep_bw_info = kzalloc(sizeof(*ep_bw_info) * 31, GFP_KERNEL);
>>
>>    Why not kcalloc()?
> 
> No particular reason.  Muscle memory I guess.
> 
> Happy either way.

    kcalloc( is designed for allocatiung arrays and clearing them, like calloc(),
so let's stick wuth it...

MBR, Sergei

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap
  2021-05-26 14:21   ` Sergei Shtylyov
@ 2021-05-26 14:44     ` Lee Jones
  2021-05-26 14:59       ` Sergei Shtylyov
  0 siblings, 1 reply; 11+ messages in thread
From: Lee Jones @ 2021-05-26 14:44 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: linux-kernel, Mathias Nyman, Greg Kroah-Hartman, linux-usb

On Wed, 26 May 2021, Sergei Shtylyov wrote:

> On 5/26/21 4:00 PM, Lee Jones wrote:
> 
> > Fixes the following W=1 kernel build warning(s):
> > 
> >  drivers/usb/host/xhci.c: In function ‘xhci_reserve_bandwidth’:
> >  drivers/usb/host/xhci.c:2859:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> > 
> > Cc: Mathias Nyman <mathias.nyman@intel.com>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: linux-usb@vger.kernel.org
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > ---
> >  drivers/usb/host/xhci.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> > index ac2a7d4288883..40ce4b4eb12ad 100644
> > --- a/drivers/usb/host/xhci.c
> > +++ b/drivers/usb/host/xhci.c
> [...]
> > @@ -2788,6 +2788,10 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
> >  		return -ENOMEM;
> >  	}
> >  
> > +	ep_bw_info = kzalloc(sizeof(*ep_bw_info) * 31, GFP_KERNEL);
> 
>    Why not kcalloc()?

No particular reason.  Muscle memory I guess.

Happy either way.

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap
  2021-05-26 13:00 ` [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap Lee Jones
@ 2021-05-26 14:21   ` Sergei Shtylyov
  2021-05-26 14:44     ` Lee Jones
  0 siblings, 1 reply; 11+ messages in thread
From: Sergei Shtylyov @ 2021-05-26 14:21 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, Mathias Nyman, Greg Kroah-Hartman, linux-usb

On 5/26/21 4:00 PM, Lee Jones wrote:

> Fixes the following W=1 kernel build warning(s):
> 
>  drivers/usb/host/xhci.c: In function ‘xhci_reserve_bandwidth’:
>  drivers/usb/host/xhci.c:2859:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> 
> Cc: Mathias Nyman <mathias.nyman@intel.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-usb@vger.kernel.org
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  drivers/usb/host/xhci.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index ac2a7d4288883..40ce4b4eb12ad 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
[...]
> @@ -2788,6 +2788,10 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
>  		return -ENOMEM;
>  	}
>  
> +	ep_bw_info = kzalloc(sizeof(*ep_bw_info) * 31, GFP_KERNEL);

   Why not kcalloc()?

[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap
  2021-05-26 13:00 [PATCH 00/24] Rid W=1 warnings from USB Lee Jones
@ 2021-05-26 13:00 ` Lee Jones
  2021-05-26 14:21   ` Sergei Shtylyov
  0 siblings, 1 reply; 11+ messages in thread
From: Lee Jones @ 2021-05-26 13:00 UTC (permalink / raw)
  To: lee.jones; +Cc: linux-kernel, Mathias Nyman, Greg Kroah-Hartman, linux-usb

Fixes the following W=1 kernel build warning(s):

 drivers/usb/host/xhci.c: In function ‘xhci_reserve_bandwidth’:
 drivers/usb/host/xhci.c:2859:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]

Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/usb/host/xhci.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index ac2a7d4288883..40ce4b4eb12ad 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -2773,7 +2773,7 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
 		struct xhci_virt_device *virt_dev,
 		struct xhci_container_ctx *in_ctx)
 {
-	struct xhci_bw_info ep_bw_info[31];
+	struct xhci_bw_info *ep_bw_info;
 	int i;
 	struct xhci_input_control_ctx *ctrl_ctx;
 	int old_active_eps = 0;
@@ -2788,6 +2788,10 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
 		return -ENOMEM;
 	}
 
+	ep_bw_info = kzalloc(sizeof(*ep_bw_info) * 31, GFP_KERNEL);
+	if (!ep_bw_info)
+		return -ENOMEM;
+
 	for (i = 0; i < 31; i++) {
 		if (!EP_IS_ADDED(ctrl_ctx, i) && !EP_IS_DROPPED(ctrl_ctx, i))
 			continue;
@@ -2824,6 +2828,7 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
 		 * Update the number of active TTs.
 		 */
 		xhci_update_tt_active_eps(xhci, virt_dev, old_active_eps);
+		kfree(ep_bw_info);
 		return 0;
 	}
 
@@ -2855,6 +2860,7 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
 					&virt_dev->eps[i],
 					virt_dev->tt_info);
 	}
+	kfree(ep_bw_info);
 	return -ENOMEM;
 }
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-06-22 11:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 18:45 [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap kernel test robot
2021-05-26 18:45 ` [PATCH] usb: host: xhci: fix call_kern.cocci warnings kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2021-05-26 13:00 [PATCH 00/24] Rid W=1 warnings from USB Lee Jones
2021-05-26 13:00 ` [PATCH 21/24] usb: host: xhci: Move array of structs from the stack onto the heap Lee Jones
2021-05-26 14:21   ` Sergei Shtylyov
2021-05-26 14:44     ` Lee Jones
2021-05-26 14:59       ` Sergei Shtylyov
2021-05-26 15:28         ` Lee Jones
2021-05-27 11:36           ` Mathias Nyman
2021-06-01  9:25             ` Lee Jones
2021-06-22 10:47               ` Lee Jones
2021-06-22 11:32                 ` Mathias Nyman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.