diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index e42cca2789ca..c597baaebc5c 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -264,6 +265,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_psci_cpu_suspend); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_event); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_group); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpufreq_acct_update_power); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_mmc_resume); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_mmc_suspend); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_signal); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shrink_node_memcgs); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_modify_thermal_request_freq); diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 89cd48fcec79..8a18adae9937 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "core.h" #include "card.h" @@ -2112,9 +2113,10 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend) ((host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) || !is_suspend || (host->caps2 & MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND))) err = mmc_poweroff_notify(host->card, notify_type); - else if (mmc_can_sleep(host->card)) + else if (mmc_can_sleep(host->card)) { + trace_android_rvh_mmc_suspend(host); err = mmc_sleep(host); - else if (!mmc_host_is_spi(host)) + } else if (!mmc_host_is_spi(host)) err = mmc_deselect_cards(host); if (!err) { @@ -2149,6 +2151,7 @@ static int mmc_suspend(struct mmc_host *host) static int _mmc_resume(struct mmc_host *host) { int err = 0; + bool resume_success = false; mmc_claim_host(host); @@ -2156,7 +2159,9 @@ static int _mmc_resume(struct mmc_host *host) goto out; mmc_power_up(host, host->card->ocr); - err = mmc_init_card(host, host->card->ocr, host->card); + trace_android_rvh_mmc_resume(host, &resume_success); + if (!resume_success) + err = mmc_init_card(host, host->card->ocr, host->card); mmc_card_clr_suspended(host->card); out: diff --git a/include/trace/hooks/mmc.h b/include/trace/hooks/mmc.h new file mode 100644 index 000000000000..3654c2a928ee --- /dev/null +++ b/include/trace/hooks/mmc.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM mmc +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH trace/hooks +#if !defined(_TRACE_HOOK_MMC_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_MMC_H +#include +struct mmc_host; + +/* + * Following tracepoints are not exported in tracefs and provide a + * mechanism for vendor modules to hook and extend functionality + */ +DECLARE_RESTRICTED_HOOK(android_rvh_mmc_suspend, + TP_PROTO(struct mmc_host *host), + TP_ARGS(host), 1); + +DECLARE_RESTRICTED_HOOK(android_rvh_mmc_resume, + TP_PROTO(struct mmc_host *host, bool *resume_success), + TP_ARGS(host, resume_success), 1); + +#endif /* _TRACE_HOOK_MMC_H */ +/* This part must be outside protection */ +#include