From patchwork Thu Jul 9 14:03:14 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: 11655941 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 B4E8B92A for ; Fri, 10 Jul 2020 07:53:42 +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 923E12077D for ; Fri, 10 Jul 2020 07:53:42 +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="TvqytnKA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 923E12077D 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 2C79D6EB83; Fri, 10 Jul 2020 07:53:00 +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 F1B0D6EA77 for ; Thu, 9 Jul 2020 14:03:34 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id f18so2536337wrs.0 for ; Thu, 09 Jul 2020 07:03:34 -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=eRj3Oh7sZBJWwDgWc3ORgJ0pvlwZ3+3t0oGyKYtF1AQ=; b=TvqytnKA8EMxKSNy7l2um5FuNdy3SYJ1dCG/7d4j6F6McuYKM8i2ZJD6vKXk0zi0sW iLOnpHvZFdRKvuQ4F/qk2i4hnaCpqz3S+KTaObiu/vxoojV/loemRU+qqb69JvOiKPDP L9xNxHrXw8FYaQ2Qu+2GrfYO2+fFLb7lmV+omk+L5cNjBloyV2TtY/zbzYyBYQnFimYN 8AyZi1sj7XAKYvMWS2Bioq/QOag3KODrknXJbFSNxV1V8A4z1fTwFOLHwC1SyhPGv+bZ Ml24pU2qObO2sXH93W147qiqJXbCXO17gVDejiU3pLSkOldsS0DL7DUgMX1yuOwiNtJL 7Ltg== 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=eRj3Oh7sZBJWwDgWc3ORgJ0pvlwZ3+3t0oGyKYtF1AQ=; b=XUlHswMvUOpENeTINUx1jMLmRAy6bnipb7ERSPV0SoIyVbflDQvMLAhjrlxQJo/c48 PC0dLiuXMcmhveo9KDiVnSNz1Cp7HVA4IJVeh7NJxaP4p21AIk8AV0vc4fKZa0ioO77E 8kXvM4l+rn1kilGQ/B4awlfiZA2yD+8YCnisAkAomh5WbEFlyeH4Az39BIqEjgEqAZzM dG5D7VpFijxNPZU/CF+suXsw9W5ugEwyb9W52CrC6oOLd2BYmwPYmsEE90XIQofKFEqQ FYF+S0idsnWKTKehq0ZVb4dQNlMLUq1Mo2rI617qSkzrBDD+r0xicAOik6PDUsPSThfh wftw== X-Gm-Message-State: AOAM532WMgdKRo1ZccQXmI86EVkxDvoINhwYoZ4Zj4v7kCO7XMyr5aW5 NswUUrd258pgP9Ohg1jhHBk= X-Google-Smtp-Source: ABdhPJw84FXJpRMyrNsB+Uk7XKJyvE///uOAMmssgYl7VQxKTPBERcN45fyPtDnuQOC7hHl3ZBZChg== X-Received: by 2002:a5d:420e:: with SMTP id n14mr67522767wrq.164.1594303413447; Thu, 09 Jul 2020 07:03:33 -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 s8sm5545256wru.38.2020.07.09.07.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 07:03:32 -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 v3 06/14] drm/panfrost: properly handle error in probe Date: Thu, 9 Jul 2020 16:03:14 +0200 Message-Id: <20200709140322.131320-7-peron.clem@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200709140322.131320-1-peron.clem@gmail.com> References: <20200709140322.131320-1-peron.clem@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 10 Jul 2020 07:52:58 +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. Reviewed-by: Steven Price Reviewed-by: Alyssa Rosenzweig Signed-off-by: Clément Péron --- 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;