Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932650AbbBBQj0 (ORCPT ); Mon, 2 Feb 2015 11:39:26 -0500 Received: from mail-la0-f53.google.com ([209.85.215.53]:57307 "EHLO mail-la0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932828AbbBBQjX (ORCPT ); Mon, 2 Feb 2015 11:39:23 -0500 Message-ID: <54CFA836.6010309@cogentembedded.com> Date: Mon, 02 Feb 2015 19:39:18 +0300 From: Sergei Shtylyov Organization: Cogent Embedded User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Jiri Slaby , Tim Chen CC: "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 Subject: Re: [PATCH] pci-dma: Fix x86 dma_alloc_coherent to fully clear all pages returned 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> In-Reply-To: <54CF8374.80704@suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2105 Lines: 59 Hello. On 02/02/2015 05:02 PM, Jiri Slaby wrote: >> 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: # 3.16+ >> --- >> 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..e9d8dee 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 = (size + ~PAGE_MASK) & PAGE_MASK; > Hi, is this an open-coded version of PAGE_ALIGN? Yes, it appears so. :-) WBR, Sergei -- 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/