From patchwork Mon Aug 26 22:33:10 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: 172221 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp4965409ily; Mon, 26 Aug 2019 15:33:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzu7UiQ7Tc1li0/dnAcD2K3Wy98BqOATwiUElkuEIQw7SKmWFouMAMZx3WPY9UfO8JutpId X-Received: by 2002:a63:1310:: with SMTP id i16mr18230655pgl.187.1566858809070; Mon, 26 Aug 2019 15:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566858809; cv=none; d=google.com; s=arc-20160816; b=P3F6XHHVIliIONtEWqMQjnb4UZTD25RdagX3He8YE7z/scFSb3ok/L09ST3kb0Oh65 Gal1dZyOCfW2JgObX5f+DH/hAQax4oksog7T/6ZrXmHkgxupOJB1Mw93yMqL5CBRb3QH /UKcB9gEtPIk5aY3Pwky1Kg3qnmuHXYmOe/SFULBYxn2Xy/SJjpZBd3uQN5Zhg84weZ6 Pn5DW7nOQjYAohM/lJt1YDkJtpFD/unOgs9xD+TWJ5GNd/7y0n2UuOAdRXMx2BltEGYe 1sAdS2/ONDsPqNb9A9cqmaiW4k19s9KHuserw1ZDt55QjgGGYurozpK+ZMJrsLft29Vm 7wHg== 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=2+9Vqkfxd/m3U2GdxEr14lMnwiaRgHUhs+RDKgtls/M=; b=bEOFwMlkZMgnmuTHjI2hbdrvzS667lfUshMDoazFEuTon7Onz3O+vv5SKm6r/pZbkI BsSgp+fmIMCBlRD5ySQs/XVaLJa92Sk2fXQkos/+NzOcssBDpgtiJMEuLp21tp9Scezi xZcnUMev45M+UWIZcORkxc1kX4ole4KeNTu6wh8TWQY7UBOXn4aXG6GVe2rhe3+27FnC SzZY5LXPQ1yb2hC5HgcURUrStEKEMeUpESXOegmMBAxrsg+OG0qYseka6SJCl8xWqyik dAxLWavbALTrgLPbSwta37/peA7322Mij3kP57VB9jnIuBbN6FK3UCgXWdr6YNx4L+mS O8Qw== 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 m184si12102800pfb.127.2019.08.26.15.33.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Aug 2019 15:33:29 -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 563306E315; Mon, 26 Aug 2019 22:33:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7AF6289C98 for ; Mon, 26 Aug 2019 22:33:20 +0000 (UTC) Received: by mail-ot1-f66.google.com with SMTP id b1so16807213otp.6 for ; Mon, 26 Aug 2019 15:33:20 -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=ZXQLljPOJppvUwH5wuivPhE8Q1AsKryxsAzIJcaFlYI=; b=DhE5xmWg20b5+jfS8pg00y7Ou4Iou2ROdSDY48nhmc9yyT5C+klg3QtYoBGZ8IefPT zWOPVxDLP9yqaJyydv/XwyDTW+neC8msUTt5Gfnl6FHJfW9mWnmBNIvulFQe9qdCDlPl 50x+sabQxuAjyLfe1NcQyFfvEWSq+m8x/ZmcHwPSTIFwk7/TJjPQWtOXIYk1oKW0P/ZP BaG69ob1wqvrbXm1XAWApuuktH9LA3ioJmn7y9WUQhA6YMN5kg6atjFszlG8aZR2wIRh g0Wi//sO6s6ZKjioS2z8KmDWaEzMgl1TBcp0mNQA18OPy1/qe8Uoh+HcVzUKgaJdqLDy 1SGQ== X-Gm-Message-State: APjAAAUbcfhbErx2eXa62HmOB1tpLphe8rRlMA+r7RfnGKXmR7LGV4zL Tsg92gmrflS1sD7mTpS34Zg345M= X-Received: by 2002:a05:6830:1e0a:: with SMTP id s10mr16241992otr.252.1566858799501; Mon, 26 Aug 2019 15:33:19 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 15:33:18 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 1/8] drm/panfrost: Rework runtime PM initialization Date: Mon, 26 Aug 2019 17:33:10 -0500 Message-Id: <20190826223317.28509-2-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" There's a few issues with the runtime PM initialization. The documentation states pm_runtime_set_active() should be called before pm_runtime_enable(). The pm_runtime_put_autosuspend() could suspend the GPU before panfrost_perfcnt_init() is called which touches the h/w. The autosuspend delay keeps things from breaking. There's no need explicitly power off the GPU only to wake back up with pm_runtime_get_sync(). Just delaying pm_runtime_enable to the end of probe is sufficient. Lets move all the runtime PM calls into the probe() function so they are all in one place and are done after all initialization. Cc: Tomeu Vizoso Cc: Steven Price Cc: David Airlie Cc: Daniel Vetter Acked-by: Alyssa Rosenzweig Signed-off-by: Rob Herring Reviewed-by: Robin Murphy :robin.murphy@arm.com> Reviewed-by: Steven Price --- v3: - Move autosuspend setup after pm_runtime_enable as only autosuspend changes trigger suspend. - Fix autosuspend delay to 50ms instead of 0. drivers/gpu/drm/panfrost/panfrost_device.c | 9 --------- drivers/gpu/drm/panfrost/panfrost_drv.c | 10 ++++++---- 2 files changed, 6 insertions(+), 13 deletions(-) -- 2.20.1 diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c index 4da71bb56c20..73805210834e 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.c +++ b/drivers/gpu/drm/panfrost/panfrost_device.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include "panfrost_device.h" @@ -166,14 +165,6 @@ int panfrost_device_init(struct panfrost_device *pfdev) if (err) goto err_out4; - /* runtime PM will wake us up later */ - panfrost_gpu_power_off(pfdev); - - pm_runtime_set_active(pfdev->dev); - pm_runtime_get_sync(pfdev->dev); - pm_runtime_mark_last_busy(pfdev->dev); - pm_runtime_put_autosuspend(pfdev->dev); - err = panfrost_perfcnt_init(pfdev); if (err) goto err_out5; diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index d74442d71048..bc2ddeb55f5d 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -523,10 +523,6 @@ static int panfrost_probe(struct platform_device *pdev) mutex_init(&pfdev->shrinker_lock); INIT_LIST_HEAD(&pfdev->shrinker_list); - pm_runtime_use_autosuspend(pfdev->dev); - pm_runtime_set_autosuspend_delay(pfdev->dev, 50); /* ~3 frames */ - pm_runtime_enable(pfdev->dev); - err = panfrost_device_init(pfdev); if (err) { if (err != -EPROBE_DEFER) @@ -541,6 +537,12 @@ static int panfrost_probe(struct platform_device *pdev) goto err_out1; } + pm_runtime_set_active(pfdev->dev); + pm_runtime_mark_last_busy(pfdev->dev); + pm_runtime_enable(pfdev->dev); + pm_runtime_set_autosuspend_delay(pfdev->dev, 50); /* ~3 frames */ + pm_runtime_use_autosuspend(pfdev->dev); + /* * Register the DRM device with the core and the connectors with * sysfs From patchwork Mon Aug 26 22:33:11 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: 172222 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp4965441ily; Mon, 26 Aug 2019 15:33:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtR5r4nPuH3hcrL3aBgB57hZi4Gx1HDGVa4heAXtdDGWFi+7m66Ya2dFoP9RkBTLRszGuv X-Received: by 2002:a65:620a:: with SMTP id d10mr18233529pgv.8.1566858810977; Mon, 26 Aug 2019 15:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566858810; cv=none; d=google.com; s=arc-20160816; b=pOKdEf9+//8JDHNWk63cUQFaFDQ6mfL2Ce1QZnYEhPA5tmAZqEA+JKk+EvPnSxSVEL ySojIyoSf1sAMB8HOUa7QYsx+Yrtv6hEkFy+EJthFNKtyg5nx7+mpmrKEP5UPGtUn9ip LGZGwy7ScejLKAzKjq2LWDV59EbQ/OUX2xhNjCdJDiN9M+cpLtx0yT5m1KXJOdaHzkOo yn88tio7L8+83Y+pXO8U8xc0vEJ52j1i/rDa0kww3ulsTQtLTYY5YlFuG/qY23zeF1Zc +nl+WZV3Ny4njA+aRDFwrMPzEerwAXzScDV3ZwiWqYO/jp9zXldOPEmuUiHCHGIt4tN0 myFw== 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=iooGw78xZfhdqWoPGY4w+dnWWnVaC4AExO/vlyMH2f8=; b=PIR6sANjn4E0xFozWFYbpwwLtdokROlovDuUS/HrLzBW3ZfGtvyePVOviHlFetfiSl HVhzSNTCkewFZHAQksrrPO1AjAb/2GqEkM1zmD4KLIIcPCkgNTyw8GPas2bUQ8gOL3a9 pM29k+kAfw12ucVqmzWe1SHYtLD+eKYFyMevyraNrnEICW4dlS5E6tDZ44Ol31lHNe4K 4zqjrQoO6u7bno98gurRv5dl1161ckgURxojn3LQOCObKsnNTD2wLxPd7i1D+Ui78VAt f6C3tHrpOkciDySN/bVaDePrnsqr2Cn8ymVZ1TkigkUAeoAsbxGOWREYNt0iH/TTvFfM tAyg== 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 33si10920469pli.149.2019.08.26.15.33.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Aug 2019 15:33:30 -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 49BFC6E313; Mon, 26 Aug 2019 22:33:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id C8F8289C98 for ; Mon, 26 Aug 2019 22:33:21 +0000 (UTC) Received: by mail-ot1-f65.google.com with SMTP id p23so12628407oto.0 for ; Mon, 26 Aug 2019 15:33:21 -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=ydH/HKcY64Hq0IwbCZKPNFDl6+x8s7JlVAmM1kUc43k=; b=eklt/d7jhlyRGu5arZgVztXRpqI4zMWCCzqIYX4uw9xqa0yJawftZH6l1TJnh1KPWZ XzP/kB5XwIYAOKmQXScbzqSanJ1nDAIHN4P3aRsGsV30gnaqq6HgIxKCCQHi0ozyrDaQ pxlGlqFn1AS5qLSB+58osLCQDlVTxsq7hAACnK/eZ/IC+VDlGyVPYzYbBkAbtxZyWuKo Y7wR6fqOtDoBZ9wgQJo30fggtpx2oprctdnzJ2PLAuZXza0EX/dC+4HVRznjBpjWO6m0 3gbGesuy+DgZ8XtiIxcCkHAqqC6DLku1glt+YjIXkEpxxP9RQa0xnTZtfVQhrBsug37m 5HHQ== X-Gm-Message-State: APjAAAWDXOri4qtrPFeIt9oult/bCBsQ9XPYqf5Wh4atVQD7RDRuNFr4 Yfo1ePvBuo/gdrgfeIzYgrPXazs= X-Received: by 2002:a05:6830:14e:: with SMTP id j14mr16501668otp.246.1566858800749; Mon, 26 Aug 2019 15:33:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 15:33:20 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 2/8] drm/panfrost: Hold runtime PM reference until jobs complete Date: Mon, 26 Aug 2019 17:33:11 -0500 Message-Id: <20190826223317.28509-3-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" Doing a pm_runtime_put as soon as a job is submitted is wrong as it should not happen until the job completes. It works currently because we are relying on the autosuspend timeout to keep the h/w enabled. Fixes: f3ba91228e8e ("drm/panfrost: Add initial panfrost driver") Cc: Tomeu Vizoso Cc: Steven Price Cc: Alyssa Rosenzweig Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring Reviewed-by: Steven Price --- v3: - Fix race between clearing pfdev->jobs[] in timeout and the ISR using the job_lock - Maintain pm_runtime_put in the panfrost_job_hw_submit error path drivers/gpu/drm/panfrost/panfrost_job.c | 39 ++++++++++++++++++------- 1 file changed, 28 insertions(+), 11 deletions(-) -- 2.20.1 diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c index 05c85f45a0de..18bcc9bac6d2 100644 --- a/drivers/gpu/drm/panfrost/panfrost_job.c +++ b/drivers/gpu/drm/panfrost/panfrost_job.c @@ -150,8 +150,10 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) if (ret < 0) return; - if (WARN_ON(job_read(pfdev, JS_COMMAND_NEXT(js)))) - goto end; + if (WARN_ON(job_read(pfdev, JS_COMMAND_NEXT(js)))) { + pm_runtime_put_sync_autosuspend(pfdev->dev); + return; + } cfg = panfrost_mmu_as_get(pfdev, &job->file_priv->mmu); @@ -187,10 +189,6 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) job_write(pfdev, JS_COMMAND_NEXT(js), JS_COMMAND_START); spin_unlock_irqrestore(&pfdev->hwaccess_lock, flags); - -end: - pm_runtime_mark_last_busy(pfdev->dev); - pm_runtime_put_autosuspend(pfdev->dev); } static void panfrost_acquire_object_fences(struct drm_gem_object **bos, @@ -369,6 +367,7 @@ static void panfrost_job_timedout(struct drm_sched_job *sched_job) struct panfrost_job *job = to_panfrost_job(sched_job); struct panfrost_device *pfdev = job->pfdev; int js = panfrost_job_get_slot(job); + unsigned long flags; int i; /* @@ -394,6 +393,15 @@ static void panfrost_job_timedout(struct drm_sched_job *sched_job) if (sched_job) drm_sched_increase_karma(sched_job); + spin_lock_irqsave(&pfdev->js->job_lock, flags); + for (i = 0; i < NUM_JOB_SLOTS; i++) { + if (pfdev->jobs[i]) { + pm_runtime_put_noidle(pfdev->dev); + pfdev->jobs[i] = NULL; + } + } + spin_unlock_irqrestore(&pfdev->js->job_lock, flags); + /* panfrost_core_dump(pfdev); */ panfrost_devfreq_record_transition(pfdev, js); @@ -450,12 +458,21 @@ static irqreturn_t panfrost_job_irq_handler(int irq, void *data) } if (status & JOB_INT_MASK_DONE(j)) { - struct panfrost_job *job = pfdev->jobs[j]; + struct panfrost_job *job; + + spin_lock(&pfdev->js->job_lock); + job = pfdev->jobs[j]; + /* Only NULL if job timeout occurred */ + if (job) { + pfdev->jobs[j] = NULL; + + panfrost_mmu_as_put(pfdev, &job->file_priv->mmu); + panfrost_devfreq_record_transition(pfdev, j); - pfdev->jobs[j] = NULL; - panfrost_mmu_as_put(pfdev, &job->file_priv->mmu); - panfrost_devfreq_record_transition(pfdev, j); - dma_fence_signal(job->done_fence); + dma_fence_signal_locked(job->done_fence); + pm_runtime_put_autosuspend(pfdev->dev); + } + spin_unlock(&pfdev->js->job_lock); } status &= ~mask; From patchwork Mon Aug 26 22:33:12 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: 172220 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp4965354ily; Mon, 26 Aug 2019 15:33:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKYHupu3ZMLMY20IWI05nZJrVKE5aQWMhWgv6O+3Q0LnUnevfFTg7Y61eqUJeVXU1CaX/L X-Received: by 2002:a17:90a:36ad:: with SMTP id t42mr21919230pjb.21.1566858806695; Mon, 26 Aug 2019 15:33:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566858806; cv=none; d=google.com; s=arc-20160816; b=QJ11myj2bVQBCo+/tgUtTRnxF+D6LAbCKkkDb1kwQSBQFigqhNdOFCfgMHhTAebLga 8JxP1KQaflzCHJ4YuHoOCNwkO0oNhbFEiqwrOPaERZP6BlnLKFPYd0GgH4sfrxkUYbcH f3CmHDGuyY9jnjhmyyaR4PaMNLFQq7KZeGM3OdxKeJsRYAV7Cvn04QsELcn0ap2utFIn fnO19fBeUhtcMCwDL9L82hy5Qk3Yd9zoDWZmpxBm33PgvuzXGFx5ivQgxp96NuKlk4/X 0rr5q+PmYH2BMO/J3C7MYbn867GTc0AXQq5nCn8IfeL8CB8paQkl11QTd2O3kXYsa790 B05g== 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=E2GLGDHyUIxmhRZ/soSFj+eCp+4x3EhognH3kgRLktA=; b=fym/owRLrP85tcdSkpJC0Un8S/fF+PaD8OT5fDUKIPVeYaTFxlNYgXM+LXZtdKC3B7 IwH0DBb0ZYxWHGeO6IPkfFtRuHhZhm+vn/hvxYbeALShrWSatmim/czp1hDaBIFC1/b3 XtnDc9X4aGhxfH/E/13WdoT3zOt3KZHQ54bixTdnMcBy//v72a2gTlQ5M0gyx+9LMXXg yJS4Fn6QCQB1d/BHKzezd2i99pGVsra9B5RJGvt7IiDx6ss2AxfpfWNYgV+tJX+CehLN gnWSmY1uXE2FNSJwaqg6WzGELphuL4OfK3AdpmIPSEdrYxUbY1uR2Bw6MJwCDvWMFz5f dHbA== 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 e129si10350939pgc.344.2019.08.26.15.33.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Aug 2019 15:33:26 -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 2243089CC9; Mon, 26 Aug 2019 22:33:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD33A89CA8 for ; Mon, 26 Aug 2019 22:33:22 +0000 (UTC) Received: by mail-ot1-f65.google.com with SMTP id j7so16796116ota.9 for ; Mon, 26 Aug 2019 15:33:22 -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=Lr1R889MqE/Qh3k6PKpRAd6kdNCwcusZ5h2myFtwlCQ=; b=SJjEmL4vkkgVQ57j1c+9dJBagBCibBszmKIfAbQGjKzAyQXOI9YE/PPXHGCx/ZXd40 rZD0VrBCVcOQwo5jynitTxcZKasgVK8HBUdPDkU1OQErGidl1ej4NMt77597dMiKWhh9 RIjk4W9vghNfNcdOyeBD0EuieVQ0UNLJk7euhamdzlsio6MzO9wEGzdLT4dVNusyycnO XjSzy9vtOzQA0hhEk3XiA3qC5JmgqT7KFGTGkydW3HxBg6wChQ1uLVRiQhoi1yCbGPJF U+qT511W53Y3tsQfQhVvd9G5/wuDXUEFXRDOaY+SK7F8aYwJTBMEOzE6s/AoyB5Odw7V 2k/Q== X-Gm-Message-State: APjAAAXLQQw8tJhkga6Q0N4lRATLnofOWa45SEB0OnfdriezBXN6ovdR VFINlWxsnWlMlBrMUHCcB1NbFt0= X-Received: by 2002:a9d:7356:: with SMTP id l22mr9274009otk.31.1566858801827; Mon, 26 Aug 2019 15:33:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 15:33:21 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 3/8] drm/panfrost: Remove unnecessary mmu->lock mutex Date: Mon, 26 Aug 2019 17:33:12 -0500 Message-Id: <20190826223317.28509-4-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" There's no need to serialize io-pgtable calls and the as_lock is sufficient to serialize flush operations, so we can remove the per page table lock. Fixes: 7282f7645d06 ("drm/panfrost: Implement per FD address spaces") Suggested-by: Robin Murphy 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 drivers/gpu/drm/panfrost/panfrost_device.h | 1 - drivers/gpu/drm/panfrost/panfrost_mmu.c | 9 --------- 2 files changed, 10 deletions(-) -- 2.20.1 diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h index f503c566e99f..b7fa08ed3a23 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -104,7 +104,6 @@ struct panfrost_device { struct panfrost_mmu { struct io_pgtable_cfg pgtbl_cfg; struct io_pgtable_ops *pgtbl_ops; - struct mutex lock; int as; atomic_t as_count; struct list_head list; diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index 842bdd7cf6be..3a8bcfa7e7b6 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -228,8 +228,6 @@ static int mmu_map_sg(struct panfrost_device *pfdev, struct panfrost_mmu *mmu, struct io_pgtable_ops *ops = mmu->pgtbl_ops; u64 start_iova = iova; - mutex_lock(&mmu->lock); - for_each_sg(sgt->sgl, sgl, sgt->nents, count) { unsigned long paddr = sg_dma_address(sgl); size_t len = sg_dma_len(sgl); @@ -249,8 +247,6 @@ 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); - return 0; } @@ -304,8 +300,6 @@ void panfrost_mmu_unmap(struct panfrost_gem_object *bo) if (ret < 0) return; - mutex_lock(&bo->mmu->lock); - while (unmapped_len < len) { size_t unmapped_page; size_t pgsize = get_pgsize(iova, len - unmapped_len); @@ -321,8 +315,6 @@ void panfrost_mmu_unmap(struct panfrost_gem_object *bo) 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); bo->is_mapped = false; @@ -356,7 +348,6 @@ int panfrost_mmu_pgtable_alloc(struct panfrost_file_priv *priv) struct panfrost_mmu *mmu = &priv->mmu; struct panfrost_device *pfdev = priv->pfdev; - mutex_init(&mmu->lock); INIT_LIST_HEAD(&mmu->list); mmu->as = -1; From patchwork Mon Aug 26 22:33:13 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: 172223 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp4965533ily; Mon, 26 Aug 2019 15:33:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUdcqtrt0oyhQYGFV0R7Ante8Iywo5yKGY1JeBhvXkzsIqPPvIuJvX2cGvfC0sxmbjyj9W X-Received: by 2002:a17:902:aa08:: with SMTP id be8mr21693964plb.144.1566858817000; Mon, 26 Aug 2019 15:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566858816; cv=none; d=google.com; s=arc-20160816; b=ylMp3C432o5uDL+bhxtoYz+w6HqnuklOFlI3RkDiRY3oAWOdZ4aUNX7MHZermFnG7j LrZ166sxgBAfuCfSIX5+lAwCE7FpxHWznTHdEh+HFvHMy5PF+6oRfnLhUl5a5XWOblTA kwMXath485rcXGNZ8XZl8mCh5DpuksYcnmzbk09sFKKxvGIqxLyOHqWeERh+wlc8umX1 MaYxBbpXrNR+IP2duIk7FIiLgTZ8wLmGqbrv6gR1ufJaVNNWn26bGtwT8w2610BQf5Bp B4s29iTivrD9akOD1u8nJAyAB4s5ESkeUEBBz2HedPwuK9aWVn7zuUtSeA3jIkELTh6C k0Bw== 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=GrEXLb6Hh5yOEX7s1V+xWWMWoJzfBuaS5gIDUHFkFQ0=; b=sNjbW385sHdCY2IJoRiHNd31LJB7G6JLZWv8BOzX7BD9tRElbfUpik0piWaG+qqJj9 H4jFECzBlMdgoY7Roa+HUPZ2lmap8iWT14IMgU4vdVkEnDqruAHGqGKvJ9XB/G9r3ToJ qNWqooWY8U5HAj0MNrWjBWsi3A+91doYV4CFWLqYTkbEeg4K5thpAAuubeFNUdgrTlsn 5FyktbUJVL8QO3aShc7JPFOCW2SaZK9M/8MkW7UVrMUzCAUx/nN+/G+V+L4ZzM6WNvd9 CywBXu5kvwBe02i6kiF93fyLiXACe+U5se6q7alCgb7MzpgKhC7PIXLyLngKU8nXpJEE CJ2Q== 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 x13si10342096pgr.210.2019.08.26.15.33.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Aug 2019 15:33:36 -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 C73E66E319; Mon, 26 Aug 2019 22:33:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oi1-f196.google.com (mail-oi1-f196.google.com [209.85.167.196]) by gabe.freedesktop.org (Postfix) with ESMTPS id E56A589CA8 for ; Mon, 26 Aug 2019 22:33:23 +0000 (UTC) Received: by mail-oi1-f196.google.com with SMTP id l2so13443235oil.0 for ; Mon, 26 Aug 2019 15:33:23 -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=JVt+vCDKgXVtdo0ejAqvuaCusDRsMqZBJphe0loOVVg=; b=gfor43rpXTHMYOqOc0q6zLwf8IYFSrgzyuLD6i7sOkr0PZwhESVk1yeT3hz5mDkpFZ n69lBsHVJIamB/ENcZMkAAHINscse6sJd56hIylhWhFAmy3v48qljBYuMZ4SLN281XQC ngcQS3KUfAWYktDXviaX2eFaOFN11Z3aHKUv97xwHloHhdB+IDcRoiMtHa7LjIM3utgG tdRH6sQKWKW1+Wkg8OyDWQb2u9czlgl3pkFgYF6l5rlA8u6hSIJDDXJn6I9++qtB32BY 77PUzvrnTmriPuX0lNlf08rnytSTn7dBePPY3RnRJ2BgdEifCXLsuxFJnFQvVkY3xNdQ 2QIw== X-Gm-Message-State: APjAAAWR788b08SnNJegNZdriJ8cqM8rJaM76jb7eeGlldE7EPy5MiBm 4OsG7OmFctE4msxejLoI7cGlll8= X-Received: by 2002:aca:4994:: with SMTP id w142mr13682915oia.132.1566858802745; Mon, 26 Aug 2019 15:33:22 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 15:33:22 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 4/8] drm/panfrost: Rework page table flushing and runtime PM interaction Date: Mon, 26 Aug 2019 17:33:13 -0500 Message-Id: <20190826223317.28509-5-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" 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 which trigger lockdep warnings. Fixes: 013b65101315 ("drm/panfrost: Add madvise and shrinker support") 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: - Use pm_runtime_get_noresume() and pm_runtime_active() instead of pm_runtime_get_if_not_used(). The problem is pm_runtime_get_if_not_used() returns 0 (no get) if in the period between the last put() and before the autosuspend timeout when the h/w is still active. drivers/gpu/drm/panfrost/panfrost_mmu.c | 38 ++++++++++++------------- 1 file changed, 18 insertions(+), 20 deletions(-) -- 2.20.1 diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index 3a8bcfa7e7b6..2204e60f7808 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -220,6 +220,22 @@ 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; + + pm_runtime_get_noresume(pfdev->dev); + + /* Flush the PTs only if we're already awake */ + if (pm_runtime_active(pfdev->dev)) + mmu_hw_do_operation(pfdev, mmu, iova, size, AS_COMMAND_FLUSH_PT); + + pm_runtime_put_sync_autosuspend(pfdev->dev); +} + static int mmu_map_sg(struct panfrost_device *pfdev, struct panfrost_mmu *mmu, u64 iova, int prot, struct sg_table *sgt) { @@ -244,8 +260,7 @@ 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); + panfrost_mmu_flush_range(pfdev, mmu, start_iova, iova - start_iova); return 0; } @@ -255,7 +270,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)) @@ -268,14 +282,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; @@ -289,17 +296,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; - while (unmapped_len < len) { size_t unmapped_page; size_t pgsize = get_pgsize(iova, len - unmapped_len); @@ -312,11 +314,7 @@ 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); - - 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; } From patchwork Mon Aug 26 22:33:14 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: 172227 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp4965757ily; Mon, 26 Aug 2019 15:33:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxp8GpW+6MbtS15/y5Jl+MQRLIVA1d3bv100LcUzgnozrIkL5bTsDBclH4SkA5ugMpX5QLL X-Received: by 2002:a17:902:bcc2:: with SMTP id o2mr21429515pls.127.1566858832665; Mon, 26 Aug 2019 15:33:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566858832; cv=none; d=google.com; s=arc-20160816; b=jbLgtTRsE2XbQArap5nSdsinJB0WUKL3aSty1UPhqFy2bUG1xaAQCE+86kEytG3Ssj 6ttC6FjmT9ItRb3dyuzlKAoMq2fWIFDL51u+uof09pIaouNXAlogYHW24FqR2WV1/7Hc sXwKarvwVkZYvVA4UEWeHnzR00CqWhfpuwCs5AjVgb2xkhHVVEfJAF+ZXV5PQLvazCLt JIAMNgBucpwsQ2tbqIHJSjSaYqYlK0QRe2nIsNtFyUTE++sX8KoR1a+s/d/5jVbUQ5i5 YNaAZDmV2PQZFAAeCN6UELtB8OfKq50vqRtN50wSaV0z1Crm+I83CYCwzGNRbrITeuYj kdSQ== 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=6wZ9gDkyNEao947tYdhIE9hBajC+mMmla4Nu4ns3XMg=; b=jDbRLG+ep8Nq42buuqFFu0WHY8hE+SqoMCIkeaskd8mknDwTC4t1T5IEd9n64j+a2e 9vrgGYHwMqjPUKgQqISFRpOoI5LFJJJMX2DQFveB4Ytnje4xKRbYXgIqGptPrvSGSsAA yLmYKgKdE+w3ftspPdTOQwMDZHCE828kPoXiGJ+9LfJK4Lg/Le9EdTR2M66YnZ/Zg0i+ 7uv7n/JfQnPonp0hk+jnve0nGzo654jymRDMUMlQ8rDabWG08mY7QGo6cQ9o1k920fXQ fLnsD+b0R5u5CQIUE5Jp9zkpdRdracKF9a802ImAyM3PIFjEQ2+HIMq7PWPBLLnxRXJK o/Bw== 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 t184si10221149pgd.211.2019.08.26.15.33.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Aug 2019 15:33:52 -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 B781D6E31E; Mon, 26 Aug 2019 22:33:51 +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 1BFA189CA8 for ; Mon, 26 Aug 2019 22:33:25 +0000 (UTC) Received: by mail-oi1-f194.google.com with SMTP id q8so13141005oij.5 for ; Mon, 26 Aug 2019 15:33:25 -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=R4jGmh892Y2Plh7rZR/Jz0sf/VgHSWV3z2nnmBNkYNk=; b=Ks3kMswmqfAqifmPDMBn1JhSFXjLOjMAzZpKKnfnKYE5WL3oFwwbSIZC+WcVkO8vGp dkA4BKt2eprVnWIalTWETa5vAQpS60c7GkeyxEihQF2kLccsbSQNX+wdsgFmWqFGnIjq IrXXz9S6EgeZrMUG6W7nE7FYW8BQvzRUhEcJOGa6QuroZnoKs+RyHG5tOm/GQeD9CQ9o izDDwO/vI1CtKkoVE2QRb+uusCZxLGp1SfJFmvGVj32vPNxN7GZ1auydXQIIwr0wkeVG al3lmCm4CqJb5hKXbGpAIP230z4aCZsdPjRlFqQyIxs4Kyi4seyYehruAcH0R0aRgTkV 1Y0w== X-Gm-Message-State: APjAAAVVzbvZmoZfRuxwTCIYTl8L9tJWQtcZR4bVKQaAUJsZFsB5rOHL KJs8X/cVUQXmDfnf3eXusoysZI4= X-Received: by 2002:aca:55d6:: with SMTP id j205mr13622153oib.63.1566858804055; Mon, 26 Aug 2019 15:33:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 15:33:23 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 5/8] drm/panfrost: Split mmu_hw_do_operation into locked and unlocked version Date: Mon, 26 Aug 2019 17:33:14 -0500 Message-Id: <20190826223317.28509-6-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" In preparation to call mmu_hw_do_operation with the as_lock already held, Add a mmu_hw_do_operation_locked function. 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: Steven Price --- v3: - new patch drivers/gpu/drm/panfrost/panfrost_mmu.c | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) -- 2.20.1 diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index 2204e60f7808..3407b00d0a3a 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -80,19 +80,11 @@ static void lock_region(struct panfrost_device *pfdev, u32 as_nr, } -static int mmu_hw_do_operation(struct panfrost_device *pfdev, - struct panfrost_mmu *mmu, - u64 iova, size_t size, u32 op) +static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr, + u64 iova, size_t size, u32 op) { - int ret, as_nr; - - spin_lock(&pfdev->as_lock); - as_nr = mmu->as; - - if (as_nr < 0) { - spin_unlock(&pfdev->as_lock); + if (as_nr < 0) return 0; - } if (op != AS_COMMAND_UNLOCK) lock_region(pfdev, as_nr, iova, size); @@ -101,10 +93,18 @@ static int mmu_hw_do_operation(struct panfrost_device *pfdev, write_cmd(pfdev, as_nr, op); /* Wait for the flush to complete */ - ret = wait_ready(pfdev, as_nr); + return wait_ready(pfdev, as_nr); +} - spin_unlock(&pfdev->as_lock); +static int mmu_hw_do_operation(struct panfrost_device *pfdev, + struct panfrost_mmu *mmu, + u64 iova, size_t size, u32 op) +{ + int ret; + spin_lock(&pfdev->as_lock); + ret = mmu_hw_do_operation_locked(pfdev, mmu->as, iova, size, op); + spin_unlock(&pfdev->as_lock); return ret; } From patchwork Mon Aug 26 22:33: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: 172224 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp4965587ily; Mon, 26 Aug 2019 15:33:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeqzi8QcpJATeDDfrK+iH427opuD9W+jVd90qox/F5G8jgXUf0AKbF7AEvGdNGB8RODKqv X-Received: by 2002:a63:1749:: with SMTP id 9mr5412629pgx.0.1566858820361; Mon, 26 Aug 2019 15:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566858820; cv=none; d=google.com; s=arc-20160816; b=NRA9k2azApuXK5wWi7rGZOPrYLVJNhJWkN749JvgCIDE3s1oAB/OcPcbrWZTZaIavL R7guQSXaUMdPw+/f4NTE1MrhZTSmdnhfw5B+llm1om0/4zMUrvidP1PcSNxNHgXlZuLm +EimhPdfXs+hCH8yfYOqcO49s9/M/jwOQo8O98M4K/OHUOkvMklHKU6HPz2JfcumAp9L MRMGWih+lK1h3xclGJpsSYj4MRYQKfcBis9wyipLREB26c2ZLNmXfdqItRoBFcQe+vjv VLYNhkdCDUGSfB++c8BCqgmYbeSb9G4c+JSbfP1CYmbpWTXV1CGnnWO/JeRxtL1amsHo GCGA== 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=J5hoEMeUnzLbBSBCzfINfR9nRIzJ+PM5+PSkQ4QYO7o=; b=HU8fNZE7n87HV0DFfWZNeCFdZEq2q1E7uIjFC2HE+K90S05HFLqI5b04pkl+X8c5nI sq6DaqrQxtAzKdxZRIUmq8dFLvSBz2x4LvAdHaQQnWzQOznln58RO1qJWrOcZhz4kWBB wBIwoO2uSltrPzCEBwT5YVNQQltePI/YJ6EoCQAg5Z9OEtLLUX9qqfwgJ+L54MxSbxbY Qouu35moa/FOrbHklyCMNofZgBwyVw36vfOcmOvLFWNFBV8LpuwheOvDRm4W7ee8IJD/ JRTlrsjpszi3iFi2FeGT7PoKSJw9cp3F9JdpC+aZs04jepp6Vk9HFTiTAHb+JqyxIIEP iYgA== 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 m22si10047151pgh.190.2019.08.26.15.33.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Aug 2019 15:33:40 -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 523A66E31D; Mon, 26 Aug 2019 22:33:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oi1-f196.google.com (mail-oi1-f196.google.com [209.85.167.196]) by gabe.freedesktop.org (Postfix) with ESMTPS id 42FD46E319 for ; Mon, 26 Aug 2019 22:33:26 +0000 (UTC) Received: by mail-oi1-f196.google.com with SMTP id t24so13387936oij.13 for ; Mon, 26 Aug 2019 15:33:26 -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=jPADKAc1YpBP/58ELuIEmfq6MEoLY9KP0v1RLwFzTo8=; b=MyixUtirrt03G8uxLBT8N1TiME6Sr8NklnSFFRljX65o5XyIdurs18llY/rGeMDFUh Zgd454UfkBa1Rfi5rcmp3+xuWBlU6VMD0k1Fzsd0dYrOF+q3QilwoRQ4DSCKT5dmHYi9 bh9oR491Vx4rsoXVxOC5MwuEmEB5t3d7Bd2uIOMCJ851UyhnRLxRsaJqp1iLPMABePV+ Wuu2yaaopLD6L22xXbS8Gf+XR/mWa15DFb/W/xf7Ys7BW+iiwESchbfHC57jlX8Z9dex JOHEynohPqWGYNwkYYPyAbqgp1FOayV7YBTReiK3akmys1eI6obuwTpnW/6DjZaFCJGh 4t1A== X-Gm-Message-State: APjAAAXSXIzTdvHKnqGqb7mjViTns9E22Ytujj7yQbd3KtiI23e8PKkJ Ai9hSrkjdH7ZbB3BQDnfojVOoUk= X-Received: by 2002:a54:4508:: with SMTP id l8mr8259245oil.90.1566858805090; Mon, 26 Aug 2019 15:33:25 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 15:33:24 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 6/8] drm/panfrost: Add cache/TLB flush before switching address space Date: Mon, 26 Aug 2019 17:33:15 -0500 Message-Id: <20190826223317.28509-7-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" It's not entirely clear if this is required, but add a flush of GPU caches and TLBs before we change an address space to new page tables. 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 --- drivers/gpu/drm/panfrost/panfrost_mmu.c | 2 ++ 1 file changed, 2 insertions(+) v3: - New patch -- 2.20.1 diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index 3407b00d0a3a..d1ebde3327fe 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -115,6 +115,8 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m u64 transtab = cfg->arm_mali_lpae_cfg.transtab; u64 memattr = cfg->arm_mali_lpae_cfg.memattr; + mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM); + mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), transtab & 0xffffffffUL); mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), transtab >> 32); 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 \(Arm\)" 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); } From patchwork Mon Aug 26 22:33:17 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: 172225 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp4965619ily; Mon, 26 Aug 2019 15:33:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxh7Ef5WpLtI7ZJstBVz7zcG8iQdIrc1oTJRfe4V2OSbXOMwCuDt5yKe0lbJix1nohmm5p+ X-Received: by 2002:aa7:8108:: with SMTP id b8mr6417951pfi.197.1566858822557; Mon, 26 Aug 2019 15:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566858822; cv=none; d=google.com; s=arc-20160816; b=ycfyQMvDjJPGOxoS18evJr1HtOZLXvJNlHsmR9Pt5qnGxzzLnkqt8Oz9ibdpNAwmOx jq6NMA2laPy6v0cKJR7GRWSnS/PQ3cQ6FJP1c7Q6c98xYq/jRd8MlFe8sPqPYzGTRPQ9 0H5u3mXnVuYRIGYT0Rv4PztR/hYaB01IwAu0u38sTC7t7kxbyaPKfU0GXosRP1Vqs4W4 ZoaMQwgT134sQMJOcJClRuOk1Bae3aAY4MLBis1BzQlOXOFMlt9PY3tTSOUMBJ9cchGk c70rNkn89QBbwrOJe746bvllJ0z1MRiZBjy6s1+dCOvSs2oUl0vbPMUPiFPT68GlURQF Kfqg== 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=6R6Z6BmuwgXboh2rR1YGxPuYKp+3dbnYibRoIa2fVxQ=; b=MPWM3x5VdTpbJ34VUNWzp+euKkCwfbSvujUpQfph/pAO9TJuYEJqbOBTCzOS5ohGNg uK0CttYdr4ubkmgvcfYDNla2nLyayKr4DUrrxyd1/bkHsV1DUhamSImvPDz8uZOyTENv nM6WlXtvXGxyUcYS7pRhD/jbh4t8P9sp6lxhe6fi6ZTsN6MrOnqz8SqBNGnCdMa9E04H JoLBOFn/uSnb8nVPIS79AFwH0kUma2QX6zCAEHBrz3lQwWsSb3EKnMLVdiGh4LxIV8qc tM5wNzmIEVg8LbHiuQ8OFsQo2a+2PBpm1OhpXkc4NRxsf0IlHCWiTEGykq6er1DdIh7n 2jLQ== 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 y5si10945523plt.128.2019.08.26.15.33.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Aug 2019 15:33:42 -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 CDC326E320; Mon, 26 Aug 2019 22:33:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oi1-f195.google.com (mail-oi1-f195.google.com [209.85.167.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9EF3789CA8 for ; Mon, 26 Aug 2019 22:33:28 +0000 (UTC) Received: by mail-oi1-f195.google.com with SMTP id o6so13405481oic.9 for ; Mon, 26 Aug 2019 15:33: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=2f3o189Bj9Dp2uZTE2x4J7wjSYnkVvJZDV1ZxRluuIQ=; b=bAZDIL2MM8zEXXRVAwJLzY6NOQ2m/qOYCTzUwLEUUrpTtTOniZ/S7mDIyFFv44sQkx BtFM5A9sym32G615yP7BcpNZFmdxsQyjy406nDwbO9JN+uCvesQ4tjZI7/1EDCO7MiVb SXaCC7p/G3MoufEEE/RxAoErE+3FKbX5048iKnaUUb/0pXJmSDNwYMPkhk7tg63dQySL 9qbbkE8mKSDPlYYvIhyO1D1NmrH3LxDhrHWD60QJdf8V0J/TKjDmzdZMJaR8E3sobjHU 5ui+f6G42yXBJ6Q+sJUB9EOwq6WE5sFCas19XNRUg8Pc30lF7d/QjdpbaUZUOwr0sV/O vA5w== X-Gm-Message-State: APjAAAUVrkWIzIDKfQcOkyEkSFPtIfZ0QftBix4VODytx94zJJq485AT JakWJYk68nWbtrFknkwDjUozpFA= X-Received: by 2002:aca:4d85:: with SMTP id a127mr13779985oib.3.1566858807186; Mon, 26 Aug 2019 15:33: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 e22sm3668959oii.7.2019.08.26.15.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 15:33:26 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 8/8] drm/panfrost: Remove unnecessary hwaccess_lock spin_lock Date: Mon, 26 Aug 2019 17:33:17 -0500 Message-Id: <20190826223317.28509-9-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" With the introduction of the as_lock to serialize address space registers, the hwaccess_lock is only used within the job code and is not protecting anything. panfrost_job_hw_submit() only accesses registers for 1 job slot and it's already serialized by drm_sched. 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: Steven Price --- v3: - New patch drivers/gpu/drm/panfrost/panfrost_device.c | 1 - drivers/gpu/drm/panfrost/panfrost_device.h | 2 -- drivers/gpu/drm/panfrost/panfrost_job.c | 4 ---- 3 files changed, 7 deletions(-) -- 2.20.1 diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c index 73805210834e..46b0b02e4289 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.c +++ b/drivers/gpu/drm/panfrost/panfrost_device.c @@ -124,7 +124,6 @@ int panfrost_device_init(struct panfrost_device *pfdev) INIT_LIST_HEAD(&pfdev->scheduled_jobs); INIT_LIST_HEAD(&pfdev->as_lru_list); - spin_lock_init(&pfdev->hwaccess_lock); spin_lock_init(&pfdev->as_lock); err = panfrost_clk_init(pfdev); diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h index b7fa08ed3a23..9c39b9794811 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -63,8 +63,6 @@ struct panfrost_device { struct drm_device *ddev; struct platform_device *pdev; - spinlock_t hwaccess_lock; - void __iomem *iomem; struct clk *clock; struct clk *bus_clock; diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c index 18bcc9bac6d2..a58551668d9a 100644 --- a/drivers/gpu/drm/panfrost/panfrost_job.c +++ b/drivers/gpu/drm/panfrost/panfrost_job.c @@ -141,7 +141,6 @@ static void panfrost_job_write_affinity(struct panfrost_device *pfdev, static void panfrost_job_hw_submit(struct panfrost_job *job, int js) { struct panfrost_device *pfdev = job->pfdev; - unsigned long flags; u32 cfg; u64 jc_head = job->jc; int ret; @@ -158,7 +157,6 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) cfg = panfrost_mmu_as_get(pfdev, &job->file_priv->mmu); panfrost_devfreq_record_transition(pfdev, js); - spin_lock_irqsave(&pfdev->hwaccess_lock, flags); job_write(pfdev, JS_HEAD_NEXT_LO(js), jc_head & 0xFFFFFFFF); job_write(pfdev, JS_HEAD_NEXT_HI(js), jc_head >> 32); @@ -187,8 +185,6 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) job, js, jc_head); job_write(pfdev, JS_COMMAND_NEXT(js), JS_COMMAND_START); - - spin_unlock_irqrestore(&pfdev->hwaccess_lock, flags); } static void panfrost_acquire_object_fences(struct drm_gem_object **bos,