lkml.org 
[lkml]   [2018]   [Mar]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/2] iommu - Enable debugfs exposure of the IOMMU
From
Date
On 03/29/2018 10:57 PM, Tom Lendacky wrote:
> On 3/29/2018 5:54 PM, Gary R Hook wrote:
>> Provide base enablement for using debugfs to expose internal data of
>> an IOMMU driver. When enabled, create the /sys/kernel/debug/iommu
>
> So this can't actually create anything yet since nothing invokes the
> function. Maybe describe how it should be used by other drivers (and
> probably include that description as a commment for the function) to
> create the directory.

Exactly. Given the approach I took, it takes another patch to take
advantage of this. I can certainly elaborate on usage if we agree that
this framework is acceptable.

>
>> directory. Emit a strong warning at boot time to indicate that this
>> feature is enabled.
>>
>> Signed-off-by: Gary R Hook <gary.hook@amd.com>
>> ---
>> drivers/iommu/Kconfig | 11 +++++++++++
>> drivers/iommu/Makefile | 2 ++
>> drivers/iommu/amd_iommu_init.c | 2 ++
>> drivers/iommu/iommu-debugfs.c | 32 ++++++++++++++++++++++++++++++++
>> include/linux/iommu.h | 4 ++++
>> 5 files changed, 51 insertions(+)
>> create mode 100644 drivers/iommu/iommu-debugfs.c
>>
>> diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
>> index f3a21343e636..c1e39dabfec2 100644
>> --- a/drivers/iommu/Kconfig
>> +++ b/drivers/iommu/Kconfig
>> @@ -60,6 +60,17 @@ config IOMMU_IO_PGTABLE_ARMV7S_SELFTEST
>>
>> endmenu
>>
>> +config IOMMU_DEBUG
>> + bool "Enable IOMMU internals in DebugFS"
>> + depends on DEBUG_FS
>> + default n
>> + help
>> + Allows exposure of IOMMU device internals. This option enables
>> + the use of debugfs by IOMMU drivers as required. Devices can,
>> + at initialization time, cause the IOMMU code to create a top-level
>> + debug/iommu directory, and then populate a subdirectory with
>> + entries as required.
>> +
>> config IOMMU_IOVA
>> tristate
>>
>> diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile
>> index 1fb695854809..5e5c3339681d 100644
>> --- a/drivers/iommu/Makefile
>> +++ b/drivers/iommu/Makefile
>> @@ -2,6 +2,7 @@
>> obj-$(CONFIG_IOMMU_API) += iommu.o
>> obj-$(CONFIG_IOMMU_API) += iommu-traces.o
>> obj-$(CONFIG_IOMMU_API) += iommu-sysfs.o
>> +obj-$(CONFIG_IOMMU_DEBUG) += iommu-debugfs.o
>> obj-$(CONFIG_IOMMU_DMA) += dma-iommu.o
>> obj-$(CONFIG_IOMMU_IO_PGTABLE) += io-pgtable.o
>> obj-$(CONFIG_IOMMU_IO_PGTABLE_ARMV7S) += io-pgtable-arm-v7s.o
>> @@ -10,6 +11,7 @@ obj-$(CONFIG_IOMMU_IOVA) += iova.o
>> obj-$(CONFIG_OF_IOMMU) += of_iommu.o
>> obj-$(CONFIG_MSM_IOMMU) += msm_iommu.o
>> obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o amd_iommu_init.o
>> +obj-$(CONFIG_AMD_IOMMU_DEBUG) += amd_iommu_debugfs.o
>
> Where is this CONFIG defined?

That, my friend is left-over cruft. Please ignore. Apologies, and thanks.

>> obj-$(CONFIG_AMD_IOMMU_V2) += amd_iommu_v2.o
>> obj-$(CONFIG_ARM_SMMU) += arm-smmu.o
>> obj-$(CONFIG_ARM_SMMU_V3) += arm-smmu-v3.o
>> diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
>> index 6fe2d0346073..99d48c42a12f 100644
>> --- a/drivers/iommu/amd_iommu_init.c
>> +++ b/drivers/iommu/amd_iommu_init.c
>> @@ -2783,6 +2783,8 @@ int __init amd_iommu_detect(void)
>> iommu_detected = 1;
>> x86_init.iommu.iommu_init = amd_iommu_init;
>>
>> +dump_stack();
>> +
>
> This definitely shouldn't be here.

Dang it!

>
>> return 1;
>> }
>>
>> diff --git a/drivers/iommu/iommu-debugfs.c b/drivers/iommu/iommu-debugfs.c
>> new file mode 100644
>> index 000000000000..94c9acc63b65
>> --- /dev/null
>> +++ b/drivers/iommu/iommu-debugfs.c
>> @@ -0,0 +1,32 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * AMD IOMMU driver
>
> This isn't the AMD IOMMU driver.

Again: dang it!

>> + *
>> + * Copyright (C) 2018 Advanced Micro Devices, Inc.
>> + *
>> + * Author: Gary R Hook <gary.hook@amd.com>
>> + */
>> +
>> +#include <linux/pci.h>
>> +#include <linux/iommu.h>
>> +#include <linux/debugfs.h>
>> +
>> +static struct dentry *iommu_debugfs_dir;
>> +
>> +#define MAX_NAME_LEN 20
>
> This isn't used anywhere.

Thanks.

>
>> +
>> +/* Return a zero on failure; 1 on successful setup */
>
> Return NULL on failure, pointer to IOMMU debugfs dentry on success.

Roger.

>
>> +struct dentry *iommu_debugfs_setup(void)
>> +{
>> + if (!debugfs_initialized())
>> + return NULL;
>> +
>> + if (!iommu_debugfs_dir)
>> + iommu_debugfs_dir = debugfs_create_dir("iommu", NULL);
>> +
>> + if (iommu_debugfs_dir)
>> + pr_warn("WARNING: IOMMU DEBUGFS SUPPORT HAS BEEN ENABLED IN THIS KERNEL\n");
>> +
>> + return iommu_debugfs_dir;
>> +}
>> +EXPORT_SYMBOL_GPL(iommu_debugfs_setup);
>> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
>> index 41b8c5757859..cb2957dac43b 100644
>> --- a/include/linux/iommu.h
>> +++ b/include/linux/iommu.h
>> @@ -696,6 +696,10 @@ const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode)
>> return NULL;
>> }
>>
>> +#ifdef CONFIG_IOMMU_DEBUG
>
> Should be a space between the #ifdef and the CONFIG_..., not a tab.

Roger that.

>
> Thanks,
> Tom
>
>> +struct dentry *iommu_debugfs_setup(void);
>> +#endif
>> +
>> #endif /* CONFIG_IOMMU_API */
>>
>> #endif /* __LINUX_IOMMU_H */
>>

\
 
 \ /
  Last update: 2018-03-30 20:42    [W:0.085 / U:0.892 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site