Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65669704 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mhi: core: add sysfs hook to modify IPC log levels"

parents 8820152e f62a5609
Loading
Loading
Loading
Loading
+48 −7
Original line number Diff line number Diff line
@@ -14,6 +14,14 @@
#include <linux/mhi.h>
#include "mhi_internal.h"

const char * const mhi_log_level_str[MHI_MSG_LVL_MAX] = {
	[MHI_MSG_LVL_VERBOSE] = "Verbose",
	[MHI_MSG_LVL_INFO] = "Info",
	[MHI_MSG_LVL_ERROR] = "Error",
	[MHI_MSG_LVL_CRITICAL] = "Critical",
	[MHI_MSG_LVL_MASK_ALL] = "Mask all",
};

const char * const mhi_ee_str[MHI_EE_MAX] = {
	[MHI_EE_PBL] = "PBL",
	[MHI_EE_SBL] = "SBL",
@@ -72,6 +80,38 @@ const char *to_mhi_pm_state_str(enum MHI_PM_STATE state)
	return mhi_pm_state_str[index];
}

static ssize_t log_level_show(struct device *dev,
			      struct device_attribute *attr,
			      char *buf)
{
	struct mhi_device *mhi_dev = to_mhi_device(dev);
	struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;

	return snprintf(buf, PAGE_SIZE, "%s\n",
			TO_MHI_LOG_LEVEL_STR(mhi_cntrl->log_lvl));
}

static ssize_t log_level_store(struct device *dev,
			       struct device_attribute *attr,
			       const char *buf,
			       size_t count)
{
	struct mhi_device *mhi_dev = to_mhi_device(dev);
	struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;
	enum MHI_DEBUG_LEVEL log_level;

	if (kstrtou32(buf, 0, &log_level) < 0)
		return -EINVAL;

	mhi_cntrl->log_lvl = log_level;

	MHI_LOG("IPC log level changed to: %s\n",
		TO_MHI_LOG_LEVEL_STR(log_level));

	return count;
}
static DEVICE_ATTR_RW(log_level);

static ssize_t bus_vote_show(struct device *dev,
			     struct device_attribute *attr,
			     char *buf)
@@ -130,27 +170,28 @@ static ssize_t device_vote_store(struct device *dev,
}
static DEVICE_ATTR_RW(device_vote);

static struct attribute *mhi_vote_attrs[] = {
static struct attribute *mhi_sysfs_attrs[] = {
	&dev_attr_log_level.attr,
	&dev_attr_bus_vote.attr,
	&dev_attr_device_vote.attr,
	NULL,
};

static const struct attribute_group mhi_vote_group = {
	.attrs = mhi_vote_attrs,
static const struct attribute_group mhi_sysfs_group = {
	.attrs = mhi_sysfs_attrs,
};

int mhi_create_vote_sysfs(struct mhi_controller *mhi_cntrl)
int mhi_create_sysfs(struct mhi_controller *mhi_cntrl)
{
	return sysfs_create_group(&mhi_cntrl->mhi_dev->dev.kobj,
				  &mhi_vote_group);
				  &mhi_sysfs_group);
}

void mhi_destroy_vote_sysfs(struct mhi_controller *mhi_cntrl)
void mhi_destroy_sysfs(struct mhi_controller *mhi_cntrl)
{
	struct mhi_device *mhi_dev = mhi_cntrl->mhi_dev;

	sysfs_remove_group(&mhi_dev->dev.kobj, &mhi_vote_group);
	sysfs_remove_group(&mhi_dev->dev.kobj, &mhi_sysfs_group);

	/* relinquish any pending votes for device */
	while (atomic_read(&mhi_dev->dev_vote))
+7 −2
Original line number Diff line number Diff line
@@ -441,6 +441,11 @@ extern const char * const mhi_state_str[MHI_STATE_MAX];
				  !mhi_state_str[state]) ? \
				"INVALID_STATE" : mhi_state_str[state])

extern const char * const mhi_log_level_str[MHI_MSG_LVL_MAX];
#define TO_MHI_LOG_LEVEL_STR(level) ((level >= MHI_MSG_LVL_MAX || \
				  !mhi_log_level_str[level]) ? \
				"Mask all" : mhi_log_level_str[level])

enum {
	MHI_PM_BIT_DISABLE,
	MHI_PM_BIT_POR,
@@ -801,8 +806,8 @@ void *mhi_to_virtual(struct mhi_ring *ring, dma_addr_t addr);
int mhi_init_timesync(struct mhi_controller *mhi_cntrl);
int mhi_create_timesync_sysfs(struct mhi_controller *mhi_cntrl);
void mhi_destroy_timesync(struct mhi_controller *mhi_cntrl);
int mhi_create_vote_sysfs(struct mhi_controller *mhi_cntrl);
void mhi_destroy_vote_sysfs(struct mhi_controller *mhi_cntrl);
int mhi_create_sysfs(struct mhi_controller *mhi_cntrl);
void mhi_destroy_sysfs(struct mhi_controller *mhi_cntrl);
int mhi_early_notify_device(struct device *dev, void *data);

/* timesync log support */
+2 −2
Original line number Diff line number Diff line
@@ -492,7 +492,7 @@ static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl)
	mhi_create_devices(mhi_cntrl);

	/* setup sysfs nodes for userspace votes */
	mhi_create_vote_sysfs(mhi_cntrl);
	mhi_create_sysfs(mhi_cntrl);

	read_lock_bh(&mhi_cntrl->pm_lock);

@@ -602,7 +602,7 @@ static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl,
	MHI_LOG("Finish resetting channels\n");

	/* remove support for userspace votes */
	mhi_destroy_vote_sysfs(mhi_cntrl);
	mhi_destroy_sysfs(mhi_cntrl);

	MHI_LOG("Waiting for all pending threads to complete\n");
	wake_up_all(&mhi_cntrl->state_event);
+2 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ enum MHI_CB {
};

/**
 * enum MHI_DEBUG_LEVL - various debugging level
 * enum MHI_DEBUG_LEVEL - various debugging level
 */
enum MHI_DEBUG_LEVEL {
	MHI_MSG_LVL_VERBOSE,
@@ -46,6 +46,7 @@ enum MHI_DEBUG_LEVEL {
	MHI_MSG_LVL_ERROR,
	MHI_MSG_LVL_CRITICAL,
	MHI_MSG_LVL_MASK_ALL,
	MHI_MSG_LVL_MAX,
};

/**