From patchwork Fri Aug 23 02:12:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 172077 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1668ily; Thu, 22 Aug 2019 19:12:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCasth5ud3esqZ0zNyt/GeZ/S14xhweTW9G0yY/L/Nv96beW2EIgLJlHAKq30y5rLaDZwk X-Received: by 2002:a17:90a:ad86:: with SMTP id s6mr2608479pjq.53.1566526352727; Thu, 22 Aug 2019 19:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566526352; cv=none; d=google.com; s=arc-20160816; b=MVDekjG9E9xQqBLIQx+ONJR+odzYhHvetIkRKlqTiLsX1HNEkT4D3i8COw62/pfMNb orSX+KdlL/+aV/2JKRsFQVeOrv3P+iBSLeLuRaAnhfRcwZC7M9lurvsrbXw9t0p7pfID HdbfubRV40Lo6SLQAlzsXn+2m0JUC5ynaltuf1JTMufhK4kWRkrYKsDiJbzlqjQ0XX3J Szp0gVIOgyYGTTv/Dxx0CnMuIVxsA2UtJ8SCVda0Ee7VzO35klKG7XYnE4g6GQk/RIrz TviNmz/95VlCfkknDxTeSXM+v2KWkIUNrfqyWbfwU96XP+CnX+BoYN94XvpKxduIOlyv dXwg== 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=qWrz8cN75qrfRwhit9NOiEi9GTc78vT2OxntMP4tUus=; b=cjhjOPjPEQWKWl2LlN+IBhyPKEqZkfjp4PsAubgrfxouOLd7sEV+WjmT5hrCfmRPgH 3tgQO/V29VtvlrsGt+MHV7zE237+TluOYNMYXjIXGqylJ/FJopSt1/q7kJqDephVNmpP BJiBj+AdJn435glyAyMz5njkgNgMJ/DMUIVY2eL8hdtv0muwYBajOLnPJq1B7ZF3DvPV SCvFPcFXq1kuH/j8A9ixRXaf2p/p8Z4bGBDzEutcwxIdmnry7pdXHi3OE7JHTm+JGQUV BfiYHjbY2jaMUE+knGHf/pj7pkx4yISbOJHGV/6OA0TF1fh1yRKFIv0b2deamEObiIRW fSPw== 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 131.252.210.177 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. [131.252.210.177]) by mx.google.com with ESMTPS id 69si796663pge.101.2019.08.22.19.12.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2019 19:12:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 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 729746EBA5; Fri, 23 Aug 2019 02:12:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oi1-f194.google.com (mail-oi1-f194.google.com [209.85.167.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id 400346EBA5 for ; Fri, 23 Aug 2019 02:12:28 +0000 (UTC) Received: by mail-oi1-f194.google.com with SMTP id h21so5915870oie.7 for ; Thu, 22 Aug 2019 19:12:28 -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=BzTdZYeFiJ1FqiKtBuuS6jDxd4HUqfZzxSvzf3pHQtc=; b=GIImCkdM3O/RMdFXv8Zz3Uh69rUrl0w6HnI3qNVDdDPaSl0HoXk29IYpg3upDMtuQy I1lPJKCRwiDRO9a40Te2e3h6QR7OrESKOoJJkaU5C2iBf8R1xj/QIWIvV95OtdiPDowC G8ApzMVwG6BW1VZEn3zSRNdxH2ebe6WOaxUZVNK4blddKJ9HlAvWFw0aDk0R+2xvRwiP 0G32vbVZQFPNRaoD8UifNPKGrkNlHn+ZRmfGJg4ZRaE+a87LSroOm6SZv0kB31MY7Pv7 u/y/iHBoEbAeTq4FLwp//eZStnd5IYzcnZ6Z8/7g0CX5SXHvCzs2yMbSeS+1nv/TM2yl 57Qw== X-Gm-Message-State: APjAAAV97/zLrf6mHwAzmRsEiZ50qHn+9qYwV1P/Ox427OqKbQz/+3+e mLhyemzUbNLe8pytNZyfkRFvajM= X-Received: by 2002:aca:55d8:: with SMTP id j207mr1558087oib.38.1566526347322; Thu, 22 Aug 2019 19:12:27 -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 c1sm457747oic.31.2019.08.22.19.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 19:12:26 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 7/8] drm/panfrost: Rework page table flushing and runtime PM interaction Date: Thu, 22 Aug 2019 21:12:15 -0500 Message-Id: <20190823021216.5862-8-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190823021216.5862-1-robh@kernel.org> References: <20190823021216.5862-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 , Alyssa Rosenzweig , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There is no point in resuming the h/w just to do flush operations and doing so takes several locks which cause lockdep issues with the shrinker. Rework the flush operations to only happen when the h/w is already awake. This avoids taking any locks associated with resuming. Cc: Tomeu Vizoso Cc: Steven Price Cc: Alyssa Rosenzweig Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring Reviewed-by: Steven Price Reviewed-by: Robin Murphy --- v2: new patch drivers/gpu/drm/panfrost/panfrost_mmu.c | 41 ++++++++++++------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index 842bdd7cf6be..ccf671a9c3fb 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -220,6 +220,23 @@ static size_t get_pgsize(u64 addr, size_t size) return SZ_2M; } +void panfrost_mmu_flush_range(struct panfrost_device *pfdev, + struct panfrost_mmu *mmu, + u64 iova, size_t size) +{ + if (mmu->as < 0) + return; + + /* Flush the PTs only if we're already awake */ + if (!pm_runtime_get_if_in_use(pfdev->dev)) + return; + + mmu_hw_do_operation(pfdev, mmu, iova, size, AS_COMMAND_FLUSH_PT); + + pm_runtime_mark_last_busy(pfdev->dev); + pm_runtime_put_autosuspend(pfdev->dev); +} + static int mmu_map_sg(struct panfrost_device *pfdev, struct panfrost_mmu *mmu, u64 iova, int prot, struct sg_table *sgt) { @@ -246,11 +263,10 @@ static int mmu_map_sg(struct panfrost_device *pfdev, struct panfrost_mmu *mmu, } } - mmu_hw_do_operation(pfdev, mmu, start_iova, iova - start_iova, - AS_COMMAND_FLUSH_PT); - mutex_unlock(&mmu->lock); + panfrost_mmu_flush_range(pfdev, mmu, start_iova, iova - start_iova); + return 0; } @@ -259,7 +275,6 @@ int panfrost_mmu_map(struct panfrost_gem_object *bo) struct drm_gem_object *obj = &bo->base.base; struct panfrost_device *pfdev = to_panfrost_device(obj->dev); struct sg_table *sgt; - int ret; int prot = IOMMU_READ | IOMMU_WRITE; if (WARN_ON(bo->is_mapped)) @@ -272,14 +287,7 @@ int panfrost_mmu_map(struct panfrost_gem_object *bo) if (WARN_ON(IS_ERR(sgt))) return PTR_ERR(sgt); - ret = pm_runtime_get_sync(pfdev->dev); - if (ret < 0) - return ret; - mmu_map_sg(pfdev, bo->mmu, bo->node.start << PAGE_SHIFT, prot, sgt); - - pm_runtime_mark_last_busy(pfdev->dev); - pm_runtime_put_autosuspend(pfdev->dev); bo->is_mapped = true; return 0; @@ -293,17 +301,12 @@ void panfrost_mmu_unmap(struct panfrost_gem_object *bo) u64 iova = bo->node.start << PAGE_SHIFT; size_t len = bo->node.size << PAGE_SHIFT; size_t unmapped_len = 0; - int ret; if (WARN_ON(!bo->is_mapped)) return; dev_dbg(pfdev->dev, "unmap: as=%d, iova=%llx, len=%zx", bo->mmu->as, iova, len); - ret = pm_runtime_get_sync(pfdev->dev); - if (ret < 0) - return; - mutex_lock(&bo->mmu->lock); while (unmapped_len < len) { @@ -318,13 +321,9 @@ void panfrost_mmu_unmap(struct panfrost_gem_object *bo) unmapped_len += pgsize; } - mmu_hw_do_operation(pfdev, bo->mmu, bo->node.start << PAGE_SHIFT, - bo->node.size << PAGE_SHIFT, AS_COMMAND_FLUSH_PT); - mutex_unlock(&bo->mmu->lock); - pm_runtime_mark_last_busy(pfdev->dev); - pm_runtime_put_autosuspend(pfdev->dev); + panfrost_mmu_flush_range(pfdev, bo->mmu, bo->node.start << PAGE_SHIFT, len); bo->is_mapped = false; }