From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756002AbcG1Esa (ORCPT ); Thu, 28 Jul 2016 00:48:30 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:35740 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751283AbcG1Es0 (ORCPT ); Thu, 28 Jul 2016 00:48:26 -0400 Date: Wed, 27 Jul 2016 21:48:24 -0700 From: Viresh Kumar To: Vinod Koul Cc: Dan Williams , linaro-kernel@lists.linaro.org, Greg Kroah-Hartman , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dmaengine: device must have at least one channel Message-ID: <20160728044824.GS6869@ubuntu> References: <4a6e2283fb7736c33fb733c310314d7bc135cd6d.1469654853.git.viresh.kumar@linaro.org> <20160728034843.GI9681@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160728034843.GI9681@localhost> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28-07-16, 09:18, Vinod Koul wrote: > On Wed, Jul 27, 2016 at 02:32:58PM -0700, Viresh Kumar wrote: > > The DMA device can't be registered if it doesn't have any channels > > registered at all. Moreover, it leads to memory leak and is reported by > > kmemleak as (on 3.10 kernel, and same shall happen on mainline): > > > > unreferenced object 0xffffffc09e597240 (size 64): > > comm "swapper/0", pid 1, jiffies 4294877736 (age 7060.280s) > > hex dump (first 32 bytes): > > 00 00 00 00 c0 ff ff ff 30 00 00 ff 00 00 00 ff ........0....... > > 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff ................ > > backtrace: > > [] create_object+0x148/0x2a0 > > [] kmemleak_alloc+0x80/0xbc > > [] kmem_cache_alloc_trace+0x120/0x1ac > > [] dma_async_device_register+0x160/0x46c > > [] foo_probe+0x1a0/0x264 > > [] platform_drv_probe+0x14/0x20 > > [] driver_probe_device+0x160/0x374 > > [] __driver_attach+0x60/0x90 > > [] bus_for_each_dev+0x7c/0xb0 > > [] driver_attach+0x1c/0x28 > > [] bus_add_driver+0x124/0x248 > > [] driver_register+0x90/0x110 > > [] platform_driver_register+0x58/0x64 > > [] foo_driver_init+0x10/0x1c > > [] do_one_initcall+0xac/0x148 > > [] kernel_init_freeable+0x1a0/0x258 > > > > Return -ENODEV from dma_async_device_register() on such a case. > > > > /Signed-off-by: Viresh Kumar > > --- > > Hi Vinod, > > > > Sorry if the fundamentals behind this patch are completely incorrect, > > i.e. We *can't* register a dma device with 0 channels. Its been long > > that I have worked on dma stuff :) > > This sounds okay, Great.. > but why would anyone register a device without having > a channel? A buggy driver? The core should be handling this no matter what, right? The out of tree driver, 3.10 based driver I have looks to be buggy to me. It is doing something like this (please ignore naming/formatting): xlate() { chan = alloc(); list_add(chan.device_node, &dma_dev.channels) } probe() { ... dma_async_device_register() of_dma_controller_register(xlate); ... } But with this it looks like the 'chan' structure wouldn't get initialized properly as that is done from within dma_async_device_register(). Right? Also, I am not sure if DMA is getting used at all right now on my platform. Just noticed the memleak, which I tried to fix. -- viresh