forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/acpi/apei/apei-base.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * apei-base.c - ACPI Platform Error Interface (APEI) supporting
34 * infrastructure
....@@ -15,15 +16,6 @@
1516 *
1617 * Copyright (C) 2009, Intel Corp.
1718 * Author: Huang Ying <ying.huang@intel.com>
18
- *
19
- * This program is free software; you can redistribute it and/or
20
- * modify it under the terms of the GNU General Public License version
21
- * 2 as published by the Free Software Foundation.
22
- *
23
- * This program is distributed in the hope that it will be useful,
24
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
- * GNU General Public License for more details.
2719 */
2820
2921 #include <linux/kernel.h>
....@@ -178,9 +170,9 @@
178170 if (ip == ctx->ip) {
179171 if (entry->instruction >= ctx->instructions ||
180172 !ctx->ins_table[entry->instruction].run) {
181
- pr_warning(FW_WARN APEI_PFX
182
- "Invalid action table, unknown instruction type: %d\n",
183
- entry->instruction);
173
+ pr_warn(FW_WARN APEI_PFX
174
+ "Invalid action table, unknown instruction type: %d\n",
175
+ entry->instruction);
184176 return -EINVAL;
185177 }
186178 run = ctx->ins_table[entry->instruction].run;
....@@ -219,9 +211,9 @@
219211 if (end)
220212 *end = i;
221213 if (ins >= ctx->instructions || !ins_table[ins].run) {
222
- pr_warning(FW_WARN APEI_PFX
223
- "Invalid action table, unknown instruction type: %d\n",
224
- ins);
214
+ pr_warn(FW_WARN APEI_PFX
215
+ "Invalid action table, unknown instruction type: %d\n",
216
+ ins);
225217 return -EINVAL;
226218 }
227219 rc = func(ctx, entry, data);
....@@ -587,18 +579,18 @@
587579 space_id = reg->space_id;
588580 *paddr = get_unaligned(&reg->address);
589581 if (!*paddr) {
590
- pr_warning(FW_BUG APEI_PFX
591
- "Invalid physical address in GAR [0x%llx/%u/%u/%u/%u]\n",
592
- *paddr, bit_width, bit_offset, access_size_code,
593
- space_id);
582
+ pr_warn(FW_BUG APEI_PFX
583
+ "Invalid physical address in GAR [0x%llx/%u/%u/%u/%u]\n",
584
+ *paddr, bit_width, bit_offset, access_size_code,
585
+ space_id);
594586 return -EINVAL;
595587 }
596588
597589 if (access_size_code < 1 || access_size_code > 4) {
598
- pr_warning(FW_BUG APEI_PFX
599
- "Invalid access size code in GAR [0x%llx/%u/%u/%u/%u]\n",
600
- *paddr, bit_width, bit_offset, access_size_code,
601
- space_id);
590
+ pr_warn(FW_BUG APEI_PFX
591
+ "Invalid access size code in GAR [0x%llx/%u/%u/%u/%u]\n",
592
+ *paddr, bit_width, bit_offset, access_size_code,
593
+ space_id);
602594 return -EINVAL;
603595 }
604596 *access_bit_width = 1UL << (access_size_code + 2);
....@@ -612,19 +604,19 @@
612604 *access_bit_width = 64;
613605
614606 if ((bit_width + bit_offset) > *access_bit_width) {
615
- pr_warning(FW_BUG APEI_PFX
616
- "Invalid bit width + offset in GAR [0x%llx/%u/%u/%u/%u]\n",
617
- *paddr, bit_width, bit_offset, access_size_code,
618
- space_id);
607
+ pr_warn(FW_BUG APEI_PFX
608
+ "Invalid bit width + offset in GAR [0x%llx/%u/%u/%u/%u]\n",
609
+ *paddr, bit_width, bit_offset, access_size_code,
610
+ space_id);
619611 return -EINVAL;
620612 }
621613
622614 if (space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY &&
623615 space_id != ACPI_ADR_SPACE_SYSTEM_IO) {
624
- pr_warning(FW_BUG APEI_PFX
625
- "Invalid address space type in GAR [0x%llx/%u/%u/%u/%u]\n",
626
- *paddr, bit_width, bit_offset, access_size_code,
627
- space_id);
616
+ pr_warn(FW_BUG APEI_PFX
617
+ "Invalid address space type in GAR [0x%llx/%u/%u/%u/%u]\n",
618
+ *paddr, bit_width, bit_offset, access_size_code,
619
+ space_id);
628620 return -EINVAL;
629621 }
630622
....@@ -640,7 +632,15 @@
640632 rc = apei_check_gar(reg, &address, &access_bit_width);
641633 if (rc)
642634 return rc;
643
- return acpi_os_map_generic_address(reg);
635
+
636
+ /* IO space doesn't need mapping */
637
+ if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO)
638
+ return 0;
639
+
640
+ if (!acpi_os_map_generic_address(reg))
641
+ return -ENXIO;
642
+
643
+ return 0;
644644 }
645645 EXPORT_SYMBOL_GPL(apei_map_generic_address);
646646