From patchwork Thu Jan 23 23:03:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349275 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 59A18921 for ; Thu, 23 Jan 2020 23:10:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 32E7E2071E for ; Thu, 23 Jan 2020 23:10:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fNhkObiS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729782AbgAWXKr (ORCPT ); Thu, 23 Jan 2020 18:10:47 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45333 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729505AbgAWXKq (ORCPT ); Thu, 23 Jan 2020 18:10:46 -0500 Received: by mail-wr1-f67.google.com with SMTP id j42so5147367wrj.12; Thu, 23 Jan 2020 15:10:45 -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=fNhkObiSjJhnzK5SIwdLnHYXfNxS+e+5gd4Jp12j/u4Q6WPoAX/s1EBaCABGIoeDTG xaJD/AUJ7VARy/nUlYVTmE1VbJKY9M3GfOMrgQ3abqPohuQHqFYEd1eEmHHzvy2i2uAb tRD1yGEe/d+w2oEg5EsWjZqhCq6KLgKvo7TrA/iJtIJHwm5erUcz+WGwUDc9fzPJ7Lop zwsEJNfWs6Xobe60qBwk3nJuHjHv4hZ3LebJutyJ5PgJr50dY0+e1U6AFLt2Vv1KcPhB lMJ8g/l6k3WB8O3EG0IhC9y3zxv3QxVw8oFAb02HQtWhV1x6akLV89Bbwm/3uDQ6Y5rI Q5zw== 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=FBvtxh6oYxRJ9qmrugrQXddpnu5TCQI9f+Vs140vOhjA/Gw84CZpSBszv6mbJdHCFi 1Z16uH4YmNt2PEtudW2m+qszYy7EeKvbU8I+o+sfppmFO3dKP1sOlfIdVhkcY8l3Uhq6 ag9mkKRE5G+TXHXktXwXVAyaduD+/WwRlhoEDpQ1idnMch8trrJu+RmBsB8tnayrkrKv HhkAEQZ7aUnGvnyGNc2H14eSkHeEhcwzb1AuMlqYa0rVKZW86eXhVVZgCV369xnX1aJs pzv3VkUaLB6zYyEA6E9PWGgTD+AF5Qic9M3dBQ1SfHDCwiML5m+wR5my/Z8rNpEG3Wqe ZkbQ== X-Gm-Message-State: APjAAAXnwk51qwAL8aaRKXCSbfzoK5aqrDZoWSm04le9LdsiSxHL7urK JXNhUjBmOTKTjsaNbN1aO9s= X-Google-Smtp-Source: APXvYqz+62yqIUxusIadJGkOBozJ4OlPot3yyml+aaBeZ0EEj/V9RTEJVTnYhkfMhC5kRIaUEtIADA== X-Received: by 2002:adf:eb8e:: with SMTP id t14mr447622wrn.384.1579821044601; Thu, 23 Jan 2020 15:10:44 -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 z6sm5105552wrw.36.2020.01.23.15.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:10:44 -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 v5 01/14] dmaengine: tegra-apb: Fix use-after-free Date: Fri, 24 Jan 2020 02:03:12 +0300 Message-Id: <20200123230325.3037-2-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-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 Acked-by: Jon Hunter --- 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 Thu Jan 23 23:03:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349297 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 EB422921 for ; Thu, 23 Jan 2020 23:11:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C23BC21835 for ; Thu, 23 Jan 2020 23:11:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Oqf0ZnX/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729814AbgAWXKv (ORCPT ); Thu, 23 Jan 2020 18:10:51 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41060 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727056AbgAWXKr (ORCPT ); Thu, 23 Jan 2020 18:10:47 -0500 Received: by mail-wr1-f66.google.com with SMTP id c9so5191616wrw.8; Thu, 23 Jan 2020 15:10:46 -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=NYonzf1fVhFYzmQTcZfQISC641wGqXMLHQ0dPIoSwuM=; b=Oqf0ZnX/iZprtRvdUHnQiYKr2Sn3z/ptVuYc2e+ppYNkcY6uJZHBLsDhnaNPEu7qOg 0Nvw1SipU2s2A6LeBbIGooyUO1A8b44Yo+XWaewzj/8br788qbWU+mV4R6YcBQZ0q3C8 IQQTDcuC1lfxuLbj6eM3snrlWxe7wqxl+6T4ZYJK0KmcBqwd8RDfm4OF2GGXYlWDP5dV 5x/DHrdpSVCsWCjbkKw0bkdEmQ4d116rkMExhyXWfwMBoEKsbd5+c+Aw4XnJiH9LxET7 q4kUFrYHRoh2CnxOTzBqAziCa1dTYesDvR8Gs8OfeA3GaktmXoZYmEpAzH2JvVp2AReW 5BZQ== 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=NYonzf1fVhFYzmQTcZfQISC641wGqXMLHQ0dPIoSwuM=; b=VcLQ6MkdiY+dRpIC8YXGE4goOWEPHDa5TlVK+/W/Cz0fHA9AF+ubfDaOEHknOFf6zI Z4Iaw/M+6OBTMphUBVBJ/+i0+LwAEtuA8uaVhuYFwXLh7MlfJbQULJSDx+fQqaibDLQk hhRDfnXSYy39zxPxXjz8kqNVnBylz4HZ1r9d2qSx2nrSV50kyrQ4bCAV48uo/bu3+TUp e3bNXMqsRgbqZjd8b4Y8Nxlp53K6PY6ZhzahypHf9ES3Rf2GQikzS0YI4aUUUjU3wYUF MKxwN2AglS3xvIpfcZ1WgH8mP72H5ye7j5MhaK6os3xwmbQRJ8r4vOxt9RJV766DdOzw Qrig== X-Gm-Message-State: APjAAAUrMPP/+MMZcKE89C7gdcLiX3isLDiLf9Nt1pBE0L2CimhyRPvD S+Yi9khLBAGVE+gd1gtTnBQ= X-Google-Smtp-Source: APXvYqzZfJtEoHCBkiLOC/3Ocg2DIdl+0cHXXkkc9L72w0gZNMoRTCjaTe/CTiML8ObFj2GkKt+3eg== X-Received: by 2002:a5d:4984:: with SMTP id r4mr425619wrq.137.1579821045825; Thu, 23 Jan 2020 15:10:45 -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 z6sm5105552wrw.36.2020.01.23.15.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:10:45 -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 v5 02/14] dmaengine: tegra-apb: Implement synchronization hook Date: Fri, 24 Jan 2020 02:03:13 +0300 Message-Id: <20200123230325.3037-3-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-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 hook which blocks until tasklet is finished. Acked-by: Jon Hunter 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 Thu Jan 23 23:03:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349299 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 B1CDE921 for ; Thu, 23 Jan 2020 23:11:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8C70F2071E for ; Thu, 23 Jan 2020 23:11:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PqNT+1dz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730097AbgAWXLj (ORCPT ); Thu, 23 Jan 2020 18:11:39 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53253 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729789AbgAWXKt (ORCPT ); Thu, 23 Jan 2020 18:10:49 -0500 Received: by mail-wm1-f66.google.com with SMTP id m24so4370914wmc.3; Thu, 23 Jan 2020 15:10:48 -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=nxiPwqrpg97YIQpnnmiKVkwXa7j5aarnOTijl3cNiEE=; b=PqNT+1dztXD8+0QAtDUL3L2CcSTzrFIonPzJAPJvVHjiP97fqctFWwWlBF5VxzrUBV lMrHegpRFSPPRB0reJ2XSLh3QOBBk824fPucbkM/KzAsKft12Gv6IWCRzVbE64Zkg3ar 8KpkR8OFdvavyqfS7sdbFTWoATY5cVJtsUvYJttN+KLLQMwAQjTbRix8XttkCX3KKefJ G0U5Blwhmr1azKY7LJeWEl4cr9XST641oRDgnHuxvkek1gNTS9gxYjQ+z/uwp8DVwd+G e5LUZhomSW140fla9BAmsWWnTCjF6qCHpzt0m74Z/q4SDCyqIfuRBT4vKcjwVS47beWx yvvg== 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=nxiPwqrpg97YIQpnnmiKVkwXa7j5aarnOTijl3cNiEE=; b=YI+k7tkY4BU4/0upvGcB+3NAM5yLVDWrQo+A9J6DqI0peSaUOMh6ha8oaocmTSB0jF unPfYWAkPkOjI6KvXxcrLLWjhgRCVoGT1YxvBtgTZz86Y1C1iXYpJw0G5lPmXJEbS63m 00Lx30f4PbDgY6jNfY5xH5r8ZaCx31n7EihQbwqnCURYda13JMvhIfjwLgd83p/FwHEk 1bIsnEDjNuRayZatT/mPL75VdagRn+d3p/8JfZyy8+5riyqteMjwH+CKuXce85VEvFow kZs/lgPEyONcVfdG5/B3mZ0XPhgcEKw81ESNgpzJL8ah/gw63nNEn1YL+osN1jI5la1w IFBg== X-Gm-Message-State: APjAAAVKvm5nLesLR4O8kGI8xtLYym91rwsQTh9Lm4Y9J7wXVObDmEas wZZeWpKoFDYUoWnBFYiFWTg= X-Google-Smtp-Source: APXvYqxYe2ONJh2cqACIU9hiNIHGZ12ItUDr/D3dtWsqTbEsjOvl9SVtermYtiNkIz/t/+dIcJM/ug== X-Received: by 2002:a05:600c:2c53:: with SMTP id r19mr248958wmg.39.1579821047357; Thu, 23 Jan 2020 15:10:47 -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 z6sm5105552wrw.36.2020.01.23.15.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:10:46 -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 v5 03/14] dmaengine: tegra-apb: Prevent race conditions on channel's freeing Date: Fri, 24 Jan 2020 02:03:14 +0300 Message-Id: <20200123230325.3037-4-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-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. Acked-by: Jon Hunter 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 Thu Jan 23 23:03:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349301 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 69B906C1 for ; Thu, 23 Jan 2020 23:11:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 440AB2071E for ; Thu, 23 Jan 2020 23:11:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LbJIua8H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729546AbgAWXLi (ORCPT ); Thu, 23 Jan 2020 18:11:38 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39696 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729505AbgAWXKu (ORCPT ); Thu, 23 Jan 2020 18:10:50 -0500 Received: by mail-wr1-f68.google.com with SMTP id y11so5192389wrt.6; Thu, 23 Jan 2020 15:10:49 -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=/HLc3OL0GnoXw5khnAyT/yqV6VIfAbT2GF3DMXd7ekc=; b=LbJIua8Hoj7e5c421cMcRUIu6N1XxSqg3W0eBhUJWwdVJzKbK9mT9jPoEU+olaMEBK DztywQFA/QMuxmVzzcpKhIFEiJZIR8CUIzCxCKfcWG/JuPNIrN68zrbMF5vj+NNK3dN/ Lm3G9nCyFpa8DjKHOlh7b53NAe+i8lCcMOwSS7eGY45mR4ltY207Yw6XBVPbs72Mbw2x Ft1OIrcqlVVCNzd5tivw6h8cVCDm2un0AmyveEX6/rwD4qZiaCUjjKNpt6Buao6uDJqr BrTncE2qnNI+BbXBu+Pt+463ow0wrldiSt3RWOocmskZpY49JxTrf6tXBe5LJioWpeZs 7BrQ== 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=/HLc3OL0GnoXw5khnAyT/yqV6VIfAbT2GF3DMXd7ekc=; b=A2b6+3oCksaPGM1yWYvDst+i/OpPwLDeTOJdcV4Ds6CsK62GNf1zIw/5il8CdMnJDx U63rKFKML0zLuicf62XnoEhpY4vsxYFzX1GQgL23BL6ZXbPemymmatUfmXsQfzIMR36w zOwg0dnQWRFZUnPy7VzQmpzis/99WXl3nWINEkEm0aTaTskCqQOqqCB4B/IewogoNnG1 VmRM6wOHyMUQDuyy2w+rozwHH0xEQA6X7txdKmzFs9ZSpO8Cn0QiPw6GVR6Y3srNhqaH /2tehA3j3glcoIeQ0qG+bcl+4TtcihtcEM2FiF6JwuawLV5N0fBfTr5AElDU9NWqmyc3 mqhQ== X-Gm-Message-State: APjAAAWhPzLTiFVxmJfdBmtrsrMaqV0bkzHBc6PlMDjqnep74QKBVTLV 4QFNX7gEgDIc9nAi5VgXwrk= X-Google-Smtp-Source: APXvYqz78pbsO+RPBMG3UVZ7svyekL0Y06mKjTdJPrPCcIHHUb/q/RwG5Z8ZI7tGlrJyJtmexykunA== X-Received: by 2002:adf:90e7:: with SMTP id i94mr425567wri.47.1579821048615; Thu, 23 Jan 2020 15:10:48 -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 z6sm5105552wrw.36.2020.01.23.15.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:10:48 -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 v5 04/14] dmaengine: tegra-apb: Clean up tasklet releasing Date: Fri, 24 Jan 2020 02:03:15 +0300 Message-Id: <20200123230325.3037-5-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-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. Acked-by: Jon Hunter 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 Thu Jan 23 23:03:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349295 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 CABF16C1 for ; Thu, 23 Jan 2020 23:11:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A552A20684 for ; Thu, 23 Jan 2020 23:11:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QU22ArdA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729836AbgAWXKw (ORCPT ); Thu, 23 Jan 2020 18:10:52 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:40796 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729678AbgAWXKv (ORCPT ); Thu, 23 Jan 2020 18:10:51 -0500 Received: by mail-wr1-f67.google.com with SMTP id c14so5188798wrn.7; Thu, 23 Jan 2020 15:10:50 -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=TN3Aq9biuh1Hk4JoQDeAp7VLhhgR3QH0ii3GwHrM2/8=; b=QU22ArdAc0hImwOzo1G/Bn3Q0m0bAPw5X2TMexZ/jmO2FoLfDcc8lQiGQuAT6Fwigc zAbnTx3z+SGU3rHzNbikqe/XSj/YSA6+hOMtu1/2yfod3tUHWtyW2HZsKtI4iwa6uW3F C2IMEshfTh6BGAlAQ41pmNMcMP/WSKSzB1V25uyMDEdwG6ha3laIF2d3fQ7IkOYSssMg yGCvPYzpdkJzpE/ISk00GNPxzajh4JmeKtdgv0l8zSWnCb9d7rHYw0uRZpU3+8pSrHwx ZR59g/ftC6ho9o4rS6D/R1AcXHpegzae6J/sQu4s8z51ItzitSapXbRw6AzsJGqo4psM Jevw== 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=TN3Aq9biuh1Hk4JoQDeAp7VLhhgR3QH0ii3GwHrM2/8=; b=jzHg6DVPOc5UFpm2DTF9BduayWWoCiiTgZ+ag4ke4wDeLTi/uimQiZwoTn7/r+myJu v6ojOS7Vum0y+NzI+z9jLSUbf2CnaHx7KWdBSSnYhugt384zUgyiT5K+UrbhhGmQtm7z irxGeZ7jACkwo14lh6sfT217ntxIMX/zMsBclOv/PLNUsM9SccaCaqDiSr9Jb+wPom0h obrVyS1E6YafcUxs9g3Ifhc/yDqNXew3AGFy/tzSWU1rQBRH+z1Zsi68aRkka2EjjCCY s9abjrgEF6+95L+H+h9NAsdjpI0DNk2tu6tVSjJISJg3Z27yO3jpPDYcxcEPeqya459k kzZA== X-Gm-Message-State: APjAAAW2Xyixjm1+8YOsuSyskWIcfcboVs6YeLzZvgkdsTZ8Iwtu7uKU dX1lxWj96k/7DMPZXAq+3eM= X-Google-Smtp-Source: APXvYqyXcG0WQl47qaYlaDh2lIxzeONymSjOWQbc5/AiaZVx++ziEgD9efjytX2rB0mpSgX/NigpmA== X-Received: by 2002:adf:eb51:: with SMTP id u17mr479368wrn.29.1579821049856; Thu, 23 Jan 2020 15:10:49 -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 z6sm5105552wrw.36.2020.01.23.15.10.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:10:49 -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 v5 05/14] dmaengine: tegra-apb: Prevent race conditions of tasklet vs free list Date: Fri, 24 Jan 2020 02:03:16 +0300 Message-Id: <20200123230325.3037-6-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-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. Acked-by: Jon Hunter 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 Thu Jan 23 23:03:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349277 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 537336C1 for ; Thu, 23 Jan 2020 23:10:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2DD3021835 for ; Thu, 23 Jan 2020 23:10:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UCi4fZRL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729851AbgAWXKy (ORCPT ); Thu, 23 Jan 2020 18:10:54 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:38751 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729832AbgAWXKx (ORCPT ); Thu, 23 Jan 2020 18:10:53 -0500 Received: by mail-wm1-f67.google.com with SMTP id u2so4378355wmc.3; Thu, 23 Jan 2020 15:10:51 -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=yfyyd1gAYNfQRVTzzie9M6MUShefAhN4x9LLDsJ6WIA=; b=UCi4fZRLcbqile5G4o/rFtRlD8ClrFQ8PF4vqF7UxQX9U7vjLamt7iOy+t3F+s++K5 HliSdFTLSKE5FlvCaUVZqlWmbmWwEqWesJ1yl/u0AZYECSRZ0z5axMpJgqMBJDFePahb wXviyyVM52EQ3Q3vR6JJfoQOITws5hhTdY6WBk/sQjBeWYgPdnZw1umMKzhgrhNP1oID TWJkw5mTnx9p+VEl3Msxcfsk2Wr5AxNPECvDRJnlfkAobiSED8B/voDu/JB0Ws2IiWUa GTx/2n7R480e0djF2YlniHS4EIhSwS971PWP583sPLCYoGUxdjGy1eF4k3/T9vMNMi9D rK1A== 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=yfyyd1gAYNfQRVTzzie9M6MUShefAhN4x9LLDsJ6WIA=; b=mGbH2O6qUNnsDDXK34dGIvL5jeqTsCFxCSvZC0F/FaJE35YAZ8CnpwoA40TXs4J8og EPrwPtrDDzbEQZFlc59FmHUTSeTqw/n+SkAEWNCNZsb/J3bI74RSJbkFZfkjHu9rbeA2 cYNcateMpSdIvTLw80mIC9lGwS43gLV4Fosu+wfTgMAF9SkP535YfI3RJnsRfQ84w3n1 S45yeJ3ILhWoKyXfvhkDfSrWh4r0YRXx0pH8AlSWiojmIcYL1xZnlRjlN/0KIVKBBvVp kisL8R7F+dt0ZgepUPCuYjJCFCzDltby+pKFPZpVEOjxb6nvPmtqWgJdB3YcabXRU+Bg nN0A== X-Gm-Message-State: APjAAAU8vedMdJyM83URDqWvSdKKVwLAdXOduz858f4yCte+8whRsVdJ DIdbDXTB5oZRIGIvOuHjGBk= X-Google-Smtp-Source: APXvYqxzc6H8NU+QZbJENgrjXzzQpow3NCyqdR7u5em2HGyrsj7YC4vee4S2r3ywh6b23zkqmOV20g== X-Received: by 2002:a05:600c:228f:: with SMTP id 15mr296725wmf.56.1579821051168; Thu, 23 Jan 2020 15:10:51 -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 z6sm5105552wrw.36.2020.01.23.15.10.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:10:50 -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 v5 06/14] dmaengine: tegra-apb: Use devm_platform_ioremap_resource Date: Fri, 24 Jan 2020 02:03:17 +0300 Message-Id: <20200123230325.3037-7-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-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. Acked-by: Jon Hunter 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 Thu Jan 23 23:03:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349279 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 C33F1921 for ; Thu, 23 Jan 2020 23:10:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D98821835 for ; Thu, 23 Jan 2020 23:10:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RFLKSghk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729678AbgAWXKz (ORCPT ); Thu, 23 Jan 2020 18:10:55 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42653 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729837AbgAWXKy (ORCPT ); Thu, 23 Jan 2020 18:10:54 -0500 Received: by mail-wr1-f68.google.com with SMTP id q6so5168318wro.9; Thu, 23 Jan 2020 15:10:52 -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=iIeXeqWybCn0khYUW1LlWp0vQo+B3g3sVK/buP+mLKA=; b=RFLKSghkKtdswaFGhkjA2H4LA8sgEW7Ckiev/iNbFObVyq7m9U73J6mO7ViFfwhnTq YyWNZuMw4Or29F2Z4b9SDYF4oBlbIj31hp4ECwE2tYqtflVWwwVDhYQ5cz/pYXQ7CupG BnA4yY2qrZsAd/qqIa8XPpvkQ5tL3tCdeNtoga/ohYXbkaYiDwf/HsRsIz63kKH1Gcrv Lo+PNT9BCcqeCVWOW0Xs55It3iRU7NMeFMM2y6loxq/ibAlbhVOqiLFH4J6VsQz1tXH0 JCmVOmzMfK+5GJSEmIJ2nm//hG6XAdgQke4eoq7DSUX8jnd7plVRYQEP/EbAOzq9pvl+ lkow== 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=iIeXeqWybCn0khYUW1LlWp0vQo+B3g3sVK/buP+mLKA=; b=PQ3an4jOteCZKFpqLHClU/VbRakFKYaqL7vo04jamS4bqsykN4FA+bH/VV9cLJnBdQ E1MTGOFzc5tuygV+9/xsjleGGuyaR5Fc3UVzc5pAUzkeEPWm8qjY2fEL7eLY0usYBami Mni1kLzsbDnF9UQ/KQ5uKOF4wOIRtiRFAbWtMdpT0Tl1WOxTNMfgzm4U2QtFJz/HX1Fv qOswYybANEjP0c3NyPTpc3JgxA90ZcfaQSlgjDBNV2PyuHaPXehHVQwHDRGmknWN4AHF YeNdzsg1QaXUyft/igthlZkF26ue2JZGl8mHlytRx6EOKwP2FDzRwXpIN6m/Qk626xbL hHMg== X-Gm-Message-State: APjAAAXv1zecJi/Z5sONpb/NF/hKne/4p5DjDT19WuEl1VqrsDpH1hCM 1ua2XMyb2gLocAtmT5UnFPYBeQ/S X-Google-Smtp-Source: APXvYqzQM9BRYlIR8ZyGAuAhCaVc7Gc6aQQznEXhWRurnHxF9+87PSuC+6K+2D09AyYrrAsGEOhkRA== X-Received: by 2002:a5d:558d:: with SMTP id i13mr452664wrv.364.1579821052375; Thu, 23 Jan 2020 15:10:52 -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 z6sm5105552wrw.36.2020.01.23.15.10.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:10:52 -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 v5 07/14] dmaengine: tegra-apb: Use devm_request_irq Date: Fri, 24 Jan 2020 02:03:18 +0300 Message-Id: <20200123230325.3037-8-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-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. Acked-by: Jon Hunter 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 Thu Jan 23 23:03:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349293 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 520E7921 for ; Thu, 23 Jan 2020 23:11:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F112C21835 for ; Thu, 23 Jan 2020 23:11:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L9bEgBMj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729863AbgAWXL0 (ORCPT ); Thu, 23 Jan 2020 18:11:26 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:50440 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729856AbgAWXK5 (ORCPT ); Thu, 23 Jan 2020 18:10:57 -0500 Received: by mail-wm1-f67.google.com with SMTP id a5so4383913wmb.0; Thu, 23 Jan 2020 15:10:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yUd6lpyTU/7Nm+cwLJMDV54bolqX/wMqfpfAeQdOYdQ=; b=L9bEgBMj598tCf55MJ/PoD7jJDy/P6S6H8W57irEOGNat86JhLQ96p08GPr6rOVrij G78b9thZr2/7sBGtKO6RsYUwPW5aJmtKMvnS5xb81oycX9ZuChbBe8EEtb3mqGm7Xjuy +9mDBGlsZENQjwvq0RLBPDOthuU1Rs5VGXdj2capQ58IUweQcEE12KtJL47L/A2Jl2QL 4EpkwQ/SZfMO4DnoFFbRVABMr0lN2/FZPGvh3Ri3AqCAVLmT4htXERTGCciQLBmVT2vo Lk1IBs/ifl3t2kl9qC/fN/fDDpXZrLOwe4hwDg/qLZ5Pm5pKGZP8xneOZF10vHwTeZkZ O4mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yUd6lpyTU/7Nm+cwLJMDV54bolqX/wMqfpfAeQdOYdQ=; b=KIy1chedXygTxfxVeucUCudujJzrzMB2+XkkbP83UFkIZf4cakiTiUr3Sw90/Er1es A+z+ZEWY63noyl465HbzG5ZzCLMx/UJgYDwZejQR+dS2LLqHmvkl4L3nF+qBwR4Cblz2 Lma4iUOXgBe6xbx2Fri0ilr2TSnFo+k36l6Hi3EWxJ9O4FzExhMhPJZtg7WIeM2nGl7P PLTUFstgsdvMLrkAxufECtN1ZIXn2WdhC/G5JNj1ZIusKr6gGzxe1P4VVZqL6mEl0fml za9jqe+qAbhA+lBdGJhUxwADssF+dnXIkEqedgEcijdJluXhklpa4iJ4SJ37FPB2wQm1 eZUA== X-Gm-Message-State: APjAAAVucj64kYmDoj4GaKFptMvs0Lc9mlYHYaiavku2rjCUpYZfFU7q oTlCSkyfgurQ6lBqpGQLudQ= X-Google-Smtp-Source: APXvYqwU8nFXG6uunw9dLYkGZLJt5Zg3saWPtYIUfKf3pogvpiyVO1S7I7TCd1YlVKmQXw4INlv24Q== X-Received: by 2002:a1c:b789:: with SMTP id h131mr267096wmf.148.1579821053752; Thu, 23 Jan 2020 15:10:53 -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 z6sm5105552wrw.36.2020.01.23.15.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:10:53 -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 v5 08/14] dmaengine: tegra-apb: Fix coding style problems Date: Fri, 24 Jan 2020 02:03:19 +0300 Message-Id: <20200123230325.3037-9-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org This patch fixes few dozens of coding style problems reported by checkpatch and prettifies code where makes sense. Signed-off-by: Dmitry Osipenko --- drivers/dma/tegra20-apb-dma.c | 276 ++++++++++++++++++---------------- 1 file changed, 144 insertions(+), 132 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index dff21e80ffa4..7158bd3145c4 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -59,7 +59,7 @@ #define TEGRA_APBDMA_STATUS_COUNT_MASK 0xFFFC #define TEGRA_APBDMA_CHAN_CSRE 0x00C -#define TEGRA_APBDMA_CHAN_CSRE_PAUSE (1 << 31) +#define TEGRA_APBDMA_CHAN_CSRE_PAUSE BIT(31) /* AHB memory address */ #define TEGRA_APBDMA_CHAN_AHBPTR 0x010 @@ -120,21 +120,21 @@ struct tegra_dma; * @support_separate_wcount_reg: Support separate word count register. */ struct tegra_dma_chip_data { - int nr_channels; - int channel_reg_size; - int max_dma_count; + unsigned int nr_channels; + unsigned int channel_reg_size; + unsigned int max_dma_count; bool support_channel_pause; bool support_separate_wcount_reg; }; /* DMA channel registers */ struct tegra_dma_channel_regs { - unsigned long csr; - unsigned long ahb_ptr; - unsigned long apb_ptr; - unsigned long ahb_seq; - unsigned long apb_seq; - unsigned long wcount; + u32 csr; + u32 ahb_ptr; + u32 apb_ptr; + u32 ahb_seq; + u32 apb_seq; + u32 wcount; }; /* @@ -168,7 +168,7 @@ struct tegra_dma_desc { struct list_head node; struct list_head tx_list; struct list_head cb_node; - int cb_count; + unsigned int cb_count; }; struct tegra_dma_channel; @@ -181,7 +181,7 @@ struct tegra_dma_channel { struct dma_chan dma_chan; char name[12]; bool config_init; - int id; + unsigned int id; void __iomem *chan_addr; spinlock_t lock; bool busy; @@ -201,7 +201,7 @@ struct tegra_dma_channel { /* Channel-slave specific configuration */ unsigned int slave_id; struct dma_slave_config dma_sconfig; - struct tegra_dma_channel_regs channel_reg; + struct tegra_dma_channel_regs channel_reg; }; /* tegra_dma: Tegra DMA specific information */ @@ -239,7 +239,7 @@ static inline u32 tdma_read(struct tegra_dma *tdma, u32 reg) } static inline void tdc_write(struct tegra_dma_channel *tdc, - u32 reg, u32 val) + u32 reg, u32 val) { writel(val, tdc->chan_addr + reg); } @@ -254,8 +254,8 @@ static inline struct tegra_dma_channel *to_tegra_dma_chan(struct dma_chan *dc) return container_of(dc, struct tegra_dma_channel, dma_chan); } -static inline struct tegra_dma_desc *txd_to_tegra_dma_desc( - struct dma_async_tx_descriptor *td) +static inline struct tegra_dma_desc * +txd_to_tegra_dma_desc(struct dma_async_tx_descriptor *td) { return container_of(td, struct tegra_dma_desc, txd); } @@ -270,8 +270,7 @@ static int tegra_dma_runtime_suspend(struct device *dev); static int tegra_dma_runtime_resume(struct device *dev); /* Get DMA desc from free list, if not there then allocate it. */ -static struct tegra_dma_desc *tegra_dma_desc_get( - struct tegra_dma_channel *tdc) +static struct tegra_dma_desc *tegra_dma_desc_get(struct tegra_dma_channel *tdc) { struct tegra_dma_desc *dma_desc; unsigned long flags; @@ -298,11 +297,12 @@ static struct tegra_dma_desc *tegra_dma_desc_get( dma_async_tx_descriptor_init(&dma_desc->txd, &tdc->dma_chan); dma_desc->txd.tx_submit = tegra_dma_tx_submit; dma_desc->txd.flags = 0; + return dma_desc; } static void tegra_dma_desc_put(struct tegra_dma_channel *tdc, - struct tegra_dma_desc *dma_desc) + struct tegra_dma_desc *dma_desc) { unsigned long flags; @@ -313,29 +313,29 @@ static void tegra_dma_desc_put(struct tegra_dma_channel *tdc, spin_unlock_irqrestore(&tdc->lock, flags); } -static struct tegra_dma_sg_req *tegra_dma_sg_req_get( - struct tegra_dma_channel *tdc) +static struct tegra_dma_sg_req * +tegra_dma_sg_req_get(struct tegra_dma_channel *tdc) { - struct tegra_dma_sg_req *sg_req = NULL; + struct tegra_dma_sg_req *sg_req; unsigned long flags; spin_lock_irqsave(&tdc->lock, flags); if (!list_empty(&tdc->free_sg_req)) { - sg_req = list_first_entry(&tdc->free_sg_req, - typeof(*sg_req), node); + sg_req = list_first_entry(&tdc->free_sg_req, typeof(*sg_req), + node); list_del(&sg_req->node); spin_unlock_irqrestore(&tdc->lock, flags); return sg_req; } spin_unlock_irqrestore(&tdc->lock, flags); - sg_req = kzalloc(sizeof(struct tegra_dma_sg_req), GFP_NOWAIT); + sg_req = kzalloc(sizeof(*sg_req), GFP_NOWAIT); return sg_req; } static int tegra_dma_slave_config(struct dma_chan *dc, - struct dma_slave_config *sconfig) + struct dma_slave_config *sconfig) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); @@ -352,11 +352,12 @@ static int tegra_dma_slave_config(struct dma_chan *dc, tdc->slave_id = sconfig->slave_id; } tdc->config_init = true; + return 0; } static void tegra_dma_global_pause(struct tegra_dma_channel *tdc, - bool wait_for_burst_complete) + bool wait_for_burst_complete) { struct tegra_dma *tdma = tdc->tdma; @@ -391,13 +392,13 @@ static void tegra_dma_global_resume(struct tegra_dma_channel *tdc) } static void tegra_dma_pause(struct tegra_dma_channel *tdc, - bool wait_for_burst_complete) + bool wait_for_burst_complete) { struct tegra_dma *tdma = tdc->tdma; if (tdma->chip_data->support_channel_pause) { tdc_write(tdc, TEGRA_APBDMA_CHAN_CSRE, - TEGRA_APBDMA_CHAN_CSRE_PAUSE); + TEGRA_APBDMA_CHAN_CSRE_PAUSE); if (wait_for_burst_complete) udelay(TEGRA_APBDMA_BURST_COMPLETE_TIME); } else { @@ -409,17 +410,15 @@ static void tegra_dma_resume(struct tegra_dma_channel *tdc) { struct tegra_dma *tdma = tdc->tdma; - if (tdma->chip_data->support_channel_pause) { + if (tdma->chip_data->support_channel_pause) tdc_write(tdc, TEGRA_APBDMA_CHAN_CSRE, 0); - } else { + else tegra_dma_global_resume(tdc); - } } static void tegra_dma_stop(struct tegra_dma_channel *tdc) { - u32 csr; - u32 status; + u32 csr, status; /* Disable interrupts */ csr = tdc_read(tdc, TEGRA_APBDMA_CHAN_CSR); @@ -440,7 +439,7 @@ static void tegra_dma_stop(struct tegra_dma_channel *tdc) } static void tegra_dma_start(struct tegra_dma_channel *tdc, - struct tegra_dma_sg_req *sg_req) + struct tegra_dma_sg_req *sg_req) { struct tegra_dma_channel_regs *ch_regs = &sg_req->ch_regs; @@ -454,11 +453,11 @@ static void tegra_dma_start(struct tegra_dma_channel *tdc, /* Start DMA */ tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR, - ch_regs->csr | TEGRA_APBDMA_CSR_ENB); + ch_regs->csr | TEGRA_APBDMA_CSR_ENB); } static void tegra_dma_configure_for_next(struct tegra_dma_channel *tdc, - struct tegra_dma_sg_req *nsg_req) + struct tegra_dma_sg_req *nsg_req) { unsigned long status; @@ -492,9 +491,9 @@ static void tegra_dma_configure_for_next(struct tegra_dma_channel *tdc, tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBPTR, nsg_req->ch_regs.ahb_ptr); if (tdc->tdma->chip_data->support_separate_wcount_reg) tdc_write(tdc, TEGRA_APBDMA_CHAN_WCOUNT, - nsg_req->ch_regs.wcount); + nsg_req->ch_regs.wcount); tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR, - nsg_req->ch_regs.csr | TEGRA_APBDMA_CSR_ENB); + nsg_req->ch_regs.csr | TEGRA_APBDMA_CSR_ENB); nsg_req->configured = true; nsg_req->words_xferred = 0; @@ -508,8 +507,7 @@ static void tdc_start_head_req(struct tegra_dma_channel *tdc) if (list_empty(&tdc->pending_sg_req)) return; - sg_req = list_first_entry(&tdc->pending_sg_req, - typeof(*sg_req), node); + sg_req = list_first_entry(&tdc->pending_sg_req, typeof(*sg_req), node); tegra_dma_start(tdc, sg_req); sg_req->configured = true; sg_req->words_xferred = 0; @@ -518,34 +516,35 @@ static void tdc_start_head_req(struct tegra_dma_channel *tdc) static void tdc_configure_next_head_desc(struct tegra_dma_channel *tdc) { - struct tegra_dma_sg_req *hsgreq; - struct tegra_dma_sg_req *hnsgreq; + struct tegra_dma_sg_req *hsgreq, *hnsgreq; if (list_empty(&tdc->pending_sg_req)) return; hsgreq = list_first_entry(&tdc->pending_sg_req, typeof(*hsgreq), node); if (!list_is_last(&hsgreq->node, &tdc->pending_sg_req)) { - hnsgreq = list_first_entry(&hsgreq->node, - typeof(*hnsgreq), node); + hnsgreq = list_first_entry(&hsgreq->node, typeof(*hnsgreq), + node); tegra_dma_configure_for_next(tdc, hnsgreq); } } -static inline int get_current_xferred_count(struct tegra_dma_channel *tdc, - struct tegra_dma_sg_req *sg_req, unsigned long status) +static inline unsigned int +get_current_xferred_count(struct tegra_dma_channel *tdc, + struct tegra_dma_sg_req *sg_req, + unsigned long status) { return sg_req->req_len - (status & TEGRA_APBDMA_STATUS_COUNT_MASK) - 4; } static void tegra_dma_abort_all(struct tegra_dma_channel *tdc) { - struct tegra_dma_sg_req *sgreq; struct tegra_dma_desc *dma_desc; + struct tegra_dma_sg_req *sgreq; while (!list_empty(&tdc->pending_sg_req)) { - sgreq = list_first_entry(&tdc->pending_sg_req, - typeof(*sgreq), node); + sgreq = list_first_entry(&tdc->pending_sg_req, typeof(*sgreq), + node); list_move_tail(&sgreq->node, &tdc->free_sg_req); if (sgreq->last_sg) { dma_desc = sgreq->dma_desc; @@ -555,7 +554,7 @@ static void tegra_dma_abort_all(struct tegra_dma_channel *tdc) /* Add in cb list if it is not there. */ if (!dma_desc->cb_count) list_add_tail(&dma_desc->cb_node, - &tdc->cb_desc); + &tdc->cb_desc); dma_desc->cb_count++; } } @@ -563,9 +562,10 @@ static void tegra_dma_abort_all(struct tegra_dma_channel *tdc) } static bool handle_continuous_head_request(struct tegra_dma_channel *tdc, - struct tegra_dma_sg_req *last_sg_req, bool to_terminate) + struct tegra_dma_sg_req *last_sg_req, + bool to_terminate) { - struct tegra_dma_sg_req *hsgreq = NULL; + struct tegra_dma_sg_req *hsgreq; if (list_empty(&tdc->pending_sg_req)) { dev_err(tdc2dev(tdc), "DMA is running without req\n"); @@ -589,14 +589,15 @@ static bool handle_continuous_head_request(struct tegra_dma_channel *tdc, /* Configure next request */ if (!to_terminate) tdc_configure_next_head_desc(tdc); + return true; } static void handle_once_dma_done(struct tegra_dma_channel *tdc, - bool to_terminate) + bool to_terminate) { - struct tegra_dma_sg_req *sgreq; struct tegra_dma_desc *dma_desc; + struct tegra_dma_sg_req *sgreq; tdc->busy = false; sgreq = list_first_entry(&tdc->pending_sg_req, typeof(*sgreq), node); @@ -622,10 +623,10 @@ static void handle_once_dma_done(struct tegra_dma_channel *tdc, } static void handle_cont_sngl_cycle_dma_done(struct tegra_dma_channel *tdc, - bool to_terminate) + bool to_terminate) { - struct tegra_dma_sg_req *sgreq; struct tegra_dma_desc *dma_desc; + struct tegra_dma_sg_req *sgreq; bool st; sgreq = list_first_entry(&tdc->pending_sg_req, typeof(*sgreq), node); @@ -657,13 +658,13 @@ static void tegra_dma_tasklet(unsigned long data) struct tegra_dma_channel *tdc = (struct tegra_dma_channel *)data; struct dmaengine_desc_callback cb; struct tegra_dma_desc *dma_desc; + unsigned int cb_count; unsigned long flags; - int cb_count; spin_lock_irqsave(&tdc->lock, flags); while (!list_empty(&tdc->cb_desc)) { - dma_desc = list_first_entry(&tdc->cb_desc, - typeof(*dma_desc), cb_node); + dma_desc = list_first_entry(&tdc->cb_desc, typeof(*dma_desc), + cb_node); list_del(&dma_desc->cb_node); dmaengine_desc_get_callback(&dma_desc->txd, &cb); cb_count = dma_desc->cb_count; @@ -681,8 +682,8 @@ static void tegra_dma_tasklet(unsigned long data) static irqreturn_t tegra_dma_isr(int irq, void *dev_id) { struct tegra_dma_channel *tdc = dev_id; - unsigned long status; unsigned long flags; + u32 status; spin_lock_irqsave(&tdc->lock, flags); @@ -697,8 +698,9 @@ static irqreturn_t tegra_dma_isr(int irq, void *dev_id) } spin_unlock_irqrestore(&tdc->lock, flags); - dev_info(tdc2dev(tdc), - "Interrupt already served status 0x%08lx\n", status); + dev_info(tdc2dev(tdc), "Interrupt already served status 0x%08x\n", + status); + return IRQ_NONE; } @@ -714,6 +716,7 @@ static dma_cookie_t tegra_dma_tx_submit(struct dma_async_tx_descriptor *txd) cookie = dma_cookie_assign(&dma_desc->txd); list_splice_tail_init(&dma_desc->tx_list, &tdc->pending_sg_req); spin_unlock_irqrestore(&tdc->lock, flags); + return cookie; } @@ -747,11 +750,10 @@ static void tegra_dma_issue_pending(struct dma_chan *dc) static int tegra_dma_terminate_all(struct dma_chan *dc) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); - struct tegra_dma_sg_req *sgreq; struct tegra_dma_desc *dma_desc; + struct tegra_dma_sg_req *sgreq; unsigned long flags; - unsigned long status; - unsigned long wcount; + u32 status, wcount; bool was_busy; spin_lock_irqsave(&tdc->lock, flags); @@ -777,8 +779,8 @@ static int tegra_dma_terminate_all(struct dma_chan *dc) tegra_dma_stop(tdc); if (!list_empty(&tdc->pending_sg_req) && was_busy) { - sgreq = list_first_entry(&tdc->pending_sg_req, - typeof(*sgreq), node); + sgreq = list_first_entry(&tdc->pending_sg_req, typeof(*sgreq), + node); sgreq->dma_desc->bytes_transferred += get_current_xferred_count(tdc, sgreq, wcount); } @@ -788,12 +790,13 @@ static int tegra_dma_terminate_all(struct dma_chan *dc) tegra_dma_abort_all(tdc); while (!list_empty(&tdc->cb_desc)) { - dma_desc = list_first_entry(&tdc->cb_desc, - typeof(*dma_desc), cb_node); + dma_desc = list_first_entry(&tdc->cb_desc, typeof(*dma_desc), + cb_node); list_del(&dma_desc->cb_node); dma_desc->cb_count = 0; } spin_unlock_irqrestore(&tdc->lock, flags); + return 0; } @@ -807,7 +810,7 @@ static void tegra_dma_synchronize(struct dma_chan *dc) static unsigned int tegra_dma_sg_bytes_xferred(struct tegra_dma_channel *tdc, struct tegra_dma_sg_req *sg_req) { - unsigned long status, wcount = 0; + u32 status, wcount = 0; if (!list_is_first(&sg_req->node, &tdc->pending_sg_req)) return 0; @@ -864,7 +867,8 @@ static unsigned int tegra_dma_sg_bytes_xferred(struct tegra_dma_channel *tdc, } static enum dma_status tegra_dma_tx_status(struct dma_chan *dc, - dma_cookie_t cookie, struct dma_tx_state *txstate) + dma_cookie_t cookie, + struct dma_tx_state *txstate) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); struct tegra_dma_desc *dma_desc; @@ -911,11 +915,12 @@ static enum dma_status tegra_dma_tx_status(struct dma_chan *dc, trace_tegra_dma_tx_status(&tdc->dma_chan, cookie, txstate); spin_unlock_irqrestore(&tdc->lock, flags); + return ret; } -static inline int get_bus_width(struct tegra_dma_channel *tdc, - enum dma_slave_buswidth slave_bw) +static inline unsigned int get_bus_width(struct tegra_dma_channel *tdc, + enum dma_slave_buswidth slave_bw) { switch (slave_bw) { case DMA_SLAVE_BUSWIDTH_1_BYTE: @@ -928,16 +933,17 @@ static inline int get_bus_width(struct tegra_dma_channel *tdc, return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_64; default: dev_warn(tdc2dev(tdc), - "slave bw is not supported, using 32bits\n"); + "slave bw is not supported, using 32bits\n"); return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_32; } } -static inline int get_burst_size(struct tegra_dma_channel *tdc, - u32 burst_size, enum dma_slave_buswidth slave_bw, int len) +static inline unsigned int get_burst_size(struct tegra_dma_channel *tdc, + u32 burst_size, + enum dma_slave_buswidth slave_bw, + u32 len) { - int burst_byte; - int burst_ahb_width; + unsigned int burst_byte, burst_ahb_width; /* * burst_size from client is in terms of the bus_width. @@ -964,9 +970,12 @@ static inline int get_burst_size(struct tegra_dma_channel *tdc, } static int get_transfer_param(struct tegra_dma_channel *tdc, - enum dma_transfer_direction direction, unsigned long *apb_addr, - unsigned long *apb_seq, unsigned long *csr, unsigned int *burst_size, - enum dma_slave_buswidth *slave_bw) + enum dma_transfer_direction direction, + u32 *apb_addr, + u32 *apb_seq, + u32 *csr, + unsigned int *burst_size, + enum dma_slave_buswidth *slave_bw) { switch (direction) { case DMA_MEM_TO_DEV: @@ -987,13 +996,15 @@ static int get_transfer_param(struct tegra_dma_channel *tdc, default: dev_err(tdc2dev(tdc), "DMA direction is not supported\n"); - return -EINVAL; + break; } + return -EINVAL; } static void tegra_dma_prep_wcount(struct tegra_dma_channel *tdc, - struct tegra_dma_channel_regs *ch_regs, u32 len) + struct tegra_dma_channel_regs *ch_regs, + u32 len) { u32 len_field = (len - 4) & 0xFFFC; @@ -1003,20 +1014,23 @@ static void tegra_dma_prep_wcount(struct tegra_dma_channel *tdc, ch_regs->csr |= len_field; } -static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg( - struct dma_chan *dc, struct scatterlist *sgl, unsigned int sg_len, - enum dma_transfer_direction direction, unsigned long flags, - void *context) +static struct dma_async_tx_descriptor * +tegra_dma_prep_slave_sg(struct dma_chan *dc, + struct scatterlist *sgl, + unsigned int sg_len, + enum dma_transfer_direction direction, + unsigned long flags, + void *context) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + struct tegra_dma_sg_req *sg_req = NULL; + u32 csr, ahb_seq, apb_ptr, apb_seq; + enum dma_slave_buswidth slave_bw; struct tegra_dma_desc *dma_desc; - unsigned int i; - struct scatterlist *sg; - unsigned long csr, ahb_seq, apb_ptr, apb_seq; struct list_head req_list; - struct tegra_dma_sg_req *sg_req = NULL; - u32 burst_size; - enum dma_slave_buswidth slave_bw; + struct scatterlist *sg; + unsigned int burst_size; + unsigned int i; if (!tdc->config_init) { dev_err(tdc2dev(tdc), "DMA channel is not configured\n"); @@ -1028,7 +1042,7 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg( } if (get_transfer_param(tdc, direction, &apb_ptr, &apb_seq, &csr, - &burst_size, &slave_bw) < 0) + &burst_size, &slave_bw) < 0) return NULL; INIT_LIST_HEAD(&req_list); @@ -1074,7 +1088,7 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg( len = sg_dma_len(sg); if ((len & 3) || (mem & 3) || - (len > tdc->tdma->chip_data->max_dma_count)) { + len > tdc->tdma->chip_data->max_dma_count) { dev_err(tdc2dev(tdc), "DMA length/memory address is not supported\n"); tegra_dma_desc_put(tdc, dma_desc); @@ -1126,20 +1140,21 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg( return &dma_desc->txd; } -static struct dma_async_tx_descriptor *tegra_dma_prep_dma_cyclic( - struct dma_chan *dc, dma_addr_t buf_addr, size_t buf_len, - size_t period_len, enum dma_transfer_direction direction, - unsigned long flags) +static struct dma_async_tx_descriptor * +tegra_dma_prep_dma_cyclic(struct dma_chan *dc, dma_addr_t buf_addr, + size_t buf_len, + size_t period_len, + enum dma_transfer_direction direction, + unsigned long flags) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); - struct tegra_dma_desc *dma_desc = NULL; struct tegra_dma_sg_req *sg_req = NULL; - unsigned long csr, ahb_seq, apb_ptr, apb_seq; - int len; - size_t remain_len; - dma_addr_t mem = buf_addr; - u32 burst_size; + u32 csr, ahb_seq, apb_ptr, apb_seq; enum dma_slave_buswidth slave_bw; + struct tegra_dma_desc *dma_desc; + dma_addr_t mem = buf_addr; + unsigned int burst_size; + size_t len, remain_len; if (!buf_len || !period_len) { dev_err(tdc2dev(tdc), "Invalid buffer/period len\n"); @@ -1173,13 +1188,13 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_dma_cyclic( len = period_len; if ((len & 3) || (buf_addr & 3) || - (len > tdc->tdma->chip_data->max_dma_count)) { + len > tdc->tdma->chip_data->max_dma_count) { dev_err(tdc2dev(tdc), "Req len/mem address is not correct\n"); return NULL; } if (get_transfer_param(tdc, direction, &apb_ptr, &apb_seq, &csr, - &burst_size, &slave_bw) < 0) + &burst_size, &slave_bw) < 0) return NULL; ahb_seq = TEGRA_APBDMA_AHBSEQ_INTR_ENB; @@ -1269,7 +1284,6 @@ static int tegra_dma_alloc_chan_resources(struct dma_chan *dc) int ret; dma_cookie_init(&tdc->dma_chan); - tdc->config_init = false; ret = pm_runtime_get_sync(tdma->dev); if (ret < 0) @@ -1303,8 +1317,8 @@ static void tegra_dma_free_chan_resources(struct dma_chan *dc) tdc->isr_handler = NULL; while (!list_empty(&dma_desc_list)) { - dma_desc = list_first_entry(&dma_desc_list, - typeof(*dma_desc), node); + dma_desc = list_first_entry(&dma_desc_list, typeof(*dma_desc), + node); list_del(&dma_desc->node); kfree(dma_desc); } @@ -1323,8 +1337,8 @@ static struct dma_chan *tegra_dma_of_xlate(struct of_phandle_args *dma_spec, struct of_dma *ofdma) { struct tegra_dma *tdma = ofdma->of_dma_data; - struct dma_chan *chan; struct tegra_dma_channel *tdc; + struct dma_chan *chan; if (dma_spec->args[0] > TEGRA_APBDMA_CSR_REQ_SEL_MASK) { dev_err(tdma->dev, "Invalid slave id: %d\n", dma_spec->args[0]); @@ -1379,20 +1393,16 @@ static const struct tegra_dma_chip_data tegra148_dma_chip_data = { static int tegra_dma_probe(struct platform_device *pdev) { + const struct tegra_dma_chip_data *cdata; struct tegra_dma *tdma; + unsigned int i; + size_t size; int ret; - int i; - const struct tegra_dma_chip_data *cdata; cdata = of_device_get_match_data(&pdev->dev); - if (!cdata) { - dev_err(&pdev->dev, "Error: No device match data found\n"); - return -ENODEV; - } + size = struct_size(tdma, channels, cdata->nr_channels); - tdma = devm_kzalloc(&pdev->dev, - struct_size(tdma, channels, cdata->nr_channels), - GFP_KERNEL); + tdma = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); if (!tdma) return -ENOMEM; @@ -1424,10 +1434,8 @@ static int tegra_dma_probe(struct platform_device *pdev) else ret = pm_runtime_get_sync(&pdev->dev); - if (ret < 0) { - pm_runtime_disable(&pdev->dev); - return ret; - } + if (ret < 0) + goto err_pm_disable; /* Reset DMA controller */ reset_control_assert(tdma->rst); @@ -1470,13 +1478,13 @@ static int tegra_dma_probe(struct platform_device *pdev) tdc->dma_chan.device = &tdma->dma_dev; dma_cookie_init(&tdc->dma_chan); list_add_tail(&tdc->dma_chan.device_node, - &tdma->dma_dev.channels); + &tdma->dma_dev.channels); tdc->tdma = tdma; tdc->id = i; tdc->slave_id = TEGRA_APBDMA_SLAVE_ID_INVALID; tasklet_init(&tdc->tasklet, tegra_dma_tasklet, - (unsigned long)tdc); + (unsigned long)tdc); spin_lock_init(&tdc->lock); INIT_LIST_HEAD(&tdc->pending_sg_req); @@ -1528,16 +1536,19 @@ static int tegra_dma_probe(struct platform_device *pdev) goto err_unregister_dma_dev; } - dev_info(&pdev->dev, "Tegra20 APB DMA driver register %d channels\n", - cdata->nr_channels); + dev_info(&pdev->dev, "Tegra20 APB DMA driver registered %u channels\n", + cdata->nr_channels); + return 0; err_unregister_dma_dev: dma_async_device_unregister(&tdma->dma_dev); + err_pm_disable: pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) tegra_dma_runtime_suspend(&pdev->dev); + return ret; } @@ -1557,7 +1568,7 @@ static int tegra_dma_remove(struct platform_device *pdev) static int tegra_dma_runtime_suspend(struct device *dev) { struct tegra_dma *tdma = dev_get_drvdata(dev); - int i; + unsigned int i; tdma->reg_gen = tdma_read(tdma, TEGRA_APBDMA_GENERAL); for (i = 0; i < tdma->chip_data->nr_channels; i++) { @@ -1586,7 +1597,8 @@ static int tegra_dma_runtime_suspend(struct device *dev) static int tegra_dma_runtime_resume(struct device *dev) { struct tegra_dma *tdma = dev_get_drvdata(dev); - int i, ret; + unsigned int i; + int ret; ret = clk_prepare_enable(tdma->dma_clk); if (ret < 0) { @@ -1614,7 +1626,7 @@ static int tegra_dma_runtime_resume(struct device *dev) tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBSEQ, ch_reg->ahb_seq); tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBPTR, ch_reg->ahb_ptr); tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR, - (ch_reg->csr & ~TEGRA_APBDMA_CSR_ENB)); + ch_reg->csr & ~TEGRA_APBDMA_CSR_ENB); } return 0; From patchwork Thu Jan 23 23:03:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349291 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 650556C1 for ; Thu, 23 Jan 2020 23:11:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3EBCF2253D for ; Thu, 23 Jan 2020 23:11:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dQUU1GoL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729898AbgAWXLV (ORCPT ); Thu, 23 Jan 2020 18:11:21 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:35466 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729863AbgAWXK5 (ORCPT ); Thu, 23 Jan 2020 18:10:57 -0500 Received: by mail-wm1-f65.google.com with SMTP id p17so4391872wmb.0; Thu, 23 Jan 2020 15:10:55 -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=1GEDu+yELGWrST9c5+TdRrJzCmMwdpupliHRsMCyGqE=; b=dQUU1GoLchg3yIGX5YtyVCZgpZ2ShXaLaryD6EqR/9309QFgrbSu/REt3nbVnaBltT GX3h3lrQxstZZZMehJXYrNWoJj+XACuMSd1iBlFp6CVEVgBefomsFpS8DSdU3O1xrxk1 BMIb5G1NRNbmuj+k7uO6J+YABNba4wBAVS00g6/5wqNErsnB+rGi+68FiHq1a4PjXCkB NyStFzReo0W1/6rarQb74XfkC+d16DDi26K1GmILe4iGADgSIcaoCISpDmZG2TNTWqnL AZMy+hmuErA3gNEq2fkB/haR+2EWXUlWdjopUqdXmbrOi9Nvx4ySCjBzkvWShegi1BRL Hkhg== 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=1GEDu+yELGWrST9c5+TdRrJzCmMwdpupliHRsMCyGqE=; b=WMAj0J0XfLF5ttpAR147DChiWLYuk/92DaqoCGR9n62IQ0yWUwpOnfcd6/oHrcaeGY Ta3Ng2CQJ7eIfCqGBjM2NPq1fN4YXzVxQsUPEVAZ+QberNyD+h+0ImKS/t2R0AiU2XYr wJlyZaMPpNxeWuVM3RrupVulkEW8gBjK/k8mvlrhQ8ydeu9++m/Jb2EI0IEvBlFi9dYm FGC/f/yKCrGDq0QIT3zH3LFLT33ngIU+VObAO4QGF4aqlLGbMsENczSINctCbdfAvQJ+ bdK6goQA4PnDa3FLYymQQcnmra/5EIs+6eDlvcDZ+4J5tNYNeOyS/YDOf8AAZ8RHZ7lp Z1AA== X-Gm-Message-State: APjAAAWJd6j9spY2CKIG0HjqgWItQijspY3r99wdxdPLTUqVO2eP28aG bm2V6puBwuhKLi444eAOANWF+rDt X-Google-Smtp-Source: APXvYqzJfDwln758RU7sb3yLvJqr1ioKkeQIP32Dp0VVfmGd2tIzQs06QaVt4sN2/XwvXUIoNkOUCg== X-Received: by 2002:a05:600c:2551:: with SMTP id e17mr281031wma.26.1579821055044; Thu, 23 Jan 2020 15:10:55 -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 z6sm5105552wrw.36.2020.01.23.15.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:10:54 -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 v5 09/14] dmaengine: tegra-apb: Remove assumptions about unavailable runtime PM Date: Fri, 24 Jan 2020 02:03:20 +0300 Message-Id: <20200123230325.3037-10-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-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 runtime PM is always available on all Tegra SoCs since the commit 40b2bb1b132a ("ARM: tegra: enforce PM requirement"), thus there is no need to handle the case of unavailable RPM in the code anymore. Signed-off-by: Dmitry Osipenko --- drivers/dma/tegra20-apb-dma.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 7158bd3145c4..22b88ccff05d 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1429,11 +1429,8 @@ 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); + ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) goto err_pm_disable; @@ -1546,8 +1543,6 @@ static int tegra_dma_probe(struct platform_device *pdev) err_pm_disable: pm_runtime_disable(&pdev->dev); - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra_dma_runtime_suspend(&pdev->dev); return ret; } @@ -1557,10 +1552,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); - pm_runtime_disable(&pdev->dev); - if (!pm_runtime_status_suspended(&pdev->dev)) - tegra_dma_runtime_suspend(&pdev->dev); return 0; } From patchwork Thu Jan 23 23:03:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349281 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 326FC921 for ; Thu, 23 Jan 2020 23:11:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0197F21734 for ; Thu, 23 Jan 2020 23:11:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y3qaU3tS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729904AbgAWXLB (ORCPT ); Thu, 23 Jan 2020 18:11:01 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53265 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729874AbgAWXK7 (ORCPT ); Thu, 23 Jan 2020 18:10:59 -0500 Received: by mail-wm1-f66.google.com with SMTP id m24so4371251wmc.3; Thu, 23 Jan 2020 15:10:57 -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=B6wMVL4MgaqmuH24oIn0CqdaMc9DNNnI31yvKkdHqzg=; b=Y3qaU3tS1xLC3VsrkKZD0J7JYQ/rpOIRN2KpD1/CQxkw3Iela4QVBkvPvRMBKTKDnQ XeXpoDhwAj3rSTs2f6Dx38PUf5iQOrI4AJMn413DW8BVNPgqqxoj8fZgrOxGHQwcCzno lTXZsZsFGMhalq/4sfMnUZKbWrmxKUESYs+Kf03o89zt1whRjodH2IXIqBZz4Y+zqZ4v x6ZC6+vT+nTN/2xbJiHXgIpFlZnXFqAd1fP548fwClHJJ2lLoc1tEod2tWgiMdQQjRjW 7yHaQQl+Mfq8jwDuyVrOr41f4CuFgrchz5XQkcp7C9/jR0NZqiMR6xr2biV6qkYCMi5u Ax1g== 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=B6wMVL4MgaqmuH24oIn0CqdaMc9DNNnI31yvKkdHqzg=; b=riFB7V3LTf/NeasEFiw3iO9L113jCtwfDYTqXNt2h1qdHpo4qTrPZJMu1fI0yX5XhZ 0b0fpxXS5OqdlyKtuc8N1A/AtquUjslZnHkfE6sRLha7T2rgqsLAwg7bRjxElOvPXNfV abL/m8C3ddHNsWb2Tl+1JiVaQxHAYTUKRRIwYhLNXNw9JtMJofK6aHiYZ2WFz3oiGyvh rGxSu8agTUJ6nMbYLddN38tr6y3g3jli4JT6REd3YBOF+K+oha3TienWtM5YmnDrQ1Mb rQ49IU981gRE0mfATYL6YIG3Hi0puA6/cb/quldzHN8tmkeAN8PDMcXH5jG21T1ICbiJ vK9A== X-Gm-Message-State: APjAAAXagz2ekG441EnPTl/m3GtPifh8FdmkNUA9Yry/FNoMqCp0tFHs s339yvsIXiKyynmT9/qaHQo= X-Google-Smtp-Source: APXvYqxjd9/0NLp3pc7W1y90q1159BuXdggGNkcGGr4KxsRt0R/NVphrnENgFX3eW0Pu87YSj1ekwg== X-Received: by 2002:a1c:2394:: with SMTP id j142mr266489wmj.25.1579821056460; Thu, 23 Jan 2020 15:10:56 -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 z6sm5105552wrw.36.2020.01.23.15.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:10:55 -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 v5 10/14] dmaengine: tegra-apb: Keep clock enabled only during of DMA transfer Date: Fri, 24 Jan 2020 02:03:21 +0300 Message-Id: <20200123230325.3037-11-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-1-digetx@gmail.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org It's a bit impractical to enable hardware's clock at the time of DMA channel's allocation because most of DMA client drivers allocate DMA channel at the time of the driver's probing and thus DMA clock is kept always-enabled in practice, defeating the whole purpose of runtime PM. Signed-off-by: Dmitry Osipenko --- drivers/dma/tegra20-apb-dma.c | 47 ++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 22b88ccff05d..0ee28d8e3c96 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -436,6 +436,8 @@ static void tegra_dma_stop(struct tegra_dma_channel *tdc) tdc_write(tdc, TEGRA_APBDMA_CHAN_STATUS, status); } tdc->busy = false; + + pm_runtime_put(tdc->tdma->dev); } static void tegra_dma_start(struct tegra_dma_channel *tdc, @@ -500,18 +502,25 @@ static void tegra_dma_configure_for_next(struct tegra_dma_channel *tdc, tegra_dma_resume(tdc); } -static void tdc_start_head_req(struct tegra_dma_channel *tdc) +static bool tdc_start_head_req(struct tegra_dma_channel *tdc) { struct tegra_dma_sg_req *sg_req; + int err; if (list_empty(&tdc->pending_sg_req)) - return; + return false; + + err = pm_runtime_get_sync(tdc->tdma->dev); + if (WARN_ON_ONCE(err < 0)) + return false; sg_req = list_first_entry(&tdc->pending_sg_req, typeof(*sg_req), node); tegra_dma_start(tdc, sg_req); sg_req->configured = true; sg_req->words_xferred = 0; tdc->busy = true; + + return true; } static void tdc_configure_next_head_desc(struct tegra_dma_channel *tdc) @@ -615,6 +624,8 @@ static void handle_once_dma_done(struct tegra_dma_channel *tdc, } list_add_tail(&sgreq->node, &tdc->free_sg_req); + pm_runtime_put(tdc->tdma->dev); + /* Do not start DMA if it is going to be terminate */ if (to_terminate || list_empty(&tdc->pending_sg_req)) return; @@ -730,9 +741,7 @@ static void tegra_dma_issue_pending(struct dma_chan *dc) dev_err(tdc2dev(tdc), "No DMA request\n"); goto end; } - if (!tdc->busy) { - tdc_start_head_req(tdc); - + if (!tdc->busy && tdc_start_head_req(tdc)) { /* Continuous single mode: Configure next req */ if (tdc->cyclic) { /* @@ -775,6 +784,13 @@ static int tegra_dma_terminate_all(struct dma_chan *dc) else wcount = status; + /* + * tegra_dma_stop() will drop the RPM's usage refcount, but + * tegra_dma_resume() touches hardware and thus we should keep + * the DMA clock active while it's needed. + */ + pm_runtime_get(tdc->tdma->dev); + was_busy = tdc->busy; tegra_dma_stop(tdc); @@ -786,6 +802,8 @@ static int tegra_dma_terminate_all(struct dma_chan *dc) } tegra_dma_resume(tdc); + pm_runtime_put(tdc->tdma->dev); + skip_dma_stop: tegra_dma_abort_all(tdc); @@ -1280,22 +1298,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 +1339,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,6 +1438,11 @@ static int tegra_dma_probe(struct platform_device *pdev) spin_lock_init(&tdma->global_lock); + ret = clk_prepare(tdma->dma_clk); + if (ret) + return ret; + + pm_runtime_irq_safe(&pdev->dev); pm_runtime_enable(&pdev->dev); ret = pm_runtime_get_sync(&pdev->dev); @@ -1543,6 +1558,7 @@ static int tegra_dma_probe(struct platform_device *pdev) err_pm_disable: pm_runtime_disable(&pdev->dev); + clk_unprepare(tdma->dma_clk); return ret; } @@ -1553,6 +1569,7 @@ static int tegra_dma_remove(struct platform_device *pdev) dma_async_device_unregister(&tdma->dma_dev); pm_runtime_disable(&pdev->dev); + clk_unprepare(tdma->dma_clk); return 0; } @@ -1581,7 +1598,7 @@ static int tegra_dma_runtime_suspend(struct device *dev) TEGRA_APBDMA_CHAN_WCOUNT); } - clk_disable_unprepare(tdma->dma_clk); + clk_disable(tdma->dma_clk); return 0; } @@ -1592,7 +1609,7 @@ static int tegra_dma_runtime_resume(struct device *dev) unsigned int i; int ret; - ret = clk_prepare_enable(tdma->dma_clk); + ret = clk_enable(tdma->dma_clk); if (ret < 0) { dev_err(dev, "clk_enable failed: %d\n", ret); return ret; From patchwork Thu Jan 23 23:03:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349289 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 D300C921 for ; Thu, 23 Jan 2020 23:11:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A1B552468B for ; Thu, 23 Jan 2020 23:11:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="udBXxgBs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729663AbgAWXLQ (ORCPT ); Thu, 23 Jan 2020 18:11:16 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36212 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729898AbgAWXLA (ORCPT ); Thu, 23 Jan 2020 18:11:00 -0500 Received: by mail-wm1-f67.google.com with SMTP id p17so4380721wma.1; Thu, 23 Jan 2020 15:10:58 -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=qyH+MurQ1K+JP11j8j9cz8CEs+bqnCzxDejqE3pavzg=; b=udBXxgBs4qAB9zBc/8NGftiGgBuHXk0vbsv5vqjAO/Y2H4CVcsAqbJUnRkaAt2sAFa bxMxWEEDjBIlTIcefoGrqM6YNrwCfQ1ZDVByg9e99k41n6h+515kigc3P4zIWo8wm43H altwffGEreat6+jY3zcRvUvsozvtwWmvKssZt1AdGsFN1qg4preaF6Fzl+il8/EZ3ao3 E7vO2nkq7cGG3P7DGLEnJw3pNkJNLqxHDIvXdyeSD/+NQOpwYNiJGcNeWfjqcUH0O96u /4vfZqtltDAEbyEoZEJ+Iw3/2X2cQFOsR61hlz6ecl6YwIL3Y3op1nGT4vfqD6WC4p2h nkhw== 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=qyH+MurQ1K+JP11j8j9cz8CEs+bqnCzxDejqE3pavzg=; b=KiH56GrOIKJ0LJSqNc7DNfvCw0gfQy9KBSazrMH/Q+DfP6qfrLRRTzsKvYjYcg1GPk ca2zTZ2paUmlT9Hq4CbNAqTI8NtihQORjNhoA2tL7hLfHcOTgmLeNgymnqAZRBZGeE/G N+/kXnITqtgDlHK+fkBRC5+yH1uRUeO47IaYG8qU7Ss0Gd5eM2IREEZ6KEhCz6FXpk9O u2c3ClLxixzVmsijRQ4TuDQQAjXnqArLyfj+2uuKvEBvBi5M6+GmlFE5MrnXa09Wc+aK RV3+lUHzkg0gLS2mu2+EN0s8+d9wLkXrA7ClSv+22CphIEFUitsbkwnV0AdRovMzVpOa pW4w== X-Gm-Message-State: APjAAAXQuMEa2rYLr0AIlGOHLTNJK0VO/AoIFsQO1D9txagBwgkOZMWf 7Bv+mWruG3rFRq6ybIdDDSk= X-Google-Smtp-Source: APXvYqwy6ZMnj1ws4EyppD+k81C93+yygFkoKQ1VqMhGarO2LPCn0qMTEmXANPdvZ/WX7L40+laa3A== X-Received: by 2002:a05:600c:145:: with SMTP id w5mr221972wmm.157.1579821057838; Thu, 23 Jan 2020 15:10:57 -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 z6sm5105552wrw.36.2020.01.23.15.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:10:57 -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 v5 11/14] dmaengine: tegra-apb: Clean up suspend-resume Date: Fri, 24 Jan 2020 02:03:22 +0300 Message-Id: <20200123230325.3037-12-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-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 | 133 ++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 64 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 0ee28d8e3c96..4a371891b7c4 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1401,6 +1401,36 @@ static const struct tegra_dma_chip_data tegra148_dma_chip_data = { .support_separate_wcount_reg = true, }; +static int tegra_dma_init_hw(struct tegra_dma *tdma) +{ + int err; + + err = reset_control_assert(tdma->rst); + if (err) { + dev_err(tdma->dev, "failed to assert reset: %d\n", err); + return err; + } + + err = clk_enable(tdma->dma_clk); + if (err) { + dev_err(tdma->dev, "failed to enable clk: %d\n", err); + return err; + } + + /* reset DMA controller */ + udelay(2); + reset_control_deassert(tdma->rst); + + /* enable global DMA registers */ + tdma_write(tdma, TEGRA_APBDMA_GENERAL, TEGRA_APBDMA_GENERAL_ENABLE); + tdma_write(tdma, TEGRA_APBDMA_CONTROL, 0); + tdma_write(tdma, TEGRA_APBDMA_IRQ_MASK_SET, 0xFFFFFFFF); + + clk_disable(tdma->dma_clk); + + return 0; +} + static int tegra_dma_probe(struct platform_device *pdev) { const struct tegra_dma_chip_data *cdata; @@ -1442,25 +1472,13 @@ static int tegra_dma_probe(struct platform_device *pdev) if (ret) return ret; + ret = tegra_dma_init_hw(tdma); + if (ret) + goto err_clk_unprepare; + pm_runtime_irq_safe(&pdev->dev); pm_runtime_enable(&pdev->dev); - 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]; @@ -1558,6 +1576,8 @@ static int tegra_dma_probe(struct platform_device *pdev) err_pm_disable: pm_runtime_disable(&pdev->dev); + +err_clk_unprepare: clk_unprepare(tdma->dma_clk); return ret; @@ -1577,26 +1597,6 @@ static int tegra_dma_remove(struct platform_device *pdev) static int tegra_dma_runtime_suspend(struct device *dev) { struct tegra_dma *tdma = dev_get_drvdata(dev); - unsigned int i; - - tdma->reg_gen = tdma_read(tdma, TEGRA_APBDMA_GENERAL); - for (i = 0; i < tdma->chip_data->nr_channels; i++) { - struct tegra_dma_channel *tdc = &tdma->channels[i]; - struct tegra_dma_channel_regs *ch_reg = &tdc->channel_reg; - - /* Only save the state of DMA channels that are in use */ - if (!tdc->config_init) - continue; - - ch_reg->csr = tdc_read(tdc, TEGRA_APBDMA_CHAN_CSR); - ch_reg->ahb_ptr = tdc_read(tdc, TEGRA_APBDMA_CHAN_AHBPTR); - ch_reg->apb_ptr = tdc_read(tdc, TEGRA_APBDMA_CHAN_APBPTR); - ch_reg->ahb_seq = tdc_read(tdc, TEGRA_APBDMA_CHAN_AHBSEQ); - ch_reg->apb_seq = tdc_read(tdc, TEGRA_APBDMA_CHAN_APBSEQ); - if (tdma->chip_data->support_separate_wcount_reg) - ch_reg->wcount = tdc_read(tdc, - TEGRA_APBDMA_CHAN_WCOUNT); - } clk_disable(tdma->dma_clk); @@ -1606,46 +1606,51 @@ static int tegra_dma_runtime_suspend(struct device *dev) static int tegra_dma_runtime_resume(struct device *dev) { struct tegra_dma *tdma = dev_get_drvdata(dev); - unsigned int i; - int ret; - ret = clk_enable(tdma->dma_clk); - if (ret < 0) { - dev_err(dev, "clk_enable failed: %d\n", ret); - return ret; - } + return clk_enable(tdma->dma_clk); +} - tdma_write(tdma, TEGRA_APBDMA_GENERAL, tdma->reg_gen); - tdma_write(tdma, TEGRA_APBDMA_CONTROL, 0); - tdma_write(tdma, TEGRA_APBDMA_IRQ_MASK_SET, 0xFFFFFFFFul); +static int __maybe_unused tegra_dma_dev_suspend(struct device *dev) +{ + struct tegra_dma *tdma = dev_get_drvdata(dev); + unsigned long flags; + unsigned int i; + bool busy; for (i = 0; i < tdma->chip_data->nr_channels; i++) { struct tegra_dma_channel *tdc = &tdma->channels[i]; - struct tegra_dma_channel_regs *ch_reg = &tdc->channel_reg; - - /* Only restore the state of DMA channels that are in use */ - if (!tdc->config_init) - continue; - - if (tdma->chip_data->support_separate_wcount_reg) - tdc_write(tdc, TEGRA_APBDMA_CHAN_WCOUNT, - ch_reg->wcount); - tdc_write(tdc, TEGRA_APBDMA_CHAN_APBSEQ, ch_reg->apb_seq); - tdc_write(tdc, TEGRA_APBDMA_CHAN_APBPTR, ch_reg->apb_ptr); - tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBSEQ, ch_reg->ahb_seq); - tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBPTR, ch_reg->ahb_ptr); - tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR, - ch_reg->csr & ~TEGRA_APBDMA_CSR_ENB); + + tasklet_kill(&tdc->tasklet); + + 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; + } } - return 0; + return pm_runtime_force_suspend(dev); +} + +static int __maybe_unused tegra_dma_dev_resume(struct device *dev) +{ + struct tegra_dma *tdma = dev_get_drvdata(dev); + int err; + + err = tegra_dma_init_hw(tdma); + if (err) + return err; + + return pm_runtime_force_resume(dev); } static const struct dev_pm_ops tegra_dma_dev_pm_ops = { SET_RUNTIME_PM_OPS(tegra_dma_runtime_suspend, tegra_dma_runtime_resume, NULL) - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) + SET_SYSTEM_SLEEP_PM_OPS(tegra_dma_dev_suspend, tegra_dma_dev_resume) }; static const struct of_device_id tegra_dma_of_match[] = { From patchwork Thu Jan 23 23:03:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349287 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 40101921 for ; Thu, 23 Jan 2020 23:11:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1A20924655 for ; Thu, 23 Jan 2020 23:11:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jxU/AVqx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729925AbgAWXLC (ORCPT ); Thu, 23 Jan 2020 18:11:02 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:39351 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729837AbgAWXLB (ORCPT ); Thu, 23 Jan 2020 18:11:01 -0500 Received: by mail-wm1-f67.google.com with SMTP id 20so4355655wmj.4; Thu, 23 Jan 2020 15:10:59 -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=gfFOKKBycfoTA+tP8C+2g2g1I1HSJbXw7d1KRYGNlF8=; b=jxU/AVqxnR3+hTPSPz6CkHPCRZ/afTWU8nW6KAmKr6oK7kSnlTg4jXQwqilt8TfYE2 cIW2ER9Io3raMN6x2ifsf+UI+3CvooSGVVKxgCFo2o+aHXTRWOqDcRD3YB9MUVQslPBP XcXYuK26JdPGXvi3FjDlWpqB1SdEfatlwwsAy9NWdNb/fv5TKsIzNV332GxpAk0i1/qq mL8hfvAFUiI9P8bGBrLTpt+qtU12wngozJYawTgAA3Fspy3nK/QR4Ri/jF0vbIVqvBC9 uekBPEZxHCNO31dknpsbJESNyHGEdBFoLpXZQD8J/edjm+WQJrGcz1CCi4XjrdOu0xXB EWqA== 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=gfFOKKBycfoTA+tP8C+2g2g1I1HSJbXw7d1KRYGNlF8=; b=GA6UxP+2iywhR2w2ypshhliDNBhO6ywQiVKmd67IjTqO3+mwAu2zgV5G67YJKocLIr OnJvWPP5QYEp/qFwenSmcDe5i3jKlRxZzFLs6Ru9bjQmTWDT5xkALPz6tbHfqNr5dhTR VA2SvVE3pXrYT3u+gjSvMDmyBSrbNoAiPmcuUVg/35hRbAz00KSoB5Z7DAShyBmUt8DY tdJ56cRok51sHB8MVjA5HAYBK4MeG1DqtxaBNM29FMj7gMsLa4xFqVYXOrDdx5wwWhsN prZSOlA1k7zW4UNo8bnAkjCiXZ5m3y/WzzJPAhQZGvfHtkhTMWr9nypD3G/ZXuokDag/ hlBQ== X-Gm-Message-State: APjAAAUyGmQiQD8h9SimjAC2DFUnNIwkJlXw+oKJKPjYlsWdgOO3rFLN fAcy2Ci684LsKVg8CW9gFYg= X-Google-Smtp-Source: APXvYqwh0xiC7euwGWnYHRUuMpS2p6IW1LN/+trarCyT+FZVT/LNKqjzFyOCZ0eGrw4s/0e77zq1bQ== X-Received: by 2002:a1c:80d4:: with SMTP id b203mr282683wmd.102.1579821059100; Thu, 23 Jan 2020 15:10:59 -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 z6sm5105552wrw.36.2020.01.23.15.10.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:10:58 -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 v5 12/14] dmaengine: tegra-apb: Add missing of_dma_controller_free Date: Fri, 24 Jan 2020 02:03:23 +0300 Message-Id: <20200123230325.3037-13-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-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. Acked-by: Jon Hunter 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 4a371891b7c4..8f4281ab6296 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1587,6 +1587,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); pm_runtime_disable(&pdev->dev); clk_unprepare(tdma->dma_clk); From patchwork Thu Jan 23 23:03:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349283 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 AA6516C1 for ; Thu, 23 Jan 2020 23:11:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8452A21734 for ; Thu, 23 Jan 2020 23:11:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vM1CawSy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729928AbgAWXLD (ORCPT ); Thu, 23 Jan 2020 18:11:03 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53268 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729906AbgAWXLC (ORCPT ); Thu, 23 Jan 2020 18:11:02 -0500 Received: by mail-wm1-f66.google.com with SMTP id m24so4371364wmc.3; Thu, 23 Jan 2020 15:11:00 -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=pEfxv5F227uxTmA12bCuYEhDZgC2pnQDO7/dlyP837c=; b=vM1CawSycwRtXeau556BXaDTNQ8OGUpN8c86vrQDEP2xpw/5VTEtfQLN95dXxUiANH JlZ0XNF9hI+UYkUC2kcHq5AYQT2p2FywWL2VyOq8NDXxsj+eGI89F0KA24ukogLzo8F8 C+bqolttYQOjoGMRc+vKWgsON/YvCIM/+Sfk9b4kr0tzkVW/UMqX/iEhhQLJ3r45UaHd kBhiQI2lv+Vu3ozM6+nKeapQTeZeIo8/iiVFXNJZf6o90T0g7Hj1CZ1RdCbiDeD5bYt1 GJrb+/rjnShPFS/I6b64vRUgDmpgNki5i/vmysAXXUJekhHEjXh+W5nsoklNhtwPLdNe FFBA== 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=pEfxv5F227uxTmA12bCuYEhDZgC2pnQDO7/dlyP837c=; b=QJa+maFiPbDTTO41U3c8hrQ6IyLrMc2oF29lV/Nqes+1OTnZaxZ6Bfdb1+OkpDDDmy kosNvbXs5/uJJJ0oAoqv/IUZyyk71LStU8RI5V4bxRarCi0ca5/yuVSXL9aUb+feb0Yv OO4fvlU8rLLsoXx2VO15Sm0YytLJuew+NDfNRDjFZMDqtqIs+2OM5H7yJVKG47jc4kmZ P1jCux1eGln6fQ7Ptfq8zZfm3eJNBmOHtxe99OQYU/y6aoD8P06z5QqNZvAivhTPFthB 4xUZKBgjSwwvVg02QkrJHnD5aSPDzFXoueLNr9qDDfJ5ZNfaNfA/xYtiEAvHlzIgImcs f9uw== X-Gm-Message-State: APjAAAU1ebyWl6UqubKPfHz0MbxlCrCEZ6+Q9yOShzaur/Od3N5cEj88 D9A7FgdPiUQyHJ3rJMV5/lw= X-Google-Smtp-Source: APXvYqzJb91qU53DHz2FkvqpCsJEamUD9/WrHBIKKy9BNJZsqb5Xi7ozeuKH9O8uo7tKXg07foLenQ== X-Received: by 2002:a1c:1b42:: with SMTP id b63mr292378wmb.16.1579821060389; Thu, 23 Jan 2020 15:11:00 -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 z6sm5105552wrw.36.2020.01.23.15.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:10:59 -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 v5 13/14] dmaengine: tegra-apb: Allow to compile as a loadable kernel module Date: Fri, 24 Jan 2020 02:03:24 +0300 Message-Id: <20200123230325.3037-14-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-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. Acked-by: Jon Hunter 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 312a6cc36c78..d765db9b7b21 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -595,7 +595,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 Thu Jan 23 23:03:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11349285 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 7966E6C1 for ; Thu, 23 Jan 2020 23:11:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 54D40218AC for ; Thu, 23 Jan 2020 23:11:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d0idhHLC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729946AbgAWXLE (ORCPT ); Thu, 23 Jan 2020 18:11:04 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36745 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729921AbgAWXLD (ORCPT ); Thu, 23 Jan 2020 18:11:03 -0500 Received: by mail-wr1-f66.google.com with SMTP id z3so5214634wru.3; Thu, 23 Jan 2020 15:11:02 -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=QMJiXLF1JbYFb+JW/uJeE/qawBShUmR+DHoM9EjGezk=; b=d0idhHLC9THq4K5LGz36aLPqrpXYpX+W2KMXspfIWMeBlV2v+FEkZjKahD0jvgIQLF uB2vJd3lOWB+MGYf4SuIAQrWdj88KKQNkpCIDTWWTHf2S51vqGL7og/F9YemACSoBkJh 29TF0Skv4bjCmVPRbgyQb4MYov9HZxD62xM7tTDN2o1B0P1SEXA9QI/+dp+1kxzq6S/R WRSSuNjiEPD8ApHNrHTgE2NyAhnblLpa5VP6HRnMbsBj3IRmaKG7nGM7B02fuA/YBj+z YQ7frwo3Ux6TSLzREqfBTEK2267tqOej+rL1UFp2z+0BF9UhNHaZllfC4mZY9nuvpm8w TVIg== 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=QMJiXLF1JbYFb+JW/uJeE/qawBShUmR+DHoM9EjGezk=; b=hQuV4vVZ2vSXzlfe5NgIDPTsCVP5UWdnOMiqnBTl7pI+fAMaBqizjoxMwdNrhQIsto CYlPpe9QMtqZi0+9T4vdFh3EV/udtLWUgGcJPdVAP1uEjJEMrBWtbj1ZnczK7F+o7Yeb XV7d9tqMODrDkghxruVD/NR/IC5BGw0gDxQYgSDY5N94VIrOO91noeT7BJy6boyz5o3u od0p49IX8ZuLcU7+OzM0noTHKANdT6e9Vywmo3XBiNaRrrhEl9f9NeKWxHFNCPdYoI8/ msPJGEBlioZhuZtn3w3AhL/V8PzjB7gZgOCVS7cW/3xMYuIz/Fz3WwQgdEh6vTCjHFFp i6Xg== X-Gm-Message-State: APjAAAVsotbfsxTKL0hvb6/WyeGBP9TO5o/phSoNd/AeeC4uIURLLcPM 06jHWQQHKQ5qLlSGoEfw56U= X-Google-Smtp-Source: APXvYqyTPHMPE845HLY2B5GKwIiCGHer2IWZI3hDnBCaAmDvl3yXjJXOPRuuOri8w/BzlrEodwNJTQ== X-Received: by 2002:adf:fc4b:: with SMTP id e11mr484141wrs.326.1579821061580; Thu, 23 Jan 2020 15:11:01 -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 z6sm5105552wrw.36.2020.01.23.15.11.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:11:01 -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 v5 14/14] dmaengine: tegra-apb: Remove MODULE_ALIAS Date: Fri, 24 Jan 2020 02:03:25 +0300 Message-Id: <20200123230325.3037-15-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200123230325.3037-1-digetx@gmail.com> References: <20200123230325.3037-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. Acked-by: Jon Hunter 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 8f4281ab6296..756a5dbef118 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1684,7 +1684,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");