From patchwork Thu Jan 21 23:33:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 12038683 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.6 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 50BA8C433E6 for ; Fri, 22 Jan 2021 08:46:43 +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 0AA1F235F9 for ; Fri, 22 Jan 2021 08:46:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0AA1F235F9 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 AC1246E9C8; Fri, 22 Jan 2021 08:46:01 +0000 (UTC) Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by gabe.freedesktop.org (Postfix) with ESMTPS id D4FEC6E979 for ; Thu, 21 Jan 2021 23:33:10 +0000 (UTC) Received: by mail-lj1-x22e.google.com with SMTP id l12so1953171ljc.3 for ; Thu, 21 Jan 2021 15:33:10 -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=nLR41DXLpX01EFGGqYnK9wGC2B/eZfRvF8CSAXF0+wM=; b=uW5eW3TZasEXRCDWT0TKkUuPWqXEULz2GdydhJeniRJoiM1zBePlAtNcnqi376CPhm gWC58dX5F0i+Vs0WgL2uoQFc416FPZKpX3cvmoq6j0O+biInsJYOfjCT9N6WVrJnjxoS 6onjhcbX0HZDdS3PsjiC1cUvSpoY5zyYIkt3QBYC6TrTTD5NwcfHJ+25qD7BBE6dtbED 1HYkhlHQiXPL1LaC1ZLBga9KzL7UO72SHgcynsqU/ZPyoyujvV9nFSQWz9uEQ6J2BIEX Cv10xXwNRVrXMetW0r8CtvnQDLWUe38sfIxvwxTLGep7Bk8WXnzxIs0K2xMIeLgXpA0+ ldwA== 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=nLR41DXLpX01EFGGqYnK9wGC2B/eZfRvF8CSAXF0+wM=; b=SAnddGwuShMsIr8UjP5Zi7mkV4JyNGsNJSaLxFWcmR26tJqFQNN5qSkXq5ICyirMRZ J2RIhluB4Pj8hsdZAEncxAz02x3bdIWlsYLahTM+vBH9GOZxLnVhu3FngbHGTa0oYlBT JBxvqDJHgtgvcABAfyxlAd/7toXKQoKTuywUNq11HRwX03VLgZPw9j03z6EET5dpL9j2 S1sJKZB098qyYwRU/ZVgBGWD7K5OluHJIbfUCT5xsbRxkoY6fvDj1JoxM4uvACezgxuw r9ckKxCTeQULMTlnK7qftWSyK2gbYaLJw2TB1d6/a21g1+oaUZpUR8kRsGou4QuEm7Sq XuoA== X-Gm-Message-State: AOAM531VFbDMivOWcbDGD/4su/tbWspUGtRw7ivoC5SDPbF05Wqcb08t Yyu87JvJEmaTcWJ3Z2Sd1NTtv4DRxS5Esycb X-Google-Smtp-Source: ABdhPJyTWeBrunTtFpZ8ytV0REk/xDX7IQe2MnkWbZ1xNoNwfR8h06feNxw//96kKZqiswmlj/GD/w== X-Received: by 2002:a2e:b4d1:: with SMTP id r17mr871501ljm.466.1611271988840; Thu, 21 Jan 2021 15:33:08 -0800 (PST) Received: from eriador.lan ([188.162.64.145]) by smtp.gmail.com with ESMTPSA id l28sm726969ljb.42.2021.01.21.15.33.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jan 2021 15:33:08 -0800 (PST) From: Dmitry Baryshkov To: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v4 1/3] drm/bridge/lontium-lt9611uxc: fix waiting for EDID to become available Date: Fri, 22 Jan 2021 02:33:01 +0300 Message-Id: <20210121233303.1221784-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210121233303.1221784-1-dmitry.baryshkov@linaro.org> References: <20210121233303.1221784-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 22 Jan 2021 08:45:43 +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 , Bjorn Andersson , 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. Signed-off-by: Dmitry Baryshkov Fixes: 0cbbd5b1a012 ("drm: bridge: add support for lontium LT9611UXC bridge") Reviewed-by: Bjorn Andersson Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c index 0c98d27f84ac..a59e811f1705 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) From patchwork Thu Jan 21 23:33:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 12038685 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.6 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 D4F87C433E0 for ; Fri, 22 Jan 2021 08:46:44 +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 93FE9235F9 for ; Fri, 22 Jan 2021 08:46:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93FE9235F9 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 4CE626E9EC; Fri, 22 Jan 2021 08:46:03 +0000 (UTC) Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D3166E97A for ; Thu, 21 Jan 2021 23:33:12 +0000 (UTC) Received: by mail-lf1-x12d.google.com with SMTP id m22so5021141lfg.5 for ; Thu, 21 Jan 2021 15:33:12 -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=LXLBko8Cp1/+g8qjMNN3MI6diNB1wKaGBp6QZagrUvw=; b=H6plmw40MZ+6SjPcYq1mPJlnbzickRzJ8SRP54NDX47VY7L8rNmE3rpyVZsiOtXeKi z8mVBmZKjk3FRQqTig0hlWgLXB+S4m9KwqcsBQFHlecYLl/fzpMOt5hd5+uJCkGUzN28 NJjT2CRKFPXHy7KeJxw1z6m9Bw6kaUnSevl/j80O2LY78QPrVz4KmfcX0ITxZ9753THh UoY5p4VENRuytKHWiXDJE5+73P7l5GR+DwttXHxCxQW1dc4oqsKs0dZ0bb/ElL/NoHFT LaCKSPE2HphOcd00RiIwmP4YelSr5zNzSB16Ar7VilBQSBw+640Mchk4kTsD9qNSYdTn 3lkw== 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=LXLBko8Cp1/+g8qjMNN3MI6diNB1wKaGBp6QZagrUvw=; b=XJsTJw8y4wn9qRBPNmj60ESDFdypB8DUfy4Y+oQvba15gF27Hn4+KZj/AB8bKhIkj0 Kh9DVZEdh1q/8Nu7bZ+brzTjXeVP9joXMY2fj6sOgIQR1OkZKHW77Ds7RVhnZ2kxCrGh 6GKleKb7cnVfcoD/flpTZdJKN37XbcVsAJ0RU2HI2nPK+vWJ0fT2SGz9E4E0FLMVo/1E VrOVvg2JFkKM4EI8b1T4VUynatBXDszMm+EETqEe7SY4WVuKqBSsvRyMNgClVBYsmSBN lq+j1zT/lndh405sbSaApviISv/WeZ1mGK2uhVfbqeBQq2G7fs55afzQE1VeOHzvU6eu v+Lw== X-Gm-Message-State: AOAM530JYgumK797Ljv/MqSdDG7fPfUjtvuwdzwiWY892gITcMPwmywL 3wvu+AuFpysSZKI0TG76yBR8PPmyWpCy6y1u X-Google-Smtp-Source: ABdhPJxU9TZ69d8kwFQwT1jPDTrC4CkWHg4Ij8Kb0Ur9THl9pf4CK7mzNN9n3FnXmF5jEMhDfzUQVA== X-Received: by 2002:a05:6512:612:: with SMTP id b18mr864962lfe.598.1611271990559; Thu, 21 Jan 2021 15:33:10 -0800 (PST) Received: from eriador.lan ([188.162.64.145]) by smtp.gmail.com with ESMTPSA id l28sm726969ljb.42.2021.01.21.15.33.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jan 2021 15:33:09 -0800 (PST) From: Dmitry Baryshkov To: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v4 2/3] drm/bridge/lontium-lt9611uxc: fix get_edid return code Date: Fri, 22 Jan 2021 02:33:02 +0300 Message-Id: <20210121233303.1221784-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210121233303.1221784-1-dmitry.baryshkov@linaro.org> References: <20210121233303.1221784-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 22 Jan 2021 08:45:43 +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 , Bjorn Andersson , Andrzej Hajda , Vinod Koul , Laurent Pinchart , Manivannan Sadhasivam , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Return NULL pointer from get_edid() callback rather than ERR_PTR() pointer, as DRM code does NULL checks rather than IS_ERR(). Also while we are at it, return NULL if getting EDID timed out. Signed-off-by: Dmitry Baryshkov Fixes: 0cbbd5b1a012 ("drm: bridge: add support for lontium LT9611UXC bridge") Reviewed-by: Bjorn Andersson Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c index a59e811f1705..b708700e182d 100644 --- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c +++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c @@ -505,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 Thu Jan 21 23:33:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 12038663 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.6 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 C9CBEC433DB for ; Fri, 22 Jan 2021 08:46:29 +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 7C16E235F9 for ; Fri, 22 Jan 2021 08:46:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C16E235F9 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 BEAFB6E9D8; Fri, 22 Jan 2021 08:46:01 +0000 (UTC) Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1BB826E97B for ; Thu, 21 Jan 2021 23:33:14 +0000 (UTC) Received: by mail-lf1-x12b.google.com with SMTP id o19so5054836lfo.1 for ; Thu, 21 Jan 2021 15:33:14 -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=wshZlF4l3dM7/942tJe1PTLnIy8oQxHCkv+Yoccj52Y=; b=nK4+stLKBtiPG93FQAlIQTeFqc44W+FLadMxRM1AguYtbsR5d9suMyKsSUdbN6L0t7 Kcbtz1mkcrwy6NuH12mTrmSiRQzTCdntFIJFWmZrC3GvOOMk66cZQhvQlqccT/ufyMYc OVKo61QS7bmkh+DL0ydk/U2njoHUxc/vOiKmbct9jljywuJvTGrxunU0r4f0g8z8V6Px 9oXNWxZyBQtamk2KnUSv2uvWjLuSFrPcLYnJWEKAXd8mO6f8Aq4WZ06qjGbEEa1ja34O uXnF5qAFpbGD2PsvnVex7b3V0yIKVQKtx2n9fLfMtmNTMgB8VjUHWIeZiPipb5dGMd5c nfog== 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=wshZlF4l3dM7/942tJe1PTLnIy8oQxHCkv+Yoccj52Y=; b=SvEtOYxVuE5tK7RvtqmInzzYQOmtpF5krCjn9//PsmS39kbfRLDzuuwUPtHNHm09iE d5bf0PDwCKzaTtBb2KGX++eBqYwLUKf8C+ul+RZA95JHO7J85OLnAFIPO9qd/aQA5fLR XYUMiEE1BdulOHZNk1TD/xpbwgV4bjG3sKJzv5iOMiUAed3pXJNz2rMOvVGwnBe6QRCs 3Itmt87RN+z4ukO4QGekC7uSvrKzM7SWioII0stfbQbDn0HRf6aXBlDkzQNDOc3g3foI /M5FBLbDOrTjgGpWJTWOy/A/dVhNpw2GSd1Nk0qqkv7JLyQcut9OEfvvC8/y7HdDZ5Cv vtjw== X-Gm-Message-State: AOAM533tFqySGxSeN7museaNCZ3DDqubfdRIV15t4x74XeYIKAAq7+Nr YM4+03nJarodwbNKveG7nL1IrtJiwTskrW6M X-Google-Smtp-Source: ABdhPJz4rYea/E+pyD21/b6h5FgZFOC7Kv2hgLlVOIq8wTHlmlSgQNGD45OjvH7xBIHOYRGF2awqsg== X-Received: by 2002:a05:6512:131f:: with SMTP id x31mr842004lfu.552.1611271992194; Thu, 21 Jan 2021 15:33:12 -0800 (PST) Received: from eriador.lan ([188.162.64.145]) by smtp.gmail.com with ESMTPSA id l28sm726969ljb.42.2021.01.21.15.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jan 2021 15:33:11 -0800 (PST) From: Dmitry Baryshkov To: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v4 3/3] drm/bridge/lontium-lt9611uxc: move HPD notification out of IRQ handler Date: Fri, 22 Jan 2021 02:33:03 +0300 Message-Id: <20210121233303.1221784-4-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210121233303.1221784-1-dmitry.baryshkov@linaro.org> References: <20210121233303.1221784-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 22 Jan 2021 08:45:43 +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 Fixes: 0cbbd5b1a012 ("drm: bridge: add support for lontium LT9611UXC bridge") Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 46 +++++++++++++++++----- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c index b708700e182d..fee27952ec6d 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,8 @@ struct lt9611uxc { bool hpd_supported; bool edid_read; + /* can be accessed from different threads, so protect this with ocm_lock */ + bool hdmi_connected; uint8_t fw_version; }; @@ -143,23 +147,41 @@ static irqreturn_t lt9611uxc_irq_thread_handler(int irq, void *dev_id) if (irq_status) regmap_write(lt9611uxc->regmap, 0xb022, 0); - lt9611uxc_unlock(lt9611uxc); - 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) - 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); } + lt9611uxc_unlock(lt9611uxc); + return IRQ_HANDLED; } +static void lt9611uxc_hpd_work(struct work_struct *work) +{ + struct lt9611uxc *lt9611uxc = container_of(work, struct lt9611uxc, work); + bool connected; + + if (lt9611uxc->connector.dev) + drm_kms_helper_hotplug_event(lt9611uxc->connector.dev); + else { + + mutex_lock(<9611uxc->ocm_lock); + connected = lt9611uxc->hdmi_connected; + mutex_unlock(<9611uxc->ocm_lock); + + drm_bridge_hpd_notify(<9611uxc->bridge, + connected ? + connector_status_connected : + connector_status_disconnected); + } +} + static void lt9611uxc_reset(struct lt9611uxc *lt9611uxc) { gpiod_set_value_cansleep(lt9611uxc->reset_gpio, 1); @@ -447,18 +469,21 @@ 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; + + lt9611uxc_lock(lt9611uxc); if (lt9611uxc->hpd_supported) { - lt9611uxc_lock(lt9611uxc); ret = regmap_read(lt9611uxc->regmap, 0xb023, ®_val); - lt9611uxc_unlock(lt9611uxc); if (ret) dev_err(lt9611uxc->dev, "failed to read hpd status: %d\n", ret); else connected = reg_val & BIT(1); } + lt9611uxc->hdmi_connected = connected; + + lt9611uxc_unlock(lt9611uxc); return connected ? connector_status_connected : connector_status_disconnected; @@ -931,6 +956,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 +994,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);