From patchwork Mon Jan 27 19:48:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soeren Moch X-Patchwork-Id: 860611 Received: from mout.web.de (mout.web.de [212.227.17.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50C77189F43; Mon, 27 Jan 2025 19:48:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738007338; cv=none; b=mQJpajz85KBcYNrLWzsqYY4n+3JPJ9h8veLjzTwJuaPGRh9nHFrxl01knAdoI8L4c+Y7FdKzUsqpyD8aAtcX4EmZqNScjGqadYU/ZliXz00TA6Qj7zHSe18JKH5L3uawWf0fZMZSFCY5M/QvCT2aBce+b4veBpp3WJmX7JWKz3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738007338; c=relaxed/simple; bh=ro6QN2mJ13LgUk7K+2HpgHyalFgS7tQjN+1OfPnc9q4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TB5uFnNCVI6kFGgObxyUj5NjeTCdcJL5Qq/49AzyBATVT+mPst8oJFdEL947ZhBd+FvCBItDJ/d95DCCdougCNT/JSieF/9aDmKFZSAbKSNoGaXBldxblmedBMVYMpAzXakB9LWq0pChrOD0Xv3UsCaq7Y2vKffeJXl8hIRS83U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=smoch@web.de header.b=g9poIM1a; arc=none smtp.client-ip=212.227.17.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=smoch@web.de header.b="g9poIM1a" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1738007327; x=1738612127; i=smoch@web.de; bh=SN7Hax3V7meZCCQdThMA9BV5EAHTRutl1/qaATTXcRk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID: MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=g9poIM1aVUqXFOlLK7oXNMeyeMWcPXvnGCBLzqBaOIAi9UmYn/z/xbNpk6w65VEI cGuQG8gl5wgvqIdSj7oZXlDAzXPRQEId7Xfp1l+JfVRh3qfxV2p/HYc7eJs8CtDoQ w92fZap+NKdcROVKiyh6j69hF3QJA64U/ONF7TAuCnJe3q55OUtVwFAZaieC9SK5S R51swjpBksSARBJXKGg3ULw4PXXGPxGqW2pVgjMf7M9gfF2e4KMbZ9pFOF3Z6+fiK MzecIV4fed1TogJ2NsNTEJigyWvjRJ7cfFOYBgk1cxOn5JJnad3twina6mGsOaxHE ngrAnJQHXzpMnDG+Dg== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from x1 ([109.40.243.154]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1M2Phc-1td3rM2scI-005wcu; Mon, 27 Jan 2025 20:48:46 +0100 From: Soeren Moch To: Kalle Valo Cc: Soeren Moch , Jes Sorensen , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Ping-Ke Shih Subject: [PATCH v2] wifi: rtl8xxxu: retry firmware download on error Date: Mon, 27 Jan 2025 20:48:28 +0100 Message-ID: <20250127194828.599379-1-smoch@web.de> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: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FmS9sS8whOF8mw2WqmUqKcpQ5JcxRIzz7EUL/ZioD9o4vrR79s6 14Ve2dPBVQr3maaVCfGzltk6P9AT8vlIic0h5NhoOhMy1I9Pob9WsIZfmmg+i18otsYX/o7Ng gWK9Trm7qL7RJVkbrtzAYyNCrhggBBdmTACSIZpzLXtbjpYeoAI1YFrw74kaZ0qeArjBA0otM lMxShimW7XekCi0StGdu1cymN/mtorRig7gABYRBAp+K+xExCQ6uE4xFT9uJxmYi27/3EA4xn D+O2ifGma2o3+av8Cx/3ABzl+F/R50kyN2N+IymWmh/+xPHR8DeN4yzLivIg/qxRUXVFtgwl4 38B+5oRwhDmu2gNVs4P2kh2md8dhz8UZvjbqDxcHDV2gUTndic9twdAOyOrTFoDu5GeqN3rXg 7DtmK0QGshtheVJIVPNlGpWi9AZIpi80Yu2mvPCV4wimgnIbFwBtPnA7WYgRv11Ri3v7LRVdk yn4D8Swq3arv1EQYaLXEPPdxKo4vcNUhHyDXL9vQNvUTbEWFnTYQ5Wh/6YgtkaIYu7rPj3PB4 PmZz4m5IroR8Wj7ACuqtzdQkg== Occasionally there is an EPROTO error during firmware download. This error is converted to EAGAIN in the download function. But nobody tries again and so device probe fails. Implement download retry to fix this. This error was observed (and fix tested) on a tbs2910 board [1] with an embedded RTL8188EU (0bda:8179) device behind a USB hub. [1] arch/arm/boot/dts/nxp/imx/imx6q-tbs2910.dts Signed-off-by: Soeren Moch --- Cc: Jes Sorensen Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Ping-Ke Shih Changes in v2: - mention related device in formal commit message - fix loop iterations - adapt download retry message to common style including function name - hide firmware write error and retry messages behind debug settings, according to feedback by Ping-Ke Shih --- drivers/net/wireless/realtek/rtl8xxxu/core.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) -- 2.43.0 diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c b/drivers/net/wireless/realtek/rtl8xxxu/core.c index 7891c988dd5f..9008c619d833 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/core.c @@ -860,9 +860,10 @@ rtl8xxxu_writeN(struct rtl8xxxu_priv *priv, u16 addr, u8 *buf, u16 len) return len; write_error: - dev_info(&udev->dev, - "%s: Failed to write block at addr: %04x size: %04x\n", - __func__, addr, blocksize); + if (rtl8xxxu_debug & RTL8XXXU_DEBUG_REG_WRITE) + dev_info(&udev->dev, + "%s: Failed to write block at addr: %04x size: %04x\n", + __func__, addr, blocksize); return -EAGAIN; } @@ -4064,8 +4065,14 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw) */ rtl8xxxu_write16(priv, REG_TRXFF_BNDY + 2, fops->trxff_boundary); - ret = rtl8xxxu_download_firmware(priv); - dev_dbg(dev, "%s: download_firmware %i\n", __func__, ret); + for (int retry = 5; retry >= 0 ; retry--) { + ret = rtl8xxxu_download_firmware(priv); + dev_dbg(dev, "%s: download_firmware %i\n", __func__, ret); + if (ret != -EAGAIN) + break; + if (retry) + dev_dbg(dev, "%s: retry firmware download\n", __func__); + } if (ret) goto exit; ret = rtl8xxxu_start_firmware(priv);