Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1524344ybt; Thu, 9 Jul 2020 09:02:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxO6U71X3WgvRYK80pICpr81w2UWWtpRr6HKDuKEGvH9gZ5fCMAWFw14Jo2IocjiyOdgEqM X-Received: by 2002:a17:906:434c:: with SMTP id z12mr51192456ejm.33.1594310523847; Thu, 09 Jul 2020 09:02:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594310523; cv=none; d=google.com; s=arc-20160816; b=ltE75mhOSyzKhpzNLVOSJXCA4zMh8rE70Uv7L3UGpxId9l27RtwViseBRv2fo9J+xU yC1SFY4aCRY/BxW7/kKaWmjqEytSRtS3Xgr27JkfSt3j/wF2a69PGgtdqFdM71SGXURw GqhCR6RVtLqAZKNuWlnVA8Ng72itcTcPrXru9bz5guWlCJ6wVGEyDDuu2pcgSNkKS79g VNf/psLjsm/CH4GHQYlPwwjo31HkqfscpTd4Qch2Tk0YZ2Yns/AYWBLjubSb/6+HQd4U zlCIIhTPgm9BobjAELEzmbpfTniTyMlRqG4uI6wvWhdWVK/UtS79oxjqs4bob97DzQSO 66IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=1syE5Rwby9GU5oR+y3viD4U4q4WaDKG0mKc98/SWo70=; b=otoy8twrZuCpvwiWrvsxTGw5mVo3RQpu6bRJB1aZtaKB1dZB1hWM7Azgdsa2UbVUlk TKm2yHlJMPWqlFCrg7uokdxibmmEQg/ir7Lofhq+WQrmVSQ0DGEOkPnTx5YHEA7I/s00 80MdVnqVq7quUpXAbYWUJg7p21jh0MEngFIX4td1QfFIxH3VDzybLCUe/TzunHRkPXIL eCzDXKJjfhfuOycgE7jK/YgpOWYB96xpsZ+Bk8l+rTWEA6V+EztKplgezI+x112DwP98 XFnLpH87Yyu3T4vK4KQbJfMMeRJbnx/zrCir6+g6e60nh2krJJX6JBVEMUfdP/Iur0rl qaMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id od19si2127220ejb.581.2020.07.09.09.01.39; Thu, 09 Jul 2020 09:02:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727905AbgGIP71 (ORCPT + 99 others); Thu, 9 Jul 2020 11:59:27 -0400 Received: from foss.arm.com ([217.140.110.172]:38296 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726519AbgGIP71 (ORCPT ); Thu, 9 Jul 2020 11:59:27 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D4C5131B; Thu, 9 Jul 2020 08:59:26 -0700 (PDT) Received: from [192.168.1.84] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 048743F792; Thu, 9 Jul 2020 08:59:24 -0700 (PDT) Subject: Re: [PATCH] drm/panfrost: fix ref count leak in panfrost_job_hw_submit To: Rob Herring , Navid Emamdoost Cc: Tomeu Vizoso , Alyssa Rosenzweig , David Airlie , Daniel Vetter , dri-devel , "linux-kernel@vger.kernel.org" , Navid Emamdoost , wu000273@umn.edu, kjlu@umn.edu, Stephen McCamant References: <20200614062730.46489-1-navid.emamdoost@gmail.com> From: Steven Price Message-ID: <30c2031a-4975-43d0-c8ca-8664969e5df3@arm.com> Date: Thu, 9 Jul 2020 16:59:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/07/2020 16:44, Rob Herring wrote: > On Sun, Jun 14, 2020 at 12:27 AM Navid Emamdoost > wrote: >> >> in panfrost_job_hw_submit, pm_runtime_get_sync is called which >> increments the counter even in case of failure, leading to incorrect >> ref count. In case of failure, decrement the ref count before returning. >> >> Signed-off-by: Navid Emamdoost >> --- >> drivers/gpu/drm/panfrost/panfrost_job.c | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c >> index 7914b1570841..89ac84667eb1 100644 >> --- a/drivers/gpu/drm/panfrost/panfrost_job.c >> +++ b/drivers/gpu/drm/panfrost/panfrost_job.c >> @@ -147,11 +147,10 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) >> >> ret = pm_runtime_get_sync(pfdev->dev); >> if (ret < 0) >> - return; >> + goto out; > > If the get failed, I don't think we want to do a put. The pm_runtime_get_sync() does actually always increment the reference (even when returning a failure), but actually I don't think we want it here anyway, as I think I explained before[1]. [1] https://lore.kernel.org/dri-devel/272650ba-2c44-9084-7829-b04023eba723@arm.com > >> >> if (WARN_ON(job_read(pfdev, JS_COMMAND_NEXT(js)))) { >> - pm_runtime_put_sync_autosuspend(pfdev->dev); This is a correct change - we don't want the put here. (Although this should never happen). >> - return; >> + goto out; >> } >> >> cfg = panfrost_mmu_as_get(pfdev, &job->file_priv->mmu); >> @@ -184,6 +183,9 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) >> job, js, jc_head); >> >> job_write(pfdev, JS_COMMAND_NEXT(js), JS_COMMAND_START); > > So we start the job here and then... > >> +out: >> + pm_runtime_put_sync_autosuspend(pfdev->dev); > > ...turn off clocks/power here. Typically, you'd be fine as autosuspend > has a delay by default, but userspace is free to change the delay to > 0. > >> + return; A return at the end of the function with no argument is pointless. Steve >> } >> >> static void panfrost_acquire_object_fences(struct drm_gem_object **bos, >> -- >> 2.17.1 >>