Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796106751; b=I8PXA786atcRNmFOJc9HHsEcNyHCc26L8WIrPMqeJlTarwCn1PGzRvVKa+LCB6YWdeKU pwdjyMz8qc50mRpZHAf6WikFNFdj06jcyX9Ihc0OkuwkCP00bfBI2uZmJ8OgYYIsLb/zZ xt1md9PYLaHZlfnVsebliEYb7QzIfYhsvf97nO0aC2wJ4a0Yyc+NPBPx69RxEmD8g52n4 e9sqL28Ood6dRbrz8uiM1zepGO7ffUc8Ac6ODLC/0kozmMA9v+khsoL2GjqTM1zEVBJTH 3JQu1WOPZEDE1o7iDQRSmeZGkkTyljLHFsOXw5kQp7Yv68KOyAlUvbhstT3I8yMQ9hA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796106751; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=jf0EGZpBdB37mYwN5LOyfW1JmkqL/X+xQJmVUs8qS6g=; b=1HavtToLWfXliFuBiOxv4KeEOmzuFm+Vwv15U8EVJs/4hPQOeJYiKsmYFJ5zRlD6URKW +xIGYqJOMSVuqdf84B5QdACCuUDd8eIvcvmavoxx1UV2PxcmnDEyLOHQt7Nu90zyk7YSg s1zcCRQ3IOq1g7TyJ54sl1PoShsoUgBGSuA8iw446XB+/zkMfxeFrBZm60gvuhK5jGMBb 2VvVEArFdlVyMzsdHIf64NONTJrPdjUlTtxJqEfzcJwAO92ZUdHcWAfY/ZCvZoj9g0Yg3 PBjIXDNbOEXkMdFVlsAkLN9426yCk206d0rtvPY9YG6GFIjJOMPR1YOWHLoJPSPDLWg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="no/oPXiw"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07CD2606A32D for ; Tue, 1 Dec 2026 06:32:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=no/oPXiw Received: by smtp.kernel.org (Postfix) with ESMTPSA id 919101F00898; Tue, 1 Dec 2026 06:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796106750; bh=jf0EGZpBdB37mYwN5LOyfW1JmkqL/X+xQJmVUs8qS6g=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=no/oPXiwb6DR/Z91hUaNj0ix6kc+ZdjrEGwMdk77v7KB4x4eth4m8gI/SZty7uhFN zzxyfRO+H2MbJtrx+aPb0w/t0a4FmuE6NPF79trSyjgIrGWfYB+fJP9zEppZhkVFqU 9h9SCKR8ggQvqntXPFeNe7pp83sA7XrwWcG0eGqmLO892rDPfzo27nKytJH0YnJT0q eyq+XXHzPcyOfInkM7YS0bK4GD3ZlybDnXuaBnoZAgg0o7ZMtL7/gcIu2i12sHmfTC 9yeX3w7wb8S7ZSmQHzZuQo7Ft8EG66Lu59h9HhN1mAg4IrcPM/EJbAbsFz24CykJPA T6Jd2RYcu+2nQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next v10 12/12] r8152: enable UPS for RTL8157 and RTL8159 QFN68 Reply-To: sashiko-reviews@lists.linux.dev To: "Chih Kai Hsu" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261130063123.2408-13-nic_swsd@realtek.com> References: <20261130063123.2408-1-nic_swsd@realtek.com> <20261130063123.2408-13-nic_swsd@realtek.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 06:32:30 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] r8152: PCUT_STATUS cleared before r8157_ups_en(tp, false) in r8157_init() - [Medium] r8152: PLA registers accessed before r8157_ups_en() on runtime resume - [Medium] r8152: unrecoverable RTL8152_INACCESSIBLE latch in r8157_ups_en() -- commit c10e0bfa00a1dd7f7d30bc58798ee583928fdb60 Author: Chih Kai Hsu r8152: enable UPS for RTL8157 and RTL8159 QFN68 This commit adds r8157_ups_en(), updates r8156_ups_flags() with per-speed EEE and speed flags, and enables UPS on runtime suspend and resume for RTL8157 and RTL8159 QFN68. > diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c > index b9586c30c04dd..0fb6dfe4abf56 100644 > --- a/drivers/net/usb/r8152.c > +++ b/drivers/net/usb/r8152.c [ ... ] > @@ -4496,6 +4534,58 @@ static void r8156_ups_en(struct r8152 *tp, bool en= able) > } > } > =20 > +static void r8157_ups_en(struct r8152 *tp, bool enable) > +{ > + u32 ocp_data; > + int ret; > + > + if (enable) { > + r8156_ups_flags(tp); > + > + ocp_byte_set_bits(tp, MCU_TYPE_USB, USB_POWER_CUT, > + UPS_EN | USP_PREWAKE | PHASE2_EN); > + > + ocp_byte_set_bits(tp, MCU_TYPE_USB, USB_MISC_2, > + UPS_FORCE_PWR_DOWN); > + } else { > + ocp_byte_clr_bits(tp, MCU_TYPE_USB, USB_POWER_CUT, > + UPS_EN | USP_PREWAKE); > + > + ocp_byte_clr_bits(tp, MCU_TYPE_USB, USB_MISC_2, > + UPS_FORCE_PWR_DOWN); > + > + ocp_data =3D ocp_read_word(tp, MCU_TYPE_USB, USB_MISC_0); > + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) > + return; > + > + if (ocp_data & PCUT_STATUS) { > + ret =3D read_poll_timeout(ocp_read_word, ocp_data, > + test_bit(RTL8152_INACCESSIBLE, > + &tp->flags) || > + (ocp_data & BACKUP_RESTRORE), > + 200, 20000, false, tp, > + MCU_TYPE_USB, USB_GPHY_CTRL); > + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) > + return; > + > + if (ret) { > + rtl_set_inaccessible(tp); > + dev_err(&tp->intf->dev, > + "backup-restore timed out\n"); > + return; > + } [Severity: Medium] As reported by Jakub Kicinski on v7 [1], can latching RTL8152_INACCESSIBLE here leave the interface permanently unusable after a runtime resume? When read_poll_timeout() times out during rtl8152_runtime_resume() -> rtl8157_runtime_enable(tp, false) -> r8157_ups_en(tp, false), the error is not returned to the PM core and no USB reset is queued, while rtl8152_resume() skips its usb_reset_device() fallback when runtime_resume is true: drivers/net/usb/r8152.c:rtl8152_resume() { ... if (!runtime_resume && test_bit(RTL8152_INACCESSIBLE, &tp->flags)) usb_reset_device(tp->udev); ... } Every subsequent r8152_control_msg() then returns -ENODEV before reaching usb_queue_reset_device(), so nothing clears RTL8152_INACCESSIBLE until the device is replugged or reset externally. > + > + /* clear USB fw_ver_reg */ > + ocp_write_byte(tp, MCU_TYPE_USB, USB_FW_USB_VER, 0); > + > + tp->rtl_ops.hw_phy_cfg(tp); > + > + rtl8152_set_speed(tp, tp->autoneg, tp->speed, > + tp->duplex, tp->advertising); > + } > + } > +} > + > static void r8153_power_cut_en(struct r8152 *tp, bool enable) > { > if (enable) > @@ -4654,9 +4744,28 @@ static void rtl8157_runtime_enable(struct r8152 *t= p, bool enable) > r8153b_u1u2en(tp, false); > r8157_u2p3en(tp, false); > rtl_runtime_suspend_enable(tp, true); > + > + switch (tp->version) { > + case RTL_VER_16: > + case RTL_VER_17_QFN68: > + r8157_ups_en(tp, true); > + break; > + default: > + break; > + } > } else { > r8153_queue_wake(tp, false); > rtl_runtime_suspend_enable(tp, false); > + > + switch (tp->version) { > + case RTL_VER_16: > + case RTL_VER_17_QFN68: > + r8157_ups_en(tp, false); > + break; > + default: > + break; > + } [Severity: Medium] Should r8157_ups_en(tp, false) run before r8153_queue_wake(tp, false) and rtl_runtime_suspend_enable(tp, false), matching rtl8153b_runtime_enable(), rtl8153c_runtime_enable(), and r8157_init()? Calling r8153_queue_wake(tp, false) and rtl_runtime_suspend_enable(tp, false) first accesses MCU_TYPE_PLA registers while UPS is still active and before r8157_ups_en(tp, false) waits for BACKUP_RESTRORE after a power cut, so the writes clearing UPCOMING_RUNTIME_D3 and LINK_OFF_WAKE_EN and restoring tp->saved_wolopts can be ignored or overwritten by the restored suspend-time snapshot. > + > r8157_u2p3en(tp, true); > if (tp->udev->speed >=3D USB_SPEED_SUPER) > r8153b_u1u2en(tp, true); > @@ -9148,7 +9257,7 @@ static void r8157_init(struct r8152 *tp) > ocp_write_word(tp, MCU_TYPE_USB, USB_U1U2_TIMER, 500); > =20 > r8157_power_cut_en(tp, false); > - r8156_ups_en(tp, false); > + r8157_ups_en(tp, false); > r8153_queue_wake(tp, false); > rtl_runtime_suspend_enable(tp, false); [Severity: Medium] Does r8157_power_cut_en(tp, false) clear PCUT_STATUS before r8157_ups_en(tp, false) can check it? drivers/net/usb/r8152.c:r8157_power_cut_en() { ... } else { ocp_word_clr_bits(tp, MCU_TYPE_USB, USB_POWER_CUT, PWR_EN); ocp_word_clr_bits(tp, MCU_TYPE_USB, USB_MISC_0, PCUT_STATUS); ocp_byte_clr_bits(tp, MCU_TYPE_USB, USB_MISC_2, BIT(1)); } } Because PCUT_STATUS in USB_MISC_0 is cleared on the preceding line, the if (ocp_data & PCUT_STATUS) block in r8157_ups_en(tp, false) is never entered from r8157_init(). When re-initializing via r8157_init() after a UPS power cut (such as on rtl8152_reset_resume()), RTL_VER_16 skips waiting for BACKUP_RESTRORE, and neither RTL_VER_16 nor RTL_VER_17_QFN68 clears USB_FW_USB_VER, causing rtl8152_fw_mac_apply() to see the surviving version register and skip reloading the lost USB firmware patch. [1] https://lore.kernel.org/r/20261021005214.1255071-1-kuba@kernel.org --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130063123.2408= -1-nic_swsd@realtek.com?part=3D12