git: 70b5d8fa0f94 - main - iommu_gas: Drop needless bound check in lowermatch
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 21 Jun 2022 00:38:15 UTC
The branch main has been updated by dougm:
URL: https://cgit.FreeBSD.org/src/commit/?id=70b5d8fa0f9457833027e4a1c57b4e68a9351cac
commit 70b5d8fa0f9457833027e4a1c57b4e68a9351cac
Author: Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2022-06-21 00:34:46 +0000
Commit: Doug Moore <dougm@FreeBSD.org>
CommitDate: 2022-06-21 00:34:46 +0000
iommu_gas: Drop needless bound check in lowermatch
The loop iteration in iommu_gas_lowermatch checks the bound
a->common->lowaddr twice per loop iteration. Rewrite to test only once
per iteration. Do not worry about passing to iommu_gas_match_one a
range wholly beyond lowaddr. Since that function checks the upper end
of the range against lowaddr, it'll get rejected there.
Reviewed by: alc
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D35522
---
sys/dev/iommu/iommu_gas.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c
index f25519552d1c..70eef9a0a1f7 100644
--- a/sys/dev/iommu/iommu_gas.c
+++ b/sys/dev/iommu/iommu_gas.c
@@ -398,16 +398,11 @@ iommu_gas_lowermatch(struct iommu_gas_match_args *a, struct iommu_map_entry *ent
*/
entry = first;
while (entry != NULL) {
- if ((first = RB_LEFT(entry, rb_entry)) != NULL) {
- if (first->last >= a->common->lowaddr) {
- /* All remaining ranges >= lowaddr */
- break;
- }
- if (iommu_gas_match_one(a, first->last, entry->start,
- a->common->lowaddr)) {
- iommu_gas_match_insert(a);
- return (0);
- }
+ if ((first = RB_LEFT(entry, rb_entry)) != NULL &&
+ iommu_gas_match_one(a, first->last, entry->start,
+ a->common->lowaddr)) {
+ iommu_gas_match_insert(a);
+ return (0);
}
if (entry->end >= a->common->lowaddr) {
/* All remaining ranges >= lowaddr */