diff options
Diffstat (limited to 'arch/sparc64/kernel/pci_iommu.c')
-rw-r--r-- | arch/sparc64/kernel/pci_iommu.c | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/arch/sparc64/kernel/pci_iommu.c b/arch/sparc64/kernel/pci_iommu.c index 7aca0f33f885..554daabb381e 100644 --- a/arch/sparc64/kernel/pci_iommu.c +++ b/arch/sparc64/kernel/pci_iommu.c | |||
@@ -220,7 +220,6 @@ static inline void iommu_free_ctx(struct pci_iommu *iommu, int ctx) | |||
220 | */ | 220 | */ |
221 | static void *pci_4u_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp, gfp_t gfp) | 221 | static void *pci_4u_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp, gfp_t gfp) |
222 | { | 222 | { |
223 | struct pcidev_cookie *pcp; | ||
224 | struct pci_iommu *iommu; | 223 | struct pci_iommu *iommu; |
225 | iopte_t *iopte; | 224 | iopte_t *iopte; |
226 | unsigned long flags, order, first_page; | 225 | unsigned long flags, order, first_page; |
@@ -237,8 +236,7 @@ static void *pci_4u_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr | |||
237 | return NULL; | 236 | return NULL; |
238 | memset((char *)first_page, 0, PAGE_SIZE << order); | 237 | memset((char *)first_page, 0, PAGE_SIZE << order); |
239 | 238 | ||
240 | pcp = pdev->sysdata; | 239 | iommu = pdev->dev.archdata.iommu; |
241 | iommu = pcp->pbm->iommu; | ||
242 | 240 | ||
243 | spin_lock_irqsave(&iommu->lock, flags); | 241 | spin_lock_irqsave(&iommu->lock, flags); |
244 | iopte = alloc_npages(iommu, size >> IO_PAGE_SHIFT); | 242 | iopte = alloc_npages(iommu, size >> IO_PAGE_SHIFT); |
@@ -268,14 +266,12 @@ static void *pci_4u_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr | |||
268 | /* Free and unmap a consistent DMA translation. */ | 266 | /* Free and unmap a consistent DMA translation. */ |
269 | static void pci_4u_free_consistent(struct pci_dev *pdev, size_t size, void *cpu, dma_addr_t dvma) | 267 | static void pci_4u_free_consistent(struct pci_dev *pdev, size_t size, void *cpu, dma_addr_t dvma) |
270 | { | 268 | { |
271 | struct pcidev_cookie *pcp; | ||
272 | struct pci_iommu *iommu; | 269 | struct pci_iommu *iommu; |
273 | iopte_t *iopte; | 270 | iopte_t *iopte; |
274 | unsigned long flags, order, npages; | 271 | unsigned long flags, order, npages; |
275 | 272 | ||
276 | npages = IO_PAGE_ALIGN(size) >> IO_PAGE_SHIFT; | 273 | npages = IO_PAGE_ALIGN(size) >> IO_PAGE_SHIFT; |
277 | pcp = pdev->sysdata; | 274 | iommu = pdev->dev.archdata.iommu; |
278 | iommu = pcp->pbm->iommu; | ||
279 | iopte = iommu->page_table + | 275 | iopte = iommu->page_table + |
280 | ((dvma - iommu->page_table_map_base) >> IO_PAGE_SHIFT); | 276 | ((dvma - iommu->page_table_map_base) >> IO_PAGE_SHIFT); |
281 | 277 | ||
@@ -295,7 +291,6 @@ static void pci_4u_free_consistent(struct pci_dev *pdev, size_t size, void *cpu, | |||
295 | */ | 291 | */ |
296 | static dma_addr_t pci_4u_map_single(struct pci_dev *pdev, void *ptr, size_t sz, int direction) | 292 | static dma_addr_t pci_4u_map_single(struct pci_dev *pdev, void *ptr, size_t sz, int direction) |
297 | { | 293 | { |
298 | struct pcidev_cookie *pcp; | ||
299 | struct pci_iommu *iommu; | 294 | struct pci_iommu *iommu; |
300 | struct pci_strbuf *strbuf; | 295 | struct pci_strbuf *strbuf; |
301 | iopte_t *base; | 296 | iopte_t *base; |
@@ -304,9 +299,8 @@ static dma_addr_t pci_4u_map_single(struct pci_dev *pdev, void *ptr, size_t sz, | |||
304 | u32 bus_addr, ret; | 299 | u32 bus_addr, ret; |
305 | unsigned long iopte_protection; | 300 | unsigned long iopte_protection; |
306 | 301 | ||
307 | pcp = pdev->sysdata; | 302 | iommu = pdev->dev.archdata.iommu; |
308 | iommu = pcp->pbm->iommu; | 303 | strbuf = pdev->dev.archdata.stc; |
309 | strbuf = &pcp->pbm->stc; | ||
310 | 304 | ||
311 | if (unlikely(direction == PCI_DMA_NONE)) | 305 | if (unlikely(direction == PCI_DMA_NONE)) |
312 | goto bad_no_ctx; | 306 | goto bad_no_ctx; |
@@ -416,7 +410,6 @@ do_flush_sync: | |||
416 | /* Unmap a single streaming mode DMA translation. */ | 410 | /* Unmap a single streaming mode DMA translation. */ |
417 | static void pci_4u_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int direction) | 411 | static void pci_4u_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int direction) |
418 | { | 412 | { |
419 | struct pcidev_cookie *pcp; | ||
420 | struct pci_iommu *iommu; | 413 | struct pci_iommu *iommu; |
421 | struct pci_strbuf *strbuf; | 414 | struct pci_strbuf *strbuf; |
422 | iopte_t *base; | 415 | iopte_t *base; |
@@ -428,9 +421,8 @@ static void pci_4u_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_ | |||
428 | return; | 421 | return; |
429 | } | 422 | } |
430 | 423 | ||
431 | pcp = pdev->sysdata; | 424 | iommu = pdev->dev.archdata.iommu; |
432 | iommu = pcp->pbm->iommu; | 425 | strbuf = pdev->dev.archdata.stc; |
433 | strbuf = &pcp->pbm->stc; | ||
434 | 426 | ||
435 | npages = IO_PAGE_ALIGN(bus_addr + sz) - (bus_addr & IO_PAGE_MASK); | 427 | npages = IO_PAGE_ALIGN(bus_addr + sz) - (bus_addr & IO_PAGE_MASK); |
436 | npages >>= IO_PAGE_SHIFT; | 428 | npages >>= IO_PAGE_SHIFT; |
@@ -549,7 +541,6 @@ static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg, | |||
549 | */ | 541 | */ |
550 | static int pci_4u_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction) | 542 | static int pci_4u_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction) |
551 | { | 543 | { |
552 | struct pcidev_cookie *pcp; | ||
553 | struct pci_iommu *iommu; | 544 | struct pci_iommu *iommu; |
554 | struct pci_strbuf *strbuf; | 545 | struct pci_strbuf *strbuf; |
555 | unsigned long flags, ctx, npages, iopte_protection; | 546 | unsigned long flags, ctx, npages, iopte_protection; |
@@ -570,9 +561,8 @@ static int pci_4u_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int n | |||
570 | return 1; | 561 | return 1; |
571 | } | 562 | } |
572 | 563 | ||
573 | pcp = pdev->sysdata; | 564 | iommu = pdev->dev.archdata.iommu; |
574 | iommu = pcp->pbm->iommu; | 565 | strbuf = pdev->dev.archdata.stc; |
575 | strbuf = &pcp->pbm->stc; | ||
576 | 566 | ||
577 | if (unlikely(direction == PCI_DMA_NONE)) | 567 | if (unlikely(direction == PCI_DMA_NONE)) |
578 | goto bad_no_ctx; | 568 | goto bad_no_ctx; |
@@ -636,7 +626,6 @@ bad_no_ctx: | |||
636 | /* Unmap a set of streaming mode DMA translations. */ | 626 | /* Unmap a set of streaming mode DMA translations. */ |
637 | static void pci_4u_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction) | 627 | static void pci_4u_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction) |
638 | { | 628 | { |
639 | struct pcidev_cookie *pcp; | ||
640 | struct pci_iommu *iommu; | 629 | struct pci_iommu *iommu; |
641 | struct pci_strbuf *strbuf; | 630 | struct pci_strbuf *strbuf; |
642 | iopte_t *base; | 631 | iopte_t *base; |
@@ -648,9 +637,8 @@ static void pci_4u_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, in | |||
648 | WARN_ON(1); | 637 | WARN_ON(1); |
649 | } | 638 | } |
650 | 639 | ||
651 | pcp = pdev->sysdata; | 640 | iommu = pdev->dev.archdata.iommu; |
652 | iommu = pcp->pbm->iommu; | 641 | strbuf = pdev->dev.archdata.stc; |
653 | strbuf = &pcp->pbm->stc; | ||
654 | 642 | ||
655 | bus_addr = sglist->dma_address & IO_PAGE_MASK; | 643 | bus_addr = sglist->dma_address & IO_PAGE_MASK; |
656 | 644 | ||
@@ -696,14 +684,12 @@ static void pci_4u_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, in | |||
696 | */ | 684 | */ |
697 | static void pci_4u_dma_sync_single_for_cpu(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int direction) | 685 | static void pci_4u_dma_sync_single_for_cpu(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int direction) |
698 | { | 686 | { |
699 | struct pcidev_cookie *pcp; | ||
700 | struct pci_iommu *iommu; | 687 | struct pci_iommu *iommu; |
701 | struct pci_strbuf *strbuf; | 688 | struct pci_strbuf *strbuf; |
702 | unsigned long flags, ctx, npages; | 689 | unsigned long flags, ctx, npages; |
703 | 690 | ||
704 | pcp = pdev->sysdata; | 691 | iommu = pdev->dev.archdata.iommu; |
705 | iommu = pcp->pbm->iommu; | 692 | strbuf = pdev->dev.archdata.stc; |
706 | strbuf = &pcp->pbm->stc; | ||
707 | 693 | ||
708 | if (!strbuf->strbuf_enabled) | 694 | if (!strbuf->strbuf_enabled) |
709 | return; | 695 | return; |
@@ -736,15 +722,13 @@ static void pci_4u_dma_sync_single_for_cpu(struct pci_dev *pdev, dma_addr_t bus_ | |||
736 | */ | 722 | */ |
737 | static void pci_4u_dma_sync_sg_for_cpu(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction) | 723 | static void pci_4u_dma_sync_sg_for_cpu(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction) |
738 | { | 724 | { |
739 | struct pcidev_cookie *pcp; | ||
740 | struct pci_iommu *iommu; | 725 | struct pci_iommu *iommu; |
741 | struct pci_strbuf *strbuf; | 726 | struct pci_strbuf *strbuf; |
742 | unsigned long flags, ctx, npages, i; | 727 | unsigned long flags, ctx, npages, i; |
743 | u32 bus_addr; | 728 | u32 bus_addr; |
744 | 729 | ||
745 | pcp = pdev->sysdata; | 730 | iommu = pdev->dev.archdata.iommu; |
746 | iommu = pcp->pbm->iommu; | 731 | strbuf = pdev->dev.archdata.stc; |
747 | strbuf = &pcp->pbm->stc; | ||
748 | 732 | ||
749 | if (!strbuf->strbuf_enabled) | 733 | if (!strbuf->strbuf_enabled) |
750 | return; | 734 | return; |
@@ -809,13 +793,12 @@ static void ali_sound_dma_hack(struct pci_dev *pdev, int set_bit) | |||
809 | 793 | ||
810 | int pci_dma_supported(struct pci_dev *pdev, u64 device_mask) | 794 | int pci_dma_supported(struct pci_dev *pdev, u64 device_mask) |
811 | { | 795 | { |
812 | struct pcidev_cookie *pcp = pdev->sysdata; | ||
813 | u64 dma_addr_mask; | 796 | u64 dma_addr_mask; |
814 | 797 | ||
815 | if (pdev == NULL) { | 798 | if (pdev == NULL) { |
816 | dma_addr_mask = 0xffffffff; | 799 | dma_addr_mask = 0xffffffff; |
817 | } else { | 800 | } else { |
818 | struct pci_iommu *iommu = pcp->pbm->iommu; | 801 | struct pci_iommu *iommu = pdev->dev.archdata.iommu; |
819 | 802 | ||
820 | dma_addr_mask = iommu->dma_addr_mask; | 803 | dma_addr_mask = iommu->dma_addr_mask; |
821 | 804 | ||