forked from Minki/linux
8f93e043d0
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:a6e2d36bf6
("media: venus: don't abuse dma_alloc for non-DMA allocations") Cc: Stanimir Varbanov <stanimir.varbanov@linaro.org> Fixes:7c65817e6d
("drm/msm: gpu: Enable zap shader for A5XX") Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org> Acked-and-Tested-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Rob Clark <robdclark@gmail.com>
63 lines
1.5 KiB
C
63 lines
1.5 KiB
C
/* Copyright (c) 2016 The Linux Foundation. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 and
|
|
* only version 2 as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
*/
|
|
#ifndef __A5XX_GPU_H__
|
|
#define __A5XX_GPU_H__
|
|
|
|
#include "adreno_gpu.h"
|
|
|
|
/* Bringing over the hack from the previous targets */
|
|
#undef ROP_COPY
|
|
#undef ROP_XOR
|
|
|
|
#include "a5xx.xml.h"
|
|
|
|
struct a5xx_gpu {
|
|
struct adreno_gpu base;
|
|
struct platform_device *pdev;
|
|
|
|
struct drm_gem_object *pm4_bo;
|
|
uint64_t pm4_iova;
|
|
|
|
struct drm_gem_object *pfp_bo;
|
|
uint64_t pfp_iova;
|
|
|
|
struct drm_gem_object *gpmu_bo;
|
|
uint64_t gpmu_iova;
|
|
uint32_t gpmu_dwords;
|
|
|
|
uint32_t lm_leakage;
|
|
};
|
|
|
|
#define to_a5xx_gpu(x) container_of(x, struct a5xx_gpu, base)
|
|
|
|
int a5xx_power_init(struct msm_gpu *gpu);
|
|
void a5xx_gpmu_ucode_init(struct msm_gpu *gpu);
|
|
|
|
static inline int spin_usecs(struct msm_gpu *gpu, uint32_t usecs,
|
|
uint32_t reg, uint32_t mask, uint32_t value)
|
|
{
|
|
while (usecs--) {
|
|
udelay(1);
|
|
if ((gpu_read(gpu, reg) & mask) == value)
|
|
return 0;
|
|
cpu_relax();
|
|
}
|
|
|
|
return -ETIMEDOUT;
|
|
}
|
|
|
|
bool a5xx_idle(struct msm_gpu *gpu);
|
|
void a5xx_set_hwcg(struct msm_gpu *gpu, bool state);
|
|
|
|
#endif /* __A5XX_GPU_H__ */
|