drivers/s390/char/sclp_mem.c
Source file repositories/reference/linux-study-clean/drivers/s390/char/sclp_mem.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/s390/char/sclp_mem.c- Extension
.c- Size
- 12981 bytes
- Lines
- 537
- Domain
- Driver Families
- Bucket
- drivers/s390
- 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.
- 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/cpufeature.hlinux/container_of.hlinux/err.hlinux/errno.hlinux/init.hlinux/kobject.hlinux/kstrtox.hlinux/memory.hlinux/memory_hotplug.hlinux/mm.hlinux/mmzone.hlinux/slab.hasm/facility.hasm/page.hasm/page-states.hasm/sclp.hsclp.h
Detected Declarations
struct memory_incrementstruct sclp_memstruct sclp_mem_argstruct assign_storage_sccbstruct attach_storage_sccbfunction arch_get_memory_phys_devicefunction rn2addrfunction do_assign_storagefunction sclp_assign_storagefunction sclp_unassign_storagefunction sclp_attach_storagefunction sclp_mem_change_statefunction list_for_each_entryfunction sclp_config_mem_showfunction sclp_config_mem_storefunction sclp_memmap_on_memory_showfunction sclp_memmap_on_memory_storefunction sclp_create_memfunction sclp_create_configured_memfunction align_to_block_sizefunction sclp_create_standby_mems_mergedfunction sclp_create_standby_memsfunction list_for_each_entryfunction sclp_init_memfunction insert_incrementfunction sclp_setup_memory
Annotated Snippet
struct memory_increment {
struct list_head list;
u16 rn;
int standby;
};
struct sclp_mem {
struct kobject kobj;
unsigned int id;
unsigned int memmap_on_memory;
unsigned int config;
#ifdef CONFIG_KASAN
unsigned int early_shadow_mapped;
#endif
};
struct sclp_mem_arg {
struct sclp_mem *sclp_mems;
struct kset *kset;
};
struct assign_storage_sccb {
struct sccb_header header;
u16 rn;
} __packed;
struct attach_storage_sccb {
struct sccb_header header;
u16 :16;
u16 assigned;
u32 :32;
u32 entries[];
} __packed;
int arch_get_memory_phys_device(unsigned long start_pfn)
{
if (!sclp.rzm)
return 0;
return PFN_PHYS(start_pfn) >> ilog2(sclp.rzm);
}
static unsigned long rn2addr(u16 rn)
{
return (unsigned long)(rn - 1) * sclp.rzm;
}
static int do_assign_storage(sclp_cmdw_t cmd, u16 rn)
{
struct assign_storage_sccb *sccb;
int rc;
sccb = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
if (!sccb)
return -ENOMEM;
sccb->header.length = PAGE_SIZE;
sccb->rn = rn;
rc = sclp_sync_request_timeout(cmd, sccb, SCLP_QUEUE_INTERVAL);
if (rc)
goto out;
switch (sccb->header.response_code) {
case 0x0020:
case 0x0120:
break;
default:
pr_warn("assign storage failed (cmd=0x%08x, response=0x%04x, rn=0x%04x)\n",
cmd, sccb->header.response_code, rn);
rc = -EIO;
break;
}
out:
free_page((unsigned long)sccb);
return rc;
}
static int sclp_assign_storage(u16 rn)
{
unsigned long start;
int rc;
rc = do_assign_storage(SCLP_CMDW_ASSIGN_STORAGE, rn);
if (rc)
return rc;
start = rn2addr(rn);
storage_key_init_range(start, start + sclp.rzm);
return 0;
}
static int sclp_unassign_storage(u16 rn)
{
return do_assign_storage(SCLP_CMDW_UNASSIGN_STORAGE, rn);
Annotation
- Immediate include surface: `linux/cpufeature.h`, `linux/container_of.h`, `linux/err.h`, `linux/errno.h`, `linux/init.h`, `linux/kobject.h`, `linux/kstrtox.h`, `linux/memory.h`.
- Detected declarations: `struct memory_increment`, `struct sclp_mem`, `struct sclp_mem_arg`, `struct assign_storage_sccb`, `struct attach_storage_sccb`, `function arch_get_memory_phys_device`, `function rn2addr`, `function do_assign_storage`, `function sclp_assign_storage`, `function sclp_unassign_storage`.
- Atlas domain: Driver Families / drivers/s390.
- Implementation status: source implementation candidate.
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.