Re: [pull] amdgpu, ttm drm-next-5.3

2019-06-05 Thread Daniel Vetter
On Thu, Jun 6, 2019 at 7:25 AM Daniel Vetter  wrote:
>
> On Thu, Jun 6, 2019 at 5:05 AM Alex Deucher  wrote:
> >
> > On Wed, Jun 5, 2019 at 10:34 PM Dave Airlie  wrote:
> > >
> > > On Thu, 6 Jun 2019 at 05:12, Alex Deucher  wrote:
> > > >
> > > > Hi Dave, Daniel,
> > > >
> > > > More new stuff for 5.3:
> > > >
> > > > amdgpu:
> > > > - Revert timeline support until KHR is ready
> > > > - Various driver reload fixes
> > > > - Refactor clock handling in DC
> > > > - Aux fixes for DC
> > > > - Bandwidth calculation updates for DC
> > > > - Fix documentation due to file rename
> > > > - RAS fix
> > > > - Fix race in late_init
> > > >
> > > > ttm:
> > > > - Allow for better forward progress when there is heavy memory 
> > > > contention
> > >
> > > dim: 137a7da92557 ("Revert "drm/amdgpu: add DRIVER_SYNCOBJ_TIMELINE to
> > > amdgpu""): mandatory review missing.
> > > dim: cf25b6444376 ("gpu: amdgpu: fix broken amdgpu_dma_buf.c
> > > references"): SHA1 in fixes line not found:
> > > dim: 988076cd8c5c ("drm/amdgpu: rename amdgpu_prime.[ch] into
> > > amdgpu_dma_buf.[ch]")
> > >
> > > The first I'm not worried about, but the fixes line should be fixed
> > > before I can pull this.
> > > 2fbd6f94accdbb223acccada68940b50b0c668d9 is the upstream commit in my 
> > > tree.
> >
> > Weird.  dim didn't complain when I ran it.  I guess the old commit
> > happened to be in my repo.  I'll fix it up.
>
> I should check also that it's an ancestor commit, not just that it's

s/I/It/, meanwhile dim makes sure this is the case. Typing mails
before coffee :-)

https://gitlab.freedesktop.org/drm/maintainer-tools/blob/master/dim#L831

Is the check.
-Daniel

> in the repo (but that's a few conditions later on, for Dave it
> obviously failed earlier). Since it's a branch not a tag I can't pull
> the old version anymore and take a look and figure out what might be
> the reason, but this should have worked.
> -Daniel
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch



-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [pull] amdgpu, ttm drm-next-5.3

2019-06-05 Thread Daniel Vetter
On Thu, Jun 6, 2019 at 5:05 AM Alex Deucher  wrote:
>
> On Wed, Jun 5, 2019 at 10:34 PM Dave Airlie  wrote:
> >
> > On Thu, 6 Jun 2019 at 05:12, Alex Deucher  wrote:
> > >
> > > Hi Dave, Daniel,
> > >
> > > More new stuff for 5.3:
> > >
> > > amdgpu:
> > > - Revert timeline support until KHR is ready
> > > - Various driver reload fixes
> > > - Refactor clock handling in DC
> > > - Aux fixes for DC
> > > - Bandwidth calculation updates for DC
> > > - Fix documentation due to file rename
> > > - RAS fix
> > > - Fix race in late_init
> > >
> > > ttm:
> > > - Allow for better forward progress when there is heavy memory contention
> >
> > dim: 137a7da92557 ("Revert "drm/amdgpu: add DRIVER_SYNCOBJ_TIMELINE to
> > amdgpu""): mandatory review missing.
> > dim: cf25b6444376 ("gpu: amdgpu: fix broken amdgpu_dma_buf.c
> > references"): SHA1 in fixes line not found:
> > dim: 988076cd8c5c ("drm/amdgpu: rename amdgpu_prime.[ch] into
> > amdgpu_dma_buf.[ch]")
> >
> > The first I'm not worried about, but the fixes line should be fixed
> > before I can pull this.
> > 2fbd6f94accdbb223acccada68940b50b0c668d9 is the upstream commit in my tree.
>
> Weird.  dim didn't complain when I ran it.  I guess the old commit
> happened to be in my repo.  I'll fix it up.

I should check also that it's an ancestor commit, not just that it's
in the repo (but that's a few conditions later on, for Dave it
obviously failed earlier). Since it's a branch not a tag I can't pull
the old version anymore and take a look and figure out what might be
the reason, but this should have worked.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[pull v2] amdgpu, ttm drm-next-5.3

2019-06-05 Thread Alex Deucher
Hi Dave, Daniel,

More new stuff for 5.3:

amdgpu:
- Revert timeline support until KHR is ready
- Various driver reload fixes
- Refactor clock handling in DC
- Aux fixes for DC
- Bandwidth calculation updates for DC
- Fix documentation due to file rename
- RAS fix
- Fix race in late_init

ttm:
- Allow for better forward progress when there is heavy memory contention

v2: fix sha1 in fixes line.

The following changes since commit 91c1ead6aee22d4595f50ba66070b94a4a8f84a9:

  Merge branch 'drm-next-5.3' of git://people.freedesktop.org/~agd5f/linux into 
drm-next (2019-05-31 10:04:39 +1000)

are available in the Git repository at:

  git://people.freedesktop.org/~agd5f/linux drm-next-5.3

for you to fetch changes up to 72a14e9b23d0a5a68f8504a2ecaf26788a11a14d:

  Revert "drm/amdgpu: add DRIVER_SYNCOBJ_TIMELINE to amdgpu" (2019-06-05 
22:18:09 -0500)


Alex Deucher (3):
  drm/amdgpu: fix a race in GPU reset with IB test (v2)
  drm/amdgpu/display: Drop some new CONFIG_DRM_AMD_DC_DCN1_01 guards
  Revert "drm/amdgpu: add DRIVER_SYNCOBJ_TIMELINE to amdgpu"

Anthony Koo (2):
  drm/amd/display: do not power on eDP power rail early
  drm/amd/display: fix issues with bad AUX reply on some displays

Aric Cyr (2):
  drm/amd/display: 3.2.32
  drm/amd/display: program manual trigger only for bottom most pipe

Chris Park (1):
  drm/amd/display: Move link functions from dc to dc_link

Christian König (7):
  drm/ttm: Make LRU removal optional v2
  drm/ttm: return immediately in case of a signal
  drm/ttm: remove manual placement preference
  drm/ttm: cleanup ttm_bo_mem_space
  drm/ttm: immediately move BOs to the new LRU v3
  drm/ttm: fix busy memory to fail other user v10
  drm/ttm: fix ttm_bo_unreserve

Chunming Zhou (1):
  drm/amd/display: use ttm_eu_reserve_buffers instead of amdgpu_bo_reserve 
v2

Daniel He (1):
  drm/amd/display: Modified AUX_DPHY_RX_CONTROL0

Emily Deng (3):
  drm/amdgpu:Fix the unpin warning about csb buffer
  drm/amdgpu/sriov: Correct some register program method
  drm/amdgpu/display: Fix reload driver error

Eric Bernstein (1):
  drm/amd/display: Refactor DIO stream encoder

Eric Yang (5):
  drm/amd/display: make clk mgr soc specific
  drm/amd/display: Move CLK_BASE_INNER macro
  drm/amd/display: move clk_mgr files to right place
  drm/amd/display: Fix type of pp_smu_wm_set_range struct
  drm/amd/display: Refactor clk_mgr functions

Eryk Brol (3):
  drm/amd/display: Disable audio stream only if it's currently enabled
  drm/amd/display: Ensure DRR triggers in BP
  drm/amd/display: Increase Backlight Gain Step Size

Gary Kattan (1):
  drm/amd/display: Implement CM dealpha and bias interfaces

Hugo Hu (1):
  drm/amd/display: Don't use ROM for output TF if GAMMA_CS_TFM_1D

Ilya Bakoulin (1):
  drm/amd/display: Add writeback_config to VBA vars

Jun Lei (1):
  drm/amd/display: Add min_dcfclk_mhz field to bb overrides

Krunoslav Kovac (2):
  drm/amd/display: Add GSL source select registers
  drm/amd/display: CS_TFM_1D only applied post EOTF

Mauro Carvalho Chehab (1):
  gpu: amdgpu: fix broken amdgpu_dma_buf.c references

Nicholas Kazlauskas (1):
  drm/amd/display: Reset planes for color management changes

Oak Zeng (1):
  drm/amdkfd: Return proper error code for gws alloc API

Paul Hsieh (1):
  drm/amd/display: disable PSR/ABM before destroy DMCU struct

Su Sung Chung (2):
  drm/amd/display: fix calculation of total_data_read_bandwidth
  drm/amd/display: fix crash on setmode when mode is close to bw limit

Wenjing Liu (1):
  drm/amd/display: assign new stream id in dc_copy_stream

xinhui pan (2):
  drm/amdgpu: ras injection use gpu address
  drm/amdgpu: cancel late_init_work before gpu reset

 Documentation/gpu/amdgpu.rst   |4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c   |   11 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c |2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c|2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  116 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c|3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c|4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c|   16 +
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  |   14 +-
 drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c   |8 +-
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c   |6 +-
 .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |2 +-
 drivers/gpu/drm/amd/display/Makefile   |1 +
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |   66 +-
 drivers/gpu/drm/amd/display/dc/Makefile|2 +-
 

Re: [pull] amdgpu, ttm drm-next-5.3

2019-06-05 Thread Alex Deucher
On Wed, Jun 5, 2019 at 10:34 PM Dave Airlie  wrote:
>
> On Thu, 6 Jun 2019 at 05:12, Alex Deucher  wrote:
> >
> > Hi Dave, Daniel,
> >
> > More new stuff for 5.3:
> >
> > amdgpu:
> > - Revert timeline support until KHR is ready
> > - Various driver reload fixes
> > - Refactor clock handling in DC
> > - Aux fixes for DC
> > - Bandwidth calculation updates for DC
> > - Fix documentation due to file rename
> > - RAS fix
> > - Fix race in late_init
> >
> > ttm:
> > - Allow for better forward progress when there is heavy memory contention
>
> dim: 137a7da92557 ("Revert "drm/amdgpu: add DRIVER_SYNCOBJ_TIMELINE to
> amdgpu""): mandatory review missing.
> dim: cf25b6444376 ("gpu: amdgpu: fix broken amdgpu_dma_buf.c
> references"): SHA1 in fixes line not found:
> dim: 988076cd8c5c ("drm/amdgpu: rename amdgpu_prime.[ch] into
> amdgpu_dma_buf.[ch]")
>
> The first I'm not worried about, but the fixes line should be fixed
> before I can pull this.
> 2fbd6f94accdbb223acccada68940b50b0c668d9 is the upstream commit in my tree.

Weird.  dim didn't complain when I ran it.  I guess the old commit
happened to be in my repo.  I'll fix it up.

Alex

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

Re: [pull] amdgpu, ttm drm-next-5.3

2019-06-05 Thread Dave Airlie
On Thu, 6 Jun 2019 at 05:12, Alex Deucher  wrote:
>
> Hi Dave, Daniel,
>
> More new stuff for 5.3:
>
> amdgpu:
> - Revert timeline support until KHR is ready
> - Various driver reload fixes
> - Refactor clock handling in DC
> - Aux fixes for DC
> - Bandwidth calculation updates for DC
> - Fix documentation due to file rename
> - RAS fix
> - Fix race in late_init
>
> ttm:
> - Allow for better forward progress when there is heavy memory contention

dim: 137a7da92557 ("Revert "drm/amdgpu: add DRIVER_SYNCOBJ_TIMELINE to
amdgpu""): mandatory review missing.
dim: cf25b6444376 ("gpu: amdgpu: fix broken amdgpu_dma_buf.c
references"): SHA1 in fixes line not found:
dim: 988076cd8c5c ("drm/amdgpu: rename amdgpu_prime.[ch] into
amdgpu_dma_buf.[ch]")

The first I'm not worried about, but the fixes line should be fixed
before I can pull this.
2fbd6f94accdbb223acccada68940b50b0c668d9 is the upstream commit in my tree.

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

RE: [PATCH] drm/amdgpu: register pm sysfs for sriov

2019-06-05 Thread Tao, Yintian
Hi  Alex

Many thanks for your review.

Best Regards
Yintian Tao

-Original Message-
From: Alex Deucher  
Sent: Thursday, June 06, 2019 10:28 AM
To: Tao, Yintian 
Cc: amd-gfx list 
Subject: Re: [PATCH] drm/amdgpu: register pm sysfs for sriov

On Wed, Jun 5, 2019 at 9:54 AM Yintian Tao  wrote:
>
> we need register pm sysfs for virt in order to support dpm level 
> modification because smu ip block will not be added under SRIOV
>
> Signed-off-by: Yintian Tao 
> Change-Id: Ib0e13934c0c33da00f9d2add6be25a373c6fb957
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  6 +++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 61 
> --
>  drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h |  2 +
>  3 files changed, 65 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index d00fd5d..9b9d387 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -2695,6 +2695,9 @@ int amdgpu_device_init(struct amdgpu_device 
> *adev,
>
> amdgpu_fbdev_init(adev);
>
> +   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev))
> +   amdgpu_virt_pm_sysfs_init(adev);
> +
> r = amdgpu_pm_sysfs_init(adev);
> if (r)
> DRM_ERROR("registering pm debugfs failed (%d).\n", r); 
> @@ -2816,6 +2819,9 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
> iounmap(adev->rmmio);
> adev->rmmio = NULL;
> amdgpu_device_doorbell_fini(adev);
> +   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev))
> +   amdgpu_virt_pm_sysfs_fini(adev);
> +
> amdgpu_debugfs_regs_cleanup(adev);
> device_remove_file(adev->dev, _attr_pcie_replay_count);
> amdgpu_ucode_sysfs_fini(adev); diff --git 
> a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> index a73e190..b6f16d45 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> @@ -269,8 +269,11 @@ static ssize_t 
> amdgpu_get_dpm_forced_performance_level(struct device *dev,
> struct amdgpu_device *adev = ddev->dev_private;
> enum amd_dpm_forced_level level = 0xff;
>
> -   if  ((adev->flags & AMD_IS_PX) &&
> -(ddev->switch_power_state != DRM_SWITCH_POWER_ON))
> +   if (amdgpu_sriov_vf(adev))
> +   return 0;
> +
> +   if ((adev->flags & AMD_IS_PX) &&
> +   (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
> return snprintf(buf, PAGE_SIZE, "off\n");
>
> if (is_support_sw_smu(adev))
> @@ -308,9 +311,11 @@ static ssize_t 
> amdgpu_set_dpm_forced_performance_level(struct device *dev,
>  (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
> return -EINVAL;
>
> -   if (is_support_sw_smu(adev))
> +   if (!amdgpu_sriov_vf(adev) && is_support_sw_smu(adev))
> current_level = smu_get_performance_level(>smu);
> -   else if (adev->powerplay.pp_funcs->get_performance_level)
> +   else if (!amdgpu_sriov_vf(adev) &&
> +adev->powerplay.pp_funcs &&
> +adev->powerplay.pp_funcs->get_performance_level)
> current_level = 
> amdgpu_dpm_get_performance_level(adev);

Wrap the entire existing block in if (!amdgpu_sriov_vf(adev) rather than adding 
the check to each case.

>
> if (strncmp("low", buf, strlen("low")) == 0) { @@ -907,6 
> +912,10 @@ static ssize_t amdgpu_get_pp_dpm_mclk(struct device *dev,
> struct drm_device *ddev = dev_get_drvdata(dev);
> struct amdgpu_device *adev = ddev->dev_private;
>
> +   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev) &&
> +   adev->virt.ops->get_pp_clk)
> +   return adev->virt.ops->get_pp_clk(adev,PP_MCLK,buf);
> +
> if (is_support_sw_smu(adev))
> return smu_print_clk_levels(>smu, PP_MCLK, buf);
> else if (adev->powerplay.pp_funcs->print_clock_levels)
> @@ -925,6 +934,9 @@ static ssize_t amdgpu_set_pp_dpm_mclk(struct device *dev,
> int ret;
> uint32_t mask = 0;
>
> +   if (amdgpu_sriov_vf(adev))
> +   return 0;
> +
> ret = amdgpu_read_mask(buf, count, );
> if (ret)
> return ret;
> @@ -965,6 +977,9 @@ static ssize_t amdgpu_set_pp_dpm_socclk(struct device 
> *dev,
> int ret;
> uint32_t mask = 0;
>
> +   if (amdgpu_sriov_vf(adev))
> +   return 0;
> +
> ret = amdgpu_read_mask(buf, count, );
> if (ret)
> return ret;
> @@ -2698,6 +2713,44 @@ void amdgpu_pm_print_power_states(struct 
> amdgpu_device *adev)
>
>  }
>
> +int amdgpu_virt_pm_sysfs_init(struct amdgpu_device *adev)

Please rename this to amdgpu_pm_virt_sysfs_init to match the rest of the naming 
conventions in the file.

> +{
> +   int ret = 0;
> +
> +   if (!(amdgpu_sriov_vf(adev) 

Re: [PATCH] drm/amdgpu: register pm sysfs for sriov

2019-06-05 Thread Alex Deucher
On Wed, Jun 5, 2019 at 9:54 AM Yintian Tao  wrote:
>
> we need register pm sysfs for virt in order
> to support dpm level modification because
> smu ip block will not be added under SRIOV
>
> Signed-off-by: Yintian Tao 
> Change-Id: Ib0e13934c0c33da00f9d2add6be25a373c6fb957
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  6 +++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 61 
> --
>  drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h |  2 +
>  3 files changed, 65 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index d00fd5d..9b9d387 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -2695,6 +2695,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
>
> amdgpu_fbdev_init(adev);
>
> +   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev))
> +   amdgpu_virt_pm_sysfs_init(adev);
> +
> r = amdgpu_pm_sysfs_init(adev);
> if (r)
> DRM_ERROR("registering pm debugfs failed (%d).\n", r);
> @@ -2816,6 +2819,9 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
> iounmap(adev->rmmio);
> adev->rmmio = NULL;
> amdgpu_device_doorbell_fini(adev);
> +   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev))
> +   amdgpu_virt_pm_sysfs_fini(adev);
> +
> amdgpu_debugfs_regs_cleanup(adev);
> device_remove_file(adev->dev, _attr_pcie_replay_count);
> amdgpu_ucode_sysfs_fini(adev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> index a73e190..b6f16d45 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> @@ -269,8 +269,11 @@ static ssize_t 
> amdgpu_get_dpm_forced_performance_level(struct device *dev,
> struct amdgpu_device *adev = ddev->dev_private;
> enum amd_dpm_forced_level level = 0xff;
>
> -   if  ((adev->flags & AMD_IS_PX) &&
> -(ddev->switch_power_state != DRM_SWITCH_POWER_ON))
> +   if (amdgpu_sriov_vf(adev))
> +   return 0;
> +
> +   if ((adev->flags & AMD_IS_PX) &&
> +   (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
> return snprintf(buf, PAGE_SIZE, "off\n");
>
> if (is_support_sw_smu(adev))
> @@ -308,9 +311,11 @@ static ssize_t 
> amdgpu_set_dpm_forced_performance_level(struct device *dev,
>  (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
> return -EINVAL;
>
> -   if (is_support_sw_smu(adev))
> +   if (!amdgpu_sriov_vf(adev) && is_support_sw_smu(adev))
> current_level = smu_get_performance_level(>smu);
> -   else if (adev->powerplay.pp_funcs->get_performance_level)
> +   else if (!amdgpu_sriov_vf(adev) &&
> +adev->powerplay.pp_funcs &&
> +adev->powerplay.pp_funcs->get_performance_level)
> current_level = amdgpu_dpm_get_performance_level(adev);

Wrap the entire existing block in if (!amdgpu_sriov_vf(adev) rather
than adding the check to each case.

>
> if (strncmp("low", buf, strlen("low")) == 0) {
> @@ -907,6 +912,10 @@ static ssize_t amdgpu_get_pp_dpm_mclk(struct device *dev,
> struct drm_device *ddev = dev_get_drvdata(dev);
> struct amdgpu_device *adev = ddev->dev_private;
>
> +   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev) &&
> +   adev->virt.ops->get_pp_clk)
> +   return adev->virt.ops->get_pp_clk(adev,PP_MCLK,buf);
> +
> if (is_support_sw_smu(adev))
> return smu_print_clk_levels(>smu, PP_MCLK, buf);
> else if (adev->powerplay.pp_funcs->print_clock_levels)
> @@ -925,6 +934,9 @@ static ssize_t amdgpu_set_pp_dpm_mclk(struct device *dev,
> int ret;
> uint32_t mask = 0;
>
> +   if (amdgpu_sriov_vf(adev))
> +   return 0;
> +
> ret = amdgpu_read_mask(buf, count, );
> if (ret)
> return ret;
> @@ -965,6 +977,9 @@ static ssize_t amdgpu_set_pp_dpm_socclk(struct device 
> *dev,
> int ret;
> uint32_t mask = 0;
>
> +   if (amdgpu_sriov_vf(adev))
> +   return 0;
> +
> ret = amdgpu_read_mask(buf, count, );
> if (ret)
> return ret;
> @@ -2698,6 +2713,44 @@ void amdgpu_pm_print_power_states(struct amdgpu_device 
> *adev)
>
>  }
>
> +int amdgpu_virt_pm_sysfs_init(struct amdgpu_device *adev)

Please rename this to amdgpu_pm_virt_sysfs_init to match the rest of
the naming conventions in the file.

> +{
> +   int ret = 0;
> +
> +   if (!(amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev)))
> +   return ret;
> +
> +   ret = device_create_file(adev->dev, _attr_pp_dpm_sclk);
> +   if (ret) {
> +   DRM_ERROR("failed to create device file pp_dpm_sclk\n");
> +   return ret;
> + 

Re: [PATCH 6/6] drm/amdkfd: Fix sdma queue allocate race condition

2019-06-05 Thread Kuehling, Felix
I think the simpler way to fix this, is to restructure 
create_queue_cpsch similar to the nocpsch version where we allocate the 
MQD early and take the DQM lock right after that. That way you don't 
need locked and unlocked variants of allocate_sdma_queue and 
deallocate_sdma_queue.

Regards,
   Felix


On 2019-06-05 12:06 p.m., Zeng, Oak wrote:
> SDMA queue allocation requires the dqm lock as it modify
> the global dqm members. Introduce functions to allocate/deallocate
> in locked/unlocked circumstance.
>
> Change-Id: Id3084524c5f65d9629b12cf6b4862a7516945cb1
> Signed-off-by: Oak Zeng 
> ---
>   .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 34 
> --
>   1 file changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c 
> b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> index 6b1a2ee..52e4ede 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -53,6 +53,8 @@ static int map_queues_cpsch(struct device_queue_manager 
> *dqm);
>   
>   static void deallocate_sdma_queue(struct device_queue_manager *dqm,
>   struct queue *q);
> +static void deallocate_sdma_queue_locked(struct device_queue_manager *dqm,
> + struct queue *q);
>   
>   static inline void deallocate_hqd(struct device_queue_manager *dqm,
>   struct queue *q);
> @@ -434,10 +436,10 @@ static int destroy_queue_nocpsch_locked(struct 
> device_queue_manager *dqm,
>   deallocate_hqd(dqm, q);
>   } else if (q->properties.type == KFD_QUEUE_TYPE_SDMA) {
>   dqm->sdma_queue_count--;
> - deallocate_sdma_queue(dqm, q);
> + deallocate_sdma_queue_locked(dqm, q);
>   } else if (q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) {
>   dqm->xgmi_sdma_queue_count--;
> - deallocate_sdma_queue(dqm, q);
> + deallocate_sdma_queue_locked(dqm, q);
>   } else {
>   pr_debug("q->properties.type %d is invalid\n",
>   q->properties.type);
> @@ -914,9 +916,12 @@ static int allocate_sdma_queue(struct 
> device_queue_manager *dqm,
>   {
>   int bit;
>   
> + dqm_lock(dqm);
>   if (q->properties.type == KFD_QUEUE_TYPE_SDMA) {
> - if (dqm->sdma_bitmap == 0)
> + if (dqm->sdma_bitmap == 0) {
> + dqm_unlock(dqm);
>   return -ENOMEM;
> + }
>   bit = __ffs64(dqm->sdma_bitmap);
>   dqm->sdma_bitmap &= ~(1ULL << bit);
>   q->sdma_id = bit;
> @@ -925,8 +930,10 @@ static int allocate_sdma_queue(struct 
> device_queue_manager *dqm,
>   q->properties.sdma_queue_id = q->sdma_id /
>   get_num_sdma_engines(dqm);
>   } else if (q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) {
> - if (dqm->xgmi_sdma_bitmap == 0)
> + if (dqm->xgmi_sdma_bitmap == 0) {
> + dqm_unlock(dqm);
>   return -ENOMEM;
> + }
>   bit = __ffs64(dqm->xgmi_sdma_bitmap);
>   dqm->xgmi_sdma_bitmap &= ~(1ULL << bit);
>   q->sdma_id = bit;
> @@ -942,13 +949,14 @@ static int allocate_sdma_queue(struct 
> device_queue_manager *dqm,
>   get_num_xgmi_sdma_engines(dqm);
>   }
>   
> + dqm_unlock(dqm);
>   pr_debug("SDMA engine id: %d\n", q->properties.sdma_engine_id);
>   pr_debug("SDMA queue id: %d\n", q->properties.sdma_queue_id);
>   
>   return 0;
>   }
>   
> -static void deallocate_sdma_queue(struct device_queue_manager *dqm,
> +static void deallocate_sdma_queue_locked(struct device_queue_manager *dqm,
>   struct queue *q)
>   {
>   if (q->properties.type == KFD_QUEUE_TYPE_SDMA) {
> @@ -962,6 +970,14 @@ static void deallocate_sdma_queue(struct 
> device_queue_manager *dqm,
>   }
>   }
>   
> +static void deallocate_sdma_queue(struct device_queue_manager *dqm,
> + struct queue *q)
> +{
> + dqm_lock(dqm);
> + deallocate_sdma_queue_locked(dqm, q);
> + dqm_unlock(dqm);
> +}
> +
>   /*
>* Device Queue Manager implementation for cp scheduler
>*/
> @@ -1356,10 +1372,10 @@ static int destroy_queue_cpsch(struct 
> device_queue_manager *dqm,
>   
>   if (q->properties.type == KFD_QUEUE_TYPE_SDMA) {
>   dqm->sdma_queue_count--;
> - deallocate_sdma_queue(dqm, q);
> + deallocate_sdma_queue_locked(dqm, q);
>   } else if (q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) {
>   dqm->xgmi_sdma_queue_count--;
> - deallocate_sdma_queue(dqm, q);
> + deallocate_sdma_queue_locked(dqm, q);
>   }
>   
>   list_del(>list);
> @@ -1585,10 +1601,10 @@ static int 

Re: [PATCH 5/6] drm/amdkfd: Fix a circular lock dependency

2019-06-05 Thread Kuehling, Felix
This patch looks good to me, but it'll probably change a little if you 
implement my suggestions for patch 4.

Regards,
   Felix

On 2019-06-05 12:06 p.m., Zeng, Oak wrote:
> The idea to break the circular lock dependency is to move allocate_mqd
> out of dqm lock protection. See callstack #1 below.
>
> [   59.510149] [drm] Initialized amdgpu 3.30.0 20150101 for :04:00.0 on 
> minor 0
>
> [  513.604034] ==
> [  513.604205] WARNING: possible circular locking dependency detected
> [  513.604375] 4.18.0-kfd-root #2 Tainted: GW
> [  513.604530] --
> [  513.604699] kswapd0/611 is trying to acquire lock:
> [  513.604840] d254022e (>lock_hidden){+.+.}, at: 
> evict_process_queues_nocpsch+0x26/0x140 [amdgpu]
> [  513.605150]
> but task is already holding lock:
> [  513.605307] 961547fc (_vma->rwsem){}, at: 
> page_lock_anon_vma_read+0xe4/0x250
> [  513.605540]
> which lock already depends on the new lock.
>
> [  513.605747]
> the existing dependency chain (in reverse order) is:
> [  513.605944]
> -> #4 (_vma->rwsem){}:
> [  513.606106]__vma_adjust+0x147/0x7f0
> [  513.606231]__split_vma+0x179/0x190
> [  513.606353]mprotect_fixup+0x217/0x260
> [  513.606553]do_mprotect_pkey+0x211/0x380
> [  513.606752]__x64_sys_mprotect+0x1b/0x20
> [  513.606954]do_syscall_64+0x50/0x1a0
> [  513.607149]entry_SYSCALL_64_after_hwframe+0x49/0xbe
> [  513.607380]
> -> #3 (>i_mmap_rwsem){}:
> [  513.607678]rmap_walk_file+0x1f0/0x280
> [  513.607887]page_referenced+0xdd/0x180
> [  513.608081]shrink_page_list+0x853/0xcb0
> [  513.608279]shrink_inactive_list+0x33b/0x700
> [  513.608483]shrink_node_memcg+0x37a/0x7f0
> [  513.608682]shrink_node+0xd8/0x490
> [  513.608869]balance_pgdat+0x18b/0x3b0
> [  513.609062]kswapd+0x203/0x5c0
> [  513.609241]kthread+0x100/0x140
> [  513.609420]ret_from_fork+0x24/0x30
> [  513.609607]
> -> #2 (fs_reclaim){+.+.}:
> [  513.609883]kmem_cache_alloc_trace+0x34/0x2e0
> [  513.610093]reservation_object_reserve_shared+0x139/0x300
> [  513.610326]ttm_bo_init_reserved+0x291/0x480 [ttm]
> [  513.610567]amdgpu_bo_do_create+0x1d2/0x650 [amdgpu]
> [  513.610811]amdgpu_bo_create+0x40/0x1f0 [amdgpu]
> [  513.611041]amdgpu_bo_create_reserved+0x249/0x2d0 [amdgpu]
> [  513.611290]amdgpu_bo_create_kernel+0x12/0x70 [amdgpu]
> [  513.611584]amdgpu_ttm_init+0x2cb/0x560 [amdgpu]
> [  513.611823]gmc_v9_0_sw_init+0x400/0x750 [amdgpu]
> [  513.612491]amdgpu_device_init+0x14eb/0x1990 [amdgpu]
> [  513.612730]amdgpu_driver_load_kms+0x78/0x290 [amdgpu]
> [  513.612958]drm_dev_register+0x111/0x1a0
> [  513.613171]amdgpu_pci_probe+0x11c/0x1e0 [amdgpu]
> [  513.613389]local_pci_probe+0x3f/0x90
> [  513.613581]pci_device_probe+0x102/0x1c0
> [  513.613779]driver_probe_device+0x2a7/0x480
> [  513.613984]__driver_attach+0x10a/0x110
> [  513.614179]bus_for_each_dev+0x67/0xc0
> [  513.614372]bus_add_driver+0x1eb/0x260
> [  513.614565]driver_register+0x5b/0xe0
> [  513.614756]do_one_initcall+0xac/0x357
> [  513.614952]do_init_module+0x5b/0x213
> [  513.615145]load_module+0x2542/0x2d30
> [  513.615337]__do_sys_finit_module+0xd2/0x100
> [  513.615541]do_syscall_64+0x50/0x1a0
> [  513.615731]entry_SYSCALL_64_after_hwframe+0x49/0xbe
> [  513.615963]
> -> #1 (reservation_ww_class_mutex){+.+.}:
> [  513.616293]amdgpu_amdkfd_alloc_gtt_mem+0xcf/0x2c0 [amdgpu]
> [  513.616554]init_mqd+0x223/0x260 [amdgpu]
> [  513.616779]create_queue_nocpsch+0x4d9/0x600 [amdgpu]
> [  513.617031]pqm_create_queue+0x37c/0x520 [amdgpu]
> [  513.617270]kfd_ioctl_create_queue+0x2f9/0x650 [amdgpu]
> [  513.617522]kfd_ioctl+0x202/0x350 [amdgpu]
> [  513.617724]do_vfs_ioctl+0x9f/0x6c0
> [  513.617914]ksys_ioctl+0x66/0x70
> [  513.618095]__x64_sys_ioctl+0x16/0x20
> [  513.618286]do_syscall_64+0x50/0x1a0
> [  513.618476]entry_SYSCALL_64_after_hwframe+0x49/0xbe
> [  513.618695]
> -> #0 (>lock_hidden){+.+.}:
> [  513.618984]__mutex_lock+0x98/0x970
> [  513.619197]evict_process_queues_nocpsch+0x26/0x140 [amdgpu]
> [  513.619459]kfd_process_evict_queues+0x3b/0xb0 [amdgpu]
> [  513.619710]kgd2kfd_quiesce_mm+0x1c/0x40 [amdgpu]
> [  513.620103]amdgpu_amdkfd_evict_userptr+0x38/0x70 [amdgpu]
> [  513.620363]amdgpu_mn_invalidate_range_start_hsa+0xa6/0xc0 [amdgpu]
> [  513.620614]__mmu_notifier_invalidate_range_start+0x70/0xb0
> [  513.620851]   

Re: [PATCH 3/6] drm/amdkfd: Refactor create_queue_nocpsch

2019-06-05 Thread Kuehling, Felix
Patches 1-3 are Reviewed-by: Felix Kuehling 

On 2019-06-05 12:06 p.m., Zeng, Oak wrote:
> This is prepare work to fix a circular lock dependency.
> No logic change
>
> Change-Id: I4e0ee918260e7780de972dd71f4ce787b4f6dde9
> Signed-off-by: Oak Zeng 
> ---
>   .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 171 
> +++--
>   1 file changed, 57 insertions(+), 114 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c 
> b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> index dab6ef4..3c042eb 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -42,10 +42,6 @@
>   static int set_pasid_vmid_mapping(struct device_queue_manager *dqm,
>   unsigned int pasid, unsigned int vmid);
>   
> -static int create_compute_queue_nocpsch(struct device_queue_manager *dqm,
> - struct queue *q,
> - struct qcm_process_device *qpd);
> -
>   static int execute_queues_cpsch(struct device_queue_manager *dqm,
>   enum kfd_unmap_queues_filter filter,
>   uint32_t filter_param);
> @@ -55,13 +51,14 @@ static int unmap_queues_cpsch(struct device_queue_manager 
> *dqm,
>   
>   static int map_queues_cpsch(struct device_queue_manager *dqm);
>   
> -static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,
> - struct queue *q,
> - struct qcm_process_device *qpd);
> -
>   static void deallocate_sdma_queue(struct device_queue_manager *dqm,
>   struct queue *q);
>   
> +static inline void deallocate_hqd(struct device_queue_manager *dqm,
> + struct queue *q);
> +static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q);
> +static int allocate_sdma_queue(struct device_queue_manager *dqm,
> + struct queue *q);
>   static void kfd_process_hw_exception(struct work_struct *work);
>   
>   static inline
> @@ -223,6 +220,9 @@ static int allocate_vmid(struct device_queue_manager *dqm,
>   /* invalidate the VM context after pasid and vmid mapping is set up */
>   kfd_flush_tlb(qpd_to_pdd(qpd));
>   
> + dqm->dev->kfd2kgd->set_scratch_backing_va(
> + dqm->dev->kgd, qpd->sh_hidden_private_base, qpd->vmid);
> +
>   return 0;
>   }
>   
> @@ -269,6 +269,7 @@ static int create_queue_nocpsch(struct 
> device_queue_manager *dqm,
>   struct queue *q,
>   struct qcm_process_device *qpd)
>   {
> + struct mqd_manager *mqd_mgr;
>   int retval;
>   
>   print_queue(q);
> @@ -298,18 +299,41 @@ static int create_queue_nocpsch(struct 
> device_queue_manager *dqm,
>   q->properties.tba_addr = qpd->tba_addr;
>   q->properties.tma_addr = qpd->tma_addr;
>   
> - if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE)
> - retval = create_compute_queue_nocpsch(dqm, q, qpd);
> - else if (q->properties.type == KFD_QUEUE_TYPE_SDMA ||
> - q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI)
> - retval = create_sdma_queue_nocpsch(dqm, q, qpd);
> - else
> - retval = -EINVAL;
> + mqd_mgr = dqm->mqd_mgrs[get_mqd_type_from_queue_type(
> + q->properties.type)];
> + if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE) {
> + retval = allocate_hqd(dqm, q);
> + if (retval)
> + goto deallocate_vmid;
> + pr_debug("Loading mqd to hqd on pipe %d, queue %d\n",
> + q->pipe, q->queue);
> + } else if (q->properties.type == KFD_QUEUE_TYPE_SDMA ||
> + q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) {
> + retval = allocate_sdma_queue(dqm, q);
> + if (retval)
> + goto deallocate_vmid;
> + dqm->asic_ops.init_sdma_vm(dqm, q, qpd);
> + }
>   
> - if (retval) {
> - if (list_empty(>queues_list))
> - deallocate_vmid(dqm, qpd, q);
> - goto out_unlock;
> + retval = allocate_doorbell(qpd, q);
> + if (retval)
> + goto out_deallocate_hqd;
> +
> + retval = mqd_mgr->init_mqd(mqd_mgr, >mqd, >mqd_mem_obj,
> + >gart_mqd_addr, >properties);
> + if (retval)
> + goto out_deallocate_doorbell;
> +
> + if (q->properties.is_active) {
> +
> + if (WARN(q->process->mm != current->mm,
> + "should only run in user thread"))
> + retval = -EFAULT;
> + else
> + retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe,
> + q->queue, >properties, current->mm);
> + 

Re: [PATCH 4/6] drm/amdkfd: Separate mqd allocation and initialization

2019-06-05 Thread Kuehling, Felix
Nice. Surprisingly this actually resulted in slightly fewer lines of 
code. Some suggestions:

Let's also rename uninit_mqd to free_mqd, as it is the counterpart to 
allocate_mqd, not init_mqd.

And unless I'm missing something, init_mqd and update_mqd cannot fail 
now that allocate_mqd has been separated from them. That means you could 
change them to void functions, and it may simplify some of the error 
handling if you have fewer potential failure cases to consider.

Regards,
   Felix

On 2019-06-05 12:06 p.m., Zeng, Oak wrote:
> Introduce a new mqd allocation interface and split the original
> init_mqd function into two functions: allocate_mqd and init_mqd.
> This is preparation work to fix a circular lock dependency.
>
> Change-Id: I26e53ee1abcdd688ad11d35b433da77e3fa1bee7
> Signed-off-by: Oak Zeng 
> ---
>   .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 16 ---
>   drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c  |  8 +-
>   drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c   |  2 +-
>   drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h   |  8 --
>   drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c   | 31 
> --
>   drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c| 31 
> --
>   drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c| 31 
> --
>   7 files changed, 59 insertions(+), 68 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c 
> b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> index 3c042eb..787b5be 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -319,10 +319,13 @@ static int create_queue_nocpsch(struct 
> device_queue_manager *dqm,
>   if (retval)
>   goto out_deallocate_hqd;
>   
> - retval = mqd_mgr->init_mqd(mqd_mgr, >mqd, >mqd_mem_obj,
> + q->mqd_mem_obj = mqd_mgr->allocate_mqd(mqd_mgr->dev, >properties);
> + if (!q->mqd_mem_obj)
> + goto out_deallocate_doorbell;
> + retval = mqd_mgr->init_mqd(mqd_mgr, >mqd, q->mqd_mem_obj,
>   >gart_mqd_addr, >properties);
>   if (retval)
> - goto out_deallocate_doorbell;
> + goto out_uninit_mqd;
>   
>   if (q->properties.is_active) {
>   
> @@ -1160,10 +1163,13 @@ static int create_queue_cpsch(struct 
> device_queue_manager *dqm, struct queue *q,
>   dqm->asic_ops.init_sdma_vm(dqm, q, qpd);
>   q->properties.tba_addr = qpd->tba_addr;
>   q->properties.tma_addr = qpd->tma_addr;
> - retval = mqd_mgr->init_mqd(mqd_mgr, >mqd, >mqd_mem_obj,
> + q->mqd_mem_obj = mqd_mgr->allocate_mqd(mqd_mgr->dev, >properties);
> + if (!q->mqd_mem_obj)
> + goto out_deallocate_doorbell;
> + retval = mqd_mgr->init_mqd(mqd_mgr, >mqd, q->mqd_mem_obj,
>   >gart_mqd_addr, >properties);
>   if (retval)
> - goto out_deallocate_doorbell;
> + goto out_deallocate_mqd;
>   
>   dqm_lock(dqm);
>   
> @@ -1191,6 +1197,8 @@ static int create_queue_cpsch(struct 
> device_queue_manager *dqm, struct queue *q,
>   dqm_unlock(dqm);
>   return retval;
>   
> +out_deallocate_mqd:
> + mqd_mgr->uninit_mqd(mqd_mgr, q->mqd, q->mqd_mem_obj);
>   out_deallocate_doorbell:
>   deallocate_doorbell(qpd, q);
>   out_deallocate_sdma_queue:
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c 
> b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
> index 1cc03b3..64c8ffe 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
> @@ -132,8 +132,12 @@ static bool initialize(struct kernel_queue *kq, struct 
> kfd_dev *dev,
>   kq->queue->device = dev;
>   kq->queue->process = kfd_get_process(current);
>   
> + kq->queue->mqd_mem_obj = kq->mqd_mgr->allocate_mqd(kq->mqd_mgr->dev,
> + >queue->properties);
> + if (!kq->queue->mqd_mem_obj)
> + goto err_allocate_mqd;
>   retval = kq->mqd_mgr->init_mqd(kq->mqd_mgr, >queue->mqd,
> - >queue->mqd_mem_obj,
> + kq->queue->mqd_mem_obj,
>   >queue->gart_mqd_addr,
>   >queue->properties);
>   if (retval != 0)
> @@ -165,6 +169,8 @@ static bool initialize(struct kernel_queue *kq, struct 
> kfd_dev *dev,
>   return true;
>   err_alloc_fence:
>   err_init_mqd:
> + kq->mqd_mgr->uninit_mqd(kq->mqd_mgr, kq->queue->mqd, 
> kq->queue->mqd_mem_obj);
> +err_allocate_mqd:
>   uninit_queue(kq->queue);
>   err_init_queue:
>   kfd_gtt_sa_free(dev, kq->wptr_mem);
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c 
> b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
> index cc04b362..b4f305a 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
> +++ 

[pull] amdgpu, ttm drm-next-5.3

2019-06-05 Thread Alex Deucher
Hi Dave, Daniel,

More new stuff for 5.3:

amdgpu:
- Revert timeline support until KHR is ready
- Various driver reload fixes
- Refactor clock handling in DC
- Aux fixes for DC
- Bandwidth calculation updates for DC
- Fix documentation due to file rename
- RAS fix
- Fix race in late_init

ttm:
- Allow for better forward progress when there is heavy memory contention

The following changes since commit 91c1ead6aee22d4595f50ba66070b94a4a8f84a9:

  Merge branch 'drm-next-5.3' of git://people.freedesktop.org/~agd5f/linux into 
drm-next (2019-05-31 10:04:39 +1000)

are available in the Git repository at:

  git://people.freedesktop.org/~agd5f/linux drm-next-5.3

for you to fetch changes up to 137a7da9255763f259351edc1a6f8d0e30ff66db:

  Revert "drm/amdgpu: add DRIVER_SYNCOBJ_TIMELINE to amdgpu" (2019-06-05 
09:54:27 -0500)


Alex Deucher (3):
  drm/amdgpu: fix a race in GPU reset with IB test (v2)
  drm/amdgpu/display: Drop some new CONFIG_DRM_AMD_DC_DCN1_01 guards
  Revert "drm/amdgpu: add DRIVER_SYNCOBJ_TIMELINE to amdgpu"

Anthony Koo (2):
  drm/amd/display: do not power on eDP power rail early
  drm/amd/display: fix issues with bad AUX reply on some displays

Aric Cyr (2):
  drm/amd/display: 3.2.32
  drm/amd/display: program manual trigger only for bottom most pipe

Chris Park (1):
  drm/amd/display: Move link functions from dc to dc_link

Christian König (7):
  drm/ttm: Make LRU removal optional v2
  drm/ttm: return immediately in case of a signal
  drm/ttm: remove manual placement preference
  drm/ttm: cleanup ttm_bo_mem_space
  drm/ttm: immediately move BOs to the new LRU v3
  drm/ttm: fix busy memory to fail other user v10
  drm/ttm: fix ttm_bo_unreserve

Chunming Zhou (1):
  drm/amd/display: use ttm_eu_reserve_buffers instead of amdgpu_bo_reserve 
v2

Daniel He (1):
  drm/amd/display: Modified AUX_DPHY_RX_CONTROL0

Emily Deng (3):
  drm/amdgpu:Fix the unpin warning about csb buffer
  drm/amdgpu/sriov: Correct some register program method
  drm/amdgpu/display: Fix reload driver error

Eric Bernstein (1):
  drm/amd/display: Refactor DIO stream encoder

Eric Yang (5):
  drm/amd/display: make clk mgr soc specific
  drm/amd/display: Move CLK_BASE_INNER macro
  drm/amd/display: move clk_mgr files to right place
  drm/amd/display: Fix type of pp_smu_wm_set_range struct
  drm/amd/display: Refactor clk_mgr functions

Eryk Brol (3):
  drm/amd/display: Disable audio stream only if it's currently enabled
  drm/amd/display: Ensure DRR triggers in BP
  drm/amd/display: Increase Backlight Gain Step Size

Gary Kattan (1):
  drm/amd/display: Implement CM dealpha and bias interfaces

Hugo Hu (1):
  drm/amd/display: Don't use ROM for output TF if GAMMA_CS_TFM_1D

Ilya Bakoulin (1):
  drm/amd/display: Add writeback_config to VBA vars

Jun Lei (1):
  drm/amd/display: Add min_dcfclk_mhz field to bb overrides

Krunoslav Kovac (2):
  drm/amd/display: Add GSL source select registers
  drm/amd/display: CS_TFM_1D only applied post EOTF

Mauro Carvalho Chehab (1):
  gpu: amdgpu: fix broken amdgpu_dma_buf.c references

Nicholas Kazlauskas (1):
  drm/amd/display: Reset planes for color management changes

Oak Zeng (1):
  drm/amdkfd: Return proper error code for gws alloc API

Paul Hsieh (1):
  drm/amd/display: disable PSR/ABM before destroy DMCU struct

Su Sung Chung (2):
  drm/amd/display: fix calculation of total_data_read_bandwidth
  drm/amd/display: fix crash on setmode when mode is close to bw limit

Wenjing Liu (1):
  drm/amd/display: assign new stream id in dc_copy_stream

xinhui pan (2):
  drm/amdgpu: ras injection use gpu address
  drm/amdgpu: cancel late_init_work before gpu reset

 Documentation/gpu/amdgpu.rst   |4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c   |   11 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c |2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c|2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  116 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c|3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c|4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c|2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c|   16 +
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  |   14 +-
 drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c   |8 +-
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c   |6 +-
 .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |2 +-
 drivers/gpu/drm/amd/display/Makefile   |1 +
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |   66 +-
 drivers/gpu/drm/amd/display/dc/Makefile|2 +-
 .../gpu/drm/amd/display/dc/calcs/dcn_calc_auto.h   |1 +
 

[pull] amdgpu drm-fixes-5.2

2019-06-05 Thread Alex Deucher
Hi Dave, Daniel,

Fixes for 5.2:
- A fix to make VCE resume more reliable
- Updates for new raven variants

The following changes since commit 2a3e0b716296a504d9e65fea7acb379c86fe4283:

  Merge tag 'imx-drm-fixes-2019-05-29' of 
git://git.pengutronix.de/git/pza/linux into drm-fixes (2019-05-31 09:15:25 
+1000)

are available in the Git repository at:

  git://people.freedesktop.org/~agd5f/linux drm-fixes-5.2

for you to fetch changes up to 1929059893022a3bbed43934c7313e66aad7346b:

  drm/amd/amdgpu: add RLC firmware to support raven1 refresh (2019-06-05 
11:14:15 -0500)


Chengming Gui (1):
  drm/amd/powerplay: add set_power_profile_mode for raven1_refresh

Louis Li (1):
  drm/amdgpu: fix ring test failure issue during s3 in vce 3.0 (V2)

Prike Liang (1):
  drm/amd/amdgpu: add RLC firmware to support raven1 refresh

 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 12 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c| 15 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h|  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c   |  4 ++-
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 12 -
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c   |  1 +
 drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | 31 ---
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h |  1 +
 8 files changed, 63 insertions(+), 14 deletions(-)
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: 答复: 答复: [PATCH] drm/amdgpu: no need fbcon under sriov

2019-06-05 Thread Koenig, Christian
Am 04.06.19 um 17:29 schrieb Tao, Yintian:

Yes, you are right the error message is at wrong place.


May I just remove this message?

Fine with me, but you might want to double check who added the message and why.

Something like "git blame " should do the trick.

Christian.




Best Regards

Yintian Tao


发件人: Koenig, Christian
发送时间: 2019年6月4日 23:22:00
收件人: Tao, Yintian; 
amd-gfx@lists.freedesktop.org
主题: Re: 答复: [PATCH] drm/amdgpu: no need fbcon under sriov

Am 04.06.19 um 17:16 schrieb Tao, Yintian:

Hi  Christian


But when amdgpu driver is unloading, it will call this function.


And driver unloading is an legal case under SR-IOV.


Do you mean PCIe device removal indicates the unplug the real device?

Yes, exactly and that is not supported.

Sounds like the error message is then on the wrong place.

Christian.



Best Regards

Yitnian Tao


发件人: Christian König 

发送时间: 2019年6月4日 21:57:37
收件人: Tao, Yintian; 
amd-gfx@lists.freedesktop.org
主题: Re: [PATCH] drm/amdgpu: no need fbcon under sriov

Am 04.06.19 um 15:43 schrieb Yintian Tao:
> Under Sriov, there is no need of the support for fbcon.

NAK, that error message is not related to fbcon but means that PCIe
device removal is not supported.

Christian.

>
> Signed-off-by: Yintian Tao 
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 1f38d6f..28d095b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -1012,7 +1012,8 @@ amdgpu_pci_remove(struct pci_dev *pdev)
>   {
>struct drm_device *dev = pci_get_drvdata(pdev);
>
> - DRM_ERROR("Device removal is currently not supported outside of 
> fbcon\n");
> + if (!amdgpu_sriov_vf(adev))
> + DRM_ERROR("Device removal is currently not supported outside of 
> fbcon\n");
>drm_dev_unplug(dev);
>drm_dev_put(dev);
>pci_disable_device(pdev);



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

Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue

2019-06-05 Thread Koenig, Christian
Mhm, looks like that somehow got dropped during rebase.

Going to dig up where that actually ended up tomorrow.

Christian.

Am 05.06.19 um 16:44 schrieb Liu, Monk:
> Strange, I get the latest "drm-next" branch and didn't see the change landed 
> 
>
> /Monk
>
> -Original Message-
> From: Koenig, Christian
> Sent: Wednesday, June 5, 2019 7:11 PM
> To: Liu, Monk ; amd-gfx@lists.freedesktop.org
> Subject: Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload 
> issue
>
> This should already be fixed by patch "drm/ttm: fix re-init of global 
> structures".
>
> Christian.
>
> Am 05.06.19 um 09:29 schrieb Liu, Monk:
>> -Original Message-
>> From: Monk Liu 
>> Sent: Wednesday, June 5, 2019 2:45 PM
>> To: amd-gfx@lists.freedesktop.org
>> Cc: Liu, Monk 
>> Subject: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload
>> issue
>>
>> need to clear bo glob and mem glob during their release otherwise their 
>> member value would be wrongly used in the next glob init stage and lead to 
>> wild pointer access problems:
>>
>> 1) kobj.state_initialized is 1
>> 2) ttm_bo_glob.bo_count isn't cleared and referenced via it
>>  on member "swap_lru" would hit out of bound array accessing
>>  bug
>>
>> Signed-off-by: Monk Liu 
>> ---
>>drivers/gpu/drm/ttm/ttm_bo.c | 2 ++
>>drivers/gpu/drm/ttm/ttm_memory.c | 8 
>>2 files changed, 10 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c
>> b/drivers/gpu/drm/ttm/ttm_bo.c index c7de667..6434eac 100644
>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>> @@ -1604,6 +1604,8 @@ static void ttm_bo_global_kobj_release(struct kobject 
>> *kobj)
>>  container_of(kobj, struct ttm_bo_global, kobj);
>>
>>  __free_page(glob->dummy_read_page);
>> +
>> +memset(glob, 0, sizeof(*glob));
>>}
>>
>>static void ttm_bo_global_release(void) diff --git
>> a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
>> index 8617958..7128bbf 100644
>> --- a/drivers/gpu/drm/ttm/ttm_memory.c
>> +++ b/drivers/gpu/drm/ttm/ttm_memory.c
>> @@ -229,9 +229,17 @@ static const struct sysfs_ops ttm_mem_global_ops = {
>>  .store = _mem_global_store,
>>};
>>
>> +void ttm_mem_glob_kobj_release(struct kobject *kobj) {
>> +struct ttm_mem_global *glob = container_of(kobj, struct
>> +ttm_mem_global, kobj);
>> +
>> +memset(glob, 0, sizeof(*glob));
>> +}
>> +
>>static struct kobj_type ttm_mem_glob_kobj_type = {
>>  .sysfs_ops = _mem_global_ops,
>>  .default_attrs = ttm_mem_global_attrs,
>> +.release = ttm_mem_glob_kobj_release,
>>};
>>
>>static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
>> --
>> 2.7.4
>>

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

Re: [PATCH] drm/amd/display: Use current connector state if NULL when checking bpc

2019-06-05 Thread Kazlauskas, Nicholas
On 6/5/19 1:30 PM, Deucher, Alexander wrote:
> Maybe add a reference to the bug report?
> Acked-by: Alex Deucher 

Oh right, I can add the bugzilla when this gets reviewed and I push. Thanks!

Nicholas Kazlauskas

> 
> *From:* amd-gfx  on behalf of 
> Nicholas Kazlauskas 
> *Sent:* Wednesday, June 5, 2019 12:33 PM
> *To:* amd-gfx@lists.freedesktop.org
> *Cc:* Li, Sun peng (Leo); Wentland, Harry; Kazlauskas, Nicholas
> *Subject:* [PATCH] drm/amd/display: Use current connector state if NULL 
> when checking bpc
> [Why]
> The old logic for checking which output depth to use relied on using
> the current connector state rather than the new proposed state. This
> was a problem when performing atomic commits since we weren't verifying
> it against the incoming max_requested_bpc.
> 
> But switching this to only use the new state and not the current state
> breaks filtering modes - it'll always assume that the maximum bpc
> supported by the display is in use, which will cause certain modes
> like 1440p@144Hz to be filtered even when using 8bpc.
> 
> [How]
> Still use the connector->state if we aren't passed an explicit state.
> This will respect the max_bpc the user currently has when filtering
> modes.
> 
> Also remember to reset the default max_requested_bpc to 8 whenever
> connector reset is called to retain old behavior when using the new
> property.
> 
> Cc: Harry Wentland 
> Cc: Leo Li 
> Signed-off-by: Nicholas Kazlauskas 
> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 
>   1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index a698c8f272ed..f627c17a1039 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -3046,6 +3046,9 @@ convert_color_depth_from_display_info(const struct 
> drm_connector *connector,
>   {
>   uint32_t bpc = connector->display_info.bpc;
> 
> +   if (!state)
> +   state = connector->state;
> +
>   if (state) {
>   bpc = state->max_bpc;
>   /* Round down to the nearest even number. */
> @@ -3820,6 +3823,7 @@ void amdgpu_dm_connector_funcs_reset(struct 
> drm_connector *connector)
>   state->underscan_enable = false;
>   state->underscan_hborder = 0;
>   state->underscan_vborder = 0;
> +   state->base.max_requested_bpc = 8;
> 
>   __drm_atomic_helper_connector_reset(connector, 
> >base);
>   }
> -- 
> 2.17.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

Re: [PATCH] drm/ttm: fix ttm_bo_unreserve

2019-06-05 Thread Koenig, Christian
Am 05.06.19 um 16:33 schrieb Kuehling, Felix:
> On 2019-06-05 9:56, Michel Dänzer wrote:
>> On 2019-06-05 1:24 p.m., Christian König wrote:
>>> Am 04.06.19 um 21:03 schrieb Zeng, Oak:
 From: amd-gfx  On Behalf Of
 Kuehling, Felix
 On 2019-06-04 11:23, Christian König wrote:
> [snip]
 --- a/include/drm/ttm/ttm_bo_driver.h
 +++ b/include/drm/ttm/ttm_bo_driver.h
 @@ -767,14 +767,12 @@ static inline int
 ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
       */
      static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
      {
 -    if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
 -    spin_lock(>bdev->glob->lru_lock);
 -    if (list_empty(>lru))
 -    ttm_bo_add_to_lru(bo);
 -    else
 -    ttm_bo_move_to_lru_tail(bo, NULL);
 -    spin_unlock(>bdev->glob->lru_lock);
 -    }
 +    spin_lock(>bdev->glob->lru_lock);
 +    if (list_empty(>lru))
 +    ttm_bo_add_to_lru(bo);
 +    else
 +    ttm_bo_move_to_lru_tail(bo, NULL);
 Going just by the function names, this seems to do the exact opposite
 of what the change description says.

 [Oak] +1, when I read the description, I also get lost...So please do
 add a more accurate description.
>>> I'm puzzled why you are confused. We now keep the BOs on the LRU while
>>> they are reserved, so on unreserve we now need to explicitly remove them
>>> from the LRU when they are pinned.
>> I don't know about Felix and Oak, but for me "remove from the LRU" is
>> confusing, as I don't see that in the code, only adding to the LRU or
>> moving to its tail.
> Exactly. The names of the functions being called imply that something
> gets added or moved on the LRU list. You have to go look at the
> implementation of those functions to find out that they do something
> else for pinned BOs (that have TTM_PL_FLAG_NO_EVICT set in their
> placement flags).
>
> Fixing the function names would probably be overkill:
> ttm_bo_add_lru_unless_pinned and
> ttm_bo_move_to_lru_tail_or_remove_if_pinned. But maybe a comment in
> ttm_bo_unreserve would help.

Ah! Yes of course, I thought you mean the ttm_bo_unreserve function name.

Going to add a comment when we start to rename the functions.

Christian.

>
> Regards,
>     Felix
>
>
>>

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

Re: [PATCH] drm/amd/display: Use current connector state if NULL when checking bpc

2019-06-05 Thread Deucher, Alexander
Maybe add a reference to the bug report?
Acked-by: Alex Deucher 

From: amd-gfx  on behalf of Nicholas 
Kazlauskas 
Sent: Wednesday, June 5, 2019 12:33 PM
To: amd-gfx@lists.freedesktop.org
Cc: Li, Sun peng (Leo); Wentland, Harry; Kazlauskas, Nicholas
Subject: [PATCH] drm/amd/display: Use current connector state if NULL when 
checking bpc

[Why]
The old logic for checking which output depth to use relied on using
the current connector state rather than the new proposed state. This
was a problem when performing atomic commits since we weren't verifying
it against the incoming max_requested_bpc.

But switching this to only use the new state and not the current state
breaks filtering modes - it'll always assume that the maximum bpc
supported by the display is in use, which will cause certain modes
like 1440p@144Hz to be filtered even when using 8bpc.

[How]
Still use the connector->state if we aren't passed an explicit state.
This will respect the max_bpc the user currently has when filtering
modes.

Also remember to reset the default max_requested_bpc to 8 whenever
connector reset is called to retain old behavior when using the new
property.

Cc: Harry Wentland 
Cc: Leo Li 
Signed-off-by: Nicholas Kazlauskas 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a698c8f272ed..f627c17a1039 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3046,6 +3046,9 @@ convert_color_depth_from_display_info(const struct 
drm_connector *connector,
 {
 uint32_t bpc = connector->display_info.bpc;

+   if (!state)
+   state = connector->state;
+
 if (state) {
 bpc = state->max_bpc;
 /* Round down to the nearest even number. */
@@ -3820,6 +3823,7 @@ void amdgpu_dm_connector_funcs_reset(struct drm_connector 
*connector)
 state->underscan_enable = false;
 state->underscan_hborder = 0;
 state->underscan_vborder = 0;
+   state->base.max_requested_bpc = 8;

 __drm_atomic_helper_connector_reset(connector, >base);
 }
--
2.17.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] drm/amd/display: Use current connector state if NULL when checking bpc

2019-06-05 Thread Nicholas Kazlauskas
[Why]
The old logic for checking which output depth to use relied on using
the current connector state rather than the new proposed state. This
was a problem when performing atomic commits since we weren't verifying
it against the incoming max_requested_bpc.

But switching this to only use the new state and not the current state
breaks filtering modes - it'll always assume that the maximum bpc
supported by the display is in use, which will cause certain modes
like 1440p@144Hz to be filtered even when using 8bpc.

[How]
Still use the connector->state if we aren't passed an explicit state.
This will respect the max_bpc the user currently has when filtering
modes.

Also remember to reset the default max_requested_bpc to 8 whenever
connector reset is called to retain old behavior when using the new
property.

Cc: Harry Wentland 
Cc: Leo Li 
Signed-off-by: Nicholas Kazlauskas 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a698c8f272ed..f627c17a1039 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3046,6 +3046,9 @@ convert_color_depth_from_display_info(const struct 
drm_connector *connector,
 {
uint32_t bpc = connector->display_info.bpc;
 
+   if (!state)
+   state = connector->state;
+
if (state) {
bpc = state->max_bpc;
/* Round down to the nearest even number. */
@@ -3820,6 +3823,7 @@ void amdgpu_dm_connector_funcs_reset(struct drm_connector 
*connector)
state->underscan_enable = false;
state->underscan_hborder = 0;
state->underscan_vborder = 0;
+   state->base.max_requested_bpc = 8;
 
__drm_atomic_helper_connector_reset(connector, >base);
}
-- 
2.17.1

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

RE: [PATCH 1/6] drm/amdkfd: Only initialize sdma vm for sdma queues

2019-06-05 Thread Zeng, Oak
Hi Felix,

I rebased this series to the latest drm-next code base.

Regards,
Oak

-Original Message-
From: Zeng, Oak  
Sent: Wednesday, June 5, 2019 12:07 PM
To: amd-gfx@lists.freedesktop.org
Cc: Kuehling, Felix ; Zhao, Yong ; 
Liu, Alex ; Freehill, Chris ; Zeng, 
Oak 
Subject: [PATCH 1/6] drm/amdkfd: Only initialize sdma vm for sdma queues

Don't do the same for compute queues

Change-Id: Id5f743ca10c2b761590bfe18cab2f802d3c04d2d
Signed-off-by: Oak Zeng 
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index c18355d..00ca3dd 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -1209,8 +1209,9 @@ static int create_queue_cpsch(struct device_queue_manager 
*dqm, struct queue *q,
 * updates the is_evicted flag but is a no-op otherwise.
 */
q->properties.is_evicted = !!qpd->evicted;
-
-   dqm->asic_ops.init_sdma_vm(dqm, q, qpd);
+   if (q->properties.type == KFD_QUEUE_TYPE_SDMA ||
+   q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI)
+   dqm->asic_ops.init_sdma_vm(dqm, q, qpd);
q->properties.tba_addr = qpd->tba_addr;
q->properties.tma_addr = qpd->tma_addr;
retval = mqd_mgr->init_mqd(mqd_mgr, >mqd, >mqd_mem_obj,
-- 
2.7.4

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

[PATCH 4/6] drm/amdkfd: Separate mqd allocation and initialization

2019-06-05 Thread Zeng, Oak
Introduce a new mqd allocation interface and split the original
init_mqd function into two functions: allocate_mqd and init_mqd.
This is preparation work to fix a circular lock dependency.

Change-Id: I26e53ee1abcdd688ad11d35b433da77e3fa1bee7
Signed-off-by: Oak Zeng 
---
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 16 ---
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c  |  8 +-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c   |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h   |  8 --
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c   | 31 --
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c| 31 --
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c| 31 --
 7 files changed, 59 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 3c042eb..787b5be 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -319,10 +319,13 @@ static int create_queue_nocpsch(struct 
device_queue_manager *dqm,
if (retval)
goto out_deallocate_hqd;
 
-   retval = mqd_mgr->init_mqd(mqd_mgr, >mqd, >mqd_mem_obj,
+   q->mqd_mem_obj = mqd_mgr->allocate_mqd(mqd_mgr->dev, >properties);
+   if (!q->mqd_mem_obj)
+   goto out_deallocate_doorbell;
+   retval = mqd_mgr->init_mqd(mqd_mgr, >mqd, q->mqd_mem_obj,
>gart_mqd_addr, >properties);
if (retval)
-   goto out_deallocate_doorbell;
+   goto out_uninit_mqd;
 
if (q->properties.is_active) {
 
@@ -1160,10 +1163,13 @@ static int create_queue_cpsch(struct 
device_queue_manager *dqm, struct queue *q,
dqm->asic_ops.init_sdma_vm(dqm, q, qpd);
q->properties.tba_addr = qpd->tba_addr;
q->properties.tma_addr = qpd->tma_addr;
-   retval = mqd_mgr->init_mqd(mqd_mgr, >mqd, >mqd_mem_obj,
+   q->mqd_mem_obj = mqd_mgr->allocate_mqd(mqd_mgr->dev, >properties);
+   if (!q->mqd_mem_obj)
+   goto out_deallocate_doorbell;
+   retval = mqd_mgr->init_mqd(mqd_mgr, >mqd, q->mqd_mem_obj,
>gart_mqd_addr, >properties);
if (retval)
-   goto out_deallocate_doorbell;
+   goto out_deallocate_mqd;
 
dqm_lock(dqm);
 
@@ -1191,6 +1197,8 @@ static int create_queue_cpsch(struct device_queue_manager 
*dqm, struct queue *q,
dqm_unlock(dqm);
return retval;
 
+out_deallocate_mqd:
+   mqd_mgr->uninit_mqd(mqd_mgr, q->mqd, q->mqd_mem_obj);
 out_deallocate_doorbell:
deallocate_doorbell(qpd, q);
 out_deallocate_sdma_queue:
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
index 1cc03b3..64c8ffe 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
@@ -132,8 +132,12 @@ static bool initialize(struct kernel_queue *kq, struct 
kfd_dev *dev,
kq->queue->device = dev;
kq->queue->process = kfd_get_process(current);
 
+   kq->queue->mqd_mem_obj = kq->mqd_mgr->allocate_mqd(kq->mqd_mgr->dev,
+   >queue->properties);
+   if (!kq->queue->mqd_mem_obj)
+   goto err_allocate_mqd;
retval = kq->mqd_mgr->init_mqd(kq->mqd_mgr, >queue->mqd,
-   >queue->mqd_mem_obj,
+   kq->queue->mqd_mem_obj,
>queue->gart_mqd_addr,
>queue->properties);
if (retval != 0)
@@ -165,6 +169,8 @@ static bool initialize(struct kernel_queue *kq, struct 
kfd_dev *dev,
return true;
 err_alloc_fence:
 err_init_mqd:
+   kq->mqd_mgr->uninit_mqd(kq->mqd_mgr, kq->queue->mqd, 
kq->queue->mqd_mem_obj);
+err_allocate_mqd:
uninit_queue(kq->queue);
 err_init_queue:
kfd_gtt_sa_free(dev, kq->wptr_mem);
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
index cc04b362..b4f305a 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
@@ -45,7 +45,7 @@ int pipe_priority_map[] = {
KFD_PIPE_PRIORITY_CS_HIGH
 };
 
-struct kfd_mem_obj *allocate_hiq_mqd(struct kfd_dev *dev)
+struct kfd_mem_obj *allocate_hiq_mqd(struct kfd_dev *dev, struct 
queue_properties *q)
 {
struct kfd_mem_obj *mqd_mem_obj = NULL;
 
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h 
b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h
index 66b8c67..8667990 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h
@@ -64,8 +64,11 @@
  */
 extern int pipe_priority_map[];
 struct mqd_manager {
+   struct kfd_mem_obj* 

[PATCH 5/6] drm/amdkfd: Fix a circular lock dependency

2019-06-05 Thread Zeng, Oak
The idea to break the circular lock dependency is to move allocate_mqd
out of dqm lock protection. See callstack #1 below.

[   59.510149] [drm] Initialized amdgpu 3.30.0 20150101 for :04:00.0 on 
minor 0

[  513.604034] ==
[  513.604205] WARNING: possible circular locking dependency detected
[  513.604375] 4.18.0-kfd-root #2 Tainted: GW
[  513.604530] --
[  513.604699] kswapd0/611 is trying to acquire lock:
[  513.604840] d254022e (>lock_hidden){+.+.}, at: 
evict_process_queues_nocpsch+0x26/0x140 [amdgpu]
[  513.605150]
   but task is already holding lock:
[  513.605307] 961547fc (_vma->rwsem){}, at: 
page_lock_anon_vma_read+0xe4/0x250
[  513.605540]
   which lock already depends on the new lock.

[  513.605747]
   the existing dependency chain (in reverse order) is:
[  513.605944]
   -> #4 (_vma->rwsem){}:
[  513.606106]__vma_adjust+0x147/0x7f0
[  513.606231]__split_vma+0x179/0x190
[  513.606353]mprotect_fixup+0x217/0x260
[  513.606553]do_mprotect_pkey+0x211/0x380
[  513.606752]__x64_sys_mprotect+0x1b/0x20
[  513.606954]do_syscall_64+0x50/0x1a0
[  513.607149]entry_SYSCALL_64_after_hwframe+0x49/0xbe
[  513.607380]
   -> #3 (>i_mmap_rwsem){}:
[  513.607678]rmap_walk_file+0x1f0/0x280
[  513.607887]page_referenced+0xdd/0x180
[  513.608081]shrink_page_list+0x853/0xcb0
[  513.608279]shrink_inactive_list+0x33b/0x700
[  513.608483]shrink_node_memcg+0x37a/0x7f0
[  513.608682]shrink_node+0xd8/0x490
[  513.608869]balance_pgdat+0x18b/0x3b0
[  513.609062]kswapd+0x203/0x5c0
[  513.609241]kthread+0x100/0x140
[  513.609420]ret_from_fork+0x24/0x30
[  513.609607]
   -> #2 (fs_reclaim){+.+.}:
[  513.609883]kmem_cache_alloc_trace+0x34/0x2e0
[  513.610093]reservation_object_reserve_shared+0x139/0x300
[  513.610326]ttm_bo_init_reserved+0x291/0x480 [ttm]
[  513.610567]amdgpu_bo_do_create+0x1d2/0x650 [amdgpu]
[  513.610811]amdgpu_bo_create+0x40/0x1f0 [amdgpu]
[  513.611041]amdgpu_bo_create_reserved+0x249/0x2d0 [amdgpu]
[  513.611290]amdgpu_bo_create_kernel+0x12/0x70 [amdgpu]
[  513.611584]amdgpu_ttm_init+0x2cb/0x560 [amdgpu]
[  513.611823]gmc_v9_0_sw_init+0x400/0x750 [amdgpu]
[  513.612491]amdgpu_device_init+0x14eb/0x1990 [amdgpu]
[  513.612730]amdgpu_driver_load_kms+0x78/0x290 [amdgpu]
[  513.612958]drm_dev_register+0x111/0x1a0
[  513.613171]amdgpu_pci_probe+0x11c/0x1e0 [amdgpu]
[  513.613389]local_pci_probe+0x3f/0x90
[  513.613581]pci_device_probe+0x102/0x1c0
[  513.613779]driver_probe_device+0x2a7/0x480
[  513.613984]__driver_attach+0x10a/0x110
[  513.614179]bus_for_each_dev+0x67/0xc0
[  513.614372]bus_add_driver+0x1eb/0x260
[  513.614565]driver_register+0x5b/0xe0
[  513.614756]do_one_initcall+0xac/0x357
[  513.614952]do_init_module+0x5b/0x213
[  513.615145]load_module+0x2542/0x2d30
[  513.615337]__do_sys_finit_module+0xd2/0x100
[  513.615541]do_syscall_64+0x50/0x1a0
[  513.615731]entry_SYSCALL_64_after_hwframe+0x49/0xbe
[  513.615963]
   -> #1 (reservation_ww_class_mutex){+.+.}:
[  513.616293]amdgpu_amdkfd_alloc_gtt_mem+0xcf/0x2c0 [amdgpu]
[  513.616554]init_mqd+0x223/0x260 [amdgpu]
[  513.616779]create_queue_nocpsch+0x4d9/0x600 [amdgpu]
[  513.617031]pqm_create_queue+0x37c/0x520 [amdgpu]
[  513.617270]kfd_ioctl_create_queue+0x2f9/0x650 [amdgpu]
[  513.617522]kfd_ioctl+0x202/0x350 [amdgpu]
[  513.617724]do_vfs_ioctl+0x9f/0x6c0
[  513.617914]ksys_ioctl+0x66/0x70
[  513.618095]__x64_sys_ioctl+0x16/0x20
[  513.618286]do_syscall_64+0x50/0x1a0
[  513.618476]entry_SYSCALL_64_after_hwframe+0x49/0xbe
[  513.618695]
   -> #0 (>lock_hidden){+.+.}:
[  513.618984]__mutex_lock+0x98/0x970
[  513.619197]evict_process_queues_nocpsch+0x26/0x140 [amdgpu]
[  513.619459]kfd_process_evict_queues+0x3b/0xb0 [amdgpu]
[  513.619710]kgd2kfd_quiesce_mm+0x1c/0x40 [amdgpu]
[  513.620103]amdgpu_amdkfd_evict_userptr+0x38/0x70 [amdgpu]
[  513.620363]amdgpu_mn_invalidate_range_start_hsa+0xa6/0xc0 [amdgpu]
[  513.620614]__mmu_notifier_invalidate_range_start+0x70/0xb0
[  513.620851]try_to_unmap_one+0x7fc/0x8f0
[  513.621049]rmap_walk_anon+0x121/0x290
[  513.621242]try_to_unmap+0x93/0xf0
[  513.621428]shrink_page_list+0x606/0xcb0
[  513.621625]shrink_inactive_list+0x33b/0x700
[  513.621835]shrink_node_memcg+0x37a/0x7f0
[  513.622034]shrink_node+0xd8/0x490
[  513.622219]

[PATCH 2/6] drm/amdkfd: Only load sdma mqd when queue is active

2019-06-05 Thread Zeng, Oak
Also calls load_mqd with current->mm struct. The mm
struct is used to read back user wptr of the queue.

Change-Id: I0f6d085878358dcd3a413054dbe61d1ca0fdf66d
Signed-off-by: Oak Zeng 
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 00ca3dd..dab6ef4 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -995,8 +995,11 @@ static int create_sdma_queue_nocpsch(struct 
device_queue_manager *dqm,
if (retval)
goto out_deallocate_doorbell;
 
+   if (!q->properties.is_active)
+   return 0;
+
retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, 0, 0, >properties,
-   NULL);
+   current->mm);
if (retval)
goto out_uninit_mqd;
 
-- 
2.7.4

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

[PATCH 6/6] drm/amdkfd: Fix sdma queue allocate race condition

2019-06-05 Thread Zeng, Oak
SDMA queue allocation requires the dqm lock as it modify
the global dqm members. Introduce functions to allocate/deallocate
in locked/unlocked circumstance.

Change-Id: Id3084524c5f65d9629b12cf6b4862a7516945cb1
Signed-off-by: Oak Zeng 
---
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 34 --
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 6b1a2ee..52e4ede 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -53,6 +53,8 @@ static int map_queues_cpsch(struct device_queue_manager *dqm);
 
 static void deallocate_sdma_queue(struct device_queue_manager *dqm,
struct queue *q);
+static void deallocate_sdma_queue_locked(struct device_queue_manager *dqm,
+   struct queue *q);
 
 static inline void deallocate_hqd(struct device_queue_manager *dqm,
struct queue *q);
@@ -434,10 +436,10 @@ static int destroy_queue_nocpsch_locked(struct 
device_queue_manager *dqm,
deallocate_hqd(dqm, q);
} else if (q->properties.type == KFD_QUEUE_TYPE_SDMA) {
dqm->sdma_queue_count--;
-   deallocate_sdma_queue(dqm, q);
+   deallocate_sdma_queue_locked(dqm, q);
} else if (q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) {
dqm->xgmi_sdma_queue_count--;
-   deallocate_sdma_queue(dqm, q);
+   deallocate_sdma_queue_locked(dqm, q);
} else {
pr_debug("q->properties.type %d is invalid\n",
q->properties.type);
@@ -914,9 +916,12 @@ static int allocate_sdma_queue(struct device_queue_manager 
*dqm,
 {
int bit;
 
+   dqm_lock(dqm);
if (q->properties.type == KFD_QUEUE_TYPE_SDMA) {
-   if (dqm->sdma_bitmap == 0)
+   if (dqm->sdma_bitmap == 0) {
+   dqm_unlock(dqm);
return -ENOMEM;
+   }
bit = __ffs64(dqm->sdma_bitmap);
dqm->sdma_bitmap &= ~(1ULL << bit);
q->sdma_id = bit;
@@ -925,8 +930,10 @@ static int allocate_sdma_queue(struct device_queue_manager 
*dqm,
q->properties.sdma_queue_id = q->sdma_id /
get_num_sdma_engines(dqm);
} else if (q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) {
-   if (dqm->xgmi_sdma_bitmap == 0)
+   if (dqm->xgmi_sdma_bitmap == 0) {
+   dqm_unlock(dqm);
return -ENOMEM;
+   }
bit = __ffs64(dqm->xgmi_sdma_bitmap);
dqm->xgmi_sdma_bitmap &= ~(1ULL << bit);
q->sdma_id = bit;
@@ -942,13 +949,14 @@ static int allocate_sdma_queue(struct 
device_queue_manager *dqm,
get_num_xgmi_sdma_engines(dqm);
}
 
+   dqm_unlock(dqm);
pr_debug("SDMA engine id: %d\n", q->properties.sdma_engine_id);
pr_debug("SDMA queue id: %d\n", q->properties.sdma_queue_id);
 
return 0;
 }
 
-static void deallocate_sdma_queue(struct device_queue_manager *dqm,
+static void deallocate_sdma_queue_locked(struct device_queue_manager *dqm,
struct queue *q)
 {
if (q->properties.type == KFD_QUEUE_TYPE_SDMA) {
@@ -962,6 +970,14 @@ static void deallocate_sdma_queue(struct 
device_queue_manager *dqm,
}
 }
 
+static void deallocate_sdma_queue(struct device_queue_manager *dqm,
+   struct queue *q)
+{
+   dqm_lock(dqm);
+   deallocate_sdma_queue_locked(dqm, q);
+   dqm_unlock(dqm);
+}
+
 /*
  * Device Queue Manager implementation for cp scheduler
  */
@@ -1356,10 +1372,10 @@ static int destroy_queue_cpsch(struct 
device_queue_manager *dqm,
 
if (q->properties.type == KFD_QUEUE_TYPE_SDMA) {
dqm->sdma_queue_count--;
-   deallocate_sdma_queue(dqm, q);
+   deallocate_sdma_queue_locked(dqm, q);
} else if (q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) {
dqm->xgmi_sdma_queue_count--;
-   deallocate_sdma_queue(dqm, q);
+   deallocate_sdma_queue_locked(dqm, q);
}
 
list_del(>list);
@@ -1585,10 +1601,10 @@ static int process_termination_cpsch(struct 
device_queue_manager *dqm,
list_for_each_entry(q, >queues_list, list) {
if (q->properties.type == KFD_QUEUE_TYPE_SDMA) {
dqm->sdma_queue_count--;
-   deallocate_sdma_queue(dqm, q);
+   deallocate_sdma_queue_locked(dqm, q);
} else if (q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) {
dqm->xgmi_sdma_queue_count--;
-   

[PATCH 3/6] drm/amdkfd: Refactor create_queue_nocpsch

2019-06-05 Thread Zeng, Oak
This is prepare work to fix a circular lock dependency.
No logic change

Change-Id: I4e0ee918260e7780de972dd71f4ce787b4f6dde9
Signed-off-by: Oak Zeng 
---
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 171 +++--
 1 file changed, 57 insertions(+), 114 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index dab6ef4..3c042eb 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -42,10 +42,6 @@
 static int set_pasid_vmid_mapping(struct device_queue_manager *dqm,
unsigned int pasid, unsigned int vmid);
 
-static int create_compute_queue_nocpsch(struct device_queue_manager *dqm,
-   struct queue *q,
-   struct qcm_process_device *qpd);
-
 static int execute_queues_cpsch(struct device_queue_manager *dqm,
enum kfd_unmap_queues_filter filter,
uint32_t filter_param);
@@ -55,13 +51,14 @@ static int unmap_queues_cpsch(struct device_queue_manager 
*dqm,
 
 static int map_queues_cpsch(struct device_queue_manager *dqm);
 
-static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,
-   struct queue *q,
-   struct qcm_process_device *qpd);
-
 static void deallocate_sdma_queue(struct device_queue_manager *dqm,
struct queue *q);
 
+static inline void deallocate_hqd(struct device_queue_manager *dqm,
+   struct queue *q);
+static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q);
+static int allocate_sdma_queue(struct device_queue_manager *dqm,
+   struct queue *q);
 static void kfd_process_hw_exception(struct work_struct *work);
 
 static inline
@@ -223,6 +220,9 @@ static int allocate_vmid(struct device_queue_manager *dqm,
/* invalidate the VM context after pasid and vmid mapping is set up */
kfd_flush_tlb(qpd_to_pdd(qpd));
 
+   dqm->dev->kfd2kgd->set_scratch_backing_va(
+   dqm->dev->kgd, qpd->sh_hidden_private_base, qpd->vmid);
+
return 0;
 }
 
@@ -269,6 +269,7 @@ static int create_queue_nocpsch(struct device_queue_manager 
*dqm,
struct queue *q,
struct qcm_process_device *qpd)
 {
+   struct mqd_manager *mqd_mgr;
int retval;
 
print_queue(q);
@@ -298,18 +299,41 @@ static int create_queue_nocpsch(struct 
device_queue_manager *dqm,
q->properties.tba_addr = qpd->tba_addr;
q->properties.tma_addr = qpd->tma_addr;
 
-   if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE)
-   retval = create_compute_queue_nocpsch(dqm, q, qpd);
-   else if (q->properties.type == KFD_QUEUE_TYPE_SDMA ||
-   q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI)
-   retval = create_sdma_queue_nocpsch(dqm, q, qpd);
-   else
-   retval = -EINVAL;
+   mqd_mgr = dqm->mqd_mgrs[get_mqd_type_from_queue_type(
+   q->properties.type)];
+   if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE) {
+   retval = allocate_hqd(dqm, q);
+   if (retval)
+   goto deallocate_vmid;
+   pr_debug("Loading mqd to hqd on pipe %d, queue %d\n",
+   q->pipe, q->queue);
+   } else if (q->properties.type == KFD_QUEUE_TYPE_SDMA ||
+   q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) {
+   retval = allocate_sdma_queue(dqm, q);
+   if (retval)
+   goto deallocate_vmid;
+   dqm->asic_ops.init_sdma_vm(dqm, q, qpd);
+   }
 
-   if (retval) {
-   if (list_empty(>queues_list))
-   deallocate_vmid(dqm, qpd, q);
-   goto out_unlock;
+   retval = allocate_doorbell(qpd, q);
+   if (retval)
+   goto out_deallocate_hqd;
+
+   retval = mqd_mgr->init_mqd(mqd_mgr, >mqd, >mqd_mem_obj,
+   >gart_mqd_addr, >properties);
+   if (retval)
+   goto out_deallocate_doorbell;
+
+   if (q->properties.is_active) {
+
+   if (WARN(q->process->mm != current->mm,
+   "should only run in user thread"))
+   retval = -EFAULT;
+   else
+   retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe,
+   q->queue, >properties, current->mm);
+   if (retval)
+   goto out_uninit_mqd;
}
 
list_add(>list, >queues_list);
@@ -329,7 +353,21 @@ static int create_queue_nocpsch(struct 
device_queue_manager *dqm,

[PATCH 1/6] drm/amdkfd: Only initialize sdma vm for sdma queues

2019-06-05 Thread Zeng, Oak
Don't do the same for compute queues

Change-Id: Id5f743ca10c2b761590bfe18cab2f802d3c04d2d
Signed-off-by: Oak Zeng 
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index c18355d..00ca3dd 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -1209,8 +1209,9 @@ static int create_queue_cpsch(struct device_queue_manager 
*dqm, struct queue *q,
 * updates the is_evicted flag but is a no-op otherwise.
 */
q->properties.is_evicted = !!qpd->evicted;
-
-   dqm->asic_ops.init_sdma_vm(dqm, q, qpd);
+   if (q->properties.type == KFD_QUEUE_TYPE_SDMA ||
+   q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI)
+   dqm->asic_ops.init_sdma_vm(dqm, q, qpd);
q->properties.tba_addr = qpd->tba_addr;
q->properties.tma_addr = qpd->tma_addr;
retval = mqd_mgr->init_mqd(mqd_mgr, >mqd, >mqd_mem_obj,
-- 
2.7.4

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

RE: [PATCH] drm/amdgpu: register pm sysfs for sriov

2019-06-05 Thread Tao, Yintian
Hi  Alex

Can you help have a review? Thanks in advance.


Best Regards
Yintian Tao

-Original Message-
From: amd-gfx  On Behalf Of Yintian Tao
Sent: Wednesday, June 05, 2019 10:09 PM
To: amd-gfx@lists.freedesktop.org; Deucher, Alexander 

Cc: Tao, Yintian 
Subject: [PATCH] drm/amdgpu: register pm sysfs for sriov

we need register pm sysfs for virt in order to support dpm level modification 
because smu ip block will not be added under SRIOV

Signed-off-by: Yintian Tao 
Change-Id: Ib0e13934c0c33da00f9d2add6be25a373c6fb957
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  6 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 61 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h |  2 +
 3 files changed, 65 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d00fd5d..9b9d387 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2695,6 +2695,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 
amdgpu_fbdev_init(adev);
 
+   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev))
+   amdgpu_virt_pm_sysfs_init(adev);
+
r = amdgpu_pm_sysfs_init(adev);
if (r)
DRM_ERROR("registering pm debugfs failed (%d).\n", r); @@ 
-2816,6 +2819,9 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
iounmap(adev->rmmio);
adev->rmmio = NULL;
amdgpu_device_doorbell_fini(adev);
+   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev))
+   amdgpu_virt_pm_sysfs_fini(adev);
+
amdgpu_debugfs_regs_cleanup(adev);
device_remove_file(adev->dev, _attr_pcie_replay_count);
amdgpu_ucode_sysfs_fini(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index a73e190..93e5205 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -269,8 +269,11 @@ static ssize_t 
amdgpu_get_dpm_forced_performance_level(struct device *dev,
struct amdgpu_device *adev = ddev->dev_private;
enum amd_dpm_forced_level level = 0xff;
 
-   if  ((adev->flags & AMD_IS_PX) &&
-(ddev->switch_power_state != DRM_SWITCH_POWER_ON))
+   if (amdgpu_sriov_vf(adev))
+   return 0;
+
+   if ((adev->flags & AMD_IS_PX) &&
+   (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
return snprintf(buf, PAGE_SIZE, "off\n");
 
if (is_support_sw_smu(adev))
@@ -308,9 +311,11 @@ static ssize_t 
amdgpu_set_dpm_forced_performance_level(struct device *dev,
 (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
return -EINVAL;
 
-   if (is_support_sw_smu(adev))
+   if (!amdgpu_sriov_vf(adev) && is_support_sw_smu(adev))
current_level = smu_get_performance_level(>smu);
-   else if (adev->powerplay.pp_funcs->get_performance_level)
+   else if (!amdgpu_sriov_vf(adev) &&
+adev->powerplay.pp_funcs &&
+adev->powerplay.pp_funcs->get_performance_level)
current_level = amdgpu_dpm_get_performance_level(adev);
 
if (strncmp("low", buf, strlen("low")) == 0) { @@ -885,6 +890,9 @@ 
static ssize_t amdgpu_set_pp_dpm_sclk(struct device *dev,
int ret;
uint32_t mask = 0;
 
+   if (amdgpu_sriov_vf(adev))
+   return 0;
+
ret = amdgpu_read_mask(buf, count, );
if (ret)
return ret;
@@ -907,6 +915,10 @@ static ssize_t amdgpu_get_pp_dpm_mclk(struct device *dev,
struct drm_device *ddev = dev_get_drvdata(dev);
struct amdgpu_device *adev = ddev->dev_private;
 
+   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev) &&
+   adev->virt.ops->get_pp_clk)
+   return adev->virt.ops->get_pp_clk(adev,PP_MCLK,buf);
+
if (is_support_sw_smu(adev))
return smu_print_clk_levels(>smu, PP_MCLK, buf);
else if (adev->powerplay.pp_funcs->print_clock_levels)
@@ -925,6 +937,9 @@ static ssize_t amdgpu_set_pp_dpm_mclk(struct device *dev,
int ret;
uint32_t mask = 0;
 
+   if (amdgpu_sriov_vf(adev))
+   return 0;
+
ret = amdgpu_read_mask(buf, count, );
if (ret)
return ret;
@@ -2698,6 +2713,44 @@ void amdgpu_pm_print_power_states(struct amdgpu_device 
*adev)
 
 }
 
+int amdgpu_virt_pm_sysfs_init(struct amdgpu_device *adev) {
+   int ret = 0;
+
+   if (!(amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev)))
+   return ret;
+
+   ret = device_create_file(adev->dev, _attr_pp_dpm_sclk);
+   if (ret) {
+   DRM_ERROR("failed to create device file pp_dpm_sclk\n");
+   return ret;
+   }
+
+   ret = device_create_file(adev->dev, _attr_pp_dpm_mclk);
+   if (ret) {
+   DRM_ERROR("failed to create device file pp_dpm_mclk\n");
+  

RE: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue

2019-06-05 Thread Liu, Monk
Strange, I get the latest "drm-next" branch and didn't see the change landed 


/Monk

-Original Message-
From: Koenig, Christian 
Sent: Wednesday, June 5, 2019 7:11 PM
To: Liu, Monk ; amd-gfx@lists.freedesktop.org
Subject: Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload 
issue

This should already be fixed by patch "drm/ttm: fix re-init of global 
structures".

Christian.

Am 05.06.19 um 09:29 schrieb Liu, Monk:
>
> -Original Message-
> From: Monk Liu 
> Sent: Wednesday, June 5, 2019 2:45 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Liu, Monk 
> Subject: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload 
> issue
>
> need to clear bo glob and mem glob during their release otherwise their 
> member value would be wrongly used in the next glob init stage and lead to 
> wild pointer access problems:
>
> 1) kobj.state_initialized is 1
> 2) ttm_bo_glob.bo_count isn't cleared and referenced via it
> on member "swap_lru" would hit out of bound array accessing
> bug
>
> Signed-off-by: Monk Liu 
> ---
>   drivers/gpu/drm/ttm/ttm_bo.c | 2 ++
>   drivers/gpu/drm/ttm/ttm_memory.c | 8 
>   2 files changed, 10 insertions(+)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c 
> b/drivers/gpu/drm/ttm/ttm_bo.c index c7de667..6434eac 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1604,6 +1604,8 @@ static void ttm_bo_global_kobj_release(struct kobject 
> *kobj)
>   container_of(kobj, struct ttm_bo_global, kobj);
>   
>   __free_page(glob->dummy_read_page);
> +
> + memset(glob, 0, sizeof(*glob));
>   }
>   
>   static void ttm_bo_global_release(void) diff --git 
> a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
> index 8617958..7128bbf 100644
> --- a/drivers/gpu/drm/ttm/ttm_memory.c
> +++ b/drivers/gpu/drm/ttm/ttm_memory.c
> @@ -229,9 +229,17 @@ static const struct sysfs_ops ttm_mem_global_ops = {
>   .store = _mem_global_store,
>   };
>   
> +void ttm_mem_glob_kobj_release(struct kobject *kobj) {
> + struct ttm_mem_global *glob = container_of(kobj, struct 
> +ttm_mem_global, kobj);
> +
> + memset(glob, 0, sizeof(*glob));
> +}
> +
>   static struct kobj_type ttm_mem_glob_kobj_type = {
>   .sysfs_ops = _mem_global_ops,
>   .default_attrs = ttm_mem_global_attrs,
> + .release = ttm_mem_glob_kobj_release,
>   };
>   
>   static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
> --
> 2.7.4
>

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

RE: [PATCH] drm/ttm: fix ttm_bo_unreserve

2019-06-05 Thread Zeng, Oak


Regards,
Oak

-Original Message-
From: Christian König  
Sent: Wednesday, June 5, 2019 7:25 AM
To: Zeng, Oak ; Kuehling, Felix ; 
dri-de...@lists.freedesktop.org; amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/ttm: fix ttm_bo_unreserve

Am 04.06.19 um 21:03 schrieb Zeng, Oak:
>
> Regards,
> Oak
>
> -Original Message-
> From: amd-gfx  On Behalf Of 
> Kuehling, Felix
> Sent: Tuesday, June 4, 2019 2:47 PM
> To: Christian König ; 
> dri-de...@lists.freedesktop.org; amd-gfx@lists.freedesktop.org
> Subject: Re: [PATCH] drm/ttm: fix ttm_bo_unreserve
>
> On 2019-06-04 11:23, Christian König wrote:
>
>> Since we now keep BOs on the LRU we need to make sure that they are 
>> removed when they are pinned.
>>
>> Signed-off-by: Christian König 
>> ---
>>include/drm/ttm/ttm_bo_driver.h | 14 ++
>>1 file changed, 6 insertions(+), 8 deletions(-)
>>
>> diff --git a/include/drm/ttm/ttm_bo_driver.h 
>> b/include/drm/ttm/ttm_bo_driver.h index 9f54cf9c60df..c9b8ba492f24
>> 100644
>> --- a/include/drm/ttm/ttm_bo_driver.h
>> +++ b/include/drm/ttm/ttm_bo_driver.h
>> @@ -767,14 +767,12 @@ static inline int ttm_bo_reserve_slowpath(struct 
>> ttm_buffer_object *bo,
>> */
>>static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
>>{
>> -if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
>> -spin_lock(>bdev->glob->lru_lock);
>> -if (list_empty(>lru))
>> -ttm_bo_add_to_lru(bo);
>> -else
>> -ttm_bo_move_to_lru_tail(bo, NULL);
>> -spin_unlock(>bdev->glob->lru_lock);
>> -}
>> +spin_lock(>bdev->glob->lru_lock);
>> +if (list_empty(>lru))
>> +ttm_bo_add_to_lru(bo);
>> +else
>> +ttm_bo_move_to_lru_tail(bo, NULL);
> Going just by the function names, this seems to do the exact opposite of what 
> the change description says.
>
> [Oak] +1, when I read the description, I also get lost...So please do add a 
> more accurate description.

I'm puzzled why you are confused. We now keep the BOs on the LRU while they are 
reserved, so on unreserve we now need to explicitly remove them from the LRU 
when they are pinned.

[Oak] When I read the description, I though you meant to remove bo from LRU on 
a pin action, but from codes, it is done on unreserve. In other words, it is 
better to say "if it is pinned" than  "when it is pinned". Sorry being 
pickyAlso from codes before your change, there was a condition 
"!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)". Is this condition to check 
whether bo is no pinned? How do you check whether bo is pinned in the new 
codes? To me condition " list_empty(>lru)" only means this bo is currently 
not on LRU list, I am not sure whether this also means it is not pinned. Also, 
can ttm_bo_move_to_lru_tail be replaced with ttm_bo_del_from_lru - from your 
description, this is more like a function to remove it from LRU. Sorry too many 
questions. I really don't know the context here...

>
> Anway, this patch is Reviewed-by: Felix Kuehling 
>
> BTW, this fix is needed for KFD. It fixes our eviction test that was broken 
> by your previous patch series. This test specifically triggers interactions 
> between KFD and graphics under memory pressure. It's something we rarely see 
> in real world compute application testing without a targeted test. But when 
> it breaks it leads to some painful intermittent failures that are hard to 
> regress and debug.
>
> Do you have any targeted tests to trigger evictions when you work on TTM 
> internals?

Cat amdgpu_evict_gtt in debugfs is a good test for this.

Christian.

>
> Regards,
>     Felix
>
>
>> +spin_unlock(>bdev->glob->lru_lock);
>>  reservation_object_unlock(bo->resv);
>>}
>>
> ___
> 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

Re: [PATCH] drm/ttm: fix ttm_bo_unreserve

2019-06-05 Thread Kuehling, Felix
On 2019-06-05 9:56, Michel Dänzer wrote:
> On 2019-06-05 1:24 p.m., Christian König wrote:
>> Am 04.06.19 um 21:03 schrieb Zeng, Oak:
>>> From: amd-gfx  On Behalf Of
>>> Kuehling, Felix
>>> On 2019-06-04 11:23, Christian König wrote:
[snip]
>>> --- a/include/drm/ttm/ttm_bo_driver.h
>>> +++ b/include/drm/ttm/ttm_bo_driver.h
>>> @@ -767,14 +767,12 @@ static inline int
>>> ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
>>>      */
>>>     static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
>>>     {
>>> -    if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
>>> -    spin_lock(>bdev->glob->lru_lock);
>>> -    if (list_empty(>lru))
>>> -    ttm_bo_add_to_lru(bo);
>>> -    else
>>> -    ttm_bo_move_to_lru_tail(bo, NULL);
>>> -    spin_unlock(>bdev->glob->lru_lock);
>>> -    }
>>> +    spin_lock(>bdev->glob->lru_lock);
>>> +    if (list_empty(>lru))
>>> +    ttm_bo_add_to_lru(bo);
>>> +    else
>>> +    ttm_bo_move_to_lru_tail(bo, NULL);
>>> Going just by the function names, this seems to do the exact opposite
>>> of what the change description says.
>>>
>>> [Oak] +1, when I read the description, I also get lost...So please do
>>> add a more accurate description.
>> I'm puzzled why you are confused. We now keep the BOs on the LRU while
>> they are reserved, so on unreserve we now need to explicitly remove them
>> from the LRU when they are pinned.
> I don't know about Felix and Oak, but for me "remove from the LRU" is
> confusing, as I don't see that in the code, only adding to the LRU or
> moving to its tail.

Exactly. The names of the functions being called imply that something 
gets added or moved on the LRU list. You have to go look at the 
implementation of those functions to find out that they do something 
else for pinned BOs (that have TTM_PL_FLAG_NO_EVICT set in their 
placement flags).

Fixing the function names would probably be overkill: 
ttm_bo_add_lru_unless_pinned and 
ttm_bo_move_to_lru_tail_or_remove_if_pinned. But maybe a comment in 
ttm_bo_unreserve would help.

Regards,
   Felix


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

[PATCH] drm/amdgpu: register pm sysfs for sriov

2019-06-05 Thread Yintian Tao
we need register pm sysfs for virt in order
to support dpm level modification because
smu ip block will not be added under SRIOV

Signed-off-by: Yintian Tao 
Change-Id: Ib0e13934c0c33da00f9d2add6be25a373c6fb957
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  6 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 61 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h |  2 +
 3 files changed, 65 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d00fd5d..9b9d387 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2695,6 +2695,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 
amdgpu_fbdev_init(adev);
 
+   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev))
+   amdgpu_virt_pm_sysfs_init(adev);
+
r = amdgpu_pm_sysfs_init(adev);
if (r)
DRM_ERROR("registering pm debugfs failed (%d).\n", r);
@@ -2816,6 +2819,9 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
iounmap(adev->rmmio);
adev->rmmio = NULL;
amdgpu_device_doorbell_fini(adev);
+   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev))
+   amdgpu_virt_pm_sysfs_fini(adev);
+
amdgpu_debugfs_regs_cleanup(adev);
device_remove_file(adev->dev, _attr_pcie_replay_count);
amdgpu_ucode_sysfs_fini(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index a73e190..93e5205 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -269,8 +269,11 @@ static ssize_t 
amdgpu_get_dpm_forced_performance_level(struct device *dev,
struct amdgpu_device *adev = ddev->dev_private;
enum amd_dpm_forced_level level = 0xff;
 
-   if  ((adev->flags & AMD_IS_PX) &&
-(ddev->switch_power_state != DRM_SWITCH_POWER_ON))
+   if (amdgpu_sriov_vf(adev))
+   return 0;
+
+   if ((adev->flags & AMD_IS_PX) &&
+   (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
return snprintf(buf, PAGE_SIZE, "off\n");
 
if (is_support_sw_smu(adev))
@@ -308,9 +311,11 @@ static ssize_t 
amdgpu_set_dpm_forced_performance_level(struct device *dev,
 (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
return -EINVAL;
 
-   if (is_support_sw_smu(adev))
+   if (!amdgpu_sriov_vf(adev) && is_support_sw_smu(adev))
current_level = smu_get_performance_level(>smu);
-   else if (adev->powerplay.pp_funcs->get_performance_level)
+   else if (!amdgpu_sriov_vf(adev) &&
+adev->powerplay.pp_funcs &&
+adev->powerplay.pp_funcs->get_performance_level)
current_level = amdgpu_dpm_get_performance_level(adev);
 
if (strncmp("low", buf, strlen("low")) == 0) {
@@ -885,6 +890,9 @@ static ssize_t amdgpu_set_pp_dpm_sclk(struct device *dev,
int ret;
uint32_t mask = 0;
 
+   if (amdgpu_sriov_vf(adev))
+   return 0;
+
ret = amdgpu_read_mask(buf, count, );
if (ret)
return ret;
@@ -907,6 +915,10 @@ static ssize_t amdgpu_get_pp_dpm_mclk(struct device *dev,
struct drm_device *ddev = dev_get_drvdata(dev);
struct amdgpu_device *adev = ddev->dev_private;
 
+   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev) &&
+   adev->virt.ops->get_pp_clk)
+   return adev->virt.ops->get_pp_clk(adev,PP_MCLK,buf);
+
if (is_support_sw_smu(adev))
return smu_print_clk_levels(>smu, PP_MCLK, buf);
else if (adev->powerplay.pp_funcs->print_clock_levels)
@@ -925,6 +937,9 @@ static ssize_t amdgpu_set_pp_dpm_mclk(struct device *dev,
int ret;
uint32_t mask = 0;
 
+   if (amdgpu_sriov_vf(adev))
+   return 0;
+
ret = amdgpu_read_mask(buf, count, );
if (ret)
return ret;
@@ -2698,6 +2713,44 @@ void amdgpu_pm_print_power_states(struct amdgpu_device 
*adev)
 
 }
 
+int amdgpu_virt_pm_sysfs_init(struct amdgpu_device *adev)
+{
+   int ret = 0;
+
+   if (!(amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev)))
+   return ret;
+
+   ret = device_create_file(adev->dev, _attr_pp_dpm_sclk);
+   if (ret) {
+   DRM_ERROR("failed to create device file pp_dpm_sclk\n");
+   return ret;
+   }
+
+   ret = device_create_file(adev->dev, _attr_pp_dpm_mclk);
+   if (ret) {
+   DRM_ERROR("failed to create device file pp_dpm_mclk\n");
+   return ret;
+   }
+
+   ret = device_create_file(adev->dev, 
_attr_power_dpm_force_performance_level);
+   if (ret) {
+   DRM_ERROR("failed to create device file for dpm state\n");
+   return ret;
+   }
+
+   return ret;
+}
+
+void amdgpu_virt_pm_sysfs_fini(struct 

Re: [PATCH] drm/ttm: fix ttm_bo_unreserve

2019-06-05 Thread Michel Dänzer
On 2019-06-05 1:24 p.m., Christian König wrote:
> Am 04.06.19 um 21:03 schrieb Zeng, Oak:
>> From: amd-gfx  On Behalf Of
>> Kuehling, Felix
>> On 2019-06-04 11:23, Christian König wrote:
>>
>>> Since we now keep BOs on the LRU we need to make sure that they are
>>> removed when they are pinned.
>>>
>>> Signed-off-by: Christian König 
>>> ---
>>>    include/drm/ttm/ttm_bo_driver.h | 14 ++
>>>    1 file changed, 6 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/include/drm/ttm/ttm_bo_driver.h
>>> b/include/drm/ttm/ttm_bo_driver.h index 9f54cf9c60df..c9b8ba492f24
>>> 100644
>>> --- a/include/drm/ttm/ttm_bo_driver.h
>>> +++ b/include/drm/ttm/ttm_bo_driver.h
>>> @@ -767,14 +767,12 @@ static inline int
>>> ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
>>>     */
>>>    static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
>>>    {
>>> -    if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
>>> -    spin_lock(>bdev->glob->lru_lock);
>>> -    if (list_empty(>lru))
>>> -    ttm_bo_add_to_lru(bo);
>>> -    else
>>> -    ttm_bo_move_to_lru_tail(bo, NULL);
>>> -    spin_unlock(>bdev->glob->lru_lock);
>>> -    }
>>> +    spin_lock(>bdev->glob->lru_lock);
>>> +    if (list_empty(>lru))
>>> +    ttm_bo_add_to_lru(bo);
>>> +    else
>>> +    ttm_bo_move_to_lru_tail(bo, NULL);
>> Going just by the function names, this seems to do the exact opposite
>> of what the change description says.
>>
>> [Oak] +1, when I read the description, I also get lost...So please do
>> add a more accurate description.
> 
> I'm puzzled why you are confused. We now keep the BOs on the LRU while
> they are reserved, so on unreserve we now need to explicitly remove them
> from the LRU when they are pinned.

I don't know about Felix and Oak, but for me "remove from the LRU" is
confusing, as I don't see that in the code, only adding to the LRU or
moving to its tail.


-- 
Earthling Michel Dänzer   |  https://www.amd.com
Libre software enthusiast | Mesa and X developer
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH] drm/amdgpu: register pm sysfs for sriov

2019-06-05 Thread Yintian Tao
we need register pm sysfs for virt in order
to support dpm level modification because
smu ip block will not be added under SRIOV

Signed-off-by: Yintian Tao 
Change-Id: Ib0e13934c0c33da00f9d2add6be25a373c6fb957
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  6 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 61 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.h |  2 +
 3 files changed, 65 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d00fd5d..9b9d387 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2695,6 +2695,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 
amdgpu_fbdev_init(adev);
 
+   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev))
+   amdgpu_virt_pm_sysfs_init(adev);
+
r = amdgpu_pm_sysfs_init(adev);
if (r)
DRM_ERROR("registering pm debugfs failed (%d).\n", r);
@@ -2816,6 +2819,9 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
iounmap(adev->rmmio);
adev->rmmio = NULL;
amdgpu_device_doorbell_fini(adev);
+   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev))
+   amdgpu_virt_pm_sysfs_fini(adev);
+
amdgpu_debugfs_regs_cleanup(adev);
device_remove_file(adev->dev, _attr_pcie_replay_count);
amdgpu_ucode_sysfs_fini(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index a73e190..b6f16d45 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -269,8 +269,11 @@ static ssize_t 
amdgpu_get_dpm_forced_performance_level(struct device *dev,
struct amdgpu_device *adev = ddev->dev_private;
enum amd_dpm_forced_level level = 0xff;
 
-   if  ((adev->flags & AMD_IS_PX) &&
-(ddev->switch_power_state != DRM_SWITCH_POWER_ON))
+   if (amdgpu_sriov_vf(adev))
+   return 0;
+
+   if ((adev->flags & AMD_IS_PX) &&
+   (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
return snprintf(buf, PAGE_SIZE, "off\n");
 
if (is_support_sw_smu(adev))
@@ -308,9 +311,11 @@ static ssize_t 
amdgpu_set_dpm_forced_performance_level(struct device *dev,
 (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
return -EINVAL;
 
-   if (is_support_sw_smu(adev))
+   if (!amdgpu_sriov_vf(adev) && is_support_sw_smu(adev))
current_level = smu_get_performance_level(>smu);
-   else if (adev->powerplay.pp_funcs->get_performance_level)
+   else if (!amdgpu_sriov_vf(adev) &&
+adev->powerplay.pp_funcs &&
+adev->powerplay.pp_funcs->get_performance_level)
current_level = amdgpu_dpm_get_performance_level(adev);
 
if (strncmp("low", buf, strlen("low")) == 0) {
@@ -907,6 +912,10 @@ static ssize_t amdgpu_get_pp_dpm_mclk(struct device *dev,
struct drm_device *ddev = dev_get_drvdata(dev);
struct amdgpu_device *adev = ddev->dev_private;
 
+   if (amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev) &&
+   adev->virt.ops->get_pp_clk)
+   return adev->virt.ops->get_pp_clk(adev,PP_MCLK,buf);
+
if (is_support_sw_smu(adev))
return smu_print_clk_levels(>smu, PP_MCLK, buf);
else if (adev->powerplay.pp_funcs->print_clock_levels)
@@ -925,6 +934,9 @@ static ssize_t amdgpu_set_pp_dpm_mclk(struct device *dev,
int ret;
uint32_t mask = 0;
 
+   if (amdgpu_sriov_vf(adev))
+   return 0;
+
ret = amdgpu_read_mask(buf, count, );
if (ret)
return ret;
@@ -965,6 +977,9 @@ static ssize_t amdgpu_set_pp_dpm_socclk(struct device *dev,
int ret;
uint32_t mask = 0;
 
+   if (amdgpu_sriov_vf(adev))
+   return 0;
+
ret = amdgpu_read_mask(buf, count, );
if (ret)
return ret;
@@ -2698,6 +2713,44 @@ void amdgpu_pm_print_power_states(struct amdgpu_device 
*adev)
 
 }
 
+int amdgpu_virt_pm_sysfs_init(struct amdgpu_device *adev)
+{
+   int ret = 0;
+
+   if (!(amdgpu_sriov_vf(adev) && amdgim_is_hwperf(adev)))
+   return ret;
+
+   ret = device_create_file(adev->dev, _attr_pp_dpm_sclk);
+   if (ret) {
+   DRM_ERROR("failed to create device file pp_dpm_sclk\n");
+   return ret;
+   }
+
+   ret = device_create_file(adev->dev, _attr_pp_dpm_mclk);
+   if (ret) {
+   DRM_ERROR("failed to create device file pp_dpm_mclk\n");
+   return ret;
+   }
+
+   ret = device_create_file(adev->dev, 
_attr_power_dpm_force_performance_level);
+   if (ret) {
+   DRM_ERROR("failed to create device file for dpm state\n");
+   return ret;
+   }
+
+   return ret;
+}
+
+void amdgpu_virt_pm_sysfs_fini(struct 

Re: [PATCH] drm/amdgpu: bump the DRM version for GDS ENOMEM fixes

2019-06-05 Thread Christian König

Am 05.06.19 um 04:50 schrieb Marek Olšák:

From: Marek Olšák 

Signed-off-by: Marek Olšák 


Reviewed-by: Christian König 


---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 1f38d6fc1fe3..f9462ad2a314 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -69,23 +69,24 @@
   * - 3.23.0 - Add query for VRAM lost counter
   * - 3.24.0 - Add high priority compute support for gfx9
   * - 3.25.0 - Add support for sensor query info (stable pstate sclk/mclk).
   * - 3.26.0 - GFX9: Process AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE.
   * - 3.27.0 - Add new chunk to to AMDGPU_CS to enable BO_LIST creation.
   * - 3.28.0 - Add AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES
   * - 3.29.0 - Add AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID
   * - 3.30.0 - Add AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE.
   * - 3.31.0 - Add support for per-flip tiling attribute changes with DC
   * - 3.32.0 - Add syncobj timeline support to AMDGPU_CS.
+ * - 3.33.0 - Fixes for GDS ENOMEM failures in AMDGPU_CS.
   */
  #define KMS_DRIVER_MAJOR  3
-#define KMS_DRIVER_MINOR   32
+#define KMS_DRIVER_MINOR   33
  #define KMS_DRIVER_PATCHLEVEL 0
  
  #define AMDGPU_MAX_TIMEOUT_PARAM_LENTH	256
  
  int amdgpu_vram_limit = 0;

  int amdgpu_vis_vram_limit = 0;
  int amdgpu_gart_size = -1; /* auto */
  int amdgpu_gtt_size = -1; /* auto */
  int amdgpu_moverate = -1; /* auto */
  int amdgpu_benchmarking = 0;


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

Re: [PATCH] drm/ttm: fix ttm_bo_unreserve

2019-06-05 Thread Christian König

Am 04.06.19 um 21:03 schrieb Zeng, Oak:


Regards,
Oak

-Original Message-
From: amd-gfx  On Behalf Of Kuehling, 
Felix
Sent: Tuesday, June 4, 2019 2:47 PM
To: Christian König ; 
dri-de...@lists.freedesktop.org; amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/ttm: fix ttm_bo_unreserve

On 2019-06-04 11:23, Christian König wrote:


Since we now keep BOs on the LRU we need to make sure that they are
removed when they are pinned.

Signed-off-by: Christian König 
---
   include/drm/ttm/ttm_bo_driver.h | 14 ++
   1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/include/drm/ttm/ttm_bo_driver.h
b/include/drm/ttm/ttm_bo_driver.h index 9f54cf9c60df..c9b8ba492f24
100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -767,14 +767,12 @@ static inline int ttm_bo_reserve_slowpath(struct 
ttm_buffer_object *bo,
*/
   static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
   {
-   if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
-   spin_lock(>bdev->glob->lru_lock);
-   if (list_empty(>lru))
-   ttm_bo_add_to_lru(bo);
-   else
-   ttm_bo_move_to_lru_tail(bo, NULL);
-   spin_unlock(>bdev->glob->lru_lock);
-   }
+   spin_lock(>bdev->glob->lru_lock);
+   if (list_empty(>lru))
+   ttm_bo_add_to_lru(bo);
+   else
+   ttm_bo_move_to_lru_tail(bo, NULL);

Going just by the function names, this seems to do the exact opposite of what 
the change description says.

[Oak] +1, when I read the description, I also get lost...So please do add a 
more accurate description.


I'm puzzled why you are confused. We now keep the BOs on the LRU while 
they are reserved, so on unreserve we now need to explicitly remove them 
from the LRU when they are pinned.




Anway, this patch is Reviewed-by: Felix Kuehling 

BTW, this fix is needed for KFD. It fixes our eviction test that was broken by 
your previous patch series. This test specifically triggers interactions 
between KFD and graphics under memory pressure. It's something we rarely see in 
real world compute application testing without a targeted test. But when it 
breaks it leads to some painful intermittent failures that are hard to regress 
and debug.

Do you have any targeted tests to trigger evictions when you work on TTM 
internals?


Cat amdgpu_evict_gtt in debugfs is a good test for this.

Christian.



Regards,
    Felix



+   spin_unlock(>bdev->glob->lru_lock);
reservation_object_unlock(bo->resv);
   }
   

___
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

Re: [PATCH] drm/amdgpu/{uvd,vcn}: fetch ring's read_ptr after alloc

2019-06-05 Thread Koenig, Christian
Am 05.06.19 um 03:35 schrieb S, Shirish:
> Hi Alex,
>
> On 6/4/2019 9:43 PM, Alex Deucher wrote:
>> On Tue, Jun 4, 2019 at 12:07 PM S, Shirish  wrote:
>>> [What]
>>> readptr read always returns zero, since most likely
>>> UVD block is either power or clock gated.
>>>
>>> [How]
>>> fetch rptr after amdgpu_ring_alloc() which informs
>>> the power management code that the block is about to be
>>> used and hence the gating is turned off.
>>>
>>> Signed-off-by: Louis Li 
>>> Signed-off-by: Shirish S 
>>> ---
>>>drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 4 +++-
>>>drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c   | 5 -
>>>drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c   | 5 -
>> What about uvd 4.2, 5.0 and VCE 2.0, 3.0, 4.0?
> amdgpu_vce_ring_test_ring() is the common function for VCE 2.0, 3.0 & 4.0
> and patch that fixes it, is already reviewed.
>
> UVD 4.2 & 5.0  use mmUVD_CONTEXT_ID instead of readptr,
> so i beleive this fix is not applicable for them.

Yeah, agree that should actually work fine for those.

This patch is Reviewed-by: Christian König 

Regards,
Christian.

> Regards,
> Shirish S
>> Alex
>>
>>>3 files changed, 11 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c 
>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
>>> index 118451f..d786098 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
>>> @@ -468,7 +468,7 @@ int amdgpu_vcn_dec_ring_test_ib(struct amdgpu_ring 
>>> *ring, long timeout)
>>>int amdgpu_vcn_enc_ring_test_ring(struct amdgpu_ring *ring)
>>>{
>>>   struct amdgpu_device *adev = ring->adev;
>>> -   uint32_t rptr = amdgpu_ring_get_rptr(ring);
>>> +   uint32_t rptr;
>>>   unsigned i;
>>>   int r;
>>>
>>> @@ -476,6 +476,8 @@ int amdgpu_vcn_enc_ring_test_ring(struct amdgpu_ring 
>>> *ring)
>>>   if (r)
>>>   return r;
>>>
>>> +   rptr = amdgpu_ring_get_rptr(ring);
>>> +
>>>   amdgpu_ring_write(ring, VCN_ENC_CMD_END);
>>>   amdgpu_ring_commit(ring);
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c 
>>> b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
>>> index c61a314..16682b7 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
>>> @@ -170,13 +170,16 @@ static void uvd_v6_0_enc_ring_set_wptr(struct 
>>> amdgpu_ring *ring)
>>>static int uvd_v6_0_enc_ring_test_ring(struct amdgpu_ring *ring)
>>>{
>>>   struct amdgpu_device *adev = ring->adev;
>>> -   uint32_t rptr = amdgpu_ring_get_rptr(ring);
>>> +   uint32_t rptr;
>>>   unsigned i;
>>>   int r;
>>>
>>>   r = amdgpu_ring_alloc(ring, 16);
>>>   if (r)
>>>   return r;
>>> +
>>> +   rptr = amdgpu_ring_get_rptr(ring);
>>> +
>>>   amdgpu_ring_write(ring, HEVC_ENC_CMD_END);
>>>   amdgpu_ring_commit(ring);
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c 
>>> b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
>>> index cdb96d4..74811b2 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
>>> @@ -175,7 +175,7 @@ static void uvd_v7_0_enc_ring_set_wptr(struct 
>>> amdgpu_ring *ring)
>>>static int uvd_v7_0_enc_ring_test_ring(struct amdgpu_ring *ring)
>>>{
>>>   struct amdgpu_device *adev = ring->adev;
>>> -   uint32_t rptr = amdgpu_ring_get_rptr(ring);
>>> +   uint32_t rptr;
>>>   unsigned i;
>>>   int r;
>>>
>>> @@ -185,6 +185,9 @@ static int uvd_v7_0_enc_ring_test_ring(struct 
>>> amdgpu_ring *ring)
>>>   r = amdgpu_ring_alloc(ring, 16);
>>>   if (r)
>>>   return r;
>>> +
>>> +   rptr = amdgpu_ring_get_rptr(ring);
>>> +
>>>   amdgpu_ring_write(ring, HEVC_ENC_CMD_END);
>>>   amdgpu_ring_commit(ring);
>>>
>>> --
>>> 2.7.4
>>>
>>> ___
>>> amd-gfx mailing list
>>> amd-gfx@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue

2019-06-05 Thread Koenig, Christian
This should already be fixed by patch "drm/ttm: fix re-init of global 
structures".

Christian.

Am 05.06.19 um 09:29 schrieb Liu, Monk:
>
> -Original Message-
> From: Monk Liu 
> Sent: Wednesday, June 5, 2019 2:45 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Liu, Monk 
> Subject: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
>
> need to clear bo glob and mem glob during their release otherwise their 
> member value would be wrongly used in the next glob init stage and lead to 
> wild pointer access problems:
>
> 1) kobj.state_initialized is 1
> 2) ttm_bo_glob.bo_count isn't cleared and referenced via it
> on member "swap_lru" would hit out of bound array accessing
> bug
>
> Signed-off-by: Monk Liu 
> ---
>   drivers/gpu/drm/ttm/ttm_bo.c | 2 ++
>   drivers/gpu/drm/ttm/ttm_memory.c | 8 
>   2 files changed, 10 insertions(+)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c 
> index c7de667..6434eac 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1604,6 +1604,8 @@ static void ttm_bo_global_kobj_release(struct kobject 
> *kobj)
>   container_of(kobj, struct ttm_bo_global, kobj);
>   
>   __free_page(glob->dummy_read_page);
> +
> + memset(glob, 0, sizeof(*glob));
>   }
>   
>   static void ttm_bo_global_release(void) diff --git 
> a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
> index 8617958..7128bbf 100644
> --- a/drivers/gpu/drm/ttm/ttm_memory.c
> +++ b/drivers/gpu/drm/ttm/ttm_memory.c
> @@ -229,9 +229,17 @@ static const struct sysfs_ops ttm_mem_global_ops = {
>   .store = _mem_global_store,
>   };
>   
> +void ttm_mem_glob_kobj_release(struct kobject *kobj) {
> + struct ttm_mem_global *glob = container_of(kobj, struct
> +ttm_mem_global, kobj);
> +
> + memset(glob, 0, sizeof(*glob));
> +}
> +
>   static struct kobj_type ttm_mem_glob_kobj_type = {
>   .sysfs_ops = _mem_global_ops,
>   .default_attrs = ttm_mem_global_attrs,
> + .release = ttm_mem_glob_kobj_release,
>   };
>   
>   static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
> --
> 2.7.4
>

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

FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue

2019-06-05 Thread Liu, Monk


-Original Message-
From: Monk Liu  
Sent: Wednesday, June 5, 2019 2:45 PM
To: amd-gfx@lists.freedesktop.org
Cc: Liu, Monk 
Subject: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue

need to clear bo glob and mem glob during their release otherwise their member 
value would be wrongly used in the next glob init stage and lead to wild 
pointer access problems:

1) kobj.state_initialized is 1
2) ttm_bo_glob.bo_count isn't cleared and referenced via it
   on member "swap_lru" would hit out of bound array accessing
   bug

Signed-off-by: Monk Liu 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 2 ++
 drivers/gpu/drm/ttm/ttm_memory.c | 8 
 2 files changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 
c7de667..6434eac 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1604,6 +1604,8 @@ static void ttm_bo_global_kobj_release(struct kobject 
*kobj)
container_of(kobj, struct ttm_bo_global, kobj);
 
__free_page(glob->dummy_read_page);
+
+   memset(glob, 0, sizeof(*glob));
 }
 
 static void ttm_bo_global_release(void) diff --git 
a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index 8617958..7128bbf 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -229,9 +229,17 @@ static const struct sysfs_ops ttm_mem_global_ops = {
.store = _mem_global_store,
 };
 
+void ttm_mem_glob_kobj_release(struct kobject *kobj) {
+   struct ttm_mem_global *glob = container_of(kobj, struct 
+ttm_mem_global, kobj);
+
+   memset(glob, 0, sizeof(*glob));
+}
+
 static struct kobj_type ttm_mem_glob_kobj_type = {
.sysfs_ops = _mem_global_ops,
.default_attrs = ttm_mem_global_attrs,
+   .release = ttm_mem_glob_kobj_release,
 };
 
 static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
--
2.7.4

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

[PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue

2019-06-05 Thread Monk Liu
need to clear bo glob and mem glob during their release
otherwise their member value would be wrongly used in the
next glob init stage and lead to wild pointer access problems:

1) kobj.state_initialized is 1
2) ttm_bo_glob.bo_count isn't cleared and referenced via it
   on member "swap_lru" would hit out of bound array accessing
   bug

Signed-off-by: Monk Liu 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 2 ++
 drivers/gpu/drm/ttm/ttm_memory.c | 8 
 2 files changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index c7de667..6434eac 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1604,6 +1604,8 @@ static void ttm_bo_global_kobj_release(struct kobject 
*kobj)
container_of(kobj, struct ttm_bo_global, kobj);
 
__free_page(glob->dummy_read_page);
+
+   memset(glob, 0, sizeof(*glob));
 }
 
 static void ttm_bo_global_release(void)
diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index 8617958..7128bbf 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -229,9 +229,17 @@ static const struct sysfs_ops ttm_mem_global_ops = {
.store = _mem_global_store,
 };
 
+void ttm_mem_glob_kobj_release(struct kobject *kobj)
+{
+   struct ttm_mem_global *glob = container_of(kobj, struct ttm_mem_global, 
kobj);
+
+   memset(glob, 0, sizeof(*glob));
+}
+
 static struct kobj_type ttm_mem_glob_kobj_type = {
.sysfs_ops = _mem_global_ops,
.default_attrs = ttm_mem_global_attrs,
+   .release = ttm_mem_glob_kobj_release,
 };
 
 static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
-- 
2.7.4

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