diff mbox series

[CI,1/1] drm/i915: add lmem_size modparam

Message ID 20220324143123.348590-2-matthew.auld@intel.com (mailing list archive)
State New, archived
Headers show
Series lmem_size modparam | expand

Commit Message

Matthew Auld March 24, 2022, 2:31 p.m. UTC
From: CQ Tang <cq.tang@intel.com>

lmem_size is used to limit the amount of lmem. Default is to use
hardware available lmem size, when setting this modpraram which is in MB
unit.

Signed-off-by: CQ Tang <cq.tang@intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Nirmoy Das <nirmoy.das@linux.intel.com>
---
 drivers/gpu/drm/i915/gt/intel_region_lmem.c | 4 ++++
 drivers/gpu/drm/i915/i915_params.c          | 3 +++
 drivers/gpu/drm/i915/i915_params.h          | 1 +
 3 files changed, 8 insertions(+)

Comments

Nirmoy Das March 24, 2022, 3:51 p.m. UTC | #1
LGTM Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>

On 3/24/2022 3:31 PM, Matthew Auld wrote:
> From: CQ Tang <cq.tang@intel.com>
>
> lmem_size is used to limit the amount of lmem. Default is to use
> hardware available lmem size, when setting this modpraram which is in MB
> unit.
>
> Signed-off-by: CQ Tang <cq.tang@intel.com>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Nirmoy Das <nirmoy.das@linux.intel.com>
> ---
>   drivers/gpu/drm/i915/gt/intel_region_lmem.c | 4 ++++
>   drivers/gpu/drm/i915/i915_params.c          | 3 +++
>   drivers/gpu/drm/i915/i915_params.h          | 1 +
>   3 files changed, 8 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_region_lmem.c b/drivers/gpu/drm/i915/gt/intel_region_lmem.c
> index 783d81072c3b..f5111c0a0060 100644
> --- a/drivers/gpu/drm/i915/gt/intel_region_lmem.c
> +++ b/drivers/gpu/drm/i915/gt/intel_region_lmem.c
> @@ -123,6 +123,10 @@ static struct intel_memory_region *setup_lmem(struct intel_gt *gt)
>   		lmem_size = intel_uncore_read64(&i915->uncore, GEN12_GSMBASE);
>   	}
>   
> +	if (i915->params.lmem_size > 0) {
> +		lmem_size = min_t(resource_size_t, lmem_size,
> +				  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);
> diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c
> index 5ad071e09301..701fbc98afa0 100644
> --- a/drivers/gpu/drm/i915/i915_params.c
> +++ b/drivers/gpu/drm/i915/i915_params.c
> @@ -202,6 +202,9 @@ i915_param_named_unsafe(request_timeout_ms, uint, 0600,
>   			"Default request/fence/batch buffer expiration timeout.");
>   #endif
>   
> +i915_param_named_unsafe(lmem_size, uint, 0400,
> +			"Set the lmem size(in MiB) for each region. (default: 0, all memory)");
> +
>   static __always_inline void _print_param(struct drm_printer *p,
>   					 const char *name,
>   					 const char *type,
> diff --git a/drivers/gpu/drm/i915/i915_params.h b/drivers/gpu/drm/i915/i915_params.h
> index c779a6f85c7e..b5e7ea45d191 100644
> --- a/drivers/gpu/drm/i915/i915_params.h
> +++ b/drivers/gpu/drm/i915/i915_params.h
> @@ -73,6 +73,7 @@ struct drm_printer;
>   	param(int, enable_dpcd_backlight, -1, 0600) \
>   	param(char *, force_probe, CONFIG_DRM_I915_FORCE_PROBE, 0400) \
>   	param(unsigned int, request_timeout_ms, CONFIG_DRM_I915_REQUEST_TIMEOUT, CONFIG_DRM_I915_REQUEST_TIMEOUT ? 0600 : 0) \
> +	param(unsigned int, lmem_size, 0, 0400) \
>   	/* leave bools at the end to not create holes */ \
>   	param(bool, enable_hangcheck, true, 0600) \
>   	param(bool, load_detect_test, false, 0600) \
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/intel_region_lmem.c b/drivers/gpu/drm/i915/gt/intel_region_lmem.c
index 783d81072c3b..f5111c0a0060 100644
--- a/drivers/gpu/drm/i915/gt/intel_region_lmem.c
+++ b/drivers/gpu/drm/i915/gt/intel_region_lmem.c
@@ -123,6 +123,10 @@  static struct intel_memory_region *setup_lmem(struct intel_gt *gt)
 		lmem_size = intel_uncore_read64(&i915->uncore, GEN12_GSMBASE);
 	}
 
+	if (i915->params.lmem_size > 0) {
+		lmem_size = min_t(resource_size_t, lmem_size,
+				  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);
diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c
index 5ad071e09301..701fbc98afa0 100644
--- a/drivers/gpu/drm/i915/i915_params.c
+++ b/drivers/gpu/drm/i915/i915_params.c
@@ -202,6 +202,9 @@  i915_param_named_unsafe(request_timeout_ms, uint, 0600,
 			"Default request/fence/batch buffer expiration timeout.");
 #endif
 
+i915_param_named_unsafe(lmem_size, uint, 0400,
+			"Set the lmem size(in MiB) for each region. (default: 0, all memory)");
+
 static __always_inline void _print_param(struct drm_printer *p,
 					 const char *name,
 					 const char *type,
diff --git a/drivers/gpu/drm/i915/i915_params.h b/drivers/gpu/drm/i915/i915_params.h
index c779a6f85c7e..b5e7ea45d191 100644
--- a/drivers/gpu/drm/i915/i915_params.h
+++ b/drivers/gpu/drm/i915/i915_params.h
@@ -73,6 +73,7 @@  struct drm_printer;
 	param(int, enable_dpcd_backlight, -1, 0600) \
 	param(char *, force_probe, CONFIG_DRM_I915_FORCE_PROBE, 0400) \
 	param(unsigned int, request_timeout_ms, CONFIG_DRM_I915_REQUEST_TIMEOUT, CONFIG_DRM_I915_REQUEST_TIMEOUT ? 0600 : 0) \
+	param(unsigned int, lmem_size, 0, 0400) \
 	/* leave bools at the end to not create holes */ \
 	param(bool, enable_hangcheck, true, 0600) \
 	param(bool, load_detect_test, false, 0600) \