Add a device to a SMMU object, or remove it
#include <smmu.h> int smmu_device_add_generic(struct smmu_object *sop, const union smmu_devid *devid);
The smmu_device_add_generic() function is called by the smmu_device_add_mmio() and smmu_device_add_pci() convenience functions. It can also be used directly by a smmuman client.
The smmu_device_add_generic() function updates the smmu_object data structure referenced by sop with a pointer to a device ID. This adds the device to the SMMU object, so that the smmuman client that created the SMMU object can program the hardware IOMMU/SMMUs to allow the device to access the memory regions associated with the SMMU object.
All devices attached to a SMMU object are granted access to the memory regions mapped to that object, with the same permissisons. If you want to give two devices access to the same memory region, but with different permissions (e.g., one device may only read, the other may only write), then you must create two separate SMMU objects (see smmu_mapping_add()).
A device may have only one owner. Attempting to use one of the smmu_device_add_*() functions when the device has already been added to a SMMU object of a different client will result in an EBUSY error. A smmuman client may move a device from one of its SMMU objects to another one of its SMMU objects, however, because this action doesn't change the device owner.
To remove a device from SMMU objects, call this function with the sop argument set to NULL.
Failure: when attempting to: