drivers/peci/request.c
Source file repositories/reference/linux-study-clean/drivers/peci/request.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/peci/request.c- Extension
.c- Size
- 13214 bytes
- Lines
- 483
- Domain
- Driver Families
- Bucket
- drivers/peci
- 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.
- 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/bug.hlinux/export.hlinux/pci.hlinux/peci.hlinux/slab.hlinux/types.hlinux/unaligned.hinternal.h
Detected Declarations
function peci_request_data_ccfunction peci_request_statusfunction peci_request_xferfunction peci_request_xfer_retryfunction peci_request_allocfunction peci_request_freefunction __pkg_cfg_readfunction __get_pci_addrfunction __pci_cfg_local_readfunction __ep_pci_cfg_readfunction __ep_mmio_readfunction peci_request_data_readbfunction peci_request_data_readwfunction peci_request_data_readlfunction peci_request_data_readqfunction peci_request_dib_readfunction peci_request_temp_read
Annotated Snippet
if (ret) {
dev_dbg(&controller->dev, "xfer error: %d\n", ret);
return ret;
}
if (peci_request_status(req) != -EAGAIN)
return 0;
/* Set the retry bit to indicate a retry attempt */
req->tx.buf[1] |= PECI_RETRY_BIT;
if (schedule_timeout_interruptible(wait_interval))
return -ERESTARTSYS;
wait_interval = min_t(long, wait_interval * 2, PECI_RETRY_INTERVAL_MAX);
} while (time_before(jiffies, start + PECI_RETRY_TIMEOUT));
dev_dbg(&controller->dev, "request timed out\n");
return -ETIMEDOUT;
}
/**
* peci_request_alloc() - allocate &struct peci_requests
* @device: PECI device to which request is going to be sent
* @tx_len: TX length
* @rx_len: RX length
*
* Return: A pointer to a newly allocated &struct peci_request on success or NULL otherwise.
*/
struct peci_request *peci_request_alloc(struct peci_device *device, u8 tx_len, u8 rx_len)
{
struct peci_request *req;
/*
* TX and RX buffers are fixed length members of peci_request, this is
* just a warn for developers to make sure to expand the buffers (or
* change the allocation method) if we go over the current limit.
*/
if (WARN_ON_ONCE(tx_len > PECI_REQUEST_MAX_BUF_SIZE || rx_len > PECI_REQUEST_MAX_BUF_SIZE))
return NULL;
/*
* PECI controllers that we are using now don't support DMA, this
* should be converted to DMA API once support for controllers that do
* allow it is added to avoid an extra copy.
*/
req = kzalloc_obj(*req);
if (!req)
return NULL;
req->device = device;
req->tx.len = tx_len;
req->rx.len = rx_len;
return req;
}
EXPORT_SYMBOL_NS_GPL(peci_request_alloc, "PECI");
/**
* peci_request_free() - free peci_request
* @req: the PECI request to be freed
*/
void peci_request_free(struct peci_request *req)
{
kfree(req);
}
EXPORT_SYMBOL_NS_GPL(peci_request_free, "PECI");
struct peci_request *peci_xfer_get_dib(struct peci_device *device)
{
struct peci_request *req;
int ret;
req = peci_request_alloc(device, PECI_GET_DIB_WR_LEN, PECI_GET_DIB_RD_LEN);
if (!req)
return ERR_PTR(-ENOMEM);
req->tx.buf[0] = PECI_GET_DIB_CMD;
ret = peci_request_xfer(req);
if (ret) {
peci_request_free(req);
return ERR_PTR(ret);
}
return req;
}
EXPORT_SYMBOL_NS_GPL(peci_xfer_get_dib, "PECI");
struct peci_request *peci_xfer_get_temp(struct peci_device *device)
Annotation
- Immediate include surface: `linux/bug.h`, `linux/export.h`, `linux/pci.h`, `linux/peci.h`, `linux/slab.h`, `linux/types.h`, `linux/unaligned.h`, `internal.h`.
- Detected declarations: `function peci_request_data_cc`, `function peci_request_status`, `function peci_request_xfer`, `function peci_request_xfer_retry`, `function peci_request_alloc`, `function peci_request_free`, `function __pkg_cfg_read`, `function __get_pci_addr`, `function __pci_cfg_local_read`, `function __ep_pci_cfg_read`.
- Atlas domain: Driver Families / drivers/peci.
- 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.