From patchwork Fri Nov 27 09:23:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 11935413 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 956C8C2D0E4 for ; Fri, 27 Nov 2020 10:12:08 +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 2578220674 for ; Fri, 27 Nov 2020 10:12:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xXo1mpme" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2578220674 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CC4446EB9D; Fri, 27 Nov 2020 10:11:40 +0000 (UTC) Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id AF3806EB71 for ; Fri, 27 Nov 2020 09:23:20 +0000 (UTC) Received: by mail-lj1-x241.google.com with SMTP id j10so5193887lja.5 for ; Fri, 27 Nov 2020 01:23:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dDVGerivDhcovGvlrg4RdGN4PhZ+oBrQSqPNlOoN/KE=; b=xXo1mpme3FQkxz7YOniDXUXLh1hheRztkvuFD0BgV002eFkuLs9/dcgDiWWCkpLt1h e1g5XSCd/9I2I221sERnEP5Fl3x2MhneduRxljWEjh4cMBhD/La7eSfE+qUnugOnZmvQ CTYXTVxuM/C5YrnndrLDTMSY/njX9IEXElhdv3mUHj9yJCDG845sHyPDxgeFGjR2Kt6B fYw7wfn1t5zKg1WL1I18oLC5Aq1lLeCDWszonc6zgKx8SDoPTC+FPtYEisuLI5e4jASN 3pFbXg6iE0k75/7eStyKP54QMo2n+JxTlPeaRbJPAhsys/nCn/ARQB+lI/K9/Yx9xU8m 29GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dDVGerivDhcovGvlrg4RdGN4PhZ+oBrQSqPNlOoN/KE=; b=Ts+RRWmRwxXDEDJiYKwXSjSBwAgjgOfml2FS5SX2UHbRbjofMKgWYxrPJ6zl+c4mkz ZezovoAgMNudAAo8fnKVZNdUx/ikSKDi3wyOGs2+FxT8ZTXt99x2ypda0PkOaKhTWp70 x5NMLrb+5+atTbsz7mDA2AmSCz1OKG1bcZWPA6tqn28FD9R9zfV1chu5MKZTGFPWVw8d 5ChUgjfR2ScsBE/QTg+jJomaGGr9xcU6f8Vba5Zahum4e11xG3yGHmTnj6ghUVVrEDka E8mGNCBcfDJR5tEmwBUDsusM5WtfUrrezTsV1mk5jptHZhDP+chM9gtCPssg7RgUu6/9 SdBQ== X-Gm-Message-State: AOAM533LrwvvxAPArnxk40LNsMulpXxUJWDzgbNnJdcUUFgi0OnCv/00 joaaILeaDlWGlvlH3mxNyqkBcO22oGyXfA== X-Google-Smtp-Source: ABdhPJw2T3Uh8Fn3UGKCfLRGJRb/SWo+VxiKeMYglY+tch0H/sdr9lyw+X2xetxPm3T4VEjuJwptvA== X-Received: by 2002:a2e:998e:: with SMTP id w14mr3176710lji.100.1606468998738; Fri, 27 Nov 2020 01:23:18 -0800 (PST) Received: from eriador.lumag.spb.ru ([188.162.64.79]) by smtp.gmail.com with ESMTPSA id a6sm615442lfi.107.2020.11.27.01.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2020 01:23:17 -0800 (PST) From: Dmitry Baryshkov To: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 1/2] drm/bridge/lontium-lt9611uxc: fix waiting for EDID to become available Date: Fri, 27 Nov 2020 12:23:15 +0300 Message-Id: <20201127092316.122246-1-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 27 Nov 2020 10:11:27 +0000 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: , Cc: Jernej Skrabec , Jonas Karlman , David Airlie , Neil Armstrong , Andrzej Hajda , Vinod Koul , Laurent Pinchart , Manivannan Sadhasivam , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" - Call wake_up() when EDID ready event is received to wake wait_event_interruptible_timeout() - Increase waiting timeout, reading EDID can take longer than 100ms, so let's be on a safe side. - Return NULL pointer from get_edid() callback rather than ERR_PTR() pointer, as DRM code does NULL checks rather than IS_ERR(). Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c index 0c98d27f84ac..b708700e182d 100644 --- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c +++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c @@ -145,8 +145,10 @@ static irqreturn_t lt9611uxc_irq_thread_handler(int irq, void *dev_id) lt9611uxc_unlock(lt9611uxc); - if (irq_status & BIT(0)) + if (irq_status & BIT(0)) { lt9611uxc->edid_read = !!(hpd_status & BIT(0)); + wake_up_all(<9611uxc->wq); + } if (irq_status & BIT(1)) { if (lt9611uxc->connector.dev) @@ -465,7 +467,7 @@ static enum drm_connector_status lt9611uxc_bridge_detect(struct drm_bridge *brid static int lt9611uxc_wait_for_edid(struct lt9611uxc *lt9611uxc) { return wait_event_interruptible_timeout(lt9611uxc->wq, lt9611uxc->edid_read, - msecs_to_jiffies(100)); + msecs_to_jiffies(500)); } static int lt9611uxc_get_edid_block(void *data, u8 *buf, unsigned int block, size_t len) @@ -503,7 +505,10 @@ static struct edid *lt9611uxc_bridge_get_edid(struct drm_bridge *bridge, ret = lt9611uxc_wait_for_edid(lt9611uxc); if (ret < 0) { dev_err(lt9611uxc->dev, "wait for EDID failed: %d\n", ret); - return ERR_PTR(ret); + return NULL; + } else if (ret == 0) { + dev_err(lt9611uxc->dev, "wait for EDID timeout\n"); + return NULL; } return drm_do_get_edid(connector, lt9611uxc_get_edid_block, lt9611uxc); From patchwork Fri Nov 27 09:23:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 11935391 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 505AAC63777 for ; Fri, 27 Nov 2020 10:11: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 CA65520674 for ; Fri, 27 Nov 2020 10:11:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VgzMNMCY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA65520674 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3FCDA6EB84; Fri, 27 Nov 2020 10:11:39 +0000 (UTC) Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 834C96EB71 for ; Fri, 27 Nov 2020 09:23:22 +0000 (UTC) Received: by mail-lj1-x242.google.com with SMTP id t22so5210723ljk.0 for ; Fri, 27 Nov 2020 01:23:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jap4CSSphbNhkQ0riEHLjy5ZHv6p/5lP6LbqE0EEZnE=; b=VgzMNMCYncvkjKZ7PGOsRpkTT1+54DEF/4ixFBc7ESvn9jYTi7c8ZUHHu5FiGgEoWG Ju+IiUrvVm93SUL/SLg+4KbI0MtS0zzN/fgX1TykpiB/DDk9Z4jjhab7BtieElUEWoOI md2ZVWBEr+F1b5UG/spnhu0pZdvj9ViMXlDSqqSev0usIQMKFqYbHlh/iTdZz1WW47my +VhfNNQgYyldQneoWQkGnPVqfR2bP7CmBPnRzQsrDNdR3Zdx+GW5xAiBgHXIe+/lN3Mu jNKohrj7OWNtuYNt8JU/ptDz1itNFH1ojC24cgiRSkqUyzxILtH/tCfMbp4GpzdHoQbb aA1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jap4CSSphbNhkQ0riEHLjy5ZHv6p/5lP6LbqE0EEZnE=; b=pzdTDGMB4ERYr+yZ5kYFYq9udsproRPcCY5cnFVzkeeWNqbMfMB9Kj/Ik7mHliaQgC 9SbId/hnARaKYLSvCqfmSVZ4Gws/SSz+gfyOqeg6/arRdU4g5fLB6mqDdbk3FVKeK0LS 2dPxlUOzsX7aXvdMwJJYVt9f9LuCPFZkQV4w43ugAt4Om1z/yCyntQ3AlS7kaPtBqgf6 eyD5En1dxnLg3v9cTWdM+rt9KWhqEUZsIE9DrUeUS1PnV+ZpwUT8CewDCtXksHRJN2yq VVH8alSLUrHu/lIXvLe3beaeRFPZCVVVCYv2GcHS0QukIYPonk+KkXBWDs4xAULKqmWM lRiA== X-Gm-Message-State: AOAM531KwwwA1wCZckEmb0aRLD7dlEUubw5Y16DQ9tKy8yFmnB8CqOh4 FCYjJTnPDOr8nrKvXvXrbtGSIsXmeX/7fw== X-Google-Smtp-Source: ABdhPJxuyB4IHPUPxJcrPeo6dQYafbut5vK33LBKEmQw43u7jbE7CeVq373AT576hexUZjM0dJT27A== X-Received: by 2002:a2e:7a18:: with SMTP id v24mr2999342ljc.224.1606469000477; Fri, 27 Nov 2020 01:23:20 -0800 (PST) Received: from eriador.lumag.spb.ru ([188.162.64.79]) by smtp.gmail.com with ESMTPSA id a6sm615442lfi.107.2020.11.27.01.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2020 01:23:19 -0800 (PST) From: Dmitry Baryshkov To: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 2/2] drm/bridge/lontium-lt9611uxc: move HPD notification out of IRQ handler Date: Fri, 27 Nov 2020 12:23:16 +0300 Message-Id: <20201127092316.122246-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201127092316.122246-1-dmitry.baryshkov@linaro.org> References: <20201127092316.122246-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 27 Nov 2020 10:11:27 +0000 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: , Cc: Jernej Skrabec , Jonas Karlman , David Airlie , Neil Armstrong , Andrzej Hajda , Vinod Koul , Laurent Pinchart , Manivannan Sadhasivam , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" drm hotplug handling code (drm_client_dev_hotplug()) can wait on mutex, thus delaying further lt9611uxc IRQ events processing. It was observed occasionally during bootups, when drm_client_modeset_probe() was waiting for EDID ready event, which was delayed because IRQ handler was stuck trying to deliver hotplug event. Move hotplug notifications from IRQ handler to separate work to be able to process IRQ events without delays. Signed-off-by: Dmitry Baryshkov Reviewed-by: Bjorn Andersson --- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c index b708700e182d..88630bc2921f 100644 --- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c +++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -36,6 +37,7 @@ struct lt9611uxc { struct mutex ocm_lock; struct wait_queue_head wq; + struct work_struct work; struct device_node *dsi0_node; struct device_node *dsi1_node; @@ -52,6 +54,7 @@ struct lt9611uxc { bool hpd_supported; bool edid_read; + bool hdmi_connected; uint8_t fw_version; }; @@ -151,15 +154,26 @@ static irqreturn_t lt9611uxc_irq_thread_handler(int irq, void *dev_id) } if (irq_status & BIT(1)) { - if (lt9611uxc->connector.dev) - drm_kms_helper_hotplug_event(lt9611uxc->connector.dev); - else - drm_bridge_hpd_notify(<9611uxc->bridge, !!(hpd_status & BIT(1))); + lt9611uxc->hdmi_connected = !!(hpd_status & BIT(1)); + schedule_work(<9611uxc->work); } return IRQ_HANDLED; } +void lt9611uxc_hpd_work(struct work_struct *work) +{ + struct lt9611uxc *lt9611uxc = container_of(work, struct lt9611uxc, work); + + if (lt9611uxc->connector.dev) + drm_kms_helper_hotplug_event(lt9611uxc->connector.dev); + else + drm_bridge_hpd_notify(<9611uxc->bridge, + lt9611uxc->hdmi_connected ? + connector_status_connected : + connector_status_disconnected); +} + static void lt9611uxc_reset(struct lt9611uxc *lt9611uxc) { gpiod_set_value_cansleep(lt9611uxc->reset_gpio, 1); @@ -447,7 +461,7 @@ static enum drm_connector_status lt9611uxc_bridge_detect(struct drm_bridge *brid struct lt9611uxc *lt9611uxc = bridge_to_lt9611uxc(bridge); unsigned int reg_val = 0; int ret; - int connected = 1; + bool connected = true; if (lt9611uxc->hpd_supported) { lt9611uxc_lock(lt9611uxc); @@ -457,8 +471,9 @@ static enum drm_connector_status lt9611uxc_bridge_detect(struct drm_bridge *brid if (ret) dev_err(lt9611uxc->dev, "failed to read hpd status: %d\n", ret); else - connected = reg_val & BIT(1); + connected = !!(reg_val & BIT(1)); } + lt9611uxc->hdmi_connected = connected; return connected ? connector_status_connected : connector_status_disconnected; @@ -931,6 +946,8 @@ static int lt9611uxc_probe(struct i2c_client *client, lt9611uxc->fw_version = ret; init_waitqueue_head(<9611uxc->wq); + INIT_WORK(<9611uxc->work, lt9611uxc_hpd_work); + ret = devm_request_threaded_irq(dev, client->irq, NULL, lt9611uxc_irq_thread_handler, IRQF_ONESHOT, "lt9611uxc", lt9611uxc); @@ -967,6 +984,7 @@ static int lt9611uxc_remove(struct i2c_client *client) struct lt9611uxc *lt9611uxc = i2c_get_clientdata(client); disable_irq(client->irq); + flush_scheduled_work(); lt9611uxc_audio_exit(lt9611uxc); drm_bridge_remove(<9611uxc->bridge);