From patchwork Mon Oct 18 08:47:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Ser X-Patchwork-Id: 12565361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7242CC433EF for ; Mon, 18 Oct 2021 08:47:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3408160F02 for ; Mon, 18 Oct 2021 08:47:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3408160F02 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=emersion.fr Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 84F0A6E867; Mon, 18 Oct 2021 08:47:40 +0000 (UTC) Received: from mail-40136.proton.ch (mail-40136.proton.ch [185.70.40.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id CE2CD6E863 for ; Mon, 18 Oct 2021 08:47:39 +0000 (UTC) Date: Mon, 18 Oct 2021 08:47:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail; t=1634546858; bh=YQTkOvdAiABoAgJvHgRsVUQ62iLcGNwcFxXJ3n6mzBQ=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=uEia5BfW4xPgQ8xRemkEYMlbEuzx1D5OjtjbXqQqz6q4hZnr5jNf5X+xLYXRW65R2 Nk5HiQ/XYnJYFyNVbfF6A0CiMJ1oIURm8Ml+fzG74cnpXxXSuKHyA7LTz6YColbA6x 5Nv2R20aiIuJTAx5R0cUuRlmXiQFt5Grcx/XaDaqvvAuyQiquzX/FdoYOExJsM+A1y JtIQbrWrVcRephz8DMlyo+SFq53cRJwhkN2D0Eo0n2Bbpgwg+B/p48HpnlH0S54Vbv dIfisrWE5xnPhGzNyy4NOXztbQM2pHXaWpzTOq1H2tvfidcmtqG6v8XrHNGVRiKQt6 IBEN9ZuGhnwbA== To: dri-devel@lists.freedesktop.org From: Simon Ser Cc: Ville Syrjala , Sam Ravnborg , Maxime Ripard Subject: [PATCH v4 5/6] drm/probe-helper: use drm_kms_helper_connector_hotplug_event Message-ID: <20211018084707.32253-6-contact@emersion.fr> In-Reply-To: <20211018084707.32253-1-contact@emersion.fr> References: <20211018084707.32253-1-contact@emersion.fr> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Simon Ser Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If an hotplug event only updates a single connector, use drm_kms_helper_connector_hotplug_event instead of drm_kms_helper_hotplug_event. Changes in v4: - Simplify loop logic (Ville, Sam) - Update drm_connector_helper_hpd_irq_event (Maxime) Signed-off-by: Simon Ser Cc: Ville Syrjala Cc: Sam Ravnborg Cc: Maxime Ripard Reviewed-by: Maxime Ripard Reviewed-by: Sam Ravnborg --- drivers/gpu/drm/drm_probe_helper.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index 3aef3b188c99..682359512996 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -888,7 +888,7 @@ bool drm_connector_helper_hpd_irq_event(struct drm_connector *connector) mutex_unlock(&dev->mode_config.mutex); if (changed) { - drm_kms_helper_hotplug_event(dev); + drm_kms_helper_connector_hotplug_event(connector); drm_dbg_kms(dev, "[CONNECTOR:%d:%s] Sent hotplug event\n", connector->base.id, connector->name); @@ -927,9 +927,9 @@ EXPORT_SYMBOL(drm_connector_helper_hpd_irq_event); */ bool drm_helper_hpd_irq_event(struct drm_device *dev) { - struct drm_connector *connector; + struct drm_connector *connector, *first_changed_connector = NULL; struct drm_connector_list_iter conn_iter; - bool changed = false; + int changed = 0; if (!dev->mode_config.poll_enabled) return false; @@ -941,16 +941,25 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev) if (!(connector->polled & DRM_CONNECTOR_POLL_HPD)) continue; - if (check_connector_changed(connector)) - changed = true; + if (check_connector_changed(connector)) { + if (!first_changed_connector) { + drm_connector_get(connector); + first_changed_connector = connector; + } + + changed++; + } } drm_connector_list_iter_end(&conn_iter); mutex_unlock(&dev->mode_config.mutex); - if (changed) { + if (changed == 1) + drm_kms_helper_connector_hotplug_event(first_changed_connector); + else if (changed > 0) drm_kms_helper_hotplug_event(dev); - DRM_DEBUG_KMS("Sent hotplug event\n"); - } + + if (first_changed_connector) + drm_connector_put(first_changed_connector); return changed; }