Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2869901rwb; Thu, 29 Sep 2022 16:40:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ru1b/s/uckawd9wIbq9RyoAx+tofqTdo9N8XtBwK+vB45y+E7yKU8NnU9mkvIdNsY+0FU X-Received: by 2002:a17:906:da86:b0:77a:52b3:da48 with SMTP id xh6-20020a170906da8600b0077a52b3da48mr4387601ejb.373.1664494801179; Thu, 29 Sep 2022 16:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664494801; cv=none; d=google.com; s=arc-20160816; b=ekBHByQlA1hR22Vr6iHZVfy704nh3Nl/juxCiFjxiIXEdZiphyRVJYuG9dxBQPLNQ3 0EiYupEhwvdsNMIId4fe+AHD2dHfFuBIAG6M9A18/qEFLYdWu6Cc8ANbnNxBeMKA3VHt gyiP5ZvJPqa6y8IMSdmBH4Mpx2JNAw6GbkTMzJHucgh6diIuJb1HOF43z2nA7zeTUeyW GaKkzoCEH/z74O5a1llsOeKLZifk8rmUA3hT8y7qhLHXdVAvQ8Orqeg2JmhP9smzar5p 9GeXJkufEj2oHe+Q4H/Z/oe29lYqT9D8h54Li7LuUaWvJr8pnQuvPInHu84F0DgKlX45 VrtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wX6zRESHhtQ20lz/WE67BzyoxRgifQyQeGWbBD1mawk=; b=INeq/0qFvqZqn88vmof0a4nJVkCZt7Gu09NbcmMhnivxNBzl+SUjpdaC5NTZts2alZ vkcxBvidk/mwiU7ft7I/WbAZVkBDPLxYj6tHl694QFXX7/L5WWi9X+1WIdn0BWRinIYr S7rMCOVDH4lryhmsskHz3T50P0NSnp4KGwI9DtLtbhNfSpwpxOgZ7gHxWtCSN4N2nBve qvMm/6dB98yltQFYHKJ8vC4t4gRrZxcZDxct8TY6DNQozOlMqyWWPBobw7TlI2WZCOkE RYSpt9mfB24dQZQws1YOTsJr2MH7WUQIx+YJlwi4AG1NhMRHngDCRXef7Fyfy3hp7VVr b4Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=Wm76qp2D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm20-20020a170907949400b0077b2e822b8fsi601607ejc.76.2022.09.29.16.39.36; Thu, 29 Sep 2022 16:40:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=Wm76qp2D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229621AbiI2XdR (ORCPT + 99 others); Thu, 29 Sep 2022 19:33:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiI2XdP (ORCPT ); Thu, 29 Sep 2022 19:33:15 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEAD9148A38 for ; Thu, 29 Sep 2022 16:33:13 -0700 (PDT) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A5C8747C; Fri, 30 Sep 2022 01:33:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664494389; bh=rsXQPfoODOoV2YweOgK8vKwcfwOCqbxKs2G25NITsXE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Wm76qp2D4KHujb8qnUUTH+dm4zmzZn2BKqGocvRED6/EcWRUtfKQUnL8Cm+vxm/Xm NY4r/893XoVIsInA/tSKO3nseZpmblPZ5ojyodhs3mfwPIBZBNUZ/kzx30uFHZd+lX 6IFzsk5SGu61QuHzRQqGGr49o3TStmnpvwfY/nWM= Date: Fri, 30 Sep 2022 02:33:08 +0300 From: Laurent Pinchart To: Michael Rodin , Maarten Lankhorst , Maxime Ripard Cc: Thomas Zimmermann , David Airlie , Daniel Vetter , Alex Deucher , Philipp Zabel , Sean Paul , Vincent Abriou , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, michael@rodin.online, erosca@de.adit-jv.com Subject: Re: [PATCH] drm: do not call detect for connectors which are forced on Message-ID: References: <20220826091121.389315-1-mrodin@de.adit-jv.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220826091121.389315-1-mrodin@de.adit-jv.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Michael, Thank you for the patch. Sorry for the late reply, I wasn't on the CC list so I didn't notice it. On Fri, Aug 26, 2022 at 11:11:21AM +0200, Michael Rodin wrote: > "detect" should not be called and its return value shall not be used when a > connector is forced as hinted in the commit d50ba256b5f1 ("drm/kms: start > adding command line interface using fb.") and the commit 6fe14acd496e > ("drm: Document drm_connector_funcs"). One negative side effect of doing > this is observed on the RCar3 SoCs which use the dw-hdmi driver. It > continues executing drm_helper_hpd_irq_event even if its connector is > forced to ON. As consequence drm_helper_hpd_irq_event calls "detect" so the > connector status is updated to "disconnected": > > [ 420.201527] [drm:drm_helper_hpd_irq_event] [CONNECTOR:76:HDMI-A-1] status updated from connected to disconnected > > This status is corrected by drm_helper_probe_single_connector_modes shortly > after this because this function checks if a connector is forced: > > [ 420.218703] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:76:HDMI-A-1] status updated from disconnected to connected > > To avoid similar issues this commit adapts functions which call "detect" > so they check if a connector is forced and return the correct status. > > Fixes: 949f08862d66 ("drm: Make the connector .detect() callback optional") Is this really the right fixes tag ? The call to .detect() in drm_helper_hpd_irq_event() predates that commit. > Signed-off-by: Michael Rodin > --- > drivers/gpu/drm/drm_probe_helper.c | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c > index bb427c5a4f1f..1691047d0472 100644 > --- a/drivers/gpu/drm/drm_probe_helper.c > +++ b/drivers/gpu/drm/drm_probe_helper.c > @@ -289,7 +289,12 @@ drm_helper_probe_detect_ctx(struct drm_connector *connector, bool force) > retry: > ret = drm_modeset_lock(&connector->dev->mode_config.connection_mutex, &ctx); > if (!ret) { > - if (funcs->detect_ctx) > + if (connector->force == DRM_FORCE_ON || > + connector->force == DRM_FORCE_ON_DIGITAL) > + ret = connector_status_connected; > + else if (connector->force == DRM_FORCE_OFF) > + ret = connector_status_disconnected; > + else if (funcs->detect_ctx) > ret = funcs->detect_ctx(connector, &ctx, force); > else if (connector->funcs->detect) > ret = connector->funcs->detect(connector, force); > @@ -340,7 +345,14 @@ drm_helper_probe_detect(struct drm_connector *connector, > if (ret) > return ret; > > - if (funcs->detect_ctx) > + if (connector->force == DRM_FORCE_ON || > + connector->force == DRM_FORCE_ON_DIGITAL) > + ret = connector_status_connected; > + else if (connector->force == DRM_FORCE_OFF) > + ret = connector_status_disconnected; > + else if (funcs->detect_ctx) > + ret = funcs->detect_ctx(connector, ctx, force); > + else if (funcs->detect_ctx) > ret = funcs->detect_ctx(connector, ctx, force); Those two conditions are identical. > else if (connector->funcs->detect) > ret = connector->funcs->detect(connector, force); The same logic is used in two places in this patch. Could this be factored out to a separate function ? It may even be possible to refactor drm_helper_probe_detect() and drm_helper_probe_detect_ctx() to share more code between the two functions. This being said, I'm not sure this is the right fix. Beside the i915 and nouveau drivers, the only callers of drm_helper_probe_detect() are drm_helper_probe_single_connector_modes(), output_poll_execute() and check_connector_changed() in this file. The first two functions already check connector->force and skip the call to drm_helper_probe_detect() if the connector is forced. Only check_connector_changed() is missing that check. Wouldn't it be simpler to return false in that function if connector->force is set ? Another question is whether it is valid for the dw-hdmi driver to call drm_helper_hpd_irq_event() when the connector status is forced. Shouldn't HPD events be ignored in that case ? The detection code has grown quite complex over time, I would really appreciate input from Maxime and Maarten on this. -- Regards, Laurent Pinchart