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: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221005154159.18750-1-ville.syrjala@linux.intel.com
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
This commit is contained in:
Ville Syrjälä 2022-10-05 18:41:57 +03:00
parent 6667d78a11
commit 5bfcff516c
3 changed files with 10 additions and 4 deletions

View file

@ -880,7 +880,7 @@ int intel_gt_probe_all(struct drm_i915_private *i915)
unsigned int i;
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);
/*

View file

@ -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)
{
int gttmmaddr_bar = intel_info->__runtime.graphics.ip.ver == 2 ? GEN2_GTTMMADR_BAR : GTTMMADR_BAR;
return i915_pci_resource_valid(pdev, gttmmaddr_bar);
return i915_pci_resource_valid(pdev, intel_mmio_bar(intel_info->__runtime.graphics.ip.ver));
}
static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

View file

@ -13,6 +13,14 @@
#define GTT_APERTURE_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 */
#define MCHBAR_I915 0x44