[Bug 105680] [CI] igt@kms_frontbuffer_tracking@* - fail - FBC disabled: mode too large for compression

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105680

Marta Löfstedt  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|REOPENED|RESOLVED

--- Comment #12 from Marta Löfstedt  ---
(In reply to Jose Roberto de Souza from comment #11)
> But this tests ran with my patch merged into IGT? I don`t think that it
> happened.

I'll set the bug to resolved fix again so it can be checked on next drmtip run

-- 
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] ALSA: hda - Silence PM ops build warning

2018-04-12 Thread Lukas Wunner
On Thu, Mar 29, 2018 at 01:46:26PM +0200, Lukas Wunner wrote:
> sound/pci/hda/hda_intel.c:1024:12: warning: 'azx_resume' defined but not used 
> [-Wunused-function]
>  static int azx_resume(struct device *dev)
> ^~
> sound/pci/hda/hda_intel.c:989:12: warning: 'azx_suspend' defined but not used 
> [-Wunused-function]
>  static int azx_suspend(struct device *dev)
> ^~~

Arnd, Takashi, just a quick FYI that the fix for the above-quoted
warnings has landed in Linus' tree half an hour ago.  Thanks for
your patience.

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


[git pull] drm fixes for 4.17-rc1

2018-04-12 Thread Dave Airlie
Hi Linus,

Decloaking in the middle of holidays (still off all next week), just
to vacuum up any outstanding fixes for rc1.

One omap, and one alsa pm fix (we merged the breaking patch via drm tree).

Otherwise it's two bunches of amdgpu fixes, removing an unneeded file,
some DC fixes, HDMI audio
regression fix, and some vega12 fixes.

I didn't get any i915 fixes so I'm assuming they can wait until -rc2
if they have any, though I probably won't be
back until rc2 releases.

Thanks,
Dave.

The following changes since commit 694f54f680f7fd8e9561928fbfc537d9afbc3d79:

  Merge branch 'drm-misc-next-fixes' of
git://anongit.freedesktop.org/drm/drm-misc into drm-next (2018-03-29
09:25:13 +1000)

are available in the Git repository at:

  git://people.freedesktop.org/~airlied/linux tags/drm-fixes-for-v4.17-rc1

for you to fetch changes up to a10beabba213924d876f2d10ca9351aeab93f58a:

  Merge branch 'drm-next-4.17' of
git://people.freedesktop.org/~agd5f/linux into drm-next (2018-04-13
09:25:21 +1000)


amdgpu, omap and snd regression fix


Alex Deucher (3):
  drm/amdgpu/sdma: fix mask in emit_pipeline_sync
  drm/amdgpu/si: implement get/set pcie_lanes asic callback
  drm/amdgpu: Fix PCIe lane width calculation

Andrey Grodzovsky (2):
  drm/amdgpu: Fix KIQ hang on bare metal for device unbind/bind back v2.
  drm/amdgpu: Add support for SRBM selection v3

Charlene Liu (1):
  drm/amd/display: HDMI has no sound after Panel power off/on

Chunming Zhou (2):
  drm/amdgpu: fix typo of domain fallback
  Revert "drm/amdgpu: Don't change preferred domian when fallback GTT v5"

Dan Carpenter (1):
  drm/amd/pp: silence a static checker warning

Dave Airlie (4):
  Merge tag 'drm-misc-next-fixes-2018-04-04' of
git://anongit.freedesktop.org/drm/drm-misc into drm-next
  Merge branch 'drm-next-4.17' of
git://people.freedesktop.org/~agd5f/linux into drm-next
  Merge tag 'drm-misc-next-fixes-2018-04-11' of
git://anongit.freedesktop.org/drm/drm-misc into drm-next
  Merge branch 'drm-next-4.17' of
git://people.freedesktop.org/~agd5f/linux into drm-next

Eric Huang (1):
  drm/amd/powerply: fix power reading on Fiji

Evan Quan (2):
  drm/amdgpu: drop compute ring timeout setting for non-sriov only (v2)
  drm/amdgpu: add MP1 and THM hw ip base reg offset

Harry Wentland (3):
  drm/amd/display: Only register backlight device if embedded
panel connected
  Revert "drm/amd/display: fix dereferencing possible ERR_PTR()"
  Revert "drm/amd/display: disable CRTCs with NULL FB on their
primary plane (V2)"

Huang Rui (1):
  drm/amdgpu: fix null pointer panic with direct fw loading on gpu reset

Kenneth Feng (1):
  drm/amd/powerplay: Enable ACG SS feature

Leo (Sunpeng) Li (1):
  drm/amd/display: Fix regamma not affecting full-intensity color values

Lukas Wunner (1):
  ALSA: hda - Silence PM ops build warning

Nico Sneck (1):
  drm/radeon: add PX quirk for Asus K73TK

Paul Parsons (1):
  drm/radeon: Fix PCIe lane width calculation

Rex Zhu (2):
  drm/amd/pp: Remove Dead functions on Vega12
  drm/amd/pp: Clean header file in vega12_smumgr.c

Roman Li (2):
  drm/amd/display: fix brightness level after resume from suspend
  drm/amd/display: Fix FBC text console corruption

Takashi Iwai (1):
  drm/amdgpu: Fix memory leaks at amdgpu_init() error path

Tomi Valkeinen (1):
  drm/omap: fix crash if there's no video PLL

 drivers/gpu/drm/amd/amdgpu/amdgpu.h|4 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c|  117 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c|9 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c  |   12 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c|   16 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |   18 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c|3 +
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c  |2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c  |7 +
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c  |7 +
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  |7 +
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  |   61 +-
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c |2 +-
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c |2 +-
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c |2 +-
 drivers/gpu/drm/amd/amdgpu/si.c|   67 +
 drivers/gpu/drm/amd/amdgpu/si_dpm.c|4 +-
 drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c   |3 +-
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |   89 +-
 drivers/gpu/drm/amd/display/dc/core/dc_link.c  |   13 +
 drivers/gpu/drm/amd/display/dc/dc_link.h   |2 +
 .../drm/amd/display/dc/dce/dce_stream_encoder.c|2 +
 .../drm/amd/display/dc/dce110/dce110_compressor.c  |   67 +-
 

[Bug 105018] Kernel panic when waking up after screen goes blank.

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105018

--- Comment #30 from L.S.S.  ---
EDIT 2: I couldn't reproduce the issue on 4.17 this time even after 2 wakeups.
However, the issue I encountered was similar (system apparently froze when
trying to wake up the screen). 

After looking into it, I found that along with the errors that showed up like
that in Comment 16 (which did not crash the system), there was an additional
"kernel BUG" related to dm_update_crtcs_state which was called by
amdgpu_dm_atomic_check, but the log appeared to have been cut (the log entries
between the two errors were apparently unrelated to the error so I did not
include them, and the new error began with a "--[ cut here ]--"). This
additional error (not 100% reproducible) might be what actually crashed the
system that time.

-- 
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 102638] Incorrect rendering in OpenGL 4 (Unigine Superposition + others)

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102638

Timothy Arceri  changed:

   What|Removed |Added

 Status|NEW |NEEDINFO

--- Comment #4 from Timothy Arceri  ---
Unigine Superposition works fine for me. Do you still have this problem with
more recent drivers? 17.1 has been unsupported for a while 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 104391] DC R9 285 HDMI audio regression since drm/amd/display: try to find matching audio inst for enc inst first

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=104391

--- Comment #5 from Andy Furniss  ---
Created attachment 138816
  --> https://bugs.freedesktop.org/attachment.cgi?id=138816=edit
dmesg with hdmi warnings

Hmm, maybe something else is going wrong.

I am getting hdmi warnings in dmesg (attached) when enabling the TV - I haven't
seen these before when testing this issue.

-- 
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 hwc v2 00/18] Add scene flattening support

2018-04-12 Thread John Stultz
On Wed, Apr 11, 2018 at 8:22 AM, Alexandru Gheorghe
 wrote:
> Flattening a scene in order to reduce memory consumption it's an idea
> which had been floating around on irc and mailing list several times,
> this patchset adds support for flattening a scene using a writeback
> connector, the latest version of the kernel patches could be found
> here [1].
>
> v1 for this patch series could be found here [2].
>
> Changes since v1:
>   - Add support to use either the same crtc or a dedicated one, this
> had been discussed on irc here [3].
>   - Add support for parsing more than one drm node, this is triggered
> by the fact the on Mali DP each device has it's own driver, so
> it's needed in order to use a dedicate crtc for flattening.
>   - Parse encoder possible_clones to detect if writeback could
> function simultaneously with the display connector.
>   - Fixes for some bugs discovered while working on this.
>   - Split changes in multiple patches.

Just for testing w/ other devices currently using drm_hwcomposer, do
you happen to have the patchset in a public git tree somewhere?

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


Re: [PATCH] drm/vc4: Fix leak of the file_priv that stored the perfmon.

2018-04-12 Thread Eric Anholt
Boris Brezillon  writes:

> On Mon,  9 Apr 2018 13:58:13 -0700
> Eric Anholt  wrote:
>
>> Signed-off-by: Eric Anholt 
>> Fixes: 65101d8c9108 ("drm/vc4: Expose performance counters to userspace")
>
> Reviewed-by: Boris Brezillon 

Applied to drm-misc-next-fixes.  Thanks!


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


[Bug 105414] R9 285 agd5f 4.17-wip DC flip_done timed out

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105414

Andy Furniss  changed:

   What|Removed |Added

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

--- Comment #1 from Andy Furniss  ---
fixed in agd5f drm-next-4.17 I guess by 

 Revert "drm/amd/display: disable CRTCs with NULL FB on their primary plane
(V2)"

-- 
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 104391] DC R9 285 HDMI audio regression since drm/amd/display: try to find matching audio inst for enc inst first

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=104391

--- Comment #4 from Andy Furniss  ---
What is the fix?

I see drm/amd/display: HDMI has no sound after Panel power off/on

just went in agd5f drm-next-4.17

But this does not fix this issue.

-- 
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: RFC for a render API to support adaptive sync and VRR

2018-04-12 Thread Stéphane Marchesin
On Tue, Apr 10, 2018 at 12:37 AM, Michel Dänzer  wrote:
> On 2018-04-10 08:45 AM, Christian König wrote:
>> Am 09.04.2018 um 23:45 schrieb Manasi Navare:
>>> Thanks for initiating the discussion. Find my comments below:
>>> On Mon, Apr 09, 2018 at 04:00:21PM -0400, Harry Wentland wrote:
 On 2018-04-09 03:56 PM, Harry Wentland wrote:
>
> === A DRM render API to support variable refresh rates ===
>
> In order to benefit from adaptive sync and VRR userland needs a way
> to let us know whether to vary frame timings or to target a
> different frame time. These can be provided as atomic properties on
> a CRTC:
>   * boolvariable_refresh_compatible
>   * inttarget_frame_duration_ns (nanosecond frame duration)
>
> This gives us the following cases:
>
> variable_refresh_compatible = 0, target_frame_duration_ns = 0
>   * drive monitor at timing's normal refresh rate
>
> variable_refresh_compatible = 1, target_frame_duration_ns = 0
>   * send new frame to monitor as soon as it's available, if within
> min/max of monitor's reported capabilities
>
> variable_refresh_compatible = 0/1, target_frame_duration_ns = > 0
>   * send new frame to monitor with the specified
> target_frame_duration_ns
>
> When a target_frame_duration_ns or variable_refresh_compatible
> cannot be supported the atomic check will reject the commit.
>
>>> What I would like is two sets of properties on a CRTC or preferably on
>>> a connector:
>>>
>>> KMD properties that UMD can query:
>>> * vrr_capable -  This will be an immutable property for exposing
>>> hardware's capability of supporting VRR. This will be set by the
>>> kernel after
>>> reading the EDID mode information and monitor range capabilities.
>>> * vrr_vrefresh_max, vrr_vrefresh_min - To expose the min and max
>>> refresh rates supported.
>>> These properties are optional and will be created and attached to the
>>> DP/eDP connector when the connector
>>> is getting intialized.
>>
>> Mhm, aren't those properties actually per mode and not per CRTC/connector?
>>
>>> Properties that you mentioned above that the UMD can set before kernel
>>> can enable VRR functionality
>>> *bool vrr_enable or vrr_compatible
>>> target_frame_duration_ns
>>
>> Yeah, that certainly makes sense. But target_frame_duration_ns is a bad
>> name/semantics.
>>
>> We should use an absolute timestamp where the frame should be presented,
>> otherwise you could run into a bunch of trouble with IOCTL restarts or
>> missed blanks.
>
> Also, a fixed target frame duration isn't suitable even for video
> playback, due to drift between the video and audio clocks.
>
> Time-based presentation seems to be the right approach for preventing
> micro-stutter in games as well, Croteam developers have been researching
> this.

Another case that you can handle with time-based presentation but not
with refresh-based API is the use of per-scanline flips in conjunction
with damage rects. For example if you know that the damage rect covers
a certain Y range, you can flip when you're outside that range if the
time that you were given allows it. That's even independent from VRR
displays.

Stéphane


>
>
> --
> Earthling Michel Dänzer   |   http://www.amd.com
> Libre software enthusiast | Mesa and X developer
> ___
> 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 106006] Kernel 4.16.0+ switch amdgpu.dc=1 causes screen brightness set to 1 to be dimmed by default

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106006

--- Comment #10 from Harry Wentland  ---
Created attachment 138814
  --> https://bugs.freedesktop.org/attachment.cgi?id=138814=edit
[PATCH] drm/amd/display: Don't program bypass on linear regamma LUT

Does this fix things for you?

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


[pull] radeon and amdgpu drm-next-4.17

2018-04-12 Thread Alex Deucher
Hi Dave,

More fixes for 4.17 and stable:
- Add a PX quirk for radeon
- Fix flickering and stability issues with DC on some platforms
- Fix HDMI audio regression
- Few other misc DC and base driver fixes

The following changes since commit 871e899db19da3dbd17a5d263b555dc5b7d8fed5:

  Merge branch 'drm-next-4.17' of git://people.freedesktop.org/~agd5f/linux 
into drm-next (2018-04-11 08:35:41 +1000)

are available in the git repository at:

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

for you to fetch changes up to 1cb19e8267a57c5174da09e0d52d1477baceccca:

  Revert "drm/amd/display: disable CRTCs with NULL FB on their primary plane 
(V2)" (2018-04-12 14:19:43 -0500)


Charlene Liu (1):
  drm/amd/display: HDMI has no sound after Panel power off/on

Evan Quan (1):
  drm/amdgpu: add MP1 and THM hw ip base reg offset

Harry Wentland (3):
  drm/amd/display: Only register backlight device if embedded panel 
connected
  Revert "drm/amd/display: fix dereferencing possible ERR_PTR()"
  Revert "drm/amd/display: disable CRTCs with NULL FB on their primary 
plane (V2)"

Huang Rui (1):
  drm/amdgpu: fix null pointer panic with direct fw loading on gpu reset

Leo (Sunpeng) Li (1):
  drm/amd/display: Fix regamma not affecting full-intensity color values

Nico Sneck (1):
  drm/radeon: add PX quirk for Asus K73TK

Roman Li (2):
  drm/amd/display: fix brightness level after resume from suspend
  drm/amd/display: Fix FBC text console corruption

 drivers/gpu/drm/amd/amdgpu/amdgpu.h|  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c|  3 +
 drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c   |  3 +-
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 89 --
 drivers/gpu/drm/amd/display/dc/core/dc_link.c  | 13 
 drivers/gpu/drm/amd/display/dc/dc_link.h   |  2 +
 .../drm/amd/display/dc/dce/dce_stream_encoder.c|  2 +
 .../drm/amd/display/dc/dce110/dce110_compressor.c  | 67 
 .../amd/display/dc/dce110/dce110_hw_sequencer.c| 13 +++-
 drivers/gpu/drm/radeon/radeon_device.c |  4 +
 10 files changed, 124 insertions(+), 74 deletions(-)
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/2] drm/amdgpu: Allow dma_map_sg() coalescing

2018-04-12 Thread Christian König

Am 12.04.2018 um 19:53 schrieb Robin Murphy:

On 11/04/18 19:28, Christian König wrote:

Am 11.04.2018 um 19:11 schrieb Robin Murphy:

Now that drm_prime_sg_to_page_addr_arrays() understands the case where
dma_map_sg() has coalesced segments and returns 0 < count < nents, we
can relax the check to only consider genuine failure.


That pattern is repeated in pretty much all drivers using TTM.


AFAICS from a look through drivers/gpu/ only 3 drivers consider the 
actual value of what dma_map_sg() returns - others only handle the 
failure case of 0, and some don't check it at all - and of those it's 
only amdgpu and radeon barfing on it being different from nents 
(vmwgfx appears to just stash it to use slightly incorrectly later).


So you would need to fix all of them, but as I said I don't think 
that this approach is a good idea.


We essentially wanted to get rid of the dma_address array in the mid 
term and that change goes into the exactly opposite direction.


But this patch bears no intention of making any fundamental change to 
the existing behaviour of this particular driver, it simply permits 
said behaviour to work at all on more systems than it currently does. 
I would consider that entirely orthogonal to future TTM-wide 
development :/


That's a really good point. Please try to fix radeon as well and maybe 
ping the vmwgfx maintainers.


With that in place I'm perfectly ok with going ahead with that approach.

Christian.



Robin.



Regards,
Christian.



Signed-off-by: Robin Murphy 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

index 205da3ff9cd0..f81e96a4242f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -813,7 +813,7 @@ static int amdgpu_ttm_tt_pin_userptr(struct 
ttm_tt *ttm)

  r = -ENOMEM;
  nents = dma_map_sg(adev->dev, ttm->sg->sgl, ttm->sg->nents, 
direction);

-    if (nents != ttm->sg->nents)
+    if (nents == 0)
  goto release_sg;
  drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages,




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


[Bug 105996] [DC][CIK] Bonaire mobile - No displays being turned on

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105996

--- Comment #3 from Harry Wentland  ---
Created attachment 138813
  --> https://bugs.freedesktop.org/attachment.cgi?id=138813=edit
[PATCH] drm/amd/display: Support LVDS panels

Can you see if this fixes things or creates different problems at boot? Looks
like we never really supported LVDS with DC but a whole bunch of code is there. 

If it crashes and burns let me know your dmesg again. I'm hoping everything is
in place but it's quite likely that we're missing some more crucial pieces.

-- 
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 106013] [CI] igt@prime_mmap@test_userptr - fail - Failed assertion: __gem_userptr(fd, ptr, size, read_only, flags, handle) == 0

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106013

--- Comment #3 from Chris Wilson  ---
The broadwater with the incoherent snooping, bwr as Tomi called it. No
snooping, no userptr.

-- 
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 106013] [CI] igt@prime_mmap@test_userptr - fail - Failed assertion: __gem_userptr(fd, ptr, size, read_only, flags, handle) == 0

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106013

Martin Peres  changed:

   What|Removed |Added

 Whiteboard||ReadyForDev

-- 
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 106013] [CI] igt@prime_mmap@test_userptr - fail - Failed assertion: __gem_userptr(fd, ptr, size, read_only, flags, handle) == 0

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106013

--- Comment #2 from Martin Peres  ---
(In reply to Chris Wilson from comment #1)
> Boring, but true, there ain't no such device on brw!

Isn't that Broadwater?

-- 
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 106013] [CI] igt@prime_mmap@test_userptr - fail - Failed assertion: __gem_userptr(fd, ptr, size, read_only, flags, handle) == 0

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106013

Chris Wilson  changed:

   What|Removed |Added

   Assignee|intel-gfx-bugs@lists.freede |dri-devel@lists.freedesktop
   |sktop.org   |.org
  Component|DRM/Intel   |IGT
 QA Contact|intel-gfx-bugs@lists.freede |
   |sktop.org   |

--- Comment #1 from Chris Wilson  ---
Boring, but true, there ain't no such device on brw!

-- 
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 2/2] drm/amdgpu: Allow dma_map_sg() coalescing

2018-04-12 Thread Robin Murphy

On 11/04/18 19:28, Christian König wrote:

Am 11.04.2018 um 19:11 schrieb Robin Murphy:

Now that drm_prime_sg_to_page_addr_arrays() understands the case where
dma_map_sg() has coalesced segments and returns 0 < count < nents, we
can relax the check to only consider genuine failure.


That pattern is repeated in pretty much all drivers using TTM.


AFAICS from a look through drivers/gpu/ only 3 drivers consider the 
actual value of what dma_map_sg() returns - others only handle the 
failure case of 0, and some don't check it at all - and of those it's 
only amdgpu and radeon barfing on it being different from nents (vmwgfx 
appears to just stash it to use slightly incorrectly later).


So you would need to fix all of them, but as I said I don't think that 
this approach is a good idea.


We essentially wanted to get rid of the dma_address array in the mid 
term and that change goes into the exactly opposite direction.


But this patch bears no intention of making any fundamental change to 
the existing behaviour of this particular driver, it simply permits said 
behaviour to work at all on more systems than it currently does. I would 
consider that entirely orthogonal to future TTM-wide development :/


Robin.



Regards,
Christian.



Signed-off-by: Robin Murphy 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

index 205da3ff9cd0..f81e96a4242f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -813,7 +813,7 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_tt 
*ttm)

  r = -ENOMEM;
  nents = dma_map_sg(adev->dev, ttm->sg->sgl, ttm->sg->nents, 
direction);

-    if (nents != ttm->sg->nents)
+    if (nents == 0)
  goto release_sg;
  drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages,



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


Re: RFC for a render API to support adaptive sync and VRR

2018-04-12 Thread Harry Wentland
On 2018-04-12 07:39 AM, Nicolai Hähnle wrote:
> On 12.04.2018 01:30, Cyr, Aric wrote:
>>> At least with VDPAU, video players are already explicitly specifying the
>>> target presentation time, so no changes should be required at that
>>> level. Don't know about other video APIs.
>>>
>>> The X11 Present extension protocol is also prepared for specifying the
>>> target presentation time already, the support for it just needs to be
>>> implemented.
>>
>> I'm perfectly OK with presentation time-based *API*.  I get it from a user 
>> mode/app perspective, and that's fine.  We need that feedback and would like 
>> help defining that portions of the stack.
>> However, I think it doesn't make as much sense as a *DDI* because it doesn't 
>> correspond to any hardware real or logical (i.e. no one would implement it 
>> in HW this way) and the industry specs aren't defined that way.
>> You can have libdrm or some other usermode component translate your 
>> presentation time into a frame duration and schedule it.  What's the 
>> advantage of having this in kernel besides the fact we lose the intent of 
>> the application and could prevent features and optimizations.  When it gets 
>> to kernel, I think it is much more elegant for the flip structure to contain 
>> a simple duration that says "hey, show this frame on the screen for this 
>> long".  Then we don't need any clocks or timers just some simple math and 
>> program the hardware.
> 
> There isn't necessarily an inherent advantage to having this translation in 
> the kernel. However, we *must* do this translation in a place that is owned 
> by display experts (i.e., you guys), because only you guys know how to 
> actually do that translation reliably and correctly.
> 
> Since your work is currently limited to the kernel, it makes sense to do it 
> in the kernel.

We're actively trying to change this. I want us (the display team) to 
eventually own anything display related across the stack, or at least closely 
work with the owners of those components.

> 
> If the translation doesn't happen in a place that you feel comfortable 
> working on, we're setting ourselves up for a future where this hypothetical 
> future UMD component will get this wrong, and there'll be a lot of 
> finger-pointing between you guys and whoever writes that UMD, with likely 
> little willingness to actually go into the respective other codebase to fix 
> what's wrong. And that's a pretty sucky future.
> 

If finger-pointing happened I'd like to apologize. Again, this is something we 
actively try to change.

Ultimately I'm looking for a solution that works for everyone and is not owned 
on a SW component basis, but rather expertise basis.

Harry

> Cheers,
> Nicolai
> 
> P.S.: I'm also a little surprised that you seem to be saying that requesting 
> a target present time is basically impossible (at least, that's kind of 
> implied by your statement about mGPUs), and yet there's precedent for such 
> APIs in both Vulkan and VDPAU.
> 
> 
>>
>> In short,
>>   1) We can simplify media players' lives by helping them get really, really 
>> close to their content rate, so they wouldn't need any frame rate conversion.
>>   They'll still need A/V syncing though, and variable refresh cannot 
>> solve this and thus is way out of scope of what we're proposing.
>>
>>   2) For gaming, don't even try to guess a frame duration, the 
>> driver/hardware will do a better job every time, just specify duration=0 and 
>> flip as fast as you can.
>>
>> Regards,
>>    Aric
>>
>> P.S. Thanks for the Croteam link.  Interesting, but basically nullified by 
>> variable refresh rate displays.  You won't have 
>> stuttering/microstuttering/juddering/tearing if your display's refresh rate 
>> matches the render/present rate of the game.  Maybe I should grab The Talos 
>> Principle to see how well it works with FreeSync display :)
>>
>> -- 
>> ARIC CYR
>> PMTS Software Engineer | SW – Display Technologies
>>
>>
>>
>>
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 105619] Kernel DC oops on dce81_create_resource_pool with kernel 4.15

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105619

--- Comment #8 from Michael Lange  ---
Created attachment 138812
  --> https://bugs.freedesktop.org/attachment.cgi?id=138812=edit
kernel-4.16.2  Xorg.0.log

-- 
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 105425] 3D & games produce periodic GPU crashes (Radeon R7 370)

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105425

--- Comment #28 from MirceaKitsune  ---
Just finished the last test from yesterday's recommendations. It appears I
cannot boot with iommu=off as that disables all USB devices, so I can't use a
keyboard and mouse and cannot do anything. I tried the closest working
equivalent I could find, which still froze after 15 minutes from bootup:

cma=0 iommu=soft intel_iommu=off amd_iommu=off

(In reply to iive from comment #27)

Thanks again, I'll be moving to these tests next and posting the results here.

-- 
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 105619] Kernel DC oops on dce81_create_resource_pool with kernel 4.15

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105619

--- Comment #7 from Michael Lange  ---
Created attachment 138811
  --> https://bugs.freedesktop.org/attachment.cgi?id=138811=edit
kernel-4.16.2  dmesg

-- 
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 105619] Kernel DC oops on dce81_create_resource_pool with kernel 4.15

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105619

--- Comment #6 from Michael Lange  ---
Running in the same problem, same error in dmesg.
I have two monitors (AOG AG272FCX), one connected via hdmi to the discrete gpu
(HD 8800) and the second one connected via hdmi to the integrated gpu (KAVERI).
On Windows 10 both working as expected, but in linux only the first monitor
(connected to HD8800) works. 

Mainbord: Gigabyte G1.Sniper A88X-CF
CPU: A10-7850K

linux: 4.16.2

The dmesg and Xorg.0.log are attached

-- 
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 105425] 3D & games produce periodic GPU crashes (Radeon R7 370)

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105425

--- Comment #27 from i...@yahoo.com ---
Loosing recently written files is unfortunately way too common, despite all
filesystem using journaling.
It might help if you call `sync` after writing the file. 

If you have kernel with enabled magic-sysrq, after crash you could hold
"Alt+PrintScrn+" and then press (one by one) "s" to sync, "u" to umount and "b"
to reboot.
All info about it could be found in: 
 linux-source/Documentation/admin-guide/sysrq.rst


Since now hangs happen in a minute after starting gameplay, does that mean that
the "workarounds" that you reported previously doesn't help anymore?


Few ideas to test.
1. Try disabling gallium threads. They are recent feature and it seems they've
been working a lot in your graphs.
`export mesa_glthread=false`
Check also /etc/drirc , ~/.drirc  etc...

2. I'm not quite sure what is the difference between num_shaders_created and
num_compilations, but at the crash there are 2 shaders created and 0 compiled.
This reminds me that you might want to turn off the shader cache. This might
introduce some stuttering during gameplay.
`export MESA_GLSL_CACHE_DISABLE=true`

3. Your framerate is limited to 60fps. It's synced to your monitor vertical
refresh. Try 
`export vblank_mode=1` 
and see if you can control it from the game.
See what happens when you disable it. (Might make things much worse, much
faster.)

4. Generally it is not good idea to test hangs with real game play. It is too
random. It would be ideal if you can record an apitrace that would reproduce
the hang reliably.
Obviously it might not be possible to do that recording on the system that
hangs. (The trace could be lost at reboot, or the commands that cause the hang
might not even be written).
If you have another machine or video card, that works reliably, try recording
gameplay of a single level. Then do the test replaying it. Would it play
entirely, would it hang, would it hang at the same place?

Can you trigger hang with `glxgears` ?

5. You might find something else to test here (e.g. disable DRI3?):
https://www.mesa3d.org/envvars.html.

-- 
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 97909] X-Plane 10 crashes with SIGSEGV on radeonsi

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97909

--- Comment #15 from Joonas Sarajärvi  ---
Still crashes for me on Fedora 27.

kernel 4.15.14
mesa 17.3.6
x-plane 11.11r2

The workaround with MESA_EXTENSION_OVERRIDE=-GL_AMD_pinned_memory reported in
earlier comments is also still useful.

-- 
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 105996] [DC][CIK] Bonaire mobile - No displays being turned on

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105996

Shawn Starr  changed:

   What|Removed |Added

 Attachment #138777|0   |1
is obsolete||

--- Comment #2 from Shawn Starr  ---
Created attachment 138810
  --> https://bugs.freedesktop.org/attachment.cgi?id=138810=edit
Kernel dmesg boot with dc_log and drm.debug=0x4

-- 
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: [RFC v4 00/25] drm: Add generic fbdev emulation

2018-04-12 Thread Noralf Trønnes
I hit a 'Sending rate exceeded' error with this patchset, so it didn't 
go out as it should.

I will resend the patchset when I find out how to avoid this problem.

Noralf.


Den 12.04.2018 15.17, skrev Noralf Trønnes:

This patchset explores the possibility of having generic fbdev emulation
in DRM for drivers that supports dumb buffers which they can export. An
API is added to support in-kernel clients in general.

In this version I was able to reuse the modesetting code from
drm_fb_helper in the client API. This avoids code duplication, carries
over lessons learned and the modesetting code is bisectable. The
downside is that it takes +10 patches to rip drm_fb_helper in two, so
maybe it's not worth it wrt possible breakage and a challenging review.

Does the Intel CI test the fbdev emulation?

Daniel had this concern with the previous version:

 The register/unregister model needs more thought. Allowing both clients
 to register whenever they want to, and drm_device instances to come and
 go is what fbcon has done, and the resulting locking is a horror show.

 I think if we require that all in-kernel drm_clients are registers when
 loading drm.ko (and enabled/disabled only per module options and
 Kconfig), then we can throw out all the locking. That avoids a lot of
 the headaches.

I have solved this by adding a notifier that fires when a new DRM device
is registered (I've removed the new() callback). Currently only
bootsplash uses this. The fbdev client needs to be setup from the driver
since it can't know on device registration if the driver will setup it's
own fbdev emulation later and the vtcon client hooks up to a user
provided device id.

Since fbcon can't handle fb_open failing, the buffer has to be
pre-allocated. Exporting a GEM buffer pins the driver module making it
impossible to unload it.
I have included 2 solutions to the problem:
- sysfs file to remove/close clients: remove_internal_clients
- Change drm_gem_prime_export() so it doesn't pin on client buffers

If a dumb buffer is exported from a kernel thread (worker) context, the
file descriptor isn't closed and I leak a reference so the buffer isn't
freed. Please look at drm_client_buffer_create() in patch
'drm/client: Finish the in-kernel client API'.
This is a blocker that needs a solution.


Noralf.

Changes since version 3:
Client API changes:
- Drop drm_client_register_funcs() which attached clients indirectly.
   Let clients attach directly using drm_client_new{_from_id}(). Clients
   that wants to attach to all devices must be linked into drm.ko and use
   the DRM device notifier. This is done to avoid the lock/race
   register/unregister hell we have with fbcon. (Daniel Vetter)
- drm_client_display_restore() checks if there is a master and if so
   returns -EBUSY. (Daniel Vetter)
- Allocate drm_file up front instead of on-demand. Since fbdev can't do
   on demand buffer allocation because of fbcon, there's no need for this.
- Add sysfs file to remove clients
- Don't pin driver module when exporting gem client buffers
- Dropped page flip support since drm_fb_helper is now used for fbdev
   emulation.

- The bootsplash client now switches over to fbdev on keypress.

Changes since version 2:
- Don't set drm master for in-kernel clients. (Daniel Vetter)
- Add in-kernel client API

Changes since version 1:
- Don't add drm_fb_helper_fb_open() and drm_fb_helper_fb_release() to
   DRM_FB_HELPER_DEFAULT_OPS(). (Fi.CI.STATIC)
   The following uses that macro and sets fb_open/close: udlfb_ops,
   amdgpufb_ops, drm_fb_helper_generic_fbdev_ops, nouveau_fbcon_ops,
   nouveau_fbcon_sw_ops, radeonfb_ops.
   This results in: warning: Initializer entry defined twice
- Support CONFIG_DRM_KMS_HELPER=m (kbuild test robot)
   ERROR:  [drivers/gpu/drm/drm_kms_helper.ko] undefined!
- Drop buggy patch: (Chris Wilson)
   drm/prime: Clear drm_gem_object->dma_buf on release
- Defer buffer creation until fb_open.


David Herrmann (1):
   drm: provide management functions for drm_file

Noralf Trønnes (24):
   drm/file: Don't set master on in-kernel clients
   drm/fb-helper: No need to cache rotation and sw_rotations
   drm/fb-helper: Remove drm_fb_helper_debug_enter/leave()
   drm/fb-helper: dpms_legacy(): Only set on connectors in use
   drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()
   drm: Begin an API for in-kernel clients
   drm/fb-helper: Use struct drm_client_display
   drm/fb-helper: Move modeset commit code to drm_client
   drm/connector: Add
 drm_connector_has_preferred_mode/pick_cmdline_mode()
   drm/connector: Add connector array functions
   drm/i915: Add drm_driver->initial_client_display callback
   drm/fb-helper: Remove struct drm_fb_helper_crtc
   drm/fb-helper: Remove struct drm_fb_helper_connector
   drm/fb-helper: Move modeset config code to drm_client
   drm: Make ioctls available for in-kernel clients
   drm/client: Bail out if there's a DRM master
   drm/client: Make the display modes 

[RFC v4 22/25] drm/fb-helper: Add generic fbdev emulation

2018-04-12 Thread Noralf Trønnes
This adds generic fbdev emulation for drivers that supports
dumb buffers which they can export.

All the driver has to do is call drm_fbdev_generic_setup().

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 255 
 include/drm/drm_fb_helper.h |  20 
 2 files changed, 275 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index b1124c08b1ed..1954de5b13e0 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -30,6 +30,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1995,6 +1996,260 @@ void drm_fb_helper_output_poll_changed(struct 
drm_device *dev)
 }
 EXPORT_SYMBOL(drm_fb_helper_output_poll_changed);
 
+static int drm_fbdev_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
+{
+   struct drm_fb_helper *fb_helper = info->par;
+
+   return dma_buf_mmap(fb_helper->buffer->dma_buf, vma, 0);
+}
+
+/*
+ * fb_ops.fb_destroy is called by the last put_fb_info() call at the end of
+ * unregister_framebuffer() or fb_release().
+ */
+static void drm_fbdev_fb_destroy(struct fb_info *info)
+{
+   struct drm_fb_helper *fb_helper = info->par;
+   struct fb_ops *fbops = NULL;
+
+   DRM_DEBUG("\n");
+
+   if (fb_helper->fbdev->fbdefio)
+   fbops = fb_helper->fbdev->fbops;
+
+   drm_fb_helper_fini(fb_helper);
+   drm_client_framebuffer_delete(fb_helper->buffer);
+   drm_client_free(fb_helper->client);
+   kfree(fb_helper);
+   kfree(fbops);
+}
+
+static struct fb_ops drm_fbdev_fb_ops = {
+   /*
+* No need to set owner, this module is already pinned by the driver.
+* A reference is taken on the driver module in drm_fb_helper_fb_open()
+* to prevent the driver going away with open fd's.
+*/
+   DRM_FB_HELPER_DEFAULT_OPS,
+   .fb_open= drm_fb_helper_fb_open,
+   .fb_release = drm_fb_helper_fb_release,
+   .fb_destroy = drm_fbdev_fb_destroy,
+   .fb_mmap= drm_fbdev_fb_mmap,
+   .fb_read= drm_fb_helper_sys_read,
+   .fb_write   = drm_fb_helper_sys_write,
+   .fb_fillrect= drm_fb_helper_sys_fillrect,
+   .fb_copyarea= drm_fb_helper_sys_copyarea,
+   .fb_imageblit   = drm_fb_helper_sys_imageblit,
+};
+
+static struct fb_deferred_io drm_fbdev_defio = {
+   .delay  = HZ / 20,
+   .deferred_io= drm_fb_helper_deferred_io,
+};
+
+/* Hack to test tinydrm before converting to vmalloc buffers */
+static int drm_fbdev_cma_deferred_io_mmap(struct fb_info *info,
+ struct vm_area_struct *vma)
+{
+   fb_deferred_io_mmap(info, vma);
+   vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+
+   return 0;
+}
+
+static int drm_fb_helper_generic_probe(struct drm_fb_helper *fb_helper,
+  struct drm_fb_helper_surface_size *sizes)
+{
+   struct drm_client_dev *client = fb_helper->client;
+   struct drm_display_mode sizes_mode = {
+   .hdisplay = sizes->surface_width,
+   .vdisplay = sizes->surface_height,
+   };
+   struct drm_client_buffer *buffer;
+   struct drm_framebuffer *fb;
+   struct fb_info *fbi;
+   u32 format;
+   int ret;
+
+   DRM_DEBUG_KMS("surface width(%d), height(%d) and bpp(%d)\n",
+ sizes->surface_width, sizes->surface_height,
+ sizes->surface_bpp);
+
+   format = drm_mode_legacy_fb_format(sizes->surface_bpp, 
sizes->surface_depth);
+   buffer = drm_client_framebuffer_create(client, _mode, format);
+   if (IS_ERR(buffer))
+   return PTR_ERR(buffer);
+
+   fb_helper->buffer = buffer;
+   fb_helper->fb = buffer->fb;
+   fb = buffer->fb;
+
+   fbi = drm_fb_helper_alloc_fbi(fb_helper);
+   if (IS_ERR(fbi)) {
+   ret = PTR_ERR(fbi);
+   goto err_free_buffer;
+   }
+
+   fbi->par = fb_helper;
+   fbi->fbops = _fbdev_fb_ops;
+   fbi->screen_size = fb->height * fb->pitches[0];
+   fbi->fix.smem_len = fbi->screen_size;
+   fbi->screen_buffer = buffer->vaddr;
+   strcpy(fbi->fix.id, "DRM emulated");
+
+   drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
+   drm_fb_helper_fill_var(fbi, fb_helper, sizes->fb_width, 
sizes->fb_height);
+
+   /*
+* Drivers that set the dirty callback:
+* - Doesn't use defio:
+*   i915, virtio, rockchip
+* - defio with vmalloc buffer blitted on the real one:
+*   vmwgfx
+* - defio is disabled because it doesn't work with shmem:
+*   udl
+* - defio with special dirty callback for fbdev, uses vmalloc for 
fbdev:
+*   qxl
+* - defio with cma buffer, will move to vmalloc buffers:
+*   tinydrm
+

[RFC v4 24/25] drm/client: Hack: Add bootsplash

2018-04-12 Thread Noralf Trønnes
A hack to test the client API.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/Kconfig |   2 +
 drivers/gpu/drm/Makefile|   1 +
 drivers/gpu/drm/client/Kconfig  |   9 ++
 drivers/gpu/drm/client/drm_bootsplash.c | 248 
 drivers/gpu/drm/client/internal.h   |  19 +++
 drivers/gpu/drm/drm_client.c|   4 +
 6 files changed, 283 insertions(+)
 create mode 100644 drivers/gpu/drm/client/Kconfig
 create mode 100644 drivers/gpu/drm/client/drm_bootsplash.c
 create mode 100644 drivers/gpu/drm/client/internal.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 757825ac60df..1328202ce17d 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -154,6 +154,8 @@ config DRM_SCHED
tristate
depends on DRM
 
+source "drivers/gpu/drm/client/Kconfig"
+
 source "drivers/gpu/drm/i2c/Kconfig"
 
 source "drivers/gpu/drm/arm/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index d25afa136d8f..388527093f80 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -30,6 +30,7 @@ drm-$(CONFIG_OF) += drm_of.o
 drm-$(CONFIG_AGP) += drm_agpsupport.o
 drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
 drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
+drm-$(CONFIG_DRM_CLIENT_BOOTSPLASH) += client/drm_bootsplash.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 \
diff --git a/drivers/gpu/drm/client/Kconfig b/drivers/gpu/drm/client/Kconfig
new file mode 100644
index ..6b01f2e51fb3
--- /dev/null
+++ b/drivers/gpu/drm/client/Kconfig
@@ -0,0 +1,9 @@
+menu "DRM Clients"
+   depends on DRM
+
+config DRM_CLIENT_BOOTSPLASH
+   bool "DRM Bootsplash"
+   help
+ DRM Bootsplash
+
+endmenu
diff --git a/drivers/gpu/drm/client/drm_bootsplash.c 
b/drivers/gpu/drm/client/drm_bootsplash.c
new file mode 100644
index ..bec3105f9b02
--- /dev/null
+++ b/drivers/gpu/drm/client/drm_bootsplash.c
@@ -0,0 +1,248 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// drm_lastclose()
+#include 
+#include "drm_internal.h"
+
+static bool drm_bootsplash_enabled = true;
+module_param_named(bootsplash_enabled, drm_bootsplash_enabled, bool, 0600);
+MODULE_PARM_DESC(bootsplash_enabled, "Enable bootsplash client 
[default=true]");
+
+struct drm_bootsplash {
+   struct drm_client_dev *client;
+   struct drm_client_display *display;
+   struct drm_client_buffer *buffer[2];
+   struct work_struct worker;
+   bool stop;
+};
+
+static bool drm_bootsplash_key_pressed;
+
+static int drm_bootsplash_keyboard_notifier_call(struct notifier_block *blk,
+ unsigned long code, void *_param)
+{
+   /* Any key is good */
+   drm_bootsplash_key_pressed = true;
+
+   return NOTIFY_OK;
+}
+
+static struct notifier_block drm_bootsplash_keyboard_notifier_block = {
+   .notifier_call = drm_bootsplash_keyboard_notifier_call,
+};
+
+static u32 drm_bootsplash_color_table[3] = {
+   0x00ff, 0xff00, 0x00ff,
+};
+
+/* Draw a box with changing colors */
+static void
+drm_bootsplash_draw(struct drm_client_buffer *buffer, unsigned int sequence)
+{
+   unsigned int x, y;
+   u32 *pix;
+
+   pix = buffer->vaddr;
+   pix += ((buffer->height / 2) - 50) * buffer->width;
+   pix += (buffer->width / 2) - 50;
+
+   for (y = 0; y < 100; y++) {
+   for (x = 0; x < 100; x++)
+   *pix++ = drm_bootsplash_color_table[sequence];
+   pix += buffer->width - 100;
+   }
+}
+
+static void drm_bootsplash_worker(struct work_struct *work)
+{
+   struct drm_bootsplash *splash = container_of(work, struct 
drm_bootsplash, worker);
+   struct drm_device *dev = splash->client->dev;
+   unsigned int i = 0, sequence = 0;
+   struct drm_framebuffer *fb;
+   int ret = 0;
+
+   while (!splash->stop && !drm_bootsplash_key_pressed) {
+   /* Did someone take over, like another in-kernel client, except 
fbdev? */
+   fb = drm_client_display_current_fb(splash->display);
+   if (splash->buffer[i]->fb != fb &&
+   !(dev->fb_helper && dev->fb_helper->fb == fb))
+   break;
+
+   i = !i;
+   drm_bootsplash_draw(splash->buffer[i], sequence++);
+   if (sequence == 3)
+   sequence = 0;
+
+   ret = drm_client_display_commit(splash->display, 
splash->buffer[i]->fb, NULL);
+   /* Is userspace in charge or is the device unplugged? */
+   if (ret == -EBUSY || ret == -ENODEV)
+   break;
+
+   msleep(500);
+ 

[RFC v4 23/25] drm: Add DRM device registered notifier

2018-04-12 Thread Noralf Trønnes
Add a notifier that fires when a new DRM device is registered.
This can be used by the bootsplash client to connect to all devices.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_drv.c | 32 
 include/drm/drm_drv.h |  4 
 2 files changed, 36 insertions(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 6f21bafb29be..e42ce320ad07 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -79,6 +80,8 @@ static struct dentry *drm_debugfs_root;
 
 DEFINE_STATIC_SRCU(drm_unplug_srcu);
 
+static BLOCKING_NOTIFIER_HEAD(drm_dev_notifier);
+
 /*
  * DRM Minors
  * A DRM device can provide several char-dev interfaces on the DRM-Major. Each
@@ -837,6 +840,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long 
flags)
 dev->dev ? dev_name(dev->dev) : "virtual device",
 dev->primary->index);
 
+   blocking_notifier_call_chain(_dev_notifier, 0, dev);
+
goto out_unlock;
 
 err_minors:
@@ -894,6 +899,33 @@ void drm_dev_unregister(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_dev_unregister);
 
+/**
+ * drm_dev_register_notifier - Register a notifier for new DRM devices
+ * @nb: Notifier block
+ *
+ * Register a notifier that fires when a new _device is registered.
+ *
+ * Note:
+ * Users of this function has to be linked into drm.ko. This is done to make
+ * life simple avoiding tricky race situations.
+ */
+void drm_dev_register_notifier(struct notifier_block *nb)
+{
+   /* Currently this can't fail, but catch it in case this changes */
+   WARN_ON(blocking_notifier_chain_register(_dev_notifier, nb));
+}
+
+/**
+ * drm_dev_unregister_notifier - Unregister DRM device notifier
+ * @nb: Notifier block
+ *
+ * This is a no-op if the notifier isn't registered.
+ */
+void drm_dev_unregister_notifier(struct notifier_block *nb)
+{
+   blocking_notifier_chain_unregister(_dev_notifier, nb);
+}
+
 /**
  * drm_dev_set_unique - Set the unique name of a DRM device
  * @dev: device of which to set the unique name
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 13356e6fd40c..5e6c6ed0d59d 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -40,6 +40,7 @@ struct drm_minor;
 struct dma_buf_attachment;
 struct drm_display_mode;
 struct drm_mode_create_dumb;
+struct notifier_block;
 struct drm_printer;
 
 /* driver capabilities and requirements mask */
@@ -641,6 +642,9 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
 int drm_dev_register(struct drm_device *dev, unsigned long flags);
 void drm_dev_unregister(struct drm_device *dev);
 
+void drm_dev_register_notifier(struct notifier_block *nb);
+void drm_dev_unregister_notifier(struct notifier_block *nb);
+
 void drm_dev_get(struct drm_device *dev);
 void drm_dev_put(struct drm_device *dev);
 void drm_dev_unref(struct drm_device *dev);
-- 
2.15.1

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


[Bug 106006] Kernel 4.16.0+ switch amdgpu.dc=1 causes screen brightness set to 1 to be dimmed by default

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106006

Michel Dänzer  changed:

   What|Removed |Added

 CC||harry.wentl...@amd.com

--- Comment #9 from Michel Dänzer  ---
For DC developers: behind the scenes, brightness 1 means no-op/pass-through
gamma LUT, lower brightness levels are simulated by modifying the gamma LUT
accordingly.

-- 
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 106006] Kernel 4.16.0+ switch amdgpu.dc=1 causes screen brightness set to 1 to be dimmed by default

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106006

--- Comment #8 from Joel Sass  ---
$ uname -a
Linux nope 4.16.0+ #1 SMP Mon Apr 2 15:52:14 CEST 2018 x86_64 x86_64 x86_64
GNU/Linux

~$ lsb_release -a
LSB Version:   
core-9.20160110ubuntu0.2-amd64:core-9.20160110ubuntu0.2-noarch:security-9.20160110ubuntu0.2-amd64:security-9.20160110ubuntu0.2-noarch
Distributor ID: Ubuntu
Description:Ubuntu 16.04.4 LTS
Release:16.04
Codename:   xenial

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


[RFC v4 14/25] drm/fb-helper: Remove struct drm_fb_helper_connector

2018-04-12 Thread Noralf Trønnes
No need to maintain a list of registered connectors. Just use the
connector iterator.

TODO: Remove:
- drm_fb_helper_add_one_connector()
- drm_fb_helper_single_add_all_connectors()
- drm_fb_helper_remove_one_connector()

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 359 ++--
 include/drm/drm_fb_helper.h |  13 --
 2 files changed, 86 insertions(+), 286 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index ce38eadcb346..6ee61f195321 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -112,59 +112,10 @@ static DEFINE_MUTEX(kernel_fb_helper_lock);
  * deferred I/O (coupled with drm_fb_helper_fbdev_teardown()).
  */
 
-#define drm_fb_helper_for_each_connector(fbh, i__) \
-   for (({ lockdep_assert_held(&(fbh)->lock); }), \
-i__ = 0; i__ < (fbh)->connector_count; i__++)
-
-static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,
-struct drm_connector *connector)
-{
-   struct drm_fb_helper_connector *fb_conn;
-   struct drm_fb_helper_connector **temp;
-   unsigned int count;
-
-   if (!drm_fbdev_emulation)
-   return 0;
-
-   lockdep_assert_held(_helper->lock);
-
-   count = fb_helper->connector_count + 1;
-
-   if (count > fb_helper->connector_info_alloc_count) {
-   size_t size = count * sizeof(fb_conn);
-
-   temp = krealloc(fb_helper->connector_info, size, GFP_KERNEL);
-   if (!temp)
-   return -ENOMEM;
-
-   fb_helper->connector_info_alloc_count = count;
-   fb_helper->connector_info = temp;
-   }
-
-   fb_conn = kzalloc(sizeof(*fb_conn), GFP_KERNEL);
-   if (!fb_conn)
-   return -ENOMEM;
-
-   drm_connector_get(connector);
-   fb_conn->connector = connector;
-   fb_helper->connector_info[fb_helper->connector_count++] = fb_conn;
-
-   return 0;
-}
-
 int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,
struct drm_connector *connector)
 {
-   int err;
-
-   if (!fb_helper)
-   return 0;
-
-   mutex_lock(_helper->lock);
-   err = __drm_fb_helper_add_one_connector(fb_helper, connector);
-   mutex_unlock(_helper->lock);
-
-   return err;
+   return 0;
 }
 EXPORT_SYMBOL(drm_fb_helper_add_one_connector);
 
@@ -184,87 +135,14 @@ EXPORT_SYMBOL(drm_fb_helper_add_one_connector);
  */
 int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)
 {
-   struct drm_device *dev;
-   struct drm_connector *connector;
-   struct drm_connector_list_iter conn_iter;
-   int i, ret = 0;
-
-   if (!drm_fbdev_emulation || !fb_helper)
-   return 0;
-
-   dev = fb_helper->dev;
-
-   mutex_lock(_helper->lock);
-   drm_connector_list_iter_begin(dev, _iter);
-   drm_for_each_connector_iter(connector, _iter) {
-   ret = __drm_fb_helper_add_one_connector(fb_helper, connector);
-   if (ret)
-   goto fail;
-   }
-   goto out;
-
-fail:
-   drm_fb_helper_for_each_connector(fb_helper, i) {
-   struct drm_fb_helper_connector *fb_helper_connector =
-   fb_helper->connector_info[i];
-
-   drm_connector_put(fb_helper_connector->connector);
-
-   kfree(fb_helper_connector);
-   fb_helper->connector_info[i] = NULL;
-   }
-   fb_helper->connector_count = 0;
-out:
-   drm_connector_list_iter_end(_iter);
-   mutex_unlock(_helper->lock);
-
-   return ret;
-}
-EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors);
-
-static int __drm_fb_helper_remove_one_connector(struct drm_fb_helper 
*fb_helper,
-   struct drm_connector *connector)
-{
-   struct drm_fb_helper_connector *fb_helper_connector;
-   int i, j;
-
-   if (!drm_fbdev_emulation)
-   return 0;
-
-   lockdep_assert_held(_helper->lock);
-
-   drm_fb_helper_for_each_connector(fb_helper, i) {
-   if (fb_helper->connector_info[i]->connector == connector)
-   break;
-   }
-
-   if (i == fb_helper->connector_count)
-   return -EINVAL;
-   fb_helper_connector = fb_helper->connector_info[i];
-   drm_connector_put(fb_helper_connector->connector);
-
-   for (j = i + 1; j < fb_helper->connector_count; j++)
-   fb_helper->connector_info[j - 1] = fb_helper->connector_info[j];
-
-   fb_helper->connector_count--;
-   kfree(fb_helper_connector);
-
return 0;
 }
+EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors);
 
 int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
   struct drm_connector 

[Bug 106006] Kernel 4.16.0+ switch amdgpu.dc=1 causes screen brightness set to 1 to be dimmed by default

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106006

--- Comment #7 from Joel Sass  ---
Created attachment 138809
  --> https://bugs.freedesktop.org/attachment.cgi?id=138809=edit
dmesg output with amdgpu.dc=1

-- 
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 106006] Kernel 4.16.0+ switch amdgpu.dc=1 causes screen brightness set to 1 to be dimmed by default

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106006

--- Comment #5 from Joel Sass  ---
Created attachment 138807
  --> https://bugs.freedesktop.org/attachment.cgi?id=138807=edit
xrandr --verbose with amdgpu.dc=1

-- 
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 106006] Kernel 4.16.0+ switch amdgpu.dc=1 causes screen brightness set to 1 to be dimmed by default

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106006

--- Comment #6 from Joel Sass  ---
Created attachment 138808
  --> https://bugs.freedesktop.org/attachment.cgi?id=138808=edit
Xorg.0.log with amdgpu.dc=1

-- 
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 106006] Kernel 4.16.0+ switch amdgpu.dc=1 causes screen brightness set to 1 to be dimmed by default

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106006

--- Comment #4 from Joel Sass  ---
A fix I've found for the issue seems to be issueing an xrandr brightness
command to each monitor output.

EG: ~$ xrandr --output DP-5 --brightness .99

If brightness is set to 1, the monitor appears to lose some sort of rendering
characteristic, not necessarily brightness - It's like color rendering or gamma
correction change somehow. Simply changing the brightness a modicum seems to
fix the issue.

-- 
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 106006] Kernel 4.16.0+ switch amdgpu.dc=1 causes screen brightness set to 1 to be dimmed by default

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106006

--- Comment #2 from Joel Sass  ---
Created attachment 138805
  --> https://bugs.freedesktop.org/attachment.cgi?id=138805=edit
Xorg.0.log with amdgpu.dc=0

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


[RFC v4 21/25] drm/fb-helper: Add drm_fb_helper_fb_open/release()

2018-04-12 Thread Noralf Trønnes
These helpers keep track of fbdev users and drm_driver.last_close will
only restore fbdev when actually in use. Additionally the display is
turned off when the last user is closing. fbcon is a user in this context.

If struct fb_ops is defined in a library, fb_open() takes a ref on the
library (fb_ops.owner) instead of the driver module. Fix that by ensuring
that the driver module is pinned.

The functions are not added to the DRM_FB_HELPER_DEFAULT_OPS() macro,
because some of its users do set fb_open/release themselves.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 54 -
 include/drm/drm_fb_helper.h | 29 ++
 2 files changed, 82 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 98e5bc92c9f2..b1124c08b1ed 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -177,7 +177,7 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct 
drm_fb_helper *fb_helper)
if (!drm_fbdev_emulation || !fb_helper)
return -ENODEV;
 
-   if (READ_ONCE(fb_helper->deferred_setup))
+   if (READ_ONCE(fb_helper->deferred_setup) || 
!READ_ONCE(fb_helper->open_count))
return 0;
 
mutex_lock(_helper->lock);
@@ -368,6 +368,7 @@ void drm_fb_helper_prepare(struct drm_device *dev, struct 
drm_fb_helper *helper,
INIT_WORK(>dirty_work, drm_fb_helper_dirty_work);
helper->dirty_clip.x1 = helper->dirty_clip.y1 = ~0;
mutex_init(>lock);
+   helper->open_count = 1;
helper->funcs = funcs;
helper->dev = dev;
 }
@@ -620,6 +621,53 @@ int drm_fb_helper_defio_init(struct drm_fb_helper 
*fb_helper)
 }
 EXPORT_SYMBOL(drm_fb_helper_defio_init);
 
+/**
+ * drm_fb_helper_fb_open - implementation for _ops.fb_open
+ * @info: fbdev registered by the helper
+ * @user: 1=userspace, 0=fbcon
+ *
+ * Increase fbdev use count.
+ * If _ops is wrapped in a library, pin the driver module.
+ */
+int drm_fb_helper_fb_open(struct fb_info *info, int user)
+{
+   struct drm_fb_helper *fb_helper = info->par;
+   struct drm_device *dev = fb_helper->dev;
+
+   if (info->fbops->owner != dev->driver->fops->owner) {
+   if (!try_module_get(dev->driver->fops->owner))
+   return -ENODEV;
+   }
+
+   fb_helper->open_count++;
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_fb_helper_fb_open);
+
+/**
+ * drm_fb_helper_fb_release - implementation for _ops.fb_release
+ * @info: fbdev registered by the helper
+ * @user: 1=userspace, 0=fbcon
+ *
+ * Decrease fbdev use count and turn off if there are no users left.
+ * If _ops is wrapped in a library, unpin the driver module.
+ */
+int drm_fb_helper_fb_release(struct fb_info *info, int user)
+{
+   struct drm_fb_helper *fb_helper = info->par;
+   struct drm_device *dev = fb_helper->dev;
+
+   if (!(--fb_helper->open_count))
+   drm_fb_helper_dpms(info, DRM_MODE_DPMS_OFF);
+
+   if (info->fbops->owner != dev->driver->fops->owner)
+   module_put(dev->driver->fops->owner);
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_fb_helper_fb_release);
+
 /**
  * drm_fb_helper_sys_read - wrapper around fb_sys_read
  * @info: fb_info struct pointer
@@ -1436,6 +1484,10 @@ static int drm_fb_helper_single_fb_probe(struct 
drm_fb_helper *fb_helper,
if (ret < 0)
return ret;
 
+   /* Block restore without users if we do track it */
+   if (fb_helper->fbdev->fbops->fb_open == drm_fb_helper_fb_open)
+   fb_helper->open_count = 0;
+
strcpy(fb_helper->fb->comm, "[fbcon]");
return 0;
 }
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 5f66f253a97b..330983975d5e 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -184,6 +184,22 @@ struct drm_fb_helper {
 * See also: @deferred_setup
 */
int preferred_bpp;
+
+   /**
+* @open_count:
+*
+* Keeps track of fbdev use to know when to not restore fbdev and to
+* disable the pipeline when the last user is gone.
+*
+* Drivers that use drm_fb_helper_fb_open() as their \.fb_open
+* callback will get an initial value of 0 and get restore based on
+* actual use. Others will get an initial value of 1 which means that
+* fbdev will always be restored. Drivers that call
+* drm_fb_helper_fb_open() in their \.fb_open, thus needs to set the
+* initial value to 0 themselves in their _fb_helper_funcs->fb_probe
+* callback.
+*/
+   unsigned int open_count;
 };
 
 /**
@@ -230,6 +246,9 @@ void drm_fb_helper_deferred_io(struct fb_info *info,
   struct list_head *pagelist);
 int drm_fb_helper_defio_init(struct drm_fb_helper *fb_helper);
 
+int drm_fb_helper_fb_open(struct fb_info *info, int 

[RFC v4 18/25] drm/client: Make the display modes available to clients

2018-04-12 Thread Noralf Trønnes
Give clients easy access to the display modes.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_client.c | 159 +--
 include/drm/drm_client.h |  25 +++
 2 files changed, 148 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index 764c556630b8..bce1630a0db2 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -8,6 +8,7 @@
  * Copyright (c) 2007 Dave Airlie 
  */
 
+#include 
 #include 
 
 #include 
@@ -54,6 +55,7 @@ struct drm_client_display *drm_client_display_create(struct 
drm_device *dev)
}
 
display->dev = dev;
+   INIT_LIST_HEAD(>modes);
display->modeset_count = num_crtc;
 
drm_for_each_crtc(crtc, dev)
@@ -84,12 +86,16 @@ EXPORT_SYMBOL(drm_client_display_create);
  */
 void drm_client_display_free(struct drm_client_display *display)
 {
+   struct drm_display_mode *mode, *tmp;
struct drm_mode_set *modeset;
unsigned int i;
 
if (!display)
return;
 
+   list_for_each_entry_safe(mode, tmp, >modes, head)
+   drm_mode_destroy(display->dev, mode);
+
drm_client_display_for_each_modeset(modeset, display) {
if (modeset->mode)
drm_mode_destroy(display->dev, modeset->mode);
@@ -670,22 +676,70 @@ static int drm_pick_crtcs(struct drm_client_display 
*display,
return best_score;
 }
 
-/**
- * drm_client_find_display() - Find display
- * @dev: DRM device
- * @width: Maximum display mode width (optional)
- * @height: Maximum display mode height (optional)
- *
- * This function returns a display the client can use if available.
- *
- * Free resources by calling drm_client_display_free().
- *
- * Returns:
- * A _client_display on success, NULL if no connectors are found
- * or error pointer on failure.
- */
-struct drm_client_display *
-drm_client_find_display(struct drm_device *dev, unsigned int width, unsigned 
int height)
+/* Give the client a static list of display modes */
+static int drm_client_display_copy_modes(struct drm_client_display *display)
+{
+   int hdisplay = 0, vdisplay = 0, vrefresh;
+   struct drm_device *dev = display->dev;
+   struct drm_display_mode *mode, *copy;
+   struct drm_connector *connector;
+   struct drm_mode_set *modeset;
+   unsigned int count = 0;
+
+   drm_client_display_for_each_modeset(modeset, display) {
+   if (!modeset->num_connectors || !modeset->mode)
+   continue;
+
+   connector = modeset->connectors[0];
+   mode = modeset->mode;
+   count++;
+
+   if (modeset->num_connectors == 2) {
+   /* Cloned output */
+   copy = drm_mode_duplicate(dev, modeset->mode);
+   if (!copy)
+   return -ENOMEM;
+   list_add_tail(>head, >modes);
+   display->mode = copy;
+
+   return 0;
+   }
+
+   if (!modeset->y)
+   hdisplay += modeset->mode->hdisplay;
+   if (!modeset->x)
+   vdisplay += modeset->mode->vdisplay;
+   vrefresh = modeset->mode->vrefresh;
+   }
+
+   if (!count)
+   return 0;
+
+   if (count == 1) {
+   struct drm_display_mode *iter;
+
+   list_for_each_entry(iter, >modes, head) {
+   copy = drm_mode_duplicate(dev, iter);
+   if (!copy)
+   return -ENOMEM;
+   list_add_tail(>head, >modes);
+   if (!display->mode && drm_mode_equal(iter, mode))
+   display->mode = copy;
+   }
+   } else {
+   /* Combined tile mode. Only the default one for now */
+   copy = drm_cvt_mode(dev, hdisplay, vdisplay, vrefresh, false, 
false, false);
+   if (!copy)
+   return -ENOMEM;
+   list_add_tail(>head, >modes);
+   display->mode = copy;
+   }
+
+   return 0;
+}
+
+static struct drm_client_display *
+drm_client_find_display_default(struct drm_device *dev, unsigned int width, 
unsigned int height)
 {
struct drm_client_display_offset *offsets;
struct drm_client_display *display;
@@ -695,25 +749,6 @@ drm_client_find_display(struct drm_device *dev, unsigned 
int width, unsigned int
int i, connector_count;
bool *enabled;
 
-   DRM_DEBUG_KMS("\n");
-
-   if (!width)
-   width = dev->mode_config.max_width;
-   if (!height)
-   height = dev->mode_config.max_height;
-
-   mutex_lock(>mode_config.mutex);
-   if (!drm_client_probe_connector_modes(dev, width, height))
-   

[RFC v4 16/25] drm: Make ioctls available for in-kernel clients

2018-04-12 Thread Noralf Trønnes
Make ioctl wrappers for functions that will be used by the in-kernel API.
The following functions are touched:
- drm_mode_create_dumb_ioctl()
- drm_mode_destroy_dumb_ioctl()
- drm_mode_addfb2()
- drm_mode_rmfb()
- drm_prime_handle_to_fd_ioctl()

drm_mode_addfb2() also gets the ability to override the debug name.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_crtc_internal.h | 18 ++---
 drivers/gpu/drm/drm_dumb_buffers.c  | 33 
 drivers/gpu/drm/drm_framebuffer.c   | 50 -
 drivers/gpu/drm/drm_internal.h  |  3 +++
 drivers/gpu/drm/drm_ioc32.c |  2 +-
 drivers/gpu/drm/drm_ioctl.c |  4 +--
 drivers/gpu/drm/drm_prime.c | 13 +++---
 7 files changed, 84 insertions(+), 39 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc_internal.h 
b/drivers/gpu/drm/drm_crtc_internal.h
index 3c2b82865ad2..8f8886ac0e4d 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -62,6 +62,12 @@ int drm_mode_getresources(struct drm_device *dev,
 
 
 /* drm_dumb_buffers.c */
+int drm_mode_create_dumb(struct drm_device *dev,
+struct drm_mode_create_dumb *args,
+struct drm_file *file_priv);
+int drm_mode_destroy_dumb(struct drm_device *dev, u32 handle,
+ struct drm_file *file_priv);
+
 /* IOCTLs */
 int drm_mode_create_dumb_ioctl(struct drm_device *dev,
   void *data, struct drm_file *file_priv);
@@ -163,14 +169,18 @@ int drm_framebuffer_check_src_coords(uint32_t src_x, 
uint32_t src_y,
 const struct drm_framebuffer *fb);
 void drm_fb_release(struct drm_file *file_priv);
 
+int drm_mode_addfb2(struct drm_device *dev, struct drm_mode_fb_cmd2 *r,
+   struct drm_file *file_priv, const char *comm);
+int drm_mode_rmfb(struct drm_device *dev, u32 fb_id,
+ struct drm_file *file_priv);
 
 /* IOCTL */
 int drm_mode_addfb(struct drm_device *dev,
   void *data, struct drm_file *file_priv);
-int drm_mode_addfb2(struct drm_device *dev,
-   void *data, struct drm_file *file_priv);
-int drm_mode_rmfb(struct drm_device *dev,
- void *data, struct drm_file *file_priv);
+int drm_mode_addfb2_ioctl(struct drm_device *dev,
+ void *data, struct drm_file *file_priv);
+int drm_mode_rmfb_ioctl(struct drm_device *dev,
+   void *data, struct drm_file *file_priv);
 int drm_mode_getfb(struct drm_device *dev,
   void *data, struct drm_file *file_priv);
 int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
diff --git a/drivers/gpu/drm/drm_dumb_buffers.c 
b/drivers/gpu/drm/drm_dumb_buffers.c
index 39ac15ce4702..eed9687b8698 100644
--- a/drivers/gpu/drm/drm_dumb_buffers.c
+++ b/drivers/gpu/drm/drm_dumb_buffers.c
@@ -53,10 +53,10 @@
  * a hardware-specific ioctl to allocate suitable buffer objects.
  */
 
-int drm_mode_create_dumb_ioctl(struct drm_device *dev,
-  void *data, struct drm_file *file_priv)
+int drm_mode_create_dumb(struct drm_device *dev,
+struct drm_mode_create_dumb *args,
+struct drm_file *file_priv)
 {
-   struct drm_mode_create_dumb *args = data;
u32 cpp, stride, size;
 
if (!dev->driver->dumb_create)
@@ -91,6 +91,12 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
return dev->driver->dumb_create(file_priv, dev, args);
 }
 
+int drm_mode_create_dumb_ioctl(struct drm_device *dev,
+  void *data, struct drm_file *file_priv)
+{
+   return drm_mode_create_dumb(dev, data, file_priv);
+}
+
 /**
  * drm_mode_mmap_dumb_ioctl - create an mmap offset for a dumb backing storage 
buffer
  * @dev: DRM device
@@ -122,17 +128,22 @@ int drm_mode_mmap_dumb_ioctl(struct drm_device *dev,
   >offset);
 }
 
+int drm_mode_destroy_dumb(struct drm_device *dev, u32 handle,
+ struct drm_file *file_priv)
+{
+   if (!dev->driver->dumb_create)
+   return -ENOSYS;
+
+   if (dev->driver->dumb_destroy)
+   return dev->driver->dumb_destroy(file_priv, dev, handle);
+   else
+   return drm_gem_dumb_destroy(file_priv, dev, handle);
+}
+
 int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv)
 {
struct drm_mode_destroy_dumb *args = data;
 
-   if (!dev->driver->dumb_create)
-   return -ENOSYS;
-
-   if (dev->driver->dumb_destroy)
-   return dev->driver->dumb_destroy(file_priv, dev, args->handle);
-   else
-   return drm_gem_dumb_destroy(file_priv, dev, args->handle);
+   return drm_mode_destroy_dumb(dev, args->handle, file_priv);
 }
-
diff --git 

[RFC v4 19/25] drm/client: Finish the in-kernel client API

2018-04-12 Thread Noralf Trønnes
The modesetting code is already present, this adds the rest of the API.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_client.c   | 573 +
 drivers/gpu/drm/drm_debugfs.c  |   7 +
 drivers/gpu/drm/drm_drv.c  |  11 +
 drivers/gpu/drm/drm_file.c |   3 +
 drivers/gpu/drm/drm_probe_helper.c |   3 +
 drivers/gpu/drm/drm_sysfs.c|  20 ++
 include/drm/drm_client.h   | 103 +++
 include/drm/drm_device.h   |   4 +
 8 files changed, 724 insertions(+)

diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index bce1630a0db2..760f1795f812 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -8,7 +8,9 @@
  * Copyright (c) 2007 Dave Airlie 
  */
 
+#include 
 #include 
+#include 
 #include 
 
 #include 
@@ -17,14 +19,280 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
+#include "drm_crtc_internal.h"
 #include "drm_internal.h"
 
 struct drm_client_display_offset {
int x, y;
 };
 
+static int drm_client_alloc_file(struct drm_client_dev *client)
+{
+   struct drm_device *dev = client->dev;
+   struct drm_file *file;
+
+   file = drm_file_alloc(dev->primary);
+   if (IS_ERR(file))
+   return PTR_ERR(file);
+
+   drm_dev_get(dev);
+
+   mutex_lock(>filelist_mutex);
+   list_add(>lhead, >filelist_internal);
+   mutex_unlock(>filelist_mutex);
+
+   client->file = file;
+
+   return 0;
+}
+
+static void drm_client_free_file(struct drm_client_dev *client)
+{
+   struct drm_device *dev = client->dev;
+
+   mutex_lock(>filelist_mutex);
+   list_del(>file->lhead);
+   mutex_unlock(>filelist_mutex);
+
+   drm_file_free(client->file);
+   drm_dev_put(dev);
+}
+
+struct drm_client_dev *
+drm_client_new(struct drm_device *dev, const struct drm_client_funcs *funcs)
+{
+   struct drm_client_dev *client;
+   int ret;
+
+   if (WARN_ON(!funcs->name))
+   return ERR_PTR(-EINVAL);
+
+   client = kzalloc(sizeof(*client), GFP_KERNEL);
+   if (!client)
+   return ERR_PTR(-ENOMEM);
+
+   client->dev = dev;
+   client->funcs = funcs;
+
+   ret = drm_client_alloc_file(client);
+   if (ret) {
+   kfree(client);
+   return ERR_PTR(ret);
+   }
+
+   mutex_lock(>clientlist_mutex);
+   list_add(>list, >clientlist);
+   mutex_unlock(>clientlist_mutex);
+
+   return client;
+}
+EXPORT_SYMBOL(drm_client_new);
+
+struct drm_client_dev *
+drm_client_new_from_id(unsigned int dev_id, const struct drm_client_funcs 
*funcs)
+{
+   struct drm_client_dev *client;
+   struct drm_minor *minor;
+
+   minor = drm_minor_acquire(dev_id);
+   if (IS_ERR(minor))
+   return ERR_CAST(minor);
+
+   client = drm_client_new(minor->dev, funcs);
+
+   drm_minor_release(minor);
+
+   return client;
+}
+EXPORT_SYMBOL(drm_client_new_from_id);
+
+/**
+ * drm_client_free - Free DRM client resources
+ * @client: DRM client
+ *
+ * This is called automatically on client removal unless the client returns
+ * non-zero in the _client_funcs->remove callback. The fbdev client does
+ * this when it can't close _file because userspace has an open fd.
+ *
+ * Note:
+ * If the client can't release it's resources on remove, it needs to hold a
+ * reference on the driver module to prevent the code from going away.
+ */
+void drm_client_free(struct drm_client_dev *client)
+{
+   DRM_DEV_DEBUG_KMS(client->dev->dev, "%s\n", client->funcs->name);
+   drm_client_free_file(client);
+   kfree(client);
+}
+EXPORT_SYMBOL(drm_client_free);
+
+static void drm_client_remove_locked(struct drm_client_dev *client)
+{
+   list_del(>list);
+
+   if (!client->funcs->remove || !client->funcs->remove(client))
+   drm_client_free(client);
+}
+
+static void drm_client_remove_safe(struct drm_device *dev,
+  struct drm_client_dev *client)
+{
+   struct drm_client_dev *iter;
+
+   mutex_lock(>clientlist_mutex);
+   list_for_each_entry(iter, >clientlist, list) {
+   if (iter == client) {
+   drm_client_remove_locked(client);
+   break;
+   }
+   }
+   mutex_unlock(>clientlist_mutex);
+}
+
+/**
+ * drm_client_remove - Remove client
+ * @client: Client
+ *
+ * Remove a client.
+ */
+void drm_client_remove(struct drm_client_dev *client)
+{
+   struct drm_device *dev;
+
+   if (!client)
+   return;
+
+   dev = client->dev;
+   drm_dev_get(dev);
+   drm_client_remove_safe(dev, client);
+   drm_dev_put(dev);
+}
+EXPORT_SYMBOL(drm_client_remove);
+
+struct drm_client_remove_defer {
+   struct list_head list;
+   struct drm_device *dev;
+   struct drm_client_dev *client;
+};
+
+static LIST_HEAD(drm_client_remove_defer_list);

[RFC v4 15/25] drm/fb-helper: Move modeset config code to drm_client

2018-04-12 Thread Noralf Trønnes
Call the function drm_client_find_display().
No functional change apart from making width/height arguments optional.
Some function name/signature changes and whitespace adjustments.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_client.c| 399 
 drivers/gpu/drm/drm_fb_helper.c | 371 +
 include/drm/drm_client.h|   2 +
 include/drm/drm_fb_helper.h |   4 -
 4 files changed, 403 insertions(+), 373 deletions(-)

diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index c85c13568cf9..27818a467b09 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -18,6 +18,10 @@
 #include 
 #include 
 
+struct drm_client_display_offset {
+   int x, y;
+};
+
 /**
  * drm_client_display_create() - Create display structure
  * @dev: DRM device
@@ -359,3 +363,398 @@ void drm_client_display_dpms(struct drm_client_display 
*display, int mode)
drm_client_display_dpms_legacy(display, mode);
 }
 EXPORT_SYMBOL(drm_client_display_dpms);
+
+static int drm_client_probe_connector_modes(struct drm_device *dev,
+   u32 max_width, u32 max_height)
+{
+   struct drm_connector_list_iter conn_iter;
+   struct drm_connector *connector;
+   int count = 0;
+
+   drm_connector_list_iter_begin(dev, _iter);
+   drm_for_each_connector_iter(connector, _iter) {
+   count += connector->funcs->fill_modes(connector, max_width, 
max_height);
+   }
+   drm_connector_list_iter_end(_iter);
+
+   return count;
+}
+
+static bool drm_target_cloned(struct drm_device *dev,
+ struct drm_connector **connectors,
+ unsigned int connector_count,
+ struct drm_display_mode **modes,
+ struct drm_client_display_offset *offsets,
+ bool *enabled, int width, int height)
+{
+   int count, i, j;
+   bool can_clone = false;
+   struct drm_display_mode *dmt_mode, *mode;
+
+   /* only contemplate cloning in the single crtc case */
+   if (dev->mode_config.num_crtc > 1)
+   return false;
+
+   count = 0;
+   for (i = 0; i < connector_count; i++) {
+   if (enabled[i])
+   count++;
+   }
+
+   /* only contemplate cloning if more than one connector is enabled */
+   if (count <= 1)
+   return false;
+
+   /* check the command line or if nothing common pick 1024x768 */
+   can_clone = true;
+   for (i = 0; i < connector_count; i++) {
+   if (!enabled[i])
+   continue;
+   modes[i] = drm_connector_pick_cmdline_mode(connectors[i]);
+   if (!modes[i]) {
+   can_clone = false;
+   break;
+   }
+   for (j = 0; j < i; j++) {
+   if (!enabled[j])
+   continue;
+   if (!drm_mode_equal(modes[j], modes[i]))
+   can_clone = false;
+   }
+   }
+
+   if (can_clone) {
+   DRM_DEBUG_KMS("can clone using command line\n");
+   return true;
+   }
+
+   /* try and find a 1024x768 mode on each connector */
+   can_clone = true;
+   dmt_mode = drm_mode_find_dmt(dev, 1024, 768, 60, false);
+
+   for (i = 0; i < connector_count; i++) {
+   if (!enabled[i])
+   continue;
+
+   list_for_each_entry(mode, [i]->modes, head) {
+   if (drm_mode_equal(mode, dmt_mode))
+   modes[i] = mode;
+   }
+   if (!modes[i])
+   can_clone = false;
+   }
+
+   if (can_clone) {
+   DRM_DEBUG_KMS("can clone using 1024x768\n");
+   return true;
+   }
+   DRM_INFO("kms: can't enable cloning when we probably wanted to.\n");
+
+   return false;
+}
+
+static void drm_get_tile_offsets(struct drm_connector **connectors,
+unsigned int connector_count,
+struct drm_display_mode **modes,
+struct drm_client_display_offset *offsets,
+int idx,
+int h_idx, int v_idx)
+{
+   int i;
+   int hoffset = 0, voffset = 0;
+
+   for (i = 0; i < connector_count; i++) {
+   struct drm_connector *connector = connectors[i];
+
+   if (!connector->has_tile)
+   continue;
+
+   if (!modes[i] && (h_idx || v_idx)) {
+   DRM_DEBUG_KMS("no modes for connector tiled %d %d\n", i,
+ connector->base.id);
+   

[RFC v4 17/25] drm/client: Bail out if there's a DRM master

2018-04-12 Thread Noralf Trønnes
If there's a DRM master, return -EBUSY.
Block userspace from becoming master by taking the master lock while
the client is setting the mode.

Suggested-by: Daniel Vetter 
Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_auth.c  | 33 +
 drivers/gpu/drm/drm_client.c| 34 +-
 drivers/gpu/drm/drm_fb_helper.c |  8 
 drivers/gpu/drm/drm_internal.h  |  2 ++
 include/drm/drm_client.h|  4 ++--
 5 files changed, 70 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index d9c0f7573905..d656d0d93da3 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -366,3 +366,36 @@ void drm_master_put(struct drm_master **master)
*master = NULL;
 }
 EXPORT_SYMBOL(drm_master_put);
+
+/**
+ * drm_master_block - Block DRM master operations
+ * @dev: DRM device
+ *
+ * This function checks if there is a master on @dev. If there is no master it
+ * blocks anyone from becoming master. In-kernel clients can use this to know
+ * when they can act as master. Use drm_master_unblock() to unblock.
+ *
+ * Returns:
+ * True if there is no master, false otherwise.
+ */
+bool drm_master_block(struct drm_device *dev)
+{
+   mutex_lock(>master_mutex);
+   if (dev->master) {
+   mutex_unlock(>master_mutex);
+   return false;
+   }
+
+   return true;
+}
+
+/**
+ * drm_master_unblock - Unblock DRM master operations
+ * @dev: DRM device
+ *
+ * Unblock and allow userspace to become master.
+ */
+void drm_master_unblock(struct drm_device *dev)
+{
+   mutex_unlock(>master_mutex);
+}
diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index 27818a467b09..764c556630b8 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -18,6 +18,8 @@
 #include 
 #include 
 
+#include "drm_internal.h"
+
 struct drm_client_display_offset {
int x, y;
 };
@@ -313,18 +315,30 @@ static int drm_client_display_restore_legacy(struct 
drm_client_display *display)
 /**
  * drm_client_display_restore() - Restore client display
  * @display: Client display
+ * @force: If true, restore even if there's a DRM master
  *
  * Restore client display using the current modeset configuration.
  *
  * Return:
  * Zero on succes or negative error code on failure.
  */
-int drm_client_display_restore(struct drm_client_display *display)
+int drm_client_display_restore(struct drm_client_display *display, bool force)
 {
-   if (drm_drv_uses_atomic_modeset(display->dev))
-   return drm_client_display_restore_atomic(display, true);
+   struct drm_device *dev = display->dev;
+   int ret;
+
+   if (!force && !drm_master_block(dev))
+   return -EBUSY;
+
+   if (drm_drv_uses_atomic_modeset(dev))
+   ret = drm_client_display_restore_atomic(display, true);
else
-   return drm_client_display_restore_legacy(display);
+   ret = drm_client_display_restore_legacy(display);
+
+   if (!force)
+   drm_master_unblock(dev);
+
+   return ret;
 }
 EXPORT_SYMBOL(drm_client_display_restore);
 
@@ -354,13 +368,23 @@ static void drm_client_display_dpms_legacy(struct 
drm_client_display *display, i
  * drm_client_display_dpms() - Set display DPMS mode
  * @display: Client display
  * @mode: DPMS mode
+ *
+ * Returns:
+ * Zero on success, -EBUSY if there's a DRM master.
  */
-void drm_client_display_dpms(struct drm_client_display *display, int mode)
+int drm_client_display_dpms(struct drm_client_display *display, int mode)
 {
+   if (!drm_master_block(display->dev))
+   return -EBUSY;
+
if (drm_drv_uses_atomic_modeset(display->dev))
drm_client_display_restore_atomic(display, mode == 
DRM_MODE_DPMS_ON);
else
drm_client_display_dpms_legacy(display, mode);
+
+   drm_master_unblock(display->dev);
+
+   return 0;
 }
 EXPORT_SYMBOL(drm_client_display_dpms);
 
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 01d8840930a3..98e5bc92c9f2 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -181,7 +181,7 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct 
drm_fb_helper *fb_helper)
return 0;
 
mutex_lock(_helper->lock);
-   ret = drm_client_display_restore(fb_helper->display);
+   ret = drm_client_display_restore(fb_helper->display, false);
 
do_delayed = fb_helper->delayed_hotplug;
if (do_delayed)
@@ -243,7 +243,7 @@ static bool drm_fb_helper_force_kernel_mode(void)
continue;
 
mutex_lock(>lock);
-   ret = drm_client_display_restore(helper->display);
+   ret = drm_client_display_restore(helper->display, true);
if (ret)

[RFC v4 13/25] drm/fb-helper: Remove struct drm_fb_helper_crtc

2018-04-12 Thread Noralf Trønnes
The stage is now set for a clean removal of drm_fb_helper_crtc.
struct drm_client_display is doing its job now.

Also remove the drm_fb_helper_funcs->initial_config which has been
superseded by drm_driver->initial_client_display.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 124 +---
 include/drm/drm_fb_helper.h |  31 --
 2 files changed, 26 insertions(+), 129 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 5407bf6dc8c0..ce38eadcb346 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -443,24 +443,6 @@ int drm_fb_helper_blank(int blank, struct fb_info *info)
 }
 EXPORT_SYMBOL(drm_fb_helper_blank);
 
-static void drm_fb_helper_modeset_release(struct drm_fb_helper *helper,
- struct drm_mode_set *modeset)
-{
-   int i;
-
-   for (i = 0; i < modeset->num_connectors; i++) {
-   drm_connector_put(modeset->connectors[i]);
-   modeset->connectors[i] = NULL;
-   }
-   modeset->num_connectors = 0;
-
-   drm_mode_destroy(helper->dev, modeset->mode);
-   modeset->mode = NULL;
-
-   /* FIXME should hold a ref? */
-   modeset->fb = NULL;
-}
-
 static void drm_fb_helper_crtc_free(struct drm_fb_helper *helper)
 {
int i;
@@ -470,14 +452,6 @@ static void drm_fb_helper_crtc_free(struct drm_fb_helper 
*helper)
kfree(helper->connector_info[i]);
}
kfree(helper->connector_info);
-
-   for (i = 0; i < helper->crtc_count; i++) {
-   struct drm_mode_set *modeset = >crtc_info[i].mode_set;
-
-   drm_fb_helper_modeset_release(helper, modeset);
-   kfree(modeset->connectors);
-   }
-   kfree(helper->crtc_info);
 }
 
 static void drm_fb_helper_resume_worker(struct work_struct *work)
@@ -552,48 +526,18 @@ int drm_fb_helper_init(struct drm_device *dev,
   struct drm_fb_helper *fb_helper,
   int max_conn_count)
 {
-   struct drm_crtc *crtc;
-   struct drm_mode_config *config = >mode_config;
-   int i;
-
if (!drm_fbdev_emulation) {
dev->fb_helper = fb_helper;
return 0;
}
 
-   if (!max_conn_count)
-   return -EINVAL;
-
-   fb_helper->crtc_info = kcalloc(config->num_crtc, sizeof(struct 
drm_fb_helper_crtc), GFP_KERNEL);
-   if (!fb_helper->crtc_info)
-   return -ENOMEM;
-
-   fb_helper->crtc_count = config->num_crtc;
fb_helper->connector_info = kcalloc(dev->mode_config.num_connector, 
sizeof(struct drm_fb_helper_connector *), GFP_KERNEL);
-   if (!fb_helper->connector_info) {
-   kfree(fb_helper->crtc_info);
+   if (!fb_helper->connector_info)
return -ENOMEM;
-   }
+
fb_helper->connector_info_alloc_count = dev->mode_config.num_connector;
fb_helper->connector_count = 0;
 
-   for (i = 0; i < fb_helper->crtc_count; i++) {
-   fb_helper->crtc_info[i].mode_set.connectors =
-   kcalloc(max_conn_count,
-   sizeof(struct drm_connector *),
-   GFP_KERNEL);
-
-   if (!fb_helper->crtc_info[i].mode_set.connectors)
-   goto out_free;
-   fb_helper->crtc_info[i].mode_set.num_connectors = 0;
-   }
-
-   i = 0;
-   drm_for_each_crtc(crtc, dev) {
-   fb_helper->crtc_info[i].mode_set.crtc = crtc;
-   i++;
-   }
-
fb_helper->display = drm_client_display_create(dev);
if (IS_ERR(fb_helper->display))
goto out_free;
@@ -1830,7 +1774,7 @@ static bool drm_target_cloned(struct drm_fb_helper 
*fb_helper,
struct drm_display_mode *dmt_mode, *mode;
 
/* only contemplate cloning in the single crtc case */
-   if (fb_helper->crtc_count > 1)
+   if (fb_helper->dev->mode_config.num_crtc > 1)
return false;
 
count = 0;
@@ -1997,16 +1941,18 @@ static bool drm_target_preferred(struct drm_fb_helper 
*fb_helper,
 }
 
 static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
- struct drm_fb_helper_crtc **best_crtcs,
+ struct drm_crtc **best_crtcs,
  struct drm_display_mode **modes,
  int n, int width, int height)
 {
-   int c, o;
+   struct drm_client_display *display = fb_helper->display;
+   struct drm_device *dev = display->dev;
+   int o, my_score, best_score, score;
struct drm_connector *connector;
const struct drm_connector_helper_funcs *connector_funcs;
+   struct drm_mode_set *modeset;
struct drm_encoder *encoder;
-   int my_score, best_score, score;
-   struct drm_fb_helper_crtc **crtcs, *crtc;
+   struct 

[RFC v4 12/25] drm/i915: Add drm_driver->initial_client_display callback

2018-04-12 Thread Noralf Trønnes
As part of moving the modesetting code out of drm_fb_helper and into
drm_client, the drm_fb_helper_funcs->initial_config callback needs to go.
Replace it with a drm_driver->initial_client_display callback that can
work for all in-kernel clients.

TODO:
- Add a patch that moves the function out of intel_fbdev.c since it's not
  fbdev specific anymore.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c|  19 +--
 drivers/gpu/drm/i915/i915_drv.c|   1 +
 drivers/gpu/drm/i915/intel_drv.h   |  11 
 drivers/gpu/drm/i915/intel_fbdev.c | 113 ++---
 include/drm/drm_drv.h  |  21 +++
 5 files changed, 104 insertions(+), 61 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index b992f59dad30..5407bf6dc8c0 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -2103,6 +2103,20 @@ static void drm_setup_crtcs(struct drm_fb_helper 
*fb_helper,
/* prevent concurrent modification of connector_count by hotplug */
lockdep_assert_held(_helper->lock);
 
+   mutex_lock(>mode_config.mutex);
+   if (drm_fb_helper_probe_connector_modes(fb_helper, width, height) == 0)
+   DRM_DEBUG_KMS("No connectors reported connected with modes\n");
+
+   if (dev->driver->initial_client_display) {
+   display = dev->driver->initial_client_display(dev, width, 
height);
+   if (display) {
+   drm_client_display_free(fb_helper->display);
+   fb_helper->display = display;
+   mutex_unlock(>mode_config.mutex);
+   return;
+   }
+   }
+
crtcs = kcalloc(fb_helper->connector_count,
sizeof(struct drm_fb_helper_crtc *), GFP_KERNEL);
modes = kcalloc(fb_helper->connector_count,
@@ -2120,9 +2134,6 @@ static void drm_setup_crtcs(struct drm_fb_helper 
*fb_helper,
if (IS_ERR(display))
goto out;
 
-   mutex_lock(_helper->dev->mode_config.mutex);
-   if (drm_fb_helper_probe_connector_modes(fb_helper, width, height) == 0)
-   DRM_DEBUG_KMS("No connectors reported connected with modes\n");
drm_enable_connectors(fb_helper, enabled);
 
if (!(fb_helper->funcs->initial_config &&
@@ -2144,7 +2155,6 @@ static void drm_setup_crtcs(struct drm_fb_helper 
*fb_helper,
 
drm_pick_crtcs(fb_helper, crtcs, modes, 0, width, height);
}
-   mutex_unlock(_helper->dev->mode_config.mutex);
 
/* need to set the modesets up here for use later */
/* fill out the connector<->crtc mappings into the modesets */
@@ -2182,6 +2192,7 @@ static void drm_setup_crtcs(struct drm_fb_helper 
*fb_helper,
drm_client_display_free(fb_helper->display);
fb_helper->display = display;
 out:
+   mutex_unlock(>mode_config.mutex);
kfree(crtcs);
kfree(modes);
kfree(offsets);
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 07c07d55398b..b746c0cbaa4b 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -2857,6 +2857,7 @@ static struct drm_driver driver = {
 
.dumb_create = i915_gem_dumb_create,
.dumb_map_offset = i915_gem_mmap_gtt,
+   .initial_client_display = i915_initial_client_display,
.ioctls = i915_ioctls,
.num_ioctls = ARRAY_SIZE(i915_ioctls),
.fops = _driver_fops,
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index d4368589b355..f77f510617c5 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1720,6 +1720,9 @@ extern void intel_fbdev_fini(struct drm_i915_private 
*dev_priv);
 extern void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool 
synchronous);
 extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
 extern void intel_fbdev_restore_mode(struct drm_device *dev);
+struct drm_client_display *
+i915_initial_client_display(struct drm_device *dev, unsigned int width,
+   unsigned int height);
 #else
 static inline int intel_fbdev_init(struct drm_device *dev)
 {
@@ -1749,6 +1752,14 @@ static inline void 
intel_fbdev_output_poll_changed(struct drm_device *dev)
 static inline void intel_fbdev_restore_mode(struct drm_device *dev)
 {
 }
+
+static inline struct drm_client_display *
+i915_initial_client_display(struct drm_device *dev, unsigned int width,
+   unsigned int height)
+{
+   return NULL;
+}
+
 #endif
 
 /* intel_fbc.c */
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c 
b/drivers/gpu/drm/i915/intel_fbdev.c
index a4ab8575a72e..b7f44c9475a8 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -38,6 +38,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include "intel_drv.h"
@@ 

[RFC v4 20/25] drm/prime: Don't pin module on export for in-kernel clients

2018-04-12 Thread Noralf Trønnes
Avoid pinning the module when exporting a GEM object as a dmabuf. This
makes it possible to unload drivers that has in-kernel clients using it.
The client is removed on drm_dev_unregister() so no need to pin the driver.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_prime.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index e6052ab2bec4..f9dbe3b9db20 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -567,6 +567,30 @@ struct dma_buf *drm_gem_prime_export(struct drm_device 
*dev,
.flags = flags,
.priv = obj,
};
+   bool is_internal = false;
+   struct drm_file *file;
+
+   mutex_lock(>filelist_mutex);
+   list_for_each_entry(file, >filelist_internal, lhead) {
+   struct drm_gem_object *iter;
+   int id;
+
+   spin_lock(>table_lock);
+   idr_for_each_entry(>object_idr, iter, id) {
+   if (iter == obj) {
+   is_internal = true;
+   break;
+   }
+   }
+   spin_unlock(>table_lock);
+
+   if (is_internal)
+   break;
+   }
+   mutex_unlock(>filelist_mutex);
+
+   if (is_internal)
+   exp_info.owner = NULL;
 
if (dev->driver->gem_prime_res_obj)
exp_info.resv = dev->driver->gem_prime_res_obj(obj);
-- 
2.15.1

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


[Bug 105680] [CI] igt@kms_frontbuffer_tracking@* - fail - FBC disabled: mode too large for compression

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105680

--- Comment #11 from Jose Roberto de Souza  ---
But this tests ran with my patch merged into IGT? I don`t think that it
happened.

-- 
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 106006] Kernel 4.16.0+ switch amdgpu.dc=1 causes screen brightness set to 1 to be dimmed by default

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106006

--- Comment #3 from Joel Sass  ---
Created attachment 138806
  --> https://bugs.freedesktop.org/attachment.cgi?id=138806=edit
xrandr --verbose with amdgpu.dc=0

-- 
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 106006] Kernel 4.16.0+ switch amdgpu.dc=1 causes screen brightness set to 1 to be dimmed by default

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106006

--- Comment #1 from Joel Sass  ---
Created attachment 138804
  --> https://bugs.freedesktop.org/attachment.cgi?id=138804=edit
dmesg output with amdgpu.dc=0

-- 
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 106006] Kernel 4.16.0+ switch amdgpu.dc=1 causes screen brightness set to 1 to be dimmed by default

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106006

Bug ID: 106006
   Summary: Kernel 4.16.0+ switch amdgpu.dc=1 causes screen
brightness set to 1 to be dimmed by default
   Product: DRI
   Version: unspecified
  Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: DRM/AMDgpu
  Assignee: dri-devel@lists.freedesktop.org
  Reporter: sass.j...@gmail.com

I'm noticing that the default screen brightness of my desktop when logged in is
set to something beneath "1" when set to "1" with amdgpu.dc=1 switch in the
kernel.

Test to get to this point:

* boot PC - (Grub screen brightness is "normal")
* Set kernel value amdgpu.dc=1 and proceed with 4.16.0+ kernel boot - (kernel
switches quiet and splash removed, brightness appears normal during boot
process)
* Lightdm display manager starts (brightness is still "normal")
* Log in to any window manager, When X starts, the desktop is immediately
darkened with what appears to be a high contrast setting. Looks like equivalent
to manual setting I can't actually discern. It's not brightness, necessarily,
but the net effect on the desktop is that everything is effectively darker.
* I've tested this with Ubuntu's Unity desktop, and gnome-flashback (compiz and
metacity), and it behaves the same.



When amdgpu.dc=0 is set, desktop appears a normal level of brightness when
logging in. It appears from the Xorg.0.log that the AMDGPU module isn't used
for X, but brightness isn't affected.

I'll include logs from amdgpu.dc=0 and amdgpu.dc=1. Let me know if you need any
other logs.

-- 
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 105425] 3D & games produce periodic GPU crashes (Radeon R7 370)

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105425

--- Comment #26 from MirceaKitsune  ---
I preformed the next test suggested to me, by changing
/etc/X11/xorg.conf.d/50-device.conf to the following content:

Section "Device"
  Identifier "Default Device"
  Driver "amdgpu"
  Option "AccelMethod" "None"
EndSection

The frequency of the crash was reduced from a matter of seconds to 45 minutes,
but a freeze still occurred after that time.

-- 
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 199101] AMDGPU Fury X random screen flicker on Linux kernel 4.16rc5

2018-04-12 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=199101

--- Comment #17 from Berillions (berilli...@gmail.com) ---
Still exist for me on kernel 4.16.2 but I have less randome flickering than
kernel 4.16/4.16.1 ...

Rx560 - 4Go
Mesa-Git
llvm 5.0.1

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


Re: RFC for a render API to support adaptive sync and VRR

2018-04-12 Thread Michel Dänzer
On 2018-04-12 01:39 PM, Nicolai Hähnle wrote:
> On 12.04.2018 01:30, Cyr, Aric wrote:
>>> At least with VDPAU, video players are already explicitly specifying the
>>> target presentation time, so no changes should be required at that
>>> level. Don't know about other video APIs.
>>>
>>> The X11 Present extension protocol is also prepared for specifying the
>>> target presentation time already, the support for it just needs to be
>>> implemented.
>>
>> I'm perfectly OK with presentation time-based *API*.  I get it from a
>> user mode/app perspective, and that's fine.  We need that feedback and
>> would like help defining that portions of the stack.
>> However, I think it doesn't make as much sense as a *DDI* because it
>> doesn't correspond to any hardware real or logical (i.e. no one would
>> implement it in HW this way) and the industry specs aren't defined
>> that way.
>> You can have libdrm or some other usermode component translate your
>> presentation time into a frame duration and schedule it.  What's the
>> advantage of having this in kernel besides the fact we lose the intent
>> of the application and could prevent features and optimizations.  When
>> it gets to kernel, I think it is much more elegant for the flip
>> structure to contain a simple duration that says "hey, show this frame
>> on the screen for this long".  Then we don't need any clocks or timers
>> just some simple math and program the hardware.
> 
> There isn't necessarily an inherent advantage to having this translation
> in the kernel.

One such advantage is that it doesn't require userspace to predict the
future, where at least in the Vulkan case there is no information to
base the prediction on. I fail to see how that can work at all.


> P.S.: I'm also a little surprised that you seem to be saying that
> requesting a target present time is basically impossible (at least,
> that's kind of implied by your statement about mGPUs), and yet there's
> precedent for such APIs in both Vulkan and VDPAU.

Keep in mind that the constraint is "present no earlier than", which can
be satisfied e.g. by waiting for the target time to pass before
programming the flip to the hardware.


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


Re: [PATCH 3/3] ARM: dts: sun7i: Add support for the Ainol AW1 tablet

2018-04-12 Thread Maxime Ripard
On Thu, Apr 12, 2018 at 01:08:51AM +0200, Paul Kocialkowski wrote:
> > > + backlight: backlight {
> > > + compatible = "pwm-backlight";
> > > + pinctrl-names = "default";
> > > + pinctrl-0 = <_enable_pin>;
> > 
> > You don't need any of the pinctrl nodes for the GPIOs
> 
> I tried without the pinctrl nodes and got issues on various controllers
> (e.g. i2c for the touchscreen) because of the missing pinctrl nodes on
> 4.16. Maybe I'm missing some patches here?

You don't need any patches. What was the error exactly?

> > > + {
> > > + cpu-supply = <_dcdc2>;
> > > +};
> > 
> > How was CPUfreq tested?
> 
> In fact, I haven't tried it at all, but I can definitely do that with
> e.g. ssvb's stress test for various cpufreq functioning points.

That would be great yes.

> > > + {
> > > + pinctrl-names = "default";
> > > + pinctrl-0 = <_pins_a>;
> > > + status = "okay";
> > > + clock-frequency = <40>; /* 400 KHz required for
> > > GSL1680. */
> > 
> > I'm not sure that comment is worth it. The only device there is the
> > touchscreen, so it's kind of obvious that it's the device that needs
> > that frequency.
> 
> Well, I found a similar comment in the other dts using the same
> touchscreen controller. Since the information was rather valuable (it
> made it clear that I needed the same clock frequency for that specific
> touchscreen),

You can have the same kind of comment for pretty much all DT
lines. you could for example have on the pinctrl property just above
the comment that the I2C2 on that boards are tied to those pins. But
that's just redundant, and the SNR would be pretty bad if we were to
do it everywhere.

> it might help others in the future (even if only when grepping for
> gsl1680).
> 
> > > +
> > > + gsl1680: touchscreen@40 {
> > > + compatible = "silead,gsl1680";

You have the gsl1680 two times here, so grep would find it either way.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com


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


[PATCH] tda998x: Check ref count before invoking drm_connector_cleanup in unbind

2018-04-12 Thread Ayan Kumar Halder
In a situation when the reference count of the drm connector is greater than 1,
the unbind function should not invoke drm_connector_cleanup as this will lead
to an inconsistent state where the drm_crtc_state->connector_mask still has
a bitmask referring to the stale connector. Later, when drm driver invokes
drm_atomic_helper_shutdown() which invokes ---> drm_atomic_helper_disable_all()
 ---> drm_atomic_commit() --> drm_atomic_check_only() -->
drm_atomic_helper_check() --> drm_atomic_helper_check_modeset(). This returns
an error due to enabled/connectors mismatch.

In such a scenario, one should just return from _unbind() and let the drm driver
subsequently invoke drm_atomic_helper_shutdown. This will reset the
drm_crtc_state->connector_mask and will shutdown the crtcs. It will also 
decrement
the reference count of the connectors to 1. Subsequently, 
drm_mode_config_cleanup
will get invoked which will do the following :-

1. Decrement the reference count for each of the connectors. Thus the ref count
will reach 0 and drm_connector_funcs->destroy() gets called. Thus,
tda998x_connector_destroy() gets invoked which calls drm_connector_cleanup

2. Invokes the destroy callback for each encoder. Thus tda998x_encoder_destroy()
gets invoked.

Signed-off-by: Ayan Kumar Halder 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index 9e67a7b..8ad1cc7 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -1709,6 +1709,9 @@ static void tda998x_unbind(struct device *dev, struct 
device *master,
 {
struct tda998x_priv *priv = dev_get_drvdata(dev);
 
+   if (kref_read(>connector.base.refcount) > 1)
+   return;
+
drm_connector_cleanup(>connector);
drm_encoder_cleanup(>encoder);
tda998x_destroy(priv);
-- 
2.7.4

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


buffer sharing across VMs - xen-zcopy and hyper_dmabuf discussion

2018-04-12 Thread Dongwon Kim
(changed subject and decoupling from udmabuf thread)

On Wed, Apr 11, 2018 at 08:59:32AM +0300, Oleksandr Andrushchenko wrote:
> On 04/10/2018 08:26 PM, Dongwon Kim wrote:
> >On Tue, Apr 10, 2018 at 09:37:53AM +0300, Oleksandr Andrushchenko wrote:
> >>On 04/06/2018 09:57 PM, Dongwon Kim wrote:
> >>>On Fri, Apr 06, 2018 at 03:36:03PM +0300, Oleksandr Andrushchenko wrote:
> On 04/06/2018 02:57 PM, Gerd Hoffmann wrote:
> >   Hi,
> >
> >>>I fail to see any common ground for xen-zcopy and udmabuf ...
> >>Does the above mean you can assume that xen-zcopy and udmabuf
> >>can co-exist as two different solutions?
> >Well, udmabuf route isn't fully clear yet, but yes.
> >
> >See also gvt (intel vgpu), where the hypervisor interface is abstracted
> >away into a separate kernel modules even though most of the actual vgpu
> >emulation code is common.
> Thank you for your input, I'm just trying to figure out
> which of the three z-copy solutions intersect and how much
> >>And what about hyper-dmabuf?
> >>>xen z-copy solution is pretty similar fundamentally to hyper_dmabuf
> >>>in terms of these core sharing feature:
> >>>
> >>>1. the sharing process - import prime/dmabuf from the producer -> extract
> >>>underlying pages and get those shared -> return references for shared pages
> >Another thing is danvet was kind of against to the idea of importing existing
> >dmabuf/prime buffer and forward it to the other domain due to synchronization
> >issues. He proposed to make hyper_dmabuf only work as an exporter so that it
> >can have a full control over the buffer. I think we need to talk about this
> >further as well.
> Yes, I saw this. But this limits the use-cases so much.

I agree. Our current approach is a lot more flexible. You can find very
similar feedback in my reply to those review messages. However, I also
understand Daniel's concern as well. I believe we need more dicussion
regarding this matter.

> For instance, running Android as a Guest (which uses ION to allocate
> buffers) means that finally HW composer will import dma-buf into
> the DRM driver. Then, in case of xen-front for example, it needs to be
> shared with the backend (Host side). Of course, we can change user-space
> to make xen-front allocate the buffers (make it exporter), but what we try
> to avoid is to change user-space which in normal world would have remain
> unchanged otherwise.
> So, I do think we have to support this use-case and just have to understand
> the complexity.
> 
> >
> >danvet, can you comment on this topic?
> >
> >>>2. the page sharing mechanism - it uses Xen-grant-table.
> >>>
> >>>And to give you a quick summary of differences as far as I understand
> >>>between two implementations (please correct me if I am wrong, Oleksandr.)
> >>>
> >>>1. xen-zcopy is DRM specific - can import only DRM prime buffer
> >>>while hyper_dmabuf can export any dmabuf regardless of originator
> >>Well, this is true. And at the same time this is just a matter
> >>of extending the API: xen-zcopy is a helper driver designed for
> >>xen-front/back use-case, so this is why it only has DRM PRIME API
> >>>2. xen-zcopy doesn't seem to have dma-buf synchronization between two VMs
> >>>while (as danvet called it as remote dmabuf api sharing) hyper_dmabuf sends
> >>>out synchronization message to the exporting VM for synchronization.
> >>This is true. Again, this is because of the use-cases it covers.
> >>But having synchronization for a generic solution seems to be a good idea.
> >Yeah, understood xen-zcopy works ok with your use case. But I am just curious
> >if it is ok not to have any inter-domain synchronization in this sharing 
> >model.
> The synchronization is done with displif protocol [1]
> >The buffer being shared is technically dma-buf and originator needs to be 
> >able
> >to keep track of it.
> As I am working in DRM terms the tracking is done by the DRM core
> for me for free. (This might be one of the reasons Daniel sees DRM
> based implementation fit very good from code-reuse POV).

yeah but once you have a DRM object (whether it's dmabuf or not) on a remote
domain, it is totally new object and out of sync (correct me if I am wrong)
with original DRM prime, isn't it? How could these two different but based on
same pages be synchronized?

> >
> >>>3. 1-level references - when using grant-table for sharing pages, there 
> >>>will
> >>>be same # of refs (each 8 byte)
> >>To be precise, grant ref is 4 bytes
> >You are right. Thanks for correction.;)
> >
> >>>as # of shared pages, which is passed to
> >>>the userspace to be shared with importing VM in case of xen-zcopy.
> >>The reason for that is that xen-zcopy is a helper driver, e.g.
> >>the grant references come from the display backend [1], which implements
> >>Xen display protocol [2]. So, effectively the backend extracts references
> >>from frontend's requests and passes those to xen-zcopy as an array
> >>of refs.
> >>>  Compared
> >>>to 

[Bug 104216] Firefox quirks (black and/or white squares)

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=104216

Michel Dänzer  changed:

   What|Removed |Added

 Resolution|--- |NOTOURBUG
 Status|NEW |RESOLVED

--- Comment #28 from Michel Dänzer  ---
PID 22401 has 781 /dev/shm/org.chromium.* files open. This looks like a Firefox
issue.

-- 
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 105425] 3D & games produce periodic GPU crashes (Radeon R7 370)

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105425

--- Comment #25 from MirceaKitsune  ---
Created attachment 138799
  --> https://bugs.freedesktop.org/attachment.cgi?id=138799=edit
GALLIUM_HUD post crash photo

-- 
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 105425] 3D & games produce periodic GPU crashes (Radeon R7 370)

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105425

--- Comment #24 from MirceaKitsune  ---
Created attachment 138798
  --> https://bugs.freedesktop.org/attachment.cgi?id=138798=edit
GALLIUM_HUD pre crash screenshot

-- 
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 105425] 3D & games produce periodic GPU crashes (Radeon R7 370)

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105425

--- Comment #23 from MirceaKitsune  ---
I just finished running the GALLIUM_HUD test, and will be taking a look at the
other options next. It was more difficult to test now since the freeze occurs
almost instantly after Xonotic loads the map (only a few seconds).

I managed to make two photos which I'll attach below: One is the last
screenshot I managed to take within the system a few seconds before it froze.
The other is a photo of my screen after the freeze has taken place, obviously
taken with my phone camera as the computer itself was bricked.

A footnote I will add, even if I don't know whether people will even believe
me: I had to take those screenshots several times because they kept getting
deleted. Whenever I booted the machine back, every screenshot of Xonotic with
this HUD was corrupted and turned into a 0 byte file... even ones that were
quickly moved to other directories precisely to avoid this, and were also taken
by an external process! Other files on my drive are fine, it's only those
screenshots... thankfully one survived and it shows all of the graphs and
parameters right before the crash. I'm legitimately crept out, as I didn't
expect a potential attack program to contain software capable of identifying
and deleting evidence of testing, which is the only explanation I can find for
what I just saw. I'll do the next tests carefully as I don't know what else may
happen to my computer.

-- 
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] drm/amdgpu: limit DMA size to PAGE_SIZE for scatter-gather buffers

2018-04-12 Thread Robin Murphy

On 12/04/18 10:42, Christian König wrote:

Am 12.04.2018 um 08:26 schrieb Christoph Hellwig:

On Wed, Apr 11, 2018 at 01:03:59PM +0100, Robin Murphy wrote:

On 10/04/18 21:59, Sinan Kaya wrote:

Code is expecing to observe the same number of buffers returned from
dma_map_sg() function compared to sg_alloc_table_from_pages(). This
doesn't hold true universally especially for systems with IOMMU.
So why not fix said code? It's clearly not a real hardware 
limitation, and
the map_sg() APIs have potentially returned fewer than nents since 
forever,

so there's really no excuse.

Yes, relying on dma_map_sg returning the same number of entries as passed
it is completely bogus.


I agree that the common DRM functions should be able to deal with both, 
but we should let the driver side decide if it wants multiple addresses 
combined or not.





IOMMU driver tries to combine buffers into a single DMA address as much
as it can. The right thing is to tell the DMA layer how much combining
IOMMU can do.

Disagree; this is a dodgy hack, since you'll now end up passing
scatterlists into dma_map_sg() which already violate max_seg_size to 
begin
with, and I think a conscientious DMA API implementation would be at 
rights
to fail the mapping for that reason (I know arm64 happens not to, but 
that

was a deliberate design decision to make my life easier at the time).

Agreed.


Sounds like my understanding of max_seg_size is incorrect, what exactly 
should that describe?


The segment size and boundary mask are there to represent a device's 
hardware scatter-gather capabilities - a lot of things have limits on 
the size and alignment of the data pointed to by a single descriptor 
(e.g. an xHCI TRB, where the data buffer must not cross a 64KB boundary) 
- although they can also be relevant to non-scatter-gather devices if 
they just have limits on how big/aligned a single DMA transfer can be.


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


[RFC v4 11/25] drm/connector: Add connector array functions

2018-04-12 Thread Noralf Trønnes
Add functions to deal with the registred connectors as an array:
- drm_connector_get_all()
- drm_connector_put_all()

And to get the enabled status of those connectors:
drm_connector_get_enabled_status()

This is prep work to remove struct drm_fb_helper_connector.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_connector.c | 105 
 include/drm/drm_connector.h |   5 ++
 2 files changed, 110 insertions(+)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index b9eb143d70fc..25c333c05a4e 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1854,3 +1854,108 @@ drm_connector_pick_cmdline_mode(struct drm_connector 
*connector)
return mode;
 }
 EXPORT_SYMBOL(drm_connector_pick_cmdline_mode);
+
+/**
+ * drm_connector_get_all - Get all connectors into an array
+ * @dev: DRM device
+ * @connectors: Returned connector array
+ *
+ * This function iterates through all registered connectors and adds them to an
+ * array allocated by this function. A ref is taken on the connectors.
+ *
+ * Use drm_connector_put_all() to drop refs and free the array.
+ *
+ * Returns:
+ * Number of connectors or -ENOMEM on failure.
+ */
+int drm_connector_get_all(struct drm_device *dev, struct drm_connector 
***connectors)
+{
+   struct drm_connector *connector, **temp, **conns = NULL;
+   struct drm_connector_list_iter conn_iter;
+   int connector_count = 0;
+
+   drm_connector_list_iter_begin(dev, _iter);
+   drm_for_each_connector_iter(connector, _iter) {
+   temp = krealloc(conns, (connector_count + 1) * sizeof(*conns), 
GFP_KERNEL);
+   if (!temp)
+   goto err_put_free;
+
+   conns = temp;
+   conns[connector_count++] = connector;
+   drm_connector_get(connector);
+   }
+   drm_connector_list_iter_end(_iter);
+
+   *connectors = conns;
+
+   return connector_count;
+
+err_put_free:
+   drm_connector_list_iter_end(_iter);
+   drm_connector_put_all(conns, connector_count);
+
+   return -ENOMEM;
+}
+EXPORT_SYMBOL(drm_connector_get_all);
+
+/**
+ * drm_connector_put_all - Put and free connector array
+ * @connectors: Array of connectors
+ * @connector_count: Number of connectors in the array (can be negative or 
zero)
+ *
+ * This function drops the ref on the connectors an frees the array.
+ */
+void drm_connector_put_all(struct drm_connector **connectors, int 
connector_count)
+{
+   int i;
+
+   if (connector_count < 1)
+   return;
+
+   for (i = 0; i < connector_count; i++)
+   drm_connector_put(connectors[i]);
+   kfree(connectors);
+}
+EXPORT_SYMBOL(drm_connector_put_all);
+
+/**
+ * drm_connector_get_enabled_status - Get enabled status on connectors
+ * @connectors: Array of connectors
+ * @connector_count: Number of connectors in the array
+ *
+ * This loops over the connector array and sets enabled if connector status is
+ * _connected_. If no connectors are connected, a new pass is done and
+ * connectors that are not _disconnected_ are set enabled.
+ *
+ * The caller is responsible for freeing the array using kfree().
+ *
+ * Returns:
+ * A boolean array of connector enabled statuses or NULL on allocation failure.
+ */
+bool *drm_connector_get_enabled_status(struct drm_connector **connectors,
+  unsigned int connector_count)
+{
+   bool *enabled, any_enabled = false;
+   unsigned int i;
+
+   enabled = kcalloc(connector_count, sizeof(*enabled), GFP_KERNEL);
+   if (!enabled)
+   return NULL;
+
+   for (i = 0; i < connector_count; i++) {
+   if (connectors[i]->status == connector_status_connected) {
+   enabled[i] = true;
+   any_enabled = true;
+   }
+   }
+
+   if (any_enabled)
+   return enabled;
+
+   for (i = 0; i < connector_count; i++)
+   if (connectors[i]->status != connector_status_disconnected)
+   enabled[i] = true;
+
+   return enabled;
+}
+EXPORT_SYMBOL(drm_connector_get_enabled_status);
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 9cb4ca42373c..c3556a5f40c9 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -1169,4 +1169,9 @@ drm_connector_has_preferred_mode(struct drm_connector 
*connector,
 struct drm_display_mode *
 drm_connector_pick_cmdline_mode(struct drm_connector *connector);
 
+int drm_connector_get_all(struct drm_device *dev, struct drm_connector 
***connectors);
+void drm_connector_put_all(struct drm_connector **connectors, int 
connector_count);
+bool *drm_connector_get_enabled_status(struct drm_connector **connectors,
+  unsigned int connector_count);
+
 #endif
-- 
2.15.1


[RFC v4 04/25] drm/fb-helper: Remove drm_fb_helper_debug_enter/leave()

2018-04-12 Thread Noralf Trønnes
Atomic drivers can't use them so finish what was started in
commit 9c79e0b1d096 ("drm/fb-helper: Give up on kgdb for atomic drivers").

This prepares the ground for creating modesets on demand.

TODO:
- Actually remove the functions, not just the contents.
- Nuke drm_crtc_helper_funcs->mode_set_base_atomic
- Documentation/dev-tools/kgdb.rst

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 82 -
 1 file changed, 82 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index e48ace2d55f5..06e94de6452a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -267,96 +267,14 @@ int drm_fb_helper_remove_one_connector(struct 
drm_fb_helper *fb_helper,
 }
 EXPORT_SYMBOL(drm_fb_helper_remove_one_connector);
 
-static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)
-{
-   uint16_t *r_base, *g_base, *b_base;
-
-   if (crtc->funcs->gamma_set == NULL)
-   return;
-
-   r_base = crtc->gamma_store;
-   g_base = r_base + crtc->gamma_size;
-   b_base = g_base + crtc->gamma_size;
-
-   crtc->funcs->gamma_set(crtc, r_base, g_base, b_base,
-  crtc->gamma_size, NULL);
-}
-
-/**
- * drm_fb_helper_debug_enter - implementation for _ops.fb_debug_enter
- * @info: fbdev registered by the helper
- */
 int drm_fb_helper_debug_enter(struct fb_info *info)
 {
-   struct drm_fb_helper *helper = info->par;
-   const struct drm_crtc_helper_funcs *funcs;
-   int i;
-
-   list_for_each_entry(helper, _fb_helper_list, kernel_fb_list) {
-   for (i = 0; i < helper->crtc_count; i++) {
-   struct drm_mode_set *mode_set =
-   >crtc_info[i].mode_set;
-
-   if (!mode_set->crtc->enabled)
-   continue;
-
-   funcs = mode_set->crtc->helper_private;
-   if (funcs->mode_set_base_atomic == NULL)
-   continue;
-
-   if (drm_drv_uses_atomic_modeset(mode_set->crtc->dev))
-   continue;
-
-   funcs->mode_set_base_atomic(mode_set->crtc,
-   mode_set->fb,
-   mode_set->x,
-   mode_set->y,
-   ENTER_ATOMIC_MODE_SET);
-   }
-   }
-
return 0;
 }
 EXPORT_SYMBOL(drm_fb_helper_debug_enter);
 
-/**
- * drm_fb_helper_debug_leave - implementation for _ops.fb_debug_leave
- * @info: fbdev registered by the helper
- */
 int drm_fb_helper_debug_leave(struct fb_info *info)
 {
-   struct drm_fb_helper *helper = info->par;
-   struct drm_crtc *crtc;
-   const struct drm_crtc_helper_funcs *funcs;
-   struct drm_framebuffer *fb;
-   int i;
-
-   for (i = 0; i < helper->crtc_count; i++) {
-   struct drm_mode_set *mode_set = >crtc_info[i].mode_set;
-
-   crtc = mode_set->crtc;
-   if (drm_drv_uses_atomic_modeset(crtc->dev))
-   continue;
-
-   funcs = crtc->helper_private;
-   fb = crtc->primary->fb;
-
-   if (!crtc->enabled)
-   continue;
-
-   if (!fb) {
-   DRM_ERROR("no fb to restore??\n");
-   continue;
-   }
-
-   if (funcs->mode_set_base_atomic == NULL)
-   continue;
-
-   drm_fb_helper_restore_lut_atomic(mode_set->crtc);
-   funcs->mode_set_base_atomic(mode_set->crtc, fb, crtc->x,
-   crtc->y, LEAVE_ATOMIC_MODE_SET);
-   }
-
return 0;
 }
 EXPORT_SYMBOL(drm_fb_helper_debug_leave);
-- 
2.15.1

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


Re: [PATCH 1/2] drm/prime: Iterate SG DMA addresses separately

2018-04-12 Thread Robin Murphy

On 12/04/18 11:33, Christian König wrote:

Am 12.04.2018 um 11:49 schrieb Lucas Stach:

Am Donnerstag, den 12.04.2018, 11:35 +0200 schrieb Christian König:

Am 12.04.2018 um 11:11 schrieb Lucas Stach:

Am Mittwoch, den 11.04.2018, 20:26 +0200 schrieb Christian König:

Am 11.04.2018 um 19:11 schrieb Robin Murphy:
For dma_map_sg(), DMA API implementations are free to merge 
consecutive
segments into a single DMA mapping if conditions are suitable, 
thus the

resulting DMA addresses may be packed into fewer entries than
ttm->sg->nents implies.

drm_prime_sg_to_page_addr_arrays() does not account for this, meaning
its callers either have to reject the 0 < count < nents case or risk
getting bogus addresses back later. Fortunately this is relatively 
easy
to deal with having to rejig structures to also store the mapped 
count,

since the total DMA length should still be equal to the total buffer
length. All we need is a separate scatterlist cursor to iterate 
the DMA

addresses separately from the CPU addresses.

Mhm, I think I like Sinas approach better.

See the hardware actually needs the dma_address on a page by page 
basis.


Joining multiple consecutive pages into one entry is just additional
overhead which we don't need.


Note that the merging done inside dma_map_sg() is pretty trivial in 
itself (it's effectively just the inverse of the logic in this patch). 
The "overhead" here is inherent in calling sg_alloc_table_from_pages() 
and dma_map_sg() at all.



But setting MAX_SEGMENT_SIZE will probably prevent an IOMMU that might
be in front of your GPU to map large pages as such, causing additional
overhead by means of additional TLB misses and page walks on the IOMMU
side.

And wouldn't you like to use huge pages at the GPU side, if the IOMMU
already provides you the service of producing one large consecutive
address range, rather than mapping them via a number of small pages?

No, I wouldn't like to use that. We're already using that :)

But we use huge pages by allocating consecutive chunks of memory so that
both the CPU as well as the GPU can increase their TLB hit rate.

I'm not convinced that this is a universal win. Many GPU buffers aren't
accessed by the CPU and allocating huge pages puts much more strain on
the kernel MM subsystem.


Yeah, we indeed see the extra overhead during allocation.


What currently happens is that the DMA subsystem tries to coalesce
multiple pages into on SG entry and we de-coalesce that inside the
driver again to create our random access array.

I guess the right thing would be to have a flag that tells the the DMA
implementation to not coalesce the entries. But (ab-)using max segment
size tells the DMA API to split the segments if they are larger than
the given size, which is probably not what you want either as you now
need to coalesce the segments again when you are mapping real huge
pages.


No, even with huge pages I need an array with every single dma address 
for a 4K pages (or whatever the normal page size is).


The problem is that I need a random access array for the DMA addresses, 
even when they are continuously.


OK, that makes me wonder if you even need dma_map_sg() in this case. 
From the sound of that it would be a lot simpler to just call 
dma_map_page() in a loop over the pair of arrays. AFAICS that's what TTM 
already does in most places.


I agree that max segment size is a bit ugly here, but at least for 
radeon, amdgpu and pretty much TTM in general it is exactly what I need.


I could fix TTM to not need that, but for radeon and amdgpu it is the 
hardware which needs this.


Sorry, I don't follow - how does the hardware care about the format of 
an intermediate data structure used to *generate* the dma_address array? 
That's all that I'm proposing to fix here.


Robin.



Christian.




That is a huge waste of memory and CPU cycles and I actually wanted to
get rid of it for quite some time now. Sinas approach seems to be a good
step into the right direction to me to actually clean that up.


Detecting such a condition is much easier if the DMA map implementation
gives you the coalesced scatter entries.

A way which preserves both path would be indeed nice to have, but that
only allows for the TLB optimization for the GPU and not the CPU any
more. So I actually see that as really minor use case.

Some of the Tegras have much larger TLBs and better page-walk
performance on the system IOMMU compared to the GPU MMU, so they would
probably benefit a good deal even if the hugepage optimization only
targets the GPU side.

Regards,
Lucas



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


[RFC v4 10/25] drm/connector: Add drm_connector_has_preferred_mode/pick_cmdline_mode()

2018-04-12 Thread Noralf Trønnes
Move them over from drm_fb_helper since they are connector functions.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_connector.c| 94 ++
 drivers/gpu/drm/drm_fb_helper.c| 75 ++
 drivers/gpu/drm/i915/intel_fbdev.c |  7 +--
 include/drm/drm_connector.h|  6 +++
 include/drm/drm_fb_helper.h| 19 
 5 files changed, 108 insertions(+), 93 deletions(-)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index b3cde897cd80..b9eb143d70fc 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1760,3 +1760,97 @@ struct drm_tile_group *drm_mode_create_tile_group(struct 
drm_device *dev,
return tg;
 }
 EXPORT_SYMBOL(drm_mode_create_tile_group);
+
+/**
+ * drm_connector_has_preferred_mode() - Lookup preferred display mode
+ * @connector: DRM connector
+ * @width: Max width
+ * @height: Max height
+ *
+ * Look for a preferred display mode within the bounds of @width and @height
+ * (inclusive).
+ *
+ * Returns:
+ * A _display_mode or NULL.
+ */
+struct drm_display_mode *
+drm_connector_has_preferred_mode(struct drm_connector *connector,
+int width, int height)
+{
+   struct drm_display_mode *mode;
+
+   list_for_each_entry(mode, >modes, head) {
+   if (mode->hdisplay > width || mode->vdisplay > height)
+   continue;
+   if (mode->type & DRM_MODE_TYPE_PREFERRED)
+   return mode;
+   }
+
+   return NULL;
+}
+EXPORT_SYMBOL(drm_connector_has_preferred_mode);
+
+/**
+ * drm_connector_pick_cmdline_mode() - Get commandline display mode
+ * @connector: DRM connector
+ *
+ * Return the display mode specified on the kernel commandline or NULL if not
+ * specified.
+ *
+ * Returns:
+ * A _display_mode or NULL.
+ */
+struct drm_display_mode *
+drm_connector_pick_cmdline_mode(struct drm_connector *connector)
+{
+   struct drm_cmdline_mode *cmdline_mode;
+   struct drm_display_mode *mode;
+   bool prefer_non_interlace;
+
+   cmdline_mode = >cmdline_mode;
+   if (!cmdline_mode->specified)
+   return NULL;
+
+   /* attempt to find a matching mode in the list of modes
+*  we have gotten so far, if not add a CVT mode that conforms
+*/
+   if (cmdline_mode->rb || cmdline_mode->margins)
+   goto create_mode;
+
+   prefer_non_interlace = !cmdline_mode->interlace;
+again:
+   list_for_each_entry(mode, >modes, head) {
+   /* check width/height */
+   if (mode->hdisplay != cmdline_mode->xres ||
+   mode->vdisplay != cmdline_mode->yres)
+   continue;
+
+   if (cmdline_mode->refresh_specified) {
+   if (mode->vrefresh != cmdline_mode->refresh)
+   continue;
+   }
+
+   if (cmdline_mode->interlace) {
+   if (!(mode->flags & DRM_MODE_FLAG_INTERLACE))
+   continue;
+   } else if (prefer_non_interlace) {
+   if (mode->flags & DRM_MODE_FLAG_INTERLACE)
+   continue;
+   }
+
+   return mode;
+   }
+
+   if (prefer_non_interlace) {
+   prefer_non_interlace = false;
+   goto again;
+   }
+
+create_mode:
+   mode = drm_mode_create_from_cmdline_mode(connector->dev,
+cmdline_mode);
+   list_add(>head, >modes);
+
+   return mode;
+}
+EXPORT_SYMBOL(drm_connector_pick_cmdline_mode);
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 785a2f5d2647..b992f59dad30 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1774,78 +1774,11 @@ static int drm_fb_helper_probe_connector_modes(struct 
drm_fb_helper *fb_helper,
return count;
 }
 
-struct drm_display_mode *drm_has_preferred_mode(struct drm_fb_helper_connector 
*fb_connector, int width, int height)
-{
-   struct drm_display_mode *mode;
-
-   list_for_each_entry(mode, _connector->connector->modes, head) {
-   if (mode->hdisplay > width ||
-   mode->vdisplay > height)
-   continue;
-   if (mode->type & DRM_MODE_TYPE_PREFERRED)
-   return mode;
-   }
-   return NULL;
-}
-EXPORT_SYMBOL(drm_has_preferred_mode);
-
 static bool drm_has_cmdline_mode(struct drm_fb_helper_connector *fb_connector)
 {
return fb_connector->connector->cmdline_mode.specified;
 }
 
-struct drm_display_mode *drm_pick_cmdline_mode(struct drm_fb_helper_connector 
*fb_helper_conn)
-{
-   struct drm_cmdline_mode *cmdline_mode;
-   struct drm_display_mode *mode;
-   bool prefer_non_interlace;
-
-   cmdline_mode = 

[RFC v4 09/25] drm/fb-helper: Move modeset commit code to drm_client

2018-04-12 Thread Noralf Trønnes
This moves the committing part of the modesetting code to drm_client.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_client.c| 242 
 drivers/gpu/drm/drm_fb_helper.c | 216 +--
 include/drm/drm_client.h|   8 ++
 3 files changed, 252 insertions(+), 214 deletions(-)

diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index 7c31a6efb2f4..c85c13568cf9 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -10,6 +10,8 @@
 
 #include 
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -117,3 +119,243 @@ drm_client_display_find_modeset(struct drm_client_display 
*display, struct drm_c
return NULL;
 }
 EXPORT_SYMBOL(drm_client_display_find_modeset);
+
+/**
+ * drm_client_display_panel_rotation() - Check panel orientation
+ * @connector: DRM connector
+ * @plane: DRM plane
+ * @rotation: Returned rotation value
+ *
+ * This function checks if @plane can hw rotate to match the panel orientation
+ * on @connector.
+ *
+ * Return:
+ * True if the plane can do the rotation, false otherwise.
+ */
+bool drm_client_display_panel_rotation(struct drm_connector *connector,
+  struct drm_plane *plane,
+  unsigned int *rotation)
+{
+   uint64_t valid_mask = 0;
+   unsigned int i;
+
+   if (!connector)
+   return false;
+
+   switch (connector->display_info.panel_orientation) {
+   case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
+   *rotation = DRM_MODE_ROTATE_180;
+   break;
+   case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
+   *rotation = DRM_MODE_ROTATE_90;
+   break;
+   case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
+   *rotation = DRM_MODE_ROTATE_270;
+   break;
+   default:
+   *rotation = DRM_MODE_ROTATE_0;
+   }
+
+   /*
+* TODO: support 90 / 270 degree hardware rotation,
+* depending on the hardware this may require the framebuffer
+* to be in a specific tiling format.
+*/
+   if (*rotation != DRM_MODE_ROTATE_180 || !plane->rotation_property)
+   return false;
+
+   for (i = 0; i < plane->rotation_property->num_values; i++)
+   valid_mask |= (1ULL << plane->rotation_property->values[i]);
+
+   if (!(*rotation & valid_mask))
+   return false;
+
+   return true;
+}
+EXPORT_SYMBOL(drm_client_display_panel_rotation);
+
+static int drm_client_display_restore_atomic(struct drm_client_display 
*display, bool active)
+{
+   struct drm_device *dev = display->dev;
+   struct drm_plane_state *plane_state;
+   struct drm_mode_set *mode_set;
+   struct drm_plane *plane;
+   struct drm_atomic_state *state;
+   int ret;
+   unsigned int plane_mask;
+   struct drm_modeset_acquire_ctx ctx;
+
+   drm_modeset_acquire_init(, 0);
+
+   state = drm_atomic_state_alloc(dev);
+   if (!state) {
+   ret = -ENOMEM;
+   goto out_ctx;
+   }
+
+   state->acquire_ctx = 
+retry:
+   plane_mask = 0;
+   drm_for_each_plane(plane, dev) {
+   plane_state = drm_atomic_get_plane_state(state, plane);
+   if (IS_ERR(plane_state)) {
+   ret = PTR_ERR(plane_state);
+   goto out_state;
+   }
+
+   plane_state->rotation = DRM_MODE_ROTATE_0;
+
+   plane->old_fb = plane->fb;
+   plane_mask |= 1 << drm_plane_index(plane);
+
+   /* disable non-primary: */
+   if (plane->type == DRM_PLANE_TYPE_PRIMARY)
+   continue;
+
+   ret = drm_atomic_disable_plane(plane, plane_state);
+   if (ret != 0)
+   goto out_state;
+   }
+
+   drm_client_display_for_each_modeset(mode_set, display) {
+   struct drm_plane *primary = mode_set->crtc->primary;
+   unsigned int rotation;
+
+   if (drm_client_display_panel_rotation(mode_set->connectors[0], 
primary, )) {
+   /* Cannot fail as we've already gotten the plane state 
above */
+   plane_state = drm_atomic_get_new_plane_state(state, 
primary);
+   plane_state->rotation = rotation;
+   }
+
+   ret = drm_atomic_set_config(mode_set, state);
+   if (ret != 0)
+   goto out_state;
+
+   /*
+* drm_atomic_set_config() sets active when a
+* mode is set, unconditionally clear it if we force DPMS off
+*/
+   if (!active) {
+   struct drm_crtc *crtc = mode_set->crtc;
+   struct drm_crtc_state *crtc_state = 
drm_atomic_get_new_crtc_state(state, crtc);
+
+   

[RFC v4 08/25] drm/fb-helper: Use struct drm_client_display

2018-04-12 Thread Noralf Trønnes
Prepare to move the modeset committing code to drm_client.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 161 
 include/drm/drm_fb_helper.h |   8 ++
 2 files changed, 89 insertions(+), 80 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 2eef24db21f8..bdb4b57d2c12 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -321,13 +322,14 @@ static bool drm_fb_helper_panel_rotation(struct 
drm_connector *connector,
return true;
 }
 
-static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool 
active)
+static int drm_client_display_restore_atomic(struct drm_client_display 
*display, bool active)
 {
-   struct drm_device *dev = fb_helper->dev;
+   struct drm_device *dev = display->dev;
struct drm_plane_state *plane_state;
+   struct drm_mode_set *mode_set;
struct drm_plane *plane;
struct drm_atomic_state *state;
-   int i, ret;
+   int ret;
unsigned int plane_mask;
struct drm_modeset_acquire_ctx ctx;
 
@@ -363,8 +365,7 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper 
*fb_helper, bool activ
goto out_state;
}
 
-   for (i = 0; i < fb_helper->crtc_count; i++) {
-   struct drm_mode_set *mode_set = 
_helper->crtc_info[i].mode_set;
+   drm_client_display_for_each_modeset(mode_set, display) {
struct drm_plane *primary = mode_set->crtc->primary;
unsigned int rotation;
 
@@ -412,13 +413,14 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper 
*fb_helper, bool activ
goto retry;
 }
 
-static int restore_fbdev_mode_legacy(struct drm_fb_helper *fb_helper)
+static int drm_client_display_restore_legacy(struct drm_client_display 
*display)
 {
-   struct drm_device *dev = fb_helper->dev;
+   struct drm_device *dev = display->dev;
+   struct drm_mode_set *mode_set;
struct drm_plane *plane;
-   int i, ret = 0;
+   int ret = 0;
 
-   drm_modeset_lock_all(fb_helper->dev);
+   drm_modeset_lock_all(dev);
drm_for_each_plane(plane, dev) {
if (plane->type != DRM_PLANE_TYPE_PRIMARY)
drm_plane_force_disable(plane);
@@ -429,8 +431,7 @@ static int restore_fbdev_mode_legacy(struct drm_fb_helper 
*fb_helper)
DRM_MODE_ROTATE_0);
}
 
-   for (i = 0; i < fb_helper->crtc_count; i++) {
-   struct drm_mode_set *mode_set = 
_helper->crtc_info[i].mode_set;
+   drm_client_display_for_each_modeset(mode_set, display) {
struct drm_crtc *crtc = mode_set->crtc;
 
if (crtc->funcs->cursor_set2) {
@@ -448,19 +449,17 @@ static int restore_fbdev_mode_legacy(struct drm_fb_helper 
*fb_helper)
goto out;
}
 out:
-   drm_modeset_unlock_all(fb_helper->dev);
+   drm_modeset_unlock_all(dev);
 
return ret;
 }
 
-static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
+static int drm_client_display_restore(struct drm_client_display *display)
 {
-   struct drm_device *dev = fb_helper->dev;
-
-   if (drm_drv_uses_atomic_modeset(dev))
-   return restore_fbdev_mode_atomic(fb_helper, true);
+   if (drm_drv_uses_atomic_modeset(display->dev))
+   return drm_client_display_restore_atomic(display, true);
else
-   return restore_fbdev_mode_legacy(fb_helper);
+   return drm_client_display_restore_legacy(display);
 }
 
 /**
@@ -486,7 +485,7 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct 
drm_fb_helper *fb_helper)
return 0;
 
mutex_lock(_helper->lock);
-   ret = restore_fbdev_mode(fb_helper);
+   ret = drm_client_display_restore(fb_helper->display);
 
do_delayed = fb_helper->delayed_hotplug;
if (do_delayed)
@@ -548,7 +547,7 @@ static bool drm_fb_helper_force_kernel_mode(void)
continue;
 
mutex_lock(>lock);
-   ret = restore_fbdev_mode(helper);
+   ret = drm_client_display_restore(helper->display);
if (ret)
error = true;
mutex_unlock(>lock);
@@ -580,22 +579,20 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op 
= {
 static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };
 #endif
 
-static void dpms_legacy(struct drm_fb_helper *fb_helper, int dpms_mode)
+static void drm_client_display_dpms_legacy(struct drm_client_display *display, 
int dpms_mode)
 {
-   struct drm_device *dev = fb_helper->dev;
+   struct drm_device *dev = display->dev;
struct drm_connector *connector;
struct drm_mode_set *modeset;
-   

[RFC v4 05/25] drm/fb-helper: dpms_legacy(): Only set on connectors in use

2018-04-12 Thread Noralf Trønnes
For each enabled crtc the functions sets dpms on all registered connectors.
Limit this to only doing it once and on the connectors actually in use.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 06e94de6452a..d0936671a9a6 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -583,20 +583,19 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op 
= { };
 static void dpms_legacy(struct drm_fb_helper *fb_helper, int dpms_mode)
 {
struct drm_device *dev = fb_helper->dev;
-   struct drm_crtc *crtc;
struct drm_connector *connector;
+   struct drm_mode_set *modeset;
int i, j;
 
drm_modeset_lock_all(dev);
for (i = 0; i < fb_helper->crtc_count; i++) {
-   crtc = fb_helper->crtc_info[i].mode_set.crtc;
+   modeset = _helper->crtc_info[i].mode_set;
 
-   if (!crtc->enabled)
+   if (!modeset->crtc->enabled)
continue;
 
-   /* Walk the connectors & encoders on this fb turning them 
on/off */
-   drm_fb_helper_for_each_connector(fb_helper, j) {
-   connector = fb_helper->connector_info[j]->connector;
+   for (j = 0; j < modeset->num_connectors; j++) {
+   connector = modeset->connectors[j];
connector->funcs->dpms(connector, dpms_mode);
drm_object_property_set_value(>base,
dev->mode_config.dpms_property, dpms_mode);
-- 
2.15.1

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


[RFC v4 07/25] drm: Begin an API for in-kernel clients

2018-04-12 Thread Noralf Trønnes
This the beginning of an API for in-kernel clients.
First out is a display representation that will be used by drm_fb_helper
in order to move out its mode setting code.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/Makefile |   2 +-
 drivers/gpu/drm/drm_client.c | 119 +++
 include/drm/drm_client.h |  44 
 3 files changed, 164 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/drm_client.c
 create mode 100644 include/drm/drm_client.h

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 9d66657ea117..d25afa136d8f 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -18,7 +18,7 @@ drm-y   :=drm_auth.o drm_bufs.o drm_cache.o \
drm_encoder.o drm_mode_object.o drm_property.o \
drm_plane.o drm_color_mgmt.o drm_print.o \
drm_dumb_buffers.o drm_mode_config.o drm_vblank.o \
-   drm_syncobj.o drm_lease.o
+   drm_syncobj.o drm_lease.o drm_client.o
 
 drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
 drm-$(CONFIG_DRM_VM) += drm_vm.o
diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
new file mode 100644
index ..7c31a6efb2f4
--- /dev/null
+++ b/drivers/gpu/drm/drm_client.c
@@ -0,0 +1,119 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2018 Noralf Trønnes
+ *
+ * For parts copied from drm_fb_helper:
+ * Copyright (c) 2006-2009 Red Hat Inc.
+ * Copyright (c) 2006-2008 Intel Corporation
+ * Copyright (c) 2007 Dave Airlie 
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+ * drm_client_display_create() - Create display structure
+ * @dev: DRM device
+ *
+ * This function creates a display structure for clients backed by an array of
+ * _mode_set, one per CRTC.
+ *
+ * Returns:
+ * A _client_display or an error pointer on allocation failure.
+ */
+struct drm_client_display *drm_client_display_create(struct drm_device *dev)
+{
+   unsigned int num_crtc = dev->mode_config.num_crtc;
+   struct drm_client_display *display;
+   struct drm_mode_set *modeset;
+   struct drm_crtc *crtc;
+   unsigned int i = 0;
+
+   display = kzalloc(sizeof(*display), GFP_KERNEL);
+   if (!display)
+   return ERR_PTR(-ENOMEM);
+
+   /* Add NULL terminating entry to enable index less iteration */
+   display->modesets = kcalloc(num_crtc + 1, sizeof(*display->modesets), 
GFP_KERNEL);
+   if (!display->modesets) {
+   kfree(display);
+   return ERR_PTR(-ENOMEM);
+   }
+
+   display->dev = dev;
+   display->modeset_count = num_crtc;
+
+   drm_for_each_crtc(crtc, dev)
+   display->modesets[i++].crtc = crtc;
+
+   drm_client_display_for_each_modeset(modeset, display) {
+   /* One connector per crtc except for the cloned case */
+   modeset->connectors = kcalloc(2, sizeof(*modeset->connectors), 
GFP_KERNEL);
+   if (!modeset->connectors)
+   goto err_free;
+   }
+
+   return display;
+
+err_free:
+   drm_client_display_free(display);
+
+   return ERR_PTR(-ENOMEM);
+}
+EXPORT_SYMBOL(drm_client_display_create);
+
+/**
+ * drm_client_display_free() - Free display structure
+ * @display: Client display
+ *
+ * This function frees the structure allocated by drm_client_display_create().
+ * It also destroys display modes and puts connectors.
+ */
+void drm_client_display_free(struct drm_client_display *display)
+{
+   struct drm_mode_set *modeset;
+   unsigned int i;
+
+   if (!display)
+   return;
+
+   drm_client_display_for_each_modeset(modeset, display) {
+   if (modeset->mode)
+   drm_mode_destroy(display->dev, modeset->mode);
+
+   for (i = 0; i < modeset->num_connectors; i++)
+   drm_connector_put(modeset->connectors[i]);
+   kfree(modeset->connectors);
+   }
+   kfree(display->modesets);
+   kfree(display);
+}
+EXPORT_SYMBOL(drm_client_display_free);
+
+/**
+ * drm_client_display_find_modeset() - Find modeset matching a CRTC
+ * @display: Client display
+ * @crtc: CRTC
+ *
+ * This function looks up the @display modeset connected to @crtc.
+ *
+ * Returns:
+ * A _mode_set or NULL.
+ */
+struct drm_mode_set *
+drm_client_display_find_modeset(struct drm_client_display *display, struct 
drm_crtc *crtc)
+{
+   struct drm_mode_set *modeset;
+
+   drm_client_display_for_each_modeset(modeset, display)
+   if (modeset->crtc == crtc)
+   return modeset;
+
+   return NULL;
+}
+EXPORT_SYMBOL(drm_client_display_find_modeset);
diff --git a/include/drm/drm_client.h b/include/drm/drm_client.h
new file mode 100644
index ..b6a057802769
--- /dev/null
+++ b/include/drm/drm_client.h
@@ -0,0 +1,44 @@
+/* 

[RFC v4 03/25] drm/fb-helper: No need to cache rotation and sw_rotations

2018-04-12 Thread Noralf Trønnes
Getting rotation info is cheap so we can do it on demand.

This is done in preparation for the removal of struct drm_fb_helper_crtc.

Cc: Hans de Goede 
Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 131 
 include/drm/drm_fb_helper.h |   8 ---
 2 files changed, 65 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 0646b108030b..e48ace2d55f5 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -361,6 +361,48 @@ int drm_fb_helper_debug_leave(struct fb_info *info)
 }
 EXPORT_SYMBOL(drm_fb_helper_debug_leave);
 
+/* Check if the plane can hw rotate to match panel orientation */
+static bool drm_fb_helper_panel_rotation(struct drm_connector *connector,
+struct drm_plane *plane,
+unsigned int *rotation)
+{
+   uint64_t valid_mask = 0;
+   unsigned int i;
+
+   if (!connector)
+   return false;
+
+   switch (connector->display_info.panel_orientation) {
+   case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
+   *rotation = DRM_MODE_ROTATE_180;
+   break;
+   case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
+   *rotation = DRM_MODE_ROTATE_90;
+   break;
+   case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
+   *rotation = DRM_MODE_ROTATE_270;
+   break;
+   default:
+   *rotation = DRM_MODE_ROTATE_0;
+   }
+
+   /*
+* TODO: support 90 / 270 degree hardware rotation,
+* depending on the hardware this may require the framebuffer
+* to be in a specific tiling format.
+*/
+   if (*rotation != DRM_MODE_ROTATE_180 || !plane->rotation_property)
+   return false;
+
+   for (i = 0; i < plane->rotation_property->num_values; i++)
+   valid_mask |= (1ULL << plane->rotation_property->values[i]);
+
+   if (!(*rotation & valid_mask))
+   return false;
+
+   return true;
+}
+
 static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool 
active)
 {
struct drm_device *dev = fb_helper->dev;
@@ -406,10 +448,13 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper 
*fb_helper, bool activ
for (i = 0; i < fb_helper->crtc_count; i++) {
struct drm_mode_set *mode_set = 
_helper->crtc_info[i].mode_set;
struct drm_plane *primary = mode_set->crtc->primary;
+   unsigned int rotation;
 
-   /* Cannot fail as we've already gotten the plane state above */
-   plane_state = drm_atomic_get_new_plane_state(state, primary);
-   plane_state->rotation = fb_helper->crtc_info[i].rotation;
+   if (drm_fb_helper_panel_rotation(mode_set->connectors[0], 
primary, )) {
+   /* Cannot fail as we've already gotten the plane state 
above */
+   plane_state = drm_atomic_get_new_plane_state(state, 
primary);
+   plane_state->rotation = rotation;
+   }
 
ret = __drm_atomic_helper_set_config(mode_set, state);
if (ret != 0)
@@ -841,7 +886,6 @@ int drm_fb_helper_init(struct drm_device *dev,
if (!fb_helper->crtc_info[i].mode_set.connectors)
goto out_free;
fb_helper->crtc_info[i].mode_set.num_connectors = 0;
-   fb_helper->crtc_info[i].rotation = DRM_MODE_ROTATE_0;
}
 
i = 0;
@@ -2414,62 +2458,6 @@ static int drm_pick_crtcs(struct drm_fb_helper 
*fb_helper,
return best_score;
 }
 
-/*
- * This function checks if rotation is necessary because of panel orientation
- * and if it is, if it is supported.
- * If rotation is necessary and supported, its gets set in fb_crtc.rotation.
- * If rotation is necessary but not supported, a DRM_MODE_ROTATE_* flag gets
- * or-ed into fb_helper->sw_rotations. In drm_setup_crtcs_fb() we check if only
- * one bit is set and then we set fb_info.fbcon_rotate_hint to make fbcon do
- * the unsupported rotation.
- */
-static void drm_setup_crtc_rotation(struct drm_fb_helper *fb_helper,
-   struct drm_fb_helper_crtc *fb_crtc,
-   struct drm_connector *connector)
-{
-   struct drm_plane *plane = fb_crtc->mode_set.crtc->primary;
-   uint64_t valid_mask = 0;
-   int i, rotation;
-
-   fb_crtc->rotation = DRM_MODE_ROTATE_0;
-
-   switch (connector->display_info.panel_orientation) {
-   case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
-   rotation = DRM_MODE_ROTATE_180;
-   break;
-   case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
-   rotation = DRM_MODE_ROTATE_90;
-   break;
-   case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
-   

[RFC v4 06/25] drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()

2018-04-12 Thread Noralf Trønnes
Prepare for moving drm_fb_helper modesetting code to drm_client.
drm_client will be linked to drm.ko, so move
__drm_atomic_helper_disable_plane() and __drm_atomic_helper_set_config()
out of drm_kms_helper.ko.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_atomic.c| 168 
 drivers/gpu/drm/drm_atomic_helper.c | 168 +---
 drivers/gpu/drm/drm_fb_helper.c |   8 +-
 include/drm/drm_atomic.h|   5 ++
 include/drm/drm_atomic_helper.h |   4 -
 5 files changed, 179 insertions(+), 174 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 7d25c42f22db..1fb602b6c8b1 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -2060,6 +2060,174 @@ void drm_atomic_clean_old_fb(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_atomic_clean_old_fb);
 
+/* just used from drm_client and atomic-helper: */
+int drm_atomic_disable_plane(struct drm_plane *plane,
+struct drm_plane_state *plane_state)
+{
+   int ret;
+
+   ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
+   if (ret != 0)
+   return ret;
+
+   drm_atomic_set_fb_for_plane(plane_state, NULL);
+   plane_state->crtc_x = 0;
+   plane_state->crtc_y = 0;
+   plane_state->crtc_w = 0;
+   plane_state->crtc_h = 0;
+   plane_state->src_x = 0;
+   plane_state->src_y = 0;
+   plane_state->src_w = 0;
+   plane_state->src_h = 0;
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_atomic_disable_plane);
+
+static int update_output_state(struct drm_atomic_state *state,
+  struct drm_mode_set *set)
+{
+   struct drm_device *dev = set->crtc->dev;
+   struct drm_crtc *crtc;
+   struct drm_crtc_state *new_crtc_state;
+   struct drm_connector *connector;
+   struct drm_connector_state *new_conn_state;
+   int ret, i;
+
+   ret = drm_modeset_lock(>mode_config.connection_mutex,
+  state->acquire_ctx);
+   if (ret)
+   return ret;
+
+   /* First disable all connectors on the target crtc. */
+   ret = drm_atomic_add_affected_connectors(state, set->crtc);
+   if (ret)
+   return ret;
+
+   for_each_new_connector_in_state(state, connector, new_conn_state, i) {
+   if (new_conn_state->crtc == set->crtc) {
+   ret = drm_atomic_set_crtc_for_connector(new_conn_state,
+   NULL);
+   if (ret)
+   return ret;
+
+   /* Make sure legacy setCrtc always re-trains */
+   new_conn_state->link_status = DRM_LINK_STATUS_GOOD;
+   }
+   }
+
+   /* Then set all connectors from set->connectors on the target crtc */
+   for (i = 0; i < set->num_connectors; i++) {
+   new_conn_state = drm_atomic_get_connector_state(state,
+   set->connectors[i]);
+   if (IS_ERR(new_conn_state))
+   return PTR_ERR(new_conn_state);
+
+   ret = drm_atomic_set_crtc_for_connector(new_conn_state,
+   set->crtc);
+   if (ret)
+   return ret;
+   }
+
+   for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+   /*
+* Don't update ->enable for the CRTC in the set_config request,
+* since a mismatch would indicate a bug in the upper layers.
+* The actual modeset code later on will catch any
+* inconsistencies here.
+*/
+   if (crtc == set->crtc)
+   continue;
+
+   if (!new_crtc_state->connector_mask) {
+   ret = drm_atomic_set_mode_prop_for_crtc(new_crtc_state,
+   NULL);
+   if (ret < 0)
+   return ret;
+
+   new_crtc_state->active = false;
+   }
+   }
+
+   return 0;
+}
+
+/* just used from drm_client and atomic-helper: */
+int drm_atomic_set_config(struct drm_mode_set *set,
+ struct drm_atomic_state *state)
+{
+   struct drm_crtc_state *crtc_state;
+   struct drm_plane_state *primary_state;
+   struct drm_crtc *crtc = set->crtc;
+   int hdisplay, vdisplay;
+   int ret;
+
+   crtc_state = drm_atomic_get_crtc_state(state, crtc);
+   if (IS_ERR(crtc_state))
+   return PTR_ERR(crtc_state);
+
+   primary_state = drm_atomic_get_plane_state(state, crtc->primary);
+   if (IS_ERR(primary_state))
+   return PTR_ERR(primary_state);
+
+   if (!set->mode) {
+  

[RFC v4 01/25] drm: provide management functions for drm_file

2018-04-12 Thread Noralf Trønnes
From: David Herrmann 

Rather than doing drm_file allocation/destruction right in the fops, lets
provide separate helpers. This decouples drm_file management from the
still-mandatory drm-fops. It prepares for use of drm_file without the
fops, both by possible separate fops implementations and APIs (not that I
am aware of any such plans), and more importantly from in-kernel use where
no real file is available.

Signed-off-by: David Herrmann 
Signed-off-by: Noralf Trønnes 
Reviewed-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_file.c | 305 +++--
 drivers/gpu/drm/drm_internal.h |   2 +
 2 files changed, 175 insertions(+), 132 deletions(-)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index e394799979a6..d4588d33f91c 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -101,6 +101,175 @@ DEFINE_MUTEX(drm_global_mutex);
 
 static int drm_open_helper(struct file *filp, struct drm_minor *minor);
 
+/**
+ * drm_file_alloc - allocate file context
+ * @minor: minor to allocate on
+ *
+ * This allocates a new DRM file context. It is not linked into any context and
+ * can be used by the caller freely. Note that the context keeps a pointer to
+ * @minor, so it must be freed before @minor is.
+ *
+ * RETURNS:
+ * Pointer to newly allocated context, ERR_PTR on failure.
+ */
+struct drm_file *drm_file_alloc(struct drm_minor *minor)
+{
+   struct drm_device *dev = minor->dev;
+   struct drm_file *file;
+   int ret;
+
+   file = kzalloc(sizeof(*file), GFP_KERNEL);
+   if (!file)
+   return ERR_PTR(-ENOMEM);
+
+   file->pid = get_pid(task_pid(current));
+   file->minor = minor;
+
+   /* for compatibility root is always authenticated */
+   file->authenticated = capable(CAP_SYS_ADMIN);
+   file->lock_count = 0;
+
+   INIT_LIST_HEAD(>lhead);
+   INIT_LIST_HEAD(>fbs);
+   mutex_init(>fbs_lock);
+   INIT_LIST_HEAD(>blobs);
+   INIT_LIST_HEAD(>pending_event_list);
+   INIT_LIST_HEAD(>event_list);
+   init_waitqueue_head(>event_wait);
+   file->event_space = 4096; /* set aside 4k for event buffer */
+
+   mutex_init(>event_read_lock);
+
+   if (drm_core_check_feature(dev, DRIVER_GEM))
+   drm_gem_open(dev, file);
+
+   if (drm_core_check_feature(dev, DRIVER_SYNCOBJ))
+   drm_syncobj_open(file);
+
+   if (drm_core_check_feature(dev, DRIVER_PRIME))
+   drm_prime_init_file_private(>prime);
+
+   if (dev->driver->open) {
+   ret = dev->driver->open(dev, file);
+   if (ret < 0)
+   goto out_prime_destroy;
+   }
+
+   if (drm_is_primary_client(file)) {
+   ret = drm_master_open(file);
+   if (ret)
+   goto out_close;
+   }
+
+   return file;
+
+out_close:
+   if (dev->driver->postclose)
+   dev->driver->postclose(dev, file);
+out_prime_destroy:
+   if (drm_core_check_feature(dev, DRIVER_PRIME))
+   drm_prime_destroy_file_private(>prime);
+   if (drm_core_check_feature(dev, DRIVER_SYNCOBJ))
+   drm_syncobj_release(file);
+   if (drm_core_check_feature(dev, DRIVER_GEM))
+   drm_gem_release(dev, file);
+   put_pid(file->pid);
+   kfree(file);
+
+   return ERR_PTR(ret);
+}
+
+static void drm_events_release(struct drm_file *file_priv)
+{
+   struct drm_device *dev = file_priv->minor->dev;
+   struct drm_pending_event *e, *et;
+   unsigned long flags;
+
+   spin_lock_irqsave(>event_lock, flags);
+
+   /* Unlink pending events */
+   list_for_each_entry_safe(e, et, _priv->pending_event_list,
+pending_link) {
+   list_del(>pending_link);
+   e->file_priv = NULL;
+   }
+
+   /* Remove unconsumed events */
+   list_for_each_entry_safe(e, et, _priv->event_list, link) {
+   list_del(>link);
+   kfree(e);
+   }
+
+   spin_unlock_irqrestore(>event_lock, flags);
+}
+
+/**
+ * drm_file_free - free file context
+ * @file: context to free, or NULL
+ *
+ * This destroys and deallocates a DRM file context previously allocated via
+ * drm_file_alloc(). The caller must make sure to unlink it from any contexts
+ * before calling this.
+ *
+ * If NULL is passed, this is a no-op.
+ *
+ * RETURNS:
+ * 0 on success, or error code on failure.
+ */
+void drm_file_free(struct drm_file *file)
+{
+   struct drm_device *dev;
+
+   if (!file)
+   return;
+
+   dev = file->minor->dev;
+
+   DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
+ task_pid_nr(current),
+ (long)old_encode_dev(file->minor->kdev->devt),
+ dev->open_count);
+
+   if (drm_core_check_feature(dev, 

[RFC v4 02/25] drm/file: Don't set master on in-kernel clients

2018-04-12 Thread Noralf Trønnes
It only makes sense for userspace clients.

Signed-off-by: Noralf Trønnes 
Reviewed-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_file.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index d4588d33f91c..55505378df47 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -155,17 +155,8 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor)
goto out_prime_destroy;
}
 
-   if (drm_is_primary_client(file)) {
-   ret = drm_master_open(file);
-   if (ret)
-   goto out_close;
-   }
-
return file;
 
-out_close:
-   if (dev->driver->postclose)
-   dev->driver->postclose(dev, file);
 out_prime_destroy:
if (drm_core_check_feature(dev, DRIVER_PRIME))
drm_prime_destroy_file_private(>prime);
@@ -365,6 +356,7 @@ static int drm_open_helper(struct file *filp, struct 
drm_minor *minor)
 {
struct drm_device *dev = minor->dev;
struct drm_file *priv;
+   int ret;
 
if (filp->f_flags & O_EXCL)
return -EBUSY;  /* No exclusive opens */
@@ -379,6 +371,14 @@ static int drm_open_helper(struct file *filp, struct 
drm_minor *minor)
if (IS_ERR(priv))
return PTR_ERR(priv);
 
+   if (drm_is_primary_client(priv)) {
+   ret = drm_master_open(priv);
+   if (ret) {
+   drm_file_free(priv);
+   return ret;
+   }
+   }
+
filp->private_data = priv;
priv->filp = filp;
 
-- 
2.15.1

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


[RFC v4 00/25] drm: Add generic fbdev emulation

2018-04-12 Thread Noralf Trønnes
This patchset explores the possibility of having generic fbdev emulation
in DRM for drivers that supports dumb buffers which they can export. An
API is added to support in-kernel clients in general.

In this version I was able to reuse the modesetting code from
drm_fb_helper in the client API. This avoids code duplication, carries
over lessons learned and the modesetting code is bisectable. The
downside is that it takes +10 patches to rip drm_fb_helper in two, so
maybe it's not worth it wrt possible breakage and a challenging review.

Does the Intel CI test the fbdev emulation?

Daniel had this concern with the previous version:

The register/unregister model needs more thought. Allowing both clients
to register whenever they want to, and drm_device instances to come and
go is what fbcon has done, and the resulting locking is a horror show.

I think if we require that all in-kernel drm_clients are registers when
loading drm.ko (and enabled/disabled only per module options and
Kconfig), then we can throw out all the locking. That avoids a lot of
the headaches.

I have solved this by adding a notifier that fires when a new DRM device
is registered (I've removed the new() callback). Currently only
bootsplash uses this. The fbdev client needs to be setup from the driver
since it can't know on device registration if the driver will setup it's
own fbdev emulation later and the vtcon client hooks up to a user
provided device id.

Since fbcon can't handle fb_open failing, the buffer has to be
pre-allocated. Exporting a GEM buffer pins the driver module making it
impossible to unload it.
I have included 2 solutions to the problem:
- sysfs file to remove/close clients: remove_internal_clients
- Change drm_gem_prime_export() so it doesn't pin on client buffers

If a dumb buffer is exported from a kernel thread (worker) context, the
file descriptor isn't closed and I leak a reference so the buffer isn't
freed. Please look at drm_client_buffer_create() in patch
'drm/client: Finish the in-kernel client API'.
This is a blocker that needs a solution.


Noralf.

Changes since version 3:
Client API changes:
- Drop drm_client_register_funcs() which attached clients indirectly.
  Let clients attach directly using drm_client_new{_from_id}(). Clients
  that wants to attach to all devices must be linked into drm.ko and use
  the DRM device notifier. This is done to avoid the lock/race
  register/unregister hell we have with fbcon. (Daniel Vetter)
- drm_client_display_restore() checks if there is a master and if so
  returns -EBUSY. (Daniel Vetter)
- Allocate drm_file up front instead of on-demand. Since fbdev can't do
  on demand buffer allocation because of fbcon, there's no need for this.
- Add sysfs file to remove clients
- Don't pin driver module when exporting gem client buffers
- Dropped page flip support since drm_fb_helper is now used for fbdev
  emulation.

- The bootsplash client now switches over to fbdev on keypress.

Changes since version 2:
- Don't set drm master for in-kernel clients. (Daniel Vetter)
- Add in-kernel client API

Changes since version 1:
- Don't add drm_fb_helper_fb_open() and drm_fb_helper_fb_release() to
  DRM_FB_HELPER_DEFAULT_OPS(). (Fi.CI.STATIC)
  The following uses that macro and sets fb_open/close: udlfb_ops,
  amdgpufb_ops, drm_fb_helper_generic_fbdev_ops, nouveau_fbcon_ops,
  nouveau_fbcon_sw_ops, radeonfb_ops.
  This results in: warning: Initializer entry defined twice
- Support CONFIG_DRM_KMS_HELPER=m (kbuild test robot)
  ERROR:  [drivers/gpu/drm/drm_kms_helper.ko] undefined!
- Drop buggy patch: (Chris Wilson)
  drm/prime: Clear drm_gem_object->dma_buf on release
- Defer buffer creation until fb_open.


David Herrmann (1):
  drm: provide management functions for drm_file

Noralf Trønnes (24):
  drm/file: Don't set master on in-kernel clients
  drm/fb-helper: No need to cache rotation and sw_rotations
  drm/fb-helper: Remove drm_fb_helper_debug_enter/leave()
  drm/fb-helper: dpms_legacy(): Only set on connectors in use
  drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()
  drm: Begin an API for in-kernel clients
  drm/fb-helper: Use struct drm_client_display
  drm/fb-helper: Move modeset commit code to drm_client
  drm/connector: Add
drm_connector_has_preferred_mode/pick_cmdline_mode()
  drm/connector: Add connector array functions
  drm/i915: Add drm_driver->initial_client_display callback
  drm/fb-helper: Remove struct drm_fb_helper_crtc
  drm/fb-helper: Remove struct drm_fb_helper_connector
  drm/fb-helper: Move modeset config code to drm_client
  drm: Make ioctls available for in-kernel clients
  drm/client: Bail out if there's a DRM master
  drm/client: Make the display modes available to clients
  drm/client: Finish the in-kernel client API
  drm/prime: Don't pin module on export for in-kernel clients
  drm/fb-helper: Add drm_fb_helper_fb_open/release()
  drm/fb-helper: Add generic fbdev emulation
  drm: Add DRM device registered 

[Bug 48424] Fix warnings/errors reported by clang's scan-build tool

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=48424

Timothy Arceri  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #4 from Timothy Arceri  ---
Patches are always welcome and this is an on going issue I don't think we need
a bug to track this. Closing.

-- 
You are receiving this mail because:
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


[Bug 104216] Firefox quirks (black and/or white squares)

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=104216

--- Comment #27 from Germano Massullo  ---
Created attachment 138784
  --> https://bugs.freedesktop.org/attachment.cgi?id=138784=edit
lsof on Firefox

(In reply to Michel Dänzer from comment #26)
> FWIW, I've never noticed such issues with the default limit of 1024. My main
> firefox process (which has been running for days, with lots of activity in a
> large number of tabs) currently has 222 open file descriptors, the helper
> processes less than 60 each.

I attach output of lsof runned against Firefox PIDs (even if it does not
describe exactly Firefox file descriptors).
If you have any suggestion about retrieving useful infos about file descriptors
used by Firefox, please let me know

-- 
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 105996] [DC][CIK] Bonaire mobile - No displays being turned on

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105996

Alex Deucher  changed:

   What|Removed |Added

 Attachment #138777|text/x-log  |text/plain
  mime type||

-- 
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 105996] [DC][CIK] Bonaire mobile - No displays being turned on

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105996

Alex Deucher  changed:

   What|Removed |Added

 Attachment #138778|text/x-log  |text/plain
  mime type||

-- 
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 199357] amdgpu: hang a few seconds after logging in, most likely due to regression

2018-04-12 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=199357

Mathias Tillman (master.ho...@gmail.com) changed:

   What|Removed |Added

 Attachment #275291|0   |1
is obsolete||

--- Comment #8 from Mathias Tillman (master.ho...@gmail.com) ---
Created attachment 275337
  --> https://bugzilla.kernel.org/attachment.cgi?id=275337=edit
Kernel log with added logging

-- 
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 199357] amdgpu: hang a few seconds after logging in, most likely due to regression

2018-04-12 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=199357

--- Comment #7 from Mathias Tillman (master.ho...@gmail.com) ---
Wanted to add some more info. The soft lock up will release after approximately
30 seconds, but after a few seconds it will lock up again and repeat.
Looking at the kernel log, it seems that when the lock up happens, it takes an
abnormally long time to reach the dm_pflip_high_irq function which is supposed
to trigger the flip_done message.
I've attached a new log with my added logging in case that helps.

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


Re: RFC for a render API to support adaptive sync and VRR

2018-04-12 Thread Nicolai Hähnle

On 12.04.2018 01:30, Cyr, Aric wrote:

At least with VDPAU, video players are already explicitly specifying the
target presentation time, so no changes should be required at that
level. Don't know about other video APIs.

The X11 Present extension protocol is also prepared for specifying the
target presentation time already, the support for it just needs to be
implemented.


I'm perfectly OK with presentation time-based *API*.  I get it from a user 
mode/app perspective, and that's fine.  We need that feedback and would like 
help defining that portions of the stack.
However, I think it doesn't make as much sense as a *DDI* because it doesn't 
correspond to any hardware real or logical (i.e. no one would implement it in 
HW this way) and the industry specs aren't defined that way.
You can have libdrm or some other usermode component translate your presentation time 
into a frame duration and schedule it.  What's the advantage of having this in kernel 
besides the fact we lose the intent of the application and could prevent features and 
optimizations.  When it gets to kernel, I think it is much more elegant for the flip 
structure to contain a simple duration that says "hey, show this frame on the screen 
for this long".  Then we don't need any clocks or timers just some simple math and 
program the hardware.


There isn't necessarily an inherent advantage to having this translation 
in the kernel. However, we *must* do this translation in a place that is 
owned by display experts (i.e., you guys), because only you guys know 
how to actually do that translation reliably and correctly.


Since your work is currently limited to the kernel, it makes sense to do 
it in the kernel.


If the translation doesn't happen in a place that you feel comfortable 
working on, we're setting ourselves up for a future where this 
hypothetical future UMD component will get this wrong, and there'll be a 
lot of finger-pointing between you guys and whoever writes that UMD, 
with likely little willingness to actually go into the respective other 
codebase to fix what's wrong. And that's a pretty sucky future.


Cheers,
Nicolai

P.S.: I'm also a little surprised that you seem to be saying that 
requesting a target present time is basically impossible (at least, 
that's kind of implied by your statement about mGPUs), and yet there's 
precedent for such APIs in both Vulkan and VDPAU.





In short,
  1) We can simplify media players' lives by helping them get really, really 
close to their content rate, so they wouldn't need any frame rate conversion.
  They'll still need A/V syncing though, and variable refresh cannot solve 
this and thus is way out of scope of what we're proposing.

  2) For gaming, don't even try to guess a frame duration, the driver/hardware 
will do a better job every time, just specify duration=0 and flip as fast as 
you can.

Regards,
   Aric

P.S. Thanks for the Croteam link.  Interesting, but basically nullified by 
variable refresh rate displays.  You won't have 
stuttering/microstuttering/juddering/tearing if your display's refresh rate 
matches the render/present rate of the game.  Maybe I should grab The Talos 
Principle to see how well it works with FreeSync display :)

--
ARIC CYR
PMTS Software Engineer | SW – Display Technologies






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


[Bug 98271] [radeonsi]Playing videos with vdpau or vaapi hardware acceleration crashes my pc

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=98271

Timothy Arceri  changed:

   What|Removed |Added

 QA Contact|mesa-dev@lists.freedesktop. |dri-devel@lists.freedesktop
   |org |.org
   Assignee|mesa-dev@lists.freedesktop. |dri-devel@lists.freedesktop
   |org |.org
  Component|Other   |Drivers/Gallium/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 97909] X-Plane 10 crashes with SIGSEGV on radeonsi

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97909

--- Comment #14 from Amarildo  ---
It's a shame they don't officially support OSS drivers despite them running
X-Plane better.

All this contributes to driver separation, confusion, and Linux still being
regarded as "not ready for quite a few games".

BTW, if you happen to run OSS drivers and wanna try X-Plane, be it v10 or v11,
set a launch command (could be on Steam too) to:

--no_pinned

This does get rid of the crashes, which are observable when e.g. clouds are
enabled.

Cheers

-- 
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 105819] Window system hang due to GPU Fault

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105819

--- Comment #2 from Andy Burns  ---
Experienced same/similar error on Fedora 28 beta, with an RX 460 card

$ lspci | grep AMD

01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI]
Baffin [Radeon RX 460/560D / Pro 450/455/460/560] (rev cf)
01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Device aae0

$ uname -a
Linux localhost.localdomain 4.16.1-300.fc28.x86_64 #1 SMP Mon Apr 9 15:29:05
UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Sorry, I don't know what the fedora version corresponds to in terms of
freedesktop version

It happened after leaving pixmark_volplosion_windowed running overnight

08:27:10 kernel: [drm] GPU recovery disabled.
08:27:10 kernel: [drm] GPU recovery disabled.
08:27:10 kernel: [drm] IP block:sdma_v3_0 is hung!
08:27:10 kernel: [drm] IP block:gfx_v8_0 is hung!
08:27:10 kernel: [drm] IP block:gmc_v8_0 is hung!
08:27:10 kernel: [drm:amdgpu_job_timedout [amdgpu]] *ERROR* ring sdma0 timeout,
last signaled seq=1000210, last emitted seq=1000212
08:27:07 kernel: [drm] GPU recovery disabled.
08:27:07 kernel: [drm] GPU recovery disabled.
08:27:07 kernel: [drm] IP block:sdma_v3_0 is hung!
08:27:07 kernel: [drm] IP block:gfx_v8_0 is hung!
08:27:07 kernel: [drm] IP block:gmc_v8_0 is hung!
08:27:07 kernel: [drm:amdgpu_job_timedout [amdgpu]] *ERROR* ring gfx timeout,
last signaled seq=2338524, last emitted seq=2338526

Then (I think) about 30 minutes later the machine either panicked, or locked
up.

-- 
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 104216] Firefox quirks (black and/or white squares)

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=104216

--- Comment #26 from Michel Dänzer  ---
The question remains where all the file descriptors are coming from. Maybe
there's a leak somewhere.

FWIW, I've never noticed such issues with the default limit of 1024. My main
firefox process (which has been running for days, with lots of activity in a
large number of tabs) currently has 222 open file descriptors, the helper
processes less than 60 each.

-- 
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 1/2] drm/prime: Iterate SG DMA addresses separately

2018-04-12 Thread Christian König

Am 12.04.2018 um 11:49 schrieb Lucas Stach:

Am Donnerstag, den 12.04.2018, 11:35 +0200 schrieb Christian König:

Am 12.04.2018 um 11:11 schrieb Lucas Stach:

Am Mittwoch, den 11.04.2018, 20:26 +0200 schrieb Christian König:

Am 11.04.2018 um 19:11 schrieb Robin Murphy:

For dma_map_sg(), DMA API implementations are free to merge consecutive
segments into a single DMA mapping if conditions are suitable, thus the
resulting DMA addresses may be packed into fewer entries than
ttm->sg->nents implies.

drm_prime_sg_to_page_addr_arrays() does not account for this, meaning
its callers either have to reject the 0 < count < nents case or risk
getting bogus addresses back later. Fortunately this is relatively easy
to deal with having to rejig structures to also store the mapped count,
since the total DMA length should still be equal to the total buffer
length. All we need is a separate scatterlist cursor to iterate the DMA
addresses separately from the CPU addresses.

Mhm, I think I like Sinas approach better.

See the hardware actually needs the dma_address on a page by page basis.

Joining multiple consecutive pages into one entry is just additional
overhead which we don't need.

But setting MAX_SEGMENT_SIZE will probably prevent an IOMMU that might
be in front of your GPU to map large pages as such, causing additional
overhead by means of additional TLB misses and page walks on the IOMMU
side.

And wouldn't you like to use huge pages at the GPU side, if the IOMMU
already provides you the service of producing one large consecutive
address range, rather than mapping them via a number of small pages?

No, I wouldn't like to use that. We're already using that :)

But we use huge pages by allocating consecutive chunks of memory so that
both the CPU as well as the GPU can increase their TLB hit rate.

I'm not convinced that this is a universal win. Many GPU buffers aren't
accessed by the CPU and allocating huge pages puts much more strain on
the kernel MM subsystem.


Yeah, we indeed see the extra overhead during allocation.


What currently happens is that the DMA subsystem tries to coalesce
multiple pages into on SG entry and we de-coalesce that inside the
driver again to create our random access array.

I guess the right thing would be to have a flag that tells the the DMA
implementation to not coalesce the entries. But (ab-)using max segment
size tells the DMA API to split the segments if they are larger than
the given size, which is probably not what you want either as you now
need to coalesce the segments again when you are mapping real huge
pages.


No, even with huge pages I need an array with every single dma address 
for a 4K pages (or whatever the normal page size is).


The problem is that I need a random access array for the DMA addresses, 
even when they are continuously.


I agree that max segment size is a bit ugly here, but at least for 
radeon, amdgpu and pretty much TTM in general it is exactly what I need.


I could fix TTM to not need that, but for radeon and amdgpu it is the 
hardware which needs this.


Christian.




That is a huge waste of memory and CPU cycles and I actually wanted to
get rid of it for quite some time now. Sinas approach seems to be a good
step into the right direction to me to actually clean that up.


Detecting such a condition is much easier if the DMA map implementation
gives you the coalesced scatter entries.

A way which preserves both path would be indeed nice to have, but that
only allows for the TLB optimization for the GPU and not the CPU any
more. So I actually see that as really minor use case.

Some of the Tegras have much larger TLBs and better page-walk
performance on the system IOMMU compared to the GPU MMU, so they would
probably benefit a good deal even if the hugepage optimization only
targets the GPU side.

Regards,
Lucas


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


[Bug 104216] Firefox quirks (black and/or white squares)

2018-04-12 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=104216

--- Comment #25 from Germano Massullo  ---
Some very good news
https://bugzilla.mozilla.org/show_bug.cgi?id=1421353#c22

-- 
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] drm/arm/malidp: Preserve LAYER_FORMAT contents when setting format

2018-04-12 Thread Liviu Dudau
On Tue, Apr 10, 2018 at 07:25:03PM +0100, Ayan Kumar Halder wrote:
> On some Mali-DP processors, the LAYER_FORMAT register contains fields
> other than the format. These bits were unconditionally cleared when
> setting the pixel format, whereas they should be preserved at their
> reset values.
> 
> Reported-by: Brian Starkey 
> Reported-by: Liviu Dudau 
> Signed-off-by: Ayan Kumar halder 

Acked-by: Liviu Dudau 

Thanks for catching this in testing!

Best regards,
Liviu

> ---
>  drivers/gpu/drm/arm/malidp_planes.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/arm/malidp_planes.c 
> b/drivers/gpu/drm/arm/malidp_planes.c
> index 7a44897..4af3c1f 100644
> --- a/drivers/gpu/drm/arm/malidp_planes.c
> +++ b/drivers/gpu/drm/arm/malidp_planes.c
> @@ -23,6 +23,7 @@
>  
>  /* Layer specific register offsets */
>  #define MALIDP_LAYER_FORMAT  0x000
> +#define   LAYER_FORMAT_MASK  0x3f
>  #define MALIDP_LAYER_CONTROL 0x004
>  #define   LAYER_ENABLE   (1 << 0)
>  #define   LAYER_FLOWCFG_MASK 7
> @@ -337,7 +338,9 @@ static void malidp_de_plane_update(struct drm_plane 
> *plane,
>   dest_w = plane->state->crtc_w;
>   dest_h = plane->state->crtc_h;
>  
> - malidp_hw_write(mp->hwdev, ms->format, mp->layer->base);
> + val = malidp_hw_read(mp->hwdev, mp->layer->base);
> + val = (val & ~LAYER_FORMAT_MASK) | ms->format;
> + malidp_hw_write(mp->hwdev, val, mp->layer->base);
>  
>   for (i = 0; i < ms->n_planes; i++) {
>   /* calculate the offset for the layer's plane registers */
> -- 
> 2.7.4
> 

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 10/11] drm/ttm: some good fixes for per-vm-lru

2018-04-12 Thread Chunming Zhou
Change-Id: Ib68bff91fd127162cf8c72516101546e1fe014df
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |  1 -
 drivers/gpu/drm/ttm/ttm_bo.c   | 39 --
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index d54abba4e017..ea95c2e9a858 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -625,7 +625,6 @@ static int amdgpu_bo_do_create1(struct amdgpu_device *adev, 
unsigned long size,
bo->tbo.index = (u64)atomic64_inc_return(>bo_index);
 
bo->tbo.bdev = >mman.bdev;
-   RB_CLEAR_NODE(>tbo.node);
amdgpu_ttm_placement_from_domain(bo, domains);
r = ttm_bo_init_reserved(>mman.bdev, >tbo, size, type,
 >placement, page_align, , acc_size,
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index d56312702b49..dc9545eeb5d6 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -164,15 +164,12 @@ static void ttm_bo_add_to_rb(struct ttm_buffer_object *bo,
 while (*new) {
struct ttm_buffer_object *this =
container_of(*new, struct ttm_buffer_object, node);
-   int result = bo->index - this->index;
 
parent = *new;
-   if (result < 0)
+   if (bo->index < this->index)
new = &((*new)->rb_left);
-   else if (result > 0)
-   new = &((*new)->rb_right);
else
-   return;
+   new = &((*new)->rb_right);
}
rb_link_node(>node, parent, new);
rb_insert_color(>node, root);
@@ -211,6 +208,24 @@ static void ttm_bo_ref_bug(struct kref *list_kref)
BUG();
 }
 
+static struct ttm_buffer_object *ttm_bo_rb_find(struct rb_root *root, u64 
index)
+{
+   struct rb_node *node = root->rb_node;
+
+   while (node) {
+   struct ttm_buffer_object *bo =
+   container_of(node, struct ttm_buffer_object, node);
+
+   if (index < bo->index)
+   node = node->rb_left;
+   else if (index > bo->index)
+   node = node->rb_right;
+   else
+   return bo;
+   }
+
+   return NULL;
+}
 void ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
 {
if (!list_empty(>swap)) {
@@ -220,10 +235,10 @@ void ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
if (!list_empty(>lru)) {
list_del_init(>lru);
kref_put(>list_kref, ttm_bo_ref_bug);
-   } else if (RB_EMPTY_NODE(>node)) {
+   } else if
+   
(ttm_bo_rb_find(>process->fixed_lru[bo->mem.mem_type][bo->priority], 
bo->index)) {
rb_erase(>node,
 
>process->fixed_lru[bo->mem.mem_type][bo->priority]);
-   RB_CLEAR_NODE(>node);
kref_put(>list_kref, ttm_bo_ref_bug);
}
/*
@@ -769,23 +784,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
for (node = rb_first(>fixed_lru[mem_type][i]); node;
 node = rb_next(node)) {
bo = rb_entry(node, struct ttm_buffer_object, node);
-   if (!ttm_bo_evict_swapout_allowable(bo, ctx, ))
+   if (!ttm_bo_evict_swapout_allowable(bo, ctx, )) {
+   bo = NULL;
continue;
+   }
 
if (place && !bdev->driver->eviction_valuable(bo,
  place)) {
if (locked)
reservation_object_unlock(bo->resv);
+   bo = NULL;
continue;
}
break;
}
 
-   /* If the inner loop terminated early, we have our candidate */
-   if (>lru != >fixed_lru[mem_type][i])
-   break;
-
-   bo = NULL;
}
if (bo)
break;
-- 
2.14.1

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


[PATCH 11/11] drm/ttm: bulk move per vm bo

2018-04-12 Thread Chunming Zhou
Change-Id: I5b6afbdd715e28e5266b5099ca9a34399d1fc3a1
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index dc9545eeb5d6..d6e7c835f4c1 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -261,8 +261,13 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo)
 {
reservation_object_assert_held(bo->resv);
 
-   ttm_bo_del_from_lru(bo);
-   ttm_bo_add_to_lru(bo);
+   if (bo->resv == bo->process->resv) {
+   list_move_tail(>process->process_list,
+  >bdev->process_list);
+   } else {
+   ttm_bo_del_from_lru(bo);
+   ttm_bo_add_to_lru(bo);
+   }
 }
 EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
 
-- 
2.14.1

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


[PATCH 09/11] drm/amdgpu: counter for every bo creation

2018-04-12 Thread Chunming Zhou
Change-Id: I877b2d5c54b3e47b66f2d58454dcf1e5f5a68972
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 7bb6ee777067..d54abba4e017 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -622,8 +622,10 @@ static int amdgpu_bo_do_create1(struct amdgpu_device 
*adev, unsigned long size,
if (type == ttm_bo_type_kernel)
bo->tbo.priority = 1;
bo->tbo.process = process;
+   bo->tbo.index = (u64)atomic64_inc_return(>bo_index);
 
bo->tbo.bdev = >mman.bdev;
+   RB_CLEAR_NODE(>tbo.node);
amdgpu_ttm_placement_from_domain(bo, domains);
r = ttm_bo_init_reserved(>mman.bdev, >tbo, size, type,
 >placement, page_align, , acc_size,
-- 
2.14.1

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


[PATCH 08/11] drm/ttm: add bo index

2018-04-12 Thread Chunming Zhou
Change-Id: I4abf5cf0aaf946162dabd08fc1fd0406c2abf418
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/ttm/ttm_bo.c| 1 +
 include/drm/ttm/ttm_bo_driver.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 73343d1108d2..d56312702b49 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1641,6 +1641,7 @@ int ttm_process_init(struct ttm_process *process, struct 
ttm_bo_device *bdev,
spin_unlock(>glob->lru_lock);
 
process->resv = resv;
+   atomic64_set(>bo_index, 0);
 
return 0;
 }
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 818aee15d1ec..4c42df6afcfe 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -443,6 +443,7 @@ struct ttm_process {
struct rb_root fixed_lru[TTM_NUM_MEM_TYPES][TTM_MAX_BO_PRIORITY];
struct list_head dynamic_lru[TTM_NUM_MEM_TYPES][TTM_MAX_BO_PRIORITY];
struct reservation_object *resv;
+   atomic64_t bo_index;
 };
 
 /**
-- 
2.14.1

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


[PATCH 07/11] drm/ttm: use RB tree instead of link list

2018-04-12 Thread Chunming Zhou
Change-Id: I0f533c6512f3b72fcf2fbf11d738f38d9e087f26
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/ttm/ttm_bo.c| 39 +++
 include/drm/ttm/ttm_bo_api.h|  3 ++-
 include/drm/ttm/ttm_bo_driver.h |  2 +-
 3 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index c1d0ec1238c6..73343d1108d2 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -157,6 +157,26 @@ static void ttm_bo_release_list(struct kref *list_kref)
ttm_mem_global_free(bdev->glob->mem_glob, acc_size);
 }
 
+static void ttm_bo_add_to_rb(struct ttm_buffer_object *bo,
+struct rb_root *root) {
+   struct rb_node **new = &(root->rb_node), *parent = NULL;
+
+while (*new) {
+   struct ttm_buffer_object *this =
+   container_of(*new, struct ttm_buffer_object, node);
+   int result = bo->index - this->index;
+
+   parent = *new;
+   if (result < 0)
+   new = &((*new)->rb_left);
+   else if (result > 0)
+   new = &((*new)->rb_right);
+   else
+   return;
+   }
+   rb_link_node(>node, parent, new);
+   rb_insert_color(>node, root);
+}
 void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
 {
struct ttm_bo_device *bdev = bo->bdev;
@@ -170,7 +190,7 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
 
kref_get(>list_kref);
if (bo->resv == ttm_process->resv)
-   list_add_tail(>lru,
+   ttm_bo_add_to_rb(bo,
  
_process->fixed_lru[bo->mem.mem_type][bo->priority]);
else
list_add_tail(>lru,
@@ -200,8 +220,12 @@ void ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
if (!list_empty(>lru)) {
list_del_init(>lru);
kref_put(>list_kref, ttm_bo_ref_bug);
+   } else if (RB_EMPTY_NODE(>node)) {
+   rb_erase(>node,
+
>process->fixed_lru[bo->mem.mem_type][bo->priority]);
+   RB_CLEAR_NODE(>node);
+   kref_put(>list_kref, ttm_bo_ref_bug);
}
-
/*
 * TODO: Add a driver hook to delete from
 * driver-specific LRU's here.
@@ -725,6 +749,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
spin_lock(>lru_lock);
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
list_for_each_entry(process, >process_list, process_list) {
+   struct rb_node *node;
list_for_each_entry(bo, >dynamic_lru[mem_type][i], 
lru) {
if (!ttm_bo_evict_swapout_allowable(bo, ctx, ))
continue;
@@ -741,11 +766,9 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
if (>lru != >dynamic_lru[mem_type][i])
break;
bo = NULL;
-   list_for_each_entry(bo, >fixed_lru[mem_type][i], lru) {
-   if (!bo)
-   continue;
-   if (>lru == >fixed_lru[mem_type][i])
-   break;
+   for (node = rb_first(>fixed_lru[mem_type][i]); node;
+node = rb_next(node)) {
+   bo = rb_entry(node, struct ttm_buffer_object, node);
if (!ttm_bo_evict_swapout_allowable(bo, ctx, ))
continue;
 
@@ -1609,7 +1632,7 @@ int ttm_process_init(struct ttm_process *process, struct 
ttm_bo_device *bdev,
INIT_LIST_HEAD(>process_list);
for (i = 0; i < TTM_NUM_MEM_TYPES; i++) {
for (j = 0; j < TTM_MAX_BO_PRIORITY; j++) {
-   INIT_LIST_HEAD(>fixed_lru[i][j]);
+   process->fixed_lru[i][j] = RB_ROOT;
INIT_LIST_HEAD(>dynamic_lru[i][j]);
}
}
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 8cb4b48f387a..9c8179bdd685 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -170,7 +170,7 @@ struct ttm_buffer_object {
/**
 * Members constant at init.
 */
-
+   struct rb_node node;
struct ttm_bo_device *bdev;
struct ttm_process *process;
enum ttm_bo_type type;
@@ -232,6 +232,7 @@ struct ttm_buffer_object {
struct reservation_object *resv;
struct reservation_object ttm_resv;
struct mutex wu_mutex;
+   u64 index;
 };
 
 /**
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index b6aa7fc5bf14..818aee15d1ec 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -440,7 +440,7 @@ struct ttm_bo_global {
 
 struct ttm_process {
 

[PATCH 06/11] drm/amdgpu: pass ttm process to buffer object

2018-04-12 Thread Chunming Zhou
Change-Id: Ifb0dc95db6a358cf7f76e2a99f94c58637ad6ee6
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c|  17 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 170 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |   6 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |   1 +
 7 files changed, 187 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 4b66585a8638..f398a566f57b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -443,7 +443,8 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, 
unsigned long size,
 int alignment, u32 initial_domain,
 u64 flags, enum ttm_bo_type type,
 struct reservation_object *resv,
-struct drm_gem_object **obj);
+struct drm_gem_object **obj,
+struct ttm_process *process);
 
 int amdgpu_mode_dumb_create(struct drm_file *file_priv,
struct drm_device *dev,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index ff89e84b34ce..1cee2125f570 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -146,7 +146,7 @@ static int amdgpufb_create_pinned_object(struct 
amdgpu_fbdev *rfbdev,
   AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
   AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
   AMDGPU_GEM_CREATE_VRAM_CLEARED,
-  true, NULL, );
+  true, NULL, , 
>kernel_process);
if (ret) {
pr_err("failed to allocate framebuffer (%d)\n", aligned_size);
return -ENOMEM;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 37b19ce97699..d5cbdc810aba 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -45,7 +45,8 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, 
unsigned long size,
 int alignment, u32 initial_domain,
 u64 flags, enum ttm_bo_type type,
 struct reservation_object *resv,
-struct drm_gem_object **obj)
+struct drm_gem_object **obj,
+struct ttm_process *process)
 {
struct amdgpu_bo *bo;
int r;
@@ -56,8 +57,8 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, 
unsigned long size,
alignment = PAGE_SIZE;
}
 
-   r = amdgpu_bo_create(adev, size, alignment, initial_domain,
-flags, type, resv, );
+   r = amdgpu_bo_create1(adev, size, alignment, initial_domain,
+ flags, type, resv, , process);
if (r) {
DRM_DEBUG("Failed to allocate GEM object (%ld, %d, %u, %d)\n",
  size, initial_domain, alignment, r);
@@ -243,7 +244,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void 
*data,
 
r = amdgpu_gem_object_create(adev, size, args->in.alignment,
 (u32)(0x & args->in.domains),
-flags, false, resv, );
+flags, false, resv, , >ttm_vm);
if (!r) {
abo = gem_to_amdgpu_bo(gobj);
abo->tbo.process = >ttm_vm;
@@ -273,6 +274,8 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void 
*data,
 {
struct ttm_operation_ctx ctx = { true, false };
struct amdgpu_device *adev = dev->dev_private;
+   struct amdgpu_fpriv *fpriv = filp->driver_priv;
+   struct amdgpu_vm *vm = >vm;
struct drm_amdgpu_gem_userptr *args = data;
struct drm_gem_object *gobj;
struct amdgpu_bo *bo;
@@ -297,7 +300,7 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void 
*data,
 
/* create a gem object to contain this object in */
r = amdgpu_gem_object_create(adev, args->size, 0, AMDGPU_GEM_DOMAIN_CPU,
-0, 0, NULL, );
+0, 0, NULL, , >ttm_vm);
if (r)
return r;
 
@@ -735,6 +738,8 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv,
struct drm_mode_create_dumb *args)
 {
struct amdgpu_device *adev = dev->dev_private;
+   struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
+   struct amdgpu_vm *vm = >vm;

[PATCH 05/11] drm/ttm: add per process lru

2018-04-12 Thread Chunming Zhou
Change-Id: Id2333f69119222a7e9bdb0357bbed97cf08636da
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/ttm/ttm_bo.c| 59 ++---
 include/drm/ttm/ttm_bo_driver.h |  3 ++-
 2 files changed, 52 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index b740d8f390ca..c1d0ec1238c6 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -161,15 +161,20 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
 {
struct ttm_bo_device *bdev = bo->bdev;
struct ttm_mem_type_manager *man;
+   struct ttm_process *ttm_process = bo->process;
 
reservation_object_assert_held(bo->resv);
 
if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
BUG_ON(!list_empty(>lru));
 
-   man = >man[bo->mem.mem_type];
-   list_add_tail(>lru, >lru[bo->priority]);
kref_get(>list_kref);
+   if (bo->resv == ttm_process->resv)
+   list_add_tail(>lru,
+ 
_process->fixed_lru[bo->mem.mem_type][bo->priority]);
+   else
+   list_add_tail(>lru,
+ 
_process->dynamic_lru[bo->mem.mem_type][bo->priority]);
 
if (bo->ttm && !(bo->ttm->page_flags &
 (TTM_PAGE_FLAG_SG | TTM_PAGE_FLAG_SWAPPED))) {
@@ -712,13 +717,35 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
struct ttm_bo_global *glob = bdev->glob;
struct ttm_mem_type_manager *man = >man[mem_type];
struct ttm_buffer_object *bo = NULL;
+   struct ttm_process *process;
bool locked = false;
unsigned i;
int ret;
 
spin_lock(>lru_lock);
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
-   list_for_each_entry(bo, >lru[i], lru) {
+   list_for_each_entry(process, >process_list, process_list) {
+   list_for_each_entry(bo, >dynamic_lru[mem_type][i], 
lru) {
+   if (!ttm_bo_evict_swapout_allowable(bo, ctx, ))
+   continue;
+
+   if (place && !bdev->driver->eviction_valuable(bo,
+ place)) {
+   if (locked)
+   reservation_object_unlock(bo->resv);
+   continue;
+   }
+   break;
+   }
+   /* If the inner loop terminated early, we have our candidate */
+   if (>lru != >dynamic_lru[mem_type][i])
+   break;
+   bo = NULL;
+   list_for_each_entry(bo, >fixed_lru[mem_type][i], lru) {
+   if (!bo)
+   continue;
+   if (>lru == >fixed_lru[mem_type][i])
+   break;
if (!ttm_bo_evict_swapout_allowable(bo, ctx, ))
continue;
 
@@ -732,11 +759,14 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
}
 
/* If the inner loop terminated early, we have our candidate */
-   if (>lru != >lru[i])
+   if (>lru != >fixed_lru[mem_type][i])
break;
 
bo = NULL;
}
+   if (bo)
+   break;
+   }
 
if (!bo) {
spin_unlock(>lru_lock);
@@ -1318,13 +1348,13 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device 
*bdev,
 
spin_lock(>lru_lock);
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
-   while (!list_empty(>lru[i])) {
+   //while (!list_empty(>lru[i])) {
spin_unlock(>lru_lock);
ret = ttm_mem_evict_first(bdev, mem_type, NULL, );
if (ret)
return ret;
spin_lock(>lru_lock);
-   }
+   //}
}
spin_unlock(>lru_lock);
 
@@ -1427,9 +1457,10 @@ int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned 
type,
man->has_type = true;
man->use_type = true;
man->size = p_size;
-
+/*
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
INIT_LIST_HEAD(>lru[i]);
+*/
man->move = NULL;
 
return 0;
@@ -1518,13 +1549,13 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
 
if (ttm_bo_delayed_delete(bdev, true))
pr_debug("Delayed destroy list was clean\n");
-
+/*
spin_lock(>lru_lock);
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
if (list_empty(>man[0].lru[0]))
pr_debug("Swap list %d was clean\n", i);
spin_unlock(>lru_lock);
-
+*/

[PATCH 04/11] drm/amdgpu: pass process to tbo

2018-04-12 Thread Chunming Zhou
Change-Id: I4de8146567b858ae07a8a27cadf71d13d490e8ac
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c| 7 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 +++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 28c2706e48d7..37b19ce97699 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -195,6 +195,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void 
*data,
uint64_t size = args->in.bo_size;
struct reservation_object *resv = NULL;
struct drm_gem_object *gobj;
+   struct amdgpu_bo *abo;
uint32_t handle;
int r;
 
@@ -243,10 +244,12 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void 
*data,
r = amdgpu_gem_object_create(adev, size, args->in.alignment,
 (u32)(0x & args->in.domains),
 flags, false, resv, );
+   if (!r) {
+   abo = gem_to_amdgpu_bo(gobj);
+   abo->tbo.process = >ttm_vm;
+   }
if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) {
if (!r) {
-   struct amdgpu_bo *abo = gem_to_amdgpu_bo(gobj);
-
abo->parent = amdgpu_bo_ref(vm->root.base.bo);
}
amdgpu_bo_unreserve(vm->root.base.bo);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 9e23d6f6f3f3..e911db2d1945 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -447,8 +447,10 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, 
unsigned long size,
else
amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0);
 
-   if (type == ttm_bo_type_kernel)
+   if (type == ttm_bo_type_kernel) {
bo->tbo.priority = 1;
+   bo->tbo.process = >kernel_process;
+   }
 
if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED &&
bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) {
-- 
2.14.1

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


[PATCH 03/11] drm/amdgpu: add kernel process

2018-04-12 Thread Chunming Zhou
Change-Id: Ie43f3c73cc65526a449208f3ce927b1dfad5cf6b
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 2babfad1fd7f..4b66585a8638 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1629,6 +1629,8 @@ struct amdgpu_device {
unsigned long last_mm_index;
boolin_gpu_reset;
struct mutex  lock_reset;
+
+   struct ttm_process  kernel_process;
 };
 
 static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 205da3ff9cd0..4c9e10505e2d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1421,6 +1421,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
return r;
}
adev->mman.initialized = true;
+   ttm_process_init(>kernel_process, >mman.bdev, NULL);
 
/* We opt to avoid OOM on system pages allocations */
adev->mman.bdev.no_retry = true;
-- 
2.14.1

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


  1   2   >