From patchwork Tue Jan 27 17:25:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 5719011 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 313FA9F2ED for ; Tue, 27 Jan 2015 17:24:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4FEA020149 for ; Tue, 27 Jan 2015 17:24:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78F9220221 for ; Tue, 27 Jan 2015 17:24:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758878AbbA0RYp (ORCPT ); Tue, 27 Jan 2015 12:24:45 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:37677 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758184AbbA0RYo (ORCPT ); Tue, 27 Jan 2015 12:24:44 -0500 Received: from avalon.ideasonboard.com (dsl-hkibrasgw3-50ddcc-40.dhcp.inet.fi [80.221.204.40]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 59A2A20D73; Tue, 27 Jan 2015 18:24:36 +0100 (CET) From: Laurent Pinchart To: dmaengine@vger.kernel.org Cc: linux-sh@vger.kernel.org Subject: [PATCH 3/6] dmaengine: rcar-dmac: Fix oops due to unintialized list in error ISR Date: Tue, 27 Jan 2015 19:25:13 +0200 Message-Id: <1422379516-1633-4-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.0.5 In-Reply-To: <1422379516-1633-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> References: <1422379516-1633-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The error interrupt handler stops and reinitializes all channels. This causes a crash for channels that have never been used, as their descriptor lists are uninitialized. Fix it by initializing the descriptor lists at probe time. Signed-off-by: Laurent Pinchart --- drivers/dma/sh/rcar-dmac.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index b7ff64557d6d..e76f5e21f666 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -930,11 +930,6 @@ static int rcar_dmac_alloc_chan_resources(struct dma_chan *chan) struct rcar_dmac_chan *rchan = to_rcar_dmac_chan(chan); int ret; - INIT_LIST_HEAD(&rchan->desc.free); - INIT_LIST_HEAD(&rchan->desc.pending); - INIT_LIST_HEAD(&rchan->desc.active); - INIT_LIST_HEAD(&rchan->desc.done); - INIT_LIST_HEAD(&rchan->desc.wait); INIT_LIST_HEAD(&rchan->desc.chunks_free); INIT_LIST_HEAD(&rchan->desc.pages); @@ -971,11 +966,11 @@ static void rcar_dmac_free_chan_resources(struct dma_chan *chan) rchan->mid_rid = -EINVAL; } - list_splice(&rchan->desc.free, &list); - list_splice(&rchan->desc.pending, &list); - list_splice(&rchan->desc.active, &list); - list_splice(&rchan->desc.done, &list); - list_splice(&rchan->desc.wait, &list); + list_splice_init(&rchan->desc.free, &list); + list_splice_init(&rchan->desc.pending, &list); + list_splice_init(&rchan->desc.active, &list); + list_splice_init(&rchan->desc.done, &list); + list_splice_init(&rchan->desc.wait, &list); list_for_each_entry(desc, &list, node) rcar_dmac_realloc_hwdesc(rchan, desc, 0); @@ -1521,6 +1516,12 @@ static int rcar_dmac_chan_probe(struct rcar_dmac *dmac, spin_lock_init(&rchan->lock); + INIT_LIST_HEAD(&rchan->desc.free); + INIT_LIST_HEAD(&rchan->desc.pending); + INIT_LIST_HEAD(&rchan->desc.active); + INIT_LIST_HEAD(&rchan->desc.done); + INIT_LIST_HEAD(&rchan->desc.wait); + /* Request the channel interrupt. */ sprintf(pdev_irqname, "ch%u", index); irq = platform_get_irq_byname(pdev, pdev_irqname);