Commit 5bfcff51 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Extract intel_mmio_bar()

We have the same code to determine the MMIO BAR in
two places. Collect it to a single place.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221005154159.18750-1-ville.syrjala@linux.intel.comReviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
parent 6667d78a
...@@ -880,7 +880,7 @@ int intel_gt_probe_all(struct drm_i915_private *i915) ...@@ -880,7 +880,7 @@ int intel_gt_probe_all(struct drm_i915_private *i915)
unsigned int i; unsigned int i;
int ret; int ret;
mmio_bar = GRAPHICS_VER(i915) == 2 ? GEN2_GTTMMADR_BAR : GTTMMADR_BAR; mmio_bar = intel_mmio_bar(GRAPHICS_VER(i915));
phys_addr = pci_resource_start(pdev, mmio_bar); phys_addr = pci_resource_start(pdev, mmio_bar);
/* /*
......
...@@ -1295,9 +1295,7 @@ bool i915_pci_resource_valid(struct pci_dev *pdev, int bar) ...@@ -1295,9 +1295,7 @@ bool i915_pci_resource_valid(struct pci_dev *pdev, int bar)
static bool intel_mmio_bar_valid(struct pci_dev *pdev, struct intel_device_info *intel_info) static bool intel_mmio_bar_valid(struct pci_dev *pdev, struct intel_device_info *intel_info)
{ {
int gttmmaddr_bar = intel_info->__runtime.graphics.ip.ver == 2 ? GEN2_GTTMMADR_BAR : GTTMMADR_BAR; return i915_pci_resource_valid(pdev, intel_mmio_bar(intel_info->__runtime.graphics.ip.ver));
return i915_pci_resource_valid(pdev, gttmmaddr_bar);
} }
static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
......
...@@ -13,6 +13,14 @@ ...@@ -13,6 +13,14 @@
#define GTT_APERTURE_BAR GFXMEM_BAR #define GTT_APERTURE_BAR GFXMEM_BAR
#define GEN12_LMEM_BAR GFXMEM_BAR #define GEN12_LMEM_BAR GFXMEM_BAR
static inline int intel_mmio_bar(int graphics_ver)
{
switch (graphics_ver) {
case 2: return GEN2_GTTMMADR_BAR;
default: return GTTMMADR_BAR;
}
}
/* BSM in include/drm/i915_drm.h */ /* BSM in include/drm/i915_drm.h */
#define MCHBAR_I915 0x44 #define MCHBAR_I915 0x44
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment