From nobody Thu Nov 28 05:51:36 2024 Received: from fhigh-a1-smtp.messagingengine.com (fhigh-a1-smtp.messagingengine.com [103.168.172.152]) (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 E7BF61A7240; Thu, 3 Oct 2024 17:21:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727976073; cv=none; b=iR/VEtyYNCd2yaltTApz2VkoSlNYgFKA8KAgLCMRv6mohbcMA/AGbtD8YfkHsY6Jlc3uGBjl8AoQURnuvnMpre5V+3/fFodQP2iV63u5/5e7Cq4QDp79HhC6MBYSRM2fYEqhNiKvw4lBl25RSb1UT8QOITc/R3eBt1KWTIrVRPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727976073; c=relaxed/simple; bh=zzvhN7MdgZFsCDeGnEYUrpETzhGoAu1pBnN9N/vbcUI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MkATss9rgCPZ4axKNW7E3lqsJ6Zkbolob5K6e8bfngg8/AIHfeCRR/6zqfBrLtuf4trOJkTxBPdY5Bhu/RxwYdQEr/7YaKk8wfqNVjAl+zc1i6ckFvQjMvi5ERSXS/E4Qwt/VzGsPDjxK2v+amgMsCO2LdD/epoav7Jf7c3Uh0Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fluxnic.net; spf=pass smtp.mailfrom=fluxnic.net; dkim=pass (1024-bit key) header.d=fluxnic.net header.i=@fluxnic.net header.b=00NORwoG; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=cOVqByRd; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=jYTvpSeP; arc=none smtp.client-ip=103.168.172.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fluxnic.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fluxnic.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fluxnic.net header.i=@fluxnic.net header.b="00NORwoG"; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="cOVqByRd"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="jYTvpSeP" Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id 1F7E711401EA; Thu, 3 Oct 2024 13:21:10 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-09.internal (MEProxy); Thu, 03 Oct 2024 13:21:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fluxnic.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=2016-12.pbsmtp; t=1727976070; x=1728062470; bh=Grcsh8hKx60b73xxxrMUlXKi0fKzSJUcDrZOp+euGcI=; b= 00NORwoG91iMQBP2nMclEiGNnhLG+JXXMOLghGRiFLvFSf4ahr43PLs8Y7eW0Tuv 4QA7Sh4czVoB5kGrvahpoysXQBtc5OO4Q1dbdEfqsT3wotArIv87LY6FDuoUD3jr 6R7R/lONBj1jp4TlxrsGD3EUo8ZyJiSAR397WeD0c7I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1727976070; x= 1728062470; bh=Grcsh8hKx60b73xxxrMUlXKi0fKzSJUcDrZOp+euGcI=; b=c OVqByRdmbNix2k68BXiGHv4FKzkX6LMMttsGbwiH4akh5/wzweWE//iIhdtuSfW/ jNNYmB+CbYP/1IWyneSmODD8pKGruhYvdu/oh3V+b83TI7wB8NphlfmDBbJlHwm/ nHOsOKflyeRAiYGW7XK9zNEsXGbFOZ2quNnnVXBbVHBd2Jx9weeidDnBsUMuVG7j KdbdC1LlJmeGBYbTjMUrhWl50yLs8hNC9O9xHC0Lym0k3QyEpynKx4Lx2YwbnoiW OKbiFsbjK9Jj5YGDFF4XI/2FQNQjzLdsFIEpveAI4OJpXEbUF84K0J46HOpRMdzP TXsScSt0m2jmELB8xigGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1727976070; x= 1728062470; bh=Grcsh8hKx60b73xxxrMUlXKi0fKzSJUcDrZOp+euGcI=; b=j YTvpSeP3uGuGL9HuWPDWscTZ+vbXUDmnMhpvqAUBMhux/vWuY3dIPcJHWD8z7ZQ0 ai/l8zBgsqs7vcgzaFylV+jD0Wqtrr8h4YAgnhu05ewc7Ug+/85B3v7/O0yOzrPo dyKPG5WWK3tR8Wn+X0IjrmstiEZbDYzEICU9UhdYCERbZG5FA4rmTeKYmZTLCTKN wsov+8/5svxZtDLp9rgK6z5P49RXlON5sNoDTolT2xecgRj/w4r2tuz5atw0RAcq 8nVZ4p0qTOqfnDRQqph6CoEZGN4YW3d3rV71fcE7YFAlZvzESrb+F7+7xi24ecav DWbeqjncOUFYOZRc2ISBw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddvuddgudduvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpefpihgtohhlrghsucfrihhtrhgvuceonhhitghosehflhhugihnihgtrd hnvghtqeenucggtffrrghtthgvrhhnpedtjeeuieeiheeiueffuddvffelheekleegkedu keeffffhudffudegvdetiefhteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehnihgtohesfhhluhignhhitgdrnhgvthdpnhgspghrtghpthht ohephedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepnhhpihhtrhgvsegsrgihlh hisghrvgdrtghomhdprhgtphhtthhopegurghvvghmsegurghvvghmlhhofhhtrdhnvght pdhrtghpthhtohepphgrsggvnhhisehrvgguhhgrthdrtghomhdprhgtphhtthhopehlih hnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehn vghtuggvvhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i58514971:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 3 Oct 2024 13:21:09 -0400 (EDT) Received: from xanadu.lan (OpenWrt.lan [192.168.1.1]) by yoda.fluxnic.net (Postfix) with ESMTPSA id 5529AE3B224; Thu, 3 Oct 2024 13:21:08 -0400 (EDT) From: Nicolas Pitre To: "David S. Miller" , Paolo Abeni Cc: Nicolas Pitre , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v2 1/2] net: ethernet: ti: am65-cpsw: prevent WARN_ON upon module removal Date: Thu, 3 Oct 2024 13:07:12 -0400 Message-ID: <20241003172105.2712027-2-nico@fluxnic.net> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241003172105.2712027-1-nico@fluxnic.net> References: <20241003172105.2712027-1-nico@fluxnic.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nicolas Pitre In am65_cpsw_nuss_remove(), move the call to am65_cpsw_unregister_devlink() after am65_cpsw_nuss_cleanup_ndev() to avoid triggering the WARN_ON(devlink_port->type !=3D DEVLINK_PORT_TYPE_NOTSET) in devl_port_unregister(). Makes it coherent with usage in m65_cpsw_nuss_register_ndevs()'s cleanup path. Signed-off-by: Nicolas Pitre Fixes: 58356eb31d60 ("net: ti: am65-cpsw-nuss: Add devlink support") --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/etherne= t/ti/am65-cpsw-nuss.c index cbe99017cb..f6bc8a4dc6 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -3652,13 +3652,13 @@ static void am65_cpsw_nuss_remove(struct platform_d= evice *pdev) return; } =20 - am65_cpsw_unregister_devlink(common); am65_cpsw_unregister_notifiers(common); =20 /* must unregister ndevs here because DD release_driver routine calls * dma_deconfigure(dev) before devres_release_all(dev) */ am65_cpsw_nuss_cleanup_ndev(common); + am65_cpsw_unregister_devlink(common); am65_cpsw_nuss_phylink_cleanup(common); am65_cpts_release(common->cpts); am65_cpsw_disable_serdes_phy(common); --=20 2.46.1 From nobody Thu Nov 28 05:51:36 2024 Received: from fhigh-a1-smtp.messagingengine.com (fhigh-a1-smtp.messagingengine.com [103.168.172.152]) (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 699721A7046; Thu, 3 Oct 2024 17:21:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727976073; cv=none; b=l7vssW/7NUsXUt9zXNjROu9dW4M4UfMdx6ll7hIRNCdfc2AhgHLNPGKs8KDcTgpJuAPdehllW8QxzAZkr3AmlOqr7XYSJwrPs1jMAqpmksW5UhJIXM6oqEIXKnLEnWqJkb2Sj+dgE+JZ7niiGZV9Ql4SAzKRRmWgGakasfzQjSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727976073; c=relaxed/simple; bh=HbEzXLH/jnP5HGWqMdjFnIPLwuD+a1iwUyOjMCqMxvM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cm2ct9VPqQNNQf6syb0vxMkV+JY1U7RS3mChaBpAee9vozOHnuNx7OjXuORhvjQq9Lg8+t2EJbIKyvIFRZbZFNYVWhnCt3rH9vJPUsloJCd0QwvqvamJq1uZu0zIjkh9Z5x1UDAmc3whjyBkOlOZIhAcnZNUdMbpZOAmBC/2maU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fluxnic.net; spf=pass smtp.mailfrom=fluxnic.net; dkim=pass (1024-bit key) header.d=fluxnic.net header.i=@fluxnic.net header.b=DE693XBz; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=I36BJjWf; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=cW4DMLQ0; arc=none smtp.client-ip=103.168.172.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fluxnic.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fluxnic.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fluxnic.net header.i=@fluxnic.net header.b="DE693XBz"; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="I36BJjWf"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="cW4DMLQ0" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 96B69114021C; Thu, 3 Oct 2024 13:21:09 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-03.internal (MEProxy); Thu, 03 Oct 2024 13:21:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fluxnic.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=2016-12.pbsmtp; t=1727976069; x=1728062469; bh=T0Gh2u4m3SKRElcRPNC2jke2wIz4dVAsTOIve8RcFg0=; b= DE693XBz/1b5g00of7cv9jCWAq197Jd9yYnds2uw+E6gX11SxNUHHbNKbe9ce1q2 NO8h/yPOuYPTqd7JF4g8i9iBtOjxCw4w79TjCAFba5JZ52jndE7xY9VFrwQKJ+Zq BfFbla3Op+E73+XB7Qg1eXdPm3VowCPT6v2HXp6gGyg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1727976069; x= 1728062469; bh=T0Gh2u4m3SKRElcRPNC2jke2wIz4dVAsTOIve8RcFg0=; b=I 36BJjWfqCEjH0XZVFxLEqE3Bn1HUPgNpFxKX8ouOisjgvZbwYV7vPPXIr4nStGtt p+bklPEW0X7Ta1rAcLew+drYFeqxz1o2hVLvSDiuFL+9/ELiS3iVj7MxtKYbvTmY y3wlbSjYJbbjlb2vUUW10bIKm8Fm+lcBQ1DbHQqop6g+BQC/9UiAok85GyiyumBE 3iHKlfuyjDZ45iNbPCouu/J1DMrAC3KHkOfe3g8y7SBneeJa1I1ES/kdj+ApZkqn v+CPyo7EM0RxVfs0nK+FQ3QQQMnEXblooLECvS/0i0cEaBTy2It6z5L7FyaHKes4 WRff2GU6kEFp1hHrVN1oA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1727976069; x= 1728062469; bh=T0Gh2u4m3SKRElcRPNC2jke2wIz4dVAsTOIve8RcFg0=; b=c W4DMLQ0SaljKT7J76tZaRYDWYyFu33Oav6pdR2JsBviGHwY+gKZdfUSzf4A1/WEW Tt0cb8/2lMPjYLS1fUI5dj9Cq32EhtHcphlO8Rfz/ZTHmBnII910OXIO+oTMWAS/ B/vnGDv2z0j+uxM0nTMrYI7KK2x8pqmgTrUrMb/vVmnxz6fACVdwMorPtRi4RYHW YuKtF2DcVEXAUZaCwyrzwyUxSr3Lhl9Y6rcVzOHO7pSh2Muqadst1LXjNuvPqu/q WWj+f1S8UvX6x+xoSHv6sHZGUI45YDHPkeortteoE4CTf5LLj3VDqSWggL9wA/JH vEipzMvFMj31ZsCWdOPxg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddvuddgudduvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddt necuhfhrohhmpefpihgtohhlrghsucfrihhtrhgvuceonhhitghosehflhhugihnihgtrd hnvghtqeenucggtffrrghtthgvrhhnpedtjeeuieeiheeiueffuddvffelheekleegkedu keeffffhudffudegvdetiefhteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehnihgtohesfhhluhignhhitgdrnhgvthdpnhgspghrtghpthht ohephedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepnhhpihhtrhgvsegsrgihlh hisghrvgdrtghomhdprhgtphhtthhopegurghvvghmsegurghvvghmlhhofhhtrdhnvght pdhrtghpthhtohepphgrsggvnhhisehrvgguhhgrthdrtghomhdprhgtphhtthhopehlih hnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehn vghtuggvvhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i58514971:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 3 Oct 2024 13:21:09 -0400 (EDT) Received: from xanadu.lan (OpenWrt.lan [192.168.1.1]) by yoda.fluxnic.net (Postfix) with ESMTPSA id 6FBF0E3B225; Thu, 3 Oct 2024 13:21:08 -0400 (EDT) From: Nicolas Pitre To: "David S. Miller" , Paolo Abeni Cc: Nicolas Pitre , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v2 2/2] net: ethernet: ti: am65-cpsw: avoid devm_alloc_etherdev, fix module removal Date: Thu, 3 Oct 2024 13:07:13 -0400 Message-ID: <20241003172105.2712027-3-nico@fluxnic.net> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241003172105.2712027-1-nico@fluxnic.net> References: <20241003172105.2712027-1-nico@fluxnic.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nicolas Pitre Usage of devm_alloc_etherdev_mqs() conflicts with am65_cpsw_nuss_cleanup_ndev() as the same struct net_device instances get unregistered twice. Switch to alloc_etherdev_mqs() and make sure am65_cpsw_nuss_cleanup_ndev() unregisters and frees those net_device instances properly. With this, it is finally possible to rmmod the driver without oopsing the kernel. Signed-off-by: Nicolas Pitre Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth = subsystem driver") --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/etherne= t/ti/am65-cpsw-nuss.c index f6bc8a4dc6..e95457c988 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -2744,10 +2744,9 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_commo= n *common, u32 port_idx) return 0; =20 /* alloc netdev */ - port->ndev =3D devm_alloc_etherdev_mqs(common->dev, - sizeof(struct am65_cpsw_ndev_priv), - AM65_CPSW_MAX_QUEUES, - AM65_CPSW_MAX_QUEUES); + port->ndev =3D alloc_etherdev_mqs(sizeof(struct am65_cpsw_ndev_priv), + AM65_CPSW_MAX_QUEUES, + AM65_CPSW_MAX_QUEUES); if (!port->ndev) { dev_err(dev, "error allocating slave net_device %u\n", port->port_id); @@ -2868,8 +2867,12 @@ static void am65_cpsw_nuss_cleanup_ndev(struct am65_= cpsw_common *common) =20 for (i =3D 0; i < common->port_num; i++) { port =3D &common->ports[i]; - if (port->ndev && port->ndev->reg_state =3D=3D NETREG_REGISTERED) + if (!port->ndev) + continue; + if (port->ndev->reg_state =3D=3D NETREG_REGISTERED) unregister_netdev(port->ndev); + free_netdev(port->ndev); + port->ndev =3D NULL; } } =20 @@ -3613,16 +3616,17 @@ static int am65_cpsw_nuss_probe(struct platform_dev= ice *pdev) =20 ret =3D am65_cpsw_nuss_init_ndevs(common); if (ret) - goto err_free_phylink; + goto err_ndevs_clear; =20 ret =3D am65_cpsw_nuss_register_ndevs(common); if (ret) - goto err_free_phylink; + goto err_ndevs_clear; =20 pm_runtime_put(dev); return 0; =20 -err_free_phylink: +err_ndevs_clear: + am65_cpsw_nuss_cleanup_ndev(common); am65_cpsw_nuss_phylink_cleanup(common); am65_cpts_release(common->cpts); err_of_clear: --=20 2.46.1