Esempio n. 1
0
/* increment the counter for # of contexts accessing the device. */
void gdev_access_start(struct gdev_device *gdev)
{
    struct gdev_device *phys = gdev_phys_get(gdev);

retry:
    if (phys) {
        gdev_lock(&phys->global_lock);
        if (phys->blocked) {
            gdev_unlock(&phys->global_lock);
            SCHED_YIELD();
            goto retry;
        }
        phys->accessed++;
        gdev_unlock(&phys->global_lock);
    }
    else {
        gdev_lock(&gdev->global_lock);
        if (gdev->blocked) {
            gdev_unlock(&gdev->global_lock);
            SCHED_YIELD();
            goto retry;
        }
        gdev->accessed++;
        gdev_unlock(&gdev->global_lock);
    }
}
Esempio n. 2
0
/* set the flag to block any access to the device. */
void gdev_block_start(struct gdev_device *gdev)
{
	struct gdev_device *phys = gdev->parent;

	/* we have to spin while some context is accessing the GPU. */
retry:
	if (phys) {
		gdev_lock(&phys->global_lock);
		if (phys->accessed) {
			gdev_unlock(&phys->global_lock);
			goto retry;
		}
		phys->blocked = 1;
		gdev_unlock(&phys->global_lock);
	}
	else {
		gdev_lock(&gdev->global_lock);
		if (gdev->accessed) {
			gdev_unlock(&gdev->global_lock);
			goto retry;
		}
		gdev->blocked = 1;
		gdev_unlock(&gdev->global_lock);
	}
}
Esempio n. 3
0
/* set the flag to block any access to the device. */
void gdev_block_start(struct gdev_device *gdev)
{
    struct gdev_device *phys = gdev_phys_get(gdev);

    /* we have to spin while some context is accessing the GPU. */
retry:
    if (phys) {
        gdev_lock(&phys->global_lock);
        if (phys->accessed || phys->blocked) {
            gdev_unlock(&phys->global_lock);
            SCHED_YIELD();
            goto retry;
        }
        phys->blocked++;
        gdev_unlock(&phys->global_lock);
    }
    else {
        gdev_lock(&gdev->global_lock);
        if (gdev->accessed || gdev->blocked) {
            gdev_unlock(&gdev->global_lock);
            SCHED_YIELD();
            goto retry;
        }
        gdev->blocked++;
        gdev_unlock(&gdev->global_lock);
    }
}
Esempio n. 4
0
/* decrement the counter for # of contexts accessing the device. */
void gdev_access_end(struct gdev_device *gdev)
{
	struct gdev_device *phys = gdev->parent;

	if (phys) {
		gdev_lock(&phys->global_lock);
		phys->accessed--;
		gdev_unlock(&phys->global_lock);
	}
	else {
		gdev_lock(&gdev->global_lock);
		gdev->accessed--;
		gdev_unlock(&gdev->global_lock);
	}
}
Esempio n. 5
0
/* clear the flag to unlock any access to the device. */
void gdev_block_end(struct gdev_device *gdev)
{
	struct gdev_device *phys = gdev->parent;

	if (phys) {
		gdev_lock(&phys->global_lock);
		phys->blocked = 0;
		gdev_unlock(&phys->global_lock);
	}
	else {
		gdev_lock(&gdev->global_lock);
		gdev->blocked = 0;
		gdev_unlock(&gdev->global_lock);
	}
}