Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp976891pxp; Wed, 16 Mar 2022 23:13:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKkeLCtJWhGrLgoX+DtaKYHmV8RYrLSmZ1TW5MU7k8Dr7vmygG5Uppj5rw2Kd5PGijda9y X-Received: by 2002:a05:6a00:a8f:b0:4e1:2619:11a2 with SMTP id b15-20020a056a000a8f00b004e1261911a2mr2846981pfl.53.1647497622185; Wed, 16 Mar 2022 23:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647497622; cv=none; d=google.com; s=arc-20160816; b=WG1UUGogKhkX7vYkXbfTQfMSp3O0wRZFKkm2wozXRHjioDIBaY/iVSDcEMtkpIV5yK kleUkmePc0H8RQIYJue9YjcchMzfHLuEbMnjY+TGftFkSOK6owmjIULS8Uar8SlNwMlR ug/FROnX02r+vDSt01uaZPdvX4oaZo+a7yXGj7okCxz5EP/7wMokBZAikUKwjzl2jz3G CRRvQK5Idxrn8s+YTE6Kz1nh4C5jwtAKcdexmq0mXcfQjD9OshVMobQJuFEMEASXDzeZ tB5H7B1mv8Kejf9zKlBZvc5ts4AREgv4QHFMPdKcxqq1fnS6zFZcfF0Ihml3wJleJ0Ij jMfQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6M5rAx4sxtQsjC08Nv0lxFnXAgE4yYPrWBgXCByieTs=; b=KcvGvdAi7zh9OGI68CYIfcPEoeWbLVl0Uj5alCQ2Y0X6qiXC0srqollsptkMtb3yM1 tyLgHyKJbmw3vJGceLBL883oWiuqwLRhKwJRw+dwBgVuozX6Mv6y87bAyCq9wuBpBWw+ DdipXSuOQRnDB3pZ3YnyS9XqJQKDAOgMyTgrbfZKggKQ7pTjGi0+fr8cixgcUhR4Ncze HfgKW6Pjziut1zq1v9ndxGdiCa9euGP+4bD2ZaRqF64KIdzePLUHQqFxYPc+WgA224Ma meVzdOPvtHI77icNj4Ifn2wjzXX1EEHSBzqrimnOfDp8qsVkEsv0TqDjNCDgUroK6l2S 3CFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=KWQuk6MP; 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=collabora.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o17-20020a639a11000000b003817672f2d4si1292510pge.316.2022.03.16.23.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 23:13:42 -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=@collabora.com header.s=mail header.b=KWQuk6MP; 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=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0178723D580; Wed, 16 Mar 2022 21:56:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350940AbiCOSGk (ORCPT + 99 others); Tue, 15 Mar 2022 14:06:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350905AbiCOSGY (ORCPT ); Tue, 15 Mar 2022 14:06:24 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 056FD3668D for ; Tue, 15 Mar 2022 11:05:11 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: bbeckett) with ESMTPSA id AFB961F430BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1647367509; bh=sv/7BhTnXU6OwO9t2oOn1ya2zRweojAD5yK19Y9oJaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KWQuk6MPHbAKO5FzGNeyNlRjlMXMJx9ygW1wM4ODTJQnqvFAtUVmAA77md3vmPiAZ 4Jz9gf2jApf32RWcb+GXbHeDnWrWc40dQOoh95XPSJYoollakbeM/cZ68+iboqTOWA Jq95cjGryzWLuSO7ry1sP+CIDurxFOIQ4V4HA7xqdgN3eCL3992dgdQ2a+hIJaW5/X GEFfzReBsMP4DwwgJYTVtBTfdkDSGVuuWKTMkCUE8lOl+s7tDCjbM604pjE3GvfauU JKwc+O/shZgc0xZJSdu644hZgIk1KJBR/wWkOv01KLptaAkFPysfHyPBuMWqpEEOgI 979RtP1a6pU1Q== From: Robert Beckett To: intel-gfx@lists.freedesktop.org, Christian Koenig , Huang Rui , David Airlie , Daniel Vetter Cc: Robert Beckett , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 5/7] drm/ttm: add range busy check for range manager Date: Tue, 15 Mar 2022 18:04:42 +0000 Message-Id: <20220315180444.3327283-6-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220315180444.3327283-1-bob.beckett@collabora.com> References: <20220315180444.3327283-1-bob.beckett@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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 RFC: do we want this to become a generic interface in ttm_resource_manager_func? RFC: would we prefer a different interface? e.g. for_each_resource_in_range or for_each_bo_in_range Signed-off-by: Robert Beckett --- drivers/gpu/drm/ttm/ttm_range_manager.c | 21 +++++++++++++++++++++ include/drm/ttm/ttm_range_manager.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c index 8cd4f3fb9f79..5662627bb933 100644 --- a/drivers/gpu/drm/ttm/ttm_range_manager.c +++ b/drivers/gpu/drm/ttm/ttm_range_manager.c @@ -206,3 +206,24 @@ int ttm_range_man_fini_nocheck(struct ttm_device *bdev, return 0; } EXPORT_SYMBOL(ttm_range_man_fini_nocheck); + +/** + * ttm_range_man_range_busy - Check whether anything is allocated with a range + * + * @man: memory manager to check + * @fpfn: first page number to check + * @lpfn: last page number to check + * + * Return: true if anything allocated within the range, false otherwise. + */ +bool ttm_range_man_range_busy(struct ttm_resource_manager *man, + unsigned fpfn, unsigned lpfn) +{ + struct ttm_range_manager *rman = to_range_manager(man); + struct drm_mm *mm = &rman->mm; + + if (__drm_mm_interval_first(mm, PFN_PHYS(fpfn), PFN_PHYS(lpfn + 1) - 1)) + return true; + return false; +} +EXPORT_SYMBOL(ttm_range_man_range_busy); diff --git a/include/drm/ttm/ttm_range_manager.h b/include/drm/ttm/ttm_range_manager.h index 7963b957e9ef..86794a3f9101 100644 --- a/include/drm/ttm/ttm_range_manager.h +++ b/include/drm/ttm/ttm_range_manager.h @@ -53,4 +53,7 @@ static __always_inline int ttm_range_man_fini(struct ttm_device *bdev, BUILD_BUG_ON(__builtin_constant_p(type) && type >= TTM_NUM_MEM_TYPES); return ttm_range_man_fini_nocheck(bdev, type); } + +bool ttm_range_man_range_busy(struct ttm_resource_manager *man, + unsigned fpfn, unsigned lpfn); #endif -- 2.25.1