From patchwork Wed Jul 10 02:58:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 2825514 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9DAC9C0AB2 for ; Wed, 10 Jul 2013 02:55:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9CC9C200F2 for ; Wed, 10 Jul 2013 02:55:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B6D35200F1 for ; Wed, 10 Jul 2013 02:55:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 97BEBE6302 for ; Tue, 9 Jul 2013 19:55:37 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from shiva.localdomain (unknown [209.20.75.48]) by gabe.freedesktop.org (Postfix) with ESMTP id 9085DE5BFA for ; Tue, 9 Jul 2013 19:54:53 -0700 (PDT) Received: by shiva.localdomain (Postfix, from userid 99) id 4C08188081; Wed, 10 Jul 2013 02:54:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lundgren.kumite (c-24-21-100-90.hsd1.or.comcast.net [24.21.100.90]) by shiva.localdomain (Postfix) with ESMTPSA id AF7378862F; Wed, 10 Jul 2013 02:54:47 +0000 (UTC) From: Ben Widawsky To: Intel GFX Date: Tue, 9 Jul 2013 19:58:03 -0700 Message-Id: <1373425083-1276-2-git-send-email-ben@bwidawsk.net> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1373425083-1276-1-git-send-email-ben@bwidawsk.net> References: <1373425083-1276-1-git-send-email-ben@bwidawsk.net> MIME-Version: 1.0 Cc: Ben Widawsky , Bryan Bell Subject: [Intel-gfx] [PATCH] intel_get_llc_size: Small tool to query LLC size X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Virus-Scanned: ClamAV using ClamSMTP CC: Chad Versace CC: Bryan Bell Signed-off-by: Ben Widawsky --- tools/Makefile.am | 1 + tools/intel_get_llc_size.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 tools/intel_get_llc_size.c diff --git a/tools/Makefile.am b/tools/Makefile.am index 2519169..a064b65 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -9,6 +9,7 @@ bin_PROGRAMS = \ intel_bios_dumper \ intel_bios_reader \ intel_error_decode \ + intel_get_llc_size \ intel_gpu_top \ intel_gpu_time \ intel_gtt \ diff --git a/tools/intel_get_llc_size.c b/tools/intel_get_llc_size.c new file mode 100644 index 0000000..bd384d2 --- /dev/null +++ b/tools/intel_get_llc_size.c @@ -0,0 +1,57 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +#include +#include "drmtest.h" +#include "i915_drm.h" + +static int get_llc_size(int fd) +{ + struct drm_i915_getparam gp; + int size; + + gp.param = I915_PARAM_HAS_LLC; + gp.value = &size; + + if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp))) + return 0; + + return size; +} + +int main(int argc, char **argv) +{ + int size, fd = drm_open_any(); + + size = get_llc_size(fd); + + if (size == 0) + fprintf(stdout, "Doesn't have LLC\n"); + else if (size == 1) + fprintf(stdout, "Kernel is too old to determine LLC size\n"); + else + fprintf(stdout, "LLC size = %dK\n", size>>10); + + return 0; +}