From patchwork Mon Jan 6 01:16: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: 11318615 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 5C25D14B4 for ; Mon, 6 Jan 2020 01:18:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3ACCF217F4 for ; Mon, 6 Jan 2020 01:18:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V/YNpxKO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727296AbgAFBRZ (ORCPT ); Sun, 5 Jan 2020 20:17:25 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35062 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727218AbgAFBRY (ORCPT ); Sun, 5 Jan 2020 20:17:24 -0500 Received: by mail-lj1-f194.google.com with SMTP id j1so41895483lja.2; Sun, 05 Jan 2020 17:17:23 -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=V/YNpxKOpbuRP2Mk+3oJ1FAOc1QVwQHLvTJkNfW3SlJCZk/0tOOlYUBdLpzFHpEjFt sss9KhNvLOX3BjjVJ0eRwtZ4ZNQpNlHEG3N8IluHiJSxqFL30IZRQbE+Smgg8ZGuNVRA omVppVsDLM9Ofbpq6+Y97yz+witqyIy7mNQ4nbO0+HVu4tvVILnP10J6jE+Zh5nr497P FWlGGcQjkZOfInHu+zVotjdEwewXIbHvhCpHP+NXlau5Y74Wy/9f4a+GeJqGd9U8ZAWY f9d+Hg1aNEWwnXuQLr6pVV11qAr8lB5AtWS2e9NjbA1ICXyW8tvjoniNreRNcVjgi3iS +D1g== 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=s2XlPrHbrYH6igBAR9xHhHbT8S1prZsbLscjtwa9Ix2iXxgtulTD34BXppGY7Z2sLE mJRhYi7k84FwkDwvAACpPbfo0T0neHON9KZLFXk5LFFfBhRTnQXEDLAkmAop4cEUL8Vb vfe3MrhbYz2K/xf3/+SkX0G/uj2jkZjsO7WfY0AHqeUn8rNUVBZuxXo7iM72TEU3y1c0 D0S/i3klgh2QGVhT4tVNFOqeDe8FbzGEXfjzMcvHFVGt4W4voH3Pw2HTUQSTuLv8F3fR u60j9xxJJjq+fUIahUvJdrD3xmapfzYppY3z+OXjhLlw8gKDYAFhGCeE9Yc6TuGgaUcF IS2Q== X-Gm-Message-State: APjAAAWIWhXh542zLKQnV/gXPbsvYS72XTxsTvldiFNVBK93dDGQ7W8s 3HTYKxhqNZvafMDOS3qOREo= X-Google-Smtp-Source: APXvYqznTkwiEcbSztg51iNbsMG4w7FcJP55xh+LJ8yg4y8/Eq+y5rOvwizusi3MeN/jLJXL7lMobg== X-Received: by 2002:a2e:810d:: with SMTP id d13mr59185866ljg.113.1578273442447; Sun, 05 Jan 2020 17:17:22 -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 y14sm28353271ljk.46.2020.01.05.17.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17:22 -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 v3 01/13] dmaengine: tegra-apb: Fix use-after-free Date: Mon, 6 Jan 2020 04:16:56 +0300 Message-Id: <20200106011708.7463-2-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-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 Mon Jan 6 01:16: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: 11318613 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 153D36C1 for ; Mon, 6 Jan 2020 01:18:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E7B332072C for ; Mon, 6 Jan 2020 01:18:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KaKzgkEl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727323AbgAFBRZ (ORCPT ); Sun, 5 Jan 2020 20:17:25 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:39691 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727268AbgAFBRZ (ORCPT ); Sun, 5 Jan 2020 20:17:25 -0500 Received: by mail-lj1-f193.google.com with SMTP id l2so49273106lja.6; Sun, 05 Jan 2020 17:17:23 -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=KaKzgkEls3Ub0KNMTwRBoR6uaqurUZoOaqFBhHrePHMddJXQgaCgyJnsj89WRoCPVX EoWPL8gGVOUNIHWstRHJOCH8slaN49O2t1BHTHcA64Inn/p3lDEPCVEfVPpHkXKVRRnm +GhT+CkSRgaWacjajq6/4E925STgFpfPppgxZhfaDBvVcubiS04IFmUavfUu3pE+IptK hGPOCtFD++31X+D4N9pOYhw7pc3Nw0h6YFflsLL6Z60LUWeZ3GkpSCaNZJv6uQUWyj7E utIOAjjogLKdG3Uu0ySh0KNr7t04ZHCmcIm8DE83uyfVKz+Z78EkDaCRvPvqno7FsOlZ ahCw== 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=s2WTQkvIi6V6SpfYXwuCjS+MinsvzmLlkxcpGWUml78jFyouH43a8SrQukQNzMWUsN YBPly5S6sZtE6Iq1RLMfjuV5IDAk5TUi1uArgn8IB0Zyzbc8viVbb8AfNytx3LKk/yw1 Efh/H78C05m7oYtbx02ejHfw9OPed2X8KfynFST52Sxzf3fv0aqj/ZBHkIv9gFY9zYHa hyc0QiSWh16HK84UalQZ6wyBxGUCFtTBS7d66PyUEmrareqndA0Fm3yReGa2zoglCObF RTfaIevQN6PGEN3DEvw9As+alfs9yAbYBqo4U8nzBYfHh54Qqwc43+LMMcG/1ut5kkpF Relw== X-Gm-Message-State: APjAAAXMr6Y5KEfPO02K13PKArM6LWweunTEIredeyOqrHBDpdoirVKS 96wyYZzEexESLxAxSxy8RhE= X-Google-Smtp-Source: APXvYqzMh1fPD9g7/PzVh/6onR/0T6+9Ig+O1p3KQe3gjPBddSbrMPe7jZQ9lYUna4DgYRGugJqc4A== X-Received: by 2002:a05:651c:8f:: with SMTP id 15mr58672337ljq.109.1578273443275; Sun, 05 Jan 2020 17:17:23 -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 y14sm28353271ljk.46.2020.01.05.17.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17:22 -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 v3 02/13] dmaengine: tegra-apb: Implement synchronization callback Date: Mon, 6 Jan 2020 04:16:57 +0300 Message-Id: <20200106011708.7463-3-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-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 --- 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 Mon Jan 6 01:16: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: 11318609 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 0301A14B4 for ; Mon, 6 Jan 2020 01:18:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D4D46217F4 for ; Mon, 6 Jan 2020 01:18:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kUkML9Or" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727357AbgAFBR1 (ORCPT ); Sun, 5 Jan 2020 20:17:27 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36254 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727170AbgAFBR0 (ORCPT ); Sun, 5 Jan 2020 20:17:26 -0500 Received: by mail-lf1-f68.google.com with SMTP id n12so35324335lfe.3; Sun, 05 Jan 2020 17:17:24 -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=kUkML9OrabwAEvWeZsnyBC7uNshLNoKhsWdF/XhXTjEArYIMFGZy1/9+c9uyWp6veo Cu01hB5n9NRIkEoX8pzRCbOx4amSb4gQ2WwVCuhvj5pctPwbVEL6IZyHpZJ0HlsNVEz6 sFH5O+iJM9fsJ1GXfTW8iErxK+I3NfsV+LgOrxU0NM1bL8O7BT2yICh+6jtGtXNrjAHs Q7CTKT5IPh1kRixqQWeMjcFnPZc0d6KH7UAGihWw73vFa7iHx5EZzmVr6S0a06fo060j YdcvsaGfIPX5BsOqnC6cSNNKJvZCgw+6m6ehr5JL/qYvwlVZZbEv7rab6bAJZk6LYY7z L3Lw== 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=FsLXhpjnCMcZTwbqVy4pDg8rppO3hMmLoK6/cO+Q6OdJ+wR4ixVyvHNoZsiI1DbkXR 3jJGs0aLhKAGTXie94MlBbyAAhgX6SC5t9ccCmc/VKaUsi3WSYcxGx1eSEy5Y57f2pHY l7+Ex+TAL6cvjtlwwB4HOWu+opGRCQBlFoVduKPfuhnk6i92hp/AR5G3MEk43PDS9+nS WwzpbSDDEFI6i0w5umhjmPvJMOXXkEfdDU6KlssXVq9hn4vZSvZd5HPhtcTOYVOuzhM4 sma4Lf+IduxmZ+1AGrXeUq/U81eO118MvBCbn3yZHnQyaeM9vHul8XlY8+LCwTZGNQTJ 2dYQ== X-Gm-Message-State: APjAAAXojcvmbxd+CM1A6O8Nkf/0itvCbn2xkxbNk4x0rTzNWpJ1fQNp I4/FSPdGSGPAXt3Pm5u/Xbk= X-Google-Smtp-Source: APXvYqwwCWxjRa08Q9QsCh5DWxn6v0JUV2txxv78VLf9uv7Zi78RSe26MCLNWRtfzT8ZyBqXcEgfJw== X-Received: by 2002:ac2:43a7:: with SMTP id t7mr51491468lfl.125.1578273444243; Sun, 05 Jan 2020 17:17:24 -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 y14sm28353271ljk.46.2020.01.05.17.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17:23 -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 v3 03/13] dmaengine: tegra-apb: Prevent race conditions on channel's freeing Date: Mon, 6 Jan 2020 04:16:58 +0300 Message-Id: <20200106011708.7463-4-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-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 --- 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 Mon Jan 6 01:16: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: 11318607 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 4AC666C1 for ; Mon, 6 Jan 2020 01:18:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 293412072C for ; Mon, 6 Jan 2020 01:18:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iYfurDC+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727370AbgAFBR2 (ORCPT ); Sun, 5 Jan 2020 20:17:28 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:34213 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727218AbgAFBR1 (ORCPT ); Sun, 5 Jan 2020 20:17:27 -0500 Received: by mail-lj1-f193.google.com with SMTP id z22so44469156ljg.1; Sun, 05 Jan 2020 17:17:25 -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=iYfurDC+4LnXEIJp+HtC5iMq3ZWbYdun4NcEAYHPcn0iHrHLNVOq58rgnYALsqukzN qJxXCarMT+q/i91kHYkHG4p+KHz28fqrTN0XPCqDgDLqcl6GaInhaXXPqCFxLqKTC35m DVGTB3Lzu7oB1TO0epMjnIIMjxANiTIvDNJyxGxgFAb+uqY30EFOB8OCMo5wWpEqV5uq ExiRvPMIlgqGK10qdYQtX1GYguVEKPCE8p1LspPupRglQhVopcirQpkxYUFE7OBcH7Bt 7Jm8/z9om5QivhZXQaFnq7ggF6e5PJ95Ol10lKg5hSNsBE2FCjTbz7mQttYb3Q1oa0g1 a+Bg== 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=AROo6GDp9WiHsXMwydu2bLKnQa9En3Ir70p8YFCQTrXFSJdIKQD/mrCi9sVoD2fFa8 A97vxsdin/fJhd46mQoehP8CuVR9nAxmkobClQOSwkJy8IRp8PT6FJqfGN+T12X7x+MD Qmajd8QB28Sag4Vm8etPI+HN153xUgVIl91Ugu3Am8lpy0thSxy+tSjtFEnIvW0MwZSK YdHIqijNLiVIUeJPKfgZf8E83ehrhp+F/o589tauyLnpmMtwY/d55JbyEU6BsrB0dt+1 bu0Ns4MXQsyrDt537CsO2mQvMSlr2sUcH10d1/Cg54iOLSHwAG/m/6CHrdrta6bh4CkY 0mLw== X-Gm-Message-State: APjAAAX4EhQWzPbNd4Mig+cGeoNvNqlf7mMI1S7f7NmJsukadInzrwqk 20du6VMqcwtgT3owc5CWziI= X-Google-Smtp-Source: APXvYqxl/QrcxfoUVFXnSQoW4fuvf5RTKybtvq1KJ3GMF/49AyDIsJpn8p8lZjn1alLOUy1/8kdn6A== X-Received: by 2002:a2e:b4cb:: with SMTP id r11mr58706047ljm.68.1578273445057; Sun, 05 Jan 2020 17:17:25 -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 y14sm28353271ljk.46.2020.01.05.17.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17:24 -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 v3 04/13] dmaengine: tegra-apb: Clean up tasklet releasing Date: Mon, 6 Jan 2020 04:16:59 +0300 Message-Id: <20200106011708.7463-5-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-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 --- 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 Mon Jan 6 01:17: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: 11318611 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 2EA4914E3 for ; Mon, 6 Jan 2020 01:18:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C597217F4 for ; Mon, 6 Jan 2020 01:18:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tQMIeYZS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727512AbgAFBSG (ORCPT ); Sun, 5 Jan 2020 20:18:06 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:46705 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727268AbgAFBR2 (ORCPT ); Sun, 5 Jan 2020 20:17:28 -0500 Received: by mail-lf1-f67.google.com with SMTP id f15so35286888lfl.13; Sun, 05 Jan 2020 17:17:26 -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=tQMIeYZSkToGF6IJkOekvw6u5tCQsNIXAfZ/9TpuCG721oFTlzA6XNgIOlv4IqLDl9 JDIMPtndCK0LMXEs8mwiEoaemrsPoTC7EPGwCwQ7cnK5WvsUR+QGa5rjQomB4vQld2WJ c0E4WnMFCA+3eLMLgQ8gavW3dnqTgidaM/9EYzWjkgGC4/4whvrv3iB9Lcz/dcTICL3Y ZLj3iFAN9iOPBCL9mdWRw6nJ3WjWFBpI/s/dTXfpApl17eR3Lq97hAWUD6YZzoANEdC/ 1B/Ykt92HLZ0guAmkeUZp0urH7oTMjSl3fVYMhHDVDy3easer8D5a4XjxWRRkvlSR/Fb LSng== 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=kQSgyrZ6AwjBHEsSJ1gIBE67snOolXLIem5tbRwqEmlWuaAmsT0tqAjR24SVscinj9 aszX5jl6UDgurCuCPMlbBeQCl+3Ja+1QZgGCMjipkZIdRs87lIE+GuuMbsU44/JKrHKm 9CHU7TQLuiUQOoAGejZUITMjImH+fqyrudVmOqSxm/4Nsjj400SIWQEEFZName2lagG8 kxSWLJPyqCYOsdDz4YUHj5B7mtn+JQ5s6SSKfBM7qozVD0sVvpDHQHifHq8fEaMg19TT 8uHdr4Fc01GSnojrHo5bLfLcVfXgDfmV1OIGcprUBPedswLnVAcvPcF1Yh7k4nDqcVUj EG7w== X-Gm-Message-State: APjAAAWHsObD5tkMYsAGIfjTD8INYAwODFdtshT1hkAmKuW0VWTZJL2z KJpYYVCprvQsg/f7zmlhTI0= X-Google-Smtp-Source: APXvYqyc/UIm3DmN61QXwb/R+vKFkesTIe8fyCUSFBzSN3eOen5o/5EoFgc03oEdjEo19m6UO3lb4g== X-Received: by 2002:ac2:5ec3:: with SMTP id d3mr55630899lfq.176.1578273445929; Sun, 05 Jan 2020 17:17:25 -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 y14sm28353271ljk.46.2020.01.05.17.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17:25 -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 v3 05/13] dmaengine: tegra-apb: Prevent race conditions of tasklet vs free list Date: Mon, 6 Jan 2020 04:17:00 +0300 Message-Id: <20200106011708.7463-6-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-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 --- 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 Mon Jan 6 01:17: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: 11318605 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 23FA614B4 for ; Mon, 6 Jan 2020 01:18:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 046DF24686 for ; Mon, 6 Jan 2020 01:18:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A348d47v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727412AbgAFBSA (ORCPT ); Sun, 5 Jan 2020 20:18:00 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:35067 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727366AbgAFBR3 (ORCPT ); Sun, 5 Jan 2020 20:17:29 -0500 Received: by mail-lj1-f196.google.com with SMTP id j1so41895564lja.2; Sun, 05 Jan 2020 17:17:27 -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=A348d47vqgmZE3QZHZNr4VYjBQsBxNT0Y7L/VpR06H89JD0HnMzIy5yX9i0EB/L+R8 pHFicXl6bs8pyz5mpLHxhFllxz9uXFaNiJAoSqhU67SBBiiFGQ/z+uQjYXNt73HCL3WE Z8FBOVoDhpCCnjKjp9Xh1WoTVqdP0c8xzjZz1MMmMF0KT/hVMDRAtwD/xfsfPgrvizEx Ytce26+8/m0xDMkDyfgvGWSDUhq8rHnKo+LN+5a7zbLVIsplaBMKmGZGZ2wyeRSlb5tA G221IFlTD6MIBARal1blCJUskAkRryzA03lj0FNCU8p+Ln88qjlzqQ4YjMEHcgpnT2GA iksw== 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=Z2o2fFs22AlzoUDtU2CRTStEc/8KsBtVO1rF5g6ljlvvCzabB4nfX8bhCGm99fqMT3 9xfF8BU027kacagj5zSUta/0kkrtsz6+s+wiVdfKharOgTewFpNdXHbzQMubudl7247k hxGeJ5/Za/N0692O7X8fyokQR6OiFknEjyF7T5zAyWjShHksUKmYrC5HBYho7Tnc/Jby jhng6qXx6WEeXhcT2jr1LZvaxQBlCmEhUKNY4syHNXHne84YPbxdo4aiU6W4wRmhQdga nZwBfFuee0+igQpCTWjdip7nPpwvEsS413HvbPgM0+JL5ceFFersqkucn3Ds69LVyWFC o1nw== X-Gm-Message-State: APjAAAWmOObvyZR+DuI3AnWreHWWSEVE3AwUcVRKvJJb144JwXWHh9xu CME7ku65RRTtUjJW1CcyQY0= X-Google-Smtp-Source: APXvYqyyxu9GfbDaxxQeEVxeLNvnxScrVjEMec1ZPASAPBAeaxevmI9ojILCm7DUqenwk+cJ6Zzoag== X-Received: by 2002:a2e:b0db:: with SMTP id g27mr60026564ljl.74.1578273446766; Sun, 05 Jan 2020 17:17:26 -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 y14sm28353271ljk.46.2020.01.05.17.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17:26 -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 v3 06/13] dmaengine: tegra-apb: Use devm_platform_ioremap_resource Date: Mon, 6 Jan 2020 04:17:01 +0300 Message-Id: <20200106011708.7463-7-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-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 --- 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 Mon Jan 6 01:17: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: 11318603 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 A6FF614B4 for ; Mon, 6 Jan 2020 01:17:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 858E424650 for ; Mon, 6 Jan 2020 01:17:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dXc6SZf2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727400AbgAFBRa (ORCPT ); Sun, 5 Jan 2020 20:17:30 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:37406 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727367AbgAFBRa (ORCPT ); Sun, 5 Jan 2020 20:17:30 -0500 Received: by mail-lf1-f65.google.com with SMTP id b15so35336005lfc.4; Sun, 05 Jan 2020 17:17:28 -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=dXc6SZf2M91qRrX2+fLpoa570MlqQZI2yCqypJ1x8NpDrofeydKtERGM1hoWmr5V2k kECYcyZ7TDd+4KtqsoPRzt1UTA5GvyQP7zm3eaRGiFd0uOHm41SEkKe9EFL2DYxoLTXD qlS8uxeUa7p80rca31cMThCeJNR3UgHmsKH3qFWE6anX5HFbrjmsF+kBD91qSB4/MMqH 6zUSSverM74yqC4UJ7ibjv14Nv9G0sRrhdxYJxYOfOuOWI13kHDkSmdaMuKGMv3ZWVYJ vMEcHs90ka2uw6736+y/cqrjFfgoNFnO8QqEyVGFmewZrEmvuXZsuJa84FuxrBUz2kK7 +4+g== 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=JpnCz2LEUTvM9mBjQBd3ip0/xwta/nH0wbLQJ0JyVISKM7ZUnaroCJyExIMzgDw/ZH yxB4Vj7CNdBmRruuwRpPZqPK0lbPm6204z9xXaE8OCRkWISHpxkShDObzdEs7mAQ1M3u qMCmQG0MiUBCmuB8PDh/Dt2kHrKVEF9Y1muMd+7phiwfaZy8kSo5q0+ijeGxXwSqcxDd KOFEW3RedpWtYDkWe6erwVM5n3wUOTnSVcbwxH7TreShyYdjsX/YV2Uz7z9GZtlPMJcA eZ8VstlYvhazhWKq5g7WoKNzkwdpKfd6w/858bS+gEg0hS+FVVYYVe13gtFhFmTVsRMs IqBg== X-Gm-Message-State: APjAAAVTb+WMOKUlE6E+0UX4na9Et1eTdkFSC25XxQsqPoYMGcTvUjPq Uqnb/01Gy1jVSs4sffQ2kxH+utM6 X-Google-Smtp-Source: APXvYqxjjD9CLBn70XF78KnX3Si+y1oBx6yJNizu0RrGS0pKiikrU7KQB/Lrrdf46h6SDGtSeOERLw== X-Received: by 2002:a19:7604:: with SMTP id c4mr56727060lff.101.1578273447620; Sun, 05 Jan 2020 17:17:27 -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 y14sm28353271ljk.46.2020.01.05.17.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17:27 -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 v3 07/13] dmaengine: tegra-apb: Use devm_request_irq Date: Mon, 6 Jan 2020 04:17:02 +0300 Message-Id: <20200106011708.7463-8-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-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 --- 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 Mon Jan 6 01:17: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: 11318601 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 CCE1714B4 for ; Mon, 6 Jan 2020 01:17:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D6BA24677 for ; Mon, 6 Jan 2020 01:17:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="evQDeQSK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727428AbgAFBRd (ORCPT ); Sun, 5 Jan 2020 20:17:33 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45761 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727384AbgAFBRc (ORCPT ); Sun, 5 Jan 2020 20:17:32 -0500 Received: by mail-lj1-f194.google.com with SMTP id j26so49252132ljc.12; Sun, 05 Jan 2020 17:17:29 -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=Wk1WTjiShg7I1pGY+PbqE2OAu+HQZYw0+E8VKICJA/M=; b=evQDeQSKkse8HXMICcinrs8bJYIulTtVp0sSjaC24LytW8EXGKzDdtVvbBLi1L5AqP G5zdXxam1ZpLNIdRLHPdDEbQdKGJo7VyXjIa/DzM1JArMQffLGWiK1r2UwIHy4J+iSx6 hFivo0mMYtLf7tmfG7MgsV/yHimApDamS6LkCxPUGw2eB9PuVp7MIPl6wqTN7SjFZKj/ PR0iQfCshrwfdiYlz/wCnF4+8ZFNErRvssoEj23dHgZ/MTU2lMXXD52uJWSQR80H9uvN YKmzCwUbYYatZX9CQNKEmG7YmKoylyj/tEJqGeUEuQbl0xiJCwh52L98XcBToke34jFk MJvg== 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=Wk1WTjiShg7I1pGY+PbqE2OAu+HQZYw0+E8VKICJA/M=; b=tJCJU/OcKr8AW1iJ+E5OTHHl3BGXg8QqifD2fpiIw8yrqsjNdTyzdjwqeVRMqvlXtT 0/qth3I9IkA/TzzRXfjQtMiKaiGGNo2ToCtGAudm8Fh//W2we3EJEgEpAuOlGmWs+Q6v 1zJJw2Yh+krxytoYnCYRzvX3UQUzzsPMpgOkY9SlXobKW0339A4I8SYWJRXw99/7+UiD cm4eHy0i1YeiRv5goXjEX0ea4E48K9znifIgp3B8AppDYAeHsdzLWUO+nYpgjqTsN3kT uxgZkz9S4ARUzLRLb7yns/bQX+1j9aIZ9Ew7BGaSSDx9J0Sh+gXMSsydBjaQMjHWJhpx 28xw== X-Gm-Message-State: APjAAAVUjopasyTAnQRQiOeeq9LkHwFZ2sMQ+RYVDoI7rLUmYs2JzLUD TFb6zXalrSy56iK0pPqT30E= X-Google-Smtp-Source: APXvYqxa9YkRmDCQzNo+bUu/iAnNJeUBD9nAuzDVrzIy2mk4pbTuFfbNN/qnT+p5VeCftUFTYhZJTg== X-Received: by 2002:a2e:85cd:: with SMTP id h13mr56910967ljj.191.1578273448504; Sun, 05 Jan 2020 17:17:28 -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 y14sm28353271ljk.46.2020.01.05.17.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17:28 -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 v3 08/13] dmaengine: tegra-apb: Fix coding style problems Date: Mon, 6 Jan 2020 04:17:03 +0300 Message-Id: <20200106011708.7463-9-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-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..804007cbd6f0 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 %d 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 Mon Jan 6 01:17: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: 11318591 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 04DAF6C1 for ; Mon, 6 Jan 2020 01:17:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CCEE221775 for ; Mon, 6 Jan 2020 01:17:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CcqVzA89" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727421AbgAFBRd (ORCPT ); Sun, 5 Jan 2020 20:17:33 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:42801 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727393AbgAFBRc (ORCPT ); Sun, 5 Jan 2020 20:17:32 -0500 Received: by mail-lj1-f196.google.com with SMTP id y4so34929938ljj.9; Sun, 05 Jan 2020 17:17: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=CbkeH0xmAQCRmWh0Eju1899FMKALNRd2ceKFdD2Xbyc=; b=CcqVzA89QDQ5sHhtU89BvHoDIqoGDwrWDG9e/L71Ii+IMab7S2FueoW7VN/AHI4H9X BcQ8LkLVX41U2lvs4zF/pDljQbm6Zh79DUKsVBLLJxFILFOElDgYAjdL3JCej2acxnU6 TbNTJ/NbeHqnK0PtMtEQAyx6b+hJZhRMoXhCDcjB6Xiytnf/MNR/WrqNSazTpdWLNuZT 8Q32w6/3b6gSoCMp27rBn9Ne8sq4xDq30ucWy7dOPOeub/+XNeVxbDl9R6/KIFFbzIRU Z02tO6E7C7KEOX4+vB+TjB047COuKvE8Qu0xQCZCjsMJv79ZHX4s5Pl33g1sb+LyT0ek X7iA== 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=CbkeH0xmAQCRmWh0Eju1899FMKALNRd2ceKFdD2Xbyc=; b=K8KnCCweMT0kHilDA0mRD7UKVfAvmuLYJgb0VBe9N9S/udFCEkDcT07Oqr9oJY417X UxTHJHxoDMBCiZRewxXD0QWTO4YFsuTBlp+OLQ00pPDjiCCvI1+NXViVRbdEx2LOEmjD SR6fGNi4qSem9WxOB1Qlyrhp1buo7Tdq1SM0tixZiitU4c7sXeNuNStsJd7cEHn0bIIs iGGBU5NZTDe/DsKGv6KStLYA8T33K+F0fLnWXYpbuIqPF+nwc4/VH5ix0SRNDDDvLRUS 4F9Km5llbioixGYHxZ0WH08/xpj7FLkdCaEn0RQwupcVimTmze1Y+WcRxBT9seahiJHp sw4A== X-Gm-Message-State: APjAAAX/GV5kqG0kxEHJ/nkxBgI6uiqLNmVStq6NAF8cmPQXDrcudTZx h7vXSzXTLfn8TEAieejrrdw= X-Google-Smtp-Source: APXvYqxF8YuRfr5bha7LJI0bHPtIoucoDkbqLfWI2xbzOCmanCNozi+lliRUMzGkavwJXw7UaNispA== X-Received: by 2002:a2e:9095:: with SMTP id l21mr57489446ljg.175.1578273449406; Sun, 05 Jan 2020 17:17: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 y14sm28353271ljk.46.2020.01.05.17.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17:28 -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 v3 09/13] dmaengine: tegra-apb: Remove runtime PM usage Date: Mon, 6 Jan 2020 04:17:04 +0300 Message-Id: <20200106011708.7463-10-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-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 benefit from runtime PM usage for the APB DMA driver because it enables clock at the time of channel's allocation and thus clock stays enabled all the time in practice, secondly there is benefit from manually disabled clock because hardware auto-gates it during idle by itself. Signed-off-by: Dmitry Osipenko --- drivers/dma/tegra20-apb-dma.c | 76 +++++++++++------------------------ 1 file changed, 24 insertions(+), 52 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 804007cbd6f0..840a58e782ec 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -266,8 +265,6 @@ static inline struct device *tdc2dev(struct tegra_dma_channel *tdc) } static dma_cookie_t tegra_dma_tx_submit(struct dma_async_tx_descriptor *tx); -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) @@ -1280,22 +1277,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 +1318,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,27 +1417,6 @@ 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)) - ret = tegra_dma_runtime_resume(&pdev->dev); - 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]; @@ -1460,9 +1428,8 @@ static int tegra_dma_probe(struct platform_device *pdev) 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_pm_disable; + return irq; } snprintf(tdc->name, sizeof(tdc->name), "apbdma.%d", i); @@ -1472,7 +1439,7 @@ static int tegra_dma_probe(struct platform_device *pdev) dev_err(&pdev->dev, "request_irq failed with err %d channel %d\n", ret, i); - goto err_pm_disable; + return ret; } tdc->dma_chan.device = &tdma->dma_dev; @@ -1493,6 +1460,20 @@ static int tegra_dma_probe(struct platform_device *pdev) INIT_LIST_HEAD(&tdc->cb_desc); } + ret = clk_prepare_enable(tdma->dma_clk); + if (ret < 0) { + dev_err(&pdev->dev, "clk_enable failed: %d\n", ret); + return ret; + } + + /* Reset DMA controller */ + reset_control_reset(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); + dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask); dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask); dma_cap_set(DMA_CYCLIC, tdma->dma_dev.cap_mask); @@ -1525,7 +1506,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_pm_disable; + goto err_clk_disable; } ret = of_dma_controller_register(pdev->dev.of_node, @@ -1544,10 +1525,8 @@ static int tegra_dma_probe(struct platform_device *pdev) 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); +err_clk_disable: + clk_disable_unprepare(tdma->dma_clk); return ret; } @@ -1557,15 +1536,12 @@ static int tegra_dma_remove(struct platform_device *pdev) struct tegra_dma *tdma = platform_get_drvdata(pdev); dma_async_device_unregister(&tdma->dma_dev); - - pm_runtime_disable(&pdev->dev); - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra_dma_runtime_suspend(&pdev->dev); + clk_disable_unprepare(tdma->dma_clk); return 0; } -static int tegra_dma_runtime_suspend(struct device *dev) +static int __maybe_unused tegra_dma_dev_suspend(struct device *dev) { struct tegra_dma *tdma = dev_get_drvdata(dev); unsigned int i; @@ -1594,7 +1570,7 @@ static int tegra_dma_runtime_suspend(struct device *dev) return 0; } -static int tegra_dma_runtime_resume(struct device *dev) +static int __maybe_unused tegra_dma_dev_resume(struct device *dev) { struct tegra_dma *tdma = dev_get_drvdata(dev); unsigned int i; @@ -1632,12 +1608,8 @@ static int tegra_dma_runtime_resume(struct device *dev) return 0; } -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) -}; +static SIMPLE_DEV_PM_OPS(tegra_dma_dev_pm_ops, tegra_dma_dev_suspend, + tegra_dma_dev_resume); static const struct of_device_id tegra_dma_of_match[] = { { From patchwork Mon Jan 6 01:17: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: 11318593 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 357DE14B4 for ; Mon, 6 Jan 2020 01:17:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 092C12467A for ; Mon, 6 Jan 2020 01:17:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ofx3h1kM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727439AbgAFBRf (ORCPT ); Sun, 5 Jan 2020 20:17:35 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:42974 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727401AbgAFBRd (ORCPT ); Sun, 5 Jan 2020 20:17:33 -0500 Received: by mail-lf1-f66.google.com with SMTP id y19so35292831lfl.9; Sun, 05 Jan 2020 17:17: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=f4vbxLY/XQdiocivNYtPxd9tQFRfFjTO1i/Gv+RTsgM=; b=Ofx3h1kMb4BOniKSIgNLG6DkIC9wDikdatdiieQ/CBcyUK31Bam+7TK9cZBI9pK+eg tSkK5iPB8lsafTprzrW1Q9/btZY6gLTBcaFT31DsixllAft4OcDeefs3fTbl2FOrkHj5 Tfe95l8OtHqiYTREaiQ4UnsWSkmfmHapTQAPLPptH+bq74PeCeOH4kG8lrxlf8lVmKKB aAR23DHThmbNqAGFF0cbX0P9TNR6VfjgOdGKe9lVVN0Z2V4YHiBelcjyXc9J+pGhvtT2 Wfi9c5kNOfJf43N/VG7lERTb4bWpHZDkvlujwgZWfRBpV7WQ/jPFIVAHQT/pGVjxoanI RXMw== 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=f4vbxLY/XQdiocivNYtPxd9tQFRfFjTO1i/Gv+RTsgM=; b=XJBQkiL3V2KyEtGiKIdgxqn5+L06Y+gZEC0nXPdji33JXpKwRBMKsmWUaOrYmTPB7X HAaWikD9fOCj4BXlUEW1J69qPJLiRn6vSt765r8DYfMEvp4ktHETKMqB9uR0wVcUTQLU 1E22kQuouhKmaqPp05du3PlED5jC1ObEB8S0zrbkNYVlIQYtQGSfx1ezNA/TOTFNCSK2 cfJBZqt+27uYiFkrD7aOZUbqstyTyZ0eF8RTpSlUm9tVHJqar/ahSg2maA8vLAD4AbXD MPPU7R8VyhaB/7OEaWcmhB59r19fMwb82vQuK3C1YC9Ui0w7YdA4c2ZBXCQgOF+BA16U fPyw== X-Gm-Message-State: APjAAAUb+jXtSoGFppoJ+dIB4W4hno+OT4tkV+BcUwLWUbCP1xGWhdf4 PNFlJKuM/J3Jr++OqA+/wmk= X-Google-Smtp-Source: APXvYqyFLPWKafsZWNv1+8FEFNvuYJMnKuOoR7/zXOgA6uXiMQzIdyNd1gYEIogqC7uR4ACnf8EiAQ== X-Received: by 2002:a19:f514:: with SMTP id j20mr51152852lfb.31.1578273450295; Sun, 05 Jan 2020 17:17: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 y14sm28353271ljk.46.2020.01.05.17.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17: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 v3 10/13] dmaengine: tegra-apb: Clean up suspend-resume Date: Mon, 6 Jan 2020 04:17:05 +0300 Message-Id: <20200106011708.7463-11-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-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 | 122 +++++++++++++++------------------- 1 file changed, 55 insertions(+), 67 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 840a58e782ec..a75d2dd850c7 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -220,9 +220,6 @@ struct tegra_dma { */ u32 global_pause_count; - /* Some register need to be cache before suspend */ - u32 reg_gen; - /* Last member of the structure */ struct tegra_dma_channel channels[0]; }; @@ -1380,6 +1377,40 @@ 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_prepare_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); + + return 0; +} + +static void tegra_dma_deinit_hw(struct tegra_dma *tdma) +{ + reset_control_reset(tdma->rst); + clk_disable_unprepare(tdma->dma_clk); +} + static int tegra_dma_probe(struct platform_device *pdev) { const struct tegra_dma_chip_data *cdata; @@ -1460,19 +1491,9 @@ static int tegra_dma_probe(struct platform_device *pdev) INIT_LIST_HEAD(&tdc->cb_desc); } - ret = clk_prepare_enable(tdma->dma_clk); - if (ret < 0) { - dev_err(&pdev->dev, "clk_enable failed: %d\n", ret); + ret = tegra_dma_init_hw(tdma); + if (ret) return ret; - } - - /* Reset DMA controller */ - reset_control_reset(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); dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask); dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask); @@ -1506,7 +1527,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_clk_disable; + goto err_deinit_hw; } ret = of_dma_controller_register(pdev->dev.of_node, @@ -1525,8 +1546,8 @@ static int tegra_dma_probe(struct platform_device *pdev) err_unregister_dma_dev: dma_async_device_unregister(&tdma->dma_dev); -err_clk_disable: - clk_disable_unprepare(tdma->dma_clk); +err_deinit_hw: + tegra_dma_deinit_hw(tdma); return ret; } @@ -1536,7 +1557,7 @@ static int tegra_dma_remove(struct platform_device *pdev) struct tegra_dma *tdma = platform_get_drvdata(pdev); dma_async_device_unregister(&tdma->dma_dev); - clk_disable_unprepare(tdma->dma_clk); + tegra_dma_deinit_hw(tdma); return 0; } @@ -1544,28 +1565,26 @@ static int tegra_dma_remove(struct platform_device *pdev) 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; - 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); + + 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); } - clk_disable_unprepare(tdma->dma_clk); + tegra_dma_deinit_hw(tdma); return 0; } @@ -1573,39 +1592,8 @@ static int __maybe_unused tegra_dma_dev_suspend(struct device *dev) static int __maybe_unused tegra_dma_dev_resume(struct device *dev) { struct tegra_dma *tdma = dev_get_drvdata(dev); - unsigned int i; - int ret; - ret = clk_prepare_enable(tdma->dma_clk); - if (ret < 0) { - dev_err(dev, "clk_enable failed: %d\n", ret); - return ret; - } - - 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); - - 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); - } - - return 0; + return tegra_dma_init_hw(tdma); } static SIMPLE_DEV_PM_OPS(tegra_dma_dev_pm_ops, tegra_dma_dev_suspend, From patchwork Mon Jan 6 01:17: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: 11318597 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 708256C1 for ; Mon, 6 Jan 2020 01:17:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4E3BB24650 for ; Mon, 6 Jan 2020 01:17:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Se0oyKMl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727481AbgAFBRs (ORCPT ); Sun, 5 Jan 2020 20:17:48 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33771 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727412AbgAFBRd (ORCPT ); Sun, 5 Jan 2020 20:17:33 -0500 Received: by mail-lj1-f195.google.com with SMTP id y6so41263850lji.0; Sun, 05 Jan 2020 17:17: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=4M1pbXI4iZqpx2CZVGwVg04bXNfT4TMrAkn2UqNwoHw=; b=Se0oyKMlmuyw/YYxi6zZKlC8K1EQMsNZBShw8PPJtx6J11F1VcNwFQsFJi6jDAvqPw wVbEYbvVQHkONk1YFCaUzMZCsoHfFbg54UNFMHfIpMbt0ad1pnhvWpm/LF1QUOCBo1uo 9SYRsFssJwucmyZtMB2KCUnOZAQeQAU4Gx/BHQ1Iu/2NVHnq0FJjc65fYKbbHOkESa6y JP9LkjwHFU8UIr0OZdGlw82haT6hciK8q/o/iEZ/70VOwEILFt4c5OKUToOXs0nvKav5 IbGch0p23k9zNUsxuFGJG0tlpPXNA4swoY6zHTfnkzhrw/07Umx7wmn8mBDTEOTnLUVt rPRA== 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=4M1pbXI4iZqpx2CZVGwVg04bXNfT4TMrAkn2UqNwoHw=; b=f8XS6HIGcXUBEVMyvQPFs5XaOrJMbyRP+G1Ye9zt4yWCla1KSSkUPHFfepfQH1W48Q jBWVbZP7dAIsZwB95SCxs/UKKzZFFwR13HOIydJ87dYMACw7RdGEqYb9dAT+SfJ5AQgf BGdiW9sikkQxLSiaqMf0hfTvU6hNmoFckFfmAH69STphpa5GV9SiN/r6eN7ECavp3s2V WC/6IXLaPACBRUlBpS9vq/QjFrDpSFnbPVz4EKbxb6YS9A7Zbqf5MIdlf03X1yu/7ng3 Wnh9omuVys7ZX0QeF83p4St2swcRkv3YeOg1DukhBl4FPrbprLfsMQIWyoXTyeSR94hn 0QAg== X-Gm-Message-State: APjAAAWhAVcWTyPj0THZc4RLrya2dvc3l3zhLn7EguELDsFGtFHLoFQv 0duRgKG5cqrYKXQ6uJr9r6o= X-Google-Smtp-Source: APXvYqzHZv3ZLSm9iyb+iAqTkmf2jyFr5iIOEvv/Y50+jciOiDlSMxvvKCo5ERPibKL4bxzex1ABmA== X-Received: by 2002:a2e:b60d:: with SMTP id r13mr58258457ljn.40.1578273451173; Sun, 05 Jan 2020 17:17: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 y14sm28353271ljk.46.2020.01.05.17.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17: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 v3 11/13] dmaengine: tegra-apb: Add missing of_dma_controller_free Date: Mon, 6 Jan 2020 04:17:06 +0300 Message-Id: <20200106011708.7463-12-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-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 --- 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 a75d2dd850c7..108307c428d1 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1556,6 +1556,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); tegra_dma_deinit_hw(tdma); From patchwork Mon Jan 6 01:17:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318595 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 884EE14E3 for ; Mon, 6 Jan 2020 01:17:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 66D632465E for ; Mon, 6 Jan 2020 01:17:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xj6U3B6N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727436AbgAFBRf (ORCPT ); Sun, 5 Jan 2020 20:17:35 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:37832 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727419AbgAFBRe (ORCPT ); Sun, 5 Jan 2020 20:17:34 -0500 Received: by mail-lj1-f195.google.com with SMTP id o13so37858961ljg.4; Sun, 05 Jan 2020 17:17: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=0hLaeTkiGQpndBzsnntj+Kt92MOlWlIIs3RhP31I+1g=; b=Xj6U3B6NTZGfvGHJ2926iwr8Kz7oH4NFoWBF2GZw5TNmS+uzOrgHabd00cq8gqhj2k cfrtJSD3izXx4Fm8uqeaivhie+Par8uBCDWJOivpwiOb5Ia4n9GMW4RE9y3SM3Pgx6uw Pc6gk6iIwo39TE6eKhqjaxRNRI/PPLRH0g+Tj3XYBv5X7xZ0P5+mwR541//UuaYUgjAX 8luFrZ9z71ayDGw6BSb2cBCKV8RxlSDy99u/OMFPY4M9BydZubeH6MN1ZcpQ92g9KV/R P9q7AYU9JwysOfI20MlyraJTNJOt0h7/Hq+gGecBYoM7t7TyNYFmh/bR8xl9rD1lrai+ 6rCA== 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=r66OCAvQKEZlHpHnGPfKYUD1AZyZN1eQ0yqWZiLZ+QeR04oooAyoJTsZYkyw9NAZjU 5mpMMcWfG2FWQHC1j5NywSiWxcnunFH8fNSQRFMUdFX5rqftr2hxnDfBbY1oS6glA9Mi Uw2/bHrtaYppPBL/zDgj7rBtvxqsq6diKHHJvPjUN8W/jQ7fX3Eb/xsEyJs4vR2rCCDE RRgBNsmaEcWxIvA59JaDqfE/xp5CRgHnUP61ozhAWp24qWpC1G/159/HsE1J7rd+/yKB xhSGcaBdfIiY19dSDn5WLpeGD1nmOe8kR+zG65eAvE3hcx6rBPXK7RwS3kLsbq6qRx2U vhVQ== X-Gm-Message-State: APjAAAV3hJnQr4yZ3IBthQ2X3dlKGB8u1sRa6Rb3s2ndEmXjSwfiKHQ1 8NML+5Pr91bC6BENMMzfGM9T7kuy X-Google-Smtp-Source: APXvYqytlJ3Wis1nxErmmc82w/Yxm2zsqQgOLOra4E4Cwq37TLMppKN1NChShh128XAJOE0vxcPDKQ== X-Received: by 2002:a2e:9587:: with SMTP id w7mr56113438ljh.42.1578273451995; Sun, 05 Jan 2020 17:17: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 y14sm28353271ljk.46.2020.01.05.17.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17: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 v3 12/13] dmaengine: tegra-apb: Allow to compile as a loadable kernel module Date: Mon, 6 Jan 2020 04:17:07 +0300 Message-Id: <20200106011708.7463-13-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-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 --- 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 Mon Jan 6 01:17:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318599 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 839286C1 for ; Mon, 6 Jan 2020 01:17:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6197124650 for ; Mon, 6 Jan 2020 01:17:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ERNPqWxq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727401AbgAFBRs (ORCPT ); Sun, 5 Jan 2020 20:17:48 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:34222 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727430AbgAFBRf (ORCPT ); Sun, 5 Jan 2020 20:17:35 -0500 Received: by mail-lj1-f193.google.com with SMTP id z22so44469348ljg.1; Sun, 05 Jan 2020 17:17: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=tc1NZnYVPS8eGKzhqigGBo/msJoPdsspl+hbIPJGjaE=; b=ERNPqWxqWjSbk38ja7XXNfIsMLjfeFR3skQ43achgRGZRI3thlsWKFbvf2ySjrERHQ k3vxK/B80tsB2/OWKU4GW56rF/x9D1g5mXh0XaKOEz9pjaydz7G2ue3Me6D4fKxGDSWg 9l9OzFyNqzGHN7fGfQaTu33o1kJ5GhTNJFxk4vFyFQB+KYDFG+ZAdsvAANFGtqdU+7ex JTILV/ffJhlM36ElCkD5R4TfZPd28eWhGAIiyfcup4jW0OK/0bzLOSTIbBNGkxHSGkNN UsqQjG0LoUS5FzXmIwU+icE8mwQzZbui1Bu68Vp4YFSlUTMr+bz+zyVOds2F92sJfrBD ZA0w== 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=tc1NZnYVPS8eGKzhqigGBo/msJoPdsspl+hbIPJGjaE=; b=OGX6rV7RAjRO5Bzsg32c3SxsYGL2URU/UJV5ijS7y9QJcdgGpI13iOZJva4eJ2YCrT CrAMW7x2EyPeOgbLSwEj7Qe7xj1BhzBdUFzdze1l8h9gsq5hrNXDOXzT6ugvqbLHwqZa m6zcPoW4ejbf9dtUk8K7lAXsQkJC+1pSqWnDyaygC9J9vpNve/L3GeShmd4/XWEKQDy7 T589cMc0oANkgrTeboLtR1QHyYfWscLa3+gr2LL+ExEp6b8ZHg0b8ivyWyweInBTb++E VyjVD6L7y4ZK8hh7ShtrlA5NLBxsXz+wiLow9KCXknS2iROOQCObETtLrT5js1LezOkf /oeA== X-Gm-Message-State: APjAAAUSQ/vT7S/sLKrSFWErB0pEOcefmEkd7XII8mesWS36CMMyIHkD FtwvkwIz/mK6tySulrCvIGw= X-Google-Smtp-Source: APXvYqzYe34c41UYasOlO3Q71ehSfXf53xRSBQ2dulBdHYyvG1rnLXnOy+IYedOtnj/EkKxRWlM/Vw== X-Received: by 2002:a2e:6c06:: with SMTP id h6mr56142370ljc.246.1578273452789; Sun, 05 Jan 2020 17:17: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 y14sm28353271ljk.46.2020.01.05.17.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:17: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 v3 13/13] dmaengine: tegra-apb: Remove MODULE_ALIAS Date: Mon, 6 Jan 2020 04:17:08 +0300 Message-Id: <20200106011708.7463-14-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106011708.7463-1-digetx@gmail.com> References: <20200106011708.7463-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 --- 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 108307c428d1..7a6a7cb81e8a 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1630,7 +1630,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");