diff mbox

[Xen-devel,v4,06/21] xen/passthrough: amd: Remove domain_id from hvm_iommu

Message ID 1398172475-27873-7-git-send-email-julien.grall@linaro.org
State Superseded, archived
Headers show

Commit Message

Julien Grall April 22, 2014, 1:14 p.m. UTC
The structure hvm_iommu contains a shadow value of domain->domain_id. There
is no reason to not directly use domain->domain_id.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Cc: Jan Beulich <jbeulich@suse.com>

---
    Changes in v3:
        - Patch added
---
 xen/drivers/passthrough/amd/iommu_cmd.c     |    3 +--
 xen/drivers/passthrough/amd/iommu_map.c     |    2 +-
 xen/drivers/passthrough/amd/pci_amd_iommu.c |    8 +++-----
 xen/include/xen/hvm/iommu.h                 |    1 -
 4 files changed, 5 insertions(+), 9 deletions(-)

Comments

Julien Grall April 28, 2014, 4:38 p.m. UTC | #1
Hello Sherry and Suravee,

Can one of you ack this change in the AMD IOMMU drivers?

Regards,

On 04/22/2014 02:14 PM, Julien Grall wrote:
> The structure hvm_iommu contains a shadow value of domain->domain_id. There
> is no reason to not directly use domain->domain_id.
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
> Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> Cc: Jan Beulich <jbeulich@suse.com>
> 
> ---
>     Changes in v3:
>         - Patch added
> ---
>  xen/drivers/passthrough/amd/iommu_cmd.c     |    3 +--
>  xen/drivers/passthrough/amd/iommu_map.c     |    2 +-
>  xen/drivers/passthrough/amd/pci_amd_iommu.c |    8 +++-----
>  xen/include/xen/hvm/iommu.h                 |    1 -
>  4 files changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/xen/drivers/passthrough/amd/iommu_cmd.c b/xen/drivers/passthrough/amd/iommu_cmd.c
> index d27bd3c..4faa01b 100644
> --- a/xen/drivers/passthrough/amd/iommu_cmd.c
> +++ b/xen/drivers/passthrough/amd/iommu_cmd.c
> @@ -354,8 +354,7 @@ static void _amd_iommu_flush_pages(struct domain *d,
>  {
>      unsigned long flags;
>      struct amd_iommu *iommu;
> -    struct hvm_iommu *hd = domain_hvm_iommu(d);
> -    unsigned int dom_id = hd->domain_id;
> +    unsigned int dom_id = d->domain_id;
>  
>      /* send INVALIDATE_IOMMU_PAGES command */
>      for_each_amd_iommu ( iommu )
> diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c
> index 1294561..b79e470 100644
> --- a/xen/drivers/passthrough/amd/iommu_map.c
> +++ b/xen/drivers/passthrough/amd/iommu_map.c
> @@ -614,7 +614,7 @@ static int update_paging_mode(struct domain *d, unsigned long gfn)
>                  /* valid = 0 only works for dom0 passthrough mode */
>                  amd_iommu_set_root_page_table((u32 *)device_entry,
>                                                page_to_maddr(hd->root_table),
> -                                              hd->domain_id,
> +                                              d->domain_id,
>                                                hd->paging_mode, 1);
>  
>                  amd_iommu_flush_device(iommu, req_id);
> diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c
> index 366c750..51b75fc 100644
> --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c
> +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c
> @@ -138,7 +138,7 @@ static void amd_iommu_setup_domain_device(
>      {
>          /* bind DTE to domain page-tables */
>          amd_iommu_set_root_page_table(
> -            (u32 *)dte, page_to_maddr(hd->root_table), hd->domain_id,
> +            (u32 *)dte, page_to_maddr(hd->root_table), domain->domain_id,
>              hd->paging_mode, valid);
>  
>          if ( pci_ats_device(iommu->seg, bus, pdev->devfn) &&
> @@ -152,7 +152,7 @@ static void amd_iommu_setup_domain_device(
>                          "domain = %d, paging mode = %d\n",
>                          req_id, pdev->type,
>                          page_to_maddr(hd->root_table),
> -                        hd->domain_id, hd->paging_mode);
> +                        domain->domain_id, hd->paging_mode);
>      }
>  
>      spin_unlock_irqrestore(&iommu->lock, flags);
> @@ -274,8 +274,6 @@ static int amd_iommu_domain_init(struct domain *d)
>                        IOMMU_PAGING_MODE_LEVEL_2 :
>                        get_paging_mode(max_page);
>  
> -    hd->domain_id = d->domain_id;
> -
>      guest_iommu_init(d);
>  
>      return 0;
> @@ -334,7 +332,7 @@ void amd_iommu_disable_domain_device(struct domain *domain,
>  
>          AMD_IOMMU_DEBUG("Disable: device id = %#x, "
>                          "domain = %d, paging mode = %d\n",
> -                        req_id,  domain_hvm_iommu(domain)->domain_id,
> +                        req_id,  domain->domain_id,
>                          domain_hvm_iommu(domain)->paging_mode);
>      }
>      spin_unlock_irqrestore(&iommu->lock, flags);
> diff --git a/xen/include/xen/hvm/iommu.h b/xen/include/xen/hvm/iommu.h
> index 8c98274..dc9c766 100644
> --- a/xen/include/xen/hvm/iommu.h
> +++ b/xen/include/xen/hvm/iommu.h
> @@ -38,7 +38,6 @@ struct hvm_iommu {
>      struct list_head mapped_rmrrs;
>  
>      /* amd iommu support */
> -    int domain_id;
>      int paging_mode;
>      struct page_info *root_table;
>      struct guest_iommu *g_iommu;
>
Jan Beulich April 29, 2014, 7:43 a.m. UTC | #2
>>> On 28.04.14 at 18:38, <julien.grall@linaro.org> wrote:
> Hello Sherry and Suravee,
> 
> Can one of you ack this change in the AMD IOMMU drivers?

Sherry,

with Suravee having become pretty silent over the last couple of
months, and Aravind having shown quite a bit of activity, would it
be reasonable to add his as maintainer alongside (or, less ideal, in
place of) Suravee for the AMD IOMMU code?

Thanks, Jan
Suthikulpanit, Suravee April 30, 2014, 3:56 a.m. UTC | #3
Sorry for late reply. Reviewed and tested.

Acked-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>

Suravee

On 04/22/2014 08:14 AM, Julien Grall wrote:
> The structure hvm_iommu contains a shadow value of domain->domain_id. There
> is no reason to not directly use domain->domain_id.
>
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
> Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> Cc: Jan Beulich <jbeulich@suse.com>
>
> ---
>      Changes in v3:
>          - Patch added
> ---
>   xen/drivers/passthrough/amd/iommu_cmd.c     |    3 +--
>   xen/drivers/passthrough/amd/iommu_map.c     |    2 +-
>   xen/drivers/passthrough/amd/pci_amd_iommu.c |    8 +++-----
>   xen/include/xen/hvm/iommu.h                 |    1 -
>   4 files changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/xen/drivers/passthrough/amd/iommu_cmd.c b/xen/drivers/passthrough/amd/iommu_cmd.c
> index d27bd3c..4faa01b 100644
> --- a/xen/drivers/passthrough/amd/iommu_cmd.c
> +++ b/xen/drivers/passthrough/amd/iommu_cmd.c
> @@ -354,8 +354,7 @@ static void _amd_iommu_flush_pages(struct domain *d,
>   {
>       unsigned long flags;
>       struct amd_iommu *iommu;
> -    struct hvm_iommu *hd = domain_hvm_iommu(d);
> -    unsigned int dom_id = hd->domain_id;
> +    unsigned int dom_id = d->domain_id;
>
>       /* send INVALIDATE_IOMMU_PAGES command */
>       for_each_amd_iommu ( iommu )
> diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c
> index 1294561..b79e470 100644
> --- a/xen/drivers/passthrough/amd/iommu_map.c
> +++ b/xen/drivers/passthrough/amd/iommu_map.c
> @@ -614,7 +614,7 @@ static int update_paging_mode(struct domain *d, unsigned long gfn)
>                   /* valid = 0 only works for dom0 passthrough mode */
>                   amd_iommu_set_root_page_table((u32 *)device_entry,
>                                                 page_to_maddr(hd->root_table),
> -                                              hd->domain_id,
> +                                              d->domain_id,
>                                                 hd->paging_mode, 1);
>
>                   amd_iommu_flush_device(iommu, req_id);
> diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c
> index 366c750..51b75fc 100644
> --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c
> +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c
> @@ -138,7 +138,7 @@ static void amd_iommu_setup_domain_device(
>       {
>           /* bind DTE to domain page-tables */
>           amd_iommu_set_root_page_table(
> -            (u32 *)dte, page_to_maddr(hd->root_table), hd->domain_id,
> +            (u32 *)dte, page_to_maddr(hd->root_table), domain->domain_id,
>               hd->paging_mode, valid);
>
>           if ( pci_ats_device(iommu->seg, bus, pdev->devfn) &&
> @@ -152,7 +152,7 @@ static void amd_iommu_setup_domain_device(
>                           "domain = %d, paging mode = %d\n",
>                           req_id, pdev->type,
>                           page_to_maddr(hd->root_table),
> -                        hd->domain_id, hd->paging_mode);
> +                        domain->domain_id, hd->paging_mode);
>       }
>
>       spin_unlock_irqrestore(&iommu->lock, flags);
> @@ -274,8 +274,6 @@ static int amd_iommu_domain_init(struct domain *d)
>                         IOMMU_PAGING_MODE_LEVEL_2 :
>                         get_paging_mode(max_page);
>
> -    hd->domain_id = d->domain_id;
> -
>       guest_iommu_init(d);
>
>       return 0;
> @@ -334,7 +332,7 @@ void amd_iommu_disable_domain_device(struct domain *domain,
>
>           AMD_IOMMU_DEBUG("Disable: device id = %#x, "
>                           "domain = %d, paging mode = %d\n",
> -                        req_id,  domain_hvm_iommu(domain)->domain_id,
> +                        req_id,  domain->domain_id,
>                           domain_hvm_iommu(domain)->paging_mode);
>       }
>       spin_unlock_irqrestore(&iommu->lock, flags);
> diff --git a/xen/include/xen/hvm/iommu.h b/xen/include/xen/hvm/iommu.h
> index 8c98274..dc9c766 100644
> --- a/xen/include/xen/hvm/iommu.h
> +++ b/xen/include/xen/hvm/iommu.h
> @@ -38,7 +38,6 @@ struct hvm_iommu {
>       struct list_head mapped_rmrrs;
>
>       /* amd iommu support */
> -    int domain_id;
>       int paging_mode;
>       struct page_info *root_table;
>       struct guest_iommu *g_iommu;
>
Suthikulpanit, Suravee April 30, 2014, 4:02 a.m. UTC | #4
Jan,

Sorry for have not been able to respond earlier.  I have been occupied 
with other works during the past month. I've reviewed and test this 
patch.  We are also planning to add Aravind along as maintainer.  We 
will be sending out the patch for the MAINTAINERS file to include him.

Suravee

On 04/29/2014 02:43 AM, Jan Beulich wrote:
>>>> On 28.04.14 at 18:38, <julien.grall@linaro.org> wrote:
>> Hello Sherry and Suravee,
>>
>> Can one of you ack this change in the AMD IOMMU drivers?
>
> Sherry,
>
> with Suravee having become pretty silent over the last couple of
> months, and Aravind having shown quite a bit of activity, would it
> be reasonable to add his as maintainer alongside (or, less ideal, in
> place of) Suravee for the AMD IOMMU code?
>
> Thanks, Jan
>
Julien Grall April 30, 2014, 11:32 a.m. UTC | #5
Hi Suravee,

On 04/30/2014 04:56 AM, Suravee Suthikulpanit wrote:
> Sorry for late reply. Reviewed and tested.
> 
> Acked-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>

Thank you for your ack.

Can you also ack patch #7 and #13? (There is some modifications for the
AMD iommu).

Regards,
diff mbox

Patch

diff --git a/xen/drivers/passthrough/amd/iommu_cmd.c b/xen/drivers/passthrough/amd/iommu_cmd.c
index d27bd3c..4faa01b 100644
--- a/xen/drivers/passthrough/amd/iommu_cmd.c
+++ b/xen/drivers/passthrough/amd/iommu_cmd.c
@@ -354,8 +354,7 @@  static void _amd_iommu_flush_pages(struct domain *d,
 {
     unsigned long flags;
     struct amd_iommu *iommu;
-    struct hvm_iommu *hd = domain_hvm_iommu(d);
-    unsigned int dom_id = hd->domain_id;
+    unsigned int dom_id = d->domain_id;
 
     /* send INVALIDATE_IOMMU_PAGES command */
     for_each_amd_iommu ( iommu )
diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c
index 1294561..b79e470 100644
--- a/xen/drivers/passthrough/amd/iommu_map.c
+++ b/xen/drivers/passthrough/amd/iommu_map.c
@@ -614,7 +614,7 @@  static int update_paging_mode(struct domain *d, unsigned long gfn)
                 /* valid = 0 only works for dom0 passthrough mode */
                 amd_iommu_set_root_page_table((u32 *)device_entry,
                                               page_to_maddr(hd->root_table),
-                                              hd->domain_id,
+                                              d->domain_id,
                                               hd->paging_mode, 1);
 
                 amd_iommu_flush_device(iommu, req_id);
diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c
index 366c750..51b75fc 100644
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c
@@ -138,7 +138,7 @@  static void amd_iommu_setup_domain_device(
     {
         /* bind DTE to domain page-tables */
         amd_iommu_set_root_page_table(
-            (u32 *)dte, page_to_maddr(hd->root_table), hd->domain_id,
+            (u32 *)dte, page_to_maddr(hd->root_table), domain->domain_id,
             hd->paging_mode, valid);
 
         if ( pci_ats_device(iommu->seg, bus, pdev->devfn) &&
@@ -152,7 +152,7 @@  static void amd_iommu_setup_domain_device(
                         "domain = %d, paging mode = %d\n",
                         req_id, pdev->type,
                         page_to_maddr(hd->root_table),
-                        hd->domain_id, hd->paging_mode);
+                        domain->domain_id, hd->paging_mode);
     }
 
     spin_unlock_irqrestore(&iommu->lock, flags);
@@ -274,8 +274,6 @@  static int amd_iommu_domain_init(struct domain *d)
                       IOMMU_PAGING_MODE_LEVEL_2 :
                       get_paging_mode(max_page);
 
-    hd->domain_id = d->domain_id;
-
     guest_iommu_init(d);
 
     return 0;
@@ -334,7 +332,7 @@  void amd_iommu_disable_domain_device(struct domain *domain,
 
         AMD_IOMMU_DEBUG("Disable: device id = %#x, "
                         "domain = %d, paging mode = %d\n",
-                        req_id,  domain_hvm_iommu(domain)->domain_id,
+                        req_id,  domain->domain_id,
                         domain_hvm_iommu(domain)->paging_mode);
     }
     spin_unlock_irqrestore(&iommu->lock, flags);
diff --git a/xen/include/xen/hvm/iommu.h b/xen/include/xen/hvm/iommu.h
index 8c98274..dc9c766 100644
--- a/xen/include/xen/hvm/iommu.h
+++ b/xen/include/xen/hvm/iommu.h
@@ -38,7 +38,6 @@  struct hvm_iommu {
     struct list_head mapped_rmrrs;
 
     /* amd iommu support */
-    int domain_id;
     int paging_mode;
     struct page_info *root_table;
     struct guest_iommu *g_iommu;