From patchwork Wed Mar 30 20:47:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 555133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5216C43217 for ; Wed, 30 Mar 2022 20:48:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351133AbiC3Utt (ORCPT ); Wed, 30 Mar 2022 16:49:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351130AbiC3Uts (ORCPT ); Wed, 30 Mar 2022 16:49:48 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BB5E46B21; Wed, 30 Mar 2022 13:48:03 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id s11so19907234pfu.13; Wed, 30 Mar 2022 13:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tAkFR+6vhq0o/UUKOqeWc9uPJoN5WXdSoZFQuuhB/hI=; b=FaRX1UWeh8GQfsWkMrLyB/2P+dHN9Hng7Nnbkb8Dmccr6iK2ArjJbfSlU8EPowuRWM qW31UzHkCjytuoAR+WWkvmyCp3G4iMnoWx/nnxlHTLpAJUQbM6GVypBSaZwMyvLSvARW ScQl1zEZXblXWWXw9Ao0riGA53h1pygszQSJnMez126k9Azct1fKBoXLyPcmzCicD4J0 4HwypBgxCK8bwUjzSXEeBNYCMLJBm3zt7CE+xreRbChK4sOA1MmLNzXoGnceIs57lW6H LuE9H0um3vrd7lKNr9E2BPQqKoF6+bx/PIgeyCRbpWeyXfH3ZlRKF2JsOe2CV+9V9fdo M55Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tAkFR+6vhq0o/UUKOqeWc9uPJoN5WXdSoZFQuuhB/hI=; b=JOK7QZVDDJAsWhqIMNiYG6Ut4hNyeauXjLe8Q0v/MGcKDSAVr2LzpjRxKGZdVZuuOO miB+gUiucgkVKVhipljRELZfIXTyNx4pyp6LjDR4bNq8BDbpXIkJSlexhyXoZlg8ZFTL QvfiBB0ym08mLOYqEaTEga/X27mP1S6U+/+SRn9JP/2X11lfR6eViDDTBoJL4Ok65kb4 Z3yWXqzNoUFbRIfoE2pS5yEXrbDbwa9EfM3ZIPwqyzx9taBM1XOmXr1qrJHQLI+aKZXQ owKTHPl4xBa1repsJiiH/MPgC/PwndsegPIs3B5VKZfpkUkAppJhs114teD3hzilm/nu XIEw== X-Gm-Message-State: AOAM532e+Wc5eBw3MIOl4fa4gDXPaUbpWgA46SCtBKA288PXcDVWRjxC /JRY8Eup4GEwy6hU+NCdAag= X-Google-Smtp-Source: ABdhPJzyLcWT52tc3P1GfBTk7VIU++snmA/PldvdmH9n7aHI7zf3vdwf3YMazpOjlkZVEhlMgaeJ3Q== X-Received: by 2002:a63:4005:0:b0:373:9ac7:fec1 with SMTP id n5-20020a634005000000b003739ac7fec1mr7699274pga.12.1648673282631; Wed, 30 Mar 2022 13:48:02 -0700 (PDT) Received: from localhost ([2a00:79e1:abd:4a00:2703:3c72:eb1a:cffd]) by smtp.gmail.com with ESMTPSA id u10-20020a63b54a000000b00380ea901cd2sm19805501pgo.6.2022.03.30.13.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 13:48:01 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Dmitry Baryshkov , Dmitry Osipenko , Rob Clark , Rob Clark , Sean Paul , Abhinav Kumar , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 04/10] drm/msm/gem: Split out inuse helper Date: Wed, 30 Mar 2022 13:47:49 -0700 Message-Id: <20220330204804.660819-5-robdclark@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220330204804.660819-1-robdclark@gmail.com> References: <20220330204804.660819-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark Prep for a following patch, where it gets a bit more complicated. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_gem.c | 2 +- drivers/gpu/drm/msm/msm_gem.h | 1 + drivers/gpu/drm/msm/msm_gem_vma.c | 9 +++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index a4f61972667b..f96d1dc72021 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -938,7 +938,7 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m, name, comm ? ":" : "", comm ? comm : "", vma->aspace, vma->iova, vma->mapped ? "mapped" : "unmapped", - vma->inuse); + msm_gem_vma_inuse(vma)); kfree(comm); } diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h index 947ff7d9b471..1b7f0f0b88bf 100644 --- a/drivers/gpu/drm/msm/msm_gem.h +++ b/drivers/gpu/drm/msm/msm_gem.h @@ -61,6 +61,7 @@ struct msm_gem_vma { int msm_gem_init_vma(struct msm_gem_address_space *aspace, struct msm_gem_vma *vma, int npages, u64 range_start, u64 range_end); +bool msm_gem_vma_inuse(struct msm_gem_vma *vma); void msm_gem_purge_vma(struct msm_gem_address_space *aspace, struct msm_gem_vma *vma); void msm_gem_unmap_vma(struct msm_gem_address_space *aspace, diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c index 64906594fc65..dc2ae097805e 100644 --- a/drivers/gpu/drm/msm/msm_gem_vma.c +++ b/drivers/gpu/drm/msm/msm_gem_vma.c @@ -37,6 +37,11 @@ msm_gem_address_space_get(struct msm_gem_address_space *aspace) return aspace; } +bool msm_gem_vma_inuse(struct msm_gem_vma *vma) +{ + return !!vma->inuse; +} + /* Actually unmap memory for the vma */ void msm_gem_purge_vma(struct msm_gem_address_space *aspace, struct msm_gem_vma *vma) @@ -44,7 +49,7 @@ void msm_gem_purge_vma(struct msm_gem_address_space *aspace, unsigned size = vma->node.size << PAGE_SHIFT; /* Print a message if we try to purge a vma in use */ - if (GEM_WARN_ON(vma->inuse > 0)) + if (GEM_WARN_ON(msm_gem_vma_inuse(vma))) return; /* Don't do anything if the memory isn't mapped */ @@ -100,7 +105,7 @@ msm_gem_map_vma(struct msm_gem_address_space *aspace, void msm_gem_close_vma(struct msm_gem_address_space *aspace, struct msm_gem_vma *vma) { - if (GEM_WARN_ON(vma->inuse > 0 || vma->mapped)) + if (GEM_WARN_ON(msm_gem_vma_inuse(vma) || vma->mapped)) return; spin_lock(&aspace->lock);