📄 io_init.c
字号:
/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1992 - 1997, 2000-2005 Silicon Graphics, Inc. All rights reserved. */#include <linux/bootmem.h>#include <linux/nodemask.h>#ifdef XEN#include <linux/init.h>#endif#include <asm/sn/types.h>#include <asm/sn/addrs.h>#include <asm/sn/sn_feature_sets.h>#include <asm/sn/geo.h>#include <asm/sn/io.h>#include <asm/sn/l1.h>#include <asm/sn/module.h>#include <asm/sn/pcibr_provider.h>#include <asm/sn/pcibus_provider_defs.h>#include <asm/sn/pcidev.h>#include <asm/sn/simulator.h>#include <asm/sn/sn_sal.h>#ifndef XEN#include <asm/sn/tioca_provider.h>#include <asm/sn/tioce_provider.h>#endif#ifdef XEN#include "asm/sn/hubdev.h"#include "asm/sn/xwidgetdev.h"#else#include "xtalk/hubdev.h"#include "xtalk/xwidgetdev.h"#endifextern void sn_init_cpei_timer(void);extern void register_sn_procfs(void);#ifdef XEN#define pci_dev_get(dev) do{}while(0)extern void sn_irq_lh_init(void);#endifstatic struct list_head sn_sysdata_list;/* sysdata list struct */struct sysdata_el { struct list_head entry; void *sysdata;};struct slab_info { struct hubdev_info hubdev;};struct brick { moduleid_t id; /* Module ID of this module */ struct slab_info slab_info[MAX_SLABS + 1];};int sn_ioif_inited; /* SN I/O infrastructure initialized? */struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES]; /* indexed by asic type */static int max_segment_number; /* Default highest segment number */static int max_pcibus_number = 255; /* Default highest pci bus number *//* * Hooks and struct for unsupported pci providers */static dma_addr_tsn_default_pci_map(struct pci_dev *pdev, unsigned long paddr, size_t size, int type){ return 0;}static voidsn_default_pci_unmap(struct pci_dev *pdev, dma_addr_t addr, int direction){ return;}static void *sn_default_pci_bus_fixup(struct pcibus_bussoft *soft, struct pci_controller *controller){ return NULL;}static struct sn_pcibus_provider sn_pci_default_provider = { .dma_map = sn_default_pci_map, .dma_map_consistent = sn_default_pci_map, .dma_unmap = sn_default_pci_unmap, .bus_fixup = sn_default_pci_bus_fixup,};/* * Retrieve the DMA Flush List given nasid, widget, and device. * This list is needed to implement the WAR - Flush DMA data on PIO Reads. */static inline u64sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num, u64 address){ struct ia64_sal_retval ret_stuff; ret_stuff.status = 0; ret_stuff.v0 = 0; SAL_CALL_NOLOCK(ret_stuff, (u64) SN_SAL_IOIF_GET_DEVICE_DMAFLUSH_LIST, (u64) nasid, (u64) widget_num, (u64) device_num, (u64) address, 0, 0, 0); return ret_stuff.status;}/* * Retrieve the hub device info structure for the given nasid. */static inline u64 sal_get_hubdev_info(u64 handle, u64 address){ struct ia64_sal_retval ret_stuff; ret_stuff.status = 0; ret_stuff.v0 = 0; SAL_CALL_NOLOCK(ret_stuff, (u64) SN_SAL_IOIF_GET_HUBDEV_INFO, (u64) handle, (u64) address, 0, 0, 0, 0, 0); return ret_stuff.v0;}/* * Retrieve the pci bus information given the bus number. */static inline u64 sal_get_pcibus_info(u64 segment, u64 busnum, u64 address){ struct ia64_sal_retval ret_stuff; ret_stuff.status = 0; ret_stuff.v0 = 0; SAL_CALL_NOLOCK(ret_stuff, (u64) SN_SAL_IOIF_GET_PCIBUS_INFO, (u64) segment, (u64) busnum, (u64) address, 0, 0, 0, 0); return ret_stuff.v0;}/* * Retrieve the pci device information given the bus and device|function number. */static inline u64sal_get_pcidev_info(u64 segment, u64 bus_number, u64 devfn, u64 pci_dev, u64 sn_irq_info){ struct ia64_sal_retval ret_stuff; ret_stuff.status = 0; ret_stuff.v0 = 0; SAL_CALL_NOLOCK(ret_stuff, (u64) SN_SAL_IOIF_GET_PCIDEV_INFO, (u64) segment, (u64) bus_number, (u64) devfn, (u64) pci_dev, sn_irq_info, 0, 0); return ret_stuff.v0;}#ifndef XEN/* * sn_pcidev_info_get() - Retrieve the pcidev_info struct for the specified * device. */inline struct pcidev_info *sn_pcidev_info_get(struct pci_dev *dev){ struct pcidev_info *pcidev; list_for_each_entry(pcidev, &(SN_PCI_CONTROLLER(dev)->pcidev_info), pdi_list) { if (pcidev->pdi_linux_pcidev == dev) { return pcidev; } } return NULL;}/* Older PROM flush WAR * * 01/16/06 -- This war will be in place until a new official PROM is released. * Additionally note that the struct sn_flush_device_war also has to be * removed from arch/ia64/sn/include/xtalk/hubdev.h */static u8 war_implemented = 0;static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device, struct sn_flush_device_common *common){ struct sn_flush_device_war *war_list; struct sn_flush_device_war *dev_entry; struct ia64_sal_retval isrv = {0,0,0,0}; if (!war_implemented) { printk(KERN_WARNING "PROM version < 4.50 -- implementing old " "PROM flush WAR\n"); war_implemented = 1; } war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL); if (!war_list) BUG(); SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST, nasid, widget, __pa(war_list), 0, 0, 0 ,0); if (isrv.status) panic("sn_device_fixup_war failed: %s\n", ia64_sal_strerror(isrv.status)); dev_entry = war_list + device; memcpy(common,dev_entry, sizeof(*common)); kfree(war_list); return isrv.status;}/* * sn_fixup_ionodes() - This routine initializes the HUB data strcuture for * each node in the system. */static void __init sn_fixup_ionodes(void){ struct sn_flush_device_kernel *sn_flush_device_kernel; struct sn_flush_device_kernel *dev_entry; struct hubdev_info *hubdev; u64 status; u64 nasid; int i, widget, device, size; /* * Get SGI Specific HUB chipset information. * Inform Prom that this kernel can support domain bus numbering. */ for (i = 0; i < num_cnodes; i++) { hubdev = (struct hubdev_info *)(NODEPDA(i)->pdinfo); nasid = cnodeid_to_nasid(i); hubdev->max_segment_number = 0xffffffff; hubdev->max_pcibus_number = 0xff; status = sal_get_hubdev_info(nasid, (u64) __pa(hubdev)); if (status) continue; /* Save the largest Domain and pcibus numbers found. */ if (hubdev->max_segment_number) { /* * Dealing with a Prom that supports segments. */ max_segment_number = hubdev->max_segment_number; max_pcibus_number = hubdev->max_pcibus_number; } /* Attach the error interrupt handlers */ if (nasid & 1) ice_error_init(hubdev); else hub_error_init(hubdev); for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) hubdev->hdi_xwidget_info[widget].xwi_hubinfo = hubdev; if (!hubdev->hdi_flush_nasid_list.widget_p) continue; size = (HUB_WIDGET_ID_MAX + 1) * sizeof(struct sn_flush_device_kernel *); hubdev->hdi_flush_nasid_list.widget_p = kzalloc(size, GFP_KERNEL); if (!hubdev->hdi_flush_nasid_list.widget_p) BUG(); for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) { size = DEV_PER_WIDGET * sizeof(struct sn_flush_device_kernel); sn_flush_device_kernel = kzalloc(size, GFP_KERNEL); if (!sn_flush_device_kernel) BUG(); dev_entry = sn_flush_device_kernel; for (device = 0; device < DEV_PER_WIDGET; device++,dev_entry++) { size = sizeof(struct sn_flush_device_common); dev_entry->common = kzalloc(size, GFP_KERNEL); if (!dev_entry->common) BUG(); if (sn_prom_feature_available( PRF_DEVICE_FLUSH_LIST)) status = sal_get_device_dmaflush_list( nasid, widget, device, (u64)(dev_entry->common)); else#ifdef XEN BUG();#else status = sn_device_fixup_war(nasid, widget, device, dev_entry->common);#endif if (status != SALRET_OK) panic("SAL call failed: %s\n", ia64_sal_strerror(status)); spin_lock_init(&dev_entry->sfdl_flush_lock); } if (sn_flush_device_kernel) hubdev->hdi_flush_nasid_list.widget_p[widget] = sn_flush_device_kernel; } }}/* * sn_pci_window_fixup() - Create a pci_window for each device resource. * Until ACPI support is added, we need this code * to setup pci_windows for use by * pcibios_bus_to_resource(), * pcibios_resource_to_bus(), etc. */static voidsn_pci_window_fixup(struct pci_dev *dev, unsigned int count, s64 * pci_addrs){ struct pci_controller *controller = PCI_CONTROLLER(dev->bus); unsigned int i; unsigned int idx; unsigned int new_count; struct pci_window *new_window; if (count == 0) return; idx = controller->windows; new_count = controller->windows + count; new_window = kcalloc(new_count, sizeof(struct pci_window), GFP_KERNEL); if (new_window == NULL) BUG(); if (controller->window) { memcpy(new_window, controller->window, sizeof(struct pci_window) * controller->windows); kfree(controller->window); } /* Setup a pci_window for each device resource. */ for (i = 0; i <= PCI_ROM_RESOURCE; i++) { if (pci_addrs[i] == -1) continue; new_window[idx].offset = dev->resource[i].start - pci_addrs[i]; new_window[idx].resource = dev->resource[i]; idx++; } controller->windows = new_count; controller->window = new_window;}void sn_pci_unfixup_slot(struct pci_dev *dev){ struct pci_dev *host_pci_dev = SN_PCIDEV_INFO(dev)->host_pci_dev; sn_irq_unfixup(dev); pci_dev_put(host_pci_dev); pci_dev_put(dev);}#endif#ifndef XEN/* * 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. */void sn_pci_fixup_slot(struct pci_dev *dev){ unsigned int count = 0; int idx; int segment = pci_domain_nr(dev->bus); int status = 0; struct pcibus_bussoft *bs; struct pci_bus *host_pci_bus; struct pci_dev *host_pci_dev; struct pcidev_info *pcidev_info; s64 pci_addrs[PCI_ROM_RESOURCE + 1]; struct sn_irq_info *sn_irq_info; unsigned long size; unsigned int bus_no, devfn; pci_dev_get(dev); /* for the sysdata pointer */ pcidev_info = kzalloc(sizeof(struct pcidev_info), GFP_KERNEL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -