diff options
author | Paul Mackerras <paulus@samba.org> | 2008-03-25 17:44:18 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-03-25 17:44:18 -0400 |
commit | 54f53f2b94feb72622bec7a8563fc487d9f97720 (patch) | |
tree | ab0c4e1dcadd25a00fa7a4febf41bc43b864cf73 /lib | |
parent | f61fb8a52cdf8b9b6a6badde84aefe58cb35d315 (diff) | |
parent | a4083c9271e0a697278e089f2c0b9a95363ada0a (diff) |
Merge branch 'linux-2.6'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/devres.c | 25 | ||||
-rw-r--r-- | lib/iomap.c | 2 | ||||
-rw-r--r-- | lib/swiotlb.c | 30 |
3 files changed, 42 insertions, 15 deletions
diff --git a/lib/devres.c b/lib/devres.c index b1d336ce7f3d..edc27a5d1b73 100644 --- a/lib/devres.c +++ b/lib/devres.c | |||
@@ -298,6 +298,31 @@ int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name) | |||
298 | EXPORT_SYMBOL(pcim_iomap_regions); | 298 | EXPORT_SYMBOL(pcim_iomap_regions); |
299 | 299 | ||
300 | /** | 300 | /** |
301 | * pcim_iomap_regions_request_all - Request all BARs and iomap specified ones | ||
302 | * @pdev: PCI device to map IO resources for | ||
303 | * @mask: Mask of BARs to iomap | ||
304 | * @name: Name used when requesting regions | ||
305 | * | ||
306 | * Request all PCI BARs and iomap regions specified by @mask. | ||
307 | */ | ||
308 | int pcim_iomap_regions_request_all(struct pci_dev *pdev, u16 mask, | ||
309 | const char *name) | ||
310 | { | ||
311 | int request_mask = ((1 << 6) - 1) & ~mask; | ||
312 | int rc; | ||
313 | |||
314 | rc = pci_request_selected_regions(pdev, request_mask, name); | ||
315 | if (rc) | ||
316 | return rc; | ||
317 | |||
318 | rc = pcim_iomap_regions(pdev, mask, name); | ||
319 | if (rc) | ||
320 | pci_release_selected_regions(pdev, request_mask); | ||
321 | return rc; | ||
322 | } | ||
323 | EXPORT_SYMBOL(pcim_iomap_regions_request_all); | ||
324 | |||
325 | /** | ||
301 | * pcim_iounmap_regions - Unmap and release PCI BARs | 326 | * pcim_iounmap_regions - Unmap and release PCI BARs |
302 | * @pdev: PCI device to map IO resources for | 327 | * @pdev: PCI device to map IO resources for |
303 | * @mask: Mask of BARs to unmap and release | 328 | * @mask: Mask of BARs to unmap and release |
diff --git a/lib/iomap.c b/lib/iomap.c index db004a9ff509..dd6ca48fe6b0 100644 --- a/lib/iomap.c +++ b/lib/iomap.c | |||
@@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioport_unmap); | |||
256 | * */ | 256 | * */ |
257 | void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) | 257 | void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) |
258 | { | 258 | { |
259 | unsigned long start = pci_resource_start(dev, bar); | 259 | resource_size_t start = pci_resource_start(dev, bar); |
260 | unsigned long len = pci_resource_len(dev, bar); | 260 | unsigned long len = pci_resource_len(dev, bar); |
261 | unsigned long flags = pci_resource_flags(dev, bar); | 261 | unsigned long flags = pci_resource_flags(dev, bar); |
262 | 262 | ||
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 4bb5a11e18a2..025922807e6e 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -310,7 +310,9 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir) | |||
310 | start_dma_addr = virt_to_bus(io_tlb_start) & mask; | 310 | start_dma_addr = virt_to_bus(io_tlb_start) & mask; |
311 | 311 | ||
312 | offset_slots = ALIGN(start_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT; | 312 | offset_slots = ALIGN(start_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT; |
313 | max_slots = ALIGN(mask + 1, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT; | 313 | max_slots = mask + 1 |
314 | ? ALIGN(mask + 1, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT | ||
315 | : 1UL << (BITS_PER_LONG - IO_TLB_SHIFT); | ||
314 | 316 | ||
315 | /* | 317 | /* |
316 | * For mappings greater than a page, we limit the stride (and | 318 | * For mappings greater than a page, we limit the stride (and |
@@ -333,16 +335,18 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir) | |||
333 | index = ALIGN(io_tlb_index, stride); | 335 | index = ALIGN(io_tlb_index, stride); |
334 | if (index >= io_tlb_nslabs) | 336 | if (index >= io_tlb_nslabs) |
335 | index = 0; | 337 | index = 0; |
336 | |||
337 | while (is_span_boundary(index, nslots, offset_slots, | ||
338 | max_slots)) { | ||
339 | index += stride; | ||
340 | if (index >= io_tlb_nslabs) | ||
341 | index = 0; | ||
342 | } | ||
343 | wrap = index; | 338 | wrap = index; |
344 | 339 | ||
345 | do { | 340 | do { |
341 | while (is_span_boundary(index, nslots, offset_slots, | ||
342 | max_slots)) { | ||
343 | index += stride; | ||
344 | if (index >= io_tlb_nslabs) | ||
345 | index = 0; | ||
346 | if (index == wrap) | ||
347 | goto not_found; | ||
348 | } | ||
349 | |||
346 | /* | 350 | /* |
347 | * If we find a slot that indicates we have 'nslots' | 351 | * If we find a slot that indicates we have 'nslots' |
348 | * number of contiguous buffers, we allocate the | 352 | * number of contiguous buffers, we allocate the |
@@ -367,14 +371,12 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir) | |||
367 | 371 | ||
368 | goto found; | 372 | goto found; |
369 | } | 373 | } |
370 | do { | 374 | index += stride; |
371 | index += stride; | 375 | if (index >= io_tlb_nslabs) |
372 | if (index >= io_tlb_nslabs) | 376 | index = 0; |
373 | index = 0; | ||
374 | } while (is_span_boundary(index, nslots, offset_slots, | ||
375 | max_slots)); | ||
376 | } while (index != wrap); | 377 | } while (index != wrap); |
377 | 378 | ||
379 | not_found: | ||
378 | spin_unlock_irqrestore(&io_tlb_lock, flags); | 380 | spin_unlock_irqrestore(&io_tlb_lock, flags); |
379 | return NULL; | 381 | return NULL; |
380 | } | 382 | } |