From patchwork Sat Dec 31 04:10:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krister Johansen X-Patchwork-Id: 9492601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DA8D560453 for ; Sat, 31 Dec 2016 04:10:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB14B22A63 for ; Sat, 31 Dec 2016 04:10:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD032252D5; Sat, 31 Dec 2016 04:10:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C96622A63 for ; Sat, 31 Dec 2016 04:10:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754575AbcLaEK1 (ORCPT ); Fri, 30 Dec 2016 23:10:27 -0500 Received: from sub5.mail.dreamhost.com ([208.113.200.129]:33126 "EHLO homiemail-a124.g.dreamhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754470AbcLaEK0 (ORCPT ); Fri, 30 Dec 2016 23:10:26 -0500 Received: from homiemail-a124.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a124.g.dreamhost.com (Postfix) with ESMTP id 0D20660000D01 for ; Fri, 30 Dec 2016 20:10:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=templeofstupid.com; h=date :from:to:cc:subject:message-id:mime-version:content-type; s= templeofstupid.com; bh=kDOFwWdstQg8pGh65a6OkjDLPmo=; b=IWxq7vTA+ oi+K7LYz7t5INRTG805MGDRGQ5bp9Mw2lbsLJVEKPc96zUcVFD4+NNPolG4mOkK+ UTpEvxLFnhZRa6g28Ke7FCCJLh5wEp+KqLxu+R8wrAMr4QqbOyLak73okgmYgQwV UkrdQkR3GfRO6uO3byedK06mSev06pSqdE= Received: from kmjvbox (c-73-70-90-212.hsd1.ca.comcast.net [73.70.90.212]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: kjlx@templeofstupid.com) by homiemail-a124.g.dreamhost.com (Postfix) with ESMTPSA id D38DF60000D06 for ; Fri, 30 Dec 2016 20:10:25 -0800 (PST) Received: from johansen (uid 1000) (envelope-from kjlx@templeofstupid.com) id e0666 by kmjvbox (DragonFly Mail Agent v0.9); Fri, 30 Dec 2016 20:10:24 -0800 Date: Fri, 30 Dec 2016 20:10:24 -0800 From: Krister Johansen To: Dave Jiang Cc: dmaengine@vger.kernel.org, Vinod Koul , Dan Williams , Pan Bian , Julia Lawall Subject: [PATCH] ioat_alloc_chan_resources should not perform sleeping allocations. Message-ID: <20161231041024.GB2448@templeofstupid.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On a kernel with DEBUG_LOCKS, ioat_free_chan_resources triggers an in_interrupt() warning. With PROVE_LOCKING, it reports detecting a SOFTIRQ-safe to SOFTIRQ-unsafe lock ordering in the same code path. This is because dma_generic_alloc_coherent() checks if the GFP flags permit blocking. It allocates from different subsystems if blocking is permitted. The free path knows how to return the memory to the correct allocator. If GFP_KERNEL is specified then the alloc and free end up going through cma_alloc(), which uses mutexes. Given that ioat_free_chan_resources() can be called in interrupt context, ioat_alloc_chan_resources() must specify GFP_ATOMIC so that the allocations do not block and instead use an allocator that uses spinlocks. Signed-off-by: Krister Johansen --- drivers/dma/ioat/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c index 90eddd9..9d82f8f 100644 --- a/drivers/dma/ioat/init.c +++ b/drivers/dma/ioat/init.c @@ -693,7 +693,7 @@ static int ioat_alloc_chan_resources(struct dma_chan *c) /* doing 2 32bit writes to mmio since 1 64b write doesn't work */ ioat_chan->completion = dma_pool_zalloc(ioat_chan->ioat_dma->completion_pool, - GFP_KERNEL, &ioat_chan->completion_dma); + GFP_ATOMIC, &ioat_chan->completion_dma); if (!ioat_chan->completion) return -ENOMEM; @@ -703,7 +703,7 @@ static int ioat_alloc_chan_resources(struct dma_chan *c) ioat_chan->reg_base + IOAT_CHANCMP_OFFSET_HIGH); order = IOAT_MAX_ORDER; - ring = ioat_alloc_ring(c, order, GFP_KERNEL); + ring = ioat_alloc_ring(c, order, GFP_ATOMIC); if (!ring) return -ENOMEM;