debuggers.hg

changeset 19938:ff5bc91d0057

AMD IOMMU: Make iommu suspend & resume functions more generic.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jul 06 11:56:51 2009 +0100 (2009-07-06)
parents 7d5433600932
children 0ab211e699e6
files xen/drivers/passthrough/amd/pci_amd_iommu.c xen/drivers/passthrough/iommu.c xen/drivers/passthrough/vtd/iommu.c xen/include/asm-x86/hvm/svm/amd-iommu-proto.h xen/include/xen/iommu.h
line diff
     1.1 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c	Mon Jul 06 11:56:17 2009 +0100
     1.2 +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c	Mon Jul 06 11:56:51 2009 +0100
     1.3 @@ -441,4 +441,6 @@ struct iommu_ops amd_iommu_ops = {
     1.4      .update_ire_from_msi = amd_iommu_msi_msg_update_ire,
     1.5      .read_apic_from_ire = amd_iommu_read_ioapic_from_ire,
     1.6      .read_msi_from_ire = amd_iommu_read_msi_from_ire,
     1.7 +    .suspend = amd_iommu_suspend,
     1.8 +    .resume = amd_iommu_resume,
     1.9  };
     2.1 --- a/xen/drivers/passthrough/iommu.c	Mon Jul 06 11:56:17 2009 +0100
     2.2 +++ b/xen/drivers/passthrough/iommu.c	Mon Jul 06 11:56:51 2009 +0100
     2.3 @@ -346,6 +346,20 @@ unsigned int iommu_read_apic_from_ire(un
     2.4      return ops->read_apic_from_ire(apic, reg);
     2.5  }
     2.6  
     2.7 +void iommu_resume()
     2.8 +{
     2.9 +    struct iommu_ops *ops = iommu_get_ops();
    2.10 +    if ( iommu_enabled )
    2.11 +        ops->resume();
    2.12 +}
    2.13 +
    2.14 +void iommu_suspend()
    2.15 +{
    2.16 +    struct iommu_ops *ops = iommu_get_ops();
    2.17 +    if ( iommu_enabled )
    2.18 +        ops->suspend();
    2.19 +}
    2.20 +
    2.21  /*
    2.22   * Local variables:
    2.23   * mode: C
     3.1 --- a/xen/drivers/passthrough/vtd/iommu.c	Mon Jul 06 11:56:17 2009 +0100
     3.2 +++ b/xen/drivers/passthrough/vtd/iommu.c	Mon Jul 06 11:56:51 2009 +0100
     3.3 @@ -1848,7 +1848,7 @@ static int intel_iommu_group_id(u8 bus, 
     3.4  }
     3.5  
     3.6  static u32 iommu_state[MAX_IOMMUS][MAX_IOMMU_REGS];
     3.7 -void iommu_suspend(void)
     3.8 +void vtd_suspend(void)
     3.9  {
    3.10      struct acpi_drhd_unit *drhd;
    3.11      struct iommu *iommu;
    3.12 @@ -1887,7 +1887,7 @@ void iommu_suspend(void)
    3.13      }
    3.14  }
    3.15  
    3.16 -void iommu_resume(void)
    3.17 +void vtd_resume(void)
    3.18  {
    3.19      struct acpi_drhd_unit *drhd;
    3.20      struct iommu *iommu;
    3.21 @@ -1934,6 +1934,8 @@ struct iommu_ops intel_iommu_ops = {
    3.22      .update_ire_from_msi = msi_msg_write_remap_rte,
    3.23      .read_apic_from_ire = io_apic_read_remap_rte,
    3.24      .read_msi_from_ire = msi_msg_read_remap_rte,
    3.25 +    .suspend = vtd_suspend,
    3.26 +    .resume = vtd_resume,
    3.27  };
    3.28  
    3.29  /*
     4.1 --- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Mon Jul 06 11:56:17 2009 +0100
     4.2 +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Mon Jul 06 11:56:51 2009 +0100
     4.3 @@ -92,6 +92,10 @@ void amd_iommu_read_msi_from_ire(
     4.4  unsigned int amd_iommu_read_ioapic_from_ire(
     4.5      unsigned int apic, unsigned int reg);
     4.6  
     4.7 +/* power management support */
     4.8 +void amd_iommu_resume(void);
     4.9 +void amd_iommu_suspend(void);
    4.10 +
    4.11  static inline u32 get_field_from_reg_u32(u32 reg_value, u32 mask, u32 shift)
    4.12  {
    4.13      u32 field;
     5.1 --- a/xen/include/xen/iommu.h	Mon Jul 06 11:56:17 2009 +0100
     5.2 +++ b/xen/include/xen/iommu.h	Mon Jul 06 11:56:51 2009 +0100
     5.3 @@ -109,6 +109,8 @@ struct iommu_ops {
     5.4      void (*update_ire_from_msi)(struct msi_desc *msi_desc, struct msi_msg *msg);
     5.5      void (*read_msi_from_ire)(struct msi_desc *msi_desc, struct msi_msg *msg);
     5.6      unsigned int (*read_apic_from_ire)(unsigned int apic, unsigned int reg);
     5.7 +    void (*suspend)(void);
     5.8 +    void (*resume)(void);
     5.9  };
    5.10  
    5.11  void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value);