Re: [Intel-gfx] [PATCH 04/35] drm: Forbid legacy MAP functions for DRIVER_MODESET

2016-04-26 Thread Daniel Vetter
On Wed, Apr 27, 2016 at 08:46:31AM +0200, Daniel Vetter wrote:
> On Tue, Apr 26, 2016 at 05:35:42PM -0400, Alex Deucher wrote:
> > On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter  
> > wrote:
> > > Like in
> > >
> > > commit 0e975980d435d58df2d430d688b8c18778b42218
> > > Author: Peter Antoine 
> > > Date:   Tue Jun 23 08:18:49 2015 +0100
> > >
> > > drm: Turn off Legacy Context Functions
> > >
> > > we need to again make an exception for nouveau, but everyone else
> > > really doesn't need this.
> > >
> > > Cc: Peter Antoine 
> > > Cc: Ben Skeggs 
> > > Signed-off-by: Daniel Vetter 
> > 
> > Not really familiar with why nouveau needs this, but the logic seems 
> > correct.
> 
> Hm, I thought the referenced commit explained this, but now that I recheck
> it doesn't. I'm not too sure again myself why I thought nouveau needs
> this. The legacy ctx stuff is required because of some old kms nouveau ddx
> that still used that stuff. I thought it also used legacy maps ... I'll
> double check once more.

Ok, nouveau ddx indeed used legacy addmap and friends, but that code is
nuked since 2006. That's 10 years, which is the rule of thumb for when we
can drop support. I'll respin this patch.
-Daniel
-- 
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 Moar struct_mutex nuking

2016-04-26 Thread Patchwork
== Series Details ==

Series: Moar struct_mutex nuking
URL   : https://patchwork.freedesktop.org/series/6358/
State : failure

== Summary ==

Series 6358v1 Moar struct_mutex nuking
http://patchwork.freedesktop.org/api/1.0/series/6358/revisions/1/mbox/

Test drv_getparams_basic:
Subgroup basic-eu-total:
pass   -> DMESG-WARN (bsw-nuc-2)
pass   -> DMESG-WARN (skl-nuci5)
pass   -> DMESG-WARN (ivb-t430s)
pass   -> DMESG-WARN (bdw-ultra)
pass   -> DMESG-WARN (skl-i7k-2)
pass   -> DMESG-WARN (byt-nuc)
pass   -> DMESG-WARN (snb-x220t)
pass   -> DMESG-WARN (snb-dellxps)
pass   -> DMESG-WARN (hsw-brixbox)
pass   -> DMESG-WARN (bdw-nuci7)
Subgroup basic-subslice-total:
pass   -> DMESG-WARN (bsw-nuc-2)
pass   -> DMESG-WARN (skl-nuci5)
pass   -> DMESG-WARN (ivb-t430s)
pass   -> DMESG-WARN (bdw-ultra)
pass   -> DMESG-WARN (skl-i7k-2)
pass   -> DMESG-WARN (byt-nuc)
pass   -> DMESG-WARN (snb-x220t)
pass   -> DMESG-WARN (snb-dellxps)
pass   -> DMESG-WARN (hsw-brixbox)
pass   -> DMESG-WARN (bdw-nuci7)
Test drv_hangman:
Subgroup error-state-basic:
pass   -> DMESG-WARN (bsw-nuc-2)
pass   -> DMESG-WARN (skl-nuci5)
pass   -> DMESG-WARN (ivb-t430s)
pass   -> DMESG-WARN (bdw-ultra)
pass   -> DMESG-WARN (skl-i7k-2)
pass   -> DMESG-WARN (byt-nuc)
pass   -> DMESG-WARN (snb-x220t)
pass   -> DMESG-WARN (hsw-brixbox)
pass   -> DMESG-WARN (bdw-nuci7)
Test drv_module_reload_basic:
pass   -> DMESG-WARN (bsw-nuc-2)
pass   -> DMESG-WARN (skl-nuci5)
pass   -> DMESG-WARN (ivb-t430s)
pass   -> DMESG-WARN (bdw-ultra)
pass   -> DMESG-WARN (skl-i7k-2)
pass   -> DMESG-WARN (byt-nuc)
pass   -> DMESG-WARN (snb-x220t)
pass   -> DMESG-WARN (hsw-brixbox)
pass   -> DMESG-WARN (bdw-nuci7)
Test gem_basic:
Subgroup bad-close:
pass   -> DMESG-WARN (bsw-nuc-2)
pass   -> DMESG-WARN (ivb-t430s)
pass   -> DMESG-WARN (bdw-ultra)
pass   -> DMESG-WARN (skl-i7k-2)
pass   -> DMESG-WARN (byt-nuc)
pass   -> DMESG-WARN (snb-x220t)
pass   -> DMESG-WARN (snb-dellxps)
pass   -> DMESG-WARN (skl-nuci5)
pass   -> DMESG-WARN (bdw-nuci7)
Subgroup create-close:
pass   -> DMESG-WARN (bsw-nuc-2)
pass   -> DMESG-WARN (skl-nuci5)
pass   -> DMESG-WARN (ivb-t430s)
pass   -> DMESG-WARN (bdw-ultra)
pass   -> DMESG-WARN (skl-i7k-2)
pass   -> DMESG-WARN (byt-nuc)
pass   -> DMESG-WARN (snb-x220t)
pass   -> DMESG-WARN (hsw-brixbox)
pass   -> DMESG-WARN (bdw-nuci7)
Subgroup create-fd-close:
pass   -> DMESG-WARN (bsw-nuc-2)
pass   -> DMESG-WARN (skl-nuci5)
pass   -> DMESG-WARN (ivb-t430s)
pass   -> DMESG-WARN (bdw-ultra)
pass   -> DMESG-WARN (skl-i7k-2)
pass   -> DMESG-WARN (byt-nuc)
pass   -> DMESG-WARN (snb-x220t)
pass   -> DMESG-WARN (hsw-brixbox)
pass   -> DMESG-WARN (bdw-nuci7)
Test gem_busy:
Subgroup basic-blt:
pass   -> DMESG-WARN (bsw-nuc-2)
pass   -> DMESG-WARN (skl-nuci5)
pass   -> DMESG-WARN (ivb-t430s)
pass   -> DMESG-WARN (bdw-ultra)
pass   -> DMESG-WARN (skl-i7k-2)
pass   -> DMESG-WARN (byt-nuc)
pass   -> DMESG-WARN (snb-x220t)
pass   -> DMESG-WARN (snb-dellxps)
pass   -> DMESG-WARN (hsw-brixbox)
pass   -> DMESG-WARN (bdw-nuci7)
Subgroup basic-bsd:
pass   -> DMESG-WARN (bsw-nuc-2)
pass   -> DMESG-WARN (skl-nuci5)
pass   -> DMESG-WARN (ivb-t430s)
pass   -> DMESG-WARN (bdw-ultra)
pass   -> DMESG-WARN (skl-i7k-2)
pass   -> DMESG-WARN (byt-nuc)
pass   -> DMESG-WARN (hsw-brixbox)
pass   -> DM

Re: [Intel-gfx] [PATCH 04/35] drm: Forbid legacy MAP functions for DRIVER_MODESET

2016-04-26 Thread Daniel Vetter
On Tue, Apr 26, 2016 at 05:35:42PM -0400, Alex Deucher wrote:
> On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter  wrote:
> > Like in
> >
> > commit 0e975980d435d58df2d430d688b8c18778b42218
> > Author: Peter Antoine 
> > Date:   Tue Jun 23 08:18:49 2015 +0100
> >
> > drm: Turn off Legacy Context Functions
> >
> > we need to again make an exception for nouveau, but everyone else
> > really doesn't need this.
> >
> > Cc: Peter Antoine 
> > Cc: Ben Skeggs 
> > Signed-off-by: Daniel Vetter 
> 
> Not really familiar with why nouveau needs this, but the logic seems correct.

Hm, I thought the referenced commit explained this, but now that I recheck
it doesn't. I'm not too sure again myself why I thought nouveau needs
this. The legacy ctx stuff is required because of some old kms nouveau ddx
that still used that stuff. I thought it also used legacy maps ... I'll
double check once more.
-Daniel

> Acked-by: Alex Deucher 
> 
> 
> > ---
> >  drivers/gpu/drm/drm_bufs.c | 12 
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> > index d92db7007f62..e8a12a4fd400 100644
> > --- a/drivers/gpu/drm/drm_bufs.c
> > +++ b/drivers/gpu/drm/drm_bufs.c
> > @@ -396,6 +396,10 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, 
> > void *data,
> > if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type 
> > == _DRM_SHM))
> > return -EPERM;
> >
> > +   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > +   drm_core_check_feature(dev, DRIVER_MODESET))
> > +   return -EINVAL;
> > +
> > err = drm_addmap_core(dev, map->offset, map->size, map->type,
> >   map->flags, &maplist);
> >
> > @@ -438,6 +442,10 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, 
> > void *data,
> > int idx;
> > int i;
> >
> > +   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > +   drm_core_check_feature(dev, DRIVER_MODESET))
> > +   return -EINVAL;
> > +
> > idx = map->offset;
> > if (idx < 0)
> > return -EINVAL;
> > @@ -569,6 +577,10 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, 
> > void *data,
> > struct drm_map_list *r_list;
> > int ret;
> >
> > +   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> > +   drm_core_check_feature(dev, DRIVER_MODESET))
> > +   return -EINVAL;
> > +
> > mutex_lock(&dev->struct_mutex);
> > list_for_each_entry(r_list, &dev->maplist, head) {
> > if (r_list->map &&
> > --
> > 2.8.1
> >
> > ___
> > dri-devel mailing list
> > dri-de...@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

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


Re: [Intel-gfx] [PATCH 01/35] drm: Give drm_agp_clear drm_legacy_ prefix

2016-04-26 Thread Daniel Vetter
On Tue, Apr 26, 2016 at 10:09:16PM +0100, Chris Wilson wrote:
> On Tue, Apr 26, 2016 at 07:29:34PM +0200, Daniel Vetter wrote:
> > It has a  DRIVER_MODESET check to sure make it's not creating havoc
> > for drm drivers. Make that clear in the name too.
> 
> The pattern is that any extern that starts
> 
>   if (drm_core_check_feature(MODESET)) return
> 
> becomes drm_legacy_ ? With the apparent caveat of KMS_LEGACY_CONTEXT.

Yeah that's what I'm aiming for. Gives you a clear signal that as soon as
you spot drm_legacy_* you don't have to bother jumping into the function
at all. We've done the same with headers, splitting things into legacy
internal headers.

> > v2: Move misplaced hunk, spotted by 0day and Thierry.
> > 
> > Cc: Thierry Reding 
> > Signed-off-by: Daniel Vetter 
> Reviewed-by: Chris Wilson 

Thanks for the review, will apply.
-Daniel
-- 
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: warning for drm/i915: Cdclk related fixes and polish

2016-04-26 Thread Patchwork
== Series Details ==

Series: drm/i915: Cdclk related fixes and polish
URL   : https://patchwork.freedesktop.org/series/6354/
State : warning

== Summary ==

Series 6354v1 drm/i915: Cdclk related fixes and polish
http://patchwork.freedesktop.org/api/1.0/series/6354/revisions/1/mbox/

Test drv_module_reload_basic:
pass   -> SKIP   (skl-nuci5)
Test kms_pipe_crc_basic:
Subgroup hang-read-crc-pipe-b:
incomplete -> PASS   (snb-dellxps)

bdw-nuci7total:200  pass:188  dwarn:0   dfail:0   fail:0   skip:12 
bdw-ultratotal:200  pass:175  dwarn:0   dfail:0   fail:0   skip:25 
bsw-nuc-2total:199  pass:158  dwarn:0   dfail:0   fail:0   skip:41 
byt-nuc  total:199  pass:158  dwarn:0   dfail:0   fail:0   skip:41 
hsw-brixbox  total:200  pass:174  dwarn:0   dfail:0   fail:0   skip:26 
skl-i7k-2total:200  pass:173  dwarn:0   dfail:0   fail:0   skip:27 
skl-nuci5total:200  pass:188  dwarn:0   dfail:0   fail:0   skip:12 
snb-dellxps  total:200  pass:158  dwarn:0   dfail:0   fail:0   skip:42 
snb-x220ttotal:200  pass:158  dwarn:0   dfail:0   fail:1   skip:41 

Results at /archive/results/CI_IGT_test/Patchwork_2080/

e005db1cb2c60d18abe837ac683d8993ea77b239 drm-intel-nightly: 
2016y-04m-26d-12h-51m-57s UTC integration manifest
b85d9d7 drm/i915: Fix comments about GMBUSFREQ register
f897835 drm/i915: Use cached cdclk value in 
i915_audio_component_get_cdclk_freq()
4e443d4 drm/i915: Update CDCLK_FREQ register on BDW after changing cdclk 
frequency

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


Re: [Intel-gfx] Could you merge the tsc patches directly from Len Brown's public repo?

2016-04-26 Thread Lu, Han
Hi Len,

Could you please share if you have any following plan to fix the hard-hang on 
SandyBridge? Will you modify patch 540cc882de7d1da2e71591e215f0e04cb89883fa and 
update your public repo? Thanks.

BR,
Han Lu

> -Original Message-
> From: Ville Syrjälä [mailto:ville.syrj...@linux.intel.com]
> Sent: Wednesday, April 27, 2016 12:36 AM
> To: Brown, Len 
> Cc: Daniel Vetter ; Lu, Han ;
> Nikula, Jani ; Lin, Mengdong
> ; Yang, Libin ; Li, Jocelyn
> ; intel-gfx 
> Subject: Re: Could you merge the tsc patches directly from Len Brown's
> public repo?
> 
> On Tue, Apr 26, 2016 at 06:46:23AM +, Brown, Len wrote:
> > > On Wed, Apr 20, 2016 at 11:24 AM, Daniel Vetter
> > > 
> > > wrote:
> > > > On Wed, Apr 20, 2016 at 10:26 AM, Lu, Han  wrote:
> > > >> Hi Jani,
> > > >>
> > > >> Please find the repo and commit id below:
> > > >> Repo:
> > > >> https://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux.git
> > > >> Branch: x86
> > > >> Commit id (begin from earliest):
> > > >> 6e0c25e64e0fb65a42dfc63ad5f660302e07cd87
> > > >> 16caa2834b2f08cdfd130baa490c45822edef256
> > > >> ce5c7b5eaad93c7b0043a7509eec319fe0a0e8a0
> > > >> ca376a9909f1151484854c46dc7f01be6d6d9bdb
> > > >> 4a62ba36cf4fb77ea35dee1f5992e0e7c48dad14
> > > >> 540cc882de7d1da2e71591e215f0e04cb89883fa
> > > >> 433f82c8ab3fcaa7ff3b852d01cc74dbdf6d94f1
> > > >> 65ae86d4fa3473d24445ea402b190e4b4342172e
> > > >> 3152b94afb8c27595f9b1bfa67885015cb569ba2
> > > >>
> > > >> I have one silly question: if I understand correctly, these
> > > >> patches
> > > will be merged into a separate branch and drm-nightly both. After a
> > > few weeks, will there be conflicts when merging from upstream to
> > > drm-nightly, as both upstream and drm-nightly contain tsc patches?
> > > >
> > > > All cherry-picked to topic/core-for-CI, pls double-check it's all
> > > > there (scripts will take another 5 minutes or so to push it all
> > > > out and rebuild drm-intel-nightly with those patches).
> > >
> > > Dropped them again because they hard-hang Ville's sandybridge on
> > > boot-up. Adding Ville and Len and mailing lists.
> >
> > Does the SNB work if you revert this one?:
> >
> > commit 540cc882de7d1da2e71591e215f0e04cb89883fa
> > Author: Len Brown 
> > Date:   Sun Nov 29 01:21:06 2015 -0500
> >
> > x86 tsc_msr: Extend to include Intel Core Architecture
> 
> Yep, that does seem to be the bad apple.
> 
> --
> Ville Syrjälä
> Intel OTC
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] linux-next: manual merge of the drm-misc tree with the drm-intel tree

2016-04-26 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the drm-misc tree got a conflict in:

  drivers/gpu/drm/i915/intel_dp.c

between commit:

  86ee27b5aa75 ("drm/i915: Read eDP Display control capability registers")

from the drm-intel tree and commit:

  9f085ebb1a50 ("rm/i915: Get rid of intel_dp_dpcd_read_wake()")

from the drm-misc tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/i915/intel_dp.c
index 6bb0b2340e7c,b52676a032f9..
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@@ -3747,9 -3744,10 +3714,9 @@@ intel_dp_get_dpcd(struct intel_dp *inte
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
struct drm_device *dev = dig_port->base.base.dev;
struct drm_i915_private *dev_priv = dev->dev_private;
 -  uint8_t rev;
  
-   if (intel_dp_dpcd_read_wake(&intel_dp->aux, 0x000, intel_dp->dpcd,
-   sizeof(intel_dp->dpcd)) < 0)
+   if (drm_dp_dpcd_read(&intel_dp->aux, 0x000, intel_dp->dpcd,
+sizeof(intel_dp->dpcd)) < 0)
return false; /* aux transfer failed */
  
DRM_DEBUG_KMS("DPCD: %*ph\n", (int) sizeof(intel_dp->dpcd), 
intel_dp->dpcd);
@@@ -3803,15 -3801,6 +3770,15 @@@
DRM_DEBUG_KMS("PSR2 %s on sink",
dev_priv->psr.psr2_support ? "supported" : "not 
supported");
}
 +
 +  /* Read the eDP Display control capabilities registers */
 +  memset(intel_dp->edp_dpcd, 0, sizeof(intel_dp->edp_dpcd));
 +  if ((intel_dp->dpcd[DP_EDP_CONFIGURATION_CAP] & 
DP_DPCD_DISPLAY_CONTROL_CAPABLE) &&
-   (intel_dp_dpcd_read_wake(&intel_dp->aux, 
DP_EDP_DPCD_REV,
++  (drm_dp_dpcd_read(&intel_dp->aux, 
DP_EDP_DPCD_REV,
 +  intel_dp->edp_dpcd, 
sizeof(intel_dp->edp_dpcd)) ==
 +  
sizeof(intel_dp->edp_dpcd)))
 +  DRM_DEBUG_KMS("EDP DPCD : %*ph\n", (int) 
sizeof(intel_dp->edp_dpcd),
 +  intel_dp->edp_dpcd);
}
  
DRM_DEBUG_KMS("Display Port TPS3 support: source %s, sink %s\n",
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 3/5] drm/crtc: take references to connectors used in a modeset.

2016-04-26 Thread Dave Airlie
From: Dave Airlie 

This just takes a reference on the connector when we set a mode
in the non-atomic paths.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/drm_crtc_helper.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc_helper.c 
b/drivers/gpu/drm/drm_crtc_helper.c
index 66ca313..29b7835 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -456,6 +456,9 @@ drm_crtc_helper_disable(struct drm_crtc *crtc)
 * between them is henceforth no longer available.
 */
connector->dpms = DRM_MODE_DPMS_OFF;
+
+   /* we keep a reference while the encoder is bound */
+   drm_connector_unreference(connector);
}
}
 
@@ -635,9 +638,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
mode_changed = true;
/* If the encoder is reused for another connector, then
 * the appropriate crtc will be set later.
+* take a reference only if we haven't had an encoder 
before.
 */
if (connector->encoder)
connector->encoder->crtc = NULL;
+   else
+   drm_connector_reference(connector);
connector->encoder = new_encoder;
}
}
-- 
2.5.5

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


[Intel-gfx] [PATCH 1/5] drm/modes: add connector reference counting. (v2)

2016-04-26 Thread Dave Airlie
From: Dave Airlie 

This uses the previous changes to add reference counts
to drm connector objects.

v2: move fbdev changes to their own patch.
add some kerneldoc
Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/drm_atomic.c | 19 +--
 drivers/gpu/drm/drm_crtc.c   | 28 
 include/drm/drm_crtc.h   | 32 +++-
 3 files changed, 72 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 8ee1db8..9d5e3c8 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -154,6 +154,7 @@ void drm_atomic_state_default_clear(struct drm_atomic_state 
*state)
   
state->connector_states[i]);
state->connectors[i] = NULL;
state->connector_states[i] = NULL;
+   drm_connector_unreference(connector);
}
 
for (i = 0; i < config->num_crtc; i++) {
@@ -924,6 +925,7 @@ drm_atomic_get_connector_state(struct drm_atomic_state 
*state,
if (!connector_state)
return ERR_PTR(-ENOMEM);
 
+   drm_connector_reference(connector);
state->connector_states[index] = connector_state;
state->connectors[index] = connector;
connector_state->state = state;
@@ -1614,12 +1616,19 @@ retry:
}
 
obj = drm_mode_object_find(dev, obj_id, DRM_MODE_OBJECT_ANY);
-   if (!obj || !obj->properties) {
+   if (!obj) {
+   ret = -ENOENT;
+   goto out;
+   }
+
+   if (!obj->properties) {
+   drm_mode_object_unreference(obj);
ret = -ENOENT;
goto out;
}
 
if (get_user(count_props, count_props_ptr + copied_objs)) {
+   drm_mode_object_unreference(obj);
ret = -EFAULT;
goto out;
}
@@ -1632,12 +1641,14 @@ retry:
struct drm_property *prop;
 
if (get_user(prop_id, props_ptr + copied_props)) {
+   drm_mode_object_unreference(obj);
ret = -EFAULT;
goto out;
}
 
prop = drm_property_find(dev, prop_id);
if (!prop) {
+   drm_mode_object_unreference(obj);
ret = -ENOENT;
goto out;
}
@@ -1645,13 +1656,16 @@ retry:
if (copy_from_user(&prop_value,
   prop_values_ptr + copied_props,
   sizeof(prop_value))) {
+   drm_mode_object_unreference(obj);
ret = -EFAULT;
goto out;
}
 
ret = atomic_set_prop(state, obj, prop, prop_value);
-   if (ret)
+   if (ret) {
+   drm_mode_object_unreference(obj);
goto out;
+   }
 
copied_props++;
}
@@ -1662,6 +1676,7 @@ retry:
plane_mask |= (1 << drm_plane_index(plane));
plane->old_fb = plane->fb;
}
+   drm_mode_object_unreference(obj);
}
 
if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 4e5b015..a78e202 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -862,6 +862,16 @@ static void drm_connector_get_cmdline_mode(struct 
drm_connector *connector)
  mode->interlace ?  " interlaced" : "");
 }
 
+static void drm_connector_free(struct kref *kref)
+{
+   struct drm_connector *connector =
+   container_of(kref, struct drm_connector, base.refcount);
+   struct drm_device *dev = connector->dev;
+
+   drm_mode_object_unregister(dev, &connector->base);
+   connector->funcs->destroy(connector);
+}
+
 /**
  * drm_connector_init - Init a preallocated connector
  * @dev: DRM device
@@ -887,7 +897,9 @@ int drm_connector_init(struct drm_device *dev,
 
drm_modeset_lock_all(dev);
 
-   ret = drm_mode_object_get_reg(dev, &connector->base, 
DRM_MODE_OBJECT_CONNECTOR, false, NULL);
+   ret = drm_mode_object_get_reg(dev, &connector->base,
+ DRM_MODE_OBJECT_CONNECTOR,
+ false, drm_connector_free);
if (ret)
goto out_unlock;
 
@@ -2147,7 +2159,7 @@ int drm_mode_getconnector(struct drm_device *dev, void 
*data,
 
mu

[Intel-gfx] [PATCH 5/5] drm/i915/mst: use reference counted connectors. (v2)

2016-04-26 Thread Dave Airlie
From: Dave Airlie 

Don't just free the connector when we get the destroy callback.

Drop a reference to it, and set it's mst_port to NULL so
no more mst work is done on it.

v2: core mst accepts NULLs fine. Cleanup EDID code properly.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/i915/intel_dp_mst.c | 45 ++---
 drivers/gpu/drm/i915/intel_drv.h|  2 +-
 2 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c 
b/drivers/gpu/drm/i915/intel_dp_mst.c
index 94b4e83..4330b21 100644
--- a/drivers/gpu/drm/i915/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/intel_dp_mst.c
@@ -109,7 +109,7 @@ static void intel_mst_disable_dp(struct intel_encoder 
*encoder)
 
DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
 
-   drm_dp_mst_reset_vcpi_slots(&intel_dp->mst_mgr, intel_mst->port);
+   drm_dp_mst_reset_vcpi_slots(&intel_dp->mst_mgr, 
intel_mst->connector->port);
 
ret = drm_dp_update_payload_part1(&intel_dp->mst_mgr);
if (ret) {
@@ -134,10 +134,12 @@ static void intel_mst_post_disable_dp(struct 
intel_encoder *encoder)
/* and this can also fail */
drm_dp_update_payload_part2(&intel_dp->mst_mgr);
 
-   drm_dp_mst_deallocate_vcpi(&intel_dp->mst_mgr, intel_mst->port);
+   drm_dp_mst_deallocate_vcpi(&intel_dp->mst_mgr, 
intel_mst->connector->port);
 
intel_dp->active_mst_links--;
-   intel_mst->port = NULL;
+
+   drm_connector_unreference(&intel_mst->connector->base);
+   intel_mst->connector = NULL;
if (intel_dp->active_mst_links == 0) {
intel_dig_port->base.post_disable(&intel_dig_port->base);
intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
@@ -177,7 +179,9 @@ static void intel_mst_pre_enable_dp(struct intel_encoder 
*encoder)
found->encoder = encoder;
 
DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
-   intel_mst->port = found->port;
+
+   intel_mst->connector = found;
+   drm_connector_reference(&intel_mst->connector->base);
 
if (intel_dp->active_mst_links == 0) {
intel_prepare_ddi_buffer(&intel_dig_port->base);
@@ -195,7 +199,7 @@ static void intel_mst_pre_enable_dp(struct intel_encoder 
*encoder)
}
 
ret = drm_dp_mst_allocate_vcpi(&intel_dp->mst_mgr,
-  intel_mst->port,
+  intel_mst->connector->port,
   intel_crtc->config->pbn, &slots);
if (ret == false) {
DRM_ERROR("failed to allocate vcpi\n");
@@ -244,7 +248,7 @@ static bool intel_dp_mst_enc_get_hw_state(struct 
intel_encoder *encoder,
 {
struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
*pipe = intel_mst->pipe;
-   if (intel_mst->port)
+   if (intel_mst->connector)
return true;
return false;
 }
@@ -308,10 +312,11 @@ static int intel_dp_mst_get_ddc_modes(struct 
drm_connector *connector)
struct edid *edid;
int ret;
 
-   edid = drm_dp_mst_get_edid(connector, &intel_dp->mst_mgr, 
intel_connector->port);
-   if (!edid)
-   return 0;
+   if (!intel_dp) {
+   return intel_connector_update_modes(connector, NULL);
+   }
 
+   edid = drm_dp_mst_get_edid(connector, &intel_dp->mst_mgr, 
intel_connector->port);
ret = intel_connector_update_modes(connector, edid);
kfree(edid);
 
@@ -324,6 +329,8 @@ intel_dp_mst_detect(struct drm_connector *connector, bool 
force)
struct intel_connector *intel_connector = to_intel_connector(connector);
struct intel_dp *intel_dp = intel_connector->mst_port;
 
+   if (!intel_dp)
+   return connector_status_disconnected;
return drm_dp_mst_detect_port(connector, &intel_dp->mst_mgr, 
intel_connector->port);
 }
 
@@ -389,6 +396,8 @@ static struct drm_encoder 
*intel_mst_atomic_best_encoder(struct drm_connector *c
struct intel_dp *intel_dp = intel_connector->mst_port;
struct intel_crtc *crtc = to_intel_crtc(state->crtc);
 
+   if (!intel_dp)
+   return NULL;
return &intel_dp->mst_encoders[crtc->pipe]->base.base;
 }
 
@@ -396,6 +405,8 @@ static struct drm_encoder *intel_mst_best_encoder(struct 
drm_connector *connecto
 {
struct intel_connector *intel_connector = to_intel_connector(connector);
struct intel_dp *intel_dp = intel_connector->mst_port;
+   if (!intel_dp)
+   return NULL;
return &intel_dp->mst_encoders[0]->base.base;
 }
 
@@ -506,23 +517,11 @@ static void intel_dp_destroy_mst_connector(struct 
drm_dp_mst_topology_mgr *mgr,
 
/* need to nuke the connector */
drm_modeset_lock_all(dev);
-   if (connector->state->crtc) {
-   struct drm_mode_set set;
-   int ret;
-
-   memset(&set, 0, sizeof(set));
-   set.crtc = connector->stat

[Intel-gfx] [PATCH 2/5] drm/fb_helper: add connector reference counting.

2016-04-26 Thread Dave Airlie
From: Dave Airlie 

This takes a reference count when fbdev adds the connector,
and drops it when it removes the connector.

It also drops the now unneeded code to find connectors
and remove the from the modeset as they are reference counted.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/drm_fb_helper.c | 34 ++
 1 file changed, 2 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 855108e..b2f58fb 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -153,40 +153,13 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper 
*fb_helper, struct drm_
if (!fb_helper_connector)
return -ENOMEM;
 
+   drm_connector_reference(connector);
fb_helper_connector->connector = connector;
fb_helper->connector_info[fb_helper->connector_count++] = 
fb_helper_connector;
return 0;
 }
 EXPORT_SYMBOL(drm_fb_helper_add_one_connector);
 
-static void remove_from_modeset(struct drm_mode_set *set,
-   struct drm_connector *connector)
-{
-   int i, j;
-
-   for (i = 0; i < set->num_connectors; i++) {
-   if (set->connectors[i] == connector)
-   break;
-   }
-
-   if (i == set->num_connectors)
-   return;
-
-   for (j = i + 1; j < set->num_connectors; j++) {
-   set->connectors[j - 1] = set->connectors[j];
-   }
-   set->num_connectors--;
-
-   /*
-* TODO maybe need to makes sure we set it back to !=NULL somewhere?
-*/
-   if (set->num_connectors == 0) {
-   set->fb = NULL;
-   drm_mode_destroy(connector->dev, set->mode);
-   set->mode = NULL;
-   }
-}
-
 int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
   struct drm_connector *connector)
 {
@@ -206,6 +179,7 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper 
*fb_helper,
if (i == fb_helper->connector_count)
return -EINVAL;
fb_helper_connector = fb_helper->connector_info[i];
+   drm_connector_unreference(fb_helper_connector->connector);
 
for (j = i + 1; j < fb_helper->connector_count; j++) {
fb_helper->connector_info[j - 1] = fb_helper->connector_info[j];
@@ -213,10 +187,6 @@ int drm_fb_helper_remove_one_connector(struct 
drm_fb_helper *fb_helper,
fb_helper->connector_count--;
kfree(fb_helper_connector);
 
-   /* also cleanup dangling references to the connector: */
-   for (i = 0; i < fb_helper->crtc_count; i++)
-   remove_from_modeset(&fb_helper->crtc_info[i].mode_set, 
connector);
-
return 0;
 }
 EXPORT_SYMBOL(drm_fb_helper_remove_one_connector);
-- 
2.5.5

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


[Intel-gfx] [PATCH 4/5] drm/atomic: use connector references

2016-04-26 Thread Dave Airlie
From: Dave Airlie 

Take a reference when setting a crtc on a connecter,
also take one when duplicating if a crtc is set,
and drop one on destroy if a crtc is set.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/drm_atomic.c| 11 ++-
 drivers/gpu/drm/drm_atomic_helper.c |  4 
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 9d5e3c8..d899dac 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1159,7 +1159,7 @@ drm_atomic_set_crtc_for_connector(struct 
drm_connector_state *conn_state,
  struct drm_crtc *crtc)
 {
struct drm_crtc_state *crtc_state;
-
+   bool had_crtc = conn_state->crtc ? true : false;
if (conn_state->crtc && conn_state->crtc != crtc) {
crtc_state = 
drm_atomic_get_existing_crtc_state(conn_state->state,

conn_state->crtc);
@@ -1179,6 +1179,15 @@ drm_atomic_set_crtc_for_connector(struct 
drm_connector_state *conn_state,
 
conn_state->crtc = crtc;
 
+   /* If we had no crtc then got one, add a reference,
+* if we had a crtc and are going to none, drop a reference,
+* otherwise just keep the reference we have.
+*/
+   if (!had_crtc && crtc)
+   drm_connector_reference(conn_state->connector);
+   else if (!crtc && had_crtc)
+drm_connector_unreference(conn_state->connector);
+
if (crtc)
DRM_DEBUG_ATOMIC("Link connector state %p to [CRTC:%d:%s]\n",
 conn_state, crtc->base.id, crtc->name);
diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index d25abce..a29deac 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2762,6 +2762,8 @@ __drm_atomic_helper_connector_duplicate_state(struct 
drm_connector *connector,
struct drm_connector_state *state)
 {
memcpy(state, connector->state, sizeof(*state));
+   if (state->crtc)
+   drm_connector_reference(connector);
 }
 EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state);
 
@@ -2889,6 +2891,8 @@ __drm_atomic_helper_connector_destroy_state(struct 
drm_connector *connector,
 * state will automatically do the right thing if code is ever added
 * to this function.
 */
+   if (state->crtc)
+   drm_connector_unreference(connector);
 }
 EXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state);
 
-- 
2.5.5

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


Re: [Intel-gfx] [PATCH v4 1/2] shmem: Support for registration of driver/file owner specific ops

2016-04-26 Thread Kirill A. Shutemov
On Tue, Apr 26, 2016 at 02:53:41PM +0200, Daniel Vetter wrote:
> On Mon, Apr 25, 2016 at 02:42:50AM +0300, Kirill A. Shutemov wrote:
> > On Mon, Apr 04, 2016 at 02:18:10PM +0100, Chris Wilson wrote:
> > > From: Akash Goel 
> > > 
> > > This provides support for the drivers or shmem file owners to register
> > > a set of callbacks, which can be invoked from the address space
> > > operations methods implemented by shmem.  This allow the file owners to
> > > hook into the shmem address space operations to do some extra/custom
> > > operations in addition to the default ones.
> > > 
> > > The private_data field of address_space struct is used to store the
> > > pointer to driver specific ops.  Currently only one ops field is defined,
> > > which is migratepage, but can be extended on an as-needed basis.
> > > 
> > > The need for driver specific operations arises since some of the
> > > operations (like migratepage) may not be handled completely within shmem,
> > > so as to be effective, and would need some driver specific handling also.
> > > Specifically, i915.ko would like to participate in migratepage().
> > > i915.ko uses shmemfs to provide swappable backing storage for its user
> > > objects, but when those objects are in use by the GPU it must pin the
> > > entire object until the GPU is idle.  As a result, large chunks of memory
> > > can be arbitrarily withdrawn from page migration, resulting in premature
> > > out-of-memory due to fragmentation.  However, if i915.ko can receive the
> > > migratepage() request, it can then flush the object from the GPU, remove
> > > its pin and thus enable the migration.
> > > 
> > > Since gfx allocations are one of the major consumer of system memory, its
> > > imperative to have such a mechanism to effectively deal with
> > > fragmentation.  And therefore the need for such a provision for initiating
> > > driver specific actions during address space operations.
> > 
> > Hm. Sorry, my ignorance, but shouldn't this kind of flushing be done in
> > response to mmu_notifier's ->invalidate_page?
> > 
> > I'm not aware about how i915 works and what's its expectation wrt shmem.
> > Do you have some userspace VMA which is mirrored on GPU side?
> > If yes, migration would cause unmapping of these pages and trigger the
> > mmu_notifier's hook.
> 
> We do that for userptr pages (i.e. stuff we steal from userspace address
> spaces). But we also have native gfx buffer objects based on shmem files,
> and thus far we need to allocate them as !GFP_MOVEABLE. And we allocate a
> _lot_ of those. And those files aren't mapped into any cpu address space
> (ofc they're mapped on the gpu side, but that's driver private), from the
> core mm they are pure pagecache. And afaiui for that we need to wire up
> the migratepage hooks through shmem to i915_gem.c

I see.

I don't particularly like the way patch hooks into migrate, but don't a
good idea how to implement this better.

This way allows to hook up to any shmem file, which can be abused by
drivers later.

I wounder if it would be better for i915 to have its own in-kernel mount
with variant of tmpfs which provides different mapping->a_ops? Or is it
overkill? I don't know.

Hugh?

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


Re: [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/guc: Use major_minor version for filename

2016-04-26 Thread O'Rourke, Tom
Hello,
These errors are unrelated to the major_minor version change.
Thanks,
Tom

>-Original Message-
>From: Patchwork [mailto:patchw...@emeril.freedesktop.org]
>Sent: Monday, April 25, 2016 10:18 PM
>To: O'Rourke, Tom 
>Cc: intel-gfx@lists.freedesktop.org
>Subject: ✗ Fi.CI.BAT: failure for drm/i915/guc: Use major_minor version for
>filename
>
>== Series Details ==
>
>Series: drm/i915/guc: Use major_minor version for filename
>URL   : https://patchwork.freedesktop.org/series/6293/
>State : failure
>
>== Summary ==
>
>Series 6293v1 drm/i915/guc: Use major_minor version for filename
>http://patchwork.freedesktop.org/api/1.0/series/6293/revisions/1/mbox/
>
>Test drv_hangman:
>Subgroup error-state-basic:
>incomplete -> PASS   (snb-dellxps)
>Test gem_busy:
>Subgroup basic-bsd1:
>pass   -> DMESG-WARN (skl-nuci5)
>Test gem_sync:
>Subgroup basic-bsd:
>pass   -> DMESG-WARN (skl-nuci5)
>Test kms_pipe_crc_basic:
>Subgroup hang-read-crc-pipe-a:
>pass   -> FAIL   (skl-nuci5)
>Subgroup read-crc-pipe-b-frame-sequence:
>skip   -> PASS   (bdw-nuci7)
>Subgroup read-crc-pipe-c-frame-sequence:
>pass   -> DMESG-WARN (skl-nuci5)
>
>bdw-nuci7total:200  pass:188  dwarn:0   dfail:0   fail:0   skip:12
>bsw-nuc-2total:199  pass:158  dwarn:0   dfail:0   fail:0   skip:41
>hsw-brixbox  total:200  pass:174  dwarn:0   dfail:0   fail:0   skip:26
>skl-i7k-2total:200  pass:173  dwarn:0   dfail:0   fail:0   skip:27
>skl-nuci5total:200  pass:185  dwarn:3   dfail:0   fail:1   skip:11
>snb-dellxps  total:193  pass:155  dwarn:0   dfail:0   fail:0   skip:38
>bdw-ultra failed to connect after reboot ilk-hp8440p failed to connect after
>reboot ivb-t430s failed to connect after reboot
>
>Results at /archive/results/CI_IGT_test/Patchwork_2065/
>
>f814551aa7232ed36d71244dd148b48660b53a78 drm-intel-nightly: 2016y-04m-
>25d-11h-36m-27s UTC integration manifest
>bc7fd31 drm/i915/guc: Use major_minor version for filename

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


Re: [Intel-gfx] [PATCH] drm/i915/kbl: Introduce the first official DMC for Kabylake.

2016-04-26 Thread Patrik Jakobsson
On Tue, Apr 26, 2016 at 11:59 PM, Rodrigo Vivi  wrote:
> Version 1.01.
>
> This firmware is made for Kabylake platform so it doesn't
> need the stepping workaround that we had before.
>
> v2: Rebased on top of latest nightly with min version
> required change.
> v3: With right CSR_VERSION (Patrik).
>
> Cc: Christophe Prigent 
> Cc: Patrik Jakobsson 
> Reviewed-by: Ben Widawsky  (v1)
> Signed-off-by: Rodrigo Vivi 

As discussed on IRC, feel free to push this when satisfied with testing.

Reviewed-by: Patrik Jakobsson 

> ---
>  drivers/gpu/drm/i915/intel_csr.c | 30 +++---
>  1 file changed, 19 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_csr.c 
> b/drivers/gpu/drm/i915/intel_csr.c
> index a34c23e..2b3b428 100644
> --- a/drivers/gpu/drm/i915/intel_csr.c
> +++ b/drivers/gpu/drm/i915/intel_csr.c
> @@ -41,16 +41,22 @@
>   * be moved to FW_FAILED.
>   */
>
> +#define I915_CSR_KBL "i915/kbl_dmc_ver1.bin"
> +MODULE_FIRMWARE(I915_CSR_KBL);
> +#define KBL_CSR_VERSION_REQUIRED   CSR_VERSION(1, 1)
> +
>  #define I915_CSR_SKL "i915/skl_dmc_ver1.bin"
> +MODULE_FIRMWARE(I915_CSR_SKL);
> +#define SKL_CSR_VERSION_REQUIRED   CSR_VERSION(1, 23)
> +
>  #define I915_CSR_BXT "i915/bxt_dmc_ver1.bin"
> +MODULE_FIRMWARE(I915_CSR_BXT);
> +#define BXT_CSR_VERSION_REQUIRED   CSR_VERSION(1, 7)
>
>  #define FIRMWARE_URL  
> "https://01.org/linuxgraphics/intel-linux-graphics-firmwares";
>
> -MODULE_FIRMWARE(I915_CSR_SKL);
> -MODULE_FIRMWARE(I915_CSR_BXT);
>
> -#define SKL_CSR_VERSION_REQUIRED   CSR_VERSION(1, 23)
> -#define BXT_CSR_VERSION_REQUIRED   CSR_VERSION(1, 7)
> +
>
>  #define CSR_MAX_FW_SIZE0x2FFF
>  #define CSR_DEFAULT_FW_OFFSET  0x
> @@ -169,12 +175,10 @@ struct stepping_info {
> char substepping;
>  };
>
> -/*
> - * Kabylake derivated from Skylake H0, so SKL H0
> - * is the right firmware for KBL A0 (revid 0).
> - */
>  static const struct stepping_info kbl_stepping_info[] = {
> -   {'H', '0'}, {'I', '0'}
> +   {'A', '0'}, {'B', '0'}, {'C', '0'},
> +   {'D', '0'}, {'E', '0'}, {'F', '0'},
> +   {'G', '0'}, {'H', '0'}, {'I', '0'},
>  };
>
>  static const struct stepping_info skl_stepping_info[] = {
> @@ -298,7 +302,9 @@ static uint32_t *parse_csr_fw(struct drm_i915_private 
> *dev_priv,
>
> csr->version = css_header->version;
>
> -   if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) {
> +   if (IS_KABYLAKE(dev_priv)) {
> +   required_min_version = KBL_CSR_VERSION_REQUIRED;
> +   } else if (IS_SKYLAKE(dev_priv)) {
> required_min_version = SKL_CSR_VERSION_REQUIRED;
> } else if (IS_BROXTON(dev_priv)) {
> required_min_version = BXT_CSR_VERSION_REQUIRED;
> @@ -446,7 +452,9 @@ void intel_csr_ucode_init(struct drm_i915_private 
> *dev_priv)
> if (!HAS_CSR(dev_priv))
> return;
>
> -   if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv))
> +   if (IS_KABYLAKE(dev_priv))
> +   csr->fw_path = I915_CSR_KBL;
> +   else if (IS_SKYLAKE(dev_priv))
> csr->fw_path = I915_CSR_SKL;
> else if (IS_BROXTON(dev_priv))
> csr->fw_path = I915_CSR_BXT;
> --
> 2.4.3
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] drm/i915/kbl: Introduce the first official DMC for Kabylake.

2016-04-26 Thread Rodrigo Vivi
Version 1.01.

This firmware is made for Kabylake platform so it doesn't
need the stepping workaround that we had before.

v2: Rebased on top of latest nightly with min version
required change.
v3: With right CSR_VERSION (Patrik).

Cc: Christophe Prigent 
Cc: Patrik Jakobsson 
Reviewed-by: Ben Widawsky  (v1)
Signed-off-by: Rodrigo Vivi 
---
 drivers/gpu/drm/i915/intel_csr.c | 30 +++---
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_csr.c b/drivers/gpu/drm/i915/intel_csr.c
index a34c23e..2b3b428 100644
--- a/drivers/gpu/drm/i915/intel_csr.c
+++ b/drivers/gpu/drm/i915/intel_csr.c
@@ -41,16 +41,22 @@
  * be moved to FW_FAILED.
  */
 
+#define I915_CSR_KBL "i915/kbl_dmc_ver1.bin"
+MODULE_FIRMWARE(I915_CSR_KBL);
+#define KBL_CSR_VERSION_REQUIRED   CSR_VERSION(1, 1)
+
 #define I915_CSR_SKL "i915/skl_dmc_ver1.bin"
+MODULE_FIRMWARE(I915_CSR_SKL);
+#define SKL_CSR_VERSION_REQUIRED   CSR_VERSION(1, 23)
+
 #define I915_CSR_BXT "i915/bxt_dmc_ver1.bin"
+MODULE_FIRMWARE(I915_CSR_BXT);
+#define BXT_CSR_VERSION_REQUIRED   CSR_VERSION(1, 7)
 
 #define FIRMWARE_URL  
"https://01.org/linuxgraphics/intel-linux-graphics-firmwares";
 
-MODULE_FIRMWARE(I915_CSR_SKL);
-MODULE_FIRMWARE(I915_CSR_BXT);
 
-#define SKL_CSR_VERSION_REQUIRED   CSR_VERSION(1, 23)
-#define BXT_CSR_VERSION_REQUIRED   CSR_VERSION(1, 7)
+
 
 #define CSR_MAX_FW_SIZE0x2FFF
 #define CSR_DEFAULT_FW_OFFSET  0x
@@ -169,12 +175,10 @@ struct stepping_info {
char substepping;
 };
 
-/*
- * Kabylake derivated from Skylake H0, so SKL H0
- * is the right firmware for KBL A0 (revid 0).
- */
 static const struct stepping_info kbl_stepping_info[] = {
-   {'H', '0'}, {'I', '0'}
+   {'A', '0'}, {'B', '0'}, {'C', '0'},
+   {'D', '0'}, {'E', '0'}, {'F', '0'},
+   {'G', '0'}, {'H', '0'}, {'I', '0'},
 };
 
 static const struct stepping_info skl_stepping_info[] = {
@@ -298,7 +302,9 @@ static uint32_t *parse_csr_fw(struct drm_i915_private 
*dev_priv,
 
csr->version = css_header->version;
 
-   if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) {
+   if (IS_KABYLAKE(dev_priv)) {
+   required_min_version = KBL_CSR_VERSION_REQUIRED;
+   } else if (IS_SKYLAKE(dev_priv)) {
required_min_version = SKL_CSR_VERSION_REQUIRED;
} else if (IS_BROXTON(dev_priv)) {
required_min_version = BXT_CSR_VERSION_REQUIRED;
@@ -446,7 +452,9 @@ void intel_csr_ucode_init(struct drm_i915_private *dev_priv)
if (!HAS_CSR(dev_priv))
return;
 
-   if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv))
+   if (IS_KABYLAKE(dev_priv))
+   csr->fw_path = I915_CSR_KBL;
+   else if (IS_SKYLAKE(dev_priv))
csr->fw_path = I915_CSR_SKL;
else if (IS_BROXTON(dev_priv))
csr->fw_path = I915_CSR_BXT;
-- 
2.4.3

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


Re: [Intel-gfx] [PATCH 09/35] drm/gem: support BO freeing without dev->struct_mutex

2016-04-26 Thread Alex Deucher
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter  wrote:
> Finally all the core gem and a lot of drivers are entirely free of
> dev->struct_mutex depencies, and we can start to have an entirely
> lockless unref path.
>
> To make sure that no one who touches the core code accidentally breaks
> existing drivers which still require dev->struct_mutex I've made the
> might_lock check unconditional.
>
> While at it de-inline the ref/unref functions, they've become a bit
> too big.
>
> v2: Make it not leak like a sieve.
>
> Signed-off-by: Daniel Vetter 

This and the rest of the series are:
Acked-by: Alex Deucher 

> ---
>  drivers/gpu/drm/drm_gem.c | 64 
> ++-
>  include/drm/drmP.h| 12 -
>  include/drm/drm_gem.h | 45 ++---
>  3 files changed, 65 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 25dac31eef37..8f2eff448bb5 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj)
>  }
>  EXPORT_SYMBOL(drm_gem_object_release);
>
> -/**
> - * drm_gem_object_free - free a GEM object
> - * @kref: kref of the object to free
> - *
> - * Called after the last reference to the object has been lost.
> - * Must be called holding struct_ mutex
> - *
> - * Frees the object
> - */
> -void
> +static void
>  drm_gem_object_free(struct kref *kref)
>  {
> struct drm_gem_object *obj =
> @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
>
> WARN_ON(!mutex_is_locked(&dev->struct_mutex));
>
> -   if (dev->driver->gem_free_object != NULL)
> +   if (dev->driver->gem_free_object_unlocked != NULL)
> +   dev->driver->gem_free_object_unlocked(obj);
> +   else if (dev->driver->gem_free_object != NULL)
> dev->driver->gem_free_object(obj);
>  }
> -EXPORT_SYMBOL(drm_gem_object_free);
> +
> +/**
> + * drm_gem_object_unreference_unlocked - release a GEM BO reference
> + * @obj: GEM buffer object
> + *
> + * This releases a reference to @obj. Callers must not hold the
> + * dev->struct_mutex lock when calling this function.
> + */
> +void
> +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
> +{
> +   struct drm_device *dev;
> +
> +   if (!obj)
> +   return;
> +
> +   dev = obj->dev;
> +   might_lock(&dev->struct_mutex);
> +
> +   if (dev->driver->gem_free_object != NULL)
> +   kref_put(&obj->refcount, drm_gem_object_free);
> +   else if (kref_put_mutex(&obj->refcount, drm_gem_object_free,
> +   &dev->struct_mutex))
> +   mutex_unlock(&dev->struct_mutex);
> +}
> +EXPORT_SYMBOL(drm_gem_object_unreference_unlocked);
> +
> +/**
> + * drm_gem_object_unreference - release a GEM BO reference
> + * @obj: GEM buffer object
> + *
> + * This releases a reference to @obj. Callers must hold the dev->struct_mutex
> + * lock when calling this function, even when the driver doesn't use
> + * dev->struct_mutex for anything.
> + *
> + * For drivers not encumbered with legacy locking use
> + * drm_gem_object_unreference_unlocked() instead.
> + */
> +void
> +drm_gem_object_unreference(struct drm_gem_object *obj)
> +{
> +   if (obj != NULL) {
> +   WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
> +
> +   kref_put(&obj->refcount, drm_gem_object_free);
> +   }
> +}
> +EXPORT_SYMBOL(drm_gem_object_unreference);
>
>  /**
>   * drm_gem_vm_open - vma->ops->open implementation for GEM
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index c81dd2250fc6..7e30b3d2b25c 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -583,9 +583,19 @@ struct drm_driver {
>  * Driver-specific constructor for drm_gem_objects, to set up
>  * obj->driver_private.
>  *
> -* Returns 0 on success.
> +* This is deprecated and should not be used by new drivers. Use
> +* @gem_free_object_unlocked instead.
>  */
> void (*gem_free_object) (struct drm_gem_object *obj);
> +
> +   /**
> +* Driver-specific constructor for drm_gem_objects, to set up
> +* obj->driver_private. This is for drivers which are not encumbered
> +* with dev->struct_mutex legacy locking schemes. Use this hook 
> instead
> +* of @gem_free_object.
> +*/
> +   void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
> +
> int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
> void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
>
> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> index 0b3e11ab8757..ae1c7f18eec0 100644
> --- a/include/drm/drm_gem.h
> +++ b/include/drm/drm_gem.h
> @@ -175,7 +175,6 @@ struct drm_gem_object {
>  };
>
>  void drm_gem_object_release(struct drm_gem_object *obj);
> -void dr

Re: [Intel-gfx] [PATCH 08/35] drm: Protect dev->filelist with its own mutex

2016-04-26 Thread Alex Deucher
On Tue, Apr 26, 2016 at 4:52 PM, Chris Wilson  wrote:
> On Tue, Apr 26, 2016 at 07:29:41PM +0200, Daniel Vetter wrote:
>> amdgpu gained dev->struct_mutex usage, and that's because it's walking
>> the dev->filelist list. Protect that list with it's own lock to take
>> one more step towards getting rid of struct_mutex usage in drivers
>> once and for all.
>>
>> While doing the conversion I noticed that 2 debugfs files in i915
>> completely lacked appropriate locking. Fix that up too.
>>
>> v2: don't forget to switch to drm_gem_object_unreference_unlocked.
>>
>> Cc: Alex Deucher 
>> Signed-off-by: Daniel Vetter 
>
> Just wondering if this worth converting over. Opening/closing isn't
> going to be high contention, I hope, though we can certainly write
> stress cases for it! The goal for drivers to stop using the struct_mutex
> as their BKL, which doesn't preclude keeping the struct_mutex around for
> where it makes sense to have a single mutex rather than a multitude.
>
> I have some misgivings over this, but only because I think its overkill.
> Reviewed-by: Chris Wilson 

I agree with Chris' sentiments.

Reviewed-by: Alex Deucher 

> -Chris
>
> --
> Chris Wilson, Intel Open Source Technology Centre
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 07/35] drm: Make drm_vm_open/close_locked private to drm_vm.c

2016-04-26 Thread Alex Deucher
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter  wrote:
> It's only used for legacy mmaping support now.
>
> Signed-off-by: Daniel Vetter 

Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/drm_internal.h |  2 --
>  drivers/gpu/drm/drm_vm.c   | 16 
>  2 files changed, 4 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
> index c81ff4769e7b..902cf6a15212 100644
> --- a/drivers/gpu/drm/drm_internal.h
> +++ b/drivers/gpu/drm/drm_internal.h
> @@ -37,8 +37,6 @@ int drm_irq_by_busid(struct drm_device *dev, void *data,
>
>  /* drm_vm.c */
>  int drm_vma_info(struct seq_file *m, void *data);
> -void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma);
> -void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma);
>
>  /* drm_prime.c */
>  int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
> diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
> index f90bd5fe35ba..ac9f4b3ec615 100644
> --- a/drivers/gpu/drm/drm_vm.c
> +++ b/drivers/gpu/drm/drm_vm.c
> @@ -395,16 +395,8 @@ static const struct vm_operations_struct drm_vm_sg_ops = 
> {
> .close = drm_vm_close,
>  };
>
> -/**
> - * \c open method for shared virtual memory.
> - *
> - * \param vma virtual memory area.
> - *
> - * Create a new drm_vma_entry structure as the \p vma private data entry and
> - * add it to drm_device::vmalist.
> - */
> -void drm_vm_open_locked(struct drm_device *dev,
> -   struct vm_area_struct *vma)
> +static void drm_vm_open_locked(struct drm_device *dev,
> +  struct vm_area_struct *vma)
>  {
> struct drm_vma_entry *vma_entry;
>
> @@ -429,8 +421,8 @@ static void drm_vm_open(struct vm_area_struct *vma)
> mutex_unlock(&dev->struct_mutex);
>  }
>
> -void drm_vm_close_locked(struct drm_device *dev,
> -   struct vm_area_struct *vma)
> +static void drm_vm_close_locked(struct drm_device *dev,
> +   struct vm_area_struct *vma)
>  {
> struct drm_vma_entry *pt, *temp;
>
> --
> 2.8.1
>
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 06/35] drm: Hide master MAP cleanup in drm_bufs.c

2016-04-26 Thread Alex Deucher
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter  wrote:
> And again make sure it's a no-op for modern drivers, again with the
> exception of nouveau. Another case of dev->struct_mutex gone for
> modern drivers!
>
> v2: Also add a DRIVER_* check like for all other maps functions to
> really short-circuit the code. And give drm_legacy_rmmap used by the
> dev unregister code the same treatment.
>
> Signed-off-by: Daniel Vetter 

Just one comment below.

Acked-by: Alex Deucher 

> ---
>  drivers/gpu/drm/drm_bufs.c | 28 
>  drivers/gpu/drm/drm_drv.c  | 10 +-
>  include/drm/drm_legacy.h   |  4 +++-
>  3 files changed, 28 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index e8a12a4fd400..5a51633da033 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -542,18 +542,38 @@ int drm_legacy_rmmap_locked(struct drm_device *dev, 
> struct drm_local_map *map)
>  }
>  EXPORT_SYMBOL(drm_legacy_rmmap_locked);
>
> -int drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
> +void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
>  {
> -   int ret;
> +   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> +   drm_core_check_feature(dev, DRIVER_MODESET))
> +   return;
>
> mutex_lock(&dev->struct_mutex);
> -   ret = drm_legacy_rmmap_locked(dev, map);
> +   drm_legacy_rmmap_locked(dev, map);
> mutex_unlock(&dev->struct_mutex);
>
> -   return ret;
> +   return;

Can drop this.

>  }
>  EXPORT_SYMBOL(drm_legacy_rmmap);
>
> +void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master 
> *master)
> +{
> +   struct drm_map_list *r_list, *list_temp;
> +
> +   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> +   drm_core_check_feature(dev, DRIVER_MODESET))
> +   return;
> +
> +   mutex_lock(&dev->struct_mutex);
> +   list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
> +   if (r_list->master == master) {
> +   drm_legacy_rmmap_locked(dev, r_list->map);
> +   r_list = NULL;
> +   }
> +   }
> +   mutex_unlock(&dev->struct_mutex);
> +}
> +
>  /* The rmmap ioctl appears to be unnecessary.  All mappings are torn down on
>   * the last close of the device, and this is necessary for cleanup when 
> things
>   * exit uncleanly.  Therefore, having userland manually remove mappings seems
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 55273f8f3acb..e1fb52d4f72c 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -121,19 +121,11 @@ static void drm_master_destroy(struct kref *kref)
>  {
> struct drm_master *master = container_of(kref, struct drm_master, 
> refcount);
> struct drm_device *dev = master->minor->dev;
> -   struct drm_map_list *r_list, *list_temp;
>
> if (dev->driver->master_destroy)
> dev->driver->master_destroy(dev, master);
>
> -   mutex_lock(&dev->struct_mutex);
> -   list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
> -   if (r_list->master == master) {
> -   drm_legacy_rmmap_locked(dev, r_list->map);
> -   r_list = NULL;
> -   }
> -   }
> -   mutex_unlock(&dev->struct_mutex);
> +   drm_legacy_master_rmmaps(dev, master);
>
> idr_destroy(&master->magic_map);
> kfree(master->unique);
> diff --git a/include/drm/drm_legacy.h b/include/drm/drm_legacy.h
> index 3e698038dc7b..a5ef2c7e40f8 100644
> --- a/include/drm/drm_legacy.h
> +++ b/include/drm/drm_legacy.h
> @@ -154,8 +154,10 @@ struct drm_map_list {
>  int drm_legacy_addmap(struct drm_device *d, resource_size_t offset,
>   unsigned int size, enum drm_map_type type,
>   enum drm_map_flags flags, struct drm_local_map **map_p);
> -int drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map);
> +void drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map);
>  int drm_legacy_rmmap_locked(struct drm_device *d, struct drm_local_map *map);
> +void drm_legacy_master_rmmaps(struct drm_device *dev,
> + struct drm_master *master);
>  struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev);
>  int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma);
>
> --
> 2.8.1
>
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 05/35] drm: Push struct_mutex into ->master_destroy

2016-04-26 Thread Alex Deucher
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter  wrote:
> Only two drivers implement this hook. vmwgfx (which doesn't need it
> really) and legacy radeon (which since v1 has been nuked, yay).
>
> v1: Rebase over radeon ums removal.
>
> Cc: Thomas Hellstrom 
> Cc: Alex Deucher 
> Signed-off-by: Daniel Vetter 

Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/drm_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index f8a7a6e66b7e..55273f8f3acb 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -123,10 +123,10 @@ static void drm_master_destroy(struct kref *kref)
> struct drm_device *dev = master->minor->dev;
> struct drm_map_list *r_list, *list_temp;
>
> -   mutex_lock(&dev->struct_mutex);
> if (dev->driver->master_destroy)
> dev->driver->master_destroy(dev, master);
>
> +   mutex_lock(&dev->struct_mutex);
> list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
> if (r_list->master == master) {
> drm_legacy_rmmap_locked(dev, r_list->map);
> --
> 2.8.1
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 04/35] drm: Forbid legacy MAP functions for DRIVER_MODESET

2016-04-26 Thread Alex Deucher
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter  wrote:
> Like in
>
> commit 0e975980d435d58df2d430d688b8c18778b42218
> Author: Peter Antoine 
> Date:   Tue Jun 23 08:18:49 2015 +0100
>
> drm: Turn off Legacy Context Functions
>
> we need to again make an exception for nouveau, but everyone else
> really doesn't need this.
>
> Cc: Peter Antoine 
> Cc: Ben Skeggs 
> Signed-off-by: Daniel Vetter 

Not really familiar with why nouveau needs this, but the logic seems correct.
Acked-by: Alex Deucher 


> ---
>  drivers/gpu/drm/drm_bufs.c | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index d92db7007f62..e8a12a4fd400 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -396,6 +396,10 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void 
> *data,
> if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == 
> _DRM_SHM))
> return -EPERM;
>
> +   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> +   drm_core_check_feature(dev, DRIVER_MODESET))
> +   return -EINVAL;
> +
> err = drm_addmap_core(dev, map->offset, map->size, map->type,
>   map->flags, &maplist);
>
> @@ -438,6 +442,10 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void 
> *data,
> int idx;
> int i;
>
> +   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> +   drm_core_check_feature(dev, DRIVER_MODESET))
> +   return -EINVAL;
> +
> idx = map->offset;
> if (idx < 0)
> return -EINVAL;
> @@ -569,6 +577,10 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void 
> *data,
> struct drm_map_list *r_list;
> int ret;
>
> +   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> +   drm_core_check_feature(dev, DRIVER_MODESET))
> +   return -EINVAL;
> +
> mutex_lock(&dev->struct_mutex);
> list_for_each_entry(r_list, &dev->maplist, head) {
> if (r_list->map &&
> --
> 2.8.1
>
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 03/35] drm: Move drm_getmap into drm_bufs.c and give it a legacy prefix

2016-04-26 Thread Alex Deucher
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter  wrote:
> It belongs right next to the addmap and rmmap functions really. And
> for OCD consistency name it drm_legacy_getmap_ioctl.
>
> Signed-off-by: Daniel Vetter 

Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/drm_bufs.c   | 52 ++
>  drivers/gpu/drm/drm_ioctl.c  | 54 
> +---
>  drivers/gpu/drm/drm_legacy.h |  2 ++
>  3 files changed, 55 insertions(+), 53 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index f1a204d253cc..d92db7007f62 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -416,6 +416,58 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void 
> *data,
> return 0;
>  }
>
> +/*
> + * Get a mapping information.
> + *
> + * \param inode device inode.
> + * \param file_priv DRM file private.
> + * \param cmd command.
> + * \param arg user argument, pointing to a drm_map structure.
> + *
> + * \return zero on success or a negative number on failure.
> + *
> + * Searches for the mapping with the specified offset and copies its 
> information
> + * into userspace
> + */
> +int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
> +   struct drm_file *file_priv)
> +{
> +   struct drm_map *map = data;
> +   struct drm_map_list *r_list = NULL;
> +   struct list_head *list;
> +   int idx;
> +   int i;
> +
> +   idx = map->offset;
> +   if (idx < 0)
> +   return -EINVAL;
> +
> +   i = 0;
> +   mutex_lock(&dev->struct_mutex);
> +   list_for_each(list, &dev->maplist) {
> +   if (i == idx) {
> +   r_list = list_entry(list, struct drm_map_list, head);
> +   break;
> +   }
> +   i++;
> +   }
> +   if (!r_list || !r_list->map) {
> +   mutex_unlock(&dev->struct_mutex);
> +   return -EINVAL;
> +   }
> +
> +   map->offset = r_list->map->offset;
> +   map->size = r_list->map->size;
> +   map->type = r_list->map->type;
> +   map->flags = r_list->map->flags;
> +   map->handle = (void *)(unsigned long) r_list->user_token;
> +   map->mtrr = arch_phys_wc_index(r_list->map->mtrr);
> +
> +   mutex_unlock(&dev->struct_mutex);
> +
> +   return 0;
> +}
> +
>  /**
>   * Remove a map private from list and deallocate resources if the mapping
>   * isn't in use.
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 3ecd1368c23a..24b941c3b561 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -148,58 +148,6 @@ static int drm_set_busid(struct drm_device *dev, struct 
> drm_file *file_priv)
>  }
>
>  /*
> - * Get a mapping information.
> - *
> - * \param inode device inode.
> - * \param file_priv DRM file private.
> - * \param cmd command.
> - * \param arg user argument, pointing to a drm_map structure.
> - *
> - * \return zero on success or a negative number on failure.
> - *
> - * Searches for the mapping with the specified offset and copies its 
> information
> - * into userspace
> - */
> -static int drm_getmap(struct drm_device *dev, void *data,
> -  struct drm_file *file_priv)
> -{
> -   struct drm_map *map = data;
> -   struct drm_map_list *r_list = NULL;
> -   struct list_head *list;
> -   int idx;
> -   int i;
> -
> -   idx = map->offset;
> -   if (idx < 0)
> -   return -EINVAL;
> -
> -   i = 0;
> -   mutex_lock(&dev->struct_mutex);
> -   list_for_each(list, &dev->maplist) {
> -   if (i == idx) {
> -   r_list = list_entry(list, struct drm_map_list, head);
> -   break;
> -   }
> -   i++;
> -   }
> -   if (!r_list || !r_list->map) {
> -   mutex_unlock(&dev->struct_mutex);
> -   return -EINVAL;
> -   }
> -
> -   map->offset = r_list->map->offset;
> -   map->size = r_list->map->size;
> -   map->type = r_list->map->type;
> -   map->flags = r_list->map->flags;
> -   map->handle = (void *)(unsigned long) r_list->user_token;
> -   map->mtrr = arch_phys_wc_index(r_list->map->mtrr);
> -
> -   mutex_unlock(&dev->struct_mutex);
> -
> -   return 0;
> -}
> -
> -/*
>   * Get client information.
>   *
>   * \param inode device inode.
> @@ -556,7 +504,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
> DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0),
> DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0),
> DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, 
> DRM_MASTER|DRM_ROOT_ONLY),
> -   DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, DRM_UNLOCKED),
> +   DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_legacy_getmap_ioctl, 
> DRM_UNLOCKED),
> DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, DR

Re: [Intel-gfx] [PATCH 02/35] drm: Put legacy lastclose work into drm_legacy_dev_reinit

2016-04-26 Thread Alex Deucher
On Tue, Apr 26, 2016 at 1:29 PM, Daniel Vetter  wrote:
> Except for the ->lasclose driver callback evrything in drm_lastclose()
> is all legacy cruft and can be hidden. Which means another
> dev->struct_mutex site disappears entirely for modern drivers!
>
> Also while at it change the return value of drm_lastclose to void
> since it will always succeed. No one checks the return value of
> close() anyway, ever.
>
> v2: Move misplaced hunk, spotted by 0day.
>
> Cc: Thierry Reding 
> Signed-off-by: Daniel Vetter 

Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/drm_fops.c | 42 
> +++---
>  drivers/gpu/drm/drm_internal.h |  2 +-
>  2 files changed, 20 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index 7b5a13cda7a6..c3d0aaac0669 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -381,14 +381,26 @@ static void drm_events_release(struct drm_file 
> *file_priv)
>   */
>  static void drm_legacy_dev_reinit(struct drm_device *dev)
>  {
> -   if (drm_core_check_feature(dev, DRIVER_MODESET))
> -   return;
> +   if (dev->irq_enabled)
> +   drm_irq_uninstall(dev);
> +
> +   mutex_lock(&dev->struct_mutex);
> +
> +   drm_legacy_agp_clear(dev);
> +
> +   drm_legacy_sg_cleanup(dev);
> +   drm_legacy_vma_flush(dev);
> +   drm_legacy_dma_takedown(dev);
> +
> +   mutex_unlock(&dev->struct_mutex);
>
> dev->sigdata.lock = NULL;
>
> dev->context_flag = 0;
> dev->last_context = 0;
> dev->if_version = 0;
> +
> +   DRM_DEBUG("lastclose completed\n");
>  }
>
>  /*
> @@ -400,7 +412,7 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
>   *
>   * \sa drm_device
>   */
> -int drm_lastclose(struct drm_device * dev)
> +void drm_lastclose(struct drm_device * dev)
>  {
> DRM_DEBUG("\n");
>
> @@ -408,23 +420,8 @@ int drm_lastclose(struct drm_device * dev)
> dev->driver->lastclose(dev);
> DRM_DEBUG("driver lastclose completed\n");
>
> -   if (dev->irq_enabled && !drm_core_check_feature(dev, DRIVER_MODESET))
> -   drm_irq_uninstall(dev);
> -
> -   mutex_lock(&dev->struct_mutex);
> -
> -   drm_legacy_agp_clear(dev);
> -
> -   drm_legacy_sg_cleanup(dev);
> -   drm_legacy_vma_flush(dev);
> -   drm_legacy_dma_takedown(dev);
> -
> -   mutex_unlock(&dev->struct_mutex);
> -
> -   drm_legacy_dev_reinit(dev);
> -
> -   DRM_DEBUG("lastclose completed\n");
> -   return 0;
> +   if (!drm_core_check_feature(dev, DRIVER_MODESET))
> +   drm_legacy_dev_reinit(dev);
>  }
>
>  /**
> @@ -445,7 +442,6 @@ int drm_release(struct inode *inode, struct file *filp)
> struct drm_file *file_priv = filp->private_data;
> struct drm_minor *minor = file_priv->minor;
> struct drm_device *dev = minor->dev;
> -   int retcode = 0;
>
> mutex_lock(&drm_global_mutex);
>
> @@ -538,7 +534,7 @@ int drm_release(struct inode *inode, struct file *filp)
>  */
>
> if (!--dev->open_count) {
> -   retcode = drm_lastclose(dev);
> +   drm_lastclose(dev);
> if (drm_device_is_unplugged(dev))
> drm_put_dev(dev);
> }
> @@ -546,7 +542,7 @@ int drm_release(struct inode *inode, struct file *filp)
>
> drm_minor_release(minor);
>
> -   return retcode;
> +   return 0;
>  }
>  EXPORT_SYMBOL(drm_release);
>
> diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
> index 43cbda3306ac..c81ff4769e7b 100644
> --- a/drivers/gpu/drm/drm_internal.h
> +++ b/drivers/gpu/drm/drm_internal.h
> @@ -26,7 +26,7 @@ extern unsigned int drm_timestamp_monotonic;
>
>  /* drm_fops.c */
>  extern struct mutex drm_global_mutex;
> -int drm_lastclose(struct drm_device *dev);
> +void drm_lastclose(struct drm_device *dev);
>
>  /* drm_pci.c */
>  int drm_pci_set_unique(struct drm_device *dev,
> --
> 2.8.1
>
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 04/35] drm: Forbid legacy MAP functions for DRIVER_MODESET

2016-04-26 Thread Chris Wilson
On Tue, Apr 26, 2016 at 07:29:37PM +0200, Daniel Vetter wrote:
> Like in
> 
> commit 0e975980d435d58df2d430d688b8c18778b42218
> Author: Peter Antoine 
> Date:   Tue Jun 23 08:18:49 2015 +0100
> 
> drm: Turn off Legacy Context Functions
> 
> we need to again make an exception for nouveau, but everyone else
> really doesn't need this.
> 
> Cc: Peter Antoine 
> Cc: Ben Skeggs 
> Signed-off-by: Daniel Vetter 

* mutters something about MODESET && !MODESET_LEGACY reading better.

Looks consistent, not going to comment on LEGACY though. There are no
direct users of the the addmap interface, so just whatever comes in
through an ioctl.
-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 03/35] drm: Move drm_getmap into drm_bufs.c and give it a legacy prefix

2016-04-26 Thread Chris Wilson
On Tue, Apr 26, 2016 at 07:29:36PM +0200, Daniel Vetter wrote:
> It belongs right next to the addmap and rmmap functions really. And
> for OCD consistency name it drm_legacy_getmap_ioctl.
> 
> Signed-off-by: Daniel Vetter 
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 06/35] drm: Hide master MAP cleanup in drm_bufs.c

2016-04-26 Thread Chris Wilson
On Tue, Apr 26, 2016 at 07:29:39PM +0200, Daniel Vetter wrote:
> And again make sure it's a no-op for modern drivers, again with the
> exception of nouveau. Another case of dev->struct_mutex gone for
> modern drivers!
> 
> v2: Also add a DRIVER_* check like for all other maps functions to
> really short-circuit the code. And give drm_legacy_rmmap used by the
> dev unregister code the same treatment.
> 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/drm_bufs.c | 28 
>  drivers/gpu/drm/drm_drv.c  | 10 +-
>  include/drm/drm_legacy.h   |  4 +++-
>  3 files changed, 28 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index e8a12a4fd400..5a51633da033 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -542,18 +542,38 @@ int drm_legacy_rmmap_locked(struct drm_device *dev, 
> struct drm_local_map *map)
>  }
>  EXPORT_SYMBOL(drm_legacy_rmmap_locked);
>  
> -int drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
> +void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
>  {
> - int ret;
> + if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> + drm_core_check_feature(dev, DRIVER_MODESET))
> + return;
>  
>   mutex_lock(&dev->struct_mutex);
> - ret = drm_legacy_rmmap_locked(dev, map);
> + drm_legacy_rmmap_locked(dev, map);
>   mutex_unlock(&dev->struct_mutex);
>  
> - return ret;
> + return;

2 dead lines.

>  }
>  EXPORT_SYMBOL(drm_legacy_rmmap);
>  
> +void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master 
> *master)
> +{
> + struct drm_map_list *r_list, *list_temp;
> +
> + if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
> + drm_core_check_feature(dev, DRIVER_MODESET))
> + return;
> +
> + mutex_lock(&dev->struct_mutex);
> + list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
> + if (r_list->master == master) {
> + drm_legacy_rmmap_locked(dev, r_list->map);
> + r_list = NULL;
> + }
> + }
> + mutex_unlock(&dev->struct_mutex);
> +}

Hmm, the entirety of the addmap interface is not guarded by legacy.
Would be good to say the two users mga and savage are !MODESET.

> +
>  /* The rmmap ioctl appears to be unnecessary.  All mappings are torn down on
>   * the last close of the device, and this is necessary for cleanup when 
> things
>   * exit uncleanly.  Therefore, having userland manually remove mappings seems
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 55273f8f3acb..e1fb52d4f72c 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -121,19 +121,11 @@ static void drm_master_destroy(struct kref *kref)
>  {
>   struct drm_master *master = container_of(kref, struct drm_master, 
> refcount);
>   struct drm_device *dev = master->minor->dev;
> - struct drm_map_list *r_list, *list_temp;
>  
>   if (dev->driver->master_destroy)
>   dev->driver->master_destroy(dev, master);
>  
> - mutex_lock(&dev->struct_mutex);
> - list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
> - if (r_list->master == master) {
> - drm_legacy_rmmap_locked(dev, r_list->map);
> - r_list = NULL;
> - }
> - }
> - mutex_unlock(&dev->struct_mutex);
> + drm_legacy_master_rmmaps(dev, master);

WARN_ON(!list_empty(&dev->maplist));

might be useful?

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 01/35] drm: Give drm_agp_clear drm_legacy_ prefix

2016-04-26 Thread Chris Wilson
On Tue, Apr 26, 2016 at 07:29:34PM +0200, Daniel Vetter wrote:
> It has a  DRIVER_MODESET check to sure make it's not creating havoc
> for drm drivers. Make that clear in the name too.

The pattern is that any extern that starts

if (drm_core_check_feature(MODESET)) return

becomes drm_legacy_ ? With the apparent caveat of KMS_LEGACY_CONTEXT.
 
> v2: Move misplaced hunk, spotted by 0day and Thierry.
> 
> Cc: Thierry Reding 
> Signed-off-by: Daniel Vetter 
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] driver crashes if I try to het 2560 x 1440 @ 50Hz CVT-RB running under Linux... Ideas?

2016-04-26 Thread Andreas Balg

As I cannot reinstall the entire machine from scratch I tried first to 
verify the issue using a Fedora 23 - Live USB Stick (which still runs
on Kernel 4.2.3) = > It practically show exactly the same
results/errors.

I've also cleaned my machine very thoroughly from any packages
installed or updated using the intel-graphics-installer and
downgraded/replaced everything using the current stable fedora packages
and even removed dkms entirely and reinstalled the kernel and kernel-
modules:

But the error remains the same:

Packages removed/replaced/downgraded:

cairo.i6861.14.4-23.intel20154
cairo.x86_641.14.4-23.intel20154
cairo-gobject.x86_64   1.14.4-23.intel20154
intel-gpu-tools.x86_64 2.99.917-23.intel20154
libva-intel-driver.i686  1.6.2-23.intel20154
libva-intel-driver.x86_64  1.6.2-23.intel20154
xorg-x11-drv-intel.x86_642.99.917-23.intel20154

    intel-linux-graphics-installer.x86_64  1.4.0-23.intel20154

Kernel from USB-Live medium was:
Linux localhost 4.2.3-300.fc23.x86_64 #1 SMP Mon Oct 5 15:42:54
UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

The error message from dmesg:

[   22.767160] [ cut here ]
[   22.767232] WARNING: CPU: 1 PID: 1792 at
drivers/gpu/drm/i915/intel_display.c:1064
intel_disable_pipe+0x28d/0x2a0 [i915]()
[   22.767236] pipe_off wait timed out
[   22.767239] Modules linked in: rfcomm xt_CHECKSUM ipt_MASQUERADE
nf_nat_masquerade_ipv4 tun fuse nf_conntrack_netbios_ns
nf_conntrack_broadcast ip6t_rpfilter ip6t_REJECT nf_reject_ipv6
xt_conntrack ebtable_nat ebtable_filter ebtable_broute bridge ebtables
ip6table_raw ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6
ip6table_mangle ip6table_security ip6table_filter ip6_tables
iptable_raw iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4
nf_nat nf_conntrack iptable_mangle iptable_security bnep rtsx_usb_ms
memstick arc4 uvcvideo videobuf2_vmalloc videobuf2_core
videobuf2_memops v4l2_common iwlmvm videodev mac80211 intel_rapl
snd_usb_audio snd_usbmidi_lib media iosf_mbi x86_pkg_temp_thermal
coretemp kvm_intel kvm snd_rawmidi iTCO_wdt iTCO_vendor_support
asus_nb_wmi asus_wmi sparse_keymap
[   22.767322]  btusb btrtl btbcm btintel bluetooth snd_hda_codec_hdmi
snd_hda_codec_realtek snd_hda_codec_generic iwlwifi snd_hda_intel
snd_hda_codec cfg80211 snd_hda_core snd_hwdep snd_seq snd_seq_device
snd_pcm joydev snd_timer snd acpi_als int3402_thermal rfkill mei_me
i2c_i801 int3403_thermal int340x_thermal_zone kfifo_buf industrialio
shpchp int3400_thermal acpi_thermal_rel tpm_tis tpm lpc_ich soundcore
mei nfsd auth_rpcgss nfs_acl lockd grace isofs squashfs
hid_logitech_hidpp hid_logitech_dj i915 crct10dif_pclmul crc32_pclmul
crc32c_intel 8021q garp stp llc cdc_mbim i2c_algo_bit mrp cdc_wdm
ghash_clmulni_intel drm_kms_helper serio_raw drm cdc_ncm usbnet uas mii
usb_storage wmi video rtsx_usb_sdmmc mmc_core rtsx_usb scsi_dh_rdac
scsi_dh_emc scsi_dh_alua sunrpc loop
[   22.767426] CPU: 1 PID: 1792 Comm: Xorg Not tainted 4.2.3-
300.fc23.x86_64 #1
[   22.767430] Hardware name: ASUSTeK COMPUTER INC. UX31A/UX31A, BIOS
UX31A.219 06/14/2013
[   22.767434]   6a212948 8801191cfa38
81771fca
[   22.767441]   8801191cfa90 8801191cfa78
8109e4a6
[   22.767447]  0700 88003da1 00070008
fffbc193
[   22.767453] Call Trace:
[   22.767464]  [] dump_stack+0x45/0x57
[   22.767475]  [] warn_slowpath_common+0x86/0xc0
[   22.767482]  [] warn_slowpath_fmt+0x55/0x70
[   22.767530]  [] intel_disable_pipe+0x28d/0x2a0
[i915]
[   22.767569]  [] ironlake_crtc_disable+0x93/0x7f0
[i915]
[   22.767611]  [] ?
intel_frontbuffer_flush+0x63/0x70 [i915]
[   22.767651]  [] __intel_set_mode+0x94c/0xb60
[i915]
[   22.767689]  [] ?
intel_modeset_compute_config+0x3af/0xb60 [i915]
[   22.767738]  [] intel_crtc_set_config+0x2b6/0x580
[i915]
[   22.767804]  []
drm_mode_set_config_internal+0x66/0x100 [drm]
[   22.767926]  [] drm_mode_setcrtc+0x3e9/0x500 [drm]
[   22.767948]  [] drm_ioctl+0x125/0x610 [drm]
[   22.767976]  [] ? drm_mode_setplane+0x1b0/0x1b0
[drm]
[   22.767992]  [] do_vfs_ioctl+0x295/0x470
[   22.768000]  [] ? selinux_file_ioctl+0x4d/0xc0
[   22.768006]  [] SyS_ioctl+0x79/0x90
[   22.768014]  [] ? SyS_rt_sigprocmask+0x8e/0xc0
[   22.768022]  []
entry_SYSCALL_64_fastpath+0x12/0x71
[   22.768029] ---[ end trace b2da396d1e42e1ca ]---
[   23.711060] [drm:intel_set_pch_fifo_underrun_reporting [i915]]
*ERROR* uncleared pch fifo underrun on pch transcoder A
[   23.73] [drm:intel_pch_fifo_underrun_irq_handler [i915]] *ERROR*
PCH transcoder A FIFO underrun


Seems basically the same to me 

Cheers


Am Dienstag, den 26.04.2016, 17:18 + schrieb Parenteau, Paul A:
> Have you tried this setup using Fedora 23 without the 1.4.0
> Installer?  If not, please do and report back.
>  
>

Re: [Intel-gfx] [PATCH 05/35] drm: Push struct_mutex into ->master_destroy

2016-04-26 Thread Chris Wilson
On Tue, Apr 26, 2016 at 07:29:38PM +0200, Daniel Vetter wrote:
> Only two drivers implement this hook. vmwgfx (which doesn't need it
> really) and legacy radeon (which since v1 has been nuked, yay).
> 
> v1: Rebase over radeon ums removal.
> 
> Cc: Thomas Hellstrom 
> Cc: Alex Deucher 
> Signed-off-by: Daniel Vetter 
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 08/35] drm: Protect dev->filelist with its own mutex

2016-04-26 Thread Chris Wilson
On Tue, Apr 26, 2016 at 07:29:41PM +0200, Daniel Vetter wrote:
> amdgpu gained dev->struct_mutex usage, and that's because it's walking
> the dev->filelist list. Protect that list with it's own lock to take
> one more step towards getting rid of struct_mutex usage in drivers
> once and for all.
> 
> While doing the conversion I noticed that 2 debugfs files in i915
> completely lacked appropriate locking. Fix that up too.
> 
> v2: don't forget to switch to drm_gem_object_unreference_unlocked.
> 
> Cc: Alex Deucher 
> Signed-off-by: Daniel Vetter 

Just wondering if this worth converting over. Opening/closing isn't
going to be high contention, I hope, though we can certainly write
stress cases for it! The goal for drivers to stop using the struct_mutex
as their BKL, which doesn't preclude keeping the struct_mutex around for
where it makes sense to have a single mutex rather than a multitude.

I have some misgivings over this, but only because I think its overkill.
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] drm/i915/kbl: Introduce the first official DMC for Kabylake.

2016-04-26 Thread Patrik Jakobsson
On Tue, Apr 26, 2016 at 6:44 PM, Rodrigo Vivi  wrote:
> Version 1.01.
>
> This firmware is made for Kabylake platform so it doesn't
> need the stepping workaround that we had before.
>
> v2: Rebased on top of latest nightly with min version
> required change.
>
> Cc: Christophe Prigent 
> Cc: Patrik Jakobsson 
> Reviewed-by: Ben Widawsky  (v1)
> Signed-off-by: Rodrigo Vivi 
> ---
>  drivers/gpu/drm/i915/intel_csr.c | 30 +++---
>  1 file changed, 19 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_csr.c 
> b/drivers/gpu/drm/i915/intel_csr.c
> index a34c23e..64cb38f 100644
> --- a/drivers/gpu/drm/i915/intel_csr.c
> +++ b/drivers/gpu/drm/i915/intel_csr.c
> @@ -41,16 +41,22 @@
>   * be moved to FW_FAILED.
>   */
>
> +#define I915_CSR_KBL "i915/kbl_dmc_ver1.bin"
> +MODULE_FIRMWARE(I915_CSR_KBL);
> +#define KBL_CSR_VERSION_REQUIRED   CSR_VERSION(1, 23)

Shouldn't this be CSR_VERSION(1,1) now that you've released the KBL
DMC firmware?

> +
>  #define I915_CSR_SKL "i915/skl_dmc_ver1.bin"
> +MODULE_FIRMWARE(I915_CSR_SKL);
> +#define SKL_CSR_VERSION_REQUIRED   CSR_VERSION(1, 23)
> +
>  #define I915_CSR_BXT "i915/bxt_dmc_ver1.bin"
> +MODULE_FIRMWARE(I915_CSR_BXT);
> +#define BXT_CSR_VERSION_REQUIRED   CSR_VERSION(1, 7)
>
>  #define FIRMWARE_URL  
> "https://01.org/linuxgraphics/intel-linux-graphics-firmwares";
>
> -MODULE_FIRMWARE(I915_CSR_SKL);
> -MODULE_FIRMWARE(I915_CSR_BXT);
>
> -#define SKL_CSR_VERSION_REQUIRED   CSR_VERSION(1, 23)
> -#define BXT_CSR_VERSION_REQUIRED   CSR_VERSION(1, 7)
> +
>
>  #define CSR_MAX_FW_SIZE0x2FFF
>  #define CSR_DEFAULT_FW_OFFSET  0x
> @@ -169,12 +175,10 @@ struct stepping_info {
> char substepping;
>  };
>
> -/*
> - * Kabylake derivated from Skylake H0, so SKL H0
> - * is the right firmware for KBL A0 (revid 0).
> - */
>  static const struct stepping_info kbl_stepping_info[] = {
> -   {'H', '0'}, {'I', '0'}
> +   {'A', '0'}, {'B', '0'}, {'C', '0'},
> +   {'D', '0'}, {'E', '0'}, {'F', '0'},
> +   {'G', '0'}, {'H', '0'}, {'I', '0'},
>  };
>
>  static const struct stepping_info skl_stepping_info[] = {
> @@ -298,7 +302,9 @@ static uint32_t *parse_csr_fw(struct drm_i915_private 
> *dev_priv,
>
> csr->version = css_header->version;
>
> -   if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) {
> +   if (IS_KABYLAKE(dev_priv)) {
> +   required_min_version = KBL_CSR_VERSION_REQUIRED;
> +   } else if (IS_SKYLAKE(dev_priv)) {
> required_min_version = SKL_CSR_VERSION_REQUIRED;
> } else if (IS_BROXTON(dev_priv)) {
> required_min_version = BXT_CSR_VERSION_REQUIRED;
> @@ -446,7 +452,9 @@ void intel_csr_ucode_init(struct drm_i915_private 
> *dev_priv)
> if (!HAS_CSR(dev_priv))
> return;
>
> -   if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv))
> +   if (IS_KABYLAKE(dev_priv))
> +   csr->fw_path = I915_CSR_KBL;
> +   else if (IS_SKYLAKE(dev_priv))
> csr->fw_path = I915_CSR_SKL;
> else if (IS_BROXTON(dev_priv))
> csr->fw_path = I915_CSR_BXT;
> --
> 2.4.3
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 09/35] drm/gem: support BO freeing without dev->struct_mutex

2016-04-26 Thread Chris Wilson
On Tue, Apr 26, 2016 at 10:10:14PM +0200, Daniel Vetter wrote:
> On Tue, Apr 26, 2016 at 08:47:32PM +0100, Chris Wilson wrote:
> > On Tue, Apr 26, 2016 at 07:29:42PM +0200, Daniel Vetter wrote:
> > > Finally all the core gem and a lot of drivers are entirely free of
> > > dev->struct_mutex depencies, and we can start to have an entirely
> > > lockless unref path.
> > > 
> > > To make sure that no one who touches the core code accidentally breaks
> > > existing drivers which still require dev->struct_mutex I've made the
> > > might_lock check unconditional.
> > > 
> > > While at it de-inline the ref/unref functions, they've become a bit
> > > too big.
> > > 
> > > v2: Make it not leak like a sieve.
> > > 
> > > Signed-off-by: Daniel Vetter 
> > > ---
> > >  drivers/gpu/drm/drm_gem.c | 64 
> > > ++-
> > >  include/drm/drmP.h| 12 -
> > >  include/drm/drm_gem.h | 45 ++---
> > >  3 files changed, 65 insertions(+), 56 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> > > index 25dac31eef37..8f2eff448bb5 100644
> > > --- a/drivers/gpu/drm/drm_gem.c
> > > +++ b/drivers/gpu/drm/drm_gem.c
> > > @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj)
> > >  }
> > >  EXPORT_SYMBOL(drm_gem_object_release);
> > >  
> > > -/**
> > > - * drm_gem_object_free - free a GEM object
> > > - * @kref: kref of the object to free
> > > - *
> > > - * Called after the last reference to the object has been lost.
> > > - * Must be called holding struct_ mutex
> > > - *
> > > - * Frees the object
> > > - */
> > > -void
> > > +static void
> > >  drm_gem_object_free(struct kref *kref)
> > >  {
> > >   struct drm_gem_object *obj =
> > > @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
> > >  
> > >   WARN_ON(!mutex_is_locked(&dev->struct_mutex));
> > >  
> > > - if (dev->driver->gem_free_object != NULL)
> > > + if (dev->driver->gem_free_object_unlocked != NULL)
> > > + dev->driver->gem_free_object_unlocked(obj);
> > > + else if (dev->driver->gem_free_object != NULL)
> > >   dev->driver->gem_free_object(obj);
> > >  }
> > > -EXPORT_SYMBOL(drm_gem_object_free);
> > > +
> > > +/**
> > > + * drm_gem_object_unreference_unlocked - release a GEM BO reference
> > > + * @obj: GEM buffer object
> > > + *
> > > + * This releases a reference to @obj. Callers must not hold the
> > > + * dev->struct_mutex lock when calling this function.
> > > + */
> > > +void
> > > +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
> > > +{
> > 
> > I have i915.ko in a state where we could use this as well. I would like
> > to have our inlines back though. I would add
> > 
> > static inline void
> > i915_gem_object_put(struct drm_i915_gem_object *obj)
> > {
> > kref_put(&obj->base.refcount, drm_gem_object_free);
> > }
> > 
> > Hmm, considering how simple that is, maybe I won't ask for
> > 
> > static inline void
> > __drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
> > {
> > BUG_ON(obj->dev->driver->gem_free_object == NULL);
> > kref_put(&obj->refcount, drm_gem_object_free);
> > }
> 
> Yeah, something like that makes sense. Imo the core versions really need
> all the silly locking checks and all that to make sure no one abuses them
> by accident, or breaks a driver still using struct_mutex. Adding a
> fastpath for drivers using gem_free_object_unlocked just wrapping the
> kref_put certainly looks like a good idea.
> 
> And if we document the exact use case I think we could even nuke the
> BUG_ON too. This can be audited with a simple
> 
> $ git grep __drm_gem_object_unreference_unlocked -- drivers/gpu/drm/$driver
> 
> so imo nothing too dangerous.
> 
> Ack/r-b on the patch itself?

Only an ack, I'm afraid. I haven't considered the ramifictions to know
if the intermediate steps are going to be painful (in some cases we'll
have an all a new hot function in our profiles, but overall there'll be
little change I hope). The end goal is definitely an improvement.

I've talked myself into having a better read of the core patches...
-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] i951 Xv playback uneven

2016-04-26 Thread Florian Zumbiehl
Hi,

with the drm-intel-nightly I am currently running, I am also seeing some
quite noticable stuttering in Xv playback. It's particularly obvious in
stuff like rolling credits. It's not directly a performance problem, as the
effect can be seen even in "stop motion" (i.e., frame by frame) playback:
Sometimes, no update happens, and then the next update "catches up", a bit
like some kind of double buffering sometimes fails to switch buffers.

Now, I haven't investigated this any further as I am getting the impression
that noone cares anyway (my mail with the debug info that Daniel requested
regarding some other problems has been almost a month ago and I got no
response to that at all) - I am happy to help where I can but I won't
invest any effort upfront if it's going to be ignored anyway, so please let
me know if you really want to look into this.

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


[Intel-gfx] [PATCH i-g-t v3 3/6] kms_panel_fitting: Remove un-used variable.

2016-04-26 Thread robert . foss
From: Robert Foss 

ref_crc is never assigned or read, and can be safely
removed.

Signed-off-by: Robert Foss 
Reviewed-by: Tomeu Vizoso 
---
 tests/kms_panel_fitting.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/kms_panel_fitting.c b/tests/kms_panel_fitting.c
index 7bfd980..099816b 100644
--- a/tests/kms_panel_fitting.c
+++ b/tests/kms_panel_fitting.c
@@ -31,7 +31,6 @@ IGT_TEST_DESCRIPTION("Test display panel fitting");
 typedef struct {
int drm_fd;
igt_display_t display;
-   igt_crc_t ref_crc;
 
int image_w;
int image_h;
-- 
2.5.0

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


[Intel-gfx] [PATCH v6 08/25] drm/i915: L3 cache remapping is part of context switching

2016-04-26 Thread Chris Wilson
Move the i915_gem_l3_remap function such that it next to the context
switching, which is where we perform the L3 remap.

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Reviewed-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_gem.c | 31 ---
 drivers/gpu/drm/i915/i915_gem_context.c | 31 +++
 2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index f9ef11273698..f07cf81ef16b 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4730,37 +4730,6 @@ err:
return ret;
 }
 
-int i915_gem_l3_remap(struct drm_i915_gem_request *req, int slice)
-{
-   struct intel_engine_cs *engine = req->engine;
-   struct drm_device *dev = engine->dev;
-   struct drm_i915_private *dev_priv = dev->dev_private;
-   u32 *remap_info = dev_priv->l3_parity.remap_info[slice];
-   int i, ret;
-
-   if (!HAS_L3_DPF(dev) || !remap_info)
-   return 0;
-
-   ret = intel_ring_begin(req, GEN7_L3LOG_SIZE / 4 * 3);
-   if (ret)
-   return ret;
-
-   /*
-* Note: We do not worry about the concurrent register cacheline hang
-* here because no other code should access these registers other than
-* at initialization time.
-*/
-   for (i = 0; i < GEN7_L3LOG_SIZE / 4; i++) {
-   intel_ring_emit(engine, MI_LOAD_REGISTER_IMM(1));
-   intel_ring_emit_reg(engine, GEN7_L3LOG(slice, i));
-   intel_ring_emit(engine, remap_info[i]);
-   }
-
-   intel_ring_advance(engine);
-
-   return ret;
-}
-
 void i915_gem_init_swizzling(struct drm_device *dev)
 {
struct drm_i915_private *dev_priv = dev->dev_private;
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c 
b/drivers/gpu/drm/i915/i915_gem_context.c
index 05752a2f1810..a429b4dcb4de 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -601,6 +601,37 @@ mi_set_context(struct drm_i915_gem_request *req, u32 
hw_flags)
return ret;
 }
 
+int i915_gem_l3_remap(struct drm_i915_gem_request *req, int slice)
+{
+   struct intel_engine_cs *engine = req->engine;
+   struct drm_device *dev = engine->dev;
+   struct drm_i915_private *dev_priv = dev->dev_private;
+   u32 *remap_info = dev_priv->l3_parity.remap_info[slice];
+   int i, ret;
+
+   if (!HAS_L3_DPF(dev) || !remap_info)
+   return 0;
+
+   ret = intel_ring_begin(req, GEN7_L3LOG_SIZE / 4 * 3);
+   if (ret)
+   return ret;
+
+   /*
+* Note: We do not worry about the concurrent register cacheline hang
+* here because no other code should access these registers other than
+* at initialization time.
+*/
+   for (i = 0; i < GEN7_L3LOG_SIZE / 4; i++) {
+   intel_ring_emit(engine, MI_LOAD_REGISTER_IMM(1));
+   intel_ring_emit_reg(engine, GEN7_L3LOG(slice, i));
+   intel_ring_emit(engine, remap_info[i]);
+   }
+
+   intel_ring_advance(engine);
+
+   return ret;
+}
+
 static inline bool skip_rcs_switch(struct intel_engine_cs *engine,
   struct intel_context *to)
 {
-- 
2.8.1

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


[Intel-gfx] [PATCH v6 17/25] drm/i915: Assign every HW context a unique ID

2016-04-26 Thread Chris Wilson
The hardware tracks contexts and expects all live contexts (those active
on the hardware) to have a unique identifier. This is used by the
hardware to assign pagefaults and the like to a particular context.

v2: Reorder to make sure ctx->link is not left dangling if the
assignment of a hw_id fails (Mika).

v3: We have 21bits of context space, not 20.

Signed-off-by: Chris Wilson 
Reviewed-by: Tvrtko Ursulin  #v2
---
 drivers/gpu/drm/i915/i915_debugfs.c |  2 +-
 drivers/gpu/drm/i915/i915_drv.h | 10 +
 drivers/gpu/drm/i915/i915_gem_context.c | 36 +
 3 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 4950d05d2948..3bd2f89933ff 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2001,7 +2001,7 @@ static int i915_context_status(struct seq_file *m, void 
*unused)
ctx->legacy_hw_ctx.rcs_state == NULL)
continue;
 
-   seq_puts(m, "HW context ");
+   seq_printf(m, "HW context %u ", ctx->hw_id);
describe_ctx(m, ctx);
if (ctx == dev_priv->kernel_context)
seq_printf(m, "(kernel context) ");
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 831da9f43324..0f7575252c6e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -851,6 +851,9 @@ struct intel_context {
struct i915_ctx_hang_stats hang_stats;
struct i915_hw_ppgtt *ppgtt;
 
+   /* Unique identifier for this context, used by the hw for tracking */
+   unsigned hw_id;
+
/* Legacy ring buffer submission */
struct {
struct drm_i915_gem_object *rcs_state;
@@ -1838,6 +1841,13 @@ struct drm_i915_private {
DECLARE_HASHTABLE(mm_structs, 7);
struct mutex mm_lock;
 
+   /* The hw wants to have a stable context identifier for the lifetime
+* of the context (for OA, PASID, faults, etc). This is limited
+* in execlists to 21 bits.
+*/
+   struct ida context_hw_ida;
+#define MAX_CONTEXT_HW_ID (1<<21) /* exclusive */
+
/* Kernel Modesetting */
 
struct drm_crtc *plane_to_crtc_mapping[I915_MAX_PIPES];
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c 
b/drivers/gpu/drm/i915/i915_gem_context.c
index 4071a0ec134a..9477af0fcb33 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -171,6 +171,8 @@ void i915_gem_context_free(struct kref *ctx_ref)
if (ctx->legacy_hw_ctx.rcs_state)
drm_gem_object_unreference(&ctx->legacy_hw_ctx.rcs_state->base);
list_del(&ctx->link);
+
+   ida_simple_remove(&ctx->i915->context_hw_ida, ctx->hw_id);
kfree(ctx);
 }
 
@@ -211,6 +213,28 @@ i915_gem_alloc_context_obj(struct drm_device *dev, size_t 
size)
return obj;
 }
 
+static int assign_hw_id(struct drm_i915_private *dev_priv, unsigned *out)
+{
+   int ret;
+
+   ret = ida_simple_get(&dev_priv->context_hw_ida,
+0, MAX_CONTEXT_HW_ID, GFP_KERNEL);
+   if (ret < 0) {
+   /* Contexts are only released when no longer active.
+* Flush any pending retires to hopefully release some
+* stale contexts and try again.
+*/
+   i915_gem_retire_requests(dev_priv->dev);
+   ret = ida_simple_get(&dev_priv->context_hw_ida,
+0, MAX_CONTEXT_HW_ID, GFP_KERNEL);
+   if (ret < 0)
+   return ret;
+   }
+
+   *out = ret;
+   return 0;
+}
+
 static struct intel_context *
 __create_hw_context(struct drm_device *dev,
struct drm_i915_file_private *file_priv)
@@ -223,6 +247,12 @@ __create_hw_context(struct drm_device *dev,
if (ctx == NULL)
return ERR_PTR(-ENOMEM);
 
+   ret = assign_hw_id(dev_priv, &ctx->hw_id);
+   if (ret) {
+   kfree(ctx);
+   return ERR_PTR(ret);
+   }
+
kref_init(&ctx->ref);
list_add_tail(&ctx->link, &dev_priv->context_list);
ctx->i915 = dev_priv;
@@ -366,6 +396,10 @@ int i915_gem_context_init(struct drm_device *dev)
}
}
 
+   /* Using the simple ida interface, the max is limited by sizeof(int) */
+   BUILD_BUG_ON(MAX_CONTEXT_HW_ID > INT_MAX);
+   ida_init(&dev_priv->context_hw_ida);
+
if (i915.enable_execlists) {
/* NB: intentionally left blank. We will allocate our own
 * backing objects as we need them, thank you very much */
@@ -429,6 +463,8 @@ void i915_gem_context_fini(struct drm_device *dev)
 
i915_gem_context_unreference(dctx);
dev_priv->kernel_context = NULL;
+
+   ida_destroy(&dev_priv->context_hw_ida);
 }
 
 static in

[Intel-gfx] [PATCH v6 06/25] drm/i915: Use i915_vma_pin_iomap on the ringbuffer object

2016-04-26 Thread Chris Wilson
Similarly to i915_gem_object_pin_map on LLC platforms, we can
use the new VMA based io mapping on !LLC to amoritize the cost
of ringbuffer pinning and unpinning.

Signed-off-by: Tvrtko Ursulin 
Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Reviewed-by: Joonas Lahtinen 
---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c 
b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 66f69cdd1d36..61c120aed11e 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2088,20 +2088,23 @@ static int init_phys_status_page(struct intel_engine_cs 
*engine)
 
 void intel_unpin_ringbuffer_obj(struct intel_ringbuffer *ringbuf)
 {
+   GEM_BUG_ON(ringbuf->vma == NULL);
+   GEM_BUG_ON(ringbuf->virtual_start == NULL);
+
if (HAS_LLC(ringbuf->obj->base.dev) && !ringbuf->obj->stolen)
i915_gem_object_unpin_map(ringbuf->obj);
else
-   iounmap(ringbuf->virtual_start);
+   i915_vma_unpin_iomap(ringbuf->vma);
ringbuf->virtual_start = NULL;
-   ringbuf->vma = NULL;
+
i915_gem_object_ggtt_unpin(ringbuf->obj);
+   ringbuf->vma = NULL;
 }
 
 int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev,
 struct intel_ringbuffer *ringbuf)
 {
struct drm_i915_private *dev_priv = to_i915(dev);
-   struct i915_ggtt *ggtt = &dev_priv->ggtt;
struct drm_i915_gem_object *obj = ringbuf->obj;
/* Ring wraparound at offset 0 sometimes hangs. No idea why. */
unsigned flags = PIN_OFFSET_BIAS | 4096;
@@ -2135,10 +2138,9 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device 
*dev,
/* Access through the GTT requires the device to be awake. */
assert_rpm_wakelock_held(dev_priv);
 
-   addr = ioremap_wc(ggtt->mappable_base +
- i915_gem_obj_ggtt_offset(obj), ringbuf->size);
-   if (addr == NULL) {
-   ret = -ENOMEM;
+   addr = i915_vma_pin_iomap(i915_gem_obj_to_ggtt(obj));
+   if (IS_ERR(addr)) {
+   ret = PTR_ERR(addr);
goto err_unpin;
}
}
-- 
2.8.1

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


[Intel-gfx] [PATCH v6 11/25] drm/i915: Rearrange switch_context to load the aliasing ppgtt on first use

2016-04-26 Thread Chris Wilson
The code to switch_mm() is already handled by i915_switch_context(), the
only difference required to setup the aliasing ppgtt is that we need to
emit te switch_mm() on the first context, i.e. when transitioning from
engine->last_context == NULL. This allows us to defer the
initialisation of the GPU from early device initialisation to first use,
which should marginally speed up both. The caveat is that we then defer
the context initialisation until first use - i.e. we cannot assume that
the GPU engines are initialised. For example, this means that power
contexts for rc6 (Ironlake) need to explicitly loaded, as they are.

Signed-off-by: Chris Wilson 
Cc: Mika Kuoppala 
Reviewed-by: Joonas Lahtinen 
---
 drivers/gpu/drm/i915/i915_drv.h |  1 -
 drivers/gpu/drm/i915/i915_gem.c | 30 -
 drivers/gpu/drm/i915/i915_gem_context.c | 77 +
 drivers/gpu/drm/i915/i915_gem_gtt.c | 14 --
 drivers/gpu/drm/i915/i915_gem_gtt.h |  1 -
 5 files changed, 31 insertions(+), 92 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a4032393eddf..444a8ea0c5c4 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3296,7 +3296,6 @@ void i915_gem_context_lost(struct drm_i915_private 
*dev_priv);
 void i915_gem_context_fini(struct drm_device *dev);
 void i915_gem_context_reset(struct drm_device *dev);
 int i915_gem_context_open(struct drm_device *dev, struct drm_file *file);
-int i915_gem_context_enable(struct drm_i915_gem_request *req);
 void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
 int i915_switch_context(struct drm_i915_gem_request *req);
 struct intel_context *
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index c5dd4008e775..71135c3ce44e 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4903,36 +4903,6 @@ i915_gem_init_hw(struct drm_device *dev)
 * on re-initialisation
 */
ret = i915_gem_set_seqno(dev, dev_priv->next_seqno+0x100);
-   if (ret)
-   goto out;
-
-   /* Now it is safe to go back round and do everything else: */
-   for_each_engine(engine, dev_priv) {
-   struct drm_i915_gem_request *req;
-
-   req = i915_gem_request_alloc(engine, NULL);
-   if (IS_ERR(req)) {
-   ret = PTR_ERR(req);
-   break;
-   }
-
-   ret = i915_ppgtt_init_ring(req);
-   if (ret)
-   goto err_request;
-
-   ret = i915_gem_context_enable(req);
-   if (ret)
-   goto err_request;
-
-err_request:
-   i915_add_request_no_flush(req);
-   if (ret) {
-   DRM_ERROR("Failed to enable %s, error=%d\n",
- engine->name, ret);
-   i915_gem_cleanup_engines(dev);
-   break;
-   }
-   }
 
 out:
intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c 
b/drivers/gpu/drm/i915/i915_gem_context.c
index 7556cb7c329d..4071a0ec134a 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -431,27 +431,6 @@ void i915_gem_context_fini(struct drm_device *dev)
dev_priv->kernel_context = NULL;
 }
 
-int i915_gem_context_enable(struct drm_i915_gem_request *req)
-{
-   struct intel_engine_cs *engine = req->engine;
-   int ret;
-
-   if (i915.enable_execlists) {
-   if (engine->init_context == NULL)
-   return 0;
-
-   ret = engine->init_context(req);
-   } else
-   ret = i915_switch_context(req);
-
-   if (ret) {
-   DRM_ERROR("ring init context: %d\n", ret);
-   return ret;
-   }
-
-   return 0;
-}
-
 static int context_idr_cleanup(int id, void *p, void *data)
 {
struct intel_context *ctx = p;
@@ -630,7 +609,8 @@ static int remap_l3(struct drm_i915_gem_request *req, int 
slice)
return 0;
 }
 
-static inline bool skip_rcs_switch(struct intel_engine_cs *engine,
+static inline bool skip_rcs_switch(struct i915_hw_ppgtt *ppgtt,
+  struct intel_engine_cs *engine,
   struct intel_context *to)
 {
if (to->remap_slice)
@@ -639,21 +619,27 @@ static inline bool skip_rcs_switch(struct intel_engine_cs 
*engine,
if (!to->legacy_hw_ctx.initialized)
return false;
 
-   if (to->ppgtt &&
-   !(intel_engine_flag(engine) & to->ppgtt->pd_dirty_rings))
+   if (ppgtt && (intel_engine_flag(engine) & ppgtt->pd_dirty_rings))
return false;
 
return to == engine->last_context;
 }
 
 static bool
-needs_pd_load_pre(struct intel_engine_cs *engine, struct 

[Intel-gfx] [PATCH v6 07/25] drm/i915: Mark the current context as lost on suspend

2016-04-26 Thread Chris Wilson
In order to force a reload of the context image upon resume, we first
need to mark its absence on suspend. Currently we are failing to restore
the golden context state and any context w/a to the default context
after resume.

One oversight corrected, is that we had forgotten to reapply the L3
remapping when restoring the lost default context.

v2: Remove deprecated WARN.

Signed-off-by: Chris Wilson 
Cc: Mika Kuoppala 
Reviewed-by: Mika Kuoppala 
---
 drivers/gpu/drm/i915/i915_drv.h |  1 +
 drivers/gpu/drm/i915/i915_gem.c |  1 +
 drivers/gpu/drm/i915/i915_gem_context.c | 54 ++---
 3 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 32f05979ade7..c3fbc056d6aa 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3293,6 +3293,7 @@ void i915_gem_object_save_bit_17_swizzle(struct 
drm_i915_gem_object *obj);
 
 /* i915_gem_context.c */
 int __must_check i915_gem_context_init(struct drm_device *dev);
+void i915_gem_context_lost(struct drm_i915_private *dev_priv);
 void i915_gem_context_fini(struct drm_device *dev);
 void i915_gem_context_reset(struct drm_device *dev);
 int i915_gem_context_open(struct drm_device *dev, struct drm_file *file);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 40f6504de7c1..f9ef11273698 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4711,6 +4711,7 @@ i915_gem_suspend(struct drm_device *dev)
i915_gem_retire_requests(dev);
 
i915_gem_stop_engines(dev);
+   i915_gem_context_lost(dev_priv);
mutex_unlock(&dev->struct_mutex);
 
cancel_delayed_work_sync(&dev_priv->gpu_error.hangcheck_work);
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c 
b/drivers/gpu/drm/i915/i915_gem_context.c
index 4e12bae5c659..05752a2f1810 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -90,6 +90,8 @@
 #include "i915_drv.h"
 #include "i915_trace.h"
 
+#define ALL_L3_SLICES(dev) (1 << NUM_L3_SLICES(dev)) - 1
+
 /* This is a HW constraint. The value below is the largest known requirement
  * I've seen in a spec to date, and that was a workaround for a non-shipping
  * part. It should be safe to decrease this, but it's more future proof as is.
@@ -249,7 +251,7 @@ __create_hw_context(struct drm_device *dev,
/* NB: Mark all slices as needing a remap so that when the context first
 * loads it will restore whatever remap state already exists. If there
 * is no remap info, it will be a NOP. */
-   ctx->remap_slice = (1 << NUM_L3_SLICES(dev)) - 1;
+   ctx->remap_slice = ALL_L3_SLICES(dev_priv);
 
ctx->hang_stats.ban_period_seconds = DRM_I915_CTX_BAN_PERIOD;
 
@@ -336,7 +338,6 @@ static void i915_gem_context_unpin(struct intel_context 
*ctx,
 void i915_gem_context_reset(struct drm_device *dev)
 {
struct drm_i915_private *dev_priv = dev->dev_private;
-   int i;
 
if (i915.enable_execlists) {
struct intel_context *ctx;
@@ -345,17 +346,7 @@ void i915_gem_context_reset(struct drm_device *dev)
intel_lr_context_reset(dev_priv, ctx);
}
 
-   for (i = 0; i < I915_NUM_ENGINES; i++) {
-   struct intel_engine_cs *engine = &dev_priv->engine[i];
-
-   if (engine->last_context) {
-   i915_gem_context_unpin(engine->last_context, engine);
-   engine->last_context = NULL;
-   }
-   }
-
-   /* Force the GPU state to be reinitialised on enabling */
-   dev_priv->kernel_context->legacy_hw_ctx.initialized = false;
+   i915_gem_context_lost(dev_priv);
 }
 
 int i915_gem_context_init(struct drm_device *dev)
@@ -403,11 +394,29 @@ int i915_gem_context_init(struct drm_device *dev)
return 0;
 }
 
+void i915_gem_context_lost(struct drm_i915_private *dev_priv)
+{
+   struct intel_engine_cs *engine;
+
+   for_each_engine(engine, dev_priv) {
+   if (engine->last_context == NULL)
+   continue;
+
+   i915_gem_context_unpin(engine->last_context, engine);
+   engine->last_context = NULL;
+   }
+
+   /* Force the GPU state to be reinitialised on enabling */
+   dev_priv->kernel_context->legacy_hw_ctx.initialized = false;
+   dev_priv->kernel_context->remap_slice = ALL_L3_SLICES(dev_priv);
+}
+
 void i915_gem_context_fini(struct drm_device *dev)
 {
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_context *dctx = dev_priv->kernel_context;
-   int i;
+
+   i915_gem_context_lost(dev_priv);
 
if (dctx->legacy_hw_ctx.rcs_state) {
/* The only known way to stop the gpu from accessing the hw 
context is
@@ -415,26 +424,9 @@ void i915_gem_context_fini(struct drm_device *dev)
 * 

[Intel-gfx] [PATCH i-g-t v3 1/6] kms_panel_fitting: Remove un-read variable.

2016-04-26 Thread robert . foss
From: Robert Foss 

Remove devid from data_t since it is never read.
Also remove one assignment to devid.

Signed-off-by: Robert Foss 
Reviewed-by: Tomeu Vizoso 
---
 tests/kms_panel_fitting.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tests/kms_panel_fitting.c b/tests/kms_panel_fitting.c
index 1f9412f..43ad770 100644
--- a/tests/kms_panel_fitting.c
+++ b/tests/kms_panel_fitting.c
@@ -29,7 +29,6 @@
 IGT_TEST_DESCRIPTION("Test display panel fitting");
 
 typedef struct {
-   uint32_t devid;
int drm_fd;
igt_display_t display;
igt_crc_t ref_crc;
@@ -225,7 +224,6 @@ igt_simple_main
data.drm_fd = drm_open_driver(DRIVER_INTEL);
igt_require_pipe_crc();
igt_display_init(&data.display, data.drm_fd);
-   data.devid = intel_get_drm_devid(data.drm_fd);
 
test_panel_fitting(&data);
 
-- 
2.5.0

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


[Intel-gfx] [PATCH i-g-t v3 4/6] kms_panel_fitting: Switched DRM format to a hardware agnostic alternative.

2016-04-26 Thread robert . foss
From: Robert Foss 

Changed the DRM format to LOCAL_DRM_FORMAT_MOD_NONE since it
is hardware agnostic.

Also fixed formatting/tabs.

Signed-off-by: Robert Foss 
Reviewed-by: Tomeu Vizoso 
---
 tests/kms_panel_fitting.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/kms_panel_fitting.c b/tests/kms_panel_fitting.c
index 099816b..427bfc6 100644
--- a/tests/kms_panel_fitting.c
+++ b/tests/kms_panel_fitting.c
@@ -65,10 +65,10 @@ static void prepare_crtc(data_t *data, igt_output_t 
*output, enum pipe pipe,
 
/* allocate fb for plane 1 */
data->fb_id1 = igt_create_pattern_fb(data->drm_fd,
-mode->hdisplay, mode->vdisplay,
-DRM_FORMAT_XRGB,
-LOCAL_I915_FORMAT_MOD_X_TILED, /* 
tiled */
-&data->fb1);
+   mode->hdisplay, mode->vdisplay,
+   DRM_FORMAT_XRGB,
+   LOCAL_DRM_FORMAT_MOD_NONE,
+   &data->fb1);
igt_assert(data->fb_id1);
 
/*
@@ -159,7 +159,7 @@ static void test_panel_fitting(data_t *d)
 
d->fb_id2 = igt_create_image_fb(d->drm_fd, 0, 0,
DRM_FORMAT_XRGB,
-   LOCAL_I915_FORMAT_MOD_X_TILED, 
/* tiled */
+   LOCAL_DRM_FORMAT_MOD_NONE,
FILE_NAME, &d->fb2);
igt_assert(d->fb_id2);
 
-- 
2.5.0

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


Re: [Intel-gfx] [PATCH 09/35] drm/gem: support BO freeing without dev->struct_mutex

2016-04-26 Thread Daniel Vetter
On Tue, Apr 26, 2016 at 08:47:32PM +0100, Chris Wilson wrote:
> On Tue, Apr 26, 2016 at 07:29:42PM +0200, Daniel Vetter wrote:
> > Finally all the core gem and a lot of drivers are entirely free of
> > dev->struct_mutex depencies, and we can start to have an entirely
> > lockless unref path.
> > 
> > To make sure that no one who touches the core code accidentally breaks
> > existing drivers which still require dev->struct_mutex I've made the
> > might_lock check unconditional.
> > 
> > While at it de-inline the ref/unref functions, they've become a bit
> > too big.
> > 
> > v2: Make it not leak like a sieve.
> > 
> > Signed-off-by: Daniel Vetter 
> > ---
> >  drivers/gpu/drm/drm_gem.c | 64 
> > ++-
> >  include/drm/drmP.h| 12 -
> >  include/drm/drm_gem.h | 45 ++---
> >  3 files changed, 65 insertions(+), 56 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> > index 25dac31eef37..8f2eff448bb5 100644
> > --- a/drivers/gpu/drm/drm_gem.c
> > +++ b/drivers/gpu/drm/drm_gem.c
> > @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj)
> >  }
> >  EXPORT_SYMBOL(drm_gem_object_release);
> >  
> > -/**
> > - * drm_gem_object_free - free a GEM object
> > - * @kref: kref of the object to free
> > - *
> > - * Called after the last reference to the object has been lost.
> > - * Must be called holding struct_ mutex
> > - *
> > - * Frees the object
> > - */
> > -void
> > +static void
> >  drm_gem_object_free(struct kref *kref)
> >  {
> > struct drm_gem_object *obj =
> > @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
> >  
> > WARN_ON(!mutex_is_locked(&dev->struct_mutex));
> >  
> > -   if (dev->driver->gem_free_object != NULL)
> > +   if (dev->driver->gem_free_object_unlocked != NULL)
> > +   dev->driver->gem_free_object_unlocked(obj);
> > +   else if (dev->driver->gem_free_object != NULL)
> > dev->driver->gem_free_object(obj);
> >  }
> > -EXPORT_SYMBOL(drm_gem_object_free);
> > +
> > +/**
> > + * drm_gem_object_unreference_unlocked - release a GEM BO reference
> > + * @obj: GEM buffer object
> > + *
> > + * This releases a reference to @obj. Callers must not hold the
> > + * dev->struct_mutex lock when calling this function.
> > + */
> > +void
> > +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
> > +{
> 
> I have i915.ko in a state where we could use this as well. I would like
> to have our inlines back though. I would add
> 
> static inline void
> i915_gem_object_put(struct drm_i915_gem_object *obj)
> {
>   kref_put(&obj->base.refcount, drm_gem_object_free);
> }
> 
> Hmm, considering how simple that is, maybe I won't ask for
> 
> static inline void
> __drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
> {
>   BUG_ON(obj->dev->driver->gem_free_object == NULL);
>   kref_put(&obj->refcount, drm_gem_object_free);
> }

Yeah, something like that makes sense. Imo the core versions really need
all the silly locking checks and all that to make sure no one abuses them
by accident, or breaks a driver still using struct_mutex. Adding a
fastpath for drivers using gem_free_object_unlocked just wrapping the
kref_put certainly looks like a good idea.

And if we document the exact use case I think we could even nuke the
BUG_ON too. This can be audited with a simple

$ git grep __drm_gem_object_unreference_unlocked -- drivers/gpu/drm/$driver

so imo nothing too dangerous.

Ack/r-b on the patch itself?
-Daniel
-- 
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] [PATCH i-g-t v3 6/6] kms_panel_fitting: Enable connectors with "scaling mode" property set.

2016-04-26 Thread robert . foss
From: Robert Foss 

Enable testing on all connectors that have the "scaling mode"
property set.

Signed-off-by: Robert Foss 
---
 tests/kms_panel_fitting.c | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/tests/kms_panel_fitting.c b/tests/kms_panel_fitting.c
index 272a531..de27803 100644
--- a/tests/kms_panel_fitting.c
+++ b/tests/kms_panel_fitting.c
@@ -139,9 +139,21 @@ static void test_panel_fitting(data_t *d)
 
for_each_connected_output(display, output) {
drmModeModeInfo *mode, native_mode;
-
-   if (output->config.connector->connector_type !=
-   DRM_MODE_CONNECTOR_eDP)
+   uint32_t prop_id;
+   uint64_t prop_value;
+   drmModePropertyPtr prop_ptr;
+   bool scaling_mode_set;
+
+   scaling_mode_set = kmstest_get_property(d->drm_fd,
+   output->config.connector->connector_id,
+   DRM_MODE_OBJECT_CONNECTOR,
+   "scaling mode",
+   &prop_id,
+   &prop_value,
+   &prop_ptr);
+
+   /* Check that the "scaling mode" property has been set. */
+   if (!scaling_mode_set)
continue;
 
pipe = output->config.pipe;
-- 
2.5.0

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


[Intel-gfx] [PATCH i-g-t v3 5/6] kms_panel_fitting: Enabled test on non-Intel hardware.

2016-04-26 Thread robert . foss
From: Robert Foss 

Switched from DRIVER_INTEL to DRIVER_ANY to enable test
on all hardware.

Signed-off-by: Robert Foss 
Reviewed-by: Tomeu Vizoso 
---
 tests/kms_panel_fitting.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/kms_panel_fitting.c b/tests/kms_panel_fitting.c
index 427bfc6..272a531 100644
--- a/tests/kms_panel_fitting.c
+++ b/tests/kms_panel_fitting.c
@@ -212,7 +212,7 @@ igt_simple_main
 
igt_skip_on_simulation();
 
-   data.drm_fd = drm_open_driver(DRIVER_INTEL);
+   data.drm_fd = drm_open_driver(DRIVER_ANY);
igt_display_init(&data.display, data.drm_fd);
 
test_panel_fitting(&data);
-- 
2.5.0

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


[Intel-gfx] [PATCH i-g-t v3 0/6] Improve kms_panel_fitting.

2016-04-26 Thread robert . foss
From: Robert Foss 

Changes since v2:
- Added reviewed-by tomeu to patch 1-5.
- kms_panel_fitting.c: Replaced connector type checking with "scaling mode" 
property check.

Changes since v1:
- Squash patches
- Based patch on 
https://lists.freedesktop.org/archives/intel-gfx/2016-March/090617.html

Robert Foss (6):
  kms_panel_fitting: Remove un-read variable.
  kms_panel_fitting: Remove un-read variable pipe_crc.
  kms_panel_fitting: Remove un-used variable.
  kms_panel_fitting: Switched DRM format to a hardware agnostic
alternative.
  kms_panel_fitting: Enabled test on non-Intel hardware.
  kms_panel_fitting: Enable connectors with "scaling mode" property set.

 tests/kms_panel_fitting.c | 42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

-- 
2.5.0

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


[Intel-gfx] [PATCH i-g-t v3 2/6] kms_panel_fitting: Remove un-read variable pipe_crc.

2016-04-26 Thread robert . foss
From: Robert Foss 

pipe_crc in data_t is assigned an allocated memory space and
then later free'd. But it is never used for any comparisons.
It should therefore be safe to remove pipe_crc and the crc
requirement.

Signed-off-by: Robert Foss 
Reviewed-by: Tomeu Vizoso 
---
 tests/kms_panel_fitting.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/tests/kms_panel_fitting.c b/tests/kms_panel_fitting.c
index 43ad770..7bfd980 100644
--- a/tests/kms_panel_fitting.c
+++ b/tests/kms_panel_fitting.c
@@ -32,7 +32,6 @@ typedef struct {
int drm_fd;
igt_display_t display;
igt_crc_t ref_crc;
-   igt_pipe_crc_t *pipe_crc;
 
int image_w;
int image_h;
@@ -59,10 +58,6 @@ static void prepare_crtc(data_t *data, igt_output_t *output, 
enum pipe pipe,
 
igt_output_set_pipe(output, pipe);
 
-   /* create the pipe_crc object for this pipe */
-   igt_pipe_crc_free(data->pipe_crc);
-   data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
-
/* before allocating, free if any older fb */
if (data->fb_id1) {
igt_remove_fb(data->drm_fd, &data->fb1);
@@ -109,9 +104,6 @@ static void cleanup_crtc(data_t *data, igt_output_t 
*output, igt_plane_t *plane)
 {
igt_display_t *display = &data->display;
 
-   igt_pipe_crc_free(data->pipe_crc);
-   data->pipe_crc = NULL;
-
if (data->fb_id1) {
igt_remove_fb(data->drm_fd, &data->fb1);
data->fb_id1 = 0;
@@ -222,7 +214,6 @@ igt_simple_main
igt_skip_on_simulation();
 
data.drm_fd = drm_open_driver(DRIVER_INTEL);
-   igt_require_pipe_crc();
igt_display_init(&data.display, data.drm_fd);
 
test_panel_fitting(&data);
-- 
2.5.0

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


[Intel-gfx] [PATCH v6 24/25] drm/i915: Stop tracking execlists retired requests

2016-04-26 Thread Chris Wilson
From: Tvrtko Ursulin 

With the previous patch having extended the pinned lifetime of
contexts by referencing the previous context from the current
request until the latter is retired (completed by the GPU),
we can now remove usage of execlist retired queue entirely.

This is because the above now guarantees that all execlist
object access requirements are satisfied by this new tracking,
and we can stop taking additional references and stop keeping
request on the execlists retired queue.

The latter was a source of significant scalability issues in
the driver causing performance hits on some tests. Most
dramatical of which was igt/gem_close_race which had run time
in tens of minutes which is now reduced to tens of seconds.

Signed-off-by: Tvrtko Ursulin 
Cc: Chris Wilson 
Reviewed-by: Chris Wilson 
Signed-off-by: Chris Wilson 
---
 drivers/gpu/drm/i915/i915_gem.c | 10 +
 drivers/gpu/drm/i915/intel_lrc.c| 39 -
 drivers/gpu/drm/i915/intel_lrc.h|  2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.h |  1 -
 4 files changed, 16 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index fc68af50ed1b..1174966b3b38 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2871,13 +2871,7 @@ static void i915_gem_reset_engine_cleanup(struct 
drm_i915_private *dev_priv,
/* Ensure irq handler finishes or is cancelled. */
tasklet_kill(&engine->irq_tasklet);
 
-   spin_lock_bh(&engine->execlist_lock);
-   /* list_splice_tail_init checks for empty lists */
-   list_splice_tail_init(&engine->execlist_queue,
- &engine->execlist_retired_req_list);
-   spin_unlock_bh(&engine->execlist_lock);
-
-   intel_execlists_retire_requests(engine);
+   intel_execlists_cancel_requests(engine);
}
 
/*
@@ -3001,8 +2995,6 @@ i915_gem_retire_requests(struct drm_device *dev)
spin_lock_bh(&engine->execlist_lock);
idle &= list_empty(&engine->execlist_queue);
spin_unlock_bh(&engine->execlist_lock);
-
-   intel_execlists_retire_requests(engine);
}
}
 
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 1035ca0e1d8d..bc3257675296 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -435,8 +435,8 @@ static void execlists_context_unqueue(struct 
intel_engine_cs *engine)
/* Same ctx: ignore first request, as second request
 * will update tail past first request's workload */
cursor->elsp_submitted = req0->elsp_submitted;
-   list_move_tail(&req0->execlist_link,
-  &engine->execlist_retired_req_list);
+   list_del(&req0->execlist_link);
+   i915_gem_request_unreference(req0);
req0 = cursor;
} else {
req1 = cursor;
@@ -468,7 +468,7 @@ static void execlists_context_unqueue(struct 
intel_engine_cs *engine)
 }
 
 static unsigned int
-execlists_check_remove_request(struct intel_engine_cs *engine, u32 request_id)
+execlists_check_remove_request(struct intel_engine_cs *engine, u32 ctx_id)
 {
struct drm_i915_gem_request *head_req;
 
@@ -478,19 +478,16 @@ execlists_check_remove_request(struct intel_engine_cs 
*engine, u32 request_id)
struct drm_i915_gem_request,
execlist_link);
 
-   if (!head_req)
-   return 0;
-
-   if (unlikely(head_req->ctx_hw_id != request_id))
-   return 0;
+   if (WARN_ON(!head_req || (head_req->ctx_hw_id != ctx_id)))
+   return 0;
 
WARN(head_req->elsp_submitted == 0, "Never submitted head request\n");
 
if (--head_req->elsp_submitted > 0)
return 0;
 
-   list_move_tail(&head_req->execlist_link,
-  &engine->execlist_retired_req_list);
+   list_del(&head_req->execlist_link);
+   i915_gem_request_unreference(head_req);
 
return 1;
 }
@@ -594,9 +591,6 @@ static void execlists_context_queue(struct 
drm_i915_gem_request *request)
struct drm_i915_gem_request *cursor;
int num_elements = 0;
 
-   intel_lr_context_pin(request->ctx, request->engine);
-   i915_gem_request_reference(request);
-
spin_lock_bh(&engine->execlist_lock);
 
list_for_each_entry(cursor, &engine->execlist_queue, execlist_link)
@@ -613,11 +607,12 @@ static void execlists_context_queue(struct 
drm_i915_gem_request *request)
if (request->ctx == tail_req->ctx) {
WARN(tail_req->elsp

[Intel-gfx] [PATCH v6 23/25] drm/i915: Store LRC hardware id in the request

2016-04-26 Thread Chris Wilson
From: Tvrtko Ursulin 

This way in the following patch we can disconnect requests
from contexts.

Signed-off-by: Tvrtko Ursulin 
Reviewed-by: Chris Wilson 
Signed-off-by: Chris Wilson 
---
 drivers/gpu/drm/i915/i915_drv.h  | 2 ++
 drivers/gpu/drm/i915/intel_lrc.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index eb4a95b853dd..e2abbcc27f2c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2352,6 +2352,8 @@ struct drm_i915_gem_request {
/** Execlists no. of times this request has been sent to the ELSP */
int elsp_submitted;
 
+   /** Execlists context hardware id. */
+   unsigned ctx_hw_id;
 };
 
 struct drm_i915_gem_request * __must_check
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 0682a79be02c..1035ca0e1d8d 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -481,7 +481,7 @@ execlists_check_remove_request(struct intel_engine_cs 
*engine, u32 request_id)
if (!head_req)
return 0;
 
-   if (unlikely(head_req->ctx->hw_id != request_id))
+   if (unlikely(head_req->ctx_hw_id != request_id))
return 0;
 
WARN(head_req->elsp_submitted == 0, "Never submitted head request\n");
@@ -619,6 +619,7 @@ static void execlists_context_queue(struct 
drm_i915_gem_request *request)
}
 
list_add_tail(&request->execlist_link, &engine->execlist_queue);
+   request->ctx_hw_id = request->ctx->hw_id;
if (num_elements == 0)
execlists_context_unqueue(engine);
 
-- 
2.8.1

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


[Intel-gfx] [PATCH v6 25/25] drm/i915: Unify GPU resets upon shutdown

2016-04-26 Thread Chris Wilson
Both execlists and legacy need to reset the context (and mode) of the
GPU before we lose control of the system. By resetting the GPU, we
revert back to default settings. This simplifies the life of any
subsequent driver (in particular for virtualized setups) as it does not
then have to try and recover from an unknown condition. As both paths
need to reset for the same reason, move the reset to a common point.

This unifies the resets added in a647828afc (drm/i915: Also perform gpu
reset under execlist mode) and 8e96d9c4d9 (drm/i915: reset the GPU on
context fini).

v2: Restrict the reset to "modern" gen (where we enable HW contexts) to
try and avoid leaving the machine in an unusable state with a risky
reset on older GPU. This should keep the status quo as to who performs
resets (i.e. currently only GPUs with HW contexts perform a reset on
shutdown).

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
CC: Joonas Lahtinen 
Cc: Mika Kuoppala 
Cc: "Niu, Bing" 
Reviewed-by: Mika Kuoppala 
---
 drivers/gpu/drm/i915/i915_dma.c | 45 +++--
 drivers/gpu/drm/i915/i915_gem.c |  8 --
 drivers/gpu/drm/i915/i915_gem_context.c | 10 +---
 3 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 5c7615041b31..d70f028afadb 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -425,6 +425,41 @@ static const struct vga_switcheroo_client_ops 
i915_switcheroo_ops = {
.can_switch = i915_switcheroo_can_switch,
 };
 
+static void i915_gem_fini(struct drm_device *dev)
+{
+   /*
+* Neither the BIOS, ourselves or any other kernel
+* expects the system to be in execlists mode on startup,
+* so we need to reset the GPU back to legacy mode. And the only
+* known way to disable logical contexts is through a GPU reset.
+*
+* So in order to leave the system in a known default configuration,
+* always reset the GPU upon unload. Afterwards we then clean up the
+* GEM state tracking, flushing off the requests and leaving the
+* system in a known idle state.
+*
+* Note that is of the upmost importance that the GPU is idle and
+* all stray writes are flushed *before* we dismantle the backing
+* storage for the pinned objects.
+*
+* However, since we are uncertain that reseting the GPU on older
+* machines is a good idea, we don't - just in case it leaves the
+* machine in an unusable condition.
+*/
+   if (HAS_HW_CONTEXTS(dev)) {
+   int reset = intel_gpu_reset(dev, ALL_ENGINES);
+   WARN_ON(reset && reset != -ENODEV);
+   }
+
+   mutex_lock(&dev->struct_mutex);
+   i915_gem_reset(dev);
+   i915_gem_cleanup_engines(dev);
+   i915_gem_context_fini(dev);
+   mutex_unlock(&dev->struct_mutex);
+
+   WARN_ON(!list_empty(&to_i915(dev)->context_list));
+}
+
 static int i915_load_modeset_init(struct drm_device *dev)
 {
struct drm_i915_private *dev_priv = dev->dev_private;
@@ -506,10 +541,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
return 0;
 
 cleanup_gem:
-   mutex_lock(&dev->struct_mutex);
-   i915_gem_cleanup_engines(dev);
-   i915_gem_context_fini(dev);
-   mutex_unlock(&dev->struct_mutex);
+   i915_gem_fini(dev);
 cleanup_irq:
intel_guc_ucode_fini(dev);
drm_irq_uninstall(dev);
@@ -1456,10 +1488,7 @@ int i915_driver_unload(struct drm_device *dev)
flush_workqueue(dev_priv->wq);
 
intel_guc_ucode_fini(dev);
-   mutex_lock(&dev->struct_mutex);
-   i915_gem_cleanup_engines(dev);
-   i915_gem_context_fini(dev);
-   mutex_unlock(&dev->struct_mutex);
+   i915_gem_fini(dev);
intel_fbc_cleanup_cfb(dev_priv);
 
intel_power_domains_fini(dev_priv);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 1174966b3b38..fb5c46dd0219 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4961,14 +4961,6 @@ i915_gem_cleanup_engines(struct drm_device *dev)
 
for_each_engine(engine, dev_priv)
dev_priv->gt.cleanup_engine(engine);
-
-   if (i915.enable_execlists)
-   /*
-* Neither the BIOS, ourselves or any other kernel
-* expects the system to be in execlists mode on startup,
-* so we need to reset the GPU back to legacy mode.
-*/
-   intel_gpu_reset(dev, ALL_ENGINES);
 }
 
 static void
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c 
b/drivers/gpu/drm/i915/i915_gem_context.c
index 9477af0fcb33..cd39aba09137 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -450,16 +450,8 @@ void i915_gem_context_fini(struct drm_device *dev)
struct drm_i915_pr

[Intel-gfx] [PATCH v6 19/25] drm/i915: Refactor execlists default context pinning

2016-04-26 Thread Chris Wilson
Refactor pinning and unpinning of contexts, such that the default
context for an engine is pinned during initialisation and unpinned
during teardown (pinning of the context handles the reference counting).
Thus we can eliminate the special case handling of the default context
that was required to mask that it was not being pinned normally.

v2: Rebalance context_queue after rebasing.
v3: Rebase to -nightly (not 40 patches in)
v4: Rebase onto request_alloc unwinding

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Reviewed-by: Tvrtko Ursulin 
Reviewed-by: Mika Kuoppala 
---
 drivers/gpu/drm/i915/i915_debugfs.c |   5 +-
 drivers/gpu/drm/i915/i915_drv.h |   1 +
 drivers/gpu/drm/i915/i915_gem.c |   2 +-
 drivers/gpu/drm/i915/intel_lrc.c| 150 +++-
 4 files changed, 65 insertions(+), 93 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index be2a4a0fae13..5bc9789e1f1e 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2095,9 +2095,8 @@ static int i915_dump_lrc(struct seq_file *m, void *unused)
return ret;
 
list_for_each_entry(ctx, &dev_priv->context_list, link)
-   if (ctx != dev_priv->kernel_context)
-   for_each_engine(engine, dev_priv)
-   i915_dump_lrc_obj(m, ctx, engine);
+   for_each_engine(engine, dev_priv)
+   i915_dump_lrc_obj(m, ctx, engine);
 
mutex_unlock(&dev->struct_mutex);
 
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 0f7575252c6e..ea7aea044603 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -868,6 +868,7 @@ struct intel_context {
struct i915_vma *lrc_vma;
u64 lrc_desc;
uint32_t *lrc_reg_state;
+   bool initialised;
} engine[I915_NUM_ENGINES];
 
struct list_head link;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index d7ff5e79182f..df9d43397492 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2719,7 +2719,7 @@ void i915_gem_request_free(struct kref *req_ref)
i915_gem_request_remove_from_client(req);
 
if (ctx) {
-   if (i915.enable_execlists && ctx != req->i915->kernel_context)
+   if (i915.enable_execlists)
intel_lr_context_unpin(ctx, req->engine);
 
i915_gem_context_unreference(ctx);
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index ccabb688e049..f74c77cf2b52 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -592,9 +592,7 @@ static void execlists_context_queue(struct 
drm_i915_gem_request *request)
struct drm_i915_gem_request *cursor;
int num_elements = 0;
 
-   if (request->ctx != request->i915->kernel_context)
-   intel_lr_context_pin(request->ctx, engine);
-
+   intel_lr_context_pin(request->ctx, request->engine);
i915_gem_request_reference(request);
 
spin_lock_bh(&engine->execlist_lock);
@@ -678,6 +676,7 @@ static int execlists_move_to_gpu(struct 
drm_i915_gem_request *req,
 
 int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request 
*request)
 {
+   struct intel_engine_cs *engine = request->engine;
int ret;
 
/* Flush enough space to reduce the likelihood of waiting after
@@ -686,7 +685,7 @@ int intel_logical_ring_alloc_request_extras(struct 
drm_i915_gem_request *request
 */
request->reserved_space += MIN_SPACE_FOR_ADD_REQUEST;
 
-   request->ringbuf = request->ctx->engine[request->engine->id].ringbuf;
+   request->ringbuf = request->ctx->engine[engine->id].ringbuf;
 
if (i915.enable_guc_submission) {
/*
@@ -701,22 +700,34 @@ int intel_logical_ring_alloc_request_extras(struct 
drm_i915_gem_request *request
return ret;
}
 
-   if (request->ctx != request->i915->kernel_context) {
-   ret = intel_lr_context_pin(request->ctx, request->engine);
-   if (ret)
-   return ret;
-   }
+   ret = intel_lr_context_pin(request->ctx, engine);
+   if (ret)
+   return ret;
 
ret = intel_ring_begin(request, 0);
if (ret)
goto err_unpin;
 
+   if (!request->ctx->engine[engine->id].initialised) {
+   ret = engine->init_context(request);
+   if (ret)
+   goto err_unpin;
+
+   request->ctx->engine[engine->id].initialised = true;
+   }
+
+   /* Note that after this point, we have committed to using
+* this request as it is being used to both track the
+* state of engine initialisation and liveness of the
+* golden

[Intel-gfx] [PATCH v6 21/25] drm/i915: Move releasing of the GEM request from free to retire/cancel

2016-04-26 Thread Chris Wilson
If we move the release of the GEM request (i.e. decoupling it from the
various lists used for client and context tracking) after it is complete
(either by the GPU retiring the request, or by the caller cancelling the
request), we can remove the requirement that the final unreference of
the GEM request need to be under the struct_mutex.

The careful reader may notice that one or two impossible NULL pointer
tests are dropped for readability. These pointers cannot be NULL since
they are assigned during request construction and never unset.

v2,v3: Rebalance execlists by moving the context unpinning.
v4: Rebase onto -nightly
v5: Avoid trying to rebalance execlist/GuC context pinning, leave that
to the next step

Signed-off-by: Chris Wilson 
Reviewed-by: Tvrtko Ursulin 
Reviewed-by: Joonas Lahtinen 
---
 drivers/gpu/drm/i915/i915_drv.h  | 14 --
 drivers/gpu/drm/i915/i915_gem.c  | 23 +--
 drivers/gpu/drm/i915/intel_display.c |  2 +-
 drivers/gpu/drm/i915/intel_pm.c  |  2 +-
 4 files changed, 11 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ea7aea044603..0bd9d17ff974 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2373,23 +2373,9 @@ i915_gem_request_reference(struct drm_i915_gem_request 
*req)
 static inline void
 i915_gem_request_unreference(struct drm_i915_gem_request *req)
 {
-   WARN_ON(!mutex_is_locked(&req->engine->dev->struct_mutex));
kref_put(&req->ref, i915_gem_request_free);
 }
 
-static inline void
-i915_gem_request_unreference__unlocked(struct drm_i915_gem_request *req)
-{
-   struct drm_device *dev;
-
-   if (!req)
-   return;
-
-   dev = req->engine->dev;
-   if (kref_put_mutex(&req->ref, i915_gem_request_free, 
&dev->struct_mutex))
-   mutex_unlock(&dev->struct_mutex);
-}
-
 static inline void i915_gem_request_assign(struct drm_i915_gem_request **pdst,
   struct drm_i915_gem_request *src)
 {
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index df9d43397492..e4c8a8b998d1 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1413,6 +1413,13 @@ static void i915_gem_request_retire(struct 
drm_i915_gem_request *request)
list_del_init(&request->list);
i915_gem_request_remove_from_client(request);
 
+   if (request->ctx) {
+   if (i915.enable_execlists)
+   intel_lr_context_unpin(request->ctx, request->engine);
+
+   i915_gem_context_unreference(request->ctx);
+   }
+
i915_gem_request_unreference(request);
 }
 
@@ -2713,18 +2720,6 @@ void i915_gem_request_free(struct kref *req_ref)
 {
struct drm_i915_gem_request *req = container_of(req_ref,
 typeof(*req), ref);
-   struct intel_context *ctx = req->ctx;
-
-   if (req->file_priv)
-   i915_gem_request_remove_from_client(req);
-
-   if (ctx) {
-   if (i915.enable_execlists)
-   intel_lr_context_unpin(ctx, req->engine);
-
-   i915_gem_context_unreference(ctx);
-   }
-
kmem_cache_free(req->i915->requests, req);
 }
 
@@ -3173,7 +3168,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, 
struct drm_file *file)
ret = __i915_wait_request(req[i], true,
  args->timeout_ns > 0 ? 
&args->timeout_ns : NULL,
  to_rps_client(file));
-   i915_gem_request_unreference__unlocked(req[i]);
+   i915_gem_request_unreference(req[i]);
}
return ret;
 
@@ -4199,7 +4194,7 @@ i915_gem_ring_throttle(struct drm_device *dev, struct 
drm_file *file)
if (ret == 0)
queue_delayed_work(dev_priv->wq, &dev_priv->mm.retire_work, 0);
 
-   i915_gem_request_unreference__unlocked(target);
+   i915_gem_request_unreference(target);
 
return ret;
 }
diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 87ce7852482b..5692df5b71e5 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11399,7 +11399,7 @@ static void intel_mmio_flip_work_func(struct 
work_struct *work)
WARN_ON(__i915_wait_request(mmio_flip->req,
false, NULL,
&mmio_flip->i915->rps.mmioflips));
-   i915_gem_request_unreference__unlocked(mmio_flip->req);
+   i915_gem_request_unreference(mmio_flip->req);
}
 
/* For framebuffer backed by dmabuf, wait for fence */
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 695a464a5e64..2422ac38ce5d 100644
--- a/drivers/gpu/drm/i

[Intel-gfx] [PATCH v6 22/25] drm/i915: Track the previous pinned context inside the request

2016-04-26 Thread Chris Wilson
As the contexts are accessed by the hardware until the switch is completed
to a new context, the hardware may still be writing to the context object
after the breadcrumb is visible. We must not unpin/unbind/prune that
object whilst still active and so we keep the previous context pinned until
the following request. We can generalise the tracking we already do via
the engine->last_context and move it to the request so that it works
equally for execlists and GuC.

v2: Drop the execlists double pin as that exposes a race inside the lrc
irq handler as it tries to access the context after it may be retired.

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Reviewed-by: Joonas Lahtinen 
---
 drivers/gpu/drm/i915/i915_drv.h  | 11 +++
 drivers/gpu/drm/i915/i915_gem.c  |  8 
 drivers/gpu/drm/i915/intel_lrc.c | 14 --
 3 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 0bd9d17ff974..eb4a95b853dd 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2305,6 +2305,17 @@ struct drm_i915_gem_request {
struct intel_context *ctx;
struct intel_ringbuffer *ringbuf;
 
+   /**
+* Context related to the previous request.
+* As the contexts are accessed by the hardware until the switch is
+* completed to a new context, the hardware may still be writing
+* to the context object after the breadcrumb is visible. We must
+* not unpin/unbind/prune that object whilst still active and so
+* we keep the previous context pinned until the following (this)
+* request is retired.
+*/
+   struct intel_context *previous_context;
+
/** Batch buffer related to this request if any (used for
error state dump only) */
struct drm_i915_gem_object *batch_obj;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index e4c8a8b998d1..fc68af50ed1b 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1413,13 +1413,13 @@ static void i915_gem_request_retire(struct 
drm_i915_gem_request *request)
list_del_init(&request->list);
i915_gem_request_remove_from_client(request);
 
-   if (request->ctx) {
+   if (request->previous_context) {
if (i915.enable_execlists)
-   intel_lr_context_unpin(request->ctx, request->engine);
-
-   i915_gem_context_unreference(request->ctx);
+   intel_lr_context_unpin(request->previous_context,
+  request->engine);
}
 
+   i915_gem_context_unreference(request->ctx);
i915_gem_request_unreference(request);
 }
 
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 4be11f8d0e04..0682a79be02c 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -771,12 +771,14 @@ intel_logical_ring_advance_and_submit(struct 
drm_i915_gem_request *request)
if (intel_engine_stopped(engine))
return 0;
 
-   if (engine->last_context != request->ctx) {
-   if (engine->last_context)
-   intel_lr_context_unpin(engine->last_context, engine);
-   intel_lr_context_pin(request->ctx, engine);
-   engine->last_context = request->ctx;
-   }
+   /* We keep the previous context alive until we retire the following
+* request. This ensures that any the context object is still pinned
+* for any residual writes the HW makes into it on the context switch
+* into the next object following the breadcrumb. Otherwise, we may
+* retire the context too early.
+*/
+   request->previous_context = engine->last_context;
+   engine->last_context = request->ctx;
 
if (dev_priv->guc.execbuf_client)
i915_guc_submit(dev_priv->guc.execbuf_client, request);
-- 
2.8.1

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


[Intel-gfx] [PATCH v6 20/25] drm/i915: Move the magical deferred context allocation into the request

2016-04-26 Thread Chris Wilson
We can hide more details of execlists from higher level code by removing
the explicit call to create an execlist context from execbuffer and
into its first use by execlists.

Signed-off-by: Chris Wilson 
Reviewed-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  8 
 drivers/gpu/drm/i915/intel_lrc.c   | 19 +--
 drivers/gpu/drm/i915/intel_lrc.h   |  2 --
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c 
b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 6f4f2a6cdf93..e0ee5d1ac372 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1085,14 +1085,6 @@ i915_gem_validate_context(struct drm_device *dev, struct 
drm_file *file,
return ERR_PTR(-EIO);
}
 
-   if (i915.enable_execlists && !ctx->engine[engine->id].state) {
-   int ret = intel_lr_context_deferred_alloc(ctx, engine);
-   if (ret) {
-   DRM_DEBUG("Could not create LRC %u: %d\n", ctx_id, ret);
-   return ERR_PTR(ret);
-   }
-   }
-
return ctx;
 }
 
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index f74c77cf2b52..4be11f8d0e04 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -228,6 +228,8 @@ enum {
 #define GEN8_CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT   0x17
 #define GEN9_CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT   0x26
 
+static int execlists_context_deferred_alloc(struct intel_context *ctx,
+   struct intel_engine_cs *engine);
 static int intel_lr_context_pin(struct intel_context *ctx,
struct intel_engine_cs *engine);
 
@@ -685,6 +687,12 @@ int intel_logical_ring_alloc_request_extras(struct 
drm_i915_gem_request *request
 */
request->reserved_space += MIN_SPACE_FOR_ADD_REQUEST;
 
+   if (request->ctx->engine[engine->id].state == NULL) {
+   ret = execlists_context_deferred_alloc(request->ctx, engine);
+   if (ret)
+   return ret;
+   }
+
request->ringbuf = request->ctx->engine[engine->id].ringbuf;
 
if (i915.enable_guc_submission) {
@@ -2006,7 +2014,7 @@ logical_ring_init(struct drm_device *dev, struct 
intel_engine_cs *engine)
if (ret)
goto error;
 
-   ret = intel_lr_context_deferred_alloc(dctx, engine);
+   ret = execlists_context_deferred_alloc(dctx, engine);
if (ret)
goto error;
 
@@ -2480,9 +2488,9 @@ uint32_t intel_lr_context_size(struct intel_engine_cs 
*engine)
 }
 
 /**
- * intel_lr_context_deferred_alloc() - create the LRC specific bits of a 
context
+ * execlists_context_deferred_alloc() - create the LRC specific bits of a 
context
  * @ctx: LR context to create.
- * @ring: engine to be used with the context.
+ * @engine: engine to be used with the context.
  *
  * This function can be called more than once, with different engines, if we 
plan
  * to use the context with them. The context backing objects and the 
ringbuffers
@@ -2492,9 +2500,8 @@ uint32_t intel_lr_context_size(struct intel_engine_cs 
*engine)
  *
  * Return: non-zero on error.
  */
-
-int intel_lr_context_deferred_alloc(struct intel_context *ctx,
-   struct intel_engine_cs *engine)
+static int execlists_context_deferred_alloc(struct intel_context *ctx,
+   struct intel_engine_cs *engine)
 {
struct drm_device *dev = engine->dev;
struct drm_i915_gem_object *ctx_obj;
diff --git a/drivers/gpu/drm/i915/intel_lrc.h b/drivers/gpu/drm/i915/intel_lrc.h
index 9510826f0d90..28ff324ba5dc 100644
--- a/drivers/gpu/drm/i915/intel_lrc.h
+++ b/drivers/gpu/drm/i915/intel_lrc.h
@@ -101,8 +101,6 @@ static inline void intel_logical_ring_emit_reg(struct 
intel_ringbuffer *ringbuf,
 
 void intel_lr_context_free(struct intel_context *ctx);
 uint32_t intel_lr_context_size(struct intel_engine_cs *engine);
-int intel_lr_context_deferred_alloc(struct intel_context *ctx,
-   struct intel_engine_cs *engine);
 void intel_lr_context_unpin(struct intel_context *ctx,
struct intel_engine_cs *engine);
 
-- 
2.8.1

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


[Intel-gfx] [PATCH v6 13/25] drm/i915: Remove the identical implementations of request space reservation

2016-04-26 Thread Chris Wilson
Now that we share intel_ring_begin(), reserving space for the tail of
the request is identical between legacy/execlists and so the tautology
can be removed. In the process, we move the reserved space tracking
from the ringbuffer on to the request. This is to enable us to reorder
the reserved space allocation in the next patch.

Signed-off-by: Chris Wilson 
Cc: Joonas Lahtinen 
Cc: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_drv.h |  3 +++
 drivers/gpu/drm/i915/i915_gem.c | 21 ++--
 drivers/gpu/drm/i915/intel_lrc.c| 15 ---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 44 +++--
 drivers/gpu/drm/i915/intel_ringbuffer.h | 17 -
 5 files changed, 19 insertions(+), 81 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 444a8ea0c5c4..831da9f43324 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2278,6 +2278,9 @@ struct drm_i915_gem_request {
/** Position in the ringbuffer of the end of the whole request */
u32 tail;
 
+   /** Preallocate space in the ringbuffer for the emitting the request */
+   u32 reserved_space;
+
/**
 * Context and ring buffer related to this request
 * Contexts are refcounted, so when this request is associated with a
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 71135c3ce44e..0e27484bd28a 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2573,6 +2573,7 @@ void __i915_add_request(struct drm_i915_gem_request 
*request,
struct drm_i915_private *dev_priv;
struct intel_ringbuffer *ringbuf;
u32 request_start;
+   u32 reserved_tail;
int ret;
 
if (WARN_ON(request == NULL))
@@ -2587,9 +2588,10 @@ void __i915_add_request(struct drm_i915_gem_request 
*request,
 * should already have been reserved in the ring buffer. Let the ring
 * know that it is time to use that space up.
 */
-   intel_ring_reserved_space_use(ringbuf);
-
request_start = intel_ring_get_tail(ringbuf);
+   reserved_tail = request->reserved_space;
+   request->reserved_space = 0;
+
/*
 * Emit any outstanding flushes - execbuf can fail to emit the flush
 * after having emitted the batchbuffer command. Hence we need to fix
@@ -2653,7 +2655,13 @@ void __i915_add_request(struct drm_i915_gem_request 
*request,
intel_mark_busy(dev_priv->dev);
 
/* Sanity check that the reserved size was large enough. */
-   intel_ring_reserved_space_end(ringbuf);
+   ret = intel_ring_get_tail(ringbuf) - request_start;
+   if (ret < 0)
+   ret += ringbuf->size;
+   WARN_ONCE(ret > reserved_tail,
+ "Not enough space reserved (%d bytes) "
+ "for adding the request (%d bytes)\n",
+ reserved_tail, ret);
 }
 
 static bool i915_context_is_banned(struct drm_i915_private *dev_priv,
@@ -2774,17 +2782,14 @@ __i915_gem_request_alloc(struct intel_engine_cs *engine,
 * to be redone if the request is not actually submitted straight
 * away, e.g. because a GPU scheduler has deferred it.
 */
-   if (i915.enable_execlists)
-   ret = intel_logical_ring_reserve_space(req);
-   else
-   ret = intel_ring_reserve_space(req);
+   req->reserved_space = MIN_SPACE_FOR_ADD_REQUEST;
+   ret = intel_ring_begin(req, 0);
if (ret) {
/*
 * At this point, the request is fully allocated even if not
 * fully prepared. Thus it can be cleaned up using the proper
 * free code.
 */
-   intel_ring_reserved_space_cancel(req->ringbuf);
i915_gem_request_unreference(req);
return ret;
}
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index ba87c94928e7..910044cf143e 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -772,21 +772,6 @@ intel_logical_ring_advance_and_submit(struct 
drm_i915_gem_request *request)
return 0;
 }
 
-int intel_logical_ring_reserve_space(struct drm_i915_gem_request *request)
-{
-   /*
-* The first call merely notes the reserve request and is common for
-* all back ends. The subsequent localised _begin() call actually
-* ensures that the reservation is available. Without the begin, if
-* the request creator immediately submitted the request without
-* adding any commands to it then there might not actually be
-* sufficient room for the submission commands.
-*/
-   intel_ring_reserved_space_reserve(request->ringbuf, 
MIN_SPACE_FOR_ADD_REQUEST);
-
-   return intel_ring_begin(request, 0);
-}
-
 /**
  * execlists_submission() - submit a batchbuffer for ex

[Intel-gfx] [PATCH v6 18/25] drm/i915: Replace the pinned context address with its unique ID

2016-04-26 Thread Chris Wilson
Rather than reuse the current location of the context in the global GTT
for its hardware identifier, use the context's unique ID assigned to it
for its whole lifetime.

Signed-off-by: Chris Wilson 
Reviewed-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_debugfs.c | 12 +---
 drivers/gpu/drm/i915/intel_lrc.c| 39 +
 drivers/gpu/drm/i915/intel_lrc.h|  3 ---
 3 files changed, 14 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 3bd2f89933ff..be2a4a0fae13 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2043,15 +2043,13 @@ static void i915_dump_lrc_obj(struct seq_file *m,
struct drm_i915_gem_object *ctx_obj = ctx->engine[engine->id].state;
unsigned long ggtt_offset = 0;
 
+   seq_printf(m, "CONTEXT: %s %u\n", engine->name, ctx->hw_id);
+
if (ctx_obj == NULL) {
-   seq_printf(m, "Context on %s with no gem object\n",
-  engine->name);
+   seq_puts(m, "\tNot allocated\n");
return;
}
 
-   seq_printf(m, "CONTEXT: %s %u\n", engine->name,
-  intel_execlists_ctx_id(ctx, engine));
-
if (!i915_gem_obj_ggtt_bound(ctx_obj))
seq_puts(m, "\tNot bound in GGTT\n");
else
@@ -2170,8 +2168,8 @@ static int i915_execlists(struct seq_file *m, void *data)
 
seq_printf(m, "\t%d requests in queue\n", count);
if (head_req) {
-   seq_printf(m, "\tHead request id: %u\n",
-  intel_execlists_ctx_id(head_req->ctx, 
engine));
+   seq_printf(m, "\tHead request context: %u\n",
+  head_req->ctx->hw_id);
seq_printf(m, "\tHead request tail: %u\n",
   head_req->tail);
}
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 5d8ee9059eee..ccabb688e049 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -224,6 +224,7 @@ enum {
FAULT_AND_CONTINUE /* Unsupported */
 };
 #define GEN8_CTX_ID_SHIFT 32
+#define GEN8_CTX_ID_WIDTH 21
 #define GEN8_CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT   0x17
 #define GEN9_CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT   0x26
 
@@ -307,7 +308,7 @@ logical_ring_init_platform_invariants(struct 
intel_engine_cs *engine)
  * This is what a descriptor looks like, from LSB to MSB:
  *bits  0-11:flags, GEN8_CTX_* (cached in ctx_desc_template)
  *bits 12-31:LRCA, GTT address of (the HWSP of) this context
- *bits 32-52:ctx ID, a globally unique tag (the LRCA again!)
+ *bits 32-52:ctx ID, a globally unique tag
  *bits 53-54:mbz, reserved for use by hardware
  *bits 55-63:group ID, currently unused and set to 0
  */
@@ -315,14 +316,14 @@ static void
 intel_lr_context_descriptor_update(struct intel_context *ctx,
   struct intel_engine_cs *engine)
 {
-   uint64_t lrca, desc;
+   u64 desc;
 
-   lrca = ctx->engine[engine->id].lrc_vma->node.start +
-  LRC_PPHWSP_PN * PAGE_SIZE;
+   BUILD_BUG_ON(MAX_CONTEXT_HW_ID > (1> PAGE_SHIFT) << GEN8_CTX_ID_SHIFT; /* bits 32-52 */
+   desc = engine->ctx_desc_template;   /* bits  0-11 */
+   desc |= ctx->engine[engine->id].lrc_vma->node.start +   /* bits 12-31 */
+  LRC_PPHWSP_PN * PAGE_SIZE;
+   desc |= (u64)ctx->hw_id << GEN8_CTX_ID_SHIFT;   /* bits 32-52 */
 
ctx->engine[engine->id].lrc_desc = desc;
 }
@@ -333,28 +334,6 @@ uint64_t intel_lr_context_descriptor(struct intel_context 
*ctx,
return ctx->engine[engine->id].lrc_desc;
 }
 
-/**
- * intel_execlists_ctx_id() - get the Execlists Context ID
- * @ctx: Context to get the ID for
- * @ring: Engine to get the ID for
- *
- * Do not confuse with ctx->id! Unfortunately we have a name overload
- * here: the old context ID we pass to userspace as a handler so that
- * they can refer to a context, and the new context ID we pass to the
- * ELSP so that the GPU can inform us of the context status via
- * interrupts.
- *
- * The context ID is a portion of the context descriptor, so we can
- * just extract the required part from the cached descriptor.
- *
- * Return: 20-bits globally unique context ID.
- */
-u32 intel_execlists_ctx_id(struct intel_context *ctx,
-  struct intel_engine_cs *engine)
-{
-   return intel_lr_context_descriptor(ctx, engine) >> GEN8_CTX_ID_SHIFT;
-}
-
 static void execlists_elsp_write(struct drm_i915_gem_request *rq0,
 struct drm_i915_gem_request *rq1)
 {
@@

[Intel-gfx] [PATCH v6 05/25] drm/i915: Move ioremap_wc tracking onto VMA

2016-04-26 Thread Chris Wilson
By tracking the iomapping on the VMA itself, we can share that area
between multiple users. Also by only revoking the iomapping upon
unbinding from the mappable portion of the GGTT, we can keep that iomap
across multiple invocations (e.g. execlists context pinning).

Note that by moving the iounnmap tracking to the VMA, we actually end up
fixing a leak of the iomapping in intel_fbdev.

v1.5: Rebase prompted by Tvrtko
v2: Drop dev_priv parameter, we can recover the i915_ggtt from the vma.
v3: Move handling of ioremap space exhaustion to vmap_purge and also
allow vmallocs to recover old iomaps. Add Tvrtko's kerneldoc.
v4: Fix a use-after-free in shrinker and rearrange i915_vma_iomap
v5: Back to i915_vm_to_ggtt
v6: Use i915_vma_pin_iomap and i915_vma_unpin_iomap to mark critical
sections and ensure the VMA cannot be reaped whilst mapped.
v7: Move i915_vma_iounmap so that consumers of the API are not tempted,
and add iomem annotations

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Reviewed-by: Tvrtko Ursulin 
Cc: Joonas Lahtinen 
---
 drivers/gpu/drm/i915/i915_gem.c  | 13 
 drivers/gpu/drm/i915/i915_gem_gtt.c  | 26 
 drivers/gpu/drm/i915/i915_gem_gtt.h  | 35 
 drivers/gpu/drm/i915/i915_gem_shrinker.c | 28 +++--
 drivers/gpu/drm/i915/intel_fbdev.c   | 22 +++-
 5 files changed, 108 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index d493e79d0f6d..40f6504de7c1 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3338,6 +3338,17 @@ static void i915_gem_object_finish_gtt(struct 
drm_i915_gem_object *obj)
old_write_domain);
 }
 
+static void __i915_vma_iounmap(struct i915_vma *vma)
+{
+   GEM_BUG_ON(vma->pin_count);
+
+   if (vma->iomap == NULL)
+   return;
+
+   io_mapping_unmap(vma->iomap);
+   vma->iomap = NULL;
+}
+
 static int __i915_vma_unbind(struct i915_vma *vma, bool wait)
 {
struct drm_i915_gem_object *obj = vma->obj;
@@ -3370,6 +3381,8 @@ static int __i915_vma_unbind(struct i915_vma *vma, bool 
wait)
ret = i915_gem_object_put_fence(obj);
if (ret)
return ret;
+
+   __i915_vma_iounmap(vma);
}
 
trace_i915_vma_unbind(vma);
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c 
b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 4ddf2ed8501f..942b98f910f8 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -3633,3 +3633,29 @@ i915_ggtt_view_size(struct drm_i915_gem_object *obj,
return obj->base.size;
}
 }
+
+void __iomem *i915_vma_pin_iomap(struct i915_vma *vma)
+{
+   void __iomem *ptr;
+
+   lockdep_assert_held(&vma->vm->dev->struct_mutex);
+   if (WARN_ON(!vma->obj->map_and_fenceable))
+   return ERR_PTR(-ENODEV);
+
+   GEM_BUG_ON(!vma->is_ggtt);
+   GEM_BUG_ON((vma->bound & GLOBAL_BIND) == 0);
+
+   ptr = vma->iomap;
+   if (ptr == NULL) {
+   ptr = io_mapping_map_wc(i915_vm_to_ggtt(vma->vm)->mappable,
+   vma->node.start,
+   vma->node.size);
+   if (ptr == NULL)
+   return ERR_PTR(-ENOMEM);
+
+   vma->iomap = ptr;
+   }
+
+   vma->pin_count++;
+   return ptr;
+}
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h 
b/drivers/gpu/drm/i915/i915_gem_gtt.h
index d7dd3d8a8758..b0ae6632c01a 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
@@ -34,6 +34,8 @@
 #ifndef __I915_GEM_GTT_H__
 #define __I915_GEM_GTT_H__
 
+#include 
+
 struct drm_i915_file_private;
 
 typedef uint32_t gen6_pte_t;
@@ -175,6 +177,7 @@ struct i915_vma {
struct drm_mm_node node;
struct drm_i915_gem_object *obj;
struct i915_address_space *vm;
+   void __iomem *iomap;
 
/** Flags and address space this VMA is bound to */
 #define GLOBAL_BIND(1<<0)
@@ -559,4 +562,36 @@ size_t
 i915_ggtt_view_size(struct drm_i915_gem_object *obj,
const struct i915_ggtt_view *view);
 
+/**
+ * i915_vma_pin_iomap - calls ioremap_wc to map the GGTT VMA via the aperture
+ * @vma: VMA to iomap
+ *
+ * The passed in VMA has to be pinned in the global GTT mappable region.
+ * An extra pinning of the VMA is acquired for the return iomapping,
+ * the caller must call i915_vma_unpin_iomap to relinquish the pinning
+ * after the iomapping is no longer required.
+ *
+ * Callers must hold the struct_mutex.
+ *
+ * Returns a valid iomapped pointer or ERR_PTR.
+ */
+void __iomem *i915_vma_pin_iomap(struct i915_vma *vma);
+
+/**
+ * i915_vma_unpin_iomap - unpins the mapping returned from i915_vma_iomap
+ * @vma: VMA to unpin
+ *
+ * Unpins the previously iomapped VMA 

[Intel-gfx] [PATCH v6 01/25] drm/i915/fbdev: Call intel_unpin_fb_obj() on release

2016-04-26 Thread Chris Wilson
When releasing the intel_fbdev, we should unpin the framebuffer that we
pinned during construction.

Signed-off-by: Chris Wilson 
---
 drivers/gpu/drm/i915/intel_display.c | 2 +-
 drivers/gpu/drm/i915/intel_drv.h | 1 +
 drivers/gpu/drm/i915/intel_fbdev.c   | 7 ++-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index b7cb632a2a31..87ce7852482b 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2309,7 +2309,7 @@ err_pm:
return ret;
 }
 
-static void intel_unpin_fb_obj(struct drm_framebuffer *fb, unsigned int 
rotation)
+void intel_unpin_fb_obj(struct drm_framebuffer *fb, unsigned int rotation)
 {
struct drm_i915_gem_object *obj = intel_fb_obj(fb);
struct i915_ggtt_view view;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index cb89a35a6755..dcb19133f640 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1162,6 +1162,7 @@ void intel_release_load_detect_pipe(struct drm_connector 
*connector,
struct drm_modeset_acquire_ctx *ctx);
 int intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
   unsigned int rotation);
+void intel_unpin_fb_obj(struct drm_framebuffer *fb, unsigned int rotation);
 struct drm_framebuffer *
 __intel_framebuffer_create(struct drm_device *dev,
   struct drm_mode_fb_cmd2 *mode_cmd,
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c 
b/drivers/gpu/drm/i915/intel_fbdev.c
index af561542a5a1..1c3ad121f1b9 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -287,7 +287,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
 out_destroy_fbi:
drm_fb_helper_release_fbi(helper);
 out_unpin:
-   i915_gem_object_ggtt_unpin(obj);
+   intel_unpin_fb_obj(&ifbdev->fb->base, BIT(DRM_ROTATE_0));
 out_unlock:
mutex_unlock(&dev->struct_mutex);
return ret;
@@ -551,6 +551,11 @@ static void intel_fbdev_destroy(struct drm_device *dev,
 
if (ifbdev->fb) {
drm_framebuffer_unregister_private(&ifbdev->fb->base);
+
+   mutex_lock(&dev->struct_mutex);
+   intel_unpin_fb_obj(&ifbdev->fb->base, BIT(DRM_ROTATE_0));
+   mutex_unlock(&dev->struct_mutex);
+
drm_framebuffer_remove(&ifbdev->fb->base);
}
 }
-- 
2.8.1

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


[Intel-gfx] [PATCH v6 16/25] drm/i915: Update execlists context descriptor format commentary

2016-04-26 Thread Chris Wilson
The comments describing the Context Descriptor Format are off by a bit
for the size of the context ID.

Signed-off-by: Chris Wilson 
Cc: Dave Gordon 
Cc: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/intel_lrc.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index b5c2c1931a5f..5d8ee9059eee 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -305,10 +305,11 @@ logical_ring_init_platform_invariants(struct 
intel_engine_cs *engine)
  * which remains valid until the context is unpinned.
  *
  * This is what a descriptor looks like, from LSB to MSB:
- *bits 0-11:flags, GEN8_CTX_* (cached in ctx_desc_template)
+ *bits  0-11:flags, GEN8_CTX_* (cached in ctx_desc_template)
  *bits 12-31:LRCA, GTT address of (the HWSP of) this context
- *bits 32-51:ctx ID, a globally unique tag (the LRCA again!)
- *bits 52-63:reserved, may encode the engine ID (for GuC)
+ *bits 32-52:ctx ID, a globally unique tag (the LRCA again!)
+ *bits 53-54:mbz, reserved for use by hardware
+ *bits 55-63:group ID, currently unused and set to 0
  */
 static void
 intel_lr_context_descriptor_update(struct intel_context *ctx,
@@ -319,9 +320,9 @@ intel_lr_context_descriptor_update(struct intel_context 
*ctx,
lrca = ctx->engine[engine->id].lrc_vma->node.start +
   LRC_PPHWSP_PN * PAGE_SIZE;
 
-   desc = engine->ctx_desc_template;  /* bits  
0-11 */
+   desc = engine->ctx_desc_template;  /* bits  0-11 */
desc |= lrca;  /* bits 12-31 */
-   desc |= (lrca >> PAGE_SHIFT) << GEN8_CTX_ID_SHIFT; /* bits 32-51 */
+   desc |= (lrca >> PAGE_SHIFT) << GEN8_CTX_ID_SHIFT; /* bits 32-52 */
 
ctx->engine[engine->id].lrc_desc = desc;
 }
-- 
2.8.1

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


[Intel-gfx] [PATCH v6 10/25] drm/i915: Remove early l3-remap

2016-04-26 Thread Chris Wilson
Since we do the l3-remap on context switch, we can remove the redundant
early call to set the mapping prior to performing the first context
switch.

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Reviewed-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_drv.h |  1 -
 drivers/gpu/drm/i915/i915_gem.c | 10 +-
 drivers/gpu/drm/i915/i915_gem_context.c |  4 ++--
 3 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index c3fbc056d6aa..a4032393eddf 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3147,7 +3147,6 @@ bool i915_gem_clflush_object(struct drm_i915_gem_object 
*obj, bool force);
 int __must_check i915_gem_init(struct drm_device *dev);
 int i915_gem_init_engines(struct drm_device *dev);
 int __must_check i915_gem_init_hw(struct drm_device *dev);
-int i915_gem_l3_remap(struct drm_i915_gem_request *req, int slice);
 void i915_gem_init_swizzling(struct drm_device *dev);
 void i915_gem_cleanup_engines(struct drm_device *dev);
 int __must_check i915_gpu_idle(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index f07cf81ef16b..c5dd4008e775 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4834,7 +4834,7 @@ i915_gem_init_hw(struct drm_device *dev)
 {
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_engine_cs *engine;
-   int ret, j;
+   int ret;
 
if (INTEL_INFO(dev)->gen < 6 && !intel_enable_gtt())
return -EIO;
@@ -4916,14 +4916,6 @@ i915_gem_init_hw(struct drm_device *dev)
break;
}
 
-   if (engine->id == RCS) {
-   for (j = 0; j < NUM_L3_SLICES(dev); j++) {
-   ret = i915_gem_l3_remap(req, j);
-   if (ret)
-   goto err_request;
-   }
-   }
-
ret = i915_ppgtt_init_ring(req);
if (ret)
goto err_request;
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c 
b/drivers/gpu/drm/i915/i915_gem_context.c
index 373bad8ee04c..7556cb7c329d 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -601,7 +601,7 @@ mi_set_context(struct drm_i915_gem_request *req, u32 
hw_flags)
return ret;
 }
 
-int i915_gem_l3_remap(struct drm_i915_gem_request *req, int slice)
+static int remap_l3(struct drm_i915_gem_request *req, int slice)
 {
u32 *remap_info = req->i915->l3_parity.remap_info[slice];
struct intel_engine_cs *engine = req->engine;
@@ -799,7 +799,7 @@ static int do_rcs_switch(struct drm_i915_gem_request *req)
if (!(to->remap_slice & (1

[Intel-gfx] [PATCH v6 12/25] drm/i915: Unify intel_ring_begin()

2016-04-26 Thread Chris Wilson
Combine the near identical implementations of intel_logical_ring_begin()
and intel_ring_begin() - the only difference is that the logical wait
has to check for a matching ring (which is assumed by legacy).

Signed-off-by: Chris Wilson 
Cc: Joonas Lahtinen 
Cc: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/intel_lrc.c| 146 ++---
 drivers/gpu/drm/i915/intel_lrc.h|   1 -
 drivers/gpu/drm/i915/intel_mocs.c   |  12 +--
 drivers/gpu/drm/i915/intel_ringbuffer.c | 182 
 drivers/gpu/drm/i915/intel_ringbuffer.h |   3 -
 5 files changed, 81 insertions(+), 263 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 2b7e6bbc017b..ba87c94928e7 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -721,48 +721,6 @@ int intel_logical_ring_alloc_request_extras(struct 
drm_i915_gem_request *request
return ret;
 }
 
-static int logical_ring_wait_for_space(struct drm_i915_gem_request *req,
-  int bytes)
-{
-   struct intel_ringbuffer *ringbuf = req->ringbuf;
-   struct intel_engine_cs *engine = req->engine;
-   struct drm_i915_gem_request *target;
-   unsigned space;
-   int ret;
-
-   if (intel_ring_space(ringbuf) >= bytes)
-   return 0;
-
-   /* The whole point of reserving space is to not wait! */
-   WARN_ON(ringbuf->reserved_in_use);
-
-   list_for_each_entry(target, &engine->request_list, list) {
-   /*
-* The request queue is per-engine, so can contain requests
-* from multiple ringbuffers. Here, we must ignore any that
-* aren't from the ringbuffer we're considering.
-*/
-   if (target->ringbuf != ringbuf)
-   continue;
-
-   /* Would completion of this request free enough space? */
-   space = __intel_ring_space(target->postfix, ringbuf->tail,
-  ringbuf->size);
-   if (space >= bytes)
-   break;
-   }
-
-   if (WARN_ON(&target->list == &engine->request_list))
-   return -ENOSPC;
-
-   ret = i915_wait_request(target);
-   if (ret)
-   return ret;
-
-   ringbuf->space = space;
-   return 0;
-}
-
 /*
  * intel_logical_ring_advance_and_submit() - advance the tail and submit the 
workload
  * @request: Request to advance the logical ringbuffer of.
@@ -814,92 +772,6 @@ intel_logical_ring_advance_and_submit(struct 
drm_i915_gem_request *request)
return 0;
 }
 
-static void __wrap_ring_buffer(struct intel_ringbuffer *ringbuf)
-{
-   uint32_t __iomem *virt;
-   int rem = ringbuf->size - ringbuf->tail;
-
-   virt = ringbuf->virtual_start + ringbuf->tail;
-   rem /= 4;
-   while (rem--)
-   iowrite32(MI_NOOP, virt++);
-
-   ringbuf->tail = 0;
-   intel_ring_update_space(ringbuf);
-}
-
-static int logical_ring_prepare(struct drm_i915_gem_request *req, int bytes)
-{
-   struct intel_ringbuffer *ringbuf = req->ringbuf;
-   int remain_usable = ringbuf->effective_size - ringbuf->tail;
-   int remain_actual = ringbuf->size - ringbuf->tail;
-   int ret, total_bytes, wait_bytes = 0;
-   bool need_wrap = false;
-
-   if (ringbuf->reserved_in_use)
-   total_bytes = bytes;
-   else
-   total_bytes = bytes + ringbuf->reserved_size;
-
-   if (unlikely(bytes > remain_usable)) {
-   /*
-* Not enough space for the basic request. So need to flush
-* out the remainder and then wait for base + reserved.
-*/
-   wait_bytes = remain_actual + total_bytes;
-   need_wrap = true;
-   } else {
-   if (unlikely(total_bytes > remain_usable)) {
-   /*
-* The base request will fit but the reserved space
-* falls off the end. So don't need an immediate wrap
-* and only need to effectively wait for the reserved
-* size space from the start of ringbuffer.
-*/
-   wait_bytes = remain_actual + ringbuf->reserved_size;
-   } else if (total_bytes > ringbuf->space) {
-   /* No wrapping required, just waiting. */
-   wait_bytes = total_bytes;
-   }
-   }
-
-   if (wait_bytes) {
-   ret = logical_ring_wait_for_space(req, wait_bytes);
-   if (unlikely(ret))
-   return ret;
-
-   if (need_wrap)
-   __wrap_ring_buffer(ringbuf);
-   }
-
-   return 0;
-}
-
-/**
- * intel_logical_ring_begin() - prepare the logical ringbuffer to accept some 
commands
- *
- * @req: The request to sta

[Intel-gfx] [PATCH v6 14/25] drm/i915: Manually unwind after a failed request allocation

2016-04-26 Thread Chris Wilson
In the next patches, we want to move the work out of freeing the request
and into its retirement (so that we can free the request without
requiring the struct_mutex). This means that we cannot rely on
unreferencing the request to completely teardown the request any more
and so we need to manually unwind the failed allocation. In doing so, we
reorder the allocation in order to make the unwind simple (and ensure
that we don't try to unwind a partial request that may have modified
global state) and so we end up pushing the initial preallocation down
into the engine request initialisation functions where we have the
requisite control over the state of the request.

Moving the initial preallocation into the engine is less than ideal: it
moves logic to handle a specific problem with request handling out of
the common code. On the other hand, it does allow those backends
significantly more flexibility in performing its allocations.

Signed-off-by: Chris Wilson 
Cc: Mika Kuoppala 
Cc: Tvrtko Ursulin 
Cc: Joonas Lahtinen 
---
 drivers/gpu/drm/i915/i915_gem.c | 28 +---
 drivers/gpu/drm/i915/intel_lrc.c| 16 ++--
 drivers/gpu/drm/i915/intel_ringbuffer.c |  2 +-
 3 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 0e27484bd28a..d7ff5e79182f 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2766,15 +2766,6 @@ __i915_gem_request_alloc(struct intel_engine_cs *engine,
req->ctx  = ctx;
i915_gem_context_reference(req->ctx);
 
-   if (i915.enable_execlists)
-   ret = intel_logical_ring_alloc_request_extras(req);
-   else
-   ret = intel_ring_alloc_request_extras(req);
-   if (ret) {
-   i915_gem_context_unreference(req->ctx);
-   goto err;
-   }
-
/*
 * Reserve space in the ring buffer for all the commands required to
 * eventually emit this request. This is to guarantee that the
@@ -2783,20 +2774,19 @@ __i915_gem_request_alloc(struct intel_engine_cs *engine,
 * away, e.g. because a GPU scheduler has deferred it.
 */
req->reserved_space = MIN_SPACE_FOR_ADD_REQUEST;
-   ret = intel_ring_begin(req, 0);
-   if (ret) {
-   /*
-* At this point, the request is fully allocated even if not
-* fully prepared. Thus it can be cleaned up using the proper
-* free code.
-*/
-   i915_gem_request_unreference(req);
-   return ret;
-   }
+
+   if (i915.enable_execlists)
+   ret = intel_logical_ring_alloc_request_extras(req);
+   else
+   ret = intel_ring_alloc_request_extras(req);
+   if (ret)
+   goto err_ctx;
 
*req_out = req;
return 0;
 
+err_ctx:
+   i915_gem_context_unreference(ctx);
 err:
kmem_cache_free(dev_priv->requests, req);
return ret;
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 910044cf143e..01517dd7069b 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -698,7 +698,7 @@ static int execlists_move_to_gpu(struct 
drm_i915_gem_request *req,
 
 int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request 
*request)
 {
-   int ret = 0;
+   int ret;
 
request->ringbuf = request->ctx->engine[request->engine->id].ringbuf;
 
@@ -715,9 +715,21 @@ int intel_logical_ring_alloc_request_extras(struct 
drm_i915_gem_request *request
return ret;
}
 
-   if (request->ctx != request->i915->kernel_context)
+   if (request->ctx != request->i915->kernel_context) {
ret = intel_lr_context_pin(request->ctx, request->engine);
+   if (ret)
+   return ret;
+   }
 
+   ret = intel_ring_begin(request, 0);
+   if (ret)
+   goto err_unpin;
+
+   return 0;
+
+err_unpin:
+   if (request->ctx != request->i915->kernel_context)
+   intel_lr_context_unpin(request->ctx, request->engine);
return ret;
 }
 
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c 
b/drivers/gpu/drm/i915/intel_ringbuffer.c
index ba5946b9fa06..1193372f74fd 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2333,7 +2333,7 @@ int intel_engine_idle(struct intel_engine_cs *engine)
 int intel_ring_alloc_request_extras(struct drm_i915_gem_request *request)
 {
request->ringbuf = request->engine->buffer;
-   return 0;
+   return intel_ring_begin(request, 0);
 }
 
 static int wait_for_space(struct drm_i915_gem_request *req, int bytes)
-- 
2.8.1

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


[Intel-gfx] Premature unpinning, finally?

2016-04-26 Thread Chris Wilson
Now we have the context leak sorted, everything should be in place to
satisfy BAT, or so I hope. A few new patches need reviewing, and the rest
could do with eyeballing - though I have tried to keep them the same, the
code around them has changed slightly, and I hope I have introduced subtle
bugs in the rebasing. 

[PATCH v6 12/25] drm/i915: Unify intel_ring_begin()
[PATCH v6 13/25] drm/i915: Remove the identical implementations of
[PATCH v6 14/25] drm/i915: Manually unwind after a failed request
[PATCH v6 15/25] drm/i915: Preallocate enough space for the average
[PATCH v6 16/25] drm/i915: Update execlists context descriptor format

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


[Intel-gfx] [PATCH v6 15/25] drm/i915: Preallocate enough space for the average request

2016-04-26 Thread Chris Wilson
Rather than being interrupted when we run out of space halfway through
the request, and having to restart from the beginning (and returning to
userspace), flush a little more free space when we prepare the request.

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/intel_lrc.c|  7 +++
 drivers/gpu/drm/i915/intel_ringbuffer.c | 16 +++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 01517dd7069b..b5c2c1931a5f 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -700,6 +700,12 @@ int intel_logical_ring_alloc_request_extras(struct 
drm_i915_gem_request *request
 {
int ret;
 
+   /* Flush enough space to reduce the likelihood of waiting after
+* we start building the request - in which case we will just
+* have to repeat work.
+*/
+   request->reserved_space += MIN_SPACE_FOR_ADD_REQUEST;
+
request->ringbuf = request->ctx->engine[request->engine->id].ringbuf;
 
if (i915.enable_guc_submission) {
@@ -725,6 +731,7 @@ int intel_logical_ring_alloc_request_extras(struct 
drm_i915_gem_request *request
if (ret)
goto err_unpin;
 
+   request->reserved_space -= MIN_SPACE_FOR_ADD_REQUEST;
return 0;
 
 err_unpin:
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c 
b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 1193372f74fd..1285605f25c7 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2332,8 +2332,22 @@ int intel_engine_idle(struct intel_engine_cs *engine)
 
 int intel_ring_alloc_request_extras(struct drm_i915_gem_request *request)
 {
+   int ret;
+
+   /* Flush enough space to reduce the likelihood of waiting after
+* we start building the request - in which case we will just
+* have to repeat work.
+*/
+   request->reserved_space += MIN_SPACE_FOR_ADD_REQUEST;
+
request->ringbuf = request->engine->buffer;
-   return intel_ring_begin(request, 0);
+
+   ret = intel_ring_begin(request, 0);
+   if (ret)
+   return ret;
+
+   request->reserved_space -= MIN_SPACE_FOR_ADD_REQUEST;
+   return 0;
 }
 
 static int wait_for_space(struct drm_i915_gem_request *req, int bytes)
-- 
2.8.1

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


[Intel-gfx] [PATCH v6 09/25] drm/i915: Consolidate L3 remapping LRI

2016-04-26 Thread Chris Wilson
We can use a single MI_LOAD_REGISTER_IMM command packet to write all the
L3 remapping registers, shrinking the number of bytes required to emit
the context switch.

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Reviewed-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_gem_context.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_context.c 
b/drivers/gpu/drm/i915/i915_gem_context.c
index a429b4dcb4de..373bad8ee04c 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -603,16 +603,14 @@ mi_set_context(struct drm_i915_gem_request *req, u32 
hw_flags)
 
 int i915_gem_l3_remap(struct drm_i915_gem_request *req, int slice)
 {
+   u32 *remap_info = req->i915->l3_parity.remap_info[slice];
struct intel_engine_cs *engine = req->engine;
-   struct drm_device *dev = engine->dev;
-   struct drm_i915_private *dev_priv = dev->dev_private;
-   u32 *remap_info = dev_priv->l3_parity.remap_info[slice];
int i, ret;
 
-   if (!HAS_L3_DPF(dev) || !remap_info)
+   if (!remap_info)
return 0;
 
-   ret = intel_ring_begin(req, GEN7_L3LOG_SIZE / 4 * 3);
+   ret = intel_ring_begin(req, GEN7_L3LOG_SIZE/4 * 2 + 2);
if (ret)
return ret;
 
@@ -621,15 +619,15 @@ int i915_gem_l3_remap(struct drm_i915_gem_request *req, 
int slice)
 * here because no other code should access these registers other than
 * at initialization time.
 */
-   for (i = 0; i < GEN7_L3LOG_SIZE / 4; i++) {
-   intel_ring_emit(engine, MI_LOAD_REGISTER_IMM(1));
+   intel_ring_emit(engine, MI_LOAD_REGISTER_IMM(GEN7_L3LOG_SIZE/4));
+   for (i = 0; i < GEN7_L3LOG_SIZE/4; i++) {
intel_ring_emit_reg(engine, GEN7_L3LOG(slice, i));
intel_ring_emit(engine, remap_info[i]);
}
-
+   intel_ring_emit(engine, MI_NOOP);
intel_ring_advance(engine);
 
-   return ret;
+   return 0;
 }
 
 static inline bool skip_rcs_switch(struct intel_engine_cs *engine,
-- 
2.8.1

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


[Intel-gfx] [PATCH v6 02/25] drm/i915/overlay: Replace i915_gem_obj_ggtt_offset() with the known flip_addr

2016-04-26 Thread Chris Wilson
When setting up the overlay page, we pin it into the GGTT (when using
virtual addresses) and store the offset as overlay->flip_addr. Rather
than doing a lookup of the GGTT address everytime, we can use the known
address instead.

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Reviewed-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/intel_overlay.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_overlay.c 
b/drivers/gpu/drm/i915/intel_overlay.c
index 597fbcda8c5c..06bcd6aee64f 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -198,7 +198,7 @@ intel_overlay_map_regs(struct intel_overlay *overlay)
regs = (struct overlay_registers __iomem 
*)overlay->reg_bo->phys_handle->vaddr;
else
regs = io_mapping_map_wc(ggtt->mappable,
-
i915_gem_obj_ggtt_offset(overlay->reg_bo));
+overlay->flip_addr);
 
return regs;
 }
@@ -1493,7 +1493,7 @@ intel_overlay_map_regs_atomic(struct intel_overlay 
*overlay)
overlay->reg_bo->phys_handle->vaddr;
else
regs = io_mapping_map_atomic_wc(ggtt->mappable,
-   
i915_gem_obj_ggtt_offset(overlay->reg_bo));
+   overlay->flip_addr);
 
return regs;
 }
@@ -1523,10 +1523,7 @@ intel_overlay_capture_error_state(struct drm_device *dev)
 
error->dovsta = I915_READ(DOVSTA);
error->isr = I915_READ(ISR);
-   if (OVERLAY_NEEDS_PHYSICAL(overlay->dev))
-   error->base = (__force long)overlay->reg_bo->phys_handle->vaddr;
-   else
-   error->base = i915_gem_obj_ggtt_offset(overlay->reg_bo);
+   error->base = overlay->flip_addr;
 
regs = intel_overlay_map_regs_atomic(overlay);
if (!regs)
-- 
2.8.1

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


[Intel-gfx] [PATCH v6 04/25] drm/i915: Introduce i915_vm_to_ggtt()

2016-04-26 Thread Chris Wilson
In a couple of places, we have an i915_address_space that we know is
really an i915_ggtt that we want to use. Create an inline helper to
convert from the i915_address_space subclass into its container.

Signed-off-by: Chris Wilson 
Cc: Joonas Lahtinen 
Cc: Tvrtko Ursulin 
Reviewed-by: Joonas Lahtinen 
Reviewed-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c 
b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 0d666b3f7e9b..4ddf2ed8501f 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -93,6 +93,13 @@
  *
  */
 
+static inline struct i915_ggtt *
+i915_vm_to_ggtt(struct i915_address_space *vm)
+{
+   GEM_BUG_ON(!i915_is_ggtt(vm));
+   return container_of(vm, struct i915_ggtt, base);
+}
+
 static int
 i915_get_ggtt_vma_pages(struct i915_vma *vma);
 
@@ -2358,7 +2365,7 @@ static void gen8_ggtt_insert_entries(struct 
i915_address_space *vm,
 enum i915_cache_level level, u32 unused)
 {
struct drm_i915_private *dev_priv = to_i915(vm->dev);
-   struct i915_ggtt *ggtt = &dev_priv->ggtt;
+   struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
unsigned first_entry = start >> PAGE_SHIFT;
gen8_pte_t __iomem *gtt_entries =
(gen8_pte_t __iomem *)ggtt->gsm + first_entry;
@@ -2436,7 +2443,7 @@ static void gen6_ggtt_insert_entries(struct 
i915_address_space *vm,
 enum i915_cache_level level, u32 flags)
 {
struct drm_i915_private *dev_priv = to_i915(vm->dev);
-   struct i915_ggtt *ggtt = &dev_priv->ggtt;
+   struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
unsigned first_entry = start >> PAGE_SHIFT;
gen6_pte_t __iomem *gtt_entries =
(gen6_pte_t __iomem *)ggtt->gsm + first_entry;
@@ -2480,7 +2487,7 @@ static void gen8_ggtt_clear_range(struct 
i915_address_space *vm,
  bool use_scratch)
 {
struct drm_i915_private *dev_priv = to_i915(vm->dev);
-   struct i915_ggtt *ggtt = &dev_priv->ggtt;
+   struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
unsigned first_entry = start >> PAGE_SHIFT;
unsigned num_entries = length >> PAGE_SHIFT;
gen8_pte_t scratch_pte, __iomem *gtt_base =
@@ -2512,7 +2519,7 @@ static void gen6_ggtt_clear_range(struct 
i915_address_space *vm,
  bool use_scratch)
 {
struct drm_i915_private *dev_priv = to_i915(vm->dev);
-   struct i915_ggtt *ggtt = &dev_priv->ggtt;
+   struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
unsigned first_entry = start >> PAGE_SHIFT;
unsigned num_entries = length >> PAGE_SHIFT;
gen6_pte_t scratch_pte, __iomem *gtt_base =
-- 
2.8.1

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


[Intel-gfx] [PATCH v6 03/25] io-mapping: Specify mapping size for io_mapping_map_wc()

2016-04-26 Thread Chris Wilson
The ioremap() hidden behind the io_mapping_map_wc() convenience helper
can be used for remapping multiple pages. Extend the helper so that
future callers can use it for larger ranges.

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Cc: Daniel Vetter 
Cc: Jani Nikula 
Cc: David Airlie 
Cc: Yishai Hadas 
Cc: Dan Williams 
Cc: Ingo Molnar 
Cc: "Peter Zijlstra (Intel)" 
Cc: David Hildenbrand 
Cc: Luis R. Rodriguez 
Cc: intel-gfx@lists.freedesktop.org
Cc: dri-de...@lists.freedesktop.org
Cc: net...@vger.kernel.org
Cc: linux-r...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Reviewed-by: Luis R. Rodriguez 
---
 drivers/gpu/drm/i915/intel_overlay.c|  3 ++-
 drivers/net/ethernet/mellanox/mlx4/pd.c |  4 +++-
 include/linux/io-mapping.h  | 10 +++---
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_overlay.c 
b/drivers/gpu/drm/i915/intel_overlay.c
index 06bcd6aee64f..8d5293644d05 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -198,7 +198,8 @@ intel_overlay_map_regs(struct intel_overlay *overlay)
regs = (struct overlay_registers __iomem 
*)overlay->reg_bo->phys_handle->vaddr;
else
regs = io_mapping_map_wc(ggtt->mappable,
-overlay->flip_addr);
+overlay->flip_addr,
+PAGE_SIZE);
 
return regs;
 }
diff --git a/drivers/net/ethernet/mellanox/mlx4/pd.c 
b/drivers/net/ethernet/mellanox/mlx4/pd.c
index b3cc3ab63799..6fc156a3918d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/pd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/pd.c
@@ -205,7 +205,9 @@ int mlx4_bf_alloc(struct mlx4_dev *dev, struct mlx4_bf *bf, 
int node)
goto free_uar;
}
 
-   uar->bf_map = io_mapping_map_wc(priv->bf_mapping, uar->index << 
PAGE_SHIFT);
+   uar->bf_map = io_mapping_map_wc(priv->bf_mapping,
+   uar->index << PAGE_SHIFT,
+   PAGE_SIZE);
if (!uar->bf_map) {
err = -ENOMEM;
goto unamp_uar;
diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h
index e399029b68c5..645ad06b5d52 100644
--- a/include/linux/io-mapping.h
+++ b/include/linux/io-mapping.h
@@ -100,14 +100,16 @@ io_mapping_unmap_atomic(void __iomem *vaddr)
 }
 
 static inline void __iomem *
-io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
+io_mapping_map_wc(struct io_mapping *mapping,
+ unsigned long offset,
+ unsigned long size)
 {
resource_size_t phys_addr;
 
BUG_ON(offset >= mapping->size);
phys_addr = mapping->base + offset;
 
-   return ioremap_wc(phys_addr, PAGE_SIZE);
+   return ioremap_wc(phys_addr, size);
 }
 
 static inline void
@@ -155,7 +157,9 @@ io_mapping_unmap_atomic(void __iomem *vaddr)
 
 /* Non-atomic map/unmap */
 static inline void __iomem *
-io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
+io_mapping_map_wc(struct io_mapping *mapping,
+ unsigned long offset,
+ unsigned long size)
 {
return ((char __force __iomem *) mapping) + offset;
 }
-- 
2.8.1

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


Re: [Intel-gfx] [PATCH 09/35] drm/gem: support BO freeing without dev->struct_mutex

2016-04-26 Thread Chris Wilson
On Tue, Apr 26, 2016 at 07:29:42PM +0200, Daniel Vetter wrote:
> Finally all the core gem and a lot of drivers are entirely free of
> dev->struct_mutex depencies, and we can start to have an entirely
> lockless unref path.
> 
> To make sure that no one who touches the core code accidentally breaks
> existing drivers which still require dev->struct_mutex I've made the
> might_lock check unconditional.
> 
> While at it de-inline the ref/unref functions, they've become a bit
> too big.
> 
> v2: Make it not leak like a sieve.
> 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/drm_gem.c | 64 
> ++-
>  include/drm/drmP.h| 12 -
>  include/drm/drm_gem.h | 45 ++---
>  3 files changed, 65 insertions(+), 56 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 25dac31eef37..8f2eff448bb5 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj)
>  }
>  EXPORT_SYMBOL(drm_gem_object_release);
>  
> -/**
> - * drm_gem_object_free - free a GEM object
> - * @kref: kref of the object to free
> - *
> - * Called after the last reference to the object has been lost.
> - * Must be called holding struct_ mutex
> - *
> - * Frees the object
> - */
> -void
> +static void
>  drm_gem_object_free(struct kref *kref)
>  {
>   struct drm_gem_object *obj =
> @@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
>  
>   WARN_ON(!mutex_is_locked(&dev->struct_mutex));
>  
> - if (dev->driver->gem_free_object != NULL)
> + if (dev->driver->gem_free_object_unlocked != NULL)
> + dev->driver->gem_free_object_unlocked(obj);
> + else if (dev->driver->gem_free_object != NULL)
>   dev->driver->gem_free_object(obj);
>  }
> -EXPORT_SYMBOL(drm_gem_object_free);
> +
> +/**
> + * drm_gem_object_unreference_unlocked - release a GEM BO reference
> + * @obj: GEM buffer object
> + *
> + * This releases a reference to @obj. Callers must not hold the
> + * dev->struct_mutex lock when calling this function.
> + */
> +void
> +drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
> +{

I have i915.ko in a state where we could use this as well. I would like
to have our inlines back though. I would add

static inline void
i915_gem_object_put(struct drm_i915_gem_object *obj)
{
kref_put(&obj->base.refcount, drm_gem_object_free);
}

Hmm, considering how simple that is, maybe I won't ask for

static inline void
__drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
{
BUG_ON(obj->dev->driver->gem_free_object == NULL);
kref_put(&obj->refcount, drm_gem_object_free);
}

after all!
-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 2/2] drm/i915: generate address mode bit from PPGTT instance

2016-04-26 Thread Wang, Zhi A
Hi Matthew:
Thanks for spending efforts on rebase! :) I'm sorry that we will drop this 
2 patches in the next round patch review. 

In the previous discussion, there were two options:

Option A. Unify GVT-g PPGTT shadow with i915 PPGTT routines, which needs these 
2 patches, then LRC submission routines could generate context descriptor 
according to the addressing space mode in i915_hw_ppgtt. (Daniel)

The reason this option is dropped because:
a. Different requirement. In i915, The caller of PPGTT routines mostly is 
VMA-oriented. It doesn't care about how the page table created. Usually i915 
will create the upper level of page table according to the wanted VMA. And 
GVT-g shadow is PTE-oriented, mostly it will populate the page table according 
to how guest modifies its PPGTT.

b. Different abstraction. GVT-g shadow is based on an unique-leveled page table 
manipulation design. E.g. both PML4/PDP/PDE population could use same 
functions, different with i915, which uses different functions to handle 
different PML4/PDP/PDE population. It hard to merge them together without big 
changes. We definitely want to prevent heavy modifications of i915, as that 
might cause regressions.

Option B. Modify the related functions in intel_lrc.c to update the PDP root 
pointers in each submission.
And the pros is we don't need to modify i915 PPGTT now. Definitely cons here is 
we need to modify LRC related routines. Chris suggested we could use 
ppgtt->pd_dirty_rings before, and the ppgtt->drity_pd_rings is highly combined 
with 32-bit page table routines. I think we might needs some modifications

The ideal option we are currently thinking is:

a. Issue LRIs to update PDPs in shadow ring buffer so that we don't need to 
modify PDP loading routines in intel_lrc.c
b. Add addressing mode bit in intel_context and make it configurable. 
Definitely i915 host context will configure this bit according to 
i915.enable_ppgtt. And GVT-g could configure it by guest requirements.

Thanks,
Zhi.

-Original Message-
From: Chris Wilson [mailto:ch...@chris-wilson.co.uk] 
Sent: Tuesday, April 26, 2016 8:56 AM
To: Auld, Matthew 
Cc: intel-gfx@lists.freedesktop.org; Wang, Zhi A ; Joonas 
Lahtinen 
Subject: Re: [PATCH 2/2] drm/i915: generate address mode bit from PPGTT instance

On Tue, Apr 26, 2016 at 04:17:52PM +0100, Matthew Auld wrote:
> From: "Wang, Zhi A" 
> 
> After the per-PPGTT address mode gets support, the LRC submission 
> should generate the address mode bit from PPGTT instance, instead of 
> the hard-coded system configuration.
> 
> v2:
> (Matthew Auld)
>   - rebase on latest -nightly
> 
> Cc: Chris Wilson 
> Cc: Joonas Lahtinen 
> Signed-off-by: Matthew Auld 
> Signed-off-by: Zhi Wang 
> ---
>  drivers/gpu/drm/i915/intel_lrc.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c 
> b/drivers/gpu/drm/i915/intel_lrc.c
> index 13cb1b3..17bd811 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -214,7 +214,7 @@ enum {
>   LEGACY_64B_CONTEXT
>  };
>  #define GEN8_CTX_ADDRESSING_MODE_SHIFT 3 -#define 
> GEN8_CTX_ADDRESSING_MODE(dev)  (USES_FULL_48BIT_PPGTT(dev) ?\
> +#define GEN8_CTX_ADDRESSING_MODE(ppgtt) (IS_48BIT_PPGTT(ppgtt) ? \
>   LEGACY_64B_CONTEXT :\
>   LEGACY_32B_CONTEXT)
>  enum {
> @@ -276,8 +276,6 @@ logical_ring_init_platform_invariants(struct 
> intel_engine_cs *engine)
>   (engine->id == VCS || engine->id == 
> VCS2);
>  
>   engine->ctx_desc_template = GEN8_CTX_VALID;
> - engine->ctx_desc_template |= GEN8_CTX_ADDRESSING_MODE(dev) <<
> -GEN8_CTX_ADDRESSING_MODE_SHIFT;
>   if (IS_GEN8(dev))
>   engine->ctx_desc_template |= GEN8_CTX_L3LLC_COHERENT;
>   engine->ctx_desc_template |= GEN8_CTX_PRIVILEGE; @@ -319,7 +317,9 @@ 
> intel_lr_context_descriptor_update(struct intel_context *ctx,
>   lrca = ctx->engine[engine->id].lrc_vma->node.start +
>  LRC_PPHWSP_PN * PAGE_SIZE;
>  
> - desc = engine->ctx_desc_template;  /* bits  
> 0-11 */
> + desc = engine->ctx_desc_template;  /* bits  0-11 */
> + desc |= GEN8_CTX_ADDRESSING_MODE(ctx->ppgtt) < + GEN8_CTX_ADDRESSING_MODE_SHIFT;

Would it not be simpler for us to use the GEN8_CTX_ADDRESSING_MODE() as our 
enum, then we would just do desc |= ctx->ppgtt->addressing_mode << 
GEN8_CTX_ADDRESSING_MODE_SHIFT;

And then we would have an enum already defined!
-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 v5 2/3] drm/i915/dsi: add support for gpio elements on CHV

2016-04-26 Thread Ville Syrjälä
On Tue, Apr 26, 2016 at 01:27:40PM +0300, Jani Nikula wrote:
> Add support for CHV gpio programming in DSI gpio elements.
> 
> v2: Overhaul macros according to Ville's review.
> 
> v3: Address Ville's review:
>  - swap E and SE gpio ranges
>  - add a note about max SE index
>  - use GPO, not HIZ
>  - swap cfg0 and cfg1
> 
> v4: fix port for dsi sequence versions 1 and 2
> 
> [Rewritten by Jani, based on earlier work by Yogesh and Deepak.]
> 
> Signed-off-by: Yogesh Mohan Marimuthu 
> Signed-off-by: Deepak M 
> Signed-off-by: Jani Nikula 

Reviewed-by: Ville Syrjälä 

> ---
>  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 70 
> ++
>  1 file changed, 70 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c 
> b/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
> index a1cc8533cff5..f122484bedfc 100644
> --- a/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
> +++ b/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
> @@ -95,6 +95,24 @@ static struct gpio_map vlv_gpio_table[] = {
>   { VLV_GPIO_NC_11_PANEL1_BKLTCTL },
>  };
>  
> +#define CHV_GPIO_IDX_START_N 0
> +#define CHV_GPIO_IDX_START_E 73
> +#define CHV_GPIO_IDX_START_SW100
> +#define CHV_GPIO_IDX_START_SE198
> +
> +#define CHV_VBT_MAX_PINS_PER_FMLY15
> +
> +#define CHV_GPIO_PAD_CFG0(f, i)  (0x4400 + (f) * 0x400 + (i) * 8)
> +#define  CHV_GPIO_GPIOEN (1 << 15)
> +#define  CHV_GPIO_GPIOCFG_GPIO   (0 << 8)
> +#define  CHV_GPIO_GPIOCFG_GPO(1 << 8)
> +#define  CHV_GPIO_GPIOCFG_GPI(2 << 8)
> +#define  CHV_GPIO_GPIOCFG_HIZ(3 << 8)
> +#define  CHV_GPIO_GPIOTXSTATE(state) ((!!(state)) << 1)
> +
> +#define CHV_GPIO_PAD_CFG1(f, i)  (0x4400 + (f) * 0x400 + (i) * 8 
> + 4)
> +#define  CHV_GPIO_CFGLOCK(1 << 31)
> +
>  static inline enum port intel_dsi_seq_port_to_port(u8 port)
>  {
>   return port ? PORT_C : PORT_A;
> @@ -232,6 +250,56 @@ static void vlv_exec_gpio(struct drm_i915_private 
> *dev_priv,
>   mutex_unlock(&dev_priv->sb_lock);
>  }
>  
> +static void chv_exec_gpio(struct drm_i915_private *dev_priv,
> +   u8 gpio_source, u8 gpio_index, bool value)
> +{
> + u16 cfg0, cfg1;
> + u16 family_num;
> + u8 port;
> +
> + if (dev_priv->vbt.dsi.seq_version >= 3) {
> + if (gpio_index >= CHV_GPIO_IDX_START_SE) {
> + /* XXX: it's unclear whether 255->57 is part of SE. */
> + gpio_index -= CHV_GPIO_IDX_START_SE;
> + port = CHV_IOSF_PORT_GPIO_SE;
> + } else if (gpio_index >= CHV_GPIO_IDX_START_SW) {
> + gpio_index -= CHV_GPIO_IDX_START_SW;
> + port = CHV_IOSF_PORT_GPIO_SW;
> + } else if (gpio_index >= CHV_GPIO_IDX_START_E) {
> + gpio_index -= CHV_GPIO_IDX_START_E;
> + port = CHV_IOSF_PORT_GPIO_E;
> + } else {
> + port = CHV_IOSF_PORT_GPIO_N;
> + }
> + } else {
> + /* XXX: The spec is unclear about CHV GPIO on seq v2 */
> + if (gpio_source != 0) {
> + DRM_DEBUG_KMS("unknown gpio source %u\n", gpio_source);
> + return;
> + }
> +
> + if (gpio_index >= CHV_GPIO_IDX_START_E) {
> + DRM_DEBUG_KMS("invalid gpio index %u for GPIO N\n",
> +   gpio_index);
> + return;
> + }
> +
> + port = CHV_IOSF_PORT_GPIO_N;
> + }
> +
> + family_num = gpio_index / CHV_VBT_MAX_PINS_PER_FMLY;
> + gpio_index = gpio_index % CHV_VBT_MAX_PINS_PER_FMLY;
> +
> + cfg0 = CHV_GPIO_PAD_CFG0(family_num, gpio_index);
> + cfg1 = CHV_GPIO_PAD_CFG1(family_num, gpio_index);
> +
> + mutex_lock(&dev_priv->sb_lock);
> + vlv_iosf_sb_write(dev_priv, port, cfg1, 0);
> + vlv_iosf_sb_write(dev_priv, port, cfg0,
> +   CHV_GPIO_GPIOCFG_GPO | CHV_GPIO_GPIOTXSTATE(value));
> + mutex_unlock(&dev_priv->sb_lock);
> +}
> +
>  static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
>  {
>   struct drm_device *dev = intel_dsi->base.base.dev;
> @@ -255,6 +323,8 @@ static const u8 *mipi_exec_gpio(struct intel_dsi 
> *intel_dsi, const u8 *data)
>  
>   if (IS_VALLEYVIEW(dev_priv))
>   vlv_exec_gpio(dev_priv, gpio_source, gpio_index, value);
> + else if (IS_CHERRYVIEW(dev_priv))
> + chv_exec_gpio(dev_priv, gpio_source, gpio_index, value);
>   else
>   DRM_DEBUG_KMS("GPIO element not supported on this platform\n");
>  
> -- 
> 2.1.4

-- 
Ville Syrjälä
Intel OTC
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v5 1/3] drm/i915/dsi: add support for sequence block v3 gpio for VLV

2016-04-26 Thread Ville Syrjälä
On Tue, Apr 26, 2016 at 01:27:39PM +0300, Jani Nikula wrote:
> Only support NC GPIOs for now, and assume the vlv gpio table only has NC
> GPIOs for now.
> 
> Signed-off-by: Jani Nikula 
> ---
>  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c 
> b/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
> index c7281c391d0f..a1cc8533cff5 100644
> --- a/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
> +++ b/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
> @@ -203,8 +203,8 @@ static void vlv_exec_gpio(struct drm_i915_private 
> *dev_priv,
>   map = &vlv_gpio_table[gpio_index];
>  
>   if (dev_priv->vbt.dsi.seq_version >= 3) {
> - DRM_DEBUG_KMS("GPIO element v3 not supported\n");
> - return;
> + /* XXX: this assumes vlv_gpio_table only has NC GPIOs. */
> + port = IOSF_PORT_GPIO_NC;

NC GPIOs start from index 0, and we accept them up to ARRAY_SIZE(vlv_gpio_table)
which only holds NC GPIOs as the comment says. Since SC GPIOs would come after
NC GPIOS in index, they would thus have been rejected already by the earlier
check. Makes sense, but I had to actually read the code to see it.

Reviewed-by: Ville Syrjälä 

>   } else {
>   if (gpio_source == 0) {
>   port = IOSF_PORT_GPIO_NC;
> -- 
> 2.1.4

-- 
Ville Syrjälä
Intel OTC
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v5 3/3] drm/i915/bxt: add bxt dsi gpio element support

2016-04-26 Thread Ville Syrjälä
On Tue, Apr 26, 2016 at 01:27:41PM +0300, Jani Nikula wrote:
> Request the GPIO by index through the consumer API. For now, use a quick
> hack to store the already requested ones, simply because I have no idea
> whether this actually works or not, and I have no way to test it.
> 
> Signed-off-by: Jani Nikula 
> ---
>  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 28 +++-
>  1 file changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c 
> b/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
> index f122484bedfc..aefcc19968e0 100644
> --- a/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
> +++ b/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
> @@ -29,6 +29,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -300,6 +301,31 @@ static void chv_exec_gpio(struct drm_i915_private 
> *dev_priv,
>   mutex_unlock(&dev_priv->sb_lock);
>  }
>  
> +static void bxt_exec_gpio(struct drm_i915_private *dev_priv,
> +   u8 gpio_source, u8 gpio_index, bool value)
> +{
> + /* XXX: this table is a quick ugly hack. */
> + static struct gpio_desc *bxt_gpio_table[U8_MAX + 1];
> + struct gpio_desc *gpio_desc = bxt_gpio_table[gpio_index];
> +
> + if (!gpio_desc) {
> + gpio_desc = devm_gpiod_get_index(dev_priv->dev->dev,
> +  NULL, gpio_index,

If I'm reading the spec right, I think we should be passing the byte 0
(GPIO Index) here, not byte 1 (GPIO number). I could be wrong though.

> +  value ? GPIOD_OUT_LOW :
> +  GPIOD_OUT_HIGH);
> +
> + if (IS_ERR_OR_NULL(gpio_desc)) {
> + DRM_ERROR("GPIO index %u request failed (%ld)\n",
> +   gpio_index, PTR_ERR(gpio_desc));
> + return;
> + }
> +
> + bxt_gpio_table[gpio_index] = gpio_desc;
> + }
> +
> + gpiod_set_value(gpio_desc, value);
> +}
> +
>  static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
>  {
>   struct drm_device *dev = intel_dsi->base.base.dev;
> @@ -326,7 +352,7 @@ static const u8 *mipi_exec_gpio(struct intel_dsi 
> *intel_dsi, const u8 *data)
>   else if (IS_CHERRYVIEW(dev_priv))
>   chv_exec_gpio(dev_priv, gpio_source, gpio_index, value);
>   else
> - DRM_DEBUG_KMS("GPIO element not supported on this platform\n");
> + bxt_exec_gpio(dev_priv, gpio_source, gpio_index, value);
>  
>   return data;
>  }
> -- 
> 2.1.4

-- 
Ville Syrjälä
Intel OTC
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v2 2/2] drm/i915/bxt: Fix inadvertent CPU snooping due to incorrect MOCS config

2016-04-26 Thread Ville Syrjälä
On Tue, Apr 26, 2016 at 04:30:05PM +0200, Daniel Vetter wrote:
> On Tue, Apr 26, 2016 at 05:26:43PM +0300, Eero Tamminen wrote:
> > Hi,
> > 
> > On 26.04.2016 16:23, Chris Wilson wrote:
> > >On Tue, Apr 26, 2016 at 04:17:55PM +0300, Imre Deak wrote:
> > >>On ti, 2016-04-26 at 13:57 +0100, Chris Wilson wrote:
> > >>>On Tue, Apr 26, 2016 at 03:44:22PM +0300, Imre Deak wrote:
> > Setting a write-back cache policy in the MOCS entry definition also
> > implies snooping, which has a considerable overhead. This is
> > unexpected for a few reasons:
> > >>>
> > >>>If it is snooping, then I don't see why it is undesirable to have it
> > >>>available in a mocs setting. If it is bogus and the bit is undefined,
> > >>>then by all means remove it.
> > >>
> > >>None of these entries are used alone for coherent surfaces. For that
> > >>the application would have to use entry index#1 or #2 _and_ call the
> > >>set caching IOCTL to set the corresponding buffer to be cached.
> > >
> > >No, the application doesn't. There are sufficent interfaces exposed that
> > >userspace can bypass the kernel if it so desired.
> > >
> > >>The
> > >>problem is that without setting the buffer to be cacheable the
> > >>expectation is that we won't be snooping and incur the corresponding
> > >>overhead. This is what this patch addresses.
> > >
> > >Not true.
> > >
> > >>The bit is also bogus, if we wanted snooping via MOCS we'd use the
> > >>dedicated HW flag for that.
> > >
> > >But you keep saying this bit *enables* snooping. So either it does or it
> > >doesn't.
> > >
> > >>If we wanted to have a snooping MOCS entry we should add that
> > >>separately (as a forth entry), but we'd need this change as a fix for
> > >>current users.
> > >
> > >The current users who are getting what they request but don't know what
> > >they were requesting?
> > 
> > What this kernel ABI (index entry #2) has been agreed & documented to
> > provide?
> > 
> > I thought this entry is supposed to replace the writeback LLC/eLLC cache
> > MOCS setting Mesa is using on (e.g. BDW) to speed up accesses to a memory
> > area which it knows always to be accessed so that it can be cached.
> > 
> > If app runs on HW where LLC/eLLC is missing, giving the app extra slowdown
> > instead of potential speedup sounds like failed HW abstraction. :-)
> 
> Well mesa needs to know llc vs. !llc anyway to not totally suck, and
> defining entry #2 as "coherent, always" makes sense. I thought entry 0 was
> the reaonable default aka pte passthrough and hence managed by kernel?

Nope, we fscked that up somewhat, and entry 1 is the PTE one :( So if
userspace forgets to set MOCS on gen9 it won't get the behaviour it
would have gotten on previous gens.

> 
> If mesa asks for nonsense, the kernel is happy to oblige.

We never really defined what entry 2 actually means: coherent or sane
performance. Mesa has, rightfully IMO, made the assumption that it means
the latter since we never set out to define any MOCS entries with
coherency in mind. And seeing that it's already out in the wild, I think
it's better to respect it. If we change it now we would just make it
more painful for people when they get their hands on the hardware.

I think what we should do is define what the MOCS indexes mean in some
uapi header. Then there would be no ambiguity.

-- 
Ville Syrjälä
Intel OTC
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [1/2] drm/i915: Support per-PPGTT address space mode

2016-04-26 Thread Patchwork
== Series Details ==

Series: series starting with [1/2] drm/i915: Support per-PPGTT address space 
mode
URL   : https://patchwork.freedesktop.org/series/6347/
State : failure

== Summary ==

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

Test gem_exec_suspend:
Subgroup basic-s3:
pass   -> INCOMPLETE (hsw-gt2)
Test kms_pipe_crc_basic:
Subgroup hang-read-crc-pipe-a:
pass   -> DMESG-WARN (snb-dellxps)
Subgroup hang-read-crc-pipe-b:
incomplete -> PASS   (snb-dellxps)

bdw-nuci7total:200  pass:188  dwarn:0   dfail:0   fail:0   skip:12 
bdw-ultratotal:200  pass:175  dwarn:0   dfail:0   fail:0   skip:25 
bsw-nuc-2total:199  pass:158  dwarn:0   dfail:0   fail:0   skip:41 
byt-nuc  total:199  pass:158  dwarn:0   dfail:0   fail:0   skip:41 
hsw-brixbox  total:200  pass:174  dwarn:0   dfail:0   fail:0   skip:26 
hsw-gt2  total:93   pass:79   dwarn:0   dfail:0   fail:1   skip:12 
ivb-t430stotal:200  pass:169  dwarn:0   dfail:0   fail:0   skip:31 
skl-i7k-2total:200  pass:173  dwarn:0   dfail:0   fail:0   skip:27 
skl-nuci5total:200  pass:189  dwarn:0   dfail:0   fail:0   skip:11 
snb-dellxps  total:200  pass:157  dwarn:1   dfail:0   fail:0   skip:42 
snb-x220ttotal:200  pass:158  dwarn:0   dfail:0   fail:1   skip:41 

Results at /archive/results/CI_IGT_test/Patchwork_2077/

e005db1cb2c60d18abe837ac683d8993ea77b239 drm-intel-nightly: 
2016y-04m-26d-12h-51m-57s UTC integration manifest
7857fe0 drm/i915: generate address mode bit from PPGTT instance
d7432f1 drm/i915: Support per-PPGTT address space mode

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


[Intel-gfx] [PATCH 09/35] drm/gem: support BO freeing without dev->struct_mutex

2016-04-26 Thread Daniel Vetter
Finally all the core gem and a lot of drivers are entirely free of
dev->struct_mutex depencies, and we can start to have an entirely
lockless unref path.

To make sure that no one who touches the core code accidentally breaks
existing drivers which still require dev->struct_mutex I've made the
might_lock check unconditional.

While at it de-inline the ref/unref functions, they've become a bit
too big.

v2: Make it not leak like a sieve.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_gem.c | 64 ++-
 include/drm/drmP.h| 12 -
 include/drm/drm_gem.h | 45 ++---
 3 files changed, 65 insertions(+), 56 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 25dac31eef37..8f2eff448bb5 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -788,16 +788,7 @@ drm_gem_object_release(struct drm_gem_object *obj)
 }
 EXPORT_SYMBOL(drm_gem_object_release);
 
-/**
- * drm_gem_object_free - free a GEM object
- * @kref: kref of the object to free
- *
- * Called after the last reference to the object has been lost.
- * Must be called holding struct_ mutex
- *
- * Frees the object
- */
-void
+static void
 drm_gem_object_free(struct kref *kref)
 {
struct drm_gem_object *obj =
@@ -806,10 +797,59 @@ drm_gem_object_free(struct kref *kref)
 
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
 
-   if (dev->driver->gem_free_object != NULL)
+   if (dev->driver->gem_free_object_unlocked != NULL)
+   dev->driver->gem_free_object_unlocked(obj);
+   else if (dev->driver->gem_free_object != NULL)
dev->driver->gem_free_object(obj);
 }
-EXPORT_SYMBOL(drm_gem_object_free);
+
+/**
+ * drm_gem_object_unreference_unlocked - release a GEM BO reference
+ * @obj: GEM buffer object
+ *
+ * This releases a reference to @obj. Callers must not hold the
+ * dev->struct_mutex lock when calling this function.
+ */
+void
+drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
+{
+   struct drm_device *dev;
+
+   if (!obj)
+   return;
+
+   dev = obj->dev;
+   might_lock(&dev->struct_mutex);
+
+   if (dev->driver->gem_free_object != NULL)
+   kref_put(&obj->refcount, drm_gem_object_free);
+   else if (kref_put_mutex(&obj->refcount, drm_gem_object_free,
+   &dev->struct_mutex))
+   mutex_unlock(&dev->struct_mutex);
+}
+EXPORT_SYMBOL(drm_gem_object_unreference_unlocked);
+
+/**
+ * drm_gem_object_unreference - release a GEM BO reference
+ * @obj: GEM buffer object
+ *
+ * This releases a reference to @obj. Callers must hold the dev->struct_mutex
+ * lock when calling this function, even when the driver doesn't use
+ * dev->struct_mutex for anything.
+ *
+ * For drivers not encumbered with legacy locking use
+ * drm_gem_object_unreference_unlocked() instead.
+ */
+void
+drm_gem_object_unreference(struct drm_gem_object *obj)
+{
+   if (obj != NULL) {
+   WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
+
+   kref_put(&obj->refcount, drm_gem_object_free);
+   }
+}
+EXPORT_SYMBOL(drm_gem_object_unreference);
 
 /**
  * drm_gem_vm_open - vma->ops->open implementation for GEM
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c81dd2250fc6..7e30b3d2b25c 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -583,9 +583,19 @@ struct drm_driver {
 * Driver-specific constructor for drm_gem_objects, to set up
 * obj->driver_private.
 *
-* Returns 0 on success.
+* This is deprecated and should not be used by new drivers. Use
+* @gem_free_object_unlocked instead.
 */
void (*gem_free_object) (struct drm_gem_object *obj);
+
+   /**
+* Driver-specific constructor for drm_gem_objects, to set up
+* obj->driver_private. This is for drivers which are not encumbered
+* with dev->struct_mutex legacy locking schemes. Use this hook instead
+* of @gem_free_object.
+*/
+   void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
+
int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
 
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index 0b3e11ab8757..ae1c7f18eec0 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -175,7 +175,6 @@ struct drm_gem_object {
 };
 
 void drm_gem_object_release(struct drm_gem_object *obj);
-void drm_gem_object_free(struct kref *kref);
 int drm_gem_object_init(struct drm_device *dev,
struct drm_gem_object *obj, size_t size);
 void drm_gem_private_object_init(struct drm_device *dev,
@@ -199,48 +198,8 @@ drm_gem_object_reference(struct drm_gem_object *obj)
kref_get(&obj->refcount);
 }
 
-/**
- * drm_gem_object_unreference - release a GEM BO refe

[Intel-gfx] [PATCH 26/35] drm/shmob: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/shmobile/shmob_drm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c 
b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index 7700ff172079..ee79264b5b6a 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -264,7 +264,7 @@ static struct drm_driver shmob_drm_driver = {
.get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank  = shmob_drm_enable_vblank,
.disable_vblank = shmob_drm_disable_vblank,
-   .gem_free_object= drm_gem_cma_free_object,
+   .gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-- 
2.8.1

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


[Intel-gfx] [PATCH 30/35] drm/vc4: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Eric Anholt 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/vc4/vc4_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index b7d2ff0e6e1f..13f704de39e1 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -98,7 +98,7 @@ static struct drm_driver vc4_drm_driver = {
 #endif
 
.gem_create_object = vc4_create_object,
-   .gem_free_object = vc4_free_object,
+   .gem_free_object_unlocked = vc4_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
 
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-- 
2.8.1

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


[Intel-gfx] [PATCH 35/35] drm/rockchip: Use cma gem vm ops

2016-04-26 Thread Daniel Vetter
No need to reinvent this little wheel.

Cc: Mark Yao 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 903202224057..4484d5a53d89 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -292,11 +292,6 @@ static const struct file_operations 
rockchip_drm_driver_fops = {
.release = drm_release,
 };
 
-const struct vm_operations_struct rockchip_drm_vm_ops = {
-   .open = drm_gem_vm_open,
-   .close = drm_gem_vm_close,
-};
-
 static struct drm_driver rockchip_drm_driver = {
.driver_features= DRIVER_MODESET | DRIVER_GEM |
  DRIVER_PRIME | DRIVER_ATOMIC,
@@ -307,7 +302,7 @@ static struct drm_driver rockchip_drm_driver = {
.get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank  = rockchip_drm_crtc_enable_vblank,
.disable_vblank = rockchip_drm_crtc_disable_vblank,
-   .gem_vm_ops = &rockchip_drm_vm_ops,
+   .gem_vm_ops = &drm_gem_cma_vm_ops,
.gem_free_object_unlocked = rockchip_gem_free_object,
.dumb_create= rockchip_gem_dumb_create,
.dumb_map_offset= rockchip_gem_dumb_map_offset,
-- 
2.8.1

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


[Intel-gfx] [PATCH 27/35] drm/tegra: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Thierry Reding 
Cc: Terje Bergström 
Cc: linux-te...@vger.kernel.org
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/tegra/drm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 2be88eb0cb83..3d9241482f81 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -932,7 +932,7 @@ static struct drm_driver tegra_drm_driver = {
.debugfs_cleanup = tegra_debugfs_cleanup,
 #endif
 
-   .gem_free_object = tegra_bo_free_object,
+   .gem_free_object_unlocked = tegra_bo_free_object,
.gem_vm_ops = &tegra_bo_vm_ops,
 
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-- 
2.8.1

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


[Intel-gfx] [PATCH 28/35] drm/tilcdc: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Tomi Valkeinen 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 709bc903524d..308e197908fc 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -549,7 +549,7 @@ static struct drm_driver tilcdc_driver = {
.get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank  = tilcdc_enable_vblank,
.disable_vblank = tilcdc_disable_vblank,
-   .gem_free_object= drm_gem_cma_free_object,
+   .gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create= drm_gem_cma_dumb_create,
.dumb_map_offset= drm_gem_cma_dumb_map_offset,
-- 
2.8.1

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


[Intel-gfx] [PATCH 33/35] drm: sti: remove useless call to dev->struct_mutex

2016-04-26 Thread Daniel Vetter
From: Benjamin Gaignard 

No need to protect debugfs functions with dev->struct_mutex

Signed-off-by: Benjamin Gaignard 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/sti/sti_cursor.c |  7 ---
 drivers/gpu/drm/sti/sti_drv.c|  6 --
 drivers/gpu/drm/sti/sti_dvo.c|  7 ---
 drivers/gpu/drm/sti/sti_gdp.c| 14 --
 drivers/gpu/drm/sti/sti_hda.c|  7 ---
 drivers/gpu/drm/sti/sti_hdmi.c   |  7 ---
 drivers/gpu/drm/sti/sti_hqvdp.c  |  7 ---
 drivers/gpu/drm/sti/sti_mixer.c  |  7 ---
 drivers/gpu/drm/sti/sti_tvout.c  |  7 ---
 drivers/gpu/drm/sti/sti_vid.c|  7 ---
 10 files changed, 76 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c
index 3abb400151ac..e6ee4c526665 100644
--- a/drivers/gpu/drm/sti/sti_cursor.c
+++ b/drivers/gpu/drm/sti/sti_cursor.c
@@ -103,12 +103,6 @@ static int cursor_dbg_show(struct seq_file *s, void *data)
 {
struct drm_info_node *node = s->private;
struct sti_cursor *cursor = (struct sti_cursor *)node->info_ent->data;
-   struct drm_device *dev = node->minor->dev;
-   int ret;
-
-   ret = mutex_lock_interruptible(&dev->struct_mutex);
-   if (ret)
-   return ret;
 
seq_printf(s, "%s: (vaddr = 0x%p)",
   sti_plane_to_str(&cursor->plane), cursor->regs);
@@ -127,7 +121,6 @@ static int cursor_dbg_show(struct seq_file *s, void *data)
DBGFS_DUMP(CUR_AWE);
seq_puts(s, "\n");
 
-   mutex_unlock(&dev->struct_mutex);
return 0;
 }
 
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 6bd6abaa5a70..a8eece20b6b4 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -72,11 +72,6 @@ static int sti_drm_fps_dbg_show(struct seq_file *s, void 
*data)
struct drm_info_node *node = s->private;
struct drm_device *dev = node->minor->dev;
struct drm_plane *p;
-   int ret;
-
-   ret = mutex_lock_interruptible(&dev->struct_mutex);
-   if (ret)
-   return ret;
 
list_for_each_entry(p, &dev->mode_config.plane_list, head) {
struct sti_plane *plane = to_sti_plane(p);
@@ -86,7 +81,6 @@ static int sti_drm_fps_dbg_show(struct seq_file *s, void 
*data)
   plane->fps_info.fips_str);
}
 
-   mutex_unlock(&dev->struct_mutex);
return 0;
 }
 
diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
index 25f76632002c..d439128e6309 100644
--- a/drivers/gpu/drm/sti/sti_dvo.c
+++ b/drivers/gpu/drm/sti/sti_dvo.c
@@ -177,12 +177,6 @@ static int dvo_dbg_show(struct seq_file *s, void *data)
 {
struct drm_info_node *node = s->private;
struct sti_dvo *dvo = (struct sti_dvo *)node->info_ent->data;
-   struct drm_device *dev = node->minor->dev;
-   int ret;
-
-   ret = mutex_lock_interruptible(&dev->struct_mutex);
-   if (ret)
-   return ret;
 
seq_printf(s, "DVO: (vaddr = 0x%p)", dvo->regs);
DBGFS_DUMP(DVO_AWG_DIGSYNC_CTRL);
@@ -193,7 +187,6 @@ static int dvo_dbg_show(struct seq_file *s, void *data)
dvo_dbg_awg_microcode(s, dvo->regs + DVO_DIGSYNC_INSTR_I);
seq_puts(s, "\n");
 
-   mutex_unlock(&dev->struct_mutex);
return 0;
 }
 
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
index ff3d3e7e7704..3d098f1ab919 100644
--- a/drivers/gpu/drm/sti/sti_gdp.c
+++ b/drivers/gpu/drm/sti/sti_gdp.c
@@ -207,14 +207,8 @@ static int gdp_dbg_show(struct seq_file *s, void *data)
 {
struct drm_info_node *node = s->private;
struct sti_gdp *gdp = (struct sti_gdp *)node->info_ent->data;
-   struct drm_device *dev = node->minor->dev;
struct drm_plane *drm_plane = &gdp->plane.drm_plane;
struct drm_crtc *crtc = drm_plane->crtc;
-   int ret;
-
-   ret = mutex_lock_interruptible(&dev->struct_mutex);
-   if (ret)
-   return ret;
 
seq_printf(s, "%s: (vaddr = 0x%p)",
   sti_plane_to_str(&gdp->plane), gdp->regs);
@@ -247,7 +241,6 @@ static int gdp_dbg_show(struct seq_file *s, void *data)
seq_printf(s, "  Connected to DRM CRTC #%d (%s)\n",
   crtc->base.id, sti_mixer_to_str(to_sti_mixer(crtc)));
 
-   mutex_unlock(&dev->struct_mutex);
return 0;
 }
 
@@ -278,13 +271,7 @@ static int gdp_node_dbg_show(struct seq_file *s, void *arg)
 {
struct drm_info_node *node = s->private;
struct sti_gdp *gdp = (struct sti_gdp *)node->info_ent->data;
-   struct drm_device *dev = node->minor->dev;
unsigned int b;
-   int ret;
-
-   ret = mutex_lock_interruptible(&dev->struct_mutex);
-   if (ret)
-   return ret;
 
for (b = 0; b < GDP_NODE_NB_BANK; b++) {
seq_printf(s, "\n%s[%d].top", sti_plane_to_str(&gdp->plane), b);
@@ -293,7 +280,6 @@ static int gdp_node_dbg_show(struct seq

[Intel-gfx] [PATCH 20/35] drm/mga200g: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Dave Airlie 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/mgag200/mgag200_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c 
b/drivers/gpu/drm/mgag200/mgag200_drv.c
index ebb470ff7200..2b4b125eebc3 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -101,7 +101,7 @@ static struct drm_driver driver = {
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,
 
-   .gem_free_object = mgag200_gem_free_object,
+   .gem_free_object_unlocked = mgag200_gem_free_object,
.dumb_create = mgag200_dumb_create,
.dumb_map_offset = mgag200_dumb_mmap_offset,
.dumb_destroy = drm_gem_dumb_destroy,
-- 
2.8.1

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


[Intel-gfx] [PATCH 32/35] drm/virtio: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Gerd Hoffmann 
Cc: David Airlie 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/virtio/virtgpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c 
b/drivers/gpu/drm/virtio/virtgpu_drv.c
index 3cc7afa77a35..5820b7020ae5 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
@@ -143,7 +143,7 @@ static struct drm_driver driver = {
.gem_prime_vunmap = virtgpu_gem_prime_vunmap,
.gem_prime_mmap = virtgpu_gem_prime_mmap,
 
-   .gem_free_object = virtio_gpu_gem_free_object,
+   .gem_free_object_unlocked = virtio_gpu_gem_free_object,
.gem_open_object = virtio_gpu_gem_object_open,
.gem_close_object = virtio_gpu_gem_object_close,
.fops = &virtio_gpu_driver_fops,
-- 
2.8.1

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


[Intel-gfx] [PATCH 24/35] drm/rcar-du: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index fb9242d27883..48ec4b6e8b26 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -217,7 +217,7 @@ static struct drm_driver rcar_du_driver = {
.get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank  = rcar_du_enable_vblank,
.disable_vblank = rcar_du_disable_vblank,
-   .gem_free_object= drm_gem_cma_free_object,
+   .gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-- 
2.8.1

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


[Intel-gfx] [PATCH 29/35] drm/vc4: Use drm_gem_object_unreference_unlocked

2016-04-26 Thread Daniel Vetter
Since my last struct_mutex crusade someone escaped!

This already has the advantage that for the common case when someone
else holds a ref the unref won't even acquire dev->struct_mutex. And
I'm working on code to allow drivers to completely opt-out of any and
all dev->struct_mutex usage, but that only works if they use the
_unlocked variants everywhere.

v2: drop comment too.

Cc: Eric Anholt 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/vc4/vc4_gem.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
index 8d4384f8b78d..1f6711a98f5d 100644
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -53,10 +53,8 @@ vc4_free_hang_state(struct drm_device *dev, struct 
vc4_hang_state *state)
 {
unsigned int i;
 
-   mutex_lock(&dev->struct_mutex);
for (i = 0; i < state->user_state.bo_count; i++)
-   drm_gem_object_unreference(state->bo[i]);
-   mutex_unlock(&dev->struct_mutex);
+   drm_gem_object_unreference_unlocked(state->bo[i]);
 
kfree(state);
 }
@@ -687,11 +685,9 @@ vc4_complete_exec(struct drm_device *dev, struct 
vc4_exec_info *exec)
struct vc4_dev *vc4 = to_vc4_dev(dev);
unsigned i;
 
-   /* Need the struct lock for drm_gem_object_unreference(). */
-   mutex_lock(&dev->struct_mutex);
if (exec->bo) {
for (i = 0; i < exec->bo_count; i++)
-   drm_gem_object_unreference(&exec->bo[i]->base);
+   drm_gem_object_unreference_unlocked(&exec->bo[i]->base);
kfree(exec->bo);
}
 
@@ -699,9 +695,8 @@ vc4_complete_exec(struct drm_device *dev, struct 
vc4_exec_info *exec)
struct vc4_bo *bo = list_first_entry(&exec->unref_list,
 struct vc4_bo, unref_head);
list_del(&bo->unref_head);
-   drm_gem_object_unreference(&bo->base.base);
+   drm_gem_object_unreference_unlocked(&bo->base.base);
}
-   mutex_unlock(&dev->struct_mutex);
 
mutex_lock(&vc4->power_lock);
if (--vc4->power_refcount == 0)
-- 
2.8.1

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


[Intel-gfx] [PATCH 25/35] drm/rockchip: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Mark Yao 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index f556a8f4fde6..903202224057 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -308,7 +308,7 @@ static struct drm_driver rockchip_drm_driver = {
.enable_vblank  = rockchip_drm_crtc_enable_vblank,
.disable_vblank = rockchip_drm_crtc_disable_vblank,
.gem_vm_ops = &rockchip_drm_vm_ops,
-   .gem_free_object= rockchip_gem_free_object,
+   .gem_free_object_unlocked = rockchip_gem_free_object,
.dumb_create= rockchip_gem_dumb_create,
.dumb_map_offset= rockchip_gem_dumb_map_offset,
.dumb_destroy   = drm_gem_dumb_destroy,
-- 
2.8.1

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


[Intel-gfx] [PATCH 15/35] drm/cirrus: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Dave Airlie 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/cirrus/cirrus_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c 
b/drivers/gpu/drm/cirrus/cirrus_drv.c
index dc83f69da6f1..b05f7eae32ce 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -142,7 +142,7 @@ static struct drm_driver driver = {
.major = DRIVER_MAJOR,
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,
-   .gem_free_object = cirrus_gem_free_object,
+   .gem_free_object_unlocked = cirrus_gem_free_object,
.dumb_create = cirrus_dumb_create,
.dumb_map_offset = cirrus_dumb_mmap_offset,
.dumb_destroy = drm_gem_dumb_destroy,
-- 
2.8.1

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


[Intel-gfx] [PATCH 21/35] drm/nouveau: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Ben Skeggs 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index db5c7d0cc25c..3a4af87fba0f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -970,7 +970,7 @@ driver_stub = {
.gem_prime_vmap = nouveau_gem_prime_vmap,
.gem_prime_vunmap = nouveau_gem_prime_vunmap,
 
-   .gem_free_object = nouveau_gem_object_del,
+   .gem_free_object_unlocked = nouveau_gem_object_del,
.gem_open_object = nouveau_gem_object_open,
.gem_close_object = nouveau_gem_object_close,
 
-- 
2.8.1

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


[Intel-gfx] [PATCH 23/35] drm/radeon: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Alex Deucher 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/radeon/radeon_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index 5d44ed0d104a..b9f74e68527e 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -525,7 +525,7 @@ static struct drm_driver kms_driver = {
.irq_uninstall = radeon_driver_irq_uninstall_kms,
.irq_handler = radeon_driver_irq_handler_kms,
.ioctls = radeon_ioctls_kms,
-   .gem_free_object = radeon_gem_object_free,
+   .gem_free_object_unlocked = radeon_gem_object_free,
.gem_open_object = radeon_gem_object_open,
.gem_close_object = radeon_gem_object_close,
.dumb_create = radeon_mode_dumb_create,
-- 
2.8.1

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


[Intel-gfx] [PATCH 34/35] drm/virtio: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
With Benjanim's patch to remove the dev->struct_mutex cargo cult the
sti driver is now also entirely legacy locking free. Let's convert it
too.

Cc: Benjamin Gaignard 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/sti/sti_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index a8eece20b6b4..a436264eab6b 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -304,7 +304,7 @@ static struct drm_driver sti_driver = {
.driver_features = DRIVER_HAVE_IRQ | DRIVER_MODESET |
DRIVER_GEM | DRIVER_PRIME | DRIVER_ATOMIC,
.load = sti_load,
-   .gem_free_object = drm_gem_cma_free_object,
+   .gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create = drm_gem_cma_dumb_create,
.dumb_map_offset = drm_gem_cma_dumb_map_offset,
-- 
2.8.1

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


[Intel-gfx] [PATCH 17/35] drm/exynos: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Inki Dae 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 5344940c8a07..f534ed62065e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -418,7 +418,7 @@ static struct drm_driver exynos_drm_driver = {
.get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank  = exynos_drm_crtc_enable_vblank,
.disable_vblank = exynos_drm_crtc_disable_vblank,
-   .gem_free_object= exynos_drm_gem_free_object,
+   .gem_free_object_unlocked = exynos_drm_gem_free_object,
.gem_vm_ops = &exynos_drm_gem_vm_ops,
.dumb_create= exynos_drm_gem_dumb_create,
.dumb_map_offset= exynos_drm_gem_dumb_map_offset,
-- 
2.8.1

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


[Intel-gfx] [PATCH 31/35] drm/vgem: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: seanp...@chromium.org
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/vgem/vgem_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
index d61a547fa3c9..1228b40691fe 100644
--- a/drivers/gpu/drm/vgem/vgem_drv.c
+++ b/drivers/gpu/drm/vgem/vgem_drv.c
@@ -235,7 +235,7 @@ static const struct file_operations vgem_driver_fops = {
 
 static struct drm_driver vgem_driver = {
.driver_features= DRIVER_GEM,
-   .gem_free_object= vgem_gem_free_object,
+   .gem_free_object_unlocked   = vgem_gem_free_object,
.gem_vm_ops = &vgem_gem_vm_ops,
.ioctls = vgem_ioctls,
.fops   = &vgem_driver_fops,
-- 
2.8.1

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


[Intel-gfx] [PATCH 19/35] drm/imx: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Sascha Hauer 
Cc: Philipp Zabel 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/imx/imx-drm-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index e26dcdec2aba..2453fb1c68a7 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -411,7 +411,7 @@ static struct drm_driver imx_drm_driver = {
.unload = imx_drm_driver_unload,
.lastclose  = imx_drm_driver_lastclose,
.set_busid  = drm_platform_set_busid,
-   .gem_free_object= drm_gem_cma_free_object,
+   .gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create= drm_gem_cma_dumb_create,
.dumb_map_offset= drm_gem_cma_dumb_map_offset,
-- 
2.8.1

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


[Intel-gfx] [PATCH 22/35] drm/qxl: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Dave Airlie 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/qxl/qxl_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index dc9df5fe50ba..460bbceae297 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -256,7 +256,7 @@ static struct drm_driver qxl_driver = {
.gem_prime_vmap = qxl_gem_prime_vmap,
.gem_prime_vunmap = qxl_gem_prime_vunmap,
.gem_prime_mmap = qxl_gem_prime_mmap,
-   .gem_free_object = qxl_gem_object_free,
+   .gem_free_object_unlocked = qxl_gem_object_free,
.gem_open_object = qxl_gem_object_open,
.gem_close_object = qxl_gem_object_close,
.fops = &qxl_fops,
-- 
2.8.1

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


[Intel-gfx] [PATCH 12/35] drm/ast: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Dave Airlie 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/ast/ast_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index fcd9c0714836..f54afd2113a9 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -209,7 +209,7 @@ static struct drm_driver driver = {
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,
 
-   .gem_free_object = ast_gem_free_object,
+   .gem_free_object_unlocked = ast_gem_free_object,
.dumb_create = ast_dumb_create,
.dumb_map_offset = ast_dumb_mmap_offset,
.dumb_destroy = drm_gem_dumb_destroy,
-- 
2.8.1

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


[Intel-gfx] [PATCH 14/35] drm/bochs: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Gerd Hoffmann 
Cc: Dave Airlie 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/bochs/bochs_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bochs/bochs_drv.c 
b/drivers/gpu/drm/bochs/bochs_drv.c
index b332b4d3b0e2..abace82de6ea 100644
--- a/drivers/gpu/drm/bochs/bochs_drv.c
+++ b/drivers/gpu/drm/bochs/bochs_drv.c
@@ -89,7 +89,7 @@ static struct drm_driver bochs_driver = {
.date   = "20130925",
.major  = 1,
.minor  = 0,
-   .gem_free_object= bochs_gem_free_object,
+   .gem_free_object_unlocked = bochs_gem_free_object,
.dumb_create= bochs_dumb_create,
.dumb_map_offset= bochs_dumb_mmap_offset,
.dumb_destroy   = drm_gem_dumb_destroy,
-- 
2.8.1

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


[Intel-gfx] [PATCH 16/35] drm/etnaviv: Use lockless gem BO free callback

2016-04-26 Thread Daniel Vetter
No dev->struct_mutex anywhere to be seen.

Cc: Christian Gmeiner 
Cc: Russell King 
Cc: Lucas Stach 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c 
b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index e8858985f01e..c2f92e362812 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -497,7 +497,7 @@ static struct drm_driver etnaviv_drm_driver = {
.open   = etnaviv_open,
.preclose   = etnaviv_preclose,
.set_busid  = drm_platform_set_busid,
-   .gem_free_object= etnaviv_gem_free_object,
+   .gem_free_object_unlocked = etnaviv_gem_free_object,
.gem_vm_ops = &vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-- 
2.8.1

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


[Intel-gfx] [PATCH 08/35] drm: Protect dev->filelist with its own mutex

2016-04-26 Thread Daniel Vetter
amdgpu gained dev->struct_mutex usage, and that's because it's walking
the dev->filelist list. Protect that list with it's own lock to take
one more step towards getting rid of struct_mutex usage in drivers
once and for all.

While doing the conversion I noticed that 2 debugfs files in i915
completely lacked appropriate locking. Fix that up too.

v2: don't forget to switch to drm_gem_object_unreference_unlocked.

Cc: Alex Deucher 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 +-
 drivers/gpu/drm/drm_drv.c   |  1 +
 drivers/gpu/drm/drm_fops.c  |  9 ++---
 drivers/gpu/drm/drm_info.c  |  4 ++--
 drivers/gpu/drm/i915/i915_debugfs.c | 12 ++--
 include/drm/drmP.h  |  1 +
 6 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index fa6a27bff298..a087b9638cde 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -93,7 +93,7 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev)
struct drm_device *ddev = adev->ddev;
struct drm_file *file;
 
-   mutex_lock(&ddev->struct_mutex);
+   mutex_lock(&ddev->filelist_mutex);
 
list_for_each_entry(file, &ddev->filelist, lhead) {
struct drm_gem_object *gobj;
@@ -103,13 +103,13 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev)
spin_lock(&file->table_lock);
idr_for_each_entry(&file->object_idr, gobj, handle) {
WARN_ONCE(1, "And also active allocations!\n");
-   drm_gem_object_unreference(gobj);
+   drm_gem_object_unreference_unlocked(gobj);
}
idr_destroy(&file->object_idr);
spin_unlock(&file->table_lock);
}
 
-   mutex_unlock(&ddev->struct_mutex);
+   mutex_unlock(&ddev->filelist_mutex);
 }
 
 /*
@@ -769,7 +769,7 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, void 
*data)
struct drm_file *file;
int r;
 
-   r = mutex_lock_interruptible(&dev->struct_mutex);
+   r = mutex_lock_interruptible(&dev->filelist_mutex);
if (r)
return r;
 
@@ -793,7 +793,7 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, void 
*data)
spin_unlock(&file->table_lock);
}
 
-   mutex_unlock(&dev->struct_mutex);
+   mutex_unlock(&dev->filelist_mutex);
return 0;
 }
 
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index e1fb52d4f72c..bff89226a344 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -590,6 +590,7 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
spin_lock_init(&dev->buf_lock);
spin_lock_init(&dev->event_lock);
mutex_init(&dev->struct_mutex);
+   mutex_init(&dev->filelist_mutex);
mutex_init(&dev->ctxlist_mutex);
mutex_init(&dev->master_mutex);
 
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index c3d0aaac0669..7af7f8bcb355 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -297,9 +297,9 @@ static int drm_open_helper(struct file *filp, struct 
drm_minor *minor)
}
mutex_unlock(&dev->master_mutex);
 
-   mutex_lock(&dev->struct_mutex);
+   mutex_lock(&dev->filelist_mutex);
list_add(&priv->lhead, &dev->filelist);
-   mutex_unlock(&dev->struct_mutex);
+   mutex_unlock(&dev->filelist_mutex);
 
 #ifdef __alpha__
/*
@@ -447,8 +447,11 @@ int drm_release(struct inode *inode, struct file *filp)
 
DRM_DEBUG("open_count = %d\n", dev->open_count);
 
-   mutex_lock(&dev->struct_mutex);
+   mutex_lock(&dev->filelist_mutex);
list_del(&file_priv->lhead);
+   mutex_unlock(&dev->filelist_mutex);
+
+   mutex_lock(&dev->struct_mutex);
if (file_priv->magic)
idr_remove(&file_priv->master->magic_map, file_priv->magic);
mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index cbb4fc0fc969..5d469b2f26f4 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -174,7 +174,7 @@ int drm_clients_info(struct seq_file *m, void *data)
/* dev->filelist is sorted youngest first, but we want to present
 * oldest first (i.e. kernel, servers, clients), so walk backwardss.
 */
-   mutex_lock(&dev->struct_mutex);
+   mutex_lock(&dev->filelist_mutex);
list_for_each_entry_reverse(priv, &dev->filelist, lhead) {
struct task_struct *task;
 
@@ -190,7 +190,7 @@ int drm_clients_info(struct seq_file *m, void *data)
   priv->magic);
rcu_read_unlock();
}
-   mutex_unlock(&dev->struct_mutex);
+   mutex_unlock(&dev->filelist_mutex);
   

[Intel-gfx] [PATCH 06/35] drm: Hide master MAP cleanup in drm_bufs.c

2016-04-26 Thread Daniel Vetter
And again make sure it's a no-op for modern drivers, again with the
exception of nouveau. Another case of dev->struct_mutex gone for
modern drivers!

v2: Also add a DRIVER_* check like for all other maps functions to
really short-circuit the code. And give drm_legacy_rmmap used by the
dev unregister code the same treatment.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_bufs.c | 28 
 drivers/gpu/drm/drm_drv.c  | 10 +-
 include/drm/drm_legacy.h   |  4 +++-
 3 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index e8a12a4fd400..5a51633da033 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -542,18 +542,38 @@ int drm_legacy_rmmap_locked(struct drm_device *dev, 
struct drm_local_map *map)
 }
 EXPORT_SYMBOL(drm_legacy_rmmap_locked);
 
-int drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
+void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
 {
-   int ret;
+   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
+   drm_core_check_feature(dev, DRIVER_MODESET))
+   return;
 
mutex_lock(&dev->struct_mutex);
-   ret = drm_legacy_rmmap_locked(dev, map);
+   drm_legacy_rmmap_locked(dev, map);
mutex_unlock(&dev->struct_mutex);
 
-   return ret;
+   return;
 }
 EXPORT_SYMBOL(drm_legacy_rmmap);
 
+void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master 
*master)
+{
+   struct drm_map_list *r_list, *list_temp;
+
+   if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
+   drm_core_check_feature(dev, DRIVER_MODESET))
+   return;
+
+   mutex_lock(&dev->struct_mutex);
+   list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
+   if (r_list->master == master) {
+   drm_legacy_rmmap_locked(dev, r_list->map);
+   r_list = NULL;
+   }
+   }
+   mutex_unlock(&dev->struct_mutex);
+}
+
 /* The rmmap ioctl appears to be unnecessary.  All mappings are torn down on
  * the last close of the device, and this is necessary for cleanup when things
  * exit uncleanly.  Therefore, having userland manually remove mappings seems
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 55273f8f3acb..e1fb52d4f72c 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -121,19 +121,11 @@ static void drm_master_destroy(struct kref *kref)
 {
struct drm_master *master = container_of(kref, struct drm_master, 
refcount);
struct drm_device *dev = master->minor->dev;
-   struct drm_map_list *r_list, *list_temp;
 
if (dev->driver->master_destroy)
dev->driver->master_destroy(dev, master);
 
-   mutex_lock(&dev->struct_mutex);
-   list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
-   if (r_list->master == master) {
-   drm_legacy_rmmap_locked(dev, r_list->map);
-   r_list = NULL;
-   }
-   }
-   mutex_unlock(&dev->struct_mutex);
+   drm_legacy_master_rmmaps(dev, master);
 
idr_destroy(&master->magic_map);
kfree(master->unique);
diff --git a/include/drm/drm_legacy.h b/include/drm/drm_legacy.h
index 3e698038dc7b..a5ef2c7e40f8 100644
--- a/include/drm/drm_legacy.h
+++ b/include/drm/drm_legacy.h
@@ -154,8 +154,10 @@ struct drm_map_list {
 int drm_legacy_addmap(struct drm_device *d, resource_size_t offset,
  unsigned int size, enum drm_map_type type,
  enum drm_map_flags flags, struct drm_local_map **map_p);
-int drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map);
+void drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map);
 int drm_legacy_rmmap_locked(struct drm_device *d, struct drm_local_map *map);
+void drm_legacy_master_rmmaps(struct drm_device *dev,
+ struct drm_master *master);
 struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev);
 int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma);
 
-- 
2.8.1

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


  1   2   3   >