Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5278922pxb; Wed, 19 Jan 2022 15:07:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfzjsGqhv2xEC72o8Q6fIVatsmteWTS6WtuYkhac0eRNEjFowHAdc+SM6mUNy3pjFth334 X-Received: by 2002:a17:902:a616:b0:14a:c625:6a7a with SMTP id u22-20020a170902a61600b0014ac6256a7amr14473933plq.108.1642633679709; Wed, 19 Jan 2022 15:07:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642633679; cv=none; d=google.com; s=arc-20160816; b=jugr+rjQiy9h5wspSwjuQLX4ANin16NTx3fmD+2Lkk4Pggn6NacLhpdAD945Cq9pzS qhf8YTga06j0s302FgqtD+dnXESU4Ty+DoLtXG+lBVbl6cGp+ggTpMV3z+grBuSQG/OQ xVyE/ICG5TDlaO6c1G3hXRCmu+IuN6QudQN56N0h9rUT4Bb4KEIJiIg5G/QaZpFKN8rb EVV+4Bt0L4f2fMmcwlbgBogyGCZJcXegz6oWJloNBvln7Gj9h3MT9g/BHvohtuYEiaiz p+CXqJuBk3soQq5coLdHGaPZo/sQuVnUzJ9t3p+f9x9nMO35kDDRUmhEzqvOcUNwGgPd u+9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=qKFSdChxw+Vw5Im5CtvbkbTyy/wW2P6TCDfvbAq/hT0=; b=c4tq/uoLrwwMMpUMkOyowdRO7npwI/e9t9I3dqzPbIe9PAIC4d2bgNcSTWdWYQmsHY 736A3rRcLlZ4EYPV+Z1OKq4VAfbt5AQUd3CHxjKHMHQPz0FjB7svrGmJnAoAWDuLR7ll eusOj7muxS/yiHu6yAcDOXB+SIlqEtA8/ok7xc/p6XovhjSRXIXVqDnH5vb5Gm1TVCnt L9Bl2A7WgQ1aKhQ6yYDOkaB8hwqKrXPkAEFHlJ6nE75AzWySw020Ikjsmb/nwdG+a5JX oqgUVijMk+k5yZqCzBtQQKOy/1/L3Cc3gGwk/ycr9MtSzgZ0XiBVH2JSQz5j7+LELNa+ HINQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mAXLwBis; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p24si936163plo.435.2022.01.19.15.07.48; Wed, 19 Jan 2022 15:07:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mAXLwBis; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344452AbiARIgt (ORCPT + 99 others); Tue, 18 Jan 2022 03:36:49 -0500 Received: from mga02.intel.com ([134.134.136.20]:35566 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343864AbiARIgs (ORCPT ); Tue, 18 Jan 2022 03:36:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642495008; x=1674031008; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=bEHey9QupRjV9zwrkI/FK565olCk7HBpauULY2Z1kUs=; b=mAXLwBisrvclJQFYDU+QiI8cNgQg+oYc6k/A6KsiWokbcQnOny+H8AwE 17nudHQ4WAoKgFky/6GkHtipAbbzgehY4DeT8V0m0QMLMizq3kLEtzwrM L+lj7WiOxyhZ2v8VylH5AfL1vg16VfPQP7nJUAYNjOpfyn71lHffg+I/8 fV5nDdYIXYXFOGHxwioglE8IOvI6bNs0Ya5OrmMS1AQVcPhqqJ76YGJTJ 4BD11mqkbUgp1WWXCS39pva8APMtHjzYP4mdlG2j0A1jXFLQFeibbfqoU ngx/x8wG3qdeaW7m/Ui9IPMdz2SuA7mWrLivKZf07V9wFgQt5VvUE1Bqr Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="232126212" X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="232126212" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2022 00:36:48 -0800 X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="517682356" Received: from ramaling-i9x.iind.intel.com (HELO intel.com) ([10.203.144.108]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2022 00:36:45 -0800 Date: Tue, 18 Jan 2022 14:06:40 +0530 From: Ramalingam C To: Robert Beckett Cc: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH 3/4] drm/i915: add gtt misalignment test Message-ID: <20220118083638.GA2476@intel.com> References: <20220111180238.1370631-1-bob.beckett@collabora.com> <20220111180238.1370631-4-bob.beckett@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220111180238.1370631-4-bob.beckett@collabora.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-01-11 at 18:02:37 +0000, Robert Beckett wrote: > add test to check handling of misaligned offsets and sizes Bob, This needs the rebase. I have rebased the other three patches of the series.. Meanwhile i will review the changes. Ram. > > Signed-off-by: Robert Beckett > --- > drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 130 ++++++++++++++++++ > 1 file changed, 130 insertions(+) > > diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c > index fea031b4ec4f..28de0b333835 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 > #include > > #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" > @@ -1066,6 +1068,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->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 */ > + expected_vma_size = round_up(size, I915_GTT_PAGE_SIZE_64K); > + expected_node_size = round_up(size, I915_GTT_PAGE_SIZE_2M); > + } > + > + if (vma->size != expected_vma_size || vma->node.size != expected_node_size) { > + err = i915_vma_unbind(vma); > + err = -EBADSLT; > + goto err_put; > + } > + > + err = i915_vma_unbind(vma); > + if (err) > + goto err_put; > + > + GEM_BUG_ON(drm_mm_node_allocated(&vma->node)); > + > +err_put: > + i915_gem_object_put(obj); > + cleanup_freed_objects(vm->i915); > + return err; > +} > + > +static int misaligned_pin(struct i915_address_space *vm, > + u64 hole_start, u64 hole_end, > + unsigned long end_time) > +{ > + struct intel_memory_region *mr; > + enum intel_region_id id; > + unsigned long flags = PIN_OFFSET_FIXED | PIN_USER; > + int err = 0; > + u64 hole_size = hole_end - hole_start; > + > + if (i915_is_ggtt(vm)) > + flags |= PIN_GLOBAL; > + > + for_each_memory_region(mr, vm->i915, id) { > + u64 min_alignment = i915_vm_min_alignment(vm, id); > + u64 size = min_alignment; > + u64 addr = round_up(hole_start + (hole_size / 2), min_alignment); > + > + /* we can't test < 4k alignment due to flags being encoded in lower bits */ > + if (min_alignment != I915_GTT_PAGE_SIZE_4K) { > + err = misaligned_case(vm, mr, addr + (min_alignment / 2), size, flags); > + /* misaligned should error with -EINVAL*/ > + if (!err) > + err = -EBADSLT; > + if (err != -EINVAL) > + return err; > + } > + > + /* test for vma->size expansion to min page size */ > + err = misaligned_case(vm, mr, addr, PAGE_SIZE, flags); > + if (min_alignment > hole_size) { > + if (!err) > + err = -EBADSLT; > + else if (err == -ENOSPC) > + err = 0; > + } > + if (err) > + return err; > + > + /* test for intermediate size not expanding vma->size for large alignments */ > + err = misaligned_case(vm, mr, addr, size / 2, flags); > + if (min_alignment > hole_size) { > + if (!err) > + err = -EBADSLT; > + else if (err == -ENOSPC) > + err = 0; > + } > + if (err) > + return err; > + } > + > + return 0; > +} > + > static int exercise_ppgtt(struct drm_i915_private *dev_priv, > int (*func)(struct i915_address_space *vm, > u64 hole_start, u64 hole_end, > @@ -1135,6 +1251,12 @@ static int igt_ppgtt_shrink_boom(void *arg) > return exercise_ppgtt(arg, shrink_boom); > } > > +static int igt_ppgtt_misaligned_pin(void *arg) > +{ > + return exercise_ppgtt(arg, misaligned_pin); > +} > + > + > static int sort_holes(void *priv, const struct list_head *A, > const struct list_head *B) > { > @@ -1207,6 +1329,12 @@ static int igt_ggtt_lowlevel(void *arg) > return exercise_ggtt(arg, lowlevel_hole); > } > > +static int igt_ggtt_misaligned_pin(void *arg) > +{ > + return exercise_ggtt(arg, misaligned_pin); > +} > + > + > static int igt_ggtt_page(void *arg) > { > const unsigned int count = PAGE_SIZE/sizeof(u32); > @@ -2137,12 +2265,14 @@ int i915_gem_gtt_live_selftests(struct drm_i915_private *i915) > SUBTEST(igt_ppgtt_fill), > SUBTEST(igt_ppgtt_shrink), > SUBTEST(igt_ppgtt_shrink_boom), > + SUBTEST(igt_ppgtt_misaligned_pin), > SUBTEST(igt_ggtt_lowlevel), > SUBTEST(igt_ggtt_drunk), > SUBTEST(igt_ggtt_walk), > SUBTEST(igt_ggtt_pot), > SUBTEST(igt_ggtt_fill), > SUBTEST(igt_ggtt_page), > + SUBTEST(igt_ggtt_misaligned_pin), > SUBTEST(igt_cs_tlb), > }; > > -- > 2.25.1 >