GPU-DRM-i915-DP: Fine-tuning for two function implementations
Subsystems (3)
cover GPU-DRM-i915-DP: Fine-tuning for two function implementations
From: Markus Elfring <[email protected]>
Date: Tue, 24 Oct 2017 15:54:32 +0200
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Delete an unnecessary goto statement in intel_dp_sink_crc() Use common error handling code in intel_dp_sink_crc_stop()
drivers/gpu/drm/i915/intel_dp.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-)
Signature · 6 lines
2.14.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/2 drm/i915/dp: Delete an unnecessary goto statement in intel_dp_sink_crc()
From: Markus Elfring <[email protected]>
Date: Tue, 24 Oct 2017 15:15:20 +0200
A jump was specified for a location which was directly behind. Thus remove such an unnecessary goto statement.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/i915/intel_dp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +1 -3
@@ -3994,10 +3994,8 @@ int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc) goto stop; } -if (drm_dp_dpcd_read (&intel_dp->aux,DP_TEST_CRC_R_CR , crc,6 ) <0 ) { +if (drm_dp_dpcd_read (&intel_dp->aux,DP_TEST_CRC_R_CR , crc,6 ) <0 ) ret = -EIO ; - goto stop; - } stop:intel_dp_sink_crc_stop (intel_dp);
Signature · 6 lines
2.14.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 drm/i915/dp: Use common error handling code in intel_dp_sink_crc_stop()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 24 Oct 2017 15:40:47 +0200
Adjust jump targets so that a specific error code assignment will be in the implementation only at the end of this function.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/i915/intel_dp.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +14 -16
@@ -3894,27 +3894,19 @@ static int intel_dp_sink_crc_stop(struct intel_dp *intel_dp)int count =0 ;int attempts =10 ; -if (drm_dp_dpcd_readb (&intel_dp->aux,DP_TEST_SINK , &buf) <0 ) { -DRM_DEBUG_KMS ("Sink CRC couldn't be stopped properly\n" ); - ret = -EIO ; - goto out; - } +if (drm_dp_dpcd_readb (&intel_dp->aux,DP_TEST_SINK , &buf) <0 ) + goto report_failure;if (drm_dp_dpcd_writeb (&intel_dp->aux,DP_TEST_SINK , - buf & ~DP_TEST_SINK_START ) <0 ) { -DRM_DEBUG_KMS ("Sink CRC couldn't be stopped properly\n" ); - ret = -EIO ; - goto out; - } + buf & ~DP_TEST_SINK_START ) <0 ) + goto report_failure;do {intel_wait_for_vblank (dev_priv, intel_crtc->pipe); +if (drm_dp_dpcd_readb (&intel_dp->aux,DP_TEST_SINK_MISC , &buf) + <0 ) + goto e_io; -if (drm_dp_dpcd_readb (&intel_dp->aux, -DP_TEST_SINK_MISC , &buf) <0 ) { - ret = -EIO ; - goto out; - } count = buf &DP_TEST_COUNT_MASK ; }while (--attempts && count);
@@ -3923,9 +3915,15 @@ static int intel_dp_sink_crc_stop(struct intel_dp *intel_dp) ret = -ETIMEDOUT ; } - out: +enable_ips:hsw_enable_ips (intel_crtc);return ret; + +report_failure: +DRM_DEBUG_KMS ("Sink CRC couldn't be stopped properly\n" ); +e_io: + ret = -EIO ; + goto enable_ips; }static int intel_dp_sink_crc_start (struct intel_dp *intel_dp)
Signature · 6 lines
2.14.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Jani Nikula
maintainerRe: [PATCH 2/2] drm/i915/dp: Use common error handling code in intel_dp_sink_crc_stop()
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 24 Oct 2017 15:40:47 +0200Adjust jump targets so that a specific error code assignment will be in the implementation only at the end of this function.
This is not an issue that needs to be "fixed".
Quoted 19 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/i915/intel_dp.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)drivers/gpu/drm/i915/intel_dp.c +0
-3@@ -3894,27 +3894,19 @@ static int intel_dp_sink_crc_stop(struct intel_dp *intel_dp)int count =0 ;int attempts =10 ; -if (drm_dp_dpcd_readb (&intel_dp->aux,DP_TEST_SINK , &buf) <0 ) { -DRM_DEBUG_KMS ("Sink CRC couldn't be stopped properly\n" ); - ret = -EIO ;
drivers/gpu/drm/i915/intel_dp.c static int intel_dp_sink_crc_stop(struct intel_dp *intel_dp) · line 3907
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +2
-6- goto out; - } +if (drm_dp_dpcd_readb (&intel_dp->aux,DP_TEST_SINK , &buf) <0 ) + goto report_failure; if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_TEST_SINK, - buf & ~DP_TEST_SINK_START ) <0 ) { -DRM_DEBUG_KMS ("Sink CRC couldn't be stopped properly\n" ); - ret = -EIO ; - goto out;
I'd rather change the debug messages to distinguish the cases. I also want to keep ret = -EIO in each individual branch, to distinguish from the cases where it's set to something other than -EIO.
Quoted 5 lines
drivers/gpu/drm/i915/intel_dp.c +2
-1- } + buf & ~DP_TEST_SINK_START) < 0) + goto report_failure; do {
drivers/gpu/drm/i915/intel_dp.c static int intel_dp_sink_crc_stop(struct intel_dp *intel_dp) · line 3917
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +3
-5intel_wait_for_vblank (dev_priv, intel_crtc->pipe); +if (drm_dp_dpcd_readb (&intel_dp->aux,DP_TEST_SINK_MISC , &buf) + <0 ) + goto e_io; -if (drm_dp_dpcd_readb (&intel_dp->aux, -DP_TEST_SINK_MISC , &buf) <0 ) { - ret = -EIO ; - goto out; - }
This is good as it is. The change makes it worse.
Quoted 7 lines
drivers/gpu/drm/i915/intel_dp.c +0
-0count = buf &DP_TEST_COUNT_MASK ; }while (--attempts && count);@@ -3923,9 +3915,15 @@ static int intel_dp_sink_crc_stop(struct intel_dp *intel_dp) ret = -ETIMEDOUT ; }
drivers/gpu/drm/i915/intel_dp.c static int intel_dp_sink_crc_stop(struct intel_dp *intel_dp) · line 3926
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +7
-1- out: +enable_ips:hsw_enable_ips (intel_crtc);return ret; + +report_failure: +DRM_DEBUG_KMS ("Sink CRC couldn't be stopped properly\n" ); +e_io: + ret = -EIO ; + goto enable_ips;
*shudder* Please no.
BR,
Jani.
Quoted 3 lines
drivers/gpu/drm/i915/intel_dp.c +0
-0}static int intel_dp_sink_crc_start (struct intel_dp *intel_dp)
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx