drm/i915: make local-memory probing a GT operation
Device local memory is very much a GT thing, therefore it should be the responsibility of the GT to setup the device local memory region. Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Signed-off-by: Matthew Auld <matthew.auld@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Link: https://patchwork.freedesktop.org/patch/msgid/20210127131417.393872-1-matthew.auld@intel.com [danvet: Rebase conflict.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Родитель
2913fa4d7d
Коммит
2dfcc7f4e9
|
@ -39,6 +39,38 @@ void intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915)
|
|||
intel_uc_init_early(>->uc);
|
||||
}
|
||||
|
||||
int intel_gt_probe_lmem(struct intel_gt *gt)
|
||||
{
|
||||
struct drm_i915_private *i915 = gt->i915;
|
||||
struct intel_memory_region *mem;
|
||||
int id;
|
||||
int err;
|
||||
|
||||
mem = intel_gt_setup_fake_lmem(gt);
|
||||
if (IS_ERR(mem)) {
|
||||
err = PTR_ERR(mem);
|
||||
if (err == -ENODEV)
|
||||
return 0;
|
||||
|
||||
drm_err(&i915->drm,
|
||||
"Failed to setup region(%d) type=%d\n",
|
||||
err, INTEL_MEMORY_LOCAL);
|
||||
return err;
|
||||
}
|
||||
|
||||
id = INTEL_REGION_LMEM;
|
||||
|
||||
mem->id = id;
|
||||
mem->type = INTEL_MEMORY_LOCAL;
|
||||
mem->instance = 0;
|
||||
|
||||
GEM_BUG_ON(!HAS_REGION(i915, id));
|
||||
GEM_BUG_ON(i915->mm.regions[id]);
|
||||
i915->mm.regions[id] = mem;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void intel_gt_init_hw_early(struct intel_gt *gt, struct i915_ggtt *ggtt)
|
||||
{
|
||||
gt->ggtt = ggtt;
|
||||
|
|
|
@ -36,6 +36,7 @@ static inline struct intel_gt *huc_to_gt(struct intel_huc *huc)
|
|||
|
||||
void intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915);
|
||||
void intel_gt_init_hw_early(struct intel_gt *gt, struct i915_ggtt *ggtt);
|
||||
int intel_gt_probe_lmem(struct intel_gt *gt);
|
||||
int intel_gt_init_mmio(struct intel_gt *gt);
|
||||
int __must_check intel_gt_init_hw(struct intel_gt *gt);
|
||||
int intel_gt_init(struct intel_gt *gt);
|
||||
|
|
|
@ -102,16 +102,22 @@ static const struct intel_memory_region_ops intel_region_lmem_ops = {
|
|||
};
|
||||
|
||||
struct intel_memory_region *
|
||||
intel_setup_fake_lmem(struct drm_i915_private *i915)
|
||||
intel_gt_setup_fake_lmem(struct intel_gt *gt)
|
||||
{
|
||||
struct drm_i915_private *i915 = gt->i915;
|
||||
struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
|
||||
struct intel_memory_region *mem;
|
||||
resource_size_t mappable_end;
|
||||
resource_size_t io_start;
|
||||
resource_size_t start;
|
||||
|
||||
if (!HAS_LMEM(i915))
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
if (!i915->params.fake_lmem_start)
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
GEM_BUG_ON(i915_ggtt_has_aperture(&i915->ggtt));
|
||||
GEM_BUG_ON(!i915->params.fake_lmem_start);
|
||||
|
||||
/* Your mappable aperture belongs to me now! */
|
||||
mappable_end = pci_resource_len(pdev, 2);
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#ifndef __INTEL_REGION_LMEM_H
|
||||
#define __INTEL_REGION_LMEM_H
|
||||
|
||||
struct drm_i915_private;
|
||||
struct intel_gt;
|
||||
|
||||
struct intel_memory_region *
|
||||
intel_setup_fake_lmem(struct drm_i915_private *i915);
|
||||
intel_gt_setup_fake_lmem(struct intel_gt *gt);
|
||||
|
||||
#endif /* !__INTEL_REGION_LMEM_H */
|
||||
|
|
|
@ -566,6 +566,10 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
|
|||
|
||||
intel_gt_init_hw_early(&dev_priv->gt, &dev_priv->ggtt);
|
||||
|
||||
ret = intel_gt_probe_lmem(&dev_priv->gt);
|
||||
if (ret)
|
||||
goto err_mem_regions;
|
||||
|
||||
ret = i915_ggtt_enable_hw(dev_priv);
|
||||
if (ret) {
|
||||
drm_err(&dev_priv->drm, "failed to enable GGTT\n");
|
||||
|
|
|
@ -258,9 +258,8 @@ int intel_memory_regions_hw_probe(struct drm_i915_private *i915)
|
|||
case INTEL_MEMORY_STOLEN:
|
||||
mem = i915_gem_stolen_setup(i915);
|
||||
break;
|
||||
case INTEL_MEMORY_LOCAL:
|
||||
mem = intel_setup_fake_lmem(i915);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IS_ERR(mem)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче