drivers/crypto/hisilicon/sec/sec_drv.c
Source file repositories/reference/linux-study-clean/drivers/crypto/hisilicon/sec/sec_drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/hisilicon/sec/sec_drv.c- Extension
.c- Size
- 33882 bytes
- Lines
- 1321
- Domain
- Driver Families
- Bucket
- drivers/crypto
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/atomic.hlinux/delay.hlinux/dma-direction.hlinux/dma-mapping.hlinux/dmapool.hlinux/io.hlinux/iommu.hlinux/interrupt.hlinux/irq.hlinux/irqreturn.hlinux/mm.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/slab.hsec_drv.h
Detected Declarations
struct sec_debug_bd_infostruct sec_out_bd_infofunction sec_queue_map_iofunction sec_queue_unmap_iofunction sec_queue_ar_pkgattrfunction sec_queue_aw_pkgattrfunction sec_clk_enfunction sec_clk_disfunction sec_reset_whole_modulefunction sec_bd_endian_littlefunction sec_cache_configfunction sec_data_axiwr_otsd_cfgfunction sec_data_axird_otsd_cfgfunction sec_clk_gate_enfunction sec_comm_cnt_cfgfunction sec_commsnap_enfunction sec_ipv6_hashmaskfunction sec_ipv4_hashmaskfunction sec_set_dbg_bd_cfgfunction sec_saa_getqm_enfunction sec_saa_int_maskfunction sec_streamidfunction sec_queue_ar_allocfunction sec_queue_aw_allocfunction sec_queue_reorderfunction sec_queue_depthfunction sec_queue_cmdbase_addrfunction sec_queue_outorder_addrfunction sec_queue_errbase_addrfunction sec_queue_irq_disablefunction sec_queue_irq_enablefunction sec_queue_abn_irq_disablefunction sec_queue_stopfunction sec_queue_startfunction sec_queue_freefunction sec_isr_handle_thfunction sec_isr_handlefunction sec_queue_irq_initfunction sec_queue_irq_uninitfunction sec_queue_stop_releasefunction sec_queue_emptyfunction sec_queue_sendfunction sec_queue_can_enqueuefunction sec_queue_hw_initfunction sec_hw_initfunction sec_hw_exitfunction sec_queue_base_initfunction sec_map_io
Annotated Snippet
struct sec_debug_bd_info {
#define SEC_DEBUG_BD_INFO_SOFT_ERR_CHECK_M GENMASK(22, 0)
u32 soft_err_check;
#define SEC_DEBUG_BD_INFO_HARD_ERR_CHECK_M GENMASK(9, 0)
u32 hard_err_check;
u32 icv_mac1st_word;
#define SEC_DEBUG_BD_INFO_GET_ID_M GENMASK(19, 0)
u32 sec_get_id;
/* W4---W15 */
u32 reserv_left[12];
};
struct sec_out_bd_info {
#define SEC_OUT_BD_INFO_Q_ID_M GENMASK(11, 0)
#define SEC_OUT_BD_INFO_ECC_2BIT_ERR BIT(14)
u16 data;
};
#define SEC_MAX_DEVICES 8
static struct sec_dev_info *sec_devices[SEC_MAX_DEVICES];
static DEFINE_MUTEX(sec_id_lock);
static int sec_queue_map_io(struct sec_queue *queue)
{
struct device *dev = queue->dev_info->dev;
struct resource *res;
res = platform_get_resource(to_platform_device(dev),
IORESOURCE_MEM,
2 + queue->queue_id);
if (!res) {
dev_err(dev, "Failed to get queue %u memory resource\n",
queue->queue_id);
return -ENOMEM;
}
queue->regs = ioremap(res->start, resource_size(res));
if (!queue->regs)
return -ENOMEM;
return 0;
}
static void sec_queue_unmap_io(struct sec_queue *queue)
{
iounmap(queue->regs);
}
static int sec_queue_ar_pkgattr(struct sec_queue *queue, u32 ar_pkg)
{
void __iomem *addr = queue->regs + SEC_Q_ARUSER_CFG_REG;
u32 regval;
regval = readl_relaxed(addr);
if (ar_pkg)
regval |= SEC_Q_ARUSER_CFG_PKG;
else
regval &= ~SEC_Q_ARUSER_CFG_PKG;
writel_relaxed(regval, addr);
return 0;
}
static int sec_queue_aw_pkgattr(struct sec_queue *queue, u32 aw_pkg)
{
void __iomem *addr = queue->regs + SEC_Q_AWUSER_CFG_REG;
u32 regval;
regval = readl_relaxed(addr);
regval |= SEC_Q_AWUSER_CFG_PKG;
writel_relaxed(regval, addr);
return 0;
}
static int sec_clk_en(struct sec_dev_info *info)
{
void __iomem *base = info->regs[SEC_COMMON];
u32 i = 0;
writel_relaxed(0x7, base + SEC_ALGSUB_CLK_EN_REG);
do {
usleep_range(1000, 10000);
if ((readl_relaxed(base + SEC_ALGSUB_CLK_ST_REG) & 0x7) == 0x7)
return 0;
i++;
} while (i < 10);
dev_err(info->dev, "sec clock enable fail!\n");
return -EIO;
}
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/atomic.h`, `linux/delay.h`, `linux/dma-direction.h`, `linux/dma-mapping.h`, `linux/dmapool.h`, `linux/io.h`, `linux/iommu.h`.
- Detected declarations: `struct sec_debug_bd_info`, `struct sec_out_bd_info`, `function sec_queue_map_io`, `function sec_queue_unmap_io`, `function sec_queue_ar_pkgattr`, `function sec_queue_aw_pkgattr`, `function sec_clk_en`, `function sec_clk_dis`, `function sec_reset_whole_module`, `function sec_bd_endian_little`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source 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.