On Wed, Nov 25, 2026 at 04:59:08PM -0300, Daniel Almeida wrote:
> Hi Alvin,
>
> This patch does quite a few things at once and I'd rather split this.
>
> The change we _really_ need in your series is the stale cache eviction
> problem. It is unfortunate that this is a problem in general, and not
> only in Tyr. For that, using the DMA API as soon as the BO is created is
> enough. You can do that in patch 6 by calling sg_table() before the CPU
> is allowed to touch the buffer, like you already do in this one.
I agree you could add this to Patch 6 (the helpers patch) and I think a
comment would be very helpful. IIUC something like this might work:
+ // Ensure that the CPU cache is flushed before userspace writes to the
buffer.
+ // This prevents a subsequent CPU cache eviction from overwriting user
data with
+ // stale zero data remaining from the initial allocation.
+ // This mismatch can occur when userspace is using the write-combine
+ // caching strategy.
Then if we remove coherency from your series (which I agree with Daniel
is the cleanest approach) then Patch 6 could also
take a very pared-down version of should_map_wc(), something like:
+/// Returns whether a BO should be mapped write-combine.
+/// Write-combine and write-back are mutually exclusive.
+pub(crate) fn should_map_wc(flags: u32) -> bool {
+ flags & uapi::drm_panthor_bo_flags_DRM_PANTHOR_BO_WB_MMAP == 0
+}
+
Then the only place you would need should_map_wc() would be in
new_object() since the dummy object and kernel bo can just keep using
write-combine.
Finally, Patch 6 could also have your getter function for BoData flags
which we will still need for your bo_mmap_offset() callback.
>
> Two other things are done by this patch:
>
> - Honor writeback mappings -> this should be its own patch.
> - Add a "coherent" flag, and thread it through the driver.
>
> What it does not do is "support write combine mappings". In fact, write
> combine mappings is the only thing properly supported and tested so far
> :)
>
> The problem with the second bullet point is that a) everything else
> needed to support coherent==true is missing and b) I don't have a system
> where coherent==true to test this. If others do, great, but even still,
> lets do this as a separate series. So I'd prefer if the coherent flag
> was dropped, along with patch 8.
>
> — Daniel