mirror of
https://github.com/commaai/agnos-kernel-sdm845.git
synced 2026-06-15 06:44:52 +08:00
mmc: host: Add Ring buffer logging for MMC.
Add ring buffer to enable tracing of significant events of eMMC in both CQ and Legacy mode for debug purpose. CONFIG_MMC_RING_BUFFER should be enabled to use ring buffer logging. Change-Id: Iceb404d77fca19e133c319bc66ec15b2d77c7c54 Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org> [xiaonian@codeaurora.org: fixed trivial merge conflicts] Signed-off-by: Xiaonian Wang <xiaonian@codeaurora.org>
This commit is contained in:
committed by
Xiaonian Wang
parent
13805b3bf7
commit
5bf4209686
@@ -23,6 +23,17 @@ config PWRSEQ_SIMPLE
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called pwrseq_simple.
|
||||
|
||||
config MMC_RING_BUFFER
|
||||
bool "MMC_RING_BUFFER"
|
||||
depends on MMC
|
||||
default n
|
||||
help
|
||||
This enables the ring buffer tracing of significant
|
||||
events for mmc driver to provide command history for
|
||||
debugging purpose.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
config MMC_EMBEDDED_SDIO
|
||||
boolean "MMC embedded SDIO device support (EXPERIMENTAL)"
|
||||
help
|
||||
|
||||
@@ -12,3 +12,4 @@ mmc_core-$(CONFIG_OF) += pwrseq.o
|
||||
obj-$(CONFIG_PWRSEQ_SIMPLE) += pwrseq_simple.o
|
||||
obj-$(CONFIG_PWRSEQ_EMMC) += pwrseq_emmc.o
|
||||
mmc_core-$(CONFIG_DEBUG_FS) += debugfs.o
|
||||
obj-$(CONFIG_MMC_RING_BUFFER) += ring_buffer.o
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
#include <linux/mmc/host.h>
|
||||
#include <linux/mmc/card.h>
|
||||
#include <linux/mmc/ring_buffer.h>
|
||||
|
||||
#include <linux/mmc/slot-gpio.h>
|
||||
|
||||
#include "core.h"
|
||||
@@ -904,6 +906,7 @@ int mmc_add_host(struct mmc_host *host)
|
||||
mmc_add_host_debugfs(host);
|
||||
#endif
|
||||
mmc_host_clk_sysfs_init(host);
|
||||
mmc_trace_init(host);
|
||||
|
||||
err = sysfs_create_group(&host->class_dev.kobj, &clk_scaling_attr_grp);
|
||||
if (err)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <linux/mmc/card.h>
|
||||
#include <linux/mmc/mmc.h>
|
||||
#include <linux/mmc/pm.h>
|
||||
#include <linux/mmc/ring_buffer.h>
|
||||
|
||||
#define MMC_AUTOSUSPEND_DELAY_MS 3000
|
||||
|
||||
@@ -603,6 +604,7 @@ struct mmc_host {
|
||||
} perf;
|
||||
bool perf_enable;
|
||||
#endif
|
||||
struct mmc_trace_buffer trace_buf;
|
||||
enum dev_state dev_status;
|
||||
bool wakeup_on_idle;
|
||||
struct mmc_cmdq_context_info cmdq_ctx;
|
||||
|
||||
55
include/linux/mmc/ring_buffer.h
Normal file
55
include/linux/mmc/ring_buffer.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MMC_RING_BUFFER__
|
||||
#define __MMC_RING_BUFFER__
|
||||
|
||||
#include <linux/mmc/card.h>
|
||||
#include <linux/smp.h>
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#define MMC_TRACE_RBUF_SZ_ORDER 2 /* 2^2 pages */
|
||||
#define MMC_TRACE_RBUF_SZ (PAGE_SIZE * (1 << MMC_TRACE_RBUF_SZ_ORDER))
|
||||
#define MMC_TRACE_EVENT_SZ 256
|
||||
#define MMC_TRACE_RBUF_NUM_EVENTS (MMC_TRACE_RBUF_SZ / MMC_TRACE_EVENT_SZ)
|
||||
|
||||
struct mmc_host;
|
||||
struct mmc_trace_buffer {
|
||||
int wr_idx;
|
||||
bool stop_tracing;
|
||||
spinlock_t trace_lock;
|
||||
char *data;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_MMC_RING_BUFFER
|
||||
void mmc_stop_tracing(struct mmc_host *mmc);
|
||||
void mmc_trace_write(struct mmc_host *mmc, const char *fmt, ...);
|
||||
void mmc_trace_init(struct mmc_host *mmc);
|
||||
void mmc_trace_free(struct mmc_host *mmc);
|
||||
void mmc_dump_trace_buffer(struct mmc_host *mmc, struct seq_file *s);
|
||||
#else
|
||||
static inline void mmc_stop_tracing(struct mmc_host *mmc) {}
|
||||
static inline void mmc_trace_write(struct mmc_host *mmc,
|
||||
const char *fmt, ...) {}
|
||||
static inline void mmc_trace_init(struct mmc_host *mmc) {}
|
||||
static inline void mmc_trace_free(struct mmc_host *mmc) {}
|
||||
static inline void mmc_dump_trace_buffer(struct mmc_host *mmc,
|
||||
struct seq_file *s) {}
|
||||
#endif
|
||||
|
||||
#define MMC_TRACE(mmc, fmt, ...) \
|
||||
mmc_trace_write(mmc, fmt, ##__VA_ARGS__)
|
||||
|
||||
#endif /* __MMC_RING_BUFFER__ */
|
||||
Reference in New Issue
Block a user