Commit 7ae46a53 authored by Michal Suchanek's avatar Michal Suchanek Committed by Kleber Sacilotto de Souza

powerpc/fadump: Return error when fadump registration fails

BugLink: https://bugs.launchpad.net/bugs/1795662

 - 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
 - return ENODEV when no memory is reserved for fadump
Signed-off-by: default avatarMichal Suchanek <msuchanek@suse.de>
Tested-by: default avatarHari Bathini <hbathini@linux.vnet.ibm.com>
[mpe: Use pr_err() to shrink the error print]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
(backported from commit 98b8cd7f)
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
Acked-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 7f9d019c
...@@ -360,9 +360,9 @@ static int __init early_fadump_reserve_mem(char *p) ...@@ -360,9 +360,9 @@ static int __init early_fadump_reserve_mem(char *p)
} }
early_param("fadump_reserve_mem", early_fadump_reserve_mem); early_param("fadump_reserve_mem", early_fadump_reserve_mem);
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; unsigned int wait_time;
pr_debug("Registering for firmware-assisted kernel dump...\n"); pr_debug("Registering for firmware-assisted kernel dump...\n");
...@@ -379,7 +379,11 @@ static void register_fw_dump(struct fadump_mem_struct *fdm) ...@@ -379,7 +379,11 @@ static void register_fw_dump(struct fadump_mem_struct *fdm)
} while (wait_time); } while (wait_time);
err = -EIO;
switch (rc) { switch (rc) {
default:
pr_err("Failed to register. Unknown Error(%d).\n", rc);
break;
case -1: case -1:
printk(KERN_ERR "Failed to register firmware-assisted kernel" printk(KERN_ERR "Failed to register firmware-assisted kernel"
" dump. Hardware Error(%d).\n", rc); " dump. Hardware Error(%d).\n", rc);
...@@ -387,18 +391,22 @@ static void register_fw_dump(struct fadump_mem_struct *fdm) ...@@ -387,18 +391,22 @@ static void register_fw_dump(struct fadump_mem_struct *fdm)
case -3: case -3:
printk(KERN_ERR "Failed to register firmware-assisted kernel" printk(KERN_ERR "Failed to register firmware-assisted kernel"
" dump. Parameter Error(%d).\n", rc); " dump. Parameter Error(%d).\n", rc);
err = -EINVAL;
break; break;
case -9: case -9:
printk(KERN_ERR "firmware-assisted kernel dump is already " printk(KERN_ERR "firmware-assisted kernel dump is already "
" registered."); " registered.");
fw_dump.dump_registered = 1; fw_dump.dump_registered = 1;
err = -EEXIST;
break; break;
case 0: case 0:
printk(KERN_INFO "firmware-assisted kernel dump registration" printk(KERN_INFO "firmware-assisted kernel dump registration"
" is successful\n"); " is successful\n");
fw_dump.dump_registered = 1; fw_dump.dump_registered = 1;
err = 0;
break; break;
} }
return err;
} }
void crash_fadump(struct pt_regs *regs, const char *str) void crash_fadump(struct pt_regs *regs, const char *str)
...@@ -997,7 +1005,7 @@ static unsigned long init_fadump_header(unsigned long addr) ...@@ -997,7 +1005,7 @@ static unsigned long init_fadump_header(unsigned long addr)
return addr; return addr;
} }
static void register_fadump(void) static int register_fadump(void)
{ {
unsigned long addr; unsigned long addr;
void *vaddr; void *vaddr;
...@@ -1008,7 +1016,7 @@ static void register_fadump(void) ...@@ -1008,7 +1016,7 @@ static void register_fadump(void)
* assisted dump. * assisted dump.
*/ */
if (!fw_dump.reserve_dump_area_size) if (!fw_dump.reserve_dump_area_size)
return; return -ENODEV;
ret = fadump_setup_crash_memory_ranges(); ret = fadump_setup_crash_memory_ranges();
if (ret) if (ret)
...@@ -1023,7 +1031,7 @@ static void register_fadump(void) ...@@ -1023,7 +1031,7 @@ static void register_fadump(void)
fadump_create_elfcore_headers(vaddr); fadump_create_elfcore_headers(vaddr);
/* register the future kernel dump with firmware. */ /* 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) static int fadump_unregister_dump(struct fadump_mem_struct *fdm)
...@@ -1208,7 +1216,6 @@ static ssize_t fadump_register_store(struct kobject *kobj, ...@@ -1208,7 +1216,6 @@ static ssize_t fadump_register_store(struct kobject *kobj,
switch (buf[0]) { switch (buf[0]) {
case '0': case '0':
if (fw_dump.dump_registered == 0) { if (fw_dump.dump_registered == 0) {
ret = -EINVAL;
goto unlock_out; goto unlock_out;
} }
/* Un-register Firmware-assisted dump */ /* Un-register Firmware-assisted dump */
...@@ -1216,11 +1223,11 @@ static ssize_t fadump_register_store(struct kobject *kobj, ...@@ -1216,11 +1223,11 @@ static ssize_t fadump_register_store(struct kobject *kobj,
break; break;
case '1': case '1':
if (fw_dump.dump_registered == 1) { if (fw_dump.dump_registered == 1) {
ret = -EINVAL; ret = -EEXIST;
goto unlock_out; goto unlock_out;
} }
/* Register Firmware-assisted dump */ /* Register Firmware-assisted dump */
register_fadump(); ret = register_fadump();
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment