Commit 8ed9b2c7 authored by Jes Sorensen's avatar Jes Sorensen Committed by Tony Luck

[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: default avatarJes Sorensen <jes@sgi.com>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent 50d8e590
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
#include "xtalk/hubdev.h" #include "xtalk/hubdev.h"
#include "xtalk/xwidgetdev.h" #include "xtalk/xwidgetdev.h"
extern void sn_init_cpei_timer(void);
extern void register_sn_procfs(void);
static struct list_head sn_sysdata_list; static struct list_head sn_sysdata_list;
/* sysdata list struct */ /* sysdata list struct */
...@@ -40,11 +44,11 @@ struct brick { ...@@ -40,11 +44,11 @@ struct brick {
struct slab_info slab_info[MAX_SLABS + 1]; struct slab_info slab_info[MAX_SLABS + 1];
}; };
int sn_ioif_inited = 0; /* SN I/O infrastructure initialized? */ int sn_ioif_inited; /* SN I/O infrastructure initialized? */
struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES]; /* indexed by asic type */ struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES]; /* indexed by asic type */
static int max_segment_number = 0; /* Default highest segment number */ static int max_segment_number; /* Default highest segment number */
static int max_pcibus_number = 255; /* Default highest pci bus number */ static int max_pcibus_number = 255; /* Default highest pci bus number */
/* /*
...@@ -84,7 +88,6 @@ static inline u64 ...@@ -84,7 +88,6 @@ static inline u64
sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num, sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
u64 address) u64 address)
{ {
struct ia64_sal_retval ret_stuff; struct ia64_sal_retval ret_stuff;
ret_stuff.status = 0; ret_stuff.status = 0;
ret_stuff.v0 = 0; ret_stuff.v0 = 0;
...@@ -94,7 +97,6 @@ sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num, ...@@ -94,7 +97,6 @@ sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
(u64) nasid, (u64) widget_num, (u64) nasid, (u64) widget_num,
(u64) device_num, (u64) address, 0, 0, 0); (u64) device_num, (u64) address, 0, 0, 0);
return ret_stuff.status; return ret_stuff.status;
} }
/* /*
...@@ -102,7 +104,6 @@ sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num, ...@@ -102,7 +104,6 @@ sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
*/ */
static inline u64 sal_get_hubdev_info(u64 handle, u64 address) static inline u64 sal_get_hubdev_info(u64 handle, u64 address)
{ {
struct ia64_sal_retval ret_stuff; struct ia64_sal_retval ret_stuff;
ret_stuff.status = 0; ret_stuff.status = 0;
ret_stuff.v0 = 0; ret_stuff.v0 = 0;
...@@ -118,7 +119,6 @@ static inline u64 sal_get_hubdev_info(u64 handle, u64 address) ...@@ -118,7 +119,6 @@ static inline u64 sal_get_hubdev_info(u64 handle, u64 address)
*/ */
static inline u64 sal_get_pcibus_info(u64 segment, u64 busnum, u64 address) static inline u64 sal_get_pcibus_info(u64 segment, u64 busnum, u64 address)
{ {
struct ia64_sal_retval ret_stuff; struct ia64_sal_retval ret_stuff;
ret_stuff.status = 0; ret_stuff.status = 0;
ret_stuff.v0 = 0; ret_stuff.v0 = 0;
...@@ -215,7 +215,7 @@ static void __init sn_fixup_ionodes(void) ...@@ -215,7 +215,7 @@ static void __init sn_fixup_ionodes(void)
struct hubdev_info *hubdev; struct hubdev_info *hubdev;
u64 status; u64 status;
u64 nasid; u64 nasid;
int i, widget, device; int i, widget, device, size;
/* /*
* Get SGI Specific HUB chipset information. * Get SGI Specific HUB chipset information.
...@@ -251,47 +251,36 @@ static void __init sn_fixup_ionodes(void) ...@@ -251,47 +251,36 @@ static void __init sn_fixup_ionodes(void)
if (!hubdev->hdi_flush_nasid_list.widget_p) if (!hubdev->hdi_flush_nasid_list.widget_p)
continue; continue;
size = (HUB_WIDGET_ID_MAX + 1) *
sizeof(struct sn_flush_device_kernel *);
hubdev->hdi_flush_nasid_list.widget_p = hubdev->hdi_flush_nasid_list.widget_p =
kmalloc((HUB_WIDGET_ID_MAX + 1) * kzalloc(size, GFP_KERNEL);
sizeof(struct sn_flush_device_kernel *), if (!hubdev->hdi_flush_nasid_list.widget_p)
GFP_KERNEL); BUG();
memset(hubdev->hdi_flush_nasid_list.widget_p, 0x0,
(HUB_WIDGET_ID_MAX + 1) *
sizeof(struct sn_flush_device_kernel *));
for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) { for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) {
sn_flush_device_kernel = kmalloc(DEV_PER_WIDGET * size = DEV_PER_WIDGET *
sizeof(struct sizeof(struct sn_flush_device_kernel);
sn_flush_device_kernel), sn_flush_device_kernel = kzalloc(size, GFP_KERNEL);
GFP_KERNEL);
if (!sn_flush_device_kernel) if (!sn_flush_device_kernel)
BUG(); BUG();
memset(sn_flush_device_kernel, 0x0,
DEV_PER_WIDGET *
sizeof(struct sn_flush_device_kernel));
dev_entry = sn_flush_device_kernel; dev_entry = sn_flush_device_kernel;
for (device = 0; device < DEV_PER_WIDGET; for (device = 0; device < DEV_PER_WIDGET;
device++,dev_entry++) { device++,dev_entry++) {
dev_entry->common = kmalloc(sizeof(struct size = sizeof(struct sn_flush_device_common);
sn_flush_device_common), dev_entry->common = kzalloc(size, GFP_KERNEL);
GFP_KERNEL);
if (!dev_entry->common) if (!dev_entry->common)
BUG(); BUG();
memset(dev_entry->common, 0x0, sizeof(struct
sn_flush_device_common));
if (sn_prom_feature_available( if (sn_prom_feature_available(
PRF_DEVICE_FLUSH_LIST)) PRF_DEVICE_FLUSH_LIST))
status = sal_get_device_dmaflush_list( status = sal_get_device_dmaflush_list(
nasid, nasid, widget, device,
widget,
device,
(u64)(dev_entry->common)); (u64)(dev_entry->common));
else else
status = sn_device_fixup_war(nasid, status = sn_device_fixup_war(nasid,
widget, widget, device,
device,
dev_entry->common); dev_entry->common);
if (status != SALRET_OK) if (status != SALRET_OK)
panic("SAL call failed: %s\n", panic("SAL call failed: %s\n",
...@@ -383,13 +372,12 @@ void sn_pci_fixup_slot(struct pci_dev *dev) ...@@ -383,13 +372,12 @@ void sn_pci_fixup_slot(struct pci_dev *dev)
pci_dev_get(dev); /* for the sysdata pointer */ pci_dev_get(dev); /* for the sysdata pointer */
pcidev_info = kzalloc(sizeof(struct pcidev_info), GFP_KERNEL); pcidev_info = kzalloc(sizeof(struct pcidev_info), GFP_KERNEL);
if (pcidev_info <= 0) if (!pcidev_info)
BUG(); /* Cannot afford to run out of memory */ BUG(); /* Cannot afford to run out of memory */
sn_irq_info = kmalloc(sizeof(struct sn_irq_info), GFP_KERNEL); sn_irq_info = kzalloc(sizeof(struct sn_irq_info), GFP_KERNEL);
if (sn_irq_info <= 0) if (!sn_irq_info)
BUG(); /* Cannot afford to run out of memory */ BUG(); /* Cannot afford to run out of memory */
memset(sn_irq_info, 0, sizeof(struct sn_irq_info));
/* Call to retrieve pci device information needed by kernel. */ /* Call to retrieve pci device information needed by kernel. */
status = sal_get_pcidev_info((u64) segment, (u64) dev->bus->number, 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,13 +470,13 @@ void sn_pci_fixup_slot(struct pci_dev *dev)
*/ */
void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus) void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
{ {
int status = 0; int status;
int nasid, cnode; int nasid, cnode;
struct pci_controller *controller; struct pci_controller *controller;
struct sn_pci_controller *sn_controller; struct sn_pci_controller *sn_controller;
struct pcibus_bussoft *prom_bussoft_ptr; struct pcibus_bussoft *prom_bussoft_ptr;
struct hubdev_info *hubdev_info; struct hubdev_info *hubdev_info;
void *provider_soft = NULL; void *provider_soft;
struct sn_pcibus_provider *provider; struct sn_pcibus_provider *provider;
status = sal_get_pcibus_info((u64) segment, (u64) busnum, 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,6 +523,8 @@ void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
bus->sysdata = controller; bus->sysdata = controller;
if (provider->bus_fixup) if (provider->bus_fixup)
provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr, controller); provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr, controller);
else
provider_soft = NULL;
if (provider_soft == NULL) { if (provider_soft == NULL) {
/* fixup failed or not applicable */ /* fixup failed or not applicable */
...@@ -638,13 +628,8 @@ void sn_bus_free_sysdata(void) ...@@ -638,13 +628,8 @@ void sn_bus_free_sysdata(void)
static int __init sn_pci_init(void) static int __init sn_pci_init(void)
{ {
int i = 0; int i, j;
int j = 0;
struct pci_dev *pci_dev = NULL; struct pci_dev *pci_dev = NULL;
extern void sn_init_cpei_timer(void);
#ifdef CONFIG_PROC_FS
extern void register_sn_procfs(void);
#endif
if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM()) if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM())
return 0; return 0;
...@@ -700,32 +685,29 @@ static int __init sn_pci_init(void) ...@@ -700,32 +685,29 @@ static int __init sn_pci_init(void)
*/ */
void hubdev_init_node(nodepda_t * npda, cnodeid_t node) void hubdev_init_node(nodepda_t * npda, cnodeid_t node)
{ {
struct hubdev_info *hubdev_info; struct hubdev_info *hubdev_info;
int size;
pg_data_t *pg;
size = sizeof(struct hubdev_info);
if (node >= num_online_nodes()) /* Headless/memless IO nodes */ if (node >= num_online_nodes()) /* Headless/memless IO nodes */
hubdev_info = pg = NODE_DATA(0);
(struct hubdev_info *)alloc_bootmem_node(NODE_DATA(0),
sizeof(struct
hubdev_info));
else else
hubdev_info = pg = NODE_DATA(node);
(struct hubdev_info *)alloc_bootmem_node(NODE_DATA(node),
sizeof(struct
hubdev_info));
npda->pdinfo = (void *)hubdev_info;
hubdev_info = (struct hubdev_info *)alloc_bootmem_node(pg, size);
npda->pdinfo = (void *)hubdev_info;
} }
geoid_t geoid_t
cnodeid_get_geoid(cnodeid_t cnode) cnodeid_get_geoid(cnodeid_t cnode)
{ {
struct hubdev_info *hubdev; struct hubdev_info *hubdev;
hubdev = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo); hubdev = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
return hubdev->hdi_geoid; return hubdev->hdi_geoid;
} }
subsys_initcall(sn_pci_init); subsys_initcall(sn_pci_init);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* License. See the file "COPYING" in the main directory of this archive * License. See the file "COPYING" in the main directory of this archive
* for more details. * for more details.
* *
* Copyright (C) 1999,2001-2004 Silicon Graphics, Inc. All Rights Reserved. * Copyright (C) 1999,2001-2004, 2006 Silicon Graphics, Inc. All Rights Reserved.
* *
* Module to export the system's Firmware Interface Tables, including * Module to export the system's Firmware Interface Tables, including
* PROM revision numbers and banners, in /proc * PROM revision numbers and banners, in /proc
...@@ -190,7 +190,7 @@ static int ...@@ -190,7 +190,7 @@ static int
read_version_entry(char *page, char **start, off_t off, int count, int *eof, read_version_entry(char *page, char **start, off_t off, int count, int *eof,
void *data) void *data)
{ {
int len = 0; int len;
/* data holds the NASID of the node */ /* data holds the NASID of the node */
len = dump_version(page, (unsigned long)data); len = dump_version(page, (unsigned long)data);
...@@ -202,7 +202,7 @@ static int ...@@ -202,7 +202,7 @@ static int
read_fit_entry(char *page, char **start, off_t off, int count, int *eof, read_fit_entry(char *page, char **start, off_t off, int count, int *eof,
void *data) void *data)
{ {
int len = 0; int len;
/* data holds the NASID of the node */ /* data holds the NASID of the node */
len = dump_fit(page, (unsigned long)data); len = dump_fit(page, (unsigned long)data);
...@@ -229,13 +229,16 @@ int __init prominfo_init(void) ...@@ -229,13 +229,16 @@ int __init prominfo_init(void)
struct proc_dir_entry *p; struct proc_dir_entry *p;
cnodeid_t cnodeid; cnodeid_t cnodeid;
unsigned long nasid; unsigned long nasid;
int size;
char name[NODE_NAME_LEN]; char name[NODE_NAME_LEN];
if (!ia64_platform_is("sn2")) if (!ia64_platform_is("sn2"))
return 0; return 0;
proc_entries = kmalloc(num_online_nodes() * sizeof(struct proc_dir_entry *), size = num_online_nodes() * sizeof(struct proc_dir_entry *);
GFP_KERNEL); proc_entries = kzalloc(size, GFP_KERNEL);
if (!proc_entries)
return -ENOMEM;
sgi_prominfo_entry = proc_mkdir("sgi_prominfo", NULL); sgi_prominfo_entry = proc_mkdir("sgi_prominfo", NULL);
...@@ -244,14 +247,12 @@ int __init prominfo_init(void) ...@@ -244,14 +247,12 @@ int __init prominfo_init(void)
sprintf(name, "node%d", cnodeid); sprintf(name, "node%d", cnodeid);
*entp = proc_mkdir(name, sgi_prominfo_entry); *entp = proc_mkdir(name, sgi_prominfo_entry);
nasid = cnodeid_to_nasid(cnodeid); nasid = cnodeid_to_nasid(cnodeid);
p = create_proc_read_entry( p = create_proc_read_entry("fit", 0, *entp, read_fit_entry,
"fit", 0, *entp, read_fit_entry,
(void *)nasid); (void *)nasid);
if (p) if (p)
p->owner = THIS_MODULE; p->owner = THIS_MODULE;
p = create_proc_read_entry( p = create_proc_read_entry("version", 0, *entp,
"version", 0, *entp, read_version_entry, read_version_entry, (void *)nasid);
(void *)nasid);
if (p) if (p)
p->owner = THIS_MODULE; p->owner = THIS_MODULE;
entp++; entp++;
...@@ -263,7 +264,7 @@ int __init prominfo_init(void) ...@@ -263,7 +264,7 @@ int __init prominfo_init(void)
void __exit prominfo_exit(void) void __exit prominfo_exit(void)
{ {
struct proc_dir_entry **entp; struct proc_dir_entry **entp;
unsigned cnodeid; unsigned int cnodeid;
char name[NODE_NAME_LEN]; char name[NODE_NAME_LEN];
entp = proc_entries; entp = proc_entries;
......
...@@ -46,7 +46,13 @@ DECLARE_PER_CPU(struct ptc_stats, ptcstats); ...@@ -46,7 +46,13 @@ DECLARE_PER_CPU(struct ptc_stats, ptcstats);
static __cacheline_aligned DEFINE_SPINLOCK(sn2_global_ptc_lock); static __cacheline_aligned DEFINE_SPINLOCK(sn2_global_ptc_lock);
void sn2_ptc_deadlock_recovery(short *, short, short, int, volatile unsigned long *, unsigned long, extern unsigned long
sn2_ptc_deadlock_recovery_core(volatile unsigned long *, unsigned long,
volatile unsigned long *, unsigned long,
volatile unsigned long *, unsigned long);
void
sn2_ptc_deadlock_recovery(short *, short, short, int,
volatile unsigned long *, unsigned long,
volatile unsigned long *, unsigned long); volatile unsigned long *, unsigned long);
/* /*
...@@ -59,16 +65,6 @@ void sn2_ptc_deadlock_recovery(short *, short, short, int, volatile unsigned lon ...@@ -59,16 +65,6 @@ void sn2_ptc_deadlock_recovery(short *, short, short, int, volatile unsigned lon
#define reset_max_active_on_deadlock() 1 #define reset_max_active_on_deadlock() 1
#define PTC_LOCK(sh1) ((sh1) ? &sn2_global_ptc_lock : &sn_nodepda->ptc_lock) #define PTC_LOCK(sh1) ((sh1) ? &sn2_global_ptc_lock : &sn_nodepda->ptc_lock)
static inline void ptc_lock(int sh1, unsigned long *flagp)
{
spin_lock_irqsave(PTC_LOCK(sh1), *flagp);
}
static inline void ptc_unlock(int sh1, unsigned long flags)
{
spin_unlock_irqrestore(PTC_LOCK(sh1), flags);
}
struct ptc_stats { struct ptc_stats {
unsigned long ptc_l; unsigned long ptc_l;
unsigned long change_rid; unsigned long change_rid;
...@@ -82,6 +78,8 @@ struct ptc_stats { ...@@ -82,6 +78,8 @@ struct ptc_stats {
unsigned long shub_ptc_flushes_not_my_mm; unsigned long shub_ptc_flushes_not_my_mm;
}; };
#define sn2_ptctest 0
static inline unsigned long wait_piowc(void) static inline unsigned long wait_piowc(void)
{ {
volatile unsigned long *piows; volatile unsigned long *piows;
...@@ -200,7 +198,7 @@ sn2_global_tlb_purge(struct mm_struct *mm, unsigned long start, ...@@ -200,7 +198,7 @@ sn2_global_tlb_purge(struct mm_struct *mm, unsigned long start,
max_active = max_active_pio(shub1); max_active = max_active_pio(shub1);
itc = ia64_get_itc(); itc = ia64_get_itc();
ptc_lock(shub1, &flags); spin_lock_irqsave(PTC_LOCK(shub1), flags);
itc2 = ia64_get_itc(); itc2 = ia64_get_itc();
__get_cpu_var(ptcstats).lock_itc_clocks += itc2 - itc; __get_cpu_var(ptcstats).lock_itc_clocks += itc2 - itc;
...@@ -258,7 +256,7 @@ sn2_global_tlb_purge(struct mm_struct *mm, unsigned long start, ...@@ -258,7 +256,7 @@ sn2_global_tlb_purge(struct mm_struct *mm, unsigned long start,
ia64_srlz_d(); ia64_srlz_d();
} }
ptc_unlock(shub1, flags); spin_unlock_irqrestore(PTC_LOCK(shub1), flags);
preempt_enable(); preempt_enable();
} }
...@@ -270,11 +268,12 @@ sn2_global_tlb_purge(struct mm_struct *mm, unsigned long start, ...@@ -270,11 +268,12 @@ sn2_global_tlb_purge(struct mm_struct *mm, unsigned long start,
* TLB flush transaction. The recovery sequence is somewhat tricky & is * TLB flush transaction. The recovery sequence is somewhat tricky & is
* coded in assembly language. * coded in assembly language.
*/ */
void sn2_ptc_deadlock_recovery(short *nasids, short ib, short ie, int mynasid, volatile unsigned long *ptc0, unsigned long data0,
void
sn2_ptc_deadlock_recovery(short *nasids, short ib, short ie, int mynasid,
volatile unsigned long *ptc0, unsigned long data0,
volatile unsigned long *ptc1, unsigned long data1) volatile unsigned long *ptc1, unsigned long data1)
{ {
extern unsigned long sn2_ptc_deadlock_recovery_core(volatile unsigned long *, unsigned long,
volatile unsigned long *, unsigned long, volatile unsigned long *, unsigned long);
short nasid, i; short nasid, i;
unsigned long *piows, zeroval, n; unsigned long *piows, zeroval, n;
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
* Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved. * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved.
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <asm/uaccess.h>
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <asm/uaccess.h>
#include <asm/sn/sn_sal.h> #include <asm/sn/sn_sal.h>
static int partition_id_show(struct seq_file *s, void *p) static int partition_id_show(struct seq_file *s, void *p)
...@@ -90,8 +90,8 @@ static int coherence_id_open(struct inode *inode, struct file *file) ...@@ -90,8 +90,8 @@ static int coherence_id_open(struct inode *inode, struct file *file)
return single_open(file, coherence_id_show, NULL); return single_open(file, coherence_id_show, NULL);
} }
static struct proc_dir_entry *sn_procfs_create_entry( static struct proc_dir_entry
const char *name, struct proc_dir_entry *parent, *sn_procfs_create_entry(const char *name, struct proc_dir_entry *parent,
int (*openfunc)(struct inode *, struct file *), int (*openfunc)(struct inode *, struct file *),
int (*releasefunc)(struct inode *, struct file *)) int (*releasefunc)(struct inode *, struct file *))
{ {
......
...@@ -284,12 +284,10 @@ struct sn_irq_info *tiocx_irq_alloc(nasid_t nasid, int widget, int irq, ...@@ -284,12 +284,10 @@ struct sn_irq_info *tiocx_irq_alloc(nasid_t nasid, int widget, int irq,
if ((nasid & 1) == 0) if ((nasid & 1) == 0)
return NULL; return NULL;
sn_irq_info = kmalloc(sn_irq_size, GFP_KERNEL); sn_irq_info = kzalloc(sn_irq_size, GFP_KERNEL);
if (sn_irq_info == NULL) if (sn_irq_info == NULL)
return NULL; return NULL;
memset(sn_irq_info, 0x0, sn_irq_size);
status = tiocx_intr_alloc(nasid, widget, __pa(sn_irq_info), irq, status = tiocx_intr_alloc(nasid, widget, __pa(sn_irq_info), irq,
req_nasid, slice); req_nasid, slice);
if (status) { if (status) {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* License. See the file "COPYING" in the main directory of this archive * License. See the file "COPYING" in the main directory of this archive
* for more details. * for more details.
* *
* Copyright (C) 2001-2004 Silicon Graphics, Inc. All rights reserved. * Copyright (C) 2001-2006 Silicon Graphics, Inc. All rights reserved.
*/ */
#include <linux/types.h> #include <linux/types.h>
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <asm/sn/pcibus_provider_defs.h> #include <asm/sn/pcibus_provider_defs.h>
#include <asm/sn/pcidev.h> #include <asm/sn/pcidev.h>
int pcibr_invalidate_ate = 0; /* by default don't invalidate ATE on free */ int pcibr_invalidate_ate; /* by default don't invalidate ATE on free */
/* /*
* mark_ate: Mark the ate as either free or inuse. * mark_ate: Mark the ate as either free or inuse.
...@@ -20,14 +20,12 @@ int pcibr_invalidate_ate = 0; /* by default don't invalidate ATE on free */ ...@@ -20,14 +20,12 @@ int pcibr_invalidate_ate = 0; /* by default don't invalidate ATE on free */
static void mark_ate(struct ate_resource *ate_resource, int start, int number, static void mark_ate(struct ate_resource *ate_resource, int start, int number,
u64 value) u64 value)
{ {
u64 *ate = ate_resource->ate; u64 *ate = ate_resource->ate;
int index; int index;
int length = 0; int length = 0;
for (index = start; length < number; index++, length++) for (index = start; length < number; index++, length++)
ate[index] = value; ate[index] = value;
} }
/* /*
...@@ -37,7 +35,6 @@ static void mark_ate(struct ate_resource *ate_resource, int start, int number, ...@@ -37,7 +35,6 @@ static void mark_ate(struct ate_resource *ate_resource, int start, int number,
static int find_free_ate(struct ate_resource *ate_resource, int start, static int find_free_ate(struct ate_resource *ate_resource, int start,
int count) int count)
{ {
u64 *ate = ate_resource->ate; u64 *ate = ate_resource->ate;
int index; int index;
int start_free; int start_free;
...@@ -70,12 +67,10 @@ static int find_free_ate(struct ate_resource *ate_resource, int start, ...@@ -70,12 +67,10 @@ static int find_free_ate(struct ate_resource *ate_resource, int start,
static inline void free_ate_resource(struct ate_resource *ate_resource, static inline void free_ate_resource(struct ate_resource *ate_resource,
int start) int start)
{ {
mark_ate(ate_resource, start, ate_resource->ate[start], 0); mark_ate(ate_resource, start, ate_resource->ate[start], 0);
if ((ate_resource->lowest_free_index > start) || if ((ate_resource->lowest_free_index > start) ||
(ate_resource->lowest_free_index < 0)) (ate_resource->lowest_free_index < 0))
ate_resource->lowest_free_index = start; ate_resource->lowest_free_index = start;
} }
/* /*
...@@ -84,7 +79,6 @@ static inline void free_ate_resource(struct ate_resource *ate_resource, ...@@ -84,7 +79,6 @@ static inline void free_ate_resource(struct ate_resource *ate_resource,
static inline int alloc_ate_resource(struct ate_resource *ate_resource, static inline int alloc_ate_resource(struct ate_resource *ate_resource,
int ate_needed) int ate_needed)
{ {
int start_index; int start_index;
/* /*
...@@ -118,19 +112,12 @@ static inline int alloc_ate_resource(struct ate_resource *ate_resource, ...@@ -118,19 +112,12 @@ static inline int alloc_ate_resource(struct ate_resource *ate_resource,
*/ */
int pcibr_ate_alloc(struct pcibus_info *pcibus_info, int count) int pcibr_ate_alloc(struct pcibus_info *pcibus_info, int count)
{ {
int status = 0; int status;
u64 flag; unsigned long flags;
flag = pcibr_lock(pcibus_info); spin_lock_irqsave(&pcibus_info->pbi_lock, flags);
status = alloc_ate_resource(&pcibus_info->pbi_int_ate_resource, count); status = alloc_ate_resource(&pcibus_info->pbi_int_ate_resource, count);
spin_unlock_irqrestore(&pcibus_info->pbi_lock, flags);
if (status < 0) {
/* Failed to allocate */
pcibr_unlock(pcibus_info, flag);
return -1;
}
pcibr_unlock(pcibus_info, flag);
return status; return status;
} }
...@@ -182,7 +169,7 @@ void pcibr_ate_free(struct pcibus_info *pcibus_info, int index) ...@@ -182,7 +169,7 @@ void pcibr_ate_free(struct pcibus_info *pcibus_info, int index)
ate_write(pcibus_info, index, count, (ate & ~PCI32_ATE_V)); ate_write(pcibus_info, index, count, (ate & ~PCI32_ATE_V));
} }
flags = pcibr_lock(pcibus_info); spin_lock_irqsave(&pcibus_info->pbi_lock, flags);
free_ate_resource(&pcibus_info->pbi_int_ate_resource, index); free_ate_resource(&pcibus_info->pbi_int_ate_resource, index);
pcibr_unlock(pcibus_info, flags); spin_unlock_irqrestore(&pcibus_info->pbi_lock, flags);
} }
...@@ -137,14 +137,12 @@ pcibr_dmatrans_direct64(struct pcidev_info * info, u64 paddr, ...@@ -137,14 +137,12 @@ pcibr_dmatrans_direct64(struct pcidev_info * info, u64 paddr,
pci_addr |= PCI64_ATTR_VIRTUAL; pci_addr |= PCI64_ATTR_VIRTUAL;
return pci_addr; return pci_addr;
} }
static dma_addr_t static dma_addr_t
pcibr_dmatrans_direct32(struct pcidev_info * info, pcibr_dmatrans_direct32(struct pcidev_info * info,
u64 paddr, size_t req_size, u64 flags) u64 paddr, size_t req_size, u64 flags)
{ {
struct pcidev_info *pcidev_info = info->pdi_host_pcidev_info; struct pcidev_info *pcidev_info = info->pdi_host_pcidev_info;
struct pcibus_info *pcibus_info = (struct pcibus_info *)pcidev_info-> struct pcibus_info *pcibus_info = (struct pcibus_info *)pcidev_info->
pdi_pcibus_info; pdi_pcibus_info;
...@@ -171,7 +169,6 @@ pcibr_dmatrans_direct32(struct pcidev_info * info, ...@@ -171,7 +169,6 @@ pcibr_dmatrans_direct32(struct pcidev_info * info,
} }
return PCI32_DIRECT_BASE | offset; return PCI32_DIRECT_BASE | offset;
} }
/* /*
...@@ -218,9 +215,8 @@ void sn_dma_flush(u64 addr) ...@@ -218,9 +215,8 @@ void sn_dma_flush(u64 addr)
u64 flags; u64 flags;
u64 itte; u64 itte;
struct hubdev_info *hubinfo; struct hubdev_info *hubinfo;
volatile struct sn_flush_device_kernel *p; struct sn_flush_device_kernel *p;
volatile struct sn_flush_device_common *common; struct sn_flush_device_common *common;
struct sn_flush_nasid_entry *flush_nasid_list; struct sn_flush_nasid_entry *flush_nasid_list;
if (!sn_ioif_inited) if (!sn_ioif_inited)
...@@ -310,8 +306,7 @@ void sn_dma_flush(u64 addr) ...@@ -310,8 +306,7 @@ void sn_dma_flush(u64 addr)
(common->sfdl_slot - 1)); (common->sfdl_slot - 1));
} }
} else { } else {
spin_lock_irqsave((spinlock_t *)&p->sfdl_flush_lock, spin_lock_irqsave(&p->sfdl_flush_lock, flags);
flags);
*common->sfdl_flush_addr = 0; *common->sfdl_flush_addr = 0;
/* force an interrupt. */ /* force an interrupt. */
...@@ -322,8 +317,7 @@ void sn_dma_flush(u64 addr) ...@@ -322,8 +317,7 @@ void sn_dma_flush(u64 addr)
cpu_relax(); cpu_relax();
/* okay, everything is synched up. */ /* okay, everything is synched up. */
spin_unlock_irqrestore((spinlock_t *)&p->sfdl_flush_lock, spin_unlock_irqrestore(&p->sfdl_flush_lock, flags);
flags);
} }
return; return;
} }
......
...@@ -163,9 +163,12 @@ pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont ...@@ -163,9 +163,12 @@ pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
/* Setup the PMU ATE map */ /* Setup the PMU ATE map */
soft->pbi_int_ate_resource.lowest_free_index = 0; soft->pbi_int_ate_resource.lowest_free_index = 0;
soft->pbi_int_ate_resource.ate = soft->pbi_int_ate_resource.ate =
kmalloc(soft->pbi_int_ate_size * sizeof(u64), GFP_KERNEL); kzalloc(soft->pbi_int_ate_size * sizeof(u64), GFP_KERNEL);
memset(soft->pbi_int_ate_resource.ate, 0,
(soft->pbi_int_ate_size * sizeof(u64))); if (!soft->pbi_int_ate_resource.ate) {
kfree(soft);
return NULL;
}
if (prom_bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCP) { if (prom_bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCP) {
/* TIO PCI Bridge: find nearest node with CPUs */ /* TIO PCI Bridge: find nearest node with CPUs */
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#define BTES_PER_NODE (is_shub2() ? 4 : 2) #define BTES_PER_NODE (is_shub2() ? 4 : 2)
#define MAX_BTES_PER_NODE 4 #define MAX_BTES_PER_NODE 4
#define BTE2OFF_CTRL (0) #define BTE2OFF_CTRL 0
#define BTE2OFF_SRC (SH2_BT_ENG_SRC_ADDR_0 - SH2_BT_ENG_CSR_0) #define BTE2OFF_SRC (SH2_BT_ENG_SRC_ADDR_0 - SH2_BT_ENG_CSR_0)
#define BTE2OFF_DEST (SH2_BT_ENG_DEST_ADDR_0 - SH2_BT_ENG_CSR_0) #define BTE2OFF_DEST (SH2_BT_ENG_DEST_ADDR_0 - SH2_BT_ENG_CSR_0)
#define BTE2OFF_NOTIFY (SH2_BT_ENG_NOTIF_ADDR_0 - SH2_BT_ENG_CSR_0) #define BTE2OFF_NOTIFY (SH2_BT_ENG_NOTIF_ADDR_0 - SH2_BT_ENG_CSR_0)
...@@ -75,11 +75,11 @@ ...@@ -75,11 +75,11 @@
: base + (BTEOFF_NOTIFY/8)) : base + (BTEOFF_NOTIFY/8))
/* Define hardware modes */ /* Define hardware modes */
#define BTE_NOTIFY (IBCT_NOTIFY) #define BTE_NOTIFY IBCT_NOTIFY
#define BTE_NORMAL BTE_NOTIFY #define BTE_NORMAL BTE_NOTIFY
#define BTE_ZERO_FILL (BTE_NOTIFY | IBCT_ZFIL_MODE) #define BTE_ZERO_FILL (BTE_NOTIFY | IBCT_ZFIL_MODE)
/* Use a reserved bit to let the caller specify a wait for any BTE */ /* Use a reserved bit to let the caller specify a wait for any BTE */
#define BTE_WACQUIRE (0x4000) #define BTE_WACQUIRE 0x4000
/* Use the BTE on the node with the destination memory */ /* Use the BTE on the node with the destination memory */
#define BTE_USE_DEST (BTE_WACQUIRE << 1) #define BTE_USE_DEST (BTE_WACQUIRE << 1)
/* Use any available BTE interface on any node for the transfer */ /* Use any available BTE interface on any node for the transfer */
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* License. See the file "COPYING" in the main directory of this archive * License. See the file "COPYING" in the main directory of this archive
* for more details. * for more details.
* *
* Copyright (C) 1992-1997,2000-2004 Silicon Graphics, Inc. All rights reserved. * Copyright (C) 1992-1997,2000-2006 Silicon Graphics, Inc. All rights reserved.
*/ */
#ifndef _ASM_IA64_SN_PCI_PCIBR_PROVIDER_H #ifndef _ASM_IA64_SN_PCI_PCIBR_PROVIDER_H
#define _ASM_IA64_SN_PCI_PCIBR_PROVIDER_H #define _ASM_IA64_SN_PCI_PCIBR_PROVIDER_H
...@@ -115,18 +115,6 @@ struct pcibus_info { ...@@ -115,18 +115,6 @@ struct pcibus_info {
spinlock_t pbi_lock; spinlock_t pbi_lock;
}; };
/*
* pcibus_info structure locking macros
*/
inline static unsigned long
pcibr_lock(struct pcibus_info *pcibus_info)
{
unsigned long flag;
spin_lock_irqsave(&pcibus_info->pbi_lock, flag);
return(flag);
}
#define pcibr_unlock(pcibus_info, flag) spin_unlock_irqrestore(&pcibus_info->pbi_lock, flag)
extern int pcibr_init_provider(void); extern int pcibr_init_provider(void);
extern void *pcibr_bus_fixup(struct pcibus_bussoft *, struct pci_controller *); extern void *pcibr_bus_fixup(struct pcibus_bussoft *, struct pci_controller *);
extern dma_addr_t pcibr_dma_map(struct pci_dev *, unsigned long, size_t); extern dma_addr_t pcibr_dma_map(struct pci_dev *, unsigned long, size_t);
......
...@@ -12,9 +12,6 @@ ...@@ -12,9 +12,6 @@
*/ */
#include <asm/types.h>
#include <asm/bitops.h>
/* --------------------- PROM Features -----------------------------*/ /* --------------------- PROM Features -----------------------------*/
extern int sn_prom_feature_available(int id); extern int sn_prom_feature_available(int id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment