* [bug report] ACPI: CPPC: Implement support for SystemIO registers
@ 2022-01-11 9:29 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-01-11 9:29 UTC (permalink / raw)
To: steven; +Cc: linux-acpi
Hello Steven Noonan,
The patch a2c8f92bea5f: "ACPI: CPPC: Implement support for SystemIO
registers" from Dec 24, 2021, leads to the following Smatch static
checker warning:
drivers/acpi/cppc_acpi.c:935 cpc_read()
warn: passing casted pointer 'val' to 'acpi_os_read_port()' 64 vs 32.
drivers/acpi/cppc_acpi.c
916 static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val)
917 {
918 int ret_val = 0;
919 void __iomem *vaddr = NULL;
920 int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
921 struct cpc_reg *reg = ®_res->cpc_entry.reg;
922
923 if (reg_res->type == ACPI_TYPE_INTEGER) {
924 *val = reg_res->cpc_entry.int_value;
925 return ret_val;
926 }
927
928 *val = 0;
929
930 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
931 u32 width = 8 << (reg->access_width - 1);
932 acpi_status status;
933
934 status = acpi_os_read_port((acpi_io_address)reg->address,
--> 935 (u32 *)val, width);
^^^^^^^^^^
This code will not work on big endian systems. You need to pass a real
&u32_tmp and then to *val = u32_tmp;
936 if (ACPI_FAILURE(status)) {
937 pr_debug("Error: Failed to read SystemIO port %llx\n",
938 reg->address);
939 return -EFAULT;
940 }
941
942 return 0;
943 } else if (reg->space_id == ACPI_ADR_SPACE_PLATFORM_COMM && pcc_ss_id >= 0)
944 vaddr = GET_PCC_VADDR(reg->address, pcc_ss_id);
945 else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
946 vaddr = reg_res->sys_mem_vaddr;
947 else if (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE)
948 return cpc_read_ffh(cpu, reg, val);
949 else
950 return acpi_os_read_memory((acpi_physical_address)reg->address,
951 val, reg->bit_width);
952
regards,
dan carpenter
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-11 9:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-11 9:29 [bug report] ACPI: CPPC: Implement support for SystemIO registers Dan Carpenter
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).