ANDROID: mmc: Add vendor hooks

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

Bug: 185083720

Change-Id: I30381ed9835338308f2b03856f510a2982db6e6a
Signed-off-by: fengmingli <mingli.feng@vivo.com>
This commit is contained in:
fengmingli
2021-04-19 10:07:48 +08:00
committed by Todd Kjos
parent 3bd9ad7eb4
commit e80bcd4627
7 changed files with 80 additions and 0 deletions

View File

@@ -56,6 +56,7 @@
#include <trace/hooks/psi.h>
#include <trace/hooks/selinux.h>
#include <trace/hooks/hung_task.h>
#include <trace/hooks/mmc_core.h>
/*
* 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);

View File

@@ -47,6 +47,8 @@
#include <linux/uaccess.h>
#include <trace/hooks/mmc_core.h>
#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;
}

View File

@@ -18,6 +18,8 @@
#include <linux/mmc/mmc.h>
#include <linux/mmc/sd.h>
#include <trace/hooks/mmc_core.h>
#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 @@ err:
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;
}

View File

@@ -14,6 +14,8 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <trace/hooks/mmc_core.h>
#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));

View File

@@ -33,6 +33,8 @@
#include <linux/mmc/sdio.h>
#include <linux/mmc/slot-gpio.h>
#include <trace/hooks/mmc_core.h>
#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

View File

@@ -17,6 +17,8 @@
#include <linux/dma-direction.h>
#include <linux/keyslot-manager.h>
#include <linux/android_vendor.h>
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;
};

View File

@@ -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 <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
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 <trace/define_trace.h>