aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/sn/kernel/io_init.c
diff options
context:
space:
mode:
authorJes Sorensen <jes@sgi.com>2006-02-13 05:29:57 -0500
committerTony Luck <tony.luck@intel.com>2006-02-15 16:24:45 -0500
commit8ed9b2c7a804335004e4bd3b4c6989c5b6bc243f (patch)
treef7420b3fe8ad59ad23707ccbfd7ccaef7abe2a70 /arch/ia64/sn/kernel/io_init.c
parent50d8e59038703c4da5acaed9afaa37ae416d3153 (diff)
[IA64-SGI] sn2 minor fixes and cleanups
General SN2 code cleanup: - Do not initialize global variables to zero - Use kzalloc instead of kmalloc+memset - Check kmalloc return values - Do not obfuscate spin lock calls - Remove some unused code - Various formatting cleanups Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'arch/ia64/sn/kernel/io_init.c')
-rw-r--r--arch/ia64/sn/kernel/io_init.c96
1 files changed, 39 insertions, 57 deletions
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 3437c2390429..dfb3f2902379 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -23,6 +23,10 @@
23#include "xtalk/hubdev.h" 23#include "xtalk/hubdev.h"
24#include "xtalk/xwidgetdev.h" 24#include "xtalk/xwidgetdev.h"
25 25
26
27extern void sn_init_cpei_timer(void);
28extern void register_sn_procfs(void);
29
26static struct list_head sn_sysdata_list; 30static struct list_head sn_sysdata_list;
27 31
28/* sysdata list struct */ 32/* sysdata list struct */
@@ -40,12 +44,12 @@ struct brick {
40 struct slab_info slab_info[MAX_SLABS + 1]; 44 struct slab_info slab_info[MAX_SLABS + 1];
41}; 45};
42 46
43int sn_ioif_inited = 0; /* SN I/O infrastructure initialized? */ 47int sn_ioif_inited; /* SN I/O infrastructure initialized? */
44 48
45struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES]; /* indexed by asic type */ 49struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES]; /* indexed by asic type */
46 50
47static int max_segment_number = 0; /* Default highest segment number */ 51static int max_segment_number; /* Default highest segment number */
48static int max_pcibus_number = 255; /* Default highest pci bus number */ 52static int max_pcibus_number = 255; /* Default highest pci bus number */
49 53
50/* 54/*
51 * Hooks and struct for unsupported pci providers 55 * Hooks and struct for unsupported pci providers
@@ -84,7 +88,6 @@ static inline u64
84sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num, 88sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
85 u64 address) 89 u64 address)
86{ 90{
87
88 struct ia64_sal_retval ret_stuff; 91 struct ia64_sal_retval ret_stuff;
89 ret_stuff.status = 0; 92 ret_stuff.status = 0;
90 ret_stuff.v0 = 0; 93 ret_stuff.v0 = 0;
@@ -94,7 +97,6 @@ sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
94 (u64) nasid, (u64) widget_num, 97 (u64) nasid, (u64) widget_num,
95 (u64) device_num, (u64) address, 0, 0, 0); 98 (u64) device_num, (u64) address, 0, 0, 0);
96 return ret_stuff.status; 99 return ret_stuff.status;
97
98} 100}
99 101
100/* 102/*
@@ -102,7 +104,6 @@ sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
102 */ 104 */
103static inline u64 sal_get_hubdev_info(u64 handle, u64 address) 105static inline u64 sal_get_hubdev_info(u64 handle, u64 address)
104{ 106{
105
106 struct ia64_sal_retval ret_stuff; 107 struct ia64_sal_retval ret_stuff;
107 ret_stuff.status = 0; 108 ret_stuff.status = 0;
108 ret_stuff.v0 = 0; 109 ret_stuff.v0 = 0;
@@ -118,7 +119,6 @@ static inline u64 sal_get_hubdev_info(u64 handle, u64 address)
118 */ 119 */
119static inline u64 sal_get_pcibus_info(u64 segment, u64 busnum, u64 address) 120static inline u64 sal_get_pcibus_info(u64 segment, u64 busnum, u64 address)
120{ 121{
121
122 struct ia64_sal_retval ret_stuff; 122 struct ia64_sal_retval ret_stuff;
123 ret_stuff.status = 0; 123 ret_stuff.status = 0;
124 ret_stuff.v0 = 0; 124 ret_stuff.v0 = 0;
@@ -215,7 +215,7 @@ static void __init sn_fixup_ionodes(void)
215 struct hubdev_info *hubdev; 215 struct hubdev_info *hubdev;
216 u64 status; 216 u64 status;
217 u64 nasid; 217 u64 nasid;
218 int i, widget, device; 218 int i, widget, device, size;
219 219
220 /* 220 /*
221 * Get SGI Specific HUB chipset information. 221 * Get SGI Specific HUB chipset information.
@@ -251,48 +251,37 @@ static void __init sn_fixup_ionodes(void)
251 if (!hubdev->hdi_flush_nasid_list.widget_p) 251 if (!hubdev->hdi_flush_nasid_list.widget_p)
252 continue; 252 continue;
253 253
254 size = (HUB_WIDGET_ID_MAX + 1) *
255 sizeof(struct sn_flush_device_kernel *);
254 hubdev->hdi_flush_nasid_list.widget_p = 256 hubdev->hdi_flush_nasid_list.widget_p =
255 kmalloc((HUB_WIDGET_ID_MAX + 1) * 257 kzalloc(size, GFP_KERNEL);
256 sizeof(struct sn_flush_device_kernel *), 258 if (!hubdev->hdi_flush_nasid_list.widget_p)
257 GFP_KERNEL); 259 BUG();
258 memset(hubdev->hdi_flush_nasid_list.widget_p, 0x0,
259 (HUB_WIDGET_ID_MAX + 1) *
260 sizeof(struct sn_flush_device_kernel *));
261 260
262 for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) { 261 for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) {
263 sn_flush_device_kernel = kmalloc(DEV_PER_WIDGET * 262 size = DEV_PER_WIDGET *
264 sizeof(struct 263 sizeof(struct sn_flush_device_kernel);
265 sn_flush_device_kernel), 264 sn_flush_device_kernel = kzalloc(size, GFP_KERNEL);
266 GFP_KERNEL);
267 if (!sn_flush_device_kernel) 265 if (!sn_flush_device_kernel)
268 BUG(); 266 BUG();
269 memset(sn_flush_device_kernel, 0x0,
270 DEV_PER_WIDGET *
271 sizeof(struct sn_flush_device_kernel));
272 267
273 dev_entry = sn_flush_device_kernel; 268 dev_entry = sn_flush_device_kernel;
274 for (device = 0; device < DEV_PER_WIDGET; 269 for (device = 0; device < DEV_PER_WIDGET;
275 device++,dev_entry++) { 270 device++,dev_entry++) {
276 dev_entry->common = kmalloc(sizeof(struct 271 size = sizeof(struct sn_flush_device_common);
277 sn_flush_device_common), 272 dev_entry->common = kzalloc(size, GFP_KERNEL);
278 GFP_KERNEL);
279 if (!dev_entry->common) 273 if (!dev_entry->common)
280 BUG(); 274 BUG();
281 memset(dev_entry->common, 0x0, sizeof(struct
282 sn_flush_device_common));
283 275
284 if (sn_prom_feature_available( 276 if (sn_prom_feature_available(
285 PRF_DEVICE_FLUSH_LIST)) 277 PRF_DEVICE_FLUSH_LIST))
286 status = sal_get_device_dmaflush_list( 278 status = sal_get_device_dmaflush_list(
287 nasid, 279 nasid, widget, device,
288 widget, 280 (u64)(dev_entry->common));
289 device,
290 (u64)(dev_entry->common));
291 else 281 else
292 status = sn_device_fixup_war(nasid, 282 status = sn_device_fixup_war(nasid,
293 widget, 283 widget, device,
294 device, 284 dev_entry->common);
295 dev_entry->common);
296 if (status != SALRET_OK) 285 if (status != SALRET_OK)
297 panic("SAL call failed: %s\n", 286 panic("SAL call failed: %s\n",
298 ia64_sal_strerror(status)); 287 ia64_sal_strerror(status));
@@ -383,13 +372,12 @@ void sn_pci_fixup_slot(struct pci_dev *dev)
383 372
384 pci_dev_get(dev); /* for the sysdata pointer */ 373 pci_dev_get(dev); /* for the sysdata pointer */
385 pcidev_info = kzalloc(sizeof(struct pcidev_info), GFP_KERNEL); 374 pcidev_info = kzalloc(sizeof(struct pcidev_info), GFP_KERNEL);
386 if (pcidev_info <= 0) 375 if (!pcidev_info)
387 BUG(); /* Cannot afford to run out of memory */ 376 BUG(); /* Cannot afford to run out of memory */
388 377
389 sn_irq_info = kmalloc(sizeof(struct sn_irq_info), GFP_KERNEL); 378 sn_irq_info = kzalloc(sizeof(struct sn_irq_info), GFP_KERNEL);
390 if (sn_irq_info <= 0) 379 if (!sn_irq_info)
391 BUG(); /* Cannot afford to run out of memory */ 380 BUG(); /* Cannot afford to run out of memory */
392 memset(sn_irq_info, 0, sizeof(struct sn_irq_info));
393 381
394 /* Call to retrieve pci device information needed by kernel. */ 382 /* Call to retrieve pci device information needed by kernel. */
395 status = sal_get_pcidev_info((u64) segment, (u64) dev->bus->number, 383 status = sal_get_pcidev_info((u64) segment, (u64) dev->bus->number,
@@ -482,13 +470,13 @@ void sn_pci_fixup_slot(struct pci_dev *dev)
482 */ 470 */
483void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus) 471void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
484{ 472{
485 int status = 0; 473 int status;
486 int nasid, cnode; 474 int nasid, cnode;
487 struct pci_controller *controller; 475 struct pci_controller *controller;
488 struct sn_pci_controller *sn_controller; 476 struct sn_pci_controller *sn_controller;
489 struct pcibus_bussoft *prom_bussoft_ptr; 477 struct pcibus_bussoft *prom_bussoft_ptr;
490 struct hubdev_info *hubdev_info; 478 struct hubdev_info *hubdev_info;
491 void *provider_soft = NULL; 479 void *provider_soft;
492 struct sn_pcibus_provider *provider; 480 struct sn_pcibus_provider *provider;
493 481
494 status = sal_get_pcibus_info((u64) segment, (u64) busnum, 482 status = sal_get_pcibus_info((u64) segment, (u64) busnum,
@@ -535,6 +523,8 @@ void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
535 bus->sysdata = controller; 523 bus->sysdata = controller;
536 if (provider->bus_fixup) 524 if (provider->bus_fixup)
537 provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr, controller); 525 provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr, controller);
526 else
527 provider_soft = NULL;
538 528
539 if (provider_soft == NULL) { 529 if (provider_soft == NULL) {
540 /* fixup failed or not applicable */ 530 /* fixup failed or not applicable */
@@ -638,13 +628,8 @@ void sn_bus_free_sysdata(void)
638 628
639static int __init sn_pci_init(void) 629static int __init sn_pci_init(void)
640{ 630{
641 int i = 0; 631 int i, j;
642 int j = 0;
643 struct pci_dev *pci_dev = NULL; 632 struct pci_dev *pci_dev = NULL;
644 extern void sn_init_cpei_timer(void);
645#ifdef CONFIG_PROC_FS
646 extern void register_sn_procfs(void);
647#endif
648 633
649 if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM()) 634 if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM())
650 return 0; 635 return 0;
@@ -700,32 +685,29 @@ static int __init sn_pci_init(void)
700 */ 685 */
701void hubdev_init_node(nodepda_t * npda, cnodeid_t node) 686void hubdev_init_node(nodepda_t * npda, cnodeid_t node)
702{ 687{
703
704 struct hubdev_info *hubdev_info; 688 struct hubdev_info *hubdev_info;
689 int size;
690 pg_data_t *pg;
691
692 size = sizeof(struct hubdev_info);
705 693
706 if (node >= num_online_nodes()) /* Headless/memless IO nodes */ 694 if (node >= num_online_nodes()) /* Headless/memless IO nodes */
707 hubdev_info = 695 pg = NODE_DATA(0);
708 (struct hubdev_info *)alloc_bootmem_node(NODE_DATA(0),
709 sizeof(struct
710 hubdev_info));
711 else 696 else
712 hubdev_info = 697 pg = NODE_DATA(node);
713 (struct hubdev_info *)alloc_bootmem_node(NODE_DATA(node),
714 sizeof(struct
715 hubdev_info));
716 npda->pdinfo = (void *)hubdev_info;
717 698
699 hubdev_info = (struct hubdev_info *)alloc_bootmem_node(pg, size);
700
701 npda->pdinfo = (void *)hubdev_info;
718} 702}
719 703
720geoid_t 704geoid_t
721cnodeid_get_geoid(cnodeid_t cnode) 705cnodeid_get_geoid(cnodeid_t cnode)
722{ 706{
723
724 struct hubdev_info *hubdev; 707 struct hubdev_info *hubdev;
725 708
726 hubdev = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo); 709 hubdev = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
727 return hubdev->hdi_geoid; 710 return hubdev->hdi_geoid;
728
729} 711}
730 712
731subsys_initcall(sn_pci_init); 713subsys_initcall(sn_pci_init);