Re: [PATCH v2] drm/amdgpu: Remove two redundant null pointer checks

2019-09-04 Thread Zhou, David(ChunMing)

On 2019/9/5 下午1:49, zhong jiang wrote:
> The functions "debugfs_remove" and "kfree" tolerate the passing
> of null pointers. Hence it is unnecessary to check such arguments
> around the calls. Thus remove the extra condition check at two places.
>
> Signed-off-by: zhong jiang 

Reviewed-by: Chunming Zhou 


> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 6 ++
>   1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> index 5652cc7..cb94627 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> @@ -1077,8 +1077,7 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 
> val)
>   
>   ttm_bo_unlock_delayed_workqueue(>mman.bdev, resched);
>   
> - if (fences)
> - kfree(fences);
> + kfree(fences);
>   
>   return 0;
>   }
> @@ -1103,8 +1102,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
>   
>   void amdgpu_debugfs_preempt_cleanup(struct amdgpu_device *adev)
>   {
> - if (adev->debugfs_preempt)
> - debugfs_remove(adev->debugfs_preempt);
> + debugfs_remove(adev->debugfs_preempt);
>   }
>   
>   #else


RE: [PATCH 25/44] tools headers UAPI: Sync drm/drm.h with the kernel

2019-05-27 Thread Zhou, David(ChunMing)
Which branch are you based? Seems all the structs are already synced except 
DRM_CAP_SYNCOBJ_TIMELINE.

-David

-Original Message-
From: Arnaldo Carvalho de Melo  
Sent: Tuesday, May 28, 2019 6:37 AM
To: Ingo Molnar ; Thomas Gleixner 
Cc: Jiri Olsa ; Namhyung Kim ; Clark 
Williams ; linux-kernel@vger.kernel.org; 
linux-perf-us...@vger.kernel.org; Arnaldo Carvalho de Melo ; 
Adrian Hunter ; Brendan Gregg 
; Koenig, Christian ; 
Zhou, David(ChunMing) ; Dave Airlie ; 
Lionel Landwerlin ; Luis Cláudio Gonçalves 

Subject: [PATCH 25/44] tools headers UAPI: Sync drm/drm.h with the kernel

From: Arnaldo Carvalho de Melo 

To pick up the changes in these csets:

  060cebb20cdb ("drm: introduce a capability flag for syncobj timeline support")
  50d1ebef79ef ("drm/syncobj: add timeline signal ioctl for syncobj v5")
  ea569910cbab ("drm/syncobj: add transition iotcls between binary and timeline 
v2")
  27b575a9aa2f ("drm/syncobj: add timeline payload query ioctl v6")
  01d6c3578379 ("drm/syncobj: add support for timeline point wait v8")
  783195ec1cad ("drm/syncobj: disable the timeline UAPI for now v2")
  48197bc564c7 ("drm: add syncobj timeline support v9")

Which automagically results in the following new ioctls being recognized by the 
'perf trace' ioctl cmd arg beautifier:

  $ tools/perf/trace/beauty/drm_ioctl.sh > /tmp/before
  $ cp include/uapi/drm/drm.h tools/include/uapi/drm/drm.h
  $ tools/perf/trace/beauty/drm_ioctl.sh > /tmp/after
  $ diff -u /tmp/before /tmp/after
  --- /tmp/before   2019-05-22 10:25:31.443151182 -0300
  +++ /tmp/after2019-05-22 10:25:46.449354819 -0300
  @@ -103,6 +103,10 @@
[0xC7] = "MODE_LIST_LESSEES",
[0xC8] = "MODE_GET_LEASE",
[0xC9] = "MODE_REVOKE_LEASE",
  + [0xCA] = "SYNCOBJ_TIMELINE_WAIT",
  + [0xCB] = "SYNCOBJ_QUERY",
  + [0xCC] = "SYNCOBJ_TRANSFER",
  + [0xCD] = "SYNCOBJ_TIMELINE_SIGNAL",
[DRM_COMMAND_BASE + 0x00] = "I915_INIT",
[DRM_COMMAND_BASE + 0x01] = "I915_FLUSH",
[DRM_COMMAND_BASE + 0x02] = "I915_FLIP",
$

I.e. the strace like raw_tracepoint:sys_enter handler in 'perf trace'
will get the cmd integer value and map it to the string.

At some point it should be possible to translate from string to integer and use 
to filter using expressions such as:

   # perf trace -e ioctl/cmd==DRM_IOCTL_SYNCOBJ*/

Or some more suitable syntax to express that only these ioctls when acting on 
DRM fds should be shown.

Cc: Adrian Hunter 
Cc: Brendan Gregg 
Cc: Christian König 
Cc: Chunming Zhou 
Cc: Dave Airlie 
Cc: Jiri Olsa 
Cc: Lionel Landwerlin 
Cc: Luis Cláudio Gonçalves 
Cc: Namhyung Kim 
Link: https://lkml.kernel.org/n/tip-jrc9ogw33w4zgqc3pu7o1...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/include/uapi/drm/drm.h | 37 
 1 file changed, 37 insertions(+)

diff --git a/tools/include/uapi/drm/drm.h b/tools/include/uapi/drm/drm.h index 
300f336633f2..661d73f9a919 100644
--- a/tools/include/uapi/drm/drm.h
+++ b/tools/include/uapi/drm/drm.h
@@ -649,6 +649,7 @@ struct drm_gem_open {
 #define DRM_CAP_PAGE_FLIP_TARGET   0x11
 #define DRM_CAP_CRTC_IN_VBLANK_EVENT   0x12
 #define DRM_CAP_SYNCOBJ0x13
+#define DRM_CAP_SYNCOBJ_TIMELINE   0x14
 
 /** DRM_IOCTL_GET_CAP ioctl argument type */  struct drm_get_cap { @@ -735,8 
+736,18 @@ struct drm_syncobj_handle {
__u32 pad;
 };
 
+struct drm_syncobj_transfer {
+   __u32 src_handle;
+   __u32 dst_handle;
+   __u64 src_point;
+   __u64 dst_point;
+   __u32 flags;
+   __u32 pad;
+};
+
 #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)  #define 
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)
+#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 2) /* wait for time 
+point to become available */
 struct drm_syncobj_wait {
__u64 handles;
/* absolute timeout */
@@ -747,12 +758,33 @@ struct drm_syncobj_wait {
__u32 pad;
 };
 
+struct drm_syncobj_timeline_wait {
+   __u64 handles;
+   /* wait on specific timeline point for every handles*/
+   __u64 points;
+   /* absolute timeout */
+   __s64 timeout_nsec;
+   __u32 count_handles;
+   __u32 flags;
+   __u32 first_signaled; /* only valid when not waiting all */
+   __u32 pad;
+};
+
+
 struct drm_syncobj_array {
__u64 handles;
__u32 count_handles;
__u32 pad;
 };
 
+struct drm_syncobj_timeline_array {
+   __u64 handles;
+   __u64 points;
+   __u32 count_handles;
+   __u32 pad;
+};
+
+
 /* Query current scanout sequence number */  struct drm_crtc_get_sequence {
__u32 crtc_id;  /* requested crtc_id */
@@ -909,6 +941,11 @@ extern "C" {
 #define DRM_IOCTL_MODE_GET_LEASE   DRM_IOWR(0xC8, struct 

RE: [PATCH] drm/amdgpu: Error handling issues about CHECKED_RETURN

2019-02-13 Thread Zhou, David(ChunMing)



> -Original Message-
> From: Bo YU 
> Sent: Thursday, February 14, 2019 12:46 PM
> To: Deucher, Alexander ; Koenig, Christian
> ; Zhou, David(ChunMing)
> ; airl...@linux.ie; dan...@ffwll.ch; Zhu, Rex
> ; Grodzovsky, Andrey
> ; dri-de...@lists.freedesktop.org; linux-
> ker...@vger.kernel.org
> Cc: Bo Yu ; amd-...@lists.freedesktop.org
> Subject: [PATCH] drm/amdgpu: Error handling issues about
> CHECKED_RETURN
> 
> From: Bo Yu 
> 
> Calling "amdgpu_ring_test_helper" without checking return value

We could need to continue to ring test even there is one ring test failed.

-David

> 
> Signed-off-by: Bo Yu 
> ---
>  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> index 57cb3a51bda7..48465a61516b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> @@ -4728,7 +4728,9 @@ static int gfx_v8_0_cp_test_all_rings(struct
> amdgpu_device *adev)
> 
>   for (i = 0; i < adev->gfx.num_compute_rings; i++) {
>   ring = >gfx.compute_ring[i];
> - amdgpu_ring_test_helper(ring);
> + r = amdgpu_ring_test_helper(ring);
> + if (r)
> + return r;
>   }
> 
>   return 0;
> --
> 2.11.0



RE: [PATCH -next] drm/amdgpu: remove set but not used variable 'grbm_soft_reset'

2018-12-09 Thread Zhou, David(ChunMing)



> -Original Message-
> From: YueHaibing 
> Sent: Saturday, December 08, 2018 11:01 PM
> To: Deucher, Alexander ; Koenig, Christian
> ; Zhou, David(ChunMing)
> ; airl...@linux.ie; Liu, Leo ;
> Gao, Likun ; Panariti, David
> ; S, Shirish ; Zhu, Rex
> ; Grodzovsky, Andrey 
> Cc: YueHaibing ; amd-...@lists.freedesktop.org;
> dri-de...@lists.freedesktop.org; linux-kernel@vger.kernel.org; kernel-
> janit...@vger.kernel.org
> Subject: [PATCH -next] drm/amdgpu: remove set but not used variable
> 'grbm_soft_reset'
> 
> Fixes gcc '-Wunused-but-set-variable' warning:
> 
> drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c: In function
> 'gfx_v8_0_pre_soft_reset':
> drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c:4950:27: warning:
>  variable 'srbm_soft_reset' set but not used [-Wunused-but-set-variable]
> 
> drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c: In function
> 'gfx_v8_0_post_soft_reset':
> drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c:5054:27: warning:
>  variable 'srbm_soft_reset' set but not used [-Wunused-but-set-variable]
> 
> It never used since introduction in commit d31a501ead7f ("drm/amdgpu: add
> pre_soft_reset ip func") and e4ae0fc33631 ("drm/amdgpu: implement
> gfx8 post_soft_reset")
> 
> Signed-off-by: YueHaibing 

Reviewed-by: Chunming Zhou 

> ---
>  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> index 1454fc3..8c1ba79 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> @@ -4947,14 +4947,13 @@ static bool gfx_v8_0_check_soft_reset(void
> *handle)  static int gfx_v8_0_pre_soft_reset(void *handle)  {
>   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> - u32 grbm_soft_reset = 0, srbm_soft_reset = 0;
> + u32 grbm_soft_reset = 0;
> 
>   if ((!adev->gfx.grbm_soft_reset) &&
>   (!adev->gfx.srbm_soft_reset))
>   return 0;
> 
>   grbm_soft_reset = adev->gfx.grbm_soft_reset;
> - srbm_soft_reset = adev->gfx.srbm_soft_reset;
> 
>   /* stop the rlc */
>   adev->gfx.rlc.funcs->stop(adev);
> @@ -5051,14 +5050,13 @@ static int gfx_v8_0_soft_reset(void *handle)
> static int gfx_v8_0_post_soft_reset(void *handle)  {
>   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> - u32 grbm_soft_reset = 0, srbm_soft_reset = 0;
> + u32 grbm_soft_reset = 0;
> 
>   if ((!adev->gfx.grbm_soft_reset) &&
>   (!adev->gfx.srbm_soft_reset))
>   return 0;
> 
>   grbm_soft_reset = adev->gfx.grbm_soft_reset;
> - srbm_soft_reset = adev->gfx.srbm_soft_reset;
> 
>   if (REG_GET_FIELD(grbm_soft_reset, GRBM_SOFT_RESET,
> SOFT_RESET_CP) ||
>   REG_GET_FIELD(grbm_soft_reset, GRBM_SOFT_RESET,
> SOFT_RESET_CPF) ||
> 
> 



RE: [PATCH 4/4] drm/amdgpu: resize VRAM BAR for CPU access

2017-03-15 Thread Zhou, David(ChunMing)
Does that means we don't need invisible vram later?

David

-Original Message-
From: dri-devel [mailto:dri-devel-boun...@lists.freedesktop.org] On Behalf Of 
Christian K?nig
Sent: Wednesday, March 15, 2017 3:38 PM
To: Ayyappa Ch 
Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org; 
amd-...@lists.freedesktop.org; platform-driver-...@vger.kernel.org; 
helg...@kernel.org; dri-de...@lists.freedesktop.org
Subject: Re: [PATCH 4/4] drm/amdgpu: resize VRAM BAR for CPU access

Carizzo is an APU and resizing BARs isn't needed nor supported there. 
The CPU can access the full stolen VRAM directly on that hardware.

As far as I know ASICs with support for this are Tonga, Fiji and all Polaris 
variants.

Christian.

Am 15.03.2017 um 08:23 schrieb Ayyappa Ch:
> Is it possible on Carrizo asics? Or only supports on newer asics?
>
> On Mon, Mar 13, 2017 at 6:11 PM, Christian König 
>  wrote:
>> From: Christian König 
>>
>> Try to resize BAR0 to let CPU access all of VRAM.
>>
>> Signed-off-by: Christian König 
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu.h|  1 +
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 29 
>> +
>>   drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c  |  8 +---
>>   drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c  |  8 +---
>>   4 files changed, 40 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> index 3b81ded..905ded9 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> @@ -1719,6 +1719,7 @@ uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device 
>> *adev, struct ttm_tt *ttm,
>>   struct ttm_mem_reg *mem);
>>   void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc 
>> *mc, u64 base);
>>   void amdgpu_gtt_location(struct amdgpu_device *adev, struct 
>> amdgpu_mc *mc);
>> +void amdgpu_resize_bar0(struct amdgpu_device *adev);
>>   void amdgpu_ttm_set_active_vram_size(struct amdgpu_device *adev, u64 size);
>>   int amdgpu_ttm_init(struct amdgpu_device *adev);
>>   void amdgpu_ttm_fini(struct amdgpu_device *adev); diff --git 
>> a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> index 118f4e6..92955fe 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> @@ -692,6 +692,35 @@ void amdgpu_gtt_location(struct amdgpu_device *adev, 
>> struct amdgpu_mc *mc)
>>  mc->gtt_size >> 20, mc->gtt_start, mc->gtt_end);
>>   }
>>
>> +/**
>> + * amdgpu_resize_bar0 - try to resize BAR0
>> + *
>> + * @adev: amdgpu_device pointer
>> + *
>> + * Try to resize BAR0 to make all VRAM CPU accessible.
>> + */
>> +void amdgpu_resize_bar0(struct amdgpu_device *adev) {
>> +   u32 size = max(ilog2(adev->mc.real_vram_size - 1) + 1, 20) - 20;
>> +   int r;
>> +
>> +   r = pci_resize_resource(adev->pdev, 0, size);
>> +
>> +   if (r == -ENOTSUPP) {
>> +   /* The hardware don't support the extension. */
>> +   return;
>> +
>> +   } else if (r == -ENOSPC) {
>> +   DRM_INFO("Not enoigh PCI address space for a large BAR.");
>> +   } else if (r) {
>> +   DRM_ERROR("Problem resizing BAR0 (%d).", r);
>> +   }
>> +
>> +   /* Reinit the doorbell mapping, it is most likely moved as well */
>> +   amdgpu_doorbell_fini(adev);
>> +   BUG_ON(amdgpu_doorbell_init(adev));
>> +}
>> +
>>   /*
>>* GPU helpers function.
>>*/
>> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c 
>> b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
>> index dc9b6d6..36a7aa5 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
>> @@ -367,13 +367,15 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev)
>>  break;
>>  }
>>  adev->mc.vram_width = numchan * chansize;
>> -   /* Could aper size report 0 ? */
>> -   adev->mc.aper_base = pci_resource_start(adev->pdev, 0);
>> -   adev->mc.aper_size = pci_resource_len(adev->pdev, 0);
>>  /* size in MB on si */
>>  adev->mc.mc_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 
>> 1024ULL;
>>  adev->mc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL 
>> * 1024ULL;
>>
>> +   if (!(adev->flags & AMD_IS_APU))
>> +   amdgpu_resize_bar0(adev);
>> +   adev->mc.aper_base = pci_resource_start(adev->pdev, 0);
>> +   adev->mc.aper_size = pci_resource_len(adev->pdev, 0);
>> +
>>   #ifdef CONFIG_X86_64
>>  if (adev->flags & AMD_IS_APU) {
>>  adev->mc.aper_base = 
>> ((u64)RREG32(mmMC_VM_FB_OFFSET)) << 22; diff --git 
>> a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c 
>> b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>> index c087b00..7761ad3 100644
>> --- 

RE: [PATCH 4/4] drm/amdgpu: resize VRAM BAR for CPU access

2017-03-15 Thread Zhou, David(ChunMing)
Does that means we don't need invisible vram later?

David

-Original Message-
From: dri-devel [mailto:dri-devel-boun...@lists.freedesktop.org] On Behalf Of 
Christian K?nig
Sent: Wednesday, March 15, 2017 3:38 PM
To: Ayyappa Ch 
Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org; 
amd-...@lists.freedesktop.org; platform-driver-...@vger.kernel.org; 
helg...@kernel.org; dri-de...@lists.freedesktop.org
Subject: Re: [PATCH 4/4] drm/amdgpu: resize VRAM BAR for CPU access

Carizzo is an APU and resizing BARs isn't needed nor supported there. 
The CPU can access the full stolen VRAM directly on that hardware.

As far as I know ASICs with support for this are Tonga, Fiji and all Polaris 
variants.

Christian.

Am 15.03.2017 um 08:23 schrieb Ayyappa Ch:
> Is it possible on Carrizo asics? Or only supports on newer asics?
>
> On Mon, Mar 13, 2017 at 6:11 PM, Christian König 
>  wrote:
>> From: Christian König 
>>
>> Try to resize BAR0 to let CPU access all of VRAM.
>>
>> Signed-off-by: Christian König 
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu.h|  1 +
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 29 
>> +
>>   drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c  |  8 +---
>>   drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c  |  8 +---
>>   4 files changed, 40 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> index 3b81ded..905ded9 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> @@ -1719,6 +1719,7 @@ uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device 
>> *adev, struct ttm_tt *ttm,
>>   struct ttm_mem_reg *mem);
>>   void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc 
>> *mc, u64 base);
>>   void amdgpu_gtt_location(struct amdgpu_device *adev, struct 
>> amdgpu_mc *mc);
>> +void amdgpu_resize_bar0(struct amdgpu_device *adev);
>>   void amdgpu_ttm_set_active_vram_size(struct amdgpu_device *adev, u64 size);
>>   int amdgpu_ttm_init(struct amdgpu_device *adev);
>>   void amdgpu_ttm_fini(struct amdgpu_device *adev); diff --git 
>> a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> index 118f4e6..92955fe 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> @@ -692,6 +692,35 @@ void amdgpu_gtt_location(struct amdgpu_device *adev, 
>> struct amdgpu_mc *mc)
>>  mc->gtt_size >> 20, mc->gtt_start, mc->gtt_end);
>>   }
>>
>> +/**
>> + * amdgpu_resize_bar0 - try to resize BAR0
>> + *
>> + * @adev: amdgpu_device pointer
>> + *
>> + * Try to resize BAR0 to make all VRAM CPU accessible.
>> + */
>> +void amdgpu_resize_bar0(struct amdgpu_device *adev) {
>> +   u32 size = max(ilog2(adev->mc.real_vram_size - 1) + 1, 20) - 20;
>> +   int r;
>> +
>> +   r = pci_resize_resource(adev->pdev, 0, size);
>> +
>> +   if (r == -ENOTSUPP) {
>> +   /* The hardware don't support the extension. */
>> +   return;
>> +
>> +   } else if (r == -ENOSPC) {
>> +   DRM_INFO("Not enoigh PCI address space for a large BAR.");
>> +   } else if (r) {
>> +   DRM_ERROR("Problem resizing BAR0 (%d).", r);
>> +   }
>> +
>> +   /* Reinit the doorbell mapping, it is most likely moved as well */
>> +   amdgpu_doorbell_fini(adev);
>> +   BUG_ON(amdgpu_doorbell_init(adev));
>> +}
>> +
>>   /*
>>* GPU helpers function.
>>*/
>> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c 
>> b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
>> index dc9b6d6..36a7aa5 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
>> @@ -367,13 +367,15 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev)
>>  break;
>>  }
>>  adev->mc.vram_width = numchan * chansize;
>> -   /* Could aper size report 0 ? */
>> -   adev->mc.aper_base = pci_resource_start(adev->pdev, 0);
>> -   adev->mc.aper_size = pci_resource_len(adev->pdev, 0);
>>  /* size in MB on si */
>>  adev->mc.mc_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 
>> 1024ULL;
>>  adev->mc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL 
>> * 1024ULL;
>>
>> +   if (!(adev->flags & AMD_IS_APU))
>> +   amdgpu_resize_bar0(adev);
>> +   adev->mc.aper_base = pci_resource_start(adev->pdev, 0);
>> +   adev->mc.aper_size = pci_resource_len(adev->pdev, 0);
>> +
>>   #ifdef CONFIG_X86_64
>>  if (adev->flags & AMD_IS_APU) {
>>  adev->mc.aper_base = 
>> ((u64)RREG32(mmMC_VM_FB_OFFSET)) << 22; diff --git 
>> a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c 
>> b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>> index c087b00..7761ad3 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>> @@ -459,13 +459,15 

RE: [PATCH] drm/amd/amdgpu: fix spelling mistake: "comleted" -> "completed"

2016-12-29 Thread Zhou, David(ChunMing)
+amd-gfx, patch is Reviewed-by: Chunming Zhou <david1.z...@amd.com>

-Original Message-
From: Colin King [mailto:colin.k...@canonical.com] 
Sent: Thursday, December 29, 2016 11:47 PM
To: Deucher, Alexander <alexander.deuc...@amd.com>; Koenig, Christian 
<christian.koe...@amd.com>; David Airlie <airl...@linux.ie>; Zhou, 
David(ChunMing) <david1.z...@amd.com>; StDenis, Tom <tom.stde...@amd.com>; Liu, 
Monk <monk@amd.com>; dri-de...@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] drm/amd/amdgpu: fix spelling mistake: "comleted" -> "completed"

From: Colin Ian King <colin.k...@canonical.com>

trivial fix to spelling mistake in WARN message

Signed-off-by: Colin Ian King <colin.k...@canonical.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 60bd4af..9ca3167 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2335,7 +2335,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
if (fence) {
r = dma_fence_wait(fence, false);
if (r) {
-   WARN(r, "recovery from shadow 
isn't comleted\n");
+   WARN(r, "recovery from shadow 
isn't completed\n");
break;
}
}
@@ -2347,7 +2347,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
if (fence) {
r = dma_fence_wait(fence, false);
if (r)
-   WARN(r, "recovery from shadow isn't 
comleted\n");
+   WARN(r, "recovery from shadow isn't 
completed\n");
}
dma_fence_put(fence);
}
-- 
2.10.2



RE: [PATCH] drm/amd/amdgpu: fix spelling mistake: "comleted" -> "completed"

2016-12-29 Thread Zhou, David(ChunMing)
+amd-gfx, patch is Reviewed-by: Chunming Zhou 

-Original Message-
From: Colin King [mailto:colin.k...@canonical.com] 
Sent: Thursday, December 29, 2016 11:47 PM
To: Deucher, Alexander ; Koenig, Christian 
; David Airlie ; Zhou, 
David(ChunMing) ; StDenis, Tom ; Liu, 
Monk ; dri-de...@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] drm/amd/amdgpu: fix spelling mistake: "comleted" -> "completed"

From: Colin Ian King 

trivial fix to spelling mistake in WARN message

Signed-off-by: Colin Ian King 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 60bd4af..9ca3167 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2335,7 +2335,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
if (fence) {
r = dma_fence_wait(fence, false);
if (r) {
-   WARN(r, "recovery from shadow 
isn't comleted\n");
+   WARN(r, "recovery from shadow 
isn't completed\n");
break;
}
}
@@ -2347,7 +2347,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
if (fence) {
r = dma_fence_wait(fence, false);
if (r)
-   WARN(r, "recovery from shadow isn't 
comleted\n");
+   WARN(r, "recovery from shadow isn't 
completed\n");
}
dma_fence_put(fence);
}
-- 
2.10.2