Commit graph

52 commits

Author SHA1 Message Date
Vijayanand Jitta
42a7efc865 iommu: iommu-debug: don't pass null character to copy_to_user
Doing a cat on pte,test_virt_addr from adb shell prints a null
character as well which is at the end of the string this is not
required so, don't pass this null character to copy_to_user.

Change-Id: I8d9120f64d1df84a704379eb00bd239fc7059e9e
Signed-off-by: Vijayanand Jitta <vjitta@codeaurora.org>
2019-02-17 21:50:33 -08:00
Srinivasarao P
6a8e47eb57 iommu/iommu-debug: fix buffer overflows in debugfs read functions
The kernel buffer 'ubuf' can overflow while copying data to user
space in debugfs read functions. Fix it by limiting the length of
data to be copied to userspace.

Change-Id: Ibb3d8c4fb637ddc0e63677ec2dff14a4cf8c0c73
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
2019-01-22 01:04:00 -08:00
VENKATA RAO KAKANI
ba826181ed iommu/debug: Add mutex to make attach/detach thread safe
This mutex lock will help to synchronise the usage of iommu domain
structure which is getting used by multiple threads to perform
iommu attach and iommu detach in case of any error.

Without this change we are seeing page poisoning - write after free
when running stress tests using iommu-debug test cases.

Change-Id: I388a90084ab8cc7e7097bac9a41ed5fed6dad312
Acked-by: Ankur Saxena <c_ankusa@qti.qualcomm.com>
Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Signed-off-by: VENKATA RAO KAKANI <vkakani@codeaurora.org>
2018-07-13 04:56:53 -07:00
Vivek Gautam
580b853d73 iommu/debug: Add mutex to make attach/detach thread safe
This mutex lock will help to synchronise the usage of iommu domain
structure which is getting used by multiple threads to perform
iommu attach and iommu detach in case of any error.

Without this change we are seeing page poisoning - write after free
when running stress tests using iommu-debug test cases.

Change-Id: I1033808a510786577c41201c2a6a330e5465d4d1
Acked-by: Ankur Saxena <c_ankusa@qti.qualcomm.com>
Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
2018-07-09 23:36:34 +05:30
Liam Mark
aecadd7140 iommu: iommu-debug: limit memory address exposure
Update pte and dma atos debugfs nodes to be inline
with other iommu debugfs nodes and only expose memory
addresses when kptr_restrict is disabled.

Change-Id: I46d5de498b811b4874be570aea7b41461b9a1a98
Signed-off-by: Liam Mark <lmark@codeaurora.org>
2017-05-30 09:29:54 -07:00
Liam Mark
a283c457ee iommu: iommu-debug: cleanup iommu debug
Only expose debugfs nodes for test devices.
Restrict secure attach to a valid vmid.
Add clock reference counting to make code more robust.
Restrict address printing with kptr_restrict.

Change-Id: Ibf90068d778b0156e3bb42287af5dda3864da5fc
Signed-off-by: Liam Mark <lmark@codeaurora.org>
2017-05-30 09:28:58 -07:00
Patrick Daly
1c2a08812e iommu: iommu-debug: Rework CONFIG_IOMMU_DEBUG_TRACKING
If CONFIG_IOMMU_DEBUG_TRACKING=y, a deadlock will occur if userspace
writes to the debugfs file "attach":

    -001|context_switch(inline)
    -001|__schedule()
    -002|__preempt_count_sub(inline)
    -002|schedule()
    -003|schedule_timeout()
    -004|do_wait_for_common(inline)
    -004|__wait_for_common(inline)
    -004|wait_for_common()
    -005|wait_for_completion()
    -006|__synchronize_srcu()
    -007|synchronize_srcu()
    -008|debugfs_remove_recursive()
    -009|iommu_debug_detach_device()
    -010|__iommu_detach_device()
    -011|__iommu_group_for_each_dev(inline)
    -011|__iommu_detach_group()
    -012|iommu_detach_device()
    -013|iommu_debug_device_profiling()
    -014|iommu_debug_device_show()
    -015|seq_read()
    -016|full_proxy_read()
    -017|__vfs_read()
    -018|vfs_read()

Since the files in the attachment directory are rarely used, remove
them. Update the data saved by this config option to work properly
with iommu groups.

Change-Id: I3f0f1d0836f37412915ce3e78d8aefe92dc8d096
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
[lmark@codeaurora.org: deadlock is not an issue on this branch
 but this change is backported because there are security benefits
 from removing the iommu debugfs attachments nodes, such as removing
 register access.]
Signed-off-by: Liam Mark <lmark@codeaurora.org>
2017-05-25 15:42:53 -07:00
Linux Build Service Account
9d0c2b4690 Merge "iommu/iommu-debug: Add validation support for per-buffer coherent mappings" 2017-05-03 23:32:05 -07:00
Sudarshan Rajagopalan
058ccb2933 iommu/iommu-debug: Add validation support for per-buffer coherent mappings
Added new debugfs files/nodes to perform basic validation of the
per-buffer IO coherent dma-mapping that was recently implemented.
Also, added a node to print out the PTE for a given IOVA.

Nodes added:
dma_attach
dma_map
dma_unmap
dma_atos
virt_addr
pte

Change-Id: I041ab5f4e37e50dd3f58e2def3fdd3125a60629c
Signed-off-by: Sudarshan Rajagopalan <sudaraja@codeaurora.org>
2017-05-02 10:32:42 -07:00
Zhiqiang Tu
b15484bc06 Merge remote-tracking branch 'remotes/quic/dev/msm-4.4-8996au' into msm-4.4
Conflicts:
	arch/arm/boot/dts/qcom/msm8996-auto-cdp.dtsi
	drivers/gpu/drm/msm/Makefile

Change-Id: Ief80c28ff1422fd71a0c3d2041531e2ab078ee7a
Signed-off-by: Zhiqiang Tu <ztu@codeaurora.org>
2017-05-02 08:59:16 +08:00
Charan Teja Reddy
ad3b1dcc93 iommu: disable smmu stalls on faulty transactions
Disable the SMMU stalls on faulty transactions by terminating it using
the CB.SCTLR register. Faulty transaction on a CB causes the back
pressure on the QSMMU transaction pipe which inturn affect the other
masters using the same SMMU. Pass the DOMAIN_ATTR_CB_STALL_DISABLE flag
to iommu_domain_set_attr api in order to use this feature.

Change-Id: Ib8fa35854ff24e0295d330c5fb79375f58c3e841
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
2017-04-25 02:03:54 -07:00
Sudarshan Rajagopalan
0c17028a92 iommu: iommu-debug: assign iova space for fastmap client
With fast mapping, the iova range is zero in the absence of
mapping object from the client. In such case, set the iova
space using the DOMAIN_ATTR_GEOMETRY dommain attribute.

CRs-Fixed: 2020868
Change-Id: I28790728c02ecb2d0a921bf5a218fb8b16662619
Signed-off-by: Sudarshan Rajagopalan <sudaraja@codeaurora.org>
2017-04-20 17:39:20 -07:00
Mitchel Humpherys
4a6f833be0 iommu/iommu-debug: Do a software table walk if ATOS fails
It's hard to tell whether ATOS failed due to a misconfiguration in
hardware or software.  Add a software table walk to help narrow down the
reasons for the failure.  If the software walk succeeds then there's
something wrong in hardware.  If the software walk fails then there's
something wrong in software.

CRs-Fixed: 1014916
Change-Id: I49dd61856ad08e1890791b3e5c180350a5eaa648
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2017-03-20 22:01:03 -07:00
Charan Teja Reddy
f1cc7ec4c8 arm: dma-mapping: add dma mapper for io-pgtable-fast for 32 bit
io-pgtable-fast was implemented to achieve
better performance for IOMMU map/un-map. Add
DMA API support that goes through io-pgtable-fast
for 32 bit targets.

Change-Id:I3d0560a4331f6b7b87c70d0885df11d12cb1d6ec
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
2017-02-13 11:05:17 +05:30
Charan Teja Reddy
3a51cab0b7 iommu: pass proper vmid value for secure attachments
Pass the proper VMID value during secure attach. This VMID is used by
the HYP/TZ to maintain the pagetables.

Change-Id: I3b7c27c079b044c9325bcbcb6fa4312e424f3a94
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
2017-01-13 18:40:37 +05:30
Patrick Daly
767cab9493 iommu: iommu-debug: Allow full dma_addr_t sized address for atos
Iommu addresses are unsigned numbers. Therefore use the unsigned variants
of the kstrto*_from_user functions.

Change-Id: I9a34d522a8dc7e2efca95b5a1ccb6a7a2e260b42
Reported-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2016-11-23 15:49:46 -08:00
Liam Mark
b40f602bfa iommu/arm-smmu: support mapping before enabling S1 translations
For performance reasons there are clients who would like to move
from stage 1 bypass to stage 1 enabled without having to stop their
device.

Currently clients need to stop their device because they have to
create the required stage 1 mappings before re-enabling the device.
Add the new DOMAIN_ATTR_EARLY_MAP domain attribute to allow clients
to create stage 1 mappings after attaching but before enabling
stage 1 translations.

If the clients set the DOMAIN_ATTR_EARLY_MAP domain attribute to 1
before attaching then then once they attach the SMMU driver won't
enable stage 1 translations. This gives the client the opportunity to
create the required early mappings (for example using iommu_map).
When the client has finished creating the necessary early mappings
the client can then set the DOMAIN_ATTR_EARLY_MAP domain attribute
to 0, this will in turn enable stage 1 translations.

Change-Id: I9e95c5d2130f1d371e201eac69dec140cc773b1f
Signed-off-by: Liam Mark <lmark@codeaurora.org>
2016-11-11 09:46:54 -08:00
Mitchel Humpherys
0abbf71d2b iommu/iommu-debug: Remove obsolete IOMMU domain attribute
The DOMAIN_ATTR_COHERENT_HTW_DISABLE IOMMU domain attribute is being
removed.  SMMU coherency will be configured through the SMMU device tree
nodes moving forward.  Remove the obsolete option.

Change-Id: If1251c945d71f8a7ab7c8e62c8a3d9d9139495ab
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-09-26 17:42:49 -07:00
Susheel Khiani
36c23da759 iommu/iommu-debug: Make debug driver 32 bit compatible
Currently iommu-debug was enable only for 64 bit
targets as there were compilation issues coming
up while enabling it for 32 bit. Fix these issues
to ensure that we can use it on 32 bit targets
too.

Change-Id: If230af86f2fdd12fb5396f3b4736e57a123422bd
Signed-off-by: Susheel Khiani <skhiani@codeaurora.org>
2016-07-21 03:13:27 -07:00
Shiraz Hashim
50044eb1b4 iommu/iommu-debug:: initialize variables before use
Initialize return values to their default before being
used.

Change-Id: Ie4dd908657573e5110bce65931d5507125da4c40
Signed-off-by: Shiraz Hashim <shashim@codeaurora.org>
2016-07-11 14:26:46 -07:00
Mitchel Humpherys
0a70cf0fac iommu/iommu-debug: Add debugfs file to enable config clocks
It's fairly common while debugging to need to enable the config clocks
for an SMMU so that you can poke around at the registers.  Add a debugfs
file to do this.

CRs-Fixed: 997751
Change-Id: I31b90d64c2facb0a681f9da586e2c90803776819
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-05-20 19:24:03 -07:00
Mitchel Humpherys
6d871ad17d iommu/iommu-debug: Add functional test for ARM DMA IOMMU mapper
The vanilla ARM DMA IOMMU mapper is used by many clients in our system,
but we have no functional test coverage of it.  Add some functional
testing for it by leveraging the tests that were recently added for the
Fast DMA mapper.  Since the Fast mapper and the ARM mapper are both DMA
API implementations we can share most of the code.

CRs-Fixed: 997751
Change-Id: I58734a82f4dc3e4658ab7995b6682205097da991
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-05-20 19:24:02 -07:00
Mitchel Humpherys
2f53f9331b iommu/iommu-debug: Add functional tests for fast mapper
Functional tests are good.  Add some for the fast DMA mapper.

CRs-Fixed: 997751
Change-Id: Iefb80124c335d65ea5bd8a15406c685125030003
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-05-20 19:24:02 -07:00
Mitchel Humpherys
ff4455471e iommu/iommu-debug: Add file for profiling the fast DMA APIs
The fast DMA API implementation that was recently needs to be profiled.
Add a new debugfs file (similar to the original "profiling" file) to do
this.

CRs-Fixed: 997751
Change-Id: I1236d9b6aaeab9d34b39e7f5d7b285691d1779da
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-05-20 19:24:01 -07:00
Mitchel Humpherys
b7d9fb96e0 iommu/iommu-debug: Add file for profiling fast mapper
We'd like to understand the performance of the fast page table mapper,
which only supports 4K page sizes.  Add a debugfs file to profile the
new mapper.

CRs-Fixed: 997751
Change-Id: I5adc3c3ecd432552386b600b9e66e3db42e73138
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-05-20 19:23:55 -07:00
Susheel Khiani
26f7b639c8 iommu/iommu-debug: Maintain list of domains during alloc
Current list of domains in iommu-debug was only
maintained during attach/detach calls. But for
masters like graphics this won't account for all
the domains, as it allocates multiple different
domains but attaches only one domain at a time.

Add support for maintaining list of unattached
domains too by adding them to debug_attachments
list during domain alloc but keeping dev as NULL.
We would add entry in debugfs attachment directory
only on actual attach call.

Change-Id: Ifde043e5c39f356b4187a30cbdf020ee943618f1
Signed-off-by: Susheel Khiani <skhiani@codeaurora.org>
2016-05-18 13:42:13 -07:00
Mitchel Humpherys
c28b11f041 iommu/iommu-debug: Add dummy driver for standalone testing
The IOMMU test framework relies on the `iommus' property, and we
currently rely on these methods for making that happen:

  (1) Clients enabling their DT nodes.

  (2) We put an `iommus' property in our IOMMU DT nodes themselves.

The problem with (1) is that clients aren't always ready during early
chip validation.  The problem with (2) is that it results in us
recursively mapping into the SMMU when we try to do cache maintenance on
our page table memory.

Fix these problems by introducing a dummy driver with associated device
tree bindings that will do absolutely nothing other than wait for the
SMMU driver and IOMMU test framework to slurp it up.

CRs-Fixed: 1003233
Change-Id: I6a5802aff5bab99d29c6ed9d953a203cbd8015bb
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-05-03 15:51:43 -07:00
Rohit Vaswani
91a1dd684f drivers: iommu, leds, input, clk, devfreq: fix warnings
Fix some variable initializations which would otherwise cause
forbidden warnings.

Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2016-03-23 20:57:40 -07:00
Patrick Daly
b04374214e iommu-debug: Add proper header file for module_init()
Fix compilation on 4.4 kernel.

Change-Id: I760e9adb94c15263e4bf653aec2e3c63e368c2bc
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2016-03-22 11:15:37 -07:00
Patrick Daly
75a6af118d iommu/iommu-debug: Add 3 more signifigant digits
Print time with ns precision.

Ex:
    size           iommu_map      iommu_unmap
      4K           43.021 us        99.479 us

Change-Id: Ib7f3db2be533c77adf0a20de557615a0e2433dd9
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2016-03-22 11:14:36 -07:00
Patrick Daly
b07bee3227 iommu/iommu-debug: Improve statistics collection
Add a nr_iters file which specifies the number of runs to average
performance over. Alternatively, setting this to 1 allows the user
to collect raw data.

Change-Id: Ifab7215027b597fb2650ab2f0c5065bebe0b8c5d
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2016-03-22 11:14:35 -07:00
Mitchel Humpherys
ef702c85fa iommu/iommu-debug: Use more iterations while profiling
Currently we only take one sample per buffer size per API when doing
profiling.  This results in high run-to-run variance in the results.
Use more iterations to help smooth this out.

Change-Id: I3779007a2f69ef79b573285b2422554f42dda99f
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:14:23 -07:00
Mitchel Humpherys
88a510ad7c iommu/iommu-debug: Add support for secure domain profiling
Secure domains do different amounts of work than non-secure domains, so
we need to be able to profile them separately.  Add another debugfs
file, "secure_profiling", that does the same thing as the "profiling"
file.

Change-Id: I6968036bfdcc63449f27336771b3956a2b7754f6
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:14:22 -07:00
Mitchel Humpherys
9516686300 iommu/iommu-debug: Only uniquify directory names for dynamic domains
The subdirectories under "attach" currently get a UUID appended to their
name to ensure that there won't be any collisions when multiple domains
are attached to the same device.  This is only needed for dynamic
domains since those are the only types of domains that can be attached
to the same device concurrently.  Only do the uniquification for dynamic
domains since the resulting directory name is a bit messy with the UUID.

Change-Id: Ia86b192e5b9d6a63132228fa86549a2977ec74a4
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:14:06 -07:00
Mitchel Humpherys
31cff0aa7f iommu/iommu-debug: Set DOMAIN_ATTR_ATOMIC during profiling
There's some non-deterministic latency incurred by enabling clocks and
regulators.  Clocks and regulators are left on for atomic domains, which
makes them a good choice for profiling the page table management code.
Use an atomic domain for map/unmap profiling to make things more
deterministic.

Change-Id: Ib9fa48699c9d6009dd3f3b322002e2fb0f2ff99c
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:14:05 -07:00
Mitchel Humpherys
0934068545 iommu/iommu-debug: Provide debugfs for iommu_reg_{read,write}
It can be useful to read and modify SMMU settings interactively.  Add a
debugfs interface for the recently added iommu_reg_read and
iommu_reg_write functions for this purpose.

Change-Id: If3c9bf1833dc950c7ca1e2ce1a373bcaa31ebcf0
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:14:02 -07:00
Mitchel Humpherys
763858dfbc iommu/iommu-debug: Pass a flags value to iommu_trigger_fault
iommu_trigger_fault now accepts a flags argument which can be handled by
the individual IOMMU drivers.  Take the value written to the debugfs
file by the user and pass it as the flags value.

Change-Id: I803e6585aea35fbb0f6e03e4279587b36a7bad92
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:13:56 -07:00
Mitchel Humpherys
7f72f4984b iommu: Add flags parameter to .trigger_fault
IOMMU drivers might want more control over the types of faults being
triggered with iommu_trigger_fault.  Add a flags parameter that can be
used to provide more control over the types of faults that can be
triggered.

Change-Id: I2f21b383437430e957ab52070d3575e8cb3dee90
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:13:55 -07:00
Chintan Pandya
1949585f6f iommu: debug: add support for MSM iommu devices
MSM iommu devices' DT bindings defer from upstream
way. And hence, the debug driver doesn't support
to profile MSM iommu devices. Add that support.

Change-Id: I507d500785408b1d96f017648475933ee408b664
Signed-off-by: Chintan Pandya <cpandya@codeaurora.org>
2016-03-22 11:13:49 -07:00
Mitchel Humpherys
6f96490713 iommu/iommu-debug: Add secure_attach debugfs file
It can be useful to perform tests on secure domains.  Add support for
this with a "secure_attach" file that will also set the
DOMAIN_ATTR_SECURE_VMID to the value written to the file.

Example usage:

    # cd /sys/kernel/debug/iommu/tests/<device>
    # echo 0xA > secure_attach
    # echo 0x1000,0x1000,0x1000,1 > map
    # echo 0x1000,0x1000 > unmap
    # echo 0 > secure_attach

Change-Id: I0181e360f3e98e0e47a3af8c6adb71c9c4a3c9b5
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:13:45 -07:00
Mitchel Humpherys
75cd28f90d iommu/iommu-debug: Show secure VMID in attach info
It can be useful to know a domain's secure VMID value.  Add this
information to the attach info debugfs file.

Change-Id: Ic8a73000b8337639f95376b13ef58a0e2a089dde
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:13:44 -07:00
Mitchel Humpherys
4a7ae76ea2 iommu/iommu-debug: Fix parsing of unmap size
The unmap debugfs file write handler is currently incorrectly parsing
the size to be unmapped (storing the IOVA as the size).  Fix this by
parsing from the correct offset (just after the first comma).

Change-Id: I438851882052acc511c713706bc4f0cbf373353e
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:13:41 -07:00
Mitchel Humpherys
3053a46e6f iommu: Create iommu debugfs directory from IOMMU code
Currently we're creating an "iommu" debugfs directory from the
iommu-debug code.  Other IOMMU modules might want to make use of this
same directory, so create it from the IOMMU framework code itself.

Change-Id: I679fdfc34ba5fcbd927dc5981438c6fabcfa3639
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:13:39 -07:00
Mitchel Humpherys
f0abe72924 iommu/iommu-debug: Don't add debugfs entries until we init
The attachment tracking code adds a node to debugfs every time a client
attaches a domain to an IOMMU device.  The problem is that clients can
start making those attachments during early boot, before iommu-debug
initializes (including setting up the root debugfs directory for the
attachment tracking), which means they get stuck in the root debugfs
directory.  Trying to initialize iommu-debug earlier than all possible
IOMMU clients is tricky, so fix this by only installing debugfs entries
onces we've initialized, installing debugfs entries for any early
attachments at initialization time.

Change-Id: I8364015346105187e0c8f787fc2b4155d72b3584
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:13:34 -07:00
Mitchel Humpherys
844ca444df iommu/iommu-debug: Add debugfs file to trigger context faults
It can be useful during development to trigger faults.  Add a debugfs
file to do so.

Change-Id: Ic7b304ef0d908ebd506979f0c87189e34d7dfc67
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:13:33 -07:00
Mitchel Humpherys
9a9c9a25ed iommu/iommu-debug: Add COHERENT_HTW_DISABLE to attach info
It can be useful to check whether or not coherent hardware table walking
has been explicitly disabled on attached domains.  Add this to the
attach info debugfs file.

Change-Id: I432303ecb734d32eaa02038694daad0d8c4d8aba
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:13:29 -07:00
Mitchel Humpherys
19ce6acc8e iommu/iommu-debug: Move attachment info file to subdirectory
Currently IOMMU attachment info is available in debugfs files located at
<debugfs_root>/iommu/attachments/<attached_device>.  However, there are
more actions that can be taken on attached devices besides just printing
their info.  Make room for more debugfs files for attached devices by
creating a directory for each one, and move the existing info file to:
<debugfs_root>/iommu/attachments/<attached_device>/info.

Change-Id: Ia56efc3aeb5e82afc34314fe48aaa0cd6e5579be
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:13:28 -07:00
Mitchel Humpherys
fd7f57ccd3 iommu/iommu-debug: Initialize debug device to 0
Currently the debug device structure is allocated with kmalloc, without
initializing all of the fields in the structure.  Later, those fields
might be uses before they've every been assigned. For example, if a user
executes the following code on a fresh boot:

    # cd /sys/kernel/debug/iommu/tests/some_device
    # echo 0 > attach

The kernel crashes with something like this (assuming page poisoning is
enabled):

 Unable to handle kernel paging request at virtual address aaaaaaaaaaaaaaaa
 pgd = ffffffc0a92a1000
 [aaaaaaaaaaaaaaaa] *pgd=0000000000000000, *pud=0000000000000000

Fix this by initializing all the fields in the structure to 0 by using
kzalloc instead of kmalloc.

Change-Id: I3514bf7bf174e176ff7a310c7134d0f53e22d771
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:13:27 -07:00
Mitchel Humpherys
1cbd556395 iommu/iommu-debug: Add translation and mapping test files
Running ATOS commands on custom mappings is a useful tool for debugging.
Add a new debugfs file for interactively attaching, detaching, mapping,
unmapping, and issuing ATOS commands.

Example usage:

    # cd /sys/kernel/debug/iommu/tests/soc:qcom,msm-audio-ion
    # echo 1 > attach
    # echo 0x1000,0x5000,0x1000,1 > map
    # echo 0x1008 > atos
    # cat atos
    0x5008
    # echo 0x2000 > atos
    # cat atos
    FAIL
    # echo 0 > attach

Change-Id: I596cd3f05fcb59653e2acddc17d175855a1eb9a1
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:13:27 -07:00
Mitchel Humpherys
682dd703a1 iommu/iommu-debug: Rename profiling device functions
The functions for iommu/devices/<device>/profiling don't actually have
the word `profiling' in the name, which will be confusing as we add more
files to that directory.  Rename them for clarity.

Change-Id: Ic57d9400d8784d2cbd667185c5b2b0e1275461dd
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:13:26 -07:00