From patchwork Mon May 20 22:42:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erico Nunes X-Patchwork-Id: 10952505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC08F76 for ; Mon, 20 May 2019 22:46:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9778C28948 for ; Mon, 20 May 2019 22:46:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87C472894B; Mon, 20 May 2019 22:46:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3B41328948 for ; Mon, 20 May 2019 22:46:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 257588924C; Mon, 20 May 2019 22:46:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id EF80989177; Mon, 20 May 2019 22:46:27 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id d9so3373885wrx.0; Mon, 20 May 2019 15:46: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:mime-version :content-transfer-encoding; bh=YNXJeh+38omCS2t9Ne6sAZvH3oGVHeeF7OTS+sEGgJM=; b=D3wCxVdil/Ot7lM9ULQdq9gWZfnQVVvZzSJuKyCpb0Sc+ZsjWRGdpRU/Ay3W71cfRh 0SQvh32G0ERISQsCOzFAQkLOpZF3+lTfkQeh0Sw4qTPbisFufuP2Is2Geq3uooqjLUi6 ye3rJp8L67CENZrIhlyqvGBEiCw5MdWiEriMyQBEds1pajL7sJNVLJcTo3xSpnxYeAI+ /KnDjLJNrplxAOoXWT456HztPUTNB13jBZKcma2eWQn4N/R0eq0ppOB4PNMH3Daw1XRs jNjSPqngeznNF6E3K58hnBK7O5Q/ipG1ui+l3AIHOepKzwBA8625VWb6paOhb9+rw1PO Hc1w== X-Gm-Message-State: APjAAAX6LnuswnbxC1dIUeG5fhsjZTCkfuT3H1kGY6dcn5PPzp6OQEJh Q0Vw7zzKHFsPeS44uGC6x5M= X-Google-Smtp-Source: APXvYqww8+4UbruB7Hhy9mS5jbE/ZjZuytTLSWBmi7w5SUDKZrpiQeU090vcpI/nsmw04CQoIlrqlQ== X-Received: by 2002:adf:e8d2:: with SMTP id k18mr297366wrn.329.1558392386716; Mon, 20 May 2019 15:46:26 -0700 (PDT) Received: from localhost.localdomain (ip-94-112-137-51.net.upcbroadband.cz. [94.112.137.51]) by smtp.gmail.com with ESMTPSA id 205sm139667wmd.43.2019.05.20.15.46.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 May 2019 15:46:26 -0700 (PDT) From: Erico Nunes To: Qiang Yu , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org Subject: [PATCH] drm/lima: add timeout to drm scheduler init Date: Tue, 21 May 2019 00:42:29 +0200 Message-Id: <20190520224229.21111-1-nunes.erico@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YNXJeh+38omCS2t9Ne6sAZvH3oGVHeeF7OTS+sEGgJM=; b=dmB5G392fAffqM05W5OKZ2UfEz3UrXr8MheHyCyLaic/pv7qopv3tlTg6a2t5D3e3E Pwqdn/DCamlyoBEdoenw/0k5oM1yWSMU3NJgYrhh00bX9Y/NwQbTykjZXAcG3TYPctOM Sx5/RmxyTGzfLLYcvxNSH3Zdc89gMttn8M2Enj9WfqmSMrE5eLBqnj/28GSjNnnq88ih m9WMJ9kq32z+yg+ERhmZBXTj2sk84CIbKx0YPh0enA9NWhFkG/qHzm7GL61jxSlFYo8f 4+eQnSdcGnrN8ttw8MK1ztBNZhb3o0S8XbMGRwgHv4SvGXLsV+gpqFPKQM6jvwfZzXce dWYA== 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: Erico Nunes Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP After "5918045c4ed4 drm/scheduler: rework job destruction", lima started to leak memory due to buffers not being destroyed after job execution in the drm scheduler. This started happening because the drm scheduler only destroyed buffers after cancelling the job timeout handler, and for lima this handler was never started as lima specified a MAX_SCHEDULE_TIMEOUT timeout. Lima seems to run well in its current state with a real timeout, so to make it more aligned with the other drivers from now on, let's use a real default timeout. This also fixes the observed memory leaks. The 500ms value was chosen as it is the current value for all other embedded gpu drivers using drm sched. Signed-off-by: Erico Nunes Reviewed-by: Qiang Yu --- drivers/gpu/drm/lima/lima_drv.c | 2 +- drivers/gpu/drm/lima/lima_sched.c | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/lima/lima_drv.c b/drivers/gpu/drm/lima/lima_drv.c index f9a281a62083..b29c26cd13b2 100644 --- a/drivers/gpu/drm/lima/lima_drv.c +++ b/drivers/gpu/drm/lima/lima_drv.c @@ -17,7 +17,7 @@ int lima_sched_timeout_ms; -MODULE_PARM_DESC(sched_timeout_ms, "task run timeout in ms (0 = no timeout (default))"); +MODULE_PARM_DESC(sched_timeout_ms, "task run timeout in ms"); module_param_named(sched_timeout_ms, lima_sched_timeout_ms, int, 0444); static int lima_ioctl_get_param(struct drm_device *dev, void *data, struct drm_file *file) diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c index 58a15479d175..4127cacac454 100644 --- a/drivers/gpu/drm/lima/lima_sched.c +++ b/drivers/gpu/drm/lima/lima_sched.c @@ -329,19 +329,16 @@ static void lima_sched_error_work(struct work_struct *work) int lima_sched_pipe_init(struct lima_sched_pipe *pipe, const char *name) { - long timeout; - - if (lima_sched_timeout_ms <= 0) - timeout = MAX_SCHEDULE_TIMEOUT; - else - timeout = msecs_to_jiffies(lima_sched_timeout_ms); + unsigned int timeout = lima_sched_timeout_ms > 0 ? + lima_sched_timeout_ms : 500; pipe->fence_context = dma_fence_context_alloc(1); spin_lock_init(&pipe->fence_lock); INIT_WORK(&pipe->error_work, lima_sched_error_work); - return drm_sched_init(&pipe->base, &lima_sched_ops, 1, 0, timeout, name); + return drm_sched_init(&pipe->base, &lima_sched_ops, 1, 0, + msecs_to_jiffies(timeout), name); } void lima_sched_pipe_fini(struct lima_sched_pipe *pipe)