Re: [Intel-gfx] [PATCH] drm/i915: add Wa_14010594013: icl,ehl

2020-01-10 Thread Anshuamn Gupta
On 2020-01-10 at 03:51:49 -0500, Matt Atwood wrote:
> The bspec tells us we need to set this bit to avoid potential underruns.
> 
> Bspec: 33450
> Bspec: 33451
> Bspec: 33452
It would be nice to add index 7386 which is having the bit for PMRSP.
> 
> Signed-off-by: Matt Atwood 
> ---
>  drivers/gpu/drm/i915/i915_reg.h | 1 +
>  drivers/gpu/drm/i915/intel_pm.c | 4 
>  2 files changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index cf770793be54..b9dc5e2ea606 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -7785,6 +7785,7 @@ enum {
>  
>  #define GEN8_CHICKEN_DCPR_1  _MMIO(0x46430)
>  #define   SKL_SELECT_ALTERNATE_DC_EXIT   (1 << 30)
> +#define   CNL_DELAY_PMRSP(1 << 22)
>  #define   MASK_WAKEMEM   (1 << 13)
>  #define   CNL_DDI_CLOCK_REG_ACCESS_ON(1 << 7)
>  
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index 148ac455dfa7..10714d43e8a3 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -6610,6 +6610,10 @@ static void icl_init_clock_gating(struct 
> drm_i915_private *dev_priv)
>   /* Wa_1407352427:icl,ehl */
>   intel_uncore_rmw(&dev_priv->uncore, UNSLICE_UNIT_LEVEL_CLKGATE2,
>0, PSDUNIT_CLKGATE_DIS);
> +
> + /*Wa_14010594013:icl, ehl */
> + I915_WRITE(GEN8_CHICKEN_DCPR_1,
> +I915_READ(GEN8_CHICKEN_DCPR_1) | CNL_DELAY_PMRSP);
Is there any functional difference between Wa_14010594013 and above 
Wa_1407352427
using different family of writes, may be not related to this patch.
Thanks,
Anshuman Gupta.
>  }
>  
>  static void tgl_init_clock_gating(struct drm_i915_private *dev_priv)
> -- 
> 2.21.1
> 
> ___
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 00/23] drm: Clean up VBLANK callbacks in struct drm_driver

2020-01-10 Thread Thomas Zimmermann
VBLANK handlers in struct drm_driver are deprecated. Only legacy,
non-KMS drivers are supposed to used them. DRM drivers with kernel
modesetting are supposed to use VBLANK callbacks of the CRTC
infrastructure.

This patchset converts all DRM drivers to CRTC VBLANK callbacks and
cleans up struct drm_driver. The remaining VBLANK callbacks in struct
drm_driver are only used by legacy drivers.

Patches 1 to 9 move get_scanout_position() to struct drm_crtc_helper_funcs
and convert drivers over. The callback is a helper for the default
implementation of get_vblank_timestamp() (i.e.,
drm_calc_vbltimestamp_from_scanoutpos()). The original callback is removed
from struct drm_driver.

Patch 10 changes the VBLANK code to evaluate vblank_disable_immediate in
struct derm_device. This simplifies the later integration of CRTC VBLANK
callbacks. If necessary, a future patch could move vblank_disable_immedate
to struct drm_crtc, so that high-precision VBLANKs could be enabled on a
per-CRTC basis.

Patches 11 to 23 move get_vblank_timestamp() to struct drm_crtc_funcs
and convert DRM drivers over. All VBLANK callbacks are removed from
struct drm_driver, except for get_vblank_counter(), enable_vblank(), and
disable_vblank(). These interfaces are moved to the legacy section
at the end of the structure.

To cover all affected drivers, I build the patchset in x86, x86-64,
arm and aarch64. I smoke-tested amdgpu, gma500, i915, radeon and vc4 on
respective hardware.

Thomas Zimmermann (23):
  drm: Add get_scanout_position() to struct drm_crtc_helper_funcs
  drm/amdgpu: Convert to struct
drm_crtc_helper_funcs.get_scanout_position()
  drm/i915: Don't use struct drm_driver.get_scanout_position()
  drm/nouveau: Convert to struct
drm_crtc_helper_funcs.get_scanout_position()
  drm/radeon: Convert to struct
drm_crtc_helper_funcs.get_scanout_position()
  drm/msm: Convert to struct
drm_crtc_helper_funcs.get_scanout_position()
  drm/vc4: Convert to struct
drm_crtc_helper_funcs.get_scanout_position()
  drm/stm: Convert to struct
drm_crtc_helper_funcs.get_scanout_position()
  drm: Remove struct drm_driver.get_scanout_position()
  drm: Evaluate struct drm_device.vblank_disable_immediate on each use
  drm: Add get_vblank_timestamp() to struct drm_crtc_funcs
  drm/amdgpu: Convert to CRTC VBLANK callbacks
  drm/gma500: Convert to CRTC VBLANK callbacks
  drm/i915: Convert to CRTC VBLANK callbacks
  drm/msm: Convert to CRTC VBLANK callbacks
  drm/nouveau: Convert to CRTC VBLANK callbacks
  drm/radeon: Convert to CRTC VBLANK callbacks
  drm/sti: Convert to CRTC VBLANK callbacks
  drm/stm: Convert to CRTC VBLANK callbacks
  drm/vc4: Convert to CRTC VBLANK callbacks
  drm/vkms: Convert to CRTC VBLANK callbacks
  drm/vmwgfx: Convert to CRTC VBLANK callbacks
  drm: Cleanup VBLANK callbacks in struct drm_driver

 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |   3 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  12 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |  15 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   |  24 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h  |   5 +
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c|   5 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c|   5 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c |   5 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c |   5 +
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c  |   5 +
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |   5 +-
 drivers/gpu/drm/drm_vblank.c  | 128 +-
 drivers/gpu/drm/gma500/cdv_intel_display.c|   3 +
 drivers/gpu/drm/gma500/psb_drv.c  |   4 -
 drivers/gpu/drm/gma500/psb_drv.h  |   6 +-
 drivers/gpu/drm/gma500/psb_intel_display.c|   3 +
 drivers/gpu/drm/gma500/psb_irq.c  |  12 +-
 drivers/gpu/drm/gma500/psb_irq.h  |   7 +-
 drivers/gpu/drm/i915/display/intel_display.c  |   7 +
 drivers/gpu/drm/i915/i915_drv.c   |   3 -
 drivers/gpu/drm/i915/i915_irq.c   | 110 +++-
 drivers/gpu/drm/i915/i915_irq.h   |   8 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  |   2 +
 drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c |   2 +
 drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c |  82 +
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c  |  95 ---
 drivers/gpu/drm/msm/msm_drv.c |  10 +-
 drivers/gpu/drm/msm/msm_drv.h |   3 +
 drivers/gpu/drm/nouveau/dispnv04/crtc.c   |   4 +
 drivers/gpu/drm/nouveau/dispnv50/head.c   |   5 +
 drivers/gpu/drm/nouveau/nouveau_display.c |  28 +---
 drivers/gpu/drm/nouveau/nouveau_display.h |   6 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c |   5 -
 drivers/gpu/drm/radeon/atombios_crtc.c|   1 +
 drivers/gpu/drm/radeon/radeon_display.c   |  25 ++-
 drivers/gpu/drm/radeon/radeon_drv.c   |  18 --
 drivers/gpu/drm/radeon/radeon_kms.c   |  29 ++--
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c   |   3 +-
 drivers/

[Intel-gfx] [PATCH 01/23] drm: Add get_scanout_position() to struct drm_crtc_helper_funcs

2020-01-10 Thread Thomas Zimmermann
The new callback get_scanout_position() reads the current location of
the scanout process. The operation is currentyl located in struct
drm_driver, but really belongs to the CRTC. Drivers will be converted
in separate patches.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/drm_vblank.c | 24 
 include/drm/drm_drv.h|  7 +---
 include/drm/drm_modeset_helper_vtables.h | 47 
 3 files changed, 65 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 1659b13b178c..c12f0b333e14 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 
 
@@ -590,7 +591,7 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  * Implements calculation of exact vblank timestamps from given 
drm_display_mode
  * timings and current video scanout position of a CRTC. This can be directly
  * used as the &drm_driver.get_vblank_timestamp implementation of a kms driver
- * if &drm_driver.get_scanout_position is implemented.
+ * if &drm_crtc_helper_funcs.get_scanout_position is implemented.
  *
  * The current implementation only handles standard video modes. For double 
scan
  * and interlaced modes the driver is supposed to adjust the hardware mode
@@ -632,8 +633,9 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct 
drm_device *dev,
}
 
/* Scanout position query not supported? Should not happen. */
-   if (!dev->driver->get_scanout_position) {
-   DRM_ERROR("Called from driver w/o get_scanout_position()!?\n");
+   if (!dev->driver->get_scanout_position ||
+   !crtc->helper_private->get_scanout_position) {
+   DRM_ERROR("Called from CRTC w/o get_scanout_position()!?\n");
return false;
}
 
@@ -664,11 +666,17 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct 
drm_device *dev,
 * Get vertical and horizontal scanout position vpos, hpos,
 * and bounding timestamps stime, etime, pre/post query.
 */
-   vbl_status = dev->driver->get_scanout_position(dev, pipe,
-  in_vblank_irq,
-  &vpos, &hpos,
-  &stime, &etime,
-  mode);
+   if (crtc->helper_private->get_scanout_position) {
+   vbl_status =
+   crtc->helper_private->get_scanout_position(
+   crtc, in_vblank_irq, &vpos, &hpos,
+   &stime, &etime, mode);
+   } else {
+   vbl_status =
+   dev->driver->get_scanout_position(
+   dev, pipe, in_vblank_irq, &vpos,
+   &hpos, &stime, &etime, mode);
+   }
 
/* Return as no-op if scanout query unsupported or failed. */
if (!vbl_status) {
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index cf13470810a5..d0049e5786fc 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -362,11 +362,8 @@ struct drm_driver {
 * True on success, false if a reliable scanout position counter could
 * not be read out.
 *
-* FIXME:
-*
-* Since this is a helper to implement @get_vblank_timestamp, we should
-* move it to &struct drm_crtc_helper_funcs, like all the other
-* helper-internal hooks.
+* This is deprecated and should not be used by new drivers.
+* Use &drm_crtc_helper_funcs.get_scanout_position instead.
 */
bool (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
  bool in_vblank_irq, int *vpos, int *hpos,
diff --git a/include/drm/drm_modeset_helper_vtables.h 
b/include/drm/drm_modeset_helper_vtables.h
index 5a87f1bd7a3f..e398512bfd5f 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -450,6 +450,53 @@ struct drm_crtc_helper_funcs {
 */
void (*atomic_disable)(struct drm_crtc *crtc,
   struct drm_crtc_state *old_crtc_state);
+
+   /**
+* @get_scanout_position:
+*
+* Called by vblank timestamping code.
+*
+* Returns the current display scanout position from a CRTC and an
+* optional accurate ktime_get() timestamp of when the position was
+* measured. Note that this is a helper callback which is only used
+* if a driver uses drm_calc_vbltimestamp_from_scanoutpos() for the
+* @drm_driver.get_vblank_timestamp callback.
+   

[Intel-gfx] [PATCH 08/23] drm/stm: Convert to struct drm_crtc_helper_funcs.get_scanout_position()

2020-01-10 Thread Thomas Zimmermann
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position(). Convert stm
over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/stm/drv.c  |  1 -
 drivers/gpu/drm/stm/ltdc.c | 65 --
 drivers/gpu/drm/stm/ltdc.h |  5 ---
 3 files changed, 34 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c
index 5a9f9aca8bc2..486985604109 100644
--- a/drivers/gpu/drm/stm/drv.c
+++ b/drivers/gpu/drm/stm/drv.c
@@ -72,7 +72,6 @@ static struct drm_driver drv_driver = {
.gem_prime_vmap = drm_gem_cma_prime_vmap,
.gem_prime_vunmap = drm_gem_cma_prime_vunmap,
.gem_prime_mmap = drm_gem_cma_prime_mmap,
-   .get_scanout_position = ltdc_crtc_scanoutpos,
.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 };
 
diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index c2815e8ae1da..8b6d1a2252e3 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -636,38 +636,13 @@ static void ltdc_crtc_atomic_flush(struct drm_crtc *crtc,
}
 }
 
-static const struct drm_crtc_helper_funcs ltdc_crtc_helper_funcs = {
-   .mode_valid = ltdc_crtc_mode_valid,
-   .mode_fixup = ltdc_crtc_mode_fixup,
-   .mode_set_nofb = ltdc_crtc_mode_set_nofb,
-   .atomic_flush = ltdc_crtc_atomic_flush,
-   .atomic_enable = ltdc_crtc_atomic_enable,
-   .atomic_disable = ltdc_crtc_atomic_disable,
-};
-
-static int ltdc_crtc_enable_vblank(struct drm_crtc *crtc)
-{
-   struct ltdc_device *ldev = crtc_to_ltdc(crtc);
-
-   DRM_DEBUG_DRIVER("\n");
-   reg_set(ldev->regs, LTDC_IER, IER_LIE);
-
-   return 0;
-}
-
-static void ltdc_crtc_disable_vblank(struct drm_crtc *crtc)
-{
-   struct ltdc_device *ldev = crtc_to_ltdc(crtc);
-
-   DRM_DEBUG_DRIVER("\n");
-   reg_clear(ldev->regs, LTDC_IER, IER_LIE);
-}
-
-bool ltdc_crtc_scanoutpos(struct drm_device *ddev, unsigned int pipe,
- bool in_vblank_irq, int *vpos, int *hpos,
- ktime_t *stime, ktime_t *etime,
- const struct drm_display_mode *mode)
+static bool ltdc_crtc_get_scanout_position(struct drm_crtc *crtc,
+  bool in_vblank_irq,
+  int *vpos, int *hpos,
+  ktime_t *stime, ktime_t *etime,
+  const struct drm_display_mode *mode)
 {
+   struct drm_device *ddev = crtc->dev;
struct ltdc_device *ldev = ddev->dev_private;
int line, vactive_start, vactive_end, vtotal;
 
@@ -710,6 +685,34 @@ bool ltdc_crtc_scanoutpos(struct drm_device *ddev, 
unsigned int pipe,
return true;
 }
 
+static const struct drm_crtc_helper_funcs ltdc_crtc_helper_funcs = {
+   .mode_valid = ltdc_crtc_mode_valid,
+   .mode_fixup = ltdc_crtc_mode_fixup,
+   .mode_set_nofb = ltdc_crtc_mode_set_nofb,
+   .atomic_flush = ltdc_crtc_atomic_flush,
+   .atomic_enable = ltdc_crtc_atomic_enable,
+   .atomic_disable = ltdc_crtc_atomic_disable,
+   .get_scanout_position = ltdc_crtc_get_scanout_position,
+};
+
+static int ltdc_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct ltdc_device *ldev = crtc_to_ltdc(crtc);
+
+   DRM_DEBUG_DRIVER("\n");
+   reg_set(ldev->regs, LTDC_IER, IER_LIE);
+
+   return 0;
+}
+
+static void ltdc_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct ltdc_device *ldev = crtc_to_ltdc(crtc);
+
+   DRM_DEBUG_DRIVER("\n");
+   reg_clear(ldev->regs, LTDC_IER, IER_LIE);
+}
+
 static const struct drm_crtc_funcs ltdc_crtc_funcs = {
.destroy = drm_crtc_cleanup,
.set_config = drm_atomic_helper_set_config,
diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
index a1ad0ae3b006..c5467d74e707 100644
--- a/drivers/gpu/drm/stm/ltdc.h
+++ b/drivers/gpu/drm/stm/ltdc.h
@@ -39,11 +39,6 @@ struct ltdc_device {
struct drm_atomic_state *suspend_state;
 };
 
-bool ltdc_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
- bool in_vblank_irq, int *vpos, int *hpos,
- ktime_t *stime, ktime_t *etime,
- const struct drm_display_mode *mode);
-
 int ltdc_load(struct drm_device *ddev);
 void ltdc_unload(struct drm_device *ddev);
 void ltdc_suspend(struct drm_device *ddev);
-- 
2.24.1

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


[Intel-gfx] [PATCH 11/23] drm: Add get_vblank_timestamp() to struct drm_crtc_funcs

2020-01-10 Thread Thomas Zimmermann
The callback get_vblank_timestamp() is currently located in struct
drm_driver, but really belongs into struct drm_crtc_funcs. Add an
equivalent there. Driver will be converted in separate patches.

The default implementation is drm_calc_vbltimestamp_from_scanoutpos().
The patch adds drm_crtc_calc_vbltimestamp_from_scanoutpos(), which is
an implementation for the CRTC callback.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/drm_vblank.c | 83 +---
 include/drm/drm_crtc.h   | 41 
 include/drm/drm_modeset_helper_vtables.h |  2 +-
 include/drm/drm_vblank.h |  4 ++
 4 files changed, 120 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index cbe8f3009df5..7cf436a4b908 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -333,7 +333,9 @@ u64 drm_crtc_accurate_vblank_count(struct drm_crtc *crtc)
u64 vblank;
unsigned long flags;
 
-   WARN_ONCE(drm_debug_enabled(DRM_UT_VBL) && 
!dev->driver->get_vblank_timestamp,
+   WARN_ONCE(drm_debug_enabled(DRM_UT_VBL) &&
+ !crtc->funcs->get_vblank_timestamp &&
+ !dev->driver->get_vblank_timestamp,
  "This function requires support for accurate vblank 
timestamps.");
 
spin_lock_irqsave(&dev->vblank_time_lock, flags);
@@ -563,6 +565,50 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 }
 EXPORT_SYMBOL(drm_calc_timestamping_constants);
 
+/**
+ * drm_crtc_calc_vbltimestamp_from_scanoutpos - precise vblank timestamp helper
+ * @crtc: CRTC whose vblank timestamp to retrieve
+ * @max_error: Desired maximum allowable error in timestamps (nanosecs)
+ * On return contains true maximum error of timestamp
+ * @vblank_time: Pointer to time which should receive the timestamp
+ * @in_vblank_irq:
+ * True when called from drm_crtc_handle_vblank().  Some drivers
+ * need to apply some workarounds for gpu-specific vblank irq quirks
+ * if flag is set.
+ *
+ * Implements calculation of exact vblank timestamps from given 
drm_display_mode
+ * timings and current video scanout position of a CRTC. This can be directly
+ * used as the &drm_crtc_funcs.get_vblank_timestamp implementation of a kms
+ * driver if &drm_crtc_helper_funcs.get_scanout_position is implemented.
+ *
+ * The current implementation only handles standard video modes. For double 
scan
+ * and interlaced modes the driver is supposed to adjust the hardware mode
+ * (taken from &drm_crtc_state.adjusted mode for atomic modeset drivers) to
+ * match the scanout position reported.
+ *
+ * Note that atomic drivers must call drm_calc_timestamping_constants() before
+ * enabling a CRTC. The atomic helpers already take care of that in
+ * drm_atomic_helper_update_legacy_modeset_state().
+ *
+ * Returns:
+ *
+ * Returns true on success, and false on failure, i.e. when no accurate
+ * timestamp could be acquired.
+ */
+bool drm_crtc_calc_vbltimestamp_from_scanoutpos(struct drm_crtc *crtc,
+   int *max_error,
+   ktime_t *vblank_time,
+   bool in_vblank_irq)
+{
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
+
+   return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
+vblank_time,
+in_vblank_irq);
+}
+EXPORT_SYMBOL(drm_crtc_calc_vbltimestamp_from_scanoutpos);
+
 /**
  * drm_calc_vbltimestamp_from_scanoutpos - precise vblank timestamp helper
  * @dev: DRM device
@@ -577,8 +623,8 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
  *
  * Implements calculation of exact vblank timestamps from given 
drm_display_mode
  * timings and current video scanout position of a CRTC. This can be directly
- * used as the &drm_driver.get_vblank_timestamp implementation of a kms driver
- * if &drm_crtc_helper_funcs.get_scanout_position is implemented.
+ * used as the &drm_crtc_funcs.get_vblank_timestamp implementation of a kms
+ * driver if &drm_crtc_helper_funcs.get_scanout_position is implemented.
  *
  * The current implementation only handles standard video modes. For double 
scan
  * and interlaced modes the driver is supposed to adjust the hardware mode
@@ -733,15 +779,22 @@ static bool
 drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe,
  ktime_t *tvblank, bool in_vblank_irq)
 {
+   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
bool ret = false;
 
/* Define requested maximum error on timestamps (nanoseconds). */
int max_error = (int) drm_timestamp_precision * 1000;
 
/* Query driver if possible and precision timestamping enabled. */
-   if (dev->driver->get_vblank_timestamp && (max_error > 0))
+   

[Intel-gfx] [PATCH 06/23] drm/msm: Convert to struct drm_crtc_helper_funcs.get_scanout_position()

2020-01-10 Thread Thomas Zimmermann
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position(). Convert
mem over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 67 +++
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c  | 61 -
 2 files changed, 67 insertions(+), 61 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
index 05cc04f729d6..4decf19847a8 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
@@ -405,6 +405,72 @@ static void mdp5_crtc_mode_set_nofb(struct drm_crtc *crtc)
spin_unlock_irqrestore(&mdp5_crtc->lm_lock, flags);
 }
 
+static struct drm_encoder *get_encoder_from_crtc(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_encoder *encoder;
+
+   drm_for_each_encoder(encoder, dev)
+   if (encoder->crtc == crtc)
+   return encoder;
+
+   return NULL;
+}
+
+static bool mdp5_crtc_get_scanout_position(struct drm_crtc *crtc,
+  bool in_vblank_irq,
+  int *vpos, int *hpos,
+  ktime_t *stime, ktime_t *etime,
+  const struct drm_display_mode *mode)
+{
+   unsigned int pipe = crtc->index;
+   struct drm_encoder *encoder;
+   int line, vsw, vbp, vactive_start, vactive_end, vfp_end;
+
+
+   encoder = get_encoder_from_crtc(crtc);
+   if (!encoder) {
+   DRM_ERROR("no encoder found for crtc %d\n", pipe);
+   return false;
+   }
+
+   vsw = mode->crtc_vsync_end - mode->crtc_vsync_start;
+   vbp = mode->crtc_vtotal - mode->crtc_vsync_end;
+
+   /*
+* the line counter is 1 at the start of the VSYNC pulse and VTOTAL at
+* the end of VFP. Translate the porch values relative to the line
+* counter positions.
+*/
+
+   vactive_start = vsw + vbp + 1;
+
+   vactive_end = vactive_start + mode->crtc_vdisplay;
+
+   /* last scan line before VSYNC */
+   vfp_end = mode->crtc_vtotal;
+
+   if (stime)
+   *stime = ktime_get();
+
+   line = mdp5_encoder_get_linecount(encoder);
+
+   if (line < vactive_start)
+   line -= vactive_start;
+   else if (line > vactive_end)
+   line = line - vfp_end - vactive_start;
+   else
+   line -= vactive_start;
+
+   *vpos = line;
+   *hpos = 0;
+
+   if (etime)
+   *etime = ktime_get();
+
+   return true;
+}
+
 static void mdp5_crtc_atomic_disable(struct drm_crtc *crtc,
 struct drm_crtc_state *old_state)
 {
@@ -1063,6 +1129,7 @@ static const struct drm_crtc_helper_funcs 
mdp5_crtc_helper_funcs = {
.atomic_flush = mdp5_crtc_atomic_flush,
.atomic_enable = mdp5_crtc_atomic_enable,
.atomic_disable = mdp5_crtc_atomic_disable,
+   .get_scanout_position = mdp5_crtc_get_scanout_position,
 };
 
 static void mdp5_crtc_vblank_irq(struct mdp_irq *irq, uint32_t irqstatus)
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
index e43ecd4be10a..8b72ac44ce55 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
@@ -595,66 +595,6 @@ static struct drm_encoder *get_encoder_from_crtc(struct 
drm_crtc *crtc)
return NULL;
 }
 
-static bool mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
-   bool in_vblank_irq, int *vpos, int *hpos,
-   ktime_t *stime, ktime_t *etime,
-   const struct drm_display_mode *mode)
-{
-   struct msm_drm_private *priv = dev->dev_private;
-   struct drm_crtc *crtc;
-   struct drm_encoder *encoder;
-   int line, vsw, vbp, vactive_start, vactive_end, vfp_end;
-
-   crtc = priv->crtcs[pipe];
-   if (!crtc) {
-   DRM_ERROR("Invalid crtc %d\n", pipe);
-   return false;
-   }
-
-   encoder = get_encoder_from_crtc(crtc);
-   if (!encoder) {
-   DRM_ERROR("no encoder found for crtc %d\n", pipe);
-   return false;
-   }
-
-   vsw = mode->crtc_vsync_end - mode->crtc_vsync_start;
-   vbp = mode->crtc_vtotal - mode->crtc_vsync_end;
-
-   /*
-* the line counter is 1 at the start of the VSYNC pulse and VTOTAL at
-* the end of VFP. Translate the porch values relative to the line
-* counter positions.
-*/
-
-   vactive_start = vsw + vbp + 1;
-
-   vactive_end = vactive_start + mode->crtc_vdisplay;
-
-   /* last scan line before VSYNC */
-   vfp_end = mode->crtc_vtotal;
-
-   if (stime)
-   *stime = ktime_get();
-
-   line = m

[Intel-gfx] [PATCH 03/23] drm/i915: Don't use struct drm_driver.get_scanout_position()

2020-01-10 Thread Thomas Zimmermann
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position().

i915 doesn't use CRTC helpers. The patch duplicates the caller
drm_calc_vbltimestamp_from_scanoutpos() for i915, such that the callback
function is not needed.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/i915/i915_drv.c |   3 +-
 drivers/gpu/drm/i915/i915_irq.c | 117 ++--
 drivers/gpu/drm/i915/i915_irq.h |   9 +--
 3 files changed, 119 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index f7385abdd74b..4a0a7fb85c53 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -2769,8 +2769,7 @@ static struct drm_driver driver = {
.gem_prime_export = i915_gem_prime_export,
.gem_prime_import = i915_gem_prime_import,
 
-   .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-   .get_scanout_position = i915_get_crtc_scanoutpos,
+   .get_vblank_timestamp = i915_calc_vbltimestamp_from_scanoutpos,
 
.dumb_create = i915_gem_dumb_create,
.dumb_map_offset = i915_gem_dumb_mmap_offset,
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index afc6aad9bf8c..99d0c3b0feae 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -52,6 +52,11 @@
 #include "i915_trace.h"
 #include "intel_pm.h"
 
+/* Retry timestamp calculation up to 3 times to satisfy
+ * drm_timestamp_precision before giving up.
+ */
+#define I915_TIMESTAMP_MAXRETRIES 3
+
 /**
  * DOC: interrupt handling
  *
@@ -762,10 +767,11 @@ static int __intel_get_crtc_scanline(struct intel_crtc 
*crtc)
return (position + crtc->scanline_offset) % vtotal;
 }
 
-bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int index,
- bool in_vblank_irq, int *vpos, int *hpos,
- ktime_t *stime, ktime_t *etime,
- const struct drm_display_mode *mode)
+static bool i915_get_crtc_scanoutpos(struct drm_device *dev,
+unsigned int index, bool in_vblank_irq,
+int *vpos, int *hpos,
+ktime_t *stime, ktime_t *etime,
+const struct drm_display_mode *mode)
 {
struct drm_i915_private *dev_priv = to_i915(dev);
struct intel_crtc *crtc = to_intel_crtc(drm_crtc_from_index(dev, 
index));
@@ -879,6 +885,109 @@ bool i915_get_crtc_scanoutpos(struct drm_device *dev, 
unsigned int index,
return true;
 }
 
+bool i915_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
+   unsigned int pipe,
+   int *max_error,
+   ktime_t *vblank_time,
+   bool in_vblank_irq)
+{
+   struct timespec64 ts_etime, ts_vblank_time;
+   ktime_t stime, etime;
+   bool vbl_status;
+   struct drm_crtc *crtc;
+   const struct drm_display_mode *mode;
+   struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
+   int vpos, hpos, i;
+   int delta_ns, duration_ns;
+
+   crtc = drm_crtc_from_index(dev, pipe);
+
+   if (pipe >= dev->num_crtcs || !crtc) {
+   DRM_ERROR("Invalid crtc %u\n", pipe);
+   return false;
+   }
+
+   if (drm_drv_uses_atomic_modeset(dev))
+   mode = &vblank->hwmode;
+   else
+   mode = &crtc->hwmode;
+
+   /* If mode timing undefined, just return as no-op:
+* Happens during initial modesetting of a crtc.
+*/
+   if (mode->crtc_clock == 0) {
+   DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
+   WARN_ON_ONCE(drm_drv_uses_atomic_modeset(dev));
+
+   return false;
+   }
+
+   /* Get current scanout position with system timestamp.
+* Repeat query up to DRM_TIMESTAMP_MAXRETRIES times
+* if single query takes longer than max_error nanoseconds.
+*
+* This guarantees a tight bound on maximum error if
+* code gets preempted or delayed for some reason.
+*/
+   for (i = 0; i < I915_TIMESTAMP_MAXRETRIES; i++) {
+   /*
+* Get vertical and horizontal scanout position vpos, hpos,
+* and bounding timestamps stime, etime, pre/post query.
+*/
+   vbl_status = i915_get_crtc_scanoutpos(dev, pipe, in_vblank_irq,
+ &vpos, &hpos, &stime,
+ &etime, mode);
+   /* Return as no-op if scanout query unsupported or failed. */
+   if (!vbl_status) {
+   DRM_DEBUG("crtc %u : scanoutpos query failed.\n",
+

[Intel-gfx] [PATCH 10/23] drm: Evaluate struct drm_device.vblank_disable_immediate on each use

2020-01-10 Thread Thomas Zimmermann
VBLANK interrupts can be disabled immediately or with a delay, where the
latter is the default. The former option can be selected by setting
get_vblank_timestamp, and enabling vblank_disable_immediate in struct
drm_device.

The setup is only evaluated once when DRM initializes VBLANKs. Evaluating
the settings on each use of vblank_disable_immediate will allow for easy
integration of CRTC VBLANK functions.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/drm_vblank.c | 31 ++-
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index b84065911d69..cbe8f3009df5 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -481,19 +481,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");
 
-   /* Driver specific high-precision vblank timestamping supported? */
-   if (dev->driver->get_vblank_timestamp)
-   DRM_INFO("Driver supports precise vblank timestamp query.\n");
-   else
-   DRM_INFO("No driver support for vblank timestamp query.\n");
-
-   /* Must have precise timestamping for reliable vblank instant disable */
-   if (dev->vblank_disable_immediate && 
!dev->driver->get_vblank_timestamp) {
-   dev->vblank_disable_immediate = false;
-   DRM_INFO("Setting vblank_disable_immediate to false because "
-"get_vblank_timestamp == NULL\n");
-   }
-
return 0;
 
 err:
@@ -1061,6 +1048,15 @@ int drm_crtc_vblank_get(struct drm_crtc *crtc)
 }
 EXPORT_SYMBOL(drm_crtc_vblank_get);
 
+static bool __vblank_disable_immediate(struct drm_device *dev, unsigned int 
pipe)
+{
+   if (!dev->vblank_disable_immediate)
+   return false;
+   if (!dev->driver->get_vblank_timestamp)
+   return false;
+   return true;
+}
+
 static void drm_vblank_put(struct drm_device *dev, unsigned int pipe)
 {
struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
@@ -1077,7 +1073,7 @@ static void drm_vblank_put(struct drm_device *dev, 
unsigned int pipe)
return;
else if (drm_vblank_offdelay < 0)
vblank_disable_fn(&vblank->disable_timer);
-   else if (!dev->vblank_disable_immediate)
+   else if (__vblank_disable_immediate(dev, pipe))
mod_timer(&vblank->disable_timer,
  jiffies + ((drm_vblank_offdelay * HZ)/1000));
}
@@ -1654,7 +1650,7 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void 
*data,
/* If the counter is currently enabled and accurate, short-circuit
 * queries to return the cached timestamp of the last vblank.
 */
-   if (dev->vblank_disable_immediate &&
+   if (__vblank_disable_immediate(dev, pipe) &&
drm_wait_vblank_is_query(vblwait) &&
READ_ONCE(vblank->enabled)) {
drm_wait_vblank_reply(dev, pipe, &vblwait->reply);
@@ -1811,7 +1807,7 @@ bool drm_handle_vblank(struct drm_device *dev, unsigned 
int pipe)
 * been signaled. The disable has to be last (after
 * drm_handle_vblank_events) so that the timestamp is always accurate.
 */
-   disable_irq = (dev->vblank_disable_immediate &&
+   disable_irq = (__vblank_disable_immediate(dev, pipe) &&
   drm_vblank_offdelay > 0 &&
   !atomic_read(&vblank->refcount));
 
@@ -1884,7 +1880,8 @@ int drm_crtc_get_sequence_ioctl(struct drm_device *dev, 
void *data,
pipe = drm_crtc_index(crtc);
 
vblank = &dev->vblank[pipe];
-   vblank_enabled = dev->vblank_disable_immediate && 
READ_ONCE(vblank->enabled);
+   vblank_enabled = __vblank_disable_immediate(dev, pipe) &&
+READ_ONCE(vblank->enabled);
 
if (!vblank_enabled) {
ret = drm_crtc_vblank_get(crtc);
-- 
2.24.1

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


[Intel-gfx] [PATCH 04/23] drm/nouveau: Convert to struct drm_crtc_helper_funcs.get_scanout_position()

2020-01-10 Thread Thomas Zimmermann
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position(). Convert
nouveau over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c   |  1 +
 drivers/gpu/drm/nouveau/dispnv50/head.c   |  1 +
 drivers/gpu/drm/nouveau/nouveau_display.c | 14 +++---
 drivers/gpu/drm/nouveau/nouveau_display.h |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c |  1 -
 5 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c 
b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 37c50ea8f847..17e9d1c078a0 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -1258,6 +1258,7 @@ static const struct drm_crtc_helper_funcs 
nv04_crtc_helper_funcs = {
.mode_set_base = nv04_crtc_mode_set_base,
.mode_set_base_atomic = nv04_crtc_mode_set_base_atomic,
.disable = nv_crtc_disable,
+   .get_scanout_position = nouveau_display_scanoutpos,
 };
 
 static const uint32_t modeset_formats[] = {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c 
b/drivers/gpu/drm/nouveau/dispnv50/head.c
index c9692df2b76c..1354d19d9a18 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head.c
@@ -403,6 +403,7 @@ nv50_head_atomic_check(struct drm_crtc *crtc, struct 
drm_crtc_state *state)
 static const struct drm_crtc_helper_funcs
 nv50_head_help = {
.atomic_check = nv50_head_atomic_check,
+   .get_scanout_position = nouveau_display_scanoutpos,
 };
 
 static void
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
b/drivers/gpu/drm/nouveau/nouveau_display.c
index 53f9bceaf17a..86f99dc8fcef 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -136,21 +136,13 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, 
int *vpos, int *hpos,
 }
 
 bool
-nouveau_display_scanoutpos(struct drm_device *dev, unsigned int pipe,
+nouveau_display_scanoutpos(struct drm_crtc *crtc,
   bool in_vblank_irq, int *vpos, int *hpos,
   ktime_t *stime, ktime_t *etime,
   const struct drm_display_mode *mode)
 {
-   struct drm_crtc *crtc;
-
-   list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-   if (nouveau_crtc(crtc)->index == pipe) {
-   return nouveau_display_scanoutpos_head(crtc, vpos, hpos,
-  stime, etime);
-   }
-   }
-
-   return false;
+   return nouveau_display_scanoutpos_head(crtc, vpos, hpos,
+  stime, etime);
 }
 
 static void
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.h 
b/drivers/gpu/drm/nouveau/nouveau_display.h
index 6e8e66882e45..71e2af693f7f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.h
+++ b/drivers/gpu/drm/nouveau/nouveau_display.h
@@ -63,7 +63,7 @@ int  nouveau_display_suspend(struct drm_device *dev, bool 
runtime);
 void nouveau_display_resume(struct drm_device *dev, bool runtime);
 int  nouveau_display_vblank_enable(struct drm_device *, unsigned int);
 void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
-bool  nouveau_display_scanoutpos(struct drm_device *, unsigned int,
+bool  nouveau_display_scanoutpos(struct drm_crtc *,
 bool, int *, int *, ktime_t *,
 ktime_t *, const struct drm_display_mode *);
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 2cd83849600f..9fb38a018240 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1123,7 +1123,6 @@ driver_stub = {
 
.enable_vblank = nouveau_display_vblank_enable,
.disable_vblank = nouveau_display_vblank_disable,
-   .get_scanout_position = nouveau_display_scanoutpos,
.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 
.ioctls = nouveau_ioctls,
-- 
2.24.1

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


[Intel-gfx] [PATCH 21/23] drm/vkms: Convert to CRTC VBLANK callbacks

2020-01-10 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert vkms over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/vkms/vkms_crtc.c | 9 ++---
 drivers/gpu/drm/vkms/vkms_drv.c  | 1 -
 drivers/gpu/drm/vkms/vkms_drv.h  | 4 
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index 74f703b8d22a..ac85e17428f8 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -76,10 +76,12 @@ static void vkms_disable_vblank(struct drm_crtc *crtc)
hrtimer_cancel(&out->vblank_hrtimer);
 }
 
-bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-  int *max_error, ktime_t *vblank_time,
-  bool in_vblank_irq)
+static bool vkms_get_vblank_timestamp(struct drm_crtc *crtc,
+ int *max_error, ktime_t *vblank_time,
+ bool in_vblank_irq)
 {
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev);
struct vkms_output *output = &vkmsdev->output;
struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
@@ -154,6 +156,7 @@ static const struct drm_crtc_funcs vkms_crtc_funcs = {
.atomic_destroy_state   = vkms_atomic_crtc_destroy_state,
.enable_vblank  = vkms_enable_vblank,
.disable_vblank = vkms_disable_vblank,
+   .get_vblank_timestamp   = vkms_get_vblank_timestamp,
.get_crc_sources= vkms_get_crc_sources,
.set_crc_source = vkms_set_crc_source,
.verify_crc_source  = vkms_verify_crc_source,
diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
index 25bd7519295f..860de052e820 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.c
+++ b/drivers/gpu/drm/vkms/vkms_drv.c
@@ -103,7 +103,6 @@ static struct drm_driver vkms_driver = {
.dumb_create= vkms_dumb_create,
.gem_vm_ops = &vkms_gem_vm_ops,
.gem_free_object_unlocked = vkms_gem_free_object,
-   .get_vblank_timestamp   = vkms_get_vblank_timestamp,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import_sg_table = vkms_prime_import_sg_table,
 
diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
index 7d52e24564db..eda04ffba7b1 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.h
+++ b/drivers/gpu/drm/vkms/vkms_drv.h
@@ -111,10 +111,6 @@ struct vkms_gem_object {
 int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
   struct drm_plane *primary, struct drm_plane *cursor);
 
-bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
-  int *max_error, ktime_t *vblank_time,
-  bool in_vblank_irq);
-
 int vkms_output_init(struct vkms_device *vkmsdev, int index);
 
 struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev,
-- 
2.24.1

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


[Intel-gfx] [PATCH 09/23] drm: Remove struct drm_driver.get_scanout_position()

2020-01-10 Thread Thomas Zimmermann
All users of struct drm_driver.get_scanout_position() have been
covnerted to the respective CRTC helper function. Remove the callback
from struct drm_driver.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/drm_vblank.c | 13 ++---
 include/drm/drm_drv.h| 52 
 2 files changed, 2 insertions(+), 63 deletions(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index c12f0b333e14..b84065911d69 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -633,8 +633,7 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct 
drm_device *dev,
}
 
/* Scanout position query not supported? Should not happen. */
-   if (!dev->driver->get_scanout_position ||
-   !crtc->helper_private->get_scanout_position) {
+   if (!crtc->helper_private->get_scanout_position) {
DRM_ERROR("Called from CRTC w/o get_scanout_position()!?\n");
return false;
}
@@ -666,17 +665,9 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct 
drm_device *dev,
 * Get vertical and horizontal scanout position vpos, hpos,
 * and bounding timestamps stime, etime, pre/post query.
 */
-   if (crtc->helper_private->get_scanout_position) {
-   vbl_status =
-   crtc->helper_private->get_scanout_position(
+   vbl_status = crtc->helper_private->get_scanout_position(
crtc, in_vblank_irq, &vpos, &hpos,
&stime, &etime, mode);
-   } else {
-   vbl_status =
-   dev->driver->get_scanout_position(
-   dev, pipe, in_vblank_irq, &vpos,
-   &hpos, &stime, &etime, mode);
-   }
 
/* Return as no-op if scanout query unsupported or failed. */
if (!vbl_status) {
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index d0049e5786fc..b704e252f3b2 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -318,58 +318,6 @@ struct drm_driver {
 */
void (*disable_vblank) (struct drm_device *dev, unsigned int pipe);
 
-   /**
-* @get_scanout_position:
-*
-* Called by vblank timestamping code.
-*
-* Returns the current display scanout position from a crtc, and an
-* optional accurate ktime_get() timestamp of when position was
-* measured. Note that this is a helper callback which is only used if a
-* driver uses drm_calc_vbltimestamp_from_scanoutpos() for the
-* @get_vblank_timestamp callback.
-*
-* Parameters:
-*
-* dev:
-* DRM device.
-* pipe:
-* Id of the crtc to query.
-* in_vblank_irq:
-* True when called from drm_crtc_handle_vblank().  Some drivers
-* need to apply some workarounds for gpu-specific vblank irq quirks
-* if flag is set.
-* vpos:
-* Target location for current vertical scanout position.
-* hpos:
-* Target location for current horizontal scanout position.
-* stime:
-* Target location for timestamp taken immediately before
-* scanout position query. Can be NULL to skip timestamp.
-* etime:
-* Target location for timestamp taken immediately after
-* scanout position query. Can be NULL to skip timestamp.
-* mode:
-* Current display timings.
-*
-* Returns vpos as a positive number while in active scanout area.
-* Returns vpos as a negative number inside vblank, counting the number
-* of scanlines to go until end of vblank, e.g., -1 means "one scanline
-* until start of active scanout / end of vblank."
-*
-* Returns:
-*
-* True on success, false if a reliable scanout position counter could
-* not be read out.
-*
-* This is deprecated and should not be used by new drivers.
-* Use &drm_crtc_helper_funcs.get_scanout_position instead.
-*/
-   bool (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
- bool in_vblank_irq, int *vpos, int *hpos,
- ktime_t *stime, ktime_t *etime,
- const struct drm_display_mode *mode);
-
/**
 * @get_vblank_timestamp:
 *
-- 
2.24.1

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


[Intel-gfx] [PATCH 12/23] drm/amdgpu: Convert to CRTC VBLANK callbacks

2020-01-10 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert amdgpu over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |  4 
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   | 24 +++
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c|  4 
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c|  4 
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c |  4 
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c |  4 
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c  |  4 
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  2 ++
 9 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 81a531b652aa..c1262ab588c9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1197,6 +1197,9 @@ int amdgpu_device_resume(struct drm_device *dev, bool 
fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
+u32 amdgpu_crtc_get_vblank_counter(struct drm_crtc *crtc);
+int amdgpu_crtc_enable_vblank(struct drm_crtc *crtc);
+void amdgpu_crtc_disable_vblank(struct drm_crtc *crtc);
 long amdgpu_kms_compat_ioctl(struct file *filp, unsigned int cmd,
 unsigned long arg);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 0749285dd1c7..9baa1ddf8693 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1377,10 +1377,6 @@ static struct drm_driver kms_driver = {
.postclose = amdgpu_driver_postclose_kms,
.lastclose = amdgpu_driver_lastclose_kms,
.unload = amdgpu_driver_unload_kms,
-   .get_vblank_counter = amdgpu_get_vblank_counter_kms,
-   .enable_vblank = amdgpu_enable_vblank_kms,
-   .disable_vblank = amdgpu_disable_vblank_kms,
-   .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
.irq_handler = amdgpu_irq_handler,
.ioctls = amdgpu_ioctls_kms,
.gem_free_object_unlocked = amdgpu_gem_object_free,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 60591dbc2097..efe4671fb032 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -1174,6 +1174,14 @@ u32 amdgpu_get_vblank_counter_kms(struct drm_device 
*dev, unsigned int pipe)
return count;
 }
 
+u32 amdgpu_crtc_get_vblank_counter(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
+
+   return amdgpu_get_vblank_counter_kms(dev, pipe);
+}
+
 /**
  * amdgpu_enable_vblank_kms - enable vblank interrupt
  *
@@ -1191,6 +1199,14 @@ int amdgpu_enable_vblank_kms(struct drm_device *dev, 
unsigned int pipe)
return amdgpu_irq_get(adev, &adev->crtc_irq, idx);
 }
 
+int amdgpu_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
+
+   return amdgpu_enable_vblank_kms(dev, pipe);
+}
+
 /**
  * amdgpu_disable_vblank_kms - disable vblank interrupt
  *
@@ -1207,6 +1223,14 @@ void amdgpu_disable_vblank_kms(struct drm_device *dev, 
unsigned int pipe)
amdgpu_irq_put(adev, &adev->crtc_irq, idx);
 }
 
+void amdgpu_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
+
+   amdgpu_disable_vblank_kms(dev, pipe);
+}
+
 const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
DRM_IOCTL_DEF_DRV(AMDGPU_GEM_CREATE, amdgpu_gem_create_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(AMDGPU_CTX, amdgpu_ctx_ioctl, 
DRM_AUTH|DRM_RENDER_ALLOW),
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index bdc1e0f036d4..8e62f46f0bfd 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2494,6 +2494,10 @@ static const struct drm_crtc_funcs dce_v10_0_crtc_funcs 
= {
.set_config = amdgpu_display_crtc_set_config,
.destroy = dce_v10_0_crtc_destroy,
.page_flip_target = amdgpu_display_crtc_page_flip_target,
+   .get_vblank_counter = amdgpu_crtc_get_vblank_counter,
+   .enable_vblank = amdgpu_crtc_enable_vblank,
+   .disable_vblank = amdgpu_crtc_disable_vblank,
+   .get_vblank_timestamp = drm_crtc_calc_vbltimestamp_from_scanoutpos,
 };
 
 static void dce_v10_0_crtc_dpms(struct drm_crtc *crtc, int mode)
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 0319da5f7bf9..9e37e4a78403 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers

[Intel-gfx] [PATCH 14/23] drm/i915: Convert to CRTC VBLANK callbacks

2020-01-10 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert i915 over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/i915/display/intel_display.c |  7 +++
 drivers/gpu/drm/i915/i915_drv.c  |  2 --
 drivers/gpu/drm/i915/i915_irq.c  | 13 +++--
 drivers/gpu/drm/i915/i915_irq.h  |  3 +--
 4 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index da5266e76738..515788698298 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -16227,6 +16227,7 @@ static const struct drm_crtc_funcs bdw_crtc_funcs = {
.get_vblank_counter = g4x_get_vblank_counter,
.enable_vblank = bdw_enable_vblank,
.disable_vblank = bdw_disable_vblank,
+   .get_vblank_timestamp = i915_calc_vbltimestamp_from_scanoutpos,
 };
 
 static const struct drm_crtc_funcs ilk_crtc_funcs = {
@@ -16235,6 +16236,7 @@ static const struct drm_crtc_funcs ilk_crtc_funcs = {
.get_vblank_counter = g4x_get_vblank_counter,
.enable_vblank = ilk_enable_vblank,
.disable_vblank = ilk_disable_vblank,
+   .get_vblank_timestamp = i915_calc_vbltimestamp_from_scanoutpos,
 };
 
 static const struct drm_crtc_funcs g4x_crtc_funcs = {
@@ -16243,6 +16245,7 @@ static const struct drm_crtc_funcs g4x_crtc_funcs = {
.get_vblank_counter = g4x_get_vblank_counter,
.enable_vblank = i965_enable_vblank,
.disable_vblank = i965_disable_vblank,
+   .get_vblank_timestamp = i915_calc_vbltimestamp_from_scanoutpos,
 };
 
 static const struct drm_crtc_funcs i965_crtc_funcs = {
@@ -16251,6 +16254,7 @@ static const struct drm_crtc_funcs i965_crtc_funcs = {
.get_vblank_counter = i915_get_vblank_counter,
.enable_vblank = i965_enable_vblank,
.disable_vblank = i965_disable_vblank,
+   .get_vblank_timestamp = i915_calc_vbltimestamp_from_scanoutpos,
 };
 
 static const struct drm_crtc_funcs i915gm_crtc_funcs = {
@@ -16259,6 +16263,7 @@ static const struct drm_crtc_funcs i915gm_crtc_funcs = {
.get_vblank_counter = i915_get_vblank_counter,
.enable_vblank = i915gm_enable_vblank,
.disable_vblank = i915gm_disable_vblank,
+   .get_vblank_timestamp = i915_calc_vbltimestamp_from_scanoutpos,
 };
 
 static const struct drm_crtc_funcs i915_crtc_funcs = {
@@ -16267,6 +16272,7 @@ static const struct drm_crtc_funcs i915_crtc_funcs = {
.get_vblank_counter = i915_get_vblank_counter,
.enable_vblank = i8xx_enable_vblank,
.disable_vblank = i8xx_disable_vblank,
+   .get_vblank_timestamp = i915_calc_vbltimestamp_from_scanoutpos,
 };
 
 static const struct drm_crtc_funcs i8xx_crtc_funcs = {
@@ -16275,6 +16281,7 @@ static const struct drm_crtc_funcs i8xx_crtc_funcs = {
/* no hw vblank counter */
.enable_vblank = i8xx_enable_vblank,
.disable_vblank = i8xx_disable_vblank,
+   .get_vblank_timestamp = i915_calc_vbltimestamp_from_scanoutpos,
 };
 
 static struct intel_crtc *intel_crtc_alloc(void)
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 4a0a7fb85c53..30b9ba136a81 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -2769,8 +2769,6 @@ static struct drm_driver driver = {
.gem_prime_export = i915_gem_prime_export,
.gem_prime_import = i915_gem_prime_import,
 
-   .get_vblank_timestamp = i915_calc_vbltimestamp_from_scanoutpos,
-
.dumb_create = i915_gem_dumb_create,
.dumb_map_offset = i915_gem_dumb_mmap_offset,
 
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 99d0c3b0feae..dbbbdff8fa89 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -885,28 +885,21 @@ static bool i915_get_crtc_scanoutpos(struct drm_device 
*dev,
return true;
 }
 
-bool i915_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
-   unsigned int pipe,
+bool i915_calc_vbltimestamp_from_scanoutpos(struct drm_crtc *crtc,
int *max_error,
ktime_t *vblank_time,
bool in_vblank_irq)
 {
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
struct timespec64 ts_etime, ts_vblank_time;
ktime_t stime, etime;
bool vbl_status;
-   struct drm_crtc *crtc;
const struct drm_display_mode *mode;
struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
int vpos, hpos, i;
int delta_ns, duration_ns;
 
-   crtc = drm_crtc_from_index(dev, pipe);
-
-   if (pipe >= dev->num_crtcs || !crtc) {
-   DRM_ERROR("Invalid crtc %u\n", pipe);
-   return false;
-

[Intel-gfx] [PATCH 23/23] drm: Cleanup VBLANK callbacks in struct drm_driver

2020-01-10 Thread Thomas Zimmermann
All non-legacy users of VBLANK functions in struct drm_driver have been
converted to use the respective interfaces in struct drm_crtc_funcs. The
remaining users of VBLANK callbacks in struct drm_driver are legacy drivers
with userspace modesetting.

There are no users left of get_vblank_timestamp(), so the callback is
being removed. The other VBLANK callbacks are being moved to the legacy
section at the end of struct drm_driver.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/drm_vblank.c |  39 +-
 include/drm/drm_drv.h| 101 ++-
 2 files changed, 17 insertions(+), 123 deletions(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 7cf436a4b908..ceff68474d4d 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -138,10 +138,9 @@ static u32 __get_vblank_counter(struct drm_device *dev, 
unsigned int pipe)
 
if (crtc->funcs->get_vblank_counter)
return crtc->funcs->get_vblank_counter(crtc);
-   }
-
-   if (dev->driver->get_vblank_counter)
+   } else if (dev->driver->get_vblank_counter) {
return dev->driver->get_vblank_counter(dev, pipe);
+   }
 
return drm_vblank_no_hw_counter(dev, pipe);
 }
@@ -334,8 +333,7 @@ u64 drm_crtc_accurate_vblank_count(struct drm_crtc *crtc)
unsigned long flags;
 
WARN_ONCE(drm_debug_enabled(DRM_UT_VBL) &&
- !crtc->funcs->get_vblank_timestamp &&
- !dev->driver->get_vblank_timestamp,
+ !crtc->funcs->get_vblank_timestamp,
  "This function requires support for accurate vblank 
timestamps.");
 
spin_lock_irqsave(&dev->vblank_time_lock, flags);
@@ -357,13 +355,11 @@ static void __disable_vblank(struct drm_device *dev, 
unsigned int pipe)
if (WARN_ON(!crtc))
return;
 
-   if (crtc->funcs->disable_vblank) {
+   if (crtc->funcs->disable_vblank)
crtc->funcs->disable_vblank(crtc);
-   return;
-   }
+   } else {
+   dev->driver->disable_vblank(dev, pipe);
}
-
-   dev->driver->disable_vblank(dev, pipe);
 }
 
 /*
@@ -791,9 +787,6 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned 
int pipe,
 
ret = crtc->funcs->get_vblank_timestamp(crtc, &max_error,
tvblank, in_vblank_irq);
-   } else if (dev->driver->get_vblank_timestamp && (max_error > 0)) {
-   ret = dev->driver->get_vblank_timestamp(dev, pipe, &max_error,
-   tvblank, in_vblank_irq);
}
 
/* GPU high precision timestamp query unsupported or failed.
@@ -1016,9 +1009,11 @@ static int __enable_vblank(struct drm_device *dev, 
unsigned int pipe)
 
if (crtc->funcs->enable_vblank)
return crtc->funcs->enable_vblank(crtc);
+   } else if (dev->driver->enable_vblank) {
+   return dev->driver->enable_vblank(dev, pipe);
}
 
-   return dev->driver->enable_vblank(dev, pipe);
+   return -EINVAL;
 }
 
 static int drm_vblank_enable(struct drm_device *dev, unsigned int pipe)
@@ -1109,13 +1104,10 @@ static bool __vblank_disable_immediate(struct 
drm_device *dev, unsigned int pipe
return false;
 
crtc = drm_crtc_from_index(dev, pipe);
-   if (crtc && crtc->funcs->get_vblank_timestamp)
-   return true;
-
-   if (dev->driver->get_vblank_timestamp)
-   return true;
+   if (!crtc || !crtc->funcs->get_vblank_timestamp)
+   return false;
 
-   return false;
+   return true;
 }
 
 static void drm_vblank_put(struct drm_device *dev, unsigned int pipe)
@@ -1798,7 +1790,6 @@ static void drm_handle_vblank_events(struct drm_device 
*dev, unsigned int pipe)
struct drm_pending_vblank_event *e, *t;
ktime_t now;
u64 seq;
-   bool high_prec;
 
assert_spin_locked(&dev->event_lock);
 
@@ -1818,10 +1809,8 @@ static void drm_handle_vblank_events(struct drm_device 
*dev, unsigned int pipe)
send_vblank_event(dev, e, seq, now);
}
 
-   high_prec = crtc->funcs->get_vblank_timestamp ||
-   dev->driver->get_vblank_timestamp;
-
-   trace_drm_vblank_event(pipe, seq, now, high_prec);
+   trace_drm_vblank_event(pipe, seq, now,
+  crtc->funcs->get_vblank_timestamp != NULL);
 }
 
 /**
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index b704e252f3b2..e290b3aca6eb 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -268,104 +268,6 @@ struct drm_driver {
 */
void (*release) (struct drm_device *);
 
-   /**
-* @get_vblank_counter:
-*
-* Driver callback for fetching a raw hardware vbl

[Intel-gfx] [PATCH 13/23] drm/gma500: Convert to CRTC VBLANK callbacks

2020-01-10 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert gma500 over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/gma500/cdv_intel_display.c |  3 +++
 drivers/gpu/drm/gma500/psb_drv.c   |  4 
 drivers/gpu/drm/gma500/psb_drv.h   |  6 +++---
 drivers/gpu/drm/gma500/psb_intel_display.c |  3 +++
 drivers/gpu/drm/gma500/psb_irq.c   | 12 +---
 drivers/gpu/drm/gma500/psb_irq.h   |  7 ---
 6 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/gma500/cdv_intel_display.c 
b/drivers/gpu/drm/gma500/cdv_intel_display.c
index 1ed854f498b7..686385a66167 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_display.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_display.c
@@ -977,6 +977,9 @@ const struct drm_crtc_funcs cdv_intel_crtc_funcs = {
.set_config = gma_crtc_set_config,
.destroy = gma_crtc_destroy,
.page_flip = gma_crtc_page_flip,
+   .enable_vblank = psb_enable_vblank,
+   .disable_vblank = psb_disable_vblank,
+   .get_vblank_counter = psb_get_vblank_counter,
 };
 
 const struct gma_clock_funcs cdv_clock_funcs = {
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 52591416f8fe..36cb292fdebe 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -363,7 +363,6 @@ static int psb_driver_load(struct drm_device *dev, unsigned 
long flags)
drm_irq_install(dev, dev->pdev->irq);
 
dev->max_vblank_count = 0xff; /* only 24 bits of frame count */
-   dev->driver->get_vblank_counter = psb_get_vblank_counter;
 
psb_modeset_init(dev);
psb_fbdev_init(dev);
@@ -507,9 +506,6 @@ static struct drm_driver driver = {
.irq_postinstall = psb_irq_postinstall,
.irq_uninstall = psb_irq_uninstall,
.irq_handler = psb_irq_handler,
-   .enable_vblank = psb_enable_vblank,
-   .disable_vblank = psb_disable_vblank,
-   .get_vblank_counter = psb_get_vblank_counter,
 
.gem_free_object = psb_gem_free_object,
.gem_vm_ops = &psb_gem_vm_ops,
diff --git a/drivers/gpu/drm/gma500/psb_drv.h b/drivers/gpu/drm/gma500/psb_drv.h
index 3d4ef3071d45..956926341316 100644
--- a/drivers/gpu/drm/gma500/psb_drv.h
+++ b/drivers/gpu/drm/gma500/psb_drv.h
@@ -681,15 +681,15 @@ extern void psb_irq_turn_off_dpst(struct drm_device *dev);
 extern void psb_irq_uninstall_islands(struct drm_device *dev, int hw_islands);
 extern int psb_vblank_wait2(struct drm_device *dev, unsigned int *sequence);
 extern int psb_vblank_wait(struct drm_device *dev, unsigned int *sequence);
-extern int psb_enable_vblank(struct drm_device *dev, unsigned int pipe);
-extern void psb_disable_vblank(struct drm_device *dev, unsigned int pipe);
+extern int psb_enable_vblank(struct drm_crtc *crtc);
+extern void psb_disable_vblank(struct drm_crtc *crtc);
 void
 psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
 
 void
 psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
 
-extern u32 psb_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
+extern u32 psb_get_vblank_counter(struct drm_crtc *crtc);
 
 /* framebuffer.c */
 extern int psbfb_probed(struct drm_device *dev);
diff --git a/drivers/gpu/drm/gma500/psb_intel_display.c 
b/drivers/gpu/drm/gma500/psb_intel_display.c
index fed3b563e62e..531c5485be17 100644
--- a/drivers/gpu/drm/gma500/psb_intel_display.c
+++ b/drivers/gpu/drm/gma500/psb_intel_display.c
@@ -433,6 +433,9 @@ const struct drm_crtc_funcs psb_intel_crtc_funcs = {
.set_config = gma_crtc_set_config,
.destroy = gma_crtc_destroy,
.page_flip = gma_crtc_page_flip,
+   .enable_vblank = psb_enable_vblank,
+   .disable_vblank = psb_disable_vblank,
+   .get_vblank_counter = psb_get_vblank_counter,
 };
 
 const struct gma_clock_funcs psb_clock_funcs = {
diff --git a/drivers/gpu/drm/gma500/psb_irq.c b/drivers/gpu/drm/gma500/psb_irq.c
index 40a37e400b02..7ec031d28dc0 100644
--- a/drivers/gpu/drm/gma500/psb_irq.c
+++ b/drivers/gpu/drm/gma500/psb_irq.c
@@ -507,8 +507,10 @@ int psb_irq_disable_dpst(struct drm_device *dev)
 /*
  * It is used to enable VBLANK interrupt
  */
-int psb_enable_vblank(struct drm_device *dev, unsigned int pipe)
+int psb_enable_vblank(struct drm_crtc *crtc)
 {
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
struct drm_psb_private *dev_priv = dev->dev_private;
unsigned long irqflags;
uint32_t reg_val = 0;
@@ -546,8 +548,10 @@ int psb_enable_vblank(struct drm_device *dev, unsigned int 
pipe)
 /*
  * It is used to disable VBLANK interrupt
  */
-void psb_disable_vblank(struct drm_device *dev, unsigned int pipe)
+void psb_disable_vblank(struct drm_crtc *crtc)
 {
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
struct drm_psb_private *dev_priv = dev->dev_private;
   

[Intel-gfx] [PATCH 16/23] drm/nouveau: Convert to CRTC VBLANK callbacks

2020-01-10 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert nouvean over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c   |  3 +++
 drivers/gpu/drm/nouveau/dispnv50/head.c   |  4 
 drivers/gpu/drm/nouveau/nouveau_display.c | 14 ++
 drivers/gpu/drm/nouveau/nouveau_display.h |  4 ++--
 drivers/gpu/drm/nouveau/nouveau_drm.c |  4 
 5 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c 
b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 17e9d1c078a0..4a4122a1c057 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -1248,6 +1248,9 @@ static const struct drm_crtc_funcs nv04_crtc_funcs = {
.set_config = drm_crtc_helper_set_config,
.page_flip = nv04_crtc_page_flip,
.destroy = nv_crtc_destroy,
+   .enable_vblank = nouveau_display_vblank_enable,
+   .disable_vblank = nouveau_display_vblank_disable,
+   .get_vblank_timestamp = drm_crtc_calc_vbltimestamp_from_scanoutpos,
 };
 
 static const struct drm_crtc_helper_funcs nv04_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c 
b/drivers/gpu/drm/nouveau/dispnv50/head.c
index 1354d19d9a18..a6b7416ca270 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head.c
@@ -29,6 +29,7 @@
 
 #include 
 #include 
+#include 
 #include "nouveau_connector.h"
 void
 nv50_head_flush_clr(struct nv50_head *head,
@@ -472,6 +473,9 @@ nv50_head_func = {
.page_flip = drm_atomic_helper_page_flip,
.atomic_duplicate_state = nv50_head_atomic_duplicate_state,
.atomic_destroy_state = nv50_head_atomic_destroy_state,
+   .enable_vblank = nouveau_display_vblank_enable,
+   .disable_vblank = nouveau_display_vblank_disable,
+   .get_vblank_timestamp = drm_crtc_calc_vbltimestamp_from_scanoutpos,
 };
 
 int
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
b/drivers/gpu/drm/nouveau/nouveau_display.c
index 86f99dc8fcef..700817dc4fa0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -54,15 +54,10 @@ nouveau_display_vblank_handler(struct nvif_notify *notify)
 }
 
 int
-nouveau_display_vblank_enable(struct drm_device *dev, unsigned int pipe)
+nouveau_display_vblank_enable(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc;
struct nouveau_crtc *nv_crtc;
 
-   crtc = drm_crtc_from_index(dev, pipe);
-   if (!crtc)
-   return -EINVAL;
-
nv_crtc = nouveau_crtc(crtc);
nvif_notify_get(&nv_crtc->vblank);
 
@@ -70,15 +65,10 @@ nouveau_display_vblank_enable(struct drm_device *dev, 
unsigned int pipe)
 }
 
 void
-nouveau_display_vblank_disable(struct drm_device *dev, unsigned int pipe)
+nouveau_display_vblank_disable(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc;
struct nouveau_crtc *nv_crtc;
 
-   crtc = drm_crtc_from_index(dev, pipe);
-   if (!crtc)
-   return;
-
nv_crtc = nouveau_crtc(crtc);
nvif_notify_put(&nv_crtc->vblank);
 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.h 
b/drivers/gpu/drm/nouveau/nouveau_display.h
index 71e2af693f7f..71c7048948f3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.h
+++ b/drivers/gpu/drm/nouveau/nouveau_display.h
@@ -61,8 +61,8 @@ int  nouveau_display_init(struct drm_device *dev, bool 
resume, bool runtime);
 void nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime);
 int  nouveau_display_suspend(struct drm_device *dev, bool runtime);
 void nouveau_display_resume(struct drm_device *dev, bool runtime);
-int  nouveau_display_vblank_enable(struct drm_device *, unsigned int);
-void nouveau_display_vblank_disable(struct drm_device *, unsigned int);
+int  nouveau_display_vblank_enable(struct drm_crtc *);
+void nouveau_display_vblank_disable(struct drm_crtc *);
 bool  nouveau_display_scanoutpos(struct drm_crtc *,
 bool, int *, int *, ktime_t *,
 ktime_t *, const struct drm_display_mode *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c 
b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 9fb38a018240..0003343014ce 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1121,10 +1121,6 @@ driver_stub = {
.debugfs_init = nouveau_drm_debugfs_init,
 #endif
 
-   .enable_vblank = nouveau_display_vblank_enable,
-   .disable_vblank = nouveau_display_vblank_disable,
-   .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-
.ioctls = nouveau_ioctls,
.num_ioctls = ARRAY_SIZE(nouveau_ioctls),
.fops = &nouveau_driver_fops,
-- 
2.24.1

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


[Intel-gfx] [PATCH 19/23] drm/stm: Convert to CRTC VBLANK callbacks

2020-01-10 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert stm over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/stm/drv.c  | 1 -
 drivers/gpu/drm/stm/ltdc.c | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c
index 486985604109..ea9fcbdc68b3 100644
--- a/drivers/gpu/drm/stm/drv.c
+++ b/drivers/gpu/drm/stm/drv.c
@@ -72,7 +72,6 @@ static struct drm_driver drv_driver = {
.gem_prime_vmap = drm_gem_cma_prime_vmap,
.gem_prime_vunmap = drm_gem_cma_prime_vunmap,
.gem_prime_mmap = drm_gem_cma_prime_mmap,
-   .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 };
 
 static int drv_load(struct drm_device *ddev)
diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 8b6d1a2252e3..4fe9b033de1b 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -722,6 +722,7 @@ static const struct drm_crtc_funcs ltdc_crtc_funcs = {
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
.enable_vblank = ltdc_crtc_enable_vblank,
.disable_vblank = ltdc_crtc_disable_vblank,
+   .get_vblank_timestamp = drm_crtc_calc_vbltimestamp_from_scanoutpos,
.gamma_set = drm_atomic_helper_legacy_gamma_set,
 };
 
-- 
2.24.1

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


[Intel-gfx] [PATCH 07/23] drm/vc4: Convert to struct drm_crtc_helper_funcs.get_scanout_position()

2020-01-10 Thread Thomas Zimmermann
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position(). Convert vc4
over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 12 +++-
 drivers/gpu/drm/vc4/vc4_drv.c  |  1 -
 drivers/gpu/drm/vc4/vc4_drv.h  |  4 
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index b00e20f5ce05..f1e7597ea17e 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -84,13 +84,14 @@ static const struct debugfs_reg32 crtc_regs[] = {
VC4_REG32(PV_HACT_ACT),
 };
 
-bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
-bool in_vblank_irq, int *vpos, int *hpos,
-ktime_t *stime, ktime_t *etime,
-const struct drm_display_mode *mode)
+static bool vc4_crtc_get_scanout_position(struct drm_crtc *crtc,
+ bool in_vblank_irq,
+ int *vpos, int *hpos,
+ ktime_t *stime, ktime_t *etime,
+ const struct drm_display_mode *mode)
 {
+   struct drm_device *dev = crtc->dev;
struct vc4_dev *vc4 = to_vc4_dev(dev);
-   struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
u32 val;
int fifo_lines;
@@ -1039,6 +1040,7 @@ static const struct drm_crtc_helper_funcs 
vc4_crtc_helper_funcs = {
.atomic_flush = vc4_crtc_atomic_flush,
.atomic_enable = vc4_crtc_atomic_enable,
.atomic_disable = vc4_crtc_atomic_disable,
+   .get_scanout_position = vc4_crtc_get_scanout_position,
 };
 
 static const struct vc4_crtc_data pv0_data = {
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 5e6fb6c2307f..e6982a7b0c5e 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -190,7 +190,6 @@ static struct drm_driver vc4_drm_driver = {
.irq_postinstall = vc4_irq_postinstall,
.irq_uninstall = vc4_irq_uninstall,
 
-   .get_scanout_position = vc4_crtc_get_scanoutpos,
.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
 
 #if defined(CONFIG_DEBUG_FS)
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index 6627b20c99e9..f90c0d08e740 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -743,10 +743,6 @@ void vc4_bo_remove_from_purgeable_pool(struct vc4_bo *bo);
 
 /* vc4_crtc.c */
 extern struct platform_driver vc4_crtc_driver;
-bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
-bool in_vblank_irq, int *vpos, int *hpos,
-ktime_t *stime, ktime_t *etime,
-const struct drm_display_mode *mode);
 void vc4_crtc_handle_vblank(struct vc4_crtc *crtc);
 void vc4_crtc_txp_armed(struct drm_crtc_state *state);
 void vc4_crtc_get_margins(struct drm_crtc_state *state,
-- 
2.24.1

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


[Intel-gfx] [PATCH 17/23] drm/radeon: Convert to CRTC VBLANK callbacks

2020-01-10 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert radeon over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/radeon/radeon_display.c | 12 --
 drivers/gpu/drm/radeon/radeon_drv.c |  7 --
 drivers/gpu/drm/radeon/radeon_kms.c | 29 ++---
 3 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_display.c 
b/drivers/gpu/drm/radeon/radeon_display.c
index 7187158b9963..9116975b6eb9 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -45,6 +45,10 @@
 #include "atom.h"
 #include "radeon.h"
 
+u32 radeon_get_vblank_counter_kms(struct drm_crtc *crtc);
+int radeon_enable_vblank_kms(struct drm_crtc *crtc);
+void radeon_disable_vblank_kms(struct drm_crtc *crtc);
+
 static void avivo_crtc_load_lut(struct drm_crtc *crtc)
 {
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
@@ -458,7 +462,7 @@ static void radeon_flip_work_func(struct work_struct 
*__work)
(DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_IN_VBLANK) &&
(!ASIC_IS_AVIVO(rdev) ||
((int) (work->target_vblank -
-   dev->driver->get_vblank_counter(dev, work->crtc_id)) > 0)))
+   crtc->funcs->get_vblank_counter(crtc)) > 0)))
usleep_range(1000, 2000);
 
/* We borrow the event spin lock for protecting flip_status */
@@ -574,7 +578,7 @@ static int radeon_crtc_page_flip_target(struct drm_crtc 
*crtc,
}
work->base = base;
work->target_vblank = target - (uint32_t)drm_crtc_vblank_count(crtc) +
-   dev->driver->get_vblank_counter(dev, work->crtc_id);
+   crtc->funcs->get_vblank_counter(crtc);
 
/* We borrow the event spin lock for protecting flip_work */
spin_lock_irqsave(&crtc->dev->event_lock, flags);
@@ -666,6 +670,10 @@ static const struct drm_crtc_funcs radeon_crtc_funcs = {
.set_config = radeon_crtc_set_config,
.destroy = radeon_crtc_destroy,
.page_flip_target = radeon_crtc_page_flip_target,
+   .get_vblank_counter = radeon_get_vblank_counter_kms,
+   .enable_vblank = radeon_enable_vblank_kms,
+   .disable_vblank = radeon_disable_vblank_kms,
+   .get_vblank_timestamp = drm_crtc_calc_vbltimestamp_from_scanoutpos,
 };
 
 static void radeon_crtc_init(struct drm_device *dev, int index)
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index 1f597f166bff..49ce2e7d5f9e 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -119,9 +119,6 @@ void radeon_driver_postclose_kms(struct drm_device *dev,
 int radeon_suspend_kms(struct drm_device *dev, bool suspend,
   bool fbcon, bool freeze);
 int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
-u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
-int radeon_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
-void radeon_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
@@ -571,10 +568,6 @@ static struct drm_driver kms_driver = {
.postclose = radeon_driver_postclose_kms,
.lastclose = radeon_driver_lastclose_kms,
.unload = radeon_driver_unload_kms,
-   .get_vblank_counter = radeon_get_vblank_counter_kms,
-   .enable_vblank = radeon_enable_vblank_kms,
-   .disable_vblank = radeon_disable_vblank_kms,
-   .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
.irq_preinstall = radeon_driver_irq_preinstall_kms,
.irq_postinstall = radeon_driver_irq_postinstall_kms,
.irq_uninstall = radeon_driver_irq_uninstall_kms,
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c 
b/drivers/gpu/drm/radeon/radeon_kms.c
index d24f23a81656..cab891f86dc0 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -739,14 +739,15 @@ void radeon_driver_postclose_kms(struct drm_device *dev,
 /**
  * radeon_get_vblank_counter_kms - get frame count
  *
- * @dev: drm dev pointer
- * @pipe: crtc to get the frame count from
+ * @crtc: crtc to get the frame count from
  *
  * Gets the frame count on the requested crtc (all asics).
  * Returns frame count on success, -EINVAL on failure.
  */
-u32 radeon_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe)
+u32 radeon_get_vblank_counter_kms(struct drm_crtc *crtc)
 {
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
int vpos, hpos, stat;
u32 count;
struct radeon_device *rdev = dev->dev_private;
@@ -808,25 +809,26 @@ u32 radeon_get_vblank_counter_kms(struct drm_device *dev, 
unsigned int pipe)

[Intel-gfx] [PATCH 05/23] drm/radeon: Convert to struct drm_crtc_helper_funcs.get_scanout_position()

2020-01-10 Thread Thomas Zimmermann
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position(). Convert
radeon over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/radeon/atombios_crtc.c  |  1 +
 drivers/gpu/drm/radeon/radeon_display.c | 13 +
 drivers/gpu/drm/radeon/radeon_drv.c | 11 ---
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c |  3 ++-
 drivers/gpu/drm/radeon/radeon_mode.h|  6 ++
 5 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c 
b/drivers/gpu/drm/radeon/atombios_crtc.c
index da2c9e295408..447d74b78f19 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -2232,6 +2232,7 @@ static const struct drm_crtc_helper_funcs 
atombios_helper_funcs = {
.prepare = atombios_crtc_prepare,
.commit = atombios_crtc_commit,
.disable = atombios_crtc_disable,
+   .get_scanout_position = radeon_get_crtc_scanout_position,
 };
 
 void radeon_atombios_init_crtc(struct drm_device *dev,
diff --git a/drivers/gpu/drm/radeon/radeon_display.c 
b/drivers/gpu/drm/radeon/radeon_display.c
index 962575e27cde..7187158b9963 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1978,3 +1978,16 @@ int radeon_get_crtc_scanoutpos(struct drm_device *dev, 
unsigned int pipe,
 
return ret;
 }
+
+bool
+radeon_get_crtc_scanout_position(struct drm_crtc *crtc,
+bool in_vblank_irq, int *vpos, int *hpos,
+ktime_t *stime, ktime_t *etime,
+const struct drm_display_mode *mode)
+{
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
+
+   return radeon_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
+ stime, etime, mode);
+}
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index fd74e2611185..1f597f166bff 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -563,16 +563,6 @@ static const struct file_operations radeon_driver_kms_fops 
= {
 #endif
 };
 
-static bool
-radeon_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
-bool in_vblank_irq, int *vpos, int *hpos,
-ktime_t *stime, ktime_t *etime,
-const struct drm_display_mode *mode)
-{
-   return radeon_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
- stime, etime, mode);
-}
-
 static struct drm_driver kms_driver = {
.driver_features =
DRIVER_USE_AGP | DRIVER_GEM | DRIVER_RENDER,
@@ -585,7 +575,6 @@ static struct drm_driver kms_driver = {
.enable_vblank = radeon_enable_vblank_kms,
.disable_vblank = radeon_disable_vblank_kms,
.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-   .get_scanout_position = radeon_get_crtc_scanout_position,
.irq_preinstall = radeon_driver_irq_preinstall_kms,
.irq_postinstall = radeon_driver_irq_postinstall_kms,
.irq_uninstall = radeon_driver_irq_uninstall_kms,
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c 
b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index a1985a552794..8817fd033cd0 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -,7 +,8 @@ static const struct drm_crtc_helper_funcs 
legacy_helper_funcs = {
.mode_set_base_atomic = radeon_crtc_set_base_atomic,
.prepare = radeon_crtc_prepare,
.commit = radeon_crtc_commit,
-   .disable = radeon_crtc_disable
+   .disable = radeon_crtc_disable,
+   .get_scanout_position = radeon_get_crtc_scanout_position,
 };
 
 
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h 
b/drivers/gpu/drm/radeon/radeon_mode.h
index fd470d6bf3f4..06c4c527d376 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -881,6 +881,12 @@ extern int radeon_get_crtc_scanoutpos(struct drm_device 
*dev, unsigned int pipe,
  ktime_t *stime, ktime_t *etime,
  const struct drm_display_mode *mode);
 
+extern bool radeon_get_crtc_scanout_position(struct drm_crtc *crtc,
+bool in_vblank_irq, int *vpos,
+int *hpos, ktime_t *stime,
+ktime_t *etime,
+const struct drm_display_mode 
*mode);
+
 extern bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev);
 extern struct edid *
 radeon_bios_get_hardcoded_edid(struct radeon_device *rdev);
-- 
2.24.1

___
Intel-gfx mail

[Intel-gfx] [PATCH 02/23] drm/amdgpu: Convert to struct drm_crtc_helper_funcs.get_scanout_position()

2020-01-10 Thread Thomas Zimmermann
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position(). Convert
amdgpu over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   | 12 
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   | 11 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h  |  5 +
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c|  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c|  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c |  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c |  1 +
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c  |  1 +
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  3 ++-
 9 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 4e699071d144..a1e769d4417d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -914,3 +914,15 @@ int amdgpu_display_crtc_idx_to_irq_type(struct 
amdgpu_device *adev, int crtc)
return AMDGPU_CRTC_IRQ_NONE;
}
 }
+
+bool amdgpu_crtc_get_scanout_position(struct drm_crtc *crtc,
+   bool in_vblank_irq, int *vpos,
+   int *hpos, ktime_t *stime, ktime_t *etime,
+   const struct drm_display_mode *mode)
+{
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
+
+   return amdgpu_display_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
+ stime, etime, mode);
+}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 3f6f14ce1511..0749285dd1c7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1367,16 +1367,6 @@ int amdgpu_file_to_fpriv(struct file *filp, struct 
amdgpu_fpriv **fpriv)
return 0;
 }
 
-static bool
-amdgpu_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
-bool in_vblank_irq, int *vpos, int *hpos,
-ktime_t *stime, ktime_t *etime,
-const struct drm_display_mode *mode)
-{
-   return amdgpu_display_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
- stime, etime, mode);
-}
-
 static struct drm_driver kms_driver = {
.driver_features =
DRIVER_USE_AGP | DRIVER_ATOMIC |
@@ -1391,7 +1381,6 @@ static struct drm_driver kms_driver = {
.enable_vblank = amdgpu_enable_vblank_kms,
.disable_vblank = amdgpu_disable_vblank_kms,
.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-   .get_scanout_position = amdgpu_get_crtc_scanout_position,
.irq_handler = amdgpu_irq_handler,
.ioctls = amdgpu_ioctls_kms,
.gem_free_object_unlocked = amdgpu_gem_object_free,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index eb9975f4decb..37ba07e2feb5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -612,6 +612,11 @@ void amdgpu_panel_mode_fixup(struct drm_encoder *encoder,
 struct drm_display_mode *adjusted_mode);
 int amdgpu_display_crtc_idx_to_irq_type(struct amdgpu_device *adev, int crtc);
 
+bool amdgpu_crtc_get_scanout_position(struct drm_crtc *crtc,
+   bool in_vblank_irq, int *vpos,
+   int *hpos, ktime_t *stime, ktime_t *etime,
+   const struct drm_display_mode *mode);
+
 /* fbdev layer */
 int amdgpu_fbdev_init(struct amdgpu_device *adev);
 void amdgpu_fbdev_fini(struct amdgpu_device *adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 40d2ac723dd6..bdc1e0f036d4 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2685,6 +2685,7 @@ static const struct drm_crtc_helper_funcs 
dce_v10_0_crtc_helper_funcs = {
.prepare = dce_v10_0_crtc_prepare,
.commit = dce_v10_0_crtc_commit,
.disable = dce_v10_0_crtc_disable,
+   .get_scanout_position = amdgpu_crtc_get_scanout_position,
 };
 
 static int dce_v10_0_crtc_init(struct amdgpu_device *adev, int index)
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 898ef72d423c..0319da5f7bf9 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -2793,6 +2793,7 @@ static const struct drm_crtc_helper_funcs 
dce_v11_0_crtc_helper_funcs = {
.prepare = dce_v11_0_crtc_prepare,
.commit = dce_v11_0_crtc_commit,
.disable = dce_v11_0_crtc_disable,
+   .get_scanout_position = amdgpu_crtc_get_scanout_position,
 };
 
 static in

[Intel-gfx] [PATCH 15/23] drm/msm: Convert to CRTC VBLANK callbacks

2020-01-10 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert msm over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  |  2 ++
 drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c |  2 ++
 drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 15 ++
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c  | 34 ---
 drivers/gpu/drm/msm/msm_drv.c | 10 ---
 drivers/gpu/drm/msm/msm_drv.h |  3 ++
 6 files changed, 28 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index f197dce54576..b177d5052c5e 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -1281,6 +1281,8 @@ static const struct drm_crtc_funcs dpu_crtc_funcs = {
.atomic_destroy_state = dpu_crtc_destroy_state,
.late_register = dpu_crtc_late_register,
.early_unregister = dpu_crtc_early_unregister,
+   .enable_vblank  = msm_crtc_enable_vblank,
+   .disable_vblank = msm_crtc_disable_vblank,
 };
 
 static const struct drm_crtc_helper_funcs dpu_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c 
b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
index f34dca5d4532..c9239b07fe4f 100644
--- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
@@ -481,6 +481,8 @@ static const struct drm_crtc_funcs mdp4_crtc_funcs = {
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank  = msm_crtc_enable_vblank,
+   .disable_vblank = msm_crtc_disable_vblank,
 };
 
 static const struct drm_crtc_helper_funcs mdp4_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
index 4decf19847a8..70c326d330f6 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
@@ -471,6 +471,17 @@ static bool mdp5_crtc_get_scanout_position(struct drm_crtc 
*crtc,
return true;
 }
 
+static u32 mdp5_crtc_get_vblank_counter(struct drm_crtc *crtc)
+{
+   struct drm_encoder *encoder;
+
+   encoder = get_encoder_from_crtc(crtc);
+   if (!encoder)
+   return 0;
+
+   return mdp5_encoder_get_framecount(encoder);
+}
+
 static void mdp5_crtc_atomic_disable(struct drm_crtc *crtc,
 struct drm_crtc_state *old_state)
 {
@@ -1120,6 +1131,10 @@ static const struct drm_crtc_funcs mdp5_crtc_funcs = {
.cursor_set = mdp5_crtc_cursor_set,
.cursor_move = mdp5_crtc_cursor_move,
.atomic_print_state = mdp5_crtc_atomic_print_state,
+   .get_vblank_counter = mdp5_crtc_get_vblank_counter,
+   .enable_vblank  = msm_crtc_enable_vblank,
+   .disable_vblank = msm_crtc_disable_vblank,
+   .get_vblank_timestamp = drm_crtc_calc_vbltimestamp_from_scanoutpos,
 };
 
 static const struct drm_crtc_helper_funcs mdp5_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
index 8b72ac44ce55..6650f478b226 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
@@ -583,38 +583,6 @@ static int get_clk(struct platform_device *pdev, struct 
clk **clkp,
return 0;
 }
 
-static struct drm_encoder *get_encoder_from_crtc(struct drm_crtc *crtc)
-{
-   struct drm_device *dev = crtc->dev;
-   struct drm_encoder *encoder;
-
-   drm_for_each_encoder(encoder, dev)
-   if (encoder->crtc == crtc)
-   return encoder;
-
-   return NULL;
-}
-
-static u32 mdp5_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
-{
-   struct msm_drm_private *priv = dev->dev_private;
-   struct drm_crtc *crtc;
-   struct drm_encoder *encoder;
-
-   if (pipe >= priv->num_crtcs)
-   return 0;
-
-   crtc = priv->crtcs[pipe];
-   if (!crtc)
-   return 0;
-
-   encoder = get_encoder_from_crtc(crtc);
-   if (!encoder)
-   return 0;
-
-   return mdp5_encoder_get_framecount(encoder);
-}
-
 struct msm_kms *mdp5_kms_init(struct drm_device *dev)
 {
struct msm_drm_private *priv = dev->dev_private;
@@ -702,8 +670,6 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev)
dev->mode_config.max_width = 0x;
dev->mode_config.max_height = 0x;
 
-   dev->driver->get_vblank_timestamp = 
drm_calc_vbltimestamp_from_scanoutpos;
-   dev->driver->get_vblank_counter = mdp5_get_vblank_counter;
dev->max_vblank_count = 0; /* max_vblank_count is set on each CRTC */
dev->vblank_disable_immediate = true;
 
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index c84f0a8b3f2c..c5e04413

[Intel-gfx] [PATCH 18/23] drm/sti: Convert to CRTC VBLANK callbacks

2020-01-10 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert sti over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/sti/sti_crtc.c | 11 ---
 drivers/gpu/drm/sti/sti_crtc.h |  2 --
 drivers/gpu/drm/sti/sti_drv.c  |  3 ---
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
index dc64fbfc4e61..49e6cb8f5836 100644
--- a/drivers/gpu/drm/sti/sti_crtc.c
+++ b/drivers/gpu/drm/sti/sti_crtc.c
@@ -279,12 +279,13 @@ int sti_crtc_vblank_cb(struct notifier_block *nb,
return 0;
 }
 
-int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe)
+static int sti_crtc_enable_vblank(struct drm_crtc *crtc)
 {
+   struct drm_device *dev = crtc->dev;
+   unsigned int pipe = crtc->index;
struct sti_private *dev_priv = dev->dev_private;
struct sti_compositor *compo = dev_priv->compo;
struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb[pipe];
-   struct drm_crtc *crtc = &compo->mixer[pipe]->drm_crtc;
struct sti_vtg *vtg = compo->vtg[pipe];
 
DRM_DEBUG_DRIVER("\n");
@@ -297,8 +298,10 @@ int sti_crtc_enable_vblank(struct drm_device *dev, 
unsigned int pipe)
return 0;
 }
 
-void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe)
+static void sti_crtc_disable_vblank(struct drm_crtc *crtc)
 {
+   struct drm_device *drm_dev = crtc->dev;
+   unsigned int pipe = crtc->index;
struct sti_private *priv = drm_dev->dev_private;
struct sti_compositor *compo = priv->compo;
struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb[pipe];
@@ -330,6 +333,8 @@ static const struct drm_crtc_funcs sti_crtc_funcs = {
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
.late_register = sti_crtc_late_register,
+   .enable_vblank = sti_crtc_enable_vblank,
+   .disable_vblank = sti_crtc_disable_vblank,
 };
 
 bool sti_crtc_is_main(struct drm_crtc *crtc)
diff --git a/drivers/gpu/drm/sti/sti_crtc.h b/drivers/gpu/drm/sti/sti_crtc.h
index df489ab14e2b..1132b4586712 100644
--- a/drivers/gpu/drm/sti/sti_crtc.h
+++ b/drivers/gpu/drm/sti/sti_crtc.h
@@ -15,8 +15,6 @@ struct sti_mixer;
 
 int sti_crtc_init(struct drm_device *drm_dev, struct sti_mixer *mixer,
  struct drm_plane *primary, struct drm_plane *cursor);
-int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe);
-void sti_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe);
 int sti_crtc_vblank_cb(struct notifier_block *nb,
   unsigned long event, void *data);
 bool sti_crtc_is_main(struct drm_crtc *drm_crtc);
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index a39fc36f815b..8e30001bf545 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -146,9 +146,6 @@ static struct drm_driver sti_driver = {
.dumb_create = drm_gem_cma_dumb_create,
.fops = &sti_driver_fops,
 
-   .enable_vblank = sti_crtc_enable_vblank,
-   .disable_vblank = sti_crtc_disable_vblank,
-
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
-- 
2.24.1

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


[Intel-gfx] [PATCH 20/23] drm/vc4: Convert to CRTC VBLANK callbacks

2020-01-10 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert vc4 over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 1 +
 drivers/gpu/drm/vc4/vc4_drv.c  | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index f1e7597ea17e..e4081634648d 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -1031,6 +1031,7 @@ static const struct drm_crtc_funcs vc4_crtc_funcs = {
.gamma_set = drm_atomic_helper_legacy_gamma_set,
.enable_vblank = vc4_enable_vblank,
.disable_vblank = vc4_disable_vblank,
+   .get_vblank_timestamp = drm_crtc_calc_vbltimestamp_from_scanoutpos,
 };
 
 static const struct drm_crtc_helper_funcs vc4_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index e6982a7b0c5e..76f93b662766 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -190,8 +190,6 @@ static struct drm_driver vc4_drm_driver = {
.irq_postinstall = vc4_irq_postinstall,
.irq_uninstall = vc4_irq_uninstall,
 
-   .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
-
 #if defined(CONFIG_DEBUG_FS)
.debugfs_init = vc4_debugfs_init,
 #endif
-- 
2.24.1

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


[Intel-gfx] [PATCH 22/23] drm/vmwgfx: Convert to CRTC VBLANK callbacks

2020-01-10 Thread Thomas Zimmermann
VBLANK callbacks in struct drm_driver are deprecated in favor of
their equivalents in struct drm_crtc_funcs. Convert vmwgfx over.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c  | 5 +
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h  | 6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  | 8 
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c  | 3 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 5 -
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 3 +++
 6 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index e962048f65d2..f5ab04468522 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1329,7 +1329,7 @@ static int vmw_pm_freeze(struct device *kdev)
 
vmw_fence_fifo_down(dev_priv->fman);
__vmw_svga_disable(dev_priv);
-   
+
vmw_release_device_late(dev_priv);
return 0;
 }
@@ -1393,9 +1393,6 @@ static struct drm_driver driver = {
DRIVER_MODESET | DRIVER_RENDER | DRIVER_ATOMIC,
.load = vmw_driver_load,
.unload = vmw_driver_unload,
-   .get_vblank_counter = vmw_get_vblank_counter,
-   .enable_vblank = vmw_enable_vblank,
-   .disable_vblank = vmw_disable_vblank,
.ioctls = vmw_ioctls,
.num_ioctls = ARRAY_SIZE(vmw_ioctls),
.master_set = vmw_master_set,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index a31e726d6d71..845b3b8c29ca 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -1100,9 +1100,9 @@ int vmw_kms_write_svga(struct vmw_private *vmw_priv,
 bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv,
uint32_t pitch,
uint32_t height);
-u32 vmw_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
-int vmw_enable_vblank(struct drm_device *dev, unsigned int pipe);
-void vmw_disable_vblank(struct drm_device *dev, unsigned int pipe);
+u32 vmw_get_vblank_counter(struct drm_crtc *crtc);
+int vmw_enable_vblank(struct drm_crtc *crtc);
+void vmw_disable_vblank(struct drm_crtc *crtc);
 int vmw_kms_present(struct vmw_private *dev_priv,
struct drm_file *file_priv,
struct vmw_framebuffer *vfb,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index f47d5710cc95..9f0fee62904a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -1991,7 +1991,7 @@ bool vmw_kms_validate_mode_vram(struct vmw_private 
*dev_priv,
 /**
  * Function called by DRM code called with vbl_lock held.
  */
-u32 vmw_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
+u32 vmw_get_vblank_counter(struct drm_crtc *crtc)
 {
return 0;
 }
@@ -1999,7 +1999,7 @@ u32 vmw_get_vblank_counter(struct drm_device *dev, 
unsigned int pipe)
 /**
  * Function called by DRM code called with vbl_lock held.
  */
-int vmw_enable_vblank(struct drm_device *dev, unsigned int pipe)
+int vmw_enable_vblank(struct drm_crtc *crtc)
 {
return -EINVAL;
 }
@@ -2007,7 +2007,7 @@ int vmw_enable_vblank(struct drm_device *dev, unsigned 
int pipe)
 /**
  * Function called by DRM code called with vbl_lock held.
  */
-void vmw_disable_vblank(struct drm_device *dev, unsigned int pipe)
+void vmw_disable_vblank(struct drm_crtc *crtc)
 {
 }
 
@@ -2088,7 +2088,7 @@ static int vmw_du_update_layout(struct vmw_private 
*dev_priv,
drm_modeset_drop_locks(&ctx);
drm_modeset_acquire_fini(&ctx);
mutex_unlock(&dev->mode_config.mutex);
- 
+
return 0;
 }
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index 5702219ec38f..16dafff5cab1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -236,6 +236,9 @@ static const struct drm_crtc_funcs vmw_legacy_crtc_funcs = {
.atomic_duplicate_state = vmw_du_crtc_duplicate_state,
.atomic_destroy_state = vmw_du_crtc_destroy_state,
.set_config = drm_atomic_helper_set_config,
+   .get_vblank_counter = vmw_get_vblank_counter,
+   .enable_vblank = vmw_enable_vblank,
+   .disable_vblank = vmw_disable_vblank,
 };
 
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index e5a283263211..207a4053e769 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -319,6 +319,9 @@ static const struct drm_crtc_funcs 
vmw_screen_object_crtc_funcs = {
.atomic_destroy_state = vmw_du_crtc_destroy_state,
.set_config = drm_atomic_helper_set_config,
.page_flip = drm_atomic_helper_page_flip,
+   .get_vblank_counter = vmw_get_vblank_counter,
+   .enable_vblank = vmw_enable_vblank,
+   .disable_vblank = vmw_disable_vblank,
 };
 
 /*
@@ -1388,6 +1391,6 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv,

[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm: Clean up VBLANK callbacks in struct drm_driver

2020-01-10 Thread Patchwork
== Series Details ==

Series: drm: Clean up VBLANK callbacks in struct drm_driver
URL   : https://patchwork.freedesktop.org/series/71873/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
30f2cd6c8fad drm: Add get_scanout_position() to struct drm_crtc_helper_funcs
-:58: CHECK:OPEN_ENDED_LINE: Lines should not end with a '('
#58: FILE: drivers/gpu/drm/drm_vblank.c:671:
+   crtc->helper_private->get_scanout_position(

-:63: CHECK:OPEN_ENDED_LINE: Lines should not end with a '('
#63: FILE: drivers/gpu/drm/drm_vblank.c:676:
+   dev->driver->get_scanout_position(

total: 0 errors, 0 warnings, 2 checks, 114 lines checked
62a0fc25c2ed drm/amdgpu: Convert to struct 
drm_crtc_helper_funcs.get_scanout_position()
-:23: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis
#23: FILE: drivers/gpu/drm/amd/amdgpu/amdgpu_display.c:919:
+bool amdgpu_crtc_get_scanout_position(struct drm_crtc *crtc,
+   bool in_vblank_irq, int *vpos,

-:71: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis
#71: FILE: drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h:616:
+bool amdgpu_crtc_get_scanout_position(struct drm_crtc *crtc,
+   bool in_vblank_irq, int *vpos,

total: 0 errors, 0 warnings, 2 checks, 93 lines checked
daf9deab4b37 drm/i915: Don't use struct drm_driver.get_scanout_position()
-:135: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV)
#135: FILE: drivers/gpu/drm/i915/i915_irq.c:958:
+ pipe, duration_ns/1000, *max_error/1000, i);
   ^

-:135: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV)
#135: FILE: drivers/gpu/drm/i915/i915_irq.c:958:
+ pipe, duration_ns/1000, *max_error/1000, i);
^

total: 0 errors, 0 warnings, 2 checks, 159 lines checked
cc4157b82402 drm/nouveau: Convert to struct 
drm_crtc_helper_funcs.get_scanout_position()
-:75: WARNING:FUNCTION_ARGUMENTS: function definition argument 'struct drm_crtc 
*' should also have an identifier name
#75: FILE: drivers/gpu/drm/nouveau/nouveau_display.h:66:
+bool  nouveau_display_scanoutpos(struct drm_crtc *,

-:75: WARNING:FUNCTION_ARGUMENTS: function definition argument 'bool' should 
also have an identifier name
#75: FILE: drivers/gpu/drm/nouveau/nouveau_display.h:66:
+bool  nouveau_display_scanoutpos(struct drm_crtc *,

-:75: WARNING:FUNCTION_ARGUMENTS: function definition argument 'int *' should 
also have an identifier name
#75: FILE: drivers/gpu/drm/nouveau/nouveau_display.h:66:
+bool  nouveau_display_scanoutpos(struct drm_crtc *,

-:75: WARNING:FUNCTION_ARGUMENTS: function definition argument 'int *' should 
also have an identifier name
#75: FILE: drivers/gpu/drm/nouveau/nouveau_display.h:66:
+bool  nouveau_display_scanoutpos(struct drm_crtc *,

-:75: WARNING:FUNCTION_ARGUMENTS: function definition argument 'ktime_t *' 
should also have an identifier name
#75: FILE: drivers/gpu/drm/nouveau/nouveau_display.h:66:
+bool  nouveau_display_scanoutpos(struct drm_crtc *,

-:75: WARNING:FUNCTION_ARGUMENTS: function definition argument 'ktime_t *' 
should also have an identifier name
#75: FILE: drivers/gpu/drm/nouveau/nouveau_display.h:66:
+bool  nouveau_display_scanoutpos(struct drm_crtc *,

-:75: WARNING:FUNCTION_ARGUMENTS: function definition argument 'const struct 
drm_display_mode *' should also have an identifier name
#75: FILE: drivers/gpu/drm/nouveau/nouveau_display.h:66:
+bool  nouveau_display_scanoutpos(struct drm_crtc *,

total: 0 errors, 7 warnings, 0 checks, 53 lines checked
78fac3c06e60 drm/radeon: Convert to struct 
drm_crtc_helper_funcs.get_scanout_position()
-:97: CHECK:AVOID_EXTERNS: extern prototypes should be avoided in .h files
#97: FILE: drivers/gpu/drm/radeon/radeon_mode.h:884:
+extern bool radeon_get_crtc_scanout_position(struct drm_crtc *crtc,

total: 0 errors, 0 warnings, 1 checks, 67 lines checked
7aa032e1e5eb drm/msm: Convert to struct 
drm_crtc_helper_funcs.get_scanout_position()
-:43: CHECK:LINE_SPACING: Please don't use multiple blank lines
#43: FILE: drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c:430:
+
+

total: 0 errors, 0 warnings, 1 checks, 152 lines checked
450559e9416c drm/vc4: Convert to struct 
drm_crtc_helper_funcs.get_scanout_position()
47676fe9e9da drm/stm: Convert to struct 
drm_crtc_helper_funcs.get_scanout_position()
4fb79c555089 drm: Remove struct drm_driver.get_scanout_position()
-:33: CHECK:OPEN_ENDED_LINE: Lines should not end with a '('
#33: FILE: drivers/gpu/drm/drm_vblank.c:668:
+   vbl_status = crtc->helper_private->get_scanout_position(

total: 0 errors, 0 warnings, 1 checks, 85 lines checked
cbfbe29f84f9 drm: Evaluate struct drm_device.vblank_disable_immediate on each 
use
115af48b3a62 drm: Add get_vblank_timestamp() to struct drm_crtc_funcs
-:105: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'max_error 
> 0

[Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm: Clean up VBLANK callbacks in struct drm_driver

2020-01-10 Thread Patchwork
== Series Details ==

Series: drm: Clean up VBLANK callbacks in struct drm_driver
URL   : https://patchwork.freedesktop.org/series/71873/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Sparse version: v0.6.0
Commit: drm: Add get_scanout_position() to struct drm_crtc_helper_funcs
Okay!

Commit: drm/amdgpu: Convert to struct 
drm_crtc_helper_funcs.get_scanout_position()
-drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:4937:6: warning: 
symbol 'dm_drm_plane_destroy_state' was not declared. Should it be static?
+drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:4938:6: warning: 
symbol 'dm_drm_plane_destroy_state' was not declared. Should it be static?
-drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:8232:6: warning: 
symbol 'amdgpu_dm_psr_enable' was not declared. Should it be static?
+drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:8233:6: warning: 
symbol 'amdgpu_dm_psr_enable' was not declared. Should it be static?

Commit: drm/i915: Don't use struct drm_driver.get_scanout_position()
Okay!

Commit: drm/nouveau: Convert to struct 
drm_crtc_helper_funcs.get_scanout_position()
Okay!

Commit: drm/radeon: Convert to struct 
drm_crtc_helper_funcs.get_scanout_position()
Okay!

Commit: drm/msm: Convert to struct drm_crtc_helper_funcs.get_scanout_position()
Okay!

Commit: drm/vc4: Convert to struct drm_crtc_helper_funcs.get_scanout_position()
Okay!

Commit: drm/stm: Convert to struct drm_crtc_helper_funcs.get_scanout_position()
Okay!

Commit: drm: Remove struct drm_driver.get_scanout_position()
Okay!

Commit: drm: Evaluate struct drm_device.vblank_disable_immediate on each use
Okay!

Commit: drm: Add get_vblank_timestamp() to struct drm_crtc_funcs
Okay!

Commit: drm/amdgpu: Convert to CRTC VBLANK callbacks
-drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:4938:6: warning: 
symbol 'dm_drm_plane_destroy_state' was not declared. Should it be static?
+drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:4940:6: warning: 
symbol 'dm_drm_plane_destroy_state' was not declared. Should it be static?
-drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:8233:6: warning: 
symbol 'amdgpu_dm_psr_enable' was not declared. Should it be static?
+drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:8235:6: warning: 
symbol 'amdgpu_dm_psr_enable' was not declared. Should it be static?

Commit: drm/gma500: Convert to CRTC VBLANK callbacks
Okay!

Commit: drm/i915: Convert to CRTC VBLANK callbacks
Okay!

Commit: drm/msm: Convert to CRTC VBLANK callbacks
Okay!

Commit: drm/nouveau: Convert to CRTC VBLANK callbacks
Okay!

Commit: drm/radeon: Convert to CRTC VBLANK callbacks
Okay!

Commit: drm/sti: Convert to CRTC VBLANK callbacks
Okay!

Commit: drm/stm: Convert to CRTC VBLANK callbacks
Okay!

Commit: drm/vc4: Convert to CRTC VBLANK callbacks
Okay!

Commit: drm/vkms: Convert to CRTC VBLANK callbacks
Okay!

Commit: drm/vmwgfx: Convert to CRTC VBLANK callbacks
Okay!

Commit: drm: Cleanup VBLANK callbacks in struct drm_driver
Okay!

___
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: Clean up VBLANK callbacks in struct drm_driver

2020-01-10 Thread Patchwork
== Series Details ==

Series: drm: Clean up VBLANK callbacks in struct drm_driver
URL   : https://patchwork.freedesktop.org/series/71873/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_7715 -> Patchwork_16048


Summary
---

  **SUCCESS**

  No regressions found.

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

Known issues


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

### IGT changes ###

 Issues hit 

  * igt@gem_exec_suspend@basic-s0:
- fi-skl-6700k2:  [PASS][1] -> [INCOMPLETE][2] ([i915#198])
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7715/fi-skl-6700k2/igt@gem_exec_susp...@basic-s0.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16048/fi-skl-6700k2/igt@gem_exec_susp...@basic-s0.html

  * igt@i915_module_load@reload-with-fault-injection:
- fi-bxt-dsi: [PASS][3] -> [DMESG-WARN][4] ([i915#889])
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7715/fi-bxt-dsi/igt@i915_module_l...@reload-with-fault-injection.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16048/fi-bxt-dsi/igt@i915_module_l...@reload-with-fault-injection.html
- fi-kbl-x1275:   [PASS][5] -> [INCOMPLETE][6] ([i915#879])
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7715/fi-kbl-x1275/igt@i915_module_l...@reload-with-fault-injection.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16048/fi-kbl-x1275/igt@i915_module_l...@reload-with-fault-injection.html

  * igt@i915_pm_rpm@module-reload:
- fi-hsw-4770:[PASS][7] -> [INCOMPLETE][8] ([i915#151])
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7715/fi-hsw-4770/igt@i915_pm_...@module-reload.html
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16048/fi-hsw-4770/igt@i915_pm_...@module-reload.html

  * igt@i915_selftest@live_blt:
- fi-hsw-4770r:   [PASS][9] -> [DMESG-FAIL][10] ([i915#563])
   [9]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7715/fi-hsw-4770r/igt@i915_selftest@live_blt.html
   [10]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16048/fi-hsw-4770r/igt@i915_selftest@live_blt.html
- fi-hsw-peppy:   [PASS][11] -> [DMESG-FAIL][12] ([i915#553] / 
[i915#725])
   [11]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7715/fi-hsw-peppy/igt@i915_selftest@live_blt.html
   [12]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16048/fi-hsw-peppy/igt@i915_selftest@live_blt.html

  
 Possible fixes 

  * igt@i915_pm_rpm@module-reload:
- fi-skl-6770hq:  [FAIL][13] ([i915#178]) -> [PASS][14]
   [13]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7715/fi-skl-6770hq/igt@i915_pm_...@module-reload.html
   [14]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16048/fi-skl-6770hq/igt@i915_pm_...@module-reload.html

  * igt@i915_selftest@live_execlists:
- fi-kbl-soraka:  [DMESG-FAIL][15] ([i915#656]) -> [PASS][16]
   [15]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7715/fi-kbl-soraka/igt@i915_selftest@live_execlists.html
   [16]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16048/fi-kbl-soraka/igt@i915_selftest@live_execlists.html

  * igt@i915_selftest@live_gem_contexts:
- fi-hsw-peppy:   [DMESG-FAIL][17] ([i915#722]) -> [PASS][18]
   [17]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7715/fi-hsw-peppy/igt@i915_selftest@live_gem_contexts.html
   [18]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16048/fi-hsw-peppy/igt@i915_selftest@live_gem_contexts.html

  
  [i915#151]: https://gitlab.freedesktop.org/drm/intel/issues/151
  [i915#178]: https://gitlab.freedesktop.org/drm/intel/issues/178
  [i915#198]: https://gitlab.freedesktop.org/drm/intel/issues/198
  [i915#553]: https://gitlab.freedesktop.org/drm/intel/issues/553
  [i915#563]: https://gitlab.freedesktop.org/drm/intel/issues/563
  [i915#656]: https://gitlab.freedesktop.org/drm/intel/issues/656
  [i915#722]: https://gitlab.freedesktop.org/drm/intel/issues/722
  [i915#725]: https://gitlab.freedesktop.org/drm/intel/issues/725
  [i915#879]: https://gitlab.freedesktop.org/drm/intel/issues/879
  [i915#889]: https://gitlab.freedesktop.org/drm/intel/issues/889


Participating hosts (44 -> 39)
--

  Additional (8): fi-byt-j1900 fi-glk-dsi fi-kbl-guc fi-kbl-8809g fi-elk-e7500 
fi-kbl-7560u fi-tgl-y fi-bsw-nick 
  Missing(13): fi-ehl-1 fi-bdw-5557u fi-hsw-4200u fi-byt-squawks 
fi-bsw-cyan fi-snb-2520m fi-kbl-7500u fi-ctg-p8600 fi-whl-u fi-skl-lmem 
fi-byt-n2820 fi-byt-clapper fi-kbl-r 


Build changes
-

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_7715 -> Patchwork_16048

  CI-20190529: 20190529
  CI_DRM_7715: 337449c74a6745cf1d9d60c41f170d31a291f0c0 @ 
git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5359: 28451bcec2245dcc1fd0eb1d4c76335b2b4f97a5 @ 
git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_16048: dad

Re: [Intel-gfx] [PATCH 01/23] drm: Add get_scanout_position() to struct drm_crtc_helper_funcs

2020-01-10 Thread Jani Nikula
On Fri, 10 Jan 2020, Thomas Zimmermann  wrote:
> The new callback get_scanout_position() reads the current location of
> the scanout process. The operation is currentyl located in struct
> drm_driver, but really belongs to the CRTC. Drivers will be converted
> in separate patches.
>
> Signed-off-by: Thomas Zimmermann 
> ---
>  drivers/gpu/drm/drm_vblank.c | 24 
>  include/drm/drm_drv.h|  7 +---
>  include/drm/drm_modeset_helper_vtables.h | 47 
>  3 files changed, 65 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index 1659b13b178c..c12f0b333e14 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 
>  
> @@ -590,7 +591,7 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
>   * Implements calculation of exact vblank timestamps from given 
> drm_display_mode
>   * timings and current video scanout position of a CRTC. This can be directly
>   * used as the &drm_driver.get_vblank_timestamp implementation of a kms 
> driver
> - * if &drm_driver.get_scanout_position is implemented.
> + * if &drm_crtc_helper_funcs.get_scanout_position is implemented.
>   *
>   * The current implementation only handles standard video modes. For double 
> scan
>   * and interlaced modes the driver is supposed to adjust the hardware mode
> @@ -632,8 +633,9 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct 
> drm_device *dev,
>   }
>  
>   /* Scanout position query not supported? Should not happen. */
> - if (!dev->driver->get_scanout_position) {
> - DRM_ERROR("Called from driver w/o get_scanout_position()!?\n");
> + if (!dev->driver->get_scanout_position ||
> + !crtc->helper_private->get_scanout_position) {

ITYM s/||/&&/

BR,
Jani.


> + DRM_ERROR("Called from CRTC w/o get_scanout_position()!?\n");
>   return false;
>   }
>  
> @@ -664,11 +666,17 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct 
> drm_device *dev,
>* Get vertical and horizontal scanout position vpos, hpos,
>* and bounding timestamps stime, etime, pre/post query.
>*/
> - vbl_status = dev->driver->get_scanout_position(dev, pipe,
> -in_vblank_irq,
> -&vpos, &hpos,
> -&stime, &etime,
> -mode);
> + if (crtc->helper_private->get_scanout_position) {
> + vbl_status =
> + crtc->helper_private->get_scanout_position(
> + crtc, in_vblank_irq, &vpos, &hpos,
> + &stime, &etime, mode);
> + } else {
> + vbl_status =
> + dev->driver->get_scanout_position(
> + dev, pipe, in_vblank_irq, &vpos,
> + &hpos, &stime, &etime, mode);
> + }
>  
>   /* Return as no-op if scanout query unsupported or failed. */
>   if (!vbl_status) {
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index cf13470810a5..d0049e5786fc 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -362,11 +362,8 @@ struct drm_driver {
>* True on success, false if a reliable scanout position counter could
>* not be read out.
>*
> -  * FIXME:
> -  *
> -  * Since this is a helper to implement @get_vblank_timestamp, we should
> -  * move it to &struct drm_crtc_helper_funcs, like all the other
> -  * helper-internal hooks.
> +  * This is deprecated and should not be used by new drivers.
> +  * Use &drm_crtc_helper_funcs.get_scanout_position instead.
>*/
>   bool (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
> bool in_vblank_irq, int *vpos, int *hpos,
> diff --git a/include/drm/drm_modeset_helper_vtables.h 
> b/include/drm/drm_modeset_helper_vtables.h
> index 5a87f1bd7a3f..e398512bfd5f 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -450,6 +450,53 @@ struct drm_crtc_helper_funcs {
>*/
>   void (*atomic_disable)(struct drm_crtc *crtc,
>  struct drm_crtc_state *old_crtc_state);
> +
> + /**
> +  * @get_scanout_position:
> +  *
> +  * Called by vblank timestamping code.
> +  *
> +  * Returns the current display scanout position from a CRTC and an
> +  * optional accurate ktime_get() timestamp of when the position was
> +  * measured. Note that

Re: [Intel-gfx] [PATCH 11/14] drm/i915: Drop the shadow ring state from the error capture

2020-01-10 Thread Mika Kuoppala
Chris Wilson  writes:

> Quoting Mika Kuoppala (2020-01-09 09:04:31)
>> Chris Wilson  writes:
>> 
>> > The shadow ring regs (ring->head, ring->tail) are meaningless in the
>> > post-mortem dump as they do not related to anything on HW. Remove them
>> > from the coredump.
>> 
>> We have been dumping these just to check that our bookkeepping matches?
>
> Kind off, but they never really match since the ring->head is very lazy,
> and ring->tail is wherever the user got up to. We have the relevant
> information from the request where we expect to be in the ring for the
> error, and the HW tells us where it was executing.
> -Chris

Ok, based on that and that  don't remember a single case where,
from external reports, these would have provided anything of value.

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


Re: [Intel-gfx] [PATCH 12/14] drm/i915: Drop the shadow w/a batch buffer

2020-01-10 Thread Andi Shyti
Hi Chris,

On Thu, Jan 09, 2020 at 08:58:37AM +, Chris Wilson wrote:
> While this is technically the batch as executed by the HW (in part at
> least), it is confusing, and only used for a minority of gen.
> 
> Signed-off-by: Chris Wilson 

Acked-by: Andi Shyti 

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


[Intel-gfx] [PATCH 3/3] drm/i915/gt: Mark ring->vma as active while pinned

2020-01-10 Thread Chris Wilson
As we use the active state to keep the vma alive while we are reading
its contents during GPU error capture, we need to mark the
ring->vma as active during execution if we want to include the rinbuffer
in the error state.

Reported-by: Lionel Landwerlin 
Fixes: b1e3177bd1d8 ("drm/i915: Coordinate i915_active with its own mutex")
Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Cc: Lionel Landwerlin 
Acked-by: Lionel Landwerlin 
---
 drivers/gpu/drm/i915/gt/intel_context.c | 31 ++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.c 
b/drivers/gpu/drm/i915/gt/intel_context.c
index 8774c18f405e..23137b2a8689 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.c
+++ b/drivers/gpu/drm/i915/gt/intel_context.c
@@ -185,6 +185,31 @@ static void __context_unpin_state(struct i915_vma *vma)
__i915_vma_unpin(vma);
 }
 
+static int __ring_active(struct intel_ring *ring)
+{
+   int err;
+
+   err = i915_active_acquire(&ring->vma->active);
+   if (err)
+   return err;
+
+   err = intel_ring_pin(ring);
+   if (err)
+   goto err_active;
+
+   return 0;
+
+err_active:
+   i915_active_release(&ring->vma->active);
+   return err;
+}
+
+static void __ring_retire(struct intel_ring *ring)
+{
+   intel_ring_unpin(ring);
+   i915_active_release(&ring->vma->active);
+}
+
 __i915_active_call
 static void __intel_context_retire(struct i915_active *active)
 {
@@ -197,7 +222,7 @@ static void __intel_context_retire(struct i915_active 
*active)
__context_unpin_state(ce->state);
 
intel_timeline_unpin(ce->timeline);
-   intel_ring_unpin(ce->ring);
+   __ring_retire(ce->ring);
 
intel_context_put(ce);
 }
@@ -211,7 +236,7 @@ static int __intel_context_active(struct i915_active 
*active)
 
intel_context_get(ce);
 
-   err = intel_ring_pin(ce->ring);
+   err = __ring_active(ce->ring);
if (err)
goto err_put;
 
@@ -231,7 +256,7 @@ static int __intel_context_active(struct i915_active 
*active)
 err_timeline:
intel_timeline_unpin(ce->timeline);
 err_ring:
-   intel_ring_unpin(ce->ring);
+   __ring_retire(ce->ring);
 err_put:
intel_context_put(ce);
return err;
-- 
2.25.0.rc2

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


[Intel-gfx] [PATCH 2/3] drm/i915/gt: Mark context->state vma as active while pinned

2020-01-10 Thread Chris Wilson
As we use the active state to keep the vma alive while we are reading
its contents during GPU error capture, we need to mark the
context->state vma as active during execution if we want to include it
in the error state.

Reported-by: Lionel Landwerlin 
Fixes: b1e3177bd1d8 ("drm/i915: Coordinate i915_active with its own mutex")
Signed-off-by: Chris Wilson 
Cc: Tvrtko Ursulin 
Cc: Lionel Landwerlin 
Acked-by: Lionel Landwerlin 
---
 drivers/gpu/drm/i915/gt/intel_context.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.c 
b/drivers/gpu/drm/i915/gt/intel_context.c
index 9796a54b4f47..8774c18f405e 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.c
+++ b/drivers/gpu/drm/i915/gt/intel_context.c
@@ -160,6 +160,10 @@ static int __context_pin_state(struct i915_vma *vma)
if (err)
return err;
 
+   err = i915_active_acquire(&vma->active);
+   if (err)
+   goto err_unpin;
+
/*
 * And mark it as a globally pinned object to let the shrinker know
 * it cannot reclaim the object until we release it.
@@ -168,11 +172,16 @@ static int __context_pin_state(struct i915_vma *vma)
vma->obj->mm.dirty = true;
 
return 0;
+
+err_unpin:
+   i915_vma_unpin(vma);
+   return err;
 }
 
 static void __context_unpin_state(struct i915_vma *vma)
 {
i915_vma_make_shrinkable(vma);
+   i915_active_release(&vma->active);
__i915_vma_unpin(vma);
 }
 
-- 
2.25.0.rc2

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


Re: [Intel-gfx] [PATCH 13/14] drm/i915: Drop request list from error state

2020-01-10 Thread Andi Shyti
Hi Chris,

On Thu, Jan 09, 2020 at 08:58:38AM +, Chris Wilson wrote:
> The list of requests from after the hang tells little about the hang
> itself, only how busy userspace was after the fact. As it pertains
> nothing to the HW state, drop it from the error state.
> 
> Signed-off-by: Chris Wilson 

Acked-by: Andi Shyti 

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


[Intel-gfx] [PATCH 1/3] drm/i915/gt: Skip trying to unbind in restore_ggtt_mappings

2020-01-10 Thread Chris Wilson
Currently we first to try to unbind the VMA (and lazily rebind on next
use) as an optimisation during restore_ggtt_mappings. Ideally, the only
objects in the GGTT upon resume are the pinned kernel objects which
can't be unbound and need to be restored. As the unbind interferes with
the plan to mark those objects as active for error capture, forgo the
optimisation.

Signed-off-by: Chris Wilson 
---
 drivers/gpu/drm/i915/gt/intel_ggtt.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c 
b/drivers/gpu/drm/i915/gt/intel_ggtt.c
index 795cd267e28e..eb9365741ff8 100644
--- a/drivers/gpu/drm/i915/gt/intel_ggtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c
@@ -1197,7 +1197,7 @@ void i915_ggtt_disable_guc(struct i915_ggtt *ggtt)
 
 static void ggtt_restore_mappings(struct i915_ggtt *ggtt)
 {
-   struct i915_vma *vma, *vn;
+   struct i915_vma *vma;
bool flush = false;
int open;
 
@@ -1212,15 +1212,12 @@ static void ggtt_restore_mappings(struct i915_ggtt 
*ggtt)
open = atomic_xchg(&ggtt->vm.open, 0);
 
/* clflush objects bound into the GGTT and rebind them. */
-   list_for_each_entry_safe(vma, vn, &ggtt->vm.bound_list, vm_link) {
+   list_for_each_entry(vma, &ggtt->vm.bound_list, vm_link) {
struct drm_i915_gem_object *obj = vma->obj;
 
if (!i915_vma_is_bound(vma, I915_VMA_GLOBAL_BIND))
continue;
 
-   if (!__i915_vma_unbind(vma))
-   continue;
-
clear_bit(I915_VMA_GLOBAL_BIND_BIT, __i915_vma_flags(vma));
WARN_ON(i915_vma_bind(vma,
  obj ? obj->cache_level : 0,
-- 
2.25.0.rc2

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


[Intel-gfx] [PATCH] drm/i915/pmu: Do not use colon characters in PMU names

2020-01-10 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

We use PCI device path in the registered PMU name in order to distinguish
between multiple GPUs. But since tools/perf reserves a special meaning to
the colon character we need to transliterate them to something else. We
choose a dash.

Signed-off-by: Tvrtko Ursulin 
Reported-by: Dmitry Rogozhkin 
Fixes: 05488673a4d4 ("drm/i915/pmu: Support multiple GPUs")
Cc: Chris Wilson 
Cc: Michal Wajdeczko 
Cc: Andi Kleen 
---
 drivers/gpu/drm/i915/i915_pmu.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
index f3ef6700a5f2..ecbd0e1f1a90 100644
--- a/drivers/gpu/drm/i915/i915_pmu.c
+++ b/drivers/gpu/drm/i915/i915_pmu.c
@@ -1117,12 +1117,22 @@ void i915_pmu_register(struct drm_i915_private *i915)
hrtimer_init(&pmu->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
pmu->timer.function = i915_sample;
 
-   if (!is_igp(i915))
+   if (!is_igp(i915)) {
pmu->name = kasprintf(GFP_KERNEL,
  "i915-%s",
  dev_name(i915->drm.dev));
-   else
+   if (pmu->name) {
+   char *p;
+
+   /* tools/perf reserves colons as special. */
+   for (p = (char *)pmu->name; *p; p++) {
+   if (*p == ':')
+   *p = '-';
+   }
+   }
+   } else {
pmu->name = "i915";
+   }
if (!pmu->name)
goto err;
 
-- 
2.20.1

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


Re: [Intel-gfx] [PATCH] drm/i915/pmu: Do not use colon characters in PMU names

2020-01-10 Thread Chris Wilson
Quoting Tvrtko Ursulin (2020-01-10 11:11:26)
> From: Tvrtko Ursulin 
> 
> We use PCI device path in the registered PMU name in order to distinguish
> between multiple GPUs. But since tools/perf reserves a special meaning to
> the colon character we need to transliterate them to something else. We
> choose a dash.
> 
> Signed-off-by: Tvrtko Ursulin 
> Reported-by: Dmitry Rogozhkin 
> Fixes: 05488673a4d4 ("drm/i915/pmu: Support multiple GPUs")
> Cc: Chris Wilson 
> Cc: Michal Wajdeczko 
> Cc: Andi Kleen 
> ---
>  drivers/gpu/drm/i915/i915_pmu.c | 14 --
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
> index f3ef6700a5f2..ecbd0e1f1a90 100644
> --- a/drivers/gpu/drm/i915/i915_pmu.c
> +++ b/drivers/gpu/drm/i915/i915_pmu.c
> @@ -1117,12 +1117,22 @@ void i915_pmu_register(struct drm_i915_private *i915)
> hrtimer_init(&pmu->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> pmu->timer.function = i915_sample;
>  
> -   if (!is_igp(i915))
> +   if (!is_igp(i915)) {
> pmu->name = kasprintf(GFP_KERNEL,
>   "i915-%s",
>   dev_name(i915->drm.dev));
> -   else
> +   if (pmu->name) {

/* tools/perf reserves colons as special. */
strreplace(pmu->name, ':', '-');

I worry because the err_idx pointed to the '-'. We may have to use _
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915/pmu: Do not use colon characters in PMU names

2020-01-10 Thread Tvrtko Ursulin



On 10/01/2020 11:21, Chris Wilson wrote:

Quoting Tvrtko Ursulin (2020-01-10 11:11:26)

From: Tvrtko Ursulin 

We use PCI device path in the registered PMU name in order to distinguish
between multiple GPUs. But since tools/perf reserves a special meaning to
the colon character we need to transliterate them to something else. We
choose a dash.

Signed-off-by: Tvrtko Ursulin 
Reported-by: Dmitry Rogozhkin 
Fixes: 05488673a4d4 ("drm/i915/pmu: Support multiple GPUs")
Cc: Chris Wilson 
Cc: Michal Wajdeczko 
Cc: Andi Kleen 
---
  drivers/gpu/drm/i915/i915_pmu.c | 14 --
  1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
index f3ef6700a5f2..ecbd0e1f1a90 100644
--- a/drivers/gpu/drm/i915/i915_pmu.c
+++ b/drivers/gpu/drm/i915/i915_pmu.c
@@ -1117,12 +1117,22 @@ void i915_pmu_register(struct drm_i915_private *i915)
 hrtimer_init(&pmu->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 pmu->timer.function = i915_sample;
  
-   if (!is_igp(i915))

+   if (!is_igp(i915)) {
 pmu->name = kasprintf(GFP_KERNEL,
   "i915-%s",
   dev_name(i915->drm.dev));
-   else
+   if (pmu->name) {


/* tools/perf reserves colons as special. */
strreplace(pmu->name, ':', '-');


I didn't know this exists, thanks.


I worry because the err_idx pointed to the '-'. We may have to use _


What is err_idx? But yes.. it would had served me well to test before 
sending. :) I just find identifiers with a mix of underscores and dashes 
so visually unappealing. :(


Regards,

Tvrtko

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


Re: [Intel-gfx] [PATCH] drm/i915/pmu: Do not use colon characters in PMU names

2020-01-10 Thread Chris Wilson
Quoting Tvrtko Ursulin (2020-01-10 11:27:55)
> 
> On 10/01/2020 11:21, Chris Wilson wrote:
> > Quoting Tvrtko Ursulin (2020-01-10 11:11:26)
> >> From: Tvrtko Ursulin 
> >>
> >> We use PCI device path in the registered PMU name in order to distinguish
> >> between multiple GPUs. But since tools/perf reserves a special meaning to
> >> the colon character we need to transliterate them to something else. We
> >> choose a dash.
> >>
> >> Signed-off-by: Tvrtko Ursulin 
> >> Reported-by: Dmitry Rogozhkin 
> >> Fixes: 05488673a4d4 ("drm/i915/pmu: Support multiple GPUs")
> >> Cc: Chris Wilson 
> >> Cc: Michal Wajdeczko 
> >> Cc: Andi Kleen 
> >> ---
> >>   drivers/gpu/drm/i915/i915_pmu.c | 14 --
> >>   1 file changed, 12 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/i915/i915_pmu.c 
> >> b/drivers/gpu/drm/i915/i915_pmu.c
> >> index f3ef6700a5f2..ecbd0e1f1a90 100644
> >> --- a/drivers/gpu/drm/i915/i915_pmu.c
> >> +++ b/drivers/gpu/drm/i915/i915_pmu.c
> >> @@ -1117,12 +1117,22 @@ void i915_pmu_register(struct drm_i915_private 
> >> *i915)
> >>  hrtimer_init(&pmu->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> >>  pmu->timer.function = i915_sample;
> >>   
> >> -   if (!is_igp(i915))
> >> +   if (!is_igp(i915)) {
> >>  pmu->name = kasprintf(GFP_KERNEL,
> >>"i915-%s",
> >>dev_name(i915->drm.dev));
> >> -   else
> >> +   if (pmu->name) {
> > 
> > /* tools/perf reserves colons as special. */
> > strreplace(pmu->name, ':', '-');
> 
> I didn't know this exists, thanks.
> 
> > I worry because the err_idx pointed to the '-'. We may have to use _
> 
> What is err_idx? But yes.. it would had served me well to test before 
> sending. :) I just find identifiers with a mix of underscores and dashes 
> so visually unappealing. :(

event syntax error: 'i915-:00:02.0/bcs0-busy/'
 \___ parser error

The parser sets err_idx on the character it failed at, and the error
message includes it. So unless we lost whitespace in all the cutting and
pasting, that says it barfed at '-'
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v2] drm/i915/pmu: Do not use colons or dashes in PMU names

2020-01-10 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

We use PCI device path in the registered PMU name in order to distinguish
between multiple GPUs. But since tools/perf reserves a special meaning to
dash and colon characters we need to transliterate them to something else.
We choose an underscore.

v2:
 * Use strreplace. (Chris)
 * Dashes are not good either. (Chris)

Signed-off-by: Tvrtko Ursulin 
Reported-by: Dmitry Rogozhkin 
Fixes: 05488673a4d4 ("drm/i915/pmu: Support multiple GPUs")
Cc: Chris Wilson 
Cc: Michal Wajdeczko 
Cc: Andi Kleen 
---
 drivers/gpu/drm/i915/i915_pmu.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
index f3ef6700a5f2..28a82c849bac 100644
--- a/drivers/gpu/drm/i915/i915_pmu.c
+++ b/drivers/gpu/drm/i915/i915_pmu.c
@@ -1117,12 +1117,17 @@ void i915_pmu_register(struct drm_i915_private *i915)
hrtimer_init(&pmu->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
pmu->timer.function = i915_sample;
 
-   if (!is_igp(i915))
+   if (!is_igp(i915)) {
pmu->name = kasprintf(GFP_KERNEL,
- "i915-%s",
+ "i915_%s",
  dev_name(i915->drm.dev));
-   else
+   if (pmu->name) {
+   /* tools/perf reserves colons as special. */
+   strreplace((char *)pmu->name, ':', '_');
+   }
+   } else {
pmu->name = "i915";
+   }
if (!pmu->name)
goto err;
 
-- 
2.20.1

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


Re: [Intel-gfx] [PATCH] drm/i915/pmu: Do not use colon characters in PMU names

2020-01-10 Thread Tvrtko Ursulin



On 10/01/2020 11:32, Chris Wilson wrote:

Quoting Tvrtko Ursulin (2020-01-10 11:27:55)


On 10/01/2020 11:21, Chris Wilson wrote:

Quoting Tvrtko Ursulin (2020-01-10 11:11:26)

From: Tvrtko Ursulin 

We use PCI device path in the registered PMU name in order to distinguish
between multiple GPUs. But since tools/perf reserves a special meaning to
the colon character we need to transliterate them to something else. We
choose a dash.

Signed-off-by: Tvrtko Ursulin 
Reported-by: Dmitry Rogozhkin 
Fixes: 05488673a4d4 ("drm/i915/pmu: Support multiple GPUs")
Cc: Chris Wilson 
Cc: Michal Wajdeczko 
Cc: Andi Kleen 
---
   drivers/gpu/drm/i915/i915_pmu.c | 14 --
   1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
index f3ef6700a5f2..ecbd0e1f1a90 100644
--- a/drivers/gpu/drm/i915/i915_pmu.c
+++ b/drivers/gpu/drm/i915/i915_pmu.c
@@ -1117,12 +1117,22 @@ void i915_pmu_register(struct drm_i915_private *i915)
  hrtimer_init(&pmu->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
  pmu->timer.function = i915_sample;
   
-   if (!is_igp(i915))

+   if (!is_igp(i915)) {
  pmu->name = kasprintf(GFP_KERNEL,
"i915-%s",
dev_name(i915->drm.dev));
-   else
+   if (pmu->name) {


/* tools/perf reserves colons as special. */
strreplace(pmu->name, ':', '-');


I didn't know this exists, thanks.


I worry because the err_idx pointed to the '-'. We may have to use _


What is err_idx? But yes.. it would had served me well to test before
sending. :) I just find identifiers with a mix of underscores and dashes
so visually unappealing. :(


event syntax error: 'i915-:00:02.0/bcs0-busy/'
  \___ parser error

The parser sets err_idx on the character it failed at, and the error
message includes it. So unless we lost whitespace in all the cutting and
pasting, that says it barfed at '-'


Oh right, interesting that it has no problem with a dash in event name. 
In v2 full event string is:


  i915__00_02.0/vcs0-busy/

A bit ugly but seems to work.

Regards,

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


Re: [Intel-gfx] [PATCH 2/2] drm/i915: Reduce warning for i915_vma_pin_iomap() without runtime-pm

2020-01-10 Thread Mika Kuoppala
Chris Wilson  writes:

> Access through the GGTT (iomap) into the vma does require the device to
> be awake. However, we often take the i915_vma_pin_iomap() as an early
> preparatory step that is long before we use the iomap. Asserting that
> the device is awake at pin time does not protect us, and is merely a
> nuisance.
>
> Signed-off-by: Chris Wilson 
> Cc: Mika Kuoppala 

I do remember stamping this. No matter, i have plenty of ink.

Reviewed-by: Mika Kuoppala 

> ---
>  drivers/gpu/drm/i915/i915_vma.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
> index cbd783c31adb..43d5c270bdb0 100644
> --- a/drivers/gpu/drm/i915/i915_vma.c
> +++ b/drivers/gpu/drm/i915/i915_vma.c
> @@ -423,8 +423,6 @@ void __iomem *i915_vma_pin_iomap(struct i915_vma *vma)
>   void __iomem *ptr;
>   int err;
>  
> - /* Access through the GTT requires the device to be awake. */
> - assert_rpm_wakelock_held(vma->vm->gt->uncore->rpm);
>   if (GEM_WARN_ON(!i915_vma_is_map_and_fenceable(vma))) {
>   err = -ENODEV;
>   goto err;
> @@ -456,6 +454,8 @@ void __iomem *i915_vma_pin_iomap(struct i915_vma *vma)
>   goto err_unpin;
>  
>   i915_vma_set_ggtt_write(vma);
> +
> + /* NB Access through the GTT requires the device to be awake. */
>   return ptr;
>  
>  err_unpin:
> -- 
> 2.25.0.rc1
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v2 1/2] drm/connector: Split out orientation quirk detection (v2)

2020-01-10 Thread Jani Nikula
On Sun, 05 Jan 2020, Hans de Goede  wrote:
> From: Derek Basehore 
>
> Not every platform needs quirk detection for panel orientation, so
> split the drm_connector_init_panel_orientation_property into two
> functions. One for platforms without the need for quirks, and the
> other for platforms that need quirks.
>
> Hans de Goede (changes in v2):
>
> Rename the function from drm_connector_init_panel_orientation_property
> to drm_connector_set_panel_orientation[_with_quirk] and pass in the
> panel-orientation to set.
>
> Beside the rename, also make the function set the passed in value
> only once, if the value was set before (to a value other then
> DRM_MODE_PANEL_ORIENTATION_UNKNOWN) make any further set calls a no-op.
>
> This change is preparation for allowing the user to override the
> panel-orientation for any connector from the kernel commandline.
> When the panel-orientation is overridden this way, then we must ignore
> the panel-orientation detection done by the driver.

Acked-by: Jani Nikula 

for merging via drm-misc.

---

Side note, I'm a bit concerned about the gradual accumulation of ad hoc
ways to set various connector properties on the kernel
command-line... without actually making it a generic way to set any
arbitrary connector properties on the kernel command-line.

BR,
Jani.



>
> Reviewed-by: Rodrigo Vivi 
> Signed-off-by: Derek Basehore 
> Signed-off-by: Hans de Goede 
> ---
>  drivers/gpu/drm/drm_connector.c | 74 ++---
>  drivers/gpu/drm/i915/display/icl_dsi.c  |  5 +-
>  drivers/gpu/drm/i915/display/intel_dp.c |  9 ++-
>  drivers/gpu/drm/i915/display/vlv_dsi.c  |  5 +-
>  include/drm/drm_connector.h |  9 ++-
>  5 files changed, 71 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 2166000ed057..de5031c4aa49 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -1139,7 +1139,8 @@ static const struct drm_prop_enum_list dp_colorspaces[] 
> = {
>   *   coordinates, so if userspace rotates the picture to adjust for
>   *   the orientation it must also apply the same transformation to the
>   *   touchscreen input coordinates. This property is initialized by calling
> - *   drm_connector_init_panel_orientation_property().
> + *   drm_connector_set_panel_orientation() or
> + *   drm_connector_set_panel_orientation_with_quirk()
>   *
>   * scaling mode:
>   *   This property defines how a non-native mode is upscaled to the native
> @@ -2046,38 +2047,41 @@ void drm_connector_set_vrr_capable_property(
>  EXPORT_SYMBOL(drm_connector_set_vrr_capable_property);
>  
>  /**
> - * drm_connector_init_panel_orientation_property -
> - *   initialize the connecters panel_orientation property
> - * @connector: connector for which to init the panel-orientation property.
> - * @width: width in pixels of the panel, used for panel quirk detection
> - * @height: height in pixels of the panel, used for panel quirk detection
> + * drm_connector_set_panel_orientation - sets the connecter's 
> panel_orientation
> + * @connector: connector for which to set the panel-orientation property.
> + * @panel_orientation: drm_panel_orientation value to set
> + *
> + * This function sets the connector's panel_orientation and attaches
> + * a "panel orientation" property to the connector.
>   *
> - * This function should only be called for built-in panels, after setting
> - * connector->display_info.panel_orientation first (if known).
> + * Calling this function on a connector where the panel_orientation has
> + * already been set is a no-op (e.g. the orientation has been overridden with
> + * a kernel commandline option).
>   *
> - * This function will check for platform specific (e.g. DMI based) quirks
> - * overriding display_info.panel_orientation first, then if panel_orientation
> - * is not DRM_MODE_PANEL_ORIENTATION_UNKNOWN it will attach the
> - * "panel orientation" property to the connector.
> + * It is allowed to call this function with a panel_orientation of
> + * DRM_MODE_PANEL_ORIENTATION_UNKNOWN, in which case it is a no-op.
>   *
>   * Returns:
>   * Zero on success, negative errno on failure.
>   */
> -int drm_connector_init_panel_orientation_property(
> - struct drm_connector *connector, int width, int height)
> +int drm_connector_set_panel_orientation(
> + struct drm_connector *connector,
> + enum drm_panel_orientation panel_orientation)
>  {
>   struct drm_device *dev = connector->dev;
>   struct drm_display_info *info = &connector->display_info;
>   struct drm_property *prop;
> - int orientation_quirk;
>  
> - orientation_quirk = drm_get_panel_orientation_quirk(width, height);
> - if (orientation_quirk != DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
> - info->panel_orientation = orientation_quirk;
> + /* Already set? */
> + if (info->panel_orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
> + return

Re: [Intel-gfx] [PATCH v2] drm/i915/pmu: Do not use colons or dashes in PMU names

2020-01-10 Thread Chris Wilson
Quoting Tvrtko Ursulin (2020-01-10 11:32:53)
> From: Tvrtko Ursulin 
> 
> We use PCI device path in the registered PMU name in order to distinguish
> between multiple GPUs. But since tools/perf reserves a special meaning to
> dash and colon characters we need to transliterate them to something else.
> We choose an underscore.
> 
> v2:
>  * Use strreplace. (Chris)
>  * Dashes are not good either. (Chris)
> 
> Signed-off-by: Tvrtko Ursulin 
> Reported-by: Dmitry Rogozhkin 
> Fixes: 05488673a4d4 ("drm/i915/pmu: Support multiple GPUs")
> Cc: Chris Wilson 
> Cc: Michal Wajdeczko 
> Cc: Andi Kleen 
> ---
>  drivers/gpu/drm/i915/i915_pmu.c | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
> index f3ef6700a5f2..28a82c849bac 100644
> --- a/drivers/gpu/drm/i915/i915_pmu.c
> +++ b/drivers/gpu/drm/i915/i915_pmu.c
> @@ -1117,12 +1117,17 @@ void i915_pmu_register(struct drm_i915_private *i915)
> hrtimer_init(&pmu->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> pmu->timer.function = i915_sample;
>  
> -   if (!is_igp(i915))
> +   if (!is_igp(i915)) {
> pmu->name = kasprintf(GFP_KERNEL,
> - "i915-%s",
> + "i915_%s",
>   dev_name(i915->drm.dev));
> -   else
> +   if (pmu->name) {
> +   /* tools/perf reserves colons as special. */
> +   strreplace((char *)pmu->name, ':', '_');
> +   }
> +   } else {
> pmu->name = "i915";
> +   }
> if (!pmu->name)
> goto err;

Sadly I have no nicer suggestion, so
Reviewed-by: Chris Wilson 
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PULL] drm-misc-next

2020-01-10 Thread Maarten Lankhorst
drm-misc-next-2020-01-10:
drm-misc-next for v5.6:

UAPI Changes:

Cross-subsystem Changes:
- Convert simple panel bindings to a template.

Core Changes:
- Revert drm-bridge-state changes, it causes a dependency error
  between drm and drm_kms_helper.
- Fix when disabling crc's.
- Assorted Kconfig fixes.

Driver Changes:
- Add ddc symlinks to more drivers.
- Fix chained bridge handling in exynos and vc4.
- More clock rate fixes in sun4i.
- Add support for AUO B116XAK01, GiantPlus GPM940B0, Sony ACX424AKP,
  BOE NV140FHM-N49, Satoz SAT050AT40H12R2 and Sharp LS020B1DD01D panels.
- Assorted small bugfixes.
The following changes since commit 3cacb2086e41bbdf4a43e494d47d05db356992b9:

  drm/mgag200: Add module parameter to pin all buffers at offset 0 (2020-01-07 
11:53:19 +0100)

are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm-misc tags/drm-misc-next-2020-01-10

for you to fetch changes up to 44c58c520ffc4b1f75241e5029c5ae6b223d0623:

  drm/panel: simple: Add Satoz SAT050AT40H12R2 panel support (2020-01-09 
20:27:06 +0100)


drm-misc-next for v5.6:

UAPI Changes:

Cross-subsystem Changes:
- Convert simple panel bindings to a template.

Core Changes:
- Revert drm-bridge-state changes, it causes a dependency error
  between drm and drm_kms_helper.
- Fix when disabling crc's.
- Assorted Kconfig fixes.

Driver Changes:
- Add ddc symlinks to more drivers.
- Fix chained bridge handling in exynos and vc4.
- More clock rate fixes in sun4i.
- Add support for AUO B116XAK01, GiantPlus GPM940B0, Sony ACX424AKP,
  BOE NV140FHM-N49, Satoz SAT050AT40H12R2 and Sharp LS020B1DD01D panels.
- Assorted small bugfixes.


Andrzej Pietrasiewicz (4):
  drm/tegra: Provide ddc symlink in output connector sysfs directory
  drm/vc4: Provide ddc symlink in connector sysfs directory
  drm: zte: Provide ddc symlink in hdmi connector sysfs directory
  drm: zte: Provide ddc symlink in vga connector sysfs directory

Arnd Bergmann (1):
  drm: meson: fix address type confusion

Benjamin Gaignard (2):
  drm/modes: tag unused variables to avoid warnings
  drm/fb-cma-helpers: Fix include issue

Boris Brezillon (8):
  drm/bridge: Fix a NULL pointer dereference in 
drm_atomic_bridge_chain_check()
  Revert "drm/bridge: Fix a NULL pointer dereference in 
drm_atomic_bridge_chain_check()"
  Revert "drm/bridge: Add the necessary bits to support bus format 
negotiation"
  Revert "drm/bridge: Add an ->atomic_check() hook"
  Revert "drm/bridge: Patch atomic hooks to take a drm_bridge_state"
  Revert "drm/bridge: Add a drm_bridge_state object"
  drm/vc4: dsi: Fix bridge chain handling
  drm/exynos: dsi: Fix bridge chain handling

Chen Zhou (1):
  drm/gma500: remove set but not used variables 'hist_reg'

Dan Carpenter (1):
  gpu/drm: clean up white space in drm_legacy_lock_master_cleanup()

Dingchen Zhang (2):
  drm: remove the newline for CRC source name.
  drm: Set crc->opened to false before setting crc source to NULL.

Hans Verkuil (1):
  drm/Kconfig: add missing 'depends on DRM' for DRM_DP_CEC

Linus Walleij (1):
  drm/panel: Add driver for Sony ACX424AKP panel

Maxime Ripard (3):
  drm/sun4i: backend: Make sure we enforce the clock rate
  drm/sun4i: drc: Make sure we enforce the clock rate
  dt-bindings: display: Convert Allwinner display pipeline to schemas

Miquel Raynal (3):
  dt-bindings: Add vendor prefix for Satoz
  dt-bindings: display: simple: Add Satoz panel
  drm/panel: simple: Add Satoz SAT050AT40H12R2 panel support

Paul Cercueil (2):
  dt-bindings: panel-simple: Add compatible for GiantPlus GPM940B0
  dt-bindings: panel-simple: Add compatible for Sharp LS020B1DD01D

Qiang Yu (1):
  drm/lima: use drm_sched_fault for error task handling

Rob Clark (2):
  dt-bindings: display: panel: Add AUO B116XAK01 panel bindings
  drm/panel: Add support for AUO B116XAK01 panel

Sam Ravnborg (2):
  dt-bindings: one binding file for all simple panels
  dt-bindings: display: add BOE 14" panel

Thomas Zimmermann (1):
  drm/udl: Make udl driver depend on CONFIG_USB

Tobias Schramm (1):
  drm/panel: Add support for BOE NV140FHM-N49 panel to panel-simple

Wambui Karuga (1):
  drm/omapdrm: use BUG_ON macro for error debugging.

kbuild test robot (1):
  video: fbdev: mmp: fix platform_get_irq.cocci warnings

 .../allwinner,sun4i-a10-display-backend.yaml   | 291 +
 .../allwinner,sun4i-a10-display-engine.yaml| 114 
 .../allwinner,sun4i-a10-display-frontend.yaml  | 138 +
 .../bindings/display/allwinner,sun4i-a10-hdmi.yaml | 183 ++
 .../bindings/display/allwinner,sun4i-a10-tcon.yaml | 676 +
 .../display/allwinner,sun4i-a10-tv-encoder.yaml|  62 ++
 .../bindings/display/allwinner,sun6i-a31-drc.yaml  | 138 +++

[Intel-gfx] [PATCH i-g-t v3] i915/perf: Find the associated perf-type for a particular device

2020-01-10 Thread Chris Wilson
Since with multiple devices, we may have multiple different perf_pmu
each with their own type, we want to find the right one for the job.

The tests are run with a specific fd, from which we can extract the
appropriate bus-id and find the associated perf-type. The performance
monitoring tools are a little more general and not yet ready to probe
all device or bind to one in particular, so we just assume the default
igfx for the time being.

v2: Extract the bus address from out of sysfs
v3: A new name for a new decade!

Signed-off-by: Chris Wilson 
Cc: "Robert M. Fosha" 
Cc: Tvrtko Ursulin 
Cc: Michal Wajdeczko 
Reviewed-by: "Robert M. Fosha"  #v2
---
 benchmarks/gem_wsim.c  |  4 +-
 lib/igt_perf.c | 91 +++---
 lib/igt_perf.h | 13 +++--
 overlay/gem-interrupts.c   |  2 +-
 overlay/gpu-freq.c |  4 +-
 overlay/gpu-top.c  | 12 ++---
 overlay/rc6.c  |  2 +-
 tests/i915/gem_ctx_freq.c  |  2 +-
 tests/i915/gem_ctx_sseu.c  |  2 +-
 tests/i915/gem_exec_balancer.c | 18 ---
 tests/perf_pmu.c   | 84 ---
 tools/intel_gpu_top.c  |  2 +-
 12 files changed, 166 insertions(+), 70 deletions(-)

diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index 6305e0d7a..9156fdc90 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -2268,8 +2268,8 @@ busy_init(const struct workload_balancer *balancer, 
struct workload *wrk)
for (d = &engines[0]; d->id != VCS; d++) {
int pfd;
 
-   pfd = perf_i915_open_group(I915_PMU_ENGINE_BUSY(d->class,
-   d->inst),
+   pfd = perf_igfx_open_group(I915_PMU_ENGINE_BUSY(d->class,
+   d->inst),
   bb->fd);
if (pfd < 0) {
if (d->id != VCS2)
diff --git a/lib/igt_perf.c b/lib/igt_perf.c
index e3dec2cc2..418c1c188 100644
--- a/lib/igt_perf.c
+++ b/lib/igt_perf.c
@@ -4,17 +4,84 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 
 #include "igt_perf.h"
 
-uint64_t i915_type_id(void)
+static char *bus_address(int i915, char *path, int pathlen)
+{
+   struct stat st;
+   int len = -1;
+   int dir;
+   char *s;
+
+   if (fstat(i915, &st) || !S_ISCHR(st.st_mode))
+   return NULL;
+
+   snprintf(path, pathlen, "/sys/dev/char/%d:%d",
+major(st.st_rdev), minor(st.st_rdev));
+
+   dir = open(path, O_RDONLY);
+   if (dir != -1) {
+   len = readlinkat(dir, "device", path, pathlen - 1);
+   close(dir);
+   }
+   if (len < 0)
+   return NULL;
+
+   path[len] = '\0';
+
+   /* strip off the relative path */
+   s = strrchr(path, '/');
+   if (s)
+   memmove(path, s + 1, len - (s - path) + 1);
+
+   return path;
+}
+
+const char *i915_perf_device(int i915, char *buf, int buflen)
+{
+   char *s;
+
+#define prefix "i915_"
+#define plen strlen(prefix)
+
+   if (!buf || buflen < plen)
+   return "i915";
+
+   memcpy(buf, prefix, plen);
+
+   if (!bus_address(i915, buf + plen, buflen - plen) ||
+   strcmp(buf + plen, ":00:02.0") == 0) /* legacy name for igfx */
+   buf[plen - 1] = '\0';
+
+   /* Convert all colons in the address to '_', thanks perf! */
+   for (s = buf; *s; s++)
+   if (*s == ':')
+   *s = '_';
+
+   return buf;
+}
+
+uint64_t i915_perf_type_id(int i915)
+{
+   char buf[80];
+
+   return igt_perf_type_id(i915_perf_device(i915, buf, sizeof(buf)));
+}
+
+uint64_t igt_perf_type_id(const char *device)
 {
char buf[64];
ssize_t ret;
int fd;
 
-   fd = open("/sys/bus/event_source/devices/i915/type", O_RDONLY);
+   snprintf(buf, sizeof(buf),
+"/sys/bus/event_source/devices/%s/type", device);
+
+   fd = open(buf, O_RDONLY);
if (fd < 0)
return 0;
 
@@ -52,15 +119,27 @@ _perf_open(uint64_t type, uint64_t config, int group, 
uint64_t format)
return ret;
 }
 
-int perf_i915_open(uint64_t config)
+int perf_igfx_open(uint64_t config)
+{
+   return _perf_open(igt_perf_type_id("i915"), config, -1,
+ PERF_FORMAT_TOTAL_TIME_ENABLED);
+}
+
+int perf_igfx_open_group(uint64_t config, int group)
+{
+   return _perf_open(igt_perf_type_id("i915"), config, group,
+ PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
+}
+
+int perf_i915_open(int i915, uint64_t config)
 {
-   return _perf_open(i915_type_id(), config, -1,
+   return _perf_open(i915_perf_type_id(i915), config, -1,
  PERF_FORMAT_TOTAL_TIME_ENABLED);
 }
 
-int perf_i915_open_group(uint64_t config, int group)
+int perf_i

Re: [Intel-gfx] [PATCH 03/23] drm/i915: Don't use struct drm_driver.get_scanout_position()

2020-01-10 Thread Jani Nikula
On Fri, 10 Jan 2020, Thomas Zimmermann  wrote:
> The callback struct drm_driver.get_scanout_position() is deprecated in
> favor of struct drm_crtc_helper_funcs.get_scanout_position().
>
> i915 doesn't use CRTC helpers. The patch duplicates the caller
> drm_calc_vbltimestamp_from_scanoutpos() for i915, such that the callback
> function is not needed.
>
> Signed-off-by: Thomas Zimmermann 
> ---
>  drivers/gpu/drm/i915/i915_drv.c |   3 +-
>  drivers/gpu/drm/i915/i915_irq.c | 117 ++--
>  drivers/gpu/drm/i915/i915_irq.h |   9 +--
>  3 files changed, 119 insertions(+), 10 deletions(-)

Not really enthusiastic about the diffstat in a "cleanup" series.

I wonder if you could add a generic helper version of
drm_calc_vbltimestamp_from_scanoutpos where you pass the
get_scanout_position function as a parameter. Both
drm_calc_vbltimestamp_from_scanoutpos and the new
i915_calc_vbltimestamp_from_scanoutpos would then be fairly thin
wrappers passing in the relevant get_scanout_position function.

This would reduce the almost identical duplication of the function in
i915.

BR,
Jani.

>
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index f7385abdd74b..4a0a7fb85c53 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -2769,8 +2769,7 @@ static struct drm_driver driver = {
>   .gem_prime_export = i915_gem_prime_export,
>   .gem_prime_import = i915_gem_prime_import,
>  
> - .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
> - .get_scanout_position = i915_get_crtc_scanoutpos,
> + .get_vblank_timestamp = i915_calc_vbltimestamp_from_scanoutpos,
>  
>   .dumb_create = i915_gem_dumb_create,
>   .dumb_map_offset = i915_gem_dumb_mmap_offset,
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index afc6aad9bf8c..99d0c3b0feae 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -52,6 +52,11 @@
>  #include "i915_trace.h"
>  #include "intel_pm.h"
>  
> +/* Retry timestamp calculation up to 3 times to satisfy
> + * drm_timestamp_precision before giving up.
> + */
> +#define I915_TIMESTAMP_MAXRETRIES 3
> +
>  /**
>   * DOC: interrupt handling
>   *
> @@ -762,10 +767,11 @@ static int __intel_get_crtc_scanline(struct intel_crtc 
> *crtc)
>   return (position + crtc->scanline_offset) % vtotal;
>  }
>  
> -bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int index,
> -   bool in_vblank_irq, int *vpos, int *hpos,
> -   ktime_t *stime, ktime_t *etime,
> -   const struct drm_display_mode *mode)
> +static bool i915_get_crtc_scanoutpos(struct drm_device *dev,
> +  unsigned int index, bool in_vblank_irq,
> +  int *vpos, int *hpos,
> +  ktime_t *stime, ktime_t *etime,
> +  const struct drm_display_mode *mode)
>  {
>   struct drm_i915_private *dev_priv = to_i915(dev);
>   struct intel_crtc *crtc = to_intel_crtc(drm_crtc_from_index(dev, 
> index));
> @@ -879,6 +885,109 @@ bool i915_get_crtc_scanoutpos(struct drm_device *dev, 
> unsigned int index,
>   return true;
>  }
>  
> +bool i915_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
> + unsigned int pipe,
> + int *max_error,
> + ktime_t *vblank_time,
> + bool in_vblank_irq)
> +{
> + struct timespec64 ts_etime, ts_vblank_time;
> + ktime_t stime, etime;
> + bool vbl_status;
> + struct drm_crtc *crtc;
> + const struct drm_display_mode *mode;
> + struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
> + int vpos, hpos, i;
> + int delta_ns, duration_ns;
> +
> + crtc = drm_crtc_from_index(dev, pipe);
> +
> + if (pipe >= dev->num_crtcs || !crtc) {
> + DRM_ERROR("Invalid crtc %u\n", pipe);
> + return false;
> + }
> +
> + if (drm_drv_uses_atomic_modeset(dev))
> + mode = &vblank->hwmode;
> + else
> + mode = &crtc->hwmode;
> +
> + /* If mode timing undefined, just return as no-op:
> +  * Happens during initial modesetting of a crtc.
> +  */
> + if (mode->crtc_clock == 0) {
> + DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
> + WARN_ON_ONCE(drm_drv_uses_atomic_modeset(dev));
> +
> + return false;
> + }
> +
> + /* Get current scanout position with system timestamp.
> +  * Repeat query up to DRM_TIMESTAMP_MAXRETRIES times
> +  * if single query takes longer than max_error nanoseconds.
> +  *
> +  * This guarantees a tight bound on maximum error if
> +  * code gets preempted or delayed for some reason.
> +  */
> +

Re: [Intel-gfx] [PATCH 03/23] drm/i915: Don't use struct drm_driver.get_scanout_position()

2020-01-10 Thread Thomas Zimmermann
Hi

Am 10.01.20 um 12:59 schrieb Jani Nikula:
> On Fri, 10 Jan 2020, Thomas Zimmermann  wrote:
>> The callback struct drm_driver.get_scanout_position() is deprecated in
>> favor of struct drm_crtc_helper_funcs.get_scanout_position().
>>
>> i915 doesn't use CRTC helpers. The patch duplicates the caller
>> drm_calc_vbltimestamp_from_scanoutpos() for i915, such that the callback
>> function is not needed.
>>
>> Signed-off-by: Thomas Zimmermann 
>> ---
>>  drivers/gpu/drm/i915/i915_drv.c |   3 +-
>>  drivers/gpu/drm/i915/i915_irq.c | 117 ++--
>>  drivers/gpu/drm/i915/i915_irq.h |   9 +--
>>  3 files changed, 119 insertions(+), 10 deletions(-)
> 
> Not really enthusiastic about the diffstat in a "cleanup" series.

Well, the cleanup is about the content of drm_driver :)

> 
> I wonder if you could add a generic helper version of
> drm_calc_vbltimestamp_from_scanoutpos where you pass the
> get_scanout_position function as a parameter. Both
> drm_calc_vbltimestamp_from_scanoutpos and the new
> i915_calc_vbltimestamp_from_scanoutpos would then be fairly thin
> wrappers passing in the relevant get_scanout_position function.

Of course. Will be in v2 of the series.

Best regards
Thomas

> 
> This would reduce the almost identical duplication of the function in
> i915.
> 
> BR,
> Jani.
> 
>>
>> diff --git a/drivers/gpu/drm/i915/i915_drv.c 
>> b/drivers/gpu/drm/i915/i915_drv.c
>> index f7385abdd74b..4a0a7fb85c53 100644
>> --- a/drivers/gpu/drm/i915/i915_drv.c
>> +++ b/drivers/gpu/drm/i915/i915_drv.c
>> @@ -2769,8 +2769,7 @@ static struct drm_driver driver = {
>>  .gem_prime_export = i915_gem_prime_export,
>>  .gem_prime_import = i915_gem_prime_import,
>>  
>> -.get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
>> -.get_scanout_position = i915_get_crtc_scanoutpos,
>> +.get_vblank_timestamp = i915_calc_vbltimestamp_from_scanoutpos,
>>  
>>  .dumb_create = i915_gem_dumb_create,
>>  .dumb_map_offset = i915_gem_dumb_mmap_offset,
>> diff --git a/drivers/gpu/drm/i915/i915_irq.c 
>> b/drivers/gpu/drm/i915/i915_irq.c
>> index afc6aad9bf8c..99d0c3b0feae 100644
>> --- a/drivers/gpu/drm/i915/i915_irq.c
>> +++ b/drivers/gpu/drm/i915/i915_irq.c
>> @@ -52,6 +52,11 @@
>>  #include "i915_trace.h"
>>  #include "intel_pm.h"
>>  
>> +/* Retry timestamp calculation up to 3 times to satisfy
>> + * drm_timestamp_precision before giving up.
>> + */
>> +#define I915_TIMESTAMP_MAXRETRIES 3
>> +
>>  /**
>>   * DOC: interrupt handling
>>   *
>> @@ -762,10 +767,11 @@ static int __intel_get_crtc_scanline(struct intel_crtc 
>> *crtc)
>>  return (position + crtc->scanline_offset) % vtotal;
>>  }
>>  
>> -bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int index,
>> -  bool in_vblank_irq, int *vpos, int *hpos,
>> -  ktime_t *stime, ktime_t *etime,
>> -  const struct drm_display_mode *mode)
>> +static bool i915_get_crtc_scanoutpos(struct drm_device *dev,
>> + unsigned int index, bool in_vblank_irq,
>> + int *vpos, int *hpos,
>> + ktime_t *stime, ktime_t *etime,
>> + const struct drm_display_mode *mode)
>>  {
>>  struct drm_i915_private *dev_priv = to_i915(dev);
>>  struct intel_crtc *crtc = to_intel_crtc(drm_crtc_from_index(dev, 
>> index));
>> @@ -879,6 +885,109 @@ bool i915_get_crtc_scanoutpos(struct drm_device *dev, 
>> unsigned int index,
>>  return true;
>>  }
>>  
>> +bool i915_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
>> +unsigned int pipe,
>> +int *max_error,
>> +ktime_t *vblank_time,
>> +bool in_vblank_irq)
>> +{
>> +struct timespec64 ts_etime, ts_vblank_time;
>> +ktime_t stime, etime;
>> +bool vbl_status;
>> +struct drm_crtc *crtc;
>> +const struct drm_display_mode *mode;
>> +struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
>> +int vpos, hpos, i;
>> +int delta_ns, duration_ns;
>> +
>> +crtc = drm_crtc_from_index(dev, pipe);
>> +
>> +if (pipe >= dev->num_crtcs || !crtc) {
>> +DRM_ERROR("Invalid crtc %u\n", pipe);
>> +return false;
>> +}
>> +
>> +if (drm_drv_uses_atomic_modeset(dev))
>> +mode = &vblank->hwmode;
>> +else
>> +mode = &crtc->hwmode;
>> +
>> +/* If mode timing undefined, just return as no-op:
>> + * Happens during initial modesetting of a crtc.
>> + */
>> +if (mode->crtc_clock == 0) {
>> +DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
>> +WARN_ON_ONCE(drm_drv_uses_atomic_modeset(dev));
>> +
>> +return false;
>> +}
>> +
>> +/* Get current scanout position with system timestamp.
>> + * Re

[Intel-gfx] [CI 4/4] drm/i915: Drop request list from error state

2020-01-10 Thread Chris Wilson
The list of requests from after the hang tells little about the hang
itself, only how busy userspace was after the fact. As it pertains
nothing to the HW state, drop it from the error state.

Signed-off-by: Chris Wilson 
Acked-by: Andi Shyti 
---
 drivers/gpu/drm/i915/i915_gpu_error.c | 75 +++
 drivers/gpu/drm/i915/i915_gpu_error.h |  3 +-
 2 files changed, 8 insertions(+), 70 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c 
b/drivers/gpu/drm/i915/i915_gpu_error.c
index 79eae3708602..95635daca4c4 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -669,7 +669,7 @@ static void err_print_gt(struct drm_i915_error_state_buf *m,
 struct intel_gt_coredump *gt)
 {
const struct intel_engine_coredump *ee;
-   int i, j;
+   int i;
 
err_printf(m, "GT awake: %s\n", yesno(gt->awake));
err_printf(m, "EIR: 0x%08x\n", gt->eir);
@@ -715,17 +715,8 @@ static void err_print_gt(struct drm_i915_error_state_buf 
*m,
const struct i915_vma_coredump *vma;
 
error_print_engine(m, ee);
-
for (vma = ee->vma; vma; vma = vma->next)
print_error_vma(m, ee->engine, vma);
-
-   if (ee->num_requests) {
-   err_printf(m, "%s --- %d requests\n",
-  ee->engine->name,
-  ee->num_requests);
-   for (j = 0; j < ee->num_requests; j++)
-   error_print_request(m, " ", &ee->requests[j]);
-   }
}
 
if (gt->uc)
@@ -936,7 +927,6 @@ static void cleanup_gt(struct intel_gt_coredump *gt)
gt->engine = ee->next;
 
i915_vma_coredump_free(ee->vma);
-   kfree(ee->requests);
kfree(ee);
}
 
@@ -1221,54 +1211,6 @@ static void record_request(const struct i915_request 
*request,
rcu_read_unlock();
 }
 
-static void engine_record_requests(const struct intel_engine_cs *engine,
-  struct i915_request *first,
-  struct intel_engine_coredump *ee)
-{
-   struct i915_request *request;
-   int count;
-
-   count = 0;
-   request = first;
-   list_for_each_entry_from(request, &engine->active.requests, sched.link)
-   count++;
-   if (!count)
-   return;
-
-   ee->requests = kcalloc(count, sizeof(*ee->requests), ATOMIC_MAYFAIL);
-   if (!ee->requests)
-   return;
-
-   ee->num_requests = count;
-
-   count = 0;
-   request = first;
-   list_for_each_entry_from(request,
-&engine->active.requests, sched.link) {
-   if (count >= ee->num_requests) {
-   /*
-* If the ring request list was changed in
-* between the point where the error request
-* list was created and dimensioned and this
-* point then just exit early to avoid crashes.
-*
-* We don't need to communicate that the
-* request list changed state during error
-* state capture and that the error state is
-* slightly incorrect as a consequence since we
-* are typically only interested in the request
-* list state at the point of error state
-* capture, not in any changes happening during
-* the capture.
-*/
-   break;
-   }
-
-   record_request(request, &ee->requests[count++]);
-   }
-   ee->num_requests = count;
-}
-
 static void engine_record_execlists(struct intel_engine_coredump *ee)
 {
const struct intel_engine_execlists * const el = &ee->engine->execlists;
@@ -1480,7 +1422,7 @@ static struct intel_engine_coredump *
 capture_engine(struct intel_engine_cs *engine,
   struct i915_vma_compress *compress)
 {
-   struct intel_engine_capture_vma *capture;
+   struct intel_engine_capture_vma *capture = NULL;
struct intel_engine_coredump *ee;
struct i915_request *rq;
unsigned long flags;
@@ -1490,19 +1432,16 @@ capture_engine(struct intel_engine_cs *engine,
return NULL;
 
spin_lock_irqsave(&engine->active.lock, flags);
-
rq = intel_engine_find_active_request(engine);
-   if (!rq) {
-   spin_unlock_irqrestore(&engine->active.lock, flags);
+   if (rq)
+   capture = intel_engine_coredump_add_request(ee, rq,
+   ATOMIC_MAYFAIL);
+   spin_unlock_irqrestore(&engine->active.lock, flags);
+   if (!capture) {
  

[Intel-gfx] [CI 1/4] drm/i915: Start chopping up the GPU error capture

2020-01-10 Thread Chris Wilson
In the near future, we will want to start a GPU error capture from a new
context, from inside the softirq region of a forced preemption. To do
so requires us to break up the monolithic error capture to provide new
entry points with finer control; in particular focusing on one
engine/gt, and being able to compose an error state from little pieces
of HW capture.

Signed-off-by: Chris Wilson 
Cc: Andi Shyti 
Acked-by: Andi Shyti 
---
 drivers/gpu/drm/i915/gt/intel_engine.h   |2 +-
 drivers/gpu/drm/i915/gt/intel_engine_cs.c|6 +-
 drivers/gpu/drm/i915/gt/intel_ggtt.c |3 +
 drivers/gpu/drm/i915/gt/intel_gtt.h  |1 +
 drivers/gpu/drm/i915/gt/intel_reset.c|2 +-
 drivers/gpu/drm/i915/gt/selftest_hangcheck.c |2 +-
 drivers/gpu/drm/i915/i915_debugfs.c  |   14 +-
 drivers/gpu/drm/i915/i915_drv.h  |2 +-
 drivers/gpu/drm/i915/i915_gpu_error.c| 1179 ++
 drivers/gpu/drm/i915/i915_gpu_error.h|  328 +++--
 drivers/gpu/drm/i915/i915_sysfs.c|6 +-
 11 files changed, 873 insertions(+), 672 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_engine.h 
b/drivers/gpu/drm/i915/gt/intel_engine.h
index 71f1bcdfc92f..5df003061e44 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine.h
+++ b/drivers/gpu/drm/i915/gt/intel_engine.h
@@ -202,7 +202,7 @@ void intel_engine_set_hwsp_writemask(struct intel_engine_cs 
*engine, u32 mask);
 u64 intel_engine_get_active_head(const struct intel_engine_cs *engine);
 u64 intel_engine_get_last_batch_head(const struct intel_engine_cs *engine);
 
-void intel_engine_get_instdone(struct intel_engine_cs *engine,
+void intel_engine_get_instdone(const struct intel_engine_cs *engine,
   struct intel_instdone *instdone);
 
 void intel_engine_init_execlists(struct intel_engine_cs *engine);
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c 
b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
index 825c94e7ca0b..f451ef376548 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
@@ -914,8 +914,8 @@ const char *i915_cache_level_str(struct drm_i915_private 
*i915, int type)
 }
 
 static u32
-read_subslice_reg(struct intel_engine_cs *engine, int slice, int subslice,
- i915_reg_t reg)
+read_subslice_reg(const struct intel_engine_cs *engine,
+ int slice, int subslice, i915_reg_t reg)
 {
struct drm_i915_private *i915 = engine->i915;
struct intel_uncore *uncore = engine->uncore;
@@ -959,7 +959,7 @@ read_subslice_reg(struct intel_engine_cs *engine, int 
slice, int subslice,
 }
 
 /* NB: please notice the memset */
-void intel_engine_get_instdone(struct intel_engine_cs *engine,
+void intel_engine_get_instdone(const struct intel_engine_cs *engine,
   struct intel_instdone *instdone)
 {
struct drm_i915_private *i915 = engine->i915;
diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c 
b/drivers/gpu/drm/i915/gt/intel_ggtt.c
index 795cd267e28e..5dba7344d7ab 100644
--- a/drivers/gpu/drm/i915/gt/intel_ggtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c
@@ -495,6 +495,7 @@ static void cleanup_init_ggtt(struct i915_ggtt *ggtt)
ggtt_release_guc_top(ggtt);
if (drm_mm_node_allocated(&ggtt->error_capture))
drm_mm_remove_node(&ggtt->error_capture);
+   mutex_destroy(&ggtt->error_mutex);
 }
 
 static int init_ggtt(struct i915_ggtt *ggtt)
@@ -526,6 +527,7 @@ static int init_ggtt(struct i915_ggtt *ggtt)
if (ret)
return ret;
 
+   mutex_init(&ggtt->error_mutex);
if (ggtt->mappable_end) {
/* Reserve a mappable slot for our lockless error capture */
ret = drm_mm_insert_node_in_range(&ggtt->vm.mm,
@@ -716,6 +718,7 @@ static void ggtt_cleanup_hw(struct i915_ggtt *ggtt)
 
if (drm_mm_node_allocated(&ggtt->error_capture))
drm_mm_remove_node(&ggtt->error_capture);
+   mutex_destroy(&ggtt->error_mutex);
 
ggtt_release_guc_top(ggtt);
intel_vgt_deballoon(ggtt);
diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.h 
b/drivers/gpu/drm/i915/gt/intel_gtt.h
index 029363cbdf49..7da7681c20b1 100644
--- a/drivers/gpu/drm/i915/gt/intel_gtt.h
+++ b/drivers/gpu/drm/i915/gt/intel_gtt.h
@@ -345,6 +345,7 @@ struct i915_ggtt {
/* Manual runtime pm autosuspend delay for user GGTT mmaps */
struct intel_wakeref_auto userfault_wakeref;
 
+   struct mutex error_mutex;
struct drm_mm_node error_capture;
struct drm_mm_node uc_fw;
 };
diff --git a/drivers/gpu/drm/i915/gt/intel_reset.c 
b/drivers/gpu/drm/i915/gt/intel_reset.c
index 76de33ae9efe..beee0cf89bce 100644
--- a/drivers/gpu/drm/i915/gt/intel_reset.c
+++ b/drivers/gpu/drm/i915/gt/intel_reset.c
@@ -1230,7 +1230,7 @@ void intel_gt_handle_error(struct intel_gt *gt,
engine_mask &= INTEL_INFO(gt->i915)->engine_mask;
 
if (flags & I915_ERROR_CAPTURE) {
-   

[Intel-gfx] [CI 2/4] drm/i915: Drop the shadow w/a batch buffer

2020-01-10 Thread Chris Wilson
While this is technically the batch as executed by the HW (in part at
least), it is confusing, and only used for a minority of gen.

Signed-off-by: Chris Wilson 
Reviewed-by: Mika Kuoppala 
Acked-by: Andi Shyti 
---
 drivers/gpu/drm/i915/i915_gpu_error.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c 
b/drivers/gpu/drm/i915/i915_gpu_error.c
index faa93c4296a7..b2b34be8eb0a 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -1428,8 +1428,6 @@ intel_engine_coredump_add_request(struct 
intel_engine_coredump *ee,
vma = capture_user(vma, rq, gfp);
vma = capture_vma(vma, rq->ring->vma, "ring", gfp);
vma = capture_vma(vma, rq->context->state, "HW context", gfp);
-   if (HAS_BROKEN_CS_TLB(rq->i915))
-   vma = capture_vma(vma, ee->engine->gt->scratch, "WA batch", 
gfp);
 
ee->cpu_ring_head = rq->ring->head;
ee->cpu_ring_tail = rq->ring->tail;
-- 
2.25.0.rc2

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


[Intel-gfx] [CI 3/4] drm/i915: Drop the shadow ring state from the error capture

2020-01-10 Thread Chris Wilson
The shadow ring regs (ring->head, ring->tail) are meaningless in the
post-mortem dump as they do not related to anything on HW. Remove them
from the coredump.

Signed-off-by: Chris Wilson 
Reviewed-by: Mika Kuoppala 
---
 drivers/gpu/drm/i915/i915_gpu_error.c | 5 -
 drivers/gpu/drm/i915/i915_gpu_error.h | 4 
 2 files changed, 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c 
b/drivers/gpu/drm/i915/i915_gpu_error.c
index b2b34be8eb0a..79eae3708602 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -553,8 +553,6 @@ static void error_print_engine(struct 
drm_i915_error_state_buf *m,
   ee->vm_info.pp_dir_base);
}
}
-   err_printf(m, "  ring->head: 0x%08x\n", ee->cpu_ring_head);
-   err_printf(m, "  ring->tail: 0x%08x\n", ee->cpu_ring_tail);
err_printf(m, "  engine reset count: %u\n", ee->reset_count);
 
for (n = 0; n < ee->num_ports; n++) {
@@ -1429,9 +1427,6 @@ intel_engine_coredump_add_request(struct 
intel_engine_coredump *ee,
vma = capture_vma(vma, rq->ring->vma, "ring", gfp);
vma = capture_vma(vma, rq->context->state, "HW context", gfp);
 
-   ee->cpu_ring_head = rq->ring->head;
-   ee->cpu_ring_tail = rq->ring->tail;
-
ee->rq_head = rq->head;
ee->rq_post = rq->postfix;
ee->rq_tail = rq->tail;
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.h 
b/drivers/gpu/drm/i915/i915_gpu_error.h
index 0df9d8c32056..8f4579d64d8c 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.h
+++ b/drivers/gpu/drm/i915/i915_gpu_error.h
@@ -66,10 +66,6 @@ struct intel_engine_coredump {
/* position of active request inside the ring */
u32 rq_head, rq_post, rq_tail;
 
-   /* our own tracking of ring head and tail */
-   u32 cpu_ring_head;
-   u32 cpu_ring_tail;
-
/* Register state */
u32 ccid;
u32 start;
-- 
2.25.0.rc2

___
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 [1/3] drm/i915/gt: Skip trying to unbind in restore_ggtt_mappings

2020-01-10 Thread Patchwork
== Series Details ==

Series: series starting with [1/3] drm/i915/gt: Skip trying to unbind in 
restore_ggtt_mappings
URL   : https://patchwork.freedesktop.org/series/71876/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_7716 -> Patchwork_16049


Summary
---

  **SUCCESS**

  No regressions found.

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

Known issues


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

### IGT changes ###

 Issues hit 

  * igt@gem_sync@basic-store-each:
- fi-tgl-y:   [PASS][1] -> [INCOMPLETE][2] ([CI#80] / [i915#472])
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7716/fi-tgl-y/igt@gem_s...@basic-store-each.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16049/fi-tgl-y/igt@gem_s...@basic-store-each.html

  * igt@i915_module_load@reload-with-fault-injection:
- fi-cfl-guc: [PASS][3] -> [DMESG-WARN][4] ([i915#889])
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7716/fi-cfl-guc/igt@i915_module_l...@reload-with-fault-injection.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16049/fi-cfl-guc/igt@i915_module_l...@reload-with-fault-injection.html
- fi-skl-6770hq:  [PASS][5] -> [DMESG-WARN][6] ([i915#889])
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7716/fi-skl-6770hq/igt@i915_module_l...@reload-with-fault-injection.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16049/fi-skl-6770hq/igt@i915_module_l...@reload-with-fault-injection.html
- fi-kbl-x1275:   [PASS][7] -> [INCOMPLETE][8] ([i915#879])
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7716/fi-kbl-x1275/igt@i915_module_l...@reload-with-fault-injection.html
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16049/fi-kbl-x1275/igt@i915_module_l...@reload-with-fault-injection.html

  * igt@i915_pm_rpm@module-reload:
- fi-cfl-guc: [PASS][9] -> [INCOMPLETE][10] ([i915#148])
   [9]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7716/fi-cfl-guc/igt@i915_pm_...@module-reload.html
   [10]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16049/fi-cfl-guc/igt@i915_pm_...@module-reload.html
- fi-skl-6770hq:  [PASS][11] -> [FAIL][12] ([i915#178])
   [11]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7716/fi-skl-6770hq/igt@i915_pm_...@module-reload.html
   [12]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16049/fi-skl-6770hq/igt@i915_pm_...@module-reload.html

  * igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u:   [PASS][13] -> [FAIL][14] ([fdo#111407])
   [13]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7716/fi-kbl-7500u/igt@kms_chamel...@hdmi-hpd-fast.html
   [14]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16049/fi-kbl-7500u/igt@kms_chamel...@hdmi-hpd-fast.html

  
 Possible fixes 

  * igt@i915_module_load@reload-with-fault-injection:
- fi-skl-6700k2:  [INCOMPLETE][15] ([i915#671]) -> [PASS][16]
   [15]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7716/fi-skl-6700k2/igt@i915_module_l...@reload-with-fault-injection.html
   [16]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16049/fi-skl-6700k2/igt@i915_module_l...@reload-with-fault-injection.html

  * igt@i915_selftest@live_blt:
- fi-bsw-nick:[DMESG-FAIL][17] ([i915#723]) -> [PASS][18]
   [17]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7716/fi-bsw-nick/igt@i915_selftest@live_blt.html
   [18]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16049/fi-bsw-nick/igt@i915_selftest@live_blt.html

  * igt@i915_selftest@live_gt_heartbeat:
- fi-bsw-n3050:   [DMESG-FAIL][19] ([i915#541]) -> [PASS][20]
   [19]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7716/fi-bsw-n3050/igt@i915_selftest@live_gt_heartbeat.html
   [20]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16049/fi-bsw-n3050/igt@i915_selftest@live_gt_heartbeat.html

  
 Warnings 

  * igt@i915_selftest@live_blt:
- fi-hsw-4770r:   [DMESG-FAIL][21] ([i915#553] / [i915#725]) -> 
[DMESG-FAIL][22] ([i915#725])
   [21]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7716/fi-hsw-4770r/igt@i915_selftest@live_blt.html
   [22]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16049/fi-hsw-4770r/igt@i915_selftest@live_blt.html

  
  [CI#80]: https://gitlab.freedesktop.org/gfx-ci/i915-infra/issues/80
  [fdo#111407]: https://bugs.freedesktop.org/show_bug.cgi?id=111407
  [i915#148]: https://gitlab.freedesktop.org/drm/intel/issues/148
  [i915#178]: https://gitlab.freedesktop.org/drm/intel/issues/178
  [i915#472]: https://gitlab.freedesktop.org/drm/intel/issues/472
  [i915#541]: https://gitlab.freedesktop.org/drm/intel/issues/541
  [i915#553]: https://gitlab.freedesktop.org/drm/intel/issues/553
  [i915#671]: https://gitlab.freedesktop.org/drm/intel/issues/671
  [i915#723]: https://gitlab.freedesktop.org/drm/intel/issu

[Intel-gfx] ✓ Fi.CI.IGT: success for Add support for mipi dsi cmd mode (rev5)

2020-01-10 Thread Patchwork
== Series Details ==

Series: Add support for mipi dsi cmd mode (rev5)
URL   : https://patchwork.freedesktop.org/series/69290/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_7712_full -> Patchwork_16037_full


Summary
---

  **SUCCESS**

  No regressions found.

  

Known issues


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

### IGT changes ###

 Issues hit 

  * igt@gem_ctx_persistence@bcs0-mixed-process:
- shard-skl:  [PASS][1] -> [FAIL][2] ([i915#679])
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7712/shard-skl4/igt@gem_ctx_persiste...@bcs0-mixed-process.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16037/shard-skl8/igt@gem_ctx_persiste...@bcs0-mixed-process.html

  * igt@gem_ctx_persistence@vcs1-queued:
- shard-iclb: [PASS][3] -> [SKIP][4] ([fdo#109276] / [fdo#112080]) 
+1 similar issue
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7712/shard-iclb1/igt@gem_ctx_persiste...@vcs1-queued.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16037/shard-iclb3/igt@gem_ctx_persiste...@vcs1-queued.html

  * igt@gem_eio@in-flight-suspend:
- shard-skl:  [PASS][5] -> [INCOMPLETE][6] ([i915#69]) +1 similar 
issue
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7712/shard-skl3/igt@gem_...@in-flight-suspend.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16037/shard-skl3/igt@gem_...@in-flight-suspend.html

  * igt@gem_exec_balancer@smoke:
- shard-iclb: [PASS][7] -> [SKIP][8] ([fdo#110854])
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7712/shard-iclb2/igt@gem_exec_balan...@smoke.html
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16037/shard-iclb8/igt@gem_exec_balan...@smoke.html
- shard-tglb: [PASS][9] -> [INCOMPLETE][10] ([fdo#111593] / 
[i915#472]) +1 similar issue
   [9]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7712/shard-tglb2/igt@gem_exec_balan...@smoke.html
   [10]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16037/shard-tglb2/igt@gem_exec_balan...@smoke.html

  * igt@gem_exec_create@forked:
- shard-kbl:  [PASS][11] -> [TIMEOUT][12] ([i915#940])
   [11]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7712/shard-kbl7/igt@gem_exec_cre...@forked.html
   [12]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16037/shard-kbl4/igt@gem_exec_cre...@forked.html

  * igt@gem_exec_parallel@basic:
- shard-tglb: [PASS][13] -> [INCOMPLETE][14] ([i915#472] / 
[i915#476])
   [13]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7712/shard-tglb1/igt@gem_exec_paral...@basic.html
   [14]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16037/shard-tglb9/igt@gem_exec_paral...@basic.html

  * igt@gem_exec_parallel@vcs1-fds:
- shard-iclb: [PASS][15] -> [SKIP][16] ([fdo#112080]) +11 similar 
issues
   [15]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7712/shard-iclb1/igt@gem_exec_paral...@vcs1-fds.html
   [16]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16037/shard-iclb8/igt@gem_exec_paral...@vcs1-fds.html

  * igt@gem_exec_schedule@in-order-bsd:
- shard-iclb: [PASS][17] -> [SKIP][18] ([fdo#112146]) +3 similar 
issues
   [17]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7712/shard-iclb3/igt@gem_exec_sched...@in-order-bsd.html
   [18]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16037/shard-iclb4/igt@gem_exec_sched...@in-order-bsd.html

  * igt@gem_exec_schedule@pi-common-bsd1:
- shard-iclb: [PASS][19] -> [SKIP][20] ([fdo#109276]) +19 similar 
issues
   [19]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7712/shard-iclb2/igt@gem_exec_sched...@pi-common-bsd1.html
   [20]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16037/shard-iclb7/igt@gem_exec_sched...@pi-common-bsd1.html

  * igt@gem_exec_schedule@pi-distinct-iova-bsd:
- shard-iclb: [PASS][21] -> [SKIP][22] ([i915#677])
   [21]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7712/shard-iclb6/igt@gem_exec_sched...@pi-distinct-iova-bsd.html
   [22]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16037/shard-iclb4/igt@gem_exec_sched...@pi-distinct-iova-bsd.html

  * igt@gem_exec_schedule@preempt-queue-chain-blt:
- shard-tglb: [PASS][23] -> [INCOMPLETE][24] ([fdo#111606] / 
[fdo#111677] / [i915#472])
   [23]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7712/shard-tglb3/igt@gem_exec_sched...@preempt-queue-chain-blt.html
   [24]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16037/shard-tglb6/igt@gem_exec_sched...@preempt-queue-chain-blt.html

  * igt@gem_exec_schedule@preempt-queue-contexts-chain-render:
- shard-tglb: [PASS][25] -> [INCOMPLETE][26] ([fdo#111677] / 
[i915#472])
   [25]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7712/shard-tglb2/igt@gem_exec_sched...@preempt-queue-contexts-chain-render.html
   [26]

[Intel-gfx] [RFC 1/8] drm/i915: Expose list of clients in sysfs

2020-01-10 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Expose a list of clients with open file handles in sysfs.

This will be a basis for a top-like utility showing per-client and per-
engine GPU load.

Currently we only expose each client's pid and name under opaque numbered
directories in /sys/class/drm/card0/clients/.

For instance:

/sys/class/drm/card0/clients/3/name: Xorg
/sys/class/drm/card0/clients/3/pid: 5664

v2:
 Chris Wilson:
 * Enclose new members into dedicated structs.
 * Protect against failed sysfs registration.

v3:
 * sysfs_attr_init.

v4:
 * Fix for internal clients.

v5:
 * Use cyclic ida for client id. (Chris)
 * Do not leak pid reference. (Chris)
 * Tidy code with some locals.

v6:
 * Use xa_alloc_cyclic to simplify locking. (Chris)
 * No need to unregister individial sysfs files. (Chris)
 * Rebase on top of fpriv kref.
 * Track client closed status and reflect in sysfs.

v7:
 * Make drm_client more standalone concept.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/Makefile  |   3 +-
 drivers/gpu/drm/i915/i915_drm_client.c | 150 +
 drivers/gpu/drm/i915/i915_drm_client.h |  61 ++
 drivers/gpu/drm/i915/i915_drv.h|   5 +
 drivers/gpu/drm/i915/i915_gem.c|  35 --
 drivers/gpu/drm/i915/i915_sysfs.c  |   8 ++
 6 files changed, 254 insertions(+), 8 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/i915_drm_client.c
 create mode 100644 drivers/gpu/drm/i915/i915_drm_client.h

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index b8c5f8934dbd..3a677a20a709 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -36,7 +36,8 @@ subdir-ccflags-y += -I$(srctree)/$(src)
 # Please keep these build lists sorted!
 
 # core driver code
-i915-y += i915_drv.o \
+i915-y += i915_drm_client.o \
+ i915_drv.o \
  i915_irq.o \
  i915_getparam.o \
  i915_params.o \
diff --git a/drivers/gpu/drm/i915/i915_drm_client.c 
b/drivers/gpu/drm/i915/i915_drm_client.c
new file mode 100644
index ..02356f48d85b
--- /dev/null
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -0,0 +1,150 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright © 2020 Intel Corporation
+ */
+
+#include 
+#include 
+#include 
+
+#include "i915_drm_client.h"
+#include "i915_gem.h"
+#include "i915_utils.h"
+
+static ssize_t
+show_client_name(struct device *kdev, struct device_attribute *attr, char *buf)
+{
+   struct i915_drm_client *client =
+   container_of(attr, typeof(*client), attr.name);
+
+   return snprintf(buf, PAGE_SIZE, "%s%s%s",
+   client->closed ? "<" : "",
+   client->name,
+   client->closed ? ">" : "");
+}
+
+static ssize_t
+show_client_pid(struct device *kdev, struct device_attribute *attr, char *buf)
+{
+   struct i915_drm_client *client =
+   container_of(attr, typeof(*client), attr.pid);
+
+   return snprintf(buf, PAGE_SIZE, "%s%u%s",
+   client->closed ? "<" : "",
+   pid_nr(client->pid),
+   client->closed ? ">" : "");
+}
+
+static int
+__i915_drm_client_register(struct i915_drm_client *client,
+  struct task_struct *task)
+{
+   struct i915_drm_clients *clients = client->clients;
+   struct device_attribute *attr;
+   int ret = -ENOMEM;
+   char idstr[32];
+
+   if (!clients->root)
+   return 0; /* intel_fbdev_init registers a client before sysfs */
+
+   client->name = kstrdup(task->comm, GFP_KERNEL);
+   if (!client->name)
+   goto err_name;
+
+   snprintf(idstr, sizeof(idstr), "%u", client->id);
+   client->root = kobject_create_and_add(idstr, clients->root);
+   if (!client->root)
+   goto err_client;
+
+   attr = &client->attr.name;
+   sysfs_attr_init(&attr->attr);
+   attr->attr.name = "name";
+   attr->attr.mode = 0444;
+   attr->show = show_client_name;
+
+   ret = sysfs_create_file(client->root, (struct attribute *)attr);
+   if (ret)
+   goto err_attr;
+
+   attr = &client->attr.pid;
+   sysfs_attr_init(&attr->attr);
+   attr->attr.name = "pid";
+   attr->attr.mode = 0444;
+   attr->show = show_client_pid;
+
+   ret = sysfs_create_file(client->root, (struct attribute *)attr);
+   if (ret)
+   goto err_attr;
+
+   client->pid = get_task_pid(task, PIDTYPE_PID);
+
+   return 0;
+
+err_attr:
+   kobject_put(client->root);
+err_client:
+   kfree(client->name);
+err_name:
+   return ret;
+}
+
+static void __i915_drm_client_unregister(struct i915_drm_client *client)
+{
+   if (!client->name)
+   return; /* fbdev client or error during drm open */
+
+   kobject_put(fetch_and_zero(&client->root));
+   put_pid(fetch_and_zero(&client->pid));
+   kfree(fetch_and_zero(&client->name));
+}
+
+struct i915_d

[Intel-gfx] [RFC 8/8] drm/i915: Fallback to hw context runtime when sw tracking is not available

2020-01-10 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

In GuC mode we are not receiving the context switch interrupts to be able
to accurately track context runtimes.

We can fallback to using PPHWSP counter updated by the GPU on context save.

QQQ
Downsides are: 1) we do not see currently executing batch and 2) with a
12MHz command streamer timestamp timer frequency the 32-bit counter wraps
every ~358 seconds. This makes endless OpenCL batches with hearbeats
turned off also a problem.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_drm_client.c | 34 --
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drm_client.c 
b/drivers/gpu/drm/i915/i915_drm_client.c
index 55b2f86cc4c1..0b84ae528dcc 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.c
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -58,6 +58,24 @@ sw_busy_add(struct i915_gem_context *ctx, unsigned int 
engine_class)
return total;
 }
 
+static u64
+hw_busy_add(struct i915_gem_context *ctx, unsigned int engine_class)
+{
+   struct i915_gem_engines *engines = rcu_dereference(ctx->engines);
+   struct i915_gem_engines_iter it;
+   struct intel_context *ce;
+   u64 total = 0;
+
+   for_each_gem_engine(ce, engines, it) {
+   if (ce->engine->uabi_class != engine_class)
+   continue;
+
+   total += intel_context_get_hw_runtime_ns(ce);
+   }
+
+   return total;
+}
+
 static ssize_t
 show_client_busy(struct device *kdev, struct device_attribute *attr, char *buf)
 {
@@ -68,12 +86,14 @@ show_client_busy(struct device *kdev, struct 
device_attribute *attr, char *buf)
struct i915_gem_context *ctx;
u64 total = 0;
 
-   if (i915_attr->no_busy_stats)
-   return -ENODEV;
-
rcu_read_lock();
-   list_for_each_entry_rcu(ctx, list, client_link)
-   total += sw_busy_add(ctx, engine_class);
+   if (i915_attr->no_busy_stats) {
+   list_for_each_entry_rcu(ctx, list, client_link)
+   total += hw_busy_add(ctx, engine_class);
+   } else {
+   list_for_each_entry_rcu(ctx, list, client_link)
+   total += sw_busy_add(ctx, engine_class);
+   }
rcu_read_unlock();
 
return snprintf(buf, PAGE_SIZE, "%llu\n", total);
@@ -164,7 +184,7 @@ __i915_drm_client_register(struct i915_drm_client *client,
if (ret) {
int j, k;
 
-   /* Unwind if not available. */
+   /* Unwind and fallback if not available. */
j = 0;
for_each_uabi_engine(engine, i915) {
if (j++ == i)
@@ -181,7 +201,7 @@ __i915_drm_client_register(struct i915_drm_client *client,
}
 
dev_notice_once(i915->drm.dev,
-   "Engine busy stats not 
available! (%d)",
+   "Reduced accuracy context 
runtime mode (%d)",
ret);
break;
}
-- 
2.20.1

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


[Intel-gfx] [RFC 0/8] Per client engine busyness

2020-01-10 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Another re-spin of the per-client engine busyness series. Highlights from this
version:

 * Two patches added on top of the series to provide the data in GuC mode.
   (For warnings and limitations please read the respective commit messages.)
 * Refactor to introduce a notion of i915_drm_client and move to separate source
   file.

Internally we track time spent on engines for each struct intel_context. This
can serve as a building block for several features from the want list:
smarter scheduler decisions, getrusage(2)-like per-GEM-context functionality
wanted by some customers, cgroups controller, dynamic SSEU tuning,...

Externally, in sysfs, we expose time spent on GPU per client and per engine
class.

Sysfs interface enables us to implement a "top-like" tool for GPU tasks. Or with
a "screenshot":

intel-gpu-top -  906/ 955 MHz;0% RC6;  5.30 Watts;  933 irqs/s

  IMC reads: 4414 MiB/s
 IMC writes: 3805 MiB/s

  ENGINE  BUSY  MI_SEMA MI_WAIT
 Render/3D/0   93.46% |▋  |  0%  0%
   Blitter/00.00% |   |  0%  0%
 Video/00.00% |   |  0%  0%
  VideoEnhance/00.00% |   |  0%  0%

  PIDNAME  Render/3D  BlitterVideo  VideoEnhance
 2733   neverball |██▌ |||||||
 2047Xorg |███▊|||||||
 2737glxgears |█▍  |||||||
 2128   xfwm4 ||||||||
 2047Xorg ||||||||


Implementation wise we add a a bunch of files in sysfs like:

# cd /sys/class/drm/card0/clients/
# tree
.
├── 7
│   ├── busy
│   │   ├── 0
│   │   ├── 1
│   │   ├── 2
│   │   └── 3
│   ├── name
│   └── pid
├── 8
│   ├── busy
│   │   ├── 0
│   │   ├── 1
│   │   ├── 2
│   │   └── 3
│   ├── name
│   └── pid
└── 9
├── busy
│   ├── 0
│   ├── 1
│   ├── 2
│   └── 3
├── name
└── pid


Files in 'busy' directories are numbered using the engine class ABI values and
they contain accumulated nanoseconds each client spent on engines of a
respective class.

Tvrtko Ursulin (8):
  drm/i915: Expose list of clients in sysfs
  drm/i915: Update client name on context create
  drm/i915: Track per-context engine busyness
  drm/i915: Track all user contexts per client
  drm/i915: Contexts can use struct pid stored in the client
  drm/i915: Expose per-engine client busyness
  drm/i915: Track hw reported context runtime
  drm/i915: Fallback to hw context runtime when sw tracking is not
available

 drivers/gpu/drm/i915/Makefile |   3 +-
 drivers/gpu/drm/i915/gem/i915_gem_context.c   |  60 +++-
 .../gpu/drm/i915/gem/i915_gem_context_types.h |  16 +-
 drivers/gpu/drm/i915/gt/intel_context.c   |  20 ++
 drivers/gpu/drm/i915/gt/intel_context.h   |  18 ++
 drivers/gpu/drm/i915/gt/intel_context_types.h |  14 +
 drivers/gpu/drm/i915/gt/intel_engine_cs.c |  16 +-
 drivers/gpu/drm/i915/gt/intel_lrc.c   |  55 +++-
 drivers/gpu/drm/i915/i915_debugfs.c   |   7 +-
 drivers/gpu/drm/i915/i915_drm_client.c| 298 ++
 drivers/gpu/drm/i915/i915_drm_client.h|  83 +
 drivers/gpu/drm/i915/i915_drv.h   |   5 +
 drivers/gpu/drm/i915/i915_gem.c   |  35 +-
 drivers/gpu/drm/i915/i915_gpu_error.c |   8 +-
 drivers/gpu/drm/i915/i915_sysfs.c |   8 +
 drivers/gpu/drm/i915/intel_device_info.c  |   2 +
 drivers/gpu/drm/i915/intel_device_info.h  |   1 +
 17 files changed, 606 insertions(+), 43 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/i915_drm_client.c
 create mode 100644 drivers/gpu/drm/i915/i915_drm_client.h

-- 
2.20.1

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


[Intel-gfx] [RFC 5/8] drm/i915: Contexts can use struct pid stored in the client

2020-01-10 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Now that contexts keep their parent client reference counted, we can
remove separate struct pid reference owned by contexts in favour of the
one already held by the client.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c   | 13 -
 drivers/gpu/drm/i915/gem/i915_gem_context_types.h | 10 --
 drivers/gpu/drm/i915/i915_debugfs.c   |  7 ---
 drivers/gpu/drm/i915/i915_gpu_error.c |  8 
 4 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c 
b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index ba8ccc754f20..758cebb99ba4 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -323,7 +323,6 @@ static void i915_gem_context_free(struct i915_gem_context 
*ctx)
if (ctx->timeline)
intel_timeline_put(ctx->timeline);
 
-   put_pid(ctx->pid);
mutex_destroy(&ctx->mutex);
 
kfree_rcu(ctx, rcu);
@@ -794,24 +793,20 @@ static int gem_context_register(struct i915_gem_context 
*ctx,
WRITE_ONCE(vm->file, fpriv); /* XXX */
mutex_unlock(&ctx->mutex);
 
-   ctx->pid = get_task_pid(current, PIDTYPE_PID);
snprintf(ctx->name, sizeof(ctx->name), "%s[%d]",
-current->comm, pid_nr(ctx->pid));
+current->comm, pid_nr(client->pid));
 
/* And finally expose ourselves to userspace via the idr */
ret = xa_alloc(&fpriv->context_xa, id, ctx, xa_limit_32b, GFP_KERNEL);
-   if (ret) {
-   put_pid(fetch_and_zero(&ctx->pid));
-   goto out;
-   }
+   if (ret)
+   return ret;
 
ctx->client = client = i915_drm_client_get(fpriv->client);
spin_lock(&client->ctx_lock);
list_add_tail_rcu(&ctx->client_link, &client->ctx_list);
spin_unlock(&client->ctx_lock);
 
-out:
-   return ret;
+   return 0;
 }
 
 int i915_gem_context_open(struct drm_i915_private *i915,
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h 
b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
index 879824159646..23421377a43d 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
@@ -90,16 +90,6 @@ struct i915_gem_context {
 */
struct i915_address_space __rcu *vm;
 
-   /**
-* @pid: process id of creator
-*
-* Note that who created the context may not be the principle user,
-* as the context may be shared across a local socket. However,
-* that should only affect the default context, all contexts created
-* explicitly by the client are expected to be isolated.
-*/
-   struct pid *pid;
-
/** link: place with &drm_i915_private.context_list */
struct list_head link;
struct llist_node free_link;
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 8f01c2bc7355..bc533501b4e0 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -346,7 +346,8 @@ static void print_context_stats(struct seq_file *m,
rcu_read_unlock();
 
rcu_read_lock();
-   task = pid_task(ctx->pid ?: file->pid, PIDTYPE_PID);
+   task = pid_task(ctx->client->pid ?: file->pid,
+   PIDTYPE_PID);
snprintf(name, sizeof(name), "%s",
 task ? task->comm : "");
rcu_read_unlock();
@@ -1492,10 +1493,10 @@ static int i915_context_status(struct seq_file *m, void 
*unused)
spin_unlock(&i915->gem.contexts.lock);
 
seq_puts(m, "HW context ");
-   if (ctx->pid) {
+   if (ctx->client->pid) {
struct task_struct *task;
 
-   task = get_pid_task(ctx->pid, PIDTYPE_PID);
+   task = get_pid_task(ctx->client->pid, PIDTYPE_PID);
if (task) {
seq_printf(m, "(%s [%d]) ",
   task->comm, task->pid);
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c 
b/drivers/gpu/drm/i915/i915_gpu_error.c
index fda0977d2059..9240327bdb7d 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -1235,8 +1235,8 @@ static void record_request(const struct i915_request 
*request,
erq->pid = 0;
rcu_read_lock();
ctx = rcu_dereference(request->context->gem_context);
-   if (ctx)
-   erq->pid = pid_nr(ctx->pid);
+   if (ctx && ctx->client->pid)
+   erq->pid = pid_nr(ctx->client->pid);
rcu_read_unlock();
 }
 
@@ -1313,11 +1313,11 @@ static bool record_context(struct 
drm_i915_error_context 

[Intel-gfx] [RFC 7/8] drm/i915: Track hw reported context runtime

2020-01-10 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

GPU saves accumulated context runtime (in CS timestamp units) in PPHWSP
which will be useful for us in cases when we are not able to track context
busyness ourselves (like with GuC). Keep a copy of this in struct
intel_context from where it can be easily read even if the context is not
pinned.

QQQ: Do we want to make this accounting conditional / able to turn on/off?

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/gt/intel_context.h   | 7 +++
 drivers/gpu/drm/i915/gt/intel_context_types.h | 5 +
 drivers/gpu/drm/i915/gt/intel_lrc.c   | 9 +
 drivers/gpu/drm/i915/intel_device_info.c  | 2 ++
 drivers/gpu/drm/i915/intel_device_info.h  | 1 +
 5 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.h 
b/drivers/gpu/drm/i915/gt/intel_context.h
index 30f0268fcc9a..389a05736fc7 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.h
+++ b/drivers/gpu/drm/i915/gt/intel_context.h
@@ -12,6 +12,7 @@
 #include 
 
 #include "i915_active.h"
+#include "i915_drv.h"
 #include "intel_context_types.h"
 #include "intel_engine_types.h"
 #include "intel_ring_types.h"
@@ -235,4 +236,10 @@ __intel_context_stats_start(struct intel_context_stats 
*stats, ktime_t now)
 
 ktime_t intel_context_get_busy_time(struct intel_context *ce);
 
+static inline u64 intel_context_get_hw_runtime_ns(struct intel_context *ce)
+{
+   return ce->total_runtime *
+  RUNTIME_INFO(ce->engine->i915)->cs_timestamp_period_ns;
+}
+
 #endif /* __INTEL_CONTEXT_H__ */
diff --git a/drivers/gpu/drm/i915/gt/intel_context_types.h 
b/drivers/gpu/drm/i915/gt/intel_context_types.h
index 963d33dc5289..7b08bf87fb82 100644
--- a/drivers/gpu/drm/i915/gt/intel_context_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_context_types.h
@@ -69,6 +69,11 @@ struct intel_context {
u64 lrc_desc;
u32 tag; /* cookie passed to HW to track this context on submission */
 
+   /* Time on GPU as tracked by the hw. */
+   u32 last_runtime;
+   u64 total_runtime;
+   u32 *pphwsp;
+
unsigned int active_count; /* protected by timeline->mutex */
 
atomic_t pin_count;
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c 
b/drivers/gpu/drm/i915/gt/intel_lrc.c
index dd559547500f..26999b43e5a1 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.c
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
@@ -1289,6 +1289,7 @@ __execlists_schedule_out(struct i915_request *rq,
 struct intel_engine_cs * const engine)
 {
struct intel_context *ce = rq->context;
+   u32 old, new;
 
/*
 * NB process_csb() is not under the engine->active.lock and hence
@@ -1309,6 +1310,13 @@ __execlists_schedule_out(struct i915_request *rq,
execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_OUT);
intel_gt_pm_put_async(engine->gt);
 
+   old = ce->last_runtime;
+   ce->last_runtime = new = ce->pphwsp[16];
+   if (new > old)
+   ce->total_runtime += new - old;
+   else
+   ce->total_runtime += (~0UL - old) + new + 1;
+
/*
 * If this is part of a virtual engine, its next request may
 * have been blocked waiting for access to the active context.
@@ -2608,6 +2616,7 @@ __execlists_context_pin(struct intel_context *ce,
 
ce->lrc_desc = lrc_descriptor(ce, engine) | CTX_DESC_FORCE_RESTORE;
ce->lrc_reg_state = vaddr + LRC_STATE_PN * PAGE_SIZE;
+   ce->pphwsp = vaddr + LRC_PPHWSP_PN * PAGE_SIZE;
__execlists_update_reg_state(ce, engine);
 
return 0;
diff --git a/drivers/gpu/drm/i915/intel_device_info.c 
b/drivers/gpu/drm/i915/intel_device_info.c
index 6670a0763be2..7732748e1939 100644
--- a/drivers/gpu/drm/i915/intel_device_info.c
+++ b/drivers/gpu/drm/i915/intel_device_info.c
@@ -1042,6 +1042,8 @@ void intel_device_info_runtime_init(struct 
drm_i915_private *dev_priv)
 
/* Initialize command stream timestamp frequency */
runtime->cs_timestamp_frequency_khz = 
read_timestamp_frequency(dev_priv);
+   runtime->cs_timestamp_period_ns =
+   div_u64(1e6, runtime->cs_timestamp_frequency_khz);
 }
 
 void intel_driver_caps_print(const struct intel_driver_caps *caps,
diff --git a/drivers/gpu/drm/i915/intel_device_info.h 
b/drivers/gpu/drm/i915/intel_device_info.h
index 2725cb7fc169..9ec816dbc418 100644
--- a/drivers/gpu/drm/i915/intel_device_info.h
+++ b/drivers/gpu/drm/i915/intel_device_info.h
@@ -216,6 +216,7 @@ struct intel_runtime_info {
struct sseu_dev_info sseu;
 
u32 cs_timestamp_frequency_khz;
+   u32 cs_timestamp_period_ns;
 
/* Media engine access to SFC per instance */
u8 vdbox_sfc_access;
-- 
2.20.1

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


[Intel-gfx] [RFC 4/8] drm/i915: Track all user contexts per client

2020-01-10 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

We soon want to start answering questions like how much GPU time is the
context belonging to a client which exited still using.

To enable this we start tracking all context belonging to a client on a
separate list, plus we make contexts take a reference on their clients
file_priv.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c   | 21 ++-
 .../gpu/drm/i915/gem/i915_gem_context_types.h |  6 ++
 drivers/gpu/drm/i915/i915_drm_client.c|  3 +++
 drivers/gpu/drm/i915/i915_drm_client.h|  5 +
 4 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c 
b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index ba3c29a01535..ba8ccc754f20 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -301,8 +301,18 @@ static struct i915_gem_engines *default_engines(struct 
i915_gem_context *ctx)
 
 static void i915_gem_context_free(struct i915_gem_context *ctx)
 {
+   struct i915_drm_client *client = ctx->client;
+
GEM_BUG_ON(!i915_gem_context_is_closed(ctx));
 
+   if (client) {
+   spin_lock(&client->ctx_lock);
+   list_del_rcu(&ctx->client_link);
+   spin_unlock(&client->ctx_lock);
+
+   i915_drm_client_put(client);
+   }
+
spin_lock(&ctx->i915->gem.contexts.lock);
list_del(&ctx->link);
spin_unlock(&ctx->i915->gem.contexts.lock);
@@ -772,6 +782,7 @@ static int gem_context_register(struct i915_gem_context 
*ctx,
struct drm_i915_file_private *fpriv,
u32 *id)
 {
+   struct i915_drm_client *client;
struct i915_address_space *vm;
int ret;
 
@@ -789,9 +800,17 @@ static int gem_context_register(struct i915_gem_context 
*ctx,
 
/* And finally expose ourselves to userspace via the idr */
ret = xa_alloc(&fpriv->context_xa, id, ctx, xa_limit_32b, GFP_KERNEL);
-   if (ret)
+   if (ret) {
put_pid(fetch_and_zero(&ctx->pid));
+   goto out;
+   }
 
+   ctx->client = client = i915_drm_client_get(fpriv->client);
+   spin_lock(&client->ctx_lock);
+   list_add_tail_rcu(&ctx->client_link, &client->ctx_list);
+   spin_unlock(&client->ctx_lock);
+
+out:
return ret;
 }
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h 
b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
index 017ca803ab47..879824159646 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
@@ -104,6 +104,12 @@ struct i915_gem_context {
struct list_head link;
struct llist_node free_link;
 
+   /** client: struct i915_drm_client */
+   struct i915_drm_client *client;
+
+   /** link: &fpriv.context_list */
+   struct list_head client_link;
+
/**
 * @ref: reference count
 *
diff --git a/drivers/gpu/drm/i915/i915_drm_client.c 
b/drivers/gpu/drm/i915/i915_drm_client.c
index 666ec67c77e9..195777b95891 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.c
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -111,6 +111,9 @@ i915_drm_client_add(struct i915_drm_clients *clients, 
struct task_struct *task)
return ERR_PTR(-ENOMEM);
 
kref_init(&client->kref);
+   spin_lock_init(&client->ctx_lock);
+   INIT_LIST_HEAD(&client->ctx_list);
+
client->clients = clients;
 
ret = xa_alloc_cyclic(&clients->xarray, &client->id, client,
diff --git a/drivers/gpu/drm/i915/i915_drm_client.h 
b/drivers/gpu/drm/i915/i915_drm_client.h
index 2c692345bc4e..16d8db075a7d 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.h
+++ b/drivers/gpu/drm/i915/i915_drm_client.h
@@ -10,9 +10,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 struct i915_drm_clients {
@@ -30,6 +32,9 @@ struct i915_drm_client {
char *name;
bool closed;
 
+   spinlock_t ctx_lock;
+   struct list_head ctx_list;
+
struct i915_drm_clients *clients;
 
struct kobject *root;
-- 
2.20.1

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


[Intel-gfx] [RFC 2/8] drm/i915: Update client name on context create

2020-01-10 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Some clients have the DRM fd passed to them over a socket by the X server.

Grab the real client and pid when they create their first context and
update the exposed data for more useful enumeration.

v2:
 * Do not leak the pid reference and borrow context idr_lock. (Chris)

v3:
 * More avoiding leaks. (Chris)

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 36 ++---
 drivers/gpu/drm/i915/i915_drm_client.c  |  4 +--
 drivers/gpu/drm/i915/i915_drm_client.h  |  4 +++
 3 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c 
b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index a2e57e62af30..ba3c29a01535 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -77,6 +77,7 @@
 #include "gt/intel_lrc_reg.h"
 #include "gt/intel_ring.h"
 
+#include "i915_drm_client.h"
 #include "i915_gem_context.h"
 #include "i915_globals.h"
 #include "i915_trace.h"
@@ -2181,7 +2182,10 @@ int i915_gem_context_create_ioctl(struct drm_device 
*dev, void *data,
 {
struct drm_i915_private *i915 = to_i915(dev);
struct drm_i915_gem_context_create_ext *args = data;
+   struct drm_i915_file_private *file_priv = file->driver_priv;
+   struct i915_drm_client *client = file_priv->client;
struct create_ext ext_data;
+   struct pid *pid;
int ret;
u32 id;
 
@@ -2195,16 +2199,35 @@ int i915_gem_context_create_ioctl(struct drm_device 
*dev, void *data,
if (ret)
return ret;
 
-   ext_data.fpriv = file->driver_priv;
+   pid = get_task_pid(current, PIDTYPE_PID);
+
+   ext_data.fpriv = file_priv;
if (client_is_banned(ext_data.fpriv)) {
DRM_DEBUG("client %s[%d] banned from creating ctx\n",
- current->comm, task_pid_nr(current));
-   return -EIO;
+ current->comm, pid_nr(pid));
+   ret = -EIO;
+   goto err_pid;
+   }
+
+   /*
+* Borrow struct_mutex to protect the client remove-add cycle.
+*/
+   ret = mutex_lock_interruptible(&dev->struct_mutex);
+   if (ret)
+   goto err_pid;
+   if (client->pid != pid) {
+   __i915_drm_client_unregister(client);
+   ret = __i915_drm_client_register(client, current);
}
+   mutex_unlock(&dev->struct_mutex);
+   if (ret)
+   goto err_pid;
 
ext_data.ctx = i915_gem_create_context(i915, args->flags);
-   if (IS_ERR(ext_data.ctx))
-   return PTR_ERR(ext_data.ctx);
+   if (IS_ERR(ext_data.ctx)) {
+   ret = PTR_ERR(ext_data.ctx);
+   goto err_pid;
+   }
 
if (args->flags & I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS) {
ret = i915_user_extensions(u64_to_user_ptr(args->extensions),
@@ -2226,6 +2249,9 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, 
void *data,
 
 err_ctx:
context_close(ext_data.ctx);
+err_pid:
+   put_pid(pid);
+
return ret;
 }
 
diff --git a/drivers/gpu/drm/i915/i915_drm_client.c 
b/drivers/gpu/drm/i915/i915_drm_client.c
index 02356f48d85b..666ec67c77e9 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.c
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -36,7 +36,7 @@ show_client_pid(struct device *kdev, struct device_attribute 
*attr, char *buf)
client->closed ? ">" : "");
 }
 
-static int
+int
 __i915_drm_client_register(struct i915_drm_client *client,
   struct task_struct *task)
 {
@@ -89,7 +89,7 @@ __i915_drm_client_register(struct i915_drm_client *client,
return ret;
 }
 
-static void __i915_drm_client_unregister(struct i915_drm_client *client)
+void __i915_drm_client_unregister(struct i915_drm_client *client)
 {
if (!client->name)
return; /* fbdev client or error during drm open */
diff --git a/drivers/gpu/drm/i915/i915_drm_client.h 
b/drivers/gpu/drm/i915/i915_drm_client.h
index 8b261dc4a1f3..2c692345bc4e 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.h
+++ b/drivers/gpu/drm/i915/i915_drm_client.h
@@ -58,4 +58,8 @@ void i915_drm_client_close(struct i915_drm_client *client);
 struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients,
struct task_struct *task);
 
+int __i915_drm_client_register(struct i915_drm_client *client,
+  struct task_struct *task);
+void __i915_drm_client_unregister(struct i915_drm_client *client);
+
 #endif /* !__I915_DRM_CLIENT_H__ */
-- 
2.20.1

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


[Intel-gfx] [RFC 6/8] drm/i915: Expose per-engine client busyness

2020-01-10 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Expose per-client and per-engine busyness under the previously added sysfs
client root.

The new files are one per-engine instance and located under the 'busy'
directory. Each contains a monotonically increasing nano-second resolution
times each client's jobs were executing on the GPU.

This enables userspace to create a top-like tool for GPU utilization:

==
intel-gpu-top -  935/ 935 MHz;0% RC6; 14.73 Watts; 1097 irqs/s

  IMC reads: 1401 MiB/s
 IMC writes:4 MiB/s

  ENGINE  BUSY MI_SEMA MI_WAIT
 Render/3D/0   63.73% |███   |  3%  0%
   Blitter/09.53% |██▊   |  6%  0%
 Video/0   39.32% |███▊  | 16%  0%
 Video/1   15.62% |▋ |  0%  0%
  VideoEnhance/00.00% |  |  0%  0%

  PIDNAME RCS  BCS  VCS VECS
 4084gem_wsim |█▌ ||█  ||   ||   |
 4086gem_wsim |█▌ ||   ||███||   |
==

v2: Use intel_context_engine_get_busy_time.
v3: New directory structure.
v4: Rebase.
v5: sysfs_attr_init.
v6: Small tidy in i915_gem_add_client.
v7: Rebase to be engine class based.
v8:
 * Always enable stats.
 * Walk all client contexts.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_drm_client.c | 127 -
 drivers/gpu/drm/i915/i915_drm_client.h |  13 +++
 2 files changed, 139 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_drm_client.c 
b/drivers/gpu/drm/i915/i915_drm_client.c
index 195777b95891..55b2f86cc4c1 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.c
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -8,7 +8,11 @@
 #include 
 #include 
 
+#include 
+
 #include "i915_drm_client.h"
+#include "gem/i915_gem_context.h"
+#include "i915_drv.h"
 #include "i915_gem.h"
 #include "i915_utils.h"
 
@@ -36,13 +40,62 @@ show_client_pid(struct device *kdev, struct 
device_attribute *attr, char *buf)
client->closed ? ">" : "");
 }
 
+static u64
+sw_busy_add(struct i915_gem_context *ctx, unsigned int engine_class)
+{
+   struct i915_gem_engines *engines = rcu_dereference(ctx->engines);
+   struct i915_gem_engines_iter it;
+   struct intel_context *ce;
+   u64 total = 0;
+
+   for_each_gem_engine(ce, engines, it) {
+   if (ce->engine->uabi_class != engine_class)
+   continue;
+
+   total += ktime_to_ns(intel_context_get_busy_time(ce));
+   }
+
+   return total;
+}
+
+static ssize_t
+show_client_busy(struct device *kdev, struct device_attribute *attr, char *buf)
+{
+   struct i915_engine_busy_attribute *i915_attr =
+   container_of(attr, typeof(*i915_attr), attr);
+   struct list_head *list = &i915_attr->client->ctx_list;
+   unsigned int engine_class = i915_attr->engine_class;
+   struct i915_gem_context *ctx;
+   u64 total = 0;
+
+   if (i915_attr->no_busy_stats)
+   return -ENODEV;
+
+   rcu_read_lock();
+   list_for_each_entry_rcu(ctx, list, client_link)
+   total += sw_busy_add(ctx, engine_class);
+   rcu_read_unlock();
+
+   return snprintf(buf, PAGE_SIZE, "%llu\n", total);
+}
+
+static const char *uabi_class_names[] = {
+   [I915_ENGINE_CLASS_RENDER] = "0",
+   [I915_ENGINE_CLASS_COPY] = "1",
+   [I915_ENGINE_CLASS_VIDEO] = "2",
+   [I915_ENGINE_CLASS_VIDEO_ENHANCE] = "3",
+};
+
 int
 __i915_drm_client_register(struct i915_drm_client *client,
   struct task_struct *task)
 {
struct i915_drm_clients *clients = client->clients;
+   struct drm_i915_private *i915 =
+   container_of(clients, typeof(*i915), clients);
+   struct intel_engine_cs *engine;
struct device_attribute *attr;
-   int ret = -ENOMEM;
+   int i, ret = -ENOMEM;
char idstr[32];
 
if (!clients->root)
@@ -77,10 +130,71 @@ __i915_drm_client_register(struct i915_drm_client *client,
if (ret)
goto err_attr;
 
+   if (HAS_LOGICAL_RING_CONTEXTS(i915)) {
+   client->busy_root =
+   kobject_create_and_add("busy", client->root);
+   if (!client->busy_root)
+   goto err_attr;
+
+   for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++) {
+   struct i915_engine_busy_attribute *i915_attr =
+   &client->attr.busy[i];
+
+   i915_attr->client = client;
+   i915_attr->engine_class = i;
+
+   attr = &i915_attr->attr;
+
+

[Intel-gfx] [RFC 3/8] drm/i915: Track per-context engine busyness

2020-01-10 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Some customers want to know how much of the GPU time are their clients
using in order to make dynamic load balancing decisions.

With the hooks already in place which track the overall engine busyness,
we can extend that slightly to split that time between contexts.

v2: Fix accounting for tail updates.
v3: Rebase.
v4: Mark currently running contexts as active on stats enable.
v5: Include some headers to fix the build.
v6: Added fine grained lock.
v7: Convert to seqlock. (Chris Wilson)
v8: Rebase and tidy with helpers.
v9: Refactor.
v10: Move recording start to promotion. (Chris)
v11: Consolidate duplicated code. (Chris)

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/gt/intel_context.c   | 20 
 drivers/gpu/drm/i915/gt/intel_context.h   | 11 +
 drivers/gpu/drm/i915/gt/intel_context_types.h |  9 
 drivers/gpu/drm/i915/gt/intel_engine_cs.c | 16 ++-
 drivers/gpu/drm/i915/gt/intel_lrc.c   | 46 ---
 5 files changed, 94 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.c 
b/drivers/gpu/drm/i915/gt/intel_context.c
index 9796a54b4f47..93894460f008 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.c
+++ b/drivers/gpu/drm/i915/gt/intel_context.c
@@ -248,6 +248,7 @@ intel_context_init(struct intel_context *ce,
INIT_LIST_HEAD(&ce->signals);
 
mutex_init(&ce->pin_mutex);
+   seqlock_init(&ce->stats.lock);
 
i915_active_init(&ce->active,
 __intel_context_active, __intel_context_retire);
@@ -342,6 +343,25 @@ struct i915_request *intel_context_create_request(struct 
intel_context *ce)
return rq;
 }
 
+ktime_t intel_context_get_busy_time(struct intel_context *ce)
+{
+   unsigned int seq;
+   ktime_t total;
+
+   do {
+   seq = read_seqbegin(&ce->stats.lock);
+
+   total = ce->stats.total;
+
+   if (ce->stats.active)
+   total = ktime_add(total,
+ ktime_sub(ktime_get(),
+   ce->stats.start));
+   } while (read_seqretry(&ce->stats.lock, seq));
+
+   return total;
+}
+
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
 #include "selftest_context.c"
 #endif
diff --git a/drivers/gpu/drm/i915/gt/intel_context.h 
b/drivers/gpu/drm/i915/gt/intel_context.h
index 30bd248827d8..30f0268fcc9a 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.h
+++ b/drivers/gpu/drm/i915/gt/intel_context.h
@@ -224,4 +224,15 @@ intel_context_clear_nopreempt(struct intel_context *ce)
clear_bit(CONTEXT_NOPREEMPT, &ce->flags);
 }
 
+static inline void
+__intel_context_stats_start(struct intel_context_stats *stats, ktime_t now)
+{
+   if (!stats->active) {
+   stats->start = now;
+   stats->active = true;
+   }
+}
+
+ktime_t intel_context_get_busy_time(struct intel_context *ce);
+
 #endif /* __INTEL_CONTEXT_H__ */
diff --git a/drivers/gpu/drm/i915/gt/intel_context_types.h 
b/drivers/gpu/drm/i915/gt/intel_context_types.h
index ca1420fb8b53..963d33dc5289 100644
--- a/drivers/gpu/drm/i915/gt/intel_context_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_context_types.h
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "i915_active_types.h"
 #include "i915_utils.h"
@@ -83,6 +84,14 @@ struct intel_context {
 
/** sseu: Control eu/slice partitioning */
struct intel_sseu sseu;
+
+   /** stats: Context GPU engine busyness tracking. */
+   struct intel_context_stats {
+   seqlock_t lock;
+   bool active;
+   ktime_t start;
+   ktime_t total;
+   } stats;
 };
 
 #endif /* __INTEL_CONTEXT_TYPES__ */
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c 
b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
index 825c94e7ca0b..9a346c060469 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
@@ -1543,8 +1543,20 @@ int intel_enable_engine_stats(struct intel_engine_cs 
*engine)
 
engine->stats.enabled_at = ktime_get();
 
-   /* XXX submission method oblivious? */
-   for (port = execlists->active; (rq = *port); port++)
+   /*
+* Mark currently running context as active.
+* XXX submission method oblivious?
+*/
+
+   rq = NULL;
+   port = execlists->active;
+   if (port)
+   rq = *port;
+   if (rq)
+   __intel_context_stats_start(&rq->context->stats,
+   engine->stats.enabled_at);
+
+   for (; (rq = *port); port++)
engine->stats.active++;
 
for (port = execlists->pending; (rq = *port); port++) {
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c 
b/drivers/gpu/drm/i915/gt/intel_lrc.c
inde

Re: [Intel-gfx] [PATCH] drm/i915/dp: Add current maximum eDP link rate to sink_rate array.

2020-01-10 Thread Ville Syrjälä
On Thu, Jan 09, 2020 at 09:19:07PM +0100, Mario Kleiner wrote:
> On Thu, Jan 9, 2020 at 7:24 PM Ville Syrjälä 
> wrote:
> 
> > On Thu, Jan 09, 2020 at 06:57:14PM +0100, Mario Kleiner wrote:
> > > On Thu, Jan 9, 2020 at 5:47 PM Ville Syrjälä <
> > ville.syrj...@linux.intel.com>
> > > wrote:
> > >
> > > > On Thu, Jan 09, 2020 at 05:30:05PM +0100, Mario Kleiner wrote:
> > > > > On Thu, Jan 9, 2020 at 4:38 PM Ville Syrjälä <
> > > > ville.syrj...@linux.intel.com>
> > > > > wrote:
> > > > >
> >
> 
> > wouldn't work if dpcd[0x1] == 0xa, which it likely is [*]. AMD DC
> > > identified it as DP 1.1, eDP 1.3, and these extended caps seem to be only
> > > part of DP 1.3+ if i understand the comments in
> > > intel_dp_extended_receiver_capabilities() correctly.
> >
> >
> Ok, looking at previous debug output logs shows that those extended caps
> are not present on the systems, ie. that extended caps bit is not set. So
> dpcd[0x1] == 0xa.
> 
> 
> > Yeah, but you never know how creative they've been with the DPCD in
> > such a propritary machine. A full DPCD dump from /dev/drm_dp_aux* would
> > be nice. Can you file a bug an attach the DPCD dump there so we have a
> > good reference on what we're talking about (also for future if/when
> > someone eventually starts to wonder why we have such hacks in the
> > code)?
> >
> >
> True, it's Apple which likes to "Think different..." :/
> 
> Will do. But is there a proper/better way to do the /dev/drm_dp_aux0 dump?
> I used cat /dev/drm_dp_aux0 > dump, and that hangs, but if i interrupt it
> after a few seconds, i get a dump file of 512k size, which seems excessive?
> On AMD DC atm., in case that matters.

It can take a while to dump the whole thing. If there are errors in some
parts (against the spec but some devices simply don't care about the
spec) you may need to use ddrescue/etc. to dump everything that can be
dumped.

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


Re: [Intel-gfx] [RFC 1/8] drm/i915: Expose list of clients in sysfs

2020-01-10 Thread Chris Wilson
Quoting Tvrtko Ursulin (2020-01-10 13:30:42)
> +static ssize_t
> +show_client_name(struct device *kdev, struct device_attribute *attr, char 
> *buf)
> +{
> +   struct i915_drm_client *client =
> +   container_of(attr, typeof(*client), attr.name);
> +
> +   return snprintf(buf, PAGE_SIZE, "%s%s%s",
> +   client->closed ? "<" : "",
> +   client->name,
> +   client->closed ? ">" : "");

client->closed ? "<%s>" : "%s", unspeakably evil?
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 18/23] drm/sti: Convert to CRTC VBLANK callbacks

2020-01-10 Thread Benjamin Gaignard
Le ven. 10 janv. 2020 à 10:21, Thomas Zimmermann  a écrit :
>
> VBLANK callbacks in struct drm_driver are deprecated in favor of
> their equivalents in struct drm_crtc_funcs. Convert sti over.
>

Hi Thomas,

Since you remove the last calls to sti_crtc functions from sti_drv.c I
think that the include could also be removed.

Anyway that looks for me:
Acked-by: Benjamin Gaignard 

Thanks,
Benjamin

> Signed-off-by: Thomas Zimmermann 
> ---
>  drivers/gpu/drm/sti/sti_crtc.c | 11 ---
>  drivers/gpu/drm/sti/sti_crtc.h |  2 --
>  drivers/gpu/drm/sti/sti_drv.c  |  3 ---
>  3 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
> index dc64fbfc4e61..49e6cb8f5836 100644
> --- a/drivers/gpu/drm/sti/sti_crtc.c
> +++ b/drivers/gpu/drm/sti/sti_crtc.c
> @@ -279,12 +279,13 @@ int sti_crtc_vblank_cb(struct notifier_block *nb,
> return 0;
>  }
>
> -int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe)
> +static int sti_crtc_enable_vblank(struct drm_crtc *crtc)
>  {
> +   struct drm_device *dev = crtc->dev;
> +   unsigned int pipe = crtc->index;
> struct sti_private *dev_priv = dev->dev_private;
> struct sti_compositor *compo = dev_priv->compo;
> struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb[pipe];
> -   struct drm_crtc *crtc = &compo->mixer[pipe]->drm_crtc;
> struct sti_vtg *vtg = compo->vtg[pipe];
>
> DRM_DEBUG_DRIVER("\n");
> @@ -297,8 +298,10 @@ int sti_crtc_enable_vblank(struct drm_device *dev, 
> unsigned int pipe)
> return 0;
>  }
>
> -void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe)
> +static void sti_crtc_disable_vblank(struct drm_crtc *crtc)
>  {
> +   struct drm_device *drm_dev = crtc->dev;
> +   unsigned int pipe = crtc->index;
> struct sti_private *priv = drm_dev->dev_private;
> struct sti_compositor *compo = priv->compo;
> struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb[pipe];
> @@ -330,6 +333,8 @@ static const struct drm_crtc_funcs sti_crtc_funcs = {
> .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
> .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
> .late_register = sti_crtc_late_register,
> +   .enable_vblank = sti_crtc_enable_vblank,
> +   .disable_vblank = sti_crtc_disable_vblank,
>  };
>
>  bool sti_crtc_is_main(struct drm_crtc *crtc)
> diff --git a/drivers/gpu/drm/sti/sti_crtc.h b/drivers/gpu/drm/sti/sti_crtc.h
> index df489ab14e2b..1132b4586712 100644
> --- a/drivers/gpu/drm/sti/sti_crtc.h
> +++ b/drivers/gpu/drm/sti/sti_crtc.h
> @@ -15,8 +15,6 @@ struct sti_mixer;
>
>  int sti_crtc_init(struct drm_device *drm_dev, struct sti_mixer *mixer,
>   struct drm_plane *primary, struct drm_plane *cursor);
> -int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe);
> -void sti_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe);
>  int sti_crtc_vblank_cb(struct notifier_block *nb,
>unsigned long event, void *data);
>  bool sti_crtc_is_main(struct drm_crtc *drm_crtc);
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index a39fc36f815b..8e30001bf545 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -146,9 +146,6 @@ static struct drm_driver sti_driver = {
> .dumb_create = drm_gem_cma_dumb_create,
> .fops = &sti_driver_fops,
>
> -   .enable_vblank = sti_crtc_enable_vblank,
> -   .disable_vblank = sti_crtc_disable_vblank,
> -
> .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
> .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
> .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
> --
> 2.24.1
>
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [RFC 2/8] drm/i915: Update client name on context create

2020-01-10 Thread Chris Wilson
Quoting Tvrtko Ursulin (2020-01-10 13:30:43)
> From: Tvrtko Ursulin 
> 
> Some clients have the DRM fd passed to them over a socket by the X server.
> 
> Grab the real client and pid when they create their first context and
> update the exposed data for more useful enumeration.
> 
> v2:
>  * Do not leak the pid reference and borrow context idr_lock. (Chris)
> 
> v3:
>  * More avoiding leaks. (Chris)
> 
> Signed-off-by: Tvrtko Ursulin 
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_context.c | 36 ++---
>  drivers/gpu/drm/i915/i915_drm_client.c  |  4 +--
>  drivers/gpu/drm/i915/i915_drm_client.h  |  4 +++
>  3 files changed, 37 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c 
> b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index a2e57e62af30..ba3c29a01535 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -77,6 +77,7 @@
>  #include "gt/intel_lrc_reg.h"
>  #include "gt/intel_ring.h"
>  
> +#include "i915_drm_client.h"
>  #include "i915_gem_context.h"
>  #include "i915_globals.h"
>  #include "i915_trace.h"
> @@ -2181,7 +2182,10 @@ int i915_gem_context_create_ioctl(struct drm_device 
> *dev, void *data,
>  {
> struct drm_i915_private *i915 = to_i915(dev);
> struct drm_i915_gem_context_create_ext *args = data;
> +   struct drm_i915_file_private *file_priv = file->driver_priv;
> +   struct i915_drm_client *client = file_priv->client;
> struct create_ext ext_data;
> +   struct pid *pid;
> int ret;
> u32 id;
>  
> @@ -2195,16 +2199,35 @@ int i915_gem_context_create_ioctl(struct drm_device 
> *dev, void *data,
> if (ret)
> return ret;
>  
> -   ext_data.fpriv = file->driver_priv;
> +   pid = get_task_pid(current, PIDTYPE_PID);
> +
> +   ext_data.fpriv = file_priv;

Might as well do this in the declaration ?

struct create_ext ext_data {
.fpriv = file->driver_priv,
};
struct i915_drm_client *client = ext_data.fpriv->client;

?

> if (client_is_banned(ext_data.fpriv)) {
> DRM_DEBUG("client %s[%d] banned from creating ctx\n",
> - current->comm, task_pid_nr(current));
> -   return -EIO;
> + current->comm, pid_nr(pid));
> +   ret = -EIO;
> +   goto err_pid;
> +   }
> +
> +   /*
> +* Borrow struct_mutex to protect the client remove-add cycle.
> +*/
> +   ret = mutex_lock_interruptible(&dev->struct_mutex);
> +   if (ret)
> +   goto err_pid;
> +   if (client->pid != pid) {
> +   __i915_drm_client_unregister(client);
> +   ret = __i915_drm_client_register(client, current);
> }
> +   mutex_unlock(&dev->struct_mutex);
> +   if (ret)
> +   goto err_pid;

-> i915_drm_client_update();

And let it manage the pid locally?

>  
> ext_data.ctx = i915_gem_create_context(i915, args->flags);
> -   if (IS_ERR(ext_data.ctx))
> -   return PTR_ERR(ext_data.ctx);
> +   if (IS_ERR(ext_data.ctx)) {
> +   ret = PTR_ERR(ext_data.ctx);
> +   goto err_pid;
> +   }
>  
> if (args->flags & I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS) {
> ret = i915_user_extensions(u64_to_user_ptr(args->extensions),
> @@ -2226,6 +2249,9 @@ int i915_gem_context_create_ioctl(struct drm_device 
> *dev, void *data,
>  
>  err_ctx:
> context_close(ext_data.ctx);
> +err_pid:
> +   put_pid(pid);
> +
> return ret;
>  }
>  
> diff --git a/drivers/gpu/drm/i915/i915_drm_client.c 
> b/drivers/gpu/drm/i915/i915_drm_client.c
> index 02356f48d85b..666ec67c77e9 100644
> --- a/drivers/gpu/drm/i915/i915_drm_client.c
> +++ b/drivers/gpu/drm/i915/i915_drm_client.c
> @@ -36,7 +36,7 @@ show_client_pid(struct device *kdev, struct 
> device_attribute *attr, char *buf)
> client->closed ? ">" : "");
>  }
>  
> -static int
> +int
>  __i915_drm_client_register(struct i915_drm_client *client,
>struct task_struct *task)
>  {
> @@ -89,7 +89,7 @@ __i915_drm_client_register(struct i915_drm_client *client,
> return ret;
>  }
>  
> -static void __i915_drm_client_unregister(struct i915_drm_client *client)
> +void __i915_drm_client_unregister(struct i915_drm_client *client)
>  {
> if (!client->name)
> return; /* fbdev client or error during drm open */
> diff --git a/drivers/gpu/drm/i915/i915_drm_client.h 
> b/drivers/gpu/drm/i915/i915_drm_client.h
> index 8b261dc4a1f3..2c692345bc4e 100644
> --- a/drivers/gpu/drm/i915/i915_drm_client.h
> +++ b/drivers/gpu/drm/i915/i915_drm_client.h
> @@ -58,4 +58,8 @@ void i915_drm_client_close(struct i915_drm_client *client);
>  struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients,
> struct task_st

Re: [Intel-gfx] [RFC 5/8] drm/i915: Contexts can use struct pid stored in the client

2020-01-10 Thread Chris Wilson
Quoting Tvrtko Ursulin (2020-01-10 13:30:46)
> From: Tvrtko Ursulin 
> 
> Now that contexts keep their parent client reference counted, we can
> remove separate struct pid reference owned by contexts in favour of the
> one already held by the client.
> 
> Signed-off-by: Tvrtko Ursulin 
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_context.c   | 13 -
>  drivers/gpu/drm/i915/gem/i915_gem_context_types.h | 10 --
>  drivers/gpu/drm/i915/i915_debugfs.c   |  7 ---
>  drivers/gpu/drm/i915/i915_gpu_error.c |  8 
>  4 files changed, 12 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c 
> b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index ba8ccc754f20..758cebb99ba4 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -323,7 +323,6 @@ static void i915_gem_context_free(struct i915_gem_context 
> *ctx)
> if (ctx->timeline)
> intel_timeline_put(ctx->timeline);
>  
> -   put_pid(ctx->pid);
> mutex_destroy(&ctx->mutex);
>  
> kfree_rcu(ctx, rcu);
> @@ -794,24 +793,20 @@ static int gem_context_register(struct i915_gem_context 
> *ctx,
> WRITE_ONCE(vm->file, fpriv); /* XXX */
> mutex_unlock(&ctx->mutex);
>  
> -   ctx->pid = get_task_pid(current, PIDTYPE_PID);
> snprintf(ctx->name, sizeof(ctx->name), "%s[%d]",
> -current->comm, pid_nr(ctx->pid));
> +current->comm, pid_nr(client->pid));
>  
> /* And finally expose ourselves to userspace via the idr */
> ret = xa_alloc(&fpriv->context_xa, id, ctx, xa_limit_32b, GFP_KERNEL);
> -   if (ret) {
> -   put_pid(fetch_and_zero(&ctx->pid));
> -   goto out;
> -   }
> +   if (ret)
> +   return ret;
>  
> ctx->client = client = i915_drm_client_get(fpriv->client);
> spin_lock(&client->ctx_lock);
> list_add_tail_rcu(&ctx->client_link, &client->ctx_list);
> spin_unlock(&client->ctx_lock);
>  
> -out:
> -   return ret;
> +   return 0;
>  }
>  
>  int i915_gem_context_open(struct drm_i915_private *i915,
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h 
> b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
> index 879824159646..23421377a43d 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
> @@ -90,16 +90,6 @@ struct i915_gem_context {
>  */
> struct i915_address_space __rcu *vm;
>  
> -   /**
> -* @pid: process id of creator
> -*
> -* Note that who created the context may not be the principle user,
> -* as the context may be shared across a local socket. However,
> -* that should only affect the default context, all contexts created
> -* explicitly by the client are expected to be isolated.
> -*/
> -   struct pid *pid;
> -
> /** link: place with &drm_i915_private.context_list */
> struct list_head link;
> struct llist_node free_link;
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
> b/drivers/gpu/drm/i915/i915_debugfs.c
> index 8f01c2bc7355..bc533501b4e0 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -346,7 +346,8 @@ static void print_context_stats(struct seq_file *m,
> rcu_read_unlock();
>  
> rcu_read_lock();
> -   task = pid_task(ctx->pid ?: file->pid, PIDTYPE_PID);
> +   task = pid_task(ctx->client->pid ?: file->pid,
> +   PIDTYPE_PID);
> snprintf(name, sizeof(name), "%s",
>  task ? task->comm : "");
> rcu_read_unlock();
> @@ -1492,10 +1493,10 @@ static int i915_context_status(struct seq_file *m, 
> void *unused)
> spin_unlock(&i915->gem.contexts.lock);
>  
> seq_puts(m, "HW context ");
> -   if (ctx->pid) {
> +   if (ctx->client->pid) {
> struct task_struct *task;
>  
> -   task = get_pid_task(ctx->pid, PIDTYPE_PID);
> +   task = get_pid_task(ctx->client->pid, PIDTYPE_PID);
> if (task) {
> seq_printf(m, "(%s [%d]) ",
>task->comm, task->pid);
> diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c 
> b/drivers/gpu/drm/i915/i915_gpu_error.c
> index fda0977d2059..9240327bdb7d 100644
> --- a/drivers/gpu/drm/i915/i915_gpu_error.c
> +++ b/drivers/gpu/drm/i915/i915_gpu_error.c
> @@ -1235,8 +1235,8 @@ static void record_request(const struct i915_request 
> *request,
> erq->pid = 0;
> rcu_read_lock();
> ctx = rcu_dereference(request->contex

Re: [Intel-gfx] [PATCH v4 2/7] drm: always determine branch device with drm_dp_is_branch()

2020-01-10 Thread Jani Nikula
On Thu, 29 Aug 2019, Oleg Vasilev  wrote:
> The helper should always be used.
>
> Reviewed-by: Emil Velikov 
> Signed-off-by: Oleg Vasilev 
> Cc: Ville Syrjälä 
> Cc: intel-gfx@lists.freedesktop.org

Pushed patches 1-2 to drm-misc-next, thanks for the patches and review.

BR,
Jani.


> ---
>  drivers/gpu/drm/drm_dp_helper.c | 3 +--
>  drivers/gpu/drm/i915/display/intel_dp.c | 2 +-
>  2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index ffc68d305afe..14320930091b 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -573,8 +573,7 @@ void drm_dp_downstream_debug(struct seq_file *m,
>   int len;
>   uint8_t rev[2];
>   int type = port_cap[0] & DP_DS_PORT_TYPE_MASK;
> - bool branch_device = dpcd[DP_DOWNSTREAMPORT_PRESENT] &
> -  DP_DWN_STRM_PORT_PRESENT;
> + bool branch_device = drm_dp_is_branch(dpcd);
>  
>   seq_printf(m, "\tDP branch device present: %s\n",
>  branch_device ? "yes" : "no");
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
> b/drivers/gpu/drm/i915/display/intel_dp.c
> index 23908da1cd5d..6da6a4859f06 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -2922,7 +2922,7 @@ static bool downstream_hpd_needs_d0(struct intel_dp 
> *intel_dp)
>* FIXME should really check all downstream ports...
>*/
>   return intel_dp->dpcd[DP_DPCD_REV] == 0x11 &&
> - intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] & 
> DP_DWN_STRM_PORT_PRESENT &&
> + drm_dp_is_branch(intel_dp->dpcd) &&
>   intel_dp->downstream_ports[0] & DP_DS_PORT_HPD;
>  }

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


Re: [Intel-gfx] [RFC 3/8] drm/i915: Track per-context engine busyness

2020-01-10 Thread Chris Wilson
Quoting Tvrtko Ursulin (2020-01-10 13:30:44)
>  #endif /* __INTEL_CONTEXT_TYPES__ */
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c 
> b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> index 825c94e7ca0b..9a346c060469 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> @@ -1543,8 +1543,20 @@ int intel_enable_engine_stats(struct intel_engine_cs 
> *engine)
>  
> engine->stats.enabled_at = ktime_get();
>  
> -   /* XXX submission method oblivious? */
> -   for (port = execlists->active; (rq = *port); port++)
> +   /*
> +* Mark currently running context as active.
> +* XXX submission method oblivious?
> +*/
> +
> +   rq = NULL;
> +   port = execlists->active;

execlists->active is never NULL (it always points at one of the arrays).
*execlists->active may be NULL.

> +   if (port)
> +   rq = *port;
> +   if (rq)
> +   __intel_context_stats_start(&rq->context->stats,
> +   engine->stats.enabled_at);
> +
> +   for (; (rq = *port); port++)
> engine->stats.active++;
>  
> @@ -2250,6 +2277,7 @@ static void process_csb(struct intel_engine_cs *engine)
> rmb();
>  
> do {
> +   struct i915_request *rq;
> bool promote;
>  
> if (++head == num_entries)
> @@ -2305,7 +2333,11 @@ static void process_csb(struct intel_engine_cs *engine)
>  
> WRITE_ONCE(execlists->pending[0], NULL);
> } else {
> -   GEM_BUG_ON(!*execlists->active);
> +   rq = *execlists->active++;
> +   GEM_BUG_ON(!rq);
> +
> +   GEM_BUG_ON(execlists->active - execlists->inflight >
> +  execlists_num_ports(execlists));
>  
> /* port0 completed, advanced to port1 */
> trace_ports(execlists, "completed", 
> execlists->active);
> @@ -2316,13 +2348,15 @@ static void process_csb(struct intel_engine_cs 
> *engine)
>  * coherent (visible from the CPU) before the
>  * user interrupt and CSB is processed.
>  */
> -   
> GEM_BUG_ON(!i915_request_completed(*execlists->active) &&
> +   GEM_BUG_ON(!i915_request_completed(rq) &&
>!reset_in_progress(execlists));
> -   execlists_schedule_out(*execlists->active++);
>  
> -   GEM_BUG_ON(execlists->active - execlists->inflight >
> -  execlists_num_ports(execlists));
> +   execlists_schedule_out(rq);
> }
> +
> +   rq = *execlists->active;
> +   if (rq)
> +   intel_context_stats_start(&rq->context->stats);
> } while (head != tail);

Actually, we can do this after processing the entire event buf.

if (execlists_active(execlists))
intel_context_stats_start((*execlists->active)->context->stats);

Once we apply the fix in
https://patchwork.freedesktop.org/patch/347934/?series=71809&rev=1

We can in fact do this as a part of set_timeslice() which means we have
all the time-related updates in the same spot.
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 03/23] drm/i915: Don't use struct drm_driver.get_scanout_position()

2020-01-10 Thread Jani Nikula
On Fri, 10 Jan 2020, Thomas Zimmermann  wrote:
> Hi
>
> Am 10.01.20 um 12:59 schrieb Jani Nikula:
>> On Fri, 10 Jan 2020, Thomas Zimmermann  wrote:
>>> The callback struct drm_driver.get_scanout_position() is deprecated in
>>> favor of struct drm_crtc_helper_funcs.get_scanout_position().
>>>
>>> i915 doesn't use CRTC helpers. The patch duplicates the caller
>>> drm_calc_vbltimestamp_from_scanoutpos() for i915, such that the callback
>>> function is not needed.
>>>
>>> Signed-off-by: Thomas Zimmermann 
>>> ---
>>>  drivers/gpu/drm/i915/i915_drv.c |   3 +-
>>>  drivers/gpu/drm/i915/i915_irq.c | 117 ++--
>>>  drivers/gpu/drm/i915/i915_irq.h |   9 +--
>>>  3 files changed, 119 insertions(+), 10 deletions(-)
>> 
>> Not really enthusiastic about the diffstat in a "cleanup" series.
>
> Well, the cleanup is about the content of drm_driver :)
>
>> 
>> I wonder if you could add a generic helper version of
>> drm_calc_vbltimestamp_from_scanoutpos where you pass the
>> get_scanout_position function as a parameter. Both
>> drm_calc_vbltimestamp_from_scanoutpos and the new
>> i915_calc_vbltimestamp_from_scanoutpos would then be fairly thin
>> wrappers passing in the relevant get_scanout_position function.
>
> Of course. Will be in v2 of the series.

Please give Ville (Cc'd) a moment before sending v2 in case he wants to
chime in on this.

Thanks,
Jani.


>
> Best regards
> Thomas
>
>> 
>> This would reduce the almost identical duplication of the function in
>> i915.
>> 
>> BR,
>> Jani.
>> 
>>>
>>> diff --git a/drivers/gpu/drm/i915/i915_drv.c 
>>> b/drivers/gpu/drm/i915/i915_drv.c
>>> index f7385abdd74b..4a0a7fb85c53 100644
>>> --- a/drivers/gpu/drm/i915/i915_drv.c
>>> +++ b/drivers/gpu/drm/i915/i915_drv.c
>>> @@ -2769,8 +2769,7 @@ static struct drm_driver driver = {
>>> .gem_prime_export = i915_gem_prime_export,
>>> .gem_prime_import = i915_gem_prime_import,
>>>  
>>> -   .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
>>> -   .get_scanout_position = i915_get_crtc_scanoutpos,
>>> +   .get_vblank_timestamp = i915_calc_vbltimestamp_from_scanoutpos,
>>>  
>>> .dumb_create = i915_gem_dumb_create,
>>> .dumb_map_offset = i915_gem_dumb_mmap_offset,
>>> diff --git a/drivers/gpu/drm/i915/i915_irq.c 
>>> b/drivers/gpu/drm/i915/i915_irq.c
>>> index afc6aad9bf8c..99d0c3b0feae 100644
>>> --- a/drivers/gpu/drm/i915/i915_irq.c
>>> +++ b/drivers/gpu/drm/i915/i915_irq.c
>>> @@ -52,6 +52,11 @@
>>>  #include "i915_trace.h"
>>>  #include "intel_pm.h"
>>>  
>>> +/* Retry timestamp calculation up to 3 times to satisfy
>>> + * drm_timestamp_precision before giving up.
>>> + */
>>> +#define I915_TIMESTAMP_MAXRETRIES 3
>>> +
>>>  /**
>>>   * DOC: interrupt handling
>>>   *
>>> @@ -762,10 +767,11 @@ static int __intel_get_crtc_scanline(struct 
>>> intel_crtc *crtc)
>>> return (position + crtc->scanline_offset) % vtotal;
>>>  }
>>>  
>>> -bool i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int index,
>>> - bool in_vblank_irq, int *vpos, int *hpos,
>>> - ktime_t *stime, ktime_t *etime,
>>> - const struct drm_display_mode *mode)
>>> +static bool i915_get_crtc_scanoutpos(struct drm_device *dev,
>>> +unsigned int index, bool in_vblank_irq,
>>> +int *vpos, int *hpos,
>>> +ktime_t *stime, ktime_t *etime,
>>> +const struct drm_display_mode *mode)
>>>  {
>>> struct drm_i915_private *dev_priv = to_i915(dev);
>>> struct intel_crtc *crtc = to_intel_crtc(drm_crtc_from_index(dev, 
>>> index));
>>> @@ -879,6 +885,109 @@ bool i915_get_crtc_scanoutpos(struct drm_device *dev, 
>>> unsigned int index,
>>> return true;
>>>  }
>>>  
>>> +bool i915_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
>>> +   unsigned int pipe,
>>> +   int *max_error,
>>> +   ktime_t *vblank_time,
>>> +   bool in_vblank_irq)
>>> +{
>>> +   struct timespec64 ts_etime, ts_vblank_time;
>>> +   ktime_t stime, etime;
>>> +   bool vbl_status;
>>> +   struct drm_crtc *crtc;
>>> +   const struct drm_display_mode *mode;
>>> +   struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
>>> +   int vpos, hpos, i;
>>> +   int delta_ns, duration_ns;
>>> +
>>> +   crtc = drm_crtc_from_index(dev, pipe);
>>> +
>>> +   if (pipe >= dev->num_crtcs || !crtc) {
>>> +   DRM_ERROR("Invalid crtc %u\n", pipe);
>>> +   return false;
>>> +   }
>>> +
>>> +   if (drm_drv_uses_atomic_modeset(dev))
>>> +   mode = &vblank->hwmode;
>>> +   else
>>> +   mode = &crtc->hwmode;
>>> +
>>> +   /* If mode timing undefined, just return as no-op:
>>> +* Happens during initial modesetting of a crtc.
>>> +*/
>>> +   if (mode->crtc_clock == 0) {
>>> +   DRM_DE

[Intel-gfx] [PATCH v3] drm/i915/hdcp: update HDCP CP property as per port authentication state

2020-01-10 Thread Anshuman Gupta
When port is disabled due to modeset crtc disable sequence
or DPMS off, it eventually disables the HDCP encryption
keeping its content protection property to CP_ENABLED.
Since content protection property left at CP_ENABLED by
mistake, HDCP authentication is not attempted at next DDI
enable sequence.
HDCP content property should be updated accordingly
as per port authentication state.

v2:
 - Incorporated the necessary locking. (Ram)
 - Set content protection property to CP_DESIRED only when
   user has not asked explicitly to set CP_UNDESIRED.

v3:
 - Reset the is_hdcp_undesired flag to false. (Ram)
 - Rephrasing commit log and small comment for is_hdcp_desired
   flag. (Ram)

CC: Ramalingam C 
Signed-off-by: Anshuman Gupta 
---
 drivers/gpu/drm/i915/display/intel_display_types.h |  6 ++
 drivers/gpu/drm/i915/display/intel_hdcp.c  | 13 -
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h 
b/drivers/gpu/drm/i915/display/intel_display_types.h
index 630a94892b7b..a7b4c8324838 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -345,6 +345,12 @@ struct intel_hdcp {
struct delayed_work check_work;
struct work_struct prop_work;
 
+   /*
+* Track new_conn CP UNDESIRED state as DDI disable
+* code path does't have access to new conn state.
+*/
+   bool is_hdcp_undesired;
+
/* HDCP1.4 Encryption status */
bool hdcp_encrypted;
 
diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c 
b/drivers/gpu/drm/i915/display/intel_hdcp.c
index 0fdbd39f6641..7f631ebd8395 100644
--- a/drivers/gpu/drm/i915/display/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
@@ -2002,11 +2002,18 @@ int intel_hdcp_disable(struct intel_connector 
*connector)
mutex_lock(&hdcp->mutex);
 
if (hdcp->value != DRM_MODE_CONTENT_PROTECTION_UNDESIRED) {
-   hdcp->value = DRM_MODE_CONTENT_PROTECTION_UNDESIRED;
if (hdcp->hdcp2_encrypted)
ret = _intel_hdcp2_disable(connector);
else if (hdcp->hdcp_encrypted)
ret = _intel_hdcp_disable(connector);
+
+   if (hdcp->is_hdcp_undesired) {
+   hdcp->value = DRM_MODE_CONTENT_PROTECTION_UNDESIRED;
+   hdcp->is_hdcp_undesired = false;
+   } else {
+   hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
+   schedule_work(&hdcp->prop_work);
+   }
}
 
mutex_unlock(&hdcp->mutex);
@@ -2044,6 +2051,7 @@ void intel_hdcp_atomic_check(struct drm_connector 
*connector,
 {
u64 old_cp = old_state->content_protection;
u64 new_cp = new_state->content_protection;
+   struct intel_connector *intel_conn = to_intel_connector(connector);
struct drm_crtc_state *crtc_state;
 
if (!new_state->crtc) {
@@ -2069,6 +2077,9 @@ void intel_hdcp_atomic_check(struct drm_connector 
*connector,
return;
}
 
+   if (new_cp == DRM_MODE_CONTENT_PROTECTION_UNDESIRED)
+   intel_conn->hdcp.is_hdcp_undesired  =  true;
+
crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
   new_state->crtc);
crtc_state->mode_changed = true;
-- 
2.24.0

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


Re: [Intel-gfx] [RFC 6/8] drm/i915: Expose per-engine client busyness

2020-01-10 Thread Chris Wilson
Quoting Tvrtko Ursulin (2020-01-10 13:30:47)
> +static ssize_t
> +show_client_busy(struct device *kdev, struct device_attribute *attr, char 
> *buf)
> +{
> +   struct i915_engine_busy_attribute *i915_attr =
> +   container_of(attr, typeof(*i915_attr), attr);
> +   struct list_head *list = &i915_attr->client->ctx_list;
> +   unsigned int engine_class = i915_attr->engine_class;
> +   struct i915_gem_context *ctx;
> +   u64 total = 0;
> +
> +   if (i915_attr->no_busy_stats)
> +   return -ENODEV;
> +
> +   rcu_read_lock();
> +   list_for_each_entry_rcu(ctx, list, client_link)
> +   total += sw_busy_add(ctx, engine_class);
> +   rcu_read_unlock();
> +
> +   return snprintf(buf, PAGE_SIZE, "%llu\n", total);
> +}
> +
> +static const char *uabi_class_names[] = {
> +   [I915_ENGINE_CLASS_RENDER] = "0",
> +   [I915_ENGINE_CLASS_COPY] = "1",
> +   [I915_ENGINE_CLASS_VIDEO] = "2",
> +   [I915_ENGINE_CLASS_VIDEO_ENHANCE] = "3",
> +};

Hmm. /sys/class/drm/card0/clients/0/busy/0

Ok. I was worried this was 0/0 and so very bland and liable to clash
later.

> +
>  int
>  __i915_drm_client_register(struct i915_drm_client *client,
>struct task_struct *task)
>  {
> struct i915_drm_clients *clients = client->clients;
> +   struct drm_i915_private *i915 =
> +   container_of(clients, typeof(*i915), clients);
> +   struct intel_engine_cs *engine;
> struct device_attribute *attr;
> -   int ret = -ENOMEM;
> +   int i, ret = -ENOMEM;
> char idstr[32];
>  
> if (!clients->root)
> @@ -77,10 +130,71 @@ __i915_drm_client_register(struct i915_drm_client 
> *client,
> if (ret)
> goto err_attr;
>  
> +   if (HAS_LOGICAL_RING_CONTEXTS(i915)) {
> +   client->busy_root =
> +   kobject_create_and_add("busy", client->root);
> +   if (!client->busy_root)
> +   goto err_attr;
> +
> +   for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++) {
> +   struct i915_engine_busy_attribute *i915_attr =
> +   &client->attr.busy[i];


if (!intel_engine_lookup_user(i915, i, 0))
continue;

i.e. skip if we don't have any engines of that class in the system.

> +
> +   i915_attr->client = client;
> +   i915_attr->engine_class = i;
> +
> +   attr = &i915_attr->attr;
> +
> +   sysfs_attr_init(&attr->attr);
> +
> +   attr->attr.name = uabi_class_names[i];
> +   attr->attr.mode = 0444;
> +   attr->show = show_client_busy;
> +
> +   ret = sysfs_create_file(client->busy_root,
> +   (struct attribute *)attr);
> +   if (ret)
> +   goto err_busy;
> +   }
> +
> +   /* Enable busy stats on all engines. */
> +   i = 0;
> +   for_each_uabi_engine(engine, i915) {
> +   ret = intel_enable_engine_stats(engine);

Hmm. We gave it a global bit in 

i915->caps.scheduler & I915_SCHEDULER_CAP_ENABLED.

That'll avoid having to do the individual checking and rollback.
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [RFC 7/8] drm/i915: Track hw reported context runtime

2020-01-10 Thread Chris Wilson
Quoting Tvrtko Ursulin (2020-01-10 13:30:48)
> From: Tvrtko Ursulin 
> 
> GPU saves accumulated context runtime (in CS timestamp units) in PPHWSP
> which will be useful for us in cases when we are not able to track context
> busyness ourselves (like with GuC). Keep a copy of this in struct
> intel_context from where it can be easily read even if the context is not
> pinned.
> 
> QQQ: Do we want to make this accounting conditional / able to turn on/off?
> 
> Signed-off-by: Tvrtko Ursulin 
> ---
>  drivers/gpu/drm/i915/gt/intel_context.h   | 7 +++
>  drivers/gpu/drm/i915/gt/intel_context_types.h | 5 +
>  drivers/gpu/drm/i915/gt/intel_lrc.c   | 9 +
>  drivers/gpu/drm/i915/intel_device_info.c  | 2 ++
>  drivers/gpu/drm/i915/intel_device_info.h  | 1 +
>  5 files changed, 24 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gt/intel_context.h 
> b/drivers/gpu/drm/i915/gt/intel_context.h
> index 30f0268fcc9a..389a05736fc7 100644
> --- a/drivers/gpu/drm/i915/gt/intel_context.h
> +++ b/drivers/gpu/drm/i915/gt/intel_context.h
> @@ -12,6 +12,7 @@
>  #include 
>  
>  #include "i915_active.h"
> +#include "i915_drv.h"
>  #include "intel_context_types.h"
>  #include "intel_engine_types.h"
>  #include "intel_ring_types.h"
> @@ -235,4 +236,10 @@ __intel_context_stats_start(struct intel_context_stats 
> *stats, ktime_t now)
>  
>  ktime_t intel_context_get_busy_time(struct intel_context *ce);
>  
> +static inline u64 intel_context_get_hw_runtime_ns(struct intel_context *ce)
> +{
> +   return ce->total_runtime *
> +  RUNTIME_INFO(ce->engine->i915)->cs_timestamp_period_ns;
> +}
> +
>  #endif /* __INTEL_CONTEXT_H__ */
> diff --git a/drivers/gpu/drm/i915/gt/intel_context_types.h 
> b/drivers/gpu/drm/i915/gt/intel_context_types.h
> index 963d33dc5289..7b08bf87fb82 100644
> --- a/drivers/gpu/drm/i915/gt/intel_context_types.h
> +++ b/drivers/gpu/drm/i915/gt/intel_context_types.h
> @@ -69,6 +69,11 @@ struct intel_context {
> u64 lrc_desc;
> u32 tag; /* cookie passed to HW to track this context on submission */
>  
> +   /* Time on GPU as tracked by the hw. */
> +   u32 last_runtime;
> +   u64 total_runtime;
> +   u32 *pphwsp;

I wouldn't bother with keeping pphwsp, we know it's the page before the
reg state. At least for the foreseeable future.

> unsigned int active_count; /* protected by timeline->mutex */
>  
> atomic_t pin_count;
> diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c 
> b/drivers/gpu/drm/i915/gt/intel_lrc.c
> index dd559547500f..26999b43e5a1 100644
> --- a/drivers/gpu/drm/i915/gt/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
> @@ -1289,6 +1289,7 @@ __execlists_schedule_out(struct i915_request *rq,
>  struct intel_engine_cs * const engine)
>  {
> struct intel_context *ce = rq->context;
> +   u32 old, new;
>  
> /*
>  * NB process_csb() is not under the engine->active.lock and hence
> @@ -1309,6 +1310,13 @@ __execlists_schedule_out(struct i915_request *rq,
> execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_OUT);
> intel_gt_pm_put_async(engine->gt);
>  
> +   old = ce->last_runtime;
> +   ce->last_runtime = new = ce->pphwsp[16];
> +   if (new > old)
> +   ce->total_runtime += new - old;
> +   else
> +   ce->total_runtime += (~0UL - old) + new + 1;

It's u32, unsigned wrap-around arithmetic is defined, so just
ce->total_runtime += new - old;

> +
> /*
>  * If this is part of a virtual engine, its next request may
>  * have been blocked waiting for access to the active context.
> @@ -2608,6 +2616,7 @@ __execlists_context_pin(struct intel_context *ce,
>  
> ce->lrc_desc = lrc_descriptor(ce, engine) | CTX_DESC_FORCE_RESTORE;
> ce->lrc_reg_state = vaddr + LRC_STATE_PN * PAGE_SIZE;
> +   ce->pphwsp = vaddr + LRC_PPHWSP_PN * PAGE_SIZE;
> __execlists_update_reg_state(ce, engine);
>  
> return 0;
> diff --git a/drivers/gpu/drm/i915/intel_device_info.c 
> b/drivers/gpu/drm/i915/intel_device_info.c
> index 6670a0763be2..7732748e1939 100644
> --- a/drivers/gpu/drm/i915/intel_device_info.c
> +++ b/drivers/gpu/drm/i915/intel_device_info.c
> @@ -1042,6 +1042,8 @@ void intel_device_info_runtime_init(struct 
> drm_i915_private *dev_priv)
>  
> /* Initialize command stream timestamp frequency */
> runtime->cs_timestamp_frequency_khz = 
> read_timestamp_frequency(dev_priv);
> +   runtime->cs_timestamp_period_ns =
> +   div_u64(1e6, runtime->cs_timestamp_frequency_khz);

drm_debug(&dev_priv->drm, "CS timestamp wraparound in %lld\n",
div_u64(U32_MAX * runtime->cs_timestamp_period_ns, NSEC_PER_SEC);
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [RFC 6/8] drm/i915: Expose per-engine client busyness

2020-01-10 Thread Tvrtko Ursulin



On 10/01/2020 13:58, Chris Wilson wrote:

Quoting Tvrtko Ursulin (2020-01-10 13:30:47)

+static ssize_t
+show_client_busy(struct device *kdev, struct device_attribute *attr, char *buf)
+{
+   struct i915_engine_busy_attribute *i915_attr =
+   container_of(attr, typeof(*i915_attr), attr);
+   struct list_head *list = &i915_attr->client->ctx_list;
+   unsigned int engine_class = i915_attr->engine_class;
+   struct i915_gem_context *ctx;
+   u64 total = 0;
+
+   if (i915_attr->no_busy_stats)
+   return -ENODEV;
+
+   rcu_read_lock();
+   list_for_each_entry_rcu(ctx, list, client_link)
+   total += sw_busy_add(ctx, engine_class);
+   rcu_read_unlock();
+
+   return snprintf(buf, PAGE_SIZE, "%llu\n", total);
+}
+
+static const char *uabi_class_names[] = {
+   [I915_ENGINE_CLASS_RENDER] = "0",
+   [I915_ENGINE_CLASS_COPY] = "1",
+   [I915_ENGINE_CLASS_VIDEO] = "2",
+   [I915_ENGINE_CLASS_VIDEO_ENHANCE] = "3",
+};


Hmm. /sys/class/drm/card0/clients/0/busy/0

Ok. I was worried this was 0/0 and so very bland and liable to clash
later.


+
  int
  __i915_drm_client_register(struct i915_drm_client *client,
struct task_struct *task)
  {
 struct i915_drm_clients *clients = client->clients;
+   struct drm_i915_private *i915 =
+   container_of(clients, typeof(*i915), clients);
+   struct intel_engine_cs *engine;
 struct device_attribute *attr;
-   int ret = -ENOMEM;
+   int i, ret = -ENOMEM;
 char idstr[32];
  
 if (!clients->root)

@@ -77,10 +130,71 @@ __i915_drm_client_register(struct i915_drm_client *client,
 if (ret)
 goto err_attr;
  
+   if (HAS_LOGICAL_RING_CONTEXTS(i915)) {

+   client->busy_root =
+   kobject_create_and_add("busy", client->root);
+   if (!client->busy_root)
+   goto err_attr;
+
+   for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++) {
+   struct i915_engine_busy_attribute *i915_attr =
+   &client->attr.busy[i];



if (!intel_engine_lookup_user(i915, i, 0))
continue;

i.e. skip if we don't have any engines of that class in the system.


Yes, thanks.


+
+   i915_attr->client = client;
+   i915_attr->engine_class = i;
+
+   attr = &i915_attr->attr;
+
+   sysfs_attr_init(&attr->attr);
+
+   attr->attr.name = uabi_class_names[i];
+   attr->attr.mode = 0444;
+   attr->show = show_client_busy;
+
+   ret = sysfs_create_file(client->busy_root,
+   (struct attribute *)attr);
+   if (ret)
+   goto err_busy;
+   }
+
+   /* Enable busy stats on all engines. */
+   i = 0;
+   for_each_uabi_engine(engine, i915) {
+   ret = intel_enable_engine_stats(engine);


Hmm. We gave it a global bit in

i915->caps.scheduler & I915_SCHEDULER_CAP_ENABLED.

That'll avoid having to do the individual checking and rollback.


I could add a top level check as a short circuit, but I prefer to check 
return code from intel_enable_engine_stats since it returns one.


Also if new GuC will have I915_SCHEDULER_CAP_ENABLED it will still fail 
to enable engine stats and then fallback to pphwsp has to happen.


Regards,

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


Re: [Intel-gfx] [RFC 6/8] drm/i915: Expose per-engine client busyness

2020-01-10 Thread Chris Wilson
Quoting Tvrtko Ursulin (2020-01-10 14:09:09)
> 
> On 10/01/2020 13:58, Chris Wilson wrote:
> > Quoting Tvrtko Ursulin (2020-01-10 13:30:47)
> >> +static ssize_t
> >> +show_client_busy(struct device *kdev, struct device_attribute *attr, char 
> >> *buf)
> >> +{
> >> +   struct i915_engine_busy_attribute *i915_attr =
> >> +   container_of(attr, typeof(*i915_attr), attr);
> >> +   struct list_head *list = &i915_attr->client->ctx_list;
> >> +   unsigned int engine_class = i915_attr->engine_class;
> >> +   struct i915_gem_context *ctx;
> >> +   u64 total = 0;
> >> +
> >> +   if (i915_attr->no_busy_stats)
> >> +   return -ENODEV;
> >> +
> >> +   rcu_read_lock();
> >> +   list_for_each_entry_rcu(ctx, list, client_link)
> >> +   total += sw_busy_add(ctx, engine_class);
> >> +   rcu_read_unlock();
> >> +
> >> +   return snprintf(buf, PAGE_SIZE, "%llu\n", total);
> >> +}
> >> +
> >> +static const char *uabi_class_names[] = {
> >> +   [I915_ENGINE_CLASS_RENDER] = "0",
> >> +   [I915_ENGINE_CLASS_COPY] = "1",
> >> +   [I915_ENGINE_CLASS_VIDEO] = "2",
> >> +   [I915_ENGINE_CLASS_VIDEO_ENHANCE] = "3",
> >> +};
> > 
> > Hmm. /sys/class/drm/card0/clients/0/busy/0
> > 
> > Ok. I was worried this was 0/0 and so very bland and liable to clash
> > later.
> > 
> >> +
> >>   int
> >>   __i915_drm_client_register(struct i915_drm_client *client,
> >> struct task_struct *task)
> >>   {
> >>  struct i915_drm_clients *clients = client->clients;
> >> +   struct drm_i915_private *i915 =
> >> +   container_of(clients, typeof(*i915), clients);
> >> +   struct intel_engine_cs *engine;
> >>  struct device_attribute *attr;
> >> -   int ret = -ENOMEM;
> >> +   int i, ret = -ENOMEM;
> >>  char idstr[32];
> >>   
> >>  if (!clients->root)
> >> @@ -77,10 +130,71 @@ __i915_drm_client_register(struct i915_drm_client 
> >> *client,
> >>  if (ret)
> >>  goto err_attr;
> >>   
> >> +   if (HAS_LOGICAL_RING_CONTEXTS(i915)) {
> >> +   client->busy_root =
> >> +   kobject_create_and_add("busy", client->root);
> >> +   if (!client->busy_root)
> >> +   goto err_attr;
> >> +
> >> +   for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++) {
> >> +   struct i915_engine_busy_attribute *i915_attr =
> >> +   &client->attr.busy[i];
> > 
> > 
> > if (!intel_engine_lookup_user(i915, i, 0))
> >   continue;
> > 
> > i.e. skip if we don't have any engines of that class in the system.
> 
> Yes, thanks.
> 
> >> +
> >> +   i915_attr->client = client;
> >> +   i915_attr->engine_class = i;
> >> +
> >> +   attr = &i915_attr->attr;
> >> +
> >> +   sysfs_attr_init(&attr->attr);
> >> +
> >> +   attr->attr.name = uabi_class_names[i];
> >> +   attr->attr.mode = 0444;
> >> +   attr->show = show_client_busy;
> >> +
> >> +   ret = sysfs_create_file(client->busy_root,
> >> +   (struct attribute *)attr);
> >> +   if (ret)
> >> +   goto err_busy;
> >> +   }
> >> +
> >> +   /* Enable busy stats on all engines. */
> >> +   i = 0;
> >> +   for_each_uabi_engine(engine, i915) {
> >> +   ret = intel_enable_engine_stats(engine);
> > 
> > Hmm. We gave it a global bit in
> > 
> >   i915->caps.scheduler & I915_SCHEDULER_CAP_ENABLED.
> > 
> > That'll avoid having to do the individual checking and rollback.
> 
> I could add a top level check as a short circuit, but I prefer to check 
> return code from intel_enable_engine_stats since it returns one.

My suggestion was to remove the return code and make it bug out, as we
[can] check before use in i915_pmu.c as well.

> Also if new GuC will have I915_SCHEDULER_CAP_ENABLED it will still fail 
> to enable engine stats and then fallback to pphwsp has to happen.

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


Re: [Intel-gfx] [PATCH 0/5] drm/i915: conversion to new drm logging macros.

2020-01-10 Thread Jani Nikula
On Tue, 07 Jan 2020, Wambui Karuga  wrote:
> This series begins the conversion to using the new struct drm_device
> based logging macros in drm/i915.
>
> Wambui Karuga (5):
>   drm/i915: convert to using the drm_dbg_kms() macro.
>   drm/i915: use new struct drm_device logging macros.
>   drm/i915: use new struct drm_device based logging macros.
>   drm/i915: convert to using new struct drm_device logging macros
>   drm/i915: use new struct drm_device based macros.

Thanks for the patches, pushed to drm-intel-next-queued.

As it's impossible to distinguish the commits from each other by the
subject line alone, I've amended the prefix while pushing as follows:

drm/i915/pch: convert to using the drm_dbg_kms() macro.
drm/i915/pm: use new struct drm_device logging macros.
drm/i915/lmem: use new struct drm_device based logging macros.
drm/i915/sideband: convert to using new struct drm_device logging macros
drm/i915/uncore: use new struct drm_device based macros.

Please pay attention to this in future work. It's not always obvious
what the prefix should be, but 'git log -- path/to/file.c' will go a
long way.

BR,
Jani.


>
>  drivers/gpu/drm/i915/intel_pch.c |  46 +--
>  drivers/gpu/drm/i915/intel_pm.c  | 351 +--
>  drivers/gpu/drm/i915/intel_region_lmem.c |  10 +-
>  drivers/gpu/drm/i915/intel_sideband.c|  29 +-
>  drivers/gpu/drm/i915/intel_uncore.c  |  25 +-
>  5 files changed, 254 insertions(+), 207 deletions(-)

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


Re: [Intel-gfx] [PATCH 03/14] drm/i915/gt: runtime-pm is no longer required for ce->ops->pin()

2020-01-10 Thread Mika Kuoppala
Chris Wilson  writes:

> Now that we have moved the runtime-pm management out of
> intel_context_acctive_acquire, and that itself out of ce->ops->pin(),
> no

s/acctive/active

> explicit runtime pm wakeref is required in intel_context_pin().
>
> Signed-off-by: Chris Wilson 

Reviewed-by: Mika Kuoppala 
> ---
>  drivers/gpu/drm/i915/gt/intel_context.c | 5 +
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_context.c 
> b/drivers/gpu/drm/i915/gt/intel_context.c
> index cac80d87b2bb..9796a54b4f47 100644
> --- a/drivers/gpu/drm/i915/gt/intel_context.c
> +++ b/drivers/gpu/drm/i915/gt/intel_context.c
> @@ -105,14 +105,11 @@ int __intel_context_do_pin(struct intel_context *ce)
>   return -EINTR;
>  
>   if (likely(!atomic_read(&ce->pin_count))) {
> - intel_wakeref_t wakeref;
> -
>   err = intel_context_active_acquire(ce);
>   if (unlikely(err))
>   goto err;
>  
> - with_intel_runtime_pm(ce->engine->uncore->rpm, wakeref)
> - err = ce->ops->pin(ce);
> + err = ce->ops->pin(ce);
>   if (unlikely(err))
>   goto err_active;
>  
> -- 
> 2.25.0.rc1
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] drm/i915/gt: Hold rpm wakeref before taking ggtt->vm.mutex

2020-01-10 Thread Chris Wilson
We need to hold the runtime-pm wakeref to update the global PTEs (as
they exist behind a PCI BAR). However, some systems invoke ACPI during
runtime resume and so require allocations, which is verboten inside the
vm->mutex. Ergo, we must not use intel_runtime_pm_get() inside the
mutex, but lift the call outside.

Closes: https://gitlab.freedesktop.org/drm/intel/issues/958
Signed-off-by: Chris Wilson 
Cc: Maarten Lankhorst 
Cc: Matthew Auld 
Cc: Mika Kuoppala 
---
 drivers/gpu/drm/i915/gt/intel_ggtt.c | 28 +---
 drivers/gpu/drm/i915/i915_vma.c  | 13 +
 2 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c 
b/drivers/gpu/drm/i915/gt/intel_ggtt.c
index 795cd267e28e..6474c6190d3d 100644
--- a/drivers/gpu/drm/i915/gt/intel_ggtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c
@@ -430,9 +430,7 @@ static int ggtt_bind_vma(struct i915_vma *vma,
 enum i915_cache_level cache_level,
 u32 flags)
 {
-   struct drm_i915_private *i915 = vma->vm->i915;
struct drm_i915_gem_object *obj = vma->obj;
-   intel_wakeref_t wakeref;
u32 pte_flags;
 
/* Applicable to VLV (gen8+ do not support RO in the GGTT) */
@@ -440,8 +438,7 @@ static int ggtt_bind_vma(struct i915_vma *vma,
if (i915_gem_object_is_readonly(obj))
pte_flags |= PTE_READ_ONLY;
 
-   with_intel_runtime_pm(&i915->runtime_pm, wakeref)
-   vma->vm->insert_entries(vma->vm, vma, cache_level, pte_flags);
+   vma->vm->insert_entries(vma->vm, vma, cache_level, pte_flags);
 
vma->page_sizes.gtt = I915_GTT_PAGE_SIZE;
 
@@ -457,11 +454,7 @@ static int ggtt_bind_vma(struct i915_vma *vma,
 
 static void ggtt_unbind_vma(struct i915_vma *vma)
 {
-   struct drm_i915_private *i915 = vma->vm->i915;
-   intel_wakeref_t wakeref;
-
-   with_intel_runtime_pm(&i915->runtime_pm, wakeref)
-   vma->vm->clear_range(vma->vm, vma->node.start, vma->size);
+   vma->vm->clear_range(vma->vm, vma->node.start, vma->size);
 }
 
 static int ggtt_reserve_guc_top(struct i915_ggtt *ggtt)
@@ -569,7 +562,6 @@ static int aliasing_gtt_bind_vma(struct i915_vma *vma,
 enum i915_cache_level cache_level,
 u32 flags)
 {
-   struct drm_i915_private *i915 = vma->vm->i915;
u32 pte_flags;
int ret;
 
@@ -597,28 +589,18 @@ static int aliasing_gtt_bind_vma(struct i915_vma *vma,
 cache_level, pte_flags);
}
 
-   if (flags & I915_VMA_GLOBAL_BIND) {
-   intel_wakeref_t wakeref;
-
-   with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
-   vma->vm->insert_entries(vma->vm, vma,
-   cache_level, pte_flags);
-   }
-   }
+   if (flags & I915_VMA_GLOBAL_BIND)
+   vma->vm->insert_entries(vma->vm, vma, cache_level, pte_flags);
 
return 0;
 }
 
 static void aliasing_gtt_unbind_vma(struct i915_vma *vma)
 {
-   struct drm_i915_private *i915 = vma->vm->i915;
-
if (i915_vma_is_bound(vma, I915_VMA_GLOBAL_BIND)) {
struct i915_address_space *vm = vma->vm;
-   intel_wakeref_t wakeref;
 
-   with_intel_runtime_pm(&i915->runtime_pm, wakeref)
-   vm->clear_range(vm, vma->node.start, vma->size);
+   vm->clear_range(vm, vma->node.start, vma->size);
}
 
if (test_and_clear_bit(I915_VMA_ALLOC_BIT, __i915_vma_flags(vma))) {
diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index 43d5c270bdb0..c702708131b8 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -858,6 +858,7 @@ static void vma_unbind_pages(struct i915_vma *vma)
 int i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
 {
struct i915_vma_work *work = NULL;
+   intel_wakeref_t wakeref = 0;
unsigned int bound;
int err;
 
@@ -883,6 +884,9 @@ int i915_vma_pin(struct i915_vma *vma, u64 size, u64 
alignment, u64 flags)
}
}
 
+   if (flags & PIN_GLOBAL)
+   wakeref = intel_runtime_pm_get(&vma->vm->i915->runtime_pm);
+
/* No more allocations allowed once we hold vm->mutex */
err = mutex_lock_interruptible(&vma->vm->mutex);
if (err)
@@ -946,6 +950,8 @@ int i915_vma_pin(struct i915_vma *vma, u64 size, u64 
alignment, u64 flags)
 err_fence:
if (work)
dma_fence_work_commit(&work->base);
+   if (wakeref)
+   intel_runtime_pm_put(&vma->vm->i915->runtime_pm, wakeref);
 err_pages:
vma_put_pages(vma);
return err;
@@ -1246,11 +1252,15 @@ int __i915_vma_unbind(struct i915_vma *vma)
 int i915_vma_unbind(struct i915_vma *vma)
 {
struct i915_address_space *vm = vma->vm;
+   intel_

Re: [Intel-gfx] [PATCH 1/3] drm/i915/gt: Skip trying to unbind in restore_ggtt_mappings

2020-01-10 Thread Matthew Auld
On Fri, 10 Jan 2020 at 11:04, Chris Wilson  wrote:
>
> Currently we first to try to unbind the VMA (and lazily rebind on next
> use) as an optimisation during restore_ggtt_mappings. Ideally, the only
> objects in the GGTT upon resume are the pinned kernel objects which
> can't be unbound and need to be restored. As the unbind interferes with
> the plan to mark those objects as active for error capture, forgo the
> optimisation.
>
> Signed-off-by: Chris Wilson 
Reviewed-by: Matthew Auld 
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v4 2/9] perf/core: open access for CAP_SYS_PERFMON privileged process

2020-01-10 Thread Peter Zijlstra
On Thu, Jan 09, 2020 at 02:36:50PM +0300, Alexey Budankov wrote:
> On 08.01.2020 19:07, Peter Zijlstra wrote:
> > On Wed, Dec 18, 2019 at 12:25:35PM +0300, Alexey Budankov wrote:

> >> diff --git a/kernel/events/core.c b/kernel/events/core.c
> >> index 059ee7116008..d9db414f2197 100644
> >> --- a/kernel/events/core.c
> >> +++ b/kernel/events/core.c
> >> @@ -9056,7 +9056,7 @@ static int perf_kprobe_event_init(struct perf_event 
> >> *event)
> >>if (event->attr.type != perf_kprobe.type)
> >>return -ENOENT;
> >>  
> >> -  if (!capable(CAP_SYS_ADMIN))
> >> +  if (!perfmon_capable())
> >>return -EACCES;
> >>  
> >>/*
> > 
> > This one only allows attaching to already extant kprobes, right? It does
> > not allow creation of kprobes.
> 
> This unblocks creation of local trace kprobes and uprobes by CAP_SYS_PERFMON 
> privileged process, exactly the same as for CAP_SYS_ADMIN privileged process.

I've no idea what you just said; it's just words.

Again, this only allows attaching to previously created kprobes, it does
not allow creating kprobes, right?

That is; I don't think CAP_SYS_PERFMON should be allowed to create
kprobes.

As might be clear; I don't actually know what the user-ABI is for
creating kprobes.
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] i915: ggtt: include asm/smp.h

2020-01-10 Thread Arnd Bergmann
Splitting up the i915_gem_gtt caused a build failure in some configurations:

drivers/gpu/drm/i915/gt/intel_ggtt.c: In function 'ggtt_restore_mappings':
drivers/gpu/drm/i915/gt/intel_ggtt.c:1239:3: error: implicit declaration of 
function 'wbinvd_on_all_cpus'; did you mean 'wrmsr_on_cpus'? 
[-Werror=implicit-function-declaration]
   wbinvd_on_all_cpus();
   ^~
   wrmsr_on_cpus

Add the missing header file.

Fixes: 2c86e55d2ab5 ("drm/i915/gtt: split up i915_gem_gtt")
Signed-off-by: Arnd Bergmann 
---
I ran into this bug a few days ago on linux-next. Please just ignore
if it's already fixed in the meantime.
---
 drivers/gpu/drm/i915/gt/intel_ggtt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c 
b/drivers/gpu/drm/i915/gt/intel_ggtt.c
index 1a2b5dcde960..9ef8ed85a738 100644
--- a/drivers/gpu/drm/i915/gt/intel_ggtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c
@@ -6,6 +6,7 @@
 #include 
 
 #include 
+#include 
 
 #include "intel_gt.h"
 #include "i915_drv.h"
-- 
2.20.0

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


Re: [Intel-gfx] [PATCH] i915: ggtt: include asm/smp.h

2020-01-10 Thread Chris Wilson
Quoting Arnd Bergmann (2020-01-10 15:17:54)
> Splitting up the i915_gem_gtt caused a build failure in some configurations:
> 
> drivers/gpu/drm/i915/gt/intel_ggtt.c: In function 'ggtt_restore_mappings':
> drivers/gpu/drm/i915/gt/intel_ggtt.c:1239:3: error: implicit declaration of 
> function 'wbinvd_on_all_cpus'; did you mean 'wrmsr_on_cpus'? 
> [-Werror=implicit-function-declaration]
>wbinvd_on_all_cpus();
>^~
>wrmsr_on_cpus
> 
> Add the missing header file.
> 
> Fixes: 2c86e55d2ab5 ("drm/i915/gtt: split up i915_gem_gtt")
> Signed-off-by: Arnd Bergmann 
> ---
> I ran into this bug a few days ago on linux-next. Please just ignore
> if it's already fixed in the meantime.

Fixed applied this morning, thanks for the fixup anyway.
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 03/23] drm/i915: Don't use struct drm_driver.get_scanout_position()

2020-01-10 Thread Ville Syrjälä
On Fri, Jan 10, 2020 at 03:56:06PM +0200, Jani Nikula wrote:
> On Fri, 10 Jan 2020, Thomas Zimmermann  wrote:
> > Hi
> >
> > Am 10.01.20 um 12:59 schrieb Jani Nikula:
> >> On Fri, 10 Jan 2020, Thomas Zimmermann  wrote:
> >>> The callback struct drm_driver.get_scanout_position() is deprecated in
> >>> favor of struct drm_crtc_helper_funcs.get_scanout_position().
> >>>
> >>> i915 doesn't use CRTC helpers. The patch duplicates the caller
> >>> drm_calc_vbltimestamp_from_scanoutpos() for i915, such that the callback
> >>> function is not needed.
> >>>
> >>> Signed-off-by: Thomas Zimmermann 
> >>> ---
> >>>  drivers/gpu/drm/i915/i915_drv.c |   3 +-
> >>>  drivers/gpu/drm/i915/i915_irq.c | 117 ++--
> >>>  drivers/gpu/drm/i915/i915_irq.h |   9 +--
> >>>  3 files changed, 119 insertions(+), 10 deletions(-)
> >> 
> >> Not really enthusiastic about the diffstat in a "cleanup" series.
> >
> > Well, the cleanup is about the content of drm_driver :)
> >
> >> 
> >> I wonder if you could add a generic helper version of
> >> drm_calc_vbltimestamp_from_scanoutpos where you pass the
> >> get_scanout_position function as a parameter. Both
> >> drm_calc_vbltimestamp_from_scanoutpos and the new
> >> i915_calc_vbltimestamp_from_scanoutpos would then be fairly thin
> >> wrappers passing in the relevant get_scanout_position function.
> >
> > Of course. Will be in v2 of the series.
> 
> Please give Ville (Cc'd) a moment before sending v2 in case he wants to
> chime in on this.

Passing the function pointer was one option I considered for this a while
back. Can't remeber what other solutions I condsidered. But I guess I
didn't like any of them enough to make an actual patch.

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


[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/pmu: Do not use colon characters in PMU names (rev2)

2020-01-10 Thread Patchwork
== Series Details ==

Series: drm/i915/pmu: Do not use colon characters in PMU names (rev2)
URL   : https://patchwork.freedesktop.org/series/71878/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_7718 -> Patchwork_16050


Summary
---

  **SUCCESS**

  No regressions found.

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

Known issues


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

### IGT changes ###

 Issues hit 

  * igt@gem_sync@basic-all:
- fi-tgl-y:   [PASS][1] -> [INCOMPLETE][2] ([i915#470] / [i915#472])
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-tgl-y/igt@gem_s...@basic-all.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16050/fi-tgl-y/igt@gem_s...@basic-all.html

  * igt@i915_module_load@reload-with-fault-injection:
- fi-cfl-8700k:   [PASS][3] -> [INCOMPLETE][4] ([i915#505])
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-cfl-8700k/igt@i915_module_l...@reload-with-fault-injection.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16050/fi-cfl-8700k/igt@i915_module_l...@reload-with-fault-injection.html

  * igt@i915_selftest@live_blt:
- fi-ivb-3770:[PASS][5] -> [DMESG-FAIL][6] ([i915#725])
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-ivb-3770/igt@i915_selftest@live_blt.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16050/fi-ivb-3770/igt@i915_selftest@live_blt.html
- fi-hsw-peppy:   [PASS][7] -> [DMESG-FAIL][8] ([i915#725])
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-hsw-peppy/igt@i915_selftest@live_blt.html
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16050/fi-hsw-peppy/igt@i915_selftest@live_blt.html

  * igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u:   [PASS][9] -> [FAIL][10] ([fdo#111407])
   [9]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-kbl-7500u/igt@kms_chamel...@hdmi-hpd-fast.html
   [10]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16050/fi-kbl-7500u/igt@kms_chamel...@hdmi-hpd-fast.html

  
 Possible fixes 

  * igt@gem_close_race@basic-threads:
- fi-byt-j1900:   [TIMEOUT][11] ([i915#816]) -> [PASS][12]
   [11]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-byt-j1900/igt@gem_close_r...@basic-threads.html
   [12]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16050/fi-byt-j1900/igt@gem_close_r...@basic-threads.html

  * {igt@gem_exec_basic@basic@bcs0}:
- fi-byt-n2820:   [FAIL][13] ([i915#694]) -> [PASS][14]
   [13]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-byt-n2820/igt@gem_exec_basic@ba...@bcs0.html
   [14]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16050/fi-byt-n2820/igt@gem_exec_basic@ba...@bcs0.html

  * {igt@gem_exec_basic@basic@vcs0}:
- fi-byt-n2820:   [WARN][15] -> [PASS][16]
   [15]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-byt-n2820/igt@gem_exec_basic@ba...@vcs0.html
   [16]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16050/fi-byt-n2820/igt@gem_exec_basic@ba...@vcs0.html

  * igt@i915_module_load@reload-with-fault-injection:
- fi-kbl-x1275:   [INCOMPLETE][17] ([i915#879]) -> [PASS][18]
   [17]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-kbl-x1275/igt@i915_module_l...@reload-with-fault-injection.html
   [18]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16050/fi-kbl-x1275/igt@i915_module_l...@reload-with-fault-injection.html

  * igt@i915_pm_rpm@module-reload:
- fi-skl-6770hq:  [FAIL][19] ([i915#178]) -> [PASS][20]
   [19]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-skl-6770hq/igt@i915_pm_...@module-reload.html
   [20]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16050/fi-skl-6770hq/igt@i915_pm_...@module-reload.html

  * igt@i915_selftest@live_blt:
- fi-hsw-4770:[DMESG-FAIL][21] ([i915#563]) -> [PASS][22]
   [21]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-hsw-4770/igt@i915_selftest@live_blt.html
   [22]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16050/fi-hsw-4770/igt@i915_selftest@live_blt.html

  * igt@i915_selftest@live_gem_contexts:
- fi-byt-n2820:   [DMESG-FAIL][23] ([i915#722]) -> [PASS][24]
   [23]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-byt-n2820/igt@i915_selftest@live_gem_contexts.html
   [24]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16050/fi-byt-n2820/igt@i915_selftest@live_gem_contexts.html

  
 Warnings 

  * igt@i915_selftest@live_blt:
- fi-hsw-4770r:   [DMESG-FAIL][25] ([i915#725]) -> [DMESG-FAIL][26] 
([i915#553] / [i915#725])
   [25]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-hsw-4770r/igt@i915_selftest@live_blt.html
   [26]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16050/fi-hsw-4770r/igt@i915_selftest@live_blt.html

  
  {na

Re: [Intel-gfx] [PATCH] drm/i915/dp: Add current maximum eDP link rate to sink_rate array.

2020-01-10 Thread Mario Kleiner
On Fri, Jan 10, 2020 at 2:32 PM Ville Syrjälä 
wrote:

> On Thu, Jan 09, 2020 at 09:19:07PM +0100, Mario Kleiner wrote:
> > On Thu, Jan 9, 2020 at 7:24 PM Ville Syrjälä <
> ville.syrj...@linux.intel.com>
> > wrote:
> >
> > > On Thu, Jan 09, 2020 at 06:57:14PM +0100, Mario Kleiner wrote:
> > > > On Thu, Jan 9, 2020 at 5:47 PM Ville Syrjälä <
> > > ville.syrj...@linux.intel.com>
> > > > wrote:
> > > >
> > > > > On Thu, Jan 09, 2020 at 05:30:05PM +0100, Mario Kleiner wrote:
> > > > > > On Thu, Jan 9, 2020 at 4:38 PM Ville Syrjälä <
> > > > > ville.syrj...@linux.intel.com>
> > > > > > wrote:
> > > > > >
> > >
> >
> > > wouldn't work if dpcd[0x1] == 0xa, which it likely is [*]. AMD DC
> > > > identified it as DP 1.1, eDP 1.3, and these extended caps seem to be
> only
> > > > part of DP 1.3+ if i understand the comments in
> > > > intel_dp_extended_receiver_capabilities() correctly.
> > >
> > >
> > Ok, looking at previous debug output logs shows that those extended caps
> > are not present on the systems, ie. that extended caps bit is not set. So
> > dpcd[0x1] == 0xa.
> >
> >
> > > Yeah, but you never know how creative they've been with the DPCD in
> > > such a propritary machine. A full DPCD dump from /dev/drm_dp_aux* would
> > > be nice. Can you file a bug an attach the DPCD dump there so we have a
> > > good reference on what we're talking about (also for future if/when
> > > someone eventually starts to wonder why we have such hacks in the
> > > code)?
> > >
> > >
> > True, it's Apple which likes to "Think different..." :/
> >
> > Will do. But is there a proper/better way to do the /dev/drm_dp_aux0
> dump?
> > I used cat /dev/drm_dp_aux0 > dump, and that hangs, but if i interrupt it
> > after a few seconds, i get a dump file of 512k size, which seems
> excessive?
> > On AMD DC atm., in case that matters.
>
> It can take a while to dump the whole thing. If there are errors in some
> parts (against the spec but some devices simply don't care about the
> spec) you may need to use ddrescue/etc. to dump everything that can be
> dumped.
>
> Ok, it is Mozilla bug 206157:

https://bugzilla.kernel.org/show_bug.cgi?id=206157

I attached the first ~ 5000 Bytes of DPCD dump, as there is a 5k file size
limit. The total dump is 512 kB, mostly zeros.

-mario

-- 
> 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 v4 2/9] perf/core: open access for CAP_SYS_PERFMON privileged process

2020-01-10 Thread Masami Hiramatsu
On Fri, 10 Jan 2020 15:02:34 +0100
Peter Zijlstra  wrote:

> On Thu, Jan 09, 2020 at 02:36:50PM +0300, Alexey Budankov wrote:
> > On 08.01.2020 19:07, Peter Zijlstra wrote:
> > > On Wed, Dec 18, 2019 at 12:25:35PM +0300, Alexey Budankov wrote:
> 
> > >> diff --git a/kernel/events/core.c b/kernel/events/core.c
> > >> index 059ee7116008..d9db414f2197 100644
> > >> --- a/kernel/events/core.c
> > >> +++ b/kernel/events/core.c
> > >> @@ -9056,7 +9056,7 @@ static int perf_kprobe_event_init(struct 
> > >> perf_event *event)
> > >>  if (event->attr.type != perf_kprobe.type)
> > >>  return -ENOENT;
> > >>  
> > >> -if (!capable(CAP_SYS_ADMIN))
> > >> +if (!perfmon_capable())
> > >>  return -EACCES;
> > >>  
> > >>  /*
> > > 
> > > This one only allows attaching to already extant kprobes, right? It does
> > > not allow creation of kprobes.
> > 
> > This unblocks creation of local trace kprobes and uprobes by 
> > CAP_SYS_PERFMON 
> > privileged process, exactly the same as for CAP_SYS_ADMIN privileged 
> > process.
> 
> I've no idea what you just said; it's just words.
> 
> Again, this only allows attaching to previously created kprobes, it does
> not allow creating kprobes, right?
> 
> That is; I don't think CAP_SYS_PERFMON should be allowed to create
> kprobes.
> 
> As might be clear; I don't actually know what the user-ABI is for
> creating kprobes.

There are 2 ABIs nowadays, ftrace and ebpf. perf-probe uses ftrace interface to
define new kprobe events, and those events are treated as completely same as
tracepoint events. On the other hand, ebpf tries to define new probe event
via perf_event interface. Above one is that interface. IOW, it creates new 
kprobe.

Thank you,


-- 
Masami Hiramatsu 
___
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 [CI,1/4] drm/i915: Start chopping up the GPU error capture

2020-01-10 Thread Patchwork
== Series Details ==

Series: series starting with [CI,1/4] drm/i915: Start chopping up the GPU error 
capture
URL   : https://patchwork.freedesktop.org/series/71885/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
d117616075ef drm/i915: Start chopping up the GPU error capture
-:90: CHECK:UNCOMMENTED_DEFINITION: struct mutex definition without comment
#90: FILE: drivers/gpu/drm/i915/gt/intel_gtt.h:348:
+   struct mutex error_mutex;

-:875: WARNING:MEMORY_BARRIER: memory barrier without comment
#875: FILE: drivers/gpu/drm/i915/i915_gpu_error.c:1019:
+   mb();

total: 0 errors, 1 warnings, 1 checks, 2333 lines checked
722c6f8f1369 drm/i915: Drop the shadow w/a batch buffer
f295e7438394 drm/i915: Drop the shadow ring state from the error capture
331533c19413 drm/i915: Drop request list from error state

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


[Intel-gfx] [PATCH v2] drm/i915/gt: Validate rotated vma bounds are within the object

2020-01-10 Thread Chris Wilson
Quite understandably, we bug out when asked to find a page that doesn't
belong to the object. However, we should report the error back to the
user long before we attempt the out-of-bound access! In this case, it is
insufficient validation on the rotated vma, with the simplest/cheapest
point for us to insert a bound check when we are computing the rotated
page lookups.

Similarly, it might be wise to see if we can validate the user input
upon creating the rotated framebuffer.

v2: Skip empty planes

Closes: https://gitlab.freedesktop.org/drm/intel/issues/951
Signed-off-by: Chris Wilson 
Cc: Ville Syrjälä 
Cc: Matthew Auld base.size >> PAGE_SHIFT;
unsigned int size = intel_rotation_info_size(rot_info);
struct sg_table *st;
struct scatterlist *sg;
@@ -1285,9 +1286,26 @@ intel_rotate_pages(struct intel_rotation_info *rot_info,
sg = st->sgl;
 
for (i = 0 ; i < ARRAY_SIZE(rot_info->plane); i++) {
-   sg = rotate_pages(obj, rot_info->plane[i].offset,
- rot_info->plane[i].width, 
rot_info->plane[i].height,
- rot_info->plane[i].stride, st, sg);
+   const struct intel_remapped_plane_info *plane =
+   &rot_info->plane[i];
+   unsigned long last;
+
+   if (!plane->height || !plane->width)
+   continue;
+
+   last = plane->offset;
+   last += (plane->height - 1) * plane->stride;
+   last += plane->width - 1;
+   if (last >= npages) {
+   ret = -EINVAL;
+   goto err_sg_alloc;
+   }
+
+   sg = rotate_pages(obj,
+ plane->offset,
+ plane->width, plane->height,
+ plane->stride,
+ st, sg);
}
 
return st;
@@ -1295,7 +1313,6 @@ intel_rotate_pages(struct intel_rotation_info *rot_info,
 err_sg_alloc:
kfree(st);
 err_st_alloc:
-
DRM_DEBUG_DRIVER("Failed to create rotated mapping for object size %zu! 
(%ux%u tiles, %u pages)\n",
 obj->base.size, rot_info->plane[0].width, 
rot_info->plane[0].height, size);
 
diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c 
b/drivers/gpu/drm/i915/selftests/i915_vma.c
index 58b5f40a07dd..24e7806867ef 100644
--- a/drivers/gpu/drm/i915/selftests/i915_vma.c
+++ b/drivers/gpu/drm/i915/selftests/i915_vma.c
@@ -962,6 +962,7 @@ static int igt_vma_remapped_gtt(void *arg)
   *t == 
I915_GGTT_VIEW_ROTATED ? "Rotated" : "Remapped",
   val, exp);
i915_vma_unpin_iomap(vma);
+   err = -EINVAL;
goto out;
}
}
-- 
2.25.0.rc2

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


Re: [Intel-gfx] [PATCH v2] drm/i915/gt: Validate rotated vma bounds are within the object

2020-01-10 Thread Chris Wilson
Quoting Chris Wilson (2020-01-10 15:53:34)
> Quite understandably, we bug out when asked to find a page that doesn't
> belong to the object. However, we should report the error back to the
> user long before we attempt the out-of-bound access! In this case, it is
> insufficient validation on the rotated vma, with the simplest/cheapest
> point for us to insert a bound check when we are computing the rotated
> page lookups.
> 
> Similarly, it might be wise to see if we can validate the user input
> upon creating the rotated framebuffer.
Reminder to self, scratch this comment. They are, it's just a bug.
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915/dp: Add current maximum eDP link rate to sink_rate array.

2020-01-10 Thread Mario Kleiner
On Thu, Jan 9, 2020 at 10:26 PM Harry Wentland  wrote:

>
>
> On 2020-01-09 4:04 p.m., Mario Kleiner wrote:
>
> On Thu, Jan 9, 2020 at 8:49 PM Alex Deucher  wrote:
>
>> On Thu, Jan 9, 2020 at 11:47 AM Mario Kleiner
>>  wrote:
>> >
>> > On Thu, Jan 9, 2020 at 4:40 PM Alex Deucher 
>> wrote:
>> >>
>> >> On Thu, Jan 9, 2020 at 10:08 AM Mario Kleiner
>> >>  wrote:
>> >> >
>> As Harry mentioned in the other thread, won't this only work if the
>> display was brought up by the vbios?  In the suspend/resume case,
>> won't we just fall back to 2.7Gbps?
>>
>> Alex
>>
>>
> Adding Harry to cc...
>
> The code is only executed for eDP. On the Intel side, it seems that
> intel_edp_init_dpcd() gets only called during driver load / modesetting
> init, so not on resume.
>
> On the AMD DC side, dc_link_detect_helper() has this early no-op return at
> the beginning:
>
> if ((link->connector_signal == SIGNAL_TYPE_LVDS ||
>   link->connector_signal == SIGNAL_TYPE_EDP) &&
>   link->local_sink)
>   return true;
>
>
> So i guess if link->local_sink doesn't get NULL'ed during a suspend/resume
> cycle, then we never reach the setup code that would overwrite with non
> vbios settings?
>
> Sounds reasonable to me, given that eDP panels are usually fixed internal
> panels, nothing that gets hot(un-)plugged?
>
> I can't test, because suspend/resume with the Polaris gpu on the MBP 2017
> is totally broken atm., just as vgaswitcheroo can't do its job. Looks like
> powering down the gpu works, but powering up doesn't. And also modesetting
> at vgaswitcheroo switch time is no-go, because the DDC/AUX lines apparently
> can't be switched on that Apple gmux, and handover of that data seems to be
> not implemented in current vgaswitcheroo. At the moment switching between
> AMD only or Intel+AMD Prime setup is quite a pita...
>
>
> I haven't followed the entire discussion on the i915 thread but for the
> amdgpu dc patch I would prefer a DPCD quirk to override the reported link
> settings with the correct link rate.
>
> Harry
>
>
Ok, as you wish. How do i do that? Is there already some DP related
official mechanism, or do i just add some if-statement to

detect_edp_sink_caps
()
that matches on a new EDID quirk to be defined for that panel in
drm_edid etc., and then

if (edit quirk for that panel)
dpcd[DP_MAX_LINK_RATE
] =
0xc;

The other question would be if we should do it for this panel on AMD DC at
all? I see my original patch more as something to fix other odd (Apple?)
panels, than for this specific one. As mentioned above, photometer testing
on AMD DC with a Polaris on the MBP 2017 suggests that the deault 2.7 Gbps
8 bit mode + AMD's spatial dithering provides higher quality results for >=
10 bpc framebuffers than actually running the panel at 10 bit without
dithering.

As a little side-note, for squeezing out more precision than the 10 bpc
framebuffers we officially have in Mesa/OpenGL, my software Psychtoolbox
has some special hacks, playing funny tricks with resizing X-Screens,
applying bit-twiddling shaders to images and MMIO programming the gpu
"behind the back" of the driver, to get the gpu into RGBA16161616 linear
scanout mode. That gives up to 12 bpc precision on that panel according to
photometer measurements. While AMD's dithering with the panel in 8 bit + 4
bit spatial dithering gives pretty good results, panel at 10 bit + 2 bit
spatial dithering has some artifacts. And even at a normal 10 bit
framebuffer, the 8 bit panel + 2 bit dithering seems to give better results
than 10 bit panel mode.

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


Re: [Intel-gfx] [PATCH i-g-t] test/i915_pm_rc6_residency: Check we enter RC6 when mostly idle

2020-01-10 Thread Imre Deak
On Thu, Jan 09, 2020 at 10:23:00PM +, Chris Wilson wrote:
> Long ago, we would only approach runtime-suspend if the GPU had been
> idle (no userspace submissions) for a second or two. However, since
> disabling automatic HW RC6 such a relaxed approach to runtime-suspend
> caused us to never enter RC6 on the desktop and consume vast quantities
> of power. Surmise this behaviour by setting up a background load that is
> only active for ~1% of the time (so equivalent to a compositor that is
> updating the clock every 50ms or so) and verify that we do continue to
> enter RC6 between the GPU pulses.
> 
> References: https://gitlab.freedesktop.org/drm/intel/issues/614
> Signed-off-by: Chris Wilson 
> Cc: Imre Deak 
> Cc: Tvrtko Ursulin 
> ---
>  tests/Makefile.am  |   1 +
>  tests/i915/i915_pm_rc6_residency.c | 174 +++--
>  tests/meson.build  |   9 +-
>  3 files changed, 173 insertions(+), 11 deletions(-)
> 
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 9a320bc23..fc3052475 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -122,6 +122,7 @@ gem_threaded_access_tiled_CFLAGS = $(AM_CFLAGS) 
> $(THREAD_CFLAGS)
>  gem_threaded_access_tiled_LDADD = $(LDADD) -lpthread
>  gem_tiled_swapping_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
>  gem_tiled_swapping_LDADD = $(LDADD) -lpthread
> +i915_pm_rc6_residency_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la
>  prime_self_import_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
>  prime_self_import_LDADD = $(LDADD) -lpthread
>  gem_userptr_blits_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
> diff --git a/tests/i915/i915_pm_rc6_residency.c 
> b/tests/i915/i915_pm_rc6_residency.c
> index 1b39c870e..a5bcb084b 100644
> --- a/tests/i915/i915_pm_rc6_residency.c
> +++ b/tests/i915/i915_pm_rc6_residency.c
> @@ -25,8 +25,6 @@
>   *
>   */
>  
> -#include "igt.h"
> -#include "igt_sysfs.h"
>  #include 
>  #include 
>  #include 
> @@ -34,6 +32,9 @@
>  #include 
>  #include 
>  
> +#include "igt.h"
> +#include "igt_perf.h"
> +#include "igt_sysfs.h"
>  
>  #define SLEEP_DURATION 3 /* in seconds */
>  
> @@ -195,31 +196,180 @@ static bool wait_for_rc6(void)
>   return false;
>  }
>  
> +static uint64_t __pmu_read_single(int fd, uint64_t *ts)
> +{
> + uint64_t data[2];
> +
> + igt_assert_eq(read(fd, data, sizeof(data)), sizeof(data));
> +
> + if (ts)
> + *ts = data[1];
> +
> + return data[0];
> +}
> +
> +static uint64_t pmu_read_single(int fd)
> +{
> + return __pmu_read_single(fd, NULL);
> +}
> +
> +#define __assert_within_epsilon(x, ref, tol_up, tol_down) \
> + igt_assert_f((double)(x) <= (1.0 + (tol_up)) * (double)(ref) && \
> +  (double)(x) >= (1.0 - (tol_down)) * (double)(ref), \
> +  "'%s' != '%s' (%f not within +%.1f%%/-%.1f%% tolerance of 
> %f)\n",\
> +  #x, #ref, (double)(x), \
> +  (tol_up) * 100.0, (tol_down) * 100.0, \
> +  (double)(ref))
> +
> +#define assert_within_epsilon(x, ref, tolerance) \
> + __assert_within_epsilon(x, ref, tolerance, tolerance)
> +
> +static bool __pmu_wait_for_rc6(int fd)
> +{
> + struct timespec tv = {};
> + uint64_t start, now;
> +
> + /* First wait for roughly an RC6 Evaluation Interval */
> + usleep(160 * 1000);
> +
> + /* Then poll for RC6 to start ticking */
> + now = pmu_read_single(fd);
> + do {
> + start = now;
> + usleep(5000);
> + now = pmu_read_single(fd);
> + if (now - start > 1e6)
> + return true;
> + } while (!igt_seconds_elapsed(&tv));
> +
> + return false;
> +}
> +
> +static unsigned int measured_usleep(unsigned int usec)
> +{
> + struct timespec ts = { };
> + unsigned int slept;
> +
> + slept = igt_nsec_elapsed(&ts);
> + igt_assert(slept == 0);
> + do {
> + usleep(usec - slept);
> + slept = igt_nsec_elapsed(&ts) / 1000;
> + } while (slept < usec);
> +
> + return igt_nsec_elapsed(&ts);
> +}
> +
> +static uint32_t batch_create(int fd)
> +{
> + const uint32_t bbe = MI_BATCH_BUFFER_END;
> + uint32_t handle;
> +
> + handle = gem_create(fd, 4096);
> + gem_write(fd, handle, 0, &bbe, sizeof(bbe));
> +
> + return handle;
> +}
> +
> +static int open_pmu(int i915, uint64_t config)
> +{
> + int fd;
> +
> + fd = perf_i915_open(config);
> + igt_skip_on(fd < 0 && errno == ENODEV);
> + igt_assert(fd >= 0);
> +
> + return fd;
> +}
> +
> +static void rc6_perf(int i915)
> +{
> + const int64_t duration_ns = 2e9;
> + uint64_t idle, prev, ts[2];
> + unsigned long slept, cycles;
> + unsigned long *done;
> + int fd;
> +
> + fd = open_pmu(i915, I915_PMU_RC6_RESIDENCY);
> + igt_require(__pmu_wait_for_rc6(fd));
> +
> + /* While idle check full RC6. */
> + prev = __pmu_read_single(fd, &ts[0]);
> + slept = measured_usleep(duration_ns / 1000)

[Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [CI,1/4] drm/i915: Start chopping up the GPU error capture

2020-01-10 Thread Patchwork
== Series Details ==

Series: series starting with [CI,1/4] drm/i915: Start chopping up the GPU error 
capture
URL   : https://patchwork.freedesktop.org/series/71885/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_7718 -> Patchwork_16051


Summary
---

  **SUCCESS**

  No regressions found.

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

Known issues


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

### IGT changes ###

 Issues hit 

  * igt@i915_module_load@reload-with-fault-injection:
- fi-cfl-guc: [PASS][1] -> [DMESG-WARN][2] ([i915#889])
   [1]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-cfl-guc/igt@i915_module_l...@reload-with-fault-injection.html
   [2]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16051/fi-cfl-guc/igt@i915_module_l...@reload-with-fault-injection.html
- fi-skl-6770hq:  [PASS][3] -> [DMESG-WARN][4] ([i915#88])
   [3]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-skl-6770hq/igt@i915_module_l...@reload-with-fault-injection.html
   [4]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16051/fi-skl-6770hq/igt@i915_module_l...@reload-with-fault-injection.html

  * igt@i915_pm_rpm@module-reload:
- fi-cfl-guc: [PASS][5] -> [INCOMPLETE][6] ([i915#148])
   [5]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-cfl-guc/igt@i915_pm_...@module-reload.html
   [6]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16051/fi-cfl-guc/igt@i915_pm_...@module-reload.html

  * igt@i915_selftest@live_gem_contexts:
- fi-hsw-peppy:   [PASS][7] -> [DMESG-FAIL][8] ([i915#722])
   [7]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-hsw-peppy/igt@i915_selftest@live_gem_contexts.html
   [8]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16051/fi-hsw-peppy/igt@i915_selftest@live_gem_contexts.html

  * igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy:   [PASS][9] -> [DMESG-WARN][10] ([i915#44])
   [9]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-hsw-peppy/igt@kms_frontbuffer_track...@basic.html
   [10]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16051/fi-hsw-peppy/igt@kms_frontbuffer_track...@basic.html

  
 Possible fixes 

  * {igt@gem_exec_basic@basic@bcs0}:
- fi-byt-n2820:   [FAIL][11] ([i915#694]) -> [PASS][12]
   [11]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-byt-n2820/igt@gem_exec_basic@ba...@bcs0.html
   [12]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16051/fi-byt-n2820/igt@gem_exec_basic@ba...@bcs0.html

  * {igt@gem_exec_basic@basic@vcs0}:
- fi-byt-n2820:   [WARN][13] -> [PASS][14]
   [13]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-byt-n2820/igt@gem_exec_basic@ba...@vcs0.html
   [14]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16051/fi-byt-n2820/igt@gem_exec_basic@ba...@vcs0.html

  * igt@i915_module_load@reload-with-fault-injection:
- fi-kbl-x1275:   [INCOMPLETE][15] ([i915#879]) -> [PASS][16]
   [15]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-kbl-x1275/igt@i915_module_l...@reload-with-fault-injection.html
   [16]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16051/fi-kbl-x1275/igt@i915_module_l...@reload-with-fault-injection.html

  * igt@i915_pm_rpm@module-reload:
- fi-skl-6770hq:  [FAIL][17] ([i915#178]) -> [PASS][18]
   [17]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-skl-6770hq/igt@i915_pm_...@module-reload.html
   [18]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16051/fi-skl-6770hq/igt@i915_pm_...@module-reload.html

  * igt@i915_selftest@live_blt:
- fi-hsw-4770:[DMESG-FAIL][19] ([i915#563]) -> [PASS][20]
   [19]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-hsw-4770/igt@i915_selftest@live_blt.html
   [20]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16051/fi-hsw-4770/igt@i915_selftest@live_blt.html

  * igt@i915_selftest@live_execlists:
- fi-kbl-soraka:  [DMESG-FAIL][21] ([i915#656]) -> [PASS][22]
   [21]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-kbl-soraka/igt@i915_selftest@live_execlists.html
   [22]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16051/fi-kbl-soraka/igt@i915_selftest@live_execlists.html

  
 Warnings 

  * igt@i915_selftest@live_blt:
- fi-hsw-4770r:   [DMESG-FAIL][23] ([i915#725]) -> [DMESG-FAIL][24] 
([i915#553] / [i915#725])
   [23]: 
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7718/fi-hsw-4770r/igt@i915_selftest@live_blt.html
   [24]: 
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16051/fi-hsw-4770r/igt@i915_selftest@live_blt.html

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

  [i915#148]: https://gitlab.freedesktop.org/drm/intel/issues/148
  [i915#178]: https:/

Re: [Intel-gfx] [PATCH i-g-t] test/i915_pm_rc6_residency: Check we enter RC6 when mostly idle

2020-01-10 Thread Chris Wilson
Quoting Imre Deak (2020-01-10 16:16:27)
> On Thu, Jan 09, 2020 at 10:23:00PM +, Chris Wilson wrote:
> > Long ago, we would only approach runtime-suspend if the GPU had been
> > idle (no userspace submissions) for a second or two. However, since
> > disabling automatic HW RC6 such a relaxed approach to runtime-suspend
> > caused us to never enter RC6 on the desktop and consume vast quantities
> > of power. Surmise this behaviour by setting up a background load that is
> > only active for ~1% of the time (so equivalent to a compositor that is
> > updating the clock every 50ms or so) and verify that we do continue to
> > enter RC6 between the GPU pulses.
> > 
> > References: https://gitlab.freedesktop.org/drm/intel/issues/614
> > Signed-off-by: Chris Wilson 
> > Cc: Imre Deak 
> > Cc: Tvrtko Ursulin 
> > ---
> >  tests/Makefile.am  |   1 +
> >  tests/i915/i915_pm_rc6_residency.c | 174 +++--
> >  tests/meson.build  |   9 +-
> >  3 files changed, 173 insertions(+), 11 deletions(-)
> > 
> > diff --git a/tests/Makefile.am b/tests/Makefile.am
> > index 9a320bc23..fc3052475 100644
> > --- a/tests/Makefile.am
> > +++ b/tests/Makefile.am
> > @@ -122,6 +122,7 @@ gem_threaded_access_tiled_CFLAGS = $(AM_CFLAGS) 
> > $(THREAD_CFLAGS)
> >  gem_threaded_access_tiled_LDADD = $(LDADD) -lpthread
> >  gem_tiled_swapping_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
> >  gem_tiled_swapping_LDADD = $(LDADD) -lpthread
> > +i915_pm_rc6_residency_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la
> >  prime_self_import_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
> >  prime_self_import_LDADD = $(LDADD) -lpthread
> >  gem_userptr_blits_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
> > diff --git a/tests/i915/i915_pm_rc6_residency.c 
> > b/tests/i915/i915_pm_rc6_residency.c
> > index 1b39c870e..a5bcb084b 100644
> > --- a/tests/i915/i915_pm_rc6_residency.c
> > +++ b/tests/i915/i915_pm_rc6_residency.c
> > @@ -25,8 +25,6 @@
> >   *
> >   */
> >  
> > -#include "igt.h"
> > -#include "igt_sysfs.h"
> >  #include 
> >  #include 
> >  #include 
> > @@ -34,6 +32,9 @@
> >  #include 
> >  #include 
> >  
> > +#include "igt.h"
> > +#include "igt_perf.h"
> > +#include "igt_sysfs.h"
> >  
> >  #define SLEEP_DURATION 3 /* in seconds */
> >  
> > @@ -195,31 +196,180 @@ static bool wait_for_rc6(void)
> >   return false;
> >  }
> >  
> > +static uint64_t __pmu_read_single(int fd, uint64_t *ts)
> > +{
> > + uint64_t data[2];
> > +
> > + igt_assert_eq(read(fd, data, sizeof(data)), sizeof(data));
> > +
> > + if (ts)
> > + *ts = data[1];
> > +
> > + return data[0];
> > +}
> > +
> > +static uint64_t pmu_read_single(int fd)
> > +{
> > + return __pmu_read_single(fd, NULL);
> > +}
> > +
> > +#define __assert_within_epsilon(x, ref, tol_up, tol_down) \
> > + igt_assert_f((double)(x) <= (1.0 + (tol_up)) * (double)(ref) && \
> > +  (double)(x) >= (1.0 - (tol_down)) * (double)(ref), \
> > +  "'%s' != '%s' (%f not within +%.1f%%/-%.1f%% tolerance 
> > of %f)\n",\
> > +  #x, #ref, (double)(x), \
> > +  (tol_up) * 100.0, (tol_down) * 100.0, \
> > +  (double)(ref))
> > +
> > +#define assert_within_epsilon(x, ref, tolerance) \
> > + __assert_within_epsilon(x, ref, tolerance, tolerance)
> > +
> > +static bool __pmu_wait_for_rc6(int fd)
> > +{
> > + struct timespec tv = {};
> > + uint64_t start, now;
> > +
> > + /* First wait for roughly an RC6 Evaluation Interval */
> > + usleep(160 * 1000);
> > +
> > + /* Then poll for RC6 to start ticking */
> > + now = pmu_read_single(fd);
> > + do {
> > + start = now;
> > + usleep(5000);
> > + now = pmu_read_single(fd);
> > + if (now - start > 1e6)
> > + return true;
> > + } while (!igt_seconds_elapsed(&tv));
> > +
> > + return false;
> > +}
> > +
> > +static unsigned int measured_usleep(unsigned int usec)
> > +{
> > + struct timespec ts = { };
> > + unsigned int slept;
> > +
> > + slept = igt_nsec_elapsed(&ts);
> > + igt_assert(slept == 0);
> > + do {
> > + usleep(usec - slept);
> > + slept = igt_nsec_elapsed(&ts) / 1000;
> > + } while (slept < usec);
> > +
> > + return igt_nsec_elapsed(&ts);
> > +}
> > +
> > +static uint32_t batch_create(int fd)
> > +{
> > + const uint32_t bbe = MI_BATCH_BUFFER_END;
> > + uint32_t handle;
> > +
> > + handle = gem_create(fd, 4096);
> > + gem_write(fd, handle, 0, &bbe, sizeof(bbe));
> > +
> > + return handle;
> > +}
> > +
> > +static int open_pmu(int i915, uint64_t config)
> > +{
> > + int fd;
> > +
> > + fd = perf_i915_open(config);
> > + igt_skip_on(fd < 0 && errno == ENODEV);
> > + igt_assert(fd >= 0);
> > +
> > + return fd;
> > +}
> > +
> > +static void rc6_perf(int i915)
> > +{
> > + const int64_t duration_ns = 2e9;
> > + uint64_t i

[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Per client engine busyness (rev3)

2020-01-10 Thread Patchwork
== Series Details ==

Series: Per client engine busyness (rev3)
URL   : https://patchwork.freedesktop.org/series/70977/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
f2a2ab0fb90e drm/i915: Expose list of clients in sysfs
-:61: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does 
MAINTAINERS need updating?
#61: 
new file mode 100644

-:66: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier 
tag in line 1
#66: FILE: drivers/gpu/drm/i915/i915_drm_client.c:1:
+/*

-:67: WARNING:SPDX_LICENSE_TAG: Misplaced SPDX-License-Identifier tag - use 
line 1 instead
#67: FILE: drivers/gpu/drm/i915/i915_drm_client.c:2:
+ * SPDX-License-Identifier: MIT

-:222: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier 
tag in line 1
#222: FILE: drivers/gpu/drm/i915/i915_drm_client.h:1:
+/*

-:223: WARNING:SPDX_LICENSE_TAG: Misplaced SPDX-License-Identifier tag - use 
line 1 instead
#223: FILE: drivers/gpu/drm/i915/i915_drm_client.h:2:
+ * SPDX-License-Identifier: MIT

total: 0 errors, 5 warnings, 0 checks, 338 lines checked
4cd0960d1b2d drm/i915: Update client name on context create
b69ea9c5500b drm/i915: Track per-context engine busyness
3878342bf2cc drm/i915: Track all user contexts per client
-:56: CHECK:MULTIPLE_ASSIGNMENTS: multiple assignments should be avoided
#56: FILE: drivers/gpu/drm/i915/gem/i915_gem_context.c:808:
+   ctx->client = client = i915_drm_client_get(fpriv->client);

-:116: CHECK:UNCOMMENTED_DEFINITION: spinlock_t definition without comment
#116: FILE: drivers/gpu/drm/i915/i915_drm_client.h:35:
+   spinlock_t ctx_lock;

total: 0 errors, 0 warnings, 2 checks, 84 lines checked
342d49e806c4 drm/i915: Contexts can use struct pid stored in the client
eb3f14196571 drm/i915: Expose per-engine client busyness
-:25: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description 
(prefer a maximum 75 chars per line)
#25: 
 Render/3D/0   63.73% |███   |  3%  0%

-:107: WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should 
probably be static const char * const
#107: FILE: drivers/gpu/drm/i915/i915_drm_client.c:82:
+static const char *uabi_class_names[] = {

-:132: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#132: FILE: drivers/gpu/drm/i915/i915_drm_client.c:133:
+   if (HAS_LOGICAL_RING_CONTEXTS(i915)) {$

-:132: WARNING:SUSPECT_CODE_INDENT: suspect code indent for conditional 
statements (7, 16)
#132: FILE: drivers/gpu/drm/i915/i915_drm_client.c:133:
+   if (HAS_LOGICAL_RING_CONTEXTS(i915)) {
+   client->busy_root =

-:189: WARNING:LEADING_SPACE: please, no spaces at the start of a line
#189: FILE: drivers/gpu/drm/i915/i915_drm_client.c:190:
+   }$

total: 0 errors, 5 warnings, 0 checks, 198 lines checked
0f5c8f1a3375 drm/i915: Track hw reported context runtime
-:72: CHECK:MULTIPLE_ASSIGNMENTS: multiple assignments should be avoided
#72: FILE: drivers/gpu/drm/i915/gt/intel_lrc.c:1314:
+   ce->last_runtime = new = ce->pphwsp[16];

total: 0 errors, 0 warnings, 1 checks, 70 lines checked
82e4aff984e7 drm/i915: Fallback to hw context runtime when sw tracking is not 
available

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


[Intel-gfx] [PATCH v2 4/4] drm/i915/uc: Add sanitize to to intel_uc_ops

2020-01-10 Thread Michal Wajdeczko
uC sanitization is only meaningful if we are running with uC present
or enabled. Make this function part of the uc_ops.

Signed-off-by: Michal Wajdeczko 
Cc: Joonas Lahtinen 
Cc: Chris Wilson 
Cc: Daniele Ceraolo Spurio 
---
 drivers/gpu/drm/i915/gt/uc/intel_uc.c | 10 ++
 drivers/gpu/drm/i915/gt/uc/intel_uc.h |  3 ++-
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.c 
b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
index 1b07135a8515..c1d5af775713 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
@@ -12,6 +12,7 @@
 
 #include "i915_drv.h"
 
+static int __uc_sanitize(struct intel_uc *uc);
 static void __uc_fetch_firmwares(struct intel_uc *uc);
 static void __uc_cleanup_firmwares(struct intel_uc *uc);
 static void __uc_init(struct intel_uc *uc);
@@ -25,6 +26,7 @@ static const struct intel_uc_ops uc_ops_off = {
 };
 
 static const struct intel_uc_ops uc_ops_on = {
+   .sanitize = __uc_sanitize,
.init_fw = __uc_fetch_firmwares,
.fini_fw = __uc_cleanup_firmwares,
.init = __uc_init,
@@ -333,14 +335,6 @@ static int __uc_sanitize(struct intel_uc *uc)
return __intel_uc_reset_hw(uc);
 }
 
-void intel_uc_sanitize(struct intel_uc *uc)
-{
-   if (!intel_uc_supports_guc(uc))
-   return;
-
-   __uc_sanitize(uc);
-}
-
 /* Initialize and verify the uC regs related to uC positioning in WOPCM */
 static int uc_init_wopcm(struct intel_uc *uc)
 {
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.h 
b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
index 8c0ce0d9f190..49c913524686 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.h
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
@@ -13,6 +13,7 @@
 struct intel_uc;
 
 struct intel_uc_ops {
+   int (*sanitize)(struct intel_uc *uc);
void (*init_fw)(struct intel_uc *uc);
void (*fini_fw)(struct intel_uc *uc);
void (*init)(struct intel_uc *uc);
@@ -33,7 +34,6 @@ struct intel_uc {
 void intel_uc_init_early(struct intel_uc *uc);
 void intel_uc_driver_late_release(struct intel_uc *uc);
 void intel_uc_init_mmio(struct intel_uc *uc);
-void intel_uc_sanitize(struct intel_uc *uc);
 void intel_uc_reset_prepare(struct intel_uc *uc);
 void intel_uc_suspend(struct intel_uc *uc);
 void intel_uc_runtime_suspend(struct intel_uc *uc);
@@ -77,6 +77,7 @@ static inline _TYPE intel_uc_##_NAME(struct intel_uc *uc) \
return uc->ops->_OPS(uc); \
return _RET; \
 }
+intel_uc_ops_function(sanitize, sanitize, int, 0);
 intel_uc_ops_function(fetch_firmwares, init_fw, void, );
 intel_uc_ops_function(cleanup_firmwares, fini_fw, void, );
 intel_uc_ops_function(init, init, void, );
-- 
2.19.2

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


[Intel-gfx] [PATCH v2 3/4] drm/i915/uc: Add init/fini to to intel_uc_ops

2020-01-10 Thread Michal Wajdeczko
uC preparation and cleanup steps are only meaningful if we are
running with uC enabled. Make these functions part of the uc_ops.

Signed-off-by: Michal Wajdeczko 
Cc: Joonas Lahtinen 
Cc: Chris Wilson 
Cc: Daniele Ceraolo Spurio 
---
 drivers/gpu/drm/i915/gt/uc/intel_uc.c | 12 +++-
 drivers/gpu/drm/i915/gt/uc/intel_uc.h |  6 --
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.c 
b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
index 133cbc360a7d..1b07135a8515 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
@@ -14,6 +14,8 @@
 
 static void __uc_fetch_firmwares(struct intel_uc *uc);
 static void __uc_cleanup_firmwares(struct intel_uc *uc);
+static void __uc_init(struct intel_uc *uc);
+static void __uc_fini(struct intel_uc *uc);
 static int __uc_check_hw(struct intel_uc *uc);
 static int __uc_init_hw(struct intel_uc *uc);
 static void __uc_fini_hw(struct intel_uc *uc);
@@ -25,7 +27,8 @@ static const struct intel_uc_ops uc_ops_off = {
 static const struct intel_uc_ops uc_ops_on = {
.init_fw = __uc_fetch_firmwares,
.fini_fw = __uc_cleanup_firmwares,
-
+   .init = __uc_init,
+   .fini = __uc_fini,
.init_hw = __uc_init_hw,
.fini_hw = __uc_fini_hw,
 };
@@ -288,14 +291,13 @@ static void __uc_cleanup_firmwares(struct intel_uc *uc)
intel_uc_fw_cleanup_fetch(&uc->guc.fw);
 }
 
-void intel_uc_init(struct intel_uc *uc)
+static void __uc_init(struct intel_uc *uc)
 {
struct intel_guc *guc = &uc->guc;
struct intel_huc *huc = &uc->huc;
int ret;
 
-   if (!intel_uc_uses_guc(uc))
-   return;
+   GEM_BUG_ON(!intel_uc_uses_guc(uc));
 
/* XXX: GuC submission is unavailable for now */
GEM_BUG_ON(intel_uc_supports_guc_submission(uc));
@@ -310,7 +312,7 @@ void intel_uc_init(struct intel_uc *uc)
intel_huc_init(huc);
 }
 
-void intel_uc_fini(struct intel_uc *uc)
+static void __uc_fini(struct intel_uc *uc)
 {
intel_huc_fini(&uc->huc);
intel_guc_fini(&uc->guc);
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.h 
b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
index 47c7c8add451..8c0ce0d9f190 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.h
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
@@ -15,6 +15,8 @@ struct intel_uc;
 struct intel_uc_ops {
void (*init_fw)(struct intel_uc *uc);
void (*fini_fw)(struct intel_uc *uc);
+   void (*init)(struct intel_uc *uc);
+   void (*fini)(struct intel_uc *uc);
int (*init_hw)(struct intel_uc *uc);
void (*fini_hw)(struct intel_uc *uc);
 };
@@ -32,8 +34,6 @@ void intel_uc_init_early(struct intel_uc *uc);
 void intel_uc_driver_late_release(struct intel_uc *uc);
 void intel_uc_init_mmio(struct intel_uc *uc);
 void intel_uc_sanitize(struct intel_uc *uc);
-void intel_uc_init(struct intel_uc *uc);
-void intel_uc_fini(struct intel_uc *uc);
 void intel_uc_reset_prepare(struct intel_uc *uc);
 void intel_uc_suspend(struct intel_uc *uc);
 void intel_uc_runtime_suspend(struct intel_uc *uc);
@@ -79,6 +79,8 @@ static inline _TYPE intel_uc_##_NAME(struct intel_uc *uc) \
 }
 intel_uc_ops_function(fetch_firmwares, init_fw, void, );
 intel_uc_ops_function(cleanup_firmwares, fini_fw, void, );
+intel_uc_ops_function(init, init, void, );
+intel_uc_ops_function(fini, fini, void, );
 intel_uc_ops_function(init_hw, init_hw, int, 0);
 intel_uc_ops_function(fini_hw, fini_hw, void, );
 #undef intel_uc_ops_function
-- 
2.19.2

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


[Intel-gfx] [PATCH v2 1/4] drm/i915/uc: Add ops to intel_uc

2020-01-10 Thread Michal Wajdeczko
Instead of spreading multiple conditionals across the uC code
to find out current mode of uC operation, start using predefined
set of function pointers that reflect that mode.

Begin with pair of init_hw/fini_hw functions that are responsible
for uC hardware initialization and cleanup.

v2: drop ops_none, use macro to generate ops helpers

Signed-off-by: Michal Wajdeczko 
Cc: Joonas Lahtinen 
Cc: Chris Wilson 
Cc: Daniele Ceraolo Spurio 
---
 drivers/gpu/drm/i915/gt/uc/intel_uc.c | 45 ++-
 drivers/gpu/drm/i915/gt/uc/intel_uc.h | 21 +++--
 2 files changed, 57 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.c 
b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
index 3ffc6267f96e..da401e97bba3 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
@@ -12,6 +12,19 @@
 
 #include "i915_drv.h"
 
+static int __uc_check_hw(struct intel_uc *uc);
+static int __uc_init_hw(struct intel_uc *uc);
+static void __uc_fini_hw(struct intel_uc *uc);
+
+static const struct intel_uc_ops uc_ops_off = {
+   .init_hw = __uc_check_hw,
+};
+
+static const struct intel_uc_ops uc_ops_on = {
+   .init_hw = __uc_init_hw,
+   .fini_hw = __uc_fini_hw,
+};
+
 /* Reset GuC providing us with fresh state for both GuC and HuC.
  */
 static int __intel_uc_reset_hw(struct intel_uc *uc)
@@ -89,6 +102,11 @@ void intel_uc_init_early(struct intel_uc *uc)
intel_huc_init_early(&uc->huc);
 
__confirm_options(uc);
+
+   if (intel_uc_uses_guc(uc))
+   uc->ops = &uc_ops_on;
+   else
+   uc->ops = &uc_ops_off;
 }
 
 void intel_uc_driver_late_release(struct intel_uc *uc)
@@ -380,24 +398,37 @@ static bool uc_is_wopcm_locked(struct intel_uc *uc)
   (intel_uncore_read(uncore, DMA_GUC_WOPCM_OFFSET) & 
GUC_WOPCM_OFFSET_VALID);
 }
 
-int intel_uc_init_hw(struct intel_uc *uc)
+static int __uc_check_hw(struct intel_uc *uc)
+{
+   if (!intel_uc_supports_guc(uc))
+   return 0;
+
+   /*
+* We can silently continue without GuC only if it was never enabled
+* before on this system after reboot, otherwise we risk GPU hangs.
+* To check if GuC was loaded before we look at WOPCM registers.
+*/
+   if (uc_is_wopcm_locked(uc))
+   return -EIO;
+
+   return 0;
+}
+
+static int __uc_init_hw(struct intel_uc *uc)
 {
struct drm_i915_private *i915 = uc_to_gt(uc)->i915;
struct intel_guc *guc = &uc->guc;
struct intel_huc *huc = &uc->huc;
int ret, attempts;
 
-   if (!intel_uc_supports_guc(uc))
-   return 0;
+   GEM_BUG_ON(!intel_uc_supports_guc(uc));
+   GEM_BUG_ON(!intel_uc_uses_guc(uc));
 
/*
 * We can silently continue without GuC only if it was never enabled
 * before on this system after reboot, otherwise we risk GPU hangs.
 * To check if GuC was loaded before we look at WOPCM registers.
 */
-   if (!intel_uc_uses_guc(uc) && !uc_is_wopcm_locked(uc))
-   return 0;
-
if (!intel_uc_fw_is_available(&guc->fw)) {
ret = uc_is_wopcm_locked(uc) ||
  intel_uc_fw_is_overridden(&guc->fw) ||
@@ -495,7 +526,7 @@ int intel_uc_init_hw(struct intel_uc *uc)
return -EIO;
 }
 
-void intel_uc_fini_hw(struct intel_uc *uc)
+static void __uc_fini_hw(struct intel_uc *uc)
 {
struct intel_guc *guc = &uc->guc;
 
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.h 
b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
index 527995c21196..d5c2d4cf1d38 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.h
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
@@ -10,7 +10,15 @@
 #include "intel_huc.h"
 #include "i915_params.h"
 
+struct intel_uc;
+
+struct intel_uc_ops {
+   int (*init_hw)(struct intel_uc *uc);
+   void (*fini_hw)(struct intel_uc *uc);
+};
+
 struct intel_uc {
+   struct intel_uc_ops const *ops;
struct intel_guc guc;
struct intel_huc huc;
 
@@ -25,8 +33,6 @@ void intel_uc_fetch_firmwares(struct intel_uc *uc);
 void intel_uc_cleanup_firmwares(struct intel_uc *uc);
 void intel_uc_sanitize(struct intel_uc *uc);
 void intel_uc_init(struct intel_uc *uc);
-int intel_uc_init_hw(struct intel_uc *uc);
-void intel_uc_fini_hw(struct intel_uc *uc);
 void intel_uc_fini(struct intel_uc *uc);
 void intel_uc_reset_prepare(struct intel_uc *uc);
 void intel_uc_suspend(struct intel_uc *uc);
@@ -64,4 +70,15 @@ static inline bool intel_uc_uses_huc(struct intel_uc *uc)
return intel_huc_is_enabled(&uc->huc);
 }
 
+#define intel_uc_ops_function(_NAME, _OPS, _TYPE, _RET) \
+static inline _TYPE intel_uc_##_NAME(struct intel_uc *uc) \
+{ \
+   if (uc->ops->_OPS) \
+   return uc->ops->_OPS(uc); \
+   return _RET; \
+}
+intel_uc_ops_function(init_hw, init_hw, int, 0);
+intel_uc_ops_function(fini_hw, fini_hw, void, );
+#undef intel_uc_ops_function
+
 #endif
-- 
2.19.2


[Intel-gfx] [PATCH v2 2/4] drm/i915/uc: Add init_fw/fini_fw to to intel_uc_ops

2020-01-10 Thread Michal Wajdeczko
Firmware fetching and cleanup steps are only meaningful if we are
running with uC enabled. Make these functions part of the uc_ops.

Signed-off-by: Michal Wajdeczko 
Cc: Joonas Lahtinen 
Cc: Chris Wilson 
Cc: Daniele Ceraolo Spurio 
---
 drivers/gpu/drm/i915/gt/uc/intel_uc.c | 12 
 drivers/gpu/drm/i915/gt/uc/intel_uc.h |  6 --
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.c 
b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
index da401e97bba3..133cbc360a7d 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
@@ -12,6 +12,8 @@
 
 #include "i915_drv.h"
 
+static void __uc_fetch_firmwares(struct intel_uc *uc);
+static void __uc_cleanup_firmwares(struct intel_uc *uc);
 static int __uc_check_hw(struct intel_uc *uc);
 static int __uc_init_hw(struct intel_uc *uc);
 static void __uc_fini_hw(struct intel_uc *uc);
@@ -21,6 +23,9 @@ static const struct intel_uc_ops uc_ops_off = {
 };
 
 static const struct intel_uc_ops uc_ops_on = {
+   .init_fw = __uc_fetch_firmwares,
+   .fini_fw = __uc_cleanup_firmwares,
+
.init_hw = __uc_init_hw,
.fini_hw = __uc_fini_hw,
 };
@@ -263,12 +268,11 @@ static void guc_disable_communication(struct intel_guc 
*guc)
DRM_INFO("GuC communication disabled\n");
 }
 
-void intel_uc_fetch_firmwares(struct intel_uc *uc)
+static void __uc_fetch_firmwares(struct intel_uc *uc)
 {
int err;
 
-   if (!intel_uc_uses_guc(uc))
-   return;
+   GEM_BUG_ON(!intel_uc_uses_guc(uc));
 
err = intel_uc_fw_fetch(&uc->guc.fw);
if (err)
@@ -278,7 +282,7 @@ void intel_uc_fetch_firmwares(struct intel_uc *uc)
intel_uc_fw_fetch(&uc->huc.fw);
 }
 
-void intel_uc_cleanup_firmwares(struct intel_uc *uc)
+static void __uc_cleanup_firmwares(struct intel_uc *uc)
 {
intel_uc_fw_cleanup_fetch(&uc->huc.fw);
intel_uc_fw_cleanup_fetch(&uc->guc.fw);
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.h 
b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
index d5c2d4cf1d38..47c7c8add451 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.h
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
@@ -13,6 +13,8 @@
 struct intel_uc;
 
 struct intel_uc_ops {
+   void (*init_fw)(struct intel_uc *uc);
+   void (*fini_fw)(struct intel_uc *uc);
int (*init_hw)(struct intel_uc *uc);
void (*fini_hw)(struct intel_uc *uc);
 };
@@ -29,8 +31,6 @@ struct intel_uc {
 void intel_uc_init_early(struct intel_uc *uc);
 void intel_uc_driver_late_release(struct intel_uc *uc);
 void intel_uc_init_mmio(struct intel_uc *uc);
-void intel_uc_fetch_firmwares(struct intel_uc *uc);
-void intel_uc_cleanup_firmwares(struct intel_uc *uc);
 void intel_uc_sanitize(struct intel_uc *uc);
 void intel_uc_init(struct intel_uc *uc);
 void intel_uc_fini(struct intel_uc *uc);
@@ -77,6 +77,8 @@ static inline _TYPE intel_uc_##_NAME(struct intel_uc *uc) \
return uc->ops->_OPS(uc); \
return _RET; \
 }
+intel_uc_ops_function(fetch_firmwares, init_fw, void, );
+intel_uc_ops_function(cleanup_firmwares, fini_fw, void, );
 intel_uc_ops_function(init_hw, init_hw, int, 0);
 intel_uc_ops_function(fini_hw, fini_hw, void, );
 #undef intel_uc_ops_function
-- 
2.19.2

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


[Intel-gfx] [PATCH v2 0/4] Add ops to intel_uc

2020-01-10 Thread Michal Wajdeczko
Instead of spreading multiple conditionals across the uC code
to find out current mode of uC operation, start using predefined
set of function pointers that reflect that mode.

v2: rebased, using macro to generate ops helpers 

Michal Wajdeczko (4):
  drm/i915/uc: Add ops to intel_uc
  drm/i915/uc: Add init_fw/fini_fw to to intel_uc_ops
  drm/i915/uc: Add init/fini to to intel_uc_ops
  drm/i915/uc: Add sanitize to to intel_uc_ops

 drivers/gpu/drm/i915/gt/uc/intel_uc.c | 77 +++
 drivers/gpu/drm/i915/gt/uc/intel_uc.h | 36 ++---
 2 files changed, 83 insertions(+), 30 deletions(-)

-- 
2.19.2

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


  1   2   >