From patchwork Mon Nov 5 15:10:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 10668423 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 138C113A4 for ; Mon, 5 Nov 2018 15:10:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 033E4299E1 for ; Mon, 5 Nov 2018 15:10:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB62829A10; Mon, 5 Nov 2018 15:10:44 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02E21299B3 for ; Mon, 5 Nov 2018 15:10:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729770AbeKFAal (ORCPT ); Mon, 5 Nov 2018 19:30:41 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:60914 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729588AbeKFAal (ORCPT ); Mon, 5 Nov 2018 19:30:41 -0500 Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 23EE3567; Mon, 5 Nov 2018 16:10:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1541430628; bh=U/XRzv7xF5CNr73osncIDCWlzh8zTIcgw1V1D3UqFPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UBEtZL8NEc0I6CzCzHvha19YJzY+lohn5jdgqlTKZcEj3LiDs0ocgHVm2vP+SFwxw 4mxnLV+Yv1geV+MVfDAf8pYGiGkyDgM4b0r0poInB+N5kBEM0FJTfvN9GUDCAaGvhZ ZesMBbh7FY1si4tmdvVhghrJm8pvgm6oPadfpDQg= From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Cc: linux-omap@vger.kernel.org, Tomi Valkeinen , Tony Lindgren Subject: [PATCH v2 4/4] drm/omap: Work around missing DISPC in runtime PM handlers Date: Mon, 5 Nov 2018 17:10:28 +0200 Message-Id: <20181105151028.4091-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181105151028.4091-1-laurent.pinchart@ideasonboard.com> References: <20181105151028.4091-1-laurent.pinchart@ideasonboard.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The runtime suspend and resume callbacks for the DSI, HDMI4, HDMI5 and VENC try to manage the runtime PM state of the DISPC, which can be unavailable at probe time (due to the DSS probe being deferred for instance) and remove time (due to the DISPC being removed already). The proper fix is to move DISPC runtime PM handling out of the encoders runtime PM handlers, but that will require more development and testing that would be reasonable for an -rc bug fix. Fixes: edb715dffdee ("drm/omap: dss: dsi: Move initialization code from bind to probe") Signed-off-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/dss/dsi.c | 22 ++++++++++++++++++---- drivers/gpu/drm/omapdrm/dss/hdmi4.c | 19 +++++++++++++++---- drivers/gpu/drm/omapdrm/dss/hdmi5.c | 19 +++++++++++++++---- drivers/gpu/drm/omapdrm/dss/venc.c | 19 +++++++++++++++---- 4 files changed, 63 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index b9d5ad7e67d8..a1b9e6659b1e 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -5473,7 +5473,12 @@ static int dsi_runtime_suspend(struct device *dev) /* wait for current handler to finish before turning the DSI off */ synchronize_irq(dsi->irq); - dispc_runtime_put(dsi->dss->dispc); + /* + * FIXME: DISPC runtime PM handling should be controlled from omapdrm, + * see dsi_runtime_resume(). + */ + if (dsi->dss && dsi->dss->dispc) + dispc_runtime_put(dsi->dss->dispc); return 0; } @@ -5483,9 +5488,18 @@ static int dsi_runtime_resume(struct device *dev) struct dsi_data *dsi = dev_get_drvdata(dev); int r; - r = dispc_runtime_get(dsi->dss->dispc); - if (r) - return r; + /* + * FIXME: The device is resumed from the probe function before the dss + * is available, in order to read a hardware configuration register. + * This doesn't require resuming the DISPC, so make it conditional. The + * DISPC runtime PM handling should instead be controlled from omapdrm, + * which is already partly the case, but needs additional testing. + */ + if (dsi->dss && dsi->dss->dispc) { + r = dispc_runtime_get(dsi->dss->dispc); + if (r) + return r; + } dsi->is_enabled = true; /* ensure the irq handler sees the is_enabled value */ diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c index 36be9a36d664..21d1147c0827 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c @@ -845,7 +845,12 @@ static int hdmi_runtime_suspend(struct device *dev) { struct omap_hdmi *hdmi = dev_get_drvdata(dev); - dispc_runtime_put(hdmi->dss->dispc); + /* + * FIXME: DISPC runtime PM handling should be controlled from omapdrm, + * see dsi_runtime_resume(). + */ + if (hdmi->dss && hdmi->dss->dispc) + dispc_runtime_put(hdmi->dss->dispc); return 0; } @@ -855,9 +860,15 @@ static int hdmi_runtime_resume(struct device *dev) struct omap_hdmi *hdmi = dev_get_drvdata(dev); int r; - r = dispc_runtime_get(hdmi->dss->dispc); - if (r < 0) - return r; + /* + * FIXME: DISPC runtime PM handling should be controlled from omapdrm, + * see dsi_runtime_resume(). + */ + if (hdmi->dss && hdmi->dss->dispc) { + r = dispc_runtime_get(hdmi->dss->dispc); + if (r < 0) + return r; + } return 0; } diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c index b0e4a7463f8c..75e2cb74a66c 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c @@ -829,7 +829,12 @@ static int hdmi_runtime_suspend(struct device *dev) { struct omap_hdmi *hdmi = dev_get_drvdata(dev); - dispc_runtime_put(hdmi->dss->dispc); + /* + * FIXME: DISPC runtime PM handling should be controlled from omapdrm, + * see dsi_runtime_resume(). + */ + if (hdmi->dss && hdmi->dss->dispc) + dispc_runtime_put(hdmi->dss->dispc); return 0; } @@ -839,9 +844,15 @@ static int hdmi_runtime_resume(struct device *dev) struct omap_hdmi *hdmi = dev_get_drvdata(dev); int r; - r = dispc_runtime_get(hdmi->dss->dispc); - if (r < 0) - return r; + /* + * FIXME: DISPC runtime PM handling should be controlled from omapdrm, + * see dsi_runtime_resume(). + */ + if (hdmi->dss && hdmi->dss->dispc) { + r = dispc_runtime_get(hdmi->dss->dispc); + if (r < 0) + return r; + } return 0; } diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c index ff0b18c8e4ac..c39ad81fbc54 100644 --- a/drivers/gpu/drm/omapdrm/dss/venc.c +++ b/drivers/gpu/drm/omapdrm/dss/venc.c @@ -946,7 +946,12 @@ static int venc_runtime_suspend(struct device *dev) if (venc->tv_dac_clk) clk_disable_unprepare(venc->tv_dac_clk); - dispc_runtime_put(venc->dss->dispc); + /* + * FIXME: DISPC runtime PM handling should be controlled from omapdrm, + * see dsi_runtime_resume(). + */ + if (venc->dss && venc->dss->dispc) + dispc_runtime_put(venc->dss->dispc); return 0; } @@ -956,9 +961,15 @@ static int venc_runtime_resume(struct device *dev) struct venc_device *venc = dev_get_drvdata(dev); int r; - r = dispc_runtime_get(venc->dss->dispc); - if (r < 0) - return r; + /* + * FIXME: DISPC runtime PM handling should be controlled from omapdrm, + * see dsi_runtime_resume(). + */ + if (venc->dss && venc->dss->dispc) { + r = dispc_runtime_get(venc->dss->dispc); + if (r < 0) + return r; + } if (venc->tv_dac_clk) clk_prepare_enable(venc->tv_dac_clk);