[Intel-gfx] [PATCH v2 1/8] drm/i915: make local-memory probing a GT operation
Chris Wilson
chris at chris-wilson.co.uk
Tue Jan 26 15:16:01 UTC 2021
Quoting Matthew Auld (2021-01-26 15:12:52)
> 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 at linux.intel.com>
> Signed-off-by: Matthew Auld <matthew.auld at intel.com>
> ---
> drivers/gpu/drm/i915/gt/intel_gt.c | 29 +++++++++++++++++++++
> drivers/gpu/drm/i915/gt/intel_gt.h | 1 +
> drivers/gpu/drm/i915/gt/intel_region_lmem.c | 3 ++-
> drivers/gpu/drm/i915/gt/intel_region_lmem.h | 4 +--
> drivers/gpu/drm/i915/i915_drv.c | 4 +++
> drivers/gpu/drm/i915/intel_memory_region.c | 5 ++--
> 6 files changed, 40 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c b/drivers/gpu/drm/i915/gt/intel_gt.c
> index d8e1ab412634..989cd2106b09 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt.c
> +++ b/drivers/gpu/drm/i915/gt/intel_gt.c
> @@ -39,6 +39,35 @@ 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;
> +
> + id = INTEL_REGION_LMEM;
> + if (!HAS_REGION(i915, id))
> + return 0;
> +
> + mem = intel_gt_setup_fake_lmem(gt);
> + if (IS_ERR(mem)) {
> + err = PTR_ERR(mem);
> + drm_err(&i915->drm,
> + "Failed to setup region(%d) type=%d\n",
> + err, INTEL_MEMORY_LOCAL);
> + return err;
> + }
> +
> + mem->id = id;
> + mem->type = INTEL_MEMORY_LOCAL;
> + mem->instance = 0;
> +
> + i915->mm.regions[id] = mem;
> +
> + return 0;
> +}
> +
> void intel_gt_init_hw_early(struct intel_gt *gt, struct i915_ggtt *ggtt)
> {
> gt->ggtt = ggtt;
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt.h b/drivers/gpu/drm/i915/gt/intel_gt.h
> index 9157c7411f60..a17bd8b3195f 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gt.h
> @@ -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);
> diff --git a/drivers/gpu/drm/i915/gt/intel_region_lmem.c b/drivers/gpu/drm/i915/gt/intel_region_lmem.c
> index 28a1d5e1fb92..ad80ff0b935c 100644
> --- a/drivers/gpu/drm/i915/gt/intel_region_lmem.c
> +++ b/drivers/gpu/drm/i915/gt/intel_region_lmem.c
> @@ -102,8 +102,9 @@ 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 = i915->drm.pdev;
> struct intel_memory_region *mem;
> resource_size_t mappable_end;
> diff --git a/drivers/gpu/drm/i915/gt/intel_region_lmem.h b/drivers/gpu/drm/i915/gt/intel_region_lmem.h
> index 8ea43e538dab..a4baa0f077a1 100644
> --- a/drivers/gpu/drm/i915/gt/intel_region_lmem.h
> +++ b/drivers/gpu/drm/i915/gt/intel_region_lmem.h
> @@ -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 */
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 0037b81d991e..7915d0dc7e16 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -574,6 +574,10 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
> if (ret)
> goto err_ggtt;
>
> + ret = intel_gt_probe_lmem(&dev_priv->gt);
> + if (ret)
> + goto err_mem_regions;
> +
> intel_gt_init_hw_early(&dev_priv->gt, &dev_priv->ggtt);
^^^ save typing later
-Chris
More information about the Intel-gfx
mailing list