summaryrefslogtreecommitdiff
path: root/drivers/iommu/qcom/msm_iommu_priv.h
blob: 4de0d7ef19e632dba4447cf37337e916babfbd6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef MSM_IOMMU_PRIV_H
#define MSM_IOMMU_PRIV_H

/**
 * struct msm_iommu_pt - Container for first level page table and its
 * attributes.
 * fl_table: Pointer to the first level page table.
 * redirect: Set to 1 if L2 redirect for page tables are enabled, 0 otherwise.
 * unaligned_fl_table: Original address of memory for the page table.
 * fl_table is manually aligned (as per spec) but we need the original address
 * to free the table.
 * fl_table_shadow: This is "copy" of the fl_table with some differences.
 * It stores the same information as fl_table except that instead of storing
 * second level page table address + page table entry descriptor bits it
 * stores the second level page table address and the number of used second
 * level page tables entries. This is used to check whether we need to free
 * the second level page table which allows us to also free the second level
 * page table after doing a TLB invalidate which should catch bugs with
 * clients trying to unmap an address that is being used.
 * fl_table_shadow will use the lower 9 bits for the use count and the upper
 * bits for the second level page table address.
 * sl_table_shadow uses the same concept as fl_table_shadow but for LPAE 2nd
 * level page tables.
 */
#ifdef CONFIG_IOMMU_LPAE
struct msm_iommu_pt {
	u64 *fl_table;
	u64 **sl_table_shadow;
	int redirect;
	u64 *unaligned_fl_table;
};
#else
struct msm_iommu_pt {
	u32 *fl_table;
	int redirect;
	u32 *fl_table_shadow;
};
#endif
/**
 * struct msm_iommu_priv - Container for page table attributes and other
 * private iommu domain information.
 * attributes.
 * pt: Page table attribute structure
 * list_attached: List of devices (contexts) attached to this domain.
 * client_name: Name of the domain client.
 */
struct msm_iommu_priv {
	struct msm_iommu_pt pt;
	struct list_head list_attached;
	struct iommu_domain domain;
	const char *client_name;
};

static inline struct msm_iommu_priv *to_msm_priv(struct iommu_domain *dom)
{
	return container_of(dom, struct msm_iommu_priv, domain);
}

#endif