public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Calgary: more updates for 2.6.23
@ 2007-07-11 13:35 muli
  2007-07-11 13:35 ` [PATCH 1/4] x86-64: Calgary - fix few style problems pointed out by checkpatch.pl muli
  0 siblings, 1 reply; 5+ messages in thread
From: muli @ 2007-07-11 13:35 UTC (permalink / raw)
  To: ak; +Cc: linux-kernel, muli, jdmason

Hi Andi,

Here are a few more Calgary updates that are appropriate for
2.6.23. The only notable one is the second one, which tightens up the
bitmap locking to only lock where absolutely necessary, giving us a
nice 10-15% improvement in CPU utilization running netperf on a large
SMP machine. Please apply.

Thanks,
Muli


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] x86-64: Calgary - fix few style problems pointed out by checkpatch.pl
  2007-07-11 13:35 Calgary: more updates for 2.6.23 muli
@ 2007-07-11 13:35 ` muli
  2007-07-11 13:35   ` [PATCH 2/4] x86-64: Calgary - tighten up the bitmap locking muli
  0 siblings, 1 reply; 5+ messages in thread
From: muli @ 2007-07-11 13:35 UTC (permalink / raw)
  To: ak; +Cc: linux-kernel, muli, jdmason

From: Muli Ben-Yehuda <muli@il.ibm.com>

No actual code was harmed in the production of this patch.

Thanks to Andrew Morton <akpm@linux-foundation.org> for telling me
about checkpatch.pl.

Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
---
 arch/x86_64/kernel/pci-calgary.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86_64/kernel/pci-calgary.c b/arch/x86_64/kernel/pci-calgary.c
index aef4cfc..f589c2d 100644
--- a/arch/x86_64/kernel/pci-calgary.c
+++ b/arch/x86_64/kernel/pci-calgary.c
@@ -377,7 +377,9 @@ static inline struct iommu_table *find_iommu_table(struct device *dev)
 		pbus = pdev->bus;
 
 	tbl = pbus->self->sysdata;
-	BUG_ON(pdev->bus->parent && (tbl->it_busno != pdev->bus->parent->number));
+
+	BUG_ON(pdev->bus->parent &&
+	       (tbl->it_busno != pdev->bus->parent->number));
 
 	return tbl;
 }
@@ -943,7 +945,8 @@ static void calioc2_dump_error_regs(struct iommu_table *tbl)
 	/* dump rest of error regs */
 	printk(KERN_EMERG "Calgary: ");
 	for (i = 0; i < ARRAY_SIZE(errregs); i++) {
-		erroff = (0x810 + (i * 0x10)); /* err regs are at 0x810 - 0x870 */
+		/* err regs are at 0x810 - 0x870 */
+		erroff = (0x810 + (i * 0x10));
 		target = calgary_reg(bbar, phboff | erroff);
 		errregs[i] = be32_to_cpu(readl(target));
 		printk("0x%08x@0x%lx ", errregs[i], erroff);
@@ -1209,7 +1212,7 @@ static int __init calgary_init(void)
 {
 	int ret;
 	struct pci_dev *dev = NULL;
-	void* tce_space;
+	void *tce_space;
 
 	ret = calgary_locate_bbars();
 	if (ret)
-- 
1.5.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] x86-64:  Calgary - tighten up the bitmap locking
  2007-07-11 13:35 ` [PATCH 1/4] x86-64: Calgary - fix few style problems pointed out by checkpatch.pl muli
@ 2007-07-11 13:35   ` muli
  2007-07-11 13:35     ` [PATCH 3/4] x86-64: Calgary - fold in redundant functions muli
  0 siblings, 1 reply; 5+ messages in thread
From: muli @ 2007-07-11 13:35 UTC (permalink / raw)
  To: ak; +Cc: linux-kernel, muli, jdmason

From: Muli Ben-Yehuda <muli@il.ibm.com>

Currently the IOMMU table's lock protects both the bitmap and access
to the hardware's TCE table. Access to the TCE table is synchronized
through the bitmap; therefore, only hold the lock while modifying the
bitmap. This gives a yummy 10-15% reduction in CPU utilization for
netperf on a large SMP machine.

Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
---
 arch/x86_64/kernel/pci-calgary.c |   40 ++++++++++++++++---------------------
 1 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/arch/x86_64/kernel/pci-calgary.c b/arch/x86_64/kernel/pci-calgary.c
index f589c2d..28ce2b3 100644
--- a/arch/x86_64/kernel/pci-calgary.c
+++ b/arch/x86_64/kernel/pci-calgary.c
@@ -235,6 +235,7 @@ static void iommu_range_reserve(struct iommu_table *tbl,
 	unsigned long index;
 	unsigned long end;
 	unsigned long badbit;
+	unsigned long flags;
 
 	index = start_addr >> PAGE_SHIFT;
 
@@ -246,6 +247,8 @@ static void iommu_range_reserve(struct iommu_table *tbl,
 	if (end > tbl->it_size) /* don't go off the table */
 		end = tbl->it_size;
 
+	spin_lock_irqsave(&tbl->it_lock, flags);
+
 	badbit = verify_bit_range(tbl->it_map, 0, index, end);
 	if (badbit != ~0UL) {
 		if (printk_ratelimit())
@@ -255,15 +258,20 @@ static void iommu_range_reserve(struct iommu_table *tbl,
 	}
 
 	set_bit_string(tbl->it_map, index, npages);
+
+	spin_unlock_irqrestore(&tbl->it_lock, flags);
 }
 
 static unsigned long iommu_range_alloc(struct iommu_table *tbl,
 	unsigned int npages)
 {
+	unsigned long flags;
 	unsigned long offset;
 
 	BUG_ON(npages == 0);
 
+	spin_lock_irqsave(&tbl->it_lock, flags);
+
 	offset = find_next_zero_string(tbl->it_map, tbl->it_hint,
 				       tbl->it_size, npages);
 	if (offset == ~0UL) {
@@ -272,6 +280,7 @@ static unsigned long iommu_range_alloc(struct iommu_table *tbl,
 					       tbl->it_size, npages);
 		if (offset == ~0UL) {
 			printk(KERN_WARNING "Calgary: IOMMU full.\n");
+			spin_unlock_irqrestore(&tbl->it_lock, flags);
 			if (panic_on_overflow)
 				panic("Calgary: fix the allocator.\n");
 			else
@@ -283,17 +292,17 @@ static unsigned long iommu_range_alloc(struct iommu_table *tbl,
 	tbl->it_hint = offset + npages;
 	BUG_ON(tbl->it_hint > tbl->it_size);
 
+	spin_unlock_irqrestore(&tbl->it_lock, flags);
+
 	return offset;
 }
 
 static dma_addr_t iommu_alloc(struct iommu_table *tbl, void *vaddr,
 	unsigned int npages, int direction)
 {
-	unsigned long entry, flags;
+	unsigned long entry;
 	dma_addr_t ret = bad_dma_address;
 
-	spin_lock_irqsave(&tbl->it_lock, flags);
-
 	entry = iommu_range_alloc(tbl, npages);
 
 	if (unlikely(entry == bad_dma_address))
@@ -306,12 +315,9 @@ static dma_addr_t iommu_alloc(struct iommu_table *tbl, void *vaddr,
 	tce_build(tbl, entry, npages, (unsigned long)vaddr & PAGE_MASK,
 		  direction);
 
-	spin_unlock_irqrestore(&tbl->it_lock, flags);
-
 	return ret;
 
 error:
-	spin_unlock_irqrestore(&tbl->it_lock, flags);
 	printk(KERN_WARNING "Calgary: failed to allocate %u pages in "
 	       "iommu %p\n", npages, tbl);
 	return bad_dma_address;
@@ -323,6 +329,7 @@ static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
 	unsigned long entry;
 	unsigned long badbit;
 	unsigned long badend;
+	unsigned long flags;
 
 	/* were we called with bad_dma_address? */
 	badend = bad_dma_address + (EMERGENCY_PAGES * PAGE_SIZE);
@@ -339,6 +346,8 @@ static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
 
 	tce_free(tbl, entry, npages);
 
+	spin_lock_irqsave(&tbl->it_lock, flags);
+
 	badbit = verify_bit_range(tbl->it_map, 1, entry, entry + npages);
 	if (badbit != ~0UL) {
 		if (printk_ratelimit())
@@ -348,18 +357,14 @@ static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
 	}
 
 	__clear_bit_string(tbl->it_map, entry, npages);
+
+	spin_unlock_irqrestore(&tbl->it_lock, flags);
 }
 
 static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
 	unsigned int npages)
 {
-	unsigned long flags;
-
-	spin_lock_irqsave(&tbl->it_lock, flags);
-
 	__iommu_free(tbl, dma_addr, npages);
-
-	spin_unlock_irqrestore(&tbl->it_lock, flags);
 }
 
 static inline struct iommu_table *find_iommu_table(struct device *dev)
@@ -404,17 +409,12 @@ static void __calgary_unmap_sg(struct iommu_table *tbl,
 void calgary_unmap_sg(struct device *dev, struct scatterlist *sglist,
 		      int nelems, int direction)
 {
-	unsigned long flags;
 	struct iommu_table *tbl = find_iommu_table(dev);
 
 	if (!translate_phb(to_pci_dev(dev)))
 		return;
 
-	spin_lock_irqsave(&tbl->it_lock, flags);
-
 	__calgary_unmap_sg(tbl, sglist, nelems, direction);
-
-	spin_unlock_irqrestore(&tbl->it_lock, flags);
 }
 
 static int calgary_nontranslate_map_sg(struct device* dev,
@@ -435,7 +435,6 @@ int calgary_map_sg(struct device *dev, struct scatterlist *sg,
 	int nelems, int direction)
 {
 	struct iommu_table *tbl = find_iommu_table(dev);
-	unsigned long flags;
 	unsigned long vaddr;
 	unsigned int npages;
 	unsigned long entry;
@@ -444,8 +443,6 @@ int calgary_map_sg(struct device *dev, struct scatterlist *sg,
 	if (!translate_phb(to_pci_dev(dev)))
 		return calgary_nontranslate_map_sg(dev, sg, nelems, direction);
 
-	spin_lock_irqsave(&tbl->it_lock, flags);
-
 	for (i = 0; i < nelems; i++ ) {
 		struct scatterlist *s = &sg[i];
 		BUG_ON(!s->page);
@@ -469,8 +466,6 @@ int calgary_map_sg(struct device *dev, struct scatterlist *sg,
 		s->dma_length = s->length;
 	}
 
-	spin_unlock_irqrestore(&tbl->it_lock, flags);
-
 	return nelems;
 error:
 	__calgary_unmap_sg(tbl, sg, nelems, direction);
@@ -478,7 +473,6 @@ error:
 		sg[i].dma_address = bad_dma_address;
 		sg[i].dma_length = 0;
 	}
-	spin_unlock_irqrestore(&tbl->it_lock, flags);
 	return 0;
 }
 
-- 
1.5.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] x86-64: Calgary - fold in redundant functions
  2007-07-11 13:35   ` [PATCH 2/4] x86-64: Calgary - tighten up the bitmap locking muli
@ 2007-07-11 13:35     ` muli
  2007-07-11 13:35       ` [PATCH 4/4] x86_64: Calgary - change _map_single, etc to static muli
  0 siblings, 1 reply; 5+ messages in thread
From: muli @ 2007-07-11 13:35 UTC (permalink / raw)
  To: ak; +Cc: linux-kernel, muli, jdmason

From: Muli Ben-Yehuda <muli@il.ibm.com>

After the bitmap changes we can get rid of the unlocked versions of
calgary_unmap_sg and iommu_free. Fold __calgary_unmap_sg and
__iommu_free into their calgary_unmap_sg and iommu_free, respectively.

Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
---
 arch/x86_64/kernel/pci-calgary.c |   30 +++++++++---------------------
 1 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/arch/x86_64/kernel/pci-calgary.c b/arch/x86_64/kernel/pci-calgary.c
index 28ce2b3..c0cdba7 100644
--- a/arch/x86_64/kernel/pci-calgary.c
+++ b/arch/x86_64/kernel/pci-calgary.c
@@ -323,7 +323,7 @@ error:
 	return bad_dma_address;
 }
 
-static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
+static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
 	unsigned int npages)
 {
 	unsigned long entry;
@@ -361,12 +361,6 @@ static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
 	spin_unlock_irqrestore(&tbl->it_lock, flags);
 }
 
-static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
-	unsigned int npages)
-{
-	__iommu_free(tbl, dma_addr, npages);
-}
-
 static inline struct iommu_table *find_iommu_table(struct device *dev)
 {
 	struct pci_dev *pdev;
@@ -389,9 +383,14 @@ static inline struct iommu_table *find_iommu_table(struct device *dev)
 	return tbl;
 }
 
-static void __calgary_unmap_sg(struct iommu_table *tbl,
+static void calgary_unmap_sg(struct device *dev,
 	struct scatterlist *sglist, int nelems, int direction)
 {
+	struct iommu_table *tbl = find_iommu_table(dev);
+
+	if (!translate_phb(to_pci_dev(dev)))
+		return;
+
 	while (nelems--) {
 		unsigned int npages;
 		dma_addr_t dma = sglist->dma_address;
@@ -401,22 +400,11 @@ static void __calgary_unmap_sg(struct iommu_table *tbl,
 			break;
 
 		npages = num_dma_pages(dma, dmalen);
-		__iommu_free(tbl, dma, npages);
+		iommu_free(tbl, dma, npages);
 		sglist++;
 	}
 }
 
-void calgary_unmap_sg(struct device *dev, struct scatterlist *sglist,
-		      int nelems, int direction)
-{
-	struct iommu_table *tbl = find_iommu_table(dev);
-
-	if (!translate_phb(to_pci_dev(dev)))
-		return;
-
-	__calgary_unmap_sg(tbl, sglist, nelems, direction);
-}
-
 static int calgary_nontranslate_map_sg(struct device* dev,
 	struct scatterlist *sg, int nelems, int direction)
 {
@@ -468,7 +456,7 @@ int calgary_map_sg(struct device *dev, struct scatterlist *sg,
 
 	return nelems;
 error:
-	__calgary_unmap_sg(tbl, sg, nelems, direction);
+	calgary_unmap_sg(dev, sg, nelems, direction);
 	for (i = 0; i < nelems; i++) {
 		sg[i].dma_address = bad_dma_address;
 		sg[i].dma_length = 0;
-- 
1.5.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] x86_64: Calgary - change _map_single, etc to static
  2007-07-11 13:35     ` [PATCH 3/4] x86-64: Calgary - fold in redundant functions muli
@ 2007-07-11 13:35       ` muli
  0 siblings, 0 replies; 5+ messages in thread
From: muli @ 2007-07-11 13:35 UTC (permalink / raw)
  To: ak; +Cc: linux-kernel, muli, jdmason, Yinghai Lu

From: Yinghai Lu <yinghai.lu@sun.com>

there function are called via dma_ops->.., so change them to static

Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
---
 arch/x86_64/kernel/pci-calgary.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86_64/kernel/pci-calgary.c b/arch/x86_64/kernel/pci-calgary.c
index c0cdba7..aec8f76 100644
--- a/arch/x86_64/kernel/pci-calgary.c
+++ b/arch/x86_64/kernel/pci-calgary.c
@@ -419,7 +419,7 @@ static int calgary_nontranslate_map_sg(struct device* dev,
 	return nelems;
 }
 
-int calgary_map_sg(struct device *dev, struct scatterlist *sg,
+static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
 	int nelems, int direction)
 {
 	struct iommu_table *tbl = find_iommu_table(dev);
@@ -464,7 +464,7 @@ error:
 	return 0;
 }
 
-dma_addr_t calgary_map_single(struct device *dev, void *vaddr,
+static dma_addr_t calgary_map_single(struct device *dev, void *vaddr,
 	size_t size, int direction)
 {
 	dma_addr_t dma_handle = bad_dma_address;
@@ -483,7 +483,7 @@ dma_addr_t calgary_map_single(struct device *dev, void *vaddr,
 	return dma_handle;
 }
 
-void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle,
+static void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle,
 	size_t size, int direction)
 {
 	struct iommu_table *tbl = find_iommu_table(dev);
@@ -496,7 +496,7 @@ void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle,
 	iommu_free(tbl, dma_handle, npages);
 }
 
-void* calgary_alloc_coherent(struct device *dev, size_t size,
+static void* calgary_alloc_coherent(struct device *dev, size_t size,
 	dma_addr_t *dma_handle, gfp_t flag)
 {
 	void *ret = NULL;
-- 
1.5.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-07-11 13:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-11 13:35 Calgary: more updates for 2.6.23 muli
2007-07-11 13:35 ` [PATCH 1/4] x86-64: Calgary - fix few style problems pointed out by checkpatch.pl muli
2007-07-11 13:35   ` [PATCH 2/4] x86-64: Calgary - tighten up the bitmap locking muli
2007-07-11 13:35     ` [PATCH 3/4] x86-64: Calgary - fold in redundant functions muli
2007-07-11 13:35       ` [PATCH 4/4] x86_64: Calgary - change _map_single, etc to static muli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox