Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176732
b: refs/heads/master
c: 7f2251b
h: refs/heads/master
v: v3
  • Loading branch information
Jack Steiner authored and Linus Torvalds committed Dec 16, 2009
1 parent 62a6efe commit 78f146a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 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: 6c9620c64be3920487c0533e0ab6724dad565d59
refs/heads/master: 7f2251b1bcdd3d2971b2fde3008b270ea11b8780
6 changes: 3 additions & 3 deletions trunk/drivers/misc/sgi-gru/grufault.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static struct gru_thread_state *gru_alloc_locked_gts(unsigned long vaddr)
vma = gru_find_vma(vaddr);
if (vma)
gts = gru_alloc_thread_state(vma, TSID(vaddr, vma));
if (gts) {
if (!IS_ERR(gts)) {
mutex_lock(&gts->ts_ctxlock);
downgrade_write(&mm->mmap_sem);
} else {
Expand Down Expand Up @@ -747,8 +747,8 @@ int gru_set_context_option(unsigned long arg)
gru_dbg(grudev, "op %d, gseg 0x%lx, value1 0x%lx\n", req.op, req.gseg, req.val1);

gts = gru_alloc_locked_gts(req.gseg);
if (!gts)
return -EINVAL;
if (IS_ERR(gts))
return PTR_ERR(gts);

switch (req.op) {
case sco_blade_chiplet:
Expand Down
18 changes: 11 additions & 7 deletions trunk/drivers/misc/sgi-gru/grumain.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/sched.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/err.h>
#include <asm/uv/uv_hub.h>
#include "gru.h"
#include "grutables.h"
Expand Down Expand Up @@ -286,7 +287,8 @@ static void gru_unload_mm_tracker(struct gru_state *gru,
void gts_drop(struct gru_thread_state *gts)
{
if (gts && atomic_dec_return(&gts->ts_refcnt) == 0) {
gru_drop_mmu_notifier(gts->ts_gms);
if (gts->ts_gms)
gru_drop_mmu_notifier(gts->ts_gms);
kfree(gts);
STAT(gts_free);
}
Expand All @@ -313,13 +315,14 @@ struct gru_thread_state *gru_alloc_gts(struct vm_area_struct *vma,
int cbr_au_count, int dsr_au_count, int options, int tsid)
{
struct gru_thread_state *gts;
struct gru_mm_struct *gms;
int bytes;

bytes = DSR_BYTES(dsr_au_count) + CBR_BYTES(cbr_au_count);
bytes += sizeof(struct gru_thread_state);
gts = kmalloc(bytes, GFP_KERNEL);
if (!gts)
return NULL;
return ERR_PTR(-ENOMEM);

STAT(gts_alloc);
memset(gts, 0, sizeof(struct gru_thread_state)); /* zero out header */
Expand All @@ -338,17 +341,18 @@ struct gru_thread_state *gru_alloc_gts(struct vm_area_struct *vma,
if (vma) {
gts->ts_mm = current->mm;
gts->ts_vma = vma;
gts->ts_gms = gru_register_mmu_notifier();
if (!gts->ts_gms)
gms = gru_register_mmu_notifier();
if (IS_ERR(gms))
goto err;
gts->ts_gms = gms;
}

gru_dbg(grudev, "alloc gts %p\n", gts);
return gts;

err:
gts_drop(gts);
return NULL;
return ERR_CAST(gms);
}

/*
Expand Down Expand Up @@ -396,8 +400,8 @@ struct gru_thread_state *gru_alloc_thread_state(struct vm_area_struct *vma,

gts = gru_alloc_gts(vma, vdata->vd_cbr_au_count, vdata->vd_dsr_au_count,
vdata->vd_user_options, tsid);
if (!gts)
return NULL;
if (IS_ERR(gts))
return gts;

spin_lock(&vdata->vd_lock);
ngts = gru_find_current_gts_nolock(vdata, tsid);
Expand Down
8 changes: 7 additions & 1 deletion trunk/drivers/misc/sgi-gru/grutlbpurge.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ struct gru_mm_struct *gru_register_mmu_notifier(void)
{
struct gru_mm_struct *gms;
struct mmu_notifier *mn;
int err;

mn = mmu_find_ops(current->mm, &gru_mmuops);
if (mn) {
Expand All @@ -311,12 +312,17 @@ struct gru_mm_struct *gru_register_mmu_notifier(void)
gms->ms_notifier.ops = &gru_mmuops;
atomic_set(&gms->ms_refcnt, 1);
init_waitqueue_head(&gms->ms_wait_queue);
__mmu_notifier_register(&gms->ms_notifier, current->mm);
err = __mmu_notifier_register(&gms->ms_notifier, current->mm);
if (err)
goto error;
}
}
gru_dbg(grudev, "gms %p, refcnt %d\n", gms,
atomic_read(&gms->ms_refcnt));
return gms;
error:
kfree(gms);
return ERR_PTR(err);
}

void gru_drop_mmu_notifier(struct gru_mm_struct *gms)
Expand Down

0 comments on commit 78f146a

Please sign in to comment.