From patchwork Sun Jan 12 17:29:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329273 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37742921 for ; Sun, 12 Jan 2020 17:31:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 14D612084D for ; Sun, 12 Jan 2020 17:31:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rnVhNxqC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733121AbgALRbd (ORCPT ); Sun, 12 Jan 2020 12:31:33 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:39877 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732972AbgALRbc (ORCPT ); Sun, 12 Jan 2020 12:31:32 -0500 Received: by mail-lj1-f196.google.com with SMTP id l2so7438104lja.6; Sun, 12 Jan 2020 09:31:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v3aEWiKiUIKlnyGDWrJTtogZVkNTJgIo6DWcgGLcpCo=; b=rnVhNxqCfDE+XLWYc6q2yJ8rtxAYQKDTrumUj7JLMXqMQ1NyPnHHtoxUBvBLvICeXQ Malqt2Rn3Gb4Jf4Z/sPTDHpKL4U5Ad5kBB5F2wcFA2ExuLvpBAdpi7XDbRkQh+gkFEfY fQvjvkpTOTW+ubBmTIkQZGhzb/9N27FPB8LkvS82HP223GAxLan+ZzPtuRnm/oL/BPso zpxcQpy7/OLbfoVZIoevFx/HTTy3hmx+RWscG9ebQvcTu8K25rdyFf2cHDRirmO39vnb 3Ff8Zk9kARvUE70FRyuAFTdAkKm1xc8RTeTbm+HuRTMfgu21+hXCoHkKw7Ecb/D4mWVX jk9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v3aEWiKiUIKlnyGDWrJTtogZVkNTJgIo6DWcgGLcpCo=; b=kEhogkqTUwqEis9pJCvctB1/2G68Y/nN22048DQyTfSz1TQjAbzkos4bMbjd6S3BvF FJ+qo6KYNKe9Pn4ffq21lGEzZTna4rBqrx1UEQ2850b2dc/3G4wLJuEmQwwiRamGNX0i Efq1dlIz7gMB3q5FmjmQmuWmv1+Z+3EUeTPYKuPihBAlZCxBjfpF5yYNQk7CAGF36I6D AX7WjalWcVpHLl41wbE5UHbh7r2OdkAiVfu3mTiiP89sknmMZMgY74smrVlJC9Um7hzj gPIQtO49+ShVAYCYzgLFUGBThZy+RKOZ1XZ16X0+S+W1idG2nvnqO1gkKpXmgBMBovaq dkJg== X-Gm-Message-State: APjAAAWWjVnFpeZ1CEGXCCDqoRAOyw8f5nW7izuIs7pSJ9Y24/pfjyXg ywOoUfjeurgq2w0efRWfLxDn7bkK X-Google-Smtp-Source: APXvYqxJOOnnEe+TT/kaxiDI0CySBUJuqn6U8+sEPnyhnWtqT37vwWichFveYRRMS5pkAlEoacw7MA== X-Received: by 2002:a2e:9592:: with SMTP id w18mr8415393ljh.98.1578850289846; Sun, 12 Jan 2020 09:31:29 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:29 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 01/14] dmaengine: tegra-apb: Fix use-after-free Date: Sun, 12 Jan 2020 20:29:53 +0300 Message-Id: <20200112173006.29863-2-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org I was doing some experiments with I2C and noticed that Tegra APB DMA driver crashes sometime after I2C DMA transfer termination. The crash happens because tegra_dma_terminate_all() bails out immediately if pending list is empty, thus it doesn't release the half-completed descriptors which are getting re-used before ISR tasklet kicks-in. tegra-i2c 7000c400.i2c: DMA transfer timeout elants_i2c 0-0010: elants_i2c_irq: failed to read data: -110 ------------[ cut here ]------------ WARNING: CPU: 0 PID: 142 at lib/list_debug.c:45 __list_del_entry_valid+0x45/0xac list_del corruption, ddbaac44->next is LIST_POISON1 (00000100) Modules linked in: CPU: 0 PID: 142 Comm: kworker/0:2 Not tainted 5.5.0-rc2-next-20191220-00175-gc3605715758d-dirty #538 Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) Workqueue: events_freezable_power_ thermal_zone_device_check [] (unwind_backtrace) from [] (show_stack+0x11/0x14) [] (show_stack) from [] (dump_stack+0x85/0x94) [] (dump_stack) from [] (__warn+0xc1/0xc4) [] (__warn) from [] (warn_slowpath_fmt+0x61/0x78) [] (warn_slowpath_fmt) from [] (__list_del_entry_valid+0x45/0xac) [] (__list_del_entry_valid) from [] (tegra_dma_tasklet+0x5b/0x154) [] (tegra_dma_tasklet) from [] (tasklet_action_common.constprop.0+0x41/0x7c) [] (tasklet_action_common.constprop.0) from [] (__do_softirq+0xd3/0x2a8) [] (__do_softirq) from [] (irq_exit+0x7b/0x98) [] (irq_exit) from [] (__handle_domain_irq+0x45/0x80) [] (__handle_domain_irq) from [] (gic_handle_irq+0x45/0x7c) [] (gic_handle_irq) from [] (__irq_svc+0x65/0x94) Exception stack(0xde2ebb90 to 0xde2ebbd8) Cc: Signed-off-by: Dmitry Osipenko --- drivers/dma/tegra20-apb-dma.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 3a45079d11ec..319f31d27014 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -756,10 +756,6 @@ static int tegra_dma_terminate_all(struct dma_chan *dc) bool was_busy; spin_lock_irqsave(&tdc->lock, flags); - if (list_empty(&tdc->pending_sg_req)) { - spin_unlock_irqrestore(&tdc->lock, flags); - return 0; - } if (!tdc->busy) goto skip_dma_stop; From patchwork Sun Jan 12 17:29:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329275 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A636D1580 for ; Sun, 12 Jan 2020 17:31:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 84CAB2187F for ; Sun, 12 Jan 2020 17:31:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VLhpT+xt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733141AbgALRbe (ORCPT ); Sun, 12 Jan 2020 12:31:34 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45374 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733115AbgALRbd (ORCPT ); Sun, 12 Jan 2020 12:31:33 -0500 Received: by mail-lj1-f194.google.com with SMTP id j26so7423670ljc.12; Sun, 12 Jan 2020 09:31:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iSzNtTGK3mbZvFsWdibdEoWrg4nzIZ5PMxmWTFl+mGA=; b=VLhpT+xtSOOwihhyK3NBL7PpJlC5RGYW6+AL19VuiQzXByT/1ufPIS8D/RH7vouOJW B298S+32ed8q7d4kG+fgtBv7U4ULiNaN9G5vjHGZAUm9faPwgGecPJYTkVPLg0V48yHh jJo0Pgq3O0+v8i9gSah+8whTlahMvTWCDVJcva2nN0hd+n53T2hjgE96LH3Vwt8H2kXr wiDztZLS3j3q8UfpIiWshX7/MzNGYgiYKAoz+9CeP95bJ82DqyixnG45O80Rqfm16Fkc yiQR8AJOzrY+/zG/iwPBAV2yycuQD25y8vwBaTPnYfnL/wi7DToyAEnHG95YHbR5CfBH XbeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iSzNtTGK3mbZvFsWdibdEoWrg4nzIZ5PMxmWTFl+mGA=; b=NATfVFjN/R8qocyqJpXzD/jY18Tu3/3mkz2mW2JDM74PrYgxMKG5QaXIPdB+PWyVvX csv1j+MDfkXoBC2ukwLElNtMN6WMauL7VYl1lxAziJt+fOaSXTT4bU/I2XAPwFzsQnOe x5iUz39nV/y5I/srxUyOjlnGr5DeTssKxPTUZunt4RzLoQZOVSfIHd+49gD6s7wlvRWX 2/ivnP6txAuDaEnPIuETfSB1tjqYkawPiVIIBh2mAzUMCcys0OeRWFMk+oRhmayF+GXI mEcc3AiDKzSphHIXXD4S2stJ4w1F6kzP7+EFFgjHkGU0NVoV5wMlVR3ru9kIL5O/FCBe NugA== X-Gm-Message-State: APjAAAVsztuLjtlRBo19kZYrLVyKndf+QYopr/lsLSYCj/sFgLSjZGz9 dkxeTVWHcYbPNGEhDUSQd1I= X-Google-Smtp-Source: APXvYqz69GLc2KT2ts1nF62Z5SiaR2QrLqQYyJCJ1+hOSA3Q6Mtq/x1Mut6cnygLHSPhmXAuRcuSYA== X-Received: by 2002:a05:651c:32b:: with SMTP id b11mr8585302ljp.203.1578850290755; Sun, 12 Jan 2020 09:31:30 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:30 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 02/14] dmaengine: tegra-apb: Implement synchronization callback Date: Sun, 12 Jan 2020 20:29:54 +0300 Message-Id: <20200112173006.29863-3-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org The ISR tasklet could be kept scheduled after DMA transfer termination, let's add synchronization callback which blocks until tasklet is finished. Signed-off-by: Dmitry Osipenko Acked-by: Jon Hunter --- drivers/dma/tegra20-apb-dma.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 319f31d27014..664e9c5df3ba 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -798,6 +798,13 @@ static int tegra_dma_terminate_all(struct dma_chan *dc) return 0; } +static void tegra_dma_synchronize(struct dma_chan *dc) +{ + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + + tasklet_kill(&tdc->tasklet); +} + static unsigned int tegra_dma_sg_bytes_xferred(struct tegra_dma_channel *tdc, struct tegra_dma_sg_req *sg_req) { @@ -1506,6 +1513,7 @@ static int tegra_dma_probe(struct platform_device *pdev) tdma->dma_dev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; tdma->dma_dev.device_config = tegra_dma_slave_config; tdma->dma_dev.device_terminate_all = tegra_dma_terminate_all; + tdma->dma_dev.device_synchronize = tegra_dma_synchronize; tdma->dma_dev.device_tx_status = tegra_dma_tx_status; tdma->dma_dev.device_issue_pending = tegra_dma_issue_pending; From patchwork Sun Jan 12 17:29:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329297 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 918CE1398 for ; Sun, 12 Jan 2020 17:32:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7004A24656 for ; Sun, 12 Jan 2020 17:32:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SJjsUnua" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733150AbgALRbf (ORCPT ); Sun, 12 Jan 2020 12:31:35 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:33734 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728512AbgALRbe (ORCPT ); Sun, 12 Jan 2020 12:31:34 -0500 Received: by mail-lf1-f67.google.com with SMTP id n25so5171820lfl.0; Sun, 12 Jan 2020 09:31:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cVivrbUaLAvYOWEQyaxZv2B+LG1a8MlZfEIn/W+0au8=; b=SJjsUnuacjwEmmFeP1a4th9a3eAh0uaYtlNT7/X4jvCpH1AI7dHTBFWk0SVlk+b0IH E3hD/TbeBVZHBOEXVL5vr8LQthhIu2TW65i8uVVBOSt6h3cVUp/NmB97oYtccCmB8xx1 gMCqnBds58LoBwEE3Wnze9BFP25Mxj9IVeSVm+I9WVmp07YH/FFuSvbrsfiWlmcdo/80 Q6PgSqmBQeinfTpsuHqALeldYcuX2ZhlTFnl0t4hAqGaT8iYhoBIrHz0iF9jRewRWGUs gnvmjrGTKpb6f8DwiO6i6nQ5re1kqeRMs4jHLbvTxPsvoTdU0QiCvOy/m8HrEiCkE3fE 4sZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cVivrbUaLAvYOWEQyaxZv2B+LG1a8MlZfEIn/W+0au8=; b=nAelAacijgjj34quagI8X6oD1Av8MAS6cZFRvUz/Bhd2cfeQRLMWmy3dUm/d2O0rsc BSYHkvdAjB3ScQaZ4V7tJ6cnzfegpolcP2aCMnNWFk7fzIEqnoT24CYcnYChHs6yTdOr eFXbCcnc4SySr0QQNF9lILG1PYJSvTiw1vpDXoEeNHqdkc6Dd4z7Pclp55Yr8eW3+es0 xJE8vpwpH3IjiB+A1AwheSEUGI2hihkvQoFd5qICa3Nt+jIPpziEaqP5+NngbAuK0DeG m8l9tNaoFTY9CiLxl/3sYSan2taiKzbgOoVPm+3M+Ia9yA7hWQ4awX4ZTQIs0265NdKp 4/zg== X-Gm-Message-State: APjAAAXjeJsnO1tDEGQRN01el0dRB+dWz6ivRLvQpTFmfP0hUDA0AOpJ xiTCzydUbc5Tz+WIEUi+gHM= X-Google-Smtp-Source: APXvYqxche74SfZP3bBOfOX10phuAZEUaoTHurS8Kbd28t9dK269h60bqAU/0dfFh9UYQFWgHAv9+w== X-Received: by 2002:a19:8a06:: with SMTP id m6mr7003628lfd.99.1578850291621; Sun, 12 Jan 2020 09:31:31 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:31 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 03/14] dmaengine: tegra-apb: Prevent race conditions on channel's freeing Date: Sun, 12 Jan 2020 20:29:55 +0300 Message-Id: <20200112173006.29863-4-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org It's incorrect to check the channel's "busy" state without taking a lock. That shouldn't cause any real troubles, nevertheless it's always better not to have any race conditions in the code. Signed-off-by: Dmitry Osipenko Acked-by: Jon Hunter --- drivers/dma/tegra20-apb-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 664e9c5df3ba..24ad3a5a04e3 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1294,8 +1294,7 @@ static void tegra_dma_free_chan_resources(struct dma_chan *dc) dev_dbg(tdc2dev(tdc), "Freeing channel %d\n", tdc->id); - if (tdc->busy) - tegra_dma_terminate_all(dc); + tegra_dma_terminate_all(dc); spin_lock_irqsave(&tdc->lock, flags); list_splice_init(&tdc->pending_sg_req, &sg_req_list); From patchwork Sun Jan 12 17:29:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329295 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 663AC921 for ; Sun, 12 Jan 2020 17:32:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 452402465A for ; Sun, 12 Jan 2020 17:32:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ckRx/zjI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733155AbgALRbf (ORCPT ); Sun, 12 Jan 2020 12:31:35 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:43665 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733128AbgALRbe (ORCPT ); Sun, 12 Jan 2020 12:31:34 -0500 Received: by mail-lf1-f67.google.com with SMTP id 9so5146929lfq.10; Sun, 12 Jan 2020 09:31:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YZYwRmQjEuEhcnI0jgHwdUL+48TsLbPTNE42sZnH8KA=; b=ckRx/zjIZyskvdQZRC0uBXbbt+Ys2YUI3OO9lw5CwxdJWiLPm76MKQqDhKCJWxH6Hl d0BJUTrk5IRxhv8nJOVpdXr5k5rwBcP7vQVxxw+AR6aHulFIfrUD/N0NqUxqNGo+CuXJ wYo8lsavKh4je+iICNhBJk6VEreyU/ppWAkQ4X0akPyUAvB+9uaOchchcFYfLcgE3seR e1RmZnxMpUUY4fIO/k+Fijz/lGRM9LWEfJv56mSwwCzYSnu/8OcC/kQoEsMAd63KdE0E RLbbr3NPN5Ek079wEGCDYlOpvgLIl5HfTRikLXwQfdyUtWCWeClNe6C7gYD5QPQZrFHc ykZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YZYwRmQjEuEhcnI0jgHwdUL+48TsLbPTNE42sZnH8KA=; b=GZ5FjdpnN//gmFdEbLJbDw/duSEXZ32zqIq6goD82RbZYKgn13zQGZKOOHXgXUkLzn 4r1Lmh9CNkgsrhaDj6ZUSJMh7bKGasJPOLiZNoQzkdSDN9v8IxdvQkHYs+exsfNjLP5h RLXcKvBOV+G81E0Xql0QjaQQGSf6sBt7dgU0ej6GTUZJj1TcnKT9sGFJqw2JA/HZiY96 x1bTLHnfKqDJFJb1yow+TJ7ATlW9ZY/c2lBr0ib+/JCUjxaybrxSOpGW1JfYf7oIN6Ro PkrYVdF8livFu/degCk8fKTmnzowVN4aiMTFnxXX/FUkzkqxUxeIZY8a6KK8GHSr6hX2 K5KQ== X-Gm-Message-State: APjAAAXe60boflwcwnL+S/asc8XmvN8oXL71k5o4VJhONmqBRCXMeybo cpahet1ll8643wlKbc5PMXY= X-Google-Smtp-Source: APXvYqx3xJWT8cwcFcD+VawFDN2Xc/5qx/EW3kcM1KdqLFEkUAUMNCjpXGaFWhimLvssZ0FkFiehVg== X-Received: by 2002:a19:3f51:: with SMTP id m78mr7482701lfa.70.1578850292504; Sun, 12 Jan 2020 09:31:32 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:32 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 04/14] dmaengine: tegra-apb: Clean up tasklet releasing Date: Sun, 12 Jan 2020 20:29:56 +0300 Message-Id: <20200112173006.29863-5-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org There is no need to kill tasklet when driver's probe fails because tasklet can't be scheduled at this time. It is also cleaner to kill tasklet on channel's freeing rather than to kill it on driver's removal, otherwise tasklet could perform a dummy execution after channel's releasing, which isn't very nice. Signed-off-by: Dmitry Osipenko Acked-by: Jon Hunter --- drivers/dma/tegra20-apb-dma.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 24ad3a5a04e3..1b8a11804962 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1287,7 +1287,6 @@ static void tegra_dma_free_chan_resources(struct dma_chan *dc) struct tegra_dma_sg_req *sg_req; struct list_head dma_desc_list; struct list_head sg_req_list; - unsigned long flags; INIT_LIST_HEAD(&dma_desc_list); INIT_LIST_HEAD(&sg_req_list); @@ -1295,15 +1294,14 @@ static void tegra_dma_free_chan_resources(struct dma_chan *dc) dev_dbg(tdc2dev(tdc), "Freeing channel %d\n", tdc->id); tegra_dma_terminate_all(dc); + tasklet_kill(&tdc->tasklet); - spin_lock_irqsave(&tdc->lock, flags); list_splice_init(&tdc->pending_sg_req, &sg_req_list); list_splice_init(&tdc->free_sg_req, &sg_req_list); list_splice_init(&tdc->free_dma_desc, &dma_desc_list); INIT_LIST_HEAD(&tdc->cb_desc); tdc->config_init = false; tdc->isr_handler = NULL; - spin_unlock_irqrestore(&tdc->lock, flags); while (!list_empty(&dma_desc_list)) { dma_desc = list_first_entry(&dma_desc_list, @@ -1542,7 +1540,6 @@ static int tegra_dma_probe(struct platform_device *pdev) struct tegra_dma_channel *tdc = &tdma->channels[i]; free_irq(tdc->irq, tdc); - tasklet_kill(&tdc->tasklet); } pm_runtime_disable(&pdev->dev); @@ -1562,7 +1559,6 @@ static int tegra_dma_remove(struct platform_device *pdev) for (i = 0; i < tdma->chip_data->nr_channels; ++i) { tdc = &tdma->channels[i]; free_irq(tdc->irq, tdc); - tasklet_kill(&tdc->tasklet); } pm_runtime_disable(&pdev->dev); From patchwork Sun Jan 12 17:29:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329293 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12D991580 for ; Sun, 12 Jan 2020 17:32:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E60B424656 for ; Sun, 12 Jan 2020 17:32:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jLYnfmpa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733165AbgALRbg (ORCPT ); Sun, 12 Jan 2020 12:31:36 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:38623 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733130AbgALRbf (ORCPT ); Sun, 12 Jan 2020 12:31:35 -0500 Received: by mail-lj1-f196.google.com with SMTP id w1so7453864ljh.5; Sun, 12 Jan 2020 09:31:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PqNp1UdCqeyiLALCUBHMvdBWRB+JgxkXykXZjY6I1uo=; b=jLYnfmpaDvagxToMteOAX02zqX3JdNkY1NNHBc2V5F5AdomTR+cE43o9jQF5NkfiT3 zIJ6R3KAGRSEB55TbV/s00z+cspVPJu57SEXavK810Ltu/e7aTLBJv46aminE9dl2Xr4 eIltzKsXZtcwwMQ8XUbJzG+VAjZZzguzhCU7MYTLrn1W+aMpWWeKJl5+rsWdMitZqm6Q bg8TIcM0sucYLne1Zpf+h0F512rbtXkfho1/Vo4ZR1mMzT9YXGoE4UsM3GJvoiXV8IR4 +QUgA9pt4YDqFvUUg4KCxY1Qt8e0r6RXPrA1IZapuP2tsieeOummlM4APJrp6yVZQIYO XqYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PqNp1UdCqeyiLALCUBHMvdBWRB+JgxkXykXZjY6I1uo=; b=Zso5z+trE9JvTckMSarhzSHtcqHpNw4AodnGSb59lGbzMhvDteBmw5fB/bFCgBTFzC oUHEG/CfC5CJ7EeaCmALQY4eeExrUfftJYhNjgTkPJWvhhwJum88f3V9v8QxW1FB0OEF 3gTcRsDYzzfhBwMH2oU5MnyWHD7myWP+sl8nVYGGQwcHVig5GYDekB19WUmnW7vWi7te 7KTSQ1Yk/91xC6ej/LN+6wSNCAN9wBpUWk3wYbXS/ORFBC39LvX9Ze6sxSVCaKt9Vdro 6RzodL4Z4fK+HN+AUj/ayYpgEWpWBJ4j2UGibiRqOSMC9Tj71Kd1+a0BC52bmFIO2Lev ujwA== X-Gm-Message-State: APjAAAVQdEldWZd1h+HUUo6pjtc4EWXUXlcdwU1uo9bytOFLHh5pNuRh kPIguhPUOkEOyuk5KT7LZVM= X-Google-Smtp-Source: APXvYqyk69gPnTU1szw7MirFqod0bsijIASrwmHqWCpYENr6jHmuA6nt+B6zXBSrYyGl34NYqcEkbQ== X-Received: by 2002:a2e:b0c4:: with SMTP id g4mr8281818ljl.83.1578850293432; Sun, 12 Jan 2020 09:31:33 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:32 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 05/14] dmaengine: tegra-apb: Prevent race conditions of tasklet vs free list Date: Sun, 12 Jan 2020 20:29:57 +0300 Message-Id: <20200112173006.29863-6-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org The interrupt handler puts a half-completed DMA descriptor on a free list and then schedules tasklet to process bottom half of the descriptor that executes client's callback, this creates possibility to pick up the busy descriptor from the free list. Thus let's disallow descriptor's re-use until it is fully processed. Signed-off-by: Dmitry Osipenko Acked-by: Jon Hunter --- drivers/dma/tegra20-apb-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 1b8a11804962..aafad50d075e 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -281,7 +281,7 @@ static struct tegra_dma_desc *tegra_dma_desc_get( /* Do not allocate if desc are waiting for ack */ list_for_each_entry(dma_desc, &tdc->free_dma_desc, node) { - if (async_tx_test_ack(&dma_desc->txd)) { + if (async_tx_test_ack(&dma_desc->txd) && !dma_desc->cb_count) { list_del(&dma_desc->node); spin_unlock_irqrestore(&tdc->lock, flags); dma_desc->txd.flags = 0; From patchwork Sun Jan 12 17:29:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329299 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD6431820 for ; Sun, 12 Jan 2020 17:32:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B05624656 for ; Sun, 12 Jan 2020 17:32:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TU4wcA6d" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733307AbgALRc0 (ORCPT ); Sun, 12 Jan 2020 12:32:26 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:36121 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733152AbgALRbg (ORCPT ); Sun, 12 Jan 2020 12:31:36 -0500 Received: by mail-lf1-f65.google.com with SMTP id n12so5153666lfe.3; Sun, 12 Jan 2020 09:31:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KfuSooXOkxJU0/VsQZ2ZGbsgKKy+nQ25m7jbl5DejHM=; b=TU4wcA6dES1E3c5DikAX5RTjfTAZDt++p3dfUk6koqvGT7aJcOMgP66k2vRwLjpkeV ogz4EWKuGcXhDZYNq55NsB26SkKU3K6jM87WGFl4eme3GSP6G2Sb4geiLP18Pu29Gjhu uWmyN+6G+t9XN6uESFmQHr0n2W5kevJBDgIA1j7oq58leYbTkKN2WFhA3uZ57rKvEgxM lqDINrg4ZhyTjljew0ULQWQ2GcM6njyusH9zi8MbLq30mZlMqfoQcqMq2jve2hfDLdnP cyYX9wziAbqmbFErQSC/LuChu8Z60/sPKm3h2Rj6/khk7tu3XE+z59bVgUJXqFKmAKAt LRNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KfuSooXOkxJU0/VsQZ2ZGbsgKKy+nQ25m7jbl5DejHM=; b=Px5TMBjtA442Snt5P4pM4nAk5KB2XRlo9TpcuzRVdPNwFQnCIny11g/yB4ZTHdJUCt D+VbKdFlKeSJVtnL5lOhM3JCXvmbufNWo/wXKDz1HJNumS+Qn4ff6tTiPBqiINWNtQFW UEzONxWQAFJ4iOzf7v1nGMtMIxEdR+FcseFefMGvPDjhjhsT5ChfVH2Ktu2CtzwckUAN ccKoSQw6z737VsSnKw15z/w905EjpETJHDsrbSxXSwdSUadkq+d86u13qj92IvHPnyIm /tinW8PDVa3W/rRGeoXOS/eqWKSVFkmYz+Ba1zq1ueJ9QGNlmvKkoKD/jw3P952UIfpt 7Ifw== X-Gm-Message-State: APjAAAV0f1gSFnTnOxHYu/np1TNQTeBmgdNkFuWrrEPaQxs+172YbB2Q Fv5rSvdvVQhWf/6uUWJi7nc= X-Google-Smtp-Source: APXvYqwULa8/QnjzJ8ktnccpfzu7jYvhSJqzgEte3YBhequmV+ogCORMJn9TE5/4LXrlF7lPYudTnQ== X-Received: by 2002:ac2:5f68:: with SMTP id c8mr5501762lfc.196.1578850294315; Sun, 12 Jan 2020 09:31:34 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:33 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 06/14] dmaengine: tegra-apb: Use devm_platform_ioremap_resource Date: Sun, 12 Jan 2020 20:29:58 +0300 Message-Id: <20200112173006.29863-7-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Use devm_platform_ioremap_resource to keep code cleaner a tad. Signed-off-by: Dmitry Osipenko Acked-by: Jon Hunter --- drivers/dma/tegra20-apb-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index aafad50d075e..f44291207928 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1402,8 +1402,7 @@ static int tegra_dma_probe(struct platform_device *pdev) tdma->chip_data = cdata; platform_set_drvdata(pdev, tdma); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - tdma->base_addr = devm_ioremap_resource(&pdev->dev, res); + tdma->base_addr = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(tdma->base_addr)) return PTR_ERR(tdma->base_addr); From patchwork Sun Jan 12 17:29:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329289 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E239E1580 for ; Sun, 12 Jan 2020 17:32:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C0DDE2187F for ; Sun, 12 Jan 2020 17:32:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NlqpxYRJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733173AbgALRbi (ORCPT ); Sun, 12 Jan 2020 12:31:38 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36124 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733159AbgALRbh (ORCPT ); Sun, 12 Jan 2020 12:31:37 -0500 Received: by mail-lf1-f68.google.com with SMTP id n12so5153682lfe.3; Sun, 12 Jan 2020 09:31:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pxocVjmZG/Uueu6zkGsV3Kg82ZUCb0WJfl2eGCqi6Qo=; b=NlqpxYRJzE9Q/JBrHE3GypkKY7e7ne5n2WrmAPaWBodQAymTD+YeRXrMvgGWOgzNNp FPsEYBVau78AcuVHzgoTvaBHw78I8I0IGoc/O7/87Aq75kO1QnjRS8ugx5BDo7CYVffS UAXQnJ1nrLPNZ5tKFXgcAlUO6mZk2Bhy/k0/MgoXhwdBHum2qLcODm6vgCith9pO092z mk/BISKs5dKOKKTIOZA+rJdB9yuMQew9HOTqX2QKqGVl/mQDAe1xP5UnxJQVrjVmQR1X RSlV9uNM3+iJx8ilUjTd2aEeIAiwR0GzPUwX6C6YuYqwmUa7BC1LkHC0gZ+mwtApzx6J 1V2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pxocVjmZG/Uueu6zkGsV3Kg82ZUCb0WJfl2eGCqi6Qo=; b=ec4MG+SDpLQ212tZT9z6Jl6hwCs/dYpBPPiFSbpJ6/9JOKZplliJ2PaUJHozuURdF2 9ZCtfi4aknNmO4Ej2ngr9zOCeW2UyqVTv+b+Bv5cW55N2xi7xENGfsGp9ef3HQj4FUDk //dHfP9m4lbhzlSHHPMubtyICq95E2P8yznq1iis0UR2XhoQvgoNvSIi28QjOcDd6IaL 3OeAvL1oITrU2PQkze3CM52U54blfzJMNxCoYrIUsCwofA113NUe6o5YErc/dvw/3R8z TAQoGe9Jbq1Tw2JcyEbF4W9FeiHhg16K05g+JeEtpAXzRr61AjaIRyqXI5QG9u3i5Np/ MuyQ== X-Gm-Message-State: APjAAAUD5VrTlWULyrCCpOA8uM2ShII/SQbuMa8uR3pfCLM52apx/Ar0 zPrHe05cKccdAI0Az4lZAkg= X-Google-Smtp-Source: APXvYqwdVZ/xBI3GWVdWTq708g9TT101L2vxnFoXUfn46hhYDF89+mdleVnanZNsRTQIKPYvlFBEaA== X-Received: by 2002:a19:f619:: with SMTP id x25mr7511282lfe.146.1578850295208; Sun, 12 Jan 2020 09:31:35 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:34 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 07/14] dmaengine: tegra-apb: Use devm_request_irq Date: Sun, 12 Jan 2020 20:29:59 +0300 Message-Id: <20200112173006.29863-8-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Use resource-managed variant of request_irq for brevity. Signed-off-by: Dmitry Osipenko Acked-by: Jon Hunter --- drivers/dma/tegra20-apb-dma.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index f44291207928..dff21e80ffa4 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -182,7 +182,6 @@ struct tegra_dma_channel { char name[12]; bool config_init; int id; - int irq; void __iomem *chan_addr; spinlock_t lock; bool busy; @@ -1380,7 +1379,6 @@ static const struct tegra_dma_chip_data tegra148_dma_chip_data = { static int tegra_dma_probe(struct platform_device *pdev) { - struct resource *res; struct tegra_dma *tdma; int ret; int i; @@ -1446,25 +1444,27 @@ static int tegra_dma_probe(struct platform_device *pdev) INIT_LIST_HEAD(&tdma->dma_dev.channels); for (i = 0; i < cdata->nr_channels; i++) { struct tegra_dma_channel *tdc = &tdma->channels[i]; + int irq; tdc->chan_addr = tdma->base_addr + TEGRA_APBDMA_CHANNEL_BASE_ADD_OFFSET + (i * cdata->channel_reg_size); - res = platform_get_resource(pdev, IORESOURCE_IRQ, i); - if (!res) { - ret = -EINVAL; + irq = platform_get_irq(pdev, i); + if (irq < 0) { + ret = irq; dev_err(&pdev->dev, "No irq resource for chan %d\n", i); - goto err_irq; + goto err_pm_disable; } - tdc->irq = res->start; + snprintf(tdc->name, sizeof(tdc->name), "apbdma.%d", i); - ret = request_irq(tdc->irq, tegra_dma_isr, 0, tdc->name, tdc); + ret = devm_request_irq(&pdev->dev, irq, tegra_dma_isr, 0, + tdc->name, tdc); if (ret) { dev_err(&pdev->dev, "request_irq failed with err %d channel %d\n", ret, i); - goto err_irq; + goto err_pm_disable; } tdc->dma_chan.device = &tdma->dma_dev; @@ -1517,7 +1517,7 @@ static int tegra_dma_probe(struct platform_device *pdev) if (ret < 0) { dev_err(&pdev->dev, "Tegra20 APB DMA driver registration failed %d\n", ret); - goto err_irq; + goto err_pm_disable; } ret = of_dma_controller_register(pdev->dev.of_node, @@ -1534,13 +1534,7 @@ static int tegra_dma_probe(struct platform_device *pdev) err_unregister_dma_dev: dma_async_device_unregister(&tdma->dma_dev); -err_irq: - while (--i >= 0) { - struct tegra_dma_channel *tdc = &tdma->channels[i]; - - free_irq(tdc->irq, tdc); - } - +err_pm_disable: pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) tegra_dma_runtime_suspend(&pdev->dev); @@ -1550,16 +1544,9 @@ static int tegra_dma_probe(struct platform_device *pdev) static int tegra_dma_remove(struct platform_device *pdev) { struct tegra_dma *tdma = platform_get_drvdata(pdev); - int i; - struct tegra_dma_channel *tdc; dma_async_device_unregister(&tdma->dma_dev); - for (i = 0; i < tdma->chip_data->nr_channels; ++i) { - tdc = &tdma->channels[i]; - free_irq(tdc->irq, tdc); - } - pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) tegra_dma_runtime_suspend(&pdev->dev); From patchwork Sun Jan 12 17:30:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329287 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7106921 for ; Sun, 12 Jan 2020 17:32:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 81A2624654 for ; Sun, 12 Jan 2020 17:32:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bM7sWd7m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733285AbgALRcQ (ORCPT ); Sun, 12 Jan 2020 12:32:16 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:42251 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733167AbgALRbk (ORCPT ); Sun, 12 Jan 2020 12:31:40 -0500 Received: by mail-lf1-f65.google.com with SMTP id y19so5143121lfl.9; Sun, 12 Jan 2020 09:31:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yUd6lpyTU/7Nm+cwLJMDV54bolqX/wMqfpfAeQdOYdQ=; b=bM7sWd7mbhZmLNL9+eT7IjXa7vFSWYGnTK+/fGG/4P1guope4WCyo7Ok6oonKb3qQ+ /lLnfpTrJbHKDnT+HzeNLVzH4MQ0mDvI5wAXMe9len3jp6xXUR9dUQc8sAmD7O8MsOoj tOFIfyRb9BpgUOTyRI9Z9LNdpk//gOIXBcDHi35hWyLWESG7Op5NhNRTDS4ribmhBVAC AygLqnepN1LrMCM/rbqja++uwC9mbRMyJ4DlfEnC5cgN0YP8tLHiKriDUTRSEYukiwUm bM6yvO5j4kq8dQ1HY7UHBGTax4O9GeN94H6NXxkKiwttGA/HM9WsAahFkTexa9GDzsMZ FlmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yUd6lpyTU/7Nm+cwLJMDV54bolqX/wMqfpfAeQdOYdQ=; b=RJ6sDgV63lX//G2BGvbwCFvGgSRYaUIr/RkiYWf+eDd3+il8Y2X4+TPMrprzYEOanW sSZ+8tCWi79ba3WrUHK5P2rAEItrvNh3/YbjNUJ1qZC2MfspLaO0/EHwJ8Haw8/NyJcS biSJCFWIL9X4GMsg+uY+Gb841X5C40KEQgHu6rFjWXRCePB6Z1/U2lRKGLesJAn1NSKH f+wRZ4mnKLfSofofOsV3bpJGCNcHEYpgfcKpSULwNPuGe5/90fa6I+2GywniCQmShfPg WobWX9e0moMasFt6MifjCaHl3nemH9XgpvHqdYSA0J2nbU7zh4UMDua4b7OVuYUULwCF ksoA== X-Gm-Message-State: APjAAAXymf0aoF1By33vyFnwjEqrcIjjLe/cwX7Q/4VDAKF9cWl1QyWJ nq91c/Pdq82cZ770OVMwDNg= X-Google-Smtp-Source: APXvYqzceWtLjBFQPdTDma6Tq2OKvxlq8DuBFZmc1ENjzpgyO64steRvkCOJiTWjwliT5GZTrPEm2A== X-Received: by 2002:ac2:544f:: with SMTP id d15mr7822680lfn.126.1578850296205; Sun, 12 Jan 2020 09:31:36 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:35 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 08/14] dmaengine: tegra-apb: Fix coding style problems Date: Sun, 12 Jan 2020 20:30:00 +0300 Message-Id: <20200112173006.29863-9-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org This patch fixes few dozens of coding style problems reported by checkpatch and prettifies code where makes sense. Signed-off-by: Dmitry Osipenko --- drivers/dma/tegra20-apb-dma.c | 276 ++++++++++++++++++---------------- 1 file changed, 144 insertions(+), 132 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index dff21e80ffa4..7158bd3145c4 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -59,7 +59,7 @@ #define TEGRA_APBDMA_STATUS_COUNT_MASK 0xFFFC #define TEGRA_APBDMA_CHAN_CSRE 0x00C -#define TEGRA_APBDMA_CHAN_CSRE_PAUSE (1 << 31) +#define TEGRA_APBDMA_CHAN_CSRE_PAUSE BIT(31) /* AHB memory address */ #define TEGRA_APBDMA_CHAN_AHBPTR 0x010 @@ -120,21 +120,21 @@ struct tegra_dma; * @support_separate_wcount_reg: Support separate word count register. */ struct tegra_dma_chip_data { - int nr_channels; - int channel_reg_size; - int max_dma_count; + unsigned int nr_channels; + unsigned int channel_reg_size; + unsigned int max_dma_count; bool support_channel_pause; bool support_separate_wcount_reg; }; /* DMA channel registers */ struct tegra_dma_channel_regs { - unsigned long csr; - unsigned long ahb_ptr; - unsigned long apb_ptr; - unsigned long ahb_seq; - unsigned long apb_seq; - unsigned long wcount; + u32 csr; + u32 ahb_ptr; + u32 apb_ptr; + u32 ahb_seq; + u32 apb_seq; + u32 wcount; }; /* @@ -168,7 +168,7 @@ struct tegra_dma_desc { struct list_head node; struct list_head tx_list; struct list_head cb_node; - int cb_count; + unsigned int cb_count; }; struct tegra_dma_channel; @@ -181,7 +181,7 @@ struct tegra_dma_channel { struct dma_chan dma_chan; char name[12]; bool config_init; - int id; + unsigned int id; void __iomem *chan_addr; spinlock_t lock; bool busy; @@ -201,7 +201,7 @@ struct tegra_dma_channel { /* Channel-slave specific configuration */ unsigned int slave_id; struct dma_slave_config dma_sconfig; - struct tegra_dma_channel_regs channel_reg; + struct tegra_dma_channel_regs channel_reg; }; /* tegra_dma: Tegra DMA specific information */ @@ -239,7 +239,7 @@ static inline u32 tdma_read(struct tegra_dma *tdma, u32 reg) } static inline void tdc_write(struct tegra_dma_channel *tdc, - u32 reg, u32 val) + u32 reg, u32 val) { writel(val, tdc->chan_addr + reg); } @@ -254,8 +254,8 @@ static inline struct tegra_dma_channel *to_tegra_dma_chan(struct dma_chan *dc) return container_of(dc, struct tegra_dma_channel, dma_chan); } -static inline struct tegra_dma_desc *txd_to_tegra_dma_desc( - struct dma_async_tx_descriptor *td) +static inline struct tegra_dma_desc * +txd_to_tegra_dma_desc(struct dma_async_tx_descriptor *td) { return container_of(td, struct tegra_dma_desc, txd); } @@ -270,8 +270,7 @@ static int tegra_dma_runtime_suspend(struct device *dev); static int tegra_dma_runtime_resume(struct device *dev); /* Get DMA desc from free list, if not there then allocate it. */ -static struct tegra_dma_desc *tegra_dma_desc_get( - struct tegra_dma_channel *tdc) +static struct tegra_dma_desc *tegra_dma_desc_get(struct tegra_dma_channel *tdc) { struct tegra_dma_desc *dma_desc; unsigned long flags; @@ -298,11 +297,12 @@ static struct tegra_dma_desc *tegra_dma_desc_get( dma_async_tx_descriptor_init(&dma_desc->txd, &tdc->dma_chan); dma_desc->txd.tx_submit = tegra_dma_tx_submit; dma_desc->txd.flags = 0; + return dma_desc; } static void tegra_dma_desc_put(struct tegra_dma_channel *tdc, - struct tegra_dma_desc *dma_desc) + struct tegra_dma_desc *dma_desc) { unsigned long flags; @@ -313,29 +313,29 @@ static void tegra_dma_desc_put(struct tegra_dma_channel *tdc, spin_unlock_irqrestore(&tdc->lock, flags); } -static struct tegra_dma_sg_req *tegra_dma_sg_req_get( - struct tegra_dma_channel *tdc) +static struct tegra_dma_sg_req * +tegra_dma_sg_req_get(struct tegra_dma_channel *tdc) { - struct tegra_dma_sg_req *sg_req = NULL; + struct tegra_dma_sg_req *sg_req; unsigned long flags; spin_lock_irqsave(&tdc->lock, flags); if (!list_empty(&tdc->free_sg_req)) { - sg_req = list_first_entry(&tdc->free_sg_req, - typeof(*sg_req), node); + sg_req = list_first_entry(&tdc->free_sg_req, typeof(*sg_req), + node); list_del(&sg_req->node); spin_unlock_irqrestore(&tdc->lock, flags); return sg_req; } spin_unlock_irqrestore(&tdc->lock, flags); - sg_req = kzalloc(sizeof(struct tegra_dma_sg_req), GFP_NOWAIT); + sg_req = kzalloc(sizeof(*sg_req), GFP_NOWAIT); return sg_req; } static int tegra_dma_slave_config(struct dma_chan *dc, - struct dma_slave_config *sconfig) + struct dma_slave_config *sconfig) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); @@ -352,11 +352,12 @@ static int tegra_dma_slave_config(struct dma_chan *dc, tdc->slave_id = sconfig->slave_id; } tdc->config_init = true; + return 0; } static void tegra_dma_global_pause(struct tegra_dma_channel *tdc, - bool wait_for_burst_complete) + bool wait_for_burst_complete) { struct tegra_dma *tdma = tdc->tdma; @@ -391,13 +392,13 @@ static void tegra_dma_global_resume(struct tegra_dma_channel *tdc) } static void tegra_dma_pause(struct tegra_dma_channel *tdc, - bool wait_for_burst_complete) + bool wait_for_burst_complete) { struct tegra_dma *tdma = tdc->tdma; if (tdma->chip_data->support_channel_pause) { tdc_write(tdc, TEGRA_APBDMA_CHAN_CSRE, - TEGRA_APBDMA_CHAN_CSRE_PAUSE); + TEGRA_APBDMA_CHAN_CSRE_PAUSE); if (wait_for_burst_complete) udelay(TEGRA_APBDMA_BURST_COMPLETE_TIME); } else { @@ -409,17 +410,15 @@ static void tegra_dma_resume(struct tegra_dma_channel *tdc) { struct tegra_dma *tdma = tdc->tdma; - if (tdma->chip_data->support_channel_pause) { + if (tdma->chip_data->support_channel_pause) tdc_write(tdc, TEGRA_APBDMA_CHAN_CSRE, 0); - } else { + else tegra_dma_global_resume(tdc); - } } static void tegra_dma_stop(struct tegra_dma_channel *tdc) { - u32 csr; - u32 status; + u32 csr, status; /* Disable interrupts */ csr = tdc_read(tdc, TEGRA_APBDMA_CHAN_CSR); @@ -440,7 +439,7 @@ static void tegra_dma_stop(struct tegra_dma_channel *tdc) } static void tegra_dma_start(struct tegra_dma_channel *tdc, - struct tegra_dma_sg_req *sg_req) + struct tegra_dma_sg_req *sg_req) { struct tegra_dma_channel_regs *ch_regs = &sg_req->ch_regs; @@ -454,11 +453,11 @@ static void tegra_dma_start(struct tegra_dma_channel *tdc, /* Start DMA */ tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR, - ch_regs->csr | TEGRA_APBDMA_CSR_ENB); + ch_regs->csr | TEGRA_APBDMA_CSR_ENB); } static void tegra_dma_configure_for_next(struct tegra_dma_channel *tdc, - struct tegra_dma_sg_req *nsg_req) + struct tegra_dma_sg_req *nsg_req) { unsigned long status; @@ -492,9 +491,9 @@ static void tegra_dma_configure_for_next(struct tegra_dma_channel *tdc, tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBPTR, nsg_req->ch_regs.ahb_ptr); if (tdc->tdma->chip_data->support_separate_wcount_reg) tdc_write(tdc, TEGRA_APBDMA_CHAN_WCOUNT, - nsg_req->ch_regs.wcount); + nsg_req->ch_regs.wcount); tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR, - nsg_req->ch_regs.csr | TEGRA_APBDMA_CSR_ENB); + nsg_req->ch_regs.csr | TEGRA_APBDMA_CSR_ENB); nsg_req->configured = true; nsg_req->words_xferred = 0; @@ -508,8 +507,7 @@ static void tdc_start_head_req(struct tegra_dma_channel *tdc) if (list_empty(&tdc->pending_sg_req)) return; - sg_req = list_first_entry(&tdc->pending_sg_req, - typeof(*sg_req), node); + sg_req = list_first_entry(&tdc->pending_sg_req, typeof(*sg_req), node); tegra_dma_start(tdc, sg_req); sg_req->configured = true; sg_req->words_xferred = 0; @@ -518,34 +516,35 @@ static void tdc_start_head_req(struct tegra_dma_channel *tdc) static void tdc_configure_next_head_desc(struct tegra_dma_channel *tdc) { - struct tegra_dma_sg_req *hsgreq; - struct tegra_dma_sg_req *hnsgreq; + struct tegra_dma_sg_req *hsgreq, *hnsgreq; if (list_empty(&tdc->pending_sg_req)) return; hsgreq = list_first_entry(&tdc->pending_sg_req, typeof(*hsgreq), node); if (!list_is_last(&hsgreq->node, &tdc->pending_sg_req)) { - hnsgreq = list_first_entry(&hsgreq->node, - typeof(*hnsgreq), node); + hnsgreq = list_first_entry(&hsgreq->node, typeof(*hnsgreq), + node); tegra_dma_configure_for_next(tdc, hnsgreq); } } -static inline int get_current_xferred_count(struct tegra_dma_channel *tdc, - struct tegra_dma_sg_req *sg_req, unsigned long status) +static inline unsigned int +get_current_xferred_count(struct tegra_dma_channel *tdc, + struct tegra_dma_sg_req *sg_req, + unsigned long status) { return sg_req->req_len - (status & TEGRA_APBDMA_STATUS_COUNT_MASK) - 4; } static void tegra_dma_abort_all(struct tegra_dma_channel *tdc) { - struct tegra_dma_sg_req *sgreq; struct tegra_dma_desc *dma_desc; + struct tegra_dma_sg_req *sgreq; while (!list_empty(&tdc->pending_sg_req)) { - sgreq = list_first_entry(&tdc->pending_sg_req, - typeof(*sgreq), node); + sgreq = list_first_entry(&tdc->pending_sg_req, typeof(*sgreq), + node); list_move_tail(&sgreq->node, &tdc->free_sg_req); if (sgreq->last_sg) { dma_desc = sgreq->dma_desc; @@ -555,7 +554,7 @@ static void tegra_dma_abort_all(struct tegra_dma_channel *tdc) /* Add in cb list if it is not there. */ if (!dma_desc->cb_count) list_add_tail(&dma_desc->cb_node, - &tdc->cb_desc); + &tdc->cb_desc); dma_desc->cb_count++; } } @@ -563,9 +562,10 @@ static void tegra_dma_abort_all(struct tegra_dma_channel *tdc) } static bool handle_continuous_head_request(struct tegra_dma_channel *tdc, - struct tegra_dma_sg_req *last_sg_req, bool to_terminate) + struct tegra_dma_sg_req *last_sg_req, + bool to_terminate) { - struct tegra_dma_sg_req *hsgreq = NULL; + struct tegra_dma_sg_req *hsgreq; if (list_empty(&tdc->pending_sg_req)) { dev_err(tdc2dev(tdc), "DMA is running without req\n"); @@ -589,14 +589,15 @@ static bool handle_continuous_head_request(struct tegra_dma_channel *tdc, /* Configure next request */ if (!to_terminate) tdc_configure_next_head_desc(tdc); + return true; } static void handle_once_dma_done(struct tegra_dma_channel *tdc, - bool to_terminate) + bool to_terminate) { - struct tegra_dma_sg_req *sgreq; struct tegra_dma_desc *dma_desc; + struct tegra_dma_sg_req *sgreq; tdc->busy = false; sgreq = list_first_entry(&tdc->pending_sg_req, typeof(*sgreq), node); @@ -622,10 +623,10 @@ static void handle_once_dma_done(struct tegra_dma_channel *tdc, } static void handle_cont_sngl_cycle_dma_done(struct tegra_dma_channel *tdc, - bool to_terminate) + bool to_terminate) { - struct tegra_dma_sg_req *sgreq; struct tegra_dma_desc *dma_desc; + struct tegra_dma_sg_req *sgreq; bool st; sgreq = list_first_entry(&tdc->pending_sg_req, typeof(*sgreq), node); @@ -657,13 +658,13 @@ static void tegra_dma_tasklet(unsigned long data) struct tegra_dma_channel *tdc = (struct tegra_dma_channel *)data; struct dmaengine_desc_callback cb; struct tegra_dma_desc *dma_desc; + unsigned int cb_count; unsigned long flags; - int cb_count; spin_lock_irqsave(&tdc->lock, flags); while (!list_empty(&tdc->cb_desc)) { - dma_desc = list_first_entry(&tdc->cb_desc, - typeof(*dma_desc), cb_node); + dma_desc = list_first_entry(&tdc->cb_desc, typeof(*dma_desc), + cb_node); list_del(&dma_desc->cb_node); dmaengine_desc_get_callback(&dma_desc->txd, &cb); cb_count = dma_desc->cb_count; @@ -681,8 +682,8 @@ static void tegra_dma_tasklet(unsigned long data) static irqreturn_t tegra_dma_isr(int irq, void *dev_id) { struct tegra_dma_channel *tdc = dev_id; - unsigned long status; unsigned long flags; + u32 status; spin_lock_irqsave(&tdc->lock, flags); @@ -697,8 +698,9 @@ static irqreturn_t tegra_dma_isr(int irq, void *dev_id) } spin_unlock_irqrestore(&tdc->lock, flags); - dev_info(tdc2dev(tdc), - "Interrupt already served status 0x%08lx\n", status); + dev_info(tdc2dev(tdc), "Interrupt already served status 0x%08x\n", + status); + return IRQ_NONE; } @@ -714,6 +716,7 @@ static dma_cookie_t tegra_dma_tx_submit(struct dma_async_tx_descriptor *txd) cookie = dma_cookie_assign(&dma_desc->txd); list_splice_tail_init(&dma_desc->tx_list, &tdc->pending_sg_req); spin_unlock_irqrestore(&tdc->lock, flags); + return cookie; } @@ -747,11 +750,10 @@ static void tegra_dma_issue_pending(struct dma_chan *dc) static int tegra_dma_terminate_all(struct dma_chan *dc) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); - struct tegra_dma_sg_req *sgreq; struct tegra_dma_desc *dma_desc; + struct tegra_dma_sg_req *sgreq; unsigned long flags; - unsigned long status; - unsigned long wcount; + u32 status, wcount; bool was_busy; spin_lock_irqsave(&tdc->lock, flags); @@ -777,8 +779,8 @@ static int tegra_dma_terminate_all(struct dma_chan *dc) tegra_dma_stop(tdc); if (!list_empty(&tdc->pending_sg_req) && was_busy) { - sgreq = list_first_entry(&tdc->pending_sg_req, - typeof(*sgreq), node); + sgreq = list_first_entry(&tdc->pending_sg_req, typeof(*sgreq), + node); sgreq->dma_desc->bytes_transferred += get_current_xferred_count(tdc, sgreq, wcount); } @@ -788,12 +790,13 @@ static int tegra_dma_terminate_all(struct dma_chan *dc) tegra_dma_abort_all(tdc); while (!list_empty(&tdc->cb_desc)) { - dma_desc = list_first_entry(&tdc->cb_desc, - typeof(*dma_desc), cb_node); + dma_desc = list_first_entry(&tdc->cb_desc, typeof(*dma_desc), + cb_node); list_del(&dma_desc->cb_node); dma_desc->cb_count = 0; } spin_unlock_irqrestore(&tdc->lock, flags); + return 0; } @@ -807,7 +810,7 @@ static void tegra_dma_synchronize(struct dma_chan *dc) static unsigned int tegra_dma_sg_bytes_xferred(struct tegra_dma_channel *tdc, struct tegra_dma_sg_req *sg_req) { - unsigned long status, wcount = 0; + u32 status, wcount = 0; if (!list_is_first(&sg_req->node, &tdc->pending_sg_req)) return 0; @@ -864,7 +867,8 @@ static unsigned int tegra_dma_sg_bytes_xferred(struct tegra_dma_channel *tdc, } static enum dma_status tegra_dma_tx_status(struct dma_chan *dc, - dma_cookie_t cookie, struct dma_tx_state *txstate) + dma_cookie_t cookie, + struct dma_tx_state *txstate) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); struct tegra_dma_desc *dma_desc; @@ -911,11 +915,12 @@ static enum dma_status tegra_dma_tx_status(struct dma_chan *dc, trace_tegra_dma_tx_status(&tdc->dma_chan, cookie, txstate); spin_unlock_irqrestore(&tdc->lock, flags); + return ret; } -static inline int get_bus_width(struct tegra_dma_channel *tdc, - enum dma_slave_buswidth slave_bw) +static inline unsigned int get_bus_width(struct tegra_dma_channel *tdc, + enum dma_slave_buswidth slave_bw) { switch (slave_bw) { case DMA_SLAVE_BUSWIDTH_1_BYTE: @@ -928,16 +933,17 @@ static inline int get_bus_width(struct tegra_dma_channel *tdc, return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_64; default: dev_warn(tdc2dev(tdc), - "slave bw is not supported, using 32bits\n"); + "slave bw is not supported, using 32bits\n"); return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_32; } } -static inline int get_burst_size(struct tegra_dma_channel *tdc, - u32 burst_size, enum dma_slave_buswidth slave_bw, int len) +static inline unsigned int get_burst_size(struct tegra_dma_channel *tdc, + u32 burst_size, + enum dma_slave_buswidth slave_bw, + u32 len) { - int burst_byte; - int burst_ahb_width; + unsigned int burst_byte, burst_ahb_width; /* * burst_size from client is in terms of the bus_width. @@ -964,9 +970,12 @@ static inline int get_burst_size(struct tegra_dma_channel *tdc, } static int get_transfer_param(struct tegra_dma_channel *tdc, - enum dma_transfer_direction direction, unsigned long *apb_addr, - unsigned long *apb_seq, unsigned long *csr, unsigned int *burst_size, - enum dma_slave_buswidth *slave_bw) + enum dma_transfer_direction direction, + u32 *apb_addr, + u32 *apb_seq, + u32 *csr, + unsigned int *burst_size, + enum dma_slave_buswidth *slave_bw) { switch (direction) { case DMA_MEM_TO_DEV: @@ -987,13 +996,15 @@ static int get_transfer_param(struct tegra_dma_channel *tdc, default: dev_err(tdc2dev(tdc), "DMA direction is not supported\n"); - return -EINVAL; + break; } + return -EINVAL; } static void tegra_dma_prep_wcount(struct tegra_dma_channel *tdc, - struct tegra_dma_channel_regs *ch_regs, u32 len) + struct tegra_dma_channel_regs *ch_regs, + u32 len) { u32 len_field = (len - 4) & 0xFFFC; @@ -1003,20 +1014,23 @@ static void tegra_dma_prep_wcount(struct tegra_dma_channel *tdc, ch_regs->csr |= len_field; } -static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg( - struct dma_chan *dc, struct scatterlist *sgl, unsigned int sg_len, - enum dma_transfer_direction direction, unsigned long flags, - void *context) +static struct dma_async_tx_descriptor * +tegra_dma_prep_slave_sg(struct dma_chan *dc, + struct scatterlist *sgl, + unsigned int sg_len, + enum dma_transfer_direction direction, + unsigned long flags, + void *context) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + struct tegra_dma_sg_req *sg_req = NULL; + u32 csr, ahb_seq, apb_ptr, apb_seq; + enum dma_slave_buswidth slave_bw; struct tegra_dma_desc *dma_desc; - unsigned int i; - struct scatterlist *sg; - unsigned long csr, ahb_seq, apb_ptr, apb_seq; struct list_head req_list; - struct tegra_dma_sg_req *sg_req = NULL; - u32 burst_size; - enum dma_slave_buswidth slave_bw; + struct scatterlist *sg; + unsigned int burst_size; + unsigned int i; if (!tdc->config_init) { dev_err(tdc2dev(tdc), "DMA channel is not configured\n"); @@ -1028,7 +1042,7 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg( } if (get_transfer_param(tdc, direction, &apb_ptr, &apb_seq, &csr, - &burst_size, &slave_bw) < 0) + &burst_size, &slave_bw) < 0) return NULL; INIT_LIST_HEAD(&req_list); @@ -1074,7 +1088,7 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg( len = sg_dma_len(sg); if ((len & 3) || (mem & 3) || - (len > tdc->tdma->chip_data->max_dma_count)) { + len > tdc->tdma->chip_data->max_dma_count) { dev_err(tdc2dev(tdc), "DMA length/memory address is not supported\n"); tegra_dma_desc_put(tdc, dma_desc); @@ -1126,20 +1140,21 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg( return &dma_desc->txd; } -static struct dma_async_tx_descriptor *tegra_dma_prep_dma_cyclic( - struct dma_chan *dc, dma_addr_t buf_addr, size_t buf_len, - size_t period_len, enum dma_transfer_direction direction, - unsigned long flags) +static struct dma_async_tx_descriptor * +tegra_dma_prep_dma_cyclic(struct dma_chan *dc, dma_addr_t buf_addr, + size_t buf_len, + size_t period_len, + enum dma_transfer_direction direction, + unsigned long flags) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); - struct tegra_dma_desc *dma_desc = NULL; struct tegra_dma_sg_req *sg_req = NULL; - unsigned long csr, ahb_seq, apb_ptr, apb_seq; - int len; - size_t remain_len; - dma_addr_t mem = buf_addr; - u32 burst_size; + u32 csr, ahb_seq, apb_ptr, apb_seq; enum dma_slave_buswidth slave_bw; + struct tegra_dma_desc *dma_desc; + dma_addr_t mem = buf_addr; + unsigned int burst_size; + size_t len, remain_len; if (!buf_len || !period_len) { dev_err(tdc2dev(tdc), "Invalid buffer/period len\n"); @@ -1173,13 +1188,13 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_dma_cyclic( len = period_len; if ((len & 3) || (buf_addr & 3) || - (len > tdc->tdma->chip_data->max_dma_count)) { + len > tdc->tdma->chip_data->max_dma_count) { dev_err(tdc2dev(tdc), "Req len/mem address is not correct\n"); return NULL; } if (get_transfer_param(tdc, direction, &apb_ptr, &apb_seq, &csr, - &burst_size, &slave_bw) < 0) + &burst_size, &slave_bw) < 0) return NULL; ahb_seq = TEGRA_APBDMA_AHBSEQ_INTR_ENB; @@ -1269,7 +1284,6 @@ static int tegra_dma_alloc_chan_resources(struct dma_chan *dc) int ret; dma_cookie_init(&tdc->dma_chan); - tdc->config_init = false; ret = pm_runtime_get_sync(tdma->dev); if (ret < 0) @@ -1303,8 +1317,8 @@ static void tegra_dma_free_chan_resources(struct dma_chan *dc) tdc->isr_handler = NULL; while (!list_empty(&dma_desc_list)) { - dma_desc = list_first_entry(&dma_desc_list, - typeof(*dma_desc), node); + dma_desc = list_first_entry(&dma_desc_list, typeof(*dma_desc), + node); list_del(&dma_desc->node); kfree(dma_desc); } @@ -1323,8 +1337,8 @@ static struct dma_chan *tegra_dma_of_xlate(struct of_phandle_args *dma_spec, struct of_dma *ofdma) { struct tegra_dma *tdma = ofdma->of_dma_data; - struct dma_chan *chan; struct tegra_dma_channel *tdc; + struct dma_chan *chan; if (dma_spec->args[0] > TEGRA_APBDMA_CSR_REQ_SEL_MASK) { dev_err(tdma->dev, "Invalid slave id: %d\n", dma_spec->args[0]); @@ -1379,20 +1393,16 @@ static const struct tegra_dma_chip_data tegra148_dma_chip_data = { static int tegra_dma_probe(struct platform_device *pdev) { + const struct tegra_dma_chip_data *cdata; struct tegra_dma *tdma; + unsigned int i; + size_t size; int ret; - int i; - const struct tegra_dma_chip_data *cdata; cdata = of_device_get_match_data(&pdev->dev); - if (!cdata) { - dev_err(&pdev->dev, "Error: No device match data found\n"); - return -ENODEV; - } + size = struct_size(tdma, channels, cdata->nr_channels); - tdma = devm_kzalloc(&pdev->dev, - struct_size(tdma, channels, cdata->nr_channels), - GFP_KERNEL); + tdma = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); if (!tdma) return -ENOMEM; @@ -1424,10 +1434,8 @@ static int tegra_dma_probe(struct platform_device *pdev) else ret = pm_runtime_get_sync(&pdev->dev); - if (ret < 0) { - pm_runtime_disable(&pdev->dev); - return ret; - } + if (ret < 0) + goto err_pm_disable; /* Reset DMA controller */ reset_control_assert(tdma->rst); @@ -1470,13 +1478,13 @@ static int tegra_dma_probe(struct platform_device *pdev) tdc->dma_chan.device = &tdma->dma_dev; dma_cookie_init(&tdc->dma_chan); list_add_tail(&tdc->dma_chan.device_node, - &tdma->dma_dev.channels); + &tdma->dma_dev.channels); tdc->tdma = tdma; tdc->id = i; tdc->slave_id = TEGRA_APBDMA_SLAVE_ID_INVALID; tasklet_init(&tdc->tasklet, tegra_dma_tasklet, - (unsigned long)tdc); + (unsigned long)tdc); spin_lock_init(&tdc->lock); INIT_LIST_HEAD(&tdc->pending_sg_req); @@ -1528,16 +1536,19 @@ static int tegra_dma_probe(struct platform_device *pdev) goto err_unregister_dma_dev; } - dev_info(&pdev->dev, "Tegra20 APB DMA driver register %d channels\n", - cdata->nr_channels); + dev_info(&pdev->dev, "Tegra20 APB DMA driver registered %u channels\n", + cdata->nr_channels); + return 0; err_unregister_dma_dev: dma_async_device_unregister(&tdma->dma_dev); + err_pm_disable: pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) tegra_dma_runtime_suspend(&pdev->dev); + return ret; } @@ -1557,7 +1568,7 @@ static int tegra_dma_remove(struct platform_device *pdev) static int tegra_dma_runtime_suspend(struct device *dev) { struct tegra_dma *tdma = dev_get_drvdata(dev); - int i; + unsigned int i; tdma->reg_gen = tdma_read(tdma, TEGRA_APBDMA_GENERAL); for (i = 0; i < tdma->chip_data->nr_channels; i++) { @@ -1586,7 +1597,8 @@ static int tegra_dma_runtime_suspend(struct device *dev) static int tegra_dma_runtime_resume(struct device *dev) { struct tegra_dma *tdma = dev_get_drvdata(dev); - int i, ret; + unsigned int i; + int ret; ret = clk_prepare_enable(tdma->dma_clk); if (ret < 0) { @@ -1614,7 +1626,7 @@ static int tegra_dma_runtime_resume(struct device *dev) tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBSEQ, ch_reg->ahb_seq); tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBPTR, ch_reg->ahb_ptr); tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR, - (ch_reg->csr & ~TEGRA_APBDMA_CSR_ENB)); + ch_reg->csr & ~TEGRA_APBDMA_CSR_ENB); } return 0; From patchwork Sun Jan 12 17:30:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329291 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A55BD921 for ; Sun, 12 Jan 2020 17:32:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 83082214D8 for ; Sun, 12 Jan 2020 17:32:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NjupIj9S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733290AbgALRcR (ORCPT ); Sun, 12 Jan 2020 12:32:17 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36125 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733169AbgALRbj (ORCPT ); Sun, 12 Jan 2020 12:31:39 -0500 Received: by mail-lf1-f68.google.com with SMTP id n12so5153745lfe.3; Sun, 12 Jan 2020 09:31:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7Jmy3B5v2Ce2+BDHjWIjOOpZMBGG7iH2rg2LqI+jBWo=; b=NjupIj9S3KJjP65J1UyjdC2snd+hLsabb5ygpvHN7JVrE4+BqMHKG3h70eTnvl1LpS y5KifdPY0Aqn+K7owyyqrbBWX8pZZkK65FtW1kqI9SOWCkmszk9D5MwNgBmaAbPCwb6N ykgfrXK4Ovs1fJSl2NUPwb1QFhmpKN1at/H44p3YiB8bvLPRZVD+T+EeAlfX+rhzEAwA pQk1aX/6ZkbFK8c2sJSymXdsiAeypNenTHoV+bH4/PY3/8E4JITdkWOuRm8I/vxYuljb HL8ARML+qAg6YVCirrrhcPuH8FoqembqH8DFKn5XKuy4XQFV2Bp8783evpNWSQ2X9YoX yn/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7Jmy3B5v2Ce2+BDHjWIjOOpZMBGG7iH2rg2LqI+jBWo=; b=eGlM09QjtG8bMhBI4sbGpYpZokqMwA8jIRj7QH6dnLGCYclcohQiCWTlHb957niBBj feIrdXijICJWXfNqisZGYWiVbWFN8qPL28PoB3cSpy01wHUIltN0yx9+ndzqVpzCNBpb nMSpe1/7e175EfbAujr+DWBQ4BJN7uQym7YMq+REuLLbA+UZOYKSj+VHeWQIm7n85faT cFMgmWqnr1KeCfa30lYDXAETtYwfCuN92y3HniT4P9Kp9y4fU43mb4AJzBfr8sGSDUjf 3emSQMZx+bfUD8nhc1VhmPCBL97ba7lpbrbcHl9wMU+aPqIypKCAraOFbtQm0qWhTGft RVnA== X-Gm-Message-State: APjAAAU9zaR+6lJJImFyaGrK3kakwigCo3QKg7RqBhra5ZaA96gGnuHa fdr28eDgwibD+3NOmi4JY4g= X-Google-Smtp-Source: APXvYqwo+ZGXn3KyQo7FHPS98R6YOVgHned9sG2IXs3oABYXuv/88YkzpzcuNx/MOHRLJq1dM2UcaQ== X-Received: by 2002:ac2:4add:: with SMTP id m29mr7438524lfp.190.1578850297066; Sun, 12 Jan 2020 09:31:37 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:36 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 09/14] dmaengine: tegra-apb: Clean up runtime PM teardown Date: Sun, 12 Jan 2020 20:30:01 +0300 Message-Id: <20200112173006.29863-10-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org It's cleaner to teardown RPM by revering the enable sequence, which makes code much easier to follow. Signed-off-by: Dmitry Osipenko --- drivers/dma/tegra20-apb-dma.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 7158bd3145c4..cc4a9ca20780 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1429,13 +1429,15 @@ static int tegra_dma_probe(struct platform_device *pdev) spin_lock_init(&tdma->global_lock); pm_runtime_enable(&pdev->dev); - if (!pm_runtime_enabled(&pdev->dev)) + if (!pm_runtime_enabled(&pdev->dev)) { ret = tegra_dma_runtime_resume(&pdev->dev); - else + if (ret) + return ret; + } else { ret = pm_runtime_get_sync(&pdev->dev); - - if (ret < 0) - goto err_pm_disable; + if (ret < 0) + goto err_pm_disable; + } /* Reset DMA controller */ reset_control_assert(tdma->rst); @@ -1545,9 +1547,10 @@ static int tegra_dma_probe(struct platform_device *pdev) dma_async_device_unregister(&tdma->dma_dev); err_pm_disable: - pm_runtime_disable(&pdev->dev); - if (!pm_runtime_status_suspended(&pdev->dev)) + if (!pm_runtime_enabled(&pdev->dev)) tegra_dma_runtime_suspend(&pdev->dev); + else + pm_runtime_disable(&pdev->dev); return ret; } @@ -1558,9 +1561,10 @@ static int tegra_dma_remove(struct platform_device *pdev) dma_async_device_unregister(&tdma->dma_dev); - pm_runtime_disable(&pdev->dev); - if (!pm_runtime_status_suspended(&pdev->dev)) + if (!pm_runtime_enabled(&pdev->dev)) tegra_dma_runtime_suspend(&pdev->dev); + else + pm_runtime_disable(&pdev->dev); return 0; } From patchwork Sun Jan 12 17:30:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329277 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B4C9921 for ; Sun, 12 Jan 2020 17:31:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3C0D24125 for ; Sun, 12 Jan 2020 17:31:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nzMS7xiE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733195AbgALRbm (ORCPT ); Sun, 12 Jan 2020 12:31:42 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:46463 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733174AbgALRbl (ORCPT ); Sun, 12 Jan 2020 12:31:41 -0500 Received: by mail-lf1-f65.google.com with SMTP id f15so5136489lfl.13; Sun, 12 Jan 2020 09:31:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8T/zq5k/xWPMO4gCZc/axjNKMU4ysMZUwvQwsO3s7lU=; b=nzMS7xiELnwrC8S+rO6OwRanLi/RFr9g1XZEwPJpoVaI4UfuY16Q9/Dhn+yXM+kBsS TZYpuyN0si52MiuS4t4ibQZVv9nJzJEXv6f9yjzXymwe4cGg2lUVLvs9wycFVw7t/TIv cEneEoD+d6/53Yq5BjrK1JoZw+t1DhNL8O2SNI6w9BPuMgqSM0DcmspGZNBY4o/IvbPU snfVf/MRdkwsArKsV3HzzwYettfs2zTUDqDf1DJ7AXRZx3ZbsEu1P2aHQtLehAB1cWWL sT2d70ut9QtHokunCaVgI9TRxJpbt3Uv+81NA2g3QL81AQJhKDMuKrkRfollmzbt5aSA UC4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8T/zq5k/xWPMO4gCZc/axjNKMU4ysMZUwvQwsO3s7lU=; b=T6AFgVCNUInas8ghs+PH5HYeadT8VY+qFnK9VtIM9MjSUnOr7jeIFv+rRluPPZFrIm iTzdDLXujatqEZ8XwuDpj8sXCTO2UE3KlsVlatPKmaEZr8KDaIX+C6T6NNqB/1wchK1C +qAEY3Mt+F4Q0/7moLgbegGikOnLpCPXejATJAbuRTzshj5BwNu/qXIGZBXEDA68QS1U CNy7iH9EH+VmZXbRVQdWhtHVhd73OTRu/fBQuz8A6CKAmtMFUuOaS1ZBPtYAx55/jcL2 2PXxDKs92fCnpOjh8HovsfeWJ76Hs9qhJWUKpZ+cm8QzHokpLU27QrXjhiZCovn4H76i m3Hg== X-Gm-Message-State: APjAAAXeV3UQxRD+NqXweiHtNS4ShPqtP/sfEFbmAu4w+l2N7Ria3UMB Bx+23A0D06Tph9T3rJexFEk= X-Google-Smtp-Source: APXvYqxtZU95wXTpbI1wV4FBPEm3KU78F4c3msKWGsp3QrpwtRBMXBbsPs0jdzeHOWNO0ztRYYUA0w== X-Received: by 2002:a19:5013:: with SMTP id e19mr7887769lfb.8.1578850297944; Sun, 12 Jan 2020 09:31:37 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:37 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 10/14] dmaengine: tegra-apb: Keep clock enabled only during of DMA transfer Date: Sun, 12 Jan 2020 20:30:02 +0300 Message-Id: <20200112173006.29863-11-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org It's a bit impractical to enable hardware's clock at the time of DMA channel's allocation because most of DMA client drivers allocate DMA channel at the time of the driver's probing and thus DMA clock is kept always-enabled in practice, defeating the whole purpose of runtime PM. Signed-off-by: Dmitry Osipenko --- drivers/dma/tegra20-apb-dma.c | 43 ++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index cc4a9ca20780..b9d8e57eaf54 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -436,6 +436,8 @@ static void tegra_dma_stop(struct tegra_dma_channel *tdc) tdc_write(tdc, TEGRA_APBDMA_CHAN_STATUS, status); } tdc->busy = false; + + pm_runtime_put(tdc->tdma->dev); } static void tegra_dma_start(struct tegra_dma_channel *tdc, @@ -500,18 +502,25 @@ static void tegra_dma_configure_for_next(struct tegra_dma_channel *tdc, tegra_dma_resume(tdc); } -static void tdc_start_head_req(struct tegra_dma_channel *tdc) +static bool tdc_start_head_req(struct tegra_dma_channel *tdc) { struct tegra_dma_sg_req *sg_req; + int err; if (list_empty(&tdc->pending_sg_req)) - return; + return false; + + err = pm_runtime_get_sync(tdc->tdma->dev); + if (WARN_ON_ONCE(err < 0)) + return false; sg_req = list_first_entry(&tdc->pending_sg_req, typeof(*sg_req), node); tegra_dma_start(tdc, sg_req); sg_req->configured = true; sg_req->words_xferred = 0; tdc->busy = true; + + return true; } static void tdc_configure_next_head_desc(struct tegra_dma_channel *tdc) @@ -615,6 +624,8 @@ static void handle_once_dma_done(struct tegra_dma_channel *tdc, } list_add_tail(&sgreq->node, &tdc->free_sg_req); + pm_runtime_put(tdc->tdma->dev); + /* Do not start DMA if it is going to be terminate */ if (to_terminate || list_empty(&tdc->pending_sg_req)) return; @@ -730,9 +741,7 @@ static void tegra_dma_issue_pending(struct dma_chan *dc) dev_err(tdc2dev(tdc), "No DMA request\n"); goto end; } - if (!tdc->busy) { - tdc_start_head_req(tdc); - + if (!tdc->busy && tdc_start_head_req(tdc)) { /* Continuous single mode: Configure next req */ if (tdc->cyclic) { /* @@ -1280,22 +1289,15 @@ tegra_dma_prep_dma_cyclic(struct dma_chan *dc, dma_addr_t buf_addr, static int tegra_dma_alloc_chan_resources(struct dma_chan *dc) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); - struct tegra_dma *tdma = tdc->tdma; - int ret; dma_cookie_init(&tdc->dma_chan); - ret = pm_runtime_get_sync(tdma->dev); - if (ret < 0) - return ret; - return 0; } static void tegra_dma_free_chan_resources(struct dma_chan *dc) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); - struct tegra_dma *tdma = tdc->tdma; struct tegra_dma_desc *dma_desc; struct tegra_dma_sg_req *sg_req; struct list_head dma_desc_list; @@ -1328,7 +1330,6 @@ static void tegra_dma_free_chan_resources(struct dma_chan *dc) list_del(&sg_req->node); kfree(sg_req); } - pm_runtime_put(tdma->dev); tdc->slave_id = TEGRA_APBDMA_SLAVE_ID_INVALID; } @@ -1428,11 +1429,16 @@ static int tegra_dma_probe(struct platform_device *pdev) spin_lock_init(&tdma->global_lock); + ret = clk_prepare(tdma->dma_clk); + if (ret) + return ret; + + pm_runtime_irq_safe(&pdev->dev); pm_runtime_enable(&pdev->dev); if (!pm_runtime_enabled(&pdev->dev)) { ret = tegra_dma_runtime_resume(&pdev->dev); if (ret) - return ret; + goto err_clk_unprepare; } else { ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) @@ -1552,6 +1558,9 @@ static int tegra_dma_probe(struct platform_device *pdev) else pm_runtime_disable(&pdev->dev); +err_clk_unprepare: + clk_unprepare(tdma->dma_clk); + return ret; } @@ -1566,6 +1575,8 @@ static int tegra_dma_remove(struct platform_device *pdev) else pm_runtime_disable(&pdev->dev); + clk_unprepare(tdma->dma_clk); + return 0; } @@ -1593,7 +1604,7 @@ static int tegra_dma_runtime_suspend(struct device *dev) TEGRA_APBDMA_CHAN_WCOUNT); } - clk_disable_unprepare(tdma->dma_clk); + clk_disable(tdma->dma_clk); return 0; } @@ -1604,7 +1615,7 @@ static int tegra_dma_runtime_resume(struct device *dev) unsigned int i; int ret; - ret = clk_prepare_enable(tdma->dma_clk); + ret = clk_enable(tdma->dma_clk); if (ret < 0) { dev_err(dev, "clk_enable failed: %d\n", ret); return ret; From patchwork Sun Jan 12 17:30:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329285 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDC08921 for ; Sun, 12 Jan 2020 17:32:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2BE324654 for ; Sun, 12 Jan 2020 17:32:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ITKybEv1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733191AbgALRcG (ORCPT ); Sun, 12 Jan 2020 12:32:06 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:42255 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733181AbgALRbl (ORCPT ); Sun, 12 Jan 2020 12:31:41 -0500 Received: by mail-lf1-f68.google.com with SMTP id y19so5143165lfl.9; Sun, 12 Jan 2020 09:31:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hP6SWGBrH3rl2FCQVrqhJx1xeutc1Bk8aKbd+Ff6RwI=; b=ITKybEv1+OYMi4vf5MY2izQ8qFZzQ/0JQOAfPReknecvap6sAqT3vRjrsBzsvj/II0 OxIdqONU+jLgycxO5bzoZqTxP21gyw8imfbzbgdZVASQuCv6GERPin5sLoJ1JYfy9zVq u3N+tmnMg+6zbSLIrGgHeXuLXJHEI0tUVdzmPox5QIevyAsHJ9UWI2i/BOuZB4oJYrmG IoJ+labmiOrZtUuigDDXnN41gvocRgDO5SY/OeWyjrXL7V6x1ytFKFg1HI+mSGeVhpjU bi6a+3QDrprdR5pHMjE8nMuSXk0As9PV/siVenMufIFdhyHauhlWOkGMKdOJHQBaNSo3 KXtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hP6SWGBrH3rl2FCQVrqhJx1xeutc1Bk8aKbd+Ff6RwI=; b=IYEJ0UBFXEpU7QJwPaJckRhpzlOGDThSN3wxj+5Nh5Kd9cUJATmuH+cycIrRIFSwid nkWvYDPSmiYf0oXatfkcKUz+B8NV7sdAdUUijmRlShFMqGsl2yNxDCWJS0wP4kvHhCIf Dk8vnvlOV/muNKPaqk+KQXe92MF3wkiGiLxW6TqW2f8ifLMaMOKt43hZOVSySk+ynJ2t /L/zSxyLRoDWevcwAWWQbwGJpDH0iBWczR2cvYSbkj5TSd/jQ5KrTgsFxH6aQoE3zEue oiJG9VWj5a77lORko88WPhXutJIjoqbSm5kdd3FgukpEbkUiasHKEWFhTuJmpX0Wg3l1 Vokw== X-Gm-Message-State: APjAAAWR0ji2da8jxDHHLR367w35T30eUqmIL7PbbSSVmRYp99yQQl3Y JUFmC5BL1hjsXdX0/Vij3lo= X-Google-Smtp-Source: APXvYqxI8HEqTA+Q5aa+7pgwN5jbKuySr1LKoNjZorR7At1ZdT2HYN+M3lQhD7RUbPlJeZnQFXA/yg== X-Received: by 2002:a19:c648:: with SMTP id w69mr7571785lff.44.1578850298922; Sun, 12 Jan 2020 09:31:38 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:38 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 11/14] dmaengine: tegra-apb: Clean up suspend-resume Date: Sun, 12 Jan 2020 20:30:03 +0300 Message-Id: <20200112173006.29863-12-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org It is enough to check whether hardware is busy on suspend and to reset it across of suspend-resume because channel's configuration is fully re-programmed on each DMA transaction anyways and because save-restore of an active channel won't end up well without pausing transfer prior to saving of the state (note that all channels shall be idling at the time of suspend, so save-restore is not needed at all). Signed-off-by: Dmitry Osipenko --- drivers/dma/tegra20-apb-dma.c | 131 +++++++++++++++++----------------- 1 file changed, 67 insertions(+), 64 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index b9d8e57eaf54..398a0e1d6506 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1392,6 +1392,36 @@ static const struct tegra_dma_chip_data tegra148_dma_chip_data = { .support_separate_wcount_reg = true, }; +static int tegra_dma_init_hw(struct tegra_dma *tdma) +{ + int err; + + err = reset_control_assert(tdma->rst); + if (err) { + dev_err(tdma->dev, "failed to assert reset: %d\n", err); + return err; + } + + err = clk_enable(tdma->dma_clk); + if (err) { + dev_err(tdma->dev, "failed to enable clk: %d\n", err); + return err; + } + + /* reset DMA controller */ + udelay(2); + reset_control_deassert(tdma->rst); + + /* enable global DMA registers */ + tdma_write(tdma, TEGRA_APBDMA_GENERAL, TEGRA_APBDMA_GENERAL_ENABLE); + tdma_write(tdma, TEGRA_APBDMA_CONTROL, 0); + tdma_write(tdma, TEGRA_APBDMA_IRQ_MASK_SET, 0xFFFFFFFF); + + clk_disable(tdma->dma_clk); + + return 0; +} + static int tegra_dma_probe(struct platform_device *pdev) { const struct tegra_dma_chip_data *cdata; @@ -1433,30 +1463,18 @@ static int tegra_dma_probe(struct platform_device *pdev) if (ret) return ret; + ret = tegra_dma_init_hw(tdma); + if (ret) + goto err_clk_unprepare; + pm_runtime_irq_safe(&pdev->dev); pm_runtime_enable(&pdev->dev); if (!pm_runtime_enabled(&pdev->dev)) { ret = tegra_dma_runtime_resume(&pdev->dev); if (ret) goto err_clk_unprepare; - } else { - ret = pm_runtime_get_sync(&pdev->dev); - if (ret < 0) - goto err_pm_disable; } - /* Reset DMA controller */ - reset_control_assert(tdma->rst); - udelay(2); - reset_control_deassert(tdma->rst); - - /* Enable global DMA registers */ - tdma_write(tdma, TEGRA_APBDMA_GENERAL, TEGRA_APBDMA_GENERAL_ENABLE); - tdma_write(tdma, TEGRA_APBDMA_CONTROL, 0); - tdma_write(tdma, TEGRA_APBDMA_IRQ_MASK_SET, 0xFFFFFFFFul); - - pm_runtime_put(&pdev->dev); - INIT_LIST_HEAD(&tdma->dma_dev.channels); for (i = 0; i < cdata->nr_channels; i++) { struct tegra_dma_channel *tdc = &tdma->channels[i]; @@ -1583,26 +1601,6 @@ static int tegra_dma_remove(struct platform_device *pdev) static int tegra_dma_runtime_suspend(struct device *dev) { struct tegra_dma *tdma = dev_get_drvdata(dev); - unsigned int i; - - tdma->reg_gen = tdma_read(tdma, TEGRA_APBDMA_GENERAL); - for (i = 0; i < tdma->chip_data->nr_channels; i++) { - struct tegra_dma_channel *tdc = &tdma->channels[i]; - struct tegra_dma_channel_regs *ch_reg = &tdc->channel_reg; - - /* Only save the state of DMA channels that are in use */ - if (!tdc->config_init) - continue; - - ch_reg->csr = tdc_read(tdc, TEGRA_APBDMA_CHAN_CSR); - ch_reg->ahb_ptr = tdc_read(tdc, TEGRA_APBDMA_CHAN_AHBPTR); - ch_reg->apb_ptr = tdc_read(tdc, TEGRA_APBDMA_CHAN_APBPTR); - ch_reg->ahb_seq = tdc_read(tdc, TEGRA_APBDMA_CHAN_AHBSEQ); - ch_reg->apb_seq = tdc_read(tdc, TEGRA_APBDMA_CHAN_APBSEQ); - if (tdma->chip_data->support_separate_wcount_reg) - ch_reg->wcount = tdc_read(tdc, - TEGRA_APBDMA_CHAN_WCOUNT); - } clk_disable(tdma->dma_clk); @@ -1612,46 +1610,51 @@ static int tegra_dma_runtime_suspend(struct device *dev) static int tegra_dma_runtime_resume(struct device *dev) { struct tegra_dma *tdma = dev_get_drvdata(dev); - unsigned int i; - int ret; - ret = clk_enable(tdma->dma_clk); - if (ret < 0) { - dev_err(dev, "clk_enable failed: %d\n", ret); - return ret; - } + return clk_enable(tdma->dma_clk); +} - tdma_write(tdma, TEGRA_APBDMA_GENERAL, tdma->reg_gen); - tdma_write(tdma, TEGRA_APBDMA_CONTROL, 0); - tdma_write(tdma, TEGRA_APBDMA_IRQ_MASK_SET, 0xFFFFFFFFul); +static int __maybe_unused tegra_dma_dev_suspend(struct device *dev) +{ + struct tegra_dma *tdma = dev_get_drvdata(dev); + unsigned long flags; + unsigned int i; + bool busy; for (i = 0; i < tdma->chip_data->nr_channels; i++) { struct tegra_dma_channel *tdc = &tdma->channels[i]; - struct tegra_dma_channel_regs *ch_reg = &tdc->channel_reg; - - /* Only restore the state of DMA channels that are in use */ - if (!tdc->config_init) - continue; - - if (tdma->chip_data->support_separate_wcount_reg) - tdc_write(tdc, TEGRA_APBDMA_CHAN_WCOUNT, - ch_reg->wcount); - tdc_write(tdc, TEGRA_APBDMA_CHAN_APBSEQ, ch_reg->apb_seq); - tdc_write(tdc, TEGRA_APBDMA_CHAN_APBPTR, ch_reg->apb_ptr); - tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBSEQ, ch_reg->ahb_seq); - tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBPTR, ch_reg->ahb_ptr); - tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR, - ch_reg->csr & ~TEGRA_APBDMA_CSR_ENB); + + spin_lock_irqsave(&tdc->lock, flags); + busy = tdc->busy; + spin_unlock_irqrestore(&tdc->lock, flags); + + if (busy) { + dev_err(tdma->dev, "channel %u busy\n", i); + return -EBUSY; + } + + tasklet_kill(&tdc->tasklet); } - return 0; + return pm_runtime_force_suspend(dev); +} + +static int __maybe_unused tegra_dma_dev_resume(struct device *dev) +{ + struct tegra_dma *tdma = dev_get_drvdata(dev); + int err; + + err = tegra_dma_init_hw(tdma); + if (err) + return err; + + return pm_runtime_force_resume(dev); } static const struct dev_pm_ops tegra_dma_dev_pm_ops = { SET_RUNTIME_PM_OPS(tegra_dma_runtime_suspend, tegra_dma_runtime_resume, NULL) - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) + SET_SYSTEM_SLEEP_PM_OPS(tegra_dma_dev_suspend, tegra_dma_dev_resume) }; static const struct of_device_id tegra_dma_of_match[] = { From patchwork Sun Jan 12 17:30:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329283 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D524D1398 for ; Sun, 12 Jan 2020 17:32:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B3588222D9 for ; Sun, 12 Jan 2020 17:32:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ann733o9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733265AbgALRcH (ORCPT ); Sun, 12 Jan 2020 12:32:07 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:35701 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733188AbgALRbl (ORCPT ); Sun, 12 Jan 2020 12:31:41 -0500 Received: by mail-lj1-f195.google.com with SMTP id j1so7450041lja.2; Sun, 12 Jan 2020 09:31:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9IXhdptGbj8V+x0JmFieXnr8n7z3VnobTAkrJvX9AgA=; b=ann733o969SVKkuM2kLDUJ90Jy/SVYXHWa/x/Lzcbo01xoHXV9NugtFAa88D4la3IJ JKPp2+I0K725Abe238DsAseQhJ3tKTee3g4tnHZhwHw2273bkjqr+NfAenxy6Z05agbx pw6khn8dM9Xug8qJ1EQjluA5svQxtgMj9ieHOZKDZqBXcQAd0cwkf/iX0Jk915Wx2fGR jTU3tXfCbL0+Sha90+ljVHWotmg7V5exRpMXokyEAVVWNESU+Bz0XYqry4uYiU+KKR3X I1uUq/aN+4JSma9HMOMkKjRRNo/+ugzypM55H+l/ZopyJpGo0i6cCGdlr3GCB0yS501W 5J+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9IXhdptGbj8V+x0JmFieXnr8n7z3VnobTAkrJvX9AgA=; b=r/gAFZJpsnncVqML4ujljgJpTXqgrSHXbIPcXZEChkyg9YuTGf5GdKEPsUce+tDRmC 34kQBUSgr2QKy9Ukm2uTL8WdABpjVmnKS+YXGKsPL85lhIwU1l5EEF1ypTZMgZaK2mFe 4Q2JXBWut+zOgCS8svomnkhDpazjACUIfEZmGsGzZbmt4QyT5Xd6Wq+sUmgg0C/MjhmD EPNL4P12fBul4Ll92tBtWs3iJcK+8TFKysWZczdrvis64Hmz/diY6BLDZt3e6p5JTPnn zH3Kmo53JFtuGlccgXUBzAT+euoTVFXioRZDsX+uUluPTZGkBaOq7YOJkTZpN7/ON8dP PBFg== X-Gm-Message-State: APjAAAXuLmZgGgqaePk825+1le6Qe0frwVkvIll7LKPuzMZLul5NVGlo D5ltpBx0ScE+FtO8mV6jnkmfrlEH X-Google-Smtp-Source: APXvYqy9vc00AnShkNJiCueI9QV4rvL4IYaf3ELS0w09VSsNmljokkg76UhRunH8ZgrEg8WRr23IDA== X-Received: by 2002:a2e:9708:: with SMTP id r8mr8563766lji.92.1578850299873; Sun, 12 Jan 2020 09:31:39 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:39 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 12/14] dmaengine: tegra-apb: Add missing of_dma_controller_free Date: Sun, 12 Jan 2020 20:30:04 +0300 Message-Id: <20200112173006.29863-13-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org The DMA controller shall be released on driver's removal. Signed-off-by: Dmitry Osipenko Acked-by: Jon Hunter --- drivers/dma/tegra20-apb-dma.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 398a0e1d6506..fbbb6a60901e 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1586,6 +1586,7 @@ static int tegra_dma_remove(struct platform_device *pdev) { struct tegra_dma *tdma = platform_get_drvdata(pdev); + of_dma_controller_free(pdev->dev.of_node); dma_async_device_unregister(&tdma->dma_dev); if (!pm_runtime_enabled(&pdev->dev)) From patchwork Sun Jan 12 17:30:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329281 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 548E91398 for ; Sun, 12 Jan 2020 17:32:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 33F4E24655 for ; Sun, 12 Jan 2020 17:32:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AF3rZjfC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733252AbgALRcA (ORCPT ); Sun, 12 Jan 2020 12:32:00 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:45387 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733191AbgALRbn (ORCPT ); Sun, 12 Jan 2020 12:31:43 -0500 Received: by mail-lj1-f195.google.com with SMTP id j26so7424044ljc.12; Sun, 12 Jan 2020 09:31:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0hLaeTkiGQpndBzsnntj+Kt92MOlWlIIs3RhP31I+1g=; b=AF3rZjfC3e2LMp8KwG8yJBu4lWsuaJxqzMWnY4SDWLOP5YsebM4zTGB2L2wWO+QMBV r2U9T/5HuthSAq/qhwbjC7iNwSzZOUwfR4490vqNySwMU5veqQr1FAjqj1uWEHlXbnaf TCtNiB/CQQ3tXdN0BN6arnbvl+XuqTxTZdor5JGQfAcXym72pVUw8eUKaDX5YbcpVDbZ /cvoobw9lBJerXFjTK+SIY+OaV4H64fZOt/J3bLfjegJ+CbYNXDgc33coN71ic5IngP/ 301kKdFX6mn1jBL6zVvcHDKc3bot//16sy9KnMhywrHwUsIVbjPE5Kxvg0V3jv23WpCw eroA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0hLaeTkiGQpndBzsnntj+Kt92MOlWlIIs3RhP31I+1g=; b=Rfjx7+6FUcbBqaYir97P57tI6wE5oVq/u4M/41R3AeJN00sq/5K1HiADZQA3ZYCUnp mG63w6hqfmSpwmbouaSdT+M1QmnR3BrL3P2y0xL82ihxbnjhdDcbZSbO73UXpA0riKLJ ovZJTADkot8r+8qO7WIzM6XvMh1UqGkQxh1189eSMs8L94sb8+szbXyF9nGv9bNpzRGg yhKyPLyLDD/u99RjuqDilta/Bwffu1qS1H3SJIIPnsfWLwuuBQ5eJ+TD1/nwVddvBmBG fT8mxGKS+w88z6nYtuHxY7NBSng+l+7u+b2XTjRTVcOf7w+yufdC4k3iNJew7ZQGn/mB pxLQ== X-Gm-Message-State: APjAAAWFNdnnWuSmf+1TBPxIk6dZpnripd5X6zIOVpawDm3/ZWxNihh+ eD+BSqXP4FCpiqgTa65d26w= X-Google-Smtp-Source: APXvYqwDyFhBtkrDhw+Tvn61pJu2+8rzeXS0mcrEA5I1ejYLwTATuESWSZR2xUEfAg2L+Y7eOmEpsw== X-Received: by 2002:a2e:b0c9:: with SMTP id g9mr8364168ljl.134.1578850300750; Sun, 12 Jan 2020 09:31:40 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:40 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 13/14] dmaengine: tegra-apb: Allow to compile as a loadable kernel module Date: Sun, 12 Jan 2020 20:30:05 +0300 Message-Id: <20200112173006.29863-14-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org The driver's removal was fixed by a recent commit and module load/unload is working well now, tested on Tegra30. Signed-off-by: Dmitry Osipenko Acked-by: Jon Hunter --- drivers/dma/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 6fa1eba9d477..9f43e2cae8b4 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -586,7 +586,7 @@ config TXX9_DMAC integrated in chips such as the Toshiba TX4927/38/39. config TEGRA20_APB_DMA - bool "NVIDIA Tegra20 APB DMA support" + tristate "NVIDIA Tegra20 APB DMA support" depends on ARCH_TEGRA select DMA_ENGINE help From patchwork Sun Jan 12 17:30:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329279 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 022EF921 for ; Sun, 12 Jan 2020 17:32:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D4D1F24654 for ; Sun, 12 Jan 2020 17:31:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WHMulbMf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733242AbgALRbz (ORCPT ); Sun, 12 Jan 2020 12:31:55 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:36128 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733197AbgALRbo (ORCPT ); Sun, 12 Jan 2020 12:31:44 -0500 Received: by mail-lf1-f66.google.com with SMTP id n12so5153822lfe.3; Sun, 12 Jan 2020 09:31:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EVgvDl53i+vPBSkzgipL2f7yd+gUN+cTRTJ+9Dy9ATg=; b=WHMulbMfP+gG/qPUHdjCEhz9ZAuexs7xrWz+rt17nYhHsnTqWPqJy21hbbuPSXZZcX o76gVaCku4QL19yNdce4TpuPQpgNmRgFMsMd4XhDEXDOx8YWRITbGZE9s7SjtakHQfCs G6HsN3BbR2HYL9guNa0IimYuL1WSP6ki+O/FAJ78lB/Boc+8/wxGcIS3adV0XTfyPcXC xEjM6zOMnjICDNRw1eQUxW4g2UGoIdKOdaq7xwV8NSXcR6IjpwvL4WM6gzJq4fpnbDtR DYFLEZgUsd6bgj7qwhtxpnOB8xHHwUnOxiqvX6vhM7Kcf32NLkYuGu6kudXZzVhTmTwQ z8LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EVgvDl53i+vPBSkzgipL2f7yd+gUN+cTRTJ+9Dy9ATg=; b=a3yBmjeD7zZBZd/nM3kp+qaCtU0TvJvh+THvUzHg7UQDLChROLtZmv6Q/pS1cdWtND TFkRRa5osNemcsv6qrKLaK2i6kLn2tgdMeA74R8DOekryE2DOS/cpYtNvP8T3Bd+yzzZ QoUuqL2bXTVcgIdGOoFa0iZlJIyd/XJkyQtjTvs4FbfuUH86zVZltdBvAd5DLFokCUFt cCM8lIirLnzFSnp6vQEFJyzH82/cy3gMABqg6bENhjzSis9LTVusNCMz14IaRCKzbyIi fZaZ2gMwz7FhaA/PsSl8EarA1uh7qlCz88hBBmFi8tRvryhPaTYApfqtV2Ei0jY2jkq5 qRHQ== X-Gm-Message-State: APjAAAWZknMH6qjmvunhGEEQfDdpMSyO5lHoqANZgs+mbY6iaNhFvj05 mliak8mC+wrbgmT/WTcpDJc= X-Google-Smtp-Source: APXvYqxuvn1YNVbrHwYIIOff8+3bBu2pceXbSKOZlk5bGqBqAcwqGfCfN5KhgOSIWyiXKZHzXgpuuA== X-Received: by 2002:a19:6a0e:: with SMTP id u14mr5421763lfu.197.1578850301617; Sun, 12 Jan 2020 09:31:41 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id 140sm4458888lfk.78.2020.01.12.09.31.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:31:41 -0800 (PST) From: Dmitry Osipenko To: Laxman Dewangan , Vinod Koul , Dan Williams , Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 14/14] dmaengine: tegra-apb: Remove MODULE_ALIAS Date: Sun, 12 Jan 2020 20:30:06 +0300 Message-Id: <20200112173006.29863-15-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112173006.29863-1-digetx@gmail.com> References: <20200112173006.29863-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Tegra APB DMA driver is an Open Firmware driver and thus it uses OF alias naming scheme which overrides MODULE_ALIAS, meaning that MODULE_ALIAS does nothing and could be removed safely. Signed-off-by: Dmitry Osipenko Acked-by: Jon Hunter --- drivers/dma/tegra20-apb-dma.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index fbbb6a60901e..0a45dd77618c 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1688,7 +1688,6 @@ static struct platform_driver tegra_dmac_driver = { module_platform_driver(tegra_dmac_driver); -MODULE_ALIAS("platform:tegra20-apbdma"); MODULE_DESCRIPTION("NVIDIA Tegra APB DMA Controller driver"); MODULE_AUTHOR("Laxman Dewangan "); MODULE_LICENSE("GPL v2");