arch/s390/include/asm/idals.h
Source file repositories/reference/linux-study-clean/arch/s390/include/asm/idals.h
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/include/asm/idals.h- Extension
.h- Size
- 7865 bytes
- Lines
- 337
- Domain
- Architecture Layer
- Bucket
- arch/s390
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/errno.hlinux/err.hlinux/types.hlinux/slab.hlinux/uaccess.hasm/dma-types.hasm/cio.h
Detected Declarations
struct idal_bufferfunction Authorfunction idal_nr_wordsfunction idal_2k_nr_wordsfunction set_normalized_cdafunction clear_normalized_cdafunction idal_buffer_freefunction idal_buffer_array_freefunction idal_buffer_array_sizefunction idal_buffer_array_datasizefunction __idal_buffer_is_neededfunction idal_buffer_set_cdafunction idal_buffer_to_userfunction idal_buffer_from_user
Annotated Snippet
struct idal_buffer {
size_t size;
size_t page_order;
dma64_t data[];
};
/*
* Allocate an idal buffer
*/
static inline struct idal_buffer *idal_buffer_alloc(size_t size, int page_order)
{
int nr_chunks, nr_ptrs, i;
struct idal_buffer *ib;
void *vaddr;
nr_ptrs = (size + IDA_BLOCK_SIZE - 1) >> IDA_SIZE_SHIFT;
nr_chunks = (PAGE_SIZE << page_order) >> IDA_SIZE_SHIFT;
ib = kmalloc_flex(*ib, data, nr_ptrs, GFP_DMA | GFP_KERNEL);
if (!ib)
return ERR_PTR(-ENOMEM);
ib->size = size;
ib->page_order = page_order;
for (i = 0; i < nr_ptrs; i++) {
if (i & (nr_chunks - 1)) {
ib->data[i] = dma64_add(ib->data[i - 1], IDA_BLOCK_SIZE);
continue;
}
vaddr = (void *)__get_free_pages(GFP_KERNEL, page_order);
if (!vaddr)
goto error;
ib->data[i] = virt_to_dma64(vaddr);
}
return ib;
error:
while (i >= nr_chunks) {
i -= nr_chunks;
vaddr = dma64_to_virt(ib->data[i]);
free_pages((unsigned long)vaddr, ib->page_order);
}
kfree(ib);
return ERR_PTR(-ENOMEM);
}
/*
* Free an idal buffer.
*/
static inline void idal_buffer_free(struct idal_buffer *ib)
{
int nr_chunks, nr_ptrs, i;
void *vaddr;
nr_ptrs = (ib->size + IDA_BLOCK_SIZE - 1) >> IDA_SIZE_SHIFT;
nr_chunks = (PAGE_SIZE << ib->page_order) >> IDA_SIZE_SHIFT;
for (i = 0; i < nr_ptrs; i += nr_chunks) {
vaddr = dma64_to_virt(ib->data[i]);
free_pages((unsigned long)vaddr, ib->page_order);
}
kfree(ib);
}
/*
* Allocate an array of IDAL buffers to cover a total data size of @size. The
* resulting array is null-terminated.
*
* The amount of individual IDAL buffers is determined based on @size.
* Each IDAL buffer can have a maximum size of @CCW_MAX_BYTE_COUNT.
*/
static inline struct idal_buffer **idal_buffer_array_alloc(size_t size, int page_order)
{
struct idal_buffer **ibs;
size_t ib_size; /* Size of a single idal buffer */
int count; /* Amount of individual idal buffers */
int i;
count = (size + CCW_MAX_BYTE_COUNT - 1) / CCW_MAX_BYTE_COUNT;
ibs = kmalloc_objs(*ibs, count + 1);
for (i = 0; i < count; i++) {
/* Determine size for the current idal buffer */
ib_size = min(size, CCW_MAX_BYTE_COUNT);
size -= ib_size;
ibs[i] = idal_buffer_alloc(ib_size, page_order);
if (IS_ERR(ibs[i])) {
while (i--)
idal_buffer_free(ibs[i]);
kfree(ibs);
ibs = NULL;
return ERR_PTR(-ENOMEM);
}
}
ibs[i] = NULL;
Annotation
- Immediate include surface: `linux/errno.h`, `linux/err.h`, `linux/types.h`, `linux/slab.h`, `linux/uaccess.h`, `asm/dma-types.h`, `asm/cio.h`.
- Detected declarations: `struct idal_buffer`, `function Author`, `function idal_nr_words`, `function idal_2k_nr_words`, `function set_normalized_cda`, `function clear_normalized_cda`, `function idal_buffer_free`, `function idal_buffer_array_free`, `function idal_buffer_array_size`, `function idal_buffer_array_datasize`.
- Atlas domain: Architecture Layer / arch/s390.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.