Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137356154
D35486.id106926.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D35486.id106926.diff
View Options
Index: sys/dev/iommu/iommu_gas.c
===================================================================
--- sys/dev/iommu/iommu_gas.c
+++ sys/dev/iommu/iommu_gas.c
@@ -376,35 +376,54 @@
static int
iommu_gas_lowermatch(struct iommu_gas_match_args *a, struct iommu_map_entry *entry)
{
- struct iommu_map_entry *child;
+ struct iommu_map_entry *first;
+ iommu_gaddr_t min_free;
/*
* If the subtree doesn't have free space for the requested allocation
- * plus two guard pages, give up.
+ * plus two guard pages, skip it.
*/
- if (entry->free_down < 2 * IOMMU_PAGE_SIZE +
- roundup2(a->size + a->offset, IOMMU_PAGE_SIZE))
- return (ENOMEM);
- if (entry->first >= a->common->lowaddr)
- return (ENOMEM);
- child = RB_LEFT(entry, rb_entry);
- if (child != NULL && 0 == iommu_gas_lowermatch(a, child))
- return (0);
- if (child != NULL && child->last < a->common->lowaddr &&
- iommu_gas_match_one(a, child->last, entry->start,
- a->common->lowaddr)) {
- iommu_gas_match_insert(a);
- return (0);
+ min_free = 2 * IOMMU_PAGE_SIZE +
+ roundup2(a->size + a->offset, IOMMU_PAGE_SIZE);
+
+ /* Find the first entry that could contain a big-enough range. */
+ first = NULL;
+ while (entry != NULL && entry->free_down >= min_free) {
+ first = entry;
+ entry = RB_LEFT(entry, rb_entry);
}
- child = RB_RIGHT(entry, rb_entry);
- if (child != NULL && entry->end < a->common->lowaddr &&
- iommu_gas_match_one(a, entry->end, child->first,
- a->common->lowaddr)) {
- iommu_gas_match_insert(a);
- return (0);
+
+ entry = first;
+ while (entry != NULL) {
+ if ((first = RB_LEFT(entry, rb_entry)) != NULL) {
+ if (first->last >= a->common->lowaddr)
+ break;
+ if (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)
+ break;
+ if ((first = RB_RIGHT(entry, rb_entry)) != NULL &&
+ iommu_gas_match_one(a, entry->end, first->first,
+ a->common->lowaddr)) {
+ iommu_gas_match_insert(a);
+ return (0);
+ }
+ if (first != NULL && first->free_down >= min_free) {
+ do
+ entry = first;
+ while ((first = RB_LEFT(entry, rb_entry)) != NULL &&
+ first->free_down >= min_free);
+ } else {
+ while ((first = RB_PARENT(entry, rb_entry)) != NULL &&
+ entry == RB_RIGHT(first, rb_entry))
+ entry = first;
+ entry = first;
+ }
}
- if (child != NULL && 0 == iommu_gas_lowermatch(a, child))
- return (0);
return (ENOMEM);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 23, 6:25 PM (30 m, 19 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26025359
Default Alt Text
D35486.id106926.diff (2 KB)
Attached To
Mode
D35486: make iommu_gas_lowermatch non-recursive
Attached
Detach File
Event Timeline
Log In to Comment