From patchwork Tue Sep 14 20:22:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 12494665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D46BC433F5 for ; Tue, 14 Sep 2021 20:22:51 +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 4CD4661178 for ; Tue, 14 Sep 2021 20:22:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4CD4661178 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org 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 A10446E7FA; Tue, 14 Sep 2021 20:22:45 +0000 (UTC) Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by gabe.freedesktop.org (Postfix) with ESMTPS id B7FC36E7FA for ; Tue, 14 Sep 2021 20:22:40 +0000 (UTC) Received: by mail-pl1-x62f.google.com with SMTP id bg1so129042plb.13 for ; Tue, 14 Sep 2021 13:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vpEXnbBKR0bloKgXMxBkZufR69FGR0namo850/sSuY0=; b=QD10I0+TVx4/lj2zfWzAgsFTRCOeUemwh5dNMsa7Dl3/o3jNo71bM29C3c1wQjJnog qNHCZT3p5Go/d2liL5u5rqpZiqfFAWm+tSypPxiw4MTgjDCWgYwSGRSX8WkDVu5c5hpg eBPZD62X+jCyS9fgUWHAmPz8GUjZK+sepSqD4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vpEXnbBKR0bloKgXMxBkZufR69FGR0namo850/sSuY0=; b=CPOtQhTIof0U756B8xZvzW72hVlYP/TH0OrMHS0uL1BH33aJOzH7+hEAIWyYjFYIh7 JKthU+EtsVd7tP6gJCmJAJOTvNvxufnd1TJpAsKV0gjxjEk93IrmYCfSqVAiPBbHfOC2 z5hoRcTZgM5lsX4Ms5xkanXD5oTDr65j4Oi7F0CuFCokcahKwhJZV91urk4AqpWxof9e vIBThMUrOp+l31J6IjtQnmc/YCRuSEvJBP1K7QtiZ/6s3MhhB0vrPcq3CXIKPPDIJIY3 nQK5Pf9KkKFI5p4A5icXsSWD/liNtDVyQDH8lsQvJ9tqqOqLTEysaZC3H2UrJJ73dhJ2 wvZQ== X-Gm-Message-State: AOAM531n5ptcMRtCEieLpNA9PPH522I1G2TWL9YYE0H+W1kVRc60IOti LNSz7jEmfL7nYIwRRUoTVCrf8A== X-Google-Smtp-Source: ABdhPJwPexQPBm3N8BIYYm1w0FBveH0mVeVCcozwvbwFgJXed/YNyR9bZk3JoDvWePbXriTorIBX1Q== X-Received: by 2002:a17:902:650b:b0:13a:123a:4ef9 with SMTP id b11-20020a170902650b00b0013a123a4ef9mr16501693plk.49.1631650960249; Tue, 14 Sep 2021 13:22:40 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:f38f:9d0f:3eba:f8c4]) by smtp.gmail.com with ESMTPSA id 141sm12185393pgg.16.2021.09.14.13.22.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 13:22:39 -0700 (PDT) From: Douglas Anderson To: Thierry Reding , Rob Herring , Sam Ravnborg Cc: devicetree@vger.kernel.org, Steev Klimaszewski , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, David Airlie , Maarten Lankhorst , Thomas Zimmermann , Linus W , Bjorn Andersson , Daniel Vetter , Maxime Ripard , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [PATCH v5 13/15] drm/panel-edp: Fix "prepare_to_enable" if panel doesn't handle HPD Date: Tue, 14 Sep 2021 13:22:00 -0700 Message-Id: <20210914132020.v5.13.Ia8288d36df4b12770af59ae3ff73ef7e08fb4e2e@changeid> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog In-Reply-To: <20210914202202.1702601-1-dianders@chromium.org> References: <20210914202202.1702601-1-dianders@chromium.org> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" While cleaning up the descriptions of the delay for eDP panels I realized that we'd have a bug if any panels need the "prepare_to_enable" but HPD handling isn't happening in the panel driver. Let's put in a stopgap to at least make us not violate timings. This is not perfectly optimal but trying to do better is hard. At the moment only 2 panels specify this delay and only 30 ms is at stake. These panels are also currently hooked up with "hpd-gpios" so effectively this "fix" is just a theoretical fix and won't actually do anything for any devices currently supported in mainline. Signed-off-by: Douglas Anderson Acked-by: Sam Ravnborg --- (no changes since v4) Changes in v4: - panel-simple-edp => panel-edp Changes in v3: - Fix "prepare_to_enable" patch new for v3. drivers/gpu/drm/panel/panel-edp.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index 80a37a4e5750..a83ef9905ea7 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -508,12 +508,32 @@ static int panel_edp_prepare(struct drm_panel *panel) static int panel_edp_enable(struct drm_panel *panel) { struct panel_edp *p = to_panel_edp(panel); + unsigned int delay; if (p->enabled) return 0; - if (p->desc->delay.enable) - msleep(p->desc->delay.enable); + delay = p->desc->delay.enable; + + /* + * If there is a "prepare_to_enable" delay then that's supposed to be + * the delay from HPD going high until we can turn the backlight on. + * However, we can only count this if HPD is handled by the panel + * driver, not if it goes to a dedicated pin on the controller. + * If we aren't handling the HPD pin ourselves then the best we + * can do is assume that HPD went high immediately before we were + * called (and link training took zero time). + * + * NOTE: if we ever end up in this "if" statement then we're + * guaranteed that the panel_edp_wait() call below will do no delay. + * It already handles that case, though, so we don't need any special + * code for it. + */ + if (p->desc->delay.prepare_to_enable && !p->hpd_gpio && !p->no_hpd) + delay = max(delay, p->desc->delay.prepare_to_enable); + + if (delay) + msleep(delay); panel_edp_wait(p->prepared_time, p->desc->delay.prepare_to_enable);