From 1f9fdab96d00903541f61cd0a7dc53ddd375b798 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 4 Mar 2008 14:28:57 -0800 Subject: [PATCH] --- yaml --- r: 86807 b: refs/heads/master c: 23d7e0390ab57cf15a5cfe8d6806192f0997e5a8 h: refs/heads/master i: 86805: e77ef389225056f859b8ec4263e993f69479bcdd 86803: 995bb2b1a6c4db5fd7f8b3b8a57b92cdc430dd37 86799: 7f4a75d59629b3a772697f8899fd7a0d615c246c v: v3 --- [refs] | 2 +- trunk/arch/alpha/kernel/pci_iommu.c | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/[refs] b/[refs] index 1bc8009cbbe0..e0259d7dfc8e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3c5f1def7dd50b792f56dcf7378c2684c06947f3 +refs/heads/master: 23d7e0390ab57cf15a5cfe8d6806192f0997e5a8 diff --git a/trunk/arch/alpha/kernel/pci_iommu.c b/trunk/arch/alpha/kernel/pci_iommu.c index bbf9990cd238..e54f829528cb 100644 --- a/trunk/arch/alpha/kernel/pci_iommu.c +++ b/trunk/arch/alpha/kernel/pci_iommu.c @@ -132,12 +132,15 @@ iommu_arena_find_pages(struct pci_iommu_arena *arena, long n, long mask) { unsigned long *ptes; long i, p, nent; + int pass = 0; /* Search forward for the first mask-aligned sequence of N free ptes */ ptes = arena->ptes; nent = arena->size >> PAGE_SHIFT; p = ALIGN(arena->next_entry, mask + 1); i = 0; + +again: while (i < n && p+i < nent) { if (ptes[p+i]) p = ALIGN(p + i + 1, mask + 1), i = 0; @@ -146,19 +149,18 @@ iommu_arena_find_pages(struct pci_iommu_arena *arena, long n, long mask) } if (i < n) { - /* Reached the end. Flush the TLB and restart the - search from the beginning. */ - alpha_mv.mv_pci_tbi(arena->hose, 0, -1); - - p = 0, i = 0; - while (i < n && p+i < nent) { - if (ptes[p+i]) - p = ALIGN(p + i + 1, mask + 1), i = 0; - else - i = i + 1; - } - - if (i < n) + if (pass < 1) { + /* + * Reached the end. Flush the TLB and restart + * the search from the beginning. + */ + alpha_mv.mv_pci_tbi(arena->hose, 0, -1); + + pass++; + p = 0; + i = 0; + goto again; + } else return -1; }