drivers/ata/libata-pmp.c
Source file repositories/reference/linux-study-clean/drivers/ata/libata-pmp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ata/libata-pmp.c- Extension
.c- Size
- 26923 bytes
- Lines
- 1119
- Domain
- Driver Families
- Bucket
- drivers/ata
- 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/kernel.hlinux/export.hlinux/libata.hlinux/slab.hlibata.hlibata-transport.h
Detected Declarations
function contextfunction contextfunction spin_lock_irqsavefunction ata_scr_readfunction ata_scr_writefunction sata_pmp_set_lpmfunction contextfunction sata_pmp_configurefunction sata_pmp_init_linksfunction sata_pmp_quirksfunction ata_for_each_linkfunction ata_for_each_linkfunction ata_for_each_linkfunction contextfunction contextfunction ata_for_each_linkfunction sata_pmp_same_pmpfunction contextfunction contextfunction ata_eh_recoverfunction ata_for_each_linkfunction sata_pmp_eh_handle_disabled_linksfunction ata_for_each_linkfunction sata_pmp_handle_link_failfunction ata_eh_recoverfunction contextexport sata_pmp_port_opsexport sata_pmp_qc_defer_cmd_switchexport sata_pmp_error_handler
Annotated Snippet
if (ap->nr_active_links == 0 || ata_link_active(link)) {
qc->flags |= ATA_QCFLAG_CLEAR_EXCL;
ret = ata_std_qc_defer(qc);
if (ret == ATA_DEFER_LINK)
return ATA_DEFER_LINK_EXCL;
return ret;
}
/*
* Note: ap->excl_link contains the link that is next in line,
* i.e. implicit round robin. If there is only one link
* dispatching, ap->excl_link will be left unclaimed, allowing
* other links to set ap->excl_link, ensuring that the currently
* active link cannot queue any more.
*/
ap->excl_link = link;
}
return ATA_DEFER_PORT;
}
/**
* sata_pmp_scr_read - read PSCR
* @link: ATA link to read PSCR for
* @reg: PSCR to read
* @r_val: resulting value
*
* Read PSCR @reg into @r_val for @link, to be called from
* ata_scr_read().
*
* LOCKING:
* Kernel thread context (may sleep).
*
* RETURNS:
* 0 on success, -errno on failure.
*/
int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *r_val)
{
unsigned int err_mask;
if (reg > SATA_PMP_PSCR_CONTROL)
return -EINVAL;
err_mask = sata_pmp_read(link, reg, r_val);
if (err_mask) {
ata_link_warn(link, "failed to read SCR %d (Emask=0x%x)\n",
reg, err_mask);
return -EIO;
}
return 0;
}
/**
* sata_pmp_scr_write - write PSCR
* @link: ATA link to write PSCR for
* @reg: PSCR to write
* @val: value to be written
*
* Write @val to PSCR @reg for @link, to be called from
* ata_scr_write() and ata_scr_write_flush().
*
* LOCKING:
* Kernel thread context (may sleep).
*
* RETURNS:
* 0 on success, -errno on failure.
*/
int sata_pmp_scr_write(struct ata_link *link, int reg, u32 val)
{
unsigned int err_mask;
if (reg > SATA_PMP_PSCR_CONTROL)
return -EINVAL;
err_mask = sata_pmp_write(link, reg, val);
if (err_mask) {
ata_link_warn(link, "failed to write SCR %d (Emask=0x%x)\n",
reg, err_mask);
return -EIO;
}
return 0;
}
/**
* sata_pmp_set_lpm - configure LPM for a PMP link
* @link: PMP link to configure LPM for
* @policy: target LPM policy
* @hints: LPM hints
*
* Configure LPM for @link. This function will contain any PMP
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/export.h`, `linux/libata.h`, `linux/slab.h`, `libata.h`, `libata-transport.h`.
- Detected declarations: `function context`, `function context`, `function spin_lock_irqsave`, `function ata_scr_read`, `function ata_scr_write`, `function sata_pmp_set_lpm`, `function context`, `function sata_pmp_configure`, `function sata_pmp_init_links`, `function sata_pmp_quirks`.
- Atlas domain: Driver Families / drivers/ata.
- 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.