From patchwork Wed Apr 2 00:45:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Bauer X-Patchwork-Id: 877907 Received: from mailgate01.uberspace.is (mailgate01.uberspace.is [95.143.172.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 829B5B661 for ; Wed, 2 Apr 2025 00:55:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.143.172.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743555316; cv=none; b=UMxSqPbRrLitUh9R0b5b+BSQSchTNjswdDoza7eJOlWNUV/dKSjpVHEIRL5O1H6CHIWfqnx+PpybS6kyCjr+Xq/7LWAEtjxFFerwcyQwYRoB/FILrmWA+yhI81LbDx72s2EHaTFFwgIL/AaX7cMhKVaIBhdzyvXaX75bq7qYtCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743555316; c=relaxed/simple; bh=o0+jC5T0IbMLQejhPVGo1EXsWLgoRdQKJfBR4m13l28=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FTGMHsSgqKD8IpoRlhFEZgC1+tX7TLdzm2OHhuqCWr6KwavOGsYyM8xC3LiEG1v0/ihuuM7K3PEn8dXPbPNdT/58tDATu+rMsOGY6oFUAQatqQhdcHLTf/msvhNj3COTqr5zC53+RgRJF4x5TiOFfhg4MkG3Ks5m3p5ruZQeCSA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=david-bauer.net; spf=pass smtp.mailfrom=david-bauer.net; dkim=pass (4096-bit key) header.d=david-bauer.net header.i=@david-bauer.net header.b=OpGqdC4W; arc=none smtp.client-ip=95.143.172.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=david-bauer.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=david-bauer.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=david-bauer.net header.i=@david-bauer.net header.b="OpGqdC4W" Received: from perseus.uberspace.de (perseus.uberspace.de [95.143.172.134]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 42B32609EC for ; Wed, 2 Apr 2025 02:46:22 +0200 (CEST) Received: (qmail 23164 invoked by uid 988); 2 Apr 2025 00:46:22 -0000 Authentication-Results: perseus.uberspace.de; auth=pass (plain) Received: from unknown (HELO unkown) (::1) by perseus.uberspace.de (Haraka/3.0.1) with ESMTPSA; Wed, 02 Apr 2025 02:46:21 +0200 From: David Bauer To: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH 1/3] mt7915: mcu: lower default timeout Date: Wed, 2 Apr 2025 02:45:25 +0200 Message-ID: <20250402004528.1036715-1-mail@david-bauer.net> X-Mailer: git-send-email 2.47.2 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Bar: / X-Rspamd-Report: SUSPICIOUS_RECIPS(1.5) BAYES_HAM(-2.999999) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -0.099999 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=david-bauer.net; s=uberspace; h=from:to:cc:subject:date; bh=o0+jC5T0IbMLQejhPVGo1EXsWLgoRdQKJfBR4m13l28=; b=OpGqdC4W5ncDvQo4pt/v3IzaB2oV6KRY2hoD8pZXVBtby0ahijnFpy/vpf+yX+YQXjsdm66KtF dHmteresF3/GQVMSquiuhBnL+gPayZMCxXCUtqwb2MKywYZ6YHa9pXaijLjY02tY34WvXpYeM5BT cOP/BOQQAmUsC6WzP6tOdET3NRaMLYeL6HWV7NDWtC5uZtlT54zxEPeiJNq/1xaYRzPuZCaNU/x2 MwSk4zeBQn0WVUtVIqG3XzMK52kR7TtehMGfHduYR+7d5wvja812NOkJ+tl48/Y6SoI/TT5zobpw JcR+bebkwbpytcX7Lq0XTrf5ymEs6nVLg+yaxVrTywTpjHBY6FWwn4tSBQNVq+Og+S8cLmRWBSNH GG+VcVQtGYjrSEX2Y8HvN+xVyrLqZ3g2hfnDcKufHcPWBQUqxhXpL+u9BeQ2eeRsfnDaHI2x8Daz dNYHOTxG3pOGx4AjjWxTeQwqk4AVFAPSWF5hqS4wusHoj4fY1ALqbwRq5zSJQgG8ZGcA7Um/mTeS Ah0/4zwnzbAfxyOK9o1fofoJXvI+CMzwRaex/q0ysefMUtY1k7l/fuMvC2bsURfClq88edPq7FYv RrsX4Q33ia9RFapToaXaH3TRUMKhlQH4Q4bwXeG0NCM6OKsjbLtkNySdW/9jimEPMyWcQMQ3EXTt 8= The default timeout set in mt76_connac2_mcu_fill_message of 20 seconds leads to excessive stalling in case messages are lost. Testing showed that a smaller timeout of 5 seconds is sufficient in normal operation. Signed-off-by: David Bauer --- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index 3643c72bb68d..c1c5afed571f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -197,6 +197,8 @@ mt7915_mcu_parse_response(struct mt76_dev *mdev, int cmd, static void mt7915_mcu_set_timeout(struct mt76_dev *mdev, int cmd) { + mdev->mcu.timeout = 5 * HZ; + if ((cmd & __MCU_CMD_FIELD_ID) != MCU_CMD_EXT_CID) return; From patchwork Wed Apr 2 00:45:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Bauer X-Patchwork-Id: 878186 Received: from mailgate01.uberspace.is (mailgate01.uberspace.is [95.143.172.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EB4C1853 for ; Wed, 2 Apr 2025 00:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.143.172.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743555315; cv=none; b=VYS+1r9pjWZJRgeOYNfNOy58+hSs2Huvon2K9b3IJicFDrNAx3/r72WCFP88t7/doq2zQG1W9jtPYlCwWYWruZ4pq0RCuKZ+ruM8AMz9OKxurNlSevddoElewp1YJGxX50pw5CXtEkj2fLupuYoew9KNetONihLynvEnHOITpAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743555315; c=relaxed/simple; bh=vcbb/N719SqerjnEgmY492MYanRbJNvTR7pgs9UQi2g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iQ/grpZUJ5lV3l/M8biSDeCDkdhGWI4rgrIQsUF13tXscuY+2hu6mVOzmrmyb/VGzq7DYtz88HNvtQ7IAz0j2GMfW1oi+VSlwz6ybxSefZZTQqXbWXLgrlD4YvXz3OLlBAR8u/F/ibG1h+59iG5eKBSDSkSrtq3ADDt3OeI7pkQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=david-bauer.net; spf=pass smtp.mailfrom=david-bauer.net; dkim=pass (4096-bit key) header.d=david-bauer.net header.i=@david-bauer.net header.b=xY361tET; arc=none smtp.client-ip=95.143.172.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=david-bauer.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=david-bauer.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=david-bauer.net header.i=@david-bauer.net header.b="xY361tET" Received: from perseus.uberspace.de (perseus.uberspace.de [95.143.172.134]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 1C53160A06 for ; Wed, 2 Apr 2025 02:46:23 +0200 (CEST) Received: (qmail 23180 invoked by uid 988); 2 Apr 2025 00:46:23 -0000 Authentication-Results: perseus.uberspace.de; auth=pass (plain) Received: from unknown (HELO unkown) (::1) by perseus.uberspace.de (Haraka/3.0.1) with ESMTPSA; Wed, 02 Apr 2025 02:46:22 +0200 From: David Bauer To: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH 2/3] mt7915: mcu: increase command timeout Date: Wed, 2 Apr 2025 02:45:26 +0200 Message-ID: <20250402004528.1036715-2-mail@david-bauer.net> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250402004528.1036715-1-mail@david-bauer.net> References: <20250402004528.1036715-1-mail@david-bauer.net> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Bar: / X-Rspamd-Report: SUSPICIOUS_RECIPS(1.5) BAYES_HAM(-3) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=david-bauer.net; s=uberspace; h=from:to:cc:subject:date; bh=vcbb/N719SqerjnEgmY492MYanRbJNvTR7pgs9UQi2g=; b=xY361tET6zI12Oo5cMJrqCzaecMWF2wZfEmGKrdaOiWA8pN9bBNW+E/WtSlYfWcFnfL0U/Dcjc 82GaoEQnAgqrDaheMTPlOfAQDeomqdZ0bOieFeWmb5h0gECxR+XWDZ3j18cq1QaCOhrcBy6mb8O2 ZpJ7/7CjAhb8qeuOBB2BJ1Mi5aWmrVJFO/HbIWbBcxbQ3uyAccltFSBBOJoIYcbKeaCTIyR+jRL7 YJ8hhVzgmy+BXshHqgTyAYBmU0Er3bniumqQ6aak6TNJWUdmoXncgDdf6ttFr+6wp1h+a/DdI/zT JBtmFU5H2XMEBiqBt03RTZ96XYYOsyOjwxbbe8iXs25Ff9aFeMkote9NxIwSjoCymmx9/27oCJXy dJF6dnRZT3fsEOdVleSI/XR8kyC8I/WBqGk+DOUjesS5lVYrgRhlZ6rw6ASpo9G4JUF2Ha9ZFWIW OtIUFikYak9Q6tj1RL9cfcem+/+Ka0+/NOjdv8t9ekhLZKNaxg9V2Vw8SnZ5cC7lo6NnQXHu2joN Wbe8/Elp/yi4sqTtXiZHhNmovvmSQZ8DJ01p3IPG0oUpItV/hMQ7TY7O6vjmmQWLslkgJ97Sz9v6 OM06VRh5E/UhzSR2VO4cwZLF9aj2tML4p70zeb3FbawG41p+rCUO/5ELJWZA7wda9u+SpfyQze1G c= Increase the timeout for MCU_EXT_CMD_EFUSE_BUFFER_MODE command. Regular retries upon hardware-recovery have been observed. Increasing the timeout slightly remedies this problem. Signed-off-by: David Bauer --- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index c1c5afed571f..d93a72d0a78a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -210,6 +210,9 @@ mt7915_mcu_set_timeout(struct mt76_dev *mdev, int cmd) case MCU_EXT_CMD_BSS_INFO_UPDATE: mdev->mcu.timeout = 2 * HZ; return; + case MCU_EXT_CMD_EFUSE_BUFFER_MODE: + mdev->mcu.timeout = 10 * HZ; + return; default: break; } From patchwork Wed Apr 2 00:45:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Bauer X-Patchwork-Id: 877908 Received: from mailgate01.uberspace.is (mailgate01.uberspace.is [95.143.172.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EB852F2F for ; Wed, 2 Apr 2025 00:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.143.172.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743555315; cv=none; b=b7Ui+uvl9YsHGAt+edyVgRzqO+F4GNWEM1hH/D/8Tj+ZMAbCZc+lF4eWPkgjqvYlASw93Wdth8+By2w+NChNyafTbgIU49I52wgDeDRMClaigAhKN7SCbk7xsVNah5CEpJHH35TSLjfN4msdTuq1zTVRALDNMO7iTWbwaARXxDA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743555315; c=relaxed/simple; bh=ZDX/F/uaex4ndiB551575kE2oTtysLodPUsWsi6X8BQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GEkZAN9Qvzj5IG23UT6CDwLrcOMcHDTfH9p/9iR8QlN3NdhaE2ko2Y6ifbYSqtE/XQJBZ5URZTqr3LgtYiGwLpeALo4qZRyPYJBitxoopbEDD4xuG3QJC6X9ADf3jYBwoJ5rvjYKDq57rMPNOliBKXdWkP9OOam2uqT4gEH7Oq4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=david-bauer.net; spf=pass smtp.mailfrom=david-bauer.net; dkim=pass (4096-bit key) header.d=david-bauer.net header.i=@david-bauer.net header.b=Ycc4JtKw; arc=none smtp.client-ip=95.143.172.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=david-bauer.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=david-bauer.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=david-bauer.net header.i=@david-bauer.net header.b="Ycc4JtKw" Received: from perseus.uberspace.de (perseus.uberspace.de [95.143.172.134]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 1705060A43 for ; Wed, 2 Apr 2025 02:46:24 +0200 (CEST) Received: (qmail 23192 invoked by uid 988); 2 Apr 2025 00:46:23 -0000 Authentication-Results: perseus.uberspace.de; auth=pass (plain) Received: from unknown (HELO unkown) (::1) by perseus.uberspace.de (Haraka/3.0.1) with ESMTPSA; Wed, 02 Apr 2025 02:46:23 +0200 From: David Bauer To: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH 3/3] mt7915: mcu: re-init MCU before loading FW patch Date: Wed, 2 Apr 2025 02:45:27 +0200 Message-ID: <20250402004528.1036715-3-mail@david-bauer.net> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250402004528.1036715-1-mail@david-bauer.net> References: <20250402004528.1036715-1-mail@david-bauer.net> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Bar: / X-Rspamd-Report: SUSPICIOUS_RECIPS(1.5) BAYES_HAM(-2.999999) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -0.099999 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=david-bauer.net; s=uberspace; h=from:to:cc:subject:date; bh=ZDX/F/uaex4ndiB551575kE2oTtysLodPUsWsi6X8BQ=; b=Ycc4JtKw/MQH+qC74VcmTdBWEb/Kw9qqatf42KdbSJM79kDfAr51QTqkK0mA/AdZnwy2rvV+r6 Kqrvl7AE1fDHgDP32FkpUdwQbTOCmQt0Hj8A8sK+31WXUnBNJBHG6nZwGq6LqGwZeIhbflsD18J/ HvHCrVLcniISeJPI2P6BNx8VmR+TakIaNQZbEBp+K6YM1LoaPj2UtM4J/GpQq5CVj2WFuZFnFb2Y gCQLIgjZKCitFR8Sr8EyERX/F+lAao2SOzDMHKLBdOD9vVUrSO52cr0e6oh5ndbXA2+1wpTIMfVB phmA3c9vUlHOsXdIHHLdBkcSBk51QjeX4StnEpyQBsAau02Ep4yse6g4TLgIKM5MKD4wcGk9EnHP p9n+9tyb5pH6sUhPKoWChxdK/JFiOvwSVYPaSPJn3n0/jDJ8dAjfmdmgsQnrBLdaM0eMUXYR0A8z zkx+LmUQ+bBWH5v2t/b6wHsvMnd5y7VQDqJq1tslqzyctmLRqc7/A8m/QN492a4i4swpVURHXoRP nYID2YffFTsONxXmEFxZhPR0frZR7zrOqVDPs93FspR+mtRqospCOPisja59xVBPao2t3RcI22vA gp3AfwpBd3RtEtZwby7trfO1UvQyMZodd8LozqkcaMG537T+DPYBcePw9O1h5P/ueksKot4pesJ2 o= Restart the MCU and release the patch semaphore before loading the MCU patch firmware from the host. This fixes failures upon error recovery in case the semaphore was previously taken and never released by the host. This happens from time to time upon triggering a full-chip error recovery. Under this circumstance, the hardware restart fails and the radio is rendered inoperational. Signed-off-by: David Bauer --- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index d93a72d0a78a..41eba991acef 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -2097,16 +2097,21 @@ static int mt7915_load_firmware(struct mt7915_dev *dev) { int ret; - /* make sure fw is download state */ - if (mt7915_firmware_state(dev, false)) { - /* restart firmware once */ - mt76_connac_mcu_restart(&dev->mt76); - ret = mt7915_firmware_state(dev, false); - if (ret) { - dev_err(dev->mt76.dev, - "Firmware is not ready for download\n"); - return ret; - } + /* Release Semaphore if taken by previous failed attempt */ + ret = mt76_connac_mcu_patch_sem_ctrl(&dev->mt76, false); + if (ret != PATCH_REL_SEM_SUCCESS) { + dev_err(dev->mt76.dev, "Could not release semaphore\n"); + /* Continue anyways */ + } + + /* Always restart MCU firmware */ + mt76_connac_mcu_restart(&dev->mt76); + + /* Check if MCU is ready */ + ret = mt7915_firmware_state(dev, false); + if (ret) { + dev_err(dev->mt76.dev, "Firmware did not enter download state\n"); + return ret; } ret = mt76_connac2_load_patch(&dev->mt76, fw_name_var(dev, ROM_PATCH));