Skip to contentSkip to conversation

Fix S3 and S4 issues related to fbdev

PATCH In review Mario Limonciello 2 participants 7 messages Aug 9, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Fix S3 and S4 issues related to fbdev

Moving to the generic fbdev helper introduced a regression in S4 support on Hawaii PRO graphics cards. A workaround commit was introduced to avoid this S4 regression until the root cause could be found, but that workaround commit introduced a completely separate regression on S3 on a WX3200.

This series reverts all the code to move to generic fbdev helpers to fix both issues.

Mario Limonciello (4):
Revert "drm/amdgpu/display: disable prefer_shadow for generic fb
helpers"
Revert "drm/amdgpu: keep fbdev buffers pinned during suspend" Revert "drm/amdgpu: drop amdgpu_display_gem_fb_init()" Revert "drm/amdgpu: use generic fb helpers instead of setting up AMD

    own's."
 drivers/gpu/drm/amd/amdgpu/Makefile           |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |  12 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  43 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c       |  13 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c        | 388 ++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c       |  30 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h      |  25 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c      |   3 +-
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c        |   3 +-
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c        |   3 +-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c         |   3 +-
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c         |   3 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |   3 +-
 13 files changed, 457 insertions(+), 74 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/4 Revert "drm/amdgpu/display: disable prefer_shadow for generic fb helpers"

Switching to the generic fb helpers caused a regression for S4, but the workaround for this regression on S4 caused another regression for S3 on a WX3200.

Fixes 3a4b1cc28fbd ("drm/amdgpu/display: disable prefer_shadow for generic fb helpers")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c          | 3 +--
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c            | 3 +--
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c            | 3 +--
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c             | 3 +--
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c             | 3 +--
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +--
 6 files changed, 6 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c +1 -2
index 108e8e8a1a36..576849e95296 100644
@@ -496,8 +496,7 @@ static int amdgpu_vkms_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_height = YRES_MAX;
 
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
-	/* disable prefer shadow for now due to hibernation issues */
-	adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +1 -2
index 9c964cd3b5d4..288fce7dc0ed 100644
@@ -2796,8 +2796,7 @@ static int dce_v10_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
-	/* disable prefer shadow for now due to hibernation issues */
-	adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
 	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
 
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +1 -2
index e0ad9f27dc3f..cbe5250b31cb 100644
@@ -2914,8 +2914,7 @@ static int dce_v11_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
-	/* disable prefer shadow for now due to hibernation issues */
-	adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
 	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
 
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +1 -2
index 77f5e998a120..b1c44fab074f 100644
@@ -2673,8 +2673,7 @@ static int dce_v6_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_width = 16384;
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
-	/* disable prefer shadow for now due to hibernation issues */
-	adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +1 -2
index 802e5c753271..572b9fa7298a 100644
@@ -2693,8 +2693,7 @@ static int dce_v8_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
-	/* disable prefer shadow for now due to hibernation issues */
-	adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
 	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
 
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -2
index ddcb7845f642..ee0cd2f279f2 100644
@@ -3823,8 +3823,7 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev)
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
-	/* disable prefer shadow for now due to hibernation issues */
-	adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 	/* indicates support for immediate flip */
 	adev_to_drm(adev)->mode_config.async_page_flip = true;
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/4 Revert "drm/amdgpu: keep fbdev buffers pinned during suspend"

In reply to Mario Limonciello

This reverts commit da427a501e9b5e2cac8c8042df12eb203726903c.

Fixes 087451f372bf ("drm/amdgpu: use generic fb helpers instead of setting up AMD own's.")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 25 ++++-----------------
 1 file changed, 4 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +4 -21
index c20922a5af9f..97fff4727724 100644
@@ -1559,21 +1559,6 @@ bool amdgpu_crtc_get_scanout_position(struct drm_crtc *crtc,
 						  stime, etime, mode);
 }
 
-static bool
-amdgpu_display_robj_is_fb(struct amdgpu_device *adev, struct amdgpu_bo *robj)
-{
-	struct drm_device *dev = adev_to_drm(adev);
-	struct drm_fb_helper *fb_helper = dev->fb_helper;
-
-	if (!fb_helper || !fb_helper->buffer)
-		return false;
-
-	if (gem_to_amdgpu_bo(fb_helper->buffer->gem) != robj)
-		return false;
-
-	return true;
-}
-
 int amdgpu_display_suspend_helper(struct amdgpu_device *adev)
 {
 	struct drm_device *dev = adev_to_drm(adev);
@@ -1609,12 +1594,10 @@ int amdgpu_display_suspend_helper(struct amdgpu_device *adev)
 			continue;
 		}
 		robj = gem_to_amdgpu_bo(fb->obj[0]);
-		if (!amdgpu_display_robj_is_fb(adev, robj)) {
-			r = amdgpu_bo_reserve(robj, true);
-			if (r == 0) {
-				amdgpu_bo_unpin(robj);
-				amdgpu_bo_unreserve(robj);
-			}
+		r = amdgpu_bo_reserve(robj, true);
+		if (r == 0) {
+			amdgpu_bo_unpin(robj);
+			amdgpu_bo_unreserve(robj);
 		}
 	}
 	return 0;
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/4 Revert "drm/amdgpu: drop amdgpu_display_gem_fb_init()"

In reply to Mario Limonciello

This reverts commit 60da2f7440f22dba48944602c2a0373068f13880.

Fixes 087451f372bf ("drm/amdgpu: use generic fb helpers instead of setting up AMD own's.")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 25 +++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h    |  5 +++++
 2 files changed, 30 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +25 -0
index 97fff4727724..92281e57f3ac 100644
@@ -1075,6 +1075,31 @@ static int amdgpu_display_get_fb_info(const struct amdgpu_framebuffer *amdgpu_fb
 	return r;
 }
 
+int amdgpu_display_gem_fb_init(struct drm_device *dev,
+			       struct amdgpu_framebuffer *rfb,
+			       const struct drm_mode_fb_cmd2 *mode_cmd,
+			       struct drm_gem_object *obj)
+{
+	int ret;
+
+	rfb->base.obj[0] = obj;
+	drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd);
+
+	ret = amdgpu_display_framebuffer_init(dev, rfb, mode_cmd, obj);
+	if (ret)
+		goto err;
+
+	ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
+	if (ret)
+		goto err;
+
+	return 0;
+err:
+	drm_dbg_kms(dev, "Failed to init gem fb: %d\n", ret);
+	rfb->base.obj[0] = NULL;
+	return ret;
+}
+
 static int amdgpu_display_gem_fb_verify_and_init(struct drm_device *dev,
 						 struct amdgpu_framebuffer *rfb,
 						 struct drm_file *file_priv,
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +5 -0
index dbe2904e015b..fb120abeec96 100644
@@ -588,6 +588,11 @@ int amdgpu_display_get_crtc_scanoutpos(struct drm_device *dev,
 			int *hpos, ktime_t *stime, ktime_t *etime,
 			const struct drm_display_mode *mode);
 
+int amdgpu_display_gem_fb_init(struct drm_device *dev,
+			       struct amdgpu_framebuffer *rfb,
+			       const struct drm_mode_fb_cmd2 *mode_cmd,
+			       struct drm_gem_object *obj);
+
 int amdgpufb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
 
 void amdgpu_enc_destroy(struct drm_encoder *encoder);
Signature · 1 line
2.34.1
#4 lore raw

PATCH 4/4 Revert "drm/amdgpu: use generic fb helpers instead of setting up AMD own's."

In reply to Mario Limonciello

Although preferable to use the generic fb helpers there is an underlying issue that causes problems for S4 that isn't yet identified. As the workaround for the S4 issue caused other problems for S3, revert the change to generic fb helpers.

If/when that underlying issue is identified switching back to generic fb helpers can be brought back in for amdgpu.

Fixes 087451f372bf ("drm/amdgpu: use generic fb helpers instead of setting up AMD own's.")
---
 drivers/gpu/drm/amd/amdgpu/Makefile         |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c  |  12 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c |  11 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c     |  13 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c      | 388 ++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c     |  30 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h    |  20 +
 7 files changed, 426 insertions(+), 50 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
index 4bde7ff55f8a..224d2dca2b7b 100644
@@ -45,7 +45,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \
 	amdgpu_atombios.o atombios_crtc.o amdgpu_connectors.o \
 	atom.o amdgpu_fence.o amdgpu_ttm.o amdgpu_object.o amdgpu_gart.o \
 	amdgpu_encoders.o amdgpu_display.o amdgpu_i2c.o \
-	amdgpu_gem.o amdgpu_ring.o \
+	amdgpu_fb.o amdgpu_gem.o amdgpu_ring.o \
 	amdgpu_cs.o amdgpu_bios.o amdgpu_benchmark.o \
 	atombios_dp.o amdgpu_afmt.o amdgpu_trace_points.o \
 	atombios_encoders.o amdgpu_sa.o atombios_i2c.o \
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8 -4
index c84fdef0ac45..a14e2c98d324 100644
@@ -3795,6 +3795,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	/* Get a log2 for easy divisions. */
 	adev->mm_stats.log2_max_MBps = ilog2(max(1u, max_MBps));
 
+	amdgpu_fbdev_init(adev);
+
 	r = amdgpu_pm_sysfs_init(adev);
 	if (r) {
 		adev->pm_sysfs_en = false;
@@ -3956,6 +3958,8 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
 	/* disable ras feature must before hw fini */
 	amdgpu_ras_pre_fini(adev);
 
+	amdgpu_fbdev_fini(adev);
+
 	amdgpu_device_ip_fini_early(adev);
 
 	amdgpu_irq_fini_hw(adev);
@@ -4066,7 +4070,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
 	drm_kms_helper_poll_disable(dev);
 
 	if (fbcon)
-		drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, true);
+		amdgpu_fbdev_set_suspend(adev, 1);
 
 	cancel_delayed_work_sync(&adev->delayed_init_work);
 
@@ -4138,7 +4142,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
 	flush_delayed_work(&adev->delayed_init_work);
 
 	if (fbcon)
-		drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, false);
+		amdgpu_fbdev_set_suspend(adev, 0);
 
 	drm_kms_helper_poll_enable(dev);
 
@@ -4856,7 +4860,7 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,
 				if (r)
 					goto out;
 
-				drm_fb_helper_set_suspend_unlocked(adev_to_drm(tmp_adev)->fb_helper, false);
+				amdgpu_fbdev_set_suspend(tmp_adev, 0);
 
 				/*
 				 * The GPU enters bad state once faulty pages
@@ -5203,7 +5207,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
 		 */
 		amdgpu_unregister_gpu_instance(tmp_adev);
 
-		drm_fb_helper_set_suspend_unlocked(adev_to_drm(tmp_adev)->fb_helper, true);
+		amdgpu_fbdev_set_suspend(tmp_adev, 1);
 
 		/* disable ras on ALL IPs */
 		if (!need_emergency_restart &&
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +7 -4
index 92281e57f3ac..eea6f8e34850 100644
@@ -1619,10 +1619,13 @@ int amdgpu_display_suspend_helper(struct amdgpu_device *adev)
 			continue;
 		}
 		robj = gem_to_amdgpu_bo(fb->obj[0]);
-		r = amdgpu_bo_reserve(robj, true);
-		if (r == 0) {
-			amdgpu_bo_unpin(robj);
-			amdgpu_bo_unreserve(robj);
+		/* don't unpin kernel fb objects */
+		if (!amdgpu_fbdev_robj_is_fb(adev, robj)) {
+			r = amdgpu_bo_reserve(robj, true);
+			if (r == 0) {
+				amdgpu_bo_unpin(robj);
+				amdgpu_bo_unreserve(robj);
+			}
 		}
 	}
 	return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -13
index 429fcdf28836..74c246e9d1b7 100644
@@ -2109,19 +2109,6 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 		goto err_pci;
 	}
 
-	/*
-	 * 1. don't init fbdev on hw without DCE
-	 * 2. don't init fbdev if there are no connectors
-	 */
-	if (adev->mode_info.mode_config_initialized &&
-	    !list_empty(&adev_to_drm(adev)->mode_config.connector_list)) {
-		/* select 8 bpp console on low vram cards */
-		if (adev->gmc.real_vram_size <= (32*1024*1024))
-			drm_fbdev_generic_setup(adev_to_drm(adev), 8);
-		else
-			drm_fbdev_generic_setup(adev_to_drm(adev), 32);
-	}
-
 	ret = amdgpu_debugfs_init(adev);
 	if (ret)
 		DRM_ERROR("Creating debugfs files failed (%d).\n", ret);
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c new file +388 -0

388 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -28
index 8ef31d687ef3..6603fb7f30ce 100644
@@ -875,32 +875,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
 	return r;
 }
 
-static int amdgpu_gem_align_pitch(struct amdgpu_device *adev,
-				  int width,
-				  int cpp,
-				  bool tiled)
-{
-	int aligned = width;
-	int pitch_mask = 0;
-
-	switch (cpp) {
-	case 1:
-		pitch_mask = 255;
-		break;
-	case 2:
-		pitch_mask = 127;
-		break;
-	case 3:
-	case 4:
-		pitch_mask = 63;
-		break;
-	}
-
-	aligned += pitch_mask;
-	aligned &= ~pitch_mask;
-	return aligned * cpp;
-}
-
 int amdgpu_mode_dumb_create(struct drm_file *file_priv,
 			    struct drm_device *dev,
 			    struct drm_mode_create_dumb *args)
@@ -922,8 +896,8 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv,
 	if (adev->mman.buffer_funcs_enabled)
 		flags |= AMDGPU_GEM_CREATE_VRAM_CLEARED;
 
-	args->pitch = amdgpu_gem_align_pitch(adev, args->width,
-					     DIV_ROUND_UP(args->bpp, 8), 0);
+	args->pitch = amdgpu_align_pitch(adev, args->width,
+					 DIV_ROUND_UP(args->bpp, 8), 0);
 	args->size = (u64)args->pitch * args->height;
 	args->size = ALIGN(args->size, PAGE_SIZE);
 	domain = amdgpu_bo_get_preferred_domain(adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +20 -0
index fb120abeec96..bca31b867cfe 100644
@@ -232,6 +232,8 @@ struct amdgpu_i2c_chan {
 	struct mutex mutex;
 };
 
+struct amdgpu_fbdev;
+
 struct amdgpu_afmt {
 	bool enabled;
 	int offset;
@@ -307,6 +309,13 @@ struct amdgpu_framebuffer {
 	uint64_t address;
 };
 
+struct amdgpu_fbdev {
+	struct drm_fb_helper helper;
+	struct amdgpu_framebuffer rfb;
+	struct list_head fbdev_list;
+	struct amdgpu_device *adev;
+};
+
 struct amdgpu_mode_info {
 	struct atom_context *atom_context;
 	struct card_info *atom_card_info;
@@ -332,6 +341,8 @@ struct amdgpu_mode_info {
 	struct edid *bios_hardcoded_edid;
 	int bios_hardcoded_edid_size;
 
+	/* pointer to fbdev info structure */
+	struct amdgpu_fbdev *rfbdev;
 	/* firmware flags */
 	u32 firmware_flags;
 	/* pointer to backlight encoder */
@@ -609,6 +620,15 @@ bool amdgpu_crtc_get_scanout_position(struct drm_crtc *crtc,
 			int *hpos, ktime_t *stime, ktime_t *etime,
 			const struct drm_display_mode *mode);
 
+/* fbdev layer */
+int amdgpu_fbdev_init(struct amdgpu_device *adev);
+void amdgpu_fbdev_fini(struct amdgpu_device *adev);
+void amdgpu_fbdev_set_suspend(struct amdgpu_device *adev, int state);
+int amdgpu_fbdev_total_size(struct amdgpu_device *adev);
+bool amdgpu_fbdev_robj_is_fb(struct amdgpu_device *adev, struct amdgpu_bo *robj);
+
+int amdgpu_align_pitch(struct amdgpu_device *adev, int width, int bpp, bool tiled);
+
 /* amdgpu_display.c */
 void amdgpu_display_print_display_setup(struct drm_device *dev);
 int amdgpu_display_modeset_create_props(struct amdgpu_device *adev);
Signature · 1 line
2.34.1
#5 lore raw
In reply to Mario Limonciello
Quoted 9 lines · Mario Limonciello

Moving to the generic fbdev helper introduced a regression in S4 support on Hawaii PRO graphics cards. A workaround commit was introduced to avoid this S4 regression until the root cause could be found, but that workaround commit introduced a completely separate regression on S3 on a WX3200.

This series reverts all the code to move to generic fbdev helpers to fix both issues.

I'm not opposed to reverting this, but I fear we'll never get rid of this old fbdev code. What about just applying the workaround for hawaii as per the attached patch? There is always the concern that this will lead to more workarounds, but I'd rather avoid touching the older asic support as much as possible.

Alex

Quoted 25 lines

Mario Limonciello (4):
Revert "drm/amdgpu/display: disable prefer_shadow for generic fb
helpers"
Revert "drm/amdgpu: keep fbdev buffers pinned during suspend" Revert "drm/amdgpu: drop amdgpu_display_gem_fb_init()" Revert "drm/amdgpu: use generic fb helpers instead of setting up AMD

    own's."
 drivers/gpu/drm/amd/amdgpu/Makefile           |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |  12 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  43 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c       |  13 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c        | 388 ++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c       |  30 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h      |  25 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c      |   3 +-
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c        |   3 +-
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c        |   3 +-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c         |   3 +-
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c         |   3 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |   3 +-
 13 files changed, 457 insertions(+), 74 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
Quoted 3 lines

--
2.34.1

From 9e04759a432adde38737fbb9da3b57db25969e18 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Tue, 9 Aug 2022 11:44:05 -0400
Subject: [PATCH] drm/amdgpu: Only disable prefer_shadow on hawaii

We changed it for all asics due to a hibernation regression on hawaii, but the workaround breaks suspend on a polaris12. Just disable it for hawaii.

Fixes 3a4b1cc28fbd ("drm/amdgpu/display: disable prefer_shadow for generic fb helpers")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c          | 3 +--
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c            | 3 +--
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c            | 3 +--
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c             | 3 +--
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c             | 7 +++++--
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 7 +++++--
 6 files changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c +1 -2
index 327166f2f35c..d68233dc772c 100644
@@ -496,8 +496,7 @@ static int amdgpu_vkms_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_height = YRES_MAX;
 
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
-	/* disable prefer shadow for now due to hibernation issues */
-	adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +1 -2
index 2e90cd828895..bdd3aef6d071 100644
@@ -2796,8 +2796,7 @@ static int dce_v10_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
-	/* disable prefer shadow for now due to hibernation issues */
-	adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
 	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
 
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +1 -2
index b32acbaad293..328d9e16668a 100644
@@ -2914,8 +2914,7 @@ static int dce_v11_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
-	/* disable prefer shadow for now due to hibernation issues */
-	adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
 	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
 
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +1 -2
index db3f55d85d5c..d101ceb8c2a4 100644
@@ -2673,8 +2673,7 @@ static int dce_v6_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_width = 16384;
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
-	/* disable prefer shadow for now due to hibernation issues */
-	adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +5 -2
index df80090eec5b..2bee8343782d 100644
@@ -2693,8 +2693,11 @@ static int dce_v8_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
-	/* disable prefer shadow for now due to hibernation issues */
-	adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	if (adev->asic_type == CHIP_HAWAII)
+		/* disable prefer shadow for now due to hibernation issues */
+		adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	else
+		adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
 	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
 
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5 -2
index a44a3f520c05..57bef5ea9aa5 100644
@@ -3825,8 +3825,11 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev)
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
-	/* disable prefer shadow for now due to hibernation issues */
-	adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	if (adev->asic_type == CHIP_HAWAII)
+		/* disable prefer shadow for now due to hibernation issues */
+		adev_to_drm(adev)->mode_config.prefer_shadow = 0;
+	else
+		adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 	/* indicates support for immediate flip */
 	adev_to_drm(adev)->mode_config.async_page_flip = true;
 
Signature · 1 line
2.35.3
#6 lore raw
Quoted 9 lines · Alex Deucher
Quoted 7 lines · Mario Limonciello

Moving to the generic fbdev helper introduced a regression in S4 support on Hawaii PRO graphics cards. A workaround commit was introduced to avoid this S4 regression until the root cause could be found, but that workaround commit introduced a completely separate regression on S3 on a WX3200.

Quoted 5 lines
Quoted 2 lines

This series reverts all the code to move to generic fbdev helpers to fix both issues.

I'm not opposed to reverting this, but I fear we'll never get rid of this old fbdev code.

Yeah, makes sense to me.

Quoted 4 lines

What about just applying the workaround for
hawaii as per the attached patch? There is always the concern that this will lead to more workarounds, but I'd rather avoid touching the older asic support as much as possible.

Yup that fixes S3 for me on the WX3200 (tested on top of 040370564b68) and I would expect keeps the W/A for S4 on the Hawaii one working effectively.

Quoted 31 lines

Alex

Quoted 28 lines

Mario Limonciello (4):
Revert "drm/amdgpu/display: disable prefer_shadow for generic fb
helpers"
Revert "drm/amdgpu: keep fbdev buffers pinned during suspend" Revert "drm/amdgpu: drop amdgpu_display_gem_fb_init()" Revert "drm/amdgpu: use generic fb helpers instead of setting up AMD

     own's."
  drivers/gpu/drm/amd/amdgpu/Makefile           |   2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |  12 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  43 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c       |  13 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c        | 388 ++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c       |  30 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h      |  25 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c      |   3 +-
  drivers/gpu/drm/amd/amdgpu/dce_v10_0.c        |   3 +-
  drivers/gpu/drm/amd/amdgpu/dce_v11_0.c        |   3 +-
  drivers/gpu/drm/amd/amdgpu/dce_v6_0.c         |   3 +-
  drivers/gpu/drm/amd/amdgpu/dce_v8_0.c         |   3 +-
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |   3 +-
  13 files changed, 457 insertions(+), 74 deletions(-)

create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c

--
2.34.1