dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Chris Wilson <chris@chris-wilson.co.uk>,
	Daniel Vetter <daniel@ffwll.ch>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	DRI Development <dri-devel@lists.freedesktop.org>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH] drm/sysfs: Send out uevent when connector->force changes
Date: Tue, 24 Nov 2015 11:51:09 +0100	[thread overview]
Message-ID: <20151124105109.GL17050@phenom.ffwll.local> (raw)
In-Reply-To: <20151120092514.GG24442@nuc-i3427.alporthouse.com>

On Fri, Nov 20, 2015 at 09:25:14AM +0000, Chris Wilson wrote:
> On Fri, Nov 20, 2015 at 09:11:00AM +0100, Daniel Vetter wrote:
> > On Thu, Nov 19, 2015 at 09:06:04PM +0000, Chris Wilson wrote:
> > > On Thu, Nov 19, 2015 at 05:46:50PM +0100, Daniel Vetter wrote:
> > > > To avoid even more code duplication punt this all to the probe worker,
> > > > which needs some slight adjustment to also generate a uevent when the
> > > > status has changed to due connector->force.
> > > > 
> > > > v2: Instead of running the output_poll_work (which is kinda the wrong
> > > > thing and a layering violation since it's an internal of the probe
> > > > helpers), or calling ->detect (which is again a layering violation
> > > > since it's used only by probe helpers) just call the official
> > > > ->fill_modes function, like a GET_CONNECTOR ioctl call.
> > > > 
> > > > v3: Restore the accidentally removed forced-probe for echo "detect" >
> > > > force.
> > > > 
> > > 
> > > > diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> > > > index 9ac4ffa6cce3..df66d9447cb0 100644
> > > > --- a/drivers/gpu/drm/drm_sysfs.c
> > > > +++ b/drivers/gpu/drm/drm_sysfs.c
> > > > @@ -167,47 +167,35 @@ static ssize_t status_store(struct device *device,
> > > >  {
> > > >  	struct drm_connector *connector = to_drm_connector(device);
> > > >  	struct drm_device *dev = connector->dev;
> > > > -	enum drm_connector_status old_status;
> > > > +	enum drm_connector_force old_force;
> > > >  	int ret;
> > > >  
> > > >  	ret = mutex_lock_interruptible(&dev->mode_config.mutex);
> > > >  	if (ret)
> > > >  		return ret;
> > > >  
> > > > -	old_status = connector->status;
> > > > +	old_force = connector->force;
> > > >  
> > > > -	if (sysfs_streq(buf, "detect")) {
> > > > +	if (sysfs_streq(buf, "detect"))
> > > >  		connector->force = 0;
> > > > -		connector->status = connector->funcs->detect(connector, true);
> > > > -	} else if (sysfs_streq(buf, "on")) {
> > > > +	else if (sysfs_streq(buf, "on"))
> > > >  		connector->force = DRM_FORCE_ON;
> > > > -	} else if (sysfs_streq(buf, "on-digital")) {
> > > > +	else if (sysfs_streq(buf, "on-digital"))
> > > >  		connector->force = DRM_FORCE_ON_DIGITAL;
> > > > -	} else if (sysfs_streq(buf, "off")) {
> > > > +	else if (sysfs_streq(buf, "off"))
> > > >  		connector->force = DRM_FORCE_OFF;
> > > > -	} else
> > > > +	else
> > > >  		ret = -EINVAL;
> > > >  
> > > > -	if (ret == 0 && connector->force) {
> > > > -		if (connector->force == DRM_FORCE_ON ||
> > > > -		    connector->force == DRM_FORCE_ON_DIGITAL)
> > > > -			connector->status = connector_status_connected;
> > > > -		else
> > > > -			connector->status = connector_status_disconnected;
> > > > -		if (connector->funcs->force)
> > > > -			connector->funcs->force(connector);
> > > > -	}
> > > > -
> > > > -	if (old_status != connector->status) {
> > > > -		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %d to %d\n",
> > > > +	if (old_force != connector->force || !connector->force) {
> > > > +		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] force updated from %d to %d or reprobing\n",
> > > >  			      connector->base.id,
> > > >  			      connector->name,
> > > > -			      old_status, connector->status);
> > > > +			      old_force, connector->force);
> > > >  
> > > > -		dev->mode_config.delayed_event = true;
> > > > -		if (dev->mode_config.poll_enabled)
> > > > -			schedule_delayed_work(&dev->mode_config.output_poll_work,
> > > > -					      0);
> > > > +		connector->funcs->fill_modes(connector,
> > > > +					     dev->mode_config.max_width,
> > > > +					     dev->mode_config.max_height);
> > > 
> > > This now does fill_modes() before we call detect(). We rely on the
> > > ordering of detect() before doing fill_modes() as in many cases we use
> > > the EDID gathered in detect() to generate the modes (if I am not
> > > mistaken, I think we merged those patches to cache the EDID for a
> > > detection cycle).
> > 
> > ->fill_modes = drm_helper_probe_single_connector_modes which then calls
> > ->detect. By going this way we avoid duplicating the "send uevent if
> > anything changed" logic all over the place, and ->detect becomes purely a
> > helper internal callback to get at the mode list for hotpluggeable
> > outputs.
> 
> Ok, that struck me as a little surprising - I was thinking of lower level
> get_modes apparently.
> 
> With that resolved,
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Applied to drm-misc, thanks for the review.

> > Yes this means that ->detect should become a helper function, but that's
> > quite an invasive change.
> 
> And something like .fill_modes -> .probe (after removing .detect).

Hm, not sure. For panels we never really probe anything, the important bit
is (at least for the caller in drm_crtc.c) that it fills in the
connectore->modes list. Given that I think the current name is okish.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-11-24 10:51 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-19 16:46 [PATCH RESEND 00/20] dev->struct_mutex locking crusade Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 01/20] drm/armada: Plug leak in dumb_map_offset Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 02/20] drm/armada: Don't grab dev->struct_mutex for in mmap offset ioctl Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 03/20] drm/armada: Drop struct_mutex from cursor paths Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 04/20] drm/armada: Use a private mutex to protect priv->linear Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 05/20] drm/tegra: don't take dev->struct_mutex in mmap offset ioctl Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 06/20] drm/tegra: Use drm_gem_object_unreference_unlocked Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 07/20] drm/gma500: Use correct unref in the gem bo create function Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 08/20] drm/gma500: Drop dev->struct_mutex from modeset code Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 09/20] drm/gma500: Drop dev->struct_mutex from fbdev init/teardown code Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 10/20] drm/gma500: Drop dev->struct_mutex from mmap offset function Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 11/20] drm/gma500: Add driver private mutex for the fault handler Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 12/20] drm/nouveau: Drop dev->struct_mutex from fbdev init Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 13/20] drm/exynos: Drop dev->struct_mutex from mmap offset function Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 14/20] drm/exynos: drop struct_mutex from exynos_gem_map_sgt_with_dma Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 15/20] drm/exynos: drop struct_mutex from exynos_drm_gem_get_ioctl Daniel Vetter
2015-11-19 16:50   ` Daniel Stone
2015-11-19 16:59     ` Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 16/20] drm/exynos: drop struct_mutex from fbdev setup Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 17/20] drm/vgem: Simplify dum_map Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 18/20] drm/vgem: Move get_pages to gem_create Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 19/20] drm/vgem: Drop dev->struct_mutex Daniel Vetter
2015-11-19 16:46 ` [PATCH RESEND 20/20] drm/vma_manage: Drop has_offset Daniel Vetter
2015-11-19 16:46 ` [PATCH] drm/sysfs: Send out uevent when connector->force changes Daniel Vetter
2015-11-19 21:06   ` Chris Wilson
2015-11-20  8:11     ` Daniel Vetter
2015-11-20  9:25       ` Chris Wilson
2015-11-24 10:51         ` Daniel Vetter [this message]
2015-11-24 11:46           ` Chris Wilson
  -- strict thread matches above, loose matches on Subject: below --
2015-11-19 14:44 Daniel Vetter

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=20151124105109.GL17050@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=chris@chris-wilson.co.uk \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox