From e80bcd46271b80971283b64b4c8298100d1a8737 Mon Sep 17 00:00:00 2001 From: fengmingli Date: Mon, 19 Apr 2021 10:07:48 +0800 Subject: [PATCH] ANDROID: mmc: Add vendor hooks Add vendor hooks to support vendor-specific exception handling features. Bug: 185083720 Change-Id: I30381ed9835338308f2b03856f510a2982db6e6a Signed-off-by: fengmingli --- drivers/android/vendor_hooks.c | 7 ++++++ drivers/mmc/core/block.c | 8 +++++++ drivers/mmc/core/sd.c | 6 +++++ drivers/mmc/core/slot-gpio.c | 7 ++++++ drivers/mmc/host/sdhci.c | 7 ++++++ include/linux/mmc/host.h | 5 +++++ include/trace/hooks/mmc_core.h | 40 ++++++++++++++++++++++++++++++++++ 7 files changed, 80 insertions(+) create mode 100644 include/trace/hooks/mmc_core.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 68579b8877d2..c7dace5fbf8b 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -56,6 +56,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -286,3 +287,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_attach); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_dirty_limits); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_uninterruptible_tasks); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_uninterruptible_tasks_dn); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_blk_reset); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_blk_mq_rw_recovery); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sd_update_bus_speed_mode); +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); diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 91d3bbecf307..fd092f2c85ae 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -47,6 +47,8 @@ #include +#include + #include "queue.h" #include "block.h" #include "core.h" @@ -963,6 +965,11 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host, struct mmc_blk_data *main_md = dev_get_drvdata(&host->card->dev); int part_err; + bool allow = true; + + trace_android_vh_mmc_blk_reset(host, err, &allow); + if (!allow) + return -ENODEV; main_md->part_curr = main_md->part_type; part_err = mmc_blk_part_switch(host->card, md->part_type); @@ -1795,6 +1802,7 @@ static void mmc_blk_mq_rw_recovery(struct mmc_queue *mq, struct request *req) err && mmc_blk_reset(md, card->host, type)) { pr_err("%s: recovery failed!\n", req->rq_disk->disk_name); mqrq->retries = MMC_NO_RETRIES; + trace_android_vh_mmc_blk_mq_rw_recovery(card); return; } diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 636d4e3aa0e3..da5cf1b5d681 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -18,6 +18,8 @@ #include #include +#include + #include "core.h" #include "card.h" #include "host.h" @@ -462,6 +464,8 @@ static void sd_update_bus_speed_mode(struct mmc_card *card) SD_MODE_UHS_SDR12)) { card->sd_bus_speed = UHS_SDR12_BUS_SPEED; } + + trace_android_vh_sd_update_bus_speed_mode(card); } static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) @@ -1403,5 +1407,7 @@ int mmc_attach_sd(struct mmc_host *host) pr_err("%s: error %d whilst initialising SD card\n", mmc_hostname(host), err); + trace_android_vh_mmc_attach_sd(host, ocr, err); + return err; } diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index 05e907451df9..298877a50af5 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c @@ -14,6 +14,8 @@ #include #include +#include + #include "slot-gpio.h" struct mmc_gpio { @@ -30,6 +32,11 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) /* Schedule a card detection after a debounce timeout */ struct mmc_host *host = dev_id; struct mmc_gpio *ctx = host->slot.handler_priv; + bool allow = true; + + trace_android_vh_mmc_gpio_cd_irqt(host, &allow); + if (!allow) + return IRQ_HANDLED; host->trigger_card_event = true; mmc_detect_change(host, msecs_to_jiffies(ctx->cd_debounce_delay_ms)); diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 58c977d581e7..3a89cfcb1827 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -33,6 +33,8 @@ #include #include +#include + #include "sdhci.h" #define DRIVER_NAME "sdhci" @@ -2395,6 +2397,7 @@ static int sdhci_get_cd(struct mmc_host *mmc) { struct sdhci_host *host = mmc_priv(mmc); int gpio_cd = mmc_gpio_get_cd(mmc); + bool allow = true; if (host->flags & SDHCI_DEVICE_DEAD) return 0; @@ -2403,6 +2406,10 @@ static int sdhci_get_cd(struct mmc_host *mmc) if (!mmc_card_is_removable(host->mmc)) return 1; + trace_android_vh_sdhci_get_cd(host, &allow); + if (!allow) + return 0; + /* * Try slot gpio detect, if defined it take precedence * over build in controller functionality diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 9b0450d58d70..511b14d76b7c 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -17,6 +17,8 @@ #include #include +#include + struct mmc_ios { unsigned int clock; /* clock rate */ unsigned short vdd; @@ -244,6 +246,7 @@ struct mmc_async_req { struct mmc_slot { int cd_irq; bool cd_wake_enabled; + ANDROID_OEM_DATA_ARRAY(1, 2); void *handler_priv; }; @@ -482,6 +485,8 @@ struct mmc_host { /* Host Software Queue support */ bool hsq_enabled; + ANDROID_OEM_DATA(1); + unsigned long private[] ____cacheline_aligned; }; diff --git a/include/trace/hooks/mmc_core.h b/include/trace/hooks/mmc_core.h new file mode 100644 index 000000000000..ad367782d59f --- /dev/null +++ b/include/trace/hooks/mmc_core.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM mmc_core + +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_MMC_CORE_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_MMC_CORE_H + +#include +#include + +struct mmc_host; +struct mmc_card; +struct sdhci_host; + +DECLARE_HOOK(android_vh_mmc_blk_reset, + TP_PROTO(struct mmc_host *host, int err, bool *allow), + TP_ARGS(host, err, allow)); +DECLARE_HOOK(android_vh_mmc_blk_mq_rw_recovery, + TP_PROTO(struct mmc_card *card), + TP_ARGS(card)); +DECLARE_HOOK(android_vh_sd_update_bus_speed_mode, + TP_PROTO(struct mmc_card *card), + TP_ARGS(card)); +DECLARE_HOOK(android_vh_mmc_attach_sd, + TP_PROTO(struct mmc_host *host, u32 ocr, int err), + TP_ARGS(host, ocr, err)); +DECLARE_HOOK(android_vh_sdhci_get_cd, + TP_PROTO(struct sdhci_host *host, bool *allow), + TP_ARGS(host, allow)); +DECLARE_HOOK(android_vh_mmc_gpio_cd_irqt, + TP_PROTO(struct mmc_host *host, bool *allow), + TP_ARGS(host, allow)); + +/* macro versions of hooks are no longer required */ + +#endif /* _TRACE_HOOK_MMC_CORE_H */ +/* This part must be outside protection */ +#include