From patchwork Thu May 18 13:59:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 95912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp525331vqo; Thu, 18 May 2023 07:13:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7LXd9SzJipWUhANcydrKGFWzru0ls/boxaNhFKSb+nuYZtTlOlGakxTMLl9x894XxdQiSm X-Received: by 2002:a17:903:234c:b0:1aa:ffa9:9260 with SMTP id c12-20020a170903234c00b001aaffa99260mr3016663plh.7.1684419236687; Thu, 18 May 2023 07:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684419236; cv=none; d=google.com; s=arc-20160816; b=eoLoMVP6FyKPafwNNrXDzPESwV3ZrL7MuFULv+4aCmBUArM+Hw917lLbZSWI8zzfix PW6YNWvk8iRJfdDhPfxUFt+Wxru1sIzb/BgMx8sWoVxo/mb/NDgq5/S/gi/RsevObMds C4s8zyPLTJcHn5j7BI3cQmjPykudKU9mK0YD1s9wbVeYP9w9vy7YRcRqR03GyzZVqYhO oNtnkNd4fgGsC6D80/7BeLQq/xBkp+3JTwbUWbQgTrRaykuX7qmNnhUCjSlnC+l3hPRG gIzBjBZWYSTZUjJM1Vy9kKtPHIKfnUw8wiikYW4JDa99+pf50PIeesb4awtj45bL2l+g pwaQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=MOCIa/CAbEbWwY2wcBgLkKevxCcqHsPJBCWi4Dwjoy8=; b=wYO/Yg3XawqMvcTbQvVGF7sRmAAkz7hHN5gY9mM8y2QwdbmeDd7qMVYiPXagruPlmv n2fqLSJcGTtd+inrknclkHz/+osHrd2e1QyaprtpnnAje9HnbreWVGZYxizcF2DOSEWd pE0zfCtA/+G+SQuMu4xXEydDKFZ+jyMoTkR8t+I4+/SLhixABT9UHUpbL2GqdMuSKvG8 IfxOgdGZBREbOP5iHzfuHNcWlJDcDYKcL1Gt61Y9W1jFTILPGzHPf/2oiHByQcP9hLpl RmNuhQFP03YCWd9wXlkf6pNr/xUhLxaGf/aG5un31j9Y3wdQV9OY59AjRtkfG5Tc+mxQ BC9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=MYElUonJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p2-20020a170902eac200b001aafb6fcf51si1384205pld.253.2023.05.18.07.13.41; Thu, 18 May 2023 07:13:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=MYElUonJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231444AbjERN74 (ORCPT + 99 others); Thu, 18 May 2023 09:59:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbjERN7y (ORCPT ); Thu, 18 May 2023 09:59:54 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7AF910DA; Thu, 18 May 2023 06:59:51 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-510dabb39aeso2286704a12.2; Thu, 18 May 2023 06:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684418390; x=1687010390; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MOCIa/CAbEbWwY2wcBgLkKevxCcqHsPJBCWi4Dwjoy8=; b=MYElUonJ2j2KjZKx7Twde5yHiRkQvW/PdI3AGMfGxdtGnfN8dXzGvaimrUD8FcBHJe PW54Pz8LSWQBma9IT0kE53k8gko9rFIW2YurwaQuJxnFYTKMl5d8gF8V9/FjpFJZfKra MtoJ4mo7QjDTy6dxI47j70KtPuKqnrFrHqmzq9tPTt26NFJV3fshXz1NujNyfwXsayKM uxoMGUHgvudN7OEJ7UWVa/U7NMPGrCrGNrK2Bw+raikLhdQZWdbBjWSyiuoDVlDYomcQ cZukX+z5eDJPjtvS9iwxXOki9iYqcHStNTO6C79TkxzgX9ewtkz2Vet5L8QblPa3dk1K SqOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684418390; x=1687010390; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MOCIa/CAbEbWwY2wcBgLkKevxCcqHsPJBCWi4Dwjoy8=; b=LTfCPL09JFwoSowWLr3BkFvMj67CGwRL6xMdWQvsKWMNUjWMf4wU4z1CbZQ88ZKgUc UE7dhlNEgLyvyU4D5VTZ1m/bVg0Qw01oCc/kXd83+USFpYVBxMa3RFVYQf6FUnter2Gr sA/OXr85ka+lw7ftmEGQeJ+UW/ZFRtyW/9Ue9H0bOnwX32DBu+QykX/6VVo+2fzrnmNA yg/cCI9CCLMK03mSydZ4VB6ryVfDhtlwlUVmc8FXw6YigmyqJwFiDYlmCKnSEOo90fcR hqHGZxiwGIu0g5bBIy4p122h8fDQQ7AH32y+B8MQL55O12f5R6LVYL3fXYdjCjAxCrIC /0GA== X-Gm-Message-State: AC+VfDyqOunkKLtl3D/xkjFspJDKvzvv2Tti1drtFrHz8wGtuJ0PTW4r c62nqzO6P9AT9HzwgtrurSg= X-Received: by 2002:aa7:dd51:0:b0:50c:52d:7197 with SMTP id o17-20020aa7dd51000000b0050c052d7197mr4459858edw.2.1684418390174; Thu, 18 May 2023 06:59:50 -0700 (PDT) Received: from fedora.. (cpezg-94-253-130-143-cbl.xnet.hr. [94.253.130.143]) by smtp.googlemail.com with ESMTPSA id t28-20020a50d71c000000b0050d89daaa70sm669003edi.2.2023.05.18.06.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 06:59:49 -0700 (PDT) From: Robert Marko To: agross@kernel.org, andersson@kernel.orgm, konrad.dybcio@linaro.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_srichara@quicinc.com Cc: Robert Marko Subject: [PATCH 1/2] firmware: qcom: scm: Add SDI disable support Date: Thu, 18 May 2023 15:59:44 +0200 Message-Id: <20230518135945.2248451-1-robimarko@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SORTED_RECIPS,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766241585651663633?= X-GMAIL-MSGID: =?utf-8?q?1766241585651663633?= Some SoC-s like IPQ5018 require SDI(Secure Debug Image) to be disabled before trying to reboot, otherwise board will just hang after reboot has been issued via PSCI. So, provide a call to SCM that allows disabling it. Signed-off-by: Robert Marko --- drivers/firmware/qcom_scm.c | 23 +++++++++++++++++++++++ drivers/firmware/qcom_scm.h | 1 + 2 files changed, 24 insertions(+) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index fde33acd46b7..bdc9324d4e62 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -407,6 +407,29 @@ int qcom_scm_set_remote_state(u32 state, u32 id) } EXPORT_SYMBOL(qcom_scm_set_remote_state); +static int qcom_scm_disable_sdi(void) +{ + int ret; + struct qcom_scm_desc desc = { + .svc = QCOM_SCM_SVC_BOOT, + .cmd = QCOM_SCM_BOOT_SDI_CONFIG, + .args[0] = 1, /* Disable watchdog debug */ + .args[1] = 0, /* Disable SDI */ + .arginfo = QCOM_SCM_ARGS(2), + .owner = ARM_SMCCC_OWNER_SIP, + }; + struct qcom_scm_res res; + + ret = qcom_scm_clk_enable(); + if (ret) + return ret; + ret = qcom_scm_call(__scm->dev, &desc, &res); + + qcom_scm_clk_disable(); + + return ret ? : res.result[0]; +} + static int __qcom_scm_set_dload_mode(struct device *dev, bool enable) { struct qcom_scm_desc desc = { diff --git a/drivers/firmware/qcom_scm.h b/drivers/firmware/qcom_scm.h index e6e512bd57d1..7b68fa820495 100644 --- a/drivers/firmware/qcom_scm.h +++ b/drivers/firmware/qcom_scm.h @@ -80,6 +80,7 @@ extern int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc, #define QCOM_SCM_SVC_BOOT 0x01 #define QCOM_SCM_BOOT_SET_ADDR 0x01 #define QCOM_SCM_BOOT_TERMINATE_PC 0x02 +#define QCOM_SCM_BOOT_SDI_CONFIG 0x09 #define QCOM_SCM_BOOT_SET_DLOAD_MODE 0x10 #define QCOM_SCM_BOOT_SET_ADDR_MC 0x11 #define QCOM_SCM_BOOT_SET_REMOTE_STATE 0x0a From patchwork Thu May 18 14:02:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Marko X-Patchwork-Id: 95913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp525542vqo; Thu, 18 May 2023 07:14:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7RY8Nf1sT/JARvaV4XVkvZoMaQuiVxpoz/ELmfMVpltoeTI/S1CsXlhr3smTIo6EVTxaCp X-Received: by 2002:a05:6a21:3946:b0:106:feff:71d with SMTP id ac6-20020a056a21394600b00106feff071dmr2157109pzc.39.1684419251517; Thu, 18 May 2023 07:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684419251; cv=none; d=google.com; s=arc-20160816; b=VoukSG6k++/uGh68kBdcGAiy3Tk48/B0lWttuxeyKGyjcWhMjLAdQ90BFGPgw5jHPk BDopGMyMiM92tB2mHkINkJfr8tHAxQ8B3gQPfKw9DzB0yCUfzZob3+l7ORQREpUPqOto rddJtHnhuzpm+tVs7JaRp7hm9Ht70dkB2vAMFY702zqNUyNHeCzb+FmVXOpdaJ1nMq5c pv2qG4rJd8PeninVHPbO+6bzJAo83w3QQnrS06MrnxnMMfj5tXduiNHU6NCWF28t0Sm3 siYlQcsWsJsVK6WWKpQo0cHRIgQWPhnKYTcGBvx0w7K2VWs9Gw8w/otF0cblFKXeO+pX bOWA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y2Hw87l7Ts/Jxr3HsiObApCTHPM3x3z16x4yMMIWg7U=; b=fL3u2honE3/63BUQerxCQF9y6yrvQWCFgYwj8Av+KRytdwr1gJa71hnmoN1V+dBqiK H4dtg64BXCVG1lZ2LelYZs+z1zwPGsGNYQXC9iVCoZgSsWnlF83hZD815XWdBGb6XZmP TxAP5ZBUF9Fu9gt4nk5WeAFyYSw0NaevUu8QJeNmAKFIEd5Oa/As5+4BjUETv+uHQlL7 OckmuomG2lMbAJZFmQiX1Ym5r5sDQ9fLqEIxoNT+CheLuHGFE01KgAnS9iwt1fuMlB5b FlAA/VGLguflaxQwX8gx4XHqCDGMjszhGDBLxNbHDVj4qnvkRGXTsJ3KIUag6mSoMKPR FKCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=UbH1d1Rv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c13-20020a17090abf0d00b002533664401esi1650493pjs.151.2023.05.18.07.13.55; Thu, 18 May 2023 07:14:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=UbH1d1Rv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231575AbjEROCh (ORCPT + 99 others); Thu, 18 May 2023 10:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231258AbjEROCc (ORCPT ); Thu, 18 May 2023 10:02:32 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FA40E51; Thu, 18 May 2023 07:02:31 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-510ea8d0bb5so797599a12.0; Thu, 18 May 2023 07:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684418549; x=1687010549; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y2Hw87l7Ts/Jxr3HsiObApCTHPM3x3z16x4yMMIWg7U=; b=UbH1d1RvF5tQKqhb7d53yj0gbmWx4JmBW7ux3rULr/Kjj0RuhefLvFoKuKO0kuGFm/ V0D0VT8n89q4OS2WsJqIWcEEGnQLhbvyhjaVN8TMCqRgmYZP5xKc07kNTiHAgLcgBEN5 t0qTXum3ZUoTrHXW7fdqxSyPbp4wH8G+W/xmC0+/VP8HHr9PIhpcIaVu0bfaZpalwmS9 OWPS3v9iQ6AlKx0SSIcmUEZQ8BvxeQzWx/KGKjoObMxmfzzpXCnqc3Mu4zIilMQyjhY3 fCiYZ5oRZ22P5VxBilzTB1TFn2XsqMNN3abIdzGxRkEIWX9b4vVgbYfdBrR4p48cnFia jpqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684418549; x=1687010549; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y2Hw87l7Ts/Jxr3HsiObApCTHPM3x3z16x4yMMIWg7U=; b=SKUpUP2PehJpDex6UEG2I6Ag9j67xvU8LZlNwWGaZMw1lFe4vqVoKNOKuSffYRAo0D 4FNU7GNuFatrO4w8maTosttiw6a2LXw5l3kNINUP4pgKlOyVavrehxrYxrsQ+nsc+enI bxvcJYO556WRfbJ3zuTR2RFOiBdwAS9ipCiXTxWmfJSa6dI465Xfwwl/sKrcyr4h8f5W OI/ReeupjHQJMgIVBfUCoZ5e4yjWIozNLK152pvQeyP2y8GKQ57l1LfmLpsg/ZmE2FrV 15z5gPNMClOZ7SS/mwMc2MR203MP+ZDTHgEaUZV20xRRraBpiiGHnqTzlYAbRJxjMixU +WZQ== X-Gm-Message-State: AC+VfDzvdwS0Fnpdzn7QCJ4ekXv5YRpFbC/Pocfo3hawTrpt3/crXVRC hEK3SFQVeHADvad61cLvNs6cWhkyN14= X-Received: by 2002:a17:906:fd8c:b0:94f:3cf5:6d7f with SMTP id xa12-20020a170906fd8c00b0094f3cf56d7fmr38420982ejb.46.1684418549192; Thu, 18 May 2023 07:02:29 -0700 (PDT) Received: from fedora.. (cpezg-94-253-130-143-cbl.xnet.hr. [94.253.130.143]) by smtp.googlemail.com with ESMTPSA id m14-20020a170906258e00b0096f272206b3sm997025ejb.125.2023.05.18.07.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 07:02:28 -0700 (PDT) From: Robert Marko To: agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, srichara@quicinc.com Cc: Robert Marko Subject: [RESEND,PATCH 2/2] firmware: qcom: scm: disable SDI on IPQ5018 Date: Thu, 18 May 2023 16:02:24 +0200 Message-Id: <20230518140224.2248782-2-robimarko@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230518140224.2248782-1-robimarko@gmail.com> References: <20230518140224.2248782-1-robimarko@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766241601201403085?= X-GMAIL-MSGID: =?utf-8?q?1766241601201403085?= IPQ5018 seems to have SDI (Secure Debug Image) enabled by default which prevents normal reboot from working causing the board to just hang after reboot is called. So, let disable SDI during SCM probe for IPQ5018. Signed-off-by: Robert Marko --- drivers/firmware/qcom_scm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index bdc9324d4e62..c6a38ce49fb0 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -1525,6 +1525,14 @@ static int qcom_scm_probe(struct platform_device *pdev) if (download_mode) qcom_scm_set_download_mode(true); + /* IPQ5018 seems to have SDI (Secure Debug Image) enabled by default + * which will prevent normal reboot causing the board to hang after + * making the reboot call. + * So, make a call to SCM to disable SDI. + */ + if (of_machine_is_compatible("qcom,ipq5018")) + qcom_scm_disable_sdi(); + return 0; }