[1/5] iommu/vt-d: debugfs: Define domain_translation_struct file ops

Message ID 20230625150442.42197-2-Jingqi.liu@intel.com
State New
Headers
Series iommu/vt-d: debugfs: Enhancements to IOMMU debugfs |

Commit Message

Liu, Jingqi June 25, 2023, 3:04 p.m. UTC
  Define domain_translation_struct file_operations instead of using
DEFINE_SHOW_ATTRIBUTE() in order to specify source identifier and pasid
to dump the specified page table.

Signed-off-by: Jingqi Liu <Jingqi.liu@intel.com>
---
 drivers/iommu/intel/debugfs.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/iommu/intel/debugfs.c b/drivers/iommu/intel/debugfs.c
index 1f925285104e..072cfef19175 100644
--- a/drivers/iommu/intel/debugfs.c
+++ b/drivers/iommu/intel/debugfs.c
@@ -391,7 +391,25 @@  static int domain_translation_struct_show(struct seq_file *m, void *unused)
 	return bus_for_each_dev(&pci_bus_type, NULL, m,
 				show_device_domain_translation);
 }
-DEFINE_SHOW_ATTRIBUTE(domain_translation_struct);
+
+static int domain_translation_struct_open(struct inode *inode,
+					  struct file *filp)
+{
+	/*
+	 * Allocate one 1Mbyte buffer to save sequential file output,
+	 * since the default size of input buffer is 1Mbyte when the
+	 * user reads.
+	 */
+	return single_open_size(filp, domain_translation_struct_show,
+				inode->i_private, SZ_1M);
+}
+
+static const struct file_operations domain_translation_struct_fops = {
+	.open		= domain_translation_struct_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
 
 static void invalidation_queue_entry_show(struct seq_file *m,
 					  struct intel_iommu *iommu)