[parisc-linux-cvs] 2.4.18-pa2

Matthew Wilcox willy@debian.org
Thu, 28 Feb 2002 07:21:44 +0000


I chickened out and left NASTY_HACK_FOR_K_CLASS ifdef in.  This code
could seriously screw up any ccio based machine except for rbrad's.
Someone who cares about K class can fix this code properly.

Index: arch/parisc/kernel/ccio-dma.c
===================================================================
RCS file: /var/cvs/linux/arch/parisc/kernel/ccio-dma.c,v
retrieving revision 1.51
diff -u -p -r1.51 ccio-dma.c
--- arch/parisc/kernel/ccio-dma.c	2002/02/09 06:46:24	1.51
+++ arch/parisc/kernel/ccio-dma.c	2002/02/28 07:07:37
@@ -1458,29 +1458,60 @@ static void __init ccio_init_resources(s
 			(unsigned long)&ioc->ioc_hpa->io_io_low_hv);
 }
 
-#ifdef NASTY_HACK_FOR_K_CLASS
-void ccio_extend_mmio_range(struct ioc *ioc)
+static struct resource *expand_ioc_area(struct ioc *ioc, unsigned long size,
+		unsigned long min, unsigned long max, unsigned long align)
 {
+#ifdef NASTY_HACK_FOR_K_CLASS
 	__raw_writel(0xfffff600, (unsigned long)&(ioc->ioc_hpa->io_io_high));
 	ioc->mmio_region[0].end = 0xf5ffffff;
-}
+	return ioc->mmio_region;
 #endif
+}
 
-struct resource * ccio_find_parisc_resource(const struct parisc_device *dev)
+static struct resource *ccio_get_resource(struct ioc* ioc,
+		const struct parisc_device *dev)
 {
-	struct ioc *ioc = ccio_get_iommu(dev);
-	if (!ioc)
+	if (!ioc) {
 		return &iomem_resource;
-
-	if ((ioc->mmio_region->start <= dev->hpa) &&
+	} else if ((ioc->mmio_region->start <= dev->hpa) &&
 			(dev->hpa < ioc->mmio_region->end)) {
 		return ioc->mmio_region;
-	} else {
+	} else if (((ioc->mmio_region + 1)->start <= dev->hpa) &&
+			(dev->hpa < (ioc->mmio_region + 1)->end)) {
 		return ioc->mmio_region + 1;
+	} else {
+		return NULL;
 	}
 }
 
+int ccio_allocate_resource(const struct parisc_device *dev,
+		struct resource *res, unsigned long size,
+		unsigned long min, unsigned long max, unsigned long align,
+		void (*alignf)(void *, struct resource *, unsigned long),
+		void *alignf_data)
+{
+	struct ioc *ioc = ccio_get_iommu(dev);
+	struct resource *parent = ccio_get_resource(ioc, dev);
+	if (!parent)
+		return -EBUSY;
+
+	if (!allocate_resource(parent, res, size, min, max, align, alignf,
+			alignf_data))
+		return 0;
+
+	expand_ioc_area(ioc, size, min, max, align);
+	return allocate_resource(parent, res, size, min, max, align, alignf,
+			alignf_data);
+}
 
+int ccio_request_resource(const struct parisc_device *dev,
+		struct resource *res)
+{
+	struct ioc *ioc = ccio_get_iommu(dev);
+	struct resource *parent = ccio_get_resource(ioc, dev);
+
+	return request_resource(parent, res);
+}
 /**
  * ccio_probe - Determine if ccio should claim this device.
  * @dev: The device which has been found
Index: arch/parisc/kernel/drivers.c
===================================================================
RCS file: /var/cvs/linux/arch/parisc/kernel/drivers.c,v
retrieving revision 1.44
diff -u -p -r1.44 drivers.c
--- arch/parisc/kernel/drivers.c	2002/02/14 06:40:46	1.44
+++ arch/parisc/kernel/drivers.c	2002/02/28 07:07:37
@@ -204,7 +204,7 @@ static struct parisc_device *find_device
  * Walks up the device tree looking for a device of the specified type.
  * If it finds it, it returns it.  If not, it returns NULL.
  */
-struct parisc_device *find_pa_parent_type(struct parisc_device *dev, int type)
+struct parisc_device *find_pa_parent_type(const struct parisc_device *dev, int type)
 {
 	while (dev != &root) {
 		if (dev->id.hw_type == type)
Index: drivers/gsc/dino.c
===================================================================
RCS file: /var/cvs/linux/drivers/gsc/dino.c,v
retrieving revision 1.58
diff -u -p -r1.58 dino.c
--- drivers/gsc/dino.c	2002/02/14 06:39:47	1.58
+++ drivers/gsc/dino.c	2002/02/28 07:07:37
@@ -472,17 +472,14 @@ dino_card_setup(struct pci_bus *bus, uns
 {
 	int i;
 	struct dino_device *dino_dev = DINO_DEV(bus->sysdata);
-	struct resource *res, *parent_resource;
+	struct resource *res;
 
 	res = &dino_dev->hba.lmmio_space;
 	res->flags = IORESOURCE_MEM;
 
-#ifdef NASTY_HACK_FOR_K_CLASS
-	ccio_extend_mmio_range(dino_dev->hba.iommu);
-#endif
-	parent_resource = ccio_find_parisc_resource(dino_dev->hba.dev);
-	if (allocate_resource(parent_resource, res, _8MB, 0xf0000000 | _8MB,
-			      0xffffffff &~ _8MB, _8MB, NULL, NULL) < 0) {
+	if (ccio_allocate_resource(dino_dev->hba.dev, res, _8MB,
+				0xf0000000 | _8MB, 0xffffffff &~ _8MB, _8MB,
+				NULL, NULL) < 0) {
 		printk(KERN_WARNING "Dino: Failed to allocate memory region\n");
 		return;
 	}
@@ -662,7 +659,7 @@ dino_bridge_init(struct dino_device *din
 {
 	unsigned long io_addr;
 	int bpos, result;
-	struct resource *res, *parent_resource;
+	struct resource *res;
 	/*
 	 * Decoding IO_ADDR_EN only works for Built-in Dino
 	 * since PDC has already initialized this.
@@ -682,8 +679,7 @@ dino_bridge_init(struct dino_device *din
 	res->start = (unsigned long) 0xfffffffff0000000 | bpos << 23;
 	res->end = res->start + 8 * 1024 * 1024 - 1;
 
-	parent_resource = ccio_find_parisc_resource(dino_dev->hba.dev);
-	result = request_resource(parent_resource, res);
+	result = ccio_request_resource(dino_dev->hba.dev, res);
 	if (result < 0) {
 		printk(KERN_ERR "%s: failed to claim PCI Bus address space!\n", name);
 		return result;
Index: drivers/gsc/eisa.c
===================================================================
RCS file: /var/cvs/linux/drivers/gsc/eisa.c,v
retrieving revision 1.16
diff -u -p -r1.16 eisa.c
--- drivers/gsc/eisa.c	2002/02/24 16:34:43	1.16
+++ drivers/gsc/eisa.c	2002/02/28 07:07:37
@@ -317,7 +317,6 @@ static void init_eisa_pic(void)
 static int __devinit eisa_probe(struct parisc_device *dev)
 {
 	int result;
-	struct resource *parent_resource;
 
 	char *name = is_mongoose(dev) ? "Mongoose" : "Wax";
 
@@ -326,13 +325,12 @@ static int __devinit eisa_probe(struct p
 
 	eisa_dev.hba.dev = dev;
 	eisa_dev.hba.iommu = ccio_get_iommu(dev);
-	parent_resource = ccio_find_parisc_resource(eisa_dev.hba.dev);
 
 	eisa_dev.hba.lmmio_space.name = "EISA";
 	eisa_dev.hba.lmmio_space.start = (unsigned long) 0xfffffffffc000000;
 	eisa_dev.hba.lmmio_space.end = (unsigned long) 0xffffffffffbfffff;
 	eisa_dev.hba.lmmio_space.flags = IORESOURCE_MEM;
-	result = request_resource(parent_resource, &eisa_dev.hba.lmmio_space);
+	result = ccio_request_resource(dev, &eisa_dev.hba.lmmio_space);
 	if (result < 0) {
 		printk(KERN_ERR "EISA: failed to claim EISA Bus address space!\n");
 		return result;
Index: include/asm-parisc/hardware.h
===================================================================
RCS file: /var/cvs/linux/include/asm-parisc/hardware.h,v
retrieving revision 1.35
diff -u -p -r1.35 hardware.h
--- include/asm-parisc/hardware.h	2002/02/09 06:46:24	1.35
+++ include/asm-parisc/hardware.h	2002/02/28 07:07:37
@@ -144,7 +144,7 @@ extern void walk_central_bus(void);
 extern void fixup_child_irqs(struct parisc_device *parent, int irqbase,
 		int (*choose)(struct parisc_device *parent));
 extern void print_subdevices(struct parisc_device *dev);
-extern struct parisc_device *find_pa_parent_type(struct parisc_device *, int);
+extern struct parisc_device *find_pa_parent_type(const struct parisc_device *, int);
 extern void print_parisc_devices(void);
 extern char *print_pa_hwpath(struct parisc_device *dev, char *path);
 extern char *print_pci_hwpath(struct pci_dev *dev, char *path);
Index: include/asm-parisc/pci.h
===================================================================
RCS file: /var/cvs/linux/include/asm-parisc/pci.h,v
retrieving revision 1.46
diff -u -p -r1.46 pci.h
--- include/asm-parisc/pci.h	2002/02/26 00:45:42	1.46
+++ include/asm-parisc/pci.h	2002/02/28 07:07:37
@@ -267,13 +267,20 @@ struct parisc_device;
 struct ioc;
 void * ccio_get_iommu(const struct parisc_device *dev);
 struct pci_dev * ccio_get_fake(const struct parisc_device *dev);
-void ccio_extend_mmio_range(struct ioc *ioc);
-struct resource * ccio_find_parisc_resource(const struct parisc_device *dev);
+int ccio_request_resource(const struct parisc_device *dev,
+		struct resource *res);
+int ccio_allocate_resource(const struct parisc_device *dev,
+		struct resource *res, unsigned long size,
+		unsigned long min, unsigned long max, unsigned long align,
+		void (*alignf)(void *, struct resource *, unsigned long),
+		void *alignf_data);
 #else /* !CONFIG_IOMMU_CCIO */
 #define ccio_get_iommu(dev) NULL
 #define ccio_get_fake(dev) NULL
-#define ccio_extend_mmio_range(ioc) do { } while (0)
-#define ccio_find_parisc_resource(x) &iomem_resource
+#define ccio_request_resource(dev, res) request_resource(&iomem_resource, res)
+#define ccio_allocate_resource(dev, res, size, min, max, align, alignf, data) \
+		allocate_resource(&iomem_resource, res, size, min, max, \
+				align, alignf, data)
 #endif /* !CONFIG_IOMMU_CCIO */
 
 #ifdef CONFIG_IOMMU_SBA
-- 
Revolutions do not require corporate support.