Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0648606A32F for ; Thu, 3 Dec 2026 19:35:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=T6Oeb9hn Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 04E2A112B4A; Thu, 3 Dec 2026 19:34:58 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 87FC3112B4A for ; Thu, 3 Dec 2026 19:34:51 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 1F4C24455E; Thu, 3 Dec 2026 19:34:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D33CC1F000C2; Thu, 3 Dec 2026 19:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796326491; bh=2KwadswVuwdwCHhg5C2+qvSY0FKpQnhbmaNTrt0ICU0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=T6Oeb9hnSE+p6lt2m8rLpLcQxE7XEpR7nsurCzgvCmM9SSpy8n7MJtsLks3eH+LeZ yKUichrEgnZIn+TDJZ+qNJTY9h/lucxzotz2AIcu9KW7ZPRhODY2UMN57jFiSiFiNG dm3T2RyuYjues4iqTfLZoBvKr+BohQImWdpCn1Vvx79EWiJAUAptfTsOH7DE7+j5zb UntofN7EAD5l625A3j3IKB90ueYKRSwZa3B5cX5oQDOvRKKcHFLh14nGppCyQbGMFF LxSWmDWdl7e1ZWKOMyipBj+G4skb5+MvuIZwJor800zmaeFE2dd0ymahBhpVKbNsN8 /HQEWafRasjeA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 03/10] i2c: sh_mobile: Terminate DMA before freeing bounce buffer in sh_mobile_xfer() To: "Lee Jones" , dri-devel@lists.freedesktop.org Cc: media-ci@linuxtv.org, wsa+renesas@sang-engineering.com In-Reply-To: <20261203183214.1939736-4-lee@kernel.org> References: <20261203183214.1939736-1-lee@kernel.org> <20261203183214.1939736-4-lee@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 19:34:49 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] i2c: sh_mobile: data race on dma_direction in sh_mobile_i2c_dma_callback() -- commit c6b6af1c3ce9c1df00cdd2b1dc80f991c809d4d9 Author: Lee Jones i2c: sh_mobile: Terminate DMA before freeing bounce buffer in sh_mobile_xfe= r() This commit terminates and synchronizes any active DMA channel in sh_mobile_xfer() before freeing the bounce buffer with i2c_put_dma_safe_msg_buf(). It also selects the DMA channel from pd->msg->flags, re-checks pd->dma_direction after dmaengine_terminate_sync(= ), and reorders sh_mobile_i2c_dma_callback(). > diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-= sh_mobile.c > index 0d10742a8ec0c..d7aa710767c75 100644 > --- a/drivers/i2c/busses/i2c-sh_mobile.c > +++ b/drivers/i2c/busses/i2c-sh_mobile.c [ ... ] > @@ -462,11 +467,10 @@ static void sh_mobile_i2c_dma_callback(void *data) > { > struct sh_mobile_i2c_data *pd =3D data; > =20 > - sh_mobile_i2c_cleanup_dma(pd, false); > pd->pos =3D pd->msg->len; > pd->stop_after_dma =3D true; > - > iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE); > + sh_mobile_i2c_cleanup_dma(pd, false); > } [Severity: Low] Does moving sh_mobile_i2c_cleanup_dma() after iic_set_clr() introduce a data race on pd->dma_direction? Clearing ICIC_TDMAE and ICIC_RDMAE unmasks the I2C hardware interrupt before dma_unmap_single() and the store to pd->dma_direction complete: CPU0 (DMAC threaded IRQ) CPU1 () sh_mobile_i2c_dma_callback() iic_set_clr(pd, ICIC, 0, ...) sh_mobile_i2c_cleanup_dma() sh_mobile_i2c_isr() dma_unmap_single(...) pd->dma_direction =3D DMA_NONE if (pd->dma_direction =3D=3D ...) <-- data race sh_mobile_i2c_isr() reads pd->dma_direction unconditionally without locking or READ_ONCE(), triggering a KCSAN data race on every normal DMA completion. It can also wake sh_mobile_xfer() before dma_unmap_single() finishes, forci= ng dmaengine_terminate_sync() to wait on the callback. Calling sh_mobile_i2c_cleanup_dma(pd, false) after setting pd->pos and pd->stop_after_dma, but before iic_set_clr(), avoids both the data race and the premature wakeup. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203183214.1939= 736-1-lee@kernel.org?part=3D3