[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=MfyCJgOCBSh7AY4jEujWXGqZBB7Tnkq0VRrAKKCcJ9hAQ@mail.gmail.com>
Date: Wed, 5 Jun 2024 09:43:02 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Ratheesh Kannoth <rkannoth@...vell.com>
Cc: Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Marcel Holtmann <marcel@...tmann.org>, Luiz Augusto von Dentz <luiz.dentz@...il.com>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Balakrishna Godavarthi <quic_bgodavar@...cinc.com>, Rocky Liao <quic_rjliao@...cinc.com>,
Kalle Valo <kvalo@...nel.org>, Jeff Johnson <jjohnson@...nel.org>,
Bjorn Andersson <andersson@...nel.org>, Konrad Dybcio <konrad.dybcio@...aro.org>,
Bjorn Helgaas <bhelgaas@...gle.com>, Srini Kandagatla <srinivas.kandagatla@...aro.org>,
Elliot Berman <quic_eberman@...cinc.com>, Caleb Connolly <caleb.connolly@...aro.org>,
Neil Armstrong <neil.armstrong@...aro.org>, Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
Alex Elder <elder@...nel.org>, linux-arm-msm@...r.kernel.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
linux-bluetooth@...r.kernel.org, netdev@...r.kernel.org,
linux-wireless@...r.kernel.org, ath11k@...ts.infradead.org,
Jeff Johnson <quic_jjohnson@...cinc.com>, ath12k@...ts.infradead.org,
linux-pm@...r.kernel.org, linux-pci@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>, kernel@...cinc.com,
Amit Pundir <amit.pundir@...aro.org>
Subject: Re: [PATCH v8 10/17] power: sequencing: implement the pwrseq core
On Wed, Jun 5, 2024 at 8:52 AM Ratheesh Kannoth <rkannoth@...vell.com> wrote:
>
> On 2024-05-29 at 00:33:18, Bartosz Golaszewski (brgl@...ev.pl) wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> >
> > Implement the power sequencing subsystem allowing devices to share
> > complex powering-up and down procedures. It's split into the consumer
> > and provider parts but does not implement any new DT bindings so that
> > the actual power sequencing is never revealed in the DT representation.
> >
> > Tested-by: Amit Pundir <amit.pundir@...aro.org>
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> > ---
> > +
> > +static struct pwrseq_unit_dep *pwrseq_unit_dep_new(struct pwrseq_unit *unit)
> nit. pwrseq_unit_dep_alloc/create rhymes well with pwrseq_unit_dep_free(),
So what?
> > +static void pwrseq_unit_free_deps(struct list_head *list)
> > +{
> > + struct pwrseq_unit_dep *dep, *next;
> > +
> > + list_for_each_entry_safe(dep, next, list, list) {
> no need of 'locks' to protect against simutaneous 'add' ?
No, this only happens once during release.
> > +
> > +static int pwrseq_unit_setup_deps(const struct pwrseq_unit_data **data,
> > + struct list_head *dep_list,
> > + struct list_head *unit_list,
> > + struct radix_tree_root *processed_units)
> > +{
> > + const struct pwrseq_unit_data *pos;
> > + struct pwrseq_unit_dep *dep;
> > + struct pwrseq_unit *unit;
> > + int i;
> > +
> > + for (i = 0; data[i]; i++) {
> Can we add range for i ? just depending on data[i] to be zero looks to be risky.
>
Why? It's perfectly normal to expect users to end the array with a
NULL pointer. The docs say these arrays must be NULL-terminated.
> > + pos = data[i];
> > +
> > + unit = pwrseq_unit_setup(pos, unit_list, processed_units);
> > + if (IS_ERR(unit))
> > + return PTR_ERR(unit);
> > +
> > + dep = pwrseq_unit_dep_new(unit);
> > + if (!dep) {
> > + pwrseq_unit_decref(unit);
> This frees only one 'unit'. is there any chance for multiple 'unit', then better clean
> up here ?
The references to those will be dropped in pwrseq_release().
> > +
> > + /*
> > + * From this point onwards the device's release() callback is
> > + * responsible for freeing resources.
> > + */
> > + device_initialize(&pwrseq->dev);
> > +
> > + ret = dev_set_name(&pwrseq->dev, "pwrseq.%d", pwrseq->id);
> > + if (ret)
> > + goto err_put_pwrseq;
> > +
> > + pwrseq->owner = config->owner ?: THIS_MODULE;
> > + pwrseq->match = config->match;
> > +
> > + init_rwsem(&pwrseq->rw_lock);
> > + mutex_init(&pwrseq->state_lock);
> > + INIT_LIST_HEAD(&pwrseq->targets);
> > + INIT_LIST_HEAD(&pwrseq->units);
> > +
> > + ret = pwrseq_setup_targets(config->targets, pwrseq);
> > + if (ret)
> > + goto err_put_pwrseq;
> > +
> > + scoped_guard(rwsem_write, &pwrseq_sem) {
> > + ret = device_add(&pwrseq->dev);
> > + if (ret)
> > + goto err_put_pwrseq;
> > + }
> > +
> > + return pwrseq;
> > +
> > +err_put_pwrseq:
> no need to kfree(pwrseq) ?
It's literally put on the next line?
Bart
Powered by blists - more mailing lists