From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.cz>, "H. Peter Anvin" <hpa@zytor.com>,
Akinobu Mita <akinobu.mita@gmail.com>,
Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, x86@kernel.org,
linux-usb@vger.kernel.org, stable <stable@vger.kernel.org>,
Alan Stern <stern@rowland.harvard.edu>, ak <ak@linux.intel.com>
Subject: Re: [PATCH] xhci: use dma_alloc_coherent with fully cleared pages
Date: Thu, 19 Feb 2015 17:05:21 +0200 [thread overview]
Message-ID: <54E5FBB1.2060300@linux.intel.com> (raw)
In-Reply-To: <1424306081.9530.137.camel@schen9-desk2.jf.intel.com>
On 19.02.2015 02:34, Tim Chen wrote:
>
> Commit d92ef66c4f8f ("x86: make dma_alloc_coherent() return zeroed memory
> if CMA is enabled") changed the dma_alloc_coherent page clearance from
> using an __GFP_ZERO in page allocation to not setting the flag but doing
> an explicit memory clear at the end.
>
> However the memory clear only covered the memory size that
> was requested, but may not be up to the full extent of the
> last page, if the total pages returned exceed the
> memory size requested. This behavior has caused problem with XHCI
> and caused it to hang:
>
> kernel: xhci_hcd 0000:00:14.0: Stopped the command ring failed, maybe the host is dead
> kernel: xhci_hcd 0000:00:14.0: Abort command ring failed
> kernel: xhci_hcd 0000:00:14.0: HC died; cleaning up
> kernel: xhci_hcd 0000:00:14.0: Error while assigning device slot ID
> kernel: xhci_hcd 0000:00:14.0: Max number of devices this xHCI host supports is 64.
>
> This patch reverts xhci the use the old behavior to avoid the hang. XHCI should
> do a proper fix to avoid this un-allocated memory.
>
> Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
> Cc: <stable@vger.kernel.org> # 3.16+
> ---
> drivers/usb/host/xhci-mem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index 5cb3d7a..39e7196 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -1658,7 +1658,7 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
> goto fail_sp;
>
> xhci->scratchpad->sp_array = dma_alloc_coherent(dev,
> - num_sp * sizeof(u64),
> + PAGE_ALIGN(num_sp * sizeof(u64)),
> &xhci->scratchpad->sp_dma, flags);
> if (!xhci->scratchpad->sp_array)
> goto fail_sp2;
>
Thanks for figuring out that the issue was in allocation of scratchpad memory.
Turns out we don't calculate the num_sp correctly in the first place, we didn't include
the additional high order field of the max scratchpad buffers xhci tells we should reserve.
I got a patch for this and will send it to forward to Greg once 3.20-rc1 is tagged
-Mathias
next prev parent reply other threads:[~2015-02-19 15:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-19 0:34 [PATCH] xhci: use dma_alloc_coherent with fully cleared pages Tim Chen
2015-02-19 15:05 ` Mathias Nyman [this message]
2015-02-19 16:56 ` Tim Chen
2015-02-19 17:43 ` Andi Kleen
2015-02-19 18:17 ` Tim 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=54E5FBB1.2060300@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=ak@linux.intel.com \
--cc=akinobu.mita@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mingo@elte.hu \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=tglx@linutronix.de \
--cc=tim.c.chen@linux.intel.com \
--cc=x86@kernel.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