From patchwork Tue Apr 21 13:35:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 11501409 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F8A513B2 for ; Tue, 21 Apr 2020 13:37:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D90D20753 for ; Tue, 21 Apr 2020 13:37:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N99sejvw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D90D20753 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3AEBA6E0CD; Tue, 21 Apr 2020 13:37:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9D2276E0CD; Tue, 21 Apr 2020 13:37:22 +0000 (UTC) Received: by mail-pl1-x641.google.com with SMTP id f8so5259025plt.2; Tue, 21 Apr 2020 06:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q99F72xfQQRlvFdNx8KaIRgOqIlkfnsXVwfUZ6na6vI=; b=N99sejvwL84+Cfqmpyzkr+XyXSdpzeBpZEUQrhhatRwGc5CVdlr4yX782OIva/clg9 P1G72rYoxbYgdnRNbqfgj0XZFG8X3WYm1NA+h76swZDAKzm8CMiqd+ioH8WO+ftF68Df otB75Ge1sT/XkV429ITEypmLensbpHvvdxEoBzlNX4HdRvQdnnQSoCoQCiesJxWvr0e2 tV0cJESgVJjZvCS6Y1cSpImKbiCSMH/6OdUFs7SJYJMNCCtGSA8ZvZYXTZVps6URPXiD e7TsmYylyNYqp3SMlqrdAl+xNU+TWN3TVUGxyU9FA9gIriEVW2EXatzn5tWXpEx2AD3y dXuw== 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; bh=q99F72xfQQRlvFdNx8KaIRgOqIlkfnsXVwfUZ6na6vI=; b=uI1sGU70bjLDW/1a+0xnNak4poUx5/5P5/t+JRe0xwUtfot38uis09FmwGmrY/iWFE qtUrTcyBrPacBiKV+n2bk8wU9qSb87i8qUXFHvAjg1ZhlXh9SGjPN9gkD1jMB4Z4nkKC AHdbEK5JiUP3GMFz2fIay+P4AukXnGk4sSoAfaH2btW8c8vmQNtWVkNkDmKV4rSFxsfy IhfetamnX8Bo090BeryhCAqvzsGdaC8MtFa+9bAdzBBbvDYUKhA8Xv3WdRbyRAY8VPrW b0wqwKh6UAEVPfvwLlWj9I85g06EnYuGMslaDZimEYhrpQrXuDU9ga8SkDF3x7NqHXML HIzg== X-Gm-Message-State: AGi0PuZgN2HXQv8tEwjYt1UNRS5GoU6A1MV1kh4msSTg4cSQp4TjlxnO otQxk3ARY03d9cqafWvaKknOTUENGzGI8g== X-Google-Smtp-Source: APiQypJ2v3TnDaVvpkl2yCoUDFrY0uFDQZkUiNs2wKpyqWYauMt6P+IQ9E5KdduaY8ddZvqThUcBvg== X-Received: by 2002:a17:902:7793:: with SMTP id o19mr14488328pll.107.1587476241967; Tue, 21 Apr 2020 06:37:21 -0700 (PDT) Received: from yuq-Aspire-4738G.lan (li2017-195.members.linode.com. [172.105.124.195]) by smtp.gmail.com with ESMTPSA id r23sm2551327pfr.64.2020.04.21.06.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:37:21 -0700 (PDT) From: Qiang Yu To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 01/10] drm/lima: use module_platform_driver helper Date: Tue, 21 Apr 2020 21:35:42 +0800 Message-Id: <20200421133551.31481-2-yuq825@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200421133551.31481-1-yuq825@gmail.com> References: <20200421133551.31481-1-yuq825@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lima@lists.freedesktop.org, David Airlie , Bhushan Shah , Vasily Khoruzhick , Andreas Baierl , Qiang Yu , Erico Nunes MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Simplify module init/exit with module_platform_driver. Signed-off-by: Qiang Yu --- drivers/gpu/drm/lima/lima_drv.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/gpu/drm/lima/lima_drv.c b/drivers/gpu/drm/lima/lima_drv.c index bbbdc8455e2f..91bf5b305e9d 100644 --- a/drivers/gpu/drm/lima/lima_drv.c +++ b/drivers/gpu/drm/lima/lima_drv.c @@ -461,17 +461,7 @@ static struct platform_driver lima_platform_driver = { }, }; -static int __init lima_init(void) -{ - return platform_driver_register(&lima_platform_driver); -} -module_init(lima_init); - -static void __exit lima_exit(void) -{ - platform_driver_unregister(&lima_platform_driver); -} -module_exit(lima_exit); +module_platform_driver(lima_platform_driver); MODULE_AUTHOR("Lima Project Developers"); MODULE_DESCRIPTION("Lima DRM Driver"); From patchwork Tue Apr 21 13:35:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 11501411 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A46013B2 for ; Tue, 21 Apr 2020 13:37:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 18667206F4 for ; Tue, 21 Apr 2020 13:37:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iiPq7JBR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18667206F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0801A6E967; Tue, 21 Apr 2020 13:37:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by gabe.freedesktop.org (Postfix) with ESMTPS id 520BE6E966; Tue, 21 Apr 2020 13:37:27 +0000 (UTC) Received: by mail-pj1-x1044.google.com with SMTP id a7so1364435pju.2; Tue, 21 Apr 2020 06:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qP9PaAXMpHklt4PkWxGJD535lg4vWx2Z2/78C5r9WSs=; b=iiPq7JBR5nlghNthIX2JMqRgHsey6EMc5QpzNUUodo6E/HIqA0EyGCv2zdlP6Wt91A H0UxPmFIz4gRYHSsqxgI2kojdzEIZUqxOBrsOv1bJZ9GjGV3OpHi7Q+DiH3T0vu7cqgg a+RmzfesTrIF6D5+yZg1s1iWO3nQM4VSd3FpJ2V2p7g4wFzEOHP/ZrNwzjNE3ACnUSVo czJ9T28/gg9Bg0LbbG/qIHelXy4rZjmFEK9/Es8m6ylFYFkx6Yc7sAN7mkQ0zSSmvqgC kOsyGtmmKEPaUWVGE7nd0vzCWmsRbsM+FCeGV98IJBi1fUOleJ+j0Q9H2OyB1yHK+bAn NTLw== 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; bh=qP9PaAXMpHklt4PkWxGJD535lg4vWx2Z2/78C5r9WSs=; b=lhj9z8sTD7IOop9yOgFVht5Nz4xDF6l1oavL37haoOTrJv5XHiYmVTreGKkpJaDEqc EY9siAjUOjHc0aZtc82kFDax7uhAHSv8mQew921QyUftbA5VtqhuFriIJo91LcCZ4yCs BE2dBGqpkMJ41OHrB0bGREUIFPPRNB5GTps0H19OAVKCIzVHhwx96OLKozZ5EQk9jJ8n oLpzlQVbB14XVF6wXM+9bej2i7cTEiGX3XU+fPbwto9qPyCT++B5V76H1Gp0Zs/Wom6N PUIUQZAidLa2n/P/gW80xDVUFNmqcAkdp3gZhmicxw2SSeoZF2pn8yeKYXRWsE4D5dOy Fwsw== X-Gm-Message-State: AGi0PuZebfirDwQwuqv3xatzJ6fOlESpUBH2/EuJ3IJsAw0XQITzwKCc nISpvjcsXWULU27cfzDQyzcfQyYhw1R55Q== X-Google-Smtp-Source: APiQypKJzjLUQjUWOYbZ1OTpv3REQo5mHSAaDj80qiYMf5vEkHCQJumN1gL764n7vfAICcbmjAa5ig== X-Received: by 2002:a17:90a:280c:: with SMTP id e12mr5595582pjd.52.1587476246693; Tue, 21 Apr 2020 06:37:26 -0700 (PDT) Received: from yuq-Aspire-4738G.lan (li2017-195.members.linode.com. [172.105.124.195]) by smtp.gmail.com with ESMTPSA id r23sm2551327pfr.64.2020.04.21.06.37.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:37:26 -0700 (PDT) From: Qiang Yu To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 02/10] drm/lima: print process name and pid when task error Date: Tue, 21 Apr 2020 21:35:43 +0800 Message-Id: <20200421133551.31481-3-yuq825@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200421133551.31481-1-yuq825@gmail.com> References: <20200421133551.31481-1-yuq825@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lima@lists.freedesktop.org, David Airlie , Bhushan Shah , Vasily Khoruzhick , Andreas Baierl , Qiang Yu , Erico Nunes MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When error task list is full, print the process info where the error task come from for debug usage. Signed-off-by: Qiang Yu --- drivers/gpu/drm/lima/lima_sched.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c index a2db1c937424..387f9439450a 100644 --- a/drivers/gpu/drm/lima/lima_sched.c +++ b/drivers/gpu/drm/lima/lima_sched.c @@ -285,7 +285,8 @@ static void lima_sched_build_error_task_list(struct lima_sched_task *task) mutex_lock(&dev->error_task_list_lock); if (dev->dump.num_tasks >= lima_max_error_tasks) { - dev_info(dev->dev, "fail to save task state: error task list is full\n"); + dev_info(dev->dev, "fail to save task state from %s pid %d: " + "error task list is full\n", ctx->pname, ctx->pid); goto out; } From patchwork Tue Apr 21 13:35:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 11501413 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12D0792C for ; Tue, 21 Apr 2020 13:37:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E56F720738 for ; Tue, 21 Apr 2020 13:37:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ugk02ikv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E56F720738 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F1E6E6E964; Tue, 21 Apr 2020 13:37:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id 06F7F6E964; Tue, 21 Apr 2020 13:37:32 +0000 (UTC) Received: by mail-pg1-x541.google.com with SMTP id o185so6231955pgo.3; Tue, 21 Apr 2020 06:37:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Lagb1/vO0DxAvOGX+tmWzfaoAW87nlvdTyVuGDvba/c=; b=Ugk02ikvltLeimw2cX5ucyurM3+CA3EcwDnP2DaZmfXYE3aswNKCDZXUHbb7m+HmoT mGOGv4UizHmyT+c9/KATOAXCOp8ihe/RDd1hZJHC5sGrcm8eQeW4ypfmrFqBHP14LOIu 1jJ2YAqqaGDzoIPcYS25/j1IddOESd61YefATgfUps6M6xzY1K97D2tdfkiZgnc9Y04p afxdsB9WjxqK5VPyjXuHbIfJAGlfkYfOXu83P06zkiA6V9I972S0L34/3LMRMTb6qlYO CfijvaXS/XE7zaGGHkjKFcRTv6Yf61sikBcNpklhtLjr4TnOTanE74l156BqDG2sb9+a INVQ== 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; bh=Lagb1/vO0DxAvOGX+tmWzfaoAW87nlvdTyVuGDvba/c=; b=NwzoYvy49gr5mzHNxERYHmkEwmYZDRMCs9R+/xawXLtd+xhYmv5pSIpEAJmSmN+CZt is8f0B+nOck4iL4lvNH9Vp1V88h/4CM5Jn/0nPC9WA4Feu9d3NuUXzlI0VETl64xfElo HvSzNhmw55XpkFGnW1iw1gcSqmiDTwIgQiRUCEUXQ/jePEl8wAF4TWU6ea/iHi/p/IT9 Cl5ylojYQ90QHGWHrYw2EqcI6u5+YTanG4eaFRaF8PylQ4zG/7PmXdUTiVU0WrhOgmQZ Ma2nslzbNWIjUIu6ZM/8INFV4vTCd/uF8GQTOZdF5l29eYZj7XkodFOdYhUFsniaB2Jo hS/w== X-Gm-Message-State: AGi0PuZAdvtuBgiM3J/0iMDxdAD0Bi8/2TR/B321W5kOjZ8nyto7TMyI xrbywlghoRRojnuKcA6UdncpoP5Nyo9eKg== X-Google-Smtp-Source: APiQypJZXSgi3BB3lYT8eA+AX8RGBEaM4ZoSnd3qqFndE+ef1Ml+XOIr/R6zAyPTUwziSBIsSBmlng== X-Received: by 2002:a63:eb15:: with SMTP id t21mr21333086pgh.279.1587476251381; Tue, 21 Apr 2020 06:37:31 -0700 (PDT) Received: from yuq-Aspire-4738G.lan (li2017-195.members.linode.com. [172.105.124.195]) by smtp.gmail.com with ESMTPSA id r23sm2551327pfr.64.2020.04.21.06.37.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:37:30 -0700 (PDT) From: Qiang Yu To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 03/10] drm/lima: check vm != NULL in lima_vm_put Date: Tue, 21 Apr 2020 21:35:44 +0800 Message-Id: <20200421133551.31481-4-yuq825@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200421133551.31481-1-yuq825@gmail.com> References: <20200421133551.31481-1-yuq825@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lima@lists.freedesktop.org, David Airlie , Bhushan Shah , Vasily Khoruzhick , Andreas Baierl , Qiang Yu , Erico Nunes MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" No need to handle this check before calling lima_vm_put. Signed-off-by: Qiang Yu --- drivers/gpu/drm/lima/lima_sched.c | 7 ++----- drivers/gpu/drm/lima/lima_vm.h | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c index 387f9439450a..3ac5797e31fc 100644 --- a/drivers/gpu/drm/lima/lima_sched.c +++ b/drivers/gpu/drm/lima/lima_sched.c @@ -252,8 +252,7 @@ static struct dma_fence *lima_sched_run_job(struct drm_sched_job *job) lima_mmu_switch_vm(pipe->mmu[i], vm); } - if (last_vm) - lima_vm_put(last_vm); + lima_vm_put(last_vm); trace_lima_task_run(task); @@ -416,9 +415,7 @@ static void lima_sched_timedout_job(struct drm_sched_job *job) lima_mmu_page_fault_resume(pipe->mmu[i]); } - if (pipe->current_vm) - lima_vm_put(pipe->current_vm); - + lima_vm_put(pipe->current_vm); pipe->current_vm = NULL; pipe->current_task = NULL; diff --git a/drivers/gpu/drm/lima/lima_vm.h b/drivers/gpu/drm/lima/lima_vm.h index 22aeec77d84d..3a7c74822d8b 100644 --- a/drivers/gpu/drm/lima/lima_vm.h +++ b/drivers/gpu/drm/lima/lima_vm.h @@ -54,7 +54,8 @@ static inline struct lima_vm *lima_vm_get(struct lima_vm *vm) static inline void lima_vm_put(struct lima_vm *vm) { - kref_put(&vm->refcount, lima_vm_release); + if (vm) + kref_put(&vm->refcount, lima_vm_release); } void lima_vm_print(struct lima_vm *vm); From patchwork Tue Apr 21 13:35:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 11501415 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E09F792C for ; Tue, 21 Apr 2020 13:37:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BEE2720753 for ; Tue, 21 Apr 2020 13:37:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rY4jhHeQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEE2720753 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0B9BF6E968; Tue, 21 Apr 2020 13:37:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by gabe.freedesktop.org (Postfix) with ESMTPS id A73AE6E968; Tue, 21 Apr 2020 13:37:36 +0000 (UTC) Received: by mail-pf1-x434.google.com with SMTP id r14so6611206pfg.2; Tue, 21 Apr 2020 06:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lsQwOx5F/yu8+yr8Rd+a/KS/hBbRD/lrzAH/QpIb0zA=; b=rY4jhHeQYFLJXRotZ50VZQcgiMfy7emGgJux7mCcmkrtrkNKhwqWDU9TXED8PI+cds wQWoIo5BVH1/Z4XUbIi0plsBo8Gmg1mlgM0dVlKIHgu6kngqVHhiZ2ZNrOlZmsIAmE4a Y8wbnL6H+alcG+oJBtR33I9QEGqYf2asw5/K8DDgitFjji+llb+BXOreDfeAYeQVV+ir h4TM173ehv1G+0UkjR4sIfrKvmETEroXgaGnSDIQDgvi1IK4SOSDSE/kfxXwQlhXEhaa Y4+7t9YdfvkDJIR9b9WESWKopbhY5FRktpEIX0orRJS/93HFVD6lTxgB0m6mLEW4Wr59 GM+A== 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; bh=lsQwOx5F/yu8+yr8Rd+a/KS/hBbRD/lrzAH/QpIb0zA=; b=KRomjT8v9L36fpJErl+0LsQUG8ZBnoPrUpQZWup7Wkgtddu5/jwGQipzdapQ40kbQS wVG6C/nTKie+UHY2euDhUE3Uyrlb2YW5FEIimlkxSPlTsvcveDtQ90u511E4nPyisqhk SAJuAS1JYu0UNTZKwhSgq550PfDYkPc8wVCgaZcf0r+Fe573x4NoILEF/KZGuS6/bA8i Pvsn0QYlfeoMB9+OJr3PFrWZYCv2Y0tQJ5b4Kkd2IJ1nSZPH8Ui/Brq96debBXzrTYqp Ggb4HZg/DCOYWZkb0JcrLf/wO5FIvOpmnJs+VGhywfOoxX3S7LwAfcueswZ0suZvI+m6 4N4A== X-Gm-Message-State: AGi0PuZGkAUVCwOthF9M+t3O3DKnBego1UyMeCPLklxtd0OjWA33e4QT ekZEEePyseaNOWWXKqTq6bMRW1hIXaGzfg== X-Google-Smtp-Source: APiQypK1eAZSlaYTIar6CSUyG7sSP5YyOgT9vk5hQqlk9z6PcCn9jqo22hCn745kyX9MuxKPI3w0Wg== X-Received: by 2002:a63:dd0a:: with SMTP id t10mr20929080pgg.50.1587476256051; Tue, 21 Apr 2020 06:37:36 -0700 (PDT) Received: from yuq-Aspire-4738G.lan (li2017-195.members.linode.com. [172.105.124.195]) by smtp.gmail.com with ESMTPSA id r23sm2551327pfr.64.2020.04.21.06.37.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:37:35 -0700 (PDT) From: Qiang Yu To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 04/10] drm/lima: always set page directory when switch vm Date: Tue, 21 Apr 2020 21:35:45 +0800 Message-Id: <20200421133551.31481-5-yuq825@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200421133551.31481-1-yuq825@gmail.com> References: <20200421133551.31481-1-yuq825@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lima@lists.freedesktop.org, David Airlie , Bhushan Shah , Vasily Khoruzhick , Andreas Baierl , Qiang Yu , Erico Nunes MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We need to flush TLB anyway before every task start, and the page directory will be set to empty vm after suspend/resume, so always set it to the task vm even no ctx switch happens. Signed-off-by: Qiang Yu --- drivers/gpu/drm/lima/lima_mmu.c | 3 +-- drivers/gpu/drm/lima/lima_sched.c | 14 ++++---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/lima/lima_mmu.c b/drivers/gpu/drm/lima/lima_mmu.c index f79d2af427e7..c26b751b0f9d 100644 --- a/drivers/gpu/drm/lima/lima_mmu.c +++ b/drivers/gpu/drm/lima/lima_mmu.c @@ -113,8 +113,7 @@ void lima_mmu_switch_vm(struct lima_ip *ip, struct lima_vm *vm) LIMA_MMU_STATUS, v, v & LIMA_MMU_STATUS_STALL_ACTIVE); - if (vm) - mmu_write(LIMA_MMU_DTE_ADDR, vm->pd.dma); + mmu_write(LIMA_MMU_DTE_ADDR, vm->pd.dma); /* flush the TLB */ mmu_write(LIMA_MMU_COMMAND, LIMA_MMU_COMMAND_ZAP_CACHE); diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c index 3ac5797e31fc..eb46db0717cd 100644 --- a/drivers/gpu/drm/lima/lima_sched.c +++ b/drivers/gpu/drm/lima/lima_sched.c @@ -200,7 +200,6 @@ static struct dma_fence *lima_sched_run_job(struct drm_sched_job *job) struct lima_sched_pipe *pipe = to_lima_pipe(job->sched); struct lima_fence *fence; struct dma_fence *ret; - struct lima_vm *vm = NULL, *last_vm = NULL; int i; /* after GPU reset */ @@ -239,21 +238,16 @@ static struct dma_fence *lima_sched_run_job(struct drm_sched_job *job) for (i = 0; i < pipe->num_l2_cache; i++) lima_l2_cache_flush(pipe->l2_cache[i]); - if (task->vm != pipe->current_vm) { - vm = lima_vm_get(task->vm); - last_vm = pipe->current_vm; - pipe->current_vm = task->vm; - } + lima_vm_put(pipe->current_vm); + pipe->current_vm = lima_vm_get(task->vm); if (pipe->bcast_mmu) - lima_mmu_switch_vm(pipe->bcast_mmu, vm); + lima_mmu_switch_vm(pipe->bcast_mmu, pipe->current_vm); else { for (i = 0; i < pipe->num_mmu; i++) - lima_mmu_switch_vm(pipe->mmu[i], vm); + lima_mmu_switch_vm(pipe->mmu[i], pipe->current_vm); } - lima_vm_put(last_vm); - trace_lima_task_run(task); pipe->error = false; From patchwork Tue Apr 21 13:35:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 11501417 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4ECF313B2 for ; Tue, 21 Apr 2020 13:37:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B32220738 for ; Tue, 21 Apr 2020 13:37:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UzIXv5u7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B32220738 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2EA7A6E969; Tue, 21 Apr 2020 13:37:43 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 484D86E966; Tue, 21 Apr 2020 13:37:41 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id 18so2961496pfx.6; Tue, 21 Apr 2020 06:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZvpB2OLlW8f604XO1Vw/EtDA4S3id/uYjXH7SZjwG2I=; b=UzIXv5u7JEiXxjssQrdoRfpDDZbU0ZPXvvZDXLQJ5Tf+wUHUugwE4TsX/NA5ZTFmMb 7FBnf/N/XEqhyDTnISVh0iBNUKv9tKJBE/5qbimBU37jwoZ1jtb+L5w7wMNKCtEnLu84 7SfWQQ/Vvh9bOqgyGsdJn5xfGYU+4Pqqc9uZPn0SchlEsviKKCm3KW7TW7GFLYAlmNMh sgKDy2pM/tq3lsm6+0dsodmzr18Tb61yPnrvJLc7/qXHUTpjpz/dZ2ZNormDYCJLf72r rrCyZYLiY+qq32CvEPIAQA0djQGBBJA/hEaGqRSMafevbI1CKanPj2Lufw282njAXB2s XwYA== 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; bh=ZvpB2OLlW8f604XO1Vw/EtDA4S3id/uYjXH7SZjwG2I=; b=syUX4RdtXZ5UhW6rn+alORxGoGV0O9wUQZxiAqPm4bkcgrBDJvcxDhfeXx3d+ubKcr py4uwzDhWFwNtgTRav1M+hGhY1Xavpei/lLD2nTLAydBdtBMvv/4TDqdq1S7zYk390aD TDJ3dI66hVahYc2MV8ceYCliqXK+bE0cIPLeVQ9GRnCv12uVlhTBQqDsluLaLScnc73d 4kONmIrXKFE49dhrpQBYpZgBDpe3cYud2ls4ZwekpkHOdorNX21UUBfvScoeh+gaXKhj 7g3NF4KDJrbvXtDoHR/TDfPVMlvA0yaDsiboHSCV+GtvAWQD6N/aqYGaNloBo4mr4Ej4 mRjg== X-Gm-Message-State: AGi0PubeDfFgtadDaxIzHJ/3pQIiBo2UsPACWK6D61kPiXsMqeZc8+W8 MJTT+Qw/Mb0x/cFoz1+kKgBvmnMPvwU/eQ== X-Google-Smtp-Source: APiQypIiDfrPxy0mplOhS3afkmButAjyF75gH8diBmw1ei6hFiHdeKKZnZPxy4SQtniYyWDJIwOWBA== X-Received: by 2002:a63:4d18:: with SMTP id a24mr20621333pgb.97.1587476260670; Tue, 21 Apr 2020 06:37:40 -0700 (PDT) Received: from yuq-Aspire-4738G.lan (li2017-195.members.linode.com. [172.105.124.195]) by smtp.gmail.com with ESMTPSA id r23sm2551327pfr.64.2020.04.21.06.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:37:40 -0700 (PDT) From: Qiang Yu To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 05/10] drm/lima: add lima_devfreq_resume/suspend Date: Tue, 21 Apr 2020 21:35:46 +0800 Message-Id: <20200421133551.31481-6-yuq825@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200421133551.31481-1-yuq825@gmail.com> References: <20200421133551.31481-1-yuq825@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lima@lists.freedesktop.org, David Airlie , Bhushan Shah , Vasily Khoruzhick , Andreas Baierl , Qiang Yu , Erico Nunes MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Used for device resume/suspend in the following commits. Signed-off-by: Qiang Yu --- drivers/gpu/drm/lima/lima_devfreq.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/lima/lima_devfreq.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/drivers/gpu/drm/lima/lima_devfreq.c b/drivers/gpu/drm/lima/lima_devfreq.c index 8c4d21d07529..f5bf85bbbb67 100644 --- a/drivers/gpu/drm/lima/lima_devfreq.c +++ b/drivers/gpu/drm/lima/lima_devfreq.c @@ -232,3 +232,27 @@ void lima_devfreq_record_idle(struct lima_devfreq *devfreq) spin_unlock_irqrestore(&devfreq->lock, irqflags); } + +int lima_devfreq_resume(struct lima_devfreq *devfreq) +{ + unsigned long irqflags; + + if (!devfreq->devfreq) + return 0; + + spin_lock_irqsave(&devfreq->lock, irqflags); + + lima_devfreq_reset(devfreq); + + spin_unlock_irqrestore(&devfreq->lock, irqflags); + + return devfreq_resume_device(devfreq->devfreq); +} + +int lima_devfreq_suspend(struct lima_devfreq *devfreq) +{ + if (!devfreq->devfreq) + return 0; + + return devfreq_suspend_device(devfreq->devfreq); +} diff --git a/drivers/gpu/drm/lima/lima_devfreq.h b/drivers/gpu/drm/lima/lima_devfreq.h index 8d71ba9fb22a..5eed2975a375 100644 --- a/drivers/gpu/drm/lima/lima_devfreq.h +++ b/drivers/gpu/drm/lima/lima_devfreq.h @@ -38,4 +38,7 @@ void lima_devfreq_fini(struct lima_device *ldev); void lima_devfreq_record_busy(struct lima_devfreq *devfreq); void lima_devfreq_record_idle(struct lima_devfreq *devfreq); +int lima_devfreq_resume(struct lima_devfreq *devfreq); +int lima_devfreq_suspend(struct lima_devfreq *devfreq); + #endif From patchwork Tue Apr 21 13:35:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 11501419 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52F391575 for ; Tue, 21 Apr 2020 13:37:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 31C5E20738 for ; Tue, 21 Apr 2020 13:37:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iOvby6IN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31C5E20738 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C1056E96A; Tue, 21 Apr 2020 13:37:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id 02B0D6E966; Tue, 21 Apr 2020 13:37:46 +0000 (UTC) Received: by mail-pg1-x541.google.com with SMTP id h69so6762573pgc.8; Tue, 21 Apr 2020 06:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=heflTtIWlDgCdrkpY0GpyDbRrtx8bAEMI94sj04Xy/4=; b=iOvby6INOMaPgxnHyr9N1zLJvCtplEFqXveCtLZycZ01hLF1nvWyjfqiNlUrOB3/mg r43BDs2pe7TwB2MS4NwkRn4cPJrmMgnxgSX3TREC9G+UfyfdSV9PYNGKTn5yV4PSieup lgLy6S7ZaJ/li/J1MUoFjmvpI0/kk1TiiQVYx/dUuKRgCoecIAb1ka7ISbN6Uasqn5AN C71nqFdCk8KPnK+kafYgWiDzZQPfwVHqUIY2wzf9xtMpEKTSEw2PTMo2Kxolww4TDUr8 tCUn6PJyYb8Yr9SdiQfSbUJogg1wr1MdBS9/CkshAwjj3O/y6pRS+EOPDqgVNPmb56KI 0Oag== 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; bh=heflTtIWlDgCdrkpY0GpyDbRrtx8bAEMI94sj04Xy/4=; b=KvtnbmonuywkiXCpHGDd03MDLpTwctvn5Kh/nb9f9DlKy91+qCg5D6ZwsKOEtPvrAD AwYKcPgKi1rw/Y4bC85hN7jq7b4ufkRn8XBgzedSE21pPWVYqMlpSM4rTY+ja6aBIKkn 1gAlFiXQeow2PxjRykpW1NYOyOy1FSotHOQ6ikORmSKKT/ezrjwC6rMjOqfcygKR2qjY VIIvVmsr80rJPiXG0v4KlP8ITWPlHTBuQ1Re1VtUPTX9Ml+FYzviORnGSz780BRG0zb6 TQ/xjMyaOmUUYz6kKe2OPKjfQ7EpJxQ3aXZuDRVK7zDm5tIHpk5zLIpQdMhXMJzz1704 EmgA== X-Gm-Message-State: AGi0PuaZx4Hx8YRS1lLVnRyhkijtipJCJniwOBWKIKzN1+ks14ghYFjm HSi//GE0qYTa5Q1XSrvVjnxjA1hA5puoxw== X-Google-Smtp-Source: APiQypLZ6+IYPSKZft3kAWu5xyzsljzByJzf/GiKlC9QUkP6M8bFiZ0hBMw+rNbgjnEXSdL627MDeA== X-Received: by 2002:a62:3784:: with SMTP id e126mr21921270pfa.303.1587476265333; Tue, 21 Apr 2020 06:37:45 -0700 (PDT) Received: from yuq-Aspire-4738G.lan (li2017-195.members.linode.com. [172.105.124.195]) by smtp.gmail.com with ESMTPSA id r23sm2551327pfr.64.2020.04.21.06.37.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:37:44 -0700 (PDT) From: Qiang Yu To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 06/10] drm/lima: power down ip blocks when pmu exit Date: Tue, 21 Apr 2020 21:35:47 +0800 Message-Id: <20200421133551.31481-7-yuq825@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200421133551.31481-1-yuq825@gmail.com> References: <20200421133551.31481-1-yuq825@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lima@lists.freedesktop.org, David Airlie , Bhushan Shah , Vasily Khoruzhick , Andreas Baierl , Qiang Yu , Erico Nunes MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Prepare resume/suspend PM. v2: Fix lima_pmu_wait_cmd timeout when mali400 case. Signed-off-by: Qiang Yu --- drivers/gpu/drm/lima/lima_device.h | 2 ++ drivers/gpu/drm/lima/lima_pmu.c | 53 +++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/lima/lima_device.h b/drivers/gpu/drm/lima/lima_device.h index 06fd9636dd72..1a5032b08883 100644 --- a/drivers/gpu/drm/lima/lima_device.h +++ b/drivers/gpu/drm/lima/lima_device.h @@ -64,6 +64,8 @@ struct lima_ip { bool async_reset; /* l2 cache */ spinlock_t lock; + /* pmu */ + u32 mask; } data; }; diff --git a/drivers/gpu/drm/lima/lima_pmu.c b/drivers/gpu/drm/lima/lima_pmu.c index 571f6d661581..d476569f2043 100644 --- a/drivers/gpu/drm/lima/lima_pmu.c +++ b/drivers/gpu/drm/lima/lima_pmu.c @@ -21,7 +21,7 @@ static int lima_pmu_wait_cmd(struct lima_ip *ip) v, v & LIMA_PMU_INT_CMD_MASK, 100, 100000); if (err) { - dev_err(dev->dev, "timeout wait pmd cmd\n"); + dev_err(dev->dev, "timeout wait pmu cmd\n"); return err; } @@ -29,6 +29,40 @@ static int lima_pmu_wait_cmd(struct lima_ip *ip) return 0; } +static u32 lima_pmu_get_ip_mask(struct lima_ip *ip) +{ + struct lima_device *dev = ip->dev; + u32 ret = 0; + int i; + + ret |= LIMA_PMU_POWER_GP0_MASK; + + if (dev->id == lima_gpu_mali400) { + ret |= LIMA_PMU_POWER_L2_MASK; + for (i = 0; i < 4; i++) { + if (dev->ip[lima_ip_pp0 + i].present) + ret |= LIMA_PMU_POWER_PP_MASK(i); + } + } else { + if (dev->ip[lima_ip_pp0].present) + ret |= LIMA450_PMU_POWER_PP0_MASK; + for (i = lima_ip_pp1; i <= lima_ip_pp3; i++) { + if (dev->ip[i].present) { + ret |= LIMA450_PMU_POWER_PP13_MASK; + break; + } + } + for (i = lima_ip_pp4; i <= lima_ip_pp7; i++) { + if (dev->ip[i].present) { + ret |= LIMA450_PMU_POWER_PP47_MASK; + break; + } + } + } + + return ret; +} + int lima_pmu_init(struct lima_ip *ip) { int err; @@ -56,5 +90,22 @@ int lima_pmu_init(struct lima_ip *ip) void lima_pmu_fini(struct lima_ip *ip) { + u32 stat; + + if (!ip->data.mask) + ip->data.mask = lima_pmu_get_ip_mask(ip); + stat = ~pmu_read(LIMA_PMU_STATUS) & ip->data.mask; + if (stat) { + pmu_write(LIMA_PMU_POWER_DOWN, stat); + + /* Don't wait for interrupt on Mali400 if all domains are + * powered off because the HW won't generate an interrupt + * in this case. + */ + if (ip->dev->id == lima_gpu_mali400) + pmu_write(LIMA_PMU_INT_CLEAR, LIMA_PMU_INT_CMD_MASK); + else + lima_pmu_wait_cmd(ip); + } } From patchwork Tue Apr 21 13:35:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 11501421 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A872092C for ; Tue, 21 Apr 2020 13:37:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 86B44206F4 for ; Tue, 21 Apr 2020 13:37:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gPtyxAMp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86B44206F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C781E6E966; Tue, 21 Apr 2020 13:37:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by gabe.freedesktop.org (Postfix) with ESMTPS id 76E276E966; Tue, 21 Apr 2020 13:37:51 +0000 (UTC) Received: by mail-pg1-x536.google.com with SMTP id o185so6232314pgo.3; Tue, 21 Apr 2020 06:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DchvojA7hVqsz/nbV2Oma/WYtV5X37C9HkzPalCpufQ=; b=gPtyxAMpi9ho+CtFOLjo0c5SQBE9cTZhF1fO98u4RU1GSwgehUQsEg4uMpgMNsRrRC vDMLAFsviR8PXjDUwxDCq7tS0wACnJlhViO9b3h1tnhPB9uEtcIJFttKuYJk5gdKTsNY CmSXhyhXKDK57fmLIha3UZn3mDwbMKAJVP6uwrzdiEGuUwADTcP/4AQC8FvAtAQsICeW iUWy0vDf/MHXTiWbuSDCmoRGDYcbsuu9814z1d8jQvtef7SnLgyq+g4s/Mdxtre6b5qc bgfcbvzhp9a7bqvpKoMSrgleiK8fbh2zVZpfxCYUO+ywn3kxIHExi0+lKof0ORPu6Vdy EBeQ== 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; bh=DchvojA7hVqsz/nbV2Oma/WYtV5X37C9HkzPalCpufQ=; b=OqUuaeR/obZkT4H4PfEn8lGQzeDOLDDlpHt/mgIzVMPkKgViJhr/Edy5r0KzGR0S+N zwG/QxxkvqsPou0iua9BKyao2cQL/Pi1Q5RvL3CwTvkoiHAI9B0/XYBrr7LtoeokU30y tlm2jg5f+v5wtRLCeNvJvK+BV35l7Z1/D0g/R5LTsDo1cw1Q1mwFjFMAViXUSp3zk4wS sE7I59jJCqCxB4lH1UQWhmFjLaZ1by4cGBj7h/gTnm57aIX2LayvXRZjXwQV+IhclCUs ws8eyb8jKVhop1dp1IRiPz1NaMjSKKva6sWwPRUkOzLnPpH80MFJpiQk4JZgBa6EFWIa TpJg== X-Gm-Message-State: AGi0PuYgvy5xexWD9mpAwwLsBu5LrOLKXEZihIcDWwJV/2hJ0kCRk4r1 wuLAzqb9kpZq735j9d2DkCDLbBjDvbiwag== X-Google-Smtp-Source: APiQypJ2dXgHBN/d2sU1KVS/mh2Uey9JXC4zeyilnVmbrkEOtXSa5iE5gNMNmKt1FtInEz5vVBf8CQ== X-Received: by 2002:aa7:9317:: with SMTP id 23mr10798342pfj.189.1587476270384; Tue, 21 Apr 2020 06:37:50 -0700 (PDT) Received: from yuq-Aspire-4738G.lan (li2017-195.members.linode.com. [172.105.124.195]) by smtp.gmail.com with ESMTPSA id r23sm2551327pfr.64.2020.04.21.06.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:37:49 -0700 (PDT) From: Qiang Yu To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 07/10] drm/lima: add resume/suspend callback for each ip Date: Tue, 21 Apr 2020 21:35:48 +0800 Message-Id: <20200421133551.31481-8-yuq825@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200421133551.31481-1-yuq825@gmail.com> References: <20200421133551.31481-1-yuq825@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lima@lists.freedesktop.org, David Airlie , Bhushan Shah , Vasily Khoruzhick , Andreas Baierl , Qiang Yu , Erico Nunes MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" For called when PM do resume/suspend. Signed-off-by: Qiang Yu --- drivers/gpu/drm/lima/lima_bcast.c | 25 ++++++++++++---- drivers/gpu/drm/lima/lima_bcast.h | 2 ++ drivers/gpu/drm/lima/lima_device.c | 4 +++ drivers/gpu/drm/lima/lima_device.h | 2 +- drivers/gpu/drm/lima/lima_dlbu.c | 17 ++++++++++- drivers/gpu/drm/lima/lima_dlbu.h | 2 ++ drivers/gpu/drm/lima/lima_gp.c | 21 +++++++++++-- drivers/gpu/drm/lima/lima_gp.h | 2 ++ drivers/gpu/drm/lima/lima_l2_cache.c | 37 ++++++++++++++++------- drivers/gpu/drm/lima/lima_l2_cache.h | 2 ++ drivers/gpu/drm/lima/lima_mmu.c | 45 ++++++++++++++++++++-------- drivers/gpu/drm/lima/lima_mmu.h | 2 ++ drivers/gpu/drm/lima/lima_pmu.c | 24 +++++++++++++-- drivers/gpu/drm/lima/lima_pmu.h | 2 ++ drivers/gpu/drm/lima/lima_pp.c | 31 +++++++++++++++++-- drivers/gpu/drm/lima/lima_pp.h | 4 +++ 16 files changed, 185 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/lima/lima_bcast.c b/drivers/gpu/drm/lima/lima_bcast.c index 288398027bfa..fbc43f243c54 100644 --- a/drivers/gpu/drm/lima/lima_bcast.c +++ b/drivers/gpu/drm/lima/lima_bcast.c @@ -26,18 +26,33 @@ void lima_bcast_enable(struct lima_device *dev, int num_pp) bcast_write(LIMA_BCAST_BROADCAST_MASK, mask); } +static int lima_bcast_hw_init(struct lima_ip *ip) +{ + bcast_write(LIMA_BCAST_BROADCAST_MASK, ip->data.mask << 16); + bcast_write(LIMA_BCAST_INTERRUPT_MASK, ip->data.mask); + return 0; +} + +int lima_bcast_resume(struct lima_ip *ip) +{ + return lima_bcast_hw_init(ip); +} + +void lima_bcast_suspend(struct lima_ip *ip) +{ + +} + int lima_bcast_init(struct lima_ip *ip) { - int i, mask = 0; + int i; for (i = lima_ip_pp0; i <= lima_ip_pp7; i++) { if (ip->dev->ip[i].present) - mask |= 1 << (i - lima_ip_pp0); + ip->data.mask |= 1 << (i - lima_ip_pp0); } - bcast_write(LIMA_BCAST_BROADCAST_MASK, mask << 16); - bcast_write(LIMA_BCAST_INTERRUPT_MASK, mask); - return 0; + return lima_bcast_hw_init(ip); } void lima_bcast_fini(struct lima_ip *ip) diff --git a/drivers/gpu/drm/lima/lima_bcast.h b/drivers/gpu/drm/lima/lima_bcast.h index c47e58563d0a..465ee587bceb 100644 --- a/drivers/gpu/drm/lima/lima_bcast.h +++ b/drivers/gpu/drm/lima/lima_bcast.h @@ -6,6 +6,8 @@ struct lima_ip; +int lima_bcast_resume(struct lima_ip *ip); +void lima_bcast_suspend(struct lima_ip *ip); int lima_bcast_init(struct lima_ip *ip); void lima_bcast_fini(struct lima_ip *ip); diff --git a/drivers/gpu/drm/lima/lima_device.c b/drivers/gpu/drm/lima/lima_device.c index 247f51fd40a2..e5f1f84ba85a 100644 --- a/drivers/gpu/drm/lima/lima_device.c +++ b/drivers/gpu/drm/lima/lima_device.c @@ -25,6 +25,8 @@ struct lima_ip_desc { int (*init)(struct lima_ip *ip); void (*fini)(struct lima_ip *ip); + int (*resume)(struct lima_ip *ip); + void (*suspend)(struct lima_ip *ip); }; #define LIMA_IP_DESC(ipname, mst0, mst1, off0, off1, func, irq) \ @@ -41,6 +43,8 @@ struct lima_ip_desc { }, \ .init = lima_##func##_init, \ .fini = lima_##func##_fini, \ + .resume = lima_##func##_resume, \ + .suspend = lima_##func##_suspend, \ } static struct lima_ip_desc lima_ip_desc[lima_ip_num] = { diff --git a/drivers/gpu/drm/lima/lima_device.h b/drivers/gpu/drm/lima/lima_device.h index 1a5032b08883..095a0b5f1703 100644 --- a/drivers/gpu/drm/lima/lima_device.h +++ b/drivers/gpu/drm/lima/lima_device.h @@ -64,7 +64,7 @@ struct lima_ip { bool async_reset; /* l2 cache */ spinlock_t lock; - /* pmu */ + /* pmu/bcast */ u32 mask; } data; }; diff --git a/drivers/gpu/drm/lima/lima_dlbu.c b/drivers/gpu/drm/lima/lima_dlbu.c index 8399ceffb94b..c1d5ea35daa7 100644 --- a/drivers/gpu/drm/lima/lima_dlbu.c +++ b/drivers/gpu/drm/lima/lima_dlbu.c @@ -42,7 +42,7 @@ void lima_dlbu_set_reg(struct lima_ip *ip, u32 *reg) dlbu_write(LIMA_DLBU_START_TILE_POS, reg[3]); } -int lima_dlbu_init(struct lima_ip *ip) +static int lima_dlbu_hw_init(struct lima_ip *ip) { struct lima_device *dev = ip->dev; @@ -52,6 +52,21 @@ int lima_dlbu_init(struct lima_ip *ip) return 0; } +int lima_dlbu_resume(struct lima_ip *ip) +{ + return lima_dlbu_hw_init(ip); +} + +void lima_dlbu_suspend(struct lima_ip *ip) +{ + +} + +int lima_dlbu_init(struct lima_ip *ip) +{ + return lima_dlbu_hw_init(ip); +} + void lima_dlbu_fini(struct lima_ip *ip) { diff --git a/drivers/gpu/drm/lima/lima_dlbu.h b/drivers/gpu/drm/lima/lima_dlbu.h index 16f877984466..be71daaaee89 100644 --- a/drivers/gpu/drm/lima/lima_dlbu.h +++ b/drivers/gpu/drm/lima/lima_dlbu.h @@ -12,6 +12,8 @@ void lima_dlbu_disable(struct lima_device *dev); void lima_dlbu_set_reg(struct lima_ip *ip, u32 *reg); +int lima_dlbu_resume(struct lima_ip *ip); +void lima_dlbu_suspend(struct lima_ip *ip); int lima_dlbu_init(struct lima_ip *ip); void lima_dlbu_fini(struct lima_ip *ip); diff --git a/drivers/gpu/drm/lima/lima_gp.c b/drivers/gpu/drm/lima/lima_gp.c index d8841c870d90..8dd501b7a3d0 100644 --- a/drivers/gpu/drm/lima/lima_gp.c +++ b/drivers/gpu/drm/lima/lima_gp.c @@ -274,6 +274,23 @@ static void lima_gp_print_version(struct lima_ip *ip) static struct kmem_cache *lima_gp_task_slab; static int lima_gp_task_slab_refcnt; +static int lima_gp_hw_init(struct lima_ip *ip) +{ + ip->data.async_reset = false; + lima_gp_soft_reset_async(ip); + return lima_gp_soft_reset_async_wait(ip); +} + +int lima_gp_resume(struct lima_ip *ip) +{ + return lima_gp_hw_init(ip); +} + +void lima_gp_suspend(struct lima_ip *ip) +{ + +} + int lima_gp_init(struct lima_ip *ip) { struct lima_device *dev = ip->dev; @@ -281,9 +298,7 @@ int lima_gp_init(struct lima_ip *ip) lima_gp_print_version(ip); - ip->data.async_reset = false; - lima_gp_soft_reset_async(ip); - err = lima_gp_soft_reset_async_wait(ip); + err = lima_gp_hw_init(ip); if (err) return err; diff --git a/drivers/gpu/drm/lima/lima_gp.h b/drivers/gpu/drm/lima/lima_gp.h index 516e5c1babbb..02ec9af78a51 100644 --- a/drivers/gpu/drm/lima/lima_gp.h +++ b/drivers/gpu/drm/lima/lima_gp.h @@ -7,6 +7,8 @@ struct lima_ip; struct lima_device; +int lima_gp_resume(struct lima_ip *ip); +void lima_gp_suspend(struct lima_ip *ip); int lima_gp_init(struct lima_ip *ip); void lima_gp_fini(struct lima_ip *ip); diff --git a/drivers/gpu/drm/lima/lima_l2_cache.c b/drivers/gpu/drm/lima/lima_l2_cache.c index 6873a7af5a5c..c67fa34fba18 100644 --- a/drivers/gpu/drm/lima/lima_l2_cache.c +++ b/drivers/gpu/drm/lima/lima_l2_cache.c @@ -38,9 +38,34 @@ int lima_l2_cache_flush(struct lima_ip *ip) return ret; } +static int lima_l2_cache_hw_init(struct lima_ip *ip) +{ + int err; + + err = lima_l2_cache_flush(ip); + if (err) + return err; + + l2_cache_write(LIMA_L2_CACHE_ENABLE, + LIMA_L2_CACHE_ENABLE_ACCESS|LIMA_L2_CACHE_ENABLE_READ_ALLOCATE); + l2_cache_write(LIMA_L2_CACHE_MAX_READS, 0x1c); + + return 0; +} + +int lima_l2_cache_resume(struct lima_ip *ip) +{ + return lima_l2_cache_hw_init(ip); +} + +void lima_l2_cache_suspend(struct lima_ip *ip) +{ + +} + int lima_l2_cache_init(struct lima_ip *ip) { - int i, err; + int i; u32 size; struct lima_device *dev = ip->dev; @@ -63,15 +88,7 @@ int lima_l2_cache_init(struct lima_ip *ip) 1 << (size & 0xff), 1 << ((size >> 24) & 0xff)); - err = lima_l2_cache_flush(ip); - if (err) - return err; - - l2_cache_write(LIMA_L2_CACHE_ENABLE, - LIMA_L2_CACHE_ENABLE_ACCESS|LIMA_L2_CACHE_ENABLE_READ_ALLOCATE); - l2_cache_write(LIMA_L2_CACHE_MAX_READS, 0x1c); - - return 0; + return lima_l2_cache_hw_init(ip); } void lima_l2_cache_fini(struct lima_ip *ip) diff --git a/drivers/gpu/drm/lima/lima_l2_cache.h b/drivers/gpu/drm/lima/lima_l2_cache.h index c63fb676ff14..1aeeefd53fb9 100644 --- a/drivers/gpu/drm/lima/lima_l2_cache.h +++ b/drivers/gpu/drm/lima/lima_l2_cache.h @@ -6,6 +6,8 @@ struct lima_ip; +int lima_l2_cache_resume(struct lima_ip *ip); +void lima_l2_cache_suspend(struct lima_ip *ip); int lima_l2_cache_init(struct lima_ip *ip); void lima_l2_cache_fini(struct lima_ip *ip); diff --git a/drivers/gpu/drm/lima/lima_mmu.c b/drivers/gpu/drm/lima/lima_mmu.c index c26b751b0f9d..dfdd12b1c5c0 100644 --- a/drivers/gpu/drm/lima/lima_mmu.c +++ b/drivers/gpu/drm/lima/lima_mmu.c @@ -59,12 +59,43 @@ static irqreturn_t lima_mmu_irq_handler(int irq, void *data) return IRQ_HANDLED; } -int lima_mmu_init(struct lima_ip *ip) +static int lima_mmu_hw_init(struct lima_ip *ip) { struct lima_device *dev = ip->dev; int err; u32 v; + mmu_write(LIMA_MMU_COMMAND, LIMA_MMU_COMMAND_HARD_RESET); + err = lima_mmu_send_command(LIMA_MMU_COMMAND_HARD_RESET, + LIMA_MMU_DTE_ADDR, v, v == 0); + if (err) + return err; + + mmu_write(LIMA_MMU_INT_MASK, LIMA_MMU_INT_PAGE_FAULT | LIMA_MMU_INT_READ_BUS_ERROR); + mmu_write(LIMA_MMU_DTE_ADDR, dev->empty_vm->pd.dma); + return lima_mmu_send_command(LIMA_MMU_COMMAND_ENABLE_PAGING, + LIMA_MMU_STATUS, v, + v & LIMA_MMU_STATUS_PAGING_ENABLED); +} + +int lima_mmu_resume(struct lima_ip *ip) +{ + if (ip->id == lima_ip_ppmmu_bcast) + return 0; + + return lima_mmu_hw_init(ip); +} + +void lima_mmu_suspend(struct lima_ip *ip) +{ + +} + +int lima_mmu_init(struct lima_ip *ip) +{ + struct lima_device *dev = ip->dev; + int err; + if (ip->id == lima_ip_ppmmu_bcast) return 0; @@ -74,12 +105,6 @@ int lima_mmu_init(struct lima_ip *ip) return -EIO; } - mmu_write(LIMA_MMU_COMMAND, LIMA_MMU_COMMAND_HARD_RESET); - err = lima_mmu_send_command(LIMA_MMU_COMMAND_HARD_RESET, - LIMA_MMU_DTE_ADDR, v, v == 0); - if (err) - return err; - err = devm_request_irq(dev->dev, ip->irq, lima_mmu_irq_handler, IRQF_SHARED, lima_ip_name(ip), ip); if (err) { @@ -87,11 +112,7 @@ int lima_mmu_init(struct lima_ip *ip) return err; } - mmu_write(LIMA_MMU_INT_MASK, LIMA_MMU_INT_PAGE_FAULT | LIMA_MMU_INT_READ_BUS_ERROR); - mmu_write(LIMA_MMU_DTE_ADDR, dev->empty_vm->pd.dma); - return lima_mmu_send_command(LIMA_MMU_COMMAND_ENABLE_PAGING, - LIMA_MMU_STATUS, v, - v & LIMA_MMU_STATUS_PAGING_ENABLED); + return lima_mmu_hw_init(ip); } void lima_mmu_fini(struct lima_ip *ip) diff --git a/drivers/gpu/drm/lima/lima_mmu.h b/drivers/gpu/drm/lima/lima_mmu.h index 4f8ccbebcba1..f0c97ac75ea0 100644 --- a/drivers/gpu/drm/lima/lima_mmu.h +++ b/drivers/gpu/drm/lima/lima_mmu.h @@ -7,6 +7,8 @@ struct lima_ip; struct lima_vm; +int lima_mmu_resume(struct lima_ip *ip); +void lima_mmu_suspend(struct lima_ip *ip); int lima_mmu_init(struct lima_ip *ip); void lima_mmu_fini(struct lima_ip *ip); diff --git a/drivers/gpu/drm/lima/lima_pmu.c b/drivers/gpu/drm/lima/lima_pmu.c index d476569f2043..e397e1146e96 100644 --- a/drivers/gpu/drm/lima/lima_pmu.c +++ b/drivers/gpu/drm/lima/lima_pmu.c @@ -63,7 +63,7 @@ static u32 lima_pmu_get_ip_mask(struct lima_ip *ip) return ret; } -int lima_pmu_init(struct lima_ip *ip) +static int lima_pmu_hw_init(struct lima_ip *ip) { int err; u32 stat; @@ -88,7 +88,7 @@ int lima_pmu_init(struct lima_ip *ip) return 0; } -void lima_pmu_fini(struct lima_ip *ip) +static void lima_pmu_hw_fini(struct lima_ip *ip) { u32 stat; @@ -109,3 +109,23 @@ void lima_pmu_fini(struct lima_ip *ip) lima_pmu_wait_cmd(ip); } } + +int lima_pmu_resume(struct lima_ip *ip) +{ + return lima_pmu_hw_init(ip); +} + +void lima_pmu_suspend(struct lima_ip *ip) +{ + lima_pmu_hw_fini(ip); +} + +int lima_pmu_init(struct lima_ip *ip) +{ + return lima_pmu_hw_init(ip); +} + +void lima_pmu_fini(struct lima_ip *ip) +{ + lima_pmu_hw_fini(ip); +} diff --git a/drivers/gpu/drm/lima/lima_pmu.h b/drivers/gpu/drm/lima/lima_pmu.h index a2a18775eb07..652dc7af3047 100644 --- a/drivers/gpu/drm/lima/lima_pmu.h +++ b/drivers/gpu/drm/lima/lima_pmu.h @@ -6,6 +6,8 @@ struct lima_ip; +int lima_pmu_resume(struct lima_ip *ip); +void lima_pmu_suspend(struct lima_ip *ip); int lima_pmu_init(struct lima_ip *ip); void lima_pmu_fini(struct lima_ip *ip); diff --git a/drivers/gpu/drm/lima/lima_pp.c b/drivers/gpu/drm/lima/lima_pp.c index 8fef224b93c8..33f01383409c 100644 --- a/drivers/gpu/drm/lima/lima_pp.c +++ b/drivers/gpu/drm/lima/lima_pp.c @@ -223,6 +223,23 @@ static void lima_pp_print_version(struct lima_ip *ip) lima_ip_name(ip), name, major, minor); } +static int lima_pp_hw_init(struct lima_ip *ip) +{ + ip->data.async_reset = false; + lima_pp_soft_reset_async(ip); + return lima_pp_soft_reset_async_wait(ip); +} + +int lima_pp_resume(struct lima_ip *ip) +{ + return lima_pp_hw_init(ip); +} + +void lima_pp_suspend(struct lima_ip *ip) +{ + +} + int lima_pp_init(struct lima_ip *ip) { struct lima_device *dev = ip->dev; @@ -230,9 +247,7 @@ int lima_pp_init(struct lima_ip *ip) lima_pp_print_version(ip); - ip->data.async_reset = false; - lima_pp_soft_reset_async(ip); - err = lima_pp_soft_reset_async_wait(ip); + err = lima_pp_hw_init(ip); if (err) return err; @@ -254,6 +269,16 @@ void lima_pp_fini(struct lima_ip *ip) } +int lima_pp_bcast_resume(struct lima_ip *ip) +{ + return 0; +} + +void lima_pp_bcast_suspend(struct lima_ip *ip) +{ + +} + int lima_pp_bcast_init(struct lima_ip *ip) { struct lima_device *dev = ip->dev; diff --git a/drivers/gpu/drm/lima/lima_pp.h b/drivers/gpu/drm/lima/lima_pp.h index bf60c77b2633..16ec96de15a9 100644 --- a/drivers/gpu/drm/lima/lima_pp.h +++ b/drivers/gpu/drm/lima/lima_pp.h @@ -7,9 +7,13 @@ struct lima_ip; struct lima_device; +int lima_pp_resume(struct lima_ip *ip); +void lima_pp_suspend(struct lima_ip *ip); int lima_pp_init(struct lima_ip *ip); void lima_pp_fini(struct lima_ip *ip); +int lima_pp_bcast_resume(struct lima_ip *ip); +void lima_pp_bcast_suspend(struct lima_ip *ip); int lima_pp_bcast_init(struct lima_ip *ip); void lima_pp_bcast_fini(struct lima_ip *ip); From patchwork Tue Apr 21 13:35:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 11501423 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B3D2792C for ; Tue, 21 Apr 2020 13:37:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 925CE2076C for ; Tue, 21 Apr 2020 13:37:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HZ1jVCY0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 925CE2076C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 794866E965; Tue, 21 Apr 2020 13:37:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id B64E76E96B; Tue, 21 Apr 2020 13:37:55 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id x3so6594686pfp.7; Tue, 21 Apr 2020 06:37:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WZJv2zaSebQm22EUezH7vPhs/Qwwg/oJh0qpgLg+YdE=; b=HZ1jVCY0o1WVjmlDkYpPfmpgxD/+LTF2HHJOONJbRjOexDI/atDHU9sOlV4qg5BpzN jLC3yydD8MgoWmv6/5xMWgVYBDwV99Z77dLhuIcWP1y/I62KQPbNbQKCREJIhTU5ccoT ebCdj+QcFTxuLce3ttr+LWGksqnRLTUMC7J1BdQ7GlcQnPNS5AKVZtQgBf/Tqs2gm329 J9XLBF5iLSXjAH6pCAYfQrBN4ecOPggc+dqO/U5KezTKiNuoIkxrZimnfBnkA64uNgeI cLY3ZvAEoKeXQ3CzdatG4z6wYd7aL1upKfRAtwweU4r2sC+O2+tfPeH5Bft7m94m5EG2 2nFQ== 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; bh=WZJv2zaSebQm22EUezH7vPhs/Qwwg/oJh0qpgLg+YdE=; b=jnwKDlT9qwlWF8lQTmao6fFzYDSkuEz6fGFvj2N5OLM1me5MoGGNCowhLO37cTwWsH Z0vlDzQHRiN17MS0nHr3R5Q7txPr1k1AhLyOUKQReCdFTeKp0FbsFLBa4C4lJdyvce2t xBdXb0BVQGFDjWnbQD89vMkDgHuchRbm8bZ8GibNiPhk1Td5/DfD8azJrQH7As004EIv uF3XCyfGmhbI4uoxRvb0W9DH4YAKntY4gg1XDtBdFBgoBvSQjp1PThVwTzejB4bv6UQX 5ug7XOsIHC4cz5Ztb2kIdYOv/yGhplIugrXfKBGm3k3/ZSc2qYUORRmu3Q6nvykQ61k0 eOGA== X-Gm-Message-State: AGi0Pubqj+W+LvqubXc1M4VWqFtXDhZPkY8HsBfJiVARiajstxfvmuYK cIE7YlBnxgOq4Jmow/3yTxYVLIEhMWU6EQ== X-Google-Smtp-Source: APiQypKNcYsi6dGYJQM0NM/nilT+JjKdUcqrWSWITT3Qkd61c8/Om0ICooJEWUA/9m2k0DEnlsU/7Q== X-Received: by 2002:a63:6d87:: with SMTP id i129mr21691152pgc.54.1587476275064; Tue, 21 Apr 2020 06:37:55 -0700 (PDT) Received: from yuq-Aspire-4738G.lan (li2017-195.members.linode.com. [172.105.124.195]) by smtp.gmail.com with ESMTPSA id r23sm2551327pfr.64.2020.04.21.06.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:37:54 -0700 (PDT) From: Qiang Yu To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 08/10] drm/lima: seperate clk/regulator enable/disable function Date: Tue, 21 Apr 2020 21:35:49 +0800 Message-Id: <20200421133551.31481-9-yuq825@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200421133551.31481-1-yuq825@gmail.com> References: <20200421133551.31481-1-yuq825@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lima@lists.freedesktop.org, David Airlie , Bhushan Shah , Vasily Khoruzhick , Andreas Baierl , Qiang Yu , Erico Nunes MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" For being used by both device init/fini and suspend/resume. Signed-off-by: Qiang Yu --- drivers/gpu/drm/lima/lima_device.c | 105 +++++++++++++++++++---------- 1 file changed, 68 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/lima/lima_device.c b/drivers/gpu/drm/lima/lima_device.c index e5f1f84ba85a..281e05a8cd4b 100644 --- a/drivers/gpu/drm/lima/lima_device.c +++ b/drivers/gpu/drm/lima/lima_device.c @@ -81,26 +81,10 @@ const char *lima_ip_name(struct lima_ip *ip) return lima_ip_desc[ip->id].name; } -static int lima_clk_init(struct lima_device *dev) +static int lima_clk_enable(struct lima_device *dev) { int err; - dev->clk_bus = devm_clk_get(dev->dev, "bus"); - if (IS_ERR(dev->clk_bus)) { - err = PTR_ERR(dev->clk_bus); - if (err != -EPROBE_DEFER) - dev_err(dev->dev, "get bus clk failed %d\n", err); - return err; - } - - dev->clk_gpu = devm_clk_get(dev->dev, "core"); - if (IS_ERR(dev->clk_gpu)) { - err = PTR_ERR(dev->clk_gpu); - if (err != -EPROBE_DEFER) - dev_err(dev->dev, "get core clk failed %d\n", err); - return err; - } - err = clk_prepare_enable(dev->clk_bus); if (err) return err; @@ -109,15 +93,7 @@ static int lima_clk_init(struct lima_device *dev) if (err) goto error_out0; - dev->reset = devm_reset_control_array_get_optional_shared(dev->dev); - - if (IS_ERR(dev->reset)) { - err = PTR_ERR(dev->reset); - if (err != -EPROBE_DEFER) - dev_err(dev->dev, "get reset controller failed %d\n", - err); - goto error_out1; - } else if (dev->reset != NULL) { + if (dev->reset) { err = reset_control_deassert(dev->reset); if (err) { dev_err(dev->dev, @@ -135,14 +111,76 @@ static int lima_clk_init(struct lima_device *dev) return err; } -static void lima_clk_fini(struct lima_device *dev) +static void lima_clk_disable(struct lima_device *dev) { - if (dev->reset != NULL) + if (dev->reset) reset_control_assert(dev->reset); clk_disable_unprepare(dev->clk_gpu); clk_disable_unprepare(dev->clk_bus); } +static int lima_clk_init(struct lima_device *dev) +{ + int err; + + dev->clk_bus = devm_clk_get(dev->dev, "bus"); + if (IS_ERR(dev->clk_bus)) { + err = PTR_ERR(dev->clk_bus); + if (err != -EPROBE_DEFER) + dev_err(dev->dev, "get bus clk failed %d\n", err); + dev->clk_bus = NULL; + return err; + } + + dev->clk_gpu = devm_clk_get(dev->dev, "core"); + if (IS_ERR(dev->clk_gpu)) { + err = PTR_ERR(dev->clk_gpu); + if (err != -EPROBE_DEFER) + dev_err(dev->dev, "get core clk failed %d\n", err); + dev->clk_gpu = NULL; + return err; + } + + dev->reset = devm_reset_control_array_get_optional_shared(dev->dev); + if (IS_ERR(dev->reset)) { + err = PTR_ERR(dev->reset); + if (err != -EPROBE_DEFER) + dev_err(dev->dev, "get reset controller failed %d\n", + err); + dev->reset = NULL; + return err; + } + + return lima_clk_enable(dev); +} + +static void lima_clk_fini(struct lima_device *dev) +{ + lima_clk_disable(dev); +} + +static int lima_regulator_enable(struct lima_device *dev) +{ + int ret; + + if (!dev->regulator) + return 0; + + ret = regulator_enable(dev->regulator); + if (ret < 0) { + dev_err(dev->dev, "failed to enable regulator: %d\n", ret); + return ret; + } + + return 0; +} + +static void lima_regulator_disable(struct lima_device *dev) +{ + if (dev->regulator) + regulator_disable(dev->regulator); +} + static int lima_regulator_init(struct lima_device *dev) { int ret; @@ -158,19 +196,12 @@ static int lima_regulator_init(struct lima_device *dev) return ret; } - ret = regulator_enable(dev->regulator); - if (ret < 0) { - dev_err(dev->dev, "failed to enable regulator: %d\n", ret); - return ret; - } - - return 0; + return lima_regulator_enable(dev); } static void lima_regulator_fini(struct lima_device *dev) { - if (dev->regulator) - regulator_disable(dev->regulator); + lima_regulator_disable(dev); } static int lima_init_ip(struct lima_device *dev, int index) From patchwork Tue Apr 21 13:35:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 11501425 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB80C1575 for ; Tue, 21 Apr 2020 13:38:02 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B9ECF20753 for ; Tue, 21 Apr 2020 13:38:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BpHGErVz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9ECF20753 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 07D446E96E; Tue, 21 Apr 2020 13:38:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED12D6E96C; Tue, 21 Apr 2020 13:38:00 +0000 (UTC) Received: by mail-pj1-x1042.google.com with SMTP id a5so594980pjh.2; Tue, 21 Apr 2020 06:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p1sZojRZuulpM3UISkxCmzN1CiQezNLcWyLy7dmd0bI=; b=BpHGErVzriwKJQa+iIem6oC2UgjjO3J8hDjKOFc1NuOuLnHMMiBhTttJe549egxj0p CraHOcdqzukBCRg1L8lMkzsxnHqUBdRQeje3OWiJgw/5XK4kJWu6m+1BAus3UsYOEYAI kgAeNaQMGySN8yFOKjbCzOfSf5DqmkNCFHjT77t3XfCkQKLVCPT9R/S+nz3YLLlQ/CJA /cJ8bPL/ZGcOHS4KiWkLq1WYK+07WohKryLSjcLBzaVddtV3vJnAVPtgXhBdv7KBgdOB IQfNvgRozXtqcSFb46xjU6fLTLNmuTYKPlVuokNWyjfPvl+4bEEWk0w138RqmTsA2FtO KX3w== 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; bh=p1sZojRZuulpM3UISkxCmzN1CiQezNLcWyLy7dmd0bI=; b=gvt6fefi32Epgu/R5rYsdsvy2S7xqKYS4KX1cR4TmExUxAnYj/IRujQ+05FqUGEK7e bPbdoEKPQUkoIbXvwbPj4RRqNY4AFSHw9LhZhBFtnzGcSDNV/22xcOfyQYGTalfEXQIf 9ZUNt6DtRByoMYlOvHxnFO/gGOA1tsH4EPrnpPnIiGKaDGvjtkBcH8TWFH0MgJT/mjKr Z9FOC+FHoQ+UUMbOt/cJ585EtHV2N/pYcQxSv+2nblp0oXz8IcqvMhfwXSzJYoTjauqS Y2ZwdzE0pG0t3X0tg9L9xKWmCc/VqA04C+EKqmCnft16A+OkaJ5elpVYUYv3v/q6edZW GPaw== X-Gm-Message-State: AGi0PuZl125G8KDf1/tPydnoMylbEG9GGdM5SEJpL91/hYe7z47BPxlr LfzPUobTd2q7uHfvDh2DkSou+rRoIvLxbw== X-Google-Smtp-Source: APiQypIwnbvGglR6uP7HqFJkcFO1y/SceXILfnf8ojcR1pSHjSuRbttBw/1HSWykkLJrO9p2F76dQQ== X-Received: by 2002:a17:902:8a8f:: with SMTP id p15mr21837701plo.45.1587476279840; Tue, 21 Apr 2020 06:37:59 -0700 (PDT) Received: from yuq-Aspire-4738G.lan (li2017-195.members.linode.com. [172.105.124.195]) by smtp.gmail.com with ESMTPSA id r23sm2551327pfr.64.2020.04.21.06.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:37:59 -0700 (PDT) From: Qiang Yu To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 09/10] drm/lima: add pm resume/suspend ops Date: Tue, 21 Apr 2020 21:35:50 +0800 Message-Id: <20200421133551.31481-10-yuq825@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200421133551.31481-1-yuq825@gmail.com> References: <20200421133551.31481-1-yuq825@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lima@lists.freedesktop.org, David Airlie , Bhushan Shah , Vasily Khoruzhick , Andreas Baierl , Qiang Yu , Erico Nunes MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add driver pm system and runtime hardware resume/suspend ops. Note this won't enable runtime pm of the device yet. v2: Do clock and power gating when suspend/resume. Signed-off-by: Qiang Yu --- drivers/gpu/drm/lima/lima_device.c | 90 ++++++++++++++++++++++++++++++ drivers/gpu/drm/lima/lima_device.h | 3 + drivers/gpu/drm/lima/lima_drv.c | 7 +++ 3 files changed, 100 insertions(+) diff --git a/drivers/gpu/drm/lima/lima_device.c b/drivers/gpu/drm/lima/lima_device.c index 281e05a8cd4b..8604b7994943 100644 --- a/drivers/gpu/drm/lima/lima_device.c +++ b/drivers/gpu/drm/lima/lima_device.c @@ -244,6 +244,27 @@ static void lima_fini_ip(struct lima_device *ldev, int index) desc->fini(ip); } +static int lima_resume_ip(struct lima_device *ldev, int index) +{ + struct lima_ip_desc *desc = lima_ip_desc + index; + struct lima_ip *ip = ldev->ip + index; + int ret = 0; + + if (ip->present) + ret = desc->resume(ip); + + return ret; +} + +static void lima_suspend_ip(struct lima_device *ldev, int index) +{ + struct lima_ip_desc *desc = lima_ip_desc + index; + struct lima_ip *ip = ldev->ip + index; + + if (ip->present) + desc->suspend(ip); +} + static int lima_init_gp_pipe(struct lima_device *dev) { struct lima_sched_pipe *pipe = dev->pipe + lima_pipe_gp; @@ -439,3 +460,72 @@ void lima_device_fini(struct lima_device *ldev) lima_clk_fini(ldev); } + +int lima_device_resume(struct device *dev) +{ + struct lima_device *ldev = dev_get_drvdata(dev); + int i, err; + + err = lima_clk_enable(ldev); + if (err) { + dev_err(dev, "resume clk fail %d\n", err); + return err; + } + + err = lima_regulator_enable(ldev); + if (err) { + dev_err(dev, "resume regulator fail %d\n", err); + goto err_out0; + } + + for (i = 0; i < lima_ip_num; i++) { + err = lima_resume_ip(ldev, i); + if (err) { + dev_err(dev, "resume ip %d fail\n", i); + goto err_out1; + } + } + + err = lima_devfreq_resume(&ldev->devfreq); + if (err) { + dev_err(dev, "devfreq resume fail\n"); + goto err_out1; + } + + return 0; + +err_out1: + while (--i >= 0) + lima_suspend_ip(ldev, i); + lima_regulator_disable(ldev); +err_out0: + lima_clk_disable(ldev); + return err; +} + +int lima_device_suspend(struct device *dev) +{ + struct lima_device *ldev = dev_get_drvdata(dev); + int i, err; + + /* check any task running */ + for (i = 0; i < lima_pipe_num; i++) { + if (atomic_read(&ldev->pipe[i].base.hw_rq_count)) + return -EBUSY; + } + + err = lima_devfreq_suspend(&ldev->devfreq); + if (err) { + dev_err(dev, "devfreq suspend fail\n"); + return err; + } + + for (i = lima_ip_num - 1; i >= 0; i--) + lima_suspend_ip(ldev, i); + + lima_regulator_disable(ldev); + + lima_clk_disable(ldev); + + return 0; +} diff --git a/drivers/gpu/drm/lima/lima_device.h b/drivers/gpu/drm/lima/lima_device.h index 095a0b5f1703..e06d1955f4a3 100644 --- a/drivers/gpu/drm/lima/lima_device.h +++ b/drivers/gpu/drm/lima/lima_device.h @@ -141,4 +141,7 @@ static inline int lima_poll_timeout(struct lima_ip *ip, lima_poll_func_t func, return 0; } +int lima_device_suspend(struct device *dev); +int lima_device_resume(struct device *dev); + #endif diff --git a/drivers/gpu/drm/lima/lima_drv.c b/drivers/gpu/drm/lima/lima_drv.c index 91bf5b305e9d..639d1cd3268a 100644 --- a/drivers/gpu/drm/lima/lima_drv.c +++ b/drivers/gpu/drm/lima/lima_drv.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -452,11 +453,17 @@ static const struct of_device_id dt_match[] = { }; MODULE_DEVICE_TABLE(of, dt_match); +static const struct dev_pm_ops lima_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) + SET_RUNTIME_PM_OPS(lima_device_suspend, lima_device_resume, NULL) +}; + static struct platform_driver lima_platform_driver = { .probe = lima_pdev_probe, .remove = lima_pdev_remove, .driver = { .name = "lima", + .pm = &lima_pm_ops, .of_match_table = dt_match, }, }; From patchwork Tue Apr 21 13:35:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 11501427 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35B1392C for ; Tue, 21 Apr 2020 13:38:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13DB2206F4 for ; Tue, 21 Apr 2020 13:38:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KALhDd0+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13DB2206F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD1F96E971; Tue, 21 Apr 2020 13:38:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id 69D9B6E96C; Tue, 21 Apr 2020 13:38:05 +0000 (UTC) Received: by mail-pg1-x543.google.com with SMTP id p8so6765406pgi.5; Tue, 21 Apr 2020 06:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v0LWS4aSBQ6f+C+jRFU323OD19Hb/ZVMLJf3ysSfdoI=; b=KALhDd0+/d0t1Lbkkq2TR0BkC+yXac5Y4ORExj/vYmOP0qkpMJrxn7CV1a81a6/7yq EyjpD1hvr6tbsRsyuAz6x3657MOgqUNrfactadVGVnBzomfp1ISqE4lOHL3Cs7tHzuBl hgy/8xIcrY9NkY8R/pcl4RRiQ5USpaH61uLEe55OAtn9Rm2lmPRwfaf6Q+Vv7b1jthgx UADnIPJrn5ZmLODYC9zLC+FkqB4c5Z8z6oqh0ypren5bAmAm+H/TWDgLWn5qnkhcO/ns Rd1NAjTr5dSjLsNYqQ/PN70dVTn0/czrXlirkZ+8cPb5SUYzIXB+c3ZIHziAv5gdVT+U 2+iQ== 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; bh=v0LWS4aSBQ6f+C+jRFU323OD19Hb/ZVMLJf3ysSfdoI=; b=OQVC0jeejMu8C4SfJHts5aAbEZ8qhsutqWg7X0br2hmG80BzR1bzV8dCpvrc3tEwzC aowFSTaD+OerTKW4QcXXo9uiZi5kwOh+0/ynppC2hHI4QjgysbefxXXFqURCbYDeS1dx whtaPDpmUII6tBTaqjcqA73yCHwE7q8cMpU217KgKgrhOlBLd3/IbUsICrspMR/WKAS3 zI3RX/qwCLoamyX3SIplDkuoTZsdTV0/NuHt0XoampJXmgOIIg2xOl9JQ3PnSIMs14se duN8zETZ75/3ZOVwVHjos56IpUhnwcRBAc5lXSaq5EzToNp32IXrtGU0YQLUEOK1h2fQ HrVg== X-Gm-Message-State: AGi0PuaY4lnMCTPg79zt7J2riUFV/ZekwsoPGBM94iY0KnZgAE3RwNGQ vkKC8musNNibx2iN8rE4ymTVY/jVBLOlGw== X-Google-Smtp-Source: APiQypKmoRjzwGLM4+U3hHEM3LcYXy/ZwxmaXtOkSpyqVRwiMHWVHr6T1mIajKjyJyS4h6yTizAdTw== X-Received: by 2002:a63:64e:: with SMTP id 75mr20745554pgg.342.1587476284658; Tue, 21 Apr 2020 06:38:04 -0700 (PDT) Received: from yuq-Aspire-4738G.lan (li2017-195.members.linode.com. [172.105.124.195]) by smtp.gmail.com with ESMTPSA id r23sm2551327pfr.64.2020.04.21.06.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:38:04 -0700 (PDT) From: Qiang Yu To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 10/10] drm/lima: enable runtime pm Date: Tue, 21 Apr 2020 21:35:51 +0800 Message-Id: <20200421133551.31481-11-yuq825@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200421133551.31481-1-yuq825@gmail.com> References: <20200421133551.31481-1-yuq825@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lima@lists.freedesktop.org, David Airlie , Bhushan Shah , Vasily Khoruzhick , Andreas Baierl , Qiang Yu , Erico Nunes MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Enable runtime pm by default so GPU suspend when idle for 200ms. This value can be changed by autosuspend_delay_ms in device's power sysfs dir. On Allwinner H3 lima_device_resume takes ~40us and lima_device_suspend takes ~20us. Signed-off-by: Qiang Yu --- drivers/gpu/drm/lima/lima_drv.c | 21 ++++++++++++---- drivers/gpu/drm/lima/lima_sched.c | 41 +++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/lima/lima_drv.c b/drivers/gpu/drm/lima/lima_drv.c index 639d1cd3268a..aadddf0fd6f0 100644 --- a/drivers/gpu/drm/lima/lima_drv.c +++ b/drivers/gpu/drm/lima/lima_drv.c @@ -405,6 +405,12 @@ static int lima_pdev_probe(struct platform_device *pdev) goto err_out2; } + pm_runtime_set_active(ldev->dev); + pm_runtime_mark_last_busy(ldev->dev); + pm_runtime_set_autosuspend_delay(ldev->dev, 200); + pm_runtime_use_autosuspend(ldev->dev); + pm_runtime_enable(ldev->dev); + /* * Register the DRM device with the core and the connectors with * sysfs. @@ -413,17 +419,16 @@ static int lima_pdev_probe(struct platform_device *pdev) if (err < 0) goto err_out3; - platform_set_drvdata(pdev, ldev); - if (sysfs_create_bin_file(&ldev->dev->kobj, &lima_error_state_attr)) dev_warn(ldev->dev, "fail to create error state sysfs\n"); return 0; err_out3: - lima_device_fini(ldev); -err_out2: + pm_runtime_disable(ldev->dev); lima_devfreq_fini(ldev); +err_out2: + lima_device_fini(ldev); err_out1: drm_dev_put(ddev); err_out0: @@ -437,10 +442,16 @@ static int lima_pdev_remove(struct platform_device *pdev) struct drm_device *ddev = ldev->ddev; sysfs_remove_bin_file(&ldev->dev->kobj, &lima_error_state_attr); - platform_set_drvdata(pdev, NULL); + drm_dev_unregister(ddev); + + /* stop autosuspend to make sure device is in active state */ + pm_runtime_set_autosuspend_delay(ldev->dev, -1); + pm_runtime_disable(ldev->dev); + lima_devfreq_fini(ldev); lima_device_fini(ldev); + drm_dev_put(ddev); lima_sched_slab_fini(); return 0; diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c index eb46db0717cd..a15fd037ded7 100644 --- a/drivers/gpu/drm/lima/lima_sched.c +++ b/drivers/gpu/drm/lima/lima_sched.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "lima_devfreq.h" #include "lima_drv.h" @@ -194,13 +195,36 @@ static struct dma_fence *lima_sched_dependency(struct drm_sched_job *job, return NULL; } +static int lima_pm_busy(struct lima_device *ldev) +{ + int ret; + + /* resume GPU if it has been suspended by runtime PM */ + ret = pm_runtime_get_sync(ldev->dev); + if (ret < 0) + return ret; + + lima_devfreq_record_busy(&ldev->devfreq); + return 0; +} + +static void lima_pm_idle(struct lima_device *ldev) +{ + lima_devfreq_record_idle(&ldev->devfreq); + + /* GPU can do auto runtime suspend */ + pm_runtime_mark_last_busy(ldev->dev); + pm_runtime_put_autosuspend(ldev->dev); +} + static struct dma_fence *lima_sched_run_job(struct drm_sched_job *job) { struct lima_sched_task *task = to_lima_task(job); struct lima_sched_pipe *pipe = to_lima_pipe(job->sched); + struct lima_device *ldev = pipe->ldev; struct lima_fence *fence; struct dma_fence *ret; - int i; + int i, err; /* after GPU reset */ if (job->s_fence->finished.error < 0) @@ -209,6 +233,13 @@ static struct dma_fence *lima_sched_run_job(struct drm_sched_job *job) fence = lima_fence_create(pipe); if (!fence) return NULL; + + err = lima_pm_busy(ldev); + if (err < 0) { + dma_fence_put(&fence->base); + return NULL; + } + task->fence = &fence->base; /* for caller usage of the fence, otherwise irq handler @@ -216,8 +247,6 @@ static struct dma_fence *lima_sched_run_job(struct drm_sched_job *job) */ ret = dma_fence_get(task->fence); - lima_devfreq_record_busy(&pipe->ldev->devfreq); - pipe->current_task = task; /* this is needed for MMU to work correctly, otherwise GP/PP @@ -388,6 +417,7 @@ static void lima_sched_timedout_job(struct drm_sched_job *job) { struct lima_sched_pipe *pipe = to_lima_pipe(job->sched); struct lima_sched_task *task = to_lima_task(job); + struct lima_device *ldev = pipe->ldev; if (!pipe->error) DRM_ERROR("lima job timeout\n"); @@ -413,7 +443,7 @@ static void lima_sched_timedout_job(struct drm_sched_job *job) pipe->current_vm = NULL; pipe->current_task = NULL; - lima_devfreq_record_idle(&pipe->ldev->devfreq); + lima_pm_idle(ldev); drm_sched_resubmit_jobs(&pipe->base); drm_sched_start(&pipe->base, true); @@ -485,6 +515,7 @@ void lima_sched_pipe_fini(struct lima_sched_pipe *pipe) void lima_sched_pipe_task_done(struct lima_sched_pipe *pipe) { struct lima_sched_task *task = pipe->current_task; + struct lima_device *ldev = pipe->ldev; if (pipe->error) { if (task && task->recoverable) @@ -495,6 +526,6 @@ void lima_sched_pipe_task_done(struct lima_sched_pipe *pipe) pipe->task_fini(pipe); dma_fence_signal(task->fence); - lima_devfreq_record_idle(&pipe->ldev->devfreq); + lima_pm_idle(ldev); } }