drivers/rapidio/rio_cm.c
Source file repositories/reference/linux-study-clean/drivers/rapidio/rio_cm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rapidio/rio_cm.c- Extension
.c- Size
- 54955 bytes
- Lines
- 2372
- Domain
- Driver Families
- Bucket
- drivers/rapidio
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/module.hlinux/kernel.hlinux/dma-mapping.hlinux/delay.hlinux/sched.hlinux/rio.hlinux/rio_drv.hlinux/slab.hlinux/idr.hlinux/interrupt.hlinux/cdev.hlinux/fs.hlinux/poll.hlinux/reboot.hlinux/bitops.hlinux/printk.hlinux/rio_cm_cdev.h
Detected Declarations
struct rio_ch_base_bhdrstruct rio_ch_chan_hdrstruct tx_reqstruct cm_devstruct chan_rx_ringstruct rio_channelstruct cm_peerstruct conn_reqstruct channel_devenum rio_cm_stateenum rio_cm_pkt_typeenum rio_cm_chopfunction riocm_cmpfunction riocm_cmp_exchfunction riocm_exchfunction riocm_put_channelfunction riocm_rx_fillfunction riocm_rx_freefunction riocm_req_handlerfunction riocm_resp_handlerfunction riocm_close_handlerfunction rio_cm_handlerfunction rio_rx_data_handlerfunction rio_ibmsg_handlerfunction riocm_inb_msg_eventfunction rio_txcq_handlerfunction list_for_each_entry_safefunction riocm_outb_msg_eventfunction riocm_queue_reqfunction riocm_post_sendfunction riocm_ch_sendfunction riocm_ch_free_rxbuffunction riocm_ch_receivefunction riocm_ch_connectfunction riocm_send_ackfunction riocm_ch_listenfunction riocm_ch_bindfunction rangefunction riocm_ch_freefunction riocm_send_closefunction riocm_ch_closefunction riocm_cdev_openfunction riocm_cdev_releasefunction cm_ep_get_list_sizefunction cm_ep_get_listfunction list_for_each_entryfunction cm_mport_get_listfunction cm_chan_create
Annotated Snippet
static const struct file_operations riocm_cdev_fops = {
.owner = THIS_MODULE,
.open = riocm_cdev_open,
.release = riocm_cdev_release,
.unlocked_ioctl = riocm_cdev_ioctl,
};
/*
* riocm_add_dev - add new remote RapidIO device into channel management core
* @dev: device object associated with RapidIO device
* @sif: subsystem interface
*
* Adds the specified RapidIO device (if applicable) into peers list of
* the corresponding channel management device (cm_dev).
*/
static int riocm_add_dev(struct device *dev, struct subsys_interface *sif)
{
struct cm_peer *peer;
struct rio_dev *rdev = to_rio_dev(dev);
struct cm_dev *cm;
/* Check if the remote device has capabilities required to support CM */
if (!dev_cm_capable(rdev))
return 0;
riocm_debug(RDEV, "(%s)", rio_name(rdev));
peer = kmalloc_obj(*peer);
if (!peer)
return -ENOMEM;
/* Find a corresponding cm_dev object */
down_write(&rdev_sem);
list_for_each_entry(cm, &cm_dev_list, list) {
if (cm->mport == rdev->net->hport)
goto found;
}
up_write(&rdev_sem);
kfree(peer);
return -ENODEV;
found:
peer->rdev = rdev;
list_add_tail(&peer->node, &cm->peers);
cm->npeers++;
up_write(&rdev_sem);
return 0;
}
/*
* riocm_remove_dev - remove remote RapidIO device from channel management core
* @dev: device object associated with RapidIO device
* @sif: subsystem interface
*
* Removes the specified RapidIO device (if applicable) from peers list of
* the corresponding channel management device (cm_dev).
*/
static void riocm_remove_dev(struct device *dev, struct subsys_interface *sif)
{
struct rio_dev *rdev = to_rio_dev(dev);
struct cm_dev *cm;
struct cm_peer *peer;
struct rio_channel *ch, *_c;
unsigned int i;
bool found = false;
LIST_HEAD(list);
/* Check if the remote device has capabilities required to support CM */
if (!dev_cm_capable(rdev))
return;
riocm_debug(RDEV, "(%s)", rio_name(rdev));
/* Find matching cm_dev object */
down_write(&rdev_sem);
list_for_each_entry(cm, &cm_dev_list, list) {
if (cm->mport == rdev->net->hport) {
found = true;
break;
}
}
if (!found) {
up_write(&rdev_sem);
return;
}
/* Remove remote device from the list of peers */
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/dma-mapping.h`, `linux/delay.h`, `linux/sched.h`, `linux/rio.h`, `linux/rio_drv.h`, `linux/slab.h`.
- Detected declarations: `struct rio_ch_base_bhdr`, `struct rio_ch_chan_hdr`, `struct tx_req`, `struct cm_dev`, `struct chan_rx_ring`, `struct rio_channel`, `struct cm_peer`, `struct conn_req`, `struct channel_dev`, `enum rio_cm_state`.
- Atlas domain: Driver Families / drivers/rapidio.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.