From patchwork Sun Jan 22 18:48:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 9531439 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CEB2860431 for ; Sun, 22 Jan 2017 18:50:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C150427F54 for ; Sun, 22 Jan 2017 18:50:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5F9427F9E; Sun, 22 Jan 2017 18:50:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5D57E27F54 for ; Sun, 22 Jan 2017 18:50:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D99F6E351; Sun, 22 Jan 2017 18:50:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id C4F416E34C; Sun, 22 Jan 2017 18:50:27 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id r126so20918848wmr.3; Sun, 22 Jan 2017 10:50:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dBW+4T4JhlziYPswaDx5Wked8/FanvOQ3B/D6CT43ME=; b=O6U2lozTfqEjxZDQn9/N58Uk0nBSJ7X/zYDS8LM0OnuUZ+mtyvPXfgpL403S4hN3N6 ugy4UEeVanOCUnAgm/Je1lj7NNuWufmwpU08hiIxVaHTyza2baGb8WrqO3zeztpCD9Y3 2GcXH3I1djHblEORorpZz7bM8n0VOkbRQ3UU8+K+6iWXDQio1Dwah0onSyuAbePoMgHE ixS2Y8f7syCrsHMxNBKVwZTJnvWhmx4+RFF+eEhhHthun8kpkHIcozjfSQ7y4Nyfb/vg cpfvWCFOrLgw8Snrw/ZrxFIVKZTG5hWub0/JLdo1sAImdoVbRRvMvVhfIqOIRTrS11pN wJgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dBW+4T4JhlziYPswaDx5Wked8/FanvOQ3B/D6CT43ME=; b=HY6X/PoduJa8HMbmBnn4/5AoYE0x3eOvAgVRw9LKIsYPMBZVuo4Gtdqq1RUMKeh2/z Kcjjt1gSgAacrVSj0IWJtRVcK9edDA9PTR+9ZjdKKaI9ekwRBx6LmgB2Bhz7DlKF0Luk f46c5rtq+Tmc7t1IhTIGArYVNlm9HqEQC3tDlHb89oVjq0LqONtoQUVcPkQjrjcK6ft6 WI59RXDtGYxAH8aSFtYxyvL4r95UgNEENYGySGD58MZxM0hcJPM+ZgkZRxCt/8YspL9o 46uGxVcIIPJ+oVTN2V/IpO/hJ82bbhb7irwbytdTPJK4rv6M0LYjkmIwSU9X6Vfk5RKk PsXw== X-Gm-Message-State: AIkVDXIdBe8jCnUB8u6U1ySKa38kYnZqugBgyCJ6gVmjK+DlI+Ui0AJ1qlVJ8gPtbaAFFQ== X-Received: by 10.28.25.70 with SMTP id 67mr11772796wmz.125.1485111026387; Sun, 22 Jan 2017 10:50:26 -0800 (PST) Received: from localhost.localdomain (cpc91186-cmbg18-2-0-cust67.5-4.cable.virginm.net. [80.1.50.68]) by smtp.gmail.com with ESMTPSA id z67sm10732776wrb.49.2017.01.22.10.50.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jan 2017 10:50:25 -0800 (PST) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 3/3] amdgpu: rework and remove amdgpu_get_auth() Date: Sun, 22 Jan 2017 18:48:13 +0000 Message-Id: <20170122184813.12995-3-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170122184813.12995-1-emil.l.velikov@gmail.com> References: <20170122184813.12995-1-emil.l.velikov@gmail.com> Cc: emil.l.velikov@gmail.com, amd-gfx@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;