From patchwork Tue Feb 14 00:09:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Pitoiset X-Patchwork-Id: 9570899 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 3F50B60442 for ; Tue, 14 Feb 2017 00:09:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30C9826E56 for ; Tue, 14 Feb 2017 00:09:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2530527B81; Tue, 14 Feb 2017 00:09:28 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, 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 E0AE727CAF for ; Tue, 14 Feb 2017 00:09:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A5106E59C; Tue, 14 Feb 2017 00:09:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id B142B6E59B for ; Tue, 14 Feb 2017 00:09:24 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id c85so855226wmi.1 for ; Mon, 13 Feb 2017 16:09:24 -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=8PPFh6f1vlIUw6aNS56klTgvWNkGgoHA92d7fRsP/QI=; b=DbIDjDIXPFdwJ+qltepUC8MnVHycbYxOpEvURIHI7ERSNRrZS/2i/q715oEA0GFo36 WE8uNti8AgeFDpEADW2YQUIPxKzXOFZHVBhfwplqAKUC371JIKi+sPA5pBTq2CLIuPsv DJ2vRdXFfQ+BJR06rOJSiG6k9DDJmM4UztK5IVFOlipc+5hPnhYrWMNaidto/S4TcZxI YMJNC7VRRt7vNfnUDIQw5wp8bXx+9fZVoKfKysCpXJwXVsD4ZCgdr2nYTDVuTIoaTwOM 3OczYXRAk6bz4LQ6XjTIbwOMMH/GQYEICBHettlMsLfeRflvDOXPegBUkjpofxmDIydM Gg4w== 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=8PPFh6f1vlIUw6aNS56klTgvWNkGgoHA92d7fRsP/QI=; b=IGVXewuFI8YN2pdEiIAfvzKxx6D78Pv1W3g/vQpjPjPw0NDxxRZQygpmwZwItxrlwn /BVtojzw8dS3aXZ7nPcXpyZYkP6dLrHxe5x2kjo7voNO83Q1WWQ96PhpDo9hoz2A+SPg /phl6eOj8NF7OZLuP+K2vaqtNe9Mweosws8ApdnwORVaXAo1uOKuiF8F1GXQmUmMIhNW 7CJAYz6zCxtl/vZPGC+SqbkPeaQXuAYBtAvTlAZPwA8FM5e9XR0CGvr9zN6OmB9xmsv9 2of3wokpG6QnN28EvYWrzQdkK/L1REFPC8m9WeycA4RzfNgErdt7Dxv4B/li7Mn4NehL 6tpg== X-Gm-Message-State: AMke39n81BxtAYQ6q2X5hZ695KSuG3FCrGxE4O+BVqjAdfjnjdSF9HAZRf8b2Drd8ByBnA== X-Received: by 10.28.99.69 with SMTP id x66mr638114wmb.91.1487030963155; Mon, 13 Feb 2017 16:09:23 -0800 (PST) Received: from localhost.localdomain (tal33-1-82-225-21-61.fbx.proxad.net. [82.225.21.61]) by smtp.gmail.com with ESMTPSA id 94sm12609890wrl.50.2017.02.13.16.09.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Feb 2017 16:09:22 -0800 (PST) From: Samuel Pitoiset To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 3/4] amdgpu: allow to query GPU sensor related information Date: Tue, 14 Feb 2017 01:09:01 +0100 Message-Id: <20170214000902.30234-4-samuel.pitoiset@gmail.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170214000902.30234-1-samuel.pitoiset@gmail.com> References: <20170214000902.30234-1-samuel.pitoiset@gmail.com> 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 This exposes amdgpu_query_gpu_sensor_info(). Signed-off-by: Samuel Pitoiset --- amdgpu/amdgpu.h | 19 +++++++++++++++++++ amdgpu/amdgpu_gpu_info.c | 15 +++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index 7b26a04c..b040f6ab 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -1059,6 +1059,25 @@ int amdgpu_query_gds_info(amdgpu_device_handle dev, struct amdgpu_gds_resource_info *gds_info); /** + * Query information about GPU sensor. + * + * The return size is query-specific and depends on the "sensor_type" + * parameter. No more than "size" bytes is returned. + * + * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() + * \param sensor_type - \c [in] AMDGPU_INFO_GPU_SENSOR_* + * \param size - \c [in] Size of the returned value. + * \param value - \c [out] Pointer to the return value. + * + * \return 0 on success\n + * <0 - Negative POSIX Error code + * +*/ +int amdgpu_query_gpu_sensor_info(amdgpu_device_handle dev, + unsigned sensor_type, + unsigned size, void *value); + +/** * Read a set of consecutive memory-mapped registers. * Not all registers are allowed to be read by userspace. * diff --git a/amdgpu/amdgpu_gpu_info.c b/amdgpu/amdgpu_gpu_info.c index 66c7e0e1..778c2ee1 100644 --- a/amdgpu/amdgpu_gpu_info.c +++ b/amdgpu/amdgpu_gpu_info.c @@ -314,3 +314,18 @@ int amdgpu_query_gds_info(amdgpu_device_handle dev, return 0; } + +int amdgpu_query_gpu_sensor_info(amdgpu_device_handle dev, unsigned sensor_type, + unsigned size, void *value) +{ + struct drm_amdgpu_info request; + + memset(&request, 0, sizeof(request)); + request.return_pointer = (uintptr_t)value; + request.return_size = size; + request.query = AMDGPU_INFO_GPU_SENSOR; + request.gpu_sensor_info.type = sensor_type; + + return drmCommandWrite(dev->fd, DRM_AMDGPU_INFO, &request, + sizeof(struct drm_amdgpu_info)); +}