All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/20] drm/amdgpu: gfx off support
@ 2018-04-19  0:22 Huang Rui
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

GFXOFF is the new GPU feature that save power consumption. It used RLC to
poweroff the gfx engine dynamicly when there is no workload on gfx pipe and make
gfx into "idle" state.
1. Add three additional RLC ucodes, and use psp to load them.
2. Revise RLC save restore list.
3. Enable CGPG (GFX power gating).
4. Enable gfxoff.
5. Revise suspend/resume sequence.

Currently, only raven is able to support gfxoff at first. And after CQE do
series rounds of testing, and there is no regression that bring by gfxoff
feature till now. 

We support two types of gfxoff, and user is able to build them manually from
firmware repo:
1. Real CGPG
	$ make clean
	$ make REAL_CGPG=1
2. Faked CGPG: (by default)
	$ make clean
	$ make	

Then configure to enable gfxoff with ppfeaturemask=0xffffbfff.

Thanks,
Ray

Huang Rui (20):
  drm/amdgpu: update psp gfx if header
  drm/amdgpu: add new rlc firmware header format v2.1
  drm/amdgpu: add save restore list cntl gpm and srm firmware support
  drm/amdgpu: enter rlc safe mode before set cgpg
  drm/amdgpu: cleanup init power gating function
  drm/amdgpu: revise init_rlc_save_restore_list behavior to support
    latest register_list_format/register_restore table
  drm/amdgpu: add setting powergating method for gfx9
  drm/amd/powerplay: send CGPG smc message if PG is enabled for raven
  drm/amdgpu: move PP_FEATURE_MASK to amd_shared header
  drm/amdgpu: add gfxoff feature mask
  drm/amdgpu: set gfxoff disabled by default
  drm/amd/powerplay: add gfx off control function
  drm/amd/powerplay: enable/disable gfxoff through smu
  drm/amdgpu: use pp_feature member to store the mask
  drm/amdgpu: clear gfxoff featue mask if the asic is not raven
  drm/amd/powerplay: add control gfxoff enabling in late init
  drm/amdgpu: it should disable gfxoff when system is going to suspend
  drm/amdgpu: fix to disable powergating in hw_fini
  drm/amdgpu: set CGPG if gfxoff is enabled for raven
  drm/amd/powerplay: use the flag to decide whether send gfxoff smc
    message

 drivers/gpu/drm/amd/amdgpu/amdgpu.h               |  16 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |   8 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h           |   2 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c           |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c           |  36 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c         |  51 ++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h         |  22 ++
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c               |   2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             | 233 +++++++++++++++-------
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c               |   2 +-
 drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h           |  67 +++++--
 drivers/gpu/drm/amd/amdgpu/psp_v10_0.c            |   9 +
 drivers/gpu/drm/amd/amdgpu/soc15.c                |   5 +
 drivers/gpu/drm/amd/include/amd_shared.h          |  19 ++
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c     |  20 +-
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c       |   6 +-
 drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c |  50 ++++-
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h         |  19 +-
 drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h      |   1 +
 include/uapi/drm/amdgpu_drm.h                     |   6 +
 20 files changed, 447 insertions(+), 129 deletions(-)

-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 01/20] drm/amdgpu: update psp gfx if header
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 02/20] drm/amdgpu: add new rlc firmware header format v2.1 Huang Rui
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h | 67 ++++++++++++++++++++++-----------
 1 file changed, 46 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h b/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
index 8da6da9..0cf48d2 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
+++ b/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
@@ -40,11 +40,20 @@ enum psp_gfx_crtl_cmd_id
     GFX_CTRL_CMD_ID_INIT_GPCOM_RING = 0x00020000,   /* initialize GPCOM ring */
     GFX_CTRL_CMD_ID_DESTROY_RINGS   = 0x00030000,   /* destroy rings */
     GFX_CTRL_CMD_ID_CAN_INIT_RINGS  = 0x00040000,   /* is it allowed to initialized the rings */
+    GFX_CTRL_CMD_ID_ENABLE_INT      = 0x00050000,   /* enable PSP-to-Gfx interrupt */
+    GFX_CTRL_CMD_ID_DISABLE_INT     = 0x00060000,   /* disable PSP-to-Gfx interrupt */
+    GFX_CTRL_CMD_ID_MODE1_RST       = 0x00070000,   /* trigger the Mode 1 reset */
 
     GFX_CTRL_CMD_ID_MAX             = 0x000F0000,   /* max command ID */
 };
 
 
+/*-----------------------------------------------------------------------------
+    NOTE:   All physical addresses used in this interface are actually
+            GPU Virtual Addresses.
+*/
+
+
 /* Control registers of the TEE Gfx interface. These are located in
 *  SRBM-to-PSP mailbox registers (total 8 registers).
 */
@@ -55,8 +64,8 @@ struct psp_gfx_ctrl
     volatile uint32_t   rbi_rptr;         /* +8   Read pointer (index) of RBI ring */
     volatile uint32_t   gpcom_wptr;       /* +12  Write pointer (index) of GPCOM ring */
     volatile uint32_t   gpcom_rptr;       /* +16  Read pointer (index) of GPCOM ring */
-    volatile uint32_t   ring_addr_lo;     /* +20  bits [31:0] of physical address of ring buffer */
-    volatile uint32_t   ring_addr_hi;     /* +24  bits [63:32] of physical address of ring buffer */
+    volatile uint32_t   ring_addr_lo;     /* +20  bits [31:0] of GPU Virtual of ring buffer (VMID=0)*/
+    volatile uint32_t   ring_addr_hi;     /* +24  bits [63:32] of GPU Virtual of ring buffer (VMID=0) */
     volatile uint32_t   ring_buf_size;    /* +28  Ring buffer size (in bytes) */
 
 };
@@ -78,6 +87,8 @@ enum psp_gfx_cmd_id
     GFX_CMD_ID_LOAD_ASD     = 0x00000004,   /* load ASD Driver */
     GFX_CMD_ID_SETUP_TMR    = 0x00000005,   /* setup TMR region */
     GFX_CMD_ID_LOAD_IP_FW   = 0x00000006,   /* load HW IP FW */
+    GFX_CMD_ID_DESTROY_TMR  = 0x00000007,   /* destroy TMR region */
+    GFX_CMD_ID_SAVE_RESTORE = 0x00000008,   /* save/restore HW IP FW */
 
 };
 
@@ -85,11 +96,11 @@ enum psp_gfx_cmd_id
 /* Command to load Trusted Application binary into PSP OS. */
 struct psp_gfx_cmd_load_ta
 {
-    uint32_t        app_phy_addr_lo;        /* bits [31:0] of the physical address of the TA binary (must be 4 KB aligned) */
-    uint32_t        app_phy_addr_hi;        /* bits [63:32] of the physical address of the TA binary */
+    uint32_t        app_phy_addr_lo;        /* bits [31:0] of the GPU Virtual address of the TA binary (must be 4 KB aligned) */
+    uint32_t        app_phy_addr_hi;        /* bits [63:32] of the GPU Virtual address of the TA binary */
     uint32_t        app_len;                /* length of the TA binary in bytes */
-    uint32_t        cmd_buf_phy_addr_lo;    /* bits [31:0] of the physical address of CMD buffer (must be 4 KB aligned) */
-    uint32_t        cmd_buf_phy_addr_hi;    /* bits [63:32] of the physical address of CMD buffer */
+    uint32_t        cmd_buf_phy_addr_lo;    /* bits [31:0] of the GPU Virtual address of CMD buffer (must be 4 KB aligned) */
+    uint32_t        cmd_buf_phy_addr_hi;    /* bits [63:32] of the GPU Virtual address of CMD buffer */
     uint32_t        cmd_buf_len;            /* length of the CMD buffer in bytes; must be multiple of 4 KB */
 
     /* Note: CmdBufLen can be set to 0. In this case no persistent CMD buffer is provided
@@ -111,8 +122,8 @@ struct psp_gfx_cmd_unload_ta
 */
 struct psp_gfx_buf_desc
 {
-    uint32_t        buf_phy_addr_lo;       /* bits [31:0] of physical address of the buffer (must be 4 KB aligned) */
-    uint32_t        buf_phy_addr_hi;       /* bits [63:32] of physical address of the buffer */
+    uint32_t        buf_phy_addr_lo;       /* bits [31:0] of GPU Virtual address of the buffer (must be 4 KB aligned) */
+    uint32_t        buf_phy_addr_hi;       /* bits [63:32] of GPU Virtual address of the buffer */
     uint32_t        buf_size;              /* buffer size in bytes (must be multiple of 4 KB and no bigger than 64 MB) */
 
 };
@@ -145,8 +156,8 @@ struct psp_gfx_cmd_invoke_cmd
 /* Command to setup TMR region. */
 struct psp_gfx_cmd_setup_tmr
 {
-    uint32_t        buf_phy_addr_lo;       /* bits [31:0] of physical address of TMR buffer (must be 4 KB aligned) */
-    uint32_t        buf_phy_addr_hi;       /* bits [63:32] of physical address of TMR buffer */
+    uint32_t        buf_phy_addr_lo;       /* bits [31:0] of GPU Virtual address of TMR buffer (must be 4 KB aligned) */
+    uint32_t        buf_phy_addr_hi;       /* bits [63:32] of GPU Virtual address of TMR buffer */
     uint32_t        buf_size;              /* buffer size in bytes (must be multiple of 4 KB) */
 
 };
@@ -174,18 +185,32 @@ enum psp_gfx_fw_type
     GFX_FW_TYPE_ISP         = 16,
     GFX_FW_TYPE_ACP         = 17,
     GFX_FW_TYPE_SMU         = 18,
+    GFX_FW_TYPE_MMSCH       = 19,
+    GFX_FW_TYPE_RLC_RESTORE_LIST_GPM_MEM        = 20,
+    GFX_FW_TYPE_RLC_RESTORE_LIST_SRM_MEM        = 21,
+    GFX_FW_TYPE_RLC_RESTORE_LIST_CNTL           = 22,
+    GFX_FW_TYPE_MAX         = 23
 };
 
 /* Command to load HW IP FW. */
 struct psp_gfx_cmd_load_ip_fw
 {
-    uint32_t                fw_phy_addr_lo;    /* bits [31:0] of physical address of FW location (must be 4 KB aligned) */
-    uint32_t                fw_phy_addr_hi;    /* bits [63:32] of physical address of FW location */
+    uint32_t                fw_phy_addr_lo;    /* bits [31:0] of GPU Virtual address of FW location (must be 4 KB aligned) */
+    uint32_t                fw_phy_addr_hi;    /* bits [63:32] of GPU Virtual address of FW location */
     uint32_t                fw_size;           /* FW buffer size in bytes */
     enum psp_gfx_fw_type    fw_type;           /* FW type */
 
 };
 
+/* Command to save/restore HW IP FW. */
+struct psp_gfx_cmd_save_restore_ip_fw
+{
+    uint32_t                save_fw;              /* if set, command is used for saving fw otherwise for resetoring*/
+    uint32_t                save_restore_addr_lo; /* bits [31:0] of FB address of GART memory used as save/restore buffer (must be 4 KB aligned) */
+    uint32_t                save_restore_addr_hi; /* bits [63:32] of FB address of GART memory used as save/restore buffer */
+    uint32_t                buf_size;             /* Size of the save/restore buffer in bytes */
+    enum psp_gfx_fw_type    fw_type;              /* FW type */
+};
 
 /* All GFX ring buffer commands. */
 union psp_gfx_commands
@@ -195,7 +220,7 @@ union psp_gfx_commands
     struct psp_gfx_cmd_invoke_cmd       cmd_invoke_cmd;
     struct psp_gfx_cmd_setup_tmr        cmd_setup_tmr;
     struct psp_gfx_cmd_load_ip_fw       cmd_load_ip_fw;
-
+    struct psp_gfx_cmd_save_restore_ip_fw cmd_save_restore_ip_fw;
 };
 
 
@@ -226,8 +251,8 @@ struct psp_gfx_cmd_resp
 
     /* These fields are used for RBI only. They are all 0 in GPCOM commands
     */
-    uint32_t        resp_buf_addr_lo;   /* +12 bits [31:0] of physical address of response buffer (must be 4 KB aligned) */
-    uint32_t        resp_buf_addr_hi;   /* +16 bits [63:32] of physical address of response buffer */
+    uint32_t        resp_buf_addr_lo;   /* +12 bits [31:0] of GPU Virtual address of response buffer (must be 4 KB aligned) */
+    uint32_t        resp_buf_addr_hi;   /* +16 bits [63:32] of GPU Virtual address of response buffer */
     uint32_t        resp_offset;        /* +20 offset within response buffer */
     uint32_t        resp_buf_size;      /* +24 total size of the response buffer in bytes */
 
@@ -251,19 +276,19 @@ struct psp_gfx_cmd_resp
 /* Structure of the Ring Buffer Frame */
 struct psp_gfx_rb_frame
 {
-    uint32_t    cmd_buf_addr_lo;    /* +0  bits [31:0] of physical address of command buffer (must be 4 KB aligned) */
-    uint32_t    cmd_buf_addr_hi;    /* +4  bits [63:32] of physical address of command buffer */
+    uint32_t    cmd_buf_addr_lo;    /* +0  bits [31:0] of GPU Virtual address of command buffer (must be 4 KB aligned) */
+    uint32_t    cmd_buf_addr_hi;    /* +4  bits [63:32] of GPU Virtual address of command buffer */
     uint32_t    cmd_buf_size;       /* +8  command buffer size in bytes */
-    uint32_t    fence_addr_lo;      /* +12 bits [31:0] of physical address of Fence for this frame */
-    uint32_t    fence_addr_hi;      /* +16 bits [63:32] of physical address of Fence for this frame */
+    uint32_t    fence_addr_lo;      /* +12 bits [31:0] of GPU Virtual address of Fence for this frame */
+    uint32_t    fence_addr_hi;      /* +16 bits [63:32] of GPU Virtual address of Fence for this frame */
     uint32_t    fence_value;        /* +20 Fence value */
     uint32_t    sid_lo;             /* +24 bits [31:0] of SID value (used only for RBI frames) */
     uint32_t    sid_hi;             /* +28 bits [63:32] of SID value (used only for RBI frames) */
     uint8_t     vmid;               /* +32 VMID value used for mapping of all addresses for this frame */
     uint8_t     frame_type;         /* +33 1: destory context frame, 0: all other frames; used only for RBI frames */
     uint8_t     reserved1[2];       /* +34 reserved, must be 0 */
-    uint32_t    reserved2[7];       /* +40 reserved, must be 0 */
-    /* total 64 bytes */
+    uint32_t    reserved2[7];       /* +36 reserved, must be 0 */
+                /* total 64 bytes */
 };
 
 #endif /* _PSP_TEE_GFX_IF_H_ */
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 02/20] drm/amdgpu: add new rlc firmware header format v2.1
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
  2018-04-19  0:22   ` [PATCH 01/20] drm/amdgpu: update psp gfx if header Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 03/20] drm/amdgpu: add save restore list cntl gpm and srm firmware support Huang Rui
                     ` (19 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 34 +++++++++++++++++++++++++++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h | 19 +++++++++++++++++
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
index dd6f989..84d6525 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
@@ -161,8 +161,38 @@ void amdgpu_ucode_print_rlc_hdr(const struct common_firmware_header *hdr)
 			  le32_to_cpu(rlc_hdr->reg_list_format_separate_array_offset_bytes));
 		DRM_DEBUG("reg_list_separate_size_bytes: %u\n",
 			  le32_to_cpu(rlc_hdr->reg_list_separate_size_bytes));
-		DRM_DEBUG("reg_list_separate_size_bytes: %u\n",
-			  le32_to_cpu(rlc_hdr->reg_list_separate_size_bytes));
+		DRM_DEBUG("reg_list_separate_array_offset_bytes: %u\n",
+			  le32_to_cpu(rlc_hdr->reg_list_separate_array_offset_bytes));
+		if (version_minor == 1) {
+			const struct rlc_firmware_header_v2_1 *v2_1 =
+				container_of(rlc_hdr, struct rlc_firmware_header_v2_1, v2_0);
+			DRM_DEBUG("reg_list_format_direct_reg_list_length: %u\n",
+				  le32_to_cpu(v2_1->reg_list_format_direct_reg_list_length));
+			DRM_DEBUG("save_restore_list_cntl_ucode_ver: %u\n",
+				  le32_to_cpu(v2_1->save_restore_list_cntl_ucode_ver));
+			DRM_DEBUG("save_restore_list_cntl_feature_ver: %u\n",
+				  le32_to_cpu(v2_1->save_restore_list_cntl_feature_ver));
+			DRM_DEBUG("save_restore_list_cntl_size_bytes %u\n",
+				  le32_to_cpu(v2_1->save_restore_list_cntl_size_bytes));
+			DRM_DEBUG("save_restore_list_cntl_offset_bytes: %u\n",
+				  le32_to_cpu(v2_1->save_restore_list_cntl_offset_bytes));
+			DRM_DEBUG("save_restore_list_gpm_ucode_ver: %u\n",
+				  le32_to_cpu(v2_1->save_restore_list_gpm_ucode_ver));
+			DRM_DEBUG("save_restore_list_gpm_feature_ver: %u\n",
+				  le32_to_cpu(v2_1->save_restore_list_gpm_feature_ver));
+			DRM_DEBUG("save_restore_list_gpm_size_bytes %u\n",
+				  le32_to_cpu(v2_1->save_restore_list_gpm_size_bytes));
+			DRM_DEBUG("save_restore_list_gpm_offset_bytes: %u\n",
+				  le32_to_cpu(v2_1->save_restore_list_gpm_offset_bytes));
+			DRM_DEBUG("save_restore_list_srm_ucode_ver: %u\n",
+				  le32_to_cpu(v2_1->save_restore_list_srm_ucode_ver));
+			DRM_DEBUG("save_restore_list_srm_feature_ver: %u\n",
+				  le32_to_cpu(v2_1->save_restore_list_srm_feature_ver));
+			DRM_DEBUG("save_restore_list_srm_size_bytes %u\n",
+				  le32_to_cpu(v2_1->save_restore_list_srm_size_bytes));
+			DRM_DEBUG("save_restore_list_srm_offset_bytes: %u\n",
+				  le32_to_cpu(v2_1->save_restore_list_srm_offset_bytes));
+		}
 	} else {
 		DRM_ERROR("Unknown RLC ucode version: %u.%u\n", version_major, version_minor);
 	}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
index 30b5500..0b262f4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
@@ -98,6 +98,24 @@ struct rlc_firmware_header_v2_0 {
 	uint32_t reg_list_separate_array_offset_bytes; /* payload offset from the start of the header */
 };
 
+/* version_major=2, version_minor=1 */
+struct rlc_firmware_header_v2_1 {
+	struct rlc_firmware_header_v2_0 v2_0;
+	uint32_t reg_list_format_direct_reg_list_length; /* length of direct reg list format array */
+	uint32_t save_restore_list_cntl_ucode_ver;
+	uint32_t save_restore_list_cntl_feature_ver;
+	uint32_t save_restore_list_cntl_size_bytes;
+	uint32_t save_restore_list_cntl_offset_bytes;
+	uint32_t save_restore_list_gpm_ucode_ver;
+	uint32_t save_restore_list_gpm_feature_ver;
+	uint32_t save_restore_list_gpm_size_bytes;
+	uint32_t save_restore_list_gpm_offset_bytes;
+	uint32_t save_restore_list_srm_ucode_ver;
+	uint32_t save_restore_list_srm_feature_ver;
+	uint32_t save_restore_list_srm_size_bytes;
+	uint32_t save_restore_list_srm_offset_bytes;
+};
+
 /* version_major=1, version_minor=0 */
 struct sdma_firmware_header_v1_0 {
 	struct common_firmware_header header;
@@ -148,6 +166,7 @@ union amdgpu_firmware_header {
 	struct gfx_firmware_header_v1_0 gfx;
 	struct rlc_firmware_header_v1_0 rlc;
 	struct rlc_firmware_header_v2_0 rlc_v2_0;
+	struct rlc_firmware_header_v2_1 rlc_v2_1;
 	struct sdma_firmware_header_v1_0 sdma;
 	struct sdma_firmware_header_v1_1 sdma_v1_1;
 	struct gpu_info_firmware_header_v1_0 gpu_info;
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 03/20] drm/amdgpu: add save restore list cntl gpm and srm firmware support
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
  2018-04-19  0:22   ` [PATCH 01/20] drm/amdgpu: update psp gfx if header Huang Rui
  2018-04-19  0:22   ` [PATCH 02/20] drm/amdgpu: add new rlc firmware header format v2.1 Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 04/20] drm/amdgpu: enter rlc safe mode before set cgpg Huang Rui
                     ` (18 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

RLC save/restore list cntl/gpm_mem/srm_mem ucodes are used for CGPG and gfxoff
function.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       | 15 +++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   | 36 ++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 17 +++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h |  3 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c     | 55 +++++++++++++++++++++++++++++--
 drivers/gpu/drm/amd/amdgpu/psp_v10_0.c    |  9 +++++
 include/uapi/drm/amdgpu_drm.h             |  6 ++++
 7 files changed, 138 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index f5b2ec2..bed1f5d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -774,9 +774,18 @@ struct amdgpu_rlc {
 	u32 starting_offsets_start;
 	u32 reg_list_format_size_bytes;
 	u32 reg_list_size_bytes;
+	u32 reg_list_format_direct_reg_list_length;
+	u32 save_restore_list_cntl_size_bytes;
+	u32 save_restore_list_gpm_size_bytes;
+	u32 save_restore_list_srm_size_bytes;
 
 	u32 *register_list_format;
 	u32 *register_restore;
+	u8 *save_restore_list_cntl;
+	u8 *save_restore_list_gpm;
+	u8 *save_restore_list_srm;
+
+	bool is_rlc_v2_1;
 };
 
 #define AMDGPU_MAX_COMPUTE_QUEUES KGD_MAX_QUEUES
@@ -943,6 +952,12 @@ struct amdgpu_gfx {
 	uint32_t			ce_feature_version;
 	uint32_t			pfp_feature_version;
 	uint32_t			rlc_feature_version;
+	uint32_t			rlc_srlc_fw_version;
+	uint32_t			rlc_srlc_feature_version;
+	uint32_t			rlc_srlg_fw_version;
+	uint32_t			rlc_srlg_feature_version;
+	uint32_t			rlc_srls_fw_version;
+	uint32_t			rlc_srls_feature_version;
 	uint32_t			mec_feature_version;
 	uint32_t			mec2_feature_version;
 	struct amdgpu_ring		gfx_ring[AMDGPU_MAX_GFX_RINGS];
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index f059d8e..6d55cae 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -215,6 +215,18 @@ static int amdgpu_firmware_info(struct drm_amdgpu_info_firmware *fw_info,
 		fw_info->ver = adev->gfx.rlc_fw_version;
 		fw_info->feature = adev->gfx.rlc_feature_version;
 		break;
+	case AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL:
+		fw_info->ver = adev->gfx.rlc_srlc_fw_version;
+		fw_info->feature = adev->gfx.rlc_srlc_feature_version;
+		break;
+	case AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM:
+		fw_info->ver = adev->gfx.rlc_srlg_fw_version;
+		fw_info->feature = adev->gfx.rlc_srlg_feature_version;
+		break;
+	case AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM:
+		fw_info->ver = adev->gfx.rlc_srls_fw_version;
+		fw_info->feature = adev->gfx.rlc_srls_feature_version;
+		break;
 	case AMDGPU_INFO_FW_GFX_MEC:
 		if (query_fw->index == 0) {
 			fw_info->ver = adev->gfx.mec_fw_version;
@@ -1150,6 +1162,30 @@ static int amdgpu_debugfs_firmware_info(struct seq_file *m, void *data)
 	seq_printf(m, "RLC feature version: %u, firmware version: 0x%08x\n",
 		   fw_info.feature, fw_info.ver);
 
+	/* RLC SAVE RESTORE LIST CNTL */
+	query_fw.fw_type = AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL;
+	ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
+	if (ret)
+		return ret;
+	seq_printf(m, "RLC SRLC feature version: %u, firmware version: 0x%08x\n",
+		   fw_info.feature, fw_info.ver);
+
+	/* RLC SAVE RESTORE LIST GPM MEM */
+	query_fw.fw_type = AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM;
+	ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
+	if (ret)
+		return ret;
+	seq_printf(m, "RLC SRLG feature version: %u, firmware version: 0x%08x\n",
+		   fw_info.feature, fw_info.ver);
+
+	/* RLC SAVE RESTORE LIST SRM MEM */
+	query_fw.fw_type = AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM;
+	ret = amdgpu_firmware_info(&fw_info, &query_fw, adev);
+	if (ret)
+		return ret;
+	seq_printf(m, "RLC SRLS feature version: %u, firmware version: 0x%08x\n",
+		   fw_info.feature, fw_info.ver);
+
 	/* MEC */
 	query_fw.fw_type = AMDGPU_INFO_FW_GFX_MEC;
 	query_fw.index = 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
index 84d6525..0c74c09 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
@@ -337,7 +337,10 @@ static int amdgpu_ucode_init_single_fw(struct amdgpu_device *adev,
 	    (ucode->ucode_id != AMDGPU_UCODE_ID_CP_MEC1 &&
 	     ucode->ucode_id != AMDGPU_UCODE_ID_CP_MEC2 &&
 	     ucode->ucode_id != AMDGPU_UCODE_ID_CP_MEC1_JT &&
-	     ucode->ucode_id != AMDGPU_UCODE_ID_CP_MEC2_JT)) {
+	     ucode->ucode_id != AMDGPU_UCODE_ID_CP_MEC2_JT &&
+	     ucode->ucode_id != AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL &&
+	     ucode->ucode_id != AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM &&
+	     ucode->ucode_id != AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM)) {
 		ucode->ucode_size = le32_to_cpu(header->ucode_size_bytes);
 
 		memcpy(ucode->kaddr, (void *)((uint8_t *)ucode->fw->data +
@@ -359,6 +362,18 @@ static int amdgpu_ucode_init_single_fw(struct amdgpu_device *adev,
 					      le32_to_cpu(header->ucode_array_offset_bytes) +
 					      le32_to_cpu(cp_hdr->jt_offset) * 4),
 		       ucode->ucode_size);
+	} else if (ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL) {
+		ucode->ucode_size = adev->gfx.rlc.save_restore_list_cntl_size_bytes;
+		memcpy(ucode->kaddr, adev->gfx.rlc.save_restore_list_cntl,
+		       ucode->ucode_size);
+	} else if (ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM) {
+		ucode->ucode_size = adev->gfx.rlc.save_restore_list_gpm_size_bytes;
+		memcpy(ucode->kaddr, adev->gfx.rlc.save_restore_list_gpm,
+		       ucode->ucode_size);
+	} else if (ucode->ucode_id == AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM) {
+		ucode->ucode_size = adev->gfx.rlc.save_restore_list_srm_size_bytes;
+		memcpy(ucode->kaddr, adev->gfx.rlc.save_restore_list_srm,
+		       ucode->ucode_size);
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
index 0b262f4..08e3857 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
@@ -187,6 +187,9 @@ enum AMDGPU_UCODE_ID {
 	AMDGPU_UCODE_ID_CP_MEC2,
 	AMDGPU_UCODE_ID_CP_MEC2_JT,
 	AMDGPU_UCODE_ID_RLC_G,
+	AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL,
+	AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM,
+	AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM,
 	AMDGPU_UCODE_ID_STORAGE,
 	AMDGPU_UCODE_ID_SMC,
 	AMDGPU_UCODE_ID_UVD,
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 6a19e03..f0ff604 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -41,7 +41,6 @@
 #define GFX9_MEC_HPD_SIZE 2048
 #define RLCG_UCODE_LOADING_START_ADDRESS 0x00002000L
 #define RLC_SAVE_RESTORE_ADDR_STARTING_OFFSET 0x00000000L
-#define GFX9_RLC_FORMAT_DIRECT_REG_LIST_LENGTH 34
 
 #define mmPWR_MISC_CNTL_STATUS					0x0183
 #define mmPWR_MISC_CNTL_STATUS_BASE_IDX				0
@@ -401,6 +400,27 @@ static void gfx_v9_0_free_microcode(struct amdgpu_device *adev)
 	kfree(adev->gfx.rlc.register_list_format);
 }
 
+static void gfx_v9_0_init_rlc_ext_microcode(struct amdgpu_device *adev)
+{
+	const struct rlc_firmware_header_v2_1 *rlc_hdr;
+
+	rlc_hdr = (const struct rlc_firmware_header_v2_1 *)adev->gfx.rlc_fw->data;
+	adev->gfx.rlc_srlc_fw_version = le32_to_cpu(rlc_hdr->save_restore_list_cntl_ucode_ver);
+	adev->gfx.rlc_srlc_feature_version = le32_to_cpu(rlc_hdr->save_restore_list_cntl_feature_ver);
+	adev->gfx.rlc.save_restore_list_cntl_size_bytes = le32_to_cpu(rlc_hdr->save_restore_list_cntl_size_bytes);
+	adev->gfx.rlc.save_restore_list_cntl = (u8 *)rlc_hdr + le32_to_cpu(rlc_hdr->save_restore_list_cntl_offset_bytes);
+	adev->gfx.rlc_srlg_fw_version = le32_to_cpu(rlc_hdr->save_restore_list_gpm_ucode_ver);
+	adev->gfx.rlc_srlg_feature_version = le32_to_cpu(rlc_hdr->save_restore_list_gpm_feature_ver);
+	adev->gfx.rlc.save_restore_list_gpm_size_bytes = le32_to_cpu(rlc_hdr->save_restore_list_gpm_size_bytes);
+	adev->gfx.rlc.save_restore_list_gpm = (u8 *)rlc_hdr + le32_to_cpu(rlc_hdr->save_restore_list_gpm_offset_bytes);
+	adev->gfx.rlc_srls_fw_version = le32_to_cpu(rlc_hdr->save_restore_list_srm_ucode_ver);
+	adev->gfx.rlc_srls_feature_version = le32_to_cpu(rlc_hdr->save_restore_list_srm_feature_ver);
+	adev->gfx.rlc.save_restore_list_srm_size_bytes = le32_to_cpu(rlc_hdr->save_restore_list_srm_size_bytes);
+	adev->gfx.rlc.save_restore_list_srm = (u8 *)rlc_hdr + le32_to_cpu(rlc_hdr->save_restore_list_srm_offset_bytes);
+	adev->gfx.rlc.reg_list_format_direct_reg_list_length =
+			le32_to_cpu(rlc_hdr->reg_list_format_direct_reg_list_length);
+}
+
 static int gfx_v9_0_init_microcode(struct amdgpu_device *adev)
 {
 	const char *chip_name;
@@ -412,6 +432,8 @@ static int gfx_v9_0_init_microcode(struct amdgpu_device *adev)
 	const struct rlc_firmware_header_v2_0 *rlc_hdr;
 	unsigned int *tmp = NULL;
 	unsigned int i = 0;
+	uint16_t version_major;
+	uint16_t version_minor;
 
 	DRM_DEBUG("\n");
 
@@ -468,6 +490,12 @@ static int gfx_v9_0_init_microcode(struct amdgpu_device *adev)
 		goto out;
 	err = amdgpu_ucode_validate(adev->gfx.rlc_fw);
 	rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data;
+
+	version_major = le16_to_cpu(rlc_hdr->header.header_version_major);
+	version_minor = le16_to_cpu(rlc_hdr->header.header_version_minor);
+	if (version_major == 2 && version_minor == 1)
+		adev->gfx.rlc.is_rlc_v2_1 = true;
+
 	adev->gfx.rlc_fw_version = le32_to_cpu(rlc_hdr->header.ucode_version);
 	adev->gfx.rlc_feature_version = le32_to_cpu(rlc_hdr->ucode_feature_version);
 	adev->gfx.rlc.save_and_restore_offset =
@@ -508,6 +536,9 @@ static int gfx_v9_0_init_microcode(struct amdgpu_device *adev)
 	for (i = 0 ; i < (rlc_hdr->reg_list_size_bytes >> 2); i++)
 		adev->gfx.rlc.register_restore[i] = le32_to_cpu(tmp[i]);
 
+	if (adev->gfx.rlc.is_rlc_v2_1)
+		gfx_v9_0_init_rlc_ext_microcode(adev);
+
 	snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", chip_name);
 	err = request_firmware(&adev->gfx.mec_fw, fw_name, adev->dev);
 	if (err)
@@ -566,6 +597,26 @@ static int gfx_v9_0_init_microcode(struct amdgpu_device *adev)
 		adev->firmware.fw_size +=
 			ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
 
+		if (adev->gfx.rlc.is_rlc_v2_1) {
+			info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL];
+			info->ucode_id = AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL;
+			info->fw = adev->gfx.rlc_fw;
+			adev->firmware.fw_size +=
+				ALIGN(adev->gfx.rlc.save_restore_list_cntl_size_bytes, PAGE_SIZE);
+
+			info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM];
+			info->ucode_id = AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM;
+			info->fw = adev->gfx.rlc_fw;
+			adev->firmware.fw_size +=
+				ALIGN(adev->gfx.rlc.save_restore_list_gpm_size_bytes, PAGE_SIZE);
+
+			info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM];
+			info->ucode_id = AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM;
+			info->fw = adev->gfx.rlc_fw;
+			adev->firmware.fw_size +=
+				ALIGN(adev->gfx.rlc.save_restore_list_srm_size_bytes, PAGE_SIZE);
+		}
+
 		info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1];
 		info->ucode_id = AMDGPU_UCODE_ID_CP_MEC1;
 		info->fw = adev->gfx.mec_fw;
@@ -1778,7 +1829,7 @@ static int gfx_v9_0_init_rlc_save_restore_list(struct amdgpu_device *adev)
 
 	/* setup unique_indirect_regs array and indirect_start_offsets array */
 	gfx_v9_0_parse_ind_reg_list(register_list_format,
-				GFX9_RLC_FORMAT_DIRECT_REG_LIST_LENGTH,
+				adev->gfx.rlc.reg_list_format_direct_reg_list_length,
 				adev->gfx.rlc.reg_list_format_size_bytes >> 2,
 				unique_indirect_regs,
 				&unique_indirect_reg_count,
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c
index 8873d83..0ff136d 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c
@@ -70,6 +70,15 @@ psp_v10_0_get_fw_type(struct amdgpu_firmware_info *ucode, enum psp_gfx_fw_type *
 	case AMDGPU_UCODE_ID_RLC_G:
 		*type = GFX_FW_TYPE_RLC_G;
 		break;
+	case AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL:
+		*type = GFX_FW_TYPE_RLC_RESTORE_LIST_CNTL;
+		break;
+	case AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM:
+		*type = GFX_FW_TYPE_RLC_RESTORE_LIST_GPM_MEM;
+		break;
+	case AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM:
+		*type = GFX_FW_TYPE_RLC_RESTORE_LIST_SRM_MEM;
+		break;
 	case AMDGPU_UCODE_ID_SMC:
 		*type = GFX_FW_TYPE_SMU;
 		break;
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index 0087799..2525194 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -623,6 +623,12 @@ struct drm_amdgpu_cs_chunk_data {
 	#define AMDGPU_INFO_FW_ASD		0x0d
 	/* Subquery id: Query VCN firmware version */
 	#define AMDGPU_INFO_FW_VCN		0x0e
+	/* Subquery id: Query GFX RLC SRLC firmware version */
+	#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f
+	/* Subquery id: Query GFX RLC SRLG firmware version */
+	#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x10
+	/* Subquery id: Query GFX RLC SRLS firmware version */
+	#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11
 /* number of bytes moved for TTM migration */
 #define AMDGPU_INFO_NUM_BYTES_MOVED		0x0f
 /* the used VRAM size */
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 04/20] drm/amdgpu: enter rlc safe mode before set cgpg
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (2 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 03/20] drm/amdgpu: add save restore list cntl gpm and srm firmware support Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 05/20] drm/amdgpu: cleanup init power gating function Huang Rui
                     ` (17 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Hawking Zhang <Hawking.Zhang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index f0ff604..537d624 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -3391,8 +3391,7 @@ static void gfx_v9_0_exit_rlc_safe_mode(struct amdgpu_device *adev)
 static void gfx_v9_0_update_gfx_cg_power_gating(struct amdgpu_device *adev,
 						bool enable)
 {
-	/* TODO: double check if we need to perform under safe mdoe */
-	/* gfx_v9_0_enter_rlc_safe_mode(adev); */
+	gfx_v9_0_enter_rlc_safe_mode(adev);
 
 	if ((adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) && enable) {
 		gfx_v9_0_enable_gfx_cg_power_gating(adev, true);
@@ -3403,7 +3402,7 @@ static void gfx_v9_0_update_gfx_cg_power_gating(struct amdgpu_device *adev,
 		gfx_v9_0_enable_gfx_pipeline_powergating(adev, false);
 	}
 
-	/* gfx_v9_0_exit_rlc_safe_mode(adev); */
+	gfx_v9_0_exit_rlc_safe_mode(adev);
 }
 
 static void gfx_v9_0_update_gfx_mg_power_gating(struct amdgpu_device *adev,
@@ -3794,7 +3793,7 @@ static void gfx_v9_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
 	}
 
 	amdgpu_ring_write(ring, header);
-BUG_ON(ib->gpu_addr & 0x3); /* Dword align */
+	BUG_ON(ib->gpu_addr & 0x3); /* Dword align */
 	amdgpu_ring_write(ring,
 #ifdef __BIG_ENDIAN
 		(2 << 0) |
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 05/20] drm/amdgpu: cleanup init power gating function
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (3 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 04/20] drm/amdgpu: enter rlc safe mode before set cgpg Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 06/20] drm/amdgpu: revise init_rlc_save_restore_list behavior to support latest register_list_format/register_restore table Huang Rui
                     ` (16 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Remove gfx_v9_0_enable_sck_slow_down_on_power_up/down and CP power gating
enabling functions because they only need to be called on setting power gating
behavior. We keep it in set_powergating callback to enable/disable PG in
late_init.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Hawking Zhang <Hawking.Zhang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 537d624..6387fda 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -2062,6 +2062,9 @@ static void gfx_v9_0_enable_gfx_dynamic_mg_power_gating(struct amdgpu_device *ad
 
 static void gfx_v9_0_init_pg(struct amdgpu_device *adev)
 {
+	if (!adev->gfx.rlc.is_rlc_v2_1)
+		return;
+
 	if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG |
 			      AMD_PG_SUPPORT_GFX_SMG |
 			      AMD_PG_SUPPORT_GFX_DMG |
@@ -2072,24 +2075,9 @@ static void gfx_v9_0_init_pg(struct amdgpu_device *adev)
 		gfx_v9_0_init_rlc_save_restore_list(adev);
 		gfx_v9_0_enable_save_restore_machine(adev);
 
-		if (adev->asic_type == CHIP_RAVEN) {
-			WREG32(mmRLC_JUMP_TABLE_RESTORE,
-				adev->gfx.rlc.cp_table_gpu_addr >> 8);
-			gfx_v9_0_init_gfx_power_gating(adev);
-
-			if (adev->pg_flags & AMD_PG_SUPPORT_RLC_SMU_HS) {
-				gfx_v9_0_enable_sck_slow_down_on_power_up(adev, true);
-				gfx_v9_0_enable_sck_slow_down_on_power_down(adev, true);
-			} else {
-				gfx_v9_0_enable_sck_slow_down_on_power_up(adev, false);
-				gfx_v9_0_enable_sck_slow_down_on_power_down(adev, false);
-			}
-
-			if (adev->pg_flags & AMD_PG_SUPPORT_CP)
-				gfx_v9_0_enable_cp_power_gating(adev, true);
-			else
-				gfx_v9_0_enable_cp_power_gating(adev, false);
-		}
+		WREG32(mmRLC_JUMP_TABLE_RESTORE,
+		       adev->gfx.rlc.cp_table_gpu_addr >> 8);
+		gfx_v9_0_init_gfx_power_gating(adev);
 	}
 }
 
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 06/20] drm/amdgpu: revise init_rlc_save_restore_list behavior to support latest register_list_format/register_restore table
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (4 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 05/20] drm/amdgpu: cleanup init power gating function Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 07/20] drm/amdgpu: add setting powergating method for gfx9 Huang Rui
                     ` (15 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

RLC save/restore list will be used on CGPG and GFXOFF function, it loads two bin
table of register_list_format/register_restore in RLC firmware.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Hawking Zhang <Hawking.Zhang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 141 +++++++++++++++++++++-------------
 1 file changed, 87 insertions(+), 54 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 6387fda..5e3ddd5 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -184,6 +184,30 @@ static const struct soc15_reg_golden golden_settings_gc_9_2_1_vg12[] =
 	SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x01bd9f33, 0x01000000)
 };
 
+static const u32 GFX_RLC_SRM_INDEX_CNTL_ADDR_OFFSETS[] =
+{
+	mmRLC_SRM_INDEX_CNTL_ADDR_0 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
+	mmRLC_SRM_INDEX_CNTL_ADDR_1 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
+	mmRLC_SRM_INDEX_CNTL_ADDR_2 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
+	mmRLC_SRM_INDEX_CNTL_ADDR_3 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
+	mmRLC_SRM_INDEX_CNTL_ADDR_4 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
+	mmRLC_SRM_INDEX_CNTL_ADDR_5 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
+	mmRLC_SRM_INDEX_CNTL_ADDR_6 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
+	mmRLC_SRM_INDEX_CNTL_ADDR_7 - mmRLC_SRM_INDEX_CNTL_ADDR_0,
+};
+
+static const u32 GFX_RLC_SRM_INDEX_CNTL_DATA_OFFSETS[] =
+{
+	mmRLC_SRM_INDEX_CNTL_DATA_0 - mmRLC_SRM_INDEX_CNTL_DATA_0,
+	mmRLC_SRM_INDEX_CNTL_DATA_1 - mmRLC_SRM_INDEX_CNTL_DATA_0,
+	mmRLC_SRM_INDEX_CNTL_DATA_2 - mmRLC_SRM_INDEX_CNTL_DATA_0,
+	mmRLC_SRM_INDEX_CNTL_DATA_3 - mmRLC_SRM_INDEX_CNTL_DATA_0,
+	mmRLC_SRM_INDEX_CNTL_DATA_4 - mmRLC_SRM_INDEX_CNTL_DATA_0,
+	mmRLC_SRM_INDEX_CNTL_DATA_5 - mmRLC_SRM_INDEX_CNTL_DATA_0,
+	mmRLC_SRM_INDEX_CNTL_DATA_6 - mmRLC_SRM_INDEX_CNTL_DATA_0,
+	mmRLC_SRM_INDEX_CNTL_DATA_7 - mmRLC_SRM_INDEX_CNTL_DATA_0,
+};
+
 #define VEGA10_GB_ADDR_CONFIG_GOLDEN 0x2a114042
 #define VEGA12_GB_ADDR_CONFIG_GOLDEN 0x24104041
 #define RAVEN_GB_ADDR_CONFIG_GOLDEN 0x24000042
@@ -1760,55 +1784,42 @@ static void gfx_v9_0_init_csb(struct amdgpu_device *adev)
 			adev->gfx.rlc.clear_state_size);
 }
 
-static void gfx_v9_0_parse_ind_reg_list(int *register_list_format,
+static void gfx_v9_1_parse_ind_reg_list(int *register_list_format,
 				int indirect_offset,
 				int list_size,
 				int *unique_indirect_regs,
 				int *unique_indirect_reg_count,
-				int max_indirect_reg_count,
 				int *indirect_start_offsets,
-				int *indirect_start_offsets_count,
-				int max_indirect_start_offsets_count)
+				int *indirect_start_offsets_count)
 {
 	int idx;
-	bool new_entry = true;
 
 	for (; indirect_offset < list_size; indirect_offset++) {
+		indirect_start_offsets[*indirect_start_offsets_count] = indirect_offset;
+		*indirect_start_offsets_count = *indirect_start_offsets_count + 1;
 
-		if (new_entry) {
-			new_entry = false;
-			indirect_start_offsets[*indirect_start_offsets_count] = indirect_offset;
-			*indirect_start_offsets_count = *indirect_start_offsets_count + 1;
-			BUG_ON(*indirect_start_offsets_count >= max_indirect_start_offsets_count);
-		}
+		while (register_list_format[indirect_offset] != 0xFFFFFFFF) {
+			indirect_offset += 2;
 
-		if (register_list_format[indirect_offset] == 0xFFFFFFFF) {
-			new_entry = true;
-			continue;
-		}
+			/* look for the matching indice */
+			for (idx = 0; idx < *unique_indirect_reg_count; idx++) {
+				if (unique_indirect_regs[idx] ==
+					register_list_format[indirect_offset] ||
+					!unique_indirect_regs[idx])
+					break;
+			}
 
-		indirect_offset += 2;
+			BUG_ON(idx >= *unique_indirect_reg_count);
 
-		/* look for the matching indice */
-		for (idx = 0; idx < *unique_indirect_reg_count; idx++) {
-			if (unique_indirect_regs[idx] ==
-				register_list_format[indirect_offset])
-				break;
-		}
+			if (!unique_indirect_regs[idx])
+				unique_indirect_regs[idx] = register_list_format[indirect_offset];
 
-		if (idx >= *unique_indirect_reg_count) {
-			unique_indirect_regs[*unique_indirect_reg_count] =
-				register_list_format[indirect_offset];
-			idx = *unique_indirect_reg_count;
-			*unique_indirect_reg_count = *unique_indirect_reg_count + 1;
-			BUG_ON(*unique_indirect_reg_count >= max_indirect_reg_count);
+			indirect_offset++;
 		}
-
-		register_list_format[indirect_offset] = idx;
 	}
 }
 
-static int gfx_v9_0_init_rlc_save_restore_list(struct amdgpu_device *adev)
+static int gfx_v9_1_init_rlc_save_restore_list(struct amdgpu_device *adev)
 {
 	int unique_indirect_regs[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
 	int unique_indirect_reg_count = 0;
@@ -1817,7 +1828,7 @@ static int gfx_v9_0_init_rlc_save_restore_list(struct amdgpu_device *adev)
 	int indirect_start_offsets_count = 0;
 
 	int list_size = 0;
-	int i = 0;
+	int i = 0, j = 0;
 	u32 tmp = 0;
 
 	u32 *register_list_format =
@@ -1828,15 +1839,14 @@ static int gfx_v9_0_init_rlc_save_restore_list(struct amdgpu_device *adev)
 		adev->gfx.rlc.reg_list_format_size_bytes);
 
 	/* setup unique_indirect_regs array and indirect_start_offsets array */
-	gfx_v9_0_parse_ind_reg_list(register_list_format,
-				adev->gfx.rlc.reg_list_format_direct_reg_list_length,
-				adev->gfx.rlc.reg_list_format_size_bytes >> 2,
-				unique_indirect_regs,
-				&unique_indirect_reg_count,
-				ARRAY_SIZE(unique_indirect_regs),
-				indirect_start_offsets,
-				&indirect_start_offsets_count,
-				ARRAY_SIZE(indirect_start_offsets));
+	unique_indirect_reg_count = ARRAY_SIZE(unique_indirect_regs);
+	gfx_v9_1_parse_ind_reg_list(register_list_format,
+				    adev->gfx.rlc.reg_list_format_direct_reg_list_length,
+				    adev->gfx.rlc.reg_list_format_size_bytes >> 2,
+				    unique_indirect_regs,
+				    &unique_indirect_reg_count,
+				    indirect_start_offsets,
+				    &indirect_start_offsets_count);
 
 	/* enable auto inc in case it is disabled */
 	tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_CNTL));
@@ -1850,19 +1860,37 @@ static int gfx_v9_0_init_rlc_save_restore_list(struct amdgpu_device *adev)
 		WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_ARAM_DATA),
 			adev->gfx.rlc.register_restore[i]);
 
-	/* load direct register */
-	WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_ARAM_ADDR), 0);
-	for (i = 0; i < adev->gfx.rlc.reg_list_size_bytes >> 2; i++)
-		WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_ARAM_DATA),
-			adev->gfx.rlc.register_restore[i]);
-
 	/* load indirect register */
 	WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_SCRATCH_ADDR),
 		adev->gfx.rlc.reg_list_format_start);
-	for (i = 0; i < adev->gfx.rlc.reg_list_format_size_bytes >> 2; i++)
+
+	/* direct register portion */
+	for (i = 0; i < adev->gfx.rlc.reg_list_format_direct_reg_list_length; i++)
 		WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_SCRATCH_DATA),
 			register_list_format[i]);
 
+	/* indirect register portion */
+	while (i < (adev->gfx.rlc.reg_list_format_size_bytes >> 2)) {
+		if (register_list_format[i] == 0xFFFFFFFF) {
+			WREG32_SOC15(GC, 0, mmRLC_GPM_SCRATCH_DATA, register_list_format[i++]);
+			continue;
+		}
+
+		WREG32_SOC15(GC, 0, mmRLC_GPM_SCRATCH_DATA, register_list_format[i++]);
+		WREG32_SOC15(GC, 0, mmRLC_GPM_SCRATCH_DATA, register_list_format[i++]);
+
+		for (j = 0; j < unique_indirect_reg_count; j++) {
+			if (register_list_format[i] == unique_indirect_regs[j]) {
+				WREG32_SOC15(GC, 0, mmRLC_GPM_SCRATCH_DATA, j);
+				break;
+			}
+		}
+
+		BUG_ON(j >= unique_indirect_reg_count);
+
+		i++;
+	}
+
 	/* set save/restore list size */
 	list_size = adev->gfx.rlc.reg_list_size_bytes >> 2;
 	list_size = list_size >> 1;
@@ -1875,14 +1903,19 @@ static int gfx_v9_0_init_rlc_save_restore_list(struct amdgpu_device *adev)
 		adev->gfx.rlc.starting_offsets_start);
 	for (i = 0; i < ARRAY_SIZE(indirect_start_offsets); i++)
 		WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_SCRATCH_DATA),
-			indirect_start_offsets[i]);
+		       indirect_start_offsets[i]);
 
 	/* load unique indirect regs*/
 	for (i = 0; i < ARRAY_SIZE(unique_indirect_regs); i++) {
-		WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_INDEX_CNTL_ADDR_0) + i,
-			unique_indirect_regs[i] & 0x3FFFF);
-		WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_INDEX_CNTL_DATA_0) + i,
-			unique_indirect_regs[i] >> 20);
+		if (unique_indirect_regs[i] != 0) {
+			WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_INDEX_CNTL_ADDR_0)
+			       + GFX_RLC_SRM_INDEX_CNTL_ADDR_OFFSETS[i],
+			       unique_indirect_regs[i] & 0x3FFFF);
+
+			WREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_INDEX_CNTL_DATA_0)
+			       + GFX_RLC_SRM_INDEX_CNTL_DATA_OFFSETS[i],
+			       unique_indirect_regs[i] >> 20);
+		}
 	}
 
 	kfree(register_list_format);
@@ -2072,7 +2105,7 @@ static void gfx_v9_0_init_pg(struct amdgpu_device *adev)
 			      AMD_PG_SUPPORT_GDS |
 			      AMD_PG_SUPPORT_RLC_SMU_HS)) {
 		gfx_v9_0_init_csb(adev);
-		gfx_v9_0_init_rlc_save_restore_list(adev);
+		gfx_v9_1_init_rlc_save_restore_list(adev);
 		gfx_v9_0_enable_save_restore_machine(adev);
 
 		WREG32(mmRLC_JUMP_TABLE_RESTORE,
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 07/20] drm/amdgpu: add setting powergating method for gfx9
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (5 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 06/20] drm/amdgpu: revise init_rlc_save_restore_list behavior to support latest register_list_format/register_restore table Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 08/20] drm/amd/powerplay: send CGPG smc message if PG is enabled for raven Huang Rui
                     ` (14 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Hawking Zhang <Hawking.Zhang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 5e3ddd5..20c57ac 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -3352,6 +3352,11 @@ static int gfx_v9_0_late_init(void *handle)
 	if (r)
 		return r;
 
+	r = amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
+						   AMD_PG_STATE_GATE);
+	if (r)
+		return r;
+
 	return 0;
 }
 
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 08/20] drm/amd/powerplay: send CGPG smc message if PG is enabled for raven
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (6 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 07/20] drm/amdgpu: add setting powergating method for gfx9 Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 09/20] drm/amdgpu: move PP_FEATURE_MASK to amd_shared header Huang Rui
                     ` (13 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Hawking Zhang <Hawking.Zhang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | 8 +++++++-
 drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h      | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
index 0f25226..f0727b4 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
@@ -206,12 +206,18 @@ static int smu10_set_power_state_tasks(struct pp_hwmgr *hwmgr, const void *input
 static int smu10_init_power_gate_state(struct pp_hwmgr *hwmgr)
 {
 	struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
+	struct amdgpu_device *adev = hwmgr->adev;
 
 	smu10_data->vcn_power_gated = true;
 	smu10_data->isp_tileA_power_gated = true;
 	smu10_data->isp_tileB_power_gated = true;
 
-	return 0;
+	if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG)
+		return smum_send_msg_to_smc_with_parameter(hwmgr,
+							   PPSMC_MSG_SetGfxCGPG,
+							   true);
+	else
+		return 0;
 }
 
 
diff --git a/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h b/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h
index 426bff2..5d07b6e 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h
@@ -75,6 +75,7 @@
 #define PPSMC_MSG_GetMinGfxclkFrequency         0x2C
 #define PPSMC_MSG_GetMaxGfxclkFrequency         0x2D
 #define PPSMC_MSG_SoftReset                     0x2E
+#define PPSMC_MSG_SetGfxCGPG			0x2F
 #define PPSMC_MSG_SetSoftMaxGfxClk              0x30
 #define PPSMC_MSG_SetHardMinGfxClk              0x31
 #define PPSMC_MSG_SetSoftMaxSocclkByFreq        0x32
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 09/20] drm/amdgpu: move PP_FEATURE_MASK to amd_shared header
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (7 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 08/20] drm/amd/powerplay: send CGPG smc message if PG is enabled for raven Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 10/20] drm/amdgpu: add gfxoff feature mask Huang Rui
                     ` (12 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

It will be used not only for powerplay but also on amdgpu part in future
patches. So move it into amd_shared header file.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h   |  2 --
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c       |  2 +-
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c       |  2 +-
 drivers/gpu/drm/amd/include/amd_shared.h  | 18 ++++++++++++++++++
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 18 ------------------
 5 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
index 354c6dc..dd6203a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
@@ -52,8 +52,6 @@ enum amdgpu_dpm_event_src {
 	AMDGPU_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL = 4
 };
 
-#define SCLK_DEEP_SLEEP_MASK 0x8
-
 struct amdgpu_ps {
 	u32 caps; /* vbios flags */
 	u32 class; /* vbios flags */
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
index be6b199..f48168f 100644
--- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
@@ -5903,7 +5903,7 @@ static int ci_dpm_init(struct amdgpu_device *adev)
 	pi->pcie_dpm_key_disabled = 0;
 	pi->thermal_sclk_dpm_enabled = 0;
 
-	if (amdgpu_pp_feature_mask & SCLK_DEEP_SLEEP_MASK)
+	if (amdgpu_pp_feature_mask & PP_SCLK_DEEP_SLEEP_MASK)
 		pi->caps_sclk_ds = true;
 	else
 		pi->caps_sclk_ds = false;
diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
index bc1720e..ef668a3 100644
--- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
@@ -2817,7 +2817,7 @@ static int kv_dpm_init(struct amdgpu_device *adev)
 		pi->caps_tcp_ramping = true;
 	}
 
-	if (amdgpu_pp_feature_mask & SCLK_DEEP_SLEEP_MASK)
+	if (amdgpu_pp_feature_mask & PP_SCLK_DEEP_SLEEP_MASK)
 		pi->caps_sclk_ds = true;
 	else
 		pi->caps_sclk_ds = false;
diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
index 9fa3aae..a63e8da 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -109,6 +109,24 @@ enum amd_powergating_state {
 #define AMD_PG_SUPPORT_GFX_PIPELINE		(1 << 12)
 #define AMD_PG_SUPPORT_MMHUB			(1 << 13)
 
+enum PP_FEATURE_MASK {
+	PP_SCLK_DPM_MASK = 0x1,
+	PP_MCLK_DPM_MASK = 0x2,
+	PP_PCIE_DPM_MASK = 0x4,
+	PP_SCLK_DEEP_SLEEP_MASK = 0x8,
+	PP_POWER_CONTAINMENT_MASK = 0x10,
+	PP_UVD_HANDSHAKE_MASK = 0x20,
+	PP_SMC_VOLTAGE_CONTROL_MASK = 0x40,
+	PP_VBI_TIME_SUPPORT_MASK = 0x80,
+	PP_ULV_MASK = 0x100,
+	PP_ENABLE_GFX_CG_THRU_SMU = 0x200,
+	PP_CLOCK_STRETCH_MASK = 0x400,
+	PP_OD_FUZZY_FAN_CONTROL_MASK = 0x800,
+	PP_SOCCLK_DPM_MASK = 0x1000,
+	PP_DCEFCLK_DPM_MASK = 0x2000,
+	PP_OVERDRIVE_MASK = 0x4000,
+};
+
 struct amd_ip_funcs {
 	/* Name of IP block */
 	char *name;
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index 9b3dd7d..0d2b3ce 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -66,24 +66,6 @@ struct vi_dpm_table {
 #define PCIE_PERF_REQ_GEN2         3
 #define PCIE_PERF_REQ_GEN3         4
 
-enum PP_FEATURE_MASK {
-	PP_SCLK_DPM_MASK = 0x1,
-	PP_MCLK_DPM_MASK = 0x2,
-	PP_PCIE_DPM_MASK = 0x4,
-	PP_SCLK_DEEP_SLEEP_MASK = 0x8,
-	PP_POWER_CONTAINMENT_MASK = 0x10,
-	PP_UVD_HANDSHAKE_MASK = 0x20,
-	PP_SMC_VOLTAGE_CONTROL_MASK = 0x40,
-	PP_VBI_TIME_SUPPORT_MASK = 0x80,
-	PP_ULV_MASK = 0x100,
-	PP_ENABLE_GFX_CG_THRU_SMU = 0x200,
-	PP_CLOCK_STRETCH_MASK = 0x400,
-	PP_OD_FUZZY_FAN_CONTROL_MASK = 0x800,
-	PP_SOCCLK_DPM_MASK = 0x1000,
-	PP_DCEFCLK_DPM_MASK = 0x2000,
-	PP_OVERDRIVE_MASK = 0x4000,
-};
-
 enum PHM_BackEnd_Magic {
 	PHM_Dummy_Magic       = 0xAA5555AA,
 	PHM_RV770_Magic       = 0xDCBAABCD,
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 10/20] drm/amdgpu: add gfxoff feature mask
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (8 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 09/20] drm/amdgpu: move PP_FEATURE_MASK to amd_shared header Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 11/20] drm/amdgpu: set gfxoff disabled by default Huang Rui
                     ` (11 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/include/amd_shared.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
index a63e8da..850e8ef 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -125,6 +125,7 @@ enum PP_FEATURE_MASK {
 	PP_SOCCLK_DPM_MASK = 0x1000,
 	PP_DCEFCLK_DPM_MASK = 0x2000,
 	PP_OVERDRIVE_MASK = 0x4000,
+	PP_GFXOFF_MASK = 0x8000,
 };
 
 struct amd_ip_funcs {
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 11/20] drm/amdgpu: set gfxoff disabled by default
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (9 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 10/20] drm/amdgpu: add gfxoff feature mask Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 12/20] drm/amd/powerplay: add gfx off control function Huang Rui
                     ` (10 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 5c0567a..3e07bd4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -121,7 +121,7 @@ uint amdgpu_pg_mask = 0xffffffff;
 uint amdgpu_sdma_phase_quantum = 32;
 char *amdgpu_disable_cu = NULL;
 char *amdgpu_virtual_display = NULL;
-uint amdgpu_pp_feature_mask = 0xffffbfff;
+uint amdgpu_pp_feature_mask = 0xffff3fff; /* gfxoff (bit 15) disabled by default */
 int amdgpu_ngg = 0;
 int amdgpu_prim_buf_per_se = 0;
 int amdgpu_pos_buf_per_se = 0;
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 12/20] drm/amd/powerplay: add gfx off control function
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (10 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 11/20] drm/amdgpu: set gfxoff disabled by default Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 13/20] drm/amd/powerplay: enable/disable gfxoff through smu Huang Rui
                     ` (9 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

gfx_off_control is used to be called for sending enabling/disabling gfxoff
message.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | 36 ++++++++++++++++++++++-
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h         |  1 +
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
index f0727b4..fde1e5c 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
@@ -42,6 +42,13 @@
 #define SMU10_DISPCLK_BYPASS_THRESHOLD     10000 /* 100Mhz */
 #define SMC_RAM_END                     0x40000
 
+#define mmPWR_MISC_CNTL_STATUS					0x0183
+#define mmPWR_MISC_CNTL_STATUS_BASE_IDX				0
+#define PWR_MISC_CNTL_STATUS__PWR_GFX_RLC_CGPG_EN__SHIFT	0x0
+#define PWR_MISC_CNTL_STATUS__PWR_GFXOFF_STATUS__SHIFT		0x1
+#define PWR_MISC_CNTL_STATUS__PWR_GFX_RLC_CGPG_EN_MASK		0x00000001L
+#define PWR_MISC_CNTL_STATUS__PWR_GFXOFF_STATUS_MASK		0x00000006L
+
 static const unsigned long SMU10_Magic = (unsigned long) PHM_Rv_Magic;
 
 
@@ -243,13 +250,31 @@ static int smu10_power_off_asic(struct pp_hwmgr *hwmgr)
 	return smu10_reset_cc6_data(hwmgr);
 }
 
+static bool smu10_is_gfx_on(struct pp_hwmgr *hwmgr)
+{
+	uint32_t reg;
+	struct amdgpu_device *adev = hwmgr->adev;
+
+	reg = RREG32_SOC15(PWR, 0, mmPWR_MISC_CNTL_STATUS);
+	if ((reg & PWR_MISC_CNTL_STATUS__PWR_GFXOFF_STATUS_MASK) ==
+	    (0x2 << PWR_MISC_CNTL_STATUS__PWR_GFXOFF_STATUS__SHIFT))
+		return true;
+
+	return false;
+}
+
 static int smu10_disable_gfx_off(struct pp_hwmgr *hwmgr)
 {
 	struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
 
-	if (smu10_data->gfx_off_controled_by_driver)
+	if (smu10_data->gfx_off_controled_by_driver) {
 		smum_send_msg_to_smc(hwmgr, PPSMC_MSG_DisableGfxOff);
 
+		/* confirm gfx is back to "on" state */
+		while (!smu10_is_gfx_on(hwmgr))
+			msleep(1);
+	}
+
 	return 0;
 }
 
@@ -273,6 +298,14 @@ static int smu10_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
 	return smu10_enable_gfx_off(hwmgr);
 }
 
+static int smu10_gfx_off_control(struct pp_hwmgr *hwmgr, bool enable)
+{
+	if (enable)
+		return smu10_enable_gfx_off(hwmgr);
+	else
+		return smu10_disable_gfx_off(hwmgr);
+}
+
 static int smu10_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,
 				struct pp_power_state  *prequest_ps,
 			const struct pp_power_state *pcurrent_ps)
@@ -1060,6 +1093,7 @@ static const struct pp_hwmgr_func smu10_hwmgr_funcs = {
 	.power_state_set = smu10_set_power_state_tasks,
 	.dynamic_state_management_disable = smu10_disable_dpm_tasks,
 	.set_mmhub_powergating_by_smu = smu10_set_mmhub_powergating_by_smu,
+	.gfx_off_control = smu10_gfx_off_control,
 };
 
 int smu10_init_function_pointers(struct pp_hwmgr *hwmgr)
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index 0d2b3ce..3d9743f 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -296,6 +296,7 @@ struct pp_hwmgr_func {
 	int (*display_clock_voltage_request)(struct pp_hwmgr *hwmgr,
 			struct pp_display_clock_request *clock);
 	int (*get_max_high_clocks)(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks);
+	int (*gfx_off_control)(struct pp_hwmgr *hwmgr, bool enable);
 	int (*power_off_asic)(struct pp_hwmgr *hwmgr);
 	int (*force_clock_level)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, uint32_t mask);
 	int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf);
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 13/20] drm/amd/powerplay: enable/disable gfxoff through smu
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (11 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 12/20] drm/amd/powerplay: add gfx off control function Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 14/20] drm/amdgpu: use pp_feature member to store the mask Huang Rui
                     ` (8 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index bd0d387..6976596 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -222,10 +222,19 @@ static int pp_set_powergating_state(void *handle,
 {
 	struct amdgpu_device *adev = handle;
 	struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
+	int ret;
 
 	if (!hwmgr || !hwmgr->pm_en)
 		return 0;
 
+	if (hwmgr->hwmgr_func->gfx_off_control) {
+		/* Enable/disable GFX off through SMU */
+		ret = hwmgr->hwmgr_func->gfx_off_control(hwmgr,
+							 state == AMD_PG_STATE_GATE);
+		if (ret)
+			pr_err("gfx off control failed!\n");
+	}
+
 	if (hwmgr->hwmgr_func->enable_per_cu_power_gating == NULL) {
 		pr_info("%s was not implemented.\n", __func__);
 		return 0;
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 14/20] drm/amdgpu: use pp_feature member to store the mask
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (12 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 13/20] drm/amd/powerplay: enable/disable gfxoff through smu Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 15/20] drm/amdgpu: clear gfxoff featue mask if the asic is not raven Huang Rui
                     ` (7 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    | 2 ++
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c           | 2 +-
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c           | 2 +-
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 2 +-
 5 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index bed1f5d..59df4b7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1433,6 +1433,7 @@ enum amd_hw_ip_block_type {
 struct amd_powerplay {
 	void *pp_handle;
 	const struct amd_pm_funcs *pp_funcs;
+	uint32_t pp_feature;
 };
 
 #define AMDGPU_RESET_MAGIC_NUM 64
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 6f1a8b7..8e63832 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1545,6 +1545,8 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)
 			return -EAGAIN;
 	}
 
+	adev->powerplay.pp_feature = amdgpu_pp_feature_mask;
+
 	for (i = 0; i < adev->num_ip_blocks; i++) {
 		if ((amdgpu_ip_block_mask & (1 << i)) == 0) {
 			DRM_ERROR("disabled ip block: %d <%s>\n",
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
index f48168f..a266dcf 100644
--- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
@@ -5903,7 +5903,7 @@ static int ci_dpm_init(struct amdgpu_device *adev)
 	pi->pcie_dpm_key_disabled = 0;
 	pi->thermal_sclk_dpm_enabled = 0;
 
-	if (amdgpu_pp_feature_mask & PP_SCLK_DEEP_SLEEP_MASK)
+	if (adev->powerplay.pp_feature & PP_SCLK_DEEP_SLEEP_MASK)
 		pi->caps_sclk_ds = true;
 	else
 		pi->caps_sclk_ds = false;
diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
index ef668a3..17f7f07 100644
--- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
@@ -2817,7 +2817,7 @@ static int kv_dpm_init(struct amdgpu_device *adev)
 		pi->caps_tcp_ramping = true;
 	}
 
-	if (amdgpu_pp_feature_mask & PP_SCLK_DEEP_SLEEP_MASK)
+	if (adev->powerplay.pp_feature & PP_SCLK_DEEP_SLEEP_MASK)
 		pi->caps_sclk_ds = true;
 	else
 		pi->caps_sclk_ds = false;
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index 6976596..246f8e9 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -53,7 +53,7 @@ static int amd_powerplay_create(struct amdgpu_device *adev)
 	mutex_init(&hwmgr->smu_lock);
 	hwmgr->chip_family = adev->family;
 	hwmgr->chip_id = adev->asic_type;
-	hwmgr->feature_mask = amdgpu_pp_feature_mask;
+	hwmgr->feature_mask = adev->powerplay.pp_feature;
 	hwmgr->display_config = &adev->pm.pm_display_cfg;
 	adev->powerplay.pp_handle = hwmgr;
 	adev->powerplay.pp_funcs = &pp_dpm_funcs;
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 15/20] drm/amdgpu: clear gfxoff featue mask if the asic is not raven
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (13 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 14/20] drm/amdgpu: use pp_feature member to store the mask Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 16/20] drm/amd/powerplay: add control gfxoff enabling in late init Huang Rui
                     ` (6 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
index bca67df..d1052b5 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
@@ -95,7 +95,8 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr)
 		hwmgr->smumgr_funcs = &ci_smu_funcs;
 		ci_set_asic_special_caps(hwmgr);
 		hwmgr->feature_mask &= ~(PP_VBI_TIME_SUPPORT_MASK |
-					PP_ENABLE_GFX_CG_THRU_SMU);
+					 PP_ENABLE_GFX_CG_THRU_SMU |
+					 PP_GFXOFF_MASK);
 		hwmgr->pp_table_version = PP_TABLE_V0;
 		hwmgr->od_enabled = false;
 		smu7_init_function_pointers(hwmgr);
@@ -103,9 +104,11 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr)
 	case AMDGPU_FAMILY_CZ:
 		hwmgr->od_enabled = false;
 		hwmgr->smumgr_funcs = &smu8_smu_funcs;
+		hwmgr->feature_mask &= ~PP_GFXOFF_MASK;
 		smu8_init_function_pointers(hwmgr);
 		break;
 	case AMDGPU_FAMILY_VI:
+		hwmgr->feature_mask &= ~PP_GFXOFF_MASK;
 		switch (hwmgr->chip_id) {
 		case CHIP_TOPAZ:
 			hwmgr->smumgr_funcs = &iceland_smu_funcs;
@@ -139,6 +142,7 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr)
 		smu7_init_function_pointers(hwmgr);
 		break;
 	case AMDGPU_FAMILY_AI:
+		hwmgr->feature_mask &= ~PP_GFXOFF_MASK;
 		switch (hwmgr->chip_id) {
 		case CHIP_VEGA10:
 			hwmgr->smumgr_funcs = &vega10_smu_funcs;
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 16/20] drm/amd/powerplay: add control gfxoff enabling in late init
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (14 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 15/20] drm/amdgpu: clear gfxoff featue mask if the asic is not raven Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 17/20] drm/amdgpu: it should disable gfxoff when system is going to suspend Huang Rui
                     ` (5 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index 246f8e9..b493369 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -180,6 +180,7 @@ static int pp_late_init(void *handle)
 {
 	struct amdgpu_device *adev = handle;
 	struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
+	int ret;
 
 	if (hwmgr && hwmgr->pm_en) {
 		mutex_lock(&hwmgr->smu_lock);
@@ -189,6 +190,14 @@ static int pp_late_init(void *handle)
 	}
 	if (adev->pm.smu_prv_buffer_size != 0)
 		pp_reserve_vram_for_smu(adev);
+
+	if (hwmgr->hwmgr_func->gfx_off_control &&
+	    (hwmgr->feature_mask & PP_GFXOFF_MASK)) {
+		ret = hwmgr->hwmgr_func->gfx_off_control(hwmgr, true);
+		if (ret)
+			pr_err("gfx off enabling failed!\n");
+	}
+
 	return 0;
 }
 
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 17/20] drm/amdgpu: it should disable gfxoff when system is going to suspend
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (15 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 16/20] drm/amd/powerplay: add control gfxoff enabling in late init Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 18/20] drm/amdgpu: fix to disable powergating in hw_fini Huang Rui
                     ` (4 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 8e63832..f509d32 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1902,6 +1902,12 @@ int amdgpu_device_ip_suspend(struct amdgpu_device *adev)
 	if (amdgpu_sriov_vf(adev))
 		amdgpu_virt_request_full_gpu(adev, false);
 
+	/* ungate SMC block powergating */
+	if (adev->powerplay.pp_feature & PP_GFXOFF_MASK)
+		amdgpu_device_ip_set_powergating_state(adev,
+						       AMD_IP_BLOCK_TYPE_SMC,
+						       AMD_CG_STATE_UNGATE);
+
 	/* ungate SMC block first */
 	r = amdgpu_device_ip_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_SMC,
 						   AMD_CG_STATE_UNGATE);
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 18/20] drm/amdgpu: fix to disable powergating in hw_fini
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (16 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 17/20] drm/amdgpu: it should disable gfxoff when system is going to suspend Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 19/20] drm/amdgpu: set CGPG if gfxoff is enabled for raven Huang Rui
                     ` (3 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

We need enable CGPG and GFXOFF together. If only enable one of them, this system
will get hang after startx (do draw command). So when gfxoff is disabled, it
also need disable CGPG after that.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 20c57ac..d4da610 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -3134,6 +3134,9 @@ static int gfx_v9_0_hw_fini(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	int i;
 
+	amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
+					       AMD_PG_STATE_UNGATE);
+
 	amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0);
 	amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0);
 
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 19/20] drm/amdgpu: set CGPG if gfxoff is enabled for raven
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (17 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 18/20] drm/amdgpu: fix to disable powergating in hw_fini Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  0:22   ` [PATCH 20/20] drm/amd/powerplay: use the flag to decide whether send gfxoff smc message Huang Rui
                     ` (2 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
index 65e781f..9006576 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -682,6 +682,11 @@ static int soc15_common_early_init(void *handle)
 			AMD_CG_SUPPORT_SDMA_LS;
 		adev->pg_flags = AMD_PG_SUPPORT_SDMA;
 
+		if (adev->powerplay.pp_feature & PP_GFXOFF_MASK)
+			adev->pg_flags |= AMD_PG_SUPPORT_GFX_PG |
+				AMD_PG_SUPPORT_CP |
+				AMD_PG_SUPPORT_RLC_SMU_HS;
+
 		adev->external_rev_id = 0x1;
 		break;
 	default:
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 20/20] drm/amd/powerplay: use the flag to decide whether send gfxoff smc message
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (18 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 19/20] drm/amdgpu: set CGPG if gfxoff is enabled for raven Huang Rui
@ 2018-04-19  0:22   ` Huang Rui
  2018-04-19  7:25   ` [PATCH 00/20] drm/amdgpu: gfx off support Christian König
  2018-04-19 13:51   ` Alex Deucher
  21 siblings, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-19  0:22 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Huang Rui

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
index fde1e5c..7712eb6 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
@@ -81,11 +81,15 @@ static int smu10_initialize_dpm_defaults(struct pp_hwmgr *hwmgr)
 	smu10_data->thermal_auto_throttling_treshold = 0;
 	smu10_data->is_nb_dpm_enabled = 1;
 	smu10_data->dpm_flags = 1;
-	smu10_data->gfx_off_controled_by_driver = false;
 	smu10_data->need_min_deep_sleep_dcefclk = true;
 	smu10_data->num_active_display = 0;
 	smu10_data->deep_sleep_dcefclk = 0;
 
+	if (hwmgr->feature_mask & PP_GFXOFF_MASK)
+		smu10_data->gfx_off_controled_by_driver = true;
+	else
+		smu10_data->gfx_off_controled_by_driver = false;
+
 	phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
 					PHM_PlatformCaps_SclkDeepSleep);
 
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/20] drm/amdgpu: gfx off support
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (19 preceding siblings ...)
  2018-04-19  0:22   ` [PATCH 20/20] drm/amd/powerplay: use the flag to decide whether send gfxoff smc message Huang Rui
@ 2018-04-19  7:25   ` Christian König
  2018-04-19 13:51   ` Alex Deucher
  21 siblings, 0 replies; 27+ messages in thread
From: Christian König @ 2018-04-19  7:25 UTC (permalink / raw)
  To: Huang Rui, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

I can't judge technical correctness, but coding style, commit messages 
etc..  look good on first glance.

Series is Acked-by: Christian König <christian.koenig@amd.com>.

Regards,
Christian.

Am 19.04.2018 um 02:22 schrieb Huang Rui:
> GFXOFF is the new GPU feature that save power consumption. It used RLC to
> poweroff the gfx engine dynamicly when there is no workload on gfx pipe and make
> gfx into "idle" state.
> 1. Add three additional RLC ucodes, and use psp to load them.
> 2. Revise RLC save restore list.
> 3. Enable CGPG (GFX power gating).
> 4. Enable gfxoff.
> 5. Revise suspend/resume sequence.
>
> Currently, only raven is able to support gfxoff at first. And after CQE do
> series rounds of testing, and there is no regression that bring by gfxoff
> feature till now.
>
> We support two types of gfxoff, and user is able to build them manually from
> firmware repo:
> 1. Real CGPG
> 	$ make clean
> 	$ make REAL_CGPG=1
> 2. Faked CGPG: (by default)
> 	$ make clean
> 	$ make	
>
> Then configure to enable gfxoff with ppfeaturemask=0xffffbfff.
>
> Thanks,
> Ray
>
> Huang Rui (20):
>    drm/amdgpu: update psp gfx if header
>    drm/amdgpu: add new rlc firmware header format v2.1
>    drm/amdgpu: add save restore list cntl gpm and srm firmware support
>    drm/amdgpu: enter rlc safe mode before set cgpg
>    drm/amdgpu: cleanup init power gating function
>    drm/amdgpu: revise init_rlc_save_restore_list behavior to support
>      latest register_list_format/register_restore table
>    drm/amdgpu: add setting powergating method for gfx9
>    drm/amd/powerplay: send CGPG smc message if PG is enabled for raven
>    drm/amdgpu: move PP_FEATURE_MASK to amd_shared header
>    drm/amdgpu: add gfxoff feature mask
>    drm/amdgpu: set gfxoff disabled by default
>    drm/amd/powerplay: add gfx off control function
>    drm/amd/powerplay: enable/disable gfxoff through smu
>    drm/amdgpu: use pp_feature member to store the mask
>    drm/amdgpu: clear gfxoff featue mask if the asic is not raven
>    drm/amd/powerplay: add control gfxoff enabling in late init
>    drm/amdgpu: it should disable gfxoff when system is going to suspend
>    drm/amdgpu: fix to disable powergating in hw_fini
>    drm/amdgpu: set CGPG if gfxoff is enabled for raven
>    drm/amd/powerplay: use the flag to decide whether send gfxoff smc
>      message
>
>   drivers/gpu/drm/amd/amdgpu/amdgpu.h               |  16 ++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |   8 +
>   drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h           |   2 -
>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c           |   2 +-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c           |  36 ++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c         |  51 ++++-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h         |  22 ++
>   drivers/gpu/drm/amd/amdgpu/ci_dpm.c               |   2 +-
>   drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             | 233 +++++++++++++++-------
>   drivers/gpu/drm/amd/amdgpu/kv_dpm.c               |   2 +-
>   drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h           |  67 +++++--
>   drivers/gpu/drm/amd/amdgpu/psp_v10_0.c            |   9 +
>   drivers/gpu/drm/amd/amdgpu/soc15.c                |   5 +
>   drivers/gpu/drm/amd/include/amd_shared.h          |  19 ++
>   drivers/gpu/drm/amd/powerplay/amd_powerplay.c     |  20 +-
>   drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c       |   6 +-
>   drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c |  50 ++++-
>   drivers/gpu/drm/amd/powerplay/inc/hwmgr.h         |  19 +-
>   drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h      |   1 +
>   include/uapi/drm/amdgpu_drm.h                     |   6 +
>   20 files changed, 447 insertions(+), 129 deletions(-)
>

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/20] drm/amdgpu: gfx off support
       [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
                     ` (20 preceding siblings ...)
  2018-04-19  7:25   ` [PATCH 00/20] drm/amdgpu: gfx off support Christian König
@ 2018-04-19 13:51   ` Alex Deucher
       [not found]     ` <CADnq5_Nn-sa0TXeLdy+1SHva=1D5aXdMy+ngokmS+GyxtHRisw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  21 siblings, 1 reply; 27+ messages in thread
From: Alex Deucher @ 2018-04-19 13:51 UTC (permalink / raw)
  To: Huang Rui; +Cc: amd-gfx list

On Wed, Apr 18, 2018 at 8:22 PM, Huang Rui <ray.huang@amd.com> wrote:
> GFXOFF is the new GPU feature that save power consumption. It used RLC to
> poweroff the gfx engine dynamicly when there is no workload on gfx pipe and make
> gfx into "idle" state.
> 1. Add three additional RLC ucodes, and use psp to load them.
> 2. Revise RLC save restore list.
> 3. Enable CGPG (GFX power gating).
> 4. Enable gfxoff.
> 5. Revise suspend/resume sequence.
>
> Currently, only raven is able to support gfxoff at first. And after CQE do
> series rounds of testing, and there is no regression that bring by gfxoff
> feature till now.
>
> We support two types of gfxoff, and user is able to build them manually from
> firmware repo:
> 1. Real CGPG
>         $ make clean
>         $ make REAL_CGPG=1
> 2. Faked CGPG: (by default)
>         $ make clean
>         $ make
>
> Then configure to enable gfxoff with ppfeaturemask=0xffffbfff.

A couple of things we need to take care of before enabling this:
1. Need to switch it off when selecting stable pstate or profiling
mode in powerplay
2. Need to check if gfx is on before accessing the RLC_GPU_CLOCK_COUNT
registers.

Alex

>
> Thanks,
> Ray
>
> Huang Rui (20):
>   drm/amdgpu: update psp gfx if header
>   drm/amdgpu: add new rlc firmware header format v2.1
>   drm/amdgpu: add save restore list cntl gpm and srm firmware support
>   drm/amdgpu: enter rlc safe mode before set cgpg
>   drm/amdgpu: cleanup init power gating function
>   drm/amdgpu: revise init_rlc_save_restore_list behavior to support
>     latest register_list_format/register_restore table
>   drm/amdgpu: add setting powergating method for gfx9
>   drm/amd/powerplay: send CGPG smc message if PG is enabled for raven
>   drm/amdgpu: move PP_FEATURE_MASK to amd_shared header
>   drm/amdgpu: add gfxoff feature mask
>   drm/amdgpu: set gfxoff disabled by default
>   drm/amd/powerplay: add gfx off control function
>   drm/amd/powerplay: enable/disable gfxoff through smu
>   drm/amdgpu: use pp_feature member to store the mask
>   drm/amdgpu: clear gfxoff featue mask if the asic is not raven
>   drm/amd/powerplay: add control gfxoff enabling in late init
>   drm/amdgpu: it should disable gfxoff when system is going to suspend
>   drm/amdgpu: fix to disable powergating in hw_fini
>   drm/amdgpu: set CGPG if gfxoff is enabled for raven
>   drm/amd/powerplay: use the flag to decide whether send gfxoff smc
>     message
>
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h               |  16 ++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |   8 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h           |   2 -
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c           |   2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c           |  36 ++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c         |  51 ++++-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h         |  22 ++
>  drivers/gpu/drm/amd/amdgpu/ci_dpm.c               |   2 +-
>  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             | 233 +++++++++++++++-------
>  drivers/gpu/drm/amd/amdgpu/kv_dpm.c               |   2 +-
>  drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h           |  67 +++++--
>  drivers/gpu/drm/amd/amdgpu/psp_v10_0.c            |   9 +
>  drivers/gpu/drm/amd/amdgpu/soc15.c                |   5 +
>  drivers/gpu/drm/amd/include/amd_shared.h          |  19 ++
>  drivers/gpu/drm/amd/powerplay/amd_powerplay.c     |  20 +-
>  drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c       |   6 +-
>  drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c |  50 ++++-
>  drivers/gpu/drm/amd/powerplay/inc/hwmgr.h         |  19 +-
>  drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h      |   1 +
>  include/uapi/drm/amdgpu_drm.h                     |   6 +
>  20 files changed, 447 insertions(+), 129 deletions(-)
>
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/20] drm/amdgpu: gfx off support
       [not found]     ` <CADnq5_Nn-sa0TXeLdy+1SHva=1D5aXdMy+ngokmS+GyxtHRisw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2018-04-19 17:58       ` Felix Kuehling
       [not found]         ` <64cd5bd0-1b0f-1372-b4df-7db92eccfc1f-5C7GfCeVMHo@public.gmane.org>
  2018-04-20  1:19       ` Huang Rui
  1 sibling, 1 reply; 27+ messages in thread
From: Felix Kuehling @ 2018-04-19 17:58 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Deucher, Alexander, Huang, Ray

On 2018-04-19 09:51 AM, Alex Deucher wrote:
> On Wed, Apr 18, 2018 at 8:22 PM, Huang Rui <ray.huang@amd.com> wrote:
>> GFXOFF is the new GPU feature that save power consumption. It used RLC to
>> poweroff the gfx engine dynamicly when there is no workload on gfx pipe and make
>> gfx into "idle" state.
>> 1. Add three additional RLC ucodes, and use psp to load them.
>> 2. Revise RLC save restore list.
>> 3. Enable CGPG (GFX power gating).
>> 4. Enable gfxoff.
>> 5. Revise suspend/resume sequence.
>>
>> Currently, only raven is able to support gfxoff at first. And after CQE do
>> series rounds of testing, and there is no regression that bring by gfxoff
>> feature till now.
>>
>> We support two types of gfxoff, and user is able to build them manually from
>> firmware repo:
>> 1. Real CGPG
>>         $ make clean
>>         $ make REAL_CGPG=1
>> 2. Faked CGPG: (by default)
>>         $ make clean
>>         $ make
>>
>> Then configure to enable gfxoff with ppfeaturemask=0xffffbfff.
> A couple of things we need to take care of before enabling this:
> 1. Need to switch it off when selecting stable pstate or profiling
> mode in powerplay
> 2. Need to check if gfx is on before accessing the RLC_GPU_CLOCK_COUNT
> registers.

I second that. Access to RLC_GPU_CLOCK_COUNT is used for some ROCm
profiling features. Accessing the register while GFX is OFF can lead to
hangs according to HW engineers. Also, GFX OFF resets the counter to 0,
which would confuse any profiling code using it.

Would it be possible to control the GFX OFF feature as part of power
profiles? For example we could have the feature disabled in the compute
power profile.

Regards,
  Felix

>
> Alex
>
>> Thanks,
>> Ray
>>
>> Huang Rui (20):
>>   drm/amdgpu: update psp gfx if header
>>   drm/amdgpu: add new rlc firmware header format v2.1
>>   drm/amdgpu: add save restore list cntl gpm and srm firmware support
>>   drm/amdgpu: enter rlc safe mode before set cgpg
>>   drm/amdgpu: cleanup init power gating function
>>   drm/amdgpu: revise init_rlc_save_restore_list behavior to support
>>     latest register_list_format/register_restore table
>>   drm/amdgpu: add setting powergating method for gfx9
>>   drm/amd/powerplay: send CGPG smc message if PG is enabled for raven
>>   drm/amdgpu: move PP_FEATURE_MASK to amd_shared header
>>   drm/amdgpu: add gfxoff feature mask
>>   drm/amdgpu: set gfxoff disabled by default
>>   drm/amd/powerplay: add gfx off control function
>>   drm/amd/powerplay: enable/disable gfxoff through smu
>>   drm/amdgpu: use pp_feature member to store the mask
>>   drm/amdgpu: clear gfxoff featue mask if the asic is not raven
>>   drm/amd/powerplay: add control gfxoff enabling in late init
>>   drm/amdgpu: it should disable gfxoff when system is going to suspend
>>   drm/amdgpu: fix to disable powergating in hw_fini
>>   drm/amdgpu: set CGPG if gfxoff is enabled for raven
>>   drm/amd/powerplay: use the flag to decide whether send gfxoff smc
>>     message
>>
>>  drivers/gpu/drm/amd/amdgpu/amdgpu.h               |  16 ++
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |   8 +
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h           |   2 -
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c           |   2 +-
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c           |  36 ++++
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c         |  51 ++++-
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h         |  22 ++
>>  drivers/gpu/drm/amd/amdgpu/ci_dpm.c               |   2 +-
>>  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             | 233 +++++++++++++++-------
>>  drivers/gpu/drm/amd/amdgpu/kv_dpm.c               |   2 +-
>>  drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h           |  67 +++++--
>>  drivers/gpu/drm/amd/amdgpu/psp_v10_0.c            |   9 +
>>  drivers/gpu/drm/amd/amdgpu/soc15.c                |   5 +
>>  drivers/gpu/drm/amd/include/amd_shared.h          |  19 ++
>>  drivers/gpu/drm/amd/powerplay/amd_powerplay.c     |  20 +-
>>  drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c       |   6 +-
>>  drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c |  50 ++++-
>>  drivers/gpu/drm/amd/powerplay/inc/hwmgr.h         |  19 +-
>>  drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h      |   1 +
>>  include/uapi/drm/amdgpu_drm.h                     |   6 +
>>  20 files changed, 447 insertions(+), 129 deletions(-)
>>
>> --
>> 2.7.4
>>
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/20] drm/amdgpu: gfx off support
       [not found]         ` <64cd5bd0-1b0f-1372-b4df-7db92eccfc1f-5C7GfCeVMHo@public.gmane.org>
@ 2018-04-19 18:08           ` Alex Deucher
  2018-04-20  1:29           ` Huang Rui
  1 sibling, 0 replies; 27+ messages in thread
From: Alex Deucher @ 2018-04-19 18:08 UTC (permalink / raw)
  To: Felix Kuehling; +Cc: Deucher, Alexander, Huang, Ray, amd-gfx list

On Thu, Apr 19, 2018 at 1:58 PM, Felix Kuehling <felix.kuehling@amd.com> wrote:
> On 2018-04-19 09:51 AM, Alex Deucher wrote:
>> On Wed, Apr 18, 2018 at 8:22 PM, Huang Rui <ray.huang@amd.com> wrote:
>>> GFXOFF is the new GPU feature that save power consumption. It used RLC to
>>> poweroff the gfx engine dynamicly when there is no workload on gfx pipe and make
>>> gfx into "idle" state.
>>> 1. Add three additional RLC ucodes, and use psp to load them.
>>> 2. Revise RLC save restore list.
>>> 3. Enable CGPG (GFX power gating).
>>> 4. Enable gfxoff.
>>> 5. Revise suspend/resume sequence.
>>>
>>> Currently, only raven is able to support gfxoff at first. And after CQE do
>>> series rounds of testing, and there is no regression that bring by gfxoff
>>> feature till now.
>>>
>>> We support two types of gfxoff, and user is able to build them manually from
>>> firmware repo:
>>> 1. Real CGPG
>>>         $ make clean
>>>         $ make REAL_CGPG=1
>>> 2. Faked CGPG: (by default)
>>>         $ make clean
>>>         $ make
>>>
>>> Then configure to enable gfxoff with ppfeaturemask=0xffffbfff.
>> A couple of things we need to take care of before enabling this:
>> 1. Need to switch it off when selecting stable pstate or profiling
>> mode in powerplay
>> 2. Need to check if gfx is on before accessing the RLC_GPU_CLOCK_COUNT
>> registers.
>
> I second that. Access to RLC_GPU_CLOCK_COUNT is used for some ROCm
> profiling features. Accessing the register while GFX is OFF can lead to
> hangs according to HW engineers. Also, GFX OFF resets the counter to 0,
> which would confuse any profiling code using it.
>
> Would it be possible to control the GFX OFF feature as part of power
> profiles? For example we could have the feature disabled in the compute
> power profile.

Yes, we should be able to do that.

Alex

>
> Regards,
>   Felix
>
>>
>> Alex
>>
>>> Thanks,
>>> Ray
>>>
>>> Huang Rui (20):
>>>   drm/amdgpu: update psp gfx if header
>>>   drm/amdgpu: add new rlc firmware header format v2.1
>>>   drm/amdgpu: add save restore list cntl gpm and srm firmware support
>>>   drm/amdgpu: enter rlc safe mode before set cgpg
>>>   drm/amdgpu: cleanup init power gating function
>>>   drm/amdgpu: revise init_rlc_save_restore_list behavior to support
>>>     latest register_list_format/register_restore table
>>>   drm/amdgpu: add setting powergating method for gfx9
>>>   drm/amd/powerplay: send CGPG smc message if PG is enabled for raven
>>>   drm/amdgpu: move PP_FEATURE_MASK to amd_shared header
>>>   drm/amdgpu: add gfxoff feature mask
>>>   drm/amdgpu: set gfxoff disabled by default
>>>   drm/amd/powerplay: add gfx off control function
>>>   drm/amd/powerplay: enable/disable gfxoff through smu
>>>   drm/amdgpu: use pp_feature member to store the mask
>>>   drm/amdgpu: clear gfxoff featue mask if the asic is not raven
>>>   drm/amd/powerplay: add control gfxoff enabling in late init
>>>   drm/amdgpu: it should disable gfxoff when system is going to suspend
>>>   drm/amdgpu: fix to disable powergating in hw_fini
>>>   drm/amdgpu: set CGPG if gfxoff is enabled for raven
>>>   drm/amd/powerplay: use the flag to decide whether send gfxoff smc
>>>     message
>>>
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu.h               |  16 ++
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |   8 +
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h           |   2 -
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c           |   2 +-
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c           |  36 ++++
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c         |  51 ++++-
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h         |  22 ++
>>>  drivers/gpu/drm/amd/amdgpu/ci_dpm.c               |   2 +-
>>>  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             | 233 +++++++++++++++-------
>>>  drivers/gpu/drm/amd/amdgpu/kv_dpm.c               |   2 +-
>>>  drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h           |  67 +++++--
>>>  drivers/gpu/drm/amd/amdgpu/psp_v10_0.c            |   9 +
>>>  drivers/gpu/drm/amd/amdgpu/soc15.c                |   5 +
>>>  drivers/gpu/drm/amd/include/amd_shared.h          |  19 ++
>>>  drivers/gpu/drm/amd/powerplay/amd_powerplay.c     |  20 +-
>>>  drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c       |   6 +-
>>>  drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c |  50 ++++-
>>>  drivers/gpu/drm/amd/powerplay/inc/hwmgr.h         |  19 +-
>>>  drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h      |   1 +
>>>  include/uapi/drm/amdgpu_drm.h                     |   6 +
>>>  20 files changed, 447 insertions(+), 129 deletions(-)
>>>
>>> --
>>> 2.7.4
>>>
>>> _______________________________________________
>>> amd-gfx mailing list
>>> amd-gfx@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/20] drm/amdgpu: gfx off support
       [not found]     ` <CADnq5_Nn-sa0TXeLdy+1SHva=1D5aXdMy+ngokmS+GyxtHRisw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2018-04-19 17:58       ` Felix Kuehling
@ 2018-04-20  1:19       ` Huang Rui
  1 sibling, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-20  1:19 UTC (permalink / raw)
  To: Alex Deucher; +Cc: amd-gfx list

On Thu, Apr 19, 2018 at 09:51:29PM +0800, Alex Deucher wrote:
> On Wed, Apr 18, 2018 at 8:22 PM, Huang Rui <ray.huang@amd.com> wrote:
> > GFXOFF is the new GPU feature that save power consumption. It used RLC to
> > poweroff the gfx engine dynamicly when there is no workload on gfx pipe and make
> > gfx into "idle" state.
> > 1. Add three additional RLC ucodes, and use psp to load them.
> > 2. Revise RLC save restore list.
> > 3. Enable CGPG (GFX power gating).
> > 4. Enable gfxoff.
> > 5. Revise suspend/resume sequence.
> >
> > Currently, only raven is able to support gfxoff at first. And after CQE do
> > series rounds of testing, and there is no regression that bring by gfxoff
> > feature till now.
> >
> > We support two types of gfxoff, and user is able to build them manually from
> > firmware repo:
> > 1. Real CGPG
> >         $ make clean
> >         $ make REAL_CGPG=1
> > 2. Faked CGPG: (by default)
> >         $ make clean
> >         $ make
> >
> > Then configure to enable gfxoff with ppfeaturemask=0xffffbfff.
> 
> A couple of things we need to take care of before enabling this:
> 1. Need to switch it off when selecting stable pstate or profiling
> mode in powerplay

Got it. We don't support enable/disable gfxoff dynamically yet. It needs
more stability testing, you know, feature is disabled by default at
current. I will try to find good sequence to make dynamically
enable/disable workable smoothly next step.

> 2. Need to check if gfx is on before accessing the RLC_GPU_CLOCK_COUNT
> registers.
> 

Please check next mail with Felix's comments.

Thanks,
Ray

> Alex
> 
> >
> > Thanks,
> > Ray
> >
> > Huang Rui (20):
> >   drm/amdgpu: update psp gfx if header
> >   drm/amdgpu: add new rlc firmware header format v2.1
> >   drm/amdgpu: add save restore list cntl gpm and srm firmware support
> >   drm/amdgpu: enter rlc safe mode before set cgpg
> >   drm/amdgpu: cleanup init power gating function
> >   drm/amdgpu: revise init_rlc_save_restore_list behavior to support
> >     latest register_list_format/register_restore table
> >   drm/amdgpu: add setting powergating method for gfx9
> >   drm/amd/powerplay: send CGPG smc message if PG is enabled for raven
> >   drm/amdgpu: move PP_FEATURE_MASK to amd_shared header
> >   drm/amdgpu: add gfxoff feature mask
> >   drm/amdgpu: set gfxoff disabled by default
> >   drm/amd/powerplay: add gfx off control function
> >   drm/amd/powerplay: enable/disable gfxoff through smu
> >   drm/amdgpu: use pp_feature member to store the mask
> >   drm/amdgpu: clear gfxoff featue mask if the asic is not raven
> >   drm/amd/powerplay: add control gfxoff enabling in late init
> >   drm/amdgpu: it should disable gfxoff when system is going to suspend
> >   drm/amdgpu: fix to disable powergating in hw_fini
> >   drm/amdgpu: set CGPG if gfxoff is enabled for raven
> >   drm/amd/powerplay: use the flag to decide whether send gfxoff smc
> >     message
> >
> >  drivers/gpu/drm/amd/amdgpu/amdgpu.h               |  16 ++
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |   8 +
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h           |   2 -
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c           |   2 +-
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c           |  36 ++++
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c         |  51 ++++-
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h         |  22 ++
> >  drivers/gpu/drm/amd/amdgpu/ci_dpm.c               |   2 +-
> >  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             | 233 +++++++++++++++-------
> >  drivers/gpu/drm/amd/amdgpu/kv_dpm.c               |   2 +-
> >  drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h           |  67 +++++--
> >  drivers/gpu/drm/amd/amdgpu/psp_v10_0.c            |   9 +
> >  drivers/gpu/drm/amd/amdgpu/soc15.c                |   5 +
> >  drivers/gpu/drm/amd/include/amd_shared.h          |  19 ++
> >  drivers/gpu/drm/amd/powerplay/amd_powerplay.c     |  20 +-
> >  drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c       |   6 +-
> >  drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c |  50 ++++-
> >  drivers/gpu/drm/amd/powerplay/inc/hwmgr.h         |  19 +-
> >  drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h      |   1 +
> >  include/uapi/drm/amdgpu_drm.h                     |   6 +
> >  20 files changed, 447 insertions(+), 129 deletions(-)
> >
> > --
> > 2.7.4
> >
> > _______________________________________________
> > amd-gfx mailing list
> > amd-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 00/20] drm/amdgpu: gfx off support
       [not found]         ` <64cd5bd0-1b0f-1372-b4df-7db92eccfc1f-5C7GfCeVMHo@public.gmane.org>
  2018-04-19 18:08           ` Alex Deucher
@ 2018-04-20  1:29           ` Huang Rui
  1 sibling, 0 replies; 27+ messages in thread
From: Huang Rui @ 2018-04-20  1:29 UTC (permalink / raw)
  To: Kuehling, Felix
  Cc: Deucher, Alexander, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Fri, Apr 20, 2018 at 01:58:33AM +0800, Kuehling, Felix wrote:
> On 2018-04-19 09:51 AM, Alex Deucher wrote:
> > On Wed, Apr 18, 2018 at 8:22 PM, Huang Rui <ray.huang@amd.com> wrote:
> >> GFXOFF is the new GPU feature that save power consumption. It used RLC to
> >> poweroff the gfx engine dynamicly when there is no workload on gfx pipe and make
> >> gfx into "idle" state.
> >> 1. Add three additional RLC ucodes, and use psp to load them.
> >> 2. Revise RLC save restore list.
> >> 3. Enable CGPG (GFX power gating).
> >> 4. Enable gfxoff.
> >> 5. Revise suspend/resume sequence.
> >>
> >> Currently, only raven is able to support gfxoff at first. And after CQE do
> >> series rounds of testing, and there is no regression that bring by gfxoff
> >> feature till now.
> >>
> >> We support two types of gfxoff, and user is able to build them manually from
> >> firmware repo:
> >> 1. Real CGPG
> >>         $ make clean
> >>         $ make REAL_CGPG=1
> >> 2. Faked CGPG: (by default)
> >>         $ make clean
> >>         $ make
> >>
> >> Then configure to enable gfxoff with ppfeaturemask=0xffffbfff.
> > A couple of things we need to take care of before enabling this:
> > 1. Need to switch it off when selecting stable pstate or profiling
> > mode in powerplay
> > 2. Need to check if gfx is on before accessing the RLC_GPU_CLOCK_COUNT
> > registers.
> 
> I second that. Access to RLC_GPU_CLOCK_COUNT is used for some ROCm
> profiling features. Accessing the register while GFX is OFF can lead to
> hangs according to HW engineers. Also, GFX OFF resets the counter to 0,
> which would confuse any profiling code using it.
> 
> Would it be possible to control the GFX OFF feature as part of power
> profiles? For example we could have the feature disabled in the compute
> power profile.
> 

Yes, you're right. We have to take care the runtime RLC_GPU_CLOCK_COUNT(GC
domain) register access. :-)
We don't support enable/disable gfxoff feature dynamically yet. Yes, this
is the next step that I should try to do it.  With the issue is resolved, I
think we can provide an interface as you can configure it in the power
profile.

Before that, can we return "0" at gfx_v9_0_get_gpu_clock_counter when gfx
is in off in order to bypass RLC_GPU_CLOCK_COUNT registers?

Thanks,
Ray
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2018-04-20  1:29 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-19  0:22 [PATCH 00/20] drm/amdgpu: gfx off support Huang Rui
     [not found] ` <1524097356-4974-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
2018-04-19  0:22   ` [PATCH 01/20] drm/amdgpu: update psp gfx if header Huang Rui
2018-04-19  0:22   ` [PATCH 02/20] drm/amdgpu: add new rlc firmware header format v2.1 Huang Rui
2018-04-19  0:22   ` [PATCH 03/20] drm/amdgpu: add save restore list cntl gpm and srm firmware support Huang Rui
2018-04-19  0:22   ` [PATCH 04/20] drm/amdgpu: enter rlc safe mode before set cgpg Huang Rui
2018-04-19  0:22   ` [PATCH 05/20] drm/amdgpu: cleanup init power gating function Huang Rui
2018-04-19  0:22   ` [PATCH 06/20] drm/amdgpu: revise init_rlc_save_restore_list behavior to support latest register_list_format/register_restore table Huang Rui
2018-04-19  0:22   ` [PATCH 07/20] drm/amdgpu: add setting powergating method for gfx9 Huang Rui
2018-04-19  0:22   ` [PATCH 08/20] drm/amd/powerplay: send CGPG smc message if PG is enabled for raven Huang Rui
2018-04-19  0:22   ` [PATCH 09/20] drm/amdgpu: move PP_FEATURE_MASK to amd_shared header Huang Rui
2018-04-19  0:22   ` [PATCH 10/20] drm/amdgpu: add gfxoff feature mask Huang Rui
2018-04-19  0:22   ` [PATCH 11/20] drm/amdgpu: set gfxoff disabled by default Huang Rui
2018-04-19  0:22   ` [PATCH 12/20] drm/amd/powerplay: add gfx off control function Huang Rui
2018-04-19  0:22   ` [PATCH 13/20] drm/amd/powerplay: enable/disable gfxoff through smu Huang Rui
2018-04-19  0:22   ` [PATCH 14/20] drm/amdgpu: use pp_feature member to store the mask Huang Rui
2018-04-19  0:22   ` [PATCH 15/20] drm/amdgpu: clear gfxoff featue mask if the asic is not raven Huang Rui
2018-04-19  0:22   ` [PATCH 16/20] drm/amd/powerplay: add control gfxoff enabling in late init Huang Rui
2018-04-19  0:22   ` [PATCH 17/20] drm/amdgpu: it should disable gfxoff when system is going to suspend Huang Rui
2018-04-19  0:22   ` [PATCH 18/20] drm/amdgpu: fix to disable powergating in hw_fini Huang Rui
2018-04-19  0:22   ` [PATCH 19/20] drm/amdgpu: set CGPG if gfxoff is enabled for raven Huang Rui
2018-04-19  0:22   ` [PATCH 20/20] drm/amd/powerplay: use the flag to decide whether send gfxoff smc message Huang Rui
2018-04-19  7:25   ` [PATCH 00/20] drm/amdgpu: gfx off support Christian König
2018-04-19 13:51   ` Alex Deucher
     [not found]     ` <CADnq5_Nn-sa0TXeLdy+1SHva=1D5aXdMy+ngokmS+GyxtHRisw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-04-19 17:58       ` Felix Kuehling
     [not found]         ` <64cd5bd0-1b0f-1372-b4df-7db92eccfc1f-5C7GfCeVMHo@public.gmane.org>
2018-04-19 18:08           ` Alex Deucher
2018-04-20  1:29           ` Huang Rui
2018-04-20  1:19       ` Huang Rui

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.