From nobody Tue Feb 10 07:57:52 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.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 4B3884B9E6D for ; Thu, 8 Jan 2026 10:36:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767868592; cv=none; b=s6tPQYNCJUI3+iE1LAFi/dIov4rx5mGteeF6n4ogcOUz1vDo6ABQA+OnrvULvArEjDPTe226nCfrrQc58nQ+iP37qdPGO1EEwZ4nK428IiLDV/lC+zxp6oV8f+CTIUFj3qk7Lzi/GsDZ7gA1BxT2hnHxj5HgkqWUir2pNjZVqdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767868592; c=relaxed/simple; bh=fyzinmoZgqFGQzgRbE/I7nHy5ErOVP8KVl3+X5XcpuE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LHVDxlQYWfi/XXe8yPG50cGkQMstBWtx+2mtBIfdg8AYVJR8Zt59Z9wdZ1uQPYX12hdElG0WmftdOu6GE3M0+jNnhmqokavxNoEgdu46pIa/zqiD9Oa1qIOY+9PKeKao+DcQMmaEaELVLZtcpZrU5E1VbvvNPRV3/+Yt/OPxJZc= 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=iUXeLhAG; arc=none smtp.client-ip=209.85.128.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="iUXeLhAG" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4779a4fc95aso8836305e9.1 for ; Thu, 08 Jan 2026 02:36:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1767868585; x=1768473385; 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=MlWiT31f3SgtmE+UZqtSfS3Vhw2y+XyQEAsJHfCJGJM=; b=iUXeLhAGI09KUOPeDeh8Zl1t3KTkrzO/7Zo6eptFVMVvnKbjOdutNUKNqbJWY70fq7 CtEFLjlC+RurTj9Spe/BZuwt8u63uKKMPbiPOFximl4d6n1XDDxBScnfIlXyfepWEncH 7lKVnZ6yR2hHNbkF7qw5fwVjG5FdLWvVfqeynvHXHB5gnFhbNPOj+2WCiC5dhdC/IbAJ nGUbpMUQILA0GFQDhBw9lPHuYH8HHdhI+iDdnVgEV0jJlPSmEc9H0YnE/GbooAHtovso bKhHXMt67GzrX1zfR0Hf0MFZ6phJh/JbDPPpgaUkoWp/q3fm12pMRzOvrH2SPeebTrEg bxhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767868585; x=1768473385; 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=MlWiT31f3SgtmE+UZqtSfS3Vhw2y+XyQEAsJHfCJGJM=; b=gYAHV/NdEFSwQxR5NXF04rIKCYo4elQ+ze5j3tPkWUjmSwiGR/Sg5Dtv3d9Q+hdXTA HBGlMEIe7MAqK/trYvHjoRG9N0wqfN4NPqGlYgziySrncc2b4JkL6V/oMbD65SPTzpUK mV0lrTEV7ayy2LjYMkKIa/lF42WeQppvT4zHYEBI75aYimYO3SDkLmb7gsuEnk/fm85W M3wpNDvfc1yBD+VNr2PQdOheDn0/6EpHk5LfI1AfUkfGefajNm5reV9YfN4FGhYodAzu VBC+rlA5m+kpMKiU5CL9qYBGUg6rBxdiBN5GFxvrkWuJRn72BgSWHu0a5F9xaUj/In3V WgQQ== X-Forwarded-Encrypted: i=1; AJvYcCWUSrunMEXz9RhL590ju4vm05X9JWO3wdo1mIura+cFzpJBipBaxYG98THNUf8nNi0hetDKavAJCTMlQSk=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5idJ0gCvn/0Bo2/jdCbSif7JURH7kV+4cjFp2KPtd+u/l72wL Jn+o6VZbebAHLyaonytJ1w8qaDejrhlTfd+jnfnGJRAw6fw1DzlRcW3oB0P4Td6rOO0= X-Gm-Gg: AY/fxX6V+1WD7YFgDrYE636czYzVpQHUyIoLYXBfBhLEVmyjjhVhny/FvhGKDSVbZLM N56vRsTghrbY7RFeNCne0HQAVWDo7B8N4UGon5xEiga8Ju1qzok9pwvQESEBi/XfzY8cJ/6VwWA 73bmVcOZPeS3KgXnsFbj3yQScKnSmLZUghxqmeFGNSNFFFkXX2phRMu4fRtXR+7431o9AWPHjPc 9fejB1GW0B/ECt45ECzww8t330BzDROliOfVbArSDpaa1M+yZMcOVyeJk7KMV4NtTgG7poeFNMJ cBXk988ar7B7gO7riDclYrDhL1Mc5VFOFtPCoK0m1njPKs4InbTp0aKQ49aclsZnkMYQwRxOWml zG5a2LEoQsPw+mqHnSOksiuXvPsSjwjqxNz8xaeDPux8nXDp7kPRsvFR53oEPSgDfGP6cDb6BvF AFUQRxFAiMHp9VVPX4A9CeVOFBeiGemwTgNjkG0c4= X-Google-Smtp-Source: AGHT+IF+EBHPhz3JKj5aczdkdvcVVpNzewaaim609iBvVtqQDrzRGqQxcaDVKwG6DKoC5k9Zk7ZRjA== X-Received: by 2002:a05:600c:8b44:b0:477:7588:c8cc with SMTP id 5b1f17b1804b1-47d7f410cc8mr113421185e9.7.1767868584926; Thu, 08 Jan 2026 02:36:24 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.17]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd5ee243sm15399033f8f.31.2026.01.08.02.36.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 02:36:24 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: vkoul@kernel.org, fabrizio.castro.jz@renesas.com, geert+renesas@glider.be, prabhakar.mahadev-lad.rj@bp.renesas.com, biju.das.jz@bp.renesas.com Cc: claudiu.beznea@tuxon.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 2/8] dmaengine: sh: rz-dmac: Move CHCTRL updates under spinlock Date: Thu, 8 Jan 2026 12:36:14 +0200 Message-ID: <20260108103620.3482147-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260108103620.3482147-1-claudiu.beznea.uj@bp.renesas.com> References: <20260108103620.3482147-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 Signed-off-by: Claudiu Beznea --- 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 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