WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Clean up use of spin_is_locked() and intr

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Clean up use of spin_is_locked() and introduce rw_is_locked().
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 Dec 2008 22:31:03 -0800
Delivery-date: Tue, 16 Dec 2008 22:32:36 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1229182090 0
# Node ID e767f80d4bcc90d761df14ba89c2d72d44c99d8b
# Parent  db0c6d297d006c86056a45343e29be962595f211
Clean up use of spin_is_locked() and introduce rw_is_locked().

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/arch/x86/irq.c                            |    4 ++--
 xen/arch/x86/msi.c                            |   10 +++++-----
 xen/common/spinlock.c                         |    6 ++++++
 xen/drivers/passthrough/iommu.c               |    2 +-
 xen/drivers/passthrough/pci.c                 |    4 ++--
 xen/drivers/passthrough/vtd/iommu.c           |   16 ++++++++--------
 xen/include/asm-ia64/linux-xen/asm/spinlock.h |    2 ++
 xen/include/asm-x86/spinlock.h                |    5 +++--
 xen/include/xen/spinlock.h                    |    6 +++++-
 9 files changed, 34 insertions(+), 21 deletions(-)

diff -r db0c6d297d00 -r e767f80d4bcc xen/arch/x86/irq.c
--- a/xen/arch/x86/irq.c        Sat Dec 13 15:04:53 2008 +0000
+++ b/xen/arch/x86/irq.c        Sat Dec 13 15:28:10 2008 +0000
@@ -850,7 +850,7 @@ int map_domain_pirq(
     struct msi_desc *msi_desc;
     struct pci_dev *pdev = NULL;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
     ASSERT(spin_is_locked(&d->event_lock));
 
     if ( !IS_PRIV(current->domain) )
@@ -930,7 +930,7 @@ int unmap_domain_pirq(struct domain *d, 
     if ( !IS_PRIV(current->domain) )
         return -EINVAL;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
     ASSERT(spin_is_locked(&d->event_lock));
 
     vector = d->arch.pirq_vector[pirq];
diff -r db0c6d297d00 -r e767f80d4bcc xen/arch/x86/msi.c
--- a/xen/arch/x86/msi.c        Sat Dec 13 15:04:53 2008 +0000
+++ b/xen/arch/x86/msi.c        Sat Dec 13 15:28:10 2008 +0000
@@ -440,7 +440,7 @@ static int msi_capability_init(struct pc
     u8 slot = PCI_SLOT(dev->devfn);
     u8 func = PCI_FUNC(dev->devfn);
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
     pos = pci_find_cap_offset(bus, slot, func, PCI_CAP_ID_MSI);
     control = pci_conf_read16(bus, slot, func, msi_control_reg(pos));
     /* MSI Entry Initialization */
@@ -509,7 +509,7 @@ static int msix_capability_init(struct p
     u8 slot = PCI_SLOT(dev->devfn);
     u8 func = PCI_FUNC(dev->devfn);
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
     ASSERT(desc);
 
     pos = pci_find_cap_offset(bus, slot, func, PCI_CAP_ID_MSIX);
@@ -574,7 +574,7 @@ static int __pci_enable_msi(struct msi_i
     int status;
     struct pci_dev *pdev;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
     pdev = pci_get_pdev(msi->bus, msi->devfn);
     if ( !pdev )
         return -ENODEV;
@@ -634,7 +634,7 @@ static int __pci_enable_msix(struct msi_
     u8 slot = PCI_SLOT(msi->devfn);
     u8 func = PCI_FUNC(msi->devfn);
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
     pdev = pci_get_pdev(msi->bus, msi->devfn);
     if ( !pdev )
         return -ENODEV;
@@ -688,7 +688,7 @@ static void __pci_disable_msix(struct ms
  */
 int pci_enable_msi(struct msi_info *msi, struct msi_desc **desc)
 {
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
 
     return  msi->table_base ? __pci_enable_msix(msi, desc) :
         __pci_enable_msi(msi, desc);
diff -r db0c6d297d00 -r e767f80d4bcc xen/common/spinlock.c
--- a/xen/common/spinlock.c     Sat Dec 13 15:04:53 2008 +0000
+++ b/xen/common/spinlock.c     Sat Dec 13 15:28:10 2008 +0000
@@ -215,3 +215,9 @@ void _write_unlock_irqrestore(rwlock_t *
     _raw_write_unlock(&lock->raw);
     local_irq_restore(flags);
 }
+
+int _rw_is_locked(rwlock_t *lock)
+{
+    check_lock(&lock->debug);
+    return _raw_rw_is_locked(&lock->raw);
+}
diff -r db0c6d297d00 -r e767f80d4bcc xen/drivers/passthrough/iommu.c
--- a/xen/drivers/passthrough/iommu.c   Sat Dec 13 15:04:53 2008 +0000
+++ b/xen/drivers/passthrough/iommu.c   Sat Dec 13 15:28:10 2008 +0000
@@ -87,7 +87,7 @@ int iommu_add_device(struct pci_dev *pde
     if ( !pdev->domain )
         return -EINVAL;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
 
     hd = domain_hvm_iommu(pdev->domain);
     if ( !iommu_enabled || !hd->platform_ops )
diff -r db0c6d297d00 -r e767f80d4bcc xen/drivers/passthrough/pci.c
--- a/xen/drivers/passthrough/pci.c     Sat Dec 13 15:04:53 2008 +0000
+++ b/xen/drivers/passthrough/pci.c     Sat Dec 13 15:28:10 2008 +0000
@@ -62,7 +62,7 @@ struct pci_dev *pci_get_pdev(int bus, in
 {
     struct pci_dev *pdev = NULL;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
 
     list_for_each_entry ( pdev, &alldevs_list, alldevs_list )
         if ( (pdev->bus == bus || bus == -1) &&
@@ -78,7 +78,7 @@ struct pci_dev *pci_get_pdev_by_domain(s
 {
     struct pci_dev *pdev = NULL;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
 
     list_for_each_entry ( pdev, &alldevs_list, alldevs_list )
          if ( (pdev->bus == bus || bus == -1) &&
diff -r db0c6d297d00 -r e767f80d4bcc xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c       Sat Dec 13 15:04:53 2008 +0000
+++ b/xen/drivers/passthrough/vtd/iommu.c       Sat Dec 13 15:28:10 2008 +0000
@@ -1037,7 +1037,7 @@ static int domain_context_mapping_one(
     struct pci_dev *pdev = NULL;
     int agaw;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
     spin_lock(&iommu->lock);
     maddr = bus_to_context_maddr(iommu, bus);
     context_entries = (struct context_entry *)map_vtd_domain_page(maddr);
@@ -1214,7 +1214,7 @@ static int domain_context_mapping(struct
     if ( !drhd )
         return -ENODEV;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
 
     type = pdev_type(bus, devfn);
     switch ( type )
@@ -1298,7 +1298,7 @@ static int domain_context_unmap_one(
     struct context_entry *context, *context_entries;
     u64 maddr;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
     spin_lock(&iommu->lock);
 
     maddr = bus_to_context_maddr(iommu, bus);
@@ -1388,7 +1388,7 @@ static int reassign_device_ownership(
     struct iommu *pdev_iommu;
     int ret, found = 0;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
     pdev = pci_get_pdev_by_domain(source, bus, devfn);
 
     if (!pdev)
@@ -1428,7 +1428,7 @@ void iommu_domain_teardown(struct domain
     if ( list_empty(&acpi_drhd_units) )
         return;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
     spin_lock(&hd->mapping_lock);
     iommu_free_pagetable(hd->pgd_maddr, agaw_to_level(hd->agaw));
     hd->pgd_maddr = 0;
@@ -1518,7 +1518,7 @@ static int iommu_prepare_rmrr_dev(struct
     u64 base, end;
     unsigned long base_pfn, end_pfn;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
     ASSERT(rmrr->base_address < rmrr->end_address);
     
     base = rmrr->base_address & PAGE_MASK_4K;
@@ -1543,7 +1543,7 @@ static int intel_iommu_add_device(struct
     u16 bdf;
     int ret, i;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
 
     if ( !pdev->domain )
         return -EINVAL;
@@ -1782,7 +1782,7 @@ int intel_iommu_assign_device(struct dom
     if ( list_empty(&acpi_drhd_units) )
         return -ENODEV;
 
-    ASSERT(spin_is_locked(&pcidevs_lock));
+    ASSERT(rw_is_locked(&pcidevs_lock));
     pdev = pci_get_pdev(bus, devfn);
     if (!pdev)
         return -ENODEV;
diff -r db0c6d297d00 -r e767f80d4bcc 
xen/include/asm-ia64/linux-xen/asm/spinlock.h
--- a/xen/include/asm-ia64/linux-xen/asm/spinlock.h     Sat Dec 13 15:04:53 
2008 +0000
+++ b/xen/include/asm-ia64/linux-xen/asm/spinlock.h     Sat Dec 13 15:28:10 
2008 +0000
@@ -216,4 +216,6 @@ do {                                                        
                        \
        clear_bit(31, (x));                                                     
        \
 })
 
+#define _raw_rw_is_locked(x) (*(int *)(x) != 0)
+
 #endif /*  _ASM_IA64_SPINLOCK_H */
diff -r db0c6d297d00 -r e767f80d4bcc xen/include/asm-x86/spinlock.h
--- a/xen/include/asm-x86/spinlock.h    Sat Dec 13 15:04:53 2008 +0000
+++ b/xen/include/asm-x86/spinlock.h    Sat Dec 13 15:28:10 2008 +0000
@@ -12,8 +12,7 @@ typedef struct {
 
 #define _RAW_SPIN_LOCK_UNLOCKED /*(raw_spinlock_t)*/ { 1 }
 
-#define _raw_spin_is_locked(x)                  \
-    (*(volatile char *)(&(x)->lock) <= 0)
+#define _raw_spin_is_locked(x) ((x)->lock <= 0)
 
 static always_inline void _raw_spin_lock(raw_spinlock_t *lock)
 {
@@ -75,4 +74,6 @@ static always_inline void _raw_write_loc
         "lock ; addl $" RW_LOCK_BIAS_STR ",%0" :        \
         "=m" ((rw)->lock) : : "memory" )
 
+#define _raw_rw_is_locked(x) ((x)->lock < RW_LOCK_BIAS)
+
 #endif /* __ASM_SPINLOCK_H */
diff -r db0c6d297d00 -r e767f80d4bcc xen/include/xen/spinlock.h
--- a/xen/include/xen/spinlock.h        Sat Dec 13 15:04:53 2008 +0000
+++ b/xen/include/xen/spinlock.h        Sat Dec 13 15:28:10 2008 +0000
@@ -72,6 +72,8 @@ void _write_unlock_irq(rwlock_t *lock);
 void _write_unlock_irq(rwlock_t *lock);
 void _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags);
 
+int _rw_is_locked(rwlock_t *lock);
+
 #define spin_lock(l)                  _spin_lock(l)
 #define spin_lock_irq(l)              _spin_lock_irq(l)
 #define spin_lock_irqsave(l, f)       ((f) = _spin_lock_irqsave(l))
@@ -80,7 +82,7 @@ void _write_unlock_irqrestore(rwlock_t *
 #define spin_unlock_irq(l)            _spin_unlock_irq(l)
 #define spin_unlock_irqrestore(l, f)  _spin_unlock_irqrestore(l, f)
 
-#define spin_is_locked(l)             _raw_spin_is_locked(&(l)->raw)
+#define spin_is_locked(l)             _spin_is_locked(l)
 #define spin_trylock(l)               _spin_trylock(l)
 
 /* Ensure a lock is quiescent between two critical operations. */
@@ -113,4 +115,6 @@ void _write_unlock_irqrestore(rwlock_t *
 #define write_unlock_irq(l)           _write_unlock_irq(l)
 #define write_unlock_irqrestore(l, f) _write_unlock_irqrestore(l, f)
 
+#define rw_is_locked(l)               _rw_is_locked(l)
+
 #endif /* __SPINLOCK_H__ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Clean up use of spin_is_locked() and introduce rw_is_locked()., Xen patchbot-unstable <=