All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings
@ 2021-11-22  9:03 Flora Cui
  2021-11-22  9:03 ` [PATCH 2/2] drm/amdgpu: check atomic flag to differeniate with legacy path Flora Cui
  2021-11-22 13:49 ` [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings Chen, Guchun
  0 siblings, 2 replies; 7+ messages in thread
From: Flora Cui @ 2021-11-22  9:03 UTC (permalink / raw)
  To: amd-gfx, guchun.chen; +Cc: Flora Cui

otherwise adev->mode_info.crtcs[] is NULL

Signed-off-by: Flora Cui <flora.cui@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 38 ++++++++++++++++--------
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |  5 ++--
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
index ce982afeff91..6c62c45e3e3e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
@@ -16,6 +16,8 @@
 #include "ivsrcid/ivsrcid_vislands30.h"
 #include "amdgpu_vkms.h"
 #include "amdgpu_display.h"
+#include "atom.h"
+#include "amdgpu_irq.h"
 
 /**
  * DOC: amdgpu_vkms
@@ -41,14 +43,13 @@ static const u32 amdgpu_vkms_formats[] = {
 
 static enum hrtimer_restart amdgpu_vkms_vblank_simulate(struct hrtimer *timer)
 {
-	struct amdgpu_vkms_output *output = container_of(timer,
-							 struct amdgpu_vkms_output,
-							 vblank_hrtimer);
-	struct drm_crtc *crtc = &output->crtc;
+	struct amdgpu_crtc *amdgpu_crtc = container_of(timer, struct amdgpu_crtc, vblank_timer);
+	struct drm_crtc *crtc = &amdgpu_crtc->base;
+	struct amdgpu_vkms_output *output = drm_crtc_to_amdgpu_vkms_output(crtc);
 	u64 ret_overrun;
 	bool ret;
 
-	ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer,
+	ret_overrun = hrtimer_forward_now(&amdgpu_crtc->vblank_timer,
 					  output->period_ns);
 	WARN_ON(ret_overrun != 1);
 
@@ -65,22 +66,21 @@ static int amdgpu_vkms_enable_vblank(struct drm_crtc *crtc)
 	unsigned int pipe = drm_crtc_index(crtc);
 	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 	struct amdgpu_vkms_output *out = drm_crtc_to_amdgpu_vkms_output(crtc);
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
 
 	drm_calc_timestamping_constants(crtc, &crtc->mode);
 
-	hrtimer_init(&out->vblank_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	out->vblank_hrtimer.function = &amdgpu_vkms_vblank_simulate;
 	out->period_ns = ktime_set(0, vblank->framedur_ns);
-	hrtimer_start(&out->vblank_hrtimer, out->period_ns, HRTIMER_MODE_REL);
+	hrtimer_start(&amdgpu_crtc->vblank_timer, out->period_ns, HRTIMER_MODE_REL);
 
 	return 0;
 }
 
 static void amdgpu_vkms_disable_vblank(struct drm_crtc *crtc)
 {
-	struct amdgpu_vkms_output *out = drm_crtc_to_amdgpu_vkms_output(crtc);
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
 
-	hrtimer_cancel(&out->vblank_hrtimer);
+	hrtimer_cancel(&amdgpu_crtc->vblank_timer);
 }
 
 static bool amdgpu_vkms_get_vblank_timestamp(struct drm_crtc *crtc,
@@ -92,13 +92,14 @@ static bool amdgpu_vkms_get_vblank_timestamp(struct drm_crtc *crtc,
 	unsigned int pipe = crtc->index;
 	struct amdgpu_vkms_output *output = drm_crtc_to_amdgpu_vkms_output(crtc);
 	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
 
 	if (!READ_ONCE(vblank->enabled)) {
 		*vblank_time = ktime_get();
 		return true;
 	}
 
-	*vblank_time = READ_ONCE(output->vblank_hrtimer.node.expires);
+	*vblank_time = READ_ONCE(amdgpu_crtc->vblank_timer.node.expires);
 
 	if (WARN_ON(*vblank_time == vblank->time))
 		return true;
@@ -165,6 +166,8 @@ static const struct drm_crtc_helper_funcs amdgpu_vkms_crtc_helper_funcs = {
 static int amdgpu_vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
 			  struct drm_plane *primary, struct drm_plane *cursor)
 {
+	struct amdgpu_device *adev = drm_to_adev(dev);
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
 	int ret;
 
 	ret = drm_crtc_init_with_planes(dev, crtc, primary, cursor,
@@ -176,6 +179,17 @@ static int amdgpu_vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
 
 	drm_crtc_helper_add(crtc, &amdgpu_vkms_crtc_helper_funcs);
 
+	amdgpu_crtc->crtc_id = drm_crtc_index(crtc);
+	adev->mode_info.crtcs[drm_crtc_index(crtc)] = amdgpu_crtc;
+
+	amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
+	amdgpu_crtc->encoder = NULL;
+	amdgpu_crtc->connector = NULL;
+	amdgpu_crtc->vsync_timer_enabled = AMDGPU_IRQ_STATE_DISABLE;
+
+	hrtimer_init(&amdgpu_crtc->vblank_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+	amdgpu_crtc->vblank_timer.function = &amdgpu_vkms_vblank_simulate;
+
 	return ret;
 }
 
@@ -401,7 +415,7 @@ int amdgpu_vkms_output_init(struct drm_device *dev,
 {
 	struct drm_connector *connector = &output->connector;
 	struct drm_encoder *encoder = &output->encoder;
-	struct drm_crtc *crtc = &output->crtc;
+	struct drm_crtc *crtc = &output->crtc.base;
 	struct drm_plane *primary, *cursor = NULL;
 	int ret;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
index 97f1b79c0724..4f8722ff37c2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
@@ -10,15 +10,14 @@
 #define YRES_MAX  16384
 
 #define drm_crtc_to_amdgpu_vkms_output(target) \
-	container_of(target, struct amdgpu_vkms_output, crtc)
+	container_of(target, struct amdgpu_vkms_output, crtc.base)
 
 extern const struct amdgpu_ip_block_version amdgpu_vkms_ip_block;
 
 struct amdgpu_vkms_output {
-	struct drm_crtc crtc;
+	struct amdgpu_crtc crtc;
 	struct drm_encoder encoder;
 	struct drm_connector connector;
-	struct hrtimer vblank_hrtimer;
 	ktime_t period_ns;
 	struct drm_pending_vblank_event *event;
 };
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] drm/amdgpu: check atomic flag to differeniate with legacy path
  2021-11-22  9:03 [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings Flora Cui
@ 2021-11-22  9:03 ` Flora Cui
  2021-11-22 16:46   ` Deucher, Alexander
  2021-11-22 13:49 ` [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings Chen, Guchun
  1 sibling, 1 reply; 7+ messages in thread
From: Flora Cui @ 2021-11-22  9:03 UTC (permalink / raw)
  To: amd-gfx, guchun.chen; +Cc: Flora Cui

since vkms support atomic KMS interface

Signed-off-by: Flora Cui <flora.cui@amd.com>
Reviewed-by: Guchun Chen <guchun.chen@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index ec42a6fd88de..87801f2e50f8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3830,7 +3830,7 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
 	/* disable all interrupts */
 	amdgpu_irq_disable_all(adev);
 	if (adev->mode_info.mode_config_initialized){
-		if (!amdgpu_device_has_dc_support(adev))
+		if (!drm_drv_uses_atomic_modeset(adev_to_drm(adev)))
 			drm_helper_force_disable_all(adev_to_drm(adev));
 		else
 			drm_atomic_helper_shutdown(adev_to_drm(adev));
@@ -5125,7 +5125,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
 			drm_sched_start(&ring->sched, !tmp_adev->asic_reset_res);
 		}
 
-		if (!amdgpu_device_has_dc_support(tmp_adev) && !job_signaled) {
+		if (!drm_drv_uses_atomic_modeset(adev_to_drm(tmp_adev)) && !job_signaled) {
 			drm_helper_resume_force_mode(adev_to_drm(tmp_adev));
 		}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings
  2021-11-22  9:03 [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings Flora Cui
  2021-11-22  9:03 ` [PATCH 2/2] drm/amdgpu: check atomic flag to differeniate with legacy path Flora Cui
@ 2021-11-22 13:49 ` Chen, Guchun
  2021-11-22 16:43   ` Deucher, Alexander
  1 sibling, 1 reply; 7+ messages in thread
From: Chen, Guchun @ 2021-11-22 13:49 UTC (permalink / raw)
  To: Cui, Flora, amd-gfx, Deucher, Alexander

[Public]

Series is:
Reviewed-by: Guchun Chen <guchun.chen@amd.com>

+Alex to comment this series as well.

Regards,
Guchun

-----Original Message-----
From: Cui, Flora <Flora.Cui@amd.com> 
Sent: Monday, November 22, 2021 5:04 PM
To: amd-gfx@lists.freedesktop.org; Chen, Guchun <Guchun.Chen@amd.com>
Cc: Cui, Flora <Flora.Cui@amd.com>
Subject: [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings

otherwise adev->mode_info.crtcs[] is NULL

Signed-off-by: Flora Cui <flora.cui@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 38 ++++++++++++++++--------  drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |  5 ++--
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
index ce982afeff91..6c62c45e3e3e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
@@ -16,6 +16,8 @@
 #include "ivsrcid/ivsrcid_vislands30.h"
 #include "amdgpu_vkms.h"
 #include "amdgpu_display.h"
+#include "atom.h"
+#include "amdgpu_irq.h"
 
 /**
  * DOC: amdgpu_vkms
@@ -41,14 +43,13 @@ static const u32 amdgpu_vkms_formats[] = {
 
 static enum hrtimer_restart amdgpu_vkms_vblank_simulate(struct hrtimer *timer)  {
-	struct amdgpu_vkms_output *output = container_of(timer,
-							 struct amdgpu_vkms_output,
-							 vblank_hrtimer);
-	struct drm_crtc *crtc = &output->crtc;
+	struct amdgpu_crtc *amdgpu_crtc = container_of(timer, struct amdgpu_crtc, vblank_timer);
+	struct drm_crtc *crtc = &amdgpu_crtc->base;
+	struct amdgpu_vkms_output *output = 
+drm_crtc_to_amdgpu_vkms_output(crtc);
 	u64 ret_overrun;
 	bool ret;
 
-	ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer,
+	ret_overrun = hrtimer_forward_now(&amdgpu_crtc->vblank_timer,
 					  output->period_ns);
 	WARN_ON(ret_overrun != 1);
 
@@ -65,22 +66,21 @@ static int amdgpu_vkms_enable_vblank(struct drm_crtc *crtc)
 	unsigned int pipe = drm_crtc_index(crtc);
 	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
 	struct amdgpu_vkms_output *out = drm_crtc_to_amdgpu_vkms_output(crtc);
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
 
 	drm_calc_timestamping_constants(crtc, &crtc->mode);
 
-	hrtimer_init(&out->vblank_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	out->vblank_hrtimer.function = &amdgpu_vkms_vblank_simulate;
 	out->period_ns = ktime_set(0, vblank->framedur_ns);
-	hrtimer_start(&out->vblank_hrtimer, out->period_ns, HRTIMER_MODE_REL);
+	hrtimer_start(&amdgpu_crtc->vblank_timer, out->period_ns, 
+HRTIMER_MODE_REL);
 
 	return 0;
 }
 
 static void amdgpu_vkms_disable_vblank(struct drm_crtc *crtc)  {
-	struct amdgpu_vkms_output *out = drm_crtc_to_amdgpu_vkms_output(crtc);
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
 
-	hrtimer_cancel(&out->vblank_hrtimer);
+	hrtimer_cancel(&amdgpu_crtc->vblank_timer);
 }
 
 static bool amdgpu_vkms_get_vblank_timestamp(struct drm_crtc *crtc, @@ -92,13 +92,14 @@ static bool amdgpu_vkms_get_vblank_timestamp(struct drm_crtc *crtc,
 	unsigned int pipe = crtc->index;
 	struct amdgpu_vkms_output *output = drm_crtc_to_amdgpu_vkms_output(crtc);
 	struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
 
 	if (!READ_ONCE(vblank->enabled)) {
 		*vblank_time = ktime_get();
 		return true;
 	}
 
-	*vblank_time = READ_ONCE(output->vblank_hrtimer.node.expires);
+	*vblank_time = READ_ONCE(amdgpu_crtc->vblank_timer.node.expires);
 
 	if (WARN_ON(*vblank_time == vblank->time))
 		return true;
@@ -165,6 +166,8 @@ static const struct drm_crtc_helper_funcs amdgpu_vkms_crtc_helper_funcs = {  static int amdgpu_vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
 			  struct drm_plane *primary, struct drm_plane *cursor)  {
+	struct amdgpu_device *adev = drm_to_adev(dev);
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
 	int ret;
 
 	ret = drm_crtc_init_with_planes(dev, crtc, primary, cursor, @@ -176,6 +179,17 @@ static int amdgpu_vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
 
 	drm_crtc_helper_add(crtc, &amdgpu_vkms_crtc_helper_funcs);
 
+	amdgpu_crtc->crtc_id = drm_crtc_index(crtc);
+	adev->mode_info.crtcs[drm_crtc_index(crtc)] = amdgpu_crtc;
+
+	amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
+	amdgpu_crtc->encoder = NULL;
+	amdgpu_crtc->connector = NULL;
+	amdgpu_crtc->vsync_timer_enabled = AMDGPU_IRQ_STATE_DISABLE;
+
+	hrtimer_init(&amdgpu_crtc->vblank_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+	amdgpu_crtc->vblank_timer.function = &amdgpu_vkms_vblank_simulate;
+
 	return ret;
 }
 
@@ -401,7 +415,7 @@ int amdgpu_vkms_output_init(struct drm_device *dev,  {
 	struct drm_connector *connector = &output->connector;
 	struct drm_encoder *encoder = &output->encoder;
-	struct drm_crtc *crtc = &output->crtc;
+	struct drm_crtc *crtc = &output->crtc.base;
 	struct drm_plane *primary, *cursor = NULL;
 	int ret;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
index 97f1b79c0724..4f8722ff37c2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
@@ -10,15 +10,14 @@
 #define YRES_MAX  16384
 
 #define drm_crtc_to_amdgpu_vkms_output(target) \
-	container_of(target, struct amdgpu_vkms_output, crtc)
+	container_of(target, struct amdgpu_vkms_output, crtc.base)
 
 extern const struct amdgpu_ip_block_version amdgpu_vkms_ip_block;
 
 struct amdgpu_vkms_output {
-	struct drm_crtc crtc;
+	struct amdgpu_crtc crtc;
 	struct drm_encoder encoder;
 	struct drm_connector connector;
-	struct hrtimer vblank_hrtimer;
 	ktime_t period_ns;
 	struct drm_pending_vblank_event *event;  };
--
2.25.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings
  2021-11-22 13:49 ` [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings Chen, Guchun
@ 2021-11-22 16:43   ` Deucher, Alexander
  2021-11-23  1:59     ` Cui, Flora
  0 siblings, 1 reply; 7+ messages in thread
From: Deucher, Alexander @ 2021-11-22 16:43 UTC (permalink / raw)
  To: Chen, Guchun, Cui, Flora, amd-gfx

[-- Attachment #1: Type: text/plain, Size: 6902 bytes --]

[Public]

Can you explain how the current code is failing?  It's not immediately obvious to me.  I'm not opposed to this change, it's just not clear to me where the current code fails.

Alex

________________________________
From: Chen, Guchun <Guchun.Chen@amd.com>
Sent: Monday, November 22, 2021 8:49 AM
To: Cui, Flora <Flora.Cui@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>
Subject: RE: [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings

[Public]

Series is:
Reviewed-by: Guchun Chen <guchun.chen@amd.com>

+Alex to comment this series as well.

Regards,
Guchun

-----Original Message-----
From: Cui, Flora <Flora.Cui@amd.com>
Sent: Monday, November 22, 2021 5:04 PM
To: amd-gfx@lists.freedesktop.org; Chen, Guchun <Guchun.Chen@amd.com>
Cc: Cui, Flora <Flora.Cui@amd.com>
Subject: [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings

otherwise adev->mode_info.crtcs[] is NULL

Signed-off-by: Flora Cui <flora.cui@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 38 ++++++++++++++++--------  drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |  5 ++--
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
index ce982afeff91..6c62c45e3e3e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
@@ -16,6 +16,8 @@
 #include "ivsrcid/ivsrcid_vislands30.h"
 #include "amdgpu_vkms.h"
 #include "amdgpu_display.h"
+#include "atom.h"
+#include "amdgpu_irq.h"

 /**
  * DOC: amdgpu_vkms
@@ -41,14 +43,13 @@ static const u32 amdgpu_vkms_formats[] = {

 static enum hrtimer_restart amdgpu_vkms_vblank_simulate(struct hrtimer *timer)  {
-       struct amdgpu_vkms_output *output = container_of(timer,
-                                                        struct amdgpu_vkms_output,
-                                                        vblank_hrtimer);
-       struct drm_crtc *crtc = &output->crtc;
+       struct amdgpu_crtc *amdgpu_crtc = container_of(timer, struct amdgpu_crtc, vblank_timer);
+       struct drm_crtc *crtc = &amdgpu_crtc->base;
+       struct amdgpu_vkms_output *output =
+drm_crtc_to_amdgpu_vkms_output(crtc);
         u64 ret_overrun;
         bool ret;

-       ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer,
+       ret_overrun = hrtimer_forward_now(&amdgpu_crtc->vblank_timer,
                                           output->period_ns);
         WARN_ON(ret_overrun != 1);

@@ -65,22 +66,21 @@ static int amdgpu_vkms_enable_vblank(struct drm_crtc *crtc)
         unsigned int pipe = drm_crtc_index(crtc);
         struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
         struct amdgpu_vkms_output *out = drm_crtc_to_amdgpu_vkms_output(crtc);
+       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);

         drm_calc_timestamping_constants(crtc, &crtc->mode);

-       hrtimer_init(&out->vblank_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-       out->vblank_hrtimer.function = &amdgpu_vkms_vblank_simulate;
         out->period_ns = ktime_set(0, vblank->framedur_ns);
-       hrtimer_start(&out->vblank_hrtimer, out->period_ns, HRTIMER_MODE_REL);
+       hrtimer_start(&amdgpu_crtc->vblank_timer, out->period_ns,
+HRTIMER_MODE_REL);

         return 0;
 }

 static void amdgpu_vkms_disable_vblank(struct drm_crtc *crtc)  {
-       struct amdgpu_vkms_output *out = drm_crtc_to_amdgpu_vkms_output(crtc);
+       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);

-       hrtimer_cancel(&out->vblank_hrtimer);
+       hrtimer_cancel(&amdgpu_crtc->vblank_timer);
 }

 static bool amdgpu_vkms_get_vblank_timestamp(struct drm_crtc *crtc, @@ -92,13 +92,14 @@ static bool amdgpu_vkms_get_vblank_timestamp(struct drm_crtc *crtc,
         unsigned int pipe = crtc->index;
         struct amdgpu_vkms_output *output = drm_crtc_to_amdgpu_vkms_output(crtc);
         struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
+       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);

         if (!READ_ONCE(vblank->enabled)) {
                 *vblank_time = ktime_get();
                 return true;
         }

-       *vblank_time = READ_ONCE(output->vblank_hrtimer.node.expires);
+       *vblank_time = READ_ONCE(amdgpu_crtc->vblank_timer.node.expires);

         if (WARN_ON(*vblank_time == vblank->time))
                 return true;
@@ -165,6 +166,8 @@ static const struct drm_crtc_helper_funcs amdgpu_vkms_crtc_helper_funcs = {  static int amdgpu_vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
                           struct drm_plane *primary, struct drm_plane *cursor)  {
+       struct amdgpu_device *adev = drm_to_adev(dev);
+       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
         int ret;

         ret = drm_crtc_init_with_planes(dev, crtc, primary, cursor, @@ -176,6 +179,17 @@ static int amdgpu_vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,

         drm_crtc_helper_add(crtc, &amdgpu_vkms_crtc_helper_funcs);

+       amdgpu_crtc->crtc_id = drm_crtc_index(crtc);
+       adev->mode_info.crtcs[drm_crtc_index(crtc)] = amdgpu_crtc;
+
+       amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
+       amdgpu_crtc->encoder = NULL;
+       amdgpu_crtc->connector = NULL;
+       amdgpu_crtc->vsync_timer_enabled = AMDGPU_IRQ_STATE_DISABLE;
+
+       hrtimer_init(&amdgpu_crtc->vblank_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+       amdgpu_crtc->vblank_timer.function = &amdgpu_vkms_vblank_simulate;
+
         return ret;
 }

@@ -401,7 +415,7 @@ int amdgpu_vkms_output_init(struct drm_device *dev,  {
         struct drm_connector *connector = &output->connector;
         struct drm_encoder *encoder = &output->encoder;
-       struct drm_crtc *crtc = &output->crtc;
+       struct drm_crtc *crtc = &output->crtc.base;
         struct drm_plane *primary, *cursor = NULL;
         int ret;

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
index 97f1b79c0724..4f8722ff37c2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
@@ -10,15 +10,14 @@
 #define YRES_MAX  16384

 #define drm_crtc_to_amdgpu_vkms_output(target) \
-       container_of(target, struct amdgpu_vkms_output, crtc)
+       container_of(target, struct amdgpu_vkms_output, crtc.base)

 extern const struct amdgpu_ip_block_version amdgpu_vkms_ip_block;

 struct amdgpu_vkms_output {
-       struct drm_crtc crtc;
+       struct amdgpu_crtc crtc;
         struct drm_encoder encoder;
         struct drm_connector connector;
-       struct hrtimer vblank_hrtimer;
         ktime_t period_ns;
         struct drm_pending_vblank_event *event;  };
--
2.25.1

[-- Attachment #2: Type: text/html, Size: 12525 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] drm/amdgpu: check atomic flag to differeniate with legacy path
  2021-11-22  9:03 ` [PATCH 2/2] drm/amdgpu: check atomic flag to differeniate with legacy path Flora Cui
@ 2021-11-22 16:46   ` Deucher, Alexander
  0 siblings, 0 replies; 7+ messages in thread
From: Deucher, Alexander @ 2021-11-22 16:46 UTC (permalink / raw)
  To: Cui, Flora, amd-gfx, Chen, Guchun

[-- Attachment #1: Type: text/plain, Size: 1941 bytes --]

[Public]

Acked-by: Alex Deucher <aleander.deucher@amd.com>
________________________________
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Flora Cui <flora.cui@amd.com>
Sent: Monday, November 22, 2021 4:03 AM
To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Chen, Guchun <Guchun.Chen@amd.com>
Cc: Cui, Flora <Flora.Cui@amd.com>
Subject: [PATCH 2/2] drm/amdgpu: check atomic flag to differeniate with legacy path

since vkms support atomic KMS interface

Signed-off-by: Flora Cui <flora.cui@amd.com>
Reviewed-by: Guchun Chen <guchun.chen@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index ec42a6fd88de..87801f2e50f8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3830,7 +3830,7 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
         /* disable all interrupts */
         amdgpu_irq_disable_all(adev);
         if (adev->mode_info.mode_config_initialized){
-               if (!amdgpu_device_has_dc_support(adev))
+               if (!drm_drv_uses_atomic_modeset(adev_to_drm(adev)))
                         drm_helper_force_disable_all(adev_to_drm(adev));
                 else
                         drm_atomic_helper_shutdown(adev_to_drm(adev));
@@ -5125,7 +5125,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
                         drm_sched_start(&ring->sched, !tmp_adev->asic_reset_res);
                 }

-               if (!amdgpu_device_has_dc_support(tmp_adev) && !job_signaled) {
+               if (!drm_drv_uses_atomic_modeset(adev_to_drm(tmp_adev)) && !job_signaled) {
                         drm_helper_resume_force_mode(adev_to_drm(tmp_adev));
                 }

--
2.25.1


[-- Attachment #2: Type: text/html, Size: 4119 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings
  2021-11-22 16:43   ` Deucher, Alexander
@ 2021-11-23  1:59     ` Cui, Flora
  2021-11-23 14:40       ` Alex Deucher
  0 siblings, 1 reply; 7+ messages in thread
From: Cui, Flora @ 2021-11-23  1:59 UTC (permalink / raw)
  To: Deucher, Alexander, Chen, Guchun, amd-gfx

[-- Attachment #1: Type: text/plain, Size: 8044 bytes --]

[Public]

Modprobe -r amdgpu get oops in amdgpu_vkms_sw_fini()
              for (i = 0; i < adev->mode_info.num_crtc; i++)
                             if (adev->mode_info.crtcs[i])
                                           hrtimer_cancel(&adev->mode_info.crtcs[i]->vblank_timer);
adev->mode_info.crtcs[i]->vblank_timer is not initiated as vkms init its own amdgpu_vkms_output-> vblank_hrtimer. This patch drop amdgpu_vkms_output-> vblank_hrtimer and try with adev->mode_info.crtcs[i]->vblank_timer to keep align with amdgpu_dm & dce_vx_0.c


From: Deucher, Alexander <Alexander.Deucher@amd.com>
Sent: 2021年11月23日 0:43
To: Chen, Guchun <Guchun.Chen@amd.com>; Cui, Flora <Flora.Cui@amd.com>; amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings


[Public]

Can you explain how the current code is failing?  It's not immediately obvious to me.  I'm not opposed to this change, it's just not clear to me where the current code fails.

Alex

________________________________
From: Chen, Guchun <Guchun.Chen@amd.com<mailto:Guchun.Chen@amd.com>>
Sent: Monday, November 22, 2021 8:49 AM
To: Cui, Flora <Flora.Cui@amd.com<mailto:Flora.Cui@amd.com>>; amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> <amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>>; Deucher, Alexander <Alexander.Deucher@amd.com<mailto:Alexander.Deucher@amd.com>>
Subject: RE: [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings

[Public]

Series is:
Reviewed-by: Guchun Chen <guchun.chen@amd.com<mailto:guchun.chen@amd.com>>

+Alex to comment this series as well.

Regards,
Guchun

-----Original Message-----
From: Cui, Flora <Flora.Cui@amd.com<mailto:Flora.Cui@amd.com>>
Sent: Monday, November 22, 2021 5:04 PM
To: amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org>; Chen, Guchun <Guchun.Chen@amd.com<mailto:Guchun.Chen@amd.com>>
Cc: Cui, Flora <Flora.Cui@amd.com<mailto:Flora.Cui@amd.com>>
Subject: [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings

otherwise adev->mode_info.crtcs[] is NULL

Signed-off-by: Flora Cui <flora.cui@amd.com<mailto:flora.cui@amd.com>>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 38 ++++++++++++++++--------  drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |  5 ++--
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
index ce982afeff91..6c62c45e3e3e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
@@ -16,6 +16,8 @@
 #include "ivsrcid/ivsrcid_vislands30.h"
 #include "amdgpu_vkms.h"
 #include "amdgpu_display.h"
+#include "atom.h"
+#include "amdgpu_irq.h"

 /**
  * DOC: amdgpu_vkms
@@ -41,14 +43,13 @@ static const u32 amdgpu_vkms_formats[] = {

 static enum hrtimer_restart amdgpu_vkms_vblank_simulate(struct hrtimer *timer)  {
-       struct amdgpu_vkms_output *output = container_of(timer,
-                                                        struct amdgpu_vkms_output,
-                                                        vblank_hrtimer);
-       struct drm_crtc *crtc = &output->crtc;
+       struct amdgpu_crtc *amdgpu_crtc = container_of(timer, struct amdgpu_crtc, vblank_timer);
+       struct drm_crtc *crtc = &amdgpu_crtc->base;
+       struct amdgpu_vkms_output *output =
+drm_crtc_to_amdgpu_vkms_output(crtc);
         u64 ret_overrun;
         bool ret;

-       ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer,
+       ret_overrun = hrtimer_forward_now(&amdgpu_crtc->vblank_timer,
                                           output->period_ns);
         WARN_ON(ret_overrun != 1);

@@ -65,22 +66,21 @@ static int amdgpu_vkms_enable_vblank(struct drm_crtc *crtc)
         unsigned int pipe = drm_crtc_index(crtc);
         struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
         struct amdgpu_vkms_output *out = drm_crtc_to_amdgpu_vkms_output(crtc);
+       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);

         drm_calc_timestamping_constants(crtc, &crtc->mode);

-       hrtimer_init(&out->vblank_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-       out->vblank_hrtimer.function = &amdgpu_vkms_vblank_simulate;
         out->period_ns = ktime_set(0, vblank->framedur_ns);
-       hrtimer_start(&out->vblank_hrtimer, out->period_ns, HRTIMER_MODE_REL);
+       hrtimer_start(&amdgpu_crtc->vblank_timer, out->period_ns,
+HRTIMER_MODE_REL);

         return 0;
 }

 static void amdgpu_vkms_disable_vblank(struct drm_crtc *crtc)  {
-       struct amdgpu_vkms_output *out = drm_crtc_to_amdgpu_vkms_output(crtc);
+       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);

-       hrtimer_cancel(&out->vblank_hrtimer);
+       hrtimer_cancel(&amdgpu_crtc->vblank_timer);
 }

 static bool amdgpu_vkms_get_vblank_timestamp(struct drm_crtc *crtc, @@ -92,13 +92,14 @@ static bool amdgpu_vkms_get_vblank_timestamp(struct drm_crtc *crtc,
         unsigned int pipe = crtc->index;
         struct amdgpu_vkms_output *output = drm_crtc_to_amdgpu_vkms_output(crtc);
         struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
+       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);

         if (!READ_ONCE(vblank->enabled)) {
                 *vblank_time = ktime_get();
                 return true;
         }

-       *vblank_time = READ_ONCE(output->vblank_hrtimer.node.expires);
+       *vblank_time = READ_ONCE(amdgpu_crtc->vblank_timer.node.expires);

         if (WARN_ON(*vblank_time == vblank->time))
                 return true;
@@ -165,6 +166,8 @@ static const struct drm_crtc_helper_funcs amdgpu_vkms_crtc_helper_funcs = {  static int amdgpu_vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
                           struct drm_plane *primary, struct drm_plane *cursor)  {
+       struct amdgpu_device *adev = drm_to_adev(dev);
+       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
         int ret;

         ret = drm_crtc_init_with_planes(dev, crtc, primary, cursor, @@ -176,6 +179,17 @@ static int amdgpu_vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,

         drm_crtc_helper_add(crtc, &amdgpu_vkms_crtc_helper_funcs);

+       amdgpu_crtc->crtc_id = drm_crtc_index(crtc);
+       adev->mode_info.crtcs[drm_crtc_index(crtc)] = amdgpu_crtc;
+
+       amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
+       amdgpu_crtc->encoder = NULL;
+       amdgpu_crtc->connector = NULL;
+       amdgpu_crtc->vsync_timer_enabled = AMDGPU_IRQ_STATE_DISABLE;
+
+       hrtimer_init(&amdgpu_crtc->vblank_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+       amdgpu_crtc->vblank_timer.function = &amdgpu_vkms_vblank_simulate;
+
         return ret;
 }

@@ -401,7 +415,7 @@ int amdgpu_vkms_output_init(struct drm_device *dev,  {
         struct drm_connector *connector = &output->connector;
         struct drm_encoder *encoder = &output->encoder;
-       struct drm_crtc *crtc = &output->crtc;
+       struct drm_crtc *crtc = &output->crtc.base;
         struct drm_plane *primary, *cursor = NULL;
         int ret;

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
index 97f1b79c0724..4f8722ff37c2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
@@ -10,15 +10,14 @@
 #define YRES_MAX  16384

 #define drm_crtc_to_amdgpu_vkms_output(target) \
-       container_of(target, struct amdgpu_vkms_output, crtc)
+       container_of(target, struct amdgpu_vkms_output, crtc.base)

 extern const struct amdgpu_ip_block_version amdgpu_vkms_ip_block;

 struct amdgpu_vkms_output {
-       struct drm_crtc crtc;
+       struct amdgpu_crtc crtc;
         struct drm_encoder encoder;
         struct drm_connector connector;
-       struct hrtimer vblank_hrtimer;
         ktime_t period_ns;
         struct drm_pending_vblank_event *event;  };
--
2.25.1

[-- Attachment #2: Type: text/html, Size: 16820 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings
  2021-11-23  1:59     ` Cui, Flora
@ 2021-11-23 14:40       ` Alex Deucher
  0 siblings, 0 replies; 7+ messages in thread
From: Alex Deucher @ 2021-11-23 14:40 UTC (permalink / raw)
  To: Cui, Flora; +Cc: Deucher, Alexander, amd-gfx, Chen, Guchun

On Mon, Nov 22, 2021 at 8:59 PM Cui, Flora <Flora.Cui@amd.com> wrote:
>
> [Public]
>
>
> Modprobe -r amdgpu get oops in amdgpu_vkms_sw_fini()
>
>               for (i = 0; i < adev->mode_info.num_crtc; i++)
>
>                              if (adev->mode_info.crtcs[i])
>
>                                            hrtimer_cancel(&adev->mode_info.crtcs[i]->vblank_timer);
>
> adev->mode_info.crtcs[i]->vblank_timer is not initiated as vkms init its own amdgpu_vkms_output-> vblank_hrtimer. This patch drop amdgpu_vkms_output-> vblank_hrtimer and try with adev->mode_info.crtcs[i]->vblank_timer to keep align with amdgpu_dm & dce_vx_0.c
>
>

I think this might be better as two patches.  The simple fix for this
problem would be:

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
index ce982afeff91..b620a6a3cb9f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
@@ -504,8 +504,7 @@ static int amdgpu_vkms_sw_fini(void *handle)
        int i = 0;

        for (i = 0; i < adev->mode_info.num_crtc; i++)
-               if (adev->mode_info.crtcs[i])
-                       hrtimer_cancel(&adev->mode_info.crtcs[i]->vblank_timer);
+               hrtimer_cancel(&adev->amdgpu_vkms_output[i].vblank_hrtimer);

        kfree(adev->mode_info.bios_hardcoded_edid);
        kfree(adev->amdgpu_vkms_output);

Then apply your patch on top to share more code with the existing dce files.

Alex

>
>
>
> From: Deucher, Alexander <Alexander.Deucher@amd.com>
> Sent: 2021年11月23日 0:43
> To: Chen, Guchun <Guchun.Chen@amd.com>; Cui, Flora <Flora.Cui@amd.com>; amd-gfx@lists.freedesktop.org
> Subject: Re: [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings
>
>
>
> [Public]
>
>
>
> Can you explain how the current code is failing?  It's not immediately obvious to me.  I'm not opposed to this change, it's just not clear to me where the current code fails.
>
>
>
> Alex
>
>
>
> ________________________________
>
> From: Chen, Guchun <Guchun.Chen@amd.com>
> Sent: Monday, November 22, 2021 8:49 AM
> To: Cui, Flora <Flora.Cui@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>
> Subject: RE: [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings
>
>
>
> [Public]
>
> Series is:
> Reviewed-by: Guchun Chen <guchun.chen@amd.com>
>
> +Alex to comment this series as well.
>
> Regards,
> Guchun
>
> -----Original Message-----
> From: Cui, Flora <Flora.Cui@amd.com>
> Sent: Monday, November 22, 2021 5:04 PM
> To: amd-gfx@lists.freedesktop.org; Chen, Guchun <Guchun.Chen@amd.com>
> Cc: Cui, Flora <Flora.Cui@amd.com>
> Subject: [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings
>
> otherwise adev->mode_info.crtcs[] is NULL
>
> Signed-off-by: Flora Cui <flora.cui@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 38 ++++++++++++++++--------  drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |  5 ++--
>  2 files changed, 28 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
> index ce982afeff91..6c62c45e3e3e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
> @@ -16,6 +16,8 @@
>  #include "ivsrcid/ivsrcid_vislands30.h"
>  #include "amdgpu_vkms.h"
>  #include "amdgpu_display.h"
> +#include "atom.h"
> +#include "amdgpu_irq.h"
>
>  /**
>   * DOC: amdgpu_vkms
> @@ -41,14 +43,13 @@ static const u32 amdgpu_vkms_formats[] = {
>
>  static enum hrtimer_restart amdgpu_vkms_vblank_simulate(struct hrtimer *timer)  {
> -       struct amdgpu_vkms_output *output = container_of(timer,
> -                                                        struct amdgpu_vkms_output,
> -                                                        vblank_hrtimer);
> -       struct drm_crtc *crtc = &output->crtc;
> +       struct amdgpu_crtc *amdgpu_crtc = container_of(timer, struct amdgpu_crtc, vblank_timer);
> +       struct drm_crtc *crtc = &amdgpu_crtc->base;
> +       struct amdgpu_vkms_output *output =
> +drm_crtc_to_amdgpu_vkms_output(crtc);
>          u64 ret_overrun;
>          bool ret;
>
> -       ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer,
> +       ret_overrun = hrtimer_forward_now(&amdgpu_crtc->vblank_timer,
>                                            output->period_ns);
>          WARN_ON(ret_overrun != 1);
>
> @@ -65,22 +66,21 @@ static int amdgpu_vkms_enable_vblank(struct drm_crtc *crtc)
>          unsigned int pipe = drm_crtc_index(crtc);
>          struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
>          struct amdgpu_vkms_output *out = drm_crtc_to_amdgpu_vkms_output(crtc);
> +       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
>
>          drm_calc_timestamping_constants(crtc, &crtc->mode);
>
> -       hrtimer_init(&out->vblank_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> -       out->vblank_hrtimer.function = &amdgpu_vkms_vblank_simulate;
>          out->period_ns = ktime_set(0, vblank->framedur_ns);
> -       hrtimer_start(&out->vblank_hrtimer, out->period_ns, HRTIMER_MODE_REL);
> +       hrtimer_start(&amdgpu_crtc->vblank_timer, out->period_ns,
> +HRTIMER_MODE_REL);
>
>          return 0;
>  }
>
>  static void amdgpu_vkms_disable_vblank(struct drm_crtc *crtc)  {
> -       struct amdgpu_vkms_output *out = drm_crtc_to_amdgpu_vkms_output(crtc);
> +       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
>
> -       hrtimer_cancel(&out->vblank_hrtimer);
> +       hrtimer_cancel(&amdgpu_crtc->vblank_timer);
>  }
>
>  static bool amdgpu_vkms_get_vblank_timestamp(struct drm_crtc *crtc, @@ -92,13 +92,14 @@ static bool amdgpu_vkms_get_vblank_timestamp(struct drm_crtc *crtc,
>          unsigned int pipe = crtc->index;
>          struct amdgpu_vkms_output *output = drm_crtc_to_amdgpu_vkms_output(crtc);
>          struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
> +       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
>
>          if (!READ_ONCE(vblank->enabled)) {
>                  *vblank_time = ktime_get();
>                  return true;
>          }
>
> -       *vblank_time = READ_ONCE(output->vblank_hrtimer.node.expires);
> +       *vblank_time = READ_ONCE(amdgpu_crtc->vblank_timer.node.expires);
>
>          if (WARN_ON(*vblank_time == vblank->time))
>                  return true;
> @@ -165,6 +166,8 @@ static const struct drm_crtc_helper_funcs amdgpu_vkms_crtc_helper_funcs = {  static int amdgpu_vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
>                            struct drm_plane *primary, struct drm_plane *cursor)  {
> +       struct amdgpu_device *adev = drm_to_adev(dev);
> +       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
>          int ret;
>
>          ret = drm_crtc_init_with_planes(dev, crtc, primary, cursor, @@ -176,6 +179,17 @@ static int amdgpu_vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
>
>          drm_crtc_helper_add(crtc, &amdgpu_vkms_crtc_helper_funcs);
>
> +       amdgpu_crtc->crtc_id = drm_crtc_index(crtc);
> +       adev->mode_info.crtcs[drm_crtc_index(crtc)] = amdgpu_crtc;
> +
> +       amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
> +       amdgpu_crtc->encoder = NULL;
> +       amdgpu_crtc->connector = NULL;
> +       amdgpu_crtc->vsync_timer_enabled = AMDGPU_IRQ_STATE_DISABLE;
> +
> +       hrtimer_init(&amdgpu_crtc->vblank_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> +       amdgpu_crtc->vblank_timer.function = &amdgpu_vkms_vblank_simulate;
> +
>          return ret;
>  }
>
> @@ -401,7 +415,7 @@ int amdgpu_vkms_output_init(struct drm_device *dev,  {
>          struct drm_connector *connector = &output->connector;
>          struct drm_encoder *encoder = &output->encoder;
> -       struct drm_crtc *crtc = &output->crtc;
> +       struct drm_crtc *crtc = &output->crtc.base;
>          struct drm_plane *primary, *cursor = NULL;
>          int ret;
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
> index 97f1b79c0724..4f8722ff37c2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
> @@ -10,15 +10,14 @@
>  #define YRES_MAX  16384
>
>  #define drm_crtc_to_amdgpu_vkms_output(target) \
> -       container_of(target, struct amdgpu_vkms_output, crtc)
> +       container_of(target, struct amdgpu_vkms_output, crtc.base)
>
>  extern const struct amdgpu_ip_block_version amdgpu_vkms_ip_block;
>
>  struct amdgpu_vkms_output {
> -       struct drm_crtc crtc;
> +       struct amdgpu_crtc crtc;
>          struct drm_encoder encoder;
>          struct drm_connector connector;
> -       struct hrtimer vblank_hrtimer;
>          ktime_t period_ns;
>          struct drm_pending_vblank_event *event;  };
> --
> 2.25.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-23 14:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22  9:03 [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings Flora Cui
2021-11-22  9:03 ` [PATCH 2/2] drm/amdgpu: check atomic flag to differeniate with legacy path Flora Cui
2021-11-22 16:46   ` Deucher, Alexander
2021-11-22 13:49 ` [PATCH 1/2] drm/amdgpu: fix vkms hrtimer settings Chen, Guchun
2021-11-22 16:43   ` Deucher, Alexander
2021-11-23  1:59     ` Cui, Flora
2021-11-23 14:40       ` Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.