From patchwork Sat Jul 4 10:25:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 11645049 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 E9F9813B6 for ; Mon, 6 Jul 2020 07:20:03 +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 C7EF92070C for ; Mon, 6 Jul 2020 07:20:03 +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="qNFNgYAd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7EF92070C 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 34D3D6E2B8; Mon, 6 Jul 2020 07:19:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 471EE6E3F7 for ; Sat, 4 Jul 2020 10:25:50 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id z2so13055973wrp.2 for ; Sat, 04 Jul 2020 03:25:50 -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 :mime-version:content-transfer-encoding; bh=UtYpmlK0sBLIGu+jD6jSIfVxQzKUKkc64VLLUVnW2E0=; b=qNFNgYAd58cWTopWsCnVpN6KF4hgB35zsvk6rweB2geap+2a/hZHA4uMl6E/nhyVcz 4ypnl0H+eZ43sMPKGNvmbbssEXLnVdNP87/3ePmLXVN3fjJ7dBtESN0y6eZgz/eW5wmF D8m38BQ7KY6+zDcy3BkKBdVqRbWTVtxZd2KIOEpCgimRHWJhRsacbK1tBOENgfk557hF BOagm7Vf7N1RO3OOeVg5Ld4aYv490y6kKN94T2AjBJ1Cw/Q0c8EKUkwbKV+50Gyz6zZu zVZrjvDEvR66R7ATN6aQmSk1hr3Iw9rizpE1dlrX3vUob8+6+iU7sgzkRYRBYnzOke+h NsjQ== 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=UtYpmlK0sBLIGu+jD6jSIfVxQzKUKkc64VLLUVnW2E0=; b=i5YNudSeB9qpsnY28cAWqCcbqxibj15BXOJoYl6GJsGYVY+aoTAZl4LruUrCC6lVqI bOwHYqK5pQT48UO7nqSXzASr4h3Z7iF0Aauan7kr5sl37YeGKQdGcBTtEJ0zWjUHWbCD +6gkAtaN9pTNDXh95UqAHdh5eD8BcYio4LGQ5RHZOqYUXedKZ1lF80cE9Mv2ZMP+Vhvn gitX7Bq0D8T8Bf6TrqUlvS/Fld6a2S2tfj5qsUZBat+CRyaFxtFppqCcRBC8mtS8wDOz rzDjR32Jev1edkx3rUizdGm1d1We0FzLvrtwX3SA4lsotZBEtQ76snwV1LgDzyJHWj5E XmfQ== X-Gm-Message-State: AOAM533Fyoh8HPerglUJvSSbHA8wqi20jBXMuU2Dnt5b4RlXSe/We3pD bNDzyZmtnCy4Ih77wjhiS1k= X-Google-Smtp-Source: ABdhPJy/tukX+K79X4Pugp0jciTOgHL2tsymvPVNBkXelV2FU7kvRasFKCl5O0QlvUUsoGSmQgxY2w== X-Received: by 2002:adf:fe4b:: with SMTP id m11mr39485996wrs.36.1593858348780; Sat, 04 Jul 2020 03:25:48 -0700 (PDT) Received: from clement-Latitude-7490.numericable.fr (213-245-241-245.rev.numericable.fr. [213.245.241.245]) by smtp.gmail.com with ESMTPSA id g14sm16421428wrm.93.2020.07.04.03.25.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 03:25:48 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Rob Herring , Tomeu Vizoso , Steven Price , Alyssa Rosenzweig , Viresh Kumar , Nishanth Menon , Stephen Boyd , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH v2 06/14] drm/panfrost: properly handle error in probe Date: Sat, 4 Jul 2020 12:25:27 +0200 Message-Id: <20200704102535.189647-7-peron.clem@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200704102535.189647-1-peron.clem@gmail.com> References: <20200704102535.189647-1-peron.clem@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 06 Jul 2020 07:19:17 +0000 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: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Introduce a boolean to know if opp table has been added. With this, we can call panfrost_devfreq_fini() in case of error and release what has been initialised. Signed-off-by: Clément Péron Reviewed-by: Steven Price --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 25 ++++++++++++++++----- drivers/gpu/drm/panfrost/panfrost_devfreq.h | 1 + 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 78753cfb59fb..d9007f44b772 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -101,6 +101,7 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) return 0; else if (ret) return ret; + pfdevfreq->opp_of_table_added = true; spin_lock_init(&pfdevfreq->lock); @@ -109,8 +110,10 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) cur_freq = clk_get_rate(pfdev->clock); opp = devfreq_recommended_opp(dev, &cur_freq, 0); - if (IS_ERR(opp)) - return PTR_ERR(opp); + if (IS_ERR(opp)) { + ret = PTR_ERR(opp); + goto err_fini; + } panfrost_devfreq_profile.initial_freq = cur_freq; dev_pm_opp_put(opp); @@ -119,8 +122,8 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL); if (IS_ERR(devfreq)) { DRM_DEV_ERROR(dev, "Couldn't initialize GPU devfreq\n"); - dev_pm_opp_of_remove_table(dev); - return PTR_ERR(devfreq); + ret = PTR_ERR(devfreq); + goto err_fini; } pfdevfreq->devfreq = devfreq; @@ -131,15 +134,25 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) pfdevfreq->cooling = cooling; return 0; + +err_fini: + panfrost_devfreq_fini(pfdev); + return ret; } void panfrost_devfreq_fini(struct panfrost_device *pfdev) { struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; - if (pfdevfreq->cooling) + if (pfdevfreq->cooling) { devfreq_cooling_unregister(pfdevfreq->cooling); - dev_pm_opp_of_remove_table(&pfdev->pdev->dev); + pfdevfreq->cooling = NULL; + } + + if (pfdevfreq->opp_of_table_added) { + dev_pm_opp_of_remove_table(&pfdev->pdev->dev); + pfdevfreq->opp_of_table_added = false; + } } void panfrost_devfreq_resume(struct panfrost_device *pfdev) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.h b/drivers/gpu/drm/panfrost/panfrost_devfreq.h index 3392df1020be..210269944687 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.h +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.h @@ -15,6 +15,7 @@ struct panfrost_device; struct panfrost_devfreq { struct devfreq *devfreq; struct thermal_cooling_device *cooling; + bool opp_of_table_added; ktime_t busy_time; ktime_t idle_time;