From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7AE971FBCB7 for ; Tue, 14 Jan 2025 18:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736879419; cv=none; b=f7mfS2/fY5cpt4jrntqPVZcXq8Yo3mBSpMILXMzBRElLnrmMHwcDN3EC1Oi7AUBbXCzCj6vVT5wX+T7gl0dCyy3n3DyOSV8+GMzQ37XzeoUN7nzwRfhcUHkBSL4IXneIuVqn+KZ2wGXS+QKei+0ta8BcZCwPRSe9SXKBkqo7R/Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736879419; c=relaxed/simple; bh=Q6ym6NiTLX94Js/7c4QLFam1iJe5mEF/nkdB0iOKssw=; h=Message-ID:Content-Type:MIME-Version:In-Reply-To:References: Subject:From:Cc:To:Date; b=W2Vc7zK+cgdURQNk6XkHSETANIohG6ggTQfEzdmBc/UMVAMn4o7OCOCE+FSl1lDNBj2dp2Mcvrl/UQdsag7ZRKOAXm3qKB2KUY8qu4j3WDV/Fy6VnLIBYXXCMvu+AaAcYifY0XVcuTOImFDzD6T762kgGBGwkitH2UVO1H4XsMw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YN+FKONN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YN+FKONN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED529C4CEDD; Tue, 14 Jan 2025 18:30:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736879419; bh=Q6ym6NiTLX94Js/7c4QLFam1iJe5mEF/nkdB0iOKssw=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=YN+FKONNKlXuatiYAuftdvXRxbCPQSv4up3Z4rbgCr5xQXIQ5x2T7y6KECjevJsDG M8Dz9i8yNyMoCU18t9kqDtHSoE6O0oOVwopYMIWkTY9cPmGvYooaG7uMUXG6whA51D 7030/sVD7z7dsL7DzzfePua7d/EKFX/GfZG32wMzZ+UiKIqDOJQjh1HkywCrFyhhCh C4XvPgW51gSd8x30LWGvoMd+rEW/GJFpfbIHVl7UCiKC5wRu5ecOm7reg2FlQ6gN6C M5yjc7OxX/4YsghbuW5UpZ44IPY3c6qvBD3pIuBbRqV+ymVUmNd4qH9UH6i4UAik1Z vz/arfe4cXuNg== Message-ID: <305d7cf5f0a66efc01181f24d3a288d3.sboyd@kernel.org> Content-Type: text/plain; charset="utf-8" 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 In-Reply-To: <58cb6c37-0ea0-4866-a2b1-92cb0f0391a7@gmail.com> References: <20250113-topic-spmi_node_breakage-v2-1-dd35a3a6daa6@oss.qualcomm.com> <5b139af8d639e20a14c8bd00e8e03a4a.sboyd@kernel.org> <58cb6c37-0ea0-4866-a2b1-92cb0f0391a7@gmail.com> Subject: Re: [PATCH v2] spmi: Fix controller->node != parent->node breakage From: Stephen Boyd Cc: Marijn Suijten , linux-kernel@vger.kernel.org, Bjorn Andersson , Abel Vesa , Johan Hovold , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Konrad Dybcio To: AngeloGioacchino Del Regno , Joe Hattori , Konrad Dybcio , Konrad Dybcio , Matthias Brugger , Mauro Carvalho Chehab Date: Tue, 14 Jan 2025 10:30:16 -0800 User-Agent: alot/0.12.dev1+gaa8c22fdeedb Quoting Konrad Dybcio (2025-01-13 14:12:28) >=20 > On 1/13/25 22:52, Stephen Boyd wrote: > > Quoting Konrad Dybcio (2025-01-13 05:02:58) > >> > >> Make controller->node specifiable to both benefit from Joe's refcount > >> improvements and un-break the aforementioned platforms. > >=20 > > How is it broken? I see spmi_pmic_arb_bus_init() calls > > devm_spmi_controller_alloc() which sets the of_node to the parent device > > and then spmi_pmic_arb_bus_init() overwrites that with > > 'ctrl->dev.of_node =3D node' later on in the same function. That will > > cause one more of_node_put() than is expected. I don't see that removed > > in this patch though, so the leak is still there? > >=20 > >> > >> Fixes: 821b07853e32 ("spmi: hisi-spmi-controller: manage the OF node r= eference in device initialization and cleanup") > >=20 > > I've dropped this patch from my queue. I don't know if we're really > > doing anything better by managing the of_node lifetime in that function > > vs. letting the callers assign the node they want and manage the > > lifetime themselves. Maybe we don't need to do anything? Presumably the > > parent device driver will unregister the controller anyway, so the > > lifetime of the of_node will be ensured regardless. For subnodes like > > qcom SPMI, the subnodes are child nodes of the parent device so they > > won't be removed. If they are dynamic nodes, then the caller can manage > > the lifetime. >=20 > Stephen, the wrong node gets assigned in the qcom driver with > multi-master controllers, resulting in probe failures. >=20 > Since the introduction of the commit referenced in fixes, > of_spmi_register_devices() sees the controller's subnodes > (which describe each of the two masters) as slave devices > - meaning no "real" devices ever get to probe >=20 Ok, I see that I was reading the already reverted state of the tree where the 'ctrl->dev.of_node =3D node' assignment came back. So there's nothing to do besides drop the patch in fixes, which I already did. We can then apply this patch to drop the duplicate assignment as a cleanup and to avoid a refcount bump on the of_node that isn't needed. ----8<--- diff --git a/drivers/spmi/hisi-spmi-controller.c b/drivers/spmi/hisi-spmi-c= ontroller.c index 3cafdf22c909..122140b97579 100644 --- a/drivers/spmi/hisi-spmi-controller.c +++ b/drivers/spmi/hisi-spmi-controller.c @@ -300,9 +300,6 @@ static int spmi_controller_probe(struct platform_device= *pdev) =20 spin_lock_init(&spmi_controller->lock); =20 - ctrl->dev.parent =3D pdev->dev.parent; - ctrl->dev.of_node =3D of_node_get(pdev->dev.of_node); - /* Callbacks */ ctrl->read_cmd =3D spmi_read_cmd; ctrl->write_cmd =3D spmi_write_cmd;