From patchwork Fri Dec 11 16:29:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11968613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56222C4361B for ; Fri, 11 Dec 2020 16:30:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D1D3523D3C for ; Fri, 11 Dec 2020 16:29:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D1D3523D3C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C3C7C6E497; Fri, 11 Dec 2020 16:29:56 +0000 (UTC) Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 956616E492 for ; Fri, 11 Dec 2020 16:29:53 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id r3so9662740wrt.2 for ; Fri, 11 Dec 2020 08:29:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wRPl19UGwYF4ueTV3ctFZKeqenPxtRHiQr2+++kl6Ac=; b=OvOASk22oH2EJ7EQdBLPGF421aTG+wG7k4zEOGLziez4YunnvvIkahai0Balaae4KW s/5+kq2RXRnI+Z8Gylc9bUs7WHaHHq1gGqR9Nqze1Y439CUiwGyFJChGGOOh0UaScodV BJybMpQPVEYrG0DSSzaAQBzHe6EhbliGphqks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wRPl19UGwYF4ueTV3ctFZKeqenPxtRHiQr2+++kl6Ac=; b=tfO2q31OiXC71ZmWxNGdsjgAPNc2RlmUSWcAFtmtxmYPIPLGkL3hTUBzk7M+l2UwYe k96iUVi3qlHkiJmybuVD9pwttMiQgr8nMVLU7bLTAEe077F6iEzjUkaZFW8M6wu6WfQ1 6jI6FQvPJzavB4W94+UrrCK+/k5S/RAV9mvT+aLqE3kX21MR9IzCXx4ZxLnpdqV/Y7S9 siz2d7T+XPtVC6AooEvmzxTHR3OuOnaenimvl21iBV4qosAJiaORi1hd9Vji2A5Z+kdh No4WakLazoqzibAMa04Kd7BRUkMUNJnVUgVCjeEalBjv5eT7ExnAxXO1fnrW7K6zqkVQ Unig== X-Gm-Message-State: AOAM5307jWgLJlv/MuD+KMVAWGDUIKuQ/E9rvJfoYCi34UTEpWQb9Pdd qgqRGuDT1R0CigMuB8sZpPmUFTgGTZFmtw== X-Google-Smtp-Source: ABdhPJwg5f6/7UMZFi90je8EDCsXp7XMRVBLkSXHcTpwSyLt/aOyC15FeBXEAoMtiLRBdpxPhTLYpw== X-Received: by 2002:a5d:4c4d:: with SMTP id n13mr14980391wrt.356.1607704191993; Fri, 11 Dec 2020 08:29:51 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id n126sm15917654wmn.21.2020.12.11.08.29.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Dec 2020 08:29:51 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH 3/3] drm/ttm: WARN_ON non-empty lru when disabling a resource manager Date: Fri, 11 Dec 2020 17:29:42 +0100 Message-Id: <20201211162942.3399050-3-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211162942.3399050-1-daniel.vetter@ffwll.ch> References: <20201211162942.3399050-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , sroland@vmware.com, Huang Rui , linux-graphics-maintainer@vmware.com, Daniel Vetter , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" ttm_resource_manager->use_type is only used for runtime changes by vmwgfx. I think ideally we'd push this functionality into drivers - ttm itself does not provide any locking to guarantee this is safe, so the only way this can work at runtime is if the driver does provide additional guarantees. vwmgfx does that through the vmw_private->reservation_sem. Therefore supporting this feature in shared code feels a bit misplaced. As a first step add a WARN_ON to make sure the resource manager is empty. This is just to make sure I actually understand correctly what vmwgfx is doing, and to make sure an eventual subsequent refactor doesn't break anything. This check should also be useful for other drivers, to make sure they haven't leaked anything. Reviewed-by: Christian König Signed-off-by: Daniel Vetter Cc: Christian Koenig Cc: Huang Rui --- include/drm/ttm/ttm_resource.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/drm/ttm/ttm_resource.h b/include/drm/ttm/ttm_resource.h index f48a70d39ac5..789ec477b607 100644 --- a/include/drm/ttm/ttm_resource.h +++ b/include/drm/ttm/ttm_resource.h @@ -191,6 +191,10 @@ struct ttm_resource { static inline void ttm_resource_manager_set_used(struct ttm_resource_manager *man, bool used) { + int i; + + for (i = 0; i < TTM_MAX_BO_PRIORITY; i++) + WARN_ON(!list_empty(&man->lru[i])); man->use_type = used; }