From patchwork Thu Mar 5 16:20:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lespiau, Damien" X-Patchwork-Id: 5947401 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CCDA69FB14 for ; Thu, 5 Mar 2015 16:20:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2E20202BE for ; Thu, 5 Mar 2015 16:20:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C96C72038E for ; Thu, 5 Mar 2015 16:20:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D66826E3A3; Thu, 5 Mar 2015 08:20:26 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id E4DCB6E7F6; Thu, 5 Mar 2015 08:20:25 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 05 Mar 2015 08:20:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,347,1422950400"; d="scan'208";a="462980617" Received: from rmoore5-mobl1.amr.corp.intel.com (HELO strange.ger.corp.intel.com) ([10.252.11.84]) by FMSMGA003.fm.intel.com with ESMTP; 05 Mar 2015 08:14:04 -0800 From: Damien Lespiau To: intel-gfx@lists.freedesktop.org Date: Thu, 5 Mar 2015 16:20:11 +0000 Message-Id: <1425572420-10067-4-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1425572420-10067-1-git-send-email-damien.lespiau@intel.com> References: <1425572420-10067-1-git-send-email-damien.lespiau@intel.com> Cc: dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH 03/12] intel: Use drm_intel_device in the gem buffer manager X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Damien Lespiau --- intel/intel_bufmgr_gem.c | 58 +++++++----------------------------------------- 1 file changed, 8 insertions(+), 50 deletions(-) diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index 33d8fbc..72a6ab1 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -60,6 +60,7 @@ #include "libdrm_lists.h" #include "intel_bufmgr.h" #include "intel_bufmgr_priv.h" +#include "intel_device.h" #include "intel_chipset.h" #include "intel_aub.h" #include "string.h" @@ -120,6 +121,7 @@ typedef struct _drm_intel_bufmgr_gem { uint64_t gtt_size; int available_fences; + struct drm_intel_device *dev; int pci_device; int gen; unsigned int has_bsd : 1; @@ -1763,6 +1765,7 @@ drm_intel_bufmgr_gem_destroy(drm_intel_bufmgr *bufmgr) } } + drm_intel_device_free(bufmgr_gem->dev); free(bufmgr); } @@ -3071,37 +3074,6 @@ drm_intel_bufmgr_gem_set_vma_cache_size(drm_intel_bufmgr *bufmgr, int limit) drm_intel_gem_bo_purge_vma_cache(bufmgr_gem); } -/** - * Get the PCI ID for the device. This can be overridden by setting the - * INTEL_DEVID_OVERRIDE environment variable to the desired ID. - */ -static int -get_pci_device_id(drm_intel_bufmgr_gem *bufmgr_gem) -{ - char *devid_override; - int devid = 0; - int ret; - drm_i915_getparam_t gp; - - if (geteuid() == getuid()) { - devid_override = getenv("INTEL_DEVID_OVERRIDE"); - if (devid_override) { - bufmgr_gem->no_exec = true; - return strtod(devid_override, NULL); - } - } - - memclear(gp); - gp.param = I915_PARAM_CHIPSET_ID; - gp.value = &devid; - ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp); - if (ret) { - fprintf(stderr, "get chip id failed: %d [%d]\n", ret, errno); - fprintf(stderr, "param: %d, val: %d\n", gp.param, *gp.value); - } - return devid; -} - drm_public int drm_intel_bufmgr_gem_get_devid(drm_intel_bufmgr *bufmgr) { @@ -3469,30 +3441,16 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size) (int)bufmgr_gem->gtt_size / 1024); } - bufmgr_gem->pci_device = get_pci_device_id(bufmgr_gem); - - if (IS_GEN2(bufmgr_gem->pci_device)) - bufmgr_gem->gen = 2; - else if (IS_GEN3(bufmgr_gem->pci_device)) - bufmgr_gem->gen = 3; - else if (IS_GEN4(bufmgr_gem->pci_device)) - bufmgr_gem->gen = 4; - else if (IS_GEN5(bufmgr_gem->pci_device)) - bufmgr_gem->gen = 5; - else if (IS_GEN6(bufmgr_gem->pci_device)) - bufmgr_gem->gen = 6; - else if (IS_GEN7(bufmgr_gem->pci_device)) - bufmgr_gem->gen = 7; - else if (IS_GEN8(bufmgr_gem->pci_device)) - bufmgr_gem->gen = 8; - else if (IS_GEN9(bufmgr_gem->pci_device)) - bufmgr_gem->gen = 9; - else { + bufmgr_gem->dev = drm_intel_device_new(fd); + if (bufmgr_gem->dev == NULL) { free(bufmgr_gem); bufmgr_gem = NULL; goto exit; } + bufmgr_gem->pci_device = drm_intel_device_get_devid(bufmgr_gem->dev); + bufmgr_gem->gen = bufmgr_gem->dev->gen; + if (IS_GEN3(bufmgr_gem->pci_device) && bufmgr_gem->gtt_size > 256*1024*1024) { /* The unmappable part of gtt on gen 3 (i.e. above 256MB) can't