Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2522906rbb; Wed, 28 Feb 2024 04:45:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX5RVi87ECRgQf+s3NWCr4nieyhxUG/7wb8IXXls74uX8z0M2TGrmdCcVHaMwA6axRL2g6XFLlVmJsWWWrp9d6PSh9QiDq9prJS+N1KCw== X-Google-Smtp-Source: AGHT+IH+VxlFpWVoq5PKeO3N3zG7zwykYwAcMmbEicVZRAa489V9vJ+0tyiiZEeDwQWpvf6B/e3U X-Received: by 2002:a05:6214:f29:b0:690:4d7:f5a2 with SMTP id iw9-20020a0562140f2900b0069004d7f5a2mr7269150qvb.1.1709124338881; Wed, 28 Feb 2024 04:45:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709124338; cv=pass; d=google.com; s=arc-20160816; b=DV7YeR+QmI7niQe6eVMT4PRN3Bzlsb9WSPRZ8ZHAdZRCUZ4Whb0VFGrmYoXtMfGhzj dfodZetk3hJnPj5oBeO3CRrbu+2UQk/MEVf/+gQMKAMAijbmXI3Kx/QGfNC2G9VC1Qo6 H99p36zLIvOjMBh99o4aCYLEEnjCWGE2HAki9obZ2q2oCByTLP2pqeLq28/zm5xByfUI 6prEjV37q1400bVZvH3S6/UNdcFH62JU57CIGVMlaO0eoCZvy2iX/gRTfJxHh3DI/Xs4 7Vu1rf9laV58/kiAghiwZ9aPPTiS//DdTl8aEqaBrnyN+ok+/Ypajs/8B3Wfq1R4Is/k jhPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=q1wVoErtw0+3zIMhqOnBtKcfiAuKOY1TgJL/Q0VPUGY=; fh=NxilBuiqz+2U7sXeqs9J6pTxX3FVKueJylk5PSevRpk=; b=NxpITassazjiusi8IW+0Lje2S9ZiTSE9ZfvVLgGVQUenbngCJ7Opu2s8Ke/NBv021A 06wtaNRU03PPzpyFjlwLDq4fLiANns8b3VZzPLbfOw5R3ZdPsi/DN/1vsz/HDOzLuuT/ WX/iWJywlHrR3C2spx9v+3wilRLHn5QkatxF4aWPpn6NCXarFQ+jn8vkq+8jEqVjniJm U+BY07zyvcNrnHyYA+zxlFA8kxRz9UQtisjLM5eYb6d8DjwZUL3o3mRNFvFLF6112d6M q21w0OT8MRYHP5XlleFnKIPQNz05WrT68sSJWWHw+7FPXVBczZZFzPzo4o/rZ39t+iWa 8xpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-85030-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85030-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h11-20020a0562140dab00b0067f3acb6c6asi9618024qvh.113.2024.02.28.04.45.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 04:45:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85030-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-85030-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85030-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7F5691C22E56 for ; Wed, 28 Feb 2024 12:45:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C95A31474D8; Wed, 28 Feb 2024 12:45:29 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 A679373522 for ; Wed, 28 Feb 2024 12:45:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709124329; cv=none; b=A5XnZttXIqt8FoKupcLVFmgXF5JitSUkdJtkmTtV+zyxdCcdniJtXzx80kqAAyBhxF8Qpq6zA8Hj3Fk9Vn7v9qO7L6Qei49UtfCziPskCmLYE1e1qv0M8MFR042nn+PcBefYAXqsu6EKTZDVEoXq36qgkWQODpXphrpTiKDN9Ps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709124329; c=relaxed/simple; bh=Mkz/kA06QlphSdZWuuxe94smsSodU8c3TnRldfFWMiQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Fc93TVuRbCMLfRfTijZET/WUiIff9XqpLmHk29HBM2NWydOUmV41pOHuVIL/JukZMglhFiuwjPMr8PCNjrUTbBjVj157lZBqnENxg0ZXJqfI70kMTKov35AqbMprG+mUtABP6dpvD+tA9+SxoFEPb8lXKtLqMvDkQkKiLvIdK/Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rfJJH-0001mR-J0; Wed, 28 Feb 2024 13:45:19 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rfJJG-003Ocn-Ca; Wed, 28 Feb 2024 13:45:18 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rfJJG-0078tb-13; Wed, 28 Feb 2024 13:45:18 +0100 From: Oleksij Rempel To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Woojung Huh Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com Subject: [PATCH net v1 1/1] net: lan78xx: fix runtime PM count underflow on link stop Date: Wed, 28 Feb 2024 13:45:17 +0100 Message-Id: <20240228124517.1702476-1-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org 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 --- drivers/net/usb/lan78xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } -- 2.39.2