Re: [Intel-gfx] [PATCH v4 3/4] drm/i915: Use new CRC debugfs API
On 5 September 2016 at 14:44, Emil Velikovwrote: > On 5 September 2016 at 10:45, Tomeu Vizoso wrote: >> On 2 September 2016 at 17:18, Emil Velikov wrote: >>> Hi Tomeu, >>> >>> IMHO it would be better to split out the refactoring into preparatory >>> patch. It brings a minor change which (not 100% sure on that) should >>> not cause issues but is worth pointing out. >> >> I think at this point it would make sense to change the series >> structure only if there was a strong reason, as a few people have >> already looked at the patches already. >> >>> On 5 August 2016 at 11:45, Tomeu Vizoso wrote: >>> +static int do_set_crc_source(struct drm_device *dev, enum pipe pipe, +enum intel_pipe_crc_source source) +{ >>> + if (source == INTEL_PIPE_CRC_SOURCE_NONE) { >>> Nit: use !source here or sourse != INTEL_PIPE_CRC_SOURCE_NONE >>> elsewhere in the code ? >> >> Agreed. >> >>> @@ -693,10 +718,11 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, spin_unlock_irq(_crc->lock); } - pipe_crc->source = source; + ret = do_set_crc_source(dev, pipe, source); + if (ret) + goto out; >>> We seem to have modified pipe_crc even if the new function fails. >>> Haven't check if it matters, but definatelly not ideal. >> >> If we had modified pipe_crc that's because we were trying to start CRC >> capture and we initialized the entry storage. As CRC generation is >> disabled, those changes have no effects. When CRC capture is attempted >> again, they will be initialized again. >> >> To avoid this we would need to split the HW programming in two >> functions and I'm not sure it would be worth it. >> > A simple way out will be to keep the "can fail" hunk at the top > separate from the rest. This way even if things get reinitialised > correctly currently, they won't break if someone applies the > (perfectly reasonable imho) assumption "function does not modify any > data when it fails". > > @@ -720,15 +746,6 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe, spin_unlock_irq(_crc->lock); kfree(entries); - - if (IS_G4X(dev)) - g4x_undo_pipe_scramble_reset(dev, pipe); - else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) - vlv_undo_pipe_scramble_reset(dev, pipe); - else if (IS_HASWELL(dev) && pipe == PIPE_A) - hsw_trans_edp_pipe_A_crc_wa(dev, false); - - hsw_enable_ips(crtc); >>> The above is the piece I have in mind: >>> With the introduction of do_set_crc_source() the above are executed >>> prior to the intel_wait_for_vblank() call. >>> >>> Afaics this will not cause any functional change, then again I'm not >>> that familiar with the i915 vblank code. >> >> Yeah, not sure either of when do those changes take effect. >> > With this said, it would be way better to keep it separate (with a big > fat warning in the commit summary). > > Speaking of which - why did you fold the separate bugfix/workaround > "skip the first one or two frames" in v5 ? Shouldn't it be separate so > that people can pick it for -fixes/-stable ? Oh, that's only in the new code paths. For the old i915 ABI, the frames are skipped in userspace, but as it's something highly HW-dependent, implementors of the new API need to do it within their drivers. Regards, Tomeu ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v4 3/4] drm/i915: Use new CRC debugfs API
On 5 September 2016 at 10:45, Tomeu Vizosowrote: > On 2 September 2016 at 17:18, Emil Velikov wrote: >> Hi Tomeu, >> >> IMHO it would be better to split out the refactoring into preparatory >> patch. It brings a minor change which (not 100% sure on that) should >> not cause issues but is worth pointing out. > > I think at this point it would make sense to change the series > structure only if there was a strong reason, as a few people have > already looked at the patches already. > >> On 5 August 2016 at 11:45, Tomeu Vizoso wrote: >> >>> +static int do_set_crc_source(struct drm_device *dev, enum pipe pipe, >>> +enum intel_pipe_crc_source source) >>> +{ >> >>> + if (source == INTEL_PIPE_CRC_SOURCE_NONE) { >> Nit: use !source here or sourse != INTEL_PIPE_CRC_SOURCE_NONE >> elsewhere in the code ? > > Agreed. > >> >>> @@ -693,10 +718,11 @@ static int pipe_crc_set_source(struct drm_device >>> *dev, enum pipe pipe, >>> spin_unlock_irq(_crc->lock); >>> } >>> >>> - pipe_crc->source = source; >>> + ret = do_set_crc_source(dev, pipe, source); >>> + if (ret) >>> + goto out; >>> >> We seem to have modified pipe_crc even if the new function fails. >> Haven't check if it matters, but definatelly not ideal. > > If we had modified pipe_crc that's because we were trying to start CRC > capture and we initialized the entry storage. As CRC generation is > disabled, those changes have no effects. When CRC capture is attempted > again, they will be initialized again. > > To avoid this we would need to split the HW programming in two > functions and I'm not sure it would be worth it. > A simple way out will be to keep the "can fail" hunk at the top separate from the rest. This way even if things get reinitialised correctly currently, they won't break if someone applies the (perfectly reasonable imho) assumption "function does not modify any data when it fails". >>> @@ -720,15 +746,6 @@ static int pipe_crc_set_source(struct drm_device *dev, >>> enum pipe pipe, >>> spin_unlock_irq(_crc->lock); >>> >>> kfree(entries); >>> - >>> - if (IS_G4X(dev)) >>> - g4x_undo_pipe_scramble_reset(dev, pipe); >>> - else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) >>> - vlv_undo_pipe_scramble_reset(dev, pipe); >>> - else if (IS_HASWELL(dev) && pipe == PIPE_A) >>> - hsw_trans_edp_pipe_A_crc_wa(dev, false); >>> - >>> - hsw_enable_ips(crtc); >> The above is the piece I have in mind: >> With the introduction of do_set_crc_source() the above are executed >> prior to the intel_wait_for_vblank() call. >> >> Afaics this will not cause any functional change, then again I'm not >> that familiar with the i915 vblank code. > > Yeah, not sure either of when do those changes take effect. > With this said, it would be way better to keep it separate (with a big fat warning in the commit summary). Speaking of which - why did you fold the separate bugfix/workaround "skip the first one or two frames" in v5 ? Shouldn't it be separate so that people can pick it for -fixes/-stable ? Thanks Emil ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v4 3/4] drm/i915: Use new CRC debugfs API
On 2 September 2016 at 17:18, Emil Velikovwrote: > Hi Tomeu, > > IMHO it would be better to split out the refactoring into preparatory > patch. It brings a minor change which (not 100% sure on that) should > not cause issues but is worth pointing out. I think at this point it would make sense to change the series structure only if there was a strong reason, as a few people have already looked at the patches already. > On 5 August 2016 at 11:45, Tomeu Vizoso wrote: > >> +static int do_set_crc_source(struct drm_device *dev, enum pipe pipe, >> +enum intel_pipe_crc_source source) >> +{ > >> + if (source == INTEL_PIPE_CRC_SOURCE_NONE) { > Nit: use !source here or sourse != INTEL_PIPE_CRC_SOURCE_NONE > elsewhere in the code ? Agreed. > >> @@ -693,10 +718,11 @@ static int pipe_crc_set_source(struct drm_device *dev, >> enum pipe pipe, >> spin_unlock_irq(_crc->lock); >> } >> >> - pipe_crc->source = source; >> + ret = do_set_crc_source(dev, pipe, source); >> + if (ret) >> + goto out; >> > We seem to have modified pipe_crc even if the new function fails. > Haven't check if it matters, but definatelly not ideal. If we had modified pipe_crc that's because we were trying to start CRC capture and we initialized the entry storage. As CRC generation is disabled, those changes have no effects. When CRC capture is attempted again, they will be initialized again. To avoid this we would need to split the HW programming in two functions and I'm not sure it would be worth it. >> @@ -720,15 +746,6 @@ static int pipe_crc_set_source(struct drm_device *dev, >> enum pipe pipe, >> spin_unlock_irq(_crc->lock); >> >> kfree(entries); >> - >> - if (IS_G4X(dev)) >> - g4x_undo_pipe_scramble_reset(dev, pipe); >> - else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) >> - vlv_undo_pipe_scramble_reset(dev, pipe); >> - else if (IS_HASWELL(dev) && pipe == PIPE_A) >> - hsw_trans_edp_pipe_A_crc_wa(dev, false); >> - >> - hsw_enable_ips(crtc); > The above is the piece I have in mind: > With the introduction of do_set_crc_source() the above are executed > prior to the intel_wait_for_vblank() call. > > Afaics this will not cause any functional change, then again I'm not > that familiar with the i915 vblank code. Yeah, not sure either of when do those changes take effect. >> +int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char >> *source_name, >> + size_t *values_cnt) >> +{ > >> + ret = do_set_crc_source(crtc->dev, crtc->index, source); >> + >> + intel_display_power_put(dev_priv, power_domain); >> + >> + *values_cnt = 5; >> + > Please don't overwrite values_cnt if the function fails. Done. Thanks, Tomeu > Regards, > Emil > ___ > dri-devel mailing list > dri-de...@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v4 3/4] drm/i915: Use new CRC debugfs API
Hi Tomeu, IMHO it would be better to split out the refactoring into preparatory patch. It brings a minor change which (not 100% sure on that) should not cause issues but is worth pointing out. On 5 August 2016 at 11:45, Tomeu Vizosowrote: > +static int do_set_crc_source(struct drm_device *dev, enum pipe pipe, > +enum intel_pipe_crc_source source) > +{ > + if (source == INTEL_PIPE_CRC_SOURCE_NONE) { Nit: use !source here or sourse != INTEL_PIPE_CRC_SOURCE_NONE elsewhere in the code ? > @@ -693,10 +718,11 @@ static int pipe_crc_set_source(struct drm_device *dev, > enum pipe pipe, > spin_unlock_irq(_crc->lock); > } > > - pipe_crc->source = source; > + ret = do_set_crc_source(dev, pipe, source); > + if (ret) > + goto out; > We seem to have modified pipe_crc even if the new function fails. Haven't check if it matters, but definatelly not ideal. > @@ -720,15 +746,6 @@ static int pipe_crc_set_source(struct drm_device *dev, > enum pipe pipe, > spin_unlock_irq(_crc->lock); > > kfree(entries); > - > - if (IS_G4X(dev)) > - g4x_undo_pipe_scramble_reset(dev, pipe); > - else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) > - vlv_undo_pipe_scramble_reset(dev, pipe); > - else if (IS_HASWELL(dev) && pipe == PIPE_A) > - hsw_trans_edp_pipe_A_crc_wa(dev, false); > - > - hsw_enable_ips(crtc); The above is the piece I have in mind: With the introduction of do_set_crc_source() the above are executed prior to the intel_wait_for_vblank() call. Afaics this will not cause any functional change, then again I'm not that familiar with the i915 vblank code. > +int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name, > + size_t *values_cnt) > +{ > + ret = do_set_crc_source(crtc->dev, crtc->index, source); > + > + intel_display_power_put(dev_priv, power_domain); > + > + *values_cnt = 5; > + Please don't overwrite values_cnt if the function fails. Regards, Emil ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH v4 3/4] drm/i915: Use new CRC debugfs API
The core provides now an ABI to userspace for generation of frame CRCs, so implement the ->set_crc_source() callback and reuse as much code as possible with the previous ABI implementation. v2: - Leave the legacy implementation in place as the ABI implementation in the core is incompatible with it. v3: - Use the "cooked" vblank counter so we have a whole 32 bits. - Make sure we don't mess with the state of the legacy CRC capture ABI implementation. v4: - Keep use of get_vblank_counter as in the legacy code, will be changed in a followup commit. Signed-off-by: Tomeu Vizoso--- drivers/gpu/drm/i915/i915_irq.c | 69 --- drivers/gpu/drm/i915/intel_display.c | 1 + drivers/gpu/drm/i915/intel_drv.h | 2 + drivers/gpu/drm/i915/intel_pipe_crc.c | 124 -- 4 files changed, 133 insertions(+), 63 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 1c2aec392412..e5fb9fa86358 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -1492,41 +1492,58 @@ static void display_pipe_crc_irq_handler(struct drm_i915_private *dev_priv, { struct intel_pipe_crc *pipe_crc = _priv->pipe_crc[pipe]; struct intel_pipe_crc_entry *entry; - int head, tail; + struct drm_crtc *crtc = intel_get_crtc_for_pipe(_priv->drm, pipe); + struct drm_driver *driver = dev_priv->drm.driver; + uint32_t crcs[5]; + int head, tail, ret; + u32 frame; spin_lock(_crc->lock); + if (pipe_crc->source) { + if (!pipe_crc->entries) { + spin_unlock(_crc->lock); + DRM_DEBUG_KMS("spurious interrupt\n"); + return; + } - if (!pipe_crc->entries) { - spin_unlock(_crc->lock); - DRM_DEBUG_KMS("spurious interrupt\n"); - return; - } - - head = pipe_crc->head; - tail = pipe_crc->tail; + head = pipe_crc->head; + tail = pipe_crc->tail; - if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) { - spin_unlock(_crc->lock); - DRM_ERROR("CRC buffer overflowing\n"); - return; - } + if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) { + spin_unlock(_crc->lock); + DRM_ERROR("CRC buffer overflowing\n"); + return; + } - entry = _crc->entries[head]; + entry = _crc->entries[head]; - entry->frame = dev_priv->drm.driver->get_vblank_counter(_priv->drm, -pipe); - entry->crc[0] = crc0; - entry->crc[1] = crc1; - entry->crc[2] = crc2; - entry->crc[3] = crc3; - entry->crc[4] = crc4; + entry->frame = driver->get_vblank_counter(_priv->drm, pipe); + entry->crc[0] = crc0; + entry->crc[1] = crc1; + entry->crc[2] = crc2; + entry->crc[3] = crc3; + entry->crc[4] = crc4; - head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); - pipe_crc->head = head; + head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); + pipe_crc->head = head; - spin_unlock(_crc->lock); + spin_unlock(_crc->lock); - wake_up_interruptible(_crc->wq); + wake_up_interruptible(_crc->wq); + } else { + spin_unlock(_crc->lock); + spin_lock(>crc.lock); + crcs[0] = crc0; + crcs[1] = crc1; + crcs[2] = crc2; + crcs[3] = crc3; + crcs[4] = crc4; + frame = driver->get_vblank_counter(_priv->drm, pipe); + ret = drm_crtc_add_crc_entry(crtc, true, frame, crcs); + spin_unlock(>crc.lock); + if (!ret) + wake_up_interruptible(>crc.wq); + } } #else static inline void diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index baeb75388dbe..ccb251fcdf46 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -13966,6 +13966,7 @@ static const struct drm_crtc_funcs intel_crtc_funcs = { .page_flip = intel_crtc_page_flip, .atomic_duplicate_state = intel_crtc_duplicate_state, .atomic_destroy_state = intel_crtc_destroy_state, + .set_crc_source = intel_crtc_set_crc_source, }; /** diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index d1af85c97a80..1790bb48ebcf 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -1797,6 +1797,8 @@ void intel_color_load_luts(struct drm_crtc_state *crtc_state); /*