Article View: linux.kernel.netdev
Article #13051Re: [PATCH net] net: spacemit: Hold RTNL lock in emac_resume() and emac_suspend()
From: Vivian Wang
Date: Mon, 09 Nov 2026 07:59
Date: Mon, 09 Nov 2026 07:59
40 lines
10635 bytes
10635 bytes
On 11/8/26 15:19, Troy Mitchell wrote: > On Sat Nov 7, 2026 at 5:32 PM GMT, Andrew Lunn wrote: >> On Fri, Nov 06, 2026 at 03:44:50PM +0500, Ali Tariq wrote: >>> >>> On 11/6/26 2:43 PM, Troy Mitchell wrote: >>>> On Thu, 5 Nov 2026 17:34:37 +0500, Ali Tariq wrote: >>>>> @@ -2056,7 +2059,9 @@ static int emac_suspend(struct device *dev) >>>>> return 0; >>>>> } >>>>> + rtnl_lock(); >>>>> emac_stop(ndev); >>>>> + rtnl_unlock(); >>>>> clk_disable_unprepare(priv->bus_clk); >>>>> netif_device_detach(ndev); >>>> This can deadlock. emac_stop() -> emac_down() calls >>>> cancel_work_sync(&priv->tx_timeout_task) with RTNL now held, while >>>> emac_tx_timeout_task() starts with rtnl_lock(). >>>> >>> Thanks Troy, that makes sense. >>> >>> For the deadlock, I think the correct function to call is rtnl_trylock() >>> inside the emac_tx_timeout_task(), which would return if the lock is already >>> held and will hold the lock if it is not. >> rtnl_trylock() is generally a workaround needed for badly written >> code. Please try to avoid it. > Agreed. If the reset is done in place, the work does not need RTNL at all, > so .ndo_stop can keep cancel_work_sync() as is. > Thanks for the diagnosis and suggestions. Although, maybe we could simply avoid cancel_work_sync() in emac_down()? emac_tx_timeout_task() checks for !netif_running and does nothing if already down so it should be safe. The task cancel_work_sync() in emac_remove() does cleanup on unbind so the task is not leaked. This seems to be the pattern in other drivers as well. What do you think? Vivian "dramforever" Wang
Technical Details
Message-ID:
<ee3f414c-fffa-41e6-8bec-6af7ce676c4b@iscas.ac.cn>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359096-linux-kernel-netdev=dewy.ruReferences:
<20261105123441.2524171-1-alitariq45892@gmail.com> <DMO13SWAGZAN.NYISGLGI7Y5A@linux.spacemit.com> <c55c5878-d9c1-4863-bc55-99d334ba2ede@gmail.com> <12a95b3a-9c8b-4a2d-9b81-12b3839e64a9@lunn.ch> <DMPNAPNEGQ5I.XYUIB7Y8HDCA@linux.spacemit.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359096-linux-kernel-netdev=dewy.ru From: wangruikang@iscas.ac.cn (Vivian Wang) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net: spacemit: Hold RTNL lock in emac_resume() and emac_suspend() Date: Mon, 9 Nov 2026 15:59:07 +0800 Organization: Usenet Network Message-ID: <ee3f414c-fffa-41e6-8bec-6af7ce676c4b@iscas.ac.cn> References: <20261105123441.2524171-1-alitariq45892@gmail.com> <DMO13SWAGZAN.NYISGLGI7Y5A@linux.spacemit.com> <c55c5878-d9c1-4863-bc55-99d334ba2ede@gmail.com> <12a95b3a-9c8b-4a2d-9b81-12b3839e64a9@lunn.ch> <DMPNAPNEGQ5I.XYUIB7Y8HDCA@linux.spacemit.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="302431"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:pNV832MyvcCaNU/FcrV63nxFqp4= sha256:FCTw4ecLk/wwfrT05pW6o/Az4uV6Iu9QTcpEvik5HYk= sha1:zXRW45XZKXMG7w0IA6mm4lAQxwY= sha256:YX1iRx/GT0ep98QxnyoAJmJIJCPdLeziciTKqRMAssU= Content-Language: en-US List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 384E81136E3; Mon, 9 Nov 2026 11:00:05 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -1.851 X-Spam-Status: No, score=-1.851 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HqO6L5PlkX4m; Mon, 9 Nov 2026 10:59:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-359096-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=iscas.ac.cn X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id DAF1111370E; Mon, 9 Nov 2026 10:59:51 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 9A0832A5E6; Mon, 9 Nov 2026 07:59:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1794211177; b=x14Y3wNl1ol56XH/4/yCki0LEtDa9Oig5v61xqa+pK9JJtCXpJYEAhCsEd5RxeUlIPiD xM1MtaVCCgE3sx792Y4xYjxV/LWzAZdOeZyEpbjtc1wry2t8KW2Cf+1w88eZK7UWV+h7a uUI3SZHW3WAvP6iDFm83rCFSAJuuzWPvrM1t9vLfxo2XNHWk2q2U0DSEcGGw6cmxI2CGL 3CaRuFBcMKdPqPPDCvmdBrnukkHSHutNdlARfs+5VrZ0BvqHpvZTRd1LxLCe74aq07tz4 YLrPGKbf50WeGpIZLUtlrmWPBU1I3X5PU5Sb6dFsPVQcKVkrMblLu8/5KLDbvunBmNA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794211177; h=X-Original-To:Received:DMARC-Filter:Received:Message-ID:Date: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=RmF4p74GyJvTjJ+9yiITFE4p7uiV1l6aM7lFScVEBu4=; b=G4D3vL5CfIxKSQSHtnFibghCuSNVlYhqKzIbSSttSrdoJ8ZfeFkiZl6+FdKDR2+jQq5K jxO/HcJQQFr5Iw+wToAammo5uvKsV2HCDMLVyKSctpkfsAj4fz6U9kL9VTT5iodaabyus yqdnp8dIkqGxX6By+SAP5X6r1St8oMX8UKO/7N0NfRWiiuExcDh4H9egB89v2wVa1e4iT JMmMpIv4dsOmSFs3JSacdCYnox9uh6fEfQ9WorfO2y6rME3ekbJjP9NVhw3bB6OdUp14q xoA3+Y70Mcb8Tnn3Uijgc3gQFG2kMxfBepUk6EouG0S5+tbyopmjqLEJ6DRhJNglkng== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=fail smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7CCF7606A335; Mon, 9 Nov 2026 07:59:37 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=159.226.251.21 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794211176; b=4H61ZtDjHMmgUTrK3y0wUCKrjodd7TpngKt+qI/BQu6sg2N0GdWxuX4bdgVFQi0GHPPi jBASCerjYmttrF7saVIEi9U3YJXY9IH23KtDLgbJnR/lokIVV86x51VM8eq/H9vS6WPFQ l5JJ1b0LORElWF4PsLzISrCJ6k2RcAjhd2m6qEogEZ6V1jYXCnDZBZrOResiuFqCUXD2L VB3F6BNRDIRYr0kWvqkmKVN7vVGRcIUhibHc1BPmZQvx8l6tKQ+ABVtV14ML6jqs2Srx7 +PBcEVlMSNKZJDZA6sgZtZmKkm2A1XjUZf2BFPgOKvfHPMZQ/UhCR0XI4oNCBqS78UQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794211176; h=DMARC-Filter:Received:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-Originating-IP:X-CM-SenderInfo; bh=RmF4p74GyJvTjJ+9yiITFE4p7uiV1l6aM7lFScVEBu4=; b=IBnQOkd3xf+c2C9OTVtbhUeYTJQZAcxx9xICx6/HykWYOIv1Z7FXm5XBq9a0KrFCLMoC AQIRjy7iMu6GyP1PS0LDJCS3DtIdyHM6ql+UUycQCd+M40K2aUjbzHUjCPeawC2f5ZXB6 TBCQEhhpK8WJ98Y5hXkBYet1faiENphpCkL2BOs31gW7MiZM7XkUWPwvbAtetzAyrG3AV nCNLSV2Zgw4Yp+8a5wTON9eny453aFw3CtENT246q27ivoxjqJDvqASJVOTGtRafYiUaT fZT6VFqVDIODR0CnIOEkEBIWKIkSNPyDuOla1058nIn42ahn9MpGMncun6bGKkHggFw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.remote-ip=159.226.251.21 X-Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AFE2606A31C; Mon, 9 Nov 2026 07:59:34 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9AFE2606A31C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn X-Received: from [192.168.0.106] (unknown [123.116.51.226]) by APP-01 (Coremail) with SMTP id qwCowACHdf9LffFq0NycAA--.589S2; Mon, 09 Nov 2026 15:59:08 +0800 (CST) X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-User-Agent: Mozilla Thunderbird X-Cc: Vadim Fedorenko <vadim.fedorenko@linux.dev>, netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Yixun Lan <dlan@kernel.org>, Chukun Pan <amadeus@jmu.edu.cn>, Siddharth Vadapalli <s-vadapalli@ti.com>, Tomas Hlavacek <tmshlvck@gmail.com>, Muhammad Bilal <meatuni001@gmail.com>, Maxime Chevallier <maxime.chevallier@bootlin.com>, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, linux-kernel@vger.kernel.org X-In-Reply-To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