From patchwork Thu Dec 12 10:55:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjian Song X-Patchwork-Id: 13904968 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 183B0E7717F for ; Thu, 12 Dec 2024 10:56:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=HIeV01Z2KJOaxxslmz6iXipE9ilqHcHhEDar7RRhGbg=; b=gFosSlagLcdb0IdX6VNlmfTea1 v8IDG+DKT1Vv9SlrEJ0cQBVCCZ4WINypPDcaQPmpFpqNNeBcxEG/DpSP8Q2xmAM09UQR9irfqkDJW vUCS2Dg6fgj6WfKYgt4OXEAaudnNJbBM+YzO7I9EsT5rXHljbVBRpo13TY5AJjUY0Qguua7tX4FhW ZM1nYadQqrp0IxoVUY2FiJtAx4DIm68XJ7pKgHhBm5a5j4Pj+a4WouSCDioQADPI+K8MYr8K103mp AAlwV8d8FAZ/Xjqdqh3s0+U0qST67iPQUvVaazX/QGiNzc6AhNbmYKbyBimJzJ89kkaMWiS0Z+/tW QxV+xttA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tLgsM-000000007Bn-09kD; Thu, 12 Dec 2024 10:56:58 +0000 Received: from mail-eastasiaazlp170100000.outbound.protection.outlook.com ([2a01:111:f403:c400::] helo=HK2PR02CU002.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tLgs4-0000000076c-31mi; Thu, 12 Dec 2024 10:56:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gTaARfZHrTZ5WDwvSx7DLPzKuZ+MP5XABWsBfv2VNo/FL5HYbgJpxDOZIu3ED/s+W1M6pxQdmLTDyEqh7mv5WeJw4Zvj6VAeCh6ZzvPmHUFrY14jK79B/U9P4wIOJEnb0r6tfOlFyA9QdCi8EThQUBf2vgugkO3+IKlx2pO4ByNnL/MBntfZzZXQuk2BjorUPlwSR/yz06EnGUD4nRSoZEYBQUSsLIzbeIXZXU8CS3U1zE/hD4+oIipQ9ElURCa2jcKVNcGdAAFK2trQMWqTo4SQuctQ3SAuk+yXI21bkUxPAt8quXkI/sy24ABuoMawaNrmKap9C2Egp/TMeNOOBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=HIeV01Z2KJOaxxslmz6iXipE9ilqHcHhEDar7RRhGbg=; b=LVZV0zg/VoPkerMGSERZm6L4xDio6duhHISMMbzil63W9UWQcH6/ahdvheAi57qG4ieNxO7v7JOmr+O53mJth1Yte7++k5lEHyTslKymt8Sqish+p5fdHV6y75kuMI1EcI81LAaYFSwpFmoMrGbIGO3WZqKUM5CGEamuYizI/q8byvmkUFgvar0opskhGF4pg9b5WpF0nTLJmdDAgAPF1rjQqtu9GvZ6CZb5DINX4FM2ZVhy+pf58MirH8FEXE4rtB2bIk3GpZ996lGMZ7BkQgv429SvbBPutmZfbFpoKB2MNZ2RneEgJ+Hy9kn63nDaDlRwH+xNupzGmdjI8xgpAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fibocom.com; dmarc=pass action=none header.from=fibocom.com; dkim=pass header.d=fibocom.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fibocomcorp.onmicrosoft.com; s=selector1-fibocomcorp-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HIeV01Z2KJOaxxslmz6iXipE9ilqHcHhEDar7RRhGbg=; b=XzK1BXowc7daFhdvW+qMY7qtzEWYPP1csx/DKvLb77Zr//yHDVt09GypDIEta55LwMOySB2OzvqeUlbHe2n9ZvzT11XiN1TKIDSWDuxTiQee/WYB8PO93yVa6EwyQIYq3H/7nNRvitKnwBzvNOp2c1idhvsPsiLSbjfwkSU80bY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=fibocom.com; Received: from TY0PR02MB5766.apcprd02.prod.outlook.com (2603:1096:400:1b5::6) by TY0PR02MB7014.apcprd02.prod.outlook.com (2603:1096:405:a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Thu, 12 Dec 2024 10:56:31 +0000 Received: from TY0PR02MB5766.apcprd02.prod.outlook.com ([fe80::f53d:47b:3b04:9a8b]) by TY0PR02MB5766.apcprd02.prod.outlook.com ([fe80::f53d:47b:3b04:9a8b%5]) with mapi id 15.20.8230.016; Thu, 12 Dec 2024 10:56:31 +0000 From: Jinjian Song To: chandrashekar.devegowda@intel.com, chiranjeevi.rapolu@linux.intel.com, haijun.liu@mediatek.com, m.chetan.kumar@linux.intel.com, ricardo.martinez@linux.intel.com, loic.poulain@linaro.org, ryazanov.s.a@gmail.com, johannes@sipsolutions.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, angelogioacchino.delregno@collabora.com, linux-arm-kernel@lists.infradead.org, matthias.bgg@gmail.com, corbet@lwn.net, linux-mediatek@lists.infradead.org, helgaas@kernel.org, danielwinkler@google.com, korneld@google.com, andrew+netdev@lunn.ch, horms@kernel.org, Jinjian Song Subject: [net-next v1] net: wwan: t7xx: Fix FSM command timeout issue Date: Thu, 12 Dec 2024 18:55:55 +0800 Message-Id: <20241212105555.10364-1-jinjian.song@fibocom.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: FR3P281CA0051.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::9) To TY0PR02MB5766.apcprd02.prod.outlook.com (2603:1096:400:1b5::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TY0PR02MB5766:EE_|TY0PR02MB7014:EE_ X-MS-Office365-Filtering-Correlation-Id: f97ab6c3-b27a-4914-0b54-08dd1a9ba2fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|1800799024|366016|38350700014|921020; X-Microsoft-Antispam-Message-Info: 2fNgnICCRJXULUt6ujbPRUZk9fszwjPnRgGxDKV0AnMDD9t1IhC4rTcIxs4GiGrgE/s823Clp51kI4o7W7Xbzy5rpJJemhLuyx+RjECyLJ4yJSQsG6VJGhq33yU1gOE/WDfo4Av3jcOZcIF+8HdQfCaDcZYo0fkiC/0AP2Y/OMH4/MojyIZIr86RQ1PX6srXukBTuF7u/9zOnfi74EQZHpVrpTwqpLCcigwPsihZhQQk+xoeOL8NhxwhjHdLA9EkF0eGr+P2P/JAlB/yJvnqrHbLlVxLFZC16WSJIYmI7tOMNMVHOOXWMvAiRAFCaFgqtNHXeEtPlsOBxYzls/95+ThOQX+sHz2emZILTBLjRI2WVR82PG3cI5ZvJ9prXZvIG8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G6+VXINfI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TY0PR02MB5766.apcprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(376014)(1800799024)(366016)(38350700014)(921020);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uSZEw7rMO2wNgMj8k45yJJFfTM94OBeXxllLN2IIB6YB2k4yzdNYRFxXQKYWekEewhqHD5+pOO0qRCEyUDWN0/vn7zMfrqG9IHpD1U8OImJEi9cDCT2o/m+4CUFOXFnzJL3myda0AM0QBtg4sCaQeJBFq+oI/TJw/NAP+I/RPa5PlcuN2TNzJg0S8xOzkn5QRFCcyqQ6EGDpr05CxLI+FLXC3m3tBYi2GtCgXJR2wpYNrXaCpagi2uVZbM1qcZA7+scPdx4hRzYh8D4lZknC856jKlKSg5+Ftr4nLvuu0QoMhuk0QH09SWGAGUFiwie8JPiwKZDAxtc8TQaDBMYyP+uid9WRMBHKDM0w6GUg5DaChTstcaKWb1uqIyH8h5QDDuQxVs76bEkrP7JjLmNJEeyen4z1p3ve3pFVXieV3jKcSsvU9Q29OK0stncRBe/2+SsHN2NFg2TH/6g4zw0wrn4ZcMlkiVBSjTWWx4PiHk0wCDpuGpMZAAER6pB6t3jaeRyqzgOK4IMjpAb4p0h0LEYVKZR1b/sgexudel8RN8qrHVaocRhRkbwD11Vo8qNFhcbBX5DB/a2uts9tfv7qp3LlbhIG6YGBJsVe9vuEMxK1d6aS2x0Ew2wbQ1XYPXQrsu6Zm957LUaVimLrgM+t2gbIbB/f8AgurklkYNdHT160wzj5jHKlQZC18Z8nQBVFf1ZTZJGoVpB3kPXY5pEbzkGJU2twouivAnJHpHoqgbZcYvvknGMSIPw7vuKaWN3Vbxp+wcJRVDGm4vL+36ilZwodNTKdqyOPqWabbPxW7fh8CZlWX8yrhx3omDdi2cGmxcfvHxCZTRuExy7G8WjVdGvjaEJvmN7wsqtxRtOlRrGhmi8+jJtIZlBUb7U32tNoYIIOhJlhdXFcKnZrWP60N3QIbmNe2x1yRjeACPw+cEWiFbmBvGVJpH7vZyfS/Rq8JVWx3m2r5cjc8VsZFUx0oQyWijyN7EgdP51vHpDK/YfhUYpL0CvZv/PTo5h7MtG8kHlcjhlVeEw49zwkRxlqA3IDbMM7hbkAvden8xpzakDl4Cq38f1XLL6Xv0vCvre9YkVEmpMbwb0aMVf41PDvnygidGJWxaJlscAB3sK+QyrRUtjRr4jh9XJ/+npHZnA+Tadm/mv2OTTZMw3HOZ12PuXj/6guTjgFOaamuQzTlkn79MJuHzHGC4nmYMOqlJhsS6AsMPgBVhGBkWbNPx0dBi+4Sr0dUoADn+A9RzRXanfFdEzgf3npjRT7za2AgzhkyCpihtTlAUCrsyWQ2XdKH5oB8jf6HUJgMN9c8NlMZVNy0jAP599epfvbKMIbvqGae8Z8Wyikxpt1q8edoWUZ5Om3lxfZK+e7C15HTLuGwTKu1s1kZvXXSPu1fnnJvFYaPEx7526s6FKNCDpkHdV0oxN/0Nct7hh+mhevrM3M3WBi1J8rVcHVCTtjcA7kFI78vTPwghFSZRuhe2BOo4qQO7z2ZMxW2axRubpxEzkBUsH62khj0TjdDR1h1/5QyGnqn//mgfVU4o09Knsa+Z3DQBoXFLmJZcd1jt4+cXMDXqa/7eGjEcbkvige3uV0eYuM4EdB9z51xG3OCKIBrYhVuQ== X-OriginatorOrg: fibocom.com X-MS-Exchange-CrossTenant-Network-Message-Id: f97ab6c3-b27a-4914-0b54-08dd1a9ba2fb X-MS-Exchange-CrossTenant-AuthSource: TY0PR02MB5766.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2024 10:56:31.7634 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 889bfe61-8c21-436b-bc07-3908050c8236 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 028xaaS3rr3xMmDqBqTmTlJzLrB9ahpJODo5QA4MSKoJofhvhK7V2+i6OD+BNEBP17cFOn85SrnzGxv9ZZgqUvuU5caL1ALkbRer7xHFb3k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR02MB7014 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241212_025640_766401_83ED2D69 X-CRM114-Status: GOOD ( 10.62 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org When driver processes the internal state change command, it use asynchronous thread to process the command operation. If the main thread detects that the task has timed out, the asynchronous thread will panic when executing te completion notification because the main thread completion object is released. BUG: unable to handle page fault for address: fffffffffffffff8 PGD 1f283a067 P4D 1f283a067 PUD 1f283c067 PMD 0 Oops: 0000 [#1] PREEMPT SMP NOPTI RIP: 0010:complete_all+0x3e/0xa0 [...] Call Trace: ? __die_body+0x68/0xb0 ? page_fault_oops+0x379/0x3e0 ? exc_page_fault+0x69/0xa0 ? asm_exc_page_fault+0x22/0x30 ? complete_all+0x3e/0xa0 fsm_main_thread+0xa3/0x9c0 [mtk_t7xx (HASH:1400 5)] ? __pfx_autoremove_wake_function+0x10/0x10 kthread+0xd8/0x110 ? __pfx_fsm_main_thread+0x10/0x10 [mtk_t7xx (HASH:1400 5)] ? __pfx_kthread+0x10/0x10 ret_from_fork+0x38/0x50 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1b/0x30 [...] CR2: fffffffffffffff8 ---[ end trace 0000000000000000 ]--- After the main thread determines that the task has timed out, mark the completion invalid, and add judgment in the asynchronous task. Signed-off-by: Jinjian Song --- drivers/net/wwan/t7xx/t7xx_state_monitor.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wwan/t7xx/t7xx_state_monitor.c b/drivers/net/wwan/t7xx/t7xx_state_monitor.c index 3931c7a13f5a..57f1a7730fff 100644 --- a/drivers/net/wwan/t7xx/t7xx_state_monitor.c +++ b/drivers/net/wwan/t7xx/t7xx_state_monitor.c @@ -108,7 +108,8 @@ static void fsm_finish_command(struct t7xx_fsm_ctl *ctl, struct t7xx_fsm_command { if (cmd->flag & FSM_CMD_FLAG_WAIT_FOR_COMPLETION) { *cmd->ret = result; - complete_all(cmd->done); + if (cmd->done) + complete_all(cmd->done); } kfree(cmd); @@ -503,8 +504,10 @@ int t7xx_fsm_append_cmd(struct t7xx_fsm_ctl *ctl, enum t7xx_fsm_cmd_state cmd_id wait_ret = wait_for_completion_timeout(&done, msecs_to_jiffies(FSM_CMD_TIMEOUT_MS)); - if (!wait_ret) + if (!wait_ret) { + cmd->done = NULL; return -ETIMEDOUT; + } return ret; }