From nobody Mon Feb 9 08:49:26 2026 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8554A2749D2 for ; Tue, 23 Dec 2025 13:50:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497844; cv=none; b=AoW5TC6vw/eXvFCjqOYu1XaIXhq2TbXA1/JNQSxThgl2oVERYeQR0w5kbEdyLTEdpIcD+xvyPGVyj3FJS/0MSnqba/e/+3k+lI3Q6qrHs9E5pdlMUj30Xl24hzemD9IXI7jVEz/zHgmfT/P+DATi1Fur9OdESfOYvjzFEdbifTo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497844; c=relaxed/simple; bh=6ZSYMN2SKXVTTfYd0IARyp5Sd5OHsSjCDdnQL0dBWGA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sS3WVzweXW5jqvxj3Oy+VeKWf4eRYEV2gXzFjhrhSxYWXTNgGFOXOwvPUKAsUcyqxG8wGU7XPzDNFxdk75v3q00oWBxBYKAsS7ftEc6wudIfi2xojw/z0FdTlaXLe6qYGhpj2juidxosz1ubtWayDxauTPlLevrrSTYmWHryVqU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=D2qA2H0D; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="D2qA2H0D" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4779cc419b2so39920825e9.3 for ; Tue, 23 Dec 2025 05:50:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1766497841; x=1767102641; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gLvTm305m57LTYmm1aI4ieZDb54ktZ6C9ruLi16NB8I=; b=D2qA2H0DzGKjYswYFXadFnb09xtAoVX0qtHfEywD7pD8Oftm1wKbwrwlA7BTYR9IQ6 Uj8J9UNrSwBg4Yx6SatY7LkmHEiBuLZ/rv9Jc+Xp/8X3B5M4Ywjaw7gB2K25RfAEGvXg 3cvBuG/HKVz8UM2JMHp63J8wbNb/TEQ9tR5Ff4FOx3cXwjnAlNawWA1TNKDq/QGBH7HX rZ0cLlQlg8Na/Hk4JYAMXM2LusUxyiVy1FkMQF8sYwLyK1bglVWyDpKZ9GFcxhiB0qxj QDPAsuWQT5R7H/Xb8e8e74Kh/uRGZ5bf1j2kUXjoDYvIjWJ7KreIiFatmH3s7zDjTIE1 Gnww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766497841; x=1767102641; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gLvTm305m57LTYmm1aI4ieZDb54ktZ6C9ruLi16NB8I=; b=PuzM3L1umkvQpZtc1tyoVNefJ9+6slMk/5OTeKlWcBgw5fI7FsJJCylj8iI0frsG+q C5K0Mima43VmkCsrAf+cDd1R0rJY8OglrKB8HB215ee3tphU2XZ+1thteMZFBK8D1bVn PQPyNpoty1HwGV0A/2O7+ZlngyaPzy4wtjhdRyEVNCNR+cm0HU/hW5MpaK+66djYUNkd 9eyhEHgTMCm14M4BXepLo1xDt+tLlW94XBL+ZCuxJNJTqqUoGzePY7zTUMUIKbIwDzLm YFQTmjHClMJql3D27a6rXjxmuQmnWHWSfD9voPGUhOrITRBucDjYqz0lM8JuMrmfD3qK roaw== X-Forwarded-Encrypted: i=1; AJvYcCVjWT2gUmFxrut+X06qMgbsJmxiK/Z0/tnDI0bLDM0U73gz/Teumjssngq6dAel29IE4uFfVy4hJcRY2w0=@vger.kernel.org X-Gm-Message-State: AOJu0YyB4opS/mab38MtzhqOGKX+2MZ54++QKuNi4OAaBHGmhayyY45W m5bvOxaAAfyIyHiUq9HluHhv2GgKovkb5Hpj8zeFllxhHZMsRZg+lZ3XdmW5Ila4bZo= X-Gm-Gg: AY/fxX41B7DJhOnBpLh3iwqHZgiozYQcS7siZv/q7NQNhR0C3OS0PBXQcH6GxRpES4E 7J1V+kZ3aRijZnpBcENE/K4COor+moty+aoZ//KBQvdchFsk7MhUqlKZXsoo1O2dlHLSbCylBo4 1cscDrH0/ObLsuOVARAXcaipgXQov2UPCQnk5pLvL6/QA6R8Lx9wS3UXW1RYGpE+9DwdNiOJL54 igFtVRHUOebmLQdfYbR9fgnkGhrC47E2jxUUZVQ643rFnI8hwwMrAQFirU78TbmPk/APB+pv1Yb vMu1ebCF6OKbBGYQJh6uPYIeeZ0zDPaS9svJsFi5Yw/UPNW86JyZP8XG2zANPVZrR+IheZfK7C7 wxhCJsPQmsgca2ITtj4aVFzeUeXVnG63pn/RK+M9It3w0BsG37fe8dE2NXaugejUN2l7/Cq5dgx j55O6Mzz7KL5tvdFk9GUIGOTEy5d+EnFCqGELSESTKnyyc32UFAx8VPE7y5sn3ipDXwEYHZ5A= X-Google-Smtp-Source: AGHT+IEHaI451aDZyjBnBK6G77N/7eVYDQxAvy5RL96QV1B2EAWVR4YQBYxfsbJGhMmbq7yO9N9+Ww== X-Received: by 2002:a05:600c:4f42:b0:477:55ce:f3c2 with SMTP id 5b1f17b1804b1-47d19556d02mr172647885e9.14.1766497840923; Tue, 23 Dec 2025 05:50:40 -0800 (PST) Received: from claudiu-TUXEDO-InfinityBook-Pro-AMD-Gen9.. ([2a02:2f04:620a:8300:4258:c40f:5faf:7af5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d192e88f5sm237921025e9.0.2025.12.23.05.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 05:50:40 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, biju.das.jz@bp.renesas.com, fabrizio.castro.jz@renesas.com, geert+renesas@glider.be, prabhakar.mahadev-lad.rj@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH v6 1/8] dmaengine: sh: rz-dmac: Protect the driver specific lists Date: Tue, 23 Dec 2025 15:49:45 +0200 Message-ID: <20251223134952.460284-2-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> References: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea The driver lists (ld_free, ld_queue) are used in rz_dmac_free_chan_resources(), rz_dmac_terminate_all(), rz_dmac_issue_pending(), and rz_dmac_irq_handler_thread(), all under the virtual channel lock. Take the same lock in rz_dmac_prep_slave_sg() and rz_dmac_prep_dma_memcpy() as well to avoid concurrency issues, since these functions also check whether the lists are empty and update or remove list entries. Fixes: 5000d37042a6 ("dmaengine: sh: Add DMAC driver for RZ/G2L SoC") Cc: stable@vger.kernel.org Signed-off-by: Claudiu Beznea --- Changes in v6: - none Changes in v5: - none, this patch is new drivers/dma/sh/rz-dmac.c | 57 ++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index 9e5f088355e2..c8e3d9f77b8a 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -10,6 +10,7 @@ */ =20 #include +#include #include #include #include @@ -448,6 +449,7 @@ static int rz_dmac_alloc_chan_resources(struct dma_chan= *chan) if (!desc) break; =20 + /* No need to lock. This is called only for the 1st client. */ list_add_tail(&desc->node, &channel->ld_free); channel->descs_allocated++; } @@ -503,18 +505,21 @@ rz_dmac_prep_dma_memcpy(struct dma_chan *chan, dma_ad= dr_t dest, dma_addr_t src, dev_dbg(dmac->dev, "%s channel: %d src=3D0x%pad dst=3D0x%pad len=3D%zu\n", __func__, channel->index, &src, &dest, len); =20 - if (list_empty(&channel->ld_free)) - return NULL; + scoped_guard(spinlock_irqsave, &channel->vc.lock) { + if (list_empty(&channel->ld_free)) + return NULL; + + desc =3D list_first_entry(&channel->ld_free, struct rz_dmac_desc, node); =20 - desc =3D list_first_entry(&channel->ld_free, struct rz_dmac_desc, node); + desc->type =3D RZ_DMAC_DESC_MEMCPY; + desc->src =3D src; + desc->dest =3D dest; + desc->len =3D len; + desc->direction =3D DMA_MEM_TO_MEM; =20 - desc->type =3D RZ_DMAC_DESC_MEMCPY; - desc->src =3D src; - desc->dest =3D dest; - desc->len =3D len; - desc->direction =3D DMA_MEM_TO_MEM; + list_move_tail(channel->ld_free.next, &channel->ld_queue); + } =20 - list_move_tail(channel->ld_free.next, &channel->ld_queue); return vchan_tx_prep(&channel->vc, &desc->vd, flags); } =20 @@ -530,27 +535,29 @@ rz_dmac_prep_slave_sg(struct dma_chan *chan, struct s= catterlist *sgl, int dma_length =3D 0; int i =3D 0; =20 - if (list_empty(&channel->ld_free)) - return NULL; + scoped_guard(spinlock_irqsave, &channel->vc.lock) { + if (list_empty(&channel->ld_free)) + return NULL; =20 - desc =3D list_first_entry(&channel->ld_free, struct rz_dmac_desc, node); + desc =3D list_first_entry(&channel->ld_free, struct rz_dmac_desc, node); =20 - for_each_sg(sgl, sg, sg_len, i) { - dma_length +=3D sg_dma_len(sg); - } + for_each_sg(sgl, sg, sg_len, i) + dma_length +=3D sg_dma_len(sg); =20 - desc->type =3D RZ_DMAC_DESC_SLAVE_SG; - desc->sg =3D sgl; - desc->sgcount =3D sg_len; - desc->len =3D dma_length; - desc->direction =3D direction; + desc->type =3D RZ_DMAC_DESC_SLAVE_SG; + desc->sg =3D sgl; + desc->sgcount =3D sg_len; + desc->len =3D dma_length; + desc->direction =3D direction; =20 - if (direction =3D=3D DMA_DEV_TO_MEM) - desc->src =3D channel->src_per_address; - else - desc->dest =3D channel->dst_per_address; + if (direction =3D=3D DMA_DEV_TO_MEM) + desc->src =3D channel->src_per_address; + else + desc->dest =3D channel->dst_per_address; + + list_move_tail(channel->ld_free.next, &channel->ld_queue); + } =20 - list_move_tail(channel->ld_free.next, &channel->ld_queue); return vchan_tx_prep(&channel->vc, &desc->vd, flags); } =20 --=20 2.43.0 From nobody Mon Feb 9 08:49:26 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4206C27E056 for ; Tue, 23 Dec 2025 13:50:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497846; cv=none; b=VX/53K7DB2qgobdBm9KknqO7Nl5cneml4y6Kfw+dNebq26+bBM23PqOhC8Ys8+aJIzRKNsg6CX28Pikn2RffBh3JYCwS6IsAsJbjD4RrK5SKcSMLTPBCYBshIpZWqq12aZbRVe5BvWgn16lL601B1RFa2XdCmvMESPpiZUY6ZLY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497846; c=relaxed/simple; bh=NuLQyH+VwGHRR72oMwwugrjxP5H7eBUcMTxjyn0Mn3E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kEwhuj4G5lCN1lxZDP3TKS+KwsazRIrbyGJ67sBKPjHuh7efiEUTYhr6bpzrRi4sAXFsPGEp/AX0Ng+qLAmMoZeeNDWE+ycs18T7Gv8htTsIzSD2glrhgjCiRYRnu1qDZchWWu3PfCRXykbeKJDB1Un/nvP8MuTpU8yAdwjqdAQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=QVgACvO4; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="QVgACvO4" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-47d3ba3a4deso355225e9.2 for ; Tue, 23 Dec 2025 05:50:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1766497843; x=1767102643; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hZ9+0Yi+2nkzLK6cHQIgso5yqDARPMTK/Jx14dRo/m8=; b=QVgACvO4Ji2edDIbIDuO4Epac+uxD68+ax1NZRPHt/iGFWtY8dqRK4jBGlLKD1siKu d8gpyewQulDCmeRGgeCnRo4iCquWHqc/ErC5uu0fQyBxxahp8bNSyRpDIV2/hJrjHBm9 4uudbx68z4IoY621r37QMcv7SgmJmO+DE22P6oMlUUtl78f9LVI4XbkSMQKLqBquhqTD zgXOY4NU2GBu5tNWJNTMl46A8peu66vO++kkCUOwmD7IuCC6hczzFJ9fqCi993oNQsKz +j/BfxiNZYW3sANhjffLVS7rucZKNlg9zn2OcOQomP9HRW1pYZ9vgDvakUnMN+gVWvLN pJvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766497843; x=1767102643; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hZ9+0Yi+2nkzLK6cHQIgso5yqDARPMTK/Jx14dRo/m8=; b=j0ZY9uK3AKtzYQD9HiGBDeDkDbOOZgBnKTXjAxkrD83fJgSGbRENhxxV5Lm7bCKJfx shV8t87Pg5RlBDJEDUMpbQH5LEJvH2vVUvowbc6cKCnk4L7Yg0Cl06evRfQUF5Ib1mAg X3pQxSWf6V2xoUS6eRwUv2xPMnWB8LBWsOSd/w/3/FOFvwlie04WA2IX2hbaRFTo58JV AUrPNi5P8H4TYUICf3D7kuaebi87vhYeEh7ikvGRkZ6e4JobFKw6XAza6DDDwAPeXdKR JdOBnkqPXCGaNGjIbtDdqK8Ey4UvmvgrYzx7S2N/a1EBv0Rt28ba1nWU3NuQe6ubIrtp T2CQ== X-Forwarded-Encrypted: i=1; AJvYcCVzc2qJctFeU7OfarotHXRBcqtXTUPXDkhNIpGvsEOrqpCJzjFq9bJO4HYa0EFROhqX1KB+FIHRAR00geU=@vger.kernel.org X-Gm-Message-State: AOJu0YzNvzA19HdAxyEBnhCYdOY9Xe4g0hMfsS725kRv57RqR2qEoHsD Wv4UgcPxgwuzU6Crqy/m3/BB27MlyvvHXmOIhu9GOguZ/uJaRNMaULW+xlBny9wgxfk= X-Gm-Gg: AY/fxX4lcj3XRcRw5RQ+6JTTg/mzw4aSF3I5j9iLTGKSzbM9vlvckh2cD0Au7EyopaW 8FdxUNuoCO9XuI/16+zo0+npmUelMiSjiXoCDzZpI0CLSDLqLyg37MRRxzbf7Zt1Xdqte0FnA9o VSf064VUlsp9YlGseirH33Z3EAoyVTrHCyjMLAXZoe3aYUxJqb6Mj8LOKAugDKczEuzsjCSgXt/ o22ruZnyV/BmdcvD2/VyjOwgGCxjd3j/GaeYaBx0icr4TuzvAzGnig+ujsyT3yuSE7Ze+hexXwt SIaA4917YZMODv+sLrwG9CoyP3AR1EZt7wrT6YKGAMC61AoOgfORdMTrahEvot95FHCXQxyggna 908uc6Xr4Hyjt5xs+z6dOQ8waWaB11EEDG/rR0CD52T1RhmO7dIsX2P1c+HgPHljtCJ7F9tgrXp g5iy+DUdkuMcWM1L2K+TNkvvNV4t7pZysoXtTpOPU3mkLxClIwf0YjvVwes94yychQl9ghQ+0= X-Google-Smtp-Source: AGHT+IHKxYmc9Jyegqhg5MAp6RDYOMSBp3GbrsFKuRyQtLXF0v+7GhMm6p7R8YXuU3Tk5WSJGR2hMg== X-Received: by 2002:a05:600c:8b6d:b0:475:dd8d:2f52 with SMTP id 5b1f17b1804b1-47d1959d1d8mr152368795e9.32.1766497842594; Tue, 23 Dec 2025 05:50:42 -0800 (PST) Received: from claudiu-TUXEDO-InfinityBook-Pro-AMD-Gen9.. ([2a02:2f04:620a:8300:4258:c40f:5faf:7af5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d192e88f5sm237921025e9.0.2025.12.23.05.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 05:50:42 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, biju.das.jz@bp.renesas.com, fabrizio.castro.jz@renesas.com, geert+renesas@glider.be, prabhakar.mahadev-lad.rj@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea , stable@vger.kernel.org Subject: [PATCH v6 2/8] dmaengine: sh: rz-dmac: Move CHCTRL updates under spinlock Date: Tue, 23 Dec 2025 15:49:46 +0200 Message-ID: <20251223134952.460284-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> References: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Both rz_dmac_disable_hw() and rz_dmac_irq_handle_channel() update the CHCTRL register. To avoid concurrency issues when configuring functionalities exposed by this registers, take the virtual channel lock. All other CHCTRL updates were already protected by the same lock. Previously, rz_dmac_disable_hw() disabled and re-enabled local IRQs, before accessing CHCTRL registers but this does not ensure race-free access. Remove the local IRQ disable/enable code as well. Fixes: 5000d37042a6 ("dmaengine: sh: Add DMAC driver for RZ/G2L SoC") Cc: stable@vger.kernel.org Signed-off-by: Claudiu Beznea --- Changes in v6: - update patch title and description - in rz_dmac_irq_handle_channel() lock only around the updates for the error path and continued using the vc lock as this is the error path and the channel will anyway be stopped; this avoids updating the code with another lock as it was suggested in the review process of v5 and the code remain simpler for a fix, w/o any impact on performance Changes in v5: - none, this patch is new drivers/dma/sh/rz-dmac.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index c8e3d9f77b8a..818d1ef6f0bf 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -298,13 +298,10 @@ static void rz_dmac_disable_hw(struct rz_dmac_chan *c= hannel) { struct dma_chan *chan =3D &channel->vc.chan; struct rz_dmac *dmac =3D to_rz_dmac(chan->device); - unsigned long flags; =20 dev_dbg(dmac->dev, "%s channel %d\n", __func__, channel->index); =20 - local_irq_save(flags); rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1); - local_irq_restore(flags); } =20 static void rz_dmac_set_dmars_register(struct rz_dmac *dmac, int nr, u32 d= mars) @@ -569,8 +566,8 @@ static int rz_dmac_terminate_all(struct dma_chan *chan) unsigned int i; LIST_HEAD(head); =20 - rz_dmac_disable_hw(channel); spin_lock_irqsave(&channel->vc.lock, flags); + rz_dmac_disable_hw(channel); for (i =3D 0; i < DMAC_NR_LMDESC; i++) lmdesc[i].header =3D 0; =20 @@ -707,7 +704,9 @@ static void rz_dmac_irq_handle_channel(struct rz_dmac_c= han *channel) if (chstat & CHSTAT_ER) { dev_err(dmac->dev, "DMAC err CHSTAT_%d =3D %08X\n", channel->index, chstat); - rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1); + + scoped_guard(spinlock_irqsave, &channel->vc.lock) + rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1); goto done; } =20 --=20 2.43.0 From nobody Mon Feb 9 08:49:26 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC85A298CC9 for ; Tue, 23 Dec 2025 13:50:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497848; cv=none; b=tds9k6JrA+88X7e8ZYzBHLi6bgH8VqIcywTMQsauZZGRa6dPwSkG76Jnsf1u42isNgsZKsQvMedYQAemYS4WahYHk9YjQJwJ0jyCkX71QFzK8g0ocRUO12d6+nrsa55DpKd48TZwtLNEMF+96Dq+xE04xzSuRCMYUzOO3bI8AG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497848; c=relaxed/simple; bh=LiPltN3HUsoWZgG0b3XladhmIyhEPP3aMOM9Buc1+pg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JDx6dVIW0BMysWi+TRwfI9RP+Zszj0cwNJkAAuttcPbWeuGK6MdlJL0lBRGnIFFG2G3MnrMVomLrffN9vW2tizitL4H4xwAClhtBW4h7V+BG7z9/9gYnrl7DD/1kHq/2r0c+9BB/LmCR6uk2Y0r9CG/VCyPMLczht3DKyEaHlOA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=JZCbpAFb; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="JZCbpAFb" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-477b5e0323bso30606335e9.0 for ; Tue, 23 Dec 2025 05:50:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1766497844; x=1767102644; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FH6nXiaIYwI1+2t9P55h/qNKuU+/btAtGFOCQCzQEyM=; b=JZCbpAFb69Xg08KBXPX0lkodb50kdhkMiNNbq5RU3CMap5ogZ/96QN5PRkhImEL0Dh nkcEtGCKb7jDodp7Fn/fATa1i3PohorHUfouQLlLDn8n7vZCt2d9ynQNIvNNP5zYF9aY n86wwvK1xXbCK7JZpaRSOyXomZn47TSsyNmpah+gwXC0otbBdWBn0/vlJfGb2E4IMkyz fLkXv18H+qWDUBPaAv0ooWkMh5m/mr9RZHl5U3O4ES5TQGsdLmbUSgIakrnIRc4V2GRG XlQf7ZGlZLN+IZN9dufZr6KF4N9TpegKufPwNunk4Z9gqeTSGJgqDxCSzHX4tgbyna17 X+lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766497844; x=1767102644; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=FH6nXiaIYwI1+2t9P55h/qNKuU+/btAtGFOCQCzQEyM=; b=thXY0rj62wJqXY6Tq+axWt2Z8NfpCFNPlndYazPEcHJaLEfSbs2qim6vfpeInC9uK2 NbjocKzxEx0z1+egJ+VuZdkw+hUbchPBEXm7NrGYi4A+P2Pnws6gNKX6VDMOmZpAjOS7 rGX2dzU7BQj0X3rPstQDzSiWqqs3FmDmzHMNccmCtgwbWeElDQT3TAhWerovrw2D6XrQ T6xqAxpJcDkWNm1GywJDYZ5RsIUtPFmIpr8TuZwv1xYEKkz0Uq/9mxacVs7oHG6KtmBp N4AqcYx3DttlG1FEIdUeG9w/d3ikDcqMbq2o0CiVQofZNa0TPnEizgxpmMAdBaSjGb05 Zhrw== X-Forwarded-Encrypted: i=1; AJvYcCVBnlbnh3I46/MCfqC+ioTkfzv1Kk3xOR4/J03Vm0CMsb7eT1P+nxhAv4fIw9nWZsjjO7LHEGyRuUmzTWE=@vger.kernel.org X-Gm-Message-State: AOJu0YwuCqcr3kobDbLSejJdgK5HddXtDH94hT4jN49/yXMAorLKD+If WjcERaEyluhxzq44AgfL5x7UVcitAFJzRIWWTBB8dpmNvJMoRwt27u6yWLSIQzuNjVg= X-Gm-Gg: AY/fxX49EujrK1hAnusjC6UtXVS2kXod8FIYFD7fJW6vybsXogMa6E+HSqm58TGr5Ir 7wl06VRxkwdrwk/9WgHV9J1rXuW8SbR6qy36zXhfshFBEZQpTCZnPmXzCG+Q4N3ULPU9hibluTK anreySSXW0MCLTjsMucIuWDTvG/ecX4BPRkUr9YPreCP+3Kub3CHEYow6pY2+3NIEwSyElZjgeC +qiZ9bRjpH+4Fe18l4B4rgEqV9cZTOrDWX+Lnusywqo90mMUhsW/PgHwVkdMPfNmEOY5i5Xfhsd TIeMcsRNTcgURWc4MXgNHctosuMc3SAQks/4rBg8sA+3PrnZk9rqu7OKx8XFKVfHDAxqp4LTduP +v2xhuI2ziJRatLLs6eS7fldKoxyc8qz6uLjKdEXNAFEmbKnO5W0AMJdmsCU/fN8foF8zYJEqOO bqIRmSP1tUNGnSnQDYzLiDLCRot7frgGVAygTtSMbvyseJLH18PCUBc08thkVWUQ/nBf66n/BQQ 69uy2RYNQ== X-Google-Smtp-Source: AGHT+IGd2yb8Lh+TigEcZp8LwOOGhaNo5nK6cQEpeL5J7doUtoN8Z0uWPDioes/NiDuiaoBlgbg2Ag== X-Received: by 2002:a05:600c:608e:b0:46f:a2ba:581f with SMTP id 5b1f17b1804b1-47d18be1812mr163275705e9.16.1766497844006; Tue, 23 Dec 2025 05:50:44 -0800 (PST) Received: from claudiu-TUXEDO-InfinityBook-Pro-AMD-Gen9.. ([2a02:2f04:620a:8300:4258:c40f:5faf:7af5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d192e88f5sm237921025e9.0.2025.12.23.05.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 05:50:43 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, biju.das.jz@bp.renesas.com, fabrizio.castro.jz@renesas.com, geert+renesas@glider.be, prabhakar.mahadev-lad.rj@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v6 3/8] dmaengine: sh: rz-dmac: Drop read of CHCTRL register Date: Tue, 23 Dec 2025 15:49:47 +0200 Message-ID: <20251223134952.460284-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> References: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea The CHCTRL register has 11 bits that can be updated by software. The documentation for all these bits states the following: - A read operation results in 0 being read - Writing zero does not affect the operation All bits in the CHCTRL register accessible by software are set and clear bits. The documentation for the CLREND bit of CHCTRL states: Setting this bit to 1 can clear the END bit of the CHSTAT_n/nS register. Also, the DMA transfer end interrupt is cleared. An attempt to read this bit results in 0 being read. 1: Clears the END bit. 0: Does not affect the operation. Since writing zero to any bit in this register does not affect controller operation and reads always return zero, there is no need to perform read-modify-write accesses to set the CLREND bit. Drop the read of the CHCTRL register. Also, since setting the CLREND bit does not interact with other functionalities exposed through this register and only clears the END interrupt, there is no need to lock around this operation. Add a comment to document this. Signed-off-by: Claudiu Beznea --- Changes in v6: - none, this patch is new drivers/dma/sh/rz-dmac.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index 818d1ef6f0bf..43a772e4478c 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -698,7 +698,7 @@ static void rz_dmac_irq_handle_channel(struct rz_dmac_c= han *channel) { struct dma_chan *chan =3D &channel->vc.chan; struct rz_dmac *dmac =3D to_rz_dmac(chan->device); - u32 chstat, chctrl; + u32 chstat; =20 chstat =3D rz_dmac_ch_readl(channel, CHSTAT, 1); if (chstat & CHSTAT_ER) { @@ -710,8 +710,11 @@ static void rz_dmac_irq_handle_channel(struct rz_dmac_= chan *channel) goto done; } =20 - chctrl =3D rz_dmac_ch_readl(channel, CHCTRL, 1); - rz_dmac_ch_writel(channel, chctrl | CHCTRL_CLREND, CHCTRL, 1); + /* + * No need to lock. This just clears the END interrupt. Writing + * zeros to CHCTRL is just ignored by HW. + */ + rz_dmac_ch_writel(channel, CHCTRL_CLREND, CHCTRL, 1); done: return; } --=20 2.43.0 From nobody Mon Feb 9 08:49:26 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED88C27381E for ; Tue, 23 Dec 2025 13:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497849; cv=none; b=b8VSZV3Vgd9odP09CzFvlbKAgTLs7XCyEvF6NOu74njQR8iIsP55ROP6AVooLzh5BU9Tb0FEMCrLk9CKUSn3vY49f++acNJVE0C8CoKG425HuqIqKyEWiJYhvK2a8rbmfsSuyhFKX1YnAwLI57UUrFqvUHzeY1ptRlfN2SHvCF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497849; c=relaxed/simple; bh=5ku80iO5mYA9cdkGR8VMlpdrWhksxjs6noDVRuZi610=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qnR6mwsmZrUObBnp1fRuME5vtCwL4onzoNI4j8lclUcgXGN9lKO8VUz3ws3L9OjrwUhboVHRGRd2J71kGaV+ehCh9TlpF7RRfqSZi9dZVnBU1aZ0oIEAGthBQj4LEbp3AvPfj3tKbLLnIZPYOUqFpk7uSrirpKmT3PljEvI3l9I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=YFjoaPTn; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="YFjoaPTn" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-477632d9326so30409625e9.1 for ; Tue, 23 Dec 2025 05:50:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1766497845; x=1767102645; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sZ76Tn6wk+dZFT/1SemDEgh7JP5C0Hyow55JGr1Byus=; b=YFjoaPTnGRE1txaTG3FU1YbxTI7MUocCYSz0YpbEWM+klfH+XCPyGfcA5A5oouoILk YVLlpeWYGqek9Z0o1IAWiCmwUB4mXxEcR+oVJhA3OvJY4FRgrRC3fl5JJd1mYJf0bDz+ eDHpfYQwn3PXffBogxyWVxtvYu0IzXoOtddHM7dHtp9D0vco4Nau4hbzA3296hAMfjPy AiBKMWoyFAuxSk5rX1k/THS7U28lFlDcOvIO1Y/Kav9/jrAw2Tx7LiKsPmz1p3UBC3JI XjUSm1eq9GqE61FuvBQMLCAJPiI39UyoVu3kfCIfMGZLqkLPrHMT77osZimwH1LNpY6E 8Z3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766497845; x=1767102645; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=sZ76Tn6wk+dZFT/1SemDEgh7JP5C0Hyow55JGr1Byus=; b=pv6L6yWojxKD3WqjMVk46j/MchyOMfRpZXQIagHY4YKPDA8qz7/YHDSSOvSMdYcMmH vFIVbkD6df08UGhz8KkHcx7OHkPpRtw9UuazKxZoTZGs5edVD7m0JxZYdRWiYF+glwLb O9TE6WJhTt/L7Ixe7Zw+Xb42zuIl7i79q1coGCRzz3B83uSZ4fiqJ8Q/AceGBRGIsrKT EiW36CoLL9bupK1d5k+/e28QEuTjtAdWL6Qs/yWcNNo5M/rg5mWaWyHaXFQmxzm6pBoX pcqJY+HNy3zkrdx87xU+8EWGBwv8sPbnn5j0+m/okimgU4XvE77/wKto2R0McUWyulTF VuTw== X-Forwarded-Encrypted: i=1; AJvYcCVsrqi8HTp0hB4Bw7B+Anl2OcJRaqqmLL/DId4uyWRY+swyIeSqbhjJ2p5IxMiOIGr+f/Piqt6t6pJbzRA=@vger.kernel.org X-Gm-Message-State: AOJu0Yxqi28OeWkhIBz60EIijoeDKdSZkOAwpKq7UCePxYZQuDXr0UoF ffOgTaQ2iIEAwA3bo/jdm8g1Np+lFy2F2ZevuzORRwiLjAfP9/j10KoGiZFGvQySWRNtMF37lAF aCm6w X-Gm-Gg: AY/fxX5dxhMRW6uNNmGue2bNXamLIVMlJX8GfvcY/eRCu2sK0AlsmBZ7tBdw0dEMK9L ub+LfeFUwn4wNeHy/Xxb2j7TXI1Mys5MfDcOvga8C7Fjf7opIrpgeskzi04PqYJs1yHwmTlGXbI Gf3k9MW8Qv7fPa6UAoYOvMYPLyGXZalb4ISXWRQ0ez/ROe/kQJoP+87d1889EsgbRhnnDKifQZY K82eVdkUSp0bKjivaoBS0UdaJXHuql0Yc7QcdYOk7EBHcBiLBCGrlJWgu4kDcqAwZ7ClKAu80FE 54xFxqnrJZS0BW4v17qDcUbWzZ6lZVCQCXuGn0e0IiroUg8t2qzFyR05udLpM0rwE/HorCKlbho pd+1Cp/S3+yNy1e7wIpTAyE9MLvihdcnD2RTNwWBPaZXU3NhfXXDOONwH1/KpryntFqbDcZbTOA e3Z5O7xrIwIHJaadS4TgIl/YzM+anmGOssdWDBvh4DWFhIgeuJqkGmY1yFWVkMFx7ELfR+2Lo= X-Google-Smtp-Source: AGHT+IFDCAPdLr0O9RM7rEnukky+OXqXM8/fNRsKzq2gxBjZCuBFZjoGflG+jDSFEXGrOkphHeoAPg== X-Received: by 2002:a05:600c:444b:b0:477:557b:691d with SMTP id 5b1f17b1804b1-47d1959fa3emr139050755e9.25.1766497845376; Tue, 23 Dec 2025 05:50:45 -0800 (PST) Received: from claudiu-TUXEDO-InfinityBook-Pro-AMD-Gen9.. ([2a02:2f04:620a:8300:4258:c40f:5faf:7af5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d192e88f5sm237921025e9.0.2025.12.23.05.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 05:50:45 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, biju.das.jz@bp.renesas.com, fabrizio.castro.jz@renesas.com, geert+renesas@glider.be, prabhakar.mahadev-lad.rj@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v6 4/8] dmaengine: sh: rz-dmac: Drop goto instruction and label Date: Tue, 23 Dec 2025 15:49:48 +0200 Message-ID: <20251223134952.460284-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> References: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea There is no need to jump to the done label just to return. Return immediately. Signed-off-by: Claudiu Beznea --- Changes in v6: - none, this patch is new drivers/dma/sh/rz-dmac.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index 43a772e4478c..a2e16b52efe8 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -707,7 +707,7 @@ static void rz_dmac_irq_handle_channel(struct rz_dmac_c= han *channel) =20 scoped_guard(spinlock_irqsave, &channel->vc.lock) rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1); - goto done; + return; } =20 /* @@ -715,8 +715,6 @@ static void rz_dmac_irq_handle_channel(struct rz_dmac_c= han *channel) * zeros to CHCTRL is just ignored by HW. */ rz_dmac_ch_writel(channel, CHCTRL_CLREND, CHCTRL, 1); -done: - return; } =20 static irqreturn_t rz_dmac_irq_handler(int irq, void *dev_id) --=20 2.43.0 From nobody Mon Feb 9 08:49:26 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69D2C2989B4 for ; Tue, 23 Dec 2025 13:50:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497850; cv=none; b=eMhDPtLGWk15Sjb1/RDNXW9oPuycsi2wFQ7drvS7LXs61Fxh0793U0ehkHJ0Kpi+oe1Xp8I+Wfkg7b3a7Bo9FvqBIvM+Vn0ps0qgam9XWYB8p11WTB3GqkfXjSRilCRp2xLXf2sOV1Efldp1FE2ySqgqG8dRcoz916WZLviOK3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497850; c=relaxed/simple; bh=Km1aZNVXUokGZG+Hi3ebns4lEQqHpnqjkOASGrRxGsQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iRozbdb1RZa/qopp0uIs6fC6M4EpuetECBhlHvIL+FiZOiLhvofLlm6bNDedDT9Y80bcaZnwHGc9e4MsPy/qtV2cPwJZgfutJ9Itx3/uuf1w2ISxGcgrbX/iXc3c3T2Dm4jbrg0AByXh9eAaqECC5cx2Quc+n9yg+tNtHMFVpCo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=Ls9qBBIA; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="Ls9qBBIA" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-477a1c28778so57505635e9.3 for ; Tue, 23 Dec 2025 05:50:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1766497847; x=1767102647; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1Kc5eyb/iSkZT0bPBeQBdO3AtAfI/oXN1kmysUx4qCE=; b=Ls9qBBIA9EBJHuMbc90vpQVDt8CG7u6wfE48DnHEZ2dkDbUd1pZ+p2CF/XjdACDAcq 2N8aqwCuSqg6SdNALnz9JDRyKcPzH8OZhg+C5Fr4valnI57OF3gk3OJBrVfsGNhyoWO+ jzTa3WScoBI05q7QQ/IGK+7Mnol08DJ1JpIabzSvtbqlrRkXa8GPDQOWPSsfShvGX7zs tyWhNfdWSXHUKyCYX1X5IEGbKk4QU6PokaP/siqIwmkNJP/qAxJev7Mpgo9yZ9ELRFqa RJTx5OslcdOpd4CfJvk8kiodGOfaGfod+mFAlPUZiiJUqJCuLv0rBHskMQ3iCbhqDUgb RoRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766497847; x=1767102647; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=1Kc5eyb/iSkZT0bPBeQBdO3AtAfI/oXN1kmysUx4qCE=; b=pXBiJocBlapj416kjlyoSywo0qq5LeAR2zDCMfMidbKVbUChny/gdfQ/U7syvMjZWn 7kYE6XRuRVZzN2aAVZvwEUzQqmPRMpcVDIF29RuS2HZjWCAD4B0FsHADYuY+tqXjAiU5 ewqC4+UfgdP2HDtVWvBRTPEtWEFwCmyqcejHKLVuFzfu6DxaWZf4A9P60WUDueW+RVKh SG4iC/+c1yHGQJzyMesfMHNlcD7023zrsdkRKqf1d1f3r2GdCbzOo1ASM9CS8cKiVke4 8opxbXceUSggdEo7Geve54c/n22H3DMzN1bWEvY7uNqR2K552jMcq0Ep6hwMMsl7euRx jhXQ== X-Forwarded-Encrypted: i=1; AJvYcCWS3vEVeDkJIlnwat76J7JOhoedbUSxqtRpOgEqrzioVvdF1zX6oJ3CrOZqVY3RtCboCJH/rPqxIlUtrSQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyGo+DJ5J8Y2AiIyZD7CNpjQZqy92re1EzVlLCLdlSXBXY4pHC/ VQJpRfY3KB6+sqPwOhqENDlQtWHX+RgEpOsurBIoUYo+17ARy786RJqKAhfU2kyTCbE= X-Gm-Gg: AY/fxX5DY4X8Ylwnw11zQHUbZKaPc4b577s8XLYt49qoZT1vnO7y9myn03xJaB0awWc oTIuEq+paFDdG6OeJxe14GfjDZmuFKwAgEVEPSyzUGYGd/H6ZRlhWl6HuUnPleqhJETOaqdnzTG 2BHIU7n7shOetWiExdSIwdOw7IbsmUXnJ1cSPadJoh8U2O9VNB6qxe4Ca6W85DDNmHskPbQteaC owvuLjgfEqxsr8xYL8wY7jJAJy0LuesJJu0OaRSvs6Mv02s/XWSHRkhTto587RoTMhEduhCxQq4 PjK45W2apyj+1b+q9wkV99Hh0yYipPp60SCwvjEkxvdldxDPazdsHYWaD3RAKipDt/DnD6tVliH nQb2dK9SHQnsMZLofm7jK9QUksPp4prBPwOnA27A2qzoPwcCiBtfZjFshYOYax3yA3PEpcdAY21 0ME9heoVhlbEco1HplefwJDOf2XtF6jFHiuKpMTOwJ//NR7JTm0vYSTRs7wIRO+hmQJG5MRL4= X-Google-Smtp-Source: AGHT+IGuFz7Ozy02JtIIyMczbxKNk13M+AOoYfGj2cgq2MPwqq4wKAu3fvsA2DoiHSohIMc2z2Wxuw== X-Received: by 2002:a05:600c:524f:b0:477:b642:9dc1 with SMTP id 5b1f17b1804b1-47d19594b2emr132953945e9.20.1766497846787; Tue, 23 Dec 2025 05:50:46 -0800 (PST) Received: from claudiu-TUXEDO-InfinityBook-Pro-AMD-Gen9.. ([2a02:2f04:620a:8300:4258:c40f:5faf:7af5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d192e88f5sm237921025e9.0.2025.12.23.05.50.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 05:50:46 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, biju.das.jz@bp.renesas.com, fabrizio.castro.jz@renesas.com, geert+renesas@glider.be, prabhakar.mahadev-lad.rj@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v6 5/8] dmaengine: sh: rz-dmac: Drop unnecessary local_irq_save() call Date: Tue, 23 Dec 2025 15:49:49 +0200 Message-ID: <20251223134952.460284-6-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> References: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea rz_dmac_enable_hw() calls local_irq_save()/local_irq_restore(), but this is not needed because the callers of rz_dmac_enable_hw() already protect the critical section using spin_lock_irqsave()/spin_lock_irqrestore(). Remove the local_irq_save()/local_irq_restore() calls. Signed-off-by: Claudiu Beznea --- Changes in v6: - none Changes in v5: - none, this patch is new drivers/dma/sh/rz-dmac.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index a2e16b52efe8..72ec42fedac6 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -267,15 +267,12 @@ static void rz_dmac_enable_hw(struct rz_dmac_chan *ch= annel) { struct dma_chan *chan =3D &channel->vc.chan; struct rz_dmac *dmac =3D to_rz_dmac(chan->device); - unsigned long flags; u32 nxla; u32 chctrl; u32 chstat; =20 dev_dbg(dmac->dev, "%s channel %d\n", __func__, channel->index); =20 - local_irq_save(flags); - rz_dmac_lmdesc_recycle(channel); =20 nxla =3D channel->lmdesc.base_dma + @@ -290,8 +287,6 @@ static void rz_dmac_enable_hw(struct rz_dmac_chan *chan= nel) rz_dmac_ch_writel(channel, CHCTRL_SWRST, CHCTRL, 1); rz_dmac_ch_writel(channel, chctrl, CHCTRL, 1); } - - local_irq_restore(flags); } =20 static void rz_dmac_disable_hw(struct rz_dmac_chan *channel) --=20 2.43.0 From nobody Mon Feb 9 08:49:26 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6C0629D275 for ; Tue, 23 Dec 2025 13:50:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497852; cv=none; b=RNtMbdcGI7/K92EJsQlerVH1zfevup4ZQ6UrLWrTIiYfWObd7DMR/IxiUE1yhdGEhh9X7rhDydWuv39c+GamEY/RtFmzZQt2DOPZ8OdW+otoEnfTx8zEsvUUTOD4hOHTfFuSq+zbNvYdi769VQV7E9IRPqwkctlr1FGe0w7w994= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497852; c=relaxed/simple; bh=/aqSn+Vb8r0d6N9C+LFafAX/mCxT084ZgLbgcXEVgTk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uXpjnqCc512oHiaeMcgvEJI7HSk0cjkbGuQT3nt912KY8OOyxvh9YBqacNP3nWnnGP4HqDMzfDxT3OPU4rTfbG8wvTXkWQAY+TzXtsNdp7NkEt2VgLINpRv++/MCpQNGeAY5COCOvdRC/8iK5j6WeYN2g6ykKnILdMFe4wZTdzY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=I540loXS; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="I540loXS" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-47795f6f5c0so28141735e9.1 for ; Tue, 23 Dec 2025 05:50:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1766497848; x=1767102648; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eKcT1GmUyDCROsSAK1ZbDjoO1xH25TSzA+fFNjS21cI=; b=I540loXS2C5Qk0ZsH0dnjtWRZXYuj/daMYqC+UKqGAf/j0uBCZYfm8WsU+86CcSLS8 9N2mcf7SvYo1jQrwzXnlLwq9pgX3AlrUNZONXORHeFl42BaGIEQGUrqK9f5GuXiH8Qje AtHnRWZDcQb18rixgALQJGEYqT/gI/Uv0ZbkcMu1llI3zDEGgUI5PmsRfVra4qNe4N7U +gEMf+rVZ7oFlbFUNSAJ+Z4Dqx1K6vTwtpK44vrO8qk5niPgcs1T5nTWG0jRN1wYgku0 jo3eXL/NEBp4OtjCfFlb9xQeCryh6n5uxtFMdbUO+n71bJzlvmVW2yf93j1b57zcEO/f blXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766497848; x=1767102648; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=eKcT1GmUyDCROsSAK1ZbDjoO1xH25TSzA+fFNjS21cI=; b=SE9YmbvU9psTL7olpJJ4uWJXWPY3bQJIeTq6TT4NKDzdxsAe+3TJ/+53GCW4WweAXB ZbHG54RBSszX3ZEX84OacVvF9Lk7jr7YsfFv5/OnkVEz/FbkoqD2SRcpPjDGPyHFF7zd kBQZHyZDtWpNYFyRMIlgWsViQAujWo3B+Vg4ALEw5ieLW7xskevV6smX69d+mEYxEHtX 0S/22ylsO2sYtOBtvBDvOMBPBN4DbgScPpx6sOjAvgHGhTuZyvU4hOSnzGqZoorosUBj fdBO8j8SW4NVCwXAz2feXpMX/YDH8/VhQOUjNl4qZjgnjeSdYkGYAzT/PFV/E+MIqN0s cZ7A== X-Forwarded-Encrypted: i=1; AJvYcCX/RVo2ZpW9ltPecJOorB92ZX0buO6VzryxgC2FAag35cG3DWvSoGG9+l9bZxzQhHy2rl0am4TMVIxz+XU=@vger.kernel.org X-Gm-Message-State: AOJu0YyQZc9/PCvAcLlrFdEUslTinAPXTYUesNIY+y4dMsdlWqpK5csV q8390XMmVYa0/B9wKbTjGnjHvCkVcBCG62+TFgydX9xyepw4f9dZAOgWdwdTeZ+4/bw= X-Gm-Gg: AY/fxX4q/u739TEEnwS53f8n1gnk47kFp6J2TIcA2kDYXURBWFohB1pSmUxiAxr8P+h oxI6KnkIxv+pyhTqRBoOZoIuhEDJQ1WcnX/NuSwBx/BK0u+NLJeCPj2uFnYZa2AYiNXdCzLej49 5/KuPFi647fo9/FYm6wpJ4GyBsVSLCBPN4GUXg+NLCfMZ+ru4KTo47LlDFf4PJ5NRfRUTsOR2M8 9FK/PhwdMDzPwqpWMaXWxgJyE358gxGrD0TWP8Xs5M4R/KYowR5yl6gLQLASrQVGRiai9vEj4l6 F0JfhVR7qZoVUQw38+WFSt7UUuXfpGwcI5ymkODijc6nq3XgPIVaAudqH8auCM3M+8d3fTna4WN oWMSxZrR0vpXl9BWHQhVNMnvFFlwUzonv1Yj42qTlf2S8+veu2K7fiUr2b7oAXGsn95hkdnCvOF DkvRZjH9MzfwEex78x2hw3wlVdt7ICaVZft9LU4iwoo8QpiBK/jDcbiaMW0ZpexvDQYP3ciMr4g T/4qkyxag== X-Google-Smtp-Source: AGHT+IFmeB9K3I/MQkOzb05XFK52brMWDg6nvkajGCk7Ev/65dM++m5feqWnaI+T5jfjg6XqmfjKig== X-Received: by 2002:a05:600c:c0d2:20b0:477:89d5:fdb2 with SMTP id 5b1f17b1804b1-47d1c4d78b4mr98877005e9.14.1766497848094; Tue, 23 Dec 2025 05:50:48 -0800 (PST) Received: from claudiu-TUXEDO-InfinityBook-Pro-AMD-Gen9.. ([2a02:2f04:620a:8300:4258:c40f:5faf:7af5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d192e88f5sm237921025e9.0.2025.12.23.05.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 05:50:47 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, biju.das.jz@bp.renesas.com, fabrizio.castro.jz@renesas.com, geert+renesas@glider.be, prabhakar.mahadev-lad.rj@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v6 6/8] dmaengine: sh: rz-dmac: Add rz_dmac_invalidate_lmdesc() Date: Tue, 23 Dec 2025 15:49:50 +0200 Message-ID: <20251223134952.460284-7-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> References: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Biju Das Add rz_dmac_invalidate_lmdesc() so that the same code can be shared between rz_dmac_terminate_all() and rz_dmac_free_chan_resources(). Based on a patch in the BSP by Long Luu . Signed-off-by: Biju Das [claudiu.beznea: adjusted the commit description; defined the lmdesc inside the for block to have more compact code] Signed-off-by: Claudiu Beznea --- Changes in v6: - none Changes in v5: - adjusted the commit description - defined the lmdesc inside the for block drivers/dma/sh/rz-dmac.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index 72ec42fedac6..45c45053e9df 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -250,6 +250,13 @@ static void rz_lmdesc_setup(struct rz_dmac_chan *chann= el, * Descriptors preparation */ =20 +static void rz_dmac_invalidate_lmdesc(struct rz_dmac_chan *channel) +{ + for (struct rz_lmdesc *lmdesc =3D channel->lmdesc.base; + lmdesc < channel->lmdesc.base + DMAC_NR_LMDESC; lmdesc++) + lmdesc->header =3D 0; +} + static void rz_dmac_lmdesc_recycle(struct rz_dmac_chan *channel) { struct rz_lmdesc *lmdesc =3D channel->lmdesc.head; @@ -456,15 +463,12 @@ static void rz_dmac_free_chan_resources(struct dma_ch= an *chan) { struct rz_dmac_chan *channel =3D to_rz_dmac_chan(chan); struct rz_dmac *dmac =3D to_rz_dmac(chan->device); - struct rz_lmdesc *lmdesc =3D channel->lmdesc.base; struct rz_dmac_desc *desc, *_desc; unsigned long flags; - unsigned int i; =20 spin_lock_irqsave(&channel->vc.lock, flags); =20 - for (i =3D 0; i < DMAC_NR_LMDESC; i++) - lmdesc[i].header =3D 0; + rz_dmac_invalidate_lmdesc(channel); =20 rz_dmac_disable_hw(channel); list_splice_tail_init(&channel->ld_active, &channel->ld_free); @@ -556,15 +560,12 @@ rz_dmac_prep_slave_sg(struct dma_chan *chan, struct s= catterlist *sgl, static int rz_dmac_terminate_all(struct dma_chan *chan) { struct rz_dmac_chan *channel =3D to_rz_dmac_chan(chan); - struct rz_lmdesc *lmdesc =3D channel->lmdesc.base; unsigned long flags; - unsigned int i; LIST_HEAD(head); =20 spin_lock_irqsave(&channel->vc.lock, flags); rz_dmac_disable_hw(channel); - for (i =3D 0; i < DMAC_NR_LMDESC; i++) - lmdesc[i].header =3D 0; + rz_dmac_invalidate_lmdesc(channel); =20 list_splice_tail_init(&channel->ld_active, &channel->ld_free); list_splice_tail_init(&channel->ld_queue, &channel->ld_free); --=20 2.43.0 From nobody Mon Feb 9 08:49:26 2026 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6930A2D7DE1 for ; Tue, 23 Dec 2025 13:50:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497854; cv=none; b=S0k4Pl0s3rJC7Qd6aMobrJa852bjz64/XMk57UbGwFeJLnwSJcTJ63U06EgDLZcLZa07WsDMs4Fl/eOsi0hcJwKkG6bmWgd6RiRgfhuu8UBvD5Lyh0qhTn33OyOdhRY7Om9OZsiMnvSly2YfW9qBKxFwD4Nvn/pp3mKwqT2uzxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497854; c=relaxed/simple; bh=V2j30uJzU9iGi0tcofb7kdtfANNgwgeTb2rJjoOkv6s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KUkP7PDldP4SXUJeXD0SagqE2rdTnmX5TroIY7iQMj1GjIH34K1QgHitaqHaFFwDZl4zdWUcor6zlyDFrVFnm72OcIgyBZ/uj9HO3/rz7x+ORWUKVMfd3+PgO6feF2rcRIu140lJ6n0PwWTfYgLN2ETfWbGOplWJB68iJLAbiCI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=dj6l5f7A; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="dj6l5f7A" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-47bdbc90dcaso33192195e9.1 for ; Tue, 23 Dec 2025 05:50:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1766497850; x=1767102650; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wwIfRwPlxJ4dUOA9CK0cEGyokIF+zsSw+S+9qTH5zlc=; b=dj6l5f7AFsff3vv3MaGhjDVU6md76azkNckHP4p9o3i7gUhdOGnbu9i73AvFmfpAi4 w1TcKiqAJ7V8AquS5GFH5aiRVfjQzYRgIfS9YR/he+2jVNzsfkYY7NgvOeCgKnVJz51X pXhN/Y9gyfApMGX3dlcnlW5bEk4fzie1bbu8QcGoTv2Y/MHAbNcgtvYStx6SzXWIXDTQ 8/EmZzWT0FFl8Be9RXKISFaUySDiw3e9kmigiY+6epTfvbi+YoNMkD3XE/b1VCpKGnTR axt5Ikzy3S76Tqsiip2oOAQzFqR2ETBcas/9B+NBDALhej+tx046pMnyssnMMygpduDJ C2GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766497850; x=1767102650; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wwIfRwPlxJ4dUOA9CK0cEGyokIF+zsSw+S+9qTH5zlc=; b=Trpvhq0n4VF6n+C8+GD7U/klGThh/SWfZ/4RurKftcj0gK1ldByO6sL34KB3sc4qBa GpVCSum8ThZqpmo3obPRheEJXVMpzUw+jMmvcDBtmMMJfB8YsJeM578gdeUc4BXPQxoR P7eKYaRrCxEeHya6DFSENDhTPdJMWV+K24KNxV+riIeqxJfvRoaE0hWp9w7v3+zyei2v QgPo1ZDqRdT59aVz4vOdOFKxwAV7mtAmTfr5qMhrVIFOXUHTOwissP8QPUsZlYI77Jc0 y4Ihbk/tkeK4nPnI1hU6cMlak9Eartf/LfQzgno63qG1L76MRcuMjmh6qkc4agbNOHMp t1jA== X-Forwarded-Encrypted: i=1; AJvYcCWSRHmL9ygYdymDsaKBaY/JZSmswOidZSr/ia+PcO7DCFJqmBJWVcRXwh5nEfxWfNmGFBsKBlXY5NQqRsU=@vger.kernel.org X-Gm-Message-State: AOJu0YyNCAvnXDO/xQ9Yc1usghQjWE+BAvUE9306zvOfTLgjXkfn3rTK fI6DHNJ12FzURJvnnmDDXIiU3skPwv27f0JnJeWbnqjH+B/NmJMrLk5uKlxikXHewVs= X-Gm-Gg: AY/fxX4pMKQ9q8+6KX9nJYHQ+BM9AzrGFo9hFCxSwxAxUhKnc21KHXsvEc+hrrBbCeG JycYASSSxzSN9/lm+FVxJMZK1CWaCZJLEGIBpX8JVVLnOKRct++HMaVk3luF6WxmEmZTYr0l6sU xtBYvRE+85TK0xzJEuRMP1lGjFkwUe1RPk+zrHrANJ/pt6O4eZFc8cWK2F3ztV0/9HrARChBeKa qwZmXk4GRuohzRZpQEypXhrbRQP6SL5OddYYAo46RT2LH43lz2/F9WiGTG/OnMRhtwTjWI2fN2Q C65SZmWBCoQ/SvSeNv2IJz7e01Z4lXkXatdwZk5mER1BYLBfQL/TcOP1rLQWdnKWNZ/z3sruPY1 yxLaVp/+QLYyTgJDFVD/24rRxmSuIk6r62zoo7LSOozEf+/yc8Wn0bKjFZR0YHjG1MLU0SLqqdQ MEBtPQ01ry+GEXUX3D7ROqx1t7s03IoPpbyWKK0VyZ++MMNZvG/iH4mFFqWzkToPwE9GrPTWtph aEZpWfP9g== X-Google-Smtp-Source: AGHT+IGpYksT8judEEY1zEyXam/PhoR55JNkEaNhLWS8xcqxEg/9LOK2xzEcnGWU/7o70HLlvIufAQ== X-Received: by 2002:a05:600c:4595:b0:477:a1a2:d829 with SMTP id 5b1f17b1804b1-47d1953ead3mr144045255e9.13.1766497850257; Tue, 23 Dec 2025 05:50:50 -0800 (PST) Received: from claudiu-TUXEDO-InfinityBook-Pro-AMD-Gen9.. ([2a02:2f04:620a:8300:4258:c40f:5faf:7af5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d192e88f5sm237921025e9.0.2025.12.23.05.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 05:50:49 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, biju.das.jz@bp.renesas.com, fabrizio.castro.jz@renesas.com, geert+renesas@glider.be, prabhakar.mahadev-lad.rj@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v6 7/8] dmaengine: sh: rz-dmac: Add device_tx_status() callback Date: Tue, 23 Dec 2025 15:49:51 +0200 Message-ID: <20251223134952.460284-8-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> References: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Biju Das Add support for device_tx_status() callback as it is needed for RZ/G2L SCIFA driver. Based on a patch in the BSP similar to rcar-dmac by Long Luu . Signed-off-by: Biju Das [claudiu.beznea: - post-increment lmdesc in rz_dmac_get_next_lmdesc() to allow the next pointer to advance - use 'lmdesc->nxla !=3D crla' comparison instead of '!(lmdesc->nxla =3D=3D crla)' in rz_dmac_calculate_residue_bytes_in_vd() - in rz_dmac_calculate_residue_bytes_in_vd() use '++i >=3D DMAC_NR_LMDESC' to verify if the full lmdesc list was checked - drop rz_dmac_calculate_total_bytes_in_vd() and use desc->len instead - re-arranged comments so they span fewer lines and are wrapped to ~80 characters - use u32 for the residue value and the functions returning it - use u32 for the variables storing register values - fixed typos] Signed-off-by: Claudiu Beznea --- Changes in v6: - s/byte/bytes in comment from rz_dmac_chan_get_residue() Changes in v5: - post-increment lmdesc in rz_dmac_get_next_lmdesc() to allow the next pointer to advance - use 'lmdesc->nxla !=3D crla' comparison instead of '!(lmdesc->nxla =3D=3D crla)' in rz_dmac_calculate_residue_bytes_in_vd() - in rz_dmac_calculate_residue_bytes_in_vd() use '++i >=3D DMAC_NR_LMDESC' to verify if the full lmdesc list was checked - drop rz_dmac_calculate_total_bytes_in_vd() and use desc->len instead - re-arranged comments so they span fewer lines and are wrapped to ~80 characters - use u32 for the residue value and the functions returning it - use u32 for the variables storing register values - fixed typos drivers/dma/sh/rz-dmac.c | 144 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 143 insertions(+), 1 deletion(-) diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index 45c45053e9df..44f0f72cbcf1 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -119,10 +119,12 @@ struct rz_dmac { * Registers */ =20 +#define CRTB 0x0020 #define CHSTAT 0x0024 #define CHCTRL 0x0028 #define CHCFG 0x002c #define NXLA 0x0038 +#define CRLA 0x003c =20 #define DCTRL 0x0000 =20 @@ -685,6 +687,146 @@ static void rz_dmac_device_synchronize(struct dma_cha= n *chan) } } =20 +static struct rz_lmdesc * +rz_dmac_get_next_lmdesc(struct rz_lmdesc *base, struct rz_lmdesc *lmdesc) +{ + struct rz_lmdesc *next =3D ++lmdesc; + + if (next >=3D base + DMAC_NR_LMDESC) + next =3D base; + + return next; +} + +static u32 rz_dmac_calculate_residue_bytes_in_vd(struct rz_dmac_chan *chan= nel) +{ + struct rz_lmdesc *lmdesc =3D channel->lmdesc.head; + struct dma_chan *chan =3D &channel->vc.chan; + struct rz_dmac *dmac =3D to_rz_dmac(chan->device); + u32 residue =3D 0, crla, i =3D 0; + + crla =3D rz_dmac_ch_readl(channel, CRLA, 1); + while (lmdesc->nxla !=3D crla) { + lmdesc =3D rz_dmac_get_next_lmdesc(channel->lmdesc.base, lmdesc); + if (++i >=3D DMAC_NR_LMDESC) + return 0; + } + + /* Calculate residue from next lmdesc to end of virtual desc */ + while (lmdesc->chcfg & CHCFG_DEM) { + residue +=3D lmdesc->tb; + lmdesc =3D rz_dmac_get_next_lmdesc(channel->lmdesc.base, lmdesc); + } + + dev_dbg(dmac->dev, "%s: VD residue is %u\n", __func__, residue); + + return residue; +} + +static u32 rz_dmac_chan_get_residue(struct rz_dmac_chan *channel, + dma_cookie_t cookie) +{ + struct rz_dmac_desc *current_desc, *desc; + enum dma_status status; + u32 crla, crtb, i; + + /* Get current processing virtual descriptor */ + current_desc =3D list_first_entry(&channel->ld_active, + struct rz_dmac_desc, node); + if (!current_desc) + return 0; + + /* + * If the cookie corresponds to a descriptor that has been completed + * there is no residue. The same check has already been performed by the + * caller but without holding the channel lock, so the descriptor could + * now be complete. + */ + status =3D dma_cookie_status(&channel->vc.chan, cookie, NULL); + if (status =3D=3D DMA_COMPLETE) + return 0; + + /* + * If the cookie doesn't correspond to the currently processing virtual + * descriptor then the descriptor hasn't been processed yet, and the + * residue is equal to the full descriptor size. Also, a client driver + * is possible to call this function before rz_dmac_irq_handler_thread() + * runs. In this case, the running descriptor will be the next + * descriptor, and will appear in the done list. So, if the argument + * cookie matches the done list's cookie, we can assume the residue is + * zero. + */ + if (cookie !=3D current_desc->vd.tx.cookie) { + list_for_each_entry(desc, &channel->ld_free, node) { + if (cookie =3D=3D desc->vd.tx.cookie) + return 0; + } + + list_for_each_entry(desc, &channel->ld_queue, node) { + if (cookie =3D=3D desc->vd.tx.cookie) + return desc->len; + } + + list_for_each_entry(desc, &channel->ld_active, node) { + if (cookie =3D=3D desc->vd.tx.cookie) + return desc->len; + } + + /* + * No descriptor found for the cookie, there's thus no residue. + * This shouldn't happen if the calling driver passes a correct + * cookie value. + */ + WARN(1, "No descriptor for cookie!"); + return 0; + } + + /* + * We need to read two registers. Make sure the hardware does not move + * to next lmdesc while reading the current lmdesc. Trying it 3 times + * should be enough: initial read, retry, retry for the paranoid. + */ + for (i =3D 0; i < 3; i++) { + crla =3D rz_dmac_ch_readl(channel, CRLA, 1); + crtb =3D rz_dmac_ch_readl(channel, CRTB, 1); + /* Still the same? */ + if (crla =3D=3D rz_dmac_ch_readl(channel, CRLA, 1)) + break; + } + + WARN_ONCE(i >=3D 3, "residue might not be continuous!"); + + /* + * Calculate number of bytes transferred in processing virtual descriptor. + * One virtual descriptor can have many lmdesc. + */ + return crtb + rz_dmac_calculate_residue_bytes_in_vd(channel); +} + +static enum dma_status rz_dmac_tx_status(struct dma_chan *chan, + dma_cookie_t cookie, + struct dma_tx_state *txstate) +{ + struct rz_dmac_chan *channel =3D to_rz_dmac_chan(chan); + enum dma_status status; + u32 residue; + + status =3D dma_cookie_status(chan, cookie, txstate); + if (status =3D=3D DMA_COMPLETE || !txstate) + return status; + + scoped_guard(spinlock_irqsave, &channel->vc.lock) + residue =3D rz_dmac_chan_get_residue(channel, cookie); + + /* if there's no residue, the cookie is complete */ + if (!residue) + return DMA_COMPLETE; + + dma_set_residue(txstate, residue); + + return status; +} + /* * -----------------------------------------------------------------------= ------ * IRQ handling @@ -1016,7 +1158,7 @@ static int rz_dmac_probe(struct platform_device *pdev) =20 engine->device_alloc_chan_resources =3D rz_dmac_alloc_chan_resources; engine->device_free_chan_resources =3D rz_dmac_free_chan_resources; - engine->device_tx_status =3D dma_cookie_status; + engine->device_tx_status =3D rz_dmac_tx_status; engine->device_prep_slave_sg =3D rz_dmac_prep_slave_sg; engine->device_prep_dma_memcpy =3D rz_dmac_prep_dma_memcpy; engine->device_config =3D rz_dmac_config; --=20 2.43.0 From nobody Mon Feb 9 08:49:26 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89D382C0F7E for ; Tue, 23 Dec 2025 13:50:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497855; cv=none; b=m0ohpp60GeRmj8KEGJU3frE99sFA6rNb12JdVS9wHziLiYXH4FoywDoKqbHtOTM8Aq/eeWFeMwJgfLZmy2lfezZWR7Z6p1D6cEEAtR5zrwdL1czyEElAUfu6YZikal7aW77pQxM+oyMILWLZgQF+T2FQSeiFgMUSF7apIGeaUaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766497855; c=relaxed/simple; bh=y8JjTRWJmfiv2OxDGhF68Hgb5xnCNX77wcUy8YnPBmo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NZ2yfG0mjsnn4cHqdGlHjn2AVNJTQPTRwbJOcqkJHP8Nnyv+4RPOu1oH9h81FTlvEjyMkHKJsxn15EiJ2Ve+UqF2yf/fKySnfzmg97uYQMKdt1Ovalp3S26HYhYsdQpYmc89P2PB/fMXcCy93O+aGsQ9slXq2hrFPrBW8cK0dso= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=IWR/Qf+v; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="IWR/Qf+v" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-47795f6f5c0so28142185e9.1 for ; Tue, 23 Dec 2025 05:50:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1766497852; x=1767102652; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MKrJmDMIWUzrtkIZ/VCoAjqFFgEwqOpXrTNpw0HEcIU=; b=IWR/Qf+vswDEYlcbqykJfwup+TswyGwHp9OYPTATrV6uHPxiqKMO+DQAWcTey3Ndsx 1ed9lH7Rx1l2oZoy9YwkNXjDyhOMhHGHxy45QemWEb3Y+AakZnYQ7YFa68OpTwGKR+zK RerIctryvhbkaTllryO1is0uxkPQJOquOaCMtKC/3WbfnWlQtd2YUDyHKyXJfZEdhRIi mBMkMT/kUplTBFBJJOndQxduB2x6K4DJTrc1BGqzItFuuVfDDeIQqgL/wJQLyENr+9zF QYAJ4HIMTPakQ4PvLNxJwy3HG/qycTYFnn1uACg/69uToMK+gH7SAn0RECUY1sNbe0my hp9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766497852; x=1767102652; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=MKrJmDMIWUzrtkIZ/VCoAjqFFgEwqOpXrTNpw0HEcIU=; b=wiPp/vgPwj9qf+siasVjFRDRinjYjVd26R0HYnoIK9RxlqZm1OhskJbhmwCFDHOUli kGcGaylcrf/ew/bxjo0sMtnv7AM4H5iLAOEJhqPXPbKUKW4Zz3vpgjp5oiqARg6V+94U amzgLxvKmUTqA3+v0+f5jPBnzHA1H3b8d9l1Sb+k1zIwSPeoX6EIuqFGdrg4ibOwMAmp /7Ztw2key+n2oSt+fLXbsa+S5Wm3RCTS81JdXgRfgzp9/c28FTPL+DYd6ju/vfIyolRj KW1ZVk+dEg0XmhPuf8A7EGKbBNahl50bCAPKCRVwSIY4lLGqHeyHz6nxSDsj3N+3vz14 9e2w== X-Forwarded-Encrypted: i=1; AJvYcCXMfUh2O9gWjBykCdym4LY7isDbJbsW0IVOI2GHuASLPNx3ATpBRBo1ZfSrw1cbo/wn4a8bX35UCY04oO0=@vger.kernel.org X-Gm-Message-State: AOJu0Ywb4bF9g5c6I2GwJDGSaWbl+gEiIZzIh/5peuhuDNg4TH1KHKw+ asjOHjLa+6SW3Bf6TD3RwRG0fdzpLabbVp6XBeDciY/MPGZkPNcDVjZ3fgLG/ff0Lpg= X-Gm-Gg: AY/fxX77bggou5DU6QqGux50sv+kMEtsgtQXX0wCKpzeUKu/njcY7Wfq2kdCx1SPRNp /dr4jFKQE7XwsjqF8d73N0PB3exSXqiSIzlKLfLSe4HIqzCj5Rv6KRC1njrA4xpeDKym9kJgTQO DA7/EEzXt07RCvLoSxfx/Z3rrfL1Crkhd0EyTYWhJnWthf7LOG/WkOr5fsuTW20NqVnLovW5weW K4Lfuusw6iTzAaCXvstR3veo2z2CuFRbxT2Vj29GNmG5BlPnDrjQXMe9qnmJtCshp64/XVoLHNq NVheFbTQspOVc+t7gkg/YWT6ht5g8Imvs5yOEGNFPKkGJw51T7UWNAbxK3mqHB8fhS7orWA4ZBP v3cF3NvYtrZ/q1p4MSZwjUb8Edeed9Qy3uVH2WrLxIj3SBA2s4T5XiwZOKWzwMMJ+SzIf5WRjYY QAXtrrIrfByIJZqoeaPRyO2si7OtXwRHUqb8sdrVn21F0J5Ctf35hgFxxwWB3LBVmatwdNjYz0P 8dhaidw5Q== X-Google-Smtp-Source: AGHT+IEWWB84HrNYbZE5+pBtM/5LWAW0LB7tSxaP0PIQtlfFAdxXlXvqkqVb7M10LhvThrKsgAGDJw== X-Received: by 2002:a05:600c:c0d2:20b0:477:89d5:fdb2 with SMTP id 5b1f17b1804b1-47d1c4d78b4mr98878225e9.14.1766497851867; Tue, 23 Dec 2025 05:50:51 -0800 (PST) Received: from claudiu-TUXEDO-InfinityBook-Pro-AMD-Gen9.. ([2a02:2f04:620a:8300:4258:c40f:5faf:7af5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d192e88f5sm237921025e9.0.2025.12.23.05.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 05:50:51 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, biju.das.jz@bp.renesas.com, fabrizio.castro.jz@renesas.com, geert+renesas@glider.be, prabhakar.mahadev-lad.rj@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v6 8/8] dmaengine: sh: rz-dmac: Add device_{pause,resume}() callbacks Date: Tue, 23 Dec 2025 15:49:52 +0200 Message-ID: <20251223134952.460284-9-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> References: <20251223134952.460284-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Add support for device_{pause, resume}() callbacks. These are required by the RZ/G2L SCIFA driver. Signed-off-by: Claudiu Beznea --- Changes in v6: - set CHCTRL_SETSUS for pause and CHCTRL_CLRSUS for resume - dropped read-modify-update approach for CHCTRL updates as the HW returns zero when reading CHCTRL - moved the read_poll_timeout_atomic() under spin lock to ensure avoid any races b/w pause and resume functionalities Changes in v5: - used suspend capability of the controller to pause/resume the transfers drivers/dma/sh/rz-dmac.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index 44f0f72cbcf1..377bdd5c9425 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -135,10 +135,12 @@ struct rz_dmac { #define CHANNEL_8_15_COMMON_BASE 0x0700 =20 #define CHSTAT_ER BIT(4) +#define CHSTAT_SUS BIT(3) #define CHSTAT_EN BIT(0) =20 #define CHCTRL_CLRINTMSK BIT(17) #define CHCTRL_CLRSUS BIT(9) +#define CHCTRL_SETSUS BIT(8) #define CHCTRL_CLRTC BIT(6) #define CHCTRL_CLREND BIT(5) #define CHCTRL_CLRRQ BIT(4) @@ -827,6 +829,38 @@ static enum dma_status rz_dmac_tx_status(struct dma_ch= an *chan, return status; } =20 +static int rz_dmac_device_pause(struct dma_chan *chan) +{ + struct rz_dmac_chan *channel =3D to_rz_dmac_chan(chan); + u32 val; + int ret; + + scoped_guard(spinlock_irqsave, &channel->vc.lock) { + rz_dmac_ch_writel(channel, CHCTRL_SETSUS, CHCTRL, 1); + ret =3D read_poll_timeout_atomic(rz_dmac_ch_readl, val, + (val & CHSTAT_SUS), 1, 1024, + false, channel, CHSTAT, 1); + } + + return ret; +} + +static int rz_dmac_device_resume(struct dma_chan *chan) +{ + struct rz_dmac_chan *channel =3D to_rz_dmac_chan(chan); + u32 val; + int ret; + + scoped_guard(spinlock_irqsave, &channel->vc.lock) { + rz_dmac_ch_writel(channel, CHCTRL_CLRSUS, CHCTRL, 1); + ret =3D read_poll_timeout_atomic(rz_dmac_ch_readl, val, + !(val & CHSTAT_SUS), 1, 1024, + false, channel, CHSTAT, 1); + } + + return ret; +} + /* * -----------------------------------------------------------------------= ------ * IRQ handling @@ -1165,6 +1199,8 @@ static int rz_dmac_probe(struct platform_device *pdev) engine->device_terminate_all =3D rz_dmac_terminate_all; engine->device_issue_pending =3D rz_dmac_issue_pending; engine->device_synchronize =3D rz_dmac_device_synchronize; + engine->device_pause =3D rz_dmac_device_pause; + engine->device_resume =3D rz_dmac_device_resume; =20 engine->copy_align =3D DMAENGINE_ALIGN_1_BYTE; dma_set_max_seg_size(engine->dev, U32_MAX); --=20 2.43.0