
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 ...
120 lines
2.5 KiB
C
120 lines
2.5 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Intel MIC Platform Software Stack (MPSS)
|
|
*
|
|
* Copyright(c) 2015 Intel Corporation.
|
|
*
|
|
* Intel MIC Coprocessor State Management (COSM) Driver
|
|
*/
|
|
|
|
#include <linux/debugfs.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/io.h>
|
|
#include "cosm_main.h"
|
|
|
|
/* Debugfs parent dir */
|
|
static struct dentry *cosm_dbg;
|
|
|
|
/**
|
|
* log_buf_show - Display MIC kernel log buffer
|
|
*
|
|
* log_buf addr/len is read from System.map by user space
|
|
* and populated in sysfs entries.
|
|
*/
|
|
static int log_buf_show(struct seq_file *s, void *unused)
|
|
{
|
|
void __iomem *log_buf_va;
|
|
int __iomem *log_buf_len_va;
|
|
struct cosm_device *cdev = s->private;
|
|
void *kva;
|
|
int size;
|
|
u64 aper_offset;
|
|
|
|
if (!cdev || !cdev->log_buf_addr || !cdev->log_buf_len)
|
|
goto done;
|
|
|
|
mutex_lock(&cdev->cosm_mutex);
|
|
switch (cdev->state) {
|
|
case MIC_BOOTING:
|
|
case MIC_ONLINE:
|
|
case MIC_SHUTTING_DOWN:
|
|
break;
|
|
default:
|
|
goto unlock;
|
|
}
|
|
|
|
/*
|
|
* Card kernel will never be relocated and any kernel text/data mapping
|
|
* can be translated to phys address by subtracting __START_KERNEL_map.
|
|
*/
|
|
aper_offset = (u64)cdev->log_buf_len - __START_KERNEL_map;
|
|
log_buf_len_va = cdev->hw_ops->aper(cdev)->va + aper_offset;
|
|
aper_offset = (u64)cdev->log_buf_addr - __START_KERNEL_map;
|
|
log_buf_va = cdev->hw_ops->aper(cdev)->va + aper_offset;
|
|
|
|
size = ioread32(log_buf_len_va);
|
|
kva = kmalloc(size, GFP_KERNEL);
|
|
if (!kva)
|
|
goto unlock;
|
|
|
|
memcpy_fromio(kva, log_buf_va, size);
|
|
seq_write(s, kva, size);
|
|
kfree(kva);
|
|
unlock:
|
|
mutex_unlock(&cdev->cosm_mutex);
|
|
done:
|
|
return 0;
|
|
}
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(log_buf);
|
|
|
|
/**
|
|
* force_reset_show - Force MIC reset
|
|
*
|
|
* Invokes the force_reset COSM bus op instead of the standard reset
|
|
* op in case a force reset of the MIC device is required
|
|
*/
|
|
static int force_reset_show(struct seq_file *s, void *pos)
|
|
{
|
|
struct cosm_device *cdev = s->private;
|
|
|
|
cosm_stop(cdev, true);
|
|
return 0;
|
|
}
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(force_reset);
|
|
|
|
void cosm_create_debug_dir(struct cosm_device *cdev)
|
|
{
|
|
char name[16];
|
|
|
|
if (!cosm_dbg)
|
|
return;
|
|
|
|
scnprintf(name, sizeof(name), "mic%d", cdev->index);
|
|
cdev->dbg_dir = debugfs_create_dir(name, cosm_dbg);
|
|
|
|
debugfs_create_file("log_buf", 0444, cdev->dbg_dir, cdev,
|
|
&log_buf_fops);
|
|
debugfs_create_file("force_reset", 0444, cdev->dbg_dir, cdev,
|
|
&force_reset_fops);
|
|
}
|
|
|
|
void cosm_delete_debug_dir(struct cosm_device *cdev)
|
|
{
|
|
if (!cdev->dbg_dir)
|
|
return;
|
|
|
|
debugfs_remove_recursive(cdev->dbg_dir);
|
|
}
|
|
|
|
void cosm_init_debugfs(void)
|
|
{
|
|
cosm_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
|
|
}
|
|
|
|
void cosm_exit_debugfs(void)
|
|
{
|
|
debugfs_remove(cosm_dbg);
|
|
}
|