Files
android_kernel_xiaomi_sm8450/drivers/misc/mei/debugfs.c
Linus Torvalds f632a8170a Merge tag 'driver-core-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core and debugfs updates from Greg KH:
 "Here is the "big" driver core and debugfs changes for 5.3-rc1

  It's a lot of different patches, all across the tree due to some api
  changes and lots of debugfs cleanups.

  Other than the debugfs cleanups, in this set of changes we have:

   - bus iteration function cleanups

   - scripts/get_abi.pl tool to display and parse Documentation/ABI
     entries in a simple way

   - cleanups to Documenatation/ABI/ entries to make them parse easier
     due to typos and other minor things

   - default_attrs use for some ktype users

   - driver model documentation file conversions to .rst

   - compressed firmware file loading

   - deferred probe fixes

  All of these have been in linux-next for a while, with a bunch of
  merge issues that Stephen has been patient with me for"

* tag 'driver-core-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (102 commits)
  debugfs: make error message a bit more verbose
  orangefs: fix build warning from debugfs cleanup patch
  ubifs: fix build warning after debugfs cleanup patch
  driver: core: Allow subsystems to continue deferring probe
  drivers: base: cacheinfo: Ensure cpu hotplug work is done before Intel RDT
  arch_topology: Remove error messages on out-of-memory conditions
  lib: notifier-error-inject: no need to check return value of debugfs_create functions
  swiotlb: no need to check return value of debugfs_create functions
  ceph: no need to check return value of debugfs_create functions
  sunrpc: no need to check return value of debugfs_create functions
  ubifs: no need to check return value of debugfs_create functions
  orangefs: no need to check return value of debugfs_create functions
  nfsd: no need to check return value of debugfs_create functions
  lib: 842: no need to check return value of debugfs_create functions
  debugfs: provide pr_fmt() macro
  debugfs: log errors when something goes wrong
  drivers: s390/cio: Fix compilation warning about const qualifiers
  drivers: Add generic helper to match by of_node
  driver_find_device: Unify the match function with class_find_device()
  bus_find_device: Unify the match callback with class_find_device
  ...
2019-07-12 12:24:03 -07:00

175 lines
4.5 KiB
C

// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2012-2016, Intel Corporation. All rights reserved
* Intel Management Engine Interface (Intel MEI) Linux driver
*/
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/mei.h>
#include "mei_dev.h"
#include "client.h"
#include "hw.h"
static int mei_dbgfs_meclients_show(struct seq_file *m, void *unused)
{
struct mei_device *dev = m->private;
struct mei_me_client *me_cl;
int i = 0;
if (!dev)
return -ENODEV;
down_read(&dev->me_clients_rwsem);
seq_puts(m, " |id|fix| UUID |con|msg len|sb|refc|\n");
/* if the driver is not enabled the list won't be consistent */
if (dev->dev_state != MEI_DEV_ENABLED)
goto out;
list_for_each_entry(me_cl, &dev->me_clients, list) {
if (!mei_me_cl_get(me_cl))
continue;
seq_printf(m, "%2d|%2d|%3d|%pUl|%3d|%7d|%2d|%4d|\n",
i++, me_cl->client_id,
me_cl->props.fixed_address,
&me_cl->props.protocol_name,
me_cl->props.max_number_of_connections,
me_cl->props.max_msg_length,
me_cl->props.single_recv_buf,
kref_read(&me_cl->refcnt));
mei_me_cl_put(me_cl);
}
out:
up_read(&dev->me_clients_rwsem);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(mei_dbgfs_meclients);
static int mei_dbgfs_active_show(struct seq_file *m, void *unused)
{
struct mei_device *dev = m->private;
struct mei_cl *cl;
int i = 0;
if (!dev)
return -ENODEV;
mutex_lock(&dev->device_lock);
seq_puts(m, " |me|host|state|rd|wr|wrq\n");
/* if the driver is not enabled the list won't be consistent */
if (dev->dev_state != MEI_DEV_ENABLED)
goto out;
list_for_each_entry(cl, &dev->file_list, link) {
seq_printf(m, "%3d|%2d|%4d|%5d|%2d|%2d|%3u\n",
i, mei_cl_me_id(cl), cl->host_client_id, cl->state,
!list_empty(&cl->rd_completed), cl->writing_state,
cl->tx_cb_queued);
i++;
}
out:
mutex_unlock(&dev->device_lock);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(mei_dbgfs_active);
static int mei_dbgfs_devstate_show(struct seq_file *m, void *unused)
{
struct mei_device *dev = m->private;
seq_printf(m, "dev: %s\n", mei_dev_state_str(dev->dev_state));
seq_printf(m, "hbm: %s\n", mei_hbm_state_str(dev->hbm_state));
if (dev->hbm_state >= MEI_HBM_ENUM_CLIENTS &&
dev->hbm_state <= MEI_HBM_STARTED) {
seq_puts(m, "hbm features:\n");
seq_printf(m, "\tPG: %01d\n", dev->hbm_f_pg_supported);
seq_printf(m, "\tDC: %01d\n", dev->hbm_f_dc_supported);
seq_printf(m, "\tIE: %01d\n", dev->hbm_f_ie_supported);
seq_printf(m, "\tDOT: %01d\n", dev->hbm_f_dot_supported);
seq_printf(m, "\tEV: %01d\n", dev->hbm_f_ev_supported);
seq_printf(m, "\tFA: %01d\n", dev->hbm_f_fa_supported);
seq_printf(m, "\tOS: %01d\n", dev->hbm_f_os_supported);
seq_printf(m, "\tDR: %01d\n", dev->hbm_f_dr_supported);
}
seq_printf(m, "pg: %s, %s\n",
mei_pg_is_enabled(dev) ? "ENABLED" : "DISABLED",
mei_pg_state_str(mei_pg_state(dev)));
return 0;
}
DEFINE_SHOW_ATTRIBUTE(mei_dbgfs_devstate);
static ssize_t mei_dbgfs_write_allow_fa(struct file *file,
const char __user *user_buf,
size_t count, loff_t *ppos)
{
struct mei_device *dev;
int ret;
dev = container_of(file->private_data,
struct mei_device, allow_fixed_address);
ret = debugfs_write_file_bool(file, user_buf, count, ppos);
if (ret < 0)
return ret;
dev->override_fixed_address = true;
return ret;
}
static const struct file_operations mei_dbgfs_allow_fa_fops = {
.open = simple_open,
.read = debugfs_read_file_bool,
.write = mei_dbgfs_write_allow_fa,
.llseek = generic_file_llseek,
};
/**
* mei_dbgfs_deregister - Remove the debugfs files and directories
*
* @dev: the mei device structure
*/
void mei_dbgfs_deregister(struct mei_device *dev)
{
if (!dev->dbgfs_dir)
return;
debugfs_remove_recursive(dev->dbgfs_dir);
dev->dbgfs_dir = NULL;
}
/**
* mei_dbgfs_register - Add the debugfs files
*
* @dev: the mei device structure
* @name: the mei device name
*/
void mei_dbgfs_register(struct mei_device *dev, const char *name)
{
struct dentry *dir;
dir = debugfs_create_dir(name, NULL);
dev->dbgfs_dir = dir;
debugfs_create_file("meclients", S_IRUSR, dir, dev,
&mei_dbgfs_meclients_fops);
debugfs_create_file("active", S_IRUSR, dir, dev,
&mei_dbgfs_active_fops);
debugfs_create_file("devstate", S_IRUSR, dir, dev,
&mei_dbgfs_devstate_fops);
debugfs_create_file("allow_fixed_address", S_IRUSR | S_IWUSR, dir,
&dev->allow_fixed_address,
&mei_dbgfs_allow_fa_fops);
}