drivers/platform/surface/aggregator/ssh_packet_layer.c
Source file repositories/reference/linux-study-clean/drivers/platform/surface/aggregator/ssh_packet_layer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/surface/aggregator/ssh_packet_layer.c- Extension
.c- Size
- 62294 bytes
- Lines
- 2087
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/unaligned.hlinux/atomic.hlinux/error-injection.hlinux/jiffies.hlinux/kfifo.hlinux/kref.hlinux/kthread.hlinux/ktime.hlinux/limits.hlinux/list.hlinux/lockdep.hlinux/serdev.hlinux/slab.hlinux/spinlock.hlinux/workqueue.hlinux/surface_aggregator/serial_hub.hssh_msgb.hssh_packet_layer.hssh_parser.htrace.h
Detected Declarations
function Copyrightfunction ssh_ptl_should_drop_nak_packetfunction ssh_ptl_should_drop_dsq_packetfunction ssh_ptl_should_fail_writefunction ssh_ptl_should_corrupt_tx_datafunction ssh_ptl_should_corrupt_rx_synfunction ssh_ptl_should_corrupt_rx_datafunction __ssh_ptl_should_drop_ack_packetfunction __ssh_ptl_should_drop_nak_packetfunction __ssh_ptl_should_drop_dsq_packetfunction ssh_ptl_should_drop_packetfunction ssh_ptl_write_buffunction ssh_ptl_tx_inject_invalid_datafunction ssh_ptl_rx_inject_invalid_synfunction ssh_ptl_rx_inject_invalid_datafunction ssh_ptl_should_drop_packetfunction ssh_ptl_write_buffunction ssh_ptl_tx_inject_invalid_datafunction ssh_packet_getfunction ssh_packet_putfunction ssh_packet_get_seqfunction ssh_packet_initfunction ssh_ctrl_packet_cache_initfunction ssh_ctrl_packet_cache_destroyfunction ssh_ctrl_packet_allocfunction ssh_ctrl_packet_freefunction ssh_ptl_timeout_reaper_modfunction ssh_packet_next_tryfunction list_for_each_prevfunction __ssh_ptl_queue_pushfunction ssh_ptl_queue_pushfunction ssh_ptl_queue_removefunction ssh_ptl_pending_pushfunction ssh_ptl_pending_removefunction __ssh_ptl_completefunction ssh_ptl_remove_and_completefunction ssh_ptl_tx_can_processfunction ssh_ptl_tx_compl_successfunction ssh_ptl_tx_compl_errorfunction ssh_ptl_tx_wait_packetfunction ssh_ptl_tx_wait_transferfunction ssh_ptl_tx_packetfunction ssh_ptl_tx_threadfnfunction ssh_ptl_tx_wakeup_packetfunction ssh_ptl_tx_startfunction ssh_ptl_tx_stopfunction ssh_ptl_wait_until_transmittedfunction ssh_ptl_acknowledge
Annotated Snippet
list_for_each(head, &p->ptl->queue.head) {
q = list_entry(head, struct ssh_packet, queue_node);
if (q->priority < p->priority)
break;
}
} else {
list_for_each_prev(head, &p->ptl->queue.head) {
q = list_entry(head, struct ssh_packet, queue_node);
if (q->priority >= p->priority) {
head = head->next;
break;
}
}
}
return head;
}
/* Must be called with queue lock held. */
static int __ssh_ptl_queue_push(struct ssh_packet *packet)
{
struct ssh_ptl *ptl = packet->ptl;
struct list_head *head;
lockdep_assert_held(&ptl->queue.lock);
if (test_bit(SSH_PTL_SF_SHUTDOWN_BIT, &ptl->state))
return -ESHUTDOWN;
/* Avoid further transitions when canceling/completing. */
if (test_bit(SSH_PACKET_SF_LOCKED_BIT, &packet->state))
return -EINVAL;
/* If this packet has already been queued, do not add it. */
if (test_and_set_bit(SSH_PACKET_SF_QUEUED_BIT, &packet->state))
return -EALREADY;
head = __ssh_ptl_queue_find_entrypoint(packet);
list_add_tail(&ssh_packet_get(packet)->queue_node, head);
return 0;
}
static int ssh_ptl_queue_push(struct ssh_packet *packet)
{
int status;
spin_lock(&packet->ptl->queue.lock);
status = __ssh_ptl_queue_push(packet);
spin_unlock(&packet->ptl->queue.lock);
return status;
}
static void ssh_ptl_queue_remove(struct ssh_packet *packet)
{
struct ssh_ptl *ptl = packet->ptl;
spin_lock(&ptl->queue.lock);
if (!test_and_clear_bit(SSH_PACKET_SF_QUEUED_BIT, &packet->state)) {
spin_unlock(&ptl->queue.lock);
return;
}
list_del(&packet->queue_node);
spin_unlock(&ptl->queue.lock);
ssh_packet_put(packet);
}
static void ssh_ptl_pending_push(struct ssh_packet *p)
{
struct ssh_ptl *ptl = p->ptl;
const ktime_t timestamp = ktime_get_coarse_boottime();
const ktime_t timeout = ptl->rtx_timeout.timeout;
/*
* Note: We can get the time for the timestamp before acquiring the
* lock as this is the only place we're setting it and this function
* is called only from the transmitter thread. Thus it is not possible
* to overwrite the timestamp with an outdated value below.
*/
spin_lock(&ptl->pending.lock);
/* If we are canceling/completing this packet, do not add it. */
if (test_bit(SSH_PACKET_SF_LOCKED_BIT, &p->state)) {
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/atomic.h`, `linux/error-injection.h`, `linux/jiffies.h`, `linux/kfifo.h`, `linux/kref.h`, `linux/kthread.h`, `linux/ktime.h`.
- Detected declarations: `function Copyright`, `function ssh_ptl_should_drop_nak_packet`, `function ssh_ptl_should_drop_dsq_packet`, `function ssh_ptl_should_fail_write`, `function ssh_ptl_should_corrupt_tx_data`, `function ssh_ptl_should_corrupt_rx_syn`, `function ssh_ptl_should_corrupt_rx_data`, `function __ssh_ptl_should_drop_ack_packet`, `function __ssh_ptl_should_drop_nak_packet`, `function __ssh_ptl_should_drop_dsq_packet`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: integration 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.