* [2.6 PATCH] Altix update
@ 2004-02-18 14:41 Pat Gefre
2004-02-18 17:06 ` Christoph Hellwig
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Pat Gefre @ 2004-02-18 14:41 UTC (permalink / raw)
To: akpm, davidm; +Cc: linux-kernel, linux-ia64
Andrew,
Here's a small mod for Altix. It breaks up our 'pci fixup' function and
has some other smallish clean ups.
For the ia64 crowd I've added 'platform_data' back into
include/asm-ia64/pci.h
Can you take this ?
Thanks,
-- Pat
diffstat:
arch/ia64/sn/io/machvec/pci_bus_cvlink.c | 411 ++++++++++++++++++-------------
arch/ia64/sn/io/machvec/pci_dma.c | 6
arch/ia64/sn/io/sn2/pic.c | 8
include/asm-ia64/pci.h | 2
include/asm-ia64/sn/pci/pci_bus_cvlink.h | 14 -
5 files changed, 270 insertions(+), 171 deletions(-)
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1558 -> 1.1559
# arch/ia64/sn/io/machvec/pci_dma.c 1.24 -> 1.25
# arch/ia64/sn/io/sn2/pic.c 1.14 -> 1.15
# arch/ia64/sn/io/machvec/pci_bus_cvlink.c 1.31 -> 1.32
# include/asm-ia64/pci.h 1.21 -> 1.22
# include/asm-ia64/sn/pci/pci_bus_cvlink.h 1.12 -> 1.13
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/02/05 pfg@sgi.com 1.1559
# arch/ia64/sn/io/machvec/pci_bus_cvlink.c
# Re-orged sn_pci_fixup()
# sn_dma_flush_init return added - not a void any longer
# arch/ia64/sn/io/machvec/pci_dma.c
# Wrap references to sysdata in SN_DEVICE_SYSDATA() macro
# arch/ia64/sn/io/sn2/pic.c
# Some more oom checks
# include/asm-ia64/pci.h
# Add platform_data
# include/asm-ia64/sn/pci/pci_bus_cvlink.h
# New data struct elements
# Removed PCIBUS_VERTEX
# --------------------------------------------
#
diff -Nru a/arch/ia64/sn/io/machvec/pci_bus_cvlink.c b/arch/ia64/sn/io/machvec/pci_bus_cvlink.c
--- a/arch/ia64/sn/io/machvec/pci_bus_cvlink.c Thu Feb 5 10:17:40 2004
+++ b/arch/ia64/sn/io/machvec/pci_bus_cvlink.c Thu Feb 5 10:17:40 2004
@@ -28,7 +28,7 @@
extern void register_pcibr_intr(int irq, pcibr_intr_t intr);
-static void sn_dma_flush_init(unsigned long start,
+static struct sn_flush_device_list *sn_dma_flush_init(unsigned long start,
unsigned long end,
int idx, int pin, int slot);
extern int cbrick_type_get_nasid(nasid_t);
@@ -156,6 +156,231 @@
return(device_vertex);
}
+/*
+ * sn_alloc_pci_sysdata() - This routine allocates a pci controller
+ * which is expected as the pci_dev and pci_bus sysdata by the Linux
+ * PCI infrastructure.
+ */
+struct pci_controller *
+sn_alloc_pci_sysdata(void)
+{
+ struct pci_controller *pci_sysdata;
+
+ pci_sysdata = kmalloc(sizeof(*pci_sysdata), GFP_KERNEL);
+ if (!pci_sysdata)
+ return NULL;
+
+ memset(pci_sysdata, 0, sizeof(*pci_sysdata));
+ return pci_sysdata;
+}
+
+/*
+ * sn_pci_fixup_bus() - This routine sets up a bus's resources
+ * consistent with the Linux PCI abstraction layer.
+ */
+static int __init
+sn_pci_fixup_bus(struct pci_bus *bus)
+{
+ struct pci_controller *pci_sysdata;
+ struct sn_widget_sysdata *widget_sysdata;
+
+ pci_sysdata = sn_alloc_pci_sysdata();
+ if (!pci_sysdata) {
+ printk(KERN_WARNING "sn_pci_fixup_bus(): Unable to "
+ "allocate memory for pci_sysdata\n");
+ return -ENOMEM;
+ }
+ widget_sysdata = kmalloc(sizeof(struct sn_widget_sysdata),
+ GFP_KERNEL);
+ if (!widget_sysdata) {
+ printk(KERN_WARNING "sn_pci_fixup_bus(): Unable to "
+ "allocate memory for widget_sysdata\n");
+ return -ENOMEM;
+ }
+
+ widget_sysdata->vhdl = pci_bus_to_vertex(bus->number);
+ pci_sysdata->platform_data = (void *)widget_sysdata;
+ bus->sysdata = pci_sysdata;
+ return 0;
+}
+
+
+/*
+ * sn_pci_fixup_slot() - This routine sets up a slot's resources
+ * consistent with the Linux PCI abstraction layer. Resources acquired
+ * from our PCI provider include PIO maps to BAR space and interrupt
+ * objects.
+ */
+static int
+sn_pci_fixup_slot(struct pci_dev *dev)
+{
+ extern int bit_pos_to_irq(int);
+ unsigned int irq;
+ int idx;
+ u16 cmd;
+ vertex_hdl_t vhdl;
+ unsigned long size;
+ struct pci_controller *pci_sysdata;
+ struct sn_device_sysdata *device_sysdata;
+ pciio_intr_line_t lines = 0;
+ vertex_hdl_t device_vertex;
+ pciio_provider_t *pci_provider;
+ pciio_intr_t intr_handle;
+
+ /* Allocate a controller structure */
+ pci_sysdata = sn_alloc_pci_sysdata();
+ if (!pci_sysdata) {
+ printk(KERN_WARNING "sn_pci_fixup_slot: Unable to "
+ "allocate memory for pci_sysdata\n");
+ return -ENOMEM;
+ }
+
+ /* Set the device vertex */
+ device_sysdata = kmalloc(sizeof(struct sn_device_sysdata), GFP_KERNEL);
+ if (!device_sysdata) {
+ printk(KERN_WARNING "sn_pci_fixup_slot: Unable to "
+ "allocate memory for device_sysdata\n");
+ return -ENOMEM;
+ }
+
+ device_sysdata->vhdl = devfn_to_vertex(dev->bus->number, dev->devfn);
+ pci_sysdata->platform_data = (void *) device_sysdata;
+ dev->sysdata = pci_sysdata;
+ set_pci_provider(device_sysdata);
+
+ pci_read_config_word(dev, PCI_COMMAND, &cmd);
+
+ /*
+ * Set the resources address correctly. The assumption here
+ * is that the addresses in the resource structure has been
+ * read from the card and it was set in the card by our
+ * Infrastructure. NOTE: PIC and TIOCP don't have big-window
+ * upport for PCI I/O space. So by mapping the I/O space
+ * first we will attempt to use Device(x) registers for I/O
+ * BARs (which can't use big windows like MEM BARs can).
+ */
+ vhdl = device_sysdata->vhdl;
+
+ /* Allocate the IORESOURCE_IO space first */
+ for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
+ unsigned long start, end, addr;
+
+ device_sysdata->pio_map[idx] = NULL;
+
+ if (!(dev->resource[idx].flags & IORESOURCE_IO))
+ continue;
+
+ start = dev->resource[idx].start;
+ end = dev->resource[idx].end;
+ size = end - start;
+ if (!size)
+ continue;
+
+ addr = (unsigned long)pciio_pio_addr(vhdl, 0,
+ PCIIO_SPACE_WIN(idx), 0, size,
+ &device_sysdata->pio_map[idx], 0);
+
+ if (!addr) {
+ dev->resource[idx].start = 0;
+ dev->resource[idx].end = 0;
+ printk("sn_pci_fixup(): pio map failure for "
+ "%s bar%d\n", dev->slot_name, idx);
+ } else {
+ addr |= __IA64_UNCACHED_OFFSET;
+ dev->resource[idx].start = addr;
+ dev->resource[idx].end = addr + size;
+ }
+
+ if (dev->resource[idx].flags & IORESOURCE_IO)
+ cmd |= PCI_COMMAND_IO;
+ }
+
+ /* Allocate the IORESOURCE_MEM space next */
+ for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
+ unsigned long start, end, addr;
+
+ if ((dev->resource[idx].flags & IORESOURCE_IO))
+ continue;
+
+ start = dev->resource[idx].start;
+ end = dev->resource[idx].end;
+ size = end - start;
+ if (!size)
+ continue;
+
+ addr = (unsigned long)pciio_pio_addr(vhdl, 0,
+ PCIIO_SPACE_WIN(idx), 0, size,
+ &device_sysdata->pio_map[idx], 0);
+
+ if (!addr) {
+ dev->resource[idx].start = 0;
+ dev->resource[idx].end = 0;
+ printk("sn_pci_fixup(): pio map failure for "
+ "%s bar%d\n", dev->slot_name, idx);
+ } else {
+ addr |= __IA64_UNCACHED_OFFSET;
+ dev->resource[idx].start = addr;
+ dev->resource[idx].end = addr + size;
+ }
+
+ if (dev->resource[idx].flags & IORESOURCE_MEM)
+ cmd |= PCI_COMMAND_MEMORY;
+ }
+
+ /*
+ * Update the Command Word on the Card.
+ */
+ cmd |= PCI_COMMAND_MASTER; /* If the device doesn't support */
+ /* bit gets dropped .. no harm */
+ pci_write_config_word(dev, PCI_COMMAND, cmd);
+
+ pci_read_config_byte(dev, PCI_INTERRUPT_PIN, (unsigned char *)&lines);
+ device_vertex = device_sysdata->vhdl;
+ pci_provider = device_sysdata->pci_provider;
+ device_sysdata->intr_handle = NULL;
+
+ if (!lines)
+ return 0;
+
+ irqpdaindr->curr = dev;
+
+ intr_handle = (pci_provider->intr_alloc)(device_vertex, NULL, lines, device_vertex);
+ if (intr_handle = NULL) {
+ printk(KERN_WARNING "sn_pci_fixup: pcibr_intr_alloc() failed\n");
+ return -ENOMEM;
+ }
+
+ device_sysdata->intr_handle = intr_handle;
+ irq = intr_handle->pi_irq;
+ irqpdaindr->device_dev[irq] = dev;
+ (pci_provider->intr_connect)(intr_handle, (intr_func_t)0, (intr_arg_t)0);
+ dev->irq = irq;
+
+ register_pcibr_intr(irq, (pcibr_intr_t)intr_handle);
+
+ for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
+ int ibits = ((pcibr_intr_t)intr_handle)->bi_ibits;
+ int i;
+
+ size = dev->resource[idx].end -
+ dev->resource[idx].start;
+ if (size = 0) continue;
+
+ for (i=0; i<8; i++) {
+ if (ibits & (1 << i) ) {
+ extern pcibr_info_t pcibr_info_get(vertex_hdl_t);
+ device_sysdata->dma_flush_list + sn_dma_flush_init(dev->resource[idx].start,
+ dev->resource[idx].end,
+ idx,
+ i,
+ PCIBR_INFO_SLOT_GET_EXT(pcibr_info_get(device_sysdata->vhdl)));
+ }
+ }
+ }
+ return 0;
+}
+
struct sn_flush_nasid_entry flush_nasid_list[MAX_NASIDS];
/* Initialize the data structures for flushing write buffers after a PIO read.
@@ -165,7 +390,7 @@
* on the in use pin. This will prevent the race condition between PIO read responses and
* DMA writes.
*/
-static void
+static struct sn_flush_device_list *
sn_dma_flush_init(unsigned long start, unsigned long end, int idx, int pin, int slot)
{
nasid_t nasid;
@@ -187,7 +412,7 @@
sizeof(struct sn_flush_device_list *), GFP_KERNEL);
if (!flush_nasid_list[nasid].widget_p) {
printk(KERN_WARNING "sn_dma_flush_init: Cannot allocate memory for nasid list\n");
- return;
+ return NULL;
}
memset(flush_nasid_list[nasid].widget_p, 0, (HUB_WIDGET_ID_MAX+1) * sizeof(struct sn_flush_device_list *));
}
@@ -211,14 +436,14 @@
* because these are the IOC4 slots and we don't flush them.
*/
if (isIO9(nasid) && bus = 0 && (slot = 1 || slot = 4)) {
- return;
+ return NULL;
}
if (flush_nasid_list[nasid].widget_p[wid_num] = NULL) {
flush_nasid_list[nasid].widget_p[wid_num] = (struct sn_flush_device_list *)kmalloc(
DEV_PER_WIDGET * sizeof (struct sn_flush_device_list), GFP_KERNEL);
if (!flush_nasid_list[nasid].widget_p[wid_num]) {
printk(KERN_WARNING "sn_dma_flush_init: Cannot allocate memory for nasid sub-list\n");
- return;
+ return NULL;
}
memset(flush_nasid_list[nasid].widget_p[wid_num], 0,
DEV_PER_WIDGET * sizeof (struct sn_flush_device_list));
@@ -303,6 +528,7 @@
((virt_to_phys(&p->flush_addr) & 0xfffffffff) |
(dnasid << 36) | (0xfUL << 48)));
}
+ return p;
}
/*
@@ -317,15 +543,9 @@
{
struct list_head *ln;
struct pci_bus *pci_bus = NULL;
- struct pci_dev *device_dev = NULL;
- struct sn_widget_sysdata *widget_sysdata;
- struct sn_device_sysdata *device_sysdata;
- pcibr_intr_t intr_handle;
- pciio_provider_t *pci_provider;
- vertex_hdl_t device_vertex;
- pciio_intr_line_t lines = 0;
+ struct pci_dev *pci_dev = NULL;
extern int numnodes;
- int cnode;
+ int cnode, ret;
if (arg = 0) {
#ifdef CONFIG_PROC_FS
@@ -333,9 +553,9 @@
#endif
extern void sgi_master_io_infr_init(void);
extern void sn_init_cpei_timer(void);
-
+
sgi_master_io_infr_init();
-
+
for (cnode = 0; cnode < numnodes; cnode++) {
extern void intr_init_vecblk(cnodeid_t);
intr_init_vecblk(cnode);
@@ -349,23 +569,20 @@
return;
}
-
done_probing = 1;
/*
* Initialize the pci bus vertex in the pci_bus struct.
*/
- for( ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
+ for( ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
pci_bus = pci_bus_b(ln);
- widget_sysdata = kmalloc(sizeof(struct sn_widget_sysdata),
- GFP_KERNEL);
- if (!widget_sysdata) {
- printk(KERN_WARNING "sn_pci_fixup(): Unable to "
- "allocate memory for widget_sysdata\n");
+ ret = sn_pci_fixup_bus(pci_bus);
+ if ( ret ) {
+ printk(KERN_WARNING
+ "sn_pci_fixup: sn_pci_fixup_bus fails : error %d\n",
+ ret);
return;
- }
- widget_sysdata->vhdl = pci_bus_to_vertex(pci_bus->number);
- pci_bus->sysdata = (void *)widget_sysdata;
+ }
}
/*
@@ -389,146 +606,14 @@
/*
* Initialize the device vertex in the pci_dev struct.
*/
- while ((device_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, device_dev)) != NULL) {
- unsigned int irq;
- int idx;
- u16 cmd;
- vertex_hdl_t vhdl;
- unsigned long size;
- extern int bit_pos_to_irq(int);
-
- /* Set the device vertex */
-
- device_sysdata = kmalloc(sizeof(struct sn_device_sysdata),
- GFP_KERNEL);
- if (!device_sysdata) {
- printk(KERN_WARNING "sn_pci_fixup: Cannot allocate memory for device sysdata\n");
+ while ((pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) != NULL) {
+ ret = sn_pci_fixup_slot(pci_dev);
+ if ( ret ) {
+ printk(KERN_WARNING
+ "sn_pci_fixup: sn_pci_fixup_slot fails : error %d\n",
+ ret);
return;
}
-
- device_sysdata->vhdl = devfn_to_vertex(device_dev->bus->number, device_dev->devfn);
- device_dev->sysdata = (void *) device_sysdata;
- set_pci_provider(device_sysdata);
-
- pci_read_config_word(device_dev, PCI_COMMAND, &cmd);
-
- /*
- * Set the resources address correctly. The assumption here
- * is that the addresses in the resource structure has been
- * read from the card and it was set in the card by our
- * Infrastructure ..
- */
- vhdl = device_sysdata->vhdl;
- /* Allocate the IORESOURCE_IO space first */
- for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
- unsigned long start, end, addr;
-
- if (!(device_dev->resource[idx].flags & IORESOURCE_IO))
- continue;
-
- start = device_dev->resource[idx].start;
- end = device_dev->resource[idx].end;
- size = end - start;
- if (!size)
- continue;
-
- addr = (unsigned long)pciio_pio_addr(vhdl, 0,
- PCIIO_SPACE_WIN(idx), 0, size, 0, 0);
- if (!addr) {
- device_dev->resource[idx].start = 0;
- device_dev->resource[idx].end = 0;
- printk("sn_pci_fixup(): pio map failure for "
- "%s bar%d\n", device_dev->slot_name, idx);
- } else {
- addr |= __IA64_UNCACHED_OFFSET;
- device_dev->resource[idx].start = addr;
- device_dev->resource[idx].end = addr + size;
- }
-
- if (device_dev->resource[idx].flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- }
-
- /* Allocate the IORESOURCE_MEM space next */
- for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
- unsigned long start, end, addr;
-
- if ((device_dev->resource[idx].flags & IORESOURCE_IO))
- continue;
-
- start = device_dev->resource[idx].start;
- end = device_dev->resource[idx].end;
- size = end - start;
- if (!size)
- continue;
-
- addr = (unsigned long)pciio_pio_addr(vhdl, 0,
- PCIIO_SPACE_WIN(idx), 0, size, 0, 0);
- if (!addr) {
- device_dev->resource[idx].start = 0;
- device_dev->resource[idx].end = 0;
- printk("sn_pci_fixup(): pio map failure for "
- "%s bar%d\n", device_dev->slot_name, idx);
- } else {
- addr |= __IA64_UNCACHED_OFFSET;
- device_dev->resource[idx].start = addr;
- device_dev->resource[idx].end = addr + size;
- }
-
- if (device_dev->resource[idx].flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
-
- /*
- * Update the Command Word on the Card.
- */
- cmd |= PCI_COMMAND_MASTER; /* If the device doesn't support */
- /* bit gets dropped .. no harm */
- pci_write_config_word(device_dev, PCI_COMMAND, cmd);
-
- pci_read_config_byte(device_dev, PCI_INTERRUPT_PIN,
- (unsigned char *)&lines);
- device_sysdata = (struct sn_device_sysdata *)device_dev->sysdata;
- device_vertex = device_sysdata->vhdl;
- pci_provider = device_sysdata->pci_provider;
-
- if (!lines) {
- continue;
- }
-
- irqpdaindr->curr = device_dev;
- intr_handle = (pci_provider->intr_alloc)(device_vertex, NULL, lines, device_vertex);
-
- if (intr_handle = NULL) {
- printk("sn_pci_fixup: pcibr_intr_alloc() failed\n");
- continue;
- }
- irq = intr_handle->bi_irq;
- irqpdaindr->device_dev[irq] = device_dev;
- (pci_provider->intr_connect)(intr_handle, (intr_func_t)0, (intr_arg_t)0);
- device_dev->irq = irq;
- register_pcibr_intr(irq, (pcibr_intr_t)intr_handle);
-
- for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
- int ibits = intr_handle->bi_ibits;
- int i;
-
- size = device_dev->resource[idx].end -
- device_dev->resource[idx].start;
- if (size = 0)
- continue;
-
- for (i=0; i<8; i++) {
- if (ibits & (1 << i) ) {
- sn_dma_flush_init(device_dev->resource[idx].start,
- device_dev->resource[idx].end,
- idx,
- i,
- PCIBR_INFO_SLOT_GET_EXT(pcibr_info_get(device_sysdata->vhdl)));
- }
- }
- }
-
}
}
diff -Nru a/arch/ia64/sn/io/machvec/pci_dma.c b/arch/ia64/sn/io/machvec/pci_dma.c
--- a/arch/ia64/sn/io/machvec/pci_dma.c Thu Feb 5 10:17:40 2004
+++ b/arch/ia64/sn/io/machvec/pci_dma.c Thu Feb 5 10:17:40 2004
@@ -127,7 +127,7 @@
/*
* Get hwgraph vertex for the device
*/
- device_sysdata = (struct sn_device_sysdata *) hwdev->sysdata;
+ device_sysdata = SN_DEVICE_SYSDATA(hwdev);
vhdl = device_sysdata->vhdl;
/*
@@ -240,7 +240,7 @@
/*
* Get the hwgraph vertex for the device
*/
- device_sysdata = (struct sn_device_sysdata *) hwdev->sysdata;
+ device_sysdata = SN_DEVICE_SYSDATA(hwdev);
vhdl = device_sysdata->vhdl;
/*
@@ -367,7 +367,7 @@
/*
* find vertex for the device
*/
- device_sysdata = (struct sn_device_sysdata *)hwdev->sysdata;
+ device_sysdata = SN_DEVICE_SYSDATA(hwdev);
vhdl = device_sysdata->vhdl;
/*
diff -Nru a/arch/ia64/sn/io/sn2/pic.c b/arch/ia64/sn/io/sn2/pic.c
--- a/arch/ia64/sn/io/sn2/pic.c Thu Feb 5 10:17:40 2004
+++ b/arch/ia64/sn/io/sn2/pic.c Thu Feb 5 10:17:40 2004
@@ -90,10 +90,15 @@
peer_widget_info->w_efunc = 0;
peer_widget_info->w_einfo = 0;
peer_widget_info->w_name = kmalloc(strlen(peer_path) + 1, GFP_KERNEL);
+ if (!peer_widget_info->w_name) {
+ kfree(peer_widget_info);
+ return -ENOMEM;
+ }
strcpy(peer_widget_info->w_name, peer_path);
if (hwgraph_info_add_LBL(peer_conn_v, INFO_LBL_XWIDGET,
(arbitrary_info_t)peer_widget_info) != GRAPH_SUCCESS) {
+ kfree(peer_widget_info->w_name);
kfree(peer_widget_info);
return 0;
}
@@ -359,6 +364,9 @@
s = dev_to_name(pcibr_vhdl, devnm, MAXDEVNAME);
pcibr_soft->bs_name = kmalloc(strlen(s) + 1, GFP_KERNEL);
+ if (!pcibr_soft->bs_name)
+ return -ENOMEM;
+
strcpy(pcibr_soft->bs_name, s);
pcibr_soft->bs_conn = xconn_vhdl;
diff -Nru a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h
--- a/include/asm-ia64/pci.h Thu Feb 5 10:17:40 2004
+++ b/include/asm-ia64/pci.h Thu Feb 5 10:17:40 2004
@@ -96,6 +96,8 @@
unsigned int windows;
struct pci_window *window;
+
+ void *platform_data;
};
#define PCI_CONTROLLER(busdev) ((struct pci_controller *) busdev->sysdata)
diff -Nru a/include/asm-ia64/sn/pci/pci_bus_cvlink.h b/include/asm-ia64/sn/pci/pci_bus_cvlink.h
--- a/include/asm-ia64/sn/pci/pci_bus_cvlink.h Thu Feb 5 10:17:40 2004
+++ b/include/asm-ia64/sn/pci/pci_bus_cvlink.h Thu Feb 5 10:17:40 2004
@@ -31,22 +31,26 @@
#define MAX_PCI_XWIDGET 256
#define MAX_ATE_MAPS 1024
+#define SN_DEVICE_SYSDATA(dev) \
+ ((struct sn_device_sysdata *) \
+ (((struct pci_controller *) ((dev)->sysdata))->platform_data))
+
#define IS_PCI32G(dev) ((dev)->dma_mask >= 0xffffffff)
#define IS_PCI32L(dev) ((dev)->dma_mask < 0xffffffff)
#define PCIDEV_VERTEX(pci_dev) \
- (((struct sn_device_sysdata *)((pci_dev)->sysdata))->vhdl)
-
-#define PCIBUS_VERTEX(pci_bus) \
- (((struct sn_widget_sysdata *)((pci_bus)->sysdata))->vhdl)
+ ((SN_DEVICE_SYSDATA(pci_dev))->vhdl)
struct sn_widget_sysdata {
vertex_hdl_t vhdl;
};
struct sn_device_sysdata {
- vertex_hdl_t vhdl;
+ vertex_hdl_t vhdl;
pciio_provider_t *pci_provider;
+ pciio_intr_t intr_handle;
+ struct sn_flush_device_list *dma_flush_list;
+ pciio_piomap_t pio_map[PCI_ROM_RESOURCE];
};
struct ioports_to_tlbs_s {
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [2.6 PATCH] Altix update 2004-02-18 14:41 [2.6 PATCH] Altix update Pat Gefre @ 2004-02-18 17:06 ` Christoph Hellwig 2004-02-18 18:38 ` David Mosberger 2004-02-18 17:47 ` David Mosberger ` (3 subsequent siblings) 4 siblings, 1 reply; 11+ messages in thread From: Christoph Hellwig @ 2004-02-18 17:06 UTC (permalink / raw) To: Pat Gefre; +Cc: akpm, davidm, linux-kernel, linux-ia64 On Wed, Feb 18, 2004 at 08:41:18AM -0600, Pat Gefre wrote: > Andrew, > > Here's a small mod for Altix. It breaks up our 'pci fixup' function and > has some other smallish clean ups. > > For the ia64 crowd I've added 'platform_data' back into > include/asm-ia64/pci.h > > Can you take this ? The patch looks okay, but this whole fixup-based pci initialization is just plain wrong to start with. I still wonder how this crap managed to enter the tree.. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [2.6 PATCH] Altix update 2004-02-18 17:06 ` Christoph Hellwig @ 2004-02-18 18:38 ` David Mosberger 2004-02-18 18:44 ` Christoph Hellwig 0 siblings, 1 reply; 11+ messages in thread From: David Mosberger @ 2004-02-18 18:38 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Pat Gefre, akpm, davidm, linux-kernel, linux-ia64 >>>>> On Wed, 18 Feb 2004 17:06:01 +0000, Christoph Hellwig <hch@infradead.org> said: Christoph> The patch looks okay, but this whole fixup-based pci Christoph> initialization is just plain wrong to start with. I don't think anybody is wedded to the code there. From what I know, it works fine, but if you want to submit enhancements, I'm pretty sure they'd be appreciated. --david ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [2.6 PATCH] Altix update 2004-02-18 18:38 ` David Mosberger @ 2004-02-18 18:44 ` Christoph Hellwig 2004-02-18 19:00 ` David Mosberger 0 siblings, 1 reply; 11+ messages in thread From: Christoph Hellwig @ 2004-02-18 18:44 UTC (permalink / raw) To: davidm; +Cc: Pat Gefre, akpm, davidm, linux-kernel, linux-ia64 On Wed, Feb 18, 2004 at 10:38:06AM -0800, David Mosberger wrote: > I don't think anybody is wedded to the code there. From what I know, > it works fine, but if you want to submit enhancements, I'm pretty sure > they'd be appreciated. I've submitted a bunch of patches in that area last autum. This resulted in a big flamewar and most are still outstanding :) ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [2.6 PATCH] Altix update 2004-02-18 18:44 ` Christoph Hellwig @ 2004-02-18 19:00 ` David Mosberger 2004-02-18 19:15 ` Christoph Hellwig 0 siblings, 1 reply; 11+ messages in thread From: David Mosberger @ 2004-02-18 19:00 UTC (permalink / raw) To: Christoph Hellwig Cc: davidm, Pat Gefre, akpm, davidm, linux-kernel, linux-ia64 >>>>> On Wed, 18 Feb 2004 18:44:11 +0000, Christoph Hellwig <hch@infradead.org> said: Christoph> On Wed, Feb 18, 2004 at 10:38:06AM -0800, David Mosberger wrote: >> I don't think anybody is wedded to the code there. From what I know, >> it works fine, but if you want to submit enhancements, I'm pretty sure >> they'd be appreciated. Christoph> I've submitted a bunch of patches in that area last Christoph> autum. This resulted in a big flamewar and most are Christoph> still outstanding :) Where? On linux-ia64 or on lkml? I don't recall these discussions (but then again, I'm admittedly very good at forgetting stuff...). --david ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [2.6 PATCH] Altix update 2004-02-18 19:00 ` David Mosberger @ 2004-02-18 19:15 ` Christoph Hellwig 2004-02-18 19:27 ` David Mosberger 0 siblings, 1 reply; 11+ messages in thread From: Christoph Hellwig @ 2004-02-18 19:15 UTC (permalink / raw) To: davidm; +Cc: Christoph Hellwig, Pat Gefre, akpm, davidm, linux-kernel, linux-ia64 On Wed, Feb 18, 2004 at 11:00:25AM -0800, David Mosberger wrote: > Where? On linux-ia64 or on lkml? I don't recall these discussions > (but then again, I'm admittedly very good at forgetting stuff...). Linux-IA64. I sent a bunch of patches to you and Jesse that you applied but large parts of SGI didn't for certain reasons (NIH comes to mind). We had some discussion on linux-ia64 and on private mail on this, SGI promised to look at the patches later. Small parts now got in without any attribution through Pat's patchkits but other parts are still missing after many month of waiting. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [2.6 PATCH] Altix update 2004-02-18 19:15 ` Christoph Hellwig @ 2004-02-18 19:27 ` David Mosberger 0 siblings, 0 replies; 11+ messages in thread From: David Mosberger @ 2004-02-18 19:27 UTC (permalink / raw) To: Christoph Hellwig Cc: davidm, Pat Gefre, akpm, davidm, linux-kernel, linux-ia64 >>>>> On Wed, 18 Feb 2004 19:15:59 +0000, Christoph Hellwig <hch@infradead.org> said: Christoph> On Wed, Feb 18, 2004 at 11:00:25AM -0800, David Mosberger wrote: >> Where? On linux-ia64 or on lkml? I don't recall these discussions >> (but then again, I'm admittedly very good at forgetting stuff...). Christoph> Linux-IA64. I sent a bunch of patches to you and Jesse Christoph> that you applied but large parts of SGI didn't for Christoph> certain reasons (NIH comes to mind). Thankfully, I have no control over SGI's tree but if you have any pending improvements for the generic ia64 portions, I'd certainly be happy to take (another) look. I really didn't (and still don't) remember of there being anything pending in this area. Not entirely surprising though: I'm quite easy to satisfy as far as the PCI subsystem goes (if it works, I'm happy ;-). --david ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [2.6 PATCH] Altix update 2004-02-18 14:41 [2.6 PATCH] Altix update Pat Gefre 2004-02-18 17:06 ` Christoph Hellwig @ 2004-02-18 17:47 ` David Mosberger 2004-02-18 18:08 ` Bartlomiej Zolnierkiewicz ` (2 subsequent siblings) 4 siblings, 0 replies; 11+ messages in thread From: David Mosberger @ 2004-02-18 17:47 UTC (permalink / raw) To: Pat Gefre; +Cc: akpm, davidm, linux-kernel, linux-ia64 >>>>> On Wed, 18 Feb 2004 08:41:18 -0600 (CST), Pat Gefre <pfg@sgi.com> said: Pat> Andrew, Here's a small mod for Altix. It breaks up our 'pci Pat> fixup' function and has some other smallish clean ups. Pat> For the ia64 crowd I've added 'platform_data' back into Pat> include/asm-ia64/pci.h Please don't send such patches to Andrew. I don't want to have divergence on fundamental ia64 data structures. Pat> Can you take this ? Feel free to send me incremental ia64 patches. I asked you to send the monster SN2 update patch to Andrew because I didn't want to get stuck with it in my tree. But now that that is taken care of, I'm perfectly happy to handle your incremental patches. --david ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [2.6 PATCH] Altix update 2004-02-18 14:41 [2.6 PATCH] Altix update Pat Gefre 2004-02-18 17:06 ` Christoph Hellwig 2004-02-18 17:47 ` David Mosberger @ 2004-02-18 18:08 ` Bartlomiej Zolnierkiewicz 2004-02-18 19:57 ` David Mosberger 2004-02-19 18:09 ` Pat Gefre 4 siblings, 0 replies; 11+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2004-02-18 18:08 UTC (permalink / raw) To: Pat Gefre, akpm, davidm; +Cc: linux-kernel, linux-ia64 [ just a random nitpicking :-) ] > +/* > + * sn_alloc_pci_sysdata() - This routine allocates a pci controller > + * which is expected as the pci_dev and pci_bus sysdata by the Linux > + * PCI infrastructure. > + */ > +struct pci_controller * > +sn_alloc_pci_sysdata(void) this can be static > + pci_sysdata = sn_alloc_pci_sysdata(); > + if (!pci_sysdata) { > + printk(KERN_WARNING "sn_pci_fixup_bus(): Unable to " > + "allocate memory for pci_sysdata\n"); > + return -ENOMEM; > + } > + widget_sysdata = kmalloc(sizeof(struct sn_widget_sysdata), > + GFP_KERNEL); > + if (!widget_sysdata) { > + printk(KERN_WARNING "sn_pci_fixup_bus(): Unable to " > + "allocate memory for widget_sysdata\n"); > + return -ENOMEM; > + } in case of -ENOMEM pci_sysdata is leaked > + /* Allocate a controller structure */ > + pci_sysdata = sn_alloc_pci_sysdata(); > + if (!pci_sysdata) { > + printk(KERN_WARNING "sn_pci_fixup_slot: Unable to " > + "allocate memory for pci_sysdata\n"); > + return -ENOMEM; > + } > + > + /* Set the device vertex */ > + device_sysdata = kmalloc(sizeof(struct sn_device_sysdata), GFP_KERNEL); > + if (!device_sysdata) { > + printk(KERN_WARNING "sn_pci_fixup_slot: Unable to " > + "allocate memory for device_sysdata\n"); > + return -ENOMEM; > + } same pci_sysdata leak on error > + /* Allocate the IORESOURCE_IO space first */ > + for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) { > + unsigned long start, end, addr; > + > + device_sysdata->pio_map[idx] = NULL; > + > + if (!(dev->resource[idx].flags & IORESOURCE_IO)) > + continue; > + > + start = dev->resource[idx].start; > + end = dev->resource[idx].end; > + size = end - start; > + if (!size) > + continue; > + > + addr = (unsigned long)pciio_pio_addr(vhdl, 0, > + PCIIO_SPACE_WIN(idx), 0, size, > + &device_sysdata->pio_map[idx], 0); > + > + if (!addr) { > + dev->resource[idx].start = 0; > + dev->resource[idx].end = 0; > + printk("sn_pci_fixup(): pio map failure for " > + "%s bar%d\n", dev->slot_name, idx); > + } else { > + addr |= __IA64_UNCACHED_OFFSET; > + dev->resource[idx].start = addr; > + dev->resource[idx].end = addr + size; > + } > + > + if (dev->resource[idx].flags & IORESOURCE_IO) > + cmd |= PCI_COMMAND_IO; > + } Can dev->resource[idx].flags be modified by pciio_pio_addr()? If not the last if() is redundant. > + /* Allocate the IORESOURCE_MEM space next */ > + for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) { > + unsigned long start, end, addr; > + > + if ((dev->resource[idx].flags & IORESOURCE_IO)) > + continue; > + > + start = dev->resource[idx].start; > + end = dev->resource[idx].end; > + size = end - start; > + if (!size) > + continue; > + > + addr = (unsigned long)pciio_pio_addr(vhdl, 0, > + PCIIO_SPACE_WIN(idx), 0, size, > + &device_sysdata->pio_map[idx], 0); > + > + if (!addr) { > + dev->resource[idx].start = 0; > + dev->resource[idx].end = 0; > + printk("sn_pci_fixup(): pio map failure for " > + "%s bar%d\n", dev->slot_name, idx); > + } else { > + addr |= __IA64_UNCACHED_OFFSET; > + dev->resource[idx].start = addr; > + dev->resource[idx].end = addr + size; > + } > + > + if (dev->resource[idx].flags & IORESOURCE_MEM) > + cmd |= PCI_COMMAND_MEMORY; > + } whitespaces damage and spaces vs tabs (there is more in the patch) IORESOURCE_IO and IORESOURCE_MEM cases beg for common helper function, static int sn_pci_set_resource(struct pci_dev *dev, unsigned long flag)? > + /* > + * Update the Command Word on the Card. > + */ > + cmd |= PCI_COMMAND_MASTER; /* If the device doesn't support */ > + /* bit gets dropped .. no harm */ > + pci_write_config_word(dev, PCI_COMMAND, cmd); > + > + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, (unsigned char *)&lines); > + device_vertex = device_sysdata->vhdl; > + pci_provider = device_sysdata->pci_provider; > + device_sysdata->intr_handle = NULL; > + > + if (!lines) > + return 0; > + > + irqpdaindr->curr = dev; > + > + intr_handle = (pci_provider->intr_alloc)(device_vertex, NULL, lines, > device_vertex); + if (intr_handle = NULL) { > + printk(KERN_WARNING "sn_pci_fixup: pcibr_intr_alloc() failed\n"); > + return -ENOMEM; > + } pci_sysdata and device_sysdata leak on error Cheers, --bart ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [2.6 PATCH] Altix update 2004-02-18 14:41 [2.6 PATCH] Altix update Pat Gefre ` (2 preceding siblings ...) 2004-02-18 18:08 ` Bartlomiej Zolnierkiewicz @ 2004-02-18 19:57 ` David Mosberger 2004-02-19 18:09 ` Pat Gefre 4 siblings, 0 replies; 11+ messages in thread From: David Mosberger @ 2004-02-18 19:57 UTC (permalink / raw) To: Pat Gefre; +Cc: akpm, davidm, linux-kernel, linux-ia64 >>>>> On Wed, 18 Feb 2004 08:41:18 -0600 (CST), Pat Gefre <pfg@sgi.com> said: Pat> Here's a small mod for Altix. It breaks up our 'pci fixup' function and Pat> has some other smallish clean ups. Pat> For the ia64 crowd I've added 'platform_data' back into Pat> include/asm-ia64/pci.h I added this patch in my tree now with some trailing white-space fixes, but no other changes. As far as I can tell, platform_data never was in the the struct pci_controller of the 2.5/2.6 tree, so it's really a new thing, not a matter of "adding it back" (yeah it's in 2.4, but that's a separate tree...). --david ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [2.6 PATCH] Altix update 2004-02-18 14:41 [2.6 PATCH] Altix update Pat Gefre ` (3 preceding siblings ...) 2004-02-18 19:57 ` David Mosberger @ 2004-02-19 18:09 ` Pat Gefre 4 siblings, 0 replies; 11+ messages in thread From: Pat Gefre @ 2004-02-19 18:09 UTC (permalink / raw) To: Christoph Hellwig Cc: davidm, Pat Gefre, akpm, davidm, linux-kernel, linux-ia64 On Wed, 18 Feb 2004, Christoph Hellwig wrote: + On Wed, Feb 18, 2004 at 10:38:06AM -0800, David Mosberger wrote: + > I don't think anybody is wedded to the code there. From what I know, + > it works fine, but if you want to submit enhancements, I'm pretty sure + > they'd be appreciated. + + I've submitted a bunch of patches in that area last autum. This resulted + in a big flamewar and most are still outstanding :) + I looked over the original email that hch sent quite awhle ago on the fixup code. This patch is closer to what was suggested: # This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.1653 -> 1.1654 # arch/ia64/sn/io/machvec/pci_bus_cvlink.c 1.33 -> 1.34 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 04/02/19 pfg@sgi.com 1.1654 # arch/ia64/sn/io/machvec/pci_bus_cvlink.c # I incorporated (at least in spirit I hope) hch's suggestions on the fixup code # put in some kfrees that I was missing and static for sn_alloc_pci_sysdata # (thanks Bartlomiej Zolnierkiewicz) # White space clean up # -------------------------------------------- # diff -Nru a/arch/ia64/sn/io/machvec/pci_bus_cvlink.c b/arch/ia64/sn/io/machvec/pci_bus_cvlink.c --- a/arch/ia64/sn/io/machvec/pci_bus_cvlink.c Thu Feb 19 12:06:34 2004 +++ b/arch/ia64/sn/io/machvec/pci_bus_cvlink.c Thu Feb 19 12:06:34 2004 @@ -54,7 +54,7 @@ } /* - * pci_bus_cvlink_init() - To be called once during initialization before + * pci_bus_cvlink_init() - To be called once during initialization before * SGI IO Infrastructure init is called. */ int @@ -74,7 +74,7 @@ } /* - * pci_bus_to_vertex() - Given a logical Linux Bus Number returns the associated + * pci_bus_to_vertex() - Given a logical Linux Bus Number returns the associated * pci bus vertex from the SGI IO Infrastructure. */ static inline vertex_hdl_t @@ -92,7 +92,7 @@ } /* - * devfn_to_vertex() - returns the vertex of the device given the bus, slot, + * devfn_to_vertex() - returns the vertex of the device given the bus, slot, * and function numbers. */ vertex_hdl_t @@ -133,8 +133,8 @@ * ../pci/1, ../pci/2 .. */ if (func = 0) { - sprintf(name, "%d", slot); - if (hwgraph_traverse(pci_bus, name, &device_vertex) = + sprintf(name, "%d", slot); + if (hwgraph_traverse(pci_bus, name, &device_vertex) = GRAPH_SUCCESS) { if (device_vertex) { return(device_vertex); @@ -161,7 +161,7 @@ * which is expected as the pci_dev and pci_bus sysdata by the Linux * PCI infrastructure. */ -struct pci_controller * +static struct pci_controller * sn_alloc_pci_sysdata(void) { struct pci_controller *pci_sysdata; @@ -195,6 +195,7 @@ if (!widget_sysdata) { printk(KERN_WARNING "sn_pci_fixup_bus(): Unable to " "allocate memory for widget_sysdata\n"); + kfree(pci_sysdata); return -ENOMEM; } @@ -240,6 +241,7 @@ if (!device_sysdata) { printk(KERN_WARNING "sn_pci_fixup_slot: Unable to " "allocate memory for device_sysdata\n"); + kfree(pci_sysdata); return -ENOMEM; } @@ -262,69 +264,69 @@ vhdl = device_sysdata->vhdl; /* Allocate the IORESOURCE_IO space first */ - for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) { - unsigned long start, end, addr; + for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) { + unsigned long start, end, addr; device_sysdata->pio_map[idx] = NULL; - if (!(dev->resource[idx].flags & IORESOURCE_IO)) - continue; + if (!(dev->resource[idx].flags & IORESOURCE_IO)) + continue; - start = dev->resource[idx].start; - end = dev->resource[idx].end; - size = end - start; - if (!size) - continue; + start = dev->resource[idx].start; + end = dev->resource[idx].end; + size = end - start; + if (!size) + continue; - addr = (unsigned long)pciio_pio_addr(vhdl, 0, - PCIIO_SPACE_WIN(idx), 0, size, + addr = (unsigned long)pciio_pio_addr(vhdl, 0, + PCIIO_SPACE_WIN(idx), 0, size, &device_sysdata->pio_map[idx], 0); - if (!addr) { - dev->resource[idx].start = 0; - dev->resource[idx].end = 0; - printk("sn_pci_fixup(): pio map failure for " - "%s bar%d\n", dev->slot_name, idx); - } else { - addr |= __IA64_UNCACHED_OFFSET; - dev->resource[idx].start = addr; - dev->resource[idx].end = addr + size; - } - - if (dev->resource[idx].flags & IORESOURCE_IO) - cmd |= PCI_COMMAND_IO; - } - - /* Allocate the IORESOURCE_MEM space next */ - for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) { - unsigned long start, end, addr; - - if ((dev->resource[idx].flags & IORESOURCE_IO)) - continue; - - start = dev->resource[idx].start; - end = dev->resource[idx].end; - size = end - start; - if (!size) - continue; + if (!addr) { + dev->resource[idx].start = 0; + dev->resource[idx].end = 0; + printk("sn_pci_fixup(): pio map failure for " + "%s bar%d\n", dev->slot_name, idx); + } else { + addr |= __IA64_UNCACHED_OFFSET; + dev->resource[idx].start = addr; + dev->resource[idx].end = addr + size; + } + + if (dev->resource[idx].flags & IORESOURCE_IO) + cmd |= PCI_COMMAND_IO; + } + + /* Allocate the IORESOURCE_MEM space next */ + for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) { + unsigned long start, end, addr; + + if ((dev->resource[idx].flags & IORESOURCE_IO)) + continue; - addr = (unsigned long)pciio_pio_addr(vhdl, 0, - PCIIO_SPACE_WIN(idx), 0, size, + start = dev->resource[idx].start; + end = dev->resource[idx].end; + size = end - start; + if (!size) + continue; + + addr = (unsigned long)pciio_pio_addr(vhdl, 0, + PCIIO_SPACE_WIN(idx), 0, size, &device_sysdata->pio_map[idx], 0); - if (!addr) { - dev->resource[idx].start = 0; - dev->resource[idx].end = 0; - printk("sn_pci_fixup(): pio map failure for " - "%s bar%d\n", dev->slot_name, idx); - } else { - addr |= __IA64_UNCACHED_OFFSET; - dev->resource[idx].start = addr; - dev->resource[idx].end = addr + size; - } + if (!addr) { + dev->resource[idx].start = 0; + dev->resource[idx].end = 0; + printk("sn_pci_fixup(): pio map failure for " + "%s bar%d\n", dev->slot_name, idx); + } else { + addr |= __IA64_UNCACHED_OFFSET; + dev->resource[idx].start = addr; + dev->resource[idx].end = addr + size; + } - if (dev->resource[idx].flags & IORESOURCE_MEM) - cmd |= PCI_COMMAND_MEMORY; + if (dev->resource[idx].flags & IORESOURCE_MEM) + cmd |= PCI_COMMAND_MEMORY; } /* @@ -347,6 +349,8 @@ intr_handle = (pci_provider->intr_alloc)(device_vertex, NULL, lines, device_vertex); if (intr_handle = NULL) { printk(KERN_WARNING "sn_pci_fixup: pcibr_intr_alloc() failed\n"); + kfree(pci_sysdata); + kfree(device_sysdata); return -ENOMEM; } @@ -384,16 +388,16 @@ struct sn_flush_nasid_entry flush_nasid_list[MAX_NASIDS]; /* Initialize the data structures for flushing write buffers after a PIO read. - * The theory is: + * The theory is: * Take an unused int. pin and associate it with a pin that is in use. * After a PIO read, force an interrupt on the unused pin, forcing a write buffer flush - * on the in use pin. This will prevent the race condition between PIO read responses and + * on the in use pin. This will prevent the race condition between PIO read responses and * DMA writes. */ static struct sn_flush_device_list * sn_dma_flush_init(unsigned long start, unsigned long end, int idx, int pin, int slot) { - nasid_t nasid; + nasid_t nasid; unsigned long dnasid; int wid_num; int bus; @@ -422,8 +426,8 @@ itte = HUB_L(IIO_ITTE_GET(nasid, itte_index)); flush_nasid_list[nasid].iio_itte[bwin] = itte; - wid_num = (itte >> IIO_ITTE_WIDGET_SHIFT) & - IIO_ITTE_WIDGET_MASK; + wid_num = (itte >> IIO_ITTE_WIDGET_SHIFT) + & IIO_ITTE_WIDGET_MASK; bus = itte & IIO_ITTE_OFFSET_MASK; if (bus = 0x4 || bus = 0x8) { bus = 0; @@ -445,7 +449,7 @@ printk(KERN_WARNING "sn_dma_flush_init: Cannot allocate memory for nasid sub-list\n"); return NULL; } - memset(flush_nasid_list[nasid].widget_p[wid_num], 0, + memset(flush_nasid_list[nasid].widget_p[wid_num], 0, DEV_PER_WIDGET * sizeof (struct sn_flush_device_list)); p = &flush_nasid_list[nasid].widget_p[wid_num][0]; for (i=0; i<DEV_PER_WIDGET;i++) { @@ -484,7 +488,7 @@ * about the case when there is a card in slot 2. A multifunction card will appear * to be in slot 6 (from an interrupt point of view) also. That's the most we'll * have to worry about. A four function card will overload the interrupt lines in - * slot 2 and 6. + * slot 2 and 6. * We also need to special case the 12160 device in slot 3. Fortunately, we have * a spare intr. line for pin 4, so we'll use that for the 12160. * All other buses have slot 3 and 4 and slots 7 and 8 unused. Since we can only @@ -504,21 +508,21 @@ pcireg_bridge_intr_device_bit_set(b, (1<<18)); dnasid = NASID_GET(virt_to_phys(&p->flush_addr)); pcireg_bridge_intr_addr_set(b, 6, ((virt_to_phys(&p->flush_addr) & 0xfffffffff) | - (dnasid << 36) | (0xfUL << 48))); + (dnasid << 36) | (0xfUL << 48))); } else if (pin = 2) { /* 12160 SCSI device in IO9 */ p->force_int_addr = (unsigned long)pcireg_bridge_force_always_addr_get(b, 4); pcireg_bridge_intr_device_bit_set(b, (2<<12)); dnasid = NASID_GET(virt_to_phys(&p->flush_addr)); pcireg_bridge_intr_addr_set(b, 4, ((virt_to_phys(&p->flush_addr) & 0xfffffffff) | - (dnasid << 36) | (0xfUL << 48))); + (dnasid << 36) | (0xfUL << 48))); } else { /* slot = 6 */ p->force_int_addr = (unsigned long)pcireg_bridge_force_always_addr_get(b, 7); pcireg_bridge_intr_device_bit_set(b, (5<<21)); dnasid = NASID_GET(virt_to_phys(&p->flush_addr)); pcireg_bridge_intr_addr_set(b, 7, ((virt_to_phys(&p->flush_addr) & 0xfffffffff) | - (dnasid << 36) | (0xfUL << 48))); + (dnasid << 36) | (0xfUL << 48))); } } else { p->force_int_addr = (unsigned long)pcireg_bridge_force_always_addr_get(b, (pin +2)); @@ -526,99 +530,13 @@ dnasid = NASID_GET(virt_to_phys(&p->flush_addr)); pcireg_bridge_intr_addr_set(b, (pin + 2), ((virt_to_phys(&p->flush_addr) & 0xfffffffff) | - (dnasid << 36) | (0xfUL << 48))); + (dnasid << 36) | (0xfUL << 48))); } return p; } /* - * sn_pci_fixup() - This routine is called when platform_pci_fixup() is - * invoked at the end of pcibios_init() to link the Linux pci - * infrastructure to SGI IO Infrasturcture - ia64/kernel/pci.c - * - * Other platform specific fixup can also be done here. - */ -static void __init -sn_pci_fixup(int arg) -{ - struct list_head *ln; - struct pci_bus *pci_bus = NULL; - struct pci_dev *pci_dev = NULL; - extern int numnodes; - int cnode, ret; - - if (arg = 0) { -#ifdef CONFIG_PROC_FS - extern void register_sn_procfs(void); -#endif - extern void sgi_master_io_infr_init(void); - extern void sn_init_cpei_timer(void); - - sgi_master_io_infr_init(); - - for (cnode = 0; cnode < numnodes; cnode++) { - extern void intr_init_vecblk(cnodeid_t); - intr_init_vecblk(cnode); - } - - sn_init_cpei_timer(); - -#ifdef CONFIG_PROC_FS - register_sn_procfs(); -#endif - return; - } - - done_probing = 1; - - /* - * Initialize the pci bus vertex in the pci_bus struct. - */ - for( ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) { - pci_bus = pci_bus_b(ln); - ret = sn_pci_fixup_bus(pci_bus); - if ( ret ) { - printk(KERN_WARNING - "sn_pci_fixup: sn_pci_fixup_bus fails : error %d\n", - ret); - return; - } - } - - /* - * set the root start and end so that drivers calling check_region() - * won't see a conflict - */ - -#ifdef CONFIG_IA64_SGI_SN_SIM - if (! IS_RUNNING_ON_SIMULATOR()) { - ioport_resource.start = 0xc000000000000000; - ioport_resource.end = 0xcfffffffffffffff; - } -#endif - - /* - * Set the root start and end for Mem Resource. - */ - iomem_resource.start = 0; - iomem_resource.end = 0xffffffffffffffff; - - /* - * Initialize the device vertex in the pci_dev struct. - */ - while ((pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) != NULL) { - ret = sn_pci_fixup_slot(pci_dev); - if ( ret ) { - printk(KERN_WARNING - "sn_pci_fixup: sn_pci_fixup_slot fails : error %d\n", - ret); - return; - } - } -} - -/* - * linux_bus_cvlink() Creates a link between the Linux PCI Bus number + * linux_bus_cvlink() Creates a link between the Linux PCI Bus number * to the actual hardware component that it represents: * /dev/hw/linux/busnum/0 -> ../../../hw/module/001c01/slab/0/Ibrick/xtalk/15/pci * @@ -638,7 +556,7 @@ continue; sprintf(name, "%x", index); - (void) hwgraph_edge_add(linux_busnum, busnum_to_pcibr_vhdl[index], + (void) hwgraph_edge_add(linux_busnum, busnum_to_pcibr_vhdl[index], name); } } @@ -649,7 +567,7 @@ * Linux PCI Bus numbers are assigned from lowest module_id numbers * (rack/slot etc.) */ -static int +static int pci_bus_map_create(struct pcibr_list_s *softlistp, moduleid_t moduleid) { @@ -659,10 +577,10 @@ memset(moduleid_str, 0, 16); format_module_id(moduleid_str, moduleid, MODULE_FORMAT_BRIEF); - (void) ioconfig_get_busnum((char *)moduleid_str, &basebus_num); + (void) ioconfig_get_busnum((char *)moduleid_str, &basebus_num); /* - * Assign the correct bus number and also the nasid of this + * Assign the correct bus number and also the nasid of this * pci Xwidget. */ bus_number = basebus_num + pcibr_widget_to_bus(pci_bus); @@ -690,20 +608,20 @@ printk("pci_bus_map_create: Cannot allocate memory for ate maps\n"); return -1; } - memset(busnum_to_atedmamaps[bus_number], 0x0, + memset(busnum_to_atedmamaps[bus_number], 0x0, sizeof(struct pcibr_dmamap_s) * MAX_ATE_MAPS); return(0); } /* - * pci_bus_to_hcl_cvlink() - This routine is called after SGI IO Infrastructure + * pci_bus_to_hcl_cvlink() - This routine is called after SGI IO Infrastructure * initialization has completed to set up the mappings between PCI BRIDGE - * ASIC and logical pci bus numbers. + * ASIC and logical pci bus numbers. * * Must be called before pci_init() is invoked. */ int -pci_bus_to_hcl_cvlink(void) +pci_bus_to_hcl_cvlink(void) { int i; extern pcibr_list_p pcibr_list; @@ -720,7 +638,7 @@ /* Is this PCI bus associated with this moduleid? */ moduleid = NODE_MODULEID( - NASID_TO_COMPACT_NODEID(pcibr_soft->bs_nasid)); + NASID_TO_COMPACT_NODEID(pcibr_soft->bs_nasid)); if (modules[i]->id = moduleid) { struct pcibr_list_s *new_element; @@ -741,9 +659,9 @@ continue; } - /* - * BASEIO IObricks attached to a module have - * a higher priority than non BASEIO IOBricks + /* + * BASEIO IObricks attached to a module have + * a higher priority than non BASEIO IOBricks * when it comes to persistant pci bus * numbering, so put them on the front of the * list. @@ -759,7 +677,7 @@ softlistp = softlistp->bl_next; } - /* + /* * We now have a list of all the pci bridges associated with * the module_id, modules[i]. Call pci_bus_map_create() for * each pci bridge @@ -787,13 +705,26 @@ /* * Ugly hack to get PCI setup until we have a proper ACPI namespace. */ + +#define PCI_BUSES_TO_SCAN 256 + extern struct pci_ops sn_pci_ops; int __init sn_pci_init (void) { -# define PCI_BUSES_TO_SCAN 256 int i = 0; struct pci_controller *controller; + struct list_head *ln; + struct pci_bus *pci_bus = NULL; + struct pci_dev *pci_dev = NULL; + extern int numnodes; + int cnode, ret; +#ifdef CONFIG_PROC_FS + extern void register_sn_procfs(void); +#endif + extern void sgi_master_io_infr_init(void); + extern void sn_init_cpei_timer(void); + if (!ia64_platform_is("sn2") || IS_RUNNING_ON_SIMULATOR()) return 0; @@ -806,7 +737,19 @@ /* * set pci_raw_ops, etc. */ - sn_pci_fixup(0); + + sgi_master_io_infr_init(); + + for (cnode = 0; cnode < numnodes; cnode++) { + extern void intr_init_vecblk(cnodeid_t); + intr_init_vecblk(cnode); + } + + sn_init_cpei_timer(); + +#ifdef CONFIG_PROC_FS + register_sn_procfs(); +#endif controller = kmalloc(sizeof(struct pci_controller), GFP_KERNEL); if (controller) { @@ -819,7 +762,53 @@ /* * actually find devices and fill in hwgraph structs */ - sn_pci_fixup(1); + + done_probing = 1; + + /* + * Initialize the pci bus vertex in the pci_bus struct. + */ + for( ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) { + pci_bus = pci_bus_b(ln); + ret = sn_pci_fixup_bus(pci_bus); + if ( ret ) { + printk(KERN_WARNING + "sn_pci_fixup: sn_pci_fixup_bus fails : error %d\n", + ret); + return; + } + } + + /* + * set the root start and end so that drivers calling check_region() + * won't see a conflict + */ + +#ifdef CONFIG_IA64_SGI_SN_SIM + if (! IS_RUNNING_ON_SIMULATOR()) { + ioport_resource.start = 0xc000000000000000; + ioport_resource.end = 0xcfffffffffffffff; + } +#endif + + /* + * Set the root start and end for Mem Resource. + */ + iomem_resource.start = 0; + iomem_resource.end = 0xffffffffffffffff; + + /* + * Initialize the device vertex in the pci_dev struct. + */ + while ((pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) != NULL) { + ret = sn_pci_fixup_slot(pci_dev); + if ( ret ) { + printk(KERN_WARNING + "sn_pci_fixup: sn_pci_fixup_slot fails : error %d\n", + ret); + return; + } + } return 0; } ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-02-19 18:09 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2004-02-18 14:41 [2.6 PATCH] Altix update Pat Gefre 2004-02-18 17:06 ` Christoph Hellwig 2004-02-18 18:38 ` David Mosberger 2004-02-18 18:44 ` Christoph Hellwig 2004-02-18 19:00 ` David Mosberger 2004-02-18 19:15 ` Christoph Hellwig 2004-02-18 19:27 ` David Mosberger 2004-02-18 17:47 ` David Mosberger 2004-02-18 18:08 ` Bartlomiej Zolnierkiewicz 2004-02-18 19:57 ` David Mosberger 2004-02-19 18:09 ` Pat Gefre
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox