Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 90985660ba48 ("drm/radeon: remove load callback from kms_driver")
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3665
Tested-by: Hans de Goede <hdegoede@redhat.com>
Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Wu Hoi Pok <wuhoipok@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Wu Hoi Pok and committed by
Alex Deucher
b4c1ad70 fbca1969

+19 -7
+2 -7
drivers/gpu/drm/radeon/atombios_dp.c
··· 228 228 { 229 229 struct drm_device *dev = radeon_connector->base.dev; 230 230 struct radeon_device *rdev = dev->dev_private; 231 - int ret; 232 231 233 232 radeon_connector->ddc_bus->rec.hpd = radeon_connector->hpd.hpd; 234 - radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev; 235 233 radeon_connector->ddc_bus->aux.drm_dev = radeon_connector->base.dev; 236 234 if (ASIC_IS_DCE5(rdev)) { 237 235 if (radeon_auxch) ··· 240 242 radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer_atom; 241 243 } 242 244 243 - ret = drm_dp_aux_register(&radeon_connector->ddc_bus->aux); 244 - if (!ret) 245 - radeon_connector->ddc_bus->has_aux = true; 246 - 247 - WARN(ret, "drm_dp_aux_register() failed with error %d\n", ret); 245 + drm_dp_aux_init(&radeon_connector->ddc_bus->aux); 246 + radeon_connector->ddc_bus->has_aux = true; 248 247 } 249 248 250 249 /***** general DP utility functions *****/
+17
drivers/gpu/drm/radeon/radeon_connectors.c
··· 1786 1786 return MODE_OK; 1787 1787 } 1788 1788 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 + 1789 1803 static const struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs = { 1790 1804 .get_modes = radeon_dp_get_modes, 1791 1805 .mode_valid = radeon_dp_mode_valid, ··· 1814 1800 .early_unregister = radeon_connector_unregister, 1815 1801 .destroy = radeon_connector_destroy, 1816 1802 .force = radeon_dvi_force, 1803 + .late_register = radeon_connector_late_register, 1817 1804 }; 1818 1805 1819 1806 static const struct drm_connector_funcs radeon_edp_connector_funcs = { ··· 1825 1810 .early_unregister = radeon_connector_unregister, 1826 1811 .destroy = radeon_connector_destroy, 1827 1812 .force = radeon_dvi_force, 1813 + .late_register = radeon_connector_late_register, 1828 1814 }; 1829 1815 1830 1816 static const struct drm_connector_funcs radeon_lvds_bridge_connector_funcs = { ··· 1836 1820 .early_unregister = radeon_connector_unregister, 1837 1821 .destroy = radeon_connector_destroy, 1838 1822 .force = radeon_dvi_force, 1823 + .late_register = radeon_connector_late_register, 1839 1824 }; 1840 1825 1841 1826 void