Exemplo n.º 1
0
/** Tests that unlocking a lock held by another context fails appropriately */
static void
test_unlock_unowned(int drmfd)
{
	int ret;

	ret = drmGetLock(drmfd, lock1, 0);
	assert(ret == 0);
	ret = drmUnlock(drmfd, lock2);
	if (ret == 0)
		errx(1, "Unlocking other context's lock succeeded");
	ret = drmUnlock(drmfd, lock1);
	assert(ret == 0);
}
Exemplo n.º 2
0
static void client()
{
	int drmfd, ret;
	unsigned int time;

	wait_event(0, SERVER_READY);

	/* XXX: Should make sure we open the same DRM as the master */
	drmfd = drm_open_any();

	client_auth(drmfd);

	/* Wait for the server to grab the lock, then grab it ourselves (to
	 * contest it).  Hopefully we hit it within the window of when the
	 * server locks.
	 */
	wait_event(0, SERVER_LOCKED);
	ret = drmGetLock(drmfd, lock2, 0);
	time = get_millis();
	if (ret != 0)
		err(1, "Failed to get lock on client\n");
	drmUnlock(drmfd, lock2);

	/* Tell the server that our locking completed, and when it did */
	send_event(0, CLIENT_LOCKED);
	ret = write(commfd[0], &time, sizeof(time));

	close(drmfd);
	exit(0);
}
Exemplo n.º 3
0
/** Tests that unlocking the lock while it's not held works correctly */
static void
test_unlock_unlocked(int drmfd)
{
	int ret;

	ret = drmUnlock(drmfd, lock1);
	if (ret == 0)
		err(1, "Unlocking unlocked lock succeeded");
}
Exemplo n.º 4
0
/** Tests that locking is successful in normal conditions */
static void
test_lock_unlock(int drmfd)
{
	int ret;

	ret = drmGetLock(drmfd, lock1, 0);
	if (ret != 0)
		err(1, "Locking failed");
	ret = drmUnlock(drmfd, lock1);
	if (ret != 0)
		err(1, "Unlocking failed");
}
Exemplo n.º 5
0
/**
 * Tests that an open/close by the same process doesn't result in the lock
 * being dropped.
 */
static void test_open_close_locked(drmfd)
{
	int ret, tempfd;

	ret = drmGetLock(drmfd, lock1, 0);
	assert(ret == 0);
	/* XXX: Need to make sure that this is the same device as drmfd */
	tempfd = drm_open_any();
	close(tempfd);
	ret = drmUnlock(drmfd, lock1);
	if (ret != 0)
		errx(1, "lock lost during open/close by same pid");
}
Exemplo n.º 6
0
static void server()
{
	int drmfd, tempfd, ret;
	unsigned int client_time, unlock_time;

	drmfd = drm_open_any_master();

	test_lock_unlock(drmfd);
	test_unlock_unlocked(drmfd);
	test_unlock_unowned(drmfd);
	test_open_close_locked(drmfd);

	/* Perform the authentication sequence with the client. */
	server_auth(drmfd);

	/* Now, test that the client attempting to lock while the server
	 * holds the lock works correctly.
	 */
	ret = drmGetLock(drmfd, lock1, 0);
	assert(ret == 0);
	send_event(1, SERVER_LOCKED);
	/* Wait a while for the client to do its thing */
	sleep(1);
	ret = drmUnlock(drmfd, lock1);
	assert(ret == 0);
	unlock_time = get_millis();

	wait_event(1, CLIENT_LOCKED);
	ret = read(commfd[1], &client_time, sizeof(client_time));
	if (ret == -1)
		err(1, "Failure to read client magic");

	if (client_time < unlock_time)
		errx(1, "Client took lock before server released it");

	close(drmfd);
}
Exemplo n.º 7
0
struct bufmgr *
bm_intel_Attach(struct intel_context *intel)
{
   GLuint i;

   for (i = 0; i < nr_bms; i++)
      if (bufmgr_pool[i].driFd == intel->driFd) {
	 bufmgr_pool[i].refcount++;
	 _mesa_printf("retrieive old bufmgr for fd %d\n",
		      bufmgr_pool[i].driFd);
	 return &bufmgr_pool[i];
      }

   if (nr_bms < BM_MAX) {
      struct bufmgr *bm = &bufmgr_pool[nr_bms++];

      _mesa_printf("create new bufmgr for fd %d\n", intel->driFd);
      bm->driFd = intel->driFd;
      bm->hash = _mesa_NewHashTable();
      bm->refcount = 1;
      _glthread_INIT_MUTEX(bm->mutex);

      drmGetLock(bm->driFd, intel->hHWContext, 0);
      BM_CKFATAL(drmMMAllocBufferPool(bm->driFd, mmPoolRing, 0,
				      DRM_MM_TT | DRM_MM_NO_EVICT |
				      DRM_MM_READ | DRM_MM_EXE |
				      BM_BATCHBUFFER, 1024 * 1024, 4096,
				      &bm->batchPool));

      drmUnlock(bm->driFd, intel->hHWContext);
      return bm;
   }

   _mesa_printf("failed to create new bufmgr for fd %d\n", intel->driFd);
   return NULL;
}
Exemplo n.º 8
0
void i830RegetLockQuiescent( i830ContextPtr imesa )
{
   drmUnlock(imesa->driFd, imesa->hHWContext);
   i830GetLock( imesa, DRM_LOCK_QUIESCENT );
}