[Intel-gfx] ✓ Fi.CI.IGT: success for drm/i915: Refine the has_audio assignment

2018-04-12 Thread Patchwork
== Series Details ==

Series: drm/i915: Refine the has_audio assignment
URL   : https://patchwork.freedesktop.org/series/41650/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4050_full -> Patchwork_8684_full =

== Summary - WARNING ==

  Minor unknown changes coming with Patchwork_8684_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_8684_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41650/revisions/1/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in 
Patchwork_8684_full:

  === IGT changes ===

 Warnings 

igt@gem_mocs_settings@mocs-rc6-blt:
  shard-kbl:  SKIP -> PASS +1


== Known issues ==

  Here are the changes found in Patchwork_8684_full that come from known issues:

  === IGT changes ===

 Issues hit 

igt@kms_flip@2x-plain-flip-fb-recreate-interruptible:
  shard-hsw:  PASS -> FAIL (fdo#100368)


 Possible fixes 

igt@kms_flip@2x-plain-flip-ts-check:
  shard-hsw:  FAIL (fdo#100368) -> PASS

igt@kms_flip@dpms-vs-vblank-race-interruptible:
  shard-hsw:  DMESG-WARN (fdo#102614) -> PASS

igt@kms_sysfs_edid_timing:
  shard-apl:  WARN (fdo#100047) -> PASS

igt@pm_rps@reset:
  shard-apl:  FAIL (fdo#102250) -> PASS


  fdo#100047 https://bugs.freedesktop.org/show_bug.cgi?id=100047
  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#102250 https://bugs.freedesktop.org/show_bug.cgi?id=102250
  fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614


== Participating hosts (6 -> 4) ==

  Missing(2): shard-glk shard-glkb 


== Build changes ==

* Linux: CI_DRM_4050 -> Patchwork_8684

  CI_DRM_4050: dc857e9d853d2bd074adaf49c49deb473328ea72 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4428: aa330c72a74c071eddb35300e4dd1957eb8d30ff @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_8684: 8a6ced3b5f509a8156fddac5afda1ea029045ac0 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4428: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8684/shards.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Refine the has_audio assignment

2018-04-12 Thread Patchwork
== Series Details ==

Series: drm/i915: Refine the has_audio assignment
URL   : https://patchwork.freedesktop.org/series/41650/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4050 -> Patchwork_8684 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41650/revisions/1/mbox/

== Known issues ==

  Here are the changes found in Patchwork_8684 that come from known issues:

  === IGT changes ===

 Issues hit 

igt@gem_ctx_switch@basic-default:
  fi-cnl-y3:  PASS -> INCOMPLETE (fdo#105086)


 Possible fixes 

igt@gem_exec_suspend@basic-s4-devices:
  fi-kbl-7500u:   DMESG-WARN (fdo#105128) -> PASS


  fdo#105086 https://bugs.freedesktop.org/show_bug.cgi?id=105086
  fdo#105128 https://bugs.freedesktop.org/show_bug.cgi?id=105128


== Participating hosts (35 -> 33) ==

  Missing(2): fi-ilk-m540 fi-skl-6700hq 


== Build changes ==

* Linux: CI_DRM_4050 -> Patchwork_8684

  CI_DRM_4050: dc857e9d853d2bd074adaf49c49deb473328ea72 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4428: aa330c72a74c071eddb35300e4dd1957eb8d30ff @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_8684: 8a6ced3b5f509a8156fddac5afda1ea029045ac0 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4428: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit


== Linux commits ==

8a6ced3b5f50 drm/i915: Refine the has_audio assignment

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8684/issues.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] drm/i915: Refine the has_audio assignment

2018-04-12 Thread Yang
From: Yang Shi 

Refine the has_audio assignment for dp and hdmi.

Signed-off-by: Yang Shi 
---
 drivers/gpu/drm/i915/intel_dp.c   | 2 +-
 drivers/gpu/drm/i915/intel_hdmi.c | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index a29868c..47aa2ea 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1644,7 +1644,7 @@ intel_dp_compute_config(struct intel_encoder *encoder,
else if (intel_conn_state->force_audio == HDMI_AUDIO_AUTO)
pipe_config->has_audio = intel_dp->has_audio;
else
-   pipe_config->has_audio = intel_conn_state->force_audio == 
HDMI_AUDIO_ON;
+   pipe_config->has_audio = false;
 
if (intel_dp_is_edp(intel_dp) && intel_connector->panel.fixed_mode) {
struct drm_display_mode *panel_mode =
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
b/drivers/gpu/drm/i915/intel_hdmi.c
index 179d0ad..3c4b92e 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -1474,8 +1474,7 @@ bool intel_hdmi_compute_config(struct intel_encoder 
*encoder,
if (intel_conn_state->force_audio == HDMI_AUDIO_AUTO)
pipe_config->has_audio = intel_hdmi->has_audio;
else
-   pipe_config->has_audio =
-   intel_conn_state->force_audio == HDMI_AUDIO_ON;
+   pipe_config->has_audio = false;
}
 
/*
-- 
2.7.4

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


Re: [Intel-gfx] [igt-dev] [PATCH i-g-t 18/20] tests/psr: Check for timestamp support

2018-04-12 Thread Dhinakaran Pandiyan

On Thu, 2018-04-12 at 14:52 +0200, Katarzyna Dec wrote:
> On Tue, Apr 10, 2018 at 07:37:30PM -0700, Dhinakaran Pandiyan wrote:
> > BDW+ have PSR interrupts from which the kernel can update exit and
> > pre-entry time stamps. Tests should prefer this over sink crc to
> > validate PSR.
> > 
> > Signed-off-by: Dhinakaran Pandiyan 
> > ---
> >  tests/kms_psr_sink_crc.c | 13 +
> >  1 file changed, 13 insertions(+)
> > 
> > diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c
> > index 043b9e38..147b492f 100644
> > --- a/tests/kms_psr_sink_crc.c
> > +++ b/tests/kms_psr_sink_crc.c
> > @@ -75,6 +75,7 @@ typedef struct {
> > igt_output_t *output;
> > bool with_psr_disabled;
> > bool with_sink_crc;
> > +   bool with_timestamps;
> >  } data_t;
> >  
> >  static void create_cursor_fb(data_t *data)
> > @@ -200,6 +201,17 @@ static bool sink_support(data_t *data)
> > strstr(buf, "Sink_Support: yes\n");
> >  }
> >  
> > +static void timestamp_support(data_t *data)
> > +{
> > +   char buf[512];
> > +
> > +   igt_sysfs_set(data->debugfs_fd, "i915_edp_psr_debug", "1");
> > +   igt_debugfs_read(data->drm_fd, "i915_edp_psr_status", buf);
> > +   data->with_timestamps = strstr(buf, "Last exit at:");
> > +   igt_debug("Time stamp support %d\n", data->with_timestamps);
> > +   igt_sysfs_set(data->debugfs_fd, "i915_edp_psr_debug", "0");
> > +}
> > +
> Is this information about timestamp in debugs already in the kernel?

Thanks for the reviews. Not yet, the patches are on the list -
https://patchwork.freedesktop.org/series/41095/

Hoping someone will merge them :)

> Kasia
> >  static bool psr_enabled(data_t *data)
> >  {
> > char buf[512];
> > @@ -500,6 +512,7 @@ int main(int argc, char *argv[])
> >  0 : 1);
> > igt_require_f(sink_support(),
> >   "Sink does not support PSR\n");
> > +   timestamp_support();
> >  
> > data.bufmgr = drm_intel_bufmgr_gem_init(data.drm_fd, 4096);
> > igt_assert(data.bufmgr);
> > -- 
> > 2.14.1
> > 
> > ___
> > igt-dev mailing list
> > igt-...@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/igt-dev
> ___
> igt-dev mailing list
> igt-...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev

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


Re: [Intel-gfx] [PATCH] drm/i915/dp: Fix intel_edp_compare_alt_mode.

2018-04-12 Thread Clint Taylor



On 03/13/2018 06:11 AM, Ville Syrjälä wrote:

On Tue, Mar 13, 2018 at 10:28:55AM +0100, Maarten Lankhorst wrote:

On fi-cnl-y3 we have 2 modes that differ only by crtc_clock. This means
that if we request the normal mode, we automatically get the downclocked
mode.

This can be seen during boot:
[drm:drm_helper_probe_single_connector_modes] [CONNECTOR:101:eDP-1] probed 
modes :
[drm:drm_mode_debug_printmodeline] Modeline 102:"3840x2160" 60 533250 3840 3888 
3920 4000 2160 2163 2168  0x48 0xa
[drm:drm_mode_debug_printmodeline] Modeline 103:"3840x2160" 48 426600 3840 3888 
3920 4000 2160 2163 2168  0x40 0xa
...
[drm:intel_dump_pipe_config [i915]] [CRTC:51:pipe A][modeset]
[drm:intel_dump_pipe_config [i915]] output_types: EDP (0x100)
[drm:intel_dump_pipe_config [i915]] cpu_transcoder: EDP, pipe bpp: 24, 
dithering: 0
[drm:intel_dump_pipe_config [i915]] dp m_n: lanes: 4; gmch_m: 4970250, gmch_n: 
8388608, link_m: 828375, link_n: 1048576, tu: 64
[drm:intel_dump_pipe_config [i915]] dp m2_n2: lanes: 4; gmch_m: 4970250, 
gmch_n: 8388608, link_m: 828375, link_n: 1048576, tu: 64
[drm:intel_dump_pipe_config [i915]] audio: 0, infoframes: 0
[drm:intel_dump_pipe_config [i915]] requested mode:
[drm:drm_mode_debug_printmodeline] Modeline 0:"3840x2160" 60 533250 3840 3888 
3920 4000 2160 2163 2168  0x48 0xa
[drm:intel_dump_pipe_config [i915]] adjusted mode:
[drm:drm_mode_debug_printmodeline] Modeline 0:"3840x2160" 48 426600 3840 3888 
3920 4000 2160 2163 2168  0x40 0xa

Testcase: kms_panel_fitting.atomic-fastset
Signed-off-by: Maarten Lankhorst 
Fixes: dc911f5bd8aa ("drm/i915/edp: Allow alternate fixed mode for eDP if 
available.")
Cc: David Weinehall 
Cc: Rodrigo Vivi 
Cc: Paulo Zanoni 
Cc: Jani Nikula 
Cc: Chris Wilson 
Cc: Jim Bride 
Cc: Joonas Lahtinen 
Cc:  # v4.14+
---
  drivers/gpu/drm/i915/intel_dp.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 9a4a51e79fa1..0bd3cc1c82b4 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1684,7 +1684,8 @@ static bool intel_edp_compare_alt_mode(struct 
drm_display_mode *m1,
m1->vdisplay == m2->vdisplay &&
m1->vsync_start == m2->vsync_start &&
m1->vsync_end == m2->vsync_end &&
-   m1->vtotal == m2->vtotal);
+   m1->vtotal == m2->vtotal &&
+   m1->clock == m2->clock);

Isn't the entire point here to ignore differences in the clock? Hmm.
Maybe not.


For DRRS we want to ignore the slower clock. However this function is 
just for PSR testing when the eDP fixed mode blanking interval is 
shorter then the single frame setup time minimum.




Probably what we really want to do is check whether the requested
refresh rate is closer to the fixed mode or the alt mode.


Since this feature appears to be for testing only the Alt mode should 
only be used if specifically requested. If not eDP fixed mode should be 
used.


Maarten, Sorry about submitting this patch again. I didn't do 5 minutes 
of research to see if someone already submitted a fix.


-Clint




return bres;
  }
  
--

2.16.2

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


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


Re: [Intel-gfx] [PATCH i-g-t v3] tests/kms_rotation_crc: Move platform checks to one place for non exhaust fence cases

2018-04-12 Thread Radhakrishna Sripada
On Fri, Apr 06, 2018 at 06:56:22PM +0300, Ville Syrjälä wrote:
> On Thu, Mar 29, 2018 at 06:19:40AM +, Sripada, Radhakrishna wrote:
> > 
> > 
> > > -Original Message-
> > > From: Ville Syrjälä [mailto:ville.syrj...@linux.intel.com]
> > > Sent: Wednesday, March 28, 2018 3:36 AM
> > > To: Maarten Lankhorst 
> > > Cc: Sripada, Radhakrishna ; igt-
> > > d...@lists.freedesktop.org; intel-gfx@lists.freedesktop.org; Srivatsa, 
> > > Anusha
> > > ; Vetter, Daniel ; 
> > > Vivi,
> > > Rodrigo ; Kahola, Mika ;
> > > Navare, Manasi D 
> > > Subject: Re: [PATCH i-g-t v3] tests/kms_rotation_crc: Move platform checks
> > > to one place for non exhaust fence cases
> > > 
> > > On Wed, Mar 28, 2018 at 10:29:15AM +0200, Maarten Lankhorst wrote:
> > > > Op 22-03-18 om 23:10 schreef Radhakrishna Sripada:
> > > > > From: Anusha Srivatsa 
> > > > >
> > > > > Cleanup the testcases by moving the platform checks to a single 
> > > > > function.
> > > > >
> > > > > The earlier version of the path is posted here [1]
> > > > >
> > > > > v2: Make use of the property enums to get the supported rotations
> > > > > v3: Move hardcodings to a single function(Ville)
> > > > >
> > > > > [1]: https://patchwork.freedesktop.org/patch/209647/
> > > > >
> > > > > Cc: Radhakrishna Sripada 
> > > > > Cc: Ville Syrjälä 
> > > > > Cc: Daniel Vetter 
> > > > > Cc: Rodrigo Vivi 
> > > > > Cc: Maarten Lankhorst 
> > > > > Cc: Mika Kahola 
> > > > > Cc: Manasi Navare 
> > > > > Signed-off-by: Anusha Srivatsa 
> > > > > Signed-off-by: Radhakrishna Sripada 
> > > > > ---
> > > > >  tests/kms_rotation_crc.c | 31 ---
> > > > >  1 file changed, 16 insertions(+), 15 deletions(-)
> > > > >
> > > > > diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
> > > > > index 0cd5c6e52b57..60fb9012e14e 100644
> > > > > --- a/tests/kms_rotation_crc.c
> > > > > +++ b/tests/kms_rotation_crc.c
> > > > > @@ -43,6 +43,7 @@ typedef struct {
> > > > >   uint32_t override_fmt;
> > > > >   uint64_t override_tiling;
> > > > >   int devid;
> > > > > + int gen;
> > > > >  } data_t;
> > > > >
> > > > >  typedef struct {
> > > > > @@ -301,6 +302,17 @@ static void wait_for_pageflip(int fd)
> > > > >   igt_assert(drmHandleEvent(fd, ) == 0);  }
> > > > >
> > > > > +static void igt_check_rotation(data_t *data) {
> > > > > + if (data->rotation & (IGT_ROTATION_90 | IGT_ROTATION_270))
> > > > > + igt_require(data->gen >= 9);
> > > > > + else if (data->rotation & IGT_REFLECT_X)
> > > > > + igt_require(data->gen >= 10 ||
> > > > > + (IS_CHERRYVIEW(data->devid) && 
> > > > > (data->rotation
> > > & IGT_ROTATION_0)));
> > > > > + else if (data->rotation & IGT_ROTATION_180)
> > > > > + igt_require(data->gen >= 4);
> > > > > +}
> > > > This still won't work as intended on CHV as it only has reflection on 
> > > > PIPE_B,
> > > for X tiled fb's.
> > > 
> > > s/X tiled//
> > So should we hack the reflect subtest to partially run for a single pipe 
> > and skip for the other pipes on Chv? If so is there a non-murky way to do 
> > it?
> 
> At least skipping for pipe A/C should happen automagically if we ask the
> plane what it supports. The pipe B case still needs to be special cased
> though.
> 

I sent an updated patch [1] making the changes. Is it ok?

[1] https://patchwork.freedesktop.org/patch/214698/

> > 
> > Thanks,
> > Radhakrishna
> > 
> > > 
> > > >
> > > >
> > > > >  static void test_single_case(data_t *data, enum pipe pipe,
> > > > >igt_output_t *output, igt_plane_t *plane,
> > > > >enum rectangle_type rect,
> > > > > @@ -369,13 +381,12 @@ static void test_plane_rotation(data_t *data,
> > > > > int plane_type, bool test_bad_form
> > > > >
> > > > >   igt_display_require_output(display);
> > > > >
> > > > > + igt_check_rotation(data);
> > > > > +
> > > > >   for_each_pipe_with_valid_output(display, pipe, output) {
> > > > >   igt_plane_t *plane;
> > > > >   int i, j;
> > > > >
> > > > > - if (IS_CHERRYVIEW(data->devid) && pipe != PIPE_B)
> > > > > - continue;
> > > > > -
> > > > >   igt_output_set_pipe(output, pipe);
> > > > >
> > > > >   plane = igt_output_get_plane_type(output, plane_type); 
> > > > > @@
> > > -538,14
> > > > > +549,13 @@ igt_main
> > > > >   };
> > > > >
> > > > >   data_t data = {};
> > > > > - int gen 

Re: [Intel-gfx] [PATCH 0/9] GPU-bound energy efficiency improvements for the intel_pstate driver.

2018-04-12 Thread Francisco Jerez
Juri Lelli  writes:

> Hi,
>
> On 11/04/18 09:26, Francisco Jerez wrote:
>> Francisco Jerez  writes:
>> 
>> > Hi Srinivas,
>> >
>> > Srinivas Pandruvada  writes:
>> >
>> >> On Tue, 2018-04-10 at 15:28 -0700, Francisco Jerez wrote:
>> >>> Francisco Jerez  writes:
>> >>> 
>> >> [...]
>> >>
>> >>
>> >>> For the case anyone is wondering what's going on, Srinivas pointed me
>> >>> at
>> >>> a larger idle power usage increase off-list, ultimately caused by the
>> >>> low-latency heuristic as discussed in the paragraph above.  I have a
>> >>> v2
>> >>> of PATCH 6 that gives the controller a third response curve roughly
>> >>> intermediate between the low-latency and low-power states of this
>> >>> revision, which avoids the energy usage increase while C0 residency
>> >>> is
>> >>> low (e.g. during idle) expected for v1.  The low-latency behavior of
>> >>> this revision is still going to be available based on a heuristic (in
>> >>> particular when a realtime-priority task is scheduled).  We're
>> >>> carrying
>> >>> out some additional testing, I'll post the code here eventually.
>> >>
>> >> Please try sched-util governor also. There is a frequency-invariant
>> >> patch, which I can send you (This eventually will be pushed by Peter).
>> >> We want to avoid complexity to intel-pstate for non HWP power sensitive
>> >> platforms as far as possible.
>> >>
>> >
>> > Unfortunately the schedutil governor (whether frequency invariant or
>> > not) has the exact same energy efficiency issues as the present
>> > intel_pstate non-HWP governor.  Its response is severely underdamped
>> > leading to energy-inefficient behavior for any oscillating non-CPU-bound
>> > workload.  To exacerbate that problem the frequency is maxed out on
>> > frequent IO waiting just like the current intel_pstate cpu-load
>> 
>> "just like" here is possibly somewhat unfair to the schedutil governor,
>> admittedly its progressive IOWAIT boosting behavior seems somewhat less
>> wasteful than the intel_pstate non-HWP governor's IOWAIT boosting
>> behavior, but it's still largely unhelpful on IO-bound conditions.
>
> Sorry if I jump in out of the blue, but what you are trying to solve
> looks very similar to what IPA [1] is targeting as well. I might be
> wrong (I'll try to spend more time reviewing your set), but my first
> impression is that we should try to solve similar problems with a more
> general approach that could benefit different sys/archs.
>

Thanks, seems interesting, I've also been taking a look at your
whitepaper and source code.  The problem we've both been trying to solve
is indeed closely related, there may be an opportunity for sharing
efforts both ways.

Correct me if I didn't understand the whole details about your power
allocation code, but IPA seems to be dividing up the available power
budget proportionally to the power requested by the different actors (up
to the point that causes some actor to reach its maximum power) and
configured weights.  From my understanding of the get_requested_power
implementations for cpufreq and devfreq, the requested power attempts to
approximate the current power usage of each device (whether it's
estimated from the current frequency and a capacitance model, from the
get_real_power callback, or other mechanism), which can be far from the
optimal power consumption in cases where the device's governor is
programming a frequency that wildly deviates from the optimal one (as is
the case with the current intel_pstate governor for any IO-bound
workload, which incidentally will suffer the greatest penalty from a
suboptimal power allocation in cases where the IO device is actually an
integrated GPU).

Is there any mechanism in place to prevent the system from stabilizing
at a power allocation that prevents it from achieving maximum
throughput?  E.g. in a TDP-limited system with two devices consuming a
total power of Pmax = P0(f0) + P1(f1), with f0 much greater than the
optimal, and f1 capped at a frequency lower than the optimal due to TDP
or thermal constraints, and assuming that the system is bottlenecking at
the second device.  In such a scenario wouldn't IPA distribute power in
a way that roughly approximates the pre-existing suboptimal
distribution?

If that's the case, I understand that it's the responsibility of the
device's (or CPU's) frequency governor to request a frequency which is
reasonably energy-efficient in the first place for the balancer to
function correctly? (That's precisely the goal of this series) -- Which
in addition allows the system to use less power to get the same work
done in cases where the system is not thermally or TDP-limited as a
whole, so the balancing logic wouldn't have any effect at all.

> I'm Cc-ing some Arm folks...
>
> Best,
>
> - Juri
>
> [1] https://developer.arm.com/open-source/intelligent-power-allocation


signature.asc
Description: PGP signature

Re: [Intel-gfx] [PATCH] drm/i915/edp: Only use alternate fixed mode when requested

2018-04-12 Thread Clint Taylor



On 04/11/2018 04:11 PM, Chris Wilson wrote:

Quoting clinton.a.tay...@intel.com (2018-04-12 00:13:26)

From: Clint Taylor 

In commit dc911f5bd8aa ("drm/i915/edp: Allow alternate fixed mode for eDP
if available."), the patch was always selecting the alternate refresh rate
even though user space was asking for the higher rate. This patch adds a
check for vrefresh rate as well as the rest of the mode geometry.

V2: use clock instead of vrefresh for compare.

Fixes: dc911f5bd8aac ("Allow alternate fixed mode for eDP if available.")
Cc: David Weinehall 
Cc: Rodrigo Vivi 
Signed-off-by: Clint Taylor 

Still leaves the other discussion point in the other thread unresolved.
The fields are supplied by the user and can be arbitrary, so if they
request a clock for a 30Hz mode, instead of using the 40Hz alternative,
we use the 60Hz normal mode (by way of example). Is equality always the
best choice here?
This feature is for testing PSR panels that don't support single frame 
setup times in their preferred timing. The down-clocked mode is the 
timing that the panel specifically states is supported. If a customer 
specifies a custom mode either it should be rejected or the eDP fixed 
mode (preferred) should be used. If we want to allow the users to set a 
custom timing to their eDP panels then we should get rid of the fixed 
mode feature for eDP panels.


-Clint


-Chris


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


Re: [Intel-gfx] [PATCH 0/9] GPU-bound energy efficiency improvements for the intel_pstate driver.

2018-04-12 Thread Francisco Jerez
Peter Zijlstra  writes:

> On Thu, Apr 12, 2018 at 11:34:54AM -0700, Francisco Jerez wrote:
>> The reason for the energy efficiency problem of iowait boosting is
>> precisely the greater oscillation between turbo and idle.  Say that
>> iowait boost increases the frequency by a factor alpha relative to the
>> optimal frequency f0 (in terms of energy efficiency) required to execute
>> some IO-bound workload.  This will cause the CPU to be busy for a
>> fraction of the time it was busy originally, approximately t1 = t0 /
>> alpha, which indeed divides the overall energy usage by a factor alpha,
>> but at the same time multiplies the instantaneous power consumption
>> while busy by a factor potentially much greater than alpha, since the
>> CPU's power curve is largely non-linear, and in fact approximately
>> convex within the frequency range allowed by the policy, so you get an
>> average energy usage possibly much greater than the optimal.
>
> Ah, but we don't (yet) have the (normalized) power curves, so we cannot
> make that call.
>
> Once we have the various energy/OPP numbers required for EAS we can
> compute the optimal. I think such was even mentioned in the thread I
> referred earlier.
>
> Until such time; we boost to max for lack of a better option.

Actually assuming that a single geometric feature of the power curve is
known -- it being convex in the frequency range allowed by the policy
(which is almost always the case, not only for Intel CPUs), the optimal
frequency for an IO-bound workload is fully independent of the exact
power curve -- It's just the minimum CPU frequency that's able to keep
the bottlenecking IO device at 100% utilization.  Any frequency higher
than that will lead to strictly lower energy efficiency whatever the
exact form of the power curve is.

I agree though that exact knowledge of the power curve *might* be useful
as a mechanism to estimate the potential costs of exceeding that optimal
frequency (e.g. as a mechanism to offset performance loss heuristically
for the case the workload fluctuates by giving the governor an upward
bias with an approximately known energy cost), but that's not required
for the governor's behavior to be approximately optimal in IO-bound
conditions.  Not making further assumptions about the power curve beyond
its convexity makes the algorithm fairly robust against any inaccuracy
in the power curve numbers (which there will always be, since the energy
efficiency of the workload is really dependent on the behavior of
multiple components of the system interacting with each other), and
makes it easily reusable on platforms where the exact power curves are
not known.


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


Re: [Intel-gfx] [PATCH] drm/i915: Block enabling FBC until flips have been completed

2018-04-12 Thread Souza, Jose
On Thu, 2018-04-12 at 18:07 +0200, Maarten Lankhorst wrote:
> There is a small race window in which FBC can be enabled after
> pre_plane_update is called, but before the page flip has been
> queued or completed.

I don't think there is such window, intel_fbc_deactivate() that is
called from intel_fbc_pre_update() will set fbc->work.scheduled =
false; so the FBC will not be enabled in intel_fbc_work_fn()

> 
> Signed-off-by: Maarten Lankhorst 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103167
> ---
>  drivers/gpu/drm/i915/i915_drv.h  |  1 +
>  drivers/gpu/drm/i915/intel_fbc.c | 35 +++---
> -
>  2 files changed, 12 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h
> b/drivers/gpu/drm/i915/i915_drv.h
> index a0b8db3db141..2e2f24c2db9e 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -492,6 +492,7 @@ struct intel_fbc {
>  
>   bool enabled;
>   bool active;
> + bool flip_pending;
>  
>   bool underrun_detected;
>   struct work_struct underrun_work;
> diff --git a/drivers/gpu/drm/i915/intel_fbc.c
> b/drivers/gpu/drm/i915/intel_fbc.c
> index b431b6733cc1..4770dd7dad5c 100644
> --- a/drivers/gpu/drm/i915/intel_fbc.c
> +++ b/drivers/gpu/drm/i915/intel_fbc.c
> @@ -924,13 +924,6 @@ static void intel_fbc_get_reg_params(struct
> intel_crtc *crtc,
>   32 * fbc->threshold) 
> * 8;
>  }
>  
> -static bool intel_fbc_reg_params_equal(struct intel_fbc_reg_params
> *params1,
> -struct intel_fbc_reg_params
> *params2)
> -{
> - /* We can use this since intel_fbc_get_reg_params() does a
> memset. */
> - return memcmp(params1, params2, sizeof(*params1)) == 0;
> -}
> -
>  void intel_fbc_pre_update(struct intel_crtc *crtc,
> struct intel_crtc_state *crtc_state,
> struct intel_plane_state *plane_state)
> @@ -952,6 +945,7 @@ void intel_fbc_pre_update(struct intel_crtc
> *crtc,
>   if (!fbc->enabled || fbc->crtc != crtc)
>   goto unlock;
>  
> + fbc->flip_pending = true;

Also this is not a good name, other actions can cause this function to
be executed other than a flip.

>   intel_fbc_update_state_cache(crtc, crtc_state, plane_state);
>  
>  deactivate:
> @@ -988,13 +982,15 @@ static void __intel_fbc_post_update(struct
> intel_crtc *crtc)
>  {
>   struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>   struct intel_fbc *fbc = _priv->fbc;
> - struct intel_fbc_reg_params old_params;
>  
>   WARN_ON(!mutex_is_locked(>lock));
>  
>   if (!fbc->enabled || fbc->crtc != crtc)
>   return;
>  
> + fbc->flip_pending = false;
> + WARN_ON(fbc->active);
> +
>   if (!i915_modparams.enable_fbc) {
>   intel_fbc_deactivate(dev_priv, "disabled at runtime
> per module param");
>   __intel_fbc_disable(dev_priv);
> @@ -1002,25 +998,16 @@ static void __intel_fbc_post_update(struct
> intel_crtc *crtc)
>   return;
>   }
>  
> - if (!intel_fbc_can_activate(crtc)) {
> - WARN_ON(fbc->active);
> + if (!intel_fbc_can_activate(crtc))
>   return;
> - }
>  
> - old_params = fbc->params;
>   intel_fbc_get_reg_params(crtc, >params);
>  
> - /* If the scanout has not changed, don't modify the FBC
> settings.
> -  * Note that we make the fundamental assumption that the fb-
> >obj
> -  * cannot be unpinned (and have its GTT offset and fence
> revoked)
> -  * without first being decoupled from the scanout and FBC
> disabled.
> -  */
> - if (fbc->active &&
> - intel_fbc_reg_params_equal(_params, >params))
> - return;
> -
> - intel_fbc_deactivate(dev_priv, "FBC enabled (active or
> scheduled)");
> - intel_fbc_schedule_activation(crtc);
> + if (!fbc->busy_bits) {

I guess this 'if' the line that is fixing the issue.

> + intel_fbc_deactivate(dev_priv, "FBC enabled (active
> or scheduled)");
> + intel_fbc_schedule_activation(crtc);
> + } else
> + intel_fbc_deactivate(dev_priv, "frontbuffer write");
>  }
>  
>  void intel_fbc_post_update(struct intel_crtc *crtc)
> @@ -1085,7 +1072,7 @@ void intel_fbc_flush(struct drm_i915_private
> *dev_priv,
>   (frontbuffer_bits & intel_fbc_get_frontbuffer_bit(fbc)))
> {
>   if (fbc->active)
>   intel_fbc_recompress(dev_priv);
> - else
> + else if (!fbc->flip_pending)
>   __intel_fbc_post_update(fbc->crtc);
>   }
>  
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 0/9] GPU-bound energy efficiency improvements for the intel_pstate driver.

2018-04-12 Thread Peter Zijlstra
On Thu, Apr 12, 2018 at 11:34:54AM -0700, Francisco Jerez wrote:
> The reason for the energy efficiency problem of iowait boosting is
> precisely the greater oscillation between turbo and idle.  Say that
> iowait boost increases the frequency by a factor alpha relative to the
> optimal frequency f0 (in terms of energy efficiency) required to execute
> some IO-bound workload.  This will cause the CPU to be busy for a
> fraction of the time it was busy originally, approximately t1 = t0 /
> alpha, which indeed divides the overall energy usage by a factor alpha,
> but at the same time multiplies the instantaneous power consumption
> while busy by a factor potentially much greater than alpha, since the
> CPU's power curve is largely non-linear, and in fact approximately
> convex within the frequency range allowed by the policy, so you get an
> average energy usage possibly much greater than the optimal.

Ah, but we don't (yet) have the (normalized) power curves, so we cannot
make that call.

Once we have the various energy/OPP numbers required for EAS we can
compute the optimal. I think such was even mentioned in the thread I
referred earlier.

Until such time; we boost to max for lack of a better option.
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] Incorrect plane programming sequence results into a corrupted display/hard hung system

2018-04-12 Thread Runyan, Arthur J
This seems like a typical atomic modeset requirement.

IPC should not impact register programming.
Vblank evasion only works if you have a guarantee on worst case 
interrupts/delays.  I think locks is part of the guarantee.
Double buffer control should guarantee safe alignment of programming across 
planes on the same pipe.  Multiple pipes will still require a wait for vblank.

From: Vyas, Tarun
Sent: Thursday, 12 April, 2018 9:57 AM
To: intel-gfx@lists.freedesktop.org
Cc: Runyan, Arthur J ; Shaikh, Azhar 
; Herbert, Marc ; Ciobanu, 
Nathan D ; Lankhorst, Maarten 

Subject: Incorrect plane programming sequence results into a corrupted 
display/hard hung system

On KBL platforms, with HW overlay and/or PSR2, a hard hang with corrupted 
display is observed while running tests that frequently disable/re-enable 
primary/overlay planes. Details recorded in this FDO bug: 
https://bugs.freedesktop.org/show_bug.cgi?id=104975.

The issue has been root caused as a race where only partial register updates 
get latched on the next vblank, specifically, the updates that give the buffer 
allocation of the current plane before disabling it (again, details captured in 
the FDO bug above). There have been several optimizations to work around this 
bug:

1.   Enable Isochronous priority control (IPC)

2.   Increase the vblank evasion time to 250 usec (We have tried 500 usec 
but that doesn't helps).

3.   Disable DOUBLE_BUFFER_CTL while the updates are done, inside 
intel_pipe_update_start and intel_pipe_update_end (doesn't helps)

4.   Grab all the required locks before starting the pipe_update.

Per Ville, none of the above optimizations guarantee a *full* update before the 
vblank. As a result, to fix this issue the right way, the plane programming 
sequence needs to be altered in the driver as mentioned below:

"Buffer allocation overlap among enabled planes will cause a full frame 
underrun, and that becomes a hard hange if pkgC or SAGV are enabled.
You need to make sure the plane is disabled before reallocating the buffer it 
uses.  For a single pipe it is sufficient to initiate the disabling of the 
plane before the reallocation.  For multiple pipes it can be more complex.
In this case you should be doing something like this to ensure plane 2A turns 
off before plane 1A steals the buffer


1. PLANE_CTL_2A -> disabled

2.   PLANE_SURF_2A:  touch to arm double buffer update

3.   PLANE_BUF_CFG_1A -> (0-860)

4.   PLANE_SURF_1A: touch to arm double buffer update
If the planes are on different pipes there needs to be a wait for vblank 
between step 2 and 3 to ensure the plane 2A disable completed."


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


[Intel-gfx] ✓ Fi.CI.IGT: success for drm/i915: Block enabling FBC until flips have been completed

2018-04-12 Thread Patchwork
== Series Details ==

Series: drm/i915: Block enabling FBC until flips have been completed
URL   : https://patchwork.freedesktop.org/series/41634/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4049_full -> Patchwork_8683_full =

== Summary - WARNING ==

  Minor unknown changes coming with Patchwork_8683_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_8683_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41634/revisions/1/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in 
Patchwork_8683_full:

  === IGT changes ===

 Warnings 

igt@gem_mocs_settings@mocs-rc6-vebox:
  shard-kbl:  SKIP -> PASS


== Known issues ==

  Here are the changes found in Patchwork_8683_full that come from known issues:

  === IGT changes ===

 Issues hit 

igt@gem_exec_schedule@preemptive-hang-blt:
  shard-kbl:  PASS -> DMESG-WARN (fdo#103558) +13

igt@kms_flip@flip-vs-expired-vblank:
  shard-hsw:  PASS -> FAIL (fdo#105189)

igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-mmap-gtt:
  shard-apl:  PASS -> FAIL (fdo#103167)


 Possible fixes 

igt@kms_flip@2x-dpms-vs-vblank-race-interruptible:
  shard-hsw:  FAIL (fdo#103060) -> PASS +1

igt@kms_flip@plain-flip-ts-check-interruptible:
  shard-hsw:  FAIL (fdo#100368) -> PASS +1

igt@kms_setmode@basic:
  shard-apl:  FAIL (fdo#99912) -> PASS


  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
  fdo#105189 https://bugs.freedesktop.org/show_bug.cgi?id=105189
  fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912


== Participating hosts (6 -> 4) ==

  Missing(2): shard-glk shard-glkb 


== Build changes ==

* Linux: CI_DRM_4049 -> Patchwork_8683

  CI_DRM_4049: 3dbfa04d62f1f1214a03c3b2d30f987dccf50ab4 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4426: d502f055ac4500cada758876a512ac4f14b34851 @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_8683: aa6ceaa62430ef2df33a85a9be4266b3b514c138 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4426: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8683/shards.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 0/9] GPU-bound energy efficiency improvements for the intel_pstate driver.

2018-04-12 Thread Francisco Jerez
Peter Zijlstra  writes:

> On Wed, Apr 11, 2018 at 09:26:11AM -0700, Francisco Jerez wrote:
>> "just like" here is possibly somewhat unfair to the schedutil governor,
>> admittedly its progressive IOWAIT boosting behavior seems somewhat less
>> wasteful than the intel_pstate non-HWP governor's IOWAIT boosting
>> behavior, but it's still largely unhelpful on IO-bound conditions.
>
> So you understand why we need the iowait boosting right?
>

Yeah, sort of.  The latency-minimizing state of this governor provides a
comparable effect, but it's based on a pessimistic estimate of the
frequency required for the workload to achieve maximum throughput
(rather than a plain or exponential boost up to the max frequency which
can substantially deviate from that frequency, see the explanation in
PATCH 6 for more details).  It's enabled under conditions partially
overlapping but not identical to iowait boosting: The optimization is
not applied under IO-bound conditions (in order to avoid impacting
energy efficiency negatively for zero or negative payoff), OTOH the
optimization is applied in some cases where the current governor
wouldn't, like RT-priority threads (that's the main difference with v2
I'm planning to send out next week).

> It is just that when we get back to runnable, we want to process the
> next data packet ASAP. See also here:
>
>   
> https://lkml.kernel.org/r/20170522082154.f57cqovterd2q...@hirez.programming.kicks-ass.net
>
> What I don't really understand is why it is costing so much power; after
> all, when we're in iowait the CPU is mostly idle and can power-gate.

The reason for the energy efficiency problem of iowait boosting is
precisely the greater oscillation between turbo and idle.  Say that
iowait boost increases the frequency by a factor alpha relative to the
optimal frequency f0 (in terms of energy efficiency) required to execute
some IO-bound workload.  This will cause the CPU to be busy for a
fraction of the time it was busy originally, approximately t1 = t0 /
alpha, which indeed divides the overall energy usage by a factor alpha,
but at the same time multiplies the instantaneous power consumption
while busy by a factor potentially much greater than alpha, since the
CPU's power curve is largely non-linear, and in fact approximately
convex within the frequency range allowed by the policy, so you get an
average energy usage possibly much greater than the optimal.


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


[Intel-gfx] ✓ Fi.CI.BAT: success for igt/prime_mmap: Test for userptr support first

2018-04-12 Thread Patchwork
== Series Details ==

Series: igt/prime_mmap: Test for userptr support first
URL   : https://patchwork.freedesktop.org/series/41638/
State : success

== Summary ==

= CI Bug Log - changes from IGT_4426 -> IGTPW_1251 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41638/revisions/1/mbox/

== Known issues ==

  Here are the changes found in IGTPW_1251 that come from known issues:

  === IGT changes ===

 Issues hit 

igt@gem_mmap_gtt@basic-small-bo-tiledx:
  fi-gdg-551: PASS -> FAIL (fdo#102575)

igt@gem_ringfill@basic-default-hang:
  fi-blb-e6850:   NOTRUN -> DMESG-WARN (fdo#101600)
  fi-pnv-d510:NOTRUN -> DMESG-WARN (fdo#101600)

igt@kms_flip@basic-flip-vs-wf_vblank:
  fi-cfl-s3:  PASS -> FAIL (fdo#103928, fdo#100368)


  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#101600 https://bugs.freedesktop.org/show_bug.cgi?id=101600
  fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
  fdo#103928 https://bugs.freedesktop.org/show_bug.cgi?id=103928


== Participating hosts (27 -> 33) ==

  Additional (8): fi-kbl-7567u fi-bxt-dsi fi-skl-gvtdvm fi-bdw-gvtdvm fi-cnl-y3 
fi-pnv-d510 fi-elk-e7500 fi-blb-e6850 
  Missing(2): fi-ilk-m540 fi-skl-6700hq 


== Build changes ==

* IGT: IGT_4426 -> IGTPW_1251
* Linux: CI_DRM_4048 -> CI_DRM_4049
* Piglit: piglit_4426 -> piglit_4428

  CI_DRM_4048: 8c59766aea748fef3de2711f69486cb37bef95bd @ 
git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_4049: 3dbfa04d62f1f1214a03c3b2d30f987dccf50ab4 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1251: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1251/
  IGT_4426: d502f055ac4500cada758876a512ac4f14b34851 @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  piglit_4426: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit
  piglit_4428: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1251/issues.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] ✓ Fi.CI.IGT: success for GMBUS changes (rev2)

2018-04-12 Thread Patchwork
== Series Details ==

Series: GMBUS changes (rev2)
URL   : https://patchwork.freedesktop.org/series/41632/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4049_full -> Patchwork_8682_full =

== Summary - WARNING ==

  Minor unknown changes coming with Patchwork_8682_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_8682_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41632/revisions/2/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in 
Patchwork_8682_full:

  === IGT changes ===

 Warnings 

igt@gem_mocs_settings@mocs-rc6-render:
  shard-kbl:  PASS -> SKIP


== Known issues ==

  Here are the changes found in Patchwork_8682_full that come from known issues:

  === IGT changes ===

 Possible fixes 

igt@kms_flip@2x-dpms-vs-vblank-race-interruptible:
  shard-hsw:  FAIL (fdo#103060) -> PASS +1

igt@kms_flip@plain-flip-ts-check-interruptible:
  shard-hsw:  FAIL (fdo#100368) -> PASS +1

igt@kms_sysfs_edid_timing:
  shard-apl:  WARN (fdo#100047) -> PASS


  fdo#100047 https://bugs.freedesktop.org/show_bug.cgi?id=100047
  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060


== Participating hosts (6 -> 4) ==

  Missing(2): shard-glk shard-glkb 


== Build changes ==

* Linux: CI_DRM_4049 -> Patchwork_8682

  CI_DRM_4049: 3dbfa04d62f1f1214a03c3b2d30f987dccf50ab4 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4426: d502f055ac4500cada758876a512ac4f14b34851 @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_8682: 47340a0ebaad023c949b0c000d3430c5d48c3091 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4426: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8682/shards.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH igt] igt/prime_mmap: Test for userptr support first

2018-04-12 Thread Chris Wilson
Before we start trying to use userptr to test interoperability with
PRIME, we first need to check that the device in question has userptr
support.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106013
Signed-off-by: Chris Wilson 
---
 tests/prime_mmap.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/tests/prime_mmap.c b/tests/prime_mmap.c
index 0da0aa68..67a6a232 100644
--- a/tests/prime_mmap.c
+++ b/tests/prime_mmap.c
@@ -307,6 +307,19 @@ static int prime_handle_to_fd_no_assert(uint32_t handle, 
int flags, int *fd_out)
return ret;
 }
 
+static bool has_userptr(void)
+{
+   uint32_t handle = 0;
+   void *ptr;
+
+   igt_assert(posix_memalign(, 4096, 4096) == 0);
+   if ( __gem_userptr(fd, ptr, 4096, 0, 0, ) == 0)
+   gem_close(fd, handle);
+   free(ptr);
+
+   return handle;
+}
+
 /* test for mmap(dma_buf_export(userptr)) */
 static void
 test_userptr(void)
@@ -315,6 +328,8 @@ test_userptr(void)
void *ptr;
uint32_t handle;
 
+   igt_require(has_userptr());
+
/* create userptr bo */
ret = posix_memalign(, 4096, BO_SIZE);
igt_assert_eq(ret, 0);
-- 
2.17.0

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


Re: [Intel-gfx] [PATCH v1] drm/i915/gen11: Preempt-to-idle support in execlists.

2018-04-12 Thread Lis, Tomasz



On 2018-03-30 20:23, Daniele Ceraolo Spurio wrote:



On 27/03/18 16:27, Chris Wilson wrote:

Quoting Tomasz Lis (2018-03-27 16:17:59)
The patch adds support of preempt-to-idle requesting by setting a 
proper
bit within Execlist Control Register, and receiving preemption 
result from

Context Status Buffer.

Preemption in previous gens required a special batch buffer to be 
executed,
so the Command Streamer never preempted to idle directly. In Icelake 
it is

possible, as there is a hardware mechanism to inform the kernel about
status of the preemption request.

This patch does not cover using the new preemption mechanism when 
GuC is

active.

Bspec: 18922
Signed-off-by: Tomasz Lis 
---
  drivers/gpu/drm/i915/i915_drv.h  |  2 ++
  drivers/gpu/drm/i915/i915_pci.c  |  3 ++-
  drivers/gpu/drm/i915/intel_device_info.h |  1 +
  drivers/gpu/drm/i915/intel_lrc.c | 45 
+++-

  drivers/gpu/drm/i915/intel_lrc.h |  1 +
  5 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h 
b/drivers/gpu/drm/i915/i915_drv.h

index 800230b..c32580b 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2514,6 +2514,8 @@ intel_info(const struct drm_i915_private 
*dev_priv)

 ((dev_priv)->info.has_logical_ring_elsq)
  #define HAS_LOGICAL_RING_PREEMPTION(dev_priv) \
((dev_priv)->info.has_logical_ring_preemption)
+#define HAS_HW_PREEMPT_TO_IDLE(dev_priv) \
+   ((dev_priv)->info.has_hw_preempt_to_idle)
    #define HAS_EXECLISTS(dev_priv) HAS_LOGICAL_RING_CONTEXTS(dev_priv)
  diff --git a/drivers/gpu/drm/i915/i915_pci.c 
b/drivers/gpu/drm/i915/i915_pci.c

index 4364922..66b6700 100644
--- a/drivers/gpu/drm/i915/i915_pci.c
+++ b/drivers/gpu/drm/i915/i915_pci.c
@@ -595,7 +595,8 @@ static const struct intel_device_info 
intel_cannonlake_info = {

 GEN(11), \
 .ddb_size = 2048, \
 .has_csr = 0, \
-   .has_logical_ring_elsq = 1
+   .has_logical_ring_elsq = 1, \
+   .has_hw_preempt_to_idle = 1
    static const struct intel_device_info intel_icelake_11_info = {
 GEN11_FEATURES,
diff --git a/drivers/gpu/drm/i915/intel_device_info.h 
b/drivers/gpu/drm/i915/intel_device_info.h

index 933e316..4eb97b5 100644
--- a/drivers/gpu/drm/i915/intel_device_info.h
+++ b/drivers/gpu/drm/i915/intel_device_info.h
@@ -98,6 +98,7 @@ enum intel_platform {
 func(has_logical_ring_contexts); \
 func(has_logical_ring_elsq); \
 func(has_logical_ring_preemption); \
+   func(has_hw_preempt_to_idle); \
 func(has_overlay); \
 func(has_pooled_eu); \
 func(has_psr); \
diff --git a/drivers/gpu/drm/i915/intel_lrc.c 
b/drivers/gpu/drm/i915/intel_lrc.c

index ba7f783..1a22de4 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -153,6 +153,7 @@
  #define GEN8_CTX_STATUS_ACTIVE_IDLE    (1 << 3)
  #define GEN8_CTX_STATUS_COMPLETE   (1 << 4)
  #define GEN8_CTX_STATUS_LITE_RESTORE   (1 << 15)
+#define GEN11_CTX_STATUS_PREEMPT_IDLE  (1 << 29)
    #define GEN8_CTX_STATUS_COMPLETED_MASK \
  (GEN8_CTX_STATUS_COMPLETE | GEN8_CTX_STATUS_PREEMPTED)
@@ -183,7 +184,9 @@ static inline bool need_preempt(const struct 
intel_engine_cs *engine,

 const struct i915_request *last,
 int prio)
  {
-   return engine->i915->preempt_context && prio > 
max(rq_prio(last), 0);

+   return (engine->i915->preempt_context ||
+   HAS_HW_PREEMPT_TO_IDLE(engine->i915)) &&


Well, you haven't actually disabled allocating the preempt_context so...

But at any rate, making this an engine->flag would eliminate one pointer
dance.



Can't we re-use I915_SCHEDULER_CAP_PREEMPTION in 
engine->i915->caps.scheduler? That btw like here to be set if 
i915->preempt_context || HAS_HW_PREEMPT_TO_IDLE(i915)
The engine->flag which Chris introduced is now used to set 
I915_SCHEDULER_CAP_PREEMPTION.



+    prio > max(rq_prio(last), 0);
  }
    /**
@@ -535,6 +538,25 @@ static void inject_preempt_context(struct 
intel_engine_cs *engine)
 execlists_set_active(>execlists, 
EXECLISTS_ACTIVE_PREEMPT);

  }
  +static void gen11_preempt_to_idle(struct intel_engine_cs *engine)
+{
+   struct intel_engine_execlists *execlists = >execlists;
+
+   GEM_TRACE("%s\n", engine->name);
+
+   /*
+    * hardware which HAS_HW_PREEMPT_TO_IDLE(), always also
+    * HAS_LOGICAL_RING_ELSQ(), so we can assume ctrl_reg is set
+    */
+   GEM_BUG_ON(execlists->ctrl_reg != NULL);


Shouldn't this check be the other way around?
Wow. I have no idea how I was able to test this patch and not trigger 
this. You are right.



+
+   /* trigger preemption to idle */
+   writel(EL_CTRL_PREEMPT_TO_IDLE, execlists->ctrl_reg);


Future plans? Because just inserting the branch into the setter of

[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Block enabling FBC until flips have been completed

2018-04-12 Thread Patchwork
== Series Details ==

Series: drm/i915: Block enabling FBC until flips have been completed
URL   : https://patchwork.freedesktop.org/series/41634/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4049 -> Patchwork_8683 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41634/revisions/1/mbox/

== Known issues ==

  Here are the changes found in Patchwork_8683 that come from known issues:

  === IGT changes ===

 Issues hit 

igt@gem_mmap_gtt@basic-small-bo-tiledx:
  fi-gdg-551: PASS -> FAIL (fdo#102575)

igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
  fi-bxt-dsi: PASS -> INCOMPLETE (fdo#103927)

igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
  fi-cnl-y3:  NOTRUN -> DMESG-FAIL (fdo#103191)


  fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
  fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
  fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927


== Participating hosts (35 -> 33) ==

  Additional (1): fi-cnl-y3 
  Missing(3): fi-ctg-p8600 fi-ilk-m540 fi-skl-6700hq 


== Build changes ==

* Linux: CI_DRM_4049 -> Patchwork_8683

  CI_DRM_4049: 3dbfa04d62f1f1214a03c3b2d30f987dccf50ab4 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4426: d502f055ac4500cada758876a512ac4f14b34851 @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_8683: aa6ceaa62430ef2df33a85a9be4266b3b514c138 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4426: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit


== Linux commits ==

aa6ceaa62430 drm/i915: Block enabling FBC until flips have been completed

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8683/issues.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] ✓ Fi.CI.IGT: success for drm/i915: Check whitelist registers across resets (rev2)

2018-04-12 Thread Patchwork
== Series Details ==

Series: drm/i915: Check whitelist registers across resets (rev2)
URL   : https://patchwork.freedesktop.org/series/41631/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4049_full -> Patchwork_8680_full =

== Summary - WARNING ==

  Minor unknown changes coming with Patchwork_8680_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_8680_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41631/revisions/2/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in 
Patchwork_8680_full:

  === IGT changes ===

 Warnings 

igt@gem_mocs_settings@mocs-rc6-blt:
  shard-kbl:  PASS -> SKIP +1

igt@gem_mocs_settings@mocs-rc6-vebox:
  shard-kbl:  SKIP -> PASS


== Known issues ==

  Here are the changes found in Patchwork_8680_full that come from known issues:

  === IGT changes ===

 Issues hit 

igt@kms_flip@2x-flip-vs-absolute-wf_vblank-interruptible:
  shard-hsw:  PASS -> FAIL (fdo#103928)

igt@kms_flip@2x-plain-flip-ts-check-interruptible:
  shard-hsw:  PASS -> FAIL (fdo#100368) +2

igt@kms_flip@absolute-wf_vblank:
  shard-kbl:  PASS -> DMESG-WARN (fdo#103558) +11


 Possible fixes 

igt@kms_flip@2x-dpms-vs-vblank-race-interruptible:
  shard-hsw:  FAIL (fdo#103060) -> PASS +1

igt@kms_flip@plain-flip-ts-check-interruptible:
  shard-hsw:  FAIL (fdo#100368) -> PASS +1


  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
  fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
  fdo#103928 https://bugs.freedesktop.org/show_bug.cgi?id=103928


== Participating hosts (6 -> 4) ==

  Missing(2): shard-glk shard-glkb 


== Build changes ==

* Linux: CI_DRM_4049 -> Patchwork_8680

  CI_DRM_4049: 3dbfa04d62f1f1214a03c3b2d30f987dccf50ab4 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4426: d502f055ac4500cada758876a512ac4f14b34851 @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_8680: 541de8069eef29c5d5ce23f2db7f10291f6b106f @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4426: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8680/shards.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] Incorrect plane programming sequence results into a corrupted display/hard hung system

2018-04-12 Thread Vyas, Tarun
On KBL platforms, with HW overlay and/or PSR2, a hard hang with corrupted 
display is observed while running tests that frequently disable/re-enable 
primary/overlay planes. Details recorded in this FDO bug: 
https://bugs.freedesktop.org/show_bug.cgi?id=104975.

The issue has been root caused as a race where only partial register updates 
get latched on the next vblank, specifically, the updates that give the buffer 
allocation of the current plane before disabling it (again, details captured in 
the FDO bug above). There have been several optimizations to work around this 
bug:

1.   Enable Isochronous priority control (IPC)

2.   Increase the vblank evasion time to 250 usec (We have tried 500 usec 
but that doesn't helps).

3.   Disable DOUBLE_BUFFER_CTL while the updates are done, inside 
intel_pipe_update_start and intel_pipe_update_end (doesn't helps)

4.   Grab all the required locks before starting the pipe_update.

Per Ville, none of the above optimizations guarantee a *full* update before the 
vblank. As a result, to fix this issue the right way, the plane programming 
sequence needs to be altered in the driver as mentioned below:

"Buffer allocation overlap among enabled planes will cause a full frame 
underrun, and that becomes a hard hange if pkgC or SAGV are enabled.
You need to make sure the plane is disabled before reallocating the buffer it 
uses.  For a single pipe it is sufficient to initiate the disabling of the 
plane before the reallocation.  For multiple pipes it can be more complex.
In this case you should be doing something like this to ensure plane 2A turns 
off before plane 1A steals the buffer


1. PLANE_CTL_2A -> disabled

2.   PLANE_SURF_2A:  touch to arm double buffer update

3.   PLANE_BUF_CFG_1A -> (0-860)

4.   PLANE_SURF_1A: touch to arm double buffer update
If the planes are on different pipes there needs to be a wait for vblank 
between step 2 and 3 to ensure the plane 2A disable completed."


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


[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Block enabling FBC until flips have been completed

2018-04-12 Thread Patchwork
== Series Details ==

Series: drm/i915: Block enabling FBC until flips have been completed
URL   : https://patchwork.freedesktop.org/series/41634/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
aa6ceaa62430 drm/i915: Block enabling FBC until flips have been completed
-:92: CHECK:BRACES: braces {} should be used on all arms of this statement
#92: FILE: drivers/gpu/drm/i915/intel_fbc.c:1006:
+   if (!fbc->busy_bits) {
[...]
+   } else
[...]

-:95: CHECK:BRACES: Unbalanced braces around else statement
#95: FILE: drivers/gpu/drm/i915/intel_fbc.c:1009:
+   } else

total: 0 errors, 0 warnings, 2 checks, 82 lines checked

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


[Intel-gfx] ✓ Fi.CI.BAT: success for GMBUS changes (rev2)

2018-04-12 Thread Patchwork
== Series Details ==

Series: GMBUS changes (rev2)
URL   : https://patchwork.freedesktop.org/series/41632/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4049 -> Patchwork_8682 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41632/revisions/2/mbox/

== Known issues ==

  Here are the changes found in Patchwork_8682 that come from known issues:

  === IGT changes ===

 Issues hit 

igt@gem_mmap_gtt@basic-small-bo-tiledx:
  fi-gdg-551: PASS -> FAIL (fdo#102575)


  fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575


== Participating hosts (35 -> 33) ==

  Additional (1): fi-cnl-y3 
  Missing(3): fi-ctg-p8600 fi-ilk-m540 fi-skl-6700hq 


== Build changes ==

* Linux: CI_DRM_4049 -> Patchwork_8682

  CI_DRM_4049: 3dbfa04d62f1f1214a03c3b2d30f987dccf50ab4 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4426: d502f055ac4500cada758876a512ac4f14b34851 @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_8682: 47340a0ebaad023c949b0c000d3430c5d48c3091 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4426: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit


== Linux commits ==

47340a0ebaad drm/i915/gmbus: Enable burst read
f6b744bf9f24 drm/i915/gmbus: Increase the Bytes per Rd/Wr Op

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8682/issues.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for GMBUS changes (rev2)

2018-04-12 Thread Patchwork
== Series Details ==

Series: GMBUS changes (rev2)
URL   : https://patchwork.freedesktop.org/series/41632/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
f6b744bf9f24 drm/i915/gmbus: Increase the Bytes per Rd/Wr Op
47340a0ebaad drm/i915/gmbus: Enable burst read
-:25: CHECK:SPACING: spaces preferred around that '<<' (ctx:VxV)
#25: FILE: drivers/gpu/drm/i915/i915_reg.h:2999:
+#define   GMBUS_BYTE_CNT_OVERRIDE (1<<6)
 ^

total: 0 errors, 0 warnings, 1 checks, 79 lines checked

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


Re: [Intel-gfx] [RFC v4 00/25] drm: Add generic fbdev emulation

2018-04-12 Thread Noralf Trønnes
I hit a 'Sending rate exceeded' error with this patchset, so it didn't 
go out as it should.

I will resend the patchset when I find out how to avoid this problem.

Noralf.


Den 12.04.2018 15.17, skrev Noralf Trønnes:

This patchset explores the possibility of having generic fbdev emulation
in DRM for drivers that supports dumb buffers which they can export. An
API is added to support in-kernel clients in general.

In this version I was able to reuse the modesetting code from
drm_fb_helper in the client API. This avoids code duplication, carries
over lessons learned and the modesetting code is bisectable. The
downside is that it takes +10 patches to rip drm_fb_helper in two, so
maybe it's not worth it wrt possible breakage and a challenging review.

Does the Intel CI test the fbdev emulation?

Daniel had this concern with the previous version:

 The register/unregister model needs more thought. Allowing both clients
 to register whenever they want to, and drm_device instances to come and
 go is what fbcon has done, and the resulting locking is a horror show.

 I think if we require that all in-kernel drm_clients are registers when
 loading drm.ko (and enabled/disabled only per module options and
 Kconfig), then we can throw out all the locking. That avoids a lot of
 the headaches.

I have solved this by adding a notifier that fires when a new DRM device
is registered (I've removed the new() callback). Currently only
bootsplash uses this. The fbdev client needs to be setup from the driver
since it can't know on device registration if the driver will setup it's
own fbdev emulation later and the vtcon client hooks up to a user
provided device id.

Since fbcon can't handle fb_open failing, the buffer has to be
pre-allocated. Exporting a GEM buffer pins the driver module making it
impossible to unload it.
I have included 2 solutions to the problem:
- sysfs file to remove/close clients: remove_internal_clients
- Change drm_gem_prime_export() so it doesn't pin on client buffers

If a dumb buffer is exported from a kernel thread (worker) context, the
file descriptor isn't closed and I leak a reference so the buffer isn't
freed. Please look at drm_client_buffer_create() in patch
'drm/client: Finish the in-kernel client API'.
This is a blocker that needs a solution.


Noralf.

Changes since version 3:
Client API changes:
- Drop drm_client_register_funcs() which attached clients indirectly.
   Let clients attach directly using drm_client_new{_from_id}(). Clients
   that wants to attach to all devices must be linked into drm.ko and use
   the DRM device notifier. This is done to avoid the lock/race
   register/unregister hell we have with fbcon. (Daniel Vetter)
- drm_client_display_restore() checks if there is a master and if so
   returns -EBUSY. (Daniel Vetter)
- Allocate drm_file up front instead of on-demand. Since fbdev can't do
   on demand buffer allocation because of fbcon, there's no need for this.
- Add sysfs file to remove clients
- Don't pin driver module when exporting gem client buffers
- Dropped page flip support since drm_fb_helper is now used for fbdev
   emulation.

- The bootsplash client now switches over to fbdev on keypress.

Changes since version 2:
- Don't set drm master for in-kernel clients. (Daniel Vetter)
- Add in-kernel client API

Changes since version 1:
- Don't add drm_fb_helper_fb_open() and drm_fb_helper_fb_release() to
   DRM_FB_HELPER_DEFAULT_OPS(). (Fi.CI.STATIC)
   The following uses that macro and sets fb_open/close: udlfb_ops,
   amdgpufb_ops, drm_fb_helper_generic_fbdev_ops, nouveau_fbcon_ops,
   nouveau_fbcon_sw_ops, radeonfb_ops.
   This results in: warning: Initializer entry defined twice
- Support CONFIG_DRM_KMS_HELPER=m (kbuild test robot)
   ERROR:  [drivers/gpu/drm/drm_kms_helper.ko] undefined!
- Drop buggy patch: (Chris Wilson)
   drm/prime: Clear drm_gem_object->dma_buf on release
- Defer buffer creation until fb_open.


David Herrmann (1):
   drm: provide management functions for drm_file

Noralf Trønnes (24):
   drm/file: Don't set master on in-kernel clients
   drm/fb-helper: No need to cache rotation and sw_rotations
   drm/fb-helper: Remove drm_fb_helper_debug_enter/leave()
   drm/fb-helper: dpms_legacy(): Only set on connectors in use
   drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()
   drm: Begin an API for in-kernel clients
   drm/fb-helper: Use struct drm_client_display
   drm/fb-helper: Move modeset commit code to drm_client
   drm/connector: Add
 drm_connector_has_preferred_mode/pick_cmdline_mode()
   drm/connector: Add connector array functions
   drm/i915: Add drm_driver->initial_client_display callback
   drm/fb-helper: Remove struct drm_fb_helper_crtc
   drm/fb-helper: Remove struct drm_fb_helper_connector
   drm/fb-helper: Move modeset config code to drm_client
   drm: Make ioctls available for in-kernel clients
   drm/client: Bail out if there's a DRM master
   drm/client: Make the display modes 

[Intel-gfx] ✓ Fi.CI.IGT: success for drm/i915/cnl: Use mmio access to context status buffer

2018-04-12 Thread Patchwork
== Series Details ==

Series: drm/i915/cnl: Use mmio access to context status buffer
URL   : https://patchwork.freedesktop.org/series/41630/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4049_full -> Patchwork_8679_full =

== Summary - WARNING ==

  Minor unknown changes coming with Patchwork_8679_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_8679_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41630/revisions/1/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in 
Patchwork_8679_full:

  === IGT changes ===

 Warnings 

igt@gem_mocs_settings@mocs-rc6-blt:
  shard-kbl:  PASS -> SKIP

igt@gem_mocs_settings@mocs-rc6-vebox:
  shard-kbl:  SKIP -> PASS


== Known issues ==

  Here are the changes found in Patchwork_8679_full that come from known issues:

  === IGT changes ===

 Issues hit 

igt@kms_flip@2x-flip-vs-expired-vblank-interruptible:
  shard-hsw:  PASS -> FAIL (fdo#102887) +1

igt@kms_frontbuffer_tracking@fbc-1p-pri-indfb-multidraw:
  shard-apl:  PASS -> FAIL (fdo#103167)

igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-render:
  shard-snb:  PASS -> FAIL (fdo#103167)

igt@kms_pipe_crc_basic@read-crc-pipe-b-frame-sequence:
  shard-apl:  PASS -> FAIL (fdo#103191)


 Possible fixes 

igt@kms_flip@2x-dpms-vs-vblank-race-interruptible:
  shard-hsw:  FAIL (fdo#103060) -> PASS +1

igt@kms_flip@plain-flip-ts-check-interruptible:
  shard-hsw:  FAIL (fdo#100368) -> PASS +1


  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
  fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191


== Participating hosts (6 -> 4) ==

  Missing(2): shard-glk shard-glkb 


== Build changes ==

* Linux: CI_DRM_4049 -> Patchwork_8679

  CI_DRM_4049: 3dbfa04d62f1f1214a03c3b2d30f987dccf50ab4 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4426: d502f055ac4500cada758876a512ac4f14b34851 @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_8679: ec952dc37d185165b612080cc6f1683593c275a1 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4426: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8679/shards.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFC v4 24/25] drm/client: Hack: Add bootsplash

2018-04-12 Thread Noralf Trønnes
A hack to test the client API.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/Kconfig |   2 +
 drivers/gpu/drm/Makefile|   1 +
 drivers/gpu/drm/client/Kconfig  |   9 ++
 drivers/gpu/drm/client/drm_bootsplash.c | 248 
 drivers/gpu/drm/client/internal.h   |  19 +++
 drivers/gpu/drm/drm_client.c|   4 +
 6 files changed, 283 insertions(+)
 create mode 100644 drivers/gpu/drm/client/Kconfig
 create mode 100644 drivers/gpu/drm/client/drm_bootsplash.c
 create mode 100644 drivers/gpu/drm/client/internal.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 757825ac60df..1328202ce17d 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -154,6 +154,8 @@ config DRM_SCHED
tristate
depends on DRM
 
+source "drivers/gpu/drm/client/Kconfig"
+
 source "drivers/gpu/drm/i2c/Kconfig"
 
 source "drivers/gpu/drm/arm/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index d25afa136d8f..388527093f80 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -30,6 +30,7 @@ drm-$(CONFIG_OF) += drm_of.o
 drm-$(CONFIG_AGP) += drm_agpsupport.o
 drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
 drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
+drm-$(CONFIG_DRM_CLIENT_BOOTSPLASH) += client/drm_bootsplash.o
 
 drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
diff --git a/drivers/gpu/drm/client/Kconfig b/drivers/gpu/drm/client/Kconfig
new file mode 100644
index ..6b01f2e51fb3
--- /dev/null
+++ b/drivers/gpu/drm/client/Kconfig
@@ -0,0 +1,9 @@
+menu "DRM Clients"
+   depends on DRM
+
+config DRM_CLIENT_BOOTSPLASH
+   bool "DRM Bootsplash"
+   help
+ DRM Bootsplash
+
+endmenu
diff --git a/drivers/gpu/drm/client/drm_bootsplash.c 
b/drivers/gpu/drm/client/drm_bootsplash.c
new file mode 100644
index ..bec3105f9b02
--- /dev/null
+++ b/drivers/gpu/drm/client/drm_bootsplash.c
@@ -0,0 +1,248 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// drm_lastclose()
+#include 
+#include "drm_internal.h"
+
+static bool drm_bootsplash_enabled = true;
+module_param_named(bootsplash_enabled, drm_bootsplash_enabled, bool, 0600);
+MODULE_PARM_DESC(bootsplash_enabled, "Enable bootsplash client 
[default=true]");
+
+struct drm_bootsplash {
+   struct drm_client_dev *client;
+   struct drm_client_display *display;
+   struct drm_client_buffer *buffer[2];
+   struct work_struct worker;
+   bool stop;
+};
+
+static bool drm_bootsplash_key_pressed;
+
+static int drm_bootsplash_keyboard_notifier_call(struct notifier_block *blk,
+ unsigned long code, void *_param)
+{
+   /* Any key is good */
+   drm_bootsplash_key_pressed = true;
+
+   return NOTIFY_OK;
+}
+
+static struct notifier_block drm_bootsplash_keyboard_notifier_block = {
+   .notifier_call = drm_bootsplash_keyboard_notifier_call,
+};
+
+static u32 drm_bootsplash_color_table[3] = {
+   0x00ff, 0xff00, 0x00ff,
+};
+
+/* Draw a box with changing colors */
+static void
+drm_bootsplash_draw(struct drm_client_buffer *buffer, unsigned int sequence)
+{
+   unsigned int x, y;
+   u32 *pix;
+
+   pix = buffer->vaddr;
+   pix += ((buffer->height / 2) - 50) * buffer->width;
+   pix += (buffer->width / 2) - 50;
+
+   for (y = 0; y < 100; y++) {
+   for (x = 0; x < 100; x++)
+   *pix++ = drm_bootsplash_color_table[sequence];
+   pix += buffer->width - 100;
+   }
+}
+
+static void drm_bootsplash_worker(struct work_struct *work)
+{
+   struct drm_bootsplash *splash = container_of(work, struct 
drm_bootsplash, worker);
+   struct drm_device *dev = splash->client->dev;
+   unsigned int i = 0, sequence = 0;
+   struct drm_framebuffer *fb;
+   int ret = 0;
+
+   while (!splash->stop && !drm_bootsplash_key_pressed) {
+   /* Did someone take over, like another in-kernel client, except 
fbdev? */
+   fb = drm_client_display_current_fb(splash->display);
+   if (splash->buffer[i]->fb != fb &&
+   !(dev->fb_helper && dev->fb_helper->fb == fb))
+   break;
+
+   i = !i;
+   drm_bootsplash_draw(splash->buffer[i], sequence++);
+   if (sequence == 3)
+   sequence = 0;
+
+   ret = drm_client_display_commit(splash->display, 
splash->buffer[i]->fb, NULL);
+   /* Is userspace in charge or is the device unplugged? */
+   if (ret == -EBUSY || ret == -ENODEV)
+   break;
+
+   msleep(500);
+ 

[Intel-gfx] [RFC v4 22/25] drm/fb-helper: Add generic fbdev emulation

2018-04-12 Thread Noralf Trønnes
This adds generic fbdev emulation for drivers that supports
dumb buffers which they can export.

All the driver has to do is call drm_fbdev_generic_setup().

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 255 
 include/drm/drm_fb_helper.h |  20 
 2 files changed, 275 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index b1124c08b1ed..1954de5b13e0 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -30,6 +30,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1995,6 +1996,260 @@ void drm_fb_helper_output_poll_changed(struct 
drm_device *dev)
 }
 EXPORT_SYMBOL(drm_fb_helper_output_poll_changed);
 
+static int drm_fbdev_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
+{
+   struct drm_fb_helper *fb_helper = info->par;
+
+   return dma_buf_mmap(fb_helper->buffer->dma_buf, vma, 0);
+}
+
+/*
+ * fb_ops.fb_destroy is called by the last put_fb_info() call at the end of
+ * unregister_framebuffer() or fb_release().
+ */
+static void drm_fbdev_fb_destroy(struct fb_info *info)
+{
+   struct drm_fb_helper *fb_helper = info->par;
+   struct fb_ops *fbops = NULL;
+
+   DRM_DEBUG("\n");
+
+   if (fb_helper->fbdev->fbdefio)
+   fbops = fb_helper->fbdev->fbops;
+
+   drm_fb_helper_fini(fb_helper);
+   drm_client_framebuffer_delete(fb_helper->buffer);
+   drm_client_free(fb_helper->client);
+   kfree(fb_helper);
+   kfree(fbops);
+}
+
+static struct fb_ops drm_fbdev_fb_ops = {
+   /*
+* No need to set owner, this module is already pinned by the driver.
+* A reference is taken on the driver module in drm_fb_helper_fb_open()
+* to prevent the driver going away with open fd's.
+*/
+   DRM_FB_HELPER_DEFAULT_OPS,
+   .fb_open= drm_fb_helper_fb_open,
+   .fb_release = drm_fb_helper_fb_release,
+   .fb_destroy = drm_fbdev_fb_destroy,
+   .fb_mmap= drm_fbdev_fb_mmap,
+   .fb_read= drm_fb_helper_sys_read,
+   .fb_write   = drm_fb_helper_sys_write,
+   .fb_fillrect= drm_fb_helper_sys_fillrect,
+   .fb_copyarea= drm_fb_helper_sys_copyarea,
+   .fb_imageblit   = drm_fb_helper_sys_imageblit,
+};
+
+static struct fb_deferred_io drm_fbdev_defio = {
+   .delay  = HZ / 20,
+   .deferred_io= drm_fb_helper_deferred_io,
+};
+
+/* Hack to test tinydrm before converting to vmalloc buffers */
+static int drm_fbdev_cma_deferred_io_mmap(struct fb_info *info,
+ struct vm_area_struct *vma)
+{
+   fb_deferred_io_mmap(info, vma);
+   vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+
+   return 0;
+}
+
+static int drm_fb_helper_generic_probe(struct drm_fb_helper *fb_helper,
+  struct drm_fb_helper_surface_size *sizes)
+{
+   struct drm_client_dev *client = fb_helper->client;
+   struct drm_display_mode sizes_mode = {
+   .hdisplay = sizes->surface_width,
+   .vdisplay = sizes->surface_height,
+   };
+   struct drm_client_buffer *buffer;
+   struct drm_framebuffer *fb;
+   struct fb_info *fbi;
+   u32 format;
+   int ret;
+
+   DRM_DEBUG_KMS("surface width(%d), height(%d) and bpp(%d)\n",
+ sizes->surface_width, sizes->surface_height,
+ sizes->surface_bpp);
+
+   format = drm_mode_legacy_fb_format(sizes->surface_bpp, 
sizes->surface_depth);
+   buffer = drm_client_framebuffer_create(client, _mode, format);
+   if (IS_ERR(buffer))
+   return PTR_ERR(buffer);
+
+   fb_helper->buffer = buffer;
+   fb_helper->fb = buffer->fb;
+   fb = buffer->fb;
+
+   fbi = drm_fb_helper_alloc_fbi(fb_helper);
+   if (IS_ERR(fbi)) {
+   ret = PTR_ERR(fbi);
+   goto err_free_buffer;
+   }
+
+   fbi->par = fb_helper;
+   fbi->fbops = _fbdev_fb_ops;
+   fbi->screen_size = fb->height * fb->pitches[0];
+   fbi->fix.smem_len = fbi->screen_size;
+   fbi->screen_buffer = buffer->vaddr;
+   strcpy(fbi->fix.id, "DRM emulated");
+
+   drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
+   drm_fb_helper_fill_var(fbi, fb_helper, sizes->fb_width, 
sizes->fb_height);
+
+   /*
+* Drivers that set the dirty callback:
+* - Doesn't use defio:
+*   i915, virtio, rockchip
+* - defio with vmalloc buffer blitted on the real one:
+*   vmwgfx
+* - defio is disabled because it doesn't work with shmem:
+*   udl
+* - defio with special dirty callback for fbdev, uses vmalloc for 
fbdev:
+*   qxl
+* - defio with cma buffer, will move to vmalloc buffers:
+*   tinydrm
+

[Intel-gfx] [RFC v4 23/25] drm: Add DRM device registered notifier

2018-04-12 Thread Noralf Trønnes
Add a notifier that fires when a new DRM device is registered.
This can be used by the bootsplash client to connect to all devices.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_drv.c | 32 
 include/drm/drm_drv.h |  4 
 2 files changed, 36 insertions(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 6f21bafb29be..e42ce320ad07 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -79,6 +80,8 @@ static struct dentry *drm_debugfs_root;
 
 DEFINE_STATIC_SRCU(drm_unplug_srcu);
 
+static BLOCKING_NOTIFIER_HEAD(drm_dev_notifier);
+
 /*
  * DRM Minors
  * A DRM device can provide several char-dev interfaces on the DRM-Major. Each
@@ -837,6 +840,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long 
flags)
 dev->dev ? dev_name(dev->dev) : "virtual device",
 dev->primary->index);
 
+   blocking_notifier_call_chain(_dev_notifier, 0, dev);
+
goto out_unlock;
 
 err_minors:
@@ -894,6 +899,33 @@ void drm_dev_unregister(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_dev_unregister);
 
+/**
+ * drm_dev_register_notifier - Register a notifier for new DRM devices
+ * @nb: Notifier block
+ *
+ * Register a notifier that fires when a new _device is registered.
+ *
+ * Note:
+ * Users of this function has to be linked into drm.ko. This is done to make
+ * life simple avoiding tricky race situations.
+ */
+void drm_dev_register_notifier(struct notifier_block *nb)
+{
+   /* Currently this can't fail, but catch it in case this changes */
+   WARN_ON(blocking_notifier_chain_register(_dev_notifier, nb));
+}
+
+/**
+ * drm_dev_unregister_notifier - Unregister DRM device notifier
+ * @nb: Notifier block
+ *
+ * This is a no-op if the notifier isn't registered.
+ */
+void drm_dev_unregister_notifier(struct notifier_block *nb)
+{
+   blocking_notifier_chain_unregister(_dev_notifier, nb);
+}
+
 /**
  * drm_dev_set_unique - Set the unique name of a DRM device
  * @dev: device of which to set the unique name
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 13356e6fd40c..5e6c6ed0d59d 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -40,6 +40,7 @@ struct drm_minor;
 struct dma_buf_attachment;
 struct drm_display_mode;
 struct drm_mode_create_dumb;
+struct notifier_block;
 struct drm_printer;
 
 /* driver capabilities and requirements mask */
@@ -641,6 +642,9 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
 int drm_dev_register(struct drm_device *dev, unsigned long flags);
 void drm_dev_unregister(struct drm_device *dev);
 
+void drm_dev_register_notifier(struct notifier_block *nb);
+void drm_dev_unregister_notifier(struct notifier_block *nb);
+
 void drm_dev_get(struct drm_device *dev);
 void drm_dev_put(struct drm_device *dev);
 void drm_dev_unref(struct drm_device *dev);
-- 
2.15.1

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


[Intel-gfx] [RFC v4 13/25] drm/fb-helper: Remove struct drm_fb_helper_crtc

2018-04-12 Thread Noralf Trønnes
The stage is now set for a clean removal of drm_fb_helper_crtc.
struct drm_client_display is doing its job now.

Also remove the drm_fb_helper_funcs->initial_config which has been
superseded by drm_driver->initial_client_display.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 124 +---
 include/drm/drm_fb_helper.h |  31 --
 2 files changed, 26 insertions(+), 129 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 5407bf6dc8c0..ce38eadcb346 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -443,24 +443,6 @@ int drm_fb_helper_blank(int blank, struct fb_info *info)
 }
 EXPORT_SYMBOL(drm_fb_helper_blank);
 
-static void drm_fb_helper_modeset_release(struct drm_fb_helper *helper,
- struct drm_mode_set *modeset)
-{
-   int i;
-
-   for (i = 0; i < modeset->num_connectors; i++) {
-   drm_connector_put(modeset->connectors[i]);
-   modeset->connectors[i] = NULL;
-   }
-   modeset->num_connectors = 0;
-
-   drm_mode_destroy(helper->dev, modeset->mode);
-   modeset->mode = NULL;
-
-   /* FIXME should hold a ref? */
-   modeset->fb = NULL;
-}
-
 static void drm_fb_helper_crtc_free(struct drm_fb_helper *helper)
 {
int i;
@@ -470,14 +452,6 @@ static void drm_fb_helper_crtc_free(struct drm_fb_helper 
*helper)
kfree(helper->connector_info[i]);
}
kfree(helper->connector_info);
-
-   for (i = 0; i < helper->crtc_count; i++) {
-   struct drm_mode_set *modeset = >crtc_info[i].mode_set;
-
-   drm_fb_helper_modeset_release(helper, modeset);
-   kfree(modeset->connectors);
-   }
-   kfree(helper->crtc_info);
 }
 
 static void drm_fb_helper_resume_worker(struct work_struct *work)
@@ -552,48 +526,18 @@ int drm_fb_helper_init(struct drm_device *dev,
   struct drm_fb_helper *fb_helper,
   int max_conn_count)
 {
-   struct drm_crtc *crtc;
-   struct drm_mode_config *config = >mode_config;
-   int i;
-
if (!drm_fbdev_emulation) {
dev->fb_helper = fb_helper;
return 0;
}
 
-   if (!max_conn_count)
-   return -EINVAL;
-
-   fb_helper->crtc_info = kcalloc(config->num_crtc, sizeof(struct 
drm_fb_helper_crtc), GFP_KERNEL);
-   if (!fb_helper->crtc_info)
-   return -ENOMEM;
-
-   fb_helper->crtc_count = config->num_crtc;
fb_helper->connector_info = kcalloc(dev->mode_config.num_connector, 
sizeof(struct drm_fb_helper_connector *), GFP_KERNEL);
-   if (!fb_helper->connector_info) {
-   kfree(fb_helper->crtc_info);
+   if (!fb_helper->connector_info)
return -ENOMEM;
-   }
+
fb_helper->connector_info_alloc_count = dev->mode_config.num_connector;
fb_helper->connector_count = 0;
 
-   for (i = 0; i < fb_helper->crtc_count; i++) {
-   fb_helper->crtc_info[i].mode_set.connectors =
-   kcalloc(max_conn_count,
-   sizeof(struct drm_connector *),
-   GFP_KERNEL);
-
-   if (!fb_helper->crtc_info[i].mode_set.connectors)
-   goto out_free;
-   fb_helper->crtc_info[i].mode_set.num_connectors = 0;
-   }
-
-   i = 0;
-   drm_for_each_crtc(crtc, dev) {
-   fb_helper->crtc_info[i].mode_set.crtc = crtc;
-   i++;
-   }
-
fb_helper->display = drm_client_display_create(dev);
if (IS_ERR(fb_helper->display))
goto out_free;
@@ -1830,7 +1774,7 @@ static bool drm_target_cloned(struct drm_fb_helper 
*fb_helper,
struct drm_display_mode *dmt_mode, *mode;
 
/* only contemplate cloning in the single crtc case */
-   if (fb_helper->crtc_count > 1)
+   if (fb_helper->dev->mode_config.num_crtc > 1)
return false;
 
count = 0;
@@ -1997,16 +1941,18 @@ static bool drm_target_preferred(struct drm_fb_helper 
*fb_helper,
 }
 
 static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
- struct drm_fb_helper_crtc **best_crtcs,
+ struct drm_crtc **best_crtcs,
  struct drm_display_mode **modes,
  int n, int width, int height)
 {
-   int c, o;
+   struct drm_client_display *display = fb_helper->display;
+   struct drm_device *dev = display->dev;
+   int o, my_score, best_score, score;
struct drm_connector *connector;
const struct drm_connector_helper_funcs *connector_funcs;
+   struct drm_mode_set *modeset;
struct drm_encoder *encoder;
-   int my_score, best_score, score;
-   struct drm_fb_helper_crtc **crtcs, *crtc;
+   struct 

[Intel-gfx] [RFC v4 14/25] drm/fb-helper: Remove struct drm_fb_helper_connector

2018-04-12 Thread Noralf Trønnes
No need to maintain a list of registered connectors. Just use the
connector iterator.

TODO: Remove:
- drm_fb_helper_add_one_connector()
- drm_fb_helper_single_add_all_connectors()
- drm_fb_helper_remove_one_connector()

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 359 ++--
 include/drm/drm_fb_helper.h |  13 --
 2 files changed, 86 insertions(+), 286 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index ce38eadcb346..6ee61f195321 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -112,59 +112,10 @@ static DEFINE_MUTEX(kernel_fb_helper_lock);
  * deferred I/O (coupled with drm_fb_helper_fbdev_teardown()).
  */
 
-#define drm_fb_helper_for_each_connector(fbh, i__) \
-   for (({ lockdep_assert_held(&(fbh)->lock); }), \
-i__ = 0; i__ < (fbh)->connector_count; i__++)
-
-static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,
-struct drm_connector *connector)
-{
-   struct drm_fb_helper_connector *fb_conn;
-   struct drm_fb_helper_connector **temp;
-   unsigned int count;
-
-   if (!drm_fbdev_emulation)
-   return 0;
-
-   lockdep_assert_held(_helper->lock);
-
-   count = fb_helper->connector_count + 1;
-
-   if (count > fb_helper->connector_info_alloc_count) {
-   size_t size = count * sizeof(fb_conn);
-
-   temp = krealloc(fb_helper->connector_info, size, GFP_KERNEL);
-   if (!temp)
-   return -ENOMEM;
-
-   fb_helper->connector_info_alloc_count = count;
-   fb_helper->connector_info = temp;
-   }
-
-   fb_conn = kzalloc(sizeof(*fb_conn), GFP_KERNEL);
-   if (!fb_conn)
-   return -ENOMEM;
-
-   drm_connector_get(connector);
-   fb_conn->connector = connector;
-   fb_helper->connector_info[fb_helper->connector_count++] = fb_conn;
-
-   return 0;
-}
-
 int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,
struct drm_connector *connector)
 {
-   int err;
-
-   if (!fb_helper)
-   return 0;
-
-   mutex_lock(_helper->lock);
-   err = __drm_fb_helper_add_one_connector(fb_helper, connector);
-   mutex_unlock(_helper->lock);
-
-   return err;
+   return 0;
 }
 EXPORT_SYMBOL(drm_fb_helper_add_one_connector);
 
@@ -184,87 +135,14 @@ EXPORT_SYMBOL(drm_fb_helper_add_one_connector);
  */
 int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)
 {
-   struct drm_device *dev;
-   struct drm_connector *connector;
-   struct drm_connector_list_iter conn_iter;
-   int i, ret = 0;
-
-   if (!drm_fbdev_emulation || !fb_helper)
-   return 0;
-
-   dev = fb_helper->dev;
-
-   mutex_lock(_helper->lock);
-   drm_connector_list_iter_begin(dev, _iter);
-   drm_for_each_connector_iter(connector, _iter) {
-   ret = __drm_fb_helper_add_one_connector(fb_helper, connector);
-   if (ret)
-   goto fail;
-   }
-   goto out;
-
-fail:
-   drm_fb_helper_for_each_connector(fb_helper, i) {
-   struct drm_fb_helper_connector *fb_helper_connector =
-   fb_helper->connector_info[i];
-
-   drm_connector_put(fb_helper_connector->connector);
-
-   kfree(fb_helper_connector);
-   fb_helper->connector_info[i] = NULL;
-   }
-   fb_helper->connector_count = 0;
-out:
-   drm_connector_list_iter_end(_iter);
-   mutex_unlock(_helper->lock);
-
-   return ret;
-}
-EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors);
-
-static int __drm_fb_helper_remove_one_connector(struct drm_fb_helper 
*fb_helper,
-   struct drm_connector *connector)
-{
-   struct drm_fb_helper_connector *fb_helper_connector;
-   int i, j;
-
-   if (!drm_fbdev_emulation)
-   return 0;
-
-   lockdep_assert_held(_helper->lock);
-
-   drm_fb_helper_for_each_connector(fb_helper, i) {
-   if (fb_helper->connector_info[i]->connector == connector)
-   break;
-   }
-
-   if (i == fb_helper->connector_count)
-   return -EINVAL;
-   fb_helper_connector = fb_helper->connector_info[i];
-   drm_connector_put(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];
-
-   fb_helper->connector_count--;
-   kfree(fb_helper_connector);
-
return 0;
 }
+EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors);
 
 int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
   struct drm_connector 

[Intel-gfx] [RFC v4 19/25] drm/client: Finish the in-kernel client API

2018-04-12 Thread Noralf Trønnes
The modesetting code is already present, this adds the rest of the API.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_client.c   | 573 +
 drivers/gpu/drm/drm_debugfs.c  |   7 +
 drivers/gpu/drm/drm_drv.c  |  11 +
 drivers/gpu/drm/drm_file.c |   3 +
 drivers/gpu/drm/drm_probe_helper.c |   3 +
 drivers/gpu/drm/drm_sysfs.c|  20 ++
 include/drm/drm_client.h   | 103 +++
 include/drm/drm_device.h   |   4 +
 8 files changed, 724 insertions(+)

diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index bce1630a0db2..760f1795f812 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -8,7 +8,9 @@
  * Copyright (c) 2007 Dave Airlie 
  */
 
+#include 
 #include 
+#include 
 #include 
 
 #include 
@@ -17,14 +19,280 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
+#include "drm_crtc_internal.h"
 #include "drm_internal.h"
 
 struct drm_client_display_offset {
int x, y;
 };
 
+static int drm_client_alloc_file(struct drm_client_dev *client)
+{
+   struct drm_device *dev = client->dev;
+   struct drm_file *file;
+
+   file = drm_file_alloc(dev->primary);
+   if (IS_ERR(file))
+   return PTR_ERR(file);
+
+   drm_dev_get(dev);
+
+   mutex_lock(>filelist_mutex);
+   list_add(>lhead, >filelist_internal);
+   mutex_unlock(>filelist_mutex);
+
+   client->file = file;
+
+   return 0;
+}
+
+static void drm_client_free_file(struct drm_client_dev *client)
+{
+   struct drm_device *dev = client->dev;
+
+   mutex_lock(>filelist_mutex);
+   list_del(>file->lhead);
+   mutex_unlock(>filelist_mutex);
+
+   drm_file_free(client->file);
+   drm_dev_put(dev);
+}
+
+struct drm_client_dev *
+drm_client_new(struct drm_device *dev, const struct drm_client_funcs *funcs)
+{
+   struct drm_client_dev *client;
+   int ret;
+
+   if (WARN_ON(!funcs->name))
+   return ERR_PTR(-EINVAL);
+
+   client = kzalloc(sizeof(*client), GFP_KERNEL);
+   if (!client)
+   return ERR_PTR(-ENOMEM);
+
+   client->dev = dev;
+   client->funcs = funcs;
+
+   ret = drm_client_alloc_file(client);
+   if (ret) {
+   kfree(client);
+   return ERR_PTR(ret);
+   }
+
+   mutex_lock(>clientlist_mutex);
+   list_add(>list, >clientlist);
+   mutex_unlock(>clientlist_mutex);
+
+   return client;
+}
+EXPORT_SYMBOL(drm_client_new);
+
+struct drm_client_dev *
+drm_client_new_from_id(unsigned int dev_id, const struct drm_client_funcs 
*funcs)
+{
+   struct drm_client_dev *client;
+   struct drm_minor *minor;
+
+   minor = drm_minor_acquire(dev_id);
+   if (IS_ERR(minor))
+   return ERR_CAST(minor);
+
+   client = drm_client_new(minor->dev, funcs);
+
+   drm_minor_release(minor);
+
+   return client;
+}
+EXPORT_SYMBOL(drm_client_new_from_id);
+
+/**
+ * drm_client_free - Free DRM client resources
+ * @client: DRM client
+ *
+ * This is called automatically on client removal unless the client returns
+ * non-zero in the _client_funcs->remove callback. The fbdev client does
+ * this when it can't close _file because userspace has an open fd.
+ *
+ * Note:
+ * If the client can't release it's resources on remove, it needs to hold a
+ * reference on the driver module to prevent the code from going away.
+ */
+void drm_client_free(struct drm_client_dev *client)
+{
+   DRM_DEV_DEBUG_KMS(client->dev->dev, "%s\n", client->funcs->name);
+   drm_client_free_file(client);
+   kfree(client);
+}
+EXPORT_SYMBOL(drm_client_free);
+
+static void drm_client_remove_locked(struct drm_client_dev *client)
+{
+   list_del(>list);
+
+   if (!client->funcs->remove || !client->funcs->remove(client))
+   drm_client_free(client);
+}
+
+static void drm_client_remove_safe(struct drm_device *dev,
+  struct drm_client_dev *client)
+{
+   struct drm_client_dev *iter;
+
+   mutex_lock(>clientlist_mutex);
+   list_for_each_entry(iter, >clientlist, list) {
+   if (iter == client) {
+   drm_client_remove_locked(client);
+   break;
+   }
+   }
+   mutex_unlock(>clientlist_mutex);
+}
+
+/**
+ * drm_client_remove - Remove client
+ * @client: Client
+ *
+ * Remove a client.
+ */
+void drm_client_remove(struct drm_client_dev *client)
+{
+   struct drm_device *dev;
+
+   if (!client)
+   return;
+
+   dev = client->dev;
+   drm_dev_get(dev);
+   drm_client_remove_safe(dev, client);
+   drm_dev_put(dev);
+}
+EXPORT_SYMBOL(drm_client_remove);
+
+struct drm_client_remove_defer {
+   struct list_head list;
+   struct drm_device *dev;
+   struct drm_client_dev *client;
+};
+
+static LIST_HEAD(drm_client_remove_defer_list);

[Intel-gfx] [RFC v4 17/25] drm/client: Bail out if there's a DRM master

2018-04-12 Thread Noralf Trønnes
If there's a DRM master, return -EBUSY.
Block userspace from becoming master by taking the master lock while
the client is setting the mode.

Suggested-by: Daniel Vetter 
Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_auth.c  | 33 +
 drivers/gpu/drm/drm_client.c| 34 +-
 drivers/gpu/drm/drm_fb_helper.c |  8 
 drivers/gpu/drm/drm_internal.h  |  2 ++
 include/drm/drm_client.h|  4 ++--
 5 files changed, 70 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index d9c0f7573905..d656d0d93da3 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -366,3 +366,36 @@ void drm_master_put(struct drm_master **master)
*master = NULL;
 }
 EXPORT_SYMBOL(drm_master_put);
+
+/**
+ * drm_master_block - Block DRM master operations
+ * @dev: DRM device
+ *
+ * This function checks if there is a master on @dev. If there is no master it
+ * blocks anyone from becoming master. In-kernel clients can use this to know
+ * when they can act as master. Use drm_master_unblock() to unblock.
+ *
+ * Returns:
+ * True if there is no master, false otherwise.
+ */
+bool drm_master_block(struct drm_device *dev)
+{
+   mutex_lock(>master_mutex);
+   if (dev->master) {
+   mutex_unlock(>master_mutex);
+   return false;
+   }
+
+   return true;
+}
+
+/**
+ * drm_master_unblock - Unblock DRM master operations
+ * @dev: DRM device
+ *
+ * Unblock and allow userspace to become master.
+ */
+void drm_master_unblock(struct drm_device *dev)
+{
+   mutex_unlock(>master_mutex);
+}
diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index 27818a467b09..764c556630b8 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -18,6 +18,8 @@
 #include 
 #include 
 
+#include "drm_internal.h"
+
 struct drm_client_display_offset {
int x, y;
 };
@@ -313,18 +315,30 @@ static int drm_client_display_restore_legacy(struct 
drm_client_display *display)
 /**
  * drm_client_display_restore() - Restore client display
  * @display: Client display
+ * @force: If true, restore even if there's a DRM master
  *
  * Restore client display using the current modeset configuration.
  *
  * Return:
  * Zero on succes or negative error code on failure.
  */
-int drm_client_display_restore(struct drm_client_display *display)
+int drm_client_display_restore(struct drm_client_display *display, bool force)
 {
-   if (drm_drv_uses_atomic_modeset(display->dev))
-   return drm_client_display_restore_atomic(display, true);
+   struct drm_device *dev = display->dev;
+   int ret;
+
+   if (!force && !drm_master_block(dev))
+   return -EBUSY;
+
+   if (drm_drv_uses_atomic_modeset(dev))
+   ret = drm_client_display_restore_atomic(display, true);
else
-   return drm_client_display_restore_legacy(display);
+   ret = drm_client_display_restore_legacy(display);
+
+   if (!force)
+   drm_master_unblock(dev);
+
+   return ret;
 }
 EXPORT_SYMBOL(drm_client_display_restore);
 
@@ -354,13 +368,23 @@ static void drm_client_display_dpms_legacy(struct 
drm_client_display *display, i
  * drm_client_display_dpms() - Set display DPMS mode
  * @display: Client display
  * @mode: DPMS mode
+ *
+ * Returns:
+ * Zero on success, -EBUSY if there's a DRM master.
  */
-void drm_client_display_dpms(struct drm_client_display *display, int mode)
+int drm_client_display_dpms(struct drm_client_display *display, int mode)
 {
+   if (!drm_master_block(display->dev))
+   return -EBUSY;
+
if (drm_drv_uses_atomic_modeset(display->dev))
drm_client_display_restore_atomic(display, mode == 
DRM_MODE_DPMS_ON);
else
drm_client_display_dpms_legacy(display, mode);
+
+   drm_master_unblock(display->dev);
+
+   return 0;
 }
 EXPORT_SYMBOL(drm_client_display_dpms);
 
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 01d8840930a3..98e5bc92c9f2 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -181,7 +181,7 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct 
drm_fb_helper *fb_helper)
return 0;
 
mutex_lock(_helper->lock);
-   ret = drm_client_display_restore(fb_helper->display);
+   ret = drm_client_display_restore(fb_helper->display, false);
 
do_delayed = fb_helper->delayed_hotplug;
if (do_delayed)
@@ -243,7 +243,7 @@ static bool drm_fb_helper_force_kernel_mode(void)
continue;
 
mutex_lock(>lock);
-   ret = drm_client_display_restore(helper->display);
+   ret = drm_client_display_restore(helper->display, true);
if (ret)

[Intel-gfx] [RFC v4 21/25] drm/fb-helper: Add drm_fb_helper_fb_open/release()

2018-04-12 Thread Noralf Trønnes
These helpers keep track of fbdev users and drm_driver.last_close will
only restore fbdev when actually in use. Additionally the display is
turned off when the last user is closing. fbcon is a user in this context.

If struct fb_ops is defined in a library, fb_open() takes a ref on the
library (fb_ops.owner) instead of the driver module. Fix that by ensuring
that the driver module is pinned.

The functions are not added to the DRM_FB_HELPER_DEFAULT_OPS() macro,
because some of its users do set fb_open/release themselves.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 54 -
 include/drm/drm_fb_helper.h | 29 ++
 2 files changed, 82 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 98e5bc92c9f2..b1124c08b1ed 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -177,7 +177,7 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct 
drm_fb_helper *fb_helper)
if (!drm_fbdev_emulation || !fb_helper)
return -ENODEV;
 
-   if (READ_ONCE(fb_helper->deferred_setup))
+   if (READ_ONCE(fb_helper->deferred_setup) || 
!READ_ONCE(fb_helper->open_count))
return 0;
 
mutex_lock(_helper->lock);
@@ -368,6 +368,7 @@ void drm_fb_helper_prepare(struct drm_device *dev, struct 
drm_fb_helper *helper,
INIT_WORK(>dirty_work, drm_fb_helper_dirty_work);
helper->dirty_clip.x1 = helper->dirty_clip.y1 = ~0;
mutex_init(>lock);
+   helper->open_count = 1;
helper->funcs = funcs;
helper->dev = dev;
 }
@@ -620,6 +621,53 @@ int drm_fb_helper_defio_init(struct drm_fb_helper 
*fb_helper)
 }
 EXPORT_SYMBOL(drm_fb_helper_defio_init);
 
+/**
+ * drm_fb_helper_fb_open - implementation for _ops.fb_open
+ * @info: fbdev registered by the helper
+ * @user: 1=userspace, 0=fbcon
+ *
+ * Increase fbdev use count.
+ * If _ops is wrapped in a library, pin the driver module.
+ */
+int drm_fb_helper_fb_open(struct fb_info *info, int user)
+{
+   struct drm_fb_helper *fb_helper = info->par;
+   struct drm_device *dev = fb_helper->dev;
+
+   if (info->fbops->owner != dev->driver->fops->owner) {
+   if (!try_module_get(dev->driver->fops->owner))
+   return -ENODEV;
+   }
+
+   fb_helper->open_count++;
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_fb_helper_fb_open);
+
+/**
+ * drm_fb_helper_fb_release - implementation for _ops.fb_release
+ * @info: fbdev registered by the helper
+ * @user: 1=userspace, 0=fbcon
+ *
+ * Decrease fbdev use count and turn off if there are no users left.
+ * If _ops is wrapped in a library, unpin the driver module.
+ */
+int drm_fb_helper_fb_release(struct fb_info *info, int user)
+{
+   struct drm_fb_helper *fb_helper = info->par;
+   struct drm_device *dev = fb_helper->dev;
+
+   if (!(--fb_helper->open_count))
+   drm_fb_helper_dpms(info, DRM_MODE_DPMS_OFF);
+
+   if (info->fbops->owner != dev->driver->fops->owner)
+   module_put(dev->driver->fops->owner);
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_fb_helper_fb_release);
+
 /**
  * drm_fb_helper_sys_read - wrapper around fb_sys_read
  * @info: fb_info struct pointer
@@ -1436,6 +1484,10 @@ static int drm_fb_helper_single_fb_probe(struct 
drm_fb_helper *fb_helper,
if (ret < 0)
return ret;
 
+   /* Block restore without users if we do track it */
+   if (fb_helper->fbdev->fbops->fb_open == drm_fb_helper_fb_open)
+   fb_helper->open_count = 0;
+
strcpy(fb_helper->fb->comm, "[fbcon]");
return 0;
 }
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 5f66f253a97b..330983975d5e 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -184,6 +184,22 @@ struct drm_fb_helper {
 * See also: @deferred_setup
 */
int preferred_bpp;
+
+   /**
+* @open_count:
+*
+* Keeps track of fbdev use to know when to not restore fbdev and to
+* disable the pipeline when the last user is gone.
+*
+* Drivers that use drm_fb_helper_fb_open() as their \.fb_open
+* callback will get an initial value of 0 and get restore based on
+* actual use. Others will get an initial value of 1 which means that
+* fbdev will always be restored. Drivers that call
+* drm_fb_helper_fb_open() in their \.fb_open, thus needs to set the
+* initial value to 0 themselves in their _fb_helper_funcs->fb_probe
+* callback.
+*/
+   unsigned int open_count;
 };
 
 /**
@@ -230,6 +246,9 @@ void drm_fb_helper_deferred_io(struct fb_info *info,
   struct list_head *pagelist);
 int drm_fb_helper_defio_init(struct drm_fb_helper *fb_helper);
 
+int drm_fb_helper_fb_open(struct fb_info *info, int 

[Intel-gfx] [RFC v4 20/25] drm/prime: Don't pin module on export for in-kernel clients

2018-04-12 Thread Noralf Trønnes
Avoid pinning the module when exporting a GEM object as a dmabuf. This
makes it possible to unload drivers that has in-kernel clients using it.
The client is removed on drm_dev_unregister() so no need to pin the driver.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_prime.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index e6052ab2bec4..f9dbe3b9db20 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -567,6 +567,30 @@ struct dma_buf *drm_gem_prime_export(struct drm_device 
*dev,
.flags = flags,
.priv = obj,
};
+   bool is_internal = false;
+   struct drm_file *file;
+
+   mutex_lock(>filelist_mutex);
+   list_for_each_entry(file, >filelist_internal, lhead) {
+   struct drm_gem_object *iter;
+   int id;
+
+   spin_lock(>table_lock);
+   idr_for_each_entry(>object_idr, iter, id) {
+   if (iter == obj) {
+   is_internal = true;
+   break;
+   }
+   }
+   spin_unlock(>table_lock);
+
+   if (is_internal)
+   break;
+   }
+   mutex_unlock(>filelist_mutex);
+
+   if (is_internal)
+   exp_info.owner = NULL;
 
if (dev->driver->gem_prime_res_obj)
exp_info.resv = dev->driver->gem_prime_res_obj(obj);
-- 
2.15.1

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


[Intel-gfx] [RFC v4 16/25] drm: Make ioctls available for in-kernel clients

2018-04-12 Thread Noralf Trønnes
Make ioctl wrappers for functions that will be used by the in-kernel API.
The following functions are touched:
- drm_mode_create_dumb_ioctl()
- drm_mode_destroy_dumb_ioctl()
- drm_mode_addfb2()
- drm_mode_rmfb()
- drm_prime_handle_to_fd_ioctl()

drm_mode_addfb2() also gets the ability to override the debug name.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_crtc_internal.h | 18 ++---
 drivers/gpu/drm/drm_dumb_buffers.c  | 33 
 drivers/gpu/drm/drm_framebuffer.c   | 50 -
 drivers/gpu/drm/drm_internal.h  |  3 +++
 drivers/gpu/drm/drm_ioc32.c |  2 +-
 drivers/gpu/drm/drm_ioctl.c |  4 +--
 drivers/gpu/drm/drm_prime.c | 13 +++---
 7 files changed, 84 insertions(+), 39 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc_internal.h 
b/drivers/gpu/drm/drm_crtc_internal.h
index 3c2b82865ad2..8f8886ac0e4d 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -62,6 +62,12 @@ int drm_mode_getresources(struct drm_device *dev,
 
 
 /* drm_dumb_buffers.c */
+int drm_mode_create_dumb(struct drm_device *dev,
+struct drm_mode_create_dumb *args,
+struct drm_file *file_priv);
+int drm_mode_destroy_dumb(struct drm_device *dev, u32 handle,
+ struct drm_file *file_priv);
+
 /* IOCTLs */
 int drm_mode_create_dumb_ioctl(struct drm_device *dev,
   void *data, struct drm_file *file_priv);
@@ -163,14 +169,18 @@ int drm_framebuffer_check_src_coords(uint32_t src_x, 
uint32_t src_y,
 const struct drm_framebuffer *fb);
 void drm_fb_release(struct drm_file *file_priv);
 
+int drm_mode_addfb2(struct drm_device *dev, struct drm_mode_fb_cmd2 *r,
+   struct drm_file *file_priv, const char *comm);
+int drm_mode_rmfb(struct drm_device *dev, u32 fb_id,
+ struct drm_file *file_priv);
 
 /* IOCTL */
 int drm_mode_addfb(struct drm_device *dev,
   void *data, struct drm_file *file_priv);
-int drm_mode_addfb2(struct drm_device *dev,
-   void *data, struct drm_file *file_priv);
-int drm_mode_rmfb(struct drm_device *dev,
- void *data, struct drm_file *file_priv);
+int drm_mode_addfb2_ioctl(struct drm_device *dev,
+ void *data, struct drm_file *file_priv);
+int drm_mode_rmfb_ioctl(struct drm_device *dev,
+   void *data, struct drm_file *file_priv);
 int drm_mode_getfb(struct drm_device *dev,
   void *data, struct drm_file *file_priv);
 int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
diff --git a/drivers/gpu/drm/drm_dumb_buffers.c 
b/drivers/gpu/drm/drm_dumb_buffers.c
index 39ac15ce4702..eed9687b8698 100644
--- a/drivers/gpu/drm/drm_dumb_buffers.c
+++ b/drivers/gpu/drm/drm_dumb_buffers.c
@@ -53,10 +53,10 @@
  * a hardware-specific ioctl to allocate suitable buffer objects.
  */
 
-int drm_mode_create_dumb_ioctl(struct drm_device *dev,
-  void *data, struct drm_file *file_priv)
+int drm_mode_create_dumb(struct drm_device *dev,
+struct drm_mode_create_dumb *args,
+struct drm_file *file_priv)
 {
-   struct drm_mode_create_dumb *args = data;
u32 cpp, stride, size;
 
if (!dev->driver->dumb_create)
@@ -91,6 +91,12 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
return dev->driver->dumb_create(file_priv, dev, args);
 }
 
+int drm_mode_create_dumb_ioctl(struct drm_device *dev,
+  void *data, struct drm_file *file_priv)
+{
+   return drm_mode_create_dumb(dev, data, file_priv);
+}
+
 /**
  * drm_mode_mmap_dumb_ioctl - create an mmap offset for a dumb backing storage 
buffer
  * @dev: DRM device
@@ -122,17 +128,22 @@ int drm_mode_mmap_dumb_ioctl(struct drm_device *dev,
   >offset);
 }
 
+int drm_mode_destroy_dumb(struct drm_device *dev, u32 handle,
+ struct drm_file *file_priv)
+{
+   if (!dev->driver->dumb_create)
+   return -ENOSYS;
+
+   if (dev->driver->dumb_destroy)
+   return dev->driver->dumb_destroy(file_priv, dev, handle);
+   else
+   return drm_gem_dumb_destroy(file_priv, dev, handle);
+}
+
 int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv)
 {
struct drm_mode_destroy_dumb *args = data;
 
-   if (!dev->driver->dumb_create)
-   return -ENOSYS;
-
-   if (dev->driver->dumb_destroy)
-   return dev->driver->dumb_destroy(file_priv, dev, args->handle);
-   else
-   return drm_gem_dumb_destroy(file_priv, dev, args->handle);
+   return drm_mode_destroy_dumb(dev, args->handle, file_priv);
 }
-
diff --git 

[Intel-gfx] [RFC v4 12/25] drm/i915: Add drm_driver->initial_client_display callback

2018-04-12 Thread Noralf Trønnes
As part of moving the modesetting code out of drm_fb_helper and into
drm_client, the drm_fb_helper_funcs->initial_config callback needs to go.
Replace it with a drm_driver->initial_client_display callback that can
work for all in-kernel clients.

TODO:
- Add a patch that moves the function out of intel_fbdev.c since it's not
  fbdev specific anymore.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c|  19 +--
 drivers/gpu/drm/i915/i915_drv.c|   1 +
 drivers/gpu/drm/i915/intel_drv.h   |  11 
 drivers/gpu/drm/i915/intel_fbdev.c | 113 ++---
 include/drm/drm_drv.h  |  21 +++
 5 files changed, 104 insertions(+), 61 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index b992f59dad30..5407bf6dc8c0 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -2103,6 +2103,20 @@ static void drm_setup_crtcs(struct drm_fb_helper 
*fb_helper,
/* prevent concurrent modification of connector_count by hotplug */
lockdep_assert_held(_helper->lock);
 
+   mutex_lock(>mode_config.mutex);
+   if (drm_fb_helper_probe_connector_modes(fb_helper, width, height) == 0)
+   DRM_DEBUG_KMS("No connectors reported connected with modes\n");
+
+   if (dev->driver->initial_client_display) {
+   display = dev->driver->initial_client_display(dev, width, 
height);
+   if (display) {
+   drm_client_display_free(fb_helper->display);
+   fb_helper->display = display;
+   mutex_unlock(>mode_config.mutex);
+   return;
+   }
+   }
+
crtcs = kcalloc(fb_helper->connector_count,
sizeof(struct drm_fb_helper_crtc *), GFP_KERNEL);
modes = kcalloc(fb_helper->connector_count,
@@ -2120,9 +2134,6 @@ static void drm_setup_crtcs(struct drm_fb_helper 
*fb_helper,
if (IS_ERR(display))
goto out;
 
-   mutex_lock(_helper->dev->mode_config.mutex);
-   if (drm_fb_helper_probe_connector_modes(fb_helper, width, height) == 0)
-   DRM_DEBUG_KMS("No connectors reported connected with modes\n");
drm_enable_connectors(fb_helper, enabled);
 
if (!(fb_helper->funcs->initial_config &&
@@ -2144,7 +2155,6 @@ static void drm_setup_crtcs(struct drm_fb_helper 
*fb_helper,
 
drm_pick_crtcs(fb_helper, crtcs, modes, 0, width, height);
}
-   mutex_unlock(_helper->dev->mode_config.mutex);
 
/* need to set the modesets up here for use later */
/* fill out the connector<->crtc mappings into the modesets */
@@ -2182,6 +2192,7 @@ static void drm_setup_crtcs(struct drm_fb_helper 
*fb_helper,
drm_client_display_free(fb_helper->display);
fb_helper->display = display;
 out:
+   mutex_unlock(>mode_config.mutex);
kfree(crtcs);
kfree(modes);
kfree(offsets);
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 07c07d55398b..b746c0cbaa4b 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -2857,6 +2857,7 @@ static struct drm_driver driver = {
 
.dumb_create = i915_gem_dumb_create,
.dumb_map_offset = i915_gem_mmap_gtt,
+   .initial_client_display = i915_initial_client_display,
.ioctls = i915_ioctls,
.num_ioctls = ARRAY_SIZE(i915_ioctls),
.fops = _driver_fops,
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index d4368589b355..f77f510617c5 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1720,6 +1720,9 @@ extern void intel_fbdev_fini(struct drm_i915_private 
*dev_priv);
 extern void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool 
synchronous);
 extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
 extern void intel_fbdev_restore_mode(struct drm_device *dev);
+struct drm_client_display *
+i915_initial_client_display(struct drm_device *dev, unsigned int width,
+   unsigned int height);
 #else
 static inline int intel_fbdev_init(struct drm_device *dev)
 {
@@ -1749,6 +1752,14 @@ static inline void 
intel_fbdev_output_poll_changed(struct drm_device *dev)
 static inline void intel_fbdev_restore_mode(struct drm_device *dev)
 {
 }
+
+static inline struct drm_client_display *
+i915_initial_client_display(struct drm_device *dev, unsigned int width,
+   unsigned int height)
+{
+   return NULL;
+}
+
 #endif
 
 /* intel_fbc.c */
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c 
b/drivers/gpu/drm/i915/intel_fbdev.c
index a4ab8575a72e..b7f44c9475a8 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -38,6 +38,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include "intel_drv.h"
@@ 

[Intel-gfx] [RFC v4 18/25] drm/client: Make the display modes available to clients

2018-04-12 Thread Noralf Trønnes
Give clients easy access to the display modes.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_client.c | 159 +--
 include/drm/drm_client.h |  25 +++
 2 files changed, 148 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index 764c556630b8..bce1630a0db2 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -8,6 +8,7 @@
  * Copyright (c) 2007 Dave Airlie 
  */
 
+#include 
 #include 
 
 #include 
@@ -54,6 +55,7 @@ struct drm_client_display *drm_client_display_create(struct 
drm_device *dev)
}
 
display->dev = dev;
+   INIT_LIST_HEAD(>modes);
display->modeset_count = num_crtc;
 
drm_for_each_crtc(crtc, dev)
@@ -84,12 +86,16 @@ EXPORT_SYMBOL(drm_client_display_create);
  */
 void drm_client_display_free(struct drm_client_display *display)
 {
+   struct drm_display_mode *mode, *tmp;
struct drm_mode_set *modeset;
unsigned int i;
 
if (!display)
return;
 
+   list_for_each_entry_safe(mode, tmp, >modes, head)
+   drm_mode_destroy(display->dev, mode);
+
drm_client_display_for_each_modeset(modeset, display) {
if (modeset->mode)
drm_mode_destroy(display->dev, modeset->mode);
@@ -670,22 +676,70 @@ static int drm_pick_crtcs(struct drm_client_display 
*display,
return best_score;
 }
 
-/**
- * drm_client_find_display() - Find display
- * @dev: DRM device
- * @width: Maximum display mode width (optional)
- * @height: Maximum display mode height (optional)
- *
- * This function returns a display the client can use if available.
- *
- * Free resources by calling drm_client_display_free().
- *
- * Returns:
- * A _client_display on success, NULL if no connectors are found
- * or error pointer on failure.
- */
-struct drm_client_display *
-drm_client_find_display(struct drm_device *dev, unsigned int width, unsigned 
int height)
+/* Give the client a static list of display modes */
+static int drm_client_display_copy_modes(struct drm_client_display *display)
+{
+   int hdisplay = 0, vdisplay = 0, vrefresh;
+   struct drm_device *dev = display->dev;
+   struct drm_display_mode *mode, *copy;
+   struct drm_connector *connector;
+   struct drm_mode_set *modeset;
+   unsigned int count = 0;
+
+   drm_client_display_for_each_modeset(modeset, display) {
+   if (!modeset->num_connectors || !modeset->mode)
+   continue;
+
+   connector = modeset->connectors[0];
+   mode = modeset->mode;
+   count++;
+
+   if (modeset->num_connectors == 2) {
+   /* Cloned output */
+   copy = drm_mode_duplicate(dev, modeset->mode);
+   if (!copy)
+   return -ENOMEM;
+   list_add_tail(>head, >modes);
+   display->mode = copy;
+
+   return 0;
+   }
+
+   if (!modeset->y)
+   hdisplay += modeset->mode->hdisplay;
+   if (!modeset->x)
+   vdisplay += modeset->mode->vdisplay;
+   vrefresh = modeset->mode->vrefresh;
+   }
+
+   if (!count)
+   return 0;
+
+   if (count == 1) {
+   struct drm_display_mode *iter;
+
+   list_for_each_entry(iter, >modes, head) {
+   copy = drm_mode_duplicate(dev, iter);
+   if (!copy)
+   return -ENOMEM;
+   list_add_tail(>head, >modes);
+   if (!display->mode && drm_mode_equal(iter, mode))
+   display->mode = copy;
+   }
+   } else {
+   /* Combined tile mode. Only the default one for now */
+   copy = drm_cvt_mode(dev, hdisplay, vdisplay, vrefresh, false, 
false, false);
+   if (!copy)
+   return -ENOMEM;
+   list_add_tail(>head, >modes);
+   display->mode = copy;
+   }
+
+   return 0;
+}
+
+static struct drm_client_display *
+drm_client_find_display_default(struct drm_device *dev, unsigned int width, 
unsigned int height)
 {
struct drm_client_display_offset *offsets;
struct drm_client_display *display;
@@ -695,25 +749,6 @@ drm_client_find_display(struct drm_device *dev, unsigned 
int width, unsigned int
int i, connector_count;
bool *enabled;
 
-   DRM_DEBUG_KMS("\n");
-
-   if (!width)
-   width = dev->mode_config.max_width;
-   if (!height)
-   height = dev->mode_config.max_height;
-
-   mutex_lock(>mode_config.mutex);
-   if (!drm_client_probe_connector_modes(dev, width, height))
-   

[Intel-gfx] [RFC v4 15/25] drm/fb-helper: Move modeset config code to drm_client

2018-04-12 Thread Noralf Trønnes
Call the function drm_client_find_display().
No functional change apart from making width/height arguments optional.
Some function name/signature changes and whitespace adjustments.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_client.c| 399 
 drivers/gpu/drm/drm_fb_helper.c | 371 +
 include/drm/drm_client.h|   2 +
 include/drm/drm_fb_helper.h |   4 -
 4 files changed, 403 insertions(+), 373 deletions(-)

diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index c85c13568cf9..27818a467b09 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -18,6 +18,10 @@
 #include 
 #include 
 
+struct drm_client_display_offset {
+   int x, y;
+};
+
 /**
  * drm_client_display_create() - Create display structure
  * @dev: DRM device
@@ -359,3 +363,398 @@ void drm_client_display_dpms(struct drm_client_display 
*display, int mode)
drm_client_display_dpms_legacy(display, mode);
 }
 EXPORT_SYMBOL(drm_client_display_dpms);
+
+static int drm_client_probe_connector_modes(struct drm_device *dev,
+   u32 max_width, u32 max_height)
+{
+   struct drm_connector_list_iter conn_iter;
+   struct drm_connector *connector;
+   int count = 0;
+
+   drm_connector_list_iter_begin(dev, _iter);
+   drm_for_each_connector_iter(connector, _iter) {
+   count += connector->funcs->fill_modes(connector, max_width, 
max_height);
+   }
+   drm_connector_list_iter_end(_iter);
+
+   return count;
+}
+
+static bool drm_target_cloned(struct drm_device *dev,
+ struct drm_connector **connectors,
+ unsigned int connector_count,
+ struct drm_display_mode **modes,
+ struct drm_client_display_offset *offsets,
+ bool *enabled, int width, int height)
+{
+   int count, i, j;
+   bool can_clone = false;
+   struct drm_display_mode *dmt_mode, *mode;
+
+   /* only contemplate cloning in the single crtc case */
+   if (dev->mode_config.num_crtc > 1)
+   return false;
+
+   count = 0;
+   for (i = 0; i < connector_count; i++) {
+   if (enabled[i])
+   count++;
+   }
+
+   /* only contemplate cloning if more than one connector is enabled */
+   if (count <= 1)
+   return false;
+
+   /* check the command line or if nothing common pick 1024x768 */
+   can_clone = true;
+   for (i = 0; i < connector_count; i++) {
+   if (!enabled[i])
+   continue;
+   modes[i] = drm_connector_pick_cmdline_mode(connectors[i]);
+   if (!modes[i]) {
+   can_clone = false;
+   break;
+   }
+   for (j = 0; j < i; j++) {
+   if (!enabled[j])
+   continue;
+   if (!drm_mode_equal(modes[j], modes[i]))
+   can_clone = false;
+   }
+   }
+
+   if (can_clone) {
+   DRM_DEBUG_KMS("can clone using command line\n");
+   return true;
+   }
+
+   /* try and find a 1024x768 mode on each connector */
+   can_clone = true;
+   dmt_mode = drm_mode_find_dmt(dev, 1024, 768, 60, false);
+
+   for (i = 0; i < connector_count; i++) {
+   if (!enabled[i])
+   continue;
+
+   list_for_each_entry(mode, [i]->modes, head) {
+   if (drm_mode_equal(mode, dmt_mode))
+   modes[i] = mode;
+   }
+   if (!modes[i])
+   can_clone = false;
+   }
+
+   if (can_clone) {
+   DRM_DEBUG_KMS("can clone using 1024x768\n");
+   return true;
+   }
+   DRM_INFO("kms: can't enable cloning when we probably wanted to.\n");
+
+   return false;
+}
+
+static void drm_get_tile_offsets(struct drm_connector **connectors,
+unsigned int connector_count,
+struct drm_display_mode **modes,
+struct drm_client_display_offset *offsets,
+int idx,
+int h_idx, int v_idx)
+{
+   int i;
+   int hoffset = 0, voffset = 0;
+
+   for (i = 0; i < connector_count; i++) {
+   struct drm_connector *connector = connectors[i];
+
+   if (!connector->has_tile)
+   continue;
+
+   if (!modes[i] && (h_idx || v_idx)) {
+   DRM_DEBUG_KMS("no modes for connector tiled %d %d\n", i,
+ connector->base.id);
+   

[Intel-gfx] ✓ Fi.CI.BAT: success for GMBUS changes

2018-04-12 Thread Patchwork
== Series Details ==

Series: GMBUS changes
URL   : https://patchwork.freedesktop.org/series/41632/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4049 -> Patchwork_8681 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41632/revisions/1/mbox/

== Known issues ==

  Here are the changes found in Patchwork_8681 that come from known issues:

  === IGT changes ===

 Issues hit 

igt@gem_mmap_gtt@basic-small-bo-tiledx:
  fi-gdg-551: PASS -> FAIL (fdo#102575)

igt@prime_vgem@basic-fence-flip:
  fi-ilk-650: PASS -> FAIL (fdo#104008)


  fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
  fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008


== Participating hosts (35 -> 32) ==

  Additional (1): fi-cnl-y3 
  Missing(4): fi-ctg-p8600 fi-ilk-m540 fi-glk-j4005 fi-skl-6700hq 


== Build changes ==

* Linux: CI_DRM_4049 -> Patchwork_8681

  CI_DRM_4049: 3dbfa04d62f1f1214a03c3b2d30f987dccf50ab4 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4426: d502f055ac4500cada758876a512ac4f14b34851 @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_8681: b214f1744d40bb235737d076af5049ea052855fe @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4426: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit


== Linux commits ==

b214f1744d40 drm/i915/gmbus: Enable burst read
bb2f104e57f8 drm/i915/gmbus: Increase the Bytes per Rd/Wr Op

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8681/issues.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] drm/i915: Block enabling FBC until flips have been completed

2018-04-12 Thread Maarten Lankhorst
There is a small race window in which FBC can be enabled after
pre_plane_update is called, but before the page flip has been
queued or completed.

Signed-off-by: Maarten Lankhorst 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103167
---
 drivers/gpu/drm/i915/i915_drv.h  |  1 +
 drivers/gpu/drm/i915/intel_fbc.c | 35 +++
 2 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a0b8db3db141..2e2f24c2db9e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -492,6 +492,7 @@ struct intel_fbc {
 
bool enabled;
bool active;
+   bool flip_pending;
 
bool underrun_detected;
struct work_struct underrun_work;
diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
index b431b6733cc1..4770dd7dad5c 100644
--- a/drivers/gpu/drm/i915/intel_fbc.c
+++ b/drivers/gpu/drm/i915/intel_fbc.c
@@ -924,13 +924,6 @@ static void intel_fbc_get_reg_params(struct intel_crtc 
*crtc,
32 * fbc->threshold) * 8;
 }
 
-static bool intel_fbc_reg_params_equal(struct intel_fbc_reg_params *params1,
-  struct intel_fbc_reg_params *params2)
-{
-   /* We can use this since intel_fbc_get_reg_params() does a memset. */
-   return memcmp(params1, params2, sizeof(*params1)) == 0;
-}
-
 void intel_fbc_pre_update(struct intel_crtc *crtc,
  struct intel_crtc_state *crtc_state,
  struct intel_plane_state *plane_state)
@@ -952,6 +945,7 @@ void intel_fbc_pre_update(struct intel_crtc *crtc,
if (!fbc->enabled || fbc->crtc != crtc)
goto unlock;
 
+   fbc->flip_pending = true;
intel_fbc_update_state_cache(crtc, crtc_state, plane_state);
 
 deactivate:
@@ -988,13 +982,15 @@ static void __intel_fbc_post_update(struct intel_crtc 
*crtc)
 {
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
struct intel_fbc *fbc = _priv->fbc;
-   struct intel_fbc_reg_params old_params;
 
WARN_ON(!mutex_is_locked(>lock));
 
if (!fbc->enabled || fbc->crtc != crtc)
return;
 
+   fbc->flip_pending = false;
+   WARN_ON(fbc->active);
+
if (!i915_modparams.enable_fbc) {
intel_fbc_deactivate(dev_priv, "disabled at runtime per module 
param");
__intel_fbc_disable(dev_priv);
@@ -1002,25 +998,16 @@ static void __intel_fbc_post_update(struct intel_crtc 
*crtc)
return;
}
 
-   if (!intel_fbc_can_activate(crtc)) {
-   WARN_ON(fbc->active);
+   if (!intel_fbc_can_activate(crtc))
return;
-   }
 
-   old_params = fbc->params;
intel_fbc_get_reg_params(crtc, >params);
 
-   /* If the scanout has not changed, don't modify the FBC settings.
-* Note that we make the fundamental assumption that the fb->obj
-* cannot be unpinned (and have its GTT offset and fence revoked)
-* without first being decoupled from the scanout and FBC disabled.
-*/
-   if (fbc->active &&
-   intel_fbc_reg_params_equal(_params, >params))
-   return;
-
-   intel_fbc_deactivate(dev_priv, "FBC enabled (active or scheduled)");
-   intel_fbc_schedule_activation(crtc);
+   if (!fbc->busy_bits) {
+   intel_fbc_deactivate(dev_priv, "FBC enabled (active or 
scheduled)");
+   intel_fbc_schedule_activation(crtc);
+   } else
+   intel_fbc_deactivate(dev_priv, "frontbuffer write");
 }
 
 void intel_fbc_post_update(struct intel_crtc *crtc)
@@ -1085,7 +1072,7 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv,
(frontbuffer_bits & intel_fbc_get_frontbuffer_bit(fbc))) {
if (fbc->active)
intel_fbc_recompress(dev_priv);
-   else
+   else if (!fbc->flip_pending)
__intel_fbc_post_update(fbc->crtc);
}
 
-- 
2.16.3

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


[Intel-gfx] [RFC v2 2/2] drm/i915/gmbus: Enable burst read

2018-04-12 Thread Ramalingam C
Support for Burst read in HW is added for HDCP2.2 compliance
requirement.

This patch enables the burst read for all the gmbus read of more than
511Bytes, on capable platforms.

v2:
  Extra line is removed.

Signed-off-by: Ramalingam C 
---
 drivers/gpu/drm/i915/i915_reg.h  |  1 +
 drivers/gpu/drm/i915/intel_i2c.c | 38 ++
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 4f583da0cee9..0ef162ee9ce0 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -2984,6 +2984,7 @@ enum i915_power_well_id {
 #define   GMBUS_RATE_400KHZ(2<<8) /* reserved on Pineview */
 #define   GMBUS_RATE_1MHZ  (3<<8) /* reserved on Pineview */
 #define   GMBUS_HOLD_EXT   (1<<7) /* 300ns hold time, rsvd on Pineview */
+#define   GMBUS_BYTE_CNT_OVERRIDE (1<<6)
 #define   GMBUS_PIN_DISABLED   0
 #define   GMBUS_PIN_SSC1
 #define   GMBUS_PIN_VGADDC 2
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index 7e92c7934657..2ee9cf2effcd 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -364,12 +364,24 @@ gmbus_wait_idle(struct drm_i915_private *dev_priv)
 static int
 gmbus_xfer_read_chunk(struct drm_i915_private *dev_priv,
  unsigned short addr, u8 *buf, unsigned int len,
- u32 gmbus1_index)
+ u32 gmbus1_index, bool burst_read)
 {
+   unsigned int bytes_af_override, size;
+
+   if (burst_read) {
+   bytes_af_override = len - (((len / 256) - 1) * 256);
+   size = bytes_af_override;
+
+   I915_WRITE_FW(GMBUS0, (I915_READ_FW(GMBUS0) |
+ GMBUS_BYTE_CNT_OVERRIDE));
+   } else {
+   size = len;
+   }
+
I915_WRITE_FW(GMBUS1,
  gmbus1_index |
  GMBUS_CYCLE_WAIT |
- (len << GMBUS_BYTE_COUNT_SHIFT) |
+ (size << GMBUS_BYTE_COUNT_SHIFT) |
  (addr << GMBUS_SLAVE_ADDR_SHIFT) |
  GMBUS_SLAVE_READ | GMBUS_SW_RDY);
while (len) {
@@ -385,11 +397,23 @@ gmbus_xfer_read_chunk(struct drm_i915_private *dev_priv,
*buf++ = val & 0xff;
val >>= 8;
} while (--len && ++loop < 4);
+
+   if (burst_read && len == (bytes_af_override - 4))
+   I915_WRITE_FW(GMBUS0, (I915_READ_FW(GMBUS0) &
+ ~GMBUS_BYTE_CNT_OVERRIDE));
}
 
return 0;
 }
 
+static bool gmbus_burst_read_supported(struct drm_i915_private *dev_priv)
+{
+   if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv) ||
+   IS_KABYLAKE(dev_priv))
+   return true;
+   return false;
+}
+
 static int
 gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg,
u32 gmbus1_index)
@@ -398,15 +422,21 @@ gmbus_xfer_read(struct drm_i915_private *dev_priv, struct 
i2c_msg *msg,
unsigned int rx_size = msg->len;
unsigned int len;
int ret;
+   bool burst_read = false;
+
+   if (rx_size > BXT_GMBUS_BYTE_COUNT_MAX)
+   burst_read = gmbus_burst_read_supported(dev_priv);
 
do {
-   if (INTEL_GEN(dev_priv) >= 9)
+   if (burst_read)
+   len = rx_size;
+   else if (INTEL_GEN(dev_priv) >= 9)
len = min(rx_size, BXT_GMBUS_BYTE_COUNT_MAX);
else
len = min(rx_size, GMBUS_BYTE_COUNT_MAX);
 
ret = gmbus_xfer_read_chunk(dev_priv, msg->addr,
-   buf, len, gmbus1_index);
+   buf, len, gmbus1_index, burst_read);
if (ret)
return ret;
 
-- 
2.7.4

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


[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for GMBUS changes

2018-04-12 Thread Patchwork
== Series Details ==

Series: GMBUS changes
URL   : https://patchwork.freedesktop.org/series/41632/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
bb2f104e57f8 drm/i915/gmbus: Increase the Bytes per Rd/Wr Op
b214f1744d40 drm/i915/gmbus: Enable burst read
-:22: CHECK:SPACING: spaces preferred around that '<<' (ctx:VxV)
#22: FILE: drivers/gpu/drm/i915/i915_reg.h:2999:
+#define   GMBUS_BYTE_CNT_OVERRIDE (1<<6)
 ^

-:92: CHECK:BRACES: Blank lines aren't necessary after an open brace '{'
#92: FILE: drivers/gpu/drm/i915/intel_i2c.c:431:
do {
+

total: 0 errors, 0 warnings, 2 checks, 80 lines checked

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


[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Check whitelist registers across resets (rev2)

2018-04-12 Thread Patchwork
== Series Details ==

Series: drm/i915: Check whitelist registers across resets (rev2)
URL   : https://patchwork.freedesktop.org/series/41631/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4049 -> Patchwork_8680 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41631/revisions/2/mbox/

== Known issues ==

  Here are the changes found in Patchwork_8680 that come from known issues:

  === IGT changes ===

 Issues hit 

igt@gem_mmap_gtt@basic-small-bo-tiledx:
  fi-gdg-551: PASS -> FAIL (fdo#102575)


  fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575


== Participating hosts (35 -> 33) ==

  Additional (1): fi-cnl-y3 
  Missing(3): fi-ctg-p8600 fi-ilk-m540 fi-skl-6700hq 


== Build changes ==

* Linux: CI_DRM_4049 -> Patchwork_8680

  CI_DRM_4049: 3dbfa04d62f1f1214a03c3b2d30f987dccf50ab4 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4426: d502f055ac4500cada758876a512ac4f14b34851 @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_8680: 541de8069eef29c5d5ce23f2db7f10291f6b106f @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4426: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit


== Linux commits ==

541de8069eef drm/i915: Check whitelist registers across resets

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8680/issues.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFC 2/2] drm/i915/gmbus: Enable burst read

2018-04-12 Thread Ramalingam C
Support for Burst read in HW is added for HDCP2.2 compliance
requirement.

This patch enables the burst read for all the gmbus read of more than
511Bytes, on capable platforms.

Signed-off-by: Ramalingam C 
---
 drivers/gpu/drm/i915/i915_reg.h  |  1 +
 drivers/gpu/drm/i915/intel_i2c.c | 39 +++
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 4f583da0cee9..0ef162ee9ce0 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -2984,6 +2984,7 @@ enum i915_power_well_id {
 #define   GMBUS_RATE_400KHZ(2<<8) /* reserved on Pineview */
 #define   GMBUS_RATE_1MHZ  (3<<8) /* reserved on Pineview */
 #define   GMBUS_HOLD_EXT   (1<<7) /* 300ns hold time, rsvd on Pineview */
+#define   GMBUS_BYTE_CNT_OVERRIDE (1<<6)
 #define   GMBUS_PIN_DISABLED   0
 #define   GMBUS_PIN_SSC1
 #define   GMBUS_PIN_VGADDC 2
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index 7e92c7934657..ad65db6049c8 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -364,12 +364,24 @@ gmbus_wait_idle(struct drm_i915_private *dev_priv)
 static int
 gmbus_xfer_read_chunk(struct drm_i915_private *dev_priv,
  unsigned short addr, u8 *buf, unsigned int len,
- u32 gmbus1_index)
+ u32 gmbus1_index, bool burst_read)
 {
+   unsigned int bytes_af_override, size;
+
+   if (burst_read) {
+   bytes_af_override = len - (((len / 256) - 1) * 256);
+   size = bytes_af_override;
+
+   I915_WRITE_FW(GMBUS0, (I915_READ_FW(GMBUS0) |
+ GMBUS_BYTE_CNT_OVERRIDE));
+   } else {
+   size = len;
+   }
+
I915_WRITE_FW(GMBUS1,
  gmbus1_index |
  GMBUS_CYCLE_WAIT |
- (len << GMBUS_BYTE_COUNT_SHIFT) |
+ (size << GMBUS_BYTE_COUNT_SHIFT) |
  (addr << GMBUS_SLAVE_ADDR_SHIFT) |
  GMBUS_SLAVE_READ | GMBUS_SW_RDY);
while (len) {
@@ -385,11 +397,23 @@ gmbus_xfer_read_chunk(struct drm_i915_private *dev_priv,
*buf++ = val & 0xff;
val >>= 8;
} while (--len && ++loop < 4);
+
+   if (burst_read && len == (bytes_af_override - 4))
+   I915_WRITE_FW(GMBUS0, (I915_READ_FW(GMBUS0) &
+ ~GMBUS_BYTE_CNT_OVERRIDE));
}
 
return 0;
 }
 
+static bool gmbus_burst_read_supported(struct drm_i915_private *dev_priv)
+{
+   if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv) ||
+   IS_KABYLAKE(dev_priv))
+   return true;
+   return false;
+}
+
 static int
 gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg,
u32 gmbus1_index)
@@ -398,15 +422,22 @@ gmbus_xfer_read(struct drm_i915_private *dev_priv, struct 
i2c_msg *msg,
unsigned int rx_size = msg->len;
unsigned int len;
int ret;
+   bool burst_read = false;
+
+   if (rx_size > BXT_GMBUS_BYTE_COUNT_MAX)
+   burst_read = gmbus_burst_read_supported(dev_priv);
 
do {
-   if (INTEL_GEN(dev_priv) >= 9)
+
+   if (burst_read)
+   len = rx_size;
+   else if (INTEL_GEN(dev_priv) >= 9)
len = min(rx_size, BXT_GMBUS_BYTE_COUNT_MAX);
else
len = min(rx_size, GMBUS_BYTE_COUNT_MAX);
 
ret = gmbus_xfer_read_chunk(dev_priv, msg->addr,
-   buf, len, gmbus1_index);
+   buf, len, gmbus1_index, burst_read);
if (ret)
return ret;
 
-- 
2.7.4

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


[Intel-gfx] [RFC 1/2] drm/i915/gmbus: Increase the Bytes per Rd/Wr Op

2018-04-12 Thread Ramalingam C
From BXT onwards Bspec says HW supports Max Bytes per single RD/WR op is
511Bytes instead of previous 256Bytes used in SW.

This change allows the max bytes per op upto 511Bytes from BXT onwards.

Cc: Jani Nikula 
Cc: Chris Wilson 
Signed-off-by: Ramalingam C 
---
 drivers/gpu/drm/i915/i915_reg.h  |  1 +
 drivers/gpu/drm/i915/intel_i2c.c | 10 --
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 475cac07d3e6..4f583da0cee9 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -3013,6 +3013,7 @@ enum i915_power_well_id {
 #define   GMBUS_CYCLE_STOP (4<<25)
 #define   GMBUS_BYTE_COUNT_SHIFT 16
 #define   GMBUS_BYTE_COUNT_MAX   256U
+#define   BXT_GMBUS_BYTE_COUNT_MAX 511U
 #define   GMBUS_SLAVE_INDEX_SHIFT 8
 #define   GMBUS_SLAVE_ADDR_SHIFT 1
 #define   GMBUS_SLAVE_READ (1<<0)
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index e6875509bcd9..7e92c7934657 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -400,7 +400,10 @@ gmbus_xfer_read(struct drm_i915_private *dev_priv, struct 
i2c_msg *msg,
int ret;
 
do {
-   len = min(rx_size, GMBUS_BYTE_COUNT_MAX);
+   if (INTEL_GEN(dev_priv) >= 9)
+   len = min(rx_size, BXT_GMBUS_BYTE_COUNT_MAX);
+   else
+   len = min(rx_size, GMBUS_BYTE_COUNT_MAX);
 
ret = gmbus_xfer_read_chunk(dev_priv, msg->addr,
buf, len, gmbus1_index);
@@ -462,7 +465,10 @@ gmbus_xfer_write(struct drm_i915_private *dev_priv, struct 
i2c_msg *msg,
int ret;
 
do {
-   len = min(tx_size, GMBUS_BYTE_COUNT_MAX);
+   if (INTEL_GEN(dev_priv) >= 9)
+   len = min(tx_size, BXT_GMBUS_BYTE_COUNT_MAX);
+   else
+   len = min(tx_size, GMBUS_BYTE_COUNT_MAX);
 
ret = gmbus_xfer_write_chunk(dev_priv, msg->addr, buf, len,
 gmbus1_index);
-- 
2.7.4

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


[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Check whitelist registers across resets (rev2)

2018-04-12 Thread Patchwork
== Series Details ==

Series: drm/i915: Check whitelist registers across resets (rev2)
URL   : https://patchwork.freedesktop.org/series/41631/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
541de8069eef drm/i915: Check whitelist registers across resets
-:417: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does 
MAINTAINERS need updating?
#417: 
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 636 lines checked

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


[Intel-gfx] [RFC 0/2] GMBUS changes

2018-04-12 Thread Ramalingam C
I am not aware if there is a reason for restricting the Bytes per GMBUS
WR/RD to 256 at present. But HW has 9Bits for Total Byte count for a
single read or Write cycle. Means we can extend a cycle of RD/WR to
511Bytes.

At present nothing much as ROI, as most of the usecases are for less
than 256Bytes. On GLK tested for 300Bytes on single normal read, found
to be working fine.

First patch does it. But I have restricted the extension to BXT onwards,
as I am not sure about the legacy platforms.

And second patch is enabling the burst read for all GMBUS read of more
than 511Bytes, on supported platforms. Basically this Burst read is
enabled in HW for HDCP2.2 compliance requirement. Instead of enabling
the burst read only for HDCP on special API this patch enables it for
all GMBUS read of >511Bytes, on capable platforms.

Ramalingam C (2):
  drm/i915/gmbus: Increase the Bytes per Rd/Wr Op
  drm/i915/gmbus: Enable burst read

 drivers/gpu/drm/i915/i915_reg.h  |  2 ++
 drivers/gpu/drm/i915/intel_i2c.c | 49 
 2 files changed, 46 insertions(+), 5 deletions(-)

-- 
2.7.4

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


[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/cnl: Use mmio access to context status buffer

2018-04-12 Thread Patchwork
== Series Details ==

Series: drm/i915/cnl: Use mmio access to context status buffer
URL   : https://patchwork.freedesktop.org/series/41630/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4049 -> Patchwork_8679 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41630/revisions/1/mbox/

== Known issues ==

  Here are the changes found in Patchwork_8679 that come from known issues:

  === IGT changes ===

 Issues hit 

igt@gem_mmap_gtt@basic-small-bo-tiledx:
  fi-gdg-551: PASS -> FAIL (fdo#102575)

igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
  fi-bxt-dsi: PASS -> INCOMPLETE (fdo#103927)


  fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
  fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927


== Participating hosts (35 -> 33) ==

  Additional (1): fi-cnl-y3 
  Missing(3): fi-ctg-p8600 fi-ilk-m540 fi-skl-6700hq 


== Build changes ==

* Linux: CI_DRM_4049 -> Patchwork_8679

  CI_DRM_4049: 3dbfa04d62f1f1214a03c3b2d30f987dccf50ab4 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4426: d502f055ac4500cada758876a512ac4f14b34851 @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_8679: ec952dc37d185165b612080cc6f1683593c275a1 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4426: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit


== Linux commits ==

ec952dc37d18 drm/i915/cnl: Use mmio access to context status buffer

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8679/issues.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v2] drm/i915: Check whitelist registers across resets

2018-04-12 Thread Chris Wilson
Add a selftest to ensure that we restore the whitelisted registers after
rewrite the registers everytime they might be scrubbed, e.g. module
load, reset and resume. For the other volatile workaround registers, we
export their presence via debugfs and check in igt/gem_workarounds.
However, we don't export the whitelist and rather than do so, let's test
them directly in the kernel.

The test we use is to read the registers back from the CS (this helps us
be sure that the registers will be valid for MI_LRI etc). In order to
generate the expected list, we split intel_whitelist_workarounds_emit
into two phases, the first to build the list and the second to apply.
Inside the test, we only build the list and then check that list against
the hw.

v2: Filter out pre-gen8 as they do not have RING_NONPRIV.

Signed-off-by: Chris Wilson 
Cc: Oscar Mateo 
Cc: Mika Kuoppala 
Cc: Joonas Lahtinen 
---
 drivers/gpu/drm/i915/i915_debugfs.c   |  14 +-
 drivers/gpu/drm/i915/i915_drv.h   |   1 -
 drivers/gpu/drm/i915/intel_lrc.c  |   8 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c   |   4 +-
 drivers/gpu/drm/i915/intel_workarounds.c  | 215 ++---
 drivers/gpu/drm/i915/intel_workarounds.h  |   2 +-
 .../drm/i915/selftests/i915_live_selftests.h  |   1 +
 .../drm/i915/selftests/intel_workarounds.c| 284 ++
 8 files changed, 389 insertions(+), 140 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/selftests/intel_workarounds.c

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 2e6652a9bb9e..e0274f41bc76 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -3304,24 +3304,13 @@ static int i915_shared_dplls_info(struct seq_file *m, 
void *unused)
 
 static int i915_wa_registers(struct seq_file *m, void *unused)
 {
-   int i;
-   int ret;
-   struct intel_engine_cs *engine;
struct drm_i915_private *dev_priv = node_to_i915(m->private);
-   struct drm_device *dev = _priv->drm;
struct i915_workarounds *workarounds = _priv->workarounds;
-   enum intel_engine_id id;
-
-   ret = mutex_lock_interruptible(>struct_mutex);
-   if (ret)
-   return ret;
+   int i;
 
intel_runtime_pm_get(dev_priv);
 
seq_printf(m, "Workarounds applied: %d\n", workarounds->count);
-   for_each_engine(engine, dev_priv, id)
-   seq_printf(m, "HW whitelist count for %s: %d\n",
-  engine->name, workarounds->hw_whitelist_count[id]);
for (i = 0; i < workarounds->count; ++i) {
i915_reg_t addr;
u32 mask, value, read;
@@ -3337,7 +3326,6 @@ static int i915_wa_registers(struct seq_file *m, void 
*unused)
}
 
intel_runtime_pm_put(dev_priv);
-   mutex_unlock(>struct_mutex);
 
return 0;
 }
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 649c0f2f3bae..15e1260be58e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1297,7 +1297,6 @@ struct i915_wa_reg {
 struct i915_workarounds {
struct i915_wa_reg reg[I915_MAX_WA_REGS];
u32 count;
-   u32 hw_whitelist_count[I915_NUM_ENGINES];
 };
 
 struct i915_virtual_gpu {
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index c7c85134a84a..4f728587a756 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1744,9 +1744,7 @@ static int gen8_init_render_ring(struct intel_engine_cs 
*engine)
if (ret)
return ret;
 
-   ret = intel_whitelist_workarounds_apply(engine);
-   if (ret)
-   return ret;
+   intel_whitelist_workarounds_apply(engine);
 
/* We need to disable the AsyncFlip performance optimisations in order
 * to use MI_WAIT_FOR_EVENT within the CS. It should already be
@@ -1769,9 +1767,7 @@ static int gen9_init_render_ring(struct intel_engine_cs 
*engine)
if (ret)
return ret;
 
-   ret = intel_whitelist_workarounds_apply(engine);
-   if (ret)
-   return ret;
+   intel_whitelist_workarounds_apply(engine);
 
return 0;
 }
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c 
b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 757bb0990c07..c68ac605b8a9 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -618,9 +618,7 @@ static int init_render_ring(struct intel_engine_cs *engine)
if (ret)
return ret;
 
-   ret = intel_whitelist_workarounds_apply(engine);
-   if (ret)
-   return ret;
+   intel_whitelist_workarounds_apply(engine);
 
/* WaTimedSingleVertexDispatch:cl,bw,ctg,elk,ilk,snb */
if (IS_GEN(dev_priv, 4, 6))
diff 

[Intel-gfx] [PATCH] drm/i915: Check whitelist registers across resets

2018-04-12 Thread Chris Wilson
Add a selftest to ensure that we restore the whitelisted registers after
rewrite the registers everytime they might be scrubbed, e.g. module
load, reset and resume. For the other volatile workaround registers, we
export their presence via debugfs and check in igt/gem_workarounds.
However, we don't export the whitelist and rather than do so, let's test
them directly in the kernel.

The test we use is to read the registers back from the CS (this helps us
be sure that the registers will be valid for MI_LRI etc). In order to
generate the expected list, we split intel_whitelist_workarounds_emit
into two phases, the first to build the list and the second to apply.
Inside the test, we only build the list and then check that list against
the hw.

Signed-off-by: Chris Wilson 
Cc: Oscar Mateo 
Cc: Mika Kuoppala 
Cc: Joonas Lahtinen 
---
 drivers/gpu/drm/i915/i915_debugfs.c   |  14 +-
 drivers/gpu/drm/i915/i915_drv.h   |   1 -
 drivers/gpu/drm/i915/intel_lrc.c  |   8 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c   |   4 +-
 drivers/gpu/drm/i915/intel_workarounds.c  | 212 ++---
 drivers/gpu/drm/i915/intel_workarounds.h  |   2 +-
 .../drm/i915/selftests/i915_live_selftests.h  |   1 +
 .../drm/i915/selftests/intel_workarounds.c| 282 ++
 8 files changed, 384 insertions(+), 140 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/selftests/intel_workarounds.c

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 2e6652a9bb9e..e0274f41bc76 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -3304,24 +3304,13 @@ static int i915_shared_dplls_info(struct seq_file *m, 
void *unused)
 
 static int i915_wa_registers(struct seq_file *m, void *unused)
 {
-   int i;
-   int ret;
-   struct intel_engine_cs *engine;
struct drm_i915_private *dev_priv = node_to_i915(m->private);
-   struct drm_device *dev = _priv->drm;
struct i915_workarounds *workarounds = _priv->workarounds;
-   enum intel_engine_id id;
-
-   ret = mutex_lock_interruptible(>struct_mutex);
-   if (ret)
-   return ret;
+   int i;
 
intel_runtime_pm_get(dev_priv);
 
seq_printf(m, "Workarounds applied: %d\n", workarounds->count);
-   for_each_engine(engine, dev_priv, id)
-   seq_printf(m, "HW whitelist count for %s: %d\n",
-  engine->name, workarounds->hw_whitelist_count[id]);
for (i = 0; i < workarounds->count; ++i) {
i915_reg_t addr;
u32 mask, value, read;
@@ -3337,7 +3326,6 @@ static int i915_wa_registers(struct seq_file *m, void 
*unused)
}
 
intel_runtime_pm_put(dev_priv);
-   mutex_unlock(>struct_mutex);
 
return 0;
 }
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 649c0f2f3bae..15e1260be58e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1297,7 +1297,6 @@ struct i915_wa_reg {
 struct i915_workarounds {
struct i915_wa_reg reg[I915_MAX_WA_REGS];
u32 count;
-   u32 hw_whitelist_count[I915_NUM_ENGINES];
 };
 
 struct i915_virtual_gpu {
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index c7c85134a84a..4f728587a756 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1744,9 +1744,7 @@ static int gen8_init_render_ring(struct intel_engine_cs 
*engine)
if (ret)
return ret;
 
-   ret = intel_whitelist_workarounds_apply(engine);
-   if (ret)
-   return ret;
+   intel_whitelist_workarounds_apply(engine);
 
/* We need to disable the AsyncFlip performance optimisations in order
 * to use MI_WAIT_FOR_EVENT within the CS. It should already be
@@ -1769,9 +1767,7 @@ static int gen9_init_render_ring(struct intel_engine_cs 
*engine)
if (ret)
return ret;
 
-   ret = intel_whitelist_workarounds_apply(engine);
-   if (ret)
-   return ret;
+   intel_whitelist_workarounds_apply(engine);
 
return 0;
 }
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c 
b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 757bb0990c07..c68ac605b8a9 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -618,9 +618,7 @@ static int init_render_ring(struct intel_engine_cs *engine)
if (ret)
return ret;
 
-   ret = intel_whitelist_workarounds_apply(engine);
-   if (ret)
-   return ret;
+   intel_whitelist_workarounds_apply(engine);
 
/* WaTimedSingleVertexDispatch:cl,bw,ctg,elk,ilk,snb */
if (IS_GEN(dev_priv, 4, 6))
diff --git a/drivers/gpu/drm/i915/intel_workarounds.c 

[Intel-gfx] ✓ Fi.CI.IGT: success for drm/i915: Enforce read order into the hardware status page csb

2018-04-12 Thread Patchwork
== Series Details ==

Series: drm/i915: Enforce read order into the hardware status page csb
URL   : https://patchwork.freedesktop.org/series/41622/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4049_full -> Patchwork_8678_full =

== Summary - WARNING ==

  Minor unknown changes coming with Patchwork_8678_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_8678_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41622/revisions/1/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in 
Patchwork_8678_full:

  === IGT changes ===

 Warnings 

igt@gem_mocs_settings@mocs-rc6-render:
  shard-kbl:  PASS -> SKIP +1

igt@gem_mocs_settings@mocs-rc6-vebox:
  shard-kbl:  SKIP -> PASS


== Known issues ==

  Here are the changes found in Patchwork_8678_full that come from known issues:

  === IGT changes ===

 Issues hit 

igt@kms_flip@plain-flip-ts-check:
  shard-hsw:  PASS -> FAIL (fdo#100368)

igt@pm_rpm@debugfs-read:
  shard-kbl:  PASS -> DMESG-WARN (fdo#103313, fdo#103558) +2


 Possible fixes 

igt@kms_flip@2x-dpms-vs-vblank-race-interruptible:
  shard-hsw:  FAIL (fdo#103060) -> PASS +1

igt@kms_flip@plain-flip-ts-check-interruptible:
  shard-hsw:  FAIL (fdo#100368) -> PASS +1


  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
  fdo#103313 https://bugs.freedesktop.org/show_bug.cgi?id=103313
  fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558


== Participating hosts (6 -> 4) ==

  Missing(2): shard-glk shard-glkb 


== Build changes ==

* Linux: CI_DRM_4049 -> Patchwork_8678

  CI_DRM_4049: 3dbfa04d62f1f1214a03c3b2d30f987dccf50ab4 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4426: d502f055ac4500cada758876a512ac4f14b34851 @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_8678: 02b77742d0823525ce798b2bcfdc4a3bec295b32 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4426: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8678/shards.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915/cnl: Use mmio access to context status buffer

2018-04-12 Thread Chris Wilson
Quoting Mika Kuoppala (2018-04-12 15:58:02)
> Evidence indicates that Cannonlake HWSP is not coherent
> as it should. Revert to using mmio access for now.
> 
> Testcase: igt/gem_ctx_switch
> References: https://bugs.freedesktop.org/show_bug.cgi?id=105888
> Cc: Chris Wilson 
> Cc: Rafael Antognolli 
> Cc: Rodrigo Vivi 
> Signed-off-by: Mika Kuoppala 

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


[Intel-gfx] [PATCH] drm/i915/cnl: Use mmio access to context status buffer

2018-04-12 Thread Mika Kuoppala
Evidence indicates that Cannonlake HWSP is not coherent
as it should. Revert to using mmio access for now.

Testcase: igt/gem_ctx_switch
References: https://bugs.freedesktop.org/show_bug.cgi?id=105888
Cc: Chris Wilson 
Cc: Rafael Antognolli 
Cc: Rodrigo Vivi 
Signed-off-by: Mika Kuoppala 
---
 drivers/gpu/drm/i915/intel_engine_cs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c 
b/drivers/gpu/drm/i915/intel_engine_cs.c
index 68898d58dd1e..1a8370779bbb 100644
--- a/drivers/gpu/drm/i915/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/intel_engine_cs.c
@@ -475,6 +475,9 @@ static bool csb_force_mmio(struct drm_i915_private *i915)
if (intel_vgpu_active(i915) && !intel_vgpu_has_hwsp_emulation(i915))
return true;
 
+   if (IS_CANNONLAKE(i915))
+   return true;
+
return false;
 }
 
-- 
2.14.1

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


Re: [Intel-gfx] [igt-dev] [PATCH igt] igt/kms_plane_scaling: Open DRM_MASTER

2018-04-12 Thread Antonio Argenziano



On 12/04/18 01:43, Chris Wilson wrote:

Modesetting requires DRM_MASTER privileges, so use
drm_open_driver_master() to assert that we do acquire them.

References: https://bugs.freedesktop.org/show_bug.cgi?id=105997
Signed-off-by: Chris Wilson 


Acked-by: Antonio Argenziano 

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


[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Enforce read order into the hardware status page csb

2018-04-12 Thread Patchwork
== Series Details ==

Series: drm/i915: Enforce read order into the hardware status page csb
URL   : https://patchwork.freedesktop.org/series/41622/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4049 -> Patchwork_8678 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: 
https://patchwork.freedesktop.org/api/1.0/series/41622/revisions/1/mbox/

== Known issues ==

  Here are the changes found in Patchwork_8678 that come from known issues:

  === IGT changes ===

 Issues hit 

igt@gem_mmap_gtt@basic-small-bo-tiledx:
  fi-gdg-551: PASS -> FAIL (fdo#102575)

igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
  fi-elk-e7500:   PASS -> DMESG-WARN (fdo#105225) +1

igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
  fi-bxt-dsi: PASS -> INCOMPLETE (fdo#103927)


  fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
  fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
  fdo#105225 https://bugs.freedesktop.org/show_bug.cgi?id=105225


== Participating hosts (35 -> 33) ==

  Additional (1): fi-cnl-y3 
  Missing(3): fi-ctg-p8600 fi-ilk-m540 fi-skl-6700hq 


== Build changes ==

* Linux: CI_DRM_4049 -> Patchwork_8678

  CI_DRM_4049: 3dbfa04d62f1f1214a03c3b2d30f987dccf50ab4 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4426: d502f055ac4500cada758876a512ac4f14b34851 @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_8678: 02b77742d0823525ce798b2bcfdc4a3bec295b32 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4426: 93b35926a150e318439d2505901288594b3548f5 @ 
git://anongit.freedesktop.org/piglit


== Linux commits ==

02b77742d082 drm/i915: Enforce read order into the hardware status page csb

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8678/issues.html
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: Enforce read order into the hardware status page csb

2018-04-12 Thread Mika Kuoppala
Chris Wilson  writes:

> Quoting Mika Kuoppala (2018-04-12 14:52:37)
>> Read ordering on cpu can be out of order and speculative.
>
> If it didn't include a barrier to prevent compiler mispeculation. rmb()
> only applies to other CPU cores and not the GPU so this is entirely
> hocus.

How I understand the Documentation/memory-barrier.txt/THE THINGS CPUS
GET UP TO, the compiler memory barrier is not enough.

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


Re: [Intel-gfx] [PATCH] drm/i915: Enforce read order into the hardware status page csb

2018-04-12 Thread Chris Wilson
Quoting Chris Wilson (2018-04-12 14:57:42)
> Quoting Mika Kuoppala (2018-04-12 14:52:37)
> > Read ordering on cpu can be out of order and speculative.
> 
> If it didn't include a barrier to prevent compiler mispeculation. rmb()
> only applies to other CPU cores and not the GPU so this is entirely
> hocus.

Or think of it in terms checkpatch will ask you, where is the
corresponding wmb()?
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: Enforce read order into the hardware status page csb

2018-04-12 Thread Chris Wilson
Quoting Chris Wilson (2018-04-12 14:57:42)
> Quoting Mika Kuoppala (2018-04-12 14:52:37)
> > Read ordering on cpu can be out of order and speculative.
> 
> If it didn't include a barrier to prevent compiler mispeculation. rmb()
> only applies to other CPU cores and not the GPU so this is entirely
> hocus.

To put it another way this is just imposing the cost of an uncached
mmio which the entire point of using HWSP in the first place is to
avoid.
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: Enforce read order into the hardware status page csb

2018-04-12 Thread Chris Wilson
Quoting Mika Kuoppala (2018-04-12 14:52:37)
> Read ordering on cpu can be out of order and speculative.

If it didn't include a barrier to prevent compiler mispeculation. rmb()
only applies to other CPU cores and not the GPU so this is entirely
hocus.
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] drm/i915: Enforce read order into the hardware status page csb

2018-04-12 Thread Mika Kuoppala
Read ordering on cpu can be out of order and speculative.
In addition, the access to the hardware status page is snooped.
This raises a concern that we might use the HWSP in an unexpected
way as we may load the head of a cbs entry before we access the tail.
Concerns like that the coherency protocol is tied somehow to the
tail read snoop.

To enforce that we really do read the tail before we fetch
the csb entry pointed by head, insert a read memory barrier after we
have read the tail.

This fixes, or masks due to added latency, context status
buffer incoherence on cnl, where we see an old context status
entry still on that a csb slot.

References: https://bugs.freedesktop.org/show_bug.cgi?id=105888
Cc: Chris Wilson 
Cc: Rafael Antognolli 
Cc: Vivi, Rodrigo 
Signed-off-by: Mika Kuoppala 
---
 drivers/gpu/drm/i915/intel_lrc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index c7c85134a84a..5378391e1e71 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -969,6 +969,8 @@ static void execlists_submission_tasklet(unsigned long data)
 
head = execlists->csb_head;
tail = READ_ONCE(buf[write_idx]);
+   /* Enforce ordering of reads into the HWSP */
+   rmb();
}
GEM_TRACE("%s cs-irq head=%d [%d%s], tail=%d [%d%s]\n",
  engine->name,
-- 
2.14.1

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


[Intel-gfx] [RFC v4 11/25] drm/connector: Add connector array functions

2018-04-12 Thread Noralf Trønnes
Add functions to deal with the registred connectors as an array:
- drm_connector_get_all()
- drm_connector_put_all()

And to get the enabled status of those connectors:
drm_connector_get_enabled_status()

This is prep work to remove struct drm_fb_helper_connector.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_connector.c | 105 
 include/drm/drm_connector.h |   5 ++
 2 files changed, 110 insertions(+)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index b9eb143d70fc..25c333c05a4e 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1854,3 +1854,108 @@ drm_connector_pick_cmdline_mode(struct drm_connector 
*connector)
return mode;
 }
 EXPORT_SYMBOL(drm_connector_pick_cmdline_mode);
+
+/**
+ * drm_connector_get_all - Get all connectors into an array
+ * @dev: DRM device
+ * @connectors: Returned connector array
+ *
+ * This function iterates through all registered connectors and adds them to an
+ * array allocated by this function. A ref is taken on the connectors.
+ *
+ * Use drm_connector_put_all() to drop refs and free the array.
+ *
+ * Returns:
+ * Number of connectors or -ENOMEM on failure.
+ */
+int drm_connector_get_all(struct drm_device *dev, struct drm_connector 
***connectors)
+{
+   struct drm_connector *connector, **temp, **conns = NULL;
+   struct drm_connector_list_iter conn_iter;
+   int connector_count = 0;
+
+   drm_connector_list_iter_begin(dev, _iter);
+   drm_for_each_connector_iter(connector, _iter) {
+   temp = krealloc(conns, (connector_count + 1) * sizeof(*conns), 
GFP_KERNEL);
+   if (!temp)
+   goto err_put_free;
+
+   conns = temp;
+   conns[connector_count++] = connector;
+   drm_connector_get(connector);
+   }
+   drm_connector_list_iter_end(_iter);
+
+   *connectors = conns;
+
+   return connector_count;
+
+err_put_free:
+   drm_connector_list_iter_end(_iter);
+   drm_connector_put_all(conns, connector_count);
+
+   return -ENOMEM;
+}
+EXPORT_SYMBOL(drm_connector_get_all);
+
+/**
+ * drm_connector_put_all - Put and free connector array
+ * @connectors: Array of connectors
+ * @connector_count: Number of connectors in the array (can be negative or 
zero)
+ *
+ * This function drops the ref on the connectors an frees the array.
+ */
+void drm_connector_put_all(struct drm_connector **connectors, int 
connector_count)
+{
+   int i;
+
+   if (connector_count < 1)
+   return;
+
+   for (i = 0; i < connector_count; i++)
+   drm_connector_put(connectors[i]);
+   kfree(connectors);
+}
+EXPORT_SYMBOL(drm_connector_put_all);
+
+/**
+ * drm_connector_get_enabled_status - Get enabled status on connectors
+ * @connectors: Array of connectors
+ * @connector_count: Number of connectors in the array
+ *
+ * This loops over the connector array and sets enabled if connector status is
+ * _connected_. If no connectors are connected, a new pass is done and
+ * connectors that are not _disconnected_ are set enabled.
+ *
+ * The caller is responsible for freeing the array using kfree().
+ *
+ * Returns:
+ * A boolean array of connector enabled statuses or NULL on allocation failure.
+ */
+bool *drm_connector_get_enabled_status(struct drm_connector **connectors,
+  unsigned int connector_count)
+{
+   bool *enabled, any_enabled = false;
+   unsigned int i;
+
+   enabled = kcalloc(connector_count, sizeof(*enabled), GFP_KERNEL);
+   if (!enabled)
+   return NULL;
+
+   for (i = 0; i < connector_count; i++) {
+   if (connectors[i]->status == connector_status_connected) {
+   enabled[i] = true;
+   any_enabled = true;
+   }
+   }
+
+   if (any_enabled)
+   return enabled;
+
+   for (i = 0; i < connector_count; i++)
+   if (connectors[i]->status != connector_status_disconnected)
+   enabled[i] = true;
+
+   return enabled;
+}
+EXPORT_SYMBOL(drm_connector_get_enabled_status);
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 9cb4ca42373c..c3556a5f40c9 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -1169,4 +1169,9 @@ drm_connector_has_preferred_mode(struct drm_connector 
*connector,
 struct drm_display_mode *
 drm_connector_pick_cmdline_mode(struct drm_connector *connector);
 
+int drm_connector_get_all(struct drm_device *dev, struct drm_connector 
***connectors);
+void drm_connector_put_all(struct drm_connector **connectors, int 
connector_count);
+bool *drm_connector_get_enabled_status(struct drm_connector **connectors,
+  unsigned int connector_count);
+
 #endif
-- 
2.15.1


[Intel-gfx] [RFC v4 05/25] drm/fb-helper: dpms_legacy(): Only set on connectors in use

2018-04-12 Thread Noralf Trønnes
For each enabled crtc the functions sets dpms on all registered connectors.
Limit this to only doing it once and on the connectors actually in use.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 06e94de6452a..d0936671a9a6 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -583,20 +583,19 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op 
= { };
 static void dpms_legacy(struct drm_fb_helper *fb_helper, int dpms_mode)
 {
struct drm_device *dev = fb_helper->dev;
-   struct drm_crtc *crtc;
struct drm_connector *connector;
+   struct drm_mode_set *modeset;
int i, j;
 
drm_modeset_lock_all(dev);
for (i = 0; i < fb_helper->crtc_count; i++) {
-   crtc = fb_helper->crtc_info[i].mode_set.crtc;
+   modeset = _helper->crtc_info[i].mode_set;
 
-   if (!crtc->enabled)
+   if (!modeset->crtc->enabled)
continue;
 
-   /* Walk the connectors & encoders on this fb turning them 
on/off */
-   drm_fb_helper_for_each_connector(fb_helper, j) {
-   connector = fb_helper->connector_info[j]->connector;
+   for (j = 0; j < modeset->num_connectors; j++) {
+   connector = modeset->connectors[j];
connector->funcs->dpms(connector, dpms_mode);
drm_object_property_set_value(>base,
dev->mode_config.dpms_property, dpms_mode);
-- 
2.15.1

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


[Intel-gfx] [RFC v4 10/25] drm/connector: Add drm_connector_has_preferred_mode/pick_cmdline_mode()

2018-04-12 Thread Noralf Trønnes
Move them over from drm_fb_helper since they are connector functions.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_connector.c| 94 ++
 drivers/gpu/drm/drm_fb_helper.c| 75 ++
 drivers/gpu/drm/i915/intel_fbdev.c |  7 +--
 include/drm/drm_connector.h|  6 +++
 include/drm/drm_fb_helper.h| 19 
 5 files changed, 108 insertions(+), 93 deletions(-)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index b3cde897cd80..b9eb143d70fc 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1760,3 +1760,97 @@ struct drm_tile_group *drm_mode_create_tile_group(struct 
drm_device *dev,
return tg;
 }
 EXPORT_SYMBOL(drm_mode_create_tile_group);
+
+/**
+ * drm_connector_has_preferred_mode() - Lookup preferred display mode
+ * @connector: DRM connector
+ * @width: Max width
+ * @height: Max height
+ *
+ * Look for a preferred display mode within the bounds of @width and @height
+ * (inclusive).
+ *
+ * Returns:
+ * A _display_mode or NULL.
+ */
+struct drm_display_mode *
+drm_connector_has_preferred_mode(struct drm_connector *connector,
+int width, int height)
+{
+   struct drm_display_mode *mode;
+
+   list_for_each_entry(mode, >modes, head) {
+   if (mode->hdisplay > width || mode->vdisplay > height)
+   continue;
+   if (mode->type & DRM_MODE_TYPE_PREFERRED)
+   return mode;
+   }
+
+   return NULL;
+}
+EXPORT_SYMBOL(drm_connector_has_preferred_mode);
+
+/**
+ * drm_connector_pick_cmdline_mode() - Get commandline display mode
+ * @connector: DRM connector
+ *
+ * Return the display mode specified on the kernel commandline or NULL if not
+ * specified.
+ *
+ * Returns:
+ * A _display_mode or NULL.
+ */
+struct drm_display_mode *
+drm_connector_pick_cmdline_mode(struct drm_connector *connector)
+{
+   struct drm_cmdline_mode *cmdline_mode;
+   struct drm_display_mode *mode;
+   bool prefer_non_interlace;
+
+   cmdline_mode = >cmdline_mode;
+   if (!cmdline_mode->specified)
+   return NULL;
+
+   /* attempt to find a matching mode in the list of modes
+*  we have gotten so far, if not add a CVT mode that conforms
+*/
+   if (cmdline_mode->rb || cmdline_mode->margins)
+   goto create_mode;
+
+   prefer_non_interlace = !cmdline_mode->interlace;
+again:
+   list_for_each_entry(mode, >modes, head) {
+   /* check width/height */
+   if (mode->hdisplay != cmdline_mode->xres ||
+   mode->vdisplay != cmdline_mode->yres)
+   continue;
+
+   if (cmdline_mode->refresh_specified) {
+   if (mode->vrefresh != cmdline_mode->refresh)
+   continue;
+   }
+
+   if (cmdline_mode->interlace) {
+   if (!(mode->flags & DRM_MODE_FLAG_INTERLACE))
+   continue;
+   } else if (prefer_non_interlace) {
+   if (mode->flags & DRM_MODE_FLAG_INTERLACE)
+   continue;
+   }
+
+   return mode;
+   }
+
+   if (prefer_non_interlace) {
+   prefer_non_interlace = false;
+   goto again;
+   }
+
+create_mode:
+   mode = drm_mode_create_from_cmdline_mode(connector->dev,
+cmdline_mode);
+   list_add(>head, >modes);
+
+   return mode;
+}
+EXPORT_SYMBOL(drm_connector_pick_cmdline_mode);
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 785a2f5d2647..b992f59dad30 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1774,78 +1774,11 @@ static int drm_fb_helper_probe_connector_modes(struct 
drm_fb_helper *fb_helper,
return count;
 }
 
-struct drm_display_mode *drm_has_preferred_mode(struct drm_fb_helper_connector 
*fb_connector, int width, int height)
-{
-   struct drm_display_mode *mode;
-
-   list_for_each_entry(mode, _connector->connector->modes, head) {
-   if (mode->hdisplay > width ||
-   mode->vdisplay > height)
-   continue;
-   if (mode->type & DRM_MODE_TYPE_PREFERRED)
-   return mode;
-   }
-   return NULL;
-}
-EXPORT_SYMBOL(drm_has_preferred_mode);
-
 static bool drm_has_cmdline_mode(struct drm_fb_helper_connector *fb_connector)
 {
return fb_connector->connector->cmdline_mode.specified;
 }
 
-struct drm_display_mode *drm_pick_cmdline_mode(struct drm_fb_helper_connector 
*fb_helper_conn)
-{
-   struct drm_cmdline_mode *cmdline_mode;
-   struct drm_display_mode *mode;
-   bool prefer_non_interlace;
-
-   cmdline_mode = 

[Intel-gfx] [RFC v4 04/25] drm/fb-helper: Remove drm_fb_helper_debug_enter/leave()

2018-04-12 Thread Noralf Trønnes
Atomic drivers can't use them so finish what was started in
commit 9c79e0b1d096 ("drm/fb-helper: Give up on kgdb for atomic drivers").

This prepares the ground for creating modesets on demand.

TODO:
- Actually remove the functions, not just the contents.
- Nuke drm_crtc_helper_funcs->mode_set_base_atomic
- Documentation/dev-tools/kgdb.rst

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 82 -
 1 file changed, 82 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index e48ace2d55f5..06e94de6452a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -267,96 +267,14 @@ int drm_fb_helper_remove_one_connector(struct 
drm_fb_helper *fb_helper,
 }
 EXPORT_SYMBOL(drm_fb_helper_remove_one_connector);
 
-static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)
-{
-   uint16_t *r_base, *g_base, *b_base;
-
-   if (crtc->funcs->gamma_set == NULL)
-   return;
-
-   r_base = crtc->gamma_store;
-   g_base = r_base + crtc->gamma_size;
-   b_base = g_base + crtc->gamma_size;
-
-   crtc->funcs->gamma_set(crtc, r_base, g_base, b_base,
-  crtc->gamma_size, NULL);
-}
-
-/**
- * drm_fb_helper_debug_enter - implementation for _ops.fb_debug_enter
- * @info: fbdev registered by the helper
- */
 int drm_fb_helper_debug_enter(struct fb_info *info)
 {
-   struct drm_fb_helper *helper = info->par;
-   const struct drm_crtc_helper_funcs *funcs;
-   int i;
-
-   list_for_each_entry(helper, _fb_helper_list, kernel_fb_list) {
-   for (i = 0; i < helper->crtc_count; i++) {
-   struct drm_mode_set *mode_set =
-   >crtc_info[i].mode_set;
-
-   if (!mode_set->crtc->enabled)
-   continue;
-
-   funcs = mode_set->crtc->helper_private;
-   if (funcs->mode_set_base_atomic == NULL)
-   continue;
-
-   if (drm_drv_uses_atomic_modeset(mode_set->crtc->dev))
-   continue;
-
-   funcs->mode_set_base_atomic(mode_set->crtc,
-   mode_set->fb,
-   mode_set->x,
-   mode_set->y,
-   ENTER_ATOMIC_MODE_SET);
-   }
-   }
-
return 0;
 }
 EXPORT_SYMBOL(drm_fb_helper_debug_enter);
 
-/**
- * drm_fb_helper_debug_leave - implementation for _ops.fb_debug_leave
- * @info: fbdev registered by the helper
- */
 int drm_fb_helper_debug_leave(struct fb_info *info)
 {
-   struct drm_fb_helper *helper = info->par;
-   struct drm_crtc *crtc;
-   const struct drm_crtc_helper_funcs *funcs;
-   struct drm_framebuffer *fb;
-   int i;
-
-   for (i = 0; i < helper->crtc_count; i++) {
-   struct drm_mode_set *mode_set = >crtc_info[i].mode_set;
-
-   crtc = mode_set->crtc;
-   if (drm_drv_uses_atomic_modeset(crtc->dev))
-   continue;
-
-   funcs = crtc->helper_private;
-   fb = crtc->primary->fb;
-
-   if (!crtc->enabled)
-   continue;
-
-   if (!fb) {
-   DRM_ERROR("no fb to restore??\n");
-   continue;
-   }
-
-   if (funcs->mode_set_base_atomic == NULL)
-   continue;
-
-   drm_fb_helper_restore_lut_atomic(mode_set->crtc);
-   funcs->mode_set_base_atomic(mode_set->crtc, fb, crtc->x,
-   crtc->y, LEAVE_ATOMIC_MODE_SET);
-   }
-
return 0;
 }
 EXPORT_SYMBOL(drm_fb_helper_debug_leave);
-- 
2.15.1

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


[Intel-gfx] [RFC v4 09/25] drm/fb-helper: Move modeset commit code to drm_client

2018-04-12 Thread Noralf Trønnes
This moves the committing part of the modesetting code to drm_client.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_client.c| 242 
 drivers/gpu/drm/drm_fb_helper.c | 216 +--
 include/drm/drm_client.h|   8 ++
 3 files changed, 252 insertions(+), 214 deletions(-)

diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index 7c31a6efb2f4..c85c13568cf9 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -10,6 +10,8 @@
 
 #include 
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -117,3 +119,243 @@ drm_client_display_find_modeset(struct drm_client_display 
*display, struct drm_c
return NULL;
 }
 EXPORT_SYMBOL(drm_client_display_find_modeset);
+
+/**
+ * drm_client_display_panel_rotation() - Check panel orientation
+ * @connector: DRM connector
+ * @plane: DRM plane
+ * @rotation: Returned rotation value
+ *
+ * This function checks if @plane can hw rotate to match the panel orientation
+ * on @connector.
+ *
+ * Return:
+ * True if the plane can do the rotation, false otherwise.
+ */
+bool drm_client_display_panel_rotation(struct drm_connector *connector,
+  struct drm_plane *plane,
+  unsigned int *rotation)
+{
+   uint64_t valid_mask = 0;
+   unsigned int i;
+
+   if (!connector)
+   return false;
+
+   switch (connector->display_info.panel_orientation) {
+   case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
+   *rotation = DRM_MODE_ROTATE_180;
+   break;
+   case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
+   *rotation = DRM_MODE_ROTATE_90;
+   break;
+   case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
+   *rotation = DRM_MODE_ROTATE_270;
+   break;
+   default:
+   *rotation = DRM_MODE_ROTATE_0;
+   }
+
+   /*
+* TODO: support 90 / 270 degree hardware rotation,
+* depending on the hardware this may require the framebuffer
+* to be in a specific tiling format.
+*/
+   if (*rotation != DRM_MODE_ROTATE_180 || !plane->rotation_property)
+   return false;
+
+   for (i = 0; i < plane->rotation_property->num_values; i++)
+   valid_mask |= (1ULL << plane->rotation_property->values[i]);
+
+   if (!(*rotation & valid_mask))
+   return false;
+
+   return true;
+}
+EXPORT_SYMBOL(drm_client_display_panel_rotation);
+
+static int drm_client_display_restore_atomic(struct drm_client_display 
*display, bool active)
+{
+   struct drm_device *dev = display->dev;
+   struct drm_plane_state *plane_state;
+   struct drm_mode_set *mode_set;
+   struct drm_plane *plane;
+   struct drm_atomic_state *state;
+   int ret;
+   unsigned int plane_mask;
+   struct drm_modeset_acquire_ctx ctx;
+
+   drm_modeset_acquire_init(, 0);
+
+   state = drm_atomic_state_alloc(dev);
+   if (!state) {
+   ret = -ENOMEM;
+   goto out_ctx;
+   }
+
+   state->acquire_ctx = 
+retry:
+   plane_mask = 0;
+   drm_for_each_plane(plane, dev) {
+   plane_state = drm_atomic_get_plane_state(state, plane);
+   if (IS_ERR(plane_state)) {
+   ret = PTR_ERR(plane_state);
+   goto out_state;
+   }
+
+   plane_state->rotation = DRM_MODE_ROTATE_0;
+
+   plane->old_fb = plane->fb;
+   plane_mask |= 1 << drm_plane_index(plane);
+
+   /* disable non-primary: */
+   if (plane->type == DRM_PLANE_TYPE_PRIMARY)
+   continue;
+
+   ret = drm_atomic_disable_plane(plane, plane_state);
+   if (ret != 0)
+   goto out_state;
+   }
+
+   drm_client_display_for_each_modeset(mode_set, display) {
+   struct drm_plane *primary = mode_set->crtc->primary;
+   unsigned int rotation;
+
+   if (drm_client_display_panel_rotation(mode_set->connectors[0], 
primary, )) {
+   /* Cannot fail as we've already gotten the plane state 
above */
+   plane_state = drm_atomic_get_new_plane_state(state, 
primary);
+   plane_state->rotation = rotation;
+   }
+
+   ret = drm_atomic_set_config(mode_set, state);
+   if (ret != 0)
+   goto out_state;
+
+   /*
+* drm_atomic_set_config() sets active when a
+* mode is set, unconditionally clear it if we force DPMS off
+*/
+   if (!active) {
+   struct drm_crtc *crtc = mode_set->crtc;
+   struct drm_crtc_state *crtc_state = 
drm_atomic_get_new_crtc_state(state, crtc);
+
+   

[Intel-gfx] [RFC v4 08/25] drm/fb-helper: Use struct drm_client_display

2018-04-12 Thread Noralf Trønnes
Prepare to move the modeset committing code to drm_client.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 161 
 include/drm/drm_fb_helper.h |   8 ++
 2 files changed, 89 insertions(+), 80 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 2eef24db21f8..bdb4b57d2c12 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -321,13 +322,14 @@ static bool drm_fb_helper_panel_rotation(struct 
drm_connector *connector,
return true;
 }
 
-static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool 
active)
+static int drm_client_display_restore_atomic(struct drm_client_display 
*display, bool active)
 {
-   struct drm_device *dev = fb_helper->dev;
+   struct drm_device *dev = display->dev;
struct drm_plane_state *plane_state;
+   struct drm_mode_set *mode_set;
struct drm_plane *plane;
struct drm_atomic_state *state;
-   int i, ret;
+   int ret;
unsigned int plane_mask;
struct drm_modeset_acquire_ctx ctx;
 
@@ -363,8 +365,7 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper 
*fb_helper, bool activ
goto out_state;
}
 
-   for (i = 0; i < fb_helper->crtc_count; i++) {
-   struct drm_mode_set *mode_set = 
_helper->crtc_info[i].mode_set;
+   drm_client_display_for_each_modeset(mode_set, display) {
struct drm_plane *primary = mode_set->crtc->primary;
unsigned int rotation;
 
@@ -412,13 +413,14 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper 
*fb_helper, bool activ
goto retry;
 }
 
-static int restore_fbdev_mode_legacy(struct drm_fb_helper *fb_helper)
+static int drm_client_display_restore_legacy(struct drm_client_display 
*display)
 {
-   struct drm_device *dev = fb_helper->dev;
+   struct drm_device *dev = display->dev;
+   struct drm_mode_set *mode_set;
struct drm_plane *plane;
-   int i, ret = 0;
+   int ret = 0;
 
-   drm_modeset_lock_all(fb_helper->dev);
+   drm_modeset_lock_all(dev);
drm_for_each_plane(plane, dev) {
if (plane->type != DRM_PLANE_TYPE_PRIMARY)
drm_plane_force_disable(plane);
@@ -429,8 +431,7 @@ static int restore_fbdev_mode_legacy(struct drm_fb_helper 
*fb_helper)
DRM_MODE_ROTATE_0);
}
 
-   for (i = 0; i < fb_helper->crtc_count; i++) {
-   struct drm_mode_set *mode_set = 
_helper->crtc_info[i].mode_set;
+   drm_client_display_for_each_modeset(mode_set, display) {
struct drm_crtc *crtc = mode_set->crtc;
 
if (crtc->funcs->cursor_set2) {
@@ -448,19 +449,17 @@ static int restore_fbdev_mode_legacy(struct drm_fb_helper 
*fb_helper)
goto out;
}
 out:
-   drm_modeset_unlock_all(fb_helper->dev);
+   drm_modeset_unlock_all(dev);
 
return ret;
 }
 
-static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
+static int drm_client_display_restore(struct drm_client_display *display)
 {
-   struct drm_device *dev = fb_helper->dev;
-
-   if (drm_drv_uses_atomic_modeset(dev))
-   return restore_fbdev_mode_atomic(fb_helper, true);
+   if (drm_drv_uses_atomic_modeset(display->dev))
+   return drm_client_display_restore_atomic(display, true);
else
-   return restore_fbdev_mode_legacy(fb_helper);
+   return drm_client_display_restore_legacy(display);
 }
 
 /**
@@ -486,7 +485,7 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct 
drm_fb_helper *fb_helper)
return 0;
 
mutex_lock(_helper->lock);
-   ret = restore_fbdev_mode(fb_helper);
+   ret = drm_client_display_restore(fb_helper->display);
 
do_delayed = fb_helper->delayed_hotplug;
if (do_delayed)
@@ -548,7 +547,7 @@ static bool drm_fb_helper_force_kernel_mode(void)
continue;
 
mutex_lock(>lock);
-   ret = restore_fbdev_mode(helper);
+   ret = drm_client_display_restore(helper->display);
if (ret)
error = true;
mutex_unlock(>lock);
@@ -580,22 +579,20 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op 
= {
 static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };
 #endif
 
-static void dpms_legacy(struct drm_fb_helper *fb_helper, int dpms_mode)
+static void drm_client_display_dpms_legacy(struct drm_client_display *display, 
int dpms_mode)
 {
-   struct drm_device *dev = fb_helper->dev;
+   struct drm_device *dev = display->dev;
struct drm_connector *connector;
struct drm_mode_set *modeset;
-   

[Intel-gfx] [RFC v4 03/25] drm/fb-helper: No need to cache rotation and sw_rotations

2018-04-12 Thread Noralf Trønnes
Getting rotation info is cheap so we can do it on demand.

This is done in preparation for the removal of struct drm_fb_helper_crtc.

Cc: Hans de Goede 
Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 131 
 include/drm/drm_fb_helper.h |   8 ---
 2 files changed, 65 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 0646b108030b..e48ace2d55f5 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -361,6 +361,48 @@ int drm_fb_helper_debug_leave(struct fb_info *info)
 }
 EXPORT_SYMBOL(drm_fb_helper_debug_leave);
 
+/* Check if the plane can hw rotate to match panel orientation */
+static bool drm_fb_helper_panel_rotation(struct drm_connector *connector,
+struct drm_plane *plane,
+unsigned int *rotation)
+{
+   uint64_t valid_mask = 0;
+   unsigned int i;
+
+   if (!connector)
+   return false;
+
+   switch (connector->display_info.panel_orientation) {
+   case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
+   *rotation = DRM_MODE_ROTATE_180;
+   break;
+   case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
+   *rotation = DRM_MODE_ROTATE_90;
+   break;
+   case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
+   *rotation = DRM_MODE_ROTATE_270;
+   break;
+   default:
+   *rotation = DRM_MODE_ROTATE_0;
+   }
+
+   /*
+* TODO: support 90 / 270 degree hardware rotation,
+* depending on the hardware this may require the framebuffer
+* to be in a specific tiling format.
+*/
+   if (*rotation != DRM_MODE_ROTATE_180 || !plane->rotation_property)
+   return false;
+
+   for (i = 0; i < plane->rotation_property->num_values; i++)
+   valid_mask |= (1ULL << plane->rotation_property->values[i]);
+
+   if (!(*rotation & valid_mask))
+   return false;
+
+   return true;
+}
+
 static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool 
active)
 {
struct drm_device *dev = fb_helper->dev;
@@ -406,10 +448,13 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper 
*fb_helper, bool activ
for (i = 0; i < fb_helper->crtc_count; i++) {
struct drm_mode_set *mode_set = 
_helper->crtc_info[i].mode_set;
struct drm_plane *primary = mode_set->crtc->primary;
+   unsigned int rotation;
 
-   /* Cannot fail as we've already gotten the plane state above */
-   plane_state = drm_atomic_get_new_plane_state(state, primary);
-   plane_state->rotation = fb_helper->crtc_info[i].rotation;
+   if (drm_fb_helper_panel_rotation(mode_set->connectors[0], 
primary, )) {
+   /* Cannot fail as we've already gotten the plane state 
above */
+   plane_state = drm_atomic_get_new_plane_state(state, 
primary);
+   plane_state->rotation = rotation;
+   }
 
ret = __drm_atomic_helper_set_config(mode_set, state);
if (ret != 0)
@@ -841,7 +886,6 @@ int drm_fb_helper_init(struct drm_device *dev,
if (!fb_helper->crtc_info[i].mode_set.connectors)
goto out_free;
fb_helper->crtc_info[i].mode_set.num_connectors = 0;
-   fb_helper->crtc_info[i].rotation = DRM_MODE_ROTATE_0;
}
 
i = 0;
@@ -2414,62 +2458,6 @@ static int drm_pick_crtcs(struct drm_fb_helper 
*fb_helper,
return best_score;
 }
 
-/*
- * This function checks if rotation is necessary because of panel orientation
- * and if it is, if it is supported.
- * If rotation is necessary and supported, its gets set in fb_crtc.rotation.
- * If rotation is necessary but not supported, a DRM_MODE_ROTATE_* flag gets
- * or-ed into fb_helper->sw_rotations. In drm_setup_crtcs_fb() we check if only
- * one bit is set and then we set fb_info.fbcon_rotate_hint to make fbcon do
- * the unsupported rotation.
- */
-static void drm_setup_crtc_rotation(struct drm_fb_helper *fb_helper,
-   struct drm_fb_helper_crtc *fb_crtc,
-   struct drm_connector *connector)
-{
-   struct drm_plane *plane = fb_crtc->mode_set.crtc->primary;
-   uint64_t valid_mask = 0;
-   int i, rotation;
-
-   fb_crtc->rotation = DRM_MODE_ROTATE_0;
-
-   switch (connector->display_info.panel_orientation) {
-   case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
-   rotation = DRM_MODE_ROTATE_180;
-   break;
-   case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
-   rotation = DRM_MODE_ROTATE_90;
-   break;
-   case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
-   

[Intel-gfx] [RFC v4 07/25] drm: Begin an API for in-kernel clients

2018-04-12 Thread Noralf Trønnes
This the beginning of an API for in-kernel clients.
First out is a display representation that will be used by drm_fb_helper
in order to move out its mode setting code.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/Makefile |   2 +-
 drivers/gpu/drm/drm_client.c | 119 +++
 include/drm/drm_client.h |  44 
 3 files changed, 164 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/drm_client.c
 create mode 100644 include/drm/drm_client.h

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 9d66657ea117..d25afa136d8f 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -18,7 +18,7 @@ drm-y   :=drm_auth.o drm_bufs.o drm_cache.o \
drm_encoder.o drm_mode_object.o drm_property.o \
drm_plane.o drm_color_mgmt.o drm_print.o \
drm_dumb_buffers.o drm_mode_config.o drm_vblank.o \
-   drm_syncobj.o drm_lease.o
+   drm_syncobj.o drm_lease.o drm_client.o
 
 drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
 drm-$(CONFIG_DRM_VM) += drm_vm.o
diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
new file mode 100644
index ..7c31a6efb2f4
--- /dev/null
+++ b/drivers/gpu/drm/drm_client.c
@@ -0,0 +1,119 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2018 Noralf Trønnes
+ *
+ * For parts copied from drm_fb_helper:
+ * Copyright (c) 2006-2009 Red Hat Inc.
+ * Copyright (c) 2006-2008 Intel Corporation
+ * Copyright (c) 2007 Dave Airlie 
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+ * drm_client_display_create() - Create display structure
+ * @dev: DRM device
+ *
+ * This function creates a display structure for clients backed by an array of
+ * _mode_set, one per CRTC.
+ *
+ * Returns:
+ * A _client_display or an error pointer on allocation failure.
+ */
+struct drm_client_display *drm_client_display_create(struct drm_device *dev)
+{
+   unsigned int num_crtc = dev->mode_config.num_crtc;
+   struct drm_client_display *display;
+   struct drm_mode_set *modeset;
+   struct drm_crtc *crtc;
+   unsigned int i = 0;
+
+   display = kzalloc(sizeof(*display), GFP_KERNEL);
+   if (!display)
+   return ERR_PTR(-ENOMEM);
+
+   /* Add NULL terminating entry to enable index less iteration */
+   display->modesets = kcalloc(num_crtc + 1, sizeof(*display->modesets), 
GFP_KERNEL);
+   if (!display->modesets) {
+   kfree(display);
+   return ERR_PTR(-ENOMEM);
+   }
+
+   display->dev = dev;
+   display->modeset_count = num_crtc;
+
+   drm_for_each_crtc(crtc, dev)
+   display->modesets[i++].crtc = crtc;
+
+   drm_client_display_for_each_modeset(modeset, display) {
+   /* One connector per crtc except for the cloned case */
+   modeset->connectors = kcalloc(2, sizeof(*modeset->connectors), 
GFP_KERNEL);
+   if (!modeset->connectors)
+   goto err_free;
+   }
+
+   return display;
+
+err_free:
+   drm_client_display_free(display);
+
+   return ERR_PTR(-ENOMEM);
+}
+EXPORT_SYMBOL(drm_client_display_create);
+
+/**
+ * drm_client_display_free() - Free display structure
+ * @display: Client display
+ *
+ * This function frees the structure allocated by drm_client_display_create().
+ * It also destroys display modes and puts connectors.
+ */
+void drm_client_display_free(struct drm_client_display *display)
+{
+   struct drm_mode_set *modeset;
+   unsigned int i;
+
+   if (!display)
+   return;
+
+   drm_client_display_for_each_modeset(modeset, display) {
+   if (modeset->mode)
+   drm_mode_destroy(display->dev, modeset->mode);
+
+   for (i = 0; i < modeset->num_connectors; i++)
+   drm_connector_put(modeset->connectors[i]);
+   kfree(modeset->connectors);
+   }
+   kfree(display->modesets);
+   kfree(display);
+}
+EXPORT_SYMBOL(drm_client_display_free);
+
+/**
+ * drm_client_display_find_modeset() - Find modeset matching a CRTC
+ * @display: Client display
+ * @crtc: CRTC
+ *
+ * This function looks up the @display modeset connected to @crtc.
+ *
+ * Returns:
+ * A _mode_set or NULL.
+ */
+struct drm_mode_set *
+drm_client_display_find_modeset(struct drm_client_display *display, struct 
drm_crtc *crtc)
+{
+   struct drm_mode_set *modeset;
+
+   drm_client_display_for_each_modeset(modeset, display)
+   if (modeset->crtc == crtc)
+   return modeset;
+
+   return NULL;
+}
+EXPORT_SYMBOL(drm_client_display_find_modeset);
diff --git a/include/drm/drm_client.h b/include/drm/drm_client.h
new file mode 100644
index ..b6a057802769
--- /dev/null
+++ b/include/drm/drm_client.h
@@ -0,0 +1,44 @@
+/* 

[Intel-gfx] [RFC v4 06/25] drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()

2018-04-12 Thread Noralf Trønnes
Prepare for moving drm_fb_helper modesetting code to drm_client.
drm_client will be linked to drm.ko, so move
__drm_atomic_helper_disable_plane() and __drm_atomic_helper_set_config()
out of drm_kms_helper.ko.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_atomic.c| 168 
 drivers/gpu/drm/drm_atomic_helper.c | 168 +---
 drivers/gpu/drm/drm_fb_helper.c |   8 +-
 include/drm/drm_atomic.h|   5 ++
 include/drm/drm_atomic_helper.h |   4 -
 5 files changed, 179 insertions(+), 174 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 7d25c42f22db..1fb602b6c8b1 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -2060,6 +2060,174 @@ void drm_atomic_clean_old_fb(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_atomic_clean_old_fb);
 
+/* just used from drm_client and atomic-helper: */
+int drm_atomic_disable_plane(struct drm_plane *plane,
+struct drm_plane_state *plane_state)
+{
+   int ret;
+
+   ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
+   if (ret != 0)
+   return ret;
+
+   drm_atomic_set_fb_for_plane(plane_state, NULL);
+   plane_state->crtc_x = 0;
+   plane_state->crtc_y = 0;
+   plane_state->crtc_w = 0;
+   plane_state->crtc_h = 0;
+   plane_state->src_x = 0;
+   plane_state->src_y = 0;
+   plane_state->src_w = 0;
+   plane_state->src_h = 0;
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_atomic_disable_plane);
+
+static int update_output_state(struct drm_atomic_state *state,
+  struct drm_mode_set *set)
+{
+   struct drm_device *dev = set->crtc->dev;
+   struct drm_crtc *crtc;
+   struct drm_crtc_state *new_crtc_state;
+   struct drm_connector *connector;
+   struct drm_connector_state *new_conn_state;
+   int ret, i;
+
+   ret = drm_modeset_lock(>mode_config.connection_mutex,
+  state->acquire_ctx);
+   if (ret)
+   return ret;
+
+   /* First disable all connectors on the target crtc. */
+   ret = drm_atomic_add_affected_connectors(state, set->crtc);
+   if (ret)
+   return ret;
+
+   for_each_new_connector_in_state(state, connector, new_conn_state, i) {
+   if (new_conn_state->crtc == set->crtc) {
+   ret = drm_atomic_set_crtc_for_connector(new_conn_state,
+   NULL);
+   if (ret)
+   return ret;
+
+   /* Make sure legacy setCrtc always re-trains */
+   new_conn_state->link_status = DRM_LINK_STATUS_GOOD;
+   }
+   }
+
+   /* Then set all connectors from set->connectors on the target crtc */
+   for (i = 0; i < set->num_connectors; i++) {
+   new_conn_state = drm_atomic_get_connector_state(state,
+   set->connectors[i]);
+   if (IS_ERR(new_conn_state))
+   return PTR_ERR(new_conn_state);
+
+   ret = drm_atomic_set_crtc_for_connector(new_conn_state,
+   set->crtc);
+   if (ret)
+   return ret;
+   }
+
+   for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+   /*
+* Don't update ->enable for the CRTC in the set_config request,
+* since a mismatch would indicate a bug in the upper layers.
+* The actual modeset code later on will catch any
+* inconsistencies here.
+*/
+   if (crtc == set->crtc)
+   continue;
+
+   if (!new_crtc_state->connector_mask) {
+   ret = drm_atomic_set_mode_prop_for_crtc(new_crtc_state,
+   NULL);
+   if (ret < 0)
+   return ret;
+
+   new_crtc_state->active = false;
+   }
+   }
+
+   return 0;
+}
+
+/* just used from drm_client and atomic-helper: */
+int drm_atomic_set_config(struct drm_mode_set *set,
+ struct drm_atomic_state *state)
+{
+   struct drm_crtc_state *crtc_state;
+   struct drm_plane_state *primary_state;
+   struct drm_crtc *crtc = set->crtc;
+   int hdisplay, vdisplay;
+   int ret;
+
+   crtc_state = drm_atomic_get_crtc_state(state, crtc);
+   if (IS_ERR(crtc_state))
+   return PTR_ERR(crtc_state);
+
+   primary_state = drm_atomic_get_plane_state(state, crtc->primary);
+   if (IS_ERR(primary_state))
+   return PTR_ERR(primary_state);
+
+   if (!set->mode) {
+  

[Intel-gfx] [RFC v4 01/25] drm: provide management functions for drm_file

2018-04-12 Thread Noralf Trønnes
From: David Herrmann 

Rather than doing drm_file allocation/destruction right in the fops, lets
provide separate helpers. This decouples drm_file management from the
still-mandatory drm-fops. It prepares for use of drm_file without the
fops, both by possible separate fops implementations and APIs (not that I
am aware of any such plans), and more importantly from in-kernel use where
no real file is available.

Signed-off-by: David Herrmann 
Signed-off-by: Noralf Trønnes 
Reviewed-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_file.c | 305 +++--
 drivers/gpu/drm/drm_internal.h |   2 +
 2 files changed, 175 insertions(+), 132 deletions(-)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index e394799979a6..d4588d33f91c 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -101,6 +101,175 @@ DEFINE_MUTEX(drm_global_mutex);
 
 static int drm_open_helper(struct file *filp, struct drm_minor *minor);
 
+/**
+ * drm_file_alloc - allocate file context
+ * @minor: minor to allocate on
+ *
+ * This allocates a new DRM file context. It is not linked into any context and
+ * can be used by the caller freely. Note that the context keeps a pointer to
+ * @minor, so it must be freed before @minor is.
+ *
+ * RETURNS:
+ * Pointer to newly allocated context, ERR_PTR on failure.
+ */
+struct drm_file *drm_file_alloc(struct drm_minor *minor)
+{
+   struct drm_device *dev = minor->dev;
+   struct drm_file *file;
+   int ret;
+
+   file = kzalloc(sizeof(*file), GFP_KERNEL);
+   if (!file)
+   return ERR_PTR(-ENOMEM);
+
+   file->pid = get_pid(task_pid(current));
+   file->minor = minor;
+
+   /* for compatibility root is always authenticated */
+   file->authenticated = capable(CAP_SYS_ADMIN);
+   file->lock_count = 0;
+
+   INIT_LIST_HEAD(>lhead);
+   INIT_LIST_HEAD(>fbs);
+   mutex_init(>fbs_lock);
+   INIT_LIST_HEAD(>blobs);
+   INIT_LIST_HEAD(>pending_event_list);
+   INIT_LIST_HEAD(>event_list);
+   init_waitqueue_head(>event_wait);
+   file->event_space = 4096; /* set aside 4k for event buffer */
+
+   mutex_init(>event_read_lock);
+
+   if (drm_core_check_feature(dev, DRIVER_GEM))
+   drm_gem_open(dev, file);
+
+   if (drm_core_check_feature(dev, DRIVER_SYNCOBJ))
+   drm_syncobj_open(file);
+
+   if (drm_core_check_feature(dev, DRIVER_PRIME))
+   drm_prime_init_file_private(>prime);
+
+   if (dev->driver->open) {
+   ret = dev->driver->open(dev, file);
+   if (ret < 0)
+   goto out_prime_destroy;
+   }
+
+   if (drm_is_primary_client(file)) {
+   ret = drm_master_open(file);
+   if (ret)
+   goto out_close;
+   }
+
+   return file;
+
+out_close:
+   if (dev->driver->postclose)
+   dev->driver->postclose(dev, file);
+out_prime_destroy:
+   if (drm_core_check_feature(dev, DRIVER_PRIME))
+   drm_prime_destroy_file_private(>prime);
+   if (drm_core_check_feature(dev, DRIVER_SYNCOBJ))
+   drm_syncobj_release(file);
+   if (drm_core_check_feature(dev, DRIVER_GEM))
+   drm_gem_release(dev, file);
+   put_pid(file->pid);
+   kfree(file);
+
+   return ERR_PTR(ret);
+}
+
+static void drm_events_release(struct drm_file *file_priv)
+{
+   struct drm_device *dev = file_priv->minor->dev;
+   struct drm_pending_event *e, *et;
+   unsigned long flags;
+
+   spin_lock_irqsave(>event_lock, flags);
+
+   /* Unlink pending events */
+   list_for_each_entry_safe(e, et, _priv->pending_event_list,
+pending_link) {
+   list_del(>pending_link);
+   e->file_priv = NULL;
+   }
+
+   /* Remove unconsumed events */
+   list_for_each_entry_safe(e, et, _priv->event_list, link) {
+   list_del(>link);
+   kfree(e);
+   }
+
+   spin_unlock_irqrestore(>event_lock, flags);
+}
+
+/**
+ * drm_file_free - free file context
+ * @file: context to free, or NULL
+ *
+ * This destroys and deallocates a DRM file context previously allocated via
+ * drm_file_alloc(). The caller must make sure to unlink it from any contexts
+ * before calling this.
+ *
+ * If NULL is passed, this is a no-op.
+ *
+ * RETURNS:
+ * 0 on success, or error code on failure.
+ */
+void drm_file_free(struct drm_file *file)
+{
+   struct drm_device *dev;
+
+   if (!file)
+   return;
+
+   dev = file->minor->dev;
+
+   DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
+ task_pid_nr(current),
+ (long)old_encode_dev(file->minor->kdev->devt),
+ dev->open_count);
+
+   if (drm_core_check_feature(dev, 

[Intel-gfx] [RFC v4 00/25] drm: Add generic fbdev emulation

2018-04-12 Thread Noralf Trønnes
This patchset explores the possibility of having generic fbdev emulation
in DRM for drivers that supports dumb buffers which they can export. An
API is added to support in-kernel clients in general.

In this version I was able to reuse the modesetting code from
drm_fb_helper in the client API. This avoids code duplication, carries
over lessons learned and the modesetting code is bisectable. The
downside is that it takes +10 patches to rip drm_fb_helper in two, so
maybe it's not worth it wrt possible breakage and a challenging review.

Does the Intel CI test the fbdev emulation?

Daniel had this concern with the previous version:

The register/unregister model needs more thought. Allowing both clients
to register whenever they want to, and drm_device instances to come and
go is what fbcon has done, and the resulting locking is a horror show.

I think if we require that all in-kernel drm_clients are registers when
loading drm.ko (and enabled/disabled only per module options and
Kconfig), then we can throw out all the locking. That avoids a lot of
the headaches.

I have solved this by adding a notifier that fires when a new DRM device
is registered (I've removed the new() callback). Currently only
bootsplash uses this. The fbdev client needs to be setup from the driver
since it can't know on device registration if the driver will setup it's
own fbdev emulation later and the vtcon client hooks up to a user
provided device id.

Since fbcon can't handle fb_open failing, the buffer has to be
pre-allocated. Exporting a GEM buffer pins the driver module making it
impossible to unload it.
I have included 2 solutions to the problem:
- sysfs file to remove/close clients: remove_internal_clients
- Change drm_gem_prime_export() so it doesn't pin on client buffers

If a dumb buffer is exported from a kernel thread (worker) context, the
file descriptor isn't closed and I leak a reference so the buffer isn't
freed. Please look at drm_client_buffer_create() in patch
'drm/client: Finish the in-kernel client API'.
This is a blocker that needs a solution.


Noralf.

Changes since version 3:
Client API changes:
- Drop drm_client_register_funcs() which attached clients indirectly.
  Let clients attach directly using drm_client_new{_from_id}(). Clients
  that wants to attach to all devices must be linked into drm.ko and use
  the DRM device notifier. This is done to avoid the lock/race
  register/unregister hell we have with fbcon. (Daniel Vetter)
- drm_client_display_restore() checks if there is a master and if so
  returns -EBUSY. (Daniel Vetter)
- Allocate drm_file up front instead of on-demand. Since fbdev can't do
  on demand buffer allocation because of fbcon, there's no need for this.
- Add sysfs file to remove clients
- Don't pin driver module when exporting gem client buffers
- Dropped page flip support since drm_fb_helper is now used for fbdev
  emulation.

- The bootsplash client now switches over to fbdev on keypress.

Changes since version 2:
- Don't set drm master for in-kernel clients. (Daniel Vetter)
- Add in-kernel client API

Changes since version 1:
- Don't add drm_fb_helper_fb_open() and drm_fb_helper_fb_release() to
  DRM_FB_HELPER_DEFAULT_OPS(). (Fi.CI.STATIC)
  The following uses that macro and sets fb_open/close: udlfb_ops,
  amdgpufb_ops, drm_fb_helper_generic_fbdev_ops, nouveau_fbcon_ops,
  nouveau_fbcon_sw_ops, radeonfb_ops.
  This results in: warning: Initializer entry defined twice
- Support CONFIG_DRM_KMS_HELPER=m (kbuild test robot)
  ERROR:  [drivers/gpu/drm/drm_kms_helper.ko] undefined!
- Drop buggy patch: (Chris Wilson)
  drm/prime: Clear drm_gem_object->dma_buf on release
- Defer buffer creation until fb_open.


David Herrmann (1):
  drm: provide management functions for drm_file

Noralf Trønnes (24):
  drm/file: Don't set master on in-kernel clients
  drm/fb-helper: No need to cache rotation and sw_rotations
  drm/fb-helper: Remove drm_fb_helper_debug_enter/leave()
  drm/fb-helper: dpms_legacy(): Only set on connectors in use
  drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()
  drm: Begin an API for in-kernel clients
  drm/fb-helper: Use struct drm_client_display
  drm/fb-helper: Move modeset commit code to drm_client
  drm/connector: Add
drm_connector_has_preferred_mode/pick_cmdline_mode()
  drm/connector: Add connector array functions
  drm/i915: Add drm_driver->initial_client_display callback
  drm/fb-helper: Remove struct drm_fb_helper_crtc
  drm/fb-helper: Remove struct drm_fb_helper_connector
  drm/fb-helper: Move modeset config code to drm_client
  drm: Make ioctls available for in-kernel clients
  drm/client: Bail out if there's a DRM master
  drm/client: Make the display modes available to clients
  drm/client: Finish the in-kernel client API
  drm/prime: Don't pin module on export for in-kernel clients
  drm/fb-helper: Add drm_fb_helper_fb_open/release()
  drm/fb-helper: Add generic fbdev emulation
  drm: Add DRM device registered 

[Intel-gfx] [RFC v4 02/25] drm/file: Don't set master on in-kernel clients

2018-04-12 Thread Noralf Trønnes
It only makes sense for userspace clients.

Signed-off-by: Noralf Trønnes 
Reviewed-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_file.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index d4588d33f91c..55505378df47 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -155,17 +155,8 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor)
goto out_prime_destroy;
}
 
-   if (drm_is_primary_client(file)) {
-   ret = drm_master_open(file);
-   if (ret)
-   goto out_close;
-   }
-
return file;
 
-out_close:
-   if (dev->driver->postclose)
-   dev->driver->postclose(dev, file);
 out_prime_destroy:
if (drm_core_check_feature(dev, DRIVER_PRIME))
drm_prime_destroy_file_private(>prime);
@@ -365,6 +356,7 @@ static int drm_open_helper(struct file *filp, struct 
drm_minor *minor)
 {
struct drm_device *dev = minor->dev;
struct drm_file *priv;
+   int ret;
 
if (filp->f_flags & O_EXCL)
return -EBUSY;  /* No exclusive opens */
@@ -379,6 +371,14 @@ static int drm_open_helper(struct file *filp, struct 
drm_minor *minor)
if (IS_ERR(priv))
return PTR_ERR(priv);
 
+   if (drm_is_primary_client(priv)) {
+   ret = drm_master_open(priv);
+   if (ret) {
+   drm_file_free(priv);
+   return ret;
+   }
+   }
+
filp->private_data = priv;
priv->filp = filp;
 
-- 
2.15.1

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


Re: [Intel-gfx] [PATCH v1 5/6] drm/i915: Do not do fb src adjustments for NV12

2018-04-12 Thread Maarten Lankhorst
Op 12-04-18 om 12:07 schreef Srinivas, Vidya:
>
>> -Original Message-
>> From: Maarten Lankhorst [mailto:maarten.lankho...@linux.intel.com]
>> Sent: Wednesday, April 11, 2018 4:08 PM
>> To: Srinivas, Vidya ; intel-gfx-
>> try...@lists.freedesktop.org
>> Cc: Kamath, Sunil ; Saarinen, Jani
>> 
>> Subject: Re: [PATCH v1 5/6] drm/i915: Do not do fb src adjustments for
>> NV12
>>
>> Op 11-04-18 om 11:09 schreef Vidya Srinivas:
>>> We skip src trunction/adjustments for
>>> NV12 case and handle the sizes directly.
>>> Without this, pipe fifo underruns are seen on APL/KBL.
>>>
>>> Credits-to: Maarten Lankhorst 
>>> Signed-off-by: Vidya Srinivas 
>>> ---
>>>  drivers/gpu/drm/i915/intel_display.c | 88
>>> ++--
>>>  drivers/gpu/drm/i915/intel_sprite.c  | 10 +++-
>>>  2 files changed, 92 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/intel_display.c
>>> b/drivers/gpu/drm/i915/intel_display.c
>>> index ebb3f8e..e4cf7a6 100644
>>> --- a/drivers/gpu/drm/i915/intel_display.c
>>> +++ b/drivers/gpu/drm/i915/intel_display.c
>>> @@ -12951,6 +12951,86 @@ skl_max_scale(struct intel_crtc *intel_crtc,
>>> }
>>>
>>>  static int
>>> +intel_primary_plane_state(struct drm_plane_state *plane_state,
>>> + const struct drm_crtc_state *crtc_state,
>>> + int min_scale, int max_scale,
>>> + bool can_position, bool can_update_disabled) {
>>> +   struct drm_framebuffer *fb = plane_state->fb;
>>> +   struct drm_rect *src = _state->src;
>>> +   struct drm_rect *dst = _state->dst;
>>> +   unsigned int rotation = plane_state->rotation;
>>> +   struct drm_rect clip = {};
>>> +   int hscale, vscale;
>>> +
>>> +   WARN_ON(plane_state->crtc && plane_state->crtc != crtc_state-
>>> crtc);
>>> +
>>> +   *src = drm_plane_state_src(plane_state);
>>> +   *dst = drm_plane_state_dest(plane_state);
>>> +
>>> +   if (!fb) {
>>> +   plane_state->visible = false;
>>> +   return 0;
>>> +   }
>>> +
>>> +   /* crtc should only be NULL when disabling (i.e., !fb) */
>>> +   if (WARN_ON(!plane_state->crtc)) {
>>> +   plane_state->visible = false;
>>> +   return 0;
>>> +   }
>>> +
>>> +   if (!crtc_state->enable && !can_update_disabled) {
>>> +   DRM_DEBUG_KMS("Cannot update plane of a disabled
>> CRTC.\n");
>>> +   return -EINVAL;
>>> +   }
>>> +
>>> +   drm_rect_rotate(src, fb->width << 16, fb->height << 16, rotation);
>>> +
>>> +   /* Check scaling */
>>> +   hscale = drm_rect_calc_hscale(src, dst, min_scale, max_scale);
>>> +   vscale = drm_rect_calc_vscale(src, dst, min_scale, max_scale);
>>> +   if (hscale < 0 || vscale < 0) {
>>> +   DRM_DEBUG_KMS("Invalid scaling of plane\n");
>>> +   drm_rect_debug_print("src: ", _state->src, true);
>>> +   drm_rect_debug_print("dst: ", _state->dst, false);
>>> +   return -ERANGE;
>>> +   }
>>> +
>>> +   if (crtc_state->enable)
>>> +   drm_mode_get_hv_timing(_state->mode, ,
>> );
>>> +
>>> +   if (fb->format->format == DRM_FORMAT_NV12) {
>>> +   plane_state->visible = true;
>>> +   goto skip_clip;
>>> +   }
>>> +
>>> +   plane_state->visible =
>>> +   drm_rect_clip_scaled(src, dst, , hscale, vscale);
>> The real problem is that it needs to be a multiple of 4. I think the clipping
>> here is harmless, we should just adjust intel_check_sprite_plane for >= SKL.
>> This will make it so we don't have to duplicate its checks.
>>
>> For NV12 we still want to call clip_rect_scaled, but then adjust all
>> coordinates by dividing by 4 on before the check, and multiplying with 4
>> after?
>>
> Thank you. Have made the changes in 
> https://patchwork.freedesktop.org/patch/216682/
> With this, I did not see any underruns. For now, have a WA only when we pass 
> 16x16
> Because, with that it further clips down and gets rejected in 
> skl_update_scaler as it is
> Less than 16. If we increase our buffer in igt, then this issue wont be there.
> Please have a check. Initially, I tried the /4 before the adjustments and *4 
> later, that wouldn’t work
> We need to have the 16.16 values multiplier of 4. So, just put it towards the 
> end of both plane checks.   
Well, this is annoying.

It seems we never rejected subpixel precision before, and resorted to clipping 
instead of rejecting.
Could we be more strict about this without breaking existing userspace?

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


Re: [Intel-gfx] [PATCH v3] drm/i915/execlists: Set queue priority from secondary port

2018-04-12 Thread Chris Wilson
Quoting Tvrtko Ursulin (2018-04-11 13:03:00)
> 
> On 11/04/2018 12:34, Chris Wilson wrote:
> > Quoting Chris Wilson (2018-04-11 11:39:29)
> >> We can refine our current execlists->queue_priority if we inspect
> >> ELSP[1] rather than the head of the unsubmitted queue. Currently, we use
> >> the unsubmitted queue and say that if a subsequent request is more
> >> important than the current queue, we will rerun the submission tasklet
> >> to evaluate the need for preemption. However, we only want to preempt if
> >> we need to jump ahead of a currently executing request in ELSP. The
> >> second reason for running the submission tasklet is amalgamate requests
> >> into the active context on ELSP[0] to avoid a stall when ELSP[0] drains.
> >> (Though repeatedly amalgamating requests into the active context and
> >> triggering many lite-restore is off question gain, the goal really is to
> >> put a context into ELSP[1] to cover the interrupt.) So if instead of
> >> looking at the head of the queue, we look at the context in ELSP[1] we
> >> can answer both of the questions more accurately -- we don't need to
> >> rerun the submission tasklet unless our new request is important enough
> >> to feed into, at least, ELSP[1].
> >>
> >> v2: Add some comments from the discussion with Tvrtko.
> >> v3: More commentary to cross-reference queue_request()
> >>
> >> References: f6322eddaff7 ("drm/i915/preemption: Allow preemption between 
> >> submission ports")
> >> Signed-off-by: Chris Wilson 
> >> Cc: Michał Winiarski 
> >> Cc: Michel Thierry 
> >> Cc: Mika Kuoppala 
> >> Cc: Tvrtko Ursulin 
> > 
> >  From the discussion thread,
> > 
> > Reviewed-by: Tvrtko Ursulin 
> > 
> > I assume Tvrtko is happy with the comments added based on that
> > conversation.
> 
> Yes, all fine!

Forgot to say, thanks and pushed.

If you are feeling better, there's the igt that purports to hit the issue
as well: https://patchwork.freedesktop.org/series/41535/
Or one of the Ms!
-Chris
___
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/bios: reduce the scope of some local variables in parse_ddi_port()

2018-04-12 Thread Jani Nikula
On Wed, 11 Apr 2018, Chris Wilson  wrote:
> Quoting Jani Nikula (2018-04-11 14:15:19)
>> No functional changes.
>> 
>> Cc: Chris Wilson 
>> Signed-off-by: Jani Nikula 
>> ---
>>  drivers/gpu/drm/i915/intel_bios.c | 10 --
>>  1 file changed, 4 insertions(+), 6 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/i915/intel_bios.c 
>> b/drivers/gpu/drm/i915/intel_bios.c
>> index 447b721c3be9..036307af8419 100644
>> --- a/drivers/gpu/drm/i915/intel_bios.c
>> +++ b/drivers/gpu/drm/i915/intel_bios.c
>> @@ -1215,10 +1215,8 @@ static void parse_ddi_port(struct drm_i915_private 
>> *dev_priv, enum port port,
>>  {
>> struct child_device_config *it, *child = NULL;
>> struct ddi_vbt_port_info *info = _priv->vbt.ddi_port_info[port];
>> -   uint8_t hdmi_level_shift;
>> int i, j;
>> bool is_dvi, is_hdmi, is_dp, is_edp, is_crt;
>> -   uint8_t aux_channel, ddc_pin;
>> /* Each DDI port can have more than one value on the "DVO Port" 
>> field,
>>  * so look for all the possible values for each port.
>>  */
>> @@ -1255,8 +1253,6 @@ static void parse_ddi_port(struct drm_i915_private 
>> *dev_priv, enum port port,
>> if (!child)
>> return;
>>  
>> -   aux_channel = child->aux_channel;
>> -
>> is_dvi = child->device_type & DEVICE_TYPE_TMDS_DVI_SIGNALING;
>> is_dp = child->device_type & DEVICE_TYPE_DISPLAYPORT_OUTPUT;
>> is_crt = child->device_type & DEVICE_TYPE_ANALOG_OUTPUT;
>> @@ -1302,6 +1298,8 @@ static void parse_ddi_port(struct drm_i915_private 
>> *dev_priv, enum port port,
>> DRM_DEBUG_KMS("Port %c is internal DP\n", port_name(port));
>>  
>> if (is_dvi) {
>> +   u8 ddc_pin;
>> +
>> ddc_pin = map_ddc_pin(dev_priv, child->ddc_pin);
>> if (intel_gmbus_is_valid_pin(dev_priv, ddc_pin)) {
>> info->alternate_ddc_pin = ddc_pin;
>> @@ -1314,14 +1312,14 @@ static void parse_ddi_port(struct drm_i915_private 
>> *dev_priv, enum port port,
>> }
>>  
>> if (is_dp) {
>> -   info->alternate_aux_channel = aux_channel;
>> +   info->alternate_aux_channel = child->aux_channel;
>>  
>> sanitize_aux_ch(dev_priv, port);
>> }
>>  
>> if (bdb_version >= 158) {
>> /* The VBT HDMI level shift values match the table we have. 
>> */
>> -   hdmi_level_shift = child->hdmi_level_shifter_value;
>> +   u8 hdmi_level_shift = child->hdmi_level_shifter_value;
>
> checkpatch will ask for a \n,

Happily not, pushed as-is, thanks for the review.

BR,
Jani.



>
> Reviewed-by: Chris Wilson 
> -Chris

-- 
Jani Nikula, Intel Open Source Technology Center
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915/psr: vbt change for psr

2018-04-12 Thread Jani Nikula
On Wed, 11 Apr 2018, vathsala nagaraju  wrote:
> From: Vathsala Nagaraju 
>
> For psr block #9, the vbt description has moved to options [0-3] for
> TP1,TP2,TP3 Wakeup time from decimal value without any change to vbt
> structure. Since spec does not  mention from which VBT version this
> change was added to vbt.bsf file, we cannot depend on bdb->version check
> to change for all the platforms.
>
> There is RCR inplace for GOP team to  provide the version number
> to make generic change. Since Kabylake with bdb version 209 is having this
> change, limiting this change to kbl and version 209+ to unblock google.

The point was to move the whole abstraction to intel_bios.c, not just
the version check. To not need any is_tp_time_options field.

I think making platform based restrictions on the vbt fields unless
explicitly specified in the vbt bspec is the wrong thing to do.

BR,
Jani.

>
> bspec 20131
>
> v2: (Jani and Rodrigo)
> move the 165 version check to intel_bios.c
>
> Cc: Rodrigo Vivi 
> CC: Puthikorn Voravootivat 
>
> Signed-off-by: Maulik V Vaghela 
> Signed-off-by: Vathsala Nagaraju 
> ---
>  drivers/gpu/drm/i915/i915_drv.h   |  1 +
>  drivers/gpu/drm/i915/intel_bios.c |  3 ++
>  drivers/gpu/drm/i915/intel_psr.c  | 84 
> ++-
>  3 files changed, 61 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 5373b17..6aa6d68 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1075,6 +1075,7 @@ struct intel_vbt_data {
>   enum psr_lines_to_wait lines_to_wait;
>   int tp1_wakeup_time;
>   int tp2_tp3_wakeup_time;
> + int is_tp_time_options;
>   } psr;
>  
>   struct {
> diff --git a/drivers/gpu/drm/i915/intel_bios.c 
> b/drivers/gpu/drm/i915/intel_bios.c
> index c5c7530..08e82e0 100644
> --- a/drivers/gpu/drm/i915/intel_bios.c
> +++ b/drivers/gpu/drm/i915/intel_bios.c
> @@ -659,6 +659,9 @@ static int intel_bios_ssc_frequency(struct 
> drm_i915_private *dev_priv,
>   return;
>   }
>  
> + if (bdb->version >= 209 && IS_KABYLAKE(dev_priv))
> + dev_priv->vbt.psr.is_tp_time_options = true;
> +
>   psr_table = >psr_table[panel_type];
>  
>   dev_priv->vbt.psr.full_link = psr_table->full_link;
> diff --git a/drivers/gpu/drm/i915/intel_psr.c 
> b/drivers/gpu/drm/i915/intel_psr.c
> index 2d53f73..74ed6d0 100644
> --- a/drivers/gpu/drm/i915/intel_psr.c
> +++ b/drivers/gpu/drm/i915/intel_psr.c
> @@ -353,24 +353,45 @@ static void hsw_activate_psr1(struct intel_dp *intel_dp)
>   if (dev_priv->psr.link_standby)
>   val |= EDP_PSR_LINK_STANDBY;
>  
> - if (dev_priv->vbt.psr.tp1_wakeup_time > 5)
> - val |= EDP_PSR_TP1_TIME_2500us;
> - else if (dev_priv->vbt.psr.tp1_wakeup_time > 1)
> - val |= EDP_PSR_TP1_TIME_500us;
> - else if (dev_priv->vbt.psr.tp1_wakeup_time > 0)
> - val |= EDP_PSR_TP1_TIME_100us;
> - else
> - val |= EDP_PSR_TP1_TIME_0us;
> -
> - if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
> - val |= EDP_PSR_TP2_TP3_TIME_2500us;
> - else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
> - val |= EDP_PSR_TP2_TP3_TIME_500us;
> - else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 0)
> - val |= EDP_PSR_TP2_TP3_TIME_100us;
> - else
> - val |= EDP_PSR_TP2_TP3_TIME_0us;
> + if (dev_priv->vbt.psr.is_tp_time_options) {
> + if (dev_priv->vbt.psr.tp1_wakeup_time == 0)
> + val |= EDP_PSR_TP1_TIME_500us;
> + else if (dev_priv->vbt.psr.tp1_wakeup_time == 1)
> + val |= EDP_PSR_TP1_TIME_100us;
> + else if (dev_priv->vbt.psr.tp1_wakeup_time == 2)
> + val |= EDP_PSR_TP1_TIME_2500us;
> + else
> + val |= EDP_PSR_TP1_TIME_0us;
> + } else {
> + if (dev_priv->vbt.psr.tp1_wakeup_time > 5)
> + val |= EDP_PSR_TP1_TIME_2500us;
> + else if (dev_priv->vbt.psr.tp1_wakeup_time > 1)
> + val |= EDP_PSR_TP1_TIME_500us;
> + else if (dev_priv->vbt.psr.tp1_wakeup_time > 0)
> + val |= EDP_PSR_TP1_TIME_100us;
> + else
> + val |= EDP_PSR_TP1_TIME_0us;
> + }
>  
> + if (dev_priv->vbt.psr.is_tp_time_options) {
> + if (dev_priv->vbt.psr.tp2_tp3_wakeup_time == 0)
> + val |=  EDP_PSR_TP2_TP3_TIME_500us;
> + else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time == 1)
> + val |= EDP_PSR_TP2_TP3_TIME_100us;
> + else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time == 2)
> + val |= 

Re: [Intel-gfx] [PATCH v2] drm/i915/edp: Do not do link training fallback or prune modes on EDP

2018-04-12 Thread Jani Nikula
On Thu, 12 Apr 2018, Timo Aaltonen  wrote:
> On 30.01.2018 09:38, Jani Nikula wrote:
>> On Tue, 23 Jan 2018, Imre Deak  wrote:
>>> On Tue, Jan 23, 2018 at 11:48:22AM +0200, Jani Nikula wrote:
 On Mon, 22 Jan 2018, Imre Deak  wrote:
> On Fri, Jan 19, 2018 at 05:45:16PM +0200, Imre Deak wrote:
>> On Thu, Oct 12, 2017 at 12:13:38PM -0700, Manasi Navare wrote:
>>> In case of eDP because the panel has a fixed mode, the link rate
>>> and lane count at which it is trained corresponds to the link BW
>>> required to support the native resolution of the panel. In case of
>>> panles with lower resolutions where fewer lanes are hooked up 
>>> internally,
>>> that number is reflected in the MAX_LANE_COUNT DPCD register of the 
>>> panel.
>>> So it is pointless to fallback to lower link rate/lane count in case
>>> of link training failure on eDP connector since the lower link BW
>>> will not support the native resolution of the panel and we cannot
>>> prune the preferred mode on the eDP connector.
>>>
>>> In case of Link training failure on the eDP panel, something is wrong
>>> in the HW internally and hence driver errors out with a loud
>>> and clear DRM_ERROR message.
>>>
>>> v2:
>>> * Fix the DEBUG_ERROR and add {} in else (Ville Syrjala)
>>>
>>> Cc: Clinton Taylor 
>>> Cc: Jim Bride 
>>> Cc: Jani Nikula 
>>> Cc: Ville Syrjala 
>>> Cc: Dave Airlie 
>>> Cc: Daniel Vetter 
>>> Signed-off-by: Manasi Navare 
>>> Reviewed-by: Ville Syrjala 
>>
>> This fell through the cracks, looks like it partially fixes
>> https://bugs.freedesktop.org/show_bug.cgi?id=103369
>>
>> Why link training fails there is not clear.
>
> Ok, the link training fail turned out to be a race between a modeset
> link training and a link retraining called from
> runtime_resume->intel_hpd_init->dp_detect. As Ville pointed out that
> one was fixed meanwhile by
>
> commit 42e5e65765265485ecf2a480c244d76c2c624449
> Author: Daniel Vetter 
> AuthorDate: Mon Nov 13 17:01:40 2017 +0100
> Commit: Daniel Vetter 
> CommitDate: Thu Nov 23 14:59:07 2017 +0100
>
> drm/i915: sync dp link status checks against atomic commmits
>
> I merged now this fix to address the other issue, adding the above bug
> as reference. Thanks for the patch and the review.

 Thanks for the follow-up... but should we have added a Fixes: or cc:
 stable tag here?
>>>
>>> Fixes: 9301397a63b3 ("drm/i915: Implement Link Rate fallback on Link
>>> training failure")
>>>
>>> I wasn't sure about stable, since for me the link training failure
>>> happened only due to the bug fixed by 42e5e65765265. In any case I can't
>>> see how it could cause problems, so yes let's Cc: stable too.
>> 
>> Rodrigo, here's another one to cherry-pick to drm-intel-next-fixes.
>
> This patch fixes a regression with a BIOS upgrade on a Dell machine,
> where the screen would stay blank after resume from suspend. So I'd like
> it to find it's way to 4.15.x if that's still a thing.

I made the backport request to v4.13+, up to stable team which kernels
they care about.

BR,
Jani.

-- 
Jani Nikula, Intel Open Source Technology Center
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 0/9] GPU-bound energy efficiency improvements for the intel_pstate driver.

2018-04-12 Thread Peter Zijlstra
On Wed, Apr 11, 2018 at 09:26:11AM -0700, Francisco Jerez wrote:
> "just like" here is possibly somewhat unfair to the schedutil governor,
> admittedly its progressive IOWAIT boosting behavior seems somewhat less
> wasteful than the intel_pstate non-HWP governor's IOWAIT boosting
> behavior, but it's still largely unhelpful on IO-bound conditions.

So you understand why we need the iowait boosting right?

It is just that when we get back to runnable, we want to process the
next data packet ASAP. See also here:

  
https://lkml.kernel.org/r/20170522082154.f57cqovterd2q...@hirez.programming.kicks-ass.net

What I don't really understand is why it is costing so much power; after
all, when we're in iowait the CPU is mostly idle and can power-gate.
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH igt] igt/kms_plane_scaling: Open DRM_MASTER

2018-04-12 Thread Chris Wilson
Modesetting requires DRM_MASTER privileges, so use
drm_open_driver_master() to assert that we do acquire them.

References: https://bugs.freedesktop.org/show_bug.cgi?id=105997
Signed-off-by: Chris Wilson 
---
 tests/kms_plane_scaling.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c
index 9d3fe958..a8454205 100644
--- a/tests/kms_plane_scaling.c
+++ b/tests/kms_plane_scaling.c
@@ -532,7 +532,7 @@ igt_main
igt_skip_on_simulation();
 
igt_fixture {
-   data.drm_fd = drm_open_driver(DRIVER_INTEL);
+   data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
igt_require_pipe_crc(data.drm_fd);
igt_display_init(, data.drm_fd);
data.devid = intel_get_drm_devid(data.drm_fd);
-- 
2.17.0

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


Re: [Intel-gfx] [PATCH 1/1] drm/i915: move audio component intialization before audio driver use it

2018-04-12 Thread Shi, Yang A
>-Original Message-
>From: Jani Nikula [mailto:jani.nik...@linux.intel.com]
>Sent: Thursday, April 12, 2018 4:06 PM
>To: Shi, Yang A ; De Marchi, Lucas
>
>Cc: Chris Wilson ; intel-gfx@lists.freedesktop.org; 
>He, Bo
>; Deak, Imre 
>Subject: RE: [Intel-gfx] [PATCH 1/1] drm/i915: move audio component 
>intialization
>before audio driver use it
>
>On Thu, 12 Apr 2018, "Shi, Yang A"  wrote:
>> Dmesg is as following:
>
>Full dmesg from boot please.

Done, I already send it directly to you.
Thanks.

BR.
Yang.

>
>BR,
>Jani.
>
>
>--
>Jani Nikula, Intel Open Source Technology Center
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v2] drm/i915/edp: Do not do link training fallback or prune modes on EDP

2018-04-12 Thread Timo Aaltonen
On 30.01.2018 09:38, Jani Nikula wrote:
> On Tue, 23 Jan 2018, Imre Deak  wrote:
>> On Tue, Jan 23, 2018 at 11:48:22AM +0200, Jani Nikula wrote:
>>> On Mon, 22 Jan 2018, Imre Deak  wrote:
 On Fri, Jan 19, 2018 at 05:45:16PM +0200, Imre Deak wrote:
> On Thu, Oct 12, 2017 at 12:13:38PM -0700, Manasi Navare wrote:
>> In case of eDP because the panel has a fixed mode, the link rate
>> and lane count at which it is trained corresponds to the link BW
>> required to support the native resolution of the panel. In case of
>> panles with lower resolutions where fewer lanes are hooked up internally,
>> that number is reflected in the MAX_LANE_COUNT DPCD register of the 
>> panel.
>> So it is pointless to fallback to lower link rate/lane count in case
>> of link training failure on eDP connector since the lower link BW
>> will not support the native resolution of the panel and we cannot
>> prune the preferred mode on the eDP connector.
>>
>> In case of Link training failure on the eDP panel, something is wrong
>> in the HW internally and hence driver errors out with a loud
>> and clear DRM_ERROR message.
>>
>> v2:
>> * Fix the DEBUG_ERROR and add {} in else (Ville Syrjala)
>>
>> Cc: Clinton Taylor 
>> Cc: Jim Bride 
>> Cc: Jani Nikula 
>> Cc: Ville Syrjala 
>> Cc: Dave Airlie 
>> Cc: Daniel Vetter 
>> Signed-off-by: Manasi Navare 
>> Reviewed-by: Ville Syrjala 
>
> This fell through the cracks, looks like it partially fixes
> https://bugs.freedesktop.org/show_bug.cgi?id=103369
>
> Why link training fails there is not clear.

 Ok, the link training fail turned out to be a race between a modeset
 link training and a link retraining called from
 runtime_resume->intel_hpd_init->dp_detect. As Ville pointed out that
 one was fixed meanwhile by

 commit 42e5e65765265485ecf2a480c244d76c2c624449
 Author: Daniel Vetter 
 AuthorDate: Mon Nov 13 17:01:40 2017 +0100
 Commit: Daniel Vetter 
 CommitDate: Thu Nov 23 14:59:07 2017 +0100

 drm/i915: sync dp link status checks against atomic commmits

 I merged now this fix to address the other issue, adding the above bug
 as reference. Thanks for the patch and the review.
>>>
>>> Thanks for the follow-up... but should we have added a Fixes: or cc:
>>> stable tag here?
>>
>> Fixes: 9301397a63b3 ("drm/i915: Implement Link Rate fallback on Link
>> training failure")
>>
>> I wasn't sure about stable, since for me the link training failure
>> happened only due to the bug fixed by 42e5e65765265. In any case I can't
>> see how it could cause problems, so yes let's Cc: stable too.
> 
> Rodrigo, here's another one to cherry-pick to drm-intel-next-fixes.

This patch fixes a regression with a BIOS upgrade on a Dell machine,
where the screen would stay blank after resume from suspend. So I'd like
it to find it's way to 4.15.x if that's still a thing.


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


Re: [Intel-gfx] [PATCH 1/1] drm/i915: move audio component intialization before audio driver use it

2018-04-12 Thread Jani Nikula
On Thu, 12 Apr 2018, "Shi, Yang A"  wrote:
> Dmesg is as following:

Full dmesg from boot please.

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Technology Center
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 0/9] GPU-bound energy efficiency improvements for the intel_pstate driver.

2018-04-12 Thread Srinivas Pandruvada
On Wed, 2018-04-11 at 09:26 -0700, Francisco Jerez wrote:
> 
> "just like" here is possibly somewhat unfair to the schedutil
> governor,
> admittedly its progressive IOWAIT boosting behavior seems somewhat
> less
> wasteful than the intel_pstate non-HWP governor's IOWAIT boosting
> behavior, but it's still largely unhelpful on IO-bound conditions.
> 

OK, if you think so, then improve it for sched-util governor or other
mechanisms (as Juri suggested) instead of intel-pstate. This will
benefit all architectures including x86 + non i915.

BTW intel-pstate can be driven by sched-util governor (passive mode),
so if your prove benefits to Broxton, this can be a default.
As before:
- No regression to idle power at all. This is more important than
benchmarks
- Not just score, performance/watt is important

Thanks,
Srinivas


> > controller does, even though the frequent IO waits may actually be
> > an
> > indication that the system is IO-bound (which means that the large
> > energy usage increase may not be translated in any performance
> > benefit
> > in practice, not to speak of performance being impacted negatively
> > in
> > TDP-bound scenarios like GPU rendering).
> > 
> > Regarding run-time complexity, I haven't observed this governor to
> > be
> > measurably more computationally intensive than the present
> > one.  It's a
> > bunch more instructions indeed, but still within the same ballpark
> > as
> > the current governor.  The average increase in CPU utilization on
> > my BXT
> > with this series is less than 0.03% (sampled via ftrace for v1, I
> > can
> > repeat the measurement for the v2 I have in the works, though I
> > don't
> > expect the result to be substantially different).  If this is a
> > problem
> > for you there are several optimization opportunities that would cut
> > down
> > the number of CPU cycles get_target_pstate_lp() takes to execute by
> > a
> > large percent (most of the optimization ideas I can think of right
> > now
> > though would come at some accuracy/maintainability/debuggability
> > cost,
> > but may still be worth pursuing), but the computational overhead is
> > low
> > enough at this point that the impact on any benchmark or real
> > workload
> > would be orders of magnitude lower than its variance, which makes
> > it
> > kind of difficult to keep the discussion data-driven [as possibly
> > any
> > performance optimization discussion should ever be ;)].
> > 
> > > 
> > > Thanks,
> > > Srinivas
> > > 
> > > 
> > > 
> > > > 
> > > > > [Absolute benchmark results are unfortunately omitted from
> > > > > this
> > > > > letter
> > > > > due to company policies, but the percent change and Student's
> > > > > T
> > > > > p-value are included above and in the referenced benchmark
> > > > > results]
> > > > > 
> > > > > The most obvious impact of this series will likely be the
> > > > > overall
> > > > > improvement in graphics performance on systems with an IGP
> > > > > integrated
> > > > > into the processor package (though for the moment this is
> > > > > only
> > > > > enabled
> > > > > on BXT+), because the TDP budget shared among CPU and GPU can
> > > > > frequently become a limiting factor in low-power devices.  On
> > > > > heavily
> > > > > TDP-bound devices this series improves performance of
> > > > > virtually any
> > > > > non-trivial graphics rendering by a significant amount (of
> > > > > the
> > > > > order
> > > > > of the energy efficiency improvement for that workload
> > > > > assuming the
> > > > > optimization didn't cause it to become non-TDP-bound).
> > > > > 
> > > > > See [1]-[5] for detailed numbers including various graphics
> > > > > benchmarks
> > > > > and a sample of the Phoronix daily-system-tracker.  Some
> > > > > popular
> > > > > graphics benchmarks like GfxBench gl_manhattan31 and gl_4
> > > > > improve
> > > > > between 5% and 11% on our systems.  The exact improvement can
> > > > > vary
> > > > > substantially between systems (compare the benchmark results
> > > > > from
> > > > > the
> > > > > two different J3455 systems [1] and [3]) due to a number of
> > > > > factors,
> > > > > including the ratio between CPU and GPU processing power, the
> > > > > behavior
> > > > > of the userspace graphics driver, the windowing system and
> > > > > resolution,
> > > > > the BIOS (which has an influence on the package TDP), the
> > > > > thermal
> > > > > characteristics of the system, etc.
> > > > > 
> > > > > Unigine Valley and Heaven improve by a similar factor on some
> > > > > systems
> > > > > (see the J3455 results [1]), but on others the improvement is
> > > > > lower
> > > > > because the benchmark fails to fully utilize the GPU, which
> > > > > causes
> > > > > the
> > > > > heuristic to remain in low-latency state for longer, which
> > > > > leaves a
> > > > > reduced TDP budget available to the GPU, which prevents
> > > > > performance
> > > > > from increasing further.  This can be avoided by using the
> > > > > alternative
> > > > >