Re: [PATCH 00/13] *** per vm lru ***

2018-05-09 Thread Zhang, Jerry (Junwei)

On 05/09/2018 02:45 PM, Chunming Zhou wrote:

move implemenation from ttm to amdgpu driver. (suggested by Christian)
per-vm-lru is because of per-vm-bo, which has no chance to refresh lru, the 
nagtive effect is game performance isn't stable.
so all per-vm-bo should have a default order, every per-vm-bo has its priority, 
relying on its creation index.
When doing CS, if any normal bo is used, then all per-vm-bo should be used, so 
per-vm-bo prioirty >= normal bo priority.

Above is per-vm-lru starting point.


How do you think that we create the per vm bo as priority 1 and kernel bo as 
priority 2 accordingly?

Will that help to make some improvement?

Jerry





Chunming Zhou (13):
   ttm: abstruct evictable bo
   ttm: allow driver has own lru policy
   drm/amdgpu: add lru backend for amdgpu driver
   drm/amdgpu: init/fini vm lru
   drm/amdgpu: pass vm lru to buffer object
   drm/amdgpu: add amdgpu lru implementation
   drm/ttm: export ttm_bo_ref_bug
   drm/amdgpu: use RB tree instead of link list
   drm/amdgpu: add bo index counter
   drm/amdgpu: bulk move per vm bo
   ttm: export ttm_transfered_destroy
   drm/amdgpu: transferred bo doesn't use vm lru
   drm/amdgpu: free vm lru when vm fini

  drivers/gpu/drm/amd/amdgpu/amdgpu.h|   5 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |   1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c |   2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c|  14 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |   9 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |   4 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|   7 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 242 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h |  25 +++
  drivers/gpu/drm/ttm/ttm_bo.c   |  92 +++
  drivers/gpu/drm/ttm/ttm_bo_util.c  |   3 +-
  include/drm/ttm/ttm_bo_driver.h|  52 +++
  12 files changed, 419 insertions(+), 37 deletions(-)


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


[PATCH] drm/ttm: specify bo priority when initializing ttm bo

2018-05-09 Thread Junwei Zhang
Expect to add an evitable bo who has reservation object
to the correct lru[bo->priority] list

Signed-off-by: Junwei Zhang 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 11 ++-
 drivers/gpu/drm/ast/ast_ttm.c   |  2 +-
 drivers/gpu/drm/bochs/bochs_mm.c|  2 +-
 drivers/gpu/drm/cirrus/cirrus_ttm.c |  2 +-
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c |  2 +-
 drivers/gpu/drm/mgag200/mgag200_ttm.c   |  2 +-
 drivers/gpu/drm/nouveau/nouveau_bo.c|  2 +-
 drivers/gpu/drm/qxl/qxl_object.c|  2 +-
 drivers/gpu/drm/radeon/radeon_object.c  |  2 +-
 drivers/gpu/drm/ttm/ttm_bo.c|  8 +---
 drivers/gpu/drm/virtio/virtgpu_object.c |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c|  2 +-
 drivers/staging/vboxvideo/vbox_ttm.c|  2 +-
 include/drm/ttm/ttm_bo_api.h|  5 -
 14 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index e62153a..9a25ecb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -360,6 +360,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
};
struct amdgpu_bo *bo;
unsigned long page_align, size = bp->size;
+   uint32_t prio = 0;
size_t acc_size;
int r;
 
@@ -419,10 +420,13 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
 
bo->tbo.bdev = >mman.bdev;
amdgpu_ttm_placement_from_domain(bo, bp->domain);
+   if (bp->type == ttm_bo_type_kernel)
+   prio = 1;
 
r = ttm_bo_init_reserved(>mman.bdev, >tbo, size, bp->type,
->placement, page_align, , acc_size,
-NULL, bp->resv, _ttm_bo_destroy);
+prio, >placement, page_align, ,
+acc_size, NULL, bp->resv,
+_ttm_bo_destroy);
if (unlikely(r != 0))
return r;
 
@@ -434,9 +438,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
else
amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0);
 
-   if (bp->type == ttm_bo_type_kernel)
-   bo->tbo.priority = 1;
-
if (bp->flags & AMDGPU_GEM_CREATE_VRAM_CLEARED &&
bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) {
struct dma_fence *fence;
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index fe354eb..aabb96a 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -320,7 +320,7 @@ int ast_bo_create(struct drm_device *dev, int size, int 
align,
   sizeof(struct ast_bo));
 
ret = ttm_bo_init(>ttm.bdev, >bo, size,
- ttm_bo_type_device, >placement,
+ ttm_bo_type_device, 0, >placement,
  align >> PAGE_SHIFT, false, acc_size,
  NULL, NULL, ast_bo_ttm_destroy);
if (ret)
diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c
index 39cd084..9693109 100644
--- a/drivers/gpu/drm/bochs/bochs_mm.c
+++ b/drivers/gpu/drm/bochs/bochs_mm.c
@@ -366,7 +366,7 @@ static int bochs_bo_create(struct drm_device *dev, int 
size, int align,
   sizeof(struct bochs_bo));
 
ret = ttm_bo_init(>ttm.bdev, >bo, size,
- ttm_bo_type_device, >placement,
+ ttm_bo_type_device, 0, >placement,
  align >> PAGE_SHIFT, false, acc_size,
  NULL, NULL, bochs_bo_ttm_destroy);
if (ret)
diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c 
b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index f219532..c1d85f8 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -327,7 +327,7 @@ int cirrus_bo_create(struct drm_device *dev, int size, int 
align,
   sizeof(struct cirrus_bo));
 
ret = ttm_bo_init(>ttm.bdev, >bo, size,
- ttm_bo_type_device, >placement,
+ ttm_bo_type_device, 0, >placement,
  align >> PAGE_SHIFT, false, acc_size,
  NULL, NULL, cirrus_bo_ttm_destroy);
if (ret)
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
index 4871025..8c24731 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
@@ -315,7 +315,7 @@ int hibmc_bo_create(struct drm_device *dev, int size, int 
align,
   sizeof(struct hibmc_bo));
 
ret = ttm_bo_init(>bdev, >bo, size,
- ttm_bo_type_device, >placement,
+ 

Re: [PATCH] drm/amd/powerplay: add PME smu message for raven

2018-05-09 Thread Alex Deucher
On Wed, May 9, 2018 at 9:01 PM, Junwei Zhang  wrote:
> Signed-off-by: Junwei Zhang 

Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h 
> b/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h
> index 5d07b6e..a2991fa 100644
> --- a/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h
> +++ b/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h
> @@ -82,7 +82,8 @@
>  #define PPSMC_MSG_SetSoftMaxFclkByFreq  0x33
>  #define PPSMC_MSG_SetSoftMaxVcn 0x34
>  #define PPSMC_MSG_PowerGateMmHub0x35
> -#define PPSMC_Message_Count 0x36
> +#define PPSMC_MSG_SetRccPfcPmeRestoreRegister   0x36
> +#define PPSMC_Message_Count 0x37
>
>
>  typedef uint16_t PPSMC_Result;
> --
> 1.9.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


Cannot compile with GCC 8.1

2018-05-09 Thread Dawson Dias
Here's a log of the output while trying to compile the kernel with GCC 8.1

-Dawson Dias


kernel_8.1_gcc
Description: Binary data
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH] drm/amd/powerplay: add PME smu message for raven

2018-05-09 Thread Junwei Zhang
Signed-off-by: Junwei Zhang 
---
 drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h 
b/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h
index 5d07b6e..a2991fa 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h
@@ -82,7 +82,8 @@
 #define PPSMC_MSG_SetSoftMaxFclkByFreq  0x33
 #define PPSMC_MSG_SetSoftMaxVcn 0x34
 #define PPSMC_MSG_PowerGateMmHub0x35
-#define PPSMC_Message_Count 0x36
+#define PPSMC_MSG_SetRccPfcPmeRestoreRegister   0x36
+#define PPSMC_Message_Count 0x37
 
 
 typedef uint16_t PPSMC_Result;
-- 
1.9.1

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


Aw: Re: 答复: [BUG] amdgpu: System freezes after resuming from suspend to ram the second time

2018-05-09 Thread John Smith

> What driver version did you used? Did you try our last release driver?

Kernelmodule amdgpu from 4.17.0-rc4 Mainline Sources. I am not using the 
userspace pro driver yet.


$ lspci | grep 'VGA\|ATI'
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (rev 07) 
(prog-if 00 [VGA controller])
Subsystem: Hewlett-Packard Company UHD Graphics 620
Flags: bus master, fast devsel, latency 0, IRQ 136
Memory at 1ff200 (64-bit, non-prefetchable) [size=16M]
Memory at b000 (64-bit, prefetchable) [size=256M]
I/O ports at 4000 [size=64]
[virtual] Expansion ROM at 000c [disabled] [size=128K]
Capabilities: 
Kernel driver in use: i915
Kernel modules: i915
01:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Lexa XT 
[Radeon PRO WX 3100]
Subsystem: Hewlett-Packard Company Lexa XT [Radeon PRO WX 3100]
Flags: bus master, fast devsel, latency 0, IRQ 138
Memory at c000 (64-bit, prefetchable) [size=256M]
Memory at d000 (64-bit, prefetchable) [size=2M]
I/O ports at 3000 [size=256]
Memory at ea30 (32-bit, non-prefetchable) [size=256K]
Expansion ROM at ea34 [disabled] [size=128K]
Capabilities: 
Kernel driver in use: amdgpu
Kernel modules: amdgpu



$ modinfo amdgpu
filename:   
/lib/modules/4.17.0-rc4-ARCH+/kernel/drivers/gpu/drm/amd/amdgpu/amdgpu.ko.xz
license:GPL and additional rights
description:AMD GPU
author: AMD linux driver team
firmware:   amdgpu/raven_gpu_info.bin
firmware:   amdgpu/vega12_gpu_info.bin
firmware:   amdgpu/vega10_gpu_info.bin
firmware:   radeon/hawaii_k_smc.bin
firmware:   radeon/hawaii_smc.bin
firmware:   radeon/bonaire_k_smc.bin
firmware:   radeon/bonaire_smc.bin
firmware:   radeon/mullins_mec.bin
firmware:   radeon/mullins_rlc.bin
firmware:   radeon/mullins_ce.bin
firmware:   radeon/mullins_me.bin
firmware:   radeon/mullins_pfp.bin
firmware:   radeon/kabini_mec.bin
firmware:   radeon/kabini_rlc.bin
firmware:   radeon/kabini_ce.bin
firmware:   radeon/kabini_me.bin
firmware:   radeon/kabini_pfp.bin
firmware:   radeon/kaveri_mec2.bin
firmware:   radeon/kaveri_mec.bin
firmware:   radeon/kaveri_rlc.bin
firmware:   radeon/kaveri_ce.bin
firmware:   radeon/kaveri_me.bin
firmware:   radeon/kaveri_pfp.bin
firmware:   radeon/hawaii_mec.bin
firmware:   radeon/hawaii_rlc.bin
firmware:   radeon/hawaii_ce.bin
firmware:   radeon/hawaii_me.bin
firmware:   radeon/hawaii_pfp.bin
firmware:   radeon/bonaire_mec.bin
firmware:   radeon/bonaire_rlc.bin
firmware:   radeon/bonaire_ce.bin
firmware:   radeon/bonaire_me.bin
firmware:   radeon/bonaire_pfp.bin
firmware:   radeon/mullins_sdma1.bin
firmware:   radeon/mullins_sdma.bin
firmware:   radeon/kabini_sdma1.bin
firmware:   radeon/kabini_sdma.bin
firmware:   radeon/kaveri_sdma1.bin
firmware:   radeon/kaveri_sdma.bin
firmware:   radeon/hawaii_sdma1.bin
firmware:   radeon/hawaii_sdma.bin
firmware:   radeon/bonaire_sdma1.bin
firmware:   radeon/bonaire_sdma.bin
firmware:   radeon/si58_mc.bin
firmware:   radeon/oland_mc.bin
firmware:   radeon/verde_mc.bin
firmware:   radeon/pitcairn_mc.bin
firmware:   radeon/tahiti_mc.bin
firmware:   radeon/hainan_rlc.bin
firmware:   radeon/hainan_ce.bin
firmware:   radeon/hainan_me.bin
firmware:   radeon/hainan_pfp.bin
firmware:   radeon/oland_rlc.bin
firmware:   radeon/oland_ce.bin
firmware:   radeon/oland_me.bin
firmware:   radeon/oland_pfp.bin
firmware:   radeon/verde_rlc.bin
firmware:   radeon/verde_ce.bin
firmware:   radeon/verde_me.bin
firmware:   radeon/verde_pfp.bin
firmware:   radeon/pitcairn_rlc.bin
firmware:   radeon/pitcairn_ce.bin
firmware:   radeon/pitcairn_me.bin
firmware:   radeon/pitcairn_pfp.bin
firmware:   radeon/tahiti_rlc.bin
firmware:   radeon/tahiti_ce.bin
firmware:   radeon/tahiti_me.bin
firmware:   radeon/tahiti_pfp.bin
firmware:   radeon/banks_k_2_smc.bin
firmware:   radeon/hainan_k_smc.bin
firmware:   radeon/hainan_smc.bin
firmware:   radeon/oland_k_smc.bin
firmware:   radeon/oland_smc.bin
firmware:   radeon/verde_k_smc.bin
firmware:   radeon/verde_smc.bin
firmware:   radeon/pitcairn_k_smc.bin
firmware:   radeon/pitcairn_smc.bin
firmware:   radeon/tahiti_smc.bin
firmware:   amdgpu/topaz_mc.bin
firmware:   radeon/hawaii_mc.bin
firmware:   radeon/bonaire_mc.bin
firmware:   amdgpu/polaris12_mc.bin
firmware:   amdgpu/polaris10_mc.bin
firmware:   amdgpu/polaris11_mc.bin
firmware:   amdgpu/tonga_mc.bin
firmware:   amdgpu/vega12_asd.bin
firmware:   amdgpu/vega12_sos.bin
firmware:   amdgpu/vega10_asd.bin
firmware:   amdgpu/vega10_sos.bin
firmware:   

[pull] amdgpu and ttm drm-fixes-4.17

2018-05-09 Thread Alex Deucher
Hi Dave,

A little bigger than normal since this is two weeks of fixes.
- Atom firmware table updates for vega12
- Fix fallout from huge page support
- Fix up smu7 power profile interface to be consistent with vega
- Misc other fixes

The following changes since commit a02cbe2e34c576cdc5e7846a3cd55245ab81db47:

  Merge branch 'vmwgfx-fixes-4.17' of 
git://people.freedesktop.org/~thomash/linux into drm-fixes (2018-05-04 10:03:27 
+1000)

are available in the git repository at:

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

for you to fetch changes up to 639f790223e62339b9cb7319ea3fae9e02c39bdb:

  drm/amd/pp: Refine the output of pp_power_profile_mode on VI (2018-05-09 
15:17:39 -0500)


Andrey Grodzovsky (1):
  drm/amdgpu: Switch to interruptable wait to recover from ring hang.

Harry Wentland (3):
  drm/amd/display: Add VG12 ASIC IDs
  drm/amd/display: Add get_firmware_info_v3_2 for VG12
  drm/amd/display: Don't return ddc result and read_bytes in same return 
value

Jerry (Fangzhi) Zuo (1):
  drm/amd: Add BIOS smu_info v3_3 required struct def.

Michel Dänzer (2):
  drm/amd/display: Use kvzalloc for potentially large allocations
  drm/ttm: Use GFP_TRANSHUGE_LIGHT for allocating huge pages

Rex Zhu (1):
  drm/amd/pp: Refine the output of pp_power_profile_mode on VI

 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c|   6 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_mst_types.c|  20 ++-
 drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c |  86 ++-
 drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c  |  10 +-
 drivers/gpu/drm/amd/display/dc/core/dc_surface.c   |  14 +-
 drivers/gpu/drm/amd/display/dc/inc/dc_link_ddc.h   |   5 +-
 drivers/gpu/drm/amd/display/include/dal_asic_id.h  |   9 +-
 .../drm/amd/display/modules/color/color_gamma.c|  72 -
 drivers/gpu/drm/amd/include/atomfirmware.h | 170 -
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c   |  52 +++
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.h   |   1 -
 drivers/gpu/drm/ttm/ttm_page_alloc.c   |  11 +-
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c   |   3 +-
 13 files changed, 364 insertions(+), 95 deletions(-)
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH] drm/amd/display: remove need of modeset flag for overlay planes

2018-05-09 Thread Harry Wentland
On 2018-04-27 06:27 AM, Shirish S wrote:
> This patch is in continuation to the
> "843e3c7 drm/amd/display: defer modeset check in dm_update_planes_state"
> where we started to eliminate the dependency on
> DRM_MODE_ATOMIC_ALLOW_MODESET to be set by the user space,
> which as such is not mandatory.
> 
> After deferring, this patch eliminates the dependency on the flag
> for overlay planes.
> 
> This has to be done in stages as its a pretty complex and requires thorough
> testing before we free primary planes as well from dependency on modeset
> flag.
> 
> Signed-off-by: Shirish S 

After the offline discussion I'm okay to go ahead with this as it should be 
relatively self-contained and currently unblocks one use-case. We'll definitely 
need to address this code soon and find a good way to stop abusing the 
allow_modeset flag.

Reviewed-by: Harry Wentland 

If this does cause unexpected fallout we can always revert and revisit.

Harry

> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> 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 1a63c04..87b661d 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -4174,7 +4174,7 @@ static void amdgpu_dm_commit_planes(struct 
> drm_atomic_state *state,
>   }
>   spin_unlock_irqrestore(>dev->event_lock, flags);
>  
> - if (!pflip_needed) {
> + if (!pflip_needed || plane->type == DRM_PLANE_TYPE_OVERLAY) {
>   WARN_ON(!dm_new_plane_state->dc_state);
>  
>   plane_states_constructed[planes_count] = 
> dm_new_plane_state->dc_state;
> @@ -4884,7 +4884,8 @@ static int dm_update_planes_state(struct dc *dc,
>  
>   /* Remove any changed/removed planes */
>   if (!enable) {
> - if (pflip_needed)
> + if (pflip_needed &&
> + plane && plane->type != DRM_PLANE_TYPE_OVERLAY)
>   continue;
>  
>   if (!old_plane_crtc)
> @@ -4931,7 +4932,8 @@ static int dm_update_planes_state(struct dc *dc,
>   if (!dm_new_crtc_state->stream)
>   continue;
>  
> - if (pflip_needed)
> + if (pflip_needed &&
> + plane && plane->type != DRM_PLANE_TYPE_OVERLAY)
>   continue;
>  
>   WARN_ON(dm_new_plane_state->dc_state);
> 
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH] drm/amd/display: clean up assignment of amdgpu_crtc

2018-05-09 Thread Alex Deucher
On Wed, May 2, 2018 at 11:04 AM, Harry Wentland  wrote:
> On 2018-05-02 10:43 AM, Colin King wrote:
>> From: Colin Ian King 
>>
>> The declaration of pointer amdgpu_crtc has a redundant assignment to
>> amdgpu_crtc. Clean this up by removing it.
>>
>> Detected by CoverityScan, CID#1460299 ("Evaluation order violation")
>>
>> Signed-off-by: Colin Ian King 
>
> Looks like i goofed. Thanks for fixing this.
>
> Reviewed-by: Harry Wentland 


Applied.  Thanks!

Alex

>
> Harry
>
>> ---
>>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> 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 1dd1142246c2..2beb8821e19e 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> @@ -3773,7 +3773,7 @@ static void remove_stream(struct amdgpu_device *adev,
>>  static int get_cursor_position(struct drm_plane *plane, struct drm_crtc 
>> *crtc,
>>  struct dc_cursor_position *position)
>>  {
>> - struct amdgpu_crtc *amdgpu_crtc = amdgpu_crtc = to_amdgpu_crtc(crtc);
>> + struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
>>   int x, y;
>>   int xorigin = 0, yorigin = 0;
>>
>>
> ___
> 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/amd/powerplay: fix spelling mistake: "contruct" -> "construct"

2018-05-09 Thread Alex Deucher
On Sat, Apr 28, 2018 at 6:21 PM, Colin King  wrote:
> From: Colin Ian King 
>
> Trivial fix to spelling mistake in PP_ASSERT_WITH_CODE message text
>
> Signed-off-by: Colin Ian King 

Applied.  thanks!

Alex

> ---
>  drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c   | 2 +-
>  drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c 
> b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
> index 26fbeafc3c96..726994cf03ea 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
> @@ -1229,7 +1229,7 @@ static int smu7_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
>
> tmp_result = smu7_construct_voltage_tables(hwmgr);
> PP_ASSERT_WITH_CODE((0 == tmp_result),
> -   "Failed to contruct voltage tables!",
> +   "Failed to construct voltage tables!",
> result = tmp_result);
> }
> smum_initialize_mc_reg_table(hwmgr);
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c 
> b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
> index 7cbb56ba6fab..ced1c2aab7a9 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
> @@ -2829,7 +2829,7 @@ static int vega10_enable_dpm_tasks(struct pp_hwmgr 
> *hwmgr)
>
> tmp_result = vega10_construct_voltage_tables(hwmgr);
> PP_ASSERT_WITH_CODE(!tmp_result,
> -   "Failed to contruct voltage tables!",
> +   "Failed to construct voltage tables!",
> result = tmp_result);
>
> tmp_result = vega10_init_smc_table(hwmgr);
> --
> 2.17.0
>
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 01/13] ttm: abstruct evictable bo

2018-05-09 Thread Alex Deucher
On Wed, May 9, 2018 at 6:06 AM, zhoucm1  wrote:
>
>
> On 2018年05月09日 17:50, Daniel Vetter wrote:
>>
>> On Wed, May 09, 2018 at 10:34:51AM +0200, Lucas Stach wrote:
>>>
>>> All of those changes are including a Change-Id that has no bearing in
>>> upstream patches and are missing a proper commit description explaining
>>> why a specific change is done.
>>
>> Imo the Change-Id: is ok if it makes people happy wrt internal tracking.
>> Linus might blow up, but there's lots of random nonsense that Linus blows
>> up on, so whatever.
>
> Yeah, Change-Id is just used internal, When upstreaming, it is removed.
> Alex, right? I'm not clear how you handle that when you upstream our
> internal patches.

Yes, I strip them off when we upstream the patches, but we use them
internally.  For patch review just ignore them.

Alex

>
>>
>> Lack of real commit message that explains stuff is the real thing here I'd
>> say.
>
> Agree, lacking commit message is really bad, that could be because this is a
> big feature, I was busy with implementing before.
> If Christian agree with my this idea, I will update more commit for every
> patch when sending again.
>
> Thanks,
> David Zhou
>
>> -Daniel
>>
>>> Regards,
>>> Lucas
>>>
>>> Am Mittwoch, den 09.05.2018, 14:45 +0800 schrieb Chunming Zhou:

 Change-Id: Ie81985282fab1e564fc2948109fae2173613b465
>
> Signed-off-by: Chunming Zhou 

 ---
   drivers/gpu/drm/ttm/ttm_bo.c | 35 ---
   1 file changed, 24 insertions(+), 11 deletions(-)

 diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
 index 98e06f8bf23b..15506682a0be 100644
 --- a/drivers/gpu/drm/ttm/ttm_bo.c
 +++ b/drivers/gpu/drm/ttm/ttm_bo.c
 @@ -704,22 +704,20 @@ static bool ttm_bo_evict_swapout_allowable(struct
 ttm_buffer_object *bo,
>
> return ret;

   }
   -static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
>
> -  uint32_t mem_type,
> -  const struct ttm_place *place,
> -  struct ttm_operation_ctx *ctx)

 +static struct ttm_buffer_object *
 +ttm_mem_get_evictable_bo(struct ttm_bo_device *bdev,
>
> +uint32_t mem_type,
> +const struct ttm_place *place,
> +struct ttm_operation_ctx *ctx,
> +bool *locked)

   {
>
> -   struct ttm_bo_global *glob = bdev->glob;
> -   struct ttm_mem_type_manager *man = >man[mem_type];
> struct ttm_buffer_object *bo = NULL;
> -   bool locked = false;
> -   unsigned i;
> -   int ret;
> +   struct ttm_mem_type_manager *man = >man[mem_type];
> +   int i;


>
> -   spin_lock(>lru_lock);
> for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
> list_for_each_entry(bo, >lru[i], lru) {
> -   if (!ttm_bo_evict_swapout_allowable(bo, ctx,
> ))
> +   if (!ttm_bo_evict_swapout_allowable(bo, ctx,
> locked))
> continue;


>
> if (place &&
> !bdev->driver->eviction_valuable(bo,

 @@ -738,6 +736,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device
 *bdev,
>
> bo = NULL;
> }


>
> +   return bo;

 +}
 +
 +static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
>
> +  uint32_t mem_type,
> +  const struct ttm_place *place,
> +  struct ttm_operation_ctx *ctx)

 +{
>
> +   struct ttm_bo_global *glob = bdev->glob;
> +   struct ttm_buffer_object *bo = NULL;
> +   bool locked = false;
> +   int ret;

 +
>
> +   spin_lock(>lru_lock);
> +   bo = ttm_mem_get_evictable_bo(bdev, mem_type, place, ctx,
> );
> if (!bo) {
> spin_unlock(>lru_lock);
> return -EBUSY;
>>>
>>> ___
>>> dri-devel mailing list
>>> dri-de...@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>
> ___
> 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 3/3] drm/vc4: Attach underscan props to the HDMI connector

2018-05-09 Thread Boris Brezillon
On Mon, 7 May 2018 17:24:08 +0200
Daniel Vetter  wrote:

> On Mon, May 07, 2018 at 04:44:34PM +0200, Boris Brezillon wrote:
> > Now that the plane code takes the underscan setup into account, we can
> > safely attach the underscan props to the HDMI connector.
> > 
> > We also take care of filling AVI infoframes correctly to expose the
> > top/botton/left/right bar.
> > 
> > Note that these underscan props match pretty well the
> > overscan_{left,right,top,bottom} properties defined in config.txt and
> > parsed by the VC4 firmware.
> > 
> > Signed-off-by: Boris Brezillon 
> > ---
> >  drivers/gpu/drm/vc4/vc4_hdmi.c | 25 +
> >  1 file changed, 25 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
> > index 1a6db291d48b..17464b5981f9 100644
> > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> > @@ -323,6 +323,16 @@ static struct drm_connector 
> > *vc4_hdmi_connector_init(struct drm_device *dev,
> >DRM_MODE_CONNECTOR_HDMIA);
> > drm_connector_helper_add(connector, _hdmi_connector_helper_funcs);
> >  
> > +   /* The hborder and vborder limit is arbitrarily set to 1024 which
> > +* should be more than enough for real use cases. Note that the actual
> > +* limitation comes from the display mode:
> > +*  hborder < hdisplay && vborder < vdisplay
> > +*/
> > +   drm_connector_attach_underscan_properties(connector,  
> 
> We should probably sprinkle __must_check over all these :-)

I'm perfectly fine adding __must_check to
drm_connector_attach_underscan_properties(), but I'm definitely not
volunteering for a massive __must_check sanitization :P.
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH umr] Re-factor ring reading out of app side of build

2018-05-09 Thread Tom St Denis
This will be used later on by the ring/ib decoder
library API that is coming.

Signed-off-by: Tom St Denis 
---
 src/app/ring_read.c  | 24 
 src/lib/CMakeLists.txt   |  1 +
 src/lib/umr_read_ring_data.c | 53 
 src/umr.h|  1 +
 4 files changed, 59 insertions(+), 20 deletions(-)
 create mode 100644 src/lib/umr_read_ring_data.c

diff --git a/src/app/ring_read.c b/src/app/ring_read.c
index 112e9f0414ad..e3ffd4aab277 100644
--- a/src/app/ring_read.c
+++ b/src/app/ring_read.c
@@ -27,8 +27,8 @@
 
 void umr_read_ring(struct umr_asic *asic, char *ringpath)
 {
-   char fname[128], ringname[32], from[32], to[32];
-   int fd, use_decoder, enable_decoder;
+   char ringname[32], from[32], to[32];
+   int use_decoder, enable_decoder;
uint32_t wptr, rptr, drv_wptr, ringsize, start, end, value,
 *ring_data;
struct umr_ring_decoder decoder, *pdecoder, *ppdecoder;
@@ -42,13 +42,6 @@ void umr_read_ring(struct umr_asic *asic, char *ringpath)
return;
}
 
-   snprintf(fname, sizeof(fname)-1, 
"/sys/kernel/debug/dri/%d/amdgpu_ring_%s", asic->instance, ringname);
-   fd = open(fname, O_RDWR);
-   if (fd < 0) {
-   perror("Could not open ring debugfs file");
-   return;
-   }
-
// only decode PM4 packets on certain rings
memset(, 0, sizeof decoder);
if (!memcmp(ringname, "gfx", 3) ||
@@ -69,18 +62,9 @@ void umr_read_ring(struct umr_asic *asic, char *ringpath)
if (asic->options.halt_waves)
umr_sq_cmd_halt_waves(asic, UMR_SQ_CMD_HALT);
 
-   /* determine file size */
-   ringsize = lseek(fd, 0, SEEK_END) - 12;
-   lseek(fd, 0, SEEK_SET);
-
-   ring_data = calloc(1, ringsize + 12);
-   if (!ring_data) {
-   close(fd);
-   perror("Could not allocate ring data");
+   ring_data = umr_read_ring_data(asic, ringname, );
+   if (!ring_data)
goto end;
-   }
-   read(fd, ring_data, ringsize + 12);
-   close(fd);
 
/* read pointers */
rptr = ring_data[0]<<2;
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index fc87ab725370..7a04540b58c8 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -27,6 +27,7 @@ add_library(umrcore STATIC
   wave_status.c
   umr_apply_bank_address.c
   umr_llvm_disasm.c
+  umr_read_ring_data.c
   update.c
   version.c
   $ $
diff --git a/src/lib/umr_read_ring_data.c b/src/lib/umr_read_ring_data.c
new file mode 100644
index ..cbdeab5f1d7b
--- /dev/null
+++ b/src/lib/umr_read_ring_data.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2018 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Tom St Denis 
+ *
+ */
+#include "umr.h"
+
+void *umr_read_ring_data(struct umr_asic *asic, char *ringname, uint32_t 
*ringsize)
+{
+   int fd;
+   void *ring_data;
+   char fname[128];
+
+   snprintf(fname, sizeof(fname)-1, 
"/sys/kernel/debug/dri/%d/amdgpu_ring_%s", asic->instance, ringname);
+   fd = open(fname, O_RDWR);
+   if (fd < 0) {
+   fprintf(stderr, "[ERROR]: Could not open ring debugfs file");
+   return NULL;
+   }
+
+   /* determine file size */
+   *ringsize = lseek(fd, 0, SEEK_END) - 12;
+   lseek(fd, 0, SEEK_SET);
+
+   ring_data = calloc(1, *ringsize + 12);
+   if (!ring_data) {
+   close(fd);
+   fprintf(stderr, "[ERROR]: Out of memory\n");
+   return NULL;
+   }
+   read(fd, ring_data, *ringsize + 12);
+   close(fd);
+   return ring_data;
+}
diff --git a/src/umr.h b/src/umr.h
index e4ae645cea62..290824b271f1 100644
--- a/src/umr.h
+++ b/src/umr.h
@@ -620,6 +620,7 @@ int umr_grbm_select_index(struct umr_asic 

Re: [PATCH 01/13] ttm: abstruct evictable bo

2018-05-09 Thread zhoucm1



On 2018年05月09日 17:50, Daniel Vetter wrote:

On Wed, May 09, 2018 at 10:34:51AM +0200, Lucas Stach wrote:

All of those changes are including a Change-Id that has no bearing in
upstream patches and are missing a proper commit description explaining
why a specific change is done.

Imo the Change-Id: is ok if it makes people happy wrt internal tracking.
Linus might blow up, but there's lots of random nonsense that Linus blows
up on, so whatever.
Yeah, Change-Id is just used internal, When upstreaming, it is removed. 
Alex, right? I'm not clear how you handle that when you upstream our 
internal patches.




Lack of real commit message that explains stuff is the real thing here I'd
say.
Agree, lacking commit message is really bad, that could be because this 
is a big feature, I was busy with implementing before.
If Christian agree with my this idea, I will update more commit for 
every patch when sending again.


Thanks,
David Zhou

-Daniel


Regards,
Lucas

Am Mittwoch, den 09.05.2018, 14:45 +0800 schrieb Chunming Zhou:

Change-Id: Ie81985282fab1e564fc2948109fae2173613b465

Signed-off-by: Chunming Zhou 

---
  drivers/gpu/drm/ttm/ttm_bo.c | 35 ---
  1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 98e06f8bf23b..15506682a0be 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -704,22 +704,20 @@ static bool ttm_bo_evict_swapout_allowable(struct 
ttm_buffer_object *bo,

    return ret;

  }
  
-static int ttm_mem_evict_first(struct ttm_bo_device *bdev,

-      uint32_t mem_type,
-      const struct ttm_place *place,
-      struct ttm_operation_ctx *ctx)

+static struct ttm_buffer_object *
+ttm_mem_get_evictable_bo(struct ttm_bo_device *bdev,

+    uint32_t mem_type,
+    const struct ttm_place *place,
+    struct ttm_operation_ctx *ctx,
+    bool *locked)

  {

-   struct ttm_bo_global *glob = bdev->glob;
-   struct ttm_mem_type_manager *man = >man[mem_type];
    struct ttm_buffer_object *bo = NULL;
-   bool locked = false;
-   unsigned i;
-   int ret;
+   struct ttm_mem_type_manager *man = >man[mem_type];
+   int i;
  

-   spin_lock(>lru_lock);
    for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
    list_for_each_entry(bo, >lru[i], lru) {
-   if (!ttm_bo_evict_swapout_allowable(bo, ctx, ))
+   if (!ttm_bo_evict_swapout_allowable(bo, ctx, locked))
    continue;
  

    if (place && !bdev->driver->eviction_valuable(bo,

@@ -738,6 +736,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,

    bo = NULL;
    }
  

+   return bo;

+}
+
+static int ttm_mem_evict_first(struct ttm_bo_device *bdev,

+      uint32_t mem_type,
+      const struct ttm_place *place,
+      struct ttm_operation_ctx *ctx)

+{

+   struct ttm_bo_global *glob = bdev->glob;
+   struct ttm_buffer_object *bo = NULL;
+   bool locked = false;
+   int ret;

+

+   spin_lock(>lru_lock);
+   bo = ttm_mem_get_evictable_bo(bdev, mem_type, place, ctx, );
    if (!bo) {
    spin_unlock(>lru_lock);
    return -EBUSY;

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


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


Re: [PATCH 01/13] ttm: abstruct evictable bo

2018-05-09 Thread Daniel Vetter
On Wed, May 09, 2018 at 10:34:51AM +0200, Lucas Stach wrote:
> All of those changes are including a Change-Id that has no bearing in
> upstream patches and are missing a proper commit description explaining
> why a specific change is done.

Imo the Change-Id: is ok if it makes people happy wrt internal tracking.
Linus might blow up, but there's lots of random nonsense that Linus blows
up on, so whatever.

Lack of real commit message that explains stuff is the real thing here I'd
say.
-Daniel

> 
> Regards,
> Lucas
> 
> Am Mittwoch, den 09.05.2018, 14:45 +0800 schrieb Chunming Zhou:
> > Change-Id: Ie81985282fab1e564fc2948109fae2173613b465
> > > Signed-off-by: Chunming Zhou 
> > ---
> >  drivers/gpu/drm/ttm/ttm_bo.c | 35 ---
> >  1 file changed, 24 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index 98e06f8bf23b..15506682a0be 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -704,22 +704,20 @@ static bool ttm_bo_evict_swapout_allowable(struct 
> > ttm_buffer_object *bo,
> > >   return ret;
> >  }
> >  
> > -static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
> > > -    uint32_t mem_type,
> > > -    const struct ttm_place *place,
> > > -    struct ttm_operation_ctx *ctx)
> > +static struct ttm_buffer_object *
> > +ttm_mem_get_evictable_bo(struct ttm_bo_device *bdev,
> > > +  uint32_t mem_type,
> > > +  const struct ttm_place *place,
> > > +  struct ttm_operation_ctx *ctx,
> > > +  bool *locked)
> >  {
> > > - struct ttm_bo_global *glob = bdev->glob;
> > > - struct ttm_mem_type_manager *man = >man[mem_type];
> > >   struct ttm_buffer_object *bo = NULL;
> > > - bool locked = false;
> > > - unsigned i;
> > > - int ret;
> > > + struct ttm_mem_type_manager *man = >man[mem_type];
> > > + int i;
> >  
> > > - spin_lock(>lru_lock);
> > >   for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
> > >   list_for_each_entry(bo, >lru[i], lru) {
> > > - if (!ttm_bo_evict_swapout_allowable(bo, ctx, ))
> > > + if (!ttm_bo_evict_swapout_allowable(bo, ctx, locked))
> > >   continue;
> >  
> > >   if (place && !bdev->driver->eviction_valuable(bo,
> > @@ -738,6 +736,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device 
> > *bdev,
> > >   bo = NULL;
> > >   }
> >  
> > > + return bo;
> > +}
> > +
> > +static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
> > > +    uint32_t mem_type,
> > > +    const struct ttm_place *place,
> > > +    struct ttm_operation_ctx *ctx)
> > +{
> > > + struct ttm_bo_global *glob = bdev->glob;
> > > + struct ttm_buffer_object *bo = NULL;
> > > + bool locked = false;
> > > + int ret;
> > +
> > > + spin_lock(>lru_lock);
> > > + bo = ttm_mem_get_evictable_bo(bdev, mem_type, place, ctx, );
> > >   if (!bo) {
> > >   spin_unlock(>lru_lock);
> > >   return -EBUSY;
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 01/13] ttm: abstruct evictable bo

2018-05-09 Thread Lucas Stach
All of those changes are including a Change-Id that has no bearing in
upstream patches and are missing a proper commit description explaining
why a specific change is done.

Regards,
Lucas

Am Mittwoch, den 09.05.2018, 14:45 +0800 schrieb Chunming Zhou:
> Change-Id: Ie81985282fab1e564fc2948109fae2173613b465
> > Signed-off-by: Chunming Zhou 
> ---
>  drivers/gpu/drm/ttm/ttm_bo.c | 35 ---
>  1 file changed, 24 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 98e06f8bf23b..15506682a0be 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -704,22 +704,20 @@ static bool ttm_bo_evict_swapout_allowable(struct 
> ttm_buffer_object *bo,
> >     return ret;
>  }
>  
> -static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
> > -      uint32_t mem_type,
> > -      const struct ttm_place *place,
> > -      struct ttm_operation_ctx *ctx)
> +static struct ttm_buffer_object *
> +ttm_mem_get_evictable_bo(struct ttm_bo_device *bdev,
> > +    uint32_t mem_type,
> > +    const struct ttm_place *place,
> > +    struct ttm_operation_ctx *ctx,
> > +    bool *locked)
>  {
> > -   struct ttm_bo_global *glob = bdev->glob;
> > -   struct ttm_mem_type_manager *man = >man[mem_type];
> >     struct ttm_buffer_object *bo = NULL;
> > -   bool locked = false;
> > -   unsigned i;
> > -   int ret;
> > +   struct ttm_mem_type_manager *man = >man[mem_type];
> > +   int i;
>  
> > -   spin_lock(>lru_lock);
> >     for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
> >     list_for_each_entry(bo, >lru[i], lru) {
> > -   if (!ttm_bo_evict_swapout_allowable(bo, ctx, ))
> > +   if (!ttm_bo_evict_swapout_allowable(bo, ctx, locked))
> >     continue;
>  
> >     if (place && !bdev->driver->eviction_valuable(bo,
> @@ -738,6 +736,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device 
> *bdev,
> >     bo = NULL;
> >     }
>  
> > +   return bo;
> +}
> +
> +static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
> > +      uint32_t mem_type,
> > +      const struct ttm_place *place,
> > +      struct ttm_operation_ctx *ctx)
> +{
> > +   struct ttm_bo_global *glob = bdev->glob;
> > +   struct ttm_buffer_object *bo = NULL;
> > +   bool locked = false;
> > +   int ret;
> +
> > +   spin_lock(>lru_lock);
> > +   bo = ttm_mem_get_evictable_bo(bdev, mem_type, place, ctx, );
> >     if (!bo) {
> >     spin_unlock(>lru_lock);
> >     return -EBUSY;
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 0/3] drm/connector: Provide generic support for underscan

2018-05-09 Thread Boris Brezillon
Hi,

On Mon,  7 May 2018 16:44:31 +0200
Boris Brezillon  wrote:

> Hello,
> 
> This is an attempt at providing generic support for underscan connector
> props. We already have 3 drivers defining the same underscan, underscan
> vborder and underscan hborder properties (amd, radeon and nouveau) and
> I am about to add a new one, hence my proposal to put the prop parsing
> code in the core and add ->underscan fields to drm_connector_state.
> 
> Note that I use this new infrastructure to support underscan in VC4
> (path 2 and 3) but did not patch existing drivers yet, mainly because I
> don't want to do this work before making sure I got the generic bits
> right.

Thanks everyone for your reviews. After the discussion we had on IRC
and the feedback I had on this patchset it's a bit unclear to me what
the next iteration should look like. Should I continue with the
underscan props, should I use TV margins exposed by the TV connector
state, should I create new props?

Remember that all I need is a way to define margins in order to let
the VC4 HW scaler shrink the planes and adjust their positions on the
screen.

Thanks,

Boris

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


[PATCH 13/13] drm/amdgpu: free vm lru when vm fini

2018-05-09 Thread Chunming Zhou
That means bo isn't per vm bo when vm fini, back to normal bo instead.

Change-Id: Ida56abd0351422dd0b4a4393545c9cdb0e1a6818
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 50 +-
 1 file changed, 43 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index a425d498f3fc..89c2cbbce436 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -150,10 +150,34 @@ int amdgpu_vm_lru_init(struct amdgpu_vm_lru *vm_lru, 
struct amdgpu_device *adev,
 int amdgpu_vm_lru_fini(struct amdgpu_vm_lru *vm_lru, struct amdgpu_device 
*adev)
 {
struct ttm_bo_global *glob = adev->mman.bdev.glob;
+   struct ttm_buffer_object *bo = NULL;
+   struct amdgpu_bo *abo = NULL;
+   struct rb_node *node;
+   int i, j;
+   bool locked;
 
+   locked = reservation_object_trylock(vm_lru->resv);
spin_lock(>lru_lock);
list_del(_lru->vm_lru_list);
+   for (i = 0; i < TTM_MAX_BO_PRIORITY; i++) {
+   for (j = 0; j < TTM_NUM_MEM_TYPES; j++) {
+   list_for_each_entry(bo, _lru->dynamic_lru[j][i], 
lru) {
+   struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
+
+   abo->vm_lru = NULL;
+   abo->index = 0;
+   }
+   for (node = rb_first(_lru->fixed_lru[j][i]);
+node; node = rb_next(node)) {
+   abo = rb_entry(node, struct amdgpu_bo, node);
+   abo->vm_lru = NULL;
+   abo->index = 0;
+   }
+   }
+   }
spin_unlock(>lru_lock);
+   if (locked)
+   reservation_object_unlock(vm_lru->resv);
 
return 0;
 }
@@ -253,12 +277,16 @@ static void amdgpu_vm_bo_add_to_rb(struct amdgpu_bo *bo,
 void amdgpu_vm_add_to_lru(struct ttm_buffer_object *bo)
 {
struct ttm_bo_device *bdev = bo->bdev;
-   struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
-   struct amdgpu_vm_lru *vm_lru = abo->vm_lru;
+   struct amdgpu_bo *abo;
+   struct amdgpu_vm_lru *vm_lru = NULL;
struct ttm_mem_type_manager *man;
 
+   if (bo->destroy != ttm_transfered_destroy) {
+   abo = ttm_to_amdgpu_bo(bo);
+   vm_lru = abo->vm_lru;
+   }
if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
-   if (bo->destroy == ttm_transfered_destroy) {
+   if (bo->destroy == ttm_transfered_destroy || !vm_lru) {
BUG_ON(!list_empty(>lru));
 
man = >man[bo->mem.mem_type];
@@ -300,11 +328,15 @@ static struct amdgpu_bo *amdgpu_vm_bo_rb_find(struct 
rb_root *root, u64 index)
 
 void amdgpu_vm_del_from_lru(struct ttm_buffer_object *bo)
 {
-   struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
-   struct amdgpu_vm_lru *vm_lru = abo->vm_lru;
+   struct amdgpu_bo *abo;
+   struct amdgpu_vm_lru *vm_lru;
 
if (bo->destroy == ttm_transfered_destroy)
return;
+   abo = ttm_to_amdgpu_bo(bo);
+   vm_lru = abo->vm_lru;
+   if (!vm_lru)
+   return;
if 
(amdgpu_vm_bo_rb_find(_lru->fixed_lru[bo->mem.mem_type][bo->priority],
 abo->index)) {
rb_erase(>node,
@@ -315,12 +347,16 @@ void amdgpu_vm_del_from_lru(struct ttm_buffer_object *bo)
 
 void amdgpu_vm_move_to_lru_tail(struct ttm_buffer_object *bo)
 {
-   struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
-   struct amdgpu_vm_lru *vm_lru = abo->vm_lru;
+   struct amdgpu_bo *abo;
+   struct amdgpu_vm_lru *vm_lru;
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
 
if (bo->destroy == ttm_transfered_destroy)
return;
+   abo = ttm_to_amdgpu_bo(bo);
+   vm_lru = abo->vm_lru;
+   if (!vm_lru)
+   return;
if (bo->resv == vm_lru->resv)
list_move_tail(_lru->vm_lru_list, >vm_lru_list);
 }
-- 
2.14.1

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


[PATCH 12/13] drm/amdgpu: transferred bo doesn't use vm lru

2018-05-09 Thread Chunming Zhou
Change-Id: I1179a21aa3712b095fd50bed6956654e0f72e611
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 537f04d25535..a425d498f3fc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -255,9 +255,15 @@ void amdgpu_vm_add_to_lru(struct ttm_buffer_object *bo)
struct ttm_bo_device *bdev = bo->bdev;
struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
struct amdgpu_vm_lru *vm_lru = abo->vm_lru;
+   struct ttm_mem_type_manager *man;
 
if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
-   if (bo->resv == vm_lru->resv)
+   if (bo->destroy == ttm_transfered_destroy) {
+   BUG_ON(!list_empty(>lru));
+
+   man = >man[bo->mem.mem_type];
+   list_add_tail(>lru, >lru[bo->priority]);
+   } else if (bo->resv == vm_lru->resv)
amdgpu_vm_bo_add_to_rb(abo, 
_lru->fixed_lru[bo->mem.mem_type][bo->priority]);
else
list_add_tail(>lru, 
_lru->dynamic_lru[bo->mem.mem_type][bo->priority]);
@@ -297,6 +303,8 @@ void amdgpu_vm_del_from_lru(struct ttm_buffer_object *bo)
struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
struct amdgpu_vm_lru *vm_lru = abo->vm_lru;
 
+   if (bo->destroy == ttm_transfered_destroy)
+   return;
if 
(amdgpu_vm_bo_rb_find(_lru->fixed_lru[bo->mem.mem_type][bo->priority],
 abo->index)) {
rb_erase(>node,
@@ -311,6 +319,8 @@ void amdgpu_vm_move_to_lru_tail(struct ttm_buffer_object 
*bo)
struct amdgpu_vm_lru *vm_lru = abo->vm_lru;
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
 
+   if (bo->destroy == ttm_transfered_destroy)
+   return;
if (bo->resv == vm_lru->resv)
list_move_tail(_lru->vm_lru_list, >vm_lru_list);
 }
-- 
2.14.1

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


[PATCH 10/13] drm/amdgpu: bulk move per vm bo

2018-05-09 Thread Chunming Zhou
Change-Id: I0d5fa7e5e88568f79e836ff47f9c9132cb7d349e
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 5bef4ffa1c87..537f04d25535 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -307,7 +307,12 @@ void amdgpu_vm_del_from_lru(struct ttm_buffer_object *bo)
 
 void amdgpu_vm_move_to_lru_tail(struct ttm_buffer_object *bo)
 {
+   struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
+   struct amdgpu_vm_lru *vm_lru = abo->vm_lru;
+   struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
 
+   if (bo->resv == vm_lru->resv)
+   list_move_tail(_lru->vm_lru_list, >vm_lru_list);
 }
 
 
-- 
2.14.1

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


[PATCH 11/13] ttm: export ttm_transfered_destroy

2018-05-09 Thread Chunming Zhou
driver will use it to check if the bo is transferred bo.

Change-Id: I6a4f3bc00621f9cb3fc24b3bc9d7d7a8ac6cd629
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 3 ++-
 include/drm/ttm/ttm_bo_driver.h   | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index f3bf545a79cf..1dda99b4724a 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -457,7 +457,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
 }
 EXPORT_SYMBOL(ttm_bo_move_memcpy);
 
-static void ttm_transfered_destroy(struct ttm_buffer_object *bo)
+void ttm_transfered_destroy(struct ttm_buffer_object *bo)
 {
struct ttm_transfer_obj *fbo;
 
@@ -465,6 +465,7 @@ static void ttm_transfered_destroy(struct ttm_buffer_object 
*bo)
ttm_bo_unref(>bo);
kfree(fbo);
 }
+EXPORT_SYMBOL(ttm_transfered_destroy);
 
 /**
  * ttm_buffer_object_transfer
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 6847d4258db1..32cc054dfa99 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -855,6 +855,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
   struct ttm_operation_ctx *ctx,
   struct ttm_mem_reg *new_mem);
 
+void ttm_transfered_destroy(struct ttm_buffer_object *bo);
 /**
  * ttm_bo_free_old_node
  *
-- 
2.14.1

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


[PATCH 09/13] drm/amdgpu: add bo index counter

2018-05-09 Thread Chunming Zhou
Change-Id: Iaec4e12164124c155753fc7aea85f76fde8d1ed6
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index a457738c512c..63faa271a7d1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -424,6 +424,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
bo->tbo.priority = 1;
bo->vm_lru = >kernel_vm_lru;
}
+   bo->index = (u64)atomic64_inc_return(>vm_lru->bo_index);
 
r = ttm_bo_init_reserved(>mman.bdev, >tbo, size, bp->type,
 >placement, page_align, , acc_size,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 1a09c07bbf20..5bef4ffa1c87 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -142,6 +142,7 @@ int amdgpu_vm_lru_init(struct amdgpu_vm_lru *vm_lru, struct 
amdgpu_device *adev,
spin_unlock(>lru_lock);
 
vm_lru->resv = resv;
+   atomic64_set(_lru->bo_index, 0);
 
return 0;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 84400673d710..773f1bda2b98 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -141,6 +141,7 @@ struct amdgpu_vm_lru {
struct rb_root fixed_lru[TTM_NUM_MEM_TYPES][TTM_MAX_BO_PRIORITY];
struct list_head dynamic_lru[TTM_NUM_MEM_TYPES][TTM_MAX_BO_PRIORITY];
struct reservation_object *resv;
+   atomic64_t bo_index;
 };
 
 /* base structure for tracking BO usage in a VM */
-- 
2.14.1

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


[PATCH 08/13] drm/amdgpu: use RB tree instead of link list

2018-05-09 Thread Chunming Zhou
Change-Id: Iaca5cdaccbc5beeb7a37c0f703cdfc97df4ece4f
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 85 +++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h |  3 +-
 4 files changed, 82 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index f04fc401327b..b6396230d30e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -82,6 +82,8 @@ struct amdgpu_bo {
struct ttm_placementplacement;
struct ttm_buffer_objecttbo;
struct ttm_bo_kmap_obj  kmap;
+   struct rb_node  node;
+   u64 index;
u64 flags;
unsignedpin_count;
u64 tiling_flags;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 207f88f38b23..a5d8f511b011 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1279,6 +1279,7 @@ static struct ttm_bo_driver amdgpu_bo_driver = {
.invalidate_caches = _invalidate_caches,
.init_mem_type = _init_mem_type,
.eviction_valuable = amdgpu_ttm_bo_eviction_valuable,
+   .lru_empty = _vm_lru_empty,
.get_evictable_bo = _vm_get_evictable_bo,
.add_to_lru = _vm_add_to_lru,
.del_from_lru = _vm_del_from_lru,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 27b3fdb6dd46..1a09c07bbf20 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -133,7 +133,7 @@ int amdgpu_vm_lru_init(struct amdgpu_vm_lru *vm_lru, struct 
amdgpu_device *adev,
INIT_LIST_HEAD(_lru->vm_lru_list);
for (i = 0; i < TTM_NUM_MEM_TYPES; i++) {
for (j = 0; j < TTM_MAX_BO_PRIORITY; j++) {
-   INIT_LIST_HEAD(_lru->fixed_lru[i][j]);
+   vm_lru->fixed_lru[i][j] = RB_ROOT;
INIT_LIST_HEAD(_lru->dynamic_lru[i][j]);
}
}
@@ -157,6 +157,24 @@ int amdgpu_vm_lru_fini(struct amdgpu_vm_lru *vm_lru, 
struct amdgpu_device *adev)
return 0;
 }
 
+bool amdgpu_vm_lru_empty(struct ttm_bo_device *bdev, unsigned mem_type)
+{
+   struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
+   struct amdgpu_vm_lru *vm_lru;
+   int i;
+
+   for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
+   list_for_each_entry(vm_lru, >vm_lru_list, vm_lru_list) {
+   if (!list_empty(_lru->dynamic_lru[mem_type][i]))
+   return false;
+   if (!RB_EMPTY_ROOT(_lru->fixed_lru[mem_type][i]))
+   return false;
+   }
+   }
+
+   return true;
+}
+
 struct ttm_buffer_object *amdgpu_vm_get_evictable_bo(struct ttm_bo_device 
*bdev,
 uint32_t mem_type,
 const struct ttm_place 
*place,
@@ -165,11 +183,13 @@ struct ttm_buffer_object 
*amdgpu_vm_get_evictable_bo(struct ttm_bo_device *bdev,
 {
struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
struct ttm_buffer_object *bo = NULL;
+   struct amdgpu_bo *abo = NULL;
struct amdgpu_vm_lru *vm_lru;
int i;
 
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
list_for_each_entry(vm_lru, >vm_lru_list, vm_lru_list) {
+   struct rb_node *node;
list_for_each_entry(bo, 
_lru->dynamic_lru[mem_type][i], lru) {
if (!ttm_bo_evict_swapout_allowable(bo, ctx, 
locked))
continue;
@@ -184,20 +204,22 @@ struct ttm_buffer_object 
*amdgpu_vm_get_evictable_bo(struct ttm_bo_device *bdev,
if (>lru != _lru->dynamic_lru[mem_type][i])
break;
bo = NULL;
-   list_for_each_entry(bo, 
_lru->fixed_lru[mem_type][i], lru) {
-   if (!ttm_bo_evict_swapout_allowable(bo, ctx, 
locked))
+   for (node = rb_first(_lru->fixed_lru[mem_type][i]);
+node; node = rb_next(node)) {
+   abo = rb_entry(node, struct amdgpu_bo, node);
+   bo = >tbo;
+   if (!ttm_bo_evict_swapout_allowable(bo, ctx, 
locked)) {
+   bo = NULL;
continue;
+   }
if (place && 

[PATCH 07/13] drm/ttm: export ttm_bo_ref_bug

2018-05-09 Thread Chunming Zhou
Change-Id: I5b5f36b4c8af422b5c9d0eaf0c2d3b4db4d9cd0b
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/ttm/ttm_bo.c| 3 ++-
 include/drm/ttm/ttm_bo_driver.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 98da2cf63c9b..e232dadd5f79 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -183,10 +183,11 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
 }
 EXPORT_SYMBOL(ttm_bo_add_to_lru);
 
-static void ttm_bo_ref_bug(struct kref *list_kref)
+void ttm_bo_ref_bug(struct kref *list_kref)
 {
BUG();
 }
+EXPORT_SYMBOL(ttm_bo_ref_bug);
 
 void ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
 {
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 29339b0a2fd6..6847d4258db1 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -601,6 +601,8 @@ int ttm_bo_global_init(struct drm_global_reference *ref);
 
 int ttm_bo_device_release(struct ttm_bo_device *bdev);
 
+void ttm_bo_ref_bug(struct kref *list_kref);
+
 /**
  * ttm_bo_device_init
  *
-- 
2.14.1

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


[PATCH 05/13] drm/amdgpu: pass vm lru to buffer object

2018-05-09 Thread Chunming Zhou
Change-Id: I28351ad8e69c13038ccff40fd9f0369ddae91371
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|  3 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c| 14 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |  8 +---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  2 ++
 5 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index f186c8f29774..cec76cda79c5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -445,7 +445,8 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, 
unsigned long size,
 int alignment, u32 initial_domain,
 u64 flags, enum ttm_bo_type type,
 struct reservation_object *resv,
-struct drm_gem_object **obj);
+struct drm_gem_object **obj,
+struct amdgpu_vm_lru *lru);
 
 int amdgpu_mode_dumb_create(struct drm_file *file_priv,
struct drm_device *dev,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index bc5fd8ebab5d..b2e45e1314eb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -146,7 +146,7 @@ static int amdgpufb_create_pinned_object(struct 
amdgpu_fbdev *rfbdev,
   AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
   AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
   AMDGPU_GEM_CREATE_VRAM_CLEARED,
-  true, NULL, );
+  true, NULL, , NULL);
if (ret) {
pr_err("failed to allocate framebuffer (%d)\n", aligned_size);
return -ENOMEM;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 7d3dc229fa47..fac20d796db0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -45,7 +45,8 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, 
unsigned long size,
 int alignment, u32 initial_domain,
 u64 flags, enum ttm_bo_type type,
 struct reservation_object *resv,
-struct drm_gem_object **obj)
+struct drm_gem_object **obj,
+struct amdgpu_vm_lru *vm_lru)
 {
struct amdgpu_bo *bo;
struct amdgpu_bo_param bp;
@@ -63,6 +64,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, 
unsigned long size,
bp.type = type;
bp.resv = resv;
bp.preferred_domain = initial_domain;
+   bp.vm_lru = vm_lru;
 retry:
bp.flags = flags;
bp.domain = initial_domain;
@@ -257,7 +259,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void 
*data,
 
r = amdgpu_gem_object_create(adev, size, args->in.alignment,
 (u32)(0x & args->in.domains),
-flags, false, resv, );
+flags, false, resv, , >vm_lru);
if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) {
if (!r) {
struct amdgpu_bo *abo = gem_to_amdgpu_bo(gobj);
@@ -285,6 +287,8 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void 
*data,
 {
struct ttm_operation_ctx ctx = { true, false };
struct amdgpu_device *adev = dev->dev_private;
+   struct amdgpu_fpriv *fpriv = filp->driver_priv;
+   struct amdgpu_vm *vm = >vm;
struct drm_amdgpu_gem_userptr *args = data;
struct drm_gem_object *gobj;
struct amdgpu_bo *bo;
@@ -309,7 +313,7 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void 
*data,
 
/* create a gem object to contain this object in */
r = amdgpu_gem_object_create(adev, args->size, 0, AMDGPU_GEM_DOMAIN_CPU,
-0, 0, NULL, );
+0, 0, NULL, , >vm_lru);
if (r)
return r;
 
@@ -747,6 +751,8 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv,
struct drm_mode_create_dumb *args)
 {
struct amdgpu_device *adev = dev->dev_private;
+   struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
+   struct amdgpu_vm *vm = >vm;
struct drm_gem_object *gobj;
uint32_t handle;
int r;
@@ -759,7 +765,7 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv,
r = amdgpu_gem_object_create(adev, args->size, 0,
 AMDGPU_GEM_DOMAIN_VRAM,
 

[PATCH 06/13] drm/amdgpu: add amdgpu lru implementation

2018-05-09 Thread Chunming Zhou
Change-Id: I023d3dd314e49bc9b1649468a82ecca6043e4317
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 59 ++
 1 file changed, 59 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 72ff2d9c8686..27b3fdb6dd46 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -163,11 +163,70 @@ struct ttm_buffer_object 
*amdgpu_vm_get_evictable_bo(struct ttm_bo_device *bdev,
 struct ttm_operation_ctx 
*ctx,
 bool *locked)
 {
+   struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
+   struct ttm_buffer_object *bo = NULL;
+   struct amdgpu_vm_lru *vm_lru;
+   int i;
+
+   for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
+   list_for_each_entry(vm_lru, >vm_lru_list, vm_lru_list) {
+   list_for_each_entry(bo, 
_lru->dynamic_lru[mem_type][i], lru) {
+   if (!ttm_bo_evict_swapout_allowable(bo, ctx, 
locked))
+   continue;
+   if (place && 
!bdev->driver->eviction_valuable(bo, place)) {
+   if (locked)
+   
reservation_object_unlock(bo->resv);
+   continue;
+   }
+   break;
+   }
+   /* If the inner loop terminated early, we have our 
candidate */
+   if (>lru != _lru->dynamic_lru[mem_type][i])
+   break;
+   bo = NULL;
+   list_for_each_entry(bo, 
_lru->fixed_lru[mem_type][i], lru) {
+   if (!ttm_bo_evict_swapout_allowable(bo, ctx, 
locked))
+   continue;
+   if (place && 
!bdev->driver->eviction_valuable(bo, place)) {
+   if (locked)
+   
reservation_object_unlock(bo->resv);
+   continue;
+   }
+   break;
+   }
+   /* If the inner loop terminated early, we have our 
candidate */
+   if (>lru != _lru->fixed_lru[mem_type][i])
+   break;
+   bo = NULL;
+   }
+   if (bo)
+   break;
+   }
+
+   return bo;
 
 }
 
 void amdgpu_vm_add_to_lru(struct ttm_buffer_object *bo)
 {
+   struct ttm_bo_device *bdev = bo->bdev;
+   struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
+   struct amdgpu_vm_lru *vm_lru = abo->vm_lru;
+
+   if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
+   if (bo->resv == vm_lru->resv)
+   list_add_tail(>lru, 
_lru->fixed_lru[bo->mem.mem_type][bo->priority]);
+   else
+   list_add_tail(>lru, 
_lru->dynamic_lru[bo->mem.mem_type][bo->priority]);
+   kref_get(>list_kref);
+
+   if (bo->ttm && !(bo->ttm->page_flags &
+(TTM_PAGE_FLAG_SG | TTM_PAGE_FLAG_SWAPPED))) {
+   list_add_tail(>swap,
+ >glob->swap_lru[bo->priority]);
+   kref_get(>list_kref);
+   }
+   }
 
 }
 
-- 
2.14.1

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


[PATCH 04/13] drm/amdgpu: init/fini vm lru

2018-05-09 Thread Chunming Zhou
Change-Id: Icba45a329e2e2094581ad6c4b8b9028a2e5c5faa
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 37 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 14 +++
 5 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 2d7500921c0b..f186c8f29774 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1532,6 +1532,8 @@ struct amdgpu_device {
dma_addr_t  dummy_page_addr;
struct amdgpu_vm_managervm_manager;
struct amdgpu_vmhub vmhub[AMDGPU_MAX_VMHUBS];
+   struct amdgpu_vm_lrukernel_vm_lru;
+   struct list_headvm_lru_list;
 
/* memory management */
struct amdgpu_mman  mman;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 887f7c9e84e0..feafcfa2633d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2266,6 +2266,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
spin_lock_init(>audio_endpt_idx_lock);
spin_lock_init(>mm_stats.lock);
 
+   INIT_LIST_HEAD(>vm_lru_list);
INIT_LIST_HEAD(>shadow_list);
mutex_init(>shadow_list_lock);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 0bbb1dfdceff..207f88f38b23 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1417,6 +1417,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
return r;
}
adev->mman.initialized = true;
+   amdgpu_vm_lru_init(>kernel_vm_lru, adev, NULL);
 
/* We opt to avoid OOM on system pages allocations */
adev->mman.bdev.no_retry = true;
@@ -1537,6 +1538,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
return;
 
amdgpu_ttm_debugfs_fini(adev);
+   amdgpu_vm_lru_fini(>kernel_vm_lru, adev);
amdgpu_ttm_fw_reserve_vram_fini(adev);
if (adev->mman.aper_base_kaddr)
iounmap(adev->mman.aper_base_kaddr);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index cc6093233ae7..72ff2d9c8686 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -124,6 +124,39 @@ static void amdgpu_vm_bo_base_init(struct 
amdgpu_vm_bo_base *base,
spin_unlock(>status_lock);
 }
 
+int amdgpu_vm_lru_init(struct amdgpu_vm_lru *vm_lru, struct amdgpu_device 
*adev,
+  struct reservation_object *resv)
+{
+   struct ttm_bo_global *glob = adev->mman.bdev.glob;
+   int i, j;
+
+   INIT_LIST_HEAD(_lru->vm_lru_list);
+   for (i = 0; i < TTM_NUM_MEM_TYPES; i++) {
+   for (j = 0; j < TTM_MAX_BO_PRIORITY; j++) {
+   INIT_LIST_HEAD(_lru->fixed_lru[i][j]);
+   INIT_LIST_HEAD(_lru->dynamic_lru[i][j]);
+   }
+   }
+   spin_lock(>lru_lock);
+   list_add_tail(_lru->vm_lru_list, >vm_lru_list);
+   spin_unlock(>lru_lock);
+
+   vm_lru->resv = resv;
+
+   return 0;
+}
+
+int amdgpu_vm_lru_fini(struct amdgpu_vm_lru *vm_lru, struct amdgpu_device 
*adev)
+{
+   struct ttm_bo_global *glob = adev->mman.bdev.glob;
+
+   spin_lock(>lru_lock);
+   list_del(_lru->vm_lru_list);
+   spin_unlock(>lru_lock);
+
+   return 0;
+}
+
 struct ttm_buffer_object *amdgpu_vm_get_evictable_bo(struct ttm_bo_device 
*bdev,
 uint32_t mem_type,
 const struct ttm_place 
*place,
@@ -2413,6 +2446,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct 
amdgpu_vm *vm,
uint64_t flags;
int r, i;
 
+   amdgpu_vm_lru_init(>vm_lru, adev, NULL);
vm->va = RB_ROOT_CACHED;
for (i = 0; i < AMDGPU_MAX_VMHUBS; i++)
vm->reserved_vmid[i] = NULL;
@@ -2468,7 +2502,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct 
amdgpu_vm *vm,
r = amdgpu_bo_create(adev, , );
if (r)
goto error_free_sched_entity;
-
+   vm->vm_lru.resv = root->tbo.resv;
r = amdgpu_bo_reserve(root, true);
if (r)
goto error_free_root;
@@ -2672,6 +2706,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct 
amdgpu_vm *vm)
  adev->vm_manager.root_level);
amdgpu_bo_unreserve(root);
}
+   amdgpu_vm_lru_fini(>vm_lru, adev);
amdgpu_bo_unref();
dma_fence_put(vm->last_update);

[PATCH 03/13] drm/amdgpu: add lru backend for amdgpu driver

2018-05-09 Thread Chunming Zhou
Change-Id: I4ee2abf1ddf5c0fe59c5803da51e99bb57388d05
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c |  4 
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  | 25 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h  |  9 +
 3 files changed, 38 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index dfd22db13fb1..0bbb1dfdceff 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1279,6 +1279,10 @@ static struct ttm_bo_driver amdgpu_bo_driver = {
.invalidate_caches = _invalidate_caches,
.init_mem_type = _init_mem_type,
.eviction_valuable = amdgpu_ttm_bo_eviction_valuable,
+   .get_evictable_bo = _vm_get_evictable_bo,
+   .add_to_lru = _vm_add_to_lru,
+   .del_from_lru = _vm_del_from_lru,
+   .move_to_lru_tail = _vm_move_to_lru_tail,
.evict_flags = _evict_flags,
.move = _bo_move,
.verify_access = _verify_access,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 8e71d3984016..cc6093233ae7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -124,6 +124,31 @@ static void amdgpu_vm_bo_base_init(struct 
amdgpu_vm_bo_base *base,
spin_unlock(>status_lock);
 }
 
+struct ttm_buffer_object *amdgpu_vm_get_evictable_bo(struct ttm_bo_device 
*bdev,
+uint32_t mem_type,
+const struct ttm_place 
*place,
+struct ttm_operation_ctx 
*ctx,
+bool *locked)
+{
+
+}
+
+void amdgpu_vm_add_to_lru(struct ttm_buffer_object *bo)
+{
+
+}
+
+void amdgpu_vm_del_from_lru(struct ttm_buffer_object *bo)
+{
+
+}
+
+void amdgpu_vm_move_to_lru_tail(struct ttm_buffer_object *bo)
+{
+
+}
+
+
 /**
  * amdgpu_vm_level_shift - return the addr shift for each level
  *
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 30f080364c97..0c965683faba 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -256,6 +256,15 @@ struct amdgpu_vm_manager {
spinlock_t  pasid_lock;
 };
 
+struct ttm_buffer_object *amdgpu_vm_get_evictable_bo(struct ttm_bo_device 
*bdev,
+uint32_t mem_type,
+const struct ttm_place 
*place,
+struct ttm_operation_ctx 
*ctx,
+bool *locked);
+void amdgpu_vm_add_to_lru(struct ttm_buffer_object *bo);
+void amdgpu_vm_del_from_lru(struct ttm_buffer_object *bo);
+void amdgpu_vm_move_to_lru_tail(struct ttm_buffer_object *bo);
+
 void amdgpu_vm_manager_init(struct amdgpu_device *adev);
 void amdgpu_vm_manager_fini(struct amdgpu_device *adev);
 int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
-- 
2.14.1

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


[PATCH 01/13] ttm: abstruct evictable bo

2018-05-09 Thread Chunming Zhou
Change-Id: Ie81985282fab1e564fc2948109fae2173613b465
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 35 ---
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 98e06f8bf23b..15506682a0be 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -704,22 +704,20 @@ static bool ttm_bo_evict_swapout_allowable(struct 
ttm_buffer_object *bo,
return ret;
 }
 
-static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
-  uint32_t mem_type,
-  const struct ttm_place *place,
-  struct ttm_operation_ctx *ctx)
+static struct ttm_buffer_object *
+ttm_mem_get_evictable_bo(struct ttm_bo_device *bdev,
+uint32_t mem_type,
+const struct ttm_place *place,
+struct ttm_operation_ctx *ctx,
+bool *locked)
 {
-   struct ttm_bo_global *glob = bdev->glob;
-   struct ttm_mem_type_manager *man = >man[mem_type];
struct ttm_buffer_object *bo = NULL;
-   bool locked = false;
-   unsigned i;
-   int ret;
+   struct ttm_mem_type_manager *man = >man[mem_type];
+   int i;
 
-   spin_lock(>lru_lock);
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
list_for_each_entry(bo, >lru[i], lru) {
-   if (!ttm_bo_evict_swapout_allowable(bo, ctx, ))
+   if (!ttm_bo_evict_swapout_allowable(bo, ctx, locked))
continue;
 
if (place && !bdev->driver->eviction_valuable(bo,
@@ -738,6 +736,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
bo = NULL;
}
 
+   return bo;
+}
+
+static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
+  uint32_t mem_type,
+  const struct ttm_place *place,
+  struct ttm_operation_ctx *ctx)
+{
+   struct ttm_bo_global *glob = bdev->glob;
+   struct ttm_buffer_object *bo = NULL;
+   bool locked = false;
+   int ret;
+
+   spin_lock(>lru_lock);
+   bo = ttm_mem_get_evictable_bo(bdev, mem_type, place, ctx, );
if (!bo) {
spin_unlock(>lru_lock);
return -EBUSY;
-- 
2.14.1

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


[PATCH 00/13] *** per vm lru ***

2018-05-09 Thread Chunming Zhou
move implemenation from ttm to amdgpu driver. (suggested by Christian)
per-vm-lru is because of per-vm-bo, which has no chance to refresh lru, the 
nagtive effect is game performance isn't stable.
so all per-vm-bo should have a default order, every per-vm-bo has its priority, 
relying on its creation index.
When doing CS, if any normal bo is used, then all per-vm-bo should be used, so 
per-vm-bo prioirty >= normal bo priority.

Above is per-vm-lru starting point.



Chunming Zhou (13):
  ttm: abstruct evictable bo
  ttm: allow driver has own lru policy
  drm/amdgpu: add lru backend for amdgpu driver
  drm/amdgpu: init/fini vm lru
  drm/amdgpu: pass vm lru to buffer object
  drm/amdgpu: add amdgpu lru implementation
  drm/ttm: export ttm_bo_ref_bug
  drm/amdgpu: use RB tree instead of link list
  drm/amdgpu: add bo index counter
  drm/amdgpu: bulk move per vm bo
  ttm: export ttm_transfered_destroy
  drm/amdgpu: transferred bo doesn't use vm lru
  drm/amdgpu: free vm lru when vm fini

 drivers/gpu/drm/amd/amdgpu/amdgpu.h|   5 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c|  14 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |   9 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |   4 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|   7 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 242 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h |  25 +++
 drivers/gpu/drm/ttm/ttm_bo.c   |  92 +++
 drivers/gpu/drm/ttm/ttm_bo_util.c  |   3 +-
 include/drm/ttm/ttm_bo_driver.h|  52 +++
 12 files changed, 419 insertions(+), 37 deletions(-)

-- 
2.14.1

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


[PATCH 02/13] ttm: allow driver has own lru policy

2018-05-09 Thread Chunming Zhou
general ttm lru cannot statisfy amdgpu per-vm-bo requirement,
we have to adapt it in amdgpu driver at least.

Change-Id: I92b2286ef507c2e055ad9101cf31279d5f8db475
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/ttm/ttm_bo.c| 54 ++---
 include/drm/ttm/ttm_bo_driver.h | 49 +
 2 files changed, 89 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 15506682a0be..98da2cf63c9b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -164,6 +164,8 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
 
reservation_object_assert_held(bo->resv);
 
+   if (bdev->driver->add_to_lru)
+   return bdev->driver->add_to_lru(bo);
if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
BUG_ON(!list_empty(>lru));
 
@@ -188,6 +190,8 @@ static void ttm_bo_ref_bug(struct kref *list_kref)
 
 void ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
 {
+   struct ttm_bo_device *bdev = bo->bdev;
+
if (!list_empty(>swap)) {
list_del_init(>swap);
kref_put(>list_kref, ttm_bo_ref_bug);
@@ -201,6 +205,8 @@ void ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
 * TODO: Add a driver hook to delete from
 * driver-specific LRU's here.
 */
+   if (bdev->driver->del_from_lru)
+   return bdev->driver->del_from_lru(bo);
 }
 
 void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo)
@@ -215,10 +221,14 @@ EXPORT_SYMBOL(ttm_bo_del_sub_from_lru);
 
 void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo)
 {
+   struct ttm_bo_device *bdev = bo->bdev;
+
reservation_object_assert_held(bo->resv);
 
ttm_bo_del_from_lru(bo);
ttm_bo_add_to_lru(bo);
+   if (bdev->driver->move_to_lru_tail)
+   return bdev->driver->move_to_lru_tail(bo);
 }
 EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
 
@@ -685,8 +695,8 @@ EXPORT_SYMBOL(ttm_bo_eviction_valuable);
  *
  * b. Otherwise, trylock it.
  */
-static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
-   struct ttm_operation_ctx *ctx, bool *locked)
+bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
+   struct ttm_operation_ctx *ctx, bool *locked)
 {
bool ret = false;
 
@@ -703,6 +713,7 @@ static bool ttm_bo_evict_swapout_allowable(struct 
ttm_buffer_object *bo,
 
return ret;
 }
+EXPORT_SYMBOL(ttm_bo_evict_swapout_allowable);
 
 static struct ttm_buffer_object *
 ttm_mem_get_evictable_bo(struct ttm_bo_device *bdev,
@@ -736,6 +747,9 @@ ttm_mem_get_evictable_bo(struct ttm_bo_device *bdev,
bo = NULL;
}
 
+   if (!bo && bdev->driver->get_evictable_bo)
+   bo= bdev->driver->get_evictable_bo(bdev, mem_type, place,
+  ctx, locked);
return bo;
 }
 
@@ -1311,6 +1325,21 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
 }
 EXPORT_SYMBOL(ttm_bo_create);
 
+bool ttm_lru_empty(struct ttm_bo_device *bdev, unsigned mem_type)
+{
+   struct ttm_mem_type_manager *man = >man[mem_type];
+   int i;
+
+   for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
+   if (!list_empty(>lru[i]))
+   return false;
+   }
+   if (bdev->driver->lru_empty)
+   return bdev->driver->lru_empty(bdev, mem_type);
+
+   return true;
+}
+
 static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
   unsigned mem_type)
 {
@@ -1323,21 +1352,18 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device 
*bdev,
struct ttm_bo_global *glob = bdev->glob;
struct dma_fence *fence;
int ret;
-   unsigned i;
 
/*
 * Can't use standard list traversal since we're unlocking.
 */
 
spin_lock(>lru_lock);
-   for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
-   while (!list_empty(>lru[i])) {
-   spin_unlock(>lru_lock);
-   ret = ttm_mem_evict_first(bdev, mem_type, NULL, );
-   if (ret)
-   return ret;
-   spin_lock(>lru_lock);
-   }
+   while (!ttm_lru_empty(bdev, mem_type)) {
+   spin_unlock(>lru_lock);
+   ret = ttm_mem_evict_first(bdev, mem_type, NULL, );
+   if (ret)
+   return ret;
+   spin_lock(>lru_lock);
}
spin_unlock(>lru_lock);
 
@@ -1533,9 +1559,9 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
pr_debug("Delayed destroy list was clean\n");
 
spin_lock(>lru_lock);
-   for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
-   if (list_empty(>man[0].lru[0]))
-   pr_debug("Swap list %d was clean\n", i);
+