From patchwork Thu Sep 21 17:06:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9964389 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 13BE46020C for ; Thu, 21 Sep 2017 17:06:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F283828D37 for ; Thu, 21 Sep 2017 17:06:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5B57295FF; Thu, 21 Sep 2017 17:06:54 +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 72AA928D37 for ; Thu, 21 Sep 2017 17:06:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 995FC6E8A3; Thu, 21 Sep 2017 17:06:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-x22c.google.com (mail-pg0-x22c.google.com [IPv6:2607:f8b0:400e:c05::22c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1CD736E8A3 for ; Thu, 21 Sep 2017 17:06:51 +0000 (UTC) Received: by mail-pg0-x22c.google.com with SMTP id i130so3849923pgc.3 for ; Thu, 21 Sep 2017 10:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ffmC3m+Glcdo8KNnxGMRDXe1FgdfV3vjPQigxqYIpwU=; b=WyeSC1WcyWvCZHXyDekOBi90qbHKXT/tkqIWOFFJ6+fSqwXcayZjJxY4Pk8LtXvVA9 6HDCRRPZ87EDgzGzW8bKmdrLE1NU497miUnqH5M6vPYv6YqYL55x4XVsONszYLzgWntG M2ny2KOzZeTEd+Vij4V9tAoeFUP853MGM4OKA= 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; bh=ffmC3m+Glcdo8KNnxGMRDXe1FgdfV3vjPQigxqYIpwU=; b=NerKVAMK/QyuGGAnqD7IjZ0+tS8exNI5ajAkPVoq3c5VFjs96zOajIlN8UMtJfYvxC D1VPv3njghvIqu1QKOT52skre8NAfUAIjpkzkhXdhKILfEKkU7MDu4p2pquQVsiFIxQS E70+xlWED06Rx+tXMqNMMOfpTj6zZs/SMwnhMDeOScmgcv2flVDVmLBLy0T8OxNzh84Q P6scxWEggjcTyfxAoqK5oZ4LBwIWyNLyTep53qNoQrMHh+wvC6zrg2YWQDJyMekRVjp3 rDA7jvc/YKAFxp58qmXO7W0+BfKvGc7GEihI2oWQNoSOTZUIoUtdCpMCF2pCIy7CKNS0 Rrkw== X-Gm-Message-State: AHPjjUh6Ax/d6GWpjTB0SmaljyPS3obI9+iAVPwj3eLTBSgcZDfHLhIw IxoqQDD99O67rD/PdC9+WslmlpOAB48= X-Google-Smtp-Source: AOwi7QCvp2nwCFlQE4NIgcIVpMGMWDqoMF37kGfX1G6F7DqM971mvU/ConZ0yf6jzs4heLGNSMb0Zw== X-Received: by 10.99.114.92 with SMTP id c28mr6185480pgn.378.1506013611360; Thu, 21 Sep 2017 10:06:51 -0700 (PDT) Received: from trickycodes.corp.google.com ([172.19.15.95]) by smtp.gmail.com with ESMTPSA id l86sm3317481pfg.155.2017.09.21.10.06.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Sep 2017 10:06:50 -0700 (PDT) From: Sean Paul To: dri-devel@lists.freedesktop.org Subject: [PATCH 01/10] drm/panel: Keep track of enabled/prepared Date: Thu, 21 Sep 2017 10:06:12 -0700 Message-Id: <20170921170638.27031-2-seanpaul@chromium.org> X-Mailer: git-send-email 2.14.1.821.g8fa685d3b7-goog In-Reply-To: <20170921170638.27031-1-seanpaul@chromium.org> References: <20170921170638.27031-1-seanpaul@chromium.org> Cc: Daniel Vetter , Thierry Reding X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds state tracking to the drm_panel functions which keep track of enabled and prepared. If the calls are unbalanced, a WARNING is issued. The motivation for this change is that a number of panel drivers (including panel-simple) all do this to protect their regulator refcounts. The atomic framework ensures the calls are balanced, and there aren't any panel drivers being used by legacy drivers. As such, these checks are useless, but let's add a WARNING just in case something crazy happens (like a legacy driver using a panel). Less code == better. Signed-off-by: Sean Paul --- drivers/gpu/drm/drm_panel.c | 2 ++ include/drm/drm_panel.h | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index 308d442a531b..9515219d3d2c 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -48,6 +48,8 @@ static LIST_HEAD(panel_list); void drm_panel_init(struct drm_panel *panel) { INIT_LIST_HEAD(&panel->list); + panel->enabled = false; + panel->prepared = false; } EXPORT_SYMBOL(drm_panel_init); diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 14ac240a1f64..b9a86a4cf29c 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -24,6 +24,7 @@ #ifndef __DRM_PANEL_H__ #define __DRM_PANEL_H__ +#include #include #include @@ -84,6 +85,8 @@ struct drm_panel_funcs { * @dev: parent device of the panel * @funcs: operations that can be performed on the panel * @list: panel entry in registry + * @enabled: keeps track of the panel enabled status + * @prepared: keeps track of the panel prepared status */ struct drm_panel { struct drm_device *drm; @@ -93,6 +96,9 @@ struct drm_panel { const struct drm_panel_funcs *funcs; struct list_head list; + + bool enabled; + bool prepared; }; /** @@ -104,12 +110,18 @@ struct drm_panel { * is usually no longer possible to communicate with the panel until another * call to drm_panel_prepare(). * + * Atomic framework should ensure that prepare/unprepare are properly balanced. + * If this is not the case, a WARNING will be issued. + * * Return: 0 on success or a negative error code on failure. */ static inline int drm_panel_unprepare(struct drm_panel *panel) { - if (panel && panel->funcs && panel->funcs->unprepare) + if (panel && panel->funcs && panel->funcs->unprepare) { + WARN_ON(!panel->prepared); + panel->prepared = false; return panel->funcs->unprepare(panel); + } return panel ? -ENOSYS : -EINVAL; } @@ -122,12 +134,18 @@ static inline int drm_panel_unprepare(struct drm_panel *panel) * drivers. For smart panels it should still be possible to communicate with * the integrated circuitry via any command bus after this call. * + * Atomic framework should ensure that enable/disable are properly balanced. + * If this is not the case, a WARNING will be issued. + * * Return: 0 on success or a negative error code on failure. */ static inline int drm_panel_disable(struct drm_panel *panel) { - if (panel && panel->funcs && panel->funcs->disable) + if (panel && panel->funcs && panel->funcs->disable) { + WARN_ON(!panel->enabled); + panel->enabled = false; return panel->funcs->disable(panel); + } return panel ? -ENOSYS : -EINVAL; } @@ -140,12 +158,18 @@ static inline int drm_panel_disable(struct drm_panel *panel) * the panel. After this has completed it is possible to communicate with any * integrated circuitry via a command bus. * + * Atomic framework should ensure that prepare/unprepare are properly balanced. + * If this is not the case, a WARNING will be issued. + * * Return: 0 on success or a negative error code on failure. */ static inline int drm_panel_prepare(struct drm_panel *panel) { - if (panel && panel->funcs && panel->funcs->prepare) + if (panel && panel->funcs && panel->funcs->prepare) { + WARN_ON(panel->prepared); + panel->prepared = true; return panel->funcs->prepare(panel); + } return panel ? -ENOSYS : -EINVAL; } @@ -158,12 +182,18 @@ static inline int drm_panel_prepare(struct drm_panel *panel) * and the backlight to be enabled. Content will be visible on screen after * this call completes. * + * Atomic framework should ensure that enable/disable are properly balanced. + * If this is not the case, a WARNING will be issued. + * * Return: 0 on success or a negative error code on failure. */ static inline int drm_panel_enable(struct drm_panel *panel) { - if (panel && panel->funcs && panel->funcs->enable) + if (panel && panel->funcs && panel->funcs->enable) { + WARN_ON(panel->enabled); + panel->enabled = true; return panel->funcs->enable(panel); + } return panel ? -ENOSYS : -EINVAL; }