From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 79E37606A322 for ; Thu, 3 Dec 2026 18:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=42Ncz6/s; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aV2+do8B DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=IATnfvRP1kbXBTulzTx8k3+sjeXA4dEw6CUqXxTgG30=; b=42Ncz6/seKo97o FCJ90lPa+bPJ6JkI18FVRNU0Wv/IRv7fsoYCa4JdJs1MsotvXloQpi/GqKQ+0u9YJCd2aTpFpqYgf zpeC6w+U/xNn/4lxc/sYfRnDfVwKdREisIhwaA5eIlQqbnnSOWqC2cmGQf14/Dd1as07g/N5yslxA gzoW4lbflJYZiAmyaKDdS6xl0eQ5Qdu/ZgZo7ZzJ8N5gpB2G12WLWTVJQkUJAumIaNbWsy6gq3SE7 rOnU0fK3z6i9D/ykL495/ZODOqCv8146wSyfSeIHMl0fM5JtdVzmzKrH7hjO5rwt+HIa4g//3O/kL I5GAB1CbAZZut7zbq2kQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZBcH-0000000FaMf-2qBR; Thu, 03 Dec 2026 18:33:13 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZBcF-0000000FaLx-2UZk for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2026 18:33:11 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id D3D2B43C73; Thu, 3 Dec 2026 18:33:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E55B1F00898; Thu, 3 Dec 2026 18:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796322790; bh=IATnfvRP1kbXBTulzTx8k3+sjeXA4dEw6CUqXxTgG30=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aV2+do8B7JIofNP/VzwZFF+AAyUUbFd7XswoHVEk713QaI1gkdSTPjmm3/NVspXMt 0BEQdDeQ0z8+Bs0OkzFAYNRdJDE4B4sQaMNyW4fKHhPxpthZVbXazPKYBUu90fx1C4 OZQTZxu6zT6qKsyXK1+vJG1cKPJcGj7XBMh6A94MyRB0aqzF3r++afTN5JFI8qTjjg NNxoHIKJYd5TQOh9v+//J+zMhLqpN+ejqB3sXrQNWdNk6bIk/N4rykT7+gfunyme61 Jauhj61uOHSlB624CKcclyyjg50BDaqolFgRbWWc+fjUBfvESyMS7qQKrqa/5GMYhQ dRBanq0GES2Jg== From: Lee Jones To: lee@kernel.org, Pierre-Yves MORDRET , Alain Volmat , Andi Shyti , Maxime Coquelin , Alexandre Torgue , Cedric Madianga , Wolfram Sang , linux-i2c@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 06/10] i2c: stm32f7: Allocate smbus_buf separately for DMA safety Date: Thu, 3 Dec 2026 18:31:10 +0000 Message-ID: <20261203183214.1939736-7-lee@kernel.org> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog In-Reply-To: <20261203183214.1939736-1-lee@kernel.org> References: <20261203183214.1939736-1-lee@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 smbus_buf is embedded directly inside struct stm32f7_i2c_msg (and thus struct stm32f7_i2c_dev), sharing a CPU cacheline with adjacent driver state. Passing it to dma_map_single() on non-coherent ARM/ARM64 SoCs can corrupt adjacent fields during cache invalidation or corrupt DMA data via concurrent CPU writes. Allocate smbus_buf separately with devm_kzalloc() during probe so it is isolated in its own DMA-safe allocation. Fixes: 7ecc8cfde553 ("i2c: i2c-stm32f7: Add DMA support") Closes: https://sashiko.dev/#/bug/linux-0de0fdd3-8e61-4777-a456-ad4761a2207c Cc: stable@vger.kernel.org Signed-off-by: Lee Jones --- drivers/i2c/busses/i2c-stm32f7.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c index 1ebb2e0bc1b0..720e1d46da09 100644 --- a/drivers/i2c/busses/i2c-stm32f7.c +++ b/drivers/i2c/busses/i2c-stm32f7.c @@ -285,7 +285,7 @@ struct stm32f7_i2c_msg { bool smbus; int size; char read_write; - u8 smbus_buf[I2C_SMBUS_BLOCK_MAX + 3] __aligned(4); + u8 *smbus_buf; }; /** @@ -2186,6 +2186,12 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) if (!i2c_dev) return -ENOMEM; + i2c_dev->f7_msg.smbus_buf = devm_kzalloc(&pdev->dev, + I2C_SMBUS_BLOCK_MAX + 3, + GFP_KERNEL); + if (!i2c_dev->f7_msg.smbus_buf) + return -ENOMEM; + setup = of_device_get_match_data(&pdev->dev); if (!setup) return dev_err_probe(&pdev->dev, -ENODEV, "Can't get device data\n"); -- 2.56.1.911.g883d8bcb20-goog