drm/amd/display: Add DMUB service function check if hw initialized
authorNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Tue, 29 Oct 2019 18:23:55 +0000 (14:23 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 19 Nov 2019 15:12:52 +0000 (10:12 -0500)
[Why]
We want to avoid reprogramming the cache window when possible.

We don't need to worry about it for S3 but we *do* need to worry about
it for S4 resume.

DM can check whether hardware should be reinitialized or store software
state when going to S4 to know whether we need to reprogram hardware.

[How]
Add helpers to the DMUB service to check hardware initialization state.

DM will hook it up later.

Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dmub/inc/dmub_srv.h
drivers/gpu/drm/amd/display/dmub/src/dmub_dcn20.c
drivers/gpu/drm/amd/display/dmub/src/dmub_dcn20.h
drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c

index 45e427d1952e9e62b7e5666c995aa99d57319f11..6f3eca266694eb16d5b2bf8a2fdec8320c597f7f 100644 (file)
@@ -252,6 +252,8 @@ struct dmub_srv_hw_funcs {
 
        bool (*is_supported)(struct dmub_srv *dmub);
 
+       bool (*is_hw_init)(struct dmub_srv *dmub);
+
        bool (*is_phy_init)(struct dmub_srv *dmub);
 
        bool (*is_auto_load_done)(struct dmub_srv *dmub);
@@ -380,6 +382,15 @@ enum dmub_status dmub_srv_calc_fb_info(struct dmub_srv *dmub,
 enum dmub_status dmub_srv_has_hw_support(struct dmub_srv *dmub,
                                         bool *is_supported);
 
+/**
+ * dmub_srv_is_hw_init() - returns hardware init state
+ *
+ * Return:
+ *   DMUB_STATUS_OK - success
+ *   DMUB_STATUS_INVALID - unspecified error
+ */
+enum dmub_status dmub_srv_is_hw_init(struct dmub_srv *dmub, bool *is_hw_init);
+
 /**
  * dmub_srv_hw_init() - initializes the underlying DMUB hardware
  * @dmub: the dmub service
index 236a4156bbe13f47fdc9e94f17d4dc303e1c3780..89fd27758dd52a18358673f23952589ad7025264 100644 (file)
@@ -122,6 +122,11 @@ void dmub_dcn20_set_inbox1_wptr(struct dmub_srv *dmub, uint32_t wptr_offset)
        REG_WRITE(DMCUB_INBOX1_WPTR, wptr_offset);
 }
 
+bool dmub_dcn20_is_hw_init(struct dmub_srv *dmub)
+{
+       return REG_READ(DMCUB_REGION3_CW2_BASE_ADDRESS) != 0;
+}
+
 bool dmub_dcn20_is_supported(struct dmub_srv *dmub)
 {
        uint32_t supported = 0;
index 41269da403633615935eb615d28a39a7141d75bb..e1ba748ca594d909aefaae846b941dd4e915d6f6 100644 (file)
@@ -55,6 +55,8 @@ uint32_t dmub_dcn20_get_inbox1_rptr(struct dmub_srv *dmub);
 
 void dmub_dcn20_set_inbox1_wptr(struct dmub_srv *dmub, uint32_t wptr_offset);
 
+bool dmub_dcn20_is_hw_init(struct dmub_srv *dmub);
+
 bool dmub_dcn20_is_supported(struct dmub_srv *dmub);
 
 bool dmub_dcn20_is_phy_init(struct dmub_srv *dmub);
index 229eab7277d1153721a0d4bec6c6c28f017d0243..2d63ae80bda92e7ea03e1abebf02a6e0921a3101 100644 (file)
@@ -76,6 +76,7 @@ static bool dmub_srv_hw_setup(struct dmub_srv *dmub, enum dmub_asic asic)
                funcs->set_inbox1_wptr = dmub_dcn20_set_inbox1_wptr;
                funcs->is_supported = dmub_dcn20_is_supported;
                funcs->is_phy_init = dmub_dcn20_is_phy_init;
+               funcs->is_hw_init = dmub_dcn20_is_hw_init;
 
                if (asic == DMUB_ASIC_DCN21) {
                        funcs->backdoor_load = dmub_dcn21_backdoor_load;
@@ -234,6 +235,19 @@ enum dmub_status dmub_srv_has_hw_support(struct dmub_srv *dmub,
        return DMUB_STATUS_OK;
 }
 
+enum dmub_status dmub_srv_is_hw_init(struct dmub_srv *dmub, bool *is_hw_init)
+{
+       *is_hw_init = false;
+
+       if (!dmub->sw_init)
+               return DMUB_STATUS_INVALID;
+
+       if (dmub->hw_funcs.is_hw_init)
+               *is_hw_init = dmub->hw_funcs.is_hw_init(dmub);
+
+       return DMUB_STATUS_OK;
+}
+
 enum dmub_status dmub_srv_hw_init(struct dmub_srv *dmub,
                                  const struct dmub_srv_hw_params *params)
 {