From patchwork Mon Aug 19 16:12:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 171652 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp3197862ily; Mon, 19 Aug 2019 09:12:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhPbPG12TDceSgw5MRT5IMibETrKDs+KIFMaNF8YaG1QOqpcM6xVrCJnMHEn+ukqedPqC2 X-Received: by 2002:a65:64c6:: with SMTP id t6mr21114085pgv.323.1566231140943; Mon, 19 Aug 2019 09:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566231140; cv=none; d=google.com; s=arc-20160816; b=y8ttjsXJhEGlWpgRjEzgBSNXzMv65gKy8+pikPAU6v5whI3aE1xEjH3JZfMu1bNrj7 SNWqh1cQ2Rmyjq1wh8xvd56V8RGeH012j2Q0cJWxm7Z4gfLAj3uBPqr5YZfOnGE9QDCG WGYJ0ltdJ2CAUOD9U+fRrW0v5R6fjvms3dodssc00ubYy41ElUnAeXM64EmoJdYnL4b2 YqTB4p05lYb6Hlo6hbEcj0vNWJTwDWs5tRviK5w8q+kJNWDDNB40PF4nxd0BnLkxB2uX ikdHSjLVYVhQkX2QQqq9e1+r7MHw/jqlBVU0BGa9LMyx47tlgsTfDvhpLBcDvmkLfpkx X1ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=7Ce3kzC82tAZE6f54QsKetZJI0N1gyHe5Az0grWSsy4=; b=0v7QNI2JMejvf5aTxe/U+ud40F+acON+0nY4JTLwF1IvPm19PcFcnBzdwCE5HY1+Bx WZa6xajU4BJCkU1oOqOgzbYpElnxU0+SLG3iMpgcolT12C+1VX2GcMzheHP5MX0V+s/w OZlTUHmOFoUl4BmuBKaYjX/qq3f7YVmvRYHAOZykU/+6mkFFa00ruq8kTjytBTVO20J0 kVr22vgF0t17X1HIXypiIzA1cKi56ixDs2QqTqo+ntcxQQ5P59rYszgR5JKMCtQQEVJ5 85G8yfcpwKP6fnK6WF90NhJp7774xxJeB9TZlChF3Sr7FUZTVF2cXzHiwuqV/+16Yllf kBkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id x10si11019362pfj.274.2019.08.19.09.12.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Aug 2019 09:12:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E34976E201; Mon, 19 Aug 2019 16:12:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id 418236E1F4 for ; Mon, 19 Aug 2019 16:12:11 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id j5so5470058ioj.8 for ; Mon, 19 Aug 2019 09:12:11 -0700 (PDT) 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=lAPAq7xSxjjLTecPqKAR65l3wBupYMfUEeatXDRr6eM=; b=VbJtlTjzG2FH89+pXrfpjLYXOlLkXSmA50hDaNc2AnzG9+YD50bK5RJxDCIvAC4NFo LZuwrM93BX8O9vs6EH9i4alCXHAiw+ufprHFPggbXCu8ix421Cw0P9K2p+3Kx1ajfVhB E7CYfR9Q9uM31x7Z53CKjK9Qm9/vWI+jO7BJC7JX4N2sSNJG5hG3rAPR8dWc4h7lgaXC KKPsP0w/N6uY3mgtf9Bjh2Pvkjqum/XlvAIyEFbRzLIYILQT6Pl5z7Es0tpy1Lwgm+vC KGrnOMR2eH75SuvUR9zOdk7/5JLitqYKjHGdAwrbm4da2kW7EaAB0AGmIdElmT6D+VEz Khug== X-Gm-Message-State: APjAAAVKVN9OZYbOds3oBKb9ahUUhxtckcLoJVBQOwKIyBm4eIKkn0I4 HJIpXZZJbCQy/sDT9lFjFGL0Lmg= X-Received: by 2002:a02:9644:: with SMTP id c62mr27156363jai.45.1566231130158; Mon, 19 Aug 2019 09:12:10 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id c19sm4770584ioi.22.2019.08.19.09.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 09:12:09 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/4] drm/panfrost: Fix shrinker lockdep issues using drm_gem_shmem_purge() Date: Mon, 19 Aug 2019 11:12:03 -0500 Message-Id: <20190819161204.3106-4-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190819161204.3106-1-robh@kernel.org> References: <20190819161204.3106-1-robh@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , Tomeu Vizoso , David Airlie , Sean Paul , Steven Price , Boris Brezillon , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This fixes 2 issues found by lockdep. First, drm_gem_shmem_purge() now uses mutex_trylock for the pages_lock to avoid a circular dependency. Second, it drops the call to panfrost_mmu_unmap() which takes several locks due to runtime PM calls. The call is not necessary because the unmapping is also called in panfrost_gem_close() already. Fixes: 013b65101315 ("drm/panfrost: Add madvise and shrinker support") Cc: Tomeu Vizoso Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring --- drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c b/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c index d191632b6197..cc15005dc68f 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c +++ b/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c @@ -36,17 +36,6 @@ panfrost_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc return count; } -static void panfrost_gem_purge(struct drm_gem_object *obj) -{ - struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj); - mutex_lock(&shmem->pages_lock); - - panfrost_mmu_unmap(to_panfrost_bo(obj)); - drm_gem_shmem_purge_locked(obj); - - mutex_unlock(&shmem->pages_lock); -} - static unsigned long panfrost_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_control *sc) { @@ -61,8 +50,8 @@ panfrost_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_control *sc) list_for_each_entry_safe(shmem, tmp, &pfdev->shrinker_list, madv_list) { if (freed >= sc->nr_to_scan) break; - if (drm_gem_shmem_is_purgeable(shmem)) { - panfrost_gem_purge(&shmem->base); + if (drm_gem_shmem_is_purgeable(shmem) && + drm_gem_shmem_purge(&shmem->base)) { freed += shmem->base.size >> PAGE_SHIFT; list_del_init(&shmem->madv_list); }