From patchwork Fri Dec 13 06:47:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjian Song X-Patchwork-Id: 13906606 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 827E5E7717D for ; Fri, 13 Dec 2024 06:48:16 +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=S+skzNz6Btvb7D8VparQSNjLaWWiBQRZ39toxKxtipw=; b=Wgjq4mIensrRRvqJo6dh5s96kI kPwoxIlSdjra85fbb9aiopEhZBZ9rZwhH9Nhfse2vnYPxNovOizLEVKy2/WFP98GPJilz80rIl7N1 UDZ/EFrJENZi+518+tgKff6tyJxIzKCSepK0/Bpas20Fv7pVF3NVTJQ0Yj40B8QOBsYFAhbm1Tp2o uR4o10pvx9eyrZcJaGW7a1EJlaDCFG0HtLS3Jmk34AbF0+lu3W627yannBsk+sWS65WJSTbImJ/yF yOcRhkaMSBjn+IVzTzIrS4iD7Usc0i56a+3Ys1Ml/Gqh6YmQfXlZ8NDFv08OfF59vArjCkTfNxBmt 5wqcPEiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tLzTD-00000002tmt-1uhW; Fri, 13 Dec 2024 06:48:15 +0000 Received: from mail-koreacentralazlp170130007.outbound.protection.outlook.com ([2a01:111:f403:c40f::7] helo=SEYPR02CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tLzTB-00000002tmB-1yK1; Fri, 13 Dec 2024 06:48:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=knVRDr/XavlFjasymwmSqOjy9Es/eKjw1qBA0MkLtTAxDrYI6t4gF+8+NTlAp5WWGBoGRGWxFJ2NZbcU6vEJQEpg6RUbnx3odai8JVSfJmx8zHCpX91lQR7DICz5Y/Gfz3ocpW9htWDgP+EqkV6tiv81Y7jHDwlLlbnKZWpB+Qt2Cr2BR0loYbgBm9rdnUcaNL2dbDv8d4vVYv/CV5lKhKPmRYDae9bQmk6tqOC44+RbYHgJS9ZFLFSpyI4FwE/BDMExls3Hg+JoB0RDejf5Q/3izy4I66Tr+9pIm4m0HDQ1wJmVVCT3u1mUM3VBMJa7wij39GY+6GZKuhL+dLjBjA== 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=S+skzNz6Btvb7D8VparQSNjLaWWiBQRZ39toxKxtipw=; b=Mey+13i/o3x7TqnIPA6+7P/BvzFUCMkGfRmeFwg+qMiMmOnIs2myAvYOFUXpYoLHotaWxOGWW+1Bs8b4vL71XdTVGQ22yg7Xb8rM9jhwn3owP0SvdQzaiHIfaTa9UeweokqbZ6RlMnvqAi28xFU657mj2/z+YXZmsY6sSjVbh/FyU7wOW3oqxlP7RcbBOYtNUm7q0MTekEZV0qBL7tEhtZY2ewTUikc8E5QItdQ18Win/kzwuzErTQ+S8nGDYBgmwL9YNTxepHwidzl6+iKEpZ+GViktx9itAzNDrMjboA4j7J23asdgVRV0B9lP7cWVvURzry58KjrgRy2mSoXOxw== 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=S+skzNz6Btvb7D8VparQSNjLaWWiBQRZ39toxKxtipw=; b=mjSylSkd8A4OuFnHYxQcejuID3si56WGBXO+lQFQhaIqfVALqUAZDMEZxYF71FhZNsFOVsu6MIa9R10TG8ZGuJdLuZ6yD2z1rR/5Z5vd85M8EexxmyDEDQO5ZiMwQDFLX5Vf3yqwmpYYYe73kDlHJuBRhxEtq7eslXkAYOZk3UA= 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 SEZPR02MB6987.apcprd02.prod.outlook.com (2603:1096:101:19b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Fri, 13 Dec 2024 06:47:52 +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; Fri, 13 Dec 2024 06:47:51 +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 v2] net: wwan: t7xx: Fix FSM command timeout issue Date: Fri, 13 Dec 2024 14:47:20 +0800 Message-Id: <20241213064720.122615-1-jinjian.song@fibocom.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: FR0P281CA0243.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:af::10) To TY0PR02MB5766.apcprd02.prod.outlook.com (2603:1096:400:1b5::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TY0PR02MB5766:EE_|SEZPR02MB6987:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ccf319b-9ea2-4ede-0e8b-08dd1b421056 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|52116014|366016|38350700014|921020; X-Microsoft-Antispam-Message-Info: v+97HsVOdXWtGUxLaExDXfVDHjsxf8k7reIa+TCdNCff1HBNe4AqcQmiBnf+5QyHJfVYvrOPmJih7zg9EozNOu36vqk9kCAYRpPr8hGuflBWl2+usrFm2aZpurdrkjhrWX0yByNGc8kfeN1fYDWVISo277LRbj8LFuz8RalwEskhW0BI+TzYUVCryptDuyRIPsf7SckaBv9S7sFu885Bc4vqzshpnlnD68Kjf7r5Cp6ywO3DeKYPBsPJzHv2ZlHtdTjnK78vhG0HPXMGi4NJID/M6N73iq2lAsnod+d5JpLNDh3KeDOViwbGflpU3dUxdPIsM7Rw/jDtP8jgTApC/pK1XCxHjJSw4hBsaIDKSgiT0Dt8t3PLeCO+dXbiDgfd6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MUbPhcZYUKD0WVhNlTUA== 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)(1800799024)(376014)(7416014)(52116014)(366016)(38350700014)(921020);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 51rQUquBPJx+DqL+hWWRIu3ewcyju21QeZCWuwqY6gs26/E1y0Y/ALA3O5/HoW5ZYvXDYgZaYVVa0Ae1/5kJehUEEoNWdZgC0eW2VhoHH/3sQGHhQjrjDsH5uQ+nsrokSeDrO1A9/lxV/ctj+2xJahi3nGBkQwylWuINTSnOi7jmJPROoFHLK2mx0NAE59OU5YfkBjZNL+ggoR80wFNRBqwv8Y35kfqJQFZ4o12BOwClvjuugOcK1ucsSp3v8ZF7ih9cGq1+IVmFzciZjE2h32iciNIpoLd4MyC4BVF1orMe+/M5nZilhwGptKGaNTfbwruGr21mBaTaLZt7p51DfITwW91vCzIwA/fpaJWopilRJD7LH5pX8H5t6f3jW+PBOJbUuKITIl9XRa+UTfrUnnD7B/MWExZisv+7KpGodT5LyAdn5Nur4A/AOvskd5zfiBTNmfNfkR+4UEujkAwRExD2r21Pv+C8pDHmyIXNZs2hmNVA138cDlyM8OzAkHZlQEA8aUWbeQLReOBe5cDqSrcMEespLmQSvYsGiQUCPzfMiG6RROZAhKhJZMslkSgXeEUnY0HpoaosKlB+RKQ0gH2SsosbkoGlpkSeQH9qSUX0nJO2Pk1QT4qljfTqlWlu4/gFumm8WPCiHJ4aag/kSJ+FsvfdgkPEPCE1xAbRzUgOTeSUp6mC5NiPsghv6DVsi4vJVfIFGnW4iaNuV5GpqdtaDRFjBlGrmkMQ3NmSznQLINP1KpMW2003ED4z9Boe7F2y5r2Sff4TDDkZaJV7HEsHXP89ZR7REj3V7Nk8n2nsXpzGSiX4HkHleKkc6HHoQ0Z+LDHys6qNgN7R0qk05e0VKkBPE+ySservvh0bu+svTDSCfVaHKLVzOzb2lpIoOipQL0gM+5xC+z6nFEfjM3rX575rhSLkvAGRAUyy0638AlDrd7C07YXzZlwsPtyPO6py9q5mWg4ZKUUPVqA397z+Z0reVavRcM+LDrjKS8oFaH7DMJZSClI5dAdbazA4eqRI2AmgLdq1yzkff/GBUdjGONERFe02i5SOHJH0WlATSae4xxzCdUeKgm0JxfvGNj2UYg+rI9KqqjYlupujmcPPCmILQBF1s7zG01af7p0tCrJzSCvl/SbhWZxbXYlg1hGbHc3zREurSvD4kYW4WgSFSnsOJi1EiqW1caSy8rBXz3+TKbZJPgA4aZgfA7QzI1Qc08qCXG3mSKa/T4bdUyiWZc8IaIEx8CswZLQROmqHYyPXaRqmV5qQeWKa+tJMc0ohU9mItr+JbayLvTvTt48qiMdHLr1jIAUkQRY/Y2adqyd3txRkbBNgN/mqn/tnPX24ukr7kHdLv//MBOcNsFn0gMH2sLQMpYCN7IiE2QTCo6U1EMBJOhXSIEj2m0Ma+zl8ZFcCPNlb/t20iUHXj9K906N8MKDyFJAFeUDzKkhBapnCP6gH/u2q0h9SUMmrMW2cZy4IqF1y8gJ3GdAAZ8qXUlZxTZaqdu70Zb4e91RCc/HnYbPtXQCoK2wBfW9eBnFRJCFf29fAvM7FGgmWJKrgsxdLFjArX+L5IyinBG4ZI9WPRNs4NPPCy674Bt2+VYA4ZxbyxOZBzltgBqVFUQ== X-OriginatorOrg: fibocom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ccf319b-9ea2-4ede-0e8b-08dd1b421056 X-MS-Exchange-CrossTenant-AuthSource: TY0PR02MB5766.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2024 06:47:51.6148 (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: h5RCbCU7Bo8T1jfWO9bsRAHCciuapyjGqgZ1DaNa0XjHnsgqiRaGx0DtNdxZdsS8N8bcBdIHt5TpqNLZXFcbGwEYh+PSRYdVZWFcPhzIT+k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR02MB6987 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241212_224813_502112_8B0DD31B X-CRM114-Status: GOOD ( 10.14 ) 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 an 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 the completion notification because the main thread completion object has been 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. Fixes: d785ed945de6 ("net: wwan: t7xx: PCIe reset rescan") 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; }