From 0ccff32415af72d348349febdf1c9a77388fad28 Mon Sep 17 00:00:00 2001 From: David Francis Date: Wed, 15 Aug 2018 14:38:30 -0400 Subject: [PATCH 0315/2940] drm/amd/display: Improve spelling, grammar, and formatting of amdgpu_dm.c comments [Why] Good spelling and grammar makes comments more pleasant and clearer. Linux has coding standards for comments that we should try to follow. [How] Fix obvious spelling and grammar issues Ensure all comments use '/*' and '*/' and multi-line comments follow linux convention Remove line-of-stars comments that do not separate sections of code and comments referring to lines of code that have since been removed Change-Id: I31145072df4c79ab46649ee65a0d49c16733e4bd Signed-off-by: David Francis Reviewed-by: Nicholas Kazlauskas Acked-by: Leo Li Signed-off-by: Alex Deucher Signed-off-by: Kalyan Alle --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 181 ++++++++++-------- 1 file changed, 102 insertions(+), 79 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 7b4876e8bcff..168848d9cf46 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -80,12 +80,7 @@ MODULE_FIRMWARE(FIRMWARE_RAVEN_DMCU); static int amdgpu_dm_init(struct amdgpu_device *adev); static void amdgpu_dm_fini(struct amdgpu_device *adev); -/* initializes drm_device display related structures, based on the information - * provided by DAL. The drm strcutures are: drm_crtc, drm_connector, - * drm_encoder, drm_mode_config - * - * Returns 0 on success - */ + static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev); /* removes and deallocates the drm structures, created by the above function */ static void amdgpu_dm_destroy_drm_device(struct amdgpu_display_manager *dm); @@ -109,6 +104,12 @@ static int amdgpu_dm_encoder_init(struct drm_device *dev, static int amdgpu_dm_connector_get_modes(struct drm_connector *connector); +static int amdgpu_dm_atomic_commit(struct drm_device *dev, + struct drm_atomic_state *state, + bool nonblock); + +static int amdgpu_dm_connector_get_modes(struct drm_connector *connector); + static int amdgpu_dm_atomic_commit(struct drm_device *dev, struct drm_atomic_state *state, bool nonblock); @@ -242,10 +243,6 @@ get_crtc_by_otg_inst(struct amdgpu_device *adev, struct drm_crtc *crtc; struct amdgpu_crtc *amdgpu_crtc; - /* - * following if is check inherited from both functions where this one is - * used now. Need to be checked why it could happen. - */ if (otg_inst == -1) { WARN_ON(1); return adev->mode_info.crtcs[0]; @@ -271,7 +268,7 @@ static void dm_pflip_high_irq(void *interrupt_params) amdgpu_crtc = get_crtc_by_otg_inst(adev, irq_params->irq_src - IRQ_TYPE_PFLIP); /* IRQ could occur when in initial stage */ - /*TODO work and BO cleanup */ + /* TODO work and BO cleanup */ if (amdgpu_crtc == NULL) { DRM_DEBUG_DRIVER("CRTC is null, returning.\n"); return; @@ -290,9 +287,9 @@ static void dm_pflip_high_irq(void *interrupt_params) } - /* wakeup usersapce */ + /* wake up usersapce */ if (amdgpu_crtc->event) { - /* Update to correct count/ts if racing with vblank irq */ + /* Update to correct count(s) if racing with vblank irq */ drm_crtc_accurate_vblank_count(&amdgpu_crtc->base); drm_crtc_send_vblank_event(&amdgpu_crtc->base, amdgpu_crtc->event); @@ -390,8 +387,8 @@ static void amdgpu_dm_fbc_init(struct drm_connector *connector) } - -/* Init display KMS +/* + * Init display KMS * * Returns 0 on success */ @@ -1003,24 +1000,27 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector) sink = aconnector->dc_link->local_sink; - /* Edid mgmt connector gets first update only in mode_valid hook and then + /* + * Edid mgmt connector gets first update only in mode_valid hook and then * the connector sink is set to either fake or physical sink depends on link status. - * don't do it here if u are during boot + * Skip if already done during boot. */ if (aconnector->base.force != DRM_FORCE_UNSPECIFIED && aconnector->dc_em_sink) { - /* For S3 resume with headless use eml_sink to fake stream - * because on resume connecotr->sink is set ti NULL + /* + * For S3 resume with headless use eml_sink to fake stream + * because on resume connector->sink is set to NULL */ mutex_lock(&dev->mode_config.mutex); if (sink) { if (aconnector->dc_sink) { amdgpu_dm_update_freesync_caps(connector, NULL); - /* retain and release bellow are used for - * bump up refcount for sink because the link don't point - * to it anymore after disconnect so on next crtc to connector + /* + * retain and release below are used to + * bump up refcount for sink because the link doesn't point + * to it anymore after disconnect, so on next crtc to connector * reshuffle by UMD we will get into unwanted dc_sink release */ if (aconnector->dc_sink != aconnector->dc_em_sink) @@ -1049,8 +1049,10 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector) return; if (aconnector->dc_sink == sink) { - /* We got a DP short pulse (Link Loss, DP CTS, etc...). - * Do nothing!! */ + /* + * We got a DP short pulse (Link Loss, DP CTS, etc...). + * Do nothing!! + */ DRM_DEBUG_DRIVER("DCHPD: connector_id=%d: dc_sink didn't change.\n", aconnector->connector_id); return; @@ -1061,11 +1063,15 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector) mutex_lock(&dev->mode_config.mutex); - /* 1. Update status of the drm connector - * 2. Send an event and let userspace tell us what to do */ + /* + * 1. Update status of the drm connector + * 2. Send an event and let userspace tell us what to do + */ if (sink) { - /* TODO: check if we still need the S3 mode update workaround. - * If yes, put it here. */ + /* + * TODO: check if we still need the S3 mode update workaround. + * If yes, put it here. + */ if (aconnector->dc_sink) amdgpu_dm_update_freesync_caps(connector, NULL); @@ -1198,7 +1204,7 @@ static void dm_handle_hpd_rx_irq(struct amdgpu_dm_connector *aconnector) break; } - /* check if there is new irq to be handle */ + /* check if there is new irq to be handled */ dret = drm_dp_dpcd_read( &aconnector->dm_dp_aux.aux, dpcd_addr, @@ -1332,7 +1338,8 @@ static int dce110_register_irq_handlers(struct amdgpu_device *adev) int_params.requested_polarity = INTERRUPT_POLARITY_DEFAULT; int_params.current_polarity = INTERRUPT_POLARITY_DEFAULT; - /* Actions of amdgpu_irq_add_id(): + /* + * Actions of amdgpu_irq_add_id(): * 1. Register a set() function with base driver. * Base driver will call set() function to enable/disable an * interrupt in DC hardware. @@ -1412,7 +1419,8 @@ static int dcn10_register_irq_handlers(struct amdgpu_device *adev) int_params.requested_polarity = INTERRUPT_POLARITY_DEFAULT; int_params.current_polarity = INTERRUPT_POLARITY_DEFAULT; - /* Actions of amdgpu_irq_add_id(): + /* + * Actions of amdgpu_irq_add_id(): * 1. Register a set() function with base driver. * Base driver will call set() function to enable/disable an * interrupt in DC hardware. @@ -1421,7 +1429,7 @@ static int dcn10_register_irq_handlers(struct amdgpu_device *adev) * coming from DC hardware. * amdgpu_dm_irq_handler() will re-direct the interrupt to DC * for acknowledging and handling. - * */ + */ /* Use VSTARTUP interrupt */ for (i = DCN_1_0__SRCID__DC_D1_OTG_VSTARTUP; @@ -1499,7 +1507,7 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev) adev->ddev->mode_config.preferred_depth = 24; adev->ddev->mode_config.prefer_shadow = 1; - /* indicate support of immediate flip */ + /* indicates support for immediate flip */ adev->ddev->mode_config.async_page_flip = true; adev->ddev->mode_config.fb_base = adev->gmc.aper_base; @@ -1585,7 +1593,7 @@ static int initialize_plane(struct amdgpu_display_manager *dm, plane->base.type = mode_info->plane_type[plane_id]; /* - * HACK: IGT tests expect that each plane can only have one + * HACK: IGT tests expect that each plane can only have * one possible CRTC. For now, set one CRTC for each * plane that is not an underlay, but still allow multiple * CRTCs for underlay planes. @@ -1613,7 +1621,8 @@ static void register_backlight_device(struct amdgpu_display_manager *dm, if ((link->connector_signal & (SIGNAL_TYPE_EDP | SIGNAL_TYPE_LVDS)) && link->type != dc_connection_none) { - /* Event if registration failed, we should continue with + /* + * Event if registration failed, we should continue with * DM initialization because not having a backlight control * is better then a black screen. */ @@ -1626,7 +1635,8 @@ static void register_backlight_device(struct amdgpu_display_manager *dm, } -/* In this architecture, the association +/* + * In this architecture, the association * connector -> encoder -> crtc * id not really requried. The crtc and connector will hold the * display_index as an abstraction to use with DAL component @@ -1794,7 +1804,7 @@ static u8 dm_get_backlight_level(struct amdgpu_encoder *amdgpu_encoder) * amdgpu_display_funcs functions *****************************************************************************/ -/** +/* * dm_bandwidth_update - program display watermarks * * @adev: amdgpu_device pointer @@ -2007,9 +2017,11 @@ static int dm_early_init(void *handle) if (adev->mode_info.funcs == NULL) adev->mode_info.funcs = &dm_display_funcs; - /* Note: Do NOT change adev->audio_endpt_rreg and + /* + * Note: Do NOT change adev->audio_endpt_rreg and * adev->audio_endpt_wreg because they are initialised in - * amdgpu_device_init() */ + * amdgpu_device_init() + */ #if defined(CONFIG_DEBUG_KERNEL_DC) device_create_file( adev->ddev->dev, @@ -2055,7 +2067,7 @@ static bool fill_rects_from_plane_state(const struct drm_plane_state *state, { plane_state->src_rect.x = state->src_x >> 16; plane_state->src_rect.y = state->src_y >> 16; - /*we ignore for now mantissa and do not to deal with floating pixels :(*/ + /* we ignore the mantissa for now and do not deal with floating pixels :( */ plane_state->src_rect.width = state->src_w >> 16; if (plane_state->src_rect.width == 0) @@ -2107,7 +2119,7 @@ static int get_fb_info(const struct amdgpu_framebuffer *amdgpu_fb, int r = amdgpu_bo_reserve(rbo, false); if (unlikely(r)) { - // Don't show error msg. when return -ERESTARTSYS + /* Don't show error message when returning -ERESTARTSYS */ if (r != -ERESTARTSYS) DRM_ERROR("Unable to reserve buffer: %d\n", r); return r; @@ -2305,8 +2317,6 @@ static int fill_plane_attributes(struct amdgpu_device *adev, return ret; } -/*****************************************************************************/ - static void update_stream_scaling_settings(const struct drm_display_mode *mode, const struct dm_connector_state *dm_state, struct dc_stream_state *stream) @@ -2369,7 +2379,8 @@ convert_color_depth_from_display_info(const struct drm_connector *connector) switch (bpc) { case 0: - /* Temporary Work around, DRM don't parse color depth for + /* + * Temporary Work around, DRM doesn't parse color depth for * EDID revision before 1.4 * TODO: Fix edid parsing */ @@ -2481,7 +2492,6 @@ static void adjust_colour_depth_from_display_info(struct dc_crtc_timing *timing_ } while (timing_out->display_color_depth > COLOR_DEPTH_888); } -/*****************************************************************************/ static void fill_stream_properties_from_drm_display_mode(struct dc_stream_state *stream, @@ -2681,9 +2691,10 @@ static void dm_enable_per_frame_crtc_master_sync(struct dc_state *context) for (i = 0; i < context->stream_count ; i++) { if (!context->streams[i]) continue; - /* TODO: add a function to read AMD VSDB bits and will set + /* + * TODO: add a function to read AMD VSDB bits and set * crtc_sync_master.multi_sync_enabled flag - * For now its set to false + * For now it's set to false */ set_multisync_trigger_params(context->streams[i]); } @@ -2746,7 +2757,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, head); if (preferred_mode == NULL) { - /* This may not be an error, the use case is when we we have no + /* + * This may not be an error, the use case is when we have no * usermode calls to reset and set mode upon hotplug. In this * case, we call set mode ourselves to restore the previous mode * and the modelist may not be filled in in time. @@ -2890,10 +2902,12 @@ amdgpu_dm_connector_detect(struct drm_connector *connector, bool force) bool connected; struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); - /* Notes: + /* + * Notes: * 1. This interface is NOT called in context of HPD irq. * 2. This interface *is called* in context of user-mode ioctl. Which - * makes it a bad place for *any* MST-related activit. */ + * makes it a bad place for *any* MST-related activity. + */ if (aconnector->base.force == DRM_FORCE_UNSPECIFIED && !aconnector->fake_enable) @@ -3149,7 +3163,8 @@ static void handle_edid_mgmt(struct amdgpu_dm_connector *aconnector) { struct dc_link *link = (struct dc_link *)aconnector->dc_link; - /* In case of headless boot with force on for DP managed connector + /* + * In case of headless boot with force on for DP managed connector * Those settings have to be != 0 to get initial modeset */ if (link->connector_signal == SIGNAL_TYPE_DISPLAY_PORT) { @@ -3177,7 +3192,8 @@ enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connec (mode->flags & DRM_MODE_FLAG_DBLSCAN)) return result; - /* Only run this the first time mode_valid is called to initilialize + /* + * Only run this the first time mode_valid is called to initilialize * EDID mgmt */ if (aconnector->base.force != DRM_FORCE_UNSPECIFIED && @@ -3218,9 +3234,9 @@ enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connec static const struct drm_connector_helper_funcs amdgpu_dm_connector_helper_funcs = { /* - * If hotplug a second bigger display in FB Con mode, bigger resolution + * If hotplugging a second bigger display in FB Con mode, bigger resolution * modes will be filtered by drm_mode_validate_size(), and those modes - * is missing after user start lightdm. So we need to renew modes list. + * are missing after user start lightdm. So we need to renew modes list. * in get_modes call back, not just return the modes count */ .get_modes = get_modes, @@ -3246,7 +3262,7 @@ static int dm_crtc_helper_atomic_check(struct drm_crtc *crtc, return ret; } - /* In some use cases, like reset, no stream is attached */ + /* In some use cases, like reset, no stream is attached */ if (!dm_crtc_state->stream) return 0; @@ -3473,7 +3489,7 @@ static const struct drm_plane_helper_funcs dm_plane_helper_funcs = { * TODO: these are currently initialized to rgb formats only. * For future use cases we should either initialize them dynamically based on * plane capabilities, or initialize this array to all formats, so internal drm - * check will succeed, and let DC to implement proper check + * check will succeed, and let DC implement proper check */ static const uint32_t rgb_formats[] = { DRM_FORMAT_RGB888, @@ -3799,7 +3815,8 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm, aconnector->hpd.hpd = AMDGPU_HPD_NONE; /* not used */ mutex_init(&aconnector->hpd_lock); - /* configure support HPD hot plug connector_>polled default value is 0 + /* + * configure support HPD hot plug connector_>polled default value is 0 * which means HPD hot plug not supported */ switch (connector_type) { @@ -3912,7 +3929,8 @@ create_i2c(struct ddc_service *ddc_service, } -/* Note: this function assumes that dc_link_detect() was called for the +/* + * Note: this function assumes that dc_link_detect() was called for the * dc_link which will be represented by this aconnector. */ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm, @@ -4244,7 +4262,8 @@ static void amdgpu_dm_do_flip(struct drm_crtc *crtc, target_vblank = target - (uint32_t)drm_crtc_vblank_count(crtc) + amdgpu_get_vblank_counter_kms(crtc->dev, acrtc->crtc_id); - /* TODO This might fail and hence better not used, wait + /* + * TODO This might fail and hence better not used, wait * explicitly on fences instead * and in general should be called for * blocking commit to as per framework helpers @@ -4261,7 +4280,8 @@ static void amdgpu_dm_do_flip(struct drm_crtc *crtc, amdgpu_bo_unreserve(abo); - /* Wait until we're out of the vertical blank period before the one + /* + * Wait until we're out of the vertical blank period before the one * targeted by the flip */ while ((acrtc->enabled && @@ -4513,7 +4533,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, } } -/** +/* * amdgpu_dm_crtc_copy_transient_flags - copy mirrored flags from DRM to DC * @crtc_state: the DRM CRTC state * @stream_state: the DC stream state. @@ -4616,8 +4636,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) * this could happen because of issues with * userspace notifications delivery. * In this case userspace tries to set mode on - * display which is disconnect in fact. - * dc_sink in NULL in this case on aconnector. + * display which is disconnected in fact. + * dc_sink is NULL in this case on aconnector. * We expect reset mode will come soon. * * This can also happen when unplug is done @@ -4686,7 +4706,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) if (!acrtc || drm_atomic_crtc_needs_modeset(new_crtc_state)) continue; - /* Skip any thing not scale or underscan changes */ + /* Skip anything that is not scaling or underscan changes */ if (!is_scaling_state_different(dm_new_con_state, dm_old_con_state)) continue; @@ -4845,9 +4865,9 @@ static int dm_force_atomic_commit(struct drm_connector *connector) } /* - * This functions handle all cases when set mode does not come upon hotplug. - * This include when the same display is unplugged then plugged back into the - * same port and when we are running without usermode desktop manager supprot + * This function handles all cases when set mode does not come upon hotplug. + * This includes when a display is unplugged then plugged back into the + * same port and when running without usermode desktop manager supprot */ void dm_restore_drm_connector_state(struct drm_device *dev, struct drm_connector *connector) @@ -4876,7 +4896,7 @@ void dm_restore_drm_connector_state(struct drm_device *dev, dm_force_atomic_commit(&aconnector->base); } -/*` +/* * Grabs all modesetting locks to serialize against any blocking commits, * Waits for completion of all non blocking commits. */ @@ -4887,7 +4907,8 @@ static int do_aquire_global_lock(struct drm_device *dev, struct drm_crtc_commit *commit; long ret; - /* Adding all modeset locks to aquire_ctx will + /* + * Adding all modeset locks to aquire_ctx will * ensure that when the framework release it the * extra locks we are locking here will get released to */ @@ -4906,7 +4927,8 @@ static int do_aquire_global_lock(struct drm_device *dev, if (!commit) continue; - /* Make sure all pending HW programming completed and + /* + * Make sure all pending HW programming completed and * page flips done */ ret = wait_for_completion_interruptible_timeout(&commit->hw_done, 10*HZ); @@ -5000,7 +5022,7 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm, /* TODO This hack should go away */ if (aconnector && enable) { - // Make sure fake sink is created in plug-in scenario + /* Make sure fake sink is created in plug-in scenario */ drm_new_conn_state = drm_atomic_get_new_connector_state(state, &aconnector->base); drm_old_conn_state = drm_atomic_get_old_connector_state(state, @@ -5020,9 +5042,9 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm, /* * we can have no stream on ACTION_SET if a display - * was disconnected during S3, in this case it not and + * was disconnected during S3, in this case it not an * error, the OS will be updated after detection, and - * do the right thing on next atomic commit + * will do the right thing on next atomic commit */ if (!new_stream) { @@ -5403,7 +5425,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, /* * For full updates case when - * removing/adding/updating streams on once CRTC while flipping + * removing/adding/updating streams on once CRTC while flipping * on another CRTC, * acquiring global lock will guarantee that any such full * update commit @@ -5513,12 +5535,13 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, (edid->version == 1 && edid->revision > 1))) { for (i = 0; i < 4; i++) { - timing = &edid->detailed_timings[i]; - data = &timing->data.other_data; - range = &data->data.range; + timing = &edid->detailed_timings[i]; + data = &timing->data.other_data; + range = &data->data.range; /* - * Check if monitor has continuous frequency mode - */ + * Check if monitor has continuous frequency mode + */ + if (data->type != EDID_DETAIL_MONITOR_RANGE) continue; /* -- 2.17.1