From patchwork Fri Aug 23 02:12:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 172076 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1625ily; Thu, 22 Aug 2019 19:12:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzG4j3BlM4sOspOT98rtz2ETzvl3P/Q/PYWw2rKo1wyTPacOtSf1RNmTby+XbM2+rkgq0L9 X-Received: by 2002:a17:902:9041:: with SMTP id w1mr2069853plz.132.1566526349817; Thu, 22 Aug 2019 19:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566526349; cv=none; d=google.com; s=arc-20160816; b=QwRrbQFriBAJw/whAs3pnKQxvPZHHZBeN/pHpVoADfG3BaAPdY/xN6Fv+c/1tOGZ+9 bAMNtlbdy6sRhXmMf9NN0JlZwyxlzK0QZkhkbKUomyk117JNj0g6wPytahRUQFJtqPT7 OsuwTAqfgFkofMq+UPEXR6Kb448+CuIvFsgWFVZ65fVFlTOoDLM5H7M01I+CMy9myRzL zgP7wHPxRbtoDhkohtSnjlMWnz3hhUYLdY3METZWqnEnpSofkrMkqaMrL+64ttMDP1lI X8sCoUlbK013vyft+lnzPTZ5whueJD5CkAXA/YqRZAwz5nGy9/gh2m+UwTnRqV7bUn3w JAdw== 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=l+29fQl4Dnqcyp+PDB2nKswG3Hq5NgBxDL6W7mYmpcU=; b=ZM2k4/XoC4Dl66M1lGN+rwuxnS202rfUCPrYhsukKgO4L42Hq9ElVJyfPImyWmm4Od 9FGAAUmlfl/KJApzCah/5mFUWzvRU3asyMURNP71mxYmrLD0Jq/tGU1rQc6Wb2ccigOu FN/jXpPZ2BNnvcOjntor9gU7hNEwid/5bkyJLmKl7o1hVE9YbF2/tuMx3fs4p39JI7aO VikCZVufrH5YNLAyQp6tftBQZok9NZSxtlRzJR7bGvJE3LFBgmIWdXdhoqHE6DLPUCoz gdr3FUyuSb5BsNvGCR/7Ukvq9AgRzcDsGz1wBU2snphtEQT43MxYQsN8UC5UlmaHpZ5X 3N0Q== 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 q23si1045831pjp.76.2019.08.22.19.12.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2019 19:12:29 -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 626A66EBA3; Fri, 23 Aug 2019 02:12:25 +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 D0C256EAAA for ; Fri, 23 Aug 2019 02:12:20 +0000 (UTC) Received: by mail-oi1-f195.google.com with SMTP id q8so5637206oij.5 for ; Thu, 22 Aug 2019 19:12: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=CtVv9KmOH1uY8onE46Ao79LAatPRJtfqcOsRBmR2M9Q=; b=lm7NrdhvRCY0ZW8DYbYnmfw1iRUuCluNcwJFuHNbL96EkrCXtu42+sOfrdQ0Dil6Rd ClV5kppI0iM3yQUUDQImHO+dsWcmgCJJ6Nq/3oqykQt8OcwJQgrCXHN6XzsUaCSZ0twS AuRU3mcFxPOFhzAlkLLdZQJvuofpOcWlrjdfLkz3ICkdYyXd1IbKI23dX/13k+8S7y9W MvKhfD+jcNjukB9JxJGwWRJDQScYTbDXPwfCUYnMreqvmNRjkxHMk4QvYk+BFQvmrXm5 ++vQ3O52l7shgpTwJ71xUeS/cC2Uc9WWOZDTi6g+/9JNy78373S/7G2vFsCdV+a0rnR0 DJ8w== X-Gm-Message-State: APjAAAXEf44elJACY+t3qMEidkjMpTQX58g6oanrZ44ZrC9UK3Yt3FYG DETiry1arIJ+CyoaHUd62eHZ36U= X-Received: by 2002:aca:dc88:: with SMTP id t130mr1435568oig.43.1566526339704; Thu, 22 Aug 2019 19:12: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 c1sm457747oic.31.2019.08.22.19.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 19:12:19 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/8] drm/panfrost: Fix possible suspend in panfrost_remove Date: Thu, 22 Aug 2019 21:12:09 -0500 Message-Id: <20190823021216.5862-2-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" Calls to panfrost_device_fini() access the h/w, but we already done a pm_runtime_put_sync_autosuspend() beforehand. This only works if the autosuspend delay is long enough. A 0ms delay will hang the system when removing the device. Fix this by moving the pm_runtime_put_sync_suspend() after the panfrost_device_fini() call. Cc: Tomeu Vizoso Cc: Steven Price Cc: Alyssa Rosenzweig Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring Reviewed-by: Steven Price --- v2: new patch drivers/gpu/drm/panfrost/panfrost_drv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 44a558c6e17e..d74442d71048 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -570,11 +570,13 @@ static int panfrost_remove(struct platform_device *pdev) drm_dev_unregister(ddev); panfrost_gem_shrinker_cleanup(ddev); + pm_runtime_get_sync(pfdev->dev); - pm_runtime_put_sync_autosuspend(pfdev->dev); - pm_runtime_disable(pfdev->dev); panfrost_devfreq_fini(pfdev); panfrost_device_fini(pfdev); + pm_runtime_put_sync_suspend(pfdev->dev); + pm_runtime_disable(pfdev->dev); + drm_dev_put(ddev); return 0; } From patchwork Fri Aug 23 02:12:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 172075 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1570ily; Thu, 22 Aug 2019 19:12:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqycnX0dmvNzTVzFjGu7tHMLUlTnsv27WnceviE50qCGDkw8b2CyRyNRCi9W5yAVDk7cqy+Y X-Received: by 2002:a17:90a:e2ca:: with SMTP id fr10mr2868172pjb.72.1566526345819; Thu, 22 Aug 2019 19:12:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566526345; cv=none; d=google.com; s=arc-20160816; b=g4P97Yo+qlvKdY9ns14pUCrcsxJP5Be2+WvdDagGZQjawgS2qfw5x35bXgE/7lerlu xdx+ztSf87hDLmvvdBnA7RfNVYctcCy/fvz/48UH7nnw16mXgz4oZKLlVM1DWRE4uYBX qonzwYOHFiI0/O9728mhyY3zmpxPkIXv/cBJvXuQfdseccoDIvQKfiMBnms843MrZyUd 08i1I2veNTaog6ldkWn1mJ0CXimsetgY2pOzDzovETTNe+Psu7/LcWKXCyEP1uUvX6vv f0yTRi1HuJdITdj+QkzYo9Oektp1BsuSrIZHRSYuvaWdkO0L/wHwHfQJRhvbAIptS1OD Q48A== 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=Szg7dU+xm4QYA9SPmlfr8Ok44itv5wlcv+QgZ442Vj4=; b=M7eFvrVq+xsAzK9Zif3CWgbzHds9PsK8WP6f1TwRq8wUqFPZ1inucvhDlEe/NuuVin JwraXD8V3G2otinqngl+U1SdEDf2K6n2S4ooC56NEsJ/4e383mxP2HU/XNxi0KvQrj9e 62YaiAM1kddG+7ogawSvo5xFRTsQTe6BV61VSYpdzVaCQJCOnoO9ZKlNddZFYuOMafqA lCG0ol3eX2/Lsx26WfeXIwH79x87xzJmkQz4LK6z24v9cY9RwJjEhxywah/aqYoLBF5g wCiQJDozXS+SU1jQKQAF/6z+H+XjvT61QagHs7OdBxkzWwK/hRHDngZH2z3rwZIhHBJ/ vZqg== 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 l65si1100287plb.312.2019.08.22.19.12.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2019 19:12:25 -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 680476EB21; Fri, 23 Aug 2019 02:12:24 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0AB856EB21 for ; Fri, 23 Aug 2019 02:12:22 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id a127so5929085oii.2 for ; Thu, 22 Aug 2019 19:12: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=fYbwrgvdXN8jjHtFDjFYgPFUHMXy/bFl85EmNqO4GoA=; b=tye3nwEsNxKHAwaBrGEfxPn74NCiu+2Vb9sHQkrrD8C2sFEMEtWPpwAN1erZvKPi8l jXhNxZWwQfm9LVt6ArqokHV52cNjOBrVcD9d6Pbhm7r++IwgBipPlUUiFSbDV2IsECT4 uNUZY8064PGfBZLFWTpVqUW1aYICUPoHsCu54+Jj4N8mg8deO2nbOHiUiBbjlG69JETT EvK1k5G5HoCGAnRUnqCjmjwidhOg67MBontTblizGgPH+OTd8n9Lz5ULTN7tHbH0BQBs cftlyO91h0A/NAcGLAO10lJ5LbqrIhsgudSNvafOUTf/PsEN4MALh54z2UKgnEGdmrYv xGLQ== X-Gm-Message-State: APjAAAUruB81TjmaYp1+5GP7mhrRiEO17VpwNHrRTFl8KESuwomE1jDp ptSq5LHZBGipvX3+RWpi9sfyMbs= X-Received: by 2002:aca:eb85:: with SMTP id j127mr1554378oih.177.1566526340953; Thu, 22 Aug 2019 19:12: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 c1sm457747oic.31.2019.08.22.19.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 19:12:20 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/8] drm/panfrost: Rework runtime PM initialization Date: Thu, 22 Aug 2019 21:12:10 -0500 Message-Id: <20190823021216.5862-3-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'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: Alyssa Rosenzweig Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring --- v2: new patch drivers/gpu/drm/panfrost/panfrost_device.c | 9 --------- drivers/gpu/drm/panfrost/panfrost_drv.c | 10 ++++++---- 2 files changed, 6 insertions(+), 13 deletions(-) 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..f27e3d6aec12 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_use_autosuspend(pfdev->dev); + pm_runtime_set_autosuspend_delay(pfdev->dev, 0); /* ~3 frames */ + pm_runtime_mark_last_busy(pfdev->dev); + pm_runtime_enable(pfdev->dev); + /* * Register the DRM device with the core and the connectors with * sysfs From patchwork Fri Aug 23 02:12: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: 172081 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1813ily; Thu, 22 Aug 2019 19:12:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUobxbnfohJaGpdFASyXVc3XMxy9buSUoithY7D3vOV+gfjBgKmPjrcQTWRrXr6xdu0pUa X-Received: by 2002:a62:5207:: with SMTP id g7mr2532850pfb.152.1566526362621; Thu, 22 Aug 2019 19:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566526362; cv=none; d=google.com; s=arc-20160816; b=wtRw049LQBkb4mFVmU2hF5TerO+GPDgNyhSb+vSZZ5I0e+OYf/Mb99PH+h/Vw9jcuX LlJAZ+rzgY1yqthdl71mbEm0R+Rs3F1y9tb+J0cw440hK6YPHOXiMfr9zWexH7EPthRS pwsVeduhe3hRZlxz7G3fDpekv/pVWWoOG5SdQoTaLGEbcckCi8UBg57fRBB8ke0MiPgi rv8iP10R/Cwig2u+nGBSyqlWY8g2Xlxn5/DrHJhMD9RAXVFlrN2XJ5aPJ8fpmCInesdv pSxz9AWQQTCHCMm0fZ4QfrCENfIzSkgOhvF2ylujKvHMguxOZ7Y+VfaIQ8xkAhKdmBwm 2PYw== 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=aLfLr1+WwjRYQS/V+DL46E7Y+uHiMOlFAHiDoOM5MIY=; b=A5tT9uVNu/EUI1Pt1BdWGnscvP81dYsVcNPAIp4ddsRfhmUTh3AjLp1AYrG3mqjrRo RZvhHSS5tqNDCFUtgt75xsESz1u+mV29KGjTxmia/BHX+R/fCujWSdeTZbbpdz5O0YNC cwsrmjDwLEqndJq9VrfPNi0oZkEJCy2hMIBSB3rJmnQ72QdD6dJj7xs5Y0rQDUl2t5Am CCuhMy7NSXgeC6jsICoqnmz3mgSi9xRtYyY4VORFAsQNgSvzJrgw1Yo0rY0/sNlNFNJi /RuAq6zK4JH+6LH90CRPGwGXpw7iQ2i2zl/YAzOH0UEtHGb1wGlIp2F1VmsC2BTAYCZf qwZw== 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 h25si1193651pfn.56.2019.08.22.19.12.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2019 19:12:42 -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 5C8816EBAA; Fri, 23 Aug 2019 02:12: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 3F5686EB21 for ; Fri, 23 Aug 2019 02:12:23 +0000 (UTC) Received: by mail-oi1-f195.google.com with SMTP id l2so5938468oil.0 for ; Thu, 22 Aug 2019 19:12: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=k+NTlGr0d+34j78gJ1Mf4qbMv8Jq5bw97eaaB6YOzMs=; b=JWsXboN9HFM4o6+2Y1ad2KtW0INYTtdu6oW08DaDtn0mwSjZ8yTOQicv+XkExIV7Zp k80BYci+ylqOIXighVlygELESViMy/Wvo9S/AzpoB3X3PQnVr8A2KAHXbT9NtQUsFvU8 c8TFQAEx8lCPWr3C+xGP+YqkMDa8Uz1UVreXn3I8aWdHvc93OYkMOmWfrJ4NtXsbI2tD om375rYvqCMEGFNMz0f4hjc7MJV79NFJHi044OuGF/SyQkKcL3o5Fj/aGOd1yrvz9/X3 1J+jMjSDNuJx1dYmT+o7xv2ULMzvbj7HFXGbuqMBhoa7uvtrD7Dlw6kdeCVPUdtKxVZc Tk/Q== X-Gm-Message-State: APjAAAXkZpFL3/4Mavsdd2iFQsyh4q0PTao6znahWXzpNSwR3CU2/vIL TNb96PO6+OoTWXdK2JV54MrVvXo= X-Received: by 2002:aca:cd12:: with SMTP id d18mr1577251oig.68.1566526342081; Thu, 22 Aug 2019 19:12: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 c1sm457747oic.31.2019.08.22.19.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 19:12:21 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 3/8] drm/panfrost: Hold runtime PM reference until jobs complete Date: Thu, 22 Aug 2019 21:12:11 -0500 Message-Id: <20190823021216.5862-4-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" 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 because we are relying on the autosuspend timeout to keep the h/w enabled. Cc: Tomeu Vizoso Cc: Steven Price Cc: Alyssa Rosenzweig Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring --- v2: new patch drivers/gpu/drm/panfrost/panfrost_job.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c index 05c85f45a0de..80c9cab9a01b 100644 --- a/drivers/gpu/drm/panfrost/panfrost_job.c +++ b/drivers/gpu/drm/panfrost/panfrost_job.c @@ -151,7 +151,7 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) return; if (WARN_ON(job_read(pfdev, JS_COMMAND_NEXT(js)))) - goto end; + return; cfg = panfrost_mmu_as_get(pfdev, &job->file_priv->mmu); @@ -187,10 +187,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, @@ -388,9 +384,13 @@ static void panfrost_job_timedout(struct drm_sched_job *sched_job) mutex_lock(&pfdev->reset_lock); - for (i = 0; i < NUM_JOB_SLOTS; i++) + for (i = 0; i < NUM_JOB_SLOTS; i++) { drm_sched_stop(&pfdev->js->queue[i].sched, sched_job); - + if (pfdev->jobs[i]) { + pm_runtime_put_noidle(pfdev->dev); + pfdev->jobs[i] = NULL; + } + } if (sched_job) drm_sched_increase_karma(sched_job); @@ -455,7 +455,9 @@ static irqreturn_t panfrost_job_irq_handler(int irq, void *data) 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); + pm_runtime_put_autosuspend(pfdev->dev); } status &= ~mask; From patchwork Fri Aug 23 02:12:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 172080 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1786ily; Thu, 22 Aug 2019 19:12:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2BSHv1h28Bc/PBVlHAA6Ko6dLbXfI1N3q2yAWvo8o+NqklvEt6uNJ0pGvFpXQ/MPfghNF X-Received: by 2002:a65:6904:: with SMTP id s4mr1858324pgq.33.1566526360924; Thu, 22 Aug 2019 19:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566526360; cv=none; d=google.com; s=arc-20160816; b=D7iESdV1kcoBENtpneVApSspunhFZ3M6vFGfBbPr5vJ0dHxPhqik7T1PAJI4W2BhQn OCF6wXWXxSvQsoLolD1ino1osvkwE+IGUwEJWLFwdyieVo0zDpHL0PxTba4axcKAiaUE p8awMIQ/ADVcxvNnL1Oi31AB4wYYIsTBbcvF4M61kEv6CZg9kP/b5X7NDI0aCsMUOcXZ mGapKLHHVGC9ARzRw4ros3io4rsGUGgD4pIJ8uAbuo4MKOv5tysI0eAWxP9QPfMv89I4 kCQJWruGzttfSz3InKT3lN5bwccxLVTqIDXtT4dsaz2qt+zMiuUXuFJmBXMn4AhVrY3B 1FbQ== 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=mpBLPkZIj951jHj6RXGuPCGzvi8zgVhic1rAYiAcQ4I=; b=Yqch9MOiTNqw80Cb7iyi+NEIrCh0NJz0S+j3spIV+/Mz1clBxFEHlcjig1aH6xGSjj HWC3KjdVhBks7OOOciWMUOKNXGAKtZk1K4W2N6Nr9NmXg1JSNtQkyH6ScW/38D+3fA07 nuT08v+4LFcT/kAk40ohOtfioHwcCNfQWxQ7OwikoLR/LAerTQe7R96teifVzu7D9Urk PhkwwmM0ISj4GfBrab9FCh+NaTxp8rFmw4q7E8L8MPZSLuM2021Fwsvy6EqnX4kG2viA qnlZ9+1PlU2D24AGI+UIy5WFzuLNiAVLKa51H98uzygfucuNluQqOdx2mbgVPuNWWTul Bh4w== 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 h21si1095720pjq.19.2019.08.22.19.12.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2019 19:12:40 -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 DB5906EBA9; Fri, 23 Aug 2019 02:12:38 +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 A02A76EBA3 for ; Fri, 23 Aug 2019 02:12:24 +0000 (UTC) Received: by mail-ot1-f66.google.com with SMTP id b1so7390873otp.6 for ; Thu, 22 Aug 2019 19:12:24 -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=LH1bRwy5I9A+NDROM4NYf/ieDn59EUywDqCfaAShmXM=; b=dbTajU5D2Fjsr/WUIIuiRvwyJeTmOfD9XCz3lJTpQbR9x1FWRuJyVNF07GIlriPqfu R7NwVpkAv2vu2Td+x6N1DZxsxwE6foT45uGR+nNgfx1lkLd22ByMUTobHksc2vEl3f6v wopihC6eL+ih+Hslk8pqoIVTIoSNdKb1USYm7IgLA1lbGehI6d4Ky5UCMvvGVVvtgvM/ H0DsERutzQXWv5KhkSm1agdWSPHvqROyKdcZyIU9pxwjBoul2qyW6if79vHnIR7eh7DB 9QrPNDq9KN8aEzyv9RSWgUBMdcKU6PZVFY1WHY02lYWPe9Hyf3osz35juqXFDqK/9fLL 6UFw== X-Gm-Message-State: APjAAAV9/OWvGQOVZudYjDBKUA83Quy6Jmyc3ys1oxFECTpp0PQG47/V BcsmHwsahRAQnmfggjafEF/haUA= X-Received: by 2002:a9d:645a:: with SMTP id m26mr2091155otl.211.1566526343528; Thu, 22 Aug 2019 19:12:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 19:12:22 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 4/8] drm/shmem: Do dma_unmap_sg before purging pages Date: Thu, 22 Aug 2019 21:12:12 -0500 Message-Id: <20190823021216.5862-5-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" Calling dma_unmap_sg() in drm_gem_shmem_free_object() is too late if the backing pages have already been released by the shrinker. The result is the following abort: Unable to handle kernel paging request at virtual address ffff8000098ed000 Mem abort info: ESR = 0x96000147 Exception class = DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 Data abort info: ISV = 0, ISS = 0x00000147 CM = 1, WnR = 1 swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000002f51000 [ffff8000098ed000] pgd=00000000401f8003, pud=00000000401f7003, pmd=00000000401b1003, pte=00e80000098ed712 Internal error: Oops: 96000147 [#1] SMP Modules linked in: panfrost gpu_sched CPU: 5 PID: 902 Comm: gnome-shell Not tainted 5.3.0-rc1+ #95 Hardware name: 96boards Rock960 (DT) pstate: 40000005 (nZcv daif -PAN -UAO) pc : __dma_inv_area+0x40/0x58 lr : arch_sync_dma_for_cpu+0x28/0x30 sp : ffff00001321ba30 x29: ffff00001321ba30 x28: ffff00001321bd08 x27: 0000000000000000 x26: 0000000000000009 x25: 0000ffffc1f86170 x24: 0000000000000000 x23: 0000000000000000 x22: 0000000000000000 x21: 0000000000021000 x20: ffff80003bb2d810 x19: 00000000098ed000 x18: 0000000000000000 x17: 0000000000000000 x16: ffff800023fd9480 x15: 0000000000000000 x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 x11: 00000000fffb9fff x10: 0000000000000000 x9 : 0000000000000000 x8 : ffff800023fd9c18 x7 : 0000000000000000 x6 : 00000000ffffffff x5 : 0000000000000000 x4 : 0000000000021000 Purging 5693440 bytes x3 : 000000000000003f x2 : 0000000000000040 x1 : ffff80000990e000 x0 : ffff8000098ed000 Call trace: __dma_inv_area+0x40/0x58 dma_direct_sync_single_for_cpu+0x7c/0x80 dma_direct_unmap_page+0x80/0x88 dma_direct_unmap_sg+0x54/0x80 drm_gem_shmem_free_object+0xfc/0x108 panfrost_gem_free_object+0x118/0x128 [panfrost] drm_gem_object_free+0x18/0x90 drm_gem_object_put_unlocked+0x58/0x80 drm_gem_object_handle_put_unlocked+0x64/0xb0 drm_gem_object_release_handle+0x70/0x98 drm_gem_handle_delete+0x64/0xb0 drm_gem_close_ioctl+0x28/0x38 drm_ioctl_kernel+0xb8/0x110 drm_ioctl+0x244/0x3f0 do_vfs_ioctl+0xbc/0x910 ksys_ioctl+0x78/0xa8 __arm64_sys_ioctl+0x1c/0x28 el0_svc_common.constprop.0+0x88/0x150 el0_svc_handler+0x28/0x78 el0_svc+0x8/0xc Code: 8a230000 54000060 d50b7e20 14000002 (d5087620) Fixes: 17acb9f35ed7 ("drm/shmem: Add madvise state and purge helpers") Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Reviewed-by: Steven Price Signed-off-by: Rob Herring --- drivers/gpu/drm/drm_gem_shmem_helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index df8f2c8adb2b..5423ec56b535 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -390,6 +390,12 @@ void drm_gem_shmem_purge_locked(struct drm_gem_object *obj) WARN_ON(!drm_gem_shmem_is_purgeable(shmem)); + dma_unmap_sg(obj->dev->dev, shmem->sgt->sgl, + shmem->sgt->nents, DMA_BIDIRECTIONAL); + sg_free_table(shmem->sgt); + kfree(shmem->sgt); + shmem->sgt = NULL; + drm_gem_shmem_put_pages_locked(shmem); shmem->madv = -1; From patchwork Fri Aug 23 02:12:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 172078 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1683ily; Thu, 22 Aug 2019 19:12:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJGN0y7fmJNFixQIxWBZNhSjmJnBwmWypUZhLDI2R3G4ySPrJtzhHcEYmwYOPwA7CrL4Qe X-Received: by 2002:a17:90a:3646:: with SMTP id s64mr2817836pjb.44.1566526353827; Thu, 22 Aug 2019 19:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566526353; cv=none; d=google.com; s=arc-20160816; b=lnWcxEDzeEaqphIuZntR2rBRNPDxUDwTJLshjWeAezAgIpQaBAGkqDxsSAvLz+/OIJ UDSPMTVGBS2j6LU/oTlCzU1RBRWSr+beuShTC30sQt/+Tmh/L5ynTYyT2uhux6LtxWSh /pfPYORQzQqf0xrNHbtB7ECU0pEuHsZBQMCekNWSVrJ3pU1zeoNxYXKbC08ICWvh1Ce2 LurUZuXU+cm3DzvZU9NOqHJl9NPJr/ccfSxCHQIlBlo4Cxn45ca53iXZFStOaH4hVKZS d78GizB2tC0od3pTAh8wJie09L0Ex1G+uEQR0p6zjxD/r2y94hRXPdCKNdWAkYfQgYuW 7MbA== 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=orjn687kFN+3UrdYU6vYK2sAeYYXRrZEdH4DP6Vlkkc=; b=ukCu/XtVolM5ULD6r6d1qU2cnoiUucTP1uV2gNZDLnGx8hg8PmMPaDVIYvtA//qxir pG5HJThMXAzTFB6HPu2gHy9rVDw3yppjBxDIrdk1W4ELfyZu11GX+jITYGe1fh1HmOR4 mqEPKKZ4+czgbQbjHKX5TpzWvx+yr719GSlN+ka9YgG584wvkQUsaU7fX4BXrYrTiqkU NDLH5xnVYdl8pVrLFQSbe32CpOShW7btSwNds5WZ57FSKgOnGIHjbmDdbDuFfQct0Ctw ipqVJvkiGRDOT0oMk83WNaYhNI3+NS7e3qN6QnX7Gv6Y0qUBjFfVcGNV84vv4+t+L/62 oOXg== 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 p1si1113298pld.28.2019.08.22.19.12.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2019 19:12:33 -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 813706EBA6; 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-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by gabe.freedesktop.org (Postfix) with ESMTPS id ABA5D6EBA5 for ; Fri, 23 Aug 2019 02:12:26 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id l2so5938529oil.0 for ; Thu, 22 Aug 2019 19:12: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=PierwHszPjoIfoYM+aQ/lMW44n7AHzmYyHh9ldDk9CQ=; b=j6AhVDUU+lX/mtw7ztV+RZDv/8GW+r61x+U0zETNHFVPlLjzVsbMJnKvn3wHDeigFt 5g0xHM+ho64Pez28bVZ2BMdBw0G99D7m44hR+vD719YgSa4cbf5puYwg43lt5ys9hurX kHeAHCyieN07HI2HsUoGzblM7kfclnJSfk0axuqiIT0rwQa2TK6xDUINtsygVNwDkPD5 ph23RGpnUkSriq15sJsTjX0GV8Pr+iOaMADNZNVavPLt7jS0xfGQXArGnQSyOZqI8dji wFkHTW1d333GoiDVZQK3I2ZqcM61kXTdLRYGUD9AgKdHBu18KwYv3YCBUeW9P+Bw/9f6 egbA== X-Gm-Message-State: APjAAAVx6NxO0fRu82+bN8UvHuPcOXHdjtSktf5oHKh/Z3Xh3zCYCJfL NGMU0ikyL3kdx21N3nx6kJcKJSE= X-Received: by 2002:aca:61c5:: with SMTP id v188mr1576196oib.34.1566526344892; Thu, 22 Aug 2019 19:12: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 c1sm457747oic.31.2019.08.22.19.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 19:12:24 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 5/8] drm/shmem: Use mutex_trylock in drm_gem_shmem_purge Date: Thu, 22 Aug 2019 21:12:13 -0500 Message-Id: <20190823021216.5862-6-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" Lockdep reports a circular locking dependency with pages_lock taken in the shrinker callback. The deadlock can't actually happen with current users at least as a BO will never be purgeable when pages_lock is held. To be safe, let's use mutex_trylock() instead and bail if a BO is locked already. WARNING: possible circular locking dependency detected 5.3.0-rc1+ #100 Tainted: G L ------------------------------------------------------ kswapd0/171 is trying to acquire lock: 000000009b9823fd (&shmem->pages_lock){+.+.}, at: drm_gem_shmem_purge+0x20/0x40 but task is already holding lock: 00000000f82369b6 (fs_reclaim){+.+.}, at: __fs_reclaim_acquire+0x0/0x40 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (fs_reclaim){+.+.}: fs_reclaim_acquire.part.18+0x34/0x40 fs_reclaim_acquire+0x20/0x28 __kmalloc_node+0x6c/0x4c0 kvmalloc_node+0x38/0xa8 drm_gem_get_pages+0x80/0x1d0 drm_gem_shmem_get_pages+0x58/0xa0 drm_gem_shmem_get_pages_sgt+0x48/0xd0 panfrost_mmu_map+0x38/0xf8 [panfrost] panfrost_gem_open+0xc0/0xe8 [panfrost] drm_gem_handle_create_tail+0xe8/0x198 drm_gem_handle_create+0x3c/0x50 panfrost_gem_create_with_handle+0x70/0xa0 [panfrost] panfrost_ioctl_create_bo+0x48/0x80 [panfrost] drm_ioctl_kernel+0xb8/0x110 drm_ioctl+0x244/0x3f0 do_vfs_ioctl+0xbc/0x910 ksys_ioctl+0x78/0xa8 __arm64_sys_ioctl+0x1c/0x28 el0_svc_common.constprop.0+0x90/0x168 el0_svc_handler+0x28/0x78 el0_svc+0x8/0xc -> #0 (&shmem->pages_lock){+.+.}: __lock_acquire+0xa2c/0x1d70 lock_acquire+0xdc/0x228 __mutex_lock+0x8c/0x800 mutex_lock_nested+0x1c/0x28 drm_gem_shmem_purge+0x20/0x40 panfrost_gem_shrinker_scan+0xc0/0x180 [panfrost] do_shrink_slab+0x208/0x500 shrink_slab+0x10c/0x2c0 shrink_node+0x28c/0x4d8 balance_pgdat+0x2c8/0x570 kswapd+0x22c/0x638 kthread+0x128/0x130 ret_from_fork+0x10/0x18 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(fs_reclaim); lock(&shmem->pages_lock); lock(fs_reclaim); lock(&shmem->pages_lock); *** DEADLOCK *** 3 locks held by kswapd0/171: #0: 00000000f82369b6 (fs_reclaim){+.+.}, at: __fs_reclaim_acquire+0x0/0x40 #1: 00000000ceb37808 (shrinker_rwsem){++++}, at: shrink_slab+0xbc/0x2c0 #2: 00000000f31efa81 (&pfdev->shrinker_lock){+.+.}, at: panfrost_gem_shrinker_scan+0x34/0x180 [panfrost] Fixes: 17acb9f35ed7 ("drm/shmem: Add madvise state and purge helpers") Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring Reviewed-by: Steven Price --- drivers/gpu/drm/drm_gem_shmem_helper.c | 7 +++++-- include/drm/drm_gem_shmem_helper.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 5423ec56b535..f5918707672f 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -415,13 +415,16 @@ void drm_gem_shmem_purge_locked(struct drm_gem_object *obj) } EXPORT_SYMBOL(drm_gem_shmem_purge_locked); -void drm_gem_shmem_purge(struct drm_gem_object *obj) +bool drm_gem_shmem_purge(struct drm_gem_object *obj) { struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj); - mutex_lock(&shmem->pages_lock); + if (!mutex_trylock(&shmem->pages_lock)) + return false; drm_gem_shmem_purge_locked(obj); mutex_unlock(&shmem->pages_lock); + + return true; } EXPORT_SYMBOL(drm_gem_shmem_purge); diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h index ce1600fdfc3e..01f514521687 100644 --- a/include/drm/drm_gem_shmem_helper.h +++ b/include/drm/drm_gem_shmem_helper.h @@ -134,7 +134,7 @@ static inline bool drm_gem_shmem_is_purgeable(struct drm_gem_shmem_object *shmem } void drm_gem_shmem_purge_locked(struct drm_gem_object *obj); -void drm_gem_shmem_purge(struct drm_gem_object *obj); +bool drm_gem_shmem_purge(struct drm_gem_object *obj); struct drm_gem_shmem_object * drm_gem_shmem_create_with_handle(struct drm_file *file_priv, From patchwork Fri Aug 23 02:12:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 172082 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1920ily; Thu, 22 Aug 2019 19:12:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzE9EMMFptesSA4UG9ivrSuxuQyH7I+U63da9ATUyur6znfnE0ySHQd2a+m+EtMaWDPnwQS X-Received: by 2002:a17:902:ab96:: with SMTP id f22mr2053949plr.147.1566526370120; Thu, 22 Aug 2019 19:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566526370; cv=none; d=google.com; s=arc-20160816; b=WJ0MWTNIzoQkywTy/18AaSCOqNXONUcPuumxjNyJ+scoFACgiHZxHstEvXmwpp42Ei bxWqY2+tkdghO9oeyDEBciDuCYduTzposLoX9MIQSdv3HZR5/uNoc+Hi3JVAwMnYgjol gJOVDnlRbC55N9vY0pn6a/eaLvTXq/YTr3A04/etY8o0/iDhHVOQu1kxIELByFA+zfKl 8C2ubjEhIhKGOdhsLEBWyqy8ota1ddWULUqEomyfiRCO41ePNeHnkdT1XpSnTBC5kswF 89zzF1hQdLBaAt088Tj5Q/NbLrxGCYi4AX3J9q6bGN52qtSrKeU4EmGGh98AnpvbtVIG U+yw== 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=k7UAEiWVoGZ53f9h4aGJsHk3JMTFkB7T41YcQ7ntxTE=; b=QcG+uMil9IOU97nYiz94wa0RHQdqdgMJIo6R0qRt4pra1v07QfdX0kMAPztmPID4WU QTSdhjvCBhUfeMQf2StXz0/o8/23s4Oe6J8TxlbQmjnZSQ98gzb1dsIyqrik4gb0yIBm bCNovRKhrEAtQYEDE6EHf179turip/LvkE+fCAK5815n1kXcB22CZe/CTynhYWy/G7xi b2BcJJBAN0xSF9tLPKo3r+h7wkO3Yza4osjjLWXGerix+JPRixIyCKXuD8uQtEMZE+ik HlioHdnDyEO42MkAfOusFKotkPNAeJ9owqTxMQ8o0yLrQv9ZwD4gwbcAArqq7vBgvnlg WeOg== 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 61si1036899plb.270.2019.08.22.19.12.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2019 19:12:50 -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 1EE5D6EBAB; Fri, 23 Aug 2019 02:12:49 +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 A74D96EBA5 for ; Fri, 23 Aug 2019 02:12:27 +0000 (UTC) Received: by mail-oi1-f194.google.com with SMTP id h21so5915851oie.7 for ; Thu, 22 Aug 2019 19:12: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=FUX/60RPleBNc8rEUfe9ndSh2CQRzsgZWa6X5GDs078=; b=rI8V7W0c5Y2IQKZFN2p7LW3p6zogvDApJ8F5ysThcxz3IAdxYdVkBVjegAdfCNS+2Q vSmg9cfwv0rkaeMjvopwecZBwhttFMl8vHEewyiTlg1FHgYl5QG6wJr8IvgjC5XD7xtv Nd9NybCrBdFlVSaMO61BQ97gg0MEqfpLZOyQfq1FyTg7+jy0VgfkjZuluKtKpTkDBf/s dZiH+rjJ+VUHaZCQme+MIyAkt7OSF+akMK3GGxZBpiEWJ6Q2uKdWxGcmLLiUbJdyrqfR VO9pXh3nyFqlcmmETQgTgVVqaGV0ss/EpYwMuDUqruG7r0IIq6ijY28659Xa2rqnJEbK YBDA== X-Gm-Message-State: APjAAAUWdqzzYs1dcoB8c6WImZGNmM6A24yXLSvxLRySfBWZLkQnUR4t EJ2ZexKLZjMAhjxI26ftnFZy6c8= X-Received: by 2002:aca:ead7:: with SMTP id i206mr1487367oih.8.1566526346137; Thu, 22 Aug 2019 19:12: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 c1sm457747oic.31.2019.08.22.19.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 19:12:25 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 6/8] drm/panfrost: Use mutex_trylock in panfrost_gem_purge Date: Thu, 22 Aug 2019 21:12:14 -0500 Message-Id: <20190823021216.5862-7-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" Lockdep reports a circular locking dependency with pages_lock taken in the shrinker callback. The deadlock can't actually happen with current users at least as a BO will never be purgeable when pages_lock is held. To be safe, let's use mutex_trylock() instead and bail if a BO is locked already. Cc: Tomeu Vizoso Cc: Steven Price Cc: Alyssa Rosenzweig Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring Reviewed-by: Steven Price --- v2: new patch drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c b/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c index d191632b6197..458f0fa68111 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c +++ b/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c @@ -36,15 +36,18 @@ panfrost_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc return count; } -static void panfrost_gem_purge(struct drm_gem_object *obj) +static bool panfrost_gem_purge(struct drm_gem_object *obj) { struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj); - mutex_lock(&shmem->pages_lock); + + if (!mutex_trylock(&shmem->pages_lock)) + return false; panfrost_mmu_unmap(to_panfrost_bo(obj)); drm_gem_shmem_purge_locked(obj); mutex_unlock(&shmem->pages_lock); + return true; } static unsigned long @@ -61,8 +64,8 @@ panfrost_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_control *sc) list_for_each_entry_safe(shmem, tmp, &pfdev->shrinker_list, madv_list) { if (freed >= sc->nr_to_scan) break; - if (drm_gem_shmem_is_purgeable(shmem)) { - panfrost_gem_purge(&shmem->base); + if (drm_gem_shmem_is_purgeable(shmem) && + panfrost_gem_purge(&shmem->base)) { freed += shmem->base.size >> PAGE_SHIFT; list_del_init(&shmem->madv_list); } 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 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; } From patchwork Fri Aug 23 02:12: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: 172079 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1752ily; Thu, 22 Aug 2019 19:12:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxy2HcNMf8XJWpgvlQFmW9k6s3meYJG+/wblW+hLWJg7MUXbccnYk77rv03eObd5fw0DpWw X-Received: by 2002:a17:902:6a84:: with SMTP id n4mr2019430plk.109.1566526359013; Thu, 22 Aug 2019 19:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566526359; cv=none; d=google.com; s=arc-20160816; b=F3XwL6ckRa65tYCGE12eOfMBEWCp+1WKCmIWrpKRi+7MgynNWvI8uJuW4g7OYvGJlD pbPB+dpkR6MYmfZCN1g/v6yTNDl3DEjEIhjiQJVJE3bCBwvmDYhFjVACbVRZ7hITz3ew KfL+KEXnv13lWx1wW2wDSc8mzui/1p9TqLrHOKJx6fKI/+i8nmmdE3KvZo8IVPJaAk2i jgRB/SLP7D47y4ULiaAc8UvoHwWGNauwusibe3WB6+U6YK7szecd4qo6jJWiwxFpbICl ERZsZ2QJCAkcEHGJkMeqaeNKLoTwcYqAj4KocDoVdOXaAUsMGYcWCH/hOSTRbXgrSMHe IWCQ== 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=6IWpzXoi4eIdyNJq2jyVsFbpd5UTu/jd58iO/jdVAMU=; b=jllH8r2EvpSCkh03Ss6yreqLLNwTvHHJmmIdJmywiHwDubKm5QHHPuoeaFH3/Q6XJ0 NqruaZj7A03/SDAbuuUGkN/B3eFvhojbF7QCVLS7ufbUBoYAV8T0vjeWsd792UwpmpPt wnsZU3KIozV4OqlG8XgK7tS8uHAkH0eEe4/N6inAvUy2rX+ctaM4owEAXu/COJ1SBjx6 WEbEm4mI/r1Wu8gGFCGcDC8CkWSuQjz0ANJ2GX9eEYmGkShaLmDcKrvxShFTHZsUNzVy bDd0B3TiirGyrgt1kTr/K8RhsuNukjsMRMcaW4T0S6d+Z1EcYXhxn+AseJR4VCZGt+IG k6Hg== 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 ck4si1131268plb.235.2019.08.22.19.12.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2019 19:12:39 -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 098186EBA7; Fri, 23 Aug 2019 02:12:38 +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 D17306EBA5 for ; Fri, 23 Aug 2019 02:12:29 +0000 (UTC) Received: by mail-ot1-f66.google.com with SMTP id f17so7407113otq.4 for ; Thu, 22 Aug 2019 19:12:29 -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=1n4qe+AkzzJcIOZArT5eHMvskMvaiSyGwRJQ9TgkdLc=; b=lP1DFb8+WWIRd+rbFO6Z/X+Gu+2iDhNZBP7KhZOppZrGJuUWPD3d36dVr+xmR5bcWU scHPakxeRzIA/0FU/MqWdqVtYNdXBjf3NZ3s38DFXBFYGZX9oZm8wnnMKdyOBUuqbkHz tIo19FcP3xlqp/S6Wh9r2NpICoKrGbHoi2cSqRkpJWUfbz7maHEb1tDirxN+VSdGrRlj QFrwN2vbMFWW7+Pp8vSYA7U8HESuOayK+be5IFExImbAhLcaFcWrxiKlKgqsMAyb86RB ucb3UtHXlP40cWayqbhzvV/Z0PcszLoXaRd7NeSw7nbGpCqA1UzdvUVPL3l0ZTj6Jmjq NbTQ== X-Gm-Message-State: APjAAAVma44JFRaeS4t7DdtjapikwWmhkXvBnGI3y4RUSUPzGqQ9hjXK Ah48F2LYyIayVinzmwJsaDK/1Is= X-Received: by 2002:a9d:77c4:: with SMTP id w4mr2319524otl.40.1566526348479; Thu, 22 Aug 2019 19:12:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 19:12:28 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 8/8] drm/panfrost: Remove unnecessary flushing from tlb_inv_context Date: Thu, 22 Aug 2019 21:12:16 -0500 Message-Id: <20190823021216.5862-9-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" tlb_inv_context() hook is only called when freeing the page tables. There's no point in flushing only to free the page tables immediately following. There is also a problem that we could be accessing the h/w when suspended. Cc: Tomeu Vizoso Cc: Steven Price Cc: Alyssa Rosenzweig Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring Reviewed-by: Steven Price --- v2: new patch drivers/gpu/drm/panfrost/panfrost_mmu.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c index ccf671a9c3fb..9f85275a896c 100644 --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c @@ -328,11 +328,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)