[Intel-gfx] [PATCH v5 4/5] drm/i915: add gtt misalignment test

Robert Beckett bob.beckett at collabora.com
Wed Jan 26 17:22:51 UTC 2022



On 26/01/2022 14:05, Thomas Hellström (Intel) wrote:
> 
> On 1/25/22 20:35, Robert Beckett wrote:
>> add test to check handling of misaligned offsets and sizes
>>
>> v4:
>>     * remove spurious blank lines
>>     * explicitly cast intel_region_id to intel_memory_type in 
>> misaligned_pin
>> Reported-by: kernel test robot <lkp at intel.com>
>>
>> Signed-off-by: Robert Beckett <bob.beckett at collabora.com>
>> ---
>>   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 128 ++++++++++++++++++
>>   1 file changed, 128 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c 
>> b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
>> index b80788a2b7f9..f082b5ff3b5e 100644
>> --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
>> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
>> @@ -22,10 +22,12 @@
>>    *
>>    */
>> +#include "gt/intel_gtt.h"
>>   #include <linux/list_sort.h>
>>   #include <linux/prime_numbers.h>
>>   #include "gem/i915_gem_context.h"
>> +#include "gem/i915_gem_region.h"
>>   #include "gem/selftests/mock_context.h"
>>   #include "gt/intel_context.h"
>>   #include "gt/intel_gpu_commands.h"
>> @@ -1067,6 +1069,120 @@ static int shrink_boom(struct 
>> i915_address_space *vm,
>>       return err;
>>   }
>> +static int misaligned_case(struct i915_address_space *vm, struct 
>> intel_memory_region *mr,
>> +               u64 addr, u64 size, unsigned long flags)
>> +{
>> +    struct drm_i915_gem_object *obj;
>> +    struct i915_vma *vma;
>> +    int err = 0;
>> +    u64 expected_vma_size, expected_node_size;
>> +
>> +    obj = i915_gem_object_create_region(mr, size, 0, 0);
>> +    if (IS_ERR(obj))
>> +        return PTR_ERR(obj);
>> +
>> +    vma = i915_vma_instance(obj, vm, NULL);
>> +    if (IS_ERR(vma)) {
>> +        err = PTR_ERR(vma);
>> +        goto err_put;
>> +    }
>> +
>> +    err = i915_vma_pin(vma, 0, 0, addr | flags);
>> +    if (err)
>> +        goto err_put;
>> +    i915_vma_unpin(vma);
>> +
>> +    if (!drm_mm_node_allocated(&vma->node)) {
>> +        err = -EINVAL;
>> +        goto err_put;
>> +    }
>> +
>> +    if (i915_vma_misplaced(vma, 0, 0, addr | flags)) {
>> +        err = -EINVAL;
>> +        goto err_put;
>> +    }
>> +
>> +    expected_vma_size = round_up(size, 1 << 
>> (ffs(vma->resource->page_sizes_gtt) - 1));
>> +    expected_node_size = expected_vma_size;
>> +
>> +    if (IS_DG2(vm->i915) && i915_gem_object_is_lmem(obj)) {
>> +        /* dg2 should expand lmem node to 2MB */
> 
> Should this test be NEEDS_COMPACT_PT()?
> 
> Otherwise LGTM. Reviewed-by: Thomas Hellström 
> <thomas.hellstrom at linux.intel.com>
Thanks. Good catch, forgot to retrofit the new macro here.
> 
> 


More information about the dri-devel mailing list