drivers/pci/tsm.c
Source file repositories/reference/linux-study-clean/drivers/pci/tsm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/tsm.c- Extension
.c- Size
- 23256 bytes
- Lines
- 901
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/pci.hlinux/pci-doe.hlinux/pci-tsm.hlinux/sysfs.hlinux/tsm.hlinux/xarray.hpci.h
Detected Declarations
function is_dsmfunction has_teefunction tsm_removefunction pci_tsm_walk_fnsfunction pci_tsm_walk_fns_reversefunction link_sysfs_disablefunction link_sysfs_enablefunction probe_fnfunction pci_tsm_connectfunction connect_showfunction is_link_tsmfunction is_devsec_tsmfunction connect_storefunction remove_fnfunction pci_walk_busfunction pci_tsm_unbindfunction pci_tsm_bindfunction pci_tsm_guest_reqfunction pci_tsm_unbind_allfunction __pci_tsm_disconnectfunction pci_tsm_disconnectfunction disconnect_storefunction bound_showfunction dsm_showfunction pci_tsm_link_group_visiblefunction pci_tsm_attr_visiblefunction pci_tsm_group_visiblefunction authenticated_showfunction Managerfunction pci_tsm_tdi_constructorfunction pci_tsm_link_constructorfunction pci_tsm_pf0_constructorfunction pci_tsm_pf0_destructorfunction pci_tsm_registerfunction pci_tsm_fn_exitfunction __pci_tsm_destroyfunction pci_tsm_destroyfunction pci_tsm_initfunction pci_tsm_unregisterfunction pci_tsm_doe_transferexport pci_tsm_unbindexport pci_tsm_bindexport pci_tsm_guest_reqexport pci_tsm_tdi_constructorexport pci_tsm_link_constructorexport pci_tsm_pf0_constructorexport pci_tsm_pf0_destructorexport pci_tsm_doe_transfer
Annotated Snippet
if (attr == &dev_attr_bound.attr) {
if (is_pci_tsm_pf0(pdev) && has_tee(pdev))
return attr->mode;
if (pdev->tsm && has_tee(pdev->tsm->dsm_dev))
return attr->mode;
}
if (attr == &dev_attr_dsm.attr) {
if (is_pci_tsm_pf0(pdev))
return attr->mode;
if (pdev->tsm && has_tee(pdev->tsm->dsm_dev))
return attr->mode;
}
if (attr == &dev_attr_connect.attr ||
attr == &dev_attr_disconnect.attr) {
if (is_pci_tsm_pf0(pdev))
return attr->mode;
}
}
return 0;
}
static bool pci_tsm_group_visible(struct kobject *kobj)
{
return pci_tsm_link_group_visible(kobj);
}
DEFINE_SYSFS_GROUP_VISIBLE(pci_tsm);
static struct attribute *pci_tsm_attrs[] = {
&dev_attr_connect.attr,
&dev_attr_disconnect.attr,
&dev_attr_bound.attr,
&dev_attr_dsm.attr,
NULL
};
const struct attribute_group pci_tsm_attr_group = {
.name = "tsm",
.attrs = pci_tsm_attrs,
.is_visible = SYSFS_GROUP_VISIBLE(pci_tsm),
};
static ssize_t authenticated_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
/*
* When the SPDM session established via TSM the 'authenticated' state
* of the device is identical to the connect state.
*/
return connect_show(dev, attr, buf);
}
static DEVICE_ATTR_RO(authenticated);
static struct attribute *pci_tsm_auth_attrs[] = {
&dev_attr_authenticated.attr,
NULL
};
const struct attribute_group pci_tsm_auth_attr_group = {
.attrs = pci_tsm_auth_attrs,
.is_visible = SYSFS_GROUP_VISIBLE(pci_tsm_link),
};
/*
* Retrieve physical function0 device whether it has TEE capability or not
*/
static struct pci_dev *pf0_dev_get(struct pci_dev *pdev)
{
struct pci_dev *pf_dev = pci_physfn(pdev);
if (PCI_FUNC(pf_dev->devfn) == 0)
return pci_dev_get(pf_dev);
return pci_get_slot(pf_dev->bus,
pf_dev->devfn - PCI_FUNC(pf_dev->devfn));
}
/*
* Find the PCI Device instance that serves as the Device Security Manager (DSM)
* for @pdev. Note that no additional reference is held for the resulting device
* because that resulting object always has a registered lifetime
* greater-than-or-equal to that of the @pdev argument. This is by virtue of
* @pdev being a descendant of, or identical to, the returned DSM device.
*/
static struct pci_dev *find_dsm_dev(struct pci_dev *pdev)
{
struct device *grandparent;
struct pci_dev *uport;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/pci.h`, `linux/pci-doe.h`, `linux/pci-tsm.h`, `linux/sysfs.h`, `linux/tsm.h`, `linux/xarray.h`, `pci.h`.
- Detected declarations: `function is_dsm`, `function has_tee`, `function tsm_remove`, `function pci_tsm_walk_fns`, `function pci_tsm_walk_fns_reverse`, `function link_sysfs_disable`, `function link_sysfs_enable`, `function probe_fn`, `function pci_tsm_connect`, `function connect_show`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration 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.