Re: [Intel-gfx] [PATCH] drm/i915/display: Trigger Modeset at boot for audio codec init

2020-03-23 Thread Khor, Swee Aun
Git diff without debug print. Please review. Thanks. 

diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index 4d1634ed6a1b..806cf622fb39 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -14108,11 +14108,13 @@ static int intel_atomic_check(struct drm_device *dev,
int ret, i;
bool any_ms = false;
 
+
/* Catch I915_MODE_FLAG_INHERITED */
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
new_crtc_state, i) {
-   if (new_crtc_state->hw.mode.private_flags !=
-   old_crtc_state->hw.mode.private_flags)
+
+   if (new_crtc_state->uapi.mode.private_flags !=
+   old_crtc_state->uapi.mode.private_flags)
new_crtc_state->uapi.mode_changed = true;
}

Regards,
SweeAun

-Original Message-
From: Khor, Swee Aun 
Sent: Monday, March 23, 2020 10:29 PM
To: 'Ville Syrjälä' ; Shankar, Uma 

Cc: Souza, Jose ; 'intel-gfx@lists.freedesktop.org' 

Subject: RE: [Intel-gfx] [PATCH] drm/i915/display: Trigger Modeset at boot for 
audio codec init

Hi Ville, 

You are right, your suggestion will fix this issue.

#Based on dmesg log, uapi mode private flags change is captured ...
[   11.404578] fbcon: i915drmfb (fb0) is primary device
[   11.404743] [drm] SA: intel_atomic_check: uapi change 
[   11.404744] [drm] SA2: intel_atomic_check: 
new_crtc_state->uapi.mode.private_flags= 0, 
old_crtc_state->uapi.mode.private_flags= 1  
[   11.404744] [drm] SA2: intel_atomic_check: 
new_crtc_state->uapi.mode.private_flags= 0, 
old_crtc_state->uapi.mode.private_flags= 0  
[   11.404745] [drm] SA2: intel_atomic_check: 
new_crtc_state->uapi.mode.private_flags= 0, 
old_crtc_state->uapi.mode.private_flags= 0  
[   11.404799] [drm:intel_atomic_check [i915]] [CONNECTOR:110:HDMI-A-2] 
Limiting display bpp to 24 instead of EDID bpp 24, requested bpp 36, max 
platform bpp 36
[   11.404855] [drm:intel_hdmi_compute_config [i915]] picking 8 bpc for HDMI 
output (pipe bpp: 24)
[   11.404898] [drm:intel_atomic_check [i915]] hw max bpp: 24, pipe bpp: 24, 
dithering: 0
...

#Here is the git diff
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index 4d1634ed6a1b..b5c56cd513d9 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -14108,11 +14108,15 @@ static int intel_atomic_check(struct drm_device *dev,
int ret, i;
bool any_ms = false;
 
+   DRM_INFO("SA: intel_atomic_check: uapi change \n");
+
/* Catch I915_MODE_FLAG_INHERITED */
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
new_crtc_state, i) {
-   if (new_crtc_state->hw.mode.private_flags !=
-   old_crtc_state->hw.mode.private_flags)
+
+   DRM_INFO("SA2: intel_atomic_check: 
new_crtc_state->uapi.mode.private_flags= %d, 
old_crtc_state->uapi.mode.private_flags= %d  \n", 
new_crtc_state->uapi.mode.private_flags, 
old_crtc_state->uapi.mode.private_flags );
+   if (new_crtc_state->uapi.mode.private_flags !=
+   old_crtc_state->uapi.mode.private_flags)
new_crtc_state->uapi.mode_changed = true;
}

Regards,
SweeAun

-Original Message-
From: Khor, Swee Aun
Sent: Saturday, March 21, 2020 12:55 AM
To: Ville Syrjälä ; Shankar, Uma 

Cc: Souza, Jose ; intel-gfx@lists.freedesktop.org
Subject: RE: [Intel-gfx] [PATCH] drm/i915/display: Trigger Modeset at boot for 
audio codec init

Hi Ville,
You means this change right? Sure. Will try your suggestion as well. 
By the way, what is different between hw.mode and uapi.mode and how we know 
which to be used? It used to only base.mode before hw/uapi split patches. 

> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -14671,8 +14671,8 @@ static int intel_atomic_check(struct drm_device *dev,
> /* Catch I915_MODE_FLAG_INHERITED */
> for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
> new_crtc_state, i) {
> -   if (new_crtc_state->hw.mode.private_flags !=
> -   old_crtc_state->hw.mode.private_flags)
> +   if (new_crtc_state->uapi.mode.private_flags !=
> +   old_crtc_state->uapi.mode.private_flags)
> new_crtc_state->uapi.mode_changed = true;
> }
> 
> ?

Regards,
SweeAun

-Original Message-
From: Ville Syrjälä 
Sent: Friday, March 20, 2020 11:24 PM
To: Shankar, Uma 
Cc: Souza, Jose ; intel-gfx@lists.freedesktop.org; Khor, 
Swee Aun 
Subject: Re: [Intel-gfx] [PATCH] drm/i915/display: Trigger Modeset at boot for 
audio codec init

On Fri, Mar 20, 

[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for DP Phy compliance auto test (rev9)

2020-03-23 Thread Patchwork
== Series Details ==

Series: DP Phy compliance auto test (rev9)
URL   : https://patchwork.freedesktop.org/series/71121/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
4e5780212f95 drm/amd/display: Align macro name as per DP spec
971a7ccb9e37 drm/dp: get/set phy compliance pattern
1b2997dcbda5 drm/i915/dp: Made intel_dp_adjust_train() non-static
340216da24fa drm/i915/dp: Preparation for DP phy compliance auto test
db7de8a9c187 drm/i915/dp: Add debugfs entry for DP phy compliance
608ba015c19c drm/i915/dp: Register definition for DP compliance register
-:29: WARNING:LONG_LINE: line over 100 characters
#29: FILE: drivers/gpu/drm/i915/i915_reg.h:9800:
+#define DDI_DP_COMP_CTL(pipe)  _MMIO_PIPE(pipe, 
_DDI_DP_COMP_CTL_A, _DDI_DP_COMP_CTL_B)

-:42: WARNING:LONG_LINE: line over 100 characters
#42: FILE: drivers/gpu/drm/i915/i915_reg.h:9813:
+#define DDI_DP_COMP_PAT(pipe, i)   _MMIO(_PIPE(pipe, 
_DDI_DP_COMP_PAT_A, _DDI_DP_COMP_PAT_B) + (i) * 4)

total: 0 errors, 2 warnings, 0 checks, 24 lines checked
eeecea37ecbc drm/i915/dp: Program vswing, pre-emphasis, test-pattern

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


[Intel-gfx] [PATCH v7 6/7] drm/i915/dp: Register definition for DP compliance register

2020-03-23 Thread Animesh Manna
DP_COMP_CTL and DP_COMP_PAT register used to program DP
compliance pattern.

v1: Initial patch.
v2: used pipe instead of port in macro definition. [Manasi]
v3: used trans_offset for offset calculation. [Manasi]
v4: Used MMIO_PIPE for evenly spaced register offset instead
MMIO_PIPE2. [Ville]

Reviewed-by: Manasi Navare 
Signed-off-by: Animesh Manna 
---
 drivers/gpu/drm/i915/i915_reg.h | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 309cb7d96b35..465862ed2cf8 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -9792,6 +9792,24 @@ enum skl_power_gate {
 #define  DDI_BUF_BALANCE_LEG_ENABLE(1 << 31)
 #define DDI_BUF_TRANS_HI(port, i)  _MMIO(_PORT(port, _DDI_BUF_TRANS_A, 
_DDI_BUF_TRANS_B) + (i) * 8 + 4)
 
+/* DDI DP Compliance Control */
+#define _DDI_DP_COMP_CTL_A 0x605F0
+#define _DDI_DP_COMP_CTL_B 0x615F0
+#define DDI_DP_COMP_CTL(pipe)  _MMIO_PIPE(pipe, 
_DDI_DP_COMP_CTL_A, _DDI_DP_COMP_CTL_B)
+#define   DDI_DP_COMP_CTL_ENABLE   (1 << 31)
+#define   DDI_DP_COMP_CTL_D10_2(0 << 28)
+#define   DDI_DP_COMP_CTL_SCRAMBLED_0  (1 << 28)
+#define   DDI_DP_COMP_CTL_PRBS7(2 << 28)
+#define   DDI_DP_COMP_CTL_CUSTOM80 (3 << 28)
+#define   DDI_DP_COMP_CTL_HBR2 (4 << 28)
+#define   DDI_DP_COMP_CTL_SCRAMBLED_1  (5 << 28)
+#define   DDI_DP_COMP_CTL_HBR2_RESET   (0xFC << 0)
+
+/* DDI DP Compliance Pattern */
+#define _DDI_DP_COMP_PAT_A 0x605F4
+#define _DDI_DP_COMP_PAT_B 0x615F4
+#define DDI_DP_COMP_PAT(pipe, i)   _MMIO(_PIPE(pipe, 
_DDI_DP_COMP_PAT_A, _DDI_DP_COMP_PAT_B) + (i) * 4)
+
 /* Sideband Interface (SBI) is programmed indirectly, via
  * SBI_ADDR, which contains the register offset; and SBI_DATA,
  * which contains the payload */
-- 
2.24.0

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


Re: [Intel-gfx] [PATCH 1/3] drm/i915/perf: rework aging tail workaround

2020-03-23 Thread Umesh Nerlige Ramappa

On Sat, Mar 21, 2020 at 09:44:43PM -0700, Dixit, Ashutosh wrote:

On Sat, 21 Mar 2020 16:26:42 -0700, Dixit, Ashutosh wrote:


On Thu, 19 Mar 2020 15:52:01 -0700, Umesh Nerlige Ramappa wrote:
>
> From: Lionel Landwerlin 

> @@ -477,16 +468,6 @@ static bool oa_buffer_check_unlocked(struct 
i915_perf_stream *stream)
> */
>spin_lock_irqsave(>oa_buffer.ptr_lock, flags);
>
>hw_tail = stream->perf->ops.oa_hw_tail_read(stream);
>
>hw_tail &= ~(report_size - 1);
>
> @@ -496,64 +477,64 @@ static bool oa_buffer_check_unlocked(struct 
i915_perf_stream *stream)
>
>now = ktime_get_mono_fast_ns();
>
> +  if (hw_tail == stream->oa_buffer.aging_tail &&
> + (now - stream->oa_buffer.aging_timestamp) > OA_TAIL_MARGIN_NSEC) {
> +  /* If the HW tail hasn't move since the last check and the HW
> +   * tail has been aging for long enough, declare it the new
> +   * tail.
> +   */
> +  stream->oa_buffer.tail = stream->oa_buffer.aging_tail;
> +  } else {
> +  u32 head, tail;
>
> +  /* NB: The head we observe here might effectively be a little
> +   * out of date. If a read() is in progress, the head could be
> +   * anywhere between this head and stream->oa_buffer.tail.
> +   */
> +  head = stream->oa_buffer.head - gtt_offset;
>
> +  hw_tail -= gtt_offset;
> +  tail = hw_tail;
>
> +  /* Walk the stream backward until we find a report with dword 0
> +   * & 1 not at 0. Since the circular buffer pointers progress by
> +   * increments of 64 bytes and that reports can be up to 256
> +   * bytes long, we can't tell whether a report has fully landed
> +   * in memory before the first 2 dwords of the following report
> +   * have effectively landed.
> +   *
> +   * This is assuming that the writes of the OA unit land in
> +   * memory in the order they were written to.
> +   * If not : (╯°□°)╯︵ ┻━┻
> */
> +  while (OA_TAKEN(tail, head) >= report_size) {
> +  u32 previous_tail = (tail - report_size) & (OA_BUFFER_SIZE 
- 1);
> +  u32 *report32 = (void *)(stream->oa_buffer.vaddr + 
previous_tail);

Sorry, this is wrong. This should just be:

tail = (tail - report_size) & (OA_BUFFER_SIZE - 1);
report32 = (void *)(stream->oa_buffer.vaddr + tail);

Otherwise when we break out of the loop below tail is still set one
report_size ahead. previous_tail is not needed. (In the previous version of
the patch this used to work out correctly).

> +
> +  /* Head of the report indicated by the HW tail register has
> +   * indeed landed into memory.
> +   */
> +  if (report32[0] != 0 || report32[1] != 0)
> +  break;
> +
> +  tail = previous_tail;
>}


Actually a couple of further improvements to the loop above are
possible. First there is no reason to start at previous_tail, we can just
start at the aligned hw_tail itself. Therefore the loop becomes:

while (OA_TAKEN(tail, head) >= report_size) {
u32 *report32 = (void *)(stream->oa_buffer.vaddr + 
tail);

if (report32[0] != 0 || report32[1] != 0)
break;

tail = (tail - report_size) & (OA_BUFFER_SIZE - 1);
}

Further, there is no reason to go back to the head but only to the old
tail. Therefore:

head = stream->oa_buffer.head - gtt_offset;
old_tail = stream->oa_buffer.tail - gtt_offset;

hw_tail -= gtt_offset;
tail = hw_tail;

while (OA_TAKEN(tail, old_tail) >= report_size) {
u32 *report32 = (void *)(stream->oa_buffer.vaddr + 
tail);

if (report32[0] != 0 || report32[1] != 0)
break;

tail = (tail - report_size) & (OA_BUFFER_SIZE - 1);
}

Please review and see if these two improvements are possible. Thanks!


I think that this is possible. We could check reports between old_tail 
and tail to optimize the number of reports we read. I will give this a 
try.


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


Re: [Intel-gfx] [PATCH 1/3] drm/i915/perf: rework aging tail workaround

2020-03-23 Thread Umesh Nerlige Ramappa

On Sat, Mar 21, 2020 at 04:26:42PM -0700, Dixit, Ashutosh wrote:

On Thu, 19 Mar 2020 15:52:01 -0700, Umesh Nerlige Ramappa wrote:


From: Lionel Landwerlin 

We're about to introduce an options to open the perf stream, giving
the user ability to configure how often it wants the kernel to poll
the OA registers for available data.

Right now the workaround against the OA tail pointer race condition
requires at least twice the internal kernel polling timer to make any
data available.

This changes introduce checks on the OA data written into the circular
buffer to make as much data as possible available on the first
iteration of the polling timer.


/snip/


diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 3222f6cd8255..c1429d3acaf9 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -223,26 +223,17 @@
  *
  * Although this can be observed explicitly while copying reports to userspace
  * by checking for a zeroed report-id field in tail reports, we want to account
- * for this earlier, as part of the oa_buffer_check to avoid lots of redundant
- * read() attempts.
- *
- * In effect we define a tail pointer for reading that lags the real tail
- * pointer by at least %OA_TAIL_MARGIN_NSEC nanoseconds, which gives enough
- * time for the corresponding reports to become visible to the CPU.
- *
- * To manage this we actually track two tail pointers:
- *  1) An 'aging' tail with an associated timestamp that is tracked until we
- * can trust the corresponding data is visible to the CPU; at which point
- * it is considered 'aged'.
- *  2) An 'aged' tail that can be used for read()ing.
- *
- * The two separate pointers let us decouple read()s from tail pointer aging.
- *
- * The tail pointers are checked and updated at a limited rate within a hrtimer
- * callback (the same callback that is used for delivering EPOLLIN events)
- *
- * Initially the tails are marked invalid with %INVALID_TAIL_PTR which
- * indicates that an updated tail pointer is needed.
+ * for this earlier, as part of the oa_buffer_check_unlocked to avoid lots of
+ * redundant read() attempts.
+ *
+ * We workaround this issue in oa_buffer_check_unlocked() by reading the 
reports
+ * in the OA buffer, starting from the tail reported by the HW until we find 2
+ * consecutive reports with their first 2 dwords of not at 0. Those dwords are


until we find a report with its first 2 dwords not 0 meaning its previous
report is completely in memory and ready to be read.


+ * also set to 0 once read and the whole buffer is cleared upon OA buffer
+ * initialization. The first dword is the reason for this report while the
+ * second is the timestamp, making the chances of having those 2 fields at 0
+ * fairly unlikely. A more detailed explanation is available in
+ * oa_buffer_check_unlocked().



@@ -477,16 +468,6 @@ static bool oa_buffer_check_unlocked(struct 
i915_perf_stream *stream)
 */
spin_lock_irqsave(>oa_buffer.ptr_lock, flags);

hw_tail = stream->perf->ops.oa_hw_tail_read(stream);

hw_tail &= ~(report_size - 1);

@@ -496,64 +477,64 @@ static bool oa_buffer_check_unlocked(struct 
i915_perf_stream *stream)

now = ktime_get_mono_fast_ns();

+   if (hw_tail == stream->oa_buffer.aging_tail &&
+  (now - stream->oa_buffer.aging_timestamp) > OA_TAIL_MARGIN_NSEC) {
+   /* If the HW tail hasn't move since the last check and the HW
+* tail has been aging for long enough, declare it the new
+* tail.
+*/
+   stream->oa_buffer.tail = stream->oa_buffer.aging_tail;
+   } else {
+   u32 head, tail;

+   /* NB: The head we observe here might effectively be a little
+* out of date. If a read() is in progress, the head could be
+* anywhere between this head and stream->oa_buffer.tail.
+*/
+   head = stream->oa_buffer.head - gtt_offset;

+   hw_tail -= gtt_offset;
+   tail = hw_tail;

+   /* Walk the stream backward until we find a report with dword 0
+* & 1 not at 0. Since the circular buffer pointers progress by
+* increments of 64 bytes and that reports can be up to 256
+* bytes long, we can't tell whether a report has fully landed
+* in memory before the first 2 dwords of the following report
+* have effectively landed.
+*
+* This is assuming that the writes of the OA unit land in
+* memory in the order they were written to.
+* If not : (╯°□°)╯︵ ┻━┻
 */
-   if (hw_tail >= gtt_offset &&
-   hw_tail < (gtt_offset + OA_BUFFER_SIZE)) {
-   stream->oa_buffer.tails[!aged_idx].offset =
-   aging_tail = hw_tail;
-

[Intel-gfx] ✓ Fi.CI.IGT: success for drm/mm: Only allow sleeping if the caller permits

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm/mm: Only allow sleeping if the caller permits
URL   : https://patchwork.freedesktop.org/series/74985/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_8180_full -> Patchwork_17059_full


Summary
---

  **SUCCESS**

  No regressions found.

  

New tests
-

  New tests have been introduced between CI_DRM_8180_full and 
Patchwork_17059_full:

### New Piglit tests (1) ###

  * spec@!opengl 1.2@tex3d-maxsize:
- Statuses : 1 fail(s)
- Exec time: [3.59] s

  

Known issues


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

### IGT changes ###

 Issues hit 

  * igt@gem_busy@busy-vcs1:
- shard-iclb: [PASS][1] -> [SKIP][2] ([fdo#112080]) +19 similar 
issues
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-iclb4/igt@gem_b...@busy-vcs1.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/shard-iclb7/igt@gem_b...@busy-vcs1.html

  * igt@gem_ctx_isolation@rcs0-s3:
- shard-kbl:  [PASS][3] -> [DMESG-WARN][4] ([i915#180]) +4 similar 
issues
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-kbl7/igt@gem_ctx_isolat...@rcs0-s3.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/shard-kbl4/igt@gem_ctx_isolat...@rcs0-s3.html

  * igt@gem_exec_balancer@smoke:
- shard-iclb: [PASS][5] -> [SKIP][6] ([fdo#110854])
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-iclb1/igt@gem_exec_balan...@smoke.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/shard-iclb7/igt@gem_exec_balan...@smoke.html

  * igt@gem_exec_schedule@fifo-bsd1:
- shard-iclb: [PASS][7] -> [SKIP][8] ([fdo#109276]) +16 similar 
issues
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-iclb1/igt@gem_exec_sched...@fifo-bsd1.html
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/shard-iclb7/igt@gem_exec_sched...@fifo-bsd1.html

  * igt@gem_exec_schedule@implicit-both-bsd2:
- shard-iclb: [PASS][9] -> [SKIP][10] ([fdo#109276] / [i915#677]) 
+2 similar issues
   [9]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-iclb1/igt@gem_exec_sched...@implicit-both-bsd2.html
   [10]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/shard-iclb7/igt@gem_exec_sched...@implicit-both-bsd2.html

  * igt@gem_exec_schedule@pi-distinct-iova-bsd:
- shard-iclb: [PASS][11] -> [SKIP][12] ([i915#677]) +2 similar 
issues
   [11]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-iclb7/igt@gem_exec_sched...@pi-distinct-iova-bsd.html
   [12]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/shard-iclb2/igt@gem_exec_sched...@pi-distinct-iova-bsd.html

  * igt@gem_exec_schedule@preemptive-hang-bsd:
- shard-iclb: [PASS][13] -> [SKIP][14] ([fdo#112146]) +2 similar 
issues
   [13]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-iclb8/igt@gem_exec_sched...@preemptive-hang-bsd.html
   [14]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/shard-iclb4/igt@gem_exec_sched...@preemptive-hang-bsd.html

  * igt@kms_cursor_crc@pipe-a-cursor-suspend:
- shard-skl:  [PASS][15] -> [INCOMPLETE][16] ([i915#300])
   [15]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-skl3/igt@kms_cursor_...@pipe-a-cursor-suspend.html
   [16]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/shard-skl3/igt@kms_cursor_...@pipe-a-cursor-suspend.html

  * igt@kms_cursor_crc@pipe-c-cursor-suspend:
- shard-apl:  [PASS][17] -> [DMESG-WARN][18] ([i915#180]) +1 
similar issue
   [17]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-apl2/igt@kms_cursor_...@pipe-c-cursor-suspend.html
   [18]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/shard-apl6/igt@kms_cursor_...@pipe-c-cursor-suspend.html

  * igt@kms_cursor_legacy@cursor-vs-flip-toggle:
- shard-hsw:  [PASS][19] -> [FAIL][20] ([i915#57])
   [19]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-hsw4/igt@kms_cursor_leg...@cursor-vs-flip-toggle.html
   [20]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/shard-hsw6/igt@kms_cursor_leg...@cursor-vs-flip-toggle.html

  * igt@kms_draw_crc@draw-method-xrgb2101010-render-ytiled:
- shard-skl:  [PASS][21] -> [FAIL][22] ([i915#52] / [i915#54]) +1 
similar issue
   [21]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-skl3/igt@kms_draw_...@draw-method-xrgb2101010-render-ytiled.html
   [22]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/shard-skl3/igt@kms_draw_...@draw-method-xrgb2101010-render-ytiled.html

  * igt@kms_flip@flip-vs-expired-vblank-interruptible:
- shard-glk:  [PASS][23] -> [FAIL][24] ([i915#79])
   [23]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-glk8/igt@kms_f...@flip-vs-expired-vblank-interruptible.html
   

Re: [Intel-gfx] [RFC] GPU-bound energy efficiency improvements for the intel_pstate driver (v2).

2020-03-23 Thread Francisco Jerez
"Pandruvada, Srinivas"  writes:

> Hi Francisco,
>
> On Tue, 2020-03-10 at 14:41 -0700, Francisco Jerez wrote:
>> This is my second take on improving the energy efficiency of the
>> intel_pstate driver under IO-bound conditions.  The problem and
>> approach to solve it are roughly the same as in my previous series
>> [1]
>> at a high level:
>> 
>> In IO-bound scenarios (by definition) the throughput of the system
>> doesn't improve with increasing CPU frequency beyond the threshold
>> value at which the IO device becomes the bottleneck, however with the
>> current governors (whether HWP is in use or not) the CPU frequency
>> tends to oscillate with the load, often with an amplitude far into
>> the
>> turbo range, leading to severely reduced energy efficiency, which is
>> particularly problematic when a limited TDP budget is shared among a
>> number of cores running some multithreaded workload, or among a CPU
>> core and an integrated GPU.
>> 
>> Improving the energy efficiency of the CPU improves the throughput of
>> the system in such TDP-limited conditions.  See [4] for some
>> preliminary benchmark results from a Razer Blade Stealth 13 Late
>> 2019/LY320 laptop with an Intel ICL processor and integrated
>> graphics,
>> including throughput results that range up to a ~15% improvement and
>> performance-per-watt results up to a ~43% improvement (estimated via
>> RAPL).  Particularly the throughput results may vary substantially
>> from one platform to another depending on the TDP budget and the
>> balance of load between CPU and GPU.
>> 
>
> You changed the EPP to 0 intentionally or unintentionally. We know that
> all energy optimization will be disabled with this change. 
> This test was done on an ICL system.
>

Hmm, that's bad, and fully unintentional.  It's probably a side effect
of intel_pstate_reset_vlp() running before intel_pstate_hwp_set(), which
could cause it to use an uninitialized value of hwp_req_cached (zero?).
I'll fix it in v3.  Thanks a lot for pointing this out.

>
> Basically without your patches on top of linux-next: EPP = 0x80
> $sudo rdmsr -a 0x774
> 80002704
> 80002704
> 80002704
> 80002704
> 80002704
> 80002704
> 80002704
> 80002704
>
>
> After your patches
>
> $sudo rdmsr -a 0x774
> 2704
> 2704
> 2704
> 2704
> 2704
> 2704
> 2704
> 2704
>
> I added some prints, basically you change the EPP at startup before
> regular HWP request update path and update on top. So boot up EPP is
> overwritten.
>
>
> [5.867476] intel_pstate_reset_vlp hwp_req cached:0
> [5.872426] intel_pstate_reset_vlp hwp_req:404
> [5.881645] intel_pstate_reset_vlp hwp_req cached:0
> [5.886634] intel_pstate_reset_vlp hwp_req:404
> [5.895819] intel_pstate_reset_vlp hwp_req cached:0
> [5.900958] intel_pstate_reset_vlp hwp_req:404
> [5.910321] intel_pstate_reset_vlp hwp_req cached:0
> [5.915406] intel_pstate_reset_vlp hwp_req:404
> [5.924623] intel_pstate_reset_vlp hwp_req cached:0
> [5.929564] intel_pstate_reset_vlp hwp_req:404
> [5.944039] intel_pstate_reset_vlp hwp_req cached:0
> [5.951672] intel_pstate_reset_vlp hwp_req:404
> [5.966157] intel_pstate_reset_vlp hwp_req cached:0
> [5.973808] intel_pstate_reset_vlp hwp_req:404
> [5.988223] intel_pstate_reset_vlp hwp_req cached:0
> [5.995823] intel_pstate_reset_vlp hwp_req:404
> [6.010062] intel_pstate: HWP enabled
>
> Thanks,
> Srinivas
>
>
>
>> One of the main differences relative to my previous version is that
>> the trade-off between energy efficiency and frequency ramp-up latency
>> is now exposed to device drivers through a new PM QoS class [It would
>> make sense to expose it to userspace too eventually but that's beyond
>> the purpose of this series].  The new PM QoS class provides a latency
>> target to CPUFREQ governors which gives them permission to filter out
>> CPU frequency oscillations with a period significantly shorter than
>> the specified target, whenever doing so leads to improved energy
>> efficiency.
>> 
>> This series takes advantage of the new PM QoS class from the i915
>> driver whenever the driver determines that the GPU has become a
>> bottleneck for an extended period of time.  At that point it places a
>> PM QoS ramp-up latency target which causes CPUFREQ to limit the CPU
>> to
>> a reasonably energy-efficient frequency able to at least achieve the
>> required amount of work in a time window approximately equal to the
>> ramp-up latency target (since any longer-term energy efficiency
>> optimization would potentially violate the latency target).  This
>> seems more effective than clamping the CPU frequency to a fixed value
>> directly from various subsystems, since the CPU is a shared resource,
>> so the frequency bound needs to consider the load and latency
>> requirements of all independent workloads running on the same CPU
>> core
>> in order to avoid performance degradation in a multitasking, possibly
>> virtualized environment.
>> 
>> The main limitation of this PM QoS 

[Intel-gfx] ✗ Fi.CI.BUILD: failure for series starting with [1/4] drm/i915/gt: Report context-is-closed prior to pinning (rev3)

2020-03-23 Thread Patchwork
== Series Details ==

Series: series starting with [1/4] drm/i915/gt: Report context-is-closed prior 
to pinning (rev3)
URL   : https://patchwork.freedesktop.org/series/74918/
State : failure

== Summary ==

Applying: drm/i915/gt: Report context-is-closed prior to pinning
Using index info to reconstruct a base tree...
M   drivers/gpu/drm/i915/gt/intel_context.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/gt/intel_context.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/gt/intel_context.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch' to see the failed patch
Patch failed at 0001 drm/i915/gt: Report context-is-closed prior to pinning
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

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


[Intel-gfx] ✗ Fi.CI.IGT: failure for drm/i915/display: Trigger Modeset at boot for audio codec init (rev2)

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm/i915/display: Trigger Modeset at boot for audio codec init (rev2)
URL   : https://patchwork.freedesktop.org/series/74828/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8180_full -> Patchwork_17056_full


Summary
---

  **FAILURE**

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

  


Changes
---

  No changes found


Participating hosts (10 -> 2)
--

  ERROR: It appears as if the changes made in Patchwork_17056_full prevented 
too many machines from booting.

  Missing(8): shard-skl shard-tglb shard-iclb shard-apl shard-glk shard-hsw 
shard-kbl shard-snb 


Build changes
-

  * CI: CI-20190529 -> None
  * IGT: IGT_5530 -> None
  * Linux: CI_DRM_8180 -> Patchwork_17056

  CI-20190529: 20190529
  CI_DRM_8180: 257af0ddcea3a234dcb79579600f971edd47353f @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5530: 2020d743940f06294d06006bb737be43fcd2881e @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17056: 0db59c6d9bd50ac3f03b40c76535eac49d25adb2 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ 
git://anongit.freedesktop.org/piglit

== Logs ==

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


Re: [Intel-gfx] [PATCH] drm/i915/execlists: Pull tasklet interrupt-bh local to direct submission

2020-03-23 Thread Chris Wilson
Quoting Francisco Jerez (2020-03-23 22:30:13)
> Chris Wilson  writes:
> 
> > Quoting Francisco Jerez (2020-03-20 22:14:51)
> >> Francisco Jerez  writes:
> >> 
> >> > Chris Wilson  writes:
> >> >
> >> >> We dropped calling process_csb prior to handling direct submission in
> >> >> order to avoid the nesting of spinlocks and lift process_csb() and the
> >> >> majority of the tasklet out of irq-off. However, we do want to avoid
> >> >> ksoftirqd latency in the fast path, so try and pull the interrupt-bh
> >> >> local to direct submission if we can acquire the tasklet's lock.
> >> >>
> >> >> v2: Tweak the balance to avoid over submitting lite-restores
> >> >>
> >> >> Signed-off-by: Chris Wilson 
> >> >> Cc: Francisco Jerez 
> >> >> Cc: Tvrtko Ursulin 
> >> >> ---
> >> >>  drivers/gpu/drm/i915/gt/intel_lrc.c| 44 --
> >> >>  drivers/gpu/drm/i915/gt/selftest_lrc.c |  2 +-
> >> >>  2 files changed, 36 insertions(+), 10 deletions(-)
> >> >>
> >> >> diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c 
> >> >> b/drivers/gpu/drm/i915/gt/intel_lrc.c
> >> >> index f09dd87324b9..dceb65a0088f 100644
> >> >> --- a/drivers/gpu/drm/i915/gt/intel_lrc.c
> >> >> +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
> >> >> @@ -2884,17 +2884,17 @@ static void queue_request(struct 
> >> >> intel_engine_cs *engine,
> >> >>  set_bit(I915_FENCE_FLAG_PQUEUE, >fence.flags);
> >> >>  }
> >> >>  
> >> >> -static void __submit_queue_imm(struct intel_engine_cs *engine)
> >> >> +static bool pending_csb(const struct intel_engine_execlists *el)
> >> >>  {
> >> >> -struct intel_engine_execlists * const execlists = 
> >> >> >execlists;
> >> >> +return READ_ONCE(*el->csb_write) != READ_ONCE(el->csb_head);
> >> >> +}
> >> >>  
> >> >> -if (reset_in_progress(execlists))
> >> >> -return; /* defer until we restart the engine following 
> >> >> reset */
> >> >> +static bool skip_lite_restore(struct intel_engine_execlists *el,
> >> >> +  const struct i915_request *rq)
> >> >> +{
> >> >> +struct i915_request *inflight = execlists_active(el);
> >> >>  
> >> >> -if (execlists->tasklet.func == execlists_submission_tasklet)
> >> >> -__execlists_submission_tasklet(engine);
> >> >> -else
> >> >> -tasklet_hi_schedule(>tasklet);
> >> >> +return inflight && inflight->context == rq->context;
> >> >>  }
> >> >>  
> >> >>  static void submit_queue(struct intel_engine_cs *engine,
> >> >> @@ -2905,8 +2905,34 @@ static void submit_queue(struct intel_engine_cs 
> >> >> *engine,
> >> >>  if (rq_prio(rq) <= execlists->queue_priority_hint)
> >> >>  return;
> >> >>  
> >> >> +if (reset_in_progress(execlists))
> >> >> +return; /* defer until we restart the engine following 
> >> >> reset */
> >> >> +
> >> >> +/*
> >> >> + * Suppress immediate lite-restores, leave that to the tasklet.
> >> >> + *
> >> >> + * However, we leave the queue_priority_hint unset so that if we do
> >> >> + * submit a second context, we push that into ELSP[1] immediately.
> >> >> + */
> >> >> +if (skip_lite_restore(execlists, rq))
> >> >> +return;
> >> >> +
> >> > Why do you need to treat lite-restore specially here?
> >
> > Lite-restore have a noticeable impact on no-op loads. A part of that is
> > that a lite-restore is about 1us, and the other part is that the driver
> > has a lot more work to do. There's a balance point around here for not
> > needlessly interrupting ourselves and ensuring that there is no bubble.
> >
> 
> Oh, I see.  But isn't inhibiting the lite restore likely to be fairly
> costly in some cases as well if it causes the GPU to go idle after the
> current context completes for as long as it takes the CPU to wake up,
> process the IRQ and dequeue the next request?

Yes. It's an amusing diversion to try and think how can we do a single
context submission (well 2) for a sequence of requests, for those
clients that like to submit N batches at once. From an idle GPU,
assuming each batch is non-trivial, we want to do something like submit
batch 1, accumulate, then submit batches 1-N, i.e. skip the intervening
lite-restores but complete the submission with all the work queued.

> Would it make sense to
> inhibit lite-restore in roughly the same conditions I set the overload
> flag?  (since that indicates we'll get an IRQ at least one request
> *before* the GPU actually goes idle, so there shouldn't be any penalty
> from inhibiting lite restore).

Yes/no. Once we have multiple contexts scheduled, we won't be doing lite
restores.

The key problem is that the irq/tasklet-bh latency is unpredictable. Only
submitting one context at a time costs about 1% in [multi-context]
transcode throughput. And the cost of lite-restore on that scale is
barely noticeable.

So it annoys me that we can measure the impact of lite-restore on
nop-throughput, but in reality we have a self-inflicted regression on
top of the 

Re: [Intel-gfx] [RFC] GPU-bound energy efficiency improvements for the intel_pstate driver (v2).

2020-03-23 Thread Pandruvada, Srinivas
Hi Francisco,

On Tue, 2020-03-10 at 14:41 -0700, Francisco Jerez wrote:
> This is my second take on improving the energy efficiency of the
> intel_pstate driver under IO-bound conditions.  The problem and
> approach to solve it are roughly the same as in my previous series
> [1]
> at a high level:
> 
> In IO-bound scenarios (by definition) the throughput of the system
> doesn't improve with increasing CPU frequency beyond the threshold
> value at which the IO device becomes the bottleneck, however with the
> current governors (whether HWP is in use or not) the CPU frequency
> tends to oscillate with the load, often with an amplitude far into
> the
> turbo range, leading to severely reduced energy efficiency, which is
> particularly problematic when a limited TDP budget is shared among a
> number of cores running some multithreaded workload, or among a CPU
> core and an integrated GPU.
> 
> Improving the energy efficiency of the CPU improves the throughput of
> the system in such TDP-limited conditions.  See [4] for some
> preliminary benchmark results from a Razer Blade Stealth 13 Late
> 2019/LY320 laptop with an Intel ICL processor and integrated
> graphics,
> including throughput results that range up to a ~15% improvement and
> performance-per-watt results up to a ~43% improvement (estimated via
> RAPL).  Particularly the throughput results may vary substantially
> from one platform to another depending on the TDP budget and the
> balance of load between CPU and GPU.
> 

You changed the EPP to 0 intentionally or unintentionally. We know that
all energy optimization will be disabled with this change. 
This test was done on an ICL system.


Basically without your patches on top of linux-next: EPP = 0x80
$sudo rdmsr -a 0x774
80002704
80002704
80002704
80002704
80002704
80002704
80002704
80002704


After your patches

$sudo rdmsr -a 0x774
2704
2704
2704
2704
2704
2704
2704
2704

I added some prints, basically you change the EPP at startup before
regular HWP request update path and update on top. So boot up EPP is
overwritten.


[5.867476] intel_pstate_reset_vlp hwp_req cached:0
[5.872426] intel_pstate_reset_vlp hwp_req:404
[5.881645] intel_pstate_reset_vlp hwp_req cached:0
[5.886634] intel_pstate_reset_vlp hwp_req:404
[5.895819] intel_pstate_reset_vlp hwp_req cached:0
[5.900958] intel_pstate_reset_vlp hwp_req:404
[5.910321] intel_pstate_reset_vlp hwp_req cached:0
[5.915406] intel_pstate_reset_vlp hwp_req:404
[5.924623] intel_pstate_reset_vlp hwp_req cached:0
[5.929564] intel_pstate_reset_vlp hwp_req:404
[5.944039] intel_pstate_reset_vlp hwp_req cached:0
[5.951672] intel_pstate_reset_vlp hwp_req:404
[5.966157] intel_pstate_reset_vlp hwp_req cached:0
[5.973808] intel_pstate_reset_vlp hwp_req:404
[5.988223] intel_pstate_reset_vlp hwp_req cached:0
[5.995823] intel_pstate_reset_vlp hwp_req:404
[6.010062] intel_pstate: HWP enabled

Thanks,
Srinivas



> One of the main differences relative to my previous version is that
> the trade-off between energy efficiency and frequency ramp-up latency
> is now exposed to device drivers through a new PM QoS class [It would
> make sense to expose it to userspace too eventually but that's beyond
> the purpose of this series].  The new PM QoS class provides a latency
> target to CPUFREQ governors which gives them permission to filter out
> CPU frequency oscillations with a period significantly shorter than
> the specified target, whenever doing so leads to improved energy
> efficiency.
> 
> This series takes advantage of the new PM QoS class from the i915
> driver whenever the driver determines that the GPU has become a
> bottleneck for an extended period of time.  At that point it places a
> PM QoS ramp-up latency target which causes CPUFREQ to limit the CPU
> to
> a reasonably energy-efficient frequency able to at least achieve the
> required amount of work in a time window approximately equal to the
> ramp-up latency target (since any longer-term energy efficiency
> optimization would potentially violate the latency target).  This
> seems more effective than clamping the CPU frequency to a fixed value
> directly from various subsystems, since the CPU is a shared resource,
> so the frequency bound needs to consider the load and latency
> requirements of all independent workloads running on the same CPU
> core
> in order to avoid performance degradation in a multitasking, possibly
> virtualized environment.
> 
> The main limitation of this PM QoS approach is that whenever multiple
> clients request different ramp-up latency targets, only the strictest
> (lowest latency) one will apply system-wide, potentially leading to
> suboptimal energy efficiency for the less latency-sensitive clients,
> (though it won't artificially limit the CPU throughput of the most
> latency-sensitive clients as a result of the PM QoS requests placed
> by
> less latency-sensitive ones).  In order to address this limitation
> I'm
> 

[Intel-gfx] ✓ Fi.CI.IGT: success for series starting with [01/12] drm/i915/selftests: Add request throughput measurement to perf

2020-03-23 Thread Patchwork
== Series Details ==

Series: series starting with [01/12] drm/i915/selftests: Add request throughput 
measurement to perf
URL   : https://patchwork.freedesktop.org/series/74974/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_8180_full -> Patchwork_17055_full


Summary
---

  **SUCCESS**

  No regressions found.

  

New tests
-

  New tests have been introduced between CI_DRM_8180_full and 
Patchwork_17055_full:

### New IGT tests (3) ###

  * igt@dmabuf@all@dma_fence_chain:
- Statuses : 8 pass(s)
- Exec time: [7.40, 31.21] s

  * igt@dmabuf@all@dma_fence_proxy:
- Statuses : 8 pass(s)
- Exec time: [0.03, 0.10] s

  * igt@i915_selftest@perf@request:
- Statuses : 7 pass(s)
- Exec time: [3.50, 5.59] s

  

Known issues


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

### IGT changes ###

 Issues hit 

  * igt@gem_busy@busy-vcs1:
- shard-iclb: [PASS][1] -> [SKIP][2] ([fdo#112080]) +12 similar 
issues
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-iclb4/igt@gem_b...@busy-vcs1.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/shard-iclb5/igt@gem_b...@busy-vcs1.html

  * igt@gem_ctx_isolation@vecs0-s3:
- shard-iclb: [PASS][3] -> [INCOMPLETE][4] ([fdo#109100])
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-iclb1/igt@gem_ctx_isolat...@vecs0-s3.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/shard-iclb3/igt@gem_ctx_isolat...@vecs0-s3.html

  * igt@gem_ctx_shared@exec-single-timeline-bsd:
- shard-iclb: [PASS][5] -> [SKIP][6] ([fdo#110841])
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-iclb8/igt@gem_ctx_sha...@exec-single-timeline-bsd.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/shard-iclb4/igt@gem_ctx_sha...@exec-single-timeline-bsd.html

  * igt@gem_ctx_shared@q-smoketest-bsd2:
- shard-iclb: [PASS][7] -> [SKIP][8] ([fdo#109276]) +9 similar 
issues
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-iclb2/igt@gem_ctx_sha...@q-smoketest-bsd2.html
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/shard-iclb6/igt@gem_ctx_sha...@q-smoketest-bsd2.html

  * igt@gem_exec_schedule@implicit-read-write-bsd2:
- shard-iclb: [PASS][9] -> [SKIP][10] ([fdo#109276] / [i915#677]) 
+1 similar issue
   [9]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-iclb2/igt@gem_exec_sched...@implicit-read-write-bsd2.html
   [10]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/shard-iclb6/igt@gem_exec_sched...@implicit-read-write-bsd2.html

  * igt@gem_exec_schedule@pi-distinct-iova-bsd:
- shard-iclb: [PASS][11] -> [SKIP][12] ([i915#677]) +3 similar 
issues
   [11]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-iclb7/igt@gem_exec_sched...@pi-distinct-iova-bsd.html
   [12]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/shard-iclb2/igt@gem_exec_sched...@pi-distinct-iova-bsd.html

  * igt@gem_exec_schedule@reorder-wide-bsd:
- shard-iclb: [PASS][13] -> [SKIP][14] ([fdo#112146]) +4 similar 
issues
   [13]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-iclb5/igt@gem_exec_sched...@reorder-wide-bsd.html
   [14]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/shard-iclb4/igt@gem_exec_sched...@reorder-wide-bsd.html

  * igt@kms_cursor_crc@pipe-a-cursor-suspend:
- shard-apl:  [PASS][15] -> [DMESG-WARN][16] ([i915#180])
   [15]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-apl8/igt@kms_cursor_...@pipe-a-cursor-suspend.html
   [16]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/shard-apl1/igt@kms_cursor_...@pipe-a-cursor-suspend.html

  * igt@kms_cursor_crc@pipe-b-cursor-suspend:
- shard-kbl:  [PASS][17] -> [DMESG-WARN][18] ([i915#180]) +1 
similar issue
   [17]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-kbl4/igt@kms_cursor_...@pipe-b-cursor-suspend.html
   [18]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/shard-kbl7/igt@kms_cursor_...@pipe-b-cursor-suspend.html

  * igt@kms_flip@plain-flip-fb-recreate-interruptible:
- shard-glk:  [PASS][19] -> [FAIL][20] ([i915#34])
   [19]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-glk7/igt@kms_f...@plain-flip-fb-recreate-interruptible.html
   [20]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/shard-glk8/igt@kms_f...@plain-flip-fb-recreate-interruptible.html

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-indfb-plflip-blt:
- shard-kbl:  [PASS][21] -> [FAIL][22] ([i915#49])
   [21]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/shard-kbl1/igt@kms_frontbuffer_track...@fbc-1p-primscrn-indfb-plflip-blt.html
   [22]: 

Re: [Intel-gfx] [PATCH] drm/i915/execlists: Pull tasklet interrupt-bh local to direct submission

2020-03-23 Thread Francisco Jerez
Chris Wilson  writes:

> Quoting Francisco Jerez (2020-03-20 22:14:51)
>> Francisco Jerez  writes:
>> 
>> > Chris Wilson  writes:
>> >
>> >> We dropped calling process_csb prior to handling direct submission in
>> >> order to avoid the nesting of spinlocks and lift process_csb() and the
>> >> majority of the tasklet out of irq-off. However, we do want to avoid
>> >> ksoftirqd latency in the fast path, so try and pull the interrupt-bh
>> >> local to direct submission if we can acquire the tasklet's lock.
>> >>
>> >> v2: Tweak the balance to avoid over submitting lite-restores
>> >>
>> >> Signed-off-by: Chris Wilson 
>> >> Cc: Francisco Jerez 
>> >> Cc: Tvrtko Ursulin 
>> >> ---
>> >>  drivers/gpu/drm/i915/gt/intel_lrc.c| 44 --
>> >>  drivers/gpu/drm/i915/gt/selftest_lrc.c |  2 +-
>> >>  2 files changed, 36 insertions(+), 10 deletions(-)
>> >>
>> >> diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c 
>> >> b/drivers/gpu/drm/i915/gt/intel_lrc.c
>> >> index f09dd87324b9..dceb65a0088f 100644
>> >> --- a/drivers/gpu/drm/i915/gt/intel_lrc.c
>> >> +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
>> >> @@ -2884,17 +2884,17 @@ static void queue_request(struct intel_engine_cs 
>> >> *engine,
>> >>  set_bit(I915_FENCE_FLAG_PQUEUE, >fence.flags);
>> >>  }
>> >>  
>> >> -static void __submit_queue_imm(struct intel_engine_cs *engine)
>> >> +static bool pending_csb(const struct intel_engine_execlists *el)
>> >>  {
>> >> -struct intel_engine_execlists * const execlists = >execlists;
>> >> +return READ_ONCE(*el->csb_write) != READ_ONCE(el->csb_head);
>> >> +}
>> >>  
>> >> -if (reset_in_progress(execlists))
>> >> -return; /* defer until we restart the engine following reset 
>> >> */
>> >> +static bool skip_lite_restore(struct intel_engine_execlists *el,
>> >> +  const struct i915_request *rq)
>> >> +{
>> >> +struct i915_request *inflight = execlists_active(el);
>> >>  
>> >> -if (execlists->tasklet.func == execlists_submission_tasklet)
>> >> -__execlists_submission_tasklet(engine);
>> >> -else
>> >> -tasklet_hi_schedule(>tasklet);
>> >> +return inflight && inflight->context == rq->context;
>> >>  }
>> >>  
>> >>  static void submit_queue(struct intel_engine_cs *engine,
>> >> @@ -2905,8 +2905,34 @@ static void submit_queue(struct intel_engine_cs 
>> >> *engine,
>> >>  if (rq_prio(rq) <= execlists->queue_priority_hint)
>> >>  return;
>> >>  
>> >> +if (reset_in_progress(execlists))
>> >> +return; /* defer until we restart the engine following reset 
>> >> */
>> >> +
>> >> +/*
>> >> + * Suppress immediate lite-restores, leave that to the tasklet.
>> >> + *
>> >> + * However, we leave the queue_priority_hint unset so that if we do
>> >> + * submit a second context, we push that into ELSP[1] immediately.
>> >> + */
>> >> +if (skip_lite_restore(execlists, rq))
>> >> +return;
>> >> +
>> > Why do you need to treat lite-restore specially here?
>
> Lite-restore have a noticeable impact on no-op loads. A part of that is
> that a lite-restore is about 1us, and the other part is that the driver
> has a lot more work to do. There's a balance point around here for not
> needlessly interrupting ourselves and ensuring that there is no bubble.
>

Oh, I see.  But isn't inhibiting the lite restore likely to be fairly
costly in some cases as well if it causes the GPU to go idle after the
current context completes for as long as it takes the CPU to wake up,
process the IRQ and dequeue the next request?  Would it make sense to
inhibit lite-restore in roughly the same conditions I set the overload
flag?  (since that indicates we'll get an IRQ at least one request
*before* the GPU actually goes idle, so there shouldn't be any penalty
from inhibiting lite restore).

>> >
>> > Anyway, trying this out now in combination with my patches now.
>> >
>> 
>> This didn't seem to help (together with your other suggestion to move
>> the overload accounting to __execlists_schedule_in/out).  And it makes
>> the current -5% SynMark OglMultithread regression with my series go down
>> to -10%.  My previous suggestion of moving the
>> intel_gt_pm_active_begin() call to process_csb() when the submission is
>> ACK'ed by the hardware does seem to help (and it roughly halves the
>> OglMultithread regression), possibly because that way we're able to
>> determine whether the first context was actually overlapping at the
>> point that the second was received by the hardware -- I haven't tested
>> it extensively yet though.
>
> Grumble, it just seems like we are setting and clearing the flag on
> completely unrelated events -- which I still think boils down to working
> around latency in the driver. Or at least I hope there's an explanation
> and bug to fix that improves responsiveness for all.
> -Chris

There *might* be a performance issue somewhere introducing latency that
the 

Re: [Intel-gfx] [PATCH 07/10] cpufreq: intel_pstate: Implement VLP controller for HWP parts.

2020-03-23 Thread Pandruvada, Srinivas
On Wed, 2020-03-18 at 13:22 -0700, Francisco Jerez wrote:
> "Pandruvada, Srinivas"  writes:
> 
> > On Wed, 2020-03-18 at 12:51 -0700, Francisco Jerez wrote:
> > > "Pandruvada, Srinivas"  writes:
> > > 
> > > > On Tue, 2020-03-10 at 14:42 -0700, Francisco Jerez wrote:
> > > > > This implements a simple variably low-pass-filtering governor
> > > > > in
> > > > > control of the HWP MIN/MAX PERF range based on the previously
> > > > > introduced get_vlp_target_range().  See "cpufreq:
> > > > > intel_pstate:
> > > > > Implement VLP controller target P-state range estimation."
> > > > > for
> > > > > the
> > > > > rationale.
> > > > 
> > > > I just gave a try on a pretty idle system with just systemd
> > > > processes
> > > > and usual background tasks with nomodset. 
> > > > 
> > > > I see that there HWP min is getting changed between 4-8. Why
> > > > are
> > > > changing HWP dynamic range even on an idle system running no
> > > > where
> > > > close to TDP?
> > > > 
> > > 
> > > The HWP request range is clamped to the frequency range specified
> > > by
> > > the
> > > CPUFREQ policy and to the cpu->pstate.min_pstate bound.
> > > 
> > > If you see the HWP minimum fluctuating above that it's likely a
> > > sign
> > > of
> > > your system not being completely idle -- If that's the case it's
> > > likely
> > > to go away after you do:
> > > 
> > >  echo 0 > /sys/kernel/debug/pstate_snb/vlp_realtime_gain_pml
> > > 
> > The objective which I though was to improve performance of GPU
> > workloads limited by TDP because of P-states ramping up and
> > resulting
> > in less power to GPU to complete a task.
> >  
> > HWP takes decision not on just load on a CPU but several other
> > factors
> > like total SoC power and scalability. We don't want to disturb HWP
> > algorithms when there is no TDP limitations. If writing 0, causes
> > this
> > behavior then that should be the default.
> > 
> 
> The heuristic disabled by that debugfs file is there to avoid
> regressions in latency-sensitive workloads as you can probably get
> from
> the ecomments.  However ISTR those regressions were specific to non-
> HWP
> systems, so I wouldn't mind disabling it for the moment (or punting
> it
> to the non-HWP series if you like)j.  But first I need to verify that
> there are no performance regressions on HWP systems after changing
> that.
> Can you confirm that the debugfs write above prevents the behavior
> you'd
> like to avoid?
It does prevent. I monitored for 10 min and didn't see any hwp_req
update.

Thanks,
Srinivas

> 
> > Thanks,
> > Srinivas
> > 
> > 
> > 
> > 
> > 
> > > > Thanks,
> > > > Srinivas
> > > > 
> > > > 
> > > > > Signed-off-by: Francisco Jerez 
> > > > > ---
> > > > >  drivers/cpufreq/intel_pstate.c | 79
> > > > > +-
> > > > >  1 file changed, 77 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/cpufreq/intel_pstate.c
> > > > > b/drivers/cpufreq/intel_pstate.c
> > > > > index cecadfec8bc1..a01eed40d897 100644
> > > > > --- a/drivers/cpufreq/intel_pstate.c
> > > > > +++ b/drivers/cpufreq/intel_pstate.c
> > > > > @@ -1905,6 +1905,20 @@ static void
> > > > > intel_pstate_reset_vlp(struct
> > > > > cpudata *cpu)
> > > > >   vlp->gain = max(1, div_fp(1000,
> > > > > vlp_params.setpoint_0_pml));
> > > > >   vlp->target.p_base = 0;
> > > > >   vlp->stats.last_response_frequency_hz =
> > > > > vlp_params.avg_hz;
> > > > > +
> > > > > + if (hwp_active) {
> > > > > + const uint32_t p0 = max(cpu->pstate.min_pstate,
> > > > > + cpu->min_perf_ratio);
> > > > > + const uint32_t p1 = max_t(uint32_t, p0, cpu-
> > > > > > max_perf_ratio);
> > > > > + const uint64_t hwp_req = (READ_ONCE(cpu-
> > > > > > hwp_req_cached) &
> > > > > +   ~(HWP_MAX_PERF(~0L) |
> > > > > + HWP_MIN_PERF(~0L) |
> > > > > + HWP_DESIRED_PERF(~0
> > > > > L))) |
> > > > > +  HWP_MIN_PERF(p0) |
> > > > > HWP_MAX_PERF(p1);
> > > > > +
> > > > > + wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST,
> > > > > hwp_req);
> > > > > + cpu->hwp_req_cached = hwp_req;
> > > > > + }
> > > > >  }
> > > > >  
> > > > >  /**
> > > > > @@ -,6 +2236,46 @@ static void
> > > > > intel_pstate_adjust_pstate(struct
> > > > > cpudata *cpu)
> > > > >   fp_toint(cpu->iowait_boost * 100));
> > > > >  }
> > > > >  
> > > > > +static void intel_pstate_adjust_pstate_range(struct cpudata
> > > > > *cpu,
> > > > > +  const unsigned int
> > > > > range[])
> > > > > +{
> > > > > + const int from = cpu->hwp_req_cached;
> > > > > + unsigned int p0, p1, p_min, p_max;
> > > > > + struct sample *sample;
> > > > > + uint64_t hwp_req;
> > > > > +
> > > > > + update_turbo_state();
> > > > > +
> > > > > + p0 = 

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/gt: Only delay the barrier pm

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm/i915/gt: Only delay the barrier pm
URL   : https://patchwork.freedesktop.org/series/74986/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8180 -> Patchwork_17060


Summary
---

  **FAILURE**

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

  External URL: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17060/index.html

Possible new issues
---

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

### IGT changes ###

 Possible regressions 

  * igt@gem_exec_gttfill@basic:
- fi-skl-6770hq:  [PASS][1] -> [INCOMPLETE][2]
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-skl-6770hq/igt@gem_exec_gttf...@basic.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17060/fi-skl-6770hq/igt@gem_exec_gttf...@basic.html

  
Known issues


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

### IGT changes ###

 Issues hit 

  * igt@i915_selftest@live@execlists:
- fi-icl-dsi: [PASS][3] -> [DMESG-FAIL][4] ([fdo#108569])
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-dsi/igt@i915_selftest@l...@execlists.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17060/fi-icl-dsi/igt@i915_selftest@l...@execlists.html

  * igt@kms_chamelium@dp-crc-fast:
- fi-cml-u2:  [PASS][5] -> [FAIL][6] ([i915#217])
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cml-u2/igt@kms_chamel...@dp-crc-fast.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17060/fi-cml-u2/igt@kms_chamel...@dp-crc-fast.html

  
 Possible fixes 

  * igt@i915_selftest@live@execlists:
- fi-bxt-dsi: [INCOMPLETE][7] ([fdo#103927] / [i915#656]) -> 
[PASS][8]
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-bxt-dsi/igt@i915_selftest@l...@execlists.html
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17060/fi-bxt-dsi/igt@i915_selftest@l...@execlists.html

  
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
  [i915#217]: https://gitlab.freedesktop.org/drm/intel/issues/217
  [i915#656]: https://gitlab.freedesktop.org/drm/intel/issues/656


Participating hosts (40 -> 40)
--

  Additional (8): fi-bdw-5557u fi-kbl-7500u fi-gdg-551 fi-elk-e7500 fi-skl-lmem 
fi-blb-e6850 fi-skl-6600u fi-snb-2600 
  Missing(8): fi-byt-squawks fi-glk-dsi fi-bsw-cyan fi-ctg-p8600 
fi-cfl-8109u fi-bsw-kefka fi-byt-clapper fi-bdw-samus 


Build changes
-

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_8180 -> Patchwork_17060

  CI-20190529: 20190529
  CI_DRM_8180: 257af0ddcea3a234dcb79579600f971edd47353f @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5530: 2020d743940f06294d06006bb737be43fcd2881e @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17060: ac635589f9e6de1215adcdc7776f40df010e160b @ 
git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

ac635589f9e6 drm/i915/gt: Only delay the barrier pm

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17060/index.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/mm: Only allow sleeping if the caller permits

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm/mm: Only allow sleeping if the caller permits
URL   : https://patchwork.freedesktop.org/series/74985/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_8180 -> Patchwork_17059


Summary
---

  **SUCCESS**

  No regressions found.

  External URL: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/index.html

Known issues


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

### IGT changes ###

 Issues hit 

  * igt@i915_selftest@live@execlists:
- fi-icl-y:   [PASS][1] -> [INCOMPLETE][2] ([i915#140])
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-y/igt@i915_selftest@l...@execlists.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/fi-icl-y/igt@i915_selftest@l...@execlists.html

  
 Warnings 

  * igt@i915_pm_rpm@basic-pci-d3-state:
- fi-kbl-guc: [SKIP][3] ([fdo#109271]) -> [FAIL][4] ([i915#138])
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-kbl-guc/igt@i915_pm_...@basic-pci-d3-state.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/fi-kbl-guc/igt@i915_pm_...@basic-pci-d3-state.html

  * igt@kms_chamelium@vga-hpd-fast:
- fi-cml-u2:  [SKIP][5] ([fdo#109309]) -> [FAIL][6] ([i915#217])
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cml-u2/igt@kms_chamel...@vga-hpd-fast.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17059/fi-cml-u2/igt@kms_chamel...@vga-hpd-fast.html

  
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109309]: https://bugs.freedesktop.org/show_bug.cgi?id=109309
  [i915#138]: https://gitlab.freedesktop.org/drm/intel/issues/138
  [i915#140]: https://gitlab.freedesktop.org/drm/intel/issues/140
  [i915#217]: https://gitlab.freedesktop.org/drm/intel/issues/217


Participating hosts (40 -> 40)
--

  Additional (8): fi-bdw-5557u fi-hsw-peppy fi-gdg-551 fi-elk-e7500 fi-skl-lmem 
fi-blb-e6850 fi-bsw-nick fi-skl-6600u 
  Missing(8): fi-byt-squawks fi-icl-u2 fi-bwr-2160 fi-bsw-cyan fi-ctg-p8600 
fi-kbl-7560u fi-byt-clapper fi-bdw-samus 


Build changes
-

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_8180 -> Patchwork_17059

  CI-20190529: 20190529
  CI_DRM_8180: 257af0ddcea3a234dcb79579600f971edd47353f @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5530: 2020d743940f06294d06006bb737be43fcd2881e @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17059: 80b6656d391aca1aaa57bc2dc1bc5a4e7155bdf7 @ 
git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

80b6656d391a drm/mm: Only allow sleeping if the caller permits

== Logs ==

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


[Intel-gfx] [PATCH] drm/i915/gt: Only delay the barrier pm

2020-03-23 Thread Chris Wilson
It is strictly sufficient to only delay the intel_engine_pm_put from the
context barrier (and not from the context exit) in order to prevent the
gem_exec_nop contention. Adding the delay to the context exit incurs
noticably extra penalty for soft-rc6.

Fixes: edee52c927ef ("drm/i915/gt: Delay release of engine-pm after last 
retirement")
Testcase: igt/i915_pm_rc6_residency/rc6-idle
Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/gt/intel_context.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.c 
b/drivers/gpu/drm/i915/gt/intel_context.c
index 622ff425fce9..e4aece20bc80 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.c
+++ b/drivers/gpu/drm/i915/gt/intel_context.c
@@ -350,7 +350,7 @@ void intel_context_enter_engine(struct intel_context *ce)
 void intel_context_exit_engine(struct intel_context *ce)
 {
intel_timeline_exit(ce->timeline);
-   intel_engine_pm_put_delay(ce->engine, 1);
+   intel_engine_pm_put(ce->engine);
 }
 
 int intel_context_prepare_remote_request(struct intel_context *ce,
-- 
2.20.1

___
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/mm: Only allow sleeping if the caller permits

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm/mm: Only allow sleeping if the caller permits
URL   : https://patchwork.freedesktop.org/series/74985/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
80b6656d391a drm/mm: Only allow sleeping if the caller permits
-:174: CHECK:LINE_SPACING: Please use a blank line after 
function/struct/union/enum declarations
#174: FILE: include/drm/drm_mm.h:155:
 };
+#define DRM_MM_INSERT_MODE GENMASK(29, 0) /* all but the special bits */

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

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


Re: [Intel-gfx] [PATCH 03/51] drm: add managed resources tied to drm_device

2020-03-23 Thread Sam Ravnborg
Hi Daniel.

On Mon, Mar 23, 2020 at 03:49:02PM +0100, Daniel Vetter wrote:
> We have lots of these. And the cleanup code tends to be of dubious
> quality. The biggest wrong pattern is that developers use devm_, which
> ties the release action to the underlying struct device, whereas
> all the userspace visible stuff attached to a drm_device can long
> outlive that one (e.g. after a hotunplug while userspace has open
> files and mmap'ed buffers). Give people what they want, but with more
> correctness.
> 
> Mostly copied from devres.c, with types adjusted to fit drm_device and
> a few simplifications - I didn't (yet) copy over everything. Since
> the types don't match code sharing looked like a hopeless endeavour.
> 
> For now it's only super simplified, no groups, you can't remove
> actions (but kfree exists, we'll need that soon). Plus all specific to
> drm_device ofc, including the logging. Which I didn't bother to make
> compile-time optional, since none of the other drm logging is compile
> time optional either.
> 
> One tricky bit here is the chicken between allocating your
> drm_device structure and initiliazing it with drm_dev_init. For
> perfect onion unwinding we'd need to have the action to kfree the
> allocation registered before drm_dev_init registers any of its own
> release handlers. But drm_dev_init doesn't know where exactly the
> drm_device is emebedded into the overall structure, and by the time it
> returns it'll all be too late. And forcing drivers to be able clean up
> everything except the one kzalloc is silly.
> 
> Work around this by having a very special final_kfree pointer. This
> also avoids troubles with the list head possibly disappearing from
> underneath us when we release all resources attached to the
> drm_device.
> 
> v2: Do all the kerneldoc at the end, to avoid lots of fairly pointless
> shuffling while getting everything into shape.
> 
> v3: Add static to add/del_dr (Neil)
> Move typo fix to the right patch (Neil)
> 
> v4: Enforce contract for drmm_add_final_kfree:
> 
> Use ksize() to check that the drm_device is indeed contained somewhere
> in the final kfree(). Because we need that or the entire managed
> release logic blows up in a pile of use-after-frees. Motivated by a
> discussion with Laurent.
> 
> v5: Review from Laurent:
> - %zu instead of casting size_t
> - header guards
> - sorting of includes
> - guarding of data assignment if we didn't allocate it for a NULL
>   pointer
> - delete spurious newline
> - cast void* data parameter correctly in ->release call, no idea how
>   this even worked before
> 
> v3: Review from Sam
> - Add the kerneldoc for the managed sub-struct back in, even if it
>   doesn't show up in the generated html somehow.
> - Explain why __always_inline.
> - Fix bisectability around the final kfree() in drm_dev_relase(). This
>   is just interim code which will disappear again.
> - Some whitespace polish.
> - Add debug output when drmm_add_action or drmm_kmalloc fail.
> 
> v4: My bisectability fix wasn't up to par as noticed by smatch.
> 
> v5: Remove unecessary {} around if else
> 
> v6: Use kstrdup_const, which requires kfree_const and introducing a free_dr()
> helper (Thomas).
> 
> Cc: Thomas Zimmermann 
> Cc: Dan Carpenter 
> Cc: Sam Ravnborg 
> Cc: Laurent Pinchart 
> Cc: Neil Armstrong  Cc: Greg Kroah-Hartman 
> Cc: "Rafael J. Wysocki" 
> Signed-off-by: Daniel Vetter 

Looks good.
Reviewed-by: Sam Ravnborg 

> ---
>  Documentation/gpu/drm-internals.rst |   6 +
>  drivers/gpu/drm/Makefile|   3 +-
>  drivers/gpu/drm/drm_drv.c   |  15 ++-
>  drivers/gpu/drm/drm_internal.h  |   3 +
>  drivers/gpu/drm/drm_managed.c   | 193 
>  include/drm/drm_device.h|  15 +++
>  include/drm/drm_managed.h   |  30 +
>  include/drm/drm_print.h |   6 +
>  8 files changed, 267 insertions(+), 4 deletions(-)
>  create mode 100644 drivers/gpu/drm/drm_managed.c
>  create mode 100644 include/drm/drm_managed.h
> 
> diff --git a/Documentation/gpu/drm-internals.rst 
> b/Documentation/gpu/drm-internals.rst
> index a73320576ca9..a6b6145fda78 100644
> --- a/Documentation/gpu/drm-internals.rst
> +++ b/Documentation/gpu/drm-internals.rst
> @@ -132,6 +132,12 @@ be unmapped; on many devices, the ROM address decoder is 
> shared with
>  other BARs, so leaving it mapped could cause undesired behaviour like
>  hangs or memory corruption.
>  
> +Managed Resources
> +-
> +
> +.. kernel-doc:: drivers/gpu/drm/drm_managed.c
> +   :doc: managed resources
> +
>  Bus-specific Device Registration and PCI Support
>  
>  
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 7f72ef5e7811..183c60048307 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -17,7 +17,8 @@ drm-y   :=  drm_auth.o drm_cache.o \
>   drm_plane.o drm_color_mgmt.o drm_print.o \
>   

[Intel-gfx] [PATCH] drm/mm: Only allow sleeping if the caller permits

2020-03-23 Thread Chris Wilson
Sometimes the drm_mm is searched from within an atomic context (yikes!)
so we must be cautious and not insert a schedule() unless the caller
indicates it is safe to do so.

Closes: https://gitlab.freedesktop.org/drm/intel/issues/1509
Fixes: 7be1b9b8e9d1 ("drm/mm: Break long searches in fragmented address spaces")
Signed-off-by: Chris Wilson 
Cc: Zbigniew Kempczyński 
Cc: Joonas Lahtinen 
---
 drivers/gpu/drm/drm_mm.c  | 21 ++-
 .../gpu/drm/i915/gem/i915_gem_execbuffer.c|  3 ++-
 drivers/gpu/drm/i915/gem/i915_gem_stolen.c|  4 +++-
 drivers/gpu/drm/i915/i915_gem.c   |  3 ++-
 drivers/gpu/drm/i915/i915_gem_gtt.c   | 10 ++---
 include/drm/drm_mm.h  | 11 ++
 6 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index bc6e208949e8..794d9d4c2d36 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -344,7 +344,7 @@ first_hole(struct drm_mm *mm,
   u64 start, u64 end, u64 size,
   enum drm_mm_insert_mode mode)
 {
-   switch (mode) {
+   switch (mode & DRM_MM_INSERT_MODE) {
default:
case DRM_MM_INSERT_BEST:
return best_hole(mm, size);
@@ -367,12 +367,17 @@ next_hole(struct drm_mm *mm,
  struct drm_mm_node *node,
  enum drm_mm_insert_mode mode)
 {
+   if (mode & DRM_MM_INSERT_ONCE)
+   return NULL; /* check only the first hit */
+
/* Searching is slow; check if we ran out of time/patience */
-   cond_resched();
-   if (fatal_signal_pending(current))
-   return NULL;
+   if (mode & DRM_MM_INSERT_INTERRUPTIBLE) {
+   cond_resched();
+   if (fatal_signal_pending(current))
+   return NULL;
+   }
 
-   switch (mode) {
+   switch (mode & DRM_MM_INSERT_MODE) {
default:
case DRM_MM_INSERT_BEST:
return rb_hole_size_to_node(rb_prev(>rb_hole_size));
@@ -476,7 +481,6 @@ int drm_mm_insert_node_in_range(struct drm_mm * const mm,
 {
struct drm_mm_node *hole;
u64 remainder_mask;
-   bool once;
 
DRM_MM_BUG_ON(range_start > range_end);
 
@@ -489,13 +493,10 @@ int drm_mm_insert_node_in_range(struct drm_mm * const mm,
if (alignment <= 1)
alignment = 0;
 
-   once = mode & DRM_MM_INSERT_ONCE;
-   mode &= ~DRM_MM_INSERT_ONCE;
-
remainder_mask = is_power_of_2(alignment) ? alignment - 1 : 0;
for (hole = first_hole(mm, range_start, range_end, size, mode);
 hole;
-hole = once ? NULL : next_hole(mm, hole, mode)) {
+hole = next_hole(mm, hole, mode)) {
u64 hole_start = __drm_mm_hole_node_start(hole);
u64 hole_end = hole_start + hole->hole_size;
u64 adj_start, adj_end;
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c 
b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index 6b3013d20851..1e06f5e36bbd 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -1057,7 +1057,8 @@ static void *reloc_iomap(struct drm_i915_gem_object *obj,
(>vm.mm, >node,
 PAGE_SIZE, 0, I915_COLOR_UNEVICTABLE,
 0, ggtt->mappable_end,
-DRM_MM_INSERT_LOW);
+DRM_MM_INSERT_LOW |
+DRM_MM_INSERT_INTERRUPTIBLE);
mutex_unlock(>vm.mutex);
if (err) /* no inactive aperture space, use cpu reloc */
return NULL;
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c 
b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
index 5557dfa83a7b..04403f8a7d3a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
@@ -43,7 +43,9 @@ int i915_gem_stolen_insert_node_in_range(struct 
drm_i915_private *i915,
mutex_lock(>mm.stolen_lock);
ret = drm_mm_insert_node_in_range(>mm.stolen, node,
  size, alignment, 0,
- start, end, DRM_MM_INSERT_BEST);
+ start, end,
+ DRM_MM_INSERT_BEST |
+ DRM_MM_INSERT_INTERRUPTIBLE);
mutex_unlock(>mm.stolen_lock);
 
return ret;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 762b50b08d73..9099c311f984 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -69,7 +69,8 @@ insert_mappable_node(struct i915_ggtt *ggtt, struct 
drm_mm_node *node, u32 size)
err = drm_mm_insert_node_in_range(>vm.mm, node,
  size, 0, 

Re: ✗ Fi.CI.BAT: failure for drm/i915/gem: Wait until the context is finally retired before releasing engines (rev3)

2020-03-23 Thread Chris Wilson
Quoting Patchwork (2020-03-23 18:09:52)
>  Possible regressions 
> 
>   * igt@gem_busy@busy-all:
> - fi-icl-guc: [PASS][1] -> [INCOMPLETE][2]
>[1]: 
> https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-guc/igt@gem_b...@busy-all.html
>[2]: 
> https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-icl-guc/igt@gem_b...@busy-all.html

uaf, the dilemma of how to order the wake-up vs the retire callback.
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] i915/pm_rc6_residency: Trigger waitboosts on intermittent workloads

2020-03-23 Thread Chris Wilson
Use gem_sync() to trigger the waitboost, currrently we use a busywait to
avoid the frequency boost, to create a new test to make sure that our
waitboost does not impact upon idling.

We can use this test to demonstrate the impact of forgetting to cancel
the waitboost due to sleeping regularly.

References: https://gitlab.freedesktop.org/drm/intel/issues/1500
Signed-off-by: Chris Wilson 
---
 tests/i915/i915_pm_rc6_residency.c | 118 -
 1 file changed, 84 insertions(+), 34 deletions(-)

diff --git a/tests/i915/i915_pm_rc6_residency.c 
b/tests/i915/i915_pm_rc6_residency.c
index 6a714cab8..93f4bb10a 100644
--- a/tests/i915/i915_pm_rc6_residency.c
+++ b/tests/i915/i915_pm_rc6_residency.c
@@ -34,6 +34,7 @@
 
 #include "igt.h"
 #include "igt_perf.h"
+#include "igt_rapl.h"
 #include "igt_sysfs.h"
 
 #define SLEEP_DURATION 3 /* in seconds */
@@ -280,67 +281,116 @@ static int open_pmu(int i915, uint64_t config)
return fd;
 }
 
+#define WAITBOOST 0x1
+#define ONCE 0x2
+
+static void bg_load(int i915, unsigned int flags, unsigned long *ctl)
+{
+   struct drm_i915_gem_exec_object2 obj = {
+   .handle = batch_create(i915),
+   };
+   struct drm_i915_gem_execbuffer2 execbuf = {
+   .buffers_ptr = to_user_pointer(),
+   .buffer_count = 1,
+   };
+
+   do {
+   struct timespec tv = {};
+
+   igt_nsec_elapsed();
+
+   gem_execbuf(i915, );
+   if (flags & WAITBOOST) {
+   gem_sync(i915, obj.handle);
+   if (flags & ONCE)
+   flags &= ~WAITBOOST;
+   } else  {
+   while (gem_bo_busy(i915, obj.handle))
+   usleep(0);
+   }
+   ctl[1]++;
+
+   usleep(igt_nsec_elapsed() / 10); /* => 1% busy */
+   } while (!READ_ONCE(*ctl));
+}
+
 static void rc6_idle(int i915)
 {
const int64_t duration_ns = SLEEP_DURATION * (int64_t)NSEC_PER_SEC;
const int tolerance = 20; /* Some RC6 is better than none! */
+   struct {
+   const char *name;
+   unsigned int flags;
+   double power;
+   } phases[] = {
+   { "normal", 0 },
+   { "boost", WAITBOOST },
+   { "once", WAITBOOST | ONCE },
+   };
+   struct power_sample sample[2];
unsigned long slept, cycles;
unsigned long *done;
uint64_t rc6, ts[2];
+   struct rapl rapl;
+   double idle = 0;
int fd;
 
fd = open_pmu(i915, I915_PMU_RC6_RESIDENCY);
igt_require(__pmu_wait_for_rc6(fd));
+   gpu_power_open();
 
/* While idle check full RC6. */
+   rapl_read(, [0]);
rc6 = -__pmu_read_single(fd, [0]);
slept = measured_usleep(duration_ns / 1000);
rc6 += __pmu_read_single(fd, [1]);
igt_debug("slept=%lu perf=%"PRIu64", rc6=%"PRIu64"\n",
  slept, ts[1] - ts[0], rc6);
+   if (rapl_read(, [1]))  {
+   idle = power_J(, [0], [1]);
+   igt_info("Total energy used while idle: %.1fmJ\n", idle * 1e3);
+   igt_assert(idle < 1e-3);
+   }
assert_within_epsilon(rc6, ts[1] - ts[0], 5);
 
-   /* Setup up a very light load */
done = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
-   igt_fork(child, 1) {
-   struct drm_i915_gem_exec_object2 obj = {
-   .handle = batch_create(i915),
-   };
-   struct drm_i915_gem_execbuffer2 execbuf = {
-   .buffers_ptr = to_user_pointer(),
-   .buffer_count = 1,
-   };
-
-   do {
-   struct timespec tv = {};
-
-   igt_nsec_elapsed();
-
-   gem_execbuf(i915, );
-   while (gem_bo_busy(i915, obj.handle))
-   usleep(0);
-   done[1]++;
 
-   usleep(igt_nsec_elapsed() / 10); /* => 1% busy */
-   } while (!READ_ONCE(*done));
+   for (int p = 0; p < ARRAY_SIZE(phases); p++) {
+   memset(done, 0, 2 * sizeof(*done));
+   igt_fork(child, 1) /* Setup up a very light load */
+   bg_load(i915, phases[p].flags, done);
+
+   rapl_read(, [0]);
+   cycles = -READ_ONCE(done[1]);
+   rc6 = -__pmu_read_single(fd, [0]);
+   slept = measured_usleep(duration_ns / 1000);
+   rc6 += __pmu_read_single(fd, [1]);
+   cycles += READ_ONCE(done[1]);
+   igt_debug("%s: slept=%lu perf=%"PRIu64", cycles=%lu, 
rc6=%"PRIu64"\n",
+ phases[p].name, slept, ts[1] - ts[0], cycles, rc6);
+   if (rapl_read(, [1]))  {
+   phases[p].power = power_J(, [0], 
[1]);
+   

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/gem: Wait until the context is finally retired before releasing engines (rev3)

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm/i915/gem: Wait until the context is finally retired before 
releasing engines (rev3)
URL   : https://patchwork.freedesktop.org/series/74836/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8180 -> Patchwork_17058


Summary
---

  **FAILURE**

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

  External URL: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/index.html

Possible new issues
---

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

### IGT changes ###

 Possible regressions 

  * igt@gem_busy@busy-all:
- fi-icl-guc: [PASS][1] -> [INCOMPLETE][2]
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-guc/igt@gem_b...@busy-all.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-icl-guc/igt@gem_b...@busy-all.html
- fi-hsw-4770r:   [PASS][3] -> [INCOMPLETE][4]
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-hsw-4770r/igt@gem_b...@busy-all.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-hsw-4770r/igt@gem_b...@busy-all.html
- fi-hsw-peppy:   NOTRUN -> [INCOMPLETE][5]
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-hsw-peppy/igt@gem_b...@busy-all.html
- fi-snb-2520m:   [PASS][6] -> [INCOMPLETE][7]
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-snb-2520m/igt@gem_b...@busy-all.html
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-snb-2520m/igt@gem_b...@busy-all.html
- fi-ivb-3770:[PASS][8] -> [INCOMPLETE][9]
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-ivb-3770/igt@gem_b...@busy-all.html
   [9]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-ivb-3770/igt@gem_b...@busy-all.html
- fi-blb-e6850:   NOTRUN -> [INCOMPLETE][10]
   [10]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-blb-e6850/igt@gem_b...@busy-all.html
- fi-hsw-4770:[PASS][11] -> [INCOMPLETE][12]
   [11]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-hsw-4770/igt@gem_b...@busy-all.html
   [12]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-hsw-4770/igt@gem_b...@busy-all.html
- fi-ilk-650: [PASS][13] -> [INCOMPLETE][14]
   [13]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-ilk-650/igt@gem_b...@busy-all.html
   [14]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-ilk-650/igt@gem_b...@busy-all.html

  * igt@gem_close_race@basic-threads:
- fi-skl-guc: [PASS][15] -> [INCOMPLETE][16]
   [15]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-skl-guc/igt@gem_close_r...@basic-threads.html
   [16]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-skl-guc/igt@gem_close_r...@basic-threads.html
- fi-bwr-2160:[PASS][17] -> [INCOMPLETE][18]
   [17]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-bwr-2160/igt@gem_close_r...@basic-threads.html
   [18]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-bwr-2160/igt@gem_close_r...@basic-threads.html
- fi-bdw-5557u:   NOTRUN -> [INCOMPLETE][19]
   [19]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-bdw-5557u/igt@gem_close_r...@basic-threads.html
- fi-icl-y:   [PASS][20] -> [INCOMPLETE][21]
   [20]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-y/igt@gem_close_r...@basic-threads.html
   [21]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-icl-y/igt@gem_close_r...@basic-threads.html
- fi-kbl-guc: [PASS][22] -> [INCOMPLETE][23]
   [22]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-kbl-guc/igt@gem_close_r...@basic-threads.html
   [23]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-kbl-guc/igt@gem_close_r...@basic-threads.html
- fi-kbl-7500u:   NOTRUN -> [INCOMPLETE][24]
   [24]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-kbl-7500u/igt@gem_close_r...@basic-threads.html
- fi-cfl-8109u:   [PASS][25] -> [INCOMPLETE][26]
   [25]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cfl-8109u/igt@gem_close_r...@basic-threads.html
   [26]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-cfl-8109u/igt@gem_close_r...@basic-threads.html
- fi-kbl-r:   [PASS][27] -> [INCOMPLETE][28]
   [27]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-kbl-r/igt@gem_close_r...@basic-threads.html
   [28]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17058/fi-kbl-r/igt@gem_close_r...@basic-threads.html
- fi-kbl-8809g:   [PASS][29] -> 

[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gem: Wait until the context is finally retired before releasing engines (rev3)

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm/i915/gem: Wait until the context is finally retired before 
releasing engines (rev3)
URL   : https://patchwork.freedesktop.org/series/74836/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
50c51a777669 drm/i915/gem: Wait until the context is finally retired before 
releasing engines
-:65: WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned'
#65: FILE: drivers/gpu/drm/i915/i915_active.c:549:
+barrier_wake(wait_queue_entry_t *wq, unsigned mode, int flags, void *key)

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

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


[Intel-gfx] ✗ Fi.CI.BAT: failure for drm_device managed resources (rev5)

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm_device managed resources (rev5)
URL   : https://patchwork.freedesktop.org/series/73633/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8180 -> Patchwork_17057


Summary
---

  **FAILURE**

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

  External URL: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17057/index.html

Possible new issues
---

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

### IGT changes ###

 Possible regressions 

  * igt@core_auth@basic-auth:
- fi-kbl-8809g:   [PASS][1] -> [FAIL][2]
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-kbl-8809g/igt@core_a...@basic-auth.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17057/fi-kbl-8809g/igt@core_a...@basic-auth.html

  * igt@kms_addfb_basic@addfb25-bad-modifier:
- fi-icl-y:   [PASS][3] -> [SKIP][4] +82 similar issues
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-y/igt@kms_addfb_ba...@addfb25-bad-modifier.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17057/fi-icl-y/igt@kms_addfb_ba...@addfb25-bad-modifier.html

  * igt@kms_addfb_basic@bad-pitch-128:
- fi-cml-u2:  [PASS][5] -> [SKIP][6] +86 similar issues
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cml-u2/igt@kms_addfb_ba...@bad-pitch-128.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17057/fi-cml-u2/igt@kms_addfb_ba...@bad-pitch-128.html

  * igt@kms_addfb_basic@clobberred-modifier:
- fi-icl-guc: [PASS][7] -> [SKIP][8] +82 similar issues
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-guc/igt@kms_addfb_ba...@clobberred-modifier.html
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17057/fi-icl-guc/igt@kms_addfb_ba...@clobberred-modifier.html

  * igt@kms_chamelium@hdmi-hpd-fast:
- fi-icl-u2:  [PASS][9] -> [SKIP][10] +89 similar issues
   [9]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-u2/igt@kms_chamel...@hdmi-hpd-fast.html
   [10]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17057/fi-icl-u2/igt@kms_chamel...@hdmi-hpd-fast.html

  * igt@kms_cursor_legacy@basic-flip-after-cursor-legacy:
- fi-cml-s:   [PASS][11] -> [SKIP][12] +82 similar issues
   [11]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cml-s/igt@kms_cursor_leg...@basic-flip-after-cursor-legacy.html
   [12]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17057/fi-cml-s/igt@kms_cursor_leg...@basic-flip-after-cursor-legacy.html

  * igt@prime_vgem@basic-wait-default:
- fi-icl-dsi: [PASS][13] -> [SKIP][14] +82 similar issues
   [13]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-dsi/igt@prime_v...@basic-wait-default.html
   [14]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17057/fi-icl-dsi/igt@prime_v...@basic-wait-default.html

  
 Warnings 

  * igt@kms_chamelium@dp-crc-fast:
- fi-icl-dsi: [SKIP][15] ([fdo#109284] / [fdo#111827]) -> 
[SKIP][16] +8 similar issues
   [15]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-dsi/igt@kms_chamel...@dp-crc-fast.html
   [16]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17057/fi-icl-dsi/igt@kms_chamel...@dp-crc-fast.html
- fi-icl-y:   [SKIP][17] ([fdo#109284] / [fdo#111827]) -> 
[SKIP][18] +8 similar issues
   [17]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-y/igt@kms_chamel...@dp-crc-fast.html
   [18]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17057/fi-icl-y/igt@kms_chamel...@dp-crc-fast.html

  * igt@kms_chamelium@dp-edid-read:
- fi-icl-guc: [SKIP][19] ([fdo#109284] / [fdo#111827]) -> 
[SKIP][20] +8 similar issues
   [19]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-guc/igt@kms_chamel...@dp-edid-read.html
   [20]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17057/fi-icl-guc/igt@kms_chamel...@dp-edid-read.html

  * igt@kms_chamelium@dp-hpd-fast:
- fi-cml-s:   [SKIP][21] ([fdo#109284] / [fdo#111827]) -> 
[SKIP][22] +8 similar issues
   [21]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cml-s/igt@kms_chamel...@dp-hpd-fast.html
   [22]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17057/fi-cml-s/igt@kms_chamel...@dp-hpd-fast.html

  * igt@kms_chamelium@hdmi-hpd-fast:
- fi-cml-u2:  [SKIP][23] ([i915#1004]) -> [SKIP][24] +2 similar 
issues
   [23]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cml-u2/igt@kms_chamel...@hdmi-hpd-fast.html
   [24]: 

[Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm_device managed resources (rev5)

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm_device managed resources (rev5)
URL   : https://patchwork.freedesktop.org/series/73633/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Sparse version: v0.6.0
Commit: mm/sl[uo]b: export __kmalloc_track(_node)_caller
Okay!

___
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_device managed resources (rev5)

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm_device managed resources (rev5)
URL   : https://patchwork.freedesktop.org/series/73633/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
bfd50eb8548d mm/sl[uo]b: export __kmalloc_track(_node)_caller
-:58: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch 
author 'Daniel Vetter '

total: 0 errors, 1 warnings, 0 checks, 28 lines checked
46c65bbf5cb3 drm/i915: Don't clear drvdata in ->release
-:20: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ 
chars of sha1> ("")' - ie: 'commit 0998d0631001 ("device-core: 
Ensure drvdata = NULL when no driver is bound")'
#20: 
commit 0998d0631001288a5974afc0b2a5f568bcdecb4d

-:45: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch 
author 'Daniel Vetter '

total: 1 errors, 1 warnings, 0 checks, 9 lines checked
a339db608acb drm: add managed resources tied to drm_device
-:72: WARNING:TYPO_SPELLING: 'unecessary' may be misspelled - perhaps 
'unnecessary'?
#72: 
v5: Remove unecessary {} around if else

-:74: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description 
(prefer a maximum 75 chars per line)
#74: 
v6: Use kstrdup_const, which requires kfree_const and introducing a free_dr()

-:81: ERROR:BAD_SIGN_OFF: Unrecognized email address: 'Neil Armstrong 
driver->release && !dev->managed.final_kfree) {
[...]
-   }
[...]

-:149: WARNING:NEEDLESS_IF: kfree(NULL) is safe and this check is probably not 
required
#149: FILE: drivers/gpu/drm/drm_drv.c:841:
+   } else if (dev->managed.final_kfree)
+   kfree(dev->managed.final_kfree);

-:168: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does 
MAINTAINERS need updating?
#168: 
new file mode 100644

-:243: ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar"
#243: FILE: drivers/gpu/drm/drm_managed.c:71:
+static __always_inline struct drmres * alloc_dr(drmres_release_t release,

-:271: CHECK:SPACING: No space is necessary after a cast
#271: FILE: drivers/gpu/drm/drm_managed.c:99:
+  dr, dr->node.name, (unsigned long) dr->node.size);

-:283: CHECK:SPACING: No space is necessary after a cast
#283: FILE: drivers/gpu/drm/drm_managed.c:111:
+  dr, dr->node.name, (unsigned long) dr->node.size);

-:289: CHECK:SPACING: No space is necessary after a cast
#289: FILE: drivers/gpu/drm/drm_managed.c:117:
+   WARN_ON(dev < (struct drm_device *) container);

-:291: CHECK:SPACING: No space is necessary after a cast
#291: FILE: drivers/gpu/drm/drm_managed.c:119:
+   (struct drm_device *) (container + ksize(container)));

-:303: ERROR:POINTER_LOCATION: "(foo*)" should be "(foo *)"
#303: FILE: drivers/gpu/drm/drm_managed.c:131:
+   dr = alloc_dr(action, data ? sizeof(void*) : 0,

-:398: WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 
'include/drm/drm_managed.h', please use '/*' instead
#398: FILE: include/drm/drm_managed.h:1:
+// SPDX-License-Identifier: GPL-2.0

-:398: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier 
tag in line 1
#398: FILE: include/drm/drm_managed.h:1:
+// SPDX-License-Identifier: GPL-2.0

-:451: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch 
author 'Daniel Vetter '

total: 3 errors, 7 warnings, 5 checks, 322 lines checked
36a0f9617061 drm: Set final_kfree in drm_dev_alloc
-:15: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ 
chars of sha1> ("")' - ie: 'commit 0a6659bdc5e8 ("drm/bochs: new 
driver")'
#15: 
commit 0a6659bdc5e8221da99eebb176fd9591435e38de

-:25: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ 
chars of sha1> ("")' - ie: 'commit b1df3a2b24a9 ("drm/virtio: add 
drm_driver.release callback.")'
#25: 
commit b1df3a2b24a917f8853d43fe9683c0e360d2c33a

-:44: WARNING:BAD_SIGN_OFF: Duplicate signature
#44: 
Cc: Oleksandr Andrushchenko 

-:45: WARNING:BAD_SIGN_OFF: Duplicate signature
#45: 
Cc: xen-de...@lists.xenproject.org

-:87: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch 
author 'Daniel Vetter '

total: 2 errors, 3 warnings, 0 checks, 29 lines checked
503da7cd8c70 drm/mipi_dbi: Use drmm_add_final_kfree in all drivers
-:189: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch 
author 'Daniel Vetter '

total: 0 errors, 1 warnings, 0 checks, 111 lines checked
a30b59188383 drm/udl: Use drmm_add_final_kfree
-:63: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch 
author 'Daniel Vetter '

total: 0 errors, 1 warnings, 0 checks, 27 lines checked
4d66e43a6718 drm/qxl: Use drmm_add_final_kfree
-:47: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch 
author 'Daniel Vetter '

total: 0 errors, 1 warnings, 0 checks, 22 lines checked
b813257d1b29 drm/i915: Use drmm_add_final_kfree
-:207: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch 
author 'Daniel Vetter '

total: 0 errors, 1 

[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/display: Trigger Modeset at boot for audio codec init (rev2)

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm/i915/display: Trigger Modeset at boot for audio codec init (rev2)
URL   : https://patchwork.freedesktop.org/series/74828/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_8180 -> Patchwork_17056


Summary
---

  **SUCCESS**

  No regressions found.

  External URL: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17056/index.html

Known issues


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

### IGT changes ###

 Issues hit 

  * igt@kms_chamelium@common-hpd-after-suspend:
- fi-cml-u2:  [PASS][1] -> [DMESG-WARN][2] ([IGT#4])
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cml-u2/igt@kms_chamel...@common-hpd-after-suspend.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17056/fi-cml-u2/igt@kms_chamel...@common-hpd-after-suspend.html

  * igt@kms_chamelium@dp-crc-fast:
- fi-cml-u2:  [PASS][3] -> [FAIL][4] ([i915#217])
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cml-u2/igt@kms_chamel...@dp-crc-fast.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17056/fi-cml-u2/igt@kms_chamel...@dp-crc-fast.html

  
 Possible fixes 

  * igt@i915_selftest@live@execlists:
- fi-bxt-dsi: [INCOMPLETE][5] ([fdo#103927] / [i915#656]) -> 
[PASS][6]
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-bxt-dsi/igt@i915_selftest@l...@execlists.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17056/fi-bxt-dsi/igt@i915_selftest@l...@execlists.html

  
 Warnings 

  * igt@i915_selftest@live@gem_contexts:
- fi-cfl-guc: [DMESG-FAIL][7] ([i915#481]) -> [DMESG-FAIL][8] 
([i915#943])
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cfl-guc/igt@i915_selftest@live@gem_contexts.html
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17056/fi-cfl-guc/igt@i915_selftest@live@gem_contexts.html

  
  [IGT#4]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/4
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [i915#217]: https://gitlab.freedesktop.org/drm/intel/issues/217
  [i915#481]: https://gitlab.freedesktop.org/drm/intel/issues/481
  [i915#656]: https://gitlab.freedesktop.org/drm/intel/issues/656
  [i915#943]: https://gitlab.freedesktop.org/drm/intel/issues/943


Participating hosts (40 -> 43)
--

  Additional (10): fi-bdw-5557u fi-hsw-peppy fi-kbl-7500u fi-gdg-551 
fi-elk-e7500 fi-skl-lmem fi-blb-e6850 fi-bsw-nick fi-skl-6600u fi-snb-2600 
  Missing(7): fi-bsw-n3050 fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 
fi-kbl-7560u fi-byt-clapper fi-bdw-samus 


Build changes
-

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_8180 -> Patchwork_17056

  CI-20190529: 20190529
  CI_DRM_8180: 257af0ddcea3a234dcb79579600f971edd47353f @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5530: 2020d743940f06294d06006bb737be43fcd2881e @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17056: 0db59c6d9bd50ac3f03b40c76535eac49d25adb2 @ 
git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

0db59c6d9bd5 drm/i915/display: Trigger Modeset at boot for audio codec init

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17056/index.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 drm/i915/display: Trigger Modeset at boot for audio codec init (rev2)

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm/i915/display: Trigger Modeset at boot for audio codec init (rev2)
URL   : https://patchwork.freedesktop.org/series/74828/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
0db59c6d9bd5 drm/i915/display: Trigger Modeset at boot for audio codec init
-:33: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description 
(prefer a maximum 75 chars per line)
#33: 
To: Ville Syrjälä ; Shankar, Uma 


-:87: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ 
chars of sha1> ("")' - ie: 'commit 33e059a2e4df ("drm/i915/psr: 
Force PSR probe only after full initialization")'
#87: 
> > commit 33e059a2e4df454359f642f2235af39de9d3e914

-:105: WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to 
using 'intel_atomic_check', this function's name, in a string
#105: FILE: drivers/gpu/drm/i915/display/intel_display.c:14746:
+   DRM_INFO("SA: intel_atomic_check: uapi change \n");

-:105: WARNING:QUOTED_WHITESPACE_BEFORE_NEWLINE: unnecessary whitespace before 
a quoted newline
#105: FILE: drivers/gpu/drm/i915/display/intel_display.c:14746:
+   DRM_INFO("SA: intel_atomic_check: uapi change \n");

-:112: CHECK:BRACES: Blank lines aren't necessary after an open brace '{'
#112: FILE: drivers/gpu/drm/i915/display/intel_display.c:14751:
new_crtc_state, i) {
+

-:113: WARNING:LONG_LINE: line over 100 characters
#113: FILE: drivers/gpu/drm/i915/display/intel_display.c:14752:
+   DRM_INFO("SA2: intel_atomic_check: 
new_crtc_state->uapi.mode.private_flags= %d, 
old_crtc_state->uapi.mode.private_flags= %d  \n", 
new_crtc_state->uapi.mode.private_flags, 
old_crtc_state->uapi.mode.private_flags );

-:113: ERROR:SPACING: space prohibited before that close parenthesis ')'
#113: FILE: drivers/gpu/drm/i915/display/intel_display.c:14752:
+   DRM_INFO("SA2: intel_atomic_check: 
new_crtc_state->uapi.mode.private_flags= %d, 
old_crtc_state->uapi.mode.private_flags= %d  \n", 
new_crtc_state->uapi.mode.private_flags, 
old_crtc_state->uapi.mode.private_flags );

-:113: WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to 
using 'intel_atomic_check', this function's name, in a string
#113: FILE: drivers/gpu/drm/i915/display/intel_display.c:14752:
+   DRM_INFO("SA2: intel_atomic_check: 
new_crtc_state->uapi.mode.private_flags= %d, 
old_crtc_state->uapi.mode.private_flags= %d  \n", 
new_crtc_state->uapi.mode.private_flags, 
old_crtc_state->uapi.mode.private_flags );

-:113: WARNING:QUOTED_WHITESPACE_BEFORE_NEWLINE: unnecessary whitespace before 
a quoted newline
#113: FILE: drivers/gpu/drm/i915/display/intel_display.c:14752:
+   DRM_INFO("SA2: intel_atomic_check: 
new_crtc_state->uapi.mode.private_flags= %d, 
old_crtc_state->uapi.mode.private_flags= %d  \n", 
new_crtc_state->uapi.mode.private_flags, 
old_crtc_state->uapi.mode.private_flags );

-:118: ERROR:MISSING_SIGN_OFF: Missing Signed-off-by: line(s)

total: 3 errors, 6 warnings, 1 checks, 17 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 series starting with [01/12] drm/i915/selftests: Add request throughput measurement to perf

2020-03-23 Thread Patchwork
== Series Details ==

Series: series starting with [01/12] drm/i915/selftests: Add request throughput 
measurement to perf
URL   : https://patchwork.freedesktop.org/series/74974/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_8180 -> Patchwork_17055


Summary
---

  **SUCCESS**

  No regressions found.

  External URL: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/index.html

New tests
-

  New tests have been introduced between CI_DRM_8180 and Patchwork_17055:

### New IGT tests (2) ###

  * igt@dmabuf@all@dma_fence_chain:
- Statuses : 38 pass(s)
- Exec time: [7.36, 28.83] s

  * igt@dmabuf@all@dma_fence_proxy:
- Statuses : 38 pass(s)
- Exec time: [0.03, 0.10] s

  

Known issues


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

### IGT changes ###

 Issues hit 

  * igt@i915_selftest@live@execlists:
- fi-icl-y:   [PASS][1] -> [INCOMPLETE][2] ([i915#140])
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-y/igt@i915_selftest@l...@execlists.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/fi-icl-y/igt@i915_selftest@l...@execlists.html
- fi-icl-guc: [PASS][3] -> [INCOMPLETE][4] ([i915#140])
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-guc/igt@i915_selftest@l...@execlists.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/fi-icl-guc/igt@i915_selftest@l...@execlists.html

  
 Warnings 

  * igt@i915_selftest@live@gem_contexts:
- fi-cfl-guc: [DMESG-FAIL][5] ([i915#481]) -> [DMESG-FAIL][6] 
([i915#730] / [i915#933])
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cfl-guc/igt@i915_selftest@live@gem_contexts.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/fi-cfl-guc/igt@i915_selftest@live@gem_contexts.html

  
  [i915#140]: https://gitlab.freedesktop.org/drm/intel/issues/140
  [i915#481]: https://gitlab.freedesktop.org/drm/intel/issues/481
  [i915#730]: https://gitlab.freedesktop.org/drm/intel/issues/730
  [i915#933]: https://gitlab.freedesktop.org/drm/intel/issues/933


Participating hosts (40 -> 42)
--

  Additional (10): fi-bdw-5557u fi-hsw-peppy fi-kbl-7500u fi-gdg-551 
fi-elk-e7500 fi-skl-lmem fi-blb-e6850 fi-bsw-nick fi-skl-6600u fi-snb-2600 
  Missing(8): fi-kbl-soraka fi-byt-squawks fi-icl-u2 fi-bsw-cyan 
fi-ctg-p8600 fi-kbl-7560u fi-byt-clapper fi-bdw-samus 


Build changes
-

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_8180 -> Patchwork_17055

  CI-20190529: 20190529
  CI_DRM_8180: 257af0ddcea3a234dcb79579600f971edd47353f @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5530: 2020d743940f06294d06006bb737be43fcd2881e @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17055: 1342e0cc637a60ab6f963d64298be1d744e2916a @ 
git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

1342e0cc637a drm/i915/gt: Yield the timeslice if caught waiting on a user 
semaphore
341125247817 drm/i915/gt: Declare when we enabled timeslicing
9b2b992129d0 drm/i915/gem: Allow combining submit-fences with syncobj
23be6793b2d9 drm/i915/gem: Teach execbuf how to wait on future syncobj
8f54e0485592 drm/syncobj: Allow use of dma-fence-proxy
3b5f0d282759 dma-buf: Proxy fence, an unsignaled fence placeholder
eeb9fd4e53b9 dma-buf: Exercise dma-fence-chain under selftests
e6dfb3670cb9 dma-buf: Report signaled links inside dma-fence-chain
5a79f011558a dma-buf: Prettify typecasts for dma-fence-chain
c65d3fa2eec2 drm/i915/perf: Schedule oa_config after modifying the contexts
030aa96c9843 drm/i915: Wrap i915_active in a simple kreffed struct
c1539761ed10 drm/i915/selftests: Add request throughput measurement to perf

== Logs ==

For more details see: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17055/index.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 series starting with [01/12] drm/i915/selftests: Add request throughput measurement to perf

2020-03-23 Thread Patchwork
== Series Details ==

Series: series starting with [01/12] drm/i915/selftests: Add request throughput 
measurement to perf
URL   : https://patchwork.freedesktop.org/series/74974/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
c1539761ed10 drm/i915/selftests: Add request throughput measurement to perf
-:96: WARNING:LINE_SPACING: Missing a blank line after declarations
#96: FILE: drivers/gpu/drm/i915/selftests/i915_request.c:1519:
+   struct perf_series *ps = arg;
+   IGT_TIMEOUT(end_time);

-:130: WARNING:LINE_SPACING: Missing a blank line after declarations
#130: FILE: drivers/gpu/drm/i915/selftests/i915_request.c:1553:
+   struct i915_request *prev = NULL;
+   IGT_TIMEOUT(end_time);

-:165: WARNING:LINE_SPACING: Missing a blank line after declarations
#165: FILE: drivers/gpu/drm/i915/selftests/i915_request.c:1588:
+   struct perf_series *ps = arg;
+   IGT_TIMEOUT(end_time);

-:188: WARNING:LINE_SPACING: Missing a blank line after declarations
#188: FILE: drivers/gpu/drm/i915/selftests/i915_request.c:1611:
+   struct drm_i915_private *i915 = arg;
+   static int (* const func[])(void *arg) = {

-:196: WARNING:LINE_SPACING: Missing a blank line after declarations
#196: FILE: drivers/gpu/drm/i915/selftests/i915_request.c:1619:
+   struct intel_engine_cs *engine;
+   int (* const *fn)(void *arg);

-:325: WARNING:LINE_SPACING: Missing a blank line after declarations
#325: FILE: drivers/gpu/drm/i915/selftests/i915_request.c:1748:
+   struct intel_context *ce;
+   IGT_TIMEOUT(end_time);

-:393: WARNING:LINE_SPACING: Missing a blank line after declarations
#393: FILE: drivers/gpu/drm/i915/selftests/i915_request.c:1816:
+   struct intel_context *ce;
+   IGT_TIMEOUT(end_time);

-:462: WARNING:LINE_SPACING: Missing a blank line after declarations
#462: FILE: drivers/gpu/drm/i915/selftests/i915_request.c:1885:
+   struct intel_context *ce;
+   IGT_TIMEOUT(end_time);

-:518: WARNING:LINE_SPACING: Missing a blank line after declarations
#518: FILE: drivers/gpu/drm/i915/selftests/i915_request.c:1941:
+   struct drm_i915_private *i915 = arg;
+   static int (* const func[])(void *arg) = {

-:526: WARNING:LINE_SPACING: Missing a blank line after declarations
#526: FILE: drivers/gpu/drm/i915/selftests/i915_request.c:1949:
+   struct intel_engine_cs *engine;
+   int (* const *fn)(void *arg);

-:571: WARNING:YIELD: Using yield() is generally wrong. See yield() kernel-doc 
(sched/core.c)
#571: FILE: drivers/gpu/drm/i915/selftests/i915_request.c:1994:
+   yield(); /* start all threads before we kthread_stop() */

total: 0 errors, 11 warnings, 0 checks, 611 lines checked
030aa96c9843 drm/i915: Wrap i915_active in a simple kreffed struct
c65d3fa2eec2 drm/i915/perf: Schedule oa_config after modifying the contexts
5a79f011558a dma-buf: Prettify typecasts for dma-fence-chain
e6dfb3670cb9 dma-buf: Report signaled links inside dma-fence-chain
eeb9fd4e53b9 dma-buf: Exercise dma-fence-chain under selftests
-:33: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does 
MAINTAINERS need updating?
#33: 
new file mode 100644

-:61: CHECK:UNCOMMENTED_DEFINITION: spinlock_t definition without comment
#61: FILE: drivers/dma-buf/st-dma-fence-chain.c:24:
+   spinlock_t lock;

-:235: WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to 
using 'find_seqno', this function's name, in a string
#235: FILE: drivers/dma-buf/st-dma-fence-chain.c:198:
+   pr_err("Reported %d for find_seqno(0)!\n", err);

-:244: WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to 
using 'find_seqno', this function's name, in a string
#244: FILE: drivers/dma-buf/st-dma-fence-chain.c:207:
+   pr_err("Reported %d for find_seqno(%d:%d)!\n",

-:249: WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to 
using 'find_seqno', this function's name, in a string
#249: FILE: drivers/dma-buf/st-dma-fence-chain.c:212:
+   pr_err("Incorrect fence reported by 
find_seqno(%d:%d)\n",

-:272: WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to 
using 'find_seqno', this function's name, in a string
#272: FILE: drivers/dma-buf/st-dma-fence-chain.c:235:
+   pr_err("Error not reported for future fence: 
find_seqno(%d:%d)!\n",

-:286: WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to 
using 'find_seqno', this function's name, in a string
#286: FILE: drivers/dma-buf/st-dma-fence-chain.c:249:
+   pr_err("Incorrect fence reported by 
find_seqno(%d:%d)\n",

-:737: WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to 
using 'dma_fence_chain', this function's name, in a string
#737: FILE: drivers/dma-buf/st-dma-fence-chain.c:700:
+   pr_info("sizeof(dma_fence_chain)=%zu\n",

total: 0 errors, 7 warnings, 1 checks, 725 lines checked
3b5f0d282759 dma-buf: Proxy fence, an unsignaled fence placeholder

[Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [1/4] drm/i915/execlists: Pull tasklet interrupt-bh local to direct submission

2020-03-23 Thread Patchwork
== Series Details ==

Series: series starting with [1/4] drm/i915/execlists: Pull tasklet 
interrupt-bh local to direct submission
URL   : https://patchwork.freedesktop.org/series/74973/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8180 -> Patchwork_17054


Summary
---

  **FAILURE**

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

  External URL: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17054/index.html

Possible new issues
---

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

### IGT changes ###

 Possible regressions 

  * igt@gem_exec_parallel@contexts:
- fi-bsw-nick:NOTRUN -> [INCOMPLETE][1]
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17054/fi-bsw-nick/igt@gem_exec_paral...@contexts.html

  
Known issues


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

### IGT changes ###

 Issues hit 

  * igt@i915_pm_rpm@basic-pci-d3-state:
- fi-icl-dsi: [PASS][2] -> [INCOMPLETE][3] ([i915#189])
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-dsi/igt@i915_pm_...@basic-pci-d3-state.html
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17054/fi-icl-dsi/igt@i915_pm_...@basic-pci-d3-state.html

  * igt@i915_selftest@live@execlists:
- fi-icl-y:   [PASS][4] -> [DMESG-FAIL][5] ([fdo#108569])
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-icl-y/igt@i915_selftest@l...@execlists.html
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17054/fi-icl-y/igt@i915_selftest@l...@execlists.html

  * igt@kms_chamelium@dp-crc-fast:
- fi-cml-u2:  [PASS][6] -> [FAIL][7] ([i915#217])
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cml-u2/igt@kms_chamel...@dp-crc-fast.html
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17054/fi-cml-u2/igt@kms_chamel...@dp-crc-fast.html

  
 Possible fixes 

  * igt@i915_selftest@live@execlists:
- fi-bxt-dsi: [INCOMPLETE][8] ([fdo#103927] / [i915#656]) -> 
[PASS][9]
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-bxt-dsi/igt@i915_selftest@l...@execlists.html
   [9]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17054/fi-bxt-dsi/igt@i915_selftest@l...@execlists.html

  * igt@i915_selftest@live@gem_contexts:
- fi-cfl-8700k:   [DMESG-FAIL][10] ([i915#481]) -> [PASS][11]
   [10]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cfl-8700k/igt@i915_selftest@live@gem_contexts.html
   [11]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17054/fi-cfl-8700k/igt@i915_selftest@live@gem_contexts.html
- fi-cfl-guc: [DMESG-FAIL][12] ([i915#481]) -> [PASS][13]
   [12]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cfl-guc/igt@i915_selftest@live@gem_contexts.html
   [13]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17054/fi-cfl-guc/igt@i915_selftest@live@gem_contexts.html

  
  {name}: This element is suppressed. This means it is ignored when computing
  the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
  [i915#189]: https://gitlab.freedesktop.org/drm/intel/issues/189
  [i915#217]: https://gitlab.freedesktop.org/drm/intel/issues/217
  [i915#481]: https://gitlab.freedesktop.org/drm/intel/issues/481
  [i915#656]: https://gitlab.freedesktop.org/drm/intel/issues/656


Participating hosts (40 -> 40)
--

  Additional (10): fi-bdw-5557u fi-hsw-peppy fi-kbl-7500u fi-gdg-551 
fi-elk-e7500 fi-skl-lmem fi-blb-e6850 fi-bsw-nick fi-skl-6600u fi-snb-2600 
  Missing(10): fi-bdw-samus fi-skl-6770hq fi-byt-squawks fi-icl-u2 
fi-bsw-cyan fi-snb-2520m fi-ctg-p8600 fi-kbl-7560u fi-byt-clapper fi-skl-6700k2 


Build changes
-

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_8180 -> Patchwork_17054

  CI-20190529: 20190529
  CI_DRM_8180: 257af0ddcea3a234dcb79579600f971edd47353f @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5530: 2020d743940f06294d06006bb737be43fcd2881e @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17054: 42c13a451e00d6b974abf23ab42bfd6de7cb30e1 @ 
git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

42c13a451e00 drm/i915/gem: Prevent switching of active GEM context VM
c9fc4147269c drm/i915: Allow for different modes of interruptible 
i915_active_wait
2e7463a5b755 drm/i915: Immediately execute the fenced work
cc3bda70c931 drm/i915/execlists: Pull tasklet interrupt-bh local to direct 

[Intel-gfx] [PATCH] drm/i915/gem: Wait until the context is finally retired before releasing engines

2020-03-23 Thread Chris Wilson
If we want to percolate information back from the HW, up through the GEM
context, we need to wait until the intel_context is scheduled out for
the last time. This is handled by the retirement of the intel_context's
barrier, i.e. by listening to the pulse after the notional unpin. So
wait until the intel_context is finally retired before releasing the
engine, so that we can inspect the final context state and pass it on.

Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 16 +++---
 drivers/gpu/drm/i915/i915_active.c  | 57 -
 drivers/gpu/drm/i915/i915_active.h  |  3 +-
 3 files changed, 64 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c 
b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index dffe0daee0d2..55f7879f6db4 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -570,23 +570,19 @@ static void engines_idle_release(struct i915_gem_context 
*ctx,
engines->ctx = i915_gem_context_get(ctx);
 
for_each_gem_engine(ce, engines, it) {
-   struct dma_fence *fence;
-   int err = 0;
+   int err;
 
/* serialises with execbuf */
set_bit(CONTEXT_CLOSED_BIT, >flags);
if (!intel_context_pin_if_active(ce))
continue;
 
-   fence = i915_active_fence_get(>timeline->last_request);
-   if (fence) {
-   err = i915_sw_fence_await_dma_fence(>fence,
-   fence, 0,
-   GFP_KERNEL);
-   dma_fence_put(fence);
-   }
+   /* Wait until context is finally scheduled out and retired */
+   err = i915_sw_fence_await_active(>fence,
+>active,
+I915_ACTIVE_AWAIT_BARRIER);
intel_context_unpin(ce);
-   if (err < 0)
+   if (err)
goto kill;
}
 
diff --git a/drivers/gpu/drm/i915/i915_active.c 
b/drivers/gpu/drm/i915/i915_active.c
index 7b685032cc1e..c01bf25c8e5e 100644
--- a/drivers/gpu/drm/i915/i915_active.c
+++ b/drivers/gpu/drm/i915/i915_active.c
@@ -542,6 +542,54 @@ static int __await_active(struct i915_active_fence *active,
return 0;
 }
 
+struct wait_barrier {
+   struct wait_queue_entry base;
+   struct i915_active *ref;
+};
+
+static int
+barrier_wake(wait_queue_entry_t *wq, unsigned mode, int flags, void *key)
+{
+   struct wait_barrier *wb = container_of(wq, typeof(*wb), base);
+
+   if (i915_active_is_idle(wb->ref)) { /* shared waitqueue, must check! */
+   list_del(>entry);
+   i915_sw_fence_complete(wq->private);
+   kfree(wq);
+   }
+
+   return 0;
+}
+
+static int __await_barrier(struct i915_active *ref, struct i915_sw_fence 
*fence)
+{
+   struct wait_barrier *wb;
+
+   wb = kmalloc(sizeof(*wb), GFP_NOWAIT | __GFP_NOWARN);
+   if (unlikely(!wb))
+   return -ENOMEM;
+
+   if (!i915_active_acquire_if_busy(ref)) {
+   kfree(wb);
+   return 0;
+   }
+
+   if (!i915_sw_fence_await(fence)) {
+   kfree(wb);
+   i915_active_release(ref);
+   return -EINVAL;
+   }
+
+   wb->base.flags = 0;
+   wb->base.func = barrier_wake;
+   wb->base.private = fence;
+
+   add_wait_queue(__var_waitqueue(ref), >base);
+
+   i915_active_release(ref);
+   return 0;
+}
+
 static int await_active(struct i915_active *ref,
unsigned int flags,
int (*fn)(void *arg, struct dma_fence *fence),
@@ -556,7 +604,8 @@ static int await_active(struct i915_active *ref,
return err;
}
 
-   if (flags & I915_ACTIVE_AWAIT_ALL && i915_active_acquire_if_busy(ref)) {
+   if (flags & I915_ACTIVE_AWAIT_ACTIVE &&
+   i915_active_acquire_if_busy(ref)) {
struct active_node *it, *n;
 
rbtree_postorder_for_each_entry_safe(it, n, >tree, node) {
@@ -569,6 +618,12 @@ static int await_active(struct i915_active *ref,
return err;
}
 
+   if (flags & I915_ACTIVE_AWAIT_BARRIER) {
+   err = __await_barrier(ref, arg);
+   if (err)
+   return err;
+   }
+
return 0;
 }
 
diff --git a/drivers/gpu/drm/i915/i915_active.h 
b/drivers/gpu/drm/i915/i915_active.h
index 4f9aa7bab514..c7d54d2302a2 100644
--- a/drivers/gpu/drm/i915/i915_active.h
+++ b/drivers/gpu/drm/i915/i915_active.h
@@ -193,7 +193,8 @@ int i915_sw_fence_await_active(struct i915_sw_fence *fence,
 int i915_request_await_active(struct i915_request *rq,
   

[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/4] drm/i915/execlists: Pull tasklet interrupt-bh local to direct submission

2020-03-23 Thread Patchwork
== Series Details ==

Series: series starting with [1/4] drm/i915/execlists: Pull tasklet 
interrupt-bh local to direct submission
URL   : https://patchwork.freedesktop.org/series/74973/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
cc3bda70c931 drm/i915/execlists: Pull tasklet interrupt-bh local to direct 
submission
2e7463a5b755 drm/i915: Immediately execute the fenced work
-:54: WARNING:AVOID_BUG: Avoid crashing the kernel - try using WARN_ON & 
recovery code rather than BUG() or BUG_ON()
#54: FILE: drivers/gpu/drm/i915/i915_sw_fence_work.h:17:
+#define __DBG_BUG_ON(expr) BUG_ON(expr)

total: 0 errors, 1 warnings, 0 checks, 76 lines checked
c9fc4147269c drm/i915: Allow for different modes of interruptible 
i915_active_wait
42c13a451e00 drm/i915/gem: Prevent switching of active GEM context VM

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


[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/selftests: mark huge_gem_object as not shrinkable

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm/i915/selftests: mark huge_gem_object as not shrinkable
URL   : https://patchwork.freedesktop.org/series/74972/
State : failure

== Summary ==

Applying: drm/i915/selftests: mark huge_gem_object as not shrinkable
Using index info to reconstruct a base tree...
M   drivers/gpu/drm/i915/gem/selftests/huge_gem_object.c
Falling back to patching base and 3-way merge...
No changes -- Patch already applied.

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


[Intel-gfx] ✗ Fi.CI.IGT: failure for i915 lpsp support for lpsp igt (rev3)

2020-03-23 Thread Patchwork
== Series Details ==

Series: i915 lpsp support for lpsp igt (rev3)
URL   : https://patchwork.freedesktop.org/series/74648/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8175_full -> Patchwork_17049_full


Summary
---

  **FAILURE**

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

  

Possible new issues
---

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

### IGT changes ###

 Possible regressions 

  * igt@i915_pm_rpm@system-suspend:
- shard-tglb: [PASS][1] -> [SKIP][2]
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8175/shard-tglb3/igt@i915_pm_...@system-suspend.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17049/shard-tglb2/igt@i915_pm_...@system-suspend.html
- shard-iclb: [PASS][3] -> [SKIP][4]
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8175/shard-iclb1/igt@i915_pm_...@system-suspend.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17049/shard-iclb1/igt@i915_pm_...@system-suspend.html

  
 Warnings 

  * igt@i915_pm_lpsp@non-edp:
- shard-iclb: [SKIP][5] ([fdo#109301]) -> [SKIP][6]
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8175/shard-iclb7/igt@i915_pm_l...@non-edp.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17049/shard-iclb7/igt@i915_pm_l...@non-edp.html
- shard-tglb: [SKIP][7] ([fdo#109301]) -> [SKIP][8]
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8175/shard-tglb6/igt@i915_pm_l...@non-edp.html
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17049/shard-tglb2/igt@i915_pm_l...@non-edp.html

  * igt@i915_pm_lpsp@screens-disabled:
- shard-snb:  [SKIP][9] ([fdo#109271]) -> [FAIL][10]
   [9]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8175/shard-snb6/igt@i915_pm_l...@screens-disabled.html
   [10]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17049/shard-snb6/igt@i915_pm_l...@screens-disabled.html

  
Known issues


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

### IGT changes ###

 Issues hit 

  * igt@gem_busy@extended-parallel-vcs1:
- shard-iclb: [PASS][11] -> [SKIP][12] ([fdo#112080]) +11 similar 
issues
   [11]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8175/shard-iclb1/igt@gem_b...@extended-parallel-vcs1.html
   [12]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17049/shard-iclb5/igt@gem_b...@extended-parallel-vcs1.html

  * igt@gem_ctx_isolation@rcs0-s3:
- shard-kbl:  [PASS][13] -> [DMESG-WARN][14] ([i915#180]) +3 
similar issues
   [13]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8175/shard-kbl4/igt@gem_ctx_isolat...@rcs0-s3.html
   [14]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17049/shard-kbl4/igt@gem_ctx_isolat...@rcs0-s3.html

  * igt@gem_ctx_persistence@close-replace-race:
- shard-tglb: [PASS][15] -> [INCOMPLETE][16] ([i915#1402])
   [15]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8175/shard-tglb6/igt@gem_ctx_persiste...@close-replace-race.html
   [16]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17049/shard-tglb8/igt@gem_ctx_persiste...@close-replace-race.html

  * igt@gem_exec_async@concurrent-writes-bsd:
- shard-iclb: [PASS][17] -> [SKIP][18] ([fdo#112146]) +6 similar 
issues
   [17]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8175/shard-iclb7/igt@gem_exec_as...@concurrent-writes-bsd.html
   [18]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17049/shard-iclb1/igt@gem_exec_as...@concurrent-writes-bsd.html

  * igt@gem_exec_schedule@implicit-write-read-bsd1:
- shard-iclb: [PASS][19] -> [SKIP][20] ([fdo#109276] / [i915#677]) 
+1 similar issue
   [19]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8175/shard-iclb2/igt@gem_exec_sched...@implicit-write-read-bsd1.html
   [20]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17049/shard-iclb7/igt@gem_exec_sched...@implicit-write-read-bsd1.html

  * igt@gem_exec_schedule@pi-shared-iova-bsd:
- shard-iclb: [PASS][21] -> [SKIP][22] ([i915#677]) +1 similar issue
   [21]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8175/shard-iclb8/igt@gem_exec_sched...@pi-shared-iova-bsd.html
   [22]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17049/shard-iclb1/igt@gem_exec_sched...@pi-shared-iova-bsd.html

  * igt@gem_exec_schedule@preempt-queue-bsd1:
- shard-iclb: [PASS][23] -> [SKIP][24] ([fdo#109276]) +22 similar 
issues
   [23]: 

Re: [Intel-gfx] [PATCH 40/51] drm/mtk: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Chun-Kuang Hu
Daniel Vetter  於 2020年3月23日 週一 下午10:51寫道:
>
> It's right above the drm_dev_put().
>
> This is made possible by a preceeding patch which added a drmm_
> cleanup action to drm_mode_config_init(), hence all we need to do to
> ensure that drm_mode_config_cleanup() is run on final drm_device
> cleanup is check the new error code for _init().
>
> Aside: Another driver with a bit much devm_kzalloc, which should
> probably use drmm_kzalloc instead ...
>
> v2: Explain why this cleanup is possible (Laurent).
>
> v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)
>

Acked-by: Chun-Kuang Hu 

> Acked-by: Sam Ravnborg 
> Cc: Sam Ravnborg 
> Cc: Thomas Zimmermann 
> Cc: Laurent Pinchart 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 9 -
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
> b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index 0563c681..2eaa9080d250 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -162,7 +162,9 @@ static int mtk_drm_kms_init(struct drm_device *drm)
> }
> private->mutex_dev = >dev;
>
> -   drm_mode_config_init(drm);
> +   ret = drmm_mode_config_init(drm);
> +   if (ret)
> +   return ret;
>
> drm->mode_config.min_width = 64;
> drm->mode_config.min_height = 64;
> @@ -179,7 +181,7 @@ static int mtk_drm_kms_init(struct drm_device *drm)
>
> ret = component_bind_all(drm->dev, drm);
> if (ret)
> -   goto err_config_cleanup;
> +   return ret;
>
> /*
>  * We currently support two fixed data streams, each optional,
> @@ -255,8 +257,6 @@ static int mtk_drm_kms_init(struct drm_device *drm)
> dma_dev->dma_parms = NULL;
>  err_component_unbind:
> component_unbind_all(drm->dev, drm);
> -err_config_cleanup:
> -   drm_mode_config_cleanup(drm);
>
> return ret;
>  }
> @@ -272,7 +272,6 @@ static void mtk_drm_kms_deinit(struct drm_device *drm)
> private->dma_dev->dma_parms = NULL;
>
> component_unbind_all(drm->dev, drm);
> -   drm_mode_config_cleanup(drm);
>  }
>
>  static const struct file_operations mtk_drm_fops = {
> --
> 2.25.1
>
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v19 4/8] drm/i915: Refactor intel_can_enable_sagv

2020-03-23 Thread Lisovskiy, Stanislav
On Mon, Mar 23, 2020 at 04:50:08PM +0200, Ville Syrjälä wrote:
> On Mon, Mar 23, 2020 at 04:36:16PM +0200, Lisovskiy, Stanislav wrote:
> > On Mon, Mar 23, 2020 at 04:18:36PM +0200, Ville Syrjälä wrote:
> > > On Fri, Mar 20, 2020 at 02:51:41PM +0200, Lisovskiy, Stanislav wrote:
> > > > On Wed, Mar 11, 2020 at 06:31:30PM +0200, Ville Syrjälä wrote:
> > > > > On Mon, Mar 09, 2020 at 06:12:00PM +0200, Stanislav Lisovskiy wrote:
> > > > > > Currently intel_can_enable_sagv function contains
> > > > > > a mix of workarounds for different platforms
> > > > > > some of them are not valid for gens >= 11 already,
> > > > > > so lets split it into separate functions.
> > > > > > 
> > > > > > v2:
> > > > > > - Rework watermark calculation algorithm to
> > > > > >   attempt to calculate Level 0 watermark
> > > > > >   with added sagv block time latency and
> > > > > >   check if it fits in DBuf in order to
> > > > > >   determine if SAGV can be enabled already
> > > > > >   at this stage, just as BSpec 49325 states.
> > > > > >   if that fails rollback to usual Level 0
> > > > > >   latency and disable SAGV.
> > > > > > - Remove unneeded tabs(James Ausmus)
> > > > > > 
> > > > > > v3: Rebased the patch
> > > > > > 
> > > > > > v4: - Added back interlaced check for Gen12 and
> > > > > >   added separate function for TGL SAGV check
> > > > > >   (thanks to James Ausmus for spotting)
> > > > > > - Removed unneeded gen check
> > > > > > - Extracted Gen12 SAGV decision making code
> > > > > >   to a separate function from skl_compute_wm
> > > > > > 
> > > > > > v5: - Added SAGV global state to dev_priv, because
> > > > > >   we need to track all pipes, not only those
> > > > > >   in atomic state. Each pipe has now correspondent
> > > > > >   bit mask reflecting, whether it can tolerate
> > > > > >   SAGV or not(thanks to Ville Syrjala for suggestions).
> > > > > > - Now using active flag instead of enable in crc
> > > > > >   usage check.
> > > > > > 
> > > > > > v6: - Fixed rebase conflicts
> > > > > > 
> > > > > > v7: - kms_cursor_legacy seems to get broken because of multiple 
> > > > > > memcpy
> > > > > >   calls when copying level 0 water marks for enabled SAGV, to
> > > > > >   fix this now simply using that field right away, without 
> > > > > > copying,
> > > > > >   for that introduced a new wm_level accessor which decides 
> > > > > > which
> > > > > >   wm_level to return based on SAGV state.
> > > > > > 
> > > > > > v8: - Protect crtc_sagv_mask same way as we do for other global 
> > > > > > state
> > > > > >   changes: i.e check if changes are needed, then grab all crtc 
> > > > > > locks
> > > > > >   to serialize the changes(Ville Syrjälä)
> > > > > > - Add crtc_sagv_mask caching in order to avoid needless 
> > > > > > recalculations
> > > > > >   (Matthew Roper)
> > > > > > - Put back Gen12 SAGV switch in order to get it enabled in 
> > > > > > separate
> > > > > >   patch(Matthew Roper)
> > > > > > - Rename *_set_sagv_mask to *_compute_sagv_mask(Matthew Roper)
> > > > > > - Check if there are no active pipes in intel_can_enable_sagv
> > > > > >   instead of platform specific functions(Matthew Roper), same
> > > > > >   for intel_has_sagv check.
> > > > > > 
> > > > > > v9  - Switched to u8 for crtc_sagv_mask(Ville Syrjälä)
> > > > > > - crtc_sagv_mask now is pipe_sagv_mask(Ville Syrjälä)
> > > > > > - Extracted sagv checking logic from 
> > > > > > skl/icl/tgl_compute_sagv_mask
> > > > > > - Extracted skl_plane_wm_level function and passing latency to
> > > > > >   separate patches(Ville Syrjälä)
> > > > > > - Removed part of unneeded copy-paste from 
> > > > > > tgl_check_pipe_fits_sagv_wm
> > > > > >   (Ville Syrjälä)
> > > > > > - Now using simple assignment for sagv_wm0 as it contains only
> > > > > >   pod types and no pointers(Ville Syrjälä)
> > > > > > - Fixed intel_can_enable_sagv not to do double duty, now it only
> > > > > >   check SAGV bits by ANDing those between local and global 
> > > > > > state.
> > > > > >   The SAGV masks are now computed after watermarks are 
> > > > > > available,
> > > > > >   in order to be able to figure out if ddb ranges are fitting 
> > > > > > nicely.
> > > > > >   (Ville Syrjälä)
> > > > > > - Now having uv_sagv_wm0 and sagv_wm0, otherwise we have wrong 
> > > > > > logic
> > > > > >   when using skl_plane_wm_level accessor, as we had previously 
> > > > > > for
> > > > > >   Gen11+ color plane and regular wm levels, so probably both
> > > > > >   has to be recalculated with additional SAGV block time for 
> > > > > > Level 0.
> > > > > > 
> > > > > > v10: - Starting to use new global state for storing pipe_sagv_mask
> > > > > > 
> > > > > > v11: - Fixed rebase conflict with recent drm-tip
> > > > > >  - Check if we really need to recalculate SAGV mask, 

[Intel-gfx] [PATCH 48/51] drm/mipi-dbi: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
Allows us to drop the drm_driver.release callback from all
drivers, and remove the mipi_dbi_release() function.

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Acked-by: Sam Ravnborg 
Cc: Laurent Pinchart 
Reviewed-by: Noralf Trønnes  (v2)
Tested-by: Noralf Trønnes 
Signed-off-by: Daniel Vetter 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Cc: Thomas Zimmermann 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Eric Anholt 
Cc: David Lechner 
Cc: Kamlesh Gurudasani 
Cc: "Noralf Trønnes" 
Cc: Sam Ravnborg 
---
 drivers/gpu/drm/drm_mipi_dbi.c  | 18 +-
 drivers/gpu/drm/tiny/hx8357d.c  |  1 -
 drivers/gpu/drm/tiny/ili9225.c  |  1 -
 drivers/gpu/drm/tiny/ili9341.c  |  1 -
 drivers/gpu/drm/tiny/ili9486.c  |  1 -
 drivers/gpu/drm/tiny/mi0283qt.c |  1 -
 drivers/gpu/drm/tiny/st7586.c   |  1 -
 drivers/gpu/drm/tiny/st7735r.c  |  1 -
 include/drm/drm_mipi_dbi.h  |  1 -
 9 files changed, 1 insertion(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
index bef93191882c..bb27c82757f1 100644
--- a/drivers/gpu/drm/drm_mipi_dbi.c
+++ b/drivers/gpu/drm/drm_mipi_dbi.c
@@ -511,7 +511,7 @@ int mipi_dbi_dev_init_with_formats(struct mipi_dbi_dev 
*dbidev,
if (!dbidev->dbi.command)
return -EINVAL;
 
-   ret = drm_mode_config_init(drm);
+   ret = drmm_mode_config_init(drm);
if (ret)
return ret;
 
@@ -583,22 +583,6 @@ int mipi_dbi_dev_init(struct mipi_dbi_dev *dbidev,
 }
 EXPORT_SYMBOL(mipi_dbi_dev_init);
 
-/**
- * mipi_dbi_release - DRM driver release helper
- * @drm: DRM device
- *
- * This function finalizes and frees _dbi.
- *
- * Drivers can use this as their _driver->release callback.
- */
-void mipi_dbi_release(struct drm_device *drm)
-{
-   DRM_DEBUG_DRIVER("\n");
-
-   drm_mode_config_cleanup(drm);
-}
-EXPORT_SYMBOL(mipi_dbi_release);
-
 /**
  * mipi_dbi_hw_reset - Hardware reset of controller
  * @dbi: MIPI DBI structure
diff --git a/drivers/gpu/drm/tiny/hx8357d.c b/drivers/gpu/drm/tiny/hx8357d.c
index c88b84366dc5..af7f3d10aac3 100644
--- a/drivers/gpu/drm/tiny/hx8357d.c
+++ b/drivers/gpu/drm/tiny/hx8357d.c
@@ -196,7 +196,6 @@ DEFINE_DRM_GEM_CMA_FOPS(hx8357d_fops);
 static struct drm_driver hx8357d_driver = {
.driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
.fops   = _fops,
-   .release= mipi_dbi_release,
DRM_GEM_CMA_VMAP_DRIVER_OPS,
.debugfs_init   = mipi_dbi_debugfs_init,
.name   = "hx8357d",
diff --git a/drivers/gpu/drm/tiny/ili9225.c b/drivers/gpu/drm/tiny/ili9225.c
index fa998a16026c..118477af4491 100644
--- a/drivers/gpu/drm/tiny/ili9225.c
+++ b/drivers/gpu/drm/tiny/ili9225.c
@@ -346,7 +346,6 @@ DEFINE_DRM_GEM_CMA_FOPS(ili9225_fops);
 static struct drm_driver ili9225_driver = {
.driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
.fops   = _fops,
-   .release= mipi_dbi_release,
DRM_GEM_CMA_VMAP_DRIVER_OPS,
.name   = "ili9225",
.desc   = "Ilitek ILI9225",
diff --git a/drivers/gpu/drm/tiny/ili9341.c b/drivers/gpu/drm/tiny/ili9341.c
index 945e15169866..e152de369019 100644
--- a/drivers/gpu/drm/tiny/ili9341.c
+++ b/drivers/gpu/drm/tiny/ili9341.c
@@ -152,7 +152,6 @@ DEFINE_DRM_GEM_CMA_FOPS(ili9341_fops);
 static struct drm_driver ili9341_driver = {
.driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
.fops   = _fops,
-   .release= mipi_dbi_release,
DRM_GEM_CMA_VMAP_DRIVER_OPS,
.debugfs_init   = mipi_dbi_debugfs_init,
.name   = "ili9341",
diff --git a/drivers/gpu/drm/tiny/ili9486.c b/drivers/gpu/drm/tiny/ili9486.c
index bf29b225d23a..c4079bf9e2c8 100644
--- a/drivers/gpu/drm/tiny/ili9486.c
+++ b/drivers/gpu/drm/tiny/ili9486.c
@@ -165,7 +165,6 @@ DEFINE_DRM_GEM_CMA_FOPS(ili9486_fops);
 static struct drm_driver ili9486_driver = {
.driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
.fops   = _fops,
-   .release= mipi_dbi_release,
DRM_GEM_CMA_VMAP_DRIVER_OPS,
.debugfs_init   = mipi_dbi_debugfs_init,
.name   = "ili9486",
diff --git a/drivers/gpu/drm/tiny/mi0283qt.c b/drivers/gpu/drm/tiny/mi0283qt.c
index b8c973bc2347..decaf57053ff 100644
--- a/drivers/gpu/drm/tiny/mi0283qt.c
+++ b/drivers/gpu/drm/tiny/mi0283qt.c
@@ -156,7 +156,6 @@ DEFINE_DRM_GEM_CMA_FOPS(mi0283qt_fops);
 static 

[Intel-gfx] [PATCH 51/51] drm: Add docs for managed resources

2020-03-23 Thread Daniel Vetter
All collected together to provide a consistent story in one patch,
instead of the somewhat bumpy refactor-evolution leading to this.

Also some thoughts on what the next steps could be:

- Create a macro called devm_drm_dev_alloc() which essentially wraps
  the kzalloc(); devm_drm_dev_init(); drmm_add_final_kfree() combo.
  Needs to be a macro since we'll have to do some typeof trickery and
  casting to make this fully generic for all drivers that embed struct
  drm_device into their own thing.

- A lot of the simple drivers now have essentially just
  drm_dev_unplug(); drm_atomic_helper_shutdown(); as their
  $bus_driver->remove hook. We could create a devm_mode_config_reset
  which sets drm_atomic_helper_shutdown as it's cleanup action, and a
  devm_drm_dev_register with drm_dev_unplug as it's cleanup action,
  and simple drivers wouldn't have a need for a ->remove function at
  all, and we could delete them.

- For more complicated drivers we need drmm_ versions of a _lot_ more
  things. All the userspace visible objects (crtc, plane, encoder,
  crtc), anything else hanging of those (maybe a drmm_get_edid, at
  least for panels and other built-in stuff).

Also some more thoughts on why we're not reusing devm_ with maybe a
fake struct device embedded into the drm_device (we can't use the
kdev, since that's in each drm_minor).

- Code review gets extremely tricky, since every time you see a devm_
  you need to carefully check whether the fake device (with the
  drm_device lifetim) or the real device (with the lifetim of the
  underlying physical device and driver binding) are used. That's not
  going to help at all, and we have enormous amounts of drivers who
  use devm_ where they really shouldn't. Having different types makes
  sure the compiler type checks this for us and ensures correctness.

- The set of functions are very much non-overlapping. E.g.
  devm_ioremap makes total sense, drmm_ioremap has the wrong lifetime,
  since hw resources need to be cleaned out at driver unbind and wont
  outlive that like a drm_device. Similar, but other way round for
  drmm_connector_init (which is the only correct version, devm_ for
  drm_connector is just buggy). Simply not having the wrong version
  again prevents bugs.

Finally I guess this opens a huge todo for all the drivers. I'm
semi-tempted to do a tree-wide s/devm_kzalloc/drmm_kzalloc/ since most
likely that'll fix an enormous amount of bugs and most likely not
cause any issues at all (aside from maybe holding onto memory slightly
too long).

v2:
- Doc improvements from Laurent.
- Also add kerneldoc for the new drmm_add_action_or_reset.

v3:
- Remove kerneldoc for drmm_remove_action.

Reviewed-by: Sam Ravnborg 
Cc: Sam Ravnborg 
Cc: Jonathan Corbet 
Cc: linux-...@vger.kernel.org
Cc: Laurent Pinchart 
Cc: Greg Kroah-Hartman 
Cc: "Rafael J. Wysocki" 
Signed-off-by: Daniel Vetter 

fixup docs
---
 Documentation/gpu/drm-internals.rst |  6 
 drivers/gpu/drm/drm_drv.c   | 18 --
 drivers/gpu/drm/drm_managed.c   | 53 +++
 include/drm/drm_drv.h   |  4 +++
 include/drm/drm_managed.h   | 55 +
 5 files changed, 133 insertions(+), 3 deletions(-)

diff --git a/Documentation/gpu/drm-internals.rst 
b/Documentation/gpu/drm-internals.rst
index a6b6145fda78..12272b168580 100644
--- a/Documentation/gpu/drm-internals.rst
+++ b/Documentation/gpu/drm-internals.rst
@@ -138,6 +138,12 @@ Managed Resources
 .. kernel-doc:: drivers/gpu/drm/drm_managed.c
:doc: managed resources
 
+.. kernel-doc:: drivers/gpu/drm/drm_managed.c
+   :export:
+
+.. kernel-doc:: include/drm/drm_managed.h
+   :internal:
+
 Bus-specific Device Registration and PCI Support
 
 
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index ea687c5ead15..72c90a53f946 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -258,9 +258,15 @@ void drm_minor_release(struct drm_minor *minor)
  * any other resources allocated at device initialization and drop the driver's
  * reference to _device using drm_dev_put().
  *
- * Note that the lifetime rules for _device instance has still a lot of
- * historical baggage. Hence use the reference counting provided by
- * drm_dev_get() and drm_dev_put() only carefully.
+ * Note that any allocation or resource which is visible to userspace must be
+ * released only when the final drm_dev_put() is called, and not when the
+ * driver is unbound from the underlying physical struct  Best to use
+ * _device managed resources with drmm_add_action(), drmm_kmalloc() and
+ * related functions.
+ *
+ * devres managed resources like devm_kmalloc() can only be used for resources
+ * directly related to the underlying hardware device, and only used in code
+ * paths fully protected by drm_dev_enter() and drm_dev_exit().
  *
  * Display driver example
  * ~~
@@ -604,6 +610,9 @@ static void 

[Intel-gfx] [PATCH 38/51] drm/stm: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
It's right above the drm_dev_put().

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

Aside: Another driver with a bit much devm_kzalloc, which should
probably use drmm_kzalloc instead ...

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Acked-by: Sam Ravnborg 
Acked-by: Philippe Cornu 
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
Cc: Yannick Fertre 
Cc: Philippe Cornu 
Cc: Benjamin Gaignard 
Cc: Vincent Abriou 
Cc: Maxime Coquelin 
Cc: Alexandre Torgue 
Cc: linux-st...@st-md-mailman.stormreply.com
Cc: linux-arm-ker...@lists.infradead.org
---
 drivers/gpu/drm/stm/drv.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c
index ea9fcbdc68b3..0f85dd86cafa 100644
--- a/drivers/gpu/drm/stm/drv.c
+++ b/drivers/gpu/drm/stm/drv.c
@@ -88,7 +88,9 @@ static int drv_load(struct drm_device *ddev)
 
ddev->dev_private = (void *)ldev;
 
-   drm_mode_config_init(ddev);
+   ret = drmm_mode_config_init(ddev);
+   if (ret)
+   return ret;
 
/*
 * set max width and height as default value.
@@ -103,7 +105,7 @@ static int drv_load(struct drm_device *ddev)
 
ret = ltdc_load(ddev);
if (ret)
-   goto err;
+   return ret;
 
drm_mode_config_reset(ddev);
drm_kms_helper_poll_init(ddev);
@@ -111,9 +113,6 @@ static int drv_load(struct drm_device *ddev)
platform_set_drvdata(pdev, ddev);
 
return 0;
-err:
-   drm_mode_config_cleanup(ddev);
-   return ret;
 }
 
 static void drv_unload(struct drm_device *ddev)
@@ -122,7 +121,6 @@ static void drv_unload(struct drm_device *ddev)
 
drm_kms_helper_poll_fini(ddev);
ltdc_unload(ddev);
-   drm_mode_config_cleanup(ddev);
 }
 
 static __maybe_unused int drv_suspend(struct device *dev)
-- 
2.25.1

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


[Intel-gfx] [PATCH 49/51] drm/udl: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
It's right above the drm_dev_put().

This allows us to delete a bit of onion unwinding in
udl_modeset_init().

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Acked-by: Sam Ravnborg 
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
Cc: Dave Airlie 
Cc: Sean Paul 
Cc: Daniel Vetter 
Cc: Thomas Zimmermann 
Cc: Emil Velikov 
Cc: Gerd Hoffmann 
Cc: "Noralf Trønnes" 
Cc: Thomas Gleixner 
Cc: Sam Ravnborg 
---
 drivers/gpu/drm/udl/udl_drv.c |  1 -
 drivers/gpu/drm/udl/udl_drv.h |  1 -
 drivers/gpu/drm/udl/udl_modeset.c | 21 ++---
 3 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 8b78c356beb5..b447fb053e78 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -37,7 +37,6 @@ DEFINE_DRM_GEM_FOPS(udl_driver_fops);
 static void udl_driver_release(struct drm_device *dev)
 {
udl_fini(dev);
-   udl_modeset_cleanup(dev);
 }
 
 static struct drm_driver driver = {
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index e67227c44cc4..1de7eb1b6aac 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -68,7 +68,6 @@ struct udl_device {
 
 /* modeset */
 int udl_modeset_init(struct drm_device *dev);
-void udl_modeset_cleanup(struct drm_device *dev);
 struct drm_connector *udl_connector_init(struct drm_device *dev);
 
 struct urb *udl_get_urb(struct drm_device *dev);
diff --git a/drivers/gpu/drm/udl/udl_modeset.c 
b/drivers/gpu/drm/udl/udl_modeset.c
index d59ebac70b15..8cad01f3d163 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -468,7 +468,9 @@ int udl_modeset_init(struct drm_device *dev)
struct drm_connector *connector;
int ret;
 
-   drm_mode_config_init(dev);
+   ret = drmm_mode_config_init(dev);
+   if (ret)
+   return ret;
 
dev->mode_config.min_width = 640;
dev->mode_config.min_height = 480;
@@ -482,10 +484,8 @@ int udl_modeset_init(struct drm_device *dev)
dev->mode_config.funcs = _mode_funcs;
 
connector = udl_connector_init(dev);
-   if (IS_ERR(connector)) {
-   ret = PTR_ERR(connector);
-   goto err_drm_mode_config_cleanup;
-   }
+   if (IS_ERR(connector))
+   return PTR_ERR(connector);
 
format_count = ARRAY_SIZE(udl_simple_display_pipe_formats);
 
@@ -494,18 +494,9 @@ int udl_modeset_init(struct drm_device *dev)
   udl_simple_display_pipe_formats,
   format_count, NULL, connector);
if (ret)
-   goto err_drm_mode_config_cleanup;
+   return ret;
 
drm_mode_config_reset(dev);
 
return 0;
-
-err_drm_mode_config_cleanup:
-   drm_mode_config_cleanup(dev);
-   return ret;
-}
-
-void udl_modeset_cleanup(struct drm_device *dev)
-{
-   drm_mode_config_cleanup(dev);
 }
-- 
2.25.1

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


[Intel-gfx] [PATCH 47/51] drm/mipi-dbi: Move drm_mode_config_init into mipi library

2020-03-23 Thread Daniel Vetter
7/7 drivers agree that's the right choice, let's do this.

This avoids duplicating the same old error checking code over all 7
drivers, which is the motivation here.

Acked-by: Sam Ravnborg 
Reviewed-by: Noralf Trønnes 
Tested-by: Noralf Trønnes 
Signed-off-by: Daniel Vetter 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Cc: Thomas Zimmermann 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Eric Anholt 
Cc: David Lechner 
Cc: Kamlesh Gurudasani 
Cc: "Noralf Trønnes" 
Cc: Sam Ravnborg 
---
 drivers/gpu/drm/drm_mipi_dbi.c  | 4 
 drivers/gpu/drm/tiny/hx8357d.c  | 2 --
 drivers/gpu/drm/tiny/ili9225.c  | 2 --
 drivers/gpu/drm/tiny/ili9341.c  | 2 --
 drivers/gpu/drm/tiny/ili9486.c  | 2 --
 drivers/gpu/drm/tiny/mi0283qt.c | 2 --
 drivers/gpu/drm/tiny/st7586.c   | 2 --
 drivers/gpu/drm/tiny/st7735r.c  | 2 --
 8 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
index 44de8502a472..bef93191882c 100644
--- a/drivers/gpu/drm/drm_mipi_dbi.c
+++ b/drivers/gpu/drm/drm_mipi_dbi.c
@@ -511,6 +511,10 @@ int mipi_dbi_dev_init_with_formats(struct mipi_dbi_dev 
*dbidev,
if (!dbidev->dbi.command)
return -EINVAL;
 
+   ret = drm_mode_config_init(drm);
+   if (ret)
+   return ret;
+
dbidev->tx_buf = devm_kmalloc(drm->dev, tx_buf_size, GFP_KERNEL);
if (!dbidev->tx_buf)
return -ENOMEM;
diff --git a/drivers/gpu/drm/tiny/hx8357d.c b/drivers/gpu/drm/tiny/hx8357d.c
index 42bc5dadcb1c..c88b84366dc5 100644
--- a/drivers/gpu/drm/tiny/hx8357d.c
+++ b/drivers/gpu/drm/tiny/hx8357d.c
@@ -239,8 +239,6 @@ static int hx8357d_probe(struct spi_device *spi)
}
drmm_add_final_kfree(drm, dbidev);
 
-   drm_mode_config_init(drm);
-
dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW);
if (IS_ERR(dc)) {
DRM_DEV_ERROR(dev, "Failed to get gpio 'dc'\n");
diff --git a/drivers/gpu/drm/tiny/ili9225.c b/drivers/gpu/drm/tiny/ili9225.c
index aae88dc5b3f7..fa998a16026c 100644
--- a/drivers/gpu/drm/tiny/ili9225.c
+++ b/drivers/gpu/drm/tiny/ili9225.c
@@ -390,8 +390,6 @@ static int ili9225_probe(struct spi_device *spi)
}
drmm_add_final_kfree(drm, dbidev);
 
-   drm_mode_config_init(drm);
-
dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(dbi->reset)) {
DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n");
diff --git a/drivers/gpu/drm/tiny/ili9341.c b/drivers/gpu/drm/tiny/ili9341.c
index 7d40cb4ff72b..945e15169866 100644
--- a/drivers/gpu/drm/tiny/ili9341.c
+++ b/drivers/gpu/drm/tiny/ili9341.c
@@ -197,8 +197,6 @@ static int ili9341_probe(struct spi_device *spi)
}
drmm_add_final_kfree(drm, dbidev);
 
-   drm_mode_config_init(drm);
-
dbi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(dbi->reset)) {
DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n");
diff --git a/drivers/gpu/drm/tiny/ili9486.c b/drivers/gpu/drm/tiny/ili9486.c
index 9515eed2625c..bf29b225d23a 100644
--- a/drivers/gpu/drm/tiny/ili9486.c
+++ b/drivers/gpu/drm/tiny/ili9486.c
@@ -211,8 +211,6 @@ static int ili9486_probe(struct spi_device *spi)
}
drmm_add_final_kfree(drm, dbidev);
 
-   drm_mode_config_init(drm);
-
dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(dbi->reset)) {
DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n");
diff --git a/drivers/gpu/drm/tiny/mi0283qt.c b/drivers/gpu/drm/tiny/mi0283qt.c
index 8555a56bce8c..b8c973bc2347 100644
--- a/drivers/gpu/drm/tiny/mi0283qt.c
+++ b/drivers/gpu/drm/tiny/mi0283qt.c
@@ -201,8 +201,6 @@ static int mi0283qt_probe(struct spi_device *spi)
}
drmm_add_final_kfree(drm, dbidev);
 
-   drm_mode_config_init(drm);
-
dbi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(dbi->reset)) {
DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n");
diff --git a/drivers/gpu/drm/tiny/st7586.c b/drivers/gpu/drm/tiny/st7586.c
index 427c2561f5f4..1f1a576be93c 100644
--- a/drivers/gpu/drm/tiny/st7586.c
+++ b/drivers/gpu/drm/tiny/st7586.c
@@ -331,8 +331,6 @@ static int st7586_probe(struct spi_device *spi)
}
drmm_add_final_kfree(drm, dbidev);
 
-   drm_mode_config_init(drm);
-
bufsize = (st7586_mode.vdisplay + 2) / 3 * st7586_mode.hdisplay;
 
dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
diff --git a/drivers/gpu/drm/tiny/st7735r.c b/drivers/gpu/drm/tiny/st7735r.c
index b447235c3d47..0f48a5a2d3d7 100644
--- a/drivers/gpu/drm/tiny/st7735r.c
+++ b/drivers/gpu/drm/tiny/st7735r.c
@@ -212,8 +212,6 @@ static int st7735r_probe(struct spi_device *spi)
}
drmm_add_final_kfree(drm, dbidev);
 
-   drm_mode_config_init(drm);
-
dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(dbi->reset)) {

[Intel-gfx] [PATCH 43/51] drm/gm12u320: Use devm_drm_dev_init

2020-03-23 Thread Daniel Vetter
Only drops the drm_dev_put, but hey a few lines!

Reviewed-by: Hans de Goede 
Signed-off-by: Daniel Vetter 
Cc: Hans de Goede 
Cc: "Noralf Trønnes" 
---
 drivers/gpu/drm/tiny/gm12u320.c | 19 +++
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index 3349f3c2a765..9fb579fc3412 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -678,7 +678,7 @@ static int gm12u320_usb_probe(struct usb_interface 
*interface,
init_waitqueue_head(>fb_update.waitq);
 
dev = >dev;
-   ret = drm_dev_init(dev, _drm_driver, >dev);
+   ret = devm_drm_dev_init(>dev, dev, _drm_driver);
if (ret) {
kfree(gm12u320);
return ret;
@@ -688,7 +688,7 @@ static int gm12u320_usb_probe(struct usb_interface 
*interface,
 
ret = drmm_mode_config_init(dev);
if (ret)
-   goto err_put;
+   return ret;
 
dev->mode_config.min_width = GM12U320_USER_WIDTH;
dev->mode_config.max_width = GM12U320_USER_WIDTH;
@@ -698,15 +698,15 @@ static int gm12u320_usb_probe(struct usb_interface 
*interface,
 
ret = gm12u320_usb_alloc(gm12u320);
if (ret)
-   goto err_put;
+   return ret;
 
ret = gm12u320_set_ecomode(gm12u320);
if (ret)
-   goto err_put;
+   return ret;
 
ret = gm12u320_conn_init(gm12u320);
if (ret)
-   goto err_put;
+   return ret;
 
ret = drm_simple_display_pipe_init(>dev,
   >pipe,
@@ -716,22 +716,18 @@ static int gm12u320_usb_probe(struct usb_interface 
*interface,
   gm12u320_pipe_modifiers,
   >conn);
if (ret)
-   goto err_put;
+   return ret;
 
drm_mode_config_reset(dev);
 
usb_set_intfdata(interface, dev);
ret = drm_dev_register(dev, 0);
if (ret)
-   goto err_put;
+   return ret;
 
drm_fbdev_generic_setup(dev, 0);
 
return 0;
-
-err_put:
-   drm_dev_put(dev);
-   return ret;
 }
 
 static void gm12u320_usb_disconnect(struct usb_interface *interface)
@@ -741,7 +737,6 @@ static void gm12u320_usb_disconnect(struct usb_interface 
*interface)
 
gm12u320_stop_fb_update(gm12u320);
drm_dev_unplug(dev);
-   drm_dev_put(dev);
 }
 
 static __maybe_unused int gm12u320_suspend(struct usb_interface *interface,
-- 
2.25.1

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


[Intel-gfx] [PATCH 44/51] drm/gm12u320: Use helpers for shutdown/suspend/resume

2020-03-23 Thread Daniel Vetter
Also there's a race in the disconnect implemenation. First shut
down, then unplug, leaves a window where userspace could sneak
in and restart the entire machinery.

With this we can also delete the very un-atomic global pipe_enabled
tracking.

Reviewed-by: Hans de Goede 
Signed-off-by: Daniel Vetter 
Cc: Hans de Goede 
Cc: "Noralf Trønnes" 
---
 drivers/gpu/drm/tiny/gm12u320.c | 16 +++-
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index 9fb579fc3412..9627cbc3ec64 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -88,7 +88,6 @@ struct gm12u320_device {
struct usb_device   *udev;
unsigned char   *cmd_buf;
unsigned char   *data_buf[GM12U320_BLOCK_COUNT];
-   bool pipe_enabled;
struct {
bool run;
struct workqueue_struct *workq;
@@ -589,7 +588,6 @@ static void gm12u320_pipe_enable(struct 
drm_simple_display_pipe *pipe,
 
gm12u320_fb_mark_dirty(plane_state->fb, );
gm12u320_start_fb_update(gm12u320);
-   gm12u320->pipe_enabled = true;
 }
 
 static void gm12u320_pipe_disable(struct drm_simple_display_pipe *pipe)
@@ -597,7 +595,6 @@ static void gm12u320_pipe_disable(struct 
drm_simple_display_pipe *pipe)
struct gm12u320_device *gm12u320 = pipe->crtc.dev->dev_private;
 
gm12u320_stop_fb_update(gm12u320);
-   gm12u320->pipe_enabled = false;
 }
 
 static void gm12u320_pipe_update(struct drm_simple_display_pipe *pipe,
@@ -733,22 +730,17 @@ static int gm12u320_usb_probe(struct usb_interface 
*interface,
 static void gm12u320_usb_disconnect(struct usb_interface *interface)
 {
struct drm_device *dev = usb_get_intfdata(interface);
-   struct gm12u320_device *gm12u320 = dev->dev_private;
 
-   gm12u320_stop_fb_update(gm12u320);
drm_dev_unplug(dev);
+   drm_atomic_helper_shutdown(dev);
 }
 
 static __maybe_unused int gm12u320_suspend(struct usb_interface *interface,
   pm_message_t message)
 {
struct drm_device *dev = usb_get_intfdata(interface);
-   struct gm12u320_device *gm12u320 = dev->dev_private;
 
-   if (gm12u320->pipe_enabled)
-   gm12u320_stop_fb_update(gm12u320);
-
-   return 0;
+   return drm_mode_config_helper_suspend(dev);
 }
 
 static __maybe_unused int gm12u320_resume(struct usb_interface *interface)
@@ -757,10 +749,8 @@ static __maybe_unused int gm12u320_resume(struct 
usb_interface *interface)
struct gm12u320_device *gm12u320 = dev->dev_private;
 
gm12u320_set_ecomode(gm12u320);
-   if (gm12u320->pipe_enabled)
-   gm12u320_start_fb_update(gm12u320);
 
-   return 0;
+   return drm_mode_config_helper_resume(dev);
 }
 
 static const struct usb_device_id id_table[] = {
-- 
2.25.1

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


[Intel-gfx] [PATCH 50/51] drm/udl: drop drm_driver.release hook

2020-03-23 Thread Daniel Vetter
There's only two functions called from that:
drm_kms_helper_poll_fini() and udl_free_urb_list(). Both of these are
also called from the ubs_driver->disconnect hook, so entirely
pointless to do the same again in the ->release hook.

Furthermore by the time we clean up the drm_driver we really shouldn't
be touching hardware anymore, so stopping the poll worker and freeing
the urb allocations in ->disconnect is the right thing to do.

Now disconnect still cleans things up before unregistering the driver,
but that's a different issue.

v2: Use _fini, not _disable in unplug, motivated by discussions with
Thomas. _disable/_enable are for suspend/resume.

Acked-by: Thomas Zimmermann 
Signed-off-by: Daniel Vetter 
Cc: Dave Airlie 
Cc: Sean Paul 
Cc: Daniel Vetter 
Cc: Thomas Zimmermann 
Cc: Emil Velikov 
Cc: Gerd Hoffmann 
Cc: "Noralf Trønnes" 
Cc: Sam Ravnborg 
Cc: Thomas Gleixner 
Cc: Alex Deucher 
---
 drivers/gpu/drm/udl/udl_drv.c  |  8 +---
 drivers/gpu/drm/udl/udl_drv.h  |  1 -
 drivers/gpu/drm/udl/udl_main.c | 10 --
 3 files changed, 1 insertion(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index b447fb053e78..1ce2d865c36d 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -34,14 +34,8 @@ static int udl_usb_resume(struct usb_interface *interface)
 
 DEFINE_DRM_GEM_FOPS(udl_driver_fops);
 
-static void udl_driver_release(struct drm_device *dev)
-{
-   udl_fini(dev);
-}
-
 static struct drm_driver driver = {
.driver_features = DRIVER_ATOMIC | DRIVER_GEM | DRIVER_MODESET,
-   .release = udl_driver_release,
 
/* gem hooks */
.gem_create_object = udl_driver_gem_create_object,
@@ -120,7 +114,7 @@ static void udl_usb_disconnect(struct usb_interface 
*interface)
 {
struct drm_device *dev = usb_get_intfdata(interface);
 
-   drm_kms_helper_poll_disable(dev);
+   drm_kms_helper_poll_fini(dev);
udl_drop_usb(dev);
drm_dev_unplug(dev);
drm_dev_put(dev);
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index 1de7eb1b6aac..2642f94a63fc 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -76,7 +76,6 @@ int udl_submit_urb(struct drm_device *dev, struct urb *urb, 
size_t len);
 void udl_urb_completion(struct urb *urb);
 
 int udl_init(struct udl_device *udl);
-void udl_fini(struct drm_device *dev);
 
 int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr,
 const char *front, char **urb_buf_ptr,
diff --git a/drivers/gpu/drm/udl/udl_main.c b/drivers/gpu/drm/udl/udl_main.c
index 538718919916..f5d27f2a5654 100644
--- a/drivers/gpu/drm/udl/udl_main.c
+++ b/drivers/gpu/drm/udl/udl_main.c
@@ -351,13 +351,3 @@ int udl_drop_usb(struct drm_device *dev)
udl_free_urb_list(dev);
return 0;
 }
-
-void udl_fini(struct drm_device *dev)
-{
-   struct udl_device *udl = to_udl(dev);
-
-   drm_kms_helper_poll_fini(dev);
-
-   if (udl->urbs.count)
-   udl_free_urb_list(dev);
-}
-- 
2.25.1

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


[Intel-gfx] [PATCH 46/51] drm/repaper: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
Allows us to drop the drm_driver.release callback.

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)
I also noticed that I've failed to add the error checking,
__must_check caught that.

Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Cc: Laurent Pinchart 
Reviewed-by: Noralf Trønnes  (v2)
Signed-off-by: Daniel Vetter 
Cc: "Noralf Trønnes" 
---
 drivers/gpu/drm/tiny/repaper.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/repaper.c b/drivers/gpu/drm/tiny/repaper.c
index 4741ff670ec9..862c3ee6055d 100644
--- a/drivers/gpu/drm/tiny/repaper.c
+++ b/drivers/gpu/drm/tiny/repaper.c
@@ -909,13 +909,6 @@ static const struct drm_mode_config_funcs 
repaper_mode_config_funcs = {
.atomic_commit = drm_atomic_helper_commit,
 };
 
-static void repaper_release(struct drm_device *drm)
-{
-   DRM_DEBUG_DRIVER("\n");
-
-   drm_mode_config_cleanup(drm);
-}
-
 static const uint32_t repaper_formats[] = {
DRM_FORMAT_XRGB,
 };
@@ -953,7 +946,6 @@ DEFINE_DRM_GEM_CMA_FOPS(repaper_fops);
 static struct drm_driver repaper_driver = {
.driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
.fops   = _fops,
-   .release= repaper_release,
DRM_GEM_CMA_VMAP_DRIVER_OPS,
.name   = "repaper",
.desc   = "Pervasive Displays RePaper e-ink panels",
@@ -1023,7 +1015,9 @@ static int repaper_probe(struct spi_device *spi)
}
drmm_add_final_kfree(drm, epd);
 
-   drm_mode_config_init(drm);
+   ret = drmm_mode_config_init(drm);
+   if (ret)
+   return ret;
drm->mode_config.funcs = _mode_config_funcs;
 
epd->spi = spi;
-- 
2.25.1

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


[Intel-gfx] [PATCH 42/51] drm/gm12u320: More drmm_

2020-03-23 Thread Daniel Vetter
The drm_mode_config_cleanup call we can drop, and all the allocations
we can switch over to drmm_kzalloc. Unfortunately the work queue is
still present, so can't get rid of the drm_driver->release function
outright.

v2: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Reviewed-by: Hans de Goede  (v1)
Signed-off-by: Daniel Vetter 
Cc: Hans de Goede 
Cc: "Noralf Trønnes" 
---
 drivers/gpu/drm/tiny/gm12u320.c | 18 +++---
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index 3928f69bbd3d..3349f3c2a765 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -160,7 +160,7 @@ static int gm12u320_usb_alloc(struct gm12u320_device 
*gm12u320)
int i, block_size;
const char *hdr;
 
-   gm12u320->cmd_buf = kmalloc(CMD_SIZE, GFP_KERNEL);
+   gm12u320->cmd_buf = drmm_kmalloc(>dev, CMD_SIZE, GFP_KERNEL);
if (!gm12u320->cmd_buf)
return -ENOMEM;
 
@@ -173,7 +173,8 @@ static int gm12u320_usb_alloc(struct gm12u320_device 
*gm12u320)
hdr = data_block_header;
}
 
-   gm12u320->data_buf[i] = kzalloc(block_size, GFP_KERNEL);
+   gm12u320->data_buf[i] = drmm_kzalloc(>dev,
+block_size, GFP_KERNEL);
if (!gm12u320->data_buf[i])
return -ENOMEM;
 
@@ -192,15 +193,8 @@ static int gm12u320_usb_alloc(struct gm12u320_device 
*gm12u320)
 
 static void gm12u320_usb_free(struct gm12u320_device *gm12u320)
 {
-   int i;
-
if (gm12u320->fb_update.workq)
destroy_workqueue(gm12u320->fb_update.workq);
-
-   for (i = 0; i < GM12U320_BLOCK_COUNT; i++)
-   kfree(gm12u320->data_buf[i]);
-
-   kfree(gm12u320->cmd_buf);
 }
 
 static int gm12u320_misc_request(struct gm12u320_device *gm12u320,
@@ -636,7 +630,6 @@ static void gm12u320_driver_release(struct drm_device *dev)
struct gm12u320_device *gm12u320 = dev->dev_private;
 
gm12u320_usb_free(gm12u320);
-   drm_mode_config_cleanup(dev);
 }
 
 DEFINE_DRM_GEM_FOPS(gm12u320_fops);
@@ -693,7 +686,10 @@ static int gm12u320_usb_probe(struct usb_interface 
*interface,
dev->dev_private = gm12u320;
drmm_add_final_kfree(dev, gm12u320);
 
-   drm_mode_config_init(dev);
+   ret = drmm_mode_config_init(dev);
+   if (ret)
+   goto err_put;
+
dev->mode_config.min_width = GM12U320_USER_WIDTH;
dev->mode_config.max_width = GM12U320_USER_WIDTH;
dev->mode_config.min_height = GM12U320_HEIGHT;
-- 
2.25.1

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


[Intel-gfx] [PATCH 41/51] drm/tidss: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
It's right above the drm_dev_put().

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

Aside: Another driver with a bit much devm_kzalloc, which should
probably use drmm_kzalloc instead ...

I'm pretty sure this one blows up already under KASAN because it's
using devm_drm_dev_init, and later on devm_kzalloc. Hence the memory
will get freed before the final drm_dev_put (all from the devres
code), but the cleanup in that final drm_dev_put will access the just
freed memory.

Unfortunately fixing this properly needs slightly more work, namely
drmm_ versions for all the drm objects (planes, crtc, ...), so that
the cleanup actually happens before even drmm_kzalloc would release
the underlying memory. Not quite there yet.

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Acked-by: Jyri Sarha 
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
Cc: Jyri Sarha 
Cc: Tomi Valkeinen 
---
 drivers/gpu/drm/tidss/tidss_drv.c |  4 
 drivers/gpu/drm/tidss/tidss_kms.c | 19 +--
 drivers/gpu/drm/tidss/tidss_kms.h |  1 -
 3 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/tidss/tidss_drv.c 
b/drivers/gpu/drm/tidss/tidss_drv.c
index 460d5e9d0cf4..ad449d104306 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.c
+++ b/drivers/gpu/drm/tidss/tidss_drv.c
@@ -103,11 +103,7 @@ static const struct dev_pm_ops tidss_pm_ops = {
 
 static void tidss_release(struct drm_device *ddev)
 {
-   struct tidss_device *tidss = ddev->dev_private;
-
drm_kms_helper_poll_fini(ddev);
-
-   tidss_modeset_cleanup(tidss);
 }
 
 DEFINE_DRM_GEM_CMA_FOPS(tidss_fops);
diff --git a/drivers/gpu/drm/tidss/tidss_kms.c 
b/drivers/gpu/drm/tidss/tidss_kms.c
index 7d419960b030..4bd339a467a4 100644
--- a/drivers/gpu/drm/tidss/tidss_kms.c
+++ b/drivers/gpu/drm/tidss/tidss_kms.c
@@ -258,7 +258,9 @@ int tidss_modeset_init(struct tidss_device *tidss)
 
dev_dbg(tidss->dev, "%s\n", __func__);
 
-   drm_mode_config_init(ddev);
+   ret = drmm_mode_config_init(ddev);
+   if (ret)
+   return ret;
 
ddev->mode_config.min_width = 8;
ddev->mode_config.min_height = 8;
@@ -270,11 +272,11 @@ int tidss_modeset_init(struct tidss_device *tidss)
 
ret = tidss_dispc_modeset_init(tidss);
if (ret)
-   goto err_mode_config_cleanup;
+   return ret;
 
ret = drm_vblank_init(ddev, tidss->num_crtcs);
if (ret)
-   goto err_mode_config_cleanup;
+   return ret;
 
/* Start with vertical blanking interrupt reporting disabled. */
for (i = 0; i < tidss->num_crtcs; ++i)
@@ -285,15 +287,4 @@ int tidss_modeset_init(struct tidss_device *tidss)
dev_dbg(tidss->dev, "%s done\n", __func__);
 
return 0;
-
-err_mode_config_cleanup:
-   drm_mode_config_cleanup(ddev);
-   return ret;
-}
-
-void tidss_modeset_cleanup(struct tidss_device *tidss)
-{
-   struct drm_device *ddev = >ddev;
-
-   drm_mode_config_cleanup(ddev);
 }
diff --git a/drivers/gpu/drm/tidss/tidss_kms.h 
b/drivers/gpu/drm/tidss/tidss_kms.h
index dda5625d0128..99aaff099f22 100644
--- a/drivers/gpu/drm/tidss/tidss_kms.h
+++ b/drivers/gpu/drm/tidss/tidss_kms.h
@@ -10,6 +10,5 @@
 struct tidss_device;
 
 int tidss_modeset_init(struct tidss_device *tidss);
-void tidss_modeset_cleanup(struct tidss_device *tidss);
 
 #endif
-- 
2.25.1

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


[Intel-gfx] [PATCH 35/51] drm/pl111: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
It's right above the drm_dev_put().

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

Aside: This driver gets its devm_ stuff all wrong wrt drm_device and
anything hanging off that. Not the only one unfortunately.

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Acked-by: Sam Ravnborg 
Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
Cc: Eric Anholt 
---
 drivers/gpu/drm/pl111/pl111_drv.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/pl111/pl111_drv.c 
b/drivers/gpu/drm/pl111/pl111_drv.c
index aa8aa8d9e405..f9ca0f3edbbb 100644
--- a/drivers/gpu/drm/pl111/pl111_drv.c
+++ b/drivers/gpu/drm/pl111/pl111_drv.c
@@ -90,10 +90,13 @@ static int pl111_modeset_init(struct drm_device *dev)
struct drm_panel *panel = NULL;
struct drm_bridge *bridge = NULL;
bool defer = false;
-   int ret = 0;
+   int ret;
int i;
 
-   drm_mode_config_init(dev);
+   ret = drmm_mode_config_init(dev);
+   if (ret)
+   return ret;
+
mode_config = >mode_config;
mode_config->funcs = _config_funcs;
mode_config->min_width = 1;
@@ -154,7 +157,7 @@ static int pl111_modeset_init(struct drm_device *dev)
DRM_MODE_CONNECTOR_Unknown);
if (IS_ERR(bridge)) {
ret = PTR_ERR(bridge);
-   goto out_config;
+   goto finish;
}
} else if (bridge) {
dev_info(dev->dev, "Using non-panel bridge\n");
@@ -197,8 +200,6 @@ static int pl111_modeset_init(struct drm_device *dev)
 out_bridge:
if (panel)
drm_panel_bridge_remove(bridge);
-out_config:
-   drm_mode_config_cleanup(dev);
 finish:
return ret;
 }
@@ -343,7 +344,6 @@ static int pl111_amba_remove(struct amba_device *amba_dev)
drm_dev_unregister(drm);
if (priv->panel)
drm_panel_bridge_remove(priv->bridge);
-   drm_mode_config_cleanup(drm);
drm_dev_put(drm);
of_reserved_mem_device_release(dev);
 
-- 
2.25.1

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


[Intel-gfx] [PATCH 29/51] drm/cirrus: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
We can even delete the drm_driver.release hook now!

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Acked-by: Gerd Hoffmann 
Cc: Sam Ravnborg 
Acked-by: Sam Ravnborg 
Cc: Thomas Zimmermann 
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
Cc: Dave Airlie 
Cc: Gerd Hoffmann 
Cc: Daniel Vetter 
Cc: "Noralf Trønnes" 
Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Cc: virtualizat...@lists.linux-foundation.org
---
 drivers/gpu/drm/cirrus/cirrus.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index a9d789a56536..bd8784ea9d64 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -510,11 +510,15 @@ static const struct drm_mode_config_funcs 
cirrus_mode_config_funcs = {
.atomic_commit = drm_atomic_helper_commit,
 };
 
-static void cirrus_mode_config_init(struct cirrus_device *cirrus)
+static int cirrus_mode_config_init(struct cirrus_device *cirrus)
 {
struct drm_device *dev = >dev;
+   int ret;
+
+   ret = drmm_mode_config_init(dev);
+   if (ret)
+   return ret;
 
-   drm_mode_config_init(dev);
dev->mode_config.min_width = 0;
dev->mode_config.min_height = 0;
dev->mode_config.max_width = CIRRUS_MAX_PITCH / 2;
@@ -522,15 +526,12 @@ static void cirrus_mode_config_init(struct cirrus_device 
*cirrus)
dev->mode_config.preferred_depth = 16;
dev->mode_config.prefer_shadow = 0;
dev->mode_config.funcs = _mode_config_funcs;
+
+   return 0;
 }
 
 /* -- */
 
-static void cirrus_release(struct drm_device *dev)
-{
-   drm_mode_config_cleanup(dev);
-}
-
 DEFINE_DRM_GEM_FOPS(cirrus_fops);
 
 static struct drm_driver cirrus_driver = {
@@ -544,7 +545,6 @@ static struct drm_driver cirrus_driver = {
 
.fops= _fops,
DRM_GEM_SHMEM_DRIVER_OPS,
-   .release = cirrus_release,
 };
 
 static int cirrus_pci_probe(struct pci_dev *pdev,
@@ -591,7 +591,9 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
if (cirrus->mmio == NULL)
goto err_unmap_vram;
 
-   cirrus_mode_config_init(cirrus);
+   ret = cirrus_mode_config_init(cirrus);
+   if (ret)
+   goto err_cleanup;
 
ret = cirrus_conn_init(cirrus);
if (ret < 0)
@@ -613,7 +615,6 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
return 0;
 
 err_cleanup:
-   drm_mode_config_cleanup(dev);
iounmap(cirrus->mmio);
 err_unmap_vram:
iounmap(cirrus->vram);
-- 
2.25.1

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


[Intel-gfx] [PATCH 26/51] drm: Manage drm_mode_config_init with drmm_

2020-03-23 Thread Daniel Vetter
drm_mode_config_cleanup is idempotent, so no harm in calling this
twice. This allows us to gradually switch drivers over by removing
explicit drm_mode_config_cleanup calls.

With this step it's now also possible that (at least for simple
drivers) automatic resource cleanup can be done correctly without a
drm_driver->release hook. Therefore allow this now in
devm_drm_dev_init().

Also with drmm_ explicit drm_driver->release hooks are kinda not the
best option: Drivers can always just register their current release
hook with drmm_add_action, but even better they could split them up to
simplify the unwinding for the driver load failure case. So deprecate
that hook to discourage future users.

v2: Fixup the example in the kerneldoc too.

v3:
- For paranoia, double check that minor->dev == dev in the release
  hook, because I botched the pointer math in the drmm library.
- Call drm_mode_config_cleanup when drmm_add_action fails, we'd be
  missing some mutex_destroy and ida_cleanup otherwise (Laurent)

v4: Add a drmm_add_action_or_reset (like devm_ has) to encapsulate this
pattern (Noralf).

v5: Fix oversight in the new drmm_add_action_or_reset macro (Noralf)

v4: Review from Sam:
- drmm_mode_config_init wrapper (also suggested by Thomas)
- improve commit message, explain better why ->relase is deprecated

v5:
- Make drmm_ the main function, with the old one as compat wrapper
  (Sam)
- Add FIXME comments to drm_mode_config_cleanup/init() that drivers
  shouldn't use these anymore.
- Move drmm_add_action_or_reset helper to an earlier patch.

Reviewed-by: Sam Ravnborg 
Cc: Laurent Pinchart 
Cc: "Noralf Trønnes" 
Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Acked-by: Noralf Trønnes 
Signed-off-by: Daniel Vetter 
---
 Documentation/gpu/drm-kms.rst |  2 +-
 drivers/gpu/drm/drm_drv.c | 23 +++
 drivers/gpu/drm/drm_mode_config.c | 23 ---
 include/drm/drm_mode_config.h | 18 +-
 4 files changed, 45 insertions(+), 21 deletions(-)

diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.rst
index 906771e03103..e1f685015807 100644
--- a/Documentation/gpu/drm-kms.rst
+++ b/Documentation/gpu/drm-kms.rst
@@ -3,7 +3,7 @@ Kernel Mode Setting (KMS)
 =
 
 Drivers must initialize the mode setting core by calling
-drm_mode_config_init() on the DRM device. The function
+drmm_mode_config_init() on the DRM device. The function
 initializes the :c:type:`struct drm_device `
 mode_config field and never fails. Once done, mode configuration must
 be setup by initializing the following fields.
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 03f5cb829957..ea687c5ead15 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -98,6 +98,8 @@ static void drm_minor_alloc_release(struct drm_device *dev, 
void *data)
struct drm_minor *minor = data;
unsigned long flags;
 
+   WARN_ON(dev != minor->dev);
+
put_device(minor->kdev);
 
spin_lock_irqsave(_minor_lock, flags);
@@ -265,8 +267,7 @@ void drm_minor_release(struct drm_minor *minor)
  *
  * The following example shows a typical structure of a DRM display driver.
  * The example focus on the probe() function and the other functions that is
- * almost always present and serves as a demonstration of devm_drm_dev_init()
- * usage with its accompanying drm_driver->release callback.
+ * almost always present and serves as a demonstration of devm_drm_dev_init().
  *
  * .. code-block:: c
  *
@@ -276,16 +277,8 @@ void drm_minor_release(struct drm_minor *minor)
  * struct clk *pclk;
  * };
  *
- * static void driver_drm_release(struct drm_device *drm)
- * {
- * struct driver_device *priv = container_of(...);
- *
- * drm_mode_config_cleanup(drm);
- * }
- *
  * static struct drm_driver driver_drm_driver = {
  * [...]
- * .release = driver_drm_release,
  * };
  *
  * static int driver_probe(struct platform_device *pdev)
@@ -310,7 +303,9 @@ void drm_minor_release(struct drm_minor *minor)
  * }
  * drmm_add_final_kfree(drm, priv);
  *
- * drm_mode_config_init(drm);
+ * ret = drmm_mode_config_init(drm);
+ * if (ret)
+ * return ret;
  *
  * priv->userspace_facing = drmm_kzalloc(..., GFP_KERNEL);
  * if (!priv->userspace_facing)
@@ -708,8 +703,7 @@ static void devm_drm_dev_init_release(void *data)
  * @driver: DRM driver
  *
  * Managed drm_dev_init(). The DRM device initialized with this function is
- * automatically put on driver detach using drm_dev_put(). You must supply a
- * _driver.release callback to control the finalization explicitly.
+ * automatically put on driver detach using drm_dev_put().
  *
  * RETURNS:
  * 0 on success, or error code on failure.
@@ -720,9 +714,6 @@ int devm_drm_dev_init(struct device *parent,
 {
int 

[Intel-gfx] [PATCH 28/51] drm/bochs: Drop explicit drm_mode_config_cleanup

2020-03-23 Thread Daniel Vetter
Instead rely on the automatic clean, for which we just need to check
that drm_mode_config_init succeeded. To avoid an inversion in the
cleanup we also have to move the dev_private allocation over to
drmm_kzalloc.

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Acked-by: Gerd Hoffmann 
Acked-by: Sam Ravnborg 
Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
Cc: Gerd Hoffmann 
Cc: virtualizat...@lists.linux-foundation.org
---
 drivers/gpu/drm/bochs/bochs.h |  1 -
 drivers/gpu/drm/bochs/bochs_drv.c |  6 ++
 drivers/gpu/drm/bochs/bochs_kms.c | 14 +-
 3 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h
index 917767173ee6..e5bd1d517a18 100644
--- a/drivers/gpu/drm/bochs/bochs.h
+++ b/drivers/gpu/drm/bochs/bochs.h
@@ -92,7 +92,6 @@ void bochs_mm_fini(struct bochs_device *bochs);
 
 /* bochs_kms.c */
 int bochs_kms_init(struct bochs_device *bochs);
-void bochs_kms_fini(struct bochs_device *bochs);
 
 /* bochs_fbdev.c */
 extern const struct drm_mode_config_funcs bochs_mode_funcs;
diff --git a/drivers/gpu/drm/bochs/bochs_drv.c 
b/drivers/gpu/drm/bochs/bochs_drv.c
index addb0568c1af..e18c51de1196 100644
--- a/drivers/gpu/drm/bochs/bochs_drv.c
+++ b/drivers/gpu/drm/bochs/bochs_drv.c
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 
 #include "bochs.h"
 
@@ -21,10 +22,7 @@ static void bochs_unload(struct drm_device *dev)
 {
struct bochs_device *bochs = dev->dev_private;
 
-   bochs_kms_fini(bochs);
bochs_mm_fini(bochs);
-   kfree(bochs);
-   dev->dev_private = NULL;
 }
 
 static int bochs_load(struct drm_device *dev)
@@ -32,7 +30,7 @@ static int bochs_load(struct drm_device *dev)
struct bochs_device *bochs;
int ret;
 
-   bochs = kzalloc(sizeof(*bochs), GFP_KERNEL);
+   bochs = drmm_kzalloc(dev, sizeof(*bochs), GFP_KERNEL);
if (bochs == NULL)
return -ENOMEM;
dev->dev_private = bochs;
diff --git a/drivers/gpu/drm/bochs/bochs_kms.c 
b/drivers/gpu/drm/bochs/bochs_kms.c
index e8cc8156d773..7f4bcfad87e9 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -134,7 +134,11 @@ const struct drm_mode_config_funcs bochs_mode_funcs = {
 
 int bochs_kms_init(struct bochs_device *bochs)
 {
-   drm_mode_config_init(bochs->dev);
+   int ret;
+
+   ret = drmm_mode_config_init(bochs->dev);
+   if (ret)
+   return ret;
 
bochs->dev->mode_config.max_width = 8192;
bochs->dev->mode_config.max_height = 8192;
@@ -160,11 +164,3 @@ int bochs_kms_init(struct bochs_device *bochs)
 
return 0;
 }
-
-void bochs_kms_fini(struct bochs_device *bochs)
-{
-   if (!bochs->dev->mode_config.num_connector)
-   return;
-
-   drm_mode_config_cleanup(bochs->dev);
-}
-- 
2.25.1

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


[Intel-gfx] [PATCH 45/51] drm/gm12u320: Simplify upload work

2020-03-23 Thread Daniel Vetter
Instead of having a work item that never stops (which really should be
a kthread), with a dedicated workqueue to not upset anyone else, use a
delayed work. A bunch of changes:

- We can throw out all the custom wakeup and requeue logic and state
  tracking. If we schedule the work with a 0 delay it'll get
  scheduled immediately.

- Persistent state (frame & draw_status_timeout) need to be moved out
  of the work.

- diff is bigger than the changes, biggest chunk is reindenting the
  work fn because it lost its while loop.

Lots of code deleting as consequence all over. Specifically we can
delete the drm_driver.release code now!

v2: Review from Hans:
- Use mod_delayed_work in the plane update path to make sure we do
  actually schedule immediately). In the worker we still want
  queue_delayed_work, which won't modify the timeout when the work is
  already scheduled. Which is exactly what we want if the work races
  with a plane update.
- Switch to system_long_wq, Hans says on usb2 a plane upload can take
  80 ms.

Reviewed-by: Hans de Goede 
Signed-off-by: Daniel Vetter 
Cc: Hans de Goede 
Cc: "Noralf Trønnes" 
---
 drivers/gpu/drm/tiny/gm12u320.c | 171 +---
 1 file changed, 68 insertions(+), 103 deletions(-)

diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index 9627cbc3ec64..6f0ea2827d62 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -89,13 +89,12 @@ struct gm12u320_device {
unsigned char   *cmd_buf;
unsigned char   *data_buf[GM12U320_BLOCK_COUNT];
struct {
-   bool run;
-   struct workqueue_struct *workq;
-   struct work_struct   work;
-   wait_queue_head_twaitq;
+   struct delayed_work   work;
struct mutex lock;
struct drm_framebuffer  *fb;
struct drm_rect  rect;
+   int frame;
+   int draw_status_timeout;
} fb_update;
 };
 
@@ -183,19 +182,9 @@ static int gm12u320_usb_alloc(struct gm12u320_device 
*gm12u320)
   data_block_footer, DATA_BLOCK_FOOTER_SIZE);
}
 
-   gm12u320->fb_update.workq = create_singlethread_workqueue(DRIVER_NAME);
-   if (!gm12u320->fb_update.workq)
-   return -ENOMEM;
-
return 0;
 }
 
-static void gm12u320_usb_free(struct gm12u320_device *gm12u320)
-{
-   if (gm12u320->fb_update.workq)
-   destroy_workqueue(gm12u320->fb_update.workq);
-}
-
 static int gm12u320_misc_request(struct gm12u320_device *gm12u320,
 u8 req_a, u8 req_b,
 u8 arg_a, u8 arg_b, u8 arg_c, u8 arg_d)
@@ -338,80 +327,77 @@ static void gm12u320_copy_fb_to_blocks(struct 
gm12u320_device *gm12u320)
 static void gm12u320_fb_update_work(struct work_struct *work)
 {
struct gm12u320_device *gm12u320 =
-   container_of(work, struct gm12u320_device, fb_update.work);
-   int draw_status_timeout = FIRST_FRAME_TIMEOUT;
+   container_of(to_delayed_work(work), struct gm12u320_device,
+fb_update.work);
int block, block_size, len;
-   int frame = 0;
int ret = 0;
 
-   while (gm12u320->fb_update.run) {
-   gm12u320_copy_fb_to_blocks(gm12u320);
-
-   for (block = 0; block < GM12U320_BLOCK_COUNT; block++) {
-   if (block == GM12U320_BLOCK_COUNT - 1)
-   block_size = DATA_LAST_BLOCK_SIZE;
-   else
-   block_size = DATA_BLOCK_SIZE;
-
-   /* Send data command to device */
-   memcpy(gm12u320->cmd_buf, cmd_data, CMD_SIZE);
-   gm12u320->cmd_buf[8] = block_size & 0xff;
-   gm12u320->cmd_buf[9] = block_size >> 8;
-   gm12u320->cmd_buf[20] = 0xfc - block * 4;
-   gm12u320->cmd_buf[21] = block | (frame << 7);
-
-   ret = usb_bulk_msg(gm12u320->udev,
-   usb_sndbulkpipe(gm12u320->udev, DATA_SND_EPT),
-   gm12u320->cmd_buf, CMD_SIZE, ,
-   CMD_TIMEOUT);
-   if (ret || len != CMD_SIZE)
-   goto err;
-
-   /* Send data block to device */
-   ret = usb_bulk_msg(gm12u320->udev,
-   usb_sndbulkpipe(gm12u320->udev, DATA_SND_EPT),
-   gm12u320->data_buf[block], block_size,
-   , DATA_TIMEOUT);
-   if (ret || len != block_size)
-   goto err;
-
-   /* Read status */
-   ret = 

[Intel-gfx] [PATCH 18/51] drm/: Use drmm_add_final_kfree

2020-03-23 Thread Daniel Vetter
These are the leftover drivers that didn't have a ->release hook that
needed to be updated.

Acked-by: Sam Ravnborg 
Acked-by: Liviu Dudau 
Signed-off-by: Daniel Vetter 
Cc: "James (Qian) Wang" 
Cc: Liviu Dudau 
Cc: Mihail Atanassov 
Cc: Russell King 
Cc: Hans de Goede 
---
 drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 ++
 drivers/gpu/drm/armada/armada_drv.c | 2 ++
 drivers/gpu/drm/vboxvideo/vbox_drv.c| 2 ++
 3 files changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
index 442d4656150a..16dfd5cdb66c 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -271,6 +272,7 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev 
*mdev)
err = drm_dev_init(drm, _kms_driver, mdev->dev);
if (err)
goto free_kms;
+   drmm_add_final_kfree(drm, kms);
 
drm->dev_private = mdev;
 
diff --git a/drivers/gpu/drm/armada/armada_drv.c 
b/drivers/gpu/drm/armada/armada_drv.c
index 197dca3fc84c..dd9ed71ed942 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -103,6 +104,7 @@ static int armada_drm_bind(struct device *dev)
kfree(priv);
return ret;
}
+   drmm_add_final_kfree(>drm, priv);
 
/* Remove early framebuffers */
ret = drm_fb_helper_remove_conflicting_framebuffers(NULL,
diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c 
b/drivers/gpu/drm/vboxvideo/vbox_drv.c
index 8512d970a09f..13eaae7921f5 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "vbox_drv.h"
 
@@ -54,6 +55,7 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
vbox->ddev.pdev = pdev;
vbox->ddev.dev_private = vbox;
pci_set_drvdata(pdev, vbox);
+   drmm_add_final_kfree(>ddev, vbox);
mutex_init(>hw_mutex);
 
ret = pci_enable_device(pdev);
-- 
2.25.1

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


[Intel-gfx] [PATCH 39/51] drm/shmob: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
It's right above the drm_dev_put().

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

Aside: Another driver with a bit much devm_kzalloc, which should
probably use drmm_kzalloc instead ...

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Reviewed-by: Laurent Pinchart  (v2)
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
Cc: Laurent Pinchart 
Cc: Kieran Bingham 
Cc: linux-renesas-...@vger.kernel.org
---
 drivers/gpu/drm/shmobile/shmob_drm_drv.c | 2 --
 drivers/gpu/drm/shmobile/shmob_drm_kms.c | 6 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c 
b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index b8c0930959c7..ae9d6b8d3ca8 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -192,7 +192,6 @@ static int shmob_drm_remove(struct platform_device *pdev)
 
drm_dev_unregister(ddev);
drm_kms_helper_poll_fini(ddev);
-   drm_mode_config_cleanup(ddev);
drm_irq_uninstall(ddev);
drm_dev_put(ddev);
 
@@ -288,7 +287,6 @@ static int shmob_drm_probe(struct platform_device *pdev)
drm_irq_uninstall(ddev);
 err_modeset_cleanup:
drm_kms_helper_poll_fini(ddev);
-   drm_mode_config_cleanup(ddev);
 err_free_drm_dev:
drm_dev_put(ddev);
 
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_kms.c 
b/drivers/gpu/drm/shmobile/shmob_drm_kms.c
index c51197b6fd85..7a866d6ce6bb 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_kms.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_kms.c
@@ -126,7 +126,11 @@ static const struct drm_mode_config_funcs 
shmob_drm_mode_config_funcs = {
 
 int shmob_drm_modeset_init(struct shmob_drm_device *sdev)
 {
-   drm_mode_config_init(sdev->ddev);
+   int ret;
+
+   ret = drmm_mode_config_init(sdev->ddev);
+   if (ret)
+   return ret;
 
shmob_drm_crtc_create(sdev);
shmob_drm_encoder_create(sdev);
-- 
2.25.1

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


[Intel-gfx] [PATCH 40/51] drm/mtk: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
It's right above the drm_dev_put().

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

Aside: Another driver with a bit much devm_kzalloc, which should
probably use drmm_kzalloc instead ...

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Acked-by: Sam Ravnborg 
Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index 0563c681..2eaa9080d250 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -162,7 +162,9 @@ static int mtk_drm_kms_init(struct drm_device *drm)
}
private->mutex_dev = >dev;
 
-   drm_mode_config_init(drm);
+   ret = drmm_mode_config_init(drm);
+   if (ret)
+   return ret;
 
drm->mode_config.min_width = 64;
drm->mode_config.min_height = 64;
@@ -179,7 +181,7 @@ static int mtk_drm_kms_init(struct drm_device *drm)
 
ret = component_bind_all(drm->dev, drm);
if (ret)
-   goto err_config_cleanup;
+   return ret;
 
/*
 * We currently support two fixed data streams, each optional,
@@ -255,8 +257,6 @@ static int mtk_drm_kms_init(struct drm_device *drm)
dma_dev->dma_parms = NULL;
 err_component_unbind:
component_unbind_all(drm->dev, drm);
-err_config_cleanup:
-   drm_mode_config_cleanup(drm);
 
return ret;
 }
@@ -272,7 +272,6 @@ static void mtk_drm_kms_deinit(struct drm_device *drm)
private->dma_dev->dma_parms = NULL;
 
component_unbind_all(drm->dev, drm);
-   drm_mode_config_cleanup(drm);
 }
 
 static const struct file_operations mtk_drm_fops = {
-- 
2.25.1

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


[Intel-gfx] [PATCH 32/51] drm/mcde: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
Allows us to drop the drm_driver.release callback.

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Acked-by: Sam Ravnborg 
Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Reviewed-by: Linus Walleij  (v2)
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
Cc: Linus Walleij 
---
 drivers/gpu/drm/mcde/mcde_drv.c | 22 ++
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
index a543ebf3d541..03d2e1a00810 100644
--- a/drivers/gpu/drm/mcde/mcde_drv.c
+++ b/drivers/gpu/drm/mcde/mcde_drv.c
@@ -184,13 +184,13 @@ static int mcde_modeset_init(struct drm_device *drm)
ret = drm_vblank_init(drm, 1);
if (ret) {
dev_err(drm->dev, "failed to init vblank\n");
-   goto out_config;
+   return ret;
}
 
ret = mcde_display_init(drm);
if (ret) {
dev_err(drm->dev, "failed to init display\n");
-   goto out_config;
+   return ret;
}
 
/*
@@ -204,7 +204,7 @@ static int mcde_modeset_init(struct drm_device *drm)
mcde->bridge);
if (ret) {
dev_err(drm->dev, "failed to attach display output bridge\n");
-   goto out_config;
+   return ret;
}
 
drm_mode_config_reset(drm);
@@ -212,17 +212,6 @@ static int mcde_modeset_init(struct drm_device *drm)
drm_fbdev_generic_setup(drm, 32);
 
return 0;
-
-out_config:
-   drm_mode_config_cleanup(drm);
-   return ret;
-}
-
-static void mcde_release(struct drm_device *drm)
-{
-   struct mcde *mcde = drm->dev_private;
-
-   drm_mode_config_cleanup(drm);
 }
 
 DEFINE_DRM_GEM_CMA_FOPS(drm_fops);
@@ -230,7 +219,6 @@ DEFINE_DRM_GEM_CMA_FOPS(drm_fops);
 static struct drm_driver mcde_drm_driver = {
.driver_features =
DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
-   .release = mcde_release,
.lastclose = drm_fb_helper_lastclose,
.ioctls = NULL,
.fops = _fops,
@@ -258,7 +246,9 @@ static int mcde_drm_bind(struct device *dev)
struct drm_device *drm = dev_get_drvdata(dev);
int ret;
 
-   drm_mode_config_init(drm);
+   ret = drmm_mode_config_init(drm);
+   if (ret)
+   return ret;
 
ret = component_bind_all(drm->dev, drm);
if (ret) {
-- 
2.25.1

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


[Intel-gfx] [PATCH 30/51] drm/cirrus: Fully embrace devm_

2020-03-23 Thread Daniel Vetter
With the drm_device lifetime fun cleaned up there's nothing in the way
anymore to use devm_ for everything hw releated. Do it, and in the
process, throw out the entire onion unwinding.

Acked-by: Gerd Hoffmann 
Signed-off-by: Daniel Vetter 
Cc: Dave Airlie 
Cc: Gerd Hoffmann 
Cc: Daniel Vetter 
Cc: "Noralf Trønnes" 
Cc: Emil Velikov 
Cc: Thomas Zimmermann 
Cc: virtualizat...@lists.linux-foundation.org
---
 drivers/gpu/drm/cirrus/cirrus.c | 44 +++--
 1 file changed, 14 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index bd8784ea9d64..a36269717c3b 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -558,7 +558,7 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
if (ret)
return ret;
 
-   ret = pci_enable_device(pdev);
+   ret = pcim_enable_device(pdev);
if (ret)
return ret;
 
@@ -569,39 +569,38 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
ret = -ENOMEM;
cirrus = kzalloc(sizeof(*cirrus), GFP_KERNEL);
if (cirrus == NULL)
-   goto err_pci_release;
+   return ret;
 
dev = >dev;
-   ret = drm_dev_init(dev, _driver, >dev);
+   ret = devm_drm_dev_init(>dev, dev, _driver);
if (ret) {
kfree(cirrus);
-   goto err_pci_release;
+   return ret;
}
dev->dev_private = cirrus;
drmm_add_final_kfree(dev, cirrus);
 
-   ret = -ENOMEM;
-   cirrus->vram = ioremap(pci_resource_start(pdev, 0),
-  pci_resource_len(pdev, 0));
+   cirrus->vram = devm_ioremap(>dev, pci_resource_start(pdev, 0),
+   pci_resource_len(pdev, 0));
if (cirrus->vram == NULL)
-   goto err_dev_put;
+   return -ENOMEM;
 
-   cirrus->mmio = ioremap(pci_resource_start(pdev, 1),
-  pci_resource_len(pdev, 1));
+   cirrus->mmio = devm_ioremap(>dev, pci_resource_start(pdev, 1),
+   pci_resource_len(pdev, 1));
if (cirrus->mmio == NULL)
-   goto err_unmap_vram;
+   return -ENOMEM;
 
ret = cirrus_mode_config_init(cirrus);
if (ret)
-   goto err_cleanup;
+   return ret;
 
ret = cirrus_conn_init(cirrus);
if (ret < 0)
-   goto err_cleanup;
+   return ret;
 
ret = cirrus_pipe_init(cirrus);
if (ret < 0)
-   goto err_cleanup;
+   return ret;
 
drm_mode_config_reset(dev);
 
@@ -609,33 +608,18 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
pci_set_drvdata(pdev, dev);
ret = drm_dev_register(dev, 0);
if (ret)
-   goto err_cleanup;
+   return ret;
 
drm_fbdev_generic_setup(dev, dev->mode_config.preferred_depth);
return 0;
-
-err_cleanup:
-   iounmap(cirrus->mmio);
-err_unmap_vram:
-   iounmap(cirrus->vram);
-err_dev_put:
-   drm_dev_put(dev);
-err_pci_release:
-   pci_release_regions(pdev);
-   return ret;
 }
 
 static void cirrus_pci_remove(struct pci_dev *pdev)
 {
struct drm_device *dev = pci_get_drvdata(pdev);
-   struct cirrus_device *cirrus = dev->dev_private;
 
drm_dev_unplug(dev);
drm_atomic_helper_shutdown(dev);
-   iounmap(cirrus->mmio);
-   iounmap(cirrus->vram);
-   drm_dev_put(dev);
-   pci_release_regions(pdev);
 }
 
 static const struct pci_device_id pciidlist[] = {
-- 
2.25.1

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


[Intel-gfx] [PATCH 33/51] drm/mcde: More devm_drm_dev_init

2020-03-23 Thread Daniel Vetter
Auto-unwind ftw, now possible with the fixed drm_device related
management.

Aside, clk/regulator seem to be missing devm versions for a bunch of
functions, preventing a pile of these simpler drivers from outright
losing their ->remove hook.

Reviewed-by: Linus Walleij 
Signed-off-by: Daniel Vetter 
Cc: Linus Walleij 
---
 drivers/gpu/drm/mcde/mcde_drv.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
index 03d2e1a00810..88cc6b4a7a64 100644
--- a/drivers/gpu/drm/mcde/mcde_drv.c
+++ b/drivers/gpu/drm/mcde/mcde_drv.c
@@ -312,7 +312,7 @@ static int mcde_probe(struct platform_device *pdev)
return -ENOMEM;
mcde->dev = dev;
 
-   ret = drm_dev_init(>drm, _drm_driver, dev);
+   ret = devm_drm_dev_init(dev, >drm, _drm_driver);
if (ret) {
kfree(mcde);
return ret;
@@ -331,12 +331,12 @@ static int mcde_probe(struct platform_device *pdev)
if (IS_ERR(mcde->epod)) {
ret = PTR_ERR(mcde->epod);
dev_err(dev, "can't get EPOD regulator\n");
-   goto dev_unref;
+   return ret;
}
ret = regulator_enable(mcde->epod);
if (ret) {
dev_err(dev, "can't enable EPOD regulator\n");
-   goto dev_unref;
+   return ret;
}
mcde->vana = devm_regulator_get(dev, "vana");
if (IS_ERR(mcde->vana)) {
@@ -487,8 +487,6 @@ static int mcde_probe(struct platform_device *pdev)
regulator_disable(mcde->vana);
 regulator_epod_off:
regulator_disable(mcde->epod);
-dev_unref:
-   drm_dev_put(drm);
return ret;
 
 }
@@ -502,7 +500,6 @@ static int mcde_remove(struct platform_device *pdev)
clk_disable_unprepare(mcde->mcde_clk);
regulator_disable(mcde->vana);
regulator_disable(mcde->epod);
-   drm_dev_put(drm);
 
return 0;
 }
-- 
2.25.1

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


[Intel-gfx] [PATCH 27/51] drm/bochs: Remove leftover drm_atomic_helper_shutdown

2020-03-23 Thread Daniel Vetter
Small mistake that crept into

commit 81da8c3b8d3df6f05b11300b7d17ccd1f3017fab
Author: Gerd Hoffmann 
Date:   Tue Feb 11 14:52:18 2020 +0100

drm/bochs: add drm_driver.release callback

where drm_atomic_helper_shutdown was left in both places. The
->release callback really shouldn't touch hardware.

Acked-by: Gerd Hoffmann 
Cc: Gerd Hoffmann 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/bochs/bochs_kms.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/bochs/bochs_kms.c 
b/drivers/gpu/drm/bochs/bochs_kms.c
index 8066d7d370d5..e8cc8156d773 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -166,6 +166,5 @@ void bochs_kms_fini(struct bochs_device *bochs)
if (!bochs->dev->mode_config.num_connector)
return;
 
-   drm_atomic_helper_shutdown(bochs->dev);
drm_mode_config_cleanup(bochs->dev);
 }
-- 
2.25.1

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


[Intel-gfx] [PATCH 24/51] drm: Manage drm_vblank_cleanup with drmm_

2020-03-23 Thread Daniel Vetter
Nothing special here, except that this is the first time that we
automatically clean up something that's initialized with an explicit
driver call. But the cleanup was done at the very end of the release
sequence for all drivers, and that's still the case. At least without
more uses of drmm_ through explicit driver calls.

Also for this one we need drmm_kcalloc, so lets add those.

The motivation here is to allow us to remove the explicit calls to
drm_dev_fini() from all drivers.

v2: Sort includes (Laurent)

v3: Motivate the change in the commit message better (Sam)

Acked-by: Sam Ravnborg 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_drv.c  |  1 -
 drivers/gpu/drm/drm_internal.h |  1 -
 drivers/gpu/drm/drm_vblank.c   | 31 ---
 include/drm/drm_managed.h  | 16 
 4 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 18e7f7389897..3516b16cd33d 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -750,7 +750,6 @@ EXPORT_SYMBOL(devm_drm_dev_init);
  */
 void drm_dev_fini(struct drm_device *dev)
 {
-   drm_vblank_cleanup(dev);
 }
 EXPORT_SYMBOL(drm_dev_fini);
 
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index a40a0222419e..2470a352730b 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -94,7 +94,6 @@ void drm_managed_release(struct drm_device *dev);
 
 /* drm_vblank.c */
 void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe);
-void drm_vblank_cleanup(struct drm_device *dev);
 
 /* IOCTLS */
 int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index da7b0b0c1090..bcf346b3e486 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -425,14 +426,10 @@ static void vblank_disable_fn(struct timer_list *t)
spin_unlock_irqrestore(>vbl_lock, irqflags);
 }
 
-void drm_vblank_cleanup(struct drm_device *dev)
+static void drm_vblank_init_release(struct drm_device *dev, void *ptr)
 {
unsigned int pipe;
 
-   /* Bail if the driver didn't call drm_vblank_init() */
-   if (dev->num_crtcs == 0)
-   return;
-
for (pipe = 0; pipe < dev->num_crtcs; pipe++) {
struct drm_vblank_crtc *vblank = >vblank[pipe];
 
@@ -441,10 +438,6 @@ void drm_vblank_cleanup(struct drm_device *dev)
 
del_timer_sync(>disable_timer);
}
-
-   kfree(dev->vblank);
-
-   dev->num_crtcs = 0;
 }
 
 /**
@@ -453,25 +446,29 @@ void drm_vblank_cleanup(struct drm_device *dev)
  * @num_crtcs: number of CRTCs supported by @dev
  *
  * This function initializes vblank support for @num_crtcs display pipelines.
- * Cleanup is handled by the DRM core, or through calling drm_dev_fini() for
- * drivers with a _driver.release callback.
+ * Cleanup is handled automatically through a cleanup function added with
+ * drmm_add_action().
  *
  * Returns:
  * Zero on success or a negative error code on failure.
  */
 int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs)
 {
-   int ret = -ENOMEM;
+   int ret;
unsigned int i;
 
spin_lock_init(>vbl_lock);
spin_lock_init(>vblank_time_lock);
 
+   dev->vblank = drmm_kcalloc(dev, num_crtcs, sizeof(*dev->vblank), 
GFP_KERNEL);
+   if (!dev->vblank)
+   return -ENOMEM;
+
dev->num_crtcs = num_crtcs;
 
-   dev->vblank = kcalloc(num_crtcs, sizeof(*dev->vblank), GFP_KERNEL);
-   if (!dev->vblank)
-   goto err;
+   ret = drmm_add_action(dev, drm_vblank_init_release, NULL);
+   if (ret)
+   return ret;
 
for (i = 0; i < num_crtcs; i++) {
struct drm_vblank_crtc *vblank = >vblank[i];
@@ -486,10 +483,6 @@ int drm_vblank_init(struct drm_device *dev, unsigned int 
num_crtcs)
DRM_INFO("Supports vblank timestamp caching Rev 2 (21.10.2013).\n");
 
return 0;
-
-err:
-   dev->num_crtcs = 0;
-   return ret;
 }
 EXPORT_SYMBOL(drm_vblank_init);
 
diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h
index 2d1e29a2200c..191d8d206ff4 100644
--- a/include/drm/drm_managed.h
+++ b/include/drm/drm_managed.h
@@ -4,6 +4,7 @@
 #define _DRM_MANAGED_H_
 
 #include 
+#include 
 #include 
 
 struct drm_device;
@@ -31,6 +32,21 @@ static inline void *drmm_kzalloc(struct drm_device *dev, 
size_t size, gfp_t gfp)
 {
return drmm_kmalloc(dev, size, gfp | __GFP_ZERO);
 }
+static inline void *drmm_kmalloc_array(struct drm_device *dev,
+  size_t n, size_t size, gfp_t flags)
+{
+   size_t bytes;
+
+   if (unlikely(check_mul_overflow(n, size, )))
+   return NULL;
+
+   return drmm_kmalloc(dev, bytes, flags);
+}

[Intel-gfx] [PATCH 36/51] drm/rcar-du: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
It's right above the drm_dev_put().

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

Aside: Another driver with a bit much devm_kzalloc, which should
probably use drmm_kzalloc instead ...

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Reviewed-by: Laurent Pinchart  (v2)
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
Cc: Laurent Pinchart 
Cc: Kieran Bingham 
Cc: linux-renesas-...@vger.kernel.org
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 1 -
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 4 +++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 654e2dd08146..3e67cf70f040 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -530,7 +530,6 @@ static int rcar_du_remove(struct platform_device *pdev)
drm_dev_unregister(ddev);
 
drm_kms_helper_poll_fini(ddev);
-   drm_mode_config_cleanup(ddev);
 
drm_dev_put(ddev);
 
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index fcfd916227d1..482329102f19 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -712,7 +712,9 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
unsigned int i;
int ret;
 
-   drm_mode_config_init(dev);
+   ret = drmm_mode_config_init(dev);
+   if (ret)
+   return ret;
 
dev->mode_config.min_width = 0;
dev->mode_config.min_height = 0;
-- 
2.25.1

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


[Intel-gfx] [PATCH 19/51] drm: Cleanups after drmm_add_final_kfree rollout

2020-03-23 Thread Daniel Vetter
A few things:
- Update the example driver in the documentation.
- We can drop the old kfree in drm_dev_release.
- Add a WARN_ON check in drm_dev_register to make sure everyone calls
  drmm_add_final_kfree and there's no leaks.

v2: Restore the full cleanup, I accidentally left some moved code
behind when fixing the bisectability of the series.

Acked-by: Sam Ravnborg 
Acked-by: Thomas Zimmermann 
Cc: Sam Ravnborg 
Cc: Dan Carpenter 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_drv.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 877ded348b6e..7f9d7ea543a0 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -297,8 +297,6 @@ void drm_minor_release(struct drm_minor *minor)
  *
  * drm_mode_config_cleanup(drm);
  * drm_dev_fini(drm);
- * kfree(priv->userspace_facing);
- * kfree(priv);
  * }
  *
  * static struct drm_driver driver_drm_driver = {
@@ -326,10 +324,11 @@ void drm_minor_release(struct drm_minor *minor)
  * kfree(drm);
  * return ret;
  * }
+ * drmm_add_final_kfree(drm, priv);
  *
  * drm_mode_config_init(drm);
  *
- * priv->userspace_facing = kzalloc(..., GFP_KERNEL);
+ * priv->userspace_facing = drmm_kzalloc(..., GFP_KERNEL);
  * if (!priv->userspace_facing)
  * return -ENOMEM;
  *
@@ -837,10 +836,7 @@ static void drm_dev_release(struct kref *ref)
 
drm_managed_release(dev);
 
-   if (!dev->driver->release && !dev->managed.final_kfree) {
-   WARN_ON(!list_empty(>managed.resources));
-   kfree(dev);
-   } else if (dev->managed.final_kfree)
+   if (dev->managed.final_kfree)
kfree(dev->managed.final_kfree);
 }
 
@@ -961,6 +957,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long 
flags)
if (!driver->load)
drm_mode_config_validate(dev);
 
+   WARN_ON(!dev->managed.final_kfree);
+
if (drm_dev_needs_global_mutex(dev))
mutex_lock(_global_mutex);
 
-- 
2.25.1

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


[Intel-gfx] [PATCH 13/51] drm/vgem: Use drmm_add_final_kfree

2020-03-23 Thread Daniel Vetter
With this we can drop the final kfree from the release function.

v2: After drm_dev_init/drmm_add_final_kfree we need to clean up
everything through a drm_dev_put. Rework the unwind code to match
that.

Acked-by: Sam Ravnborg 
Signed-off-by: Daniel Vetter 
Cc: Daniel Vetter 
Cc: Emil Velikov 
Cc: Chris Wilson 
Cc: Sean Paul 
Cc: Eric Anholt 
Cc: Rob Clark 
Cc: Sam Ravnborg 
---
 drivers/gpu/drm/vgem/vgem_drv.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
index 909eba43664a..7486014e9149 100644
--- a/drivers/gpu/drm/vgem/vgem_drv.c
+++ b/drivers/gpu/drm/vgem/vgem_drv.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "vgem_drv.h"
@@ -432,8 +433,6 @@ static void vgem_release(struct drm_device *dev)
 
platform_device_unregister(vgem->platform);
drm_dev_fini(>drm);
-
-   kfree(vgem);
 }
 
 static struct drm_driver vgem_driver = {
@@ -489,16 +488,19 @@ static int __init vgem_init(void)
   _device->platform->dev);
if (ret)
goto out_unregister;
+   drmm_add_final_kfree(_device->drm, vgem_device);
 
/* Final step: expose the device/driver to userspace */
-   ret  = drm_dev_register(_device->drm, 0);
+   ret = drm_dev_register(_device->drm, 0);
if (ret)
-   goto out_fini;
+   goto out_put;
 
return 0;
 
-out_fini:
-   drm_dev_fini(_device->drm);
+out_put:
+   drm_dev_put(_device->drm);
+   return ret;
+
 out_unregister:
platform_device_unregister(vgem_device->platform);
 out_free:
-- 
2.25.1

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


[Intel-gfx] [PATCH 37/51] drm/rockchip: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
It's (almost, there's some iommu stuff without significance) right
above the drm_dev_put().

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

Aside: Another driver with a bit much devm_kzalloc, which should
probably use drmm_kzalloc instead ...

v2: Explain why this cleanup is possible (Laurent).

v3: Jump out at the right label (Francesco)

v4: Try again, kbuild caught that I didn't build test this properly
...

v5: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Acked-by: Sam Ravnborg 
Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Cc: Francesco Lavra 
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
Cc: Sandy Huang 
Cc: "Heiko Stübner" 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-rockc...@lists.infradead.org
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 20ecb1508a22..0f3eb392fe39 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -135,14 +135,16 @@ static int rockchip_drm_bind(struct device *dev)
if (ret)
goto err_free;
 
-   drm_mode_config_init(drm_dev);
+   ret = drmm_mode_config_init(drm_dev);
+   if (ret)
+   goto err_iommu_cleanup;
 
rockchip_drm_mode_config_init(drm_dev);
 
/* Try to bind all sub drivers. */
ret = component_bind_all(dev, drm_dev);
if (ret)
-   goto err_mode_config_cleanup;
+   goto err_iommu_cleanup;
 
ret = drm_vblank_init(drm_dev, drm_dev->mode_config.num_crtc);
if (ret)
@@ -173,12 +175,9 @@ static int rockchip_drm_bind(struct device *dev)
rockchip_drm_fbdev_fini(drm_dev);
 err_unbind_all:
component_unbind_all(dev, drm_dev);
-err_mode_config_cleanup:
-   drm_mode_config_cleanup(drm_dev);
+err_iommu_cleanup:
rockchip_iommu_cleanup(drm_dev);
 err_free:
-   drm_dev->dev_private = NULL;
-   dev_set_drvdata(dev, NULL);
drm_dev_put(drm_dev);
return ret;
 }
@@ -194,11 +193,8 @@ static void rockchip_drm_unbind(struct device *dev)
 
drm_atomic_helper_shutdown(drm_dev);
component_unbind_all(dev, drm_dev);
-   drm_mode_config_cleanup(drm_dev);
rockchip_iommu_cleanup(drm_dev);
 
-   drm_dev->dev_private = NULL;
-   dev_set_drvdata(dev, NULL);
drm_dev_put(drm_dev);
 }
 
-- 
2.25.1

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


[Intel-gfx] [PATCH 31/51] drm/ingenic: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
Allows us to drop the drm_driver.release callback.

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Acked-by: Sam Ravnborg 
Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Reviewed-by: Paul Cercueil  (v2)
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
Cc: Paul Cercueil 
---
 drivers/gpu/drm/ingenic/ingenic-drm.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c 
b/drivers/gpu/drm/ingenic/ingenic-drm.c
index 192aaa4421a3..a9bc6623b488 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
@@ -489,11 +489,6 @@ static irqreturn_t ingenic_drm_irq_handler(int irq, void 
*arg)
return IRQ_HANDLED;
 }
 
-static void ingenic_drm_release(struct drm_device *drm)
-{
-   drm_mode_config_cleanup(drm);
-}
-
 static int ingenic_drm_enable_vblank(struct drm_crtc *crtc)
 {
struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
@@ -537,7 +532,6 @@ static struct drm_driver ingenic_drm_driver_data = {
.gem_prime_mmap = drm_gem_cma_prime_mmap,
 
.irq_handler= ingenic_drm_irq_handler,
-   .release= ingenic_drm_release,
 };
 
 static const struct drm_plane_funcs ingenic_drm_primary_plane_funcs = {
@@ -638,7 +632,10 @@ static int ingenic_drm_probe(struct platform_device *pdev)
}
drmm_add_final_kfree(drm, priv);
 
-   drm_mode_config_init(drm);
+   ret = drmm_mode_config_init(drm);
+   if (ret)
+   return ret;
+
drm->mode_config.min_width = 0;
drm->mode_config.min_height = 0;
drm->mode_config.max_width = soc_info->max_width;
-- 
2.25.1

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


[Intel-gfx] [PATCH 25/51] drm: Garbage collect drm_dev_fini

2020-03-23 Thread Daniel Vetter
It has become empty. Given the few users I figured not much point
splitting this up.

v2: Rebase over i915 changes.

v3: Rebase over patch split fix.

Acked-by: Sam Ravnborg 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/cirrus/cirrus.c   |  1 -
 drivers/gpu/drm/drm_drv.c | 20 ---
 drivers/gpu/drm/drm_mipi_dbi.c|  1 -
 drivers/gpu/drm/i915/i915_drv.c   |  9 -
 .../gpu/drm/i915/selftests/mock_gem_device.c  |  2 --
 drivers/gpu/drm/ingenic/ingenic-drm.c |  1 -
 drivers/gpu/drm/mcde/mcde_drv.c   |  1 -
 drivers/gpu/drm/tidss/tidss_drv.c |  2 --
 drivers/gpu/drm/tiny/gm12u320.c   |  1 -
 drivers/gpu/drm/tiny/repaper.c|  1 -
 drivers/gpu/drm/udl/udl_drv.c |  1 -
 drivers/gpu/drm/vgem/vgem_drv.c   |  1 -
 drivers/gpu/drm/vkms/vkms_drv.c   |  1 -
 drivers/gpu/drm/xen/xen_drm_front.c   |  2 --
 include/drm/drm_drv.h |  5 +
 15 files changed, 1 insertion(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index 2232556ce34c..a9d789a56536 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -529,7 +529,6 @@ static void cirrus_mode_config_init(struct cirrus_device 
*cirrus)
 static void cirrus_release(struct drm_device *dev)
 {
drm_mode_config_cleanup(dev);
-   drm_dev_fini(dev);
 }
 
 DEFINE_DRM_GEM_FOPS(cirrus_fops);
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 3516b16cd33d..03f5cb829957 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -281,7 +281,6 @@ void drm_minor_release(struct drm_minor *minor)
  * struct driver_device *priv = container_of(...);
  *
  * drm_mode_config_cleanup(drm);
- * drm_dev_fini(drm);
  * }
  *
  * static struct drm_driver driver_drm_driver = {
@@ -736,23 +735,6 @@ int devm_drm_dev_init(struct device *parent,
 }
 EXPORT_SYMBOL(devm_drm_dev_init);
 
-/**
- * drm_dev_fini - Finalize a dead DRM device
- * @dev: DRM device
- *
- * Finalize a dead DRM device. This is the converse to drm_dev_init() and
- * frees up all data allocated by it. All driver private data should be
- * finalized first. Note that this function does not free the @dev, that is
- * left to the caller.
- *
- * The ref-count of @dev must be zero, and drm_dev_fini() should only be called
- * from a _driver.release callback.
- */
-void drm_dev_fini(struct drm_device *dev)
-{
-}
-EXPORT_SYMBOL(drm_dev_fini);
-
 /**
  * drm_dev_alloc - Allocate new DRM device
  * @driver: DRM driver to allocate device for
@@ -803,8 +785,6 @@ static void drm_dev_release(struct kref *ref)
 
if (dev->driver->release)
dev->driver->release(dev);
-   else
-   drm_dev_fini(dev);
 
drm_managed_release(dev);
 
diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
index 98d0af8376fd..44de8502a472 100644
--- a/drivers/gpu/drm/drm_mipi_dbi.c
+++ b/drivers/gpu/drm/drm_mipi_dbi.c
@@ -592,7 +592,6 @@ void mipi_dbi_release(struct drm_device *drm)
DRM_DEBUG_DRIVER("\n");
 
drm_mode_config_cleanup(drm);
-   drm_dev_fini(drm);
 }
 EXPORT_SYMBOL(mipi_dbi_release);
 
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 481313536b5a..a7a3b4b98572 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -906,13 +906,6 @@ i915_driver_create(struct pci_dev *pdev, const struct 
pci_device_id *ent)
return i915;
 }
 
-static void i915_driver_destroy(struct drm_i915_private *i915)
-{
-   struct pci_dev *pdev = i915->drm.pdev;
-
-   drm_dev_fini(>drm);
-}
-
 /**
  * i915_driver_probe - setup chip and create an initial config
  * @pdev: PCI device
@@ -1015,7 +1008,6 @@ int i915_driver_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
pci_disable_device(pdev);
 out_fini:
i915_probe_error(i915, "Device initialization failed (%d)\n", ret);
-   i915_driver_destroy(i915);
drm_dev_put(>drm);
return ret;
 }
@@ -1072,7 +1064,6 @@ static void i915_driver_release(struct drm_device *dev)
intel_runtime_pm_driver_release(rpm);
 
i915_driver_late_release(dev_priv);
-   i915_driver_destroy(dev_priv);
 }
 
 static int i915_driver_open(struct drm_device *dev, struct drm_file *file)
diff --git a/drivers/gpu/drm/i915/selftests/mock_gem_device.c 
b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
index acf889e4b993..2b4407ac26de 100644
--- a/drivers/gpu/drm/i915/selftests/mock_gem_device.c
+++ b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
@@ -76,7 +76,6 @@ static void mock_device_release(struct drm_device *dev)
 
drm_mode_config_cleanup(>drm);
 
-   drm_dev_fini(>drm);
 out:
put_device(>drm.pdev->dev);
i915->drm.pdev = NULL;

[Intel-gfx] [PATCH 20/51] drm: Handle dev->unique with drmm_

2020-03-23 Thread Daniel Vetter
We need to add a drmm_kstrdup for this, but let's start somewhere.

This is not exactly perfect onion unwinding, but it's jsut a kfree so
doesn't really matter at all.

Reviewed-by: Sam Ravnborg 
Acked-by: Thomas Zimmermann 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_drv.c |  5 ++---
 drivers/gpu/drm/drm_managed.c | 16 
 include/drm/drm_managed.h |  1 +
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 7f9d7ea543a0..c80ebc6811b1 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -777,7 +777,6 @@ void drm_dev_fini(struct drm_device *dev)
mutex_destroy(>filelist_mutex);
mutex_destroy(>struct_mutex);
drm_legacy_destroy_members(dev);
-   kfree(dev->unique);
 }
 EXPORT_SYMBOL(drm_dev_fini);
 
@@ -1065,8 +1064,8 @@ EXPORT_SYMBOL(drm_dev_unregister);
  */
 int drm_dev_set_unique(struct drm_device *dev, const char *name)
 {
-   kfree(dev->unique);
-   dev->unique = kstrdup(name, GFP_KERNEL);
+   drmm_kfree(dev, dev->unique);
+   dev->unique = drmm_kstrdup(dev, name, GFP_KERNEL);
 
return dev->unique ? 0 : -ENOMEM;
 }
diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c
index 4a69771a4d93..c633c2ef5269 100644
--- a/drivers/gpu/drm/drm_managed.c
+++ b/drivers/gpu/drm/drm_managed.c
@@ -167,6 +167,22 @@ void *drmm_kmalloc(struct drm_device *dev, size_t size, 
gfp_t gfp)
 }
 EXPORT_SYMBOL(drmm_kmalloc);
 
+char *drmm_kstrdup(struct drm_device *dev, const char *s, gfp_t gfp)
+{
+   size_t size;
+   char *buf;
+
+   if (!s)
+   return NULL;
+
+   size = strlen(s) + 1;
+   buf = drmm_kmalloc(dev, size, gfp);
+   if (buf)
+   memcpy(buf, s, size);
+   return buf;
+}
+EXPORT_SYMBOL_GPL(drmm_kstrdup);
+
 void drmm_kfree(struct drm_device *dev, void *data)
 {
struct drmres *dr_match = NULL, *dr;
diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h
index 7b5df7d09b19..89e6fce9f689 100644
--- a/include/drm/drm_managed.h
+++ b/include/drm/drm_managed.h
@@ -24,6 +24,7 @@ static inline void *drmm_kzalloc(struct drm_device *dev, 
size_t size, gfp_t gfp)
 {
return drmm_kmalloc(dev, size, gfp | __GFP_ZERO);
 }
+char *drmm_kstrdup(struct drm_device *dev, const char *s, gfp_t gfp);
 
 void drmm_kfree(struct drm_device *dev, void *data);
 
-- 
2.25.1

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


[Intel-gfx] [PATCH 21/51] drm: Use drmm_ for drm_dev_init cleanup

2020-03-23 Thread Daniel Vetter
Well for the simple stuff at least, vblank, gem and minor cleanup I
want to further split up as a demonstration.

v2: We need to clear drm_device->dev otherwise the debug drm printing
after our cleanup hook (e.g. in drm_manged_release) will chase
released memory and result in a use-after-free. Not really pretty, but
oh well.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_drv.c | 48 ---
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index c80ebc6811b1..a710c53d13a8 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -580,6 +580,23 @@ static void drm_fs_inode_free(struct inode *inode)
  *used.
  */
 
+static void drm_dev_init_release(struct drm_device *dev, void *res)
+{
+   drm_legacy_ctxbitmap_cleanup(dev);
+   drm_legacy_remove_map_hash(dev);
+   drm_fs_inode_free(dev->anon_inode);
+
+   put_device(dev->dev);
+   /* Prevent use-after-free in drm_managed_release when debugging is
+* enabled. Slightly awkward, but can't really be helped. */
+   dev->dev = NULL;
+   mutex_destroy(>master_mutex);
+   mutex_destroy(>clientlist_mutex);
+   mutex_destroy(>filelist_mutex);
+   mutex_destroy(>struct_mutex);
+   drm_legacy_destroy_members(dev);
+}
+
 /**
  * drm_dev_init - Initialise new DRM device
  * @dev: DRM device
@@ -647,11 +664,15 @@ int drm_dev_init(struct drm_device *dev,
mutex_init(>clientlist_mutex);
mutex_init(>master_mutex);
 
+   ret = drmm_add_action(dev, drm_dev_init_release, NULL);
+   if (ret)
+   return ret;
+
dev->anon_inode = drm_fs_inode_new();
if (IS_ERR(dev->anon_inode)) {
ret = PTR_ERR(dev->anon_inode);
DRM_ERROR("Cannot allocate anonymous inode: %d\n", ret);
-   goto err_free;
+   goto err;
}
 
if (drm_core_check_feature(dev, DRIVER_RENDER)) {
@@ -688,19 +709,12 @@ int drm_dev_init(struct drm_device *dev,
if (drm_core_check_feature(dev, DRIVER_GEM))
drm_gem_destroy(dev);
 err_ctxbitmap:
-   drm_legacy_ctxbitmap_cleanup(dev);
-   drm_legacy_remove_map_hash(dev);
 err_minors:
drm_minor_free(dev, DRM_MINOR_PRIMARY);
drm_minor_free(dev, DRM_MINOR_RENDER);
-   drm_fs_inode_free(dev->anon_inode);
-err_free:
-   put_device(dev->dev);
-   mutex_destroy(>master_mutex);
-   mutex_destroy(>clientlist_mutex);
-   mutex_destroy(>filelist_mutex);
-   mutex_destroy(>struct_mutex);
-   drm_legacy_destroy_members(dev);
+err:
+   drm_managed_release(dev);
+
return ret;
 }
 EXPORT_SYMBOL(drm_dev_init);
@@ -763,20 +777,8 @@ void drm_dev_fini(struct drm_device *dev)
if (drm_core_check_feature(dev, DRIVER_GEM))
drm_gem_destroy(dev);
 
-   drm_legacy_ctxbitmap_cleanup(dev);
-   drm_legacy_remove_map_hash(dev);
-   drm_fs_inode_free(dev->anon_inode);
-
drm_minor_free(dev, DRM_MINOR_PRIMARY);
drm_minor_free(dev, DRM_MINOR_RENDER);
-
-   put_device(dev->dev);
-
-   mutex_destroy(>master_mutex);
-   mutex_destroy(>clientlist_mutex);
-   mutex_destroy(>filelist_mutex);
-   mutex_destroy(>struct_mutex);
-   drm_legacy_destroy_members(dev);
 }
 EXPORT_SYMBOL(drm_dev_fini);
 
-- 
2.25.1

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


[Intel-gfx] [PATCH 34/51] drm/meson: Drop explicit drm_mode_config_cleanup call

2020-03-23 Thread Daniel Vetter
It's right above the drm_dev_put().

This is made possible by a preceeding patch which added a drmm_
cleanup action to drm_mode_config_init(), hence all we need to do to
ensure that drm_mode_config_cleanup() is run on final drm_device
cleanup is check the new error code for _init().

Aside: This driver gets its devm_ stuff all wrong wrt drm_device and
anything hanging off that. Not the only one unfortunately.

v2: Explain why this cleanup is possible (Laurent).

v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)

Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Reviewed-by: Neil Armstrong  (v2)
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
Cc: Neil Armstrong 
Cc: Kevin Hilman 
Cc: linux-amlo...@lists.infradead.org
Cc: linux-arm-ker...@lists.infradead.org
---
 drivers/gpu/drm/meson/meson_drv.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_drv.c 
b/drivers/gpu/drm/meson/meson_drv.c
index b5f5eb7b4bb9..6f29fab79952 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -284,7 +284,9 @@ static int meson_drv_bind_master(struct device *dev, bool 
has_components)
/* Remove early framebuffers (ie. simplefb) */
meson_remove_framebuffers();
 
-   drm_mode_config_init(drm);
+   ret = drmm_mode_config_init(drm);
+   if (ret)
+   goto free_drm;
drm->mode_config.max_width = 3840;
drm->mode_config.max_height = 2160;
drm->mode_config.funcs = _mode_config_funcs;
@@ -379,7 +381,6 @@ static void meson_drv_unbind(struct device *dev)
drm_dev_unregister(drm);
drm_irq_uninstall(drm);
drm_kms_helper_poll_fini(drm);
-   drm_mode_config_cleanup(drm);
drm_dev_put(drm);
 }
 
-- 
2.25.1

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


[Intel-gfx] [PATCH 04/51] drm: Set final_kfree in drm_dev_alloc

2020-03-23 Thread Daniel Vetter
I also did a full review of all callers, and only the xen driver
forgot to call drm_dev_put in the failure path. Fix that up too.

v2: I noticed that xen has a drm_driver.release hook, and uses
drm_dev_alloc(). We need to remove the kfree from
xen_drm_drv_release().

bochs also has a release hook, but leaked the drm_device ever since

commit 0a6659bdc5e8221da99eebb176fd9591435e38de
Author: Gerd Hoffmann 
Date:   Tue Dec 17 18:04:46 2013 +0100

drm/bochs: new driver

This patch here fixes that leak.

Same for virtio, started leaking with

commit b1df3a2b24a917f8853d43fe9683c0e360d2c33a
Author: Gerd Hoffmann 
Date:   Tue Feb 11 14:58:04 2020 +0100

drm/virtio: add drm_driver.release callback.

Acked-by: Gerd Hoffmann 
Acked-by: Thomas Zimmermann 
Acked-by: Sam Ravnborg 
Reviewed-by: Oleksandr Andrushchenko 
Cc: Gerd Hoffmann 
Cc: Oleksandr Andrushchenko 
Cc: xen-de...@lists.xenproject.org
Signed-off-by: Daniel Vetter 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Cc: Thomas Zimmermann 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Oleksandr Andrushchenko 
Cc: xen-de...@lists.xenproject.org
---
 drivers/gpu/drm/drm_drv.c   | 3 +++
 drivers/gpu/drm/xen/xen_drm_front.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 1b9be23b93b0..877ded348b6e 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -819,6 +820,8 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
return ERR_PTR(ret);
}
 
+   drmm_add_final_kfree(dev, dev);
+
return dev;
 }
 EXPORT_SYMBOL(drm_dev_alloc);
diff --git a/drivers/gpu/drm/xen/xen_drm_front.c 
b/drivers/gpu/drm/xen/xen_drm_front.c
index 4be49c1aef51..d22b5da38935 100644
--- a/drivers/gpu/drm/xen/xen_drm_front.c
+++ b/drivers/gpu/drm/xen/xen_drm_front.c
@@ -461,7 +461,6 @@ static void xen_drm_drv_release(struct drm_device *dev)
drm_mode_config_cleanup(dev);
 
drm_dev_fini(dev);
-   kfree(dev);
 
if (front_info->cfg.be_alloc)
xenbus_switch_state(front_info->xb_dev,
@@ -561,6 +560,7 @@ static int xen_drm_drv_init(struct xen_drm_front_info 
*front_info)
 fail_modeset:
drm_kms_helper_poll_fini(drm_dev);
drm_mode_config_cleanup(drm_dev);
+   drm_dev_put(drm_dev);
 fail:
kfree(drm_info);
return ret;
-- 
2.25.1

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


[Intel-gfx] [PATCH 22/51] drm: manage drm_minor cleanup with drmm_

2020-03-23 Thread Daniel Vetter
The cleanup here is somewhat tricky, since we can't tell apart the
allocated minor index from 0. So register a cleanup action first, and
if the index allocation fails, unregister that cleanup action again to
avoid bad mistakes.

The kdev for the minor already handles NULL, so no problem there.

Hence add drmm_remove_action() to the drm_managed library.

v2: Make pointer math around void ** consistent with what Laurent
suggested.

v3: Use drmm_add_action_or_reset and remove drmm_remove_action. Noticed
because of some questions from Thomas. This also means we need to move
the drmm_add_action_or_reset helper earlier in the series.

Cc: Thomas Zimmermann 
Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_drv.c | 70 ---
 drivers/gpu/drm/drm_managed.c | 14 +++
 include/drm/drm_managed.h |  9 -
 3 files changed, 46 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index a710c53d13a8..25fc2107057c 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -93,13 +93,25 @@ static struct drm_minor **drm_minor_get_slot(struct 
drm_device *dev,
}
 }
 
+static void drm_minor_alloc_release(struct drm_device *dev, void *data)
+{
+   struct drm_minor *minor = data;
+   unsigned long flags;
+
+   put_device(minor->kdev);
+
+   spin_lock_irqsave(_minor_lock, flags);
+   idr_remove(_minors_idr, minor->index);
+   spin_unlock_irqrestore(_minor_lock, flags);
+}
+
 static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
 {
struct drm_minor *minor;
unsigned long flags;
int r;
 
-   minor = kzalloc(sizeof(*minor), GFP_KERNEL);
+   minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
if (!minor)
return -ENOMEM;
 
@@ -117,46 +129,19 @@ static int drm_minor_alloc(struct drm_device *dev, 
unsigned int type)
idr_preload_end();
 
if (r < 0)
-   goto err_free;
+   return r;
 
-   minor->index = r;
+   r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
+   if (r)
+   return r;
 
+   minor->index = r;
minor->kdev = drm_sysfs_minor_alloc(minor);
-   if (IS_ERR(minor->kdev)) {
-   r = PTR_ERR(minor->kdev);
-   goto err_index;
-   }
+   if (IS_ERR(minor->kdev))
+   return PTR_ERR(minor->kdev);
 
*drm_minor_get_slot(dev, type) = minor;
return 0;
-
-err_index:
-   spin_lock_irqsave(_minor_lock, flags);
-   idr_remove(_minors_idr, minor->index);
-   spin_unlock_irqrestore(_minor_lock, flags);
-err_free:
-   kfree(minor);
-   return r;
-}
-
-static void drm_minor_free(struct drm_device *dev, unsigned int type)
-{
-   struct drm_minor **slot, *minor;
-   unsigned long flags;
-
-   slot = drm_minor_get_slot(dev, type);
-   minor = *slot;
-   if (!minor)
-   return;
-
-   put_device(minor->kdev);
-
-   spin_lock_irqsave(_minor_lock, flags);
-   idr_remove(_minors_idr, minor->index);
-   spin_unlock_irqrestore(_minor_lock, flags);
-
-   kfree(minor);
-   *slot = NULL;
 }
 
 static int drm_minor_register(struct drm_device *dev, unsigned int type)
@@ -678,16 +663,16 @@ int drm_dev_init(struct drm_device *dev,
if (drm_core_check_feature(dev, DRIVER_RENDER)) {
ret = drm_minor_alloc(dev, DRM_MINOR_RENDER);
if (ret)
-   goto err_minors;
+   goto err;
}
 
ret = drm_minor_alloc(dev, DRM_MINOR_PRIMARY);
if (ret)
-   goto err_minors;
+   goto err;
 
ret = drm_legacy_create_map_hash(dev);
if (ret)
-   goto err_minors;
+   goto err;
 
drm_legacy_ctxbitmap_init(dev);
 
@@ -695,7 +680,7 @@ int drm_dev_init(struct drm_device *dev,
ret = drm_gem_init(dev);
if (ret) {
DRM_ERROR("Cannot initialize graphics execution manager 
(GEM)\n");
-   goto err_ctxbitmap;
+   goto err;
}
}
 
@@ -708,10 +693,6 @@ int drm_dev_init(struct drm_device *dev,
 err_setunique:
if (drm_core_check_feature(dev, DRIVER_GEM))
drm_gem_destroy(dev);
-err_ctxbitmap:
-err_minors:
-   drm_minor_free(dev, DRM_MINOR_PRIMARY);
-   drm_minor_free(dev, DRM_MINOR_RENDER);
 err:
drm_managed_release(dev);
 
@@ -776,9 +757,6 @@ void drm_dev_fini(struct drm_device *dev)
 
if (drm_core_check_feature(dev, DRIVER_GEM))
drm_gem_destroy(dev);
-
-   drm_minor_free(dev, DRM_MINOR_PRIMARY);
-   drm_minor_free(dev, DRM_MINOR_RENDER);
 }
 EXPORT_SYMBOL(drm_dev_fini);
 
diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c
index c633c2ef5269..8abf3a53aeb5 100644
--- 

[Intel-gfx] [PATCH 17/51] drm/gm12u320: Use drmm_add_final_kfree

2020-03-23 Thread Daniel Vetter
With this we can drop the final kfree from the release function.

Acked-by: Sam Ravnborg 
Reviewed-by: Hans de Goede 
Signed-off-by: Daniel Vetter 
Cc: Hans de Goede 
---
 drivers/gpu/drm/tiny/gm12u320.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index a48173441ae0..524ca0941cf9 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -637,7 +638,6 @@ static void gm12u320_driver_release(struct drm_device *dev)
gm12u320_usb_free(gm12u320);
drm_mode_config_cleanup(dev);
drm_dev_fini(dev);
-   kfree(gm12u320);
 }
 
 DEFINE_DRM_GEM_FOPS(gm12u320_fops);
@@ -692,6 +692,7 @@ static int gm12u320_usb_probe(struct usb_interface 
*interface,
return ret;
}
dev->dev_private = gm12u320;
+   drmm_add_final_kfree(dev, gm12u320);
 
drm_mode_config_init(dev);
dev->mode_config.min_width = GM12U320_USER_WIDTH;
-- 
2.25.1

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


[Intel-gfx] [PATCH 03/51] drm: add managed resources tied to drm_device

2020-03-23 Thread Daniel Vetter
We have lots of these. And the cleanup code tends to be of dubious
quality. The biggest wrong pattern is that developers use devm_, which
ties the release action to the underlying struct device, whereas
all the userspace visible stuff attached to a drm_device can long
outlive that one (e.g. after a hotunplug while userspace has open
files and mmap'ed buffers). Give people what they want, but with more
correctness.

Mostly copied from devres.c, with types adjusted to fit drm_device and
a few simplifications - I didn't (yet) copy over everything. Since
the types don't match code sharing looked like a hopeless endeavour.

For now it's only super simplified, no groups, you can't remove
actions (but kfree exists, we'll need that soon). Plus all specific to
drm_device ofc, including the logging. Which I didn't bother to make
compile-time optional, since none of the other drm logging is compile
time optional either.

One tricky bit here is the chicken between allocating your
drm_device structure and initiliazing it with drm_dev_init. For
perfect onion unwinding we'd need to have the action to kfree the
allocation registered before drm_dev_init registers any of its own
release handlers. But drm_dev_init doesn't know where exactly the
drm_device is emebedded into the overall structure, and by the time it
returns it'll all be too late. And forcing drivers to be able clean up
everything except the one kzalloc is silly.

Work around this by having a very special final_kfree pointer. This
also avoids troubles with the list head possibly disappearing from
underneath us when we release all resources attached to the
drm_device.

v2: Do all the kerneldoc at the end, to avoid lots of fairly pointless
shuffling while getting everything into shape.

v3: Add static to add/del_dr (Neil)
Move typo fix to the right patch (Neil)

v4: Enforce contract for drmm_add_final_kfree:

Use ksize() to check that the drm_device is indeed contained somewhere
in the final kfree(). Because we need that or the entire managed
release logic blows up in a pile of use-after-frees. Motivated by a
discussion with Laurent.

v5: Review from Laurent:
- %zu instead of casting size_t
- header guards
- sorting of includes
- guarding of data assignment if we didn't allocate it for a NULL
  pointer
- delete spurious newline
- cast void* data parameter correctly in ->release call, no idea how
  this even worked before

v3: Review from Sam
- Add the kerneldoc for the managed sub-struct back in, even if it
  doesn't show up in the generated html somehow.
- Explain why __always_inline.
- Fix bisectability around the final kfree() in drm_dev_relase(). This
  is just interim code which will disappear again.
- Some whitespace polish.
- Add debug output when drmm_add_action or drmm_kmalloc fail.

v4: My bisectability fix wasn't up to par as noticed by smatch.

v5: Remove unecessary {} around if else

v6: Use kstrdup_const, which requires kfree_const and introducing a free_dr()
helper (Thomas).

Cc: Thomas Zimmermann 
Cc: Dan Carpenter 
Cc: Sam Ravnborg 
Cc: Laurent Pinchart 
Cc: Neil Armstrong 
Cc: "Rafael J. Wysocki" 
Signed-off-by: Daniel Vetter 
---
 Documentation/gpu/drm-internals.rst |   6 +
 drivers/gpu/drm/Makefile|   3 +-
 drivers/gpu/drm/drm_drv.c   |  15 ++-
 drivers/gpu/drm/drm_internal.h  |   3 +
 drivers/gpu/drm/drm_managed.c   | 193 
 include/drm/drm_device.h|  15 +++
 include/drm/drm_managed.h   |  30 +
 include/drm/drm_print.h |   6 +
 8 files changed, 267 insertions(+), 4 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_managed.c
 create mode 100644 include/drm/drm_managed.h

diff --git a/Documentation/gpu/drm-internals.rst 
b/Documentation/gpu/drm-internals.rst
index a73320576ca9..a6b6145fda78 100644
--- a/Documentation/gpu/drm-internals.rst
+++ b/Documentation/gpu/drm-internals.rst
@@ -132,6 +132,12 @@ be unmapped; on many devices, the ROM address decoder is 
shared with
 other BARs, so leaving it mapped could cause undesired behaviour like
 hangs or memory corruption.
 
+Managed Resources
+-
+
+.. kernel-doc:: drivers/gpu/drm/drm_managed.c
+   :doc: managed resources
+
 Bus-specific Device Registration and PCI Support
 
 
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 7f72ef5e7811..183c60048307 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -17,7 +17,8 @@ drm-y   :=drm_auth.o drm_cache.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_writeback.o drm_client.o \
-   drm_client_modeset.o drm_atomic_uapi.o drm_hdcp.o
+   drm_client_modeset.o drm_atomic_uapi.o drm_hdcp.o \
+   drm_managed.o
 
 drm-$(CONFIG_DRM_LEGACY) += drm_legacy_misc.o drm_bufs.o drm_context.o 
drm_dma.o 

[Intel-gfx] [PATCH 15/51] drm/repaper: Use drmm_add_final_kfree

2020-03-23 Thread Daniel Vetter
With this we can drop the final kfree from the release function.

Acked-by: Sam Ravnborg 
Reviewed-by: Noralf Trønnes 
Signed-off-by: Daniel Vetter 
Cc: "Noralf Trønnes" 
---
 drivers/gpu/drm/tiny/repaper.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/tiny/repaper.c b/drivers/gpu/drm/tiny/repaper.c
index f5ebcaf7ee3a..df5654ef53ee 100644
--- a/drivers/gpu/drm/tiny/repaper.c
+++ b/drivers/gpu/drm/tiny/repaper.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -910,13 +911,10 @@ static const struct drm_mode_config_funcs 
repaper_mode_config_funcs = {
 
 static void repaper_release(struct drm_device *drm)
 {
-   struct repaper_epd *epd = drm_to_epd(drm);
-
DRM_DEBUG_DRIVER("\n");
 
drm_mode_config_cleanup(drm);
drm_dev_fini(drm);
-   kfree(epd);
 }
 
 static const uint32_t repaper_formats[] = {
@@ -1024,6 +1022,7 @@ static int repaper_probe(struct spi_device *spi)
kfree(epd);
return ret;
}
+   drmm_add_final_kfree(drm, epd);
 
drm_mode_config_init(drm);
drm->mode_config.funcs = _mode_config_funcs;
-- 
2.25.1

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


[Intel-gfx] [PATCH 06/51] drm/udl: Use drmm_add_final_kfree

2020-03-23 Thread Daniel Vetter
With this we can drop the final kfree from the release function.

v2: We need drm_dev_put to unroll the driver creation (once
drm_dev_init and drmm_add_final_kfree suceeded), otherwise
the drmm_ magic doesn't happen.

v3: Actually squash in the fixup (Laurent).

Acked-by: Thomas Zimmermann 
Acked-by: Sam Ravnborg 
Signed-off-by: Daniel Vetter 
Cc: Laurent Pinchart 
Cc: Dave Airlie 
Cc: Sean Paul 
Cc: Thomas Zimmermann 
Cc: Emil Velikov 
Cc: Daniel Vetter 
Cc: "Noralf Trønnes" 
Cc: Thomas Gleixner 
Cc: Sam Ravnborg 
---
 drivers/gpu/drm/udl/udl_drv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index e6c1cd77d4d4..6a5594946096 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -38,7 +39,6 @@ static void udl_driver_release(struct drm_device *dev)
udl_fini(dev);
udl_modeset_cleanup(dev);
drm_dev_fini(dev);
-   kfree(dev);
 }
 
 static struct drm_driver driver = {
@@ -77,11 +77,11 @@ static struct udl_device *udl_driver_create(struct 
usb_interface *interface)
 
udl->udev = udev;
udl->drm.dev_private = udl;
+   drmm_add_final_kfree(>drm, udl);
 
r = udl_init(udl);
if (r) {
-   drm_dev_fini(>drm);
-   kfree(udl);
+   drm_dev_put(>drm);
return ERR_PTR(r);
}
 
-- 
2.25.1

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


[Intel-gfx] [PATCH 05/51] drm/mipi_dbi: Use drmm_add_final_kfree in all drivers

2020-03-23 Thread Daniel Vetter
They all share mipi_dbi_release so we need to switch them all
together. With this we can drop the final kfree from the release
function.

Aside, I think we could perhaps have a tiny additional helper for
these mipi_dbi drivers, the first few lines around devm_drm_dev_init
are all the same (except for the drm_driver pointer).

Acked-by: Sam Ravnborg 
Reviewed-by: Noralf Trønnes 
Tested-by: Noralf Trønnes 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Cc: Thomas Zimmermann 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Eric Anholt 
Cc: David Lechner 
Cc: Kamlesh Gurudasani 
Cc: "Noralf Trønnes" 
Cc: Sam Ravnborg 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_mipi_dbi.c  | 3 ---
 drivers/gpu/drm/tiny/hx8357d.c  | 2 ++
 drivers/gpu/drm/tiny/ili9225.c  | 2 ++
 drivers/gpu/drm/tiny/ili9341.c  | 2 ++
 drivers/gpu/drm/tiny/ili9486.c  | 2 ++
 drivers/gpu/drm/tiny/mi0283qt.c | 2 ++
 drivers/gpu/drm/tiny/st7586.c   | 2 ++
 drivers/gpu/drm/tiny/st7735r.c  | 2 ++
 8 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
index ea929bc1e663..98d0af8376fd 100644
--- a/drivers/gpu/drm/drm_mipi_dbi.c
+++ b/drivers/gpu/drm/drm_mipi_dbi.c
@@ -589,13 +589,10 @@ EXPORT_SYMBOL(mipi_dbi_dev_init);
  */
 void mipi_dbi_release(struct drm_device *drm)
 {
-   struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(drm);
-
DRM_DEBUG_DRIVER("\n");
 
drm_mode_config_cleanup(drm);
drm_dev_fini(drm);
-   kfree(dbidev);
 }
 EXPORT_SYMBOL(mipi_dbi_release);
 
diff --git a/drivers/gpu/drm/tiny/hx8357d.c b/drivers/gpu/drm/tiny/hx8357d.c
index 9af8ff84974f..42bc5dadcb1c 100644
--- a/drivers/gpu/drm/tiny/hx8357d.c
+++ b/drivers/gpu/drm/tiny/hx8357d.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -236,6 +237,7 @@ static int hx8357d_probe(struct spi_device *spi)
kfree(dbidev);
return ret;
}
+   drmm_add_final_kfree(drm, dbidev);
 
drm_mode_config_init(drm);
 
diff --git a/drivers/gpu/drm/tiny/ili9225.c b/drivers/gpu/drm/tiny/ili9225.c
index 802fb8dde1b6..aae88dc5b3f7 100644
--- a/drivers/gpu/drm/tiny/ili9225.c
+++ b/drivers/gpu/drm/tiny/ili9225.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -387,6 +388,7 @@ static int ili9225_probe(struct spi_device *spi)
kfree(dbidev);
return ret;
}
+   drmm_add_final_kfree(drm, dbidev);
 
drm_mode_config_init(drm);
 
diff --git a/drivers/gpu/drm/tiny/ili9341.c b/drivers/gpu/drm/tiny/ili9341.c
index 33b51dc7faa8..7d40cb4ff72b 100644
--- a/drivers/gpu/drm/tiny/ili9341.c
+++ b/drivers/gpu/drm/tiny/ili9341.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -194,6 +195,7 @@ static int ili9341_probe(struct spi_device *spi)
kfree(dbidev);
return ret;
}
+   drmm_add_final_kfree(drm, dbidev);
 
drm_mode_config_init(drm);
 
diff --git a/drivers/gpu/drm/tiny/ili9486.c b/drivers/gpu/drm/tiny/ili9486.c
index 532560aebb1e..9515eed2625c 100644
--- a/drivers/gpu/drm/tiny/ili9486.c
+++ b/drivers/gpu/drm/tiny/ili9486.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -208,6 +209,7 @@ static int ili9486_probe(struct spi_device *spi)
kfree(dbidev);
return ret;
}
+   drmm_add_final_kfree(drm, dbidev);
 
drm_mode_config_init(drm);
 
diff --git a/drivers/gpu/drm/tiny/mi0283qt.c b/drivers/gpu/drm/tiny/mi0283qt.c
index e2cfd9a17143..8555a56bce8c 100644
--- a/drivers/gpu/drm/tiny/mi0283qt.c
+++ b/drivers/gpu/drm/tiny/mi0283qt.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -198,6 +199,7 @@ static int mi0283qt_probe(struct spi_device *spi)
kfree(dbidev);
return ret;
}
+   drmm_add_final_kfree(drm, dbidev);
 
drm_mode_config_init(drm);
 
diff --git a/drivers/gpu/drm/tiny/st7586.c b/drivers/gpu/drm/tiny/st7586.c
index 9ef559dd3191..427c2561f5f4 100644
--- a/drivers/gpu/drm/tiny/st7586.c
+++ b/drivers/gpu/drm/tiny/st7586.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -328,6 +329,7 @@ static int st7586_probe(struct spi_device *spi)
kfree(dbidev);
return ret;
}
+   drmm_add_final_kfree(drm, dbidev);
 
drm_mode_config_init(drm);
 
diff --git a/drivers/gpu/drm/tiny/st7735r.c b/drivers/gpu/drm/tiny/st7735r.c
index 18b925df6e51..b447235c3d47 100644
--- a/drivers/gpu/drm/tiny/st7735r.c
+++ b/drivers/gpu/drm/tiny/st7735r.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define ST7735R_FRMCTR10xb1
@@ -209,6 +210,7 @@ static int st7735r_probe(struct spi_device *spi)
kfree(dbidev);
return ret;
 

[Intel-gfx] [PATCH 16/51] drm/ingenic: Use drmm_add_final_kfree

2020-03-23 Thread Daniel Vetter
With this we can drop the final kfree from the release function.

Acked-by: Sam Ravnborg 
Reviewed-by: Paul Cercueil 
Signed-off-by: Daniel Vetter 
Cc: Paul Cercueil 
---
 drivers/gpu/drm/ingenic/ingenic-drm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c 
b/drivers/gpu/drm/ingenic/ingenic-drm.c
index 9dfe7cb530e1..e2c832eb4e9a 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -490,11 +491,8 @@ static irqreturn_t ingenic_drm_irq_handler(int irq, void 
*arg)
 
 static void ingenic_drm_release(struct drm_device *drm)
 {
-   struct ingenic_drm *priv = drm_device_get_priv(drm);
-
drm_mode_config_cleanup(drm);
drm_dev_fini(drm);
-   kfree(priv);
 }
 
 static int ingenic_drm_enable_vblank(struct drm_crtc *crtc)
@@ -639,6 +637,7 @@ static int ingenic_drm_probe(struct platform_device *pdev)
kfree(priv);
return ret;
}
+   drmm_add_final_kfree(drm, priv);
 
drm_mode_config_init(drm);
drm->mode_config.min_width = 0;
-- 
2.25.1

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


[Intel-gfx] [PATCH 07/51] drm/qxl: Use drmm_add_final_kfree

2020-03-23 Thread Daniel Vetter
With this we can drop the final kfree from the release function.

Acked-by: Gerd Hoffmann 
Signed-off-by: Daniel Vetter 
Cc: Dave Airlie 
Cc: Gerd Hoffmann 
Cc: virtualizat...@lists.linux-foundation.org
Cc: spice-de...@lists.freedesktop.org
---
 drivers/gpu/drm/qxl/qxl_drv.c | 2 --
 drivers/gpu/drm/qxl/qxl_kms.c | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 4fda3f9b29f4..09102e2efabc 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -144,8 +144,6 @@ static void qxl_drm_release(struct drm_device *dev)
 */
qxl_modeset_fini(qdev);
qxl_device_fini(qdev);
-   dev->dev_private = NULL;
-   kfree(qdev);
 }
 
 static void
diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
index 70b20ee4741a..09d7b5f6d172 100644
--- a/drivers/gpu/drm/qxl/qxl_kms.c
+++ b/drivers/gpu/drm/qxl/qxl_kms.c
@@ -27,6 +27,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 #include "qxl_drv.h"
@@ -121,6 +122,7 @@ int qxl_device_init(struct qxl_device *qdev,
qdev->ddev.pdev = pdev;
pci_set_drvdata(pdev, >ddev);
qdev->ddev.dev_private = qdev;
+   drmm_add_final_kfree(>ddev, qdev);
 
mutex_init(>gem.mutex);
mutex_init(>update_area_mutex);
-- 
2.25.1

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


[Intel-gfx] [PATCH 23/51] drm: Manage drm_gem_init with drmm_

2020-03-23 Thread Daniel Vetter
We might want to look into pushing this down into drm_mm_init, but
that would mean rolling out return codes to a pile of functions
unfortunately. So let's leave that for now.

Acked-by: Sam Ravnborg 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_drv.c  |  8 +---
 drivers/gpu/drm/drm_gem.c  | 21 ++---
 drivers/gpu/drm/drm_internal.h |  1 -
 3 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 25fc2107057c..18e7f7389897 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -686,13 +686,10 @@ int drm_dev_init(struct drm_device *dev,
 
ret = drm_dev_set_unique(dev, dev_name(parent));
if (ret)
-   goto err_setunique;
+   goto err;
 
return 0;
 
-err_setunique:
-   if (drm_core_check_feature(dev, DRIVER_GEM))
-   drm_gem_destroy(dev);
 err:
drm_managed_release(dev);
 
@@ -754,9 +751,6 @@ EXPORT_SYMBOL(devm_drm_dev_init);
 void drm_dev_fini(struct drm_device *dev)
 {
drm_vblank_cleanup(dev);
-
-   if (drm_core_check_feature(dev, DRIVER_GEM))
-   drm_gem_destroy(dev);
 }
 EXPORT_SYMBOL(drm_dev_fini);
 
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 855911bf2a39..63bfd97e69d8 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -77,6 +78,12 @@
  * up at a later date, and as our interface with shmfs for memory allocation.
  */
 
+static void
+drm_gem_init_release(struct drm_device *dev, void *ptr)
+{
+   drm_vma_offset_manager_destroy(dev->vma_offset_manager);
+}
+
 /**
  * drm_gem_init - Initialize the GEM device fields
  * @dev: drm_devic structure to initialize
@@ -89,7 +96,8 @@ drm_gem_init(struct drm_device *dev)
mutex_init(>object_name_lock);
idr_init_base(>object_name_idr, 1);
 
-   vma_offset_manager = kzalloc(sizeof(*vma_offset_manager), GFP_KERNEL);
+   vma_offset_manager = drmm_kzalloc(dev, sizeof(*vma_offset_manager),
+ GFP_KERNEL);
if (!vma_offset_manager) {
DRM_ERROR("out of memory\n");
return -ENOMEM;
@@ -100,16 +108,7 @@ drm_gem_init(struct drm_device *dev)
DRM_FILE_PAGE_OFFSET_START,
DRM_FILE_PAGE_OFFSET_SIZE);
 
-   return 0;
-}
-
-void
-drm_gem_destroy(struct drm_device *dev)
-{
-
-   drm_vma_offset_manager_destroy(dev->vma_offset_manager);
-   kfree(dev->vma_offset_manager);
-   dev->vma_offset_manager = NULL;
+   return drmm_add_action(dev, drm_gem_init_release, NULL);
 }
 
 /**
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index 23ba15773097..a40a0222419e 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -144,7 +144,6 @@ void drm_sysfs_lease_event(struct drm_device *dev);
 /* drm_gem.c */
 struct drm_gem_object;
 int drm_gem_init(struct drm_device *dev);
-void drm_gem_destroy(struct drm_device *dev);
 int drm_gem_handle_create_tail(struct drm_file *file_priv,
   struct drm_gem_object *obj,
   u32 *handlep);
-- 
2.25.1

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


[Intel-gfx] [PATCH 08/51] drm/i915: Use drmm_add_final_kfree

2020-03-23 Thread Daniel Vetter
With this we can drop the final kfree from the release function.

The mock device in the selftests needed it's pci_device split
up from the drm_device. In the future we could simplify this again
by allocating the pci_device as a managed allocation too.

v2: I overlooked that i915_driver_destroy is also called in the
unwind code of the error path. There we need a drm_dev_put.
Similar for the mock object.

Now the problem with that is that the drm_driver->release callbacks
for both the real driver and the mock one assume everything has been
set up. Hence going through that path for a partially set up driver
will result in issues. Quickest fix is to disable the ->release() hook
until the driver is fully initialized, and keep the onion unwinding.
Long term would be cleanest to move everything over to drmm_ release
actions, but that's a lot of work for a big driver like i915. Plus
more core work needed first anyway.

v3: Fix i915_drm pointer wrangling in mock_gem_device. Also switch
over to start using drm_dev_put() to clean up even on the error path.
Aside I think the current error path is leaking the allocation.

v4: more fixes for intel-gfx-ci, some if it damage from v3 :-/

Signed-off-by: Daniel Vetter 
Cc: Jani Nikula 
Cc: Joonas Lahtinen 
Cc: Rodrigo Vivi 
Cc: Chris Wilson 
Cc: Tvrtko Ursulin 
Cc: Matthew Auld 
Cc: Andi Shyti 
Cc: Mika Kuoppala 
Cc: Daniele Ceraolo Spurio 
Cc: Daniel Vetter 
Cc: Abdiel Janulgue 
Cc: intel-gfx@lists.freedesktop.org
---
 drivers/gpu/drm/i915/i915_drv.c   | 10 ++-
 drivers/gpu/drm/i915/i915_drv.h   |  3 ++
 .../gpu/drm/i915/selftests/mock_gem_device.c  | 30 ++-
 3 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 4792051e9e2e..481313536b5a 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "display/intel_acpi.h"
@@ -890,6 +891,8 @@ i915_driver_create(struct pci_dev *pdev, const struct 
pci_device_id *ent)
return ERR_PTR(err);
}
 
+   drmm_add_final_kfree(>drm, i915);
+
i915->drm.pdev = pdev;
pci_set_drvdata(pdev, i915);
 
@@ -908,7 +911,6 @@ static void i915_driver_destroy(struct drm_i915_private 
*i915)
struct pci_dev *pdev = i915->drm.pdev;
 
drm_dev_fini(>drm);
-   kfree(i915);
 }
 
 /**
@@ -992,6 +994,8 @@ int i915_driver_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
i915_welcome_messages(i915);
 
+   i915->do_release = true;
+
return 0;
 
 out_cleanup_irq:
@@ -1012,6 +1016,7 @@ int i915_driver_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 out_fini:
i915_probe_error(i915, "Device initialization failed (%d)\n", ret);
i915_driver_destroy(i915);
+   drm_dev_put(>drm);
return ret;
 }
 
@@ -1051,6 +1056,9 @@ static void i915_driver_release(struct drm_device *dev)
struct drm_i915_private *dev_priv = to_i915(dev);
struct intel_runtime_pm *rpm = _priv->runtime_pm;
 
+   if (!dev_priv->do_release)
+   return;
+
disable_rpm_wakeref_asserts(rpm);
 
i915_gem_driver_release(dev_priv);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a7ea1d855359..7ae652723ed7 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -821,6 +821,9 @@ struct i915_selftest_stash {
 struct drm_i915_private {
struct drm_device drm;
 
+   /* FIXME: Device release actions should all be moved to drmm_ */
+   bool do_release;
+
const struct intel_device_info __info; /* Use INTEL_INFO() to access. */
struct intel_runtime_info __runtime; /* Use RUNTIME_INFO() to access. */
struct intel_driver_caps caps;
diff --git a/drivers/gpu/drm/i915/selftests/mock_gem_device.c 
b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
index 754d0eb6beaa..acf889e4b993 100644
--- a/drivers/gpu/drm/i915/selftests/mock_gem_device.c
+++ b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
@@ -25,6 +25,8 @@
 #include 
 #include 
 
+#include 
+
 #include "gt/intel_gt.h"
 #include "gt/intel_gt_requests.h"
 #include "gt/mock_engine.h"
@@ -55,6 +57,9 @@ static void mock_device_release(struct drm_device *dev)
 {
struct drm_i915_private *i915 = to_i915(dev);
 
+   if (!i915->do_release)
+   goto out;
+
mock_device_flush(i915);
intel_gt_driver_remove(>gt);
 
@@ -72,7 +77,9 @@ static void mock_device_release(struct drm_device *dev)
drm_mode_config_cleanup(>drm);
 
drm_dev_fini(>drm);
+out:
put_device(>drm.pdev->dev);
+   i915->drm.pdev = NULL;
 }
 
 static struct drm_driver mock_driver = {
@@ -114,9 +121,14 @@ struct drm_i915_private *mock_gem_device(void)
struct pci_dev *pdev;
int err;
 
-   pdev = kzalloc(sizeof(*pdev) + 

[Intel-gfx] [PATCH 11/51] drm/tidss: Use drmm_add_final_kfree

2020-03-23 Thread Daniel Vetter
With this we can drop the final kfree from the release function.

Acked-by: Jyri Sarha 
Signed-off-by: Daniel Vetter 
Cc: Jyri Sarha 
Cc: Tomi Valkeinen 
---
 drivers/gpu/drm/tidss/tidss_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tidss/tidss_drv.c 
b/drivers/gpu/drm/tidss/tidss_drv.c
index d95e4be2c7b9..32a85628dbec 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.c
+++ b/drivers/gpu/drm/tidss/tidss_drv.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "tidss_dispc.h"
@@ -109,8 +110,6 @@ static void tidss_release(struct drm_device *ddev)
tidss_modeset_cleanup(tidss);
 
drm_dev_fini(ddev);
-
-   kfree(tidss);
 }
 
 DEFINE_DRM_GEM_CMA_FOPS(tidss_fops);
@@ -154,6 +153,7 @@ static int tidss_probe(struct platform_device *pdev)
kfree(ddev);
return ret;
}
+   drmm_add_final_kfree(ddev, tidss);
 
tidss->dev = dev;
tidss->feat = of_device_get_match_data(dev);
-- 
2.25.1

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


[Intel-gfx] [PATCH 00/51] drm_device managed resources, v5

2020-03-23 Thread Daniel Vetter
Hi all,

Another round, another set of polish all over. intel-gfx-ci was happy last
time around (after I fixed a fumble), so really just review and comments
needed now. There's still a few patches at the beginning holding the
entire thing up and preventing merging of the driver patches which have
acks/r-b already.

Thanks, Daniel

Daniel Vetter (51):
  mm/sl[uo]b: export __kmalloc_track(_node)_caller
  drm/i915: Don't clear drvdata in ->release
  drm: add managed resources tied to drm_device
  drm: Set final_kfree in drm_dev_alloc
  drm/mipi_dbi: Use drmm_add_final_kfree in all drivers
  drm/udl: Use drmm_add_final_kfree
  drm/qxl: Use drmm_add_final_kfree
  drm/i915: Use drmm_add_final_kfree
  drm/cirrus: Use drmm_add_final_kfree
  drm/v3d: Use drmm_add_final_kfree
  drm/tidss: Use drmm_add_final_kfree
  drm/mcde: Use drmm_add_final_kfree
  drm/vgem: Use drmm_add_final_kfree
  drm/vkms: Use drmm_add_final_kfree
  drm/repaper: Use drmm_add_final_kfree
  drm/ingenic: Use drmm_add_final_kfree
  drm/gm12u320: Use drmm_add_final_kfree
  drm/: Use drmm_add_final_kfree
  drm: Cleanups after drmm_add_final_kfree rollout
  drm: Handle dev->unique with drmm_
  drm: Use drmm_ for drm_dev_init cleanup
  drm: manage drm_minor cleanup with drmm_
  drm: Manage drm_gem_init with drmm_
  drm: Manage drm_vblank_cleanup with drmm_
  drm: Garbage collect drm_dev_fini
  drm: Manage drm_mode_config_init with drmm_
  drm/bochs: Remove leftover drm_atomic_helper_shutdown
  drm/bochs: Drop explicit drm_mode_config_cleanup
  drm/cirrus: Drop explicit drm_mode_config_cleanup call
  drm/cirrus: Fully embrace devm_
  drm/ingenic: Drop explicit drm_mode_config_cleanup call
  drm/mcde: Drop explicit drm_mode_config_cleanup call
  drm/mcde: More devm_drm_dev_init
  drm/meson: Drop explicit drm_mode_config_cleanup call
  drm/pl111: Drop explicit drm_mode_config_cleanup call
  drm/rcar-du: Drop explicit drm_mode_config_cleanup call
  drm/rockchip: Drop explicit drm_mode_config_cleanup call
  drm/stm: Drop explicit drm_mode_config_cleanup call
  drm/shmob: Drop explicit drm_mode_config_cleanup call
  drm/mtk: Drop explicit drm_mode_config_cleanup call
  drm/tidss: Drop explicit drm_mode_config_cleanup call
  drm/gm12u320: More drmm_
  drm/gm12u320: Use devm_drm_dev_init
  drm/gm12u320: Use helpers for shutdown/suspend/resume
  drm/gm12u320: Simplify upload work
  drm/repaper: Drop explicit drm_mode_config_cleanup call
  drm/mipi-dbi: Move drm_mode_config_init into mipi library
  drm/mipi-dbi: Drop explicit drm_mode_config_cleanup call
  drm/udl: Drop explicit drm_mode_config_cleanup call
  drm/udl: drop drm_driver.release hook
  drm: Add docs for managed resources

 Documentation/gpu/drm-internals.rst   |  12 +
 Documentation/gpu/drm-kms.rst |   2 +-
 drivers/gpu/drm/Makefile  |   3 +-
 .../gpu/drm/arm/display/komeda/komeda_kms.c   |   2 +
 drivers/gpu/drm/armada/armada_drv.c   |   2 +
 drivers/gpu/drm/bochs/bochs.h |   1 -
 drivers/gpu/drm/bochs/bochs_drv.c |   6 +-
 drivers/gpu/drm/bochs/bochs_kms.c |  15 +-
 drivers/gpu/drm/cirrus/cirrus.c   |  74 ++---
 drivers/gpu/drm/drm_drv.c | 215 ++
 drivers/gpu/drm/drm_gem.c |  21 +-
 drivers/gpu/drm/drm_internal.h|   5 +-
 drivers/gpu/drm/drm_managed.c | 276 ++
 drivers/gpu/drm/drm_mipi_dbi.c|  24 +-
 drivers/gpu/drm/drm_mode_config.c |  23 +-
 drivers/gpu/drm/drm_vblank.c  |  31 +-
 drivers/gpu/drm/i915/i915_drv.c   |  22 +-
 drivers/gpu/drm/i915/i915_drv.h   |   3 +
 .../gpu/drm/i915/selftests/mock_gem_device.c  |  32 +-
 drivers/gpu/drm/ingenic/ingenic-drm.c |  17 +-
 drivers/gpu/drm/mcde/mcde_drv.c   |  35 +--
 drivers/gpu/drm/mediatek/mtk_drm_drv.c|   9 +-
 drivers/gpu/drm/meson/meson_drv.c |   5 +-
 drivers/gpu/drm/pl111/pl111_drv.c |  12 +-
 drivers/gpu/drm/qxl/qxl_drv.c |   2 -
 drivers/gpu/drm/qxl/qxl_kms.c |   2 +
 drivers/gpu/drm/rcar-du/rcar_du_drv.c |   1 -
 drivers/gpu/drm/rcar-du/rcar_du_kms.c |   4 +-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  14 +-
 drivers/gpu/drm/shmobile/shmob_drm_drv.c  |   2 -
 drivers/gpu/drm/shmobile/shmob_drm_kms.c  |   6 +-
 drivers/gpu/drm/stm/drv.c |  10 +-
 drivers/gpu/drm/tidss/tidss_drv.c |  10 +-
 drivers/gpu/drm/tidss/tidss_kms.c |  19 +-
 drivers/gpu/drm/tidss/tidss_kms.h |   1 -
 drivers/gpu/drm/tiny/gm12u320.c   | 226 ++
 drivers/gpu/drm/tiny/hx8357d.c|   5 +-
 drivers/gpu/drm/tiny/ili9225.c|   5 +-
 drivers/gpu/drm/tiny/ili9341.c|   5 +-
 drivers/gpu/drm/tiny/ili9486.c|   5 +-
 drivers/gpu/drm/tiny/mi0283qt.c 

Re: [Intel-gfx] [PATCH v19 4/8] drm/i915: Refactor intel_can_enable_sagv

2020-03-23 Thread Ville Syrjälä
On Mon, Mar 23, 2020 at 04:36:16PM +0200, Lisovskiy, Stanislav wrote:
> On Mon, Mar 23, 2020 at 04:18:36PM +0200, Ville Syrjälä wrote:
> > On Fri, Mar 20, 2020 at 02:51:41PM +0200, Lisovskiy, Stanislav wrote:
> > > On Wed, Mar 11, 2020 at 06:31:30PM +0200, Ville Syrjälä wrote:
> > > > On Mon, Mar 09, 2020 at 06:12:00PM +0200, Stanislav Lisovskiy wrote:
> > > > > Currently intel_can_enable_sagv function contains
> > > > > a mix of workarounds for different platforms
> > > > > some of them are not valid for gens >= 11 already,
> > > > > so lets split it into separate functions.
> > > > > 
> > > > > v2:
> > > > > - Rework watermark calculation algorithm to
> > > > >   attempt to calculate Level 0 watermark
> > > > >   with added sagv block time latency and
> > > > >   check if it fits in DBuf in order to
> > > > >   determine if SAGV can be enabled already
> > > > >   at this stage, just as BSpec 49325 states.
> > > > >   if that fails rollback to usual Level 0
> > > > >   latency and disable SAGV.
> > > > > - Remove unneeded tabs(James Ausmus)
> > > > > 
> > > > > v3: Rebased the patch
> > > > > 
> > > > > v4: - Added back interlaced check for Gen12 and
> > > > >   added separate function for TGL SAGV check
> > > > >   (thanks to James Ausmus for spotting)
> > > > > - Removed unneeded gen check
> > > > > - Extracted Gen12 SAGV decision making code
> > > > >   to a separate function from skl_compute_wm
> > > > > 
> > > > > v5: - Added SAGV global state to dev_priv, because
> > > > >   we need to track all pipes, not only those
> > > > >   in atomic state. Each pipe has now correspondent
> > > > >   bit mask reflecting, whether it can tolerate
> > > > >   SAGV or not(thanks to Ville Syrjala for suggestions).
> > > > > - Now using active flag instead of enable in crc
> > > > >   usage check.
> > > > > 
> > > > > v6: - Fixed rebase conflicts
> > > > > 
> > > > > v7: - kms_cursor_legacy seems to get broken because of multiple memcpy
> > > > >   calls when copying level 0 water marks for enabled SAGV, to
> > > > >   fix this now simply using that field right away, without 
> > > > > copying,
> > > > >   for that introduced a new wm_level accessor which decides which
> > > > >   wm_level to return based on SAGV state.
> > > > > 
> > > > > v8: - Protect crtc_sagv_mask same way as we do for other global state
> > > > >   changes: i.e check if changes are needed, then grab all crtc 
> > > > > locks
> > > > >   to serialize the changes(Ville Syrjälä)
> > > > > - Add crtc_sagv_mask caching in order to avoid needless 
> > > > > recalculations
> > > > >   (Matthew Roper)
> > > > > - Put back Gen12 SAGV switch in order to get it enabled in 
> > > > > separate
> > > > >   patch(Matthew Roper)
> > > > > - Rename *_set_sagv_mask to *_compute_sagv_mask(Matthew Roper)
> > > > > - Check if there are no active pipes in intel_can_enable_sagv
> > > > >   instead of platform specific functions(Matthew Roper), same
> > > > >   for intel_has_sagv check.
> > > > > 
> > > > > v9  - Switched to u8 for crtc_sagv_mask(Ville Syrjälä)
> > > > > - crtc_sagv_mask now is pipe_sagv_mask(Ville Syrjälä)
> > > > > - Extracted sagv checking logic from skl/icl/tgl_compute_sagv_mask
> > > > > - Extracted skl_plane_wm_level function and passing latency to
> > > > >   separate patches(Ville Syrjälä)
> > > > > - Removed part of unneeded copy-paste from 
> > > > > tgl_check_pipe_fits_sagv_wm
> > > > >   (Ville Syrjälä)
> > > > > - Now using simple assignment for sagv_wm0 as it contains only
> > > > >   pod types and no pointers(Ville Syrjälä)
> > > > > - Fixed intel_can_enable_sagv not to do double duty, now it only
> > > > >   check SAGV bits by ANDing those between local and global state.
> > > > >   The SAGV masks are now computed after watermarks are available,
> > > > >   in order to be able to figure out if ddb ranges are fitting 
> > > > > nicely.
> > > > >   (Ville Syrjälä)
> > > > > - Now having uv_sagv_wm0 and sagv_wm0, otherwise we have wrong 
> > > > > logic
> > > > >   when using skl_plane_wm_level accessor, as we had previously for
> > > > >   Gen11+ color plane and regular wm levels, so probably both
> > > > >   has to be recalculated with additional SAGV block time for 
> > > > > Level 0.
> > > > > 
> > > > > v10: - Starting to use new global state for storing pipe_sagv_mask
> > > > > 
> > > > > v11: - Fixed rebase conflict with recent drm-tip
> > > > >  - Check if we really need to recalculate SAGV mask, otherwise
> > > > >bail out without making any changes.
> > > > >  - Use cached SAGV result, instead of recalculating it everytime,
> > > > >if bw_state hasn't changed.
> > > > > 
> > > > > v12: - Removed WARN from intel_can_enable_sagv, in some of the commits
> > > > >if we don't recalculated watermarks, 

[Intel-gfx] [PATCH 09/51] drm/cirrus: Use drmm_add_final_kfree

2020-03-23 Thread Daniel Vetter
With this we can drop the final kfree from the release function.

I also noticed that cirrus forgot to call drm_dev_fini().

v2: Don't call kfree(cirrus) after we've handed overship of that to
drm_device and the drmm_ stuff.

Acked-by: Gerd Hoffmann 
Acked-by: Sam Ravnborg 
Signed-off-by: Daniel Vetter 
Cc: Dave Airlie 
Cc: Gerd Hoffmann 
Cc: Daniel Vetter 
Cc: "Noralf Trønnes" 
Cc: Linus Walleij 
Cc: Sam Ravnborg 
Cc: Thomas Zimmermann 
Cc: virtualizat...@lists.linux-foundation.org
---
 drivers/gpu/drm/cirrus/cirrus.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index d2ff63ce8eaf..2232556ce34c 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -527,10 +528,8 @@ static void cirrus_mode_config_init(struct cirrus_device 
*cirrus)
 
 static void cirrus_release(struct drm_device *dev)
 {
-   struct cirrus_device *cirrus = dev->dev_private;
-
drm_mode_config_cleanup(dev);
-   kfree(cirrus);
+   drm_dev_fini(dev);
 }
 
 DEFINE_DRM_GEM_FOPS(cirrus_fops);
@@ -575,9 +574,12 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
 
dev = >dev;
ret = drm_dev_init(dev, _driver, >dev);
-   if (ret)
-   goto err_free_cirrus;
+   if (ret) {
+   kfree(cirrus);
+   goto err_pci_release;
+   }
dev->dev_private = cirrus;
+   drmm_add_final_kfree(dev, cirrus);
 
ret = -ENOMEM;
cirrus->vram = ioremap(pci_resource_start(pdev, 0),
@@ -618,8 +620,6 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
iounmap(cirrus->vram);
 err_dev_put:
drm_dev_put(dev);
-err_free_cirrus:
-   kfree(cirrus);
 err_pci_release:
pci_release_regions(pdev);
return ret;
-- 
2.25.1

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


[Intel-gfx] [PATCH 12/51] drm/mcde: Use drmm_add_final_kfree

2020-03-23 Thread Daniel Vetter
With this we can drop the final kfree from the release function.

Reviewed-by: Linus Walleij 
Signed-off-by: Daniel Vetter 
Cc: Linus Walleij 
---
 drivers/gpu/drm/mcde/mcde_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
index f28cb7a576ba..7474481503a1 100644
--- a/drivers/gpu/drm/mcde/mcde_drv.c
+++ b/drivers/gpu/drm/mcde/mcde_drv.c
@@ -72,6 +72,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -223,7 +224,6 @@ static void mcde_release(struct drm_device *drm)
 
drm_mode_config_cleanup(drm);
drm_dev_fini(drm);
-   kfree(mcde);
 }
 
 DEFINE_DRM_GEM_CMA_FOPS(drm_fops);
@@ -330,6 +330,7 @@ static int mcde_probe(struct platform_device *pdev)
}
drm = >drm;
drm->dev_private = mcde;
+   drmm_add_final_kfree(drm, mcde);
platform_set_drvdata(pdev, drm);
 
/* Enable continuous updates: this is what Linux' framebuffer expects */
-- 
2.25.1

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


[Intel-gfx] [PATCH 14/51] drm/vkms: Use drmm_add_final_kfree

2020-03-23 Thread Daniel Vetter
With this we can drop the final kfree from the release function.

v2: After drm_dev_init/drmm_add_final_kfree we need to clean up
everything through a drm_dev_put. Rework the unwind code to match
that.

Reviewed-by: Rodrigo Siqueira 
Tested-by: Rodrigo Siqueira 
Signed-off-by: Daniel Vetter 
Cc: Rodrigo Siqueira 
Cc: Haneen Mohammed 
Cc: Daniel Vetter 
---
 drivers/gpu/drm/vkms/vkms_drv.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
index 860de052e820..2f35fe789343 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.c
+++ b/drivers/gpu/drm/vkms/vkms_drv.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -158,13 +159,14 @@ static int __init vkms_init(void)
   _device->platform->dev);
if (ret)
goto out_unregister;
+   drmm_add_final_kfree(_device->drm, vkms_device);
 
ret = dma_coerce_mask_and_coherent(vkms_device->drm.dev,
   DMA_BIT_MASK(64));
 
if (ret) {
DRM_ERROR("Could not initialize DMA support\n");
-   goto out_fini;
+   goto out_put;
}
 
vkms_device->drm.irq_enabled = true;
@@ -172,25 +174,25 @@ static int __init vkms_init(void)
ret = drm_vblank_init(_device->drm, 1);
if (ret) {
DRM_ERROR("Failed to vblank\n");
-   goto out_fini;
+   goto out_put;
}
 
ret = vkms_modeset_init(vkms_device);
if (ret)
-   goto out_fini;
+   goto out_put;
 
ret = drm_dev_register(_device->drm, 0);
if (ret)
-   goto out_fini;
+   goto out_put;
 
return 0;
 
-out_fini:
-   drm_dev_fini(_device->drm);
+out_put:
+   drm_dev_put(_device->drm);
+   return ret;
 
 out_unregister:
platform_device_unregister(vkms_device->platform);
-
 out_free:
kfree(vkms_device);
return ret;
@@ -205,8 +207,6 @@ static void __exit vkms_exit(void)
 
drm_dev_unregister(_device->drm);
drm_dev_put(_device->drm);
-
-   kfree(vkms_device);
 }
 
 module_init(vkms_init);
-- 
2.25.1

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


[Intel-gfx] [PATCH 10/51] drm/v3d: Use drmm_add_final_kfree

2020-03-23 Thread Daniel Vetter
With this we can drop the final kfree from the release function.

I also noticed that the unwind code is wrong, after drm_dev_init the
drm_device owns the v3d allocation, so the kfree(v3d) is a double-free.
Reorder the setup to fix this issue.

After a bit more prep in drivers and drm core v3d should be able to
switch over to devm_drm_dev_init, which should clean this up further.

Acked-by: Eric Anholt 
Signed-off-by: Daniel Vetter 
Cc: Eric Anholt 
---
 drivers/gpu/drm/v3d/v3d_drv.c | 38 ++-
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c
index eaa8e9682373..8d0c0daaac81 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.c
+++ b/drivers/gpu/drm/v3d/v3d_drv.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "v3d_drv.h"
@@ -257,13 +258,23 @@ static int v3d_platform_drm_probe(struct platform_device 
*pdev)
v3d->pdev = pdev;
drm = >drm;
 
+   ret = drm_dev_init(>drm, _drm_driver, dev);
+   if (ret) {
+   kfree(v3d);
+   return ret;
+   }
+
+   platform_set_drvdata(pdev, drm);
+   drm->dev_private = v3d;
+   drmm_add_final_kfree(drm, v3d);
+
ret = map_regs(v3d, >hub_regs, "hub");
if (ret)
-   goto dev_free;
+   goto dev_destroy;
 
ret = map_regs(v3d, >core_regs[0], "core0");
if (ret)
-   goto dev_free;
+   goto dev_destroy;
 
mmu_debug = V3D_READ(V3D_MMU_DEBUG_INFO);
dev->coherent_dma_mask =
@@ -281,21 +292,21 @@ static int v3d_platform_drm_probe(struct platform_device 
*pdev)
ret = PTR_ERR(v3d->reset);
 
if (ret == -EPROBE_DEFER)
-   goto dev_free;
+   goto dev_destroy;
 
v3d->reset = NULL;
ret = map_regs(v3d, >bridge_regs, "bridge");
if (ret) {
dev_err(dev,
"Failed to get reset control or bridge regs\n");
-   goto dev_free;
+   goto dev_destroy;
}
}
 
if (v3d->ver < 41) {
ret = map_regs(v3d, >gca_regs, "gca");
if (ret)
-   goto dev_free;
+   goto dev_destroy;
}
 
v3d->mmu_scratch = dma_alloc_wc(dev, 4096, >mmu_scratch_paddr,
@@ -303,23 +314,16 @@ static int v3d_platform_drm_probe(struct platform_device 
*pdev)
if (!v3d->mmu_scratch) {
dev_err(dev, "Failed to allocate MMU scratch page\n");
ret = -ENOMEM;
-   goto dev_free;
+   goto dev_destroy;
}
 
pm_runtime_use_autosuspend(dev);
pm_runtime_set_autosuspend_delay(dev, 50);
pm_runtime_enable(dev);
 
-   ret = drm_dev_init(>drm, _drm_driver, dev);
-   if (ret)
-   goto dma_free;
-
-   platform_set_drvdata(pdev, drm);
-   drm->dev_private = v3d;
-
ret = v3d_gem_init(drm);
if (ret)
-   goto dev_destroy;
+   goto dma_free;
 
ret = v3d_irq_init(v3d);
if (ret)
@@ -335,12 +339,10 @@ static int v3d_platform_drm_probe(struct platform_device 
*pdev)
v3d_irq_disable(v3d);
 gem_destroy:
v3d_gem_destroy(drm);
-dev_destroy:
-   drm_dev_put(drm);
 dma_free:
dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr);
-dev_free:
-   kfree(v3d);
+dev_destroy:
+   drm_dev_put(drm);
return ret;
 }
 
-- 
2.25.1

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


[Intel-gfx] [PATCH 02/51] drm/i915: Don't clear drvdata in ->release

2020-03-23 Thread Daniel Vetter
For two reasons:

- The driver core clears this already for us after we're unloaded in
  __device_release_driver().

- It's way too late, the drm_device ->release callback might massively
  outlive the underlying physical device, since a drm_device can't be
  kept alive by open drm_file or well really anything else userspace
  is still hanging onto. So if we clear this ourselves, we should
  clear it in the pci ->remove callback, not in the drm_device
  ->relase callback.

Looking at git history this was fixed in the driver core with

commit 0998d0631001288a5974afc0b2a5f568bcdecb4d
Author: Hans de Goede 
Date:   Wed May 23 00:09:34 2012 +0200

device-core: Ensure drvdata = NULL when no driver is bound

v2: Cite the core fix in the commit message (Chris).

Cc: Greg Kroah-Hartman 
Cc: Chris Wilson 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/i915/i915_drv.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 48ba37e35bea..4792051e9e2e 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -909,9 +909,6 @@ static void i915_driver_destroy(struct drm_i915_private 
*i915)
 
drm_dev_fini(>drm);
kfree(i915);
-
-   /* And make sure we never chase our dangling pointer from pci_dev */
-   pci_set_drvdata(pdev, NULL);
 }
 
 /**
-- 
2.25.1

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


[Intel-gfx] [PATCH 01/51] mm/sl[uo]b: export __kmalloc_track(_node)_caller

2020-03-23 Thread Daniel Vetter
slab does this already, and I want to use this in a memory allocation
tracker in drm for stuff that's tied to the lifetime of a drm_device,
not the underlying struct device. Kinda like devres, but for drm.

Acked-by: Andrew Morton 
Signed-off-by: Daniel Vetter 
Cc: Christoph Lameter 
Cc: Pekka Enberg 
Cc: David Rientjes 
Cc: Joonsoo Kim 
Cc: Andrew Morton 
Cc: linux...@kvack.org
--
I plan to merge this through drm-misc-next (with Andrew's ack) once
the remainder of the drm series is in shape.
-Daniel
---
 mm/slob.c | 2 ++
 mm/slub.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/mm/slob.c b/mm/slob.c
index fa53e9f73893..ac2aecfbc7a8 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -524,6 +524,7 @@ void *__kmalloc_track_caller(size_t size, gfp_t gfp, 
unsigned long caller)
 {
return __do_kmalloc_node(size, gfp, NUMA_NO_NODE, caller);
 }
+EXPORT_SYMBOL(__kmalloc_track_caller);
 
 #ifdef CONFIG_NUMA
 void *__kmalloc_node_track_caller(size_t size, gfp_t gfp,
@@ -531,6 +532,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfp,
 {
return __do_kmalloc_node(size, gfp, node, caller);
 }
+EXPORT_SYMBOL(__kmalloc_node_track_caller);
 #endif
 
 void kfree(const void *block)
diff --git a/mm/slub.c b/mm/slub.c
index 2988dae3f692..a937de5182cc 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4377,6 +4377,7 @@ void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, 
unsigned long caller)
 
return ret;
 }
+EXPORT_SYMBOL(__kmalloc_track_caller);
 
 #ifdef CONFIG_NUMA
 void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
@@ -4407,6 +4408,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t 
gfpflags,
 
return ret;
 }
+EXPORT_SYMBOL(__kmalloc_node_track_caller);
 #endif
 
 #ifdef CONFIG_SYSFS
-- 
2.25.1

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


Re: [Intel-gfx] [PATCH v2 5/5] drm/i915: Enable scaling filter for plane and CRTC

2020-03-23 Thread Ville Syrjälä
On Thu, Mar 19, 2020 at 03:51:03PM +0530, Pankaj Bharadiya wrote:
> GEN >= 10 hardware supports the programmable scaler filter.
> 
> Attach scaling filter property for CRTC and plane for GEN >= 10
> hardwares and program scaler filter based on the selected filter
> type.
> 
> changes since v1:
> * None
> Changes since RFC:
> * Enable properties for GEN >= 10 platforms (Ville)
> * Do not round off the crtc co-ordinate (Danial Stone, Ville)
> * Add new functions to handle scaling filter setup (Ville)
> * Remove coefficient set 0 hardcoding.
> 
> Signed-off-by: Shashank Sharma 
> Signed-off-by: Ankit Nautiyal 
> Signed-off-by: Pankaj Bharadiya 
> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 32 ++--
>  drivers/gpu/drm/i915/display/intel_sprite.c  | 31 ++-
>  2 files changed, 60 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
> b/drivers/gpu/drm/i915/display/intel_display.c
> index 791dd908aa89..4b3387ee332e 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -6309,6 +6309,25 @@ void skl_scaler_setup_nearest_neighbor_filter(struct 
> drm_i915_private *dev_priv,
>   }
>  }
>  
> +static u32
> +skl_scaler_crtc_setup_filter(struct drm_i915_private *dev_priv, enum pipe 
> pipe,
> +   int id, int set, enum drm_crtc_scaling_filter filter)
> +{
> + u32 scaler_filter_ctl = PS_FILTER_MEDIUM;
> +
> + if (filter == DRM_CRTC_SCALING_FILTER_NEAREST_NEIGHBOR) {
> + skl_scaler_setup_nearest_neighbor_filter(dev_priv, pipe, id,
> +  set);
> + scaler_filter_ctl = PS_FILTER_PROGRAMMED |
> + PS_UV_VERT_FILTER_SELECT(set) |
> + PS_UV_HORZ_FILTER_SELECT(set) |
> + PS_Y_VERT_FILTER_SELECT(set) |
> + PS_Y_HORZ_FILTER_SELECT(set);
> +
> + }
> + return scaler_filter_ctl;

This function does too many things.

> +}
> +
>  static void skl_pfit_enable(const struct intel_crtc_state *crtc_state)
>  {
>   struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> @@ -6316,12 +6335,14 @@ static void skl_pfit_enable(const struct 
> intel_crtc_state *crtc_state)
>   enum pipe pipe = crtc->pipe;
>   const struct intel_crtc_scaler_state *scaler_state =
>   _state->scaler_state;
> + const struct drm_crtc_state *state = _state->uapi;

Pls don't add this kind of aliases. We're moving away from using the
drm_ types as much as possible.

>  
>   if (crtc_state->pch_pfit.enabled) {
>   u16 uv_rgb_hphase, uv_rgb_vphase;
>   int pfit_w, pfit_h, hscale, vscale;
>   unsigned long irqflags;
>   int id;
> + int scaler_filter_ctl;

It's a register value so u32. I'd also 
s/scaler_filter_ctl/filter_select/ or something like that.

Alternatively we could just call it ps_ctrl and have it contain
the full register value for that particular register.

>  
>   if (drm_WARN_ON(_priv->drm,
>   crtc_state->scaler_state.scaler_id < 0))
> @@ -6340,8 +6361,12 @@ static void skl_pfit_enable(const struct 
> intel_crtc_state *crtc_state)
>  
>   spin_lock_irqsave(_priv->uncore.lock, irqflags);
>  
> - intel_de_write_fw(dev_priv, SKL_PS_CTRL(pipe, id), PS_SCALER_EN 
> |
> -   PS_FILTER_MEDIUM | 
> scaler_state->scalers[id].mode);
> + scaler_filter_ctl =
> + skl_scaler_crtc_setup_filter(dev_priv, pipe, id, 0,
> + state->scaling_filter);
> + intel_de_write_fw(dev_priv, SKL_PS_CTRL(pipe, id),
> +   PS_SCALER_EN | scaler_filter_ctl |
> +   scaler_state->scalers[id].mode);
>   intel_de_write_fw(dev_priv, SKL_PS_VPHASE(pipe, id),
> PS_Y_PHASE(0) | 
> PS_UV_RGB_PHASE(uv_rgb_vphase));
>   intel_de_write_fw(dev_priv, SKL_PS_HPHASE(pipe, id),
> @@ -16777,6 +16802,9 @@ static int intel_crtc_init(struct drm_i915_private 
> *dev_priv, enum pipe pipe)
>   dev_priv->plane_to_crtc_mapping[i9xx_plane] = crtc;
>   }
>  
> + if (INTEL_GEN(dev_priv) >= 10)
> + drm_crtc_enable_scaling_filter(>base);
> +
>   intel_color_init(crtc);
>  
>   intel_crtc_crc_init(crtc);
> diff --git a/drivers/gpu/drm/i915/display/intel_sprite.c 
> b/drivers/gpu/drm/i915/display/intel_sprite.c
> index deda351719db..ac3fd9843ace 100644
> --- a/drivers/gpu/drm/i915/display/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/display/intel_sprite.c
> @@ -395,6 +395,26 @@ skl_plane_max_stride(struct intel_plane *plane,
>   return min(8192 * cpp, 32768);
>  }
>  
> +static u32
> +skl_scaler_plane_setup_filter(struct 

Re: [Intel-gfx] [PATCH v2 4/5] drm/i915/display: Add Nearest-neighbor based integer scaling support

2020-03-23 Thread Ville Syrjälä
On Thu, Mar 19, 2020 at 03:51:02PM +0530, Pankaj Bharadiya wrote:
> Integer scaling (IS) is a nearest-neighbor upscaling technique that
> simply scales up the existing pixels by an integer
> (i.e., whole number) multiplier.Nearest-neighbor (NN) interpolation
> works by filling in the missing color values in the upscaled image
> with that of the coordinate-mapped nearest source pixel value.
> 
> Both IS and NN preserve the clarity of the original image. Integer
> scaling is particularly useful for pixel art games that rely on
> sharp, blocky images to deliver their distinctive look.
> 
> Introduce skl_scaler_setup_nearest_neighbor_filter() function which
> configures the scaler filter coefficients to enable nearest-neighbor
> filtering.
> 
> Bspec: 49247
> 
> changes since v1:
> * Rearrange skl_scaler_setup_nearest_neighbor_filter() to iterate the
>   registers directly instead of the phases and taps (Ville)
> 
> changes since RFC:
> * Refine the skl_scaler_setup_nearest_neighbor_filter() logic (Ville)
> 
> Signed-off-by: Shashank Sharma 
> Signed-off-by: Ankit Nautiyal 
> Signed-off-by: Pankaj Bharadiya 
> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 72 
>  drivers/gpu/drm/i915/display/intel_display.h |  2 +
>  2 files changed, 74 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
> b/drivers/gpu/drm/i915/display/intel_display.c
> index 8f23c4d51c33..791dd908aa89 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -6237,6 +6237,78 @@ void skl_scaler_disable(const struct intel_crtc_state 
> *old_crtc_state)
>   skl_detach_scaler(crtc, i);
>  }
>  
> +static int skl_coef_tap(int i)
> +{
> + return i % 7;
> +}
> +
> +static u16 skl_nearest_filter_coef(int t)
> +{
> + return t == 3 ? 0x0800 : 0x3000;
> +}
> +
> +/**
> + *  Theory behind setting nearest-neighbor integer scaling:
> + *
> + *  17 phase of 7 taps requires 119 coefficients in 60 dwords per set.
> + *  The letter represents the filter tap (D is the center tap) and the number
> + *  represents the coefficient set for a phase (0-16).
> + *
> + * ++++
> + * |Index value | Data value coeffient 1 | Data value coeffient 2 |
> + * ++++
> + * |   00h  |  B0|  A0|
> + * ++++
> + * |   01h  |  D0|  C0|
> + * ++++
> + * |   02h  |  F0|  E0|
> + * ++++
> + * |   03h  |  A1|  G0|
> + * ++++
> + * |   04h  |  C1|  B1|
> + * ++++
> + * |   ...  |  ...   |  ...   |
> + * ++++
> + * |   38h  |  B16   |  A16   |
> + * ++++
> + * |   39h  |  D16   |  C16   |
> + * ++++
> + * |   3Ah  |  F16   |  C16   |
> + * ++++
> + * |   3Bh  |Reserved|  G16   |
> + * ++++
> + *
> + *  To enable nearest-neighbor scaling:  program scaler coefficents with
> + *  the center tap (Dxx) values set to 1 and all other values set to 0 as per
> + *  SCALER_COEFFICIENT_FORMAT
> + *
> + */
> +
> +void skl_scaler_setup_nearest_neighbor_filter(struct drm_i915_private 
> *dev_priv,
> +   enum pipe pipe, int id, int set)
> +{
> + int i;
> +
> + /*enable the index auto increment.*/

Pointless comment, and also misformatted.

> + intel_de_write_fw(dev_priv,
> +   SKL_PS_COEF_INDEX_SET(pipe, id, set),
> +   PS_COEE_INDEX_AUTO_INC);
> +
> + for (i = 0; i < 17 * 7; i += 2) {
> + u32 tmp;
> + int t;
> +
> + t = skl_coef_tap(i);
> + tmp = skl_nearest_filter_coef(t);
> +
> + t = skl_coef_tap(i+1);
> + tmp |= skl_nearest_filter_coef(t)<<16;

Missing spaces.

> +
> + intel_de_write_fw(dev_priv, 

Re: [Intel-gfx] [PATCH v19 4/8] drm/i915: Refactor intel_can_enable_sagv

2020-03-23 Thread Lisovskiy, Stanislav
On Mon, Mar 23, 2020 at 04:18:36PM +0200, Ville Syrjälä wrote:
> On Fri, Mar 20, 2020 at 02:51:41PM +0200, Lisovskiy, Stanislav wrote:
> > On Wed, Mar 11, 2020 at 06:31:30PM +0200, Ville Syrjälä wrote:
> > > On Mon, Mar 09, 2020 at 06:12:00PM +0200, Stanislav Lisovskiy wrote:
> > > > Currently intel_can_enable_sagv function contains
> > > > a mix of workarounds for different platforms
> > > > some of them are not valid for gens >= 11 already,
> > > > so lets split it into separate functions.
> > > > 
> > > > v2:
> > > > - Rework watermark calculation algorithm to
> > > >   attempt to calculate Level 0 watermark
> > > >   with added sagv block time latency and
> > > >   check if it fits in DBuf in order to
> > > >   determine if SAGV can be enabled already
> > > >   at this stage, just as BSpec 49325 states.
> > > >   if that fails rollback to usual Level 0
> > > >   latency and disable SAGV.
> > > > - Remove unneeded tabs(James Ausmus)
> > > > 
> > > > v3: Rebased the patch
> > > > 
> > > > v4: - Added back interlaced check for Gen12 and
> > > >   added separate function for TGL SAGV check
> > > >   (thanks to James Ausmus for spotting)
> > > > - Removed unneeded gen check
> > > > - Extracted Gen12 SAGV decision making code
> > > >   to a separate function from skl_compute_wm
> > > > 
> > > > v5: - Added SAGV global state to dev_priv, because
> > > >   we need to track all pipes, not only those
> > > >   in atomic state. Each pipe has now correspondent
> > > >   bit mask reflecting, whether it can tolerate
> > > >   SAGV or not(thanks to Ville Syrjala for suggestions).
> > > > - Now using active flag instead of enable in crc
> > > >   usage check.
> > > > 
> > > > v6: - Fixed rebase conflicts
> > > > 
> > > > v7: - kms_cursor_legacy seems to get broken because of multiple memcpy
> > > >   calls when copying level 0 water marks for enabled SAGV, to
> > > >   fix this now simply using that field right away, without copying,
> > > >   for that introduced a new wm_level accessor which decides which
> > > >   wm_level to return based on SAGV state.
> > > > 
> > > > v8: - Protect crtc_sagv_mask same way as we do for other global state
> > > >   changes: i.e check if changes are needed, then grab all crtc locks
> > > >   to serialize the changes(Ville Syrjälä)
> > > > - Add crtc_sagv_mask caching in order to avoid needless 
> > > > recalculations
> > > >   (Matthew Roper)
> > > > - Put back Gen12 SAGV switch in order to get it enabled in separate
> > > >   patch(Matthew Roper)
> > > > - Rename *_set_sagv_mask to *_compute_sagv_mask(Matthew Roper)
> > > > - Check if there are no active pipes in intel_can_enable_sagv
> > > >   instead of platform specific functions(Matthew Roper), same
> > > >   for intel_has_sagv check.
> > > > 
> > > > v9  - Switched to u8 for crtc_sagv_mask(Ville Syrjälä)
> > > > - crtc_sagv_mask now is pipe_sagv_mask(Ville Syrjälä)
> > > > - Extracted sagv checking logic from skl/icl/tgl_compute_sagv_mask
> > > > - Extracted skl_plane_wm_level function and passing latency to
> > > >   separate patches(Ville Syrjälä)
> > > > - Removed part of unneeded copy-paste from 
> > > > tgl_check_pipe_fits_sagv_wm
> > > >   (Ville Syrjälä)
> > > > - Now using simple assignment for sagv_wm0 as it contains only
> > > >   pod types and no pointers(Ville Syrjälä)
> > > > - Fixed intel_can_enable_sagv not to do double duty, now it only
> > > >   check SAGV bits by ANDing those between local and global state.
> > > >   The SAGV masks are now computed after watermarks are available,
> > > >   in order to be able to figure out if ddb ranges are fitting 
> > > > nicely.
> > > >   (Ville Syrjälä)
> > > > - Now having uv_sagv_wm0 and sagv_wm0, otherwise we have wrong logic
> > > >   when using skl_plane_wm_level accessor, as we had previously for
> > > >   Gen11+ color plane and regular wm levels, so probably both
> > > >   has to be recalculated with additional SAGV block time for Level 
> > > > 0.
> > > > 
> > > > v10: - Starting to use new global state for storing pipe_sagv_mask
> > > > 
> > > > v11: - Fixed rebase conflict with recent drm-tip
> > > >  - Check if we really need to recalculate SAGV mask, otherwise
> > > >bail out without making any changes.
> > > >  - Use cached SAGV result, instead of recalculating it everytime,
> > > >if bw_state hasn't changed.
> > > > 
> > > > v12: - Removed WARN from intel_can_enable_sagv, in some of the commits
> > > >if we don't recalculated watermarks, bw_state is not 
> > > > recalculated,
> > > >thus leading to SAGV state not recalculated by the commit state,
> > > >which is still calling intel_can_enable_sagv function. Fix that
> > > >by just analyzing the current global bw_state object - because
> > > >we 

Re: [Intel-gfx] [PATCH v2 3/5] drm/i915: Introduce scaling filter related registers and bit fields.

2020-03-23 Thread Ville Syrjälä
On Thu, Mar 19, 2020 at 03:51:01PM +0530, Pankaj Bharadiya wrote:
> Introduce scaler registers and bit fields needed to configure the
> scaling filter in prgrammed mode and configure scaling filter
> coefficients.
> 
> changes since v1:
> * None
> changes since RFC:
> * Parametrize scaler coeffient macros by 'set' (Ville)
> 
> Signed-off-by: Shashank Sharma 
> Signed-off-by: Ankit Nautiyal 
> Signed-off-by: Pankaj Bharadiya 
> ---
>  drivers/gpu/drm/i915/i915_reg.h | 48 +
>  1 file changed, 48 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 9c53fe918be6..d40f12d2a6b5 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -7205,6 +7205,7 @@ enum {
>  #define PS_PLANE_SEL(plane) (((plane) + 1) << 25)
>  #define PS_FILTER_MASK (3 << 23)
>  #define PS_FILTER_MEDIUM   (0 << 23)
> +#define PS_FILTER_PROGRAMMED   (1 << 23)
>  #define PS_FILTER_EDGE_ENHANCE (2 << 23)
>  #define PS_FILTER_BILINEAR (3 << 23)
>  #define PS_VERT3TAP(1 << 21)
> @@ -7219,6 +7220,10 @@ enum {
>  #define PS_VADAPT_MODE_MOST_ADAPT  (3 << 5)
>  #define PS_PLANE_Y_SEL_MASK  (7 << 5)
>  #define PS_PLANE_Y_SEL(plane) (((plane) + 1) << 5)
> +#define PS_Y_VERT_FILTER_SELECT(set)   ((set) << 4)
> +#define PS_Y_HORZ_FILTER_SELECT(set)   ((set) << 3)
> +#define PS_UV_VERT_FILTER_SELECT(set)  ((set) << 2)
> +#define PS_UV_HORZ_FILTER_SELECT(set)  ((set) << 1)
>  
>  #define _PS_PWR_GATE_1A 0x68160
>  #define _PS_PWR_GATE_2A 0x68260
> @@ -7281,6 +7286,25 @@ enum {
>  #define _PS_ECC_STAT_2B 0x68AD0
>  #define _PS_ECC_STAT_1C 0x691D0
>  
> +#define _PS_COEF_SET0_INDEX_1A  0x68198
> +#define _PS_COEF_SET0_INDEX_2A  0x68298
> +#define _PS_COEF_SET0_INDEX_1B  0x68998
> +#define _PS_COEF_SET0_INDEX_2B  0x68A98
> +#define _PS_COEF_SET1_INDEX_1A  0x681A0
> +#define _PS_COEF_SET1_INDEX_2A  0x682A0
> +#define _PS_COEF_SET1_INDEX_1B  0x689A0
> +#define _PS_COEF_SET1_INDEX_2B  0x68AA0
> +#define PS_COEE_INDEX_AUTO_INC  (1 << 10)
> +
> +#define _PS_COEF_SET0_DATA_1A   0x6819C
> +#define _PS_COEF_SET0_DATA_2A   0x6829C
> +#define _PS_COEF_SET0_DATA_1B   0x6899C
> +#define _PS_COEF_SET0_DATA_2B   0x68A9C
> +#define _PS_COEF_SET1_DATA_1A   0x681A4
> +#define _PS_COEF_SET1_DATA_2A   0x682A4
> +#define _PS_COEF_SET1_DATA_1B   0x689A4
> +#define _PS_COEF_SET1_DATA_2B   0x68AA4
> +
>  #define _ID(id, a, b) _PICK_EVEN(id, a, b)
>  #define SKL_PS_CTRL(pipe, id) _MMIO_PIPE(pipe,\
>   _ID(id, _PS_1A_CTRL, _PS_2A_CTRL),   \
> @@ -7310,6 +7334,30 @@ enum {
>   _ID(id, _PS_ECC_STAT_1A, _PS_ECC_STAT_2A),   \
>   _ID(id, _PS_ECC_STAT_1B, _PS_ECC_STAT_2B))
>  
> +#define _SKL_PS_COEF_INDEX_SET0(pipe, id)  _ID(pipe,\
> + _ID(id, _PS_COEF_SET0_INDEX_1A, 
> _PS_COEF_SET0_INDEX_2A), \
> + _ID(id, _PS_COEF_SET0_INDEX_1B, _PS_COEF_SET0_INDEX_2B))
> +
> +#define _SKL_PS_COEF_INDEX_SET1(pipe, id)  _ID(pipe,\
> + _ID(id, _PS_COEF_SET1_INDEX_1A, 
> _PS_COEF_SET1_INDEX_2A), \
> + _ID(id, _PS_COEF_SET1_INDEX_1B, _PS_COEF_SET1_INDEX_2B))
> +
> +#define _SKL_PS_COEF_DATA_SET0(pipe, id)  _ID(pipe, \
> + _ID(id, _PS_COEF_SET0_DATA_1A, _PS_COEF_SET0_DATA_2A), \
> + _ID(id, _PS_COEF_SET0_DATA_1B, _PS_COEF_SET0_DATA_2B))
> +
> +#define _SKL_PS_COEF_DATA_SET1(pipe, id)  _ID(pipe, \
> + _ID(id, _PS_COEF_SET1_DATA_1A, _PS_COEF_SET1_DATA_2A), \
> + _ID(id, _PS_COEF_SET1_DATA_1B, _PS_COEF_SET1_DATA_2B))
> +
> +#define SKL_PS_COEF_INDEX_SET(pipe, id, set) \
> + _MMIO_PIPE(set, _SKL_PS_COEF_INDEX_SET0(pipe, id), \
> + _SKL_PS_COEF_INDEX_SET1(pipe, id))
> +
> +#define SKL_PS_COEF_DATA_SET(pipe, id, set) \
> + _MMIO_PIPE(set, _SKL_PS_COEF_DATA_SET0(pipe, id), \
> + _SKL_PS_COEF_DATA_SET1(pipe, id))

I'd name those CNL_PS_COEF_{DATA,INDEX}(). Or maybe eeven GLK_ since it
already has this despite not being officially supported.

Also I'd probably just have used +(set)*8 instead of adding another trip
through _PICK_EVEN(). It's getting a bit hard to read this.

> +
>  /* legacy palette */
>  #define _LGC_PALETTE_A   0x4a000
>  #define _LGC_PALETTE_B   0x4a800
> -- 
> 2.23.0

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


Re: [Intel-gfx] [PATCH] drm/i915/display: Trigger Modeset at boot for audio codec init

2020-03-23 Thread Khor, Swee Aun
Hi Ville, 

You are right, your suggestion will fix this issue.

#Based on dmesg log, uapi mode private flags change is captured
...
[   11.404578] fbcon: i915drmfb (fb0) is primary device
[   11.404743] [drm] SA: intel_atomic_check: uapi change 
[   11.404744] [drm] SA2: intel_atomic_check: 
new_crtc_state->uapi.mode.private_flags= 0, 
old_crtc_state->uapi.mode.private_flags= 1  
[   11.404744] [drm] SA2: intel_atomic_check: 
new_crtc_state->uapi.mode.private_flags= 0, 
old_crtc_state->uapi.mode.private_flags= 0  
[   11.404745] [drm] SA2: intel_atomic_check: 
new_crtc_state->uapi.mode.private_flags= 0, 
old_crtc_state->uapi.mode.private_flags= 0  
[   11.404799] [drm:intel_atomic_check [i915]] [CONNECTOR:110:HDMI-A-2] 
Limiting display bpp to 24 instead of EDID bpp 24, requested bpp 36, max 
platform bpp 36
[   11.404855] [drm:intel_hdmi_compute_config [i915]] picking 8 bpc for HDMI 
output (pipe bpp: 24)
[   11.404898] [drm:intel_atomic_check [i915]] hw max bpp: 24, pipe bpp: 24, 
dithering: 0
...

#Here is the git diff 
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index 4d1634ed6a1b..b5c56cd513d9 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -14108,11 +14108,15 @@ static int intel_atomic_check(struct drm_device *dev,
int ret, i;
bool any_ms = false;
 
+   DRM_INFO("SA: intel_atomic_check: uapi change \n");
+
/* Catch I915_MODE_FLAG_INHERITED */
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
new_crtc_state, i) {
-   if (new_crtc_state->hw.mode.private_flags !=
-   old_crtc_state->hw.mode.private_flags)
+
+   DRM_INFO("SA2: intel_atomic_check: 
new_crtc_state->uapi.mode.private_flags= %d, 
old_crtc_state->uapi.mode.private_flags= %d  \n", 
new_crtc_state->uapi.mode.private_flags, 
old_crtc_state->uapi.mode.private_flags );
+   if (new_crtc_state->uapi.mode.private_flags !=
+   old_crtc_state->uapi.mode.private_flags)
new_crtc_state->uapi.mode_changed = true;
}

Regards,
SweeAun

-Original Message-
From: Khor, Swee Aun 
Sent: Saturday, March 21, 2020 12:55 AM
To: Ville Syrjälä ; Shankar, Uma 

Cc: Souza, Jose ; intel-gfx@lists.freedesktop.org
Subject: RE: [Intel-gfx] [PATCH] drm/i915/display: Trigger Modeset at boot for 
audio codec init

Hi Ville,
You means this change right? Sure. Will try your suggestion as well. 
By the way, what is different between hw.mode and uapi.mode and how we know 
which to be used? It used to only base.mode before hw/uapi split patches. 

> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -14671,8 +14671,8 @@ static int intel_atomic_check(struct drm_device *dev,
> /* Catch I915_MODE_FLAG_INHERITED */
> for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
> new_crtc_state, i) {
> -   if (new_crtc_state->hw.mode.private_flags !=
> -   old_crtc_state->hw.mode.private_flags)
> +   if (new_crtc_state->uapi.mode.private_flags !=
> +   old_crtc_state->uapi.mode.private_flags)
> new_crtc_state->uapi.mode_changed = true;
> }
> 
> ?

Regards,
SweeAun

-Original Message-
From: Ville Syrjälä 
Sent: Friday, March 20, 2020 11:24 PM
To: Shankar, Uma 
Cc: Souza, Jose ; intel-gfx@lists.freedesktop.org; Khor, 
Swee Aun 
Subject: Re: [Intel-gfx] [PATCH] drm/i915/display: Trigger Modeset at boot for 
audio codec init

On Fri, Mar 20, 2020 at 06:19:37AM +, Shankar, Uma wrote:
> 
> 
> > -Original Message-
> > From: Souza, Jose 
> > Sent: Friday, March 20, 2020 12:36 AM
> > To: Shankar, Uma ; 
> > intel-gfx@lists.freedesktop.org
> > Cc: Khor, Swee Aun 
> > Subject: Re: [Intel-gfx] [PATCH] drm/i915/display: Trigger Modeset 
> > at boot for audio codec init
> > 
> > On Wed, 2020-03-18 at 17:00 +0530, Uma Shankar wrote:
> > > If external monitors are connected during boot up, driver uses the 
> > > same mode programmed by BIOS and avoids a full modeset.
> > > This results in display audio codec left uninitialized and display 
> > > audio fails to work till user triggers a modeset.
> > >
> > > This patch fixes the same by triggering a modeset at boot.
> > 
> > We had the same issue for PSR, take a look to the fix:
> > commit 33e059a2e4df454359f642f2235af39de9d3e914
> > drm/i915/psr: Force PSR probe only after full initialization
> > 
> > Maybe make this even more generic.
> 
> Yeah this looks to dealing with almost a similar need. Thanks for 
> pointing this out, will try to come up with a generalized solution.

How about just fixing the uapi vs. hw fail I showed instead of adding even more 
hacks?

--
Ville Syrjälä
Intel

Re: [Intel-gfx] [PATCH v2 1/5] drm: Introduce plane and CRTC scaling filter properties

2020-03-23 Thread Ville Syrjälä
On Thu, Mar 19, 2020 at 03:50:59PM +0530, Pankaj Bharadiya wrote:
> Introduce new plane and CRTC scaling filter properties to allow
> userspace to select the driver's default scaling filter or
> Nearest-neighbor(NN) filter for upscaling operations on CRTC and
> plane.
> 
> Drivers can set up this property for a plane by calling
> drm_plane_enable_scaling_filter() and for a CRTC by calling
> drm_crtc_enable_scaling_filter().
> 
> NN filter works by filling in the missing color values in the upscaled
> image with that of the coordinate-mapped nearest source pixel value.
> 
> NN filter for integer multiple scaling can be particularly useful for
> for pixel art games that rely on sharp, blocky images to deliver their
> distinctive look.
> 
> changes since v1:
> * None
> changes since RFC:
> * Add separate properties for plane and CRTC (Ville)

I actually meant the prop should be per-object, not just separate
prop for planes and crtcs.

> 
> Signed-off-by: Shashank Sharma 
> Signed-off-by: Ankit Nautiyal 
> Signed-off-by: Pankaj Bharadiya 
> ---
>  drivers/gpu/drm/drm_atomic_uapi.c |  8 
>  drivers/gpu/drm/drm_crtc.c| 33 +++
>  drivers/gpu/drm/drm_mode_config.c | 26 
>  drivers/gpu/drm/drm_plane.c   | 33 +++
>  include/drm/drm_crtc.h| 13 
>  include/drm/drm_mode_config.h | 12 +++
>  include/drm/drm_plane.h   | 13 
>  7 files changed, 138 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c 
> b/drivers/gpu/drm/drm_atomic_uapi.c
> index a1e5e262bae2..3c72ab52ff62 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -435,6 +435,8 @@ static int drm_atomic_crtc_set_property(struct drm_crtc 
> *crtc,
>   return ret;
>   } else if (property == config->prop_vrr_enabled) {
>   state->vrr_enabled = val;
> + } else if (property == config->crtc_scaling_filter_property) {
> + state->scaling_filter = val;
>   } else if (property == config->degamma_lut_property) {
>   ret = drm_atomic_replace_property_blob_from_id(dev,
>   >degamma_lut,
> @@ -503,6 +505,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
>   *val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
>   else if (property == config->prop_out_fence_ptr)
>   *val = 0;
> + else if (property == config->crtc_scaling_filter_property)
> + *val = state->scaling_filter;
>   else if (crtc->funcs->atomic_get_property)
>   return crtc->funcs->atomic_get_property(crtc, state, property, 
> val);
>   else
> @@ -583,6 +587,8 @@ static int drm_atomic_plane_set_property(struct drm_plane 
> *plane,
>   sizeof(struct drm_rect),
>   );
>   return ret;
> + } else if (property == config->plane_scaling_filter_property) {
> + state->scaling_filter = val;
>   } else if (plane->funcs->atomic_set_property) {
>   return plane->funcs->atomic_set_property(plane, state,
>   property, val);
> @@ -641,6 +647,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
>   } else if (property == config->prop_fb_damage_clips) {
>   *val = (state->fb_damage_clips) ?
>   state->fb_damage_clips->base.id : 0;
> + } else if (property == config->plane_scaling_filter_property) {
> + *val = state->scaling_filter;
>   } else if (plane->funcs->atomic_get_property) {
>   return plane->funcs->atomic_get_property(plane, state, 
> property, val);
>   } else {
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 4936e1080e41..c8d387891dd5 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -748,3 +748,36 @@ int drm_mode_crtc_set_obj_prop(struct drm_mode_object 
> *obj,
>  
>   return ret;
>  }
> +
> +/**
> + * DOC: CRTC scaling filter property
> + *
> + * SCALING_FILTER:
> + *
> + *   Indicates scaling filter to be used for CRTC scaler
> + *
> + *   The value of this property can be one of the following:
> + *   Default:
> + *   Driver's default scaling filter
> + *   Nearest Neighbor:
> + *   Nearest Neighbor scaling filter
> + *
> + * Drivers can set up this property for a CRTC by calling
> + * drm_crtc_enable_scaling_filter()
> + */
> +
> +/**
> + * drm_crtc_enable_scaling_filter - Enables CRTC scaling filter property.
> + * @crtc: CRTC on which to enable scaling filter property.
> + *
> + * This function lets driver to enable the scaling filter property on a CRTC.
> + */
> +void drm_crtc_enable_scaling_filter(struct drm_crtc *crtc)
> +{
> + struct drm_device *dev = crtc->dev;
> +
> + drm_object_attach_property(>base,
> +  

Re: [Intel-gfx] [PATCH v19 4/8] drm/i915: Refactor intel_can_enable_sagv

2020-03-23 Thread Ville Syrjälä
On Fri, Mar 20, 2020 at 02:51:41PM +0200, Lisovskiy, Stanislav wrote:
> On Wed, Mar 11, 2020 at 06:31:30PM +0200, Ville Syrjälä wrote:
> > On Mon, Mar 09, 2020 at 06:12:00PM +0200, Stanislav Lisovskiy wrote:
> > > Currently intel_can_enable_sagv function contains
> > > a mix of workarounds for different platforms
> > > some of them are not valid for gens >= 11 already,
> > > so lets split it into separate functions.
> > > 
> > > v2:
> > > - Rework watermark calculation algorithm to
> > >   attempt to calculate Level 0 watermark
> > >   with added sagv block time latency and
> > >   check if it fits in DBuf in order to
> > >   determine if SAGV can be enabled already
> > >   at this stage, just as BSpec 49325 states.
> > >   if that fails rollback to usual Level 0
> > >   latency and disable SAGV.
> > > - Remove unneeded tabs(James Ausmus)
> > > 
> > > v3: Rebased the patch
> > > 
> > > v4: - Added back interlaced check for Gen12 and
> > >   added separate function for TGL SAGV check
> > >   (thanks to James Ausmus for spotting)
> > > - Removed unneeded gen check
> > > - Extracted Gen12 SAGV decision making code
> > >   to a separate function from skl_compute_wm
> > > 
> > > v5: - Added SAGV global state to dev_priv, because
> > >   we need to track all pipes, not only those
> > >   in atomic state. Each pipe has now correspondent
> > >   bit mask reflecting, whether it can tolerate
> > >   SAGV or not(thanks to Ville Syrjala for suggestions).
> > > - Now using active flag instead of enable in crc
> > >   usage check.
> > > 
> > > v6: - Fixed rebase conflicts
> > > 
> > > v7: - kms_cursor_legacy seems to get broken because of multiple memcpy
> > >   calls when copying level 0 water marks for enabled SAGV, to
> > >   fix this now simply using that field right away, without copying,
> > >   for that introduced a new wm_level accessor which decides which
> > >   wm_level to return based on SAGV state.
> > > 
> > > v8: - Protect crtc_sagv_mask same way as we do for other global state
> > >   changes: i.e check if changes are needed, then grab all crtc locks
> > >   to serialize the changes(Ville Syrjälä)
> > > - Add crtc_sagv_mask caching in order to avoid needless recalculations
> > >   (Matthew Roper)
> > > - Put back Gen12 SAGV switch in order to get it enabled in separate
> > >   patch(Matthew Roper)
> > > - Rename *_set_sagv_mask to *_compute_sagv_mask(Matthew Roper)
> > > - Check if there are no active pipes in intel_can_enable_sagv
> > >   instead of platform specific functions(Matthew Roper), same
> > >   for intel_has_sagv check.
> > > 
> > > v9  - Switched to u8 for crtc_sagv_mask(Ville Syrjälä)
> > > - crtc_sagv_mask now is pipe_sagv_mask(Ville Syrjälä)
> > > - Extracted sagv checking logic from skl/icl/tgl_compute_sagv_mask
> > > - Extracted skl_plane_wm_level function and passing latency to
> > >   separate patches(Ville Syrjälä)
> > > - Removed part of unneeded copy-paste from tgl_check_pipe_fits_sagv_wm
> > >   (Ville Syrjälä)
> > > - Now using simple assignment for sagv_wm0 as it contains only
> > >   pod types and no pointers(Ville Syrjälä)
> > > - Fixed intel_can_enable_sagv not to do double duty, now it only
> > >   check SAGV bits by ANDing those between local and global state.
> > >   The SAGV masks are now computed after watermarks are available,
> > >   in order to be able to figure out if ddb ranges are fitting nicely.
> > >   (Ville Syrjälä)
> > > - Now having uv_sagv_wm0 and sagv_wm0, otherwise we have wrong logic
> > >   when using skl_plane_wm_level accessor, as we had previously for
> > >   Gen11+ color plane and regular wm levels, so probably both
> > >   has to be recalculated with additional SAGV block time for Level 0.
> > > 
> > > v10: - Starting to use new global state for storing pipe_sagv_mask
> > > 
> > > v11: - Fixed rebase conflict with recent drm-tip
> > >  - Check if we really need to recalculate SAGV mask, otherwise
> > >bail out without making any changes.
> > >  - Use cached SAGV result, instead of recalculating it everytime,
> > >if bw_state hasn't changed.
> > > 
> > > v12: - Removed WARN from intel_can_enable_sagv, in some of the commits
> > >if we don't recalculated watermarks, bw_state is not recalculated,
> > >thus leading to SAGV state not recalculated by the commit state,
> > >which is still calling intel_can_enable_sagv function. Fix that
> > >by just analyzing the current global bw_state object - because
> > >we simply have no other objects related to that.
> > > 
> > > v13: - Rebased, fixed warnings regarding long lines
> > >  - Changed function call sites from intel_atomic_bw* to
> > >intel_wb_* as was suggested.(Jani Nikula)
> > >  - Taken ddb_state_changed and 

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/selftests: add some vma_sync

2020-03-23 Thread Patchwork
== Series Details ==

Series: drm/i915/selftests: add some vma_sync
URL   : https://patchwork.freedesktop.org/series/74969/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8178 -> Patchwork_17052


Summary
---

  **FAILURE**

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

  External URL: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17052/index.html

Possible new issues
---

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

### IGT changes ###

 Possible regressions 

  * igt@i915_selftest@live@coherency:
- fi-gdg-551: [PASS][1] -> [DMESG-FAIL][2]
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8178/fi-gdg-551/igt@i915_selftest@l...@coherency.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17052/fi-gdg-551/igt@i915_selftest@l...@coherency.html

  
Known issues


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

### IGT changes ###

 Issues hit 

  * igt@kms_chamelium@common-hpd-after-suspend:
- fi-icl-u2:  [PASS][3] -> [FAIL][4] ([i915#217])
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8178/fi-icl-u2/igt@kms_chamel...@common-hpd-after-suspend.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17052/fi-icl-u2/igt@kms_chamel...@common-hpd-after-suspend.html

  
 Possible fixes 

  * igt@i915_selftest@live@gem_contexts:
- fi-cml-s:   [DMESG-FAIL][5] ([i915#877]) -> [PASS][6]
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8178/fi-cml-s/igt@i915_selftest@live@gem_contexts.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17052/fi-cml-s/igt@i915_selftest@live@gem_contexts.html

  * igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u:   [FAIL][7] ([i915#323]) -> [PASS][8]
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8178/fi-kbl-7500u/igt@kms_chamel...@hdmi-hpd-fast.html
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17052/fi-kbl-7500u/igt@kms_chamel...@hdmi-hpd-fast.html

  
  [i915#217]: https://gitlab.freedesktop.org/drm/intel/issues/217
  [i915#323]: https://gitlab.freedesktop.org/drm/intel/issues/323
  [i915#877]: https://gitlab.freedesktop.org/drm/intel/issues/877


Participating hosts (50 -> 42)
--

  Additional (1): fi-byt-n2820 
  Missing(9): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks 
fi-bsw-cyan fi-ctg-p8600 fi-bsw-kefka fi-byt-clapper fi-bdw-samus 


Build changes
-

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_8178 -> Patchwork_17052

  CI-20190529: 20190529
  CI_DRM_8178: 3f4392bf31d28013e860818ba613b598bb227821 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5528: 5dee9128b2aaa77d036163f670f0e0fc15b578ab @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17052: 8bf02a45845a6710387fc0cab20cb4c79744c8ce @ 
git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

8bf02a45845a drm/i915/selftests: add some vma_sync

== Logs ==

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


Re: [Intel-gfx] [PATCH] drm/i915/selftests: mark huge_gem_object as not shrinkable

2020-03-23 Thread Chris Wilson
Quoting Matthew Auld (2020-03-23 13:53:13)
> On Mon, 23 Mar 2020 at 13:17, Chris Wilson  wrote:
> >
> > Quoting Matthew Auld (2020-03-23 13:08:21)
> > > It looks like the callers expect a non-volatile object, but it looks the
> > > shrinker will discard the object pages anyway, thinking that the pages
> > > can be swapped out if the object is marked as WILLNEED. If that's true
> > > then it might be better to mark it as volatile and fix the callers
> > > instead, but on the other hand huge_gem_objects are fairly unique in
> > > that they duplicate pages for the backing store, so maybe shrinking is
> > > not that applicable.
> >
> > Duplication of backing store is irrelevant for the shrinker -- it just
> > deals with trying to make room by releasing objects. If we release the
> > entire object, all duplicate references are released and the pages
> > become recoverable.
> 
> Ok. My rough thinking was that the shrinker page accounting(i.e what
> we return) is currently based on obj->base.size, which might be pure
> lies for huge_gem_object.
> 
> >
> > Now as to whether the callers were expecting the object to be volatile
> > (for the backing pages to be discarded on swapping) is another question.
> > The answer would be that originally it was used with perma-pinned pages,
> > so it was never a problem. But looking at the users, they do *not*
> > expect to lose data on swapping.
> >
> > So we need to fix the huge object to not gleefully throw away data,
> > which also means that we cannot shrink it (as there is no backing
> > storage to copy the pages to).
> >
> > So both making the pages as DONTNEED and IS_SHRINKABLE are technically
> > incorrect.
> 
> Do you mean WILLNEED and IS_SHRINKABLE, if object doesn't also support
> swapping? DONTNEED and IS_SHRINKABLE is correct for volatile objects.
> 
> GEM_BUG_ON(is_shrinkable(obj) && !is_swappable(obj) && obj->mm.madv ==
> WILLNEED);

For the moment, we can just drop IS_SHRINKABLE here. But there is room
for a huge object that can take part in shrinker ops by being volatile.

But for the moment there's no pressing need, so we can defer the API
problem. (I'm thinking we'll need to expose i915_gem_object_madvise.)
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


  1   2   >