[PATCH] drm/amdgpu: Stop using the DRIVER debugging flag for vblank debugging messages

2020-01-23 Thread Lyude Paul
These are some very loud debug statements that get printed on every
vblank when driver level debug printing is enabled in DRM, and doesn't
really tell us anything that isn't related to vblanks. So let's move
this over to the proper debug flag to be a little less spammy with our
debug output.

Signed-off-by: Lyude Paul 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 9402374d2466..3675e1c32707 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -407,8 +407,9 @@ static void dm_vupdate_high_irq(void *interrupt_params)
if (acrtc) {
acrtc_state = to_dm_crtc_state(acrtc->base.state);
 
-   DRM_DEBUG_DRIVER("crtc:%d, vupdate-vrr:%d\n", acrtc->crtc_id,
-amdgpu_dm_vrr_active(acrtc_state));
+   DRM_DEBUG_VBL("crtc:%d, vupdate-vrr:%d\n",
+ acrtc->crtc_id,
+ amdgpu_dm_vrr_active(acrtc_state));
 
/* Core vblank handling is done here after end of front-porch in
 * vrr mode, as vblank timestamping will give valid results
@@ -458,8 +459,9 @@ static void dm_crtc_high_irq(void *interrupt_params)
if (acrtc) {
acrtc_state = to_dm_crtc_state(acrtc->base.state);
 
-   DRM_DEBUG_DRIVER("crtc:%d, vupdate-vrr:%d\n", acrtc->crtc_id,
-amdgpu_dm_vrr_active(acrtc_state));
+   DRM_DEBUG_VBL("crtc:%d, vupdate-vrr:%d\n",
+ acrtc->crtc_id,
+ amdgpu_dm_vrr_active(acrtc_state));
 
/* Core vblank handling at start of front-porch is only possible
 * in non-vrr mode, as only there vblank timestamping will give
@@ -522,8 +524,8 @@ static void dm_dcn_crtc_high_irq(void *interrupt_params)
 
acrtc_state = to_dm_crtc_state(acrtc->base.state);
 
-   DRM_DEBUG_DRIVER("crtc:%d, vupdate-vrr:%d\n", acrtc->crtc_id,
-   amdgpu_dm_vrr_active(acrtc_state));
+   DRM_DEBUG_VBL("crtc:%d, vupdate-vrr:%d\n", acrtc->crtc_id,
+ amdgpu_dm_vrr_active(acrtc_state));
 
amdgpu_dm_crtc_handle_crc_irq(>base);
drm_crtc_handle_vblank(>base);
-- 
2.24.1

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


[PATCH] drm/amd/dm/mst: Ignore payload update failures on disable

2020-01-23 Thread Lyude Paul
Disabling a display on MST can potentially happen after the entire MST
topology has been removed, which means that we can't communicate with
the topology at all in this scenario. Likewise, this also means that we
can't properly update payloads on the topology and as such, it's a good
idea to ignore payload update failures when disabling displays.
Currently, amdgpu makes the mistake of halting the payload update
process when any payload update failures occur, resulting in leaving
DC's local copies of the payload tables out of date.

This ends up causing problems with hotplugging MST topologies, and
causes modesets on the second hotplug to fail like so:

[drm] Failed to updateMST allocation table forpipe idx:1
[ cut here ]
WARNING: CPU: 5 PID: 1511 at
drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link.c:2677
update_mst_stream_alloc_table+0x11e/0x130 [amdgpu]
Modules linked in: cdc_ether usbnet fuse xt_conntrack nf_conntrack
nf_defrag_ipv6 libcrc32c nf_defrag_ipv4 ipt_REJECT nf_reject_ipv4
nft_counter nft_compat nf_tables nfnetlink tun bridge stp llc sunrpc
vfat fat wmi_bmof uvcvideo snd_hda_codec_realtek snd_hda_codec_generic
snd_hda_codec_hdmi videobuf2_vmalloc snd_hda_intel videobuf2_memops
videobuf2_v4l2 snd_intel_dspcfg videobuf2_common crct10dif_pclmul
snd_hda_codec videodev crc32_pclmul snd_hwdep snd_hda_core
ghash_clmulni_intel snd_seq mc joydev pcspkr snd_seq_device snd_pcm
sp5100_tco k10temp i2c_piix4 snd_timer thinkpad_acpi ledtrig_audio snd
wmi soundcore video i2c_scmi acpi_cpufreq ip_tables amdgpu(O)
rtsx_pci_sdmmc amd_iommu_v2 gpu_sched mmc_core i2c_algo_bit ttm
drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops cec drm
crc32c_intel serio_raw hid_multitouch r8152 mii nvme r8169 nvme_core
rtsx_pci pinctrl_amd
CPU: 5 PID: 1511 Comm: gnome-shell Tainted: G   O  
5.5.0-rc7Lyude-Test+ #4
Hardware name: LENOVO FA495SIT26/FA495SIT26, BIOS R12ET22W(0.22 ) 01/31/2019
RIP: 0010:update_mst_stream_alloc_table+0x11e/0x130 [amdgpu]
Code: 28 00 00 00 75 2b 48 8d 65 e0 5b 41 5c 41 5d 41 5e 5d c3 0f b6 06
49 89 1c 24 41 88 44 24 08 0f b6 46 01 41 88 44 24 09 eb 93 <0f> 0b e9
2f ff ff ff e8 a6 82 a3 c2 66 0f 1f 44 00 00 0f 1f 44 00
RSP: 0018:ac428127f5b0 EFLAGS: 00010202
RAX: 0002 RBX: 8d1e166eee80 RCX: 
RDX: ac428127f668 RSI: 8d1e166eee80 RDI: ac428127f610
RBP: ac428127f640 R08: c03d94a8 R09: 
R10: 8d1e24b02000 R11: ac428127f5b0 R12: 8d1e1b83d000
R13: 8d1e1bea0b08 R14: 0002 R15: 0002
FS:  7fab23ffcd80() GS:8d1e28b4() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 7f151f1711e8 CR3: 0005997c CR4: 003406e0
Call Trace:
 ? mutex_lock+0xe/0x30
 dc_link_allocate_mst_payload+0x9a/0x210 [amdgpu]
 ? dm_read_reg_func+0x39/0xb0 [amdgpu]
 ? core_link_enable_stream+0x656/0x730 [amdgpu]
 core_link_enable_stream+0x656/0x730 [amdgpu]
 dce110_apply_ctx_to_hw+0x58e/0x5d0 [amdgpu]
 ? dcn10_verify_allow_pstate_change_high+0x1d/0x280 [amdgpu]
 ? dcn10_wait_for_mpcc_disconnect+0x3c/0x130 [amdgpu]
 dc_commit_state+0x292/0x770 [amdgpu]
 ? add_timer+0x101/0x1f0
 ? ttm_bo_put+0x1a1/0x2f0 [ttm]
 amdgpu_dm_atomic_commit_tail+0xb59/0x1ff0 [amdgpu]
 ? amdgpu_move_blit.constprop.0+0xb8/0x1f0 [amdgpu]
 ? amdgpu_bo_move+0x16d/0x2b0 [amdgpu]
 ? ttm_bo_handle_move_mem+0x118/0x570 [ttm]
 ? ttm_bo_validate+0x134/0x150 [ttm]
 ? dm_plane_helper_prepare_fb+0x1b9/0x2a0 [amdgpu]
 ? _cond_resched+0x15/0x30
 ? wait_for_completion_timeout+0x38/0x160
 ? _cond_resched+0x15/0x30
 ? wait_for_completion_interruptible+0x33/0x190
 commit_tail+0x94/0x130 [drm_kms_helper]
 drm_atomic_helper_commit+0x113/0x140 [drm_kms_helper]
 drm_atomic_helper_set_config+0x70/0xb0 [drm_kms_helper]
 drm_mode_setcrtc+0x194/0x6a0 [drm]
 ? _cond_resched+0x15/0x30
 ? mutex_lock+0xe/0x30
 ? drm_mode_getcrtc+0x180/0x180 [drm]
 drm_ioctl_kernel+0xaa/0xf0 [drm]
 drm_ioctl+0x208/0x390 [drm]
 ? drm_mode_getcrtc+0x180/0x180 [drm]
 amdgpu_drm_ioctl+0x49/0x80 [amdgpu]
 do_vfs_ioctl+0x458/0x6d0
 ksys_ioctl+0x5e/0x90
 __x64_sys_ioctl+0x16/0x20
 do_syscall_64+0x55/0x1b0
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7fab2121f87b
Code: 0f 1e fa 48 8b 05 0d 96 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff
ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa b8 10 00 00 00 0f 05 <48> 3d 01
f0 ff ff 73 01 c3 48 8b 0d dd 95 2c 00 f7 d8 64 89 01 48
RSP: 002b:7ffd045f9068 EFLAGS: 0246 ORIG_RAX: 0010
RAX: ffda RBX: 7ffd045f90a0 RCX: 7fab2121f87b
RDX: 7ffd045f90a0 RSI: c06864a2 RDI: 000b
RBP: 7ffd045f90a0 R08:  R09: 55dbd2985d10
R10: 55dbd2196280 R11: 0246 R12: c06864a2
R13: 000b R14:  R15: 55dbd2196280
---[ end trace 6ea888c24d2059cd ]---

Note as well, I have only been able to reproduce this on setups with 2
MST displays.

Signed-off-by: 

Re: [PATCH 2/2] Revert "drm/amd/display: Don't skip link training for empty dongle"

2020-01-23 Thread Harry Wentland
On 2020-01-23 2:45 p.m., Harry Wentland wrote:
> This reverts commit 80adaebd2d411b7d6872a097634848a71eb13d20.
> 
> [WHY]
> This change was working around a regression that occured in this
> patch:
> 0301ccbaf67d drm/amd/display: DP Compliance 400.1.1 failure
> 
> With the fix to run verify_link_cap when the SINK_COUNT of
> dongles becomes non-zero this change is no longer needed.
> 
> Cc: Louis Li 
> Cc: Wenjing Liu 
> Cc: Hersen Wu 
> Cc: Eric Yang 
> Signed-off-by: Harry Wentland 

Both patches have been offline reviewed by Wenjing. I'll merge them with
his review.

Harry

> ---
>  drivers/gpu/drm/amd/display/dc/core/dc_link.c | 10 ++
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c 
> b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
> index cc2e05003595..a09119c10d7c 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
> @@ -851,18 +851,12 @@ static bool dc_link_detect_helper(struct dc_link *link,
>   if (memcmp(>dpcd_caps, _dpcd_caps, 
> sizeof(struct dpcd_caps)))
>   same_dpcd = false;
>   }
> - /* Active dongle plug in without display or downstream 
> unplug*/
> + /* Active dongle downstream unplug*/
>   if (link->type == dc_connection_active_dongle &&
>   link->dpcd_caps.sink_count.bits.SINK_COUNT == 
> 0) {
> - if (prev_sink != NULL) {
> + if (prev_sink != NULL)
>   /* Downstream unplug */
>   dc_sink_release(prev_sink);
> - } else {
> - /* Empty dongle plug in */
> - dp_verify_link_cap_with_retries(link,
> - 
> >reported_link_cap,
> - 
> LINK_TRAINING_MAX_VERIFY_RETRY);
> - }
>   return true;
>   }
>  
> 
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH] drm/amd/amdgpu: fix spelling mistake "to" -> "too"

2020-01-23 Thread Alex Deucher
On Wed, Jan 22, 2020 at 7:22 PM Colin King  wrote:
>
> From: Colin Ian King 
>
> There is a spelling mistake in a DRM_ERROR message. Fix it.
>
> Signed-off-by: Colin Ian King 

Applied.  thanks!

Alex

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> index ceb0dbf685f1..59ddba137946 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> @@ -652,7 +652,7 @@ static int amdgpu_vce_cs_reloc(struct amdgpu_cs_parser 
> *p, uint32_t ib_idx,
>
> if ((addr + (uint64_t)size) >
> (mapping->last + 1) * AMDGPU_GPU_PAGE_SIZE) {
> -   DRM_ERROR("BO to small for addr 0x%010Lx %d %d\n",
> +   DRM_ERROR("BO too small for addr 0x%010Lx %d %d\n",
>   addr, lo, hi);
> return -EINVAL;
> }
> --
> 2.24.0
>
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 2/2] Revert "drm/amd/display: Don't skip link training for empty dongle"

2020-01-23 Thread Harry Wentland
This reverts commit 80adaebd2d411b7d6872a097634848a71eb13d20.

[WHY]
This change was working around a regression that occured in this
patch:
0301ccbaf67d drm/amd/display: DP Compliance 400.1.1 failure

With the fix to run verify_link_cap when the SINK_COUNT of
dongles becomes non-zero this change is no longer needed.

Cc: Louis Li 
Cc: Wenjing Liu 
Cc: Hersen Wu 
Cc: Eric Yang 
Signed-off-by: Harry Wentland 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index cc2e05003595..a09119c10d7c 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -851,18 +851,12 @@ static bool dc_link_detect_helper(struct dc_link *link,
if (memcmp(>dpcd_caps, _dpcd_caps, 
sizeof(struct dpcd_caps)))
same_dpcd = false;
}
-   /* Active dongle plug in without display or downstream 
unplug*/
+   /* Active dongle downstream unplug*/
if (link->type == dc_connection_active_dongle &&
link->dpcd_caps.sink_count.bits.SINK_COUNT == 
0) {
-   if (prev_sink != NULL) {
+   if (prev_sink != NULL)
/* Downstream unplug */
dc_sink_release(prev_sink);
-   } else {
-   /* Empty dongle plug in */
-   dp_verify_link_cap_with_retries(link,
-   
>reported_link_cap,
-   
LINK_TRAINING_MAX_VERIFY_RETRY);
-   }
return true;
}
 
-- 
2.25.0

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


[PATCH 1/2] drm/amd/display: Retrain dongles when SINK_COUNT becomes non-zero

2020-01-23 Thread Harry Wentland
[WHY]
Two years ago the patch referenced by the Fixes tag stopped running
dp_verify_link_cap_with_retries during DP detection when the reason
for the detection was a short-pulse interrupt. This effectively meant
that we were no longer doing the verify_link_cap training on active
dongles when their SINK_COUNT changed from 0 to 1.

A year ago this was partly remedied with this commit:
80adaebd2d41 drm/amd/display: Don't skip link training for empty dongle

This made sure that we trained the dongle on initial hotplug (without
connected downstream devices).

This is all fine and dandy if it weren't for the fact that there are
some dongles on the market that don't like link training when SINK_COUNT
is 0 These dongles will in fact indicate a SINK_COUNT of 0 immediately
after hotplug, even when a downstream device is connected, and then
trigger a shortpulse interrupt indicating a SINK_COUNT change to 1.

In order to play nicely we will need our policy to not link train an
active DP dongle when SINK_COUNT is 0 but ensure we train it when the
SINK_COUNT changes to 1.

[HOW]
Call dp_verify_link_cap_with_retries on detection even when the detection
is triggered from a short pulse interrupt.

With this change we can also revert this commit which we'll do in a separate
follow-up change:
80adaebd2d41 drm/amd/display: Don't skip link training for empty dongle

Fixes: 0301ccbaf67d drm/amd/display: DP Compliance 400.1.1 failure
Suggested-by: Louis Li 
Tested-by: Louis Li 
Cc: Wenjing Liu 
Cc: Hersen Wu 
Cc: Eric Yang 
Signed-off-by: Harry Wentland 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index a50768a7ba68..cc2e05003595 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -969,8 +969,7 @@ static bool dc_link_detect_helper(struct dc_link *link,
same_edid = is_same_edid(_sink->dc_edid, 
>dc_edid);
 
if (link->connector_signal == SIGNAL_TYPE_DISPLAY_PORT &&
-   sink_caps.transaction_type == 
DDC_TRANSACTION_TYPE_I2C_OVER_AUX &&
-   reason != DETECT_REASON_HPDRX) {
+   sink_caps.transaction_type == 
DDC_TRANSACTION_TYPE_I2C_OVER_AUX) {
/*
 * TODO debug why Dell 2413 doesn't like
 *  two link trainings
-- 
2.25.0

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


[pull] amdgpu drm-fixes-5.5

2020-01-23 Thread Alex Deucher
Hi Dave, Daniel,

Just one change to remove the experimental flag from renoir.

The following changes since commit def9d2780727cec3313ed3522d0123158d87224d:

  Linux 5.5-rc7 (2020-01-19 16:02:49 -0800)

are available in the Git repository at:

  git://people.freedesktop.org/~agd5f/linux tags/amd-drm-fixes-5.5-2020-01-23

for you to fetch changes up to 23fe1390c7f13af417069fc0787f7cc82839a6bd:

  drm/amdgpu: remove the experimental flag for renoir (2020-01-23 12:14:53 
-0500)


amd-drm-fixes-5.5-2020-01-23:

amdgpu:
- remove the experimental flag from renoir


Alex Deucher (1):
  drm/amdgpu: remove the experimental flag for renoir

 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


RE: [PATCH 2/2] drm/amdgpu: original raven doesn't support full asic reset

2020-01-23 Thread Zhang, Hawking
[AMD Public Use]

Series is:

Reviewed-by: Hawking Zhang 

Regards,
Hawking

-Original Message-
From: amd-gfx  On Behalf Of Alex Deucher
Sent: Friday, January 24, 2020 01:06
To: amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander 
Subject: [PATCH 2/2] drm/amdgpu: original raven doesn't support full asic reset

So don't use it.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c 
b/drivers/gpu/drm/amd/amdgpu/soc15.c
index af41ee4c9639..15f3424a1ff7 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -537,6 +537,10 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
 
 static int soc15_asic_reset(struct amdgpu_device *adev)  {
+   /* original raven doesn't have full asic reset */
+   if (adev->pdev->device == 0x15dd && adev->rev_id < 0x8)
+   return 0;
+
switch (soc15_asic_reset_method(adev)) {
case AMD_RESET_METHOD_BACO:
if (!adev->in_suspend)
--
2.24.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfxdata=02%7C01%7Chawking.zhang%40amd.com%7C69ec6c70e45d46e9bdf708d7a0268592%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637153959680502484sdata=iKzyHyCwnqWtauduoGmuJv3sHwweJo%2FeG8UdaCvBuDs%3Dreserved=0
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 1/2] drm/amdgpu: attempt to enable gfxoff on more raven1 boards (v2)

2020-01-23 Thread Alex Deucher
Switch to a blacklist so we can disable specific boards
that are problematic.

v2: make the blacklist non-raven specific.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 44 ---
 1 file changed, 40 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 33e851ad4943..67ea6a9e13d9 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -1162,18 +1162,54 @@ static void gfx_v9_0_check_fw_write_wait(struct 
amdgpu_device *adev)
}
 }
 
+struct amdgpu_gfxoff_quirk {
+   u16 chip_vendor;
+   u16 chip_device;
+   u16 subsys_vendor;
+   u16 subsys_device;
+   u8 revision;
+};
+
+static const struct amdgpu_gfxoff_quirk amdgpu_gfxoff_quirk_list[] = {
+   /* https://bugzilla.kernel.org/show_bug.cgi?id=204689 */
+   { 0x1002, 0x15dd, 0x1002, 0x15dd, 0xc8 },
+   { 0, 0, 0, 0, 0 },
+};
+
+static bool gfx_v9_0_should_disable_gfxoff(struct pci_dev *pdev)
+{
+   const struct amdgpu_gfxoff_quirk *p = amdgpu_gfxoff_quirk_list;
+
+   while (p && p->chip_device != 0) {
+   if (pdev->vendor == p->chip_vendor &&
+   pdev->device == p->chip_device &&
+   pdev->subsystem_vendor == p->subsys_vendor &&
+   pdev->subsystem_device == p->subsys_device &&
+   pdev->revision == p->revision) {
+   return true;
+   }
+   ++p;
+   }
+   return false;
+}
+
 static void gfx_v9_0_check_if_need_gfxoff(struct amdgpu_device *adev)
 {
+   if (gfx_v9_0_should_disable_gfxoff(adev->pdev))
+   adev->pm.pp_feature &= ~PP_GFXOFF_MASK;
+
switch (adev->asic_type) {
case CHIP_VEGA10:
case CHIP_VEGA12:
case CHIP_VEGA20:
break;
case CHIP_RAVEN:
-   if (!(adev->rev_id >= 0x8 ||
- adev->pdev->device == 0x15d8) &&
-   (adev->pm.fw_version < 0x41e2b || /* not raven1 fresh */
-!adev->gfx.rlc.is_rlc_v2_1)) /* without rlc save restore 
ucodes */
+   if (!(adev->rev_id >= 0x8 || adev->pdev->device == 0x15d8) &&
+   ((adev->gfx.rlc_fw_version != 106 &&
+ adev->gfx.rlc_fw_version < 531) ||
+(adev->gfx.rlc_fw_version == 53815) ||
+(adev->gfx.rlc_feature_version < 1) ||
+!adev->gfx.rlc.is_rlc_v2_1))
adev->pm.pp_feature &= ~PP_GFXOFF_MASK;
 
if (adev->pm.pp_feature & PP_GFXOFF_MASK)
-- 
2.24.1

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


[PATCH 2/2] drm/amdgpu: original raven doesn't support full asic reset

2020-01-23 Thread Alex Deucher
So don't use it.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c 
b/drivers/gpu/drm/amd/amdgpu/soc15.c
index af41ee4c9639..15f3424a1ff7 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -537,6 +537,10 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
 
 static int soc15_asic_reset(struct amdgpu_device *adev)
 {
+   /* original raven doesn't have full asic reset */
+   if (adev->pdev->device == 0x15dd && adev->rev_id < 0x8)
+   return 0;
+
switch (soc15_asic_reset_method(adev)) {
case AMD_RESET_METHOD_BACO:
if (!adev->in_suspend)
-- 
2.24.1

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


RE: [PATCH] drm/amdgpu: remove the experimental flag for renoir

2020-01-23 Thread Zhang, Hawking
[AMD Official Use Only - Internal Distribution Only]

Reviewed-by: Hawking Zhang 

Regards,
Hawking
-Original Message-
From: amd-gfx  On Behalf Of Alex Deucher
Sent: Friday, January 24, 2020 00:08
To: amd-gfx list 
Cc: Deucher, Alexander 
Subject: Re: [PATCH] drm/amdgpu: remove the experimental flag for renoir

Ping?

Alex

On Wed, Jan 22, 2020 at 11:46 AM Alex Deucher  wrote:
>
> Should work properly with the latest sbios on 5.5 and newer kernels.
>
> Signed-off-by: Alex Deucher 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 01a793a0cbf7..30a1e3ac21d6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -1004,7 +1004,7 @@ static const struct pci_device_id pciidlist[] = {
> {0x1002, 0x734F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14},
>
> /* Renoir */
> -   {0x1002, 0x1636, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
> CHIP_RENOIR|AMD_IS_APU|AMD_EXP_HW_SUPPORT},
> +   {0x1002, 0x1636, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
> + CHIP_RENOIR|AMD_IS_APU},
>
> /* Navi12 */
> {0x1002, 0x7360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
> CHIP_NAVI12|AMD_EXP_HW_SUPPORT},
> --
> 2.24.1
>
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfxdata=02%7C01%7Chawking.zhang%40amd.com%7Cbea189f0eb804f3964cf08d7a01e7897%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637153925050975234sdata=Q8GdcfxnoLYcUrZJfb%2FGDzKxyY5gknAu8KUFZ7Scwso%3Dreserved=0
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 4/4] drm/amdgpu: rework synchronization of VM updates v3

2020-01-23 Thread Christian König

Am 23.01.20 um 16:39 schrieb William Lewis:

Was the change to true from the only use of intr in
amdgpu_bo_sync_wait_resv intentional?  If so, would it not make sense to
remove the argument from the function signature while the API is changing?


That's indeed a copy & paste typo. Thanks for pointing it out.

Christian.



On 1/23/20 8:21 AM, Christian König wrote:

If provided we only sync to the BOs reservation
object and no longer to the root PD.

v2: update comment, cleanup amdgpu_bo_sync_wait_resv
v3: use correct reservation object while clearing

Signed-off-by: Christian König 
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 37 --
   drivers/gpu/drm/amd/amdgpu/amdgpu_object.h  |  3 +++
   drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c|  7 -
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  | 41 
+
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h  |  4 +--
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c  | 22 
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 15 +++
   7 files changed, 67 insertions(+), 62 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 46c76e2e1281..c70bbdda078c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -1403,30 +1403,51 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct 
dma_fence *fence,
   }
   
   /**

- * amdgpu_sync_wait_resv - Wait for BO reservation fences
+ * amdgpu_bo_sync_wait_resv - Wait for BO reservation fences
*
- * @bo: buffer object
+ * @adev: amdgpu device pointer
+ * @resv: reservation object to sync to
+ * @sync_mode: synchronization mode
* @owner: fence owner
* @intr: Whether the wait is interruptible
*
+ * Extract the fences from the reservation object and waits for them to finish.
+ *
* Returns:
* 0 on success, errno otherwise.
*/
-int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct dma_resv *resv,
+enum amdgpu_sync_mode sync_mode, void *owner,
+bool intr)
   {
-   struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
struct amdgpu_sync sync;
int r;
   
   	amdgpu_sync_create();

-   amdgpu_sync_resv(adev, , bo->tbo.base.resv,
-AMDGPU_SYNC_NE_OWNER, owner);
-   r = amdgpu_sync_wait(, intr);
+   amdgpu_sync_resv(adev, , resv, sync_mode, owner);
+   r = amdgpu_sync_wait(, true);
amdgpu_sync_free();
-
return r;
   }
   
+/**

+ * amdgpu_bo_sync_wait - Wrapper for amdgpu_bo_sync_wait_resv
+ * @bo: buffer object to wait for
+ * @owner: fence owner
+ * @intr: Whether the wait is interruptible
+ *
+ * Wrapper to wait for fences in a BO.
+ * Returns:
+ * 0 on success, errno otherwise.
+ */
+int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
+{
+   struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
+
+   return amdgpu_bo_sync_wait_resv(adev, bo->tbo.base.resv,
+   AMDGPU_SYNC_NE_OWNER, owner, intr);
+}
+
   /**
* amdgpu_bo_gpu_offset - return GPU offset of bo
* @bo:  amdgpu object for which we query the offset
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 2eeafc77c9c1..96d805889e8d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -283,6 +283,9 @@ void amdgpu_bo_release_notify(struct ttm_buffer_object *bo);
   int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
   void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
 bool shared);
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct dma_resv *resv,
+enum amdgpu_sync_mode sync_mode, void *owner,
+bool intr);
   int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr);
   u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo);
   int amdgpu_bo_validate(struct amdgpu_bo *bo);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
index 9f42032676da..b86392253696 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
@@ -249,13 +249,6 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, struct 
amdgpu_sync *sync,
owner != AMDGPU_FENCE_OWNER_UNDEFINED)
continue;
   
-		/* VM updates only sync with moves but not with user

-* command submissions or KFD evictions fences
-*/
-   if (fence_owner != AMDGPU_FENCE_OWNER_UNDEFINED &&
-   owner == AMDGPU_FENCE_OWNER_VM)
-   continue;
-
/* Ignore fences depending on the sync mode */
 

[PATCH] drm/amdgpu: allocate entities on demand

2020-01-23 Thread Nirmoy Das
Currently we pre-allocate entities and fences for all the HW IPs on
context creation and some of which are might never be used.

This patch tries to resolve entity/fences wastage by creating entity
only when needed.

Signed-off-by: Nirmoy Das 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 244 +---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h |   2 +-
 2 files changed, 135 insertions(+), 111 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index 05c2af61e7de..73f7615df8c1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -42,19 +42,12 @@ const unsigned int 
amdgpu_ctx_num_entities[AMDGPU_HW_IP_NUM] = {
[AMDGPU_HW_IP_VCN_JPEG] =   1,
 };
 
-static int amdgpu_ctx_total_num_entities(void)
-{
-   unsigned i, num_entities = 0;
-
-   for (i = 0; i < AMDGPU_HW_IP_NUM; ++i)
-   num_entities += amdgpu_ctx_num_entities[i];
-
-   return num_entities;
-}
-
 static int amdgpu_ctx_priority_permit(struct drm_file *filp,
  enum drm_sched_priority priority)
 {
+   if (priority < 0 || priority >= DRM_SCHED_PRIORITY_MAX)
+   return -EINVAL;
+
/* NORMAL and below are accessible by everyone */
if (priority <= DRM_SCHED_PRIORITY_NORMAL)
return 0;
@@ -68,64 +61,44 @@ static int amdgpu_ctx_priority_permit(struct drm_file *filp,
return -EACCES;
 }
 
-static int amdgpu_ctx_init(struct amdgpu_device *adev,
-  enum drm_sched_priority priority,
-  struct drm_file *filp,
-  struct amdgpu_ctx *ctx)
+static int amdgpu_ctx_init_entity(struct amdgpu_ctx *ctx, const u32 hw_ip, 
const u32 ring)
 {
-   unsigned num_entities = amdgpu_ctx_total_num_entities();
-   unsigned i, j;
+   struct amdgpu_device *adev = ctx->adev;
+   struct amdgpu_ctx_entity *entity;
+   struct drm_gpu_scheduler **scheds;
+   struct drm_gpu_scheduler *sched;
+   unsigned num_scheds = 0;
+   enum drm_sched_priority priority;
int r;
 
-   if (priority < 0 || priority >= DRM_SCHED_PRIORITY_MAX)
-   return -EINVAL;
-
-   r = amdgpu_ctx_priority_permit(filp, priority);
-   if (r)
-   return r;
-
-   memset(ctx, 0, sizeof(*ctx));
-   ctx->adev = adev;
-
-
-   ctx->entities[0] = kcalloc(num_entities,
-  sizeof(struct amdgpu_ctx_entity),
-  GFP_KERNEL);
-   if (!ctx->entities[0])
-   return -ENOMEM;
-
-
-   for (i = 0; i < num_entities; ++i) {
-   struct amdgpu_ctx_entity *entity = >entities[0][i];
-
-   entity->sequence = 1;
-   entity->fences = kcalloc(amdgpu_sched_jobs,
-sizeof(struct dma_fence*), GFP_KERNEL);
-   if (!entity->fences) {
-   r = -ENOMEM;
-   goto error_cleanup_memory;
-   }
+   if (!ctx->entities[hw_ip]) {
+   ctx->entities[hw_ip] = kcalloc(amdgpu_ctx_num_entities[hw_ip],
+  sizeof(struct amdgpu_ctx_entity 
*),
+  GFP_KERNEL);
+   if (!ctx->entities[hw_ip])
+   return  -ENOMEM;
}
-   for (i = 1; i < AMDGPU_HW_IP_NUM; ++i)
-   ctx->entities[i] = ctx->entities[i - 1] +
-   amdgpu_ctx_num_entities[i - 1];
 
-   kref_init(>refcount);
-   spin_lock_init(>ring_lock);
-   mutex_init(>lock);
+   ctx->entities[hw_ip][ring] = kcalloc(1, sizeof(struct 
amdgpu_ctx_entity),
+GFP_KERNEL);
+   if (!ctx->entities[hw_ip][ring]) {
+   r = -ENOMEM;
+   goto error_free_entity;
+   }
 
-   ctx->reset_counter = atomic_read(>gpu_reset_counter);
-   ctx->reset_counter_query = ctx->reset_counter;
-   ctx->vram_lost_counter = atomic_read(>vram_lost_counter);
-   ctx->init_priority = priority;
-   ctx->override_priority = DRM_SCHED_PRIORITY_UNSET;
+   entity = ctx->entities[hw_ip][ring];
 
-   for (i = 0; i < AMDGPU_HW_IP_NUM; ++i) {
-   struct drm_gpu_scheduler **scheds;
-   struct drm_gpu_scheduler *sched;
-   unsigned num_scheds = 0;
+   entity->sequence = 1;
+   entity->fences = kcalloc(amdgpu_sched_jobs,
+sizeof(struct dma_fence*), GFP_KERNEL);
+   if (!entity->fences) {
+   r = -ENOMEM;
+   goto error_free_entity;
+   }
 
-   switch (i) {
+   priority = (ctx->override_priority == DRM_SCHED_PRIORITY_UNSET) ?
+   ctx->init_priority : ctx->override_priority;
+   switch (hw_ip) {
case 

Re: [PATCH] drm/amdgpu: remove the experimental flag for renoir

2020-01-23 Thread Alex Deucher
Ping?

Alex

On Wed, Jan 22, 2020 at 11:46 AM Alex Deucher  wrote:
>
> Should work properly with the latest sbios on 5.5 and newer
> kernels.
>
> Signed-off-by: Alex Deucher 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 01a793a0cbf7..30a1e3ac21d6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -1004,7 +1004,7 @@ static const struct pci_device_id pciidlist[] = {
> {0x1002, 0x734F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14},
>
> /* Renoir */
> -   {0x1002, 0x1636, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
> CHIP_RENOIR|AMD_IS_APU|AMD_EXP_HW_SUPPORT},
> +   {0x1002, 0x1636, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
> CHIP_RENOIR|AMD_IS_APU},
>
> /* Navi12 */
> {0x1002, 0x7360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
> CHIP_NAVI12|AMD_EXP_HW_SUPPORT},
> --
> 2.24.1
>
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 4/4] drm/amdgpu: rework synchronization of VM updates v3

2020-01-23 Thread William Lewis
Was the change to true from the only use of intr in 
amdgpu_bo_sync_wait_resv intentional?  If so, would it not make sense to 
remove the argument from the function signature while the API is changing?

On 1/23/20 8:21 AM, Christian König wrote:
> If provided we only sync to the BOs reservation
> object and no longer to the root PD.
>
> v2: update comment, cleanup amdgpu_bo_sync_wait_resv
> v3: use correct reservation object while clearing
>
> Signed-off-by: Christian König 
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 37 --
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.h  |  3 +++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c|  7 -
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  | 41 
> +
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h  |  4 +--
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c  | 22 
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 15 +++
>   7 files changed, 67 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 46c76e2e1281..c70bbdda078c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -1403,30 +1403,51 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct 
> dma_fence *fence,
>   }
>   
>   /**
> - * amdgpu_sync_wait_resv - Wait for BO reservation fences
> + * amdgpu_bo_sync_wait_resv - Wait for BO reservation fences
>*
> - * @bo: buffer object
> + * @adev: amdgpu device pointer
> + * @resv: reservation object to sync to
> + * @sync_mode: synchronization mode
>* @owner: fence owner
>* @intr: Whether the wait is interruptible
>*
> + * Extract the fences from the reservation object and waits for them to 
> finish.
> + *
>* Returns:
>* 0 on success, errno otherwise.
>*/
> -int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
> +int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct dma_resv 
> *resv,
> +  enum amdgpu_sync_mode sync_mode, void *owner,
> +  bool intr)
>   {
> - struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
>   struct amdgpu_sync sync;
>   int r;
>   
>   amdgpu_sync_create();
> - amdgpu_sync_resv(adev, , bo->tbo.base.resv,
> -  AMDGPU_SYNC_NE_OWNER, owner);
> - r = amdgpu_sync_wait(, intr);
> + amdgpu_sync_resv(adev, , resv, sync_mode, owner);
> + r = amdgpu_sync_wait(, true);
>   amdgpu_sync_free();
> -
>   return r;
>   }
>   
> +/**
> + * amdgpu_bo_sync_wait - Wrapper for amdgpu_bo_sync_wait_resv
> + * @bo: buffer object to wait for
> + * @owner: fence owner
> + * @intr: Whether the wait is interruptible
> + *
> + * Wrapper to wait for fences in a BO.
> + * Returns:
> + * 0 on success, errno otherwise.
> + */
> +int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
> +{
> + struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
> +
> + return amdgpu_bo_sync_wait_resv(adev, bo->tbo.base.resv,
> + AMDGPU_SYNC_NE_OWNER, owner, intr);
> +}
> +
>   /**
>* amdgpu_bo_gpu_offset - return GPU offset of bo
>* @bo: amdgpu object for which we query the offset
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> index 2eeafc77c9c1..96d805889e8d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
> @@ -283,6 +283,9 @@ void amdgpu_bo_release_notify(struct ttm_buffer_object 
> *bo);
>   int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
>   void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
>bool shared);
> +int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct dma_resv 
> *resv,
> +  enum amdgpu_sync_mode sync_mode, void *owner,
> +  bool intr);
>   int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr);
>   u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo);
>   int amdgpu_bo_validate(struct amdgpu_bo *bo);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
> index 9f42032676da..b86392253696 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
> @@ -249,13 +249,6 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, struct 
> amdgpu_sync *sync,
>   owner != AMDGPU_FENCE_OWNER_UNDEFINED)
>   continue;
>   
> - /* VM updates only sync with moves but not with user
> -  * command submissions or KFD evictions fences
> -  */
> - if (fence_owner != AMDGPU_FENCE_OWNER_UNDEFINED &&
> - owner == AMDGPU_FENCE_OWNER_VM)
> - continue;
> -
>   /* 

Re: [PATCH 4/4] drm/amdgpu: rework synchronization of VM updates v3

2020-01-23 Thread Tom St Denis
I've tested piglit, unigine-heaven, and video playback on my 
navi10/raven1 system.  All fine (as far as the kernel is concerned).  
You can add my



Tested-by: Tom St Denis 


Tom

On 2020-01-23 9:35 a.m., Christian König wrote:

That is fixed by patch #2 in this series.

Patch #4 is then re-applying the faulty synchronization cleanup.

Regards,
Christian.

Am 23.01.20 um 15:25 schrieb Tom St Denis:

On the tip of drm-next (as of this morning) I was still getting

[  983.891264] [drm:amdgpu_gem_va_ioctl [amdgpu]] *ERROR* Couldn't 
update BO_VA (-2)


type errors.  So I'm looking for that to stop.  At least LLVM was 
fixed so I can run a full run of piglit without gfx hangs.


Tom

On 2020-01-23 9:24 a.m., Christian König wrote:

Thanks, please give them a full round.

Took me a week to figure out that we accidentally pass in the 
reservation object as NULL for cleared BOs.


Thanks,
Christian.

Am 23.01.20 um 15:22 schrieb Tom St Denis:

Just applied these now, trying them out will report back in ~20 mins.

On 2020-01-23 9:21 a.m., Christian König wrote:

If provided we only sync to the BOs reservation
object and no longer to the root PD.

v2: update comment, cleanup amdgpu_bo_sync_wait_resv
v3: use correct reservation object while clearing

Signed-off-by: Christian König 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 37 
--

  drivers/gpu/drm/amd/amdgpu/amdgpu_object.h  |  3 +++
  drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c    |  7 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  | 41 
+

  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h  |  4 +--
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c  | 22 
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 15 +++
  7 files changed, 67 insertions(+), 62 deletions(-)

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

index 46c76e2e1281..c70bbdda078c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -1403,30 +1403,51 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, 
struct dma_fence *fence,

  }
    /**
- * amdgpu_sync_wait_resv - Wait for BO reservation fences
+ * amdgpu_bo_sync_wait_resv - Wait for BO reservation fences
   *
- * @bo: buffer object
+ * @adev: amdgpu device pointer
+ * @resv: reservation object to sync to
+ * @sync_mode: synchronization mode
   * @owner: fence owner
   * @intr: Whether the wait is interruptible
   *
+ * Extract the fences from the reservation object and waits for 
them to finish.

+ *
   * Returns:
   * 0 on success, errno otherwise.
   */
-int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool 
intr)
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct 
dma_resv *resv,

+ enum amdgpu_sync_mode sync_mode, void *owner,
+ bool intr)
  {
-    struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
  struct amdgpu_sync sync;
  int r;
    amdgpu_sync_create();
-    amdgpu_sync_resv(adev, , bo->tbo.base.resv,
- AMDGPU_SYNC_NE_OWNER, owner);
-    r = amdgpu_sync_wait(, intr);
+    amdgpu_sync_resv(adev, , resv, sync_mode, owner);
+    r = amdgpu_sync_wait(, true);
  amdgpu_sync_free();
-
  return r;
  }
  +/**
+ * amdgpu_bo_sync_wait - Wrapper for amdgpu_bo_sync_wait_resv
+ * @bo: buffer object to wait for
+ * @owner: fence owner
+ * @intr: Whether the wait is interruptible
+ *
+ * Wrapper to wait for fences in a BO.
+ * Returns:
+ * 0 on success, errno otherwise.
+ */
+int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool 
intr)

+{
+    struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
+
+    return amdgpu_bo_sync_wait_resv(adev, bo->tbo.base.resv,
+    AMDGPU_SYNC_NE_OWNER, owner, intr);
+}
+
  /**
   * amdgpu_bo_gpu_offset - return GPU offset of bo
   * @bo:    amdgpu object for which we query the offset
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h

index 2eeafc77c9c1..96d805889e8d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -283,6 +283,9 @@ void amdgpu_bo_release_notify(struct 
ttm_buffer_object *bo);

  int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
  void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
   bool shared);
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct 
dma_resv *resv,

+ enum amdgpu_sync_mode sync_mode, void *owner,
+ bool intr);
  int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool 
intr);

  u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo);
  int amdgpu_bo_validate(struct amdgpu_bo *bo);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c

index 9f42032676da..b86392253696 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ 

Re: [PATCH 4/4] drm/amdgpu: rework synchronization of VM updates v3

2020-01-23 Thread Christian König

That is fixed by patch #2 in this series.

Patch #4 is then re-applying the faulty synchronization cleanup.

Regards,
Christian.

Am 23.01.20 um 15:25 schrieb Tom St Denis:

On the tip of drm-next (as of this morning) I was still getting

[  983.891264] [drm:amdgpu_gem_va_ioctl [amdgpu]] *ERROR* Couldn't 
update BO_VA (-2)


type errors.  So I'm looking for that to stop.  At least LLVM was 
fixed so I can run a full run of piglit without gfx hangs.


Tom

On 2020-01-23 9:24 a.m., Christian König wrote:

Thanks, please give them a full round.

Took me a week to figure out that we accidentally pass in the 
reservation object as NULL for cleared BOs.


Thanks,
Christian.

Am 23.01.20 um 15:22 schrieb Tom St Denis:

Just applied these now, trying them out will report back in ~20 mins.

On 2020-01-23 9:21 a.m., Christian König wrote:

If provided we only sync to the BOs reservation
object and no longer to the root PD.

v2: update comment, cleanup amdgpu_bo_sync_wait_resv
v3: use correct reservation object while clearing

Signed-off-by: Christian König 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 37 
--

  drivers/gpu/drm/amd/amdgpu/amdgpu_object.h  |  3 +++
  drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c    |  7 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  | 41 
+

  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h  |  4 +--
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c  | 22 
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 15 +++
  7 files changed, 67 insertions(+), 62 deletions(-)

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

index 46c76e2e1281..c70bbdda078c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -1403,30 +1403,51 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, 
struct dma_fence *fence,

  }
    /**
- * amdgpu_sync_wait_resv - Wait for BO reservation fences
+ * amdgpu_bo_sync_wait_resv - Wait for BO reservation fences
   *
- * @bo: buffer object
+ * @adev: amdgpu device pointer
+ * @resv: reservation object to sync to
+ * @sync_mode: synchronization mode
   * @owner: fence owner
   * @intr: Whether the wait is interruptible
   *
+ * Extract the fences from the reservation object and waits for 
them to finish.

+ *
   * Returns:
   * 0 on success, errno otherwise.
   */
-int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct 
dma_resv *resv,

+ enum amdgpu_sync_mode sync_mode, void *owner,
+ bool intr)
  {
-    struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
  struct amdgpu_sync sync;
  int r;
    amdgpu_sync_create();
-    amdgpu_sync_resv(adev, , bo->tbo.base.resv,
- AMDGPU_SYNC_NE_OWNER, owner);
-    r = amdgpu_sync_wait(, intr);
+    amdgpu_sync_resv(adev, , resv, sync_mode, owner);
+    r = amdgpu_sync_wait(, true);
  amdgpu_sync_free();
-
  return r;
  }
  +/**
+ * amdgpu_bo_sync_wait - Wrapper for amdgpu_bo_sync_wait_resv
+ * @bo: buffer object to wait for
+ * @owner: fence owner
+ * @intr: Whether the wait is interruptible
+ *
+ * Wrapper to wait for fences in a BO.
+ * Returns:
+ * 0 on success, errno otherwise.
+ */
+int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
+{
+    struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
+
+    return amdgpu_bo_sync_wait_resv(adev, bo->tbo.base.resv,
+    AMDGPU_SYNC_NE_OWNER, owner, intr);
+}
+
  /**
   * amdgpu_bo_gpu_offset - return GPU offset of bo
   * @bo:    amdgpu object for which we query the offset
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h

index 2eeafc77c9c1..96d805889e8d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -283,6 +283,9 @@ void amdgpu_bo_release_notify(struct 
ttm_buffer_object *bo);

  int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
  void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
   bool shared);
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct 
dma_resv *resv,

+ enum amdgpu_sync_mode sync_mode, void *owner,
+ bool intr);
  int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool 
intr);

  u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo);
  int amdgpu_bo_validate(struct amdgpu_bo *bo);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c

index 9f42032676da..b86392253696 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
@@ -249,13 +249,6 @@ int amdgpu_sync_resv(struct amdgpu_device 
*adev, struct amdgpu_sync *sync,

  owner != AMDGPU_FENCE_OWNER_UNDEFINED)
  continue;
  -    /* VM updates only 

Re: [PATCH 4/4] drm/amdgpu: rework synchronization of VM updates v3

2020-01-23 Thread Tom St Denis

On the tip of drm-next (as of this morning) I was still getting

[  983.891264] [drm:amdgpu_gem_va_ioctl [amdgpu]] *ERROR* Couldn't 
update BO_VA (-2)


type errors.  So I'm looking for that to stop.  At least LLVM was fixed 
so I can run a full run of piglit without gfx hangs.


Tom

On 2020-01-23 9:24 a.m., Christian König wrote:

Thanks, please give them a full round.

Took me a week to figure out that we accidentally pass in the 
reservation object as NULL for cleared BOs.


Thanks,
Christian.

Am 23.01.20 um 15:22 schrieb Tom St Denis:

Just applied these now, trying them out will report back in ~20 mins.

On 2020-01-23 9:21 a.m., Christian König wrote:

If provided we only sync to the BOs reservation
object and no longer to the root PD.

v2: update comment, cleanup amdgpu_bo_sync_wait_resv
v3: use correct reservation object while clearing

Signed-off-by: Christian König 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 37 
--

  drivers/gpu/drm/amd/amdgpu/amdgpu_object.h  |  3 +++
  drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c    |  7 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  | 41 
+

  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h  |  4 +--
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c  | 22 
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 15 +++
  7 files changed, 67 insertions(+), 62 deletions(-)

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

index 46c76e2e1281..c70bbdda078c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -1403,30 +1403,51 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, 
struct dma_fence *fence,

  }
    /**
- * amdgpu_sync_wait_resv - Wait for BO reservation fences
+ * amdgpu_bo_sync_wait_resv - Wait for BO reservation fences
   *
- * @bo: buffer object
+ * @adev: amdgpu device pointer
+ * @resv: reservation object to sync to
+ * @sync_mode: synchronization mode
   * @owner: fence owner
   * @intr: Whether the wait is interruptible
   *
+ * Extract the fences from the reservation object and waits for 
them to finish.

+ *
   * Returns:
   * 0 on success, errno otherwise.
   */
-int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct 
dma_resv *resv,

+ enum amdgpu_sync_mode sync_mode, void *owner,
+ bool intr)
  {
-    struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
  struct amdgpu_sync sync;
  int r;
    amdgpu_sync_create();
-    amdgpu_sync_resv(adev, , bo->tbo.base.resv,
- AMDGPU_SYNC_NE_OWNER, owner);
-    r = amdgpu_sync_wait(, intr);
+    amdgpu_sync_resv(adev, , resv, sync_mode, owner);
+    r = amdgpu_sync_wait(, true);
  amdgpu_sync_free();
-
  return r;
  }
  +/**
+ * amdgpu_bo_sync_wait - Wrapper for amdgpu_bo_sync_wait_resv
+ * @bo: buffer object to wait for
+ * @owner: fence owner
+ * @intr: Whether the wait is interruptible
+ *
+ * Wrapper to wait for fences in a BO.
+ * Returns:
+ * 0 on success, errno otherwise.
+ */
+int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
+{
+    struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
+
+    return amdgpu_bo_sync_wait_resv(adev, bo->tbo.base.resv,
+    AMDGPU_SYNC_NE_OWNER, owner, intr);
+}
+
  /**
   * amdgpu_bo_gpu_offset - return GPU offset of bo
   * @bo:    amdgpu object for which we query the offset
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h

index 2eeafc77c9c1..96d805889e8d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -283,6 +283,9 @@ void amdgpu_bo_release_notify(struct 
ttm_buffer_object *bo);

  int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
  void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
   bool shared);
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct 
dma_resv *resv,

+ enum amdgpu_sync_mode sync_mode, void *owner,
+ bool intr);
  int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool 
intr);

  u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo);
  int amdgpu_bo_validate(struct amdgpu_bo *bo);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c

index 9f42032676da..b86392253696 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
@@ -249,13 +249,6 @@ int amdgpu_sync_resv(struct amdgpu_device 
*adev, struct amdgpu_sync *sync,

  owner != AMDGPU_FENCE_OWNER_UNDEFINED)
  continue;
  -    /* VM updates only sync with moves but not with user
- * command submissions or KFD evictions fences
- */
-    if (fence_owner != AMDGPU_FENCE_OWNER_UNDEFINED &&
-    

Re: [PATCH 4/4] drm/amdgpu: rework synchronization of VM updates v3

2020-01-23 Thread Christian König

Thanks, please give them a full round.

Took me a week to figure out that we accidentally pass in the 
reservation object as NULL for cleared BOs.


Thanks,
Christian.

Am 23.01.20 um 15:22 schrieb Tom St Denis:

Just applied these now, trying them out will report back in ~20 mins.

On 2020-01-23 9:21 a.m., Christian König wrote:

If provided we only sync to the BOs reservation
object and no longer to the root PD.

v2: update comment, cleanup amdgpu_bo_sync_wait_resv
v3: use correct reservation object while clearing

Signed-off-by: Christian König 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 37 
--

  drivers/gpu/drm/amd/amdgpu/amdgpu_object.h  |  3 +++
  drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c    |  7 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  | 41 
+

  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h  |  4 +--
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c  | 22 
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 15 +++
  7 files changed, 67 insertions(+), 62 deletions(-)

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

index 46c76e2e1281..c70bbdda078c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -1403,30 +1403,51 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, 
struct dma_fence *fence,

  }
    /**
- * amdgpu_sync_wait_resv - Wait for BO reservation fences
+ * amdgpu_bo_sync_wait_resv - Wait for BO reservation fences
   *
- * @bo: buffer object
+ * @adev: amdgpu device pointer
+ * @resv: reservation object to sync to
+ * @sync_mode: synchronization mode
   * @owner: fence owner
   * @intr: Whether the wait is interruptible
   *
+ * Extract the fences from the reservation object and waits for them 
to finish.

+ *
   * Returns:
   * 0 on success, errno otherwise.
   */
-int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct 
dma_resv *resv,

+ enum amdgpu_sync_mode sync_mode, void *owner,
+ bool intr)
  {
-    struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
  struct amdgpu_sync sync;
  int r;
    amdgpu_sync_create();
-    amdgpu_sync_resv(adev, , bo->tbo.base.resv,
- AMDGPU_SYNC_NE_OWNER, owner);
-    r = amdgpu_sync_wait(, intr);
+    amdgpu_sync_resv(adev, , resv, sync_mode, owner);
+    r = amdgpu_sync_wait(, true);
  amdgpu_sync_free();
-
  return r;
  }
  +/**
+ * amdgpu_bo_sync_wait - Wrapper for amdgpu_bo_sync_wait_resv
+ * @bo: buffer object to wait for
+ * @owner: fence owner
+ * @intr: Whether the wait is interruptible
+ *
+ * Wrapper to wait for fences in a BO.
+ * Returns:
+ * 0 on success, errno otherwise.
+ */
+int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
+{
+    struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
+
+    return amdgpu_bo_sync_wait_resv(adev, bo->tbo.base.resv,
+    AMDGPU_SYNC_NE_OWNER, owner, intr);
+}
+
  /**
   * amdgpu_bo_gpu_offset - return GPU offset of bo
   * @bo:    amdgpu object for which we query the offset
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h

index 2eeafc77c9c1..96d805889e8d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -283,6 +283,9 @@ void amdgpu_bo_release_notify(struct 
ttm_buffer_object *bo);

  int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
  void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
   bool shared);
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct 
dma_resv *resv,

+ enum amdgpu_sync_mode sync_mode, void *owner,
+ bool intr);
  int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr);
  u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo);
  int amdgpu_bo_validate(struct amdgpu_bo *bo);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c

index 9f42032676da..b86392253696 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
@@ -249,13 +249,6 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, 
struct amdgpu_sync *sync,

  owner != AMDGPU_FENCE_OWNER_UNDEFINED)
  continue;
  -    /* VM updates only sync with moves but not with user
- * command submissions or KFD evictions fences
- */
-    if (fence_owner != AMDGPU_FENCE_OWNER_UNDEFINED &&
-    owner == AMDGPU_FENCE_OWNER_VM)
-    continue;
-
  /* Ignore fences depending on the sync mode */
  switch (mode) {
  case AMDGPU_SYNC_ALWAYS:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

index 0f79c17118bf..c268aa14381e 100644
--- 

Re: [PATCH 4/4] drm/amdgpu: rework synchronization of VM updates v3

2020-01-23 Thread Tom St Denis

Just applied these now, trying them out will report back in ~20 mins.

On 2020-01-23 9:21 a.m., Christian König wrote:

If provided we only sync to the BOs reservation
object and no longer to the root PD.

v2: update comment, cleanup amdgpu_bo_sync_wait_resv
v3: use correct reservation object while clearing

Signed-off-by: Christian König 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 37 --
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.h  |  3 +++
  drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c|  7 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  | 41 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h  |  4 +--
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c  | 22 
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 15 +++
  7 files changed, 67 insertions(+), 62 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 46c76e2e1281..c70bbdda078c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -1403,30 +1403,51 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct 
dma_fence *fence,
  }
  
  /**

- * amdgpu_sync_wait_resv - Wait for BO reservation fences
+ * amdgpu_bo_sync_wait_resv - Wait for BO reservation fences
   *
- * @bo: buffer object
+ * @adev: amdgpu device pointer
+ * @resv: reservation object to sync to
+ * @sync_mode: synchronization mode
   * @owner: fence owner
   * @intr: Whether the wait is interruptible
   *
+ * Extract the fences from the reservation object and waits for them to finish.
+ *
   * Returns:
   * 0 on success, errno otherwise.
   */
-int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct dma_resv *resv,
+enum amdgpu_sync_mode sync_mode, void *owner,
+bool intr)
  {
-   struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
struct amdgpu_sync sync;
int r;
  
  	amdgpu_sync_create();

-   amdgpu_sync_resv(adev, , bo->tbo.base.resv,
-AMDGPU_SYNC_NE_OWNER, owner);
-   r = amdgpu_sync_wait(, intr);
+   amdgpu_sync_resv(adev, , resv, sync_mode, owner);
+   r = amdgpu_sync_wait(, true);
amdgpu_sync_free();
-
return r;
  }
  
+/**

+ * amdgpu_bo_sync_wait - Wrapper for amdgpu_bo_sync_wait_resv
+ * @bo: buffer object to wait for
+ * @owner: fence owner
+ * @intr: Whether the wait is interruptible
+ *
+ * Wrapper to wait for fences in a BO.
+ * Returns:
+ * 0 on success, errno otherwise.
+ */
+int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
+{
+   struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
+
+   return amdgpu_bo_sync_wait_resv(adev, bo->tbo.base.resv,
+   AMDGPU_SYNC_NE_OWNER, owner, intr);
+}
+
  /**
   * amdgpu_bo_gpu_offset - return GPU offset of bo
   * @bo:   amdgpu object for which we query the offset
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 2eeafc77c9c1..96d805889e8d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -283,6 +283,9 @@ void amdgpu_bo_release_notify(struct ttm_buffer_object *bo);
  int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
  void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
 bool shared);
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct dma_resv *resv,
+enum amdgpu_sync_mode sync_mode, void *owner,
+bool intr);
  int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr);
  u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo);
  int amdgpu_bo_validate(struct amdgpu_bo *bo);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
index 9f42032676da..b86392253696 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
@@ -249,13 +249,6 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, struct 
amdgpu_sync *sync,
owner != AMDGPU_FENCE_OWNER_UNDEFINED)
continue;
  
-		/* VM updates only sync with moves but not with user

-* command submissions or KFD evictions fences
-*/
-   if (fence_owner != AMDGPU_FENCE_OWNER_UNDEFINED &&
-   owner == AMDGPU_FENCE_OWNER_VM)
-   continue;
-
/* Ignore fences depending on the sync mode */
switch (mode) {
case AMDGPU_SYNC_ALWAYS:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 0f79c17118bf..c268aa14381e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ 

[PATCH 2/4] drm/amdgpu: allow higher level PD invalidations

2020-01-23 Thread Christian König
Allow partial invalidation on unallocated PDs. This is useful when we
need to silence faults to stop interrupt floods on Vega.

Signed-off-by: Christian König 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 8119f32ca94d..0f79c17118bf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1467,9 +1467,8 @@ static int amdgpu_vm_update_ptes(struct 
amdgpu_vm_update_params *params,
 * smaller than the address shift. Go to the next
 * child entry and try again.
 */
-   if (!amdgpu_vm_pt_descendant(adev, ))
-   return -ENOENT;
-   continue;
+   if (amdgpu_vm_pt_descendant(adev, ))
+   continue;
} else if (frag >= parent_shift) {
/* If the fragment size is even larger than the parent
 * shift we should go up one level and check it again.
@@ -1480,8 +1479,19 @@ static int amdgpu_vm_update_ptes(struct 
amdgpu_vm_update_params *params,
}
 
pt = cursor.entry->base.bo;
-   if (!pt)
-   return -ENOENT;
+   if (!pt) {
+   /* We need all PDs and PTs for mapping something, */
+   if (flags & AMDGPU_PTE_VALID)
+   return -ENOENT;
+
+   /* but unmapping something can happen at a higher
+* level. */
+   if (!amdgpu_vm_pt_ancestor())
+   return -EINVAL;
+
+   pt = cursor.entry->base.bo;
+   shift = parent_shift;
+   }
 
/* Looks good so far, calculate parameters for the update */
incr = (uint64_t)AMDGPU_GPU_PAGE_SIZE << shift;
@@ -1495,6 +1505,9 @@ static int amdgpu_vm_update_ptes(struct 
amdgpu_vm_update_params *params,
uint64_t upd_end = min(entry_end, frag_end);
unsigned nptes = (upd_end - frag_start) >> shift;
 
+   /* This can happen when we set higher level PDs to
+* silent to stop fault floods. */
+   nptes = max(nptes, 1u);
amdgpu_vm_update_flags(params, pt, cursor.level,
   pe_start, dst, nptes, incr,
   flags | AMDGPU_PTE_FRAG(frag));
-- 
2.14.1

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


[PATCH 1/4] drm/amdgpu: return EINVAL instead of ENOENT in the VM code

2020-01-23 Thread Christian König
That we can't find a PD above the root is expected can only happen if
we try to update a larger range than actually managed by the VM.

Signed-off-by: Christian König 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 5cb182231f5d..8119f32ca94d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1475,7 +1475,7 @@ static int amdgpu_vm_update_ptes(struct 
amdgpu_vm_update_params *params,
 * shift we should go up one level and check it again.
 */
if (!amdgpu_vm_pt_ancestor())
-   return -ENOENT;
+   return -EINVAL;
continue;
}
 
-- 
2.14.1

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


[PATCH 4/4] drm/amdgpu: rework synchronization of VM updates v3

2020-01-23 Thread Christian König
If provided we only sync to the BOs reservation
object and no longer to the root PD.

v2: update comment, cleanup amdgpu_bo_sync_wait_resv
v3: use correct reservation object while clearing

Signed-off-by: Christian König 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 37 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h  |  3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c|  7 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  | 41 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h  |  4 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c  | 22 
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 15 +++
 7 files changed, 67 insertions(+), 62 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 46c76e2e1281..c70bbdda078c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -1403,30 +1403,51 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct 
dma_fence *fence,
 }
 
 /**
- * amdgpu_sync_wait_resv - Wait for BO reservation fences
+ * amdgpu_bo_sync_wait_resv - Wait for BO reservation fences
  *
- * @bo: buffer object
+ * @adev: amdgpu device pointer
+ * @resv: reservation object to sync to
+ * @sync_mode: synchronization mode
  * @owner: fence owner
  * @intr: Whether the wait is interruptible
  *
+ * Extract the fences from the reservation object and waits for them to finish.
+ *
  * Returns:
  * 0 on success, errno otherwise.
  */
-int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct dma_resv *resv,
+enum amdgpu_sync_mode sync_mode, void *owner,
+bool intr)
 {
-   struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
struct amdgpu_sync sync;
int r;
 
amdgpu_sync_create();
-   amdgpu_sync_resv(adev, , bo->tbo.base.resv,
-AMDGPU_SYNC_NE_OWNER, owner);
-   r = amdgpu_sync_wait(, intr);
+   amdgpu_sync_resv(adev, , resv, sync_mode, owner);
+   r = amdgpu_sync_wait(, true);
amdgpu_sync_free();
-
return r;
 }
 
+/**
+ * amdgpu_bo_sync_wait - Wrapper for amdgpu_bo_sync_wait_resv
+ * @bo: buffer object to wait for
+ * @owner: fence owner
+ * @intr: Whether the wait is interruptible
+ *
+ * Wrapper to wait for fences in a BO.
+ * Returns:
+ * 0 on success, errno otherwise.
+ */
+int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr)
+{
+   struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
+
+   return amdgpu_bo_sync_wait_resv(adev, bo->tbo.base.resv,
+   AMDGPU_SYNC_NE_OWNER, owner, intr);
+}
+
 /**
  * amdgpu_bo_gpu_offset - return GPU offset of bo
  * @bo:amdgpu object for which we query the offset
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 2eeafc77c9c1..96d805889e8d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -283,6 +283,9 @@ void amdgpu_bo_release_notify(struct ttm_buffer_object *bo);
 int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
 void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
 bool shared);
+int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct dma_resv *resv,
+enum amdgpu_sync_mode sync_mode, void *owner,
+bool intr);
 int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr);
 u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo);
 int amdgpu_bo_validate(struct amdgpu_bo *bo);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
index 9f42032676da..b86392253696 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
@@ -249,13 +249,6 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, struct 
amdgpu_sync *sync,
owner != AMDGPU_FENCE_OWNER_UNDEFINED)
continue;
 
-   /* VM updates only sync with moves but not with user
-* command submissions or KFD evictions fences
-*/
-   if (fence_owner != AMDGPU_FENCE_OWNER_UNDEFINED &&
-   owner == AMDGPU_FENCE_OWNER_VM)
-   continue;
-
/* Ignore fences depending on the sync mode */
switch (mode) {
case AMDGPU_SYNC_ALWAYS:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 0f79c17118bf..c268aa14381e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -797,7 +797,7 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
params.vm = vm;

[PATCH 3/4] drm/amdgpu: simplify and fix amdgpu_sync_resv

2020-01-23 Thread Christian König
No matter what we always need to sync to moves.

Signed-off-by: Christian König 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
index c124f64e7aae..9f42032676da 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
@@ -232,10 +232,19 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, struct 
amdgpu_sync *sync,
 
f = rcu_dereference_protected(flist->shared[i],
  dma_resv_held(resv));
+
+   fence_owner = amdgpu_sync_get_owner(f);
+
+   /* Always sync to moves, no matter what */
+   if (fence_owner == AMDGPU_FENCE_OWNER_UNDEFINED) {
+   r = amdgpu_sync_fence(sync, f, false);
+   if (r)
+   break;
+   }
+
/* We only want to trigger KFD eviction fences on
 * evict or move jobs. Skip KFD fences otherwise.
 */
-   fence_owner = amdgpu_sync_get_owner(f);
if (fence_owner == AMDGPU_FENCE_OWNER_KFD &&
owner != AMDGPU_FENCE_OWNER_UNDEFINED)
continue;
@@ -265,9 +274,7 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, struct 
amdgpu_sync *sync,
break;
 
case AMDGPU_SYNC_EXPLICIT:
-   if (owner != AMDGPU_FENCE_OWNER_UNDEFINED)
-   continue;
-   break;
+   continue;
}
 
r = amdgpu_sync_fence(sync, f, false);
-- 
2.14.1

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


[PATCH v4 20/22] drm/vmwgfx: Convert to CRTC VBLANK callbacks

2020-01-23 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert vmwgfx over.

v2:
* remove accidental whitespace fixes

Signed-off-by: Thomas Zimmermann 
Acked-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c  | 3 ---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h  | 6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  | 6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c  | 3 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 3 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 3 +++
 6 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index e962048f65d2..673d6920fc29 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1393,9 +1393,6 @@ static struct drm_driver driver = {
DRIVER_MODESET | DRIVER_RENDER | DRIVER_ATOMIC,
.load = vmw_driver_load,
.unload = vmw_driver_unload,
-   .get_vblank_counter = vmw_get_vblank_counter,
-   .enable_vblank = vmw_enable_vblank,
-   .disable_vblank = vmw_disable_vblank,
.ioctls = vmw_ioctls,
.num_ioctls = ARRAY_SIZE(vmw_ioctls),
.master_set = vmw_master_set,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index a31e726d6d71..845b3b8c29ca 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -1100,9 +1100,9 @@ int vmw_kms_write_svga(struct vmw_private *vmw_priv,
 bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv,
uint32_t pitch,
uint32_t height);
-u32 vmw_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
-int vmw_enable_vblank(struct drm_device *dev, unsigned int pipe);
-void vmw_disable_vblank(struct drm_device *dev, unsigned int pipe);
+u32 vmw_get_vblank_counter(struct drm_crtc *crtc);
+int vmw_enable_vblank(struct drm_crtc *crtc);
+void vmw_disable_vblank(struct drm_crtc *crtc);
 int vmw_kms_present(struct vmw_private *dev_priv,
struct drm_file *file_priv,
struct vmw_framebuffer *vfb,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index f47d5710cc95..eb6e23e8d8ef 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -1991,7 +1991,7 @@ bool vmw_kms_validate_mode_vram(struct vmw_private 
*dev_priv,
 /**
  * Function called by DRM code called with vbl_lock held.
  */
-u32 vmw_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
+u32 vmw_get_vblank_counter(struct drm_crtc *crtc)
 {
return 0;
 }
@@ -1999,7 +1999,7 @@ u32 vmw_get_vblank_counter(struct drm_device *dev, 
unsigned int pipe)
 /**
  * Function called by DRM code called with vbl_lock held.
  */
-int vmw_enable_vblank(struct drm_device *dev, unsigned int pipe)
+int vmw_enable_vblank(struct drm_crtc *crtc)
 {
return -EINVAL;
 }
@@ -2007,7 +2007,7 @@ int vmw_enable_vblank(struct drm_device *dev, unsigned 
int pipe)
 /**
  * Function called by DRM code called with vbl_lock held.
  */
-void vmw_disable_vblank(struct drm_device *dev, unsigned int pipe)
+void vmw_disable_vblank(struct drm_crtc *crtc)
 {
 }
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index 5702219ec38f..16dafff5cab1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -236,6 +236,9 @@ static const struct drm_crtc_funcs vmw_legacy_crtc_funcs = {
.atomic_duplicate_state = vmw_du_crtc_duplicate_state,
.atomic_destroy_state = vmw_du_crtc_destroy_state,
.set_config = drm_atomic_helper_set_config,
+   .get_vblank_counter = vmw_get_vblank_counter,
+   .enable_vblank = vmw_enable_vblank,
+   .disable_vblank = vmw_disable_vblank,
 };
 
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index e5a283263211..32a22e4eddb1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -319,6 +319,9 @@ static const struct drm_crtc_funcs 
vmw_screen_object_crtc_funcs = {
.atomic_destroy_state = vmw_du_crtc_destroy_state,
.set_config = drm_atomic_helper_set_config,
.page_flip = drm_atomic_helper_page_flip,
+   .get_vblank_counter = vmw_get_vblank_counter,
+   .enable_vblank = vmw_enable_vblank,
+   .disable_vblank = vmw_disable_vblank,
 };
 
 /*
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
index 41a96fb49835..570687a1a327 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
@@ -916,6 +916,9 @@ static const struct drm_crtc_funcs vmw_stdu_crtc_funcs = {
.atomic_destroy_state = vmw_du_crtc_destroy_state,
.set_config = drm_atomic_helper_set_config,
.page_flip = drm_atomic_helper_page_flip,
+   

[PATCH v4 19/22] drm/vkms: Convert to CRTC VBLANK callbacks

2020-01-23 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert vkms over.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Rodrigo Siqueira 
Tested-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/vkms/vkms_crtc.c | 9 ++---
 drivers/gpu/drm/vkms/vkms_drv.c  | 1 -
 drivers/gpu/drm/vkms/vkms_drv.h  | 4 
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index 74f703b8d22a..ac85e17428f8 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -76,10 +76,12 @@ static void vkms_disable_vblank(struct drm_crtc *crtc)
hrtimer_cancel(>vblank_hrtimer);
 }
 
-bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-  int *max_error, ktime_t *vblank_time,
-  bool in_vblank_irq)
+static bool vkms_get_vblank_timestamp(struct drm_crtc *crtc,
+ int *max_error, ktime_t *vblank_time,
+ bool in_vblank_irq)
 {
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev);
struct vkms_output *output = >output;
struct drm_vblank_crtc *vblank = >vblank[pipe];
@@ -154,6 +156,7 @@ static const struct drm_crtc_funcs vkms_crtc_funcs = {
.atomic_destroy_state   = vkms_atomic_crtc_destroy_state,
.enable_vblank  = vkms_enable_vblank,
.disable_vblank = vkms_disable_vblank,
+   .get_vblank_timestamp   = vkms_get_vblank_timestamp,
.get_crc_sources= vkms_get_crc_sources,
.set_crc_source = vkms_set_crc_source,
.verify_crc_source  = vkms_verify_crc_source,
diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
index 25bd7519295f..860de052e820 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.c
+++ b/drivers/gpu/drm/vkms/vkms_drv.c
@@ -103,7 +103,6 @@ static struct drm_driver vkms_driver = {
.dumb_create= vkms_dumb_create,
.gem_vm_ops = _gem_vm_ops,
.gem_free_object_unlocked = vkms_gem_free_object,
-   .get_vblank_timestamp   = vkms_get_vblank_timestamp,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import_sg_table = vkms_prime_import_sg_table,
 
diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
index 7d52e24564db..eda04ffba7b1 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.h
+++ b/drivers/gpu/drm/vkms/vkms_drv.h
@@ -111,10 +111,6 @@ struct vkms_gem_object {
 int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
   struct drm_plane *primary, struct drm_plane *cursor);
 
-bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-  int *max_error, ktime_t *vblank_time,
-  bool in_vblank_irq);
-
 int vkms_output_init(struct vkms_device *vkmsdev, int index);
 
 struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev,
-- 
2.24.1

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


[PATCH v4 22/22] drm: Remove legacy version of get_scanout_position()

2020-01-23 Thread Thomas Zimmermann
The legacy version of get_scanout_position() was only useful while
drivers still used drm_driver.get_scanout_position(). With no such
drivers left, the related typedef and code can be removed

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_vblank.c| 27 +++
 drivers/gpu/drm/i915/i915_irq.c |  2 +-
 include/drm/drm_vblank.h| 12 +---
 3 files changed, 9 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 90d62430a6ae..ab0a0fca589a 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -576,9 +576,6 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * @get_scanout_position:
  * Callback function to retrieve the scanout position. See
  * @struct drm_crtc_helper_funcs.get_scanout_position.
- * @get_scanout_position_legacy:
- * Callback function to retrieve the scanout position. See
- * @struct drm_driver.get_scanout_position.
  *
  * Implements calculation of exact vblank timestamps from given 
drm_display_mode
  * timings and current video scanout position of a CRTC.
@@ -601,8 +598,7 @@ bool
 drm_crtc_vblank_helper_get_vblank_timestamp_internal(
struct drm_crtc *crtc, int *max_error, ktime_t *vblank_time,
bool in_vblank_irq,
-   drm_vblank_get_scanout_position_func get_scanout_position,
-   drm_vblank_get_scanout_position_legacy_func get_scanout_position_legacy)
+   drm_vblank_get_scanout_position_func get_scanout_position)
 {
struct drm_device *dev = crtc->dev;
unsigned int pipe = crtc->index;
@@ -620,7 +616,7 @@ drm_crtc_vblank_helper_get_vblank_timestamp_internal(
}
 
/* Scanout position query not supported? Should not happen. */
-   if (!get_scanout_position && !get_scanout_position_legacy) {
+   if (!get_scanout_position) {
DRM_ERROR("Called from CRTC w/o get_scanout_position()!?\n");
return false;
}
@@ -651,19 +647,10 @@ drm_crtc_vblank_helper_get_vblank_timestamp_internal(
 * Get vertical and horizontal scanout position vpos, hpos,
 * and bounding timestamps stime, etime, pre/post query.
 */
-   if (get_scanout_position) {
-   vbl_status = get_scanout_position(crtc,
- in_vblank_irq,
- , ,
- , ,
- mode);
-   } else {
-   vbl_status = get_scanout_position_legacy(dev, pipe,
-in_vblank_irq,
-, ,
-, ,
-mode);
-   }
+   vbl_status = get_scanout_position(crtc, in_vblank_irq,
+ , ,
+ , ,
+ mode);
 
/* Return as no-op if scanout query unsupported or failed. */
if (!vbl_status) {
@@ -755,7 +742,7 @@ bool drm_crtc_vblank_helper_get_vblank_timestamp(struct 
drm_crtc *crtc,
 {
return drm_crtc_vblank_helper_get_vblank_timestamp_internal(
crtc, max_error, vblank_time, in_vblank_irq,
-   crtc->helper_private->get_scanout_position, NULL);
+   crtc->helper_private->get_scanout_position);
 }
 EXPORT_SYMBOL(drm_crtc_vblank_helper_get_vblank_timestamp);
 
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 29bf847999f5..3245f7c5c84f 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -886,7 +886,7 @@ bool intel_crtc_get_vblank_timestamp(struct drm_crtc *crtc, 
int *max_error,
 {
return drm_crtc_vblank_helper_get_vblank_timestamp_internal(
crtc, max_error, vblank_time, in_vblank_irq,
-   i915_get_crtc_scanoutpos, NULL);
+   i915_get_crtc_scanoutpos);
 }
 
 int intel_get_crtc_scanline(struct intel_crtc *crtc)
diff --git a/include/drm/drm_vblank.h b/include/drm/drm_vblank.h
index 87fcf4034d1f..5ef94137fe75 100644
--- a/include/drm/drm_vblank.h
+++ b/include/drm/drm_vblank.h
@@ -246,22 +246,12 @@ typedef bool 
(*drm_vblank_get_scanout_position_func)(struct drm_crtc *crtc,
 ktime_t *etime,
 const struct 
drm_display_mode *mode);
 
-typedef bool (*drm_vblank_get_scanout_position_legacy_func)(struct drm_device 
*dev,
-   unsigned int pipe,
- 

[PATCH v4 14/22] drm/stm: Convert to struct drm_crtc_helper_funcs.get_scanout_position()

2020-01-23 Thread Thomas Zimmermann
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position(). Convert stm
over.

Signed-off-by: Thomas Zimmermann 
Tested-by: Yannick Fertré 
---
 drivers/gpu/drm/stm/drv.c  |  1 -
 drivers/gpu/drm/stm/ltdc.c | 65 --
 drivers/gpu/drm/stm/ltdc.h |  5 ---
 3 files changed, 34 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c
index 5a9f9aca8bc2..486985604109 100644
--- a/drivers/gpu/drm/stm/drv.c
+++ b/drivers/gpu/drm/stm/drv.c
@@ -72,7 +72,6 @@ static struct drm_driver drv_driver = {
.gem_prime_vmap = drm_gem_cma_prime_vmap,
.gem_prime_vunmap = drm_gem_cma_prime_vunmap,
.gem_prime_mmap = drm_gem_cma_prime_mmap,
-   .get_scanout_position = ltdc_crtc_scanoutpos,
.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 };
 
diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index c2815e8ae1da..8b6d1a2252e3 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -636,38 +636,13 @@ static void ltdc_crtc_atomic_flush(struct drm_crtc *crtc,
}
 }
 
-static const struct drm_crtc_helper_funcs ltdc_crtc_helper_funcs = {
-   .mode_valid = ltdc_crtc_mode_valid,
-   .mode_fixup = ltdc_crtc_mode_fixup,
-   .mode_set_nofb = ltdc_crtc_mode_set_nofb,
-   .atomic_flush = ltdc_crtc_atomic_flush,
-   .atomic_enable = ltdc_crtc_atomic_enable,
-   .atomic_disable = ltdc_crtc_atomic_disable,
-};
-
-static int ltdc_crtc_enable_vblank(struct drm_crtc *crtc)
-{
-   struct ltdc_device *ldev = crtc_to_ltdc(crtc);
-
-   DRM_DEBUG_DRIVER("\n");
-   reg_set(ldev->regs, LTDC_IER, IER_LIE);
-
-   return 0;
-}
-
-static void ltdc_crtc_disable_vblank(struct drm_crtc *crtc)
-{
-   struct ltdc_device *ldev = crtc_to_ltdc(crtc);
-
-   DRM_DEBUG_DRIVER("\n");
-   reg_clear(ldev->regs, LTDC_IER, IER_LIE);
-}
-
-bool ltdc_crtc_scanoutpos(struct drm_device *ddev, unsigned int pipe,
- bool in_vblank_irq, int *vpos, int *hpos,
- ktime_t *stime, ktime_t *etime,
- const struct drm_display_mode *mode)
+static bool ltdc_crtc_get_scanout_position(struct drm_crtc *crtc,
+  bool in_vblank_irq,
+  int *vpos, int *hpos,
+  ktime_t *stime, ktime_t *etime,
+  const struct drm_display_mode *mode)
 {
+   struct drm_device *ddev = crtc->dev;
struct ltdc_device *ldev = ddev->dev_private;
int line, vactive_start, vactive_end, vtotal;
 
@@ -710,6 +685,34 @@ bool ltdc_crtc_scanoutpos(struct drm_device *ddev, 
unsigned int pipe,
return true;
 }
 
+static const struct drm_crtc_helper_funcs ltdc_crtc_helper_funcs = {
+   .mode_valid = ltdc_crtc_mode_valid,
+   .mode_fixup = ltdc_crtc_mode_fixup,
+   .mode_set_nofb = ltdc_crtc_mode_set_nofb,
+   .atomic_flush = ltdc_crtc_atomic_flush,
+   .atomic_enable = ltdc_crtc_atomic_enable,
+   .atomic_disable = ltdc_crtc_atomic_disable,
+   .get_scanout_position = ltdc_crtc_get_scanout_position,
+};
+
+static int ltdc_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct ltdc_device *ldev = crtc_to_ltdc(crtc);
+
+   DRM_DEBUG_DRIVER("\n");
+   reg_set(ldev->regs, LTDC_IER, IER_LIE);
+
+   return 0;
+}
+
+static void ltdc_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct ltdc_device *ldev = crtc_to_ltdc(crtc);
+
+   DRM_DEBUG_DRIVER("\n");
+   reg_clear(ldev->regs, LTDC_IER, IER_LIE);
+}
+
 static const struct drm_crtc_funcs ltdc_crtc_funcs = {
.destroy = drm_crtc_cleanup,
.set_config = drm_atomic_helper_set_config,
diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
index a1ad0ae3b006..c5467d74e707 100644
--- a/drivers/gpu/drm/stm/ltdc.h
+++ b/drivers/gpu/drm/stm/ltdc.h
@@ -39,11 +39,6 @@ struct ltdc_device {
struct drm_atomic_state *suspend_state;
 };
 
-bool ltdc_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
- bool in_vblank_irq, int *vpos, int *hpos,
- ktime_t *stime, ktime_t *etime,
- const struct drm_display_mode *mode);
-
 int ltdc_load(struct drm_device *ddev);
 void ltdc_unload(struct drm_device *ddev);
 void ltdc_suspend(struct drm_device *ddev);
-- 
2.24.1

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


[PATCH v4 15/22] drm/stm: Convert to CRTC VBLANK callbacks

2020-01-23 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert stm over.

Signed-off-by: Thomas Zimmermann 
Tested-by: Yannick Fertré 
---
 drivers/gpu/drm/stm/drv.c  | 1 -
 drivers/gpu/drm/stm/ltdc.c | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c
index 486985604109..ea9fcbdc68b3 100644
--- a/drivers/gpu/drm/stm/drv.c
+++ b/drivers/gpu/drm/stm/drv.c
@@ -72,7 +72,6 @@ static struct drm_driver drv_driver = {
.gem_prime_vmap = drm_gem_cma_prime_vmap,
.gem_prime_vunmap = drm_gem_cma_prime_vunmap,
.gem_prime_mmap = drm_gem_cma_prime_mmap,
-   .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 };
 
 static int drv_load(struct drm_device *ddev)
diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 8b6d1a2252e3..ee2a8cac59cb 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -722,6 +722,7 @@ static const struct drm_crtc_funcs ltdc_crtc_funcs = {
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
.enable_vblank = ltdc_crtc_enable_vblank,
.disable_vblank = ltdc_crtc_disable_vblank,
+   .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
.gamma_set = drm_atomic_helper_legacy_gamma_set,
 };
 
-- 
2.24.1

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


[PATCH v4 13/22] drm/msm: Convert to CRTC VBLANK callbacks

2020-01-23 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert msm over.

Signed-off-by: Thomas Zimmermann 
Tested-by: Yannick Fertré 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  |  2 ++
 drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c |  2 ++
 drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 15 ++
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c  | 34 ---
 drivers/gpu/drm/msm/msm_drv.c | 10 ---
 drivers/gpu/drm/msm/msm_drv.h |  3 ++
 6 files changed, 28 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index f197dce54576..b177d5052c5e 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -1281,6 +1281,8 @@ static const struct drm_crtc_funcs dpu_crtc_funcs = {
.atomic_destroy_state = dpu_crtc_destroy_state,
.late_register = dpu_crtc_late_register,
.early_unregister = dpu_crtc_early_unregister,
+   .enable_vblank  = msm_crtc_enable_vblank,
+   .disable_vblank = msm_crtc_disable_vblank,
 };
 
 static const struct drm_crtc_helper_funcs dpu_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c 
b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
index f34dca5d4532..c9239b07fe4f 100644
--- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
@@ -481,6 +481,8 @@ static const struct drm_crtc_funcs mdp4_crtc_funcs = {
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank  = msm_crtc_enable_vblank,
+   .disable_vblank = msm_crtc_disable_vblank,
 };
 
 static const struct drm_crtc_helper_funcs mdp4_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
index 4decf19847a8..b3d0a0fe76b9 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
@@ -471,6 +471,17 @@ static bool mdp5_crtc_get_scanout_position(struct drm_crtc 
*crtc,
return true;
 }
 
+static u32 mdp5_crtc_get_vblank_counter(struct drm_crtc *crtc)
+{
+   struct drm_encoder *encoder;
+
+   encoder = get_encoder_from_crtc(crtc);
+   if (!encoder)
+   return 0;
+
+   return mdp5_encoder_get_framecount(encoder);
+}
+
 static void mdp5_crtc_atomic_disable(struct drm_crtc *crtc,
 struct drm_crtc_state *old_state)
 {
@@ -1120,6 +1131,10 @@ static const struct drm_crtc_funcs mdp5_crtc_funcs = {
.cursor_set = mdp5_crtc_cursor_set,
.cursor_move = mdp5_crtc_cursor_move,
.atomic_print_state = mdp5_crtc_atomic_print_state,
+   .get_vblank_counter = mdp5_crtc_get_vblank_counter,
+   .enable_vblank  = msm_crtc_enable_vblank,
+   .disable_vblank = msm_crtc_disable_vblank,
+   .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
 };
 
 static const struct drm_crtc_helper_funcs mdp5_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
index 8b72ac44ce55..6650f478b226 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
@@ -583,38 +583,6 @@ static int get_clk(struct platform_device *pdev, struct 
clk **clkp,
return 0;
 }
 
-static struct drm_encoder *get_encoder_from_crtc(struct drm_crtc *crtc)
-{
-   struct drm_device *dev = crtc->dev;
-   struct drm_encoder *encoder;
-
-   drm_for_each_encoder(encoder, dev)
-   if (encoder->crtc == crtc)
-   return encoder;
-
-   return NULL;
-}
-
-static u32 mdp5_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
-{
-   struct msm_drm_private *priv = dev->dev_private;
-   struct drm_crtc *crtc;
-   struct drm_encoder *encoder;
-
-   if (pipe >= priv->num_crtcs)
-   return 0;
-
-   crtc = priv->crtcs[pipe];
-   if (!crtc)
-   return 0;
-
-   encoder = get_encoder_from_crtc(crtc);
-   if (!encoder)
-   return 0;
-
-   return mdp5_encoder_get_framecount(encoder);
-}
-
 struct msm_kms *mdp5_kms_init(struct drm_device *dev)
 {
struct msm_drm_private *priv = dev->dev_private;
@@ -702,8 +670,6 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev)
dev->mode_config.max_width = 0x;
dev->mode_config.max_height = 0x;
 
-   dev->driver->get_vblank_timestamp = 
drm_calc_vbltimestamp_from_scanoutpos;
-   dev->driver->get_vblank_counter = mdp5_get_vblank_counter;
dev->max_vblank_count = 0; /* max_vblank_count is set on each CRTC */
dev->vblank_disable_immediate = true;
 
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c

[PATCH v4 18/22] drm/vc4: Convert to CRTC VBLANK callbacks

2020-01-23 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert vc4 over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 1 +
 drivers/gpu/drm/vc4/vc4_drv.c  | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index f1e7597ea17e..1208258ad3b2 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -1031,6 +1031,7 @@ static const struct drm_crtc_funcs vc4_crtc_funcs = {
.gamma_set = drm_atomic_helper_legacy_gamma_set,
.enable_vblank = vc4_enable_vblank,
.disable_vblank = vc4_disable_vblank,
+   .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
 };
 
 static const struct drm_crtc_helper_funcs vc4_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index e6982a7b0c5e..76f93b662766 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -190,8 +190,6 @@ static struct drm_driver vc4_drm_driver = {
.irq_postinstall = vc4_irq_postinstall,
.irq_uninstall = vc4_irq_uninstall,
 
-   .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-
 #if defined(CONFIG_DEBUG_FS)
.debugfs_init = vc4_debugfs_init,
 #endif
-- 
2.24.1

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


[PATCH v4 12/22] drm/msm: Convert to struct drm_crtc_helper_funcs.get_scanout_position()

2020-01-23 Thread Thomas Zimmermann
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position(). Convert
mem over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 67 +++
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c  | 61 -
 2 files changed, 67 insertions(+), 61 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
index 05cc04f729d6..4decf19847a8 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
@@ -405,6 +405,72 @@ static void mdp5_crtc_mode_set_nofb(struct drm_crtc *crtc)
spin_unlock_irqrestore(_crtc->lm_lock, flags);
 }
 
+static struct drm_encoder *get_encoder_from_crtc(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_encoder *encoder;
+
+   drm_for_each_encoder(encoder, dev)
+   if (encoder->crtc == crtc)
+   return encoder;
+
+   return NULL;
+}
+
+static bool mdp5_crtc_get_scanout_position(struct drm_crtc *crtc,
+  bool in_vblank_irq,
+  int *vpos, int *hpos,
+  ktime_t *stime, ktime_t *etime,
+  const struct drm_display_mode *mode)
+{
+   unsigned int pipe = crtc->index;
+   struct drm_encoder *encoder;
+   int line, vsw, vbp, vactive_start, vactive_end, vfp_end;
+
+
+   encoder = get_encoder_from_crtc(crtc);
+   if (!encoder) {
+   DRM_ERROR("no encoder found for crtc %d\n", pipe);
+   return false;
+   }
+
+   vsw = mode->crtc_vsync_end - mode->crtc_vsync_start;
+   vbp = mode->crtc_vtotal - mode->crtc_vsync_end;
+
+   /*
+* the line counter is 1 at the start of the VSYNC pulse and VTOTAL at
+* the end of VFP. Translate the porch values relative to the line
+* counter positions.
+*/
+
+   vactive_start = vsw + vbp + 1;
+
+   vactive_end = vactive_start + mode->crtc_vdisplay;
+
+   /* last scan line before VSYNC */
+   vfp_end = mode->crtc_vtotal;
+
+   if (stime)
+   *stime = ktime_get();
+
+   line = mdp5_encoder_get_linecount(encoder);
+
+   if (line < vactive_start)
+   line -= vactive_start;
+   else if (line > vactive_end)
+   line = line - vfp_end - vactive_start;
+   else
+   line -= vactive_start;
+
+   *vpos = line;
+   *hpos = 0;
+
+   if (etime)
+   *etime = ktime_get();
+
+   return true;
+}
+
 static void mdp5_crtc_atomic_disable(struct drm_crtc *crtc,
 struct drm_crtc_state *old_state)
 {
@@ -1063,6 +1129,7 @@ static const struct drm_crtc_helper_funcs 
mdp5_crtc_helper_funcs = {
.atomic_flush = mdp5_crtc_atomic_flush,
.atomic_enable = mdp5_crtc_atomic_enable,
.atomic_disable = mdp5_crtc_atomic_disable,
+   .get_scanout_position = mdp5_crtc_get_scanout_position,
 };
 
 static void mdp5_crtc_vblank_irq(struct mdp_irq *irq, uint32_t irqstatus)
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
index e43ecd4be10a..8b72ac44ce55 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
@@ -595,66 +595,6 @@ static struct drm_encoder *get_encoder_from_crtc(struct 
drm_crtc *crtc)
return NULL;
 }
 
-static bool mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
-   bool in_vblank_irq, int *vpos, int *hpos,
-   ktime_t *stime, ktime_t *etime,
-   const struct drm_display_mode *mode)
-{
-   struct msm_drm_private *priv = dev->dev_private;
-   struct drm_crtc *crtc;
-   struct drm_encoder *encoder;
-   int line, vsw, vbp, vactive_start, vactive_end, vfp_end;
-
-   crtc = priv->crtcs[pipe];
-   if (!crtc) {
-   DRM_ERROR("Invalid crtc %d\n", pipe);
-   return false;
-   }
-
-   encoder = get_encoder_from_crtc(crtc);
-   if (!encoder) {
-   DRM_ERROR("no encoder found for crtc %d\n", pipe);
-   return false;
-   }
-
-   vsw = mode->crtc_vsync_end - mode->crtc_vsync_start;
-   vbp = mode->crtc_vtotal - mode->crtc_vsync_end;
-
-   /*
-* the line counter is 1 at the start of the VSYNC pulse and VTOTAL at
-* the end of VFP. Translate the porch values relative to the line
-* counter positions.
-*/
-
-   vactive_start = vsw + vbp + 1;
-
-   vactive_end = vactive_start + mode->crtc_vdisplay;
-
-   /* last scan line before VSYNC */
-   vfp_end = mode->crtc_vtotal;
-
-   if (stime)
-   *stime = ktime_get();
-
-   line = 

[PATCH v4 06/22] drm/gma500: Convert to CRTC VBLANK callbacks

2020-01-23 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert gma500 over.

Signed-off-by: Thomas Zimmermann 
Acked-by: Patrik Jakobsson 
---
 drivers/gpu/drm/gma500/cdv_intel_display.c |  3 +++
 drivers/gpu/drm/gma500/psb_drv.c   |  4 
 drivers/gpu/drm/gma500/psb_drv.h   |  6 +++---
 drivers/gpu/drm/gma500/psb_intel_display.c |  3 +++
 drivers/gpu/drm/gma500/psb_irq.c   | 12 +---
 drivers/gpu/drm/gma500/psb_irq.h   |  7 ---
 6 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/gma500/cdv_intel_display.c 
b/drivers/gpu/drm/gma500/cdv_intel_display.c
index 1ed854f498b7..686385a66167 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_display.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_display.c
@@ -977,6 +977,9 @@ const struct drm_crtc_funcs cdv_intel_crtc_funcs = {
.set_config = gma_crtc_set_config,
.destroy = gma_crtc_destroy,
.page_flip = gma_crtc_page_flip,
+   .enable_vblank = psb_enable_vblank,
+   .disable_vblank = psb_disable_vblank,
+   .get_vblank_counter = psb_get_vblank_counter,
 };
 
 const struct gma_clock_funcs cdv_clock_funcs = {
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 52591416f8fe..36cb292fdebe 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -363,7 +363,6 @@ static int psb_driver_load(struct drm_device *dev, unsigned 
long flags)
drm_irq_install(dev, dev->pdev->irq);
 
dev->max_vblank_count = 0xff; /* only 24 bits of frame count */
-   dev->driver->get_vblank_counter = psb_get_vblank_counter;
 
psb_modeset_init(dev);
psb_fbdev_init(dev);
@@ -507,9 +506,6 @@ static struct drm_driver driver = {
.irq_postinstall = psb_irq_postinstall,
.irq_uninstall = psb_irq_uninstall,
.irq_handler = psb_irq_handler,
-   .enable_vblank = psb_enable_vblank,
-   .disable_vblank = psb_disable_vblank,
-   .get_vblank_counter = psb_get_vblank_counter,
 
.gem_free_object = psb_gem_free_object,
.gem_vm_ops = _gem_vm_ops,
diff --git a/drivers/gpu/drm/gma500/psb_drv.h b/drivers/gpu/drm/gma500/psb_drv.h
index 3d4ef3071d45..956926341316 100644
--- a/drivers/gpu/drm/gma500/psb_drv.h
+++ b/drivers/gpu/drm/gma500/psb_drv.h
@@ -681,15 +681,15 @@ extern void psb_irq_turn_off_dpst(struct drm_device *dev);
 extern void psb_irq_uninstall_islands(struct drm_device *dev, int hw_islands);
 extern int psb_vblank_wait2(struct drm_device *dev, unsigned int *sequence);
 extern int psb_vblank_wait(struct drm_device *dev, unsigned int *sequence);
-extern int psb_enable_vblank(struct drm_device *dev, unsigned int pipe);
-extern void psb_disable_vblank(struct drm_device *dev, unsigned int pipe);
+extern int psb_enable_vblank(struct drm_crtc *crtc);
+extern void psb_disable_vblank(struct drm_crtc *crtc);
 void
 psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
 
 void
 psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
 
-extern u32 psb_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
+extern u32 psb_get_vblank_counter(struct drm_crtc *crtc);
 
 /* framebuffer.c */
 extern int psbfb_probed(struct drm_device *dev);
diff --git a/drivers/gpu/drm/gma500/psb_intel_display.c 
b/drivers/gpu/drm/gma500/psb_intel_display.c
index fed3b563e62e..531c5485be17 100644
--- a/drivers/gpu/drm/gma500/psb_intel_display.c
+++ b/drivers/gpu/drm/gma500/psb_intel_display.c
@@ -433,6 +433,9 @@ const struct drm_crtc_funcs psb_intel_crtc_funcs = {
.set_config = gma_crtc_set_config,
.destroy = gma_crtc_destroy,
.page_flip = gma_crtc_page_flip,
+   .enable_vblank = psb_enable_vblank,
+   .disable_vblank = psb_disable_vblank,
+   .get_vblank_counter = psb_get_vblank_counter,
 };
 
 const struct gma_clock_funcs psb_clock_funcs = {
diff --git a/drivers/gpu/drm/gma500/psb_irq.c b/drivers/gpu/drm/gma500/psb_irq.c
index 91f90016dba9..15eb3770d817 100644
--- a/drivers/gpu/drm/gma500/psb_irq.c
+++ b/drivers/gpu/drm/gma500/psb_irq.c
@@ -506,8 +506,10 @@ int psb_irq_disable_dpst(struct drm_device *dev)
 /*
  * It is used to enable VBLANK interrupt
  */
-int psb_enable_vblank(struct drm_device *dev, unsigned int pipe)
+int psb_enable_vblank(struct drm_crtc *crtc)
 {
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
struct drm_psb_private *dev_priv = dev->dev_private;
unsigned long irqflags;
uint32_t reg_val = 0;
@@ -545,8 +547,10 @@ int psb_enable_vblank(struct drm_device *dev, unsigned int 
pipe)
 /*
  * It is used to disable VBLANK interrupt
  */
-void psb_disable_vblank(struct drm_device *dev, unsigned int pipe)
+void psb_disable_vblank(struct drm_crtc *crtc)
 {
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
struct drm_psb_private *dev_priv = 

[PATCH v4 00/22] drm: Clean up VBLANK callbacks in struct drm_driver

2020-01-23 Thread Thomas Zimmermann
VBLANK handlers in struct drm_driver are deprecated. Only legacy,
non-KMS drivers are supposed to used them. DRM drivers with kernel
modesetting are supposed to use VBLANK callbacks of the CRTC
infrastructure.

This patchset converts all DRM drivers to CRTC VBLANK callbacks and
cleans up struct drm_driver. The remaining VBLANK callbacks in struct
drm_driver are only used by legacy drivers.

Patch 1 removes an additional setup step of vblank_disable_immediate
in struct drm_device. This simplifies the integration of CRTC VBLANK
callbacks in patch 3. If necessary, a future patch could move
vblank_disable_immedate to struct drm_crtc, so that high-precision
VBLANKs could be enabled on a per-CRTC basis.

Patches 2 and 3 prepare the DRM infrastructure. These patches add
get_scanout_position() to struct drm_crtc_helper_funcs,
get_vblank_timestamp() to struct drm_crtc_funcs, and add helpers for
the new interfaces.

Patches 4 to 20 convert drivers over.

In patch 21, all VBLANK callbacks are removed from struct drm_driver,
except for get_vblank_counter(), enable_vblank(), and disable_vblank().
These interfaces are moved to the legacy section at the end of the
structure. Old helper code is now unused and being removed as well.
Finally, patch 22 removes an older version of get_scanout_position()
from the VBLANK interface.

To cover all affected drivers, I build the patchset in x86, x86-64,
arm and aarch64. I smoke-tested amdgpu, gma500, i915, radeon and vc4 on
respective hardware.

v4:
* fixed warnings and improved code readability (Ville, Jani)
v3:
* refactor drm_calc_vbltimestamp_from_scanout_pos to share code
  with new helper (Villa, Jani)
* do more checks for crtc != NULL to cover non-KMS drivers (Ville)
* add function typedefs for readability (Ville)
v2:
* reorder patches so the i915 can be converted without duplicating
  helper code.
* merged cleanup patches
* changed VBLANK function signatures in amdgpu (Alex)

Thomas Zimmermann (22):
  drm: Remove internal setup of struct
drm_device.vblank_disable_immediate
  drm: Add get_scanout_position() to struct drm_crtc_helper_funcs
  drm: Add get_vblank_timestamp() to struct drm_crtc_funcs
  drm/amdgpu: Convert to struct
drm_crtc_helper_funcs.get_scanout_position()
  drm/amdgpu: Convert to CRTC VBLANK callbacks
  drm/gma500: Convert to CRTC VBLANK callbacks
  drm/i915: Convert to CRTC VBLANK callbacks
  drm/nouveau: Convert to struct
drm_crtc_helper_funcs.get_scanout_position()
  drm/nouveau: Convert to CRTC VBLANK callbacks
  drm/radeon: Convert to struct
drm_crtc_helper_funcs.get_scanout_position()
  drm/radeon: Convert to CRTC VBLANK callbacks
  drm/msm: Convert to struct
drm_crtc_helper_funcs.get_scanout_position()
  drm/msm: Convert to CRTC VBLANK callbacks
  drm/stm: Convert to struct
drm_crtc_helper_funcs.get_scanout_position()
  drm/stm: Convert to CRTC VBLANK callbacks
  drm/sti: Convert to CRTC VBLANK callbacks
  drm/vc4: Convert to struct
drm_crtc_helper_funcs.get_scanout_position()
  drm/vc4: Convert to CRTC VBLANK callbacks
  drm/vkms: Convert to CRTC VBLANK callbacks
  drm/vmwgfx: Convert to CRTC VBLANK callbacks
  drm: Clean-up VBLANK-related callbacks in struct drm_driver
  drm: Remove legacy version of get_scanout_position()

 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |   6 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  16 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |  15 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   |  21 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h  |   5 +
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c|   5 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c|   5 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c |   5 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c |   5 +
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c  |   5 +
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  13 +-
 drivers/gpu/drm/drm_vblank.c  | 146 +---
 drivers/gpu/drm/gma500/cdv_intel_display.c|   3 +
 drivers/gpu/drm/gma500/psb_drv.c  |   4 -
 drivers/gpu/drm/gma500/psb_drv.h  |   6 +-
 drivers/gpu/drm/gma500/psb_intel_display.c|   3 +
 drivers/gpu/drm/gma500/psb_irq.c  |  12 +-
 drivers/gpu/drm/gma500/psb_irq.h  |   7 +-
 drivers/gpu/drm/i915/display/intel_display.c  |   7 +
 drivers/gpu/drm/i915/i915_drv.c   |   3 -
 drivers/gpu/drm/i915/i915_irq.c   |  20 ++-
 drivers/gpu/drm/i915/i915_irq.h   |   6 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  |   2 +
 drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c |   2 +
 drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c |  82 +
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c  |  95 ---
 drivers/gpu/drm/msm/msm_drv.c |  10 +-
 drivers/gpu/drm/msm/msm_drv.h |   3 +
 drivers/gpu/drm/nouveau/dispnv04/crtc.c   |   4 +
 

[PATCH v4 11/22] drm/radeon: Convert to CRTC VBLANK callbacks

2020-01-23 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert radeon over.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon_display.c | 12 --
 drivers/gpu/drm/radeon/radeon_drv.c |  7 --
 drivers/gpu/drm/radeon/radeon_kms.c | 29 ++---
 3 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_display.c 
b/drivers/gpu/drm/radeon/radeon_display.c
index 2f641f3b39e7..fa722b7c8df3 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -45,6 +45,10 @@
 #include "atom.h"
 #include "radeon.h"
 
+u32 radeon_get_vblank_counter_kms(struct drm_crtc *crtc);
+int radeon_enable_vblank_kms(struct drm_crtc *crtc);
+void radeon_disable_vblank_kms(struct drm_crtc *crtc);
+
 static void avivo_crtc_load_lut(struct drm_crtc *crtc)
 {
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
@@ -458,7 +462,7 @@ static void radeon_flip_work_func(struct work_struct 
*__work)
(DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK) &&
(!ASIC_IS_AVIVO(rdev) ||
((int) (work->target_vblank -
-   dev->driver->get_vblank_counter(dev, work->crtc_id)) > 0)))
+   crtc->funcs->get_vblank_counter(crtc)) > 0)))
usleep_range(1000, 2000);
 
/* We borrow the event spin lock for protecting flip_status */
@@ -574,7 +578,7 @@ static int radeon_crtc_page_flip_target(struct drm_crtc 
*crtc,
}
work->base = base;
work->target_vblank = target - (uint32_t)drm_crtc_vblank_count(crtc) +
-   dev->driver->get_vblank_counter(dev, work->crtc_id);
+   crtc->funcs->get_vblank_counter(crtc);
 
/* We borrow the event spin lock for protecting flip_work */
spin_lock_irqsave(>dev->event_lock, flags);
@@ -666,6 +670,10 @@ static const struct drm_crtc_funcs radeon_crtc_funcs = {
.set_config = radeon_crtc_set_config,
.destroy = radeon_crtc_destroy,
.page_flip_target = radeon_crtc_page_flip_target,
+   .get_vblank_counter = radeon_get_vblank_counter_kms,
+   .enable_vblank = radeon_enable_vblank_kms,
+   .disable_vblank = radeon_disable_vblank_kms,
+   .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
 };
 
 static void radeon_crtc_init(struct drm_device *dev, int index)
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index 1f597f166bff..49ce2e7d5f9e 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -119,9 +119,6 @@ void radeon_driver_postclose_kms(struct drm_device *dev,
 int radeon_suspend_kms(struct drm_device *dev, bool suspend,
   bool fbcon, bool freeze);
 int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
-u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
-int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
@@ -571,10 +568,6 @@ static struct drm_driver kms_driver = {
.postclose = radeon_driver_postclose_kms,
.lastclose = radeon_driver_lastclose_kms,
.unload = radeon_driver_unload_kms,
-   .get_vblank_counter = radeon_get_vblank_counter_kms,
-   .enable_vblank = radeon_enable_vblank_kms,
-   .disable_vblank = radeon_disable_vblank_kms,
-   .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
.irq_preinstall = radeon_driver_irq_preinstall_kms,
.irq_postinstall = radeon_driver_irq_postinstall_kms,
.irq_uninstall = radeon_driver_irq_uninstall_kms,
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c 
b/drivers/gpu/drm/radeon/radeon_kms.c
index d24f23a81656..cab891f86dc0 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -739,14 +739,15 @@ void radeon_driver_postclose_kms(struct drm_device *dev,
 /**
  * radeon_get_vblank_counter_kms - get frame count
  *
- * @dev: drm dev pointer
- * @pipe: crtc to get the frame count from
+ * @crtc: crtc to get the frame count from
  *
  * Gets the frame count on the requested crtc (all asics).
  * Returns frame count on success, -EINVAL on failure.
  */
-u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe)
+u32 radeon_get_vblank_counter_kms(struct drm_crtc *crtc)
 {
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
int vpos, hpos, stat;
u32 count;
struct radeon_device *rdev = dev->dev_private;
@@ -808,25 +809,26 @@ u32 radeon_get_vblank_counter_kms(struct drm_device 

[PATCH v4 04/22] drm/amdgpu: Convert to struct drm_crtc_helper_funcs.get_scanout_position()

2020-01-23 Thread Thomas Zimmermann
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position(). Convert
amdgpu over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   | 12 
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   | 11 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h  |  5 +
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c|  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c|  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c |  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c |  1 +
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c  |  1 +
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  3 ++-
 9 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 4e699071d144..a1e769d4417d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -914,3 +914,15 @@ int amdgpu_display_crtc_idx_to_irq_type(struct 
amdgpu_device *adev, int crtc)
return AMDGPU_CRTC_IRQ_NONE;
}
 }
+
+bool amdgpu_crtc_get_scanout_position(struct drm_crtc *crtc,
+   bool in_vblank_irq, int *vpos,
+   int *hpos, ktime_t *stime, ktime_t *etime,
+   const struct drm_display_mode *mode)
+{
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
+
+   return amdgpu_display_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
+ stime, etime, mode);
+}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index a9c4edca70c9..955b78f1bba4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1377,16 +1377,6 @@ int amdgpu_file_to_fpriv(struct file *filp, struct 
amdgpu_fpriv **fpriv)
return 0;
 }
 
-static bool
-amdgpu_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
-bool in_vblank_irq, int *vpos, int *hpos,
-ktime_t *stime, ktime_t *etime,
-const struct drm_display_mode *mode)
-{
-   return amdgpu_display_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
- stime, etime, mode);
-}
-
 static struct drm_driver kms_driver = {
.driver_features =
DRIVER_USE_AGP | DRIVER_ATOMIC |
@@ -1402,7 +1392,6 @@ static struct drm_driver kms_driver = {
.enable_vblank = amdgpu_enable_vblank_kms,
.disable_vblank = amdgpu_disable_vblank_kms,
.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-   .get_scanout_position = amdgpu_get_crtc_scanout_position,
.irq_handler = amdgpu_irq_handler,
.ioctls = amdgpu_ioctls_kms,
.gem_free_object_unlocked = amdgpu_gem_object_free,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index eb9975f4decb..37ba07e2feb5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -612,6 +612,11 @@ void amdgpu_panel_mode_fixup(struct drm_encoder *encoder,
 struct drm_display_mode *adjusted_mode);
 int amdgpu_display_crtc_idx_to_irq_type(struct amdgpu_device *adev, int crtc);
 
+bool amdgpu_crtc_get_scanout_position(struct drm_crtc *crtc,
+   bool in_vblank_irq, int *vpos,
+   int *hpos, ktime_t *stime, ktime_t *etime,
+   const struct drm_display_mode *mode);
+
 /* fbdev layer */
 int amdgpu_fbdev_init(struct amdgpu_device *adev);
 void amdgpu_fbdev_fini(struct amdgpu_device *adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 40d2ac723dd6..bdc1e0f036d4 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2685,6 +2685,7 @@ static const struct drm_crtc_helper_funcs 
dce_v10_0_crtc_helper_funcs = {
.prepare = dce_v10_0_crtc_prepare,
.commit = dce_v10_0_crtc_commit,
.disable = dce_v10_0_crtc_disable,
+   .get_scanout_position = amdgpu_crtc_get_scanout_position,
 };
 
 static int dce_v10_0_crtc_init(struct amdgpu_device *adev, int index)
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 898ef72d423c..0319da5f7bf9 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -2793,6 +2793,7 @@ static const struct drm_crtc_helper_funcs 
dce_v11_0_crtc_helper_funcs = {
.prepare = dce_v11_0_crtc_prepare,
.commit = dce_v11_0_crtc_commit,
.disable = dce_v11_0_crtc_disable,
+   .get_scanout_position = amdgpu_crtc_get_scanout_position,
 };
 
 static 

[PATCH v4 16/22] drm/sti: Convert to CRTC VBLANK callbacks

2020-01-23 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert sti over.

v2:
* remove unnecessary include of sti_crtc.h from sti_drv.c

Signed-off-by: Thomas Zimmermann 
Acked-by: Benjamin Gaignard 
---
 drivers/gpu/drm/sti/sti_crtc.c | 11 ---
 drivers/gpu/drm/sti/sti_crtc.h |  2 --
 drivers/gpu/drm/sti/sti_drv.c  |  4 
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
index dc64fbfc4e61..49e6cb8f5836 100644
--- a/drivers/gpu/drm/sti/sti_crtc.c
+++ b/drivers/gpu/drm/sti/sti_crtc.c
@@ -279,12 +279,13 @@ int sti_crtc_vblank_cb(struct notifier_block *nb,
return 0;
 }
 
-int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe)
+static int sti_crtc_enable_vblank(struct drm_crtc *crtc)
 {
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
struct sti_private *dev_priv = dev->dev_private;
struct sti_compositor *compo = dev_priv->compo;
struct notifier_block *vtg_vblank_nb = >vtg_vblank_nb[pipe];
-   struct drm_crtc *crtc = >mixer[pipe]->drm_crtc;
struct sti_vtg *vtg = compo->vtg[pipe];
 
DRM_DEBUG_DRIVER("\n");
@@ -297,8 +298,10 @@ int sti_crtc_enable_vblank(struct drm_device *dev, 
unsigned int pipe)
return 0;
 }
 
-void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe)
+static void sti_crtc_disable_vblank(struct drm_crtc *crtc)
 {
+   struct drm_device *drm_dev = crtc->dev;
+   unsigned int pipe = crtc->index;
struct sti_private *priv = drm_dev->dev_private;
struct sti_compositor *compo = priv->compo;
struct notifier_block *vtg_vblank_nb = >vtg_vblank_nb[pipe];
@@ -330,6 +333,8 @@ static const struct drm_crtc_funcs sti_crtc_funcs = {
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
.late_register = sti_crtc_late_register,
+   .enable_vblank = sti_crtc_enable_vblank,
+   .disable_vblank = sti_crtc_disable_vblank,
 };
 
 bool sti_crtc_is_main(struct drm_crtc *crtc)
diff --git a/drivers/gpu/drm/sti/sti_crtc.h b/drivers/gpu/drm/sti/sti_crtc.h
index df489ab14e2b..1132b4586712 100644
--- a/drivers/gpu/drm/sti/sti_crtc.h
+++ b/drivers/gpu/drm/sti/sti_crtc.h
@@ -15,8 +15,6 @@ struct sti_mixer;
 
 int sti_crtc_init(struct drm_device *drm_dev, struct sti_mixer *mixer,
  struct drm_plane *primary, struct drm_plane *cursor);
-int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe);
-void sti_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe);
 int sti_crtc_vblank_cb(struct notifier_block *nb,
   unsigned long event, void *data);
 bool sti_crtc_is_main(struct drm_crtc *drm_crtc);
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index a39fc36f815b..50870d8cbb76 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -21,7 +21,6 @@
 #include 
 #include 
 
-#include "sti_crtc.h"
 #include "sti_drv.h"
 #include "sti_plane.h"
 
@@ -146,9 +145,6 @@ static struct drm_driver sti_driver = {
.dumb_create = drm_gem_cma_dumb_create,
.fops = _driver_fops,
 
-   .enable_vblank = sti_crtc_enable_vblank,
-   .disable_vblank = sti_crtc_disable_vblank,
-
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
-- 
2.24.1

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


[PATCH v4 09/22] drm/nouveau: Convert to CRTC VBLANK callbacks

2020-01-23 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert nouvean over.

v4:
* add argument names in function declaration

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c   |  3 +++
 drivers/gpu/drm/nouveau/dispnv50/head.c   |  4 
 drivers/gpu/drm/nouveau/nouveau_display.c | 14 ++
 drivers/gpu/drm/nouveau/nouveau_display.h |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_drm.c |  4 
 5 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c 
b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 17e9d1c078a0..1f08de4241e0 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -1248,6 +1248,9 @@ static const struct drm_crtc_funcs nv04_crtc_funcs = {
.set_config = drm_crtc_helper_set_config,
.page_flip = nv04_crtc_page_flip,
.destroy = nv_crtc_destroy,
+   .enable_vblank = nouveau_display_vblank_enable,
+   .disable_vblank = nouveau_display_vblank_disable,
+   .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
 };
 
 static const struct drm_crtc_helper_funcs nv04_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c 
b/drivers/gpu/drm/nouveau/dispnv50/head.c
index 41852dd8fdbd..8f6455697ba7 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head.c
@@ -29,6 +29,7 @@
 
 #include 
 #include 
+#include 
 #include "nouveau_connector.h"
 void
 nv50_head_flush_clr(struct nv50_head *head,
@@ -482,6 +483,9 @@ nv50_head_func = {
.page_flip = drm_atomic_helper_page_flip,
.atomic_duplicate_state = nv50_head_atomic_duplicate_state,
.atomic_destroy_state = nv50_head_atomic_destroy_state,
+   .enable_vblank = nouveau_display_vblank_enable,
+   .disable_vblank = nouveau_display_vblank_disable,
+   .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
 };
 
 struct nv50_head *
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
b/drivers/gpu/drm/nouveau/nouveau_display.c
index 86f99dc8fcef..700817dc4fa0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -54,15 +54,10 @@ nouveau_display_vblank_handler(struct nvif_notify *notify)
 }
 
 int
-nouveau_display_vblank_enable(struct drm_device *dev, unsigned int pipe)
+nouveau_display_vblank_enable(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc;
struct nouveau_crtc *nv_crtc;
 
-   crtc = drm_crtc_from_index(dev, pipe);
-   if (!crtc)
-   return -EINVAL;
-
nv_crtc = nouveau_crtc(crtc);
nvif_notify_get(_crtc->vblank);
 
@@ -70,15 +65,10 @@ nouveau_display_vblank_enable(struct drm_device *dev, 
unsigned int pipe)
 }
 
 void
-nouveau_display_vblank_disable(struct drm_device *dev, unsigned int pipe)
+nouveau_display_vblank_disable(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc;
struct nouveau_crtc *nv_crtc;
 
-   crtc = drm_crtc_from_index(dev, pipe);
-   if (!crtc)
-   return;
-
nv_crtc = nouveau_crtc(crtc);
nvif_notify_put(_crtc->vblank);
 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.h 
b/drivers/gpu/drm/nouveau/nouveau_display.h
index 26d34f1a77da..de004018ab5c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.h
+++ b/drivers/gpu/drm/nouveau/nouveau_display.h
@@ -61,8 +61,8 @@ int  nouveau_display_init(struct drm_device *dev, bool 
resume, bool runtime);
 void nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime);
 int  nouveau_display_suspend(struct drm_device *dev, bool runtime);
 void nouveau_display_resume(struct drm_device *dev, bool runtime);
-int  nouveau_display_vblank_enable(struct drm_device *, unsigned int);
-void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
+int  nouveau_display_vblank_enable(struct drm_crtc *crtc);
+void nouveau_display_vblank_disable(struct drm_crtc *crtc);
 bool nouveau_display_scanoutpos(struct drm_crtc *crtc,
bool in_vblank_irq, int *vpos, int *hpos,
ktime_t *stime, ktime_t *etime,
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index fcc036a08965..6b1629c14dd7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1120,10 +1120,6 @@ driver_stub = {
.debugfs_init = nouveau_drm_debugfs_init,
 #endif
 
-   .enable_vblank = nouveau_display_vblank_enable,
-   .disable_vblank = nouveau_display_vblank_disable,
-   .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-
.ioctls = nouveau_ioctls,
.num_ioctls = ARRAY_SIZE(nouveau_ioctls),
.fops = _driver_fops,
-- 
2.24.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org

[PATCH v4 07/22] drm/i915: Convert to CRTC VBLANK callbacks

2020-01-23 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of their
equivalents in struct drm_crtc_funcs. Convert i915 over.

The callback struct drm_driver.get_scanout_position() is deprecated
in favor of struct drm_crtc_helper_funcs.get_scanout_position().
i915 doesn't use CRTC helpers. Instead pass i915's implementation of
get_scanout_position() to DRM core's
drm_crtc_vblank_helper_get_vblank_timestamp_internal().

v3:
* rename dcrtc to _crtc
* use intel_ prefix for i915_crtc_get_vblank_timestamp()
* update for drm_crtc_vblank_helper_get_vblank_timestamp_internal()
v2:
* use DRM's implementation of get_vblank_timestamp()
* simplify function names

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Ville Syrjälä 
Acked-by: Jani Nikula 
---
 drivers/gpu/drm/i915/display/intel_display.c |  7 +++
 drivers/gpu/drm/i915/i915_drv.c  |  3 ---
 drivers/gpu/drm/i915/i915_irq.c  | 20 +++-
 drivers/gpu/drm/i915/i915_irq.h  |  6 ++
 4 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index dd03987cc24f..2f71360e3697 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -16323,6 +16323,7 @@ static const struct drm_crtc_funcs bdw_crtc_funcs = {
.get_vblank_counter = g4x_get_vblank_counter,
.enable_vblank = bdw_enable_vblank,
.disable_vblank = bdw_disable_vblank,
+   .get_vblank_timestamp = intel_crtc_get_vblank_timestamp,
 };
 
 static const struct drm_crtc_funcs ilk_crtc_funcs = {
@@ -16331,6 +16332,7 @@ static const struct drm_crtc_funcs ilk_crtc_funcs = {
.get_vblank_counter = g4x_get_vblank_counter,
.enable_vblank = ilk_enable_vblank,
.disable_vblank = ilk_disable_vblank,
+   .get_vblank_timestamp = intel_crtc_get_vblank_timestamp,
 };
 
 static const struct drm_crtc_funcs g4x_crtc_funcs = {
@@ -16339,6 +16341,7 @@ static const struct drm_crtc_funcs g4x_crtc_funcs = {
.get_vblank_counter = g4x_get_vblank_counter,
.enable_vblank = i965_enable_vblank,
.disable_vblank = i965_disable_vblank,
+   .get_vblank_timestamp = intel_crtc_get_vblank_timestamp,
 };
 
 static const struct drm_crtc_funcs i965_crtc_funcs = {
@@ -16347,6 +16350,7 @@ static const struct drm_crtc_funcs i965_crtc_funcs = {
.get_vblank_counter = i915_get_vblank_counter,
.enable_vblank = i965_enable_vblank,
.disable_vblank = i965_disable_vblank,
+   .get_vblank_timestamp = intel_crtc_get_vblank_timestamp,
 };
 
 static const struct drm_crtc_funcs i915gm_crtc_funcs = {
@@ -16355,6 +16359,7 @@ static const struct drm_crtc_funcs i915gm_crtc_funcs = {
.get_vblank_counter = i915_get_vblank_counter,
.enable_vblank = i915gm_enable_vblank,
.disable_vblank = i915gm_disable_vblank,
+   .get_vblank_timestamp = intel_crtc_get_vblank_timestamp,
 };
 
 static const struct drm_crtc_funcs i915_crtc_funcs = {
@@ -16363,6 +16368,7 @@ static const struct drm_crtc_funcs i915_crtc_funcs = {
.get_vblank_counter = i915_get_vblank_counter,
.enable_vblank = i8xx_enable_vblank,
.disable_vblank = i8xx_disable_vblank,
+   .get_vblank_timestamp = intel_crtc_get_vblank_timestamp,
 };
 
 static const struct drm_crtc_funcs i8xx_crtc_funcs = {
@@ -16371,6 +16377,7 @@ static const struct drm_crtc_funcs i8xx_crtc_funcs = {
/* no hw vblank counter */
.enable_vblank = i8xx_enable_vblank,
.disable_vblank = i8xx_disable_vblank,
+   .get_vblank_timestamp = intel_crtc_get_vblank_timestamp,
 };
 
 static struct intel_crtc *intel_crtc_alloc(void)
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index f7385abdd74b..30b9ba136a81 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -2769,9 +2769,6 @@ static struct drm_driver driver = {
.gem_prime_export = i915_gem_prime_export,
.gem_prime_import = i915_gem_prime_import,
 
-   .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-   .get_scanout_position = i915_get_crtc_scanoutpos,
-
.dumb_create = i915_gem_dumb_create,
.dumb_map_offset = i915_gem_dumb_mmap_offset,
 
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index afc6aad9bf8c..29bf847999f5 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -762,13 +762,15 @@ static int __intel_get_crtc_scanline(struct intel_crtc 
*crtc)
return (position + crtc->scanline_offset) % vtotal;
 }
 
-bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int index,
- bool in_vblank_irq, int *vpos, int *hpos,
- ktime_t *stime, ktime_t *etime,
- const struct drm_display_mode *mode)
+static 

[PATCH v4 21/22] drm: Clean-up VBLANK-related callbacks in struct drm_driver

2020-01-23 Thread Thomas Zimmermann
All non-legacy users of VBLANK functions in struct drm_driver have been
converted to use the respective interfaces in struct drm_crtc_funcs. The
remaining users of VBLANK callbacks in struct drm_driver are legacy drivers
with userspace modesetting.

All users of struct drm_driver.get_scanout_position() have been
converted to the respective CRTC helper function. Remove the callback
from struct drm_driver.

There are no users left of get_vblank_timestamp(), so the callback is
being removed. The other VBLANK callbacks are being moved to the legacy
section at the end of struct drm_driver.

Also removed is drm_calc_vbltimestamp_from_scanoutpos(). Callers of this
function have been converted to use the CRTC instead.

v4:
* more readable code for setting high_prec (Ville, Jani)
v2:
* merge with removal of struct drm_driver.get_scanout_position()
* remove drm_calc_vbltimestamp_from_scanoutpos()

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Daniel Vetter 
Tested-by: Yannick Fertré 
---
 drivers/gpu/drm/drm_vblank.c |  81 +++
 include/drm/drm_drv.h| 153 +--
 include/drm/drm_vblank.h |   4 -
 3 files changed, 12 insertions(+), 226 deletions(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 6aa8f43f7375..90d62430a6ae 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -138,10 +138,9 @@ static u32 __get_vblank_counter(struct drm_device *dev, 
unsigned int pipe)
 
if (crtc->funcs->get_vblank_counter)
return crtc->funcs->get_vblank_counter(crtc);
-   }
-
-   if (dev->driver->get_vblank_counter)
+   } else if (dev->driver->get_vblank_counter) {
return dev->driver->get_vblank_counter(dev, pipe);
+   }
 
return drm_vblank_no_hw_counter(dev, pipe);
 }
@@ -334,8 +333,7 @@ u64 drm_crtc_accurate_vblank_count(struct drm_crtc *crtc)
unsigned long flags;
 
WARN_ONCE(drm_debug_enabled(DRM_UT_VBL) &&
- !crtc->funcs->get_vblank_timestamp &&
- !dev->driver->get_vblank_timestamp,
+ !crtc->funcs->get_vblank_timestamp,
  "This function requires support for accurate vblank 
timestamps.");
 
spin_lock_irqsave(>vblank_time_lock, flags);
@@ -357,13 +355,11 @@ static void __disable_vblank(struct drm_device *dev, 
unsigned int pipe)
if (WARN_ON(!crtc))
return;
 
-   if (crtc->funcs->disable_vblank) {
+   if (crtc->funcs->disable_vblank)
crtc->funcs->disable_vblank(crtc);
-   return;
-   }
+   } else {
+   dev->driver->disable_vblank(dev, pipe);
}
-
-   dev->driver->disable_vblank(dev, pipe);
 }
 
 /*
@@ -565,62 +561,6 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 }
 EXPORT_SYMBOL(drm_calc_timestamping_constants);
 
-/**
- * drm_calc_vbltimestamp_from_scanoutpos - precise vblank timestamp helper
- * @dev: DRM device
- * @pipe: index of CRTC whose vblank timestamp to retrieve
- * @max_error: Desired maximum allowable error in timestamps (nanosecs)
- * On return contains true maximum error of timestamp
- * @vblank_time: Pointer to time which should receive the timestamp
- * @in_vblank_irq:
- * True when called from drm_crtc_handle_vblank().  Some drivers
- * need to apply some workarounds for gpu-specific vblank irq quirks
- * if flag is set.
- *
- * Implements calculation of exact vblank timestamps from given 
drm_display_mode
- * timings and current video scanout position of a CRTC. This can be directly
- * used as the _crtc_funcs.get_vblank_timestamp implementation of a kms
- * driver if _crtc_helper_funcs.get_scanout_position or
- * _driver.get_scanout_position is implemented.
- *
- * The current implementation only handles standard video modes. For double 
scan
- * and interlaced modes the driver is supposed to adjust the hardware mode
- * (taken from _crtc_state.adjusted mode for atomic modeset drivers) to
- * match the scanout position reported.
- *
- * Note that atomic drivers must call drm_calc_timestamping_constants() before
- * enabling a CRTC. The atomic helpers already take care of that in
- * drm_atomic_helper_update_legacy_modeset_state().
- *
- * Returns:
- *
- * Returns true on success, and false on failure, i.e. when no accurate
- * timestamp could be acquired.
- */
-bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-  unsigned int pipe,
-  int *max_error,
-  ktime_t *vblank_time,
-  bool in_vblank_irq)
-{
-   struct drm_crtc *crtc;
-
-   if (!drm_core_check_feature(dev, DRIVER_MODESET))
-   return false;
-
-   crtc = 

[PATCH v4 17/22] drm/vc4: Convert to struct drm_crtc_helper_funcs.get_scanout_position()

2020-01-23 Thread Thomas Zimmermann
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position(). Convert vc4
over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 12 +++-
 drivers/gpu/drm/vc4/vc4_drv.c  |  1 -
 drivers/gpu/drm/vc4/vc4_drv.h  |  4 
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index b00e20f5ce05..f1e7597ea17e 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -84,13 +84,14 @@ static const struct debugfs_reg32 crtc_regs[] = {
VC4_REG32(PV_HACT_ACT),
 };
 
-bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
-bool in_vblank_irq, int *vpos, int *hpos,
-ktime_t *stime, ktime_t *etime,
-const struct drm_display_mode *mode)
+static bool vc4_crtc_get_scanout_position(struct drm_crtc *crtc,
+ bool in_vblank_irq,
+ int *vpos, int *hpos,
+ ktime_t *stime, ktime_t *etime,
+ const struct drm_display_mode *mode)
 {
+   struct drm_device *dev = crtc->dev;
struct vc4_dev *vc4 = to_vc4_dev(dev);
-   struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
u32 val;
int fifo_lines;
@@ -1039,6 +1040,7 @@ static const struct drm_crtc_helper_funcs 
vc4_crtc_helper_funcs = {
.atomic_flush = vc4_crtc_atomic_flush,
.atomic_enable = vc4_crtc_atomic_enable,
.atomic_disable = vc4_crtc_atomic_disable,
+   .get_scanout_position = vc4_crtc_get_scanout_position,
 };
 
 static const struct vc4_crtc_data pv0_data = {
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 5e6fb6c2307f..e6982a7b0c5e 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -190,7 +190,6 @@ static struct drm_driver vc4_drm_driver = {
.irq_postinstall = vc4_irq_postinstall,
.irq_uninstall = vc4_irq_uninstall,
 
-   .get_scanout_position = vc4_crtc_get_scanoutpos,
.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 
 #if defined(CONFIG_DEBUG_FS)
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index 6627b20c99e9..f90c0d08e740 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -743,10 +743,6 @@ void vc4_bo_remove_from_purgeable_pool(struct vc4_bo *bo);
 
 /* vc4_crtc.c */
 extern struct platform_driver vc4_crtc_driver;
-bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
-bool in_vblank_irq, int *vpos, int *hpos,
-ktime_t *stime, ktime_t *etime,
-const struct drm_display_mode *mode);
 void vc4_crtc_handle_vblank(struct vc4_crtc *crtc);
 void vc4_crtc_txp_armed(struct drm_crtc_state *state);
 void vc4_crtc_get_margins(struct drm_crtc_state *state,
-- 
2.24.1

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


[PATCH v4 10/22] drm/radeon: Convert to struct drm_crtc_helper_funcs.get_scanout_position()

2020-01-23 Thread Thomas Zimmermann
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position(). Convert
radeon over.

v4:
* 80-character line fixes

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/radeon/atombios_crtc.c  |  1 +
 drivers/gpu/drm/radeon/radeon_display.c | 13 +
 drivers/gpu/drm/radeon/radeon_drv.c | 11 ---
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c |  3 ++-
 drivers/gpu/drm/radeon/radeon_mode.h|  6 ++
 5 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c 
b/drivers/gpu/drm/radeon/atombios_crtc.c
index be583695427a..91811757104c 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -2231,6 +2231,7 @@ static const struct drm_crtc_helper_funcs 
atombios_helper_funcs = {
.prepare = atombios_crtc_prepare,
.commit = atombios_crtc_commit,
.disable = atombios_crtc_disable,
+   .get_scanout_position = radeon_get_crtc_scanout_position,
 };
 
 void radeon_atombios_init_crtc(struct drm_device *dev,
diff --git a/drivers/gpu/drm/radeon/radeon_display.c 
b/drivers/gpu/drm/radeon/radeon_display.c
index 856526cb2caf..2f641f3b39e7 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1978,3 +1978,16 @@ int radeon_get_crtc_scanoutpos(struct drm_device *dev, 
unsigned int pipe,
 
return ret;
 }
+
+bool
+radeon_get_crtc_scanout_position(struct drm_crtc *crtc,
+bool in_vblank_irq, int *vpos, int *hpos,
+ktime_t *stime, ktime_t *etime,
+const struct drm_display_mode *mode)
+{
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
+
+   return radeon_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
+ stime, etime, mode);
+}
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index fd74e2611185..1f597f166bff 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -563,16 +563,6 @@ static const struct file_operations radeon_driver_kms_fops 
= {
 #endif
 };
 
-static bool
-radeon_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
-bool in_vblank_irq, int *vpos, int *hpos,
-ktime_t *stime, ktime_t *etime,
-const struct drm_display_mode *mode)
-{
-   return radeon_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
- stime, etime, mode);
-}
-
 static struct drm_driver kms_driver = {
.driver_features =
DRIVER_USE_AGP | DRIVER_GEM | DRIVER_RENDER,
@@ -585,7 +575,6 @@ static struct drm_driver kms_driver = {
.enable_vblank = radeon_enable_vblank_kms,
.disable_vblank = radeon_disable_vblank_kms,
.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-   .get_scanout_position = radeon_get_crtc_scanout_position,
.irq_preinstall = radeon_driver_irq_preinstall_kms,
.irq_postinstall = radeon_driver_irq_postinstall_kms,
.irq_uninstall = radeon_driver_irq_uninstall_kms,
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c 
b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index a1985a552794..8817fd033cd0 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -,7 +,8 @@ static const struct drm_crtc_helper_funcs 
legacy_helper_funcs = {
.mode_set_base_atomic = radeon_crtc_set_base_atomic,
.prepare = radeon_crtc_prepare,
.commit = radeon_crtc_commit,
-   .disable = radeon_crtc_disable
+   .disable = radeon_crtc_disable,
+   .get_scanout_position = radeon_get_crtc_scanout_position,
 };
 
 
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h 
b/drivers/gpu/drm/radeon/radeon_mode.h
index fd470d6bf3f4..3a61530c1398 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -881,6 +881,12 @@ extern int radeon_get_crtc_scanoutpos(struct drm_device 
*dev, unsigned int pipe,
  ktime_t *stime, ktime_t *etime,
  const struct drm_display_mode *mode);
 
+extern bool
+radeon_get_crtc_scanout_position(struct drm_crtc *crtc, bool in_vblank_irq,
+int *vpos, int *hpos,
+ktime_t *stime, ktime_t *etime,
+const struct drm_display_mode *mode);
+
 extern bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev);
 extern struct edid *
 radeon_bios_get_hardcoded_edid(struct radeon_device *rdev);
-- 
2.24.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org

[PATCH v4 02/22] drm: Add get_scanout_position() to struct drm_crtc_helper_funcs

2020-01-23 Thread Thomas Zimmermann
The new callback get_scanout_position() reads the current location
of the scanout process. The operation is currently located in struct
drm_driver, but really belongs to the CRTC. Drivers will be converted
in separate patches.

To help with the conversion, the timestamp calculation has been
moved from drm_calc_vbltimestamp_from_scanoutpos() to
drm_crtc_vblank_helper_get_vblank_timestamp_internal(). The helper
function supports the new and old interface of get_scanout_position().
drm_calc_vbltimestamp_from_scanoutpos() remains as a wrapper around
the new function.

Callback functions return the scanout position from the CRTC. The
legacy version of the interface receives the device and pipe index,
the modern version receives a pointer to the CRTC. We keep the
legacy version until all drivers have been converted.

v4:
* 80-character line fixes
v3:
* refactor drm_calc_vbltimestamp_from_scanoutpos() to minimize
  code duplication
* define types for get_scanout_position() callbacks
v2:
* fix logical op in drm_calc_vbltimestamp_from_scanoutpos()

Signed-off-by: Thomas Zimmermann 
Tested-by: Yannick Fertré 
Reviewed-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_vblank.c | 101 +++
 include/drm/drm_drv.h|   7 +-
 include/drm/drm_modeset_helper_vtables.h |  47 +++
 include/drm/drm_vblank.h |  25 ++
 4 files changed, 157 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 326db52f2ad8..7e962c29780c 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -577,7 +578,7 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * Implements calculation of exact vblank timestamps from given 
drm_display_mode
  * timings and current video scanout position of a CRTC. This can be directly
  * used as the _driver.get_vblank_timestamp implementation of a kms driver
- * if _driver.get_scanout_position is implemented.
+ * if _crtc_helper_funcs.get_scanout_position is implemented.
  *
  * The current implementation only handles standard video modes. For double 
scan
  * and interlaced modes the driver is supposed to adjust the hardware mode
@@ -599,28 +600,85 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct 
drm_device *dev,
   ktime_t *vblank_time,
   bool in_vblank_irq)
 {
-   struct timespec64 ts_etime, ts_vblank_time;
-   ktime_t stime, etime;
-   bool vbl_status;
struct drm_crtc *crtc;
-   const struct drm_display_mode *mode;
-   struct drm_vblank_crtc *vblank = >vblank[pipe];
-   int vpos, hpos, i;
-   int delta_ns, duration_ns;
 
if (!drm_core_check_feature(dev, DRIVER_MODESET))
return false;
 
crtc = drm_crtc_from_index(dev, pipe);
+   if (!crtc)
+   return false;
 
-   if (pipe >= dev->num_crtcs || !crtc) {
+   return drm_crtc_vblank_helper_get_vblank_timestamp_internal(crtc,
+   max_error,
+   vblank_time,
+   
in_vblank_irq,
+   
crtc->helper_private->get_scanout_position,
+   
dev->driver->get_scanout_position);
+}
+EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos);
+
+/**
+ * drm_crtc_vblank_helper_get_vblank_timestamp_internal - precise vblank
+ *timestamp helper
+ * @dev: DRM device
+ * @pipe: index of CRTC whose vblank timestamp to retrieve
+ * @max_error: Desired maximum allowable error in timestamps (nanosecs)
+ * On return contains true maximum error of timestamp
+ * @vblank_time: Pointer to time which should receive the timestamp
+ * @in_vblank_irq:
+ * True when called from drm_crtc_handle_vblank().  Some drivers
+ * need to apply some workarounds for gpu-specific vblank irq quirks
+ * if flag is set.
+ * @get_scanout_position:
+ * Callback function to retrieve the scanout position. See
+ * @struct drm_crtc_helper_funcs.get_scanout_position.
+ * @get_scanout_position_legacy:
+ * Callback function to retrieve the scanout position. See
+ * @struct drm_driver.get_scanout_position.
+ *
+ * Implements calculation of exact vblank timestamps from given 
drm_display_mode
+ * timings and current video scanout position of a CRTC.
+ *
+ * The current implementation only handles standard video modes. For double 
scan
+ * and interlaced modes the driver is supposed to adjust the hardware mode
+ * (taken from _crtc_state.adjusted mode for atomic modeset drivers) 

[PATCH v4 08/22] drm/nouveau: Convert to struct drm_crtc_helper_funcs.get_scanout_position()

2020-01-23 Thread Thomas Zimmermann
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position(). Convert
nouveau over.

v4:
* add argument names in function declaration

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c   |  1 +
 drivers/gpu/drm/nouveau/dispnv50/head.c   |  1 +
 drivers/gpu/drm/nouveau/nouveau_display.c | 14 +++---
 drivers/gpu/drm/nouveau/nouveau_display.h |  7 ---
 drivers/gpu/drm/nouveau/nouveau_drm.c |  1 -
 5 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c 
b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 37c50ea8f847..17e9d1c078a0 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -1258,6 +1258,7 @@ static const struct drm_crtc_helper_funcs 
nv04_crtc_helper_funcs = {
.mode_set_base = nv04_crtc_mode_set_base,
.mode_set_base_atomic = nv04_crtc_mode_set_base_atomic,
.disable = nv_crtc_disable,
+   .get_scanout_position = nouveau_display_scanoutpos,
 };
 
 static const uint32_t modeset_formats[] = {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c 
b/drivers/gpu/drm/nouveau/dispnv50/head.c
index d9d64602947d..41852dd8fdbd 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head.c
@@ -413,6 +413,7 @@ nv50_head_atomic_check(struct drm_crtc *crtc, struct 
drm_crtc_state *state)
 static const struct drm_crtc_helper_funcs
 nv50_head_help = {
.atomic_check = nv50_head_atomic_check,
+   .get_scanout_position = nouveau_display_scanoutpos,
 };
 
 static void
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
b/drivers/gpu/drm/nouveau/nouveau_display.c
index 53f9bceaf17a..86f99dc8fcef 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -136,21 +136,13 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, 
int *vpos, int *hpos,
 }
 
 bool
-nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
+nouveau_display_scanoutpos(struct drm_crtc *crtc,
   bool in_vblank_irq, int *vpos, int *hpos,
   ktime_t *stime, ktime_t *etime,
   const struct drm_display_mode *mode)
 {
-   struct drm_crtc *crtc;
-
-   list_for_each_entry(crtc, >mode_config.crtc_list, head) {
-   if (nouveau_crtc(crtc)->index == pipe) {
-   return nouveau_display_scanoutpos_head(crtc, vpos, hpos,
-  stime, etime);
-   }
-   }
-
-   return false;
+   return nouveau_display_scanoutpos_head(crtc, vpos, hpos,
+  stime, etime);
 }
 
 static void
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.h 
b/drivers/gpu/drm/nouveau/nouveau_display.h
index 6e8e66882e45..26d34f1a77da 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.h
+++ b/drivers/gpu/drm/nouveau/nouveau_display.h
@@ -63,9 +63,10 @@ int  nouveau_display_suspend(struct drm_device *dev, bool 
runtime);
 void nouveau_display_resume(struct drm_device *dev, bool runtime);
 int  nouveau_display_vblank_enable(struct drm_device *, unsigned int);
 void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
-bool  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
-bool, int *, int *, ktime_t *,
-ktime_t *, const struct drm_display_mode *);
+bool nouveau_display_scanoutpos(struct drm_crtc *crtc,
+   bool in_vblank_irq, int *vpos, int *hpos,
+   ktime_t *stime, ktime_t *etime,
+   const struct drm_display_mode *mode);
 
 int  nouveau_display_dumb_create(struct drm_file *, struct drm_device *,
 struct drm_mode_create_dumb *args);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index b65ae817eabf..fcc036a08965 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1122,7 +1122,6 @@ driver_stub = {
 
.enable_vblank = nouveau_display_vblank_enable,
.disable_vblank = nouveau_display_vblank_disable,
-   .get_scanout_position = nouveau_display_scanoutpos,
.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 
.ioctls = nouveau_ioctls,
-- 
2.24.1

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


[PATCH v4 05/22] drm/amdgpu: Convert to CRTC VBLANK callbacks

2020-01-23 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert amdgpu over.

v2:
* don't wrap existing functions; change signature instead

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  6 +++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |  4 
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   | 21 +++
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c|  4 
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c|  4 
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c |  4 
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c |  4 
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c  |  4 
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +
 10 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index f42e8d467c12..2319fdfc42e5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1191,9 +1191,9 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
 int amdgpu_device_ip_suspend(struct amdgpu_device *adev);
 int amdgpu_device_suspend(struct drm_device *dev, bool fbcon);
 int amdgpu_device_resume(struct drm_device *dev, bool fbcon);
-u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
-int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
+u32 amdgpu_get_vblank_counter_kms(struct drm_crtc *crtc);
+int amdgpu_enable_vblank_kms(struct drm_crtc *crtc);
+void amdgpu_disable_vblank_kms(struct drm_crtc *crtc);
 long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
 unsigned long arg);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index a1e769d4417d..ad9c9546a64f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -99,7 +99,7 @@ static void amdgpu_display_flip_work_func(struct work_struct 
*__work)
 & (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK)) ==
(DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK) &&
(int)(work->target_vblank -
- amdgpu_get_vblank_counter_kms(adev->ddev, 
amdgpu_crtc->crtc_id)) > 0) {
+ amdgpu_get_vblank_counter_kms(crtc)) > 0) {
schedule_delayed_work(>flip_work, usecs_to_jiffies(1000));
return;
}
@@ -219,7 +219,7 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc 
*crtc,
if (!adev->enable_virtual_display)
work->base = amdgpu_bo_gpu_offset(new_abo);
work->target_vblank = target - (uint32_t)drm_crtc_vblank_count(crtc) +
-   amdgpu_get_vblank_counter_kms(dev, work->crtc_id);
+   amdgpu_get_vblank_counter_kms(crtc);
 
/* we borrow the event spin lock for protecting flip_wrok */
spin_lock_irqsave(>dev->event_lock, flags);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 955b78f1bba4..bc2fa428013f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1388,10 +1388,6 @@ static struct drm_driver kms_driver = {
.postclose = amdgpu_driver_postclose_kms,
.lastclose = amdgpu_driver_lastclose_kms,
.unload = amdgpu_driver_unload_kms,
-   .get_vblank_counter = amdgpu_get_vblank_counter_kms,
-   .enable_vblank = amdgpu_enable_vblank_kms,
-   .disable_vblank = amdgpu_disable_vblank_kms,
-   .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
.irq_handler = amdgpu_irq_handler,
.ioctls = amdgpu_ioctls_kms,
.gem_free_object_unlocked = amdgpu_gem_object_free,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 60591dbc2097..98c196de27a4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -1110,14 +1110,15 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
 /**
  * amdgpu_get_vblank_counter_kms - get frame count
  *
- * @dev: drm dev pointer
- * @pipe: crtc to get the frame count from
+ * @crtc: crtc to get the frame count from
  *
  * Gets the frame count on the requested crtc (all asics).
  * Returns frame count on success, -EINVAL on failure.
  */
-u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe)
+u32 amdgpu_get_vblank_counter_kms(struct drm_crtc *crtc)
 {
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
struct amdgpu_device *adev = dev->dev_private;
int vpos, hpos, stat;
u32 count;
@@ -1177,14 +1178,15 @@ u32 amdgpu_get_vblank_counter_kms(struct drm_device 
*dev, unsigned 

[PATCH v4 03/22] drm: Add get_vblank_timestamp() to struct drm_crtc_funcs

2020-01-23 Thread Thomas Zimmermann
The callback get_vblank_timestamp() is currently located in struct
drm_driver, but really belongs into struct drm_crtc_funcs. Add an
equivalent there. Driver will be converted in separate patches.

The default implementation is drm_calc_vbltimestamp_from_scanoutpos().
The patch adds drm_crtc_vblank_helper_get_vblank_timestamp(), which is
an implementation for the CRTC callback.

v4:
* more readable code for setting high_prec (Ville, Jani)
v3:
* use refactored timestamp calculation to minimize duplicated code
* do more checks for crtc != NULL to support legacy drivers
v2:
* rename helper to drm_crtc_vblank_helper_get_vblank_timestamp()
* replace drm_calc_vbltimestamp_from_scanoutpos() with
  drm_crtc_vblank_helper_get_vblank_timestamp() in docs

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_vblank.c | 76 +---
 include/drm/drm_crtc.h   | 46 +-
 include/drm/drm_modeset_helper_vtables.h |  4 +-
 include/drm/drm_vblank.h | 16 +++--
 4 files changed, 125 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 7e962c29780c..6aa8f43f7375 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -333,7 +333,9 @@ u64 drm_crtc_accurate_vblank_count(struct drm_crtc *crtc)
u64 vblank;
unsigned long flags;
 
-   WARN_ONCE(drm_debug_enabled(DRM_UT_VBL) && 
!dev->driver->get_vblank_timestamp,
+   WARN_ONCE(drm_debug_enabled(DRM_UT_VBL) &&
+ !crtc->funcs->get_vblank_timestamp &&
+ !dev->driver->get_vblank_timestamp,
  "This function requires support for accurate vblank 
timestamps.");
 
spin_lock_irqsave(>vblank_time_lock, flags);
@@ -511,9 +513,9 @@ EXPORT_SYMBOL(drm_crtc_vblank_waitqueue);
  *
  * Calculate and store various constants which are later needed by vblank and
  * swap-completion timestamping, e.g, by
- * drm_calc_vbltimestamp_from_scanoutpos(). They are derived from CRTC's true
- * scanout timing, so they take things like panel scaling or other adjustments
- * into account.
+ * drm_crtc_vblank_helper_get_vblank_timestamp(). They are derived from
+ * CRTC's true scanout timing, so they take things like panel scaling or
+ * other adjustments into account.
  */
 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 const struct drm_display_mode *mode)
@@ -577,8 +579,9 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  *
  * Implements calculation of exact vblank timestamps from given 
drm_display_mode
  * timings and current video scanout position of a CRTC. This can be directly
- * used as the _driver.get_vblank_timestamp implementation of a kms driver
- * if _crtc_helper_funcs.get_scanout_position is implemented.
+ * used as the _crtc_funcs.get_vblank_timestamp implementation of a kms
+ * driver if _crtc_helper_funcs.get_scanout_position or
+ * _driver.get_scanout_position is implemented.
  *
  * The current implementation only handles standard video modes. For double 
scan
  * and interlaced modes the driver is supposed to adjust the hardware mode
@@ -774,6 +777,48 @@ drm_crtc_vblank_helper_get_vblank_timestamp_internal(
 }
 EXPORT_SYMBOL(drm_crtc_vblank_helper_get_vblank_timestamp_internal);
 
+/**
+ * drm_crtc_vblank_helper_get_vblank_timestamp - precise vblank timestamp
+ *   helper
+ * @crtc: CRTC whose vblank timestamp to retrieve
+ * @max_error: Desired maximum allowable error in timestamps (nanosecs)
+ * On return contains true maximum error of timestamp
+ * @vblank_time: Pointer to time which should receive the timestamp
+ * @in_vblank_irq:
+ * True when called from drm_crtc_handle_vblank().  Some drivers
+ * need to apply some workarounds for gpu-specific vblank irq quirks
+ * if flag is set.
+ *
+ * Implements calculation of exact vblank timestamps from given 
drm_display_mode
+ * timings and current video scanout position of a CRTC. This can be directly
+ * used as the _crtc_funcs.get_vblank_timestamp implementation of a kms
+ * driver if _crtc_helper_funcs.get_scanout_position is implemented.
+ *
+ * The current implementation only handles standard video modes. For double 
scan
+ * and interlaced modes the driver is supposed to adjust the hardware mode
+ * (taken from _crtc_state.adjusted mode for atomic modeset drivers) to
+ * match the scanout position reported.
+ *
+ * Note that atomic drivers must call drm_calc_timestamping_constants() before
+ * enabling a CRTC. The atomic helpers already take care of that in
+ * drm_atomic_helper_update_legacy_modeset_state().
+ *
+ * Returns:
+ *
+ * Returns true on success, and false on failure, i.e. when no accurate
+ * timestamp could be acquired.
+ */
+bool drm_crtc_vblank_helper_get_vblank_timestamp(struct drm_crtc *crtc,
+  

[PATCH v4 01/22] drm: Remove internal setup of struct drm_device.vblank_disable_immediate

2020-01-23 Thread Thomas Zimmermann
VBLANK interrupts can be disabled immediately or with a delay, where the
latter is the default. The former option can be selected by setting
get_vblank_timestamp and enabling vblank_disable_immediate in struct
drm_device. Simplify the code in preparation of the removal of struct
drm_device.get_vblank_timestamp.

v3:
* remove internal setup of vblank_disable_immediate

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_vblank.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 1659b13b178c..326db52f2ad8 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -480,19 +480,6 @@ int drm_vblank_init(struct drm_device *dev, unsigned int 
num_crtcs)
 
DRM_INFO("Supports vblank timestamp caching Rev 2 (21.10.2013).\n");
 
-   /* Driver specific high-precision vblank timestamping supported? */
-   if (dev->driver->get_vblank_timestamp)
-   DRM_INFO("Driver supports precise vblank timestamp query.\n");
-   else
-   DRM_INFO("No driver support for vblank timestamp query.\n");
-
-   /* Must have precise timestamping for reliable vblank instant disable */
-   if (dev->vblank_disable_immediate && 
!dev->driver->get_vblank_timestamp) {
-   dev->vblank_disable_immediate = false;
-   DRM_INFO("Setting vblank_disable_immediate to false because "
-"get_vblank_timestamp == NULL\n");
-   }
-
return 0;
 
 err:
-- 
2.24.1

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


[PATCH] drm/amd/amdgpu: fix spelling mistake "to" -> "too"

2020-01-23 Thread Colin King
From: Colin Ian King 

There is a spelling mistake in a DRM_ERROR message. Fix it.

Signed-off-by: Colin Ian King 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
index ceb0dbf685f1..59ddba137946 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
@@ -652,7 +652,7 @@ static int amdgpu_vce_cs_reloc(struct amdgpu_cs_parser *p, 
uint32_t ib_idx,
 
if ((addr + (uint64_t)size) >
(mapping->last + 1) * AMDGPU_GPU_PAGE_SIZE) {
-   DRM_ERROR("BO to small for addr 0x%010Lx %d %d\n",
+   DRM_ERROR("BO too small for addr 0x%010Lx %d %d\n",
  addr, lo, hi);
return -EINVAL;
}
-- 
2.24.0

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