dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Emil Velikov <emil.l.velikov@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: emil.l.velikov@gmail.com, amd-gfx@lists.freedesktop.org
Subject: [PATCH libdrm 3/3] amdgpu: rework and remove amdgpu_get_auth()
Date: Sun, 22 Jan 2017 18:48:13 +0000	[thread overview]
Message-ID: <20170122184813.12995-3-emil.l.velikov@gmail.com> (raw)
In-Reply-To: <20170122184813.12995-1-emil.l.velikov@gmail.com>

All one needs is to establish if dev->fd is the flink (primary/card)
node, rather than use DRM_IOCTL_GET_CLIENT to query the auth status.

The latter is [somewhat] deprecated and incorrect. We need to know [and
store] the primary node FD, since we're going to use it [at a later
stage] for buffer import/export sharing.

Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
---
Again not 100% sure but things look quite fishy as-is... The
conditionals might be off.

Note: original code [and this one] do not consider if flink_fd is
already set, thus as we dup we'll leak it.
---
 amdgpu/amdgpu_device.c | 43 ++-----------------------------------------
 1 file changed, 2 insertions(+), 41 deletions(-)

diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
index f4ede031..6f04d936 100644
--- a/amdgpu/amdgpu_device.c
+++ b/amdgpu/amdgpu_device.c
@@ -101,34 +101,6 @@ static int fd_compare(void *key1, void *key2)
 	return result;
 }
 
-/**
-* Get the authenticated form fd,
-*
-* \param   fd   - \c [in]  File descriptor for AMD GPU device
-* \param   auth - \c [out] Pointer to output the fd is authenticated or not
-*                          A render node fd, output auth = 0
-*                          A legacy fd, get the authenticated for compatibility root
-*
-* \return   0 on success\n
-*          >0 - AMD specific error code\n
-*          <0 - Negative POSIX Error code
-*/
-static int amdgpu_get_auth(int fd, int *auth)
-{
-	int r = 0;
-	drm_client_t client = {};
-
-	if (drmGetNodeTypeFromFd(fd) == DRM_NODE_RENDER)
-		*auth = 0;
-	else {
-		client.idx = 0;
-		r = drmIoctl(fd, DRM_IOCTL_GET_CLIENT, &client);
-		if (!r)
-			*auth = client.auth;
-	}
-	return r;
-}
-
 static void amdgpu_device_free_internal(amdgpu_device_handle dev)
 {
 	amdgpu_vamgr_deinit(dev->vamgr);
@@ -175,8 +147,6 @@ int amdgpu_device_initialize(int fd,
 	struct amdgpu_device *dev;
 	drmVersionPtr version;
 	int r;
-	int flag_auth = 0;
-	int flag_authexist=0;
 	uint32_t accel_working = 0;
 	uint64_t start, max;
 
@@ -185,19 +155,10 @@ int amdgpu_device_initialize(int fd,
 	pthread_mutex_lock(&fd_mutex);
 	if (!fd_tab)
 		fd_tab = util_hash_table_create(fd_hash, fd_compare);
-	r = amdgpu_get_auth(fd, &flag_auth);
-	if (r) {
-		pthread_mutex_unlock(&fd_mutex);
-		return r;
-	}
 	dev = util_hash_table_get(fd_tab, UINT_TO_PTR(fd));
 	if (dev) {
-		r = amdgpu_get_auth(dev->fd, &flag_authexist);
-		if (r) {
-			pthread_mutex_unlock(&fd_mutex);
-			return r;
-		}
-		if ((flag_auth) && (!flag_authexist)) {
+		if (drmGetNodeTypeFromFd(fd) == DRM_NODE_RENDER &&
+		    drmGetNodeTypeFromFd(dev->fd) == DRM_NODE_PRIMARY) {
 			dev->flink_fd = dup(fd);
 		}
 		*major_version = dev->major_version;
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-01-22 18:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-22 18:48 [PATCH libdrm 1/3] amdgpu: add missing unlock on drmPrimeFDToHandle() failure Emil Velikov
     [not found] ` <20170122184813.12995-1-emil.l.velikov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-22 18:48   ` [PATCH libdrm 2/3] amdgpu: don't mess with shared_handle if amdgpu_bo_import() fails Emil Velikov
2017-01-23 16:14     ` Nicolai Hähnle
2017-01-24  3:53       ` Emil Velikov
2017-01-23 16:15   ` [PATCH libdrm 1/3] amdgpu: add missing unlock on drmPrimeFDToHandle() failure Nicolai Hähnle
2017-01-22 18:48 ` Emil Velikov [this message]
2017-03-07  0:45   ` [PATCH libdrm 3/3] amdgpu: rework and remove amdgpu_get_auth() Emil Velikov
     [not found]     ` <CACvgo50BMP2qZsFzJK7Jmc-sAJkz7NVGKz0XjxZP3dMGs7_wtg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-07  0:47       ` Emil Velikov
2017-08-21 12:31   ` Emil Velikov
2017-08-21 12:56     ` Christian König
2017-08-21 16:37     ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170122184813.12995-3-emil.l.velikov@gmail.com \
    --to=emil.l.velikov@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).