2021-01-07 11:21:00

by Ionela Voinescu

[permalink] [raw]
Subject: [PATCH 0/3] acpi: cppc_acpi: fix sparse warnings

Hi guys,

These patches just fix some trivial sparse warnings.

Hope they help,
Ionela.

Ionela Voinescu (3):
acpi: cppc_acpi: remove __iomem annotation for cpc_reg's address
acpi: cppc_acpi: add __iomem annotation to generic_comm_base pointer
acpi: cppc_acpi: initialise vaddr pointers to NULL

drivers/acpi/cppc_acpi.c | 8 ++++----
include/acpi/cppc_acpi.h | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)


base-commit: e71ba9452f0b5b2e8dc8aa5445198cd9214a6a62
--
2.29.2.dirty


2021-01-07 11:21:08

by Ionela Voinescu

[permalink] [raw]
Subject: [PATCH 1/3] acpi: cppc_acpi: remove __iomem annotation for cpc_reg's address

The cpc_reg address does not represent either an I/O virtual address,
nor a field located in iomem. This address is used as an address offset
which eventually is given as physical address argument to ioremap or PCC
space offset to GET_PCC_VADDR. Therefore, having the __iomem annotation
does not make sense.

Fix the following sparse warnings by removing the __iomem annotation
for cpc_reg's address.

drivers/acpi/cppc_acpi.c:762:37: warning: dereference of noderef expression
drivers/acpi/cppc_acpi.c:765:48: warning: dereference of noderef expression
drivers/acpi/cppc_acpi.c:948:25: warning: dereference of noderef expression
drivers/acpi/cppc_acpi.c:954:67: warning: dereference of noderef expression
drivers/acpi/cppc_acpi.c:987:25: warning: dereference of noderef expression
drivers/acpi/cppc_acpi.c:993:68: warning: dereference of noderef expression
drivers/acpi/cppc_acpi.c:1120:13: warning: dereference of noderef expression
drivers/acpi/cppc_acpi.c:1134:13: warning: dereference of noderef expression
drivers/acpi/cppc_acpi.c:1137:13: warning: dereference of noderef expression
drivers/acpi/cppc_acpi.c:1182:14: warning: dereference of noderef expression
drivers/acpi/cppc_acpi.c:1212:13: warning: dereference of noderef expression

Suggested-by: Al Viro <[email protected]>
Signed-off-by: Ionela Voinescu <[email protected]>
Cc: Robert Moore <[email protected]>
Cc: Erik Kaneda <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
---
include/acpi/cppc_acpi.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h
index 232838d28f50..c7fc4524e151 100644
--- a/include/acpi/cppc_acpi.h
+++ b/include/acpi/cppc_acpi.h
@@ -39,7 +39,7 @@ struct cpc_reg {
u8 bit_width;
u8 bit_offset;
u8 access_width;
- u64 __iomem address;
+ u64 address;
} __packed;

/*
--
2.29.2.dirty

2021-01-07 11:21:14

by Ionela Voinescu

[permalink] [raw]
Subject: [PATCH 2/3] acpi: cppc_acpi: add __iomem annotation to generic_comm_base pointer

ppc_comm_addr is a virtual address to the PCC space and it's annotated
with __iomem. Therefore, generic_comm_base which gets assigned the value of
pcc_comm_address should be annotated as well.

This already happens in check_pcc_chan(), but not in send_pcc_cmd(), which
results in the following sparse warnings:

drivers/acpi/cppc_acpi.c:237:18: warning: cast removes address space '__iomem' of expression
drivers/acpi/cppc_acpi.c:299:9: warning: incorrect type in argument 2 (different address spaces)
drivers/acpi/cppc_acpi.c:299:9: expected void volatile [noderef] __iomem *addr
drivers/acpi/cppc_acpi.c:299:9: got unsigned short *
drivers/acpi/cppc_acpi.c:302:9: warning: incorrect type in argument 2 (different address spaces)
drivers/acpi/cppc_acpi.c:302:9: expected void volatile [noderef] __iomem *addr
drivers/acpi/cppc_acpi.c:302:9: got unsigned short *

Signed-off-by: Ionela Voinescu <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
Cc: Len Brown <[email protected]>
---
drivers/acpi/cppc_acpi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 75aaf94ae0a9..fd71020f5d5f 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -233,8 +233,8 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd)
{
int ret = -EIO, i;
struct cppc_pcc_data *pcc_ss_data = pcc_data[pcc_ss_id];
- struct acpi_pcct_shared_memory *generic_comm_base =
- (struct acpi_pcct_shared_memory *)pcc_ss_data->pcc_comm_addr;
+ struct acpi_pcct_shared_memory __iomem *generic_comm_base =
+ pcc_ss_data->pcc_comm_addr;
unsigned int time_delta;

/*
--
2.29.2.dirty

2021-01-07 11:22:43

by Ionela Voinescu

[permalink] [raw]
Subject: [PATCH 3/3] acpi: cppc_acpi: initialise vaddr pointers to NULL

Properly initialise vaddr pointers in cpc_read() and cpc_write() to
NULL instead of 0.

This fixes the following sparse warnings:
drivers/acpi/cppc_acpi.c:937:31: warning: Using plain integer as NULL pointer
drivers/acpi/cppc_acpi.c:982:31: warning: Using plain integer as NULL pointer

Signed-off-by: Ionela Voinescu <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
Cc: Len Brown <[email protected]>
---
drivers/acpi/cppc_acpi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index fd71020f5d5f..69057fcd2c04 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -934,7 +934,7 @@ int __weak cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val)
static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val)
{
int ret_val = 0;
- void __iomem *vaddr = 0;
+ void __iomem *vaddr = NULL;
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
struct cpc_reg *reg = &reg_res->cpc_entry.reg;

@@ -979,7 +979,7 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val)
static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
{
int ret_val = 0;
- void __iomem *vaddr = 0;
+ void __iomem *vaddr = NULL;
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
struct cpc_reg *reg = &reg_res->cpc_entry.reg;

--
2.29.2.dirty

2021-01-22 15:34:32

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 0/3] acpi: cppc_acpi: fix sparse warnings

On Thu, Jan 7, 2021 at 12:19 PM Ionela Voinescu <[email protected]> wrote:
>
> Hi guys,
>
> These patches just fix some trivial sparse warnings.
>
> Hope they help,
> Ionela.
>
> Ionela Voinescu (3):
> acpi: cppc_acpi: remove __iomem annotation for cpc_reg's address
> acpi: cppc_acpi: add __iomem annotation to generic_comm_base pointer
> acpi: cppc_acpi: initialise vaddr pointers to NULL
>
> drivers/acpi/cppc_acpi.c | 8 ++++----
> include/acpi/cppc_acpi.h | 2 +-
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
>
> base-commit: e71ba9452f0b5b2e8dc8aa5445198cd9214a6a62
> --

All patches in the series applied as 5.12 material with some minor
edits in the subjects, thanks!