From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751981AbbBSPEN (ORCPT ); Thu, 19 Feb 2015 10:04:13 -0500 Received: from mga03.intel.com ([134.134.136.65]:48430 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751605AbbBSPEM (ORCPT ); Thu, 19 Feb 2015 10:04:12 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,609,1418112000"; d="scan'208";a="456794632" Message-ID: <54E5FBB1.2060300@linux.intel.com> Date: Thu, 19 Feb 2015 17:05:21 +0200 From: Mathias Nyman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Tim Chen CC: Sergei Shtylyov , Greg Kroah-Hartman , Jiri Slaby , "H. Peter Anvin" , Akinobu Mita , Ingo Molnar , Andrew Morton , Marek Szyprowski , Thomas Gleixner , linux-kernel@vger.kernel.org, x86@kernel.org, linux-usb@vger.kernel.org, stable , Alan Stern , ak Subject: Re: [PATCH] xhci: use dma_alloc_coherent with fully cleared pages References: <1424306081.9530.137.camel@schen9-desk2.jf.intel.com> In-Reply-To: <1424306081.9530.137.camel@schen9-desk2.jf.intel.com> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Cc: # 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