From: Dan Carpenter <dan.carpenter@oracle.com>
To: steven@valvesoftware.com
Cc: linux-acpi@vger.kernel.org
Subject: [bug report] ACPI: CPPC: Implement support for SystemIO registers
Date: Tue, 11 Jan 2022 12:29:28 +0300 [thread overview]
Message-ID: <20220111092928.GA24968@kili> (raw)
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
reply other threads:[~2022-01-11 9:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220111092928.GA24968@kili \
--to=dan.carpenter@oracle.com \
--cc=linux-acpi@vger.kernel.org \
--cc=steven@valvesoftware.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 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).