Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp64031lfe; Fri, 15 Apr 2022 19:41:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZsBn0wXuTKrC+B5Lj1R3DNqtPVO2sbg31fcIFQvei1EZkSmOolCZfNVUR4Q25qvUM3JWs X-Received: by 2002:a17:90b:33c4:b0:1d0:b950:31fe with SMTP id lk4-20020a17090b33c400b001d0b95031femr6568255pjb.162.1650076910125; Fri, 15 Apr 2022 19:41:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650076910; cv=none; d=google.com; s=arc-20160816; b=IEslHBgry4j5BoQhwEaals/V+kfGpqi2dlLsolju5newJw9SHHCdsKOzZVubj4FxJP caIGEhjtn8yvr8LknxFfxifnTBbtC2ZR7XxgPQ09UcjMofiA15qQ3eGJxyVt1vbhn2vN Yqzlrfmu+3rbIBDfeW8CVLm4AAC3w6kZmBSrf46FQGwqMT8dvssfZcpaljis9yl4t0W8 1npoR85+9VqL/CNGCRbD2fSm/YoXdNSqXrnFGwKISkqUhrQP8rAiVOvpPtf6CPXE4cY8 jyADvN+91RZT1qe0GDkY8AZ7RHuPHuTrad2NKD+ytqNQuavbrxR706jH93EcRamlymEv bD0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=F9TJu99ug+aBP2Q39picvuRMofXWHwWbqAPIA69uxvk=; b=AQmUSWU0ParV7B7D3vTtpLvT7Dxy4UCVN2d0H+GE1nw+l6Wtn3slkKTyP520b4QUpj ScccaK60ow7HShD1HiU6IGZX2X9t48wjJK1GZQ3KL00ExdOMhQEKxACW/yQVsxDJBTuH RLShXzYJ1Sm5dI2MxfBS5/7kj/9UyTp8UXhdeu930wzQfD1TY6TmYR73AMYY9PKa4Mu9 Bl/S3VSTlMFtGE3qtnjztdk8p+fiaxx4ZCxw8PfMA4XehK4LtPwd/wmmiSFQJTTicTNQ sFCRG/biantcMKDp3qhvmG4NnDQg2seyREA//gMpVgmM4dsFi1VKQ02pIlfs53OVfm5G 0GZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=c0Qt0ubl; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b7-20020a170902b60700b00153b2d1647dsi2815481pls.133.2022.04.15.19.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:41:50 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=c0Qt0ubl; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2270C3203E1; Fri, 15 Apr 2022 18:49:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243932AbiDNPZy (ORCPT + 99 others); Thu, 14 Apr 2022 11:25:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348224AbiDNOCi (ORCPT ); Thu, 14 Apr 2022 10:02:38 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71EE360F6 for ; Thu, 14 Apr 2022 07:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649944813; x=1681480813; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=aD5+QRaeAVBYOadKFnSr3s0EBewo7xTExRjzcuYYGVc=; b=c0Qt0ubluryIxFIzYeEa8e4CTMph7mHDS/4zmcurmgEEV+I1t0ea3fc4 cjtx5xjRCHY5z/tbJgyEV2clqn7mbVZ4+SbidmeqpcMlA3EcE3KrlZ2ZR 6SEW3rR/g1ri5vgdh4PkEQ7NG4fudEuxzVpifAedjh78G8JE0xdXuXn2p mkxyojlm5by+ivPVRd7BtPIK0Hn71NMAtqhpXH74uPdI/Aj7IvGYErzo3 cGdLFVuNHorS9vmQ38RqgdNJqIFGbA1kuPE4U5VqGqeHf/6OOb/X6gPKf d0L5pa4Zx/ekU4crbbU47sUT27gtaycP7w9k85tKCNV1kMEwo0iZW41NC w==; X-IronPort-AV: E=McAfee;i="6400,9594,10316"; a="349369435" X-IronPort-AV: E=Sophos;i="5.90,259,1643702400"; d="scan'208";a="349369435" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2022 07:00:13 -0700 X-IronPort-AV: E=Sophos;i="5.90,259,1643702400"; d="scan'208";a="803142043" Received: from aviljane-mobl.ger.corp.intel.com (HELO [10.249.254.86]) ([10.249.254.86]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2022 07:00:09 -0700 Message-ID: <8f25394fb9fa71eeec2f6184ea854a391b415d22.camel@linux.intel.com> Subject: Re: [PATCH v2 3/5] drm/i915: ttm move/clear logic fix From: Thomas =?ISO-8859-1?Q?Hellstr=F6m?= To: Robert Beckett , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter Cc: Matthew Auld , linux-kernel@vger.kernel.org Date: Thu, 14 Apr 2022 16:00:06 +0200 In-Reply-To: <20220412151838.1298956-4-bob.beckett@collabora.com> References: <20220412151838.1298956-1-bob.beckett@collabora.com> <20220412151838.1298956-4-bob.beckett@collabora.com> Organization: Intel Sweden AB, Registration Number: 556189-6027 Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-3.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2022-04-12 at 15:18 +0000, Robert Beckett wrote: > ttm managed buffers start off with system resource definitions and > ttm_tt > tracking structures allocated (though unpopulated). > currently this prevents clearing of buffers on first move to desired > placements. > > The desired behaviour is to clear user allocated buffers and any > kernel > buffers that specifically requests it only. > Make the logic match the desired behaviour. > > Signed-off-by: Robert Beckett Reviewed-by: Thomas Hellström > --- >  drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 22 > +++++++++++++++++++- >  1 file changed, 21 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c > b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c > index 9fe8132de3b2..9cf85f91edb5 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c > +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c > @@ -3,6 +3,7 @@ >   * Copyright © 2021 Intel Corporation >   */ >   > +#include "drm/ttm/ttm_tt.h" >  #include >   >  #include "i915_deps.h" > @@ -470,6 +471,25 @@ __i915_ttm_move(struct ttm_buffer_object *bo, >         return fence; >  } >   > +static bool > +allow_clear(struct drm_i915_gem_object *obj, struct ttm_tt *ttm, > struct ttm_resource *dst_mem) > +{ > +       /* never clear stolen */ > +       if (dst_mem->mem_type == I915_PL_STOLEN) > +               return false; > +       /* > +        * we want to clear user buffers and any kernel buffers > +        * that specifically request clearing. > +        */ > +       if (obj->flags & I915_BO_ALLOC_USER) > +               return true; > + > +       if (ttm && ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC) > +               return true; > + > +       return false; > +} > + >  /** >   * i915_ttm_move - The TTM move callback used by i915. >   * @bo: The buffer object. > @@ -520,7 +540,7 @@ int i915_ttm_move(struct ttm_buffer_object *bo, > bool evict, >                 return PTR_ERR(dst_rsgt); >   >         clear = !i915_ttm_cpu_maps_iomem(bo->resource) && (!ttm || > !ttm_tt_is_populated(ttm)); > -       if (!(clear && ttm && !(ttm->page_flags & > TTM_TT_FLAG_ZERO_ALLOC))) { > +       if (!clear || allow_clear(obj, ttm, dst_mem)) { >                 struct i915_deps deps; >   >                 i915_deps_init(&deps, GFP_KERNEL | __GFP_NORETRY | > __GFP_NOWARN);