diff mbox

powerpc/fadump: return error when fadump registration fails

Message ID 20170524184812.5122-1-msuchanek@suse.de (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Michal Suchanek May 24, 2017, 6:48 p.m. UTC
- log an error message when registration fails and no error code listed
 in the switch is returned
 - translate the hv error code to posix error code and return it from
 fw_register
 - return the posix error code from fw_register to the process writing
 to sysfs
 - return EEXIST on re-registration
 - return success on deregistration when fadump is not registered

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 arch/powerpc/kernel/fadump.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

Comments

kernel test robot May 25, 2017, 7:16 a.m. UTC | #1
Hi Michal,

[auto build test WARNING on powerpc/next]
[also build test WARNING on v4.12-rc2 next-20170525]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Michal-Suchanek/powerpc-fadump-return-error-when-fadump-registration-fails/20170525-083625
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-allmodconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=powerpc 

All warnings (new ones prefixed by >>):

   arch/powerpc/kernel/fadump.c: In function 'register_fadump':
>> arch/powerpc/kernel/fadump.c:978:3: warning: 'return' with no value, in function returning non-void [-Wreturn-type]
      return;
      ^~~~~~
   arch/powerpc/kernel/fadump.c:968:12: note: declared here
    static int register_fadump(void)
               ^~~~~~~~~~~~~~~

vim +/return +978 arch/powerpc/kernel/fadump.c

ebaeb5ae Mahesh Salgaonkar 2012-02-16  962  	/* We will set the crashing cpu id in crash_fadump() during crash. */
ebaeb5ae Mahesh Salgaonkar 2012-02-16  963  	fdh->crashing_cpu = CPU_UNKNOWN;
2df173d9 Mahesh Salgaonkar 2012-02-16  964  
2df173d9 Mahesh Salgaonkar 2012-02-16  965  	return addr;
2df173d9 Mahesh Salgaonkar 2012-02-16  966  }
2df173d9 Mahesh Salgaonkar 2012-02-16  967  
c87372ca Michal Suchanek   2017-05-24  968  static int register_fadump(void)
3ccc00a7 Mahesh Salgaonkar 2012-02-20  969  {
2df173d9 Mahesh Salgaonkar 2012-02-16  970  	unsigned long addr;
2df173d9 Mahesh Salgaonkar 2012-02-16  971  	void *vaddr;
2df173d9 Mahesh Salgaonkar 2012-02-16  972  
3ccc00a7 Mahesh Salgaonkar 2012-02-20  973  	/*
3ccc00a7 Mahesh Salgaonkar 2012-02-20  974  	 * If no memory is reserved then we can not register for firmware-
3ccc00a7 Mahesh Salgaonkar 2012-02-20  975  	 * assisted dump.
3ccc00a7 Mahesh Salgaonkar 2012-02-20  976  	 */
3ccc00a7 Mahesh Salgaonkar 2012-02-20  977  	if (!fw_dump.reserve_dump_area_size)
3ccc00a7 Mahesh Salgaonkar 2012-02-20 @978  		return;
3ccc00a7 Mahesh Salgaonkar 2012-02-20  979  
2df173d9 Mahesh Salgaonkar 2012-02-16  980  	fadump_setup_crash_memory_ranges();
2df173d9 Mahesh Salgaonkar 2012-02-16  981  
408cddd9 Hari Bathini      2014-10-01  982  	addr = be64_to_cpu(fdm.rmr_region.destination_address) + be64_to_cpu(fdm.rmr_region.source_len);
2df173d9 Mahesh Salgaonkar 2012-02-16  983  	/* Initialize fadump crash info header. */
2df173d9 Mahesh Salgaonkar 2012-02-16  984  	addr = init_fadump_header(addr);
2df173d9 Mahesh Salgaonkar 2012-02-16  985  	vaddr = __va(addr);
2df173d9 Mahesh Salgaonkar 2012-02-16  986  

:::::: The code at line 978 was first introduced by commit
:::::: 3ccc00a7e04ff7718c9aebb4b0c982571c798759 fadump: Register for firmware assisted dump.

:::::: TO: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
:::::: CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 2fa582092d42..01bc4e56e52f 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -398,9 +398,9 @@  static int __init early_fadump_param(char *p)
 }
 early_param("fadump", early_fadump_param);
 
-static void register_fw_dump(struct fadump_mem_struct *fdm)
+static int register_fw_dump(struct fadump_mem_struct *fdm)
 {
-	int rc;
+	int rc, err;
 	unsigned int wait_time;
 
 	pr_debug("Registering for firmware-assisted kernel dump...\n");
@@ -417,7 +417,12 @@  static void register_fw_dump(struct fadump_mem_struct *fdm)
 
 	} while (wait_time);
 
+	err = -EIO;
 	switch (rc) {
+	default:
+		printk(KERN_ERR "Failed to register firmware-assisted kernel"
+			" dump. Unknown Error(%d).\n", rc);
+		break;
 	case -1:
 		printk(KERN_ERR "Failed to register firmware-assisted kernel"
 			" dump. Hardware Error(%d).\n", rc);
@@ -425,18 +430,22 @@  static void register_fw_dump(struct fadump_mem_struct *fdm)
 	case -3:
 		printk(KERN_ERR "Failed to register firmware-assisted kernel"
 			" dump. Parameter Error(%d).\n", rc);
+		err = -EINVAL;
 		break;
 	case -9:
 		printk(KERN_ERR "firmware-assisted kernel dump is already "
 			" registered.");
 		fw_dump.dump_registered = 1;
+		err = -EEXIST;
 		break;
 	case 0:
 		printk(KERN_INFO "firmware-assisted kernel dump registration"
 			" is successful\n");
 		fw_dump.dump_registered = 1;
+		err = 0;
 		break;
 	}
+	return err;
 }
 
 void crash_fadump(struct pt_regs *regs, const char *str)
@@ -977,7 +986,7 @@  static unsigned long init_fadump_header(unsigned long addr)
 	return addr;
 }
 
-static void register_fadump(void)
+static int register_fadump(void)
 {
 	unsigned long addr;
 	void *vaddr;
@@ -1000,7 +1009,7 @@  static void register_fadump(void)
 	fadump_create_elfcore_headers(vaddr);
 
 	/* register the future kernel dump with firmware. */
-	register_fw_dump(&fdm);
+	return register_fw_dump(&fdm);
 }
 
 static int fadump_unregister_dump(struct fadump_mem_struct *fdm)
@@ -1182,7 +1191,6 @@  static ssize_t fadump_register_store(struct kobject *kobj,
 	switch (buf[0]) {
 	case '0':
 		if (fw_dump.dump_registered == 0) {
-			ret = -EINVAL;
 			goto unlock_out;
 		}
 		/* Un-register Firmware-assisted dump */
@@ -1190,11 +1198,11 @@  static ssize_t fadump_register_store(struct kobject *kobj,
 		break;
 	case '1':
 		if (fw_dump.dump_registered == 1) {
-			ret = -EINVAL;
+			ret = -EEXIST;
 			goto unlock_out;
 		}
 		/* Register Firmware-assisted dump */
-		register_fadump();
+		ret = register_fadump();
 		break;
 	default:
 		ret = -EINVAL;