From patchwork Wed Jan 4 09:22:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krister Johansen X-Patchwork-Id: 9496327 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 DAFE5606B5 for ; Wed, 4 Jan 2017 09:23:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D338027D13 for ; Wed, 4 Jan 2017 09:23:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7F4927D8D; Wed, 4 Jan 2017 09:23:29 +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 7754327D8D for ; Wed, 4 Jan 2017 09:23:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965477AbdADJX2 (ORCPT ); Wed, 4 Jan 2017 04:23:28 -0500 Received: from sub5.mail.dreamhost.com ([208.113.200.129]:46737 "EHLO homiemail-a124.g.dreamhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965499AbdADJX0 (ORCPT ); Wed, 4 Jan 2017 04:23:26 -0500 Received: from homiemail-a124.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a124.g.dreamhost.com (Postfix) with ESMTP id 0EFEA60000D0B for ; Wed, 4 Jan 2017 01:22:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=templeofstupid.com; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=templeofstupid.com; bh=Lanj/fn3n0QB xeIW3MXHm+LVYYg=; b=S1gY72urlJlQtWNfys4NzEszpV1MF8MVPdOLlNWDsRp/ 5q267sp5wFPX3XFX5Z4f5N1NBuCHdEVvWaFHJW3pztih4+s4Oz/q6dApEUqKrzcf bYV2FqNK3azAL9BQRviPhkuaxL16Rp3RjWR0U/W1qDJDu8D6nh04PFO1EWWGuMM= 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 E175160000D02 for ; Wed, 4 Jan 2017 01:22:53 -0800 (PST) Received: from johansen (uid 1000) (envelope-from kjlx@templeofstupid.com) id e0679 by kmjvbox (DragonFly Mail Agent v0.9); Wed, 04 Jan 2017 01:22:52 -0800 Date: Wed, 4 Jan 2017 01:22:52 -0800 From: Krister Johansen To: Vinod Koul Cc: Dave Jiang , dmaengine@vger.kernel.org, Dan Williams , Pan Bian , Julia Lawall Subject: [PATCH v2] ioat_alloc_chan_resources should not perform sleeping allocations. Message-ID: <20170104092252.GD3009@templeofstupid.com> References: <20170102102413.GZ3573@localhost> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170102102413.GZ3573@localhost> 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_NOWAIT so that the allocations do not block and instead use an allocator that uses spinlocks. Signed-off-by: Krister Johansen Acked-by: Dave Jiang --- 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..823cdb9 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_NOWAIT, &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_NOWAIT); if (!ring) return -ENOMEM;