linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI: sysfs: Change ACPI_MASKABLE_GPE_MAX to 0x100
@ 2019-11-05 14:35 Yunfeng Ye
  2019-11-13 23:21 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Yunfeng Ye @ 2019-11-05 14:35 UTC (permalink / raw)
  To: rjw, lenb; +Cc: linux-acpi, linux-kernel, linux-doc, hushiyuan, linfeilong

There are two problems after commit 0f27cff8597d ("ACPI: sysfs: Make
ACPI GPE mask kernel parameter cover all GPEs"):

1. ACPI_MASKABLE_GPE_MAX is changed from 0x80 to 0xff, so the check
condition "gpe > ACPI_MASKABLE_GPE_MAX" is not valid because the type of
gpe is u8.

2. The size of bitmap is ACPI_MASKABLE_GPE_MAX, so it is not support the
num 255 for gpe.

Update the macro ACPI_MASKABLE_GPE_MAX to 0x100, and change the type of
gpe to u32, also modify the checking condition for gpe.

Bye the way, update the docs for kernel parameter acpi_mask_gpe.

Fixes: 0f27cff8597d ("ACPI: sysfs: Make ACPI GPE mask kernel parameter cover all GPEs")
Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
---
 Documentation/admin-guide/kernel-parameters.txt | 1 +
 drivers/acpi/sysfs.c                            | 8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index a84a83f8881e..dd878e2491e1 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -114,6 +114,7 @@
 			This facility can be used to prevent such uncontrolled
 			GPE floodings.
 			Format: <int>
+			Support masking of GPEs numbered from 0x00 to 0xff

 	acpi_no_auto_serialize	[HW,ACPI]
 			Disable auto-serialization of AML methods
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 75948a3f1a20..3c3302583d78 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -819,14 +819,14 @@ static ssize_t counter_set(struct kobject *kobj,
  * interface:
  *   echo unmask > /sys/firmware/acpi/interrupts/gpe00
  */
-#define ACPI_MASKABLE_GPE_MAX	0xFF
+#define ACPI_MASKABLE_GPE_MAX	0x100
 static DECLARE_BITMAP(acpi_masked_gpes_map, ACPI_MASKABLE_GPE_MAX) __initdata;

 static int __init acpi_gpe_set_masked_gpes(char *val)
 {
-	u8 gpe;
+	u32 gpe;

-	if (kstrtou8(val, 0, &gpe) || gpe > ACPI_MASKABLE_GPE_MAX)
+	if (kstrtouint(val, 0, &gpe) || gpe >= ACPI_MASKABLE_GPE_MAX)
 		return -EINVAL;
 	set_bit(gpe, acpi_masked_gpes_map);

@@ -838,7 +838,7 @@ void __init acpi_gpe_apply_masked_gpes(void)
 {
 	acpi_handle handle;
 	acpi_status status;
-	u8 gpe;
+	u32 gpe;

 	for_each_set_bit(gpe, acpi_masked_gpes_map, ACPI_MASKABLE_GPE_MAX) {
 		status = acpi_get_gpe_device(gpe, &handle);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ACPI: sysfs: Change ACPI_MASKABLE_GPE_MAX to 0x100
  2019-11-05 14:35 [PATCH] ACPI: sysfs: Change ACPI_MASKABLE_GPE_MAX to 0x100 Yunfeng Ye
@ 2019-11-13 23:21 ` Rafael J. Wysocki
  2019-11-14  6:45   ` Yunfeng Ye
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2019-11-13 23:21 UTC (permalink / raw)
  To: Yunfeng Ye
  Cc: lenb, linux-acpi, linux-kernel, linux-doc, hushiyuan, linfeilong

On Tuesday, November 5, 2019 3:35:25 PM CET Yunfeng Ye wrote:
> There are two problems after commit 0f27cff8597d ("ACPI: sysfs: Make
> ACPI GPE mask kernel parameter cover all GPEs"):
> 
> 1. ACPI_MASKABLE_GPE_MAX is changed from 0x80 to 0xff, so the check
> condition "gpe > ACPI_MASKABLE_GPE_MAX" is not valid because the type of
> gpe is u8.
> 
> 2. The size of bitmap is ACPI_MASKABLE_GPE_MAX, so it is not support the
> num 255 for gpe.
> 
> Update the macro ACPI_MASKABLE_GPE_MAX to 0x100, and change the type of
> gpe to u32, also modify the checking condition for gpe.
> 
> Bye the way, update the docs for kernel parameter acpi_mask_gpe.
> 
> Fixes: 0f27cff8597d ("ACPI: sysfs: Make ACPI GPE mask kernel parameter cover all GPEs")
> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>

AFAICS this really is about supporting the masking of GPE 0xFF.

> ---
>  Documentation/admin-guide/kernel-parameters.txt | 1 +
>  drivers/acpi/sysfs.c                            | 8 ++++----
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index a84a83f8881e..dd878e2491e1 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -114,6 +114,7 @@
>  			This facility can be used to prevent such uncontrolled
>  			GPE floodings.
>  			Format: <int>
> +			Support masking of GPEs numbered from 0x00 to 0xff

Why not just say "Format: <byte>" ?

> 
>  	acpi_no_auto_serialize	[HW,ACPI]
>  			Disable auto-serialization of AML methods
> diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
> index 75948a3f1a20..3c3302583d78 100644
> --- a/drivers/acpi/sysfs.c
> +++ b/drivers/acpi/sysfs.c
> @@ -819,14 +819,14 @@ static ssize_t counter_set(struct kobject *kobj,
>   * interface:
>   *   echo unmask > /sys/firmware/acpi/interrupts/gpe00
>   */
> -#define ACPI_MASKABLE_GPE_MAX	0xFF
> +#define ACPI_MASKABLE_GPE_MAX	0x100

So this is the only change that's necessary AFAICS.

>  static DECLARE_BITMAP(acpi_masked_gpes_map, ACPI_MASKABLE_GPE_MAX) __initdata;
> 
>  static int __init acpi_gpe_set_masked_gpes(char *val)
>  {
> -	u8 gpe;
> +	u32 gpe;
> 
> -	if (kstrtou8(val, 0, &gpe) || gpe > ACPI_MASKABLE_GPE_MAX)

And here you can drop the ACPI_MASKABLE_GPE_MAX check and the rest can remain
as is.

> +	if (kstrtouint(val, 0, &gpe) || gpe >= ACPI_MASKABLE_GPE_MAX)
>  		return -EINVAL;
>  	set_bit(gpe, acpi_masked_gpes_map);
> 
> @@ -838,7 +838,7 @@ void __init acpi_gpe_apply_masked_gpes(void)
>  {
>  	acpi_handle handle;
>  	acpi_status status;
> -	u8 gpe;
> +	u32 gpe;
> 
>  	for_each_set_bit(gpe, acpi_masked_gpes_map, ACPI_MASKABLE_GPE_MAX) {
>  		status = acpi_get_gpe_device(gpe, &handle);
> 





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ACPI: sysfs: Change ACPI_MASKABLE_GPE_MAX to 0x100
  2019-11-13 23:21 ` Rafael J. Wysocki
@ 2019-11-14  6:45   ` Yunfeng Ye
  0 siblings, 0 replies; 3+ messages in thread
From: Yunfeng Ye @ 2019-11-14  6:45 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: lenb, linux-acpi, linux-kernel, linux-doc, hushiyuan, linfeilong



On 2019/11/14 7:21, Rafael J. Wysocki wrote:
> On Tuesday, November 5, 2019 3:35:25 PM CET Yunfeng Ye wrote:
>> There are two problems after commit 0f27cff8597d ("ACPI: sysfs: Make
>> ACPI GPE mask kernel parameter cover all GPEs"):
>>
>> 1. ACPI_MASKABLE_GPE_MAX is changed from 0x80 to 0xff, so the check
>> condition "gpe > ACPI_MASKABLE_GPE_MAX" is not valid because the type of
>> gpe is u8.
>>
>> 2. The size of bitmap is ACPI_MASKABLE_GPE_MAX, so it is not support the
>> num 255 for gpe.
>>
>> Update the macro ACPI_MASKABLE_GPE_MAX to 0x100, and change the type of
>> gpe to u32, also modify the checking condition for gpe.
>>
>> Bye the way, update the docs for kernel parameter acpi_mask_gpe.
>>
>> Fixes: 0f27cff8597d ("ACPI: sysfs: Make ACPI GPE mask kernel parameter cover all GPEs")
>> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
> 
> AFAICS this really is about supporting the masking of GPE 0xFF.
>>> ---
>>  Documentation/admin-guide/kernel-parameters.txt | 1 +
>>  drivers/acpi/sysfs.c                            | 8 ++++----
>>  2 files changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
>> index a84a83f8881e..dd878e2491e1 100644
>> --- a/Documentation/admin-guide/kernel-parameters.txt
>> +++ b/Documentation/admin-guide/kernel-parameters.txt
>> @@ -114,6 +114,7 @@
>>  			This facility can be used to prevent such uncontrolled
>>  			GPE floodings.
>>  			Format: <int>
>> +			Support masking of GPEs numbered from 0x00 to 0xff
> 
> Why not just say "Format: <byte>" ?
> 
ok, thanks.

>>
>>  	acpi_no_auto_serialize	[HW,ACPI]
>>  			Disable auto-serialization of AML methods
>> diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
>> index 75948a3f1a20..3c3302583d78 100644
>> --- a/drivers/acpi/sysfs.c
>> +++ b/drivers/acpi/sysfs.c
>> @@ -819,14 +819,14 @@ static ssize_t counter_set(struct kobject *kobj,
>>   * interface:
>>   *   echo unmask > /sys/firmware/acpi/interrupts/gpe00
>>   */
>> -#define ACPI_MASKABLE_GPE_MAX	0xFF
>> +#define ACPI_MASKABLE_GPE_MAX	0x100
> 
> So this is the only change that's necessary AFAICS.
> 
>>  static DECLARE_BITMAP(acpi_masked_gpes_map, ACPI_MASKABLE_GPE_MAX) __initdata;
>>
>>  static int __init acpi_gpe_set_masked_gpes(char *val)
>>  {
>> -	u8 gpe;
>> +	u32 gpe;
>>
>> -	if (kstrtou8(val, 0, &gpe) || gpe > ACPI_MASKABLE_GPE_MAX)
> 
> And here you can drop the ACPI_MASKABLE_GPE_MAX check and the rest can remain
> as is.
> 
I will modify as your suggestion, thanks.

>> +	if (kstrtouint(val, 0, &gpe) || gpe >= ACPI_MASKABLE_GPE_MAX)
>>  		return -EINVAL;
>>  	set_bit(gpe, acpi_masked_gpes_map);
>>
>> @@ -838,7 +838,7 @@ void __init acpi_gpe_apply_masked_gpes(void)
>>  {
>>  	acpi_handle handle;
>>  	acpi_status status;
>> -	u8 gpe;
>> +	u32 gpe;
>>
>>  	for_each_set_bit(gpe, acpi_masked_gpes_map, ACPI_MASKABLE_GPE_MAX) {
>>  		status = acpi_get_gpe_device(gpe, &handle);
>>
> 
> 
> 
> 
> 
> .
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-14  6:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05 14:35 [PATCH] ACPI: sysfs: Change ACPI_MASKABLE_GPE_MAX to 0x100 Yunfeng Ye
2019-11-13 23:21 ` Rafael J. Wysocki
2019-11-14  6:45   ` Yunfeng Ye

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).