drivers/s390/cio/cio.c
Source file repositories/reference/linux-study-clean/drivers/s390/cio/cio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/s390/cio/cio.c- Extension
.c- Size
- 18317 bytes
- Lines
- 762
- Domain
- Driver Families
- Bucket
- drivers/s390
- 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.
- 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/export.hlinux/ftrace.hlinux/module.hlinux/init.hlinux/slab.hlinux/device.hlinux/kernel_stat.hlinux/interrupt.hlinux/irq.hasm/cio.hasm/delay.hasm/irq.hasm/irq_regs.hasm/setup.hasm/ipl.hasm/chpid.hasm/airq.hasm/isc.hlinux/sched/cputime.hasm/fcx.hasm/nmi.hasm/crw.hcio.hcss.hchsc.hioasm.hio_sch.hblacklist.hcio_debug.hchp.htrace.h
Detected Declarations
function cio_debug_initfunction cio_set_optionsfunction cio_start_handle_notoperfunction cio_startfunction cio_resumefunction cio_haltfunction cio_clearfunction cio_cancelfunction cio_cancel_halt_clearfunction cio_apply_configfunction cio_check_configfunction cio_commit_configfunction cio_update_schibfunction cio_enable_subchannelfunction cio_disable_subchannelfunction do_cio_interruptfunction init_cio_interruptsfunction cio_tschfunction cio_test_for_consolefunction cio_get_console_sch_nofunction cio_is_consolefunction cio_register_early_subchannelsfunction cio_tm_start_keyfunction cio_tm_intrgexport cio_start_keyexport cio_startexport cio_resumeexport cio_haltexport cio_clearexport cio_cancelexport cio_cancel_halt_clearexport cio_commit_configexport cio_update_schibexport cio_enable_subchannelexport cio_disable_subchannelexport cio_tm_start_keyexport cio_tm_intrg
Annotated Snippet
if (!scsw_is_tm(&sch->schib.scsw)) {
ret = cio_cancel(sch);
if (ret != -EINVAL)
return ret;
}
/*
* Cancel io unsuccessful or not applicable (transport mode).
* Continue with asynchronous instructions.
*/
*iretry = 3; /* 3 halt retries. */
}
/* Stage 2: halt io. */
if (!(scsw_actl(&sch->schib.scsw) & SCSW_ACTL_CLEAR_PEND)) {
if (*iretry) {
*iretry -= 1;
ret = cio_halt(sch);
if (ret != -EBUSY)
return (ret == 0) ? -EBUSY : ret;
}
/* Halt io unsuccessful. */
*iretry = 255; /* 255 clear retries. */
}
/* Stage 3: clear io. */
if (*iretry) {
*iretry -= 1;
ret = cio_clear(sch);
return (ret == 0) ? -EBUSY : ret;
}
/* Function was unsuccessful */
return -EIO;
}
EXPORT_SYMBOL_GPL(cio_cancel_halt_clear);
static void cio_apply_config(struct subchannel *sch, struct schib *schib)
{
schib->pmcw.intparm = sch->config.intparm;
schib->pmcw.mbi = sch->config.mbi;
schib->pmcw.isc = sch->config.isc;
schib->pmcw.ena = sch->config.ena;
schib->pmcw.mme = sch->config.mme;
schib->pmcw.mp = sch->config.mp;
schib->pmcw.csense = sch->config.csense;
schib->pmcw.mbfc = sch->config.mbfc;
if (sch->config.mbfc)
schib->mba = sch->config.mba;
}
static int cio_check_config(struct subchannel *sch, struct schib *schib)
{
return (schib->pmcw.intparm == sch->config.intparm) &&
(schib->pmcw.mbi == sch->config.mbi) &&
(schib->pmcw.isc == sch->config.isc) &&
(schib->pmcw.ena == sch->config.ena) &&
(schib->pmcw.mme == sch->config.mme) &&
(schib->pmcw.mp == sch->config.mp) &&
(schib->pmcw.csense == sch->config.csense) &&
(schib->pmcw.mbfc == sch->config.mbfc) &&
(!sch->config.mbfc || (schib->mba == sch->config.mba));
}
/*
* cio_commit_config - apply configuration to the subchannel
*/
int cio_commit_config(struct subchannel *sch)
{
int ccode, retry, ret = 0;
struct schib schib;
struct irb irb;
if (stsch(sch->schid, &schib) || !css_sch_is_valid(&schib))
return -ENODEV;
for (retry = 0; retry < 5; retry++) {
/* copy desired changes to local schib */
cio_apply_config(sch, &schib);
ccode = msch(sch->schid, &schib);
if (ccode < 0) /* -EIO if msch gets a program check. */
return ccode;
switch (ccode) {
case 0: /* successful */
if (stsch(sch->schid, &schib) ||
!css_sch_is_valid(&schib))
return -ENODEV;
if (cio_check_config(sch, &schib)) {
/* commit changes from local schib */
memcpy(&sch->schib, &schib, sizeof(schib));
return 0;
}
ret = -EAGAIN;
break;
Annotation
- Immediate include surface: `linux/export.h`, `linux/ftrace.h`, `linux/module.h`, `linux/init.h`, `linux/slab.h`, `linux/device.h`, `linux/kernel_stat.h`, `linux/interrupt.h`.
- Detected declarations: `function cio_debug_init`, `function cio_set_options`, `function cio_start_handle_notoper`, `function cio_start`, `function cio_resume`, `function cio_halt`, `function cio_clear`, `function cio_cancel`, `function cio_cancel_halt_clear`, `function cio_apply_config`.
- Atlas domain: Driver Families / drivers/s390.
- Implementation status: integration 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.