From patchwork Mon Aug 26 22:33:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 172226 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp4965642ily; Mon, 26 Aug 2019 15:33:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/AjgI5Dy5C6IU0nP+9x16CjHEoQfCK3XI//JzvSaxg7HMIGHrvdIYonK57jaZnoozmpsj X-Received: by 2002:a62:1703:: with SMTP id 3mr22637608pfx.118.1566858824373; Mon, 26 Aug 2019 15:33:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566858824; cv=none; d=google.com; s=arc-20160816; b=f3/1yXiY5WoKgUy1AdkRjHZARdoLS3ppCAEDpg/AYQNc3n+2xkCKg2q6yFFLyC2hG5 fcwdvLplZKm2dbrgvJzrgzrRYkF8KIfaqfE+Tbjes5aD0N6lF/EGUdzRJEHUIyONTmOg xlYl/8wU8kKcfHDKgeAVk5ujPxTfUs3tjuMSjhfmMc0OrYibQys9BnHtzvqDyvlYOnJC Bd48FmWLmbmlijeVYfG9QWRhIfmTZpXJgwC4cI1hLlJD/ol/CWkfVCyF2t27dyY++CC/ KVeJ8AzvvJGAGhSTtQXLc8L9OSkDZNx3TBIzwicU3T1zguoLJKIRtozJncD4X0Jpd3FC 9teg== 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=UJ6AFwxZc89JUibvrCr2Fjb1Gp8DdNanKbWn29TJ+5E=; b=WMhdmBnkmRPeWfrcMnxg4Y3pKHhreZo0afTZfDoB5TALS/OTBUZ2doefF2Q8uqIkzp Joyl8rsYwXgs/wM5epRYn6SXwbecQ3w/+Ao7sz65h/DNLXHSIVw7zIGy3LN9gRGoNSEN mZZxwa7/d2t5Mt0zYDplmDQt05ke0tuzyTHqTenXVLR89epRiat1orpFWz/9ADxS6NJE 9v4U39HCDumji8Yew1YQhrrJva2WDypYHy7CcEAYGbp85YU3Cb/H4UyPiUff/FG+S8zs BV6MQt0R4L6qAJ5zL7Z7E1mFleuGXEIdooUCIrWgIhfCDQrMtlO4jnd4HF6TroB1hk76 1iLw== 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 y13si7135997pfg.215.2019.08.26.15.33.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Aug 2019 15:33:44 -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 167776E31C; Mon, 26 Aug 2019 22:33:40 +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 91A7789CA8 for ; Mon, 26 Aug 2019 22:33:27 +0000 (UTC) Received: by mail-oi1-f194.google.com with SMTP id y8so13416120oih.10 for ; Mon, 26 Aug 2019 15:33:27 -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=ts2BNP4Mwcn8VDxGl/va9XJyRObd509hUDKfhgkialg=; b=UOyAs6Z+K3YZQWLxLWjENyJT8WX/I4Iy1AcxtYOifVgRdon0B9jOit4QWluOkOGV5B 8go8ZBDZSHtztNWs90ZFVccXAUocwKBTqNzWAwy2kXr77i5n0cpFkkcGsDSCGloLOyIY dYBxNkvXMPPwleVi3AEIGhUOCcwY+j7KPoiWnBeQQsRCtzApyxrbSDyQqWiHVPXoBoCo noQ0ACcy672YMKT2z6BRHIiV+eb6iXizjIkNOhx8XG9bxf8u161hgObMZMV7j13a2n4N aLcqY7gQDF/lgcHL4iPHZB+yfMwwb45n8gPF0We+CAFqe98Bblcn5y2klZuihMNRCx32 MB4Q== X-Gm-Message-State: APjAAAWA3Fy0dXLCMrVvWcws1eZw7wQOLWYujRNGq9DpwnYPnZI2PxfV G+8WF50SGfFjsebhEJUTK0wacZM= X-Received: by 2002:aca:c588:: with SMTP id v130mr13562313oif.165.1566858806147; Mon, 26 Aug 2019 15:33:26 -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 e22sm3668959oii.7.2019.08.26.15.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 15:33:25 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 7/8] drm/panfrost: Flush and disable address space when freeing page tables Date: Mon, 26 Aug 2019 17:33:16 -0500 Message-Id: <20190826223317.28509-8-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190826223317.28509-1-robh@kernel.org> References: <20190826223317.28509-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: Tomeu Vizoso , David Airlie , Steven Price , Alyssa Rosenzweig , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently, page tables are freed without disabling the address space first. This probably is fine as we'll switch to new page tables when the address space is allocated again and runtime PM suspend will reset the GPU clearing the registers. However, it's better to clean up after ourselves. There is also a problem that we could be accessing the h/w in tlb_inv_context() when suspended. Rework the disable code to make sure we flush caches/TLBs and disable the address space before freeing the page tables if we are not suspended. As the tlb_inv_context() hook is only called when freeing the page tables and we do a flush before disabling the AS, lets remove the flush from tlb_inv_context and avoid any runtime PM issues. Fixes: 7282f7645d06 ("drm/panfrost: Implement per FD address spaces") Cc: Tomeu Vizoso Cc: Steven Price Cc: Alyssa Rosenzweig Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring Reviewed-by: Robin Murphy Reviewed-by: Steven Price --- v3: - New patch replacing "drm/panfrost: Remove unnecessary flushing from tlb_inv_context" drivers/gpu/drm/panfrost/panfrost_mmu.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) -- 2.20.1 diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index d1ebde3327fe..387d830cb7cf 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -129,8 +129,10 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m write_cmd(pfdev, as_nr, AS_COMMAND_UPDATE); } -static void mmu_disable(struct panfrost_device *pfdev, u32 as_nr) +static void panfrost_mmu_disable(struct panfrost_device *pfdev, u32 as_nr) { + mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM); + mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), 0); mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), 0); @@ -321,11 +323,7 @@ void panfrost_mmu_unmap(struct panfrost_gem_object *bo) } static void mmu_tlb_inv_context_s1(void *cookie) -{ - struct panfrost_file_priv *priv = cookie; - - mmu_hw_do_operation(priv->pfdev, &priv->mmu, 0, ~0UL, AS_COMMAND_FLUSH_MEM); -} +{} static void mmu_tlb_inv_range_nosync(unsigned long iova, size_t size, size_t granule, bool leaf, void *cookie) @@ -374,6 +372,11 @@ void panfrost_mmu_pgtable_free(struct panfrost_file_priv *priv) spin_lock(&pfdev->as_lock); if (mmu->as >= 0) { + pm_runtime_get_noresume(pfdev->dev); + if (pm_runtime_active(pfdev->dev)) + panfrost_mmu_disable(pfdev, mmu->as); + pm_runtime_put_autosuspend(pfdev->dev); + clear_bit(mmu->as, &pfdev->as_alloc_mask); clear_bit(mmu->as, &pfdev->as_in_use_mask); list_del(&mmu->list); @@ -618,5 +621,4 @@ int panfrost_mmu_init(struct panfrost_device *pfdev) void panfrost_mmu_fini(struct panfrost_device *pfdev) { mmu_write(pfdev, MMU_INT_MASK, 0); - mmu_disable(pfdev, 0); }