aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark2016-05-31 11:06:50 -0500
committerRob Clark2016-07-20 18:42:21 -0500
commiteb846d46bca614f24c50f3fa89f94a6820e16589 (patch)
treeef805cc2fe2f4ee02694eeeecbf3c8904d20ea47 /freedreno/msm/msm_bo.c
parent0c270df8dfde6d6d7b7adb236cd3325f2c0115bd (diff)
downloadexternal-libgbm-eb846d46bca614f24c50f3fa89f94a6820e16589.tar.gz
external-libgbm-eb846d46bca614f24c50f3fa89f94a6820e16589.tar.xz
external-libgbm-eb846d46bca614f24c50f3fa89f94a6820e16589.zip
freedreno: add madvise support
With a new enough drm/msm, we can let the kernel know about buffers that are in the bo cache, so the kernel can free them under memory pressure. Signed-off-by: Rob Clark <robclark@freedesktop.org>
Diffstat (limited to 'freedreno/msm/msm_bo.c')
-rw-r--r--freedreno/msm/msm_bo.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/freedreno/msm/msm_bo.c b/freedreno/msm/msm_bo.c
index cd05a6cd..cfaec827 100644
--- a/freedreno/msm/msm_bo.c
+++ b/freedreno/msm/msm_bo.c
@@ -89,6 +89,25 @@ static void msm_bo_cpu_fini(struct fd_bo *bo)
89 drmCommandWrite(bo->dev->fd, DRM_MSM_GEM_CPU_FINI, &req, sizeof(req)); 89 drmCommandWrite(bo->dev->fd, DRM_MSM_GEM_CPU_FINI, &req, sizeof(req));
90} 90}
91 91
92static int msm_bo_madvise(struct fd_bo *bo, int willneed)
93{
94 struct drm_msm_gem_madvise req = {
95 .handle = bo->handle,
96 .madv = willneed ? MSM_MADV_WILLNEED : MSM_MADV_DONTNEED,
97 };
98 int ret;
99
100 /* older kernels do not support this: */
101 if (bo->dev->version < 1)
102 return willneed;
103
104 ret = drmCommandWriteRead(bo->dev->fd, DRM_MSM_GEM_MADVISE, &req, sizeof(req));
105 if (ret)
106 return ret;
107
108 return req.retained;
109}
110
92static void msm_bo_destroy(struct fd_bo *bo) 111static void msm_bo_destroy(struct fd_bo *bo)
93{ 112{
94 struct msm_bo *msm_bo = to_msm_bo(bo); 113 struct msm_bo *msm_bo = to_msm_bo(bo);
@@ -100,6 +119,7 @@ static const struct fd_bo_funcs funcs = {
100 .offset = msm_bo_offset, 119 .offset = msm_bo_offset,
101 .cpu_prep = msm_bo_cpu_prep, 120 .cpu_prep = msm_bo_cpu_prep,
102 .cpu_fini = msm_bo_cpu_fini, 121 .cpu_fini = msm_bo_cpu_fini,
122 .madvise = msm_bo_madvise,
103 .destroy = msm_bo_destroy, 123 .destroy = msm_bo_destroy,
104}; 124};
105 125