pci.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. /*
  2. * pci.c - Low-Level PCI Access in IA-64
  3. *
  4. * Derived from bios32.c of i386 tree.
  5. *
  6. * (c) Copyright 2002, 2005 Hewlett-Packard Development Company, L.P.
  7. * David Mosberger-Tang <davidm@hpl.hp.com>
  8. * Bjorn Helgaas <bjorn.helgaas@hp.com>
  9. * Copyright (C) 2004 Silicon Graphics, Inc.
  10. *
  11. * Note: Above list of copyright holders is incomplete...
  12. */
  13. #include <linux/acpi.h>
  14. #include <linux/types.h>
  15. #include <linux/kernel.h>
  16. #include <linux/pci.h>
  17. #include <linux/init.h>
  18. #include <linux/ioport.h>
  19. #include <linux/slab.h>
  20. #include <linux/spinlock.h>
  21. #include <linux/bootmem.h>
  22. #include <linux/export.h>
  23. #include <asm/machvec.h>
  24. #include <asm/page.h>
  25. #include <asm/io.h>
  26. #include <asm/sal.h>
  27. #include <asm/smp.h>
  28. #include <asm/irq.h>
  29. #include <asm/hw_irq.h>
  30. /*
  31. * Low-level SAL-based PCI configuration access functions. Note that SAL
  32. * calls are already serialized (via sal_lock), so we don't need another
  33. * synchronization mechanism here.
  34. */
  35. #define PCI_SAL_ADDRESS(seg, bus, devfn, reg) \
  36. (((u64) seg << 24) | (bus << 16) | (devfn << 8) | (reg))
  37. /* SAL 3.2 adds support for extended config space. */
  38. #define PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg) \
  39. (((u64) seg << 28) | (bus << 20) | (devfn << 12) | (reg))
  40. int raw_pci_read(unsigned int seg, unsigned int bus, unsigned int devfn,
  41. int reg, int len, u32 *value)
  42. {
  43. u64 addr, data = 0;
  44. int mode, result;
  45. if (!value || (seg > 65535) || (bus > 255) || (devfn > 255) || (reg > 4095))
  46. return -EINVAL;
  47. if ((seg | reg) <= 255) {
  48. addr = PCI_SAL_ADDRESS(seg, bus, devfn, reg);
  49. mode = 0;
  50. } else if (sal_revision >= SAL_VERSION_CODE(3,2)) {
  51. addr = PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg);
  52. mode = 1;
  53. } else {
  54. return -EINVAL;
  55. }
  56. result = ia64_sal_pci_config_read(addr, mode, len, &data);
  57. if (result != 0)
  58. return -EINVAL;
  59. *value = (u32) data;
  60. return 0;
  61. }
  62. int raw_pci_write(unsigned int seg, unsigned int bus, unsigned int devfn,
  63. int reg, int len, u32 value)
  64. {
  65. u64 addr;
  66. int mode, result;
  67. if ((seg > 65535) || (bus > 255) || (devfn > 255) || (reg > 4095))
  68. return -EINVAL;
  69. if ((seg | reg) <= 255) {
  70. addr = PCI_SAL_ADDRESS(seg, bus, devfn, reg);
  71. mode = 0;
  72. } else if (sal_revision >= SAL_VERSION_CODE(3,2)) {
  73. addr = PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg);
  74. mode = 1;
  75. } else {
  76. return -EINVAL;
  77. }
  78. result = ia64_sal_pci_config_write(addr, mode, len, value);
  79. if (result != 0)
  80. return -EINVAL;
  81. return 0;
  82. }
  83. static int pci_read(struct pci_bus *bus, unsigned int devfn, int where,
  84. int size, u32 *value)
  85. {
  86. return raw_pci_read(pci_domain_nr(bus), bus->number,
  87. devfn, where, size, value);
  88. }
  89. static int pci_write(struct pci_bus *bus, unsigned int devfn, int where,
  90. int size, u32 value)
  91. {
  92. return raw_pci_write(pci_domain_nr(bus), bus->number,
  93. devfn, where, size, value);
  94. }
  95. struct pci_ops pci_root_ops = {
  96. .read = pci_read,
  97. .write = pci_write,
  98. };
  99. /* Called by ACPI when it finds a new root bus. */
  100. static struct pci_controller *alloc_pci_controller(int seg)
  101. {
  102. struct pci_controller *controller;
  103. controller = kzalloc(sizeof(*controller), GFP_KERNEL);
  104. if (!controller)
  105. return NULL;
  106. controller->segment = seg;
  107. controller->node = -1;
  108. return controller;
  109. }
  110. struct pci_root_info {
  111. struct acpi_device *bridge;
  112. struct pci_controller *controller;
  113. struct list_head resources;
  114. char *name;
  115. };
  116. static unsigned int
  117. new_space (u64 phys_base, int sparse)
  118. {
  119. u64 mmio_base;
  120. int i;
  121. if (phys_base == 0)
  122. return 0; /* legacy I/O port space */
  123. mmio_base = (u64) ioremap(phys_base, 0);
  124. for (i = 0; i < num_io_spaces; i++)
  125. if (io_space[i].mmio_base == mmio_base &&
  126. io_space[i].sparse == sparse)
  127. return i;
  128. if (num_io_spaces == MAX_IO_SPACES) {
  129. printk(KERN_ERR "PCI: Too many IO port spaces "
  130. "(MAX_IO_SPACES=%lu)\n", MAX_IO_SPACES);
  131. return ~0;
  132. }
  133. i = num_io_spaces++;
  134. io_space[i].mmio_base = mmio_base;
  135. io_space[i].sparse = sparse;
  136. return i;
  137. }
  138. static u64 add_io_space(struct pci_root_info *info,
  139. struct acpi_resource_address64 *addr)
  140. {
  141. struct resource *resource;
  142. char *name;
  143. unsigned long base, min, max, base_port;
  144. unsigned int sparse = 0, space_nr, len;
  145. resource = kzalloc(sizeof(*resource), GFP_KERNEL);
  146. if (!resource) {
  147. printk(KERN_ERR "PCI: No memory for %s I/O port space\n",
  148. info->name);
  149. goto out;
  150. }
  151. len = strlen(info->name) + 32;
  152. name = kzalloc(len, GFP_KERNEL);
  153. if (!name) {
  154. printk(KERN_ERR "PCI: No memory for %s I/O port space name\n",
  155. info->name);
  156. goto free_resource;
  157. }
  158. min = addr->minimum;
  159. max = min + addr->address_length - 1;
  160. if (addr->info.io.translation_type == ACPI_SPARSE_TRANSLATION)
  161. sparse = 1;
  162. space_nr = new_space(addr->translation_offset, sparse);
  163. if (space_nr == ~0)
  164. goto free_name;
  165. base = __pa(io_space[space_nr].mmio_base);
  166. base_port = IO_SPACE_BASE(space_nr);
  167. snprintf(name, len, "%s I/O Ports %08lx-%08lx", info->name,
  168. base_port + min, base_port + max);
  169. /*
  170. * The SDM guarantees the legacy 0-64K space is sparse, but if the
  171. * mapping is done by the processor (not the bridge), ACPI may not
  172. * mark it as sparse.
  173. */
  174. if (space_nr == 0)
  175. sparse = 1;
  176. resource->name = name;
  177. resource->flags = IORESOURCE_MEM;
  178. resource->start = base + (sparse ? IO_SPACE_SPARSE_ENCODING(min) : min);
  179. resource->end = base + (sparse ? IO_SPACE_SPARSE_ENCODING(max) : max);
  180. insert_resource(&iomem_resource, resource);
  181. return base_port;
  182. free_name:
  183. kfree(name);
  184. free_resource:
  185. kfree(resource);
  186. out:
  187. return ~0;
  188. }
  189. static acpi_status resource_to_window(struct acpi_resource *resource,
  190. struct acpi_resource_address64 *addr)
  191. {
  192. acpi_status status;
  193. /*
  194. * We're only interested in _CRS descriptors that are
  195. * - address space descriptors for memory or I/O space
  196. * - non-zero size
  197. * - producers, i.e., the address space is routed downstream,
  198. * not consumed by the bridge itself
  199. */
  200. status = acpi_resource_to_address64(resource, addr);
  201. if (ACPI_SUCCESS(status) &&
  202. (addr->resource_type == ACPI_MEMORY_RANGE ||
  203. addr->resource_type == ACPI_IO_RANGE) &&
  204. addr->address_length &&
  205. addr->producer_consumer == ACPI_PRODUCER)
  206. return AE_OK;
  207. return AE_ERROR;
  208. }
  209. static acpi_status count_window(struct acpi_resource *resource, void *data)
  210. {
  211. unsigned int *windows = (unsigned int *) data;
  212. struct acpi_resource_address64 addr;
  213. acpi_status status;
  214. status = resource_to_window(resource, &addr);
  215. if (ACPI_SUCCESS(status))
  216. (*windows)++;
  217. return AE_OK;
  218. }
  219. static acpi_status add_window(struct acpi_resource *res, void *data)
  220. {
  221. struct pci_root_info *info = data;
  222. struct pci_window *window;
  223. struct acpi_resource_address64 addr;
  224. acpi_status status;
  225. unsigned long flags, offset = 0;
  226. struct resource *root;
  227. /* Return AE_OK for non-window resources to keep scanning for more */
  228. status = resource_to_window(res, &addr);
  229. if (!ACPI_SUCCESS(status))
  230. return AE_OK;
  231. if (addr.resource_type == ACPI_MEMORY_RANGE) {
  232. flags = IORESOURCE_MEM;
  233. root = &iomem_resource;
  234. offset = addr.translation_offset;
  235. } else if (addr.resource_type == ACPI_IO_RANGE) {
  236. flags = IORESOURCE_IO;
  237. root = &ioport_resource;
  238. offset = add_io_space(info, &addr);
  239. if (offset == ~0)
  240. return AE_OK;
  241. } else
  242. return AE_OK;
  243. window = &info->controller->window[info->controller->windows++];
  244. window->resource.name = info->name;
  245. window->resource.flags = flags;
  246. window->resource.start = addr.minimum + offset;
  247. window->resource.end = window->resource.start + addr.address_length - 1;
  248. window->offset = offset;
  249. if (insert_resource(root, &window->resource)) {
  250. dev_err(&info->bridge->dev,
  251. "can't allocate host bridge window %pR\n",
  252. &window->resource);
  253. } else {
  254. if (offset)
  255. dev_info(&info->bridge->dev, "host bridge window %pR "
  256. "(PCI address [%#llx-%#llx])\n",
  257. &window->resource,
  258. window->resource.start - offset,
  259. window->resource.end - offset);
  260. else
  261. dev_info(&info->bridge->dev,
  262. "host bridge window %pR\n",
  263. &window->resource);
  264. }
  265. /* HP's firmware has a hack to work around a Windows bug.
  266. * Ignore these tiny memory ranges */
  267. if (!((window->resource.flags & IORESOURCE_MEM) &&
  268. (window->resource.end - window->resource.start < 16)))
  269. pci_add_resource_offset(&info->resources, &window->resource,
  270. window->offset);
  271. return AE_OK;
  272. }
  273. struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
  274. {
  275. struct acpi_device *device = root->device;
  276. int domain = root->segment;
  277. int bus = root->secondary.start;
  278. struct pci_controller *controller;
  279. unsigned int windows = 0;
  280. struct pci_root_info info;
  281. struct pci_bus *pbus;
  282. char *name;
  283. int pxm;
  284. controller = alloc_pci_controller(domain);
  285. if (!controller)
  286. goto out1;
  287. controller->acpi_handle = device->handle;
  288. pxm = acpi_get_pxm(controller->acpi_handle);
  289. #ifdef CONFIG_NUMA
  290. if (pxm >= 0)
  291. controller->node = pxm_to_node(pxm);
  292. #endif
  293. INIT_LIST_HEAD(&info.resources);
  294. /* insert busn resource at first */
  295. pci_add_resource(&info.resources, &root->secondary);
  296. acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window,
  297. &windows);
  298. if (windows) {
  299. controller->window =
  300. kzalloc_node(sizeof(*controller->window) * windows,
  301. GFP_KERNEL, controller->node);
  302. if (!controller->window)
  303. goto out2;
  304. name = kmalloc(16, GFP_KERNEL);
  305. if (!name)
  306. goto out3;
  307. sprintf(name, "PCI Bus %04x:%02x", domain, bus);
  308. info.bridge = device;
  309. info.controller = controller;
  310. info.name = name;
  311. acpi_walk_resources(device->handle, METHOD_NAME__CRS,
  312. add_window, &info);
  313. }
  314. /*
  315. * See arch/x86/pci/acpi.c.
  316. * The desired pci bus might already be scanned in a quirk. We
  317. * should handle the case here, but it appears that IA64 hasn't
  318. * such quirk. So we just ignore the case now.
  319. */
  320. pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
  321. &info.resources);
  322. if (!pbus) {
  323. pci_free_resource_list(&info.resources);
  324. return NULL;
  325. }
  326. pci_scan_child_bus(pbus);
  327. return pbus;
  328. out3:
  329. kfree(controller->window);
  330. out2:
  331. kfree(controller);
  332. out1:
  333. return NULL;
  334. }
  335. static int is_valid_resource(struct pci_dev *dev, int idx)
  336. {
  337. unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM;
  338. struct resource *devr = &dev->resource[idx], *busr;
  339. if (!dev->bus)
  340. return 0;
  341. pci_bus_for_each_resource(dev->bus, busr, i) {
  342. if (!busr || ((busr->flags ^ devr->flags) & type_mask))
  343. continue;
  344. if ((devr->start) && (devr->start >= busr->start) &&
  345. (devr->end <= busr->end))
  346. return 1;
  347. }
  348. return 0;
  349. }
  350. static void pcibios_fixup_resources(struct pci_dev *dev, int start, int limit)
  351. {
  352. int i;
  353. for (i = start; i < limit; i++) {
  354. if (!dev->resource[i].flags)
  355. continue;
  356. if ((is_valid_resource(dev, i)))
  357. pci_claim_resource(dev, i);
  358. }
  359. }
  360. void pcibios_fixup_device_resources(struct pci_dev *dev)
  361. {
  362. pcibios_fixup_resources(dev, 0, PCI_BRIDGE_RESOURCES);
  363. }
  364. EXPORT_SYMBOL_GPL(pcibios_fixup_device_resources);
  365. static void pcibios_fixup_bridge_resources(struct pci_dev *dev)
  366. {
  367. pcibios_fixup_resources(dev, PCI_BRIDGE_RESOURCES, PCI_NUM_RESOURCES);
  368. }
  369. /*
  370. * Called after each bus is probed, but before its children are examined.
  371. */
  372. void pcibios_fixup_bus(struct pci_bus *b)
  373. {
  374. struct pci_dev *dev;
  375. if (b->self) {
  376. pci_read_bridge_bases(b);
  377. pcibios_fixup_bridge_resources(b->self);
  378. }
  379. list_for_each_entry(dev, &b->devices, bus_list)
  380. pcibios_fixup_device_resources(dev);
  381. platform_pci_fixup_bus(b);
  382. }
  383. void pcibios_set_master (struct pci_dev *dev)
  384. {
  385. /* No special bus mastering setup handling */
  386. }
  387. int
  388. pcibios_enable_device (struct pci_dev *dev, int mask)
  389. {
  390. int ret;
  391. ret = pci_enable_resources(dev, mask);
  392. if (ret < 0)
  393. return ret;
  394. if (!dev->msi_enabled)
  395. return acpi_pci_irq_enable(dev);
  396. return 0;
  397. }
  398. void
  399. pcibios_disable_device (struct pci_dev *dev)
  400. {
  401. BUG_ON(atomic_read(&dev->enable_cnt));
  402. if (!dev->msi_enabled)
  403. acpi_pci_irq_disable(dev);
  404. }
  405. resource_size_t
  406. pcibios_align_resource (void *data, const struct resource *res,
  407. resource_size_t size, resource_size_t align)
  408. {
  409. return res->start;
  410. }
  411. int
  412. pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma,
  413. enum pci_mmap_state mmap_state, int write_combine)
  414. {
  415. unsigned long size = vma->vm_end - vma->vm_start;
  416. pgprot_t prot;
  417. /*
  418. * I/O space cannot be accessed via normal processor loads and
  419. * stores on this platform.
  420. */
  421. if (mmap_state == pci_mmap_io)
  422. /*
  423. * XXX we could relax this for I/O spaces for which ACPI
  424. * indicates that the space is 1-to-1 mapped. But at the
  425. * moment, we don't support multiple PCI address spaces and
  426. * the legacy I/O space is not 1-to-1 mapped, so this is moot.
  427. */
  428. return -EINVAL;
  429. if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
  430. return -EINVAL;
  431. prot = phys_mem_access_prot(NULL, vma->vm_pgoff, size,
  432. vma->vm_page_prot);
  433. /*
  434. * If the user requested WC, the kernel uses UC or WC for this region,
  435. * and the chipset supports WC, we can use WC. Otherwise, we have to
  436. * use the same attribute the kernel uses.
  437. */
  438. if (write_combine &&
  439. ((pgprot_val(prot) & _PAGE_MA_MASK) == _PAGE_MA_UC ||
  440. (pgprot_val(prot) & _PAGE_MA_MASK) == _PAGE_MA_WC) &&
  441. efi_range_is_wc(vma->vm_start, vma->vm_end - vma->vm_start))
  442. vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
  443. else
  444. vma->vm_page_prot = prot;
  445. if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
  446. vma->vm_end - vma->vm_start, vma->vm_page_prot))
  447. return -EAGAIN;
  448. return 0;
  449. }
  450. /**
  451. * ia64_pci_get_legacy_mem - generic legacy mem routine
  452. * @bus: bus to get legacy memory base address for
  453. *
  454. * Find the base of legacy memory for @bus. This is typically the first
  455. * megabyte of bus address space for @bus or is simply 0 on platforms whose
  456. * chipsets support legacy I/O and memory routing. Returns the base address
  457. * or an error pointer if an error occurred.
  458. *
  459. * This is the ia64 generic version of this routine. Other platforms
  460. * are free to override it with a machine vector.
  461. */
  462. char *ia64_pci_get_legacy_mem(struct pci_bus *bus)
  463. {
  464. return (char *)__IA64_UNCACHED_OFFSET;
  465. }
  466. /**
  467. * pci_mmap_legacy_page_range - map legacy memory space to userland
  468. * @bus: bus whose legacy space we're mapping
  469. * @vma: vma passed in by mmap
  470. *
  471. * Map legacy memory space for this device back to userspace using a machine
  472. * vector to get the base address.
  473. */
  474. int
  475. pci_mmap_legacy_page_range(struct pci_bus *bus, struct vm_area_struct *vma,
  476. enum pci_mmap_state mmap_state)
  477. {
  478. unsigned long size = vma->vm_end - vma->vm_start;
  479. pgprot_t prot;
  480. char *addr;
  481. /* We only support mmap'ing of legacy memory space */
  482. if (mmap_state != pci_mmap_mem)
  483. return -ENOSYS;
  484. /*
  485. * Avoid attribute aliasing. See Documentation/ia64/aliasing.txt
  486. * for more details.
  487. */
  488. if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
  489. return -EINVAL;
  490. prot = phys_mem_access_prot(NULL, vma->vm_pgoff, size,
  491. vma->vm_page_prot);
  492. addr = pci_get_legacy_mem(bus);
  493. if (IS_ERR(addr))
  494. return PTR_ERR(addr);
  495. vma->vm_pgoff += (unsigned long)addr >> PAGE_SHIFT;
  496. vma->vm_page_prot = prot;
  497. if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
  498. size, vma->vm_page_prot))
  499. return -EAGAIN;
  500. return 0;
  501. }
  502. /**
  503. * ia64_pci_legacy_read - read from legacy I/O space
  504. * @bus: bus to read
  505. * @port: legacy port value
  506. * @val: caller allocated storage for returned value
  507. * @size: number of bytes to read
  508. *
  509. * Simply reads @size bytes from @port and puts the result in @val.
  510. *
  511. * Again, this (and the write routine) are generic versions that can be
  512. * overridden by the platform. This is necessary on platforms that don't
  513. * support legacy I/O routing or that hard fail on legacy I/O timeouts.
  514. */
  515. int ia64_pci_legacy_read(struct pci_bus *bus, u16 port, u32 *val, u8 size)
  516. {
  517. int ret = size;
  518. switch (size) {
  519. case 1:
  520. *val = inb(port);
  521. break;
  522. case 2:
  523. *val = inw(port);
  524. break;
  525. case 4:
  526. *val = inl(port);
  527. break;
  528. default:
  529. ret = -EINVAL;
  530. break;
  531. }
  532. return ret;
  533. }
  534. /**
  535. * ia64_pci_legacy_write - perform a legacy I/O write
  536. * @bus: bus pointer
  537. * @port: port to write
  538. * @val: value to write
  539. * @size: number of bytes to write from @val
  540. *
  541. * Simply writes @size bytes of @val to @port.
  542. */
  543. int ia64_pci_legacy_write(struct pci_bus *bus, u16 port, u32 val, u8 size)
  544. {
  545. int ret = size;
  546. switch (size) {
  547. case 1:
  548. outb(val, port);
  549. break;
  550. case 2:
  551. outw(val, port);
  552. break;
  553. case 4:
  554. outl(val, port);
  555. break;
  556. default:
  557. ret = -EINVAL;
  558. break;
  559. }
  560. return ret;
  561. }
  562. /**
  563. * set_pci_cacheline_size - determine cacheline size for PCI devices
  564. *
  565. * We want to use the line-size of the outer-most cache. We assume
  566. * that this line-size is the same for all CPUs.
  567. *
  568. * Code mostly taken from arch/ia64/kernel/palinfo.c:cache_info().
  569. */
  570. static void __init set_pci_dfl_cacheline_size(void)
  571. {
  572. unsigned long levels, unique_caches;
  573. long status;
  574. pal_cache_config_info_t cci;
  575. status = ia64_pal_cache_summary(&levels, &unique_caches);
  576. if (status != 0) {
  577. printk(KERN_ERR "%s: ia64_pal_cache_summary() failed "
  578. "(status=%ld)\n", __func__, status);
  579. return;
  580. }
  581. status = ia64_pal_cache_config_info(levels - 1,
  582. /* cache_type (data_or_unified)= */ 2, &cci);
  583. if (status != 0) {
  584. printk(KERN_ERR "%s: ia64_pal_cache_config_info() failed "
  585. "(status=%ld)\n", __func__, status);
  586. return;
  587. }
  588. pci_dfl_cache_line_size = (1 << cci.pcci_line_size) / 4;
  589. }
  590. u64 ia64_dma_get_required_mask(struct device *dev)
  591. {
  592. u32 low_totalram = ((max_pfn - 1) << PAGE_SHIFT);
  593. u32 high_totalram = ((max_pfn - 1) >> (32 - PAGE_SHIFT));
  594. u64 mask;
  595. if (!high_totalram) {
  596. /* convert to mask just covering totalram */
  597. low_totalram = (1 << (fls(low_totalram) - 1));
  598. low_totalram += low_totalram - 1;
  599. mask = low_totalram;
  600. } else {
  601. high_totalram = (1 << (fls(high_totalram) - 1));
  602. high_totalram += high_totalram - 1;
  603. mask = (((u64)high_totalram) << 32) + 0xffffffff;
  604. }
  605. return mask;
  606. }
  607. EXPORT_SYMBOL_GPL(ia64_dma_get_required_mask);
  608. u64 dma_get_required_mask(struct device *dev)
  609. {
  610. return platform_dma_get_required_mask(dev);
  611. }
  612. EXPORT_SYMBOL_GPL(dma_get_required_mask);
  613. static int __init pcibios_init(void)
  614. {
  615. set_pci_dfl_cacheline_size();
  616. return 0;
  617. }
  618. subsys_initcall(pcibios_init);