ANDROID: mmc: Add vendor hooks

Add vendor hooks to support vendor-specific exception handling features.

Bug: 185083720

Change-Id: I30381ed9835338308f2b03856f510a2982db6e6a
Signed-off-by: Mingli Feng <mingli.feng@vivo.com>
Signed-off-by: Aking Chen <akingchen@vivo.com>
(cherry picked from commit e80bcd4627)
Signed-off-by: Aking Chen <akingchen@vivo.corp-partner.google.com>
This commit is contained in:
Aking Chen
2022-05-24 10:51:11 +08:00
committed by Carlos Llamas
parent 5b2030ed91
commit b5db5ef6b9
7 changed files with 56 additions and 0 deletions

View File

@@ -346,3 +346,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_handle_tlb_conf);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_memcgv2_init); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_memcgv2_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_memcgv2_calc_decayed_watermark); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_memcgv2_calc_decayed_watermark);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_watermark); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_watermark);
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);

View File

@@ -49,6 +49,8 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <trace/hooks/mmc.h>
#include "queue.h" #include "queue.h"
#include "block.h" #include "block.h"
#include "core.h" #include "core.h"
@@ -1009,6 +1011,8 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
*/ */
return -ENODEV; return -ENODEV;
} }
trace_android_vh_mmc_blk_reset(host, err);
} }
return err; return err;
} }
@@ -1838,6 +1842,7 @@ static void mmc_blk_mq_rw_recovery(struct mmc_queue *mq, struct request *req)
err && mmc_blk_reset(md, card->host, type)) { err && mmc_blk_reset(md, card->host, type)) {
pr_err("%s: recovery failed!\n", req->rq_disk->disk_name); pr_err("%s: recovery failed!\n", req->rq_disk->disk_name);
mqrq->retries = MMC_NO_RETRIES; mqrq->retries = MMC_NO_RETRIES;
trace_android_vh_mmc_blk_mq_rw_recovery(card);
return; return;
} }

View File

@@ -18,6 +18,8 @@
#include <linux/mmc/mmc.h> #include <linux/mmc/mmc.h>
#include <linux/mmc/sd.h> #include <linux/mmc/sd.h>
#include <trace/hooks/mmc.h>
#include "core.h" #include "core.h"
#include "card.h" #include "card.h"
#include "host.h" #include "host.h"
@@ -472,6 +474,8 @@ static void sd_update_bus_speed_mode(struct mmc_card *card)
SD_MODE_UHS_SDR12)) { SD_MODE_UHS_SDR12)) {
card->sd_bus_speed = UHS_SDR12_BUS_SPEED; 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) static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
@@ -1874,5 +1878,7 @@ err:
pr_err("%s: error %d whilst initialising SD card\n", pr_err("%s: error %d whilst initialising SD card\n",
mmc_hostname(host), err); mmc_hostname(host), err);
trace_android_vh_mmc_attach_sd(host, ocr, err);
return err; return err;
} }

View File

@@ -14,6 +14,8 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <trace/hooks/mmc.h>
#include "slot-gpio.h" #include "slot-gpio.h"
struct mmc_gpio { 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 */ /* Schedule a card detection after a debounce timeout */
struct mmc_host *host = dev_id; struct mmc_host *host = dev_id;
struct mmc_gpio *ctx = host->slot.handler_priv; 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; host->trigger_card_event = true;
mmc_detect_change(host, msecs_to_jiffies(ctx->cd_debounce_delay_ms)); mmc_detect_change(host, msecs_to_jiffies(ctx->cd_debounce_delay_ms));

View File

@@ -32,6 +32,8 @@
#include <linux/mmc/sdio.h> #include <linux/mmc/sdio.h>
#include <linux/mmc/slot-gpio.h> #include <linux/mmc/slot-gpio.h>
#include <trace/hooks/mmc.h>
#include "sdhci.h" #include "sdhci.h"
#define DRIVER_NAME "sdhci" #define DRIVER_NAME "sdhci"
@@ -2421,6 +2423,7 @@ static int sdhci_get_cd(struct mmc_host *mmc)
{ {
struct sdhci_host *host = mmc_priv(mmc); struct sdhci_host *host = mmc_priv(mmc);
int gpio_cd = mmc_gpio_get_cd(mmc); int gpio_cd = mmc_gpio_get_cd(mmc);
bool allow = true;
if (host->flags & SDHCI_DEVICE_DEAD) if (host->flags & SDHCI_DEVICE_DEAD)
return 0; return 0;
@@ -2429,6 +2432,10 @@ static int sdhci_get_cd(struct mmc_host *mmc)
if (!mmc_card_is_removable(mmc)) if (!mmc_card_is_removable(mmc))
return 1; return 1;
trace_android_vh_sdhci_get_cd(host, &allow);
if (!allow)
return 0;
/* /*
* Try slot gpio detect, if defined it take precedence * Try slot gpio detect, if defined it take precedence
* over build in controller functionality * over build in controller functionality

View File

@@ -18,6 +18,8 @@
#include <linux/blk-crypto-profile.h> #include <linux/blk-crypto-profile.h>
#include <linux/android_kabi.h> #include <linux/android_kabi.h>
#include <linux/android_vendor.h>
struct mmc_ios { struct mmc_ios {
unsigned int clock; /* clock rate */ unsigned int clock; /* clock rate */
unsigned short vdd; unsigned short vdd;
@@ -290,6 +292,7 @@ struct mmc_slot {
int cd_irq; int cd_irq;
bool cd_wake_enabled; bool cd_wake_enabled;
void *handler_priv; void *handler_priv;
ANDROID_OEM_DATA(1);
}; };
/** /**
@@ -531,6 +534,8 @@ struct mmc_host {
ANDROID_KABI_RESERVE(1); ANDROID_KABI_RESERVE(1);
ANDROID_KABI_RESERVE(2); ANDROID_KABI_RESERVE(2);
ANDROID_OEM_DATA(1);
unsigned long private[] ____cacheline_aligned; unsigned long private[] ____cacheline_aligned;
}; };

View File

@@ -8,6 +8,8 @@
#include <trace/hooks/vendor_hooks.h> #include <trace/hooks/vendor_hooks.h>
struct blk_mq_queue_data; struct blk_mq_queue_data;
struct mmc_host; struct mmc_host;
struct mmc_card;
struct sdhci_host;
/* /*
* Following tracepoints are not exported in tracefs and provide a * Following tracepoints are not exported in tracefs and provide a
@@ -20,6 +22,24 @@ DECLARE_HOOK(android_vh_mmc_check_status,
DECLARE_HOOK(android_vh_mmc_sdio_pm_flag_set, DECLARE_HOOK(android_vh_mmc_sdio_pm_flag_set,
TP_PROTO(struct mmc_host *host), TP_PROTO(struct mmc_host *host),
TP_ARGS(host)); TP_ARGS(host));
DECLARE_HOOK(android_vh_mmc_blk_reset,
TP_PROTO(struct mmc_host *host, int err),
TP_ARGS(host, err));
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));
DECLARE_RESTRICTED_HOOK(android_rvh_mmc_cache_card_properties, DECLARE_RESTRICTED_HOOK(android_rvh_mmc_cache_card_properties,
TP_PROTO(struct mmc_host *host), TP_PROTO(struct mmc_host *host),