dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Dave Airlie <airlied@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/dp: add a hw mutex around the transfer functions.
Date: Wed, 4 Jun 2014 11:26:37 +0200	[thread overview]
Message-ID: <20140604092637.GL7416@phenom.ffwll.local> (raw)
In-Reply-To: <1401861865-18307-1-git-send-email-airlied@gmail.com>

On Wed, Jun 04, 2014 at 04:04:25PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This should avoid races between connector probing and HPD
> irqs in the future, currently mode_config.mutex blocks this
> possibility.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/drm_dp_helper.c      | 15 +++++++++++++++
>  drivers/gpu/drm/i915/intel_dp.c      |  1 +
>  drivers/gpu/drm/radeon/atombios_dp.c |  2 ++
>  drivers/gpu/drm/tegra/dpaux.c        |  1 +
>  include/drm/drm_dp_helper.h          |  3 ++-
>  5 files changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index 494219c..cb687f4 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -382,7 +382,10 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
>  	 * transactions.
>  	 */
>  	for (retry = 0; retry < 7; retry++) {
> +
> +		mutex_lock(&aux->hw_mutex);
>  		err = aux->transfer(aux, &msg);
> +		mutex_unlock(&aux->hw_mutex);
>  		if (err < 0) {
>  			if (err == -EBUSY)
>  				continue;
> @@ -596,7 +599,9 @@ static int drm_dp_i2c_do_msg(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
>  	 * before giving up the AUX transaction.
>  	 */
>  	for (retry = 0; retry < 7; retry++) {
> +		mutex_lock(&aux->hw_mutex);
>  		err = aux->transfer(aux, msg);
> +		mutex_unlock(&aux->hw_mutex);
>  		if (err < 0) {
>  			if (err == -EBUSY)
>  				continue;
> @@ -761,3 +766,13 @@ void drm_dp_aux_unregister_i2c_bus(struct drm_dp_aux *aux)
>  	i2c_del_adapter(&aux->ddc);
>  }
>  EXPORT_SYMBOL(drm_dp_aux_unregister_i2c_bus);
> +
> +/**
> + * drm_dp_aux_init() - init a DP aux internal structure.
> + * @aux: DisplayPort AUX channel
> + */
> +void drm_dp_aux_init(struct drm_dp_aux *aux)
> +{
> +	mutex_init(&aux->hw_mutex);
> +}

Imo we should merge this with drm_dp_aux_register (and drop the i2c_bus
part of it since it'll be more generic) - no driver should call one
without the other.

With that address this is Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> +EXPORT_SYMBOL(drm_dp_aux_init);
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index c4d8839..aa99dcb 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -698,6 +698,7 @@ intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector *connector)
>  	intel_dp->aux.name = name;
>  	intel_dp->aux.dev = dev->dev;
>  	intel_dp->aux.transfer = intel_dp_aux_transfer;
> +	drm_dp_aux_init(&intel_dp->aux);
>  
>  	DRM_DEBUG_KMS("registering %s bus for %s\n", name,
>  		      connector->base.kdev->kobj.name);
> diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
> index 225f6c6..12d8784 100644
> --- a/drivers/gpu/drm/radeon/atombios_dp.c
> +++ b/drivers/gpu/drm/radeon/atombios_dp.c
> @@ -222,6 +222,8 @@ void radeon_dp_aux_init(struct radeon_connector *radeon_connector)
>  	radeon_connector->ddc_bus->rec.hpd = radeon_connector->hpd.hpd;
>  	radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev;
>  	radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer;
> +
> +	drm_dp_aux_init(&radeon_connector->ddc_bus->aux);
>  	ret = drm_dp_aux_register_i2c_bus(&radeon_connector->ddc_bus->aux);
>  	if (!ret)
>  		radeon_connector->ddc_bus->has_aux = true;
> diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c
> index 005c19b..98cd70b 100644
> --- a/drivers/gpu/drm/tegra/dpaux.c
> +++ b/drivers/gpu/drm/tegra/dpaux.c
> @@ -331,6 +331,7 @@ static int tegra_dpaux_probe(struct platform_device *pdev)
>  
>  	dpaux->aux.transfer = tegra_dpaux_transfer;
>  	dpaux->aux.dev = &pdev->dev;
> +	drm_dp_aux_init(&dpaux->aux);
>  
>  	err = drm_dp_aux_register_i2c_bus(&dpaux->aux);
>  	if (err < 0)
> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> index 488b416..09eee36 100644
> --- a/include/drm/drm_dp_helper.h
> +++ b/include/drm/drm_dp_helper.h
> @@ -546,7 +546,7 @@ struct drm_dp_aux {
>  	const char *name;
>  	struct i2c_adapter ddc;
>  	struct device *dev;
> -
> +	struct mutex hw_mutex;
>  	ssize_t (*transfer)(struct drm_dp_aux *aux,
>  			    struct drm_dp_aux_msg *msg);
>  };
> @@ -607,5 +607,6 @@ int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link);
>  
>  int drm_dp_aux_register_i2c_bus(struct drm_dp_aux *aux);
>  void drm_dp_aux_unregister_i2c_bus(struct drm_dp_aux *aux);
> +void drm_dp_aux_init(struct drm_dp_aux *aux);
>  
>  #endif /* _DRM_DP_HELPER_H_ */
> -- 
> 1.9.3
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

      reply	other threads:[~2014-06-04  9:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-04  6:04 [PATCH] drm/dp: add a hw mutex around the transfer functions Dave Airlie
2014-06-04  9:26 ` Daniel Vetter [this message]

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=20140604092637.GL7416@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@gmail.com \
    --cc=dri-devel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox