io_common.c 17 KB

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