Skip to content

Commit

Permalink
gdev: Fixed a conflict device open/close and Launch
Browse files Browse the repository at this point in the history
  • Loading branch information
yk-fujii committed Mar 28, 2013
1 parent 9dfe320 commit a989620
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions common/gdev_api.c
Expand Up @@ -687,10 +687,15 @@ struct gdev_handle *gopen(int minor)
*/
int gclose(struct gdev_handle *h)
{
struct gdev_device *gdev=h->gdev;

if (!h)
return -ENOENT;
if (!h->gdev || !h->ctx || !h->vas)
return -ENOENT;

/* none can access GPU while someone is closing device. */
gdev_block_start(gdev);

#ifndef GDEV_SCHED_DISABLED
if (!h->se)
Expand All @@ -709,6 +714,9 @@ int gclose(struct gdev_handle *h)
/* free the objects. */
gdev_ctx_free(h->ctx);
gdev_vas_free(h->vas);

gdev_block_end(gdev);

gdev_dev_close(h->gdev);

GDEV_PRINT("Closed gdev%d\n", h->dev_id);
Expand Down
8 changes: 4 additions & 4 deletions common/gdev_nvidia.c
Expand Up @@ -135,22 +135,22 @@ void gdev_block_start(struct gdev_device *gdev)
retry:
if (phys) {
gdev_lock(&phys->global_lock);
if (phys->accessed) {
if (phys->accessed || phys->blocked) {
gdev_unlock(&phys->global_lock);
SCHED_YIELD();
goto retry;
}
phys->blocked = 1;
phys->blocked++;
gdev_unlock(&phys->global_lock);
}
else {
gdev_lock(&gdev->global_lock);
if (gdev->accessed) {
if (gdev->accessed || phys->blocked) {
gdev_unlock(&gdev->global_lock);
SCHED_YIELD();
goto retry;
}
gdev->blocked = 1;
gdev->blocked++;
gdev_unlock(&gdev->global_lock);
}
}
Expand Down

0 comments on commit a989620

Please sign in to comment.