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 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;