From patchwork Thu Nov 19 14:10:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 7657461 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 71FAEBF90C for ; Thu, 19 Nov 2015 14:10:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 49932206A7 for ; Thu, 19 Nov 2015 14:10:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4F89A206A2 for ; Thu, 19 Nov 2015 14:10:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7E066E961; Thu, 19 Nov 2015 06:10:07 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F6736E961 for ; Thu, 19 Nov 2015 06:10:05 -0800 (PST) Received: by wmww144 with SMTP id w144so240089286wmw.1 for ; Thu, 19 Nov 2015 06:10:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=TQ+xUDKFNDAgU3OxE02tKdRyfC5habmVH1/fVcSTJoY=; b=i11HYkTpcqaN6z2zGdjMNuOJght5CU2HJmcev7ndTmMxloNZA7qmRgryOvjPSNC2fX CPtR8SX4UB7aUJJkiYmdM6p6rzBFUrTlqqcqb0oT3ogxSrVH7EXrIPsa1ZdDGWSf7fv3 wxk/gx1Ifb8sIchbmre5UmOyEvsNU2q7PCPXI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=TQ+xUDKFNDAgU3OxE02tKdRyfC5habmVH1/fVcSTJoY=; b=Ayd8iU4UtKF7zYYyw2XKgKbhOni3zbDByGbOXplmdetCBWTfctcqx8dQJIVmbGZOwU iGWy94sAEyRwsXlz+SZaBjKSRn2bj45u54ykKTQLWj2FvvviIRohZaa3Z9HHEK+B5r3W DZe9oN791okWT03ktiZeXAETOocxd7O+XszytoLLrDTsTgTMpz7opkl+rNPa0rATAwZI YciScKHmnjDRjdN/gNYribdBeEScSVL02fQtxZuPSp5MJUKQ3h63IohUwkG4I1IvrwQr EbK+T9SYIutnrSmFiAA3FP2pxhqZykuzH3lyf229aaedEwi+ZOSRR2R7z8yNkY5haVDQ O6Tw== X-Gm-Message-State: ALoCoQmlwpp/l6zX8okAi8N8XcQdpUEFKPFfIkLb/i1BbKVrvREFkN3zgKGkKpEavUatiWlpCeFu X-Received: by 10.194.24.38 with SMTP id r6mr8439697wjf.5.1447942204096; Thu, 19 Nov 2015 06:10:04 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:56c9:0:22cf:30ff:fe4c:37d6]) by smtp.gmail.com with ESMTPSA id jh4sm8037525wjb.33.2015.11.19.06.10.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Nov 2015 06:10:03 -0800 (PST) Date: Thu, 19 Nov 2015 15:10:01 +0100 From: Daniel Vetter To: Chris Wilson Subject: Re: [PATCH] drm: Send a hotplug uevent after performing a sysfs connection probe Message-ID: <20151119141001.GC17050@phenom.ffwll.local> References: <1447941097-23302-1-git-send-email-chris@chris-wilson.co.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1447941097-23302-1-git-send-email-chris@chris-wilson.co.uk> X-Operating-System: Linux phenom 4.1.0-2-amd64 User-Agent: Mutt/1.5.23 (2014-03-12) Cc: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Nov 19, 2015 at 01:51:37PM +0000, Chris Wilson wrote: > If we probe the connector status from sysfs and find it has a new value, > we should synthesize the associated hotplug uevent. This keeps our > behaviour consistent and informs userspace of any override or change > imposed by the user. > > Signed-off-by: Chris Wilson > --- > drivers/gpu/drm/drm_sysfs.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c > index 615b7e667320..382b82f871bc 100644 > --- a/drivers/gpu/drm/drm_sysfs.c > +++ b/drivers/gpu/drm/drm_sysfs.c > @@ -208,6 +208,8 @@ static ssize_t status_store(struct device *device, > if (dev->mode_config.poll_enabled) > schedule_delayed_work(&dev->mode_config.output_poll_work, > 0); > + > + drm_kms_helper_hotplug_event(dev); I don't like leaking these all over the place. What about the (untested) idea below? -Daniel diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index a214a4a93b03..b7bdf12c54a5 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -147,6 +147,8 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect list_for_each_entry(mode, &connector->modes, head) mode->status = MODE_UNVERIFIED; + old_status = connector->status; + if (connector->force) { if (connector->force == DRM_FORCE_ON || connector->force == DRM_FORCE_ON_DIGITAL) @@ -156,33 +158,31 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect if (connector->funcs->force) connector->funcs->force(connector); } else { - old_status = connector->status; - connector->status = connector->funcs->detect(connector, true); + } + + /* + * Normally either the driver's hpd code or the poll loop should + * pick up any changes and fire the hotplug event. But if + * userspace sneaks in a probe, we might miss a change. Hence + * check here, and if anything changed start the hotplug code. + */ + if (old_status != connector->status) { + DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %d to %d\n", + connector->base.id, + connector->name, + old_status, connector->status); /* - * Normally either the driver's hpd code or the poll loop should - * pick up any changes and fire the hotplug event. But if - * userspace sneaks in a probe, we might miss a change. Hence - * check here, and if anything changed start the hotplug code. + * The hotplug event code might call into the fb + * helpers, and so expects that we do not hold any + * locks. Fire up the poll struct instead, it will + * disable itself again. */ - if (old_status != connector->status) { - DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %d to %d\n", - connector->base.id, - connector->name, - old_status, connector->status); - - /* - * The hotplug event code might call into the fb - * helpers, and so expects that we do not hold any - * locks. Fire up the poll struct instead, it will - * disable itself again. - */ - dev->mode_config.delayed_event = true; - if (dev->mode_config.poll_enabled) - schedule_delayed_work(&dev->mode_config.output_poll_work, - 0); - } + dev->mode_config.delayed_event = true; + if (dev->mode_config.poll_enabled) + schedule_delayed_work(&dev->mode_config.output_poll_work, + 0); } /* Re-enable polling in case the global poll config changed. */ diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index 9ac4ffa6cce3..8cc69f0b64bc 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -167,39 +167,28 @@ 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) { + DRM_DEBUG_KMS("[CONNECTOR:%d:%s] force updated from %d to %d\n", connector->base.id, connector->name, old_status, connector->status);