From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Jie Zhan <zhanjie9@hisilicon.com>
Cc: yubowen8@huawei.com, linux-pm@vger.kernel.org,
zhenglifeng1@huawei.com, liwei728@huawei.com,
linuxarm@huawei.com, cw00.choi@samsung.com,
kyungmin.park@samsung.com, myungjoo.ham@samsung.com,
lihuisong@huawei.com, prime.zeng@hisilicon.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v5 2/2] PM / devfreq: Add HiSilicon uncore frequency scaling driver
Date: Fri, 20 Jun 2025 14:10:21 +0100 [thread overview]
Message-ID: <20250620141021.0000694c@huawei.com> (raw)
In-Reply-To: <20250619151456.3328624-3-zhanjie9@hisilicon.com>
On Thu, 19 Jun 2025 23:14:56 +0800
Jie Zhan <zhanjie9@hisilicon.com> wrote:
> Add the HiSilicon uncore frequency scaling driver for Kunpeng SoCs based on
> the devfreq framework. The uncore domain contains shared computing
> resources, including system interconnects and L3 cache. The uncore
> frequency significantly impacts the system-wide performance as well as
> power consumption. This driver adds support for runtime management of
> uncore frequency from kernel and userspace. The main function includes
> setting and getting frequencies, changing frequency scaling policies, and
> querying the list of CPUs whose performance is significantly related to
> this uncore frequency domain, etc. The driver communicates with a platform
> controller through an ACPI PCC mailbox to take the actual actions of
> frequency scaling.
>
> Co-developed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
> Signed-off-by: Jie Zhan <zhanjie9@hisilicon.com>
Hi zhanjie,
A few more things inline that I missed in earlier review.
The devm_mutex one is a definite thing to fix as having it
where it is will make it far to easy to add bugs.
The other stuff is a nice to have.
So with at least the devm_mutex() call moved
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> diff --git a/drivers/devfreq/hisi_uncore_freq.c b/drivers/devfreq/hisi_uncore_freq.c
> new file mode 100644
> index 000000000000..e19678692c16
> --- /dev/null
> +++ b/drivers/devfreq/hisi_uncore_freq.c
> @@ -0,0 +1,664 @@
> +static int hisi_uncore_request_pcc_chan(struct hisi_uncore_freq *uncore)
> +{
> + struct device *dev = uncore->dev;
> + struct pcc_mbox_chan *pcc_chan;
> + int rc;
> +
> + uncore->cl = (struct mbox_client) {
> + .dev = dev,
> + .tx_block = false,
> + .knows_txdone = true,
> + };
> +
> + pcc_chan = pcc_mbox_request_channel(&uncore->cl, uncore->chan_id);
I'm not particularly keen on the repeats of pcc_mbox_free_channel() in each of
the error paths. Either use a goto and clean it up at the end or
DEFINE_FREE(pcc_mbox_chan, struct pcc_mbox_chan *, if (_T) pcc_mbox_free_channel(_T));
then here
struct pcc_mbox_chan __free(pcc_mbox_chan) *pcc_chan =
pcc_mbox_request_channel(&uncore->cl, uncore->chan_id);
remembering to do
uncor->chan = no_free_ptr(pcc_chan);
where you currently set it below.
The DEFINE_FREE() might prove useful in other drivers. kunpeng_hccs
for instance could be simplified with this. Various other candidates
though not sure how keen on cleanup.h magic those areas of the kernel are.
> + if (IS_ERR(pcc_chan))
> + return dev_err_probe(dev, PTR_ERR(pcc_chan),
> + "Failed to request PCC channel %u\n", uncore->chan_id);
> +
> + if (!pcc_chan->shmem_base_addr) {
> + pcc_mbox_free_channel(pcc_chan);
> + return dev_err_probe(dev, -EINVAL,
> + "Invalid PCC shared memory address\n");
> + }
> +
> + if (pcc_chan->shmem_size < sizeof(struct hisi_uncore_pcc_shmem)) {
> + pcc_mbox_free_channel(pcc_chan);
> + return dev_err_probe(dev, -EINVAL,
> + "Invalid PCC shared memory size (%lluB)\n",
> + pcc_chan->shmem_size);
> + }
> +
> + rc = devm_mutex_init(dev, &uncore->pcc_lock);
This is oddly placed. Drop this out of this function and do it at least one layer
up.
Having it here leaves the risk of future error cases being added after this
where the devm cleanup will happen out of order as a result.
> + if (rc) {
> + pcc_mbox_free_channel(pcc_chan);
> + return rc;
> + }
> +
> + uncore->pchan = pcc_chan;
> +
> + return 0;
> +}
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Jie Zhan <zhanjie9@hisilicon.com>
Cc: <cw00.choi@samsung.com>, <myungjoo.ham@samsung.com>,
<kyungmin.park@samsung.com>, <linux-pm@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <linuxarm@huawei.com>,
<alireza.sanaee@huawei.com>, <zhenglifeng1@huawei.com>,
<lihuisong@huawei.com>, <yubowen8@huawei.com>,
<liwei728@huawei.com>, <prime.zeng@hisilicon.com>
Subject: Re: [PATCH v5 2/2] PM / devfreq: Add HiSilicon uncore frequency scaling driver
Date: Fri, 20 Jun 2025 14:10:21 +0100 [thread overview]
Message-ID: <20250620141021.0000694c@huawei.com> (raw)
In-Reply-To: <20250619151456.3328624-3-zhanjie9@hisilicon.com>
On Thu, 19 Jun 2025 23:14:56 +0800
Jie Zhan <zhanjie9@hisilicon.com> wrote:
> Add the HiSilicon uncore frequency scaling driver for Kunpeng SoCs based on
> the devfreq framework. The uncore domain contains shared computing
> resources, including system interconnects and L3 cache. The uncore
> frequency significantly impacts the system-wide performance as well as
> power consumption. This driver adds support for runtime management of
> uncore frequency from kernel and userspace. The main function includes
> setting and getting frequencies, changing frequency scaling policies, and
> querying the list of CPUs whose performance is significantly related to
> this uncore frequency domain, etc. The driver communicates with a platform
> controller through an ACPI PCC mailbox to take the actual actions of
> frequency scaling.
>
> Co-developed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
> Signed-off-by: Jie Zhan <zhanjie9@hisilicon.com>
Hi zhanjie,
A few more things inline that I missed in earlier review.
The devm_mutex one is a definite thing to fix as having it
where it is will make it far to easy to add bugs.
The other stuff is a nice to have.
So with at least the devm_mutex() call moved
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> diff --git a/drivers/devfreq/hisi_uncore_freq.c b/drivers/devfreq/hisi_uncore_freq.c
> new file mode 100644
> index 000000000000..e19678692c16
> --- /dev/null
> +++ b/drivers/devfreq/hisi_uncore_freq.c
> @@ -0,0 +1,664 @@
> +static int hisi_uncore_request_pcc_chan(struct hisi_uncore_freq *uncore)
> +{
> + struct device *dev = uncore->dev;
> + struct pcc_mbox_chan *pcc_chan;
> + int rc;
> +
> + uncore->cl = (struct mbox_client) {
> + .dev = dev,
> + .tx_block = false,
> + .knows_txdone = true,
> + };
> +
> + pcc_chan = pcc_mbox_request_channel(&uncore->cl, uncore->chan_id);
I'm not particularly keen on the repeats of pcc_mbox_free_channel() in each of
the error paths. Either use a goto and clean it up at the end or
DEFINE_FREE(pcc_mbox_chan, struct pcc_mbox_chan *, if (_T) pcc_mbox_free_channel(_T));
then here
struct pcc_mbox_chan __free(pcc_mbox_chan) *pcc_chan =
pcc_mbox_request_channel(&uncore->cl, uncore->chan_id);
remembering to do
uncor->chan = no_free_ptr(pcc_chan);
where you currently set it below.
The DEFINE_FREE() might prove useful in other drivers. kunpeng_hccs
for instance could be simplified with this. Various other candidates
though not sure how keen on cleanup.h magic those areas of the kernel are.
> + if (IS_ERR(pcc_chan))
> + return dev_err_probe(dev, PTR_ERR(pcc_chan),
> + "Failed to request PCC channel %u\n", uncore->chan_id);
> +
> + if (!pcc_chan->shmem_base_addr) {
> + pcc_mbox_free_channel(pcc_chan);
> + return dev_err_probe(dev, -EINVAL,
> + "Invalid PCC shared memory address\n");
> + }
> +
> + if (pcc_chan->shmem_size < sizeof(struct hisi_uncore_pcc_shmem)) {
> + pcc_mbox_free_channel(pcc_chan);
> + return dev_err_probe(dev, -EINVAL,
> + "Invalid PCC shared memory size (%lluB)\n",
> + pcc_chan->shmem_size);
> + }
> +
> + rc = devm_mutex_init(dev, &uncore->pcc_lock);
This is oddly placed. Drop this out of this function and do it at least one layer
up.
Having it here leaves the risk of future error cases being added after this
where the devm cleanup will happen out of order as a result.
> + if (rc) {
> + pcc_mbox_free_channel(pcc_chan);
> + return rc;
> + }
> +
> + uncore->pchan = pcc_chan;
> +
> + return 0;
> +}
next prev parent reply other threads:[~2025-06-20 13:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-19 15:14 [PATCH v5 0/2] PM / devfreq: Add HiSilicon uncore frequency scaling driver Jie Zhan
2025-06-19 15:14 ` Jie Zhan
2025-06-19 15:14 ` [PATCH v5 1/2] PM / devfreq: Allow devfreq driver to add custom sysfs ABIs Jie Zhan
2025-06-19 15:14 ` Jie Zhan
2025-06-19 15:14 ` [PATCH v5 2/2] PM / devfreq: Add HiSilicon uncore frequency scaling driver Jie Zhan
2025-06-19 15:14 ` Jie Zhan
2025-06-20 13:10 ` Jonathan Cameron [this message]
2025-06-20 13:10 ` Jonathan Cameron
2025-06-23 8:43 ` Jie Zhan
2025-06-23 8:43 ` Jie Zhan
2025-06-23 3:39 ` [PATCH v5 0/2] " lihuisong (C)
2025-06-23 3:39 ` lihuisong (C)
2025-06-23 8:45 ` Jie Zhan
2025-06-23 8:45 ` Jie Zhan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250620141021.0000694c@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=cw00.choi@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=lihuisong@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=liwei728@huawei.com \
--cc=myungjoo.ham@samsung.com \
--cc=prime.zeng@hisilicon.com \
--cc=yubowen8@huawei.com \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.