summaryrefslogtreecommitdiffstats
path: root/src/testdir/Make_amiga.mak
AgeCommit message (Expand)Author
2020-08-14patch 8.2.1449: some test makefiles delete files that are not generatedv8.2.1449Bram Moolenaar
2020-08-13patch 8.2.1439: tiny and small builds have no test coveragev8.2.1439Bram Moolenaar
2020-08-11patch 8.2.1420: test 49 is old stylev8.2.1420Bram Moolenaar
2020-07-27patch 8.2.1305: some tests are still old stylev8.2.1305Bram Moolenaar
2019-07-05patch 8.1.1637: after running tests and clean the XfakeHOME directory remainsv8.1.1637Bram Moolenaar
2019-04-25patch 8.1.1203: some autocmd tests are old stylev8.1.1203Bram Moolenaar
2019-01-11patch 8.1.0723: cannot easily run specific test when in src/testdirv8.1.0723Bram Moolenaar
2018-06-30patch 8.1.0132: lua tests are old stylev8.1.0132Bram Moolenaar
2017-11-02patch 8.0.1253: still too many old style testsv8.0.1253Bram Moolenaar
2017-10-26patch 8.0.1221: still too many old style testsv8.0.1221Bram Moolenaar
2017-10-22patch 8.0.1209: still too many old style testsv8.0.1209Bram Moolenaar
2016-02-28patch 7.4.1453v7.4.1453Bram Moolenaar
2016-01-16patch 7.4.1111v7.4.1111Bram Moolenaar
2015-12-28patch 7.4.988v7.4.988Bram Moolenaar
2015-12-28patch 7.4.983v7.4.983Bram Moolenaar
2015-12-28patch 7.4.982v7.4.982Bram Moolenaar
2015-12-28patch 7.4.980v7.4.980Bram Moolenaar
2015-12-03patch 7.4.952v7.4.952Bram Moolenaar
2015-11-28patch 7.4.943v7.4.943Bram Moolenaar
2015-11-24patch 7.4.941v7.4.941Bram Moolenaar
2015-09-08patch 7.4.858v7.4.858Bram Moolenaar
2015-09-01patch 7.4.844v7.4.844Bram Moolenaar
2015-08-11patch 7.4.813v7.4.813Bram Moolenaar
2015-07-21patch 7.4.792v7.4.792Bram Moolenaar
2015-07-17patch 7.4.786v7.4.786Bram Moolenaar
2015-07-17patch 7.4.785v7.4.785Bram Moolenaar
2015-07-10patch 7.4.771v7.4.771Bram Moolenaar
2015-06-25patch 7.4.754v7.4.754Bram Moolenaar
2015-06-19patch 7.4.744v7.4.744Bram Moolenaar
2015-06-19patch 7.4.741v7.4.741Bram Moolenaar
2015-04-21patch 7.4.710v7.4.710Bram Moolenaar
2015-03-24updated for version 7.4.680v7.4.680Bram Moolenaar
2015-03-13updated for version 7.4.662v7.4.662Bram Moolenaar
2015-02-17updated for version 7.4.634v7.4.634Bram Moolenaar
2015-01-20updated for version 7.4.588v7.4.588Bram Moolenaar
2014-12-13updated for version 7.4.549v7.4.549Bram Moolenaar
2014-12-08updated for version 7.4.542v7.4.542Bram Moolenaar
2014-11-27updated for version 7.4.530v7.4.530Bram Moolenaar
2014-10-21updated for version 7.4.487v7.4.487Bram Moolenaar
2014-10-21updated for version 7.4.483v7.4.483Bram Moolenaar
2014-08-16updated for version 7.4.408v7.4.408Bram Moolenaar
2014-07-30updated for version 7.4.387v7.4.387Bram Moolenaar
2014-07-30updated for version 7.4.386v7.4.386Bram Moolenaar
2014-07-23updated for version 7.4.378v7.4.378Bram Moolenaar
2014-07-16updated for version 7.4.370v7.4.370Bram Moolenaar
2014-07-02updated for version 7.4.353v7.4.353Bram Moolenaar
2014-06-25updated for version 7.4.338v7.4.338Bram Moolenaar
2014-05-29updated for version 7.4.315v7.4.315Bram Moolenaar
2014-04-29updated for version 7.4.267v7.4.267Bram Moolenaar
2014-04-02updated for version 7.4.242v7.4.242Bram Moolenaar
href='#n527'>527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2011-2014 NVIDIA CORPORATION.  All rights reserved.
 */

#include <linux/bitops.h>
#include <linux/debugfs.h>
#include <linux/err.h>
#include <linux/iommu.h>
#include <linux/kernel.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/dma-mapping.h>

#include <soc/tegra/ahb.h>
#include <soc/tegra/mc.h>

struct tegra_smmu_group {
	struct list_head list;
	const struct tegra_smmu_group_soc *soc;
	struct iommu_group *group;
};

struct tegra_smmu {
	void __iomem *regs;
	struct device *dev;

	struct tegra_mc *mc;
	const struct tegra_smmu_soc *soc;

	struct list_head groups;

	unsigned long pfn_mask;
	unsigned long tlb_mask;

	unsigned long *asids;
	struct mutex lock;

	struct list_head list;

	struct dentry *debugfs;

	struct iommu_device iommu;	/* IOMMU Core code handle */
};

struct tegra_smmu_as {
	struct iommu_domain domain;
	struct tegra_smmu *smmu;
	unsigned int use_count;
	u32 *count;
	struct page **pts;
	struct page *pd;
	dma_addr_t pd_dma;
	unsigned id;
	u32 attr;
};

static struct tegra_smmu_as *to_smmu_as(struct iommu_domain *dom)
{
	return container_of(dom, struct tegra_smmu_as, domain);
}

static inline void smmu_writel(struct tegra_smmu *smmu, u32 value,
			       unsigned long offset)
{
	writel(value, smmu->regs + offset);
}

static inline u32 smmu_readl(struct tegra_smmu *smmu, unsigned long offset)
{
	return readl(smmu->regs + offset);
}

#define SMMU_CONFIG 0x010
#define  SMMU_CONFIG_ENABLE (1 << 0)

#define SMMU_TLB_CONFIG 0x14
#define  SMMU_TLB_CONFIG_HIT_UNDER_MISS (1 << 29)
#define  SMMU_TLB_CONFIG_ROUND_ROBIN_ARBITRATION (1 << 28)
#define  SMMU_TLB_CONFIG_ACTIVE_LINES(smmu) \
	((smmu)->soc->num_tlb_lines & (smmu)->tlb_mask)

#define SMMU_PTC_CONFIG 0x18
#define  SMMU_PTC_CONFIG_ENABLE (1 << 29)
#define  SMMU_PTC_CONFIG_REQ_LIMIT(x) (((x) & 0x0f) << 24)
#define  SMMU_PTC_CONFIG_INDEX_MAP(x) ((x) & 0x3f)

#define SMMU_PTB_ASID 0x01c
#define  SMMU_PTB_ASID_VALUE(x) ((x) & 0x7f)

#define SMMU_PTB_DATA 0x020
#define  SMMU_PTB_DATA_VALUE(dma, attr) ((dma) >> 12 | (attr))

#define SMMU_MK_PDE(dma, attr) ((dma) >> SMMU_PTE_SHIFT | (attr))

#define SMMU_TLB_FLUSH 0x030
#define  SMMU_TLB_FLUSH_VA_MATCH_ALL     (0 << 0)
#define  SMMU_TLB_FLUSH_VA_MATCH_SECTION (2 << 0)
#define  SMMU_TLB_FLUSH_VA_MATCH_GROUP   (3 << 0)
#define  SMMU_TLB_FLUSH_VA_SECTION(addr) ((((addr) & 0xffc00000) >> 12) | \
					  SMMU_TLB_FLUSH_VA_MATCH_SECTION)
#define  SMMU_TLB_FLUSH_VA_GROUP(addr)   ((((addr) & 0xffffc000) >> 12) | \
					  SMMU_TLB_FLUSH_VA_MATCH_GROUP)
#define  SMMU_TLB_FLUSH_ASID_MATCH       (1 << 31)

#define SMMU_PTC_FLUSH 0x034
#define  SMMU_PTC_FLUSH_TYPE_ALL (0 << 0)
#define  SMMU_PTC_FLUSH_TYPE_ADR (1 << 0)

#define SMMU_PTC_FLUSH_HI 0x9b8
#define  SMMU_PTC_FLUSH_HI_MASK 0x3

/* per-SWGROUP SMMU_*_ASID register */
#define SMMU_ASID_ENABLE (1 << 31)
#define SMMU_ASID_MASK 0x7f
#define SMMU_ASID_VALUE(x) ((x) & SMMU_ASID_MASK)

/* page table definitions */
#define SMMU_NUM_PDE 1024
#define SMMU_NUM_PTE 1024

#define SMMU_SIZE_PD (SMMU_NUM_PDE * 4)
#define SMMU_SIZE_PT (SMMU_NUM_PTE * 4)

#define SMMU_PDE_SHIFT 22
#define SMMU_PTE_SHIFT 12

#define SMMU_PD_READABLE	(1 << 31)
#define SMMU_PD_WRITABLE	(1 << 30)
#define SMMU_PD_NONSECURE	(1 << 29)

#define SMMU_PDE_READABLE	(1 << 31)
#define SMMU_PDE_WRITABLE	(1 << 30)
#define SMMU_PDE_NONSECURE	(1 << 29)
#define SMMU_PDE_NEXT		(1 << 28)

#define SMMU_PTE_READABLE	(1 << 31)
#define SMMU_PTE_WRITABLE	(1 << 30)
#define SMMU_PTE_NONSECURE	(1 << 29)

#define SMMU_PDE_ATTR		(SMMU_PDE_READABLE | SMMU_PDE_WRITABLE | \
				 SMMU_PDE_NONSECURE)

static unsigned int iova_pd_index(unsigned long iova)
{
	return (iova >> SMMU_PDE_SHIFT) & (SMMU_NUM_PDE - 1);
}

static unsigned int iova_pt_index(unsigned long iova)
{
	return (iova >> SMMU_PTE_SHIFT) & (SMMU_NUM_PTE - 1);
}

static bool smmu_dma_addr_valid(struct tegra_smmu *smmu, dma_addr_t addr)
{
	addr >>= 12;
	return (addr & smmu->pfn_mask) == addr;
}

static dma_addr_t smmu_pde_to_dma(struct tegra_smmu *smmu, u32 pde)
{
	return (dma_addr_t)(pde & smmu->pfn_mask) << 12;
}

static void smmu_flush_ptc_all(struct tegra_smmu *smmu)
{
	smmu_writel(smmu, SMMU_PTC_FLUSH_TYPE_ALL, SMMU_PTC_FLUSH);
}

static inline void smmu_flush_ptc(struct tegra_smmu *smmu, dma_addr_t dma,
				  unsigned long offset)
{
	u32 value;

	offset &= ~(smmu->mc->soc->atom_size - 1);

	if (smmu->mc->soc->num_address_bits >