Re: [PATCH] drm/ttm: fix shared slot reservation during BO creation

2018-12-05 Thread StDenis, Tom
Fixes the regression I noticed.

Tested-by: Tom St Denis 


On 2018-12-05 3:38 a.m., Christian König wrote:
> Make sure we reserve at least one slot for pipelined BO moves
> during BO creation.
> 
> Fixes: 5786b66c9e3b drm/ttm: drop the extra reservation for pipelined BO
> moves
> 
> Signed-off-by: Christian König 
> ---
>   drivers/gpu/drm/ttm/ttm_bo.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 7db66e4088e2..ffd68b039d23 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1264,6 +1264,9 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
>   WARN_ON(!locked);
>   }
>   
> + if (likely(!ret))
> + ret = reservation_object_reserve_shared(bo->resv, 1);
> +
>   if (likely(!ret))
>   ret = ttm_bo_validate(bo, placement, ctx);
>   
> 

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


Re: [PATCH 5/5] drm/amdgpu: replace iova debugfs file with iomem

2018-02-02 Thread StDenis, Tom
I haven't tried the patch but just like to point out this breaks umr :-)  I'll 
have to craft something on Monday to support this and iova in parallel until 
the iova kernels are realistically EOL'ed.

On the other hand I support this idea since it eliminates the need for an fmem 
hack.  So much appreciated.

Cheers,
Tom


From: amd-gfx  on behalf of Christian 
König 
Sent: Friday, February 2, 2018 14:09
To: amd-...@lists.freedesktop.org; dri-devel@lists.freedesktop.org
Subject: [PATCH 5/5] drm/amdgpu: replace iova debugfs file with iomem

This allows access to pages allocated through the driver with optional
IOMMU mapping.

Signed-off-by: Christian König 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 57 -
 1 file changed, 35 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 648c449aaa79..795ceaeb82d5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1929,38 +1929,51 @@ static const struct file_operations amdgpu_ttm_gtt_fops 
= {

 #endif

-static ssize_t amdgpu_iova_to_phys_read(struct file *f, char __user *buf,
-  size_t size, loff_t *pos)
+static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf,
+size_t size, loff_t *pos)
 {
struct amdgpu_device *adev = file_inode(f)->i_private;
-   int r;
-   uint64_t phys;
struct iommu_domain *dom;
+   ssize_t result = 0;
+   int r;

-   // always return 8 bytes
-   if (size != 8)
-   return -EINVAL;
+   dom = iommu_get_domain_for_dev(adev->dev);

-   // only accept page addresses
-   if (*pos & 0xFFF)
-   return -EINVAL;
+   while (size) {
+   phys_addr_t addr = *pos & PAGE_MASK;
+   loff_t off = *pos & ~PAGE_MASK;
+   size_t bytes = PAGE_SIZE - off;
+   unsigned long pfn;
+   struct page *p;
+   void *ptr;

-   dom = iommu_get_domain_for_dev(adev->dev);
-   if (dom)
-   phys = iommu_iova_to_phys(dom, *pos);
-   else
-   phys = *pos;
+   addr = dom ? iommu_iova_to_phys(dom, addr) : addr;

-   r = copy_to_user(buf, , 8);
-   if (r)
-   return -EFAULT;
+   pfn = addr >> PAGE_SHIFT;
+   if (!pfn_valid(pfn))
+   return -EPERM;
+
+   p = pfn_to_page(pfn);
+   if (p->mapping != adev->mman.bdev.dev_mapping)
+   return -EPERM;
+
+   ptr = kmap(p);
+   r = copy_to_user(buf, ptr, bytes);
+   kunmap(p);
+   if (r)
+   return -EFAULT;

-   return 8;
+   size -= bytes;
+   *pos += bytes;
+   result += bytes;
+   }
+
+   return result;
 }

-static const struct file_operations amdgpu_ttm_iova_fops = {
+static const struct file_operations amdgpu_ttm_iomem_fops = {
.owner = THIS_MODULE,
-   .read = amdgpu_iova_to_phys_read,
+   .read = amdgpu_iomem_read,
.llseek = default_llseek
 };

@@ -1973,7 +1986,7 @@ static const struct {
 #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
{ "amdgpu_gtt", _ttm_gtt_fops, TTM_PL_TT },
 #endif
-   { "amdgpu_iova", _ttm_iova_fops, TTM_PL_SYSTEM },
+   { "amdgpu_iomem", _ttm_iomem_fops, TTM_PL_SYSTEM },
 };

 #endif
--
2.14.1

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


Re: remove ttm trace and add iova debugfs (v2)

2017-09-18 Thread StDenis, Tom
Should add I was able to read/write system memory mapped by amdgpu with these 
patches in place on my polaris10 device (with iommu enabled of course).


From: amd-gfx  on behalf of Tom St Denis 

Sent: Monday, September 18, 2017 13:33
To: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Subject: remove ttm trace and add iova debugfs (v2)

In this respin I add some changes per feedback and make the iova
entry have proper read/write methods which access pages mapped
by amdgpu.  So there is no need for /dev/mem or /dev/fmem anymore
when reading system memory.

Patches 3/4 are unchanged and remove the TTM trace from amdgpu
and from TTM itself.


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


Re: [radeon-alex:drm-next-4.14-wip 39/44] drivers/gpu/drm/radeon/radeon_ttm.c:763:2: error: implicit declaration of function 'ttm_populate_and_map_pages'

2017-08-23 Thread StDenis, Tom
Odd.  I mean I had build tested it even though I don't have radeon cards to 
devel with (other than my tahiti I guess but I rarely use that).

Tom

From: Deucher, Alexander
Sent: Wednesday, August 23, 2017 17:12
To: StDenis, Tom; kbuild test robot
Cc: kbuild-...@01.org; dri-devel@lists.freedesktop.org; Koenig, Christian
Subject: RE: [radeon-alex:drm-next-4.14-wip 39/44] 
drivers/gpu/drm/radeon/radeon_ttm.c:763:2: error: implicit declaration of 
function 'ttm_populate_and_map_pages'

> -Original Message-
> From: StDenis, Tom
> Sent: Wednesday, August 23, 2017 5:08 PM
> To: kbuild test robot
> Cc: kbuild-...@01.org; dri-devel@lists.freedesktop.org; Deucher, Alexander;
> Koenig, Christian
> Subject: Re: [radeon-alex:drm-next-4.14-wip 39/44]
> drivers/gpu/drm/radeon/radeon_ttm.c:763:2: error: implicit declaration of
> function 'ttm_populate_and_map_pages'
>
> The only way this would be possible if if the commit
> d1c99475f269a85e0a1916c949526cb22b157271 didn't make it into the public
> staging tree.

It's there:
https://cgit.freedesktop.org/~agd5f/linux/commit/?h=drm-next-4.14-wip=49ad04f2eae72fe928716efe557c73d1f346b9fd
Built fine here.

Alex

>
> Tom
>
>
> 
> From: kbuild test robot <fengguang...@intel.com>
> Sent: Wednesday, August 23, 2017 16:52
> To: StDenis, Tom
> Cc: kbuild-...@01.org; dri-devel@lists.freedesktop.org; Deucher, Alexander;
> Koenig, Christian
> Subject: [radeon-alex:drm-next-4.14-wip 39/44]
> drivers/gpu/drm/radeon/radeon_ttm.c:763:2: error: implicit declaration of
> function 'ttm_populate_and_map_pages'
>
> tree:   git://people.freedesktop.org/~agd5f/linux.git drm-next-4.14-wip
> head:   9f7373596843431b63965965f1059d39600db3a2
> commit: 217dcd53c963af28d04c357aed922f1faa20 [39/44] drm/radeon:
> use new TTM populate/dma map helper functions
> config: xtensa-allmodconfig (attached as .config)
> compiler: xtensa-linux-gcc (GCC) 4.9.0
> reproduce:
> wget https://raw.githubusercontent.com/01org/lkp-
> tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> git checkout 217dcd53c963af28d04c357aed922f1faa20
> # save the attached .config to linux build tree
> make.cross ARCH=xtensa
>
> All errors (new ones prefixed by >>):
>
>drivers/gpu/drm/radeon/radeon_ttm.c: In function
> 'radeon_ttm_tt_populate':
> >> drivers/gpu/drm/radeon/radeon_ttm.c:763:2: error: implicit declaration
> of function 'ttm_populate_and_map_pages' [-Werror=implicit-function-
> declaration]
>  return ttm_populate_and_map_pages(rdev->dev, >ttm);
>  ^
>drivers/gpu/drm/radeon/radeon_ttm.c: In function
> 'radeon_ttm_tt_unpopulate':
> >> drivers/gpu/drm/radeon/radeon_ttm.c:796:2: error: implicit declaration
> of function 'ttm_unmap_and_unpopulate_pages' [-Werror=implicit-
> function-declaration]
>  ttm_unmap_and_unpopulate_pages(rdev->dev, >ttm);
>  ^
>cc1: some warnings being treated as errors
>
> vim +/ttm_populate_and_map_pages +763
> drivers/gpu/drm/radeon/radeon_ttm.c
>
>762
>  > 763  return ttm_populate_and_map_pages(rdev->dev, >ttm);
>764  }
>765
>766  static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm)
>767  {
>768  struct radeon_device *rdev;
>769  struct radeon_ttm_tt *gtt = radeon_ttm_tt_to_gtt(ttm);
>770  bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
>771
>772  if (gtt && gtt->userptr) {
>773  kfree(ttm->sg);
>774  ttm->page_flags &= ~TTM_PAGE_FLAG_SG;
>775  return;
>776  }
>777
>778  if (slave)
>779  return;
>780
>781  rdev = radeon_get_rdev(ttm->bdev);
>782  #if IS_ENABLED(CONFIG_AGP)
>783  if (rdev->flags & RADEON_IS_AGP) {
>784  ttm_agp_tt_unpopulate(ttm);
>785  return;
>786  }
>787  #endif
>788
>789  #ifdef CONFIG_SWIOTLB
>790  if (swiotlb_nr_tbl()) {
>791  ttm_dma_unpopulate(>ttm, rdev->dev);
>792  return;
>793  }
>794  #endif
>795
>  > 796  ttm_unmap_and_unpopulate_pages(rdev->dev, >ttm);
>797  }
>798
>
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [radeon-alex:drm-next-4.14-wip 39/44] drivers/gpu/drm/radeon/radeon_ttm.c:763:2: error: implicit declaration of function 'ttm_populate_and_map_pages'

2017-08-23 Thread StDenis, Tom
The only way this would be possible if if the commit 
d1c99475f269a85e0a1916c949526cb22b157271 didn't make it into the public staging 
tree.

Tom



From: kbuild test robot <fengguang...@intel.com>
Sent: Wednesday, August 23, 2017 16:52
To: StDenis, Tom
Cc: kbuild-...@01.org; dri-devel@lists.freedesktop.org; Deucher, Alexander; 
Koenig, Christian
Subject: [radeon-alex:drm-next-4.14-wip 39/44] 
drivers/gpu/drm/radeon/radeon_ttm.c:763:2: error: implicit declaration of 
function 'ttm_populate_and_map_pages'

tree:   git://people.freedesktop.org/~agd5f/linux.git drm-next-4.14-wip
head:   9f7373596843431b63965965f1059d39600db3a2
commit: 217dcd53c963af28d04c357aed922f1faa20 [39/44] drm/radeon: use new 
TTM populate/dma map helper functions
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 217dcd53c963af28d04c357aed922f1faa20
# save the attached .config to linux build tree
make.cross ARCH=xtensa

All errors (new ones prefixed by >>):

   drivers/gpu/drm/radeon/radeon_ttm.c: In function 'radeon_ttm_tt_populate':
>> drivers/gpu/drm/radeon/radeon_ttm.c:763:2: error: implicit declaration of 
>> function 'ttm_populate_and_map_pages' [-Werror=implicit-function-declaration]
 return ttm_populate_and_map_pages(rdev->dev, >ttm);
 ^
   drivers/gpu/drm/radeon/radeon_ttm.c: In function 'radeon_ttm_tt_unpopulate':
>> drivers/gpu/drm/radeon/radeon_ttm.c:796:2: error: implicit declaration of 
>> function 'ttm_unmap_and_unpopulate_pages' 
>> [-Werror=implicit-function-declaration]
 ttm_unmap_and_unpopulate_pages(rdev->dev, >ttm);
 ^
   cc1: some warnings being treated as errors

vim +/ttm_populate_and_map_pages +763 drivers/gpu/drm/radeon/radeon_ttm.c

   762
 > 763  return ttm_populate_and_map_pages(rdev->dev, >ttm);
   764  }
   765
   766  static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm)
   767  {
   768  struct radeon_device *rdev;
   769  struct radeon_ttm_tt *gtt = radeon_ttm_tt_to_gtt(ttm);
   770  bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
   771
   772  if (gtt && gtt->userptr) {
   773  kfree(ttm->sg);
   774  ttm->page_flags &= ~TTM_PAGE_FLAG_SG;
   775  return;
   776  }
   777
   778  if (slave)
   779  return;
   780
   781  rdev = radeon_get_rdev(ttm->bdev);
   782  #if IS_ENABLED(CONFIG_AGP)
   783  if (rdev->flags & RADEON_IS_AGP) {
   784  ttm_agp_tt_unpopulate(ttm);
   785  return;
   786  }
   787  #endif
   788
   789  #ifdef CONFIG_SWIOTLB
   790  if (swiotlb_nr_tbl()) {
   791  ttm_dma_unpopulate(>ttm, rdev->dev);
   792  return;
   793  }
   794  #endif
   795
 > 796  ttm_unmap_and_unpopulate_pages(rdev->dev, >ttm);
   797  }
   798

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[pull] radeon and amdgpu drm-next-4.8

2016-07-18 Thread StDenis, Tom
Hi Edward,


Just a heads up Alex is on vacation this week.


Tom



From: amd-gfx  on behalf of Edward 
O'Callaghan 
Sent: Monday, July 18, 2016 07:58
To: Alex Deucher; dri-devel at lists.freedesktop.org; amd-gfx at 
lists.freedesktop.org; airlied at gmail.com
Cc: Deucher, Alexander
Subject: Re: [pull] radeon and amdgpu drm-next-4.8

Hi Alex,

If you need me to rebase on any tip just let me know which one if that
makes life easier for you?

Cheers,
Edward.

On 07/16/2016 04:31 AM, Alex Deucher wrote:
> Hi Dave,
>
> A few more patches for 4.8.  Mostly bug fixes and some prep work
> for iceland powerplay support.  I have a couple polaris patches and
> Edward's misc cleanups that require a merge with Linus'.  I don't know
> if you are planning a merge anytime soon.
>
> The following changes since commit b1814a1def0564a2a1d3be7fa5bf7243ff899a28:
>
>   drm/amd/powerplay: don't add invalid voltage. (2016-07-07 15:06:24 -0400)
>
> are available in the git repository at:
>
>   git://people.freedesktop.org/~agd5f/linux drm-next-4.8
>
> for you to fetch changes up to 5ef8292925047ad290205af5f3ae13d0a36d774d:
>
>   drm/amdgpu: comment out unused defaults_bonaire_pro static const structures 
> to fix the build (2016-07-15 14:23:08 -0400)
>
> 
> Alex Deucher (4):
>   drm/amdgpu/powerplay: endian fixes for ppatomctrl.c
>   drm/amdgpu: support backlight control for UNIPHY3
>   drm/radeon: support backlight control for UNIPHY3
>   drm/amdgpu: disable GFX PG on CZ/BR/ST
>
> Christian König (10):
>   drm/amdgpu: sanitize fence numbers
>   drm/amdgpu: cleanup VCE coding style
>   drm/amdgpu: allow multiple sessions in the same VCE IB
>   drm/amdgpu: cleanup UVD coding style
>   drm/amdgpu: cleanup hw reference handling in the IB tests
>   drm/amdgpu: remove usec timeout loop from IB tests
>   drm/amdgpu: check flush fence context instead of same ring v2
>   drm/amdgpu: always signal all fences
>   drm/amdgpu: trace need_flush in grab_vm as well
>   drm/amdgpu: return -ENOSPC when running out of UVD handles
>
> Huang Rui (8):
>   drm/amdgpu: rename smumgr to smum for dpm
>   drm/amdgpu: no need load microcode at sdma if powerplay is enabled
>   drm/amdgpu: add ucode_start_address into cgs_firmware_info
>   drm/amd/powerplay: add SMU register macro for future use
>   drm/amdgpu: add new definitions into ppsmc.h for iceland
>   drm/amd/powerplay: add atomctrl_get_voltage_evv function in ppatomctrl
>   drm/amd/powerplay: fix the incorrect return value
>   drm/amd/powerplay: add pp_tables_get_response_times function in process 
> pptables
>
> Matthias Beyer (1):
>   drivers: gpu: drm: amd: powerplay: hwmgr: Remove unused variable
>
> Slava Grigorev (2):
>   drm/amdgpu: temporary comment out unused static const structures to fix 
> the build
>   drm/amdgpu: comment out unused defaults_bonaire_pro static const 
> structures to fix the build
>
> jimqu (1):
>   drm/amdgpu: S3 resume fail on Polaris10
>
>  drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c|   4 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c  |  17 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c |   6 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c|   8 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h  |  16 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c|  11 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c| 104 ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |  13 +-
>  drivers/gpu/drm/amd/amdgpu/atombios_encoders.c |   1 +
>  drivers/gpu/drm/amd/amdgpu/ci_dpm.c|   2 +
>  drivers/gpu/drm/amd/amdgpu/cik_sdma.c  |  18 +-
>  drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c  |  15 +-
>  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  |  16 +-
>  drivers/gpu/drm/amd/amdgpu/iceland_dpm.c   |   2 +-
>  drivers/gpu/drm/amd/amdgpu/iceland_smc.c   |   2 +-
>  .../amdgpu/{iceland_smumgr.h => iceland_smum.h}|   0
>  drivers/gpu/drm/amd/amdgpu/kv_dpm.c|   2 +
>  drivers/gpu/drm/amd/amdgpu/ppsmc.h |   4 +
>  drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c |  43 ++-
>  drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c |  15 +-
>  drivers/gpu/drm/amd/amdgpu/vce_v3_0.c  | 143 ++
>  drivers/gpu/drm/amd/amdgpu/vi.c|  14 -
>  drivers/gpu/drm/amd/include/cgs_common.h   |   4 +
>  .../gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c  |   9 +-
>  drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c   | 299 
> -
>  drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.h   |   1 +
>  .../gpu/drm/amd/powerplay/hwmgr/processpptables.c  |  13 +
>  .../gpu/drm/amd/powerplay/hwmgr/processpptables.h  |  17 +-
>  drivers/gpu/drm/amd/powerplay/inc/smumgr.h   

[PATCH] drm: amdgpu: Clean up function calls

2016-01-20 Thread StDenis, Tom
Attached is a simple patch to move a couple of memsets after variable 
declarations.


Tom St Denis
-- next part --
An HTML attachment was scrubbed...
URL: 

-- next part --
A non-text attachment was scrubbed...
Name: 0001-amdgpu-Move-memset-after-variable-declarations.patch
Type: text/x-patch
Size: 1429 bytes
Desc: 0001-amdgpu-Move-memset-after-variable-declarations.patch
URL: