ia64/xen-unstable

changeset 17434:5b7a3e040683

x86: Remove jiffies usage.

Jiffies will be obsolete in x86 after PIT timer interupt is disabled,
so this patch replace jiffies usage with NOW() API.

Signed-off-by: Yu Ke <ke.yu@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Apr 10 10:12:04 2008 +0100 (2008-04-10)
parents 9153b99a7066
children 8d750b7acfa3
files xen/arch/x86/io_apic.c xen/arch/x86/time.c xen/drivers/passthrough/vtd/dmar.h xen/drivers/passthrough/vtd/intremap.c xen/drivers/passthrough/vtd/iommu.c xen/drivers/passthrough/vtd/qinval.c xen/drivers/passthrough/vtd/utils.c xen/include/asm-ia64/domain.h xen/include/xen/sched.h
line diff
     1.1 --- a/xen/arch/x86/io_apic.c	Thu Apr 10 10:00:41 2008 +0100
     1.2 +++ b/xen/arch/x86/io_apic.c	Thu Apr 10 10:12:04 2008 +0100
     1.3 @@ -1244,7 +1244,11 @@ static void __init setup_ioapic_ids_from
     1.4   */
     1.5  static int __init timer_irq_works(void)
     1.6  {
     1.7 -    unsigned long t1 = jiffies;
     1.8 +    extern unsigned long pit0_ticks;
     1.9 +    unsigned long t1;
    1.10 +
    1.11 +    t1 = pit0_ticks;
    1.12 +    mb();
    1.13  
    1.14      local_irq_enable();
    1.15      /* Let ten ticks pass... */
    1.16 @@ -1257,7 +1261,8 @@ static int __init timer_irq_works(void)
    1.17       * might have cached one ExtINT interrupt.  Finally, at
    1.18       * least one tick may be lost due to delays.
    1.19       */
    1.20 -    if (jiffies - t1 > 4)
    1.21 +    mb();
    1.22 +    if (pit0_ticks - t1 > 4)
    1.23          return 1;
    1.24  
    1.25      return 0;
     2.1 --- a/xen/arch/x86/time.c	Thu Apr 10 10:00:41 2008 +0100
     2.2 +++ b/xen/arch/x86/time.c	Thu Apr 10 10:12:04 2008 +0100
     2.3 @@ -40,7 +40,7 @@ string_param("clocksource", opt_clocksou
     2.4  unsigned long cpu_khz;  /* CPU clock frequency in kHz. */
     2.5  unsigned long hpet_address;
     2.6  DEFINE_SPINLOCK(rtc_lock);
     2.7 -volatile unsigned long jiffies;
     2.8 +unsigned long pit0_ticks;
     2.9  static u32 wc_sec, wc_nsec; /* UTC time at last 'time update'. */
    2.10  static DEFINE_SPINLOCK(wc_lock);
    2.11  
    2.12 @@ -150,8 +150,7 @@ void timer_interrupt(int irq, void *dev_
    2.13  {
    2.14      ASSERT(local_irq_is_enabled());
    2.15  
    2.16 -    /* Update jiffies counter. */
    2.17 -    (*(volatile unsigned long *)&jiffies)++;
    2.18 +    (*(volatile unsigned long *)&pit0_ticks)++;
    2.19  
    2.20      /* Rough hack to allow accurate timers to sort-of-work with no APIC. */
    2.21      if ( !cpu_has_apic )
     3.1 --- a/xen/drivers/passthrough/vtd/dmar.h	Thu Apr 10 10:00:41 2008 +0100
     3.2 +++ b/xen/drivers/passthrough/vtd/dmar.h	Thu Apr 10 10:12:04 2008 +0100
     3.3 @@ -92,14 +92,10 @@ struct acpi_rmrr_unit * acpi_find_matche
     3.4  #define RMRR_TYPE 2
     3.5  #define ATSR_TYPE 3
     3.6  
     3.7 -#define DMAR_OPERATION_TIMEOUT (HZ*60) /* 1m */
     3.8 -#define time_after(a,b)         \
     3.9 -        (typecheck(unsigned long, a) && \
    3.10 -         typecheck(unsigned long, b) && \
    3.11 -         ((long)(b) - (long)(a) < 0))
    3.12 +#define DMAR_OPERATION_TIMEOUT MILLISECS(1000)
    3.13  
    3.14  int vtd_hw_check(void);
    3.15  void disable_pmr(struct iommu *iommu);
    3.16  int is_usb_device(struct pci_dev *pdev);
    3.17  
    3.18 -#endif // _DMAR_H_
    3.19 +#endif /* _DMAR_H_ */
     4.1 --- a/xen/drivers/passthrough/vtd/intremap.c	Thu Apr 10 10:00:41 2008 +0100
     4.2 +++ b/xen/drivers/passthrough/vtd/intremap.c	Thu Apr 10 10:12:04 2008 +0100
     4.3 @@ -21,6 +21,7 @@
     4.4  #include <xen/irq.h>
     4.5  #include <xen/sched.h>
     4.6  #include <xen/iommu.h>
     4.7 +#include <xen/time.h>
     4.8  #include "iommu.h"
     4.9  #include "dmar.h"
    4.10  #include "vtd.h"
    4.11 @@ -244,7 +245,7 @@ io_apic_write_remap_rte(
    4.12  int intremap_setup(struct iommu *iommu)
    4.13  {
    4.14      struct ir_ctrl *ir_ctrl;
    4.15 -    unsigned long start_time;
    4.16 +    s_time_t start_time;
    4.17  
    4.18      if ( !ecap_intr_remap(iommu->ecap) )
    4.19          return -ENODEV;
    4.20 @@ -275,10 +276,10 @@ int intremap_setup(struct iommu *iommu)
    4.21      dmar_writel(iommu->reg, DMAR_GCMD_REG, iommu->gcmd);
    4.22  
    4.23      /* Make sure hardware complete it */
    4.24 -    start_time = jiffies;
    4.25 +    start_time = NOW();
    4.26      while ( !(dmar_readl(iommu->reg, DMAR_GSTS_REG) & DMA_GSTS_SIRTPS) )
    4.27      {
    4.28 -        if ( time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT) )
    4.29 +        if ( NOW() > (start_time + DMAR_OPERATION_TIMEOUT) )
    4.30          {
    4.31              dprintk(XENLOG_ERR VTDPREFIX,
    4.32                      "Cannot set SIRTP field for interrupt remapping\n");
    4.33 @@ -291,10 +292,10 @@ int intremap_setup(struct iommu *iommu)
    4.34      iommu->gcmd |= DMA_GCMD_CFI;
    4.35      dmar_writel(iommu->reg, DMAR_GCMD_REG, iommu->gcmd);
    4.36  
    4.37 -    start_time = jiffies;
    4.38 +    start_time = NOW();
    4.39      while ( !(dmar_readl(iommu->reg, DMAR_GSTS_REG) & DMA_GSTS_CFIS) )
    4.40      {
    4.41 -        if ( time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT) )
    4.42 +        if ( NOW() > (start_time + DMAR_OPERATION_TIMEOUT) )
    4.43          {
    4.44              dprintk(XENLOG_ERR VTDPREFIX,
    4.45                      "Cannot set CFI field for interrupt remapping\n");
    4.46 @@ -307,10 +308,10 @@ int intremap_setup(struct iommu *iommu)
    4.47      iommu->gcmd |= DMA_GCMD_IRE;
    4.48      dmar_writel(iommu->reg, DMAR_GCMD_REG, iommu->gcmd);
    4.49  
    4.50 -    start_time = jiffies;
    4.51 +    start_time = NOW();
    4.52      while ( !(dmar_readl(iommu->reg, DMAR_GSTS_REG) & DMA_GSTS_IRES) )
    4.53      {
    4.54 -        if ( time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT) )
    4.55 +        if ( NOW() > (start_time + DMAR_OPERATION_TIMEOUT) ) 
    4.56          {
    4.57              dprintk(XENLOG_ERR VTDPREFIX,
    4.58                      "Cannot set IRE field for interrupt remapping\n");
     5.1 --- a/xen/drivers/passthrough/vtd/iommu.c	Thu Apr 10 10:00:41 2008 +0100
     5.2 +++ b/xen/drivers/passthrough/vtd/iommu.c	Thu Apr 10 10:12:04 2008 +0100
     5.3 @@ -26,6 +26,7 @@
     5.4  #include <asm/paging.h>
     5.5  #include <xen/iommu.h>
     5.6  #include <xen/numa.h>
     5.7 +#include <xen/time.h>
     5.8  #include "iommu.h"
     5.9  #include "dmar.h"
    5.10  #include "../pci-direct.h"
    5.11 @@ -356,7 +357,7 @@ static void iommu_flush_write_buffer(str
    5.12  {
    5.13      u32 val;
    5.14      unsigned long flag;
    5.15 -    unsigned long start_time;
    5.16 +    s_time_t start_time;
    5.17  
    5.18      if ( !cap_rwbf(iommu->cap) )
    5.19          return;
    5.20 @@ -366,13 +367,13 @@ static void iommu_flush_write_buffer(str
    5.21      dmar_writel(iommu->reg, DMAR_GCMD_REG, val);
    5.22  
    5.23      /* Make sure hardware complete it */
    5.24 -    start_time = jiffies;
    5.25 +    start_time = NOW();
    5.26      for ( ; ; )
    5.27      {
    5.28          val = dmar_readl(iommu->reg, DMAR_GSTS_REG);
    5.29          if ( !(val & DMA_GSTS_WBFS) )
    5.30              break;
    5.31 -        if ( time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT) )
    5.32 +        if ( NOW() > start_time + DMAR_OPERATION_TIMEOUT )
    5.33              panic("DMAR hardware is malfunctional,"
    5.34                    " please disable IOMMU\n");
    5.35          cpu_relax();
    5.36 @@ -389,7 +390,7 @@ static int flush_context_reg(
    5.37      struct iommu *iommu = (struct iommu *) _iommu;
    5.38      u64 val = 0;
    5.39      unsigned long flag;
    5.40 -    unsigned long start_time;
    5.41 +    s_time_t start_time;
    5.42  
    5.43      /*
    5.44       * In the non-present entry flush case, if hardware doesn't cache
    5.45 @@ -427,13 +428,13 @@ static int flush_context_reg(
    5.46      dmar_writeq(iommu->reg, DMAR_CCMD_REG, val);
    5.47  
    5.48      /* Make sure hardware complete it */
    5.49 -    start_time = jiffies;
    5.50 +    start_time = NOW();
    5.51      for ( ; ; )
    5.52      {
    5.53          val = dmar_readq(iommu->reg, DMAR_CCMD_REG);
    5.54          if ( !(val & DMA_CCMD_ICC) )
    5.55              break;
    5.56 -        if ( time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT) )
    5.57 +        if ( NOW() > start_time + DMAR_OPERATION_TIMEOUT )
    5.58              panic("DMAR hardware is malfunctional, please disable IOMMU\n");
    5.59          cpu_relax();
    5.60      }
    5.61 @@ -477,7 +478,7 @@ static int flush_iotlb_reg(void *_iommu,
    5.62      int tlb_offset = ecap_iotlb_offset(iommu->ecap);
    5.63      u64 val = 0, val_iva = 0;
    5.64      unsigned long flag;
    5.65 -    unsigned long start_time;
    5.66 +    s_time_t start_time;
    5.67  
    5.68      /*
    5.69       * In the non-present entry flush case, if hardware doesn't cache
    5.70 @@ -524,13 +525,13 @@ static int flush_iotlb_reg(void *_iommu,
    5.71      dmar_writeq(iommu->reg, tlb_offset + 8, val);
    5.72  
    5.73      /* Make sure hardware complete it */
    5.74 -    start_time = jiffies;
    5.75 +    start_time = NOW();
    5.76      for ( ; ; )
    5.77      {
    5.78          val = dmar_readq(iommu->reg, tlb_offset + 8);
    5.79          if ( !(val & DMA_TLB_IVT) )
    5.80              break;
    5.81 -        if ( time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT) )
    5.82 +        if ( NOW() > start_time + DMAR_OPERATION_TIMEOUT )
    5.83              panic("DMAR hardware is malfunctional, please disable IOMMU\n");
    5.84          cpu_relax();
    5.85      }
     6.1 --- a/xen/drivers/passthrough/vtd/qinval.c	Thu Apr 10 10:00:41 2008 +0100
     6.2 +++ b/xen/drivers/passthrough/vtd/qinval.c	Thu Apr 10 10:12:04 2008 +0100
     6.3 @@ -21,6 +21,7 @@
     6.4  
     6.5  #include <xen/sched.h>
     6.6  #include <xen/iommu.h>
     6.7 +#include <xen/time.h>
     6.8  #include "iommu.h"
     6.9  #include "dmar.h"
    6.10  #include "vtd.h"
    6.11 @@ -183,7 +184,7 @@ static int queue_invalidate_wait(struct 
    6.12      u8 iflag, u8 sw, u8 fn, u32 sdata, volatile u32 *saddr)
    6.13  {
    6.14      unsigned long flags;
    6.15 -    unsigned long start_time;
    6.16 +    s_time_t start_time;
    6.17      int index = -1;
    6.18      int ret = -1;
    6.19      struct qi_ctrl *qi_ctrl = iommu_qi_ctrl(iommu);
    6.20 @@ -201,10 +202,10 @@ static int queue_invalidate_wait(struct 
    6.21      if ( sw )
    6.22      {
    6.23          /* In case all wait descriptor writes to same addr with same data */
    6.24 -        start_time = jiffies;
    6.25 +        start_time = NOW();
    6.26          while ( *saddr != 1 )
    6.27          {
    6.28 -            if ( time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT) )
    6.29 +            if ( NOW() > (start_time + DMAR_OPERATION_TIMEOUT) )
    6.30              {
    6.31                  print_qi_regs(iommu);
    6.32                  panic("queue invalidate wait descriptor was not executed\n");
    6.33 @@ -414,7 +415,7 @@ static int flush_iotlb_qi(
    6.34  
    6.35  int qinval_setup(struct iommu *iommu)
    6.36  {
    6.37 -    unsigned long start_time;
    6.38 +    s_time_t start_time;
    6.39      u32 status = 0;
    6.40      struct qi_ctrl *qi_ctrl;
    6.41      struct iommu_flush *flush;
    6.42 @@ -448,13 +449,13 @@ int qinval_setup(struct iommu *iommu)
    6.43      dmar_writel(iommu->reg, DMAR_GCMD_REG, iommu->gcmd);
    6.44  
    6.45      /* Make sure hardware complete it */
    6.46 -    start_time = jiffies;
    6.47 -    while ( 1 )
    6.48 +    start_time = NOW();
    6.49 +    for ( ; ; )
    6.50      {
    6.51          status = dmar_readl(iommu->reg, DMAR_GSTS_REG);
    6.52          if ( status & DMA_GSTS_QIES )
    6.53              break;
    6.54 -        if ( time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT) )
    6.55 +        if ( NOW() > (start_time + DMAR_OPERATION_TIMEOUT) )
    6.56              panic("Cannot set QIE field for queue invalidation\n");
    6.57          cpu_relax();
    6.58      }
     7.1 --- a/xen/drivers/passthrough/vtd/utils.c	Thu Apr 10 10:00:41 2008 +0100
     7.2 +++ b/xen/drivers/passthrough/vtd/utils.c	Thu Apr 10 10:12:04 2008 +0100
     7.3 @@ -20,6 +20,7 @@
     7.4  #include <xen/sched.h>
     7.5  #include <xen/delay.h>
     7.6  #include <xen/iommu.h>
     7.7 +#include <xen/time.h>
     7.8  #include "iommu.h"
     7.9  #include "dmar.h"
    7.10  #include "../pci-direct.h"
    7.11 @@ -69,7 +70,7 @@ int vtd_hw_check(void)
    7.12  /* Disable vt-d protected memory registers. */
    7.13  void disable_pmr(struct iommu *iommu)
    7.14  {
    7.15 -    unsigned long start_time;
    7.16 +    s_time_t start_time;
    7.17      unsigned int val;
    7.18  
    7.19      val = dmar_readl(iommu->reg, DMAR_PMEN_REG);
    7.20 @@ -77,7 +78,7 @@ void disable_pmr(struct iommu *iommu)
    7.21          return;
    7.22  
    7.23      dmar_writel(iommu->reg, DMAR_PMEN_REG, val & ~DMA_PMEN_EPM);
    7.24 -    start_time = jiffies;
    7.25 +    start_time = NOW();
    7.26  
    7.27      for ( ; ; )
    7.28      {
    7.29 @@ -85,7 +86,7 @@ void disable_pmr(struct iommu *iommu)
    7.30          if ( (val & DMA_PMEN_PRS) == 0 )
    7.31              break;
    7.32  
    7.33 -        if ( time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT) )
    7.34 +        if ( NOW() > start_time + DMAR_OPERATION_TIMEOUT )
    7.35              panic("Disable PMRs timeout\n");
    7.36  
    7.37          cpu_relax();
     8.1 --- a/xen/include/asm-ia64/domain.h	Thu Apr 10 10:00:41 2008 +0100
     8.2 +++ b/xen/include/asm-ia64/domain.h	Thu Apr 10 10:12:04 2008 +0100
     8.3 @@ -18,6 +18,8 @@ struct p2m_entry;
     8.4  struct tlb_track;
     8.5  #endif
     8.6  
     8.7 +extern unsigned long volatile jiffies;
     8.8 +
     8.9  struct vcpu;
    8.10  extern void relinquish_vcpu_resources(struct vcpu *v);
    8.11  extern int vcpu_late_initialise(struct vcpu *v);
     9.1 --- a/xen/include/xen/sched.h	Thu Apr 10 10:00:41 2008 +0100
     9.2 +++ b/xen/include/xen/sched.h	Thu Apr 10 10:12:04 2008 +0100
     9.3 @@ -25,8 +25,6 @@
     9.4  DEFINE_XEN_GUEST_HANDLE(vcpu_runstate_info_compat_t);
     9.5  #endif
     9.6  
     9.7 -extern unsigned long volatile jiffies;
     9.8 -
     9.9  /* A global pointer to the initial domain (DOM0). */
    9.10  extern struct domain *dom0;
    9.11