Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 199343
b: refs/heads/master
c: 20413f2
h: refs/heads/master
i:
  199341: 3fa55fc
  199339: 251606f
  199335: 59608ae
  199327: fbfa550
v: v3
  • Loading branch information
Xiaotian Feng authored and H. Peter Anvin committed May 26, 2010
1 parent 1ece43f commit 9583066
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fe501f1e89cd460793152f500bf25d81d463515b
refs/heads/master: 20413f27163fb1b8b806c0c219dc95eae67c633a
10 changes: 7 additions & 3 deletions trunk/arch/x86/mm/pat.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ int free_memtype(u64 start, u64 end)
{
int err = -EINVAL;
int is_range_ram;
struct memtype *entry;

if (!pat_enabled)
return 0;
Expand All @@ -355,17 +356,20 @@ int free_memtype(u64 start, u64 end)
}

spin_lock(&memtype_lock);
err = rbt_memtype_erase(start, end);
entry = rbt_memtype_erase(start, end);
spin_unlock(&memtype_lock);

if (err) {
if (!entry) {
printk(KERN_INFO "%s:%d freeing invalid memtype %Lx-%Lx\n",
current->comm, current->pid, start, end);
return -EINVAL;
}

kfree(entry);

dprintk("free_memtype request 0x%Lx-0x%Lx\n", start, end);

return err;
return 0;
}


Expand Down
6 changes: 3 additions & 3 deletions trunk/arch/x86/mm/pat_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ static inline char *cattr_name(unsigned long flags)
#ifdef CONFIG_X86_PAT
extern int rbt_memtype_check_insert(struct memtype *new,
unsigned long *new_type);
extern int rbt_memtype_erase(u64 start, u64 end);
extern struct memtype *rbt_memtype_erase(u64 start, u64 end);
extern struct memtype *rbt_memtype_lookup(u64 addr);
extern int rbt_memtype_copy_nth_element(struct memtype *out, loff_t pos);
#else
static inline int rbt_memtype_check_insert(struct memtype *new,
unsigned long *new_type)
{ return 0; }
static inline int rbt_memtype_erase(u64 start, u64 end)
{ return 0; }
static inline struct memtype *rbt_memtype_erase(u64 start, u64 end)
{ return NULL; }
static inline struct memtype *rbt_memtype_lookup(u64 addr)
{ return NULL; }
static inline int rbt_memtype_copy_nth_element(struct memtype *out, loff_t pos)
Expand Down
7 changes: 4 additions & 3 deletions trunk/arch/x86/mm/pat_rbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,17 @@ int rbt_memtype_check_insert(struct memtype *new, unsigned long *ret_type)
return err;
}

int rbt_memtype_erase(u64 start, u64 end)
struct memtype *rbt_memtype_erase(u64 start, u64 end)
{
struct memtype *data;

data = memtype_rb_exact_match(&memtype_rbroot, start, end);
if (!data)
return -EINVAL;
goto out;

rb_erase(&data->rb, &memtype_rbroot);
return 0;
out:
return data;
}

struct memtype *rbt_memtype_lookup(u64 addr)
Expand Down

0 comments on commit 9583066

Please sign in to comment.