Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3076709imm; Sun, 5 Aug 2018 20:30:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdWZfOkM9YK3DP7p4H7K/E2P4kyDUDjdFzZdeVpBiW9keCnW3GMyXqElGpsriSTx4RrH1PF X-Received: by 2002:a63:e516:: with SMTP id r22-v6mr12627822pgh.170.1533526210774; Sun, 05 Aug 2018 20:30:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533526210; cv=none; d=google.com; s=arc-20160816; b=gnGiXcLDQPeLSg4e6DRYK5WPKVWHxyY2EY1BlSN3G+N/v4kbdEPa81W53cbgDJflUV GgizrynvI/PDS0919EvHSvsyfo99zpJ78W/3W+vKUQvwkkjlKnSXu2FInLxeddj6hcqW GDfjvPYSULqpbulL1kdAqUAPKTKydRlaLozL0PeGIMTuPaoTRixWphnh3cYNqIsggVO2 VPJpxaBSoETJxsV8PUizJnanuyveSl6VbazS+nx+qrWflmNSo0uBq10jDOqjtfWOEPzr wuGJQhtYQRwQ1XC3iMY+WcYCRia+nTmJjxwHJnfk7+HZ5i/LyzrhIBqvQKRZsjvXDFN2 0WqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-filter:arc-authentication-results; bh=oasZ1O0zqr4bqmIUCkLzqR6RgN8dO1/xgBGfEgsO/sk=; b=HJuCklFOO1clXii5xjB0shwQF2Jf+u0VFP0bsvTVIQIcl+FTbFAImZT5rH1LKFsYcr 0rAQCH+UDMetzwVWRR+7gharFrBbdajGwtCOByqiAtgO3XVS1yzml5vcb8yASqVk9/nc GXg5Omlr8SnKWy9tnnY2YTi1fYc/ytgxDg2SEYTRYEhBbBpHTZoDm1VYqxp8HZnpr5MD dch8Auj8lGD60CVwK+5crypZxPkG6HSet/lNQSL0PbAn8JbwxXDK0sObe7kLIDjiIjBf SOjh2ReLVsgg796RWL2tVrGMEDeuEEflGM3BThnOK6GMNvm/rgPRtb76yWVBCFahzyuH SskQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@iluvatar.ai header.s=809B2F8E-810B-11E8-86FD-A0A654EEFFEB header.b=gJS+YqWt; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=iluvatar.ai Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1-v6si13263396pfb.280.2018.08.05.20.29.56; Sun, 05 Aug 2018 20:30:10 -0700 (PDT) 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; dkim=pass header.i=@iluvatar.ai header.s=809B2F8E-810B-11E8-86FD-A0A654EEFFEB header.b=gJS+YqWt; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=iluvatar.ai Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727526AbeHFFgD (ORCPT + 99 others); Mon, 6 Aug 2018 01:36:03 -0400 Received: from mail.iluvatar.ai ([58.213.90.100]:5265 "EHLO mail.iluvatar.ai" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727168AbeHFFgD (ORCPT ); Mon, 6 Aug 2018 01:36:03 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.iluvatar.ai (Postfix) with ESMTP id BC1CD1071E33E; Mon, 6 Aug 2018 11:32:30 +0800 (CST) Received: from mail.iluvatar.ai ([127.0.0.1]) by localhost (mail.iluvatar.ai [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id s3qeorhY9623; Mon, 6 Aug 2018 11:32:30 +0800 (CST) Received: from localhost (localhost [127.0.0.1]) by mail.iluvatar.ai (Postfix) with ESMTP id EDCD710C742AA; Mon, 6 Aug 2018 11:32:29 +0800 (CST) DKIM-Filter: OpenDKIM Filter v2.9.2 mail.iluvatar.ai EDCD710C742AA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iluvatar.ai; s=809B2F8E-810B-11E8-86FD-A0A654EEFFEB; t=1533526350; bh=oasZ1O0zqr4bqmIUCkLzqR6RgN8dO1/xgBGfEgsO/sk=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; b=gJS+YqWtIeFPdydF70IoW2OGoulrtDBgbIEL5jM55MHVA8NapkwA8rfvaZMIeXxKt HfUvjDISsUtHUjnaSjZIKrw9reHJY+8B3OjmM2ou+u2A0iK+WNWcpo2xENvgDoXL+M SIKZF9VDtuFHDsew/3vXLiou3bTXJadwFRlhlJ64= X-Virus-Scanned: amavisd-new at iluvatar.ai Received: from mail.iluvatar.ai ([127.0.0.1]) by localhost (mail.iluvatar.ai [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id M7D-clwsZ2fD; Mon, 6 Aug 2018 11:32:29 +0800 (CST) Received: from hsj-Precision-5520 (unknown [192.168.128.73]) by mail.iluvatar.ai (Postfix) with ESMTPSA id 6A93C1071E33E; Mon, 6 Aug 2018 11:32:29 +0800 (CST) Date: Mon, 6 Aug 2018 11:28:47 +0800 From: Huang Shijie To: Peter Ujfalusi Cc: vkoul@kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, dave.jiang@intel.com, radhey.shyam.pandey@xilinx.com, appana.durga.rao@xilinx.com, jmkrzyszt@gmail.com, gomonovych@gmail.com, keescook@chromium.org, horms+renesas@verge.net.au, geert+renesas@glider.be, shawnguo@kernel.org, baoyou.xie@linaro.org, michal.simek@xilinx.com, baohua@kernel.org, ludovic.desroches@microchip.com, linus.walleij@linaro.org, david.brown@linaro.org Subject: Re: [PATCH 09/46] dmaengine: cppi41: use dmaenginem_async_device_register to simplify the code Message-ID: <20180806032847.GA4452@hsj-Precision-5520> References: <20180803072016.21544-1-sjhuang@iluvatar.ai> <20180803072016.21544-10-sjhuang@iluvatar.ai> <43458794-d124-13df-c944-e473dc8ee1c2@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43458794-d124-13df-c944-e473dc8ee1c2@ti.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 03, 2018 at 10:55:25AM +0300, Peter Ujfalusi wrote: > > > On 2018-08-03 10:19, Huang Shijie wrote: > > Use dmaenginem_async_device_register to simplify the code: > > remove dma_async_device_unregister > > > > Signed-off-by: Huang Shijie > > --- > > drivers/dma/ti/cppi41.c | 7 ++----- > > 1 file changed, 2 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/dma/ti/cppi41.c b/drivers/dma/ti/cppi41.c > > index 1497da367710..d2998a19ed2e 100644 > > --- a/drivers/dma/ti/cppi41.c > > +++ b/drivers/dma/ti/cppi41.c > > @@ -1096,21 +1096,19 @@ static int cppi41_dma_probe(struct platform_device *pdev) > > goto err_chans; > > cdd->irq = irq; > > > > - ret = dma_async_device_register(&cdd->ddev); > > + ret = dmaenginem_async_device_register(&cdd->ddev); > > if (ret) > > goto err_chans; > > > > ret = of_dma_controller_register(dev->of_node, > > cppi41_dma_xlate, &cpp41_dma_info); > > if (ret) > > - goto err_of; > > + goto err_chans; > > > > pm_runtime_mark_last_busy(dev); > > pm_runtime_put_autosuspend(dev); > > > > return 0; > > -err_of: > > - dma_async_device_unregister(&cdd->ddev); > > err_chans: > > deinit_cppi41(dev, cdd); > > err_init_cppi: > > @@ -1132,7 +1130,6 @@ static int cppi41_dma_remove(struct platform_device *pdev) > > dev_err(&pdev->dev, "%s could not pm_runtime_get: %i\n", > > __func__, error); > > of_dma_controller_free(pdev->dev.of_node); > > - dma_async_device_unregister(&cdd->ddev); > > If I read the code right then this is not safe. I read the code again, and find it is okay. > We would have deinitalized cppi41 driver which is not functional, but we > will still have the dma device registered and if a channel is requested > we will have kernel crash. We cannot succeed to request a channel when the drv->remove() is called. Please see __device_release_driver: --------------------------------------------------------------------- if (dev->bus && dev->bus->remove) dev->bus->remove(dev); else if (drv->remove) drv->remove(dev); device_links_driver_cleanup(dev); dma_deconfigure(dev); devres_release_all(dev); ============> Devres release --------------------------------------------------------------------- For the DMA engine driver, there is only one case which will calls drv->remove(): Use the rmmod(or modprobe -r). We do not use the device_link_add API for DMA engines. And we not manually call the device_release_driver() for DMA engines. But when we use the rmmod, the module state will be MODULE_STATE_GOING. In the find_candidate(), dma_chan_get() will fail. And we cannot get a channel. Please correct me if I am wrong :) Thanks Huang Shijie