diff options
author | Milton Miller <miltonm@bga.com> | 2011-05-11 08:25:00 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-05-19 03:25:28 -0400 |
commit | b73a635f348610304eee543d733a6277f67ba178 (patch) | |
tree | bd401ccf03f8d1ed524d83eba8089ea5bf5198f8 | |
parent | c85667802bb5093c4054f8a887a90dd0acf82d3e (diff) |
powerpc/pseries/iommu: Cleanup ddw naming
When using a property refering to the availibily of dynamic dma windows
call it ddw_avail not ddr_avail.
dupe_ddw_if_already_created does not dupilcate anything, it only finds
and reuses the windows we already created, so rename it to
find_existing_ddw. Also, it does not need the pci device node, so
remove that argument.
Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | arch/powerpc/platforms/pseries/iommu.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index a48f12644239..01faab9456ca 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c | |||
@@ -659,16 +659,16 @@ static void remove_ddw(struct device_node *np) | |||
659 | { | 659 | { |
660 | struct dynamic_dma_window_prop *dwp; | 660 | struct dynamic_dma_window_prop *dwp; |
661 | struct property *win64; | 661 | struct property *win64; |
662 | const u32 *ddr_avail; | 662 | const u32 *ddw_avail; |
663 | u64 liobn; | 663 | u64 liobn; |
664 | int len, ret; | 664 | int len, ret; |
665 | 665 | ||
666 | ddr_avail = of_get_property(np, "ibm,ddw-applicable", &len); | 666 | ddw_avail = of_get_property(np, "ibm,ddw-applicable", &len); |
667 | win64 = of_find_property(np, DIRECT64_PROPNAME, NULL); | 667 | win64 = of_find_property(np, DIRECT64_PROPNAME, NULL); |
668 | if (!win64) | 668 | if (!win64) |
669 | return; | 669 | return; |
670 | 670 | ||
671 | if (!ddr_avail || len < 3 * sizeof(u32) || win64->length < sizeof(*dwp)) | 671 | if (!ddw_avail || len < 3 * sizeof(u32) || win64->length < sizeof(*dwp)) |
672 | goto delprop; | 672 | goto delprop; |
673 | 673 | ||
674 | dwp = win64->value; | 674 | dwp = win64->value; |
@@ -684,15 +684,15 @@ static void remove_ddw(struct device_node *np) | |||
684 | pr_debug("%s successfully cleared tces in window.\n", | 684 | pr_debug("%s successfully cleared tces in window.\n", |
685 | np->full_name); | 685 | np->full_name); |
686 | 686 | ||
687 | ret = rtas_call(ddr_avail[2], 1, 1, NULL, liobn); | 687 | ret = rtas_call(ddw_avail[2], 1, 1, NULL, liobn); |
688 | if (ret) | 688 | if (ret) |
689 | pr_warning("%s: failed to remove direct window: rtas returned " | 689 | pr_warning("%s: failed to remove direct window: rtas returned " |
690 | "%d to ibm,remove-pe-dma-window(%x) %llx\n", | 690 | "%d to ibm,remove-pe-dma-window(%x) %llx\n", |
691 | np->full_name, ret, ddr_avail[2], liobn); | 691 | np->full_name, ret, ddw_avail[2], liobn); |
692 | else | 692 | else |
693 | pr_debug("%s: successfully removed direct window: rtas returned " | 693 | pr_debug("%s: successfully removed direct window: rtas returned " |
694 | "%d to ibm,remove-pe-dma-window(%x) %llx\n", | 694 | "%d to ibm,remove-pe-dma-window(%x) %llx\n", |
695 | np->full_name, ret, ddr_avail[2], liobn); | 695 | np->full_name, ret, ddw_avail[2], liobn); |
696 | 696 | ||
697 | delprop: | 697 | delprop: |
698 | ret = prom_remove_property(np, win64); | 698 | ret = prom_remove_property(np, win64); |
@@ -701,16 +701,12 @@ delprop: | |||
701 | np->full_name, ret); | 701 | np->full_name, ret); |
702 | } | 702 | } |
703 | 703 | ||
704 | static u64 dupe_ddw_if_already_created(struct pci_dev *dev, struct device_node *pdn) | 704 | static u64 find_existing_ddw(struct device_node *pdn) |
705 | { | 705 | { |
706 | struct device_node *dn; | ||
707 | struct pci_dn *pcidn; | ||
708 | struct direct_window *window; | 706 | struct direct_window *window; |
709 | const struct dynamic_dma_window_prop *direct64; | 707 | const struct dynamic_dma_window_prop *direct64; |
710 | u64 dma_addr = 0; | 708 | u64 dma_addr = 0; |
711 | 709 | ||
712 | dn = pci_device_to_OF_node(dev); | ||
713 | pcidn = PCI_DN(dn); | ||
714 | spin_lock(&direct_window_list_lock); | 710 | spin_lock(&direct_window_list_lock); |
715 | /* check if we already created a window and dupe that config if so */ | 711 | /* check if we already created a window and dupe that config if so */ |
716 | list_for_each_entry(window, &direct_window_list, list) { | 712 | list_for_each_entry(window, &direct_window_list, list) { |
@@ -758,7 +754,7 @@ static int find_existing_ddw_windows(void) | |||
758 | } | 754 | } |
759 | machine_arch_initcall(pseries, find_existing_ddw_windows); | 755 | machine_arch_initcall(pseries, find_existing_ddw_windows); |
760 | 756 | ||
761 | static int query_ddw(struct pci_dev *dev, const u32 *ddr_avail, | 757 | static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail, |
762 | struct ddw_query_response *query) | 758 | struct ddw_query_response *query) |
763 | { | 759 | { |
764 | struct device_node *dn; | 760 | struct device_node *dn; |
@@ -779,15 +775,15 @@ static int query_ddw(struct pci_dev *dev, const u32 *ddr_avail, | |||
779 | if (pcidn->eeh_pe_config_addr) | 775 | if (pcidn->eeh_pe_config_addr) |
780 | cfg_addr = pcidn->eeh_pe_config_addr; | 776 | cfg_addr = pcidn->eeh_pe_config_addr; |
781 | buid = pcidn->phb->buid; | 777 | buid = pcidn->phb->buid; |
782 | ret = rtas_call(ddr_avail[0], 3, 5, (u32 *)query, | 778 | ret = rtas_call(ddw_avail[0], 3, 5, (u32 *)query, |
783 | cfg_addr, BUID_HI(buid), BUID_LO(buid)); | 779 | cfg_addr, BUID_HI(buid), BUID_LO(buid)); |
784 | dev_info(&dev->dev, "ibm,query-pe-dma-windows(%x) %x %x %x" | 780 | dev_info(&dev->dev, "ibm,query-pe-dma-windows(%x) %x %x %x" |
785 | " returned %d\n", ddr_avail[0], cfg_addr, BUID_HI(buid), | 781 | " returned %d\n", ddw_avail[0], cfg_addr, BUID_HI(buid), |
786 | BUID_LO(buid), ret); | 782 | BUID_LO(buid), ret); |
787 | return ret; | 783 | return ret; |
788 | } | 784 | } |
789 | 785 | ||
790 | static int create_ddw(struct pci_dev *dev, const u32 *ddr_avail, | 786 | static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail, |
791 | struct ddw_create_response *create, int page_shift, | 787 | struct ddw_create_response *create, int page_shift, |
792 | int window_shift) | 788 | int window_shift) |
793 | { | 789 | { |
@@ -812,12 +808,12 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddr_avail, | |||
812 | 808 | ||
813 | do { | 809 | do { |
814 | /* extra outputs are LIOBN and dma-addr (hi, lo) */ | 810 | /* extra outputs are LIOBN and dma-addr (hi, lo) */ |
815 | ret = rtas_call(ddr_avail[1], 5, 4, (u32 *)create, cfg_addr, | 811 | ret = rtas_call(ddw_avail[1], 5, 4, (u32 *)create, cfg_addr, |
816 | BUID_HI(buid), BUID_LO(buid), page_shift, window_shift); | 812 | BUID_HI(buid), BUID_LO(buid), page_shift, window_shift); |
817 | } while (rtas_busy_delay(ret)); | 813 | } while (rtas_busy_delay(ret)); |
818 | dev_info(&dev->dev, | 814 | dev_info(&dev->dev, |
819 | "ibm,create-pe-dma-window(%x) %x %x %x %x %x returned %d " | 815 | "ibm,create-pe-dma-window(%x) %x %x %x %x %x returned %d " |
820 | "(liobn = 0x%x starting addr = %x %x)\n", ddr_avail[1], | 816 | "(liobn = 0x%x starting addr = %x %x)\n", ddw_avail[1], |
821 | cfg_addr, BUID_HI(buid), BUID_LO(buid), page_shift, | 817 | cfg_addr, BUID_HI(buid), BUID_LO(buid), page_shift, |
822 | window_shift, ret, create->liobn, create->addr_hi, create->addr_lo); | 818 | window_shift, ret, create->liobn, create->addr_hi, create->addr_lo); |
823 | 819 | ||
@@ -843,14 +839,14 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn) | |||
843 | int page_shift; | 839 | int page_shift; |
844 | u64 dma_addr, max_addr; | 840 | u64 dma_addr, max_addr; |
845 | struct device_node *dn; | 841 | struct device_node *dn; |
846 | const u32 *uninitialized_var(ddr_avail); | 842 | const u32 *uninitialized_var(ddw_avail); |
847 | struct direct_window *window; | 843 | struct direct_window *window; |
848 | struct property *win64; | 844 | struct property *win64; |
849 | struct dynamic_dma_window_prop *ddwprop; | 845 | struct dynamic_dma_window_prop *ddwprop; |
850 | 846 | ||
851 | mutex_lock(&direct_window_init_mutex); | 847 | mutex_lock(&direct_window_init_mutex); |
852 | 848 | ||
853 | dma_addr = dupe_ddw_if_already_created(dev, pdn); | 849 | dma_addr = find_existing_ddw(pdn); |
854 | if (dma_addr != 0) | 850 | if (dma_addr != 0) |
855 | goto out_unlock; | 851 | goto out_unlock; |
856 | 852 | ||
@@ -862,8 +858,8 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn) | |||
862 | * for the given node in that order. | 858 | * for the given node in that order. |
863 | * the property is actually in the parent, not the PE | 859 | * the property is actually in the parent, not the PE |
864 | */ | 860 | */ |
865 | ddr_avail = of_get_property(pdn, "ibm,ddw-applicable", &len); | 861 | ddw_avail = of_get_property(pdn, "ibm,ddw-applicable", &len); |
866 | if (!ddr_avail || len < 3 * sizeof(u32)) | 862 | if (!ddw_avail || len < 3 * sizeof(u32)) |
867 | goto out_unlock; | 863 | goto out_unlock; |
868 | 864 | ||
869 | /* | 865 | /* |
@@ -873,7 +869,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn) | |||
873 | * of page sizes: supported and supported for migrate-dma. | 869 | * of page sizes: supported and supported for migrate-dma. |
874 | */ | 870 | */ |
875 | dn = pci_device_to_OF_node(dev); | 871 | dn = pci_device_to_OF_node(dev); |
876 | ret = query_ddw(dev, ddr_avail, &query); | 872 | ret = query_ddw(dev, ddw_avail, &query); |
877 | if (ret != 0) | 873 | if (ret != 0) |
878 | goto out_unlock; | 874 | goto out_unlock; |
879 | 875 | ||
@@ -922,7 +918,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn) | |||
922 | goto out_free_prop; | 918 | goto out_free_prop; |
923 | } | 919 | } |
924 | 920 | ||
925 | ret = create_ddw(dev, ddr_avail, &create, page_shift, len); | 921 | ret = create_ddw(dev, ddw_avail, &create, page_shift, len); |
926 | if (ret != 0) | 922 | if (ret != 0) |
927 | goto out_free_prop; | 923 | goto out_free_prop; |
928 | 924 | ||