All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Liviu Dudau <Liviu.Dudau@arm.com>
Cc: David Airlie <airlied@linux.ie>, Rob Herring <robh+dt@kernel.org>,
	Brian Starkey <brian.starkey@arm.com>,
	Emil Velikov <emil.l.velikov@gmail.com>,
	devicetree <devicetree@vger.kernel.org>,
	DRI devel <dri-devel@lists.freedesktop.org>,
	LKML <linux-kernel@vger.kernel.org>,
	David Brown <David.Brown@arm.com>,
	LAKML <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v3 2/3] drm/arm: Add support for Mali Display Processors
Date: Fri, 10 Jun 2016 16:33:13 +0200	[thread overview]
Message-ID: <20160610143313.GD3363@phenom.ffwll.local> (raw)
In-Reply-To: <20160610085259.GB1165@e106497-lin.cambridge.arm.com>

On Fri, Jun 10, 2016 at 09:52:59AM +0100, Liviu Dudau wrote:
> On Thu, Jun 09, 2016 at 08:56:29PM +0200, Daniel Vetter wrote:
> I'm seeing ->disable being called at HPD event time, which is soon after ->probe.
> 
> > This is the case when enabling a crtc when it is fully
> > disabled. Just mentioning in case ->enter_config_mode() is something that
> > must be called symmetrically with ->leave_config_mode().
> 
> ->leave_config_mode() should be the default mode when HW is disabled or not active,
> and the reset default value. Regardless of that, ->enter_config_mode() can be
> called at any time, even if HW is already in config mode.
> 
> > > +
> > > +	/* mclk needs to be set to the same or higher rate than pxlclk */
> > > +	clk_set_rate(hwdev->mclk, crtc->state->adjusted_mode.crtc_clock * 1000);
> > > +	clk_set_rate(hwdev->pxlclk, crtc->state->adjusted_mode.crtc_clock * 1000);
> > > +
> > > +	hwdev->modeset(hwdev, &vm);
> > > +	hwdev->leave_config_mode(hwdev);
> > > +}
> > > +
> > > +static void malidp_crtc_disable(struct drm_crtc *crtc)
> > > +{
> > > +	struct malidp_drm *malidp = crtc_to_malidp_device(crtc);
> > > +	struct malidp_hw_device *hwdev = malidp->dev;
> > > +
> > > +	/*
> > > +	 * avoid disabling already disabled clocks and hardware
> > > +	 * (as is the case at device probe time)
> > > +	 */
> > > +	if (crtc->state->active) {
> > 
> > Comment doesn't match code. Checking crtc->state->active in ->disable
> > looks at the _new_ state, not at the current state of the crtc. Atomic
> > helpers already guarantee you that ->disable is only called when the CRTC
> > is still on. 
> 
> Except at probe* time, when the framework calls ->disable before modeset to
> make sure that the hardware is in a known state. And I'm not sure how to
> check the _current_ state of the crtc other than by using crtc->state.
> 
> * actually, it is HPD event after probe.

Surprising. And you don't have a call to
drm_helper_disable_unused_functions, which is the usual culprit. Where
exactly do you see that ->disable call? Can you pls capture a backtrace
with full drm debugging enabled?

This shouldn't happen with atomic ...

> > > +static void malidp_unbind(struct device *dev)
> > > +{
> > > +	struct drm_device *drm = dev_get_drvdata(dev);
> > > +	struct malidp_drm *malidp = drm->dev_private;
> > > +	struct malidp_hw_device *hwdev = malidp->dev;
> > > +
> > > +	if (malidp->fbdev) {
> > > +		drm_fbdev_cma_fini(malidp->fbdev);
> > > +		malidp->fbdev = NULL;
> > > +	}
> > > +	drm_kms_helper_poll_fini(drm);
> > > +	malidp_se_irq_fini(drm);
> > > +	malidp_de_irq_fini(drm);
> > > +	drm_vblank_cleanup(drm);
> > > +	component_unbind_all(dev, drm);
> > > +	drm_dev_unregister(drm);
> > 
> > Unregister first, also need to unregister connectors too.
> 
> Bah, you are right. Does unregister have to come even before
> drm_kms_helper_poll_fini() ?

It's just generally the safest approach to first unregister everything,
and only then start cleaning up.

> As for the connectors, because my driver uses an encoder that
> is also a component slave, component_[un]bind_all() should take
> care of [un]registering that.

E.g. this sounds unsafe, because drm assume that encoder lists are static
over the lifetime of the driver. You should make sure no one can get at it
any more first before cleaning up any components.

Cheers, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: Liviu Dudau <Liviu.Dudau@arm.com>
Cc: devicetree <devicetree@vger.kernel.org>,
	Emil Velikov <emil.l.velikov@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	DRI devel <dri-devel@lists.freedesktop.org>,
	Rob Herring <robh+dt@kernel.org>,
	LAKML <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v3 2/3] drm/arm: Add support for Mali Display Processors
Date: Fri, 10 Jun 2016 16:33:13 +0200	[thread overview]
Message-ID: <20160610143313.GD3363@phenom.ffwll.local> (raw)
In-Reply-To: <20160610085259.GB1165@e106497-lin.cambridge.arm.com>

On Fri, Jun 10, 2016 at 09:52:59AM +0100, Liviu Dudau wrote:
> On Thu, Jun 09, 2016 at 08:56:29PM +0200, Daniel Vetter wrote:
> I'm seeing ->disable being called at HPD event time, which is soon after ->probe.
> 
> > This is the case when enabling a crtc when it is fully
> > disabled. Just mentioning in case ->enter_config_mode() is something that
> > must be called symmetrically with ->leave_config_mode().
> 
> ->leave_config_mode() should be the default mode when HW is disabled or not active,
> and the reset default value. Regardless of that, ->enter_config_mode() can be
> called at any time, even if HW is already in config mode.
> 
> > > +
> > > +	/* mclk needs to be set to the same or higher rate than pxlclk */
> > > +	clk_set_rate(hwdev->mclk, crtc->state->adjusted_mode.crtc_clock * 1000);
> > > +	clk_set_rate(hwdev->pxlclk, crtc->state->adjusted_mode.crtc_clock * 1000);
> > > +
> > > +	hwdev->modeset(hwdev, &vm);
> > > +	hwdev->leave_config_mode(hwdev);
> > > +}
> > > +
> > > +static void malidp_crtc_disable(struct drm_crtc *crtc)
> > > +{
> > > +	struct malidp_drm *malidp = crtc_to_malidp_device(crtc);
> > > +	struct malidp_hw_device *hwdev = malidp->dev;
> > > +
> > > +	/*
> > > +	 * avoid disabling already disabled clocks and hardware
> > > +	 * (as is the case at device probe time)
> > > +	 */
> > > +	if (crtc->state->active) {
> > 
> > Comment doesn't match code. Checking crtc->state->active in ->disable
> > looks at the _new_ state, not at the current state of the crtc. Atomic
> > helpers already guarantee you that ->disable is only called when the CRTC
> > is still on. 
> 
> Except at probe* time, when the framework calls ->disable before modeset to
> make sure that the hardware is in a known state. And I'm not sure how to
> check the _current_ state of the crtc other than by using crtc->state.
> 
> * actually, it is HPD event after probe.

Surprising. And you don't have a call to
drm_helper_disable_unused_functions, which is the usual culprit. Where
exactly do you see that ->disable call? Can you pls capture a backtrace
with full drm debugging enabled?

This shouldn't happen with atomic ...

> > > +static void malidp_unbind(struct device *dev)
> > > +{
> > > +	struct drm_device *drm = dev_get_drvdata(dev);
> > > +	struct malidp_drm *malidp = drm->dev_private;
> > > +	struct malidp_hw_device *hwdev = malidp->dev;
> > > +
> > > +	if (malidp->fbdev) {
> > > +		drm_fbdev_cma_fini(malidp->fbdev);
> > > +		malidp->fbdev = NULL;
> > > +	}
> > > +	drm_kms_helper_poll_fini(drm);
> > > +	malidp_se_irq_fini(drm);
> > > +	malidp_de_irq_fini(drm);
> > > +	drm_vblank_cleanup(drm);
> > > +	component_unbind_all(dev, drm);
> > > +	drm_dev_unregister(drm);
> > 
> > Unregister first, also need to unregister connectors too.
> 
> Bah, you are right. Does unregister have to come even before
> drm_kms_helper_poll_fini() ?

It's just generally the safest approach to first unregister everything,
and only then start cleaning up.

> As for the connectors, because my driver uses an encoder that
> is also a component slave, component_[un]bind_all() should take
> care of [un]registering that.

E.g. this sounds unsafe, because drm assume that encoder lists are static
over the lifetime of the driver. You should make sure no one can get at it
any more first before cleaning up any components.

Cheers, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: daniel@ffwll.ch (Daniel Vetter)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 2/3] drm/arm: Add support for Mali Display Processors
Date: Fri, 10 Jun 2016 16:33:13 +0200	[thread overview]
Message-ID: <20160610143313.GD3363@phenom.ffwll.local> (raw)
In-Reply-To: <20160610085259.GB1165@e106497-lin.cambridge.arm.com>

On Fri, Jun 10, 2016 at 09:52:59AM +0100, Liviu Dudau wrote:
> On Thu, Jun 09, 2016 at 08:56:29PM +0200, Daniel Vetter wrote:
> I'm seeing ->disable being called at HPD event time, which is soon after ->probe.
> 
> > This is the case when enabling a crtc when it is fully
> > disabled. Just mentioning in case ->enter_config_mode() is something that
> > must be called symmetrically with ->leave_config_mode().
> 
> ->leave_config_mode() should be the default mode when HW is disabled or not active,
> and the reset default value. Regardless of that, ->enter_config_mode() can be
> called at any time, even if HW is already in config mode.
> 
> > > +
> > > +	/* mclk needs to be set to the same or higher rate than pxlclk */
> > > +	clk_set_rate(hwdev->mclk, crtc->state->adjusted_mode.crtc_clock * 1000);
> > > +	clk_set_rate(hwdev->pxlclk, crtc->state->adjusted_mode.crtc_clock * 1000);
> > > +
> > > +	hwdev->modeset(hwdev, &vm);
> > > +	hwdev->leave_config_mode(hwdev);
> > > +}
> > > +
> > > +static void malidp_crtc_disable(struct drm_crtc *crtc)
> > > +{
> > > +	struct malidp_drm *malidp = crtc_to_malidp_device(crtc);
> > > +	struct malidp_hw_device *hwdev = malidp->dev;
> > > +
> > > +	/*
> > > +	 * avoid disabling already disabled clocks and hardware
> > > +	 * (as is the case at device probe time)
> > > +	 */
> > > +	if (crtc->state->active) {
> > 
> > Comment doesn't match code. Checking crtc->state->active in ->disable
> > looks at the _new_ state, not at the current state of the crtc. Atomic
> > helpers already guarantee you that ->disable is only called when the CRTC
> > is still on. 
> 
> Except at probe* time, when the framework calls ->disable before modeset to
> make sure that the hardware is in a known state. And I'm not sure how to
> check the _current_ state of the crtc other than by using crtc->state.
> 
> * actually, it is HPD event after probe.

Surprising. And you don't have a call to
drm_helper_disable_unused_functions, which is the usual culprit. Where
exactly do you see that ->disable call? Can you pls capture a backtrace
with full drm debugging enabled?

This shouldn't happen with atomic ...

> > > +static void malidp_unbind(struct device *dev)
> > > +{
> > > +	struct drm_device *drm = dev_get_drvdata(dev);
> > > +	struct malidp_drm *malidp = drm->dev_private;
> > > +	struct malidp_hw_device *hwdev = malidp->dev;
> > > +
> > > +	if (malidp->fbdev) {
> > > +		drm_fbdev_cma_fini(malidp->fbdev);
> > > +		malidp->fbdev = NULL;
> > > +	}
> > > +	drm_kms_helper_poll_fini(drm);
> > > +	malidp_se_irq_fini(drm);
> > > +	malidp_de_irq_fini(drm);
> > > +	drm_vblank_cleanup(drm);
> > > +	component_unbind_all(dev, drm);
> > > +	drm_dev_unregister(drm);
> > 
> > Unregister first, also need to unregister connectors too.
> 
> Bah, you are right. Does unregister have to come even before
> drm_kms_helper_poll_fini() ?

It's just generally the safest approach to first unregister everything,
and only then start cleaning up.

> As for the connectors, because my driver uses an encoder that
> is also a component slave, component_[un]bind_all() should take
> care of [un]registering that.

E.g. this sounds unsafe, because drm assume that encoder lists are static
over the lifetime of the driver. You should make sure no one can get at it
any more first before cleaning up any components.

Cheers, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2016-06-10 14:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-09 16:18 [PATCH v3 0/3] Add support for ARM Mali Display Processors Liviu Dudau
2016-06-09 16:18 ` Liviu Dudau
2016-06-09 16:18 ` Liviu Dudau
2016-06-09 16:18 ` [PATCH v3 1/3] dt/bindings: display: Add DT bindings for " Liviu Dudau
2016-06-09 16:18   ` Liviu Dudau
2016-06-09 16:18   ` Liviu Dudau
2016-06-09 16:18 ` [PATCH v3 2/3] drm/arm: Add support " Liviu Dudau
2016-06-09 16:18   ` Liviu Dudau
2016-06-09 16:18   ` Liviu Dudau
2016-06-09 18:56   ` Daniel Vetter
2016-06-09 18:56     ` Daniel Vetter
2016-06-09 18:56     ` Daniel Vetter
2016-06-10  8:52     ` Liviu Dudau
2016-06-10  8:52       ` Liviu Dudau
2016-06-10  8:52       ` Liviu Dudau
2016-06-10 14:33       ` Daniel Vetter [this message]
2016-06-10 14:33         ` Daniel Vetter
2016-06-10 14:33         ` Daniel Vetter
2016-06-10 16:57         ` Liviu Dudau
2016-06-10 16:57           ` Liviu Dudau
2016-06-10 16:57           ` Liviu Dudau
2016-06-09 16:18 ` [PATCH v3 3/3] MAINTAINERS: Add entry for Mali-DP driver Liviu Dudau
2016-06-09 16:18   ` Liviu Dudau
2016-06-09 16:18   ` Liviu Dudau

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=20160610143313.GD3363@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=David.Brown@arm.com \
    --cc=Liviu.Dudau@arm.com \
    --cc=airlied@linux.ie \
    --cc=brian.starkey@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.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.