drivers/crypto/hisilicon/hpre/hpre_main.c
Source file repositories/reference/linux-study-clean/drivers/crypto/hisilicon/hpre/hpre_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/hisilicon/hpre/hpre_main.c- Extension
.c- Size
- 48577 bytes
- Lines
- 1755
- Domain
- Driver Families
- Bucket
- drivers/crypto
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/bitops.hlinux/debugfs.hlinux/init.hlinux/io.hlinux/kernel.hlinux/module.hlinux/pci.hlinux/pm_runtime.hlinux/topology.hlinux/uacce.hhpre.h
Detected Declarations
struct hpre_hw_errorenum hpre_cap_typefunction hpre_check_alg_supportfunction hpre_diff_regs_showfunction hpre_com_regs_showfunction hpre_cluster_regs_showfunction pf_q_num_setfunction hpre_wait_sva_readyfunction hpre_config_pasidfunction hpre_cfg_by_dsmfunction hpre_set_clusterfunction disable_flr_of_bmefunction hpre_close_sva_prefetchfunction hpre_open_sva_prefetchfunction hpre_enable_clock_gatefunction hpre_disable_clock_gatefunction hpre_set_user_domain_and_cachefunction hpre_cnt_regs_clearfunction hpre_master_ooo_ctrlfunction hpre_hw_error_disablefunction hpre_hw_error_enablefunction hpre_clear_enable_readfunction hpre_clear_enable_writefunction hpre_cluster_inqry_readfunction hpre_cluster_inqry_writefunction hpre_ctrl_debug_readfunction hpre_ctrl_debug_writefunction hpre_debugfs_atomic64_getfunction hpre_debugfs_atomic64_setfunction hpre_create_debugfs_filefunction hpre_pf_comm_regs_debugfs_initfunction hpre_cluster_debugfs_initfunction hpre_ctrl_debug_initfunction hpre_cap_regs_showfunction hpre_dfx_debug_initfunction hpre_debugfs_initfunction hpre_debugfs_exitfunction hpre_pre_store_cap_regfunction hpre_set_channelsfunction hpre_qm_initfunction hpre_show_last_regs_initfunction hpre_show_last_regs_uninitfunction hpre_show_last_dfx_regsfunction hpre_log_hw_errorfunction hpre_get_hw_err_statusfunction hpre_clear_hw_err_statusfunction hpre_disable_error_reportfunction hpre_enable_error_report
Annotated Snippet
static const struct file_operations hpre_ctrl_debug_fops = {
.owner = THIS_MODULE,
.open = simple_open,
.read = hpre_ctrl_debug_read,
.write = hpre_ctrl_debug_write,
};
static int hpre_debugfs_atomic64_get(void *data, u64 *val)
{
struct hpre_dfx *dfx_item = data;
*val = atomic64_read(&dfx_item->value);
return 0;
}
static int hpre_debugfs_atomic64_set(void *data, u64 val)
{
struct hpre_dfx *dfx_item = data;
struct hpre_dfx *hpre_dfx = NULL;
if (dfx_item->type == HPRE_OVERTIME_THRHLD) {
hpre_dfx = dfx_item - HPRE_OVERTIME_THRHLD;
atomic64_set(&hpre_dfx[HPRE_OVER_THRHLD_CNT].value, 0);
} else if (val) {
return -EINVAL;
}
atomic64_set(&dfx_item->value, val);
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(hpre_atomic64_ops, hpre_debugfs_atomic64_get,
hpre_debugfs_atomic64_set, "%llu\n");
static int hpre_create_debugfs_file(struct hisi_qm *qm, struct dentry *dir,
enum hpre_ctrl_dbgfs_file type, int indx)
{
struct hpre *hpre = container_of(qm, struct hpre, qm);
struct hpre_debug *dbg = &hpre->debug;
struct dentry *file_dir;
if (dir)
file_dir = dir;
else
file_dir = qm->debug.debug_root;
if (type >= HPRE_DEBUG_FILE_NUM)
return -EINVAL;
spin_lock_init(&dbg->files[indx].lock);
dbg->files[indx].debug = dbg;
dbg->files[indx].type = type;
dbg->files[indx].index = indx;
debugfs_create_file(hpre_debug_file_name[type], 0600, file_dir,
dbg->files + indx, &hpre_ctrl_debug_fops);
return 0;
}
static int hpre_pf_comm_regs_debugfs_init(struct hisi_qm *qm)
{
struct device *dev = &qm->pdev->dev;
struct debugfs_regset32 *regset;
regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL);
if (!regset)
return -ENOMEM;
regset->regs = hpre_com_dfx_regs;
regset->nregs = ARRAY_SIZE(hpre_com_dfx_regs);
regset->base = qm->io_base;
regset->dev = dev;
debugfs_create_file("regs", 0444, qm->debug.debug_root,
regset, &hpre_com_regs_fops);
return 0;
}
static int hpre_cluster_debugfs_init(struct hisi_qm *qm)
{
struct device *dev = &qm->pdev->dev;
char buf[HPRE_DBGFS_VAL_MAX_LEN];
struct debugfs_regset32 *regset;
struct dentry *tmp_d;
u32 hpre_core_info;
u8 clusters_num;
int i, ret;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/bitops.h`, `linux/debugfs.h`, `linux/init.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`, `linux/pci.h`.
- Detected declarations: `struct hpre_hw_error`, `enum hpre_cap_type`, `function hpre_check_alg_support`, `function hpre_diff_regs_show`, `function hpre_com_regs_show`, `function hpre_cluster_regs_show`, `function pf_q_num_set`, `function hpre_wait_sva_ready`, `function hpre_config_pasid`, `function hpre_cfg_by_dsm`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.