Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62a31c82 authored by Patrick Daly's avatar Patrick Daly
Browse files

iommu-debug: Remove calls to iommu_enable_config_clocks



The iommu driver is responsible for enabling the required clocks
for map/unmap operations, not clients.

For the fastmap case, clocks are theoretically left enabled forever
after the initial attach, although in practice this does not occur
because there are no clocks required for Apps smmu.

Change-Id: Ibdfced1f62c79fbb3234d80bc9c65808d818c27a
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
parent 698e1361
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -4042,27 +4042,11 @@ static void arm_smmu_tlbi_domain(struct iommu_domain *domain)
	arm_smmu_tlb_inv_context_s1(to_smmu_domain(domain));
}

static int arm_smmu_enable_config_clocks(struct iommu_domain *domain)
{
	struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);

	return arm_smmu_power_on(smmu_domain->smmu->pwr);
}

static void arm_smmu_disable_config_clocks(struct iommu_domain *domain)
{
	struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);

	arm_smmu_power_off(smmu_domain->smmu, smmu_domain->smmu->pwr);
}

static struct msm_iommu_ops arm_smmu_ops = {
	.map_sg			= arm_smmu_map_sg,
	.iova_to_phys_hard	= arm_smmu_iova_to_phys_hard,
	.is_iova_coherent	= arm_smmu_is_iova_coherent,
	.tlbi_domain		= arm_smmu_tlbi_domain,
	.enable_config_clocks	= arm_smmu_enable_config_clocks,
	.disable_config_clocks	= arm_smmu_disable_config_clocks,
	.iova_to_pte		= arm_smmu_iova_to_pte,
	.iommu_ops = {

+1 −83
Original line number Diff line number Diff line
@@ -126,8 +126,6 @@ struct iommu_debug_device {
	u64 phys;
	size_t len;
	struct list_head list;
	struct mutex clk_lock;
	unsigned int clk_count;
	/* Protects domain */
	struct mutex state_lock;
#ifdef CONFIG_ARM64_PTDUMP_CORE
@@ -654,10 +652,6 @@ static int iommu_debug_profiling_fast_dma_api_show(struct seq_file *s,
	}
	domain = ddev->domain;

	if (iommu_enable_config_clocks(domain)) {
		seq_puts(s, "Couldn't enable clocks\n");
		goto out_detach;
	}
	for (experiment = 0; experiment < 2; ++experiment) {
		size_t map_avg = 0, unmap_avg = 0;

@@ -674,7 +668,7 @@ static int iommu_debug_profiling_fast_dma_api_show(struct seq_file *s,
			ns = ktime_to_ns(diff);
			if (dma_mapping_error(dev, dma_addr)) {
				seq_puts(s, "dma_map_single failed\n");
				goto out_disable_config_clocks;
				goto out_detach;
			}
			map_elapsed_ns[i] = ns;

@@ -709,8 +703,6 @@ static int iommu_debug_profiling_fast_dma_api_show(struct seq_file *s,
		seq_printf(s, "] (avg: %zu)\n", unmap_avg);
	}

out_disable_config_clocks:
	iommu_disable_config_clocks(domain);
out_detach:
	iommu_debug_dma_deconfigure(ddev);
out_kfree:
@@ -1278,12 +1270,7 @@ static int __apply_to_new_mapping(struct seq_file *s,
	}

	dev_err_ratelimited(dev, "testing with pgtables at %pa\n", &pt_phys);
	if (iommu_enable_config_clocks(domain)) {
		ds_printf(dev, s, "Couldn't enable clocks\n");
		goto out_release_mapping;
	}
	ret = fn(dev, s, domain, priv);
	iommu_disable_config_clocks(domain);

out_release_mapping:
	iommu_debug_dma_deconfigure(ddev);
@@ -2013,67 +2000,6 @@ static const struct file_operations iommu_debug_dma_unmap_fops = {
	.write	= iommu_debug_dma_unmap_write,
};

static ssize_t iommu_debug_config_clocks_write(struct file *file,
					       const char __user *ubuf,
					       size_t count, loff_t *offset)
{
	char buf;
	struct iommu_debug_device *ddev = file->private_data;
	struct device *dev = ddev->dev;

	/* we're expecting a single character plus (optionally) a newline */
	if (count > 2) {
		dev_err_ratelimited(dev, "Invalid value\n");
		return -EINVAL;
	}

	if (!ddev->domain) {
		dev_err_ratelimited(dev, "No domain. Did you already attach?\n");
		return -EINVAL;
	}

	if (copy_from_user(&buf, ubuf, 1)) {
		dev_err_ratelimited(dev, "Couldn't copy from user\n");
		return -EFAULT;
	}

	mutex_lock(&ddev->clk_lock);
	switch (buf) {
	case '0':
		if (ddev->clk_count == 0) {
			dev_err_ratelimited(dev, "Config clocks already disabled\n");
			break;
		}

		if (--ddev->clk_count > 0)
			break;

		dev_err_ratelimited(dev, "Disabling config clocks\n");
		iommu_disable_config_clocks(ddev->domain);
		break;
	case '1':
		if (ddev->clk_count++ > 0)
			break;

		dev_err_ratelimited(dev, "Enabling config clocks\n");
		if (iommu_enable_config_clocks(ddev->domain))
			dev_err_ratelimited(dev, "Failed!\n");
		break;
	default:
		dev_err_ratelimited(dev, "Invalid value. Should be 0 or 1.\n");
		mutex_unlock(&ddev->clk_lock);
		return -EINVAL;
	}
	mutex_unlock(&ddev->clk_lock);

	return count;
}

static const struct file_operations iommu_debug_config_clocks_fops = {
	.open	= simple_open,
	.write	= iommu_debug_config_clocks_write,
};

#ifdef CONFIG_ARM64_PTDUMP_CORE
static int ptdump_show(struct seq_file *s, void *v)
{
@@ -2133,7 +2059,6 @@ static int iommu_debug_device_setup(struct device *dev)
	if (!ddev)
		return -ENOMEM;

	mutex_init(&ddev->clk_lock);
	mutex_init(&ddev->state_lock);
	ddev->dev = dev;
	dir = debugfs_create_dir(dev_name(dev), debugfs_tests_dir);
@@ -2269,13 +2194,6 @@ static int iommu_debug_device_setup(struct device *dev)
		goto err_rmdir;
	}

	if (!debugfs_create_file("config_clocks", 0200, dir, ddev,
				 &iommu_debug_config_clocks_fops)) {
		pr_err_ratelimited("Couldn't create iommu/devices/%s/config_clocks debugfs file\n",
		       dev_name(dev));
		goto err_rmdir;
	}

#ifdef CONFIG_ARM64_PTDUMP_CORE
	if (!debugfs_create_file("iommu_page_tables", 0200, dir, ddev,
			   &ptdump_fops)) {
+0 −30
Original line number Diff line number Diff line
@@ -391,8 +391,6 @@ struct iommu_ops {
 * @iova_to_phys_hard: translate iova to physical address using IOMMU hardware
 * @is_iova_coherent: checks coherency of the given iova
 * @tlbi_domain: Invalidate all TLBs covering an iommu domain
 * @enable_config_clocks: Enable all config clocks for this domain's IOMMU
 * @disable_config_clocks: Disable all config clocks for this domain's IOMMU
 * @iova_to_pte: translate iova to Page Table Entry (PTE).
 * @iommu_ops: the standard iommu ops
 */
@@ -404,8 +402,6 @@ struct msm_iommu_ops {
					 unsigned long trans_flags);
	bool (*is_iova_coherent)(struct iommu_domain *domain, dma_addr_t iova);
	void (*tlbi_domain)(struct iommu_domain *domain);
	int (*enable_config_clocks)(struct iommu_domain *domain);
	void (*disable_config_clocks)(struct iommu_domain *domain);
	uint64_t (*iova_to_pte)(struct iommu_domain *domain, dma_addr_t iova);
	struct iommu_ops iommu_ops;
};
@@ -671,23 +667,6 @@ static inline void iommu_tlbiall(struct iommu_domain *domain)
		ops->tlbi_domain(domain);
}

static inline int iommu_enable_config_clocks(struct iommu_domain *domain)
{
	struct msm_iommu_ops *ops = to_msm_iommu_ops(domain->ops);

	if (ops->enable_config_clocks)
		return ops->enable_config_clocks(domain);
	return 0;
}

static inline void iommu_disable_config_clocks(struct iommu_domain *domain)
{
	struct msm_iommu_ops *ops = to_msm_iommu_ops(domain->ops);

	if (ops->disable_config_clocks)
		ops->disable_config_clocks(domain);
}

/**
 * struct iommu_fwspec - per-device IOMMU instance data
 * @ops: ops for this device's IOMMU
@@ -1085,15 +1064,6 @@ static inline void iommu_tlbiall(struct iommu_domain *domain)
{
}

static inline int iommu_enable_config_clocks(struct iommu_domain *domain)
{
	return 0;
}

static inline void iommu_disable_config_clocks(struct iommu_domain *domain)
{
}

static inline int iommu_fwspec_init(struct device *dev,
				    struct fwnode_handle *iommu_fwnode,
				    const struct iommu_ops *ops)