Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros
iommu.c File Reference
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/bug.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/iommu.h>
#include <linux/idr.h>
#include <linux/notifier.h>
#include <linux/err.h>

Go to the source code of this file.

Data Structures

struct  iommu_group
 
struct  iommu_device
 
struct  iommu_group_attribute
 

Macros

#define pr_fmt(fmt)   "%s: " fmt, __func__
 
#define IOMMU_GROUP_ATTR(_name, _mode, _show, _store)
 
#define to_iommu_group_attr(_attr)   container_of(_attr, struct iommu_group_attribute, attr)
 
#define to_iommu_group(_kobj)   container_of(_kobj, struct iommu_group, kobj)
 

Functions

: Optional name to associate with group, visible in sysfs

iommu_group_alloc - Allocate a new group

This function is called by an iommu driver to allocate a new iommu group. The iommu group represents the minimum granularity of the iommu. Upon successful return, the caller holds a reference to the supplied group in order to hold the group until devices are added. Use iommu_group_put() to release this extra reference count, allowing the group to be automatically reclaimed once it has no devices or external references.

struct iommu_groupiommu_group_alloc (void)
 
 EXPORT_SYMBOL_GPL (iommu_group_alloc)
 
voidiommu_group_get_iommudata (struct iommu_group *group)
 
 EXPORT_SYMBOL_GPL (iommu_group_get_iommudata)
 
void iommu_group_set_iommudata (struct iommu_group *group, void *iommu_data, void(*release)(void *iommu_data))
 
 EXPORT_SYMBOL_GPL (iommu_group_set_iommudata)
 

: name

iommu_group_set_name - set name for a group : the group

Allow iommu driver to set a name for a group. When set it will appear in a name attribute file under the group in sysfs.

int iommu_group_set_name (struct iommu_group *group, const char *name)
 
 EXPORT_SYMBOL_GPL (iommu_group_set_name)
 
int iommu_group_add_device (struct iommu_group *group, struct device *dev)
 
 EXPORT_SYMBOL_GPL (iommu_group_add_device)
 
void iommu_group_remove_device (struct device *dev)
 
 EXPORT_SYMBOL_GPL (iommu_group_remove_device)
 
int iommu_group_for_each_dev (struct iommu_group *group, void *data, int(*fn)(struct device *, void *))
 
 EXPORT_SYMBOL_GPL (iommu_group_for_each_dev)
 
struct iommu_groupiommu_group_get (struct device *dev)
 
 EXPORT_SYMBOL_GPL (iommu_group_get)
 
void iommu_group_put (struct iommu_group *group)
 
 EXPORT_SYMBOL_GPL (iommu_group_put)
 
int iommu_group_register_notifier (struct iommu_group *group, struct notifier_block *nb)
 
 EXPORT_SYMBOL_GPL (iommu_group_register_notifier)
 
int iommu_group_unregister_notifier (struct iommu_group *group, struct notifier_block *nb)
 
 EXPORT_SYMBOL_GPL (iommu_group_unregister_notifier)
 
int iommu_group_id (struct iommu_group *group)
 
 EXPORT_SYMBOL_GPL (iommu_group_id)
 
int bus_set_iommu (struct bus_type *bus, struct iommu_ops *ops)
 
 EXPORT_SYMBOL_GPL (bus_set_iommu)
 
bool iommu_present (struct bus_type *bus)
 
 EXPORT_SYMBOL_GPL (iommu_present)
 
void iommu_set_fault_handler (struct iommu_domain *domain, iommu_fault_handler_t handler, void *token)
 
 EXPORT_SYMBOL_GPL (iommu_set_fault_handler)
 
struct iommu_domainiommu_domain_alloc (struct bus_type *bus)
 
 EXPORT_SYMBOL_GPL (iommu_domain_alloc)
 
void iommu_domain_free (struct iommu_domain *domain)
 
 EXPORT_SYMBOL_GPL (iommu_domain_free)
 
int iommu_attach_device (struct iommu_domain *domain, struct device *dev)
 
 EXPORT_SYMBOL_GPL (iommu_attach_device)
 
void iommu_detach_device (struct iommu_domain *domain, struct device *dev)
 
 EXPORT_SYMBOL_GPL (iommu_detach_device)
 
int iommu_attach_group (struct iommu_domain *domain, struct iommu_group *group)
 
 EXPORT_SYMBOL_GPL (iommu_attach_group)
 
void iommu_detach_group (struct iommu_domain *domain, struct iommu_group *group)
 
 EXPORT_SYMBOL_GPL (iommu_detach_group)
 
phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain, unsigned long iova)
 
 EXPORT_SYMBOL_GPL (iommu_iova_to_phys)
 
int iommu_domain_has_cap (struct iommu_domain *domain, unsigned long cap)
 
 EXPORT_SYMBOL_GPL (iommu_domain_has_cap)
 
int iommu_map (struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot)
 
 EXPORT_SYMBOL_GPL (iommu_map)
 
size_t iommu_unmap (struct iommu_domain *domain, unsigned long iova, size_t size)
 
 EXPORT_SYMBOL_GPL (iommu_unmap)
 
 subsys_initcall (iommu_init)
 
int iommu_domain_get_attr (struct iommu_domain *domain, enum iommu_attr attr, void *data)
 
 EXPORT_SYMBOL_GPL (iommu_domain_get_attr)
 
int iommu_domain_set_attr (struct iommu_domain *domain, enum iommu_attr attr, void *data)
 
 EXPORT_SYMBOL_GPL (iommu_domain_set_attr)
 

Macro Definition Documentation

#define IOMMU_GROUP_ATTR (   _name,
  _mode,
  _show,
  _store 
)
Value:
struct iommu_group_attribute iommu_group_attr_##_name = \
__ATTR(_name, _mode, _show, _store)

Definition at line 62 of file iommu.c.

#define pr_fmt (   fmt)    "%s: " fmt, __func__

Definition at line 19 of file iommu.c.

#define to_iommu_group (   _kobj)    container_of(_kobj, struct iommu_group, kobj)

Definition at line 68 of file iommu.c.

#define to_iommu_group_attr (   _attr)    container_of(_attr, struct iommu_group_attribute, attr)

Definition at line 66 of file iommu.c.

Function Documentation

int bus_set_iommu ( struct bus_type bus,
struct iommu_ops ops 
)

bus_set_iommu - set iommu-callbacks for the bus : bus. : the callbacks provided by the iommu-driver

This function is called by an iommu driver to set the iommu methods used for a particular bus. Drivers for devices on that bus can use the iommu-api after these ops are registered. This special function is needed because IOMMUs are usually devices on the bus itself, so the iommu drivers are not initialized when the bus is set up. With this function the iommu-driver can set the iommu-ops afterwards.

Definition at line 573 of file iommu.c.

EXPORT_SYMBOL_GPL ( iommu_group_alloc  )
EXPORT_SYMBOL_GPL ( iommu_group_get_iommudata  )
EXPORT_SYMBOL_GPL ( iommu_group_set_iommudata  )
EXPORT_SYMBOL_GPL ( iommu_group_set_name  )
EXPORT_SYMBOL_GPL ( iommu_group_add_device  )
EXPORT_SYMBOL_GPL ( iommu_group_remove_device  )
EXPORT_SYMBOL_GPL ( iommu_group_for_each_dev  )
EXPORT_SYMBOL_GPL ( iommu_group_get  )
EXPORT_SYMBOL_GPL ( iommu_group_put  )
EXPORT_SYMBOL_GPL ( iommu_group_register_notifier  )
EXPORT_SYMBOL_GPL ( iommu_group_unregister_notifier  )
EXPORT_SYMBOL_GPL ( iommu_group_id  )
EXPORT_SYMBOL_GPL ( bus_set_iommu  )
EXPORT_SYMBOL_GPL ( iommu_present  )
EXPORT_SYMBOL_GPL ( iommu_set_fault_handler  )
EXPORT_SYMBOL_GPL ( iommu_domain_alloc  )
EXPORT_SYMBOL_GPL ( iommu_domain_free  )
EXPORT_SYMBOL_GPL ( iommu_attach_device  )
EXPORT_SYMBOL_GPL ( iommu_detach_device  )
EXPORT_SYMBOL_GPL ( iommu_attach_group  )
EXPORT_SYMBOL_GPL ( iommu_detach_group  )
EXPORT_SYMBOL_GPL ( iommu_iova_to_phys  )
EXPORT_SYMBOL_GPL ( iommu_domain_has_cap  )
EXPORT_SYMBOL_GPL ( iommu_map  )
EXPORT_SYMBOL_GPL ( iommu_unmap  )
EXPORT_SYMBOL_GPL ( iommu_domain_get_attr  )
EXPORT_SYMBOL_GPL ( iommu_domain_set_attr  )
int iommu_attach_device ( struct iommu_domain domain,
struct device dev 
)

Definition at line 652 of file iommu.c.

int iommu_attach_group ( struct iommu_domain domain,
struct iommu_group group 
)

Definition at line 687 of file iommu.c.

void iommu_detach_device ( struct iommu_domain domain,
struct device dev 
)

Definition at line 661 of file iommu.c.

void iommu_detach_group ( struct iommu_domain domain,
struct iommu_group group 
)

Definition at line 703 of file iommu.c.

struct iommu_domain* iommu_domain_alloc ( struct bus_type bus)
read

Definition at line 616 of file iommu.c.

void iommu_domain_free ( struct iommu_domain domain)

Definition at line 643 of file iommu.c.

int iommu_domain_get_attr ( struct iommu_domain domain,
enum iommu_attr  attr,
void data 
)

Definition at line 866 of file iommu.c.

int iommu_domain_has_cap ( struct iommu_domain domain,
unsigned long  cap 
)

Definition at line 719 of file iommu.c.

int iommu_domain_set_attr ( struct iommu_domain domain,
enum iommu_attr  attr,
void data 
)

Definition at line 889 of file iommu.c.

int iommu_group_add_device ( struct iommu_group group,
struct device dev 
)

iommu_group_add_device - add a device to an iommu group : the group into which to add the device (reference should be held) : the device

This function is called by an iommu driver to add a device into a group. Adding a device increments the group reference count.

Definition at line 282 of file iommu.c.

struct iommu_group* iommu_group_alloc ( void  )
read

Definition at line 152 of file iommu.c.

int iommu_group_for_each_dev ( struct iommu_group group,
void data,
int(*)(struct device *, void *)  fn 
)

Definition at line 391 of file iommu.c.

struct iommu_group* iommu_group_get ( struct device dev)
read

iommu_group_get - Return the group for a device and increment reference : get the group that this device belongs to

This function is called by iommu drivers and users to get the group for the specified device. If found, the group is returned and the group reference in incremented, else NULL.

Definition at line 416 of file iommu.c.

void* iommu_group_get_iommudata ( struct iommu_group group)

iommu_group_get_iommudata - retrieve iommu_data registered for a group : the group

iommu drivers can store data in the group for use when doing iommu operations. This function provides a way to retrieve it. Caller should hold a group reference.

Definition at line 215 of file iommu.c.

int iommu_group_id ( struct iommu_group group)

iommu_group_id - Return ID for a group : the group to ID

Return the unique ID for the group matching the sysfs group number.

Definition at line 477 of file iommu.c.

void iommu_group_put ( struct iommu_group group)

iommu_group_put - Decrement group reference : the group to use

This function is called by iommu drivers and users to release the iommu group. Once the reference count is zero, the group is released.

Definition at line 434 of file iommu.c.

int iommu_group_register_notifier ( struct iommu_group group,
struct notifier_block nb 
)

iommu_group_register_notifier - Register a notifier for group changes : the group to watch : notifier block to signal

This function allows iommu group users to track changes in a group. See include/linux/iommu.h for actions sent via this notifier. Caller should hold a reference to the group throughout notifier registration.

Definition at line 450 of file iommu.c.

void iommu_group_remove_device ( struct device dev)

iommu_group_remove_device - remove a device from it's current group : device to be removed

This function is called by an iommu driver to remove the device from it's current group. This decrements the iommu group reference count.

Definition at line 348 of file iommu.c.

void iommu_group_set_iommudata ( struct iommu_group group,
void iommu_data,
void(*)(void *iommu_data)  release 
)

iommu_group_set_iommudata - set iommu_data for a group : the group : new data : release function for iommu_data

iommu drivers can store data in the group for use when doing iommu operations. This function provides a way to set the data after the group has been allocated. Caller should hold a group reference.

Definition at line 231 of file iommu.c.

int iommu_group_set_name ( struct iommu_group group,
const char name 
)

Definition at line 247 of file iommu.c.

int iommu_group_unregister_notifier ( struct iommu_group group,
struct notifier_block nb 
)

iommu_group_unregister_notifier - Unregister a notifier : the group to watch : notifier block to signal

Unregister a previously registered group notifier block.

Definition at line 464 of file iommu.c.

phys_addr_t iommu_iova_to_phys ( struct iommu_domain domain,
unsigned long  iova 
)

Definition at line 709 of file iommu.c.

int iommu_map ( struct iommu_domain domain,
unsigned long  iova,
phys_addr_t  paddr,
size_t  size,
int  prot 
)

Definition at line 729 of file iommu.c.

bool iommu_present ( struct bus_type bus)

Definition at line 587 of file iommu.c.

void iommu_set_fault_handler ( struct iommu_domain domain,
iommu_fault_handler_t  handler,
void token 
)

iommu_set_fault_handler() - set a fault handler for an iommu domain : iommu domain : fault handler : user data, will be passed back to the fault handler

This function should be used by IOMMU users which want to be notified whenever an IOMMU fault happens.

The fault handler itself should return 0 on success, and an appropriate error code otherwise.

Definition at line 605 of file iommu.c.

size_t iommu_unmap ( struct iommu_domain domain,
unsigned long  iova,
size_t  size 
)

Definition at line 806 of file iommu.c.

subsys_initcall ( iommu_init  )