linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Lee Jones <lee.jones@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	Mathias Nyman <mathias.nyman@intel.com>,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH 17/24] usb: host: xhci: Remove unused variable 'len'
Date: Thu, 27 May 2021 12:23:24 +0300	[thread overview]
Message-ID: <5958f870-1834-3132-a729-2b26a84349ea@linux.intel.com> (raw)
In-Reply-To: <20210527081609.GF543307@dell>

On 27.5.2021 11.16, Lee Jones wrote:
> On Thu, 27 May 2021, Greg Kroah-Hartman wrote:
> 
>> On Wed, May 26, 2021 at 02:00:30PM +0100, Lee Jones wrote:
>>> Fixes the following W=1 kernel build warning(s):
>>>
>>>  drivers/usb/host/xhci.c: In function ‘xhci_unmap_temp_buf’:
>>>  drivers/usb/host/xhci.c:1349:15: warning: variable ‘len’ set but not used [-Wunused-but-set-variable]
>>>
>>> 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 | 9 ++++-----
>>>  1 file changed, 4 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
>>> index 27283654ca080..ac2a7d4288883 100644
>>> --- a/drivers/usb/host/xhci.c
>>> +++ b/drivers/usb/host/xhci.c
>>> @@ -1346,7 +1346,6 @@ static bool xhci_urb_temp_buffer_required(struct usb_hcd *hcd,
>>>  
>>>  static void xhci_unmap_temp_buf(struct usb_hcd *hcd, struct urb *urb)
>>>  {
>>> -	unsigned int len;
>>>  	unsigned int buf_len;
>>>  	enum dma_data_direction dir;
>>>  
>>> @@ -1362,10 +1361,10 @@ static void xhci_unmap_temp_buf(struct usb_hcd *hcd, struct urb *urb)
>>>  				 dir);
>>>  
>>>  	if (usb_urb_dir_in(urb))
>>> -		len = sg_pcopy_from_buffer(urb->sg, urb->num_sgs,
>>> -					   urb->transfer_buffer,
>>> -					   buf_len,
>>> -					   0);
>>> +		sg_pcopy_from_buffer(urb->sg, urb->num_sgs,
>>> +				     urb->transfer_buffer,
>>> +				     buf_len,
>>> +				     0);
>>
>> Sorry, but no, I keep rejecting this over and over, it needs to handle
>> the error handling properly and not paper over it like this :(
> 
> Will fix.
> 
>> All the bots keep tripping up on it, you are not alone.
> 

This is getting a lot of attention. Something like this should fix it:

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 27283654ca08..306ab81421fd 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1361,12 +1361,16 @@ static void xhci_unmap_temp_buf(struct usb_hcd *hcd, struct urb *urb)
 				 urb->transfer_buffer_length,
 				 dir);
 
-	if (usb_urb_dir_in(urb))
+	if (usb_urb_dir_in(urb)) {
 		len = sg_pcopy_from_buffer(urb->sg, urb->num_sgs,
 					   urb->transfer_buffer,
 					   buf_len,
 					   0);
-
+		if (len != buf_len) {
+			xhci_dbg(xhci, "Copy from tmp buf to urb sg list failed\n");
+			urb->actual_length = len;
+		}
+	}
 	urb->transfer_flags &= ~URB_DMA_MAP_SINGLE;
 	kfree(urb->transfer_buffer);
 	urb->transfer_buffer = NULL;
 
urb->actual_length is now properly set.
The debug level message will help me find the cause if we ever need
to debug oddly behaving devices.

Note this is a very rarly taken codepath for quirky xHC harware that
can't handle a specific sequence of buffer lengths queued.

I can write a proper commit message and push this forward

-Mathias

  reply	other threads:[~2021-05-27  9:21 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 13:00 [PATCH 00/24] Rid W=1 warnings from USB Lee Jones
2021-05-26 13:00 ` [PATCH 01/24] usb: cdns3: core: Fix a couple of incorrectly documented function names Lee Jones
2021-05-26 13:00 ` [PATCH 02/24] usb: dwc2: platform: Provide function name for 'dwc2_check_core_version()' Lee Jones
2021-05-26 15:10   ` Minas Harutyunyan
2021-05-26 13:00 ` [PATCH 03/24] usb: common: ulpi: Add leading underscores for function name '__ulpi_register_driver()' Lee Jones
2021-05-26 14:35   ` Heikki Krogerus
2021-05-26 13:00 ` [PATCH 04/24] usb: cdns3: cdns3-plat: Fix incorrect naming of function 'cdns3_plat_remove()' Lee Jones
2021-05-26 13:00 ` [PATCH 05/24] usb: dwc2: params: Fix naming of 'dwc2_get_hwparams()' in the docs Lee Jones
2021-05-26 15:10   ` Minas Harutyunyan
2021-05-26 13:00 ` [PATCH 06/24] usb: isp1760: isp1760-udc: Provide missing description for 'udc' param Lee Jones
2021-05-26 14:11   ` Rui Miguel Silva
2021-05-26 13:00 ` [PATCH 07/24] usb: cdns3: cdns3-gadget: Fix a bunch of kernel-doc related formatting issues Lee Jones
2021-05-26 13:00 ` [PATCH 08/24] usb: cdns3: cdns3-ti: File headers are not good candidates for kernel-doc Lee Jones
2021-05-26 13:00 ` [PATCH 09/24] usb: cdns3: cdns3-ep0: Fix a few kernel-doc formatting issues Lee Jones
2021-05-26 13:00 ` [PATCH 10/24] usb: cdns3: cdns3-imx: File headers are not good candidates for kernel-doc Lee Jones
2021-05-26 13:00 ` [PATCH 11/24] usb: dwc2: hcd_queue: Fix typeo in function name 'dwc2_hs_pmap_unschedule()' Lee Jones
2021-05-26 15:11   ` Minas Harutyunyan
2021-05-26 13:00 ` [PATCH 12/24] usb: dwc2: pci: Fix possible copy/paste issue Lee Jones
2021-05-26 15:11   ` Minas Harutyunyan
2021-05-26 13:00 ` [PATCH 13/24] usb: chipidea: core: Fix incorrectly documented function 'ci_usb_phy_exit()' Lee Jones
2021-05-26 14:24   ` Sergei Shtylyov
2021-05-26 14:42     ` Lee Jones
2021-05-26 13:00 ` [PATCH 14/24] usb: chipidea: otg: Fix formatting and missing documentation issues Lee Jones
2021-05-26 13:00 ` [PATCH 15/24] usb: dwc2: gadget: Repair 'dwc2_hsotg_core_init_disconnected()'s documentation Lee Jones
2021-05-26 15:11   ` Minas Harutyunyan
2021-05-26 13:00 ` [PATCH 16/24] usb: chipidea: udc: Fix incorrectly documented function 'hw_port_is_high_speed()' Lee Jones
2021-05-26 13:00 ` [PATCH 17/24] usb: host: xhci: Remove unused variable 'len' Lee Jones
2021-05-27  7:26   ` Greg Kroah-Hartman
2021-05-27  8:16     ` Lee Jones
2021-05-27  9:23       ` Mathias Nyman [this message]
2021-05-27  9:50         ` Greg Kroah-Hartman
2021-05-27 11:06         ` Lee Jones
2021-05-26 13:00 ` [PATCH 18/24] usb: gadget: udc: pxa27x_udc: Fix documentation for 'pxa27x_udc_start()' Lee Jones
2021-05-26 13:18   ` Daniel Mack
2021-05-26 13:00 ` [PATCH 19/24] usb: gadget: udc: udc-xilinx: Place correct function names into the headers Lee Jones
2021-05-26 13:00 ` [PATCH 20/24] usb: cdns3: cdns3-gadget: Provide correct function naming for '__cdns3_gadget_ep_queue()' 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
2021-05-26 13:00 ` [PATCH 22/24] usb: host: xhci: Document xhci_get_endpoint_index()'s 'desc' param Lee Jones
2021-05-26 13:00 ` [PATCH 23/24] usb: cdns3: cdnsp-gadget: Provide function name for 'cdnsp_find_next_ext_cap()' Lee Jones
2021-05-26 13:00 ` [PATCH 24/24] usb: typec: ucsi: Fix copy/paste issue for 'ucsi_set_drvdata()' Lee Jones
2021-05-26 14:34   ` Heikki Krogerus
2021-05-27  1:46 ` [PATCH 00/24] Rid W=1 warnings from USB Peter Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5958f870-1834-3132-a729-2b26a84349ea@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).