aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/powertv/asic
diff options
context:
space:
mode:
authorDavid VomLehn <dvomlehn@cisco.com>2010-05-21 14:25:36 -0400
committerRalf Baechle <ralf@linux-mips.org>2010-08-05 08:25:40 -0400
commitca36c36b7821b573fe06ce6bc34db03b557f3ce4 (patch)
tree28fe24b5080e29ca62ff4d1b4bbf5afc83084792 /arch/mips/powertv/asic
parent36f217d9df3e6bf8e6ae7647827b485b79dbaf8e (diff)
MIPS: PowerTV: Use O(1) algorthm for phys_to_dma/dma_to_phys
Replace phys_to_dma()/dma_to_phys() looping algorithm with an O(1) algorithm The approach taken is inspired by the sparse memory implementation: take a certain number of high-order bits off the address them, use this as an index into a table containing an offset to the desired address and add it to the original value. There is a table for mapping physical addresses to DMA addresses and another one for the reverse mapping. The table sizes depend on how fine-grained the mappings need to be; Coarser granularity less to smaller tables. On a processor with 32-bit physical and DMA addresses, with 4 MIB granularity, memory usage is two 2048-byte arrays. Each 32-byte cache line thus covers 64 MiB of address space. Also, renames phys_to_bus() to phys_to_dma() and bus_to_phys() to dma_to_phys() to align with kernel usage. [Ralf: Fixed silly build breakage due to stackoverflow warning caused by huge array on stack.] Signed-off-by: David VomLehn <dvomlehn@cisco.com> To: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/1257/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/powertv/asic')
-rw-r--r--arch/mips/powertv/asic/asic_devices.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/arch/mips/powertv/asic/asic_devices.c b/arch/mips/powertv/asic/asic_devices.c
index 9ec523e4dd06..c81dd497ed7b 100644
--- a/arch/mips/powertv/asic/asic_devices.c
+++ b/arch/mips/powertv/asic/asic_devices.c
@@ -80,8 +80,8 @@ static bool usb_configured;
80 * Don't recommend to use it directly, it is usually used by kernel internally. 80 * Don't recommend to use it directly, it is usually used by kernel internally.
81 * Portable code should be using interfaces such as ioremp, dma_map_single, etc. 81 * Portable code should be using interfaces such as ioremp, dma_map_single, etc.
82 */ 82 */
83unsigned long phys_to_bus_offset; 83unsigned long phys_to_dma_offset;
84EXPORT_SYMBOL(phys_to_bus_offset); 84EXPORT_SYMBOL(phys_to_dma_offset);
85 85
86/* 86/*
87 * 87 *
@@ -533,10 +533,10 @@ void __init configure_platform(void)
533 533
534 switch (asic) { 534 switch (asic) {
535 case ASIC_ZEUS: 535 case ASIC_ZEUS:
536 phys_to_bus_offset = 0x30000000; 536 phys_to_dma_offset = 0x30000000;
537 break; 537 break;
538 case ASIC_CALLIOPE: 538 case ASIC_CALLIOPE:
539 phys_to_bus_offset = 0x10000000; 539 phys_to_dma_offset = 0x10000000;
540 break; 540 break;
541 case ASIC_CRONUSLITE: 541 case ASIC_CRONUSLITE:
542 /* Fall through */ 542 /* Fall through */
@@ -546,10 +546,10 @@ void __init configure_platform(void)
546 * 0x2XXXXXXX. If 0x10000000 aliases into 0x60000000- 546 * 0x2XXXXXXX. If 0x10000000 aliases into 0x60000000-
547 * 0x6XXXXXXX, the offset should be 0x50000000, not 0x10000000. 547 * 0x6XXXXXXX, the offset should be 0x50000000, not 0x10000000.
548 */ 548 */
549 phys_to_bus_offset = 0x10000000; 549 phys_to_dma_offset = 0x10000000;
550 break; 550 break;
551 default: 551 default:
552 phys_to_bus_offset = 0x00000000; 552 phys_to_dma_offset = 0x00000000;
553 break; 553 break;
554 } 554 }
555} 555}
@@ -603,7 +603,7 @@ void __init platform_alloc_bootmem(void)
603 int size = gp_resources[i].end - gp_resources[i].start + 1; 603 int size = gp_resources[i].end - gp_resources[i].start + 1;
604 if ((gp_resources[i].start != 0) && 604 if ((gp_resources[i].start != 0) &&
605 ((gp_resources[i].flags & IORESOURCE_MEM) != 0)) { 605 ((gp_resources[i].flags & IORESOURCE_MEM) != 0)) {
606 reserve_bootmem(bus_to_phys(gp_resources[i].start), 606 reserve_bootmem(dma_to_phys(gp_resources[i].start),
607 size, 0); 607 size, 0);
608 total += gp_resources[i].end - 608 total += gp_resources[i].end -
609 gp_resources[i].start + 1; 609 gp_resources[i].start + 1;
@@ -627,7 +627,7 @@ void __init platform_alloc_bootmem(void)
627 627
628 else { 628 else {
629 gp_resources[i].start = 629 gp_resources[i].start =
630 phys_to_bus(virt_to_phys(mem)); 630 phys_to_dma(virt_to_phys(mem));
631 gp_resources[i].end = 631 gp_resources[i].end =
632 gp_resources[i].start + size - 1; 632 gp_resources[i].start + size - 1;
633 total += size; 633 total += size;
@@ -691,7 +691,7 @@ static void __init pmem_setup_resource(void)
691 if (resource && pmemaddr && pmemlen) { 691 if (resource && pmemaddr && pmemlen) {
692 /* The address provided by bootloader is in kseg0. Convert to 692 /* The address provided by bootloader is in kseg0. Convert to
693 * a bus address. */ 693 * a bus address. */
694 resource->start = phys_to_bus(pmemaddr - 0x80000000); 694 resource->start = phys_to_dma(pmemaddr - 0x80000000);
695 resource->end = resource->start + pmemlen - 1; 695 resource->end = resource->start + pmemlen - 1;
696 696
697 pr_info("persistent memory: start=0x%x end=0x%x\n", 697 pr_info("persistent memory: start=0x%x end=0x%x\n",