From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: raoxu <raoxu@uniontech.com>
Cc: andreas.noever@gmail.com, westeri@kernel.org,
YehezkelShB@gmail.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH tb-next] thunderbolt: stream: unmap buffers with mapped size
Date: Tue, 23 Jun 2026 14:06:17 +0200 [thread overview]
Message-ID: <20260623120617.GB3066@black.igk.intel.com> (raw)
In-Reply-To: <BCAED571E6DC370E+20260611064530.3495292-1-raoxu@uniontech.com>
Hi,
On Thu, Jun 11, 2026 at 02:45:30PM +0800, raoxu wrote:
> From: Xu Rao <raoxu@uniontech.com>
>
> The size passed to dma_unmap_page() must match the size used for the
> corresponding dma_map_page() call.
>
> Stream RX and TX buffers are mapped with TB_MAX_FRAME_SIZE when the
> buffer pools are allocated. However, tbstream_ring_free() currently uses
> tb_ring_frame_size() as the unmap size.
>
> That helper returns the current frame payload size, not the DMA mapping
> size. On the TX path, tbstream_dev_alloc_tx() stores a shorter payload
> length in frame.size when the payload is smaller than TB_MAX_FRAME_SIZE.
> This happens for a short final DATA frame, and also for the CLOSE frame,
> which is allocated with SZ_256.
>
> In those cases the buffer was mapped with TB_MAX_FRAME_SIZE, but
> tb_ring_frame_size() returns the shorter frame payload length. This makes
> the dma_unmap_page() size differ from the original dma_map_page() size.
>
> Use TB_MAX_FRAME_SIZE when unmapping stream buffers so the unmap size
> matches the DMA mapping size used by the buffer allocation paths.
>
> Signed-off-by: Xu Rao <raoxu@uniontech.com>
Applied to thunderbolt.git/fixes, thanks!
prev parent reply other threads:[~2026-06-23 12:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 6:45 [PATCH tb-next] thunderbolt: stream: unmap buffers with mapped size raoxu
2026-06-23 12:06 ` Mika Westerberg [this message]
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=20260623120617.GB3066@black.igk.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=YehezkelShB@gmail.com \
--cc=andreas.noever@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=raoxu@uniontech.com \
--cc=westeri@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