iommu: Add sysfs attribyte for domain type
While we could print it at setup time, this is an easier way to match each device to their default IOMMU allocation type. Signed-off-by: Olof Johansson <olof@lixom.net> Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
7d0f5fd3e4
commit
c52c72d3de
@ -294,11 +294,39 @@ static ssize_t iommu_group_show_resv_regions(struct iommu_group *group,
|
|||||||
return (str - buf);
|
return (str - buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ssize_t iommu_group_show_type(struct iommu_group *group,
|
||||||
|
char *buf)
|
||||||
|
{
|
||||||
|
char *type = "unknown\n";
|
||||||
|
|
||||||
|
if (group->default_domain) {
|
||||||
|
switch (group->default_domain->type) {
|
||||||
|
case IOMMU_DOMAIN_BLOCKED:
|
||||||
|
type = "blocked\n";
|
||||||
|
break;
|
||||||
|
case IOMMU_DOMAIN_IDENTITY:
|
||||||
|
type = "identity\n";
|
||||||
|
break;
|
||||||
|
case IOMMU_DOMAIN_UNMANAGED:
|
||||||
|
type = "unmanaged\n";
|
||||||
|
break;
|
||||||
|
case IOMMU_DOMAIN_DMA:
|
||||||
|
type = "DMA";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
strcpy(buf, type);
|
||||||
|
|
||||||
|
return strlen(type);
|
||||||
|
}
|
||||||
|
|
||||||
static IOMMU_GROUP_ATTR(name, S_IRUGO, iommu_group_show_name, NULL);
|
static IOMMU_GROUP_ATTR(name, S_IRUGO, iommu_group_show_name, NULL);
|
||||||
|
|
||||||
static IOMMU_GROUP_ATTR(reserved_regions, 0444,
|
static IOMMU_GROUP_ATTR(reserved_regions, 0444,
|
||||||
iommu_group_show_resv_regions, NULL);
|
iommu_group_show_resv_regions, NULL);
|
||||||
|
|
||||||
|
static IOMMU_GROUP_ATTR(type, 0444, iommu_group_show_type, NULL);
|
||||||
|
|
||||||
static void iommu_group_release(struct kobject *kobj)
|
static void iommu_group_release(struct kobject *kobj)
|
||||||
{
|
{
|
||||||
struct iommu_group *group = to_iommu_group(kobj);
|
struct iommu_group *group = to_iommu_group(kobj);
|
||||||
@ -380,6 +408,10 @@ struct iommu_group *iommu_group_alloc(void)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ERR_PTR(ret);
|
return ERR_PTR(ret);
|
||||||
|
|
||||||
|
ret = iommu_group_create_file(group, &iommu_group_attr_type);
|
||||||
|
if (ret)
|
||||||
|
return ERR_PTR(ret);
|
||||||
|
|
||||||
pr_debug("Allocated group %d\n", group->id);
|
pr_debug("Allocated group %d\n", group->id);
|
||||||
|
|
||||||
return group;
|
return group;
|
||||||
|
Loading…
Reference in New Issue
Block a user