[PATCH 1/2] drm/amd/pm: restore fan_mode AMD_FAN_CTRL_NONE on resume (v2)

2021-08-10 Thread Ryan Taylor
Adds missing edge case to smu_restore_dpm_user_profile.

v2: Don't restore fan mode auto (Lijo)

Reviewed-by: Lijo Lazar 
Signed-off-by: Ryan Taylor 
---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c 
b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index 71afc2d20b12..b4b4d615bcbc 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -403,7 +403,8 @@ static void smu_restore_dpm_user_profile(struct smu_context 
*smu)
}
 
/* set the user dpm fan configurations */
-   if (smu->user_dpm_profile.fan_mode == AMD_FAN_CTRL_MANUAL) {
+   if (smu->user_dpm_profile.fan_mode == AMD_FAN_CTRL_MANUAL ||
+   smu->user_dpm_profile.fan_mode == AMD_FAN_CTRL_NONE) {
ret = smu_set_fan_control_mode(smu, 
smu->user_dpm_profile.fan_mode);
if (ret) {
dev_err(smu->adev->dev, "Failed to set manual fan 
control mode\n");
@@ -620,6 +621,7 @@ static int smu_early_init(void *handle)
mutex_init(>smu_baco.mutex);
smu->smu_baco.state = SMU_BACO_STATE_EXIT;
smu->smu_baco.platform_support = false;
+   smu->user_dpm_profile.fan_mode = -1;
 
adev->powerplay.pp_handle = smu;
adev->powerplay.pp_funcs = _pm_funcs;
-- 
2.32.0



[PATCH 2/2] drm/amd/pm: graceful exit on restore fan mode failure (v2)

2021-08-10 Thread Ryan Taylor
Attempt od settings restore and disable restore flag on restore fan mode
failure.

v2: Update fan mode to auto and fan speed to zero (Lijo)

Reviewed-by: Lijo Lazar 
Signed-off-by: Ryan Taylor 
---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c 
b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index b4b4d615bcbc..00d594e6dd85 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -407,11 +407,12 @@ static void smu_restore_dpm_user_profile(struct 
smu_context *smu)
smu->user_dpm_profile.fan_mode == AMD_FAN_CTRL_NONE) {
ret = smu_set_fan_control_mode(smu, 
smu->user_dpm_profile.fan_mode);
if (ret) {
+   smu->user_dpm_profile.fan_speed_percent = 0;
+   smu->user_dpm_profile.fan_mode = AMD_FAN_CTRL_AUTO;
dev_err(smu->adev->dev, "Failed to set manual fan 
control mode\n");
-   return;
}
 
-   if (!ret && smu->user_dpm_profile.fan_speed_percent) {
+   if (smu->user_dpm_profile.fan_speed_percent) {
ret = smu_set_fan_speed_percent(smu, 
smu->user_dpm_profile.fan_speed_percent);
if (ret)
dev_err(smu->adev->dev, "Failed to set manual 
fan speed\n");
-- 
2.32.0



[PATCH 3/3] drm/amdgpu: replace dce_virtual with amdgpu_vkms (v3)

2021-07-27 Thread Ryan Taylor
Move dce_virtual into amdgpu_vkms and update all references to
dce_virtual with amdgpu_vkms.

v2: Removed more references to dce_virtual.

v3: Restored display modes from previous implementation.

Reported-by: kernel test robot 
Suggested-by: Alex Deucher 
Signed-off-by: Ryan Taylor 
---
 drivers/gpu/drm/amd/amdgpu/Makefile  |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 195 
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |   3 -
 drivers/gpu/drm/amd/amdgpu/cik.c |  10 +-
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 223 ---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.h |  30 ---
 drivers/gpu/drm/amd/amdgpu/nv.c  |  22 +--
 drivers/gpu/drm/amd/amdgpu/si.c  |   8 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c   |  10 +-
 drivers/gpu/drm/amd/amdgpu/vi.c  |  14 +-
 10 files changed, 228 insertions(+), 290 deletions(-)
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.c
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.h

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 30cbcd5ce1cc..0d814c957461 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -120,8 +120,7 @@ amdgpu-y += \
 amdgpu-y += \
dce_v10_0.o \
dce_v11_0.o \
-   amdgpu_vkms.o \
-   dce_virtual.o
+   amdgpu_vkms.o
 
 # add GFX block
 amdgpu-y += \
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
index e2810b22bb43..50bdc39733aa 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
@@ -5,6 +5,15 @@
 #include 
 
 #include "amdgpu.h"
+#ifdef CONFIG_DRM_AMDGPU_SI
+#include "dce_v6_0.h"
+#endif
+#ifdef CONFIG_DRM_AMDGPU_CIK
+#include "dce_v8_0.h"
+#endif
+#include "dce_v10_0.h"
+#include "dce_v11_0.h"
+#include "ivsrcid/ivsrcid_vislands30.h"
 #include "amdgpu_vkms.h"
 #include "amdgpu_display.h"
 
@@ -444,3 +453,189 @@ int amdgpu_vkms_output_init(struct drm_device *dev,
 
return ret;
 }
+
+const struct drm_mode_config_funcs amdgpu_vkms_mode_funcs = {
+   .fb_create = amdgpu_display_user_framebuffer_create,
+   .atomic_check = drm_atomic_helper_check,
+   .atomic_commit = drm_atomic_helper_commit,
+};
+
+static int amdgpu_vkms_sw_init(void *handle)
+{
+   int r, i;
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+   adev_to_drm(adev)->max_vblank_count = 0;
+
+   adev_to_drm(adev)->mode_config.funcs = _vkms_mode_funcs;
+
+   adev_to_drm(adev)->mode_config.max_width = XRES_MAX;
+   adev_to_drm(adev)->mode_config.max_height = YRES_MAX;
+
+   adev_to_drm(adev)->mode_config.preferred_depth = 24;
+   adev_to_drm(adev)->mode_config.prefer_shadow = 1;
+
+   adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
+
+   r = amdgpu_display_modeset_create_props(adev);
+   if (r)
+   return r;
+
+   adev->amdgpu_vkms_output = kcalloc(adev->mode_info.num_crtc, 
sizeof(struct amdgpu_vkms_output), GFP_KERNEL);
+
+   /* allocate crtcs, encoders, connectors */
+   for (i = 0; i < adev->mode_info.num_crtc; i++) {
+   r = amdgpu_vkms_output_init(adev_to_drm(adev), 
>amdgpu_vkms_output[i], i);
+   if (r)
+   return r;
+   }
+
+   drm_kms_helper_poll_init(adev_to_drm(adev));
+
+   adev->mode_info.mode_config_initialized = true;
+   return 0;
+}
+
+static int amdgpu_vkms_sw_fini(void *handle)
+{
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   int i = 0;
+
+   for (i = 0; i < adev->mode_info.num_crtc; i++)
+   if (adev->mode_info.crtcs[i])
+   hrtimer_cancel(>mode_info.crtcs[i]->vblank_timer);
+
+   kfree(adev->mode_info.bios_hardcoded_edid);
+   kfree(adev->amdgpu_vkms_output);
+
+   drm_kms_helper_poll_fini(adev_to_drm(adev));
+
+   adev->mode_info.mode_config_initialized = false;
+   return 0;
+}
+
+static int amdgpu_vkms_hw_init(void *handle)
+{
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+   switch (adev->asic_type) {
+#ifdef CONFIG_DRM_AMDGPU_SI
+   case CHIP_TAHITI:
+   case CHIP_PITCAIRN:
+   case CHIP_VERDE:
+   case CHIP_OLAND:
+   dce_v6_0_disable_dce(adev);
+   break;
+#endif
+#ifdef CONFIG_DRM_AMDGPU_CIK
+   case CHIP_BONAIRE:
+   case CHIP_HAWAII:
+   case CHIP_KAVERI:
+   case CHIP_KABINI:
+   case CHIP_MULLINS:
+   dce_v8_0_disable_dce(adev);
+   break;
+#endif
+   case CHIP_FIJI:
+   case CHIP_TONGA:
+   dce_v10_0_disable_dce(adev);
+   break;
+   case CHIP_CARRIZO:
+   case CHIP_STONEY:
+   case CHIP_POLARIS

[PATCH 0/3] drm/amdgpu: modernize virtual display feature

2021-07-27 Thread Ryan Taylor
The amdgpu vkms interface provides a virtual KMS interface for several use
cases: devices without display hardware, platforms where the actual display
hardware is not useful (e.g., servers), SR-IOV virtual functions, device
emulation/simulation, and device bring up prior to display hardware being
usable. We previously emulated a legacy KMS interface, but there was a desire
to move to the atomic KMS interface. The vkms driver did everything we
needed, but we wanted KMS support natively in the driver without buffer
sharing and the ability to support an instance of VKMS per device. We first
looked at splitting vkms into a stub driver and a helper module that other
drivers could use to implement a virtual display, but this strategy ended up
being messy due to driver specific callbacks needed for buffer management.
Ultimately, it proved easier to import the vkms code as it mostly used core
drm helpers anyway.

Ryan Taylor (3):
  drm/amdgpu: create amdgpu_vkms (v4)
  drm/amdgpu: cleanup dce_virtual
  drm/amdgpu: replace dce_virtual with amdgpu_vkms (v3)

 drivers/gpu/drm/amd/amdgpu/Makefile  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h  |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c   |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 641 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |  26 +
 drivers/gpu/drm/amd/amdgpu/cik.c |  10 +-
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 780 ---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.h |  30 -
 drivers/gpu/drm/amd/amdgpu/nv.c  |  22 +-
 drivers/gpu/drm/amd/amdgpu/si.c  |   8 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c   |  10 +-
 drivers/gpu/drm/amd/amdgpu/vi.c  |  14 +-
 13 files changed, 703 insertions(+), 845 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.c
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.h


base-commit: e0186426a7efeb506164da7d4a56cfdaea38b380
-- 
2.32.0

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


[PATCH 2/3] drm/amdgpu: cleanup dce_virtual

2021-07-27 Thread Ryan Taylor
Remove obsolete functions and variables from dce_virtual.

Signed-off-by: Ryan Taylor 
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 568 +--
 1 file changed, 3 insertions(+), 565 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index f940be9d4f69..4d7069b2d0f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -21,15 +21,9 @@
  *
  */
 
-#include 
 #include 
 
 #include "amdgpu.h"
-#include "amdgpu_pm.h"
-#include "amdgpu_i2c.h"
-#include "atom.h"
-#include "amdgpu_pll.h"
-#include "amdgpu_connectors.h"
 #ifdef CONFIG_DRM_AMDGPU_SI
 #include "dce_v6_0.h"
 #endif
@@ -43,339 +37,6 @@
 #include "amdgpu_display.h"
 #include "amdgpu_vkms.h"
 
-#define DCE_VIRTUAL_VBLANK_PERIOD 1666
-
-
-static void dce_virtual_set_display_funcs(struct amdgpu_device *adev);
-static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev);
-static int dce_virtual_connector_encoder_init(struct amdgpu_device *adev,
- int index);
-static int dce_virtual_pageflip(struct amdgpu_device *adev,
-   unsigned crtc_id);
-static enum hrtimer_restart dce_virtual_vblank_timer_handle(struct hrtimer 
*vblank_timer);
-static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device 
*adev,
-   int crtc,
-   enum 
amdgpu_interrupt_state state);
-
-static u32 dce_virtual_vblank_get_counter(struct amdgpu_device *adev, int crtc)
-{
-   return 0;
-}
-
-static void dce_virtual_page_flip(struct amdgpu_device *adev,
- int crtc_id, u64 crtc_base, bool async)
-{
-   return;
-}
-
-static int dce_virtual_crtc_get_scanoutpos(struct amdgpu_device *adev, int 
crtc,
-   u32 *vbl, u32 *position)
-{
-   *vbl = 0;
-   *position = 0;
-
-   return -EINVAL;
-}
-
-static bool dce_virtual_hpd_sense(struct amdgpu_device *adev,
-  enum amdgpu_hpd_id hpd)
-{
-   return true;
-}
-
-static void dce_virtual_hpd_set_polarity(struct amdgpu_device *adev,
- enum amdgpu_hpd_id hpd)
-{
-   return;
-}
-
-static u32 dce_virtual_hpd_get_gpio_reg(struct amdgpu_device *adev)
-{
-   return 0;
-}
-
-/**
- * dce_virtual_bandwidth_update - program display watermarks
- *
- * @adev: amdgpu_device pointer
- *
- * Calculate and program the display watermarks and line
- * buffer allocation (CIK).
- */
-static void dce_virtual_bandwidth_update(struct amdgpu_device *adev)
-{
-   return;
-}
-
-static int dce_virtual_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
- u16 *green, u16 *blue, uint32_t size,
- struct drm_modeset_acquire_ctx *ctx)
-{
-   return 0;
-}
-
-static void dce_virtual_crtc_destroy(struct drm_crtc *crtc)
-{
-   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-
-   drm_crtc_cleanup(crtc);
-   kfree(amdgpu_crtc);
-}
-
-static const struct drm_crtc_funcs dce_virtual_crtc_funcs = {
-   .cursor_set2 = NULL,
-   .cursor_move = NULL,
-   .gamma_set = dce_virtual_crtc_gamma_set,
-   .set_config = amdgpu_display_crtc_set_config,
-   .destroy = dce_virtual_crtc_destroy,
-   .page_flip_target = amdgpu_display_crtc_page_flip_target,
-   .get_vblank_counter = amdgpu_get_vblank_counter_kms,
-   .enable_vblank = amdgpu_enable_vblank_kms,
-   .disable_vblank = amdgpu_disable_vblank_kms,
-   .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
-};
-
-static void dce_virtual_crtc_dpms(struct drm_crtc *crtc, int mode)
-{
-   struct drm_device *dev = crtc->dev;
-   struct amdgpu_device *adev = drm_to_adev(dev);
-   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-   unsigned type;
-
-   switch (mode) {
-   case DRM_MODE_DPMS_ON:
-   amdgpu_crtc->enabled = true;
-   /* Make sure VBLANK interrupts are still enabled */
-   type = amdgpu_display_crtc_idx_to_irq_type(adev,
-   amdgpu_crtc->crtc_id);
-   amdgpu_irq_update(adev, >crtc_irq, type);
-   drm_crtc_vblank_on(crtc);
-   break;
-   case DRM_MODE_DPMS_STANDBY:
-   case DRM_MODE_DPMS_SUSPEND:
-   case DRM_MODE_DPMS_OFF:
-   drm_crtc_vblank_off(crtc);
-   amdgpu_crtc->enabled = false;
-   break;
-   }
-}
-
-
-static void dce_virtual_crtc_prepare(struct drm_crtc *crtc)
-{
-   dce_virtual_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
-}
-
-static void dce_virtual_crtc_commit(struct drm_crtc *crtc)
-{
-   dce_vi

[PATCH 1/3] drm/amdgpu: create amdgpu_vkms (v4)

2021-07-27 Thread Ryan Taylor
Modify the VKMS driver into an api that dce_virtual can use to create
virtual displays that obey drm's atomic modesetting api.

v2: Made local functions static.

v3: Switched vkms_output kzalloc for kcalloc.
Cleanup patches by moving display mode fixes to this patch.

v4: Update atomic_check and atomic_update to comply with new kms api.

Reported-by: kernel test robot 
Suggested-by: Alex Deucher 
Signed-off-by: Ryan Taylor 
---
 drivers/gpu/drm/amd/amdgpu/Makefile  |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu.h  |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c   |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 446 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |  29 ++
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c |  23 +-
 7 files changed, 493 insertions(+), 11 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index f089794bbdd5..30cbcd5ce1cc 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -120,6 +120,7 @@ amdgpu-y += \
 amdgpu-y += \
dce_v10_0.o \
dce_v11_0.o \
+   amdgpu_vkms.o \
dce_virtual.o
 
 # add GFX block
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index d10baa3338bc..96e895d6be35 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -916,6 +916,7 @@ struct amdgpu_device {
 
/* display */
boolenable_virtual_display;
+   struct amdgpu_vkms_output   *amdgpu_vkms_output;
struct amdgpu_mode_info mode_info;
/* For pre-DCE11. DCE11 and later are in "struct amdgpu_device->dm" */
struct work_struct  hotplug_work;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index bbc6bfadafd6..06e2a461f610 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1230,7 +1230,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
int ret, retry = 0;
bool supports_atomic = false;
 
-   if (!amdgpu_virtual_display &&
+   if (amdgpu_virtual_display ||
amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK))
supports_atomic = true;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index 09b048647523..5a143ca02cf9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -344,7 +344,7 @@ int amdgpu_fbdev_init(struct amdgpu_device *adev)
}
 
/* disable all the possible outputs/crtcs before entering KMS mode */
-   if (!amdgpu_device_has_dc_support(adev))
+   if (!amdgpu_device_has_dc_support(adev) && !amdgpu_virtual_display)
drm_helper_disable_unused_functions(adev_to_drm(adev));
 
drm_fb_helper_initial_config(>helper, bpp_sel);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
new file mode 100644
index ..e2810b22bb43
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
@@ -0,0 +1,446 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include 
+#include 
+#include 
+
+#include "amdgpu.h"
+#include "amdgpu_vkms.h"
+#include "amdgpu_display.h"
+
+/**
+ * DOC: amdgpu_vkms
+ *
+ * The amdgpu vkms interface provides a virtual KMS interface for several use
+ * cases: devices without display hardware, platforms where the actual display
+ * hardware is not useful (e.g., servers), SR-IOV virtual functions, device
+ * emulation/simulation, and device bring up prior to display hardware being
+ * usable. We previously emulated a legacy KMS interface, but there was a 
desire
+ * to move to the atomic KMS interface. The vkms driver did everything we
+ * needed, but we wanted KMS support natively in the driver without buffer
+ * sharing and the ability to support an instance of VKMS per device. We first
+ * looked at splitting vkms into a stub driver and a helper module that other
+ * drivers could use to implement a virtual display, but this strategy ended up
+ * being messy due to driver specific callbacks needed for buffer management.
+ * Ultimately, it proved easier to import the vkms code as it mostly used core
+ * drm helpers anyway.
+ */
+
+static const u32 amdgpu_vkms_formats[] = {
+   DRM_FORMAT_XRGB,
+};
+
+static enum hrtimer_restart amdgpu_vkms_vblank_simulate(struct hrtimer *timer)
+{
+   struct amdgpu_vkms_output *output = container_of(timer,
+struct 
amdgpu_vkms_output,
+vblank_hrtimer);
+   st

[PATCH 3/3] drm/amdgpu: replace dce_virtual with amdgpu_vkms (v3)

2021-07-21 Thread Ryan Taylor
Move dce_virtual into amdgpu_vkms and update all references to
dce_virtual with amdgpu_vkms.

v2: Removed more references to dce_virtual.

v3: Restored display modes from previous implementation.

Reported-by: kernel test robot 
Suggested-by: Alex Deucher 
Signed-off-by: Ryan Taylor 
---
 drivers/gpu/drm/amd/amdgpu/Makefile  |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 234 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |   5 +-
 drivers/gpu/drm/amd/amdgpu/cik.c |  10 +-
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 223 -
 drivers/gpu/drm/amd/amdgpu/dce_virtual.h |  30 ---
 drivers/gpu/drm/amd/amdgpu/nv.c  |  20 +-
 drivers/gpu/drm/amd/amdgpu/si.c  |   8 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c   |  10 +-
 drivers/gpu/drm/amd/amdgpu/vi.c  |  14 +-
 10 files changed, 264 insertions(+), 293 deletions(-)
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.c
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.h

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 30cbcd5ce1cc..0d814c957461 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -120,8 +120,7 @@ amdgpu-y += \
 amdgpu-y += \
dce_v10_0.o \
dce_v11_0.o \
-   amdgpu_vkms.o \
-   dce_virtual.o
+   amdgpu_vkms.o
 
 # add GFX block
 amdgpu-y += \
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
index d5c1f1c58f5f..538d41ea 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
@@ -5,6 +5,15 @@
 #include 
 
 #include "amdgpu.h"
+#ifdef CONFIG_DRM_AMDGPU_SI
+#include "dce_v6_0.h"
+#endif
+#ifdef CONFIG_DRM_AMDGPU_CIK
+#include "dce_v8_0.h"
+#endif
+#include "dce_v10_0.h"
+#include "dce_v11_0.h"
+#include "ivsrcid/ivsrcid_vislands30.h"
 #include "amdgpu_vkms.h"
 #include "amdgpu_display.h"
 
@@ -180,12 +189,45 @@ static const struct drm_connector_funcs 
amdgpu_vkms_connector_funcs = {
 
 static int amdgpu_vkms_conn_get_modes(struct drm_connector *connector)
 {
-   int count;
+   struct drm_device *dev = connector->dev;
+   struct drm_display_mode *mode = NULL;
+   unsigned i;
+   static const struct mode_size {
+   int w;
+   int h;
+   } common_modes[] = {
+   { 640,  480},
+   { 720,  480},
+   { 800,  600},
+   { 848,  480},
+   {1024,  768},
+   {1152,  768},
+   {1280,  720},
+   {1280,  800},
+   {1280,  854},
+   {1280,  960},
+   {1280, 1024},
+   {1440,  900},
+   {1400, 1050},
+   {1680, 1050},
+   {1600, 1200},
+   {1920, 1080},
+   {1920, 1200},
+   {2560, 1440},
+   {4096, 3112},
+   {3656, 2664},
+   {3840, 2160},
+   {4096, 2160},
+   };
+
+   for (i = 0; i < ARRAY_SIZE(common_modes); i++) {
+   mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 
60, false, false, false);
+   drm_mode_probed_add(connector, mode);
+   }
 
-   count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
 
-   return count;
+   return ARRAY_SIZE(common_modes);
 }
 
 static const struct drm_connector_helper_funcs amdgpu_vkms_conn_helper_funcs = 
{
@@ -409,3 +451,189 @@ int amdgpu_vkms_output_init(struct drm_device *dev,
 
return ret;
 }
+
+const struct drm_mode_config_funcs amdgpu_vkms_mode_funcs = {
+   .fb_create = amdgpu_display_user_framebuffer_create,
+   .atomic_check = drm_atomic_helper_check,
+   .atomic_commit = drm_atomic_helper_commit,
+};
+
+static int amdgpu_vkms_sw_init(void *handle)
+{
+   int r, i;
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+   adev_to_drm(adev)->max_vblank_count = 0;
+
+   adev_to_drm(adev)->mode_config.funcs = _vkms_mode_funcs;
+
+   adev_to_drm(adev)->mode_config.max_width = XRES_MAX;
+   adev_to_drm(adev)->mode_config.max_height = YRES_MAX;
+
+   adev_to_drm(adev)->mode_config.preferred_depth = 24;
+   adev_to_drm(adev)->mode_config.prefer_shadow = 1;
+
+   adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
+
+   r = amdgpu_display_modeset_create_props(adev);
+   if (r)
+   return r;
+
+   adev->amdgpu_vkms_output = kzalloc(sizeof(struct amdgpu_vkms_output) * 
adev->mode_info.num_crtc, GFP_KERNEL);
+
+   /* allocate crtcs, encoders, connectors */
+   for (i = 0; i < adev->mode_info.num_crtc; i++) {
+   r = amdgp

[PATCH 2/3] drm/amdgpu: cleanup dce_virtual

2021-07-21 Thread Ryan Taylor
Remove obsolete functions and variables from dce_virtual.

Signed-off-by: Ryan Taylor 
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 568 +--
 1 file changed, 3 insertions(+), 565 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 642c77533157..18369b47eac7 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -21,15 +21,9 @@
  *
  */
 
-#include 
 #include 
 
 #include "amdgpu.h"
-#include "amdgpu_pm.h"
-#include "amdgpu_i2c.h"
-#include "atom.h"
-#include "amdgpu_pll.h"
-#include "amdgpu_connectors.h"
 #ifdef CONFIG_DRM_AMDGPU_SI
 #include "dce_v6_0.h"
 #endif
@@ -43,339 +37,6 @@
 #include "amdgpu_display.h"
 #include "amdgpu_vkms.h"
 
-#define DCE_VIRTUAL_VBLANK_PERIOD 1666
-
-
-static void dce_virtual_set_display_funcs(struct amdgpu_device *adev);
-static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev);
-static int dce_virtual_connector_encoder_init(struct amdgpu_device *adev,
- int index);
-static int dce_virtual_pageflip(struct amdgpu_device *adev,
-   unsigned crtc_id);
-static enum hrtimer_restart dce_virtual_vblank_timer_handle(struct hrtimer 
*vblank_timer);
-static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device 
*adev,
-   int crtc,
-   enum 
amdgpu_interrupt_state state);
-
-static u32 dce_virtual_vblank_get_counter(struct amdgpu_device *adev, int crtc)
-{
-   return 0;
-}
-
-static void dce_virtual_page_flip(struct amdgpu_device *adev,
- int crtc_id, u64 crtc_base, bool async)
-{
-   return;
-}
-
-static int dce_virtual_crtc_get_scanoutpos(struct amdgpu_device *adev, int 
crtc,
-   u32 *vbl, u32 *position)
-{
-   *vbl = 0;
-   *position = 0;
-
-   return -EINVAL;
-}
-
-static bool dce_virtual_hpd_sense(struct amdgpu_device *adev,
-  enum amdgpu_hpd_id hpd)
-{
-   return true;
-}
-
-static void dce_virtual_hpd_set_polarity(struct amdgpu_device *adev,
- enum amdgpu_hpd_id hpd)
-{
-   return;
-}
-
-static u32 dce_virtual_hpd_get_gpio_reg(struct amdgpu_device *adev)
-{
-   return 0;
-}
-
-/**
- * dce_virtual_bandwidth_update - program display watermarks
- *
- * @adev: amdgpu_device pointer
- *
- * Calculate and program the display watermarks and line
- * buffer allocation (CIK).
- */
-static void dce_virtual_bandwidth_update(struct amdgpu_device *adev)
-{
-   return;
-}
-
-static int dce_virtual_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
- u16 *green, u16 *blue, uint32_t size,
- struct drm_modeset_acquire_ctx *ctx)
-{
-   return 0;
-}
-
-static void dce_virtual_crtc_destroy(struct drm_crtc *crtc)
-{
-   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-
-   drm_crtc_cleanup(crtc);
-   kfree(amdgpu_crtc);
-}
-
-static const struct drm_crtc_funcs dce_virtual_crtc_funcs = {
-   .cursor_set2 = NULL,
-   .cursor_move = NULL,
-   .gamma_set = dce_virtual_crtc_gamma_set,
-   .set_config = amdgpu_display_crtc_set_config,
-   .destroy = dce_virtual_crtc_destroy,
-   .page_flip_target = amdgpu_display_crtc_page_flip_target,
-   .get_vblank_counter = amdgpu_get_vblank_counter_kms,
-   .enable_vblank = amdgpu_enable_vblank_kms,
-   .disable_vblank = amdgpu_disable_vblank_kms,
-   .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
-};
-
-static void dce_virtual_crtc_dpms(struct drm_crtc *crtc, int mode)
-{
-   struct drm_device *dev = crtc->dev;
-   struct amdgpu_device *adev = drm_to_adev(dev);
-   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-   unsigned type;
-
-   switch (mode) {
-   case DRM_MODE_DPMS_ON:
-   amdgpu_crtc->enabled = true;
-   /* Make sure VBLANK interrupts are still enabled */
-   type = amdgpu_display_crtc_idx_to_irq_type(adev,
-   amdgpu_crtc->crtc_id);
-   amdgpu_irq_update(adev, >crtc_irq, type);
-   drm_crtc_vblank_on(crtc);
-   break;
-   case DRM_MODE_DPMS_STANDBY:
-   case DRM_MODE_DPMS_SUSPEND:
-   case DRM_MODE_DPMS_OFF:
-   drm_crtc_vblank_off(crtc);
-   amdgpu_crtc->enabled = false;
-   break;
-   }
-}
-
-
-static void dce_virtual_crtc_prepare(struct drm_crtc *crtc)
-{
-   dce_virtual_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
-}
-
-static void dce_virtual_crtc_commit(struct drm_crtc *crtc)
-{
-   dce_vi

[PATCH 1/3] drm/amdgpu: create amdgpu_vkms (v2)

2021-07-21 Thread Ryan Taylor
Modify the VKMS driver into an api that dce_virtual can use to create
virtual displays that obey drm's atomic modesetting api.

v2: Made local functions static.

Reported-by: kernel test robot 
Signed-off-by: Ryan Taylor 
---
 drivers/gpu/drm/amd/amdgpu/Makefile  |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu.h  |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c   |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 411 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |  29 ++
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c |  23 +-
 7 files changed, 458 insertions(+), 11 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index f089794bbdd5..30cbcd5ce1cc 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -120,6 +120,7 @@ amdgpu-y += \
 amdgpu-y += \
dce_v10_0.o \
dce_v11_0.o \
+   amdgpu_vkms.o \
dce_virtual.o
 
 # add GFX block
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 54cf647bd018..d0a2f2ed433d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -919,6 +919,7 @@ struct amdgpu_device {
 
/* display */
boolenable_virtual_display;
+   struct amdgpu_vkms_output   *amdgpu_vkms_output;
struct amdgpu_mode_info mode_info;
/* For pre-DCE11. DCE11 and later are in "struct amdgpu_device->dm" */
struct work_struct  hotplug_work;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index d0c935cf4f0f..1b016e5bc75f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1230,7 +1230,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
int ret, retry = 0;
bool supports_atomic = false;
 
-   if (!amdgpu_virtual_display &&
+   if (amdgpu_virtual_display ||
amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK))
supports_atomic = true;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index 09b048647523..5a143ca02cf9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -344,7 +344,7 @@ int amdgpu_fbdev_init(struct amdgpu_device *adev)
}
 
/* disable all the possible outputs/crtcs before entering KMS mode */
-   if (!amdgpu_device_has_dc_support(adev))
+   if (!amdgpu_device_has_dc_support(adev) && !amdgpu_virtual_display)
drm_helper_disable_unused_functions(adev_to_drm(adev));
 
drm_fb_helper_initial_config(>helper, bpp_sel);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
new file mode 100644
index ..d5c1f1c58f5f
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
@@ -0,0 +1,411 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include 
+#include 
+#include 
+
+#include "amdgpu.h"
+#include "amdgpu_vkms.h"
+#include "amdgpu_display.h"
+
+/**
+ * DOC: amdgpu_vkms
+ *
+ * The amdgpu vkms interface provides a virtual KMS interface for several use
+ * cases: devices without display hardware, platforms where the actual display
+ * hardware is not useful (e.g., servers), SR-IOV virtual functions, device
+ * emulation/simulation, and device bring up prior to display hardware being
+ * usable. We previously emulated a legacy KMS interface, but there was a 
desire
+ * to move to the atomic KMS interface. The vkms driver did everything we
+ * needed, but we wanted KMS support natively in the driver without buffer
+ * sharing and the ability to support an instance of VKMS per device. We first
+ * looked at splitting vkms into a stub driver and a helper module that other
+ * drivers could use to implement a virtual display, but this strategy ended up
+ * being messy due to driver specific callbacks needed for buffer management.
+ * Ultimately, it proved easier to import the vkms code as it mostly used core
+ * drm helpers anyway.
+ */
+
+static const u32 amdgpu_vkms_formats[] = {
+   DRM_FORMAT_XRGB,
+};
+
+static enum hrtimer_restart amdgpu_vkms_vblank_simulate(struct hrtimer *timer)
+{
+   struct amdgpu_vkms_output *output = container_of(timer,
+struct 
amdgpu_vkms_output,
+vblank_hrtimer);
+   struct drm_crtc *crtc = >crtc;
+   u64 ret_overrun;
+   bool ret;
+
+   ret_overrun = hrtimer_forward_now(>vblank_hrtimer,
+ output->period_ns);
+  

[PATCH 0/3] drm/amdgpu: modernize virtual display feature

2021-07-21 Thread Ryan Taylor
The amdgpu vkms interface provides a virtual KMS interface for several use
cases: devices without display hardware, platforms where the actual display
hardware is not useful (e.g., servers), SR-IOV virtual functions, device
emulation/simulation, and device bring up prior to display hardware being
usable. We previously emulated a legacy KMS interface, but there was a desire
to move to the atomic KMS interface. The vkms driver did everything we
needed, but we wanted KMS support natively in the driver without buffer
sharing and the ability to support an instance of VKMS per device. We first
looked at splitting vkms into a stub driver and a helper module that other
drivers could use to implement a virtual display, but this strategy ended up
being messy due to driver specific callbacks needed for buffer management.
Ultimately, it proved easier to import the vkms code as it mostly used core
drm helpers anyway.

Ryan Taylor (3):
  drm/amdgpu: create amdgpu_vkms (v2)
  drm/amdgpu: cleanup dce_virtual
  drm/amdgpu: replace dce_virtual with amdgpu_vkms (v3)

 drivers/gpu/drm/amd/amdgpu/Makefile  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h  |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c   |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 639 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |  26 +
 drivers/gpu/drm/amd/amdgpu/cik.c |  10 +-
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 780 ---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.h |  30 -
 drivers/gpu/drm/amd/amdgpu/nv.c  |  20 +-
 drivers/gpu/drm/amd/amdgpu/si.c  |   8 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c   |  10 +-
 drivers/gpu/drm/amd/amdgpu/vi.c  |  14 +-
 13 files changed, 700 insertions(+), 844 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.c
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.h


base-commit: cfd09f1e35231aa7f69845b6195e7d935e81421d
-- 
2.32.0

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


[PATCH 3/3] drm/amdgpu: replace dce_virtual with amdgpu_vkms

2021-07-12 Thread Ryan Taylor
Move dce_virtual into amdgpu_vkms and update all references to
dce_virtual with amdgpu_vkms.

Signed-off-by: Ryan Taylor 
---
 drivers/gpu/drm/amd/amdgpu/Makefile  |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 195 
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |   3 -
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 223 ---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.h |  30 ---
 drivers/gpu/drm/amd/amdgpu/nv.c  |  20 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c   |  10 +-
 drivers/gpu/drm/amd/amdgpu/vi.c  |  14 +-
 8 files changed, 218 insertions(+), 280 deletions(-)
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.c
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.h

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index dfcf3b39a2f6..fd9c06c5d263 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -119,8 +119,7 @@ amdgpu-y += \
 amdgpu-y += \
dce_v10_0.o \
dce_v11_0.o \
-   amdgpu_vkms.o \
-   dce_virtual.o
+   amdgpu_vkms.o
 
 # add GFX block
 amdgpu-y += \
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
index 58bd0d7b4602..1301df309aa4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
@@ -5,6 +5,15 @@
 #include 
 
 #include "amdgpu.h"
+#ifdef CONFIG_DRM_AMDGPU_SI
+#include "dce_v6_0.h"
+#endif
+#ifdef CONFIG_DRM_AMDGPU_CIK
+#include "dce_v8_0.h"
+#endif
+#include "dce_v10_0.h"
+#include "dce_v11_0.h"
+#include "ivsrcid/ivsrcid_vislands30.h"
 #include "amdgpu_vkms.h"
 #include "amdgpu_display.h"
 
@@ -408,3 +417,189 @@ int amdgpu_vkms_output_init(struct drm_device *dev,
 
return ret;
 }
+
+const struct drm_mode_config_funcs amdgpu_vkms_mode_funcs = {
+   .fb_create = amdgpu_display_user_framebuffer_create,
+   .atomic_check = drm_atomic_helper_check,
+   .atomic_commit = drm_atomic_helper_commit,
+};
+
+static int amdgpu_vkms_sw_init(void *handle)
+{
+   int r, i;
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+   adev_to_drm(adev)->max_vblank_count = 0;
+
+   adev_to_drm(adev)->mode_config.funcs = _vkms_mode_funcs;
+
+   adev_to_drm(adev)->mode_config.max_width = XRES_MAX;
+   adev_to_drm(adev)->mode_config.max_height = YRES_MAX;
+
+   adev_to_drm(adev)->mode_config.preferred_depth = 24;
+   adev_to_drm(adev)->mode_config.prefer_shadow = 1;
+
+   adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
+
+   r = amdgpu_display_modeset_create_props(adev);
+   if (r)
+   return r;
+
+   adev->amdgpu_vkms_output = kzalloc(sizeof(struct amdgpu_vkms_output) * 
adev->mode_info.num_crtc, GFP_KERNEL);
+
+   /* allocate crtcs, encoders, connectors */
+   for (i = 0; i < adev->mode_info.num_crtc; i++) {
+   r = amdgpu_vkms_output_init(adev_to_drm(adev), 
>amdgpu_vkms_output[i], i);
+   if (r)
+   return r;
+   }
+
+   drm_kms_helper_poll_init(adev_to_drm(adev));
+
+   adev->mode_info.mode_config_initialized = true;
+   return 0;
+}
+
+static int amdgpu_vkms_sw_fini(void *handle)
+{
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+   int i = 0;
+
+   for (i = 0; i < adev->mode_info.num_crtc; i++)
+   if (adev->mode_info.crtcs[i])
+   hrtimer_cancel(>mode_info.crtcs[i]->vblank_timer);
+
+   kfree(adev->mode_info.bios_hardcoded_edid);
+   kfree(adev->amdgpu_vkms_output);
+
+   drm_kms_helper_poll_fini(adev_to_drm(adev));
+
+   adev->mode_info.mode_config_initialized = false;
+   return 0;
+}
+
+static int amdgpu_vkms_hw_init(void *handle)
+{
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+   switch (adev->asic_type) {
+#ifdef CONFIG_DRM_AMDGPU_SI
+   case CHIP_TAHITI:
+   case CHIP_PITCAIRN:
+   case CHIP_VERDE:
+   case CHIP_OLAND:
+   dce_v6_0_disable_dce(adev);
+   break;
+#endif
+#ifdef CONFIG_DRM_AMDGPU_CIK
+   case CHIP_BONAIRE:
+   case CHIP_HAWAII:
+   case CHIP_KAVERI:
+   case CHIP_KABINI:
+   case CHIP_MULLINS:
+   dce_v8_0_disable_dce(adev);
+   break;
+#endif
+   case CHIP_FIJI:
+   case CHIP_TONGA:
+   dce_v10_0_disable_dce(adev);
+   break;
+   case CHIP_CARRIZO:
+   case CHIP_STONEY:
+   case CHIP_POLARIS10:
+   case CHIP_POLARIS11:
+   case CHIP_VEGAM:
+   dce_v11_0_disable_dce(adev);
+   break;
+   case CHIP_TOPAZ:
+#ifdef CONFIG_DRM_AMDGPU_SI
+   case CHIP_HAINAN:
+#endif
+   /* no DCE */
+   break;
+  

[PATCH 2/3] drm/amdgpu: cleanup dce_virtual

2021-07-12 Thread Ryan Taylor
Remove obsolete functions and variables from dce_virtual.

Signed-off-by: Ryan Taylor 
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 568 +--
 1 file changed, 3 insertions(+), 565 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 642c77533157..18369b47eac7 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -21,15 +21,9 @@
  *
  */
 
-#include 
 #include 
 
 #include "amdgpu.h"
-#include "amdgpu_pm.h"
-#include "amdgpu_i2c.h"
-#include "atom.h"
-#include "amdgpu_pll.h"
-#include "amdgpu_connectors.h"
 #ifdef CONFIG_DRM_AMDGPU_SI
 #include "dce_v6_0.h"
 #endif
@@ -43,339 +37,6 @@
 #include "amdgpu_display.h"
 #include "amdgpu_vkms.h"
 
-#define DCE_VIRTUAL_VBLANK_PERIOD 1666
-
-
-static void dce_virtual_set_display_funcs(struct amdgpu_device *adev);
-static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev);
-static int dce_virtual_connector_encoder_init(struct amdgpu_device *adev,
- int index);
-static int dce_virtual_pageflip(struct amdgpu_device *adev,
-   unsigned crtc_id);
-static enum hrtimer_restart dce_virtual_vblank_timer_handle(struct hrtimer 
*vblank_timer);
-static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device 
*adev,
-   int crtc,
-   enum 
amdgpu_interrupt_state state);
-
-static u32 dce_virtual_vblank_get_counter(struct amdgpu_device *adev, int crtc)
-{
-   return 0;
-}
-
-static void dce_virtual_page_flip(struct amdgpu_device *adev,
- int crtc_id, u64 crtc_base, bool async)
-{
-   return;
-}
-
-static int dce_virtual_crtc_get_scanoutpos(struct amdgpu_device *adev, int 
crtc,
-   u32 *vbl, u32 *position)
-{
-   *vbl = 0;
-   *position = 0;
-
-   return -EINVAL;
-}
-
-static bool dce_virtual_hpd_sense(struct amdgpu_device *adev,
-  enum amdgpu_hpd_id hpd)
-{
-   return true;
-}
-
-static void dce_virtual_hpd_set_polarity(struct amdgpu_device *adev,
- enum amdgpu_hpd_id hpd)
-{
-   return;
-}
-
-static u32 dce_virtual_hpd_get_gpio_reg(struct amdgpu_device *adev)
-{
-   return 0;
-}
-
-/**
- * dce_virtual_bandwidth_update - program display watermarks
- *
- * @adev: amdgpu_device pointer
- *
- * Calculate and program the display watermarks and line
- * buffer allocation (CIK).
- */
-static void dce_virtual_bandwidth_update(struct amdgpu_device *adev)
-{
-   return;
-}
-
-static int dce_virtual_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
- u16 *green, u16 *blue, uint32_t size,
- struct drm_modeset_acquire_ctx *ctx)
-{
-   return 0;
-}
-
-static void dce_virtual_crtc_destroy(struct drm_crtc *crtc)
-{
-   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-
-   drm_crtc_cleanup(crtc);
-   kfree(amdgpu_crtc);
-}
-
-static const struct drm_crtc_funcs dce_virtual_crtc_funcs = {
-   .cursor_set2 = NULL,
-   .cursor_move = NULL,
-   .gamma_set = dce_virtual_crtc_gamma_set,
-   .set_config = amdgpu_display_crtc_set_config,
-   .destroy = dce_virtual_crtc_destroy,
-   .page_flip_target = amdgpu_display_crtc_page_flip_target,
-   .get_vblank_counter = amdgpu_get_vblank_counter_kms,
-   .enable_vblank = amdgpu_enable_vblank_kms,
-   .disable_vblank = amdgpu_disable_vblank_kms,
-   .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
-};
-
-static void dce_virtual_crtc_dpms(struct drm_crtc *crtc, int mode)
-{
-   struct drm_device *dev = crtc->dev;
-   struct amdgpu_device *adev = drm_to_adev(dev);
-   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-   unsigned type;
-
-   switch (mode) {
-   case DRM_MODE_DPMS_ON:
-   amdgpu_crtc->enabled = true;
-   /* Make sure VBLANK interrupts are still enabled */
-   type = amdgpu_display_crtc_idx_to_irq_type(adev,
-   amdgpu_crtc->crtc_id);
-   amdgpu_irq_update(adev, >crtc_irq, type);
-   drm_crtc_vblank_on(crtc);
-   break;
-   case DRM_MODE_DPMS_STANDBY:
-   case DRM_MODE_DPMS_SUSPEND:
-   case DRM_MODE_DPMS_OFF:
-   drm_crtc_vblank_off(crtc);
-   amdgpu_crtc->enabled = false;
-   break;
-   }
-}
-
-
-static void dce_virtual_crtc_prepare(struct drm_crtc *crtc)
-{
-   dce_virtual_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
-}
-
-static void dce_virtual_crtc_commit(struct drm_crtc *crtc)
-{
-   dce_vi

[PATCH 0/3] drm/amdgpu: modernize virtual display feature

2021-07-12 Thread Ryan Taylor
The amdgpu vkms interface provides a virtual KMS interface for several use
cases: devices without display hardware, platforms where the actual display
hardware is not useful (e.g., servers), SR-IOV virtual functions, device
emulation/simulation, and device bring up prior to display hardware being
usable. We previously emulated a legacy KMS interface, but there was a desire
to move to the atomic KMS interface. The vkms driver did everything we
needed, but we wanted KMS support natively in the driver without buffer
sharing and the ability to support an instance of VKMS per device. We first
looked at splitting vkms into a stub driver and a helper module that other
drivers could use to implement a virtual display, but this strategy ended up
being messy due to driver specific callbacks needed for buffer management.
Ultimately, it proved easier to import the vkms code as it mostly used core
drm helpers anyway.

Ryan Taylor (3):
  drm/amdgpu: create amdgpu_vkms
  drm/amdgpu: cleanup dce_virtual
  drm/amdgpu: replace dce_virtual with amdgpu_vkms

 drivers/gpu/drm/amd/amdgpu/Makefile  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h  |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c   |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 605 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |  26 +
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 780 ---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.h |  30 -
 drivers/gpu/drm/amd/amdgpu/nv.c  |  20 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c   |  10 +-
 drivers/gpu/drm/amd/amdgpu/vi.c  |  14 +-
 11 files changed, 657 insertions(+), 835 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.c
 delete mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.h

-- 
2.32.0

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


[PATCH 1/3] drm/amdgpu: create amdgpu_vkms

2021-07-12 Thread Ryan Taylor
Modify the VKMS driver into an api that dce_virtual can use to create
virtual displays that obey drm's atomic modesetting api.

Signed-off-by: Ryan Taylor 
---
 drivers/gpu/drm/amd/amdgpu/Makefile  |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu.h  |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c   |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 410 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h |  29 ++
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c |  23 +-
 7 files changed, 457 insertions(+), 11 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.h

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 7d292485ca7c..dfcf3b39a2f6 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -119,6 +119,7 @@ amdgpu-y += \
 amdgpu-y += \
dce_v10_0.o \
dce_v11_0.o \
+   amdgpu_vkms.o \
dce_virtual.o
 
 # add GFX block
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index d14b4968a026..a0198963fc8a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -912,6 +912,7 @@ struct amdgpu_device {
 
/* display */
boolenable_virtual_display;
+   struct amdgpu_vkms_output   *amdgpu_vkms_output;
struct amdgpu_mode_info mode_info;
/* For pre-DCE11. DCE11 and later are in "struct amdgpu_device->dm" */
struct work_struct  hotplug_work;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 179f2d01a082..5c774d6625e4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1222,7 +1222,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
int ret, retry = 0;
bool supports_atomic = false;
 
-   if (!amdgpu_virtual_display &&
+   if (amdgpu_virtual_display ||
amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK))
supports_atomic = true;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index 09b048647523..5a143ca02cf9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -344,7 +344,7 @@ int amdgpu_fbdev_init(struct amdgpu_device *adev)
}
 
/* disable all the possible outputs/crtcs before entering KMS mode */
-   if (!amdgpu_device_has_dc_support(adev))
+   if (!amdgpu_device_has_dc_support(adev) && !amdgpu_virtual_display)
drm_helper_disable_unused_functions(adev_to_drm(adev));
 
drm_fb_helper_initial_config(>helper, bpp_sel);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
new file mode 100644
index ..58bd0d7b4602
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
@@ -0,0 +1,410 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include 
+#include 
+#include 
+
+#include "amdgpu.h"
+#include "amdgpu_vkms.h"
+#include "amdgpu_display.h"
+
+/**
+ * DOC: amdgpu_vkms
+ *
+ * The amdgpu vkms interface provides a virtual KMS interface for several use
+ * cases: devices without display hardware, platforms where the actual display
+ * hardware is not useful (e.g., servers), SR-IOV virtual functions, device
+ * emulation/simulation, and device bring up prior to display hardware being
+ * usable. We previously emulated a legacy KMS interface, but there was a 
desire
+ * to move to the atomic KMS interface. The vkms driver did everything we
+ * needed, but we wanted KMS support natively in the driver without buffer
+ * sharing and the ability to support an instance of VKMS per device. We first
+ * looked at splitting vkms into a stub driver and a helper module that other
+ * drivers could use to implement a virtual display, but this strategy ended up
+ * being messy due to driver specific callbacks needed for buffer management.
+ * Ultimately, it proved easier to import the vkms code as it mostly used core
+ * drm helpers anyway.
+ */
+
+static const u32 amdgpu_vkms_formats[] = {
+   DRM_FORMAT_XRGB,
+};
+
+static enum hrtimer_restart amdgpu_vkms_vblank_simulate(struct hrtimer *timer)
+{
+   struct amdgpu_vkms_output *output = container_of(timer,
+struct 
amdgpu_vkms_output,
+vblank_hrtimer);
+   struct drm_crtc *crtc = >crtc;
+   u64 ret_overrun;
+   bool ret;
+
+   ret_overrun = hrtimer_forward_now(>vblank_hrtimer,
+ output->period_ns);
+   WARN_ON(ret_overrun != 1);
+
+   ret = drm_crtc_handle_vbl

[PATCH] drm/amd/pm: add swsmu init documentation

2021-01-06 Thread Ryan Taylor
Documents functions used in swsmu initialization.

Signed-off-by: Ryan Taylor 
Reviewed-by: Alex Deucher 
---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 94 ++-
 1 file changed, 93 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c 
b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index d80f7f8efdcd..82099cb3d00a 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -376,6 +376,15 @@ static int smu_get_driver_allowed_feature_mask(struct 
smu_context *smu)
return ret;
 }
 
+/**
+ * smu_set_funcs - Set ASIC specific SMU communication tools and data.
+ * @adev: amdgpu_device pointer
+ *
+ * Set hooks ( pptable_funcs), maps ( cmn2asic_mapping) and
+ * basic ASIC information (is_apu, od_enabled, etc.).
+ *
+ * Returns 0 on success, negative error code on failure.
+ */
 static int smu_set_funcs(struct amdgpu_device *adev)
 {
struct smu_context *smu = >smu;
@@ -417,6 +426,15 @@ static int smu_set_funcs(struct amdgpu_device *adev)
return 0;
 }
 
+/**
+ * smu_early_init - Early init for the SMU IP block.
+ * @handle: amdgpu_device pointer
+ *
+ * Perform basic initialization of  smu_context. Set ASIC specific SMU
+ * communication tools and data using smu_set_funcs().
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
 static int smu_early_init(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -424,10 +442,12 @@ static int smu_early_init(void *handle)
 
smu->adev = adev;
smu->pm_enabled = !!amdgpu_dpm;
+   /* Assume ASIC is not an APU until updated in smu_set_funcs(). */
smu->is_apu = false;
mutex_init(>mutex);
mutex_init(>smu_baco.mutex);
smu->smu_baco.state = SMU_BACO_STATE_EXIT;
+   /* Disable baco support until the SMU engine is running. */
smu->smu_baco.platform_support = false;
 
return smu_set_funcs(adev);
@@ -472,6 +492,17 @@ static int smu_set_default_dpm_table(struct smu_context 
*smu)
return ret;
 }
 
+
+/**
+ * smu_late_init - Finish setting up the SMU IP block.
+ * @adev: amdgpu_device pointer
+ *
+ * Setup SMU tables/values used by other driver subsystems and in userspace
+ * (Overdrive, UMD power states, etc.). Perform final SMU configuration (set
+ * performance level, update display config etc.).
+ *
+ * Returns 0 on success, negative error code on failure.
+ */
 static int smu_late_init(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -514,6 +545,8 @@ static int smu_late_init(void *handle)
 
smu_get_fan_parameters(smu);
 
+   /* Sets performance level, power profile mode and display
+* configuration. */
smu_handle_task(>smu,
smu->smu_dpm.dpm_level,
AMD_PP_TASK_COMPLETE_INIT,
@@ -601,7 +634,7 @@ static int smu_fini_fb_allocations(struct smu_context *smu)
 /**
  * smu_alloc_memory_pool - allocate memory pool in the system memory
  *
- * @smu: amdgpu_device pointer
+ * @smu: smu_context pointer
  *
  * This memory pool will be used for SMC use and msg SetSystemVirtualDramAddr
  * and DramLogSetDramAddr can notify it changed.
@@ -701,6 +734,15 @@ static void smu_free_dummy_read_table(struct smu_context 
*smu)
memset(dummy_read_1_table, 0, sizeof(struct smu_table));
 }
 
+/**
+ * smu_smc_table_sw_init -  Initialize shared driver/SMU communication tools.
+ * @smu: smu_context pointer
+ *
+ * Allocate VRAM/DRAM for shared memory objects (SMU tables, memory pool, 
etc.).
+ * Initialize i2c.
+ *
+ * Returns 0 on success, negative error code on failure.
+ */
 static int smu_smc_table_sw_init(struct smu_context *smu)
 {
int ret;
@@ -799,6 +841,18 @@ static void smu_interrupt_work_fn(struct work_struct *work)
mutex_unlock(>mutex);
 }
 
+/**
+ * smu_sw_init - Software init for the SMU IP block.
+ * @handle: amdgpu_device pointer
+ *
+ * Configure  smu_context with boot default performance profiles (power
+ * profile, workload, etc.) and power savings optimizations (powergate
+ * VCN/JPEG). Request the SMU's firmware from the kernel. Initialize features,
+ * locks, and kernel work queues. Initialize driver/SMU communication tools
+ * using smu_smc_table_sw_init(). Register the interrupt handler.
+ *
+ * Returns 0 on success, negative error code on failure.
+ */
 static int smu_sw_init(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -820,6 +874,7 @@ static int smu_sw_init(void *handle)
INIT_WORK(>interrupt_work, smu_interrupt_work_fn);
atomic64_set(>throttle_int_counter, 0);
smu->watermarks_bitmap = 0;
+
smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
smu->default_power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
 
@@ -914,6 +969,18 @@ static int smu_get_th

[PATCH] drm/amd/pm: add pptable_funcs documentation (v2)

2020-12-17 Thread Ryan Taylor
Documents the hooks in struct pptable_funcs.

v2: Improved documentation accuracy.
Signed-off-by: Ryan Taylor 
---
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 525 
 1 file changed, 525 insertions(+)

diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h 
b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
index 4bdbcce7092d..b6578550da46 100644
--- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
@@ -469,120 +469,645 @@ struct smu_context
 
 struct i2c_adapter;
 
+/**
+ * struct pptable_funcs - Callbacks used to interact with the SMU.
+ */
 struct pptable_funcs {
+   /**
+* @run_btc: Calibrate voltage/frequency curve to fit the system's
+*   power delivery and voltage margins. Required for adaptive
+*   voltage frequency scaling (AVFS).
+*/
int (*run_btc)(struct smu_context *smu);
+
+   /**
+* @get_allowed_feature_mask: Get allowed feature mask.
+* _mask: Array to store feature mask.
+* : Elements in _mask.
+*/
int (*get_allowed_feature_mask)(struct smu_context *smu, uint32_t 
*feature_mask, uint32_t num);
+
+   /**
+* @get_current_power_state: Get the current power state.
+*
+* Return: Current power state on success, negative errno on failure.
+*/
enum amd_pm_state_type (*get_current_power_state)(struct smu_context 
*smu);
+
+   /**
+* @set_default_dpm_table: Populate the dpm table with defaults.
+*/
int (*set_default_dpm_table)(struct smu_context *smu);
+
int (*set_power_state)(struct smu_context *smu);
+
+   /**
+* @populate_umd_state_clk: Populate the UMD power state table with
+*  defaults.
+*/
int (*populate_umd_state_clk)(struct smu_context *smu);
+
+   /**
+* @print_clk_levels: Print DPM clock levels for a clock domain
+*to buffer. Star current level.
+*
+* Used for sysfs interfaces.
+*/
int (*print_clk_levels)(struct smu_context *smu, enum smu_clk_type 
clk_type, char *buf);
+
+   /**
+* @force_clk_levels: Set a range of allowed DPM levels for a clock
+*domain.
+* _type: Clock domain.
+* : Range of allowed DPM levels.
+*/
int (*force_clk_levels)(struct smu_context *smu, enum smu_clk_type 
clk_type, uint32_t mask);
+
+   /**
+* @od_edit_dpm_table: Edit the custom overdrive DPM table.
+* : Type of edit.
+* : Edit parameters.
+* : Size of 
+*/
int (*od_edit_dpm_table)(struct smu_context *smu,
 enum PP_OD_DPM_TABLE_COMMAND type,
 long *input, uint32_t size);
+
+   /**
+* @get_clock_by_type_with_latency: Get the speed and latency of a clock
+*  domain.
+*/
int (*get_clock_by_type_with_latency)(struct smu_context *smu,
  enum smu_clk_type clk_type,
  struct
  pp_clock_levels_with_latency
  *clocks);
+   /**
+* @get_clock_by_type_with_voltage: Get the speed and voltage of a clock
+*  domain.
+*/
+   int (*get_clock_by_type_with_voltage)(struct smu_context *smu,
+ enum amd_pp_clock_type type,
+ struct
+ pp_clock_levels_with_voltage
+ *clocks);
+
+   /**
+* @get_power_profile_mode: Print all power profile modes to
+*  buffer. Star current mode.
+*/
int (*get_power_profile_mode)(struct smu_context *smu, char *buf);
+
+   /**
+* @set_power_profile_mode: Set a power profile mode. Also used to
+*  create/set custom power profile modes.
+* : Power profile mode parameters.
+* : Size of 
+*/
int (*set_power_profile_mode)(struct smu_context *smu, long *input, 
uint32_t size);
+
+   /**
+* @dpm_set_vcn_enable: Enable/disable VCN engine dynamic power
+*  management.
+*/
int (*dpm_set_vcn_enable)(struct smu_context *smu, bool enable);
+
+   /**
+* @dpm_set_jpeg_enable: Enable/disable JPEG engine dynamic power
+*   management.
+*/
int (*dpm_set_jpeg_enable)(struct smu_context *smu, bool enable);
+
+   /**
+* @read_sensor: Read data from a sensor.
+* : Sensor to read data from.
+* : Sensor reading.
+* : Size

[PATCH] drm/amd/pm: fix smu_v11_0_init_power power_context allocation

2020-11-12 Thread Ryan Taylor
Allocate smu_power->power_context to size of smu_11_0_power_context instead of
smu_11_0_dpm_context.

Signed-off-by: Ryan Taylor 
Reviewed-by: Alex Deucher 
Reviewed-by: Evan Quan 
---
 drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
index b880c72c322c..9ec5e30edbee 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
@@ -469,11 +469,11 @@ int smu_v11_0_init_power(struct smu_context *smu)
 {
struct smu_power_context *smu_power = >smu_power;
 
-   smu_power->power_context = kzalloc(sizeof(struct smu_11_0_dpm_context),
+   smu_power->power_context = kzalloc(sizeof(struct 
smu_11_0_power_context),
   GFP_KERNEL);
if (!smu_power->power_context)
return -ENOMEM;
-   smu_power->power_context_size = sizeof(struct smu_11_0_dpm_context);
+   smu_power->power_context_size = sizeof(struct smu_11_0_power_context);
 
return 0;
 }
-- 
2.29.2

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


[PATCH] drm/include: add PP_FEATURE_MASK comments (v3)

2020-09-23 Thread Ryan Taylor
Documents PP_FEATURE_MASK enum.
Provides instructions on how to use ppfeaturemasks.

v2: improve enum definitions and add kernel command line parameters to
ppfeaturemask instructions
v3: fix alignment issues

Signed-off-by: Ryan Taylor 
Reviewed-by: Alex Deucher 
---
 drivers/gpu/drm/amd/include/amd_shared.h | 28 
 1 file changed, 28 insertions(+)

diff --git a/drivers/gpu/drm/amd/include/amd_shared.h 
b/drivers/gpu/drm/amd/include/amd_shared.h
index e98c84ef206f..6f1469742b3a 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -128,6 +128,34 @@ enum amd_powergating_state {
 #define AMD_PG_SUPPORT_ATHUB   (1 << 16)
 #define AMD_PG_SUPPORT_JPEG(1 << 17)
 
+/**
+ * enum PP_FEATURE_MASK - Used to mask power play features.
+ *
+ * @PP_SCLK_DPM_MASK: Dynamic adjustment of the system (graphics) clock.
+ * @PP_MCLK_DPM_MASK: Dynamic adjustment of the memory clock.
+ * @PP_PCIE_DPM_MASK: Dynamic adjustment of PCIE clocks and lanes.
+ * @PP_SCLK_DEEP_SLEEP_MASK: System (graphics) clock deep sleep.
+ * @PP_POWER_CONTAINMENT_MASK: Power containment.
+ * @PP_UVD_HANDSHAKE_MASK: Unified video decoder handshake.
+ * @PP_SMC_VOLTAGE_CONTROL_MASK: Dynamic voltage control.
+ * @PP_VBI_TIME_SUPPORT_MASK: Vertical blank interval support.
+ * @PP_ULV_MASK: Ultra low voltage.
+ * @PP_ENABLE_GFX_CG_THRU_SMU: SMU control of GFX engine clockgating.
+ * @PP_CLOCK_STRETCH_MASK: Clock stretching.
+ * @PP_OD_FUZZY_FAN_CONTROL_MASK: Overdrive fuzzy fan control.
+ * @PP_SOCCLK_DPM_MASK: Dynamic adjustment of the SoC clock.
+ * @PP_DCEFCLK_DPM_MASK: Dynamic adjustment of the Display Controller Engine 
Fabric clock.
+ * @PP_OVERDRIVE_MASK: Over- and under-clocking support.
+ * @PP_GFXOFF_MASK: Dynamic graphics engine power control.
+ * @PP_ACG_MASK: Adaptive clock generator.
+ * @PP_STUTTER_MODE: Stutter mode.
+ * @PP_AVFS_MASK: Adaptive voltage and frequency scaling.
+ *
+ * To override these settings on boot, append amdgpu.ppfeaturemask= to
+ * the kernel's command line parameters. This is usually done through a 
system's
+ * boot loader (E.g. GRUB). If manually loading the driver, pass
+ * ppfeaturemask= as a modprobe parameter.
+ */
 enum PP_FEATURE_MASK {
PP_SCLK_DPM_MASK = 0x1,
PP_MCLK_DPM_MASK = 0x2,
-- 
2.28.0

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


Re: [PATCH v2] Add PP_FEATURE_MASK comments

2020-09-23 Thread Ryan Taylor
I see, I'll add it to the end next time then.

Ryan

On 9/23/20 10:13 AM, Luben Tuikov wrote:
> On 2020-09-23 12:31, Ryan Taylor wrote:
>> Thanks Luben,
>>
>> I'll make these revisions and try out Git's patch version setting.
> 
> Well, Git's own patch revision command line option (-v of git-format-patch)
> would put it in the "[PATCH v] Title text" as you had it here, and I'd
> presumed that you'd used that command line option. Our practice
> here is to manually do "[PATCH] Title text (v)", where the patch version
> is postfixed.
> 
> Regards,
> Luben
> 
>>
>> Best,
>> Ryan
>>
>> On 9/23/20 7:40 AM, Luben Tuikov wrote:
>>> On 2020-09-22 11:55, Ryan Taylor wrote:
>>>> Documents PP_FEATURE_MASK enum.
>>>> Provides instructions on how to use ppfeaturemasks.
>>>>
>>>> v2: Improved enum definitions. Adds kernel command line
>>>> parameters to ppfeaturemask instructions.
>>>>
>>>> Signed-off-by: Ryan Taylor 
>>>> Reviewed-by: Alex Deucher 
>>>> ---
>>>>  drivers/gpu/drm/amd/include/amd_shared.h | 28 
>>>>  1 file changed, 28 insertions(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/amd/include/amd_shared.h 
>>>> b/drivers/gpu/drm/amd/include/amd_shared.h
>>>> index e98c84ef206f..7c84d5beb600 100644
>>>> --- a/drivers/gpu/drm/amd/include/amd_shared.h
>>>> +++ b/drivers/gpu/drm/amd/include/amd_shared.h
>>>> @@ -128,6 +128,34 @@ enum amd_powergating_state {
>>>>  #define AMD_PG_SUPPORT_ATHUB  (1 << 16)
>>>>  #define AMD_PG_SUPPORT_JPEG   (1 << 17)
>>>>  
>>>> +/**
>>>> +* enum PP_FEATURE_MASK - Used to mask power play features.
>>>> +*
>>>> +* @PP_SCLK_DPM_MASK: Dynamic adjustment of the system (graphics) clock.
>>>> +* @PP_MCLK_DPM_MASK: Dynamic adjustment of the memory clock.
>>>> +* @PP_PCIE_DPM_MASK: Dynamic adjustment of PCIE clocks and lanes.
>>>> +* @PP_SCLK_DEEP_SLEEP_MASK: System (graphics) clock deep sleep.
>>>> +* @PP_POWER_CONTAINMENT_MASK: Power containment.
>>>> +* @PP_UVD_HANDSHAKE_MASK: Unified video decoder handshake.
>>>> +* @PP_SMC_VOLTAGE_CONTROL_MASK: Dynamic voltage control.
>>>> +* @PP_VBI_TIME_SUPPORT_MASK: Vertical blank interval support.
>>>> +* @PP_ULV_MASK: Ultra low voltage.
>>>> +* @PP_ENABLE_GFX_CG_THRU_SMU: SMU control of GFX engine clockgating.
>>>> +* @PP_CLOCK_STRETCH_MASK: Clock stretching.
>>>> +* @PP_OD_FUZZY_FAN_CONTROL_MASK: Overdrive fuzzy fan control.
>>>> +* @PP_SOCCLK_DPM_MASK: Dynamic adjustment of the SoC clock.
>>>> +* @PP_DCEFCLK_DPM_MASK: Dynamic adjustment of the Display Controller 
>>>> Engine Fabric clock.
>>>> +* @PP_OVERDRIVE_MASK: Over- and under-clocking support.
>>>> +* @PP_GFXOFF_MASK: Dynamic graphics engine power control.
>>>> +* @PP_ACG_MASK: Adaptive clock generator.
>>>> +* @PP_STUTTER_MODE: Stutter mode.
>>>> +* @PP_AVFS_MASK: Adaptive voltage and frequency scaling.
>>>> +*
>>>> +* To override these settings on boot, append amdgpu.ppfeaturemask= 
>>>> to
>>>> +* the kernel's command line parameters. This is usually done through a 
>>>> system's
>>>> +* boot loader (E.g. GRUB). If manually loading the driver, pass
>>>> +* ppfeaturemask= as a modprobe parameter.
>>>> +*/
>>>
>>> Alignment should be:
>>>
>>> /**
>>>  *
>>>  *
>>>  ...
>>>  */
>>>
>>> Also, you can use Git's own patch version setting,
>>> but I've seen here we usually put it in the commit title.
>>> (Remember, titles do not end with a period.) Something like
>>>
>>> Commit title (v2)
>>>
>>> I don't mind using either. Not sure what the direction is
>>> on this one.
>>>
>>> Regards,
>>> Luben
>>>
>>>>  enum PP_FEATURE_MASK {
>>>>PP_SCLK_DPM_MASK = 0x1,
>>>>PP_MCLK_DPM_MASK = 0x2,
>>>>
>>>
> 
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH v2] Add PP_FEATURE_MASK comments

2020-09-23 Thread Ryan Taylor
Thanks Luben,

I'll make these revisions and try out Git's patch version setting.

Best,
Ryan

On 9/23/20 7:40 AM, Luben Tuikov wrote:
> On 2020-09-22 11:55, Ryan Taylor wrote:
>> Documents PP_FEATURE_MASK enum.
>> Provides instructions on how to use ppfeaturemasks.
>>
>> v2: Improved enum definitions. Adds kernel command line
>> parameters to ppfeaturemask instructions.
>>
>> Signed-off-by: Ryan Taylor 
>> Reviewed-by: Alex Deucher 
>> ---
>>  drivers/gpu/drm/amd/include/amd_shared.h | 28 
>>  1 file changed, 28 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/include/amd_shared.h 
>> b/drivers/gpu/drm/amd/include/amd_shared.h
>> index e98c84ef206f..7c84d5beb600 100644
>> --- a/drivers/gpu/drm/amd/include/amd_shared.h
>> +++ b/drivers/gpu/drm/amd/include/amd_shared.h
>> @@ -128,6 +128,34 @@ enum amd_powergating_state {
>>  #define AMD_PG_SUPPORT_ATHUB(1 << 16)
>>  #define AMD_PG_SUPPORT_JPEG (1 << 17)
>>  
>> +/**
>> +* enum PP_FEATURE_MASK - Used to mask power play features.
>> +*
>> +* @PP_SCLK_DPM_MASK: Dynamic adjustment of the system (graphics) clock.
>> +* @PP_MCLK_DPM_MASK: Dynamic adjustment of the memory clock.
>> +* @PP_PCIE_DPM_MASK: Dynamic adjustment of PCIE clocks and lanes.
>> +* @PP_SCLK_DEEP_SLEEP_MASK: System (graphics) clock deep sleep.
>> +* @PP_POWER_CONTAINMENT_MASK: Power containment.
>> +* @PP_UVD_HANDSHAKE_MASK: Unified video decoder handshake.
>> +* @PP_SMC_VOLTAGE_CONTROL_MASK: Dynamic voltage control.
>> +* @PP_VBI_TIME_SUPPORT_MASK: Vertical blank interval support.
>> +* @PP_ULV_MASK: Ultra low voltage.
>> +* @PP_ENABLE_GFX_CG_THRU_SMU: SMU control of GFX engine clockgating.
>> +* @PP_CLOCK_STRETCH_MASK: Clock stretching.
>> +* @PP_OD_FUZZY_FAN_CONTROL_MASK: Overdrive fuzzy fan control.
>> +* @PP_SOCCLK_DPM_MASK: Dynamic adjustment of the SoC clock.
>> +* @PP_DCEFCLK_DPM_MASK: Dynamic adjustment of the Display Controller Engine 
>> Fabric clock.
>> +* @PP_OVERDRIVE_MASK: Over- and under-clocking support.
>> +* @PP_GFXOFF_MASK: Dynamic graphics engine power control.
>> +* @PP_ACG_MASK: Adaptive clock generator.
>> +* @PP_STUTTER_MODE: Stutter mode.
>> +* @PP_AVFS_MASK: Adaptive voltage and frequency scaling.
>> +*
>> +* To override these settings on boot, append amdgpu.ppfeaturemask= to
>> +* the kernel's command line parameters. This is usually done through a 
>> system's
>> +* boot loader (E.g. GRUB). If manually loading the driver, pass
>> +* ppfeaturemask= as a modprobe parameter.
>> +*/
> 
> Alignment should be:
> 
> /**
>  *
>  *
>  ...
>  */
> 
> Also, you can use Git's own patch version setting,
> but I've seen here we usually put it in the commit title.
> (Remember, titles do not end with a period.) Something like
> 
>   Commit title (v2)
> 
> I don't mind using either. Not sure what the direction is
> on this one.
> 
> Regards,
> Luben
> 
>>  enum PP_FEATURE_MASK {
>>  PP_SCLK_DPM_MASK = 0x1,
>>  PP_MCLK_DPM_MASK = 0x2,
>>
> 
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH v2] Add PP_FEATURE_MASK comments

2020-09-22 Thread Ryan Taylor
Documents PP_FEATURE_MASK enum.
Provides instructions on how to use ppfeaturemasks.

v2: Improved enum definitions. Adds kernel command line
parameters to ppfeaturemask instructions.

Signed-off-by: Ryan Taylor 
Reviewed-by: Alex Deucher 
---
 drivers/gpu/drm/amd/include/amd_shared.h | 28 
 1 file changed, 28 insertions(+)

diff --git a/drivers/gpu/drm/amd/include/amd_shared.h 
b/drivers/gpu/drm/amd/include/amd_shared.h
index e98c84ef206f..7c84d5beb600 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -128,6 +128,34 @@ enum amd_powergating_state {
 #define AMD_PG_SUPPORT_ATHUB   (1 << 16)
 #define AMD_PG_SUPPORT_JPEG(1 << 17)
 
+/**
+* enum PP_FEATURE_MASK - Used to mask power play features.
+*
+* @PP_SCLK_DPM_MASK: Dynamic adjustment of the system (graphics) clock.
+* @PP_MCLK_DPM_MASK: Dynamic adjustment of the memory clock.
+* @PP_PCIE_DPM_MASK: Dynamic adjustment of PCIE clocks and lanes.
+* @PP_SCLK_DEEP_SLEEP_MASK: System (graphics) clock deep sleep.
+* @PP_POWER_CONTAINMENT_MASK: Power containment.
+* @PP_UVD_HANDSHAKE_MASK: Unified video decoder handshake.
+* @PP_SMC_VOLTAGE_CONTROL_MASK: Dynamic voltage control.
+* @PP_VBI_TIME_SUPPORT_MASK: Vertical blank interval support.
+* @PP_ULV_MASK: Ultra low voltage.
+* @PP_ENABLE_GFX_CG_THRU_SMU: SMU control of GFX engine clockgating.
+* @PP_CLOCK_STRETCH_MASK: Clock stretching.
+* @PP_OD_FUZZY_FAN_CONTROL_MASK: Overdrive fuzzy fan control.
+* @PP_SOCCLK_DPM_MASK: Dynamic adjustment of the SoC clock.
+* @PP_DCEFCLK_DPM_MASK: Dynamic adjustment of the Display Controller Engine 
Fabric clock.
+* @PP_OVERDRIVE_MASK: Over- and under-clocking support.
+* @PP_GFXOFF_MASK: Dynamic graphics engine power control.
+* @PP_ACG_MASK: Adaptive clock generator.
+* @PP_STUTTER_MODE: Stutter mode.
+* @PP_AVFS_MASK: Adaptive voltage and frequency scaling.
+*
+* To override these settings on boot, append amdgpu.ppfeaturemask= to
+* the kernel's command line parameters. This is usually done through a system's
+* boot loader (E.g. GRUB). If manually loading the driver, pass
+* ppfeaturemask= as a modprobe parameter.
+*/
 enum PP_FEATURE_MASK {
PP_SCLK_DPM_MASK = 0x1,
PP_MCLK_DPM_MASK = 0x2,
-- 
2.28.0

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


[PATCH v3] amdgpu: Add initial kernel documentation for the amd_ip_block_type structure

2020-09-21 Thread Ryan Taylor
From: Ryan Taylor 

Added IP block section to amdgpu.rst.
Added more documentation to amd_ip_funcs.
Created documentation for amd_ip_block_type.

v2: Provides a more detailed DOC section on IP blocks.
v3: Clarifies the IP block list. Adds info on IP block enumeration.

Signed-off-by: Ryan Taylor 
Reviewed-by: Alex Deucher 
---
 Documentation/gpu/amdgpu.rst |  9 +++
 drivers/gpu/drm/amd/include/amd_shared.h | 87 +---
 2 files changed, 71 insertions(+), 25 deletions(-)

diff --git a/Documentation/gpu/amdgpu.rst b/Documentation/gpu/amdgpu.rst
index 29ca5f5feb35..57047dcb8d19 100644
--- a/Documentation/gpu/amdgpu.rst
+++ b/Documentation/gpu/amdgpu.rst
@@ -70,6 +70,15 @@ Interrupt Handling
 .. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
:internal:
 
+IP Blocks
+--
+
+.. kernel-doc:: drivers/gpu/drm/amd/include/amd_shared.h
+   :doc: IP Blocks
+
+.. kernel-doc:: drivers/gpu/drm/amd/include/amd_shared.h
+   :identifiers: amd_ip_block_type amd_ip_funcs
+
 AMDGPU XGMI Support
 ===
 
diff --git a/drivers/gpu/drm/amd/include/amd_shared.h 
b/drivers/gpu/drm/amd/include/amd_shared.h
index e98c84ef206f..6b8a40051f41 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -47,6 +47,40 @@ enum amd_apu_flags {
AMD_APU_IS_RENOIR = 0x0008UL,
 };
 
+/**
+* DOC: IP Blocks
+*
+* GPUs are composed of IP (intellectual property) blocks. These
+* IP blocks provide various functionalities: display, graphics,
+* video decode, etc. The IP blocks that comprise a particular GPU
+* are listed in the GPU's respective SoC file. amdgpu_device.c
+* acquires the list of IP blocks for the GPU in use on initialization.
+* It can then operate on this list to perform standard driver operations
+* such as: init, fini, suspend, resume, etc.
+* 
+*
+* IP block implementations are named using the following convention:
+* _v (E.g.: gfx_v6_0).
+*/
+
+/**
+* enum amd_ip_block_type - Used to classify IP blocks by functionality.
+*
+* @AMD_IP_BLOCK_TYPE_COMMON: GPU Family
+* @AMD_IP_BLOCK_TYPE_GMC: Graphics Memory Controller
+* @AMD_IP_BLOCK_TYPE_IH: Interrupt Handler
+* @AMD_IP_BLOCK_TYPE_SMC: System Management Controller
+* @AMD_IP_BLOCK_TYPE_PSP: Platform Security Processor
+* @AMD_IP_BLOCK_TYPE_DCE: Display and Compositing Engine
+* @AMD_IP_BLOCK_TYPE_GFX: Graphics and Compute Engine
+* @AMD_IP_BLOCK_TYPE_SDMA: System DMA Engine
+* @AMD_IP_BLOCK_TYPE_UVD: Unified Video Decoder
+* @AMD_IP_BLOCK_TYPE_VCE: Video Compression Engine
+* @AMD_IP_BLOCK_TYPE_ACP: Audio Co-Processor
+* @AMD_IP_BLOCK_TYPE_VCN: Video Core/Codec Next
+* @AMD_IP_BLOCK_TYPE_MES: Micro-Engine Scheduler
+* @AMD_IP_BLOCK_TYPE_JPEG: JPEG Engine
+*/
 enum amd_ip_block_type {
AMD_IP_BLOCK_TYPE_COMMON,
AMD_IP_BLOCK_TYPE_GMC,
@@ -165,56 +199,59 @@ enum DC_DEBUG_MASK {
 };
 
 enum amd_dpm_forced_level;
+
 /**
  * struct amd_ip_funcs - general hooks for managing amdgpu IP Blocks
+ * @name: Name of IP block
+ * @early_init: sets up early driver state (pre sw_init),
+ *  does not configure hw - Optional
+ * @late_init: sets up late driver/hw state (post hw_init) - Optional
+ * @sw_init: sets up driver state, does not configure hw
+ * @sw_fini: tears down driver state, does not configure hw
+ * @hw_init: sets up the hw state
+ * @hw_fini: tears down the hw state
+ * @late_fini: final cleanup
+ * @suspend: handles IP specific hw/sw changes for suspend
+ * @resume: handles IP specific hw/sw changes for resume
+ * @is_idle: returns current IP block idle status
+ * @wait_for_idle: poll for idle
+ * @check_soft_reset: check soft reset the IP block
+ * @pre_soft_reset: pre soft reset the IP block
+ * @soft_reset: soft reset the IP block
+ * @post_soft_reset: post soft reset the IP block
+ * @set_clockgating_state: enable/disable cg for the IP block
+ * @set_powergating_state: enable/disable pg for the IP block
+ * @get_clockgating_state: get current clockgating status
+ * @enable_umd_pstate: enable UMD powerstate
+ *
+ * These hooks provide an interface for controlling the operational state
+ * of IP blocks. After acquiring a list of IP blocks for the GPU in use,
+ * the driver can make chip-wide state changes by walking this list and
+ * making calls to hooks from each IP block. This list is ordered to ensure
+ * that the driver initializes the IP blocks in a safe sequence.
  */
 struct amd_ip_funcs {
-   /** @name: Name of IP block */
char *name;
-   /**
-* @early_init:
-*
-* sets up early driver state (pre sw_init),
-* does not configure hw - Optional
-*/
int (*early_init)(void *handle);
-   /** @late_init: sets up late driver/hw state (post hw_init) - Optional 
*/
int (*late_init)(void *handle);
-   /** @sw_init: sets up driver state, does not configure hw */
int (*sw_init)(void *handle);
-   /** @sw_fini: tears down driver state, does