[PATCH 3/3] amdgpu/pm: set pp_dpm_dcefclk to readonly on smu_v11 gpus

2021-04-16 Thread Darren Powell
Writing to dcefclk causes the gpu to become unresponsive, and requires a reboot.
Patch prevents user from successfully writing to file pp_dpm_dcefclk on smu_vv11
parts and gives better user feedback that this operation is not allowed.

Signed-off-by: Darren Powell 
---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c 
b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 204e34549013..317e9b47db53 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -1891,6 +1891,19 @@ static int default_attr_update(struct amdgpu_device 
*adev, struct amdgpu_device_
}
}
 
+   if (DEVICE_ATTR_IS(pp_dpm_dcefclk)) {
+   /* SMU MP1 does not support dcefclk level setting */
+   if (asic_type == CHIP_NAVI10  ||
+   asic_type == CHIP_NAVI14  ||
+   asic_type == CHIP_NAVI12  ||
+   asic_type == CHIP_SIENNA_CICHLID  ||
+   asic_type == CHIP_NAVY_FLOUNDER   ||
+   asic_type == CHIP_DIMGREY_CAVEFISH  ) {
+   dev_attr->attr.mode &= ~S_IWUGO;
+   dev_attr->store = NULL;
+   }
+   }
+
 #undef DEVICE_ATTR_IS
 
return 0;
-- 
2.25.1

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


[PATCH 2/3] amdgpu/pm: Prevent force of DCEFCLK on NAVI10 and SIENNA_CICHLID

2021-04-16 Thread Darren Powell
Writing to dcefclk causes the gpu to become unresponsive, and requires a reboot.
Patch ignores a .force_clk_levels(SMU_DCEFCLK) call and issues an
info message.

Signed-off-by: Darren Powell 
---
 drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 5 -
 drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
index f827096dc849..ac13042672ea 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
@@ -1443,7 +1443,6 @@ static int navi10_force_clk_levels(struct smu_context 
*smu,
case SMU_SOCCLK:
case SMU_MCLK:
case SMU_UCLK:
-   case SMU_DCEFCLK:
case SMU_FCLK:
/* There is only 2 levels for fine grained DPM */
if (navi10_is_support_fine_grained_dpm(smu, clk_type)) {
@@ -1463,6 +1462,10 @@ static int navi10_force_clk_levels(struct smu_context 
*smu,
if (ret)
return size;
break;
+   case SMU_DCEFCLK:
+   dev_info(smu->adev->dev,"Setting DCEFCLK min/max dpm level is 
not supported!\n");
+   break;
+
default:
break;
}
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
index 72d9c1be1835..d2fd44b903ca 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
@@ -1127,7 +1127,6 @@ static int sienna_cichlid_force_clk_levels(struct 
smu_context *smu,
case SMU_SOCCLK:
case SMU_MCLK:
case SMU_UCLK:
-   case SMU_DCEFCLK:
case SMU_FCLK:
/* There is only 2 levels for fine grained DPM */
if (sienna_cichlid_is_support_fine_grained_dpm(smu, clk_type)) {
@@ -1147,6 +1146,9 @@ static int sienna_cichlid_force_clk_levels(struct 
smu_context *smu,
if (ret)
goto forec_level_out;
break;
+   case SMU_DCEFCLK:
+   dev_info(smu->adev->dev,"Setting DCEFCLK min/max dpm level is 
not supported!\n");
+   break;
default:
break;
}
-- 
2.25.1

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


[PATCH 1/3] amdgpu/pm: add extra info to SMU msg pre-check failed message

2021-04-16 Thread Darren Powell
Insert the value of the response to error message emitted when the
SMU msg pre-check failes

Signed-off-by: Darren Powell 
---
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
index dc7d2e71aa6f..5d1743f3321e 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
@@ -104,8 +104,8 @@ int smu_cmn_send_msg_without_waiting(struct smu_context 
*smu,
 
ret = smu_cmn_wait_for_response(smu);
if (ret != 0x1) {
-   dev_err(adev->dev, "Msg issuing pre-check failed and "
-  "SMU may be not in the right state!\n");
+   dev_err(adev->dev, "Msg issuing pre-check failed(0x%x) and "
+  "SMU may be not in the right state!\n", ret);
if (ret != -ETIME)
ret = -EIO;
return ret;
-- 
2.25.1

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


[PATCH 0/3] Prevent set of DCEFCLK on smu_v11 gpus

2021-04-16 Thread Darren Powell
=== Description ===
Set of simple patches to prevent attempts to set dcefclk on NAVI10

=== Test System ===
* DESKTOP(AMD FX-8350 + NAVI10(731F/ca), BIOS: F2)
 + ISO(Ubuntu 20.04.1 LTS)
 + Kernel(5.11.0-custom-amdinternal-dirty)

=== Patch Summary ===
   linux: (g...@gitlab.freedesktop.org:agd5f) origin/amd-staging-drm-next @ 
ef08e194c809
+ d3c010c89301  amdgpu/pm: add extra info to SMU msg pre-check failed 
message
+ 318e4244c61f  amdgpu/pm: Prevent force of DCEFCLK on NAVI10 and 
SIENNA_CICHLID
+ d2a9f4653269  amdgpu/pm: set pp_dpm_dcefclk to readonly on smu_v11 gpus


=== Tests ===
General Test Sequence
-
* monitor dmesg output in a shell
  dmesg -w

* launch a root shell
  sudo bash

* set control to manual
  cd /sys/class/drm/card0/device
  echo manual > power_dpm_force_performance_level

* next step is expected to crash the GPU in unpatched and with patch 0001
** system usually continues operation so you can reboot gracefully

* TEST 1: modify pp_dpm_dcefclk to each level (0,1,2) and read setting after 
each write
  echo "1" > pp_dpm_dcefclk ; sleep 2 ; echo " ---set 1---" ; cat  
pp_dpm_dcefclk ;\
  echo "2" > pp_dpm_dcefclk ; sleep 2 ; echo " ---set 2---" ; cat  
pp_dpm_dcefclk ;\
  echo "0" > pp_dpm_dcefclk ; sleep 2 ; echo " ---set 0---" ; cat  
pp_dpm_dcefclk 
** example output
  [   74.493190] amdgpu :03:00.0: amdgpu: failed send message: 
SetSoftMaxByFreq (27)  param: 0x000504f2 response 0xff
  [   76.497102] amdgpu :03:00.0: amdgpu: Msg issuing pre-check failed and 
SMU may be not in the right state!
  [   76.497114] amdgpu :03:00.0: amdgpu: Failed to export SMU metrics 
table!
  [   76.497649] amdgpu :03:00.0: amdgpu: Msg issuing pre-check failed and 
SMU may be not in the right state!
  [   78.501229] amdgpu :03:00.0: amdgpu: Msg issuing pre-check failed and 
SMU may be not in the right state!
  [   78.501241] amdgpu :03:00.0: amdgpu: Failed to export SMU metrics 
table!
  [   78.501766] amdgpu :03:00.0: amdgpu: Msg issuing pre-check failed and 
SMU may be not in the right state!
  [   80.505401] amdgpu :03:00.0: amdgpu: Msg issuing pre-check failed and 
SMU may be not in the right state!
  [   80.505414] amdgpu :03:00.0: amdgpu: Failed to export SMU metrics 
table!

* TEST 2:
   ls -la  /sys/class/drm/card0/device/pp_dpm_dcefclk 
** example output
  -rw-r--r-- 1 root root 4096 Apr  7 18:33 
/sys/class/drm/card0/device/pp_dpm_dcefclk

* POST TEST
** restore dpm clock to auto 
  echo auto > power_dpm_force_performance_level


Test Results

* 0001 amdgpu/pm: add extra info to SMU msg pre-check failed message
** TEST 1 dmesg output
  [  101.414826] amdgpu :03:00.0: amdgpu: failed send message: 
SetSoftMaxByFreq (27)param: 0x000504f2 response 0xff
  [  103.418916] amdgpu :03:00.0: amdgpu: Msg issuing pre-check 
failed(0xff) and SMU may be not in the right state!
  [  103.418930] amdgpu :03:00.0: amdgpu: Failed to export SMU metrics 
table!
  [  103.419474] amdgpu :03:00.0: amdgpu: Msg issuing pre-check 
failed(0xff) and SMU may be not in the right state!
  [  105.423226] amdgpu :03:00.0: amdgpu: Msg issuing pre-check 
failed(0xff) and SMU may be not in the right state!
  [  105.423239] amdgpu :03:00.0: amdgpu: Failed to export SMU metrics 
table!
  [  105.423649] amdgpu :03:00.0: amdgpu: Msg issuing pre-check 
failed(0xff) and SMU may be not in the right state!
  [  107.427502] amdgpu :03:00.0: amdgpu: Msg issuing pre-check 
failed(0xff) and SMU may be not in the right state!
  [  107.427516] amdgpu :03:00.0: amdgpu: Failed to export SMU metrics 
table!

* 0002  amdgpu/pm: Prevent force of DCEFCLK on NAVI10 and SIENNA_CICHLID
** GPU remains operational after test
** TEST 1 dmesg output
  [  263.087136] amdgpu :03:00.0: amdgpu: Setting DCEFCLK min/max dpm level 
is not supported!
  [  265.092026] amdgpu :03:00.0: amdgpu: Setting DCEFCLK min/max dpm level 
is not supported!
  [  267.096648] amdgpu :03:00.0: amdgpu: Setting DCEFCLK min/max dpm level 
is not supported!

* 0003  amdgpu/pm: set pp_dpm_dcefclk to readonly on smu_v11 gpus
** TEST 2 shell output
  bash: pp_dpm_dcefclk: Permission denied
   ---set 1---
  0: 506Mhz *
  1: 886Mhz 
  2: 1266Mhz 
  bash: pp_dpm_dcefclk: Permission denied
   ---set 2---
  0: 506Mhz *
  1: 886Mhz 
  2: 1266Mhz 
  bash: pp_dpm_dcefclk: Permission denied
   ---set 0---
  0: 506Mhz *
  1: 886Mhz 
  2: 1266Mhz 

Darren Powell (3):
  amdgpu/pm: add extra info to SMU msg pre-check failed message
  amdgpu/pm: Prevent force of DCEFCLK on NAVI10 and SIENNA_CICHLID
  amdgpu/pm: set pp_dpm_dcefclk to readonly on smu_v11 gpus

 drivers/gpu/drm/amd/pm/amdgpu_pm.c  | 13 +
 drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c |  5 -
 .../gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c |  4 +++-
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c  |  4 ++--
 4 files changed, 22 insertions(+), 4 deletions(-)


b

[PATCH] drm/amdgpu/gmc9: remove dummy read workaround for newer chips

2021-04-16 Thread Alex Deucher
Aldebaran has a hw fix so no longer requires the workaround.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index f354f670c7ad..455bb91060d0 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -574,7 +574,8 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device 
*adev,
 * be updated to avoid reading an incorrect value due to
 * the new fast GRBM interface.
 */
-   if (entry->vmid_src == AMDGPU_GFXHUB_0)
+   if ((entry->vmid_src == AMDGPU_GFXHUB_0) &&
+   (adev->asic_type < CHIP_ALDEBARAN))
RREG32(hub->vm_l2_pro_fault_status);
 
status = RREG32(hub->vm_l2_pro_fault_status);
@@ -802,7 +803,8 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device 
*adev, uint32_t vmid,
 * be cleared to avoid a false ACK due to the new fast
 * GRBM interface.
 */
-   if (vmhub == AMDGPU_GFXHUB_0)
+   if ((vmhub == AMDGPU_GFXHUB_0) &&
+   (adev->asic_type < CHIP_ALDEBARAN))
RREG32_NO_KIQ(hub->vm_inv_eng0_req +
  hub->eng_distance * eng);
 
-- 
2.30.2

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


Re: 16 bpc fixed point (RGBA16) framebuffer support for core and AMD.

2021-04-16 Thread Ville Syrjälä
On Fri, Apr 16, 2021 at 06:27:23PM +0200, Mario Kleiner wrote:
> On Mon, Mar 22, 2021 at 4:52 PM Ville Syrjälä
>  wrote:
> >
> > On Fri, Mar 19, 2021 at 10:03:12PM +0100, Mario Kleiner wrote:
> > > Hi,
> > >
> > > this patch series adds the fourcc's for 16 bit fixed point unorm
> > > framebuffers to the core, and then an implementation for AMD gpu's
> > > with DisplayCore.
> > >
> > > This is intended to allow for pageflipping to, and direct scanout of,
> > > Vulkan swapchain images in the format VK_FORMAT_R16G16B16A16_UNORM.
> > > I have patched AMD's GPUOpen amdvlk OSS driver to enable this format
> > > for swapchains, mapping to DRM_FORMAT_XBGR16161616:
> > > Link: 
> > > https://github.com/kleinerm/pal/commit/a25d4802074b13a8d5f7edc96ae45469ecbac3c4
> >
> > We should also add support for these formats into igt.a Should
> > be semi-easy by just adding the suitable float<->uint16
> > conversion stuff.
> >
> 
> Hi Ville,
> 
> Could you point me to a specific test case / file that I should look
> at for adding this?

lib/igt_fb.c is the main thing. It has a bunch of conversion magic
to support rendering into all kinds of weird framebuffer formats
via cairo. 

In this should be mostly a matter of adding convert_uint16_to_float()
and convert_float_to_uint16(), plugging those into fb_convert(),
and declaring the new formats in format_desc[]. There might be
a few little extra details I'm forgetting though.

Once igt_fb has the required stuff kms_plane/pixel-format*
should automagically pick it up if the kernel reports the
format as supported.

Oh, and you need some >1.17 version of cairo for the float
support.

-- 
Ville Syrjälä
Intel
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 00/40] [Set 16] Rid W=1 warnings from GPU!

2021-04-16 Thread Lee Jones
This set is part of a larger effort attempting to clean-up W=1
kernel builds, which are currently overwhelmingly riddled with
niggly little warnings.

Lee Jones (40):
  drm/nouveau/nvkm/subdev/bios/init: Demote obvious abuse of kernel-doc
  drm/nouveau/dispnv50/disp: Remove unused variable 'ret'
  drm/msm/dp/dp_display: Remove unused variable 'hpd'
  include: drm: drm_atomic: Make use of 'new_plane_state'
  drm/nouveau/nvkm/subdev/volt/gk20a: Demote non-conformant kernel-doc
headers
  drm/nouveau/nvkm/engine/gr/gf100: Demote non-conformant kernel-doc
header
  drm/nouveau/nouveau_bo: Remove unused variables 'dev'
  drm/nouveau/nouveau_display: Remove set but unused variable 'width'
  drm/nouveau/dispnv04/crtc: Demote non-conforming kernel-doc headers
  drm/nouveau/dispnv50/disp: Remove unused variable 'ret' from function
returning void
  drm/nouveau/dispnv50/headc57d: Make local function 'headc57d_olut'
static
  drm/nouveau/nv50_display: Remove superfluous prototype for local
static functions
  drm/nouveau/dispnv50/disp: Include header containing our prototypes
  drm/nouveau/nouveau_ioc32: File headers are not good candidates for
kernel-doc
  drm/nouveau/nouveau_svm: Remove unused variable 'ret' from void
function
  drm/nouveau/nouveau_ioc32: Demote kernel-doc abuse to standard comment
block
  gpu: host1x: bus: Remove superfluous param description 'key'
  drm/omapdrm/omap_irq: Fix a couple of incorrectly documented functions
  drm/omapdrm/omap_gem: Properly document omap_gem_dumb_map_offset()
  drm/xlnx/zynqmp_disp: Fix incorrectly documented enum 'zynqmp_disp_id'
  drm/xlnx/zynqmp_dp: Fix a little potential doc-rot
  drm/ttm/ttm_tt: Demote non-conformant kernel-doc header
  drm/ttm/ttm_bo: Fix incorrectly documented function
'ttm_bo_cleanup_refs'
  drm/scheduler/sched_entity: Fix some function name disparity
  drm/radeon/radeon_device: Provide function name in kernel-doc header
  drm/amd/amdgpu/amdgpu_device: Remove unused variable 'r'
  drm/ttm/ttm_device: Demote kernel-doc abuses
  drm/panel/panel-raspberrypi-touchscreen: Demote kernel-doc abuse
  drm/amd/amdgpu/amdgpu_fence: Provide description for 'sched_score'
  drm/vgem/vgem_drv: Demote kernel-doc abuse
  drm/amd/amdgpu/amdgpu_gart: Correct a couple of function names in the
docs
  drm/amd/amdgpu/amdgpu_ttm: Fix incorrectly documented function
'amdgpu_ttm_copy_mem_to_mem()'
  drm/amd/amdgpu/amdgpu_ring: Provide description for 'sched_score'
  drm/exynos/exynos_drm_fimd: Realign function name with its header
  drm/amd/amdgpu/amdgpu_cs: Repair some function naming disparity
  drm/exynos/exynos7_drm_decon: Realign function name with its header
  drm/panel/panel-sitronix-st7701: Demote kernel-doc format abuse
  drm/exynos/exynos_drm_ipp: Fix some function name disparity issues
  drm/sti/sti_hdmi: Provide kernel-doc headers with function names
  drm/mediatek/mtk_disp_ccorr: Demote less than half-populated struct
header

 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c|   6 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c|   5 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c  |   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c  |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   |   2 +-
 drivers/gpu/drm/exynos/exynos7_drm_decon.c|   2 +-
 drivers/gpu/drm/exynos/exynos_drm_fimd.c  |   2 +-
 drivers/gpu/drm/exynos/exynos_drm_ipp.c   |   4 +-
 drivers/gpu/drm/mediatek/mtk_disp_ccorr.c |   2 +-
 drivers/gpu/drm/msm/dp/dp_display.c   |   3 -
 drivers/gpu/drm/nouveau/dispnv04/crtc.c   |   4 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.c   |  10 +-
 drivers/gpu/drm/nouveau/dispnv50/headc57d.c   |   2 +-
 drivers/gpu/drm/nouveau/nouveau_bo.c  |   4 -
 drivers/gpu/drm/nouveau/nouveau_display.c |   8 +-
 drivers/gpu/drm/nouveau/nouveau_ioc32.c   |   4 +-
 drivers/gpu/drm/nouveau/nouveau_svm.c |   5 +-
 drivers/gpu/drm/nouveau/nv50_display.h|   3 -
 .../gpu/drm/nouveau/nvkm/engine/gr/gf100.c|   2 +-
 .../gpu/drm/nouveau/nvkm/subdev/bios/init.c   | 204 ++
 .../gpu/drm/nouveau/nvkm/subdev/volt/gk20a.c  |   4 +-
 drivers/gpu/drm/omapdrm/omap_gem.c|   2 +-
 drivers/gpu/drm/omapdrm/omap_irq.c|   4 +-
 .../drm/panel/panel-raspberrypi-touchscreen.c |   2 +-
 drivers/gpu/drm/panel/panel-sitronix-st7701.c |   2 +-
 drivers/gpu/drm/radeon/radeon_device.c|   3 +-
 drivers/gpu/drm/scheduler/sched_entity.c  |   6 +-
 drivers/gpu/drm/sti/sti_hdmi.c|  18 +-
 drivers/gpu/drm/ttm/ttm_bo.c  |   2 +-
 drivers/gpu/drm/ttm/ttm_device.c  |   4 +-
 drivers/gpu/drm/ttm/ttm_tt.c  |   2 +-
 drivers/gpu/drm/vgem/vgem_drv.c   |   2 +-
 drivers/gpu/drm/xlnx/zynqmp_disp.c|   2 +-
 drivers/gpu/drm/xlnx/zynqmp_dp.c  |   2 +-
 drivers/gpu/host1x/bus.c  |   1 -
 i

[PATCH 31/40] drm/amd/amdgpu/amdgpu_gart: Correct a couple of function names in the docs

2021-04-16 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c:73: warning: expecting prototype for 
amdgpu_dummy_page_init(). Prototype was for amdgpu_gart_dummy_page_init() 
instead
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c:96: warning: expecting prototype for 
amdgpu_dummy_page_fini(). Prototype was for amdgpu_gart_dummy_page_fini() 
instead

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Nirmoy Das 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index c5a9a4fb10d2b..5562b5c90c032 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -60,7 +60,7 @@
  */
 
 /**
- * amdgpu_dummy_page_init - init dummy page used by the driver
+ * amdgpu_gart_dummy_page_init - init dummy page used by the driver
  *
  * @adev: amdgpu_device pointer
  *
@@ -86,7 +86,7 @@ static int amdgpu_gart_dummy_page_init(struct amdgpu_device 
*adev)
 }
 
 /**
- * amdgpu_dummy_page_fini - free dummy page used by the driver
+ * amdgpu_gart_dummy_page_fini - free dummy page used by the driver
  *
  * @adev: amdgpu_device pointer
  *
-- 
2.27.0

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


[PATCH 25/40] drm/radeon/radeon_device: Provide function name in kernel-doc header

2021-04-16 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/radeon_device.c:1101: warning: This comment starts with 
'/**', but isn't a kernel-doc comment. Refer 
Documentation/doc-guide/kernel-doc.rst

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon_device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
b/drivers/gpu/drm/radeon/radeon_device.c
index cc445c4cba2e3..46eea01950cb1 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1098,7 +1098,8 @@ static bool radeon_check_pot_argument(int arg)
 }
 
 /**
- * Determine a sensible default GART size according to ASIC family.
+ * radeon_gart_size_auto - Determine a sensible default GART size
+ * according to ASIC family.
  *
  * @family: ASIC family name
  */
-- 
2.27.0

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


[PATCH 26/40] drm/amd/amdgpu/amdgpu_device: Remove unused variable 'r'

2021-04-16 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c: In function 
‘amdgpu_device_suspend’:
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:3733:6: warning: variable ‘r’ set 
but not used [-Wunused-but-set-variable]

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index b4ad1c055c702..eef54b265ffdd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3730,7 +3730,6 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
 int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
 {
struct amdgpu_device *adev = drm_to_adev(dev);
-   int r;
 
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
return 0;
@@ -3745,7 +3744,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool 
fbcon)
 
amdgpu_ras_suspend(adev);
 
-   r = amdgpu_device_ip_suspend_phase1(adev);
+   amdgpu_device_ip_suspend_phase1(adev);
 
if (!adev->in_s0ix)
amdgpu_amdkfd_suspend(adev, adev->in_runpm);
@@ -3755,7 +3754,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool 
fbcon)
 
amdgpu_fence_driver_suspend(adev);
 
-   r = amdgpu_device_ip_suspend_phase2(adev);
+   amdgpu_device_ip_suspend_phase2(adev);
/* evict remaining vram memory
 * This second call to evict vram is to evict the gart page table
 * using the CPU.
-- 
2.27.0

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


[PATCH 32/40] drm/amd/amdgpu/amdgpu_ttm: Fix incorrectly documented function 'amdgpu_ttm_copy_mem_to_mem()'

2021-04-16 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:311: warning: expecting prototype for 
amdgpu_copy_ttm_mem_to_mem(). Prototype was for amdgpu_ttm_copy_mem_to_mem() 
instead

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: Jerome Glisse 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 3bef0432cac2f..859314c0d6a39 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -288,7 +288,7 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object 
*bo,
 }
 
 /**
- * amdgpu_copy_ttm_mem_to_mem - Helper function for copy
+ * amdgpu_ttm_copy_mem_to_mem - Helper function for copy
  * @adev: amdgpu device
  * @src: buffer/address where to read from
  * @dst: buffer/address where to write to
-- 
2.27.0

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


[PATCH 29/40] drm/amd/amdgpu/amdgpu_fence: Provide description for 'sched_score'

2021-04-16 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:444: warning: Function parameter or 
member 'sched_score' not described in 'amdgpu_fence_driver_init_ring'

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: Jerome Glisse 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 47ea468596184..30772608eac6c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -434,6 +434,7 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
  *
  * @ring: ring to init the fence driver on
  * @num_hw_submission: number of entries on the hardware queue
+ * @sched_score: optional score atomic shared with other schedulers
  *
  * Init the fence driver for the requested ring (all asics).
  * Helper function for amdgpu_fence_driver_init().
-- 
2.27.0

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


[PATCH 33/40] drm/amd/amdgpu/amdgpu_ring: Provide description for 'sched_score'

2021-04-16 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:169: warning: Function parameter or 
member 'sched_score' not described in 'amdgpu_ring_init'

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index 688624ebe4211..7b634a1517f9c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -158,6 +158,7 @@ void amdgpu_ring_undo(struct amdgpu_ring *ring)
  * @irq_src: interrupt source to use for this ring
  * @irq_type: interrupt type to use for this ring
  * @hw_prio: ring priority (NORMAL/HIGH)
+ * @sched_score: optional score atomic shared with other schedulers
  *
  * Initialize the driver information for the selected ring (all asics).
  * Returns 0 on success, error on failure.
-- 
2.27.0

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


[PATCH 35/40] drm/amd/amdgpu/amdgpu_cs: Repair some function naming disparity

2021-04-16 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c:685: warning: expecting prototype for 
cs_parser_fini(). Prototype was for amdgpu_cs_parser_fini() instead
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c:1502: warning: expecting prototype for 
amdgpu_cs_wait_all_fence(). Prototype was for amdgpu_cs_wait_all_fences() 
instead
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c:1656: warning: expecting prototype for 
amdgpu_cs_find_bo_va(). Prototype was for amdgpu_cs_find_mapping() instead

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: Jerome Glisse 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index b5c7669980458..90136f9dedd65 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -672,7 +672,7 @@ static int amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)
 }
 
 /**
- * cs_parser_fini() - clean parser states
+ * amdgpu_cs_parser_fini() - clean parser states
  * @parser:parser structure holding parsing context.
  * @error: error number
  * @backoff:   indicator to backoff the reservation
@@ -1488,7 +1488,7 @@ int amdgpu_cs_fence_to_handle_ioctl(struct drm_device 
*dev, void *data,
 }
 
 /**
- * amdgpu_cs_wait_all_fence - wait on all fences to signal
+ * amdgpu_cs_wait_all_fences - wait on all fences to signal
  *
  * @adev: amdgpu device
  * @filp: file private
@@ -1639,7 +1639,7 @@ int amdgpu_cs_wait_fences_ioctl(struct drm_device *dev, 
void *data,
 }
 
 /**
- * amdgpu_cs_find_bo_va - find bo_va for VM address
+ * amdgpu_cs_find_mapping - find bo_va for VM address
  *
  * @parser: command submission parser context
  * @addr: VM address
-- 
2.27.0

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


[PATCH] drm/amdgpu/pm: use linux/processor.h instead of asm/processor.h

2021-04-16 Thread Colin King
From: Colin Ian King 

Checkpatch reported that linux/processor.h should be included instead
of the asm variant. Fix this to clean up the warning.

Signed-off-by: Colin Ian King 
---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c 
b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 204e34549013..6842dd483c2a 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -33,7 +33,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include "hwmgr.h"
 
 static const struct cg_flag_name clocks[] = {
-- 
2.30.2

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


Re: 16 bpc fixed point (RGBA16) framebuffer support for core and AMD.

2021-04-16 Thread Mario Kleiner
Friendly ping to the AMD people. Nicholas, Harry, Alex, any feedback?
Would be great to get this in sooner than later.

Thanks and have a nice weekend,
-mario

On Fri, Mar 19, 2021 at 10:03 PM Mario Kleiner
 wrote:
>
> Hi,
>
> this patch series adds the fourcc's for 16 bit fixed point unorm
> framebuffers to the core, and then an implementation for AMD gpu's
> with DisplayCore.
>
> This is intended to allow for pageflipping to, and direct scanout of,
> Vulkan swapchain images in the format VK_FORMAT_R16G16B16A16_UNORM.
> I have patched AMD's GPUOpen amdvlk OSS driver to enable this format
> for swapchains, mapping to DRM_FORMAT_XBGR16161616:
> Link: 
> https://github.com/kleinerm/pal/commit/a25d4802074b13a8d5f7edc96ae45469ecbac3c4
>
> My main motivation for this is squeezing every bit of precision
> out of the hardware for scientific and medical research applications,
> where fp16 in the unorm range is limited to ~11 bpc effective linear
> precision in the upper half [0.5;1.0] of the unorm range, although
> the hardware could do at least 12 bpc.
>
> It has been successfully tested on AMD RavenRidge (DCN-1), and with
> Polaris11 (DCE-11.2). Up to two displays were active on RavenRidge
> (DP 2560x1440@144Hz + HDMI 2560x1440@120Hz), the maximum supported
> on my hw, both running at 10 bpc DP output depth.
>
> Up to three displays were active on the Polaris (DP 2560x1440@144Hz +
> 2560x1440@100Hz USB-C DP-altMode-to-HDMI converter + eDP 2880x1800@60Hz
> Apple Retina panel), all running at 10 bpc output depth.
>
> No malfunctions, visual artifacts or other oddities were observed
> (apart from an adventureous mess of cables and adapters on my desk),
> suggesting it works.
>
> I used my automatic photometer measurement procedure to verify the
> effective output precision of 10 bpc DP native signal + spatial
> dithering in the gpu as enabled by the amdgpu driver. Results show
> the expected 12 bpc precision i hoped for -- the current upper limit
> for AMD display hw afaik.
>
> So it seems to work in the way i hoped :).
>
> Some open questions wrt. AMD DC, to be addressed in this patch series, or 
> follow up
> patches if neccessary:
>
> - For the atomic check for plane scaling, the current patch will
> apply the same hw limits as for other rgb fixed point fb's, e.g.,
> for 8 bpc rgb8. Is this correct? Or would we need to use the fp16
> limits, because this is also a 64 bpp format? Or something new
> entirely?
>
> - I haven't added the new fourcc to the DCC tables yet. Should i?
>
> - I had to change an assert for DCE to allow 36bpp linebuffers (patch 4/5).
> It looks to me as if that assert was inconsistent with other places
> in the driver where COLOR_DEPTH121212 is supported, and looking at
> the code, the change seems harmless. At least on DCE-11.2 the change
> didn't cause any noticeable (by myself) or measurable (by my equipment)
> problems on any of the 3 connected displays.
>
> - Related to that change, while i needed to increase lb pixelsize to 36bpp
> to get > 10 bpc effective precision on DCN, i didn't need to do that
> on DCE. Also no change of lb pixelsize was needed on either DCN or DCe
> to get > 10 bpc precision for fp16 framebuffers, so something seems to
> behave differently for floating point 16 vs. fixed point 16. This all
> seems to suggest one could leave lb pixelsize at the old 30 bpp value
> on at least DCE-11.2 and still get the > 10 bpc precision if one wanted
> to avoid the changes of patch 4/5.
>
> Thanks,
> -mario
>
>
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: 16 bpc fixed point (RGBA16) framebuffer support for core and AMD.

2021-04-16 Thread Mario Kleiner
On Mon, Mar 22, 2021 at 4:52 PM Ville Syrjälä
 wrote:
>
> On Fri, Mar 19, 2021 at 10:03:12PM +0100, Mario Kleiner wrote:
> > Hi,
> >
> > this patch series adds the fourcc's for 16 bit fixed point unorm
> > framebuffers to the core, and then an implementation for AMD gpu's
> > with DisplayCore.
> >
> > This is intended to allow for pageflipping to, and direct scanout of,
> > Vulkan swapchain images in the format VK_FORMAT_R16G16B16A16_UNORM.
> > I have patched AMD's GPUOpen amdvlk OSS driver to enable this format
> > for swapchains, mapping to DRM_FORMAT_XBGR16161616:
> > Link: 
> > https://github.com/kleinerm/pal/commit/a25d4802074b13a8d5f7edc96ae45469ecbac3c4
>
> We should also add support for these formats into igt.a Should
> be semi-easy by just adding the suitable float<->uint16
> conversion stuff.
>

Hi Ville,

Could you point me to a specific test case / file that I should look
at for adding this?

thanks,
-mario

> --
> Ville Syrjälä
> Intel
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 35/40] drm/amd/amdgpu/amdgpu_cs: Repair some function naming disparity

2021-04-16 Thread Christian König

Am 16.04.21 um 16:37 schrieb Lee Jones:

Fixes the following W=1 kernel build warning(s):

  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c:685: warning: expecting prototype for 
cs_parser_fini(). Prototype was for amdgpu_cs_parser_fini() instead
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c:1502: warning: expecting prototype for 
amdgpu_cs_wait_all_fence(). Prototype was for amdgpu_cs_wait_all_fences() 
instead
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c:1656: warning: expecting prototype for 
amdgpu_cs_find_bo_va(). Prototype was for amdgpu_cs_find_mapping() instead

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: Jerome Glisse 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 


Reviewed-by: Christian König 


---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index b5c7669980458..90136f9dedd65 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -672,7 +672,7 @@ static int amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)
  }
  
  /**

- * cs_parser_fini() - clean parser states
+ * amdgpu_cs_parser_fini() - clean parser states
   * @parser:   parser structure holding parsing context.
   * @error:error number
   * @backoff:  indicator to backoff the reservation
@@ -1488,7 +1488,7 @@ int amdgpu_cs_fence_to_handle_ioctl(struct drm_device 
*dev, void *data,
  }
  
  /**

- * amdgpu_cs_wait_all_fence - wait on all fences to signal
+ * amdgpu_cs_wait_all_fences - wait on all fences to signal
   *
   * @adev: amdgpu device
   * @filp: file private
@@ -1639,7 +1639,7 @@ int amdgpu_cs_wait_fences_ioctl(struct drm_device *dev, 
void *data,
  }
  
  /**

- * amdgpu_cs_find_bo_va - find bo_va for VM address
+ * amdgpu_cs_find_mapping - find bo_va for VM address
   *
   * @parser: command submission parser context
   * @addr: VM address


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


Re: [PATCH 33/40] drm/amd/amdgpu/amdgpu_ring: Provide description for 'sched_score'

2021-04-16 Thread Christian König

Am 16.04.21 um 16:37 schrieb Lee Jones:

Fixes the following W=1 kernel build warning(s):

  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:169: warning: Function parameter or 
member 'sched_score' not described in 'amdgpu_ring_init'

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 


Reviewed-by: Christian König 


---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index 688624ebe4211..7b634a1517f9c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -158,6 +158,7 @@ void amdgpu_ring_undo(struct amdgpu_ring *ring)
   * @irq_src: interrupt source to use for this ring
   * @irq_type: interrupt type to use for this ring
   * @hw_prio: ring priority (NORMAL/HIGH)
+ * @sched_score: optional score atomic shared with other schedulers
   *
   * Initialize the driver information for the selected ring (all asics).
   * Returns 0 on success, error on failure.


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


Re: [PATCH 32/40] drm/amd/amdgpu/amdgpu_ttm: Fix incorrectly documented function 'amdgpu_ttm_copy_mem_to_mem()'

2021-04-16 Thread Christian König

Am 16.04.21 um 16:37 schrieb Lee Jones:

Fixes the following W=1 kernel build warning(s):

  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:311: warning: expecting prototype for 
amdgpu_copy_ttm_mem_to_mem(). Prototype was for amdgpu_ttm_copy_mem_to_mem() 
instead

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: Jerome Glisse 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 


Reviewed-by: Christian König 


---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 3bef0432cac2f..859314c0d6a39 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -288,7 +288,7 @@ static int amdgpu_ttm_map_buffer(struct ttm_buffer_object 
*bo,
  }
  
  /**

- * amdgpu_copy_ttm_mem_to_mem - Helper function for copy
+ * amdgpu_ttm_copy_mem_to_mem - Helper function for copy
   * @adev: amdgpu device
   * @src: buffer/address where to read from
   * @dst: buffer/address where to write to


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


Re: [PATCH 31/40] drm/amd/amdgpu/amdgpu_gart: Correct a couple of function names in the docs

2021-04-16 Thread Christian König

Am 16.04.21 um 16:37 schrieb Lee Jones:

Fixes the following W=1 kernel build warning(s):

  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c:73: warning: expecting prototype for 
amdgpu_dummy_page_init(). Prototype was for amdgpu_gart_dummy_page_init() 
instead
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c:96: warning: expecting prototype for 
amdgpu_dummy_page_fini(). Prototype was for amdgpu_gart_dummy_page_fini() 
instead

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Nirmoy Das 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Signed-off-by: Lee Jones 


Reviewed-by: Christian König 


---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index c5a9a4fb10d2b..5562b5c90c032 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -60,7 +60,7 @@
   */
  
  /**

- * amdgpu_dummy_page_init - init dummy page used by the driver
+ * amdgpu_gart_dummy_page_init - init dummy page used by the driver
   *
   * @adev: amdgpu_device pointer
   *
@@ -86,7 +86,7 @@ static int amdgpu_gart_dummy_page_init(struct amdgpu_device 
*adev)
  }
  
  /**

- * amdgpu_dummy_page_fini - free dummy page used by the driver
+ * amdgpu_gart_dummy_page_fini - free dummy page used by the driver
   *
   * @adev: amdgpu_device pointer
   *


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


Re: [PATCH 29/40] drm/amd/amdgpu/amdgpu_fence: Provide description for 'sched_score'

2021-04-16 Thread Christian König

Am 16.04.21 um 16:37 schrieb Lee Jones:

Fixes the following W=1 kernel build warning(s):

  drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:444: warning: Function parameter or 
member 'sched_score' not described in 'amdgpu_fence_driver_init_ring'

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: Jerome Glisse 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 


Reviewed-by: Christian König 


---
  drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 47ea468596184..30772608eac6c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -434,6 +434,7 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
   *
   * @ring: ring to init the fence driver on
   * @num_hw_submission: number of entries on the hardware queue
+ * @sched_score: optional score atomic shared with other schedulers
   *
   * Init the fence driver for the requested ring (all asics).
   * Helper function for amdgpu_fence_driver_init().


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


Re: [PATCH 25/40] drm/radeon/radeon_device: Provide function name in kernel-doc header

2021-04-16 Thread Christian König

Am 16.04.21 um 16:37 schrieb Lee Jones:

Fixes the following W=1 kernel build warning(s):

  drivers/gpu/drm/radeon/radeon_device.c:1101: warning: This comment starts 
with '/**', but isn't a kernel-doc comment. Refer 
Documentation/doc-guide/kernel-doc.rst

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Signed-off-by: Lee Jones 


Reviewed-by: Christian König 


---
  drivers/gpu/drm/radeon/radeon_device.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
b/drivers/gpu/drm/radeon/radeon_device.c
index cc445c4cba2e3..46eea01950cb1 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1098,7 +1098,8 @@ static bool radeon_check_pot_argument(int arg)
  }
  
  /**

- * Determine a sensible default GART size according to ASIC family.
+ * radeon_gart_size_auto - Determine a sensible default GART size
+ * according to ASIC family.
   *
   * @family: ASIC family name
   */


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


Re: [PATCH 31/40] drm/amd/amdgpu/amdgpu_gart: Correct a couple of function names in the docs

2021-04-16 Thread Nirmoy

Reviewed-by: Nirmoy Das 

On 4/16/21 4:37 PM, Lee Jones wrote:

Fixes the following W=1 kernel build warning(s):

  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c:73: warning: expecting prototype for 
amdgpu_dummy_page_init(). Prototype was for amdgpu_gart_dummy_page_init() 
instead
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c:96: warning: expecting prototype for 
amdgpu_dummy_page_fini(). Prototype was for amdgpu_gart_dummy_page_fini() 
instead

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Nirmoy Das 
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Signed-off-by: Lee Jones 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index c5a9a4fb10d2b..5562b5c90c032 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -60,7 +60,7 @@
   */
  
  /**

- * amdgpu_dummy_page_init - init dummy page used by the driver
+ * amdgpu_gart_dummy_page_init - init dummy page used by the driver
   *
   * @adev: amdgpu_device pointer
   *
@@ -86,7 +86,7 @@ static int amdgpu_gart_dummy_page_init(struct amdgpu_device 
*adev)
  }
  
  /**

- * amdgpu_dummy_page_fini - free dummy page used by the driver
+ * amdgpu_gart_dummy_page_fini - free dummy page used by the driver
   *
   * @adev: amdgpu_device pointer
   *

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


RE: [PATCH] drm/amdgpu: fix a error injection failed issue

2021-04-16 Thread Zhang, Hawking
[AMD Public Use]

Reviewed-by: Hawking Zhang 

Regards,
Hawking

-Original Message-
From: Dennis Li  
Sent: Friday, April 16, 2021 22:49
To: amd-gfx@lists.freedesktop.org; Deucher, Alexander 
; Kuehling, Felix ; Zhang, 
Hawking ; Koenig, Christian 
Cc: Li, Dennis 
Subject: [PATCH] drm/amdgpu: fix a error injection failed issue

because "sscanf(str, "retire_page")" always return 0, if application use the 
raw data for error injection, it always wrongly falls into "op == 3". Change to 
use strstr instead.

Signed-off-by: Dennis Li 

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 38a691a3b600..7438d4e84776 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -221,7 +221,7 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file 
*f,
op = 1;
else if (sscanf(str, "inject %32s %8s", block_name, err) == 2)
op = 2;
-   else if (sscanf(str, "retire_page") == 0)
+   else if (strstr(str, "retire_page") != NULL)
op = 3;
else if (str[0] && str[1] && str[2] && str[3])
/* ascii string, but commands are not matched. */
--
2.17.1
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH] drm/amdgpu: fix a error injection failed issue

2021-04-16 Thread Dennis Li
because "sscanf(str, "retire_page")" always return 0, if application use
the raw data for error injection, it always wrongly falls into "op ==
3". Change to use strstr instead.

Signed-off-by: Dennis Li 

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 38a691a3b600..7438d4e84776 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -221,7 +221,7 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file 
*f,
op = 1;
else if (sscanf(str, "inject %32s %8s", block_name, err) == 2)
op = 2;
-   else if (sscanf(str, "retire_page") == 0)
+   else if (strstr(str, "retire_page") != NULL)
op = 3;
else if (str[0] && str[1] && str[2] && str[3])
/* ascii string, but commands are not matched. */
-- 
2.17.1

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


Re: [PATCH 1/3] drm/amdgpu: make sure we unpin the UVD BO

2021-04-16 Thread Leo Liu

Acked-by: Leo Liu 

On 2021-04-16 8:54 a.m., Christian König wrote:

Ping?

Am 15.04.21 um 10:47 schrieb Christian König:

Releasing pinned BOs is illegal now.

Signed-off-by: Christian König 
---
  drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c 
b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c

index 7cd67cb2ac5f..1a2bf2ca1be5 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
@@ -363,6 +363,7 @@ static int uvd_v7_0_enc_ring_test_ib(struct 
amdgpu_ring *ring, long timeout)

    error:
  dma_fence_put(fence);
+    amdgpu_bo_unpin(bo);
  amdgpu_bo_unreserve(bo);
  amdgpu_bo_unref(&bo);
  return r;


___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Cleo.liu%40amd.com%7C5823d278fae848e2292008d900d6bd76%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637541744618109453%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=TIn5u5%2FPS50wcKCd6%2FwTnpPm%2BgCPa8KOT1cz6r7Xgl0%3D&reserved=0 


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


[PATCH 19/19] drm/amd/display: 3.2.132

2021-04-16 Thread Aurabindo Pillai
From: Aric Cyr 

Signed-off-by: Aric Cyr 
Reviewed-by: Aric Cyr 
Acked-by: Aurabindo Pillai 
---
 drivers/gpu/drm/amd/display/dc/dc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index ed19b9b39af0..100d434f7a03 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -45,7 +45,7 @@
 /* forward declaration */
 struct aux_payload;
 
-#define DC_VER "3.2.131"
+#define DC_VER "3.2.132"
 
 #define MAX_SURFACES 3
 #define MAX_PLANES 6
-- 
2.31.1

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


[PATCH 16/19] drm/amd/display: Report Proper Quantization Range in AVI Infoframe

2021-04-16 Thread Aurabindo Pillai
From: Dillon Varone 

[Why?]
When a monitor does not set both QS and QY bits, DC does not
set Q0, Q1, QY0 and QY1 bits in AVI infoframe. Setting RGB bits
should be separate from setting YCC bits.

[How?]
Separate logic for setting RGB and YCC quantization range bits
in the AVI infoframe.

Signed-off-by: Dillon Varone 
Reviewed-by: Chris Park 
Acked-by: Aurabindo Pillai 
---
 .../gpu/drm/amd/display/dc/core/dc_resource.c | 33 +++
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index ac7a75887f95..8cb937c046aa 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -2506,26 +2506,31 @@ static void set_avi_info_frame(
hdmi_info.bits.ITC = itc_value;
}
 
+   if (stream->qs_bit == 1) {
+   if (color_space == COLOR_SPACE_SRGB ||
+   color_space == COLOR_SPACE_2020_RGB_FULLRANGE)
+   hdmi_info.bits.Q0_Q1   = RGB_QUANTIZATION_FULL_RANGE;
+   else if (color_space == COLOR_SPACE_SRGB_LIMITED ||
+   color_space == 
COLOR_SPACE_2020_RGB_LIMITEDRANGE)
+   hdmi_info.bits.Q0_Q1   = RGB_QUANTIZATION_LIMITED_RANGE;
+   else
+   hdmi_info.bits.Q0_Q1   = RGB_QUANTIZATION_DEFAULT_RANGE;
+   } else
+   hdmi_info.bits.Q0_Q1   = RGB_QUANTIZATION_DEFAULT_RANGE;
+
/* TODO : We should handle YCC quantization */
/* but we do not have matrix calculation */
-   if (stream->qs_bit == 1 &&
-   stream->qy_bit == 1) {
+   if (stream->qy_bit == 1) {
if (color_space == COLOR_SPACE_SRGB ||
-   color_space == COLOR_SPACE_2020_RGB_FULLRANGE) {
-   hdmi_info.bits.Q0_Q1   = RGB_QUANTIZATION_FULL_RANGE;
+   color_space == COLOR_SPACE_2020_RGB_FULLRANGE)
hdmi_info.bits.YQ0_YQ1 = YYC_QUANTIZATION_LIMITED_RANGE;
-   } else if (color_space == COLOR_SPACE_SRGB_LIMITED ||
-   color_space == 
COLOR_SPACE_2020_RGB_LIMITEDRANGE) {
-   hdmi_info.bits.Q0_Q1   = RGB_QUANTIZATION_LIMITED_RANGE;
+   else if (color_space == COLOR_SPACE_SRGB_LIMITED ||
+   color_space == 
COLOR_SPACE_2020_RGB_LIMITEDRANGE)
hdmi_info.bits.YQ0_YQ1 = YYC_QUANTIZATION_LIMITED_RANGE;
-   } else {
-   hdmi_info.bits.Q0_Q1   = RGB_QUANTIZATION_DEFAULT_RANGE;
+   else
hdmi_info.bits.YQ0_YQ1 = YYC_QUANTIZATION_LIMITED_RANGE;
-   }
-   } else {
-   hdmi_info.bits.Q0_Q1   = RGB_QUANTIZATION_DEFAULT_RANGE;
-   hdmi_info.bits.YQ0_YQ1   = YYC_QUANTIZATION_LIMITED_RANGE;
-   }
+   } else
+   hdmi_info.bits.YQ0_YQ1 = YYC_QUANTIZATION_LIMITED_RANGE;
 
///VIC
format = stream->timing.timing_3d_format;
-- 
2.31.1

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


[PATCH 18/19] drm/amd/display: [FW Promotion] Release 0.0.62

2021-04-16 Thread Aurabindo Pillai
From: Anthony Koo 

Signed-off-by: Anthony Koo 
Reviewed-by: Anthony Koo 
Acked-by: Aurabindo Pillai 
---
 drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h 
b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
index ba93e139a47e..4195ff10c514 100644
--- a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
+++ b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
@@ -47,10 +47,10 @@
 
 /* Firmware versioning. */
 #ifdef DMUB_EXPOSE_VERSION
-#define DMUB_FW_VERSION_GIT_HASH 0xcf6f1711c
+#define DMUB_FW_VERSION_GIT_HASH 0x23db9b126
 #define DMUB_FW_VERSION_MAJOR 0
 #define DMUB_FW_VERSION_MINOR 0
-#define DMUB_FW_VERSION_REVISION 61
+#define DMUB_FW_VERSION_REVISION 62
 #define DMUB_FW_VERSION_TEST 0
 #define DMUB_FW_VERSION_VBIOS 0
 #define DMUB_FW_VERSION_HOTFIX 0
-- 
2.31.1

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


[PATCH 15/19] drm/amd/display: Fix call to pass bpp in 16ths of a bit

2021-04-16 Thread Aurabindo Pillai
From: Dillon Varone 

[Why & How?]
Call to dc_dsc_compute_bandwidth_range should have min and max bpp
in 16ths of a bit.  Multiply min and max bpp from policy.

Signed-off-by: Dillon Varone 
Reviewed-by: Eryk Brol 
Acked-by: Aurabindo Pillai 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
index 73cdb9fe981a..b23f7d6a1409 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
@@ -745,8 +745,8 @@ static bool compute_mst_dsc_configs_for_link(struct 
drm_atomic_state *state,
if (!dc_dsc_compute_bandwidth_range(
stream->sink->ctx->dc->res_pool->dscs[0],

stream->sink->ctx->dc->debug.dsc_min_slice_height_override,
-   dsc_policy.min_target_bpp,
-   dsc_policy.max_target_bpp,
+   dsc_policy.min_target_bpp * 16,
+   dsc_policy.max_target_bpp * 16,
&stream->sink->dsc_caps.dsc_dec_caps,
&stream->timing, ¶ms[count].bw_range))
params[count].bw_range.stream_kbps = 
dc_bandwidth_in_kbps_from_timing(&stream->timing);
-- 
2.31.1

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


[PATCH 17/19] drm/amd/display: add helper for enabling mst stream features

2021-04-16 Thread Aurabindo Pillai
From: Bing Guo 

[Why]
Some MST devices uses different method to enable mst
specific stream features.

[How]
Add dm_helpers_mst_enable_stream features. This can be
modified later when we are ready to implement those features.

Signed-off-by: Bing Guo 
Reviewed-by: Anthony Koo 
Acked-by: Aurabindo Pillai 
---
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 25 +
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 28 +++
 drivers/gpu/drm/amd/display/dc/dm_helpers.h   |  2 ++
 3 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index 103e29905b57..e8b325a828c1 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -711,3 +711,28 @@ bool dm_helpers_dmub_outbox0_interrupt_control(struct 
dc_context *ctx, bool enab
 enable ? "en" : "dis", ret);
return ret;
 }
+
+void dm_helpers_mst_enable_stream_features(const struct dc_stream_state 
*stream)
+{
+   /* TODO: virtual DPCD */
+   struct dc_link *link = stream->link;
+   union down_spread_ctrl old_downspread;
+   union down_spread_ctrl new_downspread;
+
+   if (link->aux_access_disabled)
+   return;
+
+   if (!dm_helpers_dp_read_dpcd(link->ctx, link, DP_DOWNSPREAD_CTRL,
+&old_downspread.raw,
+sizeof(old_downspread)))
+   return;
+
+   new_downspread.raw = old_downspread.raw;
+   new_downspread.bits.IGNORE_MSA_TIMING_PARAM =
+   (stream->ignore_msa_timing_param) ? 1 : 0;
+
+   if (new_downspread.raw != old_downspread.raw)
+   dm_helpers_dp_write_dpcd(link->ctx, link, DP_DOWNSPREAD_CTRL,
+&new_downspread.raw,
+sizeof(new_downspread));
+}
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index fa384923cfc1..f4374d83662a 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -1679,21 +1679,27 @@ void link_destroy(struct dc_link **link)
 static void enable_stream_features(struct pipe_ctx *pipe_ctx)
 {
struct dc_stream_state *stream = pipe_ctx->stream;
-   struct dc_link *link = stream->link;
-   union down_spread_ctrl old_downspread;
-   union down_spread_ctrl new_downspread;
 
-   core_link_read_dpcd(link, DP_DOWNSPREAD_CTRL,
-   &old_downspread.raw, sizeof(old_downspread));
+   if (pipe_ctx->stream->signal != SIGNAL_TYPE_DISPLAY_PORT_MST) {
+   struct dc_link *link = stream->link;
+   union down_spread_ctrl old_downspread;
+   union down_spread_ctrl new_downspread;
+
+   core_link_read_dpcd(link, DP_DOWNSPREAD_CTRL,
+   &old_downspread.raw, sizeof(old_downspread));
 
-   new_downspread.raw = old_downspread.raw;
+   new_downspread.raw = old_downspread.raw;
 
-   new_downspread.bits.IGNORE_MSA_TIMING_PARAM =
-   (stream->ignore_msa_timing_param) ? 1 : 0;
+   new_downspread.bits.IGNORE_MSA_TIMING_PARAM =
+   (stream->ignore_msa_timing_param) ? 1 : 0;
 
-   if (new_downspread.raw != old_downspread.raw) {
-   core_link_write_dpcd(link, DP_DOWNSPREAD_CTRL,
-   &new_downspread.raw, sizeof(new_downspread));
+   if (new_downspread.raw != old_downspread.raw) {
+   core_link_write_dpcd(link, DP_DOWNSPREAD_CTRL,
+   &new_downspread.raw, sizeof(new_downspread));
+   }
+
+   } else {
+   dm_helpers_mst_enable_stream_features(stream);
}
 }
 
diff --git a/drivers/gpu/drm/amd/display/dc/dm_helpers.h 
b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
index f41db27c44de..7617fab9e1f9 100644
--- a/drivers/gpu/drm/amd/display/dc/dm_helpers.h
+++ b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
@@ -147,6 +147,8 @@ bool dm_helpers_dp_write_dsc_enable(
 bool dm_helpers_is_dp_sink_present(
struct dc_link *link);
 
+void dm_helpers_mst_enable_stream_features(const struct dc_stream_state 
*stream);
+
 enum dc_edid_status dm_helpers_read_local_edid(
struct dc_context *ctx,
struct dc_link *link,
-- 
2.31.1

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


[PATCH 14/19] drm/amd/display: fix HDCP drm prop update for MST

2021-04-16 Thread Aurabindo Pillai
From: "Dingchen (David) Zhang" 

[why]
For MST topology with 1 physical link and multiple connectors (>=2),
e.g. daisy cahined MST + SST, or 1-to-multi MST hub, if userspace
set to enable the HDCP simultaneously on all connected outputs, the
commit tail iteratively call the hdcp_update_display() for each
display (connector). However, the hdcp workqueue data structure for
each link has only one DM connector and encryption status members,
which means the work queue of property_validate/update() would only
be triggered for the last connector within this physical link, and
therefore the HDCP property value of other connectors would stay on
DESIRED instead of switching to ENABLED, which is NOT as expected.

[how]
Use array of MAX_NUM_OF_DISPLAY for both aconnector and encryption
status in hdcp workqueue data structure for each physical link.
For property validate/update work queue, we iterates over the array
and do similar operation/check for each connected display.

Signed-off-by: Dingchen (David) Zhang 
Reviewed-by: Dingchen Zhang 
Acked-by: Aurabindo Pillai 
---
 .../amd/display/amdgpu_dm/amdgpu_dm_hdcp.c| 109 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_hdcp.h|   6 +-
 2 files changed, 81 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
index 50f6b3a86931..2ec076af9e89 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
@@ -171,9 +171,10 @@ void hdcp_update_display(struct hdcp_workqueue *hdcp_work,
struct mod_hdcp_display *display = &hdcp_work[link_index].display;
struct mod_hdcp_link *link = &hdcp_work[link_index].link;
struct mod_hdcp_display_query query;
+   unsigned int conn_index = aconnector->base.index;
 
mutex_lock(&hdcp_w->mutex);
-   hdcp_w->aconnector = aconnector;
+   hdcp_w->aconnector[conn_index] = aconnector;
 
query.display = NULL;
mod_hdcp_query_display(&hdcp_w->hdcp, aconnector->base.index, &query);
@@ -205,7 +206,7 @@ void hdcp_update_display(struct hdcp_workqueue *hdcp_work,
  
msecs_to_jiffies(DRM_HDCP_CHECK_PERIOD_MS));
} else {
display->adjust.disable = 
MOD_HDCP_DISPLAY_DISABLE_AUTHENTICATION;
-   hdcp_w->encryption_status = 
MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF;
+   hdcp_w->encryption_status[conn_index] = 
MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF;
cancel_delayed_work(&hdcp_w->property_validate_dwork);
}
 
@@ -224,9 +225,10 @@ static void hdcp_remove_display(struct hdcp_workqueue 
*hdcp_work,
 {
struct hdcp_workqueue *hdcp_w = &hdcp_work[link_index];
struct drm_connector_state *conn_state = aconnector->base.state;
+   unsigned int conn_index = aconnector->base.index;
 
mutex_lock(&hdcp_w->mutex);
-   hdcp_w->aconnector = aconnector;
+   hdcp_w->aconnector[conn_index] = aconnector;
 
/* the removal of display will invoke auth reset -> hdcp destroy and
 * we'd expect the CP prop changed back to DESIRED if at the time 
ENABLED.
@@ -247,13 +249,16 @@ static void hdcp_remove_display(struct hdcp_workqueue 
*hdcp_work,
 void hdcp_reset_display(struct hdcp_workqueue *hdcp_work, unsigned int 
link_index)
 {
struct hdcp_workqueue *hdcp_w = &hdcp_work[link_index];
+   unsigned int conn_index;
 
mutex_lock(&hdcp_w->mutex);
 
mod_hdcp_reset_connection(&hdcp_w->hdcp,  &hdcp_w->output);
 
cancel_delayed_work(&hdcp_w->property_validate_dwork);
-   hdcp_w->encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF;
+
+   for (conn_index = 0; conn_index < MAX_NUM_OF_DISPLAYS; ++conn_index)
+   hdcp_w->encryption_status[conn_index] = 
MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF;
 
process_output(hdcp_w);
 
@@ -290,38 +295,67 @@ static void event_callback(struct work_struct *work)
 
 
 }
+
+static struct amdgpu_dm_connector *find_first_connected_output(struct 
hdcp_workqueue *hdcp_work)
+{
+   unsigned int conn_index;
+
+   for (conn_index = 0; conn_index < MAX_NUM_OF_DISPLAYS; ++conn_index) {
+   if (hdcp_work->aconnector[conn_index])
+   return hdcp_work->aconnector[conn_index];
+   }
+
+   return NULL;
+}
+
 static void event_property_update(struct work_struct *work)
 {
 
struct hdcp_workqueue *hdcp_work = container_of(work, struct 
hdcp_workqueue, property_update_work);
-   struct amdgpu_dm_connector *aconnector = hdcp_work->aconnector;
-   struct drm_device *dev = hdcp_work->aconnector->base.dev;
+   struct amdgpu_dm_connector *aconnector = 
find_first_connected_output(hdcp_work);
+   struct drm_device *dev;
long ret;
+   unsigned int conn_index;
+   struct drm_connector *connector;
+   str

[PATCH 13/19] drm/amd/display: force CP to DESIRED when removing display.

2021-04-16 Thread Aurabindo Pillai
From: "Dingchen (David) Zhang" 

[why]
It is possible that the commit from userspace to cause link stream
disable and hdcp auth reset when the HDCP has been enabled at the
moment. We'd expect the CP prop back to DESIRED from ENABLED.

[how]
In the helper of hdcp display removal, we check and change the CP prop
to DESIRED if at the moment CP is ENABLED before the auth reset and
removal of linked list element.

Signed-off-by: Dingchen (David) Zhang 
Reviewed-by: Dingchen Zhang 
Acked-by: Aurabindo Pillai 
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c  | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
index 616f5b1ea3a8..50f6b3a86931 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
@@ -160,6 +160,7 @@ static void link_lock(struct hdcp_workqueue *work, bool 
lock)
mutex_unlock(&work[i].mutex);
}
 }
+
 void hdcp_update_display(struct hdcp_workqueue *hdcp_work,
 unsigned int link_index,
 struct amdgpu_dm_connector *aconnector,
@@ -222,10 +223,22 @@ static void hdcp_remove_display(struct hdcp_workqueue 
*hdcp_work,
 struct amdgpu_dm_connector *aconnector)
 {
struct hdcp_workqueue *hdcp_w = &hdcp_work[link_index];
+   struct drm_connector_state *conn_state = aconnector->base.state;
 
mutex_lock(&hdcp_w->mutex);
hdcp_w->aconnector = aconnector;
 
+   /* the removal of display will invoke auth reset -> hdcp destroy and
+* we'd expect the CP prop changed back to DESIRED if at the time 
ENABLED.
+* the CP prop change should occur before the element removed from 
linked list.
+*/
+   if (conn_state && conn_state->content_protection == 
DRM_MODE_CONTENT_PROTECTION_ENABLED) {
+   conn_state->content_protection = 
DRM_MODE_CONTENT_PROTECTION_DESIRED;
+
+   pr_debug("[HDCP_DM] display %d, CP 2 -> 1, type %u, DPMS %u\n",
+aconnector->base.index, conn_state->hdcp_content_type, 
aconnector->base.dpms);
+   }
+
mod_hdcp_remove_display(&hdcp_w->hdcp, aconnector->base.index, 
&hdcp_w->output);
 
process_output(hdcp_w);
-- 
2.31.1

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


[PATCH 03/19] drm/amd/display: update hdcp display using correct CP type.

2021-04-16 Thread Aurabindo Pillai
From: "Dingchen (David) Zhang" 

[why]
currently we enforce to update hdcp display using TYPE0, but there
is case that connector CP type prop be TYPE1 instead of type0.

[how]
using the drm prop of CP type of the connector as input argument.

Signed-off-by: Dingchen (David) Zhang 
Reviewed-by: Bhawanpreet Lakha 
Acked-by: Aurabindo Pillai 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
index 60f91853bd82..616f5b1ea3a8 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
@@ -434,6 +434,7 @@ static void update_config(void *handle, struct 
cp_psp_stream_config *config)
int link_index = aconnector->dc_link->link_index;
struct mod_hdcp_display *display = &hdcp_work[link_index].display;
struct mod_hdcp_link *link = &hdcp_work[link_index].link;
+   struct drm_connector_state *conn_state;
 
if (config->dpms_off) {
hdcp_remove_display(hdcp_work, link_index, aconnector);
@@ -459,8 +460,13 @@ static void update_config(void *handle, struct 
cp_psp_stream_config *config)
display->adjust.disable = MOD_HDCP_DISPLAY_DISABLE_AUTHENTICATION;
link->adjust.auth_delay = 3;
link->adjust.hdcp1.disable = 0;
+   conn_state = aconnector->base.state;
 
-   hdcp_update_display(hdcp_work, link_index, aconnector, 
DRM_MODE_HDCP_CONTENT_TYPE0, false);
+   pr_debug("[HDCP_DM] display %d, CP %d, type %d\n", 
aconnector->base.index,
+   (!!aconnector->base.state) ? 
aconnector->base.state->content_protection : -1,
+   (!!aconnector->base.state) ? 
aconnector->base.state->hdcp_content_type : -1);
+
+   hdcp_update_display(hdcp_work, link_index, aconnector, 
conn_state->hdcp_content_type, false);
 }
 
 
-- 
2.31.1

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


[PATCH 01/19] drm/amd/display: fixed divide by zero kernel crash during dsc enablement

2021-04-16 Thread Aurabindo Pillai
From: Robin Singh 

[why]
During dsc enable, a divide by zero condition triggered the
kernel crash.

[how]
An IGT test, which enable the DSC, was crashing at the time of
restore the default dsc status, becaue of h_totals value
becoming 0. So add a check before divide condition. If h_total
is zero, gracefully ignore and set the default value.

kernel panic log:

[  128.758827] divide error:  [#1] PREEMPT SMP NOPTI
[  128.762714] CPU: 5 PID: 4562 Comm: amd_dp_dsc Tainted: GW
 5.4.19-android-x86_64 #1
[  128.769728] Hardware name: ADVANCED MICRO DEVICES, INC. Mauna/Mauna, 
BIOS WMN0B13N Nov 11 2020
[  128.777695] RIP: 0010:hubp2_vready_at_or_After_vsync+0x37/0x7a 
[amdgpu]
[  128.785707] Code: 80 02 00 00 48 89 f3 48 8b 7f 08 b ..
[  128.805696] RSP: 0018:ad8f82d43628 EFLAGS: 00010246
..
[  128.857707] CR2: 7106d8465000 CR3: 00042653 CR4: 
00140ee0
[  128.865695] Call Trace:
[  128.869712] hubp3_setup+0x1f/0x7f [amdgpu]
[  128.873705] dcn20_update_dchubp_dpp+0xc8/0x54a [amdgpu]
[  128.877706] dcn20_program_front_end_for_ctx+0x31d/0x463 [amdgpu]
[  128.885706] dc_commit_state+0x3d2/0x658 [amdgpu]
[  128.889707] amdgpu_dm_atomic_commit_tail+0x4b3/0x1e7c [amdgpu]
[  128.897699] ? dm_read_reg_func+0x41/0xb5 [amdgpu]
[  128.901707] ? dm_read_reg_func+0x41/0xb5 [amdgpu]
[  128.905706] ? __is_insn_slot_addr+0x43/0x48
[  128.909706] ? fill_plane_buffer_attributes+0x29e/0x3dc [amdgpu]
[  128.917705] ? dm_plane_helper_prepare_fb+0x255/0x284 [amdgpu]
[  128.921700] ? usleep_range+0x7c/0x7c
[  128.925705] ? preempt_count_sub+0xf/0x18
[  128.929706] ? _raw_spin_unlock_irq+0x13/0x24
[  128.933732] ? __wait_for_common+0x11e/0x18f
[  128.937705] ? _raw_spin_unlock_irq+0x13/0x24
[  128.941706] ? __wait_for_common+0x11e/0x18f
[  128.945705] commit_tail+0x8b/0xd2 [drm_kms_helper]
[  128.949707] drm_atomic_helper_commit+0xd8/0xf5 [drm_kms_helper]
[  128.957706] amdgpu_dm_atomic_commit+0x337/0x360 [amdgpu]
[  128.961705] ? drm_atomic_check_only+0x543/0x68d [drm]
[  128.969705] ? drm_atomic_set_property+0x760/0x7af [drm]
[  128.973704] ? drm_mode_atomic_ioctl+0x6f3/0x85a [drm]
[  128.977705] drm_mode_atomic_ioctl+0x6f3/0x85a [drm]
[  128.985705] ? drm_atomic_set_property+0x7af/0x7af [drm]
[  128.989706] drm_ioctl_kernel+0x82/0xda [drm]
[  128.993706] drm_ioctl+0x225/0x319 [drm]
[  128.997707] ? drm_atomic_set_property+0x7af/0x7af [drm]
[  129.001706] ? preempt_count_sub+0xf/0x18
[  129.005713] amdgpu_drm_ioctl+0x4b/0x76 [amdgpu]
[  129.009705] vfs_ioctl+0x1d/0x2a
[  129.013705] do_vfs_ioctl+0x419/0x43d
[  129.017707] ksys_ioctl+0x52/0x71
[  129.021707] __x64_sys_ioctl+0x16/0x19
[  129.025706] do_syscall_64+0x78/0x85
[  129.029705] entry_SYSCALL_64_after_hwframe+0x44/0xa9

Signed-off-by: Robin Singh 
Reviewed-by: Harry Wentland 
Reviewed-by: Robin Singh 
Acked-by: Aurabindo Pillai 
---
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hubp.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hubp.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hubp.c
index bec7059f6d5d..a1318c31bcfa 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hubp.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hubp.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012-17 Advanced Micro Devices, Inc.
+ * Copyright 2012-2021 Advanced Micro Devices, Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -181,11 +181,14 @@ void hubp2_vready_at_or_After_vsync(struct hubp *hubp,
else
Set HUBP_VREADY_AT_OR_AFTER_VSYNC = 0
*/
-   if ((pipe_dest->vstartup_start - 
(pipe_dest->vready_offset+pipe_dest->vupdate_width
-   + pipe_dest->vupdate_offset) / pipe_dest->htotal) <= 
pipe_dest->vblank_end) {
-   value = 1;
-   } else
-   value = 0;
+   if (pipe_dest->htotal != 0) {
+   if ((pipe_dest->vstartup_start - 
(pipe_dest->vready_offset+pipe_dest->vupdate_width
+   + pipe_dest->vupdate_offset) / pipe_dest->htotal) <= 
pipe_dest->vblank_end) {
+   value = 1;
+   } else
+   value = 0;
+   }
+
REG_UPDATE(DCHUBP_CNTL, HUBP_VREADY_AT_OR_AFTER_VSYNC, value);
 }
 
-- 
2.31.1

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


[PATCH 06/19] drm/amd/display: removed unused function dc_link_reallocate_mst_payload.

2021-04-16 Thread Aurabindo Pillai
From: Robin Singh 

[Why]
Found that dc_link_reallocate_mst_payload is not used anymore
in any of the use case scenario.

[How]
removed dc_link_reallocate_mst_payload function definition
and declaration.

Signed-off-by: Robin Singh 
Reviewed-by: Harry Wentland 
Acked-by: Aurabindo Pillai 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 44 ---
 drivers/gpu/drm/amd/display/dc/dc_link.h  |  1 -
 2 files changed, 45 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index 9507b08567b4..fa384923cfc1 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -3136,50 +3136,6 @@ static enum dc_status deallocate_mst_payload(struct 
pipe_ctx *pipe_ctx)
return DC_OK;
 }
 
-enum dc_status dc_link_reallocate_mst_payload(struct dc_link *link)
-{
-   int i;
-   struct pipe_ctx *pipe_ctx;
-
-   // Clear all of MST payload then reallocate
-   for (i = 0; i < MAX_PIPES; i++) {
-   pipe_ctx = &link->dc->current_state->res_ctx.pipe_ctx[i];
-
-   /* driver enable split pipe for external monitors
-* we have to check pipe_ctx is split pipe or not
-* If it's split pipe, driver using top pipe to
-* reaallocate.
-*/
-   if (!pipe_ctx || pipe_ctx->top_pipe)
-   continue;
-
-   if (pipe_ctx->stream && pipe_ctx->stream->link == link &&
-   pipe_ctx->stream->dpms_off == false &&
-   pipe_ctx->stream->signal == 
SIGNAL_TYPE_DISPLAY_PORT_MST) {
-   deallocate_mst_payload(pipe_ctx);
-   }
-   }
-
-   for (i = 0; i < MAX_PIPES; i++) {
-   pipe_ctx = &link->dc->current_state->res_ctx.pipe_ctx[i];
-
-   if (!pipe_ctx || pipe_ctx->top_pipe)
-   continue;
-
-   if (pipe_ctx->stream && pipe_ctx->stream->link == link &&
-   pipe_ctx->stream->dpms_off == false &&
-   pipe_ctx->stream->signal == 
SIGNAL_TYPE_DISPLAY_PORT_MST) {
-   /* enable/disable PHY will clear connection between BE 
and FE
-* need to restore it.
-*/
-   
link->link_enc->funcs->connect_dig_be_to_fe(link->link_enc,
-   
pipe_ctx->stream_res.stream_enc->id, true);
-   dc_link_allocate_mst_payload(pipe_ctx);
-   }
-   }
-
-   return DC_OK;
-}
 
 #if defined(CONFIG_DRM_AMD_DC_HDCP)
 static void update_psp_stream_config(struct pipe_ctx *pipe_ctx, bool dpms_off)
diff --git a/drivers/gpu/drm/amd/display/dc/dc_link.h 
b/drivers/gpu/drm/amd/display/dc/dc_link.h
index b0013e674864..054bab45ee17 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_link.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_link.h
@@ -276,7 +276,6 @@ enum dc_detect_reason {
 bool dc_link_detect(struct dc_link *dc_link, enum dc_detect_reason reason);
 bool dc_link_get_hpd_state(struct dc_link *dc_link);
 enum dc_status dc_link_allocate_mst_payload(struct pipe_ctx *pipe_ctx);
-enum dc_status dc_link_reallocate_mst_payload(struct dc_link *link);
 
 /* Notify DC about DP RX Interrupt (aka Short Pulse Interrupt).
  * Return:
-- 
2.31.1

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


[PATCH 04/19] drm/amd/display: add handling for hdcp2 rx id list validation

2021-04-16 Thread Aurabindo Pillai
From: "Dingchen (David) Zhang" 

[why]
the current implementation of hdcp2 rx id list validation does not
have handler/checker for invalid message status, e.g. HMAC, the V
parameter calculated from PSP not matching the V prime from Rx.

[how]
return a generic FAILURE for any message status not SUCCESS or
REVOKED.

Signed-off-by: Dingchen (David) Zhang 
Reviewed-by: Bhawanpreet Lakha 
Acked-by: Aurabindo Pillai 
---
 drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
index 9d7ca316dc3f..26f96c05e0ec 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
@@ -791,6 +791,8 @@ enum mod_hdcp_status 
mod_hdcp_hdcp2_validate_rx_id_list(struct mod_hdcp *hdcp)
   
TA_HDCP2_MSG_AUTHENTICATION_STATUS__RECEIVERID_REVOKED) {
hdcp->connection.is_hdcp2_revoked = 1;
status = MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_REVOKED;
+   } else {
+   status = 
MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE;
}
}
mutex_unlock(&psp->hdcp_context.mutex);
-- 
2.31.1

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


[PATCH 11/19] drm/amd/display: Always poll for rxstatus in authenticate

2021-04-16 Thread Aurabindo Pillai
From: Nicholas Kazlauskas 

[Why]
Requirement from the spec - we shouldn't be potentially exiting out
early based on encryption status.

[How]
Drop the calls from HDCP1 and HDCP2 execution that exit out early
based on link encryption status.

Signed-off-by: Nicholas Kazlauskas 
Reviewed-by: Wenjing Liu 
Acked-by: Aurabindo Pillai 
---
 drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c | 2 --
 drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_execution.c | 2 --
 2 files changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c
index eeac14300a2a..2cbd931363bd 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c
@@ -427,8 +427,6 @@ static enum mod_hdcp_status authenticated_dp(struct 
mod_hdcp *hdcp,
event_ctx->unexpected_event = 1;
goto out;
}
-   if (!mod_hdcp_is_link_encryption_enabled(hdcp))
-   goto out;
 
if (status == MOD_HDCP_STATUS_SUCCESS)
mod_hdcp_execute_and_set(mod_hdcp_read_bstatus,
diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_execution.c 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_execution.c
index f164f6a5d4dc..c1331facdcb4 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_execution.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_execution.c
@@ -564,8 +564,6 @@ static enum mod_hdcp_status authenticated(struct mod_hdcp 
*hdcp,
event_ctx->unexpected_event = 1;
goto out;
}
-   if (!mod_hdcp_is_link_encryption_enabled(hdcp))
-   goto out;
 
process_rxstatus(hdcp, event_ctx, input, &status);
 
-- 
2.31.1

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


[PATCH 12/19] drm/amd/display: Fixed typo in function name.

2021-04-16 Thread Aurabindo Pillai
From: David Galiffi 

[How & Why]
Changed "prsent" to "present".

Signed-off-by: David Galiffi 
Reviewed-by: Chris Park 
Acked-by: Aurabindo Pillai 
---
 drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c
index 577e7f97045e..652fa89fae5f 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c
@@ -432,7 +432,7 @@ static void dcn3_get_memclk_states_from_smu(struct clk_mgr 
*clk_mgr_base)
clk_mgr->base.ctx->dc, clk_mgr_base->bw_params);
 }
 
-static bool dcn3_is_smu_prsent(struct clk_mgr *clk_mgr_base)
+static bool dcn3_is_smu_present(struct clk_mgr *clk_mgr_base)
 {
struct clk_mgr_internal *clk_mgr = TO_CLK_MGR_INTERNAL(clk_mgr_base);
return clk_mgr->smu_present;
@@ -500,7 +500,7 @@ static struct clk_mgr_funcs dcn3_funcs = {
.are_clock_states_equal = dcn3_are_clock_states_equal,
.enable_pme_wa = dcn3_enable_pme_wa,
.notify_link_rate_change = dcn30_notify_link_rate_change,
-   .is_smu_present = dcn3_is_smu_prsent
+   .is_smu_present = dcn3_is_smu_present
 };
 
 static void dcn3_init_clocks_fpga(struct clk_mgr *clk_mgr)
-- 
2.31.1

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


[PATCH 02/19] drm/amd/display: Add DSC check to seamless boot validation

2021-04-16 Thread Aurabindo Pillai
From: Anthony Wang 

[Why & How]
We want to immediately fail seamless boot validation if DSC is active,
as VBIOS currently does not support DSC timings. Add a check for
the relevant flag in dc_validate_seamless_boot_timing.

Signed-off-by: Anthony Wang 
Reviewed-by: Martin Leung 
Acked-by: Aurabindo Pillai 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 757820a3f068..724ddce8aa41 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1400,6 +1400,10 @@ bool dc_validate_seamless_boot_timing(const struct dc 
*dc,
if (crtc_timing->v_sync_width != hw_crtc_timing.v_sync_width)
return false;
 
+   /* block DSC for now, as VBIOS does not currently support DSC timings */
+   if (crtc_timing->flags.DSC)
+   return false;
+
if (dc_is_dp_signal(link->connector_signal)) {
unsigned int pix_clk_100hz;
 
-- 
2.31.1

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


[PATCH 10/19] drm/amd/display: Add link rate optimization logs for ILR

2021-04-16 Thread Aurabindo Pillai
From: Michael Strauss 

[Why&How]
Add logs to verify ILR optimization behaviour on boot

Signed-off-by: Michael Strauss 
Reviewed-by: Nicholas Kazlauskas 
Acked-by: Aurabindo Pillai 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 1 +
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 9 +++--
 .../gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c  | 4 
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 79c652eaddb6..4713f09bcbf1 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1434,6 +1434,7 @@ bool dc_validate_seamless_boot_timing(const struct dc *dc,
}
 
if (is_edp_ilr_optimization_required(link, crtc_timing)) {
+   DC_LOG_EVENT_LINK_TRAINING("Seamless boot disabled to optimize 
eDP link rate\n");
return false;
}
 
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index bbf2865b25c5..3ff3d9e90983 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -4739,8 +4739,10 @@ bool is_edp_ilr_optimization_required(struct dc_link 
*link, struct dc_crtc_timin
core_link_read_dpcd(link, DP_LINK_BW_SET,
&link_bw_set, sizeof(link_bw_set));
 
-   if (link_bw_set)
+   if (link_bw_set) {
+   DC_LOG_EVENT_LINK_TRAINING("eDP ILR: Optimization required, 
VBIOS used link_bw_set\n");
return true;
+   }
 
// Read DPCD 00115h to find the edp link rate set used
core_link_read_dpcd(link, DP_LINK_RATE_SET,
@@ -4755,9 +4757,12 @@ bool is_edp_ilr_optimization_required(struct dc_link 
*link, struct dc_crtc_timin
decide_edp_link_settings(link, &link_setting, req_bw);
 
if (link->dpcd_caps.edp_supported_link_rates[link_rate_set] != 
link_setting.link_rate ||
-   lane_count_set.bits.LANE_COUNT_SET != 
link_setting.lane_count)
+   lane_count_set.bits.LANE_COUNT_SET != 
link_setting.lane_count) {
+   DC_LOG_EVENT_LINK_TRAINING("eDP ILR: Optimization required, 
VBIOS link_rate_set not optimal\n");
return true;
+   }
 
+   DC_LOG_EVENT_LINK_TRAINING("eDP ILR: No optimization required, VBIOS 
set optimal link_rate_set\n");
return false;
 }
 
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c 
b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
index dd903b267ca5..5ddeee96bf23 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
@@ -1695,6 +1695,8 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct 
dc_state *context)
bool can_apply_edp_fast_boot = false;
bool can_apply_seamless_boot = false;
bool keep_edp_vdd_on = false;
+   DC_LOGGER_INIT();
+
 
get_edp_links_with_sink(dc, edp_links_with_sink, &edp_with_sink_num);
get_edp_links(dc, edp_links, &edp_num);
@@ -1717,6 +1719,8 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct 
dc_state *context)
edp_stream = edp_streams[0];
can_apply_edp_fast_boot = 
!is_edp_ilr_optimization_required(edp_stream->link, &edp_stream->timing);

edp_stream->apply_edp_fast_boot_optimization = can_apply_edp_fast_boot;
+   if (can_apply_edp_fast_boot)
+   DC_LOG_EVENT_LINK_TRAINING("eDP 
fast boot disabled to optimize link rate\n");
 
break;
}
-- 
2.31.1

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


[PATCH 08/19] drm/amd/display: Fix FreeSync when RGB MPO in use

2021-04-16 Thread Aurabindo Pillai
From: Aric Cyr 

[WHY]
We should skip programming manual trigger on non-primary planes when MPO is
enabled.

[HOW]
Implement an explicit mechanism for skipping manual trigger programming
for planes that shouldn't cause the frame to end.

Signed-off-by: Aric Cyr 
Reviewed-by: Anthony Koo 
Acked-by: Aurabindo Pillai 
Acked-by: Krunoslav Kovac 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 3 ++-
 drivers/gpu/drm/amd/display/dc/dc.h  | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index ee4970491d7b..79c652eaddb6 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -2833,7 +2833,8 @@ static void commit_planes_for_stream(struct dc *dc,
 
if (pipe_ctx->bottom_pipe || pipe_ctx->next_odm_pipe ||
!pipe_ctx->stream || pipe_ctx->stream != stream 
||
-   
!pipe_ctx->plane_state->update_flags.bits.addr_update)
+   
!pipe_ctx->plane_state->update_flags.bits.addr_update ||
+   pipe_ctx->plane_state->skip_manual_trigger)
continue;
 
if (pipe_ctx->stream_res.tg->funcs->program_manual_trigger)
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 870cd7c6a387..ed19b9b39af0 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -907,6 +907,8 @@ struct dc_plane_state {
 
union surface_update_flags update_flags;
bool flip_int_enabled;
+   bool skip_manual_trigger;
+
/* private to DC core */
struct dc_plane_status status;
struct dc_context *ctx;
-- 
2.31.1

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


[PATCH 09/19] drm/amd/display: Unconditionally clear training pattern set after lt

2021-04-16 Thread Aurabindo Pillai
From: Wesley Chalmers 

[WHY]
While Link Training is being performed,
and the LTTPRs are in Non-LTTPR or LTTPR Transparent mode,
any DPCD registers besides those used for Link Training are not to be
accessed.

The spec defines the link training registers as DP_TRAINING_PATTERN_SET
(102h) to DP_TRAINING_LANE3_SET (106h), and DP_LANE0_1_STATUS (202h)
to DP_ADJUST_REQUEST_LANE2_3 (207h).

[HOW]
Move the current write to DPCD Address DP_LINK_TRAINING_PATTERN_SET out
of its conditional block.

Signed-off-by: Wesley Chalmers 
Reviewed-by: Jun Lei 
Acked-by: Aurabindo Pillai 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index e6f8f3c255bc..bbf2865b25c5 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -1132,11 +1132,6 @@ static inline enum link_training_result 
perform_link_training_int(
enum link_training_result status)
 {
union lane_count_set lane_count_set = { {0} };
-   union dpcd_training_pattern dpcd_pattern = { {0} };
-
-   /* 3. set training not in progress*/
-   dpcd_pattern.v1_4.TRAINING_PATTERN_SET = 
DPCD_TRAINING_PATTERN_VIDEOIDLE;
-   dpcd_set_training_pattern(link, dpcd_pattern);
 
/* 4. mainlink output idle pattern*/
dp_set_hw_test_pattern(link, DP_TEST_PATTERN_VIDEO_MODE, NULL, 0);
@@ -1560,6 +1555,7 @@ enum link_training_result 
dc_link_dp_perform_link_training(
 {
enum link_training_result status = LINK_TRAINING_SUCCESS;
struct link_training_settings lt_settings;
+   union dpcd_training_pattern dpcd_pattern = { { 0 } };
 
bool fec_enable;
uint8_t repeater_cnt;
@@ -1624,6 +1620,9 @@ enum link_training_result 
dc_link_dp_perform_link_training(
}
}
 
+   /* 3. set training not in progress*/
+   dpcd_pattern.v1_4.TRAINING_PATTERN_SET = 
DPCD_TRAINING_PATTERN_VIDEOIDLE;
+   dpcd_set_training_pattern(link, dpcd_pattern);
if ((status == LINK_TRAINING_SUCCESS) || !skip_video_pattern) {
status = perform_link_training_int(link,
<_settings,
-- 
2.31.1

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


[PATCH 07/19] drm/amd/display: treat memory as a single-channel for asymmetric memory v2

2021-04-16 Thread Aurabindo Pillai
From: Hugo Hu 

Previous change had been reverted since it caused hang.
Remake change to avoid defect.

[Why]
1. Driver use umachannelnumber to calculate watermarks for stutter.
In asymmetric memory config, the actual bandwidth is less than
dual-channel. The bandwidth should be the same as single-channel.
2. We found single rank dimm need additional delay time for stutter.

[How]
Get information from each DIMM. Treat memory config as a single-channel
for asymmetric memory in bandwidth calculating.
Add additional delay time for single rank dimm.

Fixes: 8a3e4b2516 ("drm/amd/display: System black screen hangs on driver load")
Signed-off-by: Hugo Hu 
Reviewed-by: Sung Lee 
Acked-by: Aurabindo Pillai 
---
 .../amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c | 48 ++-
 drivers/gpu/drm/amd/display/dc/dc.h   |  2 +
 2 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
index 73e8878b03b6..a06e86853bb9 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
@@ -769,6 +769,43 @@ static struct wm_table ddr4_wm_table_rn = {
}
 };
 
+static struct wm_table ddr4_1R_wm_table_rn = {
+   .entries = {
+   {
+   .wm_inst = WM_A,
+   .wm_type = WM_TYPE_PSTATE_CHG,
+   .pstate_latency_us = 11.72,
+   .sr_exit_time_us = 13.90,
+   .sr_enter_plus_exit_time_us = 14.80,
+   .valid = true,
+   },
+   {
+   .wm_inst = WM_B,
+   .wm_type = WM_TYPE_PSTATE_CHG,
+   .pstate_latency_us = 11.72,
+   .sr_exit_time_us = 13.90,
+   .sr_enter_plus_exit_time_us = 14.80,
+   .valid = true,
+   },
+   {
+   .wm_inst = WM_C,
+   .wm_type = WM_TYPE_PSTATE_CHG,
+   .pstate_latency_us = 11.72,
+   .sr_exit_time_us = 13.90,
+   .sr_enter_plus_exit_time_us = 14.80,
+   .valid = true,
+   },
+   {
+   .wm_inst = WM_D,
+   .wm_type = WM_TYPE_PSTATE_CHG,
+   .pstate_latency_us = 11.72,
+   .sr_exit_time_us = 13.90,
+   .sr_enter_plus_exit_time_us = 14.80,
+   .valid = true,
+   },
+   }
+};
+
 static struct wm_table lpddr4_wm_table_rn = {
.entries = {
{
@@ -953,8 +990,12 @@ void rn_clk_mgr_construct(
} else {
if (is_green_sardine)
rn_bw_params.wm_table = ddr4_wm_table_gs;
-   else
-   rn_bw_params.wm_table = ddr4_wm_table_rn;
+   else {
+   if (ctx->dc->config.is_single_rank_dimm)
+   rn_bw_params.wm_table = 
ddr4_1R_wm_table_rn;
+   else
+   rn_bw_params.wm_table = 
ddr4_wm_table_rn;
+   }
}
/* Saved clocks configured at boot for debug purposes */
rn_dump_clk_registers(&clk_mgr->base.boot_snapshot, 
&clk_mgr->base, &log_info);
@@ -972,6 +1013,9 @@ void rn_clk_mgr_construct(
if (status == PP_SMU_RESULT_OK &&
ctx->dc_bios && ctx->dc_bios->integrated_info) {
rn_clk_mgr_helper_populate_bw_params 
(clk_mgr->base.bw_params, &clock_table, ctx->dc_bios->integrated_info);
+   /* treat memory config as single channel if memory is 
asymmetrics. */
+   if (ctx->dc->config.is_asymmetric_memory)
+   clk_mgr->base.bw_params->num_channels = 1;
}
}
 
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 82a324a618db..870cd7c6a387 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -308,6 +308,8 @@ struct dc_config {
 #endif
uint64_t vblank_alignment_dto_params;
uint8_t  vblank_alignment_max_frame_time_diff;
+   bool is_asymmetric_memory;
+   bool is_single_rank_dimm;
 };
 
 enum visual_confirm {
-- 
2.31.1

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


[PATCH 05/19] drm/amd/display: disable seamless boot for external DP

2021-04-16 Thread Aurabindo Pillai
From: Anthony Wang 

[Why]
Primary feature use case is with eDP panels.

[How]
Fail seamless boot validation if display is not an eDP panel.

Signed-off-by: Anthony Wang 
Reviewed-by: Martin Leung 
Acked-by: Aurabindo Pillai 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 724ddce8aa41..ee4970491d7b 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1323,11 +1323,10 @@ bool dc_validate_seamless_boot_timing(const struct dc 
*dc,
struct dc_link *link = sink->link;
unsigned int i, enc_inst, tg_inst = 0;
 
-   // Seamless port only support single DP and EDP so far
-   if ((sink->sink_signal != SIGNAL_TYPE_DISPLAY_PORT &&
-   sink->sink_signal != SIGNAL_TYPE_EDP) ||
-   sink->sink_signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
+   /* Support seamless boot on EDP displays only */
+   if (sink->sink_signal != SIGNAL_TYPE_EDP) {
return false;
+   }
 
/* Check for enabled DIG to identify enabled display */
if (!link->link_enc->funcs->is_dig_enabled(link->link_enc))
-- 
2.31.1

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


[PATCH 00/19] DC Patches for 2021 April 19

2021-04-16 Thread Aurabindo Pillai
This DC patchset brings improvements in multiple areas. In summary, we 
highlight:

* DC v3.2.132
* Fw v0.0.62
* Bug fixes across HDCP, DSC, FreeSync, etc

--

Anthony Koo (1):
  drm/amd/display: [FW Promotion] Release 0.0.62

Anthony Wang (2):
  drm/amd/display: Add DSC check to seamless boot validation
  drm/amd/display: disable seamless boot for external DP

Aric Cyr (2):
  drm/amd/display: Fix FreeSync when RGB MPO in use
  drm/amd/display: 3.2.132

Bing Guo (1):
  drm/amd/display: add helper for enabling mst stream features

David Galiffi (1):
  drm/amd/display: Fixed typo in function name.

Dillon Varone (2):
  drm/amd/display: Fix call to pass bpp in 16ths of a bit
  drm/amd/display: Report Proper Quantization Range in AVI Infoframe

Dingchen (David) Zhang (4):
  drm/amd/display: update hdcp display using correct CP type.
  drm/amd/display: add handling for hdcp2 rx id list validation
  drm/amd/display: force CP to DESIRED when removing display.
  drm/amd/display: fix HDCP drm prop update for MST

Hugo Hu (1):
  drm/amd/display: treat memory as a single-channel for asymmetric
memory v2

Michael Strauss (1):
  drm/amd/display: Add link rate optimization logs for ILR

Nicholas Kazlauskas (1):
  drm/amd/display: Always poll for rxstatus in authenticate

Robin Singh (2):
  drm/amd/display: fixed divide by zero kernel crash during dsc
enablement
  drm/amd/display: removed unused function
dc_link_reallocate_mst_payload.

Wesley Chalmers (1):
  drm/amd/display: Unconditionally clear training pattern set after lt

 .../amd/display/amdgpu_dm/amdgpu_dm_hdcp.c| 130 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_hdcp.h|   6 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c |  25 
 .../display/amdgpu_dm/amdgpu_dm_mst_types.c   |   4 +-
 .../amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c |  48 ++-
 .../display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c  |   4 +-
 drivers/gpu/drm/amd/display/dc/core/dc.c  |  15 +-
 drivers/gpu/drm/amd/display/dc/core/dc_link.c |  72 +++---
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  |  18 ++-
 .../gpu/drm/amd/display/dc/core/dc_resource.c |  33 +++--
 drivers/gpu/drm/amd/display/dc/dc.h   |   6 +-
 drivers/gpu/drm/amd/display/dc/dc_link.h  |   1 -
 .../display/dc/dce110/dce110_hw_sequencer.c   |   4 +
 .../gpu/drm/amd/display/dc/dcn20/dcn20_hubp.c |  15 +-
 drivers/gpu/drm/amd/display/dc/dm_helpers.h   |   2 +
 .../gpu/drm/amd/display/dmub/inc/dmub_cmd.h   |   4 +-
 .../display/modules/hdcp/hdcp1_execution.c|   2 -
 .../display/modules/hdcp/hdcp2_execution.c|   2 -
 .../drm/amd/display/modules/hdcp/hdcp_psp.c   |   2 +
 19 files changed, 257 insertions(+), 136 deletions(-)

-- 
2.31.1

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


Re: [PATCH v3 5/7] drm/vmwgfx: Inline ttm_bo_mmap() into vmwgfx driver

2021-04-16 Thread Thomas Zimmermann

Hi

Am 16.04.21 um 15:46 schrieb Christian König:

Am 16.04.21 um 15:31 schrieb Thomas Zimmermann:

The vmwgfx driver is the only remaining user of ttm_bo_mmap(). Inline
the code. The internal helper ttm_bo_vm_lookup() is now also part of
vmwgfx as vmw_bo_vm_lookup().

v2:
* replace pr_err() with drm_err() (Zack)

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Zack Rusin 
---
  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c | 56 ++--
  1 file changed, 53 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c

index cb9975889e2f..c8b6543b4e39 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
@@ -27,6 +27,32 @@
  #include "vmwgfx_drv.h"
+static struct ttm_buffer_object *vmw_bo_vm_lookup(struct ttm_device 
*bdev,

+  unsigned long offset,
+  unsigned long pages)
+{
+    struct vmw_private *dev_priv = container_of(bdev, struct 
vmw_private, bdev);

+    struct drm_device *drm = &dev_priv->drm;
+    struct drm_vma_offset_node *node;
+    struct ttm_buffer_object *bo = NULL;
+
+    drm_vma_offset_lock_lookup(bdev->vma_manager);
+
+    node = drm_vma_offset_lookup_locked(bdev->vma_manager, offset, 
pages);

+    if (likely(node)) {
+    bo = container_of(node, struct ttm_buffer_object,
+  base.vma_node);
+    bo = ttm_bo_get_unless_zero(bo);
+    }
+
+    drm_vma_offset_unlock_lookup(bdev->vma_manager);
+
+    if (!bo)
+    drm_err(drm, "Could not find buffer object to map\n");
+
+    return bo;
+}
+
  int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
  {
  static const struct vm_operations_struct vmw_vm_ops = {
@@ -41,10 +67,28 @@ int vmw_mmap(struct file *filp, struct 
vm_area_struct *vma)

  };
  struct drm_file *file_priv = filp->private_data;
  struct vmw_private *dev_priv = vmw_priv(file_priv->minor->dev);
-    int ret = ttm_bo_mmap(filp, vma, &dev_priv->bdev);
+    struct ttm_device *bdev = &dev_priv->bdev;
+    struct ttm_buffer_object *bo;
+    int ret;
+
+    if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET_START))
+    return -EINVAL;
+
+    bo = vmw_bo_vm_lookup(bdev, vma->vm_pgoff, vma_pages(vma));
+    if (unlikely(!bo))
+    return -EINVAL;
-    if (ret)
-    return ret;
+    if (unlikely(!bo->bdev->funcs->verify_access)) {
+    ret = -EPERM;
+    goto out_unref;
+    }
+    ret = bo->bdev->funcs->verify_access(bo, filp);


Is there any reason we can't call vmw_verify_access() directly here?

Would allow us to completely nuke the verify_access callback as well as 



far as I can see.


We have to spare something for patches 6 and 7. Otherwise they'd be 
empty. ;)


Best regards
Thomas



Regards,
Christian.


+    if (unlikely(ret != 0))
+    goto out_unref;
+
+    ret = ttm_bo_mmap_obj(vma, bo);
+    if (unlikely(ret != 0))
+    goto out_unref;
  vma->vm_ops = &vmw_vm_ops;
@@ -52,7 +96,13 @@ int vmw_mmap(struct file *filp, struct 
vm_area_struct *vma)

  if (!is_cow_mapping(vma->vm_flags))
  vma->vm_flags = 

(vma->vm_flags & ~VM_MIXEDMAP) | VM_PFNMAP;

+    ttm_bo_put(bo); /* release extra ref taken by ttm_bo_mmap_obj() */
+
  return 0;
+
+out_unref:
+    ttm_bo_put(bo);
+    return ret;
  }
  /* struct vmw_validation_mem callback */


___
dri-devel mailing list
dri-de...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer



OpenPGP_signature
Description: OpenPGP digital signature
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH v3 5/7] drm/vmwgfx: Inline ttm_bo_mmap() into vmwgfx driver

2021-04-16 Thread Christian König

Am 16.04.21 um 15:46 schrieb Christian König:

Am 16.04.21 um 15:31 schrieb Thomas Zimmermann:

The vmwgfx driver is the only remaining user of ttm_bo_mmap(). Inline
the code. The internal helper ttm_bo_vm_lookup() is now also part of
vmwgfx as vmw_bo_vm_lookup().

v2:
* replace pr_err() with drm_err() (Zack)

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Zack Rusin 
---
  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c | 56 ++--
  1 file changed, 53 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c

index cb9975889e2f..c8b6543b4e39 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
@@ -27,6 +27,32 @@
    #include "vmwgfx_drv.h"
  +static struct ttm_buffer_object *vmw_bo_vm_lookup(struct 
ttm_device *bdev,

+  unsigned long offset,
+  unsigned long pages)
+{
+    struct vmw_private *dev_priv = container_of(bdev, struct 
vmw_private, bdev);

+    struct drm_device *drm = &dev_priv->drm;
+    struct drm_vma_offset_node *node;
+    struct ttm_buffer_object *bo = NULL;
+
+    drm_vma_offset_lock_lookup(bdev->vma_manager);
+
+    node = drm_vma_offset_lookup_locked(bdev->vma_manager, offset, 
pages);

+    if (likely(node)) {
+    bo = container_of(node, struct ttm_buffer_object,
+  base.vma_node);
+    bo = ttm_bo_get_unless_zero(bo);
+    }
+
+    drm_vma_offset_unlock_lookup(bdev->vma_manager);
+
+    if (!bo)
+    drm_err(drm, "Could not find buffer object to map\n");
+
+    return bo;
+}
+
  int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
  {
  static const struct vm_operations_struct vmw_vm_ops = {
@@ -41,10 +67,28 @@ int vmw_mmap(struct file *filp, struct 
vm_area_struct *vma)

  };
  struct drm_file *file_priv = filp->private_data;
  struct vmw_private *dev_priv = vmw_priv(file_priv->minor->dev);
-    int ret = ttm_bo_mmap(filp, vma, &dev_priv->bdev);
+    struct ttm_device *bdev = &dev_priv->bdev;
+    struct ttm_buffer_object *bo;
+    int ret;
+
+    if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET_START))
+    return -EINVAL;
+
+    bo = vmw_bo_vm_lookup(bdev, vma->vm_pgoff, vma_pages(vma));
+    if (unlikely(!bo))
+    return -EINVAL;
  -    if (ret)
-    return ret;
+    if (unlikely(!bo->bdev->funcs->verify_access)) {
+    ret = -EPERM;
+    goto out_unref;
+    }
+    ret = bo->bdev->funcs->verify_access(bo, filp);


Is there any reason we can't call vmw_verify_access() directly here?

Would allow us to completely nuke the verify_access callback as well 
as far as I can see.


Forget what I said, couldn't see the next patch in my mailbox at time of 
writing.


Whole series is Reviewed-by: Christian König 

Thanks for the nice cleanup,
Christian.



Regards,
Christian.


+    if (unlikely(ret != 0))
+    goto out_unref;
+
+    ret = ttm_bo_mmap_obj(vma, bo);
+    if (unlikely(ret != 0))
+    goto out_unref;
    vma->vm_ops = &vmw_vm_ops;
  @@ -52,7 +96,13 @@ int vmw_mmap(struct file *filp, struct 
vm_area_struct *vma)

  if (!is_cow_mapping(vma->vm_flags))
  vma->vm_flags = (vma->vm_flags & ~VM_MIXEDMAP) | VM_PFNMAP;
  +    ttm_bo_put(bo); /* release extra ref taken by 
ttm_bo_mmap_obj() */

+
  return 0;
+
+out_unref:
+    ttm_bo_put(bo);
+    return ret;
  }
    /* struct vmw_validation_mem callback */




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


Re: [PATCH 1/2] drm/scheduler: Change scheduled fence track

2021-04-16 Thread Nirmoy


On 4/16/21 1:26 PM, Christian König wrote:

Am 16.04.21 um 07:04 schrieb Roy Sun:

Update the timestamp of scheduled fence on HW
completion of the previous fences

This allow more accurate tracking of the fence
execution in HW

Signed-off-by: David M Nieto 
Signed-off-by: Roy Sun 


Reviewed-by: Christian König  for the series.

Nirmoy if you are idle again could you give that a testing round? I 
don't expect it to cause trouble, just want to double check that we 
haven't forgotten taking a lock or stuff like that.




Looks good, Tested-by: Nirmoy Das . One minor typo 
below:




Thanks,
Christian.


---
  drivers/gpu/drm/scheduler/sched_main.c | 11 +--
  1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
b/drivers/gpu/drm/scheduler/sched_main.c

index 92d8de24d0a1..4e5d8d4af010 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -515,7 +515,7 @@ void drm_sched_resubmit_jobs(struct 
drm_gpu_scheduler *sched)

  EXPORT_SYMBOL(drm_sched_resubmit_jobs);
    /**
- * drm_sched_resubmit_jobs_ext - helper to relunch certain number of 
jobs from mirror ring list
+ * drm_sched_resubmit_jobs_ext - helper to relunch certain number of 
jobs from pending list



relunch -> relaunch


Regards,

Nirmoy



   *
   * @sched: scheduler instance
   * @max: job numbers to relaunch
@@ -671,7 +671,7 @@ drm_sched_select_entity(struct drm_gpu_scheduler 
*sched)

  static struct drm_sched_job *
  drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
  {
-    struct drm_sched_job *job;
+    struct drm_sched_job *job, *next;
    /*
   * Don't destroy jobs while the timeout worker is running OR 
thread
@@ -690,6 +690,13 @@ drm_sched_get_cleanup_job(struct 
drm_gpu_scheduler *sched)

  if (job && dma_fence_is_signaled(&job->s_fence->finished)) {
  /* remove job from pending_list */
  list_del_init(&job->list);
+    /* account for the next fence in the queue */
+    next = list_first_entry_or_null(&sched->pending_list,
+    struct drm_sched_job, list);
+    if (next) {
+    next->s_fence->scheduled.timestamp =
+    job->s_fence->finished.timestamp;
+    }
  } else {
  job = NULL;
  /* queue timeout for next job */



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


Re: [PATCH v3 5/7] drm/vmwgfx: Inline ttm_bo_mmap() into vmwgfx driver

2021-04-16 Thread Christian König

Am 16.04.21 um 15:31 schrieb Thomas Zimmermann:

The vmwgfx driver is the only remaining user of ttm_bo_mmap(). Inline
the code. The internal helper ttm_bo_vm_lookup() is now also part of
vmwgfx as vmw_bo_vm_lookup().

v2:
* replace pr_err() with drm_err() (Zack)

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Zack Rusin 
---
  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c | 56 ++--
  1 file changed, 53 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
index cb9975889e2f..c8b6543b4e39 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
@@ -27,6 +27,32 @@
  
  #include "vmwgfx_drv.h"
  
+static struct ttm_buffer_object *vmw_bo_vm_lookup(struct ttm_device *bdev,

+ unsigned long offset,
+ unsigned long pages)
+{
+   struct vmw_private *dev_priv = container_of(bdev, struct vmw_private, 
bdev);
+   struct drm_device *drm = &dev_priv->drm;
+   struct drm_vma_offset_node *node;
+   struct ttm_buffer_object *bo = NULL;
+
+   drm_vma_offset_lock_lookup(bdev->vma_manager);
+
+   node = drm_vma_offset_lookup_locked(bdev->vma_manager, offset, pages);
+   if (likely(node)) {
+   bo = container_of(node, struct ttm_buffer_object,
+ base.vma_node);
+   bo = ttm_bo_get_unless_zero(bo);
+   }
+
+   drm_vma_offset_unlock_lookup(bdev->vma_manager);
+
+   if (!bo)
+   drm_err(drm, "Could not find buffer object to map\n");
+
+   return bo;
+}
+
  int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
  {
static const struct vm_operations_struct vmw_vm_ops = {
@@ -41,10 +67,28 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
};
struct drm_file *file_priv = filp->private_data;
struct vmw_private *dev_priv = vmw_priv(file_priv->minor->dev);
-   int ret = ttm_bo_mmap(filp, vma, &dev_priv->bdev);
+   struct ttm_device *bdev = &dev_priv->bdev;
+   struct ttm_buffer_object *bo;
+   int ret;
+
+   if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET_START))
+   return -EINVAL;
+
+   bo = vmw_bo_vm_lookup(bdev, vma->vm_pgoff, vma_pages(vma));
+   if (unlikely(!bo))
+   return -EINVAL;
  
-	if (ret)

-   return ret;
+   if (unlikely(!bo->bdev->funcs->verify_access)) {
+   ret = -EPERM;
+   goto out_unref;
+   }
+   ret = bo->bdev->funcs->verify_access(bo, filp);


Is there any reason we can't call vmw_verify_access() directly here?

Would allow us to completely nuke the verify_access callback as well as 
far as I can see.


Regards,
Christian.


+   if (unlikely(ret != 0))
+   goto out_unref;
+
+   ret = ttm_bo_mmap_obj(vma, bo);
+   if (unlikely(ret != 0))
+   goto out_unref;
  
  	vma->vm_ops = &vmw_vm_ops;
  
@@ -52,7 +96,13 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma)

if (!is_cow_mapping(vma->vm_flags))
vma->vm_flags = (vma->vm_flags & ~VM_MIXEDMAP) | VM_PFNMAP;
  
+	ttm_bo_put(bo); /* release extra ref taken by ttm_bo_mmap_obj() */

+
return 0;
+
+out_unref:
+   ttm_bo_put(bo);
+   return ret;
  }
  
  /* struct vmw_validation_mem callback */


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


Re: [PATCH v3 0/7] drm: Clean up mmap for TTM-based GEM drivers

2021-04-16 Thread Christian König

Patches #1-#4 are Reviewed-by: Christian König 

One more comment on the vmw patches.

Regards,
Christian.

Am 16.04.21 um 15:31 schrieb Thomas Zimmermann:

Implement mmap via struct drm_gem_object_functions.mmap in amdgpu,
radeon and nouveau. This allows for using common DRM helpers for
the mmap-related callbacks in struct file_operations and struct
drm_driver. The drivers have their own vm_ops, which are now set
automatically by the DRM core functions. The code in each driver's
verify_access becomes part of the driver's new mmap implementation.

With the GEM drivers converted, vmwgfx is the only user of
ttm_bo_mmap() and related infrastructure. So move everything into
vmwgfx and delete the rsp code from TTM.

This touches several drivers. Preferably everything would be merged
at once via drm-misc-next.

v3:
* tidy up the new mmap functions in amdgpu and radeon (Christian)
v2:
* removal of amdgpu fbdev mmap already merged (Christian)
* rebase on top of amdgpu fixes [1] (Felix)
* replace pr_err() with drm_err() in vmwgfx patch (Zack)
* several typos

[1] https://patchwork.freedesktop.org/series/88822/

Thomas Zimmermann (7):
   drm/ttm: Don't override vm_ops callbacks, if set
   drm/amdgpu: Implement mmap as GEM object function
   drm/radeon: Implement mmap as GEM object function
   drm/nouveau: Implement mmap as GEM object function
   drm/vmwgfx: Inline ttm_bo_mmap() into vmwgfx driver
   drm/vmwgfx: Inline vmw_verify_access()
   drm/ttm: Remove ttm_bo_mmap() and friends

  drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 46 ---
  drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.h |  2 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  4 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 44 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 64 
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h |  1 -
  drivers/gpu/drm/nouveau/nouveau_bo.c| 10 
  drivers/gpu/drm/nouveau/nouveau_drm.c   |  3 +-
  drivers/gpu/drm/nouveau/nouveau_gem.c   | 36 
  drivers/gpu/drm/nouveau/nouveau_ttm.c   | 49 
  drivers/gpu/drm/nouveau/nouveau_ttm.h   |  1 -
  drivers/gpu/drm/radeon/radeon_drv.c |  3 +-
  drivers/gpu/drm/radeon/radeon_gem.c | 49 
  drivers/gpu/drm/radeon/radeon_ttm.c | 65 -
  drivers/gpu/drm/radeon/radeon_ttm.h |  1 -
  drivers/gpu/drm/ttm/ttm_bo_vm.c | 60 ++-
  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c  |  9 ---
  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c| 53 -
  include/drm/ttm/ttm_bo_api.h| 13 -
  include/drm/ttm/ttm_device.h| 15 -
  20 files changed, 191 insertions(+), 337 deletions(-)

--
2.31.1

___
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


[PATCH v3 3/7] drm/radeon: Implement mmap as GEM object function

2021-04-16 Thread Thomas Zimmermann
Moving the driver-specific mmap code into a GEM object function allows
for using DRM helpers for various mmap callbacks.

This change also allows to support prime-based mmap via DRM's helper
drm_gem_prime_mmap().

Permission checks are implemented by drm_gem_mmap(), with an additional
check for radeon_ttm_tt_has_userptr() in the GEM object function. The
function radeon_verify_access() is now unused and has thus been removed.

As a side effect, radeon_ttm_vm_ops and radeon_ttm_fault() are now
implemented in amdgpu's GEM code.

v3:
* remove unnecessary checks from mmap (Christian)
v2:
* rename radeon_ttm_vm_ops and radeon_ttm_fault() to
  radeon_gem_vm_ops and radeon_gem_fault() (Christian)
* fix commit description (Alex)

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/radeon/radeon_drv.c |  3 +-
 drivers/gpu/drm/radeon/radeon_gem.c | 49 ++
 drivers/gpu/drm/radeon/radeon_ttm.c | 65 -
 drivers/gpu/drm/radeon/radeon_ttm.h |  1 -
 4 files changed, 51 insertions(+), 67 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index 8885e849717d..61793ffdfa1b 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -558,7 +558,7 @@ static const struct file_operations radeon_driver_kms_fops 
= {
.open = drm_open,
.release = drm_release,
.unlocked_ioctl = radeon_drm_ioctl,
-   .mmap = radeon_mmap,
+   .mmap = drm_gem_mmap,
.poll = drm_poll,
.read = drm_read,
 #ifdef CONFIG_COMPAT
@@ -633,6 +633,7 @@ static const struct drm_driver kms_driver = {
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import_sg_table = radeon_gem_prime_import_sg_table,
+   .gem_prime_mmap = drm_gem_prime_mmap,
 
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c 
b/drivers/gpu/drm/radeon/radeon_gem.c
index 05ea2f39f626..ff8849827d61 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -44,6 +44,42 @@ void radeon_gem_prime_unpin(struct drm_gem_object *obj);
 
 const struct drm_gem_object_funcs radeon_gem_object_funcs;
 
+static vm_fault_t radeon_gem_fault(struct vm_fault *vmf)
+{
+   struct ttm_buffer_object *bo = vmf->vma->vm_private_data;
+   struct radeon_device *rdev = radeon_get_rdev(bo->bdev);
+   vm_fault_t ret;
+
+   down_read(&rdev->pm.mclk_lock);
+
+   ret = ttm_bo_vm_reserve(bo, vmf);
+   if (ret)
+   goto unlock_mclk;
+
+   ret = radeon_bo_fault_reserve_notify(bo);
+   if (ret)
+   goto unlock_resv;
+
+   ret = ttm_bo_vm_fault_reserved(vmf, vmf->vma->vm_page_prot,
+  TTM_BO_VM_NUM_PREFAULT, 1);
+   if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT))
+   goto unlock_mclk;
+
+unlock_resv:
+   dma_resv_unlock(bo->base.resv);
+
+unlock_mclk:
+   up_read(&rdev->pm.mclk_lock);
+   return ret;
+}
+
+static const struct vm_operations_struct radeon_gem_vm_ops = {
+   .fault = radeon_gem_fault,
+   .open = ttm_bo_vm_open,
+   .close = ttm_bo_vm_close,
+   .access = ttm_bo_vm_access
+};
+
 static void radeon_gem_object_free(struct drm_gem_object *gobj)
 {
struct radeon_bo *robj = gem_to_radeon_bo(gobj);
@@ -226,6 +262,17 @@ static int radeon_gem_handle_lockup(struct radeon_device 
*rdev, int r)
return r;
 }
 
+static int radeon_gem_object_mmap(struct drm_gem_object *obj, struct 
vm_area_struct *vma)
+{
+   struct radeon_bo *bo = gem_to_radeon_bo(obj);
+   struct radeon_device *rdev = radeon_get_rdev(bo->tbo.bdev);
+
+   if (radeon_ttm_tt_has_userptr(rdev, bo->tbo.ttm))
+   return -EPERM;
+
+   return drm_gem_ttm_mmap(obj, vma);
+}
+
 const struct drm_gem_object_funcs radeon_gem_object_funcs = {
.free = radeon_gem_object_free,
.open = radeon_gem_object_open,
@@ -236,6 +283,8 @@ const struct drm_gem_object_funcs radeon_gem_object_funcs = 
{
.get_sg_table = radeon_gem_prime_get_sg_table,
.vmap = drm_gem_ttm_vmap,
.vunmap = drm_gem_ttm_vunmap,
+   .mmap = radeon_gem_object_mmap,
+   .vm_ops = &radeon_gem_vm_ops,
 };
 
 /*
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
b/drivers/gpu/drm/radeon/radeon_ttm.c
index 380b3007fd0b..8b6efcc4191c 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -136,17 +136,6 @@ static void radeon_evict_flags(struct ttm_buffer_object 
*bo,
*placement = rbo->placement;
 }
 
-static int radeon_verify_access(struct ttm_buffer_object *bo, struct file 
*filp)
-{
-   struct radeon_bo *rbo = container_of(bo, struct radeon_bo, tbo);
-   struct radeon_device *rdev = radeon_get_rdev(bo->bdev);
-
-   if (radeon_ttm_tt_has_

[PATCH v3 7/7] drm/ttm: Remove ttm_bo_mmap() and friends

2021-04-16 Thread Thomas Zimmermann
The function ttm_bo_mmap is unused. Remove it and it's helpers; including
the verify_access callback in struct ttm_device_funcs.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Christian König 
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 53 -
 include/drm/ttm/ttm_bo_api.h| 13 
 include/drm/ttm/ttm_device.h| 15 --
 3 files changed, 81 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index bf4a213bc66c..6cd352399941 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -508,30 +508,6 @@ static const struct vm_operations_struct ttm_bo_vm_ops = {
.access = ttm_bo_vm_access,
 };
 
-static struct ttm_buffer_object *ttm_bo_vm_lookup(struct ttm_device *bdev,
- unsigned long offset,
- unsigned long pages)
-{
-   struct drm_vma_offset_node *node;
-   struct ttm_buffer_object *bo = NULL;
-
-   drm_vma_offset_lock_lookup(bdev->vma_manager);
-
-   node = drm_vma_offset_lookup_locked(bdev->vma_manager, offset, pages);
-   if (likely(node)) {
-   bo = container_of(node, struct ttm_buffer_object,
- base.vma_node);
-   bo = ttm_bo_get_unless_zero(bo);
-   }
-
-   drm_vma_offset_unlock_lookup(bdev->vma_manager);
-
-   if (!bo)
-   pr_err("Could not find buffer object to map\n");
-
-   return bo;
-}
-
 static void ttm_bo_mmap_vma_setup(struct ttm_buffer_object *bo, struct 
vm_area_struct *vma)
 {
/*
@@ -559,35 +535,6 @@ static void ttm_bo_mmap_vma_setup(struct ttm_buffer_object 
*bo, struct vm_area_s
vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
 }
 
-int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
-   struct ttm_device *bdev)
-{
-   struct ttm_buffer_object *bo;
-   int ret;
-
-   if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET_START))
-   return -EINVAL;
-
-   bo = ttm_bo_vm_lookup(bdev, vma->vm_pgoff, vma_pages(vma));
-   if (unlikely(!bo))
-   return -EINVAL;
-
-   if (unlikely(!bo->bdev->funcs->verify_access)) {
-   ret = -EPERM;
-   goto out_unref;
-   }
-   ret = bo->bdev->funcs->verify_access(bo, filp);
-   if (unlikely(ret != 0))
-   goto out_unref;
-
-   ttm_bo_mmap_vma_setup(bo, vma);
-   return 0;
-out_unref:
-   ttm_bo_put(bo);
-   return ret;
-}
-EXPORT_SYMBOL(ttm_bo_mmap);
-
 int ttm_bo_mmap_obj(struct vm_area_struct *vma, struct ttm_buffer_object *bo)
 {
ttm_bo_get(bo);
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 2155e2e38aec..6e35680ac01b 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -522,19 +522,6 @@ void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct 
dma_buf_map *map);
  */
 int ttm_bo_mmap_obj(struct vm_area_struct *vma, struct ttm_buffer_object *bo);
 
-/**
- * ttm_bo_mmap - mmap out of the ttm device address space.
- *
- * @filp:  filp as input from the mmap method.
- * @vma:   vma as input from the mmap method.
- * @bdev:  Pointer to the ttm_device with the address space manager.
- *
- * This function is intended to be called by the device mmap method.
- * if the device address space is to be backed by the bo manager.
- */
-int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
-   struct ttm_device *bdev);
-
 /**
  * ttm_bo_io
  *
diff --git a/include/drm/ttm/ttm_device.h b/include/drm/ttm/ttm_device.h
index 7c8f87bd52d3..cd592f8e941b 100644
--- a/include/drm/ttm/ttm_device.h
+++ b/include/drm/ttm/ttm_device.h
@@ -161,21 +161,6 @@ struct ttm_device_funcs {
struct ttm_resource *new_mem,
struct ttm_place *hop);
 
-   /**
-* struct ttm_bo_driver_member verify_access
-*
-* @bo: Pointer to a buffer object.
-* @filp: Pointer to a struct file trying to access the object.
-*
-* Called from the map / write / read methods to verify that the
-* caller is permitted to access the buffer object.
-* This member may be set to NULL, which will refuse this kind of
-* access for all buffer objects.
-* This function should return 0 if access is granted, -EPERM otherwise.
-*/
-   int (*verify_access)(struct ttm_buffer_object *bo,
-struct file *filp);
-
/**
 * Hook to notify driver about a resource delete.
 */
-- 
2.31.1

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


[PATCH v3 6/7] drm/vmwgfx: Inline vmw_verify_access()

2021-04-16 Thread Thomas Zimmermann
Vmwgfx is the only user of the TTM's verify_access callback. Inline
the call and avoid the indirection through the function pointer.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Zack Rusin 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 9 -
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c   | 7 ++-
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
index 2dc031fe4a90..a079734f9d68 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
@@ -658,14 +658,6 @@ static void vmw_evict_flags(struct ttm_buffer_object *bo,
*placement = vmw_sys_placement;
 }
 
-static int vmw_verify_access(struct ttm_buffer_object *bo, struct file *filp)
-{
-   struct ttm_object_file *tfile =
-   vmw_fpriv((struct drm_file *)filp->private_data)->tfile;
-
-   return vmw_user_bo_verify_access(bo, tfile);
-}
-
 static int vmw_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource 
*mem)
 {
struct vmw_private *dev_priv = container_of(bdev, struct vmw_private, 
bdev);
@@ -768,7 +760,6 @@ struct ttm_device_funcs vmw_bo_driver = {
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = vmw_evict_flags,
.move = vmw_move,
-   .verify_access = vmw_verify_access,
.swap_notify = vmw_swap_notify,
.io_mem_reserve = &vmw_ttm_io_mem_reserve,
 };
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
index c8b6543b4e39..e6b1f98ec99f 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
@@ -67,6 +67,7 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
};
struct drm_file *file_priv = filp->private_data;
struct vmw_private *dev_priv = vmw_priv(file_priv->minor->dev);
+   struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
struct ttm_device *bdev = &dev_priv->bdev;
struct ttm_buffer_object *bo;
int ret;
@@ -78,11 +79,7 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
if (unlikely(!bo))
return -EINVAL;
 
-   if (unlikely(!bo->bdev->funcs->verify_access)) {
-   ret = -EPERM;
-   goto out_unref;
-   }
-   ret = bo->bdev->funcs->verify_access(bo, filp);
+   ret = vmw_user_bo_verify_access(bo, tfile);
if (unlikely(ret != 0))
goto out_unref;
 
-- 
2.31.1

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


[PATCH v3 5/7] drm/vmwgfx: Inline ttm_bo_mmap() into vmwgfx driver

2021-04-16 Thread Thomas Zimmermann
The vmwgfx driver is the only remaining user of ttm_bo_mmap(). Inline
the code. The internal helper ttm_bo_vm_lookup() is now also part of
vmwgfx as vmw_bo_vm_lookup().

v2:
* replace pr_err() with drm_err() (Zack)

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Zack Rusin 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c | 56 ++--
 1 file changed, 53 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
index cb9975889e2f..c8b6543b4e39 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
@@ -27,6 +27,32 @@
 
 #include "vmwgfx_drv.h"
 
+static struct ttm_buffer_object *vmw_bo_vm_lookup(struct ttm_device *bdev,
+ unsigned long offset,
+ unsigned long pages)
+{
+   struct vmw_private *dev_priv = container_of(bdev, struct vmw_private, 
bdev);
+   struct drm_device *drm = &dev_priv->drm;
+   struct drm_vma_offset_node *node;
+   struct ttm_buffer_object *bo = NULL;
+
+   drm_vma_offset_lock_lookup(bdev->vma_manager);
+
+   node = drm_vma_offset_lookup_locked(bdev->vma_manager, offset, pages);
+   if (likely(node)) {
+   bo = container_of(node, struct ttm_buffer_object,
+ base.vma_node);
+   bo = ttm_bo_get_unless_zero(bo);
+   }
+
+   drm_vma_offset_unlock_lookup(bdev->vma_manager);
+
+   if (!bo)
+   drm_err(drm, "Could not find buffer object to map\n");
+
+   return bo;
+}
+
 int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
 {
static const struct vm_operations_struct vmw_vm_ops = {
@@ -41,10 +67,28 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
};
struct drm_file *file_priv = filp->private_data;
struct vmw_private *dev_priv = vmw_priv(file_priv->minor->dev);
-   int ret = ttm_bo_mmap(filp, vma, &dev_priv->bdev);
+   struct ttm_device *bdev = &dev_priv->bdev;
+   struct ttm_buffer_object *bo;
+   int ret;
+
+   if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET_START))
+   return -EINVAL;
+
+   bo = vmw_bo_vm_lookup(bdev, vma->vm_pgoff, vma_pages(vma));
+   if (unlikely(!bo))
+   return -EINVAL;
 
-   if (ret)
-   return ret;
+   if (unlikely(!bo->bdev->funcs->verify_access)) {
+   ret = -EPERM;
+   goto out_unref;
+   }
+   ret = bo->bdev->funcs->verify_access(bo, filp);
+   if (unlikely(ret != 0))
+   goto out_unref;
+
+   ret = ttm_bo_mmap_obj(vma, bo);
+   if (unlikely(ret != 0))
+   goto out_unref;
 
vma->vm_ops = &vmw_vm_ops;
 
@@ -52,7 +96,13 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
if (!is_cow_mapping(vma->vm_flags))
vma->vm_flags = (vma->vm_flags & ~VM_MIXEDMAP) | VM_PFNMAP;
 
+   ttm_bo_put(bo); /* release extra ref taken by ttm_bo_mmap_obj() */
+
return 0;
+
+out_unref:
+   ttm_bo_put(bo);
+   return ret;
 }
 
 /* struct vmw_validation_mem callback */
-- 
2.31.1

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


[PATCH v3 4/7] drm/nouveau: Implement mmap as GEM object function

2021-04-16 Thread Thomas Zimmermann
Moving the driver-specific mmap code into a GEM object function allows
for using DRM helpers for various mmap callbacks.

The GEM object function is provided by GEM TTM helpers. Nouveau's
implementation of verify_access is unused and has been removed. Access
permissions are validated by the DRM helpers.

As a side effect, nouveau_ttm_vm_ops and nouveau_ttm_fault() are now
implemented in nouveau's GEM code.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c  | 10 --
 drivers/gpu/drm/nouveau/nouveau_drm.c |  3 +-
 drivers/gpu/drm/nouveau/nouveau_gem.c | 36 
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 49 ---
 drivers/gpu/drm/nouveau/nouveau_ttm.h |  1 -
 5 files changed, 38 insertions(+), 61 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 3e09df0472ce..bc67cbccc83b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1051,15 +1051,6 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
return ret;
 }
 
-static int
-nouveau_bo_verify_access(struct ttm_buffer_object *bo, struct file *filp)
-{
-   struct nouveau_bo *nvbo = nouveau_bo(bo);
-
-   return drm_vma_node_verify_access(&nvbo->bo.base.vma_node,
- filp->private_data);
-}
-
 static void
 nouveau_ttm_io_mem_free_locked(struct nouveau_drm *drm,
   struct ttm_resource *reg)
@@ -1332,7 +1323,6 @@ struct ttm_device_funcs nouveau_bo_driver = {
.evict_flags = nouveau_bo_evict_flags,
.delete_mem_notify = nouveau_bo_delete_mem_notify,
.move = nouveau_bo_move,
-   .verify_access = nouveau_bo_verify_access,
.io_mem_reserve = &nouveau_ttm_io_mem_reserve,
.io_mem_free = &nouveau_ttm_io_mem_free,
 };
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 3204fc0a90d2..a616cf4573b8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1179,7 +1179,7 @@ nouveau_driver_fops = {
.open = drm_open,
.release = drm_release,
.unlocked_ioctl = nouveau_drm_ioctl,
-   .mmap = nouveau_ttm_mmap,
+   .mmap = drm_gem_mmap,
.poll = drm_poll,
.read = drm_read,
 #if defined(CONFIG_COMPAT)
@@ -1212,6 +1212,7 @@ driver_stub = {
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import_sg_table = nouveau_gem_prime_import_sg_table,
+   .gem_prime_mmap = drm_gem_prime_mmap,
 
.dumb_create = nouveau_display_dumb_create,
.dumb_map_offset = drm_gem_ttm_dumb_map_offset,
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c 
b/drivers/gpu/drm/nouveau/nouveau_gem.c
index c88cbb85f101..71dfac820c4d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -39,6 +39,40 @@
 #include 
 #include 
 
+static vm_fault_t nouveau_ttm_fault(struct vm_fault *vmf)
+{
+   struct vm_area_struct *vma = vmf->vma;
+   struct ttm_buffer_object *bo = vma->vm_private_data;
+   pgprot_t prot;
+   vm_fault_t ret;
+
+   ret = ttm_bo_vm_reserve(bo, vmf);
+   if (ret)
+   return ret;
+
+   ret = nouveau_ttm_fault_reserve_notify(bo);
+   if (ret)
+   goto error_unlock;
+
+   nouveau_bo_del_io_reserve_lru(bo);
+   prot = vm_get_page_prot(vma->vm_flags);
+   ret = ttm_bo_vm_fault_reserved(vmf, prot, TTM_BO_VM_NUM_PREFAULT, 1);
+   nouveau_bo_add_io_reserve_lru(bo);
+   if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT))
+   return ret;
+
+error_unlock:
+   dma_resv_unlock(bo->base.resv);
+   return ret;
+}
+
+static const struct vm_operations_struct nouveau_ttm_vm_ops = {
+   .fault = nouveau_ttm_fault,
+   .open = ttm_bo_vm_open,
+   .close = ttm_bo_vm_close,
+   .access = ttm_bo_vm_access
+};
+
 void
 nouveau_gem_object_del(struct drm_gem_object *gem)
 {
@@ -180,6 +214,8 @@ const struct drm_gem_object_funcs nouveau_gem_object_funcs 
= {
.get_sg_table = nouveau_gem_prime_get_sg_table,
.vmap = drm_gem_ttm_vmap,
.vunmap = drm_gem_ttm_vunmap,
+   .mmap = drm_gem_ttm_mmap,
+   .vm_ops = &nouveau_ttm_vm_ops,
 };
 
 int
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c 
b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index b81ae90b8449..e511a26379da 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -127,55 +127,6 @@ const struct ttm_resource_manager_func nv04_gart_manager = 
{
.free = nouveau_manager_del,
 };
 
-static vm_fault_t nouveau_ttm_fault(struct vm_fault *vmf)
-{
-   struct vm_area_struct *vma = vmf->vma;
-   struct ttm_buffer_object *bo = vma->vm_private_data;
-   pgprot_t prot;
-   vm_fault_t ret;
-
-   ret = ttm_bo_v

[PATCH v3 0/7] drm: Clean up mmap for TTM-based GEM drivers

2021-04-16 Thread Thomas Zimmermann
Implement mmap via struct drm_gem_object_functions.mmap in amdgpu,
radeon and nouveau. This allows for using common DRM helpers for
the mmap-related callbacks in struct file_operations and struct
drm_driver. The drivers have their own vm_ops, which are now set
automatically by the DRM core functions. The code in each driver's
verify_access becomes part of the driver's new mmap implementation.

With the GEM drivers converted, vmwgfx is the only user of
ttm_bo_mmap() and related infrastructure. So move everything into
vmwgfx and delete the rsp code from TTM.

This touches several drivers. Preferably everything would be merged
at once via drm-misc-next.

v3:
* tidy up the new mmap functions in amdgpu and radeon (Christian)
v2:
* removal of amdgpu fbdev mmap already merged (Christian)
* rebase on top of amdgpu fixes [1] (Felix)
* replace pr_err() with drm_err() in vmwgfx patch (Zack)
* several typos

[1] https://patchwork.freedesktop.org/series/88822/

Thomas Zimmermann (7):
  drm/ttm: Don't override vm_ops callbacks, if set
  drm/amdgpu: Implement mmap as GEM object function
  drm/radeon: Implement mmap as GEM object function
  drm/nouveau: Implement mmap as GEM object function
  drm/vmwgfx: Inline ttm_bo_mmap() into vmwgfx driver
  drm/vmwgfx: Inline vmw_verify_access()
  drm/ttm: Remove ttm_bo_mmap() and friends

 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 46 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.h |  2 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 44 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 64 
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h |  1 -
 drivers/gpu/drm/nouveau/nouveau_bo.c| 10 
 drivers/gpu/drm/nouveau/nouveau_drm.c   |  3 +-
 drivers/gpu/drm/nouveau/nouveau_gem.c   | 36 
 drivers/gpu/drm/nouveau/nouveau_ttm.c   | 49 
 drivers/gpu/drm/nouveau/nouveau_ttm.h   |  1 -
 drivers/gpu/drm/radeon/radeon_drv.c |  3 +-
 drivers/gpu/drm/radeon/radeon_gem.c | 49 
 drivers/gpu/drm/radeon/radeon_ttm.c | 65 -
 drivers/gpu/drm/radeon/radeon_ttm.h |  1 -
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 60 ++-
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c  |  9 ---
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c| 53 -
 include/drm/ttm/ttm_bo_api.h| 13 -
 include/drm/ttm/ttm_device.h| 15 -
 20 files changed, 191 insertions(+), 337 deletions(-)

--
2.31.1

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


[PATCH v3 1/7] drm/ttm: Don't override vm_ops callbacks, if set

2021-04-16 Thread Thomas Zimmermann
Drivers may want to set their own callbacks for a VM area. Only set
TTM's callbacks if the vm_ops field is clear.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index b31b18058965..bf4a213bc66c 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -534,7 +534,12 @@ static struct ttm_buffer_object *ttm_bo_vm_lookup(struct 
ttm_device *bdev,
 
 static void ttm_bo_mmap_vma_setup(struct ttm_buffer_object *bo, struct 
vm_area_struct *vma)
 {
-   vma->vm_ops = &ttm_bo_vm_ops;
+   /*
+* Drivers may want to override the vm_ops field. Otherwise we
+* use TTM's default callbacks.
+*/
+   if (!vma->vm_ops)
+   vma->vm_ops = &ttm_bo_vm_ops;
 
/*
 * Note: We're transferring the bo reference to
-- 
2.31.1

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


[PATCH v3 2/7] drm/amdgpu: Implement mmap as GEM object function

2021-04-16 Thread Thomas Zimmermann
Moving the driver-specific mmap code into a GEM object function allows
for using DRM helpers for various mmap callbacks.

This change resolves several inconsistencies between regular mmap and
prime-based mmap. The vm_ops field in vma is now set for all mmap'ed
areas. Previously it way only set for regular mmap calls, prime-based
mmap used TTM's default vm_ops. The function amdgpu_verify_access() is
no longer being called and therefore removed by this patch.

As a side effect, amdgpu_ttm_vm_ops and amdgpu_ttm_fault() are now
implemented in amdgpu's GEM code.

v3:
* rename mmap function to amdgpu_gem_object_mmap() (Christian)
* remove unnecessary checks from mmap (Christian)
v2:
* rename amdgpu_ttm_vm_ops and amdgpu_ttm_fault() to
  amdgpu_gem_vm_ops and amdgpu_gem_fault() (Christian)
* the check for kfd_bo has meanwhile been removed

Signed-off-by: Thomas Zimmermann 

cleanup mmap rename gem_object_mmap
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 46 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.h |  2 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 44 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 64 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h |  1 -
 6 files changed, 46 insertions(+), 115 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
index e0c4f7c7f1b9..19c5ab08d9ec 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
@@ -42,52 +42,6 @@
 #include 
 #include 
 
-/**
- * amdgpu_gem_prime_mmap - &drm_driver.gem_prime_mmap implementation
- * @obj: GEM BO
- * @vma: Virtual memory area
- *
- * Sets up a userspace mapping of the BO's memory in the given
- * virtual memory area.
- *
- * Returns:
- * 0 on success or a negative error code on failure.
- */
-int amdgpu_gem_prime_mmap(struct drm_gem_object *obj,
- struct vm_area_struct *vma)
-{
-   struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
-   struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
-   unsigned asize = amdgpu_bo_size(bo);
-   int ret;
-
-   if (!vma->vm_file)
-   return -ENODEV;
-
-   if (adev == NULL)
-   return -ENODEV;
-
-   /* Check for valid size. */
-   if (asize < vma->vm_end - vma->vm_start)
-   return -EINVAL;
-
-   if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm) ||
-   (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)) {
-   return -EPERM;
-   }
-   vma->vm_pgoff += amdgpu_bo_mmap_offset(bo) >> PAGE_SHIFT;
-
-   /* prime mmap does not need to check access, so allow here */
-   ret = drm_vma_node_allow(&obj->vma_node, vma->vm_file->private_data);
-   if (ret)
-   return ret;
-
-   ret = ttm_bo_mmap(vma->vm_file, vma, &adev->mman.bdev);
-   drm_vma_node_revoke(&obj->vma_node, vma->vm_file->private_data);
-
-   return ret;
-}
-
 static int
 __dma_resv_make_exclusive(struct dma_resv *obj)
 {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.h
index 39b5b9616fd8..3e93b9b407a9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.h
@@ -31,8 +31,6 @@ struct drm_gem_object *amdgpu_gem_prime_import(struct 
drm_device *dev,
struct dma_buf *dma_buf);
 bool amdgpu_dmabuf_is_xgmi_accessible(struct amdgpu_device *adev,
  struct amdgpu_bo *bo);
-int amdgpu_gem_prime_mmap(struct drm_gem_object *obj,
- struct vm_area_struct *vma);
 
 extern const struct dma_buf_ops amdgpu_dmabuf_ops;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 80130c1c0c68..69d2485ec665 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1686,7 +1686,7 @@ static const struct file_operations 
amdgpu_driver_kms_fops = {
.flush = amdgpu_flush,
.release = drm_release,
.unlocked_ioctl = amdgpu_drm_ioctl,
-   .mmap = amdgpu_mmap,
+   .mmap = drm_gem_mmap,
.poll = drm_poll,
.read = drm_read,
 #ifdef CONFIG_COMPAT
@@ -1749,7 +1749,7 @@ static const struct drm_driver amdgpu_kms_driver = {
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import = amdgpu_gem_prime_import,
-   .gem_prime_mmap = amdgpu_gem_prime_mmap,
+   .gem_prime_mmap = drm_gem_prime_mmap,
 
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 311bcdc59eda..df78a06ef0c8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdg

Re: [PATCH 1/3] drm/amdgpu: make sure we unpin the UVD BO

2021-04-16 Thread Christian König

Ping?

Am 15.04.21 um 10:47 schrieb Christian König:

Releasing pinned BOs is illegal now.

Signed-off-by: Christian König 
---
  drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c 
b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
index 7cd67cb2ac5f..1a2bf2ca1be5 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
@@ -363,6 +363,7 @@ static int uvd_v7_0_enc_ring_test_ib(struct amdgpu_ring 
*ring, long timeout)
  
  error:

dma_fence_put(fence);
+   amdgpu_bo_unpin(bo);
amdgpu_bo_unreserve(bo);
amdgpu_bo_unref(&bo);
return r;


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


Re: [PATCH 1/2] drm/scheduler: Change scheduled fence track

2021-04-16 Thread Christian König

Am 16.04.21 um 07:04 schrieb Roy Sun:

Update the timestamp of scheduled fence on HW
completion of the previous fences

This allow more accurate tracking of the fence
execution in HW

Signed-off-by: David M Nieto 
Signed-off-by: Roy Sun 


Reviewed-by: Christian König  for the series.

Nirmoy if you are idle again could you give that a testing round? I 
don't expect it to cause trouble, just want to double check that we 
haven't forgotten taking a lock or stuff like that.


Thanks,
Christian.


---
  drivers/gpu/drm/scheduler/sched_main.c | 11 +--
  1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
b/drivers/gpu/drm/scheduler/sched_main.c
index 92d8de24d0a1..4e5d8d4af010 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -515,7 +515,7 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler 
*sched)
  EXPORT_SYMBOL(drm_sched_resubmit_jobs);
  
  /**

- * drm_sched_resubmit_jobs_ext - helper to relunch certain number of jobs from 
mirror ring list
+ * drm_sched_resubmit_jobs_ext - helper to relunch certain number of jobs from 
pending list
   *
   * @sched: scheduler instance
   * @max: job numbers to relaunch
@@ -671,7 +671,7 @@ drm_sched_select_entity(struct drm_gpu_scheduler *sched)
  static struct drm_sched_job *
  drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
  {
-   struct drm_sched_job *job;
+   struct drm_sched_job *job, *next;
  
  	/*

 * Don't destroy jobs while the timeout worker is running  OR thread
@@ -690,6 +690,13 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
if (job && dma_fence_is_signaled(&job->s_fence->finished)) {
/* remove job from pending_list */
list_del_init(&job->list);
+   /* account for the next fence in the queue */
+   next = list_first_entry_or_null(&sched->pending_list,
+   struct drm_sched_job, list);
+   if (next) {
+   next->s_fence->scheduled.timestamp =
+   job->s_fence->finished.timestamp;
+   }
} else {
job = NULL;
/* queue timeout for next job */


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


RE: [PATCH 2/2] drm/amdgpu: only harvest gcea/mmea error status in aldebaran

2021-04-16 Thread Yang, Stanley
[AMD Official Use Only - Internal Distribution Only]

Seriers is Reviewed-by: Stanley.Yang 

Regards,
Stanley
> -Original Message-
> From: Zhang, Hawking 
> Sent: Friday, April 16, 2021 5:44 PM
> To: amd-gfx@lists.freedesktop.org; Yang, Stanley ;
> John Clements ; Li, Dennis
> 
> Cc: Zhang, Hawking 
> Subject: [PATCH 2/2] drm/amdgpu: only harvest gcea/mmea error status in
> aldebaran
> 
> In aldebaran, driver only needs to harvest SDP RdRspStatus, WrRspStatus
> and first parity error on RdRsp data. Check error type before harvest error
> information.
> 
> Signed-off-by: Hawking Zhang 
> ---
>  drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c | 21 -
> drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c | 11 +++
>  2 files changed, 19 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c
> index 9ca76a3ac38c..91427543aabe 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c
> @@ -808,7 +808,7 @@ static struct gfx_v9_4_2_utc_block
> gfx_v9_4_2_utc_blocks[] = {
> REG_SET_FIELD(0, ATC_L2_CACHE_4K_DSM_CNTL,
> WRITE_COUNTERS, 1) },  };
> 
> -static const struct soc15_reg_entry gfx_v9_4_2_rdrsp_status_regs =
> +static const struct soc15_reg_entry gfx_v9_4_2_ea_err_status_regs =
>   { SOC15_REG_ENTRY(GC, 0, regGCEA_ERR_STATUS), 0, 1, 16 };
> 
>  static int gfx_v9_4_2_get_reg_error_count(struct amdgpu_device *adev,
> @@ -1040,11 +1040,11 @@ static void
> gfx_v9_4_2_reset_ea_err_status(struct amdgpu_device *adev)
>   uint32_t i, j;
> 
>   mutex_lock(&adev->grbm_idx_mutex);
> - for (i = 0; i < gfx_v9_4_2_rdrsp_status_regs.se_num; i++) {
> - for (j = 0; j < gfx_v9_4_2_rdrsp_status_regs.instance;
> + for (i = 0; i < gfx_v9_4_2_ea_err_status_regs.se_num; i++) {
> + for (j = 0; j < gfx_v9_4_2_ea_err_status_regs.instance;
>j++) {
>   gfx_v9_4_2_select_se_sh(adev, i, 0, j);
> -
>   WREG32(SOC15_REG_ENTRY_OFFSET(gfx_v9_4_2_rdrsp_status_reg
> s), 0x10);
> +
>   WREG32(SOC15_REG_ENTRY_OFFSET(gfx_v9_4_2_ea_err_status_re
> gs), 0x10);
>   }
>   }
>   gfx_v9_4_2_select_se_sh(adev, 0x, 0x, 0x); @@
> -1089,17 +1089,20 @@ static void gfx_v9_4_2_query_ea_err_status(struct
> amdgpu_device *adev)
> 
>   mutex_lock(&adev->grbm_idx_mutex);
> 
> - for (i = 0; i < gfx_v9_4_2_rdrsp_status_regs.se_num; i++) {
> - for (j = 0; j < gfx_v9_4_2_rdrsp_status_regs.instance;
> + for (i = 0; i < gfx_v9_4_2_ea_err_status_regs.se_num; i++) {
> + for (j = 0; j < gfx_v9_4_2_ea_err_status_regs.instance;
>j++) {
>   gfx_v9_4_2_select_se_sh(adev, i, 0, j);
>   reg_value = RREG32(SOC15_REG_ENTRY_OFFSET(
> - gfx_v9_4_2_rdrsp_status_regs));
> - if (reg_value)
> + gfx_v9_4_2_ea_err_status_regs));
> + if (REG_GET_FIELD(reg_value, GCEA_ERR_STATUS,
> SDP_RDRSP_STATUS) ||
> + REG_GET_FIELD(reg_value, GCEA_ERR_STATUS,
> SDP_WRRSP_STATUS) ||
> + REG_GET_FIELD(reg_value, GCEA_ERR_STATUS,
> +SDP_RDRSP_DATAPARITY_ERROR)) {
>   dev_warn(adev->dev, "GCEA err detected at
> instance: %d, status: 0x%x!\n",
>   j, reg_value);
> + }
>   /* clear after read */
> -
>   WREG32(SOC15_REG_ENTRY_OFFSET(gfx_v9_4_2_rdrsp_status_reg
> s), 0x10);
> +
>   WREG32(SOC15_REG_ENTRY_OFFSET(gfx_v9_4_2_ea_err_status_re
> gs), 0x10);
>   }
>   }
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c
> b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c
> index d0f41346ea0c..cc69c434d0de 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c
> @@ -1286,7 +1286,7 @@ static void
> mmhub_v1_7_reset_ras_error_count(struct amdgpu_device *adev)
>   }
>  }
> 
> -static const struct soc15_reg_entry mmhub_v1_7_err_status_regs[] = {
> +static const struct soc15_reg_entry mmhub_v1_7_ea_err_status_regs[] = {
>   { SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_ERR_STATUS), 0, 0, 0 },
>   { SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_ERR_STATUS), 0, 0, 0 },
>   { SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_ERR_STATUS), 0, 0, 0 },
> @@ -1303,12 +1303,15 @@ static void
> mmhub_v1_7_query_ras_error_status(struct amdgpu_device *adev)
>   if (!amdgpu_ras_is_supported(adev,
> AMDGPU_RAS_BLOCK__MMHUB))
>   return;
> 
> - for (i = 0; i < ARRAY_SIZE(mmhub_v1_7_err_status_regs); i++) {
> + for (i = 0; i < ARRAY_SIZE(mmhub_v1_7_ea_err_status_regs); i++) {
>   reg_value =
> -
>   RREG32(SOC15_REG_ENTRY_OFFSET(mmhub_v1_7_err_status_regs
> [i]));
> - if (reg_value)
> +
>   RREG32(SOC15_REG_

[PATCH 2/2] drm/amdgpu: only harvest gcea/mmea error status in aldebaran

2021-04-16 Thread Hawking Zhang
In aldebaran, driver only needs to harvest SDP
RdRspStatus, WrRspStatus and first parity error
on RdRsp data. Check error type before harvest
error information.

Signed-off-by: Hawking Zhang 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c | 21 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c | 11 +++
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c
index 9ca76a3ac38c..91427543aabe 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_2.c
@@ -808,7 +808,7 @@ static struct gfx_v9_4_2_utc_block gfx_v9_4_2_utc_blocks[] 
= {
  REG_SET_FIELD(0, ATC_L2_CACHE_4K_DSM_CNTL, WRITE_COUNTERS, 1) },
 };
 
-static const struct soc15_reg_entry gfx_v9_4_2_rdrsp_status_regs =
+static const struct soc15_reg_entry gfx_v9_4_2_ea_err_status_regs =
{ SOC15_REG_ENTRY(GC, 0, regGCEA_ERR_STATUS), 0, 1, 16 };
 
 static int gfx_v9_4_2_get_reg_error_count(struct amdgpu_device *adev,
@@ -1040,11 +1040,11 @@ static void gfx_v9_4_2_reset_ea_err_status(struct 
amdgpu_device *adev)
uint32_t i, j;
 
mutex_lock(&adev->grbm_idx_mutex);
-   for (i = 0; i < gfx_v9_4_2_rdrsp_status_regs.se_num; i++) {
-   for (j = 0; j < gfx_v9_4_2_rdrsp_status_regs.instance;
+   for (i = 0; i < gfx_v9_4_2_ea_err_status_regs.se_num; i++) {
+   for (j = 0; j < gfx_v9_4_2_ea_err_status_regs.instance;
 j++) {
gfx_v9_4_2_select_se_sh(adev, i, 0, j);
-   
WREG32(SOC15_REG_ENTRY_OFFSET(gfx_v9_4_2_rdrsp_status_regs), 0x10);
+   
WREG32(SOC15_REG_ENTRY_OFFSET(gfx_v9_4_2_ea_err_status_regs), 0x10);
}
}
gfx_v9_4_2_select_se_sh(adev, 0x, 0x, 0x);
@@ -1089,17 +1089,20 @@ static void gfx_v9_4_2_query_ea_err_status(struct 
amdgpu_device *adev)
 
mutex_lock(&adev->grbm_idx_mutex);
 
-   for (i = 0; i < gfx_v9_4_2_rdrsp_status_regs.se_num; i++) {
-   for (j = 0; j < gfx_v9_4_2_rdrsp_status_regs.instance;
+   for (i = 0; i < gfx_v9_4_2_ea_err_status_regs.se_num; i++) {
+   for (j = 0; j < gfx_v9_4_2_ea_err_status_regs.instance;
 j++) {
gfx_v9_4_2_select_se_sh(adev, i, 0, j);
reg_value = RREG32(SOC15_REG_ENTRY_OFFSET(
-   gfx_v9_4_2_rdrsp_status_regs));
-   if (reg_value)
+   gfx_v9_4_2_ea_err_status_regs));
+   if (REG_GET_FIELD(reg_value, GCEA_ERR_STATUS, 
SDP_RDRSP_STATUS) ||
+   REG_GET_FIELD(reg_value, GCEA_ERR_STATUS, 
SDP_WRRSP_STATUS) ||
+   REG_GET_FIELD(reg_value, GCEA_ERR_STATUS, 
SDP_RDRSP_DATAPARITY_ERROR)) {
dev_warn(adev->dev, "GCEA err detected at 
instance: %d, status: 0x%x!\n",
j, reg_value);
+   }
/* clear after read */
-   
WREG32(SOC15_REG_ENTRY_OFFSET(gfx_v9_4_2_rdrsp_status_regs), 0x10);
+   
WREG32(SOC15_REG_ENTRY_OFFSET(gfx_v9_4_2_ea_err_status_regs), 0x10);
}
}
 
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c 
b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c
index d0f41346ea0c..cc69c434d0de 100644
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c
@@ -1286,7 +1286,7 @@ static void mmhub_v1_7_reset_ras_error_count(struct 
amdgpu_device *adev)
}
 }
 
-static const struct soc15_reg_entry mmhub_v1_7_err_status_regs[] = {
+static const struct soc15_reg_entry mmhub_v1_7_ea_err_status_regs[] = {
{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_ERR_STATUS), 0, 0, 0 },
{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_ERR_STATUS), 0, 0, 0 },
{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_ERR_STATUS), 0, 0, 0 },
@@ -1303,12 +1303,15 @@ static void mmhub_v1_7_query_ras_error_status(struct 
amdgpu_device *adev)
if (!amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__MMHUB))
return;
 
-   for (i = 0; i < ARRAY_SIZE(mmhub_v1_7_err_status_regs); i++) {
+   for (i = 0; i < ARRAY_SIZE(mmhub_v1_7_ea_err_status_regs); i++) {
reg_value =
-   
RREG32(SOC15_REG_ENTRY_OFFSET(mmhub_v1_7_err_status_regs[i]));
-   if (reg_value)
+   
RREG32(SOC15_REG_ENTRY_OFFSET(mmhub_v1_7_ea_err_status_regs[i]));
+   if (REG_GET_FIELD(reg_value, MMEA0_ERR_STATUS, 
SDP_RDRSP_STATUS) ||
+   REG_GET_FIELD(reg_value, MMEA0_ERR_STATUS, 
SDP_WRRSP_STATUS) ||
+   REG_GET_FIELD(reg_value, MMEA0_ERR_STATUS, 
SDP_RDRSP_DATAPARITY_ERROR)) {
dev_warn(adev->dev, "MMHUB EA err detected at instance: 
%d, status: 0x%x!\n",

[PATCH 1/2] drm/amdgpu: only harvest gcea/mmea error status in arcturus

2021-04-16 Thread Hawking Zhang
SDP RdRspStatus/WrRspStatus or first parity error on
RdRsp data can cause system fatal error in arcturus.
GPU will be freezed in such case.

Driver needs to harvest these error information before
reset the GPU. Check error type to avoid harvest normal
gcea/mmea information.

Signed-off-by: Hawking Zhang 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4.c| 16 +++-
 drivers/gpu/drm/amd/amdgpu/mmhub_v9_4.c  |  8 +++-
 .../amd/include/asic_reg/gc/gc_9_4_1_sh_mask.h   | 16 
 3 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4.c
index 830080ff90d8..b4789dfc2bb9 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4.c
@@ -994,7 +994,7 @@ static int gfx_v9_4_ras_error_inject(struct amdgpu_device 
*adev,
return ret;
 }
 
-static const struct soc15_reg_entry gfx_v9_4_rdrsp_status_regs =
+static const struct soc15_reg_entry gfx_v9_4_ea_err_status_regs =
{ SOC15_REG_ENTRY(GC, 0, mmGCEA_ERR_STATUS), 0, 1, 32 };
 
 static void gfx_v9_4_query_ras_error_status(struct amdgpu_device *adev)
@@ -1007,15 +1007,21 @@ static void gfx_v9_4_query_ras_error_status(struct 
amdgpu_device *adev)
 
mutex_lock(&adev->grbm_idx_mutex);
 
-   for (i = 0; i < gfx_v9_4_rdrsp_status_regs.se_num; i++) {
-   for (j = 0; j < gfx_v9_4_rdrsp_status_regs.instance;
+   for (i = 0; i < gfx_v9_4_ea_err_status_regs.se_num; i++) {
+   for (j = 0; j < gfx_v9_4_ea_err_status_regs.instance;
 j++) {
gfx_v9_4_select_se_sh(adev, i, 0, j);
reg_value = RREG32(SOC15_REG_ENTRY_OFFSET(
-   gfx_v9_4_rdrsp_status_regs));
-   if (reg_value)
+   gfx_v9_4_ea_err_status_regs));
+   if (REG_GET_FIELD(reg_value, GCEA_ERR_STATUS, 
SDP_RDRSP_STATUS) ||
+   REG_GET_FIELD(reg_value, GCEA_ERR_STATUS, 
SDP_WRRSP_STATUS) ||
+   REG_GET_FIELD(reg_value, GCEA_ERR_STATUS, 
SDP_RDRSP_DATAPARITY_ERROR)) {
+   /* SDP read/write error/parity error in 
FUE_IS_FATAL mode
+* can cause system fatal error in arcturas. 
Harvest the error
+* status before GPU reset */
dev_warn(adev->dev, "GCEA err detected at 
instance: %d, status: 0x%x!\n",
j, reg_value);
+   }
}
}
 
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v9_4.c 
b/drivers/gpu/drm/amd/amdgpu/mmhub_v9_4.c
index 4e2c5f117cef..d28df47cea91 100644
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v9_4.c
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v9_4.c
@@ -1644,9 +1644,15 @@ static void mmhub_v9_4_query_ras_error_status(struct 
amdgpu_device *adev)
for (i = 0; i < ARRAY_SIZE(mmhub_v9_4_err_status_regs); i++) {
reg_value =

RREG32(SOC15_REG_ENTRY_OFFSET(mmhub_v9_4_err_status_regs[i]));
-   if (reg_value)
+   if (REG_GET_FIELD(reg_value, MMEA0_ERR_STATUS, 
SDP_RDRSP_STATUS) ||
+   REG_GET_FIELD(reg_value, MMEA0_ERR_STATUS, 
SDP_WRRSP_STATUS) ||
+   REG_GET_FIELD(reg_value, MMEA0_ERR_STATUS, 
SDP_RDRSP_DATAPARITY_ERROR)) {
+   /* SDP read/write error/parity error in FUE_IS_FATAL 
mode
+* can cause system fatal error in arcturas. Harvest 
the error
+* status before GPU reset */
dev_warn(adev->dev, "MMHUB EA err detected at instance: 
%d, status: 0x%x!\n",
i, reg_value);
+   }
}
 }
 
diff --git a/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_4_1_sh_mask.h 
b/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_4_1_sh_mask.h
index 4089cfa081f5..849450caca15 100644
--- a/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_4_1_sh_mask.h
+++ b/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_4_1_sh_mask.h
@@ -617,6 +617,22 @@
 #define GCEA_EDC_CNT3__MAM_A3MEM_SEC_COUNT_MASK
   0x3000L
 #define GCEA_EDC_CNT3__MAM_A3MEM_DED_COUNT_MASK
   0xC000L
 
+//GCEA_ERR_STATUS
+#define GCEA_ERR_STATUS__SDP_RDRSP_STATUS__SHIFT   
   0x0
+#define GCEA_ERR_STATUS__SDP_WRRSP_STATUS__SHIFT   
   0x4
+#define GCEA_ERR_STATUS__SDP_RDRSP_DATASTATUS__SHIFT   
   0x8
+#define GCEA_ERR_STATUS__SDP_RDRSP_DATAPARITY_ERROR__SHIFT 
   0xa
+#define GCEA_ERR_STATUS__CLEAR_ERROR_STATUS