Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3999438pxb; Tue, 10 Nov 2020 05:42:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwE6NOuprpvyoAPPUxT3xD6d9whTLKp6qX9YIDaqrl+dmLhkbyM8WFNGjqe2JstLMwQo57W X-Received: by 2002:a05:6402:43:: with SMTP id f3mr20379708edu.373.1605015774857; Tue, 10 Nov 2020 05:42:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605015774; cv=none; d=google.com; s=arc-20160816; b=iXWCsGUkYTtpgHJ9CYqHqu3VdB3Adv/nJq8LtByq3kEuRWB6YM9UJl177ffSDdsDsM CHIZAhjUxw4t+2SKsqFVDaKJrhlfbVkcws/4K0Z87qE3flOGdXZ8TbedKWMJu5T8DQO0 gCuLBcXOlM5woJIIw6P4aJe/PqxkymQrzovo+et7Cizk7GUgPpaV1sotcd47V+xoMLdf N/KJUrQtsDKusNPj5/Pww8TRLg6iUaLuTg5qMZJF1A37/d6h4l4mpvhUM7zIrxczzGJu 68Gm+GKJUwihaGQ2LK58XYBiHn90ml4Ou6ZNctcVZy2iF+J03Y7Ais2mXaWzAgibSHid eDKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :date:cc:to:from:subject:message-id; bh=PtJujQYPy4SO1pPJWxvW971xPqU1XenG2ZZ3yCUFp1k=; b=aFQ+ZCSK/2kPL4PYIzE4iVXBYpp7zWcCp5WMCD2jLpyqDeeeSuEGZlIIWOs7eXzlvl L2ZwWmaVkA6hVX+OvbdN9lv3QXjCgMCUCtQRynenHidJgx5UT9a17P2LyD0HCR6xmJQw 4fjB+e7qicT9wK7ci3huo0VtiZxdM/FHO+jf/LzQy77RR5SgjBvMnhZ1irX3hiXOkgdz etuWuBsDTMWi0ssgXXWLMSLZEmONf7OH7q19lZvBHteGsuYQXWZu+Mkl0PKDHvpbPoRP iq8mk7vsdR400vFXVt1zLA1rBbMuJb61546t3HmJy4PKt+/kn4E2eAAFQ/x5cS8XxO3P 8aGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si8943204edi.111.2020.11.10.05.42.29; Tue, 10 Nov 2020 05:42:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730856AbgKJNi5 (ORCPT + 99 others); Tue, 10 Nov 2020 08:38:57 -0500 Received: from mx2.suse.de ([195.135.220.15]:35390 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730534AbgKJNi4 (ORCPT ); Tue, 10 Nov 2020 08:38:56 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7AAC6ACDB; Tue, 10 Nov 2020 13:38:54 +0000 (UTC) Message-ID: <25933d5863cd6ddb98dea25bdedf342ebd063480.camel@suse.de> Subject: Re: [PATCH v3 01/11] firmware: raspberrypi: Introduce devm_rpi_firmware_get() From: Nicolas Saenz Julienne To: Bartosz Golaszewski Cc: Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= , LKML , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, linux-pwm@vger.kernel.org, arm-soc , linux-devicetree , wahrenst@gmx.net, Linux Input , Dmitry Torokhov , Greg KH , devel@driverdev.osuosl.org, Philipp Zabel , linux-gpio , Linus Walleij , linux-clk , Stephen Boyd , linux-rpi-kernel@lists.infradead.org, Andy Shevchenko Date: Tue, 10 Nov 2020 14:38:52 +0100 In-Reply-To: References: <20201104103938.1286-1-nsaenzjulienne@suse.de> <20201104103938.1286-2-nsaenzjulienne@suse.de> <47eaba0bc71c6e23bff87b8a01cebf0c6d12efd0.camel@suse.de> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-aSQnVn7Q9FP2OogzR6s5" User-Agent: Evolution 3.36.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-aSQnVn7Q9FP2OogzR6s5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Bartosz, thanks for the feedback. On Thu, 2020-11-05 at 10:42 +0100, Bartosz Golaszewski wrote: > On Thu, Nov 5, 2020 at 10:28 AM Nicolas Saenz Julienne > wrote: > > Hi Bartosz, thanks for the review. > >=20 > > On Thu, 2020-11-05 at 10:13 +0100, Bartosz Golaszewski wrote: > > > > +/** > > > > + * devm_rpi_firmware_get - Get pointer to rpi_firmware structure. > > > > + * @firmware_node: Pointer to the firmware Device Tree node. > > > > + * > > > > + * Returns NULL is the firmware device is not ready. > > > > + */ > > > > +struct rpi_firmware *devm_rpi_firmware_get(struct device *dev, > > > > + struct device_node *firm= ware_node) > > > > +{ > > > > + struct platform_device *pdev =3D of_find_device_by_node(fir= mware_node); > > > > + struct rpi_firmware *fw; > > > > + > > > > + if (!pdev) > > > > + return NULL; > > > > + > > > > + fw =3D platform_get_drvdata(pdev); > > > > + if (!fw) > > > > + return NULL; > > > > + > > > > + if (!refcount_inc_not_zero(&fw->consumers)) > > > > + return NULL; > > > > + > > > > + if (devm_add_action_or_reset(dev, rpi_firmware_put, fw)) > > > > + return NULL; > > > > + > > > > + return fw; > > > > +} > > > > +EXPORT_SYMBOL_GPL(devm_rpi_firmware_get); > > >=20 > > > Usually I'd expect the devres variant to simply call > > > rpi_firmware_get() and then schedule a release callback which would > > > call whatever function is the release counterpart for it currently. > > > Devres actions are for drivers which want to schedule some more > > > unusual tasks at driver detach. Any reason for designing it this way? > >=20 > > Yes, see patch #8 where I get rid of rpi_firmware_get() altogether afte= r > > converting all users to devres. Since there is no use for the vanilla v= ersion > > of the function anymore, I figured it'd be better to merge everything i= nto > > devm_rpi_firmware_get(). That said it's not something I have strong fee= lings > > about. > >=20 >=20 > I see. So the previous version didn't really have any reference > counting and it leaked the reference returned by > of_find_device_by_node(), got it. Could you just clarify for me the > logic behind the wait_queue in rpi_firmware_remove()? If the firmware > driver gets detached and remove() stops on the wait_queue - it will be > stuck until the last user releases the firmware. I'm not sure this is > correct. Yes, that's what I meant to implement. > I'd prefer to see a kref with a release callback and remove > would simply decrease the kref and return. Each user would do the same > and then after the last user is detached the firmware would be > destroyed. Sounds good to me. I'll update it. > Don't we really have some centralized firmware subsystem that would handl= e this? Sadly no, this is an RPi specific thing, it doesn't live behind a standard = like other firmware based protocols (for ex. SCMI), and evolves as the needs ari= se. Regards, Nicolas --=-aSQnVn7Q9FP2OogzR6s5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEErOkkGDHCg2EbPcGjlfZmHno8x/4FAl+ql+wACgkQlfZmHno8 x/5TFQgArzH6eU5ljiN7do5NqV1SI7f2HoX88NazrWiPc8Ixl7QT4jfzWnZeyiBn 31OdfWDVQeexADs3RDEvq/o5SSxNP+FDGlnzm9PiYaKPWcGdOpe8wW9wggXest4N MVtyqksGQlf3MuItqI4HgP/aAhB8EKnYHTVrku2tAPR9cNliVmeusFWsPWIYXSYc IcX61cPnzFkqU56k7aNrk452Kme6XDFDi2eD2DXAzHNlSHiQOH5ZQPKBmFUkaCDL xP/T5PwL+YwF3ZWO2sU6voMp96QfiO8R/LYt215dIzlmTmdKcIC7scqEkr4HRSJp 9SW2n981ery3AA1wXoyGhLMJMilzcQ== =CaET -----END PGP SIGNATURE----- --=-aSQnVn7Q9FP2OogzR6s5--