From: Ander Conselvan De Oliveira <conselvan2@gmail.com>
To: Durgadoss R <durgadoss.r@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCHv4 1/3] drm/i915: Make finding unused crtc as a generic function
Date: Fri, 06 May 2016 16:07:44 +0300 [thread overview]
Message-ID: <1462540064.9307.56.camel@gmail.com> (raw)
In-Reply-To: <1460986305-7116-2-git-send-email-durgadoss.r@intel.com>
On Mon, 2016-04-18 at 19:01 +0530, Durgadoss R wrote:
> Looping over the crtc list and finding an unused crtc
> has other users like upfront link training. Hence move it to
"will have", since this patch precedes the upfront link training one.
> a common function to re-use the logic.
>
> v4:
> * Added ERR_PTR as a return value in kernel Doc comment (Ander)
> v3:
> * Added kernel Doc and removed an invalid comment (Ander)
> * Rebased on top of latest code which includes locking
> for state->enable usage.
> v2:
> * Made this as a separate function instead of having it
> inside upfront link train code.
>
> Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
> ---
> drivers/gpu/drm/i915/intel_display.c | 74 +++++++++++++++++++++------------
> ---
> drivers/gpu/drm/i915/intel_drv.h | 2 +
> 2 files changed, 45 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_display.c
> b/drivers/gpu/drm/i915/intel_display.c
> index 4cca155..a6df48b 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -10404,6 +10404,43 @@ static int intel_modeset_setup_plane_state(struct
> drm_atomic_state *state,
> return 0;
> }
>
> +/**
> + * intel_get_unused_crtc - Find an unused crtc for the given encoder
> + * @encoder: drm_encoder structure
> + * @ctx: ctx pointer to use with locking
> + *
> + * This function tries to find an unused crtc that can drive
> + * the given encoder. Returns NULL or ERR_PTR on failure.
This NULL or ERR_PTR makes for an awkward interface. I wonder if it should just
return ERR_PTR(-EBUSY) or even ERR_PTR(-EINVAL) if there is no free crtc. It's
no big deal though.
Also, in the success case crtc->mutex is kept locked. That should be added to
the documentation above.
> + */
> +struct drm_crtc *intel_get_unused_crtc(struct drm_encoder *encoder,
> + struct drm_modeset_acquire_ctx *ctx)
> +{
> + struct drm_crtc *possible_crtc;
> + struct drm_crtc *crtc = NULL;
> + struct drm_device *dev = encoder->dev;
> + int ret, i = -1;
> +
> + for_each_crtc(dev, possible_crtc) {
> + i++;
> + if (!(encoder->possible_crtcs & (1 << i)))
> + continue;
> +
> + ret = drm_modeset_lock(&possible_crtc->mutex, ctx);
> + if (ret)
> + return ERR_PTR(ret);
> +
> + if (possible_crtc->state->enable) {
> + drm_modeset_unlock(&possible_crtc->mutex);
> + continue;
> + }
> +
> + crtc = possible_crtc;
> + break;
This could be replaced with "return possible_crtc;". No need for the extra
assignment and break.
I see that in patch 3 you have a debug message for when this returns NULL. It
would make sense to move that debug here.
Ander
> + }
> +
> + return crtc;
> +}
> +
> bool intel_get_load_detect_pipe(struct drm_connector *connector,
> struct drm_display_mode *mode,
> struct intel_load_detect_pipe *old,
> @@ -10412,7 +10449,6 @@ bool intel_get_load_detect_pipe(struct drm_connector
> *connector,
> struct intel_crtc *intel_crtc;
> struct intel_encoder *intel_encoder =
> intel_attached_encoder(connector);
> - struct drm_crtc *possible_crtc;
> struct drm_encoder *encoder = &intel_encoder->base;
> struct drm_crtc *crtc = NULL;
> struct drm_device *dev = encoder->dev;
> @@ -10421,7 +10457,7 @@ bool intel_get_load_detect_pipe(struct drm_connector
> *connector,
> struct drm_atomic_state *state = NULL, *restore_state = NULL;
> struct drm_connector_state *connector_state;
> struct intel_crtc_state *crtc_state;
> - int ret, i = -1;
> + int ret;
>
> DRM_DEBUG_KMS("[CONNECTOR:%d:%s], [ENCODER:%d:%s]\n",
> connector->base.id, connector->name,
> @@ -10451,39 +10487,15 @@ retry:
> ret = drm_modeset_lock(&crtc->mutex, ctx);
> if (ret)
> goto fail;
> -
> - /* Make sure the crtc and connector are running */
> - goto found;
> - }
> -
> - /* Find an unused one (if possible) */
> - for_each_crtc(dev, possible_crtc) {
> - i++;
> - if (!(encoder->possible_crtcs & (1 << i)))
> - continue;
> -
> - ret = drm_modeset_lock(&possible_crtc->mutex, ctx);
> - if (ret)
> + } else {
> + crtc = intel_get_unused_crtc(encoder, ctx);
> + if (IS_ERR_OR_NULL(crtc)) {
> + ret = PTR_ERR_OR_ZERO(crtc);
> + DRM_DEBUG_KMS("no pipe available for load-detect\n");
> goto fail;
> -
> - if (possible_crtc->state->enable) {
> - drm_modeset_unlock(&possible_crtc->mutex);
> - continue;
> }
> -
> - crtc = possible_crtc;
> - break;
> - }
> -
> - /*
> - * If we didn't find an unused CRTC, don't use any.
> - */
> - if (!crtc) {
> - DRM_DEBUG_KMS("no pipe available for load-detect\n");
> - goto fail;
> }
>
> -found:
> intel_crtc = to_intel_crtc(crtc);
>
> ret = drm_modeset_lock(&crtc->primary->mutex, ctx);
> diff --git a/drivers/gpu/drm/i915/intel_drv.h
> b/drivers/gpu/drm/i915/intel_drv.h
> index e13ce22..27b5dcd 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -1159,6 +1159,8 @@ bool intel_get_load_detect_pipe(struct drm_connector
> *connector,
> void intel_release_load_detect_pipe(struct drm_connector *connector,
> struct intel_load_detect_pipe *old,
> struct drm_modeset_acquire_ctx *ctx);
> +struct drm_crtc *intel_get_unused_crtc(struct drm_encoder *encoder,
> + struct drm_modeset_acquire_ctx *ctx);
> int intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
> unsigned int rotation);
> struct drm_framebuffer *
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-05-06 13:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-18 13:31 [PATCHv4 0/3] Add USB typeC based DP support for BXT platform Durgadoss R
2016-04-18 13:31 ` [PATCHv4 1/3] drm/i915: Make finding unused crtc as a generic function Durgadoss R
2016-05-06 13:07 ` Ander Conselvan De Oliveira [this message]
2016-05-09 9:45 ` R, Durgadoss
2016-04-18 13:31 ` [PATCH 2/3] drm/i915: Split bxt_ddi_pll_select() Durgadoss R
2016-05-06 13:09 ` Ander Conselvan De Oliveira
2016-04-18 13:31 ` [PATCHv4 3/3] drm/i915/dp: Enable Upfront link training for typeC DP support on BXT Durgadoss R
2016-05-06 13:09 ` Ander Conselvan De Oliveira
2016-05-09 10:43 ` R, Durgadoss
2016-05-11 9:02 ` Ander Conselvan De Oliveira
2016-07-26 20:51 ` Rodrigo Vivi
2016-07-27 10:17 ` Daniel Vetter
2016-04-18 14:27 ` ✗ Fi.CI.BAT: failure for Add USB typeC based DP support for BXT platform (rev5) Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462540064.9307.56.camel@gmail.com \
--to=conselvan2@gmail.com \
--cc=durgadoss.r@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.