drivers/hwtracing/intel_th/sth.c
Source file repositories/reference/linux-study-clean/drivers/hwtracing/intel_th/sth.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwtracing/intel_th/sth.c- Extension
.c- Size
- 5823 bytes
- Lines
- 262
- Domain
- Driver Families
- Bucket
- drivers/hwtracing
- 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/types.hlinux/module.hlinux/device.hlinux/io.hlinux/mm.hlinux/slab.hlinux/stm.hintel_th.hsth.h
Detected Declarations
struct sth_devicefunction sth_channelfunction sth_iowritefunction sth_stm_packetfunction sth_stm_mmio_addrfunction sth_stm_linkfunction intel_th_sw_initfunction intel_th_sth_probefunction intel_th_sth_remove
Annotated Snippet
struct sth_device {
void __iomem *base;
void __iomem *channels;
phys_addr_t channels_phys;
struct device *dev;
struct stm_data stm;
unsigned int sw_nmasters;
};
static struct intel_th_channel __iomem *
sth_channel(struct sth_device *sth, unsigned int master, unsigned int channel)
{
struct intel_th_channel __iomem *sw_map = sth->channels;
return &sw_map[(master - sth->stm.sw_start) * sth->stm.sw_nchannels +
channel];
}
static void sth_iowrite(void __iomem *dest, const unsigned char *payload,
unsigned int size)
{
switch (size) {
#ifdef CONFIG_64BIT
case 8:
writeq_relaxed(*(u64 *)payload, dest);
break;
#endif
case 4:
writel_relaxed(*(u32 *)payload, dest);
break;
case 2:
writew_relaxed(*(u16 *)payload, dest);
break;
case 1:
writeb_relaxed(*(u8 *)payload, dest);
break;
default:
break;
}
}
static ssize_t notrace sth_stm_packet(struct stm_data *stm_data,
unsigned int master,
unsigned int channel,
unsigned int packet,
unsigned int flags,
unsigned int size,
const unsigned char *payload)
{
struct sth_device *sth = container_of(stm_data, struct sth_device, stm);
struct intel_th_channel __iomem *out =
sth_channel(sth, master, channel);
unsigned long reg = REG_STH_TRIG;
u64 __iomem *outp;
#ifndef CONFIG_64BIT
if (size > 4)
size = 4;
#endif
size = rounddown_pow_of_two(size);
switch (packet) {
/* Global packets (GERR, XSYNC, TRIG) are sent with register writes */
case STP_PACKET_GERR:
reg += 4;
fallthrough;
case STP_PACKET_XSYNC:
reg += 8;
fallthrough;
case STP_PACKET_TRIG:
if (flags & STP_PACKET_TIMESTAMPED)
reg += 4;
writeb_relaxed(*payload, sth->base + reg);
break;
case STP_PACKET_MERR:
if (size > 4)
size = 4;
sth_iowrite(&out->MERR, payload, size);
break;
case STP_PACKET_FLAG:
if (flags & STP_PACKET_TIMESTAMPED)
outp = (u64 __iomem *)&out->FLAG_TS;
else
outp = (u64 __iomem *)&out->FLAG;
Annotation
- Immediate include surface: `linux/types.h`, `linux/module.h`, `linux/device.h`, `linux/io.h`, `linux/mm.h`, `linux/slab.h`, `linux/stm.h`, `intel_th.h`.
- Detected declarations: `struct sth_device`, `function sth_channel`, `function sth_iowrite`, `function sth_stm_packet`, `function sth_stm_mmio_addr`, `function sth_stm_link`, `function intel_th_sw_init`, `function intel_th_sth_probe`, `function intel_th_sth_remove`.
- Atlas domain: Driver Families / drivers/hwtracing.
- 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.