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>
This commit is contained in:
Mitchel Humpherys 2016-04-13 17:08:49 -07:00 committed by Jeevan Shriram
parent 7c01b51556
commit c28b11f041
2 changed files with 54 additions and 2 deletions

View file

@ -0,0 +1,27 @@
This document describes the device tree binding for IOMMU test devices.
The iommu-debug framework can optionally make use of some platform devices
for improved standalone testing and other features.
- compatible: iommu-debug-test
Required properties
===================
- iommus: The IOMMU for the test device (see iommu.txt)
Example
=======
iommu_test_device {
compatible = "iommu-debug-test";
/*
* 42 shouldn't be used by anyone on the cpp_fd_smmu. We just
* need _something_ here to get this node recognized by the
* SMMU driver. Our test uses ATOS, which doesn't use SIDs
* anyways, so using a dummy value is ok.
*/
iommus = <&cpp_fd_smmu 42>;
};

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
* Copyright (c) 2015-2016, 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
@ -1143,6 +1143,30 @@ static inline int iommu_debug_init_tests(void) { return 0; }
static inline void iommu_debug_destroy_tests(void) { }
#endif
/*
* This isn't really a "driver", we just need something in the device tree
* so that our tests can run without any client drivers, and our tests rely
* on parsing the device tree for nodes with the `iommus' property.
*/
static int iommu_debug_pass(struct platform_device *pdev)
{
return 0;
}
static const struct of_device_id iommu_debug_of_match[] = {
{ .compatible = "iommu-debug-test" },
{ },
};
static struct platform_driver iommu_debug_driver = {
.probe = iommu_debug_pass,
.remove = iommu_debug_pass,
.driver = {
.name = "iommu-debug",
.of_match_table = iommu_debug_of_match,
},
};
static int iommu_debug_init(void)
{
if (iommu_debug_init_tracking())
@ -1151,11 +1175,12 @@ static int iommu_debug_init(void)
if (iommu_debug_init_tests())
return -ENODEV;
return 0;
return platform_driver_register(&iommu_debug_driver);
}
static void iommu_debug_exit(void)
{
platform_driver_unregister(&iommu_debug_driver);
iommu_debug_destroy_tracking();
iommu_debug_destroy_tests();
}