[PATCH 06/18] drm/i915/display/dp: Prefer drm_WARN* over WARN*

Jani Nikula jani.nikula at linux.intel.com
Tue Apr 21 06:56:08 UTC 2020


On Mon, 06 Apr 2020, Pankaj Bharadiya <pankaj.laxminarayan.bharadiya at intel.com> wrote:
> struct drm_device specific drm_WARN* macros include device information
> in the backtrace, so we know what device the warnings originate from.

The patch no longer applies.

>
> Prefer drm_WARN* over WARN* at places where struct intel_dp struct
> pointer is available.
>
> Conversion is done with below sementic patch:
>
> @@
> identifier func, T;
> @@
> func(struct intel_dp *T,...) {
> + struct drm_i915_private *i915 = dp_to_i915(T);
> <+...
> (
> -WARN_ON(
> +drm_WARN_ON(&i915->drm,
> ...)
> |
> -WARN_ON_ONCE(
> +drm_WARN_ON_ONCE(&i915->drm,
> ...)
> )
> ...+>
>
> }
>
> @@
> identifier func, T;
> @@
> func(...) {
> ...
> struct intel_dp *T = ...;
> + struct drm_i915_private *i915 = dp_to_i915(T);
> <+...
> (
> -WARN_ON(
> +drm_WARN_ON(&i915->drm,
> ...)
> |
> -WARN_ON_ONCE(
> +drm_WARN_ON_ONCE(&i915->drm,
> ...)
> )
> ...+>
>
> }
>
> Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya at intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_dp.c | 26 ++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index db6ae8e9af6e..5076a7cfe0e5 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -410,7 +410,10 @@ static int intel_dp_rate_index(const int *rates, int len, int rate)
>  
>  static void intel_dp_set_common_rates(struct intel_dp *intel_dp)
>  {
> -	WARN_ON(!intel_dp->num_source_rates || !intel_dp->num_sink_rates);
> +	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
> +
> +	drm_WARN_ON(&i915->drm,
> +		    !intel_dp->num_source_rates || !intel_dp->num_sink_rates);
>  
>  	intel_dp->num_common_rates = intersect_rates(intel_dp->source_rates,
>  						     intel_dp->num_source_rates,
> @@ -419,7 +422,7 @@ static void intel_dp_set_common_rates(struct intel_dp *intel_dp)
>  						     intel_dp->common_rates);
>  
>  	/* Paranoia, there should always be something in common. */
> -	if (WARN_ON(intel_dp->num_common_rates == 0)) {
> +	if (drm_WARN_ON(&i915->drm, intel_dp->num_common_rates == 0)) {
>  		intel_dp->common_rates[0] = 162000;
>  		intel_dp->num_common_rates = 1;
>  	}
> @@ -1549,6 +1552,7 @@ static ssize_t
>  intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
>  {
>  	struct intel_dp *intel_dp = container_of(aux, struct intel_dp, aux);
> +	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
>  	u8 txbuf[20], rxbuf[20];
>  	size_t txsize, rxsize;
>  	int ret;
> @@ -1562,10 +1566,10 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
>  		txsize = msg->size ? HEADER_SIZE + msg->size : BARE_ADDRESS_SIZE;
>  		rxsize = 2; /* 0 or 1 data bytes */
>  
> -		if (WARN_ON(txsize > 20))
> +		if (drm_WARN_ON(&i915->drm, txsize > 20))
>  			return -E2BIG;
>  
> -		WARN_ON(!msg->buffer != !msg->size);
> +		drm_WARN_ON(&i915->drm, !msg->buffer != !msg->size);
>  
>  		if (msg->buffer)
>  			memcpy(txbuf + HEADER_SIZE, msg->buffer, msg->size);
> @@ -1590,7 +1594,7 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
>  		txsize = msg->size ? HEADER_SIZE : BARE_ADDRESS_SIZE;
>  		rxsize = msg->size + 1;
>  
> -		if (WARN_ON(rxsize > 20))
> +		if (drm_WARN_ON(&i915->drm, rxsize > 20))
>  			return -E2BIG;
>  
>  		ret = intel_dp_aux_xfer(intel_dp, txbuf, txsize,
> @@ -1864,10 +1868,11 @@ static void intel_dp_print_rates(struct intel_dp *intel_dp)
>  int
>  intel_dp_max_link_rate(struct intel_dp *intel_dp)
>  {
> +	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
>  	int len;
>  
>  	len = intel_dp_common_len_rate_limit(intel_dp, intel_dp->max_link_rate);
> -	if (WARN_ON(len <= 0))
> +	if (drm_WARN_ON(&i915->drm, len <= 0))
>  		return 162000;
>  
>  	return intel_dp->common_rates[len - 1];
> @@ -1875,10 +1880,11 @@ intel_dp_max_link_rate(struct intel_dp *intel_dp)
>  
>  int intel_dp_rate_select(struct intel_dp *intel_dp, int rate)
>  {
> +	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
>  	int i = intel_dp_rate_index(intel_dp->sink_rates,
>  				    intel_dp->num_sink_rates, rate);
>  
> -	if (WARN_ON(i < 0))
> +	if (drm_WARN_ON(&i915->drm, i < 0))
>  		i = 0;
>  
>  	return i;
> @@ -5404,6 +5410,7 @@ static void intel_dp_handle_test_request(struct intel_dp *intel_dp)
>  static int
>  intel_dp_check_mst_status(struct intel_dp *intel_dp)
>  {
> +	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
>  	bool bret;
>  
>  	if (intel_dp->is_mst) {
> @@ -5412,7 +5419,7 @@ intel_dp_check_mst_status(struct intel_dp *intel_dp)
>  		int retry;
>  		bool handled;
>  
> -		WARN_ON_ONCE(intel_dp->active_mst_links < 0);
> +		drm_WARN_ON_ONCE(&i915->drm, intel_dp->active_mst_links < 0);
>  		bret = intel_dp_get_sink_irq_esi(intel_dp, esi);
>  go_again:
>  		if (bret == true) {
> @@ -5695,11 +5702,12 @@ intel_dp_short_pulse(struct intel_dp *intel_dp)
>  static enum drm_connector_status
>  intel_dp_detect_dpcd(struct intel_dp *intel_dp)
>  {
> +	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
>  	struct intel_lspcon *lspcon = dp_to_lspcon(intel_dp);
>  	u8 *dpcd = intel_dp->dpcd;
>  	u8 type;
>  
> -	if (WARN_ON(intel_dp_is_edp(intel_dp)))
> +	if (drm_WARN_ON(&i915->drm, intel_dp_is_edp(intel_dp)))
>  		return connector_status_connected;
>  
>  	if (lspcon->active)

-- 
Jani Nikula, Intel Open Source Graphics Center


More information about the dri-devel mailing list