Re: [PATCH 2/6] iommu/amd: Implement DOMAIN_ATTR_GEOMETRY attribute

From: Ohad Ben-Cohen
Date: Fri Jan 27 2012 - 02:09:04 EST


Hi Joerg,

On Thu, Jan 26, 2012 at 8:40 PM, Joerg Roedel <joerg.roedel@xxxxxxx> wrote:
> Implement the attribute itself and add the code for the
> AMD IOMMU driver.

It's somewhat non-intuitive to have the generic attribute code bundled
with the AMD implementation in the same patch (took me some time to
find it here :).

Maybe split this to two patches ?

> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index ef54718..3d0b0bf 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -345,10 +345,23 @@ EXPORT_SYMBOL_GPL(iommu_device_group);
>  int iommu_domain_get_attr(struct iommu_domain *domain,
>                          enum iommu_attr attr, void *data)
>  {
> -       if (!domain->ops->domain_get_attr)
> -               return -EINVAL;
> +       struct iommu_domain_geometry *geometry;
> +       int ret = 0;
> +
> +       switch (attr) {
> +       case DOMAIN_ATTR_GEOMETRY:
> +               geometry  = data;
> +               *geometry = domain->geometry;

This is not type-safe and will surely bite someone some day.

Sure, we can't have type safety in a multi-purpose generic interface,
but I wonder whether this is the right interface for getting the
geometry ? I.e. why not have a dedicated API for this ?

Thanks,
Ohad.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/