From patchwork Tue Dec 1 09:14:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 57478 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp2040230lbb; Tue, 1 Dec 2015 01:16:11 -0800 (PST) X-Received: by 10.66.158.129 with SMTP id wu1mr98556285pab.146.1448961371778; Tue, 01 Dec 2015 01:16:11 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q18si8907571pfi.244.2015.12.01.01.16.11; Tue, 01 Dec 2015 01:16:11 -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; 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; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756039AbbLAJQJ (ORCPT + 28 others); Tue, 1 Dec 2015 04:16:09 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:35888 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755886AbbLAJQC (ORCPT ); Tue, 1 Dec 2015 04:16:02 -0500 Received: by wmww144 with SMTP id w144so163914787wmw.1 for ; Tue, 01 Dec 2015 01:16:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8gfW/BqVtGE4Hjj4R7eMpqH/gT5x1zhZyKamv4y2tNQ=; b=sYy13hVW845r5duWOnhu2gD7v0mEe9E/k7dUjpVHm7FN7W+1f1QQ0aR9BN11Ih7Qo9 MlkYdqePWIGTw8cOkQ5PHS0yBZxICjw9i/xoKtNgVv5tfYO66LqBc6q6mwD6XmyQzCrE T18trv05GuBXa2Nx1inwe3TffsCSupRmTxY61DD+DoY5WGD//QCAKK5USkyWksvxFV3n WfM4PD6paxUo3Pt22HttvOCTztVeiW6NeDRjlORZfCMG3piJ21fkwlFmMQW096PAbckn BwGXhLI+gn6zQ20APa0f3nqIUjhs55RFIC4d9TPEiUttsuobxLb2AuzutqPRHo/8pPrj rL2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8gfW/BqVtGE4Hjj4R7eMpqH/gT5x1zhZyKamv4y2tNQ=; b=AlH+3DX+yY/hrJriqSzQG0kY2fph3FQSOQBBlkEnjIYQEhMg03PSB3wNv8lauMH5SW /hB/jw4CWpmjZZMU1hFI2Vb49PPs6BN6qXP9CRTueHhnxgdx3Qvf9167kUfGFIYJN/Ty mJOhQfExt8P45LnwmWp6Zl50Rvbf/f3kQeQNSevNAp/orsYRgU1MU4vpit2nza4u/pJC ksXXZWrjUVC+rKxIkSAijrDloFpKb2RBAWKWKfU2TNK6Cr6l8oKchncS5E6DdeNGPcU/ rGsgwKK3cERzIxAtvKuV/bZPgiNm/T6TJLiujQgXPkBq/6zLE5YQvEett8EZRdEhAGX0 YafQ== X-Gm-Message-State: ALoCoQkqxGKHTGota4tUBQPI3zJzbEDf8lYgdHXDFNi6xbvH134n0O4dAytAnPno7ibqF189HptA X-Received: by 10.194.246.132 with SMTP id xw4mr79475705wjc.75.1448961361185; Tue, 01 Dec 2015 01:16:01 -0800 (PST) Received: from mms734.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id t64sm25290428wmf.23.2015.12.01.01.15.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Dec 2015 01:16:00 -0800 (PST) From: Stanimir Varbanov To: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, dmaengine@vger.kernel.org, Vinod Koul Cc: Rob Herring , Rob Herring , Mark Rutland , Pawel Moll , Ian Campbell , Andy Gross , Archit Taneja , Stanimir Varbanov Subject: [PATCH 1/4] dmaengine: qcom_bam_dma: fix dma free memory on remove Date: Tue, 1 Dec 2015 11:14:56 +0200 Message-Id: <1448961299-15161-2-git-send-email-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1448961299-15161-1-git-send-email-stanimir.varbanov@linaro.org> References: <1448961299-15161-1-git-send-email-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Building the driver as a module and when removing the already inserted module gives below: [ 1389.392788] Unable to handle kernel paging request at virtual address ffffffbdc000001c [ 1389.421321] pgd = ffffffc02fa87000 [ 1389.447899] [ffffffbdc000001c] *pgd=0000000000000000, *pud=0000000000000000 [ 1389.460142] Internal error: Oops: 96000006 [#1] PREEMPT SMP [ 1389.466963] Modules linked in: qcom_bam_dma(-) [ 1389.486608] CPU: 2 PID: 2442 Comm: rmmod Not tainted 4.2.0+ #407 [ 1389.493885] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 1389.501196] task: ffffffc035bae2c0 ti: ffffffc0368a8000 task.ti: ffffffc0368a8000 [ 1389.508566] PC is at __free_pages+0xc/0x40 [ 1389.515893] LR is at free_pages.part.93+0x30/0x38 [ 1389.523141] pc : [] lr : [] pstate: 80000145 [ 1389.530602] sp : ffffffc0368abc20 [ 1389.537931] x29: ffffffc0368abc20 x28: ffffffc0368a8000 [ 1389.549153] x27: 0000000000000000 x26: 0000000000000000 [ 1389.560412] x25: ffffffc000cb2000 x24: 0000000000000170 [ 1389.571530] x23: 0000000000000004 x22: ffffffc036bc5010 [ 1389.582721] x21: ffffffc036bc5010 x20: 0000000000000000 [ 1389.593981] x19: 0000000000000002 x18: 0000007fcbc8e8b0 [ 1389.605301] x17: 0000007f9b8226ec x16: ffffffc0002089e8 [ 1389.616647] x15: 0000007f9b8a0588 x14: 0ffffffffffffffc [ 1389.628039] x13: 0000000000000030 x12: 0000000000000000 [ 1389.639436] x11: 0000000000000008 x10: ffffffc000ecc000 [ 1389.650872] x9 : ffffffc035bae2c0 x8 : ffffffc035bae9a8 [ 1389.662367] x7 : ffffffc035bae9a0 x6 : 0000000000000000 [ 1389.673906] x5 : ffffffbdc000001c x4 : 0000000080000000 [ 1389.685475] x3 : ffffffbdc0000000 x2 : 0000004080000000 [ 1389.697049] x1 : 0000000000000003 x0 : ffffffbdc0000000 The memory has been already freed by bam_free_chan() so fix this by skiping already freed memory. Signed-off-by: Stanimir Varbanov --- drivers/dma/qcom_bam_dma.c | 3 +++ 1 file changed, 3 insertions(+) -- 1.7.9.5 -- 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/ diff --git a/drivers/dma/qcom_bam_dma.c b/drivers/dma/qcom_bam_dma.c index 5a250cdc8376..dc9da477eb69 100644 --- a/drivers/dma/qcom_bam_dma.c +++ b/drivers/dma/qcom_bam_dma.c @@ -1231,6 +1231,9 @@ static int bam_dma_remove(struct platform_device *pdev) bam_dma_terminate_all(&bdev->channels[i].vc.chan); tasklet_kill(&bdev->channels[i].vc.task); + if (!bdev->channels[i].fifo_virt) + continue; + dma_free_writecombine(bdev->dev, BAM_DESC_FIFO_SIZE, bdev->channels[i].fifo_virt, bdev->channels[i].fifo_phys);