Skip to content

Commit

Permalink
mmc: Add mmc pstore backend support
Browse files Browse the repository at this point in the history
Adding mmc pstore backend support to be able to write to pstore
device. Code is  based on mtdpstore.

Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
  • Loading branch information
KamalDasu authored and intel-lab-lkp committed Dec 22, 2022
1 parent 76d62f2 commit 73afc48
Show file tree
Hide file tree
Showing 7 changed files with 642 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/mmc/core/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,22 @@ config PWRSEQ_SIMPLE
This driver can also be built as a module. If so, the module
will be called pwrseq_simple.

config MMC_PSTORE_BACKEND
bool "Log panic/oops to a MMC buffer"
depends on MMC_BLOCK
help
This option will let you create platform backend to store kmsg
crash dumps to a user specified MMC device. This is primarily
based on pstore/blk.

config MMC_PSTORE
tristate
select PSTORE_BLK

config MMC_BLOCK
tristate "MMC block device driver"
depends on BLOCK
select MMC_PSTORE if MMC_PSTORE_BACKEND=y
default y
help
Say Y here to enable the MMC block device driver support.
Expand Down
1 change: 1 addition & 0 deletions drivers/mmc/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ obj-$(CONFIG_PWRSEQ_EMMC) += pwrseq_emmc.o
mmc_core-$(CONFIG_DEBUG_FS) += debugfs.o
obj-$(CONFIG_MMC_BLOCK) += mmc_block.o
mmc_block-objs := block.o queue.o
mmc_block-$(CONFIG_MMC_PSTORE) += mmcpstore.o
obj-$(CONFIG_MMC_TEST) += mmc_test.o
obj-$(CONFIG_SDIO_UART) += sdio_uart.o
mmc_core-$(CONFIG_MMC_CRYPTO) += crypto.o
4 changes: 4 additions & 0 deletions drivers/mmc/core/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -2982,6 +2982,9 @@ static int mmc_blk_probe(struct mmc_card *card)
if (ret)
goto out;

if (mmc_card_mmc(card) || mmc_card_sd(card))
mmcpstore_register(card, md->disk->disk_name);

/* Add two debugfs entries */
mmc_blk_add_debugfs(card, md);

Expand Down Expand Up @@ -3131,6 +3134,7 @@ static void __exit mmc_blk_exit(void)
unregister_blkdev(MMC_BLOCK_MAJOR, "mmc");
unregister_chrdev_region(mmc_rpmb_devt, MAX_DEVICES);
bus_unregister(&mmc_rpmb_bus_type);
unregister_mmcpstore();
}

module_init(mmc_blk_init);
Expand Down
9 changes: 9 additions & 0 deletions drivers/mmc/core/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,14 @@ void mmc_blk_mq_recovery(struct mmc_queue *mq);
struct work_struct;

void mmc_blk_mq_complete_work(struct work_struct *work);
#if IS_ENABLED(CONFIG_MMC_PSTORE)
sector_t mmc_blk_get_part(struct mmc_card *card, int part_num, sector_t *size);
void mmcpstore_register(struct mmc_card *card, const char *disk_name);
void unregister_mmcpstore(void);
#else
static inline void mmcpstore_register(struct mmc_card *card,
const char *disk_name) {}
static inline void unregister_mmcpstore(void) {}
#endif

#endif

0 comments on commit 73afc48

Please sign in to comment.