From patchwork Mon Oct 9 10:05:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Gupta X-Patchwork-Id: 149921 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1759048vqo; Mon, 9 Oct 2023 03:06:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdTKs6S4IWoIZFm9FMQRtd5T1uxGHGcApXk/RS2VaM/a0ibE7Wok8riLWFIL5RapNZVZZ2 X-Received: by 2002:a05:6a20:1611:b0:15a:13f3:49ca with SMTP id l17-20020a056a20161100b0015a13f349camr20707799pzj.9.1696846005261; Mon, 09 Oct 2023 03:06:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696846005; cv=pass; d=google.com; s=arc-20160816; b=d0dch72ungm8s80Lh31X+45ZLUtSb4YspdoDmxirAcePoyyTDD1kIUhxd/0qknaKCN A7F1YV8Bvkk949FhB9RpD/+7Ea/u/hMOq9lEsRyYkBmk/MaXeVYo6EtCVxfFR6iWv/m1 X2RRE2WkwjdqGgHZAAljuYTxnwt8EZZ+ZMW9ba46NKH0pgMDBEx44yLssY96ChGDfDgC QBEN8UDtlzKVsxnv4NNAM7VHEnNWw5jr26ySkawwF8rM9jmgmvZq806ZJod4UDutQMu6 Gdxjq4Ve/6Mh1lDpiA82wRz1q/EclKAnDIAu/qVOGDxftViB+IdqPBGItrpDKrzYUhrr 535A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=3bOSTM+yEk4wMHZfxyFrjgvwUwfOEgcd9FAeju5IZTk=; fh=GTOTMXDy+VCvZcUtE228lBPtDzGkyirl/S1BKf59DSI=; b=BIUJiweED7N7qsIPSqf+24uDlJjrtHJzn0IwMSOvTYOrsdSrBUcbjfoOjtnoSs0CIJ ji1/aPmClQSS0h52ev+4isD1lsjkOMwhe2wOtorwnsBmuYfnOvAsREqtiW6jmTks2rmg ENHFFpRKfBzB4pvwhCBo9Y7j3KHkVgNthF8HjLAWfPp1waLU6hoSkim3hI1CtuPhxFij Us2bg+gOKHJcTx+HDeLnunIHZrOn7RsjqfmPCdfix9Jz+syvUOaNQu25fyMp+sBNF4Ja QTylId7DpAk2SUgfMADYbn3be3EvPnPwHUHd8H+qJUbHomLphrlMb+sbIX0WJuVFgQMh pUXw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=POX5C6Vd; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id w9-20020a170902e88900b001c753d6b95fsi9842561plg.315.2023.10.09.03.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 03:06:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=POX5C6Vd; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 0F9E38042850; Mon, 9 Oct 2023 03:06:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346056AbjJIKGV (ORCPT + 18 others); Mon, 9 Oct 2023 06:06:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346057AbjJIKGS (ORCPT ); Mon, 9 Oct 2023 06:06:18 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2071.outbound.protection.outlook.com [40.107.223.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BBEAC6; Mon, 9 Oct 2023 03:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gVvDO2gwdTq8TfvnJz2cVzWMWGi0OtukPcUmCei3JrOS36Un1oohFvWQdXCsJW8jccZwTf9T0twnfXwujMo5id3sf5WP+IRcP2leQgcZEdQhshryN4tBOH3ZkKbyqrzs+yhzWnXUITZFgf3H8TEdTdzmqYp4IGDVngxQAZ1ZUZX0fKa9AKR1tNnuPFS8foOeXJ70pXqGArBHSm+4k77vgoU6uGLHKr66t8iqkk3tJaPloXTAH+QHqoCUDkNAlm9Bt1TOlmb1x6iOYYYiXlwxOoyse4ndFWVyqoAHNKHRzsHQzwcpL2yD9AMh480nLDqi/LxEX2CdiKN7IDXyX/+52w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3bOSTM+yEk4wMHZfxyFrjgvwUwfOEgcd9FAeju5IZTk=; b=f3OVGgfl0cUTfuBD1flwy52bPuS1WUcGoFrZoPKjoeh3w9R0ZK51QEQnybq2vmPlQW59WzbJa+maYKMnbcHoH+ptdeNOylzyNPap/nCgbBnjcehSWeeaap8V4eibkSUXhsZheaj3hWOAZwokqmsCST3MasfAfpPH2keguNP1J7wFQtgoBCSEbydcm4MVsWesIUINn56z1jpafoLj/YIqyinMnT1d0aBeDYbOnqd/eVoo4P+X2F9HTLvKOczmlGXCGQWzw01xJuZM7KiGK1/6Kg5I/7dJ+DSqb9LrP/J1vkvgh4rqVqJE712S+r7nTIUvv2NEY8C6FH4NFSBMIrW9VA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=linaro.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3bOSTM+yEk4wMHZfxyFrjgvwUwfOEgcd9FAeju5IZTk=; b=POX5C6VdHAERC0bzoYg/Bfanom6f1DzdZMwyvMGO+jjyb0RAQQwX9dQvVXwTdtW5BprBjJOSQVIUre9YjyXB3gs2o+k1FY1eNvQ70nhgiG0tf8bwqYmt1vvATfSHPhzEpI2xFXcaGrs958Ypo0/qDC/judSaF2OTYLrtFG3evbB2zgDBLO9eWKcEscu9Hqz07mwQnHRn1bfMENTQSy5QRsvNiPqooSeaNqhAGdFgOv6/00ycXlu9+4HqFItoaYQxoGXQT8NUORsXb8+A1vW2Tod9falI9Qn6WN2PtapNj6IJbrcpTYluPN6mzIRu84cglNDNQegCDMpvJW+suPI3tQ== Received: from DM6PR13CA0032.namprd13.prod.outlook.com (2603:10b6:5:bc::45) by SJ0PR12MB5422.namprd12.prod.outlook.com (2603:10b6:a03:3ac::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.37; Mon, 9 Oct 2023 10:06:13 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:bc:cafe::21) by DM6PR13CA0032.outlook.office365.com (2603:10b6:5:bc::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.21 via Frontend Transport; Mon, 9 Oct 2023 10:06:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Mon, 9 Oct 2023 10:06:12 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:06:07 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:06:07 -0700 Received: from sumitg-l4t.nvidia.com (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Mon, 9 Oct 2023 03:06:04 -0700 From: Sumit Gupta To: , , , , CC: , Subject: [Patch v2 1/2] firmware: tegra: add suspend hook and reset BPMP IPC early on resume Date: Mon, 9 Oct 2023 15:35:56 +0530 Message-ID: <20231009100557.18224-2-sumitg@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231009100557.18224-1-sumitg@nvidia.com> References: <20231009100557.18224-1-sumitg@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|SJ0PR12MB5422:EE_ X-MS-Office365-Filtering-Correlation-Id: 40b61d2f-d19d-4340-0e25-08dbc8af5e43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VdEhdBXnaaeek/PnrxsH00nrjbRbPdTp02/gQaXlVSa+NPZdz6wNj5IbYiQ4wrHfX3g8cNG6J2HricGrdc9VxJaSXK1TxFbTZ+VQYqXo8JHVtv8DyluKI+4GiknIhXU6x0k2JoGjsKAtFv/I467k543eK/4Hcshsj0ysZdW8YX0HA3PYixZIujNeteJKpbalTLQZasmCojuj38B6/8KQwDEtBbX65zKCyuCA6TR9gZOEYOSJolYIjcAn4DVWoc39Ex9kcatfUq0NNPk4ZBCWCbSdJdyVkne5myq61vOhSUe/xh37WrlauPN/oCz21T68jgQWw1OzFPohxhwfEg34iBqLitJzXu7404Il10A/ietHmnvVRRpYYfaAmdWLVRXMy3OCOtvevKhmCUyhXiWXCmmHcPQdgk2cs24pp+jEfskAeIcRAV+jbcVf2jONPY28yXZkxdRhGuqGimii5s2OLYyFlAq18MCAViGePBBFr54Kyt1cJE6AUd/IXwVuQjnCz0mI2n4Lwm+7enEE48SLCnwSP9csDyXSOrnZv1Bh9V7JDcK8zn+vpUgQuVLL5wn5n8A5ZoJUuSWDR2atM5u92oZANDzZyI3tyMTq103wzWDkijxdF7i0x1N98C9/QzkPkRlFDLkWoYtWt2vhJGeY74IjtjOWOM0FXshOTom7BF4OSi6SgI3Mn2zfHrw5CCczhwQqkSGH4AU8KVKeKNwmMYWA9iLmYy34VvWPficY89JkRWhI7HplR/OmdHAPU56a X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(376002)(136003)(346002)(39860400002)(396003)(230922051799003)(451199024)(82310400011)(186009)(1800799009)(64100799003)(40470700004)(36840700001)(46966006)(40480700001)(426003)(40460700003)(83380400001)(107886003)(1076003)(2616005)(336012)(26005)(47076005)(36860700001)(110136005)(70206006)(70586007)(54906003)(316002)(8676002)(8936002)(5660300002)(4326008)(41300700001)(7696005)(6666004)(2906002)(15650500001)(82740400003)(478600001)(36756003)(356005)(7636003)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 10:06:12.8091 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40b61d2f-d19d-4340-0e25-08dbc8af5e43 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5422 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 09 Oct 2023 03:06:42 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779271996404248610 X-GMAIL-MSGID: 1779271996404248610 Add suspend hook and a 'suspended' field in the 'struct tegra_bpmp' to mark if BPMP is suspended. Also, add a 'flags' field in the 'struct tegra_bpmp_message' whose 'TEGRA_BPMP_MESSAGE_RESET' bit can be set from the Tegra MC driver to signal that the reset of BPMP IPC channels is required before sending MRQ to the BPMP FW. Together both the fields allow us to handle any requests that might be sent too soon as they can cause hang during system resume. One case where we see BPMP requests being sent before the BPMP driver has resumed is the memory bandwidth requests which are triggered by onlining the CPUs during system resume. The CPUs are onlined before the BPMP has resumed and we need to reset the BPMP IPC channels to handle these requests. The additional check for 'flags' is done to avoid any un-intended BPMP IPC reset if the tegra_bpmp_transfer*() API gets called during suspend sequence after the BPMP driver is suspended. Fixes: f41e1442ac5b ("cpufreq: tegra194: add OPP support and set bandwidth") Co-developed-by: Thierry Reding Signed-off-by: Thierry Reding Signed-off-by: Sumit Gupta Acked-by: Thierry Reding --- drivers/firmware/tegra/bpmp.c | 30 ++++++++++++++++++++++++++++++ include/soc/tegra/bpmp.h | 6 ++++++ 2 files changed, 36 insertions(+) diff --git a/drivers/firmware/tegra/bpmp.c b/drivers/firmware/tegra/bpmp.c index 51d062e0c3f1..c1590d3aa9cb 100644 --- a/drivers/firmware/tegra/bpmp.c +++ b/drivers/firmware/tegra/bpmp.c @@ -313,6 +313,8 @@ static ssize_t tegra_bpmp_channel_write(struct tegra_bpmp_channel *channel, return __tegra_bpmp_channel_write(channel, mrq, flags, data, size); } +static int __maybe_unused tegra_bpmp_resume(struct device *dev); + int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp, struct tegra_bpmp_message *msg) { @@ -325,6 +327,14 @@ int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp, if (!tegra_bpmp_message_valid(msg)) return -EINVAL; + if (bpmp->suspended) { + /* Reset BPMP IPC channels during resume based on flags passed */ + if (msg->flags & TEGRA_BPMP_MESSAGE_RESET) + tegra_bpmp_resume(bpmp->dev); + else + return -EAGAIN; + } + channel = bpmp->tx_channel; spin_lock(&bpmp->atomic_tx_lock); @@ -364,6 +374,14 @@ int tegra_bpmp_transfer(struct tegra_bpmp *bpmp, if (!tegra_bpmp_message_valid(msg)) return -EINVAL; + if (bpmp->suspended) { + /* Reset BPMP IPC channels during resume based on flags passed */ + if (msg->flags & TEGRA_BPMP_MESSAGE_RESET) + tegra_bpmp_resume(bpmp->dev); + else + return -EAGAIN; + } + channel = tegra_bpmp_write_threaded(bpmp, msg->mrq, msg->tx.data, msg->tx.size); if (IS_ERR(channel)) @@ -796,10 +814,21 @@ static int tegra_bpmp_probe(struct platform_device *pdev) return err; } +static int __maybe_unused tegra_bpmp_suspend(struct device *dev) +{ + struct tegra_bpmp *bpmp = dev_get_drvdata(dev); + + bpmp->suspended = true; + + return 0; +} + static int __maybe_unused tegra_bpmp_resume(struct device *dev) { struct tegra_bpmp *bpmp = dev_get_drvdata(dev); + bpmp->suspended = false; + if (bpmp->soc->ops->resume) return bpmp->soc->ops->resume(bpmp); else @@ -807,6 +836,7 @@ static int __maybe_unused tegra_bpmp_resume(struct device *dev) } static const struct dev_pm_ops tegra_bpmp_pm_ops = { + .suspend_noirq = tegra_bpmp_suspend, .resume_noirq = tegra_bpmp_resume, }; diff --git a/include/soc/tegra/bpmp.h b/include/soc/tegra/bpmp.h index 5842e38bb288..f5e4ac5b8cce 100644 --- a/include/soc/tegra/bpmp.h +++ b/include/soc/tegra/bpmp.h @@ -102,8 +102,12 @@ struct tegra_bpmp { #ifdef CONFIG_DEBUG_FS struct dentry *debugfs_mirror; #endif + + bool suspended; }; +#define TEGRA_BPMP_MESSAGE_RESET BIT(0) + struct tegra_bpmp_message { unsigned int mrq; @@ -117,6 +121,8 @@ struct tegra_bpmp_message { size_t size; int ret; } rx; + + unsigned long flags; }; #if IS_ENABLED(CONFIG_TEGRA_BPMP)