From patchwork Thu Apr 18 08:41:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 10906647 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E21F614DB for ; Thu, 18 Apr 2019 08:43:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB264289F5 for ; Thu, 18 Apr 2019 08:43:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF28028A3B; Thu, 18 Apr 2019 08:43:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 54249289F5 for ; Thu, 18 Apr 2019 08:43:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 12F406E0D8; Thu, 18 Apr 2019 08:43:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 853626E0D8 for ; Thu, 18 Apr 2019 08:43:36 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id f14so1337299wrj.5 for ; Thu, 18 Apr 2019 01:43:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=XaG+VmIuFzFcyeH04Vkt+dOmHujdLld/OhJ1u+Y9zcc=; b=g1GsoYyjcj8SpAWoOVLmmwlWs7+j3fcKDlLSiJl0rkgtTyu9e+o2C6a420udlswcFD o3mCHMohrPZ7XZ1fNUOkcZKEz6U56w5HYguViZObUT/K3GB4lZNbpN4MJWrrrNvY2gpY 8ytHpRFpWNCsTT2xoOC7mMq4+VJ+js2hN2A7p6BoZ7Zy4vF46UOi55DxbonPPzkqBSkJ VdUS5NlSL/vw772J56ZPqQsRd2AakyYnrtW+arKE1CnMPyEyx6bf4pZ6ZvXSaAWMP9qN pkhJSjUzRQnkQbiTgJYuud79Rz2CEy8JA0RdxqBnKFp14KrGtvxFm7XKKWHgQeWK3Kd6 BAAw== X-Gm-Message-State: APjAAAUxaN07c2B/dYpgV2SbHuG1ikOCf7oXBBx8ihlgoKQiob4+fXKV NHo7hT/LQTOWhUL/MiQR9VE= X-Google-Smtp-Source: APXvYqyCZ0rGrpXhrVfkpy+bQqBaL0cJax9xOY+BKtTwwWH+PBy06FTHLi0wDJxfQuL+aFrl+1CVJw== X-Received: by 2002:a5d:4588:: with SMTP id p8mr1483240wrq.155.1555577015208; Thu, 18 Apr 2019 01:43:35 -0700 (PDT) Received: from cizrna.lan ([109.72.12.122]) by smtp.gmail.com with ESMTPSA id w14sm1767733wrr.16.2019.04.18.01.43.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Apr 2019 01:43:34 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [PATCH] drm/panfrost: Prevent concurrent resets Date: Thu, 18 Apr 2019 10:41:48 +0200 Message-Id: <20190418084305.45021-1-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XaG+VmIuFzFcyeH04Vkt+dOmHujdLld/OhJ1u+Y9zcc=; b=kHcVB/38JpLU+vYPNimis8TXXS5FAWmQ8MKBiuQmWS8YQ8Z5jRue/GIBHUEC65BdO0 fIzHjto/uD8UAY74AVFihjrm8IWVULu4SeXMgFF6hOyY7kTUJYfX9RdecbHcRV6K8t6z HOEfIu8piiAv9nCTZaDTU9wkevPk4Yp4R2F2GKqEXIg0KA7qL5CdluL2ZRQ/l/KqOEde y14bs9iwXYKeleHVgTs0+opAvRymwlVXi366MvgzxnkaGfEUgYQJgsmLv/Sv9zabEHnu 7q8k9V+kCo3wmOmtnWAmqup/XApNKMDido8sE2st3UW+eC+dDI7zXr/ikEKe3TpkqIrR rGIg== 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: David Airlie , dri-devel@lists.freedesktop.org, Tomeu Vizoso Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP If a job times out in slot 0 while a reset is performed because a job timed out in slot 1, the drm-sched core can get into a deadlock. Signed-off-by: Tomeu Vizoso --- drivers/gpu/drm/panfrost/panfrost_device.c | 1 + drivers/gpu/drm/panfrost/panfrost_device.h | 1 + drivers/gpu/drm/panfrost/panfrost_job.c | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c index 91e8fb0f2b25..970f669c6d29 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.c +++ b/drivers/gpu/drm/panfrost/panfrost_device.c @@ -98,6 +98,7 @@ int panfrost_device_init(struct panfrost_device *pfdev) struct resource *res; mutex_init(&pfdev->sched_lock); + mutex_init(&pfdev->reset_lock); INIT_LIST_HEAD(&pfdev->scheduled_jobs); spin_lock_init(&pfdev->hwaccess_lock); diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h index 1ba48d105763..56f452dfb490 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -78,6 +78,7 @@ struct panfrost_device { struct list_head scheduled_jobs; struct mutex sched_lock; + struct mutex reset_lock; struct { struct devfreq *devfreq; diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c index 0a7ed04f7d52..a5716c8fe8b3 100644 --- a/drivers/gpu/drm/panfrost/panfrost_job.c +++ b/drivers/gpu/drm/panfrost/panfrost_job.c @@ -384,6 +384,8 @@ static void panfrost_job_timedout(struct drm_sched_job *sched_job) job_read(pfdev, JS_TAIL_LO(js)), sched_job); + mutex_lock(&pfdev->reset_lock); + for (i = 0; i < NUM_JOB_SLOTS; i++) drm_sched_stop(&pfdev->js->queue[i].sched); @@ -406,6 +408,8 @@ static void panfrost_job_timedout(struct drm_sched_job *sched_job) /* restart scheduler after GPU is usable again */ for (i = 0; i < NUM_JOB_SLOTS; i++) drm_sched_start(&pfdev->js->queue[i].sched, true); + + mutex_unlock(&pfdev->reset_lock); } static const struct drm_sched_backend_ops panfrost_sched_ops = {