Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Jul 2022 17:05:09 GMT
From:      Doug Moore <dougm@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: cf70aef40144 - stable/13 - iommu_gas: Tidy up
Message-ID:  <202207061705.266H59Kj083842@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dougm:

URL: https://cgit.FreeBSD.org/src/commit/?id=cf70aef40144e721c40c4db9fc2dd4c6ec57c849

commit cf70aef40144e721c40c4db9fc2dd4c6ec57c849
Author:     Alan Cox <alc@FreeBSD.org>
AuthorDate: 2022-06-26 05:44:47 +0000
Commit:     Doug Moore <dougm@FreeBSD.org>
CommitDate: 2022-07-06 17:00:59 +0000

    iommu_gas: Tidy up
    
    Move a comment to the code that it describes.  Improve the wording.
    
    Style fixes.
    
    MFC after:      2 weeks
    
    (cherry picked from commit da33f6d76b9d0c00649c692f6cb2b3b33bf5af30)
---
 sys/dev/iommu/iommu_gas.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c
index 48b27d6e81dc..23e603ef18dc 100644
--- a/sys/dev/iommu/iommu_gas.c
+++ b/sys/dev/iommu/iommu_gas.c
@@ -197,8 +197,7 @@ iommu_gas_rb_insert(struct iommu_domain *domain, struct iommu_map_entry *entry)
 {
 	struct iommu_map_entry *found;
 
-	found = RB_INSERT(iommu_gas_entries_tree,
-	    &domain->rb_root, entry);
+	found = RB_INSERT(iommu_gas_entries_tree, &domain->rb_root, entry);
 	return (found == NULL);
 }
 
@@ -303,6 +302,13 @@ iommu_gas_match_one(struct iommu_gas_match_args *a, iommu_gaddr_t beg,
 {
 	iommu_gaddr_t bs, start;
 
+	/*
+	 * The prev->end is always aligned on the page size, which
+	 * causes page alignment for the entry->start too.
+	 *
+	 * A page sized gap is created between consecutive
+	 * allocations to ensure that out-of-bounds accesses fault.
+	 */
 	a->entry->start = roundup2(beg + IOMMU_PAGE_SIZE,
 	    a->common->alignment);
 	if (a->entry->start + a->size > maxaddr)
@@ -356,13 +362,6 @@ iommu_gas_match_insert(struct iommu_gas_match_args *a)
 {
 	bool found __diagused;
 
-	/*
-	 * The prev->end is always aligned on the page size, which
-	 * causes page alignment for the entry->start too.
-	 *
-	 * The page sized gap is created between consequent
-	 * allocations to ensure that out-of-bounds accesses fault.
-	 */
 	a->entry->end = a->entry->start +
 	    roundup2(a->size + a->offset, IOMMU_PAGE_SIZE);
 
@@ -492,8 +491,7 @@ iommu_gas_find_space(struct iommu_domain *domain,
 
 	/* Handle lower region. */
 	if (common->lowaddr > 0) {
-		error = iommu_gas_lowermatch(&a,
-		    RB_ROOT(&domain->rb_root));
+		error = iommu_gas_lowermatch(&a, RB_ROOT(&domain->rb_root));
 		if (error == 0)
 			return (0);
 		KASSERT(error == ENOMEM,
@@ -641,7 +639,7 @@ iommu_gas_map(struct iommu_domain *domain,
 	    ("invalid flags 0x%x", flags));
 
 	entry = iommu_gas_alloc_entry(domain,
-	    (flags & IOMMU_MF_CANWAIT) != 0 ?  IOMMU_PGF_WAITOK : 0);
+	    (flags & IOMMU_MF_CANWAIT) != 0 ? IOMMU_PGF_WAITOK : 0);
 	if (entry == NULL)
 		return (ENOMEM);
 	IOMMU_DOMAIN_LOCK(domain);
@@ -665,7 +663,7 @@ iommu_gas_map(struct iommu_domain *domain,
 
 	error = domain->ops->map(domain, entry->start,
 	    entry->end - entry->start, ma, eflags,
-	    ((flags & IOMMU_MF_CANWAIT) != 0 ?  IOMMU_PGF_WAITOK : 0));
+	    ((flags & IOMMU_MF_CANWAIT) != 0 ? IOMMU_PGF_WAITOK : 0));
 	if (error == ENOMEM) {
 		iommu_domain_unload_entry(entry, true);
 		return (error);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202207061705.266H59Kj083842>