Re: [RESEND 4/6] drm/amdgpu: remove amdgpu_connector_edid() and stop using edid_blob_ptr

2024-05-13 Thread Robert Foss
_0_audio_write_sad_regs(struct 
> drm_encoder *encoder)
> return;
> }
>
> -   sad_count = drm_edid_to_sad(amdgpu_connector_edid(connector), );
> +   sad_count = drm_edid_to_sad(amdgpu_connector->edid, );
> if (sad_count < 0)
> DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
> if (sad_count <= 0)
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
> index db20012600f5..05c0df97f01d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
> @@ -1217,7 +1217,7 @@ static void 
> dce_v6_0_audio_write_speaker_allocation(struct drm_encoder *encoder)
> return;
> }
>
> -   sad_count = 
> drm_edid_to_speaker_allocation(amdgpu_connector_edid(connector), );
> +   sad_count = drm_edid_to_speaker_allocation(amdgpu_connector->edid, 
> );
> if (sad_count < 0) {
> DRM_ERROR("Couldn't read Speaker Allocation Data Block: 
> %d\n", sad_count);
> sad_count = 0;
> @@ -1292,7 +1292,7 @@ static void dce_v6_0_audio_write_sad_regs(struct 
> drm_encoder *encoder)
> return;
> }
>
> -   sad_count = drm_edid_to_sad(amdgpu_connector_edid(connector), );
> +   sad_count = drm_edid_to_sad(amdgpu_connector->edid, );
> if (sad_count < 0)
> DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
> if (sad_count <= 0)
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
> index 5b56100ec902..dc73e301d937 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
> @@ -1272,7 +1272,7 @@ static void 
> dce_v8_0_audio_write_speaker_allocation(struct drm_encoder *encoder)
> return;
> }
>
> -   sad_count = 
> drm_edid_to_speaker_allocation(amdgpu_connector_edid(connector), );
> +   sad_count = drm_edid_to_speaker_allocation(amdgpu_connector->edid, 
> );
> if (sad_count < 0) {
> DRM_ERROR("Couldn't read Speaker Allocation Data Block: 
> %d\n", sad_count);
> sad_count = 0;
> @@ -1340,7 +1340,7 @@ static void dce_v8_0_audio_write_sad_regs(struct 
> drm_encoder *encoder)
> return;
> }
>
> -   sad_count = drm_edid_to_sad(amdgpu_connector_edid(connector), );
> +   sad_count = drm_edid_to_sad(amdgpu_connector->edid, );
> if (sad_count < 0)
> DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
> if (sad_count <= 0)
> --
> 2.39.2
>

Reviewed-by: Robert Foss 


Re: [RESEND 3/6] drm/radeon: remove radeon_connector_edid() and stop using edid_blob_ptr

2024-05-13 Thread Robert Foss
On Fri, May 10, 2024 at 5:08 PM Jani Nikula  wrote:
>
> radeon_connector_edid() copies the EDID from edid_blob_ptr as a side
> effect if radeon_connector->edid isn't initialized. However, everywhere
> that the returned EDID is used, the EDID should have been set
> beforehands.
>
> Only the drm EDID code should look at the EDID property, anyway, so stop
> using it.
>
> Cc: Alex Deucher 
> Cc: Christian König 
> Cc: Pan, Xinhui 
> Cc: amd-...@lists.freedesktop.org
> Signed-off-by: Jani Nikula 
> ---
>  drivers/gpu/drm/radeon/radeon_audio.c  |  7 ---
>  drivers/gpu/drm/radeon/radeon_connectors.c | 15 ---
>  drivers/gpu/drm/radeon/radeon_mode.h   |  2 --
>  3 files changed, 4 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_audio.c 
> b/drivers/gpu/drm/radeon/radeon_audio.c
> index 16c10db3ce6f..0bcd767b9f47 100644
> --- a/drivers/gpu/drm/radeon/radeon_audio.c
> +++ b/drivers/gpu/drm/radeon/radeon_audio.c
> @@ -303,6 +303,7 @@ void radeon_audio_endpoint_wreg(struct radeon_device 
> *rdev, u32 offset,
>  static void radeon_audio_write_sad_regs(struct drm_encoder *encoder)
>  {
> struct drm_connector *connector = 
> radeon_get_connector_for_encoder(encoder);
> +   struct radeon_connector *radeon_connector = 
> to_radeon_connector(connector);
> struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
> struct cea_sad *sads;
> int sad_count;
> @@ -310,7 +311,7 @@ static void radeon_audio_write_sad_regs(struct 
> drm_encoder *encoder)
> if (!connector)
> return;
>
> -   sad_count = drm_edid_to_sad(radeon_connector_edid(connector), );
> +   sad_count = drm_edid_to_sad(radeon_connector->edid, );
> if (sad_count < 0)
> DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
> if (sad_count <= 0)
> @@ -326,6 +327,7 @@ static void radeon_audio_write_sad_regs(struct 
> drm_encoder *encoder)
>  static void radeon_audio_write_speaker_allocation(struct drm_encoder 
> *encoder)
>  {
> struct drm_connector *connector = 
> radeon_get_connector_for_encoder(encoder);
> +   struct radeon_connector *radeon_connector = 
> to_radeon_connector(connector);
> struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
> u8 *sadb = NULL;
> int sad_count;
> @@ -333,8 +335,7 @@ static void radeon_audio_write_speaker_allocation(struct 
> drm_encoder *encoder)
> if (!connector)
> return;
>
> -   sad_count = 
> drm_edid_to_speaker_allocation(radeon_connector_edid(connector),
> -  );
> +   sad_count = drm_edid_to_speaker_allocation(radeon_connector->edid, 
> );
> if (sad_count < 0) {
> DRM_DEBUG("Couldn't read Speaker Allocation Data Block: %d\n",
>   sad_count);
> diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c 
> b/drivers/gpu/drm/radeon/radeon_connectors.c
> index 81b5c3c8f658..80879e946342 100644
> --- a/drivers/gpu/drm/radeon/radeon_connectors.c
> +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
> @@ -255,21 +255,6 @@ static struct drm_encoder *radeon_find_encoder(struct 
> drm_connector *connector,
> return NULL;
>  }
>
> -struct edid *radeon_connector_edid(struct drm_connector *connector)
> -{
> -   struct radeon_connector *radeon_connector = 
> to_radeon_connector(connector);
> -   struct drm_property_blob *edid_blob = connector->edid_blob_ptr;
> -
> -   if (radeon_connector->edid) {
> -   return radeon_connector->edid;
> -   } else if (edid_blob) {
> -   struct edid *edid = kmemdup(edid_blob->data, 
> edid_blob->length, GFP_KERNEL);
> -   if (edid)
> -   radeon_connector->edid = edid;
> -   }
> -   return radeon_connector->edid;
> -}
> -
>  static void radeon_connector_get_edid(struct drm_connector *connector)
>  {
> struct drm_device *dev = connector->dev;
> diff --git a/drivers/gpu/drm/radeon/radeon_mode.h 
> b/drivers/gpu/drm/radeon/radeon_mode.h
> index 546381a5c918..e0a5af180801 100644
> --- a/drivers/gpu/drm/radeon/radeon_mode.h
> +++ b/drivers/gpu/drm/radeon/radeon_mode.h
> @@ -701,8 +701,6 @@ extern u16 
> radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connecto
>  extern bool radeon_connector_is_dp12_capable(struct drm_connector 
> *connector);
>  extern int radeon_get_monitor_bpc(struct drm_connector *connector);
>
> -extern struct edid *radeon_connector_edid(struct drm_connector *connector);
> -
>  extern void radeon_connector_hotplug(struct drm_connector *connector);
>  extern int radeon_dp_mode_valid_helper(struct drm_connector *connector,
>struct drm_display_mode *mode);
> --
> 2.39.2
>

Reviewed-by: Robert Foss 


Re: [RESEND 2/6] drm/radeon: convert to using is_hdmi and has_audio from display info

2024-05-13 Thread Robert Foss
> -   if (drm_detect_hdmi_monitor(radeon_connector_edid(connector))) {
> +   if (connector->display_info.is_hdmi) {
> /* hdmi deep color only implemented on DCE4+ */
> if ((bpc > 8) && !ASIC_IS_DCE4(rdev)) {
> DRM_DEBUG("%s: HDMI deep color %d bpc unsupported. 
> Using 8 bpc.\n",
> @@ -1478,7 +1478,7 @@ static enum drm_mode_status 
> radeon_dvi_mode_valid(struct drm_connector *connecto
> (radeon_connector->connector_object_id == 
> CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D) ||
> (radeon_connector->connector_object_id == 
> CONNECTOR_OBJECT_ID_HDMI_TYPE_B))
> return MODE_OK;
> -   else if (ASIC_IS_DCE6(rdev) && 
> drm_detect_hdmi_monitor(radeon_connector_edid(connector))) {
> +   else if (ASIC_IS_DCE6(rdev) && 
> connector->display_info.is_hdmi) {
> /* HDMI 1.3+ supports max clock of 340 Mhz */
> if (mode->clock > 34)
> return MODE_CLOCK_HIGH;
> @@ -1774,7 +1774,7 @@ static enum drm_mode_status radeon_dp_mode_valid(struct 
> drm_connector *connector
> (radeon_dig_connector->dp_sink_type == 
> CONNECTOR_OBJECT_ID_eDP)) {
> return radeon_dp_mode_valid_helper(connector, mode);
> } else {
> -   if (ASIC_IS_DCE6(rdev) && 
> drm_detect_hdmi_monitor(radeon_connector_edid(connector))) {
> +   if (ASIC_IS_DCE6(rdev) && 
> connector->display_info.is_hdmi) {
> /* HDMI 1.3+ supports max clock of 340 Mhz */
> if (mode->clock > 34)
> return MODE_CLOCK_HIGH;
> diff --git a/drivers/gpu/drm/radeon/radeon_display.c 
> b/drivers/gpu/drm/radeon/radeon_display.c
> index 5f1d24d3120c..843383f7237f 100644
> --- a/drivers/gpu/drm/radeon/radeon_display.c
> +++ b/drivers/gpu/drm/radeon/radeon_display.c
> @@ -1722,7 +1722,7 @@ bool radeon_crtc_scaling_mode_fixup(struct drm_crtc 
> *crtc,
> (!(mode->flags & DRM_MODE_FLAG_INTERLACE)) &&
> ((radeon_encoder->underscan_type == UNDERSCAN_ON) 
> ||
>  ((radeon_encoder->underscan_type == 
> UNDERSCAN_AUTO) &&
> - 
> drm_detect_hdmi_monitor(radeon_connector_edid(connector)) &&
> + connector->display_info.is_hdmi &&
>   is_hdtv_mode(mode {
> if (radeon_encoder->underscan_hborder != 0)
> radeon_crtc->h_border = 
> radeon_encoder->underscan_hborder;
> diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c 
> b/drivers/gpu/drm/radeon/radeon_encoders.c
> index 3de3dce9e89d..0f723292409e 100644
> --- a/drivers/gpu/drm/radeon/radeon_encoders.c
> +++ b/drivers/gpu/drm/radeon/radeon_encoders.c
> @@ -386,7 +386,7 @@ bool radeon_dig_monitor_is_duallink(struct drm_encoder 
> *encoder,
> case DRM_MODE_CONNECTOR_HDMIB:
> if (radeon_connector->use_digital) {
> /* HDMI 1.3 supports up to 340 Mhz over single link */
> -   if (ASIC_IS_DCE6(rdev) && 
> drm_detect_hdmi_monitor(radeon_connector_edid(connector))) {
> +   if (ASIC_IS_DCE6(rdev) && 
> connector->display_info.is_hdmi) {
> if (pixel_clock > 34)
> return true;
> else
> @@ -408,7 +408,7 @@ bool radeon_dig_monitor_is_duallink(struct drm_encoder 
> *encoder,
> return false;
> else {
> /* HDMI 1.3 supports up to 340 Mhz over single link */
> -   if (ASIC_IS_DCE6(rdev) && 
> drm_detect_hdmi_monitor(radeon_connector_edid(connector))) {
> +   if (ASIC_IS_DCE6(rdev) && 
> connector->display_info.is_hdmi) {
> if (pixel_clock > 34)
> return true;
> else
> --
> 2.39.2
>

Reviewed-by: Robert Foss 


Re: [PATCH 1/2] drm/print: drop include debugfs.h and include where needed

2024-04-25 Thread Robert Foss
On Mon, Apr 22, 2024 at 2:10 PM Jani Nikula  wrote:
>
> Surprisingly many places depend on debugfs.h to be included via
> drm_print.h. Fix them.
>
> v3: Also fix armada, ite-it6505, imagination, msm, sti, vc4, and xe
>
> v2: Also fix ivpu and vmwgfx
>
> Reviewed-by: Andrzej Hajda 
> Acked-by: Maxime Ripard 
> Link: 
> https://patchwork.freedesktop.org/patch/msgid/20240410141434.157908-1-jani.nik...@intel.com
> Signed-off-by: Jani Nikula 
>
> ---
>
> Cc: Jacek Lawrynowicz 
> Cc: Stanislaw Gruszka 
> Cc: Oded Gabbay 
> Cc: Russell King 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Robert Foss 
> Cc: Laurent Pinchart 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 
> Cc: Maarten Lankhorst 
> Cc: Maxime Ripard 
> Cc: Thomas Zimmermann 
> Cc: Jani Nikula 
> Cc: Rodrigo Vivi 
> Cc: Joonas Lahtinen 
> Cc: Tvrtko Ursulin 
> Cc: Frank Binns 
> Cc: Matt Coster 
> Cc: Rob Clark 
> Cc: Abhinav Kumar 
> Cc: Dmitry Baryshkov 
> Cc: Sean Paul 
> Cc: Marijn Suijten 
> Cc: Karol Herbst 
> Cc: Lyude Paul 
> Cc: Danilo Krummrich 
> Cc: Alex Deucher 
> Cc: "Christian König" 
> Cc: "Pan, Xinhui" 
> Cc: Alain Volmat 
> Cc: Huang Rui 
> Cc: Zack Rusin 
> Cc: Broadcom internal kernel review list 
> 
> Cc: Lucas De Marchi 
> Cc: "Thomas Hellström" 
> Cc: dri-de...@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org
> Cc: intel...@lists.freedesktop.org
> Cc: linux-arm-...@vger.kernel.org
> Cc: freedr...@lists.freedesktop.org
> Cc: nouv...@lists.freedesktop.org
> Cc: amd-...@lists.freedesktop.org
> ---
>  drivers/accel/ivpu/ivpu_debugfs.c   | 2 ++
>  drivers/gpu/drm/armada/armada_debugfs.c | 1 +
>  drivers/gpu/drm/bridge/ite-it6505.c | 1 +
>  drivers/gpu/drm/bridge/panel.c  | 2 ++
>  drivers/gpu/drm/drm_print.c | 6 +++---
>  drivers/gpu/drm/i915/display/intel_dmc.c| 1 +
>  drivers/gpu/drm/imagination/pvr_fw_trace.c  | 1 +
>  drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.c | 2 ++
>  drivers/gpu/drm/nouveau/dispnv50/crc.c  | 2 ++
>  drivers/gpu/drm/radeon/r100.c   | 1 +
>  drivers/gpu/drm/radeon/r300.c   | 1 +
>  drivers/gpu/drm/radeon/r420.c   | 1 +
>  drivers/gpu/drm/radeon/r600.c   | 3 ++-
>  drivers/gpu/drm/radeon/radeon_fence.c   | 1 +
>  drivers/gpu/drm/radeon/radeon_gem.c | 1 +
>  drivers/gpu/drm/radeon/radeon_ib.c  | 2 ++
>  drivers/gpu/drm/radeon/radeon_pm.c  | 1 +
>  drivers/gpu/drm/radeon/radeon_ring.c| 2 ++
>  drivers/gpu/drm/radeon/radeon_ttm.c | 1 +
>  drivers/gpu/drm/radeon/rs400.c  | 1 +
>  drivers/gpu/drm/radeon/rv515.c  | 1 +
>  drivers/gpu/drm/sti/sti_drv.c   | 1 +
>  drivers/gpu/drm/ttm/ttm_device.c| 1 +
>  drivers/gpu/drm/ttm/ttm_resource.c  | 3 ++-
>  drivers/gpu/drm/ttm/ttm_tt.c| 5 +++--
>  drivers/gpu/drm/vc4/vc4_drv.h   | 1 +
>  drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 2 ++
>  drivers/gpu/drm/xe/xe_debugfs.c | 1 +
>  drivers/gpu/drm/xe/xe_gt_debugfs.c  | 2 ++
>  drivers/gpu/drm/xe/xe_uc_debugfs.c  | 2 ++
>  include/drm/drm_print.h | 2 +-
>  31 files changed, 46 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/accel/ivpu/ivpu_debugfs.c 
> b/drivers/accel/ivpu/ivpu_debugfs.c
> index d09d29775b3f..e07e447d08d1 100644
> --- a/drivers/accel/ivpu/ivpu_debugfs.c
> +++ b/drivers/accel/ivpu/ivpu_debugfs.c
> @@ -3,6 +3,8 @@
>   * Copyright (C) 2020-2023 Intel Corporation
>   */
>
> +#include 
> +
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/gpu/drm/armada/armada_debugfs.c 
> b/drivers/gpu/drm/armada/armada_debugfs.c
> index 29f4b52e3c8d..a763349dd89f 100644
> --- a/drivers/gpu/drm/armada/armada_debugfs.c
> +++ b/drivers/gpu/drm/armada/armada_debugfs.c
> @@ -5,6 +5,7 @@
>   */
>
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c 
> b/drivers/gpu/drm/bridge/ite-it6505.c
> index 27334173e911..3f68c82888c2 100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> @@ -3,6 +3,7 @@
>   * Copyright (c) 2020, The Linux Foundation. All rights reserved.
>   */
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c
> index 7f41525f7a6e..32506524d9a2 100644
> --- a/drivers/gpu/drm/bridge/panel.c
> +++ b/drivers/gpu/drm/bridge/panel.c
> @@ -4,6 +4,8 @@

Re: [PATCH v2 1/2] drm/print: drop include debugfs.h and include where needed

2024-04-18 Thread Robert Foss
Hey Jani,

Thanks for doing this cleanup.

On Thu, Apr 18, 2024 at 12:13 PM Jani Nikula  wrote:
>
> Surprisingly many places depend on debugfs.h to be included via
> drm_print.h. Fix them.
>
> v2: Also fix ivpu and vmwgfx
>
> Reviewed-by: Andrzej Hajda 
> Acked-by: Maxime Ripard 
> Link: 
> https://patchwork.freedesktop.org/patch/msgid/20240410141434.157908-1-jani.nik...@intel.com
> Signed-off-by: Jani Nikula 
>
> ---
>
> Cc: Jacek Lawrynowicz 
> Cc: Stanislaw Gruszka 
> Cc: Oded Gabbay 
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Robert Foss 
> Cc: Laurent Pinchart 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 
> Cc: Maarten Lankhorst 
> Cc: Maxime Ripard 
> Cc: Thomas Zimmermann 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: Jani Nikula 
> Cc: Rodrigo Vivi 
> Cc: Joonas Lahtinen 
> Cc: Tvrtko Ursulin 
> Cc: Karol Herbst 
> Cc: Lyude Paul 
> Cc: Danilo Krummrich 
> Cc: Alex Deucher 
> Cc: "Christian König" 
> Cc: "Pan, Xinhui" 
> Cc: Huang Rui 
> Cc: Zack Rusin 
> Cc: Broadcom internal kernel review list 
> 
> Cc: dri-de...@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org
> Cc: intel...@lists.freedesktop.org
> Cc: nouv...@lists.freedesktop.org
> Cc: amd-...@lists.freedesktop.org
> ---
>  drivers/accel/ivpu/ivpu_debugfs.c| 2 ++
>  drivers/gpu/drm/bridge/panel.c   | 2 ++
>  drivers/gpu/drm/drm_print.c  | 6 +++---
>  drivers/gpu/drm/i915/display/intel_dmc.c | 1 +
>  drivers/gpu/drm/nouveau/dispnv50/crc.c   | 2 ++
>  drivers/gpu/drm/radeon/r100.c| 1 +
>  drivers/gpu/drm/radeon/r300.c| 1 +
>  drivers/gpu/drm/radeon/r420.c| 1 +
>  drivers/gpu/drm/radeon/r600.c| 3 ++-
>  drivers/gpu/drm/radeon/radeon_fence.c| 1 +
>  drivers/gpu/drm/radeon/radeon_gem.c  | 1 +
>  drivers/gpu/drm/radeon/radeon_ib.c   | 2 ++
>  drivers/gpu/drm/radeon/radeon_pm.c   | 1 +
>  drivers/gpu/drm/radeon/radeon_ring.c | 2 ++
>  drivers/gpu/drm/radeon/radeon_ttm.c  | 1 +
>  drivers/gpu/drm/radeon/rs400.c   | 1 +
>  drivers/gpu/drm/radeon/rv515.c   | 1 +
>  drivers/gpu/drm/ttm/ttm_device.c | 1 +
>  drivers/gpu/drm/ttm/ttm_resource.c   | 3 ++-
>  drivers/gpu/drm/ttm/ttm_tt.c | 5 +++--
>  drivers/gpu/drm/vmwgfx/vmwgfx_gem.c  | 2 ++
>  include/drm/drm_print.h  | 2 +-
>  22 files changed, 34 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/accel/ivpu/ivpu_debugfs.c 
> b/drivers/accel/ivpu/ivpu_debugfs.c
> index d09d29775b3f..e07e447d08d1 100644
> --- a/drivers/accel/ivpu/ivpu_debugfs.c
> +++ b/drivers/accel/ivpu/ivpu_debugfs.c
> @@ -3,6 +3,8 @@
>   * Copyright (C) 2020-2023 Intel Corporation
>   */
>
> +#include 
> +
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c
> index 7f41525f7a6e..32506524d9a2 100644
> --- a/drivers/gpu/drm/bridge/panel.c
> +++ b/drivers/gpu/drm/bridge/panel.c
> @@ -4,6 +4,8 @@
>   * Copyright (C) 2017 Broadcom
>   */
>
> +#include 
> +
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
> index 699b7dbffd7b..cf2efb44722c 100644
> --- a/drivers/gpu/drm/drm_print.c
> +++ b/drivers/gpu/drm/drm_print.c
> @@ -23,13 +23,13 @@
>   * Rob Clark 
>   */
>
> -#include 
> -
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>
>  #include 
>  #include 
> diff --git a/drivers/gpu/drm/i915/display/intel_dmc.c 
> b/drivers/gpu/drm/i915/display/intel_dmc.c
> index a34ff3383fd3..370d61c7e342 100644
> --- a/drivers/gpu/drm/i915/display/intel_dmc.c
> +++ b/drivers/gpu/drm/i915/display/intel_dmc.c
> @@ -22,6 +22,7 @@
>   *
>   */
>
> +#include 
>  #include 
>
>  #include "i915_drv.h"
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c 
> b/drivers/gpu/drm/nouveau/dispnv50/crc.c
> index 9c942fbd836d..5936b6b3b15d 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/crc.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c
> @@ -1,5 +1,7 @@
>  // SPDX-License-Identifier: MIT
> +#include 
>  #include 
> +
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
> index 86b8b770af19..0b1e19345f43 100644
> --- a/drivers/gpu/drm/radeon/r100.c
> +++ b/drivers/gpu/drm/radeon/r100.c
> @@ -26,6 +26,7 @@
>   *  Jerome Glisse
>   */
>
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/gpu/drm/radeon/r30

Re: [Intel-gfx] [PATCH v2 19/20] drm/dp_mst: Drop DRM_ERROR() on kzalloc() fail in drm_dp_mst_handle_up_req()

2021-03-31 Thread Robert Foss
Hey Lyude,

This patch looks good to me.

Reviewed-by: Robert Foss 

On Fri, 26 Mar 2021 at 21:40, Lyude Paul  wrote:
>
> Checkpatch was complaining about this - there's no need for us to print
> errors when kzalloc() fails, as kzalloc() will already WARN for us. So,
> let's fix that before converting things to make checkpatch happy.
>
> Signed-off-by: Lyude Paul 
> Cc: Robert Foss 
> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
> b/drivers/gpu/drm/drm_dp_mst_topology.c
> index ec2285595c33..74c420f5f204 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -4113,10 +4113,9 @@ static int drm_dp_mst_handle_up_req(struct 
> drm_dp_mst_topology_mgr *mgr)
> return 0;
>
> up_req = kzalloc(sizeof(*up_req), GFP_KERNEL);
> -   if (!up_req) {
> -   DRM_ERROR("Not enough memory to process MST up req\n");
> +   if (!up_req)
> return -ENOMEM;
> -   }
> +
> INIT_LIST_HEAD(_req->next);
>
> drm_dp_sideband_parse_req(>up_req_recv, _req->msg);
> --
> 2.30.2
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v2 07/20] drm/print: Fixup DRM_DEBUG_KMS_RATELIMITED()

2021-03-31 Thread Robert Foss
Hey Lyude,

I'm seeing no issues with this patch and the reasoning behind the
patch is sound to me.

Reviewed-by: Robert Foss 

On Fri, 26 Mar 2021 at 21:39, Lyude Paul  wrote:
>
> Since we're about to move drm_dp_helper.c over to drm_dbg_*(), we'll want
> to make sure that we can also add ratelimited versions of these macros in
> order to retain some of the previous debugging output behavior we had.
>
> However, as I was preparing to do this I noticed that the current
> rate limited macros we have are kind of bogus. It looks like when I wrote
> these, I didn't notice that we'd always be calling __ratelimit() even if
> the debugging message we'd be printing would normally be filtered out due
> to the relevant DRM debugging category being disabled.
>
> So, let's fix this by making sure to check drm_debug_enabled() in our
> ratelimited macros before calling __ratelimit(), and start using
> drm_dev_printk() in order to print debugging messages since that will save
> us from doing a redundant drm_debug_enabled() check. And while we're at it,
> let's move the code for this into another macro that we can reuse for
> defining new ratelimited DRM debug macros more easily.
>
> v2:
> * Make sure to use tabs where possible in __DRM_DEFINE_DBG_RATELIMITED()
>
> Signed-off-by: Lyude Paul 
> Cc: Robert Foss 
> ---
>  include/drm/drm_print.h | 20 
>  1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
> index f32d179e139d..a3c58c941bdc 100644
> --- a/include/drm/drm_print.h
> +++ b/include/drm/drm_print.h
> @@ -524,16 +524,20 @@ void __drm_err(const char *format, ...);
>  #define DRM_DEBUG_DP(fmt, ...) \
> __drm_dbg(DRM_UT_DP, fmt, ## __VA_ARGS__)
>
> -
> -#define DRM_DEBUG_KMS_RATELIMITED(fmt, ...)\
> -({ \
> -   static DEFINE_RATELIMIT_STATE(_rs,  \
> - DEFAULT_RATELIMIT_INTERVAL,   \
> - DEFAULT_RATELIMIT_BURST); \
> -   if (__ratelimit(&_rs))  \
> -   drm_dev_dbg(NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__);  \
> +#define __DRM_DEFINE_DBG_RATELIMITED(category, drm, fmt, ...)
>   \
> +({   
>   \
> +   static DEFINE_RATELIMIT_STATE(rs_, DEFAULT_RATELIMIT_INTERVAL, 
> DEFAULT_RATELIMIT_BURST);\
> +   const struct drm_device *drm_ = (drm);
>   \
> + 
>   \
> +   if (drm_debug_enabled(DRM_UT_ ## category) && __ratelimit(_))  
>   \
> +   drm_dev_printk(drm_ ? drm_->dev : NULL, KERN_DEBUG, fmt, ## 
> __VA_ARGS__);   \
>  })
>
> +#define drm_dbg_kms_ratelimited(drm, fmt, ...) \
> +   __DRM_DEFINE_DBG_RATELIMITED(KMS, drm, fmt, ## __VA_ARGS__)
> +
> +#define DRM_DEBUG_KMS_RATELIMITED(fmt, ...) drm_dbg_kms_ratelimited(NULL, 
> fmt, ## __VA_ARGS__)
> +
>  /*
>   * struct drm_device based WARNs
>   *
> --
> 2.30.2
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v2 20/20] drm/dp_mst: Convert drm_dp_mst_topology.c to drm_err()/drm_dbg*()

2021-03-31 Thread Robert Foss
Hey Lyude,

This patch looks good, but I have one question below. With it
addressed, feel free to add my r-b.

Reviewed-by: Robert Foss 

>
> -static bool drm_dp_sideband_parse_req(struct drm_dp_sideband_msg_rx *raw,
> +static bool drm_dp_sideband_parse_req(const struct drm_dp_mst_topology_mgr 
> *mgr,
> + struct drm_dp_sideband_msg_rx *raw,
>   struct drm_dp_sideband_msg_req_body 
> *msg)
>  {
> memset(msg, 0, sizeof(*msg));
> @@ -1117,12 +1125,12 @@ static bool drm_dp_sideband_parse_req(struct 
> drm_dp_sideband_msg_rx *raw,
>
> switch (msg->req_type) {
> case DP_CONNECTION_STATUS_NOTIFY:
> -   return drm_dp_sideband_parse_connection_status_notify(raw, 
> msg);
> +   return drm_dp_sideband_parse_connection_status_notify(mgr, 
> raw, msg);
> case DP_RESOURCE_STATUS_NOTIFY:
> -   return drm_dp_sideband_parse_resource_status_notify(raw, msg);
> +   return drm_dp_sideband_parse_resource_status_notify(mgr, raw, 
> msg);
> default:
> -   DRM_ERROR("Got unknown request 0x%02x (%s)\n", msg->req_type,
> - drm_dp_mst_req_type_str(msg->req_type));
> +   drm_err(mgr->dev, "Got unknown request 0x%02x (%s)\n",
> +   msg->req_type, 
> drm_dp_mst_req_type_str(msg->req_type));
> return false;
> }
>  }
>

.. snip ..

> @@ -4118,12 +4121,12 @@ static int drm_dp_mst_handle_up_req(struct 
> drm_dp_mst_topology_mgr *mgr)
>
> INIT_LIST_HEAD(_req->next);
>
> -   drm_dp_sideband_parse_req(>up_req_recv, _req->msg);
> +   drm_dp_sideband_parse_req(mgr, >up_req_recv, _req->msg);

drm_dp_sideband_parse_req() is only called here, and the function
arguments could probably stand to have `>up_req_recv` removed
(here and in the func. declaration) since the same data structure is
accessible through the `mgr` pointer inside of
drm_dp_sideband_parse_req(). I guess this is a matter of taste, so
feel free to do what you want with this.

>
> if (up_req->msg.req_type != DP_CONNECTION_STATUS_NOTIFY &&
> up_req->msg.req_type != DP_RESOURCE_STATUS_NOTIFY) {
> -   DRM_DEBUG_KMS("Received unknown up req type, ignoring: %x\n",
> - up_req->msg.req_type);
> +   drm_dbg_kms(mgr->dev, "Received unknown up req type, 
> ignoring: %x\n",
> +   up_req->msg.req_type);
> kfree(up_req);
> goto out;
> }
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v2 17/20] drm/dp: Convert drm_dp_helper.c to using drm_err/drm_dbg_*()

2021-03-31 Thread Robert Foss
Hey Lyude,

Looks good to me.

Reviewed-by: Robert Foss 


On Fri, 26 Mar 2021 at 21:40, Lyude Paul  wrote:
>
> Now that we've added a back-pointer to drm_device to drm_dp_aux, made
> drm_dp_aux available to any functions in drm_dp_helper.c which need to
> print to the kernel log, and ensured all of our logging uses a consistent
> format, let's do the final step of the conversion and actually move
> everything over to using drm_err() and drm_dbg_*().
>
> This was done by using the following cocci script:
>
>   @@
>   expression list expr;
>   @@
>
>   (
>   - DRM_DEBUG_KMS(expr);
>   + drm_dbg_kms(aux->drm_dev, expr);
>   |
>   - DRM_DEBUG_DP(expr);
>   + drm_dbg_dp(aux->drm_dev, expr);
>   |
>   - DRM_DEBUG_ATOMIC(expr);
>   + drm_dbg_atomic(aux->drm_dev, expr);
>   |
>   - DRM_DEBUG_KMS_RATELIMITED(expr);
>   + drm_dbg_kms_ratelimited(aux->drm_dev, expr);
>   |
>   - DRM_ERROR(expr);
>   + drm_err(aux->drm_dev, expr);
>   )
>
> Followed by correcting the resulting line-wrapping in the results by hand.
>
> v2:
> * Fix indenting in drm_dp_dump_access
>
> Signed-off-by: Lyude Paul 
> Cc: Robert Foss 
> ---
>  drivers/gpu/drm/drm_dp_helper.c | 121 
>  1 file changed, 59 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index 54e19d7b9c51..4940db0bcaae 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -139,8 +139,8 @@ void drm_dp_link_train_clock_recovery_delay(const struct 
> drm_dp_aux *aux,
>  DP_TRAINING_AUX_RD_MASK;
>
> if (rd_interval > 4)
> -   DRM_DEBUG_KMS("%s: AUX interval %lu, out of range (max 4)\n",
> - aux->name, rd_interval);
> +   drm_dbg_kms(aux->drm_dev, "%s: AUX interval %lu, out of range 
> (max 4)\n",
> +   aux->name, rd_interval);
>
> if (rd_interval == 0 || dpcd[DP_DPCD_REV] >= DP_DPCD_REV_14)
> rd_interval = 100;
> @@ -155,8 +155,8 @@ static void __drm_dp_link_train_channel_eq_delay(const 
> struct drm_dp_aux *aux,
>  unsigned long rd_interval)
>  {
> if (rd_interval > 4)
> -   DRM_DEBUG_KMS("%s: AUX interval %lu, out of range (max 4)\n",
> - aux->name, rd_interval);
> +   drm_dbg_kms(aux->drm_dev, "%s: AUX interval %lu, out of range 
> (max 4)\n",
> +   aux->name, rd_interval);
>
> if (rd_interval == 0)
> rd_interval = 400;
> @@ -220,11 +220,11 @@ drm_dp_dump_access(const struct drm_dp_aux *aux,
> const char *arrow = request == DP_AUX_NATIVE_READ ? "->" : "<-";
>
> if (ret > 0)
> -   DRM_DEBUG_DP("%s: 0x%05x AUX %s (ret=%3d) %*ph\n",
> -aux->name, offset, arrow, ret, min(ret, 20), 
> buffer);
> +   drm_dbg_dp(aux->drm_dev, "%s: 0x%05x AUX %s (ret=%3d) %*ph\n",
> +  aux->name, offset, arrow, ret, min(ret, 20), 
> buffer);
> else
> -   DRM_DEBUG_DP("%s: 0x%05x AUX %s (ret=%3d)\n",
> -aux->name, offset, arrow, ret);
> +   drm_dbg_dp(aux->drm_dev, "%s: 0x%05x AUX %s (ret=%3d)\n",
> +  aux->name, offset, arrow, ret);
>  }
>
>  /**
> @@ -287,8 +287,8 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 
> request,
> err = ret;
> }
>
> -   DRM_DEBUG_KMS("%s: Too many retries, giving up. First error: %d\n",
> - aux->name, err);
> +   drm_dbg_kms(aux->drm_dev, "%s: Too many retries, giving up. First 
> error: %d\n",
> +   aux->name, err);
> ret = err;
>
>  unlock:
> @@ -524,44 +524,44 @@ bool drm_dp_send_real_edid_checksum(struct drm_dp_aux 
> *aux,
>
> if (drm_dp_dpcd_read(aux, DP_DEVICE_SERVICE_IRQ_VECTOR,
>  _test_req, 1) < 1) {
> -   DRM_ERROR("%s: DPCD failed read at register 0x%x\n",
> - aux->name, DP_DEVICE_SERVICE_IRQ_VECTOR);
> +   drm_err(aux->drm_dev, "%s: DPCD failed read at register 
> 0x%x\n",
> +   aux->name, DP_DEVICE_SERVICE_IRQ_VECTOR);
> return false;
> }
> auto_test_req &a

Re: [Intel-gfx] [PATCH 13/30] drm/bridge/analogix/dp_core: Unregister DP AUX channel on error in analogix_dp_probe()

2021-03-22 Thread Robert Foss
Hey Lyude,

Thanks for the patch, it looks good to me.

Reviewed-by: Robert Foss 

On Fri, 19 Feb 2021 at 22:58, Lyude Paul  wrote:
>
> Just another drive-by fix I noticed while going through the tree to cleanup
> DP aux adapter registration - make sure we unregister the DP AUX dev if
> analogix_dp_probe() fails.
>
> Signed-off-by: Lyude Paul 
> ---
>  drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c 
> b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index aa1bb86293fd..f115233b1cb9 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -1782,6 +1782,7 @@ int analogix_dp_bind(struct analogix_dp_device *dp, 
> struct drm_device *drm_dev)
>
>  err_disable_pm_runtime:
> pm_runtime_disable(dp->dev);
> +   drm_dp_aux_unregister(>aux);
>
> return ret;
>  }
> --
> 2.29.2
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 07/30] drm/bridge/analogix/anx78xx: Add missing drm_dp_aux_unregister() call

2021-03-22 Thread Robert Foss
Hey Lyude,

Thanks for the patch, it looks good to me.

Reviewed-by: Robert Foss 

On Fri, 19 Feb 2021 at 22:56, Lyude Paul  wrote:
>
> Surprisingly, this bridge actually registers it's AUX adapter at the
> correct time already. Nice job! However, it does forget to actually
> unregister the AUX adapter, so let's add a bridge function to handle that.
>
> Signed-off-by: Lyude Paul 
> ---
>  drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c 
> b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> index 81debd02c169..ec4607dc01eb 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> @@ -942,6 +942,11 @@ static int anx78xx_bridge_attach(struct drm_bridge 
> *bridge,
> return 0;
>  }
>
> +static void anx78xx_bridge_detach(struct drm_bridge *bridge)
> +{
> +   drm_dp_aux_unregister(_to_anx78xx(bridge)->aux);
> +}
> +
>  static enum drm_mode_status
>  anx78xx_bridge_mode_valid(struct drm_bridge *bridge,
>   const struct drm_display_info *info,
> @@ -1013,6 +1018,7 @@ static void anx78xx_bridge_enable(struct drm_bridge 
> *bridge)
>
>  static const struct drm_bridge_funcs anx78xx_bridge_funcs = {
> .attach = anx78xx_bridge_attach,
> +   .detach = anx78xx_bridge_detach,
> .mode_valid = anx78xx_bridge_mode_valid,
> .disable = anx78xx_bridge_disable,
> .mode_set = anx78xx_bridge_mode_set,
> --
> 2.29.2
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 30/30] drm/dp_mst: Convert drm_dp_mst_topology.c to drm_err()/drm_dbg*()

2021-03-22 Thread Robert Foss
Hey Lyude,

Thanks for the patch

On Fri, 19 Feb 2021 at 23:03, Lyude Paul  wrote:
>
> And finally, convert all of the code in drm_dp_mst_topology.c over to using
> drm_err() and drm_dbg*(). Note that this refactor would have been a lot
> more complicated to have tried writing a coccinelle script for, so this
> whole thing was done by hand.
>
> Signed-off-by: Lyude Paul 
> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 369 +-
>  1 file changed, 187 insertions(+), 182 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
> b/drivers/gpu/drm/drm_dp_mst_topology.c
> index fb66df39e0bb..f66232954689 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -286,7 +286,8 @@ static void drm_dp_encode_sideband_msg_hdr(struct 
> drm_dp_sideband_msg_hdr *hdr,
> *len = idx;
>  }
>
> -static bool drm_dp_decode_sideband_msg_hdr(struct drm_dp_sideband_msg_hdr 
> *hdr,
> +static bool drm_dp_decode_sideband_msg_hdr(const struct 
> drm_dp_mst_topology_mgr *mgr,
> +  struct drm_dp_sideband_msg_hdr 
> *hdr,
>u8 *buf, int buflen, u8 *hdrlen)
>  {
> u8 crc4;
> @@ -303,7 +304,7 @@ static bool drm_dp_decode_sideband_msg_hdr(struct 
> drm_dp_sideband_msg_hdr *hdr,
> crc4 = drm_dp_msg_header_crc4(buf, (len * 2) - 1);
>
> if ((crc4 & 0xf) != (buf[len - 1] & 0xf)) {
> -   DRM_DEBUG_KMS("crc4 mismatch 0x%x 0x%x\n", crc4, buf[len - 
> 1]);
> +   drm_dbg_kms(mgr->dev, "crc4 mismatch 0x%x 0x%x\n", crc4, 
> buf[len - 1]);
> return false;
> }
>
> @@ -789,7 +790,8 @@ static bool drm_dp_sideband_append_payload(struct 
> drm_dp_sideband_msg_rx *msg,
> return true;
>  }
>
> -static bool drm_dp_sideband_parse_link_address(struct drm_dp_sideband_msg_rx 
> *raw,
> +static bool drm_dp_sideband_parse_link_address(const struct 
> drm_dp_mst_topology_mgr *mgr,
> +  struct drm_dp_sideband_msg_rx 
> *raw,
>struct 
> drm_dp_sideband_msg_reply_body *repmsg)
>  {
> int idx = 1;
> @@ -1014,7 +1016,8 @@ drm_dp_sideband_parse_query_stream_enc_status(
> return true;
>  }
>
> -static bool drm_dp_sideband_parse_reply(struct drm_dp_sideband_msg_rx *raw,
> +static bool drm_dp_sideband_parse_reply(const struct drm_dp_mst_topology_mgr 
> *mgr,
> +   struct drm_dp_sideband_msg_rx *raw,
> struct drm_dp_sideband_msg_reply_body 
> *msg)
>  {
> memset(msg, 0, sizeof(*msg));
> @@ -1030,7 +1033,7 @@ static bool drm_dp_sideband_parse_reply(struct 
> drm_dp_sideband_msg_rx *raw,
>
> switch (msg->req_type) {
> case DP_LINK_ADDRESS:
> -   return drm_dp_sideband_parse_link_address(raw, msg);
> +   return drm_dp_sideband_parse_link_address(mgr, raw, msg);
> case DP_QUERY_PAYLOAD:
> return drm_dp_sideband_parse_query_payload_ack(raw, msg);
> case DP_REMOTE_DPCD_READ:
> @@ -1053,14 +1056,16 @@ static bool drm_dp_sideband_parse_reply(struct 
> drm_dp_sideband_msg_rx *raw,
> case DP_QUERY_STREAM_ENC_STATUS:
> return drm_dp_sideband_parse_query_stream_enc_status(raw, 
> msg);
> default:
> -   DRM_ERROR("Got unknown reply 0x%02x (%s)\n", msg->req_type,
> - drm_dp_mst_req_type_str(msg->req_type));
> +   drm_err(mgr->dev, "Got unknown reply 0x%02x (%s)\n",
> +   msg->req_type, 
> drm_dp_mst_req_type_str(msg->req_type));
> return false;
> }
>  }
>
> -static bool drm_dp_sideband_parse_connection_status_notify(struct 
> drm_dp_sideband_msg_rx *raw,
> -  struct 
> drm_dp_sideband_msg_req_body *msg)
> +static bool
> +drm_dp_sideband_parse_connection_status_notify(const struct 
> drm_dp_mst_topology_mgr *mgr,
> +  struct drm_dp_sideband_msg_rx 
> *raw,
> +  struct 
> drm_dp_sideband_msg_req_body *msg)
>  {
> int idx = 1;
>
> @@ -1082,12 +1087,14 @@ static bool 
> drm_dp_sideband_parse_connection_status_notify(struct drm_dp_sideban
> idx++;
> return true;
>  fail_len:
> -   DRM_DEBUG_KMS("connection status reply parse length fail %d %d\n", 
> idx, raw->curlen);
> +   drm_dbg_kms(mgr->dev, "connection status reply parse length fail %d 
> %d\n",
> +   idx, raw->curlen);
> return false;
>  }
>
> -static bool drm_dp_sideband_parse_resource_status_notify(struct 
> drm_dp_sideband_msg_rx *raw,
> -  struct 
> drm_dp_sideband_msg_req_body *msg)
> +static bool drm_dp_sideband_parse_resource_status_notify(const 

Re: [Intel-gfx] [PATCH 10/30] drm/bridge/analogix/anx6345: Add missing drm_dp_aux_unregister() call

2021-03-22 Thread Robert Foss
Hey Lyude,

Thanks for the patch, it looks good to me.

Reviewed-by: Robert Foss 

On Fri, 19 Feb 2021 at 22:58, Lyude Paul  wrote:
>
> Another driver I found that seems to forget to unregister it's DP AUX
> device. Let's fix this by adding anx6345_bridge_detach().
>
> Signed-off-by: Lyude Paul 
> ---
>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c 
> b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> index d9164fab044d..8e016ba7c54a 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> @@ -574,6 +574,11 @@ static int anx6345_bridge_attach(struct drm_bridge 
> *bridge,
> return 0;
>  }
>
> +static void anx6345_bridge_detach(struct drm_bridge *bridge)
> +{
> +   drm_dp_aux_unregister(_to_anx6345(bridge)->aux);
> +}
> +
>  static enum drm_mode_status
>  anx6345_bridge_mode_valid(struct drm_bridge *bridge,
>   const struct drm_display_info *info,
> @@ -624,6 +629,7 @@ static void anx6345_bridge_enable(struct drm_bridge 
> *bridge)
>
>  static const struct drm_bridge_funcs anx6345_bridge_funcs = {
> .attach = anx6345_bridge_attach,
> +   .detach = anx6345_bridge_detach,
> .mode_valid = anx6345_bridge_mode_valid,
> .disable = anx6345_bridge_disable,
> .enable = anx6345_bridge_enable,
> --
> 2.29.2
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 18/30] drm/print: Fixup DRM_DEBUG_KMS_RATELIMITED()

2021-03-22 Thread Robert Foss
Hey Lyude,

Thanks for the patch,

On Fri, 19 Feb 2021 at 22:59, Lyude Paul  wrote:
>
> Since we're about to move drm_dp_helper.c over to drm_dbg_*(), we'll want
> to make sure that we can also add ratelimited versions of these macros in
> order to retain some of the previous debugging output behavior we had.
>
> However, as I was preparing to do this I noticed that the current
> rate limited macros we have are kind of bogus. It looks like when I wrote
> these, I didn't notice that we'd always be calling __ratelimit() even if
> the debugging message we'd be printing would normally be filtered out due
> to the relevant DRM debugging category being disabled.
>
> So, let's fix this by making sure to check drm_debug_enabled() in our
> ratelimited macros before calling __ratelimit(), and start using
> drm_dev_printk() in order to print debugging messages since that will save
> us from doing a redundant drm_debug_enabled() check. And while we're at it,
> let's move the code for this into another macro that we can reuse for
> defining new ratelimited DRM debug macros more easily.
>
> Signed-off-by: Lyude Paul 
> ---
>  include/drm/drm_print.h | 20 
>  1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
> index f32d179e139d..3a0c3fe4d292 100644
> --- a/include/drm/drm_print.h
> +++ b/include/drm/drm_print.h
> @@ -524,16 +524,20 @@ void __drm_err(const char *format, ...);
>  #define DRM_DEBUG_DP(fmt, ...) \
> __drm_dbg(DRM_UT_DP, fmt, ## __VA_ARGS__)
>
> -
> -#define DRM_DEBUG_KMS_RATELIMITED(fmt, ...)\
> -({ \
> -   static DEFINE_RATELIMIT_STATE(_rs,  \
> - DEFAULT_RATELIMIT_INTERVAL,   \
> - DEFAULT_RATELIMIT_BURST); \
> -   if (__ratelimit(&_rs))  \
> -   drm_dev_dbg(NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__);  \
> +#define __DRM_DEFINE_DBG_RATELIMITED(category, drm, fmt, ...)
> \
> +({   
> \
> +   static DEFINE_RATELIMIT_STATE(rs_, DEFAULT_RATELIMIT_INTERVAL, 
> DEFAULT_RATELIMIT_BURST); \
> +   const struct drm_device *drm_ = (drm);
>\
> + 
> \
> +   if (drm_debug_enabled(DRM_UT_ ## category) && __ratelimit(_))  
>\
> +   drm_dev_printk(drm_ ? drm_->dev : NULL, KERN_DEBUG, fmt, ## 
> __VA_ARGS__);\
>  })

checkpatch --strict is unhappy about the tabs/spaces in this patch


ERROR: code indent should use tabs where possible
#48: FILE: include/drm/drm_print.h:531:
+
   \$

WARNING: please, no spaces at the start of a line
#48: FILE: include/drm/drm_print.h:531:
+
   \$


>
> +#define drm_dbg_kms_ratelimited(drm, fmt, ...) \
> +   __DRM_DEFINE_DBG_RATELIMITED(KMS, drm, fmt, ## __VA_ARGS__)
> +
> +#define DRM_DEBUG_KMS_RATELIMITED(fmt, ...) drm_dbg_kms_ratelimited(NULL, 
> fmt, ## __VA_ARGS__)
> +
>  /*
>   * struct drm_device based WARNs
>   *
> --
> 2.29.2
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 09/30] drm/bridge/analogix/anx78xx: Cleanup on error in anx78xx_bridge_attach()

2021-03-22 Thread Robert Foss
Hey Lyude,

Thanks for the patch, it looks good to me.

Reviewed-by: Robert Foss 

On Fri, 19 Feb 2021 at 22:56, Lyude Paul  wrote:
>
> Just another issue I noticed while correcting usages of
> drm_dp_aux_init()/drm_dp_aux_register() around the tree. If any of the
> steps in anx78xx_bridge_attach() fail, we end up leaking resources. So,
> let's fix that (and fix leaking a DP AUX adapter in the process) by
> unrolling on errors.
>
> Signed-off-by: Lyude Paul 
> ---
>  drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c 
> b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> index 338dd8531d4b..f20558618220 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> @@ -918,7 +918,7 @@ static int anx78xx_bridge_attach(struct drm_bridge 
> *bridge,
>  DRM_MODE_CONNECTOR_DisplayPort);
> if (err) {
> DRM_ERROR("Failed to initialize connector: %d\n", err);
> -   return err;
> +   goto aux_unregister;
> }
>
> drm_connector_helper_add(>connector,
> @@ -930,16 +930,21 @@ static int anx78xx_bridge_attach(struct drm_bridge 
> *bridge,
>bridge->encoder);
> if (err) {
> DRM_ERROR("Failed to link up connector to encoder: %d\n", 
> err);
> -   return err;
> +   goto connector_cleanup;
> }
>
> err = drm_connector_register(>connector);
> if (err) {
> DRM_ERROR("Failed to register connector: %d\n", err);
> -   return err;
> +   goto connector_cleanup;
> }
>
> return 0;
> +connector_cleanup:
> +   drm_connector_cleanup(>connector);
> +aux_unregister:
> +   drm_dp_aux_unregister(>aux);
> +   return err;
>  }
>
>  static void anx78xx_bridge_detach(struct drm_bridge *bridge)
> --
> 2.29.2
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 11/30] drm/bridge/analogix/anx6345: Don't link encoder until after connector registration

2021-03-22 Thread Robert Foss
Hey Lyude,

Thanks for the patch, it looks good to me.

Reviewed-by: Robert Foss 

On Fri, 19 Feb 2021 at 22:58, Lyude Paul  wrote:
>
> Another case of linking an encoder to a connector after the connector's
> been registered. The proper place to do this is before connector
> registration, so let's fix that.
>
> Signed-off-by: Lyude Paul 
> ---
>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c 
> b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> index 8e016ba7c54a..6258f16da0e8 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> @@ -556,12 +556,6 @@ static int anx6345_bridge_attach(struct drm_bridge 
> *bridge,
> drm_connector_helper_add(>connector,
>  _connector_helper_funcs);
>
> -   err = drm_connector_register(>connector);
> -   if (err) {
> -   DRM_ERROR("Failed to register connector: %d\n", err);
> -   return err;
> -   }
> -
> anx6345->connector.polled = DRM_CONNECTOR_POLL_HPD;
>
> err = drm_connector_attach_encoder(>connector,
> @@ -571,6 +565,12 @@ static int anx6345_bridge_attach(struct drm_bridge 
> *bridge,
> return err;
> }
>
> +   err = drm_connector_register(>connector);
> +   if (err) {
> +   DRM_ERROR("Failed to register connector: %d\n", err);
> +   return err;
> +   }
> +
> return 0;
>  }
>
> --
> 2.29.2
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 08/30] drm/bridge/analogix/anx78xx: Setup encoder before registering connector

2021-03-22 Thread Robert Foss
Hey Lyude,

Thanks for the patch, it looks good to me.

Reviewed-by: Robert Foss 

On Fri, 19 Feb 2021 at 22:56, Lyude Paul  wrote:
>
> Since encoder mappings for connectors are exposed to userspace, we should
> be attaching the encoder before exposing the connector to userspace. Just a
> drive-by fix for an issue I noticed while fixing up usages of
> drm_dp_aux_init()/drm_dp_aux_register() across the tree.
>
> Signed-off-by: Lyude Paul 
> ---
>  drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c 
> b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> index ec4607dc01eb..338dd8531d4b 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> @@ -924,12 +924,6 @@ static int anx78xx_bridge_attach(struct drm_bridge 
> *bridge,
> drm_connector_helper_add(>connector,
>  _connector_helper_funcs);
>
> -   err = drm_connector_register(>connector);
> -   if (err) {
> -   DRM_ERROR("Failed to register connector: %d\n", err);
> -   return err;
> -   }
> -
> anx78xx->connector.polled = DRM_CONNECTOR_POLL_HPD;
>
> err = drm_connector_attach_encoder(>connector,
> @@ -939,6 +933,12 @@ static int anx78xx_bridge_attach(struct drm_bridge 
> *bridge,
> return err;
> }
>
> +   err = drm_connector_register(>connector);
> +   if (err) {
> +   DRM_ERROR("Failed to register connector: %d\n", err);
> +   return err;
> +   }
> +
> return 0;
>  }
>
> --
> 2.29.2
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 28/30] drm/dp: Convert drm_dp_helper.c to using drm_err/drm_dbg_*()

2021-03-22 Thread Robert Foss
Hey Lyude,

Thanks for the patch.

On Fri, 19 Feb 2021 at 23:03, Lyude Paul  wrote:
>
> Now that we've added a back-pointer to drm_device to drm_dp_aux, made
> drm_dp_aux available to any functions in drm_dp_helper.c which need to
> print to the kernel log, and ensured all of our logging uses a consistent
> format, let's do the final step of the conversion and actually move
> everything over to using drm_err() and drm_dbg_*().
>
> This was done by using the following cocci script:
>
>   @@
>   expression list expr;
>   @@
>
>   (
>   - DRM_DEBUG_KMS(expr);
>   + drm_dbg_kms(aux->drm_dev, expr);
>   |
>   - DRM_DEBUG_DP(expr);
>   + drm_dbg_dp(aux->drm_dev, expr);
>   |
>   - DRM_DEBUG_ATOMIC(expr);
>   + drm_dbg_atomic(aux->drm_dev, expr);
>   |
>   - DRM_DEBUG_KMS_RATELIMITED(expr);
>   + drm_dbg_kms_ratelimited(aux->drm_dev, expr);
>   |
>   - DRM_ERROR(expr);
>   + drm_err(aux->drm_dev, expr);
>   )
>
> Followed by correcting the resulting line-wrapping in the results by hand.
>
> Signed-off-by: Lyude Paul 
> ---
>  drivers/gpu/drm/drm_dp_helper.c | 122 
>  1 file changed, 60 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index b5e2671baf22..0a787ddf39fd 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -139,8 +139,8 @@ void drm_dp_link_train_clock_recovery_delay(const struct 
> drm_dp_aux *aux,
>  DP_TRAINING_AUX_RD_MASK;
>
> if (rd_interval > 4)
> -   DRM_DEBUG_KMS("%s: AUX interval %lu, out of range (max 4)\n",
> - aux->name, rd_interval);
> +   drm_dbg_kms(aux->drm_dev, "%s: AUX interval %lu, out of range 
> (max 4)\n",
> +   aux->name, rd_interval);
>
> if (rd_interval == 0 || dpcd[DP_DPCD_REV] >= DP_DPCD_REV_14)
> rd_interval = 100;
> @@ -155,8 +155,8 @@ static void __drm_dp_link_train_channel_eq_delay(const 
> struct drm_dp_aux *aux,
>  unsigned long rd_interval)
>  {
> if (rd_interval > 4)
> -   DRM_DEBUG_KMS("%s: AUX interval %lu, out of range (max 4)\n",
> - aux->name, rd_interval);
> +   drm_dbg_kms(aux->drm_dev, "%s: AUX interval %lu, out of range 
> (max 4)\n",
> +   aux->name, rd_interval);
>
> if (rd_interval == 0)
> rd_interval = 400;
> @@ -220,11 +220,12 @@ drm_dp_dump_access(const struct drm_dp_aux *aux,
> const char *arrow = request == DP_AUX_NATIVE_READ ? "->" : "<-";
>
> if (ret > 0)
> -   DRM_DEBUG_DP("%s: 0x%05x AUX %s (ret=%3d) %*ph\n",
> -aux->name, offset, arrow, ret, min(ret, 20), 
> buffer);
> +   drm_dbg_dp(aux->drm_dev, "%s: 0x%05x AUX %s (ret=%3d) %*ph\n",
> +  aux->name, offset, arrow, ret, min(ret, 20),
> +  buffer);

checkpatch --strict is unhappy with this chunk

ERROR: code indent should use tabs where possible
#75: FILE: drivers/gpu/drm/drm_dp_helper.c:224:
+^I^I   aux->name, offset, arrow, ret, min(ret, 20),$

ERROR: code indent should use tabs where possible
#76: FILE: drivers/gpu/drm/drm_dp_helper.c:225:


> else
> -   DRM_DEBUG_DP("%s: 0x%05x AUX %s (ret=%3d)\n",
> -aux->name, offset, arrow, ret);
> +   drm_dbg_dp(aux->drm_dev, "%s: 0x%05x AUX %s (ret=%3d)\n",
> +  aux->name, offset, arrow, ret);

checkpatch --strict is unhappy with this chunk

ERROR: code indent should use tabs where possible
#81: FILE: drivers/gpu/drm/drm_dp_helper.c:228:
+^I^I   aux->name, offset, arrow, ret);$


>  }
>
>  /**
> @@ -287,8 +288,8 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 
> request,
> err = ret;
> }
>
> -   DRM_DEBUG_KMS("%s: Too many retries, giving up. First error: %d\n",
> - aux->name, err);
> +   drm_dbg_kms(aux->drm_dev, "%s: Too many retries, giving up. First 
> error: %d\n",
> +   aux->name, err);
> ret = err;
>
>  unlock:
> @@ -524,44 +525,44 @@ bool drm_dp_send_real_edid_checksum(struct drm_dp_aux 
> *aux,
>
> if (drm_dp_dpcd_read(aux, DP_DEVICE_SERVICE_IRQ_VECTOR,
>  _test_req, 1) < 1) {
> -   DRM_ERROR("%s: DPCD failed read at register 0x%x\n",
> - aux->name, DP_DEVICE_SERVICE_IRQ_VECTOR);
> +   drm_err(aux->drm_dev, "%s: DPCD failed read at register 
> 0x%x\n",
> +   aux->name, DP_DEVICE_SERVICE_IRQ_VECTOR);
> return false;
> }
> auto_test_req &= DP_AUTOMATED_TEST_REQUEST;
>
> if (drm_dp_dpcd_read(aux, DP_TEST_REQUEST, _edid_read, 1) < 1) {
> -   DRM_ERROR("%s: 

Re: [Intel-gfx] [PATCH 04/30] drm/bridge/tc358767: Don't register DP AUX channel until bridge is attached

2021-03-22 Thread Robert Foss
Hey Lyude,

This patch looks good to me.

Reviewed-by: Robert Foss 

On Fri, 19 Feb 2021 at 22:56, Lyude Paul  wrote:
>
> Since this is a bridge, we don't start out with a respective DRM device.
> Likewise this means we don't have a connector, which also means that we
> should be following drm_dp_aux_register()'s documentation advice and not
> call drm_dp_aux_register() until we have a matching connector. Instead,
> call drm_dp_aux_init() in tc_probe() and wait until tc_bridge_attach() to
> register our AUX channel. We also add tc_bridge_detach() to handle
> unregistering the AUX adapter once the bridge has been disconnected.
>
> Signed-off-by: Lyude Paul 
> ---
>  drivers/gpu/drm/bridge/tc358767.c | 20 +++-
>  1 file changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/tc358767.c 
> b/drivers/gpu/drm/bridge/tc358767.c
> index 34a3e4e9f717..da89922721ed 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -1414,11 +1414,15 @@ static int tc_bridge_attach(struct drm_bridge *bridge,
> if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
> return 0;
>
> +   ret = drm_dp_aux_register(>aux);
> +   if (ret < 0)
> +   return ret;
> +
> /* Create DP/eDP connector */
> drm_connector_helper_add(>connector, _connector_helper_funcs);
> ret = drm_connector_init(drm, >connector, _connector_funcs, 
> tc->bridge.type);
> if (ret)
> -   return ret;
> +   goto aux_unregister;
>
> /* Don't poll if don't have HPD connected */
> if (tc->hpd_pin >= 0) {
> @@ -1438,10 +1442,19 @@ static int tc_bridge_attach(struct drm_bridge *bridge,
> drm_connector_attach_encoder(>connector, tc->bridge.encoder);
>
> return 0;
> +aux_unregister:
> +   drm_dp_aux_unregister(>aux);
> +   return ret;
> +}
> +
> +static void tc_bridge_detach(struct drm_bridge *bridge)
> +{
> +   drm_dp_aux_unregister(_to_tc(bridge)->aux);
>  }
>
>  static const struct drm_bridge_funcs tc_bridge_funcs = {
> .attach = tc_bridge_attach,
> +   .detach = tc_bridge_detach,
> .mode_valid = tc_mode_valid,
> .mode_set = tc_bridge_mode_set,
> .enable = tc_bridge_enable,
> @@ -1680,9 +1693,7 @@ static int tc_probe(struct i2c_client *client, const 
> struct i2c_device_id *id)
> tc->aux.name = "TC358767 AUX i2c adapter";
> tc->aux.dev = tc->dev;
> tc->aux.transfer = tc_aux_transfer;
> -   ret = drm_dp_aux_register(>aux);
> -   if (ret)
> -   return ret;
> +   drm_dp_aux_init(>aux);
>
> tc->bridge.funcs = _bridge_funcs;
> if (tc->hpd_pin >= 0)
> @@ -1702,7 +1713,6 @@ static int tc_remove(struct i2c_client *client)
> struct tc_data *tc = i2c_get_clientdata(client);
>
> drm_bridge_remove(>bridge);
> -   drm_dp_aux_unregister(>aux);
>
> return 0;
>  }
> --
> 2.29.2
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 12/30] drm/bridge/analogix/anx6345: Cleanup on errors in anx6345_bridge_attach()

2021-03-22 Thread Robert Foss
Hey Lyude,

Thanks for the patch, it looks good to me.

Reviewed-by: Robert Foss 

On Fri, 19 Feb 2021 at 22:58, Lyude Paul  wrote:
>
> Another drive-by fix I found when fixing DP AUX adapter across the kernel
> tree - make sure we don't leak resources (and by proxy-AUX adapters) on
> failures in anx6345_bridge_attach() by unrolling on errors.
>
> Signed-off-by: Lyude Paul 
> ---
>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c 
> b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> index 6258f16da0e8..aa6cda458eb9 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> @@ -550,7 +550,7 @@ static int anx6345_bridge_attach(struct drm_bridge 
> *bridge,
>  DRM_MODE_CONNECTOR_eDP);
> if (err) {
> DRM_ERROR("Failed to initialize connector: %d\n", err);
> -   return err;
> +   goto aux_unregister;
> }
>
> drm_connector_helper_add(>connector,
> @@ -562,16 +562,21 @@ static int anx6345_bridge_attach(struct drm_bridge 
> *bridge,
>bridge->encoder);
> if (err) {
> DRM_ERROR("Failed to link up connector to encoder: %d\n", 
> err);
> -   return err;
> +   goto connector_cleanup;
> }
>
> err = drm_connector_register(>connector);
> if (err) {
> DRM_ERROR("Failed to register connector: %d\n", err);
> -   return err;
> +   goto connector_cleanup;
> }
>
> return 0;
> +connector_cleanup:
> +   drm_connector_cleanup(>connector);
> +aux_unregister:
> +   drm_dp_aux_unregister(>aux);
> +   return err;
>  }
>
>  static void anx6345_bridge_detach(struct drm_bridge *bridge)
> --
> 2.29.2
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 27/30] drm/dp_mst: Pass drm_dp_mst_topology_mgr to drm_dp_get_vc_payload_bw()

2021-03-22 Thread Robert Foss
Hey Lyude,

Thanks for the patch.

On Fri, 19 Feb 2021 at 23:03, Lyude Paul  wrote:
>
> Since this is one of the few functions in drm_dp_mst_topology.c that
> doesn't have any way of getting access to a drm_device, let's pass the
> drm_dp_mst_topology_mgr down to this function so that it can use
> drm_dbg_kms().
>
> Signed-off-by: Lyude Paul 
> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c   | 7 +--
>  drivers/gpu/drm/i915/display/intel_dp_mst.c | 3 ++-
>  include/drm/drm_dp_mst_helper.h | 3 ++-
>  3 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
> b/drivers/gpu/drm/drm_dp_mst_topology.c
> index cf4f2f85711e..fb66df39e0bb 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -3631,6 +3631,7 @@ static int drm_dp_send_up_ack_reply(struct 
> drm_dp_mst_topology_mgr *mgr,
>
>  /**
>   * drm_dp_get_vc_payload_bw - get the VC payload BW for an MST link
> + * @mgr: The _dp_mst_topology_mgr to use
>   * @link_rate: link rate in 10kbits/s units
>   * @link_lane_count: lane count
>   *
> @@ -3639,7 +3640,8 @@ static int drm_dp_send_up_ack_reply(struct 
> drm_dp_mst_topology_mgr *mgr,
>   * convert the number of PBNs required for a given stream to the number of
>   * timeslots this stream requires in each MTP.
>   */
> -int drm_dp_get_vc_payload_bw(int link_rate, int link_lane_count)
> +int drm_dp_get_vc_payload_bw(const struct drm_dp_mst_topology_mgr *mgr,
> +int link_rate, int link_lane_count)
>  {
> if (link_rate == 0 || link_lane_count == 0)
> DRM_DEBUG_KMS("invalid link rate/lane count: (%d / %d)\n",
> @@ -3704,7 +3706,8 @@ int drm_dp_mst_topology_mgr_set_mst(struct 
> drm_dp_mst_topology_mgr *mgr, bool ms
> goto out_unlock;
> }
>
> -   mgr->pbn_div = 
> drm_dp_get_vc_payload_bw(drm_dp_bw_code_to_link_rate(mgr->dpcd[1]),
> +   mgr->pbn_div = drm_dp_get_vc_payload_bw(mgr,
> +   
> drm_dp_bw_code_to_link_rate(mgr->dpcd[1]),
> mgr->dpcd[2] & 
> DP_MAX_LANE_COUNT_MASK);
> if (mgr->pbn_div == 0) {
> ret = -EINVAL;
> diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c 
> b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> index 8e316146b6d1..60ca0fa32d15 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> @@ -70,7 +70,8 @@ static int intel_dp_mst_compute_link_config(struct 
> intel_encoder *encoder,
> slots = drm_dp_atomic_find_vcpi_slots(state, 
> _dp->mst_mgr,
>   connector->port,
>   crtc_state->pbn,
> - 
> drm_dp_get_vc_payload_bw(crtc_state->port_clock,
> + 
> drm_dp_get_vc_payload_bw(_dp->mst_mgr,
> + 
>  crtc_state->port_clock,
>   
>  crtc_state->lane_count));

checkpatch --strict is unhappy about this chunk

WARNING: line length of 102 exceeds 100 columns
#61: FILE: drivers/gpu/drm/i915/display/intel_dp_mst.c:73:
+   crtc_state->port_clock,

Maybe the results of drm_dp_get_vc_payload_bw() can be but in a
temporary variable.

> if (slots == -EDEADLK)
> return slots;
> diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
> index bd1c39907b92..20dc705642bd 100644
> --- a/include/drm/drm_dp_mst_helper.h
> +++ b/include/drm/drm_dp_mst_helper.h
> @@ -783,7 +783,8 @@ drm_dp_mst_detect_port(struct drm_connector *connector,
>
>  struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct 
> drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
>
> -int drm_dp_get_vc_payload_bw(int link_rate, int link_lane_count);
> +int drm_dp_get_vc_payload_bw(const struct drm_dp_mst_topology_mgr *mgr,
> +int link_rate, int link_lane_count);
>
>  int drm_dp_calc_pbn_mode(int clock, int bpp, bool dsc);
>
> --
> 2.29.2
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH i-g-t] tests/kms_plane_scaling: Fix off-by-one plane selection

2017-11-06 Thread Robert Foss
Hey Gabriel,

I've reviewed and pushed this patch.
Thanks.


Rob.
On Mon, 2017-11-06 at 16:28 -0200, Gabriel Krisman Bertazi wrote:
> Commit ca20170afc6f ("tests/kms_plane_scaling: Add support for
> dynamic
> number of planes") shifted the tested planes by one after the
> refactoring, accidentally ignoring the first plane, which is zero
> indexed.  A symptom of the issue appears on KBL, where the third
> plane
> is already the shared cursor, causing igt to configure an unsupported
> framebuffer format on it, triggering the following error:
> 
> [drm:__setplane_internal] Invalid pixel format XR24 little-endian
> (0x34325258)
> 
> With this fixed, we can exposes the pixel clock scaling issue, which
> is
> the actual problem being tracked in Bug 103159, but let's start by
> reverting to the old behavior.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103159
> Fixes: ca20170afc6f ("tests/kms_plane_scaling: Add support for
> dynamic number of planes")
> Signed-off-by: Gabriel Krisman Bertazi 
> ---
>  tests/kms_plane_scaling.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c
> index 5ed69f35f267..403df47e2d3b 100644
> --- a/tests/kms_plane_scaling.c
> +++ b/tests/kms_plane_scaling.c
> @@ -195,7 +195,7 @@ static void test_plane_scaling(data_t *d)
>   igt_assert(d->fb_id3);
>  
>   /* Set up display with plane 1 */
> - d->plane1 = igt_output_get_plane(output, 1);
> + d->plane1 = igt_output_get_plane(output, 0);
>   prepare_crtc(d, output, pipe, d->plane1, mode,
> COMMIT_UNIVERSAL);
>  
>   if (primary_plane_scaling) {
> @@ -215,7 +215,7 @@ static void test_plane_scaling(data_t *d)
>   }
>  
>   /* Set up fb2->plane2 mapping. */
> - d->plane2 = igt_output_get_plane(output, 2);
> + d->plane2 = igt_output_get_plane(output, 1);
>   igt_plane_set_fb(d->plane2, >fb2);
>  
>   /* 2nd plane windowed */
> @@ -251,7 +251,7 @@ static void test_plane_scaling(data_t *d)
>   }
>  
>   /* Set up fb3->plane3 mapping. */
> - d->plane3 = igt_output_get_plane(output, 3);
> + d->plane3 = igt_output_get_plane(output, 2);
>   igt_plane_set_fb(d->plane3, >fb3);
>  
>   /* 3rd plane windowed - no scaling */

signature.asc
Description: This is a digitally signed message part
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v4 1/2] drm/blend: Fix comment typ-o

2017-05-19 Thread Robert Foss
Fix DRM_REFELCT_Y -> DRM_REFLECT_Y.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 drivers/gpu/drm/drm_blend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
index a0d0d6843288..dee67ef6c670 100644
--- a/drivers/gpu/drm/drm_blend.c
+++ b/drivers/gpu/drm/drm_blend.c
@@ -129,7 +129,7 @@
  * "rotate-270"
  * DRM_REFLECT_X:
  * "reflect-x"
- * DRM_REFELCT_Y:
+ * DRM_REFLECT_Y:
  * "reflect-y"
  *
  * Rotation is the specified amount in degrees in counter clockwise direction,
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH v4 2/2] drm: Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ to UAPI

2017-05-19 Thread Robert Foss
Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ defines to the UAPI
as a convenience.

Ideally the DRM_ROTATE_ and DRM_REFLECT_ property ids are looked up
through the atomic API, but realizing that userspace is likely to take
shortcuts and assume that the enum values are what is sent over the
wire.

As a result these defines are provided purely as a convenience to
userspace applications.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Emil Velikov <emil.veli...@collabora.com>
Reviewed-by: Sinclair Yeh <s...@vmware.com>
Acked-by: Liviu Dudau <liviu.du...@arm.com>
---
Changes since v3:
 - Switched away from past tense in comments
 - Add define name change to previously mis-spelled DRM_REFLECT_X comment
 - Improved the comment for the DRM_MODE_REFLECT_ comment

Changes since v2:
 - Changed define prefix from DRM_MODE_PROP_ to DRM_MODE_
 - Fix compilation errors
 - Changed comment formatting
 - Deduplicated comment lines
 - Clarified DRM_MODE_PROP_REFLECT_ comment

Changes since v1:
 - Moved defines from drm.h to drm_mode.h
 - Changed define prefix from DRM_ to DRM_MODE_PROP_ 
 - Updated uses of the defines to the new prefix
 - Removed include from drm_rect.c
 - Stopped using the BIT() macro 

 drivers/gpu/drm/arm/malidp_drv.h|  2 +-
 drivers/gpu/drm/arm/malidp_planes.c | 18 -
 drivers/gpu/drm/armada/armada_overlay.c |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 20 +-
 drivers/gpu/drm/drm_atomic.c|  2 +-
 drivers/gpu/drm/drm_atomic_helper.c |  2 +-
 drivers/gpu/drm/drm_blend.c | 45 +++---
 drivers/gpu/drm/drm_fb_helper.c |  4 +-
 drivers/gpu/drm/drm_plane_helper.c  |  2 +-
 drivers/gpu/drm/drm_rect.c  | 36 +-
 drivers/gpu/drm/i915/i915_debugfs.c | 14 +++
 drivers/gpu/drm/i915/intel_atomic_plane.c   |  6 +--
 drivers/gpu/drm/i915/intel_display.c| 50 -
 drivers/gpu/drm/i915/intel_fbc.c|  2 +-
 drivers/gpu/drm/i915/intel_fbdev.c  |  2 +-
 drivers/gpu/drm/i915/intel_sprite.c | 20 +-
 drivers/gpu/drm/imx/ipuv3-plane.c   |  2 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c   | 30 +++
 drivers/gpu/drm/nouveau/nv50_display.c  |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c  |  4 +-
 drivers/gpu/drm/omapdrm/omap_fb.c   | 18 -
 drivers/gpu/drm/omapdrm/omap_plane.c| 16 
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  4 +-
 include/drm/drm_blend.h | 21 +--
 include/uapi/drm/drm_mode.h | 49 +++-
 25 files changed, 202 insertions(+), 171 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_drv.h b/drivers/gpu/drm/arm/malidp_drv.h
index 040311ffcaec..2e2033140efc 100644
--- a/drivers/gpu/drm/arm/malidp_drv.h
+++ b/drivers/gpu/drm/arm/malidp_drv.h
@@ -65,6 +65,6 @@ void malidp_de_planes_destroy(struct drm_device *drm);
 int malidp_crtc_init(struct drm_device *drm);
 
 /* often used combination of rotational bits */
-#define MALIDP_ROTATED_MASK(DRM_ROTATE_90 | DRM_ROTATE_270)
+#define MALIDP_ROTATED_MASK(DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_270)
 
 #endif  /* __MALIDP_DRV_H__ */
diff --git a/drivers/gpu/drm/arm/malidp_planes.c 
b/drivers/gpu/drm/arm/malidp_planes.c
index 814fda23cead..063a8d2b0be3 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -80,7 +80,7 @@ static void malidp_plane_reset(struct drm_plane *plane)
state = kzalloc(sizeof(*state), GFP_KERNEL);
if (state) {
state->base.plane = plane;
-   state->base.rotation = DRM_ROTATE_0;
+   state->base.rotation = DRM_MODE_ROTATE_0;
plane->state = >base;
}
 }
@@ -221,7 +221,7 @@ static int malidp_de_plane_check(struct drm_plane *plane,
return ret;
 
/* packed RGB888 / BGR888 can't be rotated or flipped */
-   if (state->rotation != DRM_ROTATE_0 &&
+   if (state->rotation != DRM_MODE_ROTATE_0 &&
(fb->format->format == DRM_FORMAT_RGB888 ||
 fb->format->format == DRM_FORMAT_BGR888))
return -EINVAL;
@@ -315,12 +315,12 @@ static void malidp_de_plane_update(struct drm_plane 
*plane,
val &= ~LAYER_ROT_MASK;
 
/* setup the rotation and axis flip bits */
-   if (plane->state->rotation & DRM_ROTATE_MASK)
-   val |= ilog2(plane->state->rotation & DRM_ROTATE_MASK) <<
+   if (plane->state->rotation & DRM_MODE_ROTATE_MASK)
+   val |= ilog2(plane->state->rotation & DRM_MODE_ROTATE_MASK) <<
   LAYER_ROT_OFFSET;
-   if (pla

Re: [Intel-gfx] [PATCH v3] drm: Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ to UAPI

2017-05-19 Thread Robert Foss



On 2017-05-18 05:49 AM, Ville Syrjälä wrote:

On Wed, May 17, 2017 at 09:39:11PM -0400, Robert Foss wrote:

+/*
+ * DRM_MODE_REFLECT_
+ *
+ * Signals that the contents of a drm plane has been reflected in
+ * the  axis.


Still vague.


Ack, I'll add some verbiage.



Also you didn't respond to my comment about the use of past tense.


Fixed in v4.


Rob.




+ *
+ * This define is provided as a convenience, looking up the property id
+ * using the name->prop id lookup is the preferred method.
+ */
+#define DRM_MODE_REFLECT_X  (1<<4)
+#define DRM_MODE_REFLECT_Y  (1<<5)
+
+/*
+ * DRM_MODE_REFLECT_MASK
+ *
+ * Bitmask used to look for drm plane reflections.
+ */
+#define DRM_MODE_REFLECT_MASK (\
+   DRM_MODE_REFLECT_X | \
+   DRM_MODE_REFLECT_Y)
+
+
  struct drm_mode_modeinfo {
__u32 clock;
__u16 hdisplay;
--
2.11.0.453.g787f75f05



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


[Intel-gfx] [PATCH v3] drm: Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ to UAPI

2017-05-17 Thread Robert Foss
Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ defines to the UAPI
as a convenience.

Ideally the DRM_ROTATE_ and DRM_REFLECT_ property ids are looked up
through the atomic API, but realizing that userspace is likely to take
shortcuts and assume that the enum values are what is sent over the
wire.

As a result these defines are provided purely as a convenience to
userspace applications.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
Changes since v2:
 - Changed define prefix from DRM_MODE_PROP_ to DRM_MODE_
 - Fix compilation errors
 - Changed comment formatting
 - Deduplicated comment lines
 - Clarified DRM_MODE_PROP_REFLECT_ comment

Changes since v1:
 - Moved defines from drm.h to drm_mode.h
 - Changed define prefix from DRM_ to DRM_MODE_PROP_ 
 - Updated uses of the defines to the new prefix
 - Removed include from drm_rect.c
 - Stopped using the BIT() macro 

 drivers/gpu/drm/arm/malidp_drv.h|  2 +-
 drivers/gpu/drm/arm/malidp_planes.c | 18 -
 drivers/gpu/drm/armada/armada_overlay.c |  2 +-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 20 +-
 drivers/gpu/drm/drm_atomic.c|  2 +-
 drivers/gpu/drm/drm_atomic_helper.c |  2 +-
 drivers/gpu/drm/drm_blend.c | 43 ++---
 drivers/gpu/drm/drm_fb_helper.c |  4 +-
 drivers/gpu/drm/drm_plane_helper.c  |  2 +-
 drivers/gpu/drm/drm_rect.c  | 36 +-
 drivers/gpu/drm/i915/i915_debugfs.c | 14 +++
 drivers/gpu/drm/i915/intel_atomic_plane.c   |  6 +--
 drivers/gpu/drm/i915/intel_display.c| 50 -
 drivers/gpu/drm/i915/intel_fbc.c|  2 +-
 drivers/gpu/drm/i915/intel_fbdev.c  |  2 +-
 drivers/gpu/drm/i915/intel_sprite.c | 20 +-
 drivers/gpu/drm/imx/ipuv3-plane.c   |  2 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c   | 30 +++
 drivers/gpu/drm/nouveau/nv50_display.c  |  2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c  |  4 +-
 drivers/gpu/drm/omapdrm/omap_fb.c   | 18 -
 drivers/gpu/drm/omapdrm/omap_plane.c| 16 
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  4 +-
 include/drm/drm_blend.h | 21 +--
 include/uapi/drm/drm_mode.h | 49 +++-
 25 files changed, 201 insertions(+), 170 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_drv.h b/drivers/gpu/drm/arm/malidp_drv.h
index 040311ffcaec..2e2033140efc 100644
--- a/drivers/gpu/drm/arm/malidp_drv.h
+++ b/drivers/gpu/drm/arm/malidp_drv.h
@@ -65,6 +65,6 @@ void malidp_de_planes_destroy(struct drm_device *drm);
 int malidp_crtc_init(struct drm_device *drm);
 
 /* often used combination of rotational bits */
-#define MALIDP_ROTATED_MASK(DRM_ROTATE_90 | DRM_ROTATE_270)
+#define MALIDP_ROTATED_MASK(DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_270)
 
 #endif  /* __MALIDP_DRV_H__ */
diff --git a/drivers/gpu/drm/arm/malidp_planes.c 
b/drivers/gpu/drm/arm/malidp_planes.c
index 814fda23cead..063a8d2b0be3 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -80,7 +80,7 @@ static void malidp_plane_reset(struct drm_plane *plane)
state = kzalloc(sizeof(*state), GFP_KERNEL);
if (state) {
state->base.plane = plane;
-   state->base.rotation = DRM_ROTATE_0;
+   state->base.rotation = DRM_MODE_ROTATE_0;
plane->state = >base;
}
 }
@@ -221,7 +221,7 @@ static int malidp_de_plane_check(struct drm_plane *plane,
return ret;
 
/* packed RGB888 / BGR888 can't be rotated or flipped */
-   if (state->rotation != DRM_ROTATE_0 &&
+   if (state->rotation != DRM_MODE_ROTATE_0 &&
(fb->format->format == DRM_FORMAT_RGB888 ||
 fb->format->format == DRM_FORMAT_BGR888))
return -EINVAL;
@@ -315,12 +315,12 @@ static void malidp_de_plane_update(struct drm_plane 
*plane,
val &= ~LAYER_ROT_MASK;
 
/* setup the rotation and axis flip bits */
-   if (plane->state->rotation & DRM_ROTATE_MASK)
-   val |= ilog2(plane->state->rotation & DRM_ROTATE_MASK) <<
+   if (plane->state->rotation & DRM_MODE_ROTATE_MASK)
+   val |= ilog2(plane->state->rotation & DRM_MODE_ROTATE_MASK) <<
   LAYER_ROT_OFFSET;
-   if (plane->state->rotation & DRM_REFLECT_X)
+   if (plane->state->rotation & DRM_MODE_REFLECT_X)
val |= LAYER_H_FLIP;
-   if (plane->state->rotation & DRM_REFLECT_Y)
+   if (plane->state->rotation & DRM_MODE_REFLECT_Y)
val |= LAYER_V_FLIP;
 
/*
@@ -370,8 +370,8 @@ int malid

[Intel-gfx] [PATCH i-g-t v1] igt_kms: Allow pipes with no cursor plane

2017-04-06 Thread Robert Foss
A cursor plane may not always be available. Since there
already exist variables that signal the existance or
non-existance of cursor planes like pipe->plane_cursor and
display->has_cursor_plane, allow the pipes that have no
cursor plane.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 5811414f..d49e152e 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1677,7 +1677,15 @@ void igt_display_init(igt_display_t *display, int drm_fd)
 * There should be no gaps. If there is, something happened
 * which we can't handle (e.g. all planes are cursors).
 */
-   igt_assert_eq(p, last_plane);
+if (pipe->plane_cursor != -1) {
+/* Cursor plane found. */
+igt_assert_eq(p, last_plane);
+} else {
+/* No cursor plane found. */
+igt_assert_lte(last_plane, p);
+}
+
+
 
pipe->n_planes = n_planes;
 
-- 
2.11.0.453.g787f75f05

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


Re: [Intel-gfx] [PATCH i-g-t v1] tools: Remove accidentally included binary intel_bios_reader

2017-03-28 Thread Robert Foss

Pushed.

On 2017-03-28 07:39 PM, Jordan Justen wrote:

Reviewed-by: Jordan Justen <jordan.l.jus...@intel.com>

On 2017-03-28 16:22:22, Robert Foss wrote:

The binary tools/intel_bios_reader was accidentally included
in 3e04c5197ff965a8cd050f9c3b5213abcf437a31.

This commit removes it again.

Signed-off-by: Robert Foss <robert.f...@collabora.com>

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


Re: [Intel-gfx] [PATCH i-g-t v3 26/33] tests/kms_rotation_crc: Add support for dynamic number of planes

2017-03-28 Thread Robert Foss

Hi,

On 2017-03-28 06:06 PM, Jordan Justen wrote:

Robert,

I think this patch got committed (with a slight change) in
3e04c5197ff965a8cd050f9c3b5213abcf437a31.

Unfortunately, I think that commit inadvertently included a binary
file 'tools/intel_bios_reader' as well. Can you remove this file?


That a pretty bad mistake. Would you just like to see a commit removing 
this binary file? Or something more clever?



Rob.



Thanks,

-Jordan

On 2017-01-30 06:12:17, Robert Foss wrote:

Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_rotation_crc.c | 63 
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index cb0ac1eb..6769a89b 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -97,17 +97,18 @@ static void commit_crtc(data_t *data, igt_output_t *output, 
igt_plane_t *plane)
 * we create an fb covering the crtc and call commit
 */

-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
igt_plane_set_fb(primary, >fb_modeset);
primary->rotation_changed = false;
igt_display_commit(display);

igt_plane_set_fb(plane, >fb);

-   if (!plane->is_cursor)
+   if (plane->type != DRM_PLANE_TYPE_CURSOR)
igt_plane_set_position(plane, data->pos_x, data->pos_y);

-   if (plane->is_primary || plane->is_cursor)
+   if (plane->type == DRM_PLANE_TYPE_PRIMARY ||
+   plane->type == DRM_PLANE_TYPE_CURSOR)
commit = COMMIT_UNIVERSAL;

if (data->display.is_atomic)
@@ -154,7 +155,7 @@ static void prepare_crtc(data_t *data, igt_output_t 
*output, enum pipe pipe,
tiling = data->override_tiling ?
 data->override_tiling : LOCAL_I915_FORMAT_MOD_Y_TILED;
w = h =  mode->vdisplay;
-   } else if (plane->is_cursor) {
+   } else if (plane->type == DRM_PLANE_TYPE_CURSOR) {
pixel_format = data->override_fmt ?
   data->override_fmt : DRM_FORMAT_ARGB;
w = h = 128;
@@ -206,10 +207,10 @@ static void cleanup_crtc(data_t *data, igt_output_t 
*output, igt_plane_t *plane)
igt_remove_fb(data->gfx_fd, >fb_flip);

/* XXX: see the note in prepare_crtc() */
-   if (!plane->is_primary) {
+   if (plane->type != DRM_PLANE_TYPE_PRIMARY) {
igt_plane_t *primary;

-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_PRIMARY);
igt_plane_set_fb(primary, NULL);
}

@@ -236,7 +237,7 @@ static void wait_for_pageflip(int fd)
igt_assert(drmHandleEvent(fd, ) == 0);
 }

-static void test_plane_rotation(data_t *data, enum igt_plane plane_type)
+static void test_plane_rotation(data_t *data, int plane_type)
 {
igt_display_t *display = >display;
igt_output_t *output;
@@ -247,10 +248,10 @@ static void test_plane_rotation(data_t *data, enum 
igt_plane plane_type)
unsigned int flip_count;
int ret;

-   if (plane_type == IGT_PLANE_PRIMARY || plane_type == IGT_PLANE_CURSOR)
+   if (plane_type == DRM_PLANE_TYPE_PRIMARY || plane_type == 
DRM_PLANE_TYPE_CURSOR)
commit = COMMIT_UNIVERSAL;

-   if (plane_type == IGT_PLANE_CURSOR)
+   if (plane_type == DRM_PLANE_TYPE_CURSOR)
igt_require(display->has_cursor_plane);

if (data->display.is_atomic)
@@ -261,7 +262,7 @@ static void test_plane_rotation(data_t *data, enum 
igt_plane plane_type)

igt_output_set_pipe(output, pipe);

-   plane = igt_output_get_plane(output, plane_type);
+   plane = igt_output_get_plane_type(output, plane_type);
igt_require(igt_plane_supports_rotation(plane));

prepare_crtc(data, output, pipe, plane);
@@ -321,7 +322,7 @@ static void test_plane_rotation(data_t *data, enum 
igt_plane plane_type)

 static void test_plane_rotation_ytiled_obj(data_t *data,
   igt_output_t *output,
-  enum igt_plane plane_type)
+  int plane_type)
 {
igt_display_t *display = >display;
uint64_t tiling = LOCAL_I915_FORMAT_MOD_Y_TILED;
@@ -335,13 +336,13 @@ static void test_plane_rotation_ytiled_obj(data_t *data,
uint32_t gem_handle;
int ret;

-   plane = igt_output_get_plane(output, plane_type);
+   plane = igt_output_get_plane_type(output, plane_type);

Re: [Intel-gfx] [PATCH i-g-t 2/2] kms_pipe_crc_basic: Skip sequence tests if the source doesn't provide frame numbers

2017-03-09 Thread Robert Foss

Reviewed-by: Robert Foss <robert.f...@collabora.com>

On 2017-03-08 08:30 AM, Tomeu Vizoso wrote:

Some frame sources such as sinks aren't able to provide meaningful frame
numbers, so in those cases just skip the TEST_SEQUENCE tests.

Signed-off-by: Tomeu Vizoso <tomeu.viz...@collabora.com>
---
 tests/kms_pipe_crc_basic.c | 29 +++--
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index d0dc2a1b58cf..415efd90330c 100644
--- a/tests/kms_pipe_crc_basic.c
+++ b/tests/kms_pipe_crc_basic.c
@@ -89,7 +89,7 @@ static void test_bad_source(data_t *data)
 #define TEST_SEQUENCE (1<<0)
 #define TEST_NONBLOCK (1<<1)

-static void
+static bool
 test_read_crc_for_output(data_t *data, int pipe, igt_output_t *output,
 unsigned flags)
 {
@@ -163,9 +163,24 @@ test_read_crc_for_output(data_t *data, int pipe, 
igt_output_t *output,
for (j = 0; j < (n_crcs - 1); j++)
igt_assert_crc_equal([j], [j + 1]);

-   if (flags & TEST_SEQUENCE)
-   for (j = 0; j < (n_crcs - 1); j++)
-   igt_assert_eq(crcs[j].frame + 1, crcs[j + 
1].frame);
+   if (flags & TEST_SEQUENCE) {
+   if (!crcs[0].has_valid_frame) {
+   igt_info("Skipping connector, its 'auto' source 
doesn't give us frame numbers.\n");
+
+   free(crcs);
+   igt_pipe_crc_free(pipe_crc);
+   igt_remove_fb(data->drm_fd, >fb);
+   igt_plane_set_fb(primary, NULL);
+
+   igt_output_set_pipe(output, PIPE_ANY);
+
+   return false;
+   } else {
+   for (j = 0; j < (n_crcs - 1); j++)
+   igt_assert_eq(crcs[j].frame + 1,
+   crcs[j + 1].frame);
+   }
+   }

free(crcs);
igt_pipe_crc_free(pipe_crc);
@@ -174,6 +189,8 @@ test_read_crc_for_output(data_t *data, int pipe, 
igt_output_t *output,

igt_output_set_pipe(output, PIPE_ANY);
}
+
+   return true;
 }

 static void test_read_crc(data_t *data, int pipe, unsigned flags)
@@ -190,8 +207,8 @@ static void test_read_crc(data_t *data, int pipe, unsigned 
flags)
 igt_subtest_name(), igt_output_name(output),
 kmstest_pipe_name(pipe));

-   test_read_crc_for_output(data, pipe, output, flags);
-   valid_connectors ++;
+   if (test_read_crc_for_output(data, pipe, output, flags))
+   valid_connectors ++;
}

igt_require_f(valid_connectors, "No connector found for pipe %i\n", 
pipe);


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


Re: [Intel-gfx] [PATCH i-g-t 1/2] lib: Open debugfs files for the given DRM device

2017-03-09 Thread Robert Foss

I've only found a very minor nitpick in intel_watermark.c,
other than that this patch does not apply cleanly on upstream/master,
so I've run no compilation or runtime tests.

When it applies to trunk, feel free to add my r-b.

On 2017-03-08 08:29 AM, Tomeu Vizoso wrote:
> When opening a DRM debugfs file, locate the right path based on the
> given DRM device FD.
>
> This is needed so, in setups with more than one DRM device, any
> operations on debugfs files affect the expected DRM device.
>
> Signed-off-by: Tomeu Vizoso 
>
> ---
>
> Guess we could be more conservative and just rename the existing
> functions to have a _legacy postfix and have the new ones accept a FD
> param. Then existing i915-specific code could keep opening the first
> debugfs dir that contains i915-prefixed files and only the generic tests
> would need to be changed to pass the DRM fd.
>
> But the "right" thing to do is to not assume that there's only one DRM
> device on the system, so maybe we want to do the changes in this patch.
> ---
>  benchmarks/gem_latency.c  |   2 +-
>  lib/drmtest.c |   2 +-
>  lib/igt_debugfs.c | 181 
+++---

>  lib/igt_debugfs.h |  28 +++---
>  lib/igt_gt.c  |  12 +--
>  lib/igt_gt.h  |   4 +-
>  lib/igt_kms.c |  10 +--
>  lib/igt_kms.h |   4 +-
>  lib/intel_io.h|   2 +-
>  lib/intel_mmio.c  |   4 +-
>  tests/drv_hangman.c   |   4 +-
>  tests/drv_missed_irq.c|  37 
>  tests/drv_suspend.c   |   8 +-
>  tests/gem_eio.c   |   2 +-
>  tests/gem_exec_latency.c  |   2 +-
>  tests/gem_exec_parse.c|   2 +-
>  tests/gem_exec_whisper.c  |   6 +-
>  tests/gem_mocs_settings.c |  14 +--
>  tests/gem_persistent_relocs.c |   2 +-
>  tests/gem_ppgtt.c |  10 +--
>  tests/gem_reloc_vs_gpu.c  |   2 +-
>  tests/gem_seqno_wrap.c|  24 ++---
>  tests/gem_tiled_swapping.c|   6 +-
>  tests/gem_workarounds.c   |   4 +-
>  tests/kms_atomic_transition.c |   2 +-
>  tests/kms_ccs.c   |   4 +-
>  tests/kms_chv_cursor_fail.c   |   4 +-
>  tests/kms_crtc_background_color.c |   4 +-
>  tests/kms_cursor_crc.c|   4 +-
>  tests/kms_cursor_legacy.c |   4 +-
>  tests/kms_draw_crc.c  |   2 +-
>  tests/kms_fbc_crc.c   |   8 +-
>  tests/kms_fbcon_fbt.c |  44 -
>  tests/kms_flip_tiling.c   |   8 +-
>  tests/kms_frontbuffer_tracking.c  |  26 +++---
>  tests/kms_invalid_dotclock.c  |   6 +-
>  tests/kms_mmap_write_crc.c|   4 +-
>  tests/kms_mmio_vs_cs_flip.c   |   6 +-
>  tests/kms_pipe_color.c|   5 +-
>  tests/kms_pipe_crc_basic.c|  12 +--
>  tests/kms_plane.c |   4 +-
>  tests/kms_plane_lowres.c  |  14 ++-
>  tests/kms_plane_multiple.c|   4 +-
>  tests/kms_plane_scaling.c |   4 +-
>  tests/kms_psr_sink_crc.c  |   6 +-
>  tests/kms_pwrite_crc.c|   4 +-
>  tests/kms_rotation_crc.c  |   4 +-
>  tests/kms_sink_crc_basic.c|   8 +-
>  tests/kms_universal_plane.c   |  12 +--
>  tests/perf.c  |  16 ++--
>  tests/pm_lpsp.c   |   2 +-
>  tests/pm_rpm.c|   6 +-
>  tests/pm_sseu.c   |  28 +++---
>  tests/prime_mmap_kms.c|   2 +-
>  tools/intel_display_crc.c |   2 +-
>  tools/intel_display_poller.c  |   8 +-
>  tools/intel_dp_compliance.c   |   6 +-
>  tools/intel_forcewaked.c  |  10 ++-
>  tools/intel_gpu_top.c |   8 +-
>  tools/intel_guc_logger.c  |  10 ++-
>  tools/intel_infoframes.c  |   7 +-
>  tools/intel_l3_parity.c   |   2 +-
>  tools/intel_panel_fitter.c|   9 +-
>  tools/intel_perf_counters.c   |   2 +-
>  tools/intel_reg.c |  12 ++-
>  tools/intel_watermark.c   |  23 +++--
>  66 files changed, 405 insertions(+), 323 deletions(-)
>
> diff --git a/benchmarks/gem_latency.c b/benchmarks/gem_latency.c
> index 7be78f20358f..fc875f1acb0a 100644
> --- a/benchmarks/gem_latency.c
> +++ b/benchmarks/gem_latency.c
> @@ -470,7 +470,7 @@ static int run(int seconds,
>if (gen < 6)
>return IGT_EXIT_SKIP; /* Needs BCS timestamp */
>
> -  intel_register_access_init(intel_get_pci_device(), false);
> +  intel_register_access_init(intel_get_pci_device(), false, fd);
>
>if (gen == 6)
>timestamp_reg = REG(RCS_TIMESTAMP);
> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index 065ab1198e79..35f71c0d4f45 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -183,7 +183,7 @@ void gem_quiescent_gpu(int fd)
>gem_sync(fd, obj.handle);
>gem_close(fd, obj.handle);
>
> -  

Re: [Intel-gfx] [PATCH i-g-t] lib/igt_gt: Remove duplicated PARAM_NO_ERROR_CAPTURE define

2017-03-07 Thread Robert Foss

Added r-b and applied upstream.

On 2017-03-06 05:10 PM, Michel Thierry wrote:

LOCAL_CONTEXT_PARAM_NO_ERROR_CAPTURE exists in lib/ioctl_wrappers.h
since commit 171b21d9f761 ("igt/gem_ctx_param: Update invalid parma
number").

Cc: Chris Wilson 
Signed-off-by: Michel Thierry 
---
 lib/igt_gt.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 4bdb9114..88b86aff 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -39,8 +39,6 @@
 #include "intel_reg.h"
 #include "intel_chipset.h"

-#define LOCAL_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4
-
 /**
  * SECTION:igt_gt
  * @short_description: GT support library


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


Re: [Intel-gfx] [PATCH i-g-t] tools/intel_guc_logger: Fix the assert for the verbosity level

2017-02-19 Thread Robert Foss

Applied to upstream/master


Rob.

On 2017-02-17 11:35 AM, Daniele Ceraolo Spurio wrote:

Reviewed-by: Daniele Ceraolo Spurio 

On 16/02/17 06:31, Oscar Mateo wrote:

I guess no one has needed to change the verbosity level of the GuC logs.

Signed-off-by: Oscar Mateo 
---
 tools/intel_guc_logger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/intel_guc_logger.c b/tools/intel_guc_logger.c
index 159a54e..c9ea60d 100644
--- a/tools/intel_guc_logger.c
+++ b/tools/intel_guc_logger.c
@@ -302,7 +302,7 @@ static int parse_options(int opt, int opt_index,
void *data)
 switch(opt) {
 case 'v':
 verbosity_level = atoi(optarg);
-igt_assert_f(verbosity_level < 0 || verbosity_level > 3,
"invalid input for -v option\n");
+igt_assert_f(verbosity_level >= 0 && verbosity_level <= 3,
"invalid input for -v option\n");
 igt_debug("verbosity level to be used is %d\n",
verbosity_level);
 break;
 case 'o':


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

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


Re: [Intel-gfx] [PATCH i-g-t 5/5] lib/igt_kms: Remove redundant cursor code

2017-02-19 Thread Robert Foss



On 2017-02-17 12:54 PM, Brian Starkey wrote:

The dynamic plane support means that there should never be gaps in the
pipe->planes array. This means we should never need to move the cursor
plane from the last slot to another.

Remove the unnecessary code, and add an assert that makes sure nothing
strange happened that broke the assignment logic.


I was tempted to make this change too, but didn't quite dare risking 
introducing unexpected behavior. But I think this is the desired behavior.



Reviewed-by: Robert Foss <robert.f...@collabora.com>



Signed-off-by: Brian Starkey <brian.star...@arm.com>
---
 lib/igt_kms.c |   19 +--
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index ef7bfd1a8108..6fbe67139d98 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1824,20 +1824,11 @@ void igt_display_init(igt_display_t *display, int 
drm_fd)
 */
igt_assert_eq(pipe->plane_primary, 0);

-   if (display->has_cursor_plane) {
-   /*
-* Cursor was put in the last slot.  If we have 0 or
-* only 1 sprite, that's the wrong slot and we need to
-* move it down.
-*/
-   if (p != last_plane) {
-   pipe->planes[p] =
-   pipe->planes[last_plane];
-   pipe->planes[p].index = p;
-   memset(>planes[last_plane], 0,
-  sizeof *plane);
-   }
-   }
+   /*
+* There should be no gaps. If there is, something happened
+* which we can't handle (e.g. all planes are cursors).
+*/
+   igt_assert_eq(p, last_plane);

pipe->n_planes = n_planes;



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


Re: [Intel-gfx] [PATCH i-g-t 4/5] lib/igt_kms: Fix memory corruption when there's no cursor plane

2017-02-19 Thread Robert Foss



On 2017-02-17 12:54 PM, Brian Starkey wrote:

The dynamic plane support means that if there's no cursor plane, then
there is no space in the pipe->planes array for it, and thus assigning
a "drm_plane-less" plane is out-of-bounds and leads to heap corruption
and later crashes.

The "drm_plane-less" cursor plane isn't included in n_planes anyway,
which means there's no way to ever access it/know that it's there - so
just remove it entirely.


Nice catch!

Reviewed-by: Robert Foss <robert.f...@collabora.com>


Rob.



Fixes: 36656239ef96 lib/igt_kms: Implement dynamic plane count support
Signed-off-by: Brian Starkey <brian.star...@arm.com>
---
 lib/igt_kms.c |6 --
 1 file changed, 6 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 45c90c71f301..ef7bfd1a8108 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1837,12 +1837,6 @@ void igt_display_init(igt_display_t *display, int drm_fd)
memset(>planes[last_plane], 0,
   sizeof *plane);
}
-   } else {
-   /* Add drm_plane-less cursor */
-   plane = >planes[p];
-   plane->pipe = pipe;
-   plane->index = p;
-   plane->type = DRM_PLANE_TYPE_CURSOR;
}

pipe->n_planes = n_planes;


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


Re: [Intel-gfx] [PATCH i-g-t 3/5] lib/igt_kms: Fix possible out-of-bounds access

2017-02-19 Thread Robert Foss



On 2017-02-17 12:54 PM, Brian Starkey wrote:

If there's no primary plane, pipe->plane_primary == -1, and the assert
meant to check that it's valid will access pipe->planes[-1].

Fix that to check that pipe->plane_primary has been set instead.


Reviewed-by: Robert Foss <robert.f...@collabora.com>


Rob.



Fixes: 36656239ef96 lib/igt_kms: Implement dynamic plane count support
Signed-off-by: Brian Starkey <brian.star...@arm.com>
---
 lib/igt_kms.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 783c891aebf1..45c90c71f301 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1820,9 +1820,9 @@ void igt_display_init(igt_display_t *display, int drm_fd)

/*
 * At the bare minimum, we should expect to have a primary
-* plane
+* plane, and it must be in slot 0.
 */
-   igt_assert(pipe->planes[pipe->plane_primary].drm_plane);
+   igt_assert_eq(pipe->plane_primary, 0);

if (display->has_cursor_plane) {
/*


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


Re: [Intel-gfx] [PATCH i-g-t 2/5] lib/igt_kms: Neaten up pipe->planes[] assignment

2017-02-19 Thread Robert Foss



On 2017-02-17 12:54 PM, Brian Starkey wrote:

Remove a bunch of branches, functionally equivalent.

Signed-off-by: Brian Starkey <brian.star...@arm.com>
---
 lib/igt_kms.c |   34 ++
 1 file changed, 10 insertions(+), 24 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 4ca9145726e2..783c891aebf1 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1785,32 +1785,18 @@ void igt_display_init(igt_display_t *display, int 
drm_fd)

type = get_drm_plane_type(display->drm_fd,
  plane_resources->planes[j]);
-   switch (type) {
-   case DRM_PLANE_TYPE_PRIMARY:
-   if (pipe->plane_primary == -1) {
-   plane = >planes[0];
-   plane->index = 0;
-   pipe->plane_primary = 0;
-   } else {
-   plane = >planes[p];
-   plane->index = p++;
-   }
-   break;
-   case DRM_PLANE_TYPE_CURSOR:
-   if (pipe->plane_cursor == -1) {
-   plane = >planes[last_plane];
-   plane->index = last_plane;
-   pipe->plane_cursor = last_plane;
-   } else {
-   plane = >planes[p];
-   plane->index = p++;
-   }
-   display->has_cursor_plane = true;


The display->has_cursor_plane assignment does not seem to appear in the 
refactored code.


With that fixed this patch is:
Reviewed-by: Robert Foss <robert.f...@collabora.com>


Rob.


-   break;
-   default:
+
+   if (type == DRM_PLANE_TYPE_PRIMARY && 
pipe->plane_primary == -1) {
+   plane = >planes[0];
+   plane->index = 0;
+   pipe->plane_primary = 0;
+   } else if (type == DRM_PLANE_TYPE_CURSOR && 
pipe->plane_cursor == -1) {
+   plane = >planes[last_plane];
+   plane->index = last_plane;
+   pipe->plane_cursor = last_plane;
+   } else {
plane = >planes[p];
plane->index = p++;
-   break;
}

igt_assert_f(plane->index < n_planes, "n_planes < 
plane->index failed\n");


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


Re: [Intel-gfx] [PATCH i-g-t 1/5] lib/igt_kms: Fix drm_plane leak

2017-02-19 Thread Robert Foss



On 2017-02-17 12:54 PM, Brian Starkey wrote:

In the loop looking for planes on a pipe, we always want to free up
the drm_plane afterwards.

Fixes: 36656239ef96 lib/igt_kms: Implement dynamic plane count support
Signed-off-by: Brian Starkey <brian.star...@arm.com>
---

Hi,

This series cleans up igt_display_init a bit.

 - Fixes a memory leak.
 - Fixes out-of-bounds array access on cards with no primary plane.
 - Fixes memory corruption/crashes on cards with no cursor plane.
 - Cleans up some left-over stuff which wasn't really relevant after
   the dynamic planes change.

There's one detail (patch 4) I'm not really sure about - the dynamic
planes stuff means that the "drm_plane-less" cursor plane doesn't
work/make sense anymore, as it will never be found by
igt_pipe_get_plane_type(). I couldn't find any tests which seemed to
rely on having that cursor plane present, but I don't have any
hardware with a cursor to test on.

igt_display_init() could be simplified a bit further by not putting
the primary/cursor planes at the start/end respectively, but at least
kms_cursor_legacy appears to rely on a non-cursor plane being index 0,
so I've left it as-is for now.

I've given this a cursory test on Mali-DP, but if anyone is able to
test it more thoroughly on Intel HW that might be a good idea.


Regarding testing, I pestered tsa@freenode about running some tests on 
intel-ci for me while writing dyn_n_planes, and he was very helpful.


I used a severely shrunk tests/intel-ci/fast-feedback.testlist
that you can find here: https://hastebin.com/tajoxawewi.pl


On a separate note, this patch looks good to me:
Reviewed-by: Robert Foss <robert.f...@collabora.com>


Rob.



-Brian

 lib/igt_kms.c |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index f59af6e75348..4ca9145726e2 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1759,12 +1759,10 @@ void igt_display_init(igt_display_t *display, int 
drm_fd)
plane_resources->planes[j]);
igt_assert(drm_plane);

-   if (!(drm_plane->possible_crtcs & (1 << i))) {
-   drmModeFreePlane(drm_plane);
-   continue;
-   }
+   if (drm_plane->possible_crtcs & (1 << i))
+   n_planes++;

-   n_planes++;
+   drmModeFreePlane(drm_plane);
}

igt_assert_lte(0, n_planes);


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


Re: [Intel-gfx] [PATCH] lib/igt_kms: Fix regression on kms_plane_lowres test

2017-02-16 Thread Robert Foss

Applied and tested patch.

Reviewed-by: Robert Foss <robert.f...@collabora.com>

On 2017-02-16 09:06 AM, Mika Kahola wrote:

kms_plane_lowres subtest pipe-C-tiling-none crashes when reading out
number of crtc. This patch fixes the bug on crtc readout.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99653
Fixes: 9de635976c426b4c835083792c7d4d6e32aec615
   ("lib/igt_kms: Avoid depencency on static plane count")

Signed-off-by: Mika Kahola <mika.kah...@intel.com>
---
 lib/igt_kms.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index dae8bf9..5388a83 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1331,6 +1331,7 @@ void kmstest_get_crtc(enum pipe pipe, struct kmstest_crtc 
*crtc)
const char *mode = "r";
int ncrtc;
int line;
+   long int n;

fid = igt_debugfs_fopen("i915_display_info", mode);

@@ -1344,18 +1342,20 @@ void kmstest_get_crtc(enum pipe pipe, struct 
kmstest_crtc *crtc)
crtc->active = true;
parse_crtc(tmp, crtc);

+   n = ftell(fid);
crtc->n_planes = parse_planes(fid, NULL);
crtc->planes = calloc(crtc->n_planes, 
sizeof(*crtc->planes));
igt_assert_f(crtc->planes, "Failed to allocate memory 
for %d planes\n", crtc->n_planes);

-   fseek(fid, 0, SEEK_END);
-   fseek(fid, 0, SEEK_SET);
+   fseek(fid, n, SEEK_SET);
parse_planes(fid, crtc->planes);

-   if (crtc->pipe != pipe)
-   crtc = NULL;
-   else
+   if (crtc->pipe != pipe) {
+   free(crtc->planes);
+   } else {
ncrtc++;
+   break;
+   }
}
}



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


Re: [Intel-gfx] [PATCH i-g-t v2] tests/kms_plane_multiple: Test only with maximum number of planes

2017-02-02 Thread Robert Foss

Reviewed-by: Robert Foss <robert.f...@collabora.com>

On 2017-02-02 06:12 AM, Mika Kahola wrote:

To be more suitable for BAT testing, let's modify the test such a way
that it only uses the maximum number of available planes. This reduces
the total number of subtests.

v2: Fix broken kms_plane_multiple --list-subtests (Petri)

Cc: Petri Latvala <petri.latv...@intel.com>
Cc: Robert Foss <robert.f...@collabora.com>
Signed-off-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_plane_multiple.c | 141 +
 1 file changed, 65 insertions(+), 76 deletions(-)

diff --git a/tests/kms_plane_multiple.c b/tests/kms_plane_multiple.c
index bb84878..4930286 100644
--- a/tests/kms_plane_multiple.c
+++ b/tests/kms_plane_multiple.c
@@ -171,7 +171,7 @@ create_fb_for_mode_position(data_t *data, igt_output_t 
*output, drmModeModeInfo
mode->hdisplay, mode->vdisplay,
color->red, color->green, color->blue);

-   for (int i = 0; i <= max_planes; i++) {
+   for (int i = 0; i < max_planes; i++) {
if (data->plane[i]->type == DRM_PLANE_TYPE_PRIMARY)
continue;
igt_paint_color(cr, rect_x[i], rect_y[i],
@@ -211,7 +211,7 @@ prepare_planes(data_t *data, enum pipe pipe_id, color_t 
*color,
/* planes with random positions */
x[primary->index] = 0;
y[primary->index] = 0;
-   for (i = 1; i <= max_planes; i++) {
+   for (i = 0; i < max_planes; i++) {
igt_plane_t *plane = igt_output_get_plane(output, i);

if (plane->type == DRM_PLANE_TYPE_PRIMARY)
@@ -247,7 +247,7 @@ prepare_planes(data_t *data, enum pipe pipe_id, color_t 
*color,
 static void
 test_atomic_plane_position_with_output(data_t *data, enum pipe pipe,
   igt_output_t *output, int n_planes,
-  int max_planes, uint64_t tiling)
+  uint64_t tiling)
 {
char buf[256];
struct drm_event *e = (void *)buf;
@@ -270,7 +270,7 @@ test_atomic_plane_position_with_output(data_t *data, enum 
pipe pipe,
}

igt_info("Testing connector %s using pipe %s with %d planes %s with seed 
%d\n",
-igt_output_name(output), kmstest_pipe_name(pipe), max_planes,
+igt_output_name(output), kmstest_pipe_name(pipe), n_planes,
 info, opt.seed);

test_init(data, pipe, n_planes);
@@ -280,7 +280,7 @@ test_atomic_plane_position_with_output(data_t *data, enum 
pipe pipe,

i = 0;
while (i < iterations || loop_forever) {
-   prepare_planes(data, pipe, , tiling, max_planes, output);
+   prepare_planes(data, pipe, , tiling, n_planes, output);

vblank_start = kmstest_get_vblank(data->display.drm_fd, pipe,
  DRM_VBLANK_NEXTONMISS);
@@ -316,7 +316,7 @@ test_atomic_plane_position_with_output(data_t *data, enum 
pipe pipe,
 static void
 test_legacy_plane_position_with_output(data_t *data, enum pipe pipe,
   igt_output_t *output, int n_planes,
-  int max_planes, uint64_t tiling)
+  uint64_t tiling)
 {
test_position_t test = { .data = data };
color_t blue  = { 0.0f, 0.0f, 1.0f };
@@ -336,7 +336,7 @@ test_legacy_plane_position_with_output(data_t *data, enum 
pipe pipe,
}

igt_info("Testing connector %s using pipe %s with %d planes %s with seed 
%d\n",
-igt_output_name(output), kmstest_pipe_name(pipe), max_planes,
+igt_output_name(output), kmstest_pipe_name(pipe), n_planes,
 info, opt.seed);

test_init(data, pipe, n_planes);
@@ -346,7 +346,7 @@ test_legacy_plane_position_with_output(data_t *data, enum 
pipe pipe,

i = 0;
while (i < iterations || loop_forever) {
-   prepare_planes(data, pipe, , tiling, max_planes, output);
+   prepare_planes(data, pipe, , tiling, n_planes, output);

igt_display_commit2(>display, COMMIT_LEGACY);

@@ -365,19 +365,16 @@ test_legacy_plane_position_with_output(data_t *data, enum 
pipe pipe,
 }

 static void
-test_plane_position(data_t *data, enum pipe pipe, bool atomic, int n_planes,
-   int max_planes, uint64_t tiling)
+test_plane_position(data_t *data, enum pipe pipe, bool atomic, uint64_t tiling)
 {
igt_output_t *output;
int connected_outs;
int devid = intel_get_drm_devid(data->drm_fd);
+   int n_planes = data->display.pipes[pipe].n_planes;

if (atomic)
igt_require(data->display.is_atomic);

-   igt_skip_on(pipe >= data->display.n_pipes);
-   igt_

[Intel-gfx] [PATCH i-g-t v5 02/10] lib/igt_kms: move igt_kms_get_alt_edid() to the right place

2017-02-01 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Brian Starkey <brian.star...@arm.com>
---
 lib/igt_kms.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 4ba6316d..41acce45 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -157,23 +157,6 @@ const unsigned char* igt_kms_get_base_edid(void)
 #define EDID_NAME alt_edid
 #include "igt_edid_template.h"
 
-/**
- * igt_kms_get_alt_edid:
- *
- * Get an alternate edid block, which includes the following modes:
- *
- *  - 1400x1050 60Hz
- *  - 1920x1080 60Hz
- *  - 1280x720 60Hz
- *  - 1024x768 60Hz
- *  - 800x600 60Hz
- *  - 640x480 60Hz
- *
- * This can be extended with further features using functions such as
- * #kmstest_edid_add_3d.
- *
- * Returns: an alternate edid block
- */
 static const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
"SRC_X",
"SRC_Y",
@@ -301,6 +284,23 @@ igt_atomic_fill_pipe_props(igt_display_t *display, 
igt_pipe_t *pipe,
drmModeFreeObjectProperties(props);
 }
 
+/**
+ * igt_kms_get_alt_edid:
+ *
+ * Get an alternate edid block, which includes the following modes:
+ *
+ *  - 1400x1050 60Hz
+ *  - 1920x1080 60Hz
+ *  - 1280x720 60Hz
+ *  - 1024x768 60Hz
+ *  - 800x600 60Hz
+ *  - 640x480 60Hz
+ *
+ * This can be extended with further features using functions such as
+ * #kmstest_edid_add_3d.
+ *
+ * Returns: an alternate edid block
+ */
 const unsigned char* igt_kms_get_alt_edid(void)
 {
update_edid_csum(alt_edid);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v5 04/10] tests/kms_atomic: use global atomic properties definitions

2017-02-01 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Brian Starkey <brian.star...@arm.com>
---
 tests/kms_atomic.c | 123 -
 1 file changed, 37 insertions(+), 86 deletions(-)

diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index e6d71c31..8df51ccd 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -105,55 +105,6 @@ static const char 
*plane_type_prop_names[NUM_PLANE_TYPE_PROPS] = {
"Cursor"
 };
 
-enum plane_properties {
-   PLANE_SRC_X = 0,
-   PLANE_SRC_Y,
-   PLANE_SRC_W,
-   PLANE_SRC_H,
-   PLANE_CRTC_X,
-   PLANE_CRTC_Y,
-   PLANE_CRTC_W,
-   PLANE_CRTC_H,
-   PLANE_FB_ID,
-   PLANE_CRTC_ID,
-   PLANE_TYPE,
-   NUM_PLANE_PROPS
-};
-
-static const char *plane_prop_names[NUM_PLANE_PROPS] = {
-   "SRC_X",
-   "SRC_Y",
-   "SRC_W",
-   "SRC_H",
-   "CRTC_X",
-   "CRTC_Y",
-   "CRTC_W",
-   "CRTC_H",
-   "FB_ID",
-   "CRTC_ID",
-   "type"
-};
-
-enum crtc_properties {
-   CRTC_MODE_ID = 0,
-   CRTC_ACTIVE,
-   NUM_CRTC_PROPS
-};
-
-static const char *crtc_prop_names[NUM_CRTC_PROPS] = {
-   "MODE_ID",
-   "ACTIVE"
-};
-
-enum connector_properties {
-   CONNECTOR_CRTC_ID = 0,
-   NUM_CONNECTOR_PROPS
-};
-
-static const char *connector_prop_names[NUM_CONNECTOR_PROPS] = {
-   "CRTC_ID"
-};
-
 struct kms_atomic_blob {
uint32_t id; /* 0 if not already allocated */
size_t len;
@@ -197,9 +148,9 @@ struct kms_atomic_state {
 
 struct kms_atomic_desc {
int fd;
-   uint32_t props_connector[NUM_CONNECTOR_PROPS];
-   uint32_t props_crtc[NUM_CRTC_PROPS];
-   uint32_t props_plane[NUM_PLANE_PROPS];
+   uint32_t props_connector[IGT_NUM_CONNECTOR_PROPS];
+   uint32_t props_crtc[IGT_NUM_CRTC_PROPS];
+   uint32_t props_plane[IGT_NUM_PLANE_PROPS];
uint64_t props_plane_type[NUM_PLANE_TYPE_PROPS];
 };
 
@@ -280,7 +231,7 @@ connector_get_current_state(struct 
kms_atomic_connector_state *connector)
for (i = 0; i < props->count_props; i++) {
uint32_t *prop_ids = connector->state->desc->props_connector;
 
-   if (props->props[i] == prop_ids[CONNECTOR_CRTC_ID])
+   if (props->props[i] == prop_ids[IGT_CONNECTOR_CRTC_ID])
connector->crtc_id = props->prop_values[i];
}
drmModeFreeObjectProperties(props);
@@ -348,16 +299,16 @@ find_connector(struct kms_atomic_state *state,
 static void plane_populate_req(struct kms_atomic_plane_state *plane,
   drmModeAtomicReq *req)
 {
-   plane_set_prop(req, plane, PLANE_CRTC_ID, plane->crtc_id);
-   plane_set_prop(req, plane, PLANE_FB_ID, plane->fb_id);
-   plane_set_prop(req, plane, PLANE_SRC_X, plane->src_x);
-   plane_set_prop(req, plane, PLANE_SRC_Y, plane->src_y);
-   plane_set_prop(req, plane, PLANE_SRC_W, plane->src_w);
-   plane_set_prop(req, plane, PLANE_SRC_H, plane->src_h);
-   plane_set_prop(req, plane, PLANE_CRTC_X, plane->crtc_x);
-   plane_set_prop(req, plane, PLANE_CRTC_Y, plane->crtc_y);
-   plane_set_prop(req, plane, PLANE_CRTC_W, plane->crtc_w);
-   plane_set_prop(req, plane, PLANE_CRTC_H, plane->crtc_h);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_ID, plane->crtc_id);
+   plane_set_prop(req, plane, IGT_PLANE_FB_ID, plane->fb_id);
+   plane_set_prop(req, plane, IGT_PLANE_SRC_X, plane->src_x);
+   plane_set_prop(req, plane, IGT_PLANE_SRC_Y, plane->src_y);
+   plane_set_prop(req, plane, IGT_PLANE_SRC_W, plane->src_w);
+   plane_set_prop(req, plane, IGT_PLANE_SRC_H, plane->src_h);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_X, plane->crtc_x);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_Y, plane->crtc_y);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_W, plane->crtc_w);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_H, plane->crtc_h);
 }
 
 static void plane_get_current_state(struct kms_atomic_plane_state *plane)
@@ -373,27 +324,27 @@ static void plane_get_current_state(struct 
kms_atomic_plane_state *plane)
for (i = 0; i < props->count_props; i++) {
uint32_t *prop_ids = desc->props_plane;
 
-   if (props->props[i] == prop_ids[PLANE_CRTC_ID])
+   if (props->props[i] == prop_ids[IGT_PLANE_CRTC_ID])
plane->crtc_id = props->prop_values[i];
-   else if (props->props[i] == prop_ids[PLANE_FB_ID])
+   else if (props->props[i] == p

[Intel-gfx] [PATCH i-g-t v5 10/10] tests/kms_atomic_transition: add in_fences tests

2017-02-01 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Brian Starkey <brian.star...@arm.com>
---
 lib/igt_kms.c |  6 ++
 tests/kms_atomic_transition.c | 19 ++-
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 7227ebca..8cd91f1e 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2475,6 +2475,12 @@ static int igt_atomic_commit(igt_display_t *display, 
uint32_t flags, void *user_
 
for_each_pipe(display, pipe) {
igt_pipe_t *pipe_obj = >pipes[pipe];
+   igt_plane_t *plane;
+
+   /* reset fence_fd to prevent it from being set for the 
next commit */
+   for_each_plane_on_pipe(display, pipe, plane) {
+   igt_plane_set_fence_fd(plane, -1);
+   }
 
if (pipe_obj->out_fence_fd == -1)
continue;
diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 4b1278a4..f284cce9 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -612,7 +612,7 @@ static void collect_crcs_mask(igt_pipe_crc_t **pipe_crcs, 
unsigned mask, igt_crc
}
 }
 
-static void run_modeset_tests(igt_display_t *display, int howmany, bool 
nonblocking)
+static void run_modeset_tests(igt_display_t *display, int howmany, bool 
nonblocking, bool fencing)
 {
struct igt_fb fbs[2];
int i, j;
@@ -659,6 +659,9 @@ static void run_modeset_tests(igt_display_t *display, int 
howmany, bool nonblock
igt_plane_set_size(plane, mode->hdisplay, 
mode->vdisplay);
} else
igt_plane_set_fb(plane, NULL);
+
+   if(fencing)
+   igt_pipe_request_out_fence(>pipes[i]);
}
 
/*
@@ -746,7 +749,7 @@ cleanup:
 
 }
 
-static void run_modeset_transition(igt_display_t *display, int 
requested_outputs, bool nonblocking)
+static void run_modeset_transition(igt_display_t *display, int 
requested_outputs, bool nonblocking, bool fencing)
 {
igt_output_t *outputs[I915_MAX_PIPES] = {};
int num_outputs = 0;
@@ -774,7 +777,7 @@ static void run_modeset_transition(igt_display_t *display, 
int requested_outputs
  "Should have at least %i outputs, found %i\n",
  requested_outputs, num_outputs);
 
-   run_modeset_tests(display, requested_outputs, nonblocking);
+   run_modeset_tests(display, requested_outputs, nonblocking, fencing);
 }
 
 igt_main
@@ -833,10 +836,16 @@ igt_main
 
for (i = 1; i <= I915_MAX_PIPES; i++) {
igt_subtest_f("%ix-modeset-transitions", i)
-   run_modeset_transition(, i, false);
+   run_modeset_transition(, i, false, false);
 
igt_subtest_f("%ix-modeset-transitions-nonblocking", i)
-   run_modeset_transition(, i, true);
+   run_modeset_transition(, i, true, false);
+
+   igt_subtest_f("%ix-modeset-transitions-fencing", i)
+   run_modeset_transition(, i, false, true);
+
+   igt_subtest_f("%ix-modeset-transitions-nonblocking-fencing", i)
+   run_modeset_transition(, i, true, true);
}
 
igt_fixture {
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v5 09/10] tests/kms_atomic_transition: add out_fences tests

2017-02-01 Thread Robert Foss
Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Brian Starkey <brian.star...@arm.com>
---
 lib/igt_kms.c |  17 +
 tests/kms_atomic_transition.c | 153 --
 2 files changed, 165 insertions(+), 5 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index fbd08515..7227ebca 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -53,6 +53,7 @@
 #include "intel_chipset.h"
 #include "igt_debugfs.h"
 #include "igt_sysfs.h"
+#include "sw_sync.h"
 
 /**
  * SECTION:igt_kms
@@ -2470,6 +2471,22 @@ static int igt_atomic_commit(igt_display_t *display, 
uint32_t flags, void *user_
}
 
ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data);
+   if (!ret) {
+
+   for_each_pipe(display, pipe) {
+   igt_pipe_t *pipe_obj = >pipes[pipe];
+
+   if (pipe_obj->out_fence_fd == -1)
+   continue;
+
+   igt_assert(pipe_obj->out_fence_fd >= 0);
+   ret = sync_fence_wait(pipe_obj->out_fence_fd, 1000);
+   igt_assert(ret == 0);
+   close(pipe_obj->out_fence_fd);
+   pipe_obj->out_fence_fd = -1;
+   }
+   }
+
drmModeAtomicFree(req);
return ret;
 
diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 72429759..4b1278a4 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -23,7 +23,9 @@
 
 #include "igt.h"
 #include "drmtest.h"
+#include "sw_sync.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -253,6 +255,94 @@ retry:
 sprite_width, sprite_height, alpha);
 }
 
+int *timeline;
+pthread_t *thread;
+int *seqno;
+
+static void prepare_fencing(igt_display_t *display, enum pipe pipe)
+{
+   igt_plane_t *plane;
+   int n_planes;
+
+   igt_require_sw_sync();
+
+   n_planes = display->pipes[pipe].n_planes;
+   timeline = calloc(sizeof(*timeline), n_planes);
+   igt_assert_f(timeline != NULL, "Failed to allocate memory for 
timelines\n");
+   thread = calloc(sizeof(*thread), n_planes);
+   igt_assert_f(thread != NULL, "Failed to allocate memory for thread\n");
+   seqno = calloc(sizeof(*seqno), n_planes);
+   igt_assert_f(seqno != NULL, "Failed to allocate memory for seqno\n");
+
+   for_each_plane_on_pipe(display, pipe, plane)
+   timeline[plane->index] = sw_sync_timeline_create();
+}
+
+static void unprepare_fencing(igt_display_t *display, enum pipe pipe)
+{
+   igt_plane_t *plane;
+
+   for_each_plane_on_pipe(display, pipe, plane)
+   close(timeline[plane->index]);
+
+   free(timeline);
+   free(thread);
+   free(seqno);
+}
+
+static void *fence_inc_thread(void *arg)
+{
+   int t = *((int *) arg);
+
+   pthread_detach(pthread_self());
+
+   usleep(5000);
+   sw_sync_timeline_inc(t, 1);
+   return NULL;
+}
+
+static void configure_fencing(igt_display_t *display, enum pipe pipe)
+{
+   igt_plane_t *plane;
+   int i, fd, ret;
+
+   for_each_plane_on_pipe(display, pipe, plane) {
+
+   if (!plane->fb)
+   continue;
+
+   i = plane->index;
+
+   seqno[i]++;
+   fd = sw_sync_timeline_create_fence(timeline[i], seqno[i]);
+   igt_plane_set_fence_fd(plane, fd);
+   close(fd);
+   ret = pthread_create([i], NULL, fence_inc_thread, 
[i]);
+   igt_assert_eq(ret, 0);
+   }
+}
+
+static void clear_fencing(igt_display_t *display, enum pipe pipe)
+{
+   igt_plane_t *plane;
+
+   for_each_plane_on_pipe(display, pipe, plane)
+   igt_plane_set_fence_fd(plane, -1);
+}
+
+static void atomic_commit(igt_display_t *display, enum pipe pipe, unsigned int 
flags, void *data, bool fencing)
+{
+   if (fencing) {
+   configure_fencing(display, pipe);
+   igt_pipe_request_out_fence(>pipes[pipe]);
+   }
+
+   igt_display_commit_atomic(display, flags, data);
+
+   if (fencing)
+   clear_fencing(display, pipe);
+}
+
 /*
  * 1. Set primary plane to a known fb.
  * 2. Make sure getcrtc returns the correct fb id.
@@ -273,6 +363,10 @@ run_transition_test(igt_display_t *display, enum pipe 
pipe, igt_output_t *output
struct plane_parms parms[display->pipes[pipe].n_planes];
bool skip_test = false;
unsigned flags = DRM_MODE_PAGE_FLIP_EVENT;
+   int ret;
+
+   if (fencing)
+   prepare_fencing(display, pipe);
 
if (nonblocking)
flags |= DRM_MODE_ATOMIC_NONBLOCK;
@@ -307,12 +401,48 @@ run_transit

[Intel-gfx] [PATCH i-g-t v5 08/10] tests/kms_atomic_transition: add fencing parameter to run_transition_tests

2017-02-01 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Brian Starkey <brian.star...@arm.com>
---
 tests/kms_atomic_transition.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 095af515..72429759 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -264,7 +264,7 @@ retry:
  */
 static void
 run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t 
*output,
-   enum transition_type type, bool nonblocking)
+   enum transition_type type, bool nonblocking, bool fencing)
 {
struct igt_fb fb, argb_fb, sprite_fb;
drmModeModeInfo *mode, override_mode;
@@ -674,19 +674,19 @@ igt_main
 
igt_subtest("plane-all-transition")
for_each_pipe_with_valid_output(, pipe, output)
-   run_transition_test(, pipe, output, 
TRANSITION_PLANES, false);
+   run_transition_test(, pipe, output, 
TRANSITION_PLANES, false, false);
 
igt_subtest("plane-all-transition-nonblocking")
for_each_pipe_with_valid_output(, pipe, output)
-   run_transition_test(, pipe, output, 
TRANSITION_PLANES, true);
+   run_transition_test(, pipe, output, 
TRANSITION_PLANES, true, false);
 
igt_subtest("plane-all-modeset-transition")
for_each_pipe_with_valid_output(, pipe, output)
-   run_transition_test(, pipe, output, 
TRANSITION_MODESET, false);
+   run_transition_test(, pipe, output, 
TRANSITION_MODESET, false, false);
 
igt_subtest("plane-toggle-modeset-transition")
for_each_pipe_with_valid_output(, pipe, output)
-   run_transition_test(, pipe, output, 
TRANSITION_MODESET_DISABLE, false);
+   run_transition_test(, pipe, output, 
TRANSITION_MODESET_DISABLE, false, false);
 
for (i = 1; i <= I915_MAX_PIPES; i++) {
igt_subtest_f("%ix-modeset-transitions", i)
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v5 00/10] tests/kms_atomic_transition add fence testing

2017-02-01 Thread Robert Foss
This series adds in/out fence testing to kms_atomic_transition test and makes 
some minor cleanups.

This series can be found here:
https://git.collabora.com/cgit/user/robertfoss/intel-gpu-tools.git/log/?h=fences_$VER


Changes since v4:
  Rebased on upstream/master
  Added Reviewed-by: Brian Starkey <brian.star...@arm.com>  to all patches

  lib/igt_kms: Added igt_pipe_get_last_out_fence()
   - Removed this patch

  lib/igt_kms: Add support for the IN_FENCE_FD property
   - Fixed typo in commit message

  lib/igt_kms:
   - Fixed description for igt_pipe_request_out_fence()
   - Set pipe_obj->out_fence_fd to -1 after close() in igt_atomic_commit()
   - Moved early igt_plane_set_fence_fd(plane, -1) call to igt_atomic_commit()


Changes since v3:
  Rebased on upstream/master

  lib/igt_kms:
   - Change out_fence from int64_t to int32_t
   - Fixed build error halfway in the series
   - Change IN_FENCE_FD to be an int always
   - Change name of out_fence to out_fence_fd
   - Removed useless assert
   - Fixed erroneous fence_fd check in igt_atomic_commit()
   - Implemented igt_plane_set_fence_fd FD close logic
   - Properly close fd in igt_atomic_prepare_plane_commit()

  tests/kms_atomic:
   - Changed type of out_fence_ptr to int32_t

  tests/kms_atomic_transition:
   - Fixed indentation errors in prepare_fencing()
   - Added close() to callers of igt_plane_set_fence_fd with valid FDs
   - Move change atomic_commit to earlier commit to remove inter commit changes


Changes since v2:
  Rebased on upstream/master

  lib/igt_kms:
- Reset plane->fence_fd to -1 during igt_atomic_prepare_plane_commit()
- Rework out_fencs_ptr to be an int64_t named out_fence
- Add igt_pipe_request_out_fence()

  tests/:
- Switch to using igt_pipe_request_out_fence()
- Close out_fence fd
- Change out_fence to int64_t in run_transition_test()
- Added comments noting that two testcases are not invalid
- Added igt_pipe_get_last_out_fence() that wraps pipe->fence_out


Changes since v1:

  lib/igt_kms:
   - Added gtk-doc for exported symbols
   - Changed integer casting to avoid potential issues
   - Changed out_fence_ptr type to int64_t*
   - Fixed igt_plane_set_fence_fd comment

  tests/:
   - Rework timeout change in commit_display()
   - Extract plane_invalid_params_fence() out plane_invalid_params()
   - Extract crtc_invalid_params_fence() out crtc_invalid_params()
   - Prevent add igt_require_sw_sync to subtests using sw_sync



Gustavo Padovan (8):
  tests/kms_atomic_transition: use igt timeout instead of blocking
  lib/igt_kms: move igt_kms_get_alt_edid() to the right place
  lib/igt_kms: export properties names
  tests/kms_atomic: use global atomic properties definitions
  lib/igt_kms: Add support for the OUT_FENCE_PTR property
  tests/kms_atomic: stress possible fence settings
  tests/kms_atomic_transition: add fencing parameter to
run_transition_tests
  tests/kms_atomic_transition: add in_fences tests

Robert Foss (2):
  lib/igt_kms: Add support for the IN_FENCE_FD property
  tests/kms_atomic_transition: add out_fences tests

 lib/igt_kms.c | 111 ---
 lib/igt_kms.h |  34 -
 tests/kms_atomic.c| 310 +-
 tests/kms_atomic_transition.c | 184 +++--
 4 files changed, 506 insertions(+), 133 deletions(-)

-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v5 01/10] tests/kms_atomic_transition: use igt timeout instead of blocking

2017-02-01 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

If the event never arrives we can timeout and end the test.

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Brian Starkey <brian.star...@arm.com>
---
 tests/kms_atomic_transition.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 5fdb6175..095af515 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -383,7 +383,9 @@ static void commit_display(igt_display_t *display, unsigned 
event_mask, bool non
struct drm_event_vblank *vblank = (void *)buf;
uint32_t crtc_id, pipe = I915_MAX_PIPES;
 
+   igt_set_timeout(3, "Timed out while reading drm_fd\n");
ret = read(display->drm_fd, buf, sizeof(buf));
+   igt_reset_timeout();
if (ret < 0 && (errno == EINTR || errno == EAGAIN))
continue;
 
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v5 07/10] tests/kms_atomic: stress possible fence settings

2017-02-01 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Brian Starkey <brian.star...@arm.com>
---
 tests/kms_atomic.c | 187 ++---
 1 file changed, 177 insertions(+), 10 deletions(-)

diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index 8df51ccd..e794a62b 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -44,6 +44,7 @@
 #include "drmtest.h"
 #include "igt.h"
 #include "igt_aux.h"
+#include "sw_sync.h"
 
 #ifndef DRM_CLIENT_CAP_ATOMIC
 #define DRM_CLIENT_CAP_ATOMIC 3
@@ -126,6 +127,7 @@ struct kms_atomic_plane_state {
uint32_t fb_id; /* 0 to disable */
uint32_t src_x, src_y, src_w, src_h; /* 16.16 fixed-point */
uint32_t crtc_x, crtc_y, crtc_w, crtc_h; /* normal integers */
+   int32_t fence_fd;
 };
 
 struct kms_atomic_crtc_state {
@@ -133,6 +135,7 @@ struct kms_atomic_crtc_state {
uint32_t obj;
int idx;
bool active;
+   int32_t *out_fence_ptr;
struct kms_atomic_blob mode;
 };
 
@@ -190,11 +193,13 @@ static uint32_t blob_duplicate(int fd, uint32_t id_orig)
crtc_populate_req(crtc, req); \
plane_populate_req(plane, req); \
do_atomic_commit((crtc)->state->desc->fd, req, flags); \
-   crtc_check_current_state(crtc, plane, relax); \
-   plane_check_current_state(plane, relax); \
+   if (!(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { \
+   crtc_check_current_state(crtc, plane, relax); \
+   plane_check_current_state(plane, relax); \
+   } \
 }
 
-#define crtc_commit_atomic_err(crtc, plane, crtc_old, plane_old, req, relax, 
e) { \
+#define crtc_commit_atomic_err(crtc, plane, crtc_old, plane_old, req, flags, 
relax, e) { \
drmModeAtomicSetCursor(req, 0); \
crtc_populate_req(crtc, req); \
plane_populate_req(plane, req); \
@@ -299,6 +304,9 @@ find_connector(struct kms_atomic_state *state,
 static void plane_populate_req(struct kms_atomic_plane_state *plane,
   drmModeAtomicReq *req)
 {
+   if (plane->fence_fd)
+   plane_set_prop(req, plane, IGT_PLANE_IN_FENCE_FD, 
plane->fence_fd);
+
plane_set_prop(req, plane, IGT_PLANE_CRTC_ID, plane->crtc_id);
plane_set_prop(req, plane, IGT_PLANE_FB_ID, plane->fb_id);
plane_set_prop(req, plane, IGT_PLANE_SRC_X, plane->src_x);
@@ -433,6 +441,10 @@ find_plane(struct kms_atomic_state *state, enum plane_type 
type,
 static void crtc_populate_req(struct kms_atomic_crtc_state *crtc,
  drmModeAtomicReq *req)
 {
+   if (crtc->out_fence_ptr)
+   crtc_set_prop(req, crtc, IGT_CRTC_OUT_FENCE_PTR,
+ (uint64_t) crtc->out_fence_ptr);
+
crtc_set_prop(req, crtc, IGT_CRTC_MODE_ID, crtc->mode.id);
crtc_set_prop(req, crtc, IGT_CRTC_ACTIVE, crtc->active);
 }
@@ -1061,6 +1073,37 @@ static void plane_invalid_params(struct 
kms_atomic_crtc_state *crtc,
drmModeAtomicFree(req);
 }
 
+static void plane_invalid_params_fence(struct kms_atomic_crtc_state *crtc,
+   struct kms_atomic_plane_state *plane_old,
+   struct kms_atomic_connector_state *conn)
+{
+   struct kms_atomic_plane_state plane = *plane_old;
+   drmModeAtomicReq *req = drmModeAtomicAlloc();
+   int timeline, fence_fd;
+
+   igt_require_sw_sync();
+
+   /* invalid fence fd */
+   plane.fence_fd = plane.state->desc->fd;
+   plane.crtc_id = plane_old->crtc_id;
+   plane_commit_atomic_err(, plane_old, req,
+   ATOMIC_RELAX_NONE, EINVAL);
+
+   /* Valid fence_fd but invalid CRTC */
+   timeline = sw_sync_timeline_create();
+   fence_fd =  sw_sync_timeline_create_fence(timeline, 1);
+   plane.fence_fd = fence_fd;
+   plane.crtc_id = ~0U;
+   plane_commit_atomic_err(, plane_old, req,
+   ATOMIC_RELAX_NONE, EINVAL);
+
+   plane.fence_fd = -1;
+   close(fence_fd);
+   close(timeline);
+
+   drmModeAtomicFree(req);
+}
+
 static void crtc_invalid_params(struct kms_atomic_crtc_state *crtc_old,
struct kms_atomic_plane_state *plane,
struct kms_atomic_connector_state *conn)
@@ -1072,30 +1115,32 @@ static void crtc_invalid_params(struct 
kms_atomic_crtc_state *crtc_old,
 
/* Pass a series of invalid object IDs for the mode ID. */
crtc.mode.id = plane->obj;
-   crtc_commit_atomic_err(, plane, crtc_old, plane, req,
+   crtc_commit_atomic_err(, plane, crtc_old, plane, req, 0,
   ATOMIC_RELAX_NONE, EINVAL);
 
crtc.mode.id = crtc.obj;
-   c

[Intel-gfx] [PATCH i-g-t v5 05/10] lib/igt_kms: Add support for the IN_FENCE_FD property

2017-02-01 Thread Robert Foss
Add support for the IN_FENCE_FD property to enable setting in fences for atomic
commits.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Brian Starkey <brian.star...@arm.com>
---
 lib/igt_kms.c | 25 +
 lib/igt_kms.h |  5 +
 2 files changed, 30 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 142658a6..9b60d74a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -168,6 +168,7 @@ const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
"CRTC_H",
"FB_ID",
"CRTC_ID",
+   "IN_FENCE_FD",
"type",
"rotation"
 };
@@ -1667,6 +1668,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
plane->type = type;
plane->pipe = pipe;
plane->drm_plane = drm_plane;
+   plane->fence_fd = -1;
 
if (is_atomic == 0) {
display->is_atomic = 1;
@@ -1994,6 +1996,11 @@ igt_atomic_prepare_plane_commit(igt_plane_t *plane, 
igt_pipe_t *pipe,
plane->index,
fb_id);
 
+   if (plane->fence_fd >= 0) {
+   uint64_t fence_fd = (int64_t) plane->fence_fd;
+   igt_atomic_populate_plane_req(req, plane, 
IGT_PLANE_IN_FENCE_FD, fence_fd);
+   }
+
if (plane->fb_changed) {
igt_atomic_populate_plane_req(req, plane, IGT_PLANE_CRTC_ID, 
fb_id ? crtc_id : 0);
igt_atomic_populate_plane_req(req, plane, IGT_PLANE_FB_ID, 
fb_id);
@@ -2815,6 +2822,24 @@ void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb 
*fb)
plane->size_changed = true;
 }
 
+/**
+ * igt_plane_set_fence_fd:
+ * @plane: plane
+ * @fence_fd: fence fd, disable fence_fd by setting it to -1
+ *
+ * This function sets a fence fd to enable a commit to wait for some event to
+ * occur before completing.
+ */
+void igt_plane_set_fence_fd(igt_plane_t *plane, int fence_fd)
+{
+   close(plane->fence_fd);
+
+   if (fcntl(fence_fd, F_GETFD) != -1)
+   plane->fence_fd = dup(fence_fd);
+   else
+   plane->fence_fd = -1;
+}
+
 void igt_plane_set_position(igt_plane_t *plane, int x, int y)
 {
igt_pipe_t *pipe = plane->pipe;
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 00e0dc68..8acad8ef 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -248,6 +248,7 @@ enum igt_atomic_plane_properties {
 
IGT_PLANE_FB_ID,
IGT_PLANE_CRTC_ID,
+   IGT_PLANE_IN_FENCE_FD,
IGT_PLANE_TYPE,
IGT_PLANE_ROTATION,
IGT_NUM_PLANE_PROPS
@@ -306,6 +307,9 @@ typedef struct {
uint32_t src_h;
 
igt_rotation_t rotation;
+
+   /* in fence fd */
+   int fence_fd;
uint32_t atomic_props_plane[IGT_NUM_PLANE_PROPS];
 } igt_plane_t;
 
@@ -396,6 +400,7 @@ void igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, 
size_t length);
 void igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
 
 void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb);
+void igt_plane_set_fence_fd(igt_plane_t *plane, int fence_fd);
 void igt_plane_set_position(igt_plane_t *plane, int x, int y);
 void igt_plane_set_size(igt_plane_t *plane, int w, int h);
 void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v5 03/10] lib/igt_kms: export properties names

2017-02-01 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Brian Starkey <brian.star...@arm.com>
---
 lib/igt_kms.c |  6 +++---
 lib/igt_kms.h | 23 +++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 41acce45..142658a6 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -157,7 +157,7 @@ const unsigned char* igt_kms_get_base_edid(void)
 #define EDID_NAME alt_edid
 #include "igt_edid_template.h"
 
-static const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
+const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
"SRC_X",
"SRC_Y",
"SRC_W",
@@ -172,7 +172,7 @@ static const char 
*igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
"rotation"
 };
 
-static const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
+const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
"background_color",
"CTM",
"DEGAMMA_LUT",
@@ -181,7 +181,7 @@ static const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] 
= {
"ACTIVE"
 };
 
-static const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
+const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
"scaling mode",
"CRTC_ID"
 };
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 25626187..00e0dc68 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -97,12 +97,28 @@ enum igt_atomic_crtc_properties {
IGT_NUM_CRTC_PROPS
 };
 
+/**
+ * igt_crtc_prop_names
+ *
+ * igt_crtc_prop_names contains a list of crtc property names,
+ * as indexed by the igt_atomic_crtc_properties enum.
+ */
+extern const char *igt_crtc_prop_names[];
+
 enum igt_atomic_connector_properties {
IGT_CONNECTOR_SCALING_MODE = 0,
IGT_CONNECTOR_CRTC_ID,
IGT_NUM_CONNECTOR_PROPS
 };
 
+/**
+ * igt_connector_prop_names
+ *
+ * igt_connector_prop_names contains a list of crtc property names,
+ * as indexed by the igt_atomic_connector_properties enum.
+ */
+extern const char *igt_connector_prop_names[];
+
 struct kmstest_connector_config {
drmModeCrtc *crtc;
drmModeConnector *connector;
@@ -237,6 +253,13 @@ enum igt_atomic_plane_properties {
IGT_NUM_PLANE_PROPS
 };
 
+/**
+ * igt_plane_prop_names
+ *
+ * igt_plane_prop_names contains a list of crtc property names,
+ * as indexed by the igt_atomic_plane_properties enum.
+ */
+extern const char *igt_plane_prop_names[];
 
 typedef struct igt_display igt_display_t;
 typedef struct igt_pipe igt_pipe_t;
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v5 06/10] lib/igt_kms: Add support for the OUT_FENCE_PTR property

2017-02-01 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Add support for the OUT_FENCE_PTR property to enable setting out fences for
atomic commits.

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Brian Starkey <brian.star...@arm.com>
---
 lib/igt_kms.c | 23 ++-
 lib/igt_kms.h |  6 +-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 9b60d74a..fbd08515 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -179,7 +179,8 @@ const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
"DEGAMMA_LUT",
"GAMMA_LUT",
"MODE_ID",
-   "ACTIVE"
+   "ACTIVE",
+   "OUT_FENCE_PTR"
 };
 
 const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
@@ -2385,6 +2386,14 @@ static void igt_atomic_prepare_crtc_commit(igt_pipe_t 
*pipe_obj, drmModeAtomicRe
igt_atomic_populate_crtc_req(req, pipe_obj, IGT_CRTC_ACTIVE, 
!!output);
}
 
+   pipe_obj->out_fence_fd = -1;
+   if (pipe_obj->out_fence_requested)
+   {
+   pipe_obj->out_fence_requested = false;
+   igt_atomic_populate_crtc_req(req, pipe_obj, 
IGT_CRTC_OUT_FENCE_PTR,
+   (uint64_t)(uintptr_t) _obj->out_fence_fd);
+   }
+
/*
 *  TODO: Add all crtc level properties here
 */
@@ -2959,6 +2968,18 @@ void igt_plane_set_rotation(igt_plane_t *plane, 
igt_rotation_t rotation)
plane->rotation_changed = true;
 }
 
+/**
+ * igt_pipe_request_out_fence:
+ * @pipe: pipe which out fence will be requested for
+ *
+ * Marks this pipe for requesting an out fence at the next atomic commit
+ * will contain the fd number of the out fence created by KMS.
+ */
+void igt_pipe_request_out_fence(igt_pipe_t *pipe)
+{
+   pipe->out_fence_requested = true;
+}
+
 void
 igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length)
 {
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 8acad8ef..6754d00e 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -94,6 +94,7 @@ enum igt_atomic_crtc_properties {
IGT_CRTC_GAMMA_LUT,
IGT_CRTC_MODE_ID,
IGT_CRTC_ACTIVE,
+   IGT_CRTC_OUT_FENCE_PTR,
IGT_NUM_CRTC_PROPS
 };
 
@@ -341,6 +342,9 @@ struct igt_pipe {
 
uint64_t mode_blob;
bool mode_changed;
+
+   int32_t out_fence_fd;
+   bool out_fence_requested;
 };
 
 typedef struct {
@@ -394,7 +398,7 @@ static inline bool igt_plane_supports_rotation(igt_plane_t 
*plane)
 {
return plane->rotation_property != 0;
 }
-
+void igt_pipe_request_out_fence(igt_pipe_t *pipe);
 void igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
 void igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, size_t length);
 void igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
-- 
2.11.0.453.g787f75f05

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


Re: [Intel-gfx] [PATCH i-g-t v4 00/11] tests/kms_atomic_transition add fence testing

2017-02-01 Thread Robert Foss

On 2017-02-01 05:44 AM, Brian Starkey wrote:

Hi Robert,

Some minor comments on 5, 6, 9, 10 and 11. With those addressed, the
whole series is:

Reviewed-by: Brian Starkey <brian.star...@arm.com>

Thanks!
-Brian


Thanks for the review Brian!

I'll submit v5 and let it soak for a little while before pushing it 
upstream.



Rob.



P.S. Immediately after hitting send I realised I should have trimmed
that blob from my reply. Sorry for bouncing that back to everyone!

On Tue, Jan 31, 2017 at 08:25:09PM -0500, Robert Foss wrote:

This series adds in/out fence testing to kms_atomic_transition test
and makes some minor cleanups.

This series can be found here:
https://git.collabora.com/cgit/user/robertfoss/intel-gpu-tools.git/log/?h=fences_$VER



Changes since v3:
 Rebased on upstream/master

 lib/igt_kms:
  - Change out_fence from int64_t to int32_t
  - Fixed build error halfway in the series
  - Change IN_FENCE_FD to be an int always
  - Change name of out_fence to out_fence_fd
  - Removed useless assert
  - Fixed erroneous fence_fd check in igt_atomic_commit()
  - Implemented igt_plane_set_fence_fd FD close logic
  - Properly close fd in igt_atomic_prepare_plane_commit()

 tests/kms_atomic:
  - Changed type of out_fence_ptr to int32_t

 tests/kms_atomic_transition:
  - Fixed indentation errors in prepare_fencing()
  - Added close() to callers of igt_plane_set_fence_fd with valid FDs
  - Move change atomic_commit to earlier commit to remove inter commit
changes


Changes since v2:
 Rebased on upstream/master

 lib/igt_kms:
   - Reset plane->fence_fd to -1 during igt_atomic_prepare_plane_commit()
   - Rework out_fencs_ptr to be an int64_t named out_fence
   - Add igt_pipe_request_out_fence()

 tests/:
   - Switch to using igt_pipe_request_out_fence()
   - Close out_fence fd
   - Change out_fence to int64_t in run_transition_test()
   - Added comments noting that two testcases are not invalid
   - Added igt_pipe_get_last_out_fence() that wraps pipe->fence_out


Changes since v1:

 lib/igt_kms:
  - Added gtk-doc for exported symbols
  - Changed integer casting to avoid potential issues
  - Changed out_fence_ptr type to int64_t*
  - Fixed igt_plane_set_fence_fd comment

 tests/:
  - Rework timeout change in commit_display()
  - Extract plane_invalid_params_fence() out plane_invalid_params()
  - Extract crtc_invalid_params_fence() out crtc_invalid_params()
  - Prevent add igt_require_sw_sync to subtests using sw_sync



Gustavo Padovan (8):
 tests/kms_atomic_transition: use igt timeout instead of blocking
 lib/igt_kms: move igt_kms_get_alt_edid() to the right place
 lib/igt_kms: export properties names
 tests/kms_atomic: use global atomic properties definitions
 lib/igt_kms: Add support for the OUT_FENCE_PTR property
 tests/kms_atomic: stress possible fence settings
 tests/kms_atomic_transition: add fencing parameter to
   run_transition_tests
 tests/kms_atomic_transition: add in_fences tests

Robert Foss (3):
 lib/igt_kms: Add support for the IN_FENCE_FD property
 tests/kms_atomic_transition: add out_fences tests
 lib/igt_kms: Added igt_pipe_get_last_out_fence()

lib/igt_kms.c | 115 +---
lib/igt_kms.h |  35 -
tests/kms_atomic.c| 310
+-
tests/kms_atomic_transition.c | 184 +++--
tools/intel_vbt_decode| Bin 0 -> 384448 bytes
5 files changed, 511 insertions(+), 133 deletions(-)
create mode 100755 tools/intel_vbt_decode

--
2.11.0.453.g787f75f05


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


Re: [Intel-gfx] [PATCH i-g-t v4 09/11] tests/kms_atomic_transition: add out_fences tests

2017-02-01 Thread Robert Foss



On 2017-02-01 05:40 AM, Brian Starkey wrote:

On Tue, Jan 31, 2017 at 08:25:18PM -0500, Robert Foss wrote:

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
lib/igt_kms.c |  16 +
tests/kms_atomic_transition.c | 153
--
2 files changed, 164 insertions(+), 5 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 7bf3fa3a..64f8b337 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -53,6 +53,7 @@
#include "intel_chipset.h"
#include "igt_debugfs.h"
#include "igt_sysfs.h"
+#include "sw_sync.h"

/**
 * SECTION:igt_kms
@@ -2470,6 +2471,21 @@ static int igt_atomic_commit(igt_display_t
*display, uint32_t flags, void *user_
}

ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data);
+if (!ret) {
+
+for_each_pipe(display, pipe) {
+igt_pipe_t *pipe_obj = >pipes[pipe];
+
+if (pipe_obj->out_fence_fd == -1)
+continue;
+
+igt_assert(pipe_obj->out_fence_fd >= 0);
+ret = sync_fence_wait(pipe_obj->out_fence_fd, 1000);
+igt_assert(ret == 0);
+close(pipe_obj->out_fence_fd);


Setting it to -1 after closing seems like a good idea.

Also see my comment on patch 11 about interactions with
get_last_out_fence.

-Brian


Ack, fixed in v5.


Rob.




+}
+}
+
drmModeAtomicFree(req);
return ret;

diff --git a/tests/kms_atomic_transition.c
b/tests/kms_atomic_transition.c
index 72429759..4b1278a4 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -23,7 +23,9 @@

#include "igt.h"
#include "drmtest.h"
+#include "sw_sync.h"
#include 
+#include 
#include 
#include 
#include 
@@ -253,6 +255,94 @@ retry:
 sprite_width, sprite_height, alpha);
}

+int *timeline;
+pthread_t *thread;
+int *seqno;
+
+static void prepare_fencing(igt_display_t *display, enum pipe pipe)
+{
+igt_plane_t *plane;
+int n_planes;
+
+igt_require_sw_sync();
+
+n_planes = display->pipes[pipe].n_planes;
+timeline = calloc(sizeof(*timeline), n_planes);
+igt_assert_f(timeline != NULL, "Failed to allocate memory for
timelines\n");
+thread = calloc(sizeof(*thread), n_planes);
+igt_assert_f(thread != NULL, "Failed to allocate memory for
thread\n");
+seqno = calloc(sizeof(*seqno), n_planes);
+igt_assert_f(seqno != NULL, "Failed to allocate memory for
seqno\n");
+
+for_each_plane_on_pipe(display, pipe, plane)
+timeline[plane->index] = sw_sync_timeline_create();
+}
+
+static void unprepare_fencing(igt_display_t *display, enum pipe pipe)
+{
+igt_plane_t *plane;
+
+for_each_plane_on_pipe(display, pipe, plane)
+close(timeline[plane->index]);
+
+free(timeline);
+free(thread);
+free(seqno);
+}
+
+static void *fence_inc_thread(void *arg)
+{
+int t = *((int *) arg);
+
+pthread_detach(pthread_self());
+
+usleep(5000);
+sw_sync_timeline_inc(t, 1);
+return NULL;
+}
+
+static void configure_fencing(igt_display_t *display, enum pipe pipe)
+{
+igt_plane_t *plane;
+int i, fd, ret;
+
+for_each_plane_on_pipe(display, pipe, plane) {
+
+if (!plane->fb)
+continue;
+
+i = plane->index;
+
+seqno[i]++;
+fd = sw_sync_timeline_create_fence(timeline[i], seqno[i]);
+igt_plane_set_fence_fd(plane, fd);
+close(fd);
+ret = pthread_create([i], NULL, fence_inc_thread,
[i]);
+igt_assert_eq(ret, 0);
+}
+}
+
+static void clear_fencing(igt_display_t *display, enum pipe pipe)
+{
+igt_plane_t *plane;
+
+for_each_plane_on_pipe(display, pipe, plane)
+igt_plane_set_fence_fd(plane, -1);
+}
+
+static void atomic_commit(igt_display_t *display, enum pipe pipe,
unsigned int flags, void *data, bool fencing)
+{
+if (fencing) {
+configure_fencing(display, pipe);
+igt_pipe_request_out_fence(>pipes[pipe]);
+}
+
+igt_display_commit_atomic(display, flags, data);
+
+if (fencing)
+clear_fencing(display, pipe);
+}
+
/*
 * 1. Set primary plane to a known fb.
 * 2. Make sure getcrtc returns the correct fb id.
@@ -273,6 +363,10 @@ run_transition_test(igt_display_t *display, enum
pipe pipe, igt_output_t *output
struct plane_parms parms[display->pipes[pipe].n_planes];
bool skip_test = false;
unsigned flags = DRM_MODE_PAGE_FLIP_EVENT;
+int ret;
+
+if (fencing)
+prepare_fencing(display, pipe);

if (nonblocking)
flags |= DRM_MODE_ATOMIC_NONBLOCK;
@@ -307,12 +401,48 @@ run_transition_test(igt_display_t *display, enum
pipe pipe, igt_output_t *output

setup_parms(display, pipe, mode, _fb, _fb, parms);

+/*
+ * In some configurations the tests may not run to completion
with all
+ * 

Re: [Intel-gfx] [PATCH i-g-t v4 06/11] lib/igt_kms: Add support for the OUT_FENCE_PTR property

2017-02-01 Thread Robert Foss



On 2017-02-01 05:40 AM, Brian Starkey wrote:

On Tue, Jan 31, 2017 at 08:25:15PM -0500, Robert Foss wrote:

From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Add support for the OUT_FENCE_PTR property to enable setting out
fences for
atomic commits.

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
lib/igt_kms.c | 23 ++-
lib/igt_kms.h |  6 +-
2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 9b60d74a..7bf3fa3a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -179,7 +179,8 @@ const char
*igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
"DEGAMMA_LUT",
"GAMMA_LUT",
"MODE_ID",
-"ACTIVE"
+"ACTIVE",
+"OUT_FENCE_PTR"
};

const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
@@ -2385,6 +2386,14 @@ static void
igt_atomic_prepare_crtc_commit(igt_pipe_t *pipe_obj, drmModeAtomicRe
igt_atomic_populate_crtc_req(req, pipe_obj, IGT_CRTC_ACTIVE,
!!output);
}

+pipe_obj->out_fence_fd = -1;
+if (pipe_obj->out_fence_requested)
+{
+pipe_obj->out_fence_requested = false;
+igt_atomic_populate_crtc_req(req, pipe_obj,
IGT_CRTC_OUT_FENCE_PTR,
+(uint64_t)(uintptr_t) _obj->out_fence_fd);
+}
+
/*
 *TODO: Add all crtc level properties here
 */
@@ -2959,6 +2968,18 @@ void igt_plane_set_rotation(igt_plane_t *plane,
igt_rotation_t rotation)
plane->rotation_changed = true;
}

+/**
+ * igt_pipe_request_out_fence:
+ * @pipe: pipe pointer to which background color to be set


Wrong description here

-Brian


Ack, fixed in v5.

Rob.




+ *
+ * Marks this pipe for requesting an out fence at the next atomic commit
+ * will contain the fd number of the out fence created by KMS.
+ */
+void igt_pipe_request_out_fence(igt_pipe_t *pipe)
+{
+pipe->out_fence_requested = true;
+}
+
void
igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length)
{
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 8acad8ef..6754d00e 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -94,6 +94,7 @@ enum igt_atomic_crtc_properties {
   IGT_CRTC_GAMMA_LUT,
   IGT_CRTC_MODE_ID,
   IGT_CRTC_ACTIVE,
+   IGT_CRTC_OUT_FENCE_PTR,
   IGT_NUM_CRTC_PROPS
};

@@ -341,6 +342,9 @@ struct igt_pipe {

uint64_t mode_blob;
bool mode_changed;
+
+int32_t out_fence_fd;
+bool out_fence_requested;
};

typedef struct {
@@ -394,7 +398,7 @@ static inline bool
igt_plane_supports_rotation(igt_plane_t *plane)
{
return plane->rotation_property != 0;
}
-
+void igt_pipe_request_out_fence(igt_pipe_t *pipe);
void igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t
length);
void igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, size_t length);
void igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
--
2.11.0.453.g787f75f05


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


Re: [Intel-gfx] [PATCH i-g-t v4 05/11] lib/igt_kms: Add support for the IN_FENCE_FD property

2017-02-01 Thread Robert Foss



On 2017-02-01 05:39 AM, Brian Starkey wrote:

On Tue, Jan 31, 2017 at 08:25:14PM -0500, Robert Foss wrote:

Add support dor the IN_FENCE_FD property to enable setting in fences
for atomic
commits.


trivial... s/dor/for/


Thanks, coming up in v5.

Rob.




Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
lib/igt_kms.c | 25 +
lib/igt_kms.h |  5 +
2 files changed, 30 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 142658a6..9b60d74a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -168,6 +168,7 @@ const char
*igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
"CRTC_H",
"FB_ID",
"CRTC_ID",
+"IN_FENCE_FD",
"type",
"rotation"
};
@@ -1667,6 +1668,7 @@ void igt_display_init(igt_display_t *display,
int drm_fd)
plane->type = type;
plane->pipe = pipe;
plane->drm_plane = drm_plane;
+plane->fence_fd = -1;

if (is_atomic == 0) {
display->is_atomic = 1;
@@ -1994,6 +1996,11 @@ igt_atomic_prepare_plane_commit(igt_plane_t
*plane, igt_pipe_t *pipe,
plane->index,
fb_id);

+if (plane->fence_fd >= 0) {
+uint64_t fence_fd = (int64_t) plane->fence_fd;
+igt_atomic_populate_plane_req(req, plane,
IGT_PLANE_IN_FENCE_FD, fence_fd);
+}
+
if (plane->fb_changed) {
igt_atomic_populate_plane_req(req, plane, IGT_PLANE_CRTC_ID,
fb_id ? crtc_id : 0);
igt_atomic_populate_plane_req(req, plane, IGT_PLANE_FB_ID,
fb_id);
@@ -2815,6 +2822,24 @@ void igt_plane_set_fb(igt_plane_t *plane,
struct igt_fb *fb)
plane->size_changed = true;
}

+/**
+ * igt_plane_set_fence_fd:
+ * @plane: plane
+ * @fence_fd: fence fd, disable fence_fd by setting it to -1
+ *
+ * This function sets a fence fd to enable a commit to wait for some
event to
+ * occur before completing.
+ */
+void igt_plane_set_fence_fd(igt_plane_t *plane, int fence_fd)
+{
+close(plane->fence_fd);
+
+if (fcntl(fence_fd, F_GETFD) != -1)
+plane->fence_fd = dup(fence_fd);
+else
+plane->fence_fd = -1;
+}
+
void igt_plane_set_position(igt_plane_t *plane, int x, int y)
{
igt_pipe_t *pipe = plane->pipe;
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 00e0dc68..8acad8ef 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -248,6 +248,7 @@ enum igt_atomic_plane_properties {

   IGT_PLANE_FB_ID,
   IGT_PLANE_CRTC_ID,
+   IGT_PLANE_IN_FENCE_FD,
   IGT_PLANE_TYPE,
   IGT_PLANE_ROTATION,
   IGT_NUM_PLANE_PROPS
@@ -306,6 +307,9 @@ typedef struct {
uint32_t src_h;

igt_rotation_t rotation;
+
+/* in fence fd */
+int fence_fd;
uint32_t atomic_props_plane[IGT_NUM_PLANE_PROPS];
} igt_plane_t;

@@ -396,6 +400,7 @@ void igt_pipe_set_ctm_matrix(igt_pipe_t *pipe,
void *ptr, size_t length);
void igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);

void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb);
+void igt_plane_set_fence_fd(igt_plane_t *plane, int fence_fd);
void igt_plane_set_position(igt_plane_t *plane, int x, int y);
void igt_plane_set_size(igt_plane_t *plane, int w, int h);
void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation);
--
2.11.0.453.g787f75f05


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


Re: [Intel-gfx] [PATCH] tests/kms_plane_multiple: Test only with maximum number of planes

2017-02-01 Thread Robert Foss

I was pondering making this change myself, but didn't dare change the
functional aspects of the test.

Feel free to add my r-b.


Rob.

On 2017-02-01 09:12 AM, Mika Kahola wrote:

To be more suitable for BAT testing, let's modify the test such a way
that it only uses the maximum number of available planes. This reduces
the total number of subtests.

Cc: Robert Foss <robert.f...@collabora.com>
Signed-off-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_plane_multiple.c | 91 +++---
 1 file changed, 37 insertions(+), 54 deletions(-)

diff --git a/tests/kms_plane_multiple.c b/tests/kms_plane_multiple.c
index bb84878..48f870e 100644
--- a/tests/kms_plane_multiple.c
+++ b/tests/kms_plane_multiple.c
@@ -171,7 +171,7 @@ create_fb_for_mode_position(data_t *data, igt_output_t 
*output, drmModeModeInfo
mode->hdisplay, mode->vdisplay,
color->red, color->green, color->blue);

-   for (int i = 0; i <= max_planes; i++) {
+   for (int i = 0; i < max_planes; i++) {
if (data->plane[i]->type == DRM_PLANE_TYPE_PRIMARY)
continue;
igt_paint_color(cr, rect_x[i], rect_y[i],
@@ -211,7 +211,7 @@ prepare_planes(data_t *data, enum pipe pipe_id, color_t 
*color,
/* planes with random positions */
x[primary->index] = 0;
y[primary->index] = 0;
-   for (i = 1; i <= max_planes; i++) {
+   for (i = 0; i < max_planes; i++) {
igt_plane_t *plane = igt_output_get_plane(output, i);

if (plane->type == DRM_PLANE_TYPE_PRIMARY)
@@ -247,7 +247,7 @@ prepare_planes(data_t *data, enum pipe pipe_id, color_t 
*color,
 static void
 test_atomic_plane_position_with_output(data_t *data, enum pipe pipe,
   igt_output_t *output, int n_planes,
-  int max_planes, uint64_t tiling)
+  uint64_t tiling)
 {
char buf[256];
struct drm_event *e = (void *)buf;
@@ -270,7 +270,7 @@ test_atomic_plane_position_with_output(data_t *data, enum 
pipe pipe,
}

igt_info("Testing connector %s using pipe %s with %d planes %s with seed 
%d\n",
-igt_output_name(output), kmstest_pipe_name(pipe), max_planes,
+igt_output_name(output), kmstest_pipe_name(pipe), n_planes,
 info, opt.seed);

test_init(data, pipe, n_planes);
@@ -280,7 +280,7 @@ test_atomic_plane_position_with_output(data_t *data, enum 
pipe pipe,

i = 0;
while (i < iterations || loop_forever) {
-   prepare_planes(data, pipe, , tiling, max_planes, output);
+   prepare_planes(data, pipe, , tiling, n_planes, output);

vblank_start = kmstest_get_vblank(data->display.drm_fd, pipe,
  DRM_VBLANK_NEXTONMISS);
@@ -316,7 +316,7 @@ test_atomic_plane_position_with_output(data_t *data, enum 
pipe pipe,
 static void
 test_legacy_plane_position_with_output(data_t *data, enum pipe pipe,
   igt_output_t *output, int n_planes,
-  int max_planes, uint64_t tiling)
+  uint64_t tiling)
 {
test_position_t test = { .data = data };
color_t blue  = { 0.0f, 0.0f, 1.0f };
@@ -336,7 +336,7 @@ test_legacy_plane_position_with_output(data_t *data, enum 
pipe pipe,
}

igt_info("Testing connector %s using pipe %s with %d planes %s with seed 
%d\n",
-igt_output_name(output), kmstest_pipe_name(pipe), max_planes,
+igt_output_name(output), kmstest_pipe_name(pipe), n_planes,
 info, opt.seed);

test_init(data, pipe, n_planes);
@@ -346,7 +346,7 @@ test_legacy_plane_position_with_output(data_t *data, enum 
pipe pipe,

i = 0;
while (i < iterations || loop_forever) {
-   prepare_planes(data, pipe, , tiling, max_planes, output);
+   prepare_planes(data, pipe, , tiling, n_planes, output);

igt_display_commit2(>display, COMMIT_LEGACY);

@@ -366,7 +366,7 @@ test_legacy_plane_position_with_output(data_t *data, enum 
pipe pipe,

 static void
 test_plane_position(data_t *data, enum pipe pipe, bool atomic, int n_planes,
-   int max_planes, uint64_t tiling)
+   uint64_t tiling)
 {
igt_output_t *output;
int connected_outs;
@@ -376,7 +376,6 @@ test_plane_position(data_t *data, enum pipe pipe, bool 
atomic, int n_planes,
igt_require(data->display.is_atomic);

igt_skip_on(pipe >= data->display.n_pipes);
-   igt_skip_on(max_planes >= data->display.pipes[pipe].n_planes);

if ((tiling == LOCAL_I915_FORMAT_MOD_Y_TILED ||
 

Re: [Intel-gfx] [PATCH i-g-t] tests/chamelium: Adapt to dynamic number of planes changes

2017-02-01 Thread Robert Foss

This looks good to me, feel free to add my r-b.

Rob.

On 2017-02-01 05:56 AM, Petri Latvala wrote:

CC: Robert Foss <robert.f...@collabora.com>
CC: Lyude <ly...@redhat.com>
Signed-off-by: Petri Latvala <petri.latv...@intel.com>
---
 tests/chamelium.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/chamelium.c b/tests/chamelium.c
index d914d5b..e03acc4 100644
--- a/tests/chamelium.c
+++ b/tests/chamelium.c
@@ -310,7 +310,7 @@ enable_output(data_t *data,
  struct igt_fb *fb)
 {
igt_display_t *display = output->display;
-   igt_plane_t *primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   igt_plane_t *primary = igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_PRIMARY);
drmModeConnector *connector = chamelium_port_get_connector(
data->chamelium, port, false);

@@ -341,7 +341,7 @@ disable_output(data_t *data,
   igt_output_t *output)
 {
igt_display_t *display = output->display;
-   igt_plane_t *primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   igt_plane_t *primary = igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_PRIMARY);
igt_assert(primary);

/* Disable the display */
@@ -364,7 +364,7 @@ test_display_crc_single(data_t *data, struct chamelium_port 
*port)

output = prepare_output(data, , port);
connector = chamelium_port_get_connector(data->chamelium, port, false);
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
igt_assert(primary);

for (i = 0; i < connector->count_modes; i++) {
@@ -418,7 +418,7 @@ test_display_crc_multiple(data_t *data, struct 
chamelium_port *port)

output = prepare_output(data, , port);
connector = chamelium_port_get_connector(data->chamelium, port, false);
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
igt_assert(primary);

for (i = 0; i < connector->count_modes; i++) {
@@ -477,7 +477,7 @@ test_display_frame_dump(data_t *data, struct chamelium_port 
*port)

output = prepare_output(data, , port);
connector = chamelium_port_get_connector(data->chamelium, port, false);
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
igt_assert(primary);

for (i = 0; i < connector->count_modes; i++) {


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


[Intel-gfx] [PATCH i-g-t v4 03/11] lib/igt_kms: export properties names

2017-01-31 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c |  6 +++---
 lib/igt_kms.h | 23 +++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 41acce45..142658a6 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -157,7 +157,7 @@ const unsigned char* igt_kms_get_base_edid(void)
 #define EDID_NAME alt_edid
 #include "igt_edid_template.h"
 
-static const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
+const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
"SRC_X",
"SRC_Y",
"SRC_W",
@@ -172,7 +172,7 @@ static const char 
*igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
"rotation"
 };
 
-static const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
+const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
"background_color",
"CTM",
"DEGAMMA_LUT",
@@ -181,7 +181,7 @@ static const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] 
= {
"ACTIVE"
 };
 
-static const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
+const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
"scaling mode",
"CRTC_ID"
 };
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 25626187..00e0dc68 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -97,12 +97,28 @@ enum igt_atomic_crtc_properties {
IGT_NUM_CRTC_PROPS
 };
 
+/**
+ * igt_crtc_prop_names
+ *
+ * igt_crtc_prop_names contains a list of crtc property names,
+ * as indexed by the igt_atomic_crtc_properties enum.
+ */
+extern const char *igt_crtc_prop_names[];
+
 enum igt_atomic_connector_properties {
IGT_CONNECTOR_SCALING_MODE = 0,
IGT_CONNECTOR_CRTC_ID,
IGT_NUM_CONNECTOR_PROPS
 };
 
+/**
+ * igt_connector_prop_names
+ *
+ * igt_connector_prop_names contains a list of crtc property names,
+ * as indexed by the igt_atomic_connector_properties enum.
+ */
+extern const char *igt_connector_prop_names[];
+
 struct kmstest_connector_config {
drmModeCrtc *crtc;
drmModeConnector *connector;
@@ -237,6 +253,13 @@ enum igt_atomic_plane_properties {
IGT_NUM_PLANE_PROPS
 };
 
+/**
+ * igt_plane_prop_names
+ *
+ * igt_plane_prop_names contains a list of crtc property names,
+ * as indexed by the igt_atomic_plane_properties enum.
+ */
+extern const char *igt_plane_prop_names[];
 
 typedef struct igt_display igt_display_t;
 typedef struct igt_pipe igt_pipe_t;
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v4 11/11] lib/igt_kms: Added igt_pipe_get_last_out_fence()

2017-01-31 Thread Robert Foss
Added the igt_pipe_get_last_out_fence() helper function
that wraps accesses to pipe->fence_out.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c | 8 
 lib/igt_kms.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index a1eaf411..b99b0398 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1938,6 +1938,14 @@ static igt_output_t *igt_pipe_get_output(igt_pipe_t 
*pipe)
return NULL;
 }
 
+int igt_pipe_get_last_out_fence(igt_pipe_t *pipe)
+{
+   int fd = (int) pipe->out_fence_fd;
+   pipe->out_fence_fd = -1;
+
+   return fd;
+}
+
 bool igt_pipe_get_property(igt_pipe_t *pipe, const char *name,
   uint32_t *prop_id, uint64_t *value,
   drmModePropertyPtr *prop)
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 6754d00e..8fb327d9 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -390,6 +390,7 @@ igt_plane_t *igt_output_get_plane_type(igt_output_t 
*output, int plane_type);
 igt_output_t *igt_output_from_connector(igt_display_t *display,
 drmModeConnector *connector);
 igt_plane_t *igt_pipe_get_plane_type(igt_pipe_t *pipe, int plane_type);
+int igt_pipe_get_last_out_fence(igt_pipe_t *pipe);
 bool igt_pipe_get_property(igt_pipe_t *pipe, const char *name,
   uint32_t *prop_id, uint64_t *value,
   drmModePropertyPtr *prop);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v4 02/11] lib/igt_kms: move igt_kms_get_alt_edid() to the right place

2017-01-31 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 4ba6316d..41acce45 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -157,23 +157,6 @@ const unsigned char* igt_kms_get_base_edid(void)
 #define EDID_NAME alt_edid
 #include "igt_edid_template.h"
 
-/**
- * igt_kms_get_alt_edid:
- *
- * Get an alternate edid block, which includes the following modes:
- *
- *  - 1400x1050 60Hz
- *  - 1920x1080 60Hz
- *  - 1280x720 60Hz
- *  - 1024x768 60Hz
- *  - 800x600 60Hz
- *  - 640x480 60Hz
- *
- * This can be extended with further features using functions such as
- * #kmstest_edid_add_3d.
- *
- * Returns: an alternate edid block
- */
 static const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
"SRC_X",
"SRC_Y",
@@ -301,6 +284,23 @@ igt_atomic_fill_pipe_props(igt_display_t *display, 
igt_pipe_t *pipe,
drmModeFreeObjectProperties(props);
 }
 
+/**
+ * igt_kms_get_alt_edid:
+ *
+ * Get an alternate edid block, which includes the following modes:
+ *
+ *  - 1400x1050 60Hz
+ *  - 1920x1080 60Hz
+ *  - 1280x720 60Hz
+ *  - 1024x768 60Hz
+ *  - 800x600 60Hz
+ *  - 640x480 60Hz
+ *
+ * This can be extended with further features using functions such as
+ * #kmstest_edid_add_3d.
+ *
+ * Returns: an alternate edid block
+ */
 const unsigned char* igt_kms_get_alt_edid(void)
 {
update_edid_csum(alt_edid);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v4 08/11] tests/kms_atomic_transition: add fencing parameter to run_transition_tests

2017-01-31 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 tests/kms_atomic_transition.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 095af515..72429759 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -264,7 +264,7 @@ retry:
  */
 static void
 run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t 
*output,
-   enum transition_type type, bool nonblocking)
+   enum transition_type type, bool nonblocking, bool fencing)
 {
struct igt_fb fb, argb_fb, sprite_fb;
drmModeModeInfo *mode, override_mode;
@@ -674,19 +674,19 @@ igt_main
 
igt_subtest("plane-all-transition")
for_each_pipe_with_valid_output(, pipe, output)
-   run_transition_test(, pipe, output, 
TRANSITION_PLANES, false);
+   run_transition_test(, pipe, output, 
TRANSITION_PLANES, false, false);
 
igt_subtest("plane-all-transition-nonblocking")
for_each_pipe_with_valid_output(, pipe, output)
-   run_transition_test(, pipe, output, 
TRANSITION_PLANES, true);
+   run_transition_test(, pipe, output, 
TRANSITION_PLANES, true, false);
 
igt_subtest("plane-all-modeset-transition")
for_each_pipe_with_valid_output(, pipe, output)
-   run_transition_test(, pipe, output, 
TRANSITION_MODESET, false);
+   run_transition_test(, pipe, output, 
TRANSITION_MODESET, false, false);
 
igt_subtest("plane-toggle-modeset-transition")
for_each_pipe_with_valid_output(, pipe, output)
-   run_transition_test(, pipe, output, 
TRANSITION_MODESET_DISABLE, false);
+   run_transition_test(, pipe, output, 
TRANSITION_MODESET_DISABLE, false, false);
 
for (i = 1; i <= I915_MAX_PIPES; i++) {
igt_subtest_f("%ix-modeset-transitions", i)
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v4 09/11] tests/kms_atomic_transition: add out_fences tests

2017-01-31 Thread Robert Foss
Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c |  16 +
 tests/kms_atomic_transition.c | 153 --
 2 files changed, 164 insertions(+), 5 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 7bf3fa3a..64f8b337 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -53,6 +53,7 @@
 #include "intel_chipset.h"
 #include "igt_debugfs.h"
 #include "igt_sysfs.h"
+#include "sw_sync.h"
 
 /**
  * SECTION:igt_kms
@@ -2470,6 +2471,21 @@ static int igt_atomic_commit(igt_display_t *display, 
uint32_t flags, void *user_
}
 
ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data);
+   if (!ret) {
+
+   for_each_pipe(display, pipe) {
+   igt_pipe_t *pipe_obj = >pipes[pipe];
+
+   if (pipe_obj->out_fence_fd == -1)
+   continue;
+
+   igt_assert(pipe_obj->out_fence_fd >= 0);
+   ret = sync_fence_wait(pipe_obj->out_fence_fd, 1000);
+   igt_assert(ret == 0);
+   close(pipe_obj->out_fence_fd);
+   }
+   }
+
drmModeAtomicFree(req);
return ret;
 
diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 72429759..4b1278a4 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -23,7 +23,9 @@
 
 #include "igt.h"
 #include "drmtest.h"
+#include "sw_sync.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -253,6 +255,94 @@ retry:
 sprite_width, sprite_height, alpha);
 }
 
+int *timeline;
+pthread_t *thread;
+int *seqno;
+
+static void prepare_fencing(igt_display_t *display, enum pipe pipe)
+{
+   igt_plane_t *plane;
+   int n_planes;
+
+   igt_require_sw_sync();
+
+   n_planes = display->pipes[pipe].n_planes;
+   timeline = calloc(sizeof(*timeline), n_planes);
+   igt_assert_f(timeline != NULL, "Failed to allocate memory for 
timelines\n");
+   thread = calloc(sizeof(*thread), n_planes);
+   igt_assert_f(thread != NULL, "Failed to allocate memory for thread\n");
+   seqno = calloc(sizeof(*seqno), n_planes);
+   igt_assert_f(seqno != NULL, "Failed to allocate memory for seqno\n");
+
+   for_each_plane_on_pipe(display, pipe, plane)
+   timeline[plane->index] = sw_sync_timeline_create();
+}
+
+static void unprepare_fencing(igt_display_t *display, enum pipe pipe)
+{
+   igt_plane_t *plane;
+
+   for_each_plane_on_pipe(display, pipe, plane)
+   close(timeline[plane->index]);
+
+   free(timeline);
+   free(thread);
+   free(seqno);
+}
+
+static void *fence_inc_thread(void *arg)
+{
+   int t = *((int *) arg);
+
+   pthread_detach(pthread_self());
+
+   usleep(5000);
+   sw_sync_timeline_inc(t, 1);
+   return NULL;
+}
+
+static void configure_fencing(igt_display_t *display, enum pipe pipe)
+{
+   igt_plane_t *plane;
+   int i, fd, ret;
+
+   for_each_plane_on_pipe(display, pipe, plane) {
+
+   if (!plane->fb)
+   continue;
+
+   i = plane->index;
+
+   seqno[i]++;
+   fd = sw_sync_timeline_create_fence(timeline[i], seqno[i]);
+   igt_plane_set_fence_fd(plane, fd);
+   close(fd);
+   ret = pthread_create([i], NULL, fence_inc_thread, 
[i]);
+   igt_assert_eq(ret, 0);
+   }
+}
+
+static void clear_fencing(igt_display_t *display, enum pipe pipe)
+{
+   igt_plane_t *plane;
+
+   for_each_plane_on_pipe(display, pipe, plane)
+   igt_plane_set_fence_fd(plane, -1);
+}
+
+static void atomic_commit(igt_display_t *display, enum pipe pipe, unsigned int 
flags, void *data, bool fencing)
+{
+   if (fencing) {
+   configure_fencing(display, pipe);
+   igt_pipe_request_out_fence(>pipes[pipe]);
+   }
+
+   igt_display_commit_atomic(display, flags, data);
+
+   if (fencing)
+   clear_fencing(display, pipe);
+}
+
 /*
  * 1. Set primary plane to a known fb.
  * 2. Make sure getcrtc returns the correct fb id.
@@ -273,6 +363,10 @@ run_transition_test(igt_display_t *display, enum pipe 
pipe, igt_output_t *output
struct plane_parms parms[display->pipes[pipe].n_planes];
bool skip_test = false;
unsigned flags = DRM_MODE_PAGE_FLIP_EVENT;
+   int ret;
+
+   if (fencing)
+   prepare_fencing(display, pipe);
 
if (nonblocking)
flags |= DRM_MODE_ATOMIC_NONBLOCK;
@@ -307,12 +401,48 @@ run_transition_test(igt_display_t *display, enum pipe 
pipe, igt_output_t *output
 
setup_parms(display, pipe,

[Intel-gfx] [PATCH i-g-t v4 01/11] tests/kms_atomic_transition: use igt timeout instead of blocking

2017-01-31 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

If the event never arrives we can timeout and end the test.

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 tests/kms_atomic_transition.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 5fdb6175..095af515 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -383,7 +383,9 @@ static void commit_display(igt_display_t *display, unsigned 
event_mask, bool non
struct drm_event_vblank *vblank = (void *)buf;
uint32_t crtc_id, pipe = I915_MAX_PIPES;
 
+   igt_set_timeout(3, "Timed out while reading drm_fd\n");
ret = read(display->drm_fd, buf, sizeof(buf));
+   igt_reset_timeout();
if (ret < 0 && (errno == EINTR || errno == EAGAIN))
continue;
 
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v4 04/11] tests/kms_atomic: use global atomic properties definitions

2017-01-31 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 tests/kms_atomic.c | 123 -
 1 file changed, 37 insertions(+), 86 deletions(-)

diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index e6d71c31..8df51ccd 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -105,55 +105,6 @@ static const char 
*plane_type_prop_names[NUM_PLANE_TYPE_PROPS] = {
"Cursor"
 };
 
-enum plane_properties {
-   PLANE_SRC_X = 0,
-   PLANE_SRC_Y,
-   PLANE_SRC_W,
-   PLANE_SRC_H,
-   PLANE_CRTC_X,
-   PLANE_CRTC_Y,
-   PLANE_CRTC_W,
-   PLANE_CRTC_H,
-   PLANE_FB_ID,
-   PLANE_CRTC_ID,
-   PLANE_TYPE,
-   NUM_PLANE_PROPS
-};
-
-static const char *plane_prop_names[NUM_PLANE_PROPS] = {
-   "SRC_X",
-   "SRC_Y",
-   "SRC_W",
-   "SRC_H",
-   "CRTC_X",
-   "CRTC_Y",
-   "CRTC_W",
-   "CRTC_H",
-   "FB_ID",
-   "CRTC_ID",
-   "type"
-};
-
-enum crtc_properties {
-   CRTC_MODE_ID = 0,
-   CRTC_ACTIVE,
-   NUM_CRTC_PROPS
-};
-
-static const char *crtc_prop_names[NUM_CRTC_PROPS] = {
-   "MODE_ID",
-   "ACTIVE"
-};
-
-enum connector_properties {
-   CONNECTOR_CRTC_ID = 0,
-   NUM_CONNECTOR_PROPS
-};
-
-static const char *connector_prop_names[NUM_CONNECTOR_PROPS] = {
-   "CRTC_ID"
-};
-
 struct kms_atomic_blob {
uint32_t id; /* 0 if not already allocated */
size_t len;
@@ -197,9 +148,9 @@ struct kms_atomic_state {
 
 struct kms_atomic_desc {
int fd;
-   uint32_t props_connector[NUM_CONNECTOR_PROPS];
-   uint32_t props_crtc[NUM_CRTC_PROPS];
-   uint32_t props_plane[NUM_PLANE_PROPS];
+   uint32_t props_connector[IGT_NUM_CONNECTOR_PROPS];
+   uint32_t props_crtc[IGT_NUM_CRTC_PROPS];
+   uint32_t props_plane[IGT_NUM_PLANE_PROPS];
uint64_t props_plane_type[NUM_PLANE_TYPE_PROPS];
 };
 
@@ -280,7 +231,7 @@ connector_get_current_state(struct 
kms_atomic_connector_state *connector)
for (i = 0; i < props->count_props; i++) {
uint32_t *prop_ids = connector->state->desc->props_connector;
 
-   if (props->props[i] == prop_ids[CONNECTOR_CRTC_ID])
+   if (props->props[i] == prop_ids[IGT_CONNECTOR_CRTC_ID])
connector->crtc_id = props->prop_values[i];
}
drmModeFreeObjectProperties(props);
@@ -348,16 +299,16 @@ find_connector(struct kms_atomic_state *state,
 static void plane_populate_req(struct kms_atomic_plane_state *plane,
   drmModeAtomicReq *req)
 {
-   plane_set_prop(req, plane, PLANE_CRTC_ID, plane->crtc_id);
-   plane_set_prop(req, plane, PLANE_FB_ID, plane->fb_id);
-   plane_set_prop(req, plane, PLANE_SRC_X, plane->src_x);
-   plane_set_prop(req, plane, PLANE_SRC_Y, plane->src_y);
-   plane_set_prop(req, plane, PLANE_SRC_W, plane->src_w);
-   plane_set_prop(req, plane, PLANE_SRC_H, plane->src_h);
-   plane_set_prop(req, plane, PLANE_CRTC_X, plane->crtc_x);
-   plane_set_prop(req, plane, PLANE_CRTC_Y, plane->crtc_y);
-   plane_set_prop(req, plane, PLANE_CRTC_W, plane->crtc_w);
-   plane_set_prop(req, plane, PLANE_CRTC_H, plane->crtc_h);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_ID, plane->crtc_id);
+   plane_set_prop(req, plane, IGT_PLANE_FB_ID, plane->fb_id);
+   plane_set_prop(req, plane, IGT_PLANE_SRC_X, plane->src_x);
+   plane_set_prop(req, plane, IGT_PLANE_SRC_Y, plane->src_y);
+   plane_set_prop(req, plane, IGT_PLANE_SRC_W, plane->src_w);
+   plane_set_prop(req, plane, IGT_PLANE_SRC_H, plane->src_h);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_X, plane->crtc_x);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_Y, plane->crtc_y);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_W, plane->crtc_w);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_H, plane->crtc_h);
 }
 
 static void plane_get_current_state(struct kms_atomic_plane_state *plane)
@@ -373,27 +324,27 @@ static void plane_get_current_state(struct 
kms_atomic_plane_state *plane)
for (i = 0; i < props->count_props; i++) {
uint32_t *prop_ids = desc->props_plane;
 
-   if (props->props[i] == prop_ids[PLANE_CRTC_ID])
+   if (props->props[i] == prop_ids[IGT_PLANE_CRTC_ID])
plane->crtc_id = props->prop_values[i];
-   else if (props->props[i] == prop_ids[PLANE_FB_ID])
+   else if (props->props[i] == prop_ids[IGT_PLANE_FB_ID])
plane->f

[Intel-gfx] [PATCH i-g-t v4 05/11] lib/igt_kms: Add support for the IN_FENCE_FD property

2017-01-31 Thread Robert Foss
Add support dor the IN_FENCE_FD property to enable setting in fences for atomic
commits.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c | 25 +
 lib/igt_kms.h |  5 +
 2 files changed, 30 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 142658a6..9b60d74a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -168,6 +168,7 @@ const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
"CRTC_H",
"FB_ID",
"CRTC_ID",
+   "IN_FENCE_FD",
"type",
"rotation"
 };
@@ -1667,6 +1668,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
plane->type = type;
plane->pipe = pipe;
plane->drm_plane = drm_plane;
+   plane->fence_fd = -1;
 
if (is_atomic == 0) {
display->is_atomic = 1;
@@ -1994,6 +1996,11 @@ igt_atomic_prepare_plane_commit(igt_plane_t *plane, 
igt_pipe_t *pipe,
plane->index,
fb_id);
 
+   if (plane->fence_fd >= 0) {
+   uint64_t fence_fd = (int64_t) plane->fence_fd;
+   igt_atomic_populate_plane_req(req, plane, 
IGT_PLANE_IN_FENCE_FD, fence_fd);
+   }
+
if (plane->fb_changed) {
igt_atomic_populate_plane_req(req, plane, IGT_PLANE_CRTC_ID, 
fb_id ? crtc_id : 0);
igt_atomic_populate_plane_req(req, plane, IGT_PLANE_FB_ID, 
fb_id);
@@ -2815,6 +2822,24 @@ void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb 
*fb)
plane->size_changed = true;
 }
 
+/**
+ * igt_plane_set_fence_fd:
+ * @plane: plane
+ * @fence_fd: fence fd, disable fence_fd by setting it to -1
+ *
+ * This function sets a fence fd to enable a commit to wait for some event to
+ * occur before completing.
+ */
+void igt_plane_set_fence_fd(igt_plane_t *plane, int fence_fd)
+{
+   close(plane->fence_fd);
+
+   if (fcntl(fence_fd, F_GETFD) != -1)
+   plane->fence_fd = dup(fence_fd);
+   else
+   plane->fence_fd = -1;
+}
+
 void igt_plane_set_position(igt_plane_t *plane, int x, int y)
 {
igt_pipe_t *pipe = plane->pipe;
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 00e0dc68..8acad8ef 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -248,6 +248,7 @@ enum igt_atomic_plane_properties {
 
IGT_PLANE_FB_ID,
IGT_PLANE_CRTC_ID,
+   IGT_PLANE_IN_FENCE_FD,
IGT_PLANE_TYPE,
IGT_PLANE_ROTATION,
IGT_NUM_PLANE_PROPS
@@ -306,6 +307,9 @@ typedef struct {
uint32_t src_h;
 
igt_rotation_t rotation;
+
+   /* in fence fd */
+   int fence_fd;
uint32_t atomic_props_plane[IGT_NUM_PLANE_PROPS];
 } igt_plane_t;
 
@@ -396,6 +400,7 @@ void igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, 
size_t length);
 void igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
 
 void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb);
+void igt_plane_set_fence_fd(igt_plane_t *plane, int fence_fd);
 void igt_plane_set_position(igt_plane_t *plane, int x, int y);
 void igt_plane_set_size(igt_plane_t *plane, int w, int h);
 void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v4 00/11] tests/kms_atomic_transition add fence testing

2017-01-31 Thread Robert Foss
This series adds in/out fence testing to kms_atomic_transition test and makes 
some minor cleanups.

This series can be found here:
https://git.collabora.com/cgit/user/robertfoss/intel-gpu-tools.git/log/?h=fences_$VER


Changes since v3:
  Rebased on upstream/master

  lib/igt_kms:
   - Change out_fence from int64_t to int32_t
   - Fixed build error halfway in the series
   - Change IN_FENCE_FD to be an int always
   - Change name of out_fence to out_fence_fd
   - Removed useless assert
   - Fixed erroneous fence_fd check in igt_atomic_commit()
   - Implemented igt_plane_set_fence_fd FD close logic
   - Properly close fd in igt_atomic_prepare_plane_commit()

  tests/kms_atomic:
   - Changed type of out_fence_ptr to int32_t

  tests/kms_atomic_transition:
   - Fixed indentation errors in prepare_fencing()
   - Added close() to callers of igt_plane_set_fence_fd with valid FDs
   - Move change atomic_commit to earlier commit to remove inter commit changes


Changes since v2:
  Rebased on upstream/master

  lib/igt_kms:
- Reset plane->fence_fd to -1 during igt_atomic_prepare_plane_commit()
- Rework out_fencs_ptr to be an int64_t named out_fence
- Add igt_pipe_request_out_fence()

  tests/:
- Switch to using igt_pipe_request_out_fence()
- Close out_fence fd
- Change out_fence to int64_t in run_transition_test()
- Added comments noting that two testcases are not invalid
- Added igt_pipe_get_last_out_fence() that wraps pipe->fence_out


Changes since v1:

  lib/igt_kms:
   - Added gtk-doc for exported symbols
   - Changed integer casting to avoid potential issues
   - Changed out_fence_ptr type to int64_t*
   - Fixed igt_plane_set_fence_fd comment

  tests/:
   - Rework timeout change in commit_display()
   - Extract plane_invalid_params_fence() out plane_invalid_params()
   - Extract crtc_invalid_params_fence() out crtc_invalid_params()
   - Prevent add igt_require_sw_sync to subtests using sw_sync



Gustavo Padovan (8):
  tests/kms_atomic_transition: use igt timeout instead of blocking
  lib/igt_kms: move igt_kms_get_alt_edid() to the right place
  lib/igt_kms: export properties names
  tests/kms_atomic: use global atomic properties definitions
  lib/igt_kms: Add support for the OUT_FENCE_PTR property
  tests/kms_atomic: stress possible fence settings
  tests/kms_atomic_transition: add fencing parameter to
run_transition_tests
  tests/kms_atomic_transition: add in_fences tests

Robert Foss (3):
  lib/igt_kms: Add support for the IN_FENCE_FD property
  tests/kms_atomic_transition: add out_fences tests
  lib/igt_kms: Added igt_pipe_get_last_out_fence()

 lib/igt_kms.c | 115 +---
 lib/igt_kms.h |  35 -
 tests/kms_atomic.c| 310 +-
 tests/kms_atomic_transition.c | 184 +++--
 tools/intel_vbt_decode| Bin 0 -> 384448 bytes
 5 files changed, 511 insertions(+), 133 deletions(-)
 create mode 100755 tools/intel_vbt_decode

-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v4 06/11] lib/igt_kms: Add support for the OUT_FENCE_PTR property

2017-01-31 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Add support for the OUT_FENCE_PTR property to enable setting out fences for
atomic commits.

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c | 23 ++-
 lib/igt_kms.h |  6 +-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 9b60d74a..7bf3fa3a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -179,7 +179,8 @@ const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
"DEGAMMA_LUT",
"GAMMA_LUT",
"MODE_ID",
-   "ACTIVE"
+   "ACTIVE",
+   "OUT_FENCE_PTR"
 };
 
 const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
@@ -2385,6 +2386,14 @@ static void igt_atomic_prepare_crtc_commit(igt_pipe_t 
*pipe_obj, drmModeAtomicRe
igt_atomic_populate_crtc_req(req, pipe_obj, IGT_CRTC_ACTIVE, 
!!output);
}
 
+   pipe_obj->out_fence_fd = -1;
+   if (pipe_obj->out_fence_requested)
+   {
+   pipe_obj->out_fence_requested = false;
+   igt_atomic_populate_crtc_req(req, pipe_obj, 
IGT_CRTC_OUT_FENCE_PTR,
+   (uint64_t)(uintptr_t) _obj->out_fence_fd);
+   }
+
/*
 *  TODO: Add all crtc level properties here
 */
@@ -2959,6 +2968,18 @@ void igt_plane_set_rotation(igt_plane_t *plane, 
igt_rotation_t rotation)
plane->rotation_changed = true;
 }
 
+/**
+ * igt_pipe_request_out_fence:
+ * @pipe: pipe pointer to which background color to be set
+ *
+ * Marks this pipe for requesting an out fence at the next atomic commit
+ * will contain the fd number of the out fence created by KMS.
+ */
+void igt_pipe_request_out_fence(igt_pipe_t *pipe)
+{
+   pipe->out_fence_requested = true;
+}
+
 void
 igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length)
 {
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 8acad8ef..6754d00e 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -94,6 +94,7 @@ enum igt_atomic_crtc_properties {
IGT_CRTC_GAMMA_LUT,
IGT_CRTC_MODE_ID,
IGT_CRTC_ACTIVE,
+   IGT_CRTC_OUT_FENCE_PTR,
IGT_NUM_CRTC_PROPS
 };
 
@@ -341,6 +342,9 @@ struct igt_pipe {
 
uint64_t mode_blob;
bool mode_changed;
+
+   int32_t out_fence_fd;
+   bool out_fence_requested;
 };
 
 typedef struct {
@@ -394,7 +398,7 @@ static inline bool igt_plane_supports_rotation(igt_plane_t 
*plane)
 {
return plane->rotation_property != 0;
 }
-
+void igt_pipe_request_out_fence(igt_pipe_t *pipe);
 void igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
 void igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, size_t length);
 void igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v4 07/11] tests/kms_atomic: stress possible fence settings

2017-01-31 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Brian Starkey <brian.star...@arm.com>
---
 tests/kms_atomic.c | 187 ++---
 1 file changed, 177 insertions(+), 10 deletions(-)

diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index 8df51ccd..e794a62b 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -44,6 +44,7 @@
 #include "drmtest.h"
 #include "igt.h"
 #include "igt_aux.h"
+#include "sw_sync.h"
 
 #ifndef DRM_CLIENT_CAP_ATOMIC
 #define DRM_CLIENT_CAP_ATOMIC 3
@@ -126,6 +127,7 @@ struct kms_atomic_plane_state {
uint32_t fb_id; /* 0 to disable */
uint32_t src_x, src_y, src_w, src_h; /* 16.16 fixed-point */
uint32_t crtc_x, crtc_y, crtc_w, crtc_h; /* normal integers */
+   int32_t fence_fd;
 };
 
 struct kms_atomic_crtc_state {
@@ -133,6 +135,7 @@ struct kms_atomic_crtc_state {
uint32_t obj;
int idx;
bool active;
+   int32_t *out_fence_ptr;
struct kms_atomic_blob mode;
 };
 
@@ -190,11 +193,13 @@ static uint32_t blob_duplicate(int fd, uint32_t id_orig)
crtc_populate_req(crtc, req); \
plane_populate_req(plane, req); \
do_atomic_commit((crtc)->state->desc->fd, req, flags); \
-   crtc_check_current_state(crtc, plane, relax); \
-   plane_check_current_state(plane, relax); \
+   if (!(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { \
+   crtc_check_current_state(crtc, plane, relax); \
+   plane_check_current_state(plane, relax); \
+   } \
 }
 
-#define crtc_commit_atomic_err(crtc, plane, crtc_old, plane_old, req, relax, 
e) { \
+#define crtc_commit_atomic_err(crtc, plane, crtc_old, plane_old, req, flags, 
relax, e) { \
drmModeAtomicSetCursor(req, 0); \
crtc_populate_req(crtc, req); \
plane_populate_req(plane, req); \
@@ -299,6 +304,9 @@ find_connector(struct kms_atomic_state *state,
 static void plane_populate_req(struct kms_atomic_plane_state *plane,
   drmModeAtomicReq *req)
 {
+   if (plane->fence_fd)
+   plane_set_prop(req, plane, IGT_PLANE_IN_FENCE_FD, 
plane->fence_fd);
+
plane_set_prop(req, plane, IGT_PLANE_CRTC_ID, plane->crtc_id);
plane_set_prop(req, plane, IGT_PLANE_FB_ID, plane->fb_id);
plane_set_prop(req, plane, IGT_PLANE_SRC_X, plane->src_x);
@@ -433,6 +441,10 @@ find_plane(struct kms_atomic_state *state, enum plane_type 
type,
 static void crtc_populate_req(struct kms_atomic_crtc_state *crtc,
  drmModeAtomicReq *req)
 {
+   if (crtc->out_fence_ptr)
+   crtc_set_prop(req, crtc, IGT_CRTC_OUT_FENCE_PTR,
+ (uint64_t) crtc->out_fence_ptr);
+
crtc_set_prop(req, crtc, IGT_CRTC_MODE_ID, crtc->mode.id);
crtc_set_prop(req, crtc, IGT_CRTC_ACTIVE, crtc->active);
 }
@@ -1061,6 +1073,37 @@ static void plane_invalid_params(struct 
kms_atomic_crtc_state *crtc,
drmModeAtomicFree(req);
 }
 
+static void plane_invalid_params_fence(struct kms_atomic_crtc_state *crtc,
+   struct kms_atomic_plane_state *plane_old,
+   struct kms_atomic_connector_state *conn)
+{
+   struct kms_atomic_plane_state plane = *plane_old;
+   drmModeAtomicReq *req = drmModeAtomicAlloc();
+   int timeline, fence_fd;
+
+   igt_require_sw_sync();
+
+   /* invalid fence fd */
+   plane.fence_fd = plane.state->desc->fd;
+   plane.crtc_id = plane_old->crtc_id;
+   plane_commit_atomic_err(, plane_old, req,
+   ATOMIC_RELAX_NONE, EINVAL);
+
+   /* Valid fence_fd but invalid CRTC */
+   timeline = sw_sync_timeline_create();
+   fence_fd =  sw_sync_timeline_create_fence(timeline, 1);
+   plane.fence_fd = fence_fd;
+   plane.crtc_id = ~0U;
+   plane_commit_atomic_err(, plane_old, req,
+   ATOMIC_RELAX_NONE, EINVAL);
+
+   plane.fence_fd = -1;
+   close(fence_fd);
+   close(timeline);
+
+   drmModeAtomicFree(req);
+}
+
 static void crtc_invalid_params(struct kms_atomic_crtc_state *crtc_old,
struct kms_atomic_plane_state *plane,
struct kms_atomic_connector_state *conn)
@@ -1072,30 +1115,32 @@ static void crtc_invalid_params(struct 
kms_atomic_crtc_state *crtc_old,
 
/* Pass a series of invalid object IDs for the mode ID. */
crtc.mode.id = plane->obj;
-   crtc_commit_atomic_err(, plane, crtc_old, plane, req,
+   crtc_commit_atomic_err(, plane, crtc_old, plane, req, 0,
   ATOMIC_RELAX_NONE, EINVAL);
 
crtc.mode.id = crtc.obj;
-   c

Re: [Intel-gfx] [PATCH i-g-t v3 11/11] tests/kms_atomic_transition: add in_fences tests

2017-01-31 Thread Robert Foss



On 2017-01-31 11:52 AM, Brian Starkey wrote:

On Mon, Jan 30, 2017 at 08:58:47PM -0500, Robert Foss wrote:

From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
lib/igt_kms.c |  3 +++
tests/kms_atomic_transition.c | 48
++-
2 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 523f3f57..bc815363 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2009,6 +2009,9 @@ igt_atomic_prepare_plane_commit(igt_plane_t
*plane, igt_pipe_t *pipe,
if (plane->fence_fd >= 0) {
uint64_t fence_fd = (int64_t) plane->fence_fd;
igt_atomic_populate_plane_req(req, plane,
IGT_PLANE_IN_FENCE_FD, fence_fd);
+
+/* reset fence_fd to prevent it from being set for the next
commit */
+plane->fence_fd = -1;


Who closes it?


Fixed in v4.




}

if (plane->fb_changed) {
diff --git a/tests/kms_atomic_transition.c
b/tests/kms_atomic_transition.c
index eebb5d66..0876bbb3 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -23,7 +23,9 @@

#include "igt.h"
#include "drmtest.h"
+#include "sw_sync.h"
#include 
+#include 
#include 
#include 
#include 
@@ -362,6 +364,9 @@ run_transition_test(igt_display_t *display, enum
pipe pipe, igt_output_t *output
unsigned flags = DRM_MODE_PAGE_FLIP_EVENT;
int ret;

+if (fencing)
+prepare_fencing(display, pipe);
+
if (nonblocking)
flags |= DRM_MODE_ATOMIC_NONBLOCK;

@@ -404,18 +409,19 @@ run_transition_test(igt_display_t *display, enum
pipe pipe, igt_output_t *output
wm_setup_plane(display, pipe, iter_max - 1, parms);

if (fencing)
-igt_pipe_set_out_fence_ptr(>pipes[pipe],
-(int64_t *) _fence);
+igt_pipe_request_out_fence(>pipes[pipe]);
+


Hopefully this can get rebased away? I'm getting confused about
what's actually being added/changed in this commit.


Fixed in v4.
The igt_pipe_set_out_fence_ptr calls were really spread about.




ret = igt_display_try_commit_atomic(display,
DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);

-if (ret != -EINVAL || n_planes < 3)
+if (ret != -EINVAL || display->pipes[pipe].n_planes < 3)
break;

ret = 0;
for_each_plane_on_pipe(display, pipe, plane) {
i = plane->index;

-if (plane->is_primary || plane->is_cursor)
+if (plane->type == DRM_PLANE_TYPE_PRIMARY ||
+plane->type == DRM_PLANE_TYPE_CURSOR)
continue;


This seems spurious?

...

A bit more add/remove churn below which can hopefully go away with a
rebase.



Ack, removing churn in v4.


Cheers,
-Brian


if (parms[i].width <= 512)
@@ -436,10 +442,8 @@ run_transition_test(igt_display_t *display, enum
pipe pipe, igt_output_t *output

wm_setup_plane(display, pipe, i, parms);

-if (fencing)
-igt_pipe_set_out_fence_ptr(>pipes[pipe],
_fence);
+atomic_commit(display, pipe, flags, (void *)(unsigned long)i,
fencing);

-igt_display_commit_atomic(display, flags, (void *)(unsigned
long)i);
drmHandleEvent(display->drm_fd, _events);

if (type == TRANSITION_MODESET_DISABLE) {
@@ -463,19 +467,14 @@ run_transition_test(igt_display_t *display, enum
pipe pipe, igt_output_t *output
if (type == TRANSITION_MODESET)
igt_output_override_mode(output, _mode);

-if (fencing)
-igt_pipe_set_out_fence_ptr(>pipes[pipe],
_fence);
-
-igt_display_commit_atomic(display, flags, (void
*)(unsigned long)j);
+atomic_commit(display, pipe, flags, (void *)(unsigned
long)i, fencing);
drmHandleEvent(display->drm_fd, _events);

wm_setup_plane(display, pipe, i, parms);
if (type == TRANSITION_MODESET)
igt_output_override_mode(output, NULL);

-if (fencing)
-igt_pipe_set_out_fence_ptr(>pipes[pipe],
_fence);
-
+atomic_commit(display, pipe, flags, (void *)(unsigned
long)i, fencing);
igt_display_commit_atomic(display, flags, (void
*)(unsigned long)i);
drmHandleEvent(display->drm_fd, _events);
}
@@ -483,6 +482,8 @@ run_transition_test(igt_display_t *display, enum
pipe pipe, igt_output_t *output
}

cleanup:
+unprepare_fencing(display, pipe);
+
igt_output_set_pipe(output, PIPE_NONE);

for_each_plane_on_pipe(display, pipe, plane)
@@ -617,7 +618,7 @@ static void collect_crcs_mask(igt_pipe_crc_t
**pipe_crcs, unsigned mask, igt_crc
}
}

-static void run_modeset_tests(igt_display_t *display, i

Re: [Intel-gfx] [PATCH i-g-t v3 10/11] tests/kms_atomic_transition: add out_fences tests

2017-01-31 Thread Robert Foss



On 2017-01-31 11:52 AM, Brian Starkey wrote:

On Mon, Jan 30, 2017 at 08:58:46PM -0500, Robert Foss wrote:

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
lib/igt_kms.c |  35 ++
tests/kms_atomic_transition.c | 148
++
2 files changed, 169 insertions(+), 14 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index f14496dd..523f3f57 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -53,6 +53,7 @@
#include "intel_chipset.h"
#include "igt_debugfs.h"
#include "igt_sysfs.h"
+#include "sw_sync.h"

/**
 * SECTION:igt_kms
@@ -2479,6 +2480,21 @@ static int igt_atomic_commit(igt_display_t
*display, uint32_t flags, void *user_
}

ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data);
+if (!ret) {
+
+for_each_pipe(display, pipe) {
+igt_pipe_t *pipe_obj = >pipes[pipe];
+
+if (pipe_obj->out_fence != -1)
+continue;


Should be "if (pipe_obj->fence == -1)" ? The stuff below seems to be
assuming the fence is valid.



Correct, fixed in v4.


+
+igt_assert(pipe_obj->out_fence >= 0);
+ret = sync_fence_wait(pipe_obj->out_fence, 1000);
+igt_assert(ret == 0);
+close(pipe_obj->out_fence);
+}
+}
+
drmModeAtomicFree(req);
return ret;

@@ -2972,6 +2988,11 @@ void igt_plane_set_rotation(igt_plane_t *plane,
igt_rotation_t rotation)
plane->rotation_changed = true;
}

+void igt_pipe_request_out_fence(igt_pipe_t *pipe)


Oh here it is!


+{
+pipe->out_fence_requested = true;
+}
+
void
igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length)
{
@@ -2994,20 +3015,6 @@ igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void
*ptr, size_t length)
}

/**
- * igt_pipe_set_out_fence_ptr:
- * @pipe: pipe pointer to which background color to be set
- * @fence_ptr: out fence pointer
- *
- * Sets the out fence pointer that will be passed to the kernel in
- * the atomic ioctl. When the kernel returns the out fence pointer
- * will contain the fd number of the out fence created by KMS.
- */
-void igt_pipe_set_out_fence_ptr(igt_pipe_t *pipe, int64_t *fence_ptr)


... and there this one goes. This deletion and the function above
need to be squashed into the earlier commit I suppose.



Ack, fixed in v4.


-{
-pipe->out_fence_ptr = fence_ptr;
-}
-
-/**
 * igt_crtc_set_background:
 * @pipe: pipe pointer to which background color to be set
 * @background: background color value in BGR 16bpc
diff --git a/tests/kms_atomic_transition.c
b/tests/kms_atomic_transition.c
index 72429759..eebb5d66 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -253,6 +253,93 @@ retry:
 sprite_width, sprite_height, alpha);
}

+int *timeline;
+pthread_t *thread;
+int *seqno;
+
+static void prepare_fencing(igt_display_t *display, enum pipe pipe)
+{
+igt_plane_t *plane;
+int n_planes;
+
+igt_require_sw_sync();
+
+n_planes = display->pipes[pipe].n_planes;
+timeline = calloc(sizeof(*timeline), n_planes);
+igt_assert_f(timeline != NULL, "Failed to allocate memory for
timelines\n");
+thread = calloc(sizeof(*thread), n_planes);
+igt_assert_f(thread != NULL, "Failed to allocate memory for
thread\n");
+seqno = calloc(sizeof(*seqno), n_planes);
+igt_assert_f(seqno != NULL, "Failed to allocate memory for
seqno\n");


The 6 lines above are space-indented



Ack, fixed in v4.


+
+for_each_plane_on_pipe(display, pipe, plane)
+timeline[plane->index] = sw_sync_timeline_create();
+}
+
+static void unprepare_fencing(igt_display_t *display, enum pipe pipe)
+{
+igt_plane_t *plane;
+
+for_each_plane_on_pipe(display, pipe, plane)
+close(timeline[plane->index]);
+
+free(timeline);
+free(thread);
+free(seqno);
+}
+
+static void *fence_inc_thread(void *arg)
+{
+int t = *((int *) arg);
+
+pthread_detach(pthread_self());
+
+usleep(5000);
+sw_sync_timeline_inc(t, 1);
+return NULL;
+}
+
+static void configure_fencing(igt_display_t *display, enum pipe pipe)
+{
+igt_plane_t *plane;
+int i, fd, ret;
+
+for_each_plane_on_pipe(display, pipe, plane) {
+
+if (!plane->fb)
+continue;
+
+i = plane->index;
+
+seqno[i]++;
+fd = sw_sync_timeline_create_fence(timeline[i], seqno[i]);
+igt_plane_set_fence_fd(plane, fd);
+ret = pthread_create([i], NULL, fence_inc_thread,
[i]);
+igt_assert_eq(ret, 0);
+}
+}
+
+static void clear_fencing(igt_display_t *display, enum pipe pipe)
+{
+igt_plane_t *plane;
+
+for_each_plane_on_pipe(display, pipe, plane)
+igt_plane_set_fence_fd(plane, -1);


Someone should close the old fence_fd if it's not 

Re: [Intel-gfx] [PATCH i-g-t v3 08/11] tests/kms_atomic: stress possible fence settings

2017-01-31 Thread Robert Foss



On 2017-01-31 11:50 AM, Brian Starkey wrote:

This one lgtm, just need to swap all the uint64_t out_fence_ptrs for
int32_t.

-Brian


Fixed in v4.

Rob.



On Mon, Jan 30, 2017 at 08:58:44PM -0500, Robert Foss wrote:

From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
tests/kms_atomic.c | 187
++---
1 file changed, 177 insertions(+), 10 deletions(-)

diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index 8df51ccd..09605e38 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -44,6 +44,7 @@
#include "drmtest.h"
#include "igt.h"
#include "igt_aux.h"
+#include "sw_sync.h"

#ifndef DRM_CLIENT_CAP_ATOMIC
#define DRM_CLIENT_CAP_ATOMIC 3
@@ -126,6 +127,7 @@ struct kms_atomic_plane_state {
uint32_t fb_id; /* 0 to disable */
uint32_t src_x, src_y, src_w, src_h; /* 16.16 fixed-point */
uint32_t crtc_x, crtc_y, crtc_w, crtc_h; /* normal integers */
+int32_t fence_fd;
};

struct kms_atomic_crtc_state {
@@ -133,6 +135,7 @@ struct kms_atomic_crtc_state {
uint32_t obj;
int idx;
bool active;
+uint64_t out_fence_ptr;
struct kms_atomic_blob mode;
};

@@ -190,11 +193,13 @@ static uint32_t blob_duplicate(int fd, uint32_t
id_orig)
crtc_populate_req(crtc, req); \
plane_populate_req(plane, req); \
do_atomic_commit((crtc)->state->desc->fd, req, flags); \
-crtc_check_current_state(crtc, plane, relax); \
-plane_check_current_state(plane, relax); \
+if (!(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { \
+crtc_check_current_state(crtc, plane, relax); \
+plane_check_current_state(plane, relax); \
+} \
}

-#define crtc_commit_atomic_err(crtc, plane, crtc_old, plane_old, req,
relax, e) { \
+#define crtc_commit_atomic_err(crtc, plane, crtc_old, plane_old, req,
flags, relax, e) { \
drmModeAtomicSetCursor(req, 0); \
crtc_populate_req(crtc, req); \
plane_populate_req(plane, req); \
@@ -299,6 +304,9 @@ find_connector(struct kms_atomic_state *state,
static void plane_populate_req(struct kms_atomic_plane_state *plane,
   drmModeAtomicReq *req)
{
+if (plane->fence_fd)
+plane_set_prop(req, plane, IGT_PLANE_IN_FENCE_FD,
plane->fence_fd);
+
plane_set_prop(req, plane, IGT_PLANE_CRTC_ID, plane->crtc_id);
plane_set_prop(req, plane, IGT_PLANE_FB_ID, plane->fb_id);
plane_set_prop(req, plane, IGT_PLANE_SRC_X, plane->src_x);
@@ -433,6 +441,10 @@ find_plane(struct kms_atomic_state *state, enum
plane_type type,
static void crtc_populate_req(struct kms_atomic_crtc_state *crtc,
  drmModeAtomicReq *req)
{
+if (crtc->out_fence_ptr)
+crtc_set_prop(req, crtc, IGT_CRTC_OUT_FENCE_PTR,
+  crtc->out_fence_ptr);
+
crtc_set_prop(req, crtc, IGT_CRTC_MODE_ID, crtc->mode.id);
crtc_set_prop(req, crtc, IGT_CRTC_ACTIVE, crtc->active);
}
@@ -1061,6 +1073,37 @@ static void plane_invalid_params(struct
kms_atomic_crtc_state *crtc,
drmModeAtomicFree(req);
}

+static void plane_invalid_params_fence(struct kms_atomic_crtc_state
*crtc,
+struct kms_atomic_plane_state *plane_old,
+struct kms_atomic_connector_state *conn)
+{
+struct kms_atomic_plane_state plane = *plane_old;
+drmModeAtomicReq *req = drmModeAtomicAlloc();
+int timeline, fence_fd;
+
+igt_require_sw_sync();
+
+/* invalid fence fd */
+plane.fence_fd = plane.state->desc->fd;
+plane.crtc_id = plane_old->crtc_id;
+plane_commit_atomic_err(, plane_old, req,
+ATOMIC_RELAX_NONE, EINVAL);
+
+/* Valid fence_fd but invalid CRTC */
+timeline = sw_sync_timeline_create();
+fence_fd =  sw_sync_timeline_create_fence(timeline, 1);
+plane.fence_fd = fence_fd;
+plane.crtc_id = ~0U;
+plane_commit_atomic_err(, plane_old, req,
+ATOMIC_RELAX_NONE, EINVAL);
+
+plane.fence_fd = -1;
+close(fence_fd);
+close(timeline);
+
+drmModeAtomicFree(req);
+}
+
static void crtc_invalid_params(struct kms_atomic_crtc_state *crtc_old,
struct kms_atomic_plane_state *plane,
struct kms_atomic_connector_state *conn)
@@ -1072,30 +1115,32 @@ static void crtc_invalid_params(struct
kms_atomic_crtc_state *crtc_old,

/* Pass a series of invalid object IDs for the mode ID. */
crtc.mode.id = plane->obj;
-crtc_commit_atomic_err(, plane, crtc_old, plane, req,
+crtc_commit_atomic_err(, plane, crtc_old, plane, req, 0,
   ATOMIC_RELAX_NONE, EINVAL);

crtc.mode.id = crtc.obj;
-crtc_commit_atomic_err(, plane, crtc_old, plane, req,
+crtc_commit_atomic_err(, plane, crtc_old, plane, req, 0,
   ATOMIC_RELAX_NONE, EINVAL);

crtc.mode.id = conn-

Re: [Intel-gfx] [PATCH i-g-t v3 07/11] lib/igt_kms: Add support for the OUT_FENCE_PTR property

2017-01-31 Thread Robert Foss



On 2017-01-31 11:49 AM, Brian Starkey wrote:

On Mon, Jan 30, 2017 at 08:58:43PM -0500, Robert Foss wrote:

From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Add support for the OUT_FENCE_PTR property to enable setting out
fences for
atomic commits.

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
lib/igt_kms.c | 26 +-
lib/igt_kms.h |  6 +-
2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b79d2867..f14496dd 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -179,7 +179,8 @@ const char
*igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
"DEGAMMA_LUT",
"GAMMA_LUT",
"MODE_ID",
-"ACTIVE"
+"ACTIVE",
+"OUT_FENCE_PTR"
};

const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
@@ -2393,6 +2394,15 @@ static void
igt_atomic_prepare_crtc_commit(igt_pipe_t *pipe_obj, drmModeAtomicRe
igt_atomic_populate_crtc_req(req, pipe_obj, IGT_CRTC_ACTIVE,
!!output);
}

+pipe_obj->out_fence = -1;
+if (pipe_obj->out_fence_requested)
+{
+pipe_obj->out_fence_requested = false;
+igt_atomic_populate_crtc_req(req, pipe_obj,
IGT_CRTC_OUT_FENCE_PTR,
+(uint64_t)(uintptr_t) _obj->out_fence);
+igt_assert_f(pipe_obj->out_fence != -1, "Unable to get fence,
received -1 fd\n");


Doesn't this assertion always fail? You just set it to -1


Ack, fixed in v4


+}
+
/*
 *TODO: Add all crtc level properties here
 */
@@ -2984,6 +2994,20 @@ igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void
*ptr, size_t length)
}

/**
+ * igt_pipe_set_out_fence_ptr:
+ * @pipe: pipe pointer to which background color to be set
+ * @fence_ptr: out fence pointer
+ *
+ * Sets the out fence pointer that will be passed to the kernel in
+ * the atomic ioctl. When the kernel returns the out fence pointer
+ * will contain the fd number of the out fence created by KMS.
+ */
+void igt_pipe_set_out_fence_ptr(igt_pipe_t *pipe, int64_t *fence_ptr)
+{
+pipe->out_fence_ptr = fence_ptr;
+}


Is this ever used? You seem to use _obj->out_fence
unconditionally above (and igt_pipe has no member named
out_fence_ptr).

I guess is left over from the previous API and needs to be removed?


That's exactly what happened. Removed in v4.




+
+/**
 * igt_crtc_set_background:
 * @pipe: pipe pointer to which background color to be set
 * @background: background color value in BGR 16bpc
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 85688853..9672dadc 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -94,6 +94,7 @@ enum igt_atomic_crtc_properties {
   IGT_CRTC_GAMMA_LUT,
   IGT_CRTC_MODE_ID,
   IGT_CRTC_ACTIVE,
+   IGT_CRTC_OUT_FENCE_PTR,
   IGT_NUM_CRTC_PROPS
};

@@ -341,6 +342,9 @@ struct igt_pipe {

uint64_t mode_blob;
bool mode_changed;
+
+int64_t out_fence;
+bool out_fence_requested;
};

typedef struct {
@@ -395,7 +399,7 @@ static inline bool
igt_plane_supports_rotation(igt_plane_t *plane)
{
return plane->rotation_property != 0;
}
-
+void igt_pipe_request_out_fence(igt_pipe_t *pipe);


Not implemented? I think this patch got confused somewhere :-(

-Brian


Yes, some code has been moved around and this piece was not properly
moved. Fixed in v4.

Rob.



void igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t
length);
void igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, size_t length);
void igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
--
2.11.0.453.g787f75f05


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


Re: [Intel-gfx] [PATCH i-g-t v3 00/11] tests/kms_atomic_transition add fence testing

2017-01-31 Thread Robert Foss



On 2017-01-31 05:18 AM, Chris Wilson wrote:

On Mon, Jan 30, 2017 at 08:58:36PM -0500, Robert Foss wrote:

This series adds in/out fence testing to kms_atomic_transition test and makes 
some minor cleanups.

This series is rebased ontop of the dyn_n_planes_v3 series.

This series can be found here:
https://git.collabora.com/cgit/user/robertfoss/intel-gpu-tools.git/log/?h=fences_$VER


Changes since v1:

  lib/igt_kms:
   - Added gtk-doc for exported symbols
   - Changed integer casting to avoid potential issues
   - Changed out_fence_ptr type to int64_t*
   - Fixed igt_plane_set_fence_fd comment

  tests/:
   - Rework timeout change in commit_display()
   - Extract plane_invalid_params_fence() out plane_invalid_params()
   - Extract crtc_invalid_params_fence() out crtc_invalid_params()
   - Prevent add igt_require_sw_sync to subtests using sw_sync


Changes since v2:
  Rebased on upstream/master

  lib/igt_kms:
- Reset plane->fence_fd to -1 during igt_atomic_prepare_plane_commit()
- Rework out_fencs_ptr to be an int64_t named out_fence
- Add igt_pipe_request_out_fence()
  tests/:
- Switch to using igt_pipe_request_out_fence()
- Close out_fence fd
- Change out_fence to int64_t in run_transition_test()
- Added comments noting that two testcases are not invalid
- Added igt_pipe_get_last_out_fence() that wraps pipe->fence_out


Looks like this this missing the uabi conversion to s32 (int).
-Chris


Correct, I'll submit a v4 with this fix later today if no other major 
issues are reported.


Rob.
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t v3 09/11] tests/kms_atomic_transition: add fencing parameter to run_transition_tests

2017-01-30 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 tests/kms_atomic_transition.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 095af515..72429759 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -264,7 +264,7 @@ retry:
  */
 static void
 run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t 
*output,
-   enum transition_type type, bool nonblocking)
+   enum transition_type type, bool nonblocking, bool fencing)
 {
struct igt_fb fb, argb_fb, sprite_fb;
drmModeModeInfo *mode, override_mode;
@@ -674,19 +674,19 @@ igt_main
 
igt_subtest("plane-all-transition")
for_each_pipe_with_valid_output(, pipe, output)
-   run_transition_test(, pipe, output, 
TRANSITION_PLANES, false);
+   run_transition_test(, pipe, output, 
TRANSITION_PLANES, false, false);
 
igt_subtest("plane-all-transition-nonblocking")
for_each_pipe_with_valid_output(, pipe, output)
-   run_transition_test(, pipe, output, 
TRANSITION_PLANES, true);
+   run_transition_test(, pipe, output, 
TRANSITION_PLANES, true, false);
 
igt_subtest("plane-all-modeset-transition")
for_each_pipe_with_valid_output(, pipe, output)
-   run_transition_test(, pipe, output, 
TRANSITION_MODESET, false);
+   run_transition_test(, pipe, output, 
TRANSITION_MODESET, false, false);
 
igt_subtest("plane-toggle-modeset-transition")
for_each_pipe_with_valid_output(, pipe, output)
-   run_transition_test(, pipe, output, 
TRANSITION_MODESET_DISABLE, false);
+   run_transition_test(, pipe, output, 
TRANSITION_MODESET_DISABLE, false, false);
 
for (i = 1; i <= I915_MAX_PIPES; i++) {
igt_subtest_f("%ix-modeset-transitions", i)
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 10/11] tests/kms_atomic_transition: add out_fences tests

2017-01-30 Thread Robert Foss
Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c |  35 ++
 tests/kms_atomic_transition.c | 148 ++
 2 files changed, 169 insertions(+), 14 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index f14496dd..523f3f57 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -53,6 +53,7 @@
 #include "intel_chipset.h"
 #include "igt_debugfs.h"
 #include "igt_sysfs.h"
+#include "sw_sync.h"
 
 /**
  * SECTION:igt_kms
@@ -2479,6 +2480,21 @@ static int igt_atomic_commit(igt_display_t *display, 
uint32_t flags, void *user_
}
 
ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data);
+   if (!ret) {
+
+   for_each_pipe(display, pipe) {
+   igt_pipe_t *pipe_obj = >pipes[pipe];
+
+   if (pipe_obj->out_fence != -1)
+   continue;
+
+   igt_assert(pipe_obj->out_fence >= 0);
+   ret = sync_fence_wait(pipe_obj->out_fence, 1000);
+   igt_assert(ret == 0);
+   close(pipe_obj->out_fence);
+   }
+   }
+
drmModeAtomicFree(req);
return ret;
 
@@ -2972,6 +2988,11 @@ void igt_plane_set_rotation(igt_plane_t *plane, 
igt_rotation_t rotation)
plane->rotation_changed = true;
 }
 
+void igt_pipe_request_out_fence(igt_pipe_t *pipe)
+{
+   pipe->out_fence_requested = true;
+}
+
 void
 igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length)
 {
@@ -2994,20 +3015,6 @@ igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, 
size_t length)
 }
 
 /**
- * igt_pipe_set_out_fence_ptr:
- * @pipe: pipe pointer to which background color to be set
- * @fence_ptr: out fence pointer
- *
- * Sets the out fence pointer that will be passed to the kernel in
- * the atomic ioctl. When the kernel returns the out fence pointer
- * will contain the fd number of the out fence created by KMS.
- */
-void igt_pipe_set_out_fence_ptr(igt_pipe_t *pipe, int64_t *fence_ptr)
-{
-   pipe->out_fence_ptr = fence_ptr;
-}
-
-/**
  * igt_crtc_set_background:
  * @pipe: pipe pointer to which background color to be set
  * @background: background color value in BGR 16bpc
diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 72429759..eebb5d66 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -253,6 +253,93 @@ retry:
 sprite_width, sprite_height, alpha);
 }
 
+int *timeline;
+pthread_t *thread;
+int *seqno;
+
+static void prepare_fencing(igt_display_t *display, enum pipe pipe)
+{
+   igt_plane_t *plane;
+   int n_planes;
+
+   igt_require_sw_sync();
+
+   n_planes = display->pipes[pipe].n_planes;
+timeline = calloc(sizeof(*timeline), n_planes);
+igt_assert_f(timeline != NULL, "Failed to allocate memory for 
timelines\n");
+thread = calloc(sizeof(*thread), n_planes);
+igt_assert_f(thread != NULL, "Failed to allocate memory for thread\n");
+seqno = calloc(sizeof(*seqno), n_planes);
+igt_assert_f(seqno != NULL, "Failed to allocate memory for seqno\n");
+
+   for_each_plane_on_pipe(display, pipe, plane)
+   timeline[plane->index] = sw_sync_timeline_create();
+}
+
+static void unprepare_fencing(igt_display_t *display, enum pipe pipe)
+{
+   igt_plane_t *plane;
+
+   for_each_plane_on_pipe(display, pipe, plane)
+   close(timeline[plane->index]);
+
+   free(timeline);
+   free(thread);
+   free(seqno);
+}
+
+static void *fence_inc_thread(void *arg)
+{
+   int t = *((int *) arg);
+
+   pthread_detach(pthread_self());
+
+   usleep(5000);
+   sw_sync_timeline_inc(t, 1);
+   return NULL;
+}
+
+static void configure_fencing(igt_display_t *display, enum pipe pipe)
+{
+   igt_plane_t *plane;
+   int i, fd, ret;
+
+   for_each_plane_on_pipe(display, pipe, plane) {
+
+   if (!plane->fb)
+   continue;
+
+   i = plane->index;
+
+   seqno[i]++;
+   fd = sw_sync_timeline_create_fence(timeline[i], seqno[i]);
+   igt_plane_set_fence_fd(plane, fd);
+   ret = pthread_create([i], NULL, fence_inc_thread, 
[i]);
+   igt_assert_eq(ret, 0);
+   }
+}
+
+static void clear_fencing(igt_display_t *display, enum pipe pipe)
+{
+   igt_plane_t *plane;
+
+   for_each_plane_on_pipe(display, pipe, plane)
+   igt_plane_set_fence_fd(plane, -1);
+}
+
+static void atomic_commit(igt_display_t *display, enum pipe pipe, unsigned int 
flags, void *data, bool fencing)
+{
+   if (fencing) {
+   configure_fencing(display, pipe);
+   igt_p

[Intel-gfx] [PATCH i-g-t v3 08/11] tests/kms_atomic: stress possible fence settings

2017-01-30 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 tests/kms_atomic.c | 187 ++---
 1 file changed, 177 insertions(+), 10 deletions(-)

diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index 8df51ccd..09605e38 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -44,6 +44,7 @@
 #include "drmtest.h"
 #include "igt.h"
 #include "igt_aux.h"
+#include "sw_sync.h"
 
 #ifndef DRM_CLIENT_CAP_ATOMIC
 #define DRM_CLIENT_CAP_ATOMIC 3
@@ -126,6 +127,7 @@ struct kms_atomic_plane_state {
uint32_t fb_id; /* 0 to disable */
uint32_t src_x, src_y, src_w, src_h; /* 16.16 fixed-point */
uint32_t crtc_x, crtc_y, crtc_w, crtc_h; /* normal integers */
+   int32_t fence_fd;
 };
 
 struct kms_atomic_crtc_state {
@@ -133,6 +135,7 @@ struct kms_atomic_crtc_state {
uint32_t obj;
int idx;
bool active;
+   uint64_t out_fence_ptr;
struct kms_atomic_blob mode;
 };
 
@@ -190,11 +193,13 @@ static uint32_t blob_duplicate(int fd, uint32_t id_orig)
crtc_populate_req(crtc, req); \
plane_populate_req(plane, req); \
do_atomic_commit((crtc)->state->desc->fd, req, flags); \
-   crtc_check_current_state(crtc, plane, relax); \
-   plane_check_current_state(plane, relax); \
+   if (!(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { \
+   crtc_check_current_state(crtc, plane, relax); \
+   plane_check_current_state(plane, relax); \
+   } \
 }
 
-#define crtc_commit_atomic_err(crtc, plane, crtc_old, plane_old, req, relax, 
e) { \
+#define crtc_commit_atomic_err(crtc, plane, crtc_old, plane_old, req, flags, 
relax, e) { \
drmModeAtomicSetCursor(req, 0); \
crtc_populate_req(crtc, req); \
plane_populate_req(plane, req); \
@@ -299,6 +304,9 @@ find_connector(struct kms_atomic_state *state,
 static void plane_populate_req(struct kms_atomic_plane_state *plane,
   drmModeAtomicReq *req)
 {
+   if (plane->fence_fd)
+   plane_set_prop(req, plane, IGT_PLANE_IN_FENCE_FD, 
plane->fence_fd);
+
plane_set_prop(req, plane, IGT_PLANE_CRTC_ID, plane->crtc_id);
plane_set_prop(req, plane, IGT_PLANE_FB_ID, plane->fb_id);
plane_set_prop(req, plane, IGT_PLANE_SRC_X, plane->src_x);
@@ -433,6 +441,10 @@ find_plane(struct kms_atomic_state *state, enum plane_type 
type,
 static void crtc_populate_req(struct kms_atomic_crtc_state *crtc,
  drmModeAtomicReq *req)
 {
+   if (crtc->out_fence_ptr)
+   crtc_set_prop(req, crtc, IGT_CRTC_OUT_FENCE_PTR,
+ crtc->out_fence_ptr);
+
crtc_set_prop(req, crtc, IGT_CRTC_MODE_ID, crtc->mode.id);
crtc_set_prop(req, crtc, IGT_CRTC_ACTIVE, crtc->active);
 }
@@ -1061,6 +1073,37 @@ static void plane_invalid_params(struct 
kms_atomic_crtc_state *crtc,
drmModeAtomicFree(req);
 }
 
+static void plane_invalid_params_fence(struct kms_atomic_crtc_state *crtc,
+   struct kms_atomic_plane_state *plane_old,
+   struct kms_atomic_connector_state *conn)
+{
+   struct kms_atomic_plane_state plane = *plane_old;
+   drmModeAtomicReq *req = drmModeAtomicAlloc();
+   int timeline, fence_fd;
+
+   igt_require_sw_sync();
+
+   /* invalid fence fd */
+   plane.fence_fd = plane.state->desc->fd;
+   plane.crtc_id = plane_old->crtc_id;
+   plane_commit_atomic_err(, plane_old, req,
+   ATOMIC_RELAX_NONE, EINVAL);
+
+   /* Valid fence_fd but invalid CRTC */
+   timeline = sw_sync_timeline_create();
+   fence_fd =  sw_sync_timeline_create_fence(timeline, 1);
+   plane.fence_fd = fence_fd;
+   plane.crtc_id = ~0U;
+   plane_commit_atomic_err(, plane_old, req,
+   ATOMIC_RELAX_NONE, EINVAL);
+
+   plane.fence_fd = -1;
+   close(fence_fd);
+   close(timeline);
+
+   drmModeAtomicFree(req);
+}
+
 static void crtc_invalid_params(struct kms_atomic_crtc_state *crtc_old,
struct kms_atomic_plane_state *plane,
struct kms_atomic_connector_state *conn)
@@ -1072,30 +1115,32 @@ static void crtc_invalid_params(struct 
kms_atomic_crtc_state *crtc_old,
 
/* Pass a series of invalid object IDs for the mode ID. */
crtc.mode.id = plane->obj;
-   crtc_commit_atomic_err(, plane, crtc_old, plane, req,
+   crtc_commit_atomic_err(, plane, crtc_old, plane, req, 0,
   ATOMIC_RELAX_NONE, EINVAL);
 
crtc.mode.id = crtc.obj;
-   crtc_commit_atomic_err(, plane, crtc_old, plane, req,
+   crt

[Intel-gfx] [PATCH i-g-t v3 11/11] tests/kms_atomic_transition: add in_fences tests

2017-01-30 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c |  3 +++
 tests/kms_atomic_transition.c | 48 ++-
 2 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 523f3f57..bc815363 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2009,6 +2009,9 @@ igt_atomic_prepare_plane_commit(igt_plane_t *plane, 
igt_pipe_t *pipe,
if (plane->fence_fd >= 0) {
uint64_t fence_fd = (int64_t) plane->fence_fd;
igt_atomic_populate_plane_req(req, plane, 
IGT_PLANE_IN_FENCE_FD, fence_fd);
+
+   /* reset fence_fd to prevent it from being set for the next 
commit */
+   plane->fence_fd = -1;
}
 
if (plane->fb_changed) {
diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index eebb5d66..0876bbb3 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -23,7 +23,9 @@
 
 #include "igt.h"
 #include "drmtest.h"
+#include "sw_sync.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -362,6 +364,9 @@ run_transition_test(igt_display_t *display, enum pipe pipe, 
igt_output_t *output
unsigned flags = DRM_MODE_PAGE_FLIP_EVENT;
int ret;
 
+   if (fencing)
+   prepare_fencing(display, pipe);
+
if (nonblocking)
flags |= DRM_MODE_ATOMIC_NONBLOCK;
 
@@ -404,18 +409,19 @@ run_transition_test(igt_display_t *display, enum pipe 
pipe, igt_output_t *output
wm_setup_plane(display, pipe, iter_max - 1, parms);
 
if (fencing)
-   igt_pipe_set_out_fence_ptr(>pipes[pipe],
-   (int64_t *) _fence);
+   igt_pipe_request_out_fence(>pipes[pipe]);
+
ret = igt_display_try_commit_atomic(display, 
DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
 
-   if (ret != -EINVAL || n_planes < 3)
+   if (ret != -EINVAL || display->pipes[pipe].n_planes < 3)
break;
 
ret = 0;
for_each_plane_on_pipe(display, pipe, plane) {
i = plane->index;
 
-   if (plane->is_primary || plane->is_cursor)
+   if (plane->type == DRM_PLANE_TYPE_PRIMARY ||
+   plane->type == DRM_PLANE_TYPE_CURSOR)
continue;
 
if (parms[i].width <= 512)
@@ -436,10 +442,8 @@ run_transition_test(igt_display_t *display, enum pipe 
pipe, igt_output_t *output
 
wm_setup_plane(display, pipe, i, parms);
 
-   if (fencing)
-   igt_pipe_set_out_fence_ptr(>pipes[pipe], 
_fence);
+   atomic_commit(display, pipe, flags, (void *)(unsigned long)i, 
fencing);
 
-   igt_display_commit_atomic(display, flags, (void *)(unsigned 
long)i);
drmHandleEvent(display->drm_fd, _events);
 
if (type == TRANSITION_MODESET_DISABLE) {
@@ -463,19 +467,14 @@ run_transition_test(igt_display_t *display, enum pipe 
pipe, igt_output_t *output
if (type == TRANSITION_MODESET)
igt_output_override_mode(output, 
_mode);
 
-   if (fencing)
-   
igt_pipe_set_out_fence_ptr(>pipes[pipe], _fence);
-
-   igt_display_commit_atomic(display, flags, (void 
*)(unsigned long)j);
+   atomic_commit(display, pipe, flags, (void 
*)(unsigned long)i, fencing);
drmHandleEvent(display->drm_fd, _events);
 
wm_setup_plane(display, pipe, i, parms);
if (type == TRANSITION_MODESET)
igt_output_override_mode(output, NULL);
 
-   if (fencing)
-   
igt_pipe_set_out_fence_ptr(>pipes[pipe], _fence);
-
+   atomic_commit(display, pipe, flags, (void 
*)(unsigned long)i, fencing);
igt_display_commit_atomic(display, flags, (void 
*)(unsigned long)i);
drmHandleEvent(display->drm_fd, _events);
}
@@ -483,6 +482,8 @@ run_transition_test(igt_display_t *display, enum pipe pipe, 
igt_output_t *output
}
 
 cleanup:
+   unprepare_fencing(display, pipe);
+
igt_output_set_pipe(output, PIPE_NONE);
 
for_each_plane_on_pipe(display, pipe, plane)
@@ -617,7 +618,7 @@ static void collect_crcs_ma

[Intel-gfx] [PATCH i-g-t v3 05/11] lib/igt_kms: Added igt_pipe_get_last_out_fence()

2017-01-30 Thread Robert Foss
Added the igt_pipe_get_last_out_fence() helper function
that wraps accesses to pipe->fence_out.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c | 8 
 lib/igt_kms.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 142658a6..f0e38b75 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1934,6 +1934,14 @@ static igt_output_t *igt_pipe_get_output(igt_pipe_t 
*pipe)
return NULL;
 }
 
+int igt_pipe_get_last_out_fence(igt_pipe_t *pipe)
+{
+   int fd = (int) pipe->out_fence;
+   pipe->out_fence = -1;
+
+   return fd;
+}
+
 bool igt_pipe_get_property(igt_pipe_t *pipe, const char *name,
   uint32_t *prop_id, uint64_t *value,
   drmModePropertyPtr *prop)
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 00e0dc68..94ff27bb 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -382,6 +382,7 @@ igt_plane_t *igt_output_get_plane_type(igt_output_t 
*output, int plane_type);
 igt_output_t *igt_output_from_connector(igt_display_t *display,
 drmModeConnector *connector);
 igt_plane_t *igt_pipe_get_plane_type(igt_pipe_t *pipe, int plane_type);
+int igt_pipe_get_last_out_fence(igt_pipe_t *pipe);
 bool igt_pipe_get_property(igt_pipe_t *pipe, const char *name,
   uint32_t *prop_id, uint64_t *value,
   drmModePropertyPtr *prop);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 07/11] lib/igt_kms: Add support for the OUT_FENCE_PTR property

2017-01-30 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Add support for the OUT_FENCE_PTR property to enable setting out fences for
atomic commits.

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c | 26 +-
 lib/igt_kms.h |  6 +-
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b79d2867..f14496dd 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -179,7 +179,8 @@ const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
"DEGAMMA_LUT",
"GAMMA_LUT",
"MODE_ID",
-   "ACTIVE"
+   "ACTIVE",
+   "OUT_FENCE_PTR"
 };
 
 const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
@@ -2393,6 +2394,15 @@ static void igt_atomic_prepare_crtc_commit(igt_pipe_t 
*pipe_obj, drmModeAtomicRe
igt_atomic_populate_crtc_req(req, pipe_obj, IGT_CRTC_ACTIVE, 
!!output);
}
 
+   pipe_obj->out_fence = -1;
+   if (pipe_obj->out_fence_requested)
+   {
+   pipe_obj->out_fence_requested = false;
+   igt_atomic_populate_crtc_req(req, pipe_obj, 
IGT_CRTC_OUT_FENCE_PTR,
+   (uint64_t)(uintptr_t) _obj->out_fence);
+   igt_assert_f(pipe_obj->out_fence != -1, "Unable to get fence, 
received -1 fd\n");
+   }
+
/*
 *  TODO: Add all crtc level properties here
 */
@@ -2984,6 +2994,20 @@ igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, 
size_t length)
 }
 
 /**
+ * igt_pipe_set_out_fence_ptr:
+ * @pipe: pipe pointer to which background color to be set
+ * @fence_ptr: out fence pointer
+ *
+ * Sets the out fence pointer that will be passed to the kernel in
+ * the atomic ioctl. When the kernel returns the out fence pointer
+ * will contain the fd number of the out fence created by KMS.
+ */
+void igt_pipe_set_out_fence_ptr(igt_pipe_t *pipe, int64_t *fence_ptr)
+{
+   pipe->out_fence_ptr = fence_ptr;
+}
+
+/**
  * igt_crtc_set_background:
  * @pipe: pipe pointer to which background color to be set
  * @background: background color value in BGR 16bpc
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 85688853..9672dadc 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -94,6 +94,7 @@ enum igt_atomic_crtc_properties {
IGT_CRTC_GAMMA_LUT,
IGT_CRTC_MODE_ID,
IGT_CRTC_ACTIVE,
+   IGT_CRTC_OUT_FENCE_PTR,
IGT_NUM_CRTC_PROPS
 };
 
@@ -341,6 +342,9 @@ struct igt_pipe {
 
uint64_t mode_blob;
bool mode_changed;
+
+   int64_t out_fence;
+   bool out_fence_requested;
 };
 
 typedef struct {
@@ -395,7 +399,7 @@ static inline bool igt_plane_supports_rotation(igt_plane_t 
*plane)
 {
return plane->rotation_property != 0;
 }
-
+void igt_pipe_request_out_fence(igt_pipe_t *pipe);
 void igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
 void igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, size_t length);
 void igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 06/11] lib/igt_kms: Add support for the IN_FENCE_FD property

2017-01-30 Thread Robert Foss
Add support dor the IN_FENCE_FD property to enable setting in fences for atomic
commits.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c | 20 
 lib/igt_kms.h |  5 +
 2 files changed, 25 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index f0e38b75..b79d2867 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -168,6 +168,7 @@ const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
"CRTC_H",
"FB_ID",
"CRTC_ID",
+   "IN_FENCE_FD",
"type",
"rotation"
 };
@@ -1667,6 +1668,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
plane->type = type;
plane->pipe = pipe;
plane->drm_plane = drm_plane;
+   plane->fence_fd = -1;
 
if (is_atomic == 0) {
display->is_atomic = 1;
@@ -2002,6 +2004,11 @@ igt_atomic_prepare_plane_commit(igt_plane_t *plane, 
igt_pipe_t *pipe,
plane->index,
fb_id);
 
+   if (plane->fence_fd >= 0) {
+   uint64_t fence_fd = (int64_t) plane->fence_fd;
+   igt_atomic_populate_plane_req(req, plane, 
IGT_PLANE_IN_FENCE_FD, fence_fd);
+   }
+
if (plane->fb_changed) {
igt_atomic_populate_plane_req(req, plane, IGT_PLANE_CRTC_ID, 
fb_id ? crtc_id : 0);
igt_atomic_populate_plane_req(req, plane, IGT_PLANE_FB_ID, 
fb_id);
@@ -2823,6 +2830,19 @@ void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb 
*fb)
plane->size_changed = true;
 }
 
+/**
+ * igt_plane_set_fence_fd:
+ * @plane: plane
+ * @fence_fd: fence fd, disable fence_fd by setting it to -1
+ *
+ * This function sets a fence fd to enable a commit to wait for some event to
+ * occur before completing.
+ */
+void igt_plane_set_fence_fd(igt_plane_t *plane, uint32_t fence_fd)
+{
+   plane->fence_fd = fence_fd;
+}
+
 void igt_plane_set_position(igt_plane_t *plane, int x, int y)
 {
igt_pipe_t *pipe = plane->pipe;
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 94ff27bb..85688853 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -248,6 +248,7 @@ enum igt_atomic_plane_properties {
 
IGT_PLANE_FB_ID,
IGT_PLANE_CRTC_ID,
+   IGT_PLANE_IN_FENCE_FD,
IGT_PLANE_TYPE,
IGT_PLANE_ROTATION,
IGT_NUM_PLANE_PROPS
@@ -306,6 +307,9 @@ typedef struct {
uint32_t src_h;
 
igt_rotation_t rotation;
+
+   /* in fence fd */
+   int32_t fence_fd;
uint32_t atomic_props_plane[IGT_NUM_PLANE_PROPS];
 } igt_plane_t;
 
@@ -397,6 +401,7 @@ void igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, 
size_t length);
 void igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
 
 void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb);
+void igt_plane_set_fence_fd(igt_plane_t *plane, uint32_t fence_fd);
 void igt_plane_set_position(igt_plane_t *plane, int x, int y);
 void igt_plane_set_size(igt_plane_t *plane, int w, int h);
 void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 04/11] tests/kms_atomic: use global atomic properties definitions

2017-01-30 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 tests/kms_atomic.c | 123 -
 1 file changed, 37 insertions(+), 86 deletions(-)

diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index e6d71c31..8df51ccd 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -105,55 +105,6 @@ static const char 
*plane_type_prop_names[NUM_PLANE_TYPE_PROPS] = {
"Cursor"
 };
 
-enum plane_properties {
-   PLANE_SRC_X = 0,
-   PLANE_SRC_Y,
-   PLANE_SRC_W,
-   PLANE_SRC_H,
-   PLANE_CRTC_X,
-   PLANE_CRTC_Y,
-   PLANE_CRTC_W,
-   PLANE_CRTC_H,
-   PLANE_FB_ID,
-   PLANE_CRTC_ID,
-   PLANE_TYPE,
-   NUM_PLANE_PROPS
-};
-
-static const char *plane_prop_names[NUM_PLANE_PROPS] = {
-   "SRC_X",
-   "SRC_Y",
-   "SRC_W",
-   "SRC_H",
-   "CRTC_X",
-   "CRTC_Y",
-   "CRTC_W",
-   "CRTC_H",
-   "FB_ID",
-   "CRTC_ID",
-   "type"
-};
-
-enum crtc_properties {
-   CRTC_MODE_ID = 0,
-   CRTC_ACTIVE,
-   NUM_CRTC_PROPS
-};
-
-static const char *crtc_prop_names[NUM_CRTC_PROPS] = {
-   "MODE_ID",
-   "ACTIVE"
-};
-
-enum connector_properties {
-   CONNECTOR_CRTC_ID = 0,
-   NUM_CONNECTOR_PROPS
-};
-
-static const char *connector_prop_names[NUM_CONNECTOR_PROPS] = {
-   "CRTC_ID"
-};
-
 struct kms_atomic_blob {
uint32_t id; /* 0 if not already allocated */
size_t len;
@@ -197,9 +148,9 @@ struct kms_atomic_state {
 
 struct kms_atomic_desc {
int fd;
-   uint32_t props_connector[NUM_CONNECTOR_PROPS];
-   uint32_t props_crtc[NUM_CRTC_PROPS];
-   uint32_t props_plane[NUM_PLANE_PROPS];
+   uint32_t props_connector[IGT_NUM_CONNECTOR_PROPS];
+   uint32_t props_crtc[IGT_NUM_CRTC_PROPS];
+   uint32_t props_plane[IGT_NUM_PLANE_PROPS];
uint64_t props_plane_type[NUM_PLANE_TYPE_PROPS];
 };
 
@@ -280,7 +231,7 @@ connector_get_current_state(struct 
kms_atomic_connector_state *connector)
for (i = 0; i < props->count_props; i++) {
uint32_t *prop_ids = connector->state->desc->props_connector;
 
-   if (props->props[i] == prop_ids[CONNECTOR_CRTC_ID])
+   if (props->props[i] == prop_ids[IGT_CONNECTOR_CRTC_ID])
connector->crtc_id = props->prop_values[i];
}
drmModeFreeObjectProperties(props);
@@ -348,16 +299,16 @@ find_connector(struct kms_atomic_state *state,
 static void plane_populate_req(struct kms_atomic_plane_state *plane,
   drmModeAtomicReq *req)
 {
-   plane_set_prop(req, plane, PLANE_CRTC_ID, plane->crtc_id);
-   plane_set_prop(req, plane, PLANE_FB_ID, plane->fb_id);
-   plane_set_prop(req, plane, PLANE_SRC_X, plane->src_x);
-   plane_set_prop(req, plane, PLANE_SRC_Y, plane->src_y);
-   plane_set_prop(req, plane, PLANE_SRC_W, plane->src_w);
-   plane_set_prop(req, plane, PLANE_SRC_H, plane->src_h);
-   plane_set_prop(req, plane, PLANE_CRTC_X, plane->crtc_x);
-   plane_set_prop(req, plane, PLANE_CRTC_Y, plane->crtc_y);
-   plane_set_prop(req, plane, PLANE_CRTC_W, plane->crtc_w);
-   plane_set_prop(req, plane, PLANE_CRTC_H, plane->crtc_h);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_ID, plane->crtc_id);
+   plane_set_prop(req, plane, IGT_PLANE_FB_ID, plane->fb_id);
+   plane_set_prop(req, plane, IGT_PLANE_SRC_X, plane->src_x);
+   plane_set_prop(req, plane, IGT_PLANE_SRC_Y, plane->src_y);
+   plane_set_prop(req, plane, IGT_PLANE_SRC_W, plane->src_w);
+   plane_set_prop(req, plane, IGT_PLANE_SRC_H, plane->src_h);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_X, plane->crtc_x);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_Y, plane->crtc_y);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_W, plane->crtc_w);
+   plane_set_prop(req, plane, IGT_PLANE_CRTC_H, plane->crtc_h);
 }
 
 static void plane_get_current_state(struct kms_atomic_plane_state *plane)
@@ -373,27 +324,27 @@ static void plane_get_current_state(struct 
kms_atomic_plane_state *plane)
for (i = 0; i < props->count_props; i++) {
uint32_t *prop_ids = desc->props_plane;
 
-   if (props->props[i] == prop_ids[PLANE_CRTC_ID])
+   if (props->props[i] == prop_ids[IGT_PLANE_CRTC_ID])
plane->crtc_id = props->prop_values[i];
-   else if (props->props[i] == prop_ids[PLANE_FB_ID])
+   else if (props->props[i] == prop_ids[IGT_PLANE_FB_ID])
plane->f

[Intel-gfx] [PATCH i-g-t v3 03/11] lib/igt_kms: export properties names

2017-01-30 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c |  6 +++---
 lib/igt_kms.h | 23 +++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 41acce45..142658a6 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -157,7 +157,7 @@ const unsigned char* igt_kms_get_base_edid(void)
 #define EDID_NAME alt_edid
 #include "igt_edid_template.h"
 
-static const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
+const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
"SRC_X",
"SRC_Y",
"SRC_W",
@@ -172,7 +172,7 @@ static const char 
*igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
"rotation"
 };
 
-static const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
+const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
"background_color",
"CTM",
"DEGAMMA_LUT",
@@ -181,7 +181,7 @@ static const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] 
= {
"ACTIVE"
 };
 
-static const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
+const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
"scaling mode",
"CRTC_ID"
 };
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 25626187..00e0dc68 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -97,12 +97,28 @@ enum igt_atomic_crtc_properties {
IGT_NUM_CRTC_PROPS
 };
 
+/**
+ * igt_crtc_prop_names
+ *
+ * igt_crtc_prop_names contains a list of crtc property names,
+ * as indexed by the igt_atomic_crtc_properties enum.
+ */
+extern const char *igt_crtc_prop_names[];
+
 enum igt_atomic_connector_properties {
IGT_CONNECTOR_SCALING_MODE = 0,
IGT_CONNECTOR_CRTC_ID,
IGT_NUM_CONNECTOR_PROPS
 };
 
+/**
+ * igt_connector_prop_names
+ *
+ * igt_connector_prop_names contains a list of crtc property names,
+ * as indexed by the igt_atomic_connector_properties enum.
+ */
+extern const char *igt_connector_prop_names[];
+
 struct kmstest_connector_config {
drmModeCrtc *crtc;
drmModeConnector *connector;
@@ -237,6 +253,13 @@ enum igt_atomic_plane_properties {
IGT_NUM_PLANE_PROPS
 };
 
+/**
+ * igt_plane_prop_names
+ *
+ * igt_plane_prop_names contains a list of crtc property names,
+ * as indexed by the igt_atomic_plane_properties enum.
+ */
+extern const char *igt_plane_prop_names[];
 
 typedef struct igt_display igt_display_t;
 typedef struct igt_pipe igt_pipe_t;
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 00/11] tests/kms_atomic_transition add fence testing

2017-01-30 Thread Robert Foss
This series adds in/out fence testing to kms_atomic_transition test and makes 
some minor cleanups.

This series is rebased ontop of the dyn_n_planes_v3 series.

This series can be found here:
https://git.collabora.com/cgit/user/robertfoss/intel-gpu-tools.git/log/?h=fences_$VER


Changes since v1:

  lib/igt_kms:
   - Added gtk-doc for exported symbols
   - Changed integer casting to avoid potential issues
   - Changed out_fence_ptr type to int64_t*
   - Fixed igt_plane_set_fence_fd comment

  tests/:
   - Rework timeout change in commit_display()
   - Extract plane_invalid_params_fence() out plane_invalid_params()
   - Extract crtc_invalid_params_fence() out crtc_invalid_params()
   - Prevent add igt_require_sw_sync to subtests using sw_sync


Changes since v2:
  Rebased on upstream/master

  lib/igt_kms:
- Reset plane->fence_fd to -1 during igt_atomic_prepare_plane_commit()
- Rework out_fencs_ptr to be an int64_t named out_fence
- Add igt_pipe_request_out_fence()
  tests/:
- Switch to using igt_pipe_request_out_fence()
- Close out_fence fd
- Change out_fence to int64_t in run_transition_test()
- Added comments noting that two testcases are not invalid
- Added igt_pipe_get_last_out_fence() that wraps pipe->fence_out

Gustavo Padovan (8):
  tests/kms_atomic_transition: use igt timeout instead of blocking
  lib/igt_kms: move igt_kms_get_alt_edid() to the right place
  lib/igt_kms: export properties names
  tests/kms_atomic: use global atomic properties definitions
  lib/igt_kms: Add support for the OUT_FENCE_PTR property
  tests/kms_atomic: stress possible fence settings
  tests/kms_atomic_transition: add fencing parameter to
run_transition_tests
  tests/kms_atomic_transition: add in_fences tests

Robert Foss (3):
  lib/igt_kms: Added igt_pipe_get_last_out_fence()
  lib/igt_kms: Add support for the IN_FENCE_FD property
  tests/kms_atomic_transition: add out_fences tests

 lib/igt_kms.c | 104 +++---
 lib/igt_kms.h |  35 -
 tests/kms_atomic.c| 310 +-
 tests/kms_atomic_transition.c | 184 +++--
 4 files changed, 503 insertions(+), 130 deletions(-)

-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 01/11] tests/kms_atomic_transition: use igt timeout instead of blocking

2017-01-30 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

If the event never arrives we can timeout and end the test.

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 tests/kms_atomic_transition.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 5fdb6175..095af515 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -383,7 +383,9 @@ static void commit_display(igt_display_t *display, unsigned 
event_mask, bool non
struct drm_event_vblank *vblank = (void *)buf;
uint32_t crtc_id, pipe = I915_MAX_PIPES;
 
+   igt_set_timeout(3, "Timed out while reading drm_fd\n");
ret = read(display->drm_fd, buf, sizeof(buf));
+   igt_reset_timeout();
if (ret < 0 && (errno == EINTR || errno == EAGAIN))
continue;
 
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 02/11] lib/igt_kms: move igt_kms_get_alt_edid() to the right place

2017-01-30 Thread Robert Foss
From: Gustavo Padovan <gustavo.pado...@collabora.co.uk>

Signed-off-by: Gustavo Padovan <gustavo.pado...@collabora.co.uk>
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/igt_kms.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 4ba6316d..41acce45 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -157,23 +157,6 @@ const unsigned char* igt_kms_get_base_edid(void)
 #define EDID_NAME alt_edid
 #include "igt_edid_template.h"
 
-/**
- * igt_kms_get_alt_edid:
- *
- * Get an alternate edid block, which includes the following modes:
- *
- *  - 1400x1050 60Hz
- *  - 1920x1080 60Hz
- *  - 1280x720 60Hz
- *  - 1024x768 60Hz
- *  - 800x600 60Hz
- *  - 640x480 60Hz
- *
- * This can be extended with further features using functions such as
- * #kmstest_edid_add_3d.
- *
- * Returns: an alternate edid block
- */
 static const char *igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
"SRC_X",
"SRC_Y",
@@ -301,6 +284,23 @@ igt_atomic_fill_pipe_props(igt_display_t *display, 
igt_pipe_t *pipe,
drmModeFreeObjectProperties(props);
 }
 
+/**
+ * igt_kms_get_alt_edid:
+ *
+ * Get an alternate edid block, which includes the following modes:
+ *
+ *  - 1400x1050 60Hz
+ *  - 1920x1080 60Hz
+ *  - 1280x720 60Hz
+ *  - 1024x768 60Hz
+ *  - 800x600 60Hz
+ *  - 640x480 60Hz
+ *
+ * This can be extended with further features using functions such as
+ * #kmstest_edid_add_3d.
+ *
+ * Returns: an alternate edid block
+ */
 const unsigned char* igt_kms_get_alt_edid(void)
 {
update_edid_csum(alt_edid);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v1] lib/drmtest: Add comment explaining DRIVER_ANY excluding DRIVER_VGEM

2017-01-30 Thread Robert Foss
Signed-off-by: Robert Foss <robert.f...@collabora.com>
---
 lib/drmtest.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/lib/drmtest.h b/lib/drmtest.h
index 19d4bd19..c9c019c0 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -42,8 +42,15 @@
 #define DRIVER_VC4 (1 << 1)
 #define DRIVER_VGEM(1 << 2)
 #define DRIVER_VIRTIO  (1 << 3)
+/*
+ * Exclude DRVER_VGEM from DRIVER_ANY since if you run on a system
+ * with vgem as well as a supported driver, you can end up with a
+ * near-100% skip rate if you don't explicitly specify the device,
+ * depending on device-load ordering.
+ */
 #define DRIVER_ANY ~(DRIVER_VGEM)
 
+
 #ifdef ANDROID
 #if (!(defined HAVE_MMAP64)) && (!(defined __x86_64__))
 extern void*  __mmap2(void *, size_t, int, int, int, off_t);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 17/33] tests/kms_panel_fitting: Add support for dynamic number of planes

2017-01-30 Thread Robert Foss
Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_panel_fitting.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tests/kms_panel_fitting.c b/tests/kms_panel_fitting.c
index 1b350762..e145a2df 100644
--- a/tests/kms_panel_fitting.c
+++ b/tests/kms_panel_fitting.c
@@ -76,10 +76,10 @@ static void prepare_crtc(data_t *data, igt_output_t 
*output, enum pipe pipe,
 * there's no way (that works) to light up a pipe with only a sprite
 * plane enabled at the moment.
 */
-   if (!plane->is_primary) {
+   if (plane->type != DRM_PLANE_TYPE_PRIMARY) {
igt_plane_t *primary;
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_PRIMARY);
igt_plane_set_fb(primary, >fb1);
}
 
@@ -116,10 +116,10 @@ static void cleanup_crtc(data_t *data, igt_output_t 
*output, igt_plane_t *plane)
data->fb_id3 = 0;
}
 
-   if (!plane->is_primary) {
+   if (plane->type != DRM_PLANE_TYPE_PRIMARY) {
igt_plane_t *primary;
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_PRIMARY);
igt_plane_set_fb(primary, NULL);
}
 
@@ -174,7 +174,7 @@ static void test_panel_fitting(data_t *d)
/* Set up display to enable panel fitting */
mode->hdisplay = 640;
mode->vdisplay = 480;
-   d->plane1 = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   d->plane1 = igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_PRIMARY);
prepare_crtc(d, output, pipe, d->plane1, mode, COMMIT_LEGACY);
 
/* disable panel fitting */
@@ -189,7 +189,7 @@ static void test_panel_fitting(data_t *d)
prepare_crtc(d, output, pipe, d->plane1, _mode, 
COMMIT_LEGACY);
 
/* Set up fb2->plane2 mapping. */
-   d->plane2 = igt_output_get_plane(output, IGT_PLANE_2);
+   d->plane2 = igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_OVERLAY);
igt_plane_set_fb(d->plane2, >fb2);
 
/* enable sprite plane */
@@ -226,8 +226,8 @@ test_panel_fitting_fastset(igt_display_t *display, const 
enum pipe pipe, igt_out
igt_output_override_mode(output, );
igt_output_set_pipe(output, pipe);
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
-   sprite = igt_output_get_plane(output, IGT_PLANE_2);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+   sprite = igt_output_get_plane_type(output, DRM_PLANE_TYPE_OVERLAY);
 
igt_create_color_fb(display->drm_fd, mode.hdisplay, mode.vdisplay,
DRM_FORMAT_XRGB, LOCAL_DRM_FORMAT_MOD_NONE,
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 31/33] tests/kms_ccs: Add support for dynamic number of planes

2017-01-30 Thread Robert Foss
Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_ccs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/kms_ccs.c b/tests/kms_ccs.c
index 047a3e87..11acda89 100644
--- a/tests/kms_ccs.c
+++ b/tests/kms_ccs.c
@@ -182,7 +182,7 @@ static void display_fb(data_t *data, int compressed)
render_ccs(data, f.handles[0], f.offsets[1], size[1],
   f.width/16, f.height/8, f.pitches[1]);
 
-   primary = igt_output_get_plane(data->output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(data->output, 
DRM_PLANE_TYPE_PRIMARY);
igt_plane_set_fb(primary, fb);
 
if (data->flags & TEST_ROTATE_180)
@@ -231,7 +231,7 @@ static void test_output(data_t *data)
display_fb(data, TEST_COMPRESSED);
}
 
-   primary = igt_output_get_plane(data->output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(data->output, 
DRM_PLANE_TYPE_PRIMARY);
igt_plane_set_fb(primary, NULL);
igt_plane_set_rotation(primary, IGT_ROTATION_0);
if (!display->is_atomic)
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 28/33] tests/kms_universal_plane: Add support for dynamic number of planes

2017-01-30 Thread Robert Foss
Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_universal_plane.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tests/kms_universal_plane.c b/tests/kms_universal_plane.c
index 48560212..a2fe1cc1 100644
--- a/tests/kms_universal_plane.c
+++ b/tests/kms_universal_plane.c
@@ -148,16 +148,16 @@ functional_test_pipe(data_t *data, enum pipe pipe, 
igt_output_t *output)
 * boolean and show up in userspace as the wrong type.
 */
for (i = 0; i < display->pipes[pipe].n_planes; i++)
-   if (display->pipes[pipe].planes[i].is_primary)
+   if (display->pipes[pipe].planes[i].type == 
DRM_PLANE_TYPE_PRIMARY)
num_primary++;
-   else if (display->pipes[pipe].planes[i].is_cursor)
+   else if (display->pipes[pipe].planes[i].type == 
DRM_PLANE_TYPE_CURSOR)
num_cursor++;
 
igt_assert_eq(num_primary, 1);
igt_assert_lte(num_cursor, 1);
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
-   sprite = igt_output_get_plane(output, IGT_PLANE_2);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+   sprite = igt_output_get_plane_type(output, DRM_PLANE_TYPE_OVERLAY);
if (!sprite) {
functional_test_fini(, output);
igt_skip("No sprite plane available\n");
@@ -369,7 +369,7 @@ sanity_test_pipe(data_t *data, enum pipe pipe, igt_output_t 
*output)
 
sanity_test_init(, output, pipe);
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
 
/* Use legacy API to set a mode with a blue FB */
igt_plane_set_fb(primary, _fb);
@@ -480,7 +480,7 @@ pageflip_test_pipe(data_t *data, enum pipe pipe, 
igt_output_t *output)
 
pageflip_test_init(, output, pipe);
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
 
/* Use legacy API to set a mode with a blue FB */
igt_plane_set_fb(primary, _fb);
@@ -602,8 +602,8 @@ cursor_leak_test_pipe(data_t *data, enum pipe pipe, 
igt_output_t *output)
_fb[i]);
}
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
-   cursor = igt_output_get_plane(output, IGT_PLANE_CURSOR);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+   cursor = igt_output_get_plane_type(output, DRM_PLANE_TYPE_CURSOR);
if (!primary || !cursor) {
cursor_leak_test_fini(data, output, _fb, cursor_fb);
igt_skip("Primary and/or cursor are unavailable\n");
@@ -706,7 +706,7 @@ gen9_test_pipe(data_t *data, enum pipe pipe, igt_output_t 
*output)
 
gen9_test_init(, output, pipe);
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
 
/* Start with a full-screen primary plane */
igt_plane_set_fb(primary, _fb);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 30/33] tests/prime_mmap_kms: Add support for dynamic number of planes

2017-01-30 Thread Robert Foss
Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/prime_mmap_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/prime_mmap_kms.c b/tests/prime_mmap_kms.c
index a2f85fa7..e7cca54c 100644
--- a/tests/prime_mmap_kms.c
+++ b/tests/prime_mmap_kms.c
@@ -168,7 +168,7 @@ static void prepare_crtc(gpu_process_t *gpu)
DRM_FORMAT_XRGB, LOCAL_DRM_FORMAT_MOD_NONE,
1.0, 1.0, 1.0, >fb);
 
-   gpu->primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   gpu->primary = igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_PRIMARY);
 
igt_plane_set_fb(gpu->primary, >fb);
igt_display_commit(display);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 33/33] lib/igt_kms: Remove code obsoleted by dyn n_planes implementation

2017-01-30 Thread Robert Foss
Due to the dyn n_planes implementation some attributes and functions
were made obsolete and cand be removed.

However to keep all of the tests building the obsolete code is
removed after all of the tests have been made compatible with the
dyn n_planes changes.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 lib/igt_kms.c | 28 
 lib/igt_kms.h | 20 
 2 files changed, 48 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 961a3e4d..4ba6316d 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -346,32 +346,6 @@ int kmstest_pipe_to_index(char pipe)
 }
 
 /**
- * kmstest_plane_name:
- * @plane: display plane
- *
- * Returns: String representing @plane, e.g. "plane1".
- */
-const char *kmstest_plane_name(enum igt_plane plane)
-{
-   static const char *names[] = {
-   [IGT_PLANE_1] = "plane1",
-   [IGT_PLANE_2] = "plane2",
-   [IGT_PLANE_3] = "plane3",
-   [IGT_PLANE_4] = "plane4",
-   [IGT_PLANE_5] = "plane5",
-   [IGT_PLANE_6] = "plane6",
-   [IGT_PLANE_7] = "plane7",
-   [IGT_PLANE_8] = "plane8",
-   [IGT_PLANE_9] = "plane9",
-   [IGT_PLANE_CURSOR] = "cursor",
-   };
-
-   igt_assert(plane < ARRAY_SIZE(names) && names[plane]);
-
-   return names[plane];
-}
-
-/**
  * kmstest_plane_type_name:
  * @plane: display plane
  *
@@ -1671,7 +1645,6 @@ void igt_display_init(igt_display_t *display, int drm_fd)
plane = >planes[p];
plane->index = p++;
}
-   plane->is_primary = 1;
break;
case DRM_PLANE_TYPE_CURSOR:
if (pipe->plane_cursor == -1) {
@@ -1683,7 +1656,6 @@ void igt_display_init(igt_display_t *display, int drm_fd)
plane->index = p++;
}
display->has_cursor_plane = true;
-   plane->is_cursor = 1;
break;
default:
plane = >planes[p];
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 510657a3..25626187 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -58,24 +58,6 @@ enum pipe {
 };
 const char *kmstest_pipe_name(enum pipe pipe);
 int kmstest_pipe_to_index(char pipe);
-
-/* We namespace this enum to not conflict with the Android i915_drm.h */
-enum igt_plane {
-IGT_PLANE_1 = 0,
-IGT_PLANE_PRIMARY = IGT_PLANE_1,
-IGT_PLANE_2,
-IGT_PLANE_3,
-IGT_PLANE_4,
-IGT_PLANE_5,
-IGT_PLANE_6,
-IGT_PLANE_7,
-IGT_PLANE_8,
-IGT_PLANE_9,
-IGT_PLANE_CURSOR, /* IGT_PLANE_CURSOR is always the last plane. */
-IGT_MAX_PLANES,
-};
-
-const char *kmstest_plane_name(enum igt_plane plane);
 const char *kmstest_plane_type_name(int plane_type);
 
 enum port {
@@ -274,8 +256,6 @@ typedef struct {
int index;
/* capabilities */
int type;
-   unsigned int is_primary   : 1;
-   unsigned int is_cursor: 1;
/* state tracking */
unsigned int fb_changed   : 1;
unsigned int position_changed : 1;
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 29/33] tests/kms_vblank: Add support for dynamic number of planes

2017-01-30 Thread Robert Foss
Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_vblank.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/kms_vblank.c b/tests/kms_vblank.c
index 122fbc8f..0d250653 100644
--- a/tests/kms_vblank.c
+++ b/tests/kms_vblank.c
@@ -76,7 +76,7 @@ static void prepare_crtc(data_t *data, int fd, igt_output_t 
*output)
0.0, 0.0, 0.0,
>primary_fb);
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
igt_plane_set_fb(primary, >primary_fb);
 
igt_display_commit(display);
@@ -91,7 +91,7 @@ static void cleanup_crtc(data_t *data, int fd, igt_output_t 
*output)
 
igt_remove_fb(fd, >primary_fb);
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
igt_plane_set_fb(primary, NULL);
 
igt_output_set_pipe(output, PIPE_ANY);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 20/33] tests/kms_plane_multiple: Add support for dynamic number of planes

2017-01-30 Thread Robert Foss
Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_plane_multiple.c | 232 -
 1 file changed, 145 insertions(+), 87 deletions(-)

diff --git a/tests/kms_plane_multiple.c b/tests/kms_plane_multiple.c
index 2b43f0c5..bb848784 100644
--- a/tests/kms_plane_multiple.c
+++ b/tests/kms_plane_multiple.c
@@ -47,8 +47,8 @@ typedef struct {
int drm_fd;
igt_display_t display;
igt_pipe_crc_t *pipe_crc;
-   igt_plane_t *plane[IGT_MAX_PLANES];
-   struct igt_fb fb[IGT_MAX_PLANES];
+   igt_plane_t **plane;
+   struct igt_fb *fb;
 } data_t;
 
 typedef struct {
@@ -70,20 +70,38 @@ struct {
 /*
  * Common code across all tests, acting on data_t
  */
-static void test_init(data_t *data, enum pipe pipe)
+static void test_init(data_t *data, enum pipe pipe, int n_planes)
 {
data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
+
+   data->plane = calloc(n_planes, sizeof(data->plane));
+   igt_assert_f(data->plane != NULL, "Failed to allocate memory for 
planes\n");
+
+   data->fb = calloc(n_planes, sizeof(struct igt_fb));
+   igt_assert_f(data->fb != NULL, "Failed to allocate memory for FBs\n");
 }
 
-static void test_fini(data_t *data, igt_output_t *output, int max_planes)
+static void test_fini(data_t *data, igt_output_t *output, int n_planes)
 {
-   for (int i = IGT_PLANE_PRIMARY; i <= max_planes; i++)
-   igt_plane_set_fb(data->plane[i], NULL);
+   for (int i = 0; i < n_planes; i++) {
+   igt_plane_t *plane = data->plane[i];
+   if (!plane)
+   continue;
+   if (plane->type == DRM_PLANE_TYPE_PRIMARY)
+   continue;
+   igt_plane_set_fb(plane, NULL);
+   data->plane[i] = NULL;
+   }
 
/* reset the constraint on the pipe */
igt_output_set_pipe(output, PIPE_ANY);
 
igt_pipe_crc_free(data->pipe_crc);
+
+   free(data->plane);
+   data->plane = NULL;
+   free(data->fb);
+   data->fb = NULL;
 }
 
 static void
@@ -91,11 +109,13 @@ test_grab_crc(data_t *data, igt_output_t *output, enum 
pipe pipe, bool atomic,
  color_t *color, uint64_t tiling, igt_crc_t *crc /* out */)
 {
drmModeModeInfo *mode;
+   igt_plane_t *primary;
int ret, n;
 
igt_output_set_pipe(output, pipe);
 
-   data->plane[IGT_PLANE_PRIMARY] = igt_output_get_plane(output, 
IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+   data->plane[primary->index] = primary;
 
mode = igt_output_get_mode(output);
 
@@ -103,9 +123,9 @@ test_grab_crc(data_t *data, igt_output_t *output, enum pipe 
pipe, bool atomic,
DRM_FORMAT_XRGB,
LOCAL_DRM_FORMAT_MOD_NONE,
color->red, color->green, color->blue,
-   >fb[IGT_PLANE_PRIMARY]);
+   >fb[primary->index]);
 
-   igt_plane_set_fb(data->plane[IGT_PLANE_PRIMARY], 
>fb[IGT_PLANE_PRIMARY]);
+   igt_plane_set_fb(data->plane[primary->index], 
>fb[primary->index]);
 
ret = igt_display_try_commit2(>display,
  atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
@@ -128,29 +148,35 @@ test_grab_crc(data_t *data, igt_output_t *output, enum 
pipe pipe, bool atomic,
  */
 
 static void
-create_fb_for_mode_position(data_t *data, drmModeModeInfo *mode,
+create_fb_for_mode_position(data_t *data, igt_output_t *output, 
drmModeModeInfo *mode,
color_t *color, int *rect_x, int *rect_y,
int *rect_w, int *rect_h, uint64_t tiling,
int max_planes)
 {
unsigned int fb_id;
cairo_t *cr;
+   igt_plane_t *primary;
+
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
 
fb_id = igt_create_fb(data->drm_fd,
  mode->hdisplay, mode->vdisplay,
  DRM_FORMAT_XRGB,
  tiling,
- >fb[IGT_PLANE_PRIMARY]);
+ >fb[primary->index]);
igt_assert(fb_id);
 
-   cr = igt_get_cairo_ctx(data->drm_fd, >fb[IGT_PLANE_PRIMARY]);
+   cr = igt_get_cairo_ctx(data->drm_fd, >fb[primary->index]);
igt_paint_color(cr, rect_x[0], rect_y[0],
mode->hdisplay, mode->vdisplay,
color->red, color->green, color->blue);
 
-   for (int i = IGT_PLANE_2; i <= max_planes; i++)
+   for 

[Intel-gfx] [PATCH i-g-t v3 19/33] tests/kms_plane: Add support for dynamic number of planes

2017-01-30 Thread Robert Foss
Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_plane.c | 96 ++-
 1 file changed, 53 insertions(+), 43 deletions(-)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index e843a170..d0de0f52 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -150,7 +150,7 @@ enum {
 static void
 test_plane_position_with_output(data_t *data,
enum pipe pipe,
-   enum igt_plane plane,
+   int plane,
igt_output_t *output,
unsigned int flags)
 {
@@ -170,7 +170,7 @@ test_plane_position_with_output(data_t *data,
igt_output_set_pipe(output, pipe);
 
mode = igt_output_get_mode(output);
-   primary = igt_output_get_plane(output, 0);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
sprite = igt_output_get_plane(output, plane);
 
create_fb_for_mode__position(data, mode, 100, 100, 64, 64,
@@ -222,7 +222,7 @@ test_plane_position_with_output(data_t *data,
 }
 
 static void
-test_plane_position(data_t *data, enum pipe pipe, enum igt_plane plane,
+test_plane_position(data_t *data, enum pipe pipe, int plane,
unsigned int flags)
 {
igt_output_t *output;
@@ -294,7 +294,7 @@ enum {
 static void
 test_plane_panning_with_output(data_t *data,
   enum pipe pipe,
-  enum igt_plane plane,
+  int plane,
   igt_output_t *output,
   unsigned int flags)
 {
@@ -348,8 +348,8 @@ test_plane_panning_with_output(data_t *data,
 }
 
 static void
-test_plane_panning(data_t *data, enum pipe pipe, enum igt_plane plane,
-unsigned int flags)
+test_plane_panning(data_t *data, enum pipe pipe, int plane,
+  unsigned int flags)
 {
igt_output_t *output;
int connected_outs = 0;
@@ -367,47 +367,57 @@ test_plane_panning(data_t *data, enum pipe pipe, enum 
igt_plane plane,
 }
 
 static void
-run_tests_for_pipe_plane(data_t *data, enum pipe pipe, enum igt_plane plane)
+run_tests_for_pipe_plane(data_t *data, enum pipe pipe)
 {
-   igt_subtest_f("plane-position-covered-pipe-%s-plane-%d",
- kmstest_pipe_name(pipe), plane)
-   test_plane_position(data, pipe, plane,
-   TEST_POSITION_FULLY_COVERED);
-
-   igt_subtest_f("plane-position-hole-pipe-%s-plane-%d",
- kmstest_pipe_name(pipe), plane)
-   test_plane_position(data, pipe, plane, 0);
-
-   igt_subtest_f("plane-position-hole-dpms-pipe-%s-plane-%d",
- kmstest_pipe_name(pipe), plane)
-   test_plane_position(data, pipe, plane,
-   TEST_DPMS);
-
-   igt_subtest_f("plane-panning-top-left-pipe-%s-plane-%d",
- kmstest_pipe_name(pipe), plane)
-   test_plane_panning(data, pipe, plane, TEST_PANNING_TOP_LEFT);
-
-   igt_subtest_f("plane-panning-bottom-right-pipe-%s-plane-%d",
- kmstest_pipe_name(pipe), plane)
-   test_plane_panning(data, pipe, plane,
-  TEST_PANNING_BOTTOM_RIGHT);
-
-   igt_subtest_f("plane-panning-bottom-right-suspend-pipe-%s-plane-%d",
- kmstest_pipe_name(pipe), plane)
-   test_plane_panning(data, pipe, plane,
-  TEST_PANNING_BOTTOM_RIGHT |
-  TEST_SUSPEND_RESUME);
-}
+   igt_subtest_f("plane-position-covered-pipe-%s-planes",
+ kmstest_pipe_name(pipe)) {
+   int n_planes = data->display.pipes[pipe].n_planes;
+   for (int plane = 1; plane < n_planes; plane++)
+   test_plane_position(data, pipe, plane,
+   TEST_POSITION_FULLY_COVERED);
+   }
 
-static void
-run_tests_for_pipe(data_t *data, enum pipe pipe)
-{
-   int plane;
+   igt_subtest_f("plane-position-hole-pipe-%s-planes",
+ kmstest_pipe_name(pipe)) {
+   int n_planes = data->display.pipes[pipe].n_planes;
+   for (int plane = 1; plane < n_planes; plane++)
+   test_plane_position(data, pipe, plane, 0);
+   }
+
+   igt_subtest_f("plane-position-hole-dpms-pipe-%s-planes",
+ kmstest_pipe_name(pipe)) {
+   int n_planes = data->display.pipes[pipe].n_planes;
+   for (int plane = 1; plane < n_planes; plane

[Intel-gfx] [PATCH i-g-t v3 21/33] tests/kms_plane_scaling: Add support for dynamic number of planes

2017-01-30 Thread Robert Foss
Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_plane_scaling.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c
index 368da09f..18ba86c9 100644
--- a/tests/kms_plane_scaling.c
+++ b/tests/kms_plane_scaling.c
@@ -85,10 +85,10 @@ static void prepare_crtc(data_t *data, igt_output_t 
*output, enum pipe pipe,
 * there's no way (that works) to light up a pipe with only a sprite
 * plane enabled at the moment.
 */
-   if (!plane->is_primary) {
+   if (plane->type != DRM_PLANE_TYPE_PRIMARY) {
igt_plane_t *primary;
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_PRIMARY);
igt_plane_set_fb(primary, >fb1);
}
 
@@ -128,10 +128,10 @@ static void cleanup_crtc(data_t *data, igt_output_t 
*output, igt_plane_t *plane)
data->fb_id3 = 0;
}
 
-   if (!plane->is_primary) {
+   if (plane->type != DRM_PLANE_TYPE_PRIMARY) {
igt_plane_t *primary;
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_PRIMARY);
igt_plane_set_fb(primary, NULL);
}
 
@@ -207,7 +207,7 @@ static void test_plane_scaling(data_t *d)
igt_assert(d->fb_id3);
 
/* Set up display with plane 1 */
-   d->plane1 = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   d->plane1 = igt_output_get_plane(output, 1);
prepare_crtc(d, output, pipe, d->plane1, mode, 
COMMIT_UNIVERSAL);
 
if (primary_plane_scaling) {
@@ -227,7 +227,7 @@ static void test_plane_scaling(data_t *d)
}
 
/* Set up fb2->plane2 mapping. */
-   d->plane2 = igt_output_get_plane(output, IGT_PLANE_2);
+   d->plane2 = igt_output_get_plane(output, 2);
igt_plane_set_fb(d->plane2, >fb2);
 
/* 2nd plane windowed */
@@ -263,7 +263,7 @@ static void test_plane_scaling(data_t *d)
}
 
/* Set up fb3->plane3 mapping. */
-   d->plane3 = igt_output_get_plane(output, IGT_PLANE_3);
+   d->plane3 = igt_output_get_plane(output, 3);
igt_plane_set_fb(d->plane3, >fb3);
 
/* 3rd plane windowed - no scaling */
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 22/33] tests/kms_properties: Add support for dynamic number of planes

2017-01-30 Thread Robert Foss
Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_properties.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/kms_properties.c b/tests/kms_properties.c
index 2650672d..a86371c0 100644
--- a/tests/kms_properties.c
+++ b/tests/kms_properties.c
@@ -38,7 +38,7 @@ static void prepare_pipe(igt_display_t *display, enum pipe 
pipe, igt_output_t *o
 
igt_output_set_pipe(output, pipe);
 
-   igt_plane_set_fb(igt_output_get_plane(output, IGT_PLANE_PRIMARY), fb);
+   igt_plane_set_fb(igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_PRIMARY), fb);
 
igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : 
COMMIT_LEGACY);
 }
@@ -163,8 +163,8 @@ static void run_plane_property_tests(igt_display_t 
*display, enum pipe pipe, igt
prepare_pipe(display, pipe, output, );
 
for_each_plane_on_pipe(display, pipe, plane) {
-   igt_info("Testing plane properties on %s.%s (output: %s)\n",
-kmstest_pipe_name(pipe), 
kmstest_plane_name(plane->index), output->name);
+   igt_info("Testing plane properties on %s.#%d-%s (output: %s)\n",
+kmstest_pipe_name(pipe), plane->index, 
kmstest_plane_type_name(plane->type), output->name);
 
test_properties(display->drm_fd, DRM_MODE_OBJECT_PLANE, 
plane->drm_plane->plane_id, atomic);
}
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 23/33] tests/kms_psr_sink_crc: Add support for dynamic number of planes

2017-01-30 Thread Robert Foss
Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_psr_sink_crc.c | 52 +---
 1 file changed, 23 insertions(+), 29 deletions(-)

diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c
index 926b8578..8f6bdc0d 100644
--- a/tests/kms_psr_sink_crc.c
+++ b/tests/kms_psr_sink_crc.c
@@ -34,12 +34,6 @@ bool running_with_psr_disabled;
 
 #define CRC_BLACK ""
 
-enum planes {
-   PRIMARY,
-   SPRITE,
-   CURSOR,
-};
-
 enum operations {
PAGE_FLIP,
MMAP_GTT,
@@ -69,7 +63,7 @@ static const char *op_str(enum operations op)
 
 typedef struct {
int drm_fd;
-   enum planes test_plane;
+   int test_plane;
enum operations op;
uint32_t devid;
uint32_t crtc_id;
@@ -313,9 +307,9 @@ static void run_test(data_t *data)
 
/* Setting a secondary fb/plane */
switch (data->test_plane) {
-   case PRIMARY: default: test_plane = data->primary; break;
-   case SPRITE: test_plane = data->sprite; break;
-   case CURSOR: test_plane = data->cursor; break;
+   case DRM_PLANE_TYPE_PRIMARY: default: test_plane = data->primary; break;
+   case DRM_PLANE_TYPE_OVERLAY: test_plane = data->sprite; break;
+   case DRM_PLANE_TYPE_CURSOR: test_plane = data->cursor; break;
}
igt_plane_set_fb(test_plane, >fb_white);
igt_display_commit(>display);
@@ -323,7 +317,7 @@ static void run_test(data_t *data)
/* Confirm it is not Green anymore */
igt_assert(wait_psr_entry(data));
get_sink_crc(data, ref_crc);
-   if (data->test_plane == PRIMARY)
+   if (data->test_plane == DRM_PLANE_TYPE_PRIMARY)
assert_or_manual(!is_green(ref_crc), "screen WHITE");
else
assert_or_manual(!is_green(ref_crc), "GREEN background with 
WHITE box");
@@ -355,7 +349,7 @@ static void run_test(data_t *data)
/* Printing white on white so the screen shouldn't change */
memset(ptr, 0xff, data->mod_size);
get_sink_crc(data, crc);
-   if (data->test_plane == PRIMARY)
+   if (data->test_plane == DRM_PLANE_TYPE_PRIMARY)
assert_or_manual(strcmp(ref_crc, crc) == 0, "screen 
WHITE");
else
assert_or_manual(strcmp(ref_crc, crc) == 0,
@@ -406,9 +400,9 @@ static void run_test(data_t *data)
 
 static void test_cleanup(data_t *data) {
igt_plane_set_fb(data->primary, NULL);
-   if (data->test_plane == SPRITE)
+   if (data->test_plane == DRM_PLANE_TYPE_OVERLAY)
igt_plane_set_fb(data->sprite, NULL);
-   if (data->test_plane == CURSOR)
+   if (data->test_plane == DRM_PLANE_TYPE_CURSOR)
igt_plane_set_fb(data->cursor, NULL);
 
igt_display_commit(>display);
@@ -428,7 +422,7 @@ static void setup_test_plane(data_t *data)
0.0, 1.0, 0.0,
>fb_green);
 
-   data->primary = igt_output_get_plane(data->output, IGT_PLANE_PRIMARY);
+   data->primary = igt_output_get_plane_type(data->output, 
DRM_PLANE_TYPE_PRIMARY);
igt_plane_set_fb(data->primary, NULL);
 
white_h = data->mode->hdisplay;
@@ -439,16 +433,16 @@ static void setup_test_plane(data_t *data)
data->mod_stride = white_h * 4;
 
switch (data->test_plane) {
-   case SPRITE:
-   data->sprite = igt_output_get_plane(data->output,
-   IGT_PLANE_2);
+   case DRM_PLANE_TYPE_OVERLAY:
+   data->sprite = igt_output_get_plane_type(data->output,
+   DRM_PLANE_TYPE_OVERLAY);
igt_plane_set_fb(data->sprite, NULL);
/* To make it different for human eyes let's make
 * sprite visible in only one quarter of the primary
 */
white_h = white_h/2;
white_v = white_v/2;
-   case PRIMARY:
+   case DRM_PLANE_TYPE_PRIMARY:
igt_create_color_fb(data->drm_fd,
white_h, white_v,
DRM_FORMAT_XRGB,
@@ -456,9 +450,9 @@ static void setup_test_plane(data_t *data)
1.0, 1.0, 1.0,
>fb_white);
break;
-   case CURSOR:
-   data->cursor = igt_output_get_plane(data->output,
-   IGT_PLANE_CURSOR);
+   case DRM_PLANE_TYPE_CURSOR:
+   data-&g

[Intel-gfx] [PATCH i-g-t v3 26/33] tests/kms_rotation_crc: Add support for dynamic number of planes

2017-01-30 Thread Robert Foss
Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_rotation_crc.c | 63 
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index cb0ac1eb..6769a89b 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -97,17 +97,18 @@ static void commit_crtc(data_t *data, igt_output_t *output, 
igt_plane_t *plane)
 * we create an fb covering the crtc and call commit
 */
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
igt_plane_set_fb(primary, >fb_modeset);
primary->rotation_changed = false;
igt_display_commit(display);
 
igt_plane_set_fb(plane, >fb);
 
-   if (!plane->is_cursor)
+   if (plane->type != DRM_PLANE_TYPE_CURSOR)
igt_plane_set_position(plane, data->pos_x, data->pos_y);
 
-   if (plane->is_primary || plane->is_cursor)
+   if (plane->type == DRM_PLANE_TYPE_PRIMARY ||
+   plane->type == DRM_PLANE_TYPE_CURSOR)
commit = COMMIT_UNIVERSAL;
 
if (data->display.is_atomic)
@@ -154,7 +155,7 @@ static void prepare_crtc(data_t *data, igt_output_t 
*output, enum pipe pipe,
tiling = data->override_tiling ?
 data->override_tiling : LOCAL_I915_FORMAT_MOD_Y_TILED;
w = h =  mode->vdisplay;
-   } else if (plane->is_cursor) {
+   } else if (plane->type == DRM_PLANE_TYPE_CURSOR) {
pixel_format = data->override_fmt ?
   data->override_fmt : DRM_FORMAT_ARGB;
w = h = 128;
@@ -206,10 +207,10 @@ static void cleanup_crtc(data_t *data, igt_output_t 
*output, igt_plane_t *plane)
igt_remove_fb(data->gfx_fd, >fb_flip);
 
/* XXX: see the note in prepare_crtc() */
-   if (!plane->is_primary) {
+   if (plane->type != DRM_PLANE_TYPE_PRIMARY) {
igt_plane_t *primary;
 
-   primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   primary = igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_PRIMARY);
igt_plane_set_fb(primary, NULL);
}
 
@@ -236,7 +237,7 @@ static void wait_for_pageflip(int fd)
igt_assert(drmHandleEvent(fd, ) == 0);
 }
 
-static void test_plane_rotation(data_t *data, enum igt_plane plane_type)
+static void test_plane_rotation(data_t *data, int plane_type)
 {
igt_display_t *display = >display;
igt_output_t *output;
@@ -247,10 +248,10 @@ static void test_plane_rotation(data_t *data, enum 
igt_plane plane_type)
unsigned int flip_count;
int ret;
 
-   if (plane_type == IGT_PLANE_PRIMARY || plane_type == IGT_PLANE_CURSOR)
+   if (plane_type == DRM_PLANE_TYPE_PRIMARY || plane_type == 
DRM_PLANE_TYPE_CURSOR)
commit = COMMIT_UNIVERSAL;
 
-   if (plane_type == IGT_PLANE_CURSOR)
+   if (plane_type == DRM_PLANE_TYPE_CURSOR)
igt_require(display->has_cursor_plane);
 
if (data->display.is_atomic)
@@ -261,7 +262,7 @@ static void test_plane_rotation(data_t *data, enum 
igt_plane plane_type)
 
igt_output_set_pipe(output, pipe);
 
-   plane = igt_output_get_plane(output, plane_type);
+   plane = igt_output_get_plane_type(output, plane_type);
igt_require(igt_plane_supports_rotation(plane));
 
prepare_crtc(data, output, pipe, plane);
@@ -321,7 +322,7 @@ static void test_plane_rotation(data_t *data, enum 
igt_plane plane_type)
 
 static void test_plane_rotation_ytiled_obj(data_t *data,
   igt_output_t *output,
-  enum igt_plane plane_type)
+  int plane_type)
 {
igt_display_t *display = >display;
uint64_t tiling = LOCAL_I915_FORMAT_MOD_Y_TILED;
@@ -335,13 +336,13 @@ static void test_plane_rotation_ytiled_obj(data_t *data,
uint32_t gem_handle;
int ret;
 
-   plane = igt_output_get_plane(output, plane_type);
+   plane = igt_output_get_plane_type(output, plane_type);
igt_require(igt_plane_supports_rotation(plane));
 
-   if (plane_type == IGT_PLANE_PRIMARY || plane_type == IGT_PLANE_CURSOR)
+   if (plane_type == DRM_PLANE_TYPE_PRIMARY || plane_type == 
DRM_PLANE_TYPE_CURSOR)
commit = COMMIT_UNIVERSAL;
 
-   if (plane_type == IGT_PLANE_CURSOR)
+   if (plane_type == DRM_PLANE_TYPE_CURSOR)
igt_require(display->has_cursor_plane);
 
if (data->display.is_

[Intel-gfx] [PATCH i-g-t v3 24/33] tests/kms_pwrite_crc: Add support for dynamic number of planes

2017-01-30 Thread Robert Foss
Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_pwrite_crc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/kms_pwrite_crc.c b/tests/kms_pwrite_crc.c
index b63afbc6..1e626375 100644
--- a/tests/kms_pwrite_crc.c
+++ b/tests/kms_pwrite_crc.c
@@ -116,7 +116,7 @@ static void prepare_crtc(data_t *data)
DRM_FORMAT_XRGB, LOCAL_DRM_FORMAT_MOD_NONE,
1.0, 1.0, 1.0, >fb[0]);
 
-   data->primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   data->primary = igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_PRIMARY);
 
igt_plane_set_fb(data->primary, >fb[0]);
igt_display_commit(display);
-- 
2.11.0.453.g787f75f05

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


[Intel-gfx] [PATCH i-g-t v3 27/33] tests/kms_sink_crc_basic: Add support for dynamic number of planes

2017-01-30 Thread Robert Foss
Add changes reflecting the new support for dynamic number of planes per pipe.

Signed-off-by: Robert Foss <robert.f...@collabora.com>
Reviewed-by: Mika Kahola <mika.kah...@intel.com>
---
 tests/kms_sink_crc_basic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/kms_sink_crc_basic.c b/tests/kms_sink_crc_basic.c
index c332eb1e..953ead10 100644
--- a/tests/kms_sink_crc_basic.c
+++ b/tests/kms_sink_crc_basic.c
@@ -138,7 +138,7 @@ static void run_test(data_t *data)
1.0, 0.0, 0.0,
>fb_red);
 
-   data->primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+   data->primary = igt_output_get_plane_type(output, 
DRM_PLANE_TYPE_PRIMARY);
 
basic_sink_crc_check(data);
return;
-- 
2.11.0.453.g787f75f05

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


  1   2   3   4   5   6   7   8   >