Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753654AbbBRTkP (ORCPT ); Wed, 18 Feb 2015 14:40:15 -0500 Received: from mga01.intel.com ([192.55.52.88]:55559 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753276AbbBRTkN (ORCPT ); Wed, 18 Feb 2015 14:40:13 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,603,1418112000"; d="scan'208";a="687539966" Message-ID: <1424288411.9530.119.camel@schen9-desk2.jf.intel.com> Subject: Re: [PATCH] pci-dma: Fix x86 dma_alloc_coherent to fully clear all pages returned From: Tim Chen To: Sergei Shtylyov , Greg Kroah-Hartman Cc: Jiri Slaby , "H. Peter Anvin" , Akinobu Mita , Mathias Nyman , Andi Kleen , Ingo Molnar , Andrew Morton , Marek Szyprowski , Thomas Gleixner , linux-kernel@vger.kernel.org, x86@kernel.org, linux-usb@vger.kernel.org, stable , Alan Stern Date: Wed, 18 Feb 2015 11:40:11 -0800 In-Reply-To: <1423074632.9530.110.camel@schen9-desk2.jf.intel.com> References: <1422647641.9530.2.camel@schen9-desk2.jf.intel.com> <54CBF1A0.9080005@cogentembedded.com> <1422654849.9530.8.camel@schen9-desk2.jf.intel.com> <54CF8374.80704@suse.cz> <54CFA836.6010309@cogentembedded.com> <1423074632.9530.110.camel@schen9-desk2.jf.intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.8.5 (3.8.5-2.fc19) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2505 Lines: 77 On Wed, 2015-02-04 at 10:30 -0800, Tim Chen wrote: > On Mon, 2015-02-02 at 19:39 +0300, Sergei Shtylyov wrote: > > > > > > Hi, is this an open-coded version of PAGE_ALIGN? > > > > Yes, it appears so. :-) > > > > WBR, Sergei > > > > Thanks for the suggestion by Jiri. I updated the patch to use PAGE_ALIGN > below. > > Regards, > Tim > Is there any resolution on this patch? I haven't seen fixes from the XHCI folks yet. This is breaking many of our systems. Thanks. Tim > --->8--- > From: Tim Chen > Subject: [PATCH] pci-dma: Fix x86 dma_alloc_coherent to fully clear all pages returned > > 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. > > Other drivers may have similar issue if it assumes that the pages > allocated are completely zeroed. > > This patch ensures that the pages returned are fully cleared. > > Signed-off-by: Tim Chen > Cc: stable@vger.kernel.org > --- > arch/x86/kernel/pci-dma.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c > index a25e202..3bdee55 100644 > --- a/arch/x86/kernel/pci-dma.c > +++ b/arch/x86/kernel/pci-dma.c > @@ -125,6 +125,8 @@ again: > > return NULL; > } > + /* round up to full page size */ > + size = PAGE_ALIGN(size); > memset(page_address(page), 0, size); > *dma_addr = addr; > return page_address(page); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/