drivers/platform/surface/aggregator/ssh_request_layer.c
Source file repositories/reference/linux-study-clean/drivers/platform/surface/aggregator/ssh_request_layer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/surface/aggregator/ssh_request_layer.c- Extension
.c- Size
- 38323 bytes
- Lines
- 1275
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/unaligned.hlinux/atomic.hlinux/completion.hlinux/error-injection.hlinux/ktime.hlinux/limits.hlinux/list.hlinux/slab.hlinux/spinlock.hlinux/types.hlinux/workqueue.hlinux/surface_aggregator/serial_hub.hlinux/surface_aggregator/controller.hssh_packet_layer.hssh_request_layer.htrace.h
Detected Declarations
struct ssh_flush_requestfunction Copyrightfunction ssh_rtl_should_drop_responsefunction ssh_request_get_rqidfunction ssh_request_get_rqid_safefunction ssh_rtl_queue_removefunction ssh_rtl_queue_emptyfunction ssh_rtl_pending_removefunction ssh_rtl_tx_pending_pushfunction ssh_rtl_complete_with_statusfunction ssh_rtl_complete_with_rspfunction ssh_rtl_tx_can_processfunction ssh_rtl_tx_try_process_onefunction ssh_rtl_tx_schedulefunction ssh_rtl_tx_work_fnfunction ssh_rtl_submitfunction ssh_rtl_cancel_nonpendingfunction ssh_rtl_timeout_reaper_modfunction ssh_rtl_timeout_startfunction ssh_rtl_completefunction ssh_rtl_cancel_nonpendingfunction ssh_rtl_cancel_pendingfunction ssh_rtl_submitfunction ssh_rtl_cancelfunction ssh_rtl_packet_callbackfunction ssh_request_get_expirationfunction ssh_rtl_timeout_reapfunction ssh_rtl_rx_eventfunction ssh_rtl_rx_commandfunction ssh_rtl_rx_datafunction ssh_rtl_packet_releasefunction ssh_request_initfunction ssh_rtl_initfunction ssh_rtl_destroyfunction ssh_rtl_startfunction ssh_rtl_flush_request_completefunction ssh_rtl_flush_request_releasefunction ssh_rtl_flushfunction ssh_rtl_shutdownfunction list_for_each_entry_safe
Annotated Snippet
struct ssh_flush_request {
struct ssh_request base;
struct completion completion;
int status;
};
static void ssh_rtl_flush_request_complete(struct ssh_request *r,
const struct ssh_command *cmd,
const struct ssam_span *data,
int status)
{
struct ssh_flush_request *rqst;
rqst = container_of(r, struct ssh_flush_request, base);
rqst->status = status;
}
static void ssh_rtl_flush_request_release(struct ssh_request *r)
{
struct ssh_flush_request *rqst;
rqst = container_of(r, struct ssh_flush_request, base);
complete_all(&rqst->completion);
}
static const struct ssh_request_ops ssh_rtl_flush_request_ops = {
.complete = ssh_rtl_flush_request_complete,
.release = ssh_rtl_flush_request_release,
};
/**
* ssh_rtl_flush() - Flush the request transport layer.
* @rtl: request transport layer
* @timeout: timeout for the flush operation in jiffies
*
* Queue a special flush request and wait for its completion. This request
* will be completed after all other currently queued and pending requests
* have been completed. Instead of a normal data packet, this request submits
* a special flush packet, meaning that upon completion, also the underlying
* packet transport layer has been flushed.
*
* Flushing the request layer guarantees that all previously submitted
* requests have been fully completed before this call returns. Additionally,
* flushing blocks execution of all later submitted requests until the flush
* has been completed.
*
* If the caller ensures that no new requests are submitted after a call to
* this function, the request transport layer is guaranteed to have no
* remaining requests when this call returns. The same guarantee does not hold
* for the packet layer, on which control packets may still be queued after
* this call.
*
* Return: Returns zero on success, %-ETIMEDOUT if the flush timed out and has
* been canceled as a result of the timeout, or %-ESHUTDOWN if the packet
* and/or request transport layer has been shut down before this call. May
* also return %-EINTR if the underlying packet transmission has been
* interrupted.
*/
int ssh_rtl_flush(struct ssh_rtl *rtl, unsigned long timeout)
{
const unsigned int init_flags = SSAM_REQUEST_UNSEQUENCED;
struct ssh_flush_request rqst;
int status;
ssh_request_init(&rqst.base, init_flags, &ssh_rtl_flush_request_ops);
rqst.base.packet.state |= BIT(SSH_PACKET_TY_FLUSH_BIT);
rqst.base.packet.priority = SSH_PACKET_PRIORITY(FLUSH, 0);
rqst.base.state |= BIT(SSH_REQUEST_TY_FLUSH_BIT);
init_completion(&rqst.completion);
status = ssh_rtl_submit(rtl, &rqst.base);
if (status)
return status;
ssh_request_put(&rqst.base);
if (!wait_for_completion_timeout(&rqst.completion, timeout)) {
ssh_rtl_cancel(&rqst.base, true);
wait_for_completion(&rqst.completion);
}
WARN_ON(rqst.status != 0 && rqst.status != -ECANCELED &&
rqst.status != -ESHUTDOWN && rqst.status != -EINTR);
return rqst.status == -ECANCELED ? -ETIMEDOUT : rqst.status;
}
/**
* ssh_rtl_shutdown() - Shut down request transport layer.
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/atomic.h`, `linux/completion.h`, `linux/error-injection.h`, `linux/ktime.h`, `linux/limits.h`, `linux/list.h`, `linux/slab.h`.
- Detected declarations: `struct ssh_flush_request`, `function Copyright`, `function ssh_rtl_should_drop_response`, `function ssh_request_get_rqid`, `function ssh_request_get_rqid_safe`, `function ssh_rtl_queue_remove`, `function ssh_rtl_queue_empty`, `function ssh_rtl_pending_remove`, `function ssh_rtl_tx_pending_push`, `function ssh_rtl_complete_with_status`.
- Atlas domain: Driver Families / drivers/platform.
- 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.