From patchwork Tue Aug 13 11:02:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Marcinkiewicz X-Patchwork-Id: 11095227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 906871399 for ; Thu, 15 Aug 2019 08:35:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 822AA2811A for ; Thu, 15 Aug 2019 08:35:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 766442864B; Thu, 15 Aug 2019 08:35:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1C4C32811A for ; Thu, 15 Aug 2019 08:35:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 942676E8E5; Thu, 15 Aug 2019 08:34:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-vk1-xa4a.google.com (mail-vk1-xa4a.google.com [IPv6:2607:f8b0:4864:20::a4a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 225CC6E0EF for ; Tue, 13 Aug 2019 11:04:13 +0000 (UTC) Received: by mail-vk1-xa4a.google.com with SMTP id w185so27600vka.20 for ; Tue, 13 Aug 2019 04:04:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=7PGacRYXVFsNBUaK9AFFTq+0n3dK1YSXmAGYlruF6gc=; b=aYDRcepPB1DlXrbZQ0PYXIJQm0WjMp3HIuBisAYaZpXET8cocwNNi/lrBMVFkhyShA ukCVUNJu2Qg9nX7/zHtWuELHW6cZPVlpS5WpzyutWUVljYqafMZFg5utnBChJ0zRKTMn 3OzKuNdekjGFMFE98t6i0zFhwdrMlOCK6wiAwm0nVgSZVNDvUZ25wuk4Kt2AZElgPVBj 7AX0t4/bpNL7g2jVW7YjJ4JAr+b1o71jmxU+AVBXr56My4vYvZz9VWlUmVPyGac3f6Hz 6/ZD04fM7J7mQZAXaJQkh2yz4ypwcpYf1fxL0pOcxnFhxz+Bv64X1AXmQcv0z81IVwfr yguA== X-Gm-Message-State: APjAAAVA1E5UNAuRiMR+xvP13E1ydiyCnzLFscC2XxsX6kOowNLVO67x yE+0JNx9r0Lnh9ICJqjPIquusmke69zJopex+lmSVNkQmcfeMcnRaprFIn68suPL2J6haj6b+bg B3pcBwX09mj8BfuN0w0H1EYJCO5VmYkTc8rLzsYwftIBbwuKgIZb3pZN3peN3ekSmNXqRFBzH9A == X-Google-Smtp-Source: APXvYqyeQaoLuHS4lwvUuncTOZ0+P8t2+0nXHV4RbzHYhLOmVe7Ku4FbTLBE7VGYoUn20Yyj7SW3SjzIXg0= X-Received: by 2002:a9f:326e:: with SMTP id y43mr1637980uad.4.1565694251963; Tue, 13 Aug 2019 04:04:11 -0700 (PDT) Date: Tue, 13 Aug 2019 13:02:39 +0200 In-Reply-To: <20190813110300.83025-1-darekm@google.com> Message-Id: <20190813110300.83025-8-darekm@google.com> Mime-Version: 1.0 References: <20190813110300.83025-1-darekm@google.com> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog Subject: [PATCH v6 7/8] drm: dw-hdmi: use cec_notifier_conn_(un)register From: Dariusz Marcinkiewicz To: dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, hverkuil-cisco@xs4all.nl X-Mailman-Approved-At: Thu, 15 Aug 2019 08:34:55 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=7PGacRYXVFsNBUaK9AFFTq+0n3dK1YSXmAGYlruF6gc=; b=kmTjua/WpkiMq8nHLEd+LjG0YWASE8dJy8v8DnjnQqJTFv/ip1x0XgtkDMWpTTy6Vu JmjhuBtQZS0wboasCWyAFpMs/HYXk/5ypvK2xWr699mfV4KLxHyTTFpc5NLRaAUy9ZVb 09xFUN1d6+7JVLTL3TNM61eV33vnagLykDXXqMYp5hZ9kAOIchcfYZrpWsOdlXhDuEQf c4h6mkc1dUIB5OGoj6KQwqsRvSIXlTHimed7bvYENAz0v8az7SbA0Cf6TN9dh+X6+99l BzUQPyJV3qYFSbIPsuKMoq2LWYrn0SlY+qhBTtKxpUmnPjjPdUEWi6cu5zm7ql1p9oEX AwPg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 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 , Douglas Anderson , open list , Laurent Pinchart , Dariusz Marcinkiewicz , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use the new cec_notifier_conn_(un)register() functions to (un)register the notifier for the HDMI connector, and fill in the cec_connector_info. Changes since v4: - typo fix Changes since v2: - removed unnecessary NULL check before a call to cec_notifier_conn_unregister, - use cec_notifier_phys_addr_invalidate to invalidate physical address. Changes since v1: Add memory barrier to make sure that the notifier becomes visible to the irq thread once it is fully constructed. Signed-off-by: Dariusz Marcinkiewicz Tested-by: Hans Verkuil --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 36 ++++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 83b94b66e464e..c00184700bb9d 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -2194,6 +2194,8 @@ static int dw_hdmi_bridge_attach(struct drm_bridge *bridge) struct dw_hdmi *hdmi = bridge->driver_private; struct drm_encoder *encoder = bridge->encoder; struct drm_connector *connector = &hdmi->connector; + struct cec_connector_info conn_info; + struct cec_notifier *notifier; connector->interlace_allowed = 1; connector->polled = DRM_CONNECTOR_POLL_HPD; @@ -2207,6 +2209,18 @@ static int dw_hdmi_bridge_attach(struct drm_bridge *bridge) drm_connector_attach_encoder(connector, encoder); + cec_fill_conn_info_from_drm(&conn_info, connector); + + notifier = cec_notifier_conn_register(hdmi->dev, NULL, &conn_info); + if (!notifier) + return -ENOMEM; + /* + * Make sure that dw_hdmi_irq thread does see the notifier + * when it fully constructed. + */ + smp_wmb(); + hdmi->cec_notifier = notifier; + return 0; } @@ -2373,9 +2387,13 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id) phy_stat & HDMI_PHY_HPD, phy_stat & HDMI_PHY_RX_SENSE); - if ((phy_stat & (HDMI_PHY_RX_SENSE | HDMI_PHY_HPD)) == 0) - cec_notifier_set_phys_addr(hdmi->cec_notifier, - CEC_PHYS_ADDR_INVALID); + if ((phy_stat & (HDMI_PHY_RX_SENSE | HDMI_PHY_HPD)) == 0) { + struct cec_notifier *notifier; + + notifier = READ_ONCE(hdmi->cec_notifier); + if (notifier) + cec_notifier_phys_addr_invalidate(notifier); + } } if (intr_stat & HDMI_IH_PHY_STAT0_HPD) { @@ -2693,12 +2711,6 @@ __dw_hdmi_probe(struct platform_device *pdev, if (ret) goto err_iahb; - hdmi->cec_notifier = cec_notifier_get(dev); - if (!hdmi->cec_notifier) { - ret = -ENOMEM; - goto err_iahb; - } - /* * To prevent overflows in HDMI_IH_FC_STAT2, set the clk regenerator * N and cts values before enabling phy @@ -2796,9 +2808,6 @@ __dw_hdmi_probe(struct platform_device *pdev, hdmi->ddc = NULL; } - if (hdmi->cec_notifier) - cec_notifier_put(hdmi->cec_notifier); - clk_disable_unprepare(hdmi->iahb_clk); if (hdmi->cec_clk) clk_disable_unprepare(hdmi->cec_clk); @@ -2820,8 +2829,7 @@ static void __dw_hdmi_remove(struct dw_hdmi *hdmi) /* Disable all interrupts */ hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); - if (hdmi->cec_notifier) - cec_notifier_put(hdmi->cec_notifier); + cec_notifier_conn_unregister(hdmi->cec_notifier); clk_disable_unprepare(hdmi->iahb_clk); clk_disable_unprepare(hdmi->isfr_clk);