drm/i915/dp: add native aux defer retry limit
Retrying indefinitely places too much trust on the aux implementation of the sink devices. Reported-by: Daniel Martin <consume.noise@gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71267 Signed-off-by: Jani Nikula <jani.nikula@intel.com> Cc: stable@vger.kernel.org Tested-by: Theodore Ts'o <tytso@mit.edu> Tested-by: Sree Harsha Totakura <freedesktop@h.totakura.in> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
		
					parent
					
						
							
								04eada25d1
							
						
					
				
			
			
				commit
				
					
						f51a44b9a6
					
				
			
		
					 1 changed files with 11 additions and 4 deletions
				
			
		| 
						 | 
					@ -537,6 +537,7 @@ intel_dp_aux_native_write(struct intel_dp *intel_dp,
 | 
				
			||||||
	uint8_t	msg[20];
 | 
						uint8_t	msg[20];
 | 
				
			||||||
	int msg_bytes;
 | 
						int msg_bytes;
 | 
				
			||||||
	uint8_t	ack;
 | 
						uint8_t	ack;
 | 
				
			||||||
 | 
						int retry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (WARN_ON(send_bytes > 16))
 | 
						if (WARN_ON(send_bytes > 16))
 | 
				
			||||||
		return -E2BIG;
 | 
							return -E2BIG;
 | 
				
			||||||
| 
						 | 
					@ -548,19 +549,21 @@ intel_dp_aux_native_write(struct intel_dp *intel_dp,
 | 
				
			||||||
	msg[3] = send_bytes - 1;
 | 
						msg[3] = send_bytes - 1;
 | 
				
			||||||
	memcpy(&msg[4], send, send_bytes);
 | 
						memcpy(&msg[4], send, send_bytes);
 | 
				
			||||||
	msg_bytes = send_bytes + 4;
 | 
						msg_bytes = send_bytes + 4;
 | 
				
			||||||
	for (;;) {
 | 
						for (retry = 0; retry < 7; retry++) {
 | 
				
			||||||
		ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes, &ack, 1);
 | 
							ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes, &ack, 1);
 | 
				
			||||||
		if (ret < 0)
 | 
							if (ret < 0)
 | 
				
			||||||
			return ret;
 | 
								return ret;
 | 
				
			||||||
		ack >>= 4;
 | 
							ack >>= 4;
 | 
				
			||||||
		if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_ACK)
 | 
							if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_ACK)
 | 
				
			||||||
			break;
 | 
								return send_bytes;
 | 
				
			||||||
		else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER)
 | 
							else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER)
 | 
				
			||||||
			usleep_range(400, 500);
 | 
								usleep_range(400, 500);
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			return -EIO;
 | 
								return -EIO;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return send_bytes;
 | 
					
 | 
				
			||||||
 | 
						DRM_ERROR("too many retries, giving up\n");
 | 
				
			||||||
 | 
						return -EIO;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Write a single byte to the aux channel in native mode */
 | 
					/* Write a single byte to the aux channel in native mode */
 | 
				
			||||||
| 
						 | 
					@ -582,6 +585,7 @@ intel_dp_aux_native_read(struct intel_dp *intel_dp,
 | 
				
			||||||
	int reply_bytes;
 | 
						int reply_bytes;
 | 
				
			||||||
	uint8_t ack;
 | 
						uint8_t ack;
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
 | 
						int retry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (WARN_ON(recv_bytes > 19))
 | 
						if (WARN_ON(recv_bytes > 19))
 | 
				
			||||||
		return -E2BIG;
 | 
							return -E2BIG;
 | 
				
			||||||
| 
						 | 
					@ -595,7 +599,7 @@ intel_dp_aux_native_read(struct intel_dp *intel_dp,
 | 
				
			||||||
	msg_bytes = 4;
 | 
						msg_bytes = 4;
 | 
				
			||||||
	reply_bytes = recv_bytes + 1;
 | 
						reply_bytes = recv_bytes + 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (;;) {
 | 
						for (retry = 0; retry < 7; retry++) {
 | 
				
			||||||
		ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes,
 | 
							ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes,
 | 
				
			||||||
				      reply, reply_bytes);
 | 
									      reply, reply_bytes);
 | 
				
			||||||
		if (ret == 0)
 | 
							if (ret == 0)
 | 
				
			||||||
| 
						 | 
					@ -612,6 +616,9 @@ intel_dp_aux_native_read(struct intel_dp *intel_dp,
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			return -EIO;
 | 
								return -EIO;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						DRM_ERROR("too many retries, giving up\n");
 | 
				
			||||||
 | 
						return -EIO;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue