Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp470530ybl; Wed, 28 Aug 2019 00:16:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7pFclOTqxfZuHHFCkryShZvUP2Wo0nuDa2LxLwPbQ8HJN94TV306ObNd9epG9IZQTVUzf X-Received: by 2002:a17:902:82c4:: with SMTP id u4mr2904772plz.196.1566976617411; Wed, 28 Aug 2019 00:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566976617; cv=none; d=google.com; s=arc-20160816; b=HlXW1c3FOPt62AqdWaXeOnM5VhS+CuCxi3yCJYtBzh9O+P43qq56+LD0uegWbqWSou t/iUE7aMwuPFu2SYs1xcIHqxLvh42hVv5ldOGIdPH89e3drIEEp9eRedSh+MCZy0WPqS GNgudMz3AKDyxhcNkSEB7bqQohLowkjjS0utCcXUZc/c4F7mrUR/ht9sZ82z7y1Rlp/F XHSMQjfFSxevLbQ1WO1CC8ouTi1irN7x+httAIM0r10da2B5o6+ikGTEon4OttL5Q73V GZcnDNzmCz0cvVE+JK77nLiJSLDh+Qm0GgaNfpVuYAeP4RAOKCIHlVQ+7ui4TZpToYEs iiBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=pO6G2tJIWIc79GlfXyD7tYRlgpCJ3Wp5sfmQpLmODHQ=; b=gG2LeuXeEQjKbk/mo4XyYoldLxPFBpu8TtdpWgkQ9ONzSMPGN10vcw1dDvq0AK1Pzl W/vD/rvkx7YiuglsxMA88SW+yJOzviYLpd1v7RPlAuUiMmz3aDGEZjEIfUs0Qo2Gqea5 Wt/Bc8k11zN4npT9/9UlDisFRxNDxgquKavDDOP2OJdLQJe9iPCz0WErnaz921hePWYL IE/Y5CGDfT7sOzRXA79H1oKJOdv66WjP8VLLJB+GN9zoxe6QHP9pU53rsIqlSPZS0GIn C7bVbEriFq5Of759e+ZJMnRVK8qMg5OR6olGkI2GQxpa6Pi0AH8a4FqI3d42sOLoLfOH 32VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=haoiuUv6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a141si1905607pfd.49.2019.08.28.00.16.41; Wed, 28 Aug 2019 00:16:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=haoiuUv6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726432AbfH1HPp (ORCPT + 99 others); Wed, 28 Aug 2019 03:15:45 -0400 Received: from mail-yw1-f74.google.com ([209.85.161.74]:45934 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbfH1HPp (ORCPT ); Wed, 28 Aug 2019 03:15:45 -0400 Received: by mail-yw1-f74.google.com with SMTP id c129so1249168ywf.12 for ; Wed, 28 Aug 2019 00:15:45 -0700 (PDT) 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=pO6G2tJIWIc79GlfXyD7tYRlgpCJ3Wp5sfmQpLmODHQ=; b=haoiuUv6FwAVdeyp7BVc3pDAqvPC/ds02yPDw/Lpq4KFYSLid/2T8oP3DA7sI/XnNp bjngcL7mnMQro96+ZwOb1Gt25bxq37G4z/Ow3o6U0dzdJZjKslbNsk+zC9g7Qce0tV0u BzgU5+IQ3ZGQGPfxagkcalDyaPCw7MxZ8hC62nXstPdNeOEigWogCgbHn1F5PP0d8gi+ b+oWiiRZHQW/ZFtAcJrlup+jI6vXsdVAs6VYfOH/lNmSeWyt3ukutR8MA5ibwX/IlN4L 9woWplT7Z01+fxXDw2GJRh4M3TQcaFmmsCLk5z9SrkRBcCglOyOyo78zPoRN6fq5d04T Aaxg== 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=pO6G2tJIWIc79GlfXyD7tYRlgpCJ3Wp5sfmQpLmODHQ=; b=CzHo25kjtMNlfLyN8sZfs/DkXCy1ZsXGN1TGPpYOClsAdEibezWRXieu9O2uj+FAgg POkIiKbRngfWXw6FztKwgjKLdjc6VrYOpW5SGEqt2mj4KNjUi/VIR/eqCqHqgRPS0YJI Z+0YP6HpUjbdCoGbdeUaptbXfthzDWnMnvoOyjbhJQyUELcUZwXVQ/MCYHqhjeXcTxvo Gi2worBLPAHjApU7r+BC+E+e7o/wkYp6duh2RcgulbWNgVzQSgGefNDJqv8WpFwn440M 3euVQ07G3Iutylqj1rRGmIFBhZDWNn1ArrT8JKSGPjgE/QLVDZR3fUiKylwNe1mQk1c+ MpDg== X-Gm-Message-State: APjAAAWHWo2iLZKFZvAbqGetrGHMDQa9rEs8WfbWWtNRc8rM14iJwqnj xh9KMYkDfkoFUxeLuFWMROcEcemVOTE= X-Received: by 2002:a81:a68d:: with SMTP id d135mr2009010ywh.38.1566976544368; Wed, 28 Aug 2019 00:15:44 -0700 (PDT) Date: Wed, 28 Aug 2019 09:15:36 +0200 In-Reply-To: <20190819112207.57166-1-darekm@google.com> Message-Id: <20190828071536.56533-1-darekm@google.com> Mime-Version: 1.0 References: <20190819112207.57166-1-darekm@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v7.2 5/9] drm: tda998x: use cec_notifier_conn_(un)register From: Dariusz Marcinkiewicz To: dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, hverkuil-cisco@xs4all.nl Cc: Dariusz Marcinkiewicz , Russell King , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v7.1: - re-added if (!notifier).. Changes since v7: - typo fix Changes since v6: - move cec_notifier_conn_unregister to tda998x_bridge_detach, - add a mutex protecting accesses to a CEC notifier. Changes since v2: - cec_notifier_phys_addr_invalidate where appropriate, - don't check for NULL notifier before calling cec_notifier_conn_unregister. 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/i2c/tda998x_drv.c | 37 ++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c index 61e042918a7fc..2bc4f50458137 100644 --- a/drivers/gpu/drm/i2c/tda998x_drv.c +++ b/drivers/gpu/drm/i2c/tda998x_drv.c @@ -82,6 +82,8 @@ struct tda998x_priv { u8 audio_port_enable[AUDIO_ROUTE_NUM]; struct tda9950_glue cec_glue; struct gpio_desc *calib; + + struct mutex cec_notify_mutex; struct cec_notifier *cec_notify; }; @@ -805,8 +807,11 @@ static irqreturn_t tda998x_irq_thread(int irq, void *data) tda998x_edid_delay_start(priv); } else { schedule_work(&priv->detect_work); - cec_notifier_set_phys_addr(priv->cec_notify, - CEC_PHYS_ADDR_INVALID); + + mutex_lock(&priv->cec_notify_mutex); + cec_notifier_phys_addr_invalidate( + priv->cec_notify); + mutex_unlock(&priv->cec_notify_mutex); } handled = true; @@ -1331,6 +1336,8 @@ static int tda998x_connector_init(struct tda998x_priv *priv, struct drm_device *drm) { struct drm_connector *connector = &priv->connector; + struct cec_connector_info conn_info; + struct cec_notifier *notifier; int ret; connector->interlace_allowed = 1; @@ -1347,6 +1354,17 @@ static int tda998x_connector_init(struct tda998x_priv *priv, if (ret) return ret; + cec_fill_conn_info_from_drm(&conn_info, connector); + + notifier = cec_notifier_conn_register(priv->cec_glue.parent, + NULL, &conn_info); + if (!notifier) + return -ENOMEM; + + mutex_lock(&priv->cec_notify_mutex); + priv->cec_notify = notifier; + mutex_unlock(&priv->cec_notify_mutex); + drm_connector_attach_encoder(&priv->connector, priv->bridge.encoder); @@ -1366,6 +1384,11 @@ static void tda998x_bridge_detach(struct drm_bridge *bridge) { struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge); + mutex_lock(&priv->cec_notify_mutex); + cec_notifier_conn_unregister(priv->cec_notify); + priv->cec_notify = NULL; + mutex_unlock(&priv->cec_notify_mutex); + drm_connector_cleanup(&priv->connector); } @@ -1789,9 +1812,6 @@ static void tda998x_destroy(struct device *dev) cancel_work_sync(&priv->detect_work); i2c_unregister_device(priv->cec); - - if (priv->cec_notify) - cec_notifier_put(priv->cec_notify); } static int tda998x_create(struct device *dev) @@ -1812,6 +1832,7 @@ static int tda998x_create(struct device *dev) mutex_init(&priv->mutex); /* protect the page access */ mutex_init(&priv->audio_mutex); /* protect access from audio thread */ mutex_init(&priv->edid_mutex); + mutex_init(&priv->cec_notify_mutex); INIT_LIST_HEAD(&priv->bridge.list); init_waitqueue_head(&priv->edid_delay_waitq); timer_setup(&priv->edid_delay_timer, tda998x_edid_delay_done, 0); @@ -1916,12 +1937,6 @@ static int tda998x_create(struct device *dev) cec_write(priv, REG_CEC_RXSHPDINTENA, CEC_RXSHPDLEV_HPD); } - priv->cec_notify = cec_notifier_get(dev); - if (!priv->cec_notify) { - ret = -ENOMEM; - goto fail; - } - priv->cec_glue.parent = dev; priv->cec_glue.data = priv; priv->cec_glue.init = tda998x_cec_hook_init; -- 2.23.0.187.g17f5b7556c-goog