From patchwork Fri Jan 6 02:50:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 90091 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp9264018qgi; Thu, 5 Jan 2017 19:01:09 -0800 (PST) X-Received: by 10.99.2.142 with SMTP id 136mr138380981pgc.25.1483671669605; Thu, 05 Jan 2017 19:01:09 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v123si47060174pfb.245.2017.01.05.19.01.08; Thu, 05 Jan 2017 19:01:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032313AbdAFC7E (ORCPT + 25 others); Thu, 5 Jan 2017 21:59:04 -0500 Received: from mail-pg0-f41.google.com ([74.125.83.41]:35293 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032080AbdAFC5n (ORCPT ); Thu, 5 Jan 2017 21:57:43 -0500 Received: by mail-pg0-f41.google.com with SMTP id i5so182144551pgh.2 for ; Thu, 05 Jan 2017 18:57:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=HjlffkrQZJ8gnld/ktNtP04o+ss/MrALNatytVbYSNY=; b=kzAs3aNRoSUEa9qfwj9rZt6fSP0n+ScHoeQlnlNQbdOyxZLTBRzlw5KuOCgbEhNCXn EucZdw+0hRXhmNh3om3hYeMpjbJtOa4l8pcMmEXYC/gxg3pqwsdlUiVH3bEztEImnZnI kQxh2TO7iYqq/E74gtRyAFk9QUOt3X9qkCnkk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HjlffkrQZJ8gnld/ktNtP04o+ss/MrALNatytVbYSNY=; b=BJGyq0ayCVe4Vk/tTCelSRELe//z7ccu9wA0E0kqNK4a2jrJpFKcKQwNWVaTOsi/FA 7DlvV27/8LoNiANOm1pRSvRtGBySphPGqYBca+qZlXVp0ZhftCfqc1tF/UzRYboYm21w CVtFTi2QM9KUC5AVC8B3+1HvHBuEzOZcty5TEOd9/li24fT1Q9mmSR9ZnAGssHm0RSLb 8A2jnWcZNMDvs1Schd98b95QcfVXZBHFZZ8K2ij9WMpsApex5vFbnfcv7g6YDnMmK08y TE94KaF9y7x58kIsD+KYarUHyyKBVtxXKlibnWIZ6LUVeQvmRM+QN3d8+vsvSVytEqV3 NUww== X-Gm-Message-State: AIkVDXK3OZu32fefalH3MhOK7ee6/nuyKCMWqDW0p1/gpgxkwpas9mDmq3N30fMYxNkKBZx9 X-Received: by 10.98.68.84 with SMTP id r81mr68858076pfa.174.1483671043855; Thu, 05 Jan 2017 18:50:43 -0800 (PST) Received: from localhost.localdomain ([103.192.224.50]) by smtp.gmail.com with ESMTPSA id y73sm156214127pfa.68.2017.01.05.18.50.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Jan 2017 18:50:42 -0800 (PST) From: Leo Yan To: John Youn , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Zhangfei Gao , John Stultz Cc: Leo Yan Subject: [PATCH] usb: dwc2: fix panic for coherent memory allocation Date: Fri, 6 Jan 2017 10:50:05 +0800 Message-Id: <1483671005-13394-1-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When use configfs to configure USB port as as ethernet gadget, the kernel has panic with below backtrace; it clearly indicates the coherent memory allocation is happened in the interrupt context, but the function __get_vm_area_node() is possible to be scheduling out so function __get_vm_area_node() triggers panic if it's called from interrupt context. To fix this issue, simply to change gfp_flag from GFP_KERNEL to GFP_NOWAIT so it can support to allocate coherent memory from interrupt context. [ 8.036567] ------------[ cut here ]------------ [ 8.041188] kernel BUG at mm/vmalloc.c:1344! [ 8.045462] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP [ 8.050950] Modules linked in: [ 8.054007] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W 4.10.0-rc2-00201-ged40875 #645 [ 8.062978] Hardware name: HiKey Development Board (DT) [ 8.068206] task: ffff000008dc2900 task.stack: ffff000008db0000 [ 8.176374] Process swapper/0 (pid: 0, stack limit = 0xffff000008db0000) [ 8.183080] Stack: (0xffff80003df19a80 to 0xffff000008db4000) [ 8.188829] Call trace: [ 8.191276] Exception stack(0xffff80003df198b0 to 0xffff80003df199e0) [ 8.197722] 98a0: 000000000002d048 0001000000000000 [ 8.205564] 98c0: ffff80003df19a80 ffff0000081aca98 00000000000001c0 0000000000000004 [ 8.213407] 98e0: ffff7e0000b48000 0000000000000009 ffff000008e93000 ffff7e0000b41200 [ 8.221250] 9900: ffff80003df19950 ffff000008174e40 0000000000000000 ffff000008e93000 [ 8.229093] 9920: ffff000008e92b00 ffff000008e92000 ffff000008c37000 ffff000008e92b00 [ 8.236935] 9940: 00000000000001c0 0000000000000004 0000000000001000 0000000000010002 [ 8.244777] 9960: 0000000000000008 ffff000008000000 ffff7dffbfff0000 00000000024000c0 [ 8.252619] 9980: 0000000000000000 0000000000000001 ffff7e0000000000 000000000002d048 [ 8.260462] 99a0: fffffffffffffe00 0000000000000001 0000000000000068 dead000000000200 [ 8.268305] 99c0: dead000000000100 00000000000001c4 fffffffffffffffe 0000000000000000 [ 8.276148] [] __get_vm_area_node.isra.37+0x180/0x184 [ 8.282769] [] get_vm_area_caller+0x34/0x3c [ 8.288522] [] dma_common_pages_remap+0x28/0x70 [ 8.294621] [] dma_common_contiguous_remap+0xcc/0xf0 [ 8.301154] [] __dma_alloc+0x10c/0x228 [ 8.306471] [] dwc2_hsotg_ep_enable+0x360/0x4c8 [ 8.312571] [] usb_ep_enable+0x3c/0x5c [ 8.317888] [] ecm_set_alt+0xac/0x164 [ 8.323117] [] composite_setup+0xbac/0x140c [ 8.328868] [] dwc2_hsotg_complete_setup+0xb8/0x368 [ 8.335315] [] usb_gadget_giveback_request+0x10/0x18 [ 8.341849] [] dwc2_hsotg_complete_request+0x7c/0x130 [ 8.348470] [] dwc2_hsotg_handle_outdone+0xfc/0x1e0 [ 8.354917] [] dwc2_hsotg_epint+0x638/0x844 [ 8.360667] [] dwc2_hsotg_irq+0x374/0x6f4 [ 8.366246] [] __handle_irq_event_percpu+0xa0/0x128 [ 8.372693] [] handle_irq_event_percpu+0x1c/0x54 [ 8.378879] [] handle_irq_event+0x44/0x74 [ 8.384456] [] handle_fasteoi_irq+0xb4/0x184 [ 8.390294] [] generic_handle_irq+0x24/0x38 [ 8.396045] [] __handle_domain_irq+0x60/0xac [ 8.401883] [] gic_handle_irq+0x54/0xa0 Signed-off-by: Leo Yan --- drivers/usb/dwc2/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index b95930f..302b60c 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3753,7 +3753,7 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep, hs_ep->desc_list = dma_alloc_coherent(hsotg->dev, MAX_DMA_DESC_NUM_GENERIC * sizeof(struct dwc2_dma_desc), - &hs_ep->desc_list_dma, GFP_KERNEL); + &hs_ep->desc_list_dma, GFP_NOWAIT); if (!hs_ep->desc_list) { ret = -ENOMEM; goto error2;