summaryrefslogtreecommitdiff
path: root/usr/src/uts/sun4u
diff options
context:
space:
mode:
authorBhaskar Sarkar <bhaskar.sarkar@sun.com>2010-04-09 09:33:58 -0700
committerBhaskar Sarkar <bhaskar.sarkar@sun.com>2010-04-09 09:33:58 -0700
commit0ea4884762cfa870ddc7a4eefff4166d5fdb3e09 (patch)
tree5bef636fa1f58c022506272dc49c6b583cdd2e8f /usr/src/uts/sun4u
parent6d1cdc09693601c358cdcd1bbd6a462920ac89ad (diff)
downloadillumos-joyent-0ea4884762cfa870ddc7a4eefff4166d5fdb3e09.tar.gz
6902219 should use atomics for pci fast dvma space accounting
Diffstat (limited to 'usr/src/uts/sun4u')
-rw-r--r--usr/src/uts/sun4u/io/pci/pci_fdvma.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/usr/src/uts/sun4u/io/pci/pci_fdvma.c b/usr/src/uts/sun4u/io/pci/pci_fdvma.c
index 747fe03609..aa01f31da6 100644
--- a/usr/src/uts/sun4u/io/pci/pci_fdvma.c
+++ b/usr/src/uts/sun4u/io/pci/pci_fdvma.c
@@ -19,12 +19,9 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* Internal PCI Fast DVMA implementation
*/
@@ -204,11 +201,14 @@ pci_fdvma_reserve(dev_info_t *dip, dev_info_t *rdip, pci_t *pci_p,
return (DDI_DMA_BADLIMITS);
/*
- * Check the size of the request.
+ * Allocate DVMA space from reserve.
*/
npages = dmareq->dmar_object.dmao_size;
- if (npages > iommu_p->iommu_dvma_reserve)
+ if ((long)atomic_add_long_nv(&iommu_p->iommu_dvma_reserve,
+ -npages) < 0) {
+ atomic_add_long(&iommu_p->iommu_dvma_reserve, npages);
return (DDI_DMA_NORESOURCES);
+ }
/*
* Allocate the dma handle.
@@ -226,10 +226,10 @@ pci_fdvma_reserve(dev_info_t *dip, dev_info_t *rdip, pci_t *pci_p,
counter_max, (void *)lo, (void *)(hi + 1),
dmareq->dmar_fp == DDI_DMA_SLEEP ? VM_SLEEP : VM_NOSLEEP));
if (dvma_pg == 0) {
+ atomic_add_long(&iommu_p->iommu_dvma_reserve, npages);
kmem_free(mp, sizeof (pci_dma_hdl_t));
return (DDI_DMA_NOMAPPING);
}
- iommu_p->iommu_dvma_reserve -= npages;
/*
* Create the fast dvma request structure.
@@ -289,7 +289,7 @@ pci_fdvma_release(dev_info_t *dip, pci_t *pci_p, ddi_dma_impl_t *mp)
npages = mp->dmai_ndvmapages;
pci_vmem_free(iommu_p, mp, (void *)mp->dmai_mapping, npages);
- iommu_p->iommu_dvma_reserve += npages;
+ atomic_add_long(&iommu_p->iommu_dvma_reserve, npages);
mp->dmai_ndvmapages = 0;
/* see if there is anyone waiting for dvma space */