Skip to content

Commit 8e82d11

Browse files
qlyjsldalexdeucher
authored andcommitted
drm/radeon: add late_register for connector
The patch is to solve null dereference in 'aux.dev', which is introduced in recent radeon rework. By having 'late_register', the connector should be registered after 'drm_dev_register' automatically, where in before it is the opposite. Fixes: 9098566 ("drm/radeon: remove load callback from kms_driver") Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3665 Tested-by: Hans de Goede <[email protected]> Suggested-by: Christophe Leroy <[email protected]> Signed-off-by: Wu Hoi Pok <[email protected]> Signed-off-by: Alex Deucher <[email protected]> (cherry picked from commit b4c1ad7)
1 parent d7d7b94 commit 8e82d11

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

drivers/gpu/drm/radeon/atombios_dp.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,8 @@ void radeon_dp_aux_init(struct radeon_connector *radeon_connector)
228228
{
229229
struct drm_device *dev = radeon_connector->base.dev;
230230
struct radeon_device *rdev = dev->dev_private;
231-
int ret;
232231

233232
radeon_connector->ddc_bus->rec.hpd = radeon_connector->hpd.hpd;
234-
radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev;
235233
radeon_connector->ddc_bus->aux.drm_dev = radeon_connector->base.dev;
236234
if (ASIC_IS_DCE5(rdev)) {
237235
if (radeon_auxch)
@@ -242,11 +240,8 @@ void radeon_dp_aux_init(struct radeon_connector *radeon_connector)
242240
radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer_atom;
243241
}
244242

245-
ret = drm_dp_aux_register(&radeon_connector->ddc_bus->aux);
246-
if (!ret)
247-
radeon_connector->ddc_bus->has_aux = true;
248-
249-
WARN(ret, "drm_dp_aux_register() failed with error %d\n", ret);
243+
drm_dp_aux_init(&radeon_connector->ddc_bus->aux);
244+
radeon_connector->ddc_bus->has_aux = true;
250245
}
251246

252247
/***** general DP utility functions *****/

drivers/gpu/drm/radeon/radeon_connectors.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,20 @@ static enum drm_mode_status radeon_dp_mode_valid(struct drm_connector *connector
17861786
return MODE_OK;
17871787
}
17881788

1789+
static int
1790+
radeon_connector_late_register(struct drm_connector *connector)
1791+
{
1792+
struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1793+
int r = 0;
1794+
1795+
if (radeon_connector->ddc_bus->has_aux) {
1796+
radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev;
1797+
r = drm_dp_aux_register(&radeon_connector->ddc_bus->aux);
1798+
}
1799+
1800+
return r;
1801+
}
1802+
17891803
static const struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs = {
17901804
.get_modes = radeon_dp_get_modes,
17911805
.mode_valid = radeon_dp_mode_valid,
@@ -1800,6 +1814,7 @@ static const struct drm_connector_funcs radeon_dp_connector_funcs = {
18001814
.early_unregister = radeon_connector_unregister,
18011815
.destroy = radeon_connector_destroy,
18021816
.force = radeon_dvi_force,
1817+
.late_register = radeon_connector_late_register,
18031818
};
18041819

18051820
static const struct drm_connector_funcs radeon_edp_connector_funcs = {
@@ -1810,6 +1825,7 @@ static const struct drm_connector_funcs radeon_edp_connector_funcs = {
18101825
.early_unregister = radeon_connector_unregister,
18111826
.destroy = radeon_connector_destroy,
18121827
.force = radeon_dvi_force,
1828+
.late_register = radeon_connector_late_register,
18131829
};
18141830

18151831
static const struct drm_connector_funcs radeon_lvds_bridge_connector_funcs = {
@@ -1820,6 +1836,7 @@ static const struct drm_connector_funcs radeon_lvds_bridge_connector_funcs = {
18201836
.early_unregister = radeon_connector_unregister,
18211837
.destroy = radeon_connector_destroy,
18221838
.force = radeon_dvi_force,
1839+
.late_register = radeon_connector_late_register,
18231840
};
18241841

18251842
void

0 commit comments

Comments
 (0)