Message ID | 20240126165856.1199387-1-l.stach@pengutronix.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/etnaviv: fix DMA direction handling for cached read/write buffers | expand |
Hi Lucas, On Fri, 26 Jan 2024 at 17:00, Lucas Stach <l.stach@pengutronix.de> wrote: > The dma sync operation needs to be done with DMA_BIDIRECTIONAL when > the BO is prepared for both read and write operations. With the > current inverted if ladder it would only be synced for DMA_FROM_DEVICE. > > [...] > > static inline enum dma_data_direction etnaviv_op_to_dma_dir(u32 op) > { > - if (op & ETNA_PREP_READ) > + if (op & (ETNA_PREP_READ | ETNA_PREP_WRITE)) > + return DMA_BIDIRECTIONAL; This test will always be true for _either_ read or write. Cheers, Daniel
Hi, On 2024/1/29 18:29, Daniel Stone wrote: > Hi Lucas, > > On Fri, 26 Jan 2024 at 17:00, Lucas Stach <l.stach@pengutronix.de> wrote: >> The dma sync operation needs to be done with DMA_BIDIRECTIONAL when >> the BO is prepared for both read and write operations. With the >> current inverted if ladder it would only be synced for DMA_FROM_DEVICE. >> >> [...] >> >> static inline enum dma_data_direction etnaviv_op_to_dma_dir(u32 op) >> { >> - if (op & ETNA_PREP_READ) >> + if (op & (ETNA_PREP_READ | ETNA_PREP_WRITE)) >> + return DMA_BIDIRECTIONAL; > This test will always be true for _either_ read or write. Haha, I think it should be"if ((op & ETNA_PREP_READ) && (op & ETNA_PREP_WRITE))" > Cheers, > Daniel
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index b5f73502e3dd..d788a27aacb8 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -356,12 +356,14 @@ static void *etnaviv_gem_vmap_impl(struct etnaviv_gem_object *obj) static inline enum dma_data_direction etnaviv_op_to_dma_dir(u32 op) { - if (op & ETNA_PREP_READ) + if (op & (ETNA_PREP_READ | ETNA_PREP_WRITE)) + return DMA_BIDIRECTIONAL; + else if (op & ETNA_PREP_READ) return DMA_FROM_DEVICE; else if (op & ETNA_PREP_WRITE) return DMA_TO_DEVICE; - else - return DMA_BIDIRECTIONAL; + + return DMA_NONE; } int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op,
The dma sync operation needs to be done with DMA_BIDIRECTIONAL when the BO is prepared for both read and write operations. With the current inverted if ladder it would only be synced for DMA_FROM_DEVICE. Fixes: a8c21a5451d8 ("drm/etnaviv: add initial etnaviv DRM driver") Signed-off-by: Lucas Stach <l.stach@pengutronix.de> --- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)