From: Jani Nikula <jani.nikula@linux.intel.com>
To: ville.syrjala@linux.intel.com, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/7] drm/i915: Replace the aux ddc name switch statement with kasprintf()
Date: Thu, 12 Nov 2015 11:23:13 +0200 [thread overview]
Message-ID: <87k2pnh8qm.fsf@intel.com> (raw)
In-Reply-To: <1447266856-30249-3-git-send-email-ville.syrjala@linux.intel.com>
On Wed, 11 Nov 2015, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Use kasprintf() to generate the "DPDDC-<port>" name for the aux helper.
>
> To deal with errors properly make intel_dp_aux_init() return something,
> and adjust the caller to match. It seems we were also missing a
> intel_dp_mst_encoder_cleanup() call on edp (non-port A) init failures,
> so add that too.
>
> The whole error/cleanup ordering doesn't feel entirely sane to me, but
> I'll leave that part alone for now.
>
> v2: Use kasprintf() instead of a table, reorder patches (Chis)
>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/intel_dp.c | 75 +++++++++++++++++++++++++----------------
> 1 file changed, 46 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index 891a7f8..df2a2d2 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -1009,6 +1009,13 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
> }
>
> static void
> +intel_dp_aux_fini(struct intel_dp *intel_dp)
> +{
> + drm_dp_aux_unregister(&intel_dp->aux);
> + kfree(intel_dp->aux.name);
> +}
> +
> +static int
> intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector *connector)
> {
> struct drm_device *dev = intel_dp_to_dev(intel_dp);
> @@ -1016,7 +1023,6 @@ intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector *connector)
> struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
> enum port port = intel_dig_port->port;
> struct ddi_vbt_port_info *info = &dev_priv->vbt.ddi_port_info[port];
> - const char *name = NULL;
> uint32_t porte_aux_ctl_reg = DPA_AUX_CH_CTL;
> int ret;
>
> @@ -1043,23 +1049,18 @@ intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector *connector)
> switch (port) {
> case PORT_A:
> intel_dp->aux_ch_ctl_reg = DPA_AUX_CH_CTL;
> - name = "DPDDC-A";
> break;
> case PORT_B:
> intel_dp->aux_ch_ctl_reg = PCH_DPB_AUX_CH_CTL;
> - name = "DPDDC-B";
> break;
> case PORT_C:
> intel_dp->aux_ch_ctl_reg = PCH_DPC_AUX_CH_CTL;
> - name = "DPDDC-C";
> break;
> case PORT_D:
> intel_dp->aux_ch_ctl_reg = PCH_DPD_AUX_CH_CTL;
> - name = "DPDDC-D";
> break;
> case PORT_E:
> intel_dp->aux_ch_ctl_reg = porte_aux_ctl_reg;
> - name = "DPDDC-E";
> break;
> default:
> BUG();
> @@ -1077,27 +1078,36 @@ intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector *connector)
> if (!IS_HASWELL(dev) && !IS_BROADWELL(dev) && port != PORT_E)
> intel_dp->aux_ch_ctl_reg = intel_dp->output_reg + 0x10;
>
> - intel_dp->aux.name = name;
> + intel_dp->aux.name = kasprintf(GFP_KERNEL, "DPDDC-%c", port_name(port));
> + if (!intel_dp->aux.name)
> + return -ENOMEM;
> +
> intel_dp->aux.dev = dev->dev;
> intel_dp->aux.transfer = intel_dp_aux_transfer;
>
> - DRM_DEBUG_KMS("registering %s bus for %s\n", name,
> + DRM_DEBUG_KMS("registering %s bus for %s\n",
> + intel_dp->aux.name,
> connector->base.kdev->kobj.name);
>
> ret = drm_dp_aux_register(&intel_dp->aux);
> if (ret < 0) {
> DRM_ERROR("drm_dp_aux_register() for %s failed (%d)\n",
> - name, ret);
> - return;
> + intel_dp->aux.name, ret);
> + kfree(intel_dp->aux.name);
> + return ret;
> }
>
> ret = sysfs_create_link(&connector->base.kdev->kobj,
> &intel_dp->aux.ddc.dev.kobj,
> intel_dp->aux.ddc.dev.kobj.name);
> if (ret < 0) {
> - DRM_ERROR("sysfs_create_link() for %s failed (%d)\n", name, ret);
> - drm_dp_aux_unregister(&intel_dp->aux);
> + DRM_ERROR("sysfs_create_link() for %s failed (%d)\n",
> + intel_dp->aux.name, ret);
> + intel_dp_aux_fini(intel_dp);
> + return ret;
> }
> +
> + return 0;
> }
>
> static void
> @@ -4771,7 +4781,7 @@ void intel_dp_encoder_destroy(struct drm_encoder *encoder)
> struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder);
> struct intel_dp *intel_dp = &intel_dig_port->dp;
>
> - drm_dp_aux_unregister(&intel_dp->aux);
> + intel_dp_aux_fini(intel_dp);
> intel_dp_mst_encoder_cleanup(intel_dig_port);
> if (is_edp(intel_dp)) {
> cancel_delayed_work_sync(&intel_dp->panel_vdd_work);
> @@ -5752,7 +5762,7 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> struct drm_device *dev = intel_encoder->base.dev;
> struct drm_i915_private *dev_priv = dev->dev_private;
> enum port port = intel_dig_port->port;
> - int type;
> + int type, ret;
>
> intel_dp->pps_pipe = INVALID_PIPE;
>
> @@ -5853,7 +5863,9 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> pps_unlock(intel_dp);
> }
>
> - intel_dp_aux_init(intel_dp, intel_connector);
> + ret = intel_dp_aux_init(intel_dp, intel_connector);
> + if (ret)
> + goto fail;
>
> /* init MST on ports that can support it */
> if (HAS_DP_MST(dev) &&
> @@ -5862,20 +5874,9 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> intel_connector->base.base.id);
>
> if (!intel_edp_init_connector(intel_dp, intel_connector)) {
> - drm_dp_aux_unregister(&intel_dp->aux);
> - if (is_edp(intel_dp)) {
> - cancel_delayed_work_sync(&intel_dp->panel_vdd_work);
> - /*
> - * vdd might still be enabled do to the delayed vdd off.
> - * Make sure vdd is actually turned off here.
> - */
> - pps_lock(intel_dp);
> - edp_panel_vdd_off_sync(intel_dp);
> - pps_unlock(intel_dp);
> - }
> - drm_connector_unregister(connector);
> - drm_connector_cleanup(connector);
> - return false;
> + intel_dp_aux_fini(intel_dp);
> + intel_dp_mst_encoder_cleanup(intel_dig_port);
> + goto fail;
> }
>
> intel_dp_add_properties(intel_dp, connector);
> @@ -5892,6 +5893,22 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> i915_debugfs_connector_add(connector);
>
> return true;
> +
> +fail:
> + if (is_edp(intel_dp)) {
> + cancel_delayed_work_sync(&intel_dp->panel_vdd_work);
> + /*
> + * vdd might still be enabled do to the delayed vdd off.
> + * Make sure vdd is actually turned off here.
> + */
> + pps_lock(intel_dp);
> + edp_panel_vdd_off_sync(intel_dp);
> + pps_unlock(intel_dp);
> + }
A follow-up might abstract this sequence as there's three copies now.
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> + drm_connector_unregister(connector);
> + drm_connector_cleanup(connector);
> +
> + return false;
> }
>
> void
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-11-12 9:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-11 18:34 [PATCH 0/7] drm/i915: Reordered AUX patches from type safety series ville.syrjala
2015-11-11 18:34 ` [PATCH 1/7] drm/i915: Replace aux_ch_ctl_reg check with port check ville.syrjala
2015-11-11 18:34 ` [PATCH 2/7] drm/i915: Replace the aux ddc name switch statement with kasprintf() ville.syrjala
2015-11-12 9:23 ` Jani Nikula [this message]
2015-11-11 18:34 ` [PATCH 3/7] drm/i915: Parametrize AUX registers ville.syrjala
2015-11-11 18:34 ` [PATCH 4/7] drm/i915: Remove the magic AUX_CTL is at DP + foo tricks ville.syrjala
2015-11-11 18:34 ` [PATCH 5/7] drm/i915: Store aux data reg offsets in intel_dp->aux_ch_data_reg[] ville.syrjala
2015-11-11 18:34 ` [PATCH 6/7] drm/i915: Add dev_priv->psr_mmio_base ville.syrjala
2015-11-11 18:34 ` [PATCH 7/7] drm/i915: Model PSR AUX register selection more like the normal AUX code ville.syrjala
2015-11-12 9:37 ` [PATCH 0/7] drm/i915: Reordered AUX patches from type safety series Jani Nikula
2015-11-16 14:22 ` Ville Syrjälä
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=87k2pnh8qm.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=ville.syrjala@linux.intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox