• Arnd Bergmann's avatar
    drm/msm: gpu: don't abuse dma_alloc for non-DMA allocations · 8f93e043
    Arnd Bergmann authored
    In zap_shader_load_mdt(), we pass a pointer to a phys_addr_t
    into dmam_alloc_coherent, which the compiler warns about:
    
    drivers/gpu/drm/msm/adreno/a5xx_gpu.c: In function 'zap_shader_load_mdt':
    drivers/gpu/drm/msm/adreno/a5xx_gpu.c:54:50: error: passing argument 3 of 'dmam_alloc_coherent' from incompatible pointer type [-Werror=incompatible-pointer-types]
    
    The returned DMA address is later passed on to a function that
    takes a phys_addr_t, so it's clearly wrong to use the DMA
    mapping interface here: the memory may be uncached, or the
    address may be completely wrong if there is an IOMMU connected
    to the device. What the code actually wants to do is to get
    the physical address from the reserved-mem node. It goes through
    the dma-mapping interfaces for obscure reasons, and this
    apparently only works by chance, relying on specific bugs
    in the error handling of the arm64 dma-mapping implementation.
    
    The same problem existed in the "venus" media driver, which was
    now fixed by Stanimir Varbanov after long discussions.
    
    In order to make some progress here, I have now ported his
    approach over to the adreno driver. The patch is currently
    untested, and should get a good review, but it is now much
    simpler than the original, and it should be obvious what
    goes wrong if I made a mistake in the port.
    
    See also: a6e2d36b ("media: venus: don't abuse dma_alloc for non-DMA allocations")
    Cc: Stanimir Varbanov <stanimir.varbanov@linaro.org>
    Fixes: 7c65817e ("drm/msm: gpu: Enable zap shader for A5XX")
    Acked-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
    Acked-and-Tested-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
    Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
    Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
    8f93e043
a5xx_gpu.h 1.48 KB