From patchwork Sat Apr 11 20:06:31 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: 11485339 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 2A124174A for ; Mon, 13 Apr 2020 09:29: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 088062063A for ; Mon, 13 Apr 2020 09:29: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="pN0e9wGO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 088062063A 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 A1A476E419; Mon, 13 Apr 2020 09:29:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0B3656E0E3 for ; Sat, 11 Apr 2020 20:06:47 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id o81so131963wmo.2 for ; Sat, 11 Apr 2020 13:06:46 -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:mime-version :content-transfer-encoding; bh=d/xeNUbJ170Rcks+8UPitiY+D8+oYUtGYjLPuwDIIMo=; b=pN0e9wGO3ZParlDyJdUgG4KPLkAkUE96VGull5/Xg47pWLrV50uqu0XeFtOOS9oB8u fBIvinRcku6msWIw7B/AMKi+0LCqk+Ns4xlEZamjwMFXLL9QSUDW6ytBAEZQBFXHI5on z8Yj6U87jwE6nEbVHCzuwVgNK1k2TmaslfzJYIkK46+OpDwXIl+zTYnk2Odcp632qAN6 QjWwgMdKuIwQL2Dncj50HHxFaJDxiiub/Tgle6VEBEOpfymnW5vcLf4MDq1RetwkVVlt PErPBYXk+zMfMwQDtTZW4oaZ/T3FUPwZI8t9fpfUsYHO2XjvlOGkaNoKKsc03AN26rzo btaA== 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=d/xeNUbJ170Rcks+8UPitiY+D8+oYUtGYjLPuwDIIMo=; b=Un+sGeuWuGcOIbsFAYMrgStjMD0ujt9cx2+wn19X8MdcrajujcwtBeNR2HnH5Fr4cE yJTtfW8w81WNfQHniDa4F2XIV5FRVmE2ATdl/qOiVO9ZePcNqm9ktk7OZelcfakwqBip uhd1tqXaTTbe/qiJix6t323WzBjcdmQiwRwskVYmvw9p4iFT1Ekxc+e0kYpaFtrPnQCa 9RTK8PnNpHKwIO/4ThxxOAzRvyDbEew65pnLd9Ydg+c30yn3kevEYWDsVxCt4Q4nbzBl CBokJekFoZYjOcVmL/+6q09t0+L7oHkCDsdgs7893p4FnCHg4HjflzifYjD7UgqvDIeU Rw4g== X-Gm-Message-State: AGi0PuaEl1H/MYBwFUChAK6GJMNZAa0GjgtTYLh97y1d9N97RW+fQqvt oxjhH2A/OCcozCLJM9BB+SU= X-Google-Smtp-Source: APiQypJiMElfxuS7xS/9PX6Fd45JEGZqUGPugBtGCjW8LaAD3OS3TMVizEGgTcv3ItEf4SBPhSxUkQ== X-Received: by 2002:a1c:1bcb:: with SMTP id b194mr11698336wmb.4.1586635605589; Sat, 11 Apr 2020 13:06:45 -0700 (PDT) Received: from localhost.localdomain (91-167-199-67.subs.proxad.net. [91.167.199.67]) by smtp.gmail.com with ESMTPSA id y5sm8712670wru.15.2020.04.11.13.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Apr 2020 13:06:44 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Rob Herring , Tomeu Vizoso , Steven Price , Alyssa Rosenzweig , Viresh Kumar , Nishanth Menon , Stephen Boyd Subject: [PATCH 1/2] drm/panfrost: missing remove opp table in case of failure Date: Sat, 11 Apr 2020 22:06:31 +0200 Message-Id: <20200411200632.4045-1-peron.clem@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 13 Apr 2020 09:29:25 +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" In case of failure we need to remove OPP table. Use Linux classic error handling with goto usage. Signed-off-by: Clément Péron Reviewed-by: Steven Price --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 413987038fbf..62541f4edd81 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -90,8 +90,11 @@ 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)) { + DRM_DEV_ERROR(dev, "Failed to set recommended OPP\n"); + ret = PTR_ERR(opp); + goto err_opp; + } panfrost_devfreq_profile.initial_freq = cur_freq; dev_pm_opp_put(opp); @@ -100,8 +103,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_opp; } pfdev->devfreq.devfreq = devfreq; @@ -112,6 +115,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) pfdev->devfreq.cooling = cooling; return 0; + +err_opp: + dev_pm_opp_of_remove_table(dev); + + return ret; } void panfrost_devfreq_fini(struct panfrost_device *pfdev) From patchwork Sat Apr 11 20:06:32 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: 11485333 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 BC00F15AB for ; Mon, 13 Apr 2020 09:29:36 +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 9610F2063A for ; Mon, 13 Apr 2020 09:29:36 +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="hrjRuhiQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9610F2063A 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 4E8CF89E11; Mon, 13 Apr 2020 09:29:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B2A66E0E3 for ; Sat, 11 Apr 2020 20:06:48 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id x25so5711138wmc.0 for ; Sat, 11 Apr 2020 13:06:48 -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=zoldyKJXtADkuzgLMxvc+aHQ8la7JVhSLGXOECKmOcc=; b=hrjRuhiQBhcZ1WdJ1Gq9N8RInWD2+8L6tzMXKTt9nRC+YJSlhe8o2apD1lBuGHue63 Gz72gk10Zomzi4uGEfF3sk1XpJPCLdmSGvztUeSx3G8GrSFxCKwtL4OLh4Nou5ySW1HH NbtcXX3XCTFKitlpLdHotw/U0MXkWnNWhIVU3/EH+tzgY6BG/FM9cIY0Ztba2yNOkKew 1S14PgZe1f14Nigk4Q+Vmhmidu2QglqQ4QBLWgKPeGfdufLgIGe2YLL8yxP41aLV/BNw 1EcNjmXLluI3nk18jkOu3nxiT0sq/SymW2ZYG0wT+LqRc+fjijZuJ1wXbP/V0I1yzIJy bxww== 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=zoldyKJXtADkuzgLMxvc+aHQ8la7JVhSLGXOECKmOcc=; b=siV/DzQyGgR6NZYaupk2w3IIacZl+mpHKPgtzJS9cMlae2WUEjjQQJ1jEI0OcIj9+j F+GIjzstj45wHHU97MOmzbwzKSop3Ko+613GRwvK8oPVt9dboFDnvhcPiPH9JforYA1j cfDTqSyWghliPDEHqje7IH3LSoAj47029eH7FW5sJPv2yldPI8WfP37Mwb/3LcoStUJV bmvoJa3R1ZIZw9BzLld4lyE14UjtZC8sbLa5jtVAuPdlpFfbTyXhGIOEAkHILR3tLu6O Tq1OPalyxQoAVyple2cJzYivlINssVXBr6r+uX9P+VUAhZgoDIoX3xpwrruqI5wVB7Vh inxQ== X-Gm-Message-State: AGi0Pua4AzeDwB7/b+0lhhaplL6iuTLVAoazOYR/fXHnJWIU1ezk1wwv ahxmsPRpYgOd7qKEJuguYOc= X-Google-Smtp-Source: APiQypLbsvsk9zLeeFB8Obt5V3v8jpdg3Qf2EvxxzUQlswj5qD7Vw52StvIIPRQTWSewjjjJ1SYvAg== X-Received: by 2002:a1c:9aca:: with SMTP id c193mr10824862wme.38.1586635606681; Sat, 11 Apr 2020 13:06:46 -0700 (PDT) Received: from localhost.localdomain (91-167-199-67.subs.proxad.net. [91.167.199.67]) by smtp.gmail.com with ESMTPSA id y5sm8712670wru.15.2020.04.11.13.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Apr 2020 13:06:45 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Rob Herring , Tomeu Vizoso , Steven Price , Alyssa Rosenzweig , Viresh Kumar , Nishanth Menon , Stephen Boyd Subject: [PATCH 2/2] drm/panfrost: add devfreq regulator support Date: Sat, 11 Apr 2020 22:06:32 +0200 Message-Id: <20200411200632.4045-2-peron.clem@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200411200632.4045-1-peron.clem@gmail.com> References: <20200411200632.4045-1-peron.clem@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 13 Apr 2020 09:29:25 +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" OPP table can defined both frequency and voltage. Register the mali regulator if it exist. Signed-off-by: Clément Péron --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 62541f4edd81..2dc8e2355358 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) struct device *dev = &pfdev->pdev->dev; struct devfreq *devfreq; struct thermal_cooling_device *cooling; + const char *mali = "mali"; + struct opp_table *opp_table = NULL; + + /* Regulator is optional */ + opp_table = dev_pm_opp_set_regulators(dev, &mali, 1); + if (IS_ERR(opp_table)) { + ret = PTR_ERR(opp_table); + if (ret != -ENODEV) { + DRM_DEV_ERROR(dev, "Failed to set regulator: %d\n", ret); + return ret; + } + } + pfdev->devfreq.opp_table = opp_table; ret = dev_pm_opp_of_add_table(dev); - if (ret == -ENODEV) /* Optional, continue without devfreq */ - return 0; - else if (ret) - return ret; + if (ret) { + if (ret == -ENODEV) /* Optional, continue without devfreq */ + ret = 0; + goto err_opp_reg; + } panfrost_devfreq_reset(pfdev); @@ -119,6 +133,12 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) err_opp: dev_pm_opp_of_remove_table(dev); +err_opp_reg: + if (pfdev->devfreq.opp_table) { + dev_pm_opp_put_regulators(pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table = NULL; + } + return ret; } @@ -126,7 +146,13 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev) { if (pfdev->devfreq.cooling) devfreq_cooling_unregister(pfdev->devfreq.cooling); + dev_pm_opp_of_remove_table(&pfdev->pdev->dev); + + if (pfdev->devfreq.opp_table) { + dev_pm_opp_put_regulators(pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table = NULL; + } } void panfrost_devfreq_resume(struct panfrost_device *pfdev) diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h index 06713811b92c..f6b0c779dfe5 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -86,6 +86,7 @@ struct panfrost_device { struct { struct devfreq *devfreq; struct thermal_cooling_device *cooling; + struct opp_table *opp_table; ktime_t busy_time; ktime_t idle_time; ktime_t time_last_update;