[parisc-linux-cvs] DIFF -pa68 DELAYED_RESOURCE_CNT in sba

Grant Grundler grundler@puffin.external.hp.com
Tue, 23 Oct 2001 21:15:54 -0600


Grant Grundler wrote:
> Log message:
> -pa68
> Enabled DELAYED_RESOURCE_CNT in SBA. Reduces the number of IO
> space reads in pci_unmap code path.
> Boots a500 (64-bit) and c3k (32-bit) but not well tested.
> Disable by setting #define DELAYED_RESOURCE_CNT to 0.


Here's the matching diff

grant


Index: Makefile
===================================================================
RCS file: /home/cvs/parisc/linux/Makefile,v
retrieving revision 1.179
diff -u -p -r1.179 Makefile
--- Makefile	2001/10/23 06:41:30	1.179
+++ Makefile	2001/10/23 20:21:51
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 9
-EXTRAVERSION = -pa67
+EXTRAVERSION = -pa68
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
Index: arch/parisc/kernel/sba_iommu.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/sba_iommu.c,v
retrieving revision 1.53
diff -u -p -r1.53 sba_iommu.c
--- sba_iommu.c	2001/10/23 06:41:31	1.53
+++ sba_iommu.c	2001/10/23 20:21:51
@@ -91,11 +91,7 @@
 ** allocated and free'd/purged at a time might make this
 ** less interesting).
 */
-#if 0
 #define DELAYED_RESOURCE_CNT	16
-#else
-#undef DELAYED_RESOURCE_CNT
-#endif
 
 #define DEFAULT_DMA_HINT_REG	0
 
@@ -212,7 +208,7 @@ struct ioc {
 	unsigned int	res_bitshift;	/* from the LEFT! */
 	unsigned int	res_size;	/* size of resource map in bytes */
 	unsigned int	hint_shift_pdir;
-#ifdef DELAYED_RESOURCE_CNT
+#if DELAYED_RESOURCE_CNT > 0
 	int saved_cnt;
 	struct sba_dma_pair {
 		dma_addr_t	iova;
@@ -891,7 +887,7 @@ static void
 sba_unmap_single(struct pci_dev *dev, dma_addr_t iova, size_t size, int direction)
 {
 	struct ioc *ioc;
-#ifdef DELAYED_RESOURCE_CNT
+#if DELAYED_RESOURCE_CNT > 0
 	struct sba_dma_pair *d;
 #endif
 	unsigned long flags; 
@@ -901,8 +897,8 @@ sba_unmap_single(struct pci_dev *dev, dm
 	ioc = GET_IOC(dev);
 	ASSERT(ioc);
 
-#ifdef DELAYED_RESOURCE_CNT
-	*d = &(ioc->saved[ioc->saved_cnt]);
+#if DELAYED_RESOURCE_CNT > 0
+	d = &(ioc->saved[ioc->saved_cnt]);
 #endif
 
 	offset = iova & ~IOVP_MASK;
@@ -920,35 +916,32 @@ sba_unmap_single(struct pci_dev *dev, dm
 	ioc->usingle_pages += size >> IOVP_SHIFT;
 #endif
 
-#ifdef DELAYED_RESOURCE_CNT
+#if DELAYED_RESOURCE_CNT > 0
 	d->iova = iova;
 	d->size = size;
-	if (++ioc->saved_cnt >= DELAYED_RESOURCE_CNT) {
-		int	cnt = ioc->saved_cnt;
-		while (cnt) {
+	if (++(ioc->saved_cnt) >= DELAYED_RESOURCE_CNT) {
+		int cnt = ioc->saved_cnt;
+		while (cnt--) {
 			sba_mark_invalid(ioc, d->iova, d->size);
 			sba_free_range(ioc, d->iova, d->size);
 			d--;
-			cnt--;
 		}
 		ioc->saved_cnt = 0;
-		/* flush purges */
-		READ_REG(ioc->ioc_hpa+IOC_PCOM);
+		READ_REG(ioc->ioc_hpa+IOC_PCOM);	/* flush purges */
 	}
-#else
+#else /* DELAYED_RESOURCE_CNT == 0 */
 	sba_mark_invalid(ioc, iova, size);
 	sba_free_range(ioc, iova, size);
-	/* flush purges */
-	READ_REG(ioc->ioc_hpa+IOC_PCOM);
-#endif
+	READ_REG(ioc->ioc_hpa+IOC_PCOM);	/* flush purges */
+#endif /* DELAYED_RESOURCE_CNT == 0 */
 	spin_unlock_irqrestore(&ioc->res_lock, flags);
 
-	/* XXX REVISIT for 2.5 Linux - we need syncdma for kernel-user
-	** space zero-copy support. For Astro based systems this isn't
-	** a big deal WRT performance.
+	/* XXX REVISIT for 2.5 Linux - need syncdma for zero-copy support.
+	** For Astro based systems this isn't a big deal WRT performance.
 	** As long as 2.4 kernels copyin/copyout data from/to userspace,
-	** we don't need the syncdma. The issue here is the cachelines
-	** in the I/O MMU are *not* fully coherent - this is a bug.
+	** we don't need the syncdma. The issue here is I/O MMU cachelines
+	** are *not* coherent in all cases.  May be hwrev dependent.
+	** Need to investigate more.
 	asm volatile("syncdma");	
 	*/
 }