smmu_device_add_pci()

Add a PCI device to a SMMU object, or remove it

Synopsis:

#include <smmu.h>

int smmu_device_add_pci(struct smmu_object *const sop,
                               unsigned const pbus,
                               unsigned const pdev,
                               unsigned const pfunc);

Arguments:

sop
Pointer to the SMMU object to which the device will be attached, or NULL to remove the device from any SMMU objects owned by the current client.
pbus
The PCI device's bus number.
pdev
The PCI device's device number.
pfunc
The PCI device's function number.

For pbus, pdev, and pfunc, you can use the SMMU_PCI_FIELD_ANY constant for wildcarding.

CAUTION:

If you use wildcarding for all bus, device and function combinations, smmu_device_add_pci() checks the buses, devices, and functions on the entire system, which may take a long time.

To avoid this, use wildcarding for only one or two of bus, device, function.

Library:

libsmmu.a

Description:

The smmu_device_add_pci() function is a convenience function. It calls smmu_device_add_generic() to add a Peripheral Component Interconnect (PCI) device to a SMMU object.

To remove a PCI device from SMMU objects, call this function with the sop argument set to NULL.

Returns:

-1
Failure: errno is set.
EBUSY
Failure when attempting to add to a SMMU object a DMA device that is owned by another smmuman client.
ENOENT

Failure: when attempting to:

  • add a device – the smmuman service doesn't know which IOMMU/SMMU unit controls the device being added
  • remove a device – the smmuman client making the call doesn't own the SMMU object to which the device is attached
0
Success
+1
Success, but the client must call smmu_mapping_add() to reissue the memory mappings for this object (see Preferred sequence for adding memory mappings and devices for more information about why memory mappings may need to be reissued).