diff options
author | Christian König <christian.koenig@amd.com> | 2017-10-26 12:06:23 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-02-19 14:17:39 -0500 |
commit | 5d43be0ccbc2f94aa872dfbe37c969510b8c77d6 (patch) | |
tree | 936d8b7d430f9b72f7d0d812e33f90016fc1b513 /drivers | |
parent | c8553f4bd29d681706dd97519e2daddf90505978 (diff) |
drm/amdgpu: allow framebuffer in GART memory as well
On CZ and newer APUs we can pin the fb into GART as well as VRAM.
v2: Don't enable gpu_vm_support for Raven yet since it leads to
a black screen. Need to debug this further before enabling.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Samuel Li <samuel.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_display.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11 |
4 files changed, 29 insertions, 7 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 38d47559f098..8ede2645a06c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "amdgpu_i2c.h" | 29 | #include "amdgpu_i2c.h" |
30 | #include "atom.h" | 30 | #include "atom.h" |
31 | #include "amdgpu_connectors.h" | 31 | #include "amdgpu_connectors.h" |
32 | #include "amdgpu_display.h" | ||
32 | #include <asm/div64.h> | 33 | #include <asm/div64.h> |
33 | 34 | ||
34 | #include <linux/pm_runtime.h> | 35 | #include <linux/pm_runtime.h> |
@@ -189,7 +190,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc, | |||
189 | goto cleanup; | 190 | goto cleanup; |
190 | } | 191 | } |
191 | 192 | ||
192 | r = amdgpu_bo_pin(new_abo, AMDGPU_GEM_DOMAIN_VRAM, &base); | 193 | r = amdgpu_bo_pin(new_abo, amdgpu_display_framebuffer_domains(adev), &base); |
193 | if (unlikely(r != 0)) { | 194 | if (unlikely(r != 0)) { |
194 | DRM_ERROR("failed to pin new abo buffer before flip\n"); | 195 | DRM_ERROR("failed to pin new abo buffer before flip\n"); |
195 | goto unreserve; | 196 | goto unreserve; |
@@ -502,6 +503,17 @@ static const struct drm_framebuffer_funcs amdgpu_fb_funcs = { | |||
502 | .create_handle = amdgpu_user_framebuffer_create_handle, | 503 | .create_handle = amdgpu_user_framebuffer_create_handle, |
503 | }; | 504 | }; |
504 | 505 | ||
506 | uint32_t amdgpu_display_framebuffer_domains(struct amdgpu_device *adev) | ||
507 | { | ||
508 | uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM; | ||
509 | |||
510 | if (adev->asic_type >= CHIP_CARRIZO && adev->asic_type < CHIP_RAVEN && | ||
511 | adev->flags & AMD_IS_APU) | ||
512 | domain |= AMDGPU_GEM_DOMAIN_GTT; | ||
513 | |||
514 | return domain; | ||
515 | } | ||
516 | |||
505 | int | 517 | int |
506 | amdgpu_framebuffer_init(struct drm_device *dev, | 518 | amdgpu_framebuffer_init(struct drm_device *dev, |
507 | struct amdgpu_framebuffer *rfb, | 519 | struct amdgpu_framebuffer *rfb, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.h index 0bcb6c6e0ca9..1ef79d268238 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #ifndef __AMDGPU_DISPLAY_H__ | 23 | #ifndef __AMDGPU_DISPLAY_H__ |
24 | #define __AMDGPU_DISPLAY_H__ | 24 | #define __AMDGPU_DISPLAY_H__ |
25 | 25 | ||
26 | uint32_t amdgpu_display_framebuffer_domains(struct amdgpu_device *adev); | ||
26 | struct drm_framebuffer * | 27 | struct drm_framebuffer * |
27 | amdgpu_user_framebuffer_create(struct drm_device *dev, | 28 | amdgpu_user_framebuffer_create(struct drm_device *dev, |
28 | struct drm_file *file_priv, | 29 | struct drm_file *file_priv, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c index ff3e9beb7d19..17a3ef297fd6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | |||
@@ -38,6 +38,8 @@ | |||
38 | 38 | ||
39 | #include <linux/vga_switcheroo.h> | 39 | #include <linux/vga_switcheroo.h> |
40 | 40 | ||
41 | #include "amdgpu_display.h" | ||
42 | |||
41 | /* object hierarchy - | 43 | /* object hierarchy - |
42 | this contains a helper + a amdgpu fb | 44 | this contains a helper + a amdgpu fb |
43 | the helper contains a pointer to amdgpu framebuffer baseclass. | 45 | the helper contains a pointer to amdgpu framebuffer baseclass. |
@@ -124,7 +126,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev, | |||
124 | struct drm_gem_object *gobj = NULL; | 126 | struct drm_gem_object *gobj = NULL; |
125 | struct amdgpu_bo *abo = NULL; | 127 | struct amdgpu_bo *abo = NULL; |
126 | bool fb_tiled = false; /* useful for testing */ | 128 | bool fb_tiled = false; /* useful for testing */ |
127 | u32 tiling_flags = 0; | 129 | u32 tiling_flags = 0, domain; |
128 | int ret; | 130 | int ret; |
129 | int aligned_size, size; | 131 | int aligned_size, size; |
130 | int height = mode_cmd->height; | 132 | int height = mode_cmd->height; |
@@ -135,12 +137,12 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev, | |||
135 | /* need to align pitch with crtc limits */ | 137 | /* need to align pitch with crtc limits */ |
136 | mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp, | 138 | mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp, |
137 | fb_tiled); | 139 | fb_tiled); |
140 | domain = amdgpu_display_framebuffer_domains(adev); | ||
138 | 141 | ||
139 | height = ALIGN(mode_cmd->height, 8); | 142 | height = ALIGN(mode_cmd->height, 8); |
140 | size = mode_cmd->pitches[0] * height; | 143 | size = mode_cmd->pitches[0] * height; |
141 | aligned_size = ALIGN(size, PAGE_SIZE); | 144 | aligned_size = ALIGN(size, PAGE_SIZE); |
142 | ret = amdgpu_gem_object_create(adev, aligned_size, 0, | 145 | ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain, |
143 | AMDGPU_GEM_DOMAIN_VRAM, | ||
144 | AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | | 146 | AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | |
145 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | | 147 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | |
146 | AMDGPU_GEM_CREATE_VRAM_CLEARED, | 148 | AMDGPU_GEM_CREATE_VRAM_CLEARED, |
@@ -166,7 +168,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev, | |||
166 | } | 168 | } |
167 | 169 | ||
168 | 170 | ||
169 | ret = amdgpu_bo_pin(abo, AMDGPU_GEM_DOMAIN_VRAM, NULL); | 171 | ret = amdgpu_bo_pin(abo, domain, NULL); |
170 | if (ret) { | 172 | if (ret) { |
171 | amdgpu_bo_unreserve(abo); | 173 | amdgpu_bo_unreserve(abo); |
172 | goto out_unref; | 174 | goto out_unref; |
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index ed7b0eff763f..4897beda82bc 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | |||
@@ -2984,11 +2984,13 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane, | |||
2984 | { | 2984 | { |
2985 | struct amdgpu_framebuffer *afb; | 2985 | struct amdgpu_framebuffer *afb; |
2986 | struct drm_gem_object *obj; | 2986 | struct drm_gem_object *obj; |
2987 | struct amdgpu_device *adev; | ||
2987 | struct amdgpu_bo *rbo; | 2988 | struct amdgpu_bo *rbo; |
2988 | uint64_t chroma_addr = 0; | 2989 | uint64_t chroma_addr = 0; |
2989 | int r; | ||
2990 | struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old; | 2990 | struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old; |
2991 | unsigned int awidth; | 2991 | unsigned int awidth; |
2992 | uint32_t domain; | ||
2993 | int r; | ||
2992 | 2994 | ||
2993 | dm_plane_state_old = to_dm_plane_state(plane->state); | 2995 | dm_plane_state_old = to_dm_plane_state(plane->state); |
2994 | dm_plane_state_new = to_dm_plane_state(new_state); | 2996 | dm_plane_state_new = to_dm_plane_state(new_state); |
@@ -3002,12 +3004,17 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane, | |||
3002 | 3004 | ||
3003 | obj = afb->obj; | 3005 | obj = afb->obj; |
3004 | rbo = gem_to_amdgpu_bo(obj); | 3006 | rbo = gem_to_amdgpu_bo(obj); |
3007 | adev = amdgpu_ttm_adev(rbo->tbo.bdev); | ||
3005 | r = amdgpu_bo_reserve(rbo, false); | 3008 | r = amdgpu_bo_reserve(rbo, false); |
3006 | if (unlikely(r != 0)) | 3009 | if (unlikely(r != 0)) |
3007 | return r; | 3010 | return r; |
3008 | 3011 | ||
3009 | r = amdgpu_bo_pin(rbo, AMDGPU_GEM_DOMAIN_VRAM, &afb->address); | 3012 | if (plane->type != DRM_PLANE_TYPE_CURSOR) |
3013 | domain = amdgpu_display_framebuffer_domains(adev); | ||
3014 | else | ||
3015 | domain = AMDGPU_GEM_DOMAIN_VRAM; | ||
3010 | 3016 | ||
3017 | r = amdgpu_bo_pin(rbo, domain, &afb->address); | ||
3011 | 3018 | ||
3012 | amdgpu_bo_unreserve(rbo); | 3019 | amdgpu_bo_unreserve(rbo); |
3013 | 3020 | ||