From: Nuno Sa via B4 Relay <devnull+nuno.sa.analog.com@kernel.org>
To: linux-iio@vger.kernel.org
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"William Breathitt Gray" <william.gray@linaro.org>
Subject: [PATCH] counter: fix privdata alignment
Date: Mon, 05 Feb 2024 16:58:14 +0100 [thread overview]
Message-ID: <20240205-counter-align-fix-v1-1-4821ced960ab@analog.com> (raw)
From: Nuno Sa <nuno.sa@analog.com>
Aligning to the L1 cache does guarantee the same alignment as kmallocing
an object [1]. Furthermore, in some platforms, that alignment is not
sufficient for DMA safety (in case someone wants to have a DMA safe
buffer in privdata) [2].
Sometime ago, we had the same fixes in IIO.
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/base/devres.c#n35
[2]: https://lore.kernel.org/linux-iio/20220508175712.647246-2-jic23@kernel.org/
Fixes: c18e2760308e ("counter: Provide alternative counter registration functions")
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---
William, if you prefer, we can do something like in IIO and add a
specific COUNTER_DMA_MINALIGN define
---
drivers/counter/counter-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/counter/counter-core.c b/drivers/counter/counter-core.c
index 09c77afb33ca..073bf6b67a57 100644
--- a/drivers/counter/counter-core.c
+++ b/drivers/counter/counter-core.c
@@ -34,7 +34,7 @@ struct counter_device_allochelper {
* This is cache line aligned to ensure private data behaves like if it
* were kmalloced separately.
*/
- unsigned long privdata[] ____cacheline_aligned;
+ unsigned long privdata[] __aligned(ARCH_DMA_MINALIGN);
};
static void counter_device_release(struct device *dev)
---
base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
change-id: 20240205-counter-align-fix-3faebfb572af
--
Thanks!
- Nuno Sá
next reply other threads:[~2024-02-05 15:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-05 15:58 Nuno Sa via B4 Relay [this message]
2024-02-08 18:34 ` [PATCH] counter: fix privdata alignment William Breathitt Gray
2024-02-09 7:42 ` Nuno Sá
2024-02-09 8:30 ` Uwe Kleine-König
2024-02-09 9:07 ` Nuno Sá
2024-02-09 9:53 ` William Breathitt Gray
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240205-counter-align-fix-v1-1-4821ced960ab@analog.com \
--to=devnull+nuno.sa.analog.com@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=william.gray@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox