From patchwork Thu Jul 11 18:53:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 2826573 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 50D4E9F756 for ; Thu, 11 Jul 2013 18:50:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 039552020E for ; Thu, 11 Jul 2013 18:50:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id AF06A201D3 for ; Thu, 11 Jul 2013 18:50:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9E06CE6619 for ; Thu, 11 Jul 2013 11:50:02 -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 C648BE5DC7 for ; Thu, 11 Jul 2013 11:49:49 -0700 (PDT) Received: by shiva.localdomain (Postfix, from userid 99) id 6D7D1886A3; Thu, 11 Jul 2013 18:49:49 +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.jf.intel.com (unknown [134.134.139.76]) by shiva.localdomain (Postfix) with ESMTPSA id 61B9A88167; Thu, 11 Jul 2013 18:49:48 +0000 (UTC) From: Ben Widawsky To: Intel GFX Date: Thu, 11 Jul 2013 11:53:06 -0700 Message-Id: <1373568787-3145-1-git-send-email-ben@bwidawsk.net> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1373568732-3061-1-git-send-email-ben@bwidawsk.net> References: <1373568732-3061-1-git-send-email-ben@bwidawsk.net> MIME-Version: 1.0 Cc: Ben Widawsky , Bryan Bell Subject: [Intel-gfx] [PATCH 1/2] 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 v2: Use the new param CC: Chad Versace CC: Bryan Bell Signed-off-by: Ben Widawsky --- tools/Makefile.am | 1 + tools/intel_get_llc_size.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 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..498e252 --- /dev/null +++ b/tools/intel_get_llc_size.c @@ -0,0 +1,58 @@ +/* + * 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" + +#define LOCAL__I915_PARAM_LLC_SIZE 27 +static int get_llc_size(int fd) +{ + struct drm_i915_getparam gp; + int size; + + gp.param = LOCAL__I915_PARAM_LLC_SIZE; + 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; +}