Commit 701d8a62 authored by Robin Murphy's avatar Robin Murphy Committed by Joerg Roedel

iommu: Tidy up window attributes

The external interface to get/set window attributes is already
abstracted behind iommu_domain_{get,set}_attr(), so there's no real
reason for the internal interface to be different. Since we only have
one window-based driver anyway, clean up the core code by just moving
the DOMAIN_ATTR_WINDOWS handling directly into the PAMU driver.
Signed-off-by: default avatarRobin Murphy <robin.murphy@arm.com>
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 7adb562c
...@@ -818,6 +818,7 @@ static int fsl_pamu_set_domain_attr(struct iommu_domain *domain, ...@@ -818,6 +818,7 @@ static int fsl_pamu_set_domain_attr(struct iommu_domain *domain,
enum iommu_attr attr_type, void *data) enum iommu_attr attr_type, void *data)
{ {
struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain);
u32 *count;
int ret = 0; int ret = 0;
switch (attr_type) { switch (attr_type) {
...@@ -829,6 +830,15 @@ static int fsl_pamu_set_domain_attr(struct iommu_domain *domain, ...@@ -829,6 +830,15 @@ static int fsl_pamu_set_domain_attr(struct iommu_domain *domain,
break; break;
case DOMAIN_ATTR_FSL_PAMU_ENABLE: case DOMAIN_ATTR_FSL_PAMU_ENABLE:
ret = configure_domain_dma_state(dma_domain, *(int *)data); ret = configure_domain_dma_state(dma_domain, *(int *)data);
break;
case DOMAIN_ATTR_WINDOWS:
count = data;
if (domain->ops->domain_set_windows != NULL)
ret = domain->ops->domain_set_windows(domain, *count);
else
ret = -ENODEV;
break; break;
default: default:
pr_debug("Unsupported attribute type\n"); pr_debug("Unsupported attribute type\n");
...@@ -843,6 +853,7 @@ static int fsl_pamu_get_domain_attr(struct iommu_domain *domain, ...@@ -843,6 +853,7 @@ static int fsl_pamu_get_domain_attr(struct iommu_domain *domain,
enum iommu_attr attr_type, void *data) enum iommu_attr attr_type, void *data)
{ {
struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain);
u32 *count;
int ret = 0; int ret = 0;
switch (attr_type) { switch (attr_type) {
...@@ -855,6 +866,15 @@ static int fsl_pamu_get_domain_attr(struct iommu_domain *domain, ...@@ -855,6 +866,15 @@ static int fsl_pamu_get_domain_attr(struct iommu_domain *domain,
break; break;
case DOMAIN_ATTR_FSL_PAMUV1: case DOMAIN_ATTR_FSL_PAMUV1:
*(int *)data = DOMAIN_ATTR_FSL_PAMUV1; *(int *)data = DOMAIN_ATTR_FSL_PAMUV1;
break;
case DOMAIN_ATTR_WINDOWS:
count = data;
if (domain->ops->domain_get_windows != NULL)
*count = domain->ops->domain_get_windows(domain);
else
ret = -ENODEV;
break; break;
default: default:
pr_debug("Unsupported attribute type\n"); pr_debug("Unsupported attribute type\n");
......
...@@ -1805,7 +1805,6 @@ int iommu_domain_get_attr(struct iommu_domain *domain, ...@@ -1805,7 +1805,6 @@ int iommu_domain_get_attr(struct iommu_domain *domain,
struct iommu_domain_geometry *geometry; struct iommu_domain_geometry *geometry;
bool *paging; bool *paging;
int ret = 0; int ret = 0;
u32 *count;
switch (attr) { switch (attr) {
case DOMAIN_ATTR_GEOMETRY: case DOMAIN_ATTR_GEOMETRY:
...@@ -1816,15 +1815,6 @@ int iommu_domain_get_attr(struct iommu_domain *domain, ...@@ -1816,15 +1815,6 @@ int iommu_domain_get_attr(struct iommu_domain *domain,
case DOMAIN_ATTR_PAGING: case DOMAIN_ATTR_PAGING:
paging = data; paging = data;
*paging = (domain->pgsize_bitmap != 0UL); *paging = (domain->pgsize_bitmap != 0UL);
break;
case DOMAIN_ATTR_WINDOWS:
count = data;
if (domain->ops->domain_get_windows != NULL)
*count = domain->ops->domain_get_windows(domain);
else
ret = -ENODEV;
break; break;
default: default:
if (!domain->ops->domain_get_attr) if (!domain->ops->domain_get_attr)
...@@ -1841,18 +1831,8 @@ int iommu_domain_set_attr(struct iommu_domain *domain, ...@@ -1841,18 +1831,8 @@ int iommu_domain_set_attr(struct iommu_domain *domain,
enum iommu_attr attr, void *data) enum iommu_attr attr, void *data)
{ {
int ret = 0; int ret = 0;
u32 *count;
switch (attr) { switch (attr) {
case DOMAIN_ATTR_WINDOWS:
count = data;
if (domain->ops->domain_set_windows != NULL)
ret = domain->ops->domain_set_windows(domain, *count);
else
ret = -ENODEV;
break;
default: default:
if (domain->ops->domain_set_attr == NULL) if (domain->ops->domain_set_attr == NULL)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment