lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <05e001da4e90$0ace4b80$206ae280$@samsung.com>
Date: Wed, 24 Jan 2024 12:09:08 +0530
From: "Shradha Todi" <shradha.t@...sung.com>
To: "'Alim Akhtar'" <alim.akhtar@...sung.com>, <linux-clk@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, <linux-pci@...r.kernel.org>,
	<linux-arm-kernel@...ts.infradead.org>, <linux-samsung-soc@...r.kernel.org>
Cc: <mturquette@...libre.com>, <sboyd@...nel.org>, <jingoohan1@...il.com>,
	<lpieralisi@...nel.org>, <kw@...ux.com>, <robh@...nel.org>,
	<bhelgaas@...gle.com>, <krzysztof.kozlowski@...aro.org>,
	<linux@...linux.org.uk>, <m.szyprowski@...sung.com>,
	<manivannan.sadhasivam@...aro.org>
Subject: RE: [PATCH v3 1/2] clk: Provide managed helper to get and enable
 bulk clocks



> -----Original Message-----
> From: Alim Akhtar <alim.akhtar@...sung.com>
> Sent: 10 January 2024 18:01
> To: 'Shradha Todi' <shradha.t@...sung.com>; linux-clk@...r.kernel.org; linux-
> kernel@...r.kernel.org; linux-pci@...r.kernel.org; linux-arm-
> kernel@...ts.infradead.org; linux-samsung-soc@...r.kernel.org
> Cc: mturquette@...libre.com; sboyd@...nel.org; jingoohan1@...il.com;
> lpieralisi@...nel.org; kw@...ux.com; robh@...nel.org; bhelgaas@...gle.com;
> krzysztof.kozlowski@...aro.org; linux@...linux.org.uk;
> m.szyprowski@...sung.com; manivannan.sadhasivam@...aro.org;
> alim.akhtar@...sung.com
> Subject: RE: [PATCH v3 1/2] clk: Provide managed helper to get and enable bulk
> clocks
> 
> Hi Shradha,
> 
> > -----Original Message-----
> > From: Shradha Todi <shradha.t@...sung.com>
> > Sent: Wednesday, January 10, 2024 4:31 PM
> > To: linux-clk@...r.kernel.org; linux-kernel@...r.kernel.org; linux-
> > pci@...r.kernel.org; linux-arm-kernel@...ts.infradead.org;
> > linux-samsung- soc@...r.kernel.org
> > Cc: mturquette@...libre.com; sboyd@...nel.org; jingoohan1@...il.com;
> > lpieralisi@...nel.org; kw@...ux.com; robh@...nel.org;
> > bhelgaas@...gle.com; krzysztof.kozlowski@...aro.org;
> > alim.akhtar@...sung.com; linux@...linux.org.uk;
> > m.szyprowski@...sung.com; manivannan.sadhasivam@...aro.org; Shradha
> > Todi <shradha.t@...sung.com>
> > Subject: [PATCH v3 1/2] clk: Provide managed helper to get and enable
> > bulk clocks
> >
> > Provide a managed devm_clk_bulk* wrapper to get and enable all bulk
> > clocks in order to simplify drivers that keeps all clocks enabled for
> > the time of driver operation.
> >
> > Suggested-by: Marek Szyprowski <m.szyprowski@...sung.com>
> > Signed-off-by: Shradha Todi <shradha.t@...sung.com>
> > ---
> >  drivers/clk/clk-devres.c | 41
> > ++++++++++++++++++++++++++++++++++++++++
> >  include/linux/clk.h      | 25 ++++++++++++++++++++++++
> >  2 files changed, 66 insertions(+)
> >
> > diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c index
> > 4fb4fd4b06bd..05b0ff4bc1d4 100644
> > --- a/drivers/clk/clk-devres.c
> > +++ b/drivers/clk/clk-devres.c
> > @@ -102,6 +102,7 @@
> > EXPORT_SYMBOL_GPL(devm_clk_get_optional_enabled);
> >  struct clk_bulk_devres {
> >  	struct clk_bulk_data *clks;
> >  	int num_clks;
> > +	void (*exit)(int num_clks, const struct clk_bulk_data *clks);
> >  };
> >
> >  static void devm_clk_bulk_release(struct device *dev, void *res) @@
> > -182,6
> > +183,46 @@ int __must_check devm_clk_bulk_get_all(struct device *dev,
> > +}
> > EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all);
> >
> > +static void devm_clk_bulk_release_all_enabled(struct device *dev,
> > +void
> May be devm_clk_bulk_release_all_disable()
> 

Will change this in the next patchset

> Also this is similar to already existing devm_clk_bulk_release_all(), may be you
> can reuse this function And add the exit() callback in devm_clk_bulk_release_all()
> 

Since I'm planning to remove the exit callback in the next version as suggested by Manivannan, I will have to
go with a new release function

> > +*res) {
> > +	struct clk_bulk_devres *devres = res;
> > +
> > +	if (devres->exit)
> > +		devres->exit(devres->num_clks, devres->clks);
> > +
> > +	clk_bulk_put_all(devres->num_clks, devres->clks); }
> > +
> > +int __must_check devm_clk_bulk_get_all_enabled(struct device *dev,
> 
> May be devm_clk_bulk_get_all_enable() is more suitable
> 

Will take this in the next patchset! Thanks for the review

> > +				  struct clk_bulk_data **clks, int *num_clks) {
> > +	struct clk_bulk_devres *devres;
> > +	int ret;
> > +
> > +	devres = devres_alloc(devm_clk_bulk_release_all_enabled,
> > +			      sizeof(*devres), GFP_KERNEL);
> > +	if (!devres)
> > +		return -ENOMEM;
> > +
> > +	ret = clk_bulk_get_all(dev, &devres->clks);
> > +	if (ret > 0) {
> > +		*clks = devres->clks;
> > +		devres->num_clks = ret;
> > +		*num_clks = ret;
> > +		devres_add(dev, devres);
> > +	} else {
> > +		devres_free(devres);
> > +		return ret;
> > +	}
> > +
> > +	ret = clk_bulk_prepare_enable(devres->num_clks, *clks);
> > +	if (!ret)
> > +		devres->exit = clk_bulk_disable_unprepare;
> > +
> > +	return ret;
> > +}
> > +EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all_enabled);
> > +
> >  static int devm_clk_match(struct device *dev, void *res, void *data)  {
> >  	struct clk **c = res;
> > diff --git a/include/linux/clk.h b/include/linux/clk.h index
> > 1ef013324237..bf3e9bee5754 100644
> > --- a/include/linux/clk.h
> > +++ b/include/linux/clk.h
> > @@ -438,6 +438,24 @@ int __must_check
> > devm_clk_bulk_get_optional(struct device *dev, int num_clks,  int
> > __must_check devm_clk_bulk_get_all(struct device *dev,
> >  				       struct clk_bulk_data **clks);
> >
> > +/**
> > + * devm_clk_bulk_get_all_enabled - managed get multiple clk consumers
> > and
> > + *					enable all clk
> > + * @dev: device for clock "consumer"
> > + * @clks: pointer to the clk_bulk_data table of consumer
> > + * @num_clks: out parameter to store the number of clk_bulk_data
> > + *
> > + * Returns success (0) or negative errno.
> > + *
> > + * This helper function allows drivers to get several clk
> > + * consumers and enable all of them in one operation with management.
> > + * The clks will automatically be disabled and freed when the device
> > + * is unbound.
> > + */
> > +
> > +int __must_check devm_clk_bulk_get_all_enabled(struct device *dev,
> > +				struct clk_bulk_data **clks, int *num_clks);
> > +
> >  /**
> >   * devm_clk_get - lookup and obtain a managed reference to a clock
> > producer.
> >   * @dev: device for clock "consumer"
> > @@ -960,6 +978,13 @@ static inline int __must_check
> > devm_clk_bulk_get_all(struct device *dev,
> >  	return 0;
> >  }
> >
> > +static inline int __must_check devm_clk_bulk_get_all_enabled(struct
> > device *dev,
> > +				struct clk_bulk_data **clks, int *num_clks) {
> > +
> > +	return 0;
> > +}
> > +
> >  static inline struct clk *devm_get_clk_from_child(struct device *dev,
> >  				struct device_node *np, const char *con_id) {
> > --
> > 2.17.1
> 



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ