drivers/block/ps3disk.c
Source file repositories/reference/linux-study-clean/drivers/block/ps3disk.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/block/ps3disk.c- Extension
.c- Size
- 13399 bytes
- Lines
- 561
- Domain
- Driver Families
- Bucket
- drivers/block
- 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.
- 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/ata.hlinux/blk-mq.hlinux/slab.hlinux/module.hasm/lv1call.hasm/ps3stor.hasm/firmware.h
Detected Declarations
struct ps3disk_privatestruct lv1_ata_cmnd_blockenum lv1_ata_protoenum lv1_ata_in_outfunction ps3disk_scatter_gatherfunction rq_for_each_segmentfunction ps3disk_submit_request_sgfunction ps3disk_submit_flush_requestfunction ps3disk_do_requestfunction ps3disk_queue_rqfunction ps3disk_interruptfunction ps3disk_sync_cachefunction swap_buf_le16function ata_id_n_sectorsfunction ata_id_stringfunction ata_id_c_stringfunction ps3disk_identifyfunction ps3disk_probefunction ps3disk_removefunction ps3disk_initfunction ps3disk_exitmodule init ps3disk_init
Annotated Snippet
static const struct blk_mq_ops ps3disk_mq_ops = {
.queue_rq = ps3disk_queue_rq,
};
static int ps3disk_probe(struct ps3_system_bus_device *_dev)
{
struct ps3_storage_device *dev = to_ps3_storage_device(&_dev->core);
struct ps3disk_private *priv;
int error;
unsigned int devidx;
struct queue_limits lim = {
.logical_block_size = dev->blk_size,
.max_hw_sectors = BOUNCE_SIZE >> 9,
.max_segments = -1,
.max_segment_size = BOUNCE_SIZE,
.dma_alignment = dev->blk_size - 1,
.features = BLK_FEAT_WRITE_CACHE |
BLK_FEAT_ROTATIONAL,
};
struct gendisk *gendisk;
if (dev->blk_size < 512) {
dev_err(&dev->sbd.core,
"%s:%u: cannot handle block size %llu\n", __func__,
__LINE__, dev->blk_size);
return -EINVAL;
}
BUILD_BUG_ON(PS3DISK_MAX_DISKS > BITS_PER_LONG);
mutex_lock(&ps3disk_mask_mutex);
devidx = find_first_zero_bit(&ps3disk_mask, PS3DISK_MAX_DISKS);
if (devidx >= PS3DISK_MAX_DISKS) {
dev_err(&dev->sbd.core, "%s:%u: Too many disks\n", __func__,
__LINE__);
mutex_unlock(&ps3disk_mask_mutex);
return -ENOSPC;
}
__set_bit(devidx, &ps3disk_mask);
mutex_unlock(&ps3disk_mask_mutex);
priv = kzalloc_obj(*priv);
if (!priv) {
error = -ENOMEM;
goto fail;
}
ps3_system_bus_set_drvdata(_dev, priv);
spin_lock_init(&priv->lock);
dev->bounce_size = BOUNCE_SIZE;
dev->bounce_buf = kmalloc(BOUNCE_SIZE, GFP_DMA);
if (!dev->bounce_buf) {
error = -ENOMEM;
goto fail_free_priv;
}
error = ps3stor_setup(dev, ps3disk_interrupt);
if (error)
goto fail_free_bounce;
ps3disk_identify(dev);
error = blk_mq_alloc_sq_tag_set(&priv->tag_set, &ps3disk_mq_ops, 1, 0);
if (error)
goto fail_teardown;
gendisk = blk_mq_alloc_disk(&priv->tag_set, &lim, dev);
if (IS_ERR(gendisk)) {
dev_err(&dev->sbd.core, "%s:%u: blk_mq_alloc_disk failed\n",
__func__, __LINE__);
error = PTR_ERR(gendisk);
goto fail_free_tag_set;
}
priv->gendisk = gendisk;
gendisk->major = ps3disk_major;
gendisk->first_minor = devidx * PS3DISK_MINORS;
gendisk->minors = PS3DISK_MINORS;
gendisk->fops = &ps3disk_fops;
gendisk->private_data = dev;
snprintf(gendisk->disk_name, sizeof(gendisk->disk_name), PS3DISK_NAME,
devidx+'a');
priv->blocking_factor = dev->blk_size >> 9;
set_capacity(gendisk,
dev->regions[dev->region_idx].size*priv->blocking_factor);
dev_info(&dev->sbd.core,
"%s is a %s (%llu MiB total, %llu MiB for OtherOS)\n",
gendisk->disk_name, priv->model, priv->raw_capacity >> 11,
get_capacity(gendisk) >> 11);
Annotation
- Immediate include surface: `linux/ata.h`, `linux/blk-mq.h`, `linux/slab.h`, `linux/module.h`, `asm/lv1call.h`, `asm/ps3stor.h`, `asm/firmware.h`.
- Detected declarations: `struct ps3disk_private`, `struct lv1_ata_cmnd_block`, `enum lv1_ata_proto`, `enum lv1_ata_in_out`, `function ps3disk_scatter_gather`, `function rq_for_each_segment`, `function ps3disk_submit_request_sg`, `function ps3disk_submit_flush_request`, `function ps3disk_do_request`, `function ps3disk_queue_rq`.
- Atlas domain: Driver Families / drivers/block.
- Implementation status: pattern 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.