Skip to contentSkip to conversation

drm/amdgpu: allow framebuffer in GART memory as well

PATCH Applied Samuel Li 7 participants 10 messages Jan 4, 2018 – Jan 5, 2018 3 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

Samuel Li

author
#0 lore raw

PATCH 1/3 drm/amdgpu: allow framebuffer in GART memory as well

From: Christian König <[email protected]>

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.

Change-Id Id0f8af3110e54a3aabf7a258871867bc121cc1a2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 14 +++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h       |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c            | 10 ++++++----
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11 +++++++++--
 4 files changed, 29 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +13 -1
index d704a45..d9fdc19 100644
@@ -29,6 +29,7 @@
 #include "amdgpu_i2c.h"
 #include "atom.h"
 #include "amdgpu_connectors.h"
+#include "amdgpu_display.h"
 #include <asm/div64.h>
 
 #include <linux/pm_runtime.h>
@@ -188,7 +189,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
 		goto cleanup;
 	}
 
-	r = amdgpu_bo_pin(new_abo, AMDGPU_GEM_DOMAIN_VRAM, &base);
+	r = amdgpu_bo_pin(new_abo, amdgpu_framebuffer_domains(adev), &base);
 	if (unlikely(r != 0)) {
 		DRM_ERROR("failed to pin new abo buffer before flip\n");
 		goto unreserve;
@@ -501,6 +502,17 @@ static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
 	.create_handle = amdgpu_user_framebuffer_create_handle,
 };
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev)
+{
+	uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM;
+
+	if (adev->asic_type >= CHIP_CARRIZO && adev->asic_type < CHIP_RAVEN &&
+	    adev->flags & AMD_IS_APU)
+		domain |= AMDGPU_GEM_DOMAIN_GTT;
+
+	return domain;
+}
+
 int
 amdgpu_framebuffer_init(struct drm_device *dev,
 			struct amdgpu_framebuffer *rfb,
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h +1 -0
index 11ae4ab..f241949 100644
@@ -23,6 +23,7 @@
 #ifndef __AMDGPU_DISPLAY_H__
 #define __AMDGPU_DISPLAY_H__
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev);
 struct drm_framebuffer *
 amdgpu_user_framebuffer_create(struct drm_device *dev,
 			       struct drm_file *file_priv,
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +6 -4
index 90fa8e8..9be3228 100644
@@ -38,6 +38,8 @@
 
 #include <linux/vga_switcheroo.h>
 
+#include "amdgpu_display.h"
+
 /* object hierarchy -
    this contains a helper + a amdgpu fb
    the helper contains a pointer to amdgpu framebuffer baseclass.
@@ -124,7 +126,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
 	struct drm_gem_object *gobj = NULL;
 	struct amdgpu_bo *abo = NULL;
 	bool fb_tiled = false; /* useful for testing */
-	u32 tiling_flags = 0;
+	u32 tiling_flags = 0, domain;
 	int ret;
 	int aligned_size, size;
 	int height = mode_cmd->height;
@@ -135,12 +137,12 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
 	/* need to align pitch with crtc limits */
 	mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp,
 						  fb_tiled);
+	domain = amdgpu_framebuffer_domains(adev);
 
 	height = ALIGN(mode_cmd->height, 8);
 	size = mode_cmd->pitches[0] * height;
 	aligned_size = ALIGN(size, PAGE_SIZE);
-	ret = amdgpu_gem_object_create(adev, aligned_size, 0,
-				       AMDGPU_GEM_DOMAIN_VRAM,
+	ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain,
 				       AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
 				       AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
 				       AMDGPU_GEM_CREATE_VRAM_CLEARED,
@@ -166,7 +168,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
 	}
 
 
-	ret = amdgpu_bo_pin(abo, AMDGPU_GEM_DOMAIN_VRAM, NULL);
+	ret = amdgpu_bo_pin(abo, domain, NULL);
 	if (ret) {
 		amdgpu_bo_unreserve(abo);
 		goto out_unref;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +9 -2
index a3bf021..9b05abd 100644
@@ -2982,11 +2982,13 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 {
 	struct amdgpu_framebuffer *afb;
 	struct drm_gem_object *obj;
+	struct amdgpu_device *adev;
 	struct amdgpu_bo *rbo;
 	uint64_t chroma_addr = 0;
-	int r;
 	struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
 	unsigned int awidth;
+	uint32_t domain;
+	int r;
 
 	dm_plane_state_old = to_dm_plane_state(plane->state);
 	dm_plane_state_new = to_dm_plane_state(new_state);
@@ -3000,12 +3002,17 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 
 	obj = afb->obj;
 	rbo = gem_to_amdgpu_bo(obj);
+	adev = amdgpu_ttm_adev(rbo->tbo.bdev);
 	r = amdgpu_bo_reserve(rbo, false);
 	if (unlikely(r != 0))
 		return r;
 
-	r = amdgpu_bo_pin(rbo, AMDGPU_GEM_DOMAIN_VRAM, &afb->address);
+	if (plane->type != DRM_PLANE_TYPE_CURSOR)
+		domain = amdgpu_framebuffer_domains(adev);
+	else
+		domain = AMDGPU_GEM_DOMAIN_VRAM;
 
+	r = amdgpu_bo_pin(rbo, domain, &afb->address);
 
 	amdgpu_bo_unreserve(rbo);
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1515100305-6774-1-git-send-email-Samuel.Li-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 41 lines · Samuel Li

From: Christian König <[email protected]>

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.

Change-Id Id0f8af3110e54a3aabf7a258871867bc121cc1a2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 14 +++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h       |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c            | 10 ++++++----
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11 +++++++++--
 4 files changed, 29 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -1
index d704a45..d9fdc19 100644
@@ -29,6 +29,7 @@
 #include "amdgpu_i2c.h"
 #include "atom.h"
 #include "amdgpu_connectors.h"
+#include "amdgpu_display.h"
 #include <asm/div64.h>
 
 #include <linux/pm_runtime.h>
@@ -188,7 +189,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
                goto cleanup;
        }
 
-       r = amdgpu_bo_pin(new_abo, AMDGPU_GEM_DOMAIN_VRAM, &base);
+       r = amdgpu_bo_pin(new_abo, amdgpu_framebuffer_domains(adev), &base);
        if (unlikely(r != 0)) {
                DRM_ERROR("failed to pin new abo buffer before flip\n");
                goto unreserve;

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c static const struct drm_framebuffer_funcs amdgpu_fb_funcs = { · line 505

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -0
@@ -501,6 +502,17 @@ static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
        .create_handle = amdgpu_user_framebuffer_create_handle,
 };
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev)

Please rename this amdgpu_display_framebuffer_domains() for consistency.

Quoted 91 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +10 -0
+{
+       uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM;
+
+       if (adev->asic_type >= CHIP_CARRIZO && adev->asic_type < CHIP_RAVEN &&
+           adev->flags & AMD_IS_APU)
+               domain |= AMDGPU_GEM_DOMAIN_GTT;
+
+       return domain;
+}
+
 int
 amdgpu_framebuffer_init(struct drm_device *dev,
                        struct amdgpu_framebuffer *rfb,
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h +1 -0
index 11ae4ab..f241949 100644
@@ -23,6 +23,7 @@
 #ifndef __AMDGPU_DISPLAY_H__
 #define __AMDGPU_DISPLAY_H__
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev);
 struct drm_framebuffer *
 amdgpu_user_framebuffer_create(struct drm_device *dev,
                               struct drm_file *file_priv,
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +6 -4
index 90fa8e8..9be3228 100644
@@ -38,6 +38,8 @@
 
 #include <linux/vga_switcheroo.h>
 
+#include "amdgpu_display.h"
+
 /* object hierarchy -
    this contains a helper + a amdgpu fb
    the helper contains a pointer to amdgpu framebuffer baseclass.
@@ -124,7 +126,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        struct drm_gem_object *gobj = NULL;
        struct amdgpu_bo *abo = NULL;
        bool fb_tiled = false; /* useful for testing */
-       u32 tiling_flags = 0;
+       u32 tiling_flags = 0, domain;
        int ret;
        int aligned_size, size;
        int height = mode_cmd->height;
@@ -135,12 +137,12 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        /* need to align pitch with crtc limits */
        mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp,
                                                  fb_tiled);
+       domain = amdgpu_framebuffer_domains(adev);
 
        height = ALIGN(mode_cmd->height, 8);
        size = mode_cmd->pitches[0] * height;
        aligned_size = ALIGN(size, PAGE_SIZE);
-       ret = amdgpu_gem_object_create(adev, aligned_size, 0,
-                                      AMDGPU_GEM_DOMAIN_VRAM,
+       ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain,
                                       AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
                                       AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
                                       AMDGPU_GEM_CREATE_VRAM_CLEARED,
@@ -166,7 +168,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        }
 
 
-       ret = amdgpu_bo_pin(abo, AMDGPU_GEM_DOMAIN_VRAM, NULL);
+       ret = amdgpu_bo_pin(abo, domain, NULL);
        if (ret) {
                amdgpu_bo_unreserve(abo);
                goto out_unref;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -1
index a3bf021..9b05abd 100644
@@ -2982,11 +2982,13 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 {
        struct amdgpu_framebuffer *afb;
        struct drm_gem_object *obj;
+       struct amdgpu_device *adev;
        struct amdgpu_bo *rbo;
        uint64_t chroma_addr = 0;
-       int r;
        struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
        unsigned int awidth;
+       uint32_t domain;
+       int r;
 
        dm_plane_state_old = to_dm_plane_state(plane->state);
        dm_plane_state_new = to_dm_plane_state(new_state);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane, · line 3010

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
@@ -3000,12 +3002,17 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 
        obj = afb->obj;
        rbo = gem_to_amdgpu_bo(obj);
+       adev = amdgpu_ttm_adev(rbo->tbo.bdev);
        r = amdgpu_bo_reserve(rbo, false);
        if (unlikely(r != 0))
                return r;
 
-       r = amdgpu_bo_pin(rbo, AMDGPU_GEM_DOMAIN_VRAM, &afb->address);
+       if (plane->type != DRM_PLANE_TYPE_CURSOR)

Do cursors have to be in vram? It seems like they shouldn't.

Alex

Quoted 11 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -1
+               domain = amdgpu_framebuffer_domains(adev);
+       else
+               domain = AMDGPU_GEM_DOMAIN_VRAM;
 
+       r = amdgpu_bo_pin(rbo, domain, &afb->address);
 
        amdgpu_bo_unreserve(rbo);
 
--

2.7.4

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
Quoted 3 lines
Quoted 1 line

+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev)

Please rename this amdgpu_display_framebuffer_domains() for consistency.

Currently all the functions in this file are named without _display_. Am I missing something?

Quoted 3 lines
Quoted 1 line

+ if (plane->type != DRM_PLANE_TYPE_CURSOR)

Do cursors have to be in vram? It seems like they shouldn't.

I checked some design documentation and related implementation just now. Looks like cursor is still supposed to be put in vram now.

Regards,
Sam

Quoted 148 lines · Alex Deucher
Quoted 41 lines · Samuel Li

From: Christian König <[email protected]>

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.

Change-Id Id0f8af3110e54a3aabf7a258871867bc121cc1a2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 14 +++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h       |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c            | 10 ++++++----
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11 +++++++++--
 4 files changed, 29 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -1
index d704a45..d9fdc19 100644
@@ -29,6 +29,7 @@
 #include "amdgpu_i2c.h"
 #include "atom.h"
 #include "amdgpu_connectors.h"
+#include "amdgpu_display.h"
 #include <asm/div64.h>
 
 #include <linux/pm_runtime.h>
@@ -188,7 +189,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
                goto cleanup;
        }
 
-       r = amdgpu_bo_pin(new_abo, AMDGPU_GEM_DOMAIN_VRAM, &base);
+       r = amdgpu_bo_pin(new_abo, amdgpu_framebuffer_domains(adev), &base);
        if (unlikely(r != 0)) {
                DRM_ERROR("failed to pin new abo buffer before flip\n");
                goto unreserve;

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c static const struct drm_framebuffer_funcs amdgpu_fb_funcs = { · line 505

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -0
@@ -501,6 +502,17 @@ static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
        .create_handle = amdgpu_user_framebuffer_create_handle,
 };
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev)

Please rename this amdgpu_display_framebuffer_domains() for consistency.

Quoted 99 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +10 -0
+{
+       uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM;
+
+       if (adev->asic_type >= CHIP_CARRIZO && adev->asic_type < CHIP_RAVEN &&
+           adev->flags & AMD_IS_APU)
+               domain |= AMDGPU_GEM_DOMAIN_GTT;
+
+       return domain;
+}
+
 int
 amdgpu_framebuffer_init(struct drm_device *dev,
                        struct amdgpu_framebuffer *rfb,
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h +1 -0
index 11ae4ab..f241949 100644
@@ -23,6 +23,7 @@
 #ifndef __AMDGPU_DISPLAY_H__
 #define __AMDGPU_DISPLAY_H__
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev);
 struct drm_framebuffer *
 amdgpu_user_framebuffer_create(struct drm_device *dev,
                               struct drm_file *file_priv,
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +6 -4
index 90fa8e8..9be3228 100644
@@ -38,6 +38,8 @@
 
 #include <linux/vga_switcheroo.h>
 
+#include "amdgpu_display.h"
+
 /* object hierarchy -
    this contains a helper + a amdgpu fb
    the helper contains a pointer to amdgpu framebuffer baseclass.
@@ -124,7 +126,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        struct drm_gem_object *gobj = NULL;
        struct amdgpu_bo *abo = NULL;
        bool fb_tiled = false; /* useful for testing */
-       u32 tiling_flags = 0;
+       u32 tiling_flags = 0, domain;
        int ret;
        int aligned_size, size;
        int height = mode_cmd->height;
@@ -135,12 +137,12 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        /* need to align pitch with crtc limits */
        mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp,
                                                  fb_tiled);
+       domain = amdgpu_framebuffer_domains(adev);
 
        height = ALIGN(mode_cmd->height, 8);
        size = mode_cmd->pitches[0] * height;
        aligned_size = ALIGN(size, PAGE_SIZE);
-       ret = amdgpu_gem_object_create(adev, aligned_size, 0,
-                                      AMDGPU_GEM_DOMAIN_VRAM,
+       ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain,
                                       AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
                                       AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
                                       AMDGPU_GEM_CREATE_VRAM_CLEARED,
@@ -166,7 +168,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        }
 
 
-       ret = amdgpu_bo_pin(abo, AMDGPU_GEM_DOMAIN_VRAM, NULL);
+       ret = amdgpu_bo_pin(abo, domain, NULL);
        if (ret) {
                amdgpu_bo_unreserve(abo);
                goto out_unref;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -1
index a3bf021..9b05abd 100644
@@ -2982,11 +2982,13 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 {
        struct amdgpu_framebuffer *afb;
        struct drm_gem_object *obj;
+       struct amdgpu_device *adev;
        struct amdgpu_bo *rbo;
        uint64_t chroma_addr = 0;
-       int r;
        struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
        unsigned int awidth;
+       uint32_t domain;
+       int r;
 
        dm_plane_state_old = to_dm_plane_state(plane->state);
        dm_plane_state_new = to_dm_plane_state(new_state);
@@ -3000,12 +3002,17 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 
        obj = afb->obj;
        rbo = gem_to_amdgpu_bo(obj);
+       adev = amdgpu_ttm_adev(rbo->tbo.bdev);
        r = amdgpu_bo_reserve(rbo, false);
        if (unlikely(r != 0))
                return r;
 
Quoted 22 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane, · line 3010

Quoted 2 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
-       r = amdgpu_bo_pin(rbo, AMDGPU_GEM_DOMAIN_VRAM, &afb->address);
+       if (plane->type != DRM_PLANE_TYPE_CURSOR)

Do cursors have to be in vram? It seems like they shouldn't.

Alex

Quoted 15 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -1
+               domain = amdgpu_framebuffer_domains(adev);
+       else
+               domain = AMDGPU_GEM_DOMAIN_VRAM;
 
+       r = amdgpu_bo_pin(rbo, domain, &afb->address);
 
        amdgpu_bo_unreserve(rbo);
 
--

2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
Quoted 4 lines · Samuel Li
Quoted 3 lines
Quoted 1 line

+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev)

Please rename this amdgpu_display_framebuffer_domains() for consistency.

Currently all the functions in this file are named without _display_. Am I missing something?

That file is still a bit of a mess but I'm trying to make all the files use consistent naming going forward to make the code more readable. The IP files (gfx, uvd, gmc, etc.) already do and I recently cleaned up amdgpu_device.c.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

+ if (plane->type != DRM_PLANE_TYPE_CURSOR)

Do cursors have to be in vram? It seems like they shouldn't.

I checked some design documentation and related implementation just now. Looks like cursor is still supposed to be put in vram now.

Sounds good. thanks for checking.

Alex

Quoted 5 lines

Regards,
Sam

Quoted 171 lines
Quoted 170 lines · Alex Deucher
Quoted 41 lines · Samuel Li

From: Christian König <[email protected]>

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.

Change-Id Id0f8af3110e54a3aabf7a258871867bc121cc1a2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 14 +++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h       |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c            | 10 ++++++----
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11 +++++++++--
 4 files changed, 29 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -1
index d704a45..d9fdc19 100644
@@ -29,6 +29,7 @@
 #include "amdgpu_i2c.h"
 #include "atom.h"
 #include "amdgpu_connectors.h"
+#include "amdgpu_display.h"
 #include <asm/div64.h>
 
 #include <linux/pm_runtime.h>
@@ -188,7 +189,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
                goto cleanup;
        }
 
-       r = amdgpu_bo_pin(new_abo, AMDGPU_GEM_DOMAIN_VRAM, &base);
+       r = amdgpu_bo_pin(new_abo, amdgpu_framebuffer_domains(adev), &base);
        if (unlikely(r != 0)) {
                DRM_ERROR("failed to pin new abo buffer before flip\n");
                goto unreserve;

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c static const struct drm_framebuffer_funcs amdgpu_fb_funcs = { · line 505

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -0
@@ -501,6 +502,17 @@ static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
        .create_handle = amdgpu_user_framebuffer_create_handle,
 };
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev)

Please rename this amdgpu_display_framebuffer_domains() for consistency.

Quoted 91 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +10 -0
+{
+       uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM;
+
+       if (adev->asic_type >= CHIP_CARRIZO && adev->asic_type < CHIP_RAVEN &&
+           adev->flags & AMD_IS_APU)
+               domain |= AMDGPU_GEM_DOMAIN_GTT;
+
+       return domain;
+}
+
 int
 amdgpu_framebuffer_init(struct drm_device *dev,
                        struct amdgpu_framebuffer *rfb,
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h +1 -0
index 11ae4ab..f241949 100644
@@ -23,6 +23,7 @@
 #ifndef __AMDGPU_DISPLAY_H__
 #define __AMDGPU_DISPLAY_H__
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev);
 struct drm_framebuffer *
 amdgpu_user_framebuffer_create(struct drm_device *dev,
                               struct drm_file *file_priv,
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +6 -4
index 90fa8e8..9be3228 100644
@@ -38,6 +38,8 @@
 
 #include <linux/vga_switcheroo.h>
 
+#include "amdgpu_display.h"
+
 /* object hierarchy -
    this contains a helper + a amdgpu fb
    the helper contains a pointer to amdgpu framebuffer baseclass.
@@ -124,7 +126,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        struct drm_gem_object *gobj = NULL;
        struct amdgpu_bo *abo = NULL;
        bool fb_tiled = false; /* useful for testing */
-       u32 tiling_flags = 0;
+       u32 tiling_flags = 0, domain;
        int ret;
        int aligned_size, size;
        int height = mode_cmd->height;
@@ -135,12 +137,12 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        /* need to align pitch with crtc limits */
        mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp,
                                                  fb_tiled);
+       domain = amdgpu_framebuffer_domains(adev);
 
        height = ALIGN(mode_cmd->height, 8);
        size = mode_cmd->pitches[0] * height;
        aligned_size = ALIGN(size, PAGE_SIZE);
-       ret = amdgpu_gem_object_create(adev, aligned_size, 0,
-                                      AMDGPU_GEM_DOMAIN_VRAM,
+       ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain,
                                       AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
                                       AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
                                       AMDGPU_GEM_CREATE_VRAM_CLEARED,
@@ -166,7 +168,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        }
 
 
-       ret = amdgpu_bo_pin(abo, AMDGPU_GEM_DOMAIN_VRAM, NULL);
+       ret = amdgpu_bo_pin(abo, domain, NULL);
        if (ret) {
                amdgpu_bo_unreserve(abo);
                goto out_unref;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -1
index a3bf021..9b05abd 100644
@@ -2982,11 +2982,13 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 {
        struct amdgpu_framebuffer *afb;
        struct drm_gem_object *obj;
+       struct amdgpu_device *adev;
        struct amdgpu_bo *rbo;
        uint64_t chroma_addr = 0;
-       int r;
        struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
        unsigned int awidth;
+       uint32_t domain;
+       int r;
 
        dm_plane_state_old = to_dm_plane_state(plane->state);
        dm_plane_state_new = to_dm_plane_state(new_state);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane, · line 3010

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
@@ -3000,12 +3002,17 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 
        obj = afb->obj;
        rbo = gem_to_amdgpu_bo(obj);
+       adev = amdgpu_ttm_adev(rbo->tbo.bdev);
        r = amdgpu_bo_reserve(rbo, false);
        if (unlikely(r != 0))
                return r;
 
-       r = amdgpu_bo_pin(rbo, AMDGPU_GEM_DOMAIN_VRAM, &afb->address);
+       if (plane->type != DRM_PLANE_TYPE_CURSOR)

Do cursors have to be in vram? It seems like they shouldn't.

Alex

Quoted 15 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -1
+               domain = amdgpu_framebuffer_domains(adev);
+       else
+               domain = AMDGPU_GEM_DOMAIN_VRAM;
 
+       r = amdgpu_bo_pin(rbo, domain, &afb->address);
 
        amdgpu_bo_unreserve(rbo);
 
--

2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): CADnq5_NAC7MzPdHzB_=x1Q5QMdTkWG2_jskRyi6gycpQ9C_67g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw

Am 04.01.2018 um 23:43 schrieb Alex Deucher:

Quoted 9 lines · Samuel Li
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev)

Please rename this amdgpu_display_framebuffer_domains() for consistency.

Currently all the functions in this file are named without _display_. Am I missing something?

That file is still a bit of a mess but I'm trying to make all the files use consistent naming going forward to make the code more readable. The IP files (gfx, uvd, gmc, etc.) already do and I recently cleaned up amdgpu_device.c.

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

+ if (plane->type != DRM_PLANE_TYPE_CURSOR)

Do cursors have to be in vram? It seems like they shouldn't.

I checked some design documentation and related implementation just now. Looks like cursor is still supposed to be put in vram now.

Sounds good. thanks for checking.

Yeah, I actually tried that while working on the patch.

At least on Carizzo the cursor must still be in VRAM or otherwise you seem to only get garbage.

Regards,
Christian.

Quoted 177 lines

Alex

Quoted 174 lines

Regards,
Sam

Quoted 168 lines · Alex Deucher
Quoted 41 lines · Samuel Li

From: Christian König <[email protected]>

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.

Change-Id Id0f8af3110e54a3aabf7a258871867bc121cc1a2
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 14 +++++++++++++-
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.h       |  1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c            | 10 ++++++----
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11 +++++++++--
  4 files changed, 29 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -1
index d704a45..d9fdc19 100644
@@ -29,6 +29,7 @@
  #include "amdgpu_i2c.h"
  #include "atom.h"
  #include "amdgpu_connectors.h"
+#include "amdgpu_display.h"
  #include <asm/div64.h>
 
  #include <linux/pm_runtime.h>
@@ -188,7 +189,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
                 goto cleanup;
         }
 
-       r = amdgpu_bo_pin(new_abo, AMDGPU_GEM_DOMAIN_VRAM, &base);
+       r = amdgpu_bo_pin(new_abo, amdgpu_framebuffer_domains(adev), &base);
         if (unlikely(r != 0)) {
                 DRM_ERROR("failed to pin new abo buffer before flip\n");
                 goto unreserve;

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c static const struct drm_framebuffer_funcs amdgpu_fb_funcs = { · line 505

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -0
@@ -501,6 +502,17 @@ static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
         .create_handle = amdgpu_user_framebuffer_create_handle,
  };
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev)

Please rename this amdgpu_display_framebuffer_domains() for consistency.

Quoted 91 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +10 -0
+{
+       uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM;
+
+       if (adev->asic_type >= CHIP_CARRIZO && adev->asic_type < CHIP_RAVEN &&
+           adev->flags & AMD_IS_APU)
+               domain |= AMDGPU_GEM_DOMAIN_GTT;
+
+       return domain;
+}
+
  int
  amdgpu_framebuffer_init(struct drm_device *dev,
                         struct amdgpu_framebuffer *rfb,
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h +1 -0
index 11ae4ab..f241949 100644
@@ -23,6 +23,7 @@
  #ifndef __AMDGPU_DISPLAY_H__
  #define __AMDGPU_DISPLAY_H__
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev);
  struct drm_framebuffer *
  amdgpu_user_framebuffer_create(struct drm_device *dev,
                                struct drm_file *file_priv,
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +6 -4
index 90fa8e8..9be3228 100644
@@ -38,6 +38,8 @@
 
  #include <linux/vga_switcheroo.h>
 
+#include "amdgpu_display.h"
+
  /* object hierarchy -
     this contains a helper + a amdgpu fb
     the helper contains a pointer to amdgpu framebuffer baseclass.
@@ -124,7 +126,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
         struct drm_gem_object *gobj = NULL;
         struct amdgpu_bo *abo = NULL;
         bool fb_tiled = false; /* useful for testing */
-       u32 tiling_flags = 0;
+       u32 tiling_flags = 0, domain;
         int ret;
         int aligned_size, size;
         int height = mode_cmd->height;
@@ -135,12 +137,12 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
         /* need to align pitch with crtc limits */
         mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp,
                                                   fb_tiled);
+       domain = amdgpu_framebuffer_domains(adev);
 
         height = ALIGN(mode_cmd->height, 8);
         size = mode_cmd->pitches[0] * height;
         aligned_size = ALIGN(size, PAGE_SIZE);
-       ret = amdgpu_gem_object_create(adev, aligned_size, 0,
-                                      AMDGPU_GEM_DOMAIN_VRAM,
+       ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain,
                                        AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
                                        AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
                                        AMDGPU_GEM_CREATE_VRAM_CLEARED,
@@ -166,7 +168,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
         }
 
 
-       ret = amdgpu_bo_pin(abo, AMDGPU_GEM_DOMAIN_VRAM, NULL);
+       ret = amdgpu_bo_pin(abo, domain, NULL);
         if (ret) {
                 amdgpu_bo_unreserve(abo);
                 goto out_unref;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -1
index a3bf021..9b05abd 100644
@@ -2982,11 +2982,13 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
  {
         struct amdgpu_framebuffer *afb;
         struct drm_gem_object *obj;
+       struct amdgpu_device *adev;
         struct amdgpu_bo *rbo;
         uint64_t chroma_addr = 0;
-       int r;
         struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
         unsigned int awidth;
+       uint32_t domain;
+       int r;
 
         dm_plane_state_old = to_dm_plane_state(plane->state);
         dm_plane_state_new = to_dm_plane_state(new_state);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane, · line 3010

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
@@ -3000,12 +3002,17 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 
         obj = afb->obj;
         rbo = gem_to_amdgpu_bo(obj);
+       adev = amdgpu_ttm_adev(rbo->tbo.bdev);
         r = amdgpu_bo_reserve(rbo, false);
         if (unlikely(r != 0))
                 return r;
 
-       r = amdgpu_bo_pin(rbo, AMDGPU_GEM_DOMAIN_VRAM, &afb->address);
+       if (plane->type != DRM_PLANE_TYPE_CURSOR)

Do cursors have to be in vram? It seems like they shouldn't.

Alex

Quoted 15 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -1
+               domain = amdgpu_framebuffer_domains(adev);
+       else
+               domain = AMDGPU_GEM_DOMAIN_VRAM;
 
+       r = amdgpu_bo_pin(rbo, domain, &afb->address);
 
         amdgpu_bo_unreserve(rbo);
 
--

2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#7 lore raw
In reply to Alex Deucher
Quoted 2 lines

to make all the files use consistent naming going forward to make the code more readable.

OK. Will do.

Sam

Quoted 14 lines · Alex Deucher
Quoted 4 lines · Samuel Li
Quoted 3 lines
Quoted 1 line

+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev)

Please rename this amdgpu_display_framebuffer_domains() for consistency.

Currently all the functions in this file are named without _display_. Am I missing something?

That file is still a bit of a mess but I'm trying to make all the files use consistent naming going forward to make the code more readable. The IP files (gfx, uvd, gmc, etc.) already do and I recently cleaned up amdgpu_device.c.

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

+ if (plane->type != DRM_PLANE_TYPE_CURSOR)

Quoted 184 lines
Quoted 3 lines
Quoted 1 line

Do cursors have to be in vram? It seems like they shouldn't.

I checked some design documentation and related implementation just now. Looks like cursor is still supposed to be put in vram now.

Sounds good. thanks for checking.

Alex

Quoted 176 lines

Regards,
Sam

Quoted 170 lines · Alex Deucher
Quoted 41 lines · Samuel Li

From: Christian König <[email protected]>

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.

Change-Id Id0f8af3110e54a3aabf7a258871867bc121cc1a2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 14 +++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h       |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c            | 10 ++++++----
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11 +++++++++--
 4 files changed, 29 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -1
index d704a45..d9fdc19 100644
@@ -29,6 +29,7 @@
 #include "amdgpu_i2c.h"
 #include "atom.h"
 #include "amdgpu_connectors.h"
+#include "amdgpu_display.h"
 #include <asm/div64.h>
 
 #include <linux/pm_runtime.h>
@@ -188,7 +189,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
                goto cleanup;
        }
 
-       r = amdgpu_bo_pin(new_abo, AMDGPU_GEM_DOMAIN_VRAM, &base);
+       r = amdgpu_bo_pin(new_abo, amdgpu_framebuffer_domains(adev), &base);
        if (unlikely(r != 0)) {
                DRM_ERROR("failed to pin new abo buffer before flip\n");
                goto unreserve;

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c static const struct drm_framebuffer_funcs amdgpu_fb_funcs = { · line 505

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -0
@@ -501,6 +502,17 @@ static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
        .create_handle = amdgpu_user_framebuffer_create_handle,
 };
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev)

Please rename this amdgpu_display_framebuffer_domains() for consistency.

Quoted 91 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +10 -0
+{
+       uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM;
+
+       if (adev->asic_type >= CHIP_CARRIZO && adev->asic_type < CHIP_RAVEN &&
+           adev->flags & AMD_IS_APU)
+               domain |= AMDGPU_GEM_DOMAIN_GTT;
+
+       return domain;
+}
+
 int
 amdgpu_framebuffer_init(struct drm_device *dev,
                        struct amdgpu_framebuffer *rfb,
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h +1 -0
index 11ae4ab..f241949 100644
@@ -23,6 +23,7 @@
 #ifndef __AMDGPU_DISPLAY_H__
 #define __AMDGPU_DISPLAY_H__
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev);
 struct drm_framebuffer *
 amdgpu_user_framebuffer_create(struct drm_device *dev,
                               struct drm_file *file_priv,
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +6 -4
index 90fa8e8..9be3228 100644
@@ -38,6 +38,8 @@
 
 #include <linux/vga_switcheroo.h>
 
+#include "amdgpu_display.h"
+
 /* object hierarchy -
    this contains a helper + a amdgpu fb
    the helper contains a pointer to amdgpu framebuffer baseclass.
@@ -124,7 +126,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        struct drm_gem_object *gobj = NULL;
        struct amdgpu_bo *abo = NULL;
        bool fb_tiled = false; /* useful for testing */
-       u32 tiling_flags = 0;
+       u32 tiling_flags = 0, domain;
        int ret;
        int aligned_size, size;
        int height = mode_cmd->height;
@@ -135,12 +137,12 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        /* need to align pitch with crtc limits */
        mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp,
                                                  fb_tiled);
+       domain = amdgpu_framebuffer_domains(adev);
 
        height = ALIGN(mode_cmd->height, 8);
        size = mode_cmd->pitches[0] * height;
        aligned_size = ALIGN(size, PAGE_SIZE);
-       ret = amdgpu_gem_object_create(adev, aligned_size, 0,
-                                      AMDGPU_GEM_DOMAIN_VRAM,
+       ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain,
                                       AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
                                       AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
                                       AMDGPU_GEM_CREATE_VRAM_CLEARED,
@@ -166,7 +168,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        }
 
 
-       ret = amdgpu_bo_pin(abo, AMDGPU_GEM_DOMAIN_VRAM, NULL);
+       ret = amdgpu_bo_pin(abo, domain, NULL);
        if (ret) {
                amdgpu_bo_unreserve(abo);
                goto out_unref;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -1
index a3bf021..9b05abd 100644
@@ -2982,11 +2982,13 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 {
        struct amdgpu_framebuffer *afb;
        struct drm_gem_object *obj;
+       struct amdgpu_device *adev;
        struct amdgpu_bo *rbo;
        uint64_t chroma_addr = 0;
-       int r;
        struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
        unsigned int awidth;
+       uint32_t domain;
+       int r;
 
        dm_plane_state_old = to_dm_plane_state(plane->state);
        dm_plane_state_new = to_dm_plane_state(new_state);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane, · line 3010

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
@@ -3000,12 +3002,17 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 
        obj = afb->obj;
        rbo = gem_to_amdgpu_bo(obj);
+       adev = amdgpu_ttm_adev(rbo->tbo.bdev);
        r = amdgpu_bo_reserve(rbo, false);
        if (unlikely(r != 0))
                return r;
 
-       r = amdgpu_bo_pin(rbo, AMDGPU_GEM_DOMAIN_VRAM, &afb->address);
+       if (plane->type != DRM_PLANE_TYPE_CURSOR)

Do cursors have to be in vram? It seems like they shouldn't.

Alex

Quoted 15 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -1
+               domain = amdgpu_framebuffer_domains(adev);
+       else
+               domain = AMDGPU_GEM_DOMAIN_VRAM;
 
+       r = amdgpu_bo_pin(rbo, domain, &afb->address);
 
        amdgpu_bo_unreserve(rbo);
 
--

2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw
In reply to a message not in the archive
Quoted 6 lines · Samuel Li

From: Christian König <[email protected]>

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.

I can't find the part to enable gpu_vm_support for CZ/ST. Is that in another patch?

Harry

Quoted 139 lines
Change-Id Id0f8af3110e54a3aabf7a258871867bc121cc1a2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 14 +++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h       |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c            | 10 ++++++----
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11 +++++++++--
 4 files changed, 29 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +13 -1
index d704a45..d9fdc19 100644
@@ -29,6 +29,7 @@
 #include "amdgpu_i2c.h"
 #include "atom.h"
 #include "amdgpu_connectors.h"
+#include "amdgpu_display.h"
 #include <asm/div64.h>
 
 #include <linux/pm_runtime.h>
@@ -188,7 +189,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
 		goto cleanup;
 	}
 
-	r = amdgpu_bo_pin(new_abo, AMDGPU_GEM_DOMAIN_VRAM, &base);
+	r = amdgpu_bo_pin(new_abo, amdgpu_framebuffer_domains(adev), &base);
 	if (unlikely(r != 0)) {
 		DRM_ERROR("failed to pin new abo buffer before flip\n");
 		goto unreserve;
@@ -501,6 +502,17 @@ static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
 	.create_handle = amdgpu_user_framebuffer_create_handle,
 };
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev)
+{
+	uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM;
+
+	if (adev->asic_type >= CHIP_CARRIZO && adev->asic_type < CHIP_RAVEN &&
+	    adev->flags & AMD_IS_APU)
+		domain |= AMDGPU_GEM_DOMAIN_GTT;
+
+	return domain;
+}
+
 int
 amdgpu_framebuffer_init(struct drm_device *dev,
 			struct amdgpu_framebuffer *rfb,
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h +1 -0
index 11ae4ab..f241949 100644
@@ -23,6 +23,7 @@
 #ifndef __AMDGPU_DISPLAY_H__
 #define __AMDGPU_DISPLAY_H__
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev);
 struct drm_framebuffer *
 amdgpu_user_framebuffer_create(struct drm_device *dev,
 			       struct drm_file *file_priv,
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +6 -4
index 90fa8e8..9be3228 100644
@@ -38,6 +38,8 @@
 
 #include <linux/vga_switcheroo.h>
 
+#include "amdgpu_display.h"
+
 /* object hierarchy -
    this contains a helper + a amdgpu fb
    the helper contains a pointer to amdgpu framebuffer baseclass.
@@ -124,7 +126,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
 	struct drm_gem_object *gobj = NULL;
 	struct amdgpu_bo *abo = NULL;
 	bool fb_tiled = false; /* useful for testing */
-	u32 tiling_flags = 0;
+	u32 tiling_flags = 0, domain;
 	int ret;
 	int aligned_size, size;
 	int height = mode_cmd->height;
@@ -135,12 +137,12 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
 	/* need to align pitch with crtc limits */
 	mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp,
 						  fb_tiled);
+	domain = amdgpu_framebuffer_domains(adev);
 
 	height = ALIGN(mode_cmd->height, 8);
 	size = mode_cmd->pitches[0] * height;
 	aligned_size = ALIGN(size, PAGE_SIZE);
-	ret = amdgpu_gem_object_create(adev, aligned_size, 0,
-				       AMDGPU_GEM_DOMAIN_VRAM,
+	ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain,
 				       AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
 				       AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
 				       AMDGPU_GEM_CREATE_VRAM_CLEARED,
@@ -166,7 +168,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
 	}
 
 
-	ret = amdgpu_bo_pin(abo, AMDGPU_GEM_DOMAIN_VRAM, NULL);
+	ret = amdgpu_bo_pin(abo, domain, NULL);
 	if (ret) {
 		amdgpu_bo_unreserve(abo);
 		goto out_unref;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -1
index a3bf021..9b05abd 100644
@@ -2982,11 +2982,13 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 {
 	struct amdgpu_framebuffer *afb;
 	struct drm_gem_object *obj;
+	struct amdgpu_device *adev;
 	struct amdgpu_bo *rbo;
 	uint64_t chroma_addr = 0;
-	int r;
 	struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
 	unsigned int awidth;
+	uint32_t domain;
+	int r;
 
 	dm_plane_state_old = to_dm_plane_state(plane->state);
 	dm_plane_state_new = to_dm_plane_state(new_state);
@@ -3000,12 +3002,17 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 
 	obj = afb->obj;
 	rbo = gem_to_amdgpu_bo(obj);
+	adev = amdgpu_ttm_adev(rbo->tbo.bdev);
 	r = amdgpu_bo_reserve(rbo, false);
 	if (unlikely(r != 0))
 		return r;
 

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane, · line 3018

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5 -1
-	r = amdgpu_bo_pin(rbo, AMDGPU_GEM_DOMAIN_VRAM, &afb->address);
+	if (plane->type != DRM_PLANE_TYPE_CURSOR)
+		domain = amdgpu_framebuffer_domains(adev);
+	else
+		domain = AMDGPU_GEM_DOMAIN_VRAM;
 
+	r = amdgpu_bo_pin(rbo, domain, &afb->address);
 
 	amdgpu_bo_unreserve(rbo);
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): e1d6a05e-82ef-70a4-27dd-5b5e4b884913-5C7GfCeVMHo@public.gmane.org

author
#10 lore raw

I think Andrey approved your patch last December?
If you mean the driver actually set up fb in gart memory, that is not included in this series. I can do that in another patch.

Regards,
Samuel Li

Quoted 186 lines

-----Original Message-----
From: Wentland, Harry
Sent: Friday, January 05, 2018 10:50 AM
To: Li, Samuel <[email protected]>; [email protected]; [email protected]
Cc: Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: allow framebuffer in GART memory as well

Quoted 6 lines · Samuel Li

From: Christian König <[email protected]>

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.

I can't find the part to enable gpu_vm_support for CZ/ST. Is that in another patch?

Harry

Quoted 8 lines
Change-Id Id0f8af3110e54a3aabf7a258871867bc121cc1a2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 14

+++++++++++++-

Quoted 3 lines
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h       |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c            | 10 ++++++----
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11

+++++++++--

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c int amdgpu_crtc_page_flip_target(struct drm_crtc

Quoted 16 lines
 4 files changed, 29 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -0
index d704a45..d9fdc19 100644
@@ -29,6 +29,7 @@
 #include "amdgpu_i2c.h"
 #include "atom.h"
 #include "amdgpu_connectors.h"
+#include "amdgpu_display.h"
 #include <asm/div64.h>
 
 #include <linux/pm_runtime.h>
@@ -188,7 +189,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc

*crtc,

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -1
 		goto cleanup;
 	}
 
-	r = amdgpu_bo_pin(new_abo, AMDGPU_GEM_DOMAIN_VRAM,

&base);

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c int amdgpu_crtc_page_flip_target(struct drm_crtc · line 192

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -0
+	r = amdgpu_bo_pin(new_abo,

amdgpu_framebuffer_domains(adev), &base);

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c static const struct drm_framebuffer_funcs

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -0
 	if (unlikely(r != 0)) {
 		DRM_ERROR("failed to pin new abo buffer before flip\n");
 		goto unreserve;
@@ -501,6 +502,17 @@ static const struct drm_framebuffer_funcs

amdgpu_fb_funcs = {

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +4 -0
 	.create_handle = amdgpu_user_framebuffer_create_handle,
 };
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev) {
+	uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM;
+
+	if (adev->asic_type >= CHIP_CARRIZO && adev->asic_type <

CHIP_RAVEN &&

drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c static int amdgpufb_create_pinned_object(struct

Quoted 37 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +6 -0
+	    adev->flags & AMD_IS_APU)
+		domain |= AMDGPU_GEM_DOMAIN_GTT;
+
+	return domain;
+}
+
 int
 amdgpu_framebuffer_init(struct drm_device *dev,
 			struct amdgpu_framebuffer *rfb,
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h +1 -0
index 11ae4ab..f241949 100644
@@ -23,6 +23,7 @@
 #ifndef __AMDGPU_DISPLAY_H__
 #define __AMDGPU_DISPLAY_H__
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev);
 struct drm_framebuffer *
 amdgpu_user_framebuffer_create(struct drm_device *dev,
 			       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 90fa8e8..9be3228 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +2 -0
@@ -38,6 +38,8 @@
 
 #include <linux/vga_switcheroo.h>
 
+#include "amdgpu_display.h"
+
 /* object hierarchy -
    this contains a helper + a amdgpu fb
    the helper contains a pointer to amdgpu framebuffer baseclass.
@@ -124,7 +126,7 @@ static int amdgpufb_create_pinned_object(struct

amdgpu_fbdev *rfbdev,

drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c static int amdgpufb_create_pinned_object(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1 -1
 	struct drm_gem_object *gobj = NULL;
 	struct amdgpu_bo *abo = NULL;
 	bool fb_tiled = false; /* useful for testing */
-	u32 tiling_flags = 0;
+	u32 tiling_flags = 0, domain;
 	int ret;
 	int aligned_size, size;
 	int height = mode_cmd->height;
@@ -135,12 +137,12 @@ static int amdgpufb_create_pinned_object(struct

amdgpu_fbdev *rfbdev,

drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +2 -2
 	/* need to align pitch with crtc limits */
 	mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd-
 width, cpp,
 						  fb_tiled);
+	domain = amdgpu_framebuffer_domains(adev);
 
 	height = ALIGN(mode_cmd->height, 8);
 	size = mode_cmd->pitches[0] * height;
 	aligned_size = ALIGN(size, PAGE_SIZE);
-	ret = amdgpu_gem_object_create(adev, aligned_size, 0,
-				       AMDGPU_GEM_DOMAIN_VRAM,
+	ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain,
 

AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |

Quoted 1 line

AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |

Quoted 1 line

AMDGPU_GEM_CREATE_VRAM_CLEARED, @@ -166,7 +168,7 @@ static

Quoted 15 lines

int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,

drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1 -1
 	}
 
 
-	ret = amdgpu_bo_pin(abo, AMDGPU_GEM_DOMAIN_VRAM, NULL);
+	ret = amdgpu_bo_pin(abo, domain, NULL);
 	if (ret) {
 		amdgpu_bo_unreserve(abo);
 		goto out_unref;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index a3bf021..9b05abd 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct · line 2988

Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
@@ -2982,11 +2982,13 @@ static int dm_plane_helper_prepare_fb(struct
 drm_plane *plane,  {
 	struct amdgpu_framebuffer *afb;
 	struct drm_gem_object *obj;
+	struct amdgpu_device *adev;
 	struct amdgpu_bo *rbo;
 	uint64_t chroma_addr = 0;
-	int r;
 	struct dm_plane_state *dm_plane_state_new,

*dm_plane_state_old;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane,

Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -0
 	unsigned int awidth;
+	uint32_t domain;
+	int r;
 
 	dm_plane_state_old = to_dm_plane_state(plane->state);
 	dm_plane_state_new = to_dm_plane_state(new_state); @@ -

3000,12

Quoted 17 lines

+3002,17 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
 	obj = afb->obj;
 	rbo = gem_to_amdgpu_bo(obj);
+	adev = amdgpu_ttm_adev(rbo->tbo.bdev);
 	r = amdgpu_bo_reserve(rbo, false);
 	if (unlikely(r != 0))
 		return r;
 
-	r = amdgpu_bo_pin(rbo, AMDGPU_GEM_DOMAIN_VRAM, &afb-

address);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -0
+	if (plane->type != DRM_PLANE_TYPE_CURSOR)
+		domain = amdgpu_framebuffer_domains(adev);
+	else
+		domain = AMDGPU_GEM_DOMAIN_VRAM;
Quoted 5 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane, · line 3017

Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
+	r = amdgpu_bo_pin(rbo, domain, &afb->address);
 
 	amdgpu_bo_unreserve(rbo);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer
#11 lore raw
Quoted 3 lines · Samuel

I think Andrey approved your patch last December?
If you mean the driver actually set up fb in gart memory, that is not included in this series. I can do that in another patch.

Sounds good.

Harry

Quoted 190 lines

Regards,
Samuel Li

Quoted 186 lines

-----Original Message-----
From: Wentland, Harry
Sent: Friday, January 05, 2018 10:50 AM
To: Li, Samuel <[email protected]>; [email protected]; [email protected]
Cc: Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: allow framebuffer in GART memory as well

Quoted 6 lines · Samuel Li

From: Christian König <[email protected]>

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.

I can't find the part to enable gpu_vm_support for CZ/ST. Is that in another patch?

Harry

Quoted 8 lines
Change-Id Id0f8af3110e54a3aabf7a258871867bc121cc1a2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 14

+++++++++++++-

Quoted 3 lines
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h       |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c            | 10 ++++++----
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11

+++++++++--

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c int amdgpu_crtc_page_flip_target(struct drm_crtc

Quoted 16 lines
 4 files changed, 29 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -0
index d704a45..d9fdc19 100644
@@ -29,6 +29,7 @@
 #include "amdgpu_i2c.h"
 #include "atom.h"
 #include "amdgpu_connectors.h"
+#include "amdgpu_display.h"
 #include <asm/div64.h>
 
 #include <linux/pm_runtime.h>
@@ -188,7 +189,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc

*crtc,

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -1
 		goto cleanup;
 	}
 
-	r = amdgpu_bo_pin(new_abo, AMDGPU_GEM_DOMAIN_VRAM,

&base);

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c int amdgpu_crtc_page_flip_target(struct drm_crtc · line 192

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -0
+	r = amdgpu_bo_pin(new_abo,

amdgpu_framebuffer_domains(adev), &base);

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c static const struct drm_framebuffer_funcs

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -0
 	if (unlikely(r != 0)) {
 		DRM_ERROR("failed to pin new abo buffer before flip\n");
 		goto unreserve;
@@ -501,6 +502,17 @@ static const struct drm_framebuffer_funcs

amdgpu_fb_funcs = {

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +4 -0
 	.create_handle = amdgpu_user_framebuffer_create_handle,
 };
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev) {
+	uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM;
+
+	if (adev->asic_type >= CHIP_CARRIZO && adev->asic_type <

CHIP_RAVEN &&

drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c static int amdgpufb_create_pinned_object(struct

Quoted 37 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +6 -0
+	    adev->flags & AMD_IS_APU)
+		domain |= AMDGPU_GEM_DOMAIN_GTT;
+
+	return domain;
+}
+
 int
 amdgpu_framebuffer_init(struct drm_device *dev,
 			struct amdgpu_framebuffer *rfb,
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h +1 -0
index 11ae4ab..f241949 100644
@@ -23,6 +23,7 @@
 #ifndef __AMDGPU_DISPLAY_H__
 #define __AMDGPU_DISPLAY_H__
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev);
 struct drm_framebuffer *
 amdgpu_user_framebuffer_create(struct drm_device *dev,
 			       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 90fa8e8..9be3228 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +2 -0
@@ -38,6 +38,8 @@
 
 #include <linux/vga_switcheroo.h>
 
+#include "amdgpu_display.h"
+
 /* object hierarchy -
    this contains a helper + a amdgpu fb
    the helper contains a pointer to amdgpu framebuffer baseclass.
@@ -124,7 +126,7 @@ static int amdgpufb_create_pinned_object(struct

amdgpu_fbdev *rfbdev,

drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c static int amdgpufb_create_pinned_object(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1 -1
 	struct drm_gem_object *gobj = NULL;
 	struct amdgpu_bo *abo = NULL;
 	bool fb_tiled = false; /* useful for testing */
-	u32 tiling_flags = 0;
+	u32 tiling_flags = 0, domain;
 	int ret;
 	int aligned_size, size;
 	int height = mode_cmd->height;
@@ -135,12 +137,12 @@ static int amdgpufb_create_pinned_object(struct

amdgpu_fbdev *rfbdev,

drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +2 -2
 	/* need to align pitch with crtc limits */
 	mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd-
 width, cpp,
 						  fb_tiled);
+	domain = amdgpu_framebuffer_domains(adev);
 
 	height = ALIGN(mode_cmd->height, 8);
 	size = mode_cmd->pitches[0] * height;
 	aligned_size = ALIGN(size, PAGE_SIZE);
-	ret = amdgpu_gem_object_create(adev, aligned_size, 0,
-				       AMDGPU_GEM_DOMAIN_VRAM,
+	ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain,
 

AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |

Quoted 1 line

AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |

Quoted 1 line

AMDGPU_GEM_CREATE_VRAM_CLEARED, @@ -166,7 +168,7 @@ static

Quoted 15 lines

int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,

drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1 -1
 	}
 
 
-	ret = amdgpu_bo_pin(abo, AMDGPU_GEM_DOMAIN_VRAM, NULL);
+	ret = amdgpu_bo_pin(abo, domain, NULL);
 	if (ret) {
 		amdgpu_bo_unreserve(abo);
 		goto out_unref;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index a3bf021..9b05abd 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct · line 2988

Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
@@ -2982,11 +2982,13 @@ static int dm_plane_helper_prepare_fb(struct
 drm_plane *plane,  {
 	struct amdgpu_framebuffer *afb;
 	struct drm_gem_object *obj;
+	struct amdgpu_device *adev;
 	struct amdgpu_bo *rbo;
 	uint64_t chroma_addr = 0;
-	int r;
 	struct dm_plane_state *dm_plane_state_new,

*dm_plane_state_old;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane,

Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -0
 	unsigned int awidth;
+	uint32_t domain;
+	int r;
 
 	dm_plane_state_old = to_dm_plane_state(plane->state);
 	dm_plane_state_new = to_dm_plane_state(new_state); @@ -

3000,12

Quoted 17 lines

+3002,17 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
 	obj = afb->obj;
 	rbo = gem_to_amdgpu_bo(obj);
+	adev = amdgpu_ttm_adev(rbo->tbo.bdev);
 	r = amdgpu_bo_reserve(rbo, false);
 	if (unlikely(r != 0))
 		return r;
 
-	r = amdgpu_bo_pin(rbo, AMDGPU_GEM_DOMAIN_VRAM, &afb-

address);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -0
+	if (plane->type != DRM_PLANE_TYPE_CURSOR)
+		domain = amdgpu_framebuffer_domains(adev);
+	else
+		domain = AMDGPU_GEM_DOMAIN_VRAM;
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane, · line 3017

Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
+	r = amdgpu_bo_pin(rbo, domain, &afb->address);
 
 	amdgpu_bo_unreserve(rbo);

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer Acked-by on v1 1/3
#12 lore raw
In reply to Samuel Li
Quoted 4 lines · Samuel Li

From: Christian König <[email protected]>

On CZ and newer APUs we can pin the fb into GART as well as VRAM.

Quoted 8 lines

v2: Don't enable gpu_vm_support for Raven yet since it leads to
a black screen. Need to debug this further before enabling.

Change-Id Id0f8af3110e54a3aabf7a258871867bc121cc1a2

Looks good for amdgpu_dm change. Still don't know much about memory spaces but patch is

Harry

Quoted 133 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 14 +++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h       |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c            | 10 ++++++----
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11 +++++++++--
 4 files changed, 29 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +13 -1
index d704a45..d9fdc19 100644
@@ -29,6 +29,7 @@
 #include "amdgpu_i2c.h"
 #include "atom.h"
 #include "amdgpu_connectors.h"
+#include "amdgpu_display.h"
 #include <asm/div64.h>
 
 #include <linux/pm_runtime.h>
@@ -188,7 +189,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
 		goto cleanup;
 	}
 
-	r = amdgpu_bo_pin(new_abo, AMDGPU_GEM_DOMAIN_VRAM, &base);
+	r = amdgpu_bo_pin(new_abo, amdgpu_framebuffer_domains(adev), &base);
 	if (unlikely(r != 0)) {
 		DRM_ERROR("failed to pin new abo buffer before flip\n");
 		goto unreserve;
@@ -501,6 +502,17 @@ static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
 	.create_handle = amdgpu_user_framebuffer_create_handle,
 };
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev)
+{
+	uint32_t domain = AMDGPU_GEM_DOMAIN_VRAM;
+
+	if (adev->asic_type >= CHIP_CARRIZO && adev->asic_type < CHIP_RAVEN &&
+	    adev->flags & AMD_IS_APU)
+		domain |= AMDGPU_GEM_DOMAIN_GTT;
+
+	return domain;
+}
+
 int
 amdgpu_framebuffer_init(struct drm_device *dev,
 			struct amdgpu_framebuffer *rfb,
drivers/gpu/drm/amd/amdgpu/amdgpu_display.h +1 -0
index 11ae4ab..f241949 100644
@@ -23,6 +23,7 @@
 #ifndef __AMDGPU_DISPLAY_H__
 #define __AMDGPU_DISPLAY_H__
 
+uint32_t amdgpu_framebuffer_domains(struct amdgpu_device *adev);
 struct drm_framebuffer *
 amdgpu_user_framebuffer_create(struct drm_device *dev,
 			       struct drm_file *file_priv,
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +6 -4
index 90fa8e8..9be3228 100644
@@ -38,6 +38,8 @@
 
 #include <linux/vga_switcheroo.h>
 
+#include "amdgpu_display.h"
+
 /* object hierarchy -
    this contains a helper + a amdgpu fb
    the helper contains a pointer to amdgpu framebuffer baseclass.
@@ -124,7 +126,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
 	struct drm_gem_object *gobj = NULL;
 	struct amdgpu_bo *abo = NULL;
 	bool fb_tiled = false; /* useful for testing */
-	u32 tiling_flags = 0;
+	u32 tiling_flags = 0, domain;
 	int ret;
 	int aligned_size, size;
 	int height = mode_cmd->height;
@@ -135,12 +137,12 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
 	/* need to align pitch with crtc limits */
 	mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp,
 						  fb_tiled);
+	domain = amdgpu_framebuffer_domains(adev);
 
 	height = ALIGN(mode_cmd->height, 8);
 	size = mode_cmd->pitches[0] * height;
 	aligned_size = ALIGN(size, PAGE_SIZE);
-	ret = amdgpu_gem_object_create(adev, aligned_size, 0,
-				       AMDGPU_GEM_DOMAIN_VRAM,
+	ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain,
 				       AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
 				       AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
 				       AMDGPU_GEM_CREATE_VRAM_CLEARED,
@@ -166,7 +168,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
 	}
 
 
-	ret = amdgpu_bo_pin(abo, AMDGPU_GEM_DOMAIN_VRAM, NULL);
+	ret = amdgpu_bo_pin(abo, domain, NULL);
 	if (ret) {
 		amdgpu_bo_unreserve(abo);
 		goto out_unref;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -1
index a3bf021..9b05abd 100644
@@ -2982,11 +2982,13 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 {
 	struct amdgpu_framebuffer *afb;
 	struct drm_gem_object *obj;
+	struct amdgpu_device *adev;
 	struct amdgpu_bo *rbo;
 	uint64_t chroma_addr = 0;
-	int r;
 	struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
 	unsigned int awidth;
+	uint32_t domain;
+	int r;
 
 	dm_plane_state_old = to_dm_plane_state(plane->state);
 	dm_plane_state_new = to_dm_plane_state(new_state);
@@ -3000,12 +3002,17 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
 
 	obj = afb->obj;
 	rbo = gem_to_amdgpu_bo(obj);
+	adev = amdgpu_ttm_adev(rbo->tbo.bdev);
 	r = amdgpu_bo_reserve(rbo, false);
 	if (unlikely(r != 0))
 		return r;
 

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_plane_helper_prepare_fb(struct drm_plane *plane, · line 3018

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5 -1
-	r = amdgpu_bo_pin(rbo, AMDGPU_GEM_DOMAIN_VRAM, &afb->address);
+	if (plane->type != DRM_PLANE_TYPE_CURSOR)
+		domain = amdgpu_framebuffer_domains(adev);
+	else
+		domain = AMDGPU_GEM_DOMAIN_VRAM;
 
+	r = amdgpu_bo_pin(rbo, domain, &afb->address);
 
 	amdgpu_bo_unreserve(rbo);
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel