From patchwork Sat Jul 4 10:25:30 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: 11645077 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 DD19F13B4 for ; Mon, 6 Jul 2020 07:20:20 +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 BAB2F2063A for ; Mon, 6 Jul 2020 07:20:20 +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="u895Asqn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BAB2F2063A 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 A60866E369; Mon, 6 Jul 2020 07:19:33 +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 671066E409 for ; Sat, 4 Jul 2020 10:25:53 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id f139so36540035wmf.5 for ; Sat, 04 Jul 2020 03:25:53 -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=dEvAV3WC8gjOi8/db5UgonIFrnz7oP9M+fD1t4PD98A=; b=u895AsqnI++nW+ATsCD6BM53ooaKE7DfxiT5p2rrbYNdSijhTa2fQojXDTEIR7jYPF eDuyVN7haX4f7btL7FsYhYPvf+qtegwUjvvWWxU2a+3rlGHRajWGZnXWwldaiRQqcO/B 6cwLMKgC4aChrc/tG8Z2LdbCLvM1pN4OOfieirBaNfQULsq97lAy3uSGUYI0zExf/EMg /wEbPOoKEenrXogE201dj1V7BdCaolqxGGhSyJ1iuPRWAyWxco+8y7t9Zu17E/orMXei NVGn3grc7xb4aECQK6M7VAlQ2ylCejDxl//pNzxVP/BRXfjaXSD9afGlg/5+0dsGcO4q PdIA== 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=dEvAV3WC8gjOi8/db5UgonIFrnz7oP9M+fD1t4PD98A=; b=Gvjf+zuQgyi6RUyWMTPyEoYg7wDh+IdZbJ/t5TSjpTQ6lEtTq+YD2t2QNgEAcIwivQ Anb/G+TPlwMlWAh/NGEVZc7EsC9MP5pduGgqd+7tXILJXTnhM4vqZT/2DWlffPms7ue7 sfVaVty9KQIwkh9Pfi/nZCNJkKH3ntGpKgR4rTbZSg/Ir8ZmgBezKudx53xlyN1rCidf huwx1x/GHbSHGJ2KQPLsMstIqIVniK6Mk7PzA4HB9rUFQOkiaAelyhCrJQfWyBoFCQRq /WLWv+IP8/bjifUrKICqqIBJprsnHdzDifoAm1fdu+8kpVnIKHqvKYqGb9xfPfpmZXIc Typw== X-Gm-Message-State: AOAM532EFXwHECvm3dPX2+pwYxoFS80zie+xXAFxXLmF+sM4cgZYvKuQ HRxKFXTGCmDtYLK5EFZBbUA= X-Google-Smtp-Source: ABdhPJxPyjX8E1s13IMa5BpsRPWoAPS1pYxySTMxZT0pEmMWQ3CcE7UVh59cuHmumr5QkfbuhHRayw== X-Received: by 2002:a1c:18e:: with SMTP id 136mr10189686wmb.93.1593858352040; Sat, 04 Jul 2020 03:25:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 03:25:51 -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 09/14] drm/panfrost: dynamically alloc regulators Date: Sat, 4 Jul 2020 12:25:30 +0200 Message-Id: <20200704102535.189647-10-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" We will later introduce regulators managed by OPP. Only alloc regulators when it's needed. This also help use to release the regulators only when they are allocated. Signed-off-by: Clément Péron Reviewed-by: Steven Price --- drivers/gpu/drm/panfrost/panfrost_device.c | 14 +++++++++----- drivers/gpu/drm/panfrost/panfrost_device.h | 3 +-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c index 464da1646398..0b0fb45aee82 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.c +++ b/drivers/gpu/drm/panfrost/panfrost_device.c @@ -90,9 +90,11 @@ static int panfrost_regulator_init(struct panfrost_device *pfdev) { int ret, i; - if (WARN(pfdev->comp->num_supplies > ARRAY_SIZE(pfdev->regulators), - "Too many supplies in compatible structure.\n")) - return -EINVAL; + pfdev->regulators = devm_kcalloc(pfdev->dev, pfdev->comp->num_supplies, + sizeof(*pfdev->regulators), + GFP_KERNEL); + if (!pfdev->regulators) + return -ENOMEM; for (i = 0; i < pfdev->comp->num_supplies; i++) pfdev->regulators[i].supply = pfdev->comp->supply_names[i]; @@ -117,8 +119,10 @@ static int panfrost_regulator_init(struct panfrost_device *pfdev) static void panfrost_regulator_fini(struct panfrost_device *pfdev) { - regulator_bulk_disable(pfdev->comp->num_supplies, - pfdev->regulators); + if (!pfdev->regulators) + return; + + regulator_bulk_disable(pfdev->comp->num_supplies, pfdev->regulators); } static void panfrost_pm_domain_fini(struct panfrost_device *pfdev) diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h index 2efa59c9d1c5..953f7536a773 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -22,7 +22,6 @@ struct panfrost_job; struct panfrost_perfcnt; #define NUM_JOB_SLOTS 3 -#define MAX_REGULATORS 2 #define MAX_PM_DOMAINS 3 struct panfrost_features { @@ -81,7 +80,7 @@ struct panfrost_device { void __iomem *iomem; struct clk *clock; struct clk *bus_clock; - struct regulator_bulk_data regulators[MAX_REGULATORS]; + struct regulator_bulk_data *regulators; struct reset_control *rstc; /* pm_domains for devices with more than one. */ struct device *pm_domain_devs[MAX_PM_DOMAINS];