From patchwork Wed Mar 21 10:08:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 10299999 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6CD82600F6 for ; Wed, 21 Mar 2018 18:14:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B89B28FB8 for ; Wed, 21 Mar 2018 18:14:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FA9C298C3; Wed, 21 Mar 2018 18:14:50 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 AC58F28FB8 for ; Wed, 21 Mar 2018 18:14:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 83EEA6E982; Wed, 21 Mar 2018 18:14:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5F8DE6E982 for ; Wed, 21 Mar 2018 18:14:46 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w2LA8VGa017291; Wed, 21 Mar 2018 05:08:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1521626911; bh=Qfkiru9cc6KIP0CXcSy8GgAea0e12GlYmtO4+8BKhhM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=IbIAYtQUtYpQoXxmtXPdaS1A9PJJBdyTAEh2VAlb7eitq0W9l0IS99foBYgEtNdoU KKXhGE16WnOKwYZUbzVu4sO+7hromHr3EQY+3faQR3E2OpuSsjxqdTuSCtb9y0aBlq 49ZCdhM6ih82AcpC+6Ty4MspA22RG1JM62HdxD2w= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w2LA8VwG010256; Wed, 21 Mar 2018 05:08:31 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Wed, 21 Mar 2018 05:08:30 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Wed, 21 Mar 2018 05:08:30 -0500 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w2LA8O1d013726; Wed, 21 Mar 2018 05:08:29 -0500 From: Peter Ujfalusi To: , Subject: [PATCH v2 2/6] drm/omap: Manage the usable omap_dss_device list within omap_drm_private Date: Wed, 21 Mar 2018 12:08:27 +0200 Message-ID: <20180321100831.12716-3-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180321100831.12716-1-peter.ujfalusi@ti.com> References: <20180321100831.12716-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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: airlied@linux.ie, jsarha@ti.com, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Instead of reaching back to DSS to iterate through the dss_devices every time, use an internal array where we store the available and usable dss_devices. At the same time remove the omapdss_device_is_connected() check from omap_modeset_init() as it became irrelevant: We are not adding dssdevs if their connect failed. Signed-off-by: Peter Ujfalusi --- drivers/gpu/drm/omapdrm/omap_drv.c | 95 +++++++++++++++++++++++--------------- drivers/gpu/drm/omapdrm/omap_drv.h | 3 ++ 2 files changed, 62 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index aeef9e8e6932..52cb8df04551 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -149,18 +149,27 @@ static int get_connector_type(struct omap_dss_device *dssdev) } } -static void omap_disconnect_dssdevs(void) +static void omap_disconnect_dssdevs(struct drm_device *ddev) { - struct omap_dss_device *dssdev = NULL; + struct omap_drm_private *priv = ddev->dev_private; + unsigned int i; + + for (i = 0; i < priv->num_dssdevs; i++) { + struct omap_dss_device *dssdev = priv->dssdevs[i]; - for_each_dss_dev(dssdev) dssdev->driver->disconnect(dssdev); + priv->dssdevs[i] = NULL; + omap_dss_put_device(dssdev); + } + + priv->num_dssdevs = 0; } -static int omap_connect_dssdevs(void) +static int omap_connect_dssdevs(struct drm_device *ddev) { - int r; + struct omap_drm_private *priv = ddev->dev_private; struct omap_dss_device *dssdev = NULL; + int r; if (!omapdss_stack_is_ready()) return -EPROBE_DEFER; @@ -173,6 +182,14 @@ static int omap_connect_dssdevs(void) } else if (r) { dev_warn(dssdev->dev, "could not connect display: %s\n", dssdev->name); + } else { + omap_dss_get_device(dssdev); + priv->dssdevs[priv->num_dssdevs++] = dssdev; + if (priv->num_dssdevs == ARRAY_SIZE(priv->dssdevs)) { + /* To balance the 'for_each_dss_dev' loop */ + omap_dss_put_device(dssdev); + break; + } } } @@ -183,7 +200,7 @@ static int omap_connect_dssdevs(void) * if we are deferring probe, we disconnect the devices we previously * connected */ - omap_disconnect_dssdevs(); + omap_disconnect_dssdevs(ddev); return r; } @@ -208,7 +225,7 @@ static int omap_modeset_init(struct drm_device *dev) int num_ovls = priv->dispc_ops->get_num_ovls(priv->dispc); int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc); int num_crtcs, crtc_idx, plane_idx; - int ret; + int ret, i; u32 plane_crtc_mask; drm_mode_config_init(dev); @@ -225,11 +242,7 @@ static int omap_modeset_init(struct drm_device *dev) * configuration does not match the expectations or exceeds * the available resources, the configuration is rejected. */ - num_crtcs = 0; - for_each_dss_dev(dssdev) - if (omapdss_device_is_connected(dssdev)) - num_crtcs++; - + num_crtcs = priv->num_dssdevs; if (num_crtcs > num_mgrs || num_crtcs > num_ovls || num_crtcs > ARRAY_SIZE(priv->crtcs) || num_crtcs > ARRAY_SIZE(priv->planes) || @@ -247,15 +260,13 @@ static int omap_modeset_init(struct drm_device *dev) crtc_idx = 0; plane_idx = 0; - for_each_dss_dev(dssdev) { + for (i = 0; i < priv->num_dssdevs; i++) { + struct omap_dss_device *dssdev = priv->dssdevs[i]; struct drm_connector *connector; struct drm_encoder *encoder; struct drm_plane *plane; struct drm_crtc *crtc; - if (!omapdss_device_is_connected(dssdev)) - continue; - encoder = omap_encoder_init(dev, dssdev); if (!encoder) return -ENOMEM; @@ -335,11 +346,14 @@ static int omap_modeset_init(struct drm_device *dev) /* * Enable the HPD in external components if supported */ -static void omap_modeset_enable_external_hpd(void) +static void omap_modeset_enable_external_hpd(struct drm_device *ddev) { - struct omap_dss_device *dssdev = NULL; + struct omap_drm_private *priv = ddev->dev_private; + int i; + + for (i = 0; i < priv->num_dssdevs; i++) { + struct omap_dss_device *dssdev = priv->dssdevs[i]; - for_each_dss_dev(dssdev) { if (dssdev->driver->enable_hpd) dssdev->driver->enable_hpd(dssdev); } @@ -348,11 +362,14 @@ static void omap_modeset_enable_external_hpd(void) /* * Disable the HPD in external components if supported */ -static void omap_modeset_disable_external_hpd(void) +static void omap_modeset_disable_external_hpd(struct drm_device *ddev) { - struct omap_dss_device *dssdev = NULL; + struct omap_drm_private *priv = ddev->dev_private; + int i; + + for (i = 0; i < priv->num_dssdevs; i++) { + struct omap_dss_device *dssdev = priv->dssdevs[i]; - for_each_dss_dev(dssdev) { if (dssdev->driver->disable_hpd) dssdev->driver->disable_hpd(dssdev); } @@ -540,7 +557,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev) omap_crtc_pre_init(priv); - ret = omap_connect_dssdevs(); + ret = omap_connect_dssdevs(ddev); if (ret) goto err_crtc_uninit; @@ -577,7 +594,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev) omap_fbdev_init(ddev); drm_kms_helper_poll_init(ddev); - omap_modeset_enable_external_hpd(); + omap_modeset_enable_external_hpd(ddev); /* * Register the DRM device with the core and the connectors with @@ -590,7 +607,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev) return 0; err_cleanup_helpers: - omap_modeset_disable_external_hpd(); + omap_modeset_disable_external_hpd(ddev); drm_kms_helper_poll_fini(ddev); omap_fbdev_fini(ddev); @@ -600,7 +617,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev) err_gem_deinit: omap_gem_deinit(ddev); destroy_workqueue(priv->wq); - omap_disconnect_dssdevs(); + omap_disconnect_dssdevs(ddev); err_crtc_uninit: omap_crtc_pre_uninit(); drm_dev_unref(ddev); @@ -615,7 +632,7 @@ static void omapdrm_cleanup(struct omap_drm_private *priv) drm_dev_unregister(ddev); - omap_modeset_disable_external_hpd(); + omap_modeset_disable_external_hpd(ddev); drm_kms_helper_poll_fini(ddev); omap_fbdev_fini(ddev); @@ -629,7 +646,7 @@ static void omapdrm_cleanup(struct omap_drm_private *priv) destroy_workqueue(priv->wq); - omap_disconnect_dssdevs(); + omap_disconnect_dssdevs(ddev); omap_crtc_pre_uninit(); drm_dev_unref(ddev); @@ -674,11 +691,14 @@ static int pdev_remove(struct platform_device *pdev) } #ifdef CONFIG_PM_SLEEP -static int omap_drm_suspend_all_displays(void) +static int omap_drm_suspend_all_displays(struct drm_device *ddev) { - struct omap_dss_device *dssdev = NULL; + struct omap_drm_private *priv = ddev->dev_private; + int i; + + for (i = 0; i < priv->num_dssdevs; i++) { + struct omap_dss_device *dssdev = priv->dssdevs[i]; - for_each_dss_dev(dssdev) { if (!dssdev->driver) continue; @@ -693,11 +713,14 @@ static int omap_drm_suspend_all_displays(void) return 0; } -static int omap_drm_resume_all_displays(void) +static int omap_drm_resume_all_displays(struct drm_device *ddev) { - struct omap_dss_device *dssdev = NULL; + struct omap_drm_private *priv = ddev->dev_private; + int i; + + for (i = 0; i < priv->num_dssdevs; i++) { + struct omap_dss_device *dssdev = priv->dssdevs[i]; - for_each_dss_dev(dssdev) { if (!dssdev->driver) continue; @@ -718,7 +741,7 @@ static int omap_drm_suspend(struct device *dev) drm_kms_helper_poll_disable(drm_dev); drm_modeset_lock_all(drm_dev); - omap_drm_suspend_all_displays(); + omap_drm_suspend_all_displays(drm_dev); drm_modeset_unlock_all(drm_dev); return 0; @@ -730,7 +753,7 @@ static int omap_drm_resume(struct device *dev) struct drm_device *drm_dev = priv->ddev; drm_modeset_lock_all(drm_dev); - omap_drm_resume_all_displays(); + omap_drm_resume_all_displays(drm_dev); drm_modeset_unlock_all(drm_dev); drm_kms_helper_poll_enable(drm_dev); diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index 6eaee4df4559..69d261f8e56b 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -54,6 +54,9 @@ struct omap_drm_private { struct dispc_device *dispc; const struct dispc_ops *dispc_ops; + unsigned int num_dssdevs; + struct omap_dss_device *dssdevs[8]; + unsigned int num_crtcs; struct drm_crtc *crtcs[8];