From nobody Tue Feb 10 11:33:04 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 3CDDD330D43 for ; Mon, 26 Jan 2026 10:32:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769423528; cv=none; b=rukHK34LmAOsrK1GaSsh/NPQXxHEZ/fPD7mymUvtVLxMAdy8QXi25V8mFI/n4cwym4ha1LEtXV90N6iQN5R54T61HlETxv6tQuFbqSU8TxRecgrFGXbOVkUW9X+i3NmtG9At5uaoZjRd+qoXk+QYYT6nas7c3ReoozVxx7m914c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769423528; c=relaxed/simple; bh=wTSw5rrByeywpyx4b28b6t68newYvzHr0oIdTZgnlTo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zh4cghQNg8Gps8WpTie66g/AvIg1uTdsXKD0xGKWgOfYYyGvkYw4YI/fZsJOS8EW7RCe+fHKJXelv1GOZMhgZd8wxjm9n2rN9iQYqJgCkOgZpoOVY5NSlzYgFJNmcTIIs8m3hdM3AOxGwvixTZG2JDj4XhADfzlfDAv5fVE+cpM= 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=CGQQtia/; arc=none smtp.client-ip=209.85.221.44 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="CGQQtia/" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-42fb2314f52so2466414f8f.0 for ; Mon, 26 Jan 2026 02:32:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1769423524; x=1770028324; 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=28LJKOzZr0ga3QymY5qs2v0wCcRNeHJMj2ha9kW7dhM=; b=CGQQtia/yGqo1RzFvOAcEJ0DGUf1TSVm/seO+wYRE1X/fXwDJ1GQZv+B7YkUZeaCtZ RyXG1R7457kAFOnZjNti1M9b5ZGCCJ3smcOlNhzpLUuwgcW8fj6yyU8ZipBHXlz+RndZ Idx52vFSCVDIsqUxQq4iW9062c7QyZgMl+nIe6EWxP58fnl+syUTB3v9KvK/ic8ZMY57 Je1P7TfymdMnPTTmpyxHbAfXc7uRjX92zoMFmWeonrlYdLCsyZ6/FxkXAHgLINcGNhAa ac0TeTRFfzXVGEm61KFUMRf0q0WLh+RS6cuAp2Jj5hbt7S2jvMoRXCCALuU2Ps2Mm5WO J7hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769423524; x=1770028324; 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=28LJKOzZr0ga3QymY5qs2v0wCcRNeHJMj2ha9kW7dhM=; b=dorgagB8LLHSit6oZcgrcFu4qAMjex8tFpMTa4Twtpt5GjzYNe7GeAlDFk/HkrypeE EdWSj2eORDuoTlKDbN0wQwwIHmdaK8FpFPjNGX76R9fAYCdoA81DRptnm6wRikN1lMH6 1J0iqbQbes7HNU2hdQIEIhhZYPZ2IrtnMTlOkeBE0sCtdGcx8mVYFXd4xkl0bNc6w/1z /jdo6PB1heMULm/9bhYMQzq/qcep4fEw1jZVTHfMz61d+532u6/ksvbUxM2ETw0R+1rG RyQPjlflpuZWLrNVR/1REszcN16sbyPCzzf+KmuloZbL0O8upJyjhVtdmQpZuGNNo5lL 8+Rg== X-Forwarded-Encrypted: i=1; AJvYcCUf9EHX+cZof5RC+Ux0Beqr2c5HtpowaCU1gZVTIdGQzQaCN6Fb7dU0mK3c5QRLqty9CbgNqemCtluqwRc=@vger.kernel.org X-Gm-Message-State: AOJu0Yz17/Nl8U2p7rC1NWSDwPQ7sdrG7j3SHFyF9ytiEyqQFFk0c9jz 0wFcvR46MaRrXYYHRoYmBEUC7ugGENlXKZL/gWn2YaJSEvQ71z/hTcJs5FjW1dtcaSQ= X-Gm-Gg: AZuq6aJdTnxf5GOwsVk4x0ofT9+F2AaDWTa8CnETOFgCrSDHQy1fwCEcxJKuVAjKnQU +nJ7/M9foJ/SbCFS0JzPishcihG7ulT8bKJ52i4MSXe81ahXxHr5CHzg/YJyOE2edrDVjK8PY+O ylcEcNSwY76CGTeLDOc40RL/kZZc+K0W/OJSt1iBjrbdQ8X8MzNXtbU94BaQk/cxNMXzyP2l/3f v2YP3aJdCalcpGD7SiGhSL9HHme56fkncmaUCF/U4spoTibKEfuH+Rz/i8MDET3H3j4bS4xFMC9 NTPEEKQ7CrJECDOC+GWjbneV1S2hrle3WR1PDV8g/Ad2K+IG52pKbLQAfpt8Gww/pl0plq3XbBF dBNcp4wJ/pZliJdy8sFnQOpdEpf7B55QAQjHoBCRrmgaLx/bbt8BKYylbpEHHuNEGFheRQuGIbq oNhtm2vXAggrwgcplti5vL3yk/2/xQrdHr+sISYE8= X-Received: by 2002:a5d:5850:0:b0:435:a258:76e with SMTP id ffacd0b85a97d-435ca3a93d0mr6619369f8f.60.1769423524419; Mon, 26 Jan 2026 02:32:04 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.31]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435b1c246ecsm29715049f8f.10.2026.01.26.02.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 02:32:04 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, p.zabel@pengutronix.de, geert+renesas@glider.be, fabrizio.castro.jz@renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Claudiu Beznea Subject: [PATCH 2/7] dmaengine: sh: rz-dmac: Add pause status bit Date: Mon, 26 Jan 2026 12:31:50 +0200 Message-ID: <20260126103155.2644586-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260126103155.2644586-1-claudiu.beznea.uj@bp.renesas.com> References: <20260126103155.2644586-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 the RZ_DMAC_CHAN_STATUS_PAUSED status bit index. This is needed to implement suspend to RAM support for cyclic DMA channels, which will be added in subsequent commits. The pause and resume implementations are updated to reuse the code added for suspend to RAM handling. Since the pause state is now stored in a per-channel software cache, there is no longer a need to interrogate the hardware registers in the pause path. Using the software status cache simplifies the implementation. The resume code was updated to use the software status cache as well. This is a preparatory commit for cyclic DMA suspend to RAM support. Signed-off-by: Claudiu Beznea --- drivers/dma/sh/rz-dmac.c | 68 ++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index 95ed357f2b74..8d8391a5b3a7 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -65,9 +66,11 @@ struct rz_dmac_desc { /** * enum rz_dmac_chan_status: RZ DMAC channel status * @RZ_DMAC_CHAN_STATUS_ENABLED: Channel is enabled + * @RZ_DMAC_CHAN_STATUS_PAUSED: Channel is paused though DMA engine callba= cks */ enum rz_dmac_chan_status { RZ_DMAC_CHAN_STATUS_ENABLED, + RZ_DMAC_CHAN_STATUS_PAUSED, }; =20 struct rz_dmac_chan { @@ -833,12 +836,9 @@ static enum dma_status rz_dmac_tx_status(struct dma_ch= an *chan, return status; =20 scoped_guard(spinlock_irqsave, &channel->vc.lock) { - u32 val; - residue =3D rz_dmac_chan_get_residue(channel, cookie); =20 - val =3D rz_dmac_ch_readl(channel, CHSTAT, 1); - if (val & CHSTAT_SUS) + if (channel->status & BIT(RZ_DMAC_CHAN_STATUS_PAUSED)) status =3D DMA_PAUSED; } =20 @@ -851,35 +851,71 @@ static enum dma_status rz_dmac_tx_status(struct dma_c= han *chan, return status; } =20 -static int rz_dmac_device_pause(struct dma_chan *chan) +static int rz_dmac_device_pause_set(struct rz_dmac_chan *channel, + enum rz_dmac_chan_status status) { - struct rz_dmac_chan *channel =3D to_rz_dmac_chan(chan); u32 val; + int ret; =20 - guard(spinlock_irqsave)(&channel->vc.lock); + lockdep_assert_held(&channel->vc.lock); =20 if (!(channel->status & BIT(RZ_DMAC_CHAN_STATUS_ENABLED))) return 0; =20 rz_dmac_ch_writel(channel, CHCTRL_SETSUS, CHCTRL, 1); - return read_poll_timeout_atomic(rz_dmac_ch_readl, val, - (val & CHSTAT_SUS), 1, 1024, - false, channel, CHSTAT, 1); + ret =3D read_poll_timeout_atomic(rz_dmac_ch_readl, val, + (val & CHSTAT_SUS), 1, 1024, false, + channel, CHSTAT, 1); + if (ret) + return ret; + + channel->status |=3D BIT(status); + + return 0; } =20 -static int rz_dmac_device_resume(struct dma_chan *chan) +static int rz_dmac_device_pause(struct dma_chan *chan) { struct rz_dmac_chan *channel =3D to_rz_dmac_chan(chan); - u32 val; =20 guard(spinlock_irqsave)(&channel->vc.lock); =20 - /* Do not check CHSTAT_SUS but rely on HW capabilities. */ + if (channel->status & BIT(RZ_DMAC_CHAN_STATUS_PAUSED)) + return 0; + + return rz_dmac_device_pause_set(channel, RZ_DMAC_CHAN_STATUS_PAUSED); +} + +static int rz_dmac_device_resume_set(struct rz_dmac_chan *channel, + enum rz_dmac_chan_status status) +{ + u32 val; + int ret; + + lockdep_assert_held(&channel->vc.lock); + + if (!(channel->status & BIT(RZ_DMAC_CHAN_STATUS_PAUSED))) + return 0; =20 rz_dmac_ch_writel(channel, CHCTRL_CLRSUS, CHCTRL, 1); - return read_poll_timeout_atomic(rz_dmac_ch_readl, val, - !(val & CHSTAT_SUS), 1, 1024, - false, channel, CHSTAT, 1); + ret =3D read_poll_timeout_atomic(rz_dmac_ch_readl, val, + !(val & CHSTAT_SUS), 1, 1024, false, + channel, CHSTAT, 1); + if (ret) + return ret; + + channel->status &=3D ~BIT(status); + + return 0; +} + +static int rz_dmac_device_resume(struct dma_chan *chan) +{ + struct rz_dmac_chan *channel =3D to_rz_dmac_chan(chan); + + guard(spinlock_irqsave)(&channel->vc.lock); + + return rz_dmac_device_resume_set(channel, RZ_DMAC_CHAN_STATUS_PAUSED); } =20 /* --=20 2.43.0