From nobody Tue Feb 10 14:32:44 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