2022-11-10 02:14:57

by Huisong Li

[permalink] [raw]
Subject: [PATCH 0/3] ACPI: PCC: optimize pcc codes and fix one bug

This series optimizes PCC codes as follows:
- Rename platform interrupt bit macro name to make it more reasonable and
readable.
- add check for platform interrupt in acpi_pcc.c

In addition, this series fixes a problem that mailbox channel can still be
requested successfully when fail to initialize PCC.

Huisong Li (3):
mailbox: pcc: rename platform interrupt bit macro name
ACPI: PCC: add check for platform interrupt
mailbox: pcc: fix 'pcc_chan_count' when fail to initialize PCC

drivers/acpi/acpi_pcc.c | 47 +++++++++++++++++++++++++----------------
drivers/mailbox/pcc.c | 13 ++++++++----
include/acpi/actbl2.h | 2 +-
3 files changed, 39 insertions(+), 23 deletions(-)

--
2.22.0



2022-11-10 02:27:50

by Huisong Li

[permalink] [raw]
Subject: [PATCH 3/3] mailbox: pcc: fix 'pcc_chan_count' when fail to initialize PCC

Currently, 'pcc_chan_count' is a non-zero value if PCC subspaces are parsed
successfully and subsequent processes is failure during initializing PCC
process. This may cause that pcc_mbox_request_channel() can still be
executed successfully , which will misleads the caller that this channel is
available.

Fixes: ce028702ddbc ("mailbox: pcc: Move bulk of PCCT parsing into pcc_mbox_probe")
Signed-off-by: Huisong Li <[email protected]>
---
drivers/mailbox/pcc.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index 7cee37dd3b73..47d70c5884e3 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c
@@ -294,6 +294,7 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
pr_err("Channel not found for idx: %d\n", subspace_id);
return ERR_PTR(-EBUSY);
}
+
dev = chan->mbox->dev;

spin_lock_irqsave(&chan->lock, flags);
@@ -735,7 +736,8 @@ static int __init pcc_init(void)

if (ret) {
pr_debug("ACPI PCC probe failed.\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto out;
}

pcc_pdev = platform_create_bundle(&pcc_mbox_driver,
@@ -743,10 +745,13 @@ static int __init pcc_init(void)

if (IS_ERR(pcc_pdev)) {
pr_debug("Err creating PCC platform bundle\n");
- return PTR_ERR(pcc_pdev);
+ ret = PTR_ERR(pcc_pdev);
+ goto out;
}

- return 0;
+out:
+ pcc_chan_count = 0;
+ return ret;
}

/*
--
2.22.0


2022-11-10 12:04:00

by Sudeep Holla

[permalink] [raw]
Subject: Re: [PATCH 3/3] mailbox: pcc: fix 'pcc_chan_count' when fail to initialize PCC

On Thu, Nov 10, 2022 at 09:50:34AM +0800, Huisong Li wrote:
> Currently, 'pcc_chan_count' is a non-zero value if PCC subspaces are parsed
> successfully and subsequent processes is failure during initializing PCC
> process. This may cause that pcc_mbox_request_channel() can still be
> executed successfully , which will misleads the caller that this channel is
> available.
>
> Fixes: ce028702ddbc ("mailbox: pcc: Move bulk of PCCT parsing into pcc_mbox_probe")
> Signed-off-by: Huisong Li <[email protected]>
> ---
> drivers/mailbox/pcc.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
> index 7cee37dd3b73..47d70c5884e3 100644
> --- a/drivers/mailbox/pcc.c
> +++ b/drivers/mailbox/pcc.c
> @@ -294,6 +294,7 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
> pr_err("Channel not found for idx: %d\n", subspace_id);
> return ERR_PTR(-EBUSY);
> }
> +

Spurious/not needed change ?

> dev = chan->mbox->dev;
>
> spin_lock_irqsave(&chan->lock, flags);
> @@ -735,7 +736,8 @@ static int __init pcc_init(void)
>
> if (ret) {
> pr_debug("ACPI PCC probe failed.\n");
> - return -ENODEV;
> + ret = -ENODEV;
> + goto out;

Not needed, we don't set pcc_chan_count if the probe failed.

> }
>
> pcc_pdev = platform_create_bundle(&pcc_mbox_driver,
> @@ -743,10 +745,13 @@ static int __init pcc_init(void)
>
> if (IS_ERR(pcc_pdev)) {
> pr_debug("Err creating PCC platform bundle\n");
> - return PTR_ERR(pcc_pdev);
> + ret = PTR_ERR(pcc_pdev);

You just need to set pcc_chan_count to 0 here, so no need for goto.

--
Regards,
Sudeep

2022-11-10 12:22:36

by Huisong Li

[permalink] [raw]
Subject: Re: [PATCH 3/3] mailbox: pcc: fix 'pcc_chan_count' when fail to initialize PCC


在 2022/11/10 18:44, Sudeep Holla 写道:
> On Thu, Nov 10, 2022 at 09:50:34AM +0800, Huisong Li wrote:
>> Currently, 'pcc_chan_count' is a non-zero value if PCC subspaces are parsed
>> successfully and subsequent processes is failure during initializing PCC
>> process. This may cause that pcc_mbox_request_channel() can still be
>> executed successfully , which will misleads the caller that this channel is
>> available.
>>
>> Fixes: ce028702ddbc ("mailbox: pcc: Move bulk of PCCT parsing into pcc_mbox_probe")
>> Signed-off-by: Huisong Li <[email protected]>
>> ---
>> drivers/mailbox/pcc.c | 11 ++++++++---
>> 1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
>> index 7cee37dd3b73..47d70c5884e3 100644
>> --- a/drivers/mailbox/pcc.c
>> +++ b/drivers/mailbox/pcc.c
>> @@ -294,6 +294,7 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
>> pr_err("Channel not found for idx: %d\n", subspace_id);
>> return ERR_PTR(-EBUSY);
>> }
>> +
> Spurious/not needed change ?
Ack
>
>> dev = chan->mbox->dev;
>>
>> spin_lock_irqsave(&chan->lock, flags);
>> @@ -735,7 +736,8 @@ static int __init pcc_init(void)
>>
>> if (ret) {
>> pr_debug("ACPI PCC probe failed.\n");
>> - return -ENODEV;
>> + ret = -ENODEV;
>> + goto out;
> Not needed, we don't set pcc_chan_count if the probe failed.
You are right. will fix it in v2, thanks.
>
>> }
>>
>> pcc_pdev = platform_create_bundle(&pcc_mbox_driver,
>> @@ -743,10 +745,13 @@ static int __init pcc_init(void)
>>
>> if (IS_ERR(pcc_pdev)) {
>> pr_debug("Err creating PCC platform bundle\n");
>> - return PTR_ERR(pcc_pdev);
>> + ret = PTR_ERR(pcc_pdev);
> You just need to set pcc_chan_count to 0 here, so no need for goto.
Ack
>

2022-11-11 03:28:30

by Huisong Li

[permalink] [raw]
Subject: [PATCH V2 0/2] optimize pcc code and fix one bug

This series addes check for platform interrupt in acpi_pcc.c and fixes a
problem that mailbox channel can still be requested successfully when fail
to initialize PCC.

---
-v2: drop the patch that rename platform interrupt bit macro

---

Huisong Li (2):
ACPI: PCC: add check for platform interrupt
mailbox: pcc: fix 'pcc_chan_count' when fail to initialize PCC

drivers/acpi/acpi_pcc.c | 47 +++++++++++++++++++++++++----------------
drivers/mailbox/pcc.c | 1 +
2 files changed, 30 insertions(+), 18 deletions(-)

--
2.22.0


2022-11-12 02:36:16

by Huisong Li

[permalink] [raw]
Subject: [PATCH V3 0/2] Optimize PCC OpRegion code and reset pcc_chan_count

This series clarifies the dependency of PCC OpRegion on interrupt and reset
pcc_chan_count to zero in case of PCC probe failure.


---
- v3: fix commit log and goto tags.
- v2: drop the patch that rename platform interrupt bit macro
---

Huisong Li (2):
ACPI: PCC: Setup PCC Opregion handler only if platform interrupt is
available
mailbox: pcc: Reset pcc_chan_count to zero in case of PCC probe
failure

drivers/acpi/acpi_pcc.c | 47 +++++++++++++++++++++++++----------------
drivers/mailbox/pcc.c | 1 +
2 files changed, 30 insertions(+), 18 deletions(-)

--
2.22.0


2022-11-12 02:36:31

by Huisong Li

[permalink] [raw]
Subject: [PATCH V3 2/2] mailbox: pcc: Reset pcc_chan_count to zero in case of PCC probe failure

Currently, 'pcc_chan_count' is remains set to a non-zero value if PCC
subspaces are parsed successfully but something else fail later during
the initial PCC probing phase. This will result in pcc_mbox_request_channel
trying to access the resources that are not initialised or allocated and
may end up in a system crash.

Reset pcc_chan_count to 0 when the PCC probe fails in order to prevent
the possible issue as described above.

Fixes: ce028702ddbc ("mailbox: pcc: Move bulk of PCCT parsing into pcc_mbox_probe")
Signed-off-by: Huisong Li <[email protected]>
Reviewed-by: Sudeep Holla <[email protected]>
---
drivers/mailbox/pcc.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index 3c2bc0ca454c..105d46c9801b 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c
@@ -743,6 +743,7 @@ static int __init pcc_init(void)

if (IS_ERR(pcc_pdev)) {
pr_debug("Err creating PCC platform bundle\n");
+ pcc_chan_count = 0;
return PTR_ERR(pcc_pdev);
}

--
2.22.0


2022-11-23 19:23:15

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH V3 0/2] Optimize PCC OpRegion code and reset pcc_chan_count

On Sat, Nov 12, 2022 at 3:07 AM Huisong Li <[email protected]> wrote:
>
> This series clarifies the dependency of PCC OpRegion on interrupt and reset
> pcc_chan_count to zero in case of PCC probe failure.
>
>
> ---
> - v3: fix commit log and goto tags.
> - v2: drop the patch that rename platform interrupt bit macro
> ---
>
> Huisong Li (2):
> ACPI: PCC: Setup PCC Opregion handler only if platform interrupt is
> available
> mailbox: pcc: Reset pcc_chan_count to zero in case of PCC probe
> failure
>
> drivers/acpi/acpi_pcc.c | 47 +++++++++++++++++++++++++----------------
> drivers/mailbox/pcc.c | 1 +
> 2 files changed, 30 insertions(+), 18 deletions(-)
>
> --

Both applied as 6.2 material, thanks!