diff mbox series

[net,v1,1/1] net: lan78xx: fix runtime PM count underflow on link stop

Message ID 20240228124517.1702476-1-o.rempel@pengutronix.de (mailing list archive)
State Accepted
Commit 1eecc7ab82c42133b748e1895275942a054a7f67
Delegated to: Netdev Maintainers
Headers show
Series [net,v1,1/1] net: lan78xx: fix runtime PM count underflow on link stop | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 958 this patch: 958
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: linux-usb@vger.kernel.org
netdev/build_clang success Errors and warnings before: 973 this patch: 973
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 975 this patch: 975
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-29--21-00 (tests: 885)

Commit Message

Oleksij Rempel Feb. 28, 2024, 12:45 p.m. UTC
Current driver has some asymmetry in the runtime PM calls. On lan78xx_open()
it will call usb_autopm_get() and unconditionally usb_autopm_put(). And
on lan78xx_stop() it will call only usb_autopm_put(). So far, it was
working only because this driver do not activate autosuspend by default,
so it was visible only by warning "Runtime PM usage count underflow!".

Since, with current driver, we can't use runtime PM with active link,
execute lan78xx_open()->usb_autopm_put() only in error case. Otherwise,
keep ref counting high as long as interface is open.

Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/usb/lan78xx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jiri Pirko Feb. 28, 2024, 1:18 p.m. UTC | #1
Wed, Feb 28, 2024 at 01:45:17PM CET, o.rempel@pengutronix.de wrote:
>Current driver has some asymmetry in the runtime PM calls. On lan78xx_open()
>it will call usb_autopm_get() and unconditionally usb_autopm_put(). And
>on lan78xx_stop() it will call only usb_autopm_put(). So far, it was
>working only because this driver do not activate autosuspend by default,
>so it was visible only by warning "Runtime PM usage count underflow!".
>
>Since, with current driver, we can't use runtime PM with active link,
>execute lan78xx_open()->usb_autopm_put() only in error case. Otherwise,
>keep ref counting high as long as interface is open.
>
>Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
>Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>
patchwork-bot+netdevbpf@kernel.org March 1, 2024, 8:40 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Wed, 28 Feb 2024 13:45:17 +0100 you wrote:
> Current driver has some asymmetry in the runtime PM calls. On lan78xx_open()
> it will call usb_autopm_get() and unconditionally usb_autopm_put(). And
> on lan78xx_stop() it will call only usb_autopm_put(). So far, it was
> working only because this driver do not activate autosuspend by default,
> so it was visible only by warning "Runtime PM usage count underflow!".
> 
> Since, with current driver, we can't use runtime PM with active link,
> execute lan78xx_open()->usb_autopm_put() only in error case. Otherwise,
> keep ref counting high as long as interface is open.
> 
> [...]

Here is the summary with links:
  - [net,v1,1/1] net: lan78xx: fix runtime PM count underflow on link stop
    https://git.kernel.org/netdev/net/c/1eecc7ab82c4

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 3ff430198512..80ee4fcdfb36 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -3135,7 +3135,8 @@  static int lan78xx_open(struct net_device *net)
 done:
 	mutex_unlock(&dev->dev_mutex);
 
-	usb_autopm_put_interface(dev->intf);
+	if (ret < 0)
+		usb_autopm_put_interface(dev->intf);
 
 	return ret;
 }