From: Jonathan Cameron <jic23@kernel.org>
To: Lauri Kasanen <cand@gmx.com>
Cc: linux-input@vger.kernel.org,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH 7/9] Input: n64joy - Fix DMA buffer alignment.
Date: Sun, 27 Nov 2022 18:01:26 +0000 [thread overview]
Message-ID: <20221127180126.349290c3@jic23-huawei> (raw)
In-Reply-To: <20221127184844.f967054e30c47a3caa5090eb@gmx.com>
On Sun, 27 Nov 2022 18:48:44 +0200
Lauri Kasanen <cand@gmx.com> wrote:
> On Sun, 27 Nov 2022 14:41:14 +0000
> Jonathan Cameron <jic23@kernel.org> wrote:
>
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > The use of ____cacheline_aligned to ensure a buffer is DMA safe only
> > enforces the start of the buffer alignment. In this case, sufficient
> > alignment is already ensured by the use of kzalloc().
> > ____cacheline_aligned does not ensure that no other members of the
> > structure are placed in the same cacheline after the end of the
> > buffer marked. Thus to ensure a DMA safe buffer it must be at the end
> > of the structure.
>
> This move is unnecessary, because the cacheline is 16 bytes and the
> buffer is 64 bytes.
Ah. That particular option hadn't occurred to me (and I'd failed to notice
how big the buffer is :( ).
The marking isn't needed at all then as the allocation is already
guaranteed to be sufficiently aligned. However, maybe that is a bit subtle
and having some sort of marking is useful.
Curious question though, why is the buffer so big?
Each struct joydata is 8 bytes I think, but the driver only accesses 4 of them.
Is the hardware putting garbage into the remaining 2 cachelines or is there
something subtle going on?
Or given my earlier success, maybe I'm misreading the code entirely.
Jonathan
>
> > Whilst here switch from ____cacheline_aligned to
> > __aligned(ARCH_KMALLOC_MINALIGN) as on some architectures, with variable
> > sized cacheline lines across their cache hierarchy, require this
> > greater alignment guarantee for DMA safety. Make this change throughout
> > the driver as it reduces need for a reader to know about the particular
> > architecture.
>
> This change looks ok.
>
> - Lauri
next prev parent reply other threads:[~2022-11-27 17:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-27 14:41 [PATCH 0/9] Input: Fix insufficent DMA alignment Jonathan Cameron
2022-11-27 14:41 ` [PATCH 1/9] Input: psxpad - Fix padding for DMA safe buffers Jonathan Cameron
2022-11-27 14:41 ` [PATCH 2/9] Input: ad714x " Jonathan Cameron
2022-11-28 7:14 ` Hennerich, Michael
2022-11-27 14:41 ` [PATCH 3/9] Input: ad7887 " Jonathan Cameron
2022-11-28 7:14 ` Hennerich, Michael
2022-11-27 14:41 ` [PATCH 4/9] Input: ads7846 " Jonathan Cameron
2022-11-27 14:41 ` [PATCH 5/9] Input: cyttsp " Jonathan Cameron
2022-11-27 14:41 ` [PATCH 6/9] Input: surface3 " Jonathan Cameron
2022-11-27 16:26 ` Jonathan Cameron
2022-11-27 14:41 ` [PATCH 7/9] Input: n64joy - Fix DMA buffer alignment Jonathan Cameron
2022-11-27 16:48 ` Lauri Kasanen
2022-11-27 18:01 ` Jonathan Cameron [this message]
2022-11-28 6:49 ` Lauri Kasanen
2022-11-28 18:04 ` Dmitry Torokhov
2022-11-27 14:41 ` [PATCH 8/9] Input: atmel_captouch - Avoid suspect " Jonathan Cameron
2022-11-27 14:41 ` [PATCH 9/9] Input: elants - Fix " Jonathan Cameron
2022-11-28 18:16 ` [PATCH 0/9] Input: Fix insufficent DMA alignment Dmitry Torokhov
2022-11-29 9:18 ` Jonathan Cameron
2022-11-30 1:23 ` Dmitry Torokhov
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=20221127180126.349290c3@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=cand@gmx.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).