drivers/crypto/intel/qat/qat_common/adf_timer.c
Source file repositories/reference/linux-study-clean/drivers/crypto/intel/qat/qat_common/adf_timer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/intel/qat/qat_common/adf_timer.c- Extension
.c- Size
- 1868 bytes
- Lines
- 72
- Domain
- Driver Families
- Bucket
- drivers/crypto
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/container_of.hlinux/dev_printk.hlinux/export.hlinux/jiffies.hlinux/ktime.hlinux/slab.hlinux/workqueue.hadf_admin.hadf_accel_devices.hadf_common_drv.hadf_timer.h
Detected Declarations
function work_handlerfunction adf_timer_startfunction adf_timer_stopexport adf_timer_startexport adf_timer_stop
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright(c) 2023 Intel Corporation */
#include <linux/container_of.h>
#include <linux/dev_printk.h>
#include <linux/export.h>
#include <linux/jiffies.h>
#include <linux/ktime.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include "adf_admin.h"
#include "adf_accel_devices.h"
#include "adf_common_drv.h"
#include "adf_timer.h"
#define ADF_DEFAULT_TIMER_PERIOD_MS 200
/* This periodic update is used to trigger HB, RL & TL fw events */
static void work_handler(struct work_struct *work)
{
struct adf_accel_dev *accel_dev;
struct adf_timer *timer_ctx;
u32 time_periods;
timer_ctx = container_of(to_delayed_work(work), struct adf_timer, work_ctx);
accel_dev = timer_ctx->accel_dev;
adf_misc_wq_queue_delayed_work(&timer_ctx->work_ctx,
msecs_to_jiffies(ADF_DEFAULT_TIMER_PERIOD_MS));
time_periods = div_u64(ktime_ms_delta(ktime_get_real(), timer_ctx->initial_ktime),
ADF_DEFAULT_TIMER_PERIOD_MS);
if (adf_send_admin_tim_sync(accel_dev, time_periods))
dev_err(&GET_DEV(accel_dev), "Failed to synchronize qat timer\n");
}
int adf_timer_start(struct adf_accel_dev *accel_dev)
{
struct adf_timer *timer_ctx;
timer_ctx = kzalloc_obj(*timer_ctx);
if (!timer_ctx)
return -ENOMEM;
timer_ctx->accel_dev = accel_dev;
accel_dev->timer = timer_ctx;
timer_ctx->initial_ktime = ktime_get_real();
INIT_DELAYED_WORK(&timer_ctx->work_ctx, work_handler);
adf_misc_wq_queue_delayed_work(&timer_ctx->work_ctx,
msecs_to_jiffies(ADF_DEFAULT_TIMER_PERIOD_MS));
return 0;
}
EXPORT_SYMBOL_GPL(adf_timer_start);
void adf_timer_stop(struct adf_accel_dev *accel_dev)
{
struct adf_timer *timer_ctx = accel_dev->timer;
if (!timer_ctx)
return;
cancel_delayed_work_sync(&timer_ctx->work_ctx);
kfree(timer_ctx);
accel_dev->timer = NULL;
}
EXPORT_SYMBOL_GPL(adf_timer_stop);
Annotation
- Immediate include surface: `linux/container_of.h`, `linux/dev_printk.h`, `linux/export.h`, `linux/jiffies.h`, `linux/ktime.h`, `linux/slab.h`, `linux/workqueue.h`, `adf_admin.h`.
- Detected declarations: `function work_handler`, `function adf_timer_start`, `function adf_timer_stop`, `export adf_timer_start`, `export adf_timer_stop`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: integration implementation candidate.
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.