diff options
author | Lv Zheng <lv.zheng@intel.com> | 2014-05-20 03:39:41 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-05-27 12:13:08 -0400 |
commit | a238317ce8185519ed083e81e84260907fbbcf7f (patch) | |
tree | f5b228ac40941946db2e7427b1085a90c78c85b5 /drivers/acpi/apei/einj.c | |
parent | 92985ef1db428cc6129a1d375a68c277aa05820b (diff) |
ACPI: Clean up acpi_os_map/unmap_memory() to eliminate __iomem.
ACPICA doesn't include protections around address space checking, Linux
build tests always complain increased sparse warnings around ACPICA
internal acpi_os_map/unmap_memory() invocations. This patch tries to fix
this issue permanently.
There are 2 choices left for us to solve this issue:
1. Add __iomem address space awareness into ACPICA.
2. Remove sparse checker of __iomem from ACPICA source code.
This patch chooses solution 2, because:
1. Most of the acpi_os_map/unmap_memory() invocations are used for ACPICA.
table mappings, which in fact are not IO addresses.
2. The only IO addresses usage is for "system memory space" mapping code in:
drivers/acpi/acpica/exregion.c
drivers/acpi/acpica/evrgnini.c
drivers/acpi/acpica/exregion.c
The mapped address is accessed in the handler of "system memory space"
- acpi_ex_system_memory_space_handler(). This function in fact can be
changed to invoke acpi_os_read/write_memory() so that __iomem can
always be type-casted in the OSL layer.
According to the above investigation, we drew the following conclusion:
It is not a good idea to introduce __iomem address space awareness into
ACPICA mostly in order to protect non-IO addresses.
We can simply remove __iomem for acpi_os_map/unmap_memory() to remove
__iomem checker for ACPICA code. Then we need to enforce external usages
to invoke other APIs that are aware of __iomem address space.
The external usages are:
drivers/acpi/apei/einj.c
drivers/acpi/acpi_extlog.c
drivers/char/tpm/tpm_acpi.c
drivers/acpi/nvs.c
This patch thus performs cleanups in this way:
1. Add acpi_os_map/unmap_iomem() to be invoked by non-ACPICA code.
2. Remove __iomem from acpi_os_map/unmap_memory().
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/apei/einj.c')
-rw-r--r-- | drivers/acpi/apei/einj.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c index 1be6f5564485..a095d4f858da 100644 --- a/drivers/acpi/apei/einj.c +++ b/drivers/acpi/apei/einj.c | |||
@@ -202,7 +202,7 @@ static void check_vendor_extension(u64 paddr, | |||
202 | 202 | ||
203 | if (!offset) | 203 | if (!offset) |
204 | return; | 204 | return; |
205 | v = acpi_os_map_memory(paddr + offset, sizeof(*v)); | 205 | v = acpi_os_map_iomem(paddr + offset, sizeof(*v)); |
206 | if (!v) | 206 | if (!v) |
207 | return; | 207 | return; |
208 | sbdf = v->pcie_sbdf; | 208 | sbdf = v->pcie_sbdf; |
@@ -210,7 +210,7 @@ static void check_vendor_extension(u64 paddr, | |||
210 | sbdf >> 24, (sbdf >> 16) & 0xff, | 210 | sbdf >> 24, (sbdf >> 16) & 0xff, |
211 | (sbdf >> 11) & 0x1f, (sbdf >> 8) & 0x7, | 211 | (sbdf >> 11) & 0x1f, (sbdf >> 8) & 0x7, |
212 | v->vendor_id, v->device_id, v->rev_id); | 212 | v->vendor_id, v->device_id, v->rev_id); |
213 | acpi_os_unmap_memory(v, sizeof(*v)); | 213 | acpi_os_unmap_iomem(v, sizeof(*v)); |
214 | } | 214 | } |
215 | 215 | ||
216 | static void *einj_get_parameter_address(void) | 216 | static void *einj_get_parameter_address(void) |
@@ -236,7 +236,7 @@ static void *einj_get_parameter_address(void) | |||
236 | if (pa_v5) { | 236 | if (pa_v5) { |
237 | struct set_error_type_with_address *v5param; | 237 | struct set_error_type_with_address *v5param; |
238 | 238 | ||
239 | v5param = acpi_os_map_memory(pa_v5, sizeof(*v5param)); | 239 | v5param = acpi_os_map_iomem(pa_v5, sizeof(*v5param)); |
240 | if (v5param) { | 240 | if (v5param) { |
241 | acpi5 = 1; | 241 | acpi5 = 1; |
242 | check_vendor_extension(pa_v5, v5param); | 242 | check_vendor_extension(pa_v5, v5param); |
@@ -246,11 +246,11 @@ static void *einj_get_parameter_address(void) | |||
246 | if (param_extension && pa_v4) { | 246 | if (param_extension && pa_v4) { |
247 | struct einj_parameter *v4param; | 247 | struct einj_parameter *v4param; |
248 | 248 | ||
249 | v4param = acpi_os_map_memory(pa_v4, sizeof(*v4param)); | 249 | v4param = acpi_os_map_iomem(pa_v4, sizeof(*v4param)); |
250 | if (!v4param) | 250 | if (!v4param) |
251 | return NULL; | 251 | return NULL; |
252 | if (v4param->reserved1 || v4param->reserved2) { | 252 | if (v4param->reserved1 || v4param->reserved2) { |
253 | acpi_os_unmap_memory(v4param, sizeof(*v4param)); | 253 | acpi_os_unmap_iomem(v4param, sizeof(*v4param)); |
254 | return NULL; | 254 | return NULL; |
255 | } | 255 | } |
256 | return v4param; | 256 | return v4param; |
@@ -794,7 +794,7 @@ err_unmap: | |||
794 | sizeof(struct set_error_type_with_address) : | 794 | sizeof(struct set_error_type_with_address) : |
795 | sizeof(struct einj_parameter); | 795 | sizeof(struct einj_parameter); |
796 | 796 | ||
797 | acpi_os_unmap_memory(einj_param, size); | 797 | acpi_os_unmap_iomem(einj_param, size); |
798 | } | 798 | } |
799 | apei_exec_post_unmap_gars(&ctx); | 799 | apei_exec_post_unmap_gars(&ctx); |
800 | err_release: | 800 | err_release: |
@@ -816,7 +816,7 @@ static void __exit einj_exit(void) | |||
816 | sizeof(struct set_error_type_with_address) : | 816 | sizeof(struct set_error_type_with_address) : |
817 | sizeof(struct einj_parameter); | 817 | sizeof(struct einj_parameter); |
818 | 818 | ||
819 | acpi_os_unmap_memory(einj_param, size); | 819 | acpi_os_unmap_iomem(einj_param, size); |
820 | } | 820 | } |
821 | einj_exec_ctx_init(&ctx); | 821 | einj_exec_ctx_init(&ctx); |
822 | apei_exec_post_unmap_gars(&ctx); | 822 | apei_exec_post_unmap_gars(&ctx); |