drivers/net/ipa/ipa_mem.c
Source file repositories/reference/linux-study-clean/drivers/net/ipa/ipa_mem.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ipa/ipa_mem.c- Extension
.c- Size
- 18398 bytes
- Lines
- 706
- Domain
- Driver Families
- Bucket
- drivers/net
- 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 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/dma-mapping.hlinux/io.hlinux/iommu.hlinux/of_address.hlinux/platform_device.hlinux/types.hlinux/soc/qcom/smem.hgsi_trans.hipa.hipa_cmd.hipa_data.hipa_mem.hipa_reg.hipa_table.h
Detected Declarations
function Copyrightfunction ipa_mem_zero_region_addfunction ipa_mem_setupfunction ipa_mem_id_validfunction ipa_mem_id_requiredfunction ipa_mem_valid_onefunction ipa_mem_validfunction ipa_mem_size_validfunction ipa_mem_configfunction ipa_mem_deconfigfunction ipa_mem_zero_modemfunction ipa_imem_initfunction ipa_imem_exitfunction ipa_smem_initfunction ipa_smem_exitfunction ipa_mem_initfunction ipa_mem_exit
Annotated Snippet
if (__test_and_set_bit(mem->id, regions)) {
dev_err(dev, "duplicate memory region %u\n", mem->id);
return false;
}
/* Defined regions have non-zero size and/or canary count */
if (!ipa_mem_valid_one(ipa, mem))
return false;
}
/* Now see if any required regions are not defined */
for_each_clear_bit(mem_id, regions, IPA_MEM_COUNT) {
if (ipa_mem_id_required(ipa, mem_id))
dev_err(dev, "required memory region %u missing\n",
mem_id);
}
return true;
}
/* Do all memory regions fit within the IPA local memory? */
static bool ipa_mem_size_valid(struct ipa *ipa)
{
struct device *dev = ipa->dev;
u32 limit = ipa->mem_size;
u32 i;
for (i = 0; i < ipa->mem_count; i++) {
const struct ipa_mem *mem = &ipa->mem[i];
if (mem->offset + mem->size <= limit)
continue;
dev_err(dev, "region %u ends beyond memory limit (0x%08x)\n",
mem->id, limit);
return false;
}
return true;
}
/**
* ipa_mem_config() - Configure IPA shared memory
* @ipa: IPA pointer
*
* Return: 0 if successful, or a negative error code
*/
int ipa_mem_config(struct ipa *ipa)
{
struct device *dev = ipa->dev;
const struct ipa_mem *mem;
const struct reg *reg;
dma_addr_t addr;
u32 mem_size;
void *virt;
u32 val;
u32 i;
/* Check the advertised location and size of the shared memory area */
reg = ipa_reg(ipa, SHARED_MEM_SIZE);
val = ioread32(ipa->reg_virt + reg_offset(reg));
/* The fields in the register are in 8 byte units */
ipa->mem_offset = 8 * reg_decode(reg, MEM_BADDR, val);
/* Make sure the end is within the region's mapped space */
mem_size = 8 * reg_decode(reg, MEM_SIZE, val);
/* If the sizes don't match, issue a warning */
if (ipa->mem_offset + mem_size < ipa->mem_size) {
dev_warn(dev, "limiting IPA memory size to 0x%08x\n",
mem_size);
ipa->mem_size = mem_size;
} else if (ipa->mem_offset + mem_size > ipa->mem_size) {
dev_dbg(dev, "ignoring larger reported memory size: 0x%08x\n",
mem_size);
}
/* We know our memory size; make sure regions are all in range */
if (!ipa_mem_size_valid(ipa))
return -EINVAL;
/* Prealloc DMA memory for zeroing regions */
virt = dma_alloc_coherent(dev, IPA_MEM_MAX, &addr, GFP_KERNEL);
if (!virt)
return -ENOMEM;
ipa->zero_addr = addr;
ipa->zero_virt = virt;
ipa->zero_size = IPA_MEM_MAX;
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/io.h`, `linux/iommu.h`, `linux/of_address.h`, `linux/platform_device.h`, `linux/types.h`, `linux/soc/qcom/smem.h`, `gsi_trans.h`.
- Detected declarations: `function Copyright`, `function ipa_mem_zero_region_add`, `function ipa_mem_setup`, `function ipa_mem_id_valid`, `function ipa_mem_id_required`, `function ipa_mem_valid_one`, `function ipa_mem_valid`, `function ipa_mem_size_valid`, `function ipa_mem_config`, `function ipa_mem_deconfig`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- 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.