From patchwork Sat Oct 14 06:55:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiji Yang X-Patchwork-Id: 13421924 X-Patchwork-Delegate: kvalo@adurom.com 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4CC8CDB465 for ; Sat, 14 Oct 2023 06:55:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231469AbjJNGz0 (ORCPT ); Sat, 14 Oct 2023 02:55:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjJNGzZ (ORCPT ); Sat, 14 Oct 2023 02:55:25 -0400 Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01olkn2109.outbound.protection.outlook.com [40.92.99.109]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 715B083 for ; Fri, 13 Oct 2023 23:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g8gIc5Rnv5k6PLrQLh6++rTFE3h6TiJDNLAhOojqeu35pQqlpuZi40SE9HkriGU+C6MRh7rDNd2SwGlbp2Yc3CpGxaf9z85GPxj5p6rb78gS1b3TADlW0pLzwKckRucJ2Nd09Es3x0GtyOCkGAgnXiLPrxZomNEAcOoqHkKL9cLJIlVadmiX6SIbDuwOyIL9Hfprxljr7VqASEDdGx+E3XSxg10wl1c2I3FGZjepORwJZcDEj7+bdqdaC4hxtJ0ni9CvU9DNx6bHVNBAgwgx3FDq+eWpXXWG+KTTgEq9B1XEo++jm3XaDJAV5m4u3TxcJZUpmaP16iu67mDFSakFmg== 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=kHkyyeYZYw8yrsNEZp3pB9iIQFv1UETmRjviTZ461oU=; b=MsAwrljtQal3Rzq0siNvjnXV+d6MxdaZ2mn3W4p2hd/vEgU9A7GBVcHe047fmFOh0N0AhQaE1pFqFZiyNUqV4EpwZ/x2f371LpqkE9taOJZU36WHkZY12P8uh5+6F8B+FJoqEUT2wBFHL6Ghpdn0PAJxXgWiTDGP+VOshfResApp4SlkPTeebim9G0NYN/DKrw1tdqO7hYMW1kL8d+p0xceXMRoI0up7MVVoh5ua3rti5eekJw+fJGN8rvhuajJzj6lbOiFeKm1PBALZH0YBiePosZuVQDPZF4E6h6N3LJADyMe6qrCG36lswxPqCL6oGFrofiIVC0CappyY0cmqDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kHkyyeYZYw8yrsNEZp3pB9iIQFv1UETmRjviTZ461oU=; b=d4Ok4/YT9VcUMi5KgtwcXpbqOCT5/ad8Mio9h7R+qvk+gWaZDJ9DCjNw5FKXsgkC6FDIu3jjUIEzoL1glrCCamc23VX6G16uqXbYykEXTNKeqkbApytZnLQ9aRsW7nba1s2UBp83qXw+7qvfv1NyZqleyvZ34dEqVvoC8t7Zp+Pr1cWUitb06pXj9B6ECBxfjOmsDEOyJui1f6K+lAxud1TohOJCD/8K++FfkCULl3qKyxBh4fZcFAeoA8vKvCGnObkccJmBN5rb+/LWwmWVrQy6fuIxzXF9rUv+7vYoFRiqJES8DmYeZEK67a9dL7cNCeE6l8Olb5n8/C8nJcbNbw== Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) by OSZP286MB2332.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:15e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.29; Sat, 14 Oct 2023 06:55:20 +0000 Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::bbb1:a301:f7b6:744a]) by TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::bbb1:a301:f7b6:744a%4]) with mapi id 15.20.6886.030; Sat, 14 Oct 2023 06:55:20 +0000 From: Shiji Yang To: linux-wireless@vger.kernel.org Cc: Stanislaw Gruszka , Helmut Schaa , Kalle Valo , Shiji Yang Subject: [PATCH] wifi: rt2x00: fix rt2800 watchdog function Date: Sat, 14 Oct 2023 14:55:01 +0800 Message-ID: X-Mailer: git-send-email 2.39.2 X-TMN: [ZcRznt3HgiZxV1aXQK0xnDrTWtoPqk9TbFczE7bnSSs=] X-ClientProxiedBy: TYCP286CA0328.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3b7::17) To TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) X-Microsoft-Original-Message-ID: <20231014065502.2841-1-yangshiji66@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYAP286MB0315:EE_|OSZP286MB2332:EE_ X-MS-Office365-Filtering-Correlation-Id: 55c5a1c7-f8ad-488c-6882-08dbcc82879b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kX3FKwoXrgZeft6oQlGrtYi3K3ldmYK8odU2dm9tu+QzqEnlqgN1lI8T7geijsPWqg7EGWET4+/WSGegWEGPfWz9OQQsUebcw9JAUatXpW8Rsetja1M2kNrznAxHIf6AnR67uV0yOWjpGEV2A/yLyfySmI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tJ7BNxozZDPKhZ9t7ZtcbpmvmBaR4WZKbWQACNbQqeCZ+ZiZO2KgC9EZbKxrOGm0jvwSVM6Vgh98+4IHmA+G6w7ZMxJ7d3flslChZ88BCDAiowIx4nw66xKGe9vHV6jomv2pNRvqbE8XroIc3e97cjW/trTwWS15z5BH5jEBP+PPmJ8CGhtPlaQrBekOKMr5zLPcnLwvwr2ATxezYl8QPyxnGgtjDm2dbmxOfA7zuEeNsF1qeXk4uYnse38pwzLK5HA0ZtoFzYXtH1AFCGavykxjfvkq9tjUlf/g/tV5jzsERfTS+oPnqmkVFB/bg/McSQ22rFI0R0LprAb5iQN9jcYH3SiuKKMtJQJR4TY0+23/dxgiLLdkL4qFy8fJXejpXXWs2KO36K8LOibVDqumLI7/SrErHW2Q0dXGbR3xemqe9RQNa6iR0aRj9afhCr7XNCwmgQ+Q9f4lKoMnxWIpZfMe2ma0hTT4DVUsypwi1rTHD47M0eJOpQoMKMDHWuqmzaFNXSxORKcmmDEVjN4AuFBj7hSVZIl6fHYPjgmhkG+5RR/igwitTY58aL6LZgfxeEl0mnWOaIWcDy3fDusKUxKIfTURyBkfu7Cl5Nyu63DWd3ClOPLWx0A4Rw/mLRw3A4i2RRm1tAHVxEjRrff9OqaZwCH2GHhSCcFw3cgAgRs0WhXJmOmJjW44= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55c5a1c7-f8ad-488c-6882-08dbcc82879b X-MS-Exchange-CrossTenant-AuthSource: TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2023 06:55:20.4024 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZP286MB2332 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The watchdog function is broken on rt2800 series SoCs. This patch fixes the incorrect watchdog logic to make it work again. 1. Update current wdt queue index if it's not equal to the previous index. Watchdog compares the current and previous queue index to judge if the queue hung. 2. Make sure hung_{rx,tx} 'true' status won't be override by the normal queue. Any queue hangs should trigger a reset action. 3. Clear the watchdog counter of all queues before resetting the hardware. This change may help to avoid the reset loop. 4. Change hang check function return type to bool as we only need to return two status, yes or no. Signed-off-by: Shiji Yang Acked-by: Stanislaw Gruszka --- drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c index e65cc00fa..d39d87827 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c @@ -1236,13 +1236,14 @@ void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev) } EXPORT_SYMBOL_GPL(rt2800_txdone_nostatus); -static int rt2800_check_hung(struct data_queue *queue) +static bool rt2800_check_hung(struct data_queue *queue) { unsigned int cur_idx = rt2800_drv_get_dma_done(queue); - if (queue->wd_idx != cur_idx) + if (queue->wd_idx != cur_idx) { + queue->wd_idx = cur_idx; queue->wd_count = 0; - else + } else queue->wd_count++; return queue->wd_count > 16; @@ -1279,7 +1280,7 @@ void rt2800_watchdog(struct rt2x00_dev *rt2x00dev) case QID_MGMT: if (rt2x00queue_empty(queue)) continue; - hung_tx = rt2800_check_hung(queue); + hung_tx = hung_tx || rt2800_check_hung(queue); break; case QID_RX: /* For station mode we should reactive at least @@ -1288,7 +1289,7 @@ void rt2800_watchdog(struct rt2x00_dev *rt2x00dev) */ if (rt2x00dev->intf_sta_count == 0) continue; - hung_rx = rt2800_check_hung(queue); + hung_rx = hung_rx || rt2800_check_hung(queue); break; default: break; @@ -1301,8 +1302,12 @@ void rt2800_watchdog(struct rt2x00_dev *rt2x00dev) if (hung_rx) rt2x00_warn(rt2x00dev, "Watchdog RX hung detected\n"); - if (hung_tx || hung_rx) + if (hung_tx || hung_rx) { + queue_for_each(rt2x00dev, queue) + queue->wd_count = 0; + ieee80211_restart_hw(rt2x00dev->hw); + } } EXPORT_SYMBOL_GPL(rt2800_watchdog);