From patchwork Fri Aug 5 15:59:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Piotr_Pi=C3=B3rkowski?= X-Patchwork-Id: 12937518 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B7D8C00140 for ; Fri, 5 Aug 2022 16:01:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 497F093A89; Fri, 5 Aug 2022 16:01:27 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 21FC9A3A12; Fri, 5 Aug 2022 16:01:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659715268; x=1691251268; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=d6oQcgkSZUFLFzGx1qOhwgVjbpRgYdJZTMwiCO96jfY=; b=gUGtAOEPbLjeBJN6T2YJXuDeClh2xxQfKg8ELwjnmKrA8hSJnMssisRu P5poCLfjRy89xRrPx3doCciXOuLz+JpGZ9LxAk0tA4deFcME48MPti6Xv mKuAGzzA3Nf1AuTQFPnt+kW6RR5/Re5ZwFAsU+QAVtIRWmb7qlprWywyg mJiwiCRjzaVvYp5GV3X5y82x6VQwGSghiFlEB/Ob6o3qR7Lv0HEE8oH6s w4aL2cHpVsWwK/FnlkZ9qHX40enkbtmKitvj8dlS5zXKpZR1qevc24sgE /Gfrcsxvucko9YZjDhExf2os/vsplEiLk4TjctbKCCDX1JEdDHRicUqMB g==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="273275965" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="273275965" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 09:01:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="671731824" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by fmsmga004.fm.intel.com with ESMTP; 05 Aug 2022 09:01:04 -0700 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Fri, 5 Aug 2022 09:01:04 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Fri, 5 Aug 2022 09:01:04 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.172) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.28; Fri, 5 Aug 2022 09:01:00 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TK2xR6LuRjimk6do0X/9TCzjaVt9KjeQ2dKcyswDtZcNsE/B9KGp+57F5/83cDl/MsdfLj0Gr1eh/cyV40cSyIDQsh0iuNvqFCMUHUQ43zJtF4VagpqHQ/b888iZnFrh4M+wHGv9gGlMAz9+RaZHvBAhA5bxZUUQ9+QGQ+CzdjHROntnHYkS/Em3Ixuk84RhIar33gnNiZUuHfNqkMyLJYq7fn6YGBoE/CLQeWozB4GGWLmZDAMM1GWTwEVfpeaih1xC6swRmyvOyJyurH+p/oC34ek2XsjK6azUfv3Q/uNyT9qcPbOUKIP/zhYq+gmyA/t3QwGt9f2qrQG7tDP5fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=04ICKZfsoFXyKBPItVNMf86hBDmjQOyJbMODJjuB13M=; b=nrauLgWlrx4sBYg6jCjMzXuT1ajMsGAJcdg2TgOspD5axw0a/fOiycJwYp2wtX2CUcUxYr/cFoY/t6ucfIa+qNWTF1JASaoL0tIr+cNKDEpWNJUUr9iKmbkTYWvWLZhkiQ9UZhHVu1Qv7xHg+VdGp4b3zNmnpQ9vYWhV2+GgfBSine5K164hxROcUn2t6qfcnmCiiZHVhdPfDAarFxOQERabhkr/33N4sGvl7dhbNeEdpH/aG8u75LQafiSoMWpuufarGhAoGTGQJ+clhYg54zG55QLRsii21W9pbmqjUptCxvqBobjm/KFMdn9OM8CoIyoH6az3cExnc8D2XLu4qQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM5PR11MB1372.namprd11.prod.outlook.com (2603:10b6:3:11::14) by DM5PR1101MB2075.namprd11.prod.outlook.com (2603:10b6:4:5a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Fri, 5 Aug 2022 16:00:45 +0000 Received: from DM5PR11MB1372.namprd11.prod.outlook.com ([fe80::bc9e:4951:a404:5507]) by DM5PR11MB1372.namprd11.prod.outlook.com ([fe80::bc9e:4951:a404:5507%3]) with mapi id 15.20.5504.016; Fri, 5 Aug 2022 16:00:45 +0000 From: "Piorkowski, Piotr" To: , Date: Fri, 5 Aug 2022 17:59:58 +0200 Message-ID: <20220805155959.1983584-2-piotr.piorkowski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220805155959.1983584-1-piotr.piorkowski@intel.com> References: <20220805155959.1983584-1-piotr.piorkowski@intel.com> X-ClientProxiedBy: FR3P281CA0059.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4b::21) To DM5PR11MB1372.namprd11.prod.outlook.com (2603:10b6:3:11::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ad934820-8b23-42d4-0d72-08da76fb9a4f X-MS-TrafficTypeDiagnostic: DM5PR1101MB2075:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lX3/VlVOZLCkpm8iH6mwvgqw6IgxszBknIzL2Pj+Ylnkml0gBU/1gZNvx7Pq9wwxHqw9qENBTLe79yubIwcNMtSk4UKaUFGgaX26gwC2Yi57N4pEAlkHrDW2N7ymp3l9q9AbvHUb5EUhHM/fWOQLViPEeywN3i0gJeoR7wMkIdDZ9s96yPx/j2GLzjwYJIQ23odO/3h4vyy01lhBqjHZ1iLY7LYH1VEBEt89Ss51WHxWI32Wj1m/yUrpyTcu/fkxZ1UQwr6CcEdLjE1j1ekLlnBtkOD67e3xBckMccHs6AGZDSoOr5zoHuxwPJ58+0IKbY5F0Q18B2UT+HXQYLmFolHuSmBv1khjHT5TDQP5jpNvLhZGThF+Ya4ZSW6NWS/RvdpwXpqMazB/tN9QpR4DlyJLxKfcLGJtu8Y0VsvI6kX9+F6PytnfFq2W12ny8qcAXDsFHA4NE+pguoEBlJ+3vD81eqVOvURNoLq4p0dz3k0OdhSs03rQFojZU1JyBVV0e0/+BZ61U5LJ1OTkNFJ/co2eqpcpbrEB0hRMI9HI53sQcQyIsmXrWsEckIQzA6WFtzvyCV3kcxl1oD8gls4+LMnLh0B4tpi4CmwYmJ4DSekaH7lFfHbMrEe2kJl+DAimriDtIMLIzPjdNsjw27sryRUH7q8g/7pY1SwfcvYRCKw1/4IEOr1ibfqLq+3kEJXmqs/kifwoD5d1Kpza/ZuBLkTb8zUDnHPJtzyheVHmrKdVgQK1myI7nifpFc4C3GHv X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR11MB1372.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(136003)(346002)(396003)(39860400002)(376002)(366004)(2906002)(83380400001)(82960400001)(38100700002)(6486002)(316002)(66574015)(5660300002)(66556008)(54906003)(66476007)(66946007)(8676002)(4326008)(6512007)(186003)(1076003)(2616005)(8936002)(86362001)(41300700001)(6506007)(478600001)(36756003)(6666004)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?+1PnlpwzQXXxTpquReEWa5MizQZB?= =?utf-8?q?+TysYDQaIyRJlRarAuGtLKRHisxpLM04c7bUkQBmnaBzfxk8F9kPJlyal3b+7m6GF?= =?utf-8?q?y4jk405HshFRCD3uo6fM7rnMX5LRT115mrMM3tVCEmL6LBSi2ZOg/xesoiA+8RytF?= =?utf-8?q?7OVcOwt58l9/tZigUjRknwHnWyR+x4t5UHcyiFViE7HSLLVwMd05Dgn4xCeD/pdmg?= =?utf-8?q?h01fe/QeTpsx62XPRAwXIuFbZSJQSM8c19RWOzAJGCALGjXHeSBn3hxTlmOl5XEvw?= =?utf-8?q?DC5ikSbNiWipE35qrMrP1TIlCTKkB5Bsl92N3BRnwluq5SqtBLzJTYbiW6tme8cEN?= =?utf-8?q?K3nKUU83yetO9r4XKE6V5HPdpEdqIeLzJ0Z0wnPZJTKDXtczo85MmSh5Qt929TGvr?= =?utf-8?q?EuICbZt3zhyeipJ+dVMCtfXRrC2WCoX0BaGmRJ7go183+45IqHEsSW3Rg/9gCE1Wv?= =?utf-8?q?1aUi0ZDC4s60LJmbruct9ABUkSJU3hpQjH5EfAZbx23+KIuKXupTMNONtACC9A3Yh?= =?utf-8?q?J7iFjj5PPvRBbwrAA8jVDLUkJ0ethQCVBC00F4naLPyTaIJ9U9Uj2xClxyN2tl5hw?= =?utf-8?q?Xiiu/xEufgW8JRQSR0HbZrH+tAhPp83icUbEjgHvFu6pm1WWLeXjsYpk9jvLWDreo?= =?utf-8?q?qq01nbDhYZCo16K4CGEsOk48fw1Rs49i5Nc3B1u63IdSArIyfTCEDtB8lO+umDsyG?= =?utf-8?q?98lISN3mvcxyV9xqHkw+0hZfO+UIIT9VX0Pc1vDvYzRo3PbRaYfDNcQY5h62pNIv5?= =?utf-8?q?BX9HXQKEvuw5+wSl2k5eK/AK1yknWvPrL6K3teWFTT2vLI521eYq5kTwuU1PJHH4t?= =?utf-8?q?qjwN7AwiJu/h4rYxcMhBvyrG2m3LysOxpu5e7YBwBWFXbSYuYiIg7VC8zJi2H4vZI?= =?utf-8?q?clbPsd+vyY9bmjSILpiGzXOpMFoxi2NW+9MI/ZrWwX8Eap4JxMuR8hbj2CI7MG2fS?= =?utf-8?q?Nc4f3ClMPoq2j4Z7w/gxudWvFgQAm3tFL2NIO51lEAMb5UPT6fOLscwNbfmXz3pkj?= =?utf-8?q?we8s8ZeAJa4QAnR253J+MsE1K/zNUEp9Cf1BuknRn9f5n2VTC0sIqUorRl3SOpuqe?= =?utf-8?q?FgOLumWZA+wlnuIHAOXYxgbck93I0Pd5PFWB3xcObHnjilNfgz5Y9A3/zNlDkvrUj?= =?utf-8?q?r5n4KijL6nTVPKqyCb7IViD95yPo+F7DMeg11UGrfZbmIPx8+JlVCnr0QUoRb0L8t?= =?utf-8?q?9BS7K6qRIaoek7CCIDkWWxhaId5c+Eg3A22G8DV+Dgf0ff6ADkuXi/vNxVgk5kfGK?= =?utf-8?q?tZR8hwg8d1CrPh7oqhyuzz3TxCY0cfMmJrToOgUrEEReXmQEazO6eWA3y0Bv3+ytO?= =?utf-8?q?V4kbjqcfupEcl/7MkOdMLFYqQoKEZnfecsVVKtVEHNG+ecIxT75pTDh3ZYcgAnfxn?= =?utf-8?q?+aVIxHE5tbwPD9UMa6m1k0UkbvEhV+42Q2pAGkXR69z5KzC8MP5fWP6ZZHAevq+M8?= =?utf-8?q?kU9QzWAxo1tNr4rOw9rVg8JcZmaQj4sFBvLCiqlBo0g0Q0U1WRoCtDhdm8+0Rydt4?= =?utf-8?q?yKM03117YNa+bh/nta2q/OXR++gqLEdOQQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: ad934820-8b23-42d4-0d72-08da76fb9a4f X-MS-Exchange-CrossTenant-AuthSource: DM5PR11MB1372.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2022 16:00:22.5649 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WXUwv47z9SmtTmAhXs1JaJm4SNaDL04a+0YYcXDYEiTT9/B3rt90EYdy2vulq8U+Xc6Wm8F8IXOUBzaqAEzBuOKdeEx/XRRt7NU9m3g5Dgk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1101MB2075 X-OriginatorOrg: intel.com Subject: [Intel-gfx] [PATCH v3 1/2] drm/i915: Use of BARs names instead of numbers X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jani Nikula , Lucas De Marchi Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Piotr PiĆ³rkowski At the moment, when we refer to some PCI BAR we use the number of this BAR in the code. The meaning of BARs between different platforms may be different. Therefore, in order to organize the code, let's start using defined names instead of numbers. v2: Add lost header in cfg_space.c Signed-off-by: Piotr PiĆ³rkowski Cc: Jani Nikula Cc: Lucas De Marchi Cc: Matt Roper Reviewed-by: Jani Nikula Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/i915/display/intel_lpe_audio.c | 5 +++-- drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 7 ++++--- drivers/gpu/drm/i915/gt/intel_ggtt.c | 9 +++++---- drivers/gpu/drm/i915/gt/intel_gt.c | 3 ++- drivers/gpu/drm/i915/gt/intel_region_lmem.c | 13 ++++++------- drivers/gpu/drm/i915/gvt/cfg_space.c | 5 +++-- drivers/gpu/drm/i915/intel_pci_config.h | 7 +++++++ 7 files changed, 30 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_lpe_audio.c b/drivers/gpu/drm/i915/display/intel_lpe_audio.c index 4970bf146c4a..1e18696aaecf 100644 --- a/drivers/gpu/drm/i915/display/intel_lpe_audio.c +++ b/drivers/gpu/drm/i915/display/intel_lpe_audio.c @@ -73,6 +73,7 @@ #include "i915_drv.h" #include "intel_de.h" #include "intel_lpe_audio.h" +#include "intel_pci_config.h" #define HAS_LPE_AUDIO(dev_priv) ((dev_priv)->audio.lpe.platdev != NULL) @@ -100,9 +101,9 @@ lpe_audio_platdev_create(struct drm_i915_private *dev_priv) rsc[0].flags = IORESOURCE_IRQ; rsc[0].name = "hdmi-lpe-audio-irq"; - rsc[1].start = pci_resource_start(pdev, 0) + + rsc[1].start = pci_resource_start(pdev, GTTMMADR_BAR) + I915_HDMI_LPE_AUDIO_BASE; - rsc[1].end = pci_resource_start(pdev, 0) + + rsc[1].end = pci_resource_start(pdev, GTTMMADR_BAR) + I915_HDMI_LPE_AUDIO_BASE + I915_HDMI_LPE_AUDIO_SIZE - 1; rsc[1].flags = IORESOURCE_MEM; rsc[1].name = "hdmi-lpe-audio-mmio"; diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c index 166d0a4b9e8c..c369cfd185bc 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c @@ -22,6 +22,7 @@ #include "i915_utils.h" #include "i915_vgpu.h" #include "intel_mchbar_regs.h" +#include "intel_pci_config.h" /* * The BIOS typically reserves some of the system's memory for the exclusive @@ -830,7 +831,7 @@ i915_gem_stolen_lmem_setup(struct drm_i915_private *i915, u16 type, /* Use DSM base address instead for stolen memory */ dsm_base = intel_uncore_read64(uncore, GEN12_DSMBASE); if (IS_DG1(uncore->i915)) { - lmem_size = pci_resource_len(pdev, 2); + lmem_size = pci_resource_len(pdev, GEN12_LMEM_BAR); if (WARN_ON(lmem_size < dsm_base)) return ERR_PTR(-ENODEV); } else { @@ -842,11 +843,11 @@ i915_gem_stolen_lmem_setup(struct drm_i915_private *i915, u16 type, } dsm_size = lmem_size - dsm_base; - if (pci_resource_len(pdev, 2) < lmem_size) { + if (pci_resource_len(pdev, GEN12_LMEM_BAR) < lmem_size) { io_start = 0; io_size = 0; } else { - io_start = pci_resource_start(pdev, 2) + dsm_base; + io_start = pci_resource_start(pdev, GEN12_LMEM_BAR) + dsm_base; io_size = dsm_size; } diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c b/drivers/gpu/drm/i915/gt/intel_ggtt.c index 15a915bb4088..8214e07a0f5b 100644 --- a/drivers/gpu/drm/i915/gt/intel_ggtt.c +++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c @@ -16,6 +16,7 @@ #include "intel_ggtt_gmch.h" #include "intel_gt.h" #include "intel_gt_regs.h" +#include "intel_pci_config.h" #include "i915_drv.h" #include "i915_scatterlist.h" #include "i915_utils.h" @@ -869,8 +870,8 @@ static int ggtt_probe_common(struct i915_ggtt *ggtt, u64 size) u32 pte_flags; int ret; - GEM_WARN_ON(pci_resource_len(pdev, 0) != gen6_gttmmadr_size(i915)); - phys_addr = pci_resource_start(pdev, 0) + gen6_gttadr_offset(i915); + GEM_WARN_ON(pci_resource_len(pdev, GTTMMADR_BAR) != gen6_gttmmadr_size(i915)); + phys_addr = pci_resource_start(pdev, GTTMMADR_BAR) + gen6_gttadr_offset(i915); /* * On BXT+/ICL+ writes larger than 64 bit to the GTT pagetable range @@ -930,7 +931,7 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt) u16 snb_gmch_ctl; if (!HAS_LMEM(i915)) { - ggtt->gmadr = pci_resource(pdev, 2); + ggtt->gmadr = pci_resource(pdev, GTT_APERTURE_BAR); ggtt->mappable_end = resource_size(&ggtt->gmadr); } @@ -1084,7 +1085,7 @@ static int gen6_gmch_probe(struct i915_ggtt *ggtt) unsigned int size; u16 snb_gmch_ctl; - ggtt->gmadr = pci_resource(pdev, 2); + ggtt->gmadr = pci_resource(pdev, GTT_APERTURE_BAR); ggtt->mappable_end = resource_size(&ggtt->gmadr); /* diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c b/drivers/gpu/drm/i915/gt/intel_gt.c index f435e06125aa..e4bac2431e41 100644 --- a/drivers/gpu/drm/i915/gt/intel_gt.c +++ b/drivers/gpu/drm/i915/gt/intel_gt.c @@ -26,6 +26,7 @@ #include "intel_gt_requests.h" #include "intel_migrate.h" #include "intel_mocs.h" +#include "intel_pci_config.h" #include "intel_pm.h" #include "intel_rc6.h" #include "intel_renderstate.h" @@ -830,7 +831,7 @@ int intel_gt_probe_all(struct drm_i915_private *i915) unsigned int mmio_bar; int ret; - mmio_bar = GRAPHICS_VER(i915) == 2 ? 1 : 0; + mmio_bar = GRAPHICS_VER(i915) == 2 ? GEN2_GTTMMADR_BAR : GTTMMADR_BAR; phys_addr = pci_resource_start(pdev, mmio_bar); /* diff --git a/drivers/gpu/drm/i915/gt/intel_region_lmem.c b/drivers/gpu/drm/i915/gt/intel_region_lmem.c index aa6aed837194..1e79d3c8b126 100644 --- a/drivers/gpu/drm/i915/gt/intel_region_lmem.c +++ b/drivers/gpu/drm/i915/gt/intel_region_lmem.c @@ -6,6 +6,7 @@ #include "i915_drv.h" #include "i915_reg.h" #include "intel_memory_region.h" +#include "intel_pci_config.h" #include "intel_region_lmem.h" #include "intel_region_ttm.h" #include "gem/i915_gem_lmem.h" @@ -45,7 +46,6 @@ _resize_bar(struct drm_i915_private *i915, int resno, resource_size_t size) drm_info(&i915->drm, "BAR%d resized to %dM\n", resno, 1 << bar_size); } -#define LMEM_BAR_NUM 2 static void i915_resize_lmem_bar(struct drm_i915_private *i915, resource_size_t lmem_size) { struct pci_dev *pdev = to_pci_dev(i915->drm.dev); @@ -56,15 +56,14 @@ static void i915_resize_lmem_bar(struct drm_i915_private *i915, resource_size_t u32 pci_cmd; int i; - current_size = roundup_pow_of_two(pci_resource_len(pdev, LMEM_BAR_NUM)); + current_size = roundup_pow_of_two(pci_resource_len(pdev, GEN12_LMEM_BAR)); if (i915->params.lmem_bar_size) { u32 bar_sizes; rebar_size = i915->params.lmem_bar_size * (resource_size_t)SZ_1M; - bar_sizes = pci_rebar_get_possible_sizes(pdev, - LMEM_BAR_NUM); + bar_sizes = pci_rebar_get_possible_sizes(pdev, GEN12_LMEM_BAR); if (rebar_size == current_size) return; @@ -107,7 +106,7 @@ static void i915_resize_lmem_bar(struct drm_i915_private *i915, resource_size_t pci_write_config_dword(pdev, PCI_COMMAND, pci_cmd & ~PCI_COMMAND_MEMORY); - _resize_bar(i915, LMEM_BAR_NUM, rebar_size); + _resize_bar(i915, GEN12_LMEM_BAR, rebar_size); pci_assign_unassigned_bus_resources(pdev->bus); pci_write_config_dword(pdev, PCI_COMMAND, pci_cmd); @@ -236,8 +235,8 @@ static struct intel_memory_region *setup_lmem(struct intel_gt *gt) mul_u32_u32(i915->params.lmem_size, SZ_1M)); } - io_start = pci_resource_start(pdev, 2); - io_size = min(pci_resource_len(pdev, 2), lmem_size); + io_start = pci_resource_start(pdev, GEN12_LMEM_BAR); + io_size = min(pci_resource_len(pdev, GEN12_LMEM_BAR), lmem_size); if (!io_size) return ERR_PTR(-EIO); diff --git a/drivers/gpu/drm/i915/gvt/cfg_space.c b/drivers/gpu/drm/i915/gvt/cfg_space.c index dad3a6054335..eef3bba8a41b 100644 --- a/drivers/gpu/drm/i915/gvt/cfg_space.c +++ b/drivers/gpu/drm/i915/gvt/cfg_space.c @@ -33,6 +33,7 @@ #include "i915_drv.h" #include "gvt.h" +#include "intel_pci_config.h" enum { INTEL_GVT_PCI_BAR_GTTMMIO = 0, @@ -353,9 +354,9 @@ void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu, memset(vgpu_cfg_space(vgpu) + INTEL_GVT_PCI_OPREGION, 0, 4); vgpu->cfg_space.bar[INTEL_GVT_PCI_BAR_GTTMMIO].size = - pci_resource_len(pdev, 0); + pci_resource_len(pdev, GTTMMADR_BAR); vgpu->cfg_space.bar[INTEL_GVT_PCI_BAR_APERTURE].size = - pci_resource_len(pdev, 2); + pci_resource_len(pdev, GTT_APERTURE_BAR); memset(vgpu_cfg_space(vgpu) + PCI_ROM_ADDRESS, 0, 4); diff --git a/drivers/gpu/drm/i915/intel_pci_config.h b/drivers/gpu/drm/i915/intel_pci_config.h index 12cd9d4f23de..4977a524ce6f 100644 --- a/drivers/gpu/drm/i915/intel_pci_config.h +++ b/drivers/gpu/drm/i915/intel_pci_config.h @@ -6,6 +6,13 @@ #ifndef __INTEL_PCI_CONFIG_H__ #define __INTEL_PCI_CONFIG_H__ +/* PCI BARs */ +#define GTTMMADR_BAR 0 +#define GEN2_GTTMMADR_BAR 1 +#define GFXMEM_BAR 2 +#define GTT_APERTURE_BAR GFXMEM_BAR +#define GEN12_LMEM_BAR GFXMEM_BAR + /* BSM in include/drm/i915_drm.h */ #define MCHBAR_I915 0x44