diff --git a/drivers/staging/blackbox/Kconfig b/drivers/staging/blackbox/Kconfig index a3c94f9272271251fca0729afa8a31bce9260cc1..cbfb275c52e0f315ec7c333b6c304f70fd0c3137 100644 --- a/drivers/staging/blackbox/Kconfig +++ b/drivers/staging/blackbox/Kconfig @@ -32,6 +32,13 @@ config BLACKBOX_STORAGE_BY_MEMORY panic occurs. It depends on supporting warm reset and disabling erase ddr when warm reset. +config BLACKBOX_USE_PSTORE_BLK_DEBUG + bool "blackbox use pstore blk for debug" + depends on BLACKBOX + default n + help + If Y, this enables pstore blk for blackbox. + config BLACKBOX_STORAGE_BY_PSTORE_BLK tristate "blackbox fault log storage by pstore blk" depends on BLACKBOX diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig index 25bd47bd03f3a9a6b4564bad15aec2b7273064a0..40ec4d3f45e7c29ded34afe91624ab222f694423 100644 --- a/fs/pstore/Kconfig +++ b/fs/pstore/Kconfig @@ -177,7 +177,7 @@ config PSTORE_BLK tristate "Log panic/oops to a block device" depends on PSTORE depends on BLOCK - depends on BROKEN + depends on BLACKBOX_USE_PSTORE_BLK_DEBUG || BROKEN select PSTORE_ZONE default n help diff --git a/fs/pstore/blk.c b/fs/pstore/blk.c index 6a768a5dae91e70adbabeeb64d6ebc3cc891faa1..b7a290482840e411d11a31e1f319f82fb2c32067 100644 --- a/fs/pstore/blk.c +++ b/fs/pstore/blk.c @@ -53,6 +53,7 @@ MODULE_PARM_DESC(ftrace_size, "ftrace size in kbytes"); #if IS_ENABLED(CONFIG_PSTORE_BLACKBOX) static long blackbox_size = CONFIG_PSTORE_BLK_BLACKBOX_SIZE; +bool pstore_blk_ready; #else static long blackbox_size = -1; #endif @@ -501,6 +502,11 @@ static int __init pstore_blk_init(void) ret = __register_pstore_blk(&info); mutex_unlock(&pstore_blk_lock); +#if IS_ENABLED(CONFIG_PSTORE_BLACKBOX) + if (best_effort && blkdev[0]) + pstore_blk_ready = true; +#endif + return ret; } late_initcall(pstore_blk_init); diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h index 7fb219042f13d149b10502f2969fb7603f27e62a..dec9d17a5d9403985814eed386eda838bf4bccdc 100644 --- a/fs/pstore/internal.h +++ b/fs/pstore/internal.h @@ -50,4 +50,7 @@ extern void pstore_record_init(struct pstore_record *record, int __init pstore_init_fs(void); void __exit pstore_exit_fs(void); +#ifdef CONFIG_PSTORE_BLACKBOX +extern bool pstore_blk_ready; /* flag which pstore_blk is ready */ +#endif #endif diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index f9ab44bf0de6e92288acb541c16bcc57342aeaa4..7cb499250c5a1b8978025ac3fa91e93cd835951a 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -435,6 +435,9 @@ void pstore_blackbox_dump(struct kmsg_dumper *dumper, const char *why; int ret; + if (!pstore_blk_ready) + return; + why = kmsg_dump_reason_str(reason); if (down_trylock(&psinfo->buf_lock)) {