Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7373850rdb; Wed, 3 Jan 2024 13:50:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVRvBn3rSayP83n2+eU5MfCP6EXV2lEShLpTKl5bFkUMPgBKPMcx7LedjYO5MBqHhJk0yJ X-Received: by 2002:a9d:61c4:0:b0:6dc:8bc:43e8 with SMTP id h4-20020a9d61c4000000b006dc08bc43e8mr9185965otk.66.1704318631823; Wed, 03 Jan 2024 13:50:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704318631; cv=none; d=google.com; s=arc-20160816; b=UqEOxvicarIDOyY2yorgQItAZIXB4DjvbMjhYDUhppoxQ91hSKSkFg2Mn4CIMvUNMz /FCXF7iEvfwEdrnJ4pkFeeYdoo0bWwxhMfwCWEeYJWOx7kFVnxUt/T18+VtlR93ylgc5 zN+MtbFAu7tAJ6A/dUJMgguDjbaV2q0uX2vug1sPMHBxw8A9im4J+H+p/nOM8R23lxPV hRVY8jdWxUsDNSo5mbYAiO0rFl1ri0lnU02NSPgO9ud2KRFLs0qwfcZqy02DDU6xa8Ap XMAH1iti61jwjw4C5T43xCf9OnARpswSA7JvX6A1fhG9mESOIlAaK5iE9CsFwg+x1YYz jBGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=aUL3qmp8YyJgWnCTGwj76mcYbxOhNMbAwT7dZHuyZLE=; fh=Rkkg0b1d3bQj6JkkJSEyieQ8ruY9I8jSgtTW93db3MI=; b=GVr3GswEGXuRmCCNMrO3Q2QDLytLsQS8yqMrgY+cLGm7GDFWYk6+mpaZ3Lan0zouGJ J39Nex3kdYu2ErKlJlZu5fRZET4mNNqT7GxGsrOE66nPXUYJp/+MN6jnVV2jrFBQN6Dt pT/HNnaG8U0U30y63rlx6bSrHpqKu8h4ddJ/pIlrK4bEIM8zbTj8+ZRu1rki61bhvC0J AHHr0lCFFlEetDgIn71+s7ejHpGAi0ocvDp+BANsXnJ8eSwSXe/OKCI1ZxSKINTnCErB 7YtMTPw3J9WdWyNWmELpauVY6OQSiXfWmg4DrEp+y9DNgsethsbLzHwHhRGXcWMakoAT ykag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bE7I7rp2; spf=pass (google.com: domain of linux-kernel+bounces-16034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16034-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id cc5-20020a05622a410500b0042588d183b4si29912705qtb.753.2024.01.03.13.50.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 13:50:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bE7I7rp2; spf=pass (google.com: domain of linux-kernel+bounces-16034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16034-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 821E01C2490B for ; Wed, 3 Jan 2024 21:50:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3EE721DA36; Wed, 3 Jan 2024 21:50:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bE7I7rp2" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBE521DA21; Wed, 3 Jan 2024 21:50:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2cce6bb9b48so57363931fa.1; Wed, 03 Jan 2024 13:50:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704318618; x=1704923418; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=aUL3qmp8YyJgWnCTGwj76mcYbxOhNMbAwT7dZHuyZLE=; b=bE7I7rp2ZHRU3CiKEqNmMClEw6oEJfJ8+g/soopZC78zongH3Otu/1nWacM0YJowDg IdDdznCojwhdeyp2i8Ypbg98d62RcgExtvSm7VuA3kDeYfFQBfVDEdpvT99PnqemOpKe drJD70+0OaSqhMg8OosDA60A26d0yUMKQVP2/v5nbgYtWDwK48hFledUx0ajuv0UtcRx CB2hWHbTuTN4MnkFSJtlQ+nWYSpJxt38XUTzyRlHLCE7yg220bSJkaWkU3f30k7Rwz8r Fn8TM/aqRYGEO98mh1b+8yUyVH2R9ifhvRaX69KR0VKMMuvD6XywT7glTMu6kn2SFgsn QN3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704318618; x=1704923418; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aUL3qmp8YyJgWnCTGwj76mcYbxOhNMbAwT7dZHuyZLE=; b=q2VlWJYqKCAARPkq2gb9X5jcXrsDFTT0kTqg7OAFVJOxP2IKHNCOOij1LYnIJQPA6r RkThbWsNwOX4JpyGoE4sadROUrbq8bPm9OHR+ureq04gUXO2WzOh10FvamihCEuQgZKP 4cxqE7jQ750A++x+ql4TonotDRdttE9z9kVS5H6Md6SV6apw3tS9RHKQ9B9yQw0GBLFn P7QT/tM40O0g2FZCy0LwTcxDi9/YTFveH5kdqWkTQ+v4IcBIA049NwWC4e2CKJyarLVI MBIZcfZbx7CrpFhVTwvM17tX3a+Z+eclrlN2o3Jy1Pe+llG8QqKFJS3aQNS6H+7m5vsJ NpmQ== X-Gm-Message-State: AOJu0YwBOw6db9BQyB4g66kvH1KoDnBQ6+7XcBomZplj5y0ijKUaK+Ar M46mTAy4KfkmSlE/ZTte/WtrJvUN8gs+Q3PqoH8= X-Received: by 2002:a2e:9684:0:b0:2cc:1e7b:3612 with SMTP id q4-20020a2e9684000000b002cc1e7b3612mr4209336lji.65.1704318617657; Wed, 03 Jan 2024 13:50:17 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231220045228.27079-2-luizluca@gmail.com> In-Reply-To: From: Luiz Angelo Daros de Luca Date: Wed, 3 Jan 2024 18:50:06 -0300 Message-ID: Subject: Re: [PATCH net-next] net: mdio: get/put device node during (un)registration To: "Russell King (Oracle)" Cc: kuba@kernel.org, netdev@vger.kernel.org, andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" > Please test to check that this addresses your issue. Thanks. > > diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c > index 6cf73c15635b..afbad1ad8683 100644 > --- a/drivers/net/phy/mdio_bus.c > +++ b/drivers/net/phy/mdio_bus.c > @@ -193,6 +193,10 @@ static void mdiobus_release(struct device *d) > bus->state != MDIOBUS_ALLOCATED, > "%s: not in RELEASED or ALLOCATED state\n", > bus->id); > + > + if (bus->state == MDIOBUS_RELEASED) > + fwnode_handle_put(dev_fwnode(d)); > + > kfree(bus); > } > > @@ -684,6 +688,15 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) > bus->dev.groups = NULL; > dev_set_name(&bus->dev, "%s", bus->id); > > + /* If the bus state is allocated, we're registering a fresh bus > + * that may have a fwnode associated with it. Grab a reference > + * to the fwnode. This will be dropped when the bus is released. > + * If the bus was set to unregistered, it means that the bus was > + * previously registered, and we've already grabbed a reference. > + */ > + if (bus->state == MDIOBUS_ALLOCATED) > + fwnode_handle_get(dev_fwnode(&bus->dev)); > + > /* We need to set state to MDIOBUS_UNREGISTERED to correctly release > * the device in mdiobus_free() > * > -- Thanks Russel. It is much better than my approach. You simply get/put during registration/unregistration when a node is defined, no matter who defined it (of_mdiobus_register or anything else). Clean and simple. Regards, Luiz