Re: [Intel-gfx] [PATCH 10/10] Revert "drm: crc: Wait for a frame before returning from open()"

2018-06-22 Thread Tomeu Vizoso

On 06/22/2018 02:30 PM, Maarten Lankhorst wrote:

Op 22-06-18 om 12:41 schreef Mahesh Kumar:

This reverts commit e8fa5671183c80342d520ad81d14fa79a9d4a680.

Don't wait for first CRC during crtc_crc_open. It avoids one frame wait
during open. If application want to wait after read call, it can use
poll/read blocking read() call.


Hi,

unfortunately I don't remember why that was deemed undesirable, and I 
failed to explain so in the commit message.


My only comment is that it would be good to make the motivation for this 
revert explicit, in case someone else in the future wonders.


I would also test it in a machine with eDP, IGT should be able to test there.

Thanks,

Tomeu


Suggested-by: Ville Syrjälä 
Signed-off-by: Mahesh Kumar 
---
  drivers/gpu/drm/drm_debugfs_crc.c | 16 
  1 file changed, 16 deletions(-)

diff --git a/drivers/gpu/drm/drm_debugfs_crc.c 
b/drivers/gpu/drm/drm_debugfs_crc.c
index 834bc7ee5550..69ec2728727e 100644
--- a/drivers/gpu/drm/drm_debugfs_crc.c
+++ b/drivers/gpu/drm/drm_debugfs_crc.c
@@ -211,24 +211,8 @@ static int crtc_crc_open(struct inode *inode, struct file 
*filep)
if (ret)
goto err;
  
-	spin_lock_irq(&crc->lock);

-   /*
-* Only return once we got a first frame, so userspace doesn't have to
-* guess when this particular piece of HW will be ready to start
-* generating CRCs.
-*/
-   ret = wait_event_interruptible_lock_irq(crc->wq,
-   crtc_crc_data_count(crc),
-   crc->lock);
-   spin_unlock_irq(&crc->lock);
-
-   if (ret)
-   goto err_disable;
-
return 0;
  
-err_disable:

-   crtc->funcs->set_crc_source(crtc, NULL);
  err:
spin_lock_irq(&crc->lock);
crtc_crc_cleanup(crc);


Adding Tomeu Vizoso to the cc.

Can you resend the series, and add dri-de...@lists.freedesktop.org and the 
driver maintainers to the cc? You'll need to get acks from the maintainers to 
merge this through drm-misc. :)

~Maarten


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


Re: [Intel-gfx] [RFC PATCH 01/60] hyper_dmabuf: initial working version of hyper_dmabuf drv

2017-12-29 Thread Tomeu Vizoso
On 26 December 2017 at 19:19, Matt Roper  wrote:
> On Wed, Dec 20, 2017 at 10:59:57AM +0100, Daniel Vetter wrote:
>> On Tue, Dec 19, 2017 at 03:27:31PM -0800, Dongwon Kim wrote:
>> > I forgot to include this brief information about this patch series.
>> >
>> > This patch series contains the implementation of a new device driver,
>> > hyper_dmabuf, which provides a method for DMA-BUF sharing across
>> > different OSes running on the same virtual OS platform powered by
>> > a hypervisor.
>> >
>> > Detailed information about this driver is described in a high-level doc
>> > added by the second patch of the series.
>> >
>> > [RFC PATCH 02/60] hyper_dmabuf: added a doc for hyper_dmabuf sharing
>> >
>> > I am attaching 'Overview' section here as a summary.
>> >
>> > --
>> > Section 1. Overview
>> > --
>> >
>> > Hyper_DMABUF driver is a Linux device driver running on multiple Virtual
>> > achines (VMs), which expands DMA-BUF sharing capability to the VM 
>> > environment
>> > where multiple different OS instances need to share same physical data 
>> > without
>> > data-copy across VMs.
>> >
>> > To share a DMA_BUF across VMs, an instance of the Hyper_DMABUF drv on the
>> > exporting VM (so called, “exporter”) imports a local DMA_BUF from the 
>> > original
>> > producer of the buffer, then re-exports it with an unique ID, 
>> > hyper_dmabuf_id
>> > for the buffer to the importing VM (so called, “importer”).
>> >
>> > Another instance of the Hyper_DMABUF driver on importer registers
>> > a hyper_dmabuf_id together with reference information for the shared 
>> > physical
>> > pages associated with the DMA_BUF to its database when the export happens.
>> >
>> > The actual mapping of the DMA_BUF on the importer’s side is done by
>> > the Hyper_DMABUF driver when user space issues the IOCTL command to access
>> > the shared DMA_BUF. The Hyper_DMABUF driver works as both an importing and
>> > exporting driver as is, that is, no special configuration is required.
>> > Consequently, only a single module per VM is needed to enable cross-VM 
>> > DMA_BUF
>> > exchange.
>>
>> So I know that most dma-buf implementations (especially lots of importers
>> in drivers/gpu) break this, but fundamentally only the original exporter
>> is allowed to know about the underlying pages. There's various scenarios
>> where a dma-buf isn't backed by anything like a struct page.
>>
>> So your first step of noodling the underlying struct page out from the
>> dma-buf is kinda breaking the abstraction, and I think it's not a good
>> idea to have that. Especially not for sharing across VMs.
>>
>> I think a better design would be if hyper-dmabuf would be the dma-buf
>> exporter in both of the VMs, and you'd import it everywhere you want to in
>> some gpu/video/whatever driver in the VMs. That way hyper-dmabuf is always
>> in control of the pages, and a lot of the troubling forwarding you
>> currently need to do disappears.
>
> I think one of the main driving use cases here is for a "local" graphics
> compositor inside the VM to accept client buffers from unmodified
> applications and then pass those buffers along to a "global" compositor
> running in the service domain.  This would allow the global compositor
> to composite applications running in different virtual machines (and
> possibly running under different operating systems).
>
> If we require that hyper-dmabuf always be the exporter, that complicates
> things a little bit since a buffer allocated via regular interfaces (GEM
> ioctls or whatever) wouldn't be directly transferrable to the global
> compositor.  For graphics use cases like this, we could probably hide a
> lot of the details by modifying/replacing the EGL implementation that
> handles the details of buffer allocation.  However if we have
> applications that are themselves just passing along externally-allocated
> buffers (e.g., images from a camera device), we'd probably need to
> modify those applications and/or the drivers they get their content
> from.

There's also non-GPU-rendering clients that pass SHM buffers to the compositor.

For now, a Wayland proxy in the guest is copying the client-provided
buffers to virtio-gpu resources at the appropriate times, which also
need to be copied once more to host memory. Would be great to reduce
the number of copies that that implies.

For more on this effort:

https://patchwork.kernel.org/patch/10134603/

Regards,

Tomeu

>
> Matt
>
>>
>> 2nd thing: This seems very much related to what's happening around gvt and
>> allowing at least the host (in a kvm based VM environment) to be able to
>> access some of the dma-buf (or well, framebuffers in general) that the
>> client is using. Adding some mailing lists for that.
>> -Daniel
>>
>> >
>> > --
>> >
>> > There is a

Re: [Intel-gfx] [PATCH] drm/crc: Handle opening and closing crc better

2017-07-06 Thread Tomeu Vizoso
Looks good to me:

Reviewed-by: Tomeu Vizoso 

I guess you have tested this with IGT? In any case, I think it would
be good to mention how a patch has been tested in the changelog. That
can be very useful to others if things go wrong at some point.

Thanks,

Tomeu




On 21 June 2017 at 13:00, Maarten Lankhorst
 wrote:
> When I was doing a grep . -r /sys/kernel/debug/dri/0 I noticed a WARN
> appearing when I aborted the grep with ^C.
>
> After investigating I've also noticed that the error handling was
> lacking and there are race conditions involving multiple calls to
> open/close simultaneously.
>
> Fix this by setting the opened flag first and using crc->entries to
> decide when crc can be collected.
>
> Also call unset crc source before cleaning up, this way there is
> no race with a future open().
>
> Signed-off-by: Maarten Lankhorst 
> ---
>  drivers/gpu/drm/drm_debugfs_crc.c | 46 
> ++-
>  1 file changed, 31 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_debugfs_crc.c 
> b/drivers/gpu/drm/drm_debugfs_crc.c
> index 1722d8f21449..d0ea4627a093 100644
> --- a/drivers/gpu/drm/drm_debugfs_crc.c
> +++ b/drivers/gpu/drm/drm_debugfs_crc.c
> @@ -136,21 +136,38 @@ static int crtc_crc_data_count(struct drm_crtc_crc *crc)
> return CIRC_CNT(crc->head, crc->tail, DRM_CRC_ENTRIES_NR);
>  }
>
> +static void crtc_crc_cleanup(struct drm_crtc_crc *crc)
> +{
> +   kfree(crc->entries);
> +   crc->entries = NULL;
> +   crc->head = 0;
> +   crc->tail = 0;
> +   crc->values_cnt = 0;
> +   crc->opened = false;
> +}
> +
>  static int crtc_crc_open(struct inode *inode, struct file *filep)
>  {
> struct drm_crtc *crtc = inode->i_private;
> struct drm_crtc_crc *crc = &crtc->crc;
> struct drm_crtc_crc_entry *entries = NULL;
> size_t values_cnt;
> -   int ret;
> +   int ret = 0;
>
> -   if (crc->opened)
> -   return -EBUSY;
> +   spin_lock_irq(&crc->lock);
> +   if (!crc->opened)
> +   crc->opened = true;
> +   else
> +   ret = -EBUSY;
> +   spin_unlock_irq(&crc->lock);
>
> -   ret = crtc->funcs->set_crc_source(crtc, crc->source, &values_cnt);
> if (ret)
> return ret;
>
> +   ret = crtc->funcs->set_crc_source(crtc, crc->source, &values_cnt);
> +   if (ret)
> +   goto err;
> +
> if (WARN_ON(values_cnt > DRM_MAX_CRC_NR)) {
> ret = -EINVAL;
> goto err_disable;
> @@ -170,7 +187,6 @@ static int crtc_crc_open(struct inode *inode, struct file 
> *filep)
> spin_lock_irq(&crc->lock);
> crc->entries = entries;
> crc->values_cnt = values_cnt;
> -   crc->opened = true;
>
> /*
>  * Only return once we got a first frame, so userspace doesn't have to
> @@ -182,12 +198,17 @@ static int crtc_crc_open(struct inode *inode, struct 
> file *filep)
> crc->lock);
> spin_unlock_irq(&crc->lock);
>
> -   WARN_ON(ret);
> +   if (ret)
> +   goto err_disable;
>
> return 0;
>
>  err_disable:
> crtc->funcs->set_crc_source(crtc, NULL, &values_cnt);
> +err:
> +   spin_lock_irq(&crc->lock);
> +   crtc_crc_cleanup(crc);
> +   spin_unlock_irq(&crc->lock);
> return ret;
>  }
>
> @@ -197,17 +218,12 @@ static int crtc_crc_release(struct inode *inode, struct 
> file *filep)
> struct drm_crtc_crc *crc = &crtc->crc;
> size_t values_cnt;
>
> +   crtc->funcs->set_crc_source(crtc, NULL, &values_cnt);
> +
> spin_lock_irq(&crc->lock);
> -   kfree(crc->entries);
> -   crc->entries = NULL;
> -   crc->head = 0;
> -   crc->tail = 0;
> -   crc->values_cnt = 0;
> -   crc->opened = false;
> +   crtc_crc_cleanup(crc);
> spin_unlock_irq(&crc->lock);
>
> -   crtc->funcs->set_crc_source(crtc, NULL, &values_cnt);
> -
> return 0;
>  }
>
> @@ -334,7 +350,7 @@ int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool 
> has_frame,
> spin_lock(&crc->lock);
>
> /* Caller may not have noticed yet that userspace has stopped reading 
> */
> -   if (!crc->opened) {
> +   if (!crc->entries) {
> spin_unlock(&crc->lock);
> return -EINVAL;
> }
> --
> 2.11.0
>
> ___
> 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 03/16] drm: document driver interface for CRC capturing

2017-03-22 Thread Tomeu Vizoso
Thanks for doing this.

Reviewed-by: Tomeu Vizoso 

On 22 March 2017 at 09:36, Daniel Vetter  wrote:
> This was missed in Tomeu's patch. Also remove the kerneldoc for the
> internal function, we don't document that in general.
>
> While at it word-smith the docs slightly for more clarity.
>
> Cc: Tomeu Vizoso 
> Signed-off-by: Daniel Vetter 
> ---
>  Documentation/gpu/drm-uapi.rst|  3 +++
>  drivers/gpu/drm/drm_debugfs_crc.c | 17 ++---
>  include/drm/drm_crtc.h|  5 -
>  3 files changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
> index 352652810dab..369e8ca12b8e 100644
> --- a/Documentation/gpu/drm-uapi.rst
> +++ b/Documentation/gpu/drm-uapi.rst
> @@ -207,6 +207,9 @@ Display CRC Support
>  .. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
> :doc: CRC ABI
>
> +.. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
> +   :export:
> +
>  VBlank event handling
>  =
>
> diff --git a/drivers/gpu/drm/drm_debugfs_crc.c 
> b/drivers/gpu/drm/drm_debugfs_crc.c
> index 96891c4a6e23..1722d8f21449 100644
> --- a/drivers/gpu/drm/drm_debugfs_crc.c
> +++ b/drivers/gpu/drm/drm_debugfs_crc.c
> @@ -36,7 +36,7 @@
>   * DOC: CRC ABI
>   *
>   * DRM device drivers can provide to userspace CRC information of each frame 
> as
> - * it reached a given hardware component (a "source").
> + * it reached a given hardware component (a CRC sampling "source").
>   *
>   * Userspace can control generation of CRCs in a given CRTC by writing to the
>   * file dri/0/crtc-N/crc/control in debugfs, with N being the index of the 
> CRTC.
> @@ -57,6 +57,11 @@
>   * rely on being able to generate matching CRC values for the frame contents 
> that
>   * it submits. In this general case, the maximum userspace can do is to 
> compare
>   * the reported CRCs of frames that should have the same contents.
> + *
> + * On the driver side the implementation effort is minimal, drivers only 
> need to
> + * implement &drm_crtc_funcs.set_crc_source. The debugfs files are 
> automatically
> + * set up if that vfunc is set. CRC samples need to be captured in the 
> driver by
> + * calling drm_crtc_add_crc_entry().
>   */
>
>  static int crc_control_show(struct seq_file *m, void *data)
> @@ -280,16 +285,6 @@ static const struct file_operations 
> drm_crtc_crc_data_fops = {
> .release = crtc_crc_release,
>  };
>
> -/**
> - * drm_debugfs_crtc_crc_add - Add files to debugfs for capture of frame CRCs
> - * @crtc: CRTC to whom the frames will belong
> - *
> - * Adds files to debugfs directory that allows userspace to control the
> - * generation of frame CRCs and to read them.
> - *
> - * Returns:
> - * Zero on success, error code on failure.
> - */
>  int drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
>  {
> struct dentry *crc_ent, *ent;
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 6ef59da3fd8e..24dcb121bad4 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -590,9 +590,12 @@ struct drm_crtc_funcs {
>  * When CRC generation is enabled, the driver should call
>  * drm_crtc_add_crc_entry() at each frame, providing any information
>  * that characterizes the frame contents in the crcN arguments, as
> -* provided from the configured source. Drivers must accept a "auto"
> +* provided from the configured source. Drivers must accept an "auto"
>  * source name that will select a default source for this CRTC.
>  *
> +* Note that "auto" can depend upon the current modeset configuration,
> +* e.g. it could pick an encoder or output specific CRC sampling 
> point.
> +*
>  * This callback is optional if the driver does not support any CRC
>  * generation functionality.
>  *
> --
> 2.11.0
>
> ___
> 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


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

2017-03-21 Thread Tomeu Vizoso
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.

v2: - rebased and fixed new API additions

v3: - updated chamelium test, which was missed previously
- use the minor of the device for the debugfs path, not the major
- have a proper exit handler for calling igt_hpd_storm_reset with the
  right device fd.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Robert Foss 
---
 benchmarks/gem_latency.c  |   2 +-
 lib/drmtest.c |   2 +-
 lib/igt_aux.c |  10 +-
 lib/igt_aux.h |   4 +-
 lib/igt_debugfs.c | 197 +++---
 lib/igt_debugfs.h |  30 +++---
 lib/igt_gt.c  |  14 +--
 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 +-
 lib/intel_os.c|   9 +-
 tests/chamelium.c |  20 ++--
 tests/drv_hangman.c   |   4 +-
 tests/drv_missed_irq.c|  35 +++
 tests/drv_suspend.c   |   8 +-
 tests/gem_concurrent_all.c|   2 +-
 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_render_linear_blits.c   |   2 +-
 tests/gem_render_tiled_blits.c|   2 +-
 tests/gem_seqno_wrap.c|  24 ++---
 tests/gem_tiled_swapping.c|   9 +-
 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 +++--
 73 files changed, 446 insertions(+), 352 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);
 
-   igt_drop_caches_set(DROP_RETIRE | DROP_FREED);
+   igt_drop_caches_set(fd, DROP_RETIRE | DROP_FREED);
 }
 
 /**
diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 7ee279a3cc33..1222806c94a3 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -350,10 +350,10 @@ void igt_stop_signal_helper(void)
 }
 
 static struct igt_helper_proc

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

2017-03-21 Thread Tomeu Vizoso
Some frame sources such as sinks aren't able to provide meaningful frame
numbers, so in those cases just skip the TEST_SEQUENCE tests.

v2: Rebased

Signed-off-by: Tomeu Vizoso 
---
 tests/kms_pipe_crc_basic.c | 28 ++--
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index 49e856abbf4c..5a01fc6c2777 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)
 {
@@ -167,9 +167,23 @@ 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(&crcs[j], &crcs[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_remove_fb(data->drm_fd, &data->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_remove_fb(data->drm_fd, &data->fb);
@@ -177,6 +191,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)
@@ -193,8 +209,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);
-- 
2.9.3

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


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

2017-03-20 Thread Tomeu Vizoso
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.

v2: rebased and fixed new API additions

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Robert Foss 
---
 benchmarks/gem_latency.c  |   2 +-
 lib/drmtest.c |   2 +-
 lib/igt_aux.c |  10 +--
 lib/igt_aux.h |   4 +-
 lib/igt_debugfs.c | 185 ++
 lib/igt_debugfs.h |  30 +++
 lib/igt_gt.c  |  14 +--
 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 +-
 lib/intel_os.c|   9 +-
 tests/drv_hangman.c   |   4 +-
 tests/drv_missed_irq.c|  35 
 tests/drv_suspend.c   |   8 +-
 tests/gem_concurrent_all.c|   2 +-
 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_render_linear_blits.c   |   2 +-
 tests/gem_render_tiled_blits.c|   2 +-
 tests/gem_seqno_wrap.c|  24 ++---
 tests/gem_tiled_swapping.c|   9 +-
 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 +++--
 72 files changed, 425 insertions(+), 341 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);
 
-   igt_drop_caches_set(DROP_RETIRE | DROP_FREED);
+   igt_drop_caches_set(fd, DROP_RETIRE | DROP_FREED);
 }
 
 /**
diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 7ee279a3cc33..1222806c94a3 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -350,10 +350,10 @@ void igt_stop_signal_helper(void)
 }
 
 static struct igt_helper_process shrink_helper;
-static void __attribute__((noreturn)) shrink_helper_process(pid_t pid)
+static void __attribute__((noreturn)) shrink_helper_process(int fd, pid_t pid)
 {
while (1) {
-   igt_drop_caches_set(DROP_SHRINK_

[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-20 Thread Tomeu Vizoso
Some frame sources such as sinks aren't able to provide meaningful frame
numbers, so in those cases just skip the TEST_SEQUENCE tests.

v2: Rebased

Signed-off-by: Tomeu Vizoso 
---
 tests/kms_pipe_crc_basic.c | 28 ++--
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index 49e856abbf4c..5a01fc6c2777 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)
 {
@@ -167,9 +167,23 @@ 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(&crcs[j], &crcs[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_remove_fb(data->drm_fd, &data->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_remove_fb(data->drm_fd, &data->fb);
@@ -177,6 +191,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)
@@ -193,8 +209,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);
-- 
2.9.3

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


[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-08 Thread Tomeu Vizoso
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 
---
 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(&crcs[j], &crcs[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, &data->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);
-- 
2.9.3

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


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

2017-03-08 Thread Tomeu Vizoso
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);
 
-   igt_drop_caches_set(DROP_RETIRE | DROP_FREED);
+   igt_drop_caches_set(fd, DROP_RETIRE | DROP_FREED);
 }
 
 /**
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index e64d001b71cf..80a48d2dec81 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -131,39 +131,34 @@ const char *igt_debugfs_mount(void)
return "/sys/kernel/debug";
 }
 
-static bool __igt_debugfs_init(igt_debugfs_t *debugfs)
+static char *

Re: [Intel-gfx] [PATCH i-g-t 1/2] lib: Remove i915ism when checking that debugfs is mounted

2017-03-02 Thread Tomeu Vizoso
On 2 March 2017 at 14:46, Chris Wilson  wrote:
> On Thu, Mar 02, 2017 at 02:39:16PM +0100, Tomeu Vizoso wrote:
>> On 2 March 2017 at 11:12, Chris Wilson  wrote:
>> > On Thu, Mar 02, 2017 at 11:08:25AM +0100, Tomeu Vizoso wrote:
>> >> Instead of checking for "i915_error_state" within dri/N/, check for
>> >> "name".
>> >>
>> >> This allows more tests to run against drivers other than i915.
>> >
>> > Bleh. Sadly many users are expecting to have the i915 directory. Please
>> > kill the singleton and convert users to request which device debugfs
>> > they want.
>>
>> Are you sure this is needed? If a test opened the device with
>> DRIVER_INTEL, it cannot happen that the debugfs dir is present but the
>> i915-specific files aren't.
>
> Opening by DRIVER_INTEL does not mean that the first name is i915. I am
> suggesting that we transition away from assuming that we only want to
> open i915's debugfs by opening the exact debugfs dir. (i.e. find the
> minor index for the desired device, then open that path.)

Got it now, thanks for the explanation.

Regards,

Tomeu

> -Chris
>
> --
> Chris Wilson, Intel Open Source Technology Centre
> ___
> 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 1/2] lib: Remove i915ism when checking that debugfs is mounted

2017-03-02 Thread Tomeu Vizoso
On 2 March 2017 at 11:12, Chris Wilson  wrote:
> On Thu, Mar 02, 2017 at 11:08:25AM +0100, Tomeu Vizoso wrote:
>> Instead of checking for "i915_error_state" within dri/N/, check for
>> "name".
>>
>> This allows more tests to run against drivers other than i915.
>
> Bleh. Sadly many users are expecting to have the i915 directory. Please
> kill the singleton and convert users to request which device debugfs
> they want.

Are you sure this is needed? If a test opened the device with
DRIVER_INTEL, it cannot happen that the debugfs dir is present but the
i915-specific files aren't.

Regards,

Tomeu

> -Chris
>
> --
> Chris Wilson, Intel Open Source Technology Centre
> ___
> 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


[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-02 Thread Tomeu Vizoso
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 
---
 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 dd2ad3c366bc..6c65cfe6e9d3 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(&crcs[j], &crcs[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, &data->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);
-- 
2.9.3

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


[Intel-gfx] [PATCH i-g-t 1/2] lib: Remove i915ism when checking that debugfs is mounted

2017-03-02 Thread Tomeu Vizoso
Instead of checking for "i915_error_state" within dri/N/, check for
"name".

This allows more tests to run against drivers other than i915.

Signed-off-by: Tomeu Vizoso 
---
 lib/igt_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index e64d001b71cf..3f4f32da5b4a 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -139,7 +139,7 @@ static bool __igt_debugfs_init(igt_debugfs_t *debugfs)
strcpy(debugfs->root, igt_debugfs_mount());
for (n = 0; n < 16; n++) {
int len = sprintf(debugfs->dri_path, "%s/dri/%d", 
debugfs->root, n);
-   sprintf(debugfs->dri_path + len, "/i915_error_state");
+   sprintf(debugfs->dri_path + len, "/name");
if (stat(debugfs->dri_path, &st) == 0) {
debugfs->dri_path[len] = '\0';
return true;
-- 
2.9.3

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


[Intel-gfx] [PATCH] drm/edid: Add EDID_QUIRK_FORCE_8BPC quirk for Rotel RSX-1058

2017-02-20 Thread Tomeu Vizoso
Rotel RSX-1058 is a receiver with 4 HDMI inputs and a HDMI output, all
1.1.

When a sink that supports deep color is connected to the output, the
receiver will send EDIDs that advertise this capability, even if it
isn't possible with HDMI versions earlier than 1.3.

Currently the kernel is assuming that deep color is possible and the
sink displays an error.

This quirk will make sure that deep color isn't used with this
particular receiver.

Fixes: 7a0baa623446 ("Revert "drm/i915: Disable 12bpc hdmi for now"")
References: https://bugs.freedesktop.org/show_bug.cgi?id=99869
Signed-off-by: Tomeu Vizoso 
---
 drivers/gpu/drm/drm_edid.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 24e7b282f16c..d994ccf94f88 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -148,6 +148,9 @@ static const struct edid_quirk {
 
/* Panel in Samsung NP700G7A-S01PL notebook reports 6bpc */
{ "SEC", 0xd033, EDID_QUIRK_FORCE_8BPC },
+
+   /* Rotel RSX-1058 forwards sink's EDID but only does HDMI 1.1*/
+   { "ETR", 13896, EDID_QUIRK_FORCE_8BPC },
 };
 
 /*
-- 
2.9.3

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


Re: [Intel-gfx] [PATCH i-g-t] lib: Add basic support for valgrind annotations.

2017-02-09 Thread Tomeu Vizoso
Patch looks good to me, but I think the signal changes should be in
their own commit.

On 7 February 2017 at 16:12, Maarten Lankhorst
 wrote:
...
> +#define VG(x) x
> +#else
> +#define VG(x)
> +#endif

Wouldn't be better to stub VALGRIND_MAKE_MEM_DEFINED instead?

Regards,

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


[Intel-gfx] [PATCH i-g-t] kms_flip: Calculate max acceptable delta for TEST_TS_CONT

2017-02-09 Thread Tomeu Vizoso
Right now it's hardcoded to a maximum difference of 150 page flips to
account the fixed amount of time that the suspend cycle should take, but
in some cases suspending and resuming will take much more time due to
unrelated issues.

In my case, I have a machine in which the RTC will cause an interrupt
storm (~8k interrupts per second) from the moment an alarm is set until
the alarm actually fires. This causes so much CPU contention that the
suspend cycle takes much longer and the 150 value is not enough.

This patch takes into account the time that passed between the last two
page flips and calculates an acceptable difference taking into account
the vertical refresh rate of the current mode.

Signed-off-by: Tomeu Vizoso 
References: https://bugs.freedesktop.org/show_bug.cgi?id=98289
---
 tests/kms_flip.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 41406dfe9199..522777c24da2 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -500,17 +500,25 @@ static void check_state(const struct test_output *o, 
const struct event_state *e
 
/* Check that the vblank frame didn't wrap unexpectedly. */
if (o->flags & TEST_TS_CONT) {
+   double elapsed;
+   unsigned max_delta;
+
/* Ignore seq_step here since vblank waits time out immediately
 * when we kill the crtc. */
igt_assert_f(es->current_seq - es->last_seq >= 0,
 "unexpected %s seq %u, should be >= %u\n",
 es->name, es->current_seq, es->last_seq);
-   igt_assert_f(es->current_seq - es->last_seq <= 150,
+
+   timersub(&es->current_ts, &es->last_ts, &diff);
+   elapsed = 1e6*diff.tv_sec + diff.tv_usec;
+   max_delta = elapsed * o->kmode[0].vrefresh / 1e6;
+
+   igt_assert_f(es->current_seq - es->last_seq <= max_delta,
 "unexpected %s seq %u, should be < %u\n",
-es->name, es->current_seq, es->last_seq + 150);
+es->name, es->current_seq, es->last_seq + 
max_delta);
 
-   igt_debug("testing ts continuity: Current frame %u, old frame 
%u\n",
- es->current_seq, es->last_seq);
+   igt_debug("testing ts continuity: Current frame %u, old frame 
%u, max delta %u\n",
+ es->current_seq, es->last_seq, max_delta);
}
 
if (o->flags & TEST_CHECK_TS) {
-- 
2.9.3

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


Re: [Intel-gfx] [RESEND PATCH v14 2/2] drm/i915: Put "cooked" vlank counters in frame CRC lines

2017-01-16 Thread Tomeu Vizoso
On 10 January 2017 at 17:31, Daniel Vetter  wrote:
> On Tue, Jan 10, 2017 at 05:54:57PM +0200, Ville Syrjälä wrote:
>> On Tue, Jan 10, 2017 at 02:43:05PM +0100, Tomeu Vizoso wrote:
>> > Use drm_accurate_vblank_count so we have the full 32 bit to represent
>> > the frame counter and userspace has a simpler way of knowing when the
>> > counter wraps around.
>> >
>> > Signed-off-by: Tomeu Vizoso 
>> > Reviewed-by: Emil Velikov 
>> > Reviewed-by: Robert Foss 
>> > ---
>> >
>> >  drivers/gpu/drm/i915/i915_irq.c | 6 +++---
>> >  1 file changed, 3 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/i915/i915_irq.c 
>> > b/drivers/gpu/drm/i915/i915_irq.c
>> > index b9beb5955dae..75fb1f66cc0c 100644
>> > --- a/drivers/gpu/drm/i915/i915_irq.c
>> > +++ b/drivers/gpu/drm/i915/i915_irq.c
>> > @@ -1557,7 +1557,6 @@ static void display_pipe_crc_irq_handler(struct 
>> > drm_i915_private *dev_priv,
>> > struct drm_driver *driver = dev_priv->drm.driver;
>> > uint32_t crcs[5];
>> > int head, tail;
>> > -   u32 frame;
>> >
>> > spin_lock(&pipe_crc->lock);
>> > if (pipe_crc->source) {
>> > @@ -1612,8 +1611,9 @@ static void display_pipe_crc_irq_handler(struct 
>> > drm_i915_private *dev_priv,
>> > crcs[2] = crc2;
>> > crcs[3] = crc3;
>> > crcs[4] = crc4;
>> > -   frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
>> > -   drm_crtc_add_crc_entry(&crtc->base, true, frame, crcs);
>> > +   drm_crtc_add_crc_entry(&crtc->base, true,
>> > +  drm_accurate_vblank_count(&crtc->base),
>>
>> My assumption would be that this gets called after the vblank irq
>> handler, so using the _accurate version seems a bit overkill.
>
> Since we're at like v15 of this I figured I'll pull this in, and we can
> polish this a bit more later. Tomeu, can you pls do that follow-up patch
> and get Ville to review+merge it.

At least on the SKL and SNB I have here, the -sequence subtests in
kms_pipe_crc_basic fail if I replace the call to
drm_accurate_vblank_count with drm_crtc_vblank_count.

Any ideas on why this could be?

Thanks,

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


[Intel-gfx] [RESEND PATCH v14 2/2] drm/i915: Put "cooked" vlank counters in frame CRC lines

2017-01-10 Thread Tomeu Vizoso
Use drm_accurate_vblank_count so we have the full 32 bit to represent
the frame counter and userspace has a simpler way of knowing when the
counter wraps around.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
Reviewed-by: Robert Foss 
---

 drivers/gpu/drm/i915/i915_irq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index b9beb5955dae..75fb1f66cc0c 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1557,7 +1557,6 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
struct drm_driver *driver = dev_priv->drm.driver;
uint32_t crcs[5];
int head, tail;
-   u32 frame;
 
spin_lock(&pipe_crc->lock);
if (pipe_crc->source) {
@@ -1612,8 +1611,9 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
crcs[2] = crc2;
crcs[3] = crc3;
crcs[4] = crc4;
-   frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
-   drm_crtc_add_crc_entry(&crtc->base, true, frame, crcs);
+   drm_crtc_add_crc_entry(&crtc->base, true,
+  drm_accurate_vblank_count(&crtc->base),
+  crcs);
}
 }
 #else
-- 
2.9.3

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


[Intel-gfx] [RESEND PATCH v14 1/2] drm/i915: Use new CRC debugfs API

2017-01-10 Thread Tomeu Vizoso
The core provides now an ABI to userspace for generation of frame CRCs,
so implement the ->set_crc_source() callback and reuse as much code as
possible with the previous ABI implementation.

When handling the pageflip interrupt, we skip 1 or 2 frames depending on
the HW because they contain wrong values. For the legacy ABI for
generating frame CRCs, this was done in userspace but now that we have a
generic ABI it's better if it's not exposed by the kernel.

v2:
- Leave the legacy implementation in place as the ABI implementation
  in the core is incompatible with it.
v3:
- Use the "cooked" vblank counter so we have a whole 32 bits.
- Make sure we don't mess with the state of the legacy CRC capture
  ABI implementation.
v4:
- Keep use of get_vblank_counter as in the legacy code, will be
  changed in a followup commit.

v5:
- Skip first frame or two as it's known that they contain wrong
  data.
- A few fixes suggested by Emil Velikov.

v6:
- Rework programming of the HW registers to preserve previous
  behavior.

v7:
- Address whitespace issue.
- Added a comment on why in the implementation of the new ABI we
  skip the 1st or 2nd frames.

v9:
- Add stub for intel_crtc_set_crc_source.

v12:
- Rebased.
- Remove stub for intel_crtc_set_crc_source and instead set the
  callback to NULL (Jani Nikula).

v15:
    - Rebased.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
Reviewed-by: Robert Foss 

irq

---

 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 77 ++--
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  6 +++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 5 files changed, 142 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ffeebf869e36..7a0eab675031 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1810,6 +1810,7 @@ struct intel_pipe_crc {
enum intel_pipe_crc_source source;
int head, tail;
wait_queue_head_t wq;
+   int skipped;
 };
 
 struct i915_frontbuffer_tracking {
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index a0e70f5b3aad..b9beb5955dae 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1553,41 +1553,68 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
 {
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
struct intel_pipe_crc_entry *entry;
+   struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
+   struct drm_driver *driver = dev_priv->drm.driver;
+   uint32_t crcs[5];
int head, tail;
+   u32 frame;
 
spin_lock(&pipe_crc->lock);
+   if (pipe_crc->source) {
+   if (!pipe_crc->entries) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_DEBUG_KMS("spurious interrupt\n");
+   return;
+   }
 
-   if (!pipe_crc->entries) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_DEBUG_KMS("spurious interrupt\n");
-   return;
-   }
-
-   head = pipe_crc->head;
-   tail = pipe_crc->tail;
+   head = pipe_crc->head;
+   tail = pipe_crc->tail;
 
-   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_ERROR("CRC buffer overflowing\n");
-   return;
-   }
+   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_ERROR("CRC buffer overflowing\n");
+   return;
+   }
 
-   entry = &pipe_crc->entries[head];
+   entry = &pipe_crc->entries[head];
 
-   entry->frame = dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm,
-pipe);
-   entry->crc[0] = crc0;
-   entry->crc[1] = crc1;
-   entry->crc[2] = crc2;
-   entry->crc[3] = crc3;
-   entry->crc[4] = crc4;
+   entry->frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
+   entry->crc[0] = crc0;
+   entry->crc[1] = crc1;
+   entry->crc[2] = crc2;
+   entry->crc[3] = crc3;
+   entry->crc[4] = crc4;
 
-   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
-   pipe_crc->head = head;
+   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
+   

[Intel-gfx] [RESEND PATCH v14 0/2] New debugfs API for capturing CRC of frames

2017-01-10 Thread Tomeu Vizoso
Hi,

here are the last two patches that remain to be merged in this series,
rebased on today's drm-tip.

Thanks,

Tomeu


Tomeu Vizoso (2):
  drm/i915: Use new CRC debugfs API
  drm/i915: Put "cooked" vlank counters in frame CRC lines

 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 77 ++--
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  6 +++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 5 files changed, 142 insertions(+), 37 deletions(-)

-- 
2.9.3

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


[Intel-gfx] [PATCH i-g-t] lib: Make sure we don't use a negative offset

2017-01-06 Thread Tomeu Vizoso
As bytes_read can contain an error condition under some circumstances,
in which we want to error out.

Signed-off-by: Tomeu Vizoso 
---
 lib/igt_debugfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index d828687a62ca..b1b67e740041 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -601,6 +601,7 @@ static int read_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t 
*out)
igt_assert(pipe_crc->flags & O_NONBLOCK);
bytes_read = 0;
}
+   igt_assert_lte(0, bytes_read);
buf[bytes_read] = '\0';
 
if (bytes_read && !pipe_crc_init_from_string(pipe_crc, out, buf))
-- 
2.9.3

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


[Intel-gfx] [PATCH v14 4/4] drm/i915: Put "cooked" vlank counters in frame CRC lines

2017-01-02 Thread Tomeu Vizoso
Use drm_accurate_vblank_count so we have the full 32 bit to represent
the frame counter and userspace has a simpler way of knowing when the
counter wraps around.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
Reviewed-by: Robert Foss 
---

 drivers/gpu/drm/i915/i915_irq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 24b7620c1005..c0e3d1c1b4f0 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1557,7 +1557,6 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
struct drm_driver *driver = dev_priv->drm.driver;
uint32_t crcs[5];
int head, tail, ret;
-   u32 frame;
 
spin_lock(&pipe_crc->lock);
if (pipe_crc->source) {
@@ -1612,8 +1611,9 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
crcs[2] = crc2;
crcs[3] = crc3;
crcs[4] = crc4;
-   frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
-   ret = drm_crtc_add_crc_entry(&crtc->base, true, frame, crcs);
+   ret = drm_crtc_add_crc_entry(&crtc->base, true,
+
drm_accurate_vblank_count(&crtc->base),
+crcs);
if (!ret)
wake_up_interruptible(&crtc->base.crc.wq);
}
-- 
2.9.3

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


[Intel-gfx] [PATCH v14 3/4] drm/i915: Use new CRC debugfs API

2017-01-02 Thread Tomeu Vizoso
The core provides now an ABI to userspace for generation of frame CRCs,
so implement the ->set_crc_source() callback and reuse as much code as
possible with the previous ABI implementation.

When handling the pageflip interrupt, we skip 1 or 2 frames depending on
the HW because they contain wrong values. For the legacy ABI for
generating frame CRCs, this was done in userspace but now that we have a
generic ABI it's better if it's not exposed by the kernel.

v2:
- Leave the legacy implementation in place as the ABI implementation
  in the core is incompatible with it.
v3:
- Use the "cooked" vblank counter so we have a whole 32 bits.
- Make sure we don't mess with the state of the legacy CRC capture
  ABI implementation.
v4:
- Keep use of get_vblank_counter as in the legacy code, will be
  changed in a followup commit.

v5:
- Skip first frame or two as it's known that they contain wrong
  data.
- A few fixes suggested by Emil Velikov.

v6:
- Rework programming of the HW registers to preserve previous
  behavior.

v7:
- Address whitespace issue.
- Added a comment on why in the implementation of the new ABI we
  skip the 1st or 2nd frames.

v9:
- Add stub for intel_crtc_set_crc_source.

v12:
- Rebased.
- Remove stub for intel_crtc_set_crc_source and instead set the
  callback to NULL (Jani Nikula).

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
Reviewed-by: Robert Foss 
---

 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 81 --
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  6 +++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 5 files changed, 145 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 77d7a079c51b..b8a66cc225ff 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1886,6 +1886,7 @@ struct intel_pipe_crc {
enum intel_pipe_crc_source source;
int head, tail;
wait_queue_head_t wq;
+   int skipped;
 };
 
 struct i915_frontbuffer_tracking {
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index a0e70f5b3aad..24b7620c1005 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1553,41 +1553,70 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
 {
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
struct intel_pipe_crc_entry *entry;
-   int head, tail;
+   struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
+   struct drm_driver *driver = dev_priv->drm.driver;
+   uint32_t crcs[5];
+   int head, tail, ret;
+   u32 frame;
 
spin_lock(&pipe_crc->lock);
+   if (pipe_crc->source) {
+   if (!pipe_crc->entries) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_DEBUG_KMS("spurious interrupt\n");
+   return;
+   }
 
-   if (!pipe_crc->entries) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_DEBUG_KMS("spurious interrupt\n");
-   return;
-   }
-
-   head = pipe_crc->head;
-   tail = pipe_crc->tail;
+   head = pipe_crc->head;
+   tail = pipe_crc->tail;
 
-   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_ERROR("CRC buffer overflowing\n");
-   return;
-   }
+   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_ERROR("CRC buffer overflowing\n");
+   return;
+   }
 
-   entry = &pipe_crc->entries[head];
+   entry = &pipe_crc->entries[head];
 
-   entry->frame = dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm,
-pipe);
-   entry->crc[0] = crc0;
-   entry->crc[1] = crc1;
-   entry->crc[2] = crc2;
-   entry->crc[3] = crc3;
-   entry->crc[4] = crc4;
+   entry->frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
+   entry->crc[0] = crc0;
+   entry->crc[1] = crc1;
+   entry->crc[2] = crc2;
+   entry->crc[3] = crc3;
+   entry->crc[4] = crc4;
 
-   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
-   pipe_crc->head = head;
+   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
+   

[Intel-gfx] [PATCH v14 0/4] New debugfs API for capturing CRC of frames

2017-01-02 Thread Tomeu Vizoso
Hi,

here are the patches that remain to be merged in this series.

Since v13, I have added a patch that makes open() block until the first
CRC comes. This is because otherwise, userspace would need to guess how
much time this particular HW takes to become ready to generate frame
CRCs. This patch could be dropped if it's preferred that userspace waits
for the first frame CRC to come before assuming that the HW is ready.

The other patches are unchanged.

Thanks,

Tomeu


Tomeu Vizoso (4):
  drm: Move locking into drm_debugfs_crtc_crc_add
  drm: crc: Wait for a frame before returning from open()
  drm/i915: Use new CRC debugfs API
  drm/i915: Put "cooked" vlank counters in frame CRC lines

 drivers/gpu/drm/drm_debugfs_crc.c | 32 +---
 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 81 --
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  6 +++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 6 files changed, 169 insertions(+), 46 deletions(-)

-- 
2.9.3

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


Re: [Intel-gfx] [PATCH 01/17] drm/docs: Small cleanup in drm-uapi.rst

2017-01-01 Thread Tomeu Vizoso
On 30 December 2016 at 12:12, David Herrmann  wrote:
> Hi
>
> On Thu, Dec 29, 2016 at 9:48 PM, Daniel Vetter  wrote:
>> - Remove the outdated hunk about driver documentation which somehow
>>   got misplaced here in the split-up.
>>
>> - Collect all the testing&validation stuff together and give the CRC
>>   section a heading for prettier output.
>>
>> Cc: Tomeu Vizoso 
>> Cc: Jani Nikula 
>> Signed-off-by: Daniel Vetter 
>> ---
>>  Documentation/gpu/drm-uapi.rst | 25 +++--
>>  1 file changed, 11 insertions(+), 14 deletions(-)
>
> Reviewed-by: David Herrmann 

Reviewed-by: Tomeu Vizoso 

Regards,

Tomeu

>
> Thanks
> David
>
>> diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
>> index de3ac9f90f8f..fcc228ef5bc4 100644
>> --- a/Documentation/gpu/drm-uapi.rst
>> +++ b/Documentation/gpu/drm-uapi.rst
>> @@ -156,8 +156,12 @@ other hand, a driver requires shared state between 
>> clients which is
>>  visible to user-space and accessible beyond open-file boundaries, they
>>  cannot support render nodes.
>>
>> +
>> +Testing and validation
>> +==
>> +
>>  Validating changes with IGT
>> -===
>> +---
>>
>>  There's a collection of tests that aims to cover the whole functionality of
>>  DRM drivers and that can be used to check that changes to DRM drivers or the
>> @@ -193,6 +197,12 @@ run-tests.sh is a wrapper around piglit that will 
>> execute the tests matching
>>  the -t options. A report in HTML format will be available in
>>  ./results/html/index.html. Results can be compared with piglit.
>>
>> +Display CRC Support
>> +---
>> +
>> +.. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
>> +   :doc: CRC ABI
>> +
>>  VBlank event handling
>>  =
>>
>> @@ -209,16 +219,3 @@ DRM_IOCTL_MODESET_CTL
>>  mode setting, since on many devices the vertical blank counter is
>>  reset to 0 at some point during modeset. Modern drivers should not
>>  call this any more since with kernel mode setting it is a no-op.
>> -
>> -This second part of the GPU Driver Developer's Guide documents driver
>> -code, implementation details and also all the driver-specific userspace
>> -interfaces. Especially since all hardware-acceleration interfaces to
>> -userspace are driver specific for efficiency and other reasons these
>> -interfaces can be rather substantial. Hence every driver has its own
>> -chapter.
>> -
>> -Testing and validation
>> -==
>> -
>> -.. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
>> -   :doc: CRC ABI
>> --
>> 2.7.4
>>
>> ___
>> dri-devel mailing list
>> dri-de...@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> ___
> 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


[Intel-gfx] [PATCH v13 2/3] drm/i915: Use new CRC debugfs API

2016-12-14 Thread Tomeu Vizoso
The core provides now an ABI to userspace for generation of frame CRCs,
so implement the ->set_crc_source() callback and reuse as much code as
possible with the previous ABI implementation.

When handling the pageflip interrupt, we skip 1 or 2 frames depending on
the HW because they contain wrong values. For the legacy ABI for
generating frame CRCs, this was done in userspace but now that we have a
generic ABI it's better if it's not exposed by the kernel.

v2:
- Leave the legacy implementation in place as the ABI implementation
  in the core is incompatible with it.
v3:
- Use the "cooked" vblank counter so we have a whole 32 bits.
- Make sure we don't mess with the state of the legacy CRC capture
  ABI implementation.
v4:
- Keep use of get_vblank_counter as in the legacy code, will be
  changed in a followup commit.

v5:
- Skip first frame or two as it's known that they contain wrong
  data.
- A few fixes suggested by Emil Velikov.

v6:
- Rework programming of the HW registers to preserve previous
  behavior.

v7:
- Address whitespace issue.
- Added a comment on why in the implementation of the new ABI we
  skip the 1st or 2nd frames.

v9:
- Add stub for intel_crtc_set_crc_source.

v12:
- Rebased.
- Remove stub for intel_crtc_set_crc_source and instead set the
  callback to NULL (Jani Nikula).

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 81 --
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  6 +++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 5 files changed, 145 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 20bc04d5e617..d7c0b44a1447 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1874,6 +1874,7 @@ struct intel_pipe_crc {
enum intel_pipe_crc_source source;
int head, tail;
wait_queue_head_t wq;
+   int skipped;
 };
 
 struct i915_frontbuffer_tracking {
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index a0e70f5b3aad..24b7620c1005 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1553,41 +1553,70 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
 {
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
struct intel_pipe_crc_entry *entry;
-   int head, tail;
+   struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
+   struct drm_driver *driver = dev_priv->drm.driver;
+   uint32_t crcs[5];
+   int head, tail, ret;
+   u32 frame;
 
spin_lock(&pipe_crc->lock);
+   if (pipe_crc->source) {
+   if (!pipe_crc->entries) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_DEBUG_KMS("spurious interrupt\n");
+   return;
+   }
 
-   if (!pipe_crc->entries) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_DEBUG_KMS("spurious interrupt\n");
-   return;
-   }
-
-   head = pipe_crc->head;
-   tail = pipe_crc->tail;
+   head = pipe_crc->head;
+   tail = pipe_crc->tail;
 
-   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_ERROR("CRC buffer overflowing\n");
-   return;
-   }
+   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_ERROR("CRC buffer overflowing\n");
+   return;
+   }
 
-   entry = &pipe_crc->entries[head];
+   entry = &pipe_crc->entries[head];
 
-   entry->frame = dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm,
-pipe);
-   entry->crc[0] = crc0;
-   entry->crc[1] = crc1;
-   entry->crc[2] = crc2;
-   entry->crc[3] = crc3;
-   entry->crc[4] = crc4;
+   entry->frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
+   entry->crc[0] = crc0;
+   entry->crc[1] = crc1;
+   entry->crc[2] = crc2;
+   entry->crc[3] = crc3;
+   entry->crc[4] = crc4;
 
-   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
-   pipe_crc->head = head;
+   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
+   

[Intel-gfx] [PATCH v13 3/3] drm/i915: Put "cooked" vlank counters in frame CRC lines

2016-12-14 Thread Tomeu Vizoso
Use drm_accurate_vblank_count so we have the full 32 bit to represent
the frame counter and userspace has a simpler way of knowing when the
counter wraps around.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_irq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 24b7620c1005..c0e3d1c1b4f0 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1557,7 +1557,6 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
struct drm_driver *driver = dev_priv->drm.driver;
uint32_t crcs[5];
int head, tail, ret;
-   u32 frame;
 
spin_lock(&pipe_crc->lock);
if (pipe_crc->source) {
@@ -1612,8 +1611,9 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
crcs[2] = crc2;
crcs[3] = crc3;
crcs[4] = crc4;
-   frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
-   ret = drm_crtc_add_crc_entry(&crtc->base, true, frame, crcs);
+   ret = drm_crtc_add_crc_entry(&crtc->base, true,
+
drm_accurate_vblank_count(&crtc->base),
+crcs);
if (!ret)
wake_up_interruptible(&crtc->base.crc.wq);
}
-- 
2.7.4

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


[Intel-gfx] [PATCH v13 0/3] New debugfs API for capturing CRC of frames

2016-12-14 Thread Tomeu Vizoso
Hi,

here are the patches that remain to be merged in this series.

I have only rebased them since last time.

Thanks,

Tomeu


Tomeu Vizoso (3):
  drm: Move locking into drm_debugfs_crtc_crc_add
  drm/i915: Use new CRC debugfs API
  drm/i915: Put "cooked" vlank counters in frame CRC lines

 drivers/gpu/drm/drm_debugfs_crc.c |  9 +++-
 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 81 --
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  6 +++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 6 files changed, 152 insertions(+), 40 deletions(-)

-- 
2.7.4

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


[Intel-gfx] [RESEND PATCH v12] drm/i915/debugfs: Move out pipe CRC code

2016-12-12 Thread Tomeu Vizoso
In preparation to using a generic API in the DRM core for continuous CRC
generation, move the related code out of i915_debugfs.c into a new file.

Eventually, only the Intel-specific code will remain in this new file.

v2: Rebased.

v6: Rebased.

v7: Fix whitespace issue.

v9: Have intel_display_crc_init accept a drm_i915_private instead.

v12: Rebased.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/i915/Makefile |   2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   | 882 +--
 drivers/gpu/drm/i915/intel_drv.h  |   5 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 939 ++
 4 files changed, 949 insertions(+), 879 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 3c30916727fb..5196509e71cf 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -24,7 +24,7 @@ i915-y := i915_drv.o \
  intel_runtime_pm.o
 
 i915-$(CONFIG_COMPAT)   += i915_ioc32.o
-i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o
+i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o intel_pipe_crc.o
 
 # GEM code
 i915-y += i915_cmd_parser.o \
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 54e196d9d83e..1fad1235a0c7 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -26,19 +26,9 @@
  *
  */
 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include "intel_drv.h"
-#include "intel_ringbuffer.h"
-#include 
-#include "i915_drv.h"
 
 static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
 {
@@ -3546,12 +3536,6 @@ static int i915_drrs_status(struct seq_file *m, void 
*unused)
return 0;
 }
 
-struct pipe_crc_info {
-   const char *name;
-   struct drm_i915_private *dev_priv;
-   enum pipe pipe;
-};
-
 static int i915_dp_mst_info(struct seq_file *m, void *unused)
 {
struct drm_i915_private *dev_priv = node_to_i915(m->private);
@@ -3581,844 +3565,6 @@ static int i915_dp_mst_info(struct seq_file *m, void 
*unused)
return 0;
 }
 
-static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes)
-   return -ENODEV;
-
-   spin_lock_irq(&pipe_crc->lock);
-
-   if (pipe_crc->opened) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EBUSY; /* already open */
-   }
-
-   pipe_crc->opened = true;
-   filep->private_data = inode->i_private;
-
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   spin_lock_irq(&pipe_crc->lock);
-   pipe_crc->opened = false;
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-/* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN  (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN(PIPE_CRC_LINE_LEN + 1)
-
-static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
-{
-   assert_spin_locked(&pipe_crc->lock);
-   return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
-   INTEL_PIPE_CRC_ENTRIES_NR);
-}
-
-static ssize_t
-i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
-  loff_t *pos)
-{
-   struct pipe_crc_info *info = filep->private_data;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-   char buf[PIPE_CRC_BUFFER_LEN];
-   int n_entries;
-   ssize_t bytes_read;
-
-   /*
-* Don't allow user space to provide buffers not big enough to hold
-* a line of data.
-*/
-   if (count < PIPE_CRC_LINE_LEN)
-   return -EINVAL;
-
-   if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
-   return 0;
-
-   /* nothing to read */
-   spin_lock_irq(&pipe_crc->lock);
-   while (pipe_crc_data_count(pipe_crc) == 0) {
-   int ret;
-
-   if (filep->f_flags & O_NONBLOCK) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EAGAIN;
-   }
-
-   ret = wait_

[Intel-gfx] [PATCH] drm/edid: Don't print an error if the checksum of a CEA block is wrong

2016-12-08 Thread Tomeu Vizoso
It's common to share screens within CI labs, and it's also common for
KVM switches to alter the contents of the CEA block but leave the
checksum outdated.

So in this case, print a debug message instead of an error.

References: https://bugs.freedesktop.org/show_bug.cgi?id=98228
Cc: Chris Wilson 
Cc: Tomi Sarvela 
Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Tomeu Vizoso 
---
 drivers/gpu/drm/drm_edid.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 6798c3ad9d53..db79bc949216 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -1128,16 +1128,19 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool 
print_bad_edid,
 
csum = drm_edid_block_checksum(raw_edid);
if (csum) {
-   if (print_bad_edid) {
-   DRM_ERROR("EDID checksum is invalid, remainder is 
%d\n", csum);
-   }
-
if (edid_corrupt)
*edid_corrupt = true;
 
/* allow CEA to slide through, switches mangle this */
-   if (raw_edid[0] != 0x02)
+   if (raw_edid[0] == CEA_EXT) {
+   DRM_DEBUG("EDID checksum is invalid, remainder is 
%d\n", csum);
+   DRM_DEBUG("Assuming a KVM switch modified the CEA block 
but left the original checksum\n");
+   } else {
+   if (print_bad_edid)
+   DRM_ERROR("EDID checksum is invalid, remainder 
is %d\n", csum);
+
goto bad;
+   }
}
 
/* per-block-type checks */
-- 
2.7.4

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


Re: [Intel-gfx] [RFC i-g-t v3 5/5] Add support for hotplug testing with the Chamelium

2016-12-07 Thread Tomeu Vizoso
On 7 December 2016 at 20:56, Lyude Paul  wrote:
> On Wed, 2016-12-07 at 12:27 +0100, Tomeu Vizoso wrote:
>> On 1 December 2016 at 02:24, Lyude  wrote:

(big snip)

>> > + * By default, this file is expected to exist in
>> > ~/.igt_chamelium_rc . The
>> > + * directory for this can be overriden by setting the environment
>> > variable
>> > + * %CHAMELIUM_CONFIG_PATH.
>>
>> It would be a pity if in time we need to add configuration parameters
>> for other aspects of IGT and we have to choose between renaming this
>> file, or having two configuration files for the same project. Why not
>> call it just .igt_rc?
> Nice catch. While I'm at it I'll add a patch to expose a function or
> two to get a global GKeyFile that's shared across tests that need
> configurations. As well I'll make sure connector groups are prefixed
> with something such as "Chamelium:" since we'll be sharing things.

Sounds great.

>> > +/**
>> > + * chamelium_async_hpd_pulse_finish:
>> > + *
>> > + * Waits for any asynchronous RPC started by
>> > #chamelium_async_hpd_pulse_start
>> > + * to complete, and then cleans up any leftover responses from the
>> > chamelium.
>> > + * If all of the RPC calls have already completed, this function
>> > returns
>> > + * immediately.
>>
>> This makes me wonder if it wouldn't have been better to go with
>> libsoup, as it uses a real event loop that we may need to use in
>> tests
>> for other reasons.
>
> Fwiw, I wouldn't worry about this part too much. The only reason we we
> use async calls here is so that we can use the mixed pulses RPC to get
> the chamelium to send delayed hotplug events by using the pulse width
> as the delay. I wouldn't think there would be any situations where the
> chamelium would fail to send a hotplug, since all that part requires is
> just asserting the hpd line. It could fail if the IO board stopped
> responding, but in that case everything else is going to fail too and
> we won't get the hotplug event we're expecting anyway.
>
> This is just my opinion though, if you can think of some use cases that
> this could seriously cause some issues I'll be happy to change it.

Fair enough. When this issue came up first, I tried to think of any
use cases in which having a proper event loop would be important, but
I wasn't able to back then and I still cannot think of anything, so
I'm fine with things as they are. Also, as you have the code
structured, it would be quite easy to switch to libsoup if needed in
the future.

>> > +   /* Sleep so we don't accidentally cause an hpd
>> > storm */
>> > +   sleep(1);
>>
>> Wouldn't such a long sleep unnecessarily slow test runs down?
> Yes, but I don't see much of a way around it right now. Eventually I'd
> like to add something to i915's debugfs to allow disabling HPD storm
> detection (we'll need this as well if we want to eventually add HPD
> storm detection tests).

That's cool, but I was thinking that the sleep duration could be shorter.

>> > +
>> > +static void
>> > +test_display(data_t *data, struct chamelium_port *port)
>> > +{
>> > +   igt_display_t display;
>> > +   igt_output_t *output;
>> > +   igt_plane_t *primary;
>> > +   struct igt_fb fb;
>> > +   drmModeRes *res;
>> > +   drmModeModeInfo *mode;
>> > +   drmModeConnector *connector;
>> > +   uint32_t crtc_id;
>> > +   int fb_id;
>> > +
>> > +   reset_state(data, port);
>> > +
>> > +   chamelium_plug(port->id);
>> > +   wait_for_connector(data, port, DRM_MODE_CONNECTED);
>> > +   igt_assert(res = drmModeGetResources(data->drm_fd));
>> > +   kmstest_unset_all_crtcs(data->drm_fd, res);
>> > +
>> > +   igt_display_init(&display, data->drm_fd);
>> > +
>> > +   /* Find the output struct for this connector */
>> > +   for_each_connected_output(&display, output) {
>> > +   if (output->config.connector->connector_id ==
>> > +   port->connector_id)
>> > +   break;
>>
>> Are we that sure that we'll always find such an output? Could be
>> quite
>> disconcerting if that stopped being true, even if by a bug.
> Not sure I follow here: that's what the wait_for_connector() call is
> there for. I'd expect that we could make the assumption we'll find a
> connector if we've managed to make it that far without failing.

My concern was rather that, as code evolve, that assumption could
become false and the bug would manifest in a disconcerting way. So I
would just assert that the connector that we got after the loop is
really the one we expected.

Thanks,

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


Re: [Intel-gfx] [RFC i-g-t v3 5/5] Add support for hotplug testing with the Chamelium

2016-12-07 Thread Tomeu Vizoso
Hi Lyude,

this looks very good. Some minor comments below.

Regards,

Tomeu

On 1 December 2016 at 02:24, Lyude  wrote:
> For the purpose of testing things such as hotplugging and bad monitors,
> the ChromeOS team ended up designing a neat little device known as the
> Chamelium. More information on this can be found here:
>
> https://www.chromium.org/chromium-os/testing/chamelium
>
> This adds support for a couple of things to intel-gpu-tools:
>  - igt library functions for connecting to udev and monitoring it for
>hotplug events, loosely based off of the unfinished hotplugging
>implementation in testdisplay
>  - Library functions for controlling the chamelium in tests using
>xmlrpc. A couple of RPC calls were ommitted here, mainly because they
>didn't seem very useful for our needs (yet)
>  - A set of basic tests using the chamelium.
>
> Signed-off-by: Lyude 
>
> Changes since v1:
> - Don't try to guess connector mappings, have the user specify them
>   manually using a configuration file
> - Open DRM fd using DRIVER_ANY, not DRIVER_INTEL
> - Lower the hotplug timeout a little bit, since 30 seconds was leftover
>   from debugging these tests anyway
> - Don't try to keep track of the original state of the chamelium ports,
>   and just leave them plugged in after each run. This makes more sense
>   to me, since I'd imagine in automated testing setups using chameliums
>   that all of the extra monitors will probably be provided by the
>   Chamelium to begin with, so keeping them plugged in would make sure
>   tests running afterwards that require >1 monitor don't get skipped.
> - Add wait_for_connector() to the chamelium tests. After some more
>   testing, I found that depending on the system some tests would throw
>   false negatives due to us not waiting long enough for the system to
>   detect that we connected something to it. This mainly happened with
>   VGA connectors, since their lack of HPD makes them take significantly
>   longer for the hardware to notice. wait_for_connector() fixes this by
>   continually reprobing the status of the desired connector (without
>   relying on a hpd event happening, since that might never come) until
>   we get what we want, or we time out and fail.
> - Use kmstest_get_property() for retrieving EDIDs instead of doing it by
>   hand
> - Don't hardcode PIPE_A for bringing up the display, use kmstest to find
>   an appropriate CRTC to use.
> Changes since v2:
> - Fix incorrect usage of the list helpers when recording new EDIDs
> - Add missing documentation
> - Make sure documentation actually appears
> - Since we finally got video capture working, add CRC functions and fix
>   the ones we couldn't actually test before
> - In the exit handler, reset the xmlrpc env so we can properly reset the
>   Chamelium even after an RPC error
> - Make sure compiling without Chamelium support still works
> ---
>  configure.ac   |  13 +
>  .../intel-gpu-tools/intel-gpu-tools-docs.xml   |   1 +
>  lib/Makefile.am|   4 +-
>  lib/Makefile.sources   |  10 +-
>  lib/igt.h  |   4 +
>  lib/igt_chamelium.c| 849 
> +
>  lib/igt_chamelium.h|  73 ++
>  scripts/run-tests.sh   |   4 +-
>  tests/Makefile.am  |   5 +-
>  tests/Makefile.sources |   9 +-
>  tests/chamelium.c  | 407 ++
>  11 files changed, 1371 insertions(+), 8 deletions(-)
>  create mode 100644 lib/igt_chamelium.c
>  create mode 100644 lib/igt_chamelium.h
>  create mode 100644 tests/chamelium.c
>
> diff --git a/configure.ac b/configure.ac
> index b62b8fc..1920609 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -263,6 +263,18 @@ if test "x$with_libunwind" = xyes; then
>   AC_MSG_ERROR([libunwind not found. Use 
> --without-libunwind to disable libunwind support.]))
>  fi
>
> +# enable support for using the chamelium
> +AC_ARG_ENABLE(chamelium,
> + AS_HELP_STRING([--disable-chamelium],
> +[Build tests without chamelium support]),
> + [], [enable_chamelium=yes])
> +
> +AM_CONDITIONAL(HAVE_CHAMELIUM, [test "x$enable_chamelium" = xyes])
> +if test "x$enable_chamelium" = xyes; then
> +   AC_DEFINE(HAVE_CHAMELIUM, 1, [chamelium suport])
> +   PKG_CHECK_MODULES(XMLRPC, xmlrpc_client)
> +fi
> +

IMO libxmlrpc is a very common dependency and thus adding the
possibility of disabling Chamelium support isn't worth the cruft we
have to add later. Plus, alternative build configurations tend to
break and remain broken as most people hacking on the project won't be
using them.

>  # enable debug symbols
>  AC_ARG_ENABLE(debug,
>   AS_HELP_STRING([--disable-debug],
> @@ -360,6 +

Re: [Intel-gfx] [PATCH i-g-t 1/3] igt_kms: Don't assume we have cursor planes if we have primary ones

2016-12-06 Thread Tomeu Vizoso
On 21 November 2016 at 23:32, Lyude  wrote:
> On certain models of nvidia and AMD GPUs, we can have a primary plane
> without any DRM plane for the cursor plane. Check for this so we don't
> segfault on non-intel hardware.
>
> Signed-off-by: Lyude 
> ---
>  lib/igt_kms.c | 27 +++
>  lib/igt_kms.h |  1 +
>  2 files changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 433a721..13d323e 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -1419,7 +1419,7 @@ void igt_display_init(igt_display_t *display, int 
> drm_fd)
> plane = &pipe->planes[IGT_PLANE_CURSOR];
> plane->is_cursor = 1;
> plane->index = IGT_PLANE_CURSOR;
> -   display->has_universal_planes = 1;
> +   display->has_cursor_plane = 1;

Looks good to me, but Daniel Vetter voiced support the other day for
dropping support for !has_universal_planes so it may not be a good
idea to complicate this further.

But if we go this way, the has_cursor_plane name could be misleading
in the !universal_plane case if there's a cursor plane.

Regards,

Tomeu

> break;
> default:
> plane = &pipe->planes[p];
> @@ -1444,9 +1444,20 @@ void igt_display_init(igt_display_t *display, int 
> drm_fd)
> plane->rotation = (igt_rotation_t)prop_value;
> }
>
> -   if (display->has_universal_planes) {
> +   if (!display->has_universal_planes) {
> +   /*
> +* No universal plane support.  Add drm_plane-less
> +* primary and cursor planes.
> +*/
> +   plane = &pipe->planes[IGT_PLANE_PRIMARY];
> +   plane->pipe = pipe;
> +   plane->index = IGT_PLANE_PRIMARY;
> +   plane->is_primary = true;
> +   }
> +
> +   if (display->has_cursor_plane) {
> /*
> -* If we have universal planes, we should have both
> +* If we have a cursor plane, we should have both
>  * primary and cursor planes setup now.
>  */
> igt_assert(pipe->planes[IGT_PLANE_PRIMARY].drm_plane 
> &&
> @@ -1464,15 +1475,7 @@ void igt_display_init(igt_display_t *display, int 
> drm_fd)
>sizeof *plane);
> }
> } else {
> -   /*
> -* No universal plane support.  Add drm_plane-less
> -* primary and cursor planes.
> -*/
> -   plane = &pipe->planes[IGT_PLANE_PRIMARY];
> -   plane->pipe = pipe;
> -   plane->index = IGT_PLANE_PRIMARY;
> -   plane->is_primary = true;
> -
> +   /* Add drm_plane-less cursor */
> plane = &pipe->planes[p];
> plane->pipe = pipe;
> plane->index = p;
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 95395cd..95d81c3 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -312,6 +312,7 @@ struct igt_display {
> igt_output_t *outputs;
> igt_pipe_t pipes[I915_MAX_PIPES];
> bool has_universal_planes;
> +   bool has_cursor_plane;
> bool is_atomic;
>  };
>
> --
> 2.7.4
>
> ___
> 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 2/3] igt_kms: Change the max number of pipes to 6

2016-12-06 Thread Tomeu Vizoso
On 21 November 2016 at 23:32, Lyude  wrote:
> Unfortunately the assumption that we only have 6 display pipes available
> is specific to Intel, and seems to be breaking igt_display_init() on
> both radeon and nouveau since this causes us not to leave enough space
> in the igt_display_t struct to hold information for all 6 pipes.
>
> So, up the max to 6. As well, add IGT_MAX_PIPES and use that instead
> since this is no longer specific to Intel. We also leave I915_MAX_PIPES
> defined as 3 so as to not break existing tests relying on this.

Hi Lyude,

we already have igt_display_t.n_pipes for this, which is count_crtcs.

So I think any tests should stop using the hardcoded values and use
the value we get from the kernel instead.

Regards,

Tomeu

> Signed-off-by: Lyude 
> ---
>  lib/igt_kms.h | 22 +++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 95d81c3..0ea2454 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -46,7 +46,10 @@
>   * @PIPE_A: First crtc.
>   * @PIPE_B: Second crtc.
>   * @PIPE_C: Third crtc.
> - * @I915_MAX_PIPES: Max number of pipes allowed.
> + * @PIPE_D: Fourth crtc.
> + * @PIPE_E: Fifth crtc.
> + * @PIPE_F: Sixth crtc.
> + * @IGT_MAX_PIPES: Max number of pipes allowed.
>   */
>  enum pipe {
>  PIPE_NONE = -1,
> @@ -54,10 +57,23 @@ enum pipe {
>  PIPE_A = 0,
>  PIPE_B,
>  PIPE_C,
> -I915_MAX_PIPES
> +   PIPE_D,
> +   PIPE_E,
> +   PIPE_F,
> +   IGT_MAX_PIPES,
>  };
>  const char *kmstest_pipe_name(enum pipe pipe);
>
> +/**
> + * I915_MAX_PIPES:
> + *
> + * The max number of pipes on i915 devices. This should only be used for 
> tests
> + * which are guaranteed to only be used on intel hardware. All other tests
> + * should use @IGT_MAX_PIPES and/or check the number of reported pipes on the
> + * hardware.
> + */
> +#define I915_MAX_PIPES 3
> +
>  /* We namespace this enum to not conflict with the Android i915_drm.h */
>  enum igt_plane {
> IGT_PLANE_1 = 0,
> @@ -310,7 +326,7 @@ struct igt_display {
> int n_outputs;
> unsigned long pipes_in_use;
> igt_output_t *outputs;
> -   igt_pipe_t pipes[I915_MAX_PIPES];
> +   igt_pipe_t pipes[IGT_MAX_PIPES];
> bool has_universal_planes;
> bool has_cursor_plane;
> bool is_atomic;
> --
> 2.7.4
>
> ___
> 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


[Intel-gfx] [PATCH i-g-t] lib: Use igt_assert_eq in CHECK_RETURN

2016-12-06 Thread Tomeu Vizoso
So that debug logs contain the unexpected value.

Signed-off-by: Tomeu Vizoso 
---
 lib/igt_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 989704e14803..1e30ddcc5373 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1681,7 +1681,7 @@ static uint32_t igt_plane_get_fb_gem_handle(igt_plane_t 
*plane)
 #define CHECK_RETURN(r, fail) {\
if (r && !fail) \
return r;   \
-   igt_assert(r == 0); \
+   igt_assert_eq(r, 0);\
 }
 
 
-- 
2.7.4

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


[Intel-gfx] [PATCH i-g-t v1] tests/kms_ccs: Add test for render compression

2016-12-06 Thread Tomeu Vizoso
Add a few subtests that check that lossless compressed render targets
are properly displayed. Also test a few error conditions.

Cc: Ville Syrjälä 
Cc: Ben Widawsky 
Signed-off-by: Tomeu Vizoso 

---
Hi,

this has been tested with Ville's branch at:

https://github.com/vsyrjala/linux/tree/fb_format_dedup_2_ccs

The test was based on Ville's one at:

https://github.com/vsyrjala/intel-gpu-tools/tree/ccs_test_3

Regards,

Tomeu
---
 lib/ioctl_wrappers.h   |   2 +
 tests/Makefile.sources |   1 +
 tests/kms_ccs.c| 306 +
 3 files changed, 309 insertions(+)
 create mode 100644 tests/kms_ccs.c

diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 26270975b6c2..71e2a5fe4fd1 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -222,6 +222,8 @@ struct local_drm_mode_fb_cmd2 {
 #define LOCAL_I915_FORMAT_MOD_X_TILED  local_fourcc_mod_code(INTEL, 1)
 #define LOCAL_I915_FORMAT_MOD_Y_TILED  local_fourcc_mod_code(INTEL, 2)
 #define LOCAL_I915_FORMAT_MOD_Yf_TILED local_fourcc_mod_code(INTEL, 3)
+#define LOCAL_I915_FORMAT_MOD_Y_TILED_CCS  local_fourcc_mod_code(INTEL, 4)
+#define LOCAL_I915_FORMAT_MOD_Yf_TILED_CCS local_fourcc_mod_code(INTEL, 5)
 
 #define LOCAL_DRM_IOCTL_MODE_ADDFB2DRM_IOWR(0xB8, \
 struct local_drm_mode_fb_cmd2)
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 65e079220d97..95c570a86675 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -91,6 +91,7 @@ TESTS_progs_M = \
kms_atomic \
kms_atomic_transition \
kms_busy \
+   kms_ccs \
kms_chv_cursor_fail \
kms_cursor_crc \
kms_cursor_legacy \
diff --git a/tests/kms_ccs.c b/tests/kms_ccs.c
new file mode 100644
index ..7e7255c374a4
--- /dev/null
+++ b/tests/kms_ccs.c
@@ -0,0 +1,306 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include "igt.h"
+
+IGT_TEST_DESCRIPTION("Test render compression (RC), in which the main surface "
+"is complemented by a color control surface (CCS) that "
+"the display uses to interpret the compressed data.");
+
+enum test_flags {
+   TEST_CRC= 1 << 1,
+   TEST_ROTATE_180 = 1 << 2,
+   TEST_BAD_PIXEL_FORMAT   = 1 << 3,
+   TEST_BAD_ROTATION_90= 1 << 4,
+};
+
+typedef struct {
+   int drm_fd;
+   igt_display_t display;
+   struct igt_fb fb;
+   igt_output_t *output;
+   enum pipe pipe;
+   enum test_flags flags;
+} data_t;
+
+#define COMPRESSED_RED 0x0fff
+#define COMPRESSED_GREEN   0x000ff00f
+#define COMPRESSED_BLUE0x0fff
+
+#define RED0x00ff
+
+static void render_fb(data_t *data, bool compressed)
+{
+   struct igt_fb *fb = &data->fb;
+   uint32_t *ptr;
+   int i;
+
+   igt_assert(fb->fb_id);
+
+   ptr = gem_mmap__cpu(data->drm_fd, fb->gem_handle,
+   0, fb->size,
+   PROT_READ | PROT_WRITE);
+
+   for (i = 0; i < fb->size / 4; i++) {
+   /* Fill upper half as compressed */
+   if (compressed && i < fb->size / 4 / 2)
+   ptr[i] = COMPRESSED_RED;
+   else
+   ptr[i] = RED;
+   }
+
+   munmap(ptr, fb->size);
+}
+
+static uint8_t *ccs_ptr(uint8_t *ptr,
+   unsigned int x, unsigned int y,
+   unsigned int stride)
+{
+   return ptr +
+   ((y & ~0x3f) * stride) +
+   ((x & ~0x7) * 64) +
+   ((y & 0x3f) *

Re: [Intel-gfx] [PATCH i-g-t v9 00/21] Implement sw_sync test

2016-12-05 Thread Tomeu Vizoso
This series has my Reviewed-by tag with the small issues I pointed out
addressed. But I think it would be very good if you could go through
all the igt_assert* calls and make sure that no information is being
lost that could aid in triaging and debugging.

The messages you chose for igt_assert_f were very good in explaining
*what* went wrong, but if the values used in the comparison were
contained in the string, the person reading the logs would have a
better chance of understanding *why* without having to instrument the
code and re-run.

Thanks,

Tomeu

On 22 November 2016 at 14:28,   wrote:
> From: Robert Foss 
>
> This series implements the sw_sync test and the lib/sw_sync helper functions
> for said test.
>
> The sw_sync subtests range from very basic tests of the sw_sync functionality,
> to stress testing and randomized tests.
>
>
> Changes since v1:
> Added "Reviewed-by: Eric Engestrom " tag
>
>   lib/sw_sync:
>   - Fixed fd value checking
>   - Fixed fd validity check in sw_sync_fd_close()
>   - Moved sw_sync related paths to define
>   - Switched from malloc+memset to calloc in sync_file_info()
>   - Switched sizeof to dereferenced ptr
>
>   tests/sw_sync:
>   - Moved lib/sw_sync related code to lib/sw_sync commit
>   - Replaced memset with assignment in loop
>
>
> Changes since v2:
>
>   lib/sw_sync:
>   - Replaced fd validity check in sw_sync_timeline_create()
>   - Replace sw_sync_XXX_destroy() functions with close()
>   - Simplified sw_sync_timeline_inc() comparison
>   - Changed sw_sync_merge() return value to -errno
>   - Changed name of sw_sync_fence_size() to sw_sync_fence_count()
>   - Reworked implementation of sw_sync_fence_count()
>   - Reworked implementation of sw_sync_fence_count_status()
>
>   tests/sw_sync:
>   - Replace sw_sync_XXX_destroy() functions with close()
>
>
> Changes since v3:
>
>   lib/sw_sync:
>   - Changed sw_sync_fence_create() to take uint32_t seqno
>   - Added raw __sw_sync_fence_create() and failure check 
> sw_sync_fence_create()
>
>   tests/sw_sync:
>   - Switch to using __sw_sync_fence_create() for failure cases
>
>
> Changes since v4:
>
>   lib/sw_sync:
>   - Fixed whitespace in sw_sync_fence_count()
>   - Fixed whitespace and style of sw_sync_wait()
>   - Fixed whitespace in __sw_sync_fence_count_status()
>
>
> Changes since v5:
>
>   lib/sw_sync:
>   - Added kernel_has_sw_sync()
>   - Added igt_require_sw_sync()
>   - Split out __sw_sync_merge() from sw_sync_merge()
>   - Added igt_debugfs.h include
>   - Change sw_sync_wait to reflect android implementation
>   - Renamed some functions:
>- sw_sync_merge -> sync_merge
>- sw_sync_wait -> sync_wait
>- sw_sync_fence_count -> sync_fence_count
>- sw_sync_fence_count_status -> sync_fence_count_status
>- __sw_sync_fence_count_status -> __sync_fence_count_status
>
>   tests/sw_sync:
>   - Added subtest test_sync_expired_merge
>   - Added subtest test_timeline_closed
>   - Added subtest test_timeline_closed_signaled
>   - Added subtest test_sync_merge_invalid
>   - Added subtest test_sync_busy_fork
>   - Added subtest test_sync_busy_unixsockets
>   - Skip test on no sw_sync support
>   - Reworked comments of test_sync_wait
>   - Renamed test_sync_wait -> test_sync_busy
>   - Improved test_sync_wait igt_assert_f messages
>
>
> Changes since v6:
>
>   tests/sw_sync:
>   - Added igt_assert to test_sync_expired_merge
>   - Added prime increments to test_sync_busy
>
>
> Changes since v7:
>
>   - Removed accidental inclusions
>
>
> Changes since v8:
>
>   - Removed some more accidental inclusions
>
>   lib/sw_sync:
> - Moved some changes into the lib/sw_sync commit
>
> Rafael Antognolli (1):
>   tests/sw_sync: Add subtest test_sync_expired_merge
>
> Robert Foss (20):
>   lib/sw_sync: Add helper functions for managing synchronization
> primitives
>   test/sw_sync: Add sw_sync test
>   tests/sw_sync: Add subtest test_alloc_fence
>   tests/sw_sync: Add subtest test_alloc_fence_invalid_timeline
>   tests/sw_sync: Add subtest test_alloc_merge_fence
>   tests/sw_sync: Add subtest test_sync_busy
>   tests/sw_sync: Add subtest test_sync_merge
>   tests/sw_sync: Add subtest test_sync_merge_same
>   tests/sw_sync: Add subtest test_sync_multi_consumer
>   tests/sw_sync: Add subtest test_sync_multi_consumer_producer
>   tests/sw_sync: Add subtest test_sync_random_merge
>   tests/sw_sync: Add subtest test_sync_multi_timeline_wait
>   tests/sw_sync: Add subtest test_sync_multi_producer_single_consumer
>   tests/sw_sync: Add subtest test_timeline_closed
>   tests/sw_sync: Add subtest test_timeline_closed_signaled
>   lib/sw_sync: Add igt_require_sw_sync to enable skipping on no sw_sync
> support
>   tests/sw_sync: Add igt_require check for sw_sync feature
>   tests/sw_sync: Add subtest test_sync_merge_invalid
>   tests/sw_sync: Add subtest test_sync_busy_fork
>   tests/sw_sync: Add subtest test_sync_busy_unixsocket
>
>  lib/Makefile.sources   |   2 +
>  lib/sw_sync.c  | 222 
>  lib/sw_

Re: [Intel-gfx] [PATCH i-g-t v9 09/21] tests/sw_sync: Add subtest test_sync_multi_consumer

2016-12-05 Thread Tomeu Vizoso
On 22 November 2016 at 14:28,   wrote:
> From: Robert Foss 
>
> This subtest verifies the access ordering of multiple consumer threads.
>
> Signed-off-by: Robert Foss 
> Reviewed-by: Eric Engestrom 
> ---
>  tests/sw_sync.c | 103 
> 
>  1 file changed, 103 insertions(+)
>
> diff --git a/tests/sw_sync.c b/tests/sw_sync.c
> index ada1243..cd0c588 100644
> --- a/tests/sw_sync.c
> +++ b/tests/sw_sync.c
> @@ -27,6 +27,8 @@
>   *Robert Foss 
>   */
>
> +#include 
> +#include 
>  #include 
>  #include 
>
> @@ -39,6 +41,15 @@
>
>  IGT_TEST_DESCRIPTION("Test SW Sync Framework");
>
> +typedef struct {
> +   int timeline;
> +   uint32_t thread_id;
> +   uint32_t nbr_threads;
> +   uint32_t nbr_iterations;

Any reason why these two cannot be just defines?

> +   volatile uint32_t * volatile counter;
> +   sem_t *sem;
> +} data_t;
> +
>  static void test_alloc_timeline(void)
>  {
> int timeline;
> @@ -219,6 +230,95 @@ static void test_sync_merge_same(void)
> close(timeline);
>  }
>
> +static void * test_sync_multi_consumer_thread(void *arg)
> +{
> +   data_t *data = arg;
> +   int thread_id = data->thread_id;
> +   int nbr_threads = data->nbr_threads;
> +   int timeline = data->timeline;
> +   int iterations = data->nbr_iterations;
> +   int ret, i;
> +
> +   for (i = 0; i < iterations; i++) {
> +   int next_point = i * nbr_threads + thread_id;
> +   int fence = sw_sync_fence_create(timeline, next_point);
> +
> +   ret = sync_wait(fence, 1000);
> +   if (ret == -1)
> +   {
> +   return (void *) 1;
> +   }
> +
> +   if (*(data->counter) != next_point)
> +   {
> +   return (void *) 1;
> +   }
> +
> +   sem_post(data->sem);
> +   close(fence);
> +   }
> +   return NULL;
> +}
> +
> +static void test_sync_multi_consumer(void)
> +{
> +   const uint32_t nbr_threads = 8;
> +   const uint32_t nbr_iterations = 1 << 14;
> +   data_t data_arr[nbr_threads];
> +   pthread_t thread_arr[nbr_threads];
> +   sem_t sem;
> +   int timeline;
> +   volatile uint32_t counter = 0;
> +   uintptr_t thread_ret = 0;
> +   data_t data;
> +   int i, ret;
> +
> +   sem_init(&sem, 0, 0);
> +   timeline = sw_sync_timeline_create();
> +
> +   data.nbr_iterations = nbr_iterations;
> +   data.nbr_threads = nbr_threads;
> +   data.counter = &counter;
> +   data.timeline = timeline;
> +   data.sem = &sem;
> +
> +   /* Start sync threads. */
> +   for (i = 0; i < nbr_threads; i++)
> +   {
> +   data_arr[i] = data;
> +   data_arr[i].thread_id = i;
> +   ret = pthread_create(&thread_arr[i], NULL,
> +test_sync_multi_consumer_thread,
> +(void *) &(data_arr[i]));
> +   igt_assert_eq(ret, 0);
> +   }
> +
> +   /* Produce 'content'. */
> +   for (i = 0; i < nbr_threads * nbr_iterations; i++)
> +   {
> +   sem_wait(&sem);
> +
> +   counter++;
> +   sw_sync_timeline_inc(timeline, 1);
> +   }
> +
> +   /* Wait for threads to complete. */
> +   for (i = 0; i < nbr_threads; i++)
> +   {
> +   uintptr_t local_thread_ret;
> +   pthread_join(thread_arr[i], (void **)&local_thread_ret);
> +   thread_ret |= local_thread_ret;
> +   }
> +
> +   close(timeline);
> +   sem_destroy(&sem);
> +
> +   igt_assert_f(counter == nbr_threads * nbr_iterations,
> +"Counter has unexpected value.\n");

In this case I think igt_assert_eq would be more useful.

> +   igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n");

Here probably as well, unless the message can be improved.

> +}
> +
>  igt_main
>  {
> igt_subtest("alloc_timeline")
> @@ -241,5 +341,8 @@ igt_main
>
> igt_subtest("sync_merge_same")
> test_sync_merge_same();
> +
> +   igt_subtest("sync_multi_consumer")
> +   test_sync_multi_consumer();
>  }
>
> --
> 2.10.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 v9 01/21] lib/sw_sync: Add helper functions for managing synchronization primitives

2016-12-05 Thread Tomeu Vizoso
Hi Robert,

looks pretty good to me, have just found a few nits.

With those addressed:

Reviewed-by: Tomeu Vizoso 

Regards,

Tomeu

On 22 November 2016 at 14:28,   wrote:
> From: Robert Foss 
>
> Base functions to help testing the Sync File Framework (explicit fencing
> mechanism ported from Android).
> These functions allow you to create, use and destroy timelines and fences.
>
> Signed-off-by: Robert Foss 
> Signed-off-by: Gustavo Padovan 
> Reviewed-by: Eric Engestrom 
> ---
>  lib/Makefile.sources |   2 +
>  lib/sw_sync.c| 199 
> +++
>  lib/sw_sync.h|  48 +
>  3 files changed, 249 insertions(+)
>  create mode 100644 lib/sw_sync.c
>  create mode 100644 lib/sw_sync.h
>
> diff --git a/lib/Makefile.sources b/lib/Makefile.sources
> index e8e277b..7aaf42f 100644
> --- a/lib/Makefile.sources
> +++ b/lib/Makefile.sources
> @@ -63,6 +63,8 @@ lib_source_list = \
> rendercopy_gen8.c   \
> rendercopy_gen9.c   \
> rendercopy.h\
> +   sw_sync.c   \
> +   sw_sync.h   \
> intel_reg_map.c \
> intel_iosf.c\
> igt_kms.c   \
> diff --git a/lib/sw_sync.c b/lib/sw_sync.c
> new file mode 100644
> index 000..862f8c4
> --- /dev/null
> +++ b/lib/sw_sync.c
> @@ -0,0 +1,199 @@
> +/*
> + * Copyright 2012 Google, Inc

What's the reason for this? I only see simple wrappers for the uapi in
the IGT style, so I wonder how it can be based in some work that
carries Google's copyright from 2012.

> + * Copyright © 2016 Collabora, Ltd.
> + *
> + * Based on the implementation from the Android Open Source Project

Ditto.

> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> DEALINGS
> + * IN THE SOFTWARE.
> + *
> + * Authors:
> + *Robert Foss 
> + */
> +
> +#ifndef ANDROID
> +#define _GNU_SOURCE
> +#else
> +#include 
> +#endif
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "sw_sync.h"
> +#include "drmtest.h"
> +#include "ioctl_wrappers.h"
> +
> +#ifndef SW_SYNC_IOC_INC
>
> +struct sw_sync_create_fence_data {
> +   __u32   value;
> +   charname[32];
> +   __s32   fence;
> +};
> +
> +#define SW_SYNC_IOC_MAGIC  'W'
> +#define SW_SYNC_IOC_CREATE_FENCE   _IOWR(SW_SYNC_IOC_MAGIC, 0,\
> +   struct 
> sw_sync_create_fence_data)
> +#define SW_SYNC_IOC_INC_IOW(SW_SYNC_IOC_MAGIC, 1, 
> __u32)
> +#endif

What about using the LOCAL_ scheme as in ioctl_wrappers.h so we have a
bigger chance of remembering to remove the local definitions once we
stop testing kernels without this API definition?

> +
> +#define DEVFS_SW_SYNC   "/dev/sw_sync"

What's the reason for this? May be worth adding a comment if we really
need to keep this.

> +#define DEBUGFS_SW_SYNC "/sys/kernel/debug/sync/sw_sync"
> +
> +
> +int sw_sync_fd_is_valid(int fd)

bool?

> +{
> +   int status;
> +
> +   if (fd < 0)
> +   return 0;
> +
> +   status = fcntl(fd, F_GETFD, 0);
> +   return status >= 0;
> +}
> +
> +int sw_sync_timeline_create(void)
> +{
> +   int fd = open(DEVFS_SW_SYNC, O_RDWR);
> +
> +   if (fd < 0)
> +   fd = open(DEBUGFS_SW_SYNC, O_RDWR);
> +
> +   igt_assert(sw_sync_fd_is_valid(fd));
> +
> +   return fd;
> +}
> +
> +int __sw_sync_

[Intel-gfx] [PATCH i-g-t v4] lib/debugfs: Support new generic ABI for CRC capture

2016-12-05 Thread Tomeu Vizoso
The kernel has now a new debugfs ABI that can also allow capturing frame
CRCs for drivers other than i915.

Add alternative codepaths so the new ABI is used if the kernel is recent
enough, and fall back to the legacy ABI if not.

Signed-off-by: Tomeu Vizoso 

---

Hi,

this has been rebased so Robert can test it.

Thanks,

Tomeu
---
 lib/igt_debugfs.c  | 190 +
 lib/igt_debugfs.h  |   4 +-
 tests/kms_pipe_crc_basic.c |  30 ++-
 3 files changed, 171 insertions(+), 53 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 9142e3f78868..3d92c6a10a41 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -291,25 +292,23 @@ char *igt_crc_to_string(igt_crc_t *crc)
 {
char buf[128];
 
-   igt_assert_eq(crc->n_words, 5);
-
sprintf(buf, "%08x %08x %08x %08x %08x", crc->crc[0],
crc->crc[1], crc->crc[2], crc->crc[3], crc->crc[4]);
 
return strdup(buf);
 }
 
+#define MAX_CRC_ENTRIES 10
+#define MAX_LINE_LEN (10 + 11 * MAX_CRC_ENTRIES + 1)
+
 /* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN   (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1)
+#define LEGACY_LINE_LEN   (6 * 8 + 5 + 1)
 
 struct _igt_pipe_crc {
int ctl_fd;
int crc_fd;
-   int line_len;
-   int buffer_len;
int flags;
+   bool is_legacy;
 
enum pipe pipe;
enum intel_pipe_crc_source source;
@@ -340,13 +339,26 @@ static bool igt_pipe_crc_do_start(igt_pipe_crc_t 
*pipe_crc)
/* Stop first just to make sure we don't have lingering state left. */
igt_pipe_crc_stop(pipe_crc);
 
-   sprintf(buf, "pipe %s %s", kmstest_pipe_name(pipe_crc->pipe),
-   pipe_crc_source_name(pipe_crc->source));
+   if (pipe_crc->is_legacy)
+   sprintf(buf, "pipe %s %s", kmstest_pipe_name(pipe_crc->pipe),
+   pipe_crc_source_name(pipe_crc->source));
+   else
+   sprintf(buf, "%s", pipe_crc_source_name(pipe_crc->source));
+
errno = 0;
igt_assert_eq(write(pipe_crc->ctl_fd, buf, strlen(buf)), strlen(buf));
if (errno != 0)
return false;
 
+   if (!pipe_crc->is_legacy) {
+   sprintf(buf, "crtc-%d/crc/data", pipe_crc->pipe);
+   errno = 0;
+   pipe_crc->crc_fd = igt_debugfs_open(buf, pipe_crc->flags);
+   if (pipe_crc->crc_fd == -1 && errno == EINVAL)
+   return false;
+   igt_assert_eq(errno, 0);
+   }
+
return true;
 }
 
@@ -360,15 +372,45 @@ static void igt_pipe_crc_pipe_off(int fd, enum pipe pipe)
 
 static void igt_pipe_crc_reset(void)
 {
+   igt_debugfs_t *debugfs = __igt_debugfs_singleton();
int fd;
+   struct dirent *dirent;
+   char buf[128];
+   const char *cmd = "none";
+   bool done = false;
+   DIR *dir;
+
+   dir = opendir(debugfs->dri_path);
+   if (dir) {
+   while ((dirent = readdir(dir))) {
+   if (strcmp(dirent->d_name, "crtc-") != 0)
+   continue;
+
+   sprintf(buf, "%s/%s/crc/control", debugfs->dri_path,
+   dirent->d_name);
+   fd = open(buf, O_WRONLY);
+   if (fd == -1)
+   continue;
+
+   igt_assert_eq(write(fd, cmd, strlen(cmd)), strlen(cmd));
+   done = true;
+
+   close(fd);
+   }
+   closedir(dir);
+   }
 
-   fd = igt_debugfs_open("i915_display_crc_ctl", O_WRONLY);
+   if (done)
+   return;
 
-   igt_pipe_crc_pipe_off(fd, PIPE_A);
-   igt_pipe_crc_pipe_off(fd, PIPE_B);
-   igt_pipe_crc_pipe_off(fd, PIPE_C);
+   fd = igt_debugfs_open("i915_display_crc_ctl", O_WRONLY);
+   if (fd != -1) {
+   igt_pipe_crc_pipe_off(fd, PIPE_A);
+   igt_pipe_crc_pipe_off(fd, PIPE_B);
+   igt_pipe_crc_pipe_off(fd, PIPE_C);
 
-   close(fd);
+   close(fd);
+   }
 }
 
 static void pipe_crc_exit_handler(int sig)
@@ -390,13 +432,16 @@ void igt_require_pipe_crc(void)
size_t written;
int ret;
 
-   ctl = igt_debugfs_fopen("i915_display_crc_ctl", "r+");
-   igt_require_f(ctl,
- "No display_crc_ctl found, kernel too old\n");
-   written = fwrite(cmd, 1, strlen(cmd), ctl);
-   ret = fflush(ctl);
-   igt_require_f((written == strlen(cmd) &&

[Intel-gfx] [RESEND PATCH v12 1/4] drm/i915/debugfs: Move out pipe CRC code

2016-12-04 Thread Tomeu Vizoso
In preparation to using a generic API in the DRM core for continuous CRC
generation, move the related code out of i915_debugfs.c into a new file.

Eventually, only the Intel-specific code will remain in this new file.

v2: Rebased.

v6: Rebased.

v7: Fix whitespace issue.

v9: Have intel_display_crc_init accept a drm_i915_private instead.

v12: Rebased.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/Makefile |   2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   | 882 +--
 drivers/gpu/drm/i915/intel_drv.h  |   5 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 939 ++
 4 files changed, 949 insertions(+), 879 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 3dea46af9fe6..0e4c15b93f04 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -24,7 +24,7 @@ i915-y := i915_drv.o \
  intel_runtime_pm.o
 
 i915-$(CONFIG_COMPAT)   += i915_ioc32.o
-i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o
+i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o intel_pipe_crc.o
 
 # GEM code
 i915-y += i915_cmd_parser.o \
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 96407f684f7f..d6de8e70ee96 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -26,19 +26,9 @@
  *
  */
 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include "intel_drv.h"
-#include "intel_ringbuffer.h"
-#include 
-#include "i915_drv.h"
 
 static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
 {
@@ -3547,12 +3537,6 @@ static int i915_drrs_status(struct seq_file *m, void 
*unused)
return 0;
 }
 
-struct pipe_crc_info {
-   const char *name;
-   struct drm_i915_private *dev_priv;
-   enum pipe pipe;
-};
-
 static int i915_dp_mst_info(struct seq_file *m, void *unused)
 {
struct drm_i915_private *dev_priv = node_to_i915(m->private);
@@ -3582,844 +3566,6 @@ static int i915_dp_mst_info(struct seq_file *m, void 
*unused)
return 0;
 }
 
-static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes)
-   return -ENODEV;
-
-   spin_lock_irq(&pipe_crc->lock);
-
-   if (pipe_crc->opened) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EBUSY; /* already open */
-   }
-
-   pipe_crc->opened = true;
-   filep->private_data = inode->i_private;
-
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   spin_lock_irq(&pipe_crc->lock);
-   pipe_crc->opened = false;
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-/* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN  (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN(PIPE_CRC_LINE_LEN + 1)
-
-static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
-{
-   assert_spin_locked(&pipe_crc->lock);
-   return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
-   INTEL_PIPE_CRC_ENTRIES_NR);
-}
-
-static ssize_t
-i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
-  loff_t *pos)
-{
-   struct pipe_crc_info *info = filep->private_data;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-   char buf[PIPE_CRC_BUFFER_LEN];
-   int n_entries;
-   ssize_t bytes_read;
-
-   /*
-* Don't allow user space to provide buffers not big enough to hold
-* a line of data.
-*/
-   if (count < PIPE_CRC_LINE_LEN)
-   return -EINVAL;
-
-   if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
-   return 0;
-
-   /* nothing to read */
-   spin_lock_irq(&pipe_crc->lock);
-   while (pipe_crc_data_count(pipe_crc) == 0) {
-   int ret;
-
-   if (filep->f_flags & O_NONBLOCK) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EAGAIN;
-   }
-
-   ret =

[Intel-gfx] [RESEND PATCH v12 3/4] drm/i915: Use new CRC debugfs API

2016-12-04 Thread Tomeu Vizoso
The core provides now an ABI to userspace for generation of frame CRCs,
so implement the ->set_crc_source() callback and reuse as much code as
possible with the previous ABI implementation.

When handling the pageflip interrupt, we skip 1 or 2 frames depending on
the HW because they contain wrong values. For the legacy ABI for
generating frame CRCs, this was done in userspace but now that we have a
generic ABI it's better if it's not exposed by the kernel.

v2:
- Leave the legacy implementation in place as the ABI implementation
  in the core is incompatible with it.
v3:
- Use the "cooked" vblank counter so we have a whole 32 bits.
- Make sure we don't mess with the state of the legacy CRC capture
  ABI implementation.
v4:
- Keep use of get_vblank_counter as in the legacy code, will be
  changed in a followup commit.

v5:
- Skip first frame or two as it's known that they contain wrong
  data.
- A few fixes suggested by Emil Velikov.

v6:
- Rework programming of the HW registers to preserve previous
  behavior.

v7:
- Address whitespace issue.
- Added a comment on why in the implementation of the new ABI we
  skip the 1st or 2nd frames.

v9:
- Add stub for intel_crtc_set_crc_source.

v12:
- Rebased.
- Remove stub for intel_crtc_set_crc_source and instead set the
  callback to NULL (Jani Nikula).

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 81 --
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  6 +++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 5 files changed, 145 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 56002a52936d..70aeb0d640fc 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1751,6 +1751,7 @@ struct intel_pipe_crc {
enum intel_pipe_crc_source source;
int head, tail;
wait_queue_head_t wq;
+   int skipped;
 };
 
 struct i915_frontbuffer_tracking {
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 07ca71cabb2b..2eac6ed0f653 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1553,41 +1553,70 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
 {
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
struct intel_pipe_crc_entry *entry;
-   int head, tail;
+   struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
+   struct drm_driver *driver = dev_priv->drm.driver;
+   uint32_t crcs[5];
+   int head, tail, ret;
+   u32 frame;
 
spin_lock(&pipe_crc->lock);
+   if (pipe_crc->source) {
+   if (!pipe_crc->entries) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_DEBUG_KMS("spurious interrupt\n");
+   return;
+   }
 
-   if (!pipe_crc->entries) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_DEBUG_KMS("spurious interrupt\n");
-   return;
-   }
-
-   head = pipe_crc->head;
-   tail = pipe_crc->tail;
+   head = pipe_crc->head;
+   tail = pipe_crc->tail;
 
-   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_ERROR("CRC buffer overflowing\n");
-   return;
-   }
+   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_ERROR("CRC buffer overflowing\n");
+   return;
+   }
 
-   entry = &pipe_crc->entries[head];
+   entry = &pipe_crc->entries[head];
 
-   entry->frame = dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm,
-pipe);
-   entry->crc[0] = crc0;
-   entry->crc[1] = crc1;
-   entry->crc[2] = crc2;
-   entry->crc[3] = crc3;
-   entry->crc[4] = crc4;
+   entry->frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
+   entry->crc[0] = crc0;
+   entry->crc[1] = crc1;
+   entry->crc[2] = crc2;
+   entry->crc[3] = crc3;
+   entry->crc[4] = crc4;
 
-   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
-   pipe_crc->head = head;
+   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
+   

[Intel-gfx] [RESEND PATCH v12 0/4] New debugfs API for capturing CRC of frames

2016-12-04 Thread Tomeu Vizoso
Hi,

here are the patches that remain to be merged in this series. They have
been rebased and I have also addressed two smaller comments:

- Move locking into drm_crtc_add_crc_entry (Daniel Vetter).
- Define intel_crtc_set_crc_source as NULL if !CONFIG_DEBUG_FS (Jani
  Nikula).

Thanks,

Tomeu


Tomeu Vizoso (4):
  drm/i915/debugfs: Move out pipe CRC code
  drm: Move locking into drm_debugfs_crtc_crc_add
  drm/i915: Use new CRC debugfs API
  drm/i915: Put "cooked" vlank counters in frame CRC lines

 drivers/gpu/drm/drm_debugfs_crc.c |9 +-
 drivers/gpu/drm/i915/Makefile |2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   |  882 +---
 drivers/gpu/drm/i915/i915_drv.h   |1 +
 drivers/gpu/drm/i915/i915_irq.c   |   81 ++-
 drivers/gpu/drm/i915/intel_display.c  |1 +
 drivers/gpu/drm/i915/intel_drv.h  |   11 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 1009 +
 8 files changed, 1089 insertions(+), 907 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

-- 
2.7.4

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


[Intel-gfx] [RESEND PATCH v12 4/4] drm/i915: Put "cooked" vlank counters in frame CRC lines

2016-12-04 Thread Tomeu Vizoso
Use drm_accurate_vblank_count so we have the full 32 bit to represent
the frame counter and userspace has a simpler way of knowing when the
counter wraps around.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_irq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 2eac6ed0f653..a395fe0fb4f3 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1557,7 +1557,6 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
struct drm_driver *driver = dev_priv->drm.driver;
uint32_t crcs[5];
int head, tail, ret;
-   u32 frame;
 
spin_lock(&pipe_crc->lock);
if (pipe_crc->source) {
@@ -1612,8 +1611,9 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
crcs[2] = crc2;
crcs[3] = crc3;
crcs[4] = crc4;
-   frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
-   ret = drm_crtc_add_crc_entry(&crtc->base, true, frame, crcs);
+   ret = drm_crtc_add_crc_entry(&crtc->base, true,
+
drm_accurate_vblank_count(&crtc->base),
+crcs);
if (!ret)
wake_up_interruptible(&crtc->base.crc.wq);
}
-- 
2.7.4

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


[Intel-gfx] [PATCH i-g-t 1/2] lib: Check format of framebuffer before SetPlane

2016-11-23 Thread Tomeu Vizoso
Avoid setting a framebuffer in a format that the plane doesn't support,
so we have better debug output in IGT and we don't have to dig into
dmesg files to find out what's going on.

I found this issue when kms_plane_scaling tried to use a cursor plane as
a regular one in a Skylake machine with just one overlay.

Signed-off-by: Tomeu Vizoso 
---
 lib/igt_kms.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 989704e14803..3234fa1bbdc4 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1670,6 +1670,14 @@ static uint32_t igt_plane_get_fb_id(igt_plane_t *plane)
return 0;
 }
 
+static uint32_t igt_plane_get_fb_format(igt_plane_t *plane)
+{
+   if (plane->fb)
+   return plane->fb->drm_format;
+   else
+   return 0;
+}
+
 static uint32_t igt_plane_get_fb_gem_handle(igt_plane_t *plane)
 {
if (plane->fb)
@@ -1678,6 +1686,28 @@ static uint32_t igt_plane_get_fb_gem_handle(igt_plane_t 
*plane)
return 0;
 }
 
+static bool igt_plane_supports_format(igt_plane_t *plane, uint32_t format)
+{
+   int i;
+
+   for (i = 0; i < plane->drm_plane->count_formats; i++) {
+   if (format == plane->drm_plane->formats[i])
+   return true;
+   }
+
+   igt_debug("Plane %d in pipe %s doesn't support format %s.\n",
+ plane->index,
+ kmstest_pipe_name(plane->pipe->pipe),
+ igt_format_str(format));
+
+   igt_debug("Formats supported are:");
+   for (i = 0; i < plane->drm_plane->count_formats; i++)
+   igt_debug(" %s", igt_format_str(plane->drm_plane->formats[i]));
+   igt_debug(".\n");
+
+   return false;
+}
+
 #define CHECK_RETURN(r, fail) {\
if (r && !fail) \
return r;   \
@@ -1772,6 +1802,7 @@ static int igt_drm_plane_commit(igt_plane_t *plane,
int32_t crtc_y;
uint32_t crtc_w;
uint32_t crtc_h;
+   uint32_t format;
 
igt_assert(plane->drm_plane);
 
@@ -1821,6 +1852,10 @@ static int igt_drm_plane_commit(igt_plane_t *plane,
src_x >> 16, src_y >> 16, src_w >> 16, src_h >> 16,
crtc_x, crtc_y, crtc_w, crtc_h);
 
+   /* it's an error to try an unsupported format */
+   format = igt_plane_get_fb_format(plane);
+   igt_assert(igt_plane_supports_format(plane, format));
+
ret = drmModeSetPlane(display->drm_fd,
  plane->drm_plane->plane_id,
  crtc_id,
-- 
2.7.4

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


[Intel-gfx] [PATCH i-g-t 0/2] Improve error report when there are less overlays than expected

2016-11-23 Thread Tomeu Vizoso
Hi,

kms_plane_scaling would happily try to use the cursor plane as if it was an
overlay, and the first signal of it would be the kernel refusing the SetPlane
call because of the pixel format not matching.

To improve this situation, we check the format of the framebuffer before
calling SetPlane (printing the supported formats), and skip the test if there
aren't enough overlay planes.

Thanks,

Tomeu

Tomeu Vizoso (2):
  lib: Check format of framebuffer before SetPlane
  kms_plane_scaling: Skip if we don't have enough overlays

 lib/igt_kms.c | 35 +++
 tests/kms_plane_scaling.c |  4 
 2 files changed, 39 insertions(+)

-- 
2.7.4

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


[Intel-gfx] [PATCH i-g-t 2/2] kms_plane_scaling: Skip if we don't have enough overlays

2016-11-23 Thread Tomeu Vizoso
The test currently assumes that there are two overlay planes available,
but that's not generally true and from the error that returns the
kernel, it isn't obvious what's going on.

Signed-off-by: Tomeu Vizoso 
---
 tests/kms_plane_scaling.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c
index 4546ce548515..0e2a875c6542 100644
--- a/tests/kms_plane_scaling.c
+++ b/tests/kms_plane_scaling.c
@@ -229,6 +229,8 @@ static void test_plane_scaling(data_t *d)
 
/* Set up fb2->plane2 mapping. */
d->plane2 = igt_output_get_plane(output, IGT_PLANE_2);
+   if(d->plane2->is_cursor)
+   continue;
igt_plane_set_fb(d->plane2, &d->fb2);
 
/* 2nd plane windowed */
@@ -265,6 +267,8 @@ static void test_plane_scaling(data_t *d)
 
/* Set up fb3->plane3 mapping. */
d->plane3 = igt_output_get_plane(output, IGT_PLANE_3);
+   if(d->plane3->is_cursor)
+   continue;
igt_plane_set_fb(d->plane3, &d->fb3);
 
/* 3rd plane windowed - no scaling */
-- 
2.7.4

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


Re: [Intel-gfx] [i-g-t PATCH v8 4/5] igt/kms_flip: Use new igt_spin_batch

2016-11-21 Thread Tomeu Vizoso
On 21 November 2016 at 10:25, Abdiel Janulgue
 wrote:
> v7: Reuse NSEC_PER_SEC defines
> v8: Don't wait on the fb, it must be busy. Exit the spin batch
> when flip is queued (Chris Wilson)
>
> Cc: Chris Wilson 
> Cc: Daniel Vetter 
> Signed-off-by: Abdiel Janulgue 
> ---
>  tests/kms_flip.c | 212 
> +++
>  1 file changed, 26 insertions(+), 186 deletions(-)

Looks good to me.

Reviewed-by: Tomeu Vizoso 

Cheers,

Tomeu

> diff --git a/tests/kms_flip.c b/tests/kms_flip.c
> index 2a9fe2e..437c564 100644
> --- a/tests/kms_flip.c
> +++ b/tests/kms_flip.c
> @@ -85,9 +85,6 @@
>  #define DRM_CAP_TIMESTAMP_MONOTONIC 6
>  #endif
>
> -#define USEC_PER_SEC 100L
> -#define NSEC_PER_SEC 10L
> -
>  drmModeRes *resources;
>  int drm_fd;
>  static drm_intel_bufmgr *bufmgr;
> @@ -191,109 +188,6 @@ static unsigned long gettime_us(void)
> return ts.tv_sec * 100 + ts.tv_nsec / 1000;
>  }
>
> -static int calibrate_dummy_load(struct test_output *o,
> -   const char *ring_name,
> -   int (*emit)(struct test_output *o, int limit, 
> int timeout))
> -{
> -   unsigned long start;
> -   int ops = 1;
> -
> -   start = gettime_us();
> -
> -   do {
> -   unsigned long diff;
> -   int ret;
> -
> -   ret = emit(o, (ops+1)/2, 10);
> -   diff = gettime_us() - start;
> -
> -   if (ret || diff / USEC_PER_SEC >= 1)
> -   break;
> -
> -   ops += ops;
> -   } while (ops < 10);
> -
> -   igt_debug("%s dummy load calibrated: %d operations / second\n",
> - ring_name, ops);
> -
> -   return ops;
> -}
> -
> -static void blit_copy(drm_intel_bo *dst, drm_intel_bo *src,
> - unsigned int width, unsigned int height,
> - unsigned int dst_pitch, unsigned int src_pitch)
> -{
> -   BLIT_COPY_BATCH_START(0);
> -   OUT_BATCH((3 << 24) | /* 32 bits */
> - (0xcc << 16) | /* copy ROP */
> - dst_pitch);
> -   OUT_BATCH(0 << 16 | 0);
> -   OUT_BATCH(height << 16 | width);
> -   OUT_RELOC_FENCED(dst, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 
> 0);
> -   OUT_BATCH(0 << 16 | 0);
> -   OUT_BATCH(src_pitch);
> -   OUT_RELOC_FENCED(src, I915_GEM_DOMAIN_RENDER, 0, 0);
> -   ADVANCE_BATCH();
> -
> -   if (batch->gen >= 6) {
> -   BEGIN_BATCH(3, 0);
> -   OUT_BATCH(XY_SETUP_CLIP_BLT_CMD);
> -   OUT_BATCH(0);
> -   OUT_BATCH(0);
> -   ADVANCE_BATCH();
> -   }
> -}
> -
> -static int _emit_dummy_load__bcs(struct test_output *o, int limit, int 
> timeout)
> -{
> -   int i, ret = 0;
> -   drm_intel_bo *src_bo, *dst_bo, *fb_bo;
> -   struct igt_fb *fb_info = &o->fb_info[o->current_fb_id];
> -
> -   igt_require(bufmgr);
> -
> -   src_bo = drm_intel_bo_alloc(bufmgr, "dummy_bo", 2048*2048*4, 4096);
> -   igt_assert(src_bo);
> -
> -   dst_bo = drm_intel_bo_alloc(bufmgr, "dummy_bo", 2048*2048*4, 4096);
> -   igt_assert(dst_bo);
> -
> -   fb_bo = gem_handle_to_libdrm_bo(bufmgr, drm_fd, "imported", 
> fb_info->gem_handle);
> -   igt_assert(fb_bo);
> -
> -   for (i = 0; i < limit; i++) {
> -   blit_copy(dst_bo, src_bo,
> - 2048, 2048,
> - 2048*4, 2048*4);
> -
> -   igt_swap(src_bo, dst_bo);
> -   }
> -   blit_copy(fb_bo, src_bo,
> - min(o->fb_width, 2048), min(o->fb_height, 2048),
> - fb_info->stride, 2048*4);
> -   intel_batchbuffer_flush(batch);
> -
> -   if (timeout > 0)
> -   ret = drm_intel_gem_bo_wait(fb_bo, timeout * NSEC_PER_SEC);
> -
> -   drm_intel_bo_unreference(src_bo);
> -   drm_intel_bo_unreference(dst_bo);
> -   drm_intel_bo_unreference(fb_bo);
> -
> -   return ret;
> -}
> -
> -static void emit_dummy_load__bcs(struct test_output *o, int seconds)
> -{
> -   static int ops_per_sec;
> -
> -   if (ops_per_sec == 0)
> -   ops_per_sec = calibrate_dummy_load(o, "bcs",
> -  _emit_dummy_load__bcs);
> -
> -   _emit_dummy_load__bcs(o, seconds * ops_per_sec, 0);
> -}
> -
>  static void emit_fence_stress(struct test_output *o)
>  {
> 

Re: [Intel-gfx] [i-g-t PATCH v8 5/5] igt/kms_busy.c: Use new igt_spin_batch

2016-11-21 Thread Tomeu Vizoso
Looks good to me.

Reviewed-by: Tomeu Vizoso 

Cheers,

Tomeu

On 21 November 2016 at 10:25, Abdiel Janulgue
 wrote:
> v7: Adapt to api rename
> v8: Tidy up finish_fb_busy (Chris Wilson)
>
> Cc: Chris Wilson 
> Cc: Daniel Vetter 
> Signed-off-by: Abdiel Janulgue 
> ---
>  tests/kms_busy.c | 81 
> +---
>  1 file changed, 6 insertions(+), 75 deletions(-)
>
> diff --git a/tests/kms_busy.c b/tests/kms_busy.c
> index b555f99..8a8a3eb 100644
> --- a/tests/kms_busy.c
> +++ b/tests/kms_busy.c
> @@ -78,80 +78,11 @@ static void do_cleanup_display(igt_display_t *dpy)
> igt_display_commit2(dpy, dpy->is_atomic ? COMMIT_ATOMIC : 
> COMMIT_LEGACY);
>  }
>
> -static uint32_t *
> -make_fb_busy(igt_display_t *dpy, unsigned ring, const struct igt_fb *fb)
> -{
> -   const int gen = intel_gen(intel_get_drm_devid(dpy->drm_fd));
> -   struct drm_i915_gem_exec_object2 obj[2];
> -#define SCRATCH 0
> -#define BATCH 1
> -   struct drm_i915_gem_relocation_entry reloc[2];
> -   struct drm_i915_gem_execbuffer2 execbuf;
> -   uint32_t *batch;
> -   int i;
> -
> -   memset(&execbuf, 0, sizeof(execbuf));
> -   execbuf.buffers_ptr = (uintptr_t)obj;
> -   execbuf.buffer_count = 2;
> -   execbuf.flags = ring;
> -
> -   memset(obj, 0, sizeof(obj));
> -   obj[SCRATCH].handle = fb->gem_handle;
> -
> -   obj[BATCH].handle = gem_create(dpy->drm_fd, 4096);
> -   obj[BATCH].relocs_ptr = (uintptr_t)reloc;
> -   obj[BATCH].relocation_count = 2;
> -   memset(reloc, 0, sizeof(reloc));
> -   reloc[0].target_handle = obj[BATCH].handle; /* recurse */
> -   reloc[0].presumed_offset = 0;
> -   reloc[0].offset = sizeof(uint32_t);
> -   reloc[0].delta = 0;
> -   reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND;
> -   reloc[0].write_domain = 0;
> -
> -   batch = gem_mmap__wc(dpy->drm_fd,
> -obj[BATCH].handle, 0, 4096, PROT_WRITE);
> -   gem_set_domain(dpy->drm_fd, obj[BATCH].handle,
> -  I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
> -
> -   batch[i = 0] = MI_BATCH_BUFFER_START;
> -   if (gen >= 8) {
> -   batch[i] |= 1 << 8 | 1;
> -   batch[++i] = 0;
> -   batch[++i] = 0;
> -   } else if (gen >= 6) {
> -   batch[i] |= 1 << 8;
> -   batch[++i] = 0;
> -   } else {
> -   batch[i] |= 2 << 6;
> -   batch[++i] = 0;
> -   if (gen < 4) {
> -   batch[i] |= 1;
> -   reloc[0].delta = 1;
> -   }
> -   }
> -
> -   /* dummy write to fb */
> -   reloc[1].target_handle = obj[SCRATCH].handle;
> -   reloc[1].presumed_offset = 0;
> -   reloc[1].offset = 1024;
> -   reloc[1].delta = 0;
> -   reloc[1].read_domains = I915_GEM_DOMAIN_RENDER;
> -   reloc[1].write_domain = I915_GEM_DOMAIN_RENDER;
> -
> -   gem_execbuf(dpy->drm_fd, &execbuf);
> -   gem_close(dpy->drm_fd, obj[BATCH].handle);
> -
> -   return batch;
> -}
> -
> -static void finish_fb_busy(uint32_t *batch, int msecs)
> +static void finish_fb_busy(igt_spin_t *spin, int msecs)
>  {
> struct timespec tv = { 0, msecs * 1000 * 1000 };
> nanosleep(&tv, NULL);
> -   batch[0] = MI_BATCH_BUFFER_END;
> -   __sync_synchronize();
> -   munmap(batch, 4096);
> +   igt_spin_batch_exit(spin);
>  }
>
>  static void sighandler(int sig)
> @@ -165,9 +96,8 @@ static void flip_to_fb(igt_display_t *dpy, int pipe,
> struct pollfd pfd = { .fd = dpy->drm_fd, .events = POLLIN };
> struct timespec tv = { 1, 0 };
> struct drm_event_vblank ev;
> -   uint32_t *batch;
> -
> -   batch = make_fb_busy(dpy, ring, fb);
> +   igt_spin_t *t = igt_spin_batch_new(dpy->drm_fd, -1,
> + ring, fb->gem_handle);
> igt_fork(child, 1) {
> igt_assert(gem_bo_busy(dpy->drm_fd, fb->gem_handle));
> do_or_die(drmModePageFlip(dpy->drm_fd,
> @@ -179,7 +109,8 @@ static void flip_to_fb(igt_display_t *dpy, int pipe,
> }
> igt_assert_f(nanosleep(&tv, NULL) == -1,
>  "flip to %s blocked waiting for busy fb", name);
> -   finish_fb_busy(batch, 2*TIMEOUT);
> +   finish_fb_busy(t, 2*TIMEOUT);
> +   igt_spin_batch_free(dpy->drm_fd, t);
> igt_waitchildren();
> igt_assert(read(dpy->drm_fd, &ev, sizeof(ev)) == sizeof(ev));
> igt_assert(poll(&pfd, 1, 0) == 0);
> --
> 2.7.4
>
> ___
> 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] [i-g-t PATCH v9 1/3] igt/gem_wait: Use new igt_spin_batch

2016-11-21 Thread Tomeu Vizoso
On 21 November 2016 at 13:07, Abdiel Janulgue
 wrote:
> v7: Adapt to api rename
> v8: Restore sanitycheck wait on the recursive batch and
> avoid using C99 locals (Chris Wilson)
> v9: Explicitly quit the batch instead of timing out right away
>
> Cc: Chris Wilson 
> Cc: Daniel Vetter 
> Cc: Tomeu Vizoso 
> Signed-off-by: Abdiel Janulgue 
> ---
>  tests/gem_wait.c | 126 
> ---
>  1 file changed, 7 insertions(+), 119 deletions(-)

Looks good to me.

Reviewed-by: Tomeu Vizoso 

Cheers,

Tomeu

> diff --git a/tests/gem_wait.c b/tests/gem_wait.c
> index b4127de..27d13f5 100644
> --- a/tests/gem_wait.c
> +++ b/tests/gem_wait.c
> @@ -27,18 +27,6 @@
>
>  #include "igt.h"
>
> -#include 
> -#include 
> -#include 
> -
> -#define gettid() syscall(__NR_gettid)
> -#define sigev_notify_thread_id _sigev_un._tid
> -
> -#define LOCAL_I915_EXEC_BSD_SHIFT  (13)
> -#define LOCAL_I915_EXEC_BSD_MASK   (3 << LOCAL_I915_EXEC_BSD_SHIFT)
> -
> -#define ENGINE_MASK  (I915_EXEC_RING_MASK | LOCAL_I915_EXEC_BSD_MASK)
> -
>  static int __gem_wait(int fd, struct drm_i915_gem_wait *w)
>  {
> int err;
> @@ -75,89 +63,18 @@ static void invalid_buf(int fd)
> igt_assert_eq(__gem_wait(fd, &wait), -ENOENT);
>  }
>
> -static uint32_t *batch;
> -
> -static void sigiter(int sig, siginfo_t *info, void *arg)
> -{
> -   *batch = MI_BATCH_BUFFER_END;
> -   __sync_synchronize();
> -}
> -
> -#define MSEC_PER_SEC (1000)
> -#define USEC_PER_SEC (1000 * MSEC_PER_SEC)
> -#define NSEC_PER_SEC (1000 * USEC_PER_SEC)
> -
>  #define BUSY 1
>  #define HANG 2
>  static void basic(int fd, unsigned engine, unsigned flags)
>  {
> -   const int gen = intel_gen(intel_get_drm_devid(fd));
> -   struct drm_i915_gem_exec_object2 obj;
> -   struct drm_i915_gem_relocation_entry reloc;
> -   struct drm_i915_gem_execbuffer2 execbuf;
> struct drm_i915_gem_wait wait;
> -   unsigned engines[16];
> -   unsigned nengine;
> -   int i, timeout;
> -
> -   nengine = 0;
> -   if (engine == -1) {
> -   for_each_engine(fd, engine)
> -   if (engine) engines[nengine++] = engine;
> -   } else {
> -   igt_require(gem_has_ring(fd, engine));
> -   engines[nengine++] = engine;
> -   }
> -   igt_require(nengine);
> -
> -   memset(&execbuf, 0, sizeof(execbuf));
> -   execbuf.buffers_ptr = (uintptr_t)&obj;
> -   execbuf.buffer_count = 1;
> -
> -   memset(&obj, 0, sizeof(obj));
> -   obj.handle = gem_create(fd, 4096);
> -
> -   obj.relocs_ptr = (uintptr_t)&reloc;
> -   obj.relocation_count = 1;
> -   memset(&reloc, 0, sizeof(reloc));
> -
> -   batch = gem_mmap__gtt(fd, obj.handle, 4096, PROT_WRITE);
> -   gem_set_domain(fd, obj.handle,
> -   I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
> -
> -   reloc.target_handle = obj.handle; /* recurse */
> -   reloc.presumed_offset = 0;
> -   reloc.offset = sizeof(uint32_t);
> -   reloc.delta = 0;
> -   reloc.read_domains = I915_GEM_DOMAIN_COMMAND;
> -   reloc.write_domain = 0;
> -
> -   i = 0;
> -   batch[i] = MI_BATCH_BUFFER_START;
> -   if (gen >= 8) {
> -   batch[i] |= 1 << 8 | 1;
> -   batch[++i] = 0;
> -   batch[++i] = 0;
> -   } else if (gen >= 6) {
> -   batch[i] |= 1 << 8;
> -   batch[++i] = 0;
> -   } else {
> -   batch[i] |= 2 << 6;
> -   batch[++i] = 0;
> -   if (gen < 4) {
> -   batch[i] |= 1;
> -   reloc.delta = 1;
> -   }
> -   }
> -
> -   for (i = 0; i < nengine; i++) {
> -   execbuf.flags &= ~ENGINE_MASK;
> -   execbuf.flags |= engines[i];
> -   gem_execbuf(fd, &execbuf);
> -   }
> +   igt_spin_t *spin;
> +   int timeout;
> +   int wait_s = (flags == 0) ? NSEC_PER_SEC : -1;
> +   spin = igt_spin_batch_new(fd, wait_s, engine, 0);
>
> memset(&wait, 0, sizeof(wait));
> -   wait.bo_handle = obj.handle;
> +   wait.bo_handle = spin->handle;
> igt_assert_eq(__gem_wait(fd, &wait), -ETIME);
>
> if (flags & BUSY) {
> @@ -165,8 +82,7 @@ static void basic(int fd, unsigned engine, unsigned flags)
>
> timeout = 120;
> if ((flags & HANG) == 0) {
> -

Re: [Intel-gfx] [i-g-t PATCH v9 2/5] lib: add igt_dummyload

2016-11-21 Thread Tomeu Vizoso
On 21 November 2016 at 10:25, Abdiel Janulgue
 wrote:
> A lot of igt testcases need some GPU workload to make sure a race
> window is big enough. Unfortunately having a fixed amount of
> workload leads to spurious test failures or overly long runtimes
> on some fast/slow platforms. This library contains functionality
> to submit GPU workloads that should consume exactly a specific
> amount of time.
>
> v2 : Add recursive batch feature from Chris
> v3 : Drop auto-tuned stuff. Add bo dependecy to recursive batch
>  by adding a dummy reloc to the bo as suggested by Ville.
> v4:  Fix dependency reloc as write instead of read (Ville).
>  Fix wrong handling of batchbuffer start on ILK causing
>  test failure
> v5:  Convert kms_busy to use this api
> v6:  Add this library to docs
> v7:  Document global use of batch, reuse defines
>  Minor code cleanups.
>  Rename igt_spin_batch and igt_post_spin_batch to
>  igt_spin_batch_new and igt_spin_batch_free
>  respectively (Tomeu Vizoso).
>  Fix error in dependency relocation handling in HSW causing
>  tests to fail.
> v8:  Restore correct order of objects in the execbuffer. Batch
>  object should always be last.
> v9 : Add helper to terminate batch manually
>
> Cc: Daniel Vetter 
> Cc: Ville Syrjälä 
> Cc: Chris Wilson 
> Cc: to...@tomeuvizoso.net
> Signed-off-by: Abdiel Janulgue 
> ---
>  .../intel-gpu-tools/intel-gpu-tools-docs.xml   |   1 +
>  lib/Makefile.sources   |   2 +
>  lib/igt.h  |   1 +
>  lib/igt_dummyload.c| 295 
> +
>  lib/igt_dummyload.h|  45 
>  5 files changed, 344 insertions(+)
>  create mode 100644 lib/igt_dummyload.c
>  create mode 100644 lib/igt_dummyload.h
>
> diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml 
> b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
> index c862f2a..55902ab 100644
> --- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
> +++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
> @@ -32,6 +32,7 @@
>  
>  
>  
> +
>
>
>
> diff --git a/lib/Makefile.sources b/lib/Makefile.sources
> index e8e277b..7fc5ec2 100644
> --- a/lib/Makefile.sources
> +++ b/lib/Makefile.sources
> @@ -75,6 +75,8 @@ lib_source_list = \
> igt_draw.h  \
> igt_pm.c\
> igt_pm.h\
> +   igt_dummyload.c \
> +   igt_dummyload.h \
> uwildmat/uwildmat.h \
> uwildmat/uwildmat.c \
> $(NULL)
> diff --git a/lib/igt.h b/lib/igt.h
> index d751f24..a0028d5 100644
> --- a/lib/igt.h
> +++ b/lib/igt.h
> @@ -32,6 +32,7 @@
>  #include "igt_core.h"
>  #include "igt_debugfs.h"
>  #include "igt_draw.h"
> +#include "igt_dummyload.h"
>  #include "igt_fb.h"
>  #include "igt_gt.h"
>  #include "igt_kms.h"
> diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
> new file mode 100644
> index 000..c3be8fa
> --- /dev/null
> +++ b/lib/igt_dummyload.c
> @@ -0,0 +1,295 @@
> +/*
> + * Copyright © 2016 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> DEALINGS
> + * IN THE SOFTWARE.
> + *
> + */
> +
> +#include "igt.h"
> +#include "igt_dummyload.h"
> +#include 
> +#include 
> +#include 
> +
> +/**
> + * SECTION:igt_dummyload
> + * @short_de

Re: [Intel-gfx] [i-g-t PATCH v7 1/5] lib: Make signal helper definitions reusable

2016-11-21 Thread Tomeu Vizoso
On 21 November 2016 at 10:25, Abdiel Janulgue
 wrote:
> More and more test-cases are using this.
>
> Signed-off-by: Abdiel Janulgue 
> ---
>  lib/igt_aux.c   | 11 ---
>  lib/igt_aux.h   | 10 ++
>  lib/igt_core.c  |  3 ---
>  tests/drv_hangman.c |  1 -
>  4 files changed, 10 insertions(+), 15 deletions(-)
>
> diff --git a/lib/igt_aux.c b/lib/igt_aux.c
> index 421f6d4..b5ae854 100644
> --- a/lib/igt_aux.c
> +++ b/lib/igt_aux.c
> @@ -75,17 +75,6 @@
>   * fit into any other topic.
>   */
>
> -
> -/* signal interrupt helpers */
> -
> -#define MSEC_PER_SEC (1000)
> -#define USEC_PER_SEC (1000*MSEC_PER_SEC)
> -#define NSEC_PER_SEC (1000*USEC_PER_SEC)
> -
> -/* signal interrupt helpers */
> -#define gettid() syscall(__NR_gettid)
> -#define sigev_notify_thread_id _sigev_un._tid

I see a few more instances of these in other files. Could those be removed now?

Otherwise it looks good to me.

Regards,

Tomeu

> -
>  static struct __igt_sigiter_global {
> pid_t tid;
> timer_t timer;
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> index d30196b..d4da499 100644
> --- a/lib/igt_aux.h
> +++ b/lib/igt_aux.h
> @@ -35,6 +35,16 @@
>  extern drm_intel_bo **trash_bos;
>  extern int num_trash_bos;
>
> +/* signal interrupt helpers */
> +
> +#define MSEC_PER_SEC (1000)
> +#define USEC_PER_SEC (1000*MSEC_PER_SEC)
> +#define NSEC_PER_SEC (1000*USEC_PER_SEC)
> +
> +/* signal interrupt helpers */
> +#define gettid() syscall(__NR_gettid)
> +#define sigev_notify_thread_id _sigev_un._tid
> +
>  /* auxialiary igt helpers from igt_aux.c */
>  /* generally useful helpers */
>  void igt_fork_signal_helper(void);
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 9cd5f98..f64c809 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -398,9 +398,6 @@ error:
> return -errno;
>  }
>
> -#define MSEC_PER_SEC (1000)
> -#define USEC_PER_SEC (1000*MSEC_PER_SEC)
> -#define NSEC_PER_SEC (1000*USEC_PER_SEC)
>  uint64_t igt_nsec_elapsed(struct timespec *start)
>  {
> struct timespec now;
> diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c
> index f80d65d..db0a077 100644
> --- a/tests/drv_hangman.c
> +++ b/tests/drv_hangman.c
> @@ -293,7 +293,6 @@ static void test_error_state_capture(unsigned ring_id,
>   * case and it takes a lot more time to wrap, so the acthd can potentially 
> keep
>   * increasing for a long time
>   */
> -#define NSEC_PER_SEC   10LL
>  static void hangcheck_unterminated(void)
>  {
> int fd;
> --
> 2.7.4
>
> ___
> 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] [i-g-t PATCH v8 3/5] igt/gem_wait: Use new igt_spin_batch

2016-11-21 Thread Tomeu Vizoso
On 21 November 2016 at 10:25, Abdiel Janulgue
 wrote:
> v7: Adapt to api rename
> v8: Restore sanitycheck wait on the recursive batch and
> avoid using C99 locals (Chris Wilson)
>
> Cc: Chris Wilson 
> Cc: Daniel Vetter 
> Signed-off-by: Abdiel Janulgue 
> ---
>  tests/gem_wait.c | 128 
> ---

Hi,

I'm seeing failures on i5-5200U that I don't see with this patch
reverted. They all look like this:

(gem_wait:19238) CRITICAL: Test assertion failure function basic, file
../../intel-gpu-tools/tests/gem_wait.c:80:
(gem_wait:19238) CRITICAL: Failed assertion: __gem_wait(fd, &wait) == -62
(gem_wait:19238) CRITICAL: Last errno: 62, Timer expired
(gem_wait:19238) CRITICAL: error: 0 != -62
Stack trace:
  #0 [__igt_fail_assert+0xf1]
  #1 [basic+0x214]
  #2 [+0x214]
Subtest busy-vebox failed.
 DEBUG 
(gem_wait:19238) ioctl-wrappers-DEBUG: Test requirement passed:
gem_has_ring(fd, ring)
(gem_wait:19238) igt-dummyload-DEBUG: Test requirement passed: nengine
(gem_wait:19238) CRITICAL: Test assertion failure function basic, file
../../intel-gpu-tools/tests/gem_wait.c:80:
(gem_wait:19238) CRITICAL: Failed assertion: __gem_wait(fd, &wait) == -62
(gem_wait:19238) CRITICAL: Last errno: 62, Timer expired
(gem_wait:19238) CRITICAL: error: 0 != -62
  END  
Subtest busy-vebox: FAIL (0.003s)

CI seems to have gained support for running BAT on IGT changes, but
that doesn't seem to have been wired to patchwork yet. Maybe you could
arrange for a CI run using a branch in your IGT tree? So this series
are tested on a wider array of HW.

Regards,

Tomeu

>  1 file changed, 8 insertions(+), 120 deletions(-)
>
> diff --git a/tests/gem_wait.c b/tests/gem_wait.c
> index b4127de..6332e76 100644
> --- a/tests/gem_wait.c
> +++ b/tests/gem_wait.c
> @@ -27,18 +27,6 @@
>
>  #include "igt.h"
>
> -#include 
> -#include 
> -#include 
> -
> -#define gettid() syscall(__NR_gettid)
> -#define sigev_notify_thread_id _sigev_un._tid
> -
> -#define LOCAL_I915_EXEC_BSD_SHIFT  (13)
> -#define LOCAL_I915_EXEC_BSD_MASK   (3 << LOCAL_I915_EXEC_BSD_SHIFT)
> -
> -#define ENGINE_MASK  (I915_EXEC_RING_MASK | LOCAL_I915_EXEC_BSD_MASK)
> -
>  static int __gem_wait(int fd, struct drm_i915_gem_wait *w)
>  {
> int err;
> @@ -75,129 +63,33 @@ static void invalid_buf(int fd)
> igt_assert_eq(__gem_wait(fd, &wait), -ENOENT);
>  }
>
> -static uint32_t *batch;
> -
> -static void sigiter(int sig, siginfo_t *info, void *arg)
> -{
> -   *batch = MI_BATCH_BUFFER_END;
> -   __sync_synchronize();
> -}
> -
> -#define MSEC_PER_SEC (1000)
> -#define USEC_PER_SEC (1000 * MSEC_PER_SEC)
> -#define NSEC_PER_SEC (1000 * USEC_PER_SEC)
> -
>  #define BUSY 1
>  #define HANG 2
>  static void basic(int fd, unsigned engine, unsigned flags)
>  {
> -   const int gen = intel_gen(intel_get_drm_devid(fd));
> -   struct drm_i915_gem_exec_object2 obj;
> -   struct drm_i915_gem_relocation_entry reloc;
> -   struct drm_i915_gem_execbuffer2 execbuf;
> struct drm_i915_gem_wait wait;
> -   unsigned engines[16];
> -   unsigned nengine;
> -   int i, timeout;
> -
> -   nengine = 0;
> -   if (engine == -1) {
> -   for_each_engine(fd, engine)
> -   if (engine) engines[nengine++] = engine;
> -   } else {
> -   igt_require(gem_has_ring(fd, engine));
> -   engines[nengine++] = engine;
> -   }
> -   igt_require(nengine);
> -
> -   memset(&execbuf, 0, sizeof(execbuf));
> -   execbuf.buffers_ptr = (uintptr_t)&obj;
> -   execbuf.buffer_count = 1;
> -
> -   memset(&obj, 0, sizeof(obj));
> -   obj.handle = gem_create(fd, 4096);
> -
> -   obj.relocs_ptr = (uintptr_t)&reloc;
> -   obj.relocation_count = 1;
> -   memset(&reloc, 0, sizeof(reloc));
> -
> -   batch = gem_mmap__gtt(fd, obj.handle, 4096, PROT_WRITE);
> -   gem_set_domain(fd, obj.handle,
> -   I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
> -
> -   reloc.target_handle = obj.handle; /* recurse */
> -   reloc.presumed_offset = 0;
> -   reloc.offset = sizeof(uint32_t);
> -   reloc.delta = 0;
> -   reloc.read_domains = I915_GEM_DOMAIN_COMMAND;
> -   reloc.write_domain = 0;
> -
> -   i = 0;
> -   batch[i] = MI_BATCH_BUFFER_START;
> -   if (gen >= 8) {
> -   batch[i] |= 1 << 8 | 1;
> -   batch[++i] = 0;
> -   batch[++i] = 0;
> -   } else if (gen >= 6) {
> -   batch[i] |= 1 << 8;
> -   batch[++i] = 0;
> -   } else {
> -   batch[i] |= 2 << 6;
> -   batch[++i] = 0;
> -   if (gen < 4) {
> -   batch[i] |= 1;
> -   reloc.delta = 1;
> -   }
> -   }
> +   igt_spin_t *spin;
> +   int timeout;
> +   int wait_s = (flags == 0) ? NSEC_PER_SEC : 0;
>
> -   for (i = 0; i < nengine; i++) {
> -   ex

[Intel-gfx] [PATCH i-g-t v3] lib/debugfs: Support new generic ABI for CRC capture

2016-11-17 Thread Tomeu Vizoso
The kernel has now a new debugfs ABI that can also allow capturing frame
CRCs for drivers other than i915.

Add alternative codepaths so the new ABI is used if the kernel is recent
enough, and fall back to the legacy ABI if not.

Signed-off-by: Tomeu Vizoso 

---

Have just rebased this, and made sure we fallback to the old ABI when
accessing the debugfs files directly from kms_pipe_crc_basic.

Thanks,

Tomeu
---
 lib/igt_debugfs.c  | 190 +
 lib/igt_debugfs.h  |   4 +-
 tests/kms_pipe_crc_basic.c |  30 ++-
 3 files changed, 171 insertions(+), 53 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 9142e3f78868..3d92c6a10a41 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -291,25 +292,23 @@ char *igt_crc_to_string(igt_crc_t *crc)
 {
char buf[128];
 
-   igt_assert_eq(crc->n_words, 5);
-
sprintf(buf, "%08x %08x %08x %08x %08x", crc->crc[0],
crc->crc[1], crc->crc[2], crc->crc[3], crc->crc[4]);
 
return strdup(buf);
 }
 
+#define MAX_CRC_ENTRIES 10
+#define MAX_LINE_LEN (10 + 11 * MAX_CRC_ENTRIES + 1)
+
 /* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN   (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1)
+#define LEGACY_LINE_LEN   (6 * 8 + 5 + 1)
 
 struct _igt_pipe_crc {
int ctl_fd;
int crc_fd;
-   int line_len;
-   int buffer_len;
int flags;
+   bool is_legacy;
 
enum pipe pipe;
enum intel_pipe_crc_source source;
@@ -340,13 +339,26 @@ static bool igt_pipe_crc_do_start(igt_pipe_crc_t 
*pipe_crc)
/* Stop first just to make sure we don't have lingering state left. */
igt_pipe_crc_stop(pipe_crc);
 
-   sprintf(buf, "pipe %s %s", kmstest_pipe_name(pipe_crc->pipe),
-   pipe_crc_source_name(pipe_crc->source));
+   if (pipe_crc->is_legacy)
+   sprintf(buf, "pipe %s %s", kmstest_pipe_name(pipe_crc->pipe),
+   pipe_crc_source_name(pipe_crc->source));
+   else
+   sprintf(buf, "%s", pipe_crc_source_name(pipe_crc->source));
+
errno = 0;
igt_assert_eq(write(pipe_crc->ctl_fd, buf, strlen(buf)), strlen(buf));
if (errno != 0)
return false;
 
+   if (!pipe_crc->is_legacy) {
+   sprintf(buf, "crtc-%d/crc/data", pipe_crc->pipe);
+   errno = 0;
+   pipe_crc->crc_fd = igt_debugfs_open(buf, pipe_crc->flags);
+   if (pipe_crc->crc_fd == -1 && errno == EINVAL)
+   return false;
+   igt_assert_eq(errno, 0);
+   }
+
return true;
 }
 
@@ -360,15 +372,45 @@ static void igt_pipe_crc_pipe_off(int fd, enum pipe pipe)
 
 static void igt_pipe_crc_reset(void)
 {
+   igt_debugfs_t *debugfs = __igt_debugfs_singleton();
int fd;
+   struct dirent *dirent;
+   char buf[128];
+   const char *cmd = "none";
+   bool done = false;
+   DIR *dir;
+
+   dir = opendir(debugfs->dri_path);
+   if (dir) {
+   while ((dirent = readdir(dir))) {
+   if (strcmp(dirent->d_name, "crtc-") != 0)
+   continue;
+
+   sprintf(buf, "%s/%s/crc/control", debugfs->dri_path,
+   dirent->d_name);
+   fd = open(buf, O_WRONLY);
+   if (fd == -1)
+   continue;
+
+   igt_assert_eq(write(fd, cmd, strlen(cmd)), strlen(cmd));
+   done = true;
+
+   close(fd);
+   }
+   closedir(dir);
+   }
 
-   fd = igt_debugfs_open("i915_display_crc_ctl", O_WRONLY);
+   if (done)
+   return;
 
-   igt_pipe_crc_pipe_off(fd, PIPE_A);
-   igt_pipe_crc_pipe_off(fd, PIPE_B);
-   igt_pipe_crc_pipe_off(fd, PIPE_C);
+   fd = igt_debugfs_open("i915_display_crc_ctl", O_WRONLY);
+   if (fd != -1) {
+   igt_pipe_crc_pipe_off(fd, PIPE_A);
+   igt_pipe_crc_pipe_off(fd, PIPE_B);
+   igt_pipe_crc_pipe_off(fd, PIPE_C);
 
-   close(fd);
+   close(fd);
+   }
 }
 
 static void pipe_crc_exit_handler(int sig)
@@ -390,13 +432,16 @@ void igt_require_pipe_crc(void)
size_t written;
int ret;
 
-   ctl = igt_debugfs_fopen("i915_display_crc_ctl", "r+");
-   igt_require_f(ctl,
- "No display_crc_ctl found, kernel too old\n");
-   written = fwrite(cmd, 1, strlen(cmd), ctl

[Intel-gfx] [PATCH v12 0/4] New debugfs API for capturing CRC of frames

2016-11-17 Thread Tomeu Vizoso
Hi,

here are the patches that remain to be merged in this series. They have
been rebased and I have also addressed two smaller comments:

- Move locking into drm_crtc_add_crc_entry (Daniel Vetter).
- Define intel_crtc_set_crc_source as NULL if !CONFIG_DEBUG_FS (Jani
  Nikula).

Thanks,

Tomeu


Tomeu Vizoso (4):
  drm/i915/debugfs: Move out pipe CRC code
  drm: Move locking into drm_debugfs_crtc_crc_add
  drm/i915: Use new CRC debugfs API
  drm/i915: Put "cooked" vlank counters in frame CRC lines

 drivers/gpu/drm/drm_debugfs_crc.c |9 +-
 drivers/gpu/drm/i915/Makefile |2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   |  882 +---
 drivers/gpu/drm/i915/i915_drv.h   |1 +
 drivers/gpu/drm/i915/i915_irq.c   |   81 ++-
 drivers/gpu/drm/i915/intel_display.c  |1 +
 drivers/gpu/drm/i915/intel_drv.h  |   11 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 1009 +
 8 files changed, 1089 insertions(+), 907 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

-- 
2.7.4

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


[Intel-gfx] [PATCH v12 3/4] drm/i915: Use new CRC debugfs API

2016-11-17 Thread Tomeu Vizoso
The core provides now an ABI to userspace for generation of frame CRCs,
so implement the ->set_crc_source() callback and reuse as much code as
possible with the previous ABI implementation.

When handling the pageflip interrupt, we skip 1 or 2 frames depending on
the HW because they contain wrong values. For the legacy ABI for
generating frame CRCs, this was done in userspace but now that we have a
generic ABI it's better if it's not exposed by the kernel.

v2:
- Leave the legacy implementation in place as the ABI implementation
  in the core is incompatible with it.
v3:
- Use the "cooked" vblank counter so we have a whole 32 bits.
- Make sure we don't mess with the state of the legacy CRC capture
  ABI implementation.
v4:
- Keep use of get_vblank_counter as in the legacy code, will be
  changed in a followup commit.

v5:
- Skip first frame or two as it's known that they contain wrong
  data.
- A few fixes suggested by Emil Velikov.

v6:
- Rework programming of the HW registers to preserve previous
  behavior.

v7:
- Address whitespace issue.
- Added a comment on why in the implementation of the new ABI we
  skip the 1st or 2nd frames.

v9:
- Add stub for intel_crtc_set_crc_source.

v12:
- Rebased.
- Remove stub for intel_crtc_set_crc_source and instead set the
  callback to NULL (Jani Nikula).

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 81 --
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  6 +++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 5 files changed, 145 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 006914ca36fe..86d63c446ca6 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1733,6 +1733,7 @@ struct intel_pipe_crc {
enum intel_pipe_crc_source source;
int head, tail;
wait_queue_head_t wq;
+   int skipped;
 };
 
 struct i915_frontbuffer_tracking {
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index cb8a75f6ca16..7870a86d7209 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1553,41 +1553,70 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
 {
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
struct intel_pipe_crc_entry *entry;
-   int head, tail;
+   struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
+   struct drm_driver *driver = dev_priv->drm.driver;
+   uint32_t crcs[5];
+   int head, tail, ret;
+   u32 frame;
 
spin_lock(&pipe_crc->lock);
+   if (pipe_crc->source) {
+   if (!pipe_crc->entries) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_DEBUG_KMS("spurious interrupt\n");
+   return;
+   }
 
-   if (!pipe_crc->entries) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_DEBUG_KMS("spurious interrupt\n");
-   return;
-   }
-
-   head = pipe_crc->head;
-   tail = pipe_crc->tail;
+   head = pipe_crc->head;
+   tail = pipe_crc->tail;
 
-   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_ERROR("CRC buffer overflowing\n");
-   return;
-   }
+   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_ERROR("CRC buffer overflowing\n");
+   return;
+   }
 
-   entry = &pipe_crc->entries[head];
+   entry = &pipe_crc->entries[head];
 
-   entry->frame = dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm,
-pipe);
-   entry->crc[0] = crc0;
-   entry->crc[1] = crc1;
-   entry->crc[2] = crc2;
-   entry->crc[3] = crc3;
-   entry->crc[4] = crc4;
+   entry->frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
+   entry->crc[0] = crc0;
+   entry->crc[1] = crc1;
+   entry->crc[2] = crc2;
+   entry->crc[3] = crc3;
+   entry->crc[4] = crc4;
 
-   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
-   pipe_crc->head = head;
+   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
+   

[Intel-gfx] [PATCH v12 1/4] drm/i915/debugfs: Move out pipe CRC code

2016-11-17 Thread Tomeu Vizoso
In preparation to using a generic API in the DRM core for continuous CRC
generation, move the related code out of i915_debugfs.c into a new file.

Eventually, only the Intel-specific code will remain in this new file.

v2: Rebased.

v6: Rebased.

v7: Fix whitespace issue.

v9: Have intel_display_crc_init accept a drm_i915_private instead.

v12: Rebased.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/Makefile |   2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   | 882 +--
 drivers/gpu/drm/i915/intel_drv.h  |   5 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 939 ++
 4 files changed, 949 insertions(+), 879 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 3dea46af9fe6..0e4c15b93f04 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -24,7 +24,7 @@ i915-y := i915_drv.o \
  intel_runtime_pm.o
 
 i915-$(CONFIG_COMPAT)   += i915_ioc32.o
-i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o
+i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o intel_pipe_crc.o
 
 # GEM code
 i915-y += i915_cmd_parser.o \
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 1cc971cb6cb1..7863d2080b19 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -26,19 +26,9 @@
  *
  */
 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include "intel_drv.h"
-#include "intel_ringbuffer.h"
-#include 
-#include "i915_drv.h"
 
 static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
 {
@@ -3548,12 +3538,6 @@ static int i915_drrs_status(struct seq_file *m, void 
*unused)
return 0;
 }
 
-struct pipe_crc_info {
-   const char *name;
-   struct drm_i915_private *dev_priv;
-   enum pipe pipe;
-};
-
 static int i915_dp_mst_info(struct seq_file *m, void *unused)
 {
struct drm_i915_private *dev_priv = node_to_i915(m->private);
@@ -3583,844 +3567,6 @@ static int i915_dp_mst_info(struct seq_file *m, void 
*unused)
return 0;
 }
 
-static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes)
-   return -ENODEV;
-
-   spin_lock_irq(&pipe_crc->lock);
-
-   if (pipe_crc->opened) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EBUSY; /* already open */
-   }
-
-   pipe_crc->opened = true;
-   filep->private_data = inode->i_private;
-
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   spin_lock_irq(&pipe_crc->lock);
-   pipe_crc->opened = false;
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-/* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN  (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN(PIPE_CRC_LINE_LEN + 1)
-
-static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
-{
-   assert_spin_locked(&pipe_crc->lock);
-   return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
-   INTEL_PIPE_CRC_ENTRIES_NR);
-}
-
-static ssize_t
-i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
-  loff_t *pos)
-{
-   struct pipe_crc_info *info = filep->private_data;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-   char buf[PIPE_CRC_BUFFER_LEN];
-   int n_entries;
-   ssize_t bytes_read;
-
-   /*
-* Don't allow user space to provide buffers not big enough to hold
-* a line of data.
-*/
-   if (count < PIPE_CRC_LINE_LEN)
-   return -EINVAL;
-
-   if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
-   return 0;
-
-   /* nothing to read */
-   spin_lock_irq(&pipe_crc->lock);
-   while (pipe_crc_data_count(pipe_crc) == 0) {
-   int ret;
-
-   if (filep->f_flags & O_NONBLOCK) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EAGAIN;
-   }
-
-   ret =

[Intel-gfx] [PATCH v12 4/4] drm/i915: Put "cooked" vlank counters in frame CRC lines

2016-11-17 Thread Tomeu Vizoso
Use drm_accurate_vblank_count so we have the full 32 bit to represent
the frame counter and userspace has a simpler way of knowing when the
counter wraps around.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_irq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 7870a86d7209..c522a8b611b8 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1557,7 +1557,6 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
struct drm_driver *driver = dev_priv->drm.driver;
uint32_t crcs[5];
int head, tail, ret;
-   u32 frame;
 
spin_lock(&pipe_crc->lock);
if (pipe_crc->source) {
@@ -1612,8 +1611,9 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
crcs[2] = crc2;
crcs[3] = crc3;
crcs[4] = crc4;
-   frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
-   ret = drm_crtc_add_crc_entry(&crtc->base, true, frame, crcs);
+   ret = drm_crtc_add_crc_entry(&crtc->base, true,
+
drm_accurate_vblank_count(&crtc->base),
+crcs);
if (!ret)
wake_up_interruptible(&crtc->base.crc.wq);
}
-- 
2.7.4

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


Re: [Intel-gfx] [PATCH v11 3/4] drm/i915: Use new CRC debugfs API

2016-11-16 Thread Tomeu Vizoso
On 16 November 2016 at 13:58, Jani Nikula  wrote:
> On Wed, 16 Nov 2016, Tomeu Vizoso  wrote:
>> On 15 November 2016 at 09:27, Jani Nikula  
>> wrote:
>>> On Tue, 15 Nov 2016, David Weinehall  wrote:
>>>> On Mon, Nov 14, 2016 at 12:44:25PM +0200, Jani Nikula wrote:
>>>>> On Thu, 06 Oct 2016, Tomeu Vizoso  wrote:
>>>>> > diff --git a/drivers/gpu/drm/i915/intel_display.c 
>>>>> > b/drivers/gpu/drm/i915/intel_display.c
>>>>> > index 23a6c7213eca..7412a05fa5d9 100644
>>>>> > --- a/drivers/gpu/drm/i915/intel_display.c
>>>>> > +++ b/drivers/gpu/drm/i915/intel_display.c
>>>>> > @@ -14636,6 +14636,7 @@ static const struct drm_crtc_funcs 
>>>>> > intel_crtc_funcs = {
>>>>> >.page_flip = intel_crtc_page_flip,
>>>>> >.atomic_duplicate_state = intel_crtc_duplicate_state,
>>>>> >.atomic_destroy_state = intel_crtc_destroy_state,
>>>>> > +  .set_crc_source = intel_crtc_set_crc_source,
>>>>> >  };
>>>>> >
>>>>> >  /**
>>>>> > diff --git a/drivers/gpu/drm/i915/intel_drv.h 
>>>>> > b/drivers/gpu/drm/i915/intel_drv.h
>>>>> > index 737261b09110..31894b7c6517 100644
>>>>> > --- a/drivers/gpu/drm/i915/intel_drv.h
>>>>> > +++ b/drivers/gpu/drm/i915/intel_drv.h
>>>>> > @@ -1844,6 +1844,14 @@ void intel_color_load_luts(struct drm_crtc_state 
>>>>> > *crtc_state);
>>>>> >  /* intel_pipe_crc.c */
>>>>> >  int intel_pipe_crc_create(struct drm_minor *minor);
>>>>> >  void intel_pipe_crc_cleanup(struct drm_minor *minor);
>>>>> > +#ifdef CONFIG_DEBUG_FS
>>>>> > +int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char 
>>>>> > *source_name,
>>>>> > +size_t *values_cnt);
>>>>> > +#else
>>>>> > +static inline int intel_crtc_set_crc_source(struct drm_crtc *crtc,
>>>>> > +  const char *source_name,
>>>>> > +  size_t *values_cnt) { return 0; }
>>>>> > +#endif
>>>>>
>>>>> "inline" here doesn't work because it's used as a function pointer.
>>>>>
>>>>> Is it better to have a function that returns 0 for .set_crc_source, or
>>>>> to set .set_crc_source to NULL when CONFIG_DEBUG_FS=n?
>>>>
>>>> I'd say that whenever we have a function pointer we should have a dummy
>>>> function without side-effects for this kind of things.
>>>
>>> Whoever calls .set_crc_source could do smarter things depending on the
>>> hook not being there vs. just silently plunging on.
>>
>> In this specific case, when CONFIG_DEBUG_FS=n it doesn't make any
>> sense to call that callback, so I think we should have a dummy
>> implementation to avoid adding an ifdef to the .c.
>
> We don't want the ifdef to the .c file, but we could do
>
> #ifdef CONFIG_DEBUG_FS
> int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name,
> size_t *values_cnt);
> #else
> #define intel_crtc_set_crc_source NULL
> #endif

Sounds good to me, and though I don't have any objections, wonder why
this isn't a common idiom in the DRM subsystem. I was able to find
only one instance: drm_compat_ioctl.

Regards,

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


Re: [Intel-gfx] [PATCH v11 3/4] drm/i915: Use new CRC debugfs API

2016-11-16 Thread Tomeu Vizoso
On 15 November 2016 at 09:27, Jani Nikula  wrote:
> On Tue, 15 Nov 2016, David Weinehall  wrote:
>> On Mon, Nov 14, 2016 at 12:44:25PM +0200, Jani Nikula wrote:
>>> On Thu, 06 Oct 2016, Tomeu Vizoso  wrote:
>>> > diff --git a/drivers/gpu/drm/i915/intel_display.c 
>>> > b/drivers/gpu/drm/i915/intel_display.c
>>> > index 23a6c7213eca..7412a05fa5d9 100644
>>> > --- a/drivers/gpu/drm/i915/intel_display.c
>>> > +++ b/drivers/gpu/drm/i915/intel_display.c
>>> > @@ -14636,6 +14636,7 @@ static const struct drm_crtc_funcs 
>>> > intel_crtc_funcs = {
>>> >.page_flip = intel_crtc_page_flip,
>>> >.atomic_duplicate_state = intel_crtc_duplicate_state,
>>> >.atomic_destroy_state = intel_crtc_destroy_state,
>>> > +  .set_crc_source = intel_crtc_set_crc_source,
>>> >  };
>>> >
>>> >  /**
>>> > diff --git a/drivers/gpu/drm/i915/intel_drv.h 
>>> > b/drivers/gpu/drm/i915/intel_drv.h
>>> > index 737261b09110..31894b7c6517 100644
>>> > --- a/drivers/gpu/drm/i915/intel_drv.h
>>> > +++ b/drivers/gpu/drm/i915/intel_drv.h
>>> > @@ -1844,6 +1844,14 @@ void intel_color_load_luts(struct drm_crtc_state 
>>> > *crtc_state);
>>> >  /* intel_pipe_crc.c */
>>> >  int intel_pipe_crc_create(struct drm_minor *minor);
>>> >  void intel_pipe_crc_cleanup(struct drm_minor *minor);
>>> > +#ifdef CONFIG_DEBUG_FS
>>> > +int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char 
>>> > *source_name,
>>> > +size_t *values_cnt);
>>> > +#else
>>> > +static inline int intel_crtc_set_crc_source(struct drm_crtc *crtc,
>>> > +  const char *source_name,
>>> > +  size_t *values_cnt) { return 0; }
>>> > +#endif
>>>
>>> "inline" here doesn't work because it's used as a function pointer.
>>>
>>> Is it better to have a function that returns 0 for .set_crc_source, or
>>> to set .set_crc_source to NULL when CONFIG_DEBUG_FS=n?
>>
>> I'd say that whenever we have a function pointer we should have a dummy
>> function without side-effects for this kind of things.
>
> Whoever calls .set_crc_source could do smarter things depending on the
> hook not being there vs. just silently plunging on.

In this specific case, when CONFIG_DEBUG_FS=n it doesn't make any
sense to call that callback, so I think we should have a dummy
implementation to avoid adding an ifdef to the .c.

Regards,

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


Re: [Intel-gfx] [RFC i-g-t 0/4] intel-gpu-tools: Add support for the Chamelium

2016-11-16 Thread Tomeu Vizoso
On 15 November 2016 at 22:44, Lyude Paul  wrote:
> I'm fine with libsoup as well, I'll check it out and probably move all
> of the code over to using that instead.

Cool.

> On Tue, 2016-11-15 at 12:44 +0100, Tomeu Vizoso wrote:
>> On 11 November 2016 at 18:53, Lyude Paul  wrote:
>> > > >  - While writing this patch series, I found that quite a few of
>> > > > the
>> > > > RPC calls
>> > > >for chameleond don't work as expected. For instance, I have
>> > > > had
>> > > > absolutely
>> > > >no luck getting CRCs from any of the display types that the
>> > > > chamelium
>> > > >supports.
>> > >
>> > > When I looked at this a few months ago, frame CRCs were working
>> > > just
>> > > fine. I was using libsoup, so maybe there's some problem with the
>> > > unpacking of the checksum?
>> >
>> > I'm pretty sure it's on the chameleond side of things. Using the
>> > test
>> > server application in chameleond's source shows the same issue.
>>
>> And what's the problem? You always get CRCs with a value of zero? I
>> only tried with HDMI, but IIRC I got to a point where
>> kms_universal_plane passed.
> The issue is I don't get CRCs, period :(. It looks like somewhere down
> the line chameleond is throwing a big fit whenever I try to get them:

Have no good ideas right now, and it will pass some time before I can
look at it.

I would say to just go ahead with what matters to you right now, and I
will look at it when I rebase my branch on top of yours, which will be
once IGT gains support for the generic frame CRC ABI.

Regards,

Tomeu

> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
>>>> p.Plug(1)
>>>> p.ComputePixelChecksum(1, 0, 0, 1920, 1080)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib64/python2.7/xmlrpclib.py", line 1243, in __call__
> return self.__send(self.__name, args)
>   File "/usr/lib64/python2.7/xmlrpclib.py", line 1602, in __request
> verbose=self.__verbose
>   File "/usr/lib64/python2.7/xmlrpclib.py", line 1283, in request
> return self.single_request(host, handler, request_body, verbose)
>   File "/usr/lib64/python2.7/xmlrpclib.py", line 1316, in
> single_request
> return self.parse_response(response)
>   File "/usr/lib64/python2.7/xmlrpclib.py", line 1493, in
> parse_response
> return u.close()
>   File "/usr/lib64/python2.7/xmlrpclib.py", line 800, in close
> raise Fault(**self._stack[0])
> Fault: :[Errno 8] Exec format
> error">
>>>> p.ComputePixelChecksum(1, 0, 0, 1920, 1080)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib64/python2.7/xmlrpclib.py", line 1243, in __call__
> return self.__send(self.__name, args)
>   File "/usr/lib64/python2.7/xmlrpclib.py", line 1602, in __request
> verbose=self.__verbose
>   File "/usr/lib64/python2.7/xmlrpclib.py", line 1283, in request
> return self.single_request(host, handler, request_body, verbose)
>   File "/usr/lib64/python2.7/xmlrpclib.py", line 1316, in
> single_request
> return self.parse_response(response)
>   File "/usr/lib64/python2.7/xmlrpclib.py", line 1493, in
> parse_response
> return u.close()
>   File "/usr/lib64/python2.7/xmlrpclib.py", line 800, in close
> raise Fault(**self._stack[0])
> Fault: :[Errno 8] Exec format
> error">
>
> Haven't had much luck with any of the other ports either
>
>>
>> Regards,
>>
>> Tomeu
>>
>> >
>> > >
>> > > >
>> > > >
>> > > > This isn't a huge deal though, since we usually just use the
>> > > >native CRC read back on the GPU anyway.
>> > >
>> > > I'm not completely sure what you mean by that, but not all
>> > > graphic
>> > > pipelines are able to provide frame CRCs so I think this
>> > > Chamelium
>> > > work will be very useful when running tests that do check frame
>> > > CRCs.
>> > I wasn't aware of that, thanks for letting me know
>> >
>> > >
>> > >
>> > > Regards,
>> > >
>> > > Tomeu
>> > >
>> > > >
>> > > >
>> > > >
>>

Re: [Intel-gfx] [PATCH 02/12] tests/kms_atomic_transition: don't assume max pipes

2016-11-15 Thread Tomeu Vizoso
On 15 November 2016 at 09:01, Daniel Vetter  wrote:
> On Mon, Nov 14, 2016 at 06:59:16PM +0900, Gustavo Padovan wrote:
>> From: Gustavo Padovan 
>>
>> Signed-off-by: Gustavo Padovan 
>> ---
>>  tests/kms_atomic_transition.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
>> index e693c88..8b26b53 100644
>> --- a/tests/kms_atomic_transition.c
>> +++ b/tests/kms_atomic_transition.c
>> @@ -404,7 +404,7 @@ static void run_modeset_tests(igt_display_t *display, 
>> int howmany, bool nonblock
>>  {
>>   struct igt_fb fbs[2];
>>   int i, j;
>> - unsigned iter_max = 1 << I915_MAX_PIPES;
>> + unsigned iter_max = 1 << display->n_pipes;
>
> Didn't Tomeu have some patch series to fix these all up?

Don't remember, and couldn't find any within my local branches. Maybe
Robert? But I'm adding it to my backlog anyway.

Regards,

Tomeu

> -Daniel
>
>>   igt_pipe_crc_t *pipe_crcs[I915_MAX_PIPES];
>>   igt_output_t *output;
>>   unsigned width = 0, height = 0;
>> --
>> 2.5.5
>>
>> ___
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [RFC i-g-t 0/4] intel-gpu-tools: Add support for the Chamelium

2016-11-15 Thread Tomeu Vizoso
On 11 November 2016 at 18:53, Lyude Paul  wrote:
> Alright, quick question: should we be going with your branch then or
> mine?

I'm not going to be able to work on this in the short term, so I think
it's up to you.

Wonder if there are more opinions regarding xmlrpc vs. libsoup. I
liked it mostly because we already depend on glib.

> On Wed, 2016-11-09 at 16:09 +0100, Tomeu Vizoso wrote:
>> Hi Lyude,
>>
>> I think this looks very good.
>>
>> On 8 November 2016 at 01:05, Lyude  wrote:
>> >
>> >
>> >  - While writing this patch series, I found that quite a few of the
>> > RPC calls
>> >for chameleond don't work as expected. For instance, I have had
>> > absolutely
>> >no luck getting CRCs from any of the display types that the
>> > chamelium
>> >supports.
>>
>> When I looked at this a few months ago, frame CRCs were working just
>> fine. I was using libsoup, so maybe there's some problem with the
>> unpacking of the checksum?
>
> I'm pretty sure it's on the chameleond side of things. Using the test
> server application in chameleond's source shows the same issue.

And what's the problem? You always get CRCs with a value of zero? I
only tried with HDMI, but IIRC I got to a point where
kms_universal_plane passed.

Regards,

Tomeu

>> >
>> > This isn't a huge deal though, since we usually just use the
>> >native CRC read back on the GPU anyway.
>>
>> I'm not completely sure what you mean by that, but not all graphic
>> pipelines are able to provide frame CRCs so I think this Chamelium
>> work will be very useful when running tests that do check frame CRCs.
> I wasn't aware of that, thanks for letting me know
>
>>
>> Regards,
>>
>> Tomeu
>>
>> >
>> >
>> >  - Among other things that are broken with the chameleon, video
>> > signal
>> >detection for DisplayPort is one of them. After the first
>> > plug/unplug cycle,
>> >the DisplayPort receiver gets stuck and gives the wrong results
>> > for
>> >WaitForInputStable. Luckily I've already got a fix I'll be
>> > submitting to the
>> >ChromeOS guys when I get around to setting up their homebrew git
>> > tools:
>> >
>> > https://github.com/Lyude/chameleond/tree/wip/chameleon-fixe
>> > s
>> >
>> >For now, expect the dp-display tests to fail without those
>> > patches.
>> >
>> > Lyude (4):
>> >   igt_aux: Add igt_skip_without_suspend_support()
>> >   igt_aux: Add igt_set_autoresume_delay()
>> >   igt_aux: Add some list helpers from wayland
>> >   Add support for hotplug testing with the Chamelium
>> >
>> >  configure.ac   |  13 +
>> >  lib/Makefile.am|  10 +-
>> >  lib/igt.h  |   1 +
>> >  lib/igt_aux.c  |  94 
>> >  lib/igt_aux.h  |  41 
>> >  lib/igt_chamelium.c| 628
>> > +
>> >  lib/igt_chamelium.h|  77 ++
>> >  lib/igt_kms.c  | 107 +
>> >  lib/igt_kms.h  |  13 +-
>> >  scripts/run-tests.sh   |   4 +-
>> >  tests/Makefile.am  |   5 +-
>> >  tests/Makefile.sources |   1 +
>> >  tests/chamelium.c  | 549
>> > ++
>> >  13 files changed, 1538 insertions(+), 5 deletions(-)
>> >  create mode 100644 lib/igt_chamelium.c
>> >  create mode 100644 lib/igt_chamelium.h
>> >  create mode 100644 tests/chamelium.c
>> >
>> > --
>> > 2.7.4
>> >
>> > ___
>> > Intel-gfx mailing list
>> > Intel-gfx@lists.freedesktop.org
>> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> --
> Cheers,
> Lyude
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [i-g-t PATCH v6 1/4] lib: add igt_dummyload

2016-11-15 Thread Tomeu Vizoso
On 15 November 2016 at 11:59, Tomeu Vizoso  wrote:
> On 14 November 2016 at 19:24, Abdiel Janulgue
>  wrote:
>> A lot of igt testcases need some GPU workload to make sure a race
>> window is big enough. Unfortunately having a fixed amount of
>> workload leads to spurious test failures or overtly long runtimes
>> on some fast/slow platforms. This library contains functionality
>> to submit GPU workloads that should consume exactly a specific
>> amount of time.
>>
>> v2 : Add recursive batch feature from Chris
>> v3 : Drop auto-tuned stuff. Add bo dependecy to recursive batch
>>  by adding a dummy reloc to the bo as suggested by Ville.
>> v4:  Fix dependency reloc as write instead of read (Ville).
>>  Fix wrong handling of batchbuffer start on ILK causing
>>  test failure
>> v5:  Convert kms_busy to use this api
>> v6:  Add this library to docs
>>
>> Cc: Daniel Vetter 
>> Cc: Ville Syrjälä 
>> Cc: Chris Wilson 
>> Signed-off-by: Abdiel Janulgue 
>> ---
>>  .../intel-gpu-tools/intel-gpu-tools-docs.xml   |   1 +
>>  lib/Makefile.sources   |   2 +
>>  lib/igt.h  |   1 +
>>  lib/igt_dummyload.c| 276 
>> +
>>  lib/igt_dummyload.h|  42 
>>  5 files changed, 322 insertions(+)
>>  create mode 100644 lib/igt_dummyload.c
>>  create mode 100644 lib/igt_dummyload.h
>>
>> diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml 
>> b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
>> index c862f2a..55902ab 100644
>> --- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
>> +++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
>> @@ -32,6 +32,7 @@
>>  
>>  
>>  
>> +
>>
>>
>>
>> diff --git a/lib/Makefile.sources b/lib/Makefile.sources
>> index e8e277b..7fc5ec2 100644
>> --- a/lib/Makefile.sources
>> +++ b/lib/Makefile.sources
>> @@ -75,6 +75,8 @@ lib_source_list = \
>> igt_draw.h  \
>> igt_pm.c\
>> igt_pm.h\
>> +   igt_dummyload.c \
>> +   igt_dummyload.h \
>> uwildmat/uwildmat.h \
>> uwildmat/uwildmat.c \
>> $(NULL)
>> diff --git a/lib/igt.h b/lib/igt.h
>> index d751f24..a0028d5 100644
>> --- a/lib/igt.h
>> +++ b/lib/igt.h
>> @@ -32,6 +32,7 @@
>>  #include "igt_core.h"
>>  #include "igt_debugfs.h"
>>  #include "igt_draw.h"
>> +#include "igt_dummyload.h"
>>  #include "igt_fb.h"
>>  #include "igt_gt.h"
>>  #include "igt_kms.h"
>> diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
>> new file mode 100644
>> index 000..b934fd5
>> --- /dev/null
>> +++ b/lib/igt_dummyload.c
>> @@ -0,0 +1,276 @@
>> +/*
>> + * Copyright © 2016 Intel Corporation
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the 
>> "Software"),
>> + * to deal in the Software without restriction, including without limitation
>> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom the
>> + * Software is furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the next
>> + * paragraph) shall be included in all copies or substantial portions of the
>> + * Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
>> OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
>> OTHER
>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
>> DEALINGS
>> + * IN THE SOFTWARE.
>> + *
>> + */
>> +
>> +#include "igt.h"
>> +#include "igt_dummyload.h"
>> +#include 
>> +#include 
>> +#include 
>> +
>> +/**
>> + * SECTION:igt_dummyload
>> + * @

Re: [Intel-gfx] [i-g-t PATCH v6 1/4] lib: add igt_dummyload

2016-11-15 Thread Tomeu Vizoso
On 14 November 2016 at 19:24, Abdiel Janulgue
 wrote:
> A lot of igt testcases need some GPU workload to make sure a race
> window is big enough. Unfortunately having a fixed amount of
> workload leads to spurious test failures or overtly long runtimes
> on some fast/slow platforms. This library contains functionality
> to submit GPU workloads that should consume exactly a specific
> amount of time.
>
> v2 : Add recursive batch feature from Chris
> v3 : Drop auto-tuned stuff. Add bo dependecy to recursive batch
>  by adding a dummy reloc to the bo as suggested by Ville.
> v4:  Fix dependency reloc as write instead of read (Ville).
>  Fix wrong handling of batchbuffer start on ILK causing
>  test failure
> v5:  Convert kms_busy to use this api
> v6:  Add this library to docs
>
> Cc: Daniel Vetter 
> Cc: Ville Syrjälä 
> Cc: Chris Wilson 
> Signed-off-by: Abdiel Janulgue 
> ---
>  .../intel-gpu-tools/intel-gpu-tools-docs.xml   |   1 +
>  lib/Makefile.sources   |   2 +
>  lib/igt.h  |   1 +
>  lib/igt_dummyload.c| 276 
> +
>  lib/igt_dummyload.h|  42 
>  5 files changed, 322 insertions(+)
>  create mode 100644 lib/igt_dummyload.c
>  create mode 100644 lib/igt_dummyload.h
>
> diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml 
> b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
> index c862f2a..55902ab 100644
> --- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
> +++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
> @@ -32,6 +32,7 @@
>  
>  
>  
> +
>
>
>
> diff --git a/lib/Makefile.sources b/lib/Makefile.sources
> index e8e277b..7fc5ec2 100644
> --- a/lib/Makefile.sources
> +++ b/lib/Makefile.sources
> @@ -75,6 +75,8 @@ lib_source_list = \
> igt_draw.h  \
> igt_pm.c\
> igt_pm.h\
> +   igt_dummyload.c \
> +   igt_dummyload.h \
> uwildmat/uwildmat.h \
> uwildmat/uwildmat.c \
> $(NULL)
> diff --git a/lib/igt.h b/lib/igt.h
> index d751f24..a0028d5 100644
> --- a/lib/igt.h
> +++ b/lib/igt.h
> @@ -32,6 +32,7 @@
>  #include "igt_core.h"
>  #include "igt_debugfs.h"
>  #include "igt_draw.h"
> +#include "igt_dummyload.h"
>  #include "igt_fb.h"
>  #include "igt_gt.h"
>  #include "igt_kms.h"
> diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
> new file mode 100644
> index 000..b934fd5
> --- /dev/null
> +++ b/lib/igt_dummyload.c
> @@ -0,0 +1,276 @@
> +/*
> + * Copyright © 2016 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> DEALINGS
> + * IN THE SOFTWARE.
> + *
> + */
> +
> +#include "igt.h"
> +#include "igt_dummyload.h"
> +#include 
> +#include 
> +#include 
> +
> +/**
> + * SECTION:igt_dummyload
> + * @short_description: Library for submitting GPU workloads
> + * @title: Dummyload
> + * @include: igt.h
> + *
> + * A lot of igt testcases need some GPU workload to make sure a race window 
> is
> + * big enough. Unfortunately having a fixed amount of workload leads to
> + * spurious test failures or overtly long runtimes on some fast/slow 
> platforms.

s/overtly/overly

> + * This library contains functionality to submit GPU workloads that should
> + * consume exactly a specific amount of time.
> + */
> +
> +#define NSEC_PER_SEC 10L

Time to put this in a header in lib? With this series applied we would
have 7 separate definitions.

> +#define gettid() syscall(__NR_gettid)
> +#define sigev_notify_thread_id _sigev_un._tid

Guess this should be fine as well to be in a single place because IGT
knows what it's doing regarding TIDs?

> +#define LOCAL_I915_EXEC_BSD_SHIFT  (13)
> +#define LOCAL_I915_EXEC_BSD_MASK   (3 << LOCAL_I915_EXEC_BSD_SHIF

Re: [Intel-gfx] [i-g-t PATCH v6 4/4] igt/kms_busy.c: Use new igt_spin_batch

2016-11-15 Thread Tomeu Vizoso
Hi Abdiel,

here running the whole of kms_busy causes all subtests after the first
one to be skipped due to:

Test requirement not met in function __real_main164, file
../../intel-gpu-tools/tests/kms_busy.c:195:
Test requirement: gem_has_ring(display.drm_fd, e->exec_id | e->flags)

If I run the subtests individually, the do get to run, so I guess
there's some issue with cleanup.

Btw, do you know why patchwork doesn't know about v6?

https://patchwork.freedesktop.org/series/15155/

I think it would be good to make sure that all commit messages contain
the why of the change, and a cover letter as the one generated by
git-send-email would be good to have, even if with very succinct
contents.

Thanks,

Tomeu

On 14 November 2016 at 19:24, Abdiel Janulgue
 wrote:
> Cc: Chris Wilson 
> Cc: Daniel Vetter 
> Signed-off-by: Abdiel Janulgue 
> ---
>  tests/kms_busy.c | 75 
> +++-
>  1 file changed, 4 insertions(+), 71 deletions(-)
>
> diff --git a/tests/kms_busy.c b/tests/kms_busy.c
> index b555f99..d0fe412 100644
> --- a/tests/kms_busy.c
> +++ b/tests/kms_busy.c
> @@ -78,73 +78,6 @@ static void do_cleanup_display(igt_display_t *dpy)
> igt_display_commit2(dpy, dpy->is_atomic ? COMMIT_ATOMIC : 
> COMMIT_LEGACY);
>  }
>
> -static uint32_t *
> -make_fb_busy(igt_display_t *dpy, unsigned ring, const struct igt_fb *fb)
> -{
> -   const int gen = intel_gen(intel_get_drm_devid(dpy->drm_fd));
> -   struct drm_i915_gem_exec_object2 obj[2];
> -#define SCRATCH 0
> -#define BATCH 1
> -   struct drm_i915_gem_relocation_entry reloc[2];
> -   struct drm_i915_gem_execbuffer2 execbuf;
> -   uint32_t *batch;
> -   int i;
> -
> -   memset(&execbuf, 0, sizeof(execbuf));
> -   execbuf.buffers_ptr = (uintptr_t)obj;
> -   execbuf.buffer_count = 2;
> -   execbuf.flags = ring;
> -
> -   memset(obj, 0, sizeof(obj));
> -   obj[SCRATCH].handle = fb->gem_handle;
> -
> -   obj[BATCH].handle = gem_create(dpy->drm_fd, 4096);
> -   obj[BATCH].relocs_ptr = (uintptr_t)reloc;
> -   obj[BATCH].relocation_count = 2;
> -   memset(reloc, 0, sizeof(reloc));
> -   reloc[0].target_handle = obj[BATCH].handle; /* recurse */
> -   reloc[0].presumed_offset = 0;
> -   reloc[0].offset = sizeof(uint32_t);
> -   reloc[0].delta = 0;
> -   reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND;
> -   reloc[0].write_domain = 0;
> -
> -   batch = gem_mmap__wc(dpy->drm_fd,
> -obj[BATCH].handle, 0, 4096, PROT_WRITE);
> -   gem_set_domain(dpy->drm_fd, obj[BATCH].handle,
> -  I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
> -
> -   batch[i = 0] = MI_BATCH_BUFFER_START;
> -   if (gen >= 8) {
> -   batch[i] |= 1 << 8 | 1;
> -   batch[++i] = 0;
> -   batch[++i] = 0;
> -   } else if (gen >= 6) {
> -   batch[i] |= 1 << 8;
> -   batch[++i] = 0;
> -   } else {
> -   batch[i] |= 2 << 6;
> -   batch[++i] = 0;
> -   if (gen < 4) {
> -   batch[i] |= 1;
> -   reloc[0].delta = 1;
> -   }
> -   }
> -
> -   /* dummy write to fb */
> -   reloc[1].target_handle = obj[SCRATCH].handle;
> -   reloc[1].presumed_offset = 0;
> -   reloc[1].offset = 1024;
> -   reloc[1].delta = 0;
> -   reloc[1].read_domains = I915_GEM_DOMAIN_RENDER;
> -   reloc[1].write_domain = I915_GEM_DOMAIN_RENDER;
> -
> -   gem_execbuf(dpy->drm_fd, &execbuf);
> -   gem_close(dpy->drm_fd, obj[BATCH].handle);
> -
> -   return batch;
> -}
> -
>  static void finish_fb_busy(uint32_t *batch, int msecs)
>  {
> struct timespec tv = { 0, msecs * 1000 * 1000 };
> @@ -165,9 +98,8 @@ static void flip_to_fb(igt_display_t *dpy, int pipe,
> struct pollfd pfd = { .fd = dpy->drm_fd, .events = POLLIN };
> struct timespec tv = { 1, 0 };
> struct drm_event_vblank ev;
> -   uint32_t *batch;
> -
> -   batch = make_fb_busy(dpy, ring, fb);
> +   igt_spin_t t = igt_spin_batch(dpy->drm_fd, -1,
> + ring, fb->gem_handle);
> igt_fork(child, 1) {
> igt_assert(gem_bo_busy(dpy->drm_fd, fb->gem_handle));
> do_or_die(drmModePageFlip(dpy->drm_fd,
> @@ -179,7 +111,8 @@ static void flip_to_fb(igt_display_t *dpy, int pipe,
> }
> igt_assert_f(nanosleep(&tv, NULL) == -1,
>  "flip to %s blocked waiting for busy fb", name);
> -   finish_fb_busy(batch, 2*TIMEOUT);
> +   finish_fb_busy(t.batch, 2*TIMEOUT);
> +   igt_post_spin_batch(dpy->drm_fd, t);
> igt_waitchildren();
> igt_assert(read(dpy->drm_fd, &ev, sizeof(ev)) == sizeof(ev));
> igt_assert(poll(&pfd, 1, 0) == 0);
> --
> 2.7.4
>
> ___
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop

[Intel-gfx] [PATCH i-g-t] lib: Pass I915_TILING_NONE if Yf or Ys

2016-11-11 Thread Tomeu Vizoso
The kernel expects that BOs for framebuffers with
I915_FORMAT_MOD_Yf_TILED will have I915_TILING_NONE.

Fixes: 050c00d53f39 ("lib: Pass I915_TILING_Y to the kernel if Yf or Ys")
Cc: Tvrtko Ursulin 
Signed-off-by: Tomeu Vizoso 
---
 lib/ioctl_wrappers.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index eabf3ee3abe6..8b75b9d4a6cb 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -158,8 +158,9 @@ int __gem_set_tiling(int fd, uint32_t handle, uint32_t 
tiling, uint32_t stride)
 
igt_require_intel(fd);
 
+   /* The kernel doesn't know about these tiling modes, expects NONE */
if (tiling == I915_TILING_Yf || tiling == I915_TILING_Ys)
-   tiling = I915_TILING_Y;
+   tiling = I915_TILING_NONE;
 
memset(&st, 0, sizeof(st));
do {
-- 
2.7.4

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


Re: [Intel-gfx] [i-g-t PATCH v1 08/14] lib: Add igt_create_bo_with_dimensions

2016-11-11 Thread Tomeu Vizoso
On 11 November 2016 at 12:33, Tvrtko Ursulin
 wrote:
>
> On 11/11/2016 11:23, Tomeu Vizoso wrote:
>>
>> On 11/10/2016 05:23 PM, Tvrtko Ursulin wrote:
>>>
>>>
>>> On 10/11/2016 13:17, Tomeu Vizoso wrote:
>>>>
>>>> On 1 November 2016 at 16:44, Tvrtko Ursulin 
>>>> wrote:
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>>
>>>>>
>>>>> On 02/03/16 14:00, Tomeu Vizoso wrote:
>>>>>>
>>>>>>
>>>>>> igt_create_bo_with_dimensions() is intended to abstract differences
>>>>>> between drivers in buffer object creation.
>>>>>>
>>>>>> The driver-specific ioctls will be called if the driver that is being
>>>>>> tested can satisfy the needs of the calling subtest, or it will be
>>>>>> skipped otherwise.
>>>>>>
>>>>>> Signed-off-by: Tomeu Vizoso 
>>>>>> ---
>>>>>>
>>>>>>  lib/igt_fb.c | 83
>>>>>> ++--
>>>>>>  lib/igt_fb.h |  6 +
>>>>>>  2 files changed, 65 insertions(+), 24 deletions(-)
>>>>>>
>>>>>> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
>>>>>> index cd1605308308..0a3526f4e4ea 100644
>>>>>> --- a/lib/igt_fb.c
>>>>>> +++ b/lib/igt_fb.c
>>>>>> @@ -174,30 +174,66 @@ void igt_calc_fb_size(int fd, int width, int
>>>>>> height,
>>>>>> int bpp, uint64_t tiling,
>>>>>> *size_ret = size;
>>>>>>  }
>>>>>>
>>>>>> +int igt_create_bo_with_dimensions(int fd, int width, int height,
>>>>>> + uint32_t format, uint64_t modifier,
>>>>>> + unsigned stride, unsigned *size_ret,
>>>>>> + unsigned *stride_ret, bool *is_dumb)
>>>>>> +{
>>>>>> +   int bpp = igt_drm_format_to_bpp(format);
>>>>>> +   int bo;
>>>>>> +
>>>>>> +   igt_assert((modifier && stride) || (!modifier && !stride));
>>>>>> +
>>>>>> +   if (modifier) {
>>>>>> +   unsigned size, calculated_stride;
>>>>>> +
>>>>>> +   igt_calc_fb_size(fd, width, height, bpp, modifier,
>>>>>> &size,
>>>>>> +&calculated_stride);
>>>>>> +   if (stride == 0)
>>>>>> +   stride = calculated_stride;
>>>>>> +
>>>>>> +   if (is_dumb)
>>>>>> +   *is_dumb = false;
>>>>>> +
>>>>>> +   if (is_i915_device(fd)) {
>>>>>> +
>>>>>> +   bo = gem_create(fd, size);
>>>>>> +   gem_set_tiling(fd, bo, modifier, stride);
>>>>>
>>>>>
>>>>>
>>>>> This is broken, gem_set_tiling does not take a fb modifier but an
>>>>> object
>>>>> tiling mode.
>>>>>
>>>>> You can demonstrate the failure if you got a Skylake system with:
>>>>>
>>>>> tests/kms_flip_tiling --r flip-changes-tiling-Yf
>>>>
>>>>
>>>> Hi,
>>>>
>>>> that subtest fails occasionally here due to CRC issues, but the one
>>>> that fails due to the tiling constant passed to gem_set_tiling is
>>>> flip-Yf-tiled.
>>>>
>>>> Have fixed it by converting the modifier to a tiling mode, but I also
>>>> needed to make sure that we don't pass to the kernel the Yf or Ys
>>>> constants as the kernel doesn't know about those.
>>>>
>>>> Both fixes have been pushed already.
>>>
>>>
>>> With the two patches you pushed flip-changes-tiling-Yf is still broken
>>> due the tiling mode mismatch, not the CRC.
>>>
>>> Perhaps you tested with all three patches you posted today?
>>
>>
>> Just before pushing I tested with this:
>>
>> IGT-Version: 1.16-g050c00d (x86_64) (Linux: 4.5.5-300.fc24.x86_64 x86_64)
>>
>> So I can only think of a difference in the hw causing a different
>> codepath to execute (it's a i3-6100U), or a difference in the kernel.
>>
>> This is a remote box and I don't have yet all the infrastructure in
>> place so I could monitor the boot, nor power cycle it, so I cannot test
>> with a newer kernel yet.
>>
>> If you can confirm that we should be passing I915_TILING_NONE to
>> set_tiling when the FB has I915_FORMAT_MOD_Yf_TILED, I can fix that, but
>> I would also like to understand why the test is failing for you.
>
>
> It should definitely be I915_TILING_NONE. If you look at the i915 code,
> intel_display.c/intel_framebuffer_init will reject attempts to add a
> framebuffer where object tiling does not match the framebuffer modifier. And
> the intel_fb_modifier_to_tiling helper translates the Yf/Ys modifiers to
> NONE tiling.

Cool, will do that change now.

> So I have no idea how it could have possibly worked for you. :)

Yeah, I'm curious as well, will check in a bit.

Thanks,

Tomeu


>
> Regards,
>
> Tvrtko
> ___
> 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] [i-g-t PATCH v1 08/14] lib: Add igt_create_bo_with_dimensions

2016-11-11 Thread Tomeu Vizoso
On 11/10/2016 05:23 PM, Tvrtko Ursulin wrote:
> 
> On 10/11/2016 13:17, Tomeu Vizoso wrote:
>> On 1 November 2016 at 16:44, Tvrtko Ursulin  wrote:
>>>
>>> Hi,
>>>
>>>
>>>
>>> On 02/03/16 14:00, Tomeu Vizoso wrote:
>>>>
>>>> igt_create_bo_with_dimensions() is intended to abstract differences
>>>> between drivers in buffer object creation.
>>>>
>>>> The driver-specific ioctls will be called if the driver that is being
>>>> tested can satisfy the needs of the calling subtest, or it will be
>>>> skipped otherwise.
>>>>
>>>> Signed-off-by: Tomeu Vizoso 
>>>> ---
>>>>
>>>>  lib/igt_fb.c | 83
>>>> ++--
>>>>  lib/igt_fb.h |  6 +
>>>>  2 files changed, 65 insertions(+), 24 deletions(-)
>>>>
>>>> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
>>>> index cd1605308308..0a3526f4e4ea 100644
>>>> --- a/lib/igt_fb.c
>>>> +++ b/lib/igt_fb.c
>>>> @@ -174,30 +174,66 @@ void igt_calc_fb_size(int fd, int width, int height,
>>>> int bpp, uint64_t tiling,
>>>> *size_ret = size;
>>>>  }
>>>>
>>>> +int igt_create_bo_with_dimensions(int fd, int width, int height,
>>>> + uint32_t format, uint64_t modifier,
>>>> + unsigned stride, unsigned *size_ret,
>>>> + unsigned *stride_ret, bool *is_dumb)
>>>> +{
>>>> +   int bpp = igt_drm_format_to_bpp(format);
>>>> +   int bo;
>>>> +
>>>> +   igt_assert((modifier && stride) || (!modifier && !stride));
>>>> +
>>>> +   if (modifier) {
>>>> +   unsigned size, calculated_stride;
>>>> +
>>>> +   igt_calc_fb_size(fd, width, height, bpp, modifier, &size,
>>>> +&calculated_stride);
>>>> +   if (stride == 0)
>>>> +   stride = calculated_stride;
>>>> +
>>>> +   if (is_dumb)
>>>> +   *is_dumb = false;
>>>> +
>>>> +   if (is_i915_device(fd)) {
>>>> +
>>>> +   bo = gem_create(fd, size);
>>>> +   gem_set_tiling(fd, bo, modifier, stride);
>>>
>>>
>>> This is broken, gem_set_tiling does not take a fb modifier but an object
>>> tiling mode.
>>>
>>> You can demonstrate the failure if you got a Skylake system with:
>>>
>>> tests/kms_flip_tiling --r flip-changes-tiling-Yf
>>
>> Hi,
>>
>> that subtest fails occasionally here due to CRC issues, but the one
>> that fails due to the tiling constant passed to gem_set_tiling is
>> flip-Yf-tiled.
>>
>> Have fixed it by converting the modifier to a tiling mode, but I also
>> needed to make sure that we don't pass to the kernel the Yf or Ys
>> constants as the kernel doesn't know about those.
>>
>> Both fixes have been pushed already.
> 
> With the two patches you pushed flip-changes-tiling-Yf is still broken 
> due the tiling mode mismatch, not the CRC.
> 
> Perhaps you tested with all three patches you posted today?

Just before pushing I tested with this:

IGT-Version: 1.16-g050c00d (x86_64) (Linux: 4.5.5-300.fc24.x86_64 x86_64)

So I can only think of a difference in the hw causing a different
codepath to execute (it's a i3-6100U), or a difference in the kernel.

This is a remote box and I don't have yet all the infrastructure in
place so I could monitor the boot, nor power cycle it, so I cannot test
with a newer kernel yet.

If you can confirm that we should be passing I915_TILING_NONE to
set_tiling when the FB has I915_FORMAT_MOD_Yf_TILED, I can fix that, but
I would also like to understand why the test is failing for you.

Regards,

Tomeu

>>> I would like to be able to tell you that all subtests there should pass,
>>> since they have been at some point, but I have a feeling that there are
>>> other breakages affecting it these days. :(
>>
>> Yeah, at least I can say that they are passing now in this particular
>> machine (i3-6100U).
>>
>> To make such issues less likely in the future, I have sent a patch
>> that makes clear when a variable contains a fb modifier constant, and
>> when a tiling mode. Haven't pushed it because I'm not 100% sure it's
>> worth it, so I would appreciate any opinions.
> 
> I will look at that one later.
> 
> Regards,
> 
> Tvrtko
> 

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


Re: [Intel-gfx] [i-g-t PATCH v1 08/14] lib: Add igt_create_bo_with_dimensions

2016-11-10 Thread Tomeu Vizoso
On 1 November 2016 at 16:44, Tvrtko Ursulin  wrote:
>
> Hi,
>
>
>
> On 02/03/16 14:00, Tomeu Vizoso wrote:
>>
>> igt_create_bo_with_dimensions() is intended to abstract differences
>> between drivers in buffer object creation.
>>
>> The driver-specific ioctls will be called if the driver that is being
>> tested can satisfy the needs of the calling subtest, or it will be
>> skipped otherwise.
>>
>> Signed-off-by: Tomeu Vizoso 
>> ---
>>
>>  lib/igt_fb.c | 83
>> ++--
>>  lib/igt_fb.h |  6 +
>>  2 files changed, 65 insertions(+), 24 deletions(-)
>>
>> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
>> index cd1605308308..0a3526f4e4ea 100644
>> --- a/lib/igt_fb.c
>> +++ b/lib/igt_fb.c
>> @@ -174,30 +174,66 @@ void igt_calc_fb_size(int fd, int width, int height,
>> int bpp, uint64_t tiling,
>> *size_ret = size;
>>  }
>>
>> +int igt_create_bo_with_dimensions(int fd, int width, int height,
>> + uint32_t format, uint64_t modifier,
>> + unsigned stride, unsigned *size_ret,
>> + unsigned *stride_ret, bool *is_dumb)
>> +{
>> +   int bpp = igt_drm_format_to_bpp(format);
>> +   int bo;
>> +
>> +   igt_assert((modifier && stride) || (!modifier && !stride));
>> +
>> +   if (modifier) {
>> +   unsigned size, calculated_stride;
>> +
>> +   igt_calc_fb_size(fd, width, height, bpp, modifier, &size,
>> +&calculated_stride);
>> +   if (stride == 0)
>> +   stride = calculated_stride;
>> +
>> +   if (is_dumb)
>> +   *is_dumb = false;
>> +
>> +   if (is_i915_device(fd)) {
>> +
>> +   bo = gem_create(fd, size);
>> +   gem_set_tiling(fd, bo, modifier, stride);
>
>
> This is broken, gem_set_tiling does not take a fb modifier but an object
> tiling mode.
>
> You can demonstrate the failure if you got a Skylake system with:
>
> tests/kms_flip_tiling --r flip-changes-tiling-Yf

Hi,

that subtest fails occasionally here due to CRC issues, but the one
that fails due to the tiling constant passed to gem_set_tiling is
flip-Yf-tiled.

Have fixed it by converting the modifier to a tiling mode, but I also
needed to make sure that we don't pass to the kernel the Yf or Ys
constants as the kernel doesn't know about those.

Both fixes have been pushed already.

> I would like to be able to tell you that all subtests there should pass,
> since they have been at some point, but I have a feeling that there are
> other breakages affecting it these days. :(

Yeah, at least I can say that they are passing now in this particular
machine (i3-6100U).

To make such issues less likely in the future, I have sent a patch
that makes clear when a variable contains a fb modifier constant, and
when a tiling mode. Haven't pushed it because I'm not 100% sure it's
worth it, so I would appreciate any opinions.

Thanks,

Tomeu

> Regards,
>
> Tvrtko
>
>
>
>> +
>> +   if (size_ret)
>> +   *size_ret = size;
>> +
>> +   if (stride_ret)
>> +   *stride_ret = stride;
>> +
>> +   return bo;
>> +   } else {
>> +   bool driver_has_tiling_support = false;
>> +
>> +   igt_require(driver_has_tiling_support);
>> +   return -EINVAL;
>> +   }
>> +   } else {
>> +   if (is_dumb)
>> +   *is_dumb = true;
>> +   return dumb_create(fd, width, height, bpp, stride_ret,
>> size_ret);
>> +   }
>> +}
>> +
>>  /* helpers to create nice-looking framebuffers */
>> -static int create_bo_for_fb(int fd, int width, int height, int bpp,
>> +static int create_bo_for_fb(int fd, int width, int height, uint32_t
>> format,
>> uint64_t tiling, unsigned bo_size,
>> unsigned bo_stride, uint32_t *gem_handle_ret,
>> -   unsigned *size_ret, unsigned *stride_ret)
>> +   unsigned *size_ret, unsigned *stride_ret,
>> +   bool *is_dumb)
>>  {
>> u

[Intel-gfx] [PATCH i-g-t] lib: Rename tiling variables to modifier if that's what they contain

2016-11-10 Thread Tomeu Vizoso
Though right now modifiers are only used to specify tiling, there are
different constants for them and naming them differently should help
with not mixing them.

Signed-off-by: Tomeu Vizoso 
---
 lib/igt_fb.c| 83 +++--
 lib/igt_fb.h|  4 +--
 tests/kms_fbc_crc.c |  8 +++---
 tests/kms_flip.c| 12 
 4 files changed, 54 insertions(+), 53 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index bb87869f18ce..19981f0ddf6c 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -74,10 +74,10 @@ static struct format_desc_struct {
 #define for_each_format(f) \
for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++)
 
-static void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
+static void igt_get_fb_tile_size(int fd, uint64_t modifier, int fb_bpp,
 unsigned *width_ret, unsigned *height_ret)
 {
-   switch (tiling) {
+   switch (modifier) {
case LOCAL_DRM_FORMAT_MOD_NONE:
*width_ret = 64;
*height_ret = 1;
@@ -137,22 +137,22 @@ static void igt_get_fb_tile_size(int fd, uint64_t tiling, 
int fb_bpp,
  * @width: width of the framebuffer in pixels
  * @height: height of the framebuffer in pixels
  * @bpp: bytes per pixel of the framebuffer
- * @tiling: tiling layout of the framebuffer (as framebuffer modifier)
+ * @modifier: framebuffer modifier
  * @size_ret: returned size for the framebuffer
  * @stride_ret: returned stride for the framebuffer
  *
  * This function returns valid stride and size values for a framebuffer with 
the
  * specified parameters.
  */
-void igt_calc_fb_size(int fd, int width, int height, int bpp, uint64_t tiling,
+void igt_calc_fb_size(int fd, int width, int height, int bpp, uint64_t 
modifier,
  unsigned *size_ret, unsigned *stride_ret)
 {
unsigned int tile_width, tile_height, stride, size;
int byte_width = width * (bpp / 8);
 
-   igt_get_fb_tile_size(fd, tiling, bpp, &tile_width, &tile_height);
+   igt_get_fb_tile_size(fd, modifier, bpp, &tile_width, &tile_height);
 
-   if (tiling != LOCAL_DRM_FORMAT_MOD_NONE &&
+   if (modifier != LOCAL_DRM_FORMAT_MOD_NONE &&
intel_gen(intel_get_drm_devid(fd)) <= 3) {
int v;
 
@@ -208,17 +208,17 @@ uint64_t igt_fb_mod_to_tiling(uint64_t modifier)
 
 /* helpers to create nice-looking framebuffers */
 static int create_bo_for_fb(int fd, int width, int height, uint32_t format,
-   uint64_t tiling, unsigned size, unsigned stride,
+   uint64_t modifier, unsigned size, unsigned stride,
unsigned *size_ret, unsigned *stride_ret,
bool *is_dumb)
 {
int bpp = igt_drm_format_to_bpp(format);
int bo;
 
-   if (tiling || size || stride) {
+   if (modifier || size || stride) {
unsigned calculated_size, calculated_stride;
 
-   igt_calc_fb_size(fd, width, height, bpp, tiling,
+   igt_calc_fb_size(fd, width, height, bpp, modifier,
 &calculated_size, &calculated_stride);
if (stride == 0)
stride = calculated_stride;
@@ -229,10 +229,11 @@ static int create_bo_for_fb(int fd, int width, int 
height, uint32_t format,
*is_dumb = false;
 
if (is_i915_device(fd)) {
+   unsigned int tiling = igt_fb_mod_to_tiling(modifier);
uint32_t *ptr;
 
bo = gem_create(fd, size);
-   gem_set_tiling(fd, bo, igt_fb_mod_to_tiling(tiling), 
stride);
+   gem_set_tiling(fd, bo, tiling, stride);
 
/* Ensure the framebuffer is preallocated */
ptr = gem_mmap__gtt(fd, bo, size, PROT_READ);
@@ -598,7 +599,7 @@ void igt_paint_image(cairo_t *cr, const char *filename,
  * @width: width of the framebuffer in pixel
  * @height: height of the framebuffer in pixel
  * @format: drm fourcc pixel format code
- * @tiling: tiling layout of the framebuffer (as framebuffer modifier)
+ * @modifier: framebuffer modifier
  * @fb: pointer to an #igt_fb structure
  * @bo_size: size of the backing bo (0 for automatic size)
  * @bo_stride: stride of the backing bo (0 for automatic stride)
@@ -615,7 +616,7 @@ void igt_paint_image(cairo_t *cr, const char *filename,
  */
 unsigned int
 igt_create_fb_with_bo_size(int fd, int width, int height,
-  uint32_t format, uint64_t tiling,
+  uint32_t format, uint64_t modifier,
   struct igt_fb *fb, unsigned bo_size,
   unsigned bo_stride)
 {
@@ -623,9 +624,9 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
 
memset(fb, 0, sizeof(*fb));
 
-  

[Intel-gfx] [PATCH i-g-t] lib: Pass I915_TILING_Y to the kernel if Yf or Ys

2016-11-10 Thread Tomeu Vizoso
GEM_SET_TILING doesn't care about Yf or Ys, so just pass Y.

Signed-off-by: Tomeu Vizoso 
---
 lib/ioctl_wrappers.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 95bc5e268bcd..eabf3ee3abe6 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -158,6 +158,9 @@ int __gem_set_tiling(int fd, uint32_t handle, uint32_t 
tiling, uint32_t stride)
 
igt_require_intel(fd);
 
+   if (tiling == I915_TILING_Yf || tiling == I915_TILING_Ys)
+   tiling = I915_TILING_Y;
+
memset(&st, 0, sizeof(st));
do {
st.handle = handle;
-- 
2.7.4

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


[Intel-gfx] [PATCH i-g-t] lib: Pass tiling constant where that's expected

2016-11-10 Thread Tomeu Vizoso
We were passing in two places a framebuffer modifier constant instead of
a tiling constant.

Also adds igt_fb_mod_to_tiling so tests can do that by themselves.

Cc: Tvrtko Ursulin 
Fixes: 8a1a38661f56 ("lib: Add igt_create_bo_with_dimensions")
Signed-off-by: Tomeu Vizoso 
---
 lib/igt_fb.c | 48 +---
 lib/igt_fb.h |  2 ++
 tests/kms_flip.c |  2 +-
 3 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 47472f4399e9..bb87869f18ce 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -180,6 +180,32 @@ void igt_calc_fb_size(int fd, int width, int height, int 
bpp, uint64_t tiling,
*size_ret = size;
 }
 
+/**
+ * igt_fb_mod_to_tiling:
+ * @modifier: DRM framebuffer modifier
+ *
+ * This function converts a DRM framebuffer modifier to its corresponding
+ * tiling constant.
+ *
+ * Returns:
+ * A tiling constant
+ */
+uint64_t igt_fb_mod_to_tiling(uint64_t modifier)
+{
+   switch (modifier) {
+   case LOCAL_DRM_FORMAT_MOD_NONE:
+   return I915_TILING_NONE;
+   case LOCAL_I915_FORMAT_MOD_X_TILED:
+   return I915_TILING_X;
+   case LOCAL_I915_FORMAT_MOD_Y_TILED:
+   return I915_TILING_Y;
+   case LOCAL_I915_FORMAT_MOD_Yf_TILED:
+   return I915_TILING_Yf;
+   default:
+   igt_assert(0);
+   }
+}
+
 /* helpers to create nice-looking framebuffers */
 static int create_bo_for_fb(int fd, int width, int height, uint32_t format,
uint64_t tiling, unsigned size, unsigned stride,
@@ -206,7 +232,7 @@ static int create_bo_for_fb(int fd, int width, int height, 
uint32_t format,
uint32_t *ptr;
 
bo = gem_create(fd, size);
-   gem_set_tiling(fd, bo, tiling, stride);
+   gem_set_tiling(fd, bo, igt_fb_mod_to_tiling(tiling), 
stride);
 
/* Ensure the framebuffer is preallocated */
ptr = gem_mmap__gtt(fd, bo, size, PROT_READ);
@@ -956,27 +982,11 @@ struct fb_blit_upload {
} linear;
 };
 
-static unsigned int fb_mod_to_obj_tiling(uint64_t fb_mod)
-{
-   switch (fb_mod) {
-   case LOCAL_DRM_FORMAT_MOD_NONE:
-   return I915_TILING_NONE;
-   case LOCAL_I915_FORMAT_MOD_X_TILED:
-   return I915_TILING_X;
-   case LOCAL_I915_FORMAT_MOD_Y_TILED:
-   return I915_TILING_Y;
-   case LOCAL_I915_FORMAT_MOD_Yf_TILED:
-   return I915_TILING_Yf;
-   default:
-   igt_assert(0);
-   }
-}
-
 static void destroy_cairo_surface__blit(void *arg)
 {
struct fb_blit_upload *blit = arg;
struct igt_fb *fb = blit->fb;
-   unsigned int obj_tiling = fb_mod_to_obj_tiling(fb->tiling);
+   unsigned int obj_tiling = igt_fb_mod_to_tiling(fb->tiling);
 
munmap(blit->linear.map, blit->linear.size);
fb->cairo_surface = NULL;
@@ -1005,7 +1015,7 @@ static void create_cairo_surface__blit(int fd, struct 
igt_fb *fb)
 {
struct fb_blit_upload *blit;
cairo_format_t cairo_format;
-   unsigned int obj_tiling = fb_mod_to_obj_tiling(fb->tiling);
+   unsigned int obj_tiling = igt_fb_mod_to_tiling(fb->tiling);
 
blit = malloc(sizeof(*blit));
igt_assert(blit);
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index e1c4c1fa1f73..4a680cefb16d 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -129,6 +129,8 @@ int igt_create_bo_with_dimensions(int fd, int width, int 
height, uint32_t format
  unsigned *stride_ret, unsigned *size_ret,
  bool *is_dumb);
 
+uint64_t igt_fb_mod_to_tiling(uint64_t modifier);
+
 /* cairo-based painting */
 cairo_t *igt_get_cairo_ctx(int fd, struct igt_fb *fb);
 void igt_paint_color(cairo_t *cr, int x, int y, int w, int h,
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 6a1549e7b857..2a9fe2e3f702 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -370,7 +370,7 @@ static int _emit_dummy_load__rcs(struct test_output *o, int 
limit, int timeout)
sb[2].bo = gem_handle_to_libdrm_bo(bufmgr, drm_fd, "imported", 
fb_info->gem_handle);
igt_assert(sb[2].bo);
sb[2].size = sb[2].bo->size;
-   sb[2].tiling = fb_info->tiling;
+   sb[2].tiling = igt_fb_mod_to_tiling(fb_info->tiling);
sb[2].data = NULL;
sb[2].num_tiles = sb[2].bo->size;
sb[2].stride = fb_info->stride;
-- 
2.7.4

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


Re: [Intel-gfx] [RFC i-g-t 4/4] Add support for hotplug testing with the Chamelium

2016-11-09 Thread Tomeu Vizoso
On 8 November 2016 at 01:05, Lyude  wrote:
> For the purpose of testing things such as hotplugging and bad monitors,
> the ChromeOS team ended up designing a neat little device known as the
> Chamelium. More information on this can be found here:
>
> https://www.chromium.org/chromium-os/testing/chamelium
>
> This adds support for a couple of things to intel-gpu-tools:
>  - igt library functions for connecting to udev and monitoring it for
>hotplug events, loosely based off of the unfinished hotplugging
>implementation in testdisplay
>  - Library functions for controlling the chamelium in tests using
>xmlrpc. A couple of RPC calls were ommitted here, mainly because they
>didn't seem very useful for our needs or because they're just plain
>broken
>  - A set of basic tests using the chamelium.

I think it would be good to split this patch in a few smaller bits,
each with its logical change.

> Because there's no surefire way that I know of where we can map which
> chamelium port belongs to which port on the system being tested (we
> could just use hotplugging, but then we'd be relying on something that
> might be broken on the machine and potentially give false positives for
> certain tests), most of the chamelium tests will figure out whether or
> not a connection happened by counting the number of connectors matching
> the status we're looking for before hotplugging with the chamelium, vs.
> after hotplugging it.

Back when I started work on this, it was agreed with Daniel Vetter
that a config file would be used for this mapping (and other
configuration). This is the $HOME/.igtrc I was using during
development:

[Chamelium]
server_ip=192.168.100.123
server_port=9992
port_names=HDMI
connector_names=HDMI-A-1

I used the keyfile API in glib, as we are already depending on it (and
that's also why I chose libsoup instead of libxmlrpc).

For reference, this is the WIP branch that I was using to test frame
CRC capture with Chamelium:

https://git.collabora.com/cgit/user/tomeu/intel-gpu-tools.git/commit/?h=chamelium-crc

Regards,

Tomeu

> Tests which require that we know which port belongs to a certain port
> (such as ones where we actually perform a modeset) will unplug all of
> the chamelium ports, plug the desired port, then use the first DRM
> connector with the desired connector type that's marked as connected. In
> order to ensure we don't end up using the wrong connector, these tests
> will skip if they find any connectors with the desired type marked as
> connected before performing the hotplug on the chamelium.
>
> Running these tests requires (of course) a working Chamelium, along with
> the RPC URL for the chamelium being specified in the environment
> variable CHAMELIUM_HOST. If no URL is specified, the tests will just
> skip on their own. As well, tests for connectors which are not actually
> present on the system or the chamelium will skip on their own as well.
>
> Signed-off-by: Lyude 
> ---
>  configure.ac   |  13 +
>  lib/Makefile.am|  10 +-
>  lib/igt.h  |   1 +
>  lib/igt_chamelium.c| 628 
> +
>  lib/igt_chamelium.h|  77 ++
>  lib/igt_kms.c  | 107 +
>  lib/igt_kms.h  |  13 +-
>  scripts/run-tests.sh   |   4 +-
>  tests/Makefile.am  |   5 +-
>  tests/Makefile.sources |   1 +
>  tests/chamelium.c  | 549 ++
>  11 files changed, 1403 insertions(+), 5 deletions(-)
>  create mode 100644 lib/igt_chamelium.c
>  create mode 100644 lib/igt_chamelium.h
>  create mode 100644 tests/chamelium.c
>
> diff --git a/configure.ac b/configure.ac
> index 735cfd5..88113b2 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -259,6 +259,18 @@ if test "x$with_libunwind" = xyes; then
>   AC_MSG_ERROR([libunwind not found. Use 
> --without-libunwind to disable libunwind support.]))
>  fi
>
> +# enable support for using the chamelium
> +AC_ARG_ENABLE(chamelium,
> + AS_HELP_STRING([--without-chamelium],
> +[Build tests without chamelium support]),
> + [], [with_chamelium=yes])
> +
> +AM_CONDITIONAL(HAVE_CHAMELIUM, [test "x$with_chamelium" = xyes])
> +if test "x$with_chamelium" = xyes; then
> +   AC_DEFINE(HAVE_CHAMELIUM, 1, [chamelium suport])
> +   PKG_CHECK_MODULES(XMLRPC, xmlrpc_client)
> +fi
> +
>  # enable debug symbols
>  AC_ARG_ENABLE(debug,
>   AS_HELP_STRING([--disable-debug],
> @@ -356,6 +368,7 @@ echo "   Assembler  : ${enable_assembler}"
>  echo "   Debugger   : ${enable_debugger}"
>  echo "   Overlay: X: ${enable_overlay_xlib}, Xv: 
> ${enable_overlay_xvlib}"
>  echo "   x86-specific tools : ${build_x86}"
> +echo "   Chamelium support  : ${with_chamelium}"
>  echo ""
>  echo " • API-Documentation  : ${enable_gtk_doc}"
>  echo " • Fail on warnings   : ${enable_werror}"
> diff -

Re: [Intel-gfx] [RFC i-g-t 0/4] intel-gpu-tools: Add support for the Chamelium

2016-11-09 Thread Tomeu Vizoso
Hi Lyude,

I think this looks very good.

On 8 November 2016 at 01:05, Lyude  wrote:
>
>  - While writing this patch series, I found that quite a few of the RPC calls
>for chameleond don't work as expected. For instance, I have had absolutely
>no luck getting CRCs from any of the display types that the chamelium
>supports.

When I looked at this a few months ago, frame CRCs were working just
fine. I was using libsoup, so maybe there's some problem with the
unpacking of the checksum?

> This isn't a huge deal though, since we usually just use the
>native CRC read back on the GPU anyway.

I'm not completely sure what you mean by that, but not all graphic
pipelines are able to provide frame CRCs so I think this Chamelium
work will be very useful when running tests that do check frame CRCs.

Regards,

Tomeu

>
>  - Among other things that are broken with the chameleon, video signal
>detection for DisplayPort is one of them. After the first plug/unplug 
> cycle,
>the DisplayPort receiver gets stuck and gives the wrong results for
>WaitForInputStable. Luckily I've already got a fix I'll be submitting to 
> the
>ChromeOS guys when I get around to setting up their homebrew git tools:
>
> https://github.com/Lyude/chameleond/tree/wip/chameleon-fixes
>
>For now, expect the dp-display tests to fail without those patches.
>
> Lyude (4):
>   igt_aux: Add igt_skip_without_suspend_support()
>   igt_aux: Add igt_set_autoresume_delay()
>   igt_aux: Add some list helpers from wayland
>   Add support for hotplug testing with the Chamelium
>
>  configure.ac   |  13 +
>  lib/Makefile.am|  10 +-
>  lib/igt.h  |   1 +
>  lib/igt_aux.c  |  94 
>  lib/igt_aux.h  |  41 
>  lib/igt_chamelium.c| 628 
> +
>  lib/igt_chamelium.h|  77 ++
>  lib/igt_kms.c  | 107 +
>  lib/igt_kms.h  |  13 +-
>  scripts/run-tests.sh   |   4 +-
>  tests/Makefile.am  |   5 +-
>  tests/Makefile.sources |   1 +
>  tests/chamelium.c  | 549 ++
>  13 files changed, 1538 insertions(+), 5 deletions(-)
>  create mode 100644 lib/igt_chamelium.c
>  create mode 100644 lib/igt_chamelium.h
>  create mode 100644 tests/chamelium.c
>
> --
> 2.7.4
>
> ___
> 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] lib/drmtest: Take DRIVER_ANY into account when opening the DRM device

2016-10-27 Thread Tomeu Vizoso
On 27 October 2016 at 10:06, Chris Wilson  wrote:
> On Thu, Oct 27, 2016 at 09:58:19AM +0200, Tomeu Vizoso wrote:
>> __drm_open_driver was changed to bail out on VGEM devices unless they
>> are explicitly asked for (DRIVER_VGEM). But with that change we lost
>> support for DRIVER_ANY.
>>
>> Signed-off-by: Tomeu Vizoso 
>> Fixes: 7ce63894854d ("lib: Support opening vGEM device")
>> Cc: Chris Wilson 
>> ---
>>  lib/drmtest.c | 4 
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/lib/drmtest.c b/lib/drmtest.c
>> index 5d3aaa836735..786ffa1b1fae 100644
>> --- a/lib/drmtest.c
>> +++ b/lib/drmtest.c
>> @@ -269,6 +269,10 @@ int __drm_open_driver(int chipset)
>>   is_virtio_device(fd))
>>   return fd;
>>
>> + /* Only VGEM-specific tests should be run on VGEM */
>> + if (chipset & DRIVER_ANY && !is_vgem_device(fd))
>> + return fd;
>> +
>
> chipset == DRIVER_ANY
>
> Otherwise if we request DRIVER_INTEL, this will return the first hit if
> !intel and !vgem.

Great, thanks.

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


[Intel-gfx] [PATCH i-g-t] lib/drmtest: Take DRIVER_ANY into account when opening the DRM device

2016-10-27 Thread Tomeu Vizoso
__drm_open_driver was changed to bail out on VGEM devices unless they
are explicitly asked for (DRIVER_VGEM). But with that change we lost
support for DRIVER_ANY.

Signed-off-by: Tomeu Vizoso 
Fixes: 7ce63894854d ("lib: Support opening vGEM device")
Cc: Chris Wilson 
---
 lib/drmtest.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 5d3aaa836735..786ffa1b1fae 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -269,6 +269,10 @@ int __drm_open_driver(int chipset)
is_virtio_device(fd))
return fd;
 
+   /* Only VGEM-specific tests should be run on VGEM */
+   if (chipset & DRIVER_ANY && !is_vgem_device(fd))
+   return fd;
+
close(fd);
}
 
-- 
2.7.4

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


[Intel-gfx] [PATCH v11 4/4] drm/i915: Put "cooked" vlank counters in frame CRC lines

2016-10-06 Thread Tomeu Vizoso
Use drm_accurate_vblank_count so we have the full 32 bit to represent
the frame counter and userspace has a simpler way of knowing when the
counter wraps around.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_irq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 1549cc4f88ec..238a353454e9 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1495,7 +1495,6 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
struct drm_driver *driver = dev_priv->drm.driver;
uint32_t crcs[5];
int head, tail, ret;
-   u32 frame;
 
spin_lock(&pipe_crc->lock);
if (pipe_crc->source) {
@@ -1551,8 +1550,9 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
crcs[2] = crc2;
crcs[3] = crc3;
crcs[4] = crc4;
-   frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
-   ret = drm_crtc_add_crc_entry(crtc, true, frame, crcs);
+   ret = drm_crtc_add_crc_entry(crtc, true,
+drm_accurate_vblank_count(crtc),
+crcs);
spin_unlock(&crtc->crc.lock);
if (!ret)
wake_up_interruptible(&crtc->crc.wq);
-- 
2.7.4

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


[Intel-gfx] [PATCH v11 3/4] drm/i915: Use new CRC debugfs API

2016-10-06 Thread Tomeu Vizoso
The core provides now an ABI to userspace for generation of frame CRCs,
so implement the ->set_crc_source() callback and reuse as much code as
possible with the previous ABI implementation.

When handling the pageflip interrupt, we skip 1 or 2 frames depending on
the HW because they contain wrong values. For the legacy ABI for
generating frame CRCs, this was done in userspace but now that we have a
generic ABI it's better if it's not exposed by the kernel.

v2:
- Leave the legacy implementation in place as the ABI implementation
  in the core is incompatible with it.
v3:
- Use the "cooked" vblank counter so we have a whole 32 bits.
- Make sure we don't mess with the state of the legacy CRC capture
  ABI implementation.
v4:
- Keep use of get_vblank_counter as in the legacy code, will be
  changed in a followup commit.

v5:
- Skip first frame or two as it's known that they contain wrong
  data.
- A few fixes suggested by Emil Velikov.

v6:
- Rework programming of the HW registers to preserve previous
  behavior.

v7:
- Address whitespace issue.
- Added a comment on why in the implementation of the new ABI we
  skip the 1st or 2nd frames.

v9:
- Add stub for intel_crtc_set_crc_source.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 83 +--
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  8 +++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 5 files changed, 149 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index f8c66eea06bc..20522f0a4c57 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1713,6 +1713,7 @@ struct intel_pipe_crc {
enum intel_pipe_crc_source source;
int head, tail;
wait_queue_head_t wq;
+   int skipped;
 };
 
 struct i915_frontbuffer_tracking {
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index bd6c8b0eeaef..1549cc4f88ec 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1491,41 +1491,72 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
 {
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
struct intel_pipe_crc_entry *entry;
-   int head, tail;
+   struct drm_crtc *crtc = intel_get_crtc_for_pipe(&dev_priv->drm, pipe);
+   struct drm_driver *driver = dev_priv->drm.driver;
+   uint32_t crcs[5];
+   int head, tail, ret;
+   u32 frame;
 
spin_lock(&pipe_crc->lock);
+   if (pipe_crc->source) {
+   if (!pipe_crc->entries) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_DEBUG_KMS("spurious interrupt\n");
+   return;
+   }
 
-   if (!pipe_crc->entries) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_DEBUG_KMS("spurious interrupt\n");
-   return;
-   }
-
-   head = pipe_crc->head;
-   tail = pipe_crc->tail;
+   head = pipe_crc->head;
+   tail = pipe_crc->tail;
 
-   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_ERROR("CRC buffer overflowing\n");
-   return;
-   }
+   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_ERROR("CRC buffer overflowing\n");
+   return;
+   }
 
-   entry = &pipe_crc->entries[head];
+   entry = &pipe_crc->entries[head];
 
-   entry->frame = dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm,
-pipe);
-   entry->crc[0] = crc0;
-   entry->crc[1] = crc1;
-   entry->crc[2] = crc2;
-   entry->crc[3] = crc3;
-   entry->crc[4] = crc4;
+   entry->frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
+   entry->crc[0] = crc0;
+   entry->crc[1] = crc1;
+   entry->crc[2] = crc2;
+   entry->crc[3] = crc3;
+   entry->crc[4] = crc4;
 
-   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
-   pipe_crc->head = head;
+   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
+   pipe_crc->head = head;
 
-   spin_unlock(&pipe_crc->lock);
+   spin_unlock(&pipe_crc->lock);
 
-   wake_u

[Intel-gfx] [PATCH v11 1/4] drm/i915/debugfs: Move out pipe CRC code

2016-10-06 Thread Tomeu Vizoso
In preparation to using a generic API in the DRM core for continuous CRC
generation, move the related code out of i915_debugfs.c into a new file.

Eventually, only the Intel-specific code will remain in this new file.

v2: Rebased.

v6: Rebased.

v7: Fix whitespace issue.

v9: Have intel_display_crc_init accept a drm_i915_private instead.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/Makefile |   2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   | 886 +---
 drivers/gpu/drm/i915/intel_drv.h  |   5 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 943 ++
 4 files changed, 953 insertions(+), 883 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index a998c2bce70a..e6fe0040fe64 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -24,7 +24,7 @@ i915-y := i915_drv.o \
  intel_runtime_pm.o
 
 i915-$(CONFIG_COMPAT)   += i915_ioc32.o
-i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o
+i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o intel_pipe_crc.o
 
 # GEM code
 i915-y += i915_cmd_parser.o \
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index da7141382b00..4fb9d829884e 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -26,19 +26,9 @@
  *
  */
 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include "intel_drv.h"
-#include "intel_ringbuffer.h"
-#include 
-#include "i915_drv.h"
 
 static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
 {
@@ -3414,12 +3404,6 @@ static int i915_drrs_status(struct seq_file *m, void 
*unused)
return 0;
 }
 
-struct pipe_crc_info {
-   const char *name;
-   struct drm_i915_private *dev_priv;
-   enum pipe pipe;
-};
-
 static int i915_dp_mst_info(struct seq_file *m, void *unused)
 {
struct drm_i915_private *dev_priv = node_to_i915(m->private);
@@ -3449,848 +3433,6 @@ static int i915_dp_mst_info(struct seq_file *m, void 
*unused)
return 0;
 }
 
-static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes)
-   return -ENODEV;
-
-   spin_lock_irq(&pipe_crc->lock);
-
-   if (pipe_crc->opened) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EBUSY; /* already open */
-   }
-
-   pipe_crc->opened = true;
-   filep->private_data = inode->i_private;
-
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   spin_lock_irq(&pipe_crc->lock);
-   pipe_crc->opened = false;
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-/* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN  (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN(PIPE_CRC_LINE_LEN + 1)
-
-static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
-{
-   assert_spin_locked(&pipe_crc->lock);
-   return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
-   INTEL_PIPE_CRC_ENTRIES_NR);
-}
-
-static ssize_t
-i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
-  loff_t *pos)
-{
-   struct pipe_crc_info *info = filep->private_data;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-   char buf[PIPE_CRC_BUFFER_LEN];
-   int n_entries;
-   ssize_t bytes_read;
-
-   /*
-* Don't allow user space to provide buffers not big enough to hold
-* a line of data.
-*/
-   if (count < PIPE_CRC_LINE_LEN)
-   return -EINVAL;
-
-   if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
-   return 0;
-
-   /* nothing to read */
-   spin_lock_irq(&pipe_crc->lock);
-   while (pipe_crc_data_count(pipe_crc) == 0) {
-   int ret;
-
-   if (filep->f_flags & O_NONBLOCK) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EAGAIN;
-   }
-
-   ret = wait_

[Intel-gfx] [PATCH v11 0/4] New debugfs API for capturing CRC of frames

2016-10-06 Thread Tomeu Vizoso
Hi,

this series basically takes the facility for continuously capturing CRCs
of frames from the i915 driver and into the DRM core.

The idea is that test suites such as IGT use this information to check
that frames that are exected to be identical, also have identical CRC
values.

Other drivers for hardware that can provide frame CRCs (including eDP
panels that support self-refresh) can easily implement the new callback
and provide userspace with the CRC values.

Sorry about that, but there was a dangling brace in v10 breaking the build so
here is this v11.

Thanks,

Tomeu


Tomeu Vizoso (4):
  drm/i915/debugfs: Move out pipe CRC code
  drm: Add API for capturing frame CRCs
  drm/i915: Use new CRC debugfs API
  drm/i915: Put "cooked" vlank counters in frame CRC lines

 Documentation/gpu/drm-uapi.rst|6 +
 drivers/gpu/drm/Makefile  |3 +-
 drivers/gpu/drm/drm_crtc.c|   34 +-
 drivers/gpu/drm/drm_debugfs.c |   34 +-
 drivers/gpu/drm/drm_debugfs_crc.c |  351 
 drivers/gpu/drm/drm_internal.h|   16 +
 drivers/gpu/drm/i915/Makefile |2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   |  886 +---
 drivers/gpu/drm/i915/i915_drv.h   |1 +
 drivers/gpu/drm/i915/i915_irq.c   |   83 ++-
 drivers/gpu/drm/i915/intel_display.c  |1 +
 drivers/gpu/drm/i915/intel_drv.h  |   13 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 1013 +
 include/drm/drm_crtc.h|   41 ++
 include/drm/drm_debugfs_crc.h |   73 +++
 15 files changed, 1645 insertions(+), 912 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_debugfs_crc.c
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c
 create mode 100644 include/drm/drm_debugfs_crc.h

-- 
2.7.4

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


[Intel-gfx] [PATCH v10 4/4] drm/i915: Put "cooked" vlank counters in frame CRC lines

2016-10-06 Thread Tomeu Vizoso
Use drm_accurate_vblank_count so we have the full 32 bit to represent
the frame counter and userspace has a simpler way of knowing when the
counter wraps around.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_irq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 1549cc4f88ec..238a353454e9 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1495,7 +1495,6 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
struct drm_driver *driver = dev_priv->drm.driver;
uint32_t crcs[5];
int head, tail, ret;
-   u32 frame;
 
spin_lock(&pipe_crc->lock);
if (pipe_crc->source) {
@@ -1551,8 +1550,9 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
crcs[2] = crc2;
crcs[3] = crc3;
crcs[4] = crc4;
-   frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
-   ret = drm_crtc_add_crc_entry(crtc, true, frame, crcs);
+   ret = drm_crtc_add_crc_entry(crtc, true,
+drm_accurate_vblank_count(crtc),
+crcs);
spin_unlock(&crtc->crc.lock);
if (!ret)
wake_up_interruptible(&crtc->crc.wq);
-- 
2.7.4

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


[Intel-gfx] [PATCH v10 1/4] drm/i915/debugfs: Move out pipe CRC code

2016-10-06 Thread Tomeu Vizoso
In preparation to using a generic API in the DRM core for continuous CRC
generation, move the related code out of i915_debugfs.c into a new file.

Eventually, only the Intel-specific code will remain in this new file.

v2: Rebased.

v6: Rebased.

v7: Fix whitespace issue.

v9: Have intel_display_crc_init accept a drm_i915_private instead.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/Makefile |   2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   | 886 +---
 drivers/gpu/drm/i915/intel_drv.h  |   5 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 943 ++
 4 files changed, 953 insertions(+), 883 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index a998c2bce70a..e6fe0040fe64 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -24,7 +24,7 @@ i915-y := i915_drv.o \
  intel_runtime_pm.o
 
 i915-$(CONFIG_COMPAT)   += i915_ioc32.o
-i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o
+i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o intel_pipe_crc.o
 
 # GEM code
 i915-y += i915_cmd_parser.o \
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index da7141382b00..4fb9d829884e 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -26,19 +26,9 @@
  *
  */
 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include "intel_drv.h"
-#include "intel_ringbuffer.h"
-#include 
-#include "i915_drv.h"
 
 static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
 {
@@ -3414,12 +3404,6 @@ static int i915_drrs_status(struct seq_file *m, void 
*unused)
return 0;
 }
 
-struct pipe_crc_info {
-   const char *name;
-   struct drm_i915_private *dev_priv;
-   enum pipe pipe;
-};
-
 static int i915_dp_mst_info(struct seq_file *m, void *unused)
 {
struct drm_i915_private *dev_priv = node_to_i915(m->private);
@@ -3449,848 +3433,6 @@ static int i915_dp_mst_info(struct seq_file *m, void 
*unused)
return 0;
 }
 
-static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes)
-   return -ENODEV;
-
-   spin_lock_irq(&pipe_crc->lock);
-
-   if (pipe_crc->opened) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EBUSY; /* already open */
-   }
-
-   pipe_crc->opened = true;
-   filep->private_data = inode->i_private;
-
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   spin_lock_irq(&pipe_crc->lock);
-   pipe_crc->opened = false;
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-/* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN  (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN(PIPE_CRC_LINE_LEN + 1)
-
-static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
-{
-   assert_spin_locked(&pipe_crc->lock);
-   return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
-   INTEL_PIPE_CRC_ENTRIES_NR);
-}
-
-static ssize_t
-i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
-  loff_t *pos)
-{
-   struct pipe_crc_info *info = filep->private_data;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-   char buf[PIPE_CRC_BUFFER_LEN];
-   int n_entries;
-   ssize_t bytes_read;
-
-   /*
-* Don't allow user space to provide buffers not big enough to hold
-* a line of data.
-*/
-   if (count < PIPE_CRC_LINE_LEN)
-   return -EINVAL;
-
-   if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
-   return 0;
-
-   /* nothing to read */
-   spin_lock_irq(&pipe_crc->lock);
-   while (pipe_crc_data_count(pipe_crc) == 0) {
-   int ret;
-
-   if (filep->f_flags & O_NONBLOCK) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EAGAIN;
-   }
-
-   ret = wait_

[Intel-gfx] [PATCH v10 3/4] drm/i915: Use new CRC debugfs API

2016-10-06 Thread Tomeu Vizoso
The core provides now an ABI to userspace for generation of frame CRCs,
so implement the ->set_crc_source() callback and reuse as much code as
possible with the previous ABI implementation.

When handling the pageflip interrupt, we skip 1 or 2 frames depending on
the HW because they contain wrong values. For the legacy ABI for
generating frame CRCs, this was done in userspace but now that we have a
generic ABI it's better if it's not exposed by the kernel.

v2:
- Leave the legacy implementation in place as the ABI implementation
  in the core is incompatible with it.
v3:
- Use the "cooked" vblank counter so we have a whole 32 bits.
- Make sure we don't mess with the state of the legacy CRC capture
  ABI implementation.
v4:
- Keep use of get_vblank_counter as in the legacy code, will be
  changed in a followup commit.

v5:
- Skip first frame or two as it's known that they contain wrong
  data.
- A few fixes suggested by Emil Velikov.

v6:
- Rework programming of the HW registers to preserve previous
  behavior.

v7:
- Address whitespace issue.
- Added a comment on why in the implementation of the new ABI we
  skip the 1st or 2nd frames.

v9:
- Add stub for intel_crtc_set_crc_source.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 83 +--
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  8 +++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 5 files changed, 149 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index f8c66eea06bc..20522f0a4c57 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1713,6 +1713,7 @@ struct intel_pipe_crc {
enum intel_pipe_crc_source source;
int head, tail;
wait_queue_head_t wq;
+   int skipped;
 };
 
 struct i915_frontbuffer_tracking {
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index bd6c8b0eeaef..1549cc4f88ec 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1491,41 +1491,72 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
 {
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
struct intel_pipe_crc_entry *entry;
-   int head, tail;
+   struct drm_crtc *crtc = intel_get_crtc_for_pipe(&dev_priv->drm, pipe);
+   struct drm_driver *driver = dev_priv->drm.driver;
+   uint32_t crcs[5];
+   int head, tail, ret;
+   u32 frame;
 
spin_lock(&pipe_crc->lock);
+   if (pipe_crc->source) {
+   if (!pipe_crc->entries) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_DEBUG_KMS("spurious interrupt\n");
+   return;
+   }
 
-   if (!pipe_crc->entries) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_DEBUG_KMS("spurious interrupt\n");
-   return;
-   }
-
-   head = pipe_crc->head;
-   tail = pipe_crc->tail;
+   head = pipe_crc->head;
+   tail = pipe_crc->tail;
 
-   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_ERROR("CRC buffer overflowing\n");
-   return;
-   }
+   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_ERROR("CRC buffer overflowing\n");
+   return;
+   }
 
-   entry = &pipe_crc->entries[head];
+   entry = &pipe_crc->entries[head];
 
-   entry->frame = dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm,
-pipe);
-   entry->crc[0] = crc0;
-   entry->crc[1] = crc1;
-   entry->crc[2] = crc2;
-   entry->crc[3] = crc3;
-   entry->crc[4] = crc4;
+   entry->frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
+   entry->crc[0] = crc0;
+   entry->crc[1] = crc1;
+   entry->crc[2] = crc2;
+   entry->crc[3] = crc3;
+   entry->crc[4] = crc4;
 
-   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
-   pipe_crc->head = head;
+   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
+   pipe_crc->head = head;
 
-   spin_unlock(&pipe_crc->lock);
+   spin_unlock(&pipe_crc->lock);
 
-   wake_u

[Intel-gfx] [PATCH v10 0/4] New debugfs API for capturing CRC of frames

2016-10-06 Thread Tomeu Vizoso
Hi,

this series basically takes the facility for continuously capturing CRCs
of frames from the i915 driver and into the DRM core.

The idea is that test suites such as IGT use this information to check
that frames that are exected to be identical, also have identical CRC
values.

Other drivers for hardware that can provide frame CRCs (including eDP
panels that support self-refresh) can easily implement the new callback
and provide userspace with the CRC values.

In this v10 debugfs creation failures don't abort CRTC registration, as
suggested by Emil Velikov.

Thanks,

Tomeu


Tomeu Vizoso (4):
  drm/i915/debugfs: Move out pipe CRC code
  drm: Add API for capturing frame CRCs
  drm/i915: Use new CRC debugfs API
  drm/i915: Put "cooked" vlank counters in frame CRC lines

 Documentation/gpu/drm-uapi.rst|6 +
 drivers/gpu/drm/Makefile  |3 +-
 drivers/gpu/drm/drm_crtc.c|   34 +-
 drivers/gpu/drm/drm_debugfs.c |   34 +-
 drivers/gpu/drm/drm_debugfs_crc.c |  351 
 drivers/gpu/drm/drm_internal.h|   16 +
 drivers/gpu/drm/i915/Makefile |2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   |  886 +---
 drivers/gpu/drm/i915/i915_drv.h   |1 +
 drivers/gpu/drm/i915/i915_irq.c   |   83 ++-
 drivers/gpu/drm/i915/intel_display.c  |1 +
 drivers/gpu/drm/i915/intel_drv.h  |   13 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 1013 +
 include/drm/drm_crtc.h|   41 ++
 include/drm/drm_debugfs_crc.h |   73 +++
 15 files changed, 1645 insertions(+), 912 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_debugfs_crc.c
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c
 create mode 100644 include/drm/drm_debugfs_crc.h

-- 
2.7.4

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


[Intel-gfx] [PATCH v9 1/4] drm/i915/debugfs: Move out pipe CRC code

2016-10-06 Thread Tomeu Vizoso
In preparation to using a generic API in the DRM core for continuous CRC
generation, move the related code out of i915_debugfs.c into a new file.

Eventually, only the Intel-specific code will remain in this new file.

v2: Rebased.

v6: Rebased.

v7: Fix whitespace issue.

v9: Have intel_display_crc_init accept a drm_i915_private instead.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/Makefile |   2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   | 886 +---
 drivers/gpu/drm/i915/intel_drv.h  |   5 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 943 ++
 4 files changed, 953 insertions(+), 883 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index a998c2bce70a..e6fe0040fe64 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -24,7 +24,7 @@ i915-y := i915_drv.o \
  intel_runtime_pm.o
 
 i915-$(CONFIG_COMPAT)   += i915_ioc32.o
-i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o
+i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o intel_pipe_crc.o
 
 # GEM code
 i915-y += i915_cmd_parser.o \
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index da7141382b00..4fb9d829884e 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -26,19 +26,9 @@
  *
  */
 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include "intel_drv.h"
-#include "intel_ringbuffer.h"
-#include 
-#include "i915_drv.h"
 
 static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
 {
@@ -3414,12 +3404,6 @@ static int i915_drrs_status(struct seq_file *m, void 
*unused)
return 0;
 }
 
-struct pipe_crc_info {
-   const char *name;
-   struct drm_i915_private *dev_priv;
-   enum pipe pipe;
-};
-
 static int i915_dp_mst_info(struct seq_file *m, void *unused)
 {
struct drm_i915_private *dev_priv = node_to_i915(m->private);
@@ -3449,848 +3433,6 @@ static int i915_dp_mst_info(struct seq_file *m, void 
*unused)
return 0;
 }
 
-static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes)
-   return -ENODEV;
-
-   spin_lock_irq(&pipe_crc->lock);
-
-   if (pipe_crc->opened) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EBUSY; /* already open */
-   }
-
-   pipe_crc->opened = true;
-   filep->private_data = inode->i_private;
-
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   spin_lock_irq(&pipe_crc->lock);
-   pipe_crc->opened = false;
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-/* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN  (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN(PIPE_CRC_LINE_LEN + 1)
-
-static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
-{
-   assert_spin_locked(&pipe_crc->lock);
-   return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
-   INTEL_PIPE_CRC_ENTRIES_NR);
-}
-
-static ssize_t
-i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
-  loff_t *pos)
-{
-   struct pipe_crc_info *info = filep->private_data;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-   char buf[PIPE_CRC_BUFFER_LEN];
-   int n_entries;
-   ssize_t bytes_read;
-
-   /*
-* Don't allow user space to provide buffers not big enough to hold
-* a line of data.
-*/
-   if (count < PIPE_CRC_LINE_LEN)
-   return -EINVAL;
-
-   if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
-   return 0;
-
-   /* nothing to read */
-   spin_lock_irq(&pipe_crc->lock);
-   while (pipe_crc_data_count(pipe_crc) == 0) {
-   int ret;
-
-   if (filep->f_flags & O_NONBLOCK) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EAGAIN;
-   }
-
-   ret = wait_

[Intel-gfx] [PATCH v9 3/4] drm/i915: Use new CRC debugfs API

2016-10-06 Thread Tomeu Vizoso
The core provides now an ABI to userspace for generation of frame CRCs,
so implement the ->set_crc_source() callback and reuse as much code as
possible with the previous ABI implementation.

When handling the pageflip interrupt, we skip 1 or 2 frames depending on
the HW because they contain wrong values. For the legacy ABI for
generating frame CRCs, this was done in userspace but now that we have a
generic ABI it's better if it's not exposed by the kernel.

v2:
- Leave the legacy implementation in place as the ABI implementation
  in the core is incompatible with it.
v3:
- Use the "cooked" vblank counter so we have a whole 32 bits.
- Make sure we don't mess with the state of the legacy CRC capture
  ABI implementation.
v4:
- Keep use of get_vblank_counter as in the legacy code, will be
  changed in a followup commit.

v5:
- Skip first frame or two as it's known that they contain wrong
  data.
- A few fixes suggested by Emil Velikov.

v6:
- Rework programming of the HW registers to preserve previous
  behavior.

v7:
- Address whitespace issue.
- Added a comment on why in the implementation of the new ABI we
  skip the 1st or 2nd frames.

v9:
- Add stub for intel_crtc_set_crc_source.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 83 +--
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  8 +++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 5 files changed, 149 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index f8c66eea06bc..20522f0a4c57 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1713,6 +1713,7 @@ struct intel_pipe_crc {
enum intel_pipe_crc_source source;
int head, tail;
wait_queue_head_t wq;
+   int skipped;
 };
 
 struct i915_frontbuffer_tracking {
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index bd6c8b0eeaef..1549cc4f88ec 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1491,41 +1491,72 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
 {
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
struct intel_pipe_crc_entry *entry;
-   int head, tail;
+   struct drm_crtc *crtc = intel_get_crtc_for_pipe(&dev_priv->drm, pipe);
+   struct drm_driver *driver = dev_priv->drm.driver;
+   uint32_t crcs[5];
+   int head, tail, ret;
+   u32 frame;
 
spin_lock(&pipe_crc->lock);
+   if (pipe_crc->source) {
+   if (!pipe_crc->entries) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_DEBUG_KMS("spurious interrupt\n");
+   return;
+   }
 
-   if (!pipe_crc->entries) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_DEBUG_KMS("spurious interrupt\n");
-   return;
-   }
-
-   head = pipe_crc->head;
-   tail = pipe_crc->tail;
+   head = pipe_crc->head;
+   tail = pipe_crc->tail;
 
-   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_ERROR("CRC buffer overflowing\n");
-   return;
-   }
+   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_ERROR("CRC buffer overflowing\n");
+   return;
+   }
 
-   entry = &pipe_crc->entries[head];
+   entry = &pipe_crc->entries[head];
 
-   entry->frame = dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm,
-pipe);
-   entry->crc[0] = crc0;
-   entry->crc[1] = crc1;
-   entry->crc[2] = crc2;
-   entry->crc[3] = crc3;
-   entry->crc[4] = crc4;
+   entry->frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
+   entry->crc[0] = crc0;
+   entry->crc[1] = crc1;
+   entry->crc[2] = crc2;
+   entry->crc[3] = crc3;
+   entry->crc[4] = crc4;
 
-   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
-   pipe_crc->head = head;
+   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
+   pipe_crc->head = head;
 
-   spin_unlock(&pipe_crc->lock);
+   spin_unlock(&pipe_crc->lock);
 
-   wake_u

[Intel-gfx] [PATCH v9 4/4] drm/i915: Put "cooked" vlank counters in frame CRC lines

2016-10-06 Thread Tomeu Vizoso
Use drm_accurate_vblank_count so we have the full 32 bit to represent
the frame counter and userspace has a simpler way of knowing when the
counter wraps around.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_irq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 1549cc4f88ec..238a353454e9 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1495,7 +1495,6 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
struct drm_driver *driver = dev_priv->drm.driver;
uint32_t crcs[5];
int head, tail, ret;
-   u32 frame;
 
spin_lock(&pipe_crc->lock);
if (pipe_crc->source) {
@@ -1551,8 +1550,9 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
crcs[2] = crc2;
crcs[3] = crc3;
crcs[4] = crc4;
-   frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
-   ret = drm_crtc_add_crc_entry(crtc, true, frame, crcs);
+   ret = drm_crtc_add_crc_entry(crtc, true,
+drm_accurate_vblank_count(crtc),
+crcs);
spin_unlock(&crtc->crc.lock);
if (!ret)
wake_up_interruptible(&crtc->crc.wq);
-- 
2.7.4

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


[Intel-gfx] [PATCH v9 0/4] New debugfs API for capturing CRC of frames

2016-10-06 Thread Tomeu Vizoso
Hi,

this series basically takes the facility for continuously capturing CRCs
of frames from the i915 driver and into the DRM core.

The idea is that test suites such as IGT use this information to check
that frames that are exected to be identical, also have identical CRC
values.

Other drivers for hardware that can provide frame CRCs (including eDP
panels that support self-refresh) can easily implement the new callback
and provide userspace with the CRC values.

In this v9, there are build fixes for !CONFIG_DEBUG_FS and a fix so we don't
break probing of drivers that still use the .load callback (tested on
Tegra124).

Thanks,

Tomeu


Tomeu Vizoso (4):
  drm/i915/debugfs: Move out pipe CRC code
  drm: Add API for capturing frame CRCs
  drm/i915: Use new CRC debugfs API
  drm/i915: Put "cooked" vlank counters in frame CRC lines

 Documentation/gpu/drm-uapi.rst|6 +
 drivers/gpu/drm/Makefile  |3 +-
 drivers/gpu/drm/drm_crtc.c|   34 +-
 drivers/gpu/drm/drm_debugfs.c |   34 +-
 drivers/gpu/drm/drm_debugfs_crc.c |  351 
 drivers/gpu/drm/drm_internal.h|   16 +
 drivers/gpu/drm/i915/Makefile |2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   |  886 +---
 drivers/gpu/drm/i915/i915_drv.h   |1 +
 drivers/gpu/drm/i915/i915_irq.c   |   83 ++-
 drivers/gpu/drm/i915/intel_display.c  |1 +
 drivers/gpu/drm/i915/intel_drv.h  |   13 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 1013 +
 include/drm/drm_crtc.h|   41 ++
 include/drm/drm_debugfs_crc.h |   73 +++
 15 files changed, 1645 insertions(+), 912 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_debugfs_crc.c
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c
 create mode 100644 include/drm/drm_debugfs_crc.h

-- 
2.7.4

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


[Intel-gfx] [PATCH v2] drm/i915: Fix build when !CONFIG_DEBUG_FS

2016-09-30 Thread Tomeu Vizoso
Add stub for intel_crtc_set_crc_source() and fix arguments of
intel_display_crc_init().

Signed-off-by: Tomeu Vizoso 
Fixes: 21165bd933ac ("drm/i915/debugfs: Move out pipe CRC code")
Fixes: 13fa0253d97a ("drm/i915: Use new CRC debugfs API")
---
 drivers/gpu/drm/i915/i915_drv.c   | 2 +-
 drivers/gpu/drm/i915/i915_drv.h   | 2 +-
 drivers/gpu/drm/i915/intel_drv.h  | 6 ++
 drivers/gpu/drm/i915/intel_pipe_crc.c | 3 +--
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 31b2b6300d8d..9c1543240e27 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -847,7 +847,7 @@ static int i915_driver_init_early(struct drm_i915_private 
*dev_priv,
intel_init_audio_hooks(dev_priv);
i915_gem_load_init(&dev_priv->drm);
 
-   intel_display_crc_init(&dev_priv->drm);
+   intel_display_crc_init(dev_priv);
 
intel_device_info_dump(dev_priv);
 
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 91ff3d735c45..d1195f4ffd29 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3524,7 +3524,7 @@ static inline bool 
i915_gem_object_needs_bit17_swizzle(struct drm_i915_gem_objec
 int i915_debugfs_register(struct drm_i915_private *dev_priv);
 void i915_debugfs_unregister(struct drm_i915_private *dev_priv);
 int i915_debugfs_connector_add(struct drm_connector *connector);
-void intel_display_crc_init(struct drm_device *dev);
+void intel_display_crc_init(struct drm_i915_private *dev_priv);
 #else
 static inline int i915_debugfs_register(struct drm_i915_private *dev_priv) 
{return 0;}
 static inline void i915_debugfs_unregister(struct drm_i915_private *dev_priv) 
{}
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index c49a11ed70be..73bab745c855 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1842,8 +1842,14 @@ void intel_color_load_luts(struct drm_crtc_state 
*crtc_state);
 /* intel_pipe_crc.c */
 int intel_pipe_crc_create(struct drm_minor *minor);
 void intel_pipe_crc_cleanup(struct drm_minor *minor);
+#ifdef CONFIG_DEBUG_FS
 int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name,
  size_t *values_cnt);
+#else
+static inline int intel_crtc_set_crc_source(struct drm_crtc *crtc,
+   const char *source_name,
+   size_t *values_cnt) { return 0; }
+#endif
 extern const struct file_operations i915_display_crc_ctl_fops;
 
 #endif /* __INTEL_DRV_H__ */
diff --git a/drivers/gpu/drm/i915/intel_pipe_crc.c 
b/drivers/gpu/drm/i915/intel_pipe_crc.c
index a3f3f45645ac..1a51e174e9e5 100644
--- a/drivers/gpu/drm/i915/intel_pipe_crc.c
+++ b/drivers/gpu/drm/i915/intel_pipe_crc.c
@@ -915,9 +915,8 @@ const struct file_operations i915_display_crc_ctl_fops = {
.write = display_crc_ctl_write
 };
 
-void intel_display_crc_init(struct drm_device *dev)
+void intel_display_crc_init(struct drm_i915_private *dev_priv)
 {
-   struct drm_i915_private *dev_priv = dev->dev_private;
enum pipe pipe;
 
for_each_pipe(dev_priv, pipe) {
-- 
2.7.4

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


[Intel-gfx] [PATCH] drm/i915: Fix build when !CONFIG_DEBUG_FS

2016-09-30 Thread Tomeu Vizoso
Add stub for intel_crtc_set_crc_source() and fix arguments of stub for
intel_display_crc_init().

Signed-off-by: Tomeu Vizoso 
Fixes: 21165bd933ac ("drm/i915/debugfs: Move out pipe CRC code")
Fixes: 13fa0253d97a ("drm/i915: Use new CRC debugfs API")
---
 drivers/gpu/drm/i915/i915_drv.h  | 2 +-
 drivers/gpu/drm/i915/intel_drv.h | 6 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 91ff3d735c45..e0cb71c9c52e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3530,7 +3530,7 @@ static inline int i915_debugfs_register(struct 
drm_i915_private *dev_priv) {retu
 static inline void i915_debugfs_unregister(struct drm_i915_private *dev_priv) 
{}
 static inline int i915_debugfs_connector_add(struct drm_connector *connector)
 { return 0; }
-static inline void intel_display_crc_init(struct drm_i915_private *dev_priv) {}
+static inline void intel_display_crc_init(struct drm_device *dev) {}
 #endif
 
 /* i915_gpu_error.c */
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index c49a11ed70be..73bab745c855 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1842,8 +1842,14 @@ void intel_color_load_luts(struct drm_crtc_state 
*crtc_state);
 /* intel_pipe_crc.c */
 int intel_pipe_crc_create(struct drm_minor *minor);
 void intel_pipe_crc_cleanup(struct drm_minor *minor);
+#ifdef CONFIG_DEBUG_FS
 int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name,
  size_t *values_cnt);
+#else
+static inline int intel_crtc_set_crc_source(struct drm_crtc *crtc,
+   const char *source_name,
+   size_t *values_cnt) { return 0; }
+#endif
 extern const struct file_operations i915_display_crc_ctl_fops;
 
 #endif /* __INTEL_DRV_H__ */
-- 
2.7.4

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


[Intel-gfx] [PATCH i-g-t v3] lib/debugfs: Support new generic ABI for CRC capture

2016-09-29 Thread Tomeu Vizoso
The kernel has now a new debugfs ABI that can also allow capturing frame
CRCs for drivers other than i915.

Add alternative codepaths so the new ABI is used if the kernel is recent
enough, and fall back to the legacy ABI if not.

Signed-off-by: Tomeu Vizoso 
---

Have just dropped the additional testing of the legacy ABI if the new one is
available, so we just fallback to the old one if needed.

---
 lib/igt_debugfs.c  | 188 +
 lib/igt_debugfs.h  |   4 +-
 tests/kms_pipe_crc_basic.c |  38 -
 3 files changed, 158 insertions(+), 72 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index fb13a88bf8cd..89b8d5ba98ca 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -290,25 +291,23 @@ char *igt_crc_to_string(igt_crc_t *crc)
 {
char buf[128];
 
-   igt_assert_eq(crc->n_words, 5);
-
sprintf(buf, "%08x %08x %08x %08x %08x", crc->crc[0],
crc->crc[1], crc->crc[2], crc->crc[3], crc->crc[4]);
 
return strdup(buf);
 }
 
+#define MAX_CRC_ENTRIES 10
+#define MAX_LINE_LEN (10 + 11 * MAX_CRC_ENTRIES + 1)
+
 /* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN   (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1)
+#define LEGACY_LINE_LEN   (6 * 8 + 5 + 1)
 
 struct _igt_pipe_crc {
int ctl_fd;
int crc_fd;
-   int line_len;
-   int buffer_len;
int flags;
+   bool is_legacy;
 
enum pipe pipe;
enum intel_pipe_crc_source source;
@@ -339,13 +338,26 @@ static bool igt_pipe_crc_do_start(igt_pipe_crc_t 
*pipe_crc)
/* Stop first just to make sure we don't have lingering state left. */
igt_pipe_crc_stop(pipe_crc);
 
-   sprintf(buf, "pipe %s %s", kmstest_pipe_name(pipe_crc->pipe),
-   pipe_crc_source_name(pipe_crc->source));
+   if (pipe_crc->is_legacy)
+   sprintf(buf, "pipe %s %s", kmstest_pipe_name(pipe_crc->pipe),
+   pipe_crc_source_name(pipe_crc->source));
+   else
+   sprintf(buf, "%s", pipe_crc_source_name(pipe_crc->source));
+
errno = 0;
igt_assert_eq(write(pipe_crc->ctl_fd, buf, strlen(buf)), strlen(buf));
if (errno != 0)
return false;
 
+   if (!pipe_crc->is_legacy) {
+   sprintf(buf, "crtc-%d/crc/data", pipe_crc->pipe);
+   errno = 0;
+   pipe_crc->crc_fd = igt_debugfs_open(buf, pipe_crc->flags);
+   if (pipe_crc->crc_fd == -1 && errno == EINVAL)
+   return false;
+   igt_assert_eq(errno, 0);
+   }
+
return true;
 }
 
@@ -359,15 +371,45 @@ static void igt_pipe_crc_pipe_off(int fd, enum pipe pipe)
 
 static void igt_pipe_crc_reset(void)
 {
+   igt_debugfs_t *debugfs = __igt_debugfs_singleton();
int fd;
+   struct dirent *dirent;
+   char buf[128];
+   const char *cmd = "none";
+   bool done = false;
+   DIR *dir;
+
+   dir = opendir(debugfs->dri_path);
+   if (dir) {
+   while ((dirent = readdir(dir))) {
+   if (strcmp(dirent->d_name, "crtc-") != 0)
+   continue;
+
+   sprintf(buf, "%s/%s/crc/control", debugfs->dri_path,
+   dirent->d_name);
+   fd = open(buf, O_WRONLY);
+   if (fd == -1)
+   continue;
+
+   igt_assert_eq(write(fd, cmd, strlen(cmd)), strlen(cmd));
+   done = true;
+
+   close(fd);
+   }
+   closedir(dir);
+   }
 
-   fd = igt_debugfs_open("i915_display_crc_ctl", O_WRONLY);
+   if (done)
+   return;
 
-   igt_pipe_crc_pipe_off(fd, PIPE_A);
-   igt_pipe_crc_pipe_off(fd, PIPE_B);
-   igt_pipe_crc_pipe_off(fd, PIPE_C);
+   fd = igt_debugfs_open("i915_display_crc_ctl", O_WRONLY);
+   if (fd != -1) {
+   igt_pipe_crc_pipe_off(fd, PIPE_A);
+   igt_pipe_crc_pipe_off(fd, PIPE_B);
+   igt_pipe_crc_pipe_off(fd, PIPE_C);
 
-   close(fd);
+   close(fd);
+   }
 }
 
 static void pipe_crc_exit_handler(int sig)
@@ -389,13 +431,16 @@ void igt_require_pipe_crc(void)
size_t written;
int ret;
 
-   ctl = igt_debugfs_fopen("i915_display_crc_ctl", "r+");
-   igt_require_f(ctl,
- "No display_crc_ctl found, kernel too old\n");
-   written = fwrite(cmd, 1, strlen(cmd), ctl);
-   ret 

[Intel-gfx] [PATCH i-g-t v2] lib/debugfs: Support new generic ABI for CRC capture

2016-09-29 Thread Tomeu Vizoso
The kernel has now a new debugfs ABI that can also allow capturing frame
CRCs for drivers other than i915.

Add alternative codepaths so the new ABI is used if the kernel is recent
enough, and fall back to the legacy ABI if not.

Signed-off-by: Tomeu Vizoso 
---
 lib/igt_debugfs.c  | 236 +++--
 lib/igt_debugfs.h  |   8 +-
 tests/kms_pipe_crc_basic.c | 162 +++
 3 files changed, 311 insertions(+), 95 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index fb13a88bf8cd..575396b00c8f 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -257,6 +258,10 @@ bool igt_debugfs_search(const char *filename, const char 
*substring)
  * Pipe CRC
  */
 
+#define CRC_DEFAULTS   0
+#define CRC_FORCE_LEGACY   (1 << 0)
+#define CRC_NONBLOCK   (1 << 1)
+
 /**
  * igt_assert_crc_equal:
  * @a: first pipe CRC value
@@ -290,25 +295,23 @@ char *igt_crc_to_string(igt_crc_t *crc)
 {
char buf[128];
 
-   igt_assert_eq(crc->n_words, 5);
-
sprintf(buf, "%08x %08x %08x %08x %08x", crc->crc[0],
crc->crc[1], crc->crc[2], crc->crc[3], crc->crc[4]);
 
return strdup(buf);
 }
 
+#define MAX_CRC_ENTRIES 10
+#define MAX_LINE_LEN (10 + 11 * MAX_CRC_ENTRIES + 1)
+
 /* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN   (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN (PIPE_CRC_LINE_LEN + 1)
+#define LEGACY_LINE_LEN   (6 * 8 + 5 + 1)
 
 struct _igt_pipe_crc {
int ctl_fd;
int crc_fd;
-   int line_len;
-   int buffer_len;
int flags;
+   bool is_legacy;
 
enum pipe pipe;
enum intel_pipe_crc_source source;
@@ -329,23 +332,39 @@ static const char *pipe_crc_sources[] = {
 
 static const char *pipe_crc_source_name(enum intel_pipe_crc_source source)
 {
-return pipe_crc_sources[source];
+   return pipe_crc_sources[source];
 }
 
 static bool igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)
 {
char buf[64];
+   int mode = O_RDONLY;
 
/* Stop first just to make sure we don't have lingering state left. */
igt_pipe_crc_stop(pipe_crc);
 
-   sprintf(buf, "pipe %s %s", kmstest_pipe_name(pipe_crc->pipe),
-   pipe_crc_source_name(pipe_crc->source));
+   if (pipe_crc->is_legacy)
+   sprintf(buf, "pipe %s %s", kmstest_pipe_name(pipe_crc->pipe),
+   pipe_crc_source_name(pipe_crc->source));
+   else
+   sprintf(buf, "%s", pipe_crc_source_name(pipe_crc->source));
+
errno = 0;
igt_assert_eq(write(pipe_crc->ctl_fd, buf, strlen(buf)), strlen(buf));
if (errno != 0)
return false;
 
+   if (!pipe_crc->is_legacy) {
+   sprintf(buf, "crtc-%d/crc/data", pipe_crc->pipe);
+   errno = 0;
+   if (pipe_crc->flags & CRC_NONBLOCK)
+   mode |= O_NONBLOCK;
+   pipe_crc->crc_fd = igt_debugfs_open(buf, mode);
+   if (pipe_crc->crc_fd == -1 && errno == EINVAL)
+   return false;
+   igt_assert_eq(errno, 0);
+   }
+
return true;
 }
 
@@ -359,15 +378,38 @@ static void igt_pipe_crc_pipe_off(int fd, enum pipe pipe)
 
 static void igt_pipe_crc_reset(void)
 {
+   igt_debugfs_t *debugfs = __igt_debugfs_singleton();
int fd;
+   struct dirent *dirent;
+   char buf[128];
+   const char *cmd = "none";
+   DIR *dir;
 
fd = igt_debugfs_open("i915_display_crc_ctl", O_WRONLY);
+   if (fd != -1) {
+   igt_pipe_crc_pipe_off(fd, PIPE_A);
+   igt_pipe_crc_pipe_off(fd, PIPE_B);
+   igt_pipe_crc_pipe_off(fd, PIPE_C);
+
+   close(fd);
+   }
 
-   igt_pipe_crc_pipe_off(fd, PIPE_A);
-   igt_pipe_crc_pipe_off(fd, PIPE_B);
-   igt_pipe_crc_pipe_off(fd, PIPE_C);
+   dir = opendir(debugfs->dri_path);
+   if (dir) {
+   while ((dirent = readdir(dir))) {
+   if (strcmp(dirent->d_name, "crtc-") != 0)
+   continue;
 
-   close(fd);
+   sprintf(buf, "%s/%s/crc/control", debugfs->dri_path,
+   dirent->d_name);
+   fd = open(buf, O_WRONLY);
+
+   igt_assert_eq(write(fd, cmd, strlen(cmd)), strlen(cmd));
+
+   close(fd);
+   }
+   closedir(dir);
+   }
 }
 
 static void pipe_crc_exit_handler(int sig)
@@ -389,13 +431,16 @@ void igt_require_pipe_crc(void)
size_t written;
 

Re: [Intel-gfx] [PATCH] drm: Add frame CRC debugfs files only for drivers that have CRTC

2016-09-29 Thread Tomeu Vizoso
On 29 September 2016 at 05:42, Dhinakaran Pandiyan
 wrote:
> vgem does not do modeset, looping through non-existent CRTC's while
> registering drm_minor in
>
> 'commit 48c787899882 ("drm: Add API for capturing frame CRCs")'
>
> caused kernel oops. So, let's add CRC debugfs files
> only for those drivers that do modeset.
>
> Signed-off-by: Dhinakaran Pandiyan 
> Cc: Tomeu Vizoso 
> Cc: Daniel Vetter 
> Cc: Emil Velikov 

Reviewed-by: Tomeu Vizoso 

But I would prefer if drm_for_each_crtc was safe to call in any device
regardless of the features that its driver supports.

Regards,

Tomeu

> ---
>  drivers/gpu/drm/drm_drv.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 70d2543..294404f 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -208,6 +208,7 @@ static int drm_minor_register(struct drm_device *dev, 
> unsigned int type)
> struct drm_crtc *crtc;
> unsigned long flags;
> int ret;
> +   bool is_modeset;
>
> DRM_DEBUG("\n");
>
> @@ -221,7 +222,8 @@ static int drm_minor_register(struct drm_device *dev, 
> unsigned int type)
> return ret;
> }
>
> -   if (type == DRM_MINOR_PRIMARY) {
> +   is_modeset = drm_core_check_feature(dev, DRIVER_MODESET);
> +   if (type == DRM_MINOR_PRIMARY && is_modeset) {
> drm_for_each_crtc(crtc, dev) {
> ret = drm_debugfs_crtc_add(crtc);
> if (ret)
> @@ -255,12 +257,14 @@ static void drm_minor_unregister(struct drm_device 
> *dev, unsigned int type)
> struct drm_minor *minor;
> struct drm_crtc *crtc;
> unsigned long flags;
> +   bool is_modeset;
>
> minor = *drm_minor_get_slot(dev, type);
> if (!minor || !device_is_registered(minor->kdev))
> return;
>
> -   if (type == DRM_MINOR_PRIMARY) {
> +   is_modeset = drm_core_check_feature(dev, DRIVER_MODESET);
> +   if (type == DRM_MINOR_PRIMARY && is_modeset) {
> drm_for_each_crtc(crtc, dev)
> drm_debugfs_crtc_remove(crtc);
> }
> --
> 2.7.4
>
> ___
> 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 2/2] kms_atomic: plane_primary: Allow modeset if atomic check returns -EINVAL

2016-09-27 Thread Tomeu Vizoso
On 12 September 2016 at 09:11, Liu Ying  wrote:
> Allowing modeset may prevent the test case from failing in case the atomic
> check phase finds the userspace doesn't allow modeset for the commit and
> returns -EINVAL.  A real case is to run the test case on imx-drm which
> requires a full modeset when we change an active plane's configuration,
> e.g., pixel format and stride.

Pushed both changes, thanks!

Tomeu

> Cc: Daniel Vetter 
> Cc: Marius Vlad 
> Cc: Micah Fedke 
> Cc: Daniel Stone 
> Signed-off-by: Liu Ying 
> ---
>  tests/kms_atomic.c | 17 ++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
> index bc6e575..1441fdf 100644
> --- a/tests/kms_atomic.c
> +++ b/tests/kms_atomic.c
> @@ -910,6 +910,8 @@ static void plane_primary(struct kms_atomic_crtc_state 
> *crtc,
> uint32_t format = plane_get_igt_format(&plane);
> drmModeAtomicReq *req = drmModeAtomicAlloc();
> struct igt_fb fb;
> +   uint32_t flags = 0;
> +   int ret;
>
> igt_require(format != 0);
>
> @@ -926,12 +928,21 @@ static void plane_primary(struct kms_atomic_crtc_state 
> *crtc,
> plane.crtc_w, plane.crtc_h,
> format, I915_TILING_NONE, &fb);
>
> +   drmModeAtomicSetCursor(req, 0);
> +   crtc_populate_req(crtc, req);
> +   plane_populate_req(&plane, req);
> +   ret = drmModeAtomicCommit(crtc->state->desc->fd, req,
> + DRM_MODE_ATOMIC_TEST_ONLY, NULL);
> +   /* Try harder in case the failure is caused by disallowing modeset. */
> +   if (ret == -EINVAL)
> +   flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
> +
> /* Flip the primary plane using the atomic API, and double-check
>  * state is what we think it should be. */
> -   crtc_commit_atomic(crtc, &plane, req, ATOMIC_RELAX_NONE, 0);
> +   crtc_commit_atomic(crtc, &plane, req, ATOMIC_RELAX_NONE, flags);
>
> /* Restore the primary plane and check the state matches the old. */
> -   crtc_commit_atomic(crtc, plane_old, req, ATOMIC_RELAX_NONE, 0);
> +   crtc_commit_atomic(crtc, plane_old, req, ATOMIC_RELAX_NONE, flags);
>
> /* Re-enable the plane through the legacy CRTC/primary-plane API, and
>  * verify through atomic. */
> @@ -942,7 +953,7 @@ static void plane_primary(struct kms_atomic_crtc_state 
> *crtc,
> crtc_commit_legacy(crtc, plane_old, CRTC_RELAX_MODE);
>
> /* Finally, restore to the original state. */
> -   crtc_commit_atomic(crtc, plane_old, req, ATOMIC_RELAX_NONE, 0);
> +   crtc_commit_atomic(crtc, plane_old, req, ATOMIC_RELAX_NONE, flags);
>
> drmModeAtomicFree(req);
>  }
> --
> 2.7.4
>
> ___
> 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


[Intel-gfx] [PATCH v8 3/4] drm/i915: Use new CRC debugfs API

2016-09-09 Thread Tomeu Vizoso
The core provides now an ABI to userspace for generation of frame CRCs,
so implement the ->set_crc_source() callback and reuse as much code as
possible with the previous ABI implementation.

When handling the pageflip interrupt, we skip 1 or 2 frames depending on
the HW because they contain wrong values. For the legacy ABI for
generating frame CRCs, this was done in userspace but now that we have a
generic ABI it's better if it's not exposed by the kernel.

v2:
- Leave the legacy implementation in place as the ABI implementation
  in the core is incompatible with it.
v3:
- Use the "cooked" vblank counter so we have a whole 32 bits.
- Make sure we don't mess with the state of the legacy CRC capture
  ABI implementation.
v4:
- Keep use of get_vblank_counter as in the legacy code, will be
  changed in a followup commit.

v5:
- Skip first frame or two as it's known that they contain wrong
  data.
- A few fixes suggested by Emil Velikov.

v6:
- Rework programming of the HW registers to preserve previous
  behavior.

v7:
- Address whitespace issue.
- Added a comment on why in the implementation of the new ABI we
  skip the 1st or 2nd frames.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_drv.h   |  1 +
 drivers/gpu/drm/i915/i915_irq.c   | 83 +--
 drivers/gpu/drm/i915/intel_display.c  |  1 +
 drivers/gpu/drm/i915/intel_drv.h  |  2 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 94 ++-
 5 files changed, 143 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 4e7912704633..cf4bfc29ec40 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1693,6 +1693,7 @@ struct intel_pipe_crc {
enum intel_pipe_crc_source source;
int head, tail;
wait_queue_head_t wq;
+   int skipped;
 };
 
 struct i915_frontbuffer_tracking {
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 82358d4e0cc2..e56c7f627093 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1485,41 +1485,72 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
 {
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
struct intel_pipe_crc_entry *entry;
-   int head, tail;
+   struct drm_crtc *crtc = intel_get_crtc_for_pipe(&dev_priv->drm, pipe);
+   struct drm_driver *driver = dev_priv->drm.driver;
+   uint32_t crcs[5];
+   int head, tail, ret;
+   u32 frame;
 
spin_lock(&pipe_crc->lock);
+   if (pipe_crc->source) {
+   if (!pipe_crc->entries) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_DEBUG_KMS("spurious interrupt\n");
+   return;
+   }
 
-   if (!pipe_crc->entries) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_DEBUG_KMS("spurious interrupt\n");
-   return;
-   }
-
-   head = pipe_crc->head;
-   tail = pipe_crc->tail;
+   head = pipe_crc->head;
+   tail = pipe_crc->tail;
 
-   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
-   spin_unlock(&pipe_crc->lock);
-   DRM_ERROR("CRC buffer overflowing\n");
-   return;
-   }
+   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(&pipe_crc->lock);
+   DRM_ERROR("CRC buffer overflowing\n");
+   return;
+   }
 
-   entry = &pipe_crc->entries[head];
+   entry = &pipe_crc->entries[head];
 
-   entry->frame = dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm,
-pipe);
-   entry->crc[0] = crc0;
-   entry->crc[1] = crc1;
-   entry->crc[2] = crc2;
-   entry->crc[3] = crc3;
-   entry->crc[4] = crc4;
+   entry->frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
+   entry->crc[0] = crc0;
+   entry->crc[1] = crc1;
+   entry->crc[2] = crc2;
+   entry->crc[3] = crc3;
+   entry->crc[4] = crc4;
 
-   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
-   pipe_crc->head = head;
+   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
+   pipe_crc->head = head;
 
-   spin_unlock(&pipe_crc->lock);
+   spin_unlock(&pipe_crc->lock);
 
-   wake_up_interruptible(&pipe_crc->wq);
+   w

[Intel-gfx] [PATCH v8 4/4] drm/i915: Put "cooked" vlank counters in frame CRC lines

2016-09-09 Thread Tomeu Vizoso
Use drm_accurate_vblank_count so we have the full 32 bit to represent
the frame counter and userspace has a simpler way of knowing when the
counter wraps around.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/i915_irq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index e56c7f627093..6d3d4ad62498 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1489,7 +1489,6 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
struct drm_driver *driver = dev_priv->drm.driver;
uint32_t crcs[5];
int head, tail, ret;
-   u32 frame;
 
spin_lock(&pipe_crc->lock);
if (pipe_crc->source) {
@@ -1545,8 +1544,9 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
crcs[2] = crc2;
crcs[3] = crc3;
crcs[4] = crc4;
-   frame = driver->get_vblank_counter(&dev_priv->drm, pipe);
-   ret = drm_crtc_add_crc_entry(crtc, true, frame, crcs);
+   ret = drm_crtc_add_crc_entry(crtc, true,
+drm_accurate_vblank_count(crtc),
+crcs);
spin_unlock(&crtc->crc.lock);
if (!ret)
wake_up_interruptible(&crtc->crc.wq);
-- 
2.7.4

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


[Intel-gfx] [PATCH v8 1/4] drm/i915/debugfs: Move out pipe CRC code

2016-09-09 Thread Tomeu Vizoso
In preparation to using a generic API in the DRM core for continuous CRC
generation, move the related code out of i915_debugfs.c into a new file.

Eventually, only the Intel-specific code will remain in this new file.

v2: Rebased.

v6: Rebased.

v7: Fix whitespace issue.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Emil Velikov 
---

 drivers/gpu/drm/i915/Makefile |   2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   | 886 +--
 drivers/gpu/drm/i915/i915_drv.c   |   2 +-
 drivers/gpu/drm/i915/i915_drv.h   |   2 +-
 drivers/gpu/drm/i915/intel_drv.h  |   5 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 944 ++
 6 files changed, 956 insertions(+), 885 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index a7da24640e88..6238f8042426 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -23,7 +23,7 @@ i915-y := i915_drv.o \
  intel_runtime_pm.o
 
 i915-$(CONFIG_COMPAT)   += i915_ioc32.o
-i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o
+i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o intel_pipe_crc.o
 
 # GEM code
 i915-y += i915_cmd_parser.o \
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 02b627e03dd8..daa1b5a5c423 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -26,19 +26,9 @@
  *
  */
 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include "intel_drv.h"
-#include "intel_ringbuffer.h"
-#include 
-#include "i915_drv.h"
 
 static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
 {
@@ -3378,12 +3368,6 @@ static int i915_drrs_status(struct seq_file *m, void 
*unused)
return 0;
 }
 
-struct pipe_crc_info {
-   const char *name;
-   struct drm_i915_private *dev_priv;
-   enum pipe pipe;
-};
-
 static int i915_dp_mst_info(struct seq_file *m, void *unused)
 {
struct drm_i915_private *dev_priv = node_to_i915(m->private);
@@ -3413,848 +3397,6 @@ static int i915_dp_mst_info(struct seq_file *m, void 
*unused)
return 0;
 }
 
-static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   if (info->pipe >= INTEL_INFO(dev_priv)->num_pipes)
-   return -ENODEV;
-
-   spin_lock_irq(&pipe_crc->lock);
-
-   if (pipe_crc->opened) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EBUSY; /* already open */
-   }
-
-   pipe_crc->opened = true;
-   filep->private_data = inode->i_private;
-
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-
-   spin_lock_irq(&pipe_crc->lock);
-   pipe_crc->opened = false;
-   spin_unlock_irq(&pipe_crc->lock);
-
-   return 0;
-}
-
-/* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN  (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN(PIPE_CRC_LINE_LEN + 1)
-
-static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
-{
-   assert_spin_locked(&pipe_crc->lock);
-   return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
-   INTEL_PIPE_CRC_ENTRIES_NR);
-}
-
-static ssize_t
-i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
-  loff_t *pos)
-{
-   struct pipe_crc_info *info = filep->private_data;
-   struct drm_i915_private *dev_priv = info->dev_priv;
-   struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[info->pipe];
-   char buf[PIPE_CRC_BUFFER_LEN];
-   int n_entries;
-   ssize_t bytes_read;
-
-   /*
-* Don't allow user space to provide buffers not big enough to hold
-* a line of data.
-*/
-   if (count < PIPE_CRC_LINE_LEN)
-   return -EINVAL;
-
-   if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
-   return 0;
-
-   /* nothing to read */
-   spin_lock_irq(&pipe_crc->lock);
-   while (pipe_crc_data_count(pipe_crc) == 0) {
-   int ret;
-
-   if (filep->f_flags & O_NONBLOCK) {
-   spin_unlock_irq(&pipe_crc->lock);
-   return -EAGAIN;
-   }
-
-  

[Intel-gfx] [PATCH v8 0/4] New debugfs API for capturing CRC of frames

2016-09-09 Thread Tomeu Vizoso
Hi,

this series basically takes the facility for continuously capturing CRCs
of frames from the i915 driver and into the DRM core.

The idea is that test suites such as IGT use this information to check
that frames that are exected to be identical, also have identical CRC
values.

Other drivers for hardware that can provide frame CRCs (including eDP
panels that support self-refresh) can easily implement the new callback
and provide userspace with the CRC values.

Thanks,

Tomeu

Tomeu Vizoso (4):
  drm/i915/debugfs: Move out pipe CRC code
  drm: Add API for capturing frame CRCs
  drm/i915: Use new CRC debugfs API
  drm/i915: Put "cooked" vlank counters in frame CRC lines

 Documentation/gpu/drm-uapi.rst|6 +
 drivers/gpu/drm/Makefile  |3 +-
 drivers/gpu/drm/drm_crtc.c|   29 +-
 drivers/gpu/drm/drm_debugfs.c |   34 +-
 drivers/gpu/drm/drm_debugfs_crc.c |  351 
 drivers/gpu/drm/drm_drv.c |   19 +
 drivers/gpu/drm/drm_internal.h|   16 +
 drivers/gpu/drm/i915/Makefile |2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   |  886 +---
 drivers/gpu/drm/i915/i915_drv.c   |2 +-
 drivers/gpu/drm/i915/i915_drv.h   |3 +-
 drivers/gpu/drm/i915/i915_irq.c   |   83 ++-
 drivers/gpu/drm/i915/intel_display.c  |1 +
 drivers/gpu/drm/i915/intel_drv.h  |7 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 1014 +
 include/drm/drm_crtc.h|   41 ++
 include/drm/drm_debugfs_crc.h |   73 +++
 17 files changed, 1656 insertions(+), 914 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_debugfs_crc.c
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c
 create mode 100644 include/drm/drm_debugfs_crc.h

-- 
2.7.4

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


  1   2   3   >