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

Commit 467dcfc2 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "iommu: arm-smmu: fix check for need for preallocate memory"

parents f33c5bfd 6d515ec7
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -3256,8 +3256,13 @@ static size_t arm_smmu_map_sg(struct iommu_domain *domain, unsigned long iova,
				  prot, &size);
		spin_unlock_irqrestore(&smmu_domain->cb_lock, flags);


		if (ret == -ENOMEM) {
			/* unmap any partially mapped iova */
			if (size) {
				arm_smmu_secure_domain_unlock(smmu_domain);
				arm_smmu_unmap(domain, iova, size);
				arm_smmu_secure_domain_lock(smmu_domain);
			}
			arm_smmu_prealloc_memory(smmu_domain,
						 batch_size, &nonsecure_pool);
			spin_lock_irqsave(&smmu_domain->cb_lock, flags);
@@ -3272,8 +3277,8 @@ static size_t arm_smmu_map_sg(struct iommu_domain *domain, unsigned long iova,
							 &nonsecure_pool);
		}

		/* Returns 0 on error */
		if (!ret) {
		/* Returns -ve val on error */
		if (ret < 0) {
			size_to_unmap = iova + size - __saved_iova_start;
			goto out;
		}
@@ -3281,16 +3286,17 @@ static size_t arm_smmu_map_sg(struct iommu_domain *domain, unsigned long iova,
		iova += batch_size;
		idx_start = idx_end;
		sg_start = sg_end;
		size = 0;
	}

out:
	arm_smmu_assign_table(smmu_domain);
	arm_smmu_secure_domain_unlock(smmu_domain);

	if (size_to_unmap) {
		arm_smmu_unmap(domain, __saved_iova_start, size_to_unmap);
		iova = __saved_iova_start;
	}
	arm_smmu_secure_domain_unlock(smmu_domain);
	return iova - __saved_iova_start;
}

+3 −2
Original line number Diff line number Diff line
@@ -634,7 +634,8 @@ static int arm_lpae_map_sg(struct io_pgtable_ops *ops, unsigned long iova,
	arm_lpae_iopte prot;
	struct scatterlist *s;
	size_t mapped = 0;
	int i, ret;
	int i;
	int ret = -EINVAL;
	unsigned int min_pagesz;
	struct io_pgtable_cfg *cfg = &data->iop.cfg;
	struct map_state ms;
@@ -705,7 +706,7 @@ static int arm_lpae_map_sg(struct io_pgtable_ops *ops, unsigned long iova,
out_err:
	/* Return the size of the partial mapping so that they can be undone */
	*size = mapped;
	return 0;
	return ret;
}

static void __arm_lpae_free_pgtable(struct arm_lpae_io_pgtable *data, int lvl,
+2 −2
Original line number Diff line number Diff line
@@ -154,8 +154,8 @@ struct io_pgtable_cfg {
 *
 * @map:		Map a physically contiguous memory region.
 * @map_sg:		Map a scatterlist.  Returns the number of bytes mapped,
 *			or 0 on failure.  The size parameter contains the size
 *			of the partial mapping in case of failure.
 *			or -ve val on failure.  The size parameter contains the
 *			size of the partial mapping in case of failure.
 * @unmap:		Unmap a physically contiguous memory region.
 * @iova_to_phys:	Translate iova to physical address.
 * @is_iova_coherent:	Checks coherency of given IOVA. Returns True if coherent