From patchwork Mon Feb 11 09:46:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 10805387 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 9AFD66C2 for ; Mon, 11 Feb 2019 09:48:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D40B29DEA for ; Mon, 11 Feb 2019 09:48:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 719ED29E0B; Mon, 11 Feb 2019 09:48:08 +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,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 F339F29DEA for ; Mon, 11 Feb 2019 09:48:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 43EC66E43C; Mon, 11 Feb 2019 09:47:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id B2C416E274 for ; Mon, 11 Feb 2019 09:47:21 +0000 (UTC) Received: from pendragon.brusselsairlines.com (233.56-78-194.adsl-static.isp.belgacom.be [194.78.56.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9D0D49D9; Mon, 11 Feb 2019 10:47:13 +0100 (CET) From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 11/50] drm/omap: Remove connection checks from display .enable() and .remove() Date: Mon, 11 Feb 2019 11:46:26 +0200 Message-Id: <20190211094705.2845-12-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190211094705.2845-1-laurent.pinchart@ideasonboard.com> References: <20190211094705.2845-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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: Tomi Valkeinen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The displays (connectors, panels and encoders) return an error from their .enable() handler when the dss device is not connected. They also disconnect the dss device explicitly from their .remove() handler if it is still connected. Those safety checks are not needed: - The .enable() handler is called from code paths that access the dss devices chain from the display device, which is set to NULL when the device isn't connected. - The .remove() handler can only be called when unloading the module as the driver has the suppress_bind_attrs attribute set, and a reference to the module is taken when constructing the dss devices chain, so the module can only be unloaded when the dss device is disconnected. Remove the safety checks. Signed-off-by: Laurent Pinchart Reviewed-by: Sebastian Reichel Tested-by: Sebastian Reichel --- .../gpu/drm/omapdrm/displays/encoder-opa362.c | 7 ------- .../gpu/drm/omapdrm/displays/encoder-tfp410.c | 7 ------- .../drm/omapdrm/displays/encoder-tpd12s015.c | 4 ---- drivers/gpu/drm/omapdrm/dss/base.c | 5 +++++ drivers/gpu/drm/omapdrm/dss/omapdss.h | 5 ----- drivers/gpu/drm/omapdrm/omap_encoder.c | 17 +++++------------ 6 files changed, 10 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c index 4fefd80f53bb..0b1032625e42 100644 --- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c +++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c @@ -49,9 +49,6 @@ static int opa362_enable(struct omap_dss_device *dssdev) dev_dbg(dssdev->dev, "enable\n"); - if (!omapdss_device_is_connected(dssdev)) - return -ENODEV; - if (omapdss_device_is_enabled(dssdev)) return 0; @@ -145,10 +142,6 @@ static int __exit opa362_remove(struct platform_device *pdev) if (omapdss_device_is_enabled(dssdev)) opa362_disable(dssdev); - WARN_ON(omapdss_device_is_connected(dssdev)); - if (omapdss_device_is_connected(dssdev)) - omapdss_device_disconnect(NULL, dssdev); - return 0; } diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c index f1a748353279..fcc2dc5188a2 100644 --- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c @@ -42,9 +42,6 @@ static int tfp410_enable(struct omap_dss_device *dssdev) struct omap_dss_device *src = dssdev->src; int r; - if (!omapdss_device_is_connected(dssdev)) - return -ENODEV; - if (omapdss_device_is_enabled(dssdev)) return 0; @@ -139,10 +136,6 @@ static int __exit tfp410_remove(struct platform_device *pdev) if (omapdss_device_is_enabled(dssdev)) tfp410_disable(dssdev); - WARN_ON(omapdss_device_is_connected(dssdev)); - if (omapdss_device_is_connected(dssdev)) - omapdss_device_disconnect(NULL, dssdev); - return 0; } diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c index 94de55fd8884..1a2bc59bf104 100644 --- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c @@ -229,10 +229,6 @@ static int __exit tpd_remove(struct platform_device *pdev) if (omapdss_device_is_enabled(dssdev)) tpd_disable(dssdev); - WARN_ON(omapdss_device_is_connected(dssdev)); - if (omapdss_device_is_connected(dssdev)) - omapdss_device_disconnect(NULL, dssdev); - return 0; } diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c index 472f56e3de70..787157b00694 100644 --- a/drivers/gpu/drm/omapdrm/dss/base.c +++ b/drivers/gpu/drm/omapdrm/dss/base.c @@ -185,6 +185,11 @@ struct omap_dss_device *omapdss_device_get_next(struct omap_dss_device *from, } EXPORT_SYMBOL(omapdss_device_get_next); +static bool omapdss_device_is_connected(struct omap_dss_device *dssdev) +{ + return dssdev->src; +} + int omapdss_device_connect(struct dss_device *dss, struct omap_dss_device *src, struct omap_dss_device *dst) diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index de0520a8eb4e..698155dd7941 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -505,11 +505,6 @@ int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask); int omapdss_compat_init(void); void omapdss_compat_uninit(void); -static inline bool omapdss_device_is_connected(struct omap_dss_device *dssdev) -{ - return dssdev->src; -} - static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev) { return dssdev->state == OMAP_DSS_DISPLAY_ACTIVE; diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c index 5427c0b3ff9e..3c3d88e1df38 100644 --- a/drivers/gpu/drm/omapdrm/omap_encoder.c +++ b/drivers/gpu/drm/omapdrm/omap_encoder.c @@ -168,24 +168,17 @@ static void omap_encoder_enable(struct drm_encoder *encoder) dev_dbg(dev->dev, "enable(%s)\n", dssdev->name); - if (!omapdss_device_is_connected(dssdev)) { - r = -ENODEV; - goto error; - } - if (omapdss_device_is_enabled(dssdev)) return; r = dssdev->ops->enable(dssdev); - if (r) - goto error; + if (r) { + dev_err(dev->dev, "Failed to enable display '%s': %d\n", + dssdev->name, r); + return; + } dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; - return; - -error: - dev_err(dev->dev, "Failed to enable display '%s': %d\n", - dssdev->name, r); } static int omap_encoder_atomic_check(struct drm_encoder *encoder,