drivers/scsi/esas2r/esas2r_ioctl.c
Source file repositories/reference/linux-study-clean/drivers/scsi/esas2r/esas2r_ioctl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/esas2r/esas2r_ioctl.c- Extension
.c- Size
- 51775 bytes
- Lines
- 2084
- Domain
- Driver Families
- Bucket
- drivers/scsi
- 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.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hesas2r.h
Detected Declarations
struct esas2r_buffered_ioctlfunction complete_fm_api_reqfunction get_physaddr_fm_apifunction get_physaddr_fm_api_headerfunction do_fm_apifunction complete_nvr_reqfunction get_physaddr_buffered_ioctlfunction complete_buffered_ioctl_reqfunction handle_buffered_ioctlfunction smp_ioctl_callbackfunction handle_smp_ioctlfunction esas2r_csmi_ioctl_tunnel_comp_cbfunction csmi_ioctl_tunnelfunction check_lunfunction csmi_ioctl_callbackfunction csmi_ioctl_done_callbackfunction handle_csmi_ioctlfunction hba_ioctl_tunnelfunction scsi_passthru_comp_cbfunction hba_ioctl_callbackfunction hba_ioctl_done_callbackfunction handle_hba_ioctlfunction esas2r_write_paramsfunction esas2r_ioctl_handlerfunction esas2r_ioctlfunction free_fw_buffersfunction allocate_fw_buffersfunction esas2r_read_fwfunction esas2r_write_fwfunction vda_complete_reqfunction get_physaddr_vdafunction esas2r_read_vdafunction esas2r_write_vdafunction fs_api_complete_reqfunction get_physaddr_fs_apifunction esas2r_read_fsfunction esas2r_write_fs
Annotated Snippet
struct esas2r_buffered_ioctl {
struct esas2r_adapter *a;
void *ioctl;
u32 length;
u32 control_code;
u32 offset;
BUFFERED_IOCTL_CALLBACK
callback;
void *context;
BUFFERED_IOCTL_DONE_CALLBACK
done_callback;
void *done_context;
};
static void complete_fm_api_req(struct esas2r_adapter *a,
struct esas2r_request *rq)
{
a->fm_api_command_done = 1;
wake_up_interruptible(&a->fm_api_waiter);
}
/* Callbacks for building scatter/gather lists for FM API requests */
static u32 get_physaddr_fm_api(struct esas2r_sg_context *sgc, u64 *addr)
{
struct esas2r_adapter *a = (struct esas2r_adapter *)sgc->adapter;
int offset = sgc->cur_offset - a->save_offset;
(*addr) = a->firmware.phys + offset;
return a->firmware.orig_len - offset;
}
static u32 get_physaddr_fm_api_header(struct esas2r_sg_context *sgc, u64 *addr)
{
struct esas2r_adapter *a = (struct esas2r_adapter *)sgc->adapter;
int offset = sgc->cur_offset - a->save_offset;
(*addr) = a->firmware.header_buff_phys + offset;
return sizeof(struct esas2r_flash_img) - offset;
}
/* Handle EXPRESS_IOCTL_RW_FIRMWARE ioctl with img_type = FW_IMG_FM_API. */
static void do_fm_api(struct esas2r_adapter *a, struct esas2r_flash_img *fi)
{
struct esas2r_request *rq;
if (mutex_lock_interruptible(&a->fm_api_mutex)) {
fi->status = FI_STAT_BUSY;
return;
}
rq = esas2r_alloc_request(a);
if (rq == NULL) {
fi->status = FI_STAT_BUSY;
goto free_sem;
}
if (fi == &a->firmware.header) {
a->firmware.header_buff = dma_alloc_coherent(&a->pcid->dev,
(size_t)sizeof(
struct
esas2r_flash_img),
(dma_addr_t *)&a->
firmware.
header_buff_phys,
GFP_KERNEL);
if (a->firmware.header_buff == NULL) {
esas2r_debug("failed to allocate header buffer!");
fi->status = FI_STAT_BUSY;
goto free_req;
}
memcpy(a->firmware.header_buff, fi,
sizeof(struct esas2r_flash_img));
a->save_offset = a->firmware.header_buff;
a->fm_api_sgc.get_phys_addr =
(PGETPHYSADDR)get_physaddr_fm_api_header;
} else {
a->save_offset = (u8 *)fi;
a->fm_api_sgc.get_phys_addr =
(PGETPHYSADDR)get_physaddr_fm_api;
}
rq->comp_cb = complete_fm_api_req;
a->fm_api_command_done = 0;
a->fm_api_sgc.cur_offset = a->save_offset;
if (!esas2r_fm_api(a, (struct esas2r_flash_img *)a->save_offset, rq,
&a->fm_api_sgc))
Annotation
- Immediate include surface: `linux/bitfield.h`, `esas2r.h`.
- Detected declarations: `struct esas2r_buffered_ioctl`, `function complete_fm_api_req`, `function get_physaddr_fm_api`, `function get_physaddr_fm_api_header`, `function do_fm_api`, `function complete_nvr_req`, `function get_physaddr_buffered_ioctl`, `function complete_buffered_ioctl_req`, `function handle_buffered_ioctl`, `function smp_ioctl_callback`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: source 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.
- 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.