From nobody Thu Apr 9 17:24:01 2026 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.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 A6FAC26B755 for ; Fri, 6 Mar 2026 12:41:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772800901; cv=none; b=WUgEJ/zqbWuR/lwWEEIGLJeieHsDTHuG7xU6OK+TM1uQerJhC0tqoF1jxboL/3FpuDRr7IbNyaCznuoT2fo8HAF36SABDDI9uG6qpV0hjCn1Rwupsui+sb5PVBT+uycbj6+yWwAwObx8U7LGVRMFBUODxcGRhXUCVrZKZ3/1GWY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772800901; c=relaxed/simple; bh=RN3Xvj39V/yKMYYPWCiHYcUQb1LTVs8M5GbjU78OU3c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tsBMOsFvU8nqDLCgSwSVBZiuAhzLfSpgEXRJ9YnUmv2H7xQNrHzWSfOdDpBmWvyAS3nojNiI/SB679px+rJ463PahLhrMlKJUeJSeS9rl77fKzyJ4Aly9ZEdiSZTeeTGFfFM9ljEghcRbfhi5FA0VXecESNNfmM9bHDgHs3+aD4= 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=RVWOeo7C; arc=none smtp.client-ip=209.85.221.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="RVWOeo7C" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-439c9eb5d36so2733762f8f.2 for ; Fri, 06 Mar 2026 04:41:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1772800898; x=1773405698; 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=JtXHbNPdEBg9KTwTT66W1+1GRh4EUiwex5QWGP93Nrc=; b=RVWOeo7CE058x4pBoPeHmEvS293hHs+QKwqnHkENZwvtidN7/KMhlnwHt+mGd/VQ5Q X5lbP7fQ/fGFjRfM0PifMT/Hz3kxtjMiNXwOoJMam4H9MIduxKGUkTOFdObcOt/AMKWV HsSN8lFae/NrXks2R0u+txhrnl6gVoFcJ4w0vjFP+sVubZ+ZgOb6ijVoF+c+Nz2bWtxo 2AzAsaf1D7i6cBB0FzTYW7LCyR7LXIjZKQqYFyxNWLFZJI8G9qy20xEMo36VMQ/aDIMW WCe3qOaLmdEZj6nbzb3EZFo/8Nem5z6/mKWi06TzHE/Cg1n1+NYWydTVeoqIjSWgB9iR vRJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772800898; x=1773405698; 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=JtXHbNPdEBg9KTwTT66W1+1GRh4EUiwex5QWGP93Nrc=; b=ob7zTWVScjN5IeWoOArWDhd8RPbXgvlh7gZ88lzJJKcobWDA71X8poQYSsgs+u6n/K GgwoVoaF/sDKnspniXlDbXKXkY+HdLzba5Ud6iQ0E+Hqs790hE7xrNCDLfkqKQRi4xEf Vza61sEMJQb/MsmAwqV4Dn7qOLfDu09GQrMm3QfrAS3MEwN5hhmrN9MdPSCw0WdrHPLW MnZI5DQK1clrNi0R76F/KYCaY512xYx974v1yXXf5KRqNDtA2GN+MYhGWktY6zm0ti8c EfYAQvLJbn3wKqw+M77TyjMj7KYBS5IWTQ3+c2mQoyBJtiQ1CLkw8RTgbEYdVaa/SJlP rrAw== X-Forwarded-Encrypted: i=1; AJvYcCVhlK+UXc15apgl910GMJtWrZolipMi3ov4fz4Kf0ZXcWasw/+AOSE/X98SICEj1GFXFO/sT8mYbz4f9wU=@vger.kernel.org X-Gm-Message-State: AOJu0Yw60RKqyCg66gsjyGDO/0BNnLHmpnwOAQ8e0oB8U7FVuHB4Ivpn tUY7i4kPoDo5ZzJLHa1/25INr2719Q+GOZdtPgXJia6EL+DdftEB0ChAl9r3OFfFNJE= X-Gm-Gg: ATEYQzyDSR/v96e2UiEvapdvmd4BsXHaZSvmmrmR2u6tRlYByXAf683qk3jhGfxRy12 g6es4QJZa/GPcgEqBPREXrUNWSwM8QrCDY2spSRbUgOvRta3/k//hxqmgWbd8Sf/8FQx73hdm1Z 1RVxrnBayIORv0lKHr3BFGHaQbZfqHhWH43VUwOHDtA6IKyMdx3mu9WmS/C+TuoZtwv0P8ubdxF 1LzaSQCz23dxbxADIfTjEXD9jGwpkPX/7u9oAeaZLRcMpisgLpe3FenYQpbvJn9fV2Ay26V9ZhX RUl2UvXra1xqVAxMX757Cb0HsECI7DHo6KwcQ0xl5f2QtFbnf6FH7ZLc7Wn/wDjqoOe/yCIMb4U EKJYJELwbd5yT9Vh2giKsRGnGWIP1gQrLMlRnHWITTGgbkmendgYu5k903jwUU/Y2qAppy2xuRK CguBq29dNd4tREmQKGCZ/Hkz6h/sVGlJypRNnpzB5za2aWJnKjav51 X-Received: by 2002:a05:600c:a086:b0:483:75f1:54f with SMTP id 5b1f17b1804b1-48526982991mr30474875e9.31.1772800898064; Fri, 06 Mar 2026 04:41:38 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485276b0c38sm38150505e9.9.2026.03.06.04.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 04:41:37 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, Frank.Li@kernel.org, biju.das.jz@bp.renesas.com, geert+renesas@glider.be, fabrizio.castro.jz@renesas.com, 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, Frank Li Subject: [PATCH v9 1/8] dmaengine: sh: rz-dmac: Protect the driver specific lists Date: Fri, 6 Mar 2026 14:41:26 +0200 Message-ID: <20260306124133.2304687-2-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260306124133.2304687-1-claudiu.beznea.uj@bp.renesas.com> References: <20260306124133.2304687-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 Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v9: - collected tags Changes in v8: - none Changes in v7: - none 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 d84ca551b2bf..089e1ab29159 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 @@ -447,6 +448,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++; } @@ -502,18 +504,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 @@ -529,27 +534,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 Thu Apr 9 17:24:01 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 0C3C823507C for ; Fri, 6 Mar 2026 12:41:40 +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=1772800902; cv=none; b=qXn1GcPN54CUwyjJ6xtgYgcReigmQDkGrO91XEP6/LVPkHsrNLqrI+hN5OUQIH/8Rd21Z5HxrcxU55mVtvQFxxfHp0CUZKJhHk18Jw2YAflby/ycJLCOC7EjrchMglu14MkvCzsGY8RNrfkYEg3pWc4hXpT272O5lg/I1Qu0AD4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772800902; c=relaxed/simple; bh=HZ/1WFdnj+qO0WVw6GV1ZKDvd1Zn76kMVG0yFAr2u44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MW1J5xF5xUzaWaPACqCwcFM5hYgKWsLCniJAXEF3DpoITqm1dYAqmRwJQXHbrd4h2qwO4ZEjpNyfn0/HTEDVToo8V2rD5r5b+gx+CCU/i6vwKxOFXXquOfyZmKa8lvNYnLZA3FDMvE7rd8E350RvUzLG1MzdXIJlDkGMwDxJOPw= 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=kdApaBin; 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="kdApaBin" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4836f363ad2so107484555e9.1 for ; Fri, 06 Mar 2026 04:41:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1772800899; x=1773405699; 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=CtS0r5TfYlqaL5VTrxQnay2hKIBKEN7+yQrm8HEoL/c=; b=kdApaBinAt2kDkuIVkkiY6ZUkaY5pZz5QD5TdUX9op/vnu2Zu1O0IhSl2nZ8bbgKZd IGa+dkdb/uvENx0/+TTDk5L6lgeFIACyM7bflYNrQ1ZqDda+mZDXPgykd0/lH2LUZjP2 411sWRLd55WzmvaHSS0F7UPzxlartjTKxDdvWYD+R20afVZ66BGZFj+dMrZeAv4J0XI2 meXPRxwAg3KtG5CvSLSL/ru9RS0DdYHa9wC9NK4RgEpdcJReIg0K+APFfGN3od0gcTkQ /P5ctNkwpdFTNGX6FxN+X12wkl/fN+I3QPRth0VRimQ5IRqhZoh9ZJnPxjFaqCrEHtl0 76Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772800899; x=1773405699; 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=CtS0r5TfYlqaL5VTrxQnay2hKIBKEN7+yQrm8HEoL/c=; b=HJnZ4pSFPO3jeReV+FWkeyO3nQTkLzXFMvDFzaE3ESKTu8W4z4ratQSfnpl7aMLFSH qVpIRptisWGez+/jgjcttQGIxYLgxlDtoaKRsZ82yDbYVjdxeXeAIEnrIrKISSsarYT5 iAn4DsCHM2vcImeUP6yriFQ+sf+Qsojtsi3GZTyfST6imkw1C2Z01dVc29+tP4X5hfAv Ye8KieYFfpFFh470F0F1IBC+Z1HLp0L2Xh9vnTuA4eJ34TEBL+PZMRsEfUPDRcq7oEBb sczo/BCpZuwmDWoSMKJbslTUPhOoGsBnvc95M50op36Vl3dsn+IkY84y9Z/eeP2oX7a8 gbEA== X-Forwarded-Encrypted: i=1; AJvYcCVh9PwDytqOILURqCIX/fAcjqq2T49PQWffhLflieZNdwKH0JG7kLRMjC1sKgs9GpLQxIoiYsLXdt9Th68=@vger.kernel.org X-Gm-Message-State: AOJu0YwkbC4YE4Xa0Bwcwzh9xpNgQBShhMiDHkVXmCwFSlR4Xv4M5kJ8 EYxRSY+7bvprsOsIHbmeW68t3JlgbiD2dFnzMIdWUdG/DxgjRsD4PGhOaqMZUY7p52w= X-Gm-Gg: ATEYQzzyjEnbvSU9ksXz/nJ/Ypi7gOLfHez1z1ZnFdTresma3dDnzwVZTS8wgAue1ZG mP3Zu4Yf25ge+effoYpKUrI1PPGRFnO2sMybDWwN0jYnjenDpzKoKLpXB69mU4OG81Nb7fzfXfk Gub6JdrkBIemS6lWIZVh8NetH+mw3TnQCbkFVVBK6ot0Co9D4KYyD8y6QXJLeZOP+11ex1wRWYJ ju6N36LUAomI+LSB2sShePpCV441S0knDR10j9AWPd1ZNdMpMzRHGn1iBHBvzfITkVhH421gbm4 xWwfidOOpp1Gb5eOPbB2Jex0lrXUWBrhBKpclzt3hzVDnEQ5zKkoVzrQ0A+fR78vkAPln0SR9Vi iQd3w+jF9JWDuQHIRSZARr/X5mR7HNfziT6vFmnpmQ6tlGooxhte36AYgXVD3rXSH8UPz7/4N1c ncURAbNZYKCFHnnY3WCEWrkH9AcfCRngm2x2bo6Yp1XnaaDKhmsnDq X-Received: by 2002:a05:600c:3e08:b0:483:7eea:b172 with SMTP id 5b1f17b1804b1-485269675a7mr33794685e9.23.1772800899339; Fri, 06 Mar 2026 04:41:39 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485276b0c38sm38150505e9.9.2026.03.06.04.41.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 04:41:38 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, Frank.Li@kernel.org, biju.das.jz@bp.renesas.com, geert+renesas@glider.be, fabrizio.castro.jz@renesas.com, 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, Frank Li Subject: [PATCH v9 2/8] dmaengine: sh: rz-dmac: Move CHCTRL updates under spinlock Date: Fri, 6 Mar 2026 14:41:27 +0200 Message-ID: <20260306124133.2304687-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260306124133.2304687-1-claudiu.beznea.uj@bp.renesas.com> References: <20260306124133.2304687-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 Reviewed-by: Biju Das Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v9: - collected tags Changes in v8: - none Changes in v7: - collected tags 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 089e1ab29159..f30bdf69c740 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -297,13 +297,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) @@ -568,8 +565,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 @@ -706,7 +703,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 Thu Apr 9 17:24:01 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 4ADD9285CA7 for ; Fri, 6 Mar 2026 12:41:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772800903; cv=none; b=sK27POQUxZztwcAWPjB/L7puLAhSCy5cEVPvBqH1VCDmlVPHND7fSZ/Wlh4JXIGhaeqepq3iSCKkq2wxeBI5TKd/3dGPaE/1KK1lzndO7UzbXt1IpS0nzHVYOZw5uCJg9M25rnna7pDEciBFETST/Dq3MgAUYtpbFyb9WwVYF4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772800903; c=relaxed/simple; bh=SjCE/QHioNwLTDQuUYwPk6oerv0xCCcUmYIaEF9w9K0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SkY5B3j2zYbi7rUtJpMCShYMOtm5eM7Jc18ulmz9+Zn3XXm/pmBk4Ap3kxMSwB6dacUFMmEXmhAIWM3UiV2xDom4OwUVchVrFHlvpGivRjfGJz6DukFWH5gMsl2HDK1D1LjT7WUFrtP4Eqx5bKCi8hmcxOC1beK0vmOhQRAfo1Y= 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=MgDLNuim; arc=none smtp.client-ip=209.85.128.49 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="MgDLNuim" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4833115090dso94661135e9.3 for ; Fri, 06 Mar 2026 04:41:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1772800901; x=1773405701; 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=TdAKvTV1z72NR5PYnaT/8EadbSxsVoneWRjGufMFMis=; b=MgDLNuimauUMfytoXW1D4QnlFlhMwqrZSRTqyZw2oz4V82C57sIw6NAYamBJLRsSoh xLoHA1KcyiEwUXP1i48pHbwODCQtr4KRwTCLo7c3DuJXmHGmc9UAlNK4Btfn842dFVg/ oLpz4eOCqtCRTr1d/3QARBajXQbseg6ejsdzx7rarleZE3lNPzzLzk/ZMEAwNrEgNO5N uwrepxiCgQc7STIbRfHpjfM7yi76IAdaiyyqJtiWgesMDY3n2A/AS17yGKwo6tuTCXLT wtynLGHcsKDcQbx65kznAu6LU5MrlP9NhNMt7cbu4UFZzSlL9Vea105hNBWUrJrEUOA0 rxdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772800901; x=1773405701; 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=TdAKvTV1z72NR5PYnaT/8EadbSxsVoneWRjGufMFMis=; b=FDx9v/vTKtSq/Baoll/J/6WI+xNuqtz4dJCf/vS62O7KERfeWEoczk4sbW9VjdAN/1 Xu1Cw4pGUxnQudQC7pMLIP+ke7JTik3OEpCGt8Wt9t25o6a7IbLg+1DWxoufPgvl5GH6 yxnriMw2JZ3R5XWKYeeVo6EZGVnVzTPj/fRud0RbNPWVJxlg90ghHeFndTrlm6AJ9ZNR AcR20XpFfyNwJIXmCbEmloG29/5FKR296KKwShuDCKA5hOgLDik4CuyX+9wH81b7xg3B Tgc1mFuYWwM+saQFAm169fCkpJ7KAHc9g+R/8gTb28G0zaTTSdD9IIpZNj55olAloYQi 5yqg== X-Forwarded-Encrypted: i=1; AJvYcCU45QIv9xkYOy0VhiKJRRMhVBFpJcbFAWopDaSGfpBnZW2oVifI1me729sVpzjpQ1TKLAiCyR/v12JnmuU=@vger.kernel.org X-Gm-Message-State: AOJu0YwFyuJ21PLsCn6iFHi43zOP5/QZYtxt4b1H7LpNg+jAb4ZTtKyW f2OIE7BPK+bH/mPFLewpfTUiZMBEsLQji8y4CtIlQcG8ftDW29wFJIDm5T+UIia/JYs= X-Gm-Gg: ATEYQzxDV8IiWgh7S865FEeMpkasPAIMqQb8TXB672PKAhzyk4KW2hgZjvH8u6Us0FU r90PS9OdMU+5tUyDdLHoJMfK5Yv3MzBUXXmoMScOIjl1mzrCVpyR7h/MVNvIt4c2EZ7Dcz/NoQf jnb0LbKr3g0pmwAYbtFG2jrK2v28IGorAMknN6i3hSqdOwLCkcMnYCHN/Pc7/EONM2PmQ4VzgIO rb+P6HhIQtVHmus7UjrpwtD8ez/qbjDP+k/vacbORIEcfJaFoFXABbqZP7Wi3VZfnQihI9RJJDz cy1ptLEemZi24aEGrUJNtsjKEtqrOFJ7qtpcd6NJVhKpNd9IkwaHv5HjO0wJNwogu0ukz5BLGJX jIbVcrUAB2h5m1DeoX5hVTPMK/FFPlbT3XulPZP7+aG6UKrUeJVSr6+z87ZlAZfZ+j8W83glqoT mHXNma1hrw1kwhJ1UJ+XjZhxyC38s/2KH8tK2C2TwYQe2bd1idm9S/ X-Received: by 2002:a05:600c:3acf:b0:483:b505:9db4 with SMTP id 5b1f17b1804b1-48526978d8fmr30254655e9.31.1772800900661; Fri, 06 Mar 2026 04:41:40 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485276b0c38sm38150505e9.9.2026.03.06.04.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 04:41:40 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, Frank.Li@kernel.org, biju.das.jz@bp.renesas.com, geert+renesas@glider.be, fabrizio.castro.jz@renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea , Frank Li Subject: [PATCH v9 3/8] dmaengine: sh: rz-dmac: Drop read of CHCTRL register Date: Fri, 6 Mar 2026 14:41:28 +0200 Message-ID: <20260306124133.2304687-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260306124133.2304687-1-claudiu.beznea.uj@bp.renesas.com> References: <20260306124133.2304687-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. Reviewed-by: Biju Das Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v9: - collected tags Changes in v8: - none Changes in v7: - collected tags 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 f30bdf69c740..2895d10aa2c8 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -697,7 +697,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) { @@ -709,8 +709,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 Thu Apr 9 17:24:01 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 81B63280CE5 for ; Fri, 6 Mar 2026 12:41:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772800905; cv=none; b=V1bHTpJ2vWljqg7Q+6ubru6T1vXD/OXVNsxrXNFMaIN8oL6Mmb2OVlLCVZzBXr1MertymoHTLiggr88bC3pzvi1okisXfrXdXKONVXw7RB/r8TfO4W9Aj43vK7+7rgLt6GzjisLEcJRI73Kj+txrgcjPcEXpwCv38o5mVFQKFEk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772800905; c=relaxed/simple; bh=E8FrnPZikkCzYivt8gFgvp5FnUb2bbAQTvsngXDzgMc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SXyrBtiVuzOSA1TUp+RQFNS4faqoZeM/b8DROtwRv+iJjhpAVUm82QUIe7Wa/BIIgoETlOGVf4Le6BXgsJIM8JjH3BVTbG1y3mjXh+nGqZKo2Wiki+1tk8CqQ79exbgCVs0FO8zbSC9UjKTgfdDS2fB0lHequ9DlgEQwy5pXp7Q= 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=aq6p0/zd; arc=none smtp.client-ip=209.85.128.49 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="aq6p0/zd" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4852a8482fcso922705e9.3 for ; Fri, 06 Mar 2026 04:41:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1772800902; x=1773405702; 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=evbDeWChFM1NVRF6K9uXPZD1Lo9mgGF+LHECV76EJao=; b=aq6p0/zd5k9UXb34x/efHkKY8StCobYra99vTZFq20TO5yelFUxFcDysifqJfxs31l BQhw/wtITQZVwroabNS670FU31dn+dxNW3FRwCCwy8zTgwHE6lE3Vzkm9ca2479pUVU/ CSH2Jl8HNKISVRY+uMpC3Af1l5yfAqr+6l4UnDfYAbIvSu0OmoSbjFHOgYnQUffeYTz0 Wbh0jcoO+3+LornuMXJVb111JZVaVRZc+CcF3DOUqg8aoFX5Rnkzs1db73+V9nswFcr7 nK2gAos8xSAVa6RtABkAhNoggFKO9Je76Ql20UQXSYROnOLpx7H+5srv280wachhJ7ed /JOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772800902; x=1773405702; 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=evbDeWChFM1NVRF6K9uXPZD1Lo9mgGF+LHECV76EJao=; b=AR6g1OIsTDAslzHVUEX4eVe0GB0AS5Jl6hFFmwWmA+mldUcRN6r7b2rcsQ+mwsio/z SApnjDD8dILNNHuYQ7s52EbN5WIEaUcM97jwE3DX4QMzr7lubNGg6mXjfzlNPQxa1rU7 X9BUemfnRW6/pkU5Hq/+1lkLHOcIpZcF5gjxuLmmlMKS1qYPgNYigbih1D2MKdQrxpe/ /ljxA6C7UZ5jbTa8+x1/P3EFN/Z9yNcx/6ObXRE7/yJs/ub/Hu3pW/J6R26uSKq6T/3w T4hmNDTIerr6OsckvdOpPm7X7+6eQAph/JTgQLUHnoLFxAqf4yXv2JgVPjFdVnW8FGVu APrg== X-Forwarded-Encrypted: i=1; AJvYcCUJv0C3YjO4MKlB5X6BUP/8ARBKzDvT37cfKtQ61p3NOH6oBMJN69jfEqaEhnl2XKsBOdyM+UeqflU1Ypc=@vger.kernel.org X-Gm-Message-State: AOJu0Yyn1MtHoCek8NuvfTXmGngdKsPZWKrGASSjl2PQS4wg2QT9xJR6 K174UuYqYN5uaaWAfjJXKKZnooOR+0i06ngwRkX465y4efE+pBhhUMOjQyzuIzr1H50z0AVNlFT 6ejri X-Gm-Gg: ATEYQzzKehdEl+/IU404gcf8ndn2JVmWWcLb6FzfuNEd1cJaSCJhwlmcRxMpPvf3d9K 0qNWf7YVpAQaIPimEMKjlDRJyMWBdcK2Fcd1pNpdhrDox++5I734yQ0Hcc+/WyMESulcGCe2Rj8 K7W6A5hWi/HDUyUCAcwfEZXIgNC6gmXyhnspyiVr51izKMgmsh708/EZIM3W9Ts1kmBiCJ2mjpi tPiQWyKmoy7fMhM6lsIkw5GRNbXeFDN1Q2YWygbzsmlvzo0+e1HlsNmX7ktcEsd5jAINd7FgBQ/ YgO/P5/f6QnnnelclXz4UdxPZij1e8+Rnm8D3Q1dbnhtLw4lwF4wPUxGvAq0HgO76etQO4T5jm0 uZqVdp3anccQTYWo2WxMcOb9KexxeUbB82pS1yfW37P6wop+X4O5IDl8E7BSPaWNcciAyTxv2RK 6XCnYm7tIRdzTNXwRSmg8XS6yy+G7m4MbkYGqbztTJE1yvO7Pf1WGI X-Received: by 2002:a05:600c:3b04:b0:483:71f7:2796 with SMTP id 5b1f17b1804b1-48526923e1amr31113775e9.10.1772800901899; Fri, 06 Mar 2026 04:41:41 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485276b0c38sm38150505e9.9.2026.03.06.04.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 04:41:41 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, Frank.Li@kernel.org, biju.das.jz@bp.renesas.com, geert+renesas@glider.be, fabrizio.castro.jz@renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea , Frank Li Subject: [PATCH v9 4/8] dmaengine: sh: rz-dmac: Drop goto instruction and label Date: Fri, 6 Mar 2026 14:41:29 +0200 Message-ID: <20260306124133.2304687-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260306124133.2304687-1-claudiu.beznea.uj@bp.renesas.com> References: <20260306124133.2304687-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, so return immediately. Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v9: - collected tags - updated patch description Changes in v8: - none Changes in v7: - none 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 2895d10aa2c8..4bb446c1cd67 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -706,7 +706,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 /* @@ -714,8 +714,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 Thu Apr 9 17:24:01 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 B328C303A12 for ; Fri, 6 Mar 2026 12:41:44 +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=1772800906; cv=none; b=k6qKnjBlpSDIhjWLprY+ZlZhtft4gJPqjefeW3QknckNH77Oxg1jhkPQ6xJQVxY4Y1WsZxTvuxtuVHYnRekuUe/aQXeQrZdUDehvKYOOvx593OD6xEHseQgdBm5q2kj5/EgaMPV1fa/D3vrwC53OloLwERi7xfLWl81VJ86LaMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772800906; c=relaxed/simple; bh=zMC8Z35n6hZqb+F6CM9QqlHZLYZ6S/y6G2PDsOYtUHQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W4qOB2DBqjObftypGoeQSQSASypp18FiWhq/0vIj4o3Y9KkgpbtzmDPwmWEGWBMqgCuA8Vg2KfbbTXAiQu2CfJ9xbF1tPUJI8kha+V5oNGNoOIYE0/62OekDKBhNNzRmhwQP1ypqrD4SYUOhAJnQfE5EbaVzPoaTC84tTggs5mU= 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=M3mgMlM/; 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="M3mgMlM/" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4806bf39419so74921105e9.1 for ; Fri, 06 Mar 2026 04:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1772800903; x=1773405703; 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=djodlEhOqxbj01WP7bf1DpXdR4vQl3fw8jTNz3jaE3g=; b=M3mgMlM/Jp9a1z+gVPXJ8IxZJTHvybbgRL82752E/YwqRZURITyQ03y/rabHbm2oJ4 uqoEy7n0+j9LCA8bScZjRh66p3VesD8l9aFIqHONkdMNZq+we4WTshbNrMTswdHeiwu+ QPUtmZCbAdCOviBgoCpd7kveutPlrJuKczR9hhZ/FQQ0nKFkgqCeHKix2iKLv28A0G+8 lh60WnEJN1y6Pp8dhzABTgl75MUtgl7Kem7uu+cY/j0nvEjPoE54WC1kfzDmFnukq/Zm 0HkPVPDmyvJfP8Yy/ECqK2B4+Ia1hDPyjVE4G0ACcE25kSWwnXavZLkn/Dox1NHgl5vM CQ7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772800903; x=1773405703; 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=djodlEhOqxbj01WP7bf1DpXdR4vQl3fw8jTNz3jaE3g=; b=bYEGZde7UmA/lVqy2aoeYOEWskwS4OXWarNsZ9/TrPiGNLovRJxpEA6svOuyj2WxaV JOl6PbQBbNfNqpch5ED/C/SCF5jkg0k1j0jUc5VtBji6u2A6NvMmrlzCNQKL8ImBvaAF mgrEWfbRqajMQu/cMTsTSUxTR396l6xrAVHOblJwp18eYmj4pk0Jg/eJ4sxEvil1OThS NsRg41nmgSSZQ1UOD353tm4gGTS5F2+4K92bLytkm4Q8dlOb6pia67DrRhOn3/4oRxVs jpZeiwxFhCSThAcyq8y9a7n47gvZw6vNLVpS2H2qEzH/LWE6JJQ4vW/eLIlGW4t7HyrG 7dLg== X-Forwarded-Encrypted: i=1; AJvYcCVFvU7jf6gaWN8JvnWSHkyvB+vkaydcZrERyIpaEx/msdylPIDJECnmqvXokDd67CbX1IdeoM/5XkBpg/E=@vger.kernel.org X-Gm-Message-State: AOJu0YzMUrWP1fcFqgoMpt4RPmjVOOsJNxZHkL4zfIJ+WbQwP2vDTy95 cd9sy3iXpKPqct35qZDh9FhxZlgBEjTLjKqdhPutWkwC02dX73epQMEKEIN0P57NvCs= X-Gm-Gg: ATEYQzwxCpOvFbECbkd1lQJfIRfZwcWiQaciqy5PzGTZiABwmQJ1x5cqc330SanvTPE ALVbeFOR40E2FoqGzGj6e1o4vJYgH2Q8CPIMZdqXZFw6v7ZNqKPUcc/TSUirwjeboHWe3mHYhIY UFVhV6OzqZOgTqRv4FO37ks9U/3sgRcA5MZRMP7M6pGF3MO2jWOgmaogAj9wXMHOdx9SgG1zW1z AQNxCoT6icV4qWRW831F4HM2GlAQOR00WdPs9yB2OF491Tt1+SkRf2THK4z+O2N63xg5rYdP5wU fSAWyP2eNSvyhZ8IXYCZgLY+5Ma/OYSw8E8sYfh5zPQ3uAg4kC2WR7Dp1JypPpbbBz81Y6gRaYq aTXSwj94gjf6djBHRllqx6N+LdNap+abKk9c7RbBOgFqQ4hBIOZlzZXM6tKojBfFztCX7JMToRk Nr/NtgdlBn2IE10Zctn682Wdansxfw63uSGG8bRuqgyzaGNKqhPWqB8JxvDmysVS0= X-Received: by 2002:a05:600c:8b2b:b0:477:9890:9ab8 with SMTP id 5b1f17b1804b1-48526715213mr28640755e9.3.1772800903039; Fri, 06 Mar 2026 04:41:43 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485276b0c38sm38150505e9.9.2026.03.06.04.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 04:41:42 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, Frank.Li@kernel.org, biju.das.jz@bp.renesas.com, geert+renesas@glider.be, fabrizio.castro.jz@renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea , Frank Li Subject: [PATCH v9 5/8] dmaengine: sh: rz-dmac: Drop unnecessary local_irq_save() call Date: Fri, 6 Mar 2026 14:41:30 +0200 Message-ID: <20260306124133.2304687-6-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260306124133.2304687-1-claudiu.beznea.uj@bp.renesas.com> References: <20260306124133.2304687-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. Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v9: - collected tags Changes in v8: - none Changes in v7: - none 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 4bb446c1cd67..9c159c53e3ee 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -266,15 +266,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 + @@ -289,8 +286,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 Thu Apr 9 17:24:01 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 168C13644C5 for ; Fri, 6 Mar 2026 12:41:45 +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=1772800907; cv=none; b=Q+w+B8TfSF4wqnT1CMyG+U6xg5u+p4u6mSh9Res9y40zFfUjZUxuwc21NR/Olvs+J9thvih1tTs4yC8FfNY91bH1d8KDfOrdnrFawbqu6Ay7ZEOdnc2XXgymnyDnOaEd9Yf5CZF3FEjk5C0KvdKp4NvjWFx9n26Iyv+xpIy+qkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772800907; c=relaxed/simple; bh=1BaQ5eOGmq5cxUJDWe8gk0vsUkz4EwiNSGLh3VMzngE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rh2Pbgw4c88zU1A1a5PsJdVQfbEaYqlL63Kry1GYTx1ah3RSIPhUJ01u6bL24syUAVg3eLeJkifpsO8WWl4ofTO/5qFfQvL9EaWhH+4byZV6ffUdGaMGSlbpZDc2XZzcbMODEDYJV44mOhVmT7bGdt4jNRwExYuZBjDG142yiL8= 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=ntIAK4q7; 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="ntIAK4q7" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-48375f10628so60976925e9.1 for ; Fri, 06 Mar 2026 04:41:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1772800904; x=1773405704; 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=GmNjUk7kVZWIP4LPt/EwE/P4I5p8ejRGJw2udSg4T6w=; b=ntIAK4q7nvcmULy9GXsHRaTDuW1bApJS7IvPGxskFo7Uv4lm7h8kHBrdYxwHSK1Yz6 +j4om18I6EwulezJehAbPlWD0lBdfVVDfguUTTd1Q6tf6AFd+m2yVe5y14yONS0Y3EfO vXNbbb9ygguyHN/zWV7tV0ogJeKMPR+hpPKSWC/b9Yg0tQt2rD4TWfAgngj1Hq/qcAfl g1JT9ibQQ1WNdEoab9y9sPH0nrUcEDZYKL2IkBY+cqH+uyaOkl/mNDFHK+5L6N+wl+Ss CVJf+/KThSudQJCr7vy/qaqGofzNV7w9GQhr6O7eyk7Rxz7+O7XnsV4aI/5S6KaV6X2F GUoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772800904; x=1773405704; 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=GmNjUk7kVZWIP4LPt/EwE/P4I5p8ejRGJw2udSg4T6w=; b=SPKUH3lZVoCe7EIHlzWQBCMFxeVuqzOUDNi4sPy+475CQio3fipssCV6AIfmD6ESI5 NZ3JhF8/BKyBjS8Spoy0Kfqg8sYtQ4obaruhE8+SO2/sgdK7X7OZPWr615XFGHzit5OI kyVst7yaSVFc8MiBpGuHAc3TE9rcLhjFo2k7B1oQgacg4jy1qBZ0NrW2j6p4JWnoVLty miah/oD7kumHHb3S9ok/8j/BqCC7fVoFiRWCCVw5gc2ipA2DZcLH6fOoFpEpfUWPdsjP 1187PJ7zwq3YgNQkrEPU5AK75aV0AUjsfsCmNU3QcrMXF5TyE64iZkzRhbURcvZRYA/3 TjNQ== X-Forwarded-Encrypted: i=1; AJvYcCVJllEO6ZCgIGY7A26Jnc8Dvv8qtosHp0dwVOm+fj+0GDwF9pqznV/GLo01JOFe0D6lC/p6AJUi4ubbEa0=@vger.kernel.org X-Gm-Message-State: AOJu0YzkOelNvjrNRyj0tTVHU7f/Wn7EVCLxYFHMbv40UVjGCIojgaZ0 1E4ScGGECAX0QZB5RtNL583KG83HTJG4fFQ60uUFQt3mLvJotXQtcG50+ljVcestuHY= X-Gm-Gg: ATEYQzx+QClrYve5C6Ga0gh3/13nQRIKrXWZRv0e8TBJzEo/abS3mwiWO5HaAFb8VcZ oiDvbwBp+6c69CLgC5vCst9lgiBFS77LBMf15jTg3nKVIWTRk2dmDmBVhlQDTB/HlLgzPAY15rY YhrP/EYa9joqsn9oyKr23bf6i+/pJA5MoMbrHHYavj09Wq2OcSOv7IHhtN1PLmNC2455k46u6hF Ipwxy93TIkE0j0ZqTjrYS2SdWo+Vd0OS6FoRtx4MkPYGv9SK4XwjEfuzLYJub09iR/NiajiwWrT rebr5aL9lBq9ajREjbL/PjPzzO7Oy8mG/gYXIO1ELieOogXE1JUnmZeo7cnRp1iLZKG1MuvYfHU BLqrS8y6fnJtghmxJJXayOJ2kWs4/P6ZMw305xXjDWSBuhe9JDDOWZgeelRZL+/vdLph4JgNJmM +rliDJ+ojUNEDGifeD59owzuBV7395oQkwL0/Edk6F49J7WyLQKG5D X-Received: by 2002:a05:600c:6085:b0:479:2f95:5179 with SMTP id 5b1f17b1804b1-4852692fec0mr32246445e9.15.1772800904402; Fri, 06 Mar 2026 04:41:44 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485276b0c38sm38150505e9.9.2026.03.06.04.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 04:41:43 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, Frank.Li@kernel.org, biju.das.jz@bp.renesas.com, geert+renesas@glider.be, fabrizio.castro.jz@renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Frank Li , Claudiu Beznea Subject: [PATCH v9 6/8] dmaengine: sh: rz-dmac: Add rz_dmac_invalidate_lmdesc() Date: Fri, 6 Mar 2026 14:41:31 +0200 Message-ID: <20260306124133.2304687-7-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260306124133.2304687-1-claudiu.beznea.uj@bp.renesas.com> References: <20260306124133.2304687-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 Reviewed-by: Frank Li [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 v9: - collected tags Changes in v8: - none Changes in v7: - none 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 9c159c53e3ee..274c9cd40713 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -249,6 +249,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; @@ -455,15 +462,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); @@ -555,15 +559,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 Thu Apr 9 17:24:01 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 5A4073845AF for ; Fri, 6 Mar 2026 12:41:47 +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=1772800909; cv=none; b=iuzOconxJeFg/wnea3wo0fLk5AFjR7Ui/tUJfR+dMafB/Wa8V8FTrGbv3R5TO1alFNa10kTPN7bCWV5RhjXMVDYhehFXYzBU1q3OEErt3tUPPsH0ugBqtYah2jkUsrk047sHayUMRVQOJoWZj2YbgjCO00HDqmEmu33JwWYepvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772800909; c=relaxed/simple; bh=nSiQtEYZ1Ezr70vkp2ZeOST+tOl2pH5840ALPWqFaCs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qJGqqHtf7mDP5+sxgstT4l7bnbPgHVWGyNW8H5Aemi+Qva/KBKpCqVeQB2h3pP5oY8XoV4MV4XDP+w2L4YyVQz+zPCF/vRAjkB3nX4RCT15hjpHHy02bb7Lg1zk214p97Xfd+rpyTiQbqw6mr03ryVe1MWWaKhpnX0k+gndDAZc= 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=Io//6dw2; 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="Io//6dw2" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-483703e4b08so89748635e9.1 for ; Fri, 06 Mar 2026 04:41:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1772800906; x=1773405706; 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=nsmFxT5OqHzHHM4Ncsz2v6IqxYstw+p2fVPLaiDV9OE=; b=Io//6dw2I+r1O+/GEIDV2ZWTSREF0mtXEaQOJsRkt5N58Usx0Fsnh/57GqlJVh9sjF gMLIGxE0K0vw8thDKc/5LkFAxANLuLgPIAC41edFP5bzg9aTpqNtjFPuB+znllG6ERUF lcA1mCfq9gKp3bYtEL1z40qr5FUNWxbyDyEhOlaLechH6GCyaJoVUoBqmLPOAMr4WH3W YnmlNE21kAwf7NXh/qyuhGDzoGthOvdrq7Prbj3ib/cR0uICJX5X2XK5by+TS5ZI3xFj dpBrPQrEoIwWgG4qQiNyHzfd+thMqyukjtWsJUNR0dsxJ3z4+B+LF40uH5HuNrsoUKqj k5+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772800906; x=1773405706; 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=nsmFxT5OqHzHHM4Ncsz2v6IqxYstw+p2fVPLaiDV9OE=; b=FV1SGloHpelsyovxBzKXAIqrHdZLXcM/4AvcStzJRArpspfU8nO0RITK4ZtNWly/QZ DUpMwMVaDALtKO0Bfa+lh/INsl3Ciw5BPYlJBOS0iDi2xcxi9VWZxwPTXakq2NXiGl6u iSoUlKdqUmSYPksirkIQabo4e0Hw0G7lVWu6BF98a2pnTLGjUf1ZBn6hbb0NSSV6EkGt NcLcpTGIVTcXXRDPLR74gHI4/dTrzKb2laLJDgsC6mOlqy61zkC6bL4oSfXlPdOJD2y9 BSGAJVAuZ0iDTPeW/5R9vduVAI+iQoUExpxcZ+3lqnGiPe3hIG3RuN21DBZ2jmGggqiw U3pw== X-Forwarded-Encrypted: i=1; AJvYcCX5G42kVI8vqdwA6P7ylzqxD0pfip115f2MPam1yy16Debx+yixhsbN68QSSTShweO7YnJCxNeZnfM6UPQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yymgs4eVbu0iggqtdVn2cgopB5rJH86PWNEsxRxQ9canA6Dg5rx p6V26GKQKtAiiXBFN697G0e4tIo7QCORjGGbladwGmf3jOZ7HdGGdgRC6AH1g7FULfY= X-Gm-Gg: ATEYQzx/0ozE5pOc/u6LdU5DT1lHIMF9CSuiWibmkCmuHy8Rm2LXkr2YGS1+Jg/Bwan GGed42sWLwIpYeIYzTCglmnnn0yyoQyRNIErBd04VonYEy5a3XS1TiKFd70u0ikTgkmoMFrIPTi PYNJz1Btb7Dvozd7mlrf1NK0ZVK8qMuyiDZLoC7MNqD74ux467mGngmtOlC/NT7mj57s9V0Cm7t 6cR8fkoq25WLXoxRgDK5QKsUao6B9xLba7OatvJoArMe7W4xEaeNBDSEwxVDvAY+dJEOjgA+hA5 oirQwcxXHcladuMd7bMVlBmqfgnrTjeHIH+Drbn9/X/FBha9CJvuxhBtD0CIEoXX3varwp98OxM 9fRwepnVIGzKN6T6FI51sFUn7R726cOCoju+1S1mdQ6znoXSNU0Xgq2eP2C/nDAqT4H/lLVamMP 86vGLrpEptznCWVg/HmggrIKprvTZhBzXV1XSYBhnfFFCOcIY+uvrF X-Received: by 2002:a05:600c:4e88:b0:483:7ea3:3de3 with SMTP id 5b1f17b1804b1-48526715266mr28560065e9.2.1772800905597; Fri, 06 Mar 2026 04:41:45 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485276b0c38sm38150505e9.9.2026.03.06.04.41.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 04:41:45 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, Frank.Li@kernel.org, biju.das.jz@bp.renesas.com, geert+renesas@glider.be, fabrizio.castro.jz@renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Long Luu , Claudiu Beznea Subject: [PATCH v9 7/8] dmaengine: sh: rz-dmac: Add device_tx_status() callback Date: Fri, 6 Mar 2026 14:41:32 +0200 Message-ID: <20260306124133.2304687-8-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260306124133.2304687-1-claudiu.beznea.uj@bp.renesas.com> References: <20260306124133.2304687-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 The RZ/G2L SCIFA driver uses dmaengine_prep_slave_sg() to enqueue DMA transfers and implements a timeout mechanism on RX to handle cases where a DMA transfer does not complete. The timeout is implemented using an hrtimer. In the hrtimer callback, dmaengine_tx_status() is called (along with dmaengine_pause()) to retrieve the transfer residue and handle incomplete DMA transfers. Add support for the device_tx_status() callback. Co-developed-by: Long Luu Signed-off-by: Long Luu Signed-off-by: Biju Das Co-developed-by: Claudiu Beznea Signed-off-by: Claudiu Beznea --- Changes in v9: - adjusted the patch description - dropped contribution list for Claudiu Beznea - used Co-developed-by + SoB tags and included Long Luu in the contribution list as well - dropped the read of CRLA in rz_dmac_calculate_residue_bytes_in_vd() and use the copy from the calling function (rz_dmac_chan_get_residue()) Changes in v8: - populated engine->residue_granularity Changes in v7: - none 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 274c9cd40713..3b318fe06f28 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -118,10 +118,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 @@ -684,6 +686,145 @@ 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, u32 crla) +{ + 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, i =3D 0; + + 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, crla); +} + +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 @@ -1006,6 +1147,7 @@ static int rz_dmac_probe(struct platform_device *pdev) engine =3D &dmac->engine; dma_cap_set(DMA_SLAVE, engine->cap_mask); dma_cap_set(DMA_MEMCPY, engine->cap_mask); + engine->residue_granularity =3D DMA_RESIDUE_GRANULARITY_BURST; rz_dmac_writel(dmac, DCTRL_DEFAULT, CHANNEL_0_7_COMMON_BASE + DCTRL); rz_dmac_writel(dmac, DCTRL_DEFAULT, CHANNEL_8_15_COMMON_BASE + DCTRL); =20 @@ -1013,7 +1155,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 Thu Apr 9 17:24:01 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 7632B38E5F0 for ; Fri, 6 Mar 2026 12:41:48 +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=1772800910; cv=none; b=nE6XlpyXS62mu5rfZQGFt6lbdZbW6QaFN/1JhjXPdUNtFY9ZP61oq9tZWZ9LU/r2i4s8ve7tWc3REGeVhVao4GIakz0FPp/gC4OPpSIvPlSuW8cRDjqXBv+VDsLHkoyBYXbL+Q1bcewFxU5UCEBk4a0IJQ1uagviVc/kzeYLpMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772800910; c=relaxed/simple; bh=m8HVDXAI0gFsFczYRIXenJR42GRKUDLDJ1N+K6c+Cok=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KfBECaTsN3D5jpidAfFUyuq+wl+U/N3006FEn8JBoy2vbj18l5I/hP+7+AJYyveO2yOlVlz8nRq/sL0YSw9qdJjn1LpWRFqDdJynxsSNhdjy55rPmmdTZYTTKVYAvdoS7G7ji9IR6bXRgyZ+jwixSxGTcpS/g0ZuHSbTOr9EGr8= 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=N4XPZ5+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="N4XPZ5+V" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-48374014a77so110902625e9.3 for ; Fri, 06 Mar 2026 04:41:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1772800907; x=1773405707; 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=zoqbEN/HoHhqzl9Aahz7CWhnPYMvokOytjXCAykOjvU=; b=N4XPZ5+V6hl/xQylb76IRz/46cOrSgDw+aOkzOJAdHrHcraJ9Yt0nDzZxKFIVMk360 9NEZDV8h3rIPG7hgNYtqieBqR/kg0Y8CTi7T+enDAy7/DPii9RDLIunlWeBwQhpgU119 e3QmU5E3t7lGsEJoQTLMHyF+U9dX7is3Eg9lPsbUKCA3MxnwpczHpz991F5ANuqUqoX0 GU4+79k9ssfpMPwPzMT0A8k/8HAXmg6fewFSX3e23L+NRkEVdBgwvyIR3y110NX2USCh BVQiOYioPlWXt0SEFBCm/l9dDDeSe6A2oXk/Fy7uOSP1OcGrQxK/6HHeMIkknz/6mx4F zrFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772800907; x=1773405707; 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=zoqbEN/HoHhqzl9Aahz7CWhnPYMvokOytjXCAykOjvU=; b=pJYKCgwMLMBhV06nnqDrtwBvhm1FZPlT5Kcw0CIS3OY8dAjSziZfvE2U4fh6OoP8mb dqo/nzNfM5RnOh6ayNzBnm+Res+F/AjP8uejEKQbbgntBN8DpMyCYmwz6ToDDFArT/0O bcv2WNhEUQ4wgGXeU3VkVx8L6/GM8XK303rMzHJHyq9d5lB4hj874d3RRWp+X7BJXB10 YIrOQ05Ip1Chs0tphcwoY55FRvmWKY4okXWN357xVJwjyM8WsW1oy4CcIl/vOacTSwts U9xa2wvly2nurzYdONE4RhB8GFIGZpS2WIDJAN6pS/327B9XUSsF80FxxjPFNnqr8Tav wlsw== X-Forwarded-Encrypted: i=1; AJvYcCXz8VQf2ot+UA76rj94Qvke3SXUxQ2Hm62JScds76yAjkZVuoIscvomldUJ+KCzMfYqZ1z8Ac3VOmh7a1M=@vger.kernel.org X-Gm-Message-State: AOJu0YwaySHfa2ErBlAXKS1apePn3ynsJ+fqdYpCVAWfS50uMdc2yKLx VX/0J2vyeKmOFyX8ENaliktaTO+vgoMLwEGPKAWv5hGLqnTUsdWv3LYm+6b6xQWkovc= X-Gm-Gg: ATEYQzwhArunjNS2xH/0um4YEKxgH2XmorkWhxuOHf4ZA9iXUlVxBh3GbN+3Bor1aJC g8ks+iM0VdPVbat8WKMnhWrViqHOlUCxKDKflpQ72O6oVKjVayQjHSAd8iTefvROIIHP8d7ZBUU yIm0sADZtYBZDKquq/dbMPoA9PHb4SPyNTm8AeGOoU+6qnJ26ho3bULx7fMUPICdBCUjOLCScC+ 8OFXbXLmG/8bkPL5Z39j5LBq3QmF2MqpCLI7jRFIVWRDPQUgtd9oUUgIPbm/wuUylLnkgRILkMj RU2RIaGgovxC+BXLPuzuilKY0eQvVhKFNc4Ke5oJNtcMR4KF14mUsTyb1/zDXWQW/hIfLJ4lHED 4mz2AryFwR4Kl9ys+voNzyO1ln+BH6vj/aKvzjiaIhi+xxysN/MHQ8rsIphhAuhUV97W1Pu0dOg VlqeysSaIodiRoZqZD+wgL29dyzvcbliiOtbZvKKegGppzMx5XtEOX X-Received: by 2002:a05:600c:5303:b0:477:c478:46d7 with SMTP id 5b1f17b1804b1-4852695aa55mr31872855e9.22.1772800906819; Fri, 06 Mar 2026 04:41:46 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485276b0c38sm38150505e9.9.2026.03.06.04.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 04:41:46 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, Frank.Li@kernel.org, biju.das.jz@bp.renesas.com, geert+renesas@glider.be, fabrizio.castro.jz@renesas.com, 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 v9 8/8] dmaengine: sh: rz-dmac: Add device_{pause,resume}() callbacks Date: Fri, 6 Mar 2026 14:41:33 +0200 Message-ID: <20260306124133.2304687-9-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260306124133.2304687-1-claudiu.beznea.uj@bp.renesas.com> References: <20260306124133.2304687-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 RZ/G2L SCIFA driver uses dmaengine_prep_slave_sg() to enqueue DMA transfers and implements a timeout mechanism on RX to handle cases where a DMA transfer does not complete. The timeout is implemented using an hrtimer. In the hrtimer callback, dmaengine_tx_status() is called (along with dmaengine_pause()) to retrieve the transfer residue and handle incomplete DMA transfers. Add support for device_{pause, resume}() callbacks. Signed-off-by: Claudiu Beznea --- Changes in v9: - updated the patch description Changes in v8: - reported residue for paused channels as well Changes in v7: - use guard() instead of scoped_guard() - in rz_dmac_device_pause() checked the channel is enabled before suspending it to avoid read poll timeouts - added a comment in rz_dmac_device_resume() 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 | 49 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index 3b318fe06f28..6ad41e0285f5 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -134,10 +134,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) @@ -813,11 +815,18 @@ static enum dma_status rz_dmac_tx_status(struct dma_c= han *chan, if (status =3D=3D DMA_COMPLETE || !txstate) return status; =20 - scoped_guard(spinlock_irqsave, &channel->vc.lock) + scoped_guard(spinlock_irqsave, &channel->vc.lock) { + u32 val; + residue =3D rz_dmac_chan_get_residue(channel, cookie); =20 - /* if there's no residue, the cookie is complete */ - if (!residue) + val =3D rz_dmac_ch_readl(channel, CHSTAT, 1); + if (val & CHSTAT_SUS) + status =3D DMA_PAUSED; + } + + /* if there's no residue and no paused, the cookie is complete */ + if (!residue && status !=3D DMA_PAUSED) return DMA_COMPLETE; =20 dma_set_residue(txstate, residue); @@ -825,6 +834,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; + + guard(spinlock_irqsave)(&channel->vc.lock); + + val =3D rz_dmac_ch_readl(channel, CHSTAT, 1); + if (!(val & CHSTAT_EN)) + return 0; + + 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); +} + +static int rz_dmac_device_resume(struct dma_chan *chan) +{ + struct rz_dmac_chan *channel =3D to_rz_dmac_chan(chan); + u32 val; + + guard(spinlock_irqsave)(&channel->vc.lock); + + /* Do not check CHSTAT_SUS but rely on HW capabilities. */ + + 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); +} + /* * -----------------------------------------------------------------------= ------ * IRQ handling @@ -1162,6 +1203,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