Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2129982pxb; Mon, 12 Apr 2021 15:27:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWvbAY+NJt6RCkW7qcDjzU3OwihRc2MRBuyDprohH2yY8FPlCIF8B6xpoaqE25hi9g61et X-Received: by 2002:a17:90a:db4b:: with SMTP id u11mr1446734pjx.154.1618266450990; Mon, 12 Apr 2021 15:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618266450; cv=none; d=google.com; s=arc-20160816; b=iq+jTkT5ZNe5FZrhk8qFLXvEGnFsJzBdJF8A/XLjvOeZmfs7jfAb244ajGwlJMjX+e NaZ8SYobY9zMpqlDDAdwLFBLUOJnImMw8UbgLtZZLaRrm5h4u9XTK9WAxBPP1p6wrxP2 HwnQwm7hXFtjRjXzErteMSJ5IEfjlmao7LVxgAST5AIbECW5EQ4mArzX2DmBUL/uFwL7 I6Zt/3WqIQtuuVG4CRtZbX2cLd4HrMbLNi21w1ubSfsC4KIo1oMpXRg/8FBzbXE28c5N hqX5GlUupX7221RWt5WiigZjl4Vv07HgNGdg6zexnyBya6x+OZy4bFCfR06MQAhlt2ub 0wdg== 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=MRVTSH1qpSz6H4j2xsvfUZv/KDmGAPaP6Cs6uMD6AJc=; b=y1d+SqSCtwnjvGE01OsqS4gtGZefkVl3ZA/liTeBV6pjN77G9JmV0L2dKMoavGXBuS KD0lgqb/XRa8FVghmaWrdBPpRdi+Vg1/oF/HpS0WhvglEVSxcuA+W30WWTrLvxiauVAH XnFB5xLdbrGvi2NjrCtOX3gqg/M1DB0l9VGjQp1J885teSIoDMcoeZBWDFUP4hRfZWDt 46BiL9QImFJljhq1xlS3/QidhnnqySmkHilwvEhfSk4B7za6SKNfAJIP2nRs/kgojKOY BKaRFGvZOQLAvnoaToFoLVbVPmQW5VORNGm5jTs7JPj+tLjeXL+/TISXzSdjtv96Z5np TSSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=11LhxH+n; 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 y62si14833417pgb.15.2021.04.12.15.27.18; Mon, 12 Apr 2021 15:27:30 -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=11LhxH+n; 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 S239551AbhDLJaP (ORCPT + 99 others); Mon, 12 Apr 2021 05:30:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:56774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238994AbhDLJG0 (ORCPT ); Mon, 12 Apr 2021 05:06:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D366461384; Mon, 12 Apr 2021 09:03:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618218199; bh=a2/KlIOhfZVE0ULLCyfKNEC2aC9EBC7sBfGewH1J7wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=11LhxH+npyJmkEcR2my81iuMd2mHniddKivm8YBxBBm70qXK7uz5lptSt6FG9laul 4R84NiqR6CEDbrS8r6DJt+bUqmFR2w5zWIlFbmTEEbwer9kWkzAWDGWE3Uz7D2Uxhf tryJIIBp4Y9n0QBg1XW88IgRVYN9dXwE/F3MiVBk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Carlos Leija , Praneeth Bajjuri , Bryan Buckley , Tero Kristo , Carl Philipp Klemm , Merlijn Wajer , Ivan Jelincic , Pavel Machek , Sebastian Reichel , Tero Kristo , Tony Lindgren , Sasha Levin Subject: [PATCH 5.11 108/210] ARM: OMAP4: PM: update ROM return address for OSWR and OFF Date: Mon, 12 Apr 2021 10:40:13 +0200 Message-Id: <20210412084019.611258776@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084016.009884719@linuxfoundation.org> References: <20210412084016.009884719@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: Carlos Leija [ Upstream commit b3d09a06d89f474cb52664e016849315a97e09d9 ] We need to add a dummy smc call to the cpuidle wakeup path to force the ROM code to save the return address after MMU is enabled again. This is needed to prevent random hangs on secure devices like droid4. Otherwise the system will eventually hang when entering deeper SoC idle states with the core and mpu domains in open-switch retention (OSWR). The hang happens as the ROM code tries to use the earlier physical return address set by omap-headsmp.S with MMU off while waking up CPU1 again. The hangs started happening in theory already with commit caf8c87d7ff2 ("ARM: OMAP2+: Allow core oswr for omap4"), but in practise the issue went unnoticed as various drivers were often blocking any deeper idle states with hardware autoidle features. This patch is based on an earlier TI Linux kernel tree commit 92f0b3028d9e ("OMAP4: PM: update ROM return address for OSWR and OFF") written by Carlos Leija , Praneeth Bajjuri , and Bryan Buckley . A later version of the patch was updated to use CPU_PM notifiers by Tero Kristo . Signed-off-by: Carlos Leija Signed-off-by: Praneeth Bajjuri Signed-off-by: Bryan Buckley Signed-off-by: Tero Kristo Fixes: caf8c87d7ff2 ("ARM: OMAP2+: Allow core oswr for omap4") Reported-by: Carl Philipp Klemm Reported-by: Merlijn Wajer Cc: Ivan Jelincic Cc: Pavel Machek Cc: Sebastian Reichel Cc: Tero Kristo [tony@atomide.com: updated to apply, updated description] Signed-off-by: Tony Lindgren Signed-off-by: Sasha Levin --- arch/arm/mach-omap2/omap-secure.c | 39 +++++++++++++++++++++++++++++++ arch/arm/mach-omap2/omap-secure.h | 1 + 2 files changed, 40 insertions(+) diff --git a/arch/arm/mach-omap2/omap-secure.c b/arch/arm/mach-omap2/omap-secure.c index f70d561f37f7..0659ab4cb0af 100644 --- a/arch/arm/mach-omap2/omap-secure.c +++ b/arch/arm/mach-omap2/omap-secure.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -20,6 +21,7 @@ #include "common.h" #include "omap-secure.h" +#include "soc.h" static phys_addr_t omap_secure_memblock_base; @@ -213,3 +215,40 @@ void __init omap_secure_init(void) { omap_optee_init_check(); } + +/* + * Dummy dispatcher call after core OSWR and MPU off. Updates the ROM return + * address after MMU has been re-enabled after CPU1 has been woken up again. + * Otherwise the ROM code will attempt to use the earlier physical return + * address that got set with MMU off when waking up CPU1. Only used on secure + * devices. + */ +static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v) +{ + switch (cmd) { + case CPU_CLUSTER_PM_EXIT: + omap_secure_dispatcher(OMAP4_PPA_SERVICE_0, + FLAG_START_CRITICAL, + 0, 0, 0, 0, 0); + break; + default: + break; + } + + return NOTIFY_OK; +} + +static struct notifier_block secure_notifier_block = { + .notifier_call = cpu_notifier, +}; + +static int __init secure_pm_init(void) +{ + if (omap_type() == OMAP2_DEVICE_TYPE_GP || !soc_is_omap44xx()) + return 0; + + cpu_pm_register_notifier(&secure_notifier_block); + + return 0; +} +omap_arch_initcall(secure_pm_init); diff --git a/arch/arm/mach-omap2/omap-secure.h b/arch/arm/mach-omap2/omap-secure.h index 4aaa95706d39..172069f31616 100644 --- a/arch/arm/mach-omap2/omap-secure.h +++ b/arch/arm/mach-omap2/omap-secure.h @@ -50,6 +50,7 @@ #define OMAP5_DRA7_MON_SET_ACR_INDEX 0x107 /* Secure PPA(Primary Protected Application) APIs */ +#define OMAP4_PPA_SERVICE_0 0x21 #define OMAP4_PPA_L2_POR_INDEX 0x23 #define OMAP4_PPA_CPU_ACTRL_SMP_INDEX 0x25 -- 2.30.2