Commit 405a1f90 authored by Alex Deucher's avatar Alex Deucher

drm/amdgpu/display: split dp connector registration (v4)

Split into init and register functions to avoid a segfault
in some configs when the load/unload callbacks are removed.

v2:
- add back accidently dropped has_aux setting
- set dev in late_register

v3:
- fix dp cec ordering

v4:
- squash in kdev reference fix
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Tested-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 14f04fa4
...@@ -1461,6 +1461,20 @@ static enum drm_mode_status amdgpu_connector_dp_mode_valid(struct drm_connector ...@@ -1461,6 +1461,20 @@ static enum drm_mode_status amdgpu_connector_dp_mode_valid(struct drm_connector
return MODE_OK; return MODE_OK;
} }
static int
amdgpu_connector_late_register(struct drm_connector *connector)
{
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
int r = 0;
if (amdgpu_connector->ddc_bus->has_aux) {
amdgpu_connector->ddc_bus->aux.dev = amdgpu_connector->base.kdev;
r = drm_dp_aux_register(&amdgpu_connector->ddc_bus->aux);
}
return r;
}
static const struct drm_connector_helper_funcs amdgpu_connector_dp_helper_funcs = { static const struct drm_connector_helper_funcs amdgpu_connector_dp_helper_funcs = {
.get_modes = amdgpu_connector_dp_get_modes, .get_modes = amdgpu_connector_dp_get_modes,
.mode_valid = amdgpu_connector_dp_mode_valid, .mode_valid = amdgpu_connector_dp_mode_valid,
...@@ -1475,6 +1489,7 @@ static const struct drm_connector_funcs amdgpu_connector_dp_funcs = { ...@@ -1475,6 +1489,7 @@ static const struct drm_connector_funcs amdgpu_connector_dp_funcs = {
.early_unregister = amdgpu_connector_unregister, .early_unregister = amdgpu_connector_unregister,
.destroy = amdgpu_connector_destroy, .destroy = amdgpu_connector_destroy,
.force = amdgpu_connector_dvi_force, .force = amdgpu_connector_dvi_force,
.late_register = amdgpu_connector_late_register,
}; };
static const struct drm_connector_funcs amdgpu_connector_edp_funcs = { static const struct drm_connector_funcs amdgpu_connector_edp_funcs = {
...@@ -1485,6 +1500,7 @@ static const struct drm_connector_funcs amdgpu_connector_edp_funcs = { ...@@ -1485,6 +1500,7 @@ static const struct drm_connector_funcs amdgpu_connector_edp_funcs = {
.early_unregister = amdgpu_connector_unregister, .early_unregister = amdgpu_connector_unregister,
.destroy = amdgpu_connector_destroy, .destroy = amdgpu_connector_destroy,
.force = amdgpu_connector_dvi_force, .force = amdgpu_connector_dvi_force,
.late_register = amdgpu_connector_late_register,
}; };
void void
......
...@@ -186,16 +186,10 @@ amdgpu_atombios_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *m ...@@ -186,16 +186,10 @@ amdgpu_atombios_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *m
void amdgpu_atombios_dp_aux_init(struct amdgpu_connector *amdgpu_connector) void amdgpu_atombios_dp_aux_init(struct amdgpu_connector *amdgpu_connector)
{ {
int ret;
amdgpu_connector->ddc_bus->rec.hpd = amdgpu_connector->hpd.hpd; amdgpu_connector->ddc_bus->rec.hpd = amdgpu_connector->hpd.hpd;
amdgpu_connector->ddc_bus->aux.dev = amdgpu_connector->base.kdev;
amdgpu_connector->ddc_bus->aux.transfer = amdgpu_atombios_dp_aux_transfer; amdgpu_connector->ddc_bus->aux.transfer = amdgpu_atombios_dp_aux_transfer;
ret = drm_dp_aux_register(&amdgpu_connector->ddc_bus->aux); drm_dp_aux_init(&amdgpu_connector->ddc_bus->aux);
if (!ret)
amdgpu_connector->ddc_bus->has_aux = true; amdgpu_connector->ddc_bus->has_aux = true;
WARN(ret, "drm_dp_aux_register_i2c_bus() failed with error %d\n", ret);
} }
/***** general DP utility functions *****/ /***** general DP utility functions *****/
......
...@@ -155,6 +155,12 @@ amdgpu_dm_mst_connector_late_register(struct drm_connector *connector) ...@@ -155,6 +155,12 @@ amdgpu_dm_mst_connector_late_register(struct drm_connector *connector)
struct amdgpu_dm_connector *amdgpu_dm_connector = struct amdgpu_dm_connector *amdgpu_dm_connector =
to_amdgpu_dm_connector(connector); to_amdgpu_dm_connector(connector);
struct drm_dp_mst_port *port = amdgpu_dm_connector->port; struct drm_dp_mst_port *port = amdgpu_dm_connector->port;
int r;
amdgpu_dm_connector->dm_dp_aux.aux.dev = connector->kdev;
r = drm_dp_aux_register(&amdgpu_dm_connector->dm_dp_aux.aux);
if (r)
return r;
#if defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_FS)
connector_debugfs_init(amdgpu_dm_connector); connector_debugfs_init(amdgpu_dm_connector);
...@@ -480,11 +486,10 @@ void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm, ...@@ -480,11 +486,10 @@ void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
struct amdgpu_dm_connector *aconnector) struct amdgpu_dm_connector *aconnector)
{ {
aconnector->dm_dp_aux.aux.name = "dmdc"; aconnector->dm_dp_aux.aux.name = "dmdc";
aconnector->dm_dp_aux.aux.dev = aconnector->base.kdev;
aconnector->dm_dp_aux.aux.transfer = dm_dp_aux_transfer; aconnector->dm_dp_aux.aux.transfer = dm_dp_aux_transfer;
aconnector->dm_dp_aux.ddc_service = aconnector->dc_link->ddc; aconnector->dm_dp_aux.ddc_service = aconnector->dc_link->ddc;
drm_dp_aux_register(&aconnector->dm_dp_aux.aux); drm_dp_aux_init(&aconnector->dm_dp_aux.aux);
drm_dp_cec_register_connector(&aconnector->dm_dp_aux.aux, drm_dp_cec_register_connector(&aconnector->dm_dp_aux.aux,
&aconnector->base); &aconnector->base);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment