public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Das, Nirmoy" <nirmoy.das@linux.intel.com>
To: Andrzej Hajda <andrzej.hajda@intel.com>,
	"Das, Nirmoy" <nirmoy.das@intel.com>,
	igt-dev@lists.freedesktop.org
Cc: matthew.auld@intel.com
Subject: Re: [igt-dev] [PATCH i-g-t 1/2] lib/i915/intel_memory_region: Add gem_has_smallbar
Date: Tue, 24 Jan 2023 09:01:14 +0100	[thread overview]
Message-ID: <c14c7afa-5a42-9472-216b-5f98a266074f@linux.intel.com> (raw)
In-Reply-To: <ee1a994a-9b72-05d7-fd49-0109b22593df@intel.com>


On 1/23/2023 8:53 PM, Andrzej Hajda wrote:
>
>
> On 23.01.2023 16:45, Das, Nirmoy wrote:
>>
>> On 1/23/2023 4:16 PM, Andrzej Hajda wrote:
>>>
>>>
>>> On 20.01.2023 11:07, Nirmoy Das wrote:
>>>> Add gem_has_smallbar() to detect a device with smallbar.
>>>>
>>>> Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
>>>> ---
>>>>   lib/i915/intel_memory_region.c | 32 ++++++++++++++++++++++++++++++++
>>>>   lib/i915/intel_memory_region.h |  1 +
>>>>   2 files changed, 33 insertions(+)
>>>>
>>>> diff --git a/lib/i915/intel_memory_region.c 
>>>> b/lib/i915/intel_memory_region.c
>>>> index 84e1bceb3..655720819 100644
>>>> --- a/lib/i915/intel_memory_region.c
>>>> +++ b/lib/i915/intel_memory_region.c
>>>> @@ -183,6 +183,38 @@ bool gem_has_lmem(int fd)
>>>>       return gem_get_lmem_region_count(fd) > 0;
>>>>   }
>>>>   +/**
>>>> + * gem_has_smallbar:
>>>> + * @fd: open i915 drm file descriptor
>>>> + *
>>>> + * Helper function to check if the device comes with small-bar.
>>>> + *
>>>> + * Returns: True if at least one lmem region was found.
>>>> + */
>>>> +bool gem_has_smallbar(int fd)
>>>> +{
>>>> +    struct drm_i915_query_memory_regions *info;
>>>> +    struct drm_i915_memory_region_info *rf;
>>>> +    bool ret = false;
>>>> +
>>>> +    info = gem_get_query_memory_regions(fd);
>>>> +    igt_assert(info);
>>>> +
>>>> +    for (int i = 0; i < info->num_regions; i++) {
>>>> +        rf = &info->regions[i];
>>>> +        if (rf->region.memory_class == I915_MEMORY_CLASS_DEVICE) {
>>>> +            if (rf->probed_size > rf->probed_cpu_visible_size) {
>>>> +                ret = true;
>>>> +                break;
>>>> +            }
>>>> +        }
>>>> +    }
>>>> +    free(info);
>>>
>>> Why not for_each_memory_region ?
>>
>>
>> No particular reason, it is inspired by existing code from the same 
>> file.  for_each_memory_region() though calls into 
>> gem_get_query_memory_regions() eventually.
>
> I though it could be shorter, sth like:
> bool gem_has_smallbar(int fd)
> {
>     bool ret;
>
>     for_each_memory_region(r, fd)
>         if (r->ci.memory_class == I915_MEMORY_CLASS_DEVICE && r->size 
> > r->cpu_size)
>             ret = true;
>     return ret;
> }
>
> Apparently 'break' leaks memory, so it is not so perfect :)
> Up to you.
>

Looks good but because you r-b this version, lazy me will take it 
without re-spinning it :)

> Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>


Thanks, Andrzej.


Nirmoy

>
>
> Regards
> Andrzej
>
>>
>>
>> Regards,
>>
>> Nirmoy
>>
>>>
>>> Regards
>>> Andrzej
>>>
>>>> +
>>>> +    return ret;
>>>> +}
>>>> +
>>>> +
>>>>   /* A version of gem_create_in_memory_region_list which can be 
>>>> allowed to
>>>>      fail so that the object creation can be retried */
>>>>   int __gem_create_in_memory_region_list(int fd, uint32_t *handle, 
>>>> uint64_t *size, uint32_t flags,
>>>> diff --git a/lib/i915/intel_memory_region.h 
>>>> b/lib/i915/intel_memory_region.h
>>>> index 425bda0ec..9e24bd8fb 100644
>>>> --- a/lib/i915/intel_memory_region.h
>>>> +++ b/lib/i915/intel_memory_region.h
>>>> @@ -62,6 +62,7 @@ struct drm_i915_query_memory_regions 
>>>> *gem_get_query_memory_regions(int fd);
>>>>   unsigned int gem_get_lmem_region_count(int fd);
>>>>     bool gem_has_lmem(int fd);
>>>> +bool gem_has_smallbar(int fd);
>>>>     int __gem_create_in_memory_region_list(int fd, uint32_t 
>>>> *handle, uint64_t *size, uint32_t flags,
>>>>                          const struct 
>>>> drm_i915_gem_memory_class_instance *mem_regions,
>>>
>

  reply	other threads:[~2023-01-24  8:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 10:07 [igt-dev] [PATCH i-g-t 1/2] lib/i915/intel_memory_region: Add gem_has_smallbar Nirmoy Das
2023-01-20 10:07 ` [igt-dev] [PATCH i-g-t 2/2] test/i915/gem_eio: Skip suspend test on smallbar machine Nirmoy Das
2023-01-20 15:45   ` Matthew Auld
2023-01-20 19:38     ` Das, Nirmoy
2023-01-20 10:14 ` [igt-dev] [PATCH i-g-t 1/2] lib/i915/intel_memory_region: Add gem_has_smallbar Das, Nirmoy
2023-01-20 11:30 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/2] " Patchwork
2023-01-23 11:56 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] lib/i915/intel_memory_region: Add gem_has_smallbar (rev2) Patchwork
2023-01-23 15:16 ` [igt-dev] [PATCH i-g-t 1/2] lib/i915/intel_memory_region: Add gem_has_smallbar Andrzej Hajda
2023-01-23 15:45   ` Das, Nirmoy
2023-01-23 19:53     ` Andrzej Hajda
2023-01-24  8:01       ` Das, Nirmoy [this message]
2023-01-24  1:23 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/2] lib/i915/intel_memory_region: Add gem_has_smallbar (rev2) Patchwork

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=c14c7afa-5a42-9472-216b-5f98a266074f@linux.intel.com \
    --to=nirmoy.das@linux.intel.com \
    --cc=andrzej.hajda@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=nirmoy.das@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox