drivers/accel/qaic/qaic_timesync.c
Source file repositories/reference/linux-study-clean/drivers/accel/qaic/qaic_timesync.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accel/qaic/qaic_timesync.c- Extension
.c- Size
- 10706 bytes
- Lines
- 406
- Domain
- Driver Families
- Bucket
- drivers/accel
- 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.
- 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/io.hlinux/kernel.hlinux/math64.hlinux/mhi.hlinux/mod_devicetable.hlinux/module.hlinux/time64.hlinux/timer.hqaic.hqaic_timesync.h
Detected Declarations
struct qts_hdrstruct qts_timevalstruct qts_host_time_sync_msg_datastruct mqts_devstruct qts_resp_msgstruct qts_respenum qts_msg_typefunction read_qtimerfunction read_qtimerfunction qaic_timesync_ul_xfer_cbfunction qaic_timesync_dl_xfer_cbfunction qaic_timesync_timerfunction qaic_mqts_ch_stop_timerfunction qaic_timesync_probefunction qaic_timesync_removefunction qaic_boot_timesync_workerfunction qaic_boot_timesync_queue_respfunction qaic_boot_timesync_removefunction qaic_boot_timesync_probefunction qaic_boot_timesync_ul_xfer_cbfunction qaic_boot_timesync_dl_xfer_cbfunction qaic_timesync_initfunction qaic_timesync_deinit
Annotated Snippet
struct qts_hdr {
__le16 signature;
__le16 reserved_1;
u8 reserved_2;
u8 msg_type;
__le16 reserved_3;
} __packed;
/**
* struct qts_timeval - Structure to carry time information.
* @tv_sec: Seconds part of the time.
* @tv_usec: uS (microseconds) part of the time.
*/
struct qts_timeval {
__le64 tv_sec;
__le64 tv_usec;
} __packed;
/**
* struct qts_host_time_sync_msg_data - Structure to denote the timesync message.
* @header: Header of the timesync message.
* @data: Time information.
*/
struct qts_host_time_sync_msg_data {
struct qts_hdr header;
struct qts_timeval data;
} __packed;
/**
* struct mqts_dev - MHI QAIC Timesync Control device.
* @qdev: Pointer to the root device struct driven by QAIC driver.
* @mhi_dev: Pointer to associated MHI device.
* @timer: Timer handle used for timesync.
* @qtimer_addr: Device QTimer register pointer.
* @buff_in_use: atomic variable to track if the sync_msg buffer is in use.
* @dev: Device pointer to qdev->pdev->dev stored for easy access.
* @sync_msg: Buffer used to send timesync message over MHI.
*/
struct mqts_dev {
struct qaic_device *qdev;
struct mhi_device *mhi_dev;
struct timer_list timer;
void __iomem *qtimer_addr;
atomic_t buff_in_use;
struct device *dev;
struct qts_host_time_sync_msg_data *sync_msg;
};
struct qts_resp_msg {
struct qts_hdr hdr;
} __packed;
struct qts_resp {
struct qts_resp_msg data;
struct work_struct work;
struct qaic_device *qdev;
};
#ifdef readq
static u64 read_qtimer(const volatile void __iomem *addr)
{
return readq(addr);
}
#else
static u64 read_qtimer(const volatile void __iomem *addr)
{
u64 low, high;
low = readl(addr);
high = readl(addr + sizeof(u32));
return low | (high << 32);
}
#endif
static void qaic_timesync_ul_xfer_cb(struct mhi_device *mhi_dev, struct mhi_result *mhi_result)
{
struct mqts_dev *mqtsdev = dev_get_drvdata(&mhi_dev->dev);
dev_dbg(mqtsdev->dev, "%s status: %d xfer_len: %zu\n", __func__,
mhi_result->transaction_status, mhi_result->bytes_xferd);
atomic_set(&mqtsdev->buff_in_use, 0);
}
static void qaic_timesync_dl_xfer_cb(struct mhi_device *mhi_dev, struct mhi_result *mhi_result)
{
struct mqts_dev *mqtsdev = dev_get_drvdata(&mhi_dev->dev);
dev_err(mqtsdev->dev, "%s no data expected on dl channel\n", __func__);
}
Annotation
- Immediate include surface: `linux/io.h`, `linux/kernel.h`, `linux/math64.h`, `linux/mhi.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/time64.h`, `linux/timer.h`.
- Detected declarations: `struct qts_hdr`, `struct qts_timeval`, `struct qts_host_time_sync_msg_data`, `struct mqts_dev`, `struct qts_resp_msg`, `struct qts_resp`, `enum qts_msg_type`, `function read_qtimer`, `function read_qtimer`, `function qaic_timesync_ul_xfer_cb`.
- Atlas domain: Driver Families / drivers/accel.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.