diff mbox

[RFC,7/9] iommu/arm: Add alloc_page_table platform callback

Message ID 1489608329-7275-8-git-send-email-olekstysh@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Oleksandr Tyshchenko March 15, 2017, 8:05 p.m. UTC
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

The alloc_page_table callback is a mandatory thing
for the IOMMUs that don't share page table with the CPU on ARM.
The unshared IOMMUs have to perform all required actions here
to be ready to handle IOMMU mapping updates right after completing it.

The arch_iommu_populate_page_table() seems an appropriate place
to call newly created callback.
Since we will only be here for the unshared IOMMUs always
return error if the callback wasn't implemented.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
---
 xen/drivers/passthrough/arm/iommu.c | 5 +++--
 xen/include/xen/iommu.h             | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

Comments

Jan Beulich March 22, 2017, 3:49 p.m. UTC | #1
>>> On 15.03.17 at 21:05, <olekstysh@gmail.com> wrote:
> --- a/xen/include/xen/iommu.h
> +++ b/xen/include/xen/iommu.h
> @@ -181,6 +181,7 @@ struct iommu_ops {
>      int __must_check (*unmap_page)(struct domain *d, unsigned long gfn);
>      int __must_check (*unmap_pages)(struct domain *d, unsigned long gfn,
>                                      unsigned long page_count);
> +    int (*alloc_page_table)(struct domain *d);
>      void (*free_page_table)(struct page_info *);
>  #ifdef CONFIG_X86
>      void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value);

As you can see in patch context here, we have x86-specific callbacks.
If the new one is used on ARM only, it should be made ARM-only.

Jan
Oleksandr Tyshchenko March 23, 2017, 12:57 p.m. UTC | #2
On Wed, Mar 22, 2017 at 5:49 PM, Jan Beulich <JBeulich@suse.com> wrote:
>>>> On 15.03.17 at 21:05, <olekstysh@gmail.com> wrote:
>> --- a/xen/include/xen/iommu.h
>> +++ b/xen/include/xen/iommu.h
>> @@ -181,6 +181,7 @@ struct iommu_ops {
>>      int __must_check (*unmap_page)(struct domain *d, unsigned long gfn);
>>      int __must_check (*unmap_pages)(struct domain *d, unsigned long gfn,
>>                                      unsigned long page_count);
>> +    int (*alloc_page_table)(struct domain *d);
>>      void (*free_page_table)(struct page_info *);
>>  #ifdef CONFIG_X86
>>      void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value);
>
> As you can see in patch context here, we have x86-specific callbacks.
> If the new one is used on ARM only, it should be made ARM-only.

Agree. Will do.
diff mbox

Patch

diff --git a/xen/drivers/passthrough/arm/iommu.c b/xen/drivers/passthrough/arm/iommu.c
index 95b1abb..f132032 100644
--- a/xen/drivers/passthrough/arm/iommu.c
+++ b/xen/drivers/passthrough/arm/iommu.c
@@ -70,6 +70,7 @@  void arch_iommu_domain_destroy(struct domain *d)
 
 int arch_iommu_populate_page_table(struct domain *d)
 {
-    /* The IOMMU shares the p2m with the CPU */
-    return -ENOSYS;
+    const struct iommu_ops *ops = iommu_get_ops();
+
+    return ops->alloc_page_table ? ops->alloc_page_table(d) : -ENOSYS;
 }
diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
index ab68ae2..3150d7b 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -181,6 +181,7 @@  struct iommu_ops {
     int __must_check (*unmap_page)(struct domain *d, unsigned long gfn);
     int __must_check (*unmap_pages)(struct domain *d, unsigned long gfn,
                                     unsigned long page_count);
+    int (*alloc_page_table)(struct domain *d);
     void (*free_page_table)(struct page_info *);
 #ifdef CONFIG_X86
     void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value);