提交 deefd07e 编写于 作者: F Flora Cui 提交者: Alex Deucher

drm/amdgpu: fix vkms crtc settings

otherwise adev->mode_info.crtcs[] is NULL
Signed-off-by: NFlora Cui <flora.cui@amd.com>
Reviewed-by: NAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
上级 4f7ee199
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "ivsrcid/ivsrcid_vislands30.h" #include "ivsrcid/ivsrcid_vislands30.h"
#include "amdgpu_vkms.h" #include "amdgpu_vkms.h"
#include "amdgpu_display.h" #include "amdgpu_display.h"
#include "atom.h"
#include "amdgpu_irq.h"
/** /**
* DOC: amdgpu_vkms * DOC: amdgpu_vkms
...@@ -41,14 +43,13 @@ static const u32 amdgpu_vkms_formats[] = { ...@@ -41,14 +43,13 @@ static const u32 amdgpu_vkms_formats[] = {
static enum hrtimer_restart amdgpu_vkms_vblank_simulate(struct hrtimer *timer) static enum hrtimer_restart amdgpu_vkms_vblank_simulate(struct hrtimer *timer)
{ {
struct amdgpu_vkms_output *output = container_of(timer, struct amdgpu_crtc *amdgpu_crtc = container_of(timer, struct amdgpu_crtc, vblank_timer);
struct amdgpu_vkms_output, struct drm_crtc *crtc = &amdgpu_crtc->base;
vblank_hrtimer); struct amdgpu_vkms_output *output = drm_crtc_to_amdgpu_vkms_output(crtc);
struct drm_crtc *crtc = &output->crtc;
u64 ret_overrun; u64 ret_overrun;
bool ret; bool ret;
ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer, ret_overrun = hrtimer_forward_now(&amdgpu_crtc->vblank_timer,
output->period_ns); output->period_ns);
WARN_ON(ret_overrun != 1); WARN_ON(ret_overrun != 1);
...@@ -65,22 +66,21 @@ static int amdgpu_vkms_enable_vblank(struct drm_crtc *crtc) ...@@ -65,22 +66,21 @@ static int amdgpu_vkms_enable_vblank(struct drm_crtc *crtc)
unsigned int pipe = drm_crtc_index(crtc); unsigned int pipe = drm_crtc_index(crtc);
struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
struct amdgpu_vkms_output *out = drm_crtc_to_amdgpu_vkms_output(crtc); 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); 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); 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; return 0;
} }
static void amdgpu_vkms_disable_vblank(struct drm_crtc *crtc) 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, 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, ...@@ -92,13 +92,14 @@ static bool amdgpu_vkms_get_vblank_timestamp(struct drm_crtc *crtc,
unsigned int pipe = crtc->index; unsigned int pipe = crtc->index;
struct amdgpu_vkms_output *output = drm_crtc_to_amdgpu_vkms_output(crtc); struct amdgpu_vkms_output *output = drm_crtc_to_amdgpu_vkms_output(crtc);
struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
if (!READ_ONCE(vblank->enabled)) { if (!READ_ONCE(vblank->enabled)) {
*vblank_time = ktime_get(); *vblank_time = ktime_get();
return true; 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)) if (WARN_ON(*vblank_time == vblank->time))
return true; return true;
...@@ -165,6 +166,8 @@ static const struct drm_crtc_helper_funcs amdgpu_vkms_crtc_helper_funcs = { ...@@ -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, static int amdgpu_vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
struct drm_plane *primary, struct drm_plane *cursor) 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; int ret;
ret = drm_crtc_init_with_planes(dev, crtc, primary, cursor, 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, ...@@ -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); 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; return ret;
} }
...@@ -401,7 +415,7 @@ int amdgpu_vkms_output_init(struct drm_device *dev, ...@@ -401,7 +415,7 @@ int amdgpu_vkms_output_init(struct drm_device *dev,
{ {
struct drm_connector *connector = &output->connector; struct drm_connector *connector = &output->connector;
struct drm_encoder *encoder = &output->encoder; 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; struct drm_plane *primary, *cursor = NULL;
int ret; int ret;
...@@ -504,8 +518,8 @@ static int amdgpu_vkms_sw_fini(void *handle) ...@@ -504,8 +518,8 @@ static int amdgpu_vkms_sw_fini(void *handle)
int i = 0; int i = 0;
for (i = 0; i < adev->mode_info.num_crtc; i++) for (i = 0; i < adev->mode_info.num_crtc; i++)
if (adev->amdgpu_vkms_output[i].vblank_hrtimer.function) if (adev->mode_info.crtcs[i])
hrtimer_cancel(&adev->amdgpu_vkms_output[i].vblank_hrtimer); hrtimer_cancel(&adev->mode_info.crtcs[i]->vblank_timer);
kfree(adev->mode_info.bios_hardcoded_edid); kfree(adev->mode_info.bios_hardcoded_edid);
kfree(adev->amdgpu_vkms_output); kfree(adev->amdgpu_vkms_output);
......
...@@ -10,15 +10,14 @@ ...@@ -10,15 +10,14 @@
#define YRES_MAX 16384 #define YRES_MAX 16384
#define drm_crtc_to_amdgpu_vkms_output(target) \ #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; extern const struct amdgpu_ip_block_version amdgpu_vkms_ip_block;
struct amdgpu_vkms_output { struct amdgpu_vkms_output {
struct drm_crtc crtc; struct amdgpu_crtc crtc;
struct drm_encoder encoder; struct drm_encoder encoder;
struct drm_connector connector; struct drm_connector connector;
struct hrtimer vblank_hrtimer;
ktime_t period_ns; ktime_t period_ns;
struct drm_pending_vblank_event *event; struct drm_pending_vblank_event *event;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册