Re: [PATCH 07/29] drm/i915/tc: Move the intel_tc_port struct declaration to intel_tc.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@xxxxxxxxxxxxxxxxxxxxx> On Behalf Of Imre
> Deak
> Sent: Thursday, March 23, 2023 4:20 PM
> To: intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> Subject:  [PATCH 07/29] drm/i915/tc: Move the intel_tc_port struct
> declaration to intel_tc.c
> 
> Move the intel_tc_port struct to intel_tc.c for better isolation. This requires
> allocating the struct dynamically.
> 

Reviewed-by: Mika Kahola <mika.kahola@xxxxxxxxx>

> Signed-off-by: Imre Deak <imre.deak@xxxxxxxxx>
> ---
>  drivers/gpu/drm/i915/display/intel_ddi.c      |  7 +--
>  .../drm/i915/display/intel_display_types.h    |  4 +-
>  drivers/gpu/drm/i915/display/intel_tc.c       | 45 +++++++++++++++++--
>  drivers/gpu/drm/i915/display/intel_tc.h       | 30 +------------
>  4 files changed, 49 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c
> b/drivers/gpu/drm/i915/display/intel_ddi.c
> index 73240cf78c8bf..dac3ec8fbbc11 100644
> --- a/drivers/gpu/drm/i915/display/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/display/intel_ddi.c
> @@ -3843,7 +3843,7 @@ static void intel_ddi_encoder_destroy(struct
> drm_encoder *encoder)
> 
>  	intel_dp_encoder_flush_work(encoder);
>  	if (intel_phy_is_tc(i915, phy))
> -		intel_tc_port_flush_work(dig_port);
> +		intel_tc_port_cleanup(dig_port);
>  	intel_display_power_flush_work(i915);
> 
>  	drm_encoder_cleanup(encoder);
> @@ -4284,7 +4284,7 @@ static void intel_ddi_encoder_shutdown(struct
> intel_encoder *encoder)
>  	if (!intel_phy_is_tc(i915, phy))
>  		return;
> 
> -	intel_tc_port_flush_work(dig_port);
> +	intel_tc_port_cleanup(dig_port);
>  }
> 
>  #define port_tc_name(port) ((port) - PORT_TC1 + '1') @@ -4541,7 +4541,8 @@
> void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port)
>  				    is_legacy ? "legacy" : "non-legacy");
>  		}
> 
> -		intel_tc_port_init(dig_port, is_legacy);
> +		if (intel_tc_port_init(dig_port, is_legacy) < 0)
> +			goto err;
> 
>  		encoder->update_prepare = intel_ddi_update_prepare;
>  		encoder->update_complete = intel_ddi_update_complete; diff -
> -git a/drivers/gpu/drm/i915/display/intel_display_types.h
> b/drivers/gpu/drm/i915/display/intel_display_types.h
> index 0130c7b7f0232..ce24e58b2a825 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> @@ -54,13 +54,13 @@
>  #include "intel_display_power.h"
>  #include "intel_dpll_mgr.h"
>  #include "intel_wm_types.h"
> -#include "intel_tc.h"
> 
>  struct drm_printer;
>  struct __intel_global_objs_state;
>  struct intel_ddi_buf_trans;
>  struct intel_fbc;
>  struct intel_connector;
> +struct intel_tc_port;
> 
>  /*
>   * Display related stuff
> @@ -1781,7 +1781,7 @@ struct intel_digital_port {
>  	intel_wakeref_t ddi_io_wakeref;
>  	intel_wakeref_t aux_wakeref;
> 
> -	struct intel_tc_port tc;
> +	struct intel_tc_port *tc;
> 
>  	/* protects num_hdcp_streams reference count, hdcp_port_data and
> hdcp_auth_status */
>  	struct mutex hdcp_mutex;
> diff --git a/drivers/gpu/drm/i915/display/intel_tc.c
> b/drivers/gpu/drm/i915/display/intel_tc.c
> index 48a59a675cd57..2a04c5ea44ade 100644
> --- a/drivers/gpu/drm/i915/display/intel_tc.c
> +++ b/drivers/gpu/drm/i915/display/intel_tc.c
> @@ -15,6 +15,28 @@
>  #include "intel_mg_phy_regs.h"
>  #include "intel_tc.h"
> 
> +enum tc_port_mode {
> +	TC_PORT_DISCONNECTED,
> +	TC_PORT_TBT_ALT,
> +	TC_PORT_DP_ALT,
> +	TC_PORT_LEGACY,
> +};
> +
> +struct intel_tc_port {
> +	struct intel_digital_port *dig_port;
> +	struct mutex lock;	/* protects the TypeC port mode */
> +	intel_wakeref_t lock_wakeref;
> +	enum intel_display_power_domain lock_power_domain;
> +	struct delayed_work disconnect_phy_work;
> +	int link_refcount;
> +	bool legacy_port:1;
> +	char port_name[8];
> +	enum tc_port_mode mode;
> +	enum tc_port_mode init_mode;
> +	enum phy_fia phy_fia;
> +	u8 phy_fia_idx;
> +};
> +
>  static u32 tc_phy_hpd_live_status(struct intel_tc_port *tc);  static bool
> tc_phy_is_ready(struct intel_tc_port *tc);  static bool
> tc_phy_take_ownership(struct intel_tc_port *tc, bool take); @@ -36,7 +58,7
> @@ static const char *tc_port_mode_name(enum tc_port_mode mode)
> 
>  static struct intel_tc_port *to_tc_port(struct intel_digital_port *dig_port)  {
> -	return &dig_port->tc;
> +	return dig_port->tc;
>  }
> 
>  static struct drm_i915_private *tc_to_i915(struct intel_tc_port *tc) @@ -
> 1158,16 +1180,21 @@ tc_port_load_fia_params(struct drm_i915_private *i915,
> struct intel_tc_port *tc)
>  	}
>  }
> 
> -void intel_tc_port_init(struct intel_digital_port *dig_port, bool is_legacy)
> +int intel_tc_port_init(struct intel_digital_port *dig_port, bool
> +is_legacy)
>  {
>  	struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev);
> -	struct intel_tc_port *tc = to_tc_port(dig_port);
> +	struct intel_tc_port *tc;
>  	enum port port = dig_port->base.port;
>  	enum tc_port tc_port = intel_port_to_tc(i915, port);
> 
>  	if (drm_WARN_ON(&i915->drm, tc_port == TC_PORT_NONE))
> -		return;
> +		return -EINVAL;
> +
> +	tc = kzalloc(sizeof(*tc), GFP_KERNEL);
> +	if (!tc)
> +		return -ENOMEM;
> 
> +	dig_port->tc = tc;
>  	tc->dig_port = dig_port;
> 
>  	snprintf(tc->port_name, sizeof(tc->port_name), @@ -1181,4 +1208,14
> @@ void intel_tc_port_init(struct intel_digital_port *dig_port, bool is_legacy)
>  	tc_port_load_fia_params(i915, tc);
> 
>  	intel_tc_port_init_mode(dig_port);
> +
> +	return 0;
> +}
> +
> +void intel_tc_port_cleanup(struct intel_digital_port *dig_port) {
> +	intel_tc_port_flush_work(dig_port);
> +
> +	kfree(dig_port->tc);
> +	dig_port->tc = NULL;
>  }
> diff --git a/drivers/gpu/drm/i915/display/intel_tc.h
> b/drivers/gpu/drm/i915/display/intel_tc.h
> index cc3a7fd4ac102..dd0810f9ea95e 100644
> --- a/drivers/gpu/drm/i915/display/intel_tc.h
> +++ b/drivers/gpu/drm/i915/display/intel_tc.h
> @@ -6,39 +6,12 @@
>  #ifndef __INTEL_TC_H__
>  #define __INTEL_TC_H__
> 
> -#include <linux/mutex.h>
>  #include <linux/types.h>
> 
> -#include "intel_display.h"
> -#include "intel_display_power.h"
> -#include "intel_wakeref.h"
> -
>  struct intel_crtc_state;
>  struct intel_digital_port;
>  struct intel_encoder;
> 
> -enum tc_port_mode {
> -	TC_PORT_DISCONNECTED,
> -	TC_PORT_TBT_ALT,
> -	TC_PORT_DP_ALT,
> -	TC_PORT_LEGACY,
> -};
> -
> -struct intel_tc_port {
> -	struct intel_digital_port *dig_port;
> -	struct mutex lock;	/* protects the TypeC port mode */
> -	intel_wakeref_t lock_wakeref;
> -	enum intel_display_power_domain lock_power_domain;
> -	struct delayed_work disconnect_phy_work;
> -	int link_refcount;
> -	bool legacy_port:1;
> -	char port_name[8];
> -	enum tc_port_mode mode;
> -	enum tc_port_mode init_mode;
> -	enum phy_fia phy_fia;
> -	u8 phy_fia_idx;
> -};
> -
>  bool intel_tc_port_in_tbt_alt_mode(struct intel_digital_port *dig_port);  bool
> intel_tc_port_in_dp_alt_mode(struct intel_digital_port *dig_port);  bool
> intel_tc_port_in_legacy_mode(struct intel_digital_port *dig_port); @@ -63,7
> +36,8 @@ void intel_tc_port_get_link(struct intel_digital_port *dig_port,  void
> intel_tc_port_put_link(struct intel_digital_port *dig_port);  bool
> intel_tc_port_ref_held(struct intel_digital_port *dig_port);
> 
> -void intel_tc_port_init(struct intel_digital_port *dig_port, bool is_legacy);
> +int intel_tc_port_init(struct intel_digital_port *dig_port, bool
> +is_legacy); void intel_tc_port_cleanup(struct intel_digital_port
> +*dig_port);
> 
>  bool intel_tc_cold_requires_aux_pw(struct intel_digital_port *dig_port);
> 
> --
> 2.37.1





[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux