Re: [Intel-gfx] [alsa-devel] [PATCH v4 0/3] support DP MST audio

2016-12-06 Thread Takashi Iwai
On Tue, 06 Dec 2016 08:51:43 +0100,
Daniel Vetter wrote:
> 
> On Tue, Dec 6, 2016 at 8:20 AM, Takashi Iwai  wrote:
> > On Tue, 06 Dec 2016 03:58:21 +0100,
> > Yang, Libin wrote:
> >>
> >> The patchset is based on drm-tip branch in
> >> git://anongit.freedesktop.org/drm-tip
> >
> > I'll review and merge if it's OK.
> >
> > Daniel, do you guys have the stable branch that I can pull into sound
> > tree for DP-MST audio stuff for 4.10?
> 
> DP mst audio support missed 4.10 over here on the drm side. And I
> wasn't aware that we need a topic branch for it, so I just smashed it
> into our drm-intel-next queue ... I can send you the most recent
> stable tag for that, but that's heading in only for 4.11.

It's fine, we can postpone to 4.11 as well.  I just thought it were
already queued for 4.10.

If so, I'm going to queue these patches once after 4.10-rc1 is
released.


thanks,

Takashi


> -Daniel
> 
> >
> >
> > thanks,
> >
> > Takashi
> >
> >
> >> Regards,
> >> Libin
> >>
> >>
> >> >-Original Message-
> >> >From: Yang, Libin
> >> >Sent: Tuesday, December 6, 2016 10:49 AM
> >> >To: alsa-de...@alsa-project.org; ti...@suse.de
> >> >Cc: Lin, Mengdong ; Yang, Libin
> >> >
> >> >Subject: [alsa-devel] [PATCH v4 0/3] support DP MST audio
> >> >
> >> >From: Libin Yang 
> >> >
> >> >This patchset starts to support DP MST audio.
> >> >
> >> >This patchset is based on drm-tip on
> >> >git://anongit.freedesktop.org/drm-tip
> >> >
> >> >change log:
> >> >v4: refine some comments in 0001 and 0002 patches.
> >> >refine the 0003 patch for the new ALSA-Configuration document
> >> >
> >> >Libin Yang (3):
> >> >  ALSA: hda - add DP mst verb support
> >> >  ALSA: hda - add DP MST audio support
> >> >  ALSA: Documentation about HDA DP MST pin init and connection
> >> >
> >> > Documentation/sound/hd-audio/dp-mst.rst |  17 +++
> >> > sound/pci/hda/hda_codec.c   |  76 +-
> >> > sound/pci/hda/hda_codec.h   |   3 +
> >> > sound/pci/hda/patch_hdmi.c  | 245 
> >> > +--
> >> >-
> >> > 4 files changed, 285 insertions(+), 56 deletions(-)
> >> >
> >> >--
> >> >2.7.4
> >>
> 
> 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
> 
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v2 11/15] drm/i915: Protect DSPARB registers with a spinlock

2016-12-06 Thread Maarten Lankhorst
Op 05-12-16 om 15:13 schreef ville.syrj...@linux.intel.com:
> From: Ville Syrjälä 
>
> Each DSPARB register can house bits for two separate pipes, hence
> we must protect the registers during reprogramming so that parallel
> FIFO reconfigurations happening simultaneosly on multiple pipes won't
> corrupt each others values.
>
> We'll use a new spinlock for this instead of the wm_mutex since we'll
> have to move the DSPARB programming to happen from the vblank evade
> critical section, and we can't use mutexes in there.
>
> v2: Document why we use a spinlock instead of a mutex (Maarten)
>
> Cc: Maarten Lankhorst 
> Signed-off-by: Ville Syrjälä 
Reviewed-by: Maarten Lankhorst 
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 15/15] drm/i915: Pass crtc state to vlv_compute_wm_level()

2016-12-06 Thread Maarten Lankhorst
Hey,

Op 02-12-16 om 14:07 schreef Ville Syrjälä:
> On Thu, Dec 01, 2016 at 03:47:55PM +0100, Maarten Lankhorst wrote:
>> Op 28-11-16 om 18:37 schreef ville.syrj...@linux.intel.com:
>>> From: Ville Syrjälä 
>>>
>>> Rather than accessing crtc->config in vlv_compute_wm_level() let's
>>> pass in the crtc state explicitly. One step closer to atomic.
>>>
>>> Signed-off-by: Ville Syrjälä 
>> Yay. All users of intel_crtc->config have to die in the future, but this is 
>> temporarily a legit use for it.
> Pardon the stray reply earlier. What I wanted to say was that I was
> playing around with coccinelle a bit the other night, and managed to
> trick it into a little bit of crtc->config killing. I think I'll try
> to expand my efforts there a bit more before posting the stuff though.
>
Don't worry about it, most of them have to be audited to make sure that the 
right crtc_state passed in is used. It shouldn't blindly be used to convert to 
crtc->state.
I did some of the more tricky conversions in my nightly branch. 
https://cgit.freedesktop.org/~mlankhorst/linux/log/?h=nightly
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 1/2] drm/i915: Advertise ppgtt support type in platform definition

2016-12-06 Thread Michał Winiarski
On Mon, Dec 05, 2016 at 05:57:03PM -0800, Michel Thierry wrote:
> Instead of being hidden in sanitize_enable_ppgtt.
> It also seems to be the place to do so nowadays.

Reviewed-by: Michał Winiarski 

-Michał
 
> Signed-off-by: Michel Thierry 
> ---
>  drivers/gpu/drm/i915/i915_drv.h |  3 +++
>  drivers/gpu/drm/i915/i915_gem_gtt.c |  7 +++
>  drivers/gpu/drm/i915/i915_pci.c | 11 +++
>  3 files changed, 17 insertions(+), 4 deletions(-)
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 2/2] drm/i915: Keep has_* in alphabetical order

2016-12-06 Thread Michał Winiarski
On Mon, Dec 05, 2016 at 05:57:04PM -0800, Michel Thierry wrote:
> As it already says in the comment block...

Reviewed-by: Michał Winiarski 

-Michał
 
> Signed-off-by: Michel Thierry 
> ---
>  drivers/gpu/drm/i915/i915_drv.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] dim: Try git-merge --ff-only before git-rebase -i when updating branches.

2016-12-06 Thread Maarten Lankhorst
When a branch can be fast-forwarded, try it first before rebasing.
This will prevent a whole lot of editor windows opening with 'noop'
when running dim ub.

Signed-off-by: Maarten Lankhorst 
---
 dim | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/dim b/dim
index fa63ae8c8a79..b2e6841e23d7 100755
--- a/dim
+++ b/dim
@@ -1286,9 +1286,7 @@ function dim_update_branches
repo=`branch_to_repo $branch`
remote=`repo_to_remote $repo`
 
-   if git diff --quiet $remote/$branch; then
-   $DRY git rebase
-   else
+   if ! $DRY git merge --ff-only ; then
$DRY git rebase -i
fi
done
-- 
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: Shrink pipe config checker

2016-12-06 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Replace INTEL_ERR_OR_DBG_KMS macro with an intel_err_or_dbg_kms
function to shrink the code and rodata strings.

   textdata bss dec hex filename
1271480   418312016 1315327  1411ff i915.ko.0
1265160   418312016 1309007  13f94f i915.ko.2

Total of ~6 KiB saving across text and strings.

v2:
 * Annotate the function for printf-style checking.
 * Rename to pipe_config_err. (Chris Wilson)

Signed-off-by: Tvrtko Ursulin 
Reviewed-by: Chris Wilson  (v1)
---
 drivers/gpu/drm/i915/intel_display.c | 51 
 1 file changed, 34 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index a88c810dbf6b..76323a28f1a4 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13209,6 +13209,31 @@ intel_compare_link_m_n(const struct intel_link_m_n 
*m_n,
return false;
 }
 
+static void __printf(3, 4)
+pipe_config_err(bool adjust, const char *name, const char *format, ...)
+{
+   char *level;
+   unsigned int category;
+   struct va_format vaf;
+   va_list args;
+
+   if (adjust) {
+   level = KERN_DEBUG;
+   category = DRM_UT_KMS;
+   } else {
+   level = KERN_ERR;
+   category = DRM_UT_NONE;
+   }
+
+   va_start(args, format);
+   vaf.fmt = format;
+   vaf.va = &args;
+
+   drm_printk(level, category, "mismatch in %s %pV", name, &vaf);
+
+   va_end(args);
+}
+
 static bool
 intel_pipe_config_compare(struct drm_i915_private *dev_priv,
  struct intel_crtc_state *current_config,
@@ -13217,17 +13242,9 @@ intel_pipe_config_compare(struct drm_i915_private 
*dev_priv,
 {
bool ret = true;
 
-#define INTEL_ERR_OR_DBG_KMS(fmt, ...) \
-   do { \
-   if (!adjust) \
-   DRM_ERROR(fmt, ##__VA_ARGS__); \
-   else \
-   DRM_DEBUG_KMS(fmt, ##__VA_ARGS__); \
-   } while (0)
-
 #define PIPE_CONF_CHECK_X(name)\
if (current_config->name != pipe_config->name) { \
-   INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
+   pipe_config_err(adjust, __stringify(name), \
  "(expected 0x%08x, found 0x%08x)\n", \
  current_config->name, \
  pipe_config->name); \
@@ -13236,7 +13253,7 @@ intel_pipe_config_compare(struct drm_i915_private 
*dev_priv,
 
 #define PIPE_CONF_CHECK_I(name)\
if (current_config->name != pipe_config->name) { \
-   INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
+   pipe_config_err(adjust, __stringify(name), \
  "(expected %i, found %i)\n", \
  current_config->name, \
  pipe_config->name); \
@@ -13245,7 +13262,7 @@ intel_pipe_config_compare(struct drm_i915_private 
*dev_priv,
 
 #define PIPE_CONF_CHECK_P(name)\
if (current_config->name != pipe_config->name) { \
-   INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
+   pipe_config_err(adjust, __stringify(name), \
  "(expected %p, found %p)\n", \
  current_config->name, \
  pipe_config->name); \
@@ -13256,7 +13273,7 @@ intel_pipe_config_compare(struct drm_i915_private 
*dev_priv,
if (!intel_compare_link_m_n(¤t_config->name, \
&pipe_config->name,\
adjust)) { \
-   INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
+   pipe_config_err(adjust, __stringify(name), \
  "(expected tu %i gmch %i/%i link %i/%i, " \
  "found tu %i, gmch %i/%i link %i/%i)\n", \
  current_config->name.tu, \
@@ -13282,7 +13299,7 @@ intel_pipe_config_compare(struct drm_i915_private 
*dev_priv,
&pipe_config->name, adjust) && \
!intel_compare_link_m_n(¤t_config->alt_name, \
&pipe_config->name, adjust)) { \
-   INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
+   pipe_config_err(adjust, __stringify(name), \
  "(expected tu %i gmch %i/%i link %i/%i, " \
  "or tu %i gmch %i/%i link %i/%i, " \
  "found tu %i, gmch %i/%i link %i/%i)\n", \
@@ -13306,8 +13323,9 @@ intel_pipe_config_compare(struct drm_i915_private 
*dev_priv,
 
 #define PIPE_CONF_CHECK_FLAGS(name, mask)  \
if ((current_config->name ^ pipe_config->name) & (mask)) { \
-   INTEL_ERR_OR_DBG_KMS("mismatch in " #name "(" #mask ") " \
- "(expected %i, found %i)\n", \
+   pipe_config_err(adjust, __stringify(name), \
+ "(%x) 

[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Shrink pipe config checker (rev2)

2016-12-06 Thread Patchwork
== Series Details ==

Series: drm/i915: Shrink pipe config checker (rev2)
URL   : https://patchwork.freedesktop.org/series/16359/
State : success

== Summary ==

Series 16359v2 drm/i915: Shrink pipe config checker
https://patchwork.freedesktop.org/api/1.0/series/16359/revisions/2/mbox/

Test drv_module_reload:
Subgroup basic-reload-inject:
dmesg-warn -> PASS   (fi-skl-6770hq)

fi-bdw-5557u total:247  pass:232  dwarn:0   dfail:0   fail:0   skip:15 
fi-bsw-n3050 total:247  pass:207  dwarn:0   dfail:0   fail:0   skip:40 
fi-byt-j1900 total:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-byt-n2820 total:247  pass:215  dwarn:0   dfail:0   fail:0   skip:32 
fi-hsw-4770  total:247  pass:227  dwarn:0   dfail:0   fail:0   skip:20 
fi-hsw-4770r total:247  pass:227  dwarn:0   dfail:0   fail:0   skip:20 
fi-ilk-650   total:247  pass:194  dwarn:0   dfail:0   fail:0   skip:53 
fi-ivb-3520m total:247  pass:225  dwarn:0   dfail:0   fail:0   skip:22 
fi-ivb-3770  total:247  pass:225  dwarn:0   dfail:0   fail:0   skip:22 
fi-kbl-7500u total:247  pass:225  dwarn:0   dfail:0   fail:0   skip:22 
fi-skl-6260u total:247  pass:233  dwarn:0   dfail:0   fail:0   skip:14 
fi-skl-6700hqtotal:247  pass:226  dwarn:0   dfail:0   fail:0   skip:21 
fi-skl-6700k total:247  pass:223  dwarn:3   dfail:0   fail:0   skip:21 
fi-skl-6770hqtotal:247  pass:233  dwarn:0   dfail:0   fail:0   skip:14 
fi-snb-2520m total:247  pass:215  dwarn:0   dfail:0   fail:0   skip:32 
fi-snb-2600  total:247  pass:214  dwarn:0   dfail:0   fail:0   skip:33 

9448ba081ec5f0b9a94d4c4e6206240097ec035e drm-tip: 2016y-12m-06d-09h-23m-53s UTC 
integration manifest
52c3d7b drm/i915: Shrink pipe config checker

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3201/
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] drm: Don't block the kworker waiting for mode_config.lock in output_poll()

2016-12-06 Thread Chris Wilson
If we cannot acquire the mode_config.lock immediately, just back off and
queue a new attempt after the poll interval. This is mostly to stop the
hung task spam when the system is deadlocked, but it will also lessen
the load (in such extreme cases).

Signed-off-by: Chris Wilson 
---
 drivers/gpu/drm/drm_probe_helper.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_probe_helper.c 
b/drivers/gpu/drm/drm_probe_helper.c
index ff9ba6f35248..0bf629354297 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -394,7 +394,11 @@ static void output_poll_execute(struct work_struct *work)
if (!drm_kms_helper_poll)
goto out;
 
-   mutex_lock(&dev->mode_config.mutex);
+   if (!mutex_trylock(&dev->mode_config.mutex)) {
+   repoll = true;
+   goto out;
+   }
+
drm_for_each_connector(connector, dev) {
 
/* Ignore forced connectors. */
-- 
2.11.0

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


Re: [Intel-gfx] [PATCH] drm: Don't block the kworker waiting for mode_config.lock in output_poll()

2016-12-06 Thread Eric Engestrom
On Tuesday, 2016-12-06 11:37:15 +, Chris Wilson wrote:
> If we cannot acquire the mode_config.lock immediately, just back off and

s/mode_config.lock/mode_config.mutex lock/ ?

> queue a new attempt after the poll interval. This is mostly to stop the
> hung task spam when the system is deadlocked, but it will also lessen
> the load (in such extreme cases).
> 
> Signed-off-by: Chris Wilson 

Reviewed-by: Eric Engestrom 

> ---
>  drivers/gpu/drm/drm_probe_helper.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_probe_helper.c 
> b/drivers/gpu/drm/drm_probe_helper.c
> index ff9ba6f35248..0bf629354297 100644
> --- a/drivers/gpu/drm/drm_probe_helper.c
> +++ b/drivers/gpu/drm/drm_probe_helper.c
> @@ -394,7 +394,11 @@ static void output_poll_execute(struct work_struct *work)
>   if (!drm_kms_helper_poll)
>   goto out;
>  
> - mutex_lock(&dev->mode_config.mutex);
> + if (!mutex_trylock(&dev->mode_config.mutex)) {
> + repoll = true;
> + goto out;
> + }
> +
>   drm_for_each_connector(connector, dev) {
>  
>   /* Ignore forced connectors. */
> -- 
> 2.11.0
> 
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] ✓ Fi.CI.BAT: success for drm: Don't block the kworker waiting for mode_config.lock in output_poll()

2016-12-06 Thread Patchwork
== Series Details ==

Series: drm: Don't block the kworker waiting for mode_config.lock in 
output_poll()
URL   : https://patchwork.freedesktop.org/series/16413/
State : success

== Summary ==

Series 16413v1 drm: Don't block the kworker waiting for mode_config.lock in 
output_poll()
https://patchwork.freedesktop.org/api/1.0/series/16413/revisions/1/mbox/

Test drv_module_reload:
Subgroup basic-reload-inject:
dmesg-warn -> PASS   (fi-skl-6770hq)

fi-bdw-5557u total:247  pass:232  dwarn:0   dfail:0   fail:0   skip:15 
fi-bsw-n3050 total:247  pass:207  dwarn:0   dfail:0   fail:0   skip:40 
fi-bxt-t5700 total:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-byt-j1900 total:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-byt-n2820 total:247  pass:215  dwarn:0   dfail:0   fail:0   skip:32 
fi-hsw-4770  total:247  pass:227  dwarn:0   dfail:0   fail:0   skip:20 
fi-hsw-4770r total:247  pass:227  dwarn:0   dfail:0   fail:0   skip:20 
fi-ilk-650   total:247  pass:194  dwarn:0   dfail:0   fail:0   skip:53 
fi-ivb-3520m total:247  pass:225  dwarn:0   dfail:0   fail:0   skip:22 
fi-ivb-3770  total:247  pass:225  dwarn:0   dfail:0   fail:0   skip:22 
fi-kbl-7500u total:247  pass:225  dwarn:0   dfail:0   fail:0   skip:22 
fi-skl-6260u total:247  pass:233  dwarn:0   dfail:0   fail:0   skip:14 
fi-skl-6700hqtotal:247  pass:226  dwarn:0   dfail:0   fail:0   skip:21 
fi-skl-6700k total:247  pass:223  dwarn:3   dfail:0   fail:0   skip:21 
fi-skl-6770hqtotal:247  pass:233  dwarn:0   dfail:0   fail:0   skip:14 
fi-snb-2520m total:247  pass:215  dwarn:0   dfail:0   fail:0   skip:32 
fi-snb-2600  total:247  pass:214  dwarn:0   dfail:0   fail:0   skip:33 

9448ba081ec5f0b9a94d4c4e6206240097ec035e drm-tip: 2016y-12m-06d-09h-23m-53s UTC 
integration manifest
7c9a146 drm: Don't block the kworker waiting for mode_config.lock in 
output_poll()

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3202/
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v2] drm/i915: Use memcpy_from_wc for GPU error capture

2016-12-06 Thread Chris Wilson
On all platforms we now always read the contents of buffers via the GTT,
i.e. using WC cpu access. Reads are slow, but they can be accelerated
with an internal read buffer using sse4.1 (movntqda). This is our
i915_memcpy_from_wc() routine which also checks for sse4.1 support and
so we can fallback to using a regular slow memcpy if we need to.

When compressing the pages, the reads are currently done inside zlib's
fill_window() routine and so we must copy the page into a temporary
which is then already inside the CPU cache and fast for zlib's
compression. When not compressing the pages, we don't need a temporary
and can just use the accelerated read from WC into the destination.

v2: Use zstream locals to reduce diff and allocate the additional
temporary storage if sse4.1 is supported.

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_gpu_error.c | 50 ++-
 1 file changed, 37 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c 
b/drivers/gpu/drm/i915/i915_gpu_error.c
index a14f7badc337..70e2c955afc6 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -176,9 +176,14 @@ static void i915_error_puts(struct 
drm_i915_error_state_buf *e,
 
 #ifdef CONFIG_DRM_I915_COMPRESS_ERROR
 
-static bool compress_init(struct z_stream_s *zstream)
+struct compress {
+   struct z_stream_s zstream;
+   void *tmp;
+};
+
+static bool compress_init(struct compress *c)
 {
-   memset(zstream, 0, sizeof(*zstream));
+   struct z_stream_s *zstream = memset(&c->zstream, 0, sizeof(c->zstream));
 
zstream->workspace =
kmalloc(zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL),
@@ -191,14 +196,22 @@ static bool compress_init(struct z_stream_s *zstream)
return false;
}
 
+   c->tmp = NULL;
+   if (i915_memcpy_from_wc(NULL, 0, PAGE_SIZE))
+   c->tmp = (void *)__get_free_page(GFP_ATOMIC | __GFP_NOWARN);
+
return true;
 }
 
-static int compress_page(struct z_stream_s *zstream,
+static int compress_page(struct compress *c,
 void *src,
 struct drm_i915_error_object *dst)
 {
+   struct z_stream_s *zstream = &c->zstream;
+
zstream->next_in = src;
+   if (c->tmp && i915_memcpy_from_wc(c->tmp, src, PAGE_SIZE))
+   zstream->next_in = c->tmp;
zstream->avail_in = PAGE_SIZE;
 
do {
@@ -226,9 +239,11 @@ static int compress_page(struct z_stream_s *zstream,
return 0;
 }
 
-static void compress_fini(struct z_stream_s *zstream,
+static void compress_fini(struct compress *c,
  struct drm_i915_error_object *dst)
 {
+   struct z_stream_s *zstream = &c->zstream;
+
if (dst) {
zlib_deflate(zstream, Z_FINISH);
dst->unused = zstream->avail_out;
@@ -236,6 +251,9 @@ static void compress_fini(struct z_stream_s *zstream,
 
zlib_deflateEnd(zstream);
kfree(zstream->workspace);
+
+   if (c->tmp)
+   free_page((unsigned long)c->tmp);
 }
 
 static void err_compression_marker(struct drm_i915_error_state_buf *m)
@@ -245,28 +263,34 @@ static void err_compression_marker(struct 
drm_i915_error_state_buf *m)
 
 #else
 
-static bool compress_init(struct z_stream_s *zstream)
+struct compress {
+};
+
+static bool compress_init(struct compress *c)
 {
return true;
 }
 
-static int compress_page(struct z_stream_s *zstream,
+static int compress_page(struct compress *c,
 void *src,
 struct drm_i915_error_object *dst)
 {
unsigned long page;
+   void *ptr;
 
page = __get_free_page(GFP_ATOMIC | __GFP_NOWARN);
if (!page)
return -ENOMEM;
 
-   dst->pages[dst->page_count++] =
-   memcpy((void *)page, src, PAGE_SIZE);
+   ptr = (void *)page;
+   if (!i915_memcpy_from_wc(ptr, src, PAGE_SIZE))
+   memcpy(ptr, src, PAGE_SIZE);
+   dst->pages[dst->page_count++] = ptr;
 
return 0;
 }
 
-static void compress_fini(struct z_stream_s *zstream,
+static void compress_fini(struct compress *c,
  struct drm_i915_error_object *dst)
 {
 }
@@ -784,7 +808,7 @@ i915_error_object_create(struct drm_i915_private *i915,
struct i915_ggtt *ggtt = &i915->ggtt;
const u64 slot = ggtt->error_capture.start;
struct drm_i915_error_object *dst;
-   struct z_stream_s zstream;
+   struct compress compress;
unsigned long num_pages;
struct sgt_iter iter;
dma_addr_t dma;
@@ -804,7 +828,7 @@ i915_error_object_create(struct drm_i915_private *i915,
dst->page_count = 0;
dst->unused = 0;
 
-   if (!compress_init(&zstream)) {
+   if (!compress_init(&compress)) {
kfree(dst);
return NULL;
}
@@ -817,7 +841,7 @@ i915_error_object_cr

Re: [Intel-gfx] [PATCH v2] drm/i915: Use memcpy_from_wc for GPU error capture

2016-12-06 Thread Chris Wilson
On Tue, Dec 06, 2016 at 12:22:03PM +, Chris Wilson wrote:
> On all platforms we now always read the contents of buffers via the GTT,
> i.e. using WC cpu access. Reads are slow, but they can be accelerated
> with an internal read buffer using sse4.1 (movntqda). This is our
> i915_memcpy_from_wc() routine which also checks for sse4.1 support and
> so we can fallback to using a regular slow memcpy if we need to.
> 
> When compressing the pages, the reads are currently done inside zlib's
> fill_window() routine and so we must copy the page into a temporary
> which is then already inside the CPU cache and fast for zlib's
> compression. When not compressing the pages, we don't need a temporary
> and can just use the accelerated read from WC into the destination.
> 
> v2: Use zstream locals to reduce diff and allocate the additional
> temporary storage if sse4.1 is supported.
> 
> Signed-off-by: Chris Wilson 
> Cc: Tvrtko Ursulin 
> ---
>  drivers/gpu/drm/i915/i915_gpu_error.c | 50 
> ++-
>  1 file changed, 37 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c 
> b/drivers/gpu/drm/i915/i915_gpu_error.c
> index a14f7badc337..70e2c955afc6 100644
> --- a/drivers/gpu/drm/i915/i915_gpu_error.c
> +++ b/drivers/gpu/drm/i915/i915_gpu_error.c
> @@ -176,9 +176,14 @@ static void i915_error_puts(struct 
> drm_i915_error_state_buf *e,
>  
>  #ifdef CONFIG_DRM_I915_COMPRESS_ERROR
>  
> -static bool compress_init(struct z_stream_s *zstream)
> +struct compress {
> + struct z_stream_s zstream;
> + void *tmp;
> +};
> +
> +static bool compress_init(struct compress *c)
>  {
> - memset(zstream, 0, sizeof(*zstream));
> + struct z_stream_s *zstream = memset(&c->zstream, 0, sizeof(c->zstream));
>  
>   zstream->workspace =
>   kmalloc(zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL),
> @@ -191,14 +196,22 @@ static bool compress_init(struct z_stream_s *zstream)
>   return false;
>   }
>  
> + c->tmp = NULL;
> + if (i915_memcpy_from_wc(NULL, 0, PAGE_SIZE))

s/PAGE_SIZE/0/ here bah.
-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] [PATCH v3] drm/i915: Use memcpy_from_wc for GPU error capture

2016-12-06 Thread Chris Wilson
On all platforms we now always read the contents of buffers via the GTT,
i.e. using WC cpu access. Reads are slow, but they can be accelerated
with an internal read buffer using sse4.1 (movntqda). This is our
i915_memcpy_from_wc() routine which also checks for sse4.1 support and
so we can fallback to using a regular slow memcpy if we need to.

When compressing the pages, the reads are currently done inside zlib's
fill_window() routine and so we must copy the page into a temporary
which is then already inside the CPU cache and fast for zlib's
compression. When not compressing the pages, we don't need a temporary
and can just use the accelerated read from WC into the destination.

v2: Use zstream locals to reduce diff and allocate the additional
temporary storage only if sse4.1 is supported.
v3: Use length=0 for the sse4.1 support check

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_gpu_error.c | 50 ++-
 1 file changed, 37 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c 
b/drivers/gpu/drm/i915/i915_gpu_error.c
index a14f7badc337..307999b852fd 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -176,9 +176,14 @@ static void i915_error_puts(struct 
drm_i915_error_state_buf *e,
 
 #ifdef CONFIG_DRM_I915_COMPRESS_ERROR
 
-static bool compress_init(struct z_stream_s *zstream)
+struct compress {
+   struct z_stream_s zstream;
+   void *tmp;
+};
+
+static bool compress_init(struct compress *c)
 {
-   memset(zstream, 0, sizeof(*zstream));
+   struct z_stream_s *zstream = memset(&c->zstream, 0, sizeof(c->zstream));
 
zstream->workspace =
kmalloc(zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL),
@@ -191,14 +196,22 @@ static bool compress_init(struct z_stream_s *zstream)
return false;
}
 
+   c->tmp = NULL;
+   if (i915_memcpy_from_wc(NULL, 0, 0))
+   c->tmp = (void *)__get_free_page(GFP_ATOMIC | __GFP_NOWARN);
+
return true;
 }
 
-static int compress_page(struct z_stream_s *zstream,
+static int compress_page(struct compress *c,
 void *src,
 struct drm_i915_error_object *dst)
 {
+   struct z_stream_s *zstream = &c->zstream;
+
zstream->next_in = src;
+   if (c->tmp && i915_memcpy_from_wc(c->tmp, src, PAGE_SIZE))
+   zstream->next_in = c->tmp;
zstream->avail_in = PAGE_SIZE;
 
do {
@@ -226,9 +239,11 @@ static int compress_page(struct z_stream_s *zstream,
return 0;
 }
 
-static void compress_fini(struct z_stream_s *zstream,
+static void compress_fini(struct compress *c,
  struct drm_i915_error_object *dst)
 {
+   struct z_stream_s *zstream = &c->zstream;
+
if (dst) {
zlib_deflate(zstream, Z_FINISH);
dst->unused = zstream->avail_out;
@@ -236,6 +251,9 @@ static void compress_fini(struct z_stream_s *zstream,
 
zlib_deflateEnd(zstream);
kfree(zstream->workspace);
+
+   if (c->tmp)
+   free_page((unsigned long)c->tmp);
 }
 
 static void err_compression_marker(struct drm_i915_error_state_buf *m)
@@ -245,28 +263,34 @@ static void err_compression_marker(struct 
drm_i915_error_state_buf *m)
 
 #else
 
-static bool compress_init(struct z_stream_s *zstream)
+struct compress {
+};
+
+static bool compress_init(struct compress *c)
 {
return true;
 }
 
-static int compress_page(struct z_stream_s *zstream,
+static int compress_page(struct compress *c,
 void *src,
 struct drm_i915_error_object *dst)
 {
unsigned long page;
+   void *ptr;
 
page = __get_free_page(GFP_ATOMIC | __GFP_NOWARN);
if (!page)
return -ENOMEM;
 
-   dst->pages[dst->page_count++] =
-   memcpy((void *)page, src, PAGE_SIZE);
+   ptr = (void *)page;
+   if (!i915_memcpy_from_wc(ptr, src, PAGE_SIZE))
+   memcpy(ptr, src, PAGE_SIZE);
+   dst->pages[dst->page_count++] = ptr;
 
return 0;
 }
 
-static void compress_fini(struct z_stream_s *zstream,
+static void compress_fini(struct compress *c,
  struct drm_i915_error_object *dst)
 {
 }
@@ -784,7 +808,7 @@ i915_error_object_create(struct drm_i915_private *i915,
struct i915_ggtt *ggtt = &i915->ggtt;
const u64 slot = ggtt->error_capture.start;
struct drm_i915_error_object *dst;
-   struct z_stream_s zstream;
+   struct compress compress;
unsigned long num_pages;
struct sgt_iter iter;
dma_addr_t dma;
@@ -804,7 +828,7 @@ i915_error_object_create(struct drm_i915_private *i915,
dst->page_count = 0;
dst->unused = 0;
 
-   if (!compress_init(&zstream)) {
+   if (!compress_init(&compress)) {
kfree(dst);
return NULL;
   

Re: [Intel-gfx] [PATCH] drm: Don't block the kworker waiting for mode_config.lock in output_poll()

2016-12-06 Thread Daniel Vetter
On Tue, Dec 06, 2016 at 11:55:14AM +, Eric Engestrom wrote:
> On Tuesday, 2016-12-06 11:37:15 +, Chris Wilson wrote:
> > If we cannot acquire the mode_config.lock immediately, just back off and
> 
> s/mode_config.lock/mode_config.mutex lock/ ?

Fixed
> 
> > queue a new attempt after the poll interval. This is mostly to stop the
> > hung task spam when the system is deadlocked, but it will also lessen
> > the load (in such extreme cases).
> > 
> > Signed-off-by: Chris Wilson 
> 
> Reviewed-by: Eric Engestrom 

... and applied, thanks.
-Daniel

> 
> > ---
> >  drivers/gpu/drm/drm_probe_helper.c | 6 +-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_probe_helper.c 
> > b/drivers/gpu/drm/drm_probe_helper.c
> > index ff9ba6f35248..0bf629354297 100644
> > --- a/drivers/gpu/drm/drm_probe_helper.c
> > +++ b/drivers/gpu/drm/drm_probe_helper.c
> > @@ -394,7 +394,11 @@ static void output_poll_execute(struct work_struct 
> > *work)
> > if (!drm_kms_helper_poll)
> > goto out;
> >  
> > -   mutex_lock(&dev->mode_config.mutex);
> > +   if (!mutex_trylock(&dev->mode_config.mutex)) {
> > +   repoll = true;
> > +   goto out;
> > +   }
> > +
> > drm_for_each_connector(connector, dev) {
> >  
> > /* Ignore forced connectors. */
> > -- 
> > 2.11.0
> > 
> ___
> 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
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: Use memcpy_from_wc for GPU error capture (rev2)

2016-12-06 Thread Patchwork
== Series Details ==

Series: drm/i915: Use memcpy_from_wc for GPU error capture (rev2)
URL   : https://patchwork.freedesktop.org/series/16323/
State : failure

== Summary ==

Series 16323v2 drm/i915: Use memcpy_from_wc for GPU error capture
https://patchwork.freedesktop.org/api/1.0/series/16323/revisions/2/mbox/

Test drv_hangman:
Subgroup error-state-basic:
pass   -> INCOMPLETE (fi-snb-2520m)
pass   -> INCOMPLETE (fi-skl-6770hq)
pass   -> INCOMPLETE (fi-ilk-650)
pass   -> INCOMPLETE (fi-skl-6700k)
pass   -> INCOMPLETE (fi-ivb-3520m)
pass   -> INCOMPLETE (fi-ivb-3770)
pass   -> INCOMPLETE (fi-hsw-4770)
pass   -> INCOMPLETE (fi-kbl-7500u)
pass   -> INCOMPLETE (fi-byt-n2820)
pass   -> INCOMPLETE (fi-hsw-4770r)
pass   -> INCOMPLETE (fi-skl-6260u)
pass   -> INCOMPLETE (fi-snb-2600)
pass   -> INCOMPLETE (fi-bdw-5557u)
pass   -> INCOMPLETE (fi-byt-j1900)
pass   -> INCOMPLETE (fi-skl-6700hq)

fi-bdw-5557u total:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-byt-j1900 total:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-byt-n2820 total:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-hsw-4770  total:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-hsw-4770r total:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-ilk-650   total:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-ivb-3520m total:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-ivb-3770  total:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-kbl-7500u total:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-skl-6260u total:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-skl-6700hqtotal:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-skl-6700k total:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-skl-6770hqtotal:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-snb-2520m total:5pass:4dwarn:0   dfail:0   fail:0   skip:0  
fi-snb-2600  total:5pass:4dwarn:0   dfail:0   fail:0   skip:0  

9448ba081ec5f0b9a94d4c4e6206240097ec035e drm-tip: 2016y-12m-06d-09h-23m-53s UTC 
integration manifest
bdc2b72 drm/i915: Use memcpy_from_wc for GPU error capture

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3203/
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v3] drm/i915: Use memcpy_from_wc for GPU error capture

2016-12-06 Thread Tvrtko Ursulin


On 06/12/2016 12:40, Chris Wilson wrote:

On all platforms we now always read the contents of buffers via the GTT,
i.e. using WC cpu access. Reads are slow, but they can be accelerated
with an internal read buffer using sse4.1 (movntqda). This is our
i915_memcpy_from_wc() routine which also checks for sse4.1 support and
so we can fallback to using a regular slow memcpy if we need to.

When compressing the pages, the reads are currently done inside zlib's
fill_window() routine and so we must copy the page into a temporary
which is then already inside the CPU cache and fast for zlib's
compression. When not compressing the pages, we don't need a temporary
and can just use the accelerated read from WC into the destination.

v2: Use zstream locals to reduce diff and allocate the additional
temporary storage only if sse4.1 is supported.
v3: Use length=0 for the sse4.1 support check

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_gpu_error.c | 50 ++-
 1 file changed, 37 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c 
b/drivers/gpu/drm/i915/i915_gpu_error.c
index a14f7badc337..307999b852fd 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -176,9 +176,14 @@ static void i915_error_puts(struct 
drm_i915_error_state_buf *e,

 #ifdef CONFIG_DRM_I915_COMPRESS_ERROR

-static bool compress_init(struct z_stream_s *zstream)
+struct compress {
+   struct z_stream_s zstream;
+   void *tmp;
+};
+
+static bool compress_init(struct compress *c)
 {
-   memset(zstream, 0, sizeof(*zstream));
+   struct z_stream_s *zstream = memset(&c->zstream, 0, sizeof(c->zstream));

zstream->workspace =
kmalloc(zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL),
@@ -191,14 +196,22 @@ static bool compress_init(struct z_stream_s *zstream)
return false;
}

+   c->tmp = NULL;
+   if (i915_memcpy_from_wc(NULL, 0, 0))
+   c->tmp = (void *)__get_free_page(GFP_ATOMIC | __GFP_NOWARN);
+
return true;
 }

-static int compress_page(struct z_stream_s *zstream,
+static int compress_page(struct compress *c,
 void *src,
 struct drm_i915_error_object *dst)
 {
+   struct z_stream_s *zstream = &c->zstream;
+
zstream->next_in = src;
+   if (c->tmp && i915_memcpy_from_wc(c->tmp, src, PAGE_SIZE))
+   zstream->next_in = c->tmp;
zstream->avail_in = PAGE_SIZE;

do {
@@ -226,9 +239,11 @@ static int compress_page(struct z_stream_s *zstream,
return 0;
 }

-static void compress_fini(struct z_stream_s *zstream,
+static void compress_fini(struct compress *c,
  struct drm_i915_error_object *dst)
 {
+   struct z_stream_s *zstream = &c->zstream;
+
if (dst) {
zlib_deflate(zstream, Z_FINISH);
dst->unused = zstream->avail_out;
@@ -236,6 +251,9 @@ static void compress_fini(struct z_stream_s *zstream,

zlib_deflateEnd(zstream);
kfree(zstream->workspace);
+
+   if (c->tmp)
+   free_page((unsigned long)c->tmp);
 }

 static void err_compression_marker(struct drm_i915_error_state_buf *m)
@@ -245,28 +263,34 @@ static void err_compression_marker(struct 
drm_i915_error_state_buf *m)

 #else

-static bool compress_init(struct z_stream_s *zstream)
+struct compress {
+};
+
+static bool compress_init(struct compress *c)
 {
return true;
 }

-static int compress_page(struct z_stream_s *zstream,
+static int compress_page(struct compress *c,
 void *src,
 struct drm_i915_error_object *dst)
 {
unsigned long page;
+   void *ptr;

page = __get_free_page(GFP_ATOMIC | __GFP_NOWARN);
if (!page)
return -ENOMEM;

-   dst->pages[dst->page_count++] =
-   memcpy((void *)page, src, PAGE_SIZE);
+   ptr = (void *)page;
+   if (!i915_memcpy_from_wc(ptr, src, PAGE_SIZE))
+   memcpy(ptr, src, PAGE_SIZE);
+   dst->pages[dst->page_count++] = ptr;

return 0;
 }

-static void compress_fini(struct z_stream_s *zstream,
+static void compress_fini(struct compress *c,
  struct drm_i915_error_object *dst)
 {
 }
@@ -784,7 +808,7 @@ i915_error_object_create(struct drm_i915_private *i915,
struct i915_ggtt *ggtt = &i915->ggtt;
const u64 slot = ggtt->error_capture.start;
struct drm_i915_error_object *dst;
-   struct z_stream_s zstream;
+   struct compress compress;
unsigned long num_pages;
struct sgt_iter iter;
dma_addr_t dma;
@@ -804,7 +828,7 @@ i915_error_object_create(struct drm_i915_private *i915,
dst->page_count = 0;
dst->unused = 0;

-   if (!compress_init(&zstream)) {
+   if (!compress_init(&compress)) {
kfree(dst);
 

[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Use memcpy_from_wc for GPU error capture (rev3)

2016-12-06 Thread Patchwork
== Series Details ==

Series: drm/i915: Use memcpy_from_wc for GPU error capture (rev3)
URL   : https://patchwork.freedesktop.org/series/16323/
State : success

== Summary ==

Series 16323v3 drm/i915: Use memcpy_from_wc for GPU error capture
https://patchwork.freedesktop.org/api/1.0/series/16323/revisions/3/mbox/


fi-bdw-5557u total:247  pass:218  dwarn:0   dfail:0   fail:0   skip:29 
fi-bsw-n3050 total:247  pass:194  dwarn:0   dfail:0   fail:0   skip:53 
fi-bxt-t5700 total:247  pass:205  dwarn:0   dfail:0   fail:0   skip:42 
fi-byt-j1900 total:247  pass:205  dwarn:0   dfail:0   fail:0   skip:42 
fi-byt-n2820 total:247  pass:201  dwarn:0   dfail:0   fail:0   skip:46 
fi-hsw-4770  total:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-hsw-4770r total:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-ilk-650   total:247  pass:180  dwarn:0   dfail:0   fail:0   skip:67 
fi-ivb-3520m total:247  pass:212  dwarn:0   dfail:0   fail:0   skip:35 
fi-ivb-3770  total:247  pass:211  dwarn:0   dfail:0   fail:0   skip:36 
fi-kbl-7500u total:247  pass:211  dwarn:0   dfail:0   fail:0   skip:36 
fi-skl-6260u total:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-skl-6700hqtotal:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-skl-6700k total:247  pass:209  dwarn:3   dfail:0   fail:0   skip:35 
fi-skl-6770hqtotal:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-snb-2520m total:247  pass:201  dwarn:0   dfail:0   fail:0   skip:46 
fi-snb-2600  total:247  pass:200  dwarn:0   dfail:0   fail:0   skip:47 

586bf1e1e2119aecc56b4ac72efe74068657fb73 drm-tip: 2016y-12m-06d-12h-29m-51s UTC 
integration manifest
d4ed2fe drm/i915: Use memcpy_from_wc for GPU error capture

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3204/
___
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) * 8) +
+   (x & 7);
+}
+
+static void render_ccs(data_t *data, uint32_t gem_handle,
+  uint32_t offset, uint32_t size,
+ 

Re: [Intel-gfx] [Mesa-dev] [PATCH 00/27] Renderbuffer Decompression (and GBM modifiers)

2016-12-06 Thread Paulo Zanoni
2016-12-01 20:09 GMT-02:00 Ben Widawsky :
> From: Ben Widawsky 
>
> This patch series ultimately adds support within the i965 driver for
> Renderbuffer Decompression with GBM. In short, this feature reduces memory
> bandwidth by allowing the GPU to work with losslessly compressed data and 
> having
> that compression scheme understood by the display engine for decompression. 
> The
> display engine will decompress on the fly and scanout the image.
>
> Quoting from the final patch, the bandwidth savings on a SKL GT4 with a 19x10
> display running kmscube:
>
> Without compression:
> Read bandwidth: 603.91 MiB/s
> Write bandwidth: 615.28 MiB/s
>
> With compression:
> Read bandwidth: 259.34 MiB/s
> Write bandwidth: 337.83 MiB/s
>
>
> The hardware achieves this savings by maintaining an auxiliary buffer
> containing "opaque" compression information. It's opaque in the sense that the
> low level compression scheme is not needed, but, knowledge of the overall
> layout of the compressed data is required. The auxiliary buffer is created by
> the driver on behalf of the client when requested. That buffer needs to be
> passed along wherever the main image's buffer goes.
>
> The overall strategy is that the buffer/surface is created with a list of
> modifiers. The list of modifiers the hardware is capable of using will come 
> from
> a new kernel API that is aware of the hardware and general constraints. A 
> client
> will request the list of modifiers and pass it directly back in during buffer
> creation (potentially the client can prune the list, but as of now there is no
> reason to.) This new API is being developed by Kristian. I did not get far
> enough to play with that.
>
> For EGL, a similar mechanism would exist whereby when importing a buffer into
> EGL, one would provide a modifier and probably a pointer to the auxiliary data
> upon import. (Import therefore might require multiple dma-buf fds), but for 
> i965
> and Intel, this wouldn't be necessary.
>
> Here is a brief description of the series:
> 1-6 Adds support in GBM for per plane functions where necessary. This is
> required because the kernel expects the auxiliary buffer to be passed along 
> as a
> plane. It has its own offset, and stride, and the client shouldn't need to
> calculate those.
>
> 7-9 Adds support in GBM to understand modifiers. When creating a buffer or
> surface, the client is expected to pass in a list of modifiers that the driver
> will optimally choose from. As a result of this, the GBM APIs need to support
> modifiers.
>
> 10-12 Support Y-tiled modifier. Y-tiling was already a modifier exposed by the
> kernel. With the previous patches in place, it's easy to support this too.
>
> 13-26 Plumbing to support sending CCS buffers to display. Leveraging much of 
> the
> existing code for MCS buffers, these patches creating an MCS for the scanout
> buffer. The trickery here is that a single BO contains both the main surface 
> and
> the auxiliary data. Previously, auxiliary data always lived in its own BO.
>
> 27 Support CCS-modifier. Finally, the code can parse the CCS fb modifier(s) 
> and
> realize the bandwidth savings that come with it.
>
> This was tested using kmscube
> (https://github.com/bwidawsk/kmscube/tree/modifiers). The kmscube 
> implementation
> is missing support for GET_PLANE2 - which is currently being worked on by
> Kristian.
>
> Upstream plan:

First of all, I'd like to point that I haven't really been following
this feature closely, so maybe my questions are irrelevant to this
series. But still, I feel I have to poitn these things since maybe
they are relevant. Please tell me if I'm not talking about the same
thing as you are.

The main question is: where's the matching i915.ko series? Shouldn't
that be step 0 in your upstream plan?

I do recall seeing BSpec text containing "do this thing if render
decompression is enabled" and, at that time, our code wasn't
implementing those instructions. AFAIU, the Kernel didn't really had
support for render decompression, so its specific bits were just
ignored. I was assuming that whoever implemented the feature would add
all the necessary bits, especially since we didn't seem to have any
sort of "if (has_render_decompression(dev_priv))" to call. I am 100%
sure there's such an example in the Gen 9 Watermarks instructions, but
I'm sure I saw more somewhere else (Display WA page?). And reember:
missing watermarks workarounds equals flickering screens.

Is this relevant to your series? How will Mesa be able to detect that
the Kernel it's running on contains the necessary Render Decompression
checks/WAs/code it needs? How can the Kernel detect that Render
Decompression is in use and start doing the things it should do?

Thanks,
Paulo


> 1. All of the patches up through 26 should be mergeable today after review.
> 2. After 1-12 land, client support of Y-tiling should be achievable. 
> Modesetting
> driver can probably be updated as can things like Weston. Clients as

Re: [Intel-gfx] [PATCH 1/4] drm: Add a new connector atomic property for link status

2016-12-06 Thread Manasi Navare
On Tue, Dec 06, 2016 at 08:23:05AM +0100, Daniel Vetter wrote:
> On Mon, Dec 05, 2016 at 04:27:35PM -0800, Manasi Navare wrote:
> > At the time userspace does setcrtc, we've already promised the mode
> > would work. The promise is based on the theoretical capabilities of
> > the link, but it's possible we can't reach this in practice. The DP
> > spec describes how the link should be reduced, but we can't reduce
> > the link below the requirements of the mode. Black screen follows.
> > 
> > One idea would be to have setcrtc return a failure. However, it
> > already should not fail as the atomic checks have passed. It would
> > also conflict with the idea of making setcrtc asynchronous in the
> > future, returning before the actual mode setting and link training.
> > 
> > Another idea is to train the link "upfront" at hotplug time, before
> > pruning the mode list, so that we can do the pruning based on
> > practical not theoretical capabilities. However, the changes for link
> > training are pretty drastic, all for the sake of error handling and
> > DP compliance, when the most common happy day scenario is the current
> > approach of link training at mode setting time, using the optimal
> > parameters for the mode. It is also not certain all hardware could do
> > this without the pipe on; not even all our hardware can do this. Some
> > of this can be solved, but not trivially.
> > 
> > Both of the above ideas also fail to address link degradation *during*
> > operation.
> > 
> > The solution is to add a new "link-status" connector property in order
> > to address link training failure in a way that:
> > a) changes the current happy day scenario as little as possible, to
> > avoid regressions, b) can be implemented the same way by all drm
> > drivers, c) is still opt-in for the drivers and userspace, and opting
> > out doesn't regress the user experience, d) doesn't prevent drivers
> > from implementing better or alternate approaches, possibly without
> > userspace involvement. And, of course, handles all the issues presented.
> > In the usual happy day scenario, this is always "good". If something
> > fails during or after a mode set, the kernel driver can set the link
> > status to "bad" and issue a hotplug uevent for userspace to have it
> > re-check the valid modes through GET_CONNECTOR IOCTL, and try modeset
> > again. If the theoretical capabilities of the link can't be reached,
> > the mode list is trimmed based on that.
> > 
> > v4:
> > * Add comments in kernel-doc format (Daniel Vetter)
> > * Update the kernel-doc for link-status (Sean Paul)
> > v3:
> > * Fixed a build error (Jani Saarinen)
> > v2:
> > * Removed connector->link_status (Daniel Vetter)
> > * Set connector->state->link_status in 
> > drm_mode_connector_set_link_status_property
> > (Daniel Vetter)
> > * Set the connector_changed flag to true if connector->state->link_status 
> > changed.
> > * Reset link_status to GOOD in update_output_state (Daniel Vetter)
> > * Never allow userspace to set link status from Good To Bad (Daniel Vetter)
> > 
> > Acked-by: Tony Cheng 
> > Acked-by: Harry Wentland 
> > Cc: Jani Nikula 
> > Cc: Daniel Vetter 
> > Cc: Ville Syrjala 
> > Cc: Chris Wilson 
> > Cc: Sean Paul 
> 
> Didn't Sean r-b this already?
> 
> > Signed-off-by: Manasi Navare 
> 
> Looks all nice and tidy, great work.
> 
> Reviewed-by: Daniel Vetter 
> 
> Can be merged as soon as we have an ack from Martin that the -modesetting
> side is ready to go too.
> -Daniel
>

Thanks Daniel. 
And yes I missed Sean Paul's r-b. I will add yours and his r-b and resubmit
the patch.

Manasi

 
> > ---
> >  drivers/gpu/drm/drm_atomic.c| 10 +++
> >  drivers/gpu/drm/drm_atomic_helper.c | 15 +++
> >  drivers/gpu/drm/drm_connector.c | 53 
> > +
> >  include/drm/drm_connector.h | 19 +
> >  include/drm/drm_mode_config.h   |  5 
> >  include/uapi/drm/drm_mode.h |  4 +++
> >  6 files changed, 106 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > index 19d7bcb..70a5152 100644
> > --- a/drivers/gpu/drm/drm_atomic.c
> > +++ b/drivers/gpu/drm/drm_atomic.c
> > @@ -1087,6 +1087,14 @@ int drm_atomic_connector_set_property(struct 
> > drm_connector *connector,
> >  * now?) atomic writes to DPMS property:
> >  */
> > return -EINVAL;
> > +   } else if (property == config->link_status_property) {
> > +   /* Never downgrade from GOOD to BAD on userspace's request here,
> > +* only hw issues can do that.
> > +*/
> > +   if (state->link_status == DRM_LINK_STATUS_GOOD)
> > +   return 0;
> > +   state->link_status = val;
> > +   return 0;
> > } else if (connector->funcs->atomic_set_property) {
> > return connector->funcs->atomic_set_property(connector,
> > state, property, val);
> > @@ -1

[Intel-gfx] [PATCH v4 1/4] drm: Add a new connector atomic property for link status

2016-12-06 Thread Manasi Navare
At the time userspace does setcrtc, we've already promised the mode
would work. The promise is based on the theoretical capabilities of
the link, but it's possible we can't reach this in practice. The DP
spec describes how the link should be reduced, but we can't reduce
the link below the requirements of the mode. Black screen follows.

One idea would be to have setcrtc return a failure. However, it
already should not fail as the atomic checks have passed. It would
also conflict with the idea of making setcrtc asynchronous in the
future, returning before the actual mode setting and link training.

Another idea is to train the link "upfront" at hotplug time, before
pruning the mode list, so that we can do the pruning based on
practical not theoretical capabilities. However, the changes for link
training are pretty drastic, all for the sake of error handling and
DP compliance, when the most common happy day scenario is the current
approach of link training at mode setting time, using the optimal
parameters for the mode. It is also not certain all hardware could do
this without the pipe on; not even all our hardware can do this. Some
of this can be solved, but not trivially.

Both of the above ideas also fail to address link degradation *during*
operation.

The solution is to add a new "link-status" connector property in order
to address link training failure in a way that:
a) changes the current happy day scenario as little as possible, to
avoid regressions, b) can be implemented the same way by all drm
drivers, c) is still opt-in for the drivers and userspace, and opting
out doesn't regress the user experience, d) doesn't prevent drivers
from implementing better or alternate approaches, possibly without
userspace involvement. And, of course, handles all the issues presented.
In the usual happy day scenario, this is always "good". If something
fails during or after a mode set, the kernel driver can set the link
status to "bad" and issue a hotplug uevent for userspace to have it
re-check the valid modes through GET_CONNECTOR IOCTL, and try modeset
again. If the theoretical capabilities of the link can't be reached,
the mode list is trimmed based on that.

v4:
* Add comments in kernel-doc format (Daniel Vetter)
* Update the kernel-doc for link-status (Sean Paul)
v3:
* Fixed a build error (Jani Saarinen)
v2:
* Removed connector->link_status (Daniel Vetter)
* Set connector->state->link_status in 
drm_mode_connector_set_link_status_property
(Daniel Vetter)
* Set the connector_changed flag to true if connector->state->link_status 
changed.
* Reset link_status to GOOD in update_output_state (Daniel Vetter)
* Never allow userspace to set link status from Good To Bad (Daniel Vetter)

Reviewed-by: Sean Paul 
Reviewed-by: Daniel Vetter  
Acked-by: Tony Cheng 
Acked-by: Harry Wentland 
Cc: Jani Nikula 
Cc: Daniel Vetter 
Cc: Ville Syrjala 
Cc: Chris Wilson 
Cc: Sean Paul 
Signed-off-by: Manasi Navare 
---
 drivers/gpu/drm/drm_atomic.c| 10 +++
 drivers/gpu/drm/drm_atomic_helper.c | 15 +++
 drivers/gpu/drm/drm_connector.c | 53 +
 include/drm/drm_connector.h | 19 +
 include/drm/drm_mode_config.h   |  5 
 include/uapi/drm/drm_mode.h |  4 +++
 6 files changed, 106 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 19d7bcb..70a5152 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1087,6 +1087,14 @@ int drm_atomic_connector_set_property(struct 
drm_connector *connector,
 * now?) atomic writes to DPMS property:
 */
return -EINVAL;
+   } else if (property == config->link_status_property) {
+   /* Never downgrade from GOOD to BAD on userspace's request here,
+* only hw issues can do that.
+*/
+   if (state->link_status == DRM_LINK_STATUS_GOOD)
+   return 0;
+   state->link_status = val;
+   return 0;
} else if (connector->funcs->atomic_set_property) {
return connector->funcs->atomic_set_property(connector,
state, property, val);
@@ -1135,6 +1143,8 @@ static void drm_atomic_connector_print_state(struct 
drm_printer *p,
*val = (state->crtc) ? state->crtc->base.id : 0;
} else if (property == config->dpms_property) {
*val = connector->dpms;
+   } else if (property == config->link_status_property) {
+   *val = state->link_status;
} else if (connector->funcs->atomic_get_property) {
return connector->funcs->atomic_get_property(connector,
state, property, val);
diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 494680c..3d6c1ce 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helpe

[Intel-gfx] ✗ Fi.CI.BAT: failure for Link Training failure handling by sending Hotplug Uevent (rev2)

2016-12-06 Thread Patchwork
== Series Details ==

Series: Link Training failure handling by sending Hotplug Uevent (rev2)
URL   : https://patchwork.freedesktop.org/series/16399/
State : failure

== Summary ==

Series 16399v2 Link Training failure handling by sending Hotplug Uevent
https://patchwork.freedesktop.org/api/1.0/series/16399/revisions/2/mbox/

Test drv_module_reload:
Subgroup basic-reload:
pass   -> DMESG-WARN (fi-ilk-650)
Subgroup basic-reload-inject:
pass   -> INCOMPLETE (fi-ilk-650)
dmesg-warn -> INCOMPLETE (fi-skl-6700k)
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-c:
dmesg-warn -> PASS   (fi-skl-6770hq)

fi-bdw-5557u total:247  pass:218  dwarn:0   dfail:0   fail:0   skip:29 
fi-bsw-n3050 total:247  pass:194  dwarn:0   dfail:0   fail:0   skip:53 
fi-bxt-t5700 total:247  pass:205  dwarn:0   dfail:0   fail:0   skip:42 
fi-byt-j1900 total:247  pass:205  dwarn:0   dfail:0   fail:0   skip:42 
fi-byt-n2820 total:247  pass:201  dwarn:0   dfail:0   fail:0   skip:46 
fi-hsw-4770  total:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-hsw-4770r total:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-ilk-650   total:7pass:5dwarn:1   dfail:0   fail:0   skip:0  
fi-ivb-3520m total:247  pass:212  dwarn:0   dfail:0   fail:0   skip:35 
fi-ivb-3770  total:247  pass:211  dwarn:0   dfail:0   fail:0   skip:36 
fi-kbl-7500u total:247  pass:211  dwarn:0   dfail:0   fail:0   skip:36 
fi-skl-6260u total:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-skl-6700hqtotal:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-skl-6700k total:7pass:5dwarn:1   dfail:0   fail:0   skip:0  
fi-skl-6770hqtotal:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-snb-2520m total:247  pass:201  dwarn:0   dfail:0   fail:0   skip:46 
fi-snb-2600  total:247  pass:200  dwarn:0   dfail:0   fail:0   skip:47 

1bc5ec1e0d7c411ccd38404de5b7b328620c82e4 drm-tip: 2016y-12m-06d-15h-09m-40s UTC 
integration manifest
2f13b5b drm/i915: Implement Link Rate fallback on Link training failure
cfa32e0 drm/i915: Find fallback link rate/lane count
0146bd4 drm/i915: Compute sink's max lane count/link BW at Hotplug
e6ed8c6 drm: Add a new connector atomic property for link status

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3205/
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] drm/i915: Tidy load failure reporting

2016-12-06 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Several changes here:

 * Remove unused i915_report_error.
 * Unexport __i915_printk and rename it to i915_load_error,
   converting the latter from a macro to a static function.
 * Use drm_dev_printk instead of open-coding the same.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_drv.c | 45 +++--
 drivers/gpu/drm/i915/i915_drv.h |  7 ---
 2 files changed, 21 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index ae583c79c19f..78b2d03bf808 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -68,52 +68,49 @@ bool __i915_inject_load_failure(const char *func, int line)
return false;
 }
 
+static bool i915_error_injected(struct drm_i915_private *dev_priv)
+{
+   return i915.inject_load_failure &&
+  i915_load_fail_count == i915.inject_load_failure;
+}
+
 #define FDO_BUG_URL "https://bugs.freedesktop.org/enter_bug.cgi?product=DRI";
 #define FDO_BUG_MSG "Please file a bug at " FDO_BUG_URL " against DRM/Intel " \
"providing the dmesg log by booting with drm.debug=0xf"
 
-void
-__i915_printk(struct drm_i915_private *dev_priv, const char *level,
- const char *fmt, ...)
+static void __printf(2, 3)
+i915_load_error(struct drm_i915_private *dev_priv, const char *fmt, ...)
 {
-   static bool shown_bug_once;
+   static bool shown_bug_once __read_mostly;
struct device *kdev = dev_priv->drm.dev;
-   bool is_error = level[1] <= KERN_ERR[1];
-   bool is_debug = level[1] == KERN_DEBUG[1];
+   char *level;
+   bool is_error;
struct va_format vaf;
va_list args;
 
-   if (is_debug && !(drm_debug & DRM_UT_DRIVER))
-   return;
+   if (i915_error_injected(dev_priv)) {
+   is_error = true;
+   level = KERN_ERR;
+   } else {
+   is_error = false;
+   level = KERN_DEBUG;
+   };
 
va_start(args, fmt);
 
vaf.fmt = fmt;
vaf.va = &args;
 
-   dev_printk(level, kdev, "[" DRM_NAME ":%ps] %pV",
-  __builtin_return_address(0), &vaf);
+   drm_dev_printk(kdev, level, DRM_UT_DRIVER, __func__, "", fmt, &vaf);
+
+   va_end(args);
 
if (is_error && !shown_bug_once) {
dev_notice(kdev, "%s", FDO_BUG_MSG);
shown_bug_once = true;
}
-
-   va_end(args);
-}
-
-static bool i915_error_injected(struct drm_i915_private *dev_priv)
-{
-   return i915.inject_load_failure &&
-  i915_load_fail_count == i915.inject_load_failure;
 }
 
-#define i915_load_error(dev_priv, fmt, ...) \
-   __i915_printk(dev_priv,  \
- i915_error_injected(dev_priv) ? KERN_DEBUG : KERN_ERR, \
- fmt, ##__VA_ARGS__)
-
-
 static enum intel_pch intel_virt_detect_pch(struct drm_i915_private *dev_priv)
 {
enum intel_pch ret = PCH_NOP;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 605247baa7d1..f523cdfa8636 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2766,13 +2766,6 @@ int intel_sanitize_enable_ppgtt(struct drm_i915_private 
*dev_priv,
 bool intel_sanitize_semaphores(struct drm_i915_private *dev_priv, int value);
 
 /* i915_drv.c */
-void __printf(3, 4)
-__i915_printk(struct drm_i915_private *dev_priv, const char *level,
- const char *fmt, ...);
-
-#define i915_report_error(dev_priv, fmt, ...) \
-   __i915_printk(dev_priv, KERN_ERR, fmt, ##__VA_ARGS__)
-
 #ifdef CONFIG_COMPAT
 extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
  unsigned long arg);
-- 
2.7.4

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


Re: [Intel-gfx] [PATCH] drm/i915/guc: Drop comment on fwif autogeneration

2016-12-06 Thread Srivatsa, Anusha


>-Original Message-
>From: Hiler, Arkadiusz
>Sent: Monday, December 5, 2016 9:37 PM
>To: Srivatsa, Anusha 
>Cc: intel-gfx@lists.freedesktop.org; Mcgee, Jeff ;
>Kamble, Sagar A 
>Subject: Re: [PATCH] drm/i915/guc: Drop comment on fwif autogeneration
>
>On Tue, Dec 06, 2016 at 12:59:03AM +0100, Srivatsa, Anusha wrote:
>> >-Original Message-
>> >From: Hiler, Arkadiusz
>> >Sent: Monday, December 5, 2016 8:04 AM
>> >To: intel-gfx@lists.freedesktop.org
>> >Cc: Srivatsa, Anusha ; Mcgee, Jeff
>> >; Kamble, Sagar A 
>> >Subject: [PATCH] drm/i915/guc: Drop comment on fwif autogeneration
>> >
>> >The firmware interface file was initially partially autogenerated,
>> >but this is no longer the case.
>> >
>> >It was never updated automatically, and a lot manual changes were
>> >introduced since.
>> >
>> >From now on any changes to the firmware interface will be managed by
>> >hand, which gives us flexibility when it comes to structure reuse
>> >(HuC/GuC) and naming conventions.
>> >
>> >Cc: Anusha Srivatsa 
>> >Cc: Jeff Mcgee 
>> >Cc: Sagar A. Kamble 
>> >Signed-off-by: Arkadiusz Hiler 
>> >---
>> > drivers/gpu/drm/i915/intel_guc_fwif.h | 9 -
>> > 1 file changed, 9 deletions(-)
>> >
>> >diff --git a/drivers/gpu/drm/i915/intel_guc_fwif.h
>> >b/drivers/gpu/drm/i915/intel_guc_fwif.h
>> >index 00ca0df..3202b32 100644
>> >--- a/drivers/gpu/drm/i915/intel_guc_fwif.h
>> >+++ b/drivers/gpu/drm/i915/intel_guc_fwif.h
>> >@@ -23,15 +23,6 @@
>> > #ifndef _INTEL_GUC_FWIF_H
>> > #define _INTEL_GUC_FWIF_H
>> >
>> >-/*
>> >- * This file is partially autogenerated, although currently with
>> >some manual
>> >- * fixups afterwards. In future, it should be entirely
>> >autogenerated, in order
>> >- * to ensure that the definitions herein remain in sync with those
>> >used by the
>> >- * GuC's own firmware.
>> >- *
>> >- * EDITING THIS FILE IS THEREFORE NOT RECOMMENDED - YOUR CHANGES
>MAY
>> >BE LOST.
>> >- */
>>
>> With this removal of comment, do you feel moving the contents of
>intel_guc_fwif.h to intel_uc.c or renaming the file to intel_uc_fwif.h makes a 
>lot
>of difference?
>
>I think this area could use some reorganization, but we should give it more
>thought before we do anything.
>
>Keeping all the GuC-related defines/structs that are used to communicate with
>FW and are prone to change in a separate file seems like a good idea.
>
>This would make them easier to manage in cases of any turbulence.
>
>I agree that `intel_uc_fwif.h` would be a good name, as your HuC patchset is
>reusing some of the intrfaces (e.g. css headers) for HuC.
>
>The rename can be done as part of the HuC effort. I'll give it some more 
>thought
>today and send you a RFC version of the reorg to include in your patchset.
>
Sure. Thanks!

Anusha
>Cheers,
>Arek
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] ✗ Fi.CI.BAT: warning for series starting with [1/2] drm/i915: Advertise ppgtt support type in platform definition

2016-12-06 Thread Michel Thierry

On 05/12/16 18:15, Patchwork wrote:

== Series Details ==

Series: series starting with [1/2] drm/i915: Advertise ppgtt support type in 
platform definition
URL   : https://patchwork.freedesktop.org/series/16403/
State : warning

== Summary ==

Series 16403v1 Series without cover letter
https://patchwork.freedesktop.org/api/1.0/series/16403/revisions/1/mbox/

Test kms_pipe_crc_basic:
Subgroup nonblocking-crc-pipe-a:
pass   -> DMESG-WARN (fi-snb-2520m)



[  486.586950] [drm:drm_edid_block_valid] *ERROR* EDID checksum is 
invalid, remainder is 117


This is already reported in 
https://bugs.freedesktop.org/show_bug.cgi?id=98625 {[SNB BAT] HDMI: EDID 
checksum is invalid}


Thanks to Michał for reviewing the patches.

-Michel


fi-bdw-5557u total:247  pass:232  dwarn:0   dfail:0   fail:0   skip:15
fi-bsw-n3050 total:247  pass:207  dwarn:0   dfail:0   fail:0   skip:40
fi-bxt-t5700 total:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28
fi-byt-j1900 total:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28
fi-byt-n2820 total:247  pass:215  dwarn:0   dfail:0   fail:0   skip:32
fi-hsw-4770  total:247  pass:227  dwarn:0   dfail:0   fail:0   skip:20
fi-hsw-4770r total:247  pass:227  dwarn:0   dfail:0   fail:0   skip:20
fi-ilk-650   total:247  pass:194  dwarn:0   dfail:0   fail:0   skip:53
fi-ivb-3520m total:247  pass:225  dwarn:0   dfail:0   fail:0   skip:22
fi-ivb-3770  total:247  pass:225  dwarn:0   dfail:0   fail:0   skip:22
fi-kbl-7500u total:247  pass:225  dwarn:0   dfail:0   fail:0   skip:22
fi-skl-6260u total:247  pass:233  dwarn:0   dfail:0   fail:0   skip:14
fi-skl-6700hqtotal:247  pass:226  dwarn:0   dfail:0   fail:0   skip:21
fi-skl-6700k total:247  pass:223  dwarn:3   dfail:0   fail:0   skip:21
fi-skl-6770hqtotal:247  pass:233  dwarn:0   dfail:0   fail:0   skip:14
fi-snb-2520m total:247  pass:214  dwarn:1   dfail:0   fail:0   skip:32
fi-snb-2600  total:247  pass:214  dwarn:0   dfail:0   fail:0   skip:33

c3ccb720019c23b0c1fff182214a7ad26af519b8 drm-tip: 2016y-12m-05d-20h-50m-01s UTC 
integration manifest
f38c193 drm/i915: Keep has_* in alphabetical order
92d7853 drm/i915: Advertise ppgtt support type in platform definition

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3200/


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


[Intel-gfx] ✗ Fi.CI.BAT: warning for drm/i915: Tidy load failure reporting

2016-12-06 Thread Patchwork
== Series Details ==

Series: drm/i915: Tidy load failure reporting
URL   : https://patchwork.freedesktop.org/series/16435/
State : warning

== Summary ==

Series 16435v1 drm/i915: Tidy load failure reporting
https://patchwork.freedesktop.org/api/1.0/series/16435/revisions/1/mbox/

Test drv_module_reload:
Subgroup basic-reload-inject:
pass   -> DMESG-WARN (fi-skl-6770hq)
pass   -> DMESG-WARN (fi-skl-6700hq)
pass   -> DMESG-WARN (fi-hsw-4770)
pass   -> DMESG-WARN (fi-skl-6260u)
pass   -> DMESG-WARN (fi-ivb-3770)
pass   -> DMESG-WARN (fi-bdw-5557u)
pass   -> DMESG-WARN (fi-bsw-n3050)
pass   -> DMESG-WARN (fi-hsw-4770r)
pass   -> DMESG-WARN (fi-bxt-t5700)
pass   -> DMESG-WARN (fi-snb-2520m)
pass   -> DMESG-WARN (fi-ilk-650)
pass   -> DMESG-WARN (fi-snb-2600)
pass   -> DMESG-WARN (fi-ivb-3520m)
pass   -> DMESG-WARN (fi-kbl-7500u)
pass   -> DMESG-WARN (fi-byt-n2820)
pass   -> DMESG-WARN (fi-byt-j1900)
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-c:
dmesg-warn -> PASS   (fi-skl-6770hq)

fi-bdw-5557u total:247  pass:217  dwarn:1   dfail:0   fail:0   skip:29 
fi-bsw-n3050 total:247  pass:193  dwarn:1   dfail:0   fail:0   skip:53 
fi-bxt-t5700 total:247  pass:204  dwarn:1   dfail:0   fail:0   skip:42 
fi-byt-j1900 total:247  pass:204  dwarn:1   dfail:0   fail:0   skip:42 
fi-byt-n2820 total:247  pass:200  dwarn:1   dfail:0   fail:0   skip:46 
fi-hsw-4770  total:247  pass:212  dwarn:1   dfail:0   fail:0   skip:34 
fi-hsw-4770r total:247  pass:212  dwarn:1   dfail:0   fail:0   skip:34 
fi-ilk-650   total:247  pass:179  dwarn:1   dfail:0   fail:0   skip:67 
fi-ivb-3520m total:247  pass:211  dwarn:1   dfail:0   fail:0   skip:35 
fi-ivb-3770  total:247  pass:210  dwarn:1   dfail:0   fail:0   skip:36 
fi-kbl-7500u total:247  pass:210  dwarn:1   dfail:0   fail:0   skip:36 
fi-skl-6260u total:247  pass:218  dwarn:1   dfail:0   fail:0   skip:28 
fi-skl-6700hqtotal:247  pass:212  dwarn:1   dfail:0   fail:0   skip:34 
fi-skl-6700k total:247  pass:209  dwarn:3   dfail:0   fail:0   skip:35 
fi-skl-6770hqtotal:247  pass:218  dwarn:1   dfail:0   fail:0   skip:28 
fi-snb-2520m total:247  pass:200  dwarn:1   dfail:0   fail:0   skip:46 
fi-snb-2600  total:247  pass:199  dwarn:1   dfail:0   fail:0   skip:47 

1bc5ec1e0d7c411ccd38404de5b7b328620c82e4 drm-tip: 2016y-12m-06d-15h-09m-40s UTC 
integration manifest
b908481 drm/i915: Tidy load failure reporting

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3206/
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFC 0/5] DRM logging tidy

2016-12-06 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

I wasn't here at the beginnings of DRM so I might have gotten this wrong,
however the existance of DRM_NAME suggested to me that the intention was to
allow individual drivers to override it and get appropriate prefixes in their
log messages.

I can't see that any driver is using it like that but I still thought it would
be neat to do that. That way we could have our log messages look more
obviously ours. For example after this series we have:

 [i915] Memory usable by graphics device = 4096M
 [i915] VT-d active for gfx access
 [i915] Replacing VGA console driver
 [i915] ACPI BIOS requests an excessive sleep of 2 ms, using 1500 ms instead
 [i915] Finished loading DMC firmware i915/skl_dmc_ver1_26.bin (v1.26)
 [i915] Disabling framebuffer compression (FBC) to prevent screen flicker with 
VT-d enabled
 [i915] GuC firmware load skipped
 [i915] Initialized i915 1.6.0 20161205 for :00:02.0 on minor 0
 [i915] DRM_I915_DEBUG enabled
 [i915] DRM_I915_DEBUG_GEM enabled
 [i915] RC6 on

Previously all that was prefixed with "[drm]" which was OK but I think the
above is even better.

Also to consider is that recent drm_printk work has removed (it hardcoded)
DRM_NAME from DRM_ERROR and DRM_DEBUG macros, while leaving it with the rest
(DRM_INFO, NOTE and WARNING) creating a bit of a inconsistency.

This series also makes all the logging macros use drm_printk, but also
makes DRM_NAME passed in from the macro wrappers in all cases. So drivers
can override it regardless of the log level.

And finally, the series also removes a bit of redundant data from the debug
messages effectively converting this:

 [drm:edp_panel_off [i915]] Wait for panel power off time

Into this:

 [edp_panel_off [i915]] Wait for panel power off time

Which still has all the data in it.

Tvrtko Ursulin (5):
  drm/i915: Give our log messages our name
  drm: Respect driver set DRM_NAME in drm_printk
  drm: Respect driver set DRM_NAME in drm_dev_printk
  drm: Use drm_printk for all logging macros
  drm: Do not log driver prefix in debug messages

 drivers/gpu/drm/drm_drv.c   | 39 +++--
 drivers/gpu/drm/i915/i915_drv.c |  3 +-
 include/drm/drmP.h  | 94 -
 include/drm/drm_drv.h   | 11 ++---
 include/uapi/drm/i915_drm.h |  3 ++
 5 files changed, 92 insertions(+), 58 deletions(-)

-- 
2.7.4

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


[Intel-gfx] [RFC 2/5] drm: Respect driver set DRM_NAME in drm_printk

2016-12-06 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Instead of logging with the DRM core name, pass in the name explicitly
in order to allow individual drivers to have all their log messages
prefixed with their own name.

For instance i915, instead of:

 [drm:edp_panel_off [i915]] Wait for panel power off time

would now log debug messages as:

 [i915:edp_panel_off [i915]] Wait for panel power off time

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/drm_drv.c |  6 +++---
 include/drm/drmP.h| 14 +++---
 include/drm/drm_drv.h |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index f74b7d06ec01..f6b674b03db9 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -92,7 +92,7 @@ void drm_dev_printk(const struct device *dev, const char 
*level,
 EXPORT_SYMBOL(drm_dev_printk);
 
 void drm_printk(const char *level, unsigned int category,
-   const char *format, ...)
+   const char *driver, const char *format, ...)
 {
struct va_format vaf;
va_list args;
@@ -104,8 +104,8 @@ void drm_printk(const char *level, unsigned int category,
vaf.fmt = format;
vaf.va = &args;
 
-   printk("%s" "[" DRM_NAME ":%ps]%s %pV",
-  level, __builtin_return_address(0),
+   printk("%s[%s:%ps]%s %pV",
+  level, driver, __builtin_return_address(0),
   strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf);
 
va_end(args);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index a9cfd33c7b1a..eedfbe51795a 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -176,7 +176,7 @@ struct dma_buf_attachment;
drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\
   fmt, ##__VA_ARGS__)
 #define DRM_ERROR(fmt, ...)\
-   drm_printk(KERN_ERR, DRM_UT_NONE, fmt,  ##__VA_ARGS__)
+   drm_printk(KERN_ERR, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__)
 
 /**
  * Rate limited error output.  Like DRM_ERROR() but won't flood the log.
@@ -219,37 +219,37 @@ struct dma_buf_attachment;
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \
   ##args)
 #define DRM_DEBUG(fmt, ...)\
-   drm_printk(KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__)
+   drm_printk(KERN_DEBUG, DRM_UT_CORE, DRM_NAME, fmt, ##__VA_ARGS__)
 
 #define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...)
\
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "",\
   fmt, ##args)
 #define DRM_DEBUG_DRIVER(fmt, ...) \
-   drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
+   drm_printk(KERN_DEBUG, DRM_UT_DRIVER, DRM_NAME, fmt, ##__VA_ARGS__)
 
 #define DRM_DEV_DEBUG_KMS(dev, fmt, args...)   \
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt,  \
   ##args)
 #define DRM_DEBUG_KMS(fmt, ...)\
-   drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__)
+   drm_printk(KERN_DEBUG, DRM_UT_KMS, DRM_NAME, fmt, ##__VA_ARGS__)
 
 #define DRM_DEV_DEBUG_PRIME(dev, fmt, args...) \
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "", \
   fmt, ##args)
 #define DRM_DEBUG_PRIME(fmt, ...)  \
-   drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
+   drm_printk(KERN_DEBUG, DRM_UT_PRIME, DRM_NAME, fmt, ##__VA_ARGS__)
 
 #define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...)
\
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "",\
   fmt, ##args)
 #define DRM_DEBUG_ATOMIC(fmt, ...) \
-   drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
+   drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, DRM_NAME, fmt, ##__VA_ARGS__)
 
 #define DRM_DEV_DEBUG_VBL(dev, fmt, args...)   \
drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt,  \
   ##args)
 #define DRM_DEBUG_VBL(fmt, ...)\
-   drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__)
+   drm_printk(KERN_DEBUG, DRM_UT_VBL, DRM_NAME, fmt, ##__VA_ARGS__)
 
 #define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...)\
 ({ \
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index c4fc49583dc0..0ad6cde5757b 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -411,9 +411,9 @@ extern __printf(6, 7)
 void drm_dev_printk(const struct device *dev, const char *level,
unsigned int category, const char *function_name,
const char *prefix

[Intel-gfx] [RFC 1/5] drm/i915: Give our log messages our name

2016-12-06 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Define DRM_NAME to i915 so that the log messages we output change from:

 [drm] RC6 on

to:

 [i915] RC6 on

Since I wasn't around in the beginning of DRM I wonder whether that
was the intended purpose of DRM_NAME or if it was something else.

Today it looks a bit messy with it being used by both macros and core
DRM helpers, like drm_dev_printk and drm_printk, meaning that this
change only affects some and not all log messages.

Following patches will try to correct that as well.

Signed-off-by: Tvrtko Ursulin 
---
 include/uapi/drm/i915_drm.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index da32c2f6c3f9..b777a6b7b3dc 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -29,6 +29,9 @@
 
 #include "drm.h"
 
+#undef DRM_NAME
+#define DRM_NAME "i915"
+
 #if defined(__cplusplus)
 extern "C" {
 #endif
-- 
2.7.4

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


[Intel-gfx] [RFC 4/5] drm: Use drm_printk for all logging macros

2016-12-06 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Eliminate _DRM_PRINTK macro and use drm_printk for all log levels.

This required drm_printk to vary the verbosity level of the logged
metadata depending on the log level.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/drm_drv.c | 31 ++-
 include/drm/drmP.h| 44 ++--
 2 files changed, 52 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index a2f4eb4509b9..bda4639c73e4 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -80,12 +80,21 @@ void drm_dev_printk(const struct device *dev, const char 
*level,
vaf.fmt = format;
vaf.va = &args;
 
-   if (dev)
-   dev_printk(level, dev, "[%s:%ps]%s %pV",
-  driver, function_name, prefix, &vaf);
-   else
-   printk("%s[%s:%ps]%s %pV",
-  level, driver, function_name, prefix, &vaf);
+   if (level[1] != KERN_DEBUG[1]) {
+   if (dev)
+   dev_printk(level, dev, "[%s]%s %pV",
+  driver, prefix, &vaf);
+   else
+   printk("%s[%s]%s %pV",
+  level, driver, prefix, &vaf);
+   } else {
+   if (dev)
+   dev_printk(level, dev, "[%s:%ps]%s %pV",
+  driver, function_name, prefix, &vaf);
+   else
+   printk("%s[%s:%ps]%s %pV",
+  level, driver, function_name, prefix, &vaf);
+   }
 
va_end(args);
 }
@@ -104,9 +113,13 @@ void drm_printk(const char *level, unsigned int category,
vaf.fmt = format;
vaf.va = &args;
 
-   printk("%s[%s:%ps]%s %pV",
-  level, driver, __builtin_return_address(0),
-  strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf);
+   if (level[1] != KERN_DEBUG[1])
+   printk("%s[%s]%s %pV",
+  level, driver,
+  strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf);
+   else
+   printk("%s[%s:%ps] %pV",
+  level, driver, __builtin_return_address(0), &vaf);
 
va_end(args);
 }
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8661045ffaf1..b8f9dcd49b36 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -146,25 +146,41 @@ struct dma_buf_attachment;
 /** \name Macros to make printk easier */
 /*@{*/
 
-#define _DRM_PRINTK(once, level, fmt, ...) \
-   do {\
-   printk##once(KERN_##level "[" DRM_NAME "] " fmt,\
-##__VA_ARGS__);\
-   } while (0)
-
 #define DRM_INFO(fmt, ...) \
-   _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
-#define DRM_NOTE(fmt, ...) \
-   _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__)
-#define DRM_WARN(fmt, ...) \
-   _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__)
+   drm_printk(KERN_INFO, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__)
 
 #define DRM_INFO_ONCE(fmt, ...)
\
-   _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__)
+({ \
+   static bool __print_once __read_mostly; \
+   if (!__print_once) {\
+   __print_once = true;\
+   DRM_INFO(fmt, ##__VA_ARGS__);   \
+   }   \
+})
+
+#define DRM_NOTE(fmt, ...) \
+   drm_printk(KERN_NOTICE, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__)
+
 #define DRM_NOTE_ONCE(fmt, ...)
\
-   _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__)
+({ \
+   static bool __print_once __read_mostly; \
+   if (!__print_once) {\
+   __print_once = true;\
+   DRM_NOTE(fmt, ##__VA_ARGS__);   \
+   }   \
+})
+
+#define DRM_WARN(fmt, ...) \
+   drm_printk(KERN_WARNING, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__)
+
 #define DRM_WARN_ONCE(fmt, ...)
\
-   _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__)
+({   

[Intel-gfx] [RFC 3/5] drm: Respect driver set DRM_NAME in drm_dev_printk

2016-12-06 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Same as the previous patch did for drm_printk, allow for the
logging macros to pass in the driver set DRM_NAME.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/drm_drv.c   | 14 +++---
 drivers/gpu/drm/i915/i915_drv.c |  3 ++-
 include/drm/drmP.h  | 36 ++--
 include/drm/drm_drv.h   |  7 ---
 4 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index f6b674b03db9..a2f4eb4509b9 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -65,11 +65,10 @@ static struct idr drm_minors_idr;
 
 static struct dentry *drm_debugfs_root;
 
-#define DRM_PRINTK_FMT "[" DRM_NAME ":%s]%s %pV"
-
 void drm_dev_printk(const struct device *dev, const char *level,
-   unsigned int category, const char *function_name,
-   const char *prefix, const char *format, ...)
+   unsigned int category, const char *driver,
+   const char *function_name, const char *prefix,
+   const char *format, ...)
 {
struct va_format vaf;
va_list args;
@@ -82,10 +81,11 @@ void drm_dev_printk(const struct device *dev, const char 
*level,
vaf.va = &args;
 
if (dev)
-   dev_printk(level, dev, DRM_PRINTK_FMT, function_name, prefix,
-  &vaf);
+   dev_printk(level, dev, "[%s:%ps]%s %pV",
+  driver, function_name, prefix, &vaf);
else
-   printk("%s" DRM_PRINTK_FMT, level, function_name, prefix, &vaf);
+   printk("%s[%s:%ps]%s %pV",
+  level, driver, function_name, prefix, &vaf);
 
va_end(args);
 }
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 78b2d03bf808..77d82fce371d 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -101,7 +101,8 @@ i915_load_error(struct drm_i915_private *dev_priv, const 
char *fmt, ...)
vaf.fmt = fmt;
vaf.va = &args;
 
-   drm_dev_printk(kdev, level, DRM_UT_DRIVER, __func__, "", fmt, &vaf);
+   drm_dev_printk(kdev, level, DRM_UT_DRIVER, DRM_NAME, __func__, "",
+  fmt, &vaf);
 
va_end(args);
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index eedfbe51795a..8661045ffaf1 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -173,8 +173,8 @@ struct dma_buf_attachment;
  * \param arg arguments
  */
 #define DRM_DEV_ERROR(dev, fmt, ...)   \
-   drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\
-  fmt, ##__VA_ARGS__)
+   drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, DRM_NAME, __func__,  \
+  " *ERROR*", fmt, ##__VA_ARGS__)
 #define DRM_ERROR(fmt, ...)\
drm_printk(KERN_ERR, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__)
 
@@ -197,8 +197,8 @@ struct dma_buf_attachment;
DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
 
 #define DRM_DEV_INFO(dev, fmt, ...)\
-   drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt,  \
-  ##__VA_ARGS__)
+   drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, DRM_NAME, __func__, \
+  "", fmt, ##__VA_ARGS__)
 
 #define DRM_DEV_INFO_ONCE(dev, fmt, ...)   \
 ({ \
@@ -216,38 +216,38 @@ struct dma_buf_attachment;
  * \param arg arguments
  */
 #define DRM_DEV_DEBUG(dev, fmt, args...)   \
-   drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \
-  ##args)
+   drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, DRM_NAME, __func__,\
+  "", fmt, ##args)
 #define DRM_DEBUG(fmt, ...)\
drm_printk(KERN_DEBUG, DRM_UT_CORE, DRM_NAME, fmt, ##__VA_ARGS__)
 
 #define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...)
\
-   drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "",\
-  fmt, ##args)
+   drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, DRM_NAME,\
+  __func__, "", fmt, ##args)
 #define DRM_DEBUG_DRIVER(fmt, ...) \
drm_printk(KERN_DEBUG, DRM_UT_DRIVER, DRM_NAME, fmt, ##__VA_ARGS__)
 
 #define DRM_DEV_DEBUG_KMS(dev, fmt, args...)   \
-   drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt,  \
-  ##args)
-#define DRM_DEBUG_KMS(fmt, ...)\
+   drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, DRM_NAME, __func__, \
+  "", fmt, ##args)
+#define DRM_DEBUG_KMS(fmt, ...)

[Intel-gfx] [RFC 5/5] drm: Do not log driver prefix in debug messages

2016-12-06 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Driver prefix is a bit redundant in debug messages. If we choose
not to log it we change debug messages which used to look like this:

 [i915:edp_panel_off [i915]] Wait for panel power off time

to this:

 [edp_panel_off [i915]] Wait for panel power off time

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/drm_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index bda4639c73e4..498beaf8ee8b 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -118,8 +118,8 @@ void drm_printk(const char *level, unsigned int category,
   level, driver,
   strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf);
else
-   printk("%s[%s:%ps] %pV",
-  level, driver, __builtin_return_address(0), &vaf);
+   printk("%s[%ps] %pV",
+  level, __builtin_return_address(0), &vaf);
 
va_end(args);
 }
-- 
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: Tidy load failure reporting

2016-12-06 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Several changes here:

 * Remove unused i915_report_error.
 * Unexport __i915_printk and rename it to i915_load_error,
   converting the latter from a macro to a static function.
 * Use drm_dev_printk instead of open-coding the same.

v2: Fix reversed error condition.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_drv.c | 45 +++--
 drivers/gpu/drm/i915/i915_drv.h |  7 ---
 2 files changed, 21 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index ae583c79c19f..7217ecdb790d 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -68,52 +68,49 @@ bool __i915_inject_load_failure(const char *func, int line)
return false;
 }
 
+static bool i915_error_injected(struct drm_i915_private *dev_priv)
+{
+   return i915.inject_load_failure &&
+  i915_load_fail_count == i915.inject_load_failure;
+}
+
 #define FDO_BUG_URL "https://bugs.freedesktop.org/enter_bug.cgi?product=DRI";
 #define FDO_BUG_MSG "Please file a bug at " FDO_BUG_URL " against DRM/Intel " \
"providing the dmesg log by booting with drm.debug=0xf"
 
-void
-__i915_printk(struct drm_i915_private *dev_priv, const char *level,
- const char *fmt, ...)
+static void __printf(2, 3)
+i915_load_error(struct drm_i915_private *dev_priv, const char *fmt, ...)
 {
-   static bool shown_bug_once;
+   static bool shown_bug_once __read_mostly;
struct device *kdev = dev_priv->drm.dev;
-   bool is_error = level[1] <= KERN_ERR[1];
-   bool is_debug = level[1] == KERN_DEBUG[1];
+   char *level;
+   bool is_error;
struct va_format vaf;
va_list args;
 
-   if (is_debug && !(drm_debug & DRM_UT_DRIVER))
-   return;
+   if (i915_error_injected(dev_priv)) {
+   is_error = false;
+   level = KERN_DEBUG;
+   } else {
+   is_error = true;
+   level = KERN_ERR;
+   };
 
va_start(args, fmt);
 
vaf.fmt = fmt;
vaf.va = &args;
 
-   dev_printk(level, kdev, "[" DRM_NAME ":%ps] %pV",
-  __builtin_return_address(0), &vaf);
+   drm_dev_printk(kdev, level, DRM_UT_DRIVER, __func__, "", fmt, &vaf);
+
+   va_end(args);
 
if (is_error && !shown_bug_once) {
dev_notice(kdev, "%s", FDO_BUG_MSG);
shown_bug_once = true;
}
-
-   va_end(args);
-}
-
-static bool i915_error_injected(struct drm_i915_private *dev_priv)
-{
-   return i915.inject_load_failure &&
-  i915_load_fail_count == i915.inject_load_failure;
 }
 
-#define i915_load_error(dev_priv, fmt, ...) \
-   __i915_printk(dev_priv,  \
- i915_error_injected(dev_priv) ? KERN_DEBUG : KERN_ERR, \
- fmt, ##__VA_ARGS__)
-
-
 static enum intel_pch intel_virt_detect_pch(struct drm_i915_private *dev_priv)
 {
enum intel_pch ret = PCH_NOP;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 605247baa7d1..f523cdfa8636 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2766,13 +2766,6 @@ int intel_sanitize_enable_ppgtt(struct drm_i915_private 
*dev_priv,
 bool intel_sanitize_semaphores(struct drm_i915_private *dev_priv, int value);
 
 /* i915_drv.c */
-void __printf(3, 4)
-__i915_printk(struct drm_i915_private *dev_priv, const char *level,
- const char *fmt, ...);
-
-#define i915_report_error(dev_priv, fmt, ...) \
-   __i915_printk(dev_priv, KERN_ERR, fmt, ##__VA_ARGS__)
-
 #ifdef CONFIG_COMPAT
 extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
  unsigned long arg);
-- 
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: Use DRM_DEV_ERROR in i915_driver_load

2016-12-06 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Now that it is available we don't have to open code a similar
error message ourselves.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 7217ecdb790d..b4bf9255a215 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1186,8 +1186,7 @@ int i915_driver_load(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (dev_priv)
ret = drm_dev_init(&dev_priv->drm, &driver, &pdev->dev);
if (ret) {
-   dev_printk(KERN_ERR, &pdev->dev,
-  "[" DRM_NAME ":%s] allocation failed\n", __func__);
+   DRM_DEV_ERROR(&pdev->dev, "allocation failed\n");
kfree(dev_priv);
return ret;
}
-- 
2.7.4

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


[Intel-gfx] ✗ Fi.CI.BAT: failure for DRM logging tidy

2016-12-06 Thread Patchwork
== Series Details ==

Series: DRM logging tidy
URL   : https://patchwork.freedesktop.org/series/16439/
State : failure

== Summary ==

  CC [M]  drivers/gpu/drm/i915/intel_renderstate_gen6.o
  CC [M]  drivers/gpu/drm/i915/i915_guc_submission.o
  CC [M]  drivers/gpu/drm/i915/intel_renderstate_gen7.o
  LD  drivers/mmc/built-in.o
  CC [M]  drivers/gpu/drm/i915/intel_renderstate_gen8.o
  CC [M]  drivers/gpu/drm/i915/intel_audio.o
  CC [M]  drivers/gpu/drm/i915/intel_renderstate_gen9.o
cc1: all warnings being treated as errors
  LD  drivers/pnp/pnpacpi/built-in.o
  LD  kernel/built-in.o
  GEN lib/crc32table.h
  CC [M]  drivers/gpu/drm/i915/intel_atomic.o
  CC [M]  drivers/gpu/drm/i915/intel_atomic_plane.o
  CC [M]  drivers/gpu/drm/i915/intel_bios.o
  LD  drivers/pnp/built-in.o
scripts/Makefile.build:293: recipe for target 'drivers/gpu/drm/i915/i915_drv.o' 
failed
make[4]: *** [drivers/gpu/drm/i915/i915_drv.o] Error 1
make[4]: *** Waiting for unfinished jobs
  CC  lib/crc32.o
  CC [M]  drivers/gpu/drm/i915/intel_color.o
  CC [M]  drivers/gpu/drm/i915/intel_dpio_phy.o
  CC [M]  drivers/gpu/drm/i915/intel_display.o
  LD [M]  drivers/misc/mei/mei-me.o
  LD [M]  drivers/net/ethernet/intel/igbvf/igbvf.o
  LD  drivers/misc/built-in.o
  LD  drivers/usb/storage/usb-storage.o
  LD  drivers/usb/storage/built-in.o
  LD [M]  drivers/usb/serial/usbserial.o
  LD  drivers/acpi/acpica/acpi.o
  LD  drivers/iommu/built-in.o
  LD [M]  sound/pci/hda/snd-hda-codec-generic.o
  LD  drivers/pci/pcie/aer/aerdriver.o
  LD  drivers/spi/built-in.o
  LD  sound/pci/built-in.o
  LD  drivers/pci/pcie/aer/built-in.o
  LD  drivers/pci/pcie/built-in.o
  LD  drivers/acpi/acpica/built-in.o
  LD  drivers/thermal/thermal_sys.o
  LD  drivers/tty/serial/8250/8250.o
  LD  drivers/gpu/drm/drm.o
  LD  drivers/acpi/built-in.o
  LD  sound/built-in.o
  LD  drivers/thermal/built-in.o
  LD  drivers/video/fbdev/core/fb.o
  LD  net/ipv6/ipv6.o
  LD  drivers/video/fbdev/core/built-in.o
  LD [M]  drivers/net/ethernet/intel/e1000/e1000.o
  LD  lib/raid6/raid6_pq.o
  LD  drivers/usb/gadget/libcomposite.o
  LD  drivers/video/fbdev/built-in.o
  LD  lib/raid6/built-in.o
  LD  net/ipv6/built-in.o
  LD  drivers/scsi/scsi_mod.o
  LD  drivers/pci/built-in.o
  LD  drivers/tty/serial/8250/8250_base.o
  LD  drivers/tty/serial/8250/built-in.o
  LD  drivers/tty/serial/built-in.o
  LD  drivers/usb/gadget/udc/udc-core.o
  LD  fs/btrfs/btrfs.o
  LD  drivers/usb/gadget/udc/built-in.o
  LD  drivers/usb/gadget/built-in.o
  LD  fs/btrfs/built-in.o
  LD  net/ipv4/built-in.o
  LD  drivers/video/console/built-in.o
  LD  drivers/video/built-in.o
  CC  arch/x86/kernel/cpu/capflags.o
  LD [M]  drivers/net/ethernet/intel/igb/igb.o
  LD  drivers/usb/core/usbcore.o
  LD  arch/x86/kernel/cpu/built-in.o
  LD  arch/x86/kernel/built-in.o
  LD  drivers/usb/core/built-in.o
  LD  drivers/scsi/sd_mod.o
  LD  drivers/scsi/built-in.o
  LD  arch/x86/built-in.o
  LD  drivers/md/md-mod.o
  LD  drivers/md/built-in.o
  AR  lib/lib.a
  EXPORTS lib/lib-ksyms.o
  LD  lib/built-in.o
  LD  drivers/usb/host/xhci-hcd.o
  LD  net/core/built-in.o
  LD  net/built-in.o
  LD  drivers/tty/vt/built-in.o
  LD  drivers/tty/built-in.o
  LD  drivers/usb/host/built-in.o
  LD  drivers/usb/built-in.o
  LD  fs/ext4/ext4.o
  LD  fs/ext4/built-in.o
  LD  fs/built-in.o
  LD [M]  drivers/net/ethernet/intel/e1000e/e1000e.o
  LD  drivers/net/ethernet/built-in.o
  LD  drivers/net/built-in.o
scripts/Makefile.build:544: recipe for target 'drivers/gpu/drm/i915' failed
make[3]: *** [drivers/gpu/drm/i915] Error 2
scripts/Makefile.build:544: recipe for target 'drivers/gpu/drm' failed
make[2]: *** [drivers/gpu/drm] Error 2
scripts/Makefile.build:544: recipe for target 'drivers/gpu' failed
make[1]: *** [drivers/gpu] Error 2
Makefile:988: recipe for target 'drivers' failed
make: *** [drivers] Error 2

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


Re: [Intel-gfx] [RFC 5/5] drm: Do not log driver prefix in debug messages

2016-12-06 Thread Gustavo Padovan
Hi Tvrtko,

2016-12-06 Tvrtko Ursulin :

> From: Tvrtko Ursulin 
> 
> Driver prefix is a bit redundant in debug messages. If we choose
> not to log it we change debug messages which used to look like this:
> 
>  [i915:edp_panel_off [i915]] Wait for panel power off time
> 
> to this:
> 
>  [edp_panel_off [i915]] Wait for panel power off time

Why not remove the second mention to the driver's name instead.

[i915:edp_panel_off] looks more logic to me.

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


[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Tidy load failure reporting (rev2)

2016-12-06 Thread Patchwork
== Series Details ==

Series: drm/i915: Tidy load failure reporting (rev2)
URL   : https://patchwork.freedesktop.org/series/16435/
State : success

== Summary ==

Series 16435v2 drm/i915: Tidy load failure reporting
https://patchwork.freedesktop.org/api/1.0/series/16435/revisions/2/mbox/


fi-bdw-5557u total:247  pass:218  dwarn:0   dfail:0   fail:0   skip:29 
fi-bsw-n3050 total:247  pass:194  dwarn:0   dfail:0   fail:0   skip:53 
fi-byt-j1900 total:247  pass:205  dwarn:0   dfail:0   fail:0   skip:42 
fi-byt-n2820 total:247  pass:201  dwarn:0   dfail:0   fail:0   skip:46 
fi-hsw-4770  total:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-hsw-4770r total:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-ilk-650   total:247  pass:180  dwarn:0   dfail:0   fail:0   skip:67 
fi-ivb-3520m total:247  pass:212  dwarn:0   dfail:0   fail:0   skip:35 
fi-ivb-3770  total:247  pass:211  dwarn:0   dfail:0   fail:0   skip:36 
fi-kbl-7500u total:247  pass:211  dwarn:0   dfail:0   fail:0   skip:36 
fi-skl-6260u total:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-skl-6700hqtotal:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-skl-6700k total:247  pass:209  dwarn:3   dfail:0   fail:0   skip:35 
fi-skl-6770hqtotal:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-snb-2520m total:247  pass:201  dwarn:0   dfail:0   fail:0   skip:46 
fi-snb-2600  total:247  pass:200  dwarn:0   dfail:0   fail:0   skip:47 

08aa3ac5c18159c9105252903713cb21c27e9442 drm-tip: 2016y-12m-06d-18h-32m-52s UTC 
integration manifest
153190a drm/i915: Tidy load failure reporting

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3208/
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: Use DRM_DEV_ERROR in i915_driver_load

2016-12-06 Thread Patchwork
== Series Details ==

Series: drm/i915: Use DRM_DEV_ERROR in i915_driver_load
URL   : https://patchwork.freedesktop.org/series/16441/
State : failure

== Summary ==

Series 16441v1 drm/i915: Use DRM_DEV_ERROR in i915_driver_load
https://patchwork.freedesktop.org/api/1.0/series/16441/revisions/1/mbox/

Test drv_module_reload:
Subgroup basic-reload-inject:
pass   -> INCOMPLETE (fi-skl-6260u)

fi-bdw-5557u total:247  pass:218  dwarn:0   dfail:0   fail:0   skip:29 
fi-bsw-n3050 total:247  pass:194  dwarn:0   dfail:0   fail:0   skip:53 
fi-bxt-t5700 total:247  pass:205  dwarn:0   dfail:0   fail:0   skip:42 
fi-byt-j1900 total:247  pass:205  dwarn:0   dfail:0   fail:0   skip:42 
fi-byt-n2820 total:247  pass:201  dwarn:0   dfail:0   fail:0   skip:46 
fi-hsw-4770  total:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-hsw-4770r total:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-ilk-650   total:247  pass:180  dwarn:0   dfail:0   fail:0   skip:67 
fi-ivb-3520m total:247  pass:212  dwarn:0   dfail:0   fail:0   skip:35 
fi-ivb-3770  total:247  pass:211  dwarn:0   dfail:0   fail:0   skip:36 
fi-kbl-7500u total:247  pass:211  dwarn:0   dfail:0   fail:0   skip:36 
fi-skl-6260u total:7pass:6dwarn:0   dfail:0   fail:0   skip:0  
fi-skl-6700hqtotal:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-skl-6700k total:247  pass:209  dwarn:3   dfail:0   fail:0   skip:35 
fi-skl-6770hqtotal:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-snb-2520m total:247  pass:201  dwarn:0   dfail:0   fail:0   skip:46 
fi-snb-2600  total:247  pass:200  dwarn:0   dfail:0   fail:0   skip:47 

08aa3ac5c18159c9105252903713cb21c27e9442 drm-tip: 2016y-12m-06d-18h-32m-52s UTC 
integration manifest
15c67d9 drm/i915: Use DRM_DEV_ERROR in i915_driver_load

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3209/
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: Use DRM_DEV_ERROR in i915_driver_load

2016-12-06 Thread Chris Wilson
On Tue, Dec 06, 2016 at 07:04:13PM +, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin 
> 
> Now that it is available we don't have to open code a similar
> error message ourselves.
> 
> Signed-off-by: Tvrtko Ursulin 
Reviewed-by: Chris Wilson 
-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


Re: [Intel-gfx] [PATCH v2] drm/i915: Tidy load failure reporting

2016-12-06 Thread Chris Wilson
On Tue, Dec 06, 2016 at 07:00:26PM +, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin 
> 
> Several changes here:
> 
>  * Remove unused i915_report_error.

The plan was to start using it for the more prominent errors. (Any and
every DRM_ERROR should be considered to be a userfacing error message
and incorporate a request to file a bug. Almost all need massaging to be
useful though.)

>  * Unexport __i915_printk and rename it to i915_load_error,
>converting the latter from a macro to a static function.
>  * Use drm_dev_printk instead of open-coding the same.
> 
> v2: Fix reversed error condition.
> 
> Signed-off-by: Tvrtko Ursulin 
> ---
>  drivers/gpu/drm/i915/i915_drv.c | 45 
> +++--
>  drivers/gpu/drm/i915/i915_drv.h |  7 ---
>  2 files changed, 21 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index ae583c79c19f..7217ecdb790d 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -68,52 +68,49 @@ bool __i915_inject_load_failure(const char *func, int 
> line)
>   return false;
>  }
>  
> +static bool i915_error_injected(struct drm_i915_private *dev_priv)
> +{
> + return i915.inject_load_failure &&
> +i915_load_fail_count == i915.inject_load_failure;
> +}
> +
>  #define FDO_BUG_URL "https://bugs.freedesktop.org/enter_bug.cgi?product=DRI";
>  #define FDO_BUG_MSG "Please file a bug at " FDO_BUG_URL " against DRM/Intel 
> " \
>   "providing the dmesg log by booting with drm.debug=0xf"
>  
> -void
> -__i915_printk(struct drm_i915_private *dev_priv, const char *level,
> -   const char *fmt, ...)
> +static void __printf(2, 3)
> +i915_load_error(struct drm_i915_private *dev_priv, const char *fmt, ...)
>  {
> - static bool shown_bug_once;
> + static bool shown_bug_once __read_mostly;
>   struct device *kdev = dev_priv->drm.dev;
> - bool is_error = level[1] <= KERN_ERR[1];
> - bool is_debug = level[1] == KERN_DEBUG[1];
> + char *level;
> + bool is_error;
>   struct va_format vaf;
>   va_list args;
>  
> - if (is_debug && !(drm_debug & DRM_UT_DRIVER))
> - return;
> + if (i915_error_injected(dev_priv)) {
> + is_error = false;
> + level = KERN_DEBUG;
> + } else {
> + is_error = true;
> + level = KERN_ERR;
> + };

Stray ';'

The drm_dev_printk replacement looks reasonable.
-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] [PATCH] drm/i915: Do not reset detect_done flag in intel_dp_detect

2016-12-06 Thread Manasi Navare
The detect_done flag was introduced in the commit
7d23e3c37bb3fc6952dc84007ee60cb533fd2d5c in order to avoid
multiple detects on hotplug where intel_dp_long_pulse()
was called from HPD handler as well as in intel_dp_detect.
So this detect_done flag was required to make sure intel_dp_detect()
did not call long pulse handler again if it was already been called
from HPD handler. However commit 1015811609c0328b5ed670d07748591b837e74eb
differs the long hpd handling entirely until the hotplug work runs to
avoid the double long hpd handling the "detect_done" flag is trying
to prevent.

So now we do not need to reset the detect_done flag to false in
intel_dp_detect. It will be reset in the intel_dp_hpd_pulse so
that intel_dp_detect does a full detect. However if the .detect
gets called during mode enumeration then we do not need to do a
full detect. This patch avoids the WARNS_ONS during connected boot
case when it calls intel_dp_check_link_status() due to multiple
detects and also avoids DP compliance failures. It avoids doing
a full detect every single time on .detect().

Cc: Ville Syrjala 
Cc: Daniel Vetter 
Cc: Jani Nikula 
Signed-off-by: Manasi Navare 
---
 drivers/gpu/drm/i915/intel_dp.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index db75bb9..9c9277e 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -4470,8 +4470,6 @@ static bool intel_digital_port_connected(struct 
drm_i915_private *dev_priv,
if (!intel_dp->detect_done)
status = intel_dp_long_pulse(intel_dp->attached_connector);
 
-   intel_dp->detect_done = false;
-
return status;
 }
 
-- 
1.9.1

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


[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Do not reset detect_done flag in intel_dp_detect

2016-12-06 Thread Patchwork
== Series Details ==

Series: drm/i915: Do not reset detect_done flag in intel_dp_detect
URL   : https://patchwork.freedesktop.org/series/16456/
State : success

== Summary ==

Series 16456v1 drm/i915: Do not reset detect_done flag in intel_dp_detect
https://patchwork.freedesktop.org/api/1.0/series/16456/revisions/1/mbox/


fi-bdw-5557u total:247  pass:218  dwarn:0   dfail:0   fail:0   skip:29 
fi-bsw-n3050 total:247  pass:194  dwarn:0   dfail:0   fail:0   skip:53 
fi-bxt-t5700 total:247  pass:205  dwarn:0   dfail:0   fail:0   skip:42 
fi-byt-j1900 total:247  pass:205  dwarn:0   dfail:0   fail:0   skip:42 
fi-byt-n2820 total:247  pass:201  dwarn:0   dfail:0   fail:0   skip:46 
fi-hsw-4770  total:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-hsw-4770r total:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-ilk-650   total:247  pass:180  dwarn:0   dfail:0   fail:0   skip:67 
fi-ivb-3520m total:247  pass:212  dwarn:0   dfail:0   fail:0   skip:35 
fi-ivb-3770  total:247  pass:211  dwarn:0   dfail:0   fail:0   skip:36 
fi-kbl-7500u total:247  pass:211  dwarn:0   dfail:0   fail:0   skip:36 
fi-skl-6260u total:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-skl-6700hqtotal:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-skl-6700k total:247  pass:209  dwarn:3   dfail:0   fail:0   skip:35 
fi-skl-6770hqtotal:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-snb-2520m total:247  pass:201  dwarn:0   dfail:0   fail:0   skip:46 
fi-snb-2600  total:247  pass:200  dwarn:0   dfail:0   fail:0   skip:47 

08aa3ac5c18159c9105252903713cb21c27e9442 drm-tip: 2016y-12m-06d-18h-32m-52s UTC 
integration manifest
9e30950 drm/i915: Do not reset detect_done flag in intel_dp_detect

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3210/
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


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

2016-12-06 Thread Robert Foss
This subtest verifies the access ordering of multiple consumer threads.

Signed-off-by: Robert Foss 
Reviewed-by: Eric Engestrom 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 98 +
 1 file changed, 98 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index c0eade51..5b6532c2 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -24,6 +24,8 @@
  *Robert Foss 
  */
 
+#include 
+#include 
 #include 
 #include 
 
@@ -36,6 +38,13 @@
 
 IGT_TEST_DESCRIPTION("Test SW Sync Framework");
 
+typedef struct {
+   int timeline;
+   uint32_t thread_id;
+   volatile uint32_t * volatile counter;
+   sem_t *sem;
+} data_t;
+
 static void test_alloc_timeline(void)
 {
int timeline;
@@ -217,6 +226,92 @@ static void test_sync_merge_same(void)
close(timeline);
 }
 
+#define MULTI_CONSUMER_THREADS 8
+#define MULTI_CONSUMER_ITERATIONS (1 << 14)
+static void * test_sync_multi_consumer_thread(void *arg)
+{
+   data_t *data = arg;
+   int thread_id = data->thread_id;
+   int timeline = data->timeline;
+   int ret, i;
+
+   for (i = 0; i < MULTI_CONSUMER_ITERATIONS; i++) {
+   int next_point = i * MULTI_CONSUMER_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)
+{
+
+   data_t data_arr[MULTI_CONSUMER_THREADS];
+   pthread_t thread_arr[MULTI_CONSUMER_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.counter = &counter;
+   data.timeline = timeline;
+   data.sem = &sem;
+
+   /* Start sync threads. */
+   for (i = 0; i < MULTI_CONSUMER_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 < MULTI_CONSUMER_THREADS * MULTI_CONSUMER_ITERATIONS; i++)
+   {
+   sem_wait(&sem);
+
+   counter++;
+   sw_sync_timeline_inc(timeline, 1);
+   }
+
+   /* Wait for threads to complete. */
+   for (i = 0; i < MULTI_CONSUMER_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 == MULTI_CONSUMER_THREADS * 
MULTI_CONSUMER_ITERATIONS,
+"Counter has unexpected value.\n");
+
+   igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n");
+}
+
 igt_main
 {
igt_subtest("alloc_timeline")
@@ -239,5 +334,8 @@ igt_main
 
igt_subtest("sync_merge_same")
test_sync_merge_same();
+
+   igt_subtest("sync_multi_consumer")
+   test_sync_multi_consumer();
 }
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 01/21] lib/sw_sync: Add helper functions for managing synchronization primitives

2016-12-06 Thread 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 
Reviewed-by: Tomeu Vizoso 
---
 lib/Makefile.sources |   2 +
 lib/sw_sync.c| 196 +++
 lib/sw_sync.h|  44 
 3 files changed, 242 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 e8e277bd..7aaf42f8 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 ..a2168f78
--- /dev/null
+++ b/lib/sw_sync.c
@@ -0,0 +1,196 @@
+/*
+ * Copyright © 2016 Collabora, Ltd.
+ *
+ * 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 
+
+#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 LOCAL_SW_SYNC_IOC_MAGIC'W'
+#define LOCAL_SW_SYNC_IOC_CREATE_FENCE _IOWR(LOCAL_SW_SYNC_IOC_MAGIC, 0,\
+   struct 
sw_sync_create_fence_data)
+#define LOCAL_SW_SYNC_IOC_INC  _IOW(LOCAL_SW_SYNC_IOC_MAGIC, 
1, __u32)
+#endif
+
+/*
+ * Keep the paths for sw_sync in one place until
+ * in the kernel API.
+ */
+#define DEVFS_SW_SYNC   "/dev/sw_sync"
+#define DEBUGFS_SW_SYNC "/sys/kernel/debug/sync/sw_sync"
+
+
+static bool sw_sync_fd_is_valid(int fd)
+{
+   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_f(sw_sync_fd_is_valid(fd), "Created invalid timeline");
+
+   return fd;
+}
+
+int __sw_sync_fence_create(int fd, uint32_t seqno)
+{
+
+   struct sw_sync_create_fence_data data = {0};
+   data.value = seqno;
+
+   if (igt_ioctl(fd, LOCAL_SW_SYNC_IOC_CREATE_FENCE, &data))
+   return -errno;
+
+   return data.fence;
+}
+
+int sw_sync_fence_create(int fd, uint32_t seqno)
+{
+   int fence = __sw_sync_fence_create(fd, seqno);
+   igt_assert_f(sw_sync_fd_is_valid(fence), "Created invalid fence");
+   return fence;
+}
+
+void sw_sync_timeline_inc(int fd, uint32_t count)
+{
+   uint32_t arg = count;
+
+   do_ioctl(fd, LOCAL_SW_SYNC_IOC_INC, &arg);
+}
+
+int sync_merge(int fd1, int fd2)
+{
+   struct sync_merge_data data = {};
+   int err;
+
+   data.fd2 = fd2;
+
+   err = ioctl(fd1, SYNC_IOC_MERGE, &data);
+   if (err < 0)
+   return -errno;
+
+   return data.fence;
+}
+
+int sync_wait(int fd, int timeout)
+{
+   struct pollfd fds = {0};
+   int ret;
+
+   fds.fd = fd;
+   fds.events = POLLIN;
+
+   do {
+ret = poll(&fds, 1, timeout);
+if (ret > 0) {
+ if (fds.revents & (POLLERR | POLLNVAL)) {
+  errno = EINVAL;
+  return -1;
+ }
+

[Intel-gfx] [PATCH i-g-t v10 10/21] tests/sw_sync: Add subtest test_sync_multi_consumer_producer

2016-12-06 Thread Robert Foss
This test verifies that stressing the kernel by creating multiple
consumer/producer threads that wait on a single timeline to be incremented
by another conumer/producer thread does not fail.
And that the order amongst the threads is maintained.

Signed-off-by: Robert Foss 
Reviewed-by: Eric Engestrom 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 95 ++---
 1 file changed, 90 insertions(+), 5 deletions(-)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 5b6532c2..f32dae5a 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -102,24 +102,28 @@ static void test_sync_busy(void)
 
/* Make sure that fence has not been signaled yet */
ret = sync_wait(fence, 0);
-   igt_assert_f(ret == -1 && errno == ETIME, "Fence signaled early 
(timeline value 0, fence seqno 5)\n");
+   igt_assert_f(ret == -1 && errno == ETIME,
+   "Fence signaled early (timeline value 0, fence seqno 5)\n");
 
/* Advance timeline from 0 -> 1 */
sw_sync_timeline_inc(timeline, 1);
 
/* Make sure that fence has not been signaled yet */
ret = sync_wait(fence, 0);
-   igt_assert_f(ret == -1 && errno == ETIME, "Fence signaled early 
(timeline value 1, fence seqno 5)\n");
+   igt_assert_f(ret == -1 && errno == ETIME,
+   "Fence signaled early (timeline value 1, fence seqno 5)\n");
 
/* Advance timeline from 1 -> 5: signaling the fence (seqno 5)*/
sw_sync_timeline_inc(timeline, 4);
ret = sync_wait(fence, 0);
-   igt_assert_f(ret == 0, "Fence not signaled (timeline value 5, fence 
seqno 5)\n");
+   igt_assert_f(ret == 0,
+   "Fence not signaled (timeline value 5, fence seqno 5)\n");
 
/* Go even further, and confirm wait still succeeds */
sw_sync_timeline_inc(timeline, 5);
ret = sync_wait(fence, 0);
-   igt_assert_f(ret == 0, "Fence not signaled (timeline value 10, fence 
seqno 5)\n");
+   igt_assert_f(ret == 0,
+   "Fence not signaled (timeline value 10, fence seqno 5)\n");
 
seqno = 10;
for_each_prime_number(prime, 100) {
@@ -130,7 +134,8 @@ static void test_sync_busy(void)
sw_sync_timeline_inc(timeline, prime);
 
ret = sync_wait(fence_prime, 0);
-   igt_assert_f(ret == 0, "Fence not signaled during test of prime 
timeline increments\n");
+   igt_assert_f(ret == 0,
+   "Fence not signaled during test of prime timeline 
increments\n");
close(fence_prime);
}
 
@@ -312,6 +317,83 @@ static void test_sync_multi_consumer(void)
igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n");
 }
 
+#define MULTI_CONSUMER_PRODUCER_THREADS 8
+#define MULTI_CONSUMER_PRODUCER_ITERATIONS (1 << 14)
+static void * test_sync_multi_consumer_producer_thread(void *arg)
+{
+   data_t *data = arg;
+   int thread_id = data->thread_id;
+   int timeline = data->timeline;
+   int ret, i;
+
+   for (i = 0; i < MULTI_CONSUMER_PRODUCER_ITERATIONS; i++) {
+   int next_point = i * MULTI_CONSUMER_PRODUCER_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;
+   }
+
+   (*data->counter)++;
+
+   /* Kick off the next thread. */
+   sw_sync_timeline_inc(timeline, 1);
+
+   close(fence);
+   }
+   return NULL;
+}
+
+static void test_sync_multi_consumer_producer(void)
+{
+   data_t data_arr[MULTI_CONSUMER_PRODUCER_THREADS];
+   pthread_t thread_arr[MULTI_CONSUMER_PRODUCER_THREADS];
+   int timeline;
+   volatile uint32_t counter = 0;
+   uintptr_t thread_ret = 0;
+   data_t data;
+   int i, ret;
+
+   timeline = sw_sync_timeline_create();
+
+   data.counter = &counter;
+   data.timeline = timeline;
+
+   /* Start consumer threads. */
+   for (i = 0; i < MULTI_CONSUMER_PRODUCER_THREADS; i++)
+   {
+   data_arr[i] = data;
+   data_arr[i].thread_id = i;
+   ret = pthread_create(&thread_arr[i], NULL,
+test_sync_multi_consumer_producer_thread,
+(void *) &(data_arr[i]));
+   igt_assert_eq(ret, 0);
+   }
+
+   /* Wait for threads to complete. */
+   for (i = 0; i < MULTI_CONSUMER_PRODUCER_THREADS; i++)
+   {
+   uintptr_t local_thread_ret;
+   pthread_join(thread_arr[i], (void **)&local_thread_ret);
+   thread_ret |= local_thread_ret;
+   }
+
+   close(timeline);
+
+   igt_assert_f(counter == MULTI_CONSUMER_PRODUCER_TH

[Intel-gfx] [PATCH i-g-t v10 02/21] test/sw_sync: Add sw_sync test

2016-12-06 Thread Robert Foss
Add initial tests for sw_sync.

Signed-off-by: Robert Foss 
Signed-off-by: Gustavo Padovan 
Reviewed-by: Eric Engestrom 
Reviewed-by: Tomeu Vizoso 
---
 tests/Makefile.sources |  1 +
 tests/sw_sync.c| 51 ++
 2 files changed, 52 insertions(+)
 create mode 100644 tests/sw_sync.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 65e07922..88480945 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -131,6 +131,7 @@ TESTS_progs_M = \
prime_mmap_kms \
prime_self_import \
prime_vgem \
+   sw_sync \
template \
vgem_basic \
vgem_slow \
diff --git a/tests/sw_sync.c b/tests/sw_sync.c
new file mode 100644
index ..42fc1e2b
--- /dev/null
+++ b/tests/sw_sync.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright © 2016 Collabora, Ltd.
+ *
+ * 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 
+ */
+
+#include 
+#include 
+
+#include "igt.h"
+#include "igt_aux.h"
+
+#include "sw_sync.h"
+
+
+IGT_TEST_DESCRIPTION("Test SW Sync Framework");
+
+static void test_alloc_timeline(void)
+{
+   int timeline;
+
+   timeline = sw_sync_timeline_create();
+   close(timeline);
+}
+
+igt_main
+{
+   igt_subtest("alloc_timeline")
+   test_alloc_timeline();
+}
+
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 04/21] tests/sw_sync: Add subtest test_alloc_fence_invalid_timeline

2016-12-06 Thread Robert Foss
This subtests tests that creating fences on negative timelines fail.

Signed-off-by: Robert Foss 
Reviewed-by: Eric Engestrom 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 3db62cd0..1ec88741 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -55,6 +55,11 @@ static void test_alloc_fence(void)
close(timeline);
 }
 
+static void test_alloc_fence_invalid_timeline(void)
+{
+   igt_assert_f(__sw_sync_fence_create(-1, 0) < 0,
+   "Did not fail to create fence on invalid timeline\n");
+}
 
 igt_main
 {
@@ -63,5 +68,8 @@ igt_main
 
igt_subtest("alloc_fence")
test_alloc_fence();
+
+   igt_subtest("alloc_fence_invalid_timeline")
+   test_alloc_fence_invalid_timeline();
 }
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 11/21] tests/sw_sync: Add subtest test_sync_random_merge

2016-12-06 Thread Robert Foss
This subtest verifies that creating many timelines and merging random fences
from each timeline with eachother results in merged fences that are fully
functional.

Signed-off-by: Robert Foss 
Reviewed-by: Eric Engestrom 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 73 +
 1 file changed, 73 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index f32dae5a..81e83fc8 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -394,6 +394,76 @@ static void test_sync_multi_consumer_producer(void)
igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n");
 }
 
+static void test_sync_random_merge(void)
+{
+   int i, size, ret;
+   const int nbr_timeline = 32;
+   const int nbr_merge = 1024;
+   int fence_map[nbr_timeline];
+   int timeline_arr[nbr_timeline];
+   int fence, tmpfence, merged;
+   int timeline, timeline_offset, sync_pt;
+
+   srand(time(NULL));
+
+   for (i = 0; i < nbr_timeline; i++) {
+   timeline_arr[i] = sw_sync_timeline_create();
+   fence_map[i] = -1;
+   }
+
+   sync_pt = rand();
+   fence = sw_sync_fence_create(timeline_arr[0], sync_pt);
+
+   fence_map[0] = sync_pt;
+
+   /* Randomly create syncpoints out of a fixed set of timelines,
+* and merge them together.
+*/
+   for (i = 0; i < nbr_merge; i++) {
+   /* Generate syncpoint. */
+   timeline_offset = rand() % nbr_timeline;
+   timeline = timeline_arr[timeline_offset];
+   sync_pt = rand();
+
+   /* Keep track of the latest sync_pt in each timeline. */
+   if (fence_map[timeline_offset] == -1)
+   fence_map[timeline_offset] = sync_pt;
+   else if (fence_map[timeline_offset] < sync_pt)
+   fence_map[timeline_offset] = sync_pt;
+
+   /* Merge. */
+   tmpfence = sw_sync_fence_create(timeline, sync_pt);
+   merged = sync_merge(tmpfence, fence);
+   close(tmpfence);
+   close(fence);
+   fence = merged;
+   }
+
+   size = 0;
+   for (i = 0; i < nbr_timeline; i++)
+   if (fence_map[i] != -1)
+   size++;
+
+   /* Trigger the merged fence. */
+   for (i = 0; i < nbr_timeline; i++) {
+   if (fence_map[i] != -1) {
+   ret = sync_wait(fence, 0);
+   igt_assert_f(ret == -1 && errno == ETIME,
+   "Failure waiting on fence until timeout\n");
+   /* Increment the timeline to the last sync_pt */
+   sw_sync_timeline_inc(timeline_arr[i], fence_map[i]);
+   }
+   }
+
+   /* Check that the fence is triggered. */
+   ret = sync_wait(fence, 0);
+   igt_assert_f(ret == 0, "Failure triggering fence\n");
+
+   close(fence);
+   for (i = 0; i < nbr_timeline; i++)
+   close(timeline_arr[i]);
+}
+
 igt_main
 {
igt_subtest("alloc_timeline")
@@ -422,5 +492,8 @@ igt_main
 
igt_subtest("sync_multi_consumer_producer")
test_sync_multi_consumer_producer();
+
+   igt_subtest("sync_random_merge")
+   test_sync_random_merge();
 }
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 00/21] Implement sw_sync test

2016-12-06 Thread 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


Changes since v9:

Added: Reviewed-by: Tomeu Vizoso 
Made asserts more informative

  tests/sw_sync:
- Removed nbr_threads from data_t
- Removed nbr_iterations from data_t
  lib/sw_sync:
- Removed undue Google/AOSP attribution
- Added LOCAL_ prefix to some defines
- Added comment for sw_sync path defines
- Changed return type of sw_sync_fd_is_valid to bool
- Made sw_sync_fd_is_valid internal to lib/sw_sync
- Remove dead sw_sync_fd_is_valid call from sync_merge
- Initialize structs at declaration instead of using memset


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  | 219 +++
 lib/sw_sync.h  |  45 +++
 tests/Makefile.sources |   1 +
 tests/sw_sync.c| 956 +
 5 files changed, 1223 insertions(+)
 create mode 100644 lib/sw_sync.c
 create mode 100644 lib/sw_sync.h
 create mode 100644 tests/sw_sync.c

-- 
2.11.0


[Intel-gfx] [PATCH i-g-t v10 05/21] tests/sw_sync: Add subtest test_alloc_merge_fence

2016-12-06 Thread Robert Foss
This subtest verifies that merging two fences works in the simples possible
case.

Signed-off-by: Robert Foss 
Reviewed-by: Eric Engestrom 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 1ec88741..1af571bb 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -61,6 +61,26 @@ static void test_alloc_fence_invalid_timeline(void)
"Did not fail to create fence on invalid timeline\n");
 }
 
+static void test_alloc_merge_fence(void)
+{
+   int in_fence[2];
+   int fence_merge;
+   int timeline[2];
+
+   timeline[0] = sw_sync_timeline_create();
+   timeline[1] = sw_sync_timeline_create();
+
+   in_fence[0] = sw_sync_fence_create(timeline[0], 1);
+   in_fence[1] = sw_sync_fence_create(timeline[1], 1);
+   fence_merge = sync_merge(in_fence[1], in_fence[0]);
+
+   close(in_fence[0]);
+   close(in_fence[1]);
+   close(fence_merge);
+   close(timeline[0]);
+   close(timeline[1]);
+}
+
 igt_main
 {
igt_subtest("alloc_timeline")
@@ -71,5 +91,8 @@ igt_main
 
igt_subtest("alloc_fence_invalid_timeline")
test_alloc_fence_invalid_timeline();
+
+   igt_subtest("alloc_merge_fence")
+   test_alloc_merge_fence();
 }
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 14/21] tests/sw_sync: Add subtest test_sync_expired_merge

2016-12-06 Thread Robert Foss
From: Rafael Antognolli 

This test creates an already expired fence, then creates a merged fence
out of that expired one (passed twice to the merge operation), and
finally closes the merged fence. It shows that if the refcounts are
wrong on the original expired fence, it might get freed while still in
use. Usually a kernel panick will follow.

Signed-off-by: Rafael Antognolli 
Signed-off-by: Robert Foss 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 13a9602f..572efc3b 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -593,6 +593,34 @@ static void test_sync_multi_producer_single_consumer(void)
pthread_join(threads[i], NULL);
 }
 
+static void test_sync_expired_merge(void)
+{
+   int iterations = 1 << 20;
+   int timeline;
+   int i;
+   int fence_expired, fence_merged;
+
+   timeline = sw_sync_timeline_create();
+
+   sw_sync_timeline_inc(timeline, 100);
+   fence_expired = sw_sync_fence_create(timeline, 1);
+   igt_assert_f(sync_wait(fence_expired, 0) == 0,
+"Failure waiting for expired fence\n");
+
+   fence_merged = sync_merge(fence_expired, fence_expired);
+   close(fence_merged);
+
+   for (i = 0; i < iterations; i++) {
+   int fence = sync_merge(fence_expired, fence_expired);
+
+   igt_assert_f(sync_wait(fence, -1) == 0,
+"Failure waiting on fence\n");
+   close(fence);
+   }
+
+   close(fence_expired);
+}
+
 static void test_sync_random_merge(void)
 {
int i, size, ret;
@@ -698,6 +726,9 @@ igt_main
igt_subtest("sync_multi_producer_single_consumer")
test_sync_multi_producer_single_consumer();
 
+   igt_subtest("sync_expired_merge")
+   test_sync_expired_merge();
+
igt_subtest("sync_random_merge")
test_sync_random_merge();
 }
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 03/21] tests/sw_sync: Add subtest test_alloc_fence

2016-12-06 Thread Robert Foss
Add subtest alloc_fence that verifies that it's possible to allocate a fence
on a timeline.

Signed-off-by: Robert Foss 
Reviewed-by: Eric Engestrom 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 42fc1e2b..3db62cd0 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -43,9 +43,25 @@ static void test_alloc_timeline(void)
close(timeline);
 }
 
+static void test_alloc_fence(void)
+{
+   int in_fence;
+   int timeline;
+
+   timeline = sw_sync_timeline_create();
+   in_fence = sw_sync_fence_create(timeline, 0);
+
+   close(in_fence);
+   close(timeline);
+}
+
+
 igt_main
 {
igt_subtest("alloc_timeline")
test_alloc_timeline();
+
+   igt_subtest("alloc_fence")
+   test_alloc_fence();
 }
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 12/21] tests/sw_sync: Add subtest test_sync_multi_timeline_wait

2016-12-06 Thread Robert Foss
This subtest verifies that waiting, timing out on a wait and that counting
fences in various states works.

Signed-off-by: Robert Foss 
Reviewed-by: Eric Engestrom 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 66 +
 1 file changed, 66 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 81e83fc8..b0bd2ad4 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -231,6 +231,69 @@ static void test_sync_merge_same(void)
close(timeline);
 }
 
+static void test_sync_multi_timeline_wait(void)
+{
+   int timeline[3];
+   int in_fence[3];
+   int fence_merge;
+   int active, signaled, ret;
+
+   timeline[0] = sw_sync_timeline_create();
+   timeline[1] = sw_sync_timeline_create();
+   timeline[2] = sw_sync_timeline_create();
+
+   in_fence[0] = sw_sync_fence_create(timeline[0], 5);
+   in_fence[1] = sw_sync_fence_create(timeline[1], 5);
+   in_fence[2] = sw_sync_fence_create(timeline[2], 5);
+
+   fence_merge = sync_merge(in_fence[0], in_fence[1]);
+   fence_merge = sync_merge(in_fence[2], fence_merge);
+
+   /* Confirm fence isn't signaled */
+   active = sync_fence_count_status(fence_merge,
+   SW_SYNC_FENCE_STATUS_ACTIVE);
+   igt_assert_f(active == 3, "Fence signaled too early\n");
+
+   ret = sync_wait(fence_merge, 0);
+   igt_assert_f(ret == -1 && errno == ETIME, "Failure waiting on fence 
until timeout\n");
+
+   sw_sync_timeline_inc(timeline[0], 5);
+   active = sync_fence_count_status(fence_merge,
+   SW_SYNC_FENCE_STATUS_ACTIVE);
+   signaled = sync_fence_count_status(fence_merge,
+ SW_SYNC_FENCE_STATUS_SIGNALED);
+   igt_assert_f(active == 2 && signaled == 1,
+   "Fence did not signal properly\n");
+
+   sw_sync_timeline_inc(timeline[1], 5);
+   active = sync_fence_count_status(fence_merge,
+   SW_SYNC_FENCE_STATUS_ACTIVE);
+   signaled = sync_fence_count_status(fence_merge,
+ SW_SYNC_FENCE_STATUS_SIGNALED);
+   igt_assert_f(active == 1 && signaled == 2,
+   "Fence did not signal properly\n");
+
+   sw_sync_timeline_inc(timeline[2], 5);
+   active = sync_fence_count_status(fence_merge,
+   SW_SYNC_FENCE_STATUS_ACTIVE);
+   signaled = sync_fence_count_status(fence_merge,
+ SW_SYNC_FENCE_STATUS_SIGNALED);
+   igt_assert_f(active == 0 && signaled == 3,
+"Fence did not signal properly\n");
+
+   /* confirm you can successfully wait */
+   ret = sync_wait(fence_merge, 100);
+   igt_assert_f(ret == 0, "Failure waiting on signaled fence\n");
+
+   close(in_fence[0]);
+   close(in_fence[1]);
+   close(in_fence[2]);
+   close(fence_merge);
+   close(timeline[0]);
+   close(timeline[1]);
+   close(timeline[2]);
+}
+
 #define MULTI_CONSUMER_THREADS 8
 #define MULTI_CONSUMER_ITERATIONS (1 << 14)
 static void * test_sync_multi_consumer_thread(void *arg)
@@ -487,6 +550,9 @@ igt_main
igt_subtest("sync_merge_same")
test_sync_merge_same();
 
+   igt_subtest("sync_multi_timeline_wait")
+   test_sync_multi_timeline_wait();
+
igt_subtest("sync_multi_consumer")
test_sync_multi_consumer();
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 13/21] tests/sw_sync: Add subtest test_sync_multi_producer_single_consumer

2016-12-06 Thread Robert Foss
This subtest runs a single consumer thread and multiple producer thread that
are synchronized using multiple timelines.

Signed-off-by: Robert Foss 
Reviewed-by: Eric Engestrom 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 139 
 1 file changed, 139 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index b0bd2ad4..13a9602f 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -457,6 +457,142 @@ static void test_sync_multi_consumer_producer(void)
igt_assert_f(thread_ret == 0, "A sync thread reported failure.\n");
 }
 
+static int test_mspc_wait_on_fence(int fence)
+{
+   int error, active;
+
+   do {
+   error = sync_fence_count_status(fence,
+  SW_SYNC_FENCE_STATUS_ERROR);
+   igt_assert_f(error == 0, "Error occurred on fence\n");
+   active = sync_fence_count_status(fence,
+   
SW_SYNC_FENCE_STATUS_ACTIVE);
+   } while (active);
+
+   return 0;
+}
+
+static struct {
+   int iterations;
+   int threads;
+   int counter;
+   int cons_timeline;
+   int *prod_timeline;
+   pthread_mutex_t lock;
+} test_mpsc_data;
+
+static int mpsc_producer_thread(void *d)
+{
+   int id = (long)d;
+   int fence, i;
+   int *prod_timeline = test_mpsc_data.prod_timeline;
+   int cons_timeline = test_mpsc_data.cons_timeline;
+   int iterations = test_mpsc_data.iterations;
+
+   for (i = 0; i < iterations; i++) {
+   fence = sw_sync_fence_create(cons_timeline, i);
+
+   /* Wait for the consumer to finish. Use alternate
+* means of waiting on the fence
+*/
+   if ((iterations + id) % 8 != 0) {
+   igt_assert_f(sync_wait(fence, -1) == 0,
+"Failure waiting on fence\n");
+   } else {
+   igt_assert_f(test_mspc_wait_on_fence(fence) == 0,
+"Failure waiting on fence\n");
+   }
+
+   /* Every producer increments the counter, the consumer
+* checks and erases it
+*/
+   pthread_mutex_lock(&test_mpsc_data.lock);
+   test_mpsc_data.counter++;
+   pthread_mutex_unlock(&test_mpsc_data.lock);
+
+   sw_sync_timeline_inc(prod_timeline[id], 1);
+   close(fence);
+   }
+
+   return 0;
+}
+
+static int mpsc_consumer_thread(void)
+{
+   int fence, merged, tmp, it, i;
+   int *prod_timeline = test_mpsc_data.prod_timeline;
+   int cons_timeline = test_mpsc_data.cons_timeline;
+   int iterations = test_mpsc_data.iterations;
+   int n = test_mpsc_data.threads;
+
+   for (it = 1; it <= iterations; it++) {
+   fence = sw_sync_fence_create(prod_timeline[0], it);
+   for (i = 1; i < n; i++) {
+   tmp = sw_sync_fence_create(prod_timeline[i], it);
+   merged = sync_merge(tmp, fence);
+   close(tmp);
+   close(fence);
+   fence = merged;
+   }
+
+   /* Make sure we see an increment from every producer thread.
+* Vary the means by which we wait.
+*/
+   if (iterations % 8 != 0) {
+   igt_assert_f(sync_wait(fence, -1) == 0,
+   "Producers did not increment as 
expected\n");
+   } else {
+   igt_assert_f(test_mspc_wait_on_fence(fence) == 0,
+"Failure waiting on fence\n");
+   }
+
+   igt_assert_f(test_mpsc_data.counter == n * it,
+"Counter value mismatch\n");
+
+   /* Release the producer threads */
+   sw_sync_timeline_inc(cons_timeline, 1);
+   close(fence);
+   }
+
+   return 0;
+}
+
+/* IMPORTANT NOTE: if you see this test failing on your system, it may be
+ * due to a shortage of file descriptors. Please ensure your system has
+ * a sensible limit for this test to finish correctly.
+ */
+static void test_sync_multi_producer_single_consumer(void)
+{
+   int iterations = 1 << 12;
+   int n = 5;
+   int prod_timeline[n];
+   int cons_timeline;
+   pthread_t threads[n];
+   long i;
+
+   cons_timeline = sw_sync_timeline_create();
+   for (i = 0; i < n; i++)
+   prod_timeline[i] = sw_sync_timeline_create();
+
+   test_mpsc_data.prod_timeline = prod_timeline;
+   test_mpsc_data.cons_timeline = cons_timeline;
+   test_mpsc_data.iterations = iterations;
+   test_mpsc_data.threads = n;
+   test_mpsc_data.counter = 0;
+   pthread_mutex_init(&test_mpsc_data.lock, NULL);
+
+   for (i = 0; i < n;

[Intel-gfx] [PATCH i-g-t v10 07/21] tests/sw_sync: Add subtest test_sync_merge

2016-12-06 Thread Robert Foss
Add subtest test_sync_merge that tests merging fences and the validity of the
resulting merged fence.

Signed-off-by: Robert Foss 
Reviewed-by: Eric Engestrom 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 67 +
 1 file changed, 67 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 075791fd..7780c9e1 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -129,6 +129,70 @@ static void test_sync_busy(void)
close(timeline);
 }
 
+static void test_sync_merge(void)
+{
+   int in_fence[3];
+   int fence_merge;
+   int timeline;
+   int active, signaled;
+
+   timeline = sw_sync_timeline_create();
+   in_fence[0] = sw_sync_fence_create(timeline, 1);
+   in_fence[1] = sw_sync_fence_create(timeline, 2);
+   in_fence[2] = sw_sync_fence_create(timeline, 3);
+
+   fence_merge = sync_merge(in_fence[0], in_fence[1]);
+   fence_merge = sync_merge(in_fence[2], fence_merge);
+
+   /* confirm all fences have one active point (even d) */
+   active = sync_fence_count_status(in_fence[0],
+   SW_SYNC_FENCE_STATUS_ACTIVE);
+   igt_assert_f(active == 1, "in_fence[0] has too many active fences\n");
+   active = sync_fence_count_status(in_fence[1],
+   SW_SYNC_FENCE_STATUS_ACTIVE);
+   igt_assert_f(active == 1, "in_fence[1] has too many active fences\n");
+   active = sync_fence_count_status(in_fence[2],
+   SW_SYNC_FENCE_STATUS_ACTIVE);
+   igt_assert_f(active == 1, "in_fence[2] has too many active fences\n");
+   active = sync_fence_count_status(fence_merge,
+   SW_SYNC_FENCE_STATUS_ACTIVE);
+   igt_assert_f(active == 1, "fence_merge has too many active fences\n");
+
+   /* confirm that fence_merge is not signaled until the max of fence 
0,1,2 */
+   sw_sync_timeline_inc(timeline, 1);
+   signaled = sync_fence_count_status(in_fence[0],
+ SW_SYNC_FENCE_STATUS_SIGNALED);
+   active = sync_fence_count_status(fence_merge,
+   SW_SYNC_FENCE_STATUS_ACTIVE);
+   igt_assert_f(signaled == 1, "in_fence[0] did not signal\n");
+   igt_assert_f(active == 1, "fence_merge signaled too early\n");
+
+   sw_sync_timeline_inc(timeline, 1);
+   signaled = sync_fence_count_status(in_fence[1],
+ SW_SYNC_FENCE_STATUS_SIGNALED);
+   active = sync_fence_count_status(fence_merge,
+   SW_SYNC_FENCE_STATUS_ACTIVE);
+   igt_assert_f(signaled == 1, "in_fence[1] did not signal\n");
+   igt_assert_f(active == 1, "fence_merge signaled too early\n");
+
+   sw_sync_timeline_inc(timeline, 1);
+   signaled = sync_fence_count_status(in_fence[2],
+ SW_SYNC_FENCE_STATUS_SIGNALED);
+   igt_assert_f(signaled == 1, "in_fence[2] did not signal\n");
+   signaled = sync_fence_count_status(fence_merge,
+  SW_SYNC_FENCE_STATUS_SIGNALED);
+   active = sync_fence_count_status(fence_merge,
+   SW_SYNC_FENCE_STATUS_ACTIVE);
+   igt_assert_f(active == 0 && signaled == 1,
+"fence_merge did not signal\n");
+
+   close(in_fence[0]);
+   close(in_fence[1]);
+   close(in_fence[2]);
+   close(fence_merge);
+   close(timeline);
+}
+
 igt_main
 {
igt_subtest("alloc_timeline")
@@ -145,5 +209,8 @@ igt_main
 
igt_subtest("sync_busy")
test_sync_busy();
+
+   igt_subtest("sync_merge")
+   test_sync_merge();
 }
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 20/21] tests/sw_sync: Add subtest test_sync_busy_fork

2016-12-06 Thread Robert Foss
Add subtest test_sync_busy_fork which increments the timeline in a forked child
process.

Signed-off-by: Robert Foss 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 3c876e03..c64bb80e 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -172,6 +172,42 @@ static void test_sync_busy(void)
close(timeline);
 }
 
+static void test_sync_busy_fork(void)
+{
+   int fence, ret;
+   int timeline;
+   int skip = 0;
+
+   timeline = sw_sync_timeline_create();
+   fence = sw_sync_fence_create(timeline, 1);
+
+   switch (fork()) {
+   case 0:
+   /* Child process */
+   usleep(1*1000*1000);
+   /* Advance timeline from 0 -> 1 */
+   sw_sync_timeline_inc(timeline, 1);
+   _Exit(0);
+   break;
+   case -1:
+   /* Failed fork */
+   skip = 1;
+   break;
+   default:
+   /* Parent process */
+   ret = sync_wait(fence, 0);
+   igt_assert_f(ret == -1 && errno == ETIME, "Fence signaled (it 
should not have been signalled yet)\n");
+
+   ret = sync_wait(fence, 2*1000);
+   igt_assert_f(ret == 0, "Fence not signaled (timeline value 1 
fence seqno 1)\n");
+   break;
+   }
+
+   close(fence);
+   close(timeline);
+   igt_require(!skip);
+}
+
 static void test_sync_merge_invalid(void)
 {
int in_fence;
@@ -784,6 +820,9 @@ igt_main
igt_subtest("sync_busy")
test_sync_busy();
 
+   igt_subtest("sync_busy_fork")
+   test_sync_busy_fork();
+
igt_subtest("sync_merge_invalid")
test_sync_merge_invalid();
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 16/21] tests/sw_sync: Add subtest test_timeline_closed_signaled

2016-12-06 Thread Robert Foss
Add subtest test_timeline_closed_signaled that verifies that a signaled fence
stays signaled after its timeline has been closed.

Signed-off-by: Robert Foss 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 1de45277..f990818d 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -85,6 +85,21 @@ static void test_timeline_closed(void)
 "Failure waiting on unsignaled fence on closed timeline\n");
 }
 
+static void test_timeline_closed_signaled(void)
+{
+   int fence, ret;
+   int timeline;
+
+   timeline = sw_sync_timeline_create();
+   fence = sw_sync_fence_create(timeline, 1);
+
+   sw_sync_timeline_inc(timeline, 1);
+   close(timeline);
+   ret = sync_wait(fence, 0);
+   igt_assert_f(ret == 0,
+"Failure waiting on signaled fence for closed timeline\n");
+}
+
 static void test_alloc_merge_fence(void)
 {
int in_fence[2];
@@ -719,6 +734,9 @@ igt_main
igt_subtest("timeline_closed")
test_timeline_closed();
 
+   igt_subtest("timeline_closed_signaled")
+   test_timeline_closed_signaled();
+
igt_subtest("alloc_merge_fence")
test_alloc_merge_fence();
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 18/21] tests/sw_sync: Add igt_require check for sw_sync feature

2016-12-06 Thread Robert Foss
Make sure that this test is skipped if the sw_sync feature is missing from
the host system.

Signed-off-by: Robert Foss 
Reviewed-by: Tomeu Vizoso 
---
 lib/sw_sync.c   | 1 +
 tests/sw_sync.c | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/lib/sw_sync.c b/lib/sw_sync.c
index d4ecc898..614554a6 100644
--- a/lib/sw_sync.c
+++ b/lib/sw_sync.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 
+#include "igt_debugfs.h"
 #include "sw_sync.h"
 #include "drmtest.h"
 #include "ioctl_wrappers.h"
diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index f990818d..5bccb053 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -722,6 +722,9 @@ static void test_sync_random_merge(void)
 
 igt_main
 {
+   igt_fixture
+   igt_require_sw_sync();
+
igt_subtest("alloc_timeline")
test_alloc_timeline();
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 17/21] lib/sw_sync: Add igt_require_sw_sync to enable skipping on no sw_sync support

2016-12-06 Thread Robert Foss
Add igt_require_sw_sync to provide tests to skip if sw_sync support isn't
available on the host machine.

Signed-off-by: Robert Foss 
Reviewed-by: Tomeu Vizoso 
---
 lib/sw_sync.c | 22 ++
 lib/sw_sync.h |  1 +
 2 files changed, 23 insertions(+)

diff --git a/lib/sw_sync.c b/lib/sw_sync.c
index a2168f78..d4ecc898 100644
--- a/lib/sw_sync.c
+++ b/lib/sw_sync.c
@@ -194,3 +194,25 @@ int sync_fence_count_status(int fd, int status)
igt_assert_f(count >= 0, "No fences with supplied status found");
return count;
 }
+
+static bool kernel_has_sw_sync(void)
+{
+   bool err;
+
+   igt_ignore_warn(system("/sbin/modprobe -s r sw_sync"));
+
+   err = false;
+   if (access(DEVFS_SW_SYNC, R_OK | W_OK) < 0) {
+   char buf[128];
+
+   snprintf(buf, sizeof(buf), "%s/sw_sync", igt_debugfs_mount());
+   err = access(DEBUGFS_SW_SYNC, R_OK | W_OK) < 0;
+   }
+
+   return !err;
+}
+
+void igt_require_sw_sync(void)
+{
+   igt_require(kernel_has_sw_sync());
+}
diff --git a/lib/sw_sync.h b/lib/sw_sync.h
index cea5a603..82af3378 100644
--- a/lib/sw_sync.h
+++ b/lib/sw_sync.h
@@ -39,6 +39,7 @@ int sync_merge(int fd1, int fd2);
 int sync_wait(int fence, int timeout);
 int sync_fence_count(int fd);
 int sync_fence_count_status(int fd, int status);
+void igt_require_sw_sync(void);
 
 #endif
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 15/21] tests/sw_sync: Add subtest test_timeline_closed

2016-12-06 Thread Robert Foss
This subtest verifies that the fences of a timeline are not signalled when
a timelne is closed.

Signed-off-by: Robert Foss 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 572efc3b..1de45277 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -71,6 +71,20 @@ static void test_alloc_fence_invalid_timeline(void)
"Did not fail to create fence on invalid timeline\n");
 }
 
+static void test_timeline_closed(void)
+{
+   int fence, ret;
+   int timeline;
+
+   timeline = sw_sync_timeline_create();
+   fence = sw_sync_fence_create(timeline, 1);
+
+   close(timeline);
+   ret = sync_wait(fence, 0);
+   igt_assert_f(ret == -1 && errno == ETIME,
+"Failure waiting on unsignaled fence on closed timeline\n");
+}
+
 static void test_alloc_merge_fence(void)
 {
int in_fence[2];
@@ -702,6 +716,9 @@ igt_main
igt_subtest("alloc_fence_invalid_timeline")
test_alloc_fence_invalid_timeline();
 
+   igt_subtest("timeline_closed")
+   test_timeline_closed();
+
igt_subtest("alloc_merge_fence")
test_alloc_merge_fence();
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 08/21] tests/sw_sync: Add subtest test_sync_merge_same

2016-12-06 Thread Robert Foss
This subtest verifies merging a fence with itself does not fail.

Signed-off-by: Robert Foss 
Reviewed-by: Eric Engestrom 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 7780c9e1..c0eade51 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -193,6 +193,30 @@ static void test_sync_merge(void)
close(timeline);
 }
 
+static void test_sync_merge_same(void)
+{
+   int in_fence[2];
+   int timeline;
+   int signaled;
+
+   timeline = sw_sync_timeline_create();
+   in_fence[0] = sw_sync_fence_create(timeline, 1);
+   in_fence[1] = sync_merge(in_fence[0], in_fence[0]);
+
+   signaled = sync_fence_count_status(in_fence[0],
+ SW_SYNC_FENCE_STATUS_SIGNALED);
+   igt_assert_f(signaled == 0, "Fence signaled too early\n");
+
+   sw_sync_timeline_inc(timeline, 1);
+   signaled = sync_fence_count_status(in_fence[0],
+ SW_SYNC_FENCE_STATUS_SIGNALED);
+   igt_assert_f(signaled == 1, "Fence did not signal\n");
+
+   close(in_fence[0]);
+   close(in_fence[1]);
+   close(timeline);
+}
+
 igt_main
 {
igt_subtest("alloc_timeline")
@@ -212,5 +236,8 @@ igt_main
 
igt_subtest("sync_merge")
test_sync_merge();
+
+   igt_subtest("sync_merge_same")
+   test_sync_merge_same();
 }
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 21/21] tests/sw_sync: Add subtest test_sync_busy_unixsocket

2016-12-06 Thread Robert Foss
Add subtest test_sync_busy_fork which increments the timeline in a forked child
process, where the timeline fd has been sent through a UNIX socket.

Signed-off-by: Robert Foss 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 103 
 1 file changed, 103 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index c64bb80e..7a428c86 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -27,6 +27,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #include "igt.h"
@@ -172,6 +174,104 @@ static void test_sync_busy(void)
close(timeline);
 }
 
+static void test_sync_busy_fork_unixsocket(void)
+{
+   int fence, ret;
+   int timeline;
+   int skip = 0;
+   int sv[2];
+
+
+   timeline = sw_sync_timeline_create();
+   fence = sw_sync_fence_create(timeline, 1);
+
+   if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sv) != 0) {
+   skip = 1;
+   goto out;
+   }
+
+   switch (fork()) {
+   case 0:
+   {
+   /* Child process */
+   int socket = sv[1];
+   int socket_timeline;
+   struct msghdr msg = {0};
+   struct cmsghdr *cmsg;
+   unsigned char *data;
+   char m_buffer[256];
+   char c_buffer[256];
+   struct iovec io = { .iov_base = m_buffer, .iov_len = 
sizeof(m_buffer) };
+   close(sv[0]);
+
+   msg.msg_iov = &io;
+   msg.msg_iovlen = 1;
+   msg.msg_control = c_buffer;
+   msg.msg_controllen = sizeof(c_buffer);
+
+   if (recvmsg(socket, &msg, 0) < 0)
+   _Exit(1);
+
+   cmsg = CMSG_FIRSTHDR(&msg);
+   data = CMSG_DATA(cmsg);
+   socket_timeline = *((int *) data);
+
+   /* Advance timeline from 0 -> 1 */
+   sw_sync_timeline_inc(socket_timeline, 1);
+
+   _Exit(0);
+   break;
+   }
+   case -1:
+   {
+   /* Failed fork */
+   skip = 1;
+   break;
+   }
+   default:
+   {
+   /* Parent process */
+   int socket = sv[0];
+   struct cmsghdr *cmsg;
+   struct iovec io = { .iov_base = (char *)"ABC", .iov_len = 3 };
+   struct msghdr msg = { 0 };
+   char buf[CMSG_SPACE(sizeof(timeline))];
+   memset(buf, '\0', sizeof(buf));
+   close(sv[1]);
+
+   msg.msg_iov = &io;
+   msg.msg_iovlen = 1;
+   msg.msg_control = buf;
+   msg.msg_controllen = sizeof(buf);
+
+   cmsg = CMSG_FIRSTHDR(&msg);
+   cmsg->cmsg_level = SOL_SOCKET;
+   cmsg->cmsg_type = SCM_RIGHTS;
+   cmsg->cmsg_len = CMSG_LEN(sizeof(timeline));
+
+   *((int *) CMSG_DATA(cmsg)) = timeline;
+   msg.msg_controllen = cmsg->cmsg_len;
+
+   ret = sync_wait(fence, 0);
+   igt_assert_f(ret == -1 && errno == ETIME, "Fence signaled (it 
should not have been signalled yet)\n");
+
+   if (sendmsg(socket, &msg, 0) < 0) {
+   skip = 1;
+   goto out;
+   }
+
+   ret = sync_wait(fence, 2*1000);
+   igt_assert_f(ret == 0, "Fence not signaled (timeline value 1 
fence seqno 1)\n");
+   break;
+   }
+   }
+
+out:
+   close(fence);
+   close(timeline);
+   igt_require(!skip);
+}
+
 static void test_sync_busy_fork(void)
 {
int fence, ret;
@@ -823,6 +923,9 @@ igt_main
igt_subtest("sync_busy_fork")
test_sync_busy_fork();
 
+   igt_subtest("sync_busy_fork_unixsocket")
+   test_sync_busy_fork_unixsocket();
+
igt_subtest("sync_merge_invalid")
test_sync_merge_invalid();
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 19/21] tests/sw_sync: Add subtest test_sync_merge_invalid

2016-12-06 Thread Robert Foss
Add subtest test_sync_merge_invalid that tests merging invalid fences.

Signed-off-by: Robert Foss 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 41 +
 1 file changed, 41 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 5bccb053..3c876e03 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -172,6 +172,44 @@ static void test_sync_busy(void)
close(timeline);
 }
 
+static void test_sync_merge_invalid(void)
+{
+   int in_fence;
+   int fence_invalid;
+   int fence_merge;
+   int timeline;
+   char tmppath[] = "/tmp/igt-XX";
+   int skip = 0;
+
+   timeline = sw_sync_timeline_create();
+   in_fence = sw_sync_fence_create(timeline, 1);
+
+   fence_invalid = -1;
+   fence_merge = sync_merge(in_fence, fence_invalid);
+   igt_assert_f(fence_merge < 0, "Verify invalid fd (-1) handling");
+
+   fence_invalid = drm_open_driver(DRIVER_ANY);
+   fence_merge = sync_merge(in_fence, fence_invalid);
+   igt_assert_f(fence_merge < 0, "Verify invalid fd (device fd) handling");
+
+   fence_invalid = mkstemp(tmppath);
+   if (fence_invalid == -1) {
+   skip = 1;
+   goto out;
+   }
+   unlink(tmppath);
+   fence_invalid = drm_open_driver(DRIVER_ANY);
+   fence_merge = sync_merge(in_fence, fence_invalid);
+   close(fence_invalid);
+   igt_assert_f(fence_merge < 0, "Verify invalid fd (file fd) handling");
+
+out:
+   close(in_fence);
+   close(fence_merge);
+   close(timeline);
+   igt_require(skip == 0);
+}
+
 static void test_sync_merge(void)
 {
int in_fence[3];
@@ -746,6 +784,9 @@ igt_main
igt_subtest("sync_busy")
test_sync_busy();
 
+   igt_subtest("sync_merge_invalid")
+   test_sync_merge_invalid();
+
igt_subtest("sync_merge")
test_sync_merge();
 
-- 
2.11.0

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


[Intel-gfx] [PATCH i-g-t v10 06/21] tests/sw_sync: Add subtest test_sync_busy

2016-12-06 Thread Robert Foss
This subtest verifies that waiting on fences works properly.

Signed-off-by: Robert Foss 
Reviewed-by: Eric Engestrom 
Reviewed-by: Tomeu Vizoso 
---
 tests/sw_sync.c | 51 +++
 1 file changed, 51 insertions(+)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 1af571bb..075791fd 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -29,6 +29,7 @@
 
 #include "igt.h"
 #include "igt_aux.h"
+#include "igt_primes.h"
 
 #include "sw_sync.h"
 
@@ -81,6 +82,53 @@ static void test_alloc_merge_fence(void)
close(timeline[1]);
 }
 
+static void test_sync_busy(void)
+{
+   int fence, ret;
+   int timeline;
+   int seqno;
+
+   timeline = sw_sync_timeline_create();
+   fence = sw_sync_fence_create(timeline, 5);
+
+   /* Make sure that fence has not been signaled yet */
+   ret = sync_wait(fence, 0);
+   igt_assert_f(ret == -1 && errno == ETIME, "Fence signaled early 
(timeline value 0, fence seqno 5)\n");
+
+   /* Advance timeline from 0 -> 1 */
+   sw_sync_timeline_inc(timeline, 1);
+
+   /* Make sure that fence has not been signaled yet */
+   ret = sync_wait(fence, 0);
+   igt_assert_f(ret == -1 && errno == ETIME, "Fence signaled early 
(timeline value 1, fence seqno 5)\n");
+
+   /* Advance timeline from 1 -> 5: signaling the fence (seqno 5)*/
+   sw_sync_timeline_inc(timeline, 4);
+   ret = sync_wait(fence, 0);
+   igt_assert_f(ret == 0, "Fence not signaled (timeline value 5, fence 
seqno 5)\n");
+
+   /* Go even further, and confirm wait still succeeds */
+   sw_sync_timeline_inc(timeline, 5);
+   ret = sync_wait(fence, 0);
+   igt_assert_f(ret == 0, "Fence not signaled (timeline value 10, fence 
seqno 5)\n");
+
+   seqno = 10;
+   for_each_prime_number(prime, 100) {
+   int fence_prime;
+   seqno += prime;
+
+   fence_prime = sw_sync_fence_create(timeline, seqno);
+   sw_sync_timeline_inc(timeline, prime);
+
+   ret = sync_wait(fence_prime, 0);
+   igt_assert_f(ret == 0, "Fence not signaled during test of prime 
timeline increments\n");
+   close(fence_prime);
+   }
+
+   close(fence);
+   close(timeline);
+}
+
 igt_main
 {
igt_subtest("alloc_timeline")
@@ -94,5 +142,8 @@ igt_main
 
igt_subtest("alloc_merge_fence")
test_alloc_merge_fence();
+
+   igt_subtest("sync_busy")
+   test_sync_busy();
 }
 
-- 
2.11.0

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


[Intel-gfx] [PATCH] tools/backlight_helper: #include "config.h"

2016-12-06 Thread Mike Frysinger
From: Mike Gilbert 

---
 tools/backlight_helper.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/tools/backlight_helper.c b/tools/backlight_helper.c
index a00f0d6bd8a2..aadb8fac92ba 100644
--- a/tools/backlight_helper.c
+++ b/tools/backlight_helper.c
@@ -1,3 +1,7 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include 
 #include 
 #include 
-- 
2.11.0.rc2

___
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


Re: [Intel-gfx] [RFC 5/5] drm: Do not log driver prefix in debug messages

2016-12-06 Thread Tvrtko Ursulin


Hi,

On 06/12/2016 19:49, Gustavo Padovan wrote:

Hi Tvrtko,

2016-12-06 Tvrtko Ursulin :


From: Tvrtko Ursulin 

Driver prefix is a bit redundant in debug messages. If we choose
not to log it we change debug messages which used to look like this:

 [i915:edp_panel_off [i915]] Wait for panel power off time

to this:

 [edp_panel_off [i915]] Wait for panel power off time


Why not remove the second mention to the driver's name instead.

[i915:edp_panel_off] looks more logic to me.


Would possibly be more readable yes, but the whole string comes from %ps 
AFAICS so I don't think we could split it.


Regards,

Tvrtko

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


[Intel-gfx] [PATCH v3] drm/i915: Tidy load failure reporting

2016-12-06 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Several changes here:

 * Remove unused i915_report_error.
 * Unexport __i915_printk and rename it to i915_load_error,
   converting the latter from a macro to a static function.
 * Use drm_dev_printk instead of open-coding the same.

v2: Fix reversed error condition.
v3: Remove stray semi-colon. (Chris Wilson)

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_drv.c | 45 +++--
 drivers/gpu/drm/i915/i915_drv.h |  7 ---
 2 files changed, 21 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index ae583c79c19f..e8b1cb123dae 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -68,52 +68,49 @@ bool __i915_inject_load_failure(const char *func, int line)
return false;
 }
 
+static bool i915_error_injected(struct drm_i915_private *dev_priv)
+{
+   return i915.inject_load_failure &&
+  i915_load_fail_count == i915.inject_load_failure;
+}
+
 #define FDO_BUG_URL "https://bugs.freedesktop.org/enter_bug.cgi?product=DRI";
 #define FDO_BUG_MSG "Please file a bug at " FDO_BUG_URL " against DRM/Intel " \
"providing the dmesg log by booting with drm.debug=0xf"
 
-void
-__i915_printk(struct drm_i915_private *dev_priv, const char *level,
- const char *fmt, ...)
+static void __printf(2, 3)
+i915_load_error(struct drm_i915_private *dev_priv, const char *fmt, ...)
 {
-   static bool shown_bug_once;
+   static bool shown_bug_once __read_mostly;
struct device *kdev = dev_priv->drm.dev;
-   bool is_error = level[1] <= KERN_ERR[1];
-   bool is_debug = level[1] == KERN_DEBUG[1];
+   char *level;
+   bool is_error;
struct va_format vaf;
va_list args;
 
-   if (is_debug && !(drm_debug & DRM_UT_DRIVER))
-   return;
+   if (i915_error_injected(dev_priv)) {
+   is_error = false;
+   level = KERN_DEBUG;
+   } else {
+   is_error = true;
+   level = KERN_ERR;
+   }
 
va_start(args, fmt);
 
vaf.fmt = fmt;
vaf.va = &args;
 
-   dev_printk(level, kdev, "[" DRM_NAME ":%ps] %pV",
-  __builtin_return_address(0), &vaf);
+   drm_dev_printk(kdev, level, DRM_UT_DRIVER, __func__, "", fmt, &vaf);
+
+   va_end(args);
 
if (is_error && !shown_bug_once) {
dev_notice(kdev, "%s", FDO_BUG_MSG);
shown_bug_once = true;
}
-
-   va_end(args);
-}
-
-static bool i915_error_injected(struct drm_i915_private *dev_priv)
-{
-   return i915.inject_load_failure &&
-  i915_load_fail_count == i915.inject_load_failure;
 }
 
-#define i915_load_error(dev_priv, fmt, ...) \
-   __i915_printk(dev_priv,  \
- i915_error_injected(dev_priv) ? KERN_DEBUG : KERN_ERR, \
- fmt, ##__VA_ARGS__)
-
-
 static enum intel_pch intel_virt_detect_pch(struct drm_i915_private *dev_priv)
 {
enum intel_pch ret = PCH_NOP;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 605247baa7d1..f523cdfa8636 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2766,13 +2766,6 @@ int intel_sanitize_enable_ppgtt(struct drm_i915_private 
*dev_priv,
 bool intel_sanitize_semaphores(struct drm_i915_private *dev_priv, int value);
 
 /* i915_drv.c */
-void __printf(3, 4)
-__i915_printk(struct drm_i915_private *dev_priv, const char *level,
- const char *fmt, ...);
-
-#define i915_report_error(dev_priv, fmt, ...) \
-   __i915_printk(dev_priv, KERN_ERR, fmt, ##__VA_ARGS__)
-
 #ifdef CONFIG_COMPAT
 extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
  unsigned long arg);
-- 
2.7.4

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


Re: [Intel-gfx] ✗ Fi.CI.BAT: warning for series starting with [1/2] drm/i915: Advertise ppgtt support type in platform definition

2016-12-06 Thread Tvrtko Ursulin


On 06/12/2016 17:57, Michel Thierry wrote:

On 05/12/16 18:15, Patchwork wrote:

== Series Details ==

Series: series starting with [1/2] drm/i915: Advertise ppgtt support
type in platform definition
URL   : https://patchwork.freedesktop.org/series/16403/
State : warning

== Summary ==

Series 16403v1 Series without cover letter
https://patchwork.freedesktop.org/api/1.0/series/16403/revisions/1/mbox/

Test kms_pipe_crc_basic:
Subgroup nonblocking-crc-pipe-a:
pass   -> DMESG-WARN (fi-snb-2520m)



[  486.586950] [drm:drm_edid_block_valid] *ERROR* EDID checksum is
invalid, remainder is 117

This is already reported in
https://bugs.freedesktop.org/show_bug.cgi?id=98625 {[SNB BAT] HDMI: EDID
checksum is invalid}

Thanks to Michał for reviewing the patches.


Pushed to dinq, thanks for the patches and review!

Regards,

Tvrtko

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


Re: [Intel-gfx] ✗ Fi.CI.BAT: warning for drm/i915/guc: Drop comment on fwif autogeneration

2016-12-06 Thread Tvrtko Ursulin


On 06/12/2016 05:41, Arkadiusz Hiler wrote:

On Mon, Dec 05, 2016 at 06:59:01PM +, Patchwork wrote:

== Series Details ==

Series: drm/i915/guc: Drop comment on fwif autogeneration
URL   : https://patchwork.freedesktop.org/series/16373/
State : warning

== Summary ==

Series 16373v1 drm/i915/guc: Drop comment on fwif autogeneration
https://patchwork.freedesktop.org/api/1.0/series/16373/revisions/1/mbox/

Test gem_busy:
Subgroup basic-hang-default:
fail   -> PASS   (fi-hsw-4770r)


The cange is only a comment removal. Could not affect the pass.


Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-a:
pass   -> DMESG-WARN (fi-skl-6770hq)



[  408.780897] [drm:skl_set_cdclk [i915]] *ERROR* failed to inform PCU about 
cdclk change

https://bugs.freedesktop.org/show_bug.cgi?id=97929



a947529bb652fdcf50e8c0e8ee5102b737bae23e drm-tip: 2016y-12m-05d-14h-27m-06s UTC 
integration manifest
abb5dbd drm/i915/guc: Drop comment on fwif autogeneration


Pushed to dinq, thanks for the patch and review!

Regards,

Tvrtko

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


[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Tidy load failure reporting (rev3)

2016-12-06 Thread Patchwork
== Series Details ==

Series: drm/i915: Tidy load failure reporting (rev3)
URL   : https://patchwork.freedesktop.org/series/16435/
State : success

== Summary ==

Series 16435v3 drm/i915: Tidy load failure reporting
https://patchwork.freedesktop.org/api/1.0/series/16435/revisions/3/mbox/

Test drv_module_reload:
Subgroup basic-reload-inject:
incomplete -> PASS   (fi-kbl-7500u)

fi-bdw-5557u total:247  pass:218  dwarn:0   dfail:0   fail:0   skip:29 
fi-bsw-n3050 total:247  pass:194  dwarn:0   dfail:0   fail:0   skip:53 
fi-bxt-t5700 total:247  pass:205  dwarn:0   dfail:0   fail:0   skip:42 
fi-byt-j1900 total:247  pass:205  dwarn:0   dfail:0   fail:0   skip:42 
fi-byt-n2820 total:247  pass:201  dwarn:0   dfail:0   fail:0   skip:46 
fi-hsw-4770  total:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-hsw-4770r total:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-ilk-650   total:247  pass:180  dwarn:0   dfail:0   fail:0   skip:67 
fi-ivb-3520m total:247  pass:212  dwarn:0   dfail:0   fail:0   skip:35 
fi-ivb-3770  total:247  pass:211  dwarn:0   dfail:0   fail:0   skip:36 
fi-kbl-7500u total:247  pass:211  dwarn:0   dfail:0   fail:0   skip:36 
fi-skl-6260u total:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-skl-6700hqtotal:247  pass:213  dwarn:0   dfail:0   fail:0   skip:34 
fi-skl-6700k total:247  pass:209  dwarn:3   dfail:0   fail:0   skip:35 
fi-skl-6770hqtotal:247  pass:219  dwarn:0   dfail:0   fail:0   skip:28 
fi-snb-2520m total:247  pass:201  dwarn:0   dfail:0   fail:0   skip:46 
fi-snb-2600  total:247  pass:200  dwarn:0   dfail:0   fail:0   skip:47 

f6eb1c22f17fb3aa43bfcce1715d576f656011da drm-tip: 2016y-12m-07d-03h-14m-42s UTC 
integration manifest
ea3eee9 drm/i915: Tidy load failure reporting

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3211/
___
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


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