Re: [radeon-alex:drm-next-4.12-wip 34/40] drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c:620:4: warning: left shift count >= width of type

2017-02-10 Thread Christian König

Mhm, guys any idea why the build bot is spamming us with that warning?

The type is 64bit and the shift is 63, so that should work fine.

Regards,
Christian.

Am 10.02.2017 um 20:48 schrieb kbuild test robot:

tree:   git://people.freedesktop.org/~agd5f/linux.git drm-next-4.12-wip
head:   d32ff0ea8e22964abcc6406e00a0646f2bfb94c7
commit: 382a21d981661dbc8198c37dc95707e1e381ce76 [34/40] drm/amdgpu: IOCTL 
interface for PRT support v4
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
 wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
 chmod +x ~/bin/make.cross
 git checkout 382a21d981661dbc8198c37dc95707e1e381ce76
 # save the attached .config to linux build tree
 make.cross ARCH=xtensa

All warnings (new ones prefixed by >>):

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c: In function 'amdgpu_gem_va_ioctl':

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c:620:4: warning: left shift count >= 
width of type

va_flags |= AMDGPU_PTE_PRT;
^

vim +620 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c

604 r = -ENOENT;
605 goto error_backoff;
606 }
607 } else {
608 bo_va = fpriv->prt_va;
609 }
610 
611 switch (args->operation) {
612 case AMDGPU_VA_OP_MAP:
613 if (args->flags & AMDGPU_VM_PAGE_READABLE)
614 va_flags |= AMDGPU_PTE_READABLE;
615 if (args->flags & AMDGPU_VM_PAGE_WRITEABLE)
616 va_flags |= AMDGPU_PTE_WRITEABLE;
617 if (args->flags & AMDGPU_VM_PAGE_EXECUTABLE)
618 va_flags |= AMDGPU_PTE_EXECUTABLE;
619 if (args->flags & AMDGPU_VM_PAGE_PRT)
  > 620  va_flags |= AMDGPU_PTE_PRT;
621 r = amdgpu_vm_bo_map(adev, bo_va, args->va_address,
622  args->offset_in_bo, args->map_size,
623  va_flags);
624 break;
625 case AMDGPU_VA_OP_UNMAP:
626 r = amdgpu_vm_bo_unmap(adev, bo_va, args->va_address);
627 break;
628 default:

---
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



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


[bug report] drm/msm/dsi: Move PHY operations out of host

2017-02-10 Thread Dan Carpenter
Hello Hai Li,

This is a semi-automatic email about new static checker warnings.

The patch b62aa70a98c5: "drm/msm/dsi: Move PHY operations out of 
host" from Jan 7, 2017, leads to the following Smatch complaint:

./drivers/gpu/drm/msm/dsi/dsi_manager.c:174 dsi_mgr_phy_enable()
 error: we previously assumed 'mdsi' could be null (see line 157)

./drivers/gpu/drm/msm/dsi/dsi_manager.c
   156   */
   157  if (IS_DUAL_DSI() && mdsi && sdsi) {
 
Check for NULL.

   158  if (!mdsi->phy_enabled && !sdsi->phy_enabled) {
   159  msm_dsi_host_reset_phy(mdsi->host);
   160  msm_dsi_host_reset_phy(sdsi->host);
   161  
   162  ret = enable_phy(mdsi, src_pll_id,
   163   
_timings[DSI_CLOCK_MASTER]);
   164  if (ret)
   165  return ret;
   166  ret = enable_phy(sdsi, src_pll_id,
   167   
_timings[DSI_CLOCK_SLAVE]);
   168  if (ret) {
   169  msm_dsi_phy_disable(mdsi->phy);
   170  return ret;
   171  }
   172  }
   173  } else {
   174  msm_dsi_host_reset_phy(mdsi->host);
   ^^
Unchecked dereference.

   175  ret = enable_phy(msm_dsi, src_pll_id, 
_timings[id]);
   176  if (ret)

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


[Bug 193341] AMDGPU: kernel NULL pointer dereferenced with hybrid graphics

2017-02-10 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=193341

--- Comment #5 from Alex Deucher (alexdeuc...@gmail.com) ---
Created attachment 254699
  --> https://bugzilla.kernel.org/attachment.cgi?id=254699=edit
possible fix

This should fix it (along with the previous patch).

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 99387] Kernel 4.9: Kaveri + Hainan choked on boot using amdgpu

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99387

--- Comment #15 from Alex Deucher  ---
Created attachment 129497
  --> https://bugs.freedesktop.org/attachment.cgi?id=129497=edit
possible fix

This should fix it (in addition to the previous patch).

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 193341] AMDGPU: kernel NULL pointer dereferenced with hybrid graphics

2017-02-10 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=193341

Marco Piazza (mpia...@gmail.com) changed:

   What|Removed |Added

 CC||mpia...@gmail.com

--- Comment #4 from Marco Piazza (mpia...@gmail.com) ---
Attached logs about amdgpu kernel oops on hybrid gpu (KABINI+HAINAN)

4.9.9: https://bugs.freedesktop.org/show_bug.cgi?id=99387#c13

4.9.2: https://bugs.freedesktop.org/show_bug.cgi?id=99387#c14

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 99387] Kernel 4.9: Kaveri + Hainan choked on boot using amdgpu

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99387

--- Comment #14 from Marco  ---
Created attachment 129496
  --> https://bugs.freedesktop.org/attachment.cgi?id=129496=edit
oops in 4.9.2

For the sake of being complete,
find attached log of kernel oops on kernel 4.9.2 (before patch was applied)

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 97879] [amdgpu] Rocket League: long hangs (several seconds) when loading assets (models/textures/shaders?)

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97879

--- Comment #80 from Jani Kärkkäinen  ---
I think this is merged now? 

Using the padoka git ppa which just so happened to be updated, which included
this patch (as it was just merged?), I can confirm the findings others had. The
lag spikes effectively disappeared, but fps dropped to about 80% (on the lowest
settings, to be fair). 

What's interesting though is that now it was possible to set the highest
quality (before the patch it just lagged for me for double digit seconds, just
for setting it up), and if I remember correctly, the fps was horrid, about half
of the lowest settings. But now I can play just fine with 1080p quality maxed @
74 fps.

Also, before the patch the fps was quite stable, but now it fluctuates a lot
more. It doesn't affect the gameplay negatively, though.

Testing this on RX480.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 99387] Kernel 4.9: Kaveri + Hainan choked on boot using amdgpu

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99387

--- Comment #13 from Marco  ---
Created attachment 129495
  --> https://bugs.freedesktop.org/attachment.cgi?id=129495=edit
Oops 4.9.9

Jumping in, I have a similar hybrid GPU:
01:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Sun PRO
[Radeon HD 8570A/8570M] (rev ff)
00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI]
Kabini [Radeon HD 8330] 

Same kernel config:
CONFIG_DRM_AMDGPU=m
CONFIG_DRM_AMDGPU_SI=y
CONFIG_DRM_AMDGPU_CIK=y
CONFIG_DRM_AMDGPU_USERPTR=y

tried now 4.9.9 with the patch landed in stable.
Kernel oops on boot. See attached pstore log message.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 99748] [radeonsi] Civ6 Assert in LLVM SIMachineScheduler.cpp with R600_DEBUG=sisched

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99748

Mike Lothian  changed:

   What|Removed |Added

 CC||m...@fireburn.co.uk

--- Comment #1 from Mike Lothian  ---
This wasn't limited to Civ6, saw the issue on Rocket League as well

Reverting:

commit ce06d9cb99298eb844b66e117f5108a06747c907
Author: Alexander Timofeev 
Date:   Tue Feb 7 17:57:48 2017 +

[AMDGPU] Fix for SIMachineScheduler crash. SI Scheduler should track
 lane masks.

 Differential revision: https://reviews.llvm.org/D29442

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294324
91177308-0d34-0410-b5e6-96231b3b80d8

Allowed it to work again

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 97879] [amdgpu] Rocket League: long hangs (several seconds) when loading assets (models/textures/shaders?)

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97879

--- Comment #79 from Timothee Besset  ---
(testing done - it may take a few days before this rolls out in a steam update)

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[radeon-alex:drm-next-4.12-wip 34/40] drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c:620:16: note: in expansion of macro 'AMDGPU_PTE_PRT'

2017-02-10 Thread kbuild test robot
tree:   git://people.freedesktop.org/~agd5f/linux.git drm-next-4.12-wip
head:   d32ff0ea8e22964abcc6406e00a0646f2bfb94c7
commit: 382a21d981661dbc8198c37dc95707e1e381ce76 [34/40] drm/amdgpu: IOCTL 
interface for PRT support v4
config: parisc-allmodconfig (attached as .config)
compiler: hppa-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 382a21d981661dbc8198c37dc95707e1e381ce76
# save the attached .config to linux build tree
make.cross ARCH=parisc 

All warnings (new ones prefixed by >>):

   In file included from drivers/gpu/drm/amd/amdgpu/amdgpu.h:58:0,
from drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c:32:
   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c: In function 'amdgpu_gem_va_ioctl':
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h:68:30: warning: left shift count >= 
width of type [-Wshift-count-overflow]
#define AMDGPU_PTE_PRT  (1UL << 63)
 ^
>> drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c:620:16: note: in expansion of macro 
>> 'AMDGPU_PTE_PRT'
   va_flags |= AMDGPU_PTE_PRT;
   ^~

vim +/AMDGPU_PTE_PRT +620 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c

   604  r = -ENOENT;
   605  goto error_backoff;
   606  }
   607  } else {
   608  bo_va = fpriv->prt_va;
   609  }
   610  
   611  switch (args->operation) {
   612  case AMDGPU_VA_OP_MAP:
   613  if (args->flags & AMDGPU_VM_PAGE_READABLE)
   614  va_flags |= AMDGPU_PTE_READABLE;
   615  if (args->flags & AMDGPU_VM_PAGE_WRITEABLE)
   616  va_flags |= AMDGPU_PTE_WRITEABLE;
   617  if (args->flags & AMDGPU_VM_PAGE_EXECUTABLE)
   618  va_flags |= AMDGPU_PTE_EXECUTABLE;
   619  if (args->flags & AMDGPU_VM_PAGE_PRT)
 > 620  va_flags |= AMDGPU_PTE_PRT;
   621  r = amdgpu_vm_bo_map(adev, bo_va, args->va_address,
   622   args->offset_in_bo, args->map_size,
   623   va_flags);
   624  break;
   625  case AMDGPU_VA_OP_UNMAP:
   626  r = amdgpu_vm_bo_unmap(adev, bo_va, args->va_address);
   627  break;
   628  default:

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm: Reduce EDID warnings from DRM_ERROR to DRM_NOTE

2017-02-10 Thread Chris Wilson
The warnings from parsing the EDID are not driver errors, but the
"normal but significant" conditions from the external device. As such,
they do not need the ferocity of an *ERROR*, but can use the less harsh
DRM_NOTE instead.

Signed-off-by: Chris Wilson 
---
 drivers/gpu/drm/drm_edid.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 5a3b34a88ac3..24e7b282f16c 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -1140,7 +1140,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool 
print_bad_edid,
DRM_DEBUG("Assuming a KVM switch modified the CEA block 
but left the original checksum\n");
} else {
if (print_bad_edid)
-   DRM_ERROR("EDID checksum is invalid, remainder 
is %d\n", csum);
+   DRM_NOTE("EDID checksum is invalid, remainder 
is %d\n", csum);
 
goto bad;
}
@@ -1150,7 +1150,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool 
print_bad_edid,
switch (raw_edid[0]) {
case 0: /* base */
if (edid->version != 1) {
-   DRM_ERROR("EDID has major version %d, instead of 1\n", 
edid->version);
+   DRM_NOTE("EDID has major version %d, instead of 1\n", 
edid->version);
goto bad;
}
 
@@ -1167,11 +1167,12 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool 
print_bad_edid,
 bad:
if (print_bad_edid) {
if (drm_edid_is_zero(raw_edid, EDID_LENGTH)) {
-   printk(KERN_ERR "EDID block is all zeroes\n");
+   printk(KERN_NOTICE "EDID block is all zeroes\n");
} else {
-   printk(KERN_ERR "Raw EDID:\n");
-   print_hex_dump(KERN_ERR, " \t", DUMP_PREFIX_NONE, 16, 1,
-  raw_edid, EDID_LENGTH, false);
+   printk(KERN_NOTICE "Raw EDID:\n");
+   print_hex_dump(KERN_NOTICE,
+  " \t", DUMP_PREFIX_NONE, 16, 1,
+  raw_edid, EDID_LENGTH, false);
}
}
return false;
@@ -4002,7 +4003,7 @@ static int validate_displayid(u8 *displayid, int length, 
int idx)
csum += displayid[i];
}
if (csum) {
-   DRM_ERROR("DisplayID checksum invalid, remainder is %d\n", 
csum);
+   DRM_NOTE("DisplayID checksum invalid, remainder is %d\n", csum);
return -EINVAL;
}
return 0;
-- 
2.11.0

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


[radeon-alex:drm-next-4.12-wip 33/40] drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h:68:30: warning: left shift count >= width of type

2017-02-10 Thread kbuild test robot
tree:   git://people.freedesktop.org/~agd5f/linux.git drm-next-4.12-wip
head:   d32ff0ea8e22964abcc6406e00a0646f2bfb94c7
commit: 7958b9959ea9dd544675adebddab255f7c536da7 [33/40] drm/amdgpu: add basic 
PRT support (v2)
config: parisc-allmodconfig (attached as .config)
compiler: hppa-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 7958b9959ea9dd544675adebddab255f7c536da7
# save the attached .config to linux build tree
make.cross ARCH=parisc 

All warnings (new ones prefixed by >>):

   In file included from drivers/gpu/drm/amd/amdgpu/amdgpu.h:58:0,
from drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:31:
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c: In function 'amdgpu_vm_free_mapping':
>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h:68:30: warning: left shift count >= 
>> width of type [-Wshift-count-overflow]
#define AMDGPU_PTE_PRT  (1UL << 63)
 ^
>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1222:24: note: in expansion of macro 
>> 'AMDGPU_PTE_PRT'
 if ((mapping->flags & AMDGPU_PTE_PRT) &&
   ^~
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c: In function 'amdgpu_vm_bo_map':
>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h:68:30: warning: left shift count >= 
>> width of type [-Wshift-count-overflow]
#define AMDGPU_PTE_PRT  (1UL << 63)
 ^
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1379:14: note: in expansion of macro 
'AMDGPU_PTE_PRT'
 if (flags & AMDGPU_PTE_PRT) {
 ^~
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c: In function 'amdgpu_vm_fini':
>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h:68:30: warning: left shift count >= 
>> width of type [-Wshift-count-overflow]
#define AMDGPU_PTE_PRT  (1UL << 63)
 ^
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1701:24: note: in expansion of macro 
'AMDGPU_PTE_PRT'
  if (mapping->flags & AMDGPU_PTE_PRT)
   ^~

vim +68 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h

52  
53  /* LOG2 number of continuous pages for the fragment field */
54  #define AMDGPU_LOG2_PAGES_PER_FRAG 4
55  
56  #define AMDGPU_PTE_VALID(1 << 0)
57  #define AMDGPU_PTE_SYSTEM   (1 << 1)
58  #define AMDGPU_PTE_SNOOPED  (1 << 2)
59  
60  /* VI only */
61  #define AMDGPU_PTE_EXECUTABLE   (1 << 4)
62  
63  #define AMDGPU_PTE_READABLE (1 << 5)
64  #define AMDGPU_PTE_WRITEABLE(1 << 6)
65  
66  #define AMDGPU_PTE_FRAG(x)  ((x & 0x1f) << 7)
67  
  > 68  #define AMDGPU_PTE_PRT  (1UL << 63)
69  
70  /* How to programm VM fault handling */
71  #define AMDGPU_VM_FAULT_STOP_NEVER  0
72  #define AMDGPU_VM_FAULT_STOP_FIRST  1
73  #define AMDGPU_VM_FAULT_STOP_ALWAYS 2
74  
75  struct amdgpu_vm_pt {
76  struct amdgpu_bo*bo;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[radeon-alex:drm-next-4.12-wip 34/40] drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c:620:4: warning: left shift count >= width of type

2017-02-10 Thread kbuild test robot
tree:   git://people.freedesktop.org/~agd5f/linux.git drm-next-4.12-wip
head:   d32ff0ea8e22964abcc6406e00a0646f2bfb94c7
commit: 382a21d981661dbc8198c37dc95707e1e381ce76 [34/40] drm/amdgpu: IOCTL 
interface for PRT support v4
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 382a21d981661dbc8198c37dc95707e1e381ce76
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c: In function 'amdgpu_gem_va_ioctl':
>> drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c:620:4: warning: left shift count >= 
>> width of type
   va_flags |= AMDGPU_PTE_PRT;
   ^

vim +620 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c

   604  r = -ENOENT;
   605  goto error_backoff;
   606  }
   607  } else {
   608  bo_va = fpriv->prt_va;
   609  }
   610  
   611  switch (args->operation) {
   612  case AMDGPU_VA_OP_MAP:
   613  if (args->flags & AMDGPU_VM_PAGE_READABLE)
   614  va_flags |= AMDGPU_PTE_READABLE;
   615  if (args->flags & AMDGPU_VM_PAGE_WRITEABLE)
   616  va_flags |= AMDGPU_PTE_WRITEABLE;
   617  if (args->flags & AMDGPU_VM_PAGE_EXECUTABLE)
   618  va_flags |= AMDGPU_PTE_EXECUTABLE;
   619  if (args->flags & AMDGPU_VM_PAGE_PRT)
 > 620  va_flags |= AMDGPU_PTE_PRT;
   621  r = amdgpu_vm_bo_map(adev, bo_va, args->va_address,
   622   args->offset_in_bo, args->map_size,
   623   va_flags);
   624  break;
   625  case AMDGPU_VA_OP_UNMAP:
   626  r = amdgpu_vm_bo_unmap(adev, bo_va, args->va_address);
   627  break;
   628  default:

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[radeon-alex:drm-next-4.12-wip 33/40] drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1222:2: warning: left shift count >= width of type

2017-02-10 Thread kbuild test robot
tree:   git://people.freedesktop.org/~agd5f/linux.git drm-next-4.12-wip
head:   d32ff0ea8e22964abcc6406e00a0646f2bfb94c7
commit: 7958b9959ea9dd544675adebddab255f7c536da7 [33/40] drm/amdgpu: add basic 
PRT support (v2)
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 7958b9959ea9dd544675adebddab255f7c536da7
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c: In function 'amdgpu_vm_free_mapping':
>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1222:2: warning: left shift count >= 
>> width of type
 if ((mapping->flags & AMDGPU_PTE_PRT) &&
 ^
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c: In function 'amdgpu_vm_bo_map':
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1379:2: warning: left shift count >= 
width of type
 if (flags & AMDGPU_PTE_PRT) {
 ^
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c: In function 'amdgpu_vm_fini':
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1701:3: warning: left shift count >= 
width of type
  if (mapping->flags & AMDGPU_PTE_PRT)
  ^

vim +1222 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

  1206  
  1207  /**
  1208   * amdgpu_vm_free_mapping - free a mapping
  1209   *
  1210   * @adev: amdgpu_device pointer
  1211   * @vm: requested vm
  1212   * @mapping: mapping to be freed
  1213   * @fence: fence of the unmap operation
  1214   *
  1215   * Free a mapping and make sure we decrease the PRT usage count if 
applicable.
  1216   */
  1217  static void amdgpu_vm_free_mapping(struct amdgpu_device *adev,
  1218 struct amdgpu_vm *vm,
  1219 struct amdgpu_bo_va_mapping *mapping,
  1220 struct dma_fence *fence)
  1221  {
> 1222  if ((mapping->flags & AMDGPU_PTE_PRT) &&
  1223  atomic_dec_return(>vm_manager.num_prt_mappings) == 0) 
{
  1224  struct amdgpu_prt_cb *cb = kmalloc(sizeof(struct 
amdgpu_prt_cb),
  1225 GFP_KERNEL);
  1226  
  1227  cb->adev = adev;
  1228  if (!fence || dma_fence_add_callback(fence, >cb,
  1229   amdgpu_vm_prt_cb)) 
{
  1230  amdgpu_vm_update_prt_state(adev);

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 95306] Random Blank(black) screens on "Carrizo"

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=95306

--- Comment #58 from Tom St Denis  ---
The only deltas I can see from rc4 to now are in powerplay... so does booting
with amdgpu.powerplay=0 help?

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 95306] Random Blank(black) screens on "Carrizo"

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=95306

--- Comment #57 from Patrick Laurin  ---
I was finally able to get another laptop from my company. No more AMDGPU
for me!
Core i3 with Intel HD Graphics 520 = Heaven
But hey, i'll still follow that thread :)


On 9 February 2017 at 20:18,  wrote:

> *Comment # 56  on
> bug 95306  from Jaime
> Rodrigo  *
>
> I tried 4.10 RC7, and I could successfully login with this kernel. But after 5
> mins of using it, I had a blackout again :/ . Guess I'll stick to RC5 for a
> while
>
> --
> You are receiving this mail because:
>
>- You are on the CC list for the bug.
>
>

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 97879] [amdgpu] Rocket League: long hangs (several seconds) when loading assets (models/textures/shaders?)

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97879

--- Comment #78 from Timothee Besset  ---
Testing a game side fix for this problem atm (doesn't require the patched
drivers). If someone wants to give it a spin before I send it to Psyonix, catch
me on freenode (TTimo).

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2] drm/atmel-hlcdc: Simplify the HLCDC layer logic

2017-02-10 Thread Boris Brezillon
An HLCDC layers in Atmel's nomenclature is either a DRM plane or a 'Post
Processing Layer' which can be used to output the results of the HLCDC
composition in a memory buffer.

atmel_hlcdc_layer.c was designed to be generic enough to be re-usable in
both cases, but we're not exposing the post-processing layer yet, and
even if we were, I'm not sure the code would provide the necessary tools
to manipulate this kind of layer.

Moreover, the code in atmel_hlcdc_{plane,layer}.c was designed before the
atomic modesetting API, and was trying solve the
check-setting/commit-if-ok/rollback-otherwise problem, which is now
entirely solved by the existing core infrastructure.

And finally, the code in atmel_hlcdc_layer.c in over-complicated compared
to what we really need. This rework is a good excuse to simplify it. Note
that this rework solves an existing resource leak (leading to a -EBUSY
error) which I failed to clearly identify.

Signed-off-by: Boris Brezillon 
---
Hi Daniel,

I intentionally dropped your ack, since inheriting from atmel_hlcdc_layer
is implying a lot of changes.

Regards,

Boris

Changes in v2:
- make atmel_hlcdc_plane inherit from atmel_hlcdc_layer
- provide read/write_reg/cfg() helpers to access layer regs
- move all layer related definitions into atmel_hlcdc_dc.h and remove
  atmel_hlcdc_layer.h
- fix a bug in atmel_hlcdc_plane_atomic_duplicate_state()
---
 drivers/gpu/drm/atmel-hlcdc/Makefile|   1 -
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c  |  39 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c|  82 +--
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h| 364 +++--
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c | 666 
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.h | 399 --
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 637 +++---
 7 files changed, 695 insertions(+), 1493 deletions(-)
 delete mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c
 delete mode 100644 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.h

diff --git a/drivers/gpu/drm/atmel-hlcdc/Makefile 
b/drivers/gpu/drm/atmel-hlcdc/Makefile
index 10ae426e60bd..bb5f8507a8ce 100644
--- a/drivers/gpu/drm/atmel-hlcdc/Makefile
+++ b/drivers/gpu/drm/atmel-hlcdc/Makefile
@@ -1,6 +1,5 @@
 atmel-hlcdc-dc-y := atmel_hlcdc_crtc.o \
atmel_hlcdc_dc.o \
-   atmel_hlcdc_layer.o \
atmel_hlcdc_output.o \
atmel_hlcdc_plane.o
 
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 9b17a66cf0e1..2fcec0a72567 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -445,8 +445,8 @@ static const struct drm_crtc_funcs atmel_hlcdc_crtc_funcs = 
{
 
 int atmel_hlcdc_crtc_create(struct drm_device *dev)
 {
+   struct atmel_hlcdc_plane *primary = NULL, *cursor = NULL;
struct atmel_hlcdc_dc *dc = dev->dev_private;
-   struct atmel_hlcdc_planes *planes = dc->planes;
struct atmel_hlcdc_crtc *crtc;
int ret;
int i;
@@ -457,20 +457,41 @@ int atmel_hlcdc_crtc_create(struct drm_device *dev)
 
crtc->dc = dc;
 
-   ret = drm_crtc_init_with_planes(dev, >base,
-   >primary->base,
-   planes->cursor ? >cursor->base : NULL,
-   _hlcdc_crtc_funcs, NULL);
+   for (i = 0; i < ATMEL_HLCDC_MAX_LAYERS; i++) {
+   if (!dc->layers[i])
+   continue;
+
+   switch (dc->layers[i]->desc->type) {
+   case ATMEL_HLCDC_BASE_LAYER:
+   primary = atmel_hlcdc_layer_to_plane(dc->layers[i]);
+   break;
+
+   case ATMEL_HLCDC_CURSOR_LAYER:
+   cursor = atmel_hlcdc_layer_to_plane(dc->layers[i]);
+   break;
+
+   default:
+   break;
+   }
+   }
+
+   ret = drm_crtc_init_with_planes(dev, >base, >base,
+   >base, _hlcdc_crtc_funcs,
+   NULL);
if (ret < 0)
goto fail;
 
crtc->id = drm_crtc_index(>base);
 
-   if (planes->cursor)
-   planes->cursor->base.possible_crtcs = 1 << crtc->id;
+   for (i = 0; i < ATMEL_HLCDC_MAX_LAYERS; i++) {
+   struct atmel_hlcdc_plane *overlay;
 
-   for (i = 0; i < planes->noverlays; i++)
-   planes->overlays[i]->base.possible_crtcs = 1 << crtc->id;
+   if (dc->layers[i] &&
+   dc->layers[i]->desc->type == ATMEL_HLCDC_OVERLAY_LAYER) {
+   overlay = atmel_hlcdc_layer_to_plane(dc->layers[i]);
+   overlay->base.possible_crtcs = 1 << crtc->id;
+   }
+   }
 
drm_crtc_helper_add(>base, 

[Bug 99476] Forcing perf level to high doesn't change memory clock

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99476

Samuel Pitoiset  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #2 from Samuel Pitoiset  ---
This is fixed in amd-staging-4.9. I didn't test the firmwares. Looks good now.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 99765] Make Octopus OpenCL support work on Clover and RadeonSI

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99765

Vedran Miletić  changed:

   What|Removed |Added

 Blocks||99553
URL||http://octopus-code.org


Referenced Bugs:

https://bugs.freedesktop.org/show_bug.cgi?id=99553
[Bug 99553] Tracker bug for runnning OpenCL applications on Clover
-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 99553] Tracker bug for runnning OpenCL applications on Clover

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99553

Vedran Miletić  changed:

   What|Removed |Added

 Depends on||99765


Referenced Bugs:

https://bugs.freedesktop.org/show_bug.cgi?id=99765
[Bug 99765] Make Octopus OpenCL support work on Clover and RadeonSI
-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 99765] Make Octopus OpenCL support work on Clover and RadeonSI

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99765

Bug ID: 99765
   Summary: Make Octopus OpenCL support work on Clover and
RadeonSI
   Product: Mesa
   Version: git
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Drivers/Gallium/radeonsi
  Assignee: dri-devel@lists.freedesktop.org
  Reporter: ved...@miletic.net
QA Contact: dri-devel@lists.freedesktop.org

Octopus is a quantum chemistry code with experimental OpenCL support using
clBLAS and clFFT [1]. It can be compiled with:

$ ./configure --with-libxc-include=/usr/lib64/gfortran/modules --enable-opencl
--with-clblas-prefix=/usr/local --with-clfft-prefix=/usr/local

Running test file named inp from
http://octopus-code.org/wiki/Tutorial:Hydrogen_atom results in:

AN INTERNAL KERNEL BUILD ERROR OCCURRED!
device name = AMD FIJI (DRM 3.8.0 / 4.9.7-201.fc25.x86_64, LLVM 5.0.0)
error = -43
memory pattern = Register accumulation based swap, computing kernel generator
Subproblem dimensions: dims[0].itemY = 32, dims[0].itemX = 32, dims[0].y = 32,
dims[0].x = 32, dims[0].bwidth = 64; ; dims[1].itemY = 4, dims[1].itemX = 4,
dims[1].y = 4, dims[1].x = 4, dims[1].bwidth = 4; ; 
Parallelism granularity: pgran->wgDim = 1, pgran->wgSize[0] = 64,
pgran->wgSize[1] = 1, pgran->wfSize = 64
Kernel extra flags: 268462752
Source:

(...)



Build log:




 Octopus debug trace not available. You can enable it with 'Debug = trace'.
Segmentation fault (core dumped)

[1] https://github.com/clMathLibraries

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 7/7] drm: Rename connector list iterator API

2017-02-10 Thread Thierry Reding
On Fri, Feb 10, 2017 at 06:14:14PM +0100, Thierry Reding wrote:
[...]
>  /**
> - * drm_connector_list_iter_get - initialize a connector_list iterator
> + * drm_connector_list_iter_begin - initialize a connector_list iterator
>   * @dev: DRM device
>   * @iter: connector_list iterator
>   *
>   * Sets @iter up to walk the _mode_config.connector_list of @dev. @iter
> - * must always be cleaned up again by calling drm_connector_list_iter_put().
> + * must always be cleaned up again by calling drm_connector_list_iter_end().
>   * Iteration itself happens using drm_connector_list_iter_next() or
>   * drm_for_each_connector_iter().
>   */
> -void drm_connector_list_iter_get(struct drm_device *dev,
> -  struct drm_connector_list_iter *iter)
> +void drm_connector_list_iter_begin(struct drm_device *dev,
> +struct drm_connector_list_iter *iter)
>  {
>   iter->dev = dev;
>   iter->conn = NULL;
>   lock_acquire_shared_recursive(_list_iter_dep_map, 0, 1, NULL, 
> _RET_IP_);
>  }
> -EXPORT_SYMBOL(drm_connector_list_iter_get);
> +EXPORT_SYMBOL(drm_connector_list_iter_end);

Erm... this should obviously have been drm_connector_list_iter_begin, no
idea why the build tests didn't catch this on the first run.

Thierry


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


Re: [PATCH v3 21/24] drm/rockchip: dw-mipi-dsi: defer probe if panel is not loaded

2017-02-10 Thread John Keeping
On Tue, 31 Jan 2017 14:21:17 -0500, Sean Paul wrote:

> On Sun, Jan 29, 2017 at 01:24:41PM +, John Keeping wrote:
> > This ensures that the output resolution is known before fbcon loads.
> > 
> > Signed-off-by: John Keeping 
> > ---
> > Unchanged in v3
> > Unchanged in v2
> > 
> >  drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 11 +--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
> > b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > index f5b15377ef85..5bad92e2370e 100644
> > --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > @@ -1176,10 +1176,17 @@ static int dw_mipi_dsi_bind(struct device *dev, 
> > struct device *master,
> >  
> > dsi->dsi_host.ops = _mipi_dsi_host_ops;
> > dsi->dsi_host.dev = dev;
> > -   return mipi_dsi_host_register(>dsi_host);
> > +   ret = mipi_dsi_host_register(>dsi_host);
> > +   if (!ret && !dsi->panel) {
> > +   mipi_dsi_host_unregister(>dsi_host);
> > +   drm_encoder_cleanup(>encoder);
> > +   drm_connector_cleanup(>connector);  
> 
> Move the host registration up before dw_mipi_dsi_register() to avoid
> having to clean up the encoder and connector?

No, mipi_dsi_host_register() has to be called after the connector is
registered because it is likely to result in a call to
dw_mipi_dsi_host_attach() which attaches a panel to the connector.

> > +   ret = -EPROBE_DEFER;
> > +   }
> >  
> >  err_pllref:
> > -   clk_disable_unprepare(dsi->pllref_clk);
> > +   if (ret)  
> 
> I personally think it's cleaner to explicitly goto in the error conditional 
> (or
> in this case, the defer conditional) and have a return 0; right before the 
> err_*
> labels. Then you don't need to worry about a) checking ret in all of your
> cleanups and b) someone adding code above the labels that you don't intend to
> run.

Agreed.  I'll change this to use a goto if we hit the EPROBE_DEFER case
and keep all the cleanup together.

> > +   clk_disable_unprepare(dsi->pllref_clk);
> > return ret;
> >  }
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 5/7] drm: Introduce drm_gem_object_{get,put}()

2017-02-10 Thread Thierry Reding
From: Thierry Reding 

For consistency with other reference counting APIs in the kernel, add
drm_gem_object_get() and drm_gem_object_put(), as well as an unlocked
variant of the latter, to reference count GEM buffer objects.

Compatibility aliases are added to keep existing code working. To help
speed up the transition, all the instances of the old functions in the
DRM core are already replaced in this commit.

The existing semantic patch for the DRM subsystem-wide conversion is
extended to account for these new helpers.

Reviewed-by: Sean Paul 
Acked-by: Christian König 
Signed-off-by: Thierry Reding 
---
 Documentation/gpu/drm-mm.rst | 14 +++---
 drivers/gpu/drm/drm_fb_cma_helper.c  | 16 +++
 drivers/gpu/drm/drm_gem.c| 44 +-
 drivers/gpu/drm/drm_gem_cma_helper.c | 10 ++--
 drivers/gpu/drm/drm_prime.c  | 10 ++--
 include/drm/drm_gem.h| 80 +---
 scripts/coccinelle/api/drm-get-put.cocci | 20 
 7 files changed, 130 insertions(+), 64 deletions(-)

diff --git a/Documentation/gpu/drm-mm.rst b/Documentation/gpu/drm-mm.rst
index f5760b140f13..fd35998acefc 100644
--- a/Documentation/gpu/drm-mm.rst
+++ b/Documentation/gpu/drm-mm.rst
@@ -183,14 +183,12 @@ GEM Objects Lifetime
 
 
 All GEM objects are reference-counted by the GEM core. References can be
-acquired and release by :c:func:`calling
-drm_gem_object_reference()` and
-:c:func:`drm_gem_object_unreference()` respectively. The caller
-must hold the :c:type:`struct drm_device `
-struct_mutex lock when calling
-:c:func:`drm_gem_object_reference()`. As a convenience, GEM
-provides :c:func:`drm_gem_object_unreference_unlocked()`
-functions that can be called without holding the lock.
+acquired and release by :c:func:`calling drm_gem_object_get()` and
+:c:func:`drm_gem_object_put()` respectively. The caller must hold the
+:c:type:`struct drm_device ` struct_mutex lock when calling
+:c:func:`drm_gem_object_get()`. As a convenience, GEM provides
+:c:func:`drm_gem_object_put_unlocked()` functions that can be called without
+holding the lock.
 
 When the last reference to a GEM object is released the GEM core calls
 the :c:type:`struct drm_driver ` gem_free_object
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
b/drivers/gpu/drm/drm_fb_cma_helper.c
index 596fabf18c3e..eccc07d20925 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -102,7 +102,7 @@ void drm_fb_cma_destroy(struct drm_framebuffer *fb)
 
for (i = 0; i < 4; i++) {
if (fb_cma->obj[i])
-   
drm_gem_object_unreference_unlocked(_cma->obj[i]->base);
+   drm_gem_object_put_unlocked(_cma->obj[i]->base);
}
 
drm_framebuffer_cleanup(fb);
@@ -190,7 +190,7 @@ struct drm_framebuffer *drm_fb_cma_create_with_funcs(struct 
drm_device *dev,
if (!obj) {
dev_err(dev->dev, "Failed to lookup GEM object\n");
ret = -ENXIO;
-   goto err_gem_object_unreference;
+   goto err_gem_object_put;
}
 
min_size = (height - 1) * mode_cmd->pitches[i]
@@ -198,9 +198,9 @@ struct drm_framebuffer *drm_fb_cma_create_with_funcs(struct 
drm_device *dev,
 + mode_cmd->offsets[i];
 
if (obj->size < min_size) {
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
ret = -EINVAL;
-   goto err_gem_object_unreference;
+   goto err_gem_object_put;
}
objs[i] = to_drm_gem_cma_obj(obj);
}
@@ -208,14 +208,14 @@ struct drm_framebuffer 
*drm_fb_cma_create_with_funcs(struct drm_device *dev,
fb_cma = drm_fb_cma_alloc(dev, mode_cmd, objs, i, funcs);
if (IS_ERR(fb_cma)) {
ret = PTR_ERR(fb_cma);
-   goto err_gem_object_unreference;
+   goto err_gem_object_put;
}
 
return _cma->fb;
 
-err_gem_object_unreference:
+err_gem_object_put:
for (i--; i >= 0; i--)
-   drm_gem_object_unreference_unlocked([i]->base);
+   drm_gem_object_put_unlocked([i]->base);
return ERR_PTR(ret);
 }
 EXPORT_SYMBOL_GPL(drm_fb_cma_create_with_funcs);
@@ -477,7 +477,7 @@ drm_fbdev_cma_create(struct drm_fb_helper *helper,
 err_fb_info_destroy:
drm_fb_helper_release_fbi(helper);
 err_gem_free_object:
-   drm_gem_object_unreference_unlocked(>base);
+   drm_gem_object_put_unlocked(>base);
return ret;
 }
 
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index bc93de308673..b1e28c944637 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c

[PATCH v2 7/7] drm: Rename connector list iterator API

2017-02-10 Thread Thierry Reding
From: Thierry Reding 

Currently the functions that initialize and tear down a connector
iterator use the _get() and _put() suffixes. However, these suffixes
are typically used by reference counting functions.

Make these function names a little more consistent by changing the
suffixes to _begin() and _end(), which is a fairly common pattern in
the rest of the Linux kernel.

Suggested-by: Jani Nikula 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_atomic.c| 10 +-
 drivers/gpu/drm/drm_atomic_helper.c | 18 +-
 drivers/gpu/drm/drm_connector.c | 24 
 drivers/gpu/drm/drm_crtc_helper.c   | 36 ++--
 drivers/gpu/drm/drm_encoder.c   |  6 +++---
 drivers/gpu/drm/drm_fb_helper.c |  4 ++--
 drivers/gpu/drm/drm_mode_config.c   | 18 +-
 drivers/gpu/drm/drm_plane_helper.c  |  4 ++--
 drivers/gpu/drm/drm_probe_helper.c  | 12 ++--
 include/drm/drm_connector.h | 12 ++--
 10 files changed, 72 insertions(+), 72 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index ff5f1756a7ff..3e7c403af922 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1421,18 +1421,18 @@ drm_atomic_add_affected_connectors(struct 
drm_atomic_state *state,
 * Changed connectors are already in @state, so only need to look at the
 * current configuration.
 */
-   drm_connector_list_iter_get(state->dev, _iter);
+   drm_connector_list_iter_begin(state->dev, _iter);
drm_for_each_connector_iter(connector, _iter) {
if (connector->state->crtc != crtc)
continue;
 
conn_state = drm_atomic_get_connector_state(state, connector);
if (IS_ERR(conn_state)) {
-   drm_connector_list_iter_put(_iter);
+   drm_connector_list_iter_end(_iter);
return PTR_ERR(conn_state);
}
}
-   drm_connector_list_iter_put(_iter);
+   drm_connector_list_iter_end(_iter);
 
return 0;
 }
@@ -1694,10 +1694,10 @@ void drm_state_dump(struct drm_device *dev, struct 
drm_printer *p)
list_for_each_entry(crtc, >crtc_list, head)
drm_atomic_crtc_print_state(p, crtc->state);
 
-   drm_connector_list_iter_get(dev, _iter);
+   drm_connector_list_iter_begin(dev, _iter);
drm_for_each_connector_iter(connector, _iter)
drm_atomic_connector_print_state(p, connector->state);
-   drm_connector_list_iter_put(_iter);
+   drm_connector_list_iter_end(_iter);
 }
 EXPORT_SYMBOL(drm_state_dump);
 
diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 6f94fca4c601..3c2c07ff7168 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -145,7 +145,7 @@ static int handle_conflicting_encoders(struct 
drm_atomic_state *state,
 * and the crtc is disabled if no encoder is left. This preserves
 * compatibility with the legacy set_config behavior.
 */
-   drm_connector_list_iter_get(state->dev, _iter);
+   drm_connector_list_iter_begin(state->dev, _iter);
drm_for_each_connector_iter(connector, _iter) {
struct drm_crtc_state *crtc_state;
 
@@ -193,7 +193,7 @@ static int handle_conflicting_encoders(struct 
drm_atomic_state *state,
}
}
 out:
-   drm_connector_list_iter_put(_iter);
+   drm_connector_list_iter_end(_iter);
 
return ret;
 }
@@ -2429,7 +2429,7 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
 
state->acquire_ctx = ctx;
 
-   drm_connector_list_iter_get(dev, _iter);
+   drm_connector_list_iter_begin(dev, _iter);
drm_for_each_connector_iter(conn, _iter) {
struct drm_crtc *crtc = conn->state->crtc;
struct drm_crtc_state *crtc_state;
@@ -2448,7 +2448,7 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
 
err = drm_atomic_commit(state);
 free:
-   drm_connector_list_iter_put(_iter);
+   drm_connector_list_iter_end(_iter);
drm_atomic_state_put(state);
return err;
 }
@@ -2940,7 +2940,7 @@ int drm_atomic_helper_connector_dpms(struct drm_connector 
*connector,
 
WARN_ON(!drm_modeset_is_locked(>connection_mutex));
 
-   drm_connector_list_iter_get(connector->dev, _iter);
+   drm_connector_list_iter_begin(connector->dev, _iter);
drm_for_each_connector_iter(tmp_connector, _iter) {
if (tmp_connector->state->crtc != crtc)
continue;
@@ -2950,7 +2950,7 @@ int drm_atomic_helper_connector_dpms(struct drm_connector 
*connector,
break;
}
}
-   drm_connector_list_iter_put(_iter);
+   

[PATCH v2 6/7] drm: Introduce drm_property_blob_{get,put}()

2017-02-10 Thread Thierry Reding
From: Thierry Reding 

For consistency with other reference counting APIs in the kernel, add
drm_property_blob_get() and drm_property_blob_put() to reference count
DRM blob properties.

Compatibility aliases are added to keep existing code working. To help
speed up the transition, all the instances of the old functions in the
DRM core are already replaced in this commit.

A semantic patch is provided that can be used to convert all drivers to
the new helpers.

Reviewed-by: Sean Paul 
Acked-by: Christian König 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_atomic.c | 16 ++---
 drivers/gpu/drm/drm_atomic_helper.c  | 18 +++---
 drivers/gpu/drm/drm_mode_config.c|  2 +-
 drivers/gpu/drm/drm_property.c   | 40 
 include/drm/drm_property.h   | 35 
 scripts/coccinelle/api/drm-get-put.cocci | 10 
 6 files changed, 78 insertions(+), 43 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 740650b450c5..ff5f1756a7ff 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -322,7 +322,7 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state 
*state,
if (mode && memcmp(>mode, mode, sizeof(*mode)) == 0)
return 0;
 
-   drm_property_unreference_blob(state->mode_blob);
+   drm_property_blob_put(state->mode_blob);
state->mode_blob = NULL;
 
if (mode) {
@@ -368,7 +368,7 @@ int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state 
*state,
if (blob == state->mode_blob)
return 0;
 
-   drm_property_unreference_blob(state->mode_blob);
+   drm_property_blob_put(state->mode_blob);
state->mode_blob = NULL;
 
memset(>mode, 0, sizeof(state->mode));
@@ -380,7 +380,7 @@ int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state 
*state,
blob->data))
return -EINVAL;
 
-   state->mode_blob = drm_property_reference_blob(blob);
+   state->mode_blob = drm_property_blob_get(blob);
state->enable = true;
DRM_DEBUG_ATOMIC("Set [MODE:%s] for CRTC state %p\n",
 state->mode.name, state);
@@ -413,9 +413,9 @@ drm_atomic_replace_property_blob(struct drm_property_blob 
**blob,
if (old_blob == new_blob)
return;
 
-   drm_property_unreference_blob(old_blob);
+   drm_property_blob_put(old_blob);
if (new_blob)
-   drm_property_reference_blob(new_blob);
+   drm_property_blob_get(new_blob);
*blob = new_blob;
*replaced = true;
 
@@ -437,13 +437,13 @@ drm_atomic_replace_property_blob_from_id(struct drm_crtc 
*crtc,
return -EINVAL;
 
if (expected_size > 0 && expected_size != new_blob->length) {
-   drm_property_unreference_blob(new_blob);
+   drm_property_blob_put(new_blob);
return -EINVAL;
}
}
 
drm_atomic_replace_property_blob(blob, new_blob, replaced);
-   drm_property_unreference_blob(new_blob);
+   drm_property_blob_put(new_blob);
 
return 0;
 }
@@ -478,7 +478,7 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
struct drm_property_blob *mode =
drm_property_lookup_blob(dev, val);
ret = drm_atomic_set_mode_prop_for_crtc(state, mode);
-   drm_property_unreference_blob(mode);
+   drm_property_blob_put(mode);
return ret;
} else if (property == config->degamma_lut_property) {
ret = drm_atomic_replace_property_blob_from_id(crtc,
diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 1599a2acf7aa..6f94fca4c601 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3042,13 +3042,13 @@ void __drm_atomic_helper_crtc_duplicate_state(struct 
drm_crtc *crtc,
memcpy(state, crtc->state, sizeof(*state));
 
if (state->mode_blob)
-   drm_property_reference_blob(state->mode_blob);
+   drm_property_blob_get(state->mode_blob);
if (state->degamma_lut)
-   drm_property_reference_blob(state->degamma_lut);
+   drm_property_blob_get(state->degamma_lut);
if (state->ctm)
-   drm_property_reference_blob(state->ctm);
+   drm_property_blob_get(state->ctm);
if (state->gamma_lut)
-   drm_property_reference_blob(state->gamma_lut);
+   drm_property_blob_get(state->gamma_lut);
state->mode_changed = false;
state->active_changed = false;
state->planes_changed = 

[PATCH v2 2/7] drm: Introduce drm_mode_object_{get,put}()

2017-02-10 Thread Thierry Reding
From: Thierry Reding 

For consistency with other reference counting APIs in the kernel, add
drm_mode_object_get() and drm_mode_object_put() to reference count DRM
mode objects.

Compatibility aliases are added to keep existing code working. To help
speed up the transition, all the instances of the old functions in the
DRM core are already replaced in this commit.

A semantic patch is provided that can be used to convert all drivers to
the new helpers.

Reviewed-by: Sean Paul 
Acked-by: Christian König 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_atomic.c | 14 +--
 drivers/gpu/drm/drm_mode_object.c| 26 ++--
 drivers/gpu/drm/drm_property.c   |  6 ++---
 include/drm/drm_mode_object.h| 36 ++-
 scripts/coccinelle/api/drm-get-put.cocci | 42 
 5 files changed, 95 insertions(+), 29 deletions(-)
 create mode 100644 scripts/coccinelle/api/drm-get-put.cocci

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index a5673107db26..2bb0a759e8ec 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -2122,13 +2122,13 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
}
 
if (!obj->properties) {
-   drm_mode_object_unreference(obj);
+   drm_mode_object_put(obj);
ret = -ENOENT;
goto out;
}
 
if (get_user(count_props, count_props_ptr + copied_objs)) {
-   drm_mode_object_unreference(obj);
+   drm_mode_object_put(obj);
ret = -EFAULT;
goto out;
}
@@ -2141,14 +2141,14 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
struct drm_property *prop;
 
if (get_user(prop_id, props_ptr + copied_props)) {
-   drm_mode_object_unreference(obj);
+   drm_mode_object_put(obj);
ret = -EFAULT;
goto out;
}
 
prop = drm_mode_obj_find_prop_id(obj, prop_id);
if (!prop) {
-   drm_mode_object_unreference(obj);
+   drm_mode_object_put(obj);
ret = -ENOENT;
goto out;
}
@@ -2156,14 +2156,14 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
if (copy_from_user(_value,
   prop_values_ptr + copied_props,
   sizeof(prop_value))) {
-   drm_mode_object_unreference(obj);
+   drm_mode_object_put(obj);
ret = -EFAULT;
goto out;
}
 
ret = atomic_set_prop(state, obj, prop, prop_value);
if (ret) {
-   drm_mode_object_unreference(obj);
+   drm_mode_object_put(obj);
goto out;
}
 
@@ -2176,7 +2176,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
plane_mask |= (1 << drm_plane_index(plane));
plane->old_fb = plane->fb;
}
-   drm_mode_object_unreference(obj);
+   drm_mode_object_put(obj);
}
 
ret = prepare_crtc_signaling(dev, state, arg, file_priv, _state,
diff --git a/drivers/gpu/drm/drm_mode_object.c 
b/drivers/gpu/drm/drm_mode_object.c
index 3b405dbf1b8d..da9a9adbcc98 100644
--- a/drivers/gpu/drm/drm_mode_object.c
+++ b/drivers/gpu/drm/drm_mode_object.c
@@ -133,7 +133,7 @@ struct drm_mode_object *__drm_mode_object_find(struct 
drm_device *dev,
  *
  * This function is used to look up a modeset object. It will acquire a
  * reference for reference counted objects. This reference must be dropped 
again
- * by callind drm_mode_object_unreference().
+ * by callind drm_mode_object_put().
  */
 struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
uint32_t id, uint32_t type)
@@ -146,38 +146,38 @@ struct drm_mode_object *drm_mode_object_find(struct 
drm_device *dev,
 EXPORT_SYMBOL(drm_mode_object_find);
 
 /**
- * drm_mode_object_unreference - decr the object refcnt
- * @obj: mode_object
+ * drm_mode_object_put - release a mode object reference
+ * @obj: DRM mode object
  *
  * This function decrements the object's refcount if it is a refcounted modeset
  * object. It is a no-op on any other object. This is used to drop references
- * 

[PATCH v2 1/7] drm: Rename drm_mode_object_get()

2017-02-10 Thread Thierry Reding
From: Thierry Reding 

Subsequent patches will introduce reference counting APIs that are more
consistent with similar APIs throughout the Linux kernel. These APIs use
the _get() and _put() suffixes and will collide with this existing
function.

Rename the function to drm_mode_object_add() which is a slightly more
accurate description of what it does. Also the kerneldoc for this
function gives an indication that it's badly named because it doesn't
actually acquire a reference to anything.

Reviewed-by: Sean Paul 
Acked-by: Christian König 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_connector.c |  6 +++---
 drivers/gpu/drm/drm_crtc.c  |  2 +-
 drivers/gpu/drm/drm_crtc_internal.h | 12 +---
 drivers/gpu/drm/drm_encoder.c   |  2 +-
 drivers/gpu/drm/drm_framebuffer.c   |  4 ++--
 drivers/gpu/drm/drm_mode_object.c   | 18 +++---
 drivers/gpu/drm/drm_modes.c |  2 +-
 drivers/gpu/drm/drm_plane.c |  2 +-
 drivers/gpu/drm/drm_property.c  |  6 +++---
 9 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 45464c8b797d..0616062b055a 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -189,9 +189,9 @@ int drm_connector_init(struct drm_device *dev,
struct ida *connector_ida =
_connector_enum_list[connector_type].ida;
 
-   ret = drm_mode_object_get_reg(dev, >base,
- DRM_MODE_OBJECT_CONNECTOR,
- false, drm_connector_free);
+   ret = __drm_mode_object_add(dev, >base,
+   DRM_MODE_OBJECT_CONNECTOR,
+   false, drm_connector_free);
if (ret)
return ret;
 
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 6915f897bd8e..e2284539f82c 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -282,7 +282,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, 
struct drm_crtc *crtc,
spin_lock_init(>commit_lock);
 
drm_modeset_lock_init(>mutex);
-   ret = drm_mode_object_get(dev, >base, DRM_MODE_OBJECT_CRTC);
+   ret = drm_mode_object_add(dev, >base, DRM_MODE_OBJECT_CRTC);
if (ret)
return ret;
 
diff --git a/drivers/gpu/drm/drm_crtc_internal.h 
b/drivers/gpu/drm/drm_crtc_internal.h
index 955c5690bf64..43bbf48ee129 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -98,15 +98,13 @@ int drm_mode_destroyblob_ioctl(struct drm_device *dev,
   void *data, struct drm_file *file_priv);
 
 /* drm_mode_object.c */
-int drm_mode_object_get_reg(struct drm_device *dev,
-   struct drm_mode_object *obj,
-   uint32_t obj_type,
-   bool register_obj,
-   void (*obj_free_cb)(struct kref *kref));
+int __drm_mode_object_add(struct drm_device *dev, struct drm_mode_object *obj,
+ uint32_t obj_type, bool register_obj,
+ void (*obj_free_cb)(struct kref *kref));
+int drm_mode_object_add(struct drm_device *dev, struct drm_mode_object *obj,
+   uint32_t obj_type);
 void drm_mode_object_register(struct drm_device *dev,
  struct drm_mode_object *obj);
-int drm_mode_object_get(struct drm_device *dev,
-   struct drm_mode_object *obj, uint32_t obj_type);
 struct drm_mode_object *__drm_mode_object_find(struct drm_device *dev,
   uint32_t id, uint32_t type);
 void drm_mode_object_unregister(struct drm_device *dev,
diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c
index 129450713bb7..634ae0244ea9 100644
--- a/drivers/gpu/drm/drm_encoder.c
+++ b/drivers/gpu/drm/drm_encoder.c
@@ -110,7 +110,7 @@ int drm_encoder_init(struct drm_device *dev,
 {
int ret;
 
-   ret = drm_mode_object_get(dev, >base, DRM_MODE_OBJECT_ENCODER);
+   ret = drm_mode_object_add(dev, >base, DRM_MODE_OBJECT_ENCODER);
if (ret)
return ret;
 
diff --git a/drivers/gpu/drm/drm_framebuffer.c 
b/drivers/gpu/drm/drm_framebuffer.c
index 28a0108a1ab8..11daa24692aa 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -638,8 +638,8 @@ int drm_framebuffer_init(struct drm_device *dev, struct 
drm_framebuffer *fb,
 
fb->funcs = funcs;
 
-   ret = drm_mode_object_get_reg(dev, >base, DRM_MODE_OBJECT_FB,
- false, drm_framebuffer_free);
+   ret = __drm_mode_object_add(dev, >base, DRM_MODE_OBJECT_FB,
+   false, drm_framebuffer_free);
if (ret)

[PATCH v2 4/7] drm: Introduce drm_framebuffer_{get,put}()

2017-02-10 Thread Thierry Reding
From: Thierry Reding 

For consistency with other reference counting APIs in the kernel, add
drm_framebuffer_get() and drm_framebuffer_put() to reference count DRM
framebuffers.

Compatibility aliases are added to keep existing code working. To help
speed up the transition, all the instances of the old functions in the
DRM core are already replaced in this commit.

The existing semantic patch for the DRM subsystem-wide conversion is
extended to account for these new helpers.

Reviewed-by: Sean Paul 
Acked-by: Christian König 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_atomic.c |  6 ++--
 drivers/gpu/drm/drm_atomic_helper.c  |  4 +--
 drivers/gpu/drm/drm_crtc.c   |  8 +++---
 drivers/gpu/drm/drm_framebuffer.c| 34 +++---
 drivers/gpu/drm/drm_plane.c  | 12 
 include/drm/drm_framebuffer.h| 49 
 scripts/coccinelle/api/drm-get-put.cocci | 10 +++
 7 files changed, 79 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 82bad40b2f3e..740650b450c5 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -733,7 +733,7 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, val);
drm_atomic_set_fb_for_plane(state, fb);
if (fb)
-   drm_framebuffer_unreference(fb);
+   drm_framebuffer_put(fb);
} else if (property == config->prop_in_fence_fd) {
if (state->fence)
return -EINVAL;
@@ -1837,12 +1837,12 @@ void drm_atomic_clean_old_fb(struct drm_device *dev,
if (ret == 0) {
struct drm_framebuffer *new_fb = plane->state->fb;
if (new_fb)
-   drm_framebuffer_reference(new_fb);
+   drm_framebuffer_get(new_fb);
plane->fb = new_fb;
plane->crtc = plane->state->crtc;
 
if (plane->old_fb)
-   drm_framebuffer_unreference(plane->old_fb);
+   drm_framebuffer_put(plane->old_fb);
}
plane->old_fb = NULL;
}
diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 45c99de350c1..1599a2acf7aa 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3151,7 +3151,7 @@ void __drm_atomic_helper_plane_duplicate_state(struct 
drm_plane *plane,
memcpy(state, plane->state, sizeof(*state));
 
if (state->fb)
-   drm_framebuffer_reference(state->fb);
+   drm_framebuffer_get(state->fb);
 
state->fence = NULL;
 }
@@ -3191,7 +3191,7 @@ EXPORT_SYMBOL(drm_atomic_helper_plane_duplicate_state);
 void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
 {
if (state->fb)
-   drm_framebuffer_unreference(state->fb);
+   drm_framebuffer_put(state->fb);
 
if (state->fence)
dma_fence_put(state->fence);
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 9594c623799b..e2974d3c92e7 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -471,9 +471,9 @@ int drm_mode_set_config_internal(struct drm_mode_set *set)
 
drm_for_each_crtc(tmp, crtc->dev) {
if (tmp->primary->fb)
-   drm_framebuffer_reference(tmp->primary->fb);
+   drm_framebuffer_get(tmp->primary->fb);
if (tmp->primary->old_fb)
-   drm_framebuffer_unreference(tmp->primary->old_fb);
+   drm_framebuffer_put(tmp->primary->old_fb);
tmp->primary->old_fb = NULL;
}
 
@@ -567,7 +567,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
}
fb = crtc->primary->fb;
/* Make refcounting symmetric with the lookup path. */
-   drm_framebuffer_reference(fb);
+   drm_framebuffer_get(fb);
} else {
fb = drm_framebuffer_lookup(dev, crtc_req->fb_id);
if (!fb) {
@@ -680,7 +680,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
 
 out:
if (fb)
-   drm_framebuffer_unreference(fb);
+   drm_framebuffer_put(fb);
 
if (connector_set) {
for (i = 0; i < crtc_req->count_connectors; i++) {
diff --git a/drivers/gpu/drm/drm_framebuffer.c 
b/drivers/gpu/drm/drm_framebuffer.c
index 11daa24692aa..5e8e1d06866a 100644
--- 

[PATCH v2 3/7] drm: Introduce drm_connector_{get,put}()

2017-02-10 Thread Thierry Reding
From: Thierry Reding 

For consistency with other reference counting APIs in the kernel, add
drm_connector_get() and drm_connector_put() functions to reference count
connectors.

Compatibility aliases are added to keep existing code working. To help
speed up the transition, all the instances of the old functions in the
DRM core are already replaced in this commit.

The existing semantic patch for mode object reference count conversion
is extended for these new helpers.

Reviewed-by: Sean Paul 
Acked-by: Christian König 
Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_atomic.c |  8 +++
 drivers/gpu/drm/drm_atomic_helper.c  |  4 ++--
 drivers/gpu/drm/drm_connector.c  | 10 
 drivers/gpu/drm/drm_crtc.c   |  2 +-
 drivers/gpu/drm/drm_crtc_helper.c|  6 ++---
 drivers/gpu/drm/drm_fb_helper.c  | 12 +-
 drivers/gpu/drm/drm_mode_config.c|  2 +-
 include/drm/drm_connector.h  | 41 +---
 scripts/coccinelle/api/drm-get-put.cocci | 10 
 9 files changed, 65 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 2bb0a759e8ec..82bad40b2f3e 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -150,7 +150,7 @@ void drm_atomic_state_default_clear(struct drm_atomic_state 
*state)
   
state->connectors[i].state);
state->connectors[i].ptr = NULL;
state->connectors[i].state = NULL;
-   drm_connector_unreference(connector);
+   drm_connector_put(connector);
}
 
for (i = 0; i < config->num_crtc; i++) {
@@ -1026,7 +1026,7 @@ drm_atomic_get_connector_state(struct drm_atomic_state 
*state,
if (!connector_state)
return ERR_PTR(-ENOMEM);
 
-   drm_connector_reference(connector);
+   drm_connector_get(connector);
state->connectors[index].state = connector_state;
state->connectors[index].ptr = connector;
connector_state->state = state;
@@ -1357,7 +1357,7 @@ drm_atomic_set_crtc_for_connector(struct 
drm_connector_state *conn_state,
crtc_state->connector_mask &=
~(1 << drm_connector_index(conn_state->connector));
 
-   drm_connector_unreference(conn_state->connector);
+   drm_connector_put(conn_state->connector);
conn_state->crtc = NULL;
}
 
@@ -1369,7 +1369,7 @@ drm_atomic_set_crtc_for_connector(struct 
drm_connector_state *conn_state,
crtc_state->connector_mask |=
1 << drm_connector_index(conn_state->connector);
 
-   drm_connector_reference(conn_state->connector);
+   drm_connector_get(conn_state->connector);
conn_state->crtc = crtc;
 
DRM_DEBUG_ATOMIC("Link connector state %p to [CRTC:%d:%s]\n",
diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 01d936b7be43..45c99de350c1 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3272,7 +3272,7 @@ __drm_atomic_helper_connector_duplicate_state(struct 
drm_connector *connector,
 {
memcpy(state, connector->state, sizeof(*state));
if (state->crtc)
-   drm_connector_reference(connector);
+   drm_connector_get(connector);
 }
 EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state);
 
@@ -3398,7 +3398,7 @@ void
 __drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state)
 {
if (state->crtc)
-   drm_connector_unreference(state->connector);
+   drm_connector_put(state->connector);
 }
 EXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state);
 
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 0616062b055a..0dc0e5b33f8a 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -35,8 +35,8 @@
  * als fixed panels or anything else that can display pixels in some form. As
  * opposed to all other KMS objects representing hardware (like CRTC, encoder 
or
  * plane abstractions) connectors can be hotplugged and unplugged at runtime.
- * Hence they are reference-counted using drm_connector_reference() and
- * drm_connector_unreference().
+ * Hence they are reference-counted using drm_connector_get() and
+ * drm_connector_put().
  *
  * KMS driver must create, initialize, register and attach at a 
  * drm_connector for each such sink. The instance is created as other KMS
@@ -545,7 +545,7 @@ drm_connector_list_iter_next(struct drm_connector_list_iter 
*iter)
spin_unlock_irqrestore(>connector_list_lock, flags);
 
if (old_conn)
-   drm_connector_unreference(old_conn);
+   

[PATCH v2 0/7] drm: Introduce consistent reference counting APIs

2017-02-10 Thread Thierry Reding
From: Thierry Reding 

This series introduces DRM reference counting APIs that are consistent
with other reference counting APIs in the kernel. They are also much
shorter. Compatibility aliases are added to keep existing code working
and will stay in place until all users of the old APIs are gone.

All occurrences of the old APIs in the core are already replaced by
this series, and a semantic patch is provided that allows drivers to
be converted automatically. I plan on generating patches against the
drivers once the new functions have been merged and send them out to
their respective maintainers.

Oh, and this fixes one of the items in our recently added TODO list.

Changes in v2:
- add patch to rename drm_connector_list_iter_{get,put}() because they
  aren't in fact reference counting
- add Reviewed-by from Sean, Acked-by from Christian
- left in the semantic patch for convenience, it can be removed along
  with the compatibility functions

Thanks,
Thierry

Thierry Reding (7):
  drm: Rename drm_mode_object_get()
  drm: Introduce drm_mode_object_{get,put}()
  drm: Introduce drm_connector_{get,put}()
  drm: Introduce drm_framebuffer_{get,put}()
  drm: Introduce drm_gem_object_{get,put}()
  drm: Introduce drm_property_blob_{get,put}()
  drm: Rename connector list iterator API

 Documentation/gpu/drm-mm.rst | 14 +++--
 drivers/gpu/drm/drm_atomic.c | 54 +--
 drivers/gpu/drm/drm_atomic_helper.c  | 44 +++
 drivers/gpu/drm/drm_connector.c  | 40 +++---
 drivers/gpu/drm/drm_crtc.c   | 12 ++---
 drivers/gpu/drm/drm_crtc_helper.c| 42 +++
 drivers/gpu/drm/drm_crtc_internal.h  | 12 ++---
 drivers/gpu/drm/drm_encoder.c|  8 +--
 drivers/gpu/drm/drm_fb_cma_helper.c  | 16 +++---
 drivers/gpu/drm/drm_fb_helper.c  | 16 +++---
 drivers/gpu/drm/drm_framebuffer.c| 38 ++---
 drivers/gpu/drm/drm_gem.c| 44 +++
 drivers/gpu/drm/drm_gem_cma_helper.c | 10 ++--
 drivers/gpu/drm/drm_mode_config.c| 22 
 drivers/gpu/drm/drm_mode_object.c| 44 +++
 drivers/gpu/drm/drm_modes.c  |  2 +-
 drivers/gpu/drm/drm_plane.c  | 14 ++---
 drivers/gpu/drm/drm_plane_helper.c   |  4 +-
 drivers/gpu/drm/drm_prime.c  | 10 ++--
 drivers/gpu/drm/drm_probe_helper.c   | 12 ++---
 drivers/gpu/drm/drm_property.c   | 52 +-
 include/drm/drm_connector.h  | 51 +-
 include/drm/drm_framebuffer.h| 49 -
 include/drm/drm_gem.h| 80 +--
 include/drm/drm_mode_object.h| 36 ++---
 include/drm/drm_property.h   | 35 ++--
 scripts/coccinelle/api/drm-get-put.cocci | 92 
 27 files changed, 542 insertions(+), 311 deletions(-)
 create mode 100644 scripts/coccinelle/api/drm-get-put.cocci

-- 
2.11.1

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


[PATCH 8/8] Revert "drm/amdgpu: Refactor flip into prepare submit and submit. (v3)"

2017-02-10 Thread Harry Wentland
This reverts commit cb341a319f7e66f879d69af929c3dadfc1a8f31e.
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 136 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h|  15 ---
 2 files changed, 28 insertions(+), 123 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index a6000ce6ff43..7bcc65b0c76d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -138,52 +138,10 @@ static void amdgpu_unpin_work_func(struct work_struct 
*__work)
kfree(work);
 }
 
-
-static void amdgpu_flip_work_cleanup(struct amdgpu_flip_work *work)
-{
-   int i;
-
-   amdgpu_bo_unref(>old_abo);
-   dma_fence_put(work->excl);
-   for (i = 0; i < work->shared_count; ++i)
-   dma_fence_put(work->shared[i]);
-   kfree(work->shared);
-   kfree(work);
-}
-
-static void amdgpu_flip_cleanup_unreserve(struct amdgpu_flip_work *work,
- struct amdgpu_bo *new_abo)
-{
-   amdgpu_bo_unreserve(new_abo);
-   amdgpu_flip_work_cleanup(work);
-}
-
-static void amdgpu_flip_cleanup_unpin(struct amdgpu_flip_work *work,
- struct amdgpu_bo *new_abo)
-{
-   if (unlikely(amdgpu_bo_unpin(new_abo) != 0))
-   DRM_ERROR("failed to unpin new abo in error path\n");
-   amdgpu_flip_cleanup_unreserve(work, new_abo);
-}
-
-void amdgpu_crtc_cleanup_flip_ctx(struct amdgpu_flip_work *work,
- struct amdgpu_bo *new_abo)
-{
-   if (unlikely(amdgpu_bo_reserve(new_abo, false) != 0)) {
-   DRM_ERROR("failed to reserve new abo in error path\n");
-   amdgpu_flip_work_cleanup(work);
-   return;
-   }
-   amdgpu_flip_cleanup_unpin(work, new_abo);
-}
-
-int amdgpu_crtc_prepare_flip(struct drm_crtc *crtc,
-struct drm_framebuffer *fb,
-struct drm_pending_vblank_event *event,
-uint32_t page_flip_flags,
-uint32_t target,
-struct amdgpu_flip_work **work_p,
-struct amdgpu_bo **new_abo_p)
+int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
+struct drm_framebuffer *fb,
+struct drm_pending_vblank_event *event,
+uint32_t page_flip_flags, uint32_t target)
 {
struct drm_device *dev = crtc->dev;
struct amdgpu_device *adev = dev->dev_private;
@@ -196,7 +154,7 @@ int amdgpu_crtc_prepare_flip(struct drm_crtc *crtc,
unsigned long flags;
u64 tiling_flags;
u64 base;
-   int r;
+   int i, r;
 
work = kzalloc(sizeof *work, GFP_KERNEL);
if (work == NULL)
@@ -257,79 +215,41 @@ int amdgpu_crtc_prepare_flip(struct drm_crtc *crtc,
spin_unlock_irqrestore(>dev->event_lock, flags);
r = -EBUSY;
goto pflip_cleanup;
-
}
-   spin_unlock_irqrestore(>dev->event_lock, flags);
-
-   *work_p = work;
-   *new_abo_p = new_abo;
-
-   return 0;
-
-pflip_cleanup:
-   amdgpu_crtc_cleanup_flip_ctx(work, new_abo);
-   return r;
-
-unpin:
-   amdgpu_flip_cleanup_unpin(work, new_abo);
-   return r;
-
-unreserve:
-   amdgpu_flip_cleanup_unreserve(work, new_abo);
-   return r;
 
-cleanup:
-   amdgpu_flip_work_cleanup(work);
-   return r;
-
-}
-
-void amdgpu_crtc_submit_flip(struct drm_crtc *crtc,
-struct drm_framebuffer *fb,
-struct amdgpu_flip_work *work,
-struct amdgpu_bo *new_abo)
-{
-   unsigned long flags;
-   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-
-   spin_lock_irqsave(>dev->event_lock, flags);
amdgpu_crtc->pflip_status = AMDGPU_FLIP_PENDING;
amdgpu_crtc->pflip_works = work;
 
+
+   DRM_DEBUG_DRIVER("crtc:%d[%p], pflip_stat:AMDGPU_FLIP_PENDING, work: 
%p,\n",
+amdgpu_crtc->crtc_id, amdgpu_crtc, 
work);
/* update crtc fb */
crtc->primary->fb = fb;
spin_unlock_irqrestore(>dev->event_lock, flags);
-
-   DRM_DEBUG_DRIVER(
-   "crtc:%d[%p], pflip_stat:AMDGPU_FLIP_PENDING, work: 
%p,\n",
-   amdgpu_crtc->crtc_id, amdgpu_crtc, work);
-
amdgpu_flip_work_func(>flip_work.work);
-}
-
-int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
-struct drm_framebuffer *fb,
-struct drm_pending_vblank_event *event,
-uint32_t page_flip_flags,
-uint32_t target)
-{
-   struct amdgpu_bo *new_abo;
-   struct amdgpu_flip_work *work;
-   int r;
+   return 0;
 
- 

[PATCH 6/8] drm/amd/display: Refactor atomic commit implementation.

2017-02-10 Thread Harry Wentland
From: Andrey Grodzovsky 

Modify amdgpu_dm_atomic_comit to implement
atomic_comit_tail hook.
Unify Buffer objects allocation and dealocation
for surface updates and page flips.
Simplify wait for fences and target_vbank logic
for non blockiing commit.
Remove hacky update surface to page flip synchronization
we had and rely on atomic framework synchronization logic.

Change-Id: I23a01d2744b9f75d4e534a95e586d64de47ca32c
Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |  62 ++--
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c| 321 +
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.h|   7 +-
 3 files changed, 190 insertions(+), 200 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 b259867364fa..58eac40fb464 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -155,7 +155,6 @@ static struct amdgpu_crtc *get_crtc_by_otg_inst(
 
 static void dm_pflip_high_irq(void *interrupt_params)
 {
-   struct amdgpu_flip_work *works;
struct amdgpu_crtc *amdgpu_crtc;
struct common_irq_params *irq_params = interrupt_params;
struct amdgpu_device *adev = irq_params->adev;
@@ -171,7 +170,6 @@ static void dm_pflip_high_irq(void *interrupt_params)
}
 
spin_lock_irqsave(>ddev->event_lock, flags);
-   works = amdgpu_crtc->pflip_works;
 
if (amdgpu_crtc->pflip_status != AMDGPU_FLIP_SUBMITTED){
DRM_DEBUG_DRIVER("amdgpu_crtc->pflip_status = %d 
!=AMDGPU_FLIP_SUBMITTED(%d) on crtc:%d[%p] \n",
@@ -183,23 +181,25 @@ static void dm_pflip_high_irq(void *interrupt_params)
return;
}
 
-   /* page flip completed. clean up */
-   amdgpu_crtc->pflip_status = AMDGPU_FLIP_NONE;
-   amdgpu_crtc->pflip_works = NULL;
 
/* wakeup usersapce */
-   if (works->event)
-   drm_crtc_send_vblank_event(_crtc->base,
-  works->event);
+   if (amdgpu_crtc->event &&
+   amdgpu_crtc->event->event.base.type
+   == DRM_EVENT_FLIP_COMPLETE) {
+   drm_crtc_send_vblank_event(_crtc->base, 
amdgpu_crtc->event);
+   /* page flip completed. clean up */
+   amdgpu_crtc->event = NULL;
+   } else {
+   WARN_ON(1);
+   }
 
+   amdgpu_crtc->pflip_status = AMDGPU_FLIP_NONE;
spin_unlock_irqrestore(>ddev->event_lock, flags);
 
-   DRM_DEBUG_DRIVER("%s - crtc :%d[%p], pflip_stat:AMDGPU_FLIP_NONE, work: 
%p,\n",
-   __func__, amdgpu_crtc->crtc_id, 
amdgpu_crtc, works);
+   DRM_DEBUG_DRIVER("%s - crtc :%d[%p], pflip_stat:AMDGPU_FLIP_NONE \n",
+   __func__, amdgpu_crtc->crtc_id, 
amdgpu_crtc);
 
-   if (amdgpu_crtc->base.funcs->page_flip_target)
-   drm_crtc_vblank_put(_crtc->base);
-   schedule_work(>unpin_work);
+   drm_crtc_vblank_put(_crtc->base);
 }
 
 static void dm_crtc_high_irq(void *interrupt_params)
@@ -731,7 +731,11 @@ static struct drm_mode_config_funcs amdgpu_dm_mode_funcs = 
{
.fb_create = amdgpu_user_framebuffer_create,
.output_poll_changed = amdgpu_output_poll_changed,
.atomic_check = amdgpu_dm_atomic_check,
-   .atomic_commit = amdgpu_dm_atomic_commit
+   .atomic_commit = drm_atomic_helper_commit
+};
+
+static struct drm_mode_config_helper_funcs amdgpu_dm_mode_config_helperfuncs = 
{
+   .atomic_commit_tail = amdgpu_dm_atomic_commit_tail
 };
 
 void amdgpu_dm_update_connector_after_detect(
@@ -1106,6 +1110,7 @@ static int amdgpu_dm_mode_config_init(struct 
amdgpu_device *adev)
adev->mode_info.mode_config_initialized = true;
 
adev->ddev->mode_config.funcs = (void *)_dm_mode_funcs;
+   adev->ddev->mode_config.helper_private = 
_dm_mode_config_helperfuncs;
 
adev->ddev->mode_config.max_width = 16384;
adev->ddev->mode_config.max_height = 16384;
@@ -1359,6 +1364,14 @@ static void dm_page_flip(struct amdgpu_device *adev,
acrtc = adev->mode_info.crtcs[crtc_id];
stream = acrtc->stream;
 
+
+   if (acrtc->pflip_status != AMDGPU_FLIP_NONE) {
+   DRM_ERROR("flip queue: acrtc %d, already busy\n", 
acrtc->crtc_id);
+   /* In commit tail framework this cannot happen */
+   BUG_ON(0);
+   }
+
+
/*
 * Received a page flip call after the display has been reset.
 * Just return in this case. Everything should be clean-up on reset.
@@ -1373,15 +1386,28 @@ static void dm_page_flip(struct amdgpu_device *adev,
addr.address.grph.addr.high_part = upper_32_bits(crtc_base);
addr.flip_immediate = async;
 
+
+   if (acrtc->base.state->event &&
+   

[PATCH 7/8] drm/amd/display: Refactor headless to use atomic commit.

2017-02-10 Thread Harry Wentland
From: Andrey Grodzovsky 

Headless mode set needs to be synchronized against outstanding nonblocking
commits. This achieved by building atomic state and commiting it.

Change-Id: Ie5e778afb33dd5c303a169216a7bb8c2d857037e
Signed-off-by: Andrey Grodzovsky 
---
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c| 140 +
 1 file changed, 61 insertions(+), 79 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
index 93cc3d128a11..69c85ef63c4b 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
@@ -2802,6 +2802,65 @@ void amdgpu_dm_atomic_commit_tail(
/* Release old FB */
drm_atomic_helper_cleanup_planes(dev, state);
 }
+
+
+static int dm_force_atomic_commit(struct drm_connector *connector)
+{
+   int ret = 0;
+   struct drm_device *ddev = connector->dev;
+   struct drm_atomic_state *state = drm_atomic_state_alloc(ddev);
+   struct amdgpu_crtc *disconnected_acrtc = 
to_amdgpu_crtc(connector->encoder->crtc);
+   struct drm_plane *plane = disconnected_acrtc->base.primary;
+   struct drm_connector_state *conn_state;
+   struct drm_crtc_state *crtc_state;
+   struct drm_plane_state *plane_state;
+
+   if (!state)
+   return ENOMEM;
+
+   state->acquire_ctx = ddev->mode_config.acquire_ctx;
+
+   /* Construct an atomic state to restore previous display setting */
+
+   /*
+* Attach connectors to drm_atomic_state
+*/
+   conn_state = drm_atomic_get_connector_state(state, connector);
+
+   ret = PTR_ERR_OR_ZERO(conn_state);
+   if (ret)
+   goto err;
+
+   /* Attach crtc to drm_atomic_state*/
+   crtc_state = drm_atomic_get_crtc_state(state, 
_acrtc->base);
+
+   ret = PTR_ERR_OR_ZERO(crtc_state);
+   if (ret)
+   goto err;
+
+   /* force a restore */
+   crtc_state->mode_changed = true;
+
+   /* Attach plane to drm_atomic_state */
+   plane_state = drm_atomic_get_plane_state(state, plane);
+
+   ret = PTR_ERR_OR_ZERO(plane_state);
+   if (ret)
+   goto err;
+
+
+   /* Call commit internally with the state we just constructed */
+   ret = drm_atomic_commit(state);
+   if (!ret)
+   return 0;
+
+err:
+   DRM_ERROR("Restoring old state failed with %i\n", ret);
+   drm_atomic_state_put(state);
+
+   return ret;
+}
+
 /*
  * This functions handle all cases when set mode does not come upon hotplug.
  * This include when the same display is unplugged then plugged back into the
@@ -2809,15 +2868,8 @@ void amdgpu_dm_atomic_commit_tail(
  */
 void dm_restore_drm_connector_state(struct drm_device *dev, struct 
drm_connector *connector)
 {
-   struct drm_crtc *crtc;
-   struct amdgpu_device *adev = dev->dev_private;
-   struct dc *dc = adev->dm.dc;
struct amdgpu_connector *aconnector = to_amdgpu_connector(connector);
struct amdgpu_crtc *disconnected_acrtc;
-   const struct dc_sink *sink;
-   const struct dc_stream *commit_streams[MAX_STREAMS];
-   const struct dc_stream *current_stream;
-   uint32_t commit_streams_count = 0;
 
if (!aconnector->dc_sink || !connector->state || !connector->encoder)
return;
@@ -2827,83 +2879,13 @@ void dm_restore_drm_connector_state(struct drm_device 
*dev, struct drm_connector
if (!disconnected_acrtc || !disconnected_acrtc->stream)
return;
 
-   sink = disconnected_acrtc->stream->sink;
-
/*
 * If the previous sink is not released and different from the current,
 * we deduce we are in a state where we can not rely on usermode call
 * to turn on the display, so we do it here
 */
-   if (sink != aconnector->dc_sink) {
-   struct dm_connector_state *dm_state =
-   to_dm_connector_state(aconnector->base.state);
-
-   struct dc_stream *new_stream =
-   create_stream_for_sink(
-   aconnector,
-   _acrtc->base.state->mode,
-   dm_state);
-
-   DRM_INFO("Headless hotplug, restoring connector state\n");
-   /*
-* we evade vblanks and pflips on crtc that
-* should be changed
-*/
-   manage_dm_interrupts(adev, disconnected_acrtc, false);
-   /* this is the update mode case */
-
-   current_stream = disconnected_acrtc->stream;
-
-   disconnected_acrtc->stream = new_stream;
-   disconnected_acrtc->enabled = true;
-   disconnected_acrtc->hw_mode = 
disconnected_acrtc->base.state->mode;
-
-   commit_streams_count = 0;
-
- 

[PATCH 5/8] drm/amdgpu: Add a few members to support DAL atomic refactor.

2017-02-10 Thread Harry Wentland
From: Andrey Grodzovsky 

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index fda53fa0313f..1e77136d6f0c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -322,6 +322,9 @@ struct amdgpu_display_funcs {
 struct amdgpu_framebuffer {
struct drm_framebuffer base;
struct drm_gem_object *obj;
+
+   /* caching for later use */
+   uint64_t address;
 };
 
 struct amdgpu_fbdev {
@@ -447,6 +450,7 @@ struct amdgpu_crtc {
uint32_t flip_flags;
/* After Set Mode stream will be non-NULL */
const struct dc_stream *stream;
+   struct drm_pending_vblank_event *event;
 };
 
 struct amdgpu_encoder_atom_dig {
-- 
2.9.3

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


[PATCH 4/8] drm/amd/display: Remove unused define from amdgpu_dm_types

2017-02-10 Thread Harry Wentland
Change-Id: Idfd0d0d6e537eddbc75378ba394b0f36bd89dd50
Signed-off-by: Harry Wentland 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.h 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.h
index 6ed1480a8bc3..4faa1659f7f9 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.h
@@ -59,11 +59,6 @@ int amdgpu_dm_atomic_commit(
 int amdgpu_dm_atomic_check(struct drm_device *dev,
struct drm_atomic_state *state);
 
-int dm_create_validation_set_for_stream(
-   struct drm_connector *connector,
-   struct drm_display_mode *mode,
-   struct dc_validation_set *val_set);
-
 void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector);
 struct drm_connector_state *amdgpu_dm_connector_atomic_duplicate_state(
struct drm_connector *connector);
-- 
2.9.3

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


[PATCH 3/8] drm/amd/display: Use atomic helpers for gamma

2017-02-10 Thread Harry Wentland
We were using set_properties and gamma in a weird way.
This change aligns the properties with other drivers
and allows us to remove a private gamma flag and reuse
atomic helpers for most of this.

Change-Id: Ic74b692ee6c6d3e4fd938c6226e65b54075ff983
Signed-off-by: Harry Wentland 
---
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c| 89 +-
 1 file changed, 21 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
index e80ecd5707f8..2ee5765f0315 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
@@ -61,7 +61,6 @@ struct dm_connector_state {
 #define to_dm_connector_state(x)\
container_of((x), struct dm_connector_state, base)
 
-#define AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET 1
 
 void amdgpu_dm_encoder_destroy(struct drm_encoder *encoder)
 {
@@ -551,23 +550,18 @@ static void fill_gamma_from_crtc(
 {
int i;
struct dc_gamma *gamma;
-   uint16_t *red, *green, *blue;
-   int end = (crtc->gamma_size > NUM_OF_RAW_GAMMA_RAMP_RGB_256) ?
-   NUM_OF_RAW_GAMMA_RAMP_RGB_256 : crtc->gamma_size;
-
-   red = crtc->gamma_store;
-   green = red + crtc->gamma_size;
-   blue = green + crtc->gamma_size;
+   struct drm_crtc_state *state = crtc->state;
+   struct drm_color_lut *lut = (struct drm_color_lut *) 
state->gamma_lut->data;
 
gamma = dc_create_gamma();
 
if (gamma == NULL)
return;
 
-   for (i = 0; i < end; i++) {
-   gamma->red[i] = (unsigned short) red[i];
-   gamma->green[i] = (unsigned short) green[i];
-   gamma->blue[i] = (unsigned short) blue[i];
+   for (i = 0; i < NUM_OF_RAW_GAMMA_RAMP_RGB_256; i++) {
+   gamma->red[i] = lut[i].red;
+   gamma->green[i] = lut[i].green;
+   gamma->blue[i] = lut[i].blue;
}
 
dc_surface->gamma_correction = gamma;
@@ -601,8 +595,7 @@ static void fill_plane_attributes(
surface->in_transfer_func = input_tf;
 
/* In case of gamma set, update gamma value */
-   if (crtc->mode.private_flags &
-   AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET) {
+   if (state->crtc->state->gamma_lut) {
fill_gamma_from_crtc(crtc, surface);
}
 }
@@ -719,12 +712,6 @@ static void dm_dc_surface_commit(
dc_surface,
crtc->primary->state,
true);
-   if (crtc->mode.private_flags &
-   AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET) {
-   /* reset trigger of gamma */
-   crtc->mode.private_flags &=
-   ~AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET;
-   }
 
dc_surfaces[0] = dc_surface;
 
@@ -1049,50 +1036,6 @@ void amdgpu_dm_crtc_destroy(struct drm_crtc *crtc)
kfree(crtc);
 }
 
-static int amdgpu_dm_atomic_crtc_gamma_set(
-   struct drm_crtc *crtc,
-   u16 *red,
-   u16 *green,
-   u16 *blue,
-   uint32_t size)
-{
-   struct drm_device *dev = crtc->dev;
-   struct drm_property *prop = dev->mode_config.prop_crtc_id;
-
-   crtc->state->mode.private_flags |= 
AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET;
-
-   return drm_atomic_helper_crtc_set_property(crtc, prop, 0);
-}
-
-static int dm_crtc_funcs_atomic_set_property(
-   struct drm_crtc *crtc,
-   struct drm_crtc_state *crtc_state,
-   struct drm_property *property,
-   uint64_t val)
-{
-   struct drm_plane_state *plane_state;
-
-   crtc_state->planes_changed = true;
-
-   /*
-* Bit of magic done here. We need to ensure
-* that planes get update after mode is set.
-* So, we need to add primary plane to state,
-* and this way atomic_update would be called
-* for it
-*/
-   plane_state =
-   drm_atomic_get_plane_state(
-   crtc_state->state,
-   crtc->primary);
-
-   if (!plane_state)
-   return -EINVAL;
-
-   return 0;
-}
-
-
 static int amdgpu_atomic_helper_page_flip(struct drm_crtc *crtc,
struct drm_framebuffer *fb,
struct drm_pending_vblank_event *event,
@@ -1174,12 +1117,12 @@ static const struct drm_crtc_funcs amdgpu_dm_crtc_funcs 
= {
.cursor_set = dm_crtc_cursor_set,
.cursor_move = dm_crtc_cursor_move,
.destroy = amdgpu_dm_crtc_destroy,
-   .gamma_set = amdgpu_dm_atomic_crtc_gamma_set,
+   .gamma_set = drm_atomic_helper_legacy_gamma_set,
.set_config = drm_atomic_helper_set_config,
+   .set_property = drm_atomic_helper_crtc_set_property,
.page_flip = amdgpu_atomic_helper_page_flip,
.atomic_duplicate_state = 

[PATCH 1/8] drm/amdgpu: Expose mode_config functions for DM

2017-02-10 Thread Harry Wentland
Signed-off-by: Harry Wentland 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c |  4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h | 33 +
 2 files changed, 35 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index a7d3a3943e56..a6000ce6ff43 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -596,7 +596,7 @@ amdgpu_framebuffer_init(struct drm_device *dev,
return 0;
 }
 
-static struct drm_framebuffer *
+struct drm_framebuffer *
 amdgpu_user_framebuffer_create(struct drm_device *dev,
   struct drm_file *file_priv,
   const struct drm_mode_fb_cmd2 *mode_cmd)
@@ -628,7 +628,7 @@ amdgpu_user_framebuffer_create(struct drm_device *dev,
return _fb->base;
 }
 
-static void amdgpu_output_poll_changed(struct drm_device *dev)
+void amdgpu_output_poll_changed(struct drm_device *dev)
 {
struct amdgpu_device *adev = dev->dev_private;
amdgpu_fb_output_poll_changed(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.h
new file mode 100644
index ..3cc0ef0c055e
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2017 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.
+ *
+ */
+#ifndef __AMDGPU_DISPLAY_H__
+#define __AMDGPU_DISPLAY_H__
+
+struct drm_framebuffer *
+amdgpu_user_framebuffer_create(struct drm_device *dev,
+  struct drm_file 
*file_priv,
+  const struct 
drm_mode_fb_cmd2 *mode_cmd);
+
+void amdgpu_output_poll_changed(struct drm_device *dev);
+
+#endif
-- 
2.9.3

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


[PATCH 2/8] drm/amd/display: Use amdgpu mode funcs statically

2017-02-10 Thread Harry Wentland
No need to assign them dynamically. This is much more readable.

Change-Id: I2d8a356e8d916800c4553c4e9b19ce42f7f1c391
Signed-off-by: Harry Wentland 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 +++-
 1 file changed, 3 insertions(+), 5 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 5a2ed49c0b8a..b259867364fa 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -28,6 +28,7 @@
 
 #include "vid.h"
 #include "amdgpu.h"
+#include "amdgpu_display.h"
 #include "atom.h"
 #include "amdgpu_dm.h"
 #include "amdgpu_dm_types.h"
@@ -727,6 +728,8 @@ const struct amdgpu_ip_block_version dm_ip_block =
 
 /* TODO: it is temporary non-const, should fixed later */
 static struct drm_mode_config_funcs amdgpu_dm_mode_funcs = {
+   .fb_create = amdgpu_user_framebuffer_create,
+   .output_poll_changed = amdgpu_output_poll_changed,
.atomic_check = amdgpu_dm_atomic_check,
.atomic_commit = amdgpu_dm_atomic_commit
 };
@@ -1102,11 +1105,6 @@ static int amdgpu_dm_mode_config_init(struct 
amdgpu_device *adev)
 
adev->mode_info.mode_config_initialized = true;
 
-   amdgpu_dm_mode_funcs.fb_create =
-   amdgpu_mode_funcs.fb_create;
-   amdgpu_dm_mode_funcs.output_poll_changed =
-   amdgpu_mode_funcs.output_poll_changed;
-
adev->ddev->mode_config.funcs = (void *)_dm_mode_funcs;
 
adev->ddev->mode_config.max_width = 16384;
-- 
2.9.3

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


[PATCH 0/8] Refactor DC atomic commit and gamma

2017-02-10 Thread Harry Wentland
Resending with CC to dri-devel as per Alex's suggestions. This
might be of interest to a wider audience.

These patches are first steps of addressing some of the problems
in DC's atomic implementation. Please take a look and provide
feedback if possible. Our hope is that we can start setting a
direction on fixing up DC to do atomic correctly and lay the
groundwork for moving past the midlayer.

THe biggest patch here is Andrey's work to bring atomic_commit
in line with the atomic helpers instead of rolling our own. We
got atomic_commmit_tail now and things appear to work correctly
with this change. It allowed us to clean up some of the commit
code, but there's still a lot left.

The second important patch is fixing up our gamma implementation
and correct the use of crtc_set_property and atomic_set_properties.

Beyond that there's some minor cleanup and support patches for
the above change.

The whole DC tree with these patches and rebased on drm-next a couple
days ago can be found at 

https://cgit.freedesktop.org/~hwentland/linux/log/?h=dc-drm-next-atomic

Known issue:
  - corruption on one display in two-display setup

Cheers,
Harry

Andrey Grodzovsky (3):
  drm/amdgpu: Add a few members to support DAL atomic refactor.
  drm/amd/display: Refactor atomic commit implementation.
  drm/amd/display: Refactor headless to use atomic commit.

Harry Wentland (5):
  drm/amdgpu: Expose mode_config functions for DM
  drm/amd/display: Use amdgpu mode funcs statically
  drm/amd/display: Use atomic helpers for gamma
  drm/amd/display: Remove unused define from amdgpu_dm_types
  Revert "drm/amdgpu: Refactor flip into prepare submit and submit.
(v3)"

 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c| 140 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h|  33 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h   |  19 +-
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |  70 ++-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c| 548 +
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.h|  12 +-
 6 files changed, 341 insertions(+), 481 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h

-- 
2.9.3

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


[PATCH v3 6/6] drm/i915: allow HDMI 2.0 clock rates

2017-02-10 Thread Shashank Sharma
Geminilake has a native HDMI 2.0 controller, which is capable of
driving clocks upto 594Mhz. This patch updates the max tmds clock
limit for the same.

V2: rebase
V3: rebase

Cc: Ander Conselvan De Oliveira 
Signed-off-by: Shashank Sharma 
---
 drivers/gpu/drm/i915/intel_hdmi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
b/drivers/gpu/drm/i915/intel_hdmi.c
index 9970131..b1ddcc5 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -1210,6 +1210,8 @@ static int intel_hdmi_source_max_tmds_clock(struct 
drm_i915_private *dev_priv)
 {
if (IS_G4X(dev_priv))
return 165000;
+   else if (IS_GEMINILAKE(dev_priv))
+   return 594000;
else if (IS_HASWELL(dev_priv) || INTEL_INFO(dev_priv)->gen >= 8)
return 30;
else
-- 
1.9.1

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


[PATCH v3 5/6] drm/i915: enable scrambling

2017-02-10 Thread Shashank Sharma
Geminilake platform sports a native HDMI 2.0 controller, and is
capable of driving pixel-clocks upto 594Mhz. HDMI 2.0 spec
mendates scrambling for these higher clocks, for reduced RF footprint.

This patch checks if the monitor supports scrambling, and if required,
enables it during the modeset.

V2: Addressed review comments from Ville:
- Do not track scrambling status in DRM layer, track somewhere in
  driver like in intel_crtc_state.
- Don't talk to monitor at such a low layer, set monitor scrambling
  in intel_enable_ddi() before enabling the port.

V3: Addressed review comments from Jani
- In comments, function names, use "sink" instead of "monitor",
  so that the implementation could be close to the language of
  HDMI spec.

Signed-off-by: Shashank Sharma 
---
 drivers/gpu/drm/i915/i915_reg.h   |   4 ++
 drivers/gpu/drm/i915/intel_ddi.c  |  28 ++
 drivers/gpu/drm/i915/intel_drv.h  |  14 +
 drivers/gpu/drm/i915/intel_hdmi.c | 106 ++
 4 files changed, 152 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 141a5c1..81cf10b 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -7819,7 +7819,11 @@ enum {
 #define  TRANS_DDI_EDP_INPUT_B_ONOFF   (5<<12)
 #define  TRANS_DDI_EDP_INPUT_C_ONOFF   (6<<12)
 #define  TRANS_DDI_DP_VC_PAYLOAD_ALLOC (1<<8)
+#define  TRANS_DDI_HDMI_SCRAMBLER_CTS_ENABLE (1<<7)
+#define  TRANS_DDI_HDMI_SCRAMBLER_RESET_FREQ (1<<6)
 #define  TRANS_DDI_BFI_ENABLE  (1<<4)
+#define  TRANS_DDI_HIGH_TMDS_CHAR_RATE (1<<4)
+#define  TRANS_DDI_HDMI_SCRAMBLING (1<<0)
 
 /* DisplayPort Transport Control */
 #define _DP_TP_CTL_A   0x64040
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index cd6fedd..bd8293d 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1278,6 +1278,11 @@ void intel_ddi_enable_transcoder_func(struct drm_crtc 
*crtc)
temp |= TRANS_DDI_MODE_SELECT_HDMI;
else
temp |= TRANS_DDI_MODE_SELECT_DVI;
+
+   if (IS_GEMINILAKE(dev_priv))
+   temp = intel_hdmi_handle_source_scrambling(
+   intel_encoder,
+   _crtc->config->base.adjusted_mode, temp);
} else if (type == INTEL_OUTPUT_ANALOG) {
temp |= TRANS_DDI_MODE_SELECT_FDI;
temp |= (intel_crtc->config->fdi_lanes - 1) << 1;
@@ -1843,6 +1848,21 @@ static void intel_enable_ddi(struct intel_encoder 
*intel_encoder,
struct intel_digital_port *intel_dig_port =
enc_to_dig_port(encoder);
 
+   if (IS_GEMINILAKE(dev_priv)) {
+   struct intel_crtc *crtc = to_intel_crtc(encoder->crtc);
+   /*
+* GLK sports a native HDMI 2.0 controller. If required
+* clock rate is > 340 Mhz && scrambling is supported
+* by sink, enable scrambling before enabling the
+* HDMI 2.0 port. The sink can choose to disable the
+* scrambling if it doesn't detect a scrambled within
+* 100 ms.
+*/
+   intel_hdmi_handle_sink_scrambling(intel_encoder,
+   conn_state->connector,
+   crtc->config, true);
+   }
+
/* In HDMI/DVI mode, the port width, and swing/emphasis values
 * are ignored so nothing special needs to be done besides
 * enabling the port.
@@ -1875,6 +1895,14 @@ static void intel_disable_ddi(struct intel_encoder 
*intel_encoder,
if (old_crtc_state->has_audio)
intel_audio_codec_disable(intel_encoder);
 
+   if (type == INTEL_OUTPUT_HDMI) {
+   struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
+
+   intel_hdmi_handle_sink_scrambling(intel_encoder,
+   old_conn_state->connector,
+   intel_crtc->config, false);
+   }
+
if (type == INTEL_OUTPUT_EDP) {
struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 6e37fba..df0170b88 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -691,6 +691,12 @@ struct intel_crtc_state {
 
/* Gamma mode programmed on the pipe */
uint32_t gamma_mode;
+
+   /* HDMI scrambling status (sink) */
+   bool scrambling;
+
+   /* HDMI High TMDS char rate ratio (sink) */
+   bool high_tmds_clock_ratio;
 };
 
 struct vlv_wm_state {
@@ -1609,6 +1615,14 @@ void 

[PATCH v3 4/6] drm: scrambling support in drm layer

2017-02-10 Thread Shashank Sharma
HDMI 2.0 spec mandates scrambling for modes with pixel clock higher
than 340 MHz. This patch adds few new functions in drm layer for
core drivers to enable/disable scrambling.

This patch adds:
- A function to detect scrambling support parsing HF-VSDB
- A function to check scrambling status runtime using SCDC read.
- Two functions to enable/disable scrambling using SCDC read/write.
- Few new bools to reflect scrambling support and status.

V2: Addressed review comments from Thierry, Ville and Dhinakaran
Thierry:
- Mhz -> MHz in comments and commit message.
- i2c -> I2C in comments.
- Fix the function documentations, keep in sync with drm_scdc_helper.c
- drm_connector -> DRM connector.
- Create structure for SCDC, and save scrambling status inside that,
  in a sub-structure.
- Call this sub-structure scrambling instead of scr_info.
- low_rates -> low_clocks in scrambling status structure.
- Store the return value of I2C read/write and print the error code
  in case of failure.

Thierry and Ville:
- Move the scrambling enable/disable/query functions in
  drm_scdc_helper.c file.
- Add drm_SCDC prefix for the functions.
- Optimize the return statement from function
  drm_SCDC_check_scrambling_status.

Ville:
- Dont overwrite saved max TMDS clock value in display_info,
  if max tmds clock from HF-VSDB is not > 340 MHz.
- drm_detect_hdmi_scrambling -> drm_parse_hdmi_forum_vsdb.
- Remove dynamic tracking of SCDC status from DRM layer, force bool.
- Program clock ratio bit also, while enabling scrambling.

Dhinakaran:
- Add a comment about *5000 while extracting max clock supported.

V3: Addressed review comments from Jose.
- Create separate functions to enable scrambling and to set TMDS
  clock/character rate ratio.

Signed-off-by: Shashank Sharma 
---
 drivers/gpu/drm/drm_edid.c|  33 +++-
 drivers/gpu/drm/drm_scdc_helper.c | 164 ++
 include/drm/drm_connector.h   |  19 +
 include/drm/drm_edid.h|   6 +-
 include/drm/drm_scdc_helper.h |  41 ++
 5 files changed, 261 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 65f3702..6999a24 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "drm_crtc_internal.h"
 
@@ -3810,13 +3811,43 @@ enum hdmi_quantization_range
 static void drm_parse_hdmi_forum_vsdb(struct drm_connector *connector,
 const u8 *hf_vsdb)
 {
-   struct drm_hdmi_info *hdmi = >display_info.hdmi;
+   struct drm_display_info *display = >display_info;
+   struct drm_hdmi_info *hdmi = >hdmi;
 
if (hf_vsdb[6] & 0x80) {
hdmi->scdc.supported = true;
if (hf_vsdb[6] & 0x40)
hdmi->scdc.read_request = true;
}
+
+   /*
+* All HDMI 2.0 monitors must support scrambling at rates > 340 MHz.
+* And as per the spec, three factors confirm this:
+* * Availability of a HF-VSDB block in EDID (check)
+* * Non zero Max_TMDS_Char_Rate filed in HF-VSDB (let's check)
+* * SCDC support available (let's check)
+* Lets check it out.
+*/
+
+   if (hf_vsdb[5]) {
+   /* max clock is 5000 KHz times block value */
+   u32 max_tmds_clock = hf_vsdb[5] * 5000;
+   struct drm_scdc *scdc = >scdc;
+
+   if (max_tmds_clock > 34) {
+   display->max_tmds_clock = max_tmds_clock;
+   DRM_DEBUG_KMS("HF-VSDB: max TMDS clock %d kHz\n",
+   display->max_tmds_clock);
+   }
+
+   if (scdc->supported) {
+   scdc->scrambling.supported = true;
+
+   /* Few sinks support scrambling for cloks < 340M */
+   if ((hf_vsdb[6] & 0x8))
+   scdc->scrambling.low_rates = true;
+   }
+   }
 }
 
 static void drm_parse_hdmi_deep_color_info(struct drm_connector *connector,
diff --git a/drivers/gpu/drm/drm_scdc_helper.c 
b/drivers/gpu/drm/drm_scdc_helper.c
index fe0e121..c0cf82b 100644
--- a/drivers/gpu/drm/drm_scdc_helper.c
+++ b/drivers/gpu/drm/drm_scdc_helper.c
@@ -22,8 +22,10 @@
  */
 
 #include 
+#include 
 
 #include 
+#include 
 
 /**
  * DOC: scdc helpers
@@ -109,3 +111,165 @@ ssize_t drm_scdc_write(struct i2c_adapter *adapter, u8 
offset,
return err;
 }
 EXPORT_SYMBOL(drm_scdc_write);
+
+/**
+ * drm_scdc_check_scrambling_status - what is status of scrambling?
+ * @adapter: I2C adapter for DDC channel
+ *
+ * Reads the scrambler status over SCDC, and checks the
+ * scrambling status.
+ *
+ * Returns:
+ * True if the scrambling is enabled, false otherwise.
+ */
+
+bool drm_scdc_check_scrambling_status(struct i2c_adapter *adapter)
+{
+   u8 status;
+   int ret;
+
+   ret = 

[PATCH v3 0/6] HDMI 2.0: Scrambling in DRM layer

2017-02-10 Thread Shashank Sharma
HDMI 2.0 spec defines a method to reduce the RF footprint while
operating at higher pixel clocks, which is called Scrambling.
Scrambling can be controlled over a new set of I2C registers
which are accessible over existing DDC I2C lines, called SCDC
register set.

This patch series contains 6 patches:
- First two patches add generic drm helper functions to read and
  write into SCDC registers. These patches are written by Thierry,
  in a patch series published here:
  https://patchwork.kernel.org/patch/9459051/
  Minor changes were done to map the patches into this series.
  
- Next two patches add functions for scrambling detection and
  scrambling control.

- Next two patches use this infrastructure in DRM layer from
  I915 driver, to enable scrambling on a GLK deivce which sports
  a native HDMI 2.0 controller.

V2:
 - addressed review comments from Thierry, Ville and Dhinakaran
 - added signed-off-by:self in first two patches(Jani N)

V3:
 - addressed review comments from Jose and Jani

Shashank Sharma (4):
  drm/edid: detect SCDC support in HF-VSDB
  drm: scrambling support in drm layer
  drm/i915: enable scrambling
  drm/i915: allow HDMI 2.0 clock rates

Thierry Reding (2):
  drm: Add SCDC helpers
  drm/edid: check for HF-VSDB block

 Documentation/gpu/drm-kms-helpers.rst |  12 ++
 drivers/gpu/drm/Makefile  |   3 +-
 drivers/gpu/drm/drm_edid.c|  60 
 drivers/gpu/drm/drm_scdc_helper.c | 275 ++
 drivers/gpu/drm/i915/i915_reg.h   |   4 +
 drivers/gpu/drm/i915/intel_ddi.c  |  28 
 drivers/gpu/drm/i915/intel_drv.h  |  14 ++
 drivers/gpu/drm/i915/intel_hdmi.c | 107 +
 include/drm/drm_connector.h   |  52 +++
 include/drm/drm_edid.h|   6 +-
 include/drm/drm_scdc_helper.h | 173 +
 include/linux/hdmi.h  |   1 +
 12 files changed, 733 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_scdc_helper.c
 create mode 100644 include/drm/drm_scdc_helper.h

-- 
1.9.1

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


[PATCH v3 1/6] drm: Add SCDC helpers

2017-02-10 Thread Shashank Sharma
From: Thierry Reding 

SCDC is a mechanism defined in the HDMI 2.0 specification that allows
the source and sink devices to communicate.

This commit introduces helpers to access the SCDC and provides the
symbolic names for the various registers defined in the specification.

V2: Rebase.
V3: Added R-B from Jose.
Signed-off-by: Thierry Reding 
Signed-off-by: Shashank Sharma 
Reviewed-by: Jose Abreu 
---
 Documentation/gpu/drm-kms-helpers.rst |  12 
 drivers/gpu/drm/Makefile  |   3 +-
 drivers/gpu/drm/drm_scdc_helper.c | 111 
 include/drm/drm_scdc_helper.h | 132 ++
 4 files changed, 257 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/drm_scdc_helper.c
 create mode 100644 include/drm/drm_scdc_helper.h

diff --git a/Documentation/gpu/drm-kms-helpers.rst 
b/Documentation/gpu/drm-kms-helpers.rst
index 03040aa..7592756 100644
--- a/Documentation/gpu/drm-kms-helpers.rst
+++ b/Documentation/gpu/drm-kms-helpers.rst
@@ -217,6 +217,18 @@ EDID Helper Functions Reference
 .. kernel-doc:: drivers/gpu/drm/drm_edid.c
:export:
 
+SCDC Helper Functions Reference
+===
+
+.. kernel-doc:: drivers/gpu/drm/drm_scdc_helper.c
+   :doc: scdc helpers
+
+.. kernel-doc:: include/drm/drm_scdc_helper.h
+   :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_scdc_helper.c
+   :export:
+
 Rectangle Utilities Reference
 =
 
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 92de399..ad91cd9 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -31,7 +31,8 @@ drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
 drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
drm_kms_helper_common.o drm_dp_dual_mode_helper.o \
-   drm_simple_kms_helper.o drm_modeset_helper.o
+   drm_simple_kms_helper.o drm_modeset_helper.o \
+   drm_scdc_helper.o
 
 drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
 drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
diff --git a/drivers/gpu/drm/drm_scdc_helper.c 
b/drivers/gpu/drm/drm_scdc_helper.c
new file mode 100644
index 000..fe0e121
--- /dev/null
+++ b/drivers/gpu/drm/drm_scdc_helper.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2015 NVIDIA Corporation. All rights reserved.
+ *
+ * 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, sub license,
+ * 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+#include 
+
+#include 
+
+/**
+ * DOC: scdc helpers
+ *
+ * Status and Control Data Channel (SCDC) is a mechanism introduced by the
+ * HDMI 2.0 specification. It is a point-to-point protocol that allows the
+ * HDMI source and HDMI sink to exchange data. The same I2C interface that
+ * is used to access EDID serves as the transport mechanism for SCDC.
+ */
+
+#define SCDC_I2C_SLAVE_ADDRESS 0x54
+
+/**
+ * drm_scdc_read - read a block of data from SCDC
+ * @adapter: I2C controller
+ * @offset: start offset of block to read
+ * @buffer: return location for the block to read
+ * @size: size of the block to read
+ *
+ * Reads a block of data from SCDC, starting at a given offset.
+ *
+ * Returns:
+ * The number of bytes read from SCDC or a negative error code on failure.
+ */
+ssize_t drm_scdc_read(struct i2c_adapter *adapter, u8 offset, void *buffer,
+ size_t size)
+{
+   struct i2c_msg msgs[2] = {
+   {
+   .addr = SCDC_I2C_SLAVE_ADDRESS,
+   .flags = 0,
+   .len = 1,
+   .buf = ,
+   }, {
+   .addr = SCDC_I2C_SLAVE_ADDRESS,
+   .flags = I2C_M_RD,
+   .len = size,
+

[PATCH v3 2/6] drm/edid: check for HF-VSDB block

2017-02-10 Thread Shashank Sharma
From: Thierry Reding 

This patch implements a small function that finds if a
given CEA db is hdmi-forum vendor specific data block
or not.

V2: Rebase.
V3: Added R-B from Jose.

Signed-off-by: Thierry Reding 
Signed-off-by: Shashank Sharma 
Reviewed-by: Jose Abreu 
---
 drivers/gpu/drm/drm_edid.c | 15 +++
 include/linux/hdmi.h   |  1 +
 2 files changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 5a3b34a..153114a 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3244,6 +3244,21 @@ static bool cea_db_is_hdmi_vsdb(const u8 *db)
return hdmi_id == HDMI_IEEE_OUI;
 }
 
+static bool cea_db_is_hdmi_forum_vsdb(const u8 *db)
+{
+   unsigned int oui;
+
+   if (cea_db_tag(db) != VENDOR_BLOCK)
+   return false;
+
+   if (cea_db_payload_len(db) < 7)
+   return false;
+
+   oui = db[3] << 16 | db[2] << 8 | db[1];
+
+   return oui == HDMI_FORUM_IEEE_OUI;
+}
+
 #define for_each_cea_db(cea, i, start, end) \
for ((i) = (start); (i) < (end) && (i) + 
cea_db_payload_len(&(cea)[(i)]) < (end); (i) += cea_db_payload_len(&(cea)[(i)]) 
+ 1)
 
diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h
index edbb4fc..d271ff2 100644
--- a/include/linux/hdmi.h
+++ b/include/linux/hdmi.h
@@ -35,6 +35,7 @@ enum hdmi_infoframe_type {
 };
 
 #define HDMI_IEEE_OUI 0x000c03
+#define HDMI_FORUM_IEEE_OUI 0xc45dd8
 #define HDMI_INFOFRAME_HEADER_SIZE  4
 #define HDMI_AVI_INFOFRAME_SIZE13
 #define HDMI_SPD_INFOFRAME_SIZE25
-- 
1.9.1

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


[PATCH v3 3/6] drm/edid: detect SCDC support in HF-VSDB

2017-02-10 Thread Shashank Sharma
This patch does following:
- Adds a new structure (drm_hdmi_info) in drm_display_info.
  This structure will be used to save and indicate if sink
  supports advanced HDMI 2.0 features
- Adds another structure drm_scdc within drm_hdmi_info, to
  reflect scdc support and capabilities in connected HDMI 2.0 sink.
- Checks the HF-VSDB block for presence of SCDC, and marks it
  in scdc structure
- If SCDC is present, checks if sink is capable of generating
  SCDC read request, and marks it in scdc structure.

V2: Addressed review comments
 Thierry:
 - Fix typos in commit message and make abbreviation consistent
   across the commit message.
 - Change structure object name from hdmi_info -> hdmi
 - Fix typos and abbreviations in description of structure drm_hdmi_info
   end the description with a full stop.
 - Create a structure drm_scdc, and keep all information related to SCDC
   register set (supported, read request supported) etc in it.

 Ville:
 - Change rr -> read_request
 - Call drm_detect_scrambling function drm_parse_hf_vsdb so that all
   of HF-VSDB parsing can be kept in same function, in incremental
   patches.

V3: Rebase.

Signed-off-by: Shashank Sharma 
Reviewed-by: Thierry Reding 
---
 drivers/gpu/drm/drm_edid.c  | 14 ++
 include/drm/drm_connector.h | 33 +
 2 files changed, 47 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 153114a..65f3702 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3807,6 +3807,18 @@ enum hdmi_quantization_range
 }
 EXPORT_SYMBOL(drm_default_rgb_quant_range);
 
+static void drm_parse_hdmi_forum_vsdb(struct drm_connector *connector,
+const u8 *hf_vsdb)
+{
+   struct drm_hdmi_info *hdmi = >display_info.hdmi;
+
+   if (hf_vsdb[6] & 0x80) {
+   hdmi->scdc.supported = true;
+   if (hf_vsdb[6] & 0x40)
+   hdmi->scdc.read_request = true;
+   }
+}
+
 static void drm_parse_hdmi_deep_color_info(struct drm_connector *connector,
   const u8 *hdmi)
 {
@@ -3921,6 +3933,8 @@ static void drm_parse_cea_ext(struct drm_connector 
*connector,
 
if (cea_db_is_hdmi_vsdb(db))
drm_parse_hdmi_vsdb_video(connector, db);
+   if (cea_db_is_hdmi_forum_vsdb(db))
+   drm_parse_hdmi_forum_vsdb(connector, db);
}
 }
 
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index e5e1edd..6d5304e 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -87,6 +87,34 @@ enum subpixel_order {
SubPixelVerticalRGB,
SubPixelVerticalBGR,
SubPixelNone,
+
+};
+
+/*
+ * struct drm_scdc - Information about scdc capabilities of a HDMI 2.0 sink
+ *
+ * Provides SCDC register support and capabilities related information on a
+ * HDMI 2.0 sink. In case of a HDMI 1.4 sink, all parameter must be 0.
+ */
+struct drm_scdc {
+   /**
+* @supported: status control & data channel present.
+*/
+   bool supported;
+   /**
+* @read_request: sink is capable of generating scdc read request.
+*/
+   bool read_request;
+};
+
+/**
+ * struct drm_hdmi_info - runtime information about the connected HDMI sink
+ *
+ * Describes if a given display supports advanced HDMI 2.0 features.
+ * This information is available in CEA-861-F extension blocks (like HF-VSDB).
+ */
+struct drm_hdmi_info {
+   struct drm_scdc scdc;
 };
 
 /**
@@ -188,6 +216,11 @@ struct drm_display_info {
 * @cea_rev: CEA revision of the HDMI sink.
 */
u8 cea_rev;
+
+   /**
+* @hdmi: advance features of a HDMI sink.
+*/
+   struct drm_hdmi_info hdmi;
 };
 
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
-- 
1.9.1

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


Re: [PATCH 0/8] Refactor DC atomic commit and gamma

2017-02-10 Thread Alex Deucher
On Thu, Feb 9, 2017 at 4:41 PM, Harry Wentland  wrote:
> These patches are first steps of addressing some of the problems
> in DC's atomic implementation. Please take a look and provide
> feedback if possible. Our hope is that we can start setting a
> direction on fixing up DC to do atomic correctly and lay the
> groundwork for moving past the midlayer.
>
> THe biggest patch here is Andrey's work to bring atomic_commit
> in line with the atomic helpers instead of rolling our own. We
> got atomic_commmit_tail now and things appear to work correctly
> with this change. It allowed us to clean up some of the commit
> code, but there's still a lot left.
>
> The second important patch is fixing up our gamma implementation
> and correct the use of crtc_set_property and atomic_set_properties.
>
> Beyond that there's some minor cleanup and support patches for
> the above change.
>
> The whole DC tree with these patches and rebased on drm-next a couple
> days ago can be found at
>
> https://cgit.freedesktop.org/~hwentland/linux/log/?h=dc-drm-next-atomic
>
> Known issue:
>   - corruption on one display in two-display setup
>
> Cheers,
> Harry


Harry, can you please resend this series and add dri-devel as well so
the discussion happens in a larger forum in case others working on
atomic have similar questions?

Thanks,

Alex

>
> Andrey Grodzovsky (3):
>   drm/amdgpu: Add a few members to support DAL atomic refactor.
>   drm/amd/display: Refactor atomic commit implementation.
>   drm/amd/display: Refactor headless to use atomic commit.
>
> Harry Wentland (5):
>   drm/amdgpu: Expose mode_config functions for DM
>   drm/amd/display: Use amdgpu mode funcs statically
>   drm/amd/display: Use atomic helpers for gamma
>   drm/amd/display: Remove unused define from amdgpu_dm_types
>   Revert "drm/amdgpu: Refactor flip into prepare submit and submit.
> (v3)"
>
>  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c| 140 ++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_display.h|  33 ++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h   |  19 +-
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |  70 ++-
>  .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c| 548 
> +
>  .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.h|  12 +-
>  6 files changed, 341 insertions(+), 481 deletions(-)
>  create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_display.h
>
> --
> 2.9.3
>
> ___
> 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


[Bug 99553] Tracker bug for runnning OpenCL applications on Clover

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99553

Vedran Miletić  changed:

   What|Removed |Added

 Depends on||99764


Referenced Bugs:

https://bugs.freedesktop.org/show_bug.cgi?id=99764
[Bug 99764] Make OpenMM OpenCL support work on Clover and RadeonSI
-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 0/6] drm: Introduce consistent reference counting APIs

2017-02-10 Thread Daniel Vetter
On Fri, Feb 10, 2017 at 8:29 AM, Jani Nikula
 wrote:
> On Thu, 09 Feb 2017, Thierry Reding  wrote:
>> On Thu, Feb 09, 2017 at 08:07:41PM +0100, Daniel Vetter wrote:
>>> On Thu, Feb 09, 2017 at 07:39:33PM +0200, Jani Nikula wrote:
>>> > On Thu, 09 Feb 2017, Daniel Vetter  wrote:
>>> > > On Thu, Feb 09, 2017 at 04:10:12PM +0200, Jani Nikula wrote:
>>> > >> On Wed, 08 Feb 2017, Thierry Reding  wrote:
>>> > >> > This series introduces DRM reference counting APIs that are 
>>> > >> > consistent
>>> > >> > with other reference counting APIs in the kernel. They are also much
>>> > >> > shorter. Compatibility aliases are added to keep existing code 
>>> > >> > working
>>> > >> > and will stay in place until all users of the old APIs are gone.
>>> > >>
>>> > >> I like it.
>>> > >>
>>> > >> But it makes drm_connector_list_iter_{get,put} stick out like a sore
>>> > >> thumb. Something for the TODO list I guess.
>>> > >
>>> > > Hm, why is that one the sore thumb now? Just because it's really long? 
>>> > > It
>>> > > does acquire/drop references behind the scenes, that's why I went with 
>>> > > the
>>> > > _get/put postfixes ...
>>> >
>>> > I think the assumption is that get/put work on an object, and you can
>>> > get/put as many times as you like, as long as you keep them at
>>> > balance. AFAICT this doesn't hold for iter.
>>>
>>> Hm right. What else should we use instead? start/stop are confusing in the
>>> context of list walking, create/destroy maybe?
>>
>> I rather like the _begin()/_end() suffix that I think iterators have in
>> the C++ STL. Well, I guess it's really .end() and .begin() methods in
>> C++.
>>
>> But the following reads rather nicely:
>>
>>   drm_connector_list_iter_begin(dev, );
>>
>>   drm_for_each_connector_iter(connector, )
>>   ...
>>
>>   drm_connector_list_iter_end();
>>
>> Alternatively some other iterators simply use an _init() suffix to
>> initialize the iterator. The kernel has a few of these, such as the
>> of_phandle_iterator (see include/linux/of.h) or of_pci_range_parser (see
>> include include/linux/of_address.h).
>>
>> EFI code uses _begin()/_end() in include/linux/efi.h, cgroups seems to
>> have _start()/_end() in include/linux/cgroup.h. include/linux/klist.h
>> uses klist_iter_init()/klist_iter_exit(). include/linux/rhashtable.h has
>> rhashtable_walk_start()/rhashtable_walk_stop().
>>
>> A quick grep also shows other variants, one of them being _first(), but
>> those don't have an explicit end function.
>>
>> So there's quite a few options to choose from, but I guess that doesn't
>> make it any easier.
>>
>> If this was a poll, my vote would go to _begin()/_end().
>
> I think begin/end are sensible.
>
> An alternative is to make iter get/put work as get/put do, but I suppose
> there's no real need for them to behave that way, i.e. it's
> overengineering.
>
> And if it wasn't clear, I didn't mean that this should block the patches
> at hand in any way. Someone(tm) can follow up with the iter stuff later
> on. It's not broken, it just feels slightly misleading after these
> changes.

+1 on begin/end for the iters, if someone gets around to it.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 1/2] drm/cma-helper: Add multi buffer support for cma fbdev

2017-02-10 Thread Maxime Ripard
Hi Daniel,

On Thu, Feb 09, 2017 at 06:04:38PM +0100, Daniel Vetter wrote:
> On Thu, Feb 02, 2017 at 11:31:56AM +0100, Maxime Ripard wrote:
> > From: Xinliang Liu 
> > 
> > This patch add a config to support to create multi buffer for cma fbdev.
> > Such as double buffer and triple buffer.
> > 
> > Cma fbdev is convient to add a legency fbdev. And still many Android
> > devices use fbdev now and at least double buffer is needed for these
> > Android devices, so that a buffer flip can be operated. It will need
> > some time for Android device vendors to abondon legency fbdev. So multi
> > buffer for fbdev is needed.
> > 
> > Signed-off-by: Xinliang Liu 
> > [s.chr...@phytec.de: Picking patch from
> >  https://lkml.org/lkml/2015/9/14/188]
> > Signed-off-by: Stefan Christ 
> > Signed-off-by: Maxime Ripard 
> > ---
> >  drivers/gpu/drm/Kconfig | 8 
> >  drivers/gpu/drm/drm_fb_cma_helper.c | 8 +++-
> >  2 files changed, 15 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> > index ebfe8404c25f..2ca9bb26a4e4 100644
> > --- a/drivers/gpu/drm/Kconfig
> > +++ b/drivers/gpu/drm/Kconfig
> > @@ -121,6 +121,14 @@ config DRM_KMS_CMA_HELPER
> > help
> >   Choose this if you need the KMS CMA helper functions
> >  
> > +config DRM_CMA_FBDEV_BUFFER_NUM
> > +   int "Cma Fbdev Buffer Number"
> > +   depends on DRM_KMS_CMA_HELPER
> > +   default 1
> > +   help
> > + Defines the buffer number of cma fbdev.  Default is one buffer.
> > + For double buffer please set to 2 and 3 for triple buffer.
> > +
> >  source "drivers/gpu/drm/i2c/Kconfig"
> >  
> >  source "drivers/gpu/drm/arm/Kconfig"
> > diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
> > b/drivers/gpu/drm/drm_fb_cma_helper.c
> > index 81b3558302b5..e3f8b9e720a0 100644
> > --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> > +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> > @@ -411,6 +411,12 @@ static void drm_fbdev_cma_defio_fini(struct fb_info 
> > *fbi)
> > kfree(fbi->fbops);
> >  }
> >  
> > +static int fbdev_num_buffers = CONFIG_DRM_CMA_FBDEV_BUFFER_NUM;
> > +module_param(fbdev_num_buffers, int, 0444);
> > +MODULE_PARM_DESC(fbdev_num_buffers,
> > +"Number of frame buffers to allocate [default="
> > +__MODULE_STRING(CONFIG_DRM_CMA_FBDEV_BUFFER_NUM) "]");
> 
> Pure bikshed: Should this be an overallocation %? 200 for
> double-buffering, 100 as the default?

I'm not against it, but would it make sense to allocate something like
120% of a buffer?

> Slightly less bikesheddy: Can't we do this in the core helpers somehow?

I guess that would move it to drm_fb_helper_single_fb_probe then? It
makes sense.

> I'd be nice if this is not cma specific. If it's not possible, I'd at
> least move the symbol to drm_fb_helper.c, and add some kernel-doc around
> it. That allows any other non-cma driver to at least implement support for
> this. That also has the benefit of featuring it more prominently, in our
> docs.

I'll move it and add the kerneldoc.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


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


[PATCH v2 2/7] drm/st: Add STM32 LTDC driver

2017-02-10 Thread Yannick Fertre
This patch adds support for the STM32 LCD-TFT display controller.

Signed-off-by: Yannick Fertre 
---
 drivers/gpu/drm/Kconfig  |2 +
 drivers/gpu/drm/Makefile |1 +
 drivers/gpu/drm/stm/Kconfig  |   14 +
 drivers/gpu/drm/stm/Makefile |7 +
 drivers/gpu/drm/stm/drv.c|  232 +++
 drivers/gpu/drm/stm/drv.h|   24 +
 drivers/gpu/drm/stm/ltdc.c   | 1381 ++
 drivers/gpu/drm/stm/ltdc.h   |   22 +
 8 files changed, 1683 insertions(+)
 create mode 100644 drivers/gpu/drm/stm/Kconfig
 create mode 100644 drivers/gpu/drm/stm/Makefile
 create mode 100644 drivers/gpu/drm/stm/drv.c
 create mode 100644 drivers/gpu/drm/stm/drv.h
 create mode 100644 drivers/gpu/drm/stm/ltdc.c
 create mode 100644 drivers/gpu/drm/stm/ltdc.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 90bc65d..b6dea28 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -237,6 +237,8 @@ source "drivers/gpu/drm/fsl-dcu/Kconfig"
 
 source "drivers/gpu/drm/tegra/Kconfig"
 
+source "drivers/gpu/drm/stm/Kconfig"
+
 source "drivers/gpu/drm/panel/Kconfig"
 
 source "drivers/gpu/drm/bridge/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 92de399..a4bcb95 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -81,6 +81,7 @@ obj-$(CONFIG_DRM_BOCHS) += bochs/
 obj-$(CONFIG_DRM_VIRTIO_GPU) += virtio/
 obj-$(CONFIG_DRM_MSM) += msm/
 obj-$(CONFIG_DRM_TEGRA) += tegra/
+obj-$(CONFIG_DRM_STM) += stm/
 obj-$(CONFIG_DRM_STI) += sti/
 obj-$(CONFIG_DRM_IMX) += imx/
 obj-$(CONFIG_DRM_MEDIATEK) += mediatek/
diff --git a/drivers/gpu/drm/stm/Kconfig b/drivers/gpu/drm/stm/Kconfig
new file mode 100644
index 000..2b91db6
--- /dev/null
+++ b/drivers/gpu/drm/stm/Kconfig
@@ -0,0 +1,14 @@
+config DRM_STM
+   tristate "DRM Support for STMicroelectronics SoC Series"
+   depends on DRM && (ARCH_STM32 || ARCH_MULTIPLATFORM)
+   select DRM_KMS_HELPER
+   select DRM_GEM_CMA_HELPER
+   select DRM_KMS_CMA_HELPER
+   select DRM_PANEL
+   select VIDEOMODE_HELPERS
+   select FB_PROVIDE_GET_FB_UNMAPPED_AREA
+   help
+ Choose this option if you have an ST STMicroelectronics SoC.
+
+ To compile this driver as a module, choose M here: the module
+ will be called stm-drm.
diff --git a/drivers/gpu/drm/stm/Makefile b/drivers/gpu/drm/stm/Makefile
new file mode 100644
index 000..e114d45
--- /dev/null
+++ b/drivers/gpu/drm/stm/Makefile
@@ -0,0 +1,7 @@
+ccflags-y := -Iinclude/drm
+
+stm-drm-y := \
+   drv.o \
+   ltdc.o
+
+obj-$(CONFIG_DRM_STM) += stm-drm.o
diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c
new file mode 100644
index 000..d98b6a1
--- /dev/null
+++ b/drivers/gpu/drm/stm/drv.c
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) STMicroelectronics SA 2017
+ *
+ * Authors: Philippe Cornu 
+ *  Yannick Fertre 
+ *  Fabien Dessenne 
+ *  Mickael Reulier 
+ *
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "drv.h"
+#include "ltdc.h"
+
+#define DRIVER_NAME"stm"
+#define DRIVER_DESC"STMicroelectronics SoC DRM"
+#define DRIVER_DATE"20170209"
+#define DRIVER_MAJOR   1
+#define DRIVER_MINOR   0
+#define DRIVER_PATCH_LEVEL 0
+
+#define ST_MAX_FB_WIDTH2048
+#define ST_MAX_FB_HEIGHT   2048 /* same as width to handle orientation */
+
+static void drv_output_poll_changed(struct drm_device *ddev)
+{
+   struct stm_private *priv = ddev->dev_private;
+
+   drm_fbdev_cma_hotplug_event(priv->fbdev);
+}
+
+static const struct drm_mode_config_funcs drv_mode_config_funcs = {
+   .fb_create = drm_fb_cma_create,
+   .output_poll_changed = drv_output_poll_changed,
+   .atomic_check = drm_atomic_helper_check,
+   .atomic_commit = drm_atomic_helper_commit,
+};
+
+static const struct file_operations drv_driver_fops = {
+   .owner = THIS_MODULE,
+   .open = drm_open,
+   .release = drm_release,
+   .unlocked_ioctl = drm_ioctl,
+   .compat_ioctl = drm_compat_ioctl,
+   .poll = drm_poll,
+   .read = drm_read,
+   .mmap = drm_gem_cma_mmap,
+   .get_unmapped_area = drm_gem_cma_get_unmapped_area,
+};
+
+static void drv_lastclose(struct drm_device *ddev)
+{
+   struct stm_private *priv = ddev->dev_private;
+
+   DRM_DEBUG("%s\n", __func__);
+
+   drm_fbdev_cma_restore_mode(priv->fbdev);
+}
+
+static struct drm_driver drv_driver = {
+   .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
+  DRIVER_ATOMIC,
+   .lastclose = drv_lastclose,
+   .name = DRIVER_NAME,
+   .desc = DRIVER_DESC,
+   .date = DRIVER_DATE,
+   .major = DRIVER_MAJOR,
+ 

[PATCH v2 6/7] ARM: dts: stm32: Enable ltdc & simple panel on stm32f429-Eval board

2017-02-10 Thread Yannick Fertre
Enable ltdc & enable am-480272h3tmqw-t01h panel.

Signed-off-by: Yannick Fertre 
---
 arch/arm/boot/dts/stm32429i-eval.dts | 59 
 1 file changed, 59 insertions(+)

diff --git a/arch/arm/boot/dts/stm32429i-eval.dts 
b/arch/arm/boot/dts/stm32429i-eval.dts
index 601a22a..5a5f941 100644
--- a/arch/arm/boot/dts/stm32429i-eval.dts
+++ b/arch/arm/boot/dts/stm32429i-eval.dts
@@ -110,6 +110,52 @@
clocks = < 0 30>;
clock-names = "main_clk";
};
+
+   panel_rgb: panel-rgb {
+   compatible = "ampire,am-480272h3tmqw-t01h";
+   status = "okay";
+   port {
+   panel_in_rgb: endpoint {
+   remote-endpoint = <_out_rgb>;
+   };
+   };
+   };
+};
+
+ {
+   pinctrl_ltdc: ltdc@0 {
+   pins {
+   pinmux = ,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+;
+   slew-rate = <2>;
+   };
+   };
 };
 
 _hse {
@@ -146,3 +192,16 @@
pinctrl-names = "default";
status = "okay";
 };
+
+ {
+   status = "okay";
+   pinctrl-0 = <_ltdc>;
+   pinctrl-names = "default";
+   dma-ranges;
+
+   port {
+   ltdc_out_rgb: endpoint {
+   remote-endpoint = <_in_rgb>;
+   };
+   };
+};
-- 
1.9.1

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


[PATCH v2 7/7] ARM: configs: stm32: ADD LDTC support

2017-02-10 Thread Yannick Fertre
Signed-off-by: Yannick Fertre 
---
 arch/arm/configs/stm32_defconfig | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/configs/stm32_defconfig b/arch/arm/configs/stm32_defconfig
index e995209..d6a00b8 100644
--- a/arch/arm/configs/stm32_defconfig
+++ b/arch/arm/configs/stm32_defconfig
@@ -70,3 +70,8 @@ CONFIG_MAGIC_SYSRQ=y
 # CONFIG_FTRACE is not set
 CONFIG_CRC_ITU_T=y
 CONFIG_CRC7=y
+CONFIG_DRM=y
+CONFIG_DRM_ST=y
+CONFIG_DRM_PANEL=y
+CONFIG_DRM_PANEL_SIMPLE=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
-- 
1.9.1

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


[PATCH v2 1/7] dt-bindings: display: add STM32 LTDC driver

2017-02-10 Thread Yannick Fertre
Signed-off-by: Yannick Fertre 
---
 .../devicetree/bindings/display/st,stm32-ltdc.txt  | 37 ++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/st,stm32-ltdc.txt

diff --git a/Documentation/devicetree/bindings/display/st,stm32-ltdc.txt 
b/Documentation/devicetree/bindings/display/st,stm32-ltdc.txt
new file mode 100644
index 000..b93e1c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/st,stm32-ltdc.txt
@@ -0,0 +1,37 @@
+* STMicroelectronics STM32 lcd-tft display controller
+
+- ltdc: lcd-tft display controller host
+  must be a sub-node of st-display-subsystem
+  Required properties:
+  - compatible: "st,stm32-ltdc"
+  - reg: Physical base address of the IP registers and length of memory mapped 
region.
+  - clocks: A list of phandle + clock-specifier pairs, one for each
+entry in 'clock-names'.
+  - clock-names: A list of clock names. For ltdc it should contain:
+  - "clk-lcd" for the clock feeding the output pixel clock & IP clock.
+  - resets: reset to be used by the device (defined by use of RCC macro).
+  Required nodes:
+- Video port for RGB output.
+
+Example:
+
+/ {
+   ...
+   soc {
+   ...
+   ltdc: stm32-ltdc@40016800 {
+   compatible = "st,stm32-ltdc";
+   reg = <0x40016800 0x200>;
+   interrupts = <88>, <89>;
+   resets = < STM32F4_APB2_RESET(LTDC)>;
+   clocks = < 1 CLK_LCD>;
+   clock-names = "lcd";
+   status = "disabled";
+
+   port {
+   ltdc_out_rgb: endpoint {
+   };
+   };
+   };
+   };
+};
-- 
1.9.1

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


[PATCH v2 0/7] STM32 LCD-TFT display controller

2017-02-10 Thread Yannick Fertre
Version 2:
- Rename driver directory from st to stm.
- Rename compatiblity from st,ltdc to st,stm32-ltdc.
- Remove compatibility st,display-subsystem.
- Rename driver from st-drm to stm-drm.
- Rework probe sequence & remove display-subsystem part.
- I keep clock name which is necessary for devm_regmap_init_mmio_clk call.

Version 1:
- Initial commit

The purpose of this set of patches is to add a new driver for stm32f429.
This driver was developed and tested on evaluation board stm32429i.

Stm32f4 is a MCU platform which don't have MMU so the last patches developed
by Benjamin Gaignard regarding "DRM: allow to use mmuless devices"
are necessary.

The board stm429i embeds a Ampire AM-480272H3TMQW-T01H screen.
A new simple panel am-480272h3tmqw-t01h have been added to support it.

Yannick Fertre (9):
  dt-bindings: display: add STM32 LTDC driver
  drm/st: Add STM32 LTDC driver
  dt-bindings: Add Ampire AM-480272H3TMQW-T01H panel
  drm/panel: simple: Add support for Ampire AM-480272H3TMQW-T01H
  ARM: dts: stm32: Add ltdc support on stm32f429 MCU
  ARM: dts: stm32: Enable ltdc & simple panel on stm32f429-Eval board
  ARM: configs: stm32: ADD LDTC support

 .../display/panel/ampire,am-480272h3tmqw-t01h.txt  |7 +
 .../devicetree/bindings/display/st,stm32-ltdc.txt  |   37 +
 arch/arm/boot/dts/stm32429i-eval.dts   |   59 +
 arch/arm/boot/dts/stm32f429.dtsi   |   19 +-
 arch/arm/configs/stm32_defconfig   |5 +
 drivers/gpu/drm/Kconfig|2 +
 drivers/gpu/drm/Makefile   |1 +
 drivers/gpu/drm/panel/panel-simple.c   |   29 +
 drivers/gpu/drm/stm/Kconfig|   14 +
 drivers/gpu/drm/stm/Makefile   |7 +
 drivers/gpu/drm/stm/drv.c  |  232 
 drivers/gpu/drm/stm/drv.h  |   24 +
 drivers/gpu/drm/stm/ltdc.c | 1381 
 drivers/gpu/drm/stm/ltdc.h |   22 +
 14 files changed, 1838 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/ampire,am-480272h3tmqw-t01h.txt
 create mode 100644 Documentation/devicetree/bindings/display/st,stm32-ltdc.txt
 create mode 100644 drivers/gpu/drm/stm/Kconfig
 create mode 100644 drivers/gpu/drm/stm/Makefile
 create mode 100644 drivers/gpu/drm/stm/drv.c
 create mode 100644 drivers/gpu/drm/stm/drv.h
 create mode 100644 drivers/gpu/drm/stm/ltdc.c
 create mode 100644 drivers/gpu/drm/stm/ltdc.h

-- 
1.9.1

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


[PATCH v2 5/7] ARM: dts: stm32: Add ltdc support on stm32f429 MCU

2017-02-10 Thread Yannick Fertre
Add LTDC (Lcd-tft Display Controller) support.

Signed-off-by: Yannick Fertre 
---
 arch/arm/boot/dts/stm32f429.dtsi | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi
index e4dae0e..00f6681 100644
--- a/arch/arm/boot/dts/stm32f429.dtsi
+++ b/arch/arm/boot/dts/stm32f429.dtsi
@@ -48,6 +48,8 @@
 #include "skeleton.dtsi"
 #include "armv7-m.dtsi"
 #include 
+#include 
+#include 
 
 / {
clocks {
@@ -206,7 +208,7 @@
reg = <0x40007000 0x400>;
};
 
-   pin-controller {
+   pinctrl: pin-controller {
#address-cells = <1>;
#size-cells = <1>;
compatible = "st,stm32f429-pinctrl";
@@ -426,6 +428,21 @@
interrupts = <80>;
clocks = < 0 38>;
};
+
+   ltdc: stm32-ltdc@40016800 {
+   compatible = "st,stm32-ltdc";
+   reg = <0x40016800 0x200>;
+   interrupts = <88>, <89>;
+   resets = < STM32F4_APB2_RESET(LTDC)>;
+   clocks = < 1 CLK_LCD>;
+   clock-names = "lcd";
+   status = "disabled";
+
+   port {
+   ltdc_out_rgb: endpoint {
+   };
+   };
+   };
};
 };
 
-- 
1.9.1

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


[PATCH v2 4/7] drm/panel: simple: Add support for Ampire AM-480272H3TMQW-T01H

2017-02-10 Thread Yannick Fertre
Add simple-panel support for the Ampire AM-480272H3TMQW-T01H,
which is a 4.3" WQVGA panel.

Signed-off-by: Yannick Fertre 
---
 drivers/gpu/drm/panel/panel-simple.c | 29 +
 1 file changed, 29 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 06aaf79..ee5d2ff 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -386,6 +386,32 @@ static void panel_simple_shutdown(struct device *dev)
panel_simple_disable(>base);
 }
 
+static const struct drm_display_mode ampire_am_480272h3tmqw_t01h_mode = {
+   .clock = 9000,
+   .hdisplay = 480,
+   .hsync_start = 480 + 2,
+   .hsync_end = 480 + 2 + 41,
+   .htotal = 480 + 2 + 41 + 2,
+   .vdisplay = 272,
+   .vsync_start = 272 + 2,
+   .vsync_end = 272 + 2 + 10,
+   .vtotal = 272 + 2 + 10 + 2,
+   .vrefresh = 60,
+   .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
+};
+
+static const struct panel_desc ampire_am_480272h3tmqw_t01h = {
+   .modes = _am_480272h3tmqw_t01h_mode,
+   .num_modes = 1,
+   .bpc = 8,
+
+   .size = {
+   .width = 105,
+   .height = 67,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
+};
+
 static const struct drm_display_mode ampire_am800480r3tmqwa1h_mode = {
.clock = 3,
.hdisplay = 800,
@@ -1715,6 +1741,9 @@ static void panel_simple_shutdown(struct device *dev)
 
 static const struct of_device_id platform_of_match[] = {
{
+   .compatible = "ampire,am-480272h3tmqw-t01h",
+   .data = _am_480272h3tmqw_t01h,
+   }, {
.compatible = "ampire,am800480r3tmqwa1h",
.data = _am800480r3tmqwa1h,
}, {
-- 
1.9.1

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


[PATCH v2 3/7] dt-bindings: Add Ampire AM-480272H3TMQW-T01H panel

2017-02-10 Thread Yannick Fertre
Signed-off-by: Yannick Fertre 
---
 .../bindings/display/panel/ampire,am-480272h3tmqw-t01h.txt | 7 +++
 1 file changed, 7 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/ampire,am-480272h3tmqw-t01h.txt

diff --git 
a/Documentation/devicetree/bindings/display/panel/ampire,am-480272h3tmqw-t01h.txt
 
b/Documentation/devicetree/bindings/display/panel/ampire,am-480272h3tmqw-t01h.txt
new file mode 100644
index 000..f59e3c4
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/display/panel/ampire,am-480272h3tmqw-t01h.txt
@@ -0,0 +1,7 @@
+Ampire AM-480272H3TMQW-T01H 4.3" WQVGA TFT LCD panel
+
+Required properties:
+- compatible: should be "ampire,am-480272h3tmqw-t01h"
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.
-- 
1.9.1

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


[PATCH v2 2/9] drm/st: Add STM32 LTDC driver

2017-02-10 Thread Yannick Fertre
This patch adds support for the STM32 LCD-TFT display controller.

Signed-off-by: Yannick Fertre 
---
 drivers/gpu/drm/Kconfig  |2 +
 drivers/gpu/drm/Makefile |1 +
 drivers/gpu/drm/stm/Kconfig  |   14 +
 drivers/gpu/drm/stm/Makefile |7 +
 drivers/gpu/drm/stm/drv.c|  232 +++
 drivers/gpu/drm/stm/drv.h|   24 +
 drivers/gpu/drm/stm/ltdc.c   | 1381 ++
 drivers/gpu/drm/stm/ltdc.h   |   22 +
 8 files changed, 1683 insertions(+)
 create mode 100644 drivers/gpu/drm/stm/Kconfig
 create mode 100644 drivers/gpu/drm/stm/Makefile
 create mode 100644 drivers/gpu/drm/stm/drv.c
 create mode 100644 drivers/gpu/drm/stm/drv.h
 create mode 100644 drivers/gpu/drm/stm/ltdc.c
 create mode 100644 drivers/gpu/drm/stm/ltdc.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 90bc65d..b6dea28 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -237,6 +237,8 @@ source "drivers/gpu/drm/fsl-dcu/Kconfig"
 
 source "drivers/gpu/drm/tegra/Kconfig"
 
+source "drivers/gpu/drm/stm/Kconfig"
+
 source "drivers/gpu/drm/panel/Kconfig"
 
 source "drivers/gpu/drm/bridge/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 92de399..a4bcb95 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -81,6 +81,7 @@ obj-$(CONFIG_DRM_BOCHS) += bochs/
 obj-$(CONFIG_DRM_VIRTIO_GPU) += virtio/
 obj-$(CONFIG_DRM_MSM) += msm/
 obj-$(CONFIG_DRM_TEGRA) += tegra/
+obj-$(CONFIG_DRM_STM) += stm/
 obj-$(CONFIG_DRM_STI) += sti/
 obj-$(CONFIG_DRM_IMX) += imx/
 obj-$(CONFIG_DRM_MEDIATEK) += mediatek/
diff --git a/drivers/gpu/drm/stm/Kconfig b/drivers/gpu/drm/stm/Kconfig
new file mode 100644
index 000..2b91db6
--- /dev/null
+++ b/drivers/gpu/drm/stm/Kconfig
@@ -0,0 +1,14 @@
+config DRM_STM
+   tristate "DRM Support for STMicroelectronics SoC Series"
+   depends on DRM && (ARCH_STM32 || ARCH_MULTIPLATFORM)
+   select DRM_KMS_HELPER
+   select DRM_GEM_CMA_HELPER
+   select DRM_KMS_CMA_HELPER
+   select DRM_PANEL
+   select VIDEOMODE_HELPERS
+   select FB_PROVIDE_GET_FB_UNMAPPED_AREA
+   help
+ Choose this option if you have an ST STMicroelectronics SoC.
+
+ To compile this driver as a module, choose M here: the module
+ will be called stm-drm.
diff --git a/drivers/gpu/drm/stm/Makefile b/drivers/gpu/drm/stm/Makefile
new file mode 100644
index 000..e114d45
--- /dev/null
+++ b/drivers/gpu/drm/stm/Makefile
@@ -0,0 +1,7 @@
+ccflags-y := -Iinclude/drm
+
+stm-drm-y := \
+   drv.o \
+   ltdc.o
+
+obj-$(CONFIG_DRM_STM) += stm-drm.o
diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c
new file mode 100644
index 000..d98b6a1
--- /dev/null
+++ b/drivers/gpu/drm/stm/drv.c
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) STMicroelectronics SA 2017
+ *
+ * Authors: Philippe Cornu 
+ *  Yannick Fertre 
+ *  Fabien Dessenne 
+ *  Mickael Reulier 
+ *
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "drv.h"
+#include "ltdc.h"
+
+#define DRIVER_NAME"stm"
+#define DRIVER_DESC"STMicroelectronics SoC DRM"
+#define DRIVER_DATE"20170209"
+#define DRIVER_MAJOR   1
+#define DRIVER_MINOR   0
+#define DRIVER_PATCH_LEVEL 0
+
+#define ST_MAX_FB_WIDTH2048
+#define ST_MAX_FB_HEIGHT   2048 /* same as width to handle orientation */
+
+static void drv_output_poll_changed(struct drm_device *ddev)
+{
+   struct stm_private *priv = ddev->dev_private;
+
+   drm_fbdev_cma_hotplug_event(priv->fbdev);
+}
+
+static const struct drm_mode_config_funcs drv_mode_config_funcs = {
+   .fb_create = drm_fb_cma_create,
+   .output_poll_changed = drv_output_poll_changed,
+   .atomic_check = drm_atomic_helper_check,
+   .atomic_commit = drm_atomic_helper_commit,
+};
+
+static const struct file_operations drv_driver_fops = {
+   .owner = THIS_MODULE,
+   .open = drm_open,
+   .release = drm_release,
+   .unlocked_ioctl = drm_ioctl,
+   .compat_ioctl = drm_compat_ioctl,
+   .poll = drm_poll,
+   .read = drm_read,
+   .mmap = drm_gem_cma_mmap,
+   .get_unmapped_area = drm_gem_cma_get_unmapped_area,
+};
+
+static void drv_lastclose(struct drm_device *ddev)
+{
+   struct stm_private *priv = ddev->dev_private;
+
+   DRM_DEBUG("%s\n", __func__);
+
+   drm_fbdev_cma_restore_mode(priv->fbdev);
+}
+
+static struct drm_driver drv_driver = {
+   .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
+  DRIVER_ATOMIC,
+   .lastclose = drv_lastclose,
+   .name = DRIVER_NAME,
+   .desc = DRIVER_DESC,
+   .date = DRIVER_DATE,
+   .major = DRIVER_MAJOR,
+ 

[PATCH v2 9/9] ARM: configs: stm32: ADD LDTC support

2017-02-10 Thread Yannick Fertre
Signed-off-by: Yannick Fertre 
---
 arch/arm/configs/stm32_defconfig | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/configs/stm32_defconfig b/arch/arm/configs/stm32_defconfig
index e995209..d6a00b8 100644
--- a/arch/arm/configs/stm32_defconfig
+++ b/arch/arm/configs/stm32_defconfig
@@ -70,3 +70,8 @@ CONFIG_MAGIC_SYSRQ=y
 # CONFIG_FTRACE is not set
 CONFIG_CRC_ITU_T=y
 CONFIG_CRC7=y
+CONFIG_DRM=y
+CONFIG_DRM_ST=y
+CONFIG_DRM_PANEL=y
+CONFIG_DRM_PANEL_SIMPLE=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
-- 
1.9.1

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


[PATCH v2 7/9] ARM: dts: stm32: Add ltdc support on stm32f429 MCU

2017-02-10 Thread Yannick Fertre
Add LTDC (Lcd-tft Display Controller) support.

Signed-off-by: Yannick Fertre 
---
 arch/arm/boot/dts/stm32f429.dtsi | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi
index 47351e2..00f6681 100644
--- a/arch/arm/boot/dts/stm32f429.dtsi
+++ b/arch/arm/boot/dts/stm32f429.dtsi
@@ -49,6 +49,7 @@
 #include "armv7-m.dtsi"
 #include 
 #include 
+#include 
 
 / {
clocks {
@@ -432,9 +433,9 @@
compatible = "st,stm32-ltdc";
reg = <0x40016800 0x200>;
interrupts = <88>, <89>;
-   resets = < 314>;
+   resets = < STM32F4_APB2_RESET(LTDC)>;
clocks = < 1 CLK_LCD>;
-   clock-names = "clk-lcd";
+   clock-names = "lcd";
status = "disabled";
 
port {
-- 
1.9.1

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


[PATCH v2 1/9] dt-bindings: display: add STM32 LTDC driver

2017-02-10 Thread Yannick Fertre
Signed-off-by: Yannick Fertre 
---
 .../devicetree/bindings/display/st,stm32-ltdc.txt  | 37 ++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/st,stm32-ltdc.txt

diff --git a/Documentation/devicetree/bindings/display/st,stm32-ltdc.txt 
b/Documentation/devicetree/bindings/display/st,stm32-ltdc.txt
new file mode 100644
index 000..b93e1c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/st,stm32-ltdc.txt
@@ -0,0 +1,37 @@
+* STMicroelectronics STM32 lcd-tft display controller
+
+- ltdc: lcd-tft display controller host
+  must be a sub-node of st-display-subsystem
+  Required properties:
+  - compatible: "st,stm32-ltdc"
+  - reg: Physical base address of the IP registers and length of memory mapped 
region.
+  - clocks: A list of phandle + clock-specifier pairs, one for each
+entry in 'clock-names'.
+  - clock-names: A list of clock names. For ltdc it should contain:
+  - "clk-lcd" for the clock feeding the output pixel clock & IP clock.
+  - resets: reset to be used by the device (defined by use of RCC macro).
+  Required nodes:
+- Video port for RGB output.
+
+Example:
+
+/ {
+   ...
+   soc {
+   ...
+   ltdc: stm32-ltdc@40016800 {
+   compatible = "st,stm32-ltdc";
+   reg = <0x40016800 0x200>;
+   interrupts = <88>, <89>;
+   resets = < STM32F4_APB2_RESET(LTDC)>;
+   clocks = < 1 CLK_LCD>;
+   clock-names = "lcd";
+   status = "disabled";
+
+   port {
+   ltdc_out_rgb: endpoint {
+   };
+   };
+   };
+   };
+};
-- 
1.9.1

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


[PATCH v2 5/9] drm/panel: simple: Add support for Ampire AM-480272H3TMQW-T01H

2017-02-10 Thread Yannick Fertre
Add simple-panel support for the Ampire AM-480272H3TMQW-T01H,
which is a 4.3" WQVGA panel.

Signed-off-by: Yannick Fertre 
---
 drivers/gpu/drm/panel/panel-simple.c | 29 +
 1 file changed, 29 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 06aaf79..ee5d2ff 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -386,6 +386,32 @@ static void panel_simple_shutdown(struct device *dev)
panel_simple_disable(>base);
 }
 
+static const struct drm_display_mode ampire_am_480272h3tmqw_t01h_mode = {
+   .clock = 9000,
+   .hdisplay = 480,
+   .hsync_start = 480 + 2,
+   .hsync_end = 480 + 2 + 41,
+   .htotal = 480 + 2 + 41 + 2,
+   .vdisplay = 272,
+   .vsync_start = 272 + 2,
+   .vsync_end = 272 + 2 + 10,
+   .vtotal = 272 + 2 + 10 + 2,
+   .vrefresh = 60,
+   .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
+};
+
+static const struct panel_desc ampire_am_480272h3tmqw_t01h = {
+   .modes = _am_480272h3tmqw_t01h_mode,
+   .num_modes = 1,
+   .bpc = 8,
+
+   .size = {
+   .width = 105,
+   .height = 67,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
+};
+
 static const struct drm_display_mode ampire_am800480r3tmqwa1h_mode = {
.clock = 3,
.hdisplay = 800,
@@ -1715,6 +1741,9 @@ static void panel_simple_shutdown(struct device *dev)
 
 static const struct of_device_id platform_of_match[] = {
{
+   .compatible = "ampire,am-480272h3tmqw-t01h",
+   .data = _am_480272h3tmqw_t01h,
+   }, {
.compatible = "ampire,am800480r3tmqwa1h",
.data = _am800480r3tmqwa1h,
}, {
-- 
1.9.1

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


[PATCH v2 6/9] ARM: dts: stm32: Add ltdc support on stm32f429 MCU

2017-02-10 Thread Yannick Fertre
Add LTDC (Lcd-tft Display Controller) support.

Signed-off-by: Yannick Fertre 
---
 arch/arm/boot/dts/stm32f429.dtsi | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi
index e4dae0e..47351e2 100644
--- a/arch/arm/boot/dts/stm32f429.dtsi
+++ b/arch/arm/boot/dts/stm32f429.dtsi
@@ -48,6 +48,7 @@
 #include "skeleton.dtsi"
 #include "armv7-m.dtsi"
 #include 
+#include 
 
 / {
clocks {
@@ -206,7 +207,7 @@
reg = <0x40007000 0x400>;
};
 
-   pin-controller {
+   pinctrl: pin-controller {
#address-cells = <1>;
#size-cells = <1>;
compatible = "st,stm32f429-pinctrl";
@@ -426,6 +427,21 @@
interrupts = <80>;
clocks = < 0 38>;
};
+
+   ltdc: stm32-ltdc@40016800 {
+   compatible = "st,stm32-ltdc";
+   reg = <0x40016800 0x200>;
+   interrupts = <88>, <89>;
+   resets = < 314>;
+   clocks = < 1 CLK_LCD>;
+   clock-names = "clk-lcd";
+   status = "disabled";
+
+   port {
+   ltdc_out_rgb: endpoint {
+   };
+   };
+   };
};
 };
 
-- 
1.9.1

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


[PATCH v2 4/9] dt-bindings: Add Ampire AM-480272H3TMQW-T01H panel

2017-02-10 Thread Yannick Fertre
Signed-off-by: Yannick Fertre 
---
 .../bindings/display/panel/ampire,am-480272h3tmqw-t01h.txt | 7 +++
 1 file changed, 7 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/ampire,am-480272h3tmqw-t01h.txt

diff --git 
a/Documentation/devicetree/bindings/display/panel/ampire,am-480272h3tmqw-t01h.txt
 
b/Documentation/devicetree/bindings/display/panel/ampire,am-480272h3tmqw-t01h.txt
new file mode 100644
index 000..f59e3c4
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/display/panel/ampire,am-480272h3tmqw-t01h.txt
@@ -0,0 +1,7 @@
+Ampire AM-480272H3TMQW-T01H 4.3" WQVGA TFT LCD panel
+
+Required properties:
+- compatible: should be "ampire,am-480272h3tmqw-t01h"
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.
-- 
1.9.1

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


[PATCH v2 3/9] drm/st: Add STM32 LTDC driver

2017-02-10 Thread Yannick Fertre
This patch adds support for the STM32 LCD-TFT display controller.

Signed-off-by: Yannick Fertre 
---
 drivers/gpu/drm/stm/ltdc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 0a393e2..148607d 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -1246,7 +1246,7 @@ int ltdc_load(struct drm_device *ddev)
 
mutex_init(>err_lock);
 
-   ltdc->pixel_clk = devm_clk_get(dev, "clk-lcd");
+   ltdc->pixel_clk = devm_clk_get(dev, "lcd");
if (IS_ERR(ltdc->pixel_clk)) {
DRM_ERROR("Unable to get lcd clock\n");
return -ENODEV;
@@ -1263,7 +1263,7 @@ int ltdc_load(struct drm_device *ddev)
return PTR_ERR(regs);
}
 
-   ltdc->map = devm_regmap_init_mmio_clk(dev, "clk-lcd", regs,
+   ltdc->map = devm_regmap_init_mmio_clk(dev, "lcd", regs,
  _regmap_config);
if (IS_ERR(ltdc->map)) {
dev_err(dev, "Couldn't create ltdc register mapping\n");
-- 
1.9.1

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


[PATCH v2 0/9] STM32 LCD-TFT display controller

2017-02-10 Thread Yannick Fertre
Version 2:
- Rename driver directory from st to stm.
- Rename compatiblity from st,ltdc to st,stm32-ltdc.
- Remove compatibility st,display-subsystem.
- Rename driver from st-drm to stm-drm.
- Rework probe sequence & remove display-subsystem part.
- I keep clock name which is necessary for devm_regmap_init_mmio_clk call.

Version 1:
- Initial commit

The purpose of this set of patches is to add a new driver for stm32f429.
This driver was developed and tested on evaluation board stm32429i.

Stm32f4 is a MCU platform which don't have MMU so the last patches developed
by Benjamin Gaignard regarding "DRM: allow to use mmuless devices"
are necessary.

The board stm429i embeds a Ampire AM-480272H3TMQW-T01H screen.
A new simple panel am-480272h3tmqw-t01h have been added to support it.

Yannick Fertre (9):
  dt-bindings: display: add STM32 LTDC driver
  drm/st: Add STM32 LTDC driver
  drm/st: Add STM32 LTDC driver
  dt-bindings: Add Ampire AM-480272H3TMQW-T01H panel
  drm/panel: simple: Add support for Ampire AM-480272H3TMQW-T01H
  ARM: dts: stm32: Add ltdc support on stm32f429 MCU
  ARM: dts: stm32: Add ltdc support on stm32f429 MCU
  ARM: dts: stm32: Enable ltdc & simple panel on stm32f429-Eval board
  ARM: configs: stm32: ADD LDTC support

 .../display/panel/ampire,am-480272h3tmqw-t01h.txt  |7 +
 .../devicetree/bindings/display/st,stm32-ltdc.txt  |   37 +
 arch/arm/boot/dts/stm32429i-eval.dts   |   59 +
 arch/arm/boot/dts/stm32f429.dtsi   |   19 +-
 arch/arm/configs/stm32_defconfig   |5 +
 drivers/gpu/drm/Kconfig|2 +
 drivers/gpu/drm/Makefile   |1 +
 drivers/gpu/drm/panel/panel-simple.c   |   29 +
 drivers/gpu/drm/stm/Kconfig|   14 +
 drivers/gpu/drm/stm/Makefile   |7 +
 drivers/gpu/drm/stm/drv.c  |  232 
 drivers/gpu/drm/stm/drv.h  |   24 +
 drivers/gpu/drm/stm/ltdc.c | 1381 
 drivers/gpu/drm/stm/ltdc.h |   22 +
 14 files changed, 1838 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/ampire,am-480272h3tmqw-t01h.txt
 create mode 100644 Documentation/devicetree/bindings/display/st,stm32-ltdc.txt
 create mode 100644 drivers/gpu/drm/stm/Kconfig
 create mode 100644 drivers/gpu/drm/stm/Makefile
 create mode 100644 drivers/gpu/drm/stm/drv.c
 create mode 100644 drivers/gpu/drm/stm/drv.h
 create mode 100644 drivers/gpu/drm/stm/ltdc.c
 create mode 100644 drivers/gpu/drm/stm/ltdc.h

-- 
1.9.1

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


[PATCH v2 8/9] ARM: dts: stm32: Enable ltdc & simple panel on stm32f429-Eval board

2017-02-10 Thread Yannick Fertre
Enable ltdc & enable am-480272h3tmqw-t01h panel.

Signed-off-by: Yannick Fertre 
---
 arch/arm/boot/dts/stm32429i-eval.dts | 59 
 1 file changed, 59 insertions(+)

diff --git a/arch/arm/boot/dts/stm32429i-eval.dts 
b/arch/arm/boot/dts/stm32429i-eval.dts
index 601a22a..5a5f941 100644
--- a/arch/arm/boot/dts/stm32429i-eval.dts
+++ b/arch/arm/boot/dts/stm32429i-eval.dts
@@ -110,6 +110,52 @@
clocks = < 0 30>;
clock-names = "main_clk";
};
+
+   panel_rgb: panel-rgb {
+   compatible = "ampire,am-480272h3tmqw-t01h";
+   status = "okay";
+   port {
+   panel_in_rgb: endpoint {
+   remote-endpoint = <_out_rgb>;
+   };
+   };
+   };
+};
+
+ {
+   pinctrl_ltdc: ltdc@0 {
+   pins {
+   pinmux = ,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+;
+   slew-rate = <2>;
+   };
+   };
 };
 
 _hse {
@@ -146,3 +192,16 @@
pinctrl-names = "default";
status = "okay";
 };
+
+ {
+   status = "okay";
+   pinctrl-0 = <_ltdc>;
+   pinctrl-names = "default";
+   dma-ranges;
+
+   port {
+   ltdc_out_rgb: endpoint {
+   remote-endpoint = <_in_rgb>;
+   };
+   };
+};
-- 
1.9.1

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


Re: [PATCH 0/6] drm: Introduce consistent reference counting APIs

2017-02-10 Thread Christian König

Am 08.02.2017 um 19:24 schrieb Thierry Reding:

From: Thierry Reding 

This series introduces DRM reference counting APIs that are consistent
with other reference counting APIs in the kernel. They are also much
shorter. Compatibility aliases are added to keep existing code working
and will stay in place until all users of the old APIs are gone.

All occurrences of the old APIs in the core are already replaced by
this series, and a semantic patch is provided that allows drivers to
be converted automatically. I plan on generating patches against the
drivers once the new functions have been merged and send them out to
their respective maintainers.

Oh, and this fixes one of the items in our recently added TODO list.

Thanks,
Thierry


Oh, yes please. Really nice to get the naming in line with the rest of 
the kernel.


Whole set is Acked-by: Christian König .

Leave me a note if you have patches for amdgpu/radeon and need an rb.

Regards,
Christian.



Thierry Reding (6):
   drm: Rename drm_mode_object_get()
   drm: Introduce drm_mode_object_{get,put}()
   drm: Introduce drm_connector_{get,put}()
   drm: Introduce drm_framebuffer_{get,put}()
   drm: Introduce drm_gem_object_{get,put}()
   drm: Introduce drm_property_blob_{get,put}()

  Documentation/gpu/drm-mm.rst | 14 +++--
  drivers/gpu/drm/drm_atomic.c | 44 +++
  drivers/gpu/drm/drm_atomic_helper.c  | 26 -
  drivers/gpu/drm/drm_connector.c  | 16 +++---
  drivers/gpu/drm/drm_crtc.c   | 12 ++---
  drivers/gpu/drm/drm_crtc_helper.c|  6 +--
  drivers/gpu/drm/drm_crtc_internal.h  | 12 ++---
  drivers/gpu/drm/drm_encoder.c|  2 +-
  drivers/gpu/drm/drm_fb_cma_helper.c  | 16 +++---
  drivers/gpu/drm/drm_fb_helper.c  | 12 ++---
  drivers/gpu/drm/drm_framebuffer.c| 38 ++---
  drivers/gpu/drm/drm_gem.c| 44 +++
  drivers/gpu/drm/drm_gem_cma_helper.c | 10 ++--
  drivers/gpu/drm/drm_mode_config.c|  4 +-
  drivers/gpu/drm/drm_mode_object.c| 44 +++
  drivers/gpu/drm/drm_modes.c  |  2 +-
  drivers/gpu/drm/drm_plane.c  | 14 ++---
  drivers/gpu/drm/drm_prime.c  | 10 ++--
  drivers/gpu/drm/drm_property.c   | 52 +-
  include/drm/drm_connector.h  | 41 +++---
  include/drm/drm_framebuffer.h| 49 -
  include/drm/drm_gem.h| 80 +--
  include/drm/drm_mode_object.h| 36 ++---
  include/drm/drm_property.h   | 35 ++--
  scripts/coccinelle/api/drm-get-put.cocci | 92 
  25 files changed, 471 insertions(+), 240 deletions(-)
  create mode 100644 scripts/coccinelle/api/drm-get-put.cocci



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


[Bug 99747] Problems with mesa 13.0.x and ubuntu 17.04

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99747

--- Comment #4 from APoliTech  ---
But upgrading to llvm-toolchain-3.9 (1:3.9.1-4ubuntu3)   fixed "The problem is
that all the pictures that i open on this os i will see them blue-is (look at
the pics)"

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 99747] Problems with mesa 13.0.x and ubuntu 17.04

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99747

--- Comment #3 from APoliTech  ---
 sudo  apt-cache policy libllvm3.9
libllvm3.9:
  Installed: 1:3.9.1-2ubuntu1
  Candidate: 1:3.9.1-2ubuntu1
  Version table:
 *** 1:3.9.1-2ubuntu1 500
500 http://ro.archive.ubuntu.com/ubuntu zesty/main amd64 Packages
100 /var/lib/dpkg/status

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 2/2] drm/fb_helper: implement ioctl FBIO_WAITFORVSYNC

2017-02-10 Thread Ville Syrjälä
On Thu, Feb 02, 2017 at 11:31:57AM +0100, Maxime Ripard wrote:
> From: Stefan Christ 
> 
> Implement legacy framebuffer ioctl FBIO_WAITFORVSYNC in the generic
> framebuffer emulation driver. Legacy framebuffer users like non kms/drm
> based OpenGL(ES)/EGL implementations may require the ioctl to
> synchronize drawing or buffer flip for double buffering. It is tested on
> the i.MX6.
> 
> Code is based on
> 
> https://github.com/Xilinx/linux-xlnx/blob/master/drivers/gpu/drm/xilinx/xilinx_drm_fb.c#L196
> 
> Signed-off-by: Stefan Christ 
> Signed-off-by: Maxime Ripard 
> ---
>  drivers/gpu/drm/drm_fb_helper.c | 55 ++-
>  include/drm/drm_fb_helper.h |  5 ++-
>  2 files changed, 59 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index e934b541feea..39a3532e311c 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -1234,6 +1234,61 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct 
> fb_info *info)
>  EXPORT_SYMBOL(drm_fb_helper_setcmap);
>  
>  /**
> + * drm_fb_helper_ioctl - legacy ioctl implementation
> + * @info: fbdev registered by the helper
> + * @cmd: ioctl command
> + * @arg: ioctl argument
> + *
> + * A helper to implement the standard fbdev ioctl. Only
> + * FBIO_WAITFORVSYNC is implemented for now.
> + */
> +int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, unsigned 
> long arg)
> +{
> + struct drm_fb_helper *fb_helper = info->par;
> + struct drm_device *dev = fb_helper->dev;
> + unsigned int i;
> + int ret = 0;
> +
> + drm_modeset_lock_all(dev);
> + if (!drm_fb_helper_is_bound(fb_helper)) {
> + drm_modeset_unlock_all(dev);
> + return -EBUSY;
> + }
> +
> + switch (cmd) {
> + case FBIO_WAITFORVSYNC:
> + for (i = 0; i < fb_helper->crtc_count; i++) {

FBIO_WAITFORVSYNC takes the crtc as a parmeter, so I'm not sure we want
to do this for all the crtcs. Though what that crtc means for fb is
rather poorly defined.

> + struct drm_mode_set *mode_set;
> + struct drm_crtc *crtc;
> +
> + mode_set = _helper->crtc_info[i].mode_set;
> + crtc = mode_set->crtc;
> +
> + /*
> +  * Only call drm_crtc_wait_one_vblank for crtcs that
> +  * are currently enabled.
> +  */
> + if (!crtc->enabled)
> + continue;
> +
> + ret = drm_crtc_vblank_get(crtc);
> + if (!ret) {
> + drm_crtc_wait_one_vblank(crtc);
> + drm_crtc_vblank_put(crtc);
> + }

This looks quite sub-optimal. It should rather do something along the
lines of what drm_atomic_helper_wait_for_vblanks() does.

> + }
> + goto unlock;
> + default:
> + ret = -ENOTTY;
> + }
> +
> +unlock:
> + drm_modeset_unlock_all(dev);
> + return ret;
> +}
> +EXPORT_SYMBOL(drm_fb_helper_ioctl);
> +
> +/**
>   * drm_fb_helper_check_var - implementation for ->fb_check_var
>   * @var: screeninfo to check
>   * @info: fbdev registered by the helper
> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
> index 975deedd593e..460be9d9fa98 100644
> --- a/include/drm/drm_fb_helper.h
> +++ b/include/drm/drm_fb_helper.h
> @@ -230,7 +230,8 @@ struct drm_fb_helper {
>   .fb_blank   = drm_fb_helper_blank, \
>   .fb_pan_display = drm_fb_helper_pan_display, \
>   .fb_debug_enter = drm_fb_helper_debug_enter, \
> - .fb_debug_leave = drm_fb_helper_debug_leave
> + .fb_debug_leave = drm_fb_helper_debug_leave, \
> + .fb_ioctl   = drm_fb_helper_ioctl
>  
>  #ifdef CONFIG_DRM_FBDEV_EMULATION
>  void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper 
> *helper,
> @@ -286,6 +287,8 @@ void drm_fb_helper_set_suspend_unlocked(struct 
> drm_fb_helper *fb_helper,
>  
>  int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);
>  
> +int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, unsigned 
> long arg);
> +
>  int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
>  int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int 
> bpp_sel);
>  int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper);
> -- 
> git-series 0.8.11
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 99762] "Black Mesa" not launching

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99762

Samuel Pitoiset  changed:

   What|Removed |Added

Summary|black mesa not launching|"Black Mesa" not launching

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 99762] black mesa not launching

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99762

--- Comment #1 from Samuel Pitoiset  ---
At first look, I thought "Black Mesa" was a joke but it's not. Funny name! :-)

According to
https://steamcommunity.com/app/362890/discussions/0/312265327168384714/, the
Linux version seems to have various issues. I will let you know when I can test
myself.

Thanks for reporting.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 99762] black mesa not launching

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99762

Bug ID: 99762
   Summary: black mesa not launching
   Product: Mesa
   Version: 13.0
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Drivers/Gallium/radeonsi
  Assignee: dri-devel@lists.freedesktop.org
  Reporter: bronsonmath...@gmail.com
QA Contact: dri-devel@lists.freedesktop.org

I see not command line output, so can only assume a recent driver update has
caused this game to stop running.

Using mesa 13.0.3 on a radeon 6970 under kde neon.

Running the game from steam gives no error in the console, and does nothing. I
had it working fine previously with an older version.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 97879] [amdgpu] Rocket League: long hangs (several seconds) when loading assets (models/textures/shaders?)

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97879

--- Comment #77 from freedesk...@bremsspur.org ---
(In reply to Michel Dänzer from comment #75)
> (In reply to Clemens Eisserer from comment #73)
> > just to be curious, does it actually map the buffer with the READ flag?
> 
> According to Timothee and the apitrace it does, so
> https://patchwork.freedesktop.org/patch/138047/ should help for this issue.

it helps, but fps drops quite a bit on my aged r660g gpu (patch applied to mesa
13.0.4). It runs better as Mareks test did before, so maybe it works out for
newer hardware.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/i915: Fix not finding the VBT when it overlaps with OPREGION_ASLE_EXT

2017-02-10 Thread Jani Nikula
On Fri, 10 Feb 2017, Hans de Goede  wrote:
> On 06-02-17 08:04, Jani Nikula wrote:
>> First, I want a big fat warning comment about what's going on
>> here. Otherwise someone's bound to "fix" this later on.
>
> Done for v2, which I will send shortly.

Thanks.

>> Second, per the spec, the ASLE ext mailbox is 1k in size, and there's a
>> 1k reserved region at the end. We probably shouldn't allow VBT to extend
>> over there. But hey, per the spec we also shouldn't allow VBT to extend
>> over mailbox #5 either. So if you can't be bothered with that, neither
>> will I.
>
> Hmm, that makes no sense, OPREGION_SIZE is 8192 bytes or 0x2000,
> OPREGION_ASLE_EXT_OFFSET is 0x1C00 or 7168 bytes, if there is 1k
> reserved after the ASLE ext mailbox then there is exactly 0 bytes
> available for the ASLE ext mailbox or OPREGION_SIZE should be 9216
> not 8192 (which I don't think so). Maybe the last 1k is either
> the ASLE ext mailbox OR reserved ?

You're quite right, that makes no sense. :) Looks like we account for
the reserved part at the end of struct opregion_asle_ext, but the spec
isn't quite clear whether the reserved part is actually part of the
mailbox or not. I'm not quite sure how I managed to confuse myself to
turn that into 1k. Sorry.

BR,
Jani.

-- 
Jani Nikula, Intel Open Source Technology Center
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2] drm/i915: Fix not finding the VBT when it overlaps with OPREGION_ASLE_EXT

2017-02-10 Thread Hans de Goede
If there is no OPREGION_ASLE_EXT then a VBT stored in mailbox #4 may
use the ASLE_EXT parts of the opregion. Adjust the vbt_size calculation
for a vbt in mailbox #4 for this.

This fixes the driver not finding the VBT on a jumper ezpad mini3
cherrytrail tablet and on a ACER SW5_017 machine.

Cc: sta...@vger.kernel.org
Signed-off-by: Hans de Goede 
---
Changes in v2:
-Added a code comment explaining the why and how of the change
---
 drivers/gpu/drm/i915/intel_opregion.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_opregion.c 
b/drivers/gpu/drm/i915/intel_opregion.c
index f4429f6..f2de2d0 100644
--- a/drivers/gpu/drm/i915/intel_opregion.c
+++ b/drivers/gpu/drm/i915/intel_opregion.c
@@ -982,7 +982,18 @@ int intel_opregion_setup(struct drm_i915_private *dev_priv)
opregion->vbt_size = vbt_size;
} else {
vbt = base + OPREGION_VBT_OFFSET;
-   vbt_size = OPREGION_ASLE_EXT_OFFSET - 
OPREGION_VBT_OFFSET;
+   /*
+* The VBT specification says that if the ASLE ext
+* mailbox is not used its area is reserved, but
+* one some CHT boards the VBT extends into the
+* ASLE ext area. Allow this even though it is
+* against the spec, so we do not end up rejecting
+* the VBT on those boards (and end up not finding the
+* LCD panel because of this).
+*/
+   vbt_size = (mboxes & MBOX_ASLE_EXT) ?
+   OPREGION_ASLE_EXT_OFFSET : OPREGION_SIZE;
+   vbt_size -= OPREGION_VBT_OFFSET;
if (intel_bios_is_valid_vbt(vbt, vbt_size)) {
DRM_DEBUG_KMS("Found valid VBT in ACPI OpRegion 
(Mailbox #4)\n");
opregion->vbt = vbt;
-- 
2.9.3

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


Re: [PATCH] drm/i915: Fix not finding the VBT when it overlaps with OPREGION_ASLE_EXT

2017-02-10 Thread Hans de Goede

Hi,

On 06-02-17 08:04, Jani Nikula wrote:

On Sun, 25 Dec 2016, Hans de Goede  wrote:

If there is no OPREGION_ASLE_EXT then a VBT stored in mailbox #4 may
use the ASLE_EXT parts of the opregion. Adjust the vbt_size calculation
for a vbt in mailbox #4 for this.

This fixes the driver not finding the VBT on a jumper ezpad mini3
cherrytrail tablet.

Cc: sta...@vger.kernel.org
Signed-off-by: Hans de Goede 
---
Note even with this fixed the panel still does not work with 4.9,
but it does with drm-intel-next-queued :) I believe the missing bit in
4.9 is the "drm/915: Parsing the missed out DTD fields from the VBT"
commit, but I've not verified this.
---
 drivers/gpu/drm/i915/intel_opregion.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_opregion.c 
b/drivers/gpu/drm/i915/intel_opregion.c
index f4429f6..eff35ae 100644
--- a/drivers/gpu/drm/i915/intel_opregion.c
+++ b/drivers/gpu/drm/i915/intel_opregion.c
@@ -982,7 +982,9 @@ int intel_opregion_setup(struct drm_i915_private *dev_priv)
opregion->vbt_size = vbt_size;
} else {
vbt = base + OPREGION_VBT_OFFSET;
-   vbt_size = OPREGION_ASLE_EXT_OFFSET - 
OPREGION_VBT_OFFSET;
+   vbt_size = (mboxes & MBOX_ASLE_EXT) ?
+   OPREGION_ASLE_EXT_OFFSET : OPREGION_SIZE;
+   vbt_size -= OPREGION_VBT_OFFSET;


First, I want a big fat warning comment about what's going on
here. Otherwise someone's bound to "fix" this later on.


Done for v2, which I will send shortly.


Second, per the spec, the ASLE ext mailbox is 1k in size, and there's a
1k reserved region at the end. We probably shouldn't allow VBT to extend
over there. But hey, per the spec we also shouldn't allow VBT to extend
over mailbox #5 either. So if you can't be bothered with that, neither
will I.


Hmm, that makes no sense, OPREGION_SIZE is 8192 bytes or 0x2000,
OPREGION_ASLE_EXT_OFFSET is 0x1C00 or 7168 bytes, if there is 1k
reserved after the ASLE ext mailbox then there is exactly 0 bytes
available for the ASLE ext mailbox or OPREGION_SIZE should be 9216
not 8192 (which I don't think so). Maybe the last 1k is either
the ASLE ext mailbox OR reserved ?

Anyways leaving this bit as is for now.

Regards,

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


[Bug 99136] Blood Effects Total War: Warhammer

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99136

--- Comment #25 from siyia  ---
This is what it spams when the bug happens

apitrace: warning: glNamedBufferStorage: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/o
MAP_PERSISTENT_BIT

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 11/12] drm/i915: Add intel_uncore_suspend / resume functions

2017-02-10 Thread Hans de Goede
Rename intel_uncore_early_sanitize to intel_uncore_resume, dropping the
(always true) restore_forcewake argument and add a new intel_uncore_resume
function to replace the intel_uncore_forcewake_reset(dev_priv, false)
calls done from the suspend / runtime_suspend functions and make
intel_uncore_forcewake_reset private.

This is a preparation patch for adding PMIC bus access notifier support.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=155241
Signed-off-by: Hans de Goede 
Tested-by: tagorereddy 
---
Changes in v2:
-Spelling: P-Unit, PMIC
Changes in v3:
-Rename intel_uncore_resume to intel_uncore_resume_early
-Keep intel_uncore_forcewake_reset name as is
---
 drivers/gpu/drm/i915/i915_drv.c |  6 +++---
 drivers/gpu/drm/i915/i915_drv.h |  6 ++
 drivers/gpu/drm/i915/intel_uncore.c | 14 +-
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index a17dde8..8d75249 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1506,7 +1506,7 @@ static int i915_drm_suspend(struct drm_device *dev)
opregion_target_state = suspend_to_idle(dev_priv) ? PCI_D1 : PCI_D3cold;
intel_opregion_notify_adapter(dev_priv, opregion_target_state);
 
-   intel_uncore_forcewake_reset(dev_priv, false);
+   intel_uncore_suspend(dev_priv);
intel_opregion_unregister(dev_priv);
 
intel_fbdev_set_suspend(dev, FBINFO_STATE_SUSPENDED, true);
@@ -1751,7 +1751,7 @@ static int i915_drm_resume_early(struct drm_device *dev)
DRM_ERROR("Resume prepare failed: %d, continuing anyway\n",
  ret);
 
-   intel_uncore_early_sanitize(dev_priv, true);
+   intel_uncore_resume_early(dev_priv);
 
if (IS_GEN9_LP(dev_priv)) {
if (!dev_priv->suspended_to_idle)
@@ -2396,7 +2396,7 @@ static int intel_runtime_suspend(struct device *kdev)
return ret;
}
 
-   intel_uncore_forcewake_reset(dev_priv, false);
+   intel_uncore_suspend(dev_priv);
 
enable_rpm_wakeref_asserts(dev_priv);
WARN_ON_ONCE(atomic_read(_priv->pm.wakeref_count));
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 604b20f..998239f 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3010,14 +3010,12 @@ int intel_irq_install(struct drm_i915_private 
*dev_priv);
 void intel_irq_uninstall(struct drm_i915_private *dev_priv);
 
 extern void intel_uncore_sanitize(struct drm_i915_private *dev_priv);
-extern void intel_uncore_early_sanitize(struct drm_i915_private *dev_priv,
-   bool restore_forcewake);
 extern void intel_uncore_init(struct drm_i915_private *dev_priv);
 extern bool intel_uncore_unclaimed_mmio(struct drm_i915_private *dev_priv);
 extern bool intel_uncore_arm_unclaimed_mmio_detection(struct drm_i915_private 
*dev_priv);
 extern void intel_uncore_fini(struct drm_i915_private *dev_priv);
-extern void intel_uncore_forcewake_reset(struct drm_i915_private *dev_priv,
-bool restore);
+extern void intel_uncore_suspend(struct drm_i915_private *dev_priv);
+extern void intel_uncore_resume_early(struct drm_i915_private *dev_priv);
 const char *intel_uncore_forcewake_domain_to_str(const enum 
forcewake_domain_id id);
 void intel_uncore_forcewake_get(struct drm_i915_private *dev_priv,
enum forcewake_domains domains);
diff --git a/drivers/gpu/drm/i915/intel_uncore.c 
b/drivers/gpu/drm/i915/intel_uncore.c
index 1ff8fd9..b6d726b 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -257,8 +257,8 @@ intel_uncore_fw_release_timer(struct hrtimer *timer)
return HRTIMER_NORESTART;
 }
 
-void intel_uncore_forcewake_reset(struct drm_i915_private *dev_priv,
- bool restore)
+static void intel_uncore_forcewake_reset(struct drm_i915_private *dev_priv,
+bool restore)
 {
unsigned long irqflags;
struct intel_uncore_forcewake_domain *domain;
@@ -434,10 +434,14 @@ static void __intel_uncore_early_sanitize(struct 
drm_i915_private *dev_priv,
intel_uncore_forcewake_reset(dev_priv, restore_forcewake);
 }
 
-void intel_uncore_early_sanitize(struct drm_i915_private *dev_priv,
-bool restore_forcewake)
+void intel_uncore_suspend(struct drm_i915_private *dev_priv)
 {
-   __intel_uncore_early_sanitize(dev_priv, restore_forcewake);
+   intel_uncore_forcewake_reset(dev_priv, false);
+}
+
+void intel_uncore_resume_early(struct drm_i915_private *dev_priv)
+{
+   __intel_uncore_early_sanitize(dev_priv, true);
i915_check_and_clear_faults(dev_priv);
 }
 
-- 
2.9.3

___
dri-devel mailing list

[PATCH v3 10/12] i2c: designware-baytrail: Call pmic_bus_access_notifier_chain

2017-02-10 Thread Hans de Goede
Call the iosf_mbi pmic_bus_access_notifier_chain on bus acquire / release.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=155241
Signed-off-by: Hans de Goede 
Tested-by: tagorereddy 
Reviewed-by: Andy Shevchenko 
Acked-by: Wolfram Sang 
Acked-by: Jarkko Nikula 
---
Changes in v2:
-Spelling: P-Unit, PMIC
---
 drivers/i2c/busses/i2c-designware-baytrail.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/i2c/busses/i2c-designware-baytrail.c 
b/drivers/i2c/busses/i2c-designware-baytrail.c
index 7eddc3b..1749a0f 100644
--- a/drivers/i2c/busses/i2c-designware-baytrail.c
+++ b/drivers/i2c/busses/i2c-designware-baytrail.c
@@ -63,6 +63,8 @@ static void reset_semaphore(struct dw_i2c_dev *dev)
 
pm_qos_update_request(>pm_qos, PM_QOS_DEFAULT_VALUE);
 
+   iosf_mbi_call_pmic_bus_access_notifier_chain(MBI_PMIC_BUS_ACCESS_END,
+NULL);
iosf_mbi_punit_release();
 }
 
@@ -82,6 +84,8 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
return 0;
 
iosf_mbi_punit_acquire();
+   iosf_mbi_call_pmic_bus_access_notifier_chain(MBI_PMIC_BUS_ACCESS_BEGIN,
+NULL);
 
/*
 * Disallow the CPU to enter C6 or C7 state, entering these states
-- 
2.9.3

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


[PATCH v3 12/12] drm/i915: Listen for PMIC bus access notifications

2017-02-10 Thread Hans de Goede
Listen for PMIC bus access notifications and get FORCEWAKE_ALL while
the bus is accessed to avoid needing to do any forcewakes, which need
PMIC bus access, while the PMIC bus is busy:

This fixes errors like these showing up in dmesg, usually followed
by a gfx or system freeze:

[drm:fw_domains_get [i915]] *ERROR* render: timed out waiting for forcewake ack 
request.
[drm:fw_domains_get [i915]] *MEDIA* render: timed out waiting for forcewake ack 
request.
i2c_designware 808622C1:06: punit semaphore timed out, resetting
i2c_designware 808622C1:06: PUNIT SEM: 2
i2c_designware 808622C1:06: couldn't acquire bus ownership

Downside of this approach is that it causes wakeups whenever the PMIC
bus is accessed. Unfortunately we cannot simply wait for the PMIC bus
to go idle when we hit a race, as forcewakes may be done from interrupt
handlers where we cannot sleep to wait for the i2c PMIC bus access to
finish.

Note that the notifications and thus the wakeups will only happen on
baytrail / cherrytrail devices using PMICs with a shared i2c bus for
P-Unit and host PMIC access (i2c busses with a _SEM method in their
APCI node), e.g. an axp288 PMIC.

I plan to write some patches for drivers accessing the PMIC bus to
limit their bus accesses to a bare minimum (e.g. cache registers, do not
update battery level more often then 4 times a minute), to limit the
amount of wakeups.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=155241
Signed-off-by: Hans de Goede 
Tested-by: tagorereddy 
---
Changes in v2:
-Spelling: P-Unit, PMIC
Changes in v3:
-Improve comment explaining why we call intel_uncore_forcewake_get(ALL) on
 MBI_PMIC_BUS_ACCESS_BEGIN notification
---
 drivers/gpu/drm/i915/Kconfig|  1 +
 drivers/gpu/drm/i915/i915_drv.h |  1 +
 drivers/gpu/drm/i915/intel_uncore.c | 39 +
 3 files changed, 41 insertions(+)

diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
index 1ae0bb9..a5cd5da 100644
--- a/drivers/gpu/drm/i915/Kconfig
+++ b/drivers/gpu/drm/i915/Kconfig
@@ -20,6 +20,7 @@ config DRM_I915
select ACPI_VIDEO if ACPI
select ACPI_BUTTON if ACPI
select SYNC_FILE
+   select IOSF_MBI
help
  Choose this option if you have a system that has "Intel Graphics
  Media Accelerator" or "HD Graphics" integrated graphics,
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 998239f..4e405d0 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -725,6 +725,7 @@ struct intel_uncore {
const struct intel_forcewake_range *fw_domains_table;
unsigned int fw_domains_table_entries;
 
+   struct notifier_block pmic_bus_access_nb;
struct intel_uncore_funcs funcs;
 
unsigned fifo_count;
diff --git a/drivers/gpu/drm/i915/intel_uncore.c 
b/drivers/gpu/drm/i915/intel_uncore.c
index b6d726b..1be3cdc 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -25,6 +25,7 @@
 #include "intel_drv.h"
 #include "i915_vgpu.h"
 
+#include 
 #include 
 
 #define FORCEWAKE_ACK_TIMEOUT_MS 50
@@ -436,12 +437,16 @@ static void __intel_uncore_early_sanitize(struct 
drm_i915_private *dev_priv,
 
 void intel_uncore_suspend(struct drm_i915_private *dev_priv)
 {
+   iosf_mbi_unregister_pmic_bus_access_notifier(
+   _priv->uncore.pmic_bus_access_nb);
intel_uncore_forcewake_reset(dev_priv, false);
 }
 
 void intel_uncore_resume_early(struct drm_i915_private *dev_priv)
 {
__intel_uncore_early_sanitize(dev_priv, true);
+   iosf_mbi_register_pmic_bus_access_notifier(
+   _priv->uncore.pmic_bus_access_nb);
i915_check_and_clear_faults(dev_priv);
 }
 
@@ -1329,6 +1334,32 @@ static void intel_uncore_fw_domains_init(struct 
drm_i915_private *dev_priv)
dev_priv->uncore.fw_domains_table_entries = ARRAY_SIZE((d)); \
 }
 
+static int i915_pmic_bus_access_notifier(struct notifier_block *nb,
+unsigned long action, void *data)
+{
+   struct drm_i915_private *dev_priv = container_of(nb,
+   struct drm_i915_private, uncore.pmic_bus_access_nb);
+
+   switch (action) {
+   case MBI_PMIC_BUS_ACCESS_BEGIN:
+   /*
+* forcewake all now to make sure that we don't need to do a
+* forcewake later which on systems where this notifier gets
+* called requires the punit to access to the shared pmic i2c
+* bus, which will be busy after this notification, leading to:
+* "render: timed out waiting for forcewake ack request."
+* errors.
+*/
+   intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
+   break;
+   case MBI_PMIC_BUS_ACCESS_END:
+   intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
+   

[PATCH v3 09/12] i2c: designware-baytrail: Acquire P-Unit access on bus acquire

2017-02-10 Thread Hans de Goede
Acquire P-Unit access to stop others from accessing the P-Unit while the
PMIC i2c bus is in use. This is necessary because accessing the P-Unit
from the kernel may result in the P-Unit trying to access the PMIC i2c
bus, which results in a hang when it happens while we own the PMIC i2c
bus semaphore.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=155241
Signed-off-by: Hans de Goede 
Tested-by: tagorereddy 
Acked-by: Wolfram Sang 
Acked-by: Jarkko Nikula 
---
Changes in v2:
-Spelling: P-Unit, PMIC
-Adjust for iosf_mbi_punit_lock/_unlock to _acquire/_release rename
---
 drivers/i2c/busses/i2c-designware-baytrail.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/i2c/busses/i2c-designware-baytrail.c 
b/drivers/i2c/busses/i2c-designware-baytrail.c
index 3effc9a..7eddc3b 100644
--- a/drivers/i2c/busses/i2c-designware-baytrail.c
+++ b/drivers/i2c/busses/i2c-designware-baytrail.c
@@ -62,6 +62,8 @@ static void reset_semaphore(struct dw_i2c_dev *dev)
dev_err(dev->dev, "iosf failed to reset punit semaphore during 
write\n");
 
pm_qos_update_request(>pm_qos, PM_QOS_DEFAULT_VALUE);
+
+   iosf_mbi_punit_release();
 }
 
 static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
@@ -79,6 +81,8 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
if (!dev->release_lock)
return 0;
 
+   iosf_mbi_punit_acquire();
+
/*
 * Disallow the CPU to enter C6 or C7 state, entering these states
 * requires the punit to talk to the pmic and if this happens while
-- 
2.9.3

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


[PATCH v3 07/12] i2c: designware-baytrail: Fix race when resetting the semaphore

2017-02-10 Thread Hans de Goede
Use iosf_mbi_modify instead of iosf_mbi_read + iosf_mbi_write so that
we keep the iosf_mbi_lock locked during the read-modify-write done to
reset the semaphore.

Signed-off-by: Hans de Goede 
Reviewed-by: Andy Shevchenko 
Acked-by: Jarkko Nikula 
Acked-by: Wolfram Sang 
---
Changes in v5:
-New patch in v5 of this patch-set
---
 drivers/i2c/busses/i2c-designware-baytrail.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-baytrail.c 
b/drivers/i2c/busses/i2c-designware-baytrail.c
index 650a700..8df529c 100644
--- a/drivers/i2c/busses/i2c-designware-baytrail.c
+++ b/drivers/i2c/busses/i2c-designware-baytrail.c
@@ -47,15 +47,8 @@ static int get_sem(struct dw_i2c_dev *dev, u32 *sem)
 
 static void reset_semaphore(struct dw_i2c_dev *dev)
 {
-   u32 data;
-
-   if (iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE, 
)) {
-   dev_err(dev->dev, "iosf failed to reset punit semaphore during 
read\n");
-   return;
-   }
-
-   data &= ~PUNIT_SEMAPHORE_BIT;
-   if (iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, PUNIT_SEMAPHORE, 
data))
+   if (iosf_mbi_modify(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE,
+   0, PUNIT_SEMAPHORE_BIT))
dev_err(dev->dev, "iosf failed to reset punit semaphore during 
write\n");
 
pm_qos_update_request(>pm_qos, PM_QOS_DEFAULT_VALUE);
-- 
2.9.3

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


[PATCH v3 08/12] i2c: designware-baytrail: Add support for cherrytrail

2017-02-10 Thread Hans de Goede
The cherrytrail punit has the pmic i2c bus access semaphore at a
different register address.

Signed-off-by: Hans de Goede 
Reviewed-by: Takashi Iwai 
Tested-by: Takashi Iwai 
Reviewed-by: Andy Shevchenko 
Acked-by: Jarkko Nikula 
Acked-by: Wolfram Sang 
---
Changes in v2:
-Adjust for accessor_flags -> flags rename
-Add flags field to struct dw_pci_controller
-Add get_sem_addr() helper replacing MODEL_CHERRYTRAIL flag checking in
 PUNIT_SEMAPHORE macro
Changes in v3:
-Add a gap between ACCESS_* and MODEL_* flags as reserved space for
 future ACCESS_* flags
Changes in v4:
-s/CHV/CHT/
---
 drivers/i2c/busses/i2c-designware-baytrail.c | 19 +++
 drivers/i2c/busses/i2c-designware-core.h |  2 ++
 drivers/i2c/busses/i2c-designware-pcidrv.c   | 26 +++---
 drivers/i2c/busses/i2c-designware-platdrv.c  |  2 +-
 4 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-baytrail.c 
b/drivers/i2c/busses/i2c-designware-baytrail.c
index 8df529c..3effc9a 100644
--- a/drivers/i2c/busses/i2c-designware-baytrail.c
+++ b/drivers/i2c/busses/i2c-designware-baytrail.c
@@ -24,17 +24,27 @@
 
 #define SEMAPHORE_TIMEOUT  100
 #define PUNIT_SEMAPHORE0x7
+#define PUNIT_SEMAPHORE_CHT0x10e
 #define PUNIT_SEMAPHORE_BITBIT(0)
 #define PUNIT_SEMAPHORE_ACQUIREBIT(1)
 
 static unsigned long acquired;
 
+static u32 get_sem_addr(struct dw_i2c_dev *dev)
+{
+   if (dev->flags & MODEL_CHERRYTRAIL)
+   return PUNIT_SEMAPHORE_CHT;
+   else
+   return PUNIT_SEMAPHORE;
+}
+
 static int get_sem(struct dw_i2c_dev *dev, u32 *sem)
 {
+   u32 addr = get_sem_addr(dev);
u32 data;
int ret;
 
-   ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE, 
);
+   ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, addr, );
if (ret) {
dev_err(dev->dev, "iosf failed to read punit semaphore\n");
return ret;
@@ -47,7 +57,7 @@ static int get_sem(struct dw_i2c_dev *dev, u32 *sem)
 
 static void reset_semaphore(struct dw_i2c_dev *dev)
 {
-   if (iosf_mbi_modify(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE,
+   if (iosf_mbi_modify(BT_MBI_UNIT_PMC, MBI_REG_READ, get_sem_addr(dev),
0, PUNIT_SEMAPHORE_BIT))
dev_err(dev->dev, "iosf failed to reset punit semaphore during 
write\n");
 
@@ -56,6 +66,7 @@ static void reset_semaphore(struct dw_i2c_dev *dev)
 
 static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
 {
+   u32 addr = get_sem_addr(dev);
u32 sem = PUNIT_SEMAPHORE_ACQUIRE;
int ret;
unsigned long start, end;
@@ -76,7 +87,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
pm_qos_update_request(>pm_qos, 0);
 
/* host driver writes to side band semaphore register */
-   ret = iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, PUNIT_SEMAPHORE, 
sem);
+   ret = iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, addr, sem);
if (ret) {
dev_err(dev->dev, "iosf punit semaphore request failed\n");
goto out;
@@ -101,7 +112,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
 out:
reset_semaphore(dev);
 
-   ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE, 
);
+   ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, addr, );
if (ret)
dev_err(dev->dev, "iosf failed to read punit semaphore\n");
else
diff --git a/drivers/i2c/busses/i2c-designware-core.h 
b/drivers/i2c/busses/i2c-designware-core.h
index 94a5fd1..a8e74ca 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -135,6 +135,8 @@ struct dw_i2c_dev {
 #define ACCESS_16BIT   0x0002
 #define ACCESS_INTR_MASK   0x0004
 
+#define MODEL_CHERRYTRAIL  0x0100
+
 extern int i2c_dw_init(struct dw_i2c_dev *dev);
 extern void i2c_dw_disable(struct dw_i2c_dev *dev);
 extern void i2c_dw_disable_int(struct dw_i2c_dev *dev);
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c 
b/drivers/i2c/busses/i2c-designware-pcidrv.c
index d6423cf..ed485b6 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -45,6 +45,7 @@ enum dw_pci_ctl_id_t {
medfield,
merrifield,
baytrail,
+   cherrytrail,
haswell,
 };
 
@@ -63,6 +64,7 @@ struct dw_pci_controller {
u32 rx_fifo_depth;
u32 clk_khz;
u32 functionality;
+   u32 flags;
struct dw_scl_sda_cfg *scl_sda_cfg;
int (*setup)(struct pci_dev *pdev, struct dw_pci_controller *c);
 };
@@ -170,6 +172,15 @@ static struct dw_pci_controller dw_pci_controllers[] = {
.functionality = I2C_FUNC_10BIT_ADDR,

[PATCH v3 06/12] i2c: designware-baytrail: Disallow the CPU to enter C6 or C7 while holding the punit semaphore

2017-02-10 Thread Hans de Goede
On my cherrytrail tablet with axp288 pmic, just doing a bunch of repeated
reads from the pmic, e.g. "i2cdump -y 14 0x34" would lookup the tablet in
1 - 3 runs guaranteed.

This seems to be causes by the cpu trying to enter C6 or C7 while we hold
the punit bus semaphore, at which point everything just hangs.

Avoid this by disallowing the CPU to enter C6 or C7 before acquiring the
punit bus semaphore.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=109051
Signed-off-by: Hans de Goede 
Tested-by: Takashi Iwai 
Reviewed-by: Andy Shevchenko 
Acked-by: Jarkko Nikula 
Acked-by: Wolfram Sang 
---
Changes in v2:
-New patch in v2 of this set
Changes in v3:
-Change commit message and comment in the code from "force the CPU to C1"
 to "Disallow the CPU to enter C6 or C7", as the CPU may still be in either
 C0 or C1 with the request pm_qos
Changes in v4:
-Rename i2c_dw_eval_lock_support to i2c_dw_probe_lock_support so that we can
 add a matching i2c_dw_remove_lock_support cleanup function
-Move qm_pos removal to new i2c_dw_remove_lock_support function
-Move pm_qos_add_request to the end of i2c_dw_probe_lock_support
Changes in v5:
-Update the pm_qos for a latency of 0 *before* requesting the semaphore,
 instead of doing it while waiting for the request to be acked
---
 drivers/i2c/busses/i2c-designware-baytrail.c | 24 ++--
 drivers/i2c/busses/i2c-designware-core.h |  9 +++--
 drivers/i2c/busses/i2c-designware-platdrv.c  |  4 +++-
 3 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-baytrail.c 
b/drivers/i2c/busses/i2c-designware-baytrail.c
index cf0..650a700 100644
--- a/drivers/i2c/busses/i2c-designware-baytrail.c
+++ b/drivers/i2c/busses/i2c-designware-baytrail.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -56,6 +57,8 @@ static void reset_semaphore(struct dw_i2c_dev *dev)
data &= ~PUNIT_SEMAPHORE_BIT;
if (iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, PUNIT_SEMAPHORE, 
data))
dev_err(dev->dev, "iosf failed to reset punit semaphore during 
write\n");
+
+   pm_qos_update_request(>pm_qos, PM_QOS_DEFAULT_VALUE);
 }
 
 static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
@@ -72,11 +75,18 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
if (!dev->release_lock)
return 0;
 
+   /*
+* Disallow the CPU to enter C6 or C7 state, entering these states
+* requires the punit to talk to the pmic and if this happens while
+* we're holding the semaphore, the SoC hangs.
+*/
+   pm_qos_update_request(>pm_qos, 0);
+
/* host driver writes to side band semaphore register */
ret = iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, PUNIT_SEMAPHORE, 
sem);
if (ret) {
dev_err(dev->dev, "iosf punit semaphore request failed\n");
-   return ret;
+   goto out;
}
 
/* host driver waits for bit 0 to be set in semaphore register */
@@ -95,6 +105,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
} while (time_before(jiffies, end));
 
dev_err(dev->dev, "punit semaphore timed out, resetting\n");
+out:
reset_semaphore(dev);
 
ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE, 
);
@@ -121,7 +132,7 @@ static void baytrail_i2c_release(struct dw_i2c_dev *dev)
jiffies_to_msecs(jiffies - acquired));
 }
 
-int i2c_dw_eval_lock_support(struct dw_i2c_dev *dev)
+int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev)
 {
acpi_status status;
unsigned long long shared_host = 0;
@@ -149,5 +160,14 @@ int i2c_dw_eval_lock_support(struct dw_i2c_dev *dev)
dev->release_lock = baytrail_i2c_release;
dev->pm_runtime_disabled = true;
 
+   pm_qos_add_request(>pm_qos, PM_QOS_CPU_DMA_LATENCY,
+  PM_QOS_DEFAULT_VALUE);
+
return 0;
 }
+
+void i2c_dw_remove_lock_support(struct dw_i2c_dev *dev)
+{
+   if (dev->acquire_lock)
+   pm_qos_remove_request(>pm_qos);
+}
diff --git a/drivers/i2c/busses/i2c-designware-core.h 
b/drivers/i2c/busses/i2c-designware-core.h
index 2c50571..94a5fd1 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -23,6 +23,7 @@
  */
 
 #include 
+#include 
 
 #define DW_IC_DEFAULT_FUNCTIONALITY (I2C_FUNC_I2C |\
I2C_FUNC_SMBUS_BYTE |   \
@@ -75,6 +76,7 @@
  * @fp_lcnt: fast plus LCNT value
  * @hs_hcnt: high speed HCNT value
  * @hs_lcnt: high speed LCNT value
+ * @pm_qos: pm_qos_request used while holding a hardware lock on the bus
  * @acquire_lock: function to acquire a hardware lock on the bus
  * @release_lock: function to release a hardware lock on the bus
  * 

[PATCH v3 05/12] i2c: designware-baytrail: Only check iosf_mbi_available() for shared hosts

2017-02-10 Thread Hans de Goede
If (!shared_host) simply return 0, this avoids delaying the probe if
iosf_mbi_available() returns false when an i2c bus is not using the
punit semaphore.

Also move the if (!iosf_mbi_available()) check to above the
dev_info, so that we do not repeat the dev_info on every probe
until iosf_mbi_available() returns true.

Signed-off-by: Hans de Goede 
Reviewed-by: Andy Shevchenko 
Acked-by: Jarkko Nikula 
Tested-by: Takashi Iwai 
Acked-by: Wolfram Sang 
---
Changes in v2:
-New patch in v2 of this set
Changes in v3:
-Use if (!shared_host) return 0, to simplify the non-shared_host path
 and to avoid nested ifs
---
 drivers/i2c/busses/i2c-designware-baytrail.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-baytrail.c 
b/drivers/i2c/busses/i2c-designware-baytrail.c
index a3f581c..cf0 100644
--- a/drivers/i2c/busses/i2c-designware-baytrail.c
+++ b/drivers/i2c/busses/i2c-designware-baytrail.c
@@ -138,15 +138,16 @@ int i2c_dw_eval_lock_support(struct dw_i2c_dev *dev)
if (ACPI_FAILURE(status))
return 0;
 
-   if (shared_host) {
-   dev_info(dev->dev, "I2C bus managed by PUNIT\n");
-   dev->acquire_lock = baytrail_i2c_acquire;
-   dev->release_lock = baytrail_i2c_release;
-   dev->pm_runtime_disabled = true;
-   }
+   if (!shared_host)
+   return 0;
 
if (!iosf_mbi_available())
return -EPROBE_DEFER;
 
+   dev_info(dev->dev, "I2C bus managed by PUNIT\n");
+   dev->acquire_lock = baytrail_i2c_acquire;
+   dev->release_lock = baytrail_i2c_release;
+   dev->pm_runtime_disabled = true;
+
return 0;
 }
-- 
2.9.3

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


[PATCH v3 03/12] i2c: designware: Rename accessor_flags to flags

2017-02-10 Thread Hans de Goede
Rename accessor_flags to flags, so that we can use the field for
other flags too. This is a preparation patch for adding cherrytrail
support to the punit semaphore code.

Signed-off-by: Hans de Goede 
Reviewed-by: Andy Shevchenko 
Acked-by: Jarkko Nikula 
Tested-by: Takashi Iwai 
Acked-by: Wolfram Sang 
---
 drivers/i2c/busses/i2c-designware-core.c| 14 +++---
 drivers/i2c/busses/i2c-designware-core.h|  2 +-
 drivers/i2c/busses/i2c-designware-platdrv.c |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-core.c 
b/drivers/i2c/busses/i2c-designware-core.c
index 6d81c56..8c3ba42 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -177,13 +177,13 @@ static u32 dw_readl(struct dw_i2c_dev *dev, int offset)
 {
u32 value;
 
-   if (dev->accessor_flags & ACCESS_16BIT)
+   if (dev->flags & ACCESS_16BIT)
value = readw_relaxed(dev->base + offset) |
(readw_relaxed(dev->base + offset + 2) << 16);
else
value = readl_relaxed(dev->base + offset);
 
-   if (dev->accessor_flags & ACCESS_SWAP)
+   if (dev->flags & ACCESS_SWAP)
return swab32(value);
else
return value;
@@ -191,10 +191,10 @@ static u32 dw_readl(struct dw_i2c_dev *dev, int offset)
 
 static void dw_writel(struct dw_i2c_dev *dev, u32 b, int offset)
 {
-   if (dev->accessor_flags & ACCESS_SWAP)
+   if (dev->flags & ACCESS_SWAP)
b = swab32(b);
 
-   if (dev->accessor_flags & ACCESS_16BIT) {
+   if (dev->flags & ACCESS_16BIT) {
writew_relaxed((u16)b, dev->base + offset);
writew_relaxed((u16)(b >> 16), dev->base + offset + 2);
} else {
@@ -339,10 +339,10 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
reg = dw_readl(dev, DW_IC_COMP_TYPE);
if (reg == ___constant_swab32(DW_IC_COMP_TYPE_VALUE)) {
/* Configure register endianess access */
-   dev->accessor_flags |= ACCESS_SWAP;
+   dev->flags |= ACCESS_SWAP;
} else if (reg == (DW_IC_COMP_TYPE_VALUE & 0x)) {
/* Configure register access mode 16bit */
-   dev->accessor_flags |= ACCESS_16BIT;
+   dev->flags |= ACCESS_16BIT;
} else if (reg != DW_IC_COMP_TYPE_VALUE) {
dev_err(dev->dev, "Unknown Synopsys component type: "
"0x%08x\n", reg);
@@ -926,7 +926,7 @@ static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
 tx_aborted:
if ((stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET)) || dev->msg_err)
complete(>cmd_complete);
-   else if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK)) {
+   else if (unlikely(dev->flags & ACCESS_INTR_MASK)) {
/* workaround to trigger pending interrupt */
stat = dw_readl(dev, DW_IC_INTR_MASK);
i2c_dw_disable_int(dev);
diff --git a/drivers/i2c/busses/i2c-designware-core.h 
b/drivers/i2c/busses/i2c-designware-core.h
index 26250b4..2c50571 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -103,7 +103,7 @@ struct dw_i2c_dev {
unsigned intstatus;
u32 abort_source;
int irq;
-   u32 accessor_flags;
+   u32 flags;
struct i2c_adapter  adapter;
u32 functionality;
u32 master_cfg;
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c 
b/drivers/i2c/busses/i2c-designware-platdrv.c
index 6ce4313..3eede7b 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -112,7 +112,7 @@ static int dw_i2c_acpi_configure(struct platform_device 
*pdev)
 
id = acpi_match_device(pdev->dev.driver->acpi_match_table, >dev);
if (id && id->driver_data)
-   dev->accessor_flags |= (u32)id->driver_data;
+   dev->flags |= (u32)id->driver_data;
 
return 0;
 }
-- 
2.9.3

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


[PATCH v3 02/12] x86/platform/intel/iosf_mbi: Add a PMIC bus access notifier

2017-02-10 Thread Hans de Goede
Some drivers may need to acquire P-Unit managed resources from interrupt
context, where they cannot call iosf_mbi_punit_acquire().

This commit adds a notifier chain which allows a driver to get notified
(in a process context) before other drivers start accessing the PMIC bus,
so that the driver can acquire any resources, which it may need during
the window the other driver is accessing the PMIC, before hand.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=155241
Signed-off-by: Hans de Goede 
Tested-by: tagorereddy 
Reviewed-by: Andy Shevchenko 
---
Changes in v2:
-Spelling: P-Unit, PMIC
-Adjust for iosf_mbi_punit_lock/_unlock to _acquire/_release rename
---
 arch/x86/include/asm/iosf_mbi.h| 54 ++
 arch/x86/platform/intel/iosf_mbi.c | 36 +
 2 files changed, 90 insertions(+)

diff --git a/arch/x86/include/asm/iosf_mbi.h b/arch/x86/include/asm/iosf_mbi.h
index f6119d0..59e8f8b 100644
--- a/arch/x86/include/asm/iosf_mbi.h
+++ b/arch/x86/include/asm/iosf_mbi.h
@@ -47,6 +47,10 @@
 #define QRK_MBI_UNIT_MM0x05
 #define QRK_MBI_UNIT_SOC   0x31
 
+/* Action values for the pmic_bus_access_notifier functions */
+#define MBI_PMIC_BUS_ACCESS_BEGIN  1
+#define MBI_PMIC_BUS_ACCESS_END2
+
 #if IS_ENABLED(CONFIG_IOSF_MBI)
 
 bool iosf_mbi_available(void);
@@ -115,6 +119,38 @@ void iosf_mbi_punit_acquire(void);
  */
 void iosf_mbi_punit_release(void);
 
+/**
+ * iosf_mbi_register_pmic_bus_access_notifier - Register PMIC bus notifier
+ *
+ * This function can be used by drivers which may need to acquire P-Unit
+ * managed resources from interrupt context, where iosf_mbi_punit_acquire()
+ * can not be used.
+ *
+ * This function allows a driver to register a notifier to get notified (in a
+ * process context) before other drivers start accessing the PMIC bus.
+ *
+ * This allows the driver to acquire any resources, which it may need during
+ * the window the other driver is accessing the PMIC, before hand.
+ *
+ * @nb: notifier_block to register
+ */
+int iosf_mbi_register_pmic_bus_access_notifier(struct notifier_block *nb);
+
+/**
+ * iosf_mbi_register_pmic_bus_access_notifier - Unregister PMIC bus notifier
+ *
+ * @nb: notifier_block to unregister
+ */
+int iosf_mbi_unregister_pmic_bus_access_notifier(struct notifier_block *nb);
+
+/**
+ * iosf_mbi_call_pmic_bus_access_notifier_chain - Call PMIC bus notifier chain
+ *
+ * @val: action to pass into listener's notifier_call function
+ * @v: data pointer to pass into listener's notifier_call function
+ */
+int iosf_mbi_call_pmic_bus_access_notifier_chain(unsigned long val, void *v);
+
 #else /* CONFIG_IOSF_MBI is not enabled */
 static inline
 bool iosf_mbi_available(void)
@@ -146,6 +182,24 @@ int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 
mdr, u32 mask)
 static inline void iosf_mbi_punit_acquire(void) {}
 static inline void iosf_mbi_punit_release(void) {}
 
+static inline
+int iosf_mbi_register_pmic_bus_access_notifier(struct notifier_block *nb)
+{
+   return 0;
+}
+
+static inline
+int iosf_mbi_unregister_pmic_bus_access_notifier(struct notifier_block *nb)
+{
+   return 0;
+}
+
+static inline
+int iosf_mbi_call_pmic_bus_access_notifier_chain(unsigned long val, void *v)
+{
+   return 0;
+}
+
 #endif /* CONFIG_IOSF_MBI */
 
 #endif /* IOSF_MBI_SYMS_H */
diff --git a/arch/x86/platform/intel/iosf_mbi.c 
b/arch/x86/platform/intel/iosf_mbi.c
index ed24fa9f..a952ac1 100644
--- a/arch/x86/platform/intel/iosf_mbi.c
+++ b/arch/x86/platform/intel/iosf_mbi.c
@@ -35,6 +35,7 @@
 static struct pci_dev *mbi_pdev;
 static DEFINE_SPINLOCK(iosf_mbi_lock);
 static DEFINE_MUTEX(iosf_mbi_punit_mutex);
+static BLOCKING_NOTIFIER_HEAD(iosf_mbi_pmic_bus_access_notifier);
 
 static inline u32 iosf_mbi_form_mcr(u8 op, u8 port, u8 offset)
 {
@@ -203,6 +204,41 @@ void iosf_mbi_punit_release(void)
 }
 EXPORT_SYMBOL(iosf_mbi_punit_release);
 
+int iosf_mbi_register_pmic_bus_access_notifier(struct notifier_block *nb)
+{
+   int ret;
+
+   /* Wait for the bus to go inactive before registering */
+   mutex_lock(_mbi_punit_mutex);
+   ret = blocking_notifier_chain_register(
+   _mbi_pmic_bus_access_notifier, nb);
+   mutex_unlock(_mbi_punit_mutex);
+
+   return ret;
+}
+EXPORT_SYMBOL(iosf_mbi_register_pmic_bus_access_notifier);
+
+int iosf_mbi_unregister_pmic_bus_access_notifier(struct notifier_block *nb)
+{
+   int ret;
+
+   /* Wait for the bus to go inactive before unregistering */
+   mutex_lock(_mbi_punit_mutex);
+   ret = blocking_notifier_chain_unregister(
+   _mbi_pmic_bus_access_notifier, nb);
+   mutex_unlock(_mbi_punit_mutex);
+
+   return ret;
+}
+EXPORT_SYMBOL(iosf_mbi_unregister_pmic_bus_access_notifier);
+
+int iosf_mbi_call_pmic_bus_access_notifier_chain(unsigned long val, void *v)

[PATCH v3 04/12] i2c: designware-baytrail: Pass dw_i2c_dev into helper functions

2017-02-10 Thread Hans de Goede
Pass dw_i2c_dev into the helper functions, this is a preparation patch
for the punit semaphore fixes done in the other patches in this set.

Signed-off-by: Hans de Goede 
Reviewed-by: Takashi Iwai 
Tested-by: Takashi Iwai 
Reviewed-by: Andy Shevchenko 
Acked-by: Jarkko Nikula 
Acked-by: Wolfram Sang 
---
 drivers/i2c/busses/i2c-designware-baytrail.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-baytrail.c 
b/drivers/i2c/busses/i2c-designware-baytrail.c
index 1590ad0..a3f581c 100644
--- a/drivers/i2c/busses/i2c-designware-baytrail.c
+++ b/drivers/i2c/busses/i2c-designware-baytrail.c
@@ -28,14 +28,14 @@
 
 static unsigned long acquired;
 
-static int get_sem(struct device *dev, u32 *sem)
+static int get_sem(struct dw_i2c_dev *dev, u32 *sem)
 {
u32 data;
int ret;
 
ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE, 
);
if (ret) {
-   dev_err(dev, "iosf failed to read punit semaphore\n");
+   dev_err(dev->dev, "iosf failed to read punit semaphore\n");
return ret;
}
 
@@ -44,18 +44,18 @@ static int get_sem(struct device *dev, u32 *sem)
return 0;
 }
 
-static void reset_semaphore(struct device *dev)
+static void reset_semaphore(struct dw_i2c_dev *dev)
 {
u32 data;
 
if (iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE, 
)) {
-   dev_err(dev, "iosf failed to reset punit semaphore during 
read\n");
+   dev_err(dev->dev, "iosf failed to reset punit semaphore during 
read\n");
return;
}
 
data &= ~PUNIT_SEMAPHORE_BIT;
if (iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, PUNIT_SEMAPHORE, 
data))
-   dev_err(dev, "iosf failed to reset punit semaphore during 
write\n");
+   dev_err(dev->dev, "iosf failed to reset punit semaphore during 
write\n");
 }
 
 static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
@@ -83,7 +83,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
start = jiffies;
end = start + msecs_to_jiffies(SEMAPHORE_TIMEOUT);
do {
-   ret = get_sem(dev->dev, );
+   ret = get_sem(dev, );
if (!ret && sem) {
acquired = jiffies;
dev_dbg(dev->dev, "punit semaphore acquired after 
%ums\n",
@@ -95,7 +95,7 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
} while (time_before(jiffies, end));
 
dev_err(dev->dev, "punit semaphore timed out, resetting\n");
-   reset_semaphore(dev->dev);
+   reset_semaphore(dev);
 
ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE, 
);
if (ret)
@@ -116,7 +116,7 @@ static void baytrail_i2c_release(struct dw_i2c_dev *dev)
if (!dev->acquire_lock)
return;
 
-   reset_semaphore(dev->dev);
+   reset_semaphore(dev);
dev_dbg(dev->dev, "punit semaphore held for %ums\n",
jiffies_to_msecs(jiffies - acquired));
 }
-- 
2.9.3

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


[PATCH v3 01/12] x86/platform/intel/iosf_mbi: Add a mutex for P-Unit access

2017-02-10 Thread Hans de Goede
One some systems the P-Unit accesses the PMIC to change various voltages
through the same bus as other kernel drivers use for e.g. battery
monitoring.

If a driver sends requests to the P-Unit which require the P-Unit to access
the PMIC bus while another driver is also accessing the PMIC bus various
bad things happen.

This commit adds a mutex to protect the P-Unit against simultaneous
accesses and 2 functions to lock / unlock this mutex.

Note on these systems the i2c-bus driver will request a sempahore from the
P-Unit for exclusive access to the PMIC bus when i2c drivers are accessing
it, but this does not appear to be sufficient, we still need to avoid
making certain P-Unit requests during the access window to avoid problems.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=155241
Signed-off-by: Hans de Goede 
Tested-by: tagorereddy 
Reviewed-by: Andy Shevchenko 
---
Changes in v2:
-Rename iosf_mbi_punit_lock/_unlock to _acquire/_release rename
-Spelling: P-Unit, PMIC
---
 arch/x86/include/asm/iosf_mbi.h| 31 +++
 arch/x86/platform/intel/iosf_mbi.c | 13 +
 2 files changed, 44 insertions(+)

diff --git a/arch/x86/include/asm/iosf_mbi.h b/arch/x86/include/asm/iosf_mbi.h
index b41ee16..f6119d0 100644
--- a/arch/x86/include/asm/iosf_mbi.h
+++ b/arch/x86/include/asm/iosf_mbi.h
@@ -88,6 +88,33 @@ int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr);
  */
 int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask);
 
+/**
+ * iosf_mbi_punit_acquire() - Acquire access to the P-Unit
+ *
+ * One some systems the P-Unit accesses the PMIC to change various voltages
+ * through the same bus as other kernel drivers use for e.g. battery 
monitoring.
+ *
+ * If a driver sends requests to the P-Unit which require the P-Unit to access
+ * the PMIC bus while another driver is also accessing the PMIC bus various bad
+ * things happen.
+ *
+ * To avoid these problems this function must be called before accessing the
+ * P-Unit or the PMIC, be it through iosf_mbi* functions or through other 
means.
+ *
+ * Note on these systems the i2c-bus driver will request a sempahore from the
+ * P-Unit for exclusive access to the PMIC bus when i2c drivers are accessing
+ * it, but this does not appear to be sufficient, we still need to avoid making
+ * certain P-Unit requests during the access window to avoid problems.
+ *
+ * This function locks a mutex, as such it may sleep.
+ */
+void iosf_mbi_punit_acquire(void);
+
+/**
+ * iosf_mbi_punit_release() - Release access to the P-Unit
+ */
+void iosf_mbi_punit_release(void);
+
 #else /* CONFIG_IOSF_MBI is not enabled */
 static inline
 bool iosf_mbi_available(void)
@@ -115,6 +142,10 @@ int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 
mdr, u32 mask)
WARN(1, "IOSF_MBI driver not available");
return -EPERM;
 }
+
+static inline void iosf_mbi_punit_acquire(void) {}
+static inline void iosf_mbi_punit_release(void) {}
+
 #endif /* CONFIG_IOSF_MBI */
 
 #endif /* IOSF_MBI_SYMS_H */
diff --git a/arch/x86/platform/intel/iosf_mbi.c 
b/arch/x86/platform/intel/iosf_mbi.c
index edf2c54..ed24fa9f 100644
--- a/arch/x86/platform/intel/iosf_mbi.c
+++ b/arch/x86/platform/intel/iosf_mbi.c
@@ -34,6 +34,7 @@
 
 static struct pci_dev *mbi_pdev;
 static DEFINE_SPINLOCK(iosf_mbi_lock);
+static DEFINE_MUTEX(iosf_mbi_punit_mutex);
 
 static inline u32 iosf_mbi_form_mcr(u8 op, u8 port, u8 offset)
 {
@@ -190,6 +191,18 @@ bool iosf_mbi_available(void)
 }
 EXPORT_SYMBOL(iosf_mbi_available);
 
+void iosf_mbi_punit_acquire(void)
+{
+   mutex_lock(_mbi_punit_mutex);
+}
+EXPORT_SYMBOL(iosf_mbi_punit_acquire);
+
+void iosf_mbi_punit_release(void)
+{
+   mutex_unlock(_mbi_punit_mutex);
+}
+EXPORT_SYMBOL(iosf_mbi_punit_release);
+
 #ifdef CONFIG_IOSF_MBI_DEBUG
 static u32 dbg_mdr;
 static u32 dbg_mcr;
-- 
2.9.3

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


[PATCH v3 00/12] coordinate cht i2c-pmic and i915-punit accesses

2017-02-10 Thread Hans de Goede
Hi All,

Here is v3 of my cht i2c-pmic and i915-punit access coordination
patchset. New in this version is the dropping of the punit_acquire /
_release calls around punit accesses in the i915 driver, these seem
to be unnecessary in this case acquiring the pmic-bus semaphore in
the punit seems to be enough. We do definitely need the forcewake stuff
done by "drm/i915: Listen for PMIC bus access notifications", without
that cht devices which have a pmic which makes the kernel share the bus
with the punit see forcewake timeouts followed by a lockup.

Also new in this version is some renames + extra comments in patch 11 and 12
as reqested by Ville.

This patch-set includes 6 i2c patches, these patches are ready for merging,
they have Wolfram's (the i2c maintainer's) ack. The problem is the 6th i2c
patch which fixes the punit semaphore support in i2c-designware-baytrail.c,
which fixes the i2c-designware not binding to the pmic (axp288) i2c bus.
But with this fixed we actually start triggering the coordination problems
the rest of this patch-set addresses.

So the plan (again with Wolfram's ack) is for all these patches
including the i2c-designware ones to go upstream through the drm-intel
tree, to avoid an intermediate state were things don't work.

As for the how and why of this patchset, let me copy and paste the
cover letter of v1 of this set which is still mostly valid:

### being v1 cover letter ###

This series fixes an issue where the following messages are shown in dmesg:
[drm:fw_domains_get [i915]] *ERROR* render: timed out waiting for forcewake ack 
request.
[drm:fw_domains_get [i915]] *MEDIA* render: timed out waiting for forcewake ack 
request.
i2c_designware 808622C1:06: punit semaphore timed out, resetting
i2c_designware 808622C1:06: PUNIT SEM: 2
i2c_designware 808622C1:06: couldn't acquire bus ownership

Usually followed by a gfx or system freeze, this is happening both on my
cherrytrail tablet as well as being seen by an user commenting on:
https://bugzilla.kernel.org/show_bug.cgi?id=155241

This problem is triggered by my patch series to fix the punit i2c bus
semaphore code in drivers/i2c/busses/designware-baytrail.c .

Which actually allows i2c access to pmic-s wich need bus-access arbritration
for the first time on cherrytrail, combined with patches from me to actually
make the axp288_fuel_gauge driver load, which leads to regular pmic i2c
accesses (when userspace checks the battery level).

The fix / workaround


Testing has shown that just taking the punit i2c bus semaphore on
i2c accesses to a shared pmic i2c bus is not enough to avoid problem,
e.g. besides this series to coordinate i915 access, we also need:
https://patchwork.ozlabs.org/patch/710070/

This series introduces 2 mechanisms to coordinate direct pmic accesses
vs punit requests which lead to pmic accesses. The first mechanism is
a simple mutex, which works well for the direct punit accesses the i915
code does. However testing has shown this is not enough, we also need
to avoid doing a forcewake when a driver is directly accessing the pmic
i2c bus, otherwise we get the timeout errors quoted above, the fact
that after the forcewake errors the designware-baytrail.c code also
fails to acquire the lock, suggests that doing forcewakes during the
access window causes the i2c bus to get stuck (or the punit to get
confused).

The deal with the forcewake issue a notifier is introduced which allows
drivers to get notified before any pmic i2c transfer begins (and after
it ends). This is used in the i915 driver to do a
forcewake_get(FORCEWAKE_ALL) before the access begins avoiding needing to
it while the access is in progress.

Testing has shown that this avoids the problem for both me and the user,
where as before it could be reproduced at will.

The implementation of the fix
=

I've decided to put the mutex and the notifier in the iosf_mbi code,
as that is somewhat of a common middle ground between the i915 driver and
the designware-baytrail.c code, with the latter already depending on the
iosf_mbi code. I'm open for moving them if someone has a suggestion for a
better place to put them.

If iosf_mbi support is not enabled then all the functions used will become
static inline NOPs and nothing changes on the i915 side.

If the code is enabled and runs on a system which does not need pmic i2c
bus arbritration, then the mutex lock / unlock calls added to the i915 code
will still be made, but there won't be any contention, so other then the
overhead of the lock / unlock there will not be any delays. These calls are
not made in any hot paths.

The biggest downside IMHO is that taking FORCEWAKE_ALL before each bus
access will cause extra GPU wakeups, and thus powerdrain. I plan to make
the impact of this minimal by modifying any drivers (axp288 code, with
which I'm quite familiar by now) to limit their i2c accesses to a bare
minimum. Specifically I plan to e.g. cache the battery level and wait
at 

Re: [PATCH v2 13/13] drm/i915: Acquire P-Unit access when modifying P-Unit settings

2017-02-10 Thread Hans de Goede

Hi,

On 30-01-17 16:11, Ville Syrjälä wrote:

On Mon, Jan 30, 2017 at 04:02:19PM +0100, Hans de Goede wrote:

Hi,

On 30-01-17 14:10, Ville Syrjälä wrote:

On Sat, Jan 28, 2017 at 06:18:45PM +0100, Hans de Goede wrote:

Hi,

On 01/28/2017 05:25 PM, Hans de Goede wrote:

Hi,

On 01/27/2017 02:51 PM, Ville Syrjälä wrote:

On Mon, Jan 23, 2017 at 10:09:58PM +0100, Hans de Goede wrote:

Make sure the P-Unit or the PMIC i2c bus is not in use when we send a
request to the P-Unit by calling iosf_mbi_punit_acquire() / _release()
around P-Unit write accesses.


Can't we just stuff the calls into the actual punit write function
rather than sprinkling them all over the place?


punit access is acquired across sections like this:

iosf_mbi_punit_acquire();

val = vlv_punit_read(dev_priv, PUNIT_REG_DSPFREQ);
val &= ~DSPFREQGUAR_MASK;
val |= (cmd << DSPFREQGUAR_SHIFT);
vlv_punit_write(dev_priv, PUNIT_REG_DSPFREQ, val);
if (wait_for((vlv_punit_read(dev_priv, PUNIT_REG_DSPFREQ) &
  DSPFREQSTAT_MASK) == (cmd << DSPFREQSTAT_SHIFT),
 50)) {
DRM_ERROR("timed out waiting for CDclk change\n");
}
iosf_mbi_punit_release();

Where we want to wait for the requested change to have taken
effect before releasing the punit.


Hmm. That's somewhat unfortunate. It also highlights a problem with the
patch wrt. RPS. We don't wait for the GPU to actually change frequencies
in set_rps() because that would slow things down too much. So I have to
wonder how much luck is needed to make this workaround really effective.


So the history of this patch-set is that I wrote this patch before
writing the patch to get FORCEWAKE_ALL before the pmic bus becomes
active (patch 12/13). Since a lot of testing was done with this
patch included in the patch-set and since it seemed a good idea
regardless (given my experience with accessing the punit vs
pmic bus accesses) I decided to leave it in.

Possibly just the patch to get FORCEWAKE_ALL is enough, that one
actually fixed things for me. That is also why I made this the
last patch in the set. I asked tagorereddy to test his system
without this patch, but he did not get around to that.

After all we do tell the punit to not touch the bus by acquiring
the pmic bus semaphore from i2c-desigware-baytrail.c, so maybe
for RPS freq changes it honors that and properly waits. Maybe it
honors that for all punit requests i915 does and the only real
problem is the forcewake stuff ?

I can try to drop this patch from my queue and run without it
for a while and see if things don't regress. And also ask
tagorereddy again to test his system that way.

Does that (dropping this patch for now) sound like a good idea?


More test results couldn't hurt at least.


Ok, I've done a whole bunch of suspend + resume cycles on my cht
tablet with this patch dropped and things still work fine
(where as without the first 12 patches of this patch-set that
 was a guarenteed way to get a forcewake timeout followed by
 a lockup).

So it indeed seems this test is not necessary. I'll send a v3
with that patch dropped, as well as your comments for
patches 11 and 12 being addressed.

Regards,

Hans

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


[PULL] sti-drm-next-2017-02-10

2017-02-10 Thread Vincent Abriou
Hi Dave,

Here is an update of the STI drm driver containing;
- remove deprecated stih416 chip functionnalities
- fix issues met around gdp panes
- fix STI driver unbind procedure
- DVI/HDMI mode is automatically detected
- allow fps statisitics resetting

Regard,
Vincent


The following changes since commit 13f62f54d174d3417c3caaafedf5e22a0a03e442:

  Merge branch 'drm-next-4.11' of git://people.freedesktop.org/~agd5f/linux 
into drm-next (2017-02-10 10:13:30 +1000)

are available in the git repository at:

  https://github.com/vinceab/linux.git tags/sti-drm-next-2017-02-10

for you to fetch changes up to c462c2f5f5ee5ed77a790c361e6aae807ef923ce:

  drm/sti: debug fps reset (2017-02-10 09:34:39 +0100)


- remove deprecated stih416 chip functionnalities
- fix issues met around gdp panes
- fix STI driver unbind procedure
- DVI/HDMI mode is automatically detected
- allow fps statisitics resetting


Fabien DESSENNE (3):
  drm/sti: use atomic_helper for commit
  drm/sti: Fix up crtc_state->event handling
  drm/sti: do not check hw scaling if mode is not set

Vincent Abriou (8):
  drm/sti: remove deprecated sink_term config
  drm/sti: remove deprecated legacy vtg slave
  drm/sti: enable gdp pixel clock in atomic_update
  drm/sti: do not set gdp pixel clock rate if mode is not set
  drm/sti: do not post GDP command if no update
  drm/sti: unbind all components while driver cleanup
  drm/sti: hdmi: automatically check DVI/HDMI mode
  drm/sti: debug fps reset

 drivers/gpu/drm/sti/sti_crtc.c  | 46 +++---
 drivers/gpu/drm/sti/sti_drv.c   | 87 +
 drivers/gpu/drm/sti/sti_drv.h   |  6 ---
 drivers/gpu/drm/sti/sti_gdp.c   | 85 ++--
 drivers/gpu/drm/sti/sti_hdmi.c  | 38 +++---
 drivers/gpu/drm/sti/sti_hdmi.h  | 17 +---
 drivers/gpu/drm/sti/sti_hqvdp.c |  6 +--
 drivers/gpu/drm/sti/sti_mixer.h |  2 -
 drivers/gpu/drm/sti/sti_vtg.c   | 58 +++
 9 files changed, 95 insertions(+), 250 deletions(-)
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 98869] Electronic Super Joy graphic artefacts (regression,bisected)

2017-02-10 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=98869

--- Comment #20 from cosiek...@o2.pl ---
Yes of course.
I have tested this patch and it resolved the problem :)
Thank you very much!!!

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel