diff options
| author | Hiroshi Doyu <hdoyu@nvidia.com> | 2012-09-14 12:22:00 -0400 |
|---|---|---|
| committer | Joerg Roedel <joerg.roedel@amd.com> | 2012-09-18 06:36:38 -0400 |
| commit | 5a2c937a8be8c9c5a6d23308b5ee841b6394a1cf (patch) | |
| tree | d38dc60a32b3112d19805cdcecd381f3140a6c80 | |
| parent | 39abf8aa7dfad0badb4741373023cda369aacc8e (diff) | |
iommu/tegra: smmu: Use debugfs_create_dir for directory
The commit c3b1a35 "debugfs: make sure that debugfs_create_file() gets
used only for regulars" doesn't allow to use debugfs_create_file() for
dir. Keep debugfs data in smmu_device instead of directory's i_private.
Signed-off-by: Hiroshi Doyu <hdoyu@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
| -rw-r--r-- | drivers/iommu/tegra-smmu.c | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 95b4698abd3e..7e42c71c1ffc 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c | |||
| @@ -246,6 +246,12 @@ struct smmu_as { | |||
| 246 | spinlock_t client_lock; /* for client list */ | 246 | spinlock_t client_lock; /* for client list */ |
| 247 | }; | 247 | }; |
| 248 | 248 | ||
| 249 | struct smmu_debugfs_info { | ||
| 250 | struct smmu_device *smmu; | ||
| 251 | int mc; | ||
| 252 | int cache; | ||
| 253 | }; | ||
| 254 | |||
| 249 | /* | 255 | /* |
| 250 | * Per SMMU device - IOMMU device | 256 | * Per SMMU device - IOMMU device |
| 251 | */ | 257 | */ |
| @@ -267,6 +273,7 @@ struct smmu_device { | |||
| 267 | unsigned long asid_security; | 273 | unsigned long asid_security; |
| 268 | 274 | ||
| 269 | struct dentry *debugfs_root; | 275 | struct dentry *debugfs_root; |
| 276 | struct smmu_debugfs_info *debugfs_info; | ||
| 270 | 277 | ||
| 271 | struct device_node *ahb; | 278 | struct device_node *ahb; |
| 272 | 279 | ||
| @@ -917,9 +924,10 @@ static ssize_t smmu_debugfs_stats_write(struct file *file, | |||
| 917 | const char __user *buffer, | 924 | const char __user *buffer, |
| 918 | size_t count, loff_t *pos) | 925 | size_t count, loff_t *pos) |
| 919 | { | 926 | { |
| 927 | struct smmu_debugfs_info *info; | ||
| 920 | struct smmu_device *smmu; | 928 | struct smmu_device *smmu; |
| 921 | struct dentry *dent; | 929 | struct dentry *dent; |
| 922 | int i, cache, mc; | 930 | int i; |
| 923 | enum { | 931 | enum { |
| 924 | _OFF = 0, | 932 | _OFF = 0, |
| 925 | _ON, | 933 | _ON, |
| @@ -947,11 +955,10 @@ static ssize_t smmu_debugfs_stats_write(struct file *file, | |||
| 947 | return -EINVAL; | 955 | return -EINVAL; |
| 948 | 956 | ||
| 949 | dent = file->f_dentry; | 957 | dent = file->f_dentry; |
| 950 | cache = (int)dent->d_inode->i_private; | 958 | info = dent->d_inode->i_private; |
| 951 | mc = (int)dent->d_parent->d_inode->i_private; | 959 | smmu = info->smmu; |
| 952 | smmu = dent->d_parent->d_parent->d_inode->i_private; | ||
| 953 | 960 | ||
| 954 | offs = SMMU_CACHE_CONFIG(cache); | 961 | offs = SMMU_CACHE_CONFIG(info->cache); |
| 955 | val = smmu_read(smmu, offs); | 962 | val = smmu_read(smmu, offs); |
| 956 | switch (i) { | 963 | switch (i) { |
| 957 | case _OFF: | 964 | case _OFF: |
| @@ -983,21 +990,21 @@ static ssize_t smmu_debugfs_stats_write(struct file *file, | |||
| 983 | 990 | ||
| 984 | static int smmu_debugfs_stats_show(struct seq_file *s, void *v) | 991 | static int smmu_debugfs_stats_show(struct seq_file *s, void *v) |
| 985 | { | 992 | { |
| 993 | struct smmu_debugfs_info *info; | ||
| 986 | struct smmu_device *smmu; | 994 | struct smmu_device *smmu; |
| 987 | struct dentry *dent; | 995 | struct dentry *dent; |
| 988 | int i, cache, mc; | 996 | int i; |
| 989 | const char * const stats[] = { "hit", "miss", }; | 997 | const char * const stats[] = { "hit", "miss", }; |
| 990 | 998 | ||
| 991 | dent = d_find_alias(s->private); | 999 | dent = d_find_alias(s->private); |
| 992 | cache = (int)dent->d_inode->i_private; | 1000 | info = dent->d_inode->i_private; |
| 993 | mc = (int)dent->d_parent->d_inode->i_private; | 1001 | smmu = info->smmu; |
| 994 | smmu = dent->d_parent->d_parent->d_inode->i_private; | ||
| 995 | 1002 | ||
| 996 | for (i = 0; i < ARRAY_SIZE(stats); i++) { | 1003 | for (i = 0; i < ARRAY_SIZE(stats); i++) { |
| 997 | u32 val; | 1004 | u32 val; |
| 998 | size_t offs; | 1005 | size_t offs; |
| 999 | 1006 | ||
| 1000 | offs = SMMU_STATS_CACHE_COUNT(mc, cache, i); | 1007 | offs = SMMU_STATS_CACHE_COUNT(info->mc, info->cache, i); |
| 1001 | val = smmu_read(smmu, offs); | 1008 | val = smmu_read(smmu, offs); |
| 1002 | seq_printf(s, "%s:%08x ", stats[i], val); | 1009 | seq_printf(s, "%s:%08x ", stats[i], val); |
| 1003 | 1010 | ||
| @@ -1025,16 +1032,22 @@ static const struct file_operations smmu_debugfs_stats_fops = { | |||
| 1025 | static void smmu_debugfs_delete(struct smmu_device *smmu) | 1032 | static void smmu_debugfs_delete(struct smmu_device *smmu) |
| 1026 | { | 1033 | { |
| 1027 | debugfs_remove_recursive(smmu->debugfs_root); | 1034 | debugfs_remove_recursive(smmu->debugfs_root); |
| 1035 | kfree(smmu->debugfs_info); | ||
| 1028 | } | 1036 | } |
| 1029 | 1037 | ||
| 1030 | static void smmu_debugfs_create(struct smmu_device *smmu) | 1038 | static void smmu_debugfs_create(struct smmu_device *smmu) |
| 1031 | { | 1039 | { |
| 1032 | int i; | 1040 | int i; |
| 1041 | size_t bytes; | ||
| 1033 | struct dentry *root; | 1042 | struct dentry *root; |
| 1034 | 1043 | ||
| 1035 | root = debugfs_create_file(dev_name(smmu->dev), | 1044 | bytes = ARRAY_SIZE(smmu_debugfs_mc) * ARRAY_SIZE(smmu_debugfs_cache) * |
| 1036 | S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, | 1045 | sizeof(*smmu->debugfs_info); |
| 1037 | NULL, smmu, NULL); | 1046 | smmu->debugfs_info = kmalloc(bytes, GFP_KERNEL); |
| 1047 | if (!smmu->debugfs_info) | ||
| 1048 | return; | ||
| 1049 | |||
| 1050 | root = debugfs_create_dir(dev_name(smmu->dev), NULL); | ||
| 1038 | if (!root) | 1051 | if (!root) |
| 1039 | goto err_out; | 1052 | goto err_out; |
| 1040 | smmu->debugfs_root = root; | 1053 | smmu->debugfs_root = root; |
| @@ -1043,18 +1056,23 @@ static void smmu_debugfs_create(struct smmu_device *smmu) | |||
| 1043 | int j; | 1056 | int j; |
| 1044 | struct dentry *mc; | 1057 | struct dentry *mc; |
| 1045 | 1058 | ||
| 1046 | mc = debugfs_create_file(smmu_debugfs_mc[i], | 1059 | mc = debugfs_create_dir(smmu_debugfs_mc[i], root); |
| 1047 | S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, | ||
| 1048 | root, (void *)i, NULL); | ||
| 1049 | if (!mc) | 1060 | if (!mc) |
| 1050 | goto err_out; | 1061 | goto err_out; |
| 1051 | 1062 | ||
| 1052 | for (j = 0; j < ARRAY_SIZE(smmu_debugfs_cache); j++) { | 1063 | for (j = 0; j < ARRAY_SIZE(smmu_debugfs_cache); j++) { |
| 1053 | struct dentry *cache; | 1064 | struct dentry *cache; |
| 1065 | struct smmu_debugfs_info *info; | ||
| 1066 | |||
| 1067 | info = smmu->debugfs_info; | ||
| 1068 | info += i * ARRAY_SIZE(smmu_debugfs_mc) + j; | ||
| 1069 | info->smmu = smmu; | ||
| 1070 | info->mc = i; | ||
| 1071 | info->cache = j; | ||
| 1054 | 1072 | ||
| 1055 | cache = debugfs_create_file(smmu_debugfs_cache[j], | 1073 | cache = debugfs_create_file(smmu_debugfs_cache[j], |
| 1056 | S_IWUGO | S_IRUGO, mc, | 1074 | S_IWUGO | S_IRUGO, mc, |
| 1057 | (void *)j, | 1075 | (void *)info, |
| 1058 | &smmu_debugfs_stats_fops); | 1076 | &smmu_debugfs_stats_fops); |
| 1059 | if (!cache) | 1077 | if (!cache) |
| 1060 | goto err_out; | 1078 | goto err_out; |
