drivers/hid/intel-ish-hid/ipc/ipc.c
Source file repositories/reference/linux-study-clean/drivers/hid/intel-ish-hid/ipc/ipc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/intel-ish-hid/ipc/ipc.c- Extension
.c- Size
- 25683 bytes
- Lines
- 1037
- Domain
- Driver Families
- Bucket
- drivers/hid
- 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/devm-helpers.hlinux/sched.hlinux/spinlock.hlinux/delay.hlinux/jiffies.hclient.hhw-ish.hhbm.h
Detected Declarations
function ish_reg_readfunction ish_reg_writefunction _ish_read_fw_sts_regfunction check_generated_interruptfunction ish_is_input_readyfunction set_host_readyfunction ishtp_fw_is_readyfunction ish_set_host_rdyfunction ish_clr_host_rdyfunction ish_chk_host_rdyfunction ish_set_host_readyfunction _ishtp_read_hdrfunction _ishtp_readfunction write_ipc_from_queuefunction IPC_HEADER_GET_MNG_CMDfunction write_ipc_to_queuefunction ipc_send_mng_msgfunction timed_wait_for_timeoutfunction ish_send_reset_notify_ackfunction ish_fw_reset_handlerfunction fw_reset_work_fnfunction _ish_sync_fw_clockfunction recv_ipcfunction ish_irq_handlerfunction ish_disable_dmafunction ish_wakeupfunction _ish_hw_resetfunction _ish_ipc_resetfunction ish_hw_startfunction ish_ipc_get_headerfunction _dma_no_cache_snoopingfunction ishtp_free_workqueuefunction ish_dev_initfunction ish_device_disable
Annotated Snippet
IPC_HEADER_GET_MNG_CMD(doorbell_val) == MNG_SYNC_FW_CLOCK) {
uint64_t usec_system, usec_utc;
struct ipc_time_update_msg time_update;
struct time_sync_format ts_format;
usec_system = ktime_to_us(ktime_get_boottime());
usec_utc = ktime_to_us(ktime_get_real());
ts_format.ts1_source = HOST_SYSTEM_TIME_USEC;
ts_format.ts2_source = HOST_UTC_TIME_USEC;
ts_format.reserved = 0;
time_update.primary_host_time = usec_system;
time_update.secondary_host_time = usec_utc;
time_update.sync_info = ts_format;
memcpy(r_buf, &time_update,
sizeof(struct ipc_time_update_msg));
}
for (i = 0, reg_addr = IPC_REG_HOST2ISH_MSG; i < length >> 2; i++,
reg_addr += 4)
ish_reg_write(dev, reg_addr, r_buf[i]);
rem = length & 0x3;
if (rem > 0) {
uint32_t reg = 0;
memcpy(®, &r_buf[length >> 2], rem);
ish_reg_write(dev, reg_addr, reg);
}
ish_reg_write(dev, IPC_REG_HOST2ISH_DRBL, doorbell_val);
/* Flush writes to msg registers and doorbell */
ish_reg_read(dev, IPC_REG_ISH_HOST_FWSTS);
/* Update IPC counters */
++dev->ipc_tx_cnt;
dev->ipc_tx_bytes_cnt += IPC_HEADER_GET_LENGTH(doorbell_val);
ipc_send_compl = ipc_link->ipc_send_compl;
ipc_send_compl_prm = ipc_link->ipc_send_compl_prm;
list_del_init(&ipc_link->link);
list_add(&ipc_link->link, &dev->wr_free_list);
spin_unlock_irqrestore(&dev->wr_processing_spinlock, flags);
/*
* callback will be called out of spinlock,
* after ipc_link returned to free list
*/
if (ipc_send_compl)
ipc_send_compl(ipc_send_compl_prm);
return 0;
}
/**
* write_ipc_to_queue() - write ipc msg to Tx queue
* @dev: ishtp device instance
* @ipc_send_compl: Send complete callback
* @ipc_send_compl_prm: Parameter to send in complete callback
* @msg: Pointer to message
* @length: Length of message
*
* Recived msg with IPC (and upper protocol) header and add it to the device
* Tx-to-write list then try to send the first IPC waiting msg
* (if DRBL is cleared)
* This function returns negative value for failure (means free list
* is empty, or msg too long) and 0 for success.
*
* Return: 0 for success else failure code
*/
static int write_ipc_to_queue(struct ishtp_device *dev,
void (*ipc_send_compl)(void *), void *ipc_send_compl_prm,
unsigned char *msg, int length)
{
struct wr_msg_ctl_info *ipc_link;
unsigned long flags;
if (length > IPC_FULL_MSG_SIZE)
return -EMSGSIZE;
spin_lock_irqsave(&dev->wr_processing_spinlock, flags);
if (list_empty(&dev->wr_free_list)) {
spin_unlock_irqrestore(&dev->wr_processing_spinlock, flags);
return -ENOMEM;
}
ipc_link = list_first_entry(&dev->wr_free_list,
struct wr_msg_ctl_info, link);
list_del_init(&ipc_link->link);
Annotation
- Immediate include surface: `linux/devm-helpers.h`, `linux/sched.h`, `linux/spinlock.h`, `linux/delay.h`, `linux/jiffies.h`, `client.h`, `hw-ish.h`, `hbm.h`.
- Detected declarations: `function ish_reg_read`, `function ish_reg_write`, `function _ish_read_fw_sts_reg`, `function check_generated_interrupt`, `function ish_is_input_ready`, `function set_host_ready`, `function ishtp_fw_is_ready`, `function ish_set_host_rdy`, `function ish_clr_host_rdy`, `function ish_chk_host_rdy`.
- Atlas domain: Driver Families / drivers/hid.
- 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.