ANDROID: mmc: Add vendor hooks for sdcard failure diagnostics

For sdcard failure diagnostics, add vendor hooks to monitor the sdcard
identification and the sdcard reset failure in the request
recovery handling.

Link:https://android-review.googlesource.com/c/kernel/common/+/2070567

It is a partial cherry-pick of android13-5.15 for some hooks, and removed
the addition of struct members

Bug: 376616688
Change-Id: I41c62901e10a9faa218af037dd5febdad1f1f1af
Signed-off-by: Guilong Fu <guilong.fu@transsion.com>
This commit is contained in:
guilongfu
2024-10-31 17:49:52 +08:00
parent f3367f466a
commit 11512e4a72
6 changed files with 32 additions and 1 deletions

View File

@@ -459,3 +459,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_swapmem_gather_finish);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_read_fault);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_read);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_map_pages);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_blk_reset);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_attach_sd);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sdhci_get_cd);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_gpio_cd_irqt);

View File

@@ -1068,8 +1068,10 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
* in that case.
*/
main_md->part_curr = err ? MMC_BLK_PART_INVALID : main_md->part_type;
if (err)
if (err) {
trace_android_vh_mmc_blk_reset(host, err);
return err;
}
/* Ensure we switch back to the correct partition */
if (mmc_blk_part_switch(host->card, md->part_type))
/*

View File

@@ -1885,5 +1885,7 @@ err:
pr_err("%s: error %d whilst initialising SD card\n",
mmc_hostname(host), err);
trace_android_vh_mmc_attach_sd(host, err);
return err;
}

View File

@@ -13,6 +13,7 @@
#include <linux/mmc/slot-gpio.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <trace/hooks/mmc.h>
#include "slot-gpio.h"
@@ -31,6 +32,8 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id)
struct mmc_host *host = dev_id;
struct mmc_gpio *ctx = host->slot.handler_priv;
trace_android_vh_mmc_gpio_cd_irqt(host);
host->trigger_card_event = true;
mmc_detect_change(host, msecs_to_jiffies(ctx->cd_debounce_delay_ms));

View File

@@ -31,6 +31,7 @@
#include <linux/mmc/card.h>
#include <linux/mmc/sdio.h>
#include <linux/mmc/slot-gpio.h>
#include <trace/hooks/mmc.h>
#include "sdhci.h"
@@ -2502,6 +2503,8 @@ static int sdhci_get_cd(struct mmc_host *mmc)
if (!mmc_card_is_removable(mmc))
return 1;
trace_android_vh_sdhci_get_cd(host);
/*
* Try slot gpio detect, if defined it take precedence
* over build in controller functionality

View File

@@ -9,6 +9,7 @@
struct mmc_host;
struct mmc_card;
struct mmc_queue;
struct sdhci_host;
/*
* Following tracepoints are not exported in tracefs and provide a
@@ -34,6 +35,22 @@ DECLARE_HOOK(android_vh_mmc_update_mmc_queue,
TP_PROTO(struct mmc_card *card, struct mmc_queue *mq),
TP_ARGS(card, mq));
DECLARE_HOOK(android_vh_mmc_blk_reset,
TP_PROTO(struct mmc_host *host, int err),
TP_ARGS(host, err));
DECLARE_HOOK(android_vh_mmc_attach_sd,
TP_PROTO(struct mmc_host *host, int err),
TP_ARGS(host, err));
DECLARE_HOOK(android_vh_sdhci_get_cd,
TP_PROTO(struct sdhci_host *host),
TP_ARGS(host));
DECLARE_HOOK(android_vh_mmc_gpio_cd_irqt,
TP_PROTO(struct mmc_host *host),
TP_ARGS(host));
#endif /* _TRACE_HOOK_MMC_H */
/* This part must be outside protection */
#include <trace/define_trace.h>