[parisc-linux-cvs] ccio & dino naming changes
Matthew Wilcox
willy@ldl.fc.hp.com
Fri, 8 Feb 2002 23:50:23 -0700 (MST)
* -pa22
* remove compile warnings from ccio
* change ccio naming in proc/iomem
* fix out-by-one error in ccio_find_parisc_resource
* replace ccio_find_ioa with calls to find_pa_parent_type
* docbook find_pa_parent_type
* replace a few `Dino:' with `%s:' and print Dino/Cujo as appropriate.
Index: arch/parisc/kernel/ccio-dma.c
===================================================================
RCS file: /var/cvs/linux/arch/parisc/kernel/ccio-dma.c,v
retrieving revision 1.50
diff -u -p -r1.50 ccio-dma.c
--- arch/parisc/kernel/ccio-dma.c 2002/01/13 16:01:17 1.50
+++ arch/parisc/kernel/ccio-dma.c 2002/02/09 06:39:59
@@ -159,7 +159,6 @@ struct ioc {
u32 pdir_size; /* in bytes, determined by IOV Space size */
u32 chainid_shift; /* specify bit location of chain_id */
struct ioc *next; /* Linked list of discovered iocs */
- struct parisc_device_id *iodc; /* data about dev from firmware */
const char *name; /* device name from firmware */
unsigned int hw_path; /* the hardware path this ioc is associatd with */
struct pci_dev *fake_pci_dev; /* the fake pci_dev for non-pci devs */
@@ -644,7 +643,7 @@ ccio_map_single(struct pci_dev *dev, voi
ASSERT(size > 0);
/* save offset bits */
- offset = ((dma_addr_t) addr) & ~IOVP_MASK;
+ offset = ((unsigned long) addr) & ~IOVP_MASK;
/* round up to nearest IOVP_SIZE */
size = ROUNDUP(size + offset, IOVP_SIZE);
@@ -1120,7 +1119,7 @@ static int ccio_proc_info(char *buf, cha
break;
len = sprintf(tmp, "IO PDIR size : %d bytes (%d entries)\n",
- ((ioc->res_size << 3) * sizeof(u64)), total_pages);
+ total_pages * 8, total_pages);
if (proc_append(tmp, len, &buf, &offset, &count))
break;
@@ -1131,7 +1130,7 @@ static int ccio_proc_info(char *buf, cha
break;
len = sprintf(tmp, "Resource bitmap : %d bytes (%d pages)\n",
- ioc->res_size, ioc->res_size << 3);
+ ioc->res_size, total_pages);
if (proc_append(tmp, len, &buf, &offset, &count))
break;
@@ -1209,8 +1208,46 @@ static int ccio_resource_map(char *buf,
}
#endif
+/**
+ * ccio_find_ioc - Find the ioc in the ioc_list
+ * @hw_path: The hardware path of the ioc.
+ *
+ * This function searches the ioc_list for an ioc that matches
+ * the provide hardware path.
+ */
+static struct ioc * ccio_find_ioc(int hw_path)
+{
+ int i;
+ struct ioc *ioc;
+
+ ioc = ioc_list;
+ for (i = 0; i < ioc_count; i++) {
+ if (ioc->hw_path == hw_path)
+ return ioc;
+
+ ioc = ioc->next;
+ }
+
+ return NULL;
+}
+
+/**
+ * ccio_get_iommu - Find the iommu which controls this device
+ * @dev: The parisc device.
+ *
+ * This function searches through the registerd IOMMU's and returns the
+ * appropriate IOMMU for the device based upon the devices hardware path.
+ */
+void * ccio_get_iommu(const struct parisc_device *dev)
+{
+ dev = find_pa_parent_type(dev, HPHW_IOA);
+ if (!dev)
+ return NULL;
+
+ return ccio_find_ioc(dev->hw_path);
+}
+
#define CUJO_20_STEP 0x10000000 /* inc upper nibble */
-void * ccio_get_iommu(struct parisc_device *dev);
/* Cujo 2.0 has a bug which will silently corrupt data being transferred
* to/from certain pages. To avoid this happening, we mark these pages
@@ -1390,7 +1427,8 @@ ccio_ioc_init(struct ioc *ioc)
}
}
-static int ccio_init_resource(struct resource *res, unsigned long ioaddr)
+static void
+ccio_init_resource(struct resource *res, char *name, unsigned long ioaddr)
{
int result;
@@ -1398,32 +1436,26 @@ static int ccio_init_resource(struct res
res->start = (unsigned long)(signed) __raw_readl(ioaddr) << 16;
res->end = (unsigned long)(signed) (__raw_readl(ioaddr + 4) << 16) - 1;
if (res->end < res->start)
- return 0;
+ return;
+ res->name = name;
result = request_resource(&iomem_resource, res);
if (result < 0) {
printk(KERN_ERR
"%s: failed to claim CCIO bus address space!\n",
__FILE__);
- return 0;
}
- return 1;
}
static void __init ccio_init_resources(struct ioc *ioc)
{
struct resource *res = ioc->mmio_region;
- if (ccio_init_resource(res, (unsigned long)&ioc->ioc_hpa->io_io_low)) {
- char *name = kmalloc(17, GFP_KERNEL);
- sprintf(name, "GSC Bus %d Primary", ioc_count);
- res->name = name;
- }
+ char *name = kmalloc(14, GFP_KERNEL);
- res++;
- if (ccio_init_resource(res, (unsigned long)&ioc->ioc_hpa->io_io_low_hv)) {
- char *name = kmalloc(19, GFP_KERNEL);
- sprintf(name, "GSC Bus %d Secondary", ioc_count);
- res->name = name;
- }
+ sprintf(name, "GSC Bus [%d/]", ioc->hw_path);
+
+ ccio_init_resource(res, name, (unsigned long)&ioc->ioc_hpa->io_io_low);
+ ccio_init_resource(res + 1, name,
+ (unsigned long)&ioc->ioc_hpa->io_io_low_hv);
}
#ifdef NASTY_HACK_FOR_K_CLASS
@@ -1434,13 +1466,13 @@ void ccio_extend_mmio_range(struct ioc *
}
#endif
-struct resource * ccio_find_parisc_resource(struct parisc_device *dev)
+struct resource * ccio_find_parisc_resource(const struct parisc_device *dev)
{
struct ioc *ioc = ccio_get_iommu(dev);
if (!ioc)
return &iomem_resource;
- if ((ioc->mmio_region->start < dev->hpa) &&
+ if ((ioc->mmio_region->start <= dev->hpa) &&
(dev->hpa < ioc->mmio_region->end)) {
return ioc->mmio_region;
} else {
@@ -1468,17 +1500,16 @@ static int ccio_probe(struct parisc_devi
return 1;
}
memset(ioc, 0, sizeof(struct ioc));
+
+ ioc->name = dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn";
- printk(KERN_INFO MODULE_NAME " found %s at 0x%lx\n",
- dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn", dev->hpa);
+ printk(KERN_INFO "Found %s at 0x%lx\n", ioc->name, dev->hpa);
for (i = 0; i < ioc_count; i++) {
ioc_p = &(*ioc_p)->next;
}
*ioc_p = ioc;
- ioc->iodc = &dev->id;
- ioc->name = dev->name;
ioc->hw_path = dev->hw_path;
ioc->ioc_hpa = (struct ioa_registers *)dev->hpa;
ccio_ioc_init(ioc);
@@ -1496,71 +1527,12 @@ static int ccio_probe(struct parisc_devi
ioc_count++;
return 0;
}
-
-/**
- * ccio_find_ioa - Find the ioa device in the hardware path
- * @dev: The parisc device.
- *
- * This function searches up the hardware path and returns the device
- * containing the ccio device. [Note maybe this function should be
- * more generic and provided as part of the iotree infrastructure?].
- */
-static struct parisc_device * ccio_find_ioa(struct parisc_device *dev)
-{
- while(dev) {
- if(dev->id.hw_type == HPHW_IOA)
- return dev;
-
- dev = dev->parent;
- }
-
- return NULL;
-}
-
-/**
- * ccio_find_ioc - Find the ioc in the ioc_list
- * @hw_path: The hardware path of the ioc.
- *
- * This function searches the ioc_list for an ioc that matches
- * the provide hardware path.
- */
-static struct ioc * ccio_find_ioc(int hw_path)
-{
- int i;
- struct ioc *ioc;
-
- ioc = ioc_list;
- for (i = 0; i < ioc_count; i++) {
- if(ioc->hw_path == hw_path)
- return ioc;
-
- ioc = ioc->next;
- }
-
- return NULL;
-}
-
-/**
- * ccio_get_iommu - Find the iommu which controls this device
- * @dev: The parisc device.
- *
- * This function searches through the registerd IOMMU's and returns the
- * appropriate IOMMU for the device based upon the devices hardware path.
- */
-void * ccio_get_iommu(struct parisc_device *dev)
-{
- dev = ccio_find_ioa(dev);
- if (!dev)
- return NULL;
-
- return ccio_find_ioc(dev->hw_path);
-}
-struct pci_dev * ccio_get_fake(struct parisc_device *dev)
+struct pci_dev * ccio_get_fake(const struct parisc_device *dev)
{
struct ioc *ioc;
- dev = ccio_find_ioa(dev);
+ dev = find_pa_parent_type(dev, HPHW_IOA);
if(!dev)
return NULL;
Index: arch/parisc/kernel/drivers.c
===================================================================
RCS file: /var/cvs/linux/arch/parisc/kernel/drivers.c,v
retrieving revision 1.41
diff -u -p -r1.41 drivers.c
--- arch/parisc/kernel/drivers.c 2002/02/05 23:53:21 1.41
+++ arch/parisc/kernel/drivers.c 2002/02/09 06:39:59
@@ -197,13 +197,21 @@ static struct parisc_device *find_device
return NULL;
}
+/**
+ * find_pa_parent_type - Find a parent of a specific type
+ * @dev: The device to start searching from
+ * @type: The device type to search for.
+ *
+ * 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)
{
- do {
- dev = dev->parent;
+ while (dev != &root) {
if (dev->id.hw_type == type)
return dev;
- } while (dev != &root);
+ dev = dev->parent;
+ }
return NULL;
}
Index: drivers/gsc/dino.c
===================================================================
RCS file: /var/cvs/linux/drivers/gsc/dino.c,v
retrieving revision 1.55
diff -u -p -r1.55 dino.c
--- drivers/gsc/dino.c 2002/02/02 15:25:14 1.55
+++ drivers/gsc/dino.c 2002/02/09 06:40:00
@@ -658,7 +658,7 @@ dino_card_init(struct dino_device *dino_
}
static int __init
-dino_bridge_init(struct dino_device *dino_dev)
+dino_bridge_init(struct dino_device *dino_dev, const char *name)
{
unsigned long io_addr;
int bpos, result;
@@ -670,7 +670,7 @@ dino_bridge_init(struct dino_device *din
io_addr = gsc_readl(dino_dev->hba.base_addr + DINO_IO_ADDR_EN);
if (io_addr == 0) {
- printk(KERN_WARNING "Dino: No PCI devices enabled.\n");
+ printk(KERN_WARNING "%s: No PCI devices enabled.\n", name);
return -ENODEV;
}
@@ -685,7 +685,7 @@ dino_bridge_init(struct dino_device *din
parent_resource = ccio_find_parisc_resource(dino_dev->hba.dev);
result = request_resource(parent_resource, res);
if (result < 0) {
- printk(KERN_ERR "Dino: failed to claim PCI Bus address space!\n");
+ printk(KERN_ERR "%s: failed to claim PCI Bus address space!\n", name);
return result;
}
@@ -886,7 +886,7 @@ dino_driver_callback(struct parisc_devic
if (is_card_dino(&dev->id)) {
dino_card_init(dino_dev);
} else {
- dino_bridge_init(dino_dev);
+ dino_bridge_init(dino_dev, name);
}
if (dino_common_init(dev, dino_dev))
Index: include/asm-parisc/hardware.h
===================================================================
RCS file: /var/cvs/linux/include/asm-parisc/hardware.h,v
retrieving revision 1.34
diff -u -p -r1.34 hardware.h
--- include/asm-parisc/hardware.h 2002/01/30 08:14:47 1.34
+++ include/asm-parisc/hardware.h 2002/02/09 06:40:00
@@ -144,6 +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 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.44
diff -u -p -r1.44 pci.h
--- include/asm-parisc/pci.h 2002/02/04 19:29:43 1.44
+++ include/asm-parisc/pci.h 2002/02/09 06:40:00
@@ -251,10 +251,10 @@ extern inline void pcibios_register_hba(
#ifdef CONFIG_IOMMU_CCIO
struct parisc_device;
struct ioc;
-void * ccio_get_iommu(struct parisc_device *dev);
-struct pci_dev * ccio_get_fake(struct parisc_device *dev);
+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(struct parisc_device *dev);
+struct resource * ccio_find_parisc_resource(const struct parisc_device *dev);
#else /* !CONFIG_IOMMU_CCIO */
#define ccio_get_iommu(dev) NULL
#define ccio_get_fake(dev) NULL