Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3425705pxf; Mon, 29 Mar 2021 01:44:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzamDJ0VEVQP9P9jxIGRKjGID5M42DwYqyN6G2rgo6+NklJFAtah9kaSJiuOp/srtOlLWKo X-Received: by 2002:a17:907:d8b:: with SMTP id go11mr15682054ejc.167.1617007443751; Mon, 29 Mar 2021 01:44:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007443; cv=none; d=google.com; s=arc-20160816; b=AAjFRF9N3Y+BK8R4d72UfIdR9DY79m8GZ3LWqhBWp0hAZE6VyNJKfJ1AxBRB27N8Yb yEszs2TBymVCjO1lQxb/H9caI/lypXzihXcdSet+GglX/jG7DtWOO1C3VUmcox/QkQZx uoh3rwMJqKPcFz/xclig/rVpWa8leEfzAPmJ+QoJ1NU7+V6owA0nwvt529FgxUC+Uu+/ tV3YFQLo6WRcU2CxiWRX/nPCMaHaK/wtagO7A87CCzYSwuRsNG6bW5UxGNDWgf23CR4F nQB25bSKmhgAXZqpn4/kMCUXDJ6xqubqA8+Wgpk/7I6OsDREeonXr+vYEJweKxvH+rr/ cwcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6se8YPWh4oWBaugw2oWZMzkBFmlI7KvqeQOo0etpkLQ=; b=xaYjrJ+5VSeNg87M5sDYSMmW3BM4q01F/7QyyM3NE+8yCi6l9Tp3KVRa4qYl8RFonl Jt+osLjiood1PoAQI4wH2sbUzFJvM5xfqqNN28SAkLG4Esj/dPSRQU12cw9wZRhaA7Da h5HZqpG7gRMcAJd/ieO6bJMmsSjlADy5Nm7+fJ/hU549LwU+YI5Fum3GjcjOSIZTSh/A M/UlSbtsfdFibeNK1KdZ80EpL+8kYfvOA7M+7MYGZ3cA5Oh3+lMcizWW4kyKJSKHi9Ad +qzkIQkPEBReEvwHmigm9aZaDIvy9qPeB/WEhkBOW0/ADX1MccM/uPUz2GXyJGNojzQW rU8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SqfZYiZH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de6si12266371ejc.467.2021.03.29.01.43.41; Mon, 29 Mar 2021 01:44:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SqfZYiZH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235084AbhC2ImP (ORCPT + 99 others); Mon, 29 Mar 2021 04:42:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:41658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234204AbhC2IX4 (ORCPT ); Mon, 29 Mar 2021 04:23:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 483D0619C4; Mon, 29 Mar 2021 08:23:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006235; bh=Hw9A6Psap29M1k2WTByEluXpzjwHWq9t16vzcJNwzyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SqfZYiZH4OyfUM9GuEDVqJNHIK6xWB0TsKPn+X+kbEIaO0pSpBipHTixRC6RYHwBa AReOpl7hCW1GxV6hfe1JrHieGpL23vvO6fCXJOQIlX25AlyYOgIlPOz2LUA/Xhfj7K 4r/oGJwyF42L+nnPSd9rWArF+Kelq/GvVQ9mQ818= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabio Estevam , Rob Clark , Sasha Levin Subject: [PATCH 5.10 167/221] drm/msm: Fix suspend/resume on i.MX5 Date: Mon, 29 Mar 2021 09:58:18 +0200 Message-Id: <20210329075634.718810265@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fabio Estevam [ Upstream commit a9748134ea4aad989e52a6a91479e0acfd306e5b ] When putting iMX5 into suspend, the following flow is observed: [ 70.023427] [] (msm_atomic_commit_tail) from [] (commit_tail+0x9c/0x18c) [ 70.031890] [] (commit_tail) from [] (drm_atomic_helper_commit+0x1a0/0x1d4) [ 70.040627] [] (drm_atomic_helper_commit) from [] (drm_atomic_helper_disable_all+0x1c4/0x1d4) [ 70.050913] [] (drm_atomic_helper_disable_all) from [] (drm_atomic_helper_suspend+0xb8/0x170) [ 70.061198] [] (drm_atomic_helper_suspend) from [] (drm_mode_config_helper_suspend+0x24/0x58) In the i.MX5 case, priv->kms is not populated (as i.MX5 does not use any of the Qualcomm display controllers), causing a NULL pointer dereference in msm_atomic_commit_tail(): [ 24.268964] 8<--- cut here --- [ 24.274602] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 24.283434] pgd = (ptrval) [ 24.286387] [00000000] *pgd=ca212831 [ 24.290788] Internal error: Oops: 17 [#1] SMP ARM [ 24.295609] Modules linked in: [ 24.298777] CPU: 0 PID: 197 Comm: init Not tainted 5.11.0-rc2-next-20210111 #333 [ 24.306276] Hardware name: Freescale i.MX53 (Device Tree Support) [ 24.312442] PC is at msm_atomic_commit_tail+0x54/0xb9c [ 24.317743] LR is at commit_tail+0xa4/0x1b0 Fix the problem by calling drm_mode_config_helper_suspend/resume() only when priv->kms is available. Fixes: ca8199f13498 ("drm/msm/dpu: ensure device suspend happens during PM sleep") Signed-off-by: Fabio Estevam Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/msm_drv.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 45e325c982c2..b38ebccad42f 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -1079,6 +1079,10 @@ static int __maybe_unused msm_pm_resume(struct device *dev) static int __maybe_unused msm_pm_prepare(struct device *dev) { struct drm_device *ddev = dev_get_drvdata(dev); + struct msm_drm_private *priv = ddev ? ddev->dev_private : NULL; + + if (!priv || !priv->kms) + return 0; return drm_mode_config_helper_suspend(ddev); } @@ -1086,6 +1090,10 @@ static int __maybe_unused msm_pm_prepare(struct device *dev) static void __maybe_unused msm_pm_complete(struct device *dev) { struct drm_device *ddev = dev_get_drvdata(dev); + struct msm_drm_private *priv = ddev ? ddev->dev_private : NULL; + + if (!priv || !priv->kms) + return; drm_mode_config_helper_resume(ddev); } -- 2.30.1