io_common.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2006 Silicon Graphics, Inc. All rights reserved.
  7. */
  8. #include <linux/bootmem.h>
  9. #include <asm/sn/types.h>
  10. #include <asm/sn/addrs.h>
  11. #include <asm/sn/sn_feature_sets.h>
  12. #include <asm/sn/geo.h>
  13. #include <asm/sn/io.h>
  14. #include <asm/sn/l1.h>
  15. #include <asm/sn/module.h>
  16. #include <asm/sn/pcibr_provider.h>
  17. #include <asm/sn/pcibus_provider_defs.h>
  18. #include <asm/sn/pcidev.h>
  19. #include <asm/sn/simulator.h>
  20. #include <asm/sn/sn_sal.h>
  21. #include <asm/sn/tioca_provider.h>
  22. #include <asm/sn/tioce_provider.h>
  23. #include "xtalk/hubdev.h"
  24. #include "xtalk/xwidgetdev.h"
  25. #include <linux/acpi.h>
  26. #include <asm/sn/sn2/sn_hwperf.h>
  27. #include <asm/sn/acpi.h>
  28. extern void sn_init_cpei_timer(void);
  29. extern void register_sn_procfs(void);
  30. extern void sn_acpi_bus_fixup(struct pci_bus *);
  31. extern void sn_bus_fixup(struct pci_bus *);
  32. extern void sn_acpi_slot_fixup(struct pci_dev *, struct pcidev_info *);
  33. extern void sn_more_slot_fixup(struct pci_dev *, struct pcidev_info *);
  34. extern void sn_legacy_pci_window_fixup(struct pci_controller *, u64, u64);
  35. extern void sn_io_acpi_init(void);
  36. extern void sn_io_init(void);
  37. static struct list_head sn_sysdata_list;
  38. /* sysdata list struct */
  39. struct sysdata_el {
  40. struct list_head entry;
  41. void *sysdata;
  42. };
  43. int sn_ioif_inited; /* SN I/O infrastructure initialized? */
  44. struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES]; /* indexed by asic type */
  45. int sn_acpi_base_support(void)
  46. {
  47. struct acpi_table_header *header;
  48. (void)acpi_get_table_by_index(ACPI_TABLE_INDEX_DSDT, &header);
  49. if (header && header->oem_revision >= 0x20101)
  50. return 1;
  51. return 0;
  52. }
  53. /*
  54. * Hooks and struct for unsupported pci providers
  55. */
  56. static dma_addr_t
  57. sn_default_pci_map(struct pci_dev *pdev, unsigned long paddr, size_t size, int type)
  58. {
  59. return 0;
  60. }
  61. static void
  62. sn_default_pci_unmap(struct pci_dev *pdev, dma_addr_t addr, int direction)
  63. {
  64. return;
  65. }
  66. static void *
  67. sn_default_pci_bus_fixup(struct pcibus_bussoft *soft, struct pci_controller *controller)
  68. {
  69. return NULL;
  70. }
  71. static struct sn_pcibus_provider sn_pci_default_provider = {
  72. .dma_map = sn_default_pci_map,
  73. .dma_map_consistent = sn_default_pci_map,
  74. .dma_unmap = sn_default_pci_unmap,
  75. .bus_fixup = sn_default_pci_bus_fixup,
  76. };
  77. /*
  78. * Retrieve the DMA Flush List given nasid, widget, and device.
  79. * This list is needed to implement the WAR - Flush DMA data on PIO Reads.
  80. */
  81. static inline u64
  82. sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
  83. u64 address)
  84. {
  85. struct ia64_sal_retval ret_stuff;
  86. ret_stuff.status = 0;
  87. ret_stuff.v0 = 0;
  88. SAL_CALL_NOLOCK(ret_stuff,
  89. (u64) SN_SAL_IOIF_GET_DEVICE_DMAFLUSH_LIST,
  90. (u64) nasid, (u64) widget_num,
  91. (u64) device_num, (u64) address, 0, 0, 0);
  92. return ret_stuff.status;
  93. }
  94. /*
  95. * Retrieve the pci device information given the bus and device|function number.
  96. */
  97. static inline u64
  98. sal_get_pcidev_info(u64 segment, u64 bus_number, u64 devfn, u64 pci_dev,
  99. u64 sn_irq_info)
  100. {
  101. struct ia64_sal_retval ret_stuff;
  102. ret_stuff.status = 0;
  103. ret_stuff.v0 = 0;
  104. SAL_CALL_NOLOCK(ret_stuff,
  105. (u64) SN_SAL_IOIF_GET_PCIDEV_INFO,
  106. (u64) segment, (u64) bus_number, (u64) devfn,
  107. (u64) pci_dev,
  108. sn_irq_info, 0, 0);
  109. return ret_stuff.v0;
  110. }
  111. /*
  112. * sn_pcidev_info_get() - Retrieve the pcidev_info struct for the specified
  113. * device.
  114. */
  115. inline struct pcidev_info *
  116. sn_pcidev_info_get(struct pci_dev *dev)
  117. {
  118. struct pcidev_info *pcidev;
  119. list_for_each_entry(pcidev,
  120. &(SN_PLATFORM_DATA(dev)->pcidev_info), pdi_list) {
  121. if (pcidev->pdi_linux_pcidev == dev)
  122. return pcidev;
  123. }
  124. return NULL;
  125. }
  126. /* Older PROM flush WAR
  127. *
  128. * 01/16/06 -- This war will be in place until a new official PROM is released.
  129. * Additionally note that the struct sn_flush_device_war also has to be
  130. * removed from arch/ia64/sn/include/xtalk/hubdev.h
  131. */
  132. static u8 war_implemented = 0;
  133. static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device,
  134. struct sn_flush_device_common *common)
  135. {
  136. struct sn_flush_device_war *war_list;
  137. struct sn_flush_device_war *dev_entry;
  138. struct ia64_sal_retval isrv = {0,0,0,0};
  139. if (!war_implemented) {
  140. printk(KERN_WARNING "PROM version < 4.50 -- implementing old "
  141. "PROM flush WAR\n");
  142. war_implemented = 1;
  143. }
  144. war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL);
  145. if (!war_list)
  146. BUG();
  147. SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST,
  148. nasid, widget, __pa(war_list), 0, 0, 0 ,0);
  149. if (isrv.status)
  150. panic("sn_device_fixup_war failed: %s\n",
  151. ia64_sal_strerror(isrv.status));
  152. dev_entry = war_list + device;
  153. memcpy(common,dev_entry, sizeof(*common));
  154. kfree(war_list);
  155. return isrv.status;
  156. }
  157. /*
  158. * sn_common_hubdev_init() - This routine is called to initialize the HUB data
  159. * structure for each node in the system.
  160. */
  161. void __init
  162. sn_common_hubdev_init(struct hubdev_info *hubdev)
  163. {
  164. struct sn_flush_device_kernel *sn_flush_device_kernel;
  165. struct sn_flush_device_kernel *dev_entry;
  166. s64 status;
  167. int widget, device, size;
  168. /* Attach the error interrupt handlers */
  169. if (hubdev->hdi_nasid & 1) /* If TIO */
  170. ice_error_init(hubdev);
  171. else
  172. hub_error_init(hubdev);
  173. for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++)
  174. hubdev->hdi_xwidget_info[widget].xwi_hubinfo = hubdev;
  175. if (!hubdev->hdi_flush_nasid_list.widget_p)
  176. return;
  177. size = (HUB_WIDGET_ID_MAX + 1) *
  178. sizeof(struct sn_flush_device_kernel *);
  179. hubdev->hdi_flush_nasid_list.widget_p =
  180. kzalloc(size, GFP_KERNEL);
  181. if (!hubdev->hdi_flush_nasid_list.widget_p)
  182. BUG();
  183. for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) {
  184. size = DEV_PER_WIDGET *
  185. sizeof(struct sn_flush_device_kernel);
  186. sn_flush_device_kernel = kzalloc(size, GFP_KERNEL);
  187. if (!sn_flush_device_kernel)
  188. BUG();
  189. dev_entry = sn_flush_device_kernel;
  190. for (device = 0; device < DEV_PER_WIDGET;
  191. device++, dev_entry++) {
  192. size = sizeof(struct sn_flush_device_common);
  193. dev_entry->common = kzalloc(size, GFP_KERNEL);
  194. if (!dev_entry->common)
  195. BUG();
  196. if (sn_prom_feature_available(PRF_DEVICE_FLUSH_LIST))
  197. status = sal_get_device_dmaflush_list(
  198. hubdev->hdi_nasid, widget, device,
  199. (u64)(dev_entry->common));
  200. else
  201. status = sn_device_fixup_war(hubdev->hdi_nasid,
  202. widget, device,
  203. dev_entry->common);
  204. if (status != SALRET_OK)
  205. panic("SAL call failed: %s\n",
  206. ia64_sal_strerror(status));
  207. spin_lock_init(&dev_entry->sfdl_flush_lock);
  208. }
  209. if (sn_flush_device_kernel)
  210. hubdev->hdi_flush_nasid_list.widget_p[widget] =
  211. sn_flush_device_kernel;
  212. }
  213. }
  214. void sn_pci_unfixup_slot(struct pci_dev *dev)
  215. {
  216. struct pci_dev *host_pci_dev = SN_PCIDEV_INFO(dev)->host_pci_dev;
  217. sn_irq_unfixup(dev);
  218. pci_dev_put(host_pci_dev);
  219. pci_dev_put(dev);
  220. }
  221. /*
  222. * sn_pci_fixup_slot() - This routine sets up a slot's resources consistent
  223. * with the Linux PCI abstraction layer. Resources
  224. * acquired from our PCI provider include PIO maps
  225. * to BAR space and interrupt objects.
  226. */
  227. void sn_pci_fixup_slot(struct pci_dev *dev)
  228. {
  229. int segment = pci_domain_nr(dev->bus);
  230. int status = 0;
  231. struct pcibus_bussoft *bs;
  232. struct pci_bus *host_pci_bus;
  233. struct pci_dev *host_pci_dev;
  234. struct pcidev_info *pcidev_info;
  235. struct sn_irq_info *sn_irq_info;
  236. unsigned int bus_no, devfn;
  237. pci_dev_get(dev); /* for the sysdata pointer */
  238. pcidev_info = kzalloc(sizeof(struct pcidev_info), GFP_KERNEL);
  239. if (!pcidev_info)
  240. BUG(); /* Cannot afford to run out of memory */
  241. sn_irq_info = kzalloc(sizeof(struct sn_irq_info), GFP_KERNEL);
  242. if (!sn_irq_info)
  243. BUG(); /* Cannot afford to run out of memory */
  244. /* Call to retrieve pci device information needed by kernel. */
  245. status = sal_get_pcidev_info((u64) segment, (u64) dev->bus->number,
  246. dev->devfn,
  247. (u64) __pa(pcidev_info),
  248. (u64) __pa(sn_irq_info));
  249. if (status)
  250. BUG(); /* Cannot get platform pci device information */
  251. /* Add pcidev_info to list in pci_controller.platform_data */
  252. list_add_tail(&pcidev_info->pdi_list,
  253. &(SN_PLATFORM_DATA(dev->bus)->pcidev_info));
  254. if (SN_ACPI_BASE_SUPPORT())
  255. sn_acpi_slot_fixup(dev, pcidev_info);
  256. else
  257. sn_more_slot_fixup(dev, pcidev_info);
  258. /*
  259. * Using the PROMs values for the PCI host bus, get the Linux
  260. * PCI host_pci_dev struct and set up host bus linkages
  261. */
  262. bus_no = (pcidev_info->pdi_slot_host_handle >> 32) & 0xff;
  263. devfn = pcidev_info->pdi_slot_host_handle & 0xffffffff;
  264. host_pci_bus = pci_find_bus(segment, bus_no);
  265. host_pci_dev = pci_get_slot(host_pci_bus, devfn);
  266. pcidev_info->host_pci_dev = host_pci_dev;
  267. pcidev_info->pdi_linux_pcidev = dev;
  268. pcidev_info->pdi_host_pcidev_info = SN_PCIDEV_INFO(host_pci_dev);
  269. bs = SN_PCIBUS_BUSSOFT(dev->bus);
  270. pcidev_info->pdi_pcibus_info = bs;
  271. if (bs && bs->bs_asic_type < PCIIO_ASIC_MAX_TYPES) {
  272. SN_PCIDEV_BUSPROVIDER(dev) = sn_pci_provider[bs->bs_asic_type];
  273. } else {
  274. SN_PCIDEV_BUSPROVIDER(dev) = &sn_pci_default_provider;
  275. }
  276. /* Only set up IRQ stuff if this device has a host bus context */
  277. if (bs && sn_irq_info->irq_irq) {
  278. pcidev_info->pdi_sn_irq_info = sn_irq_info;
  279. dev->irq = pcidev_info->pdi_sn_irq_info->irq_irq;
  280. sn_irq_fixup(dev, sn_irq_info);
  281. } else {
  282. pcidev_info->pdi_sn_irq_info = NULL;
  283. kfree(sn_irq_info);
  284. }
  285. }
  286. /*
  287. * sn_common_bus_fixup - Perform platform specific bus fixup.
  288. * Execute the ASIC specific fixup routine
  289. * for this bus.
  290. */
  291. void
  292. sn_common_bus_fixup(struct pci_bus *bus,
  293. struct pcibus_bussoft *prom_bussoft_ptr)
  294. {
  295. int cnode;
  296. struct pci_controller *controller;
  297. struct hubdev_info *hubdev_info;
  298. int nasid;
  299. void *provider_soft;
  300. struct sn_pcibus_provider *provider;
  301. struct sn_platform_data *sn_platform_data;
  302. controller = PCI_CONTROLLER(bus);
  303. /*
  304. * Per-provider fixup. Copies the bus soft structure from prom
  305. * to local area and links SN_PCIBUS_BUSSOFT().
  306. */
  307. if (prom_bussoft_ptr->bs_asic_type >= PCIIO_ASIC_MAX_TYPES) {
  308. printk(KERN_WARNING "sn_common_bus_fixup: Unsupported asic type, %d",
  309. prom_bussoft_ptr->bs_asic_type);
  310. return;
  311. }
  312. if (prom_bussoft_ptr->bs_asic_type == PCIIO_ASIC_TYPE_PPB)
  313. return; /* no further fixup necessary */
  314. provider = sn_pci_provider[prom_bussoft_ptr->bs_asic_type];
  315. if (provider == NULL)
  316. panic("sn_common_bus_fixup: No provider registered for this asic type, %d",
  317. prom_bussoft_ptr->bs_asic_type);
  318. if (provider->bus_fixup)
  319. provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr,
  320. controller);
  321. else
  322. provider_soft = NULL;
  323. /*
  324. * Generic bus fixup goes here. Don't reference prom_bussoft_ptr
  325. * after this point.
  326. */
  327. controller->platform_data = kzalloc(sizeof(struct sn_platform_data),
  328. GFP_KERNEL);
  329. if (controller->platform_data == NULL)
  330. BUG();
  331. sn_platform_data =
  332. (struct sn_platform_data *) controller->platform_data;
  333. sn_platform_data->provider_soft = provider_soft;
  334. INIT_LIST_HEAD(&((struct sn_platform_data *)
  335. controller->platform_data)->pcidev_info);
  336. nasid = NASID_GET(SN_PCIBUS_BUSSOFT(bus)->bs_base);
  337. cnode = nasid_to_cnodeid(nasid);
  338. hubdev_info = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
  339. SN_PCIBUS_BUSSOFT(bus)->bs_xwidget_info =
  340. &(hubdev_info->hdi_xwidget_info[SN_PCIBUS_BUSSOFT(bus)->bs_xid]);
  341. /*
  342. * If the node information we obtained during the fixup phase is
  343. * invalid then set controller->node to -1 (undetermined)
  344. */
  345. if (controller->node >= num_online_nodes()) {
  346. struct pcibus_bussoft *b = SN_PCIBUS_BUSSOFT(bus);
  347. printk(KERN_WARNING "Device ASIC=%u XID=%u PBUSNUM=%u"
  348. "L_IO=%lx L_MEM=%lx BASE=%lx\n",
  349. b->bs_asic_type, b->bs_xid, b->bs_persist_busnum,
  350. b->bs_legacy_io, b->bs_legacy_mem, b->bs_base);
  351. printk(KERN_WARNING "on node %d but only %d nodes online."
  352. "Association set to undetermined.\n",
  353. controller->node, num_online_nodes());
  354. controller->node = -1;
  355. }
  356. }
  357. void sn_bus_store_sysdata(struct pci_dev *dev)
  358. {
  359. struct sysdata_el *element;
  360. element = kzalloc(sizeof(struct sysdata_el), GFP_KERNEL);
  361. if (!element) {
  362. dev_dbg(dev, "%s: out of memory!\n", __FUNCTION__);
  363. return;
  364. }
  365. element->sysdata = SN_PCIDEV_INFO(dev);
  366. list_add(&element->entry, &sn_sysdata_list);
  367. }
  368. void sn_bus_free_sysdata(void)
  369. {
  370. struct sysdata_el *element;
  371. struct list_head *list, *safe;
  372. list_for_each_safe(list, safe, &sn_sysdata_list) {
  373. element = list_entry(list, struct sysdata_el, entry);
  374. list_del(&element->entry);
  375. list_del(&(((struct pcidev_info *)
  376. (element->sysdata))->pdi_list));
  377. kfree(element->sysdata);
  378. kfree(element);
  379. }
  380. return;
  381. }
  382. /*
  383. * hubdev_init_node() - Creates the HUB data structure and link them to it's
  384. * own NODE specific data area.
  385. */
  386. void hubdev_init_node(nodepda_t * npda, cnodeid_t node)
  387. {
  388. struct hubdev_info *hubdev_info;
  389. int size;
  390. pg_data_t *pg;
  391. size = sizeof(struct hubdev_info);
  392. if (node >= num_online_nodes()) /* Headless/memless IO nodes */
  393. pg = NODE_DATA(0);
  394. else
  395. pg = NODE_DATA(node);
  396. hubdev_info = (struct hubdev_info *)alloc_bootmem_node(pg, size);
  397. npda->pdinfo = (void *)hubdev_info;
  398. }
  399. geoid_t
  400. cnodeid_get_geoid(cnodeid_t cnode)
  401. {
  402. struct hubdev_info *hubdev;
  403. hubdev = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
  404. return hubdev->hdi_geoid;
  405. }
  406. void sn_generate_path(struct pci_bus *pci_bus, char *address)
  407. {
  408. nasid_t nasid;
  409. cnodeid_t cnode;
  410. geoid_t geoid;
  411. moduleid_t moduleid;
  412. u16 bricktype;
  413. nasid = NASID_GET(SN_PCIBUS_BUSSOFT(pci_bus)->bs_base);
  414. cnode = nasid_to_cnodeid(nasid);
  415. geoid = cnodeid_get_geoid(cnode);
  416. moduleid = geo_module(geoid);
  417. sprintf(address, "module_%c%c%c%c%.2d",
  418. '0'+RACK_GET_CLASS(MODULE_GET_RACK(moduleid)),
  419. '0'+RACK_GET_GROUP(MODULE_GET_RACK(moduleid)),
  420. '0'+RACK_GET_NUM(MODULE_GET_RACK(moduleid)),
  421. MODULE_GET_BTCHAR(moduleid), MODULE_GET_BPOS(moduleid));
  422. /* Tollhouse requires slot id to be displayed */
  423. bricktype = MODULE_GET_BTYPE(moduleid);
  424. if ((bricktype == L1_BRICKTYPE_191010) ||
  425. (bricktype == L1_BRICKTYPE_1932))
  426. sprintf(address, "%s^%d", address, geo_slot(geoid));
  427. }
  428. /*
  429. * sn_pci_fixup_bus() - Perform SN specific setup of software structs
  430. * (pcibus_bussoft, pcidev_info) and hardware
  431. * registers, for the specified bus and devices under it.
  432. */
  433. void __devinit
  434. sn_pci_fixup_bus(struct pci_bus *bus)
  435. {
  436. if (SN_ACPI_BASE_SUPPORT())
  437. sn_acpi_bus_fixup(bus);
  438. else
  439. sn_bus_fixup(bus);
  440. }
  441. /*
  442. * sn_io_early_init - Perform early IO (and some non-IO) initialization.
  443. * In particular, setup the sn_pci_provider[] array.
  444. * This needs to be done prior to any bus scanning
  445. * (acpi_scan_init()) in the ACPI case, as the SN
  446. * bus fixup code will reference the array.
  447. */
  448. static int __init
  449. sn_io_early_init(void)
  450. {
  451. int i;
  452. if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM())
  453. return 0;
  454. /*
  455. * prime sn_pci_provider[]. Individial provider init routines will
  456. * override their respective default entries.
  457. */
  458. for (i = 0; i < PCIIO_ASIC_MAX_TYPES; i++)
  459. sn_pci_provider[i] = &sn_pci_default_provider;
  460. pcibr_init_provider();
  461. tioca_init_provider();
  462. tioce_init_provider();
  463. /*
  464. * This is needed to avoid bounce limit checks in the blk layer
  465. */
  466. ia64_max_iommu_merge_mask = ~PAGE_MASK;
  467. sn_irq_lh_init();
  468. INIT_LIST_HEAD(&sn_sysdata_list);
  469. sn_init_cpei_timer();
  470. #ifdef CONFIG_PROC_FS
  471. register_sn_procfs();
  472. #endif
  473. {
  474. struct acpi_table_header *header;
  475. (void)acpi_get_table_by_index(ACPI_TABLE_INDEX_DSDT, &header);
  476. printk(KERN_INFO "ACPI DSDT OEM Rev 0x%x\n",
  477. header->oem_revision);
  478. }
  479. if (SN_ACPI_BASE_SUPPORT())
  480. sn_io_acpi_init();
  481. else
  482. sn_io_init();
  483. return 0;
  484. }
  485. arch_initcall(sn_io_early_init);
  486. /*
  487. * sn_io_late_init() - Perform any final platform specific IO initialization.
  488. */
  489. int __init
  490. sn_io_late_init(void)
  491. {
  492. struct pci_bus *bus;
  493. struct pcibus_bussoft *bussoft;
  494. cnodeid_t cnode;
  495. nasid_t nasid;
  496. cnodeid_t near_cnode;
  497. if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM())
  498. return 0;
  499. /*
  500. * Setup closest node in pci_controller->node for
  501. * PIC, TIOCP, TIOCE (TIOCA does it during bus fixup using
  502. * info from the PROM).
  503. */
  504. bus = NULL;
  505. while ((bus = pci_find_next_bus(bus)) != NULL) {
  506. bussoft = SN_PCIBUS_BUSSOFT(bus);
  507. nasid = NASID_GET(bussoft->bs_base);
  508. cnode = nasid_to_cnodeid(nasid);
  509. if ((bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCP) ||
  510. (bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCE)) {
  511. /* TIO PCI Bridge: find nearest node with CPUs */
  512. int e = sn_hwperf_get_nearest_node(cnode, NULL,
  513. &near_cnode);
  514. if (e < 0) {
  515. near_cnode = (cnodeid_t)-1; /* use any node */
  516. printk(KERN_WARNING "pcibr_bus_fixup: failed "
  517. "to find near node with CPUs to TIO "
  518. "node %d, err=%d\n", cnode, e);
  519. }
  520. PCI_CONTROLLER(bus)->node = near_cnode;
  521. } else if (bussoft->bs_asic_type == PCIIO_ASIC_TYPE_PIC) {
  522. PCI_CONTROLLER(bus)->node = cnode;
  523. }
  524. }
  525. sn_ioif_inited = 1; /* SN I/O infrastructure now initialized */
  526. return 0;
  527. }
  528. fs_initcall(sn_io_late_init);
  529. EXPORT_SYMBOL(sn_pci_fixup_slot);
  530. EXPORT_SYMBOL(sn_pci_unfixup_slot);
  531. EXPORT_SYMBOL(sn_bus_store_sysdata);
  532. EXPORT_SYMBOL(sn_bus_free_sysdata);
  533. EXPORT_SYMBOL(sn_generate_path);