linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Greg KH <gregkh@linuxfoundation.org>,
	Tejas Joglekar <Tejas.Joglekar@synopsys.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	Chunfeng Yun <chunfeng.yun@mediatek.com>,
	Fredrik Noring <noring@nocrew.org>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Raul E Rangel <rrangel@chromium.org>,
	Laurentiu Tudor <laurentiu.tudor@nxp.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	John Youn <John.Youn@synopsys.com>
Subject: Re: [RESENDING RFC PATCH 4/4] usb: xhci: Use temporary buffer to consolidate SG
Date: Fri, 27 Mar 2020 13:25:34 +0200	[thread overview]
Message-ID: <db1519be-979b-575d-9077-b26920aea5fc@linux.intel.com> (raw)
In-Reply-To: <20200327102211.GA1700570@kroah.com>


>>>> +static int xhci_map_temp_buffer(struct usb_hcd *hcd, struct urb *urb)
>>>> +{
>>>> +	void *temp;
>>>> +	int ret = 0;
>>>> +	unsigned int len;
>>>> +	unsigned int buf_len;
>>>> +	enum dma_data_direction dir;
>>>> +	struct xhci_hcd *xhci;
>>>> +
>>>> +	xhci = hcd_to_xhci(hcd);
>>>> +	dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
>>>> +	buf_len = urb->transfer_buffer_length;
>>>> +
>>>> +	temp = kzalloc_node(buf_len, GFP_ATOMIC,
>>>> +			    dev_to_node(hcd->self.sysdev));
>>>> +	if (!temp) {
>>>> +		xhci_warn(xhci, "Failed to create temp buffer, HC may fail\n");
>>>
>>> Didn't kzalloc just warn before this?
>>>
>> Yes, It should.
> 
> Then do not spit out another message please.
> 
>>> And isn't this whole thing going to cause a lot more memory allocations
>>> per submission than before?
>>>
>> If buffer sizes for SG list are very small (less than MPS size per TRB_CACHE_SIZE)
>> yes, it will have more memory allocations. 
> 
> That's not good :(
> 

I actually recommended this after looking at the real numbers.

It was explained to me that the Synopsis xHC has a flaw that it will hang if its
TRB cache contains 16 chained TRBs (no ending TRB), and the combined TRB size
is _less_ than 1024 bytes.

So this only happens if a URB has a sg list with more than 16 entries whose
total size is less than 1024 bytes.

I was told this has not been seen ever in real life usage.

So in the unlikey case this is ever triggered we will end up allocating a small
bounce buffer, probably around 1024 bytes, and copy the data over from the sg-list.

(for HS speeds limits are 8 chained TRBs and 512 bytes)

- Mathias

  reply	other threads:[~2020-03-27 11:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27  8:52 [RESENDING RFC PATCH 0/4] Add logic to consolidate TRBs for Synopsys xHC Tejas Joglekar
2020-03-27  8:34 ` [RFC PATCH 1/4] dt-bindings: usb: Add snps,consolidate-sgl & consolidate-sgl Tejas Joglekar
2020-03-27  9:41   ` [RESENDING RFC " Tejas Joglekar
2020-03-27  9:54   ` Greg KH
2020-03-27 10:11     ` Tejas Joglekar
2020-03-27 10:24       ` Greg KH
2020-03-27 10:28         ` Tejas Joglekar
2020-04-05  1:45   ` Rob Herring
2020-04-14 10:09     ` Tejas Joglekar
2020-04-16  8:22       ` Felipe Balbi
2020-04-16 16:37         ` Tejas Joglekar
2020-04-17 11:44           ` Mathias Nyman
2020-03-27  8:35 ` [RFC PATCH 2/4] usb: xhci: Set quirk for XHCI_CONSOLIDATE_SG_LIST Tejas Joglekar
2020-03-27  9:42   ` [RESENDING RFC " Tejas Joglekar
2020-03-27  8:35 ` [RFC PATCH 3/4] usb: dwc3: Add device property consolidate-sgl Tejas Joglekar
2020-03-27  9:42   ` [RESENDING RFC " Tejas Joglekar
2020-03-27  8:53 ` [RESENDING RFC PATCH 4/4] usb: xhci: Use temporary buffer to consolidate SG Tejas Joglekar
2020-03-27  9:27   ` Greg KH
2020-03-27 10:05     ` Tejas Joglekar
2020-03-27 10:22       ` Greg KH
2020-03-27 11:25         ` Mathias Nyman [this message]
2020-03-27 15:38           ` Raul Rangel
2020-03-27  9:28 ` [RESENDING RFC PATCH 0/4] Add logic to consolidate TRBs for Synopsys xHC Greg KH
2020-03-27  9:43   ` Tejas Joglekar

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=db1519be-979b-575d-9077-b26920aea5fc@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=John.Youn@synopsys.com \
    --cc=Tejas.Joglekar@synopsys.com \
    --cc=bigeasy@linutronix.de \
    --cc=chunfeng.yun@mediatek.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=laurentiu.tudor@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mathias.nyman@intel.com \
    --cc=noring@nocrew.org \
    --cc=rrangel@chromium.org \
    /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).