drivers/soc/qcom/smem.c
Source file repositories/reference/linux-study-clean/drivers/soc/qcom/smem.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/qcom/smem.c- Extension
.c- Size
- 34223 bytes
- Lines
- 1291
- Domain
- Driver Families
- Bucket
- drivers/soc
- 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.
- 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/hwspinlock.hlinux/io.hlinux/module.hlinux/of.hlinux/of_address.hlinux/of_reserved_mem.hlinux/platform_device.hlinux/sizes.hlinux/slab.hlinux/soc/qcom/smem.hlinux/soc/qcom/socinfo.h
Detected Declarations
struct smem_proc_commstruct smem_global_entrystruct smem_headerstruct smem_ptable_entrystruct smem_ptablestruct smem_partition_headerstruct smem_partitionstruct smem_private_entrystruct smem_infostruct smem_regionstruct qcom_smemfunction phdr_to_last_uncached_entryfunction phdr_to_first_cached_entryfunction phdr_to_last_cached_entryfunction phdr_to_first_uncached_entryfunction uncached_entry_nextfunction cached_entry_nextfunction qcom_smem_bust_hwspin_lock_by_hostfunction qcom_smem_is_availablefunction qcom_smem_alloc_privatefunction qcom_smem_alloc_globalfunction qcom_smem_allocfunction qcom_smem_getfunction qcom_smem_get_free_spacefunction addr_in_rangefunction qcom_smem_virt_to_physfunction xa_for_eachfunction qcom_smem_get_soc_idfunction qcom_smem_get_feature_codefunction qcom_smem_get_sbl_versionfunction qcom_smem_get_item_countfunction qcom_smem_partition_headerfunction qcom_smem_set_global_partitionfunction qcom_smem_enumerate_partitionsfunction qcom_smem_map_tocfunction qcom_smem_map_globalfunction qcom_smem_resolve_memfunction qcom_smem_probefunction le32_to_cpufunction qcom_smem_removefunction qcom_smem_initfunction qcom_smem_exitexport qcom_smem_bust_hwspin_lock_by_hostexport qcom_smem_is_availableexport qcom_smem_allocexport qcom_smem_getexport qcom_smem_get_free_spaceexport qcom_smem_virt_to_phys
Annotated Snippet
struct smem_proc_comm {
__le32 command;
__le32 status;
__le32 params[2];
};
/**
* struct smem_global_entry - entry to reference smem items on the heap
* @allocated: boolean to indicate if this entry is used
* @offset: offset to the allocated space
* @size: size of the allocated space, 8 byte aligned
* @aux_base: base address for the memory region used by this unit, or 0 for
* the default region. bits 0,1 are reserved
*/
struct smem_global_entry {
__le32 allocated;
__le32 offset;
__le32 size;
__le32 aux_base; /* bits 1:0 reserved */
};
#define AUX_BASE_MASK 0xfffffffc
/**
* struct smem_header - header found in beginning of primary smem region
* @proc_comm: proc_comm communication interface (legacy)
* @version: array of versions for the various subsystems
* @initialized: boolean to indicate that smem is initialized
* @free_offset: index of the first unallocated byte in smem
* @available: number of bytes available for allocation
* @reserved: reserved field, must be 0
* @toc: array of references to items
*/
struct smem_header {
struct smem_proc_comm proc_comm[4];
__le32 version[32];
__le32 initialized;
__le32 free_offset;
__le32 available;
__le32 reserved;
struct smem_global_entry toc[SMEM_ITEM_COUNT];
};
/**
* struct smem_ptable_entry - one entry in the @smem_ptable list
* @offset: offset, within the main shared memory region, of the partition
* @size: size of the partition
* @flags: flags for the partition (currently unused)
* @host0: first processor/host with access to this partition
* @host1: second processor/host with access to this partition
* @cacheline: alignment for "cached" entries
* @reserved: reserved entries for later use
*/
struct smem_ptable_entry {
__le32 offset;
__le32 size;
__le32 flags;
__le16 host0;
__le16 host1;
__le32 cacheline;
__le32 reserved[7];
};
/**
* struct smem_ptable - partition table for the private partitions
* @magic: magic number, must be SMEM_PTABLE_MAGIC
* @version: version of the partition table
* @num_entries: number of partitions in the table
* @reserved: for now reserved entries
* @entry: list of @smem_ptable_entry for the @num_entries partitions
*/
struct smem_ptable {
u8 magic[4];
__le32 version;
__le32 num_entries;
__le32 reserved[5];
struct smem_ptable_entry entry[];
};
static const u8 SMEM_PTABLE_MAGIC[] = { 0x24, 0x54, 0x4f, 0x43 }; /* "$TOC" */
/**
* struct smem_partition_header - header of the partitions
* @magic: magic number, must be SMEM_PART_MAGIC
* @host0: first processor/host with access to this partition
* @host1: second processor/host with access to this partition
* @size: size of the partition
* @offset_free_uncached: offset to the first free byte of uncached memory in
* this partition
* @offset_free_cached: offset to the first free byte of cached memory in this
* partition
Annotation
- Immediate include surface: `linux/hwspinlock.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_reserved_mem.h`, `linux/platform_device.h`, `linux/sizes.h`.
- Detected declarations: `struct smem_proc_comm`, `struct smem_global_entry`, `struct smem_header`, `struct smem_ptable_entry`, `struct smem_ptable`, `struct smem_partition_header`, `struct smem_partition`, `struct smem_private_entry`, `struct smem_info`, `struct smem_region`.
- Atlas domain: Driver Families / drivers/soc.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.