On Wed, Sep 30, 2020 at 07:16:44PM +0200, Paul Cercueil wrote:
> It turns out that if you want to mmap GEM buffers fully cached, then
> they should be allocated as such as well. Who would have known?
> 
> Introduce a custom .dumb_create callback, that will behave just like
> drm_gem_cma_dumb_create(), except that it will allocate the GEM buffer
> using dma_alloc_noncoherent() if non-coherent memory is what we want.

I think you want to merge this with patch 2, then change patch 2 to
still use dma_alloc_wc for the !ingenic_drm_cached_gem_buf and to
get the phys address using virt_to_phys for the
ingenic_drm_cached_gem_buf instead of abusing the dma address in
->paddr.  The free side also needs to use
dma_free_noncoherent.

> +static int ingenic_drm_gem_cma_dumb_create(struct drm_file *file_priv,
> +                                        struct drm_device *drm,
> +                                        struct drm_mode_create_dumb *args)
> +{
> +     /*
> +      * This is basically a copy of drm_gem_cma_dumb_create, which supports
> +      * creating fully cached GEM buffers.
> +      */

What about adding this to the core GEM code instead?  We'll probaby
run into other potential users as well.

Reply via email to