Skip to content

Commit

Permalink
Fix iommu address space allocation
Browse files Browse the repository at this point in the history
commit a15a519 upstream.

This fixes kernel.org bug #13584. The IOVA code attempted to optimise
the insertion of new ranges into the rbtree, with the unfortunate result
that some ranges just didn't get inserted into the tree at all. Then
those ranges would be handed out more than once, and things kind of go
downhill from there.

Introduced after 2.6.25 by ddf0288
("PCI: iova RB tree setup tweak").

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Cc: mark gross <mgross@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
David Woodhouse authored and Greg Kroah-Hartman committed Jul 20, 2009
1 parent e1a4576 commit bfa4144
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions drivers/pci/iova.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
/*
* Copyright (c) 2006, Intel Corporation.
* Copyright © 2006-2009, Intel Corporation.
*
* This file is released under the GPLv2.
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Copyright (C) 2006-2008 Intel Corporation
* Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
*/

Expand Down Expand Up @@ -123,7 +133,15 @@ static int __alloc_and_insert_iova_range(struct iova_domain *iovad,
/* Insert the new_iova into domain rbtree by holding writer lock */
/* Add new node and rebalance tree. */
{
struct rb_node **entry = &((prev)), *parent = NULL;
struct rb_node **entry, *parent = NULL;

/* If we have 'prev', it's a valid place to start the
insertion. Otherwise, start from the root. */
if (prev)
entry = &prev;
else
entry = &iovad->rbroot.rb_node;

/* Figure out where to put new node */
while (*entry) {
struct iova *this = container_of(*entry,
Expand Down

0 comments on commit bfa4144

Please sign in to comment.