All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Das, Nirmoy" <nirmoy.das@linux.intel.com>
To: priyanka.dandamudi@intel.com, matthew.auld@intel.com,
	intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 2/2] drm/i915: Add lmem_bar_size modparam
Date: Fri, 17 Jun 2022 13:18:36 +0200	[thread overview]
Message-ID: <f1f66fe2-fa96-834a-d6c4-adca89667786@linux.intel.com> (raw)
In-Reply-To: <878ef90b-0e7e-9e07-1a74-43f6bf096392@linux.intel.com>


On 6/17/2022 9:54 AM, Das, Nirmoy wrote:
>
> On 6/16/2022 5:12 PM, priyanka.dandamudi@intel.com wrote:
>> From: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
>>
>> For testing purposes, support forcing the lmem_bar_size through a new
>> modparam. In CI we only have a limited number of configurations for DG2,
>> but we still need to be reasonably sure we get a usable device (also
>> verifying we report the correct values for things like
>> probed_cpu_visible_size etc) with all the potential lmem_bar sizes that
>> we might expect see in the wild.
>>
>> v2: Update commit message and a minor modification.(Matt)
>>
>> Cc: Matthew Auld <matthew.auld@intel.com>
>> Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
>> ---
>>   drivers/gpu/drm/i915/gt/intel_region_lmem.c |  4 +++
>>   drivers/gpu/drm/i915/i915_driver.c          | 28 ++++++++++++++++++++-
>>   drivers/gpu/drm/i915/i915_params.c          |  2 ++
>>   drivers/gpu/drm/i915/i915_params.h          |  1 +
>>   4 files changed, 34 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gt/intel_region_lmem.c 
>> b/drivers/gpu/drm/i915/gt/intel_region_lmem.c
>> index e9c12e0d6f59..4614c30f878f 100644
>> --- a/drivers/gpu/drm/i915/gt/intel_region_lmem.c
>> +++ b/drivers/gpu/drm/i915/gt/intel_region_lmem.c
>> @@ -111,6 +111,10 @@ static struct intel_memory_region 
>> *setup_lmem(struct intel_gt *gt)
>>           flat_ccs_base = intel_gt_read_register(gt, 
>> XEHPSDV_FLAT_CCS_BASE_ADDR);
>>           flat_ccs_base = (flat_ccs_base >> XEHPSDV_CCS_BASE_SHIFT) * 
>> SZ_64K;
>>   +        /* XXX: Remove this once we have small-bar uapi bits */
>> +        if (i915->params.lmem_bar_size > 0)
>> +            lmem_size = pci_resource_len(pdev, 2);
>> +
>>           /* FIXME: Remove this when we have small-bar enabled */
>>           if (pci_resource_len(pdev, 2) < lmem_size) {
>>               drm_err(&i915->drm, "System requires small-BAR support, 
>> which is currently unsupported on this kernel\n");
>> diff --git a/drivers/gpu/drm/i915/i915_driver.c 
>> b/drivers/gpu/drm/i915/i915_driver.c
>> index 4bdb471cb2e2..b2763b032012 100644
>> --- a/drivers/gpu/drm/i915/i915_driver.c
>> +++ b/drivers/gpu/drm/i915/i915_driver.c
>> @@ -362,8 +362,34 @@ static void i915_resize_lmem_bar(struct 
>> drm_i915_private *i915)
>>       u32 pci_cmd;
>>       int i;
>>   -    if (!rebar_size)
>> +    if (i915->params.lmem_bar_size > 0) {
>> +        u32 lmem_bar_size;
>> +        u32 set_bit;
>> +        u32 rebar;
>> +        u32 msb;
>> +        int k;
>> +
>> +        lmem_bar_size = i915->params.lmem_bar_size;
>> +        rebar = pci_rebar_get_possible_sizes(pdev, LMEM_BAR_NUM);
>> +        msb = __fls(rebar);
>> +
>> +        for (k = msb; k >= 0; k--) {
>> +            set_bit = (1 << k);
>> +
>> +            if (set_bit & rebar) {
>> +                if (set_bit == lmem_bar_size) {
>> +                    rebar_size = 1ULL << (__fls(lmem_bar_size) +
>> +                            BAR_SIZE_SHIFT);
>
>
> We have pci_rebar_bytes_to_size() helper function for this please use 
> that.


What I mean is: these calculations are confusing(at-least for me).


You could do:

if (i915->params.lmem_bar_size)

     rebar_size = i915->params.lmem_bar_size (in bytes)

else

     rebar_size = device lmem_size; --> we need this to make sure we 
only rebar till roundup_pow_of_two(), not max of 
pci_rebar_get_possible_sizes().


Now validate that  pci_rebar_bytes_to_size(rebar_size) is within 
pci_rebar_get_possible_sizes() range.


Regards,

Nirmoy


>
> Nirmoy
>
>> +
>> +                    if (rebar_size == pci_resource_len(pdev, 
>> LMEM_BAR_NUM))
>> +                        return;
>> +                    break;
>> +                }
>> +            }
>> +        }
>> +    } else if (!rebar_size) {
>>           return;
>> +    }
>>         /* Find out if root bus contains 64bit memory addressing */
>>       while (root->parent)
>> diff --git a/drivers/gpu/drm/i915/i915_params.c 
>> b/drivers/gpu/drm/i915/i915_params.c
>> index 701fbc98afa0..6fc475a5db61 100644
>> --- a/drivers/gpu/drm/i915/i915_params.c
>> +++ b/drivers/gpu/drm/i915/i915_params.c
>> @@ -204,6 +204,8 @@ i915_param_named_unsafe(request_timeout_ms, uint, 
>> 0600,
>>     i915_param_named_unsafe(lmem_size, uint, 0400,
>>               "Set the lmem size(in MiB) for each region. (default: 
>> 0, all memory)");
>> +i915_param_named_unsafe(lmem_bar_size, uint, 0400,
>> +            "Set the lmem bar size(in MiB).");
>>     static __always_inline void _print_param(struct drm_printer *p,
>>                        const char *name,
>> diff --git a/drivers/gpu/drm/i915/i915_params.h 
>> b/drivers/gpu/drm/i915/i915_params.h
>> index b5e7ea45d191..2733cb6cfe09 100644
>> --- a/drivers/gpu/drm/i915/i915_params.h
>> +++ b/drivers/gpu/drm/i915/i915_params.h
>> @@ -74,6 +74,7 @@ struct drm_printer;
>>       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) \
>> +    param(unsigned int, lmem_bar_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) \

  reply	other threads:[~2022-06-17 11:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16 15:12 [Intel-gfx] [PATCH 0/2] Add support for LMEM PCIe resizable bar priyanka.dandamudi
2022-06-16 15:12 ` [Intel-gfx] [PATCH 1/2] drm/i915: " priyanka.dandamudi
2022-06-17  8:32   ` Jani Nikula
2022-06-17 18:44     ` Lucas De Marchi
2022-06-17 18:44       ` Lucas De Marchi
2022-06-17 20:32       ` Bjorn Helgaas
2022-06-17 20:32         ` Bjorn Helgaas
2022-06-17 21:27         ` Lucas De Marchi
2022-06-18 15:14           ` Christian König
2022-06-24  4:02             ` Dandamudi, Priyanka
2022-06-24  4:02               ` Dandamudi, Priyanka
2022-06-29  6:00               ` Thomas Hellström (Intel)
2022-06-16 15:12 ` [Intel-gfx] [PATCH 2/2] drm/i915: Add lmem_bar_size modparam priyanka.dandamudi
2022-06-17  7:54   ` Das, Nirmoy
2022-06-17 11:18     ` Das, Nirmoy [this message]
2022-06-16 19:51 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for Add support for LMEM PCIe resizable bar Patchwork
2022-06-16 20:10 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-06-17  4:02 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2022-06-15  5:43 [Intel-gfx] [PATCH 0/2] " priyanka.dandamudi
2022-06-15  5:43 ` [Intel-gfx] [PATCH 2/2] drm/i915: Add lmem_bar_size modparam priyanka.dandamudi
2022-06-15 10:17   ` Matthew Auld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f1f66fe2-fa96-834a-d6c4-adca89667786@linux.intel.com \
    --to=nirmoy.das@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=priyanka.dandamudi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.