From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751376AbbGUEOP (ORCPT ); Tue, 21 Jul 2015 00:14:15 -0400 Received: from mga02.intel.com ([134.134.136.20]:4368 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750769AbbGUEON (ORCPT ); Tue, 21 Jul 2015 00:14:13 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,512,1432623600"; d="scan'208";a="732511293" Date: Tue, 21 Jul 2015 09:45:58 +0530 From: Vinod Koul To: Julia Lawall Cc: Alex Smith , Zubair.Kakakhel@imgtec.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: question about drivers/dma/dma-jz4780.c Message-ID: <20150721041558.GE23525@localhost> References: <55ACAEC5.7090000@imgtec.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 20, 2015 at 10:28:14AM +0200, Julia Lawall wrote: > On Mon, 20 Jul 2015, Alex Smith wrote: > > > On 19/07/2015 10:08, Julia Lawall wrote: > > > The file drivers/dma/dma-jz4780.c has a probe function that sets up irqs > > > using devm_request_irq. The probe function then ends with: > > > > > > err_unregister_dev: > > > dma_async_device_unregister(dd); > > > > > > err_disable_clk: > > > clk_disable_unprepare(jzdma->clk); > > > return ret; > > > } > > > > > > The remove function, on the other hand contains: > > > > > > of_dma_controller_free(pdev->dev.of_node); > > > devm_free_irq(&pdev->dev, jzdma->irq, jzdma); > > > dma_async_device_unregister(&jzdma->dma_device); > > > > > > The need for calling devm_free_irq explicitly would be that it needs to > > > occur before dma_async_device_unregister, to eg avoid a reference to a > > > dangling pointer. But devm_free_irq is implicitly called after the call > > > to dma_async_device_unregister at the end of the probe function. Which > > > one is correct? Not just users but from a device management you are ensuring that your device is not able to send any more interrupts and also your tasklet is not spawned further. For this it is neccessary that devm_irq_free be called explcitly by devices > > > > > > julia > > > > Hi, > > > > I think the explicit devm_free_irq() here is unnecessary, as when remove is > > called there should be no remaining users of the DMA controller and therefore > > no chance of an IRQ occurring between the controller being unregistered and an > > implicit IRQ release afterwards. Are you ensuring that device can no longer sent interrupts and all instances of tasklet running or either completed are terminated and no further tasklet can be spawned? -- ~Vinod