diff mbox series

[1/2] RAS: ACPI: APEI: add conditional compilation to ARM error report functions

Message ID 95baa46a5e1c88f08e328dbbfbbd01602e092234.1719471257.git.mchehab+huawei@kernel.org
State Superseded
Headers show
Series Add other fields to ARM trace event | expand

Commit Message

Mauro Carvalho Chehab June 27, 2024, 7:01 a.m. UTC
From: Daniel Ferguson <danielf@os.amperecomputing.com>

This prevents the unnecessary inclusion of ARM specific RAS error
handling routines in non-ARM platforms.

[mchehab: avoid unneeded ifdefs and fix coding style issues]
Signed-off-by: Daniel Ferguson <danielf@os.amperecomputing.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/acpi/apei/ghes.c | 11 +++++------
 drivers/ras/ras.c        |  2 ++
 2 files changed, 7 insertions(+), 6 deletions(-)

Comments

Mauro Carvalho Chehab June 27, 2024, 10:31 a.m. UTC | #1
Em Thu, 27 Jun 2024 09:50:34 +0200
Borislav Petkov <bp@alien8.de> escreveu:

> On Thu, Jun 27, 2024 at 09:01:08AM +0200, Mauro Carvalho Chehab wrote:
> > @@ -570,7 +571,7 @@ static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
> >  				    error_type);
> >  		p += err_info->length;
> >  	}
> > -
> > +#endif
> >  	return queued;  
> 
> The previous version I saw, had it right. "queued" was outside the ifdeffery:
> 
> drivers/acpi/apei/ghes.c: In function ‘ghes_handle_arm_hw_error’:
> drivers/acpi/apei/ghes.c:575:16: error: ‘queued’ undeclared (first use in this function)
>   575 |         return queued;
>       |                ^~~~~~
> drivers/acpi/apei/ghes.c:575:16: note: each undeclared identifier is reported only once for each function it appears in
> drivers/acpi/apei/ghes.c:576:1: error: control reaches end of non-void function [-Werror=return-type]
>   576 | }
>       | ^
> cc1: some warnings being treated as errors
> make[5]: *** [scripts/Makefile.build:244: drivers/acpi/apei/ghes.o] Error 1
> make[4]: *** [scripts/Makefile.build:485: drivers/acpi/apei] Error 2
> make[4]: *** Waiting for unfinished jobs....
> make[3]: *** [scripts/Makefile.build:485: drivers/acpi] Error 2
> make[3]: *** Waiting for unfinished jobs....
> make[2]: *** [scripts/Makefile.build:485: drivers] Error 2
> make[2]: *** Waiting for unfinished jobs....
> make[1]: *** [/mnt/kernel/kernel/2nd/linux/Makefile:1934: .] Error 2
> make: *** [Makefile:240: __sub-make] Error 2


Sorry, bad conflict resolution during rebase. Will send a v2.


Thanks,
Mauro
kernel test robot June 28, 2024, 4:46 a.m. UTC | #2
Hi Mauro,

kernel test robot noticed the following build errors:

[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on rafael-pm/bleeding-edge linus/master v6.10-rc5 next-20240627]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mauro-Carvalho-Chehab/RAS-ACPI-APEI-add-conditional-compilation-to-ARM-error-report-functions/20240627-225843
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/95baa46a5e1c88f08e328dbbfbbd01602e092234.1719471257.git.mchehab%2Bhuawei%40kernel.org
patch subject: [PATCH 1/2] RAS: ACPI: APEI: add conditional compilation to ARM error report functions
config: x86_64-buildonly-randconfig-003-20240628 (https://download.01.org/0day-ci/archive/20240628/202406281232.xTKmzO76-lkp@intel.com/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240628/202406281232.xTKmzO76-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406281232.xTKmzO76-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   drivers/acpi/apei/ghes.c: In function 'ghes_handle_arm_hw_error':
>> drivers/acpi/apei/ghes.c:575:16: error: 'queued' undeclared (first use in this function)
     575 |         return queued;
         |                ^~~~~~
   drivers/acpi/apei/ghes.c:575:16: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/acpi/apei/ghes.c:576:1: warning: control reaches end of non-void function [-Wreturn-type]
     576 | }
         | ^


vim +/queued +575 drivers/acpi/apei/ghes.c

7f17b4a121d0d5 James Morse     2020-05-01  530  
a70297d2213253 Shuai Xue       2023-12-18  531  static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
a70297d2213253 Shuai Xue       2023-12-18  532  				     int sev, bool sync)
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  533  {
4a485d7f807462 Daniel Ferguson 2024-06-27  534  #if defined(CONFIG_ARM) || defined (CONFIG_ARM64)
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  535  	struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata);
a70297d2213253 Shuai Xue       2023-12-18  536  	int flags = sync ? MF_ACTION_REQUIRED : 0;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  537  	bool queued = false;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  538  	int sec_sev, i;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  539  	char *p;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  540  
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  541  	log_arm_hw_error(err);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  542  
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  543  	sec_sev = ghes_severity(gdata->error_severity);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  544  	if (sev != GHES_SEV_RECOVERABLE || sec_sev != GHES_SEV_RECOVERABLE)
7f17b4a121d0d5 James Morse     2020-05-01  545  		return false;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  546  
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  547  	p = (char *)(err + 1);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  548  	for (i = 0; i < err->err_info_num; i++) {
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  549  		struct cper_arm_err_info *err_info = (struct cper_arm_err_info *)p;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  550  		bool is_cache = (err_info->type == CPER_ARM_CACHE_ERROR);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  551  		bool has_pa = (err_info->validation_bits & CPER_ARM_INFO_VALID_PHYSICAL_ADDR);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  552  		const char *error_type = "unknown error";
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  553  
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  554  		/*
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  555  		 * The field (err_info->error_info & BIT(26)) is fixed to set to
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  556  		 * 1 in some old firmware of HiSilicon Kunpeng920. We assume that
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  557  		 * firmware won't mix corrected errors in an uncorrected section,
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  558  		 * and don't filter out 'corrected' error here.
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  559  		 */
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  560  		if (is_cache && has_pa) {
a70297d2213253 Shuai Xue       2023-12-18  561  			queued = ghes_do_memory_failure(err_info->physical_fault_addr, flags);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  562  			p += err_info->length;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  563  			continue;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  564  		}
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  565  
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  566  		if (err_info->type < ARRAY_SIZE(cper_proc_error_type_strs))
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  567  			error_type = cper_proc_error_type_strs[err_info->type];
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  568  
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  569  		pr_warn_ratelimited(FW_WARN GHES_PFX
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  570  				    "Unhandled processor error type: %s\n",
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  571  				    error_type);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  572  		p += err_info->length;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  573  	}
4a485d7f807462 Daniel Ferguson 2024-06-27  574  #endif
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11 @575  	return queued;
cf870c70a19444 Naveen N. Rao   2013-07-10 @576  }
cf870c70a19444 Naveen N. Rao   2013-07-10  577
kernel test robot June 28, 2024, 6:04 a.m. UTC | #3
Hi Mauro,

kernel test robot noticed the following build errors:

[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on rafael-pm/bleeding-edge linus/master v6.10-rc5 next-20240627]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mauro-Carvalho-Chehab/RAS-ACPI-APEI-add-conditional-compilation-to-ARM-error-report-functions/20240627-225843
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/95baa46a5e1c88f08e328dbbfbbd01602e092234.1719471257.git.mchehab%2Bhuawei%40kernel.org
patch subject: [PATCH 1/2] RAS: ACPI: APEI: add conditional compilation to ARM error report functions
config: x86_64-randconfig-161-20240628 (https://download.01.org/0day-ci/archive/20240628/202406281337.j4rbN9nr-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240628/202406281337.j4rbN9nr-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406281337.j4rbN9nr-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/acpi/apei/ghes.c:575:9: error: use of undeclared identifier 'queued'
     575 |         return queued;
         |                ^
   1 error generated.


vim +/queued +575 drivers/acpi/apei/ghes.c

7f17b4a121d0d5 James Morse     2020-05-01  530  
a70297d2213253 Shuai Xue       2023-12-18  531  static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
a70297d2213253 Shuai Xue       2023-12-18  532  				     int sev, bool sync)
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  533  {
4a485d7f807462 Daniel Ferguson 2024-06-27  534  #if defined(CONFIG_ARM) || defined (CONFIG_ARM64)
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  535  	struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata);
a70297d2213253 Shuai Xue       2023-12-18  536  	int flags = sync ? MF_ACTION_REQUIRED : 0;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  537  	bool queued = false;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  538  	int sec_sev, i;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  539  	char *p;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  540  
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  541  	log_arm_hw_error(err);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  542  
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  543  	sec_sev = ghes_severity(gdata->error_severity);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  544  	if (sev != GHES_SEV_RECOVERABLE || sec_sev != GHES_SEV_RECOVERABLE)
7f17b4a121d0d5 James Morse     2020-05-01  545  		return false;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  546  
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  547  	p = (char *)(err + 1);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  548  	for (i = 0; i < err->err_info_num; i++) {
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  549  		struct cper_arm_err_info *err_info = (struct cper_arm_err_info *)p;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  550  		bool is_cache = (err_info->type == CPER_ARM_CACHE_ERROR);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  551  		bool has_pa = (err_info->validation_bits & CPER_ARM_INFO_VALID_PHYSICAL_ADDR);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  552  		const char *error_type = "unknown error";
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  553  
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  554  		/*
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  555  		 * The field (err_info->error_info & BIT(26)) is fixed to set to
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  556  		 * 1 in some old firmware of HiSilicon Kunpeng920. We assume that
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  557  		 * firmware won't mix corrected errors in an uncorrected section,
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  558  		 * and don't filter out 'corrected' error here.
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  559  		 */
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  560  		if (is_cache && has_pa) {
a70297d2213253 Shuai Xue       2023-12-18  561  			queued = ghes_do_memory_failure(err_info->physical_fault_addr, flags);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  562  			p += err_info->length;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  563  			continue;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  564  		}
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  565  
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  566  		if (err_info->type < ARRAY_SIZE(cper_proc_error_type_strs))
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  567  			error_type = cper_proc_error_type_strs[err_info->type];
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  568  
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  569  		pr_warn_ratelimited(FW_WARN GHES_PFX
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  570  				    "Unhandled processor error type: %s\n",
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  571  				    error_type);
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  572  		p += err_info->length;
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11  573  	}
4a485d7f807462 Daniel Ferguson 2024-06-27  574  #endif
ccb5ecdc2ddeaf Xiaofei Tan     2021-06-11 @575  	return queued;
cf870c70a19444 Naveen N. Rao   2013-07-10  576  }
cf870c70a19444 Naveen N. Rao   2013-07-10  577
diff mbox series

Patch

diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 623cc0cb4a65..25f876b8fa4c 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -529,8 +529,9 @@  static bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata,
 }
 
 static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
-				       int sev, bool sync)
+				     int sev, bool sync)
 {
+#if defined(CONFIG_ARM) || defined (CONFIG_ARM64)
 	struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata);
 	int flags = sync ? MF_ACTION_REQUIRED : 0;
 	bool queued = false;
@@ -570,7 +571,7 @@  static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
 				    error_type);
 		p += err_info->length;
 	}
-
+#endif
 	return queued;
 }
 
@@ -773,11 +774,9 @@  static bool ghes_do_proc(struct ghes *ghes,
 
 			arch_apei_report_mem_error(sev, mem_err);
 			queued = ghes_handle_memory_failure(gdata, sev, sync);
-		}
-		else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
+		} else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
 			ghes_handle_aer(gdata);
-		}
-		else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) {
+		} else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) {
 			queued = ghes_handle_arm_hw_error(gdata, sev, sync);
 		} else if (guid_equal(sec_type, &CPER_SEC_CXL_GEN_MEDIA_GUID)) {
 			struct cxl_cper_event_rec *rec = acpi_hest_get_payload(gdata);
diff --git a/drivers/ras/ras.c b/drivers/ras/ras.c
index a6e4792a1b2e..5d94ab79c8c3 100644
--- a/drivers/ras/ras.c
+++ b/drivers/ras/ras.c
@@ -54,7 +54,9 @@  void log_non_standard_event(const guid_t *sec_type, const guid_t *fru_id,
 
 void log_arm_hw_error(struct cper_sec_proc_arm *err)
 {
+#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
 	trace_arm_event(err);
+#endif
 }
 
 static int __init ras_init(void)