From patchwork Wed Oct 2 12:22:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13819761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ECC69CF31B4 for ; Wed, 2 Oct 2024 12:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EWiwvj5KSak5iw1HXEVPujm6Q2wWyAwA6z/lZYjaN0g=; b=WZncMG700KnwRE8avtqejw9NXC S1NVthSLqjaguq08HdaJ248P3hQB4XfuNJdmH85qUkwvUDQiv3dMFIEfM1nSYHgGc/XSFkylm4xsn M7rK2t385EgB82u8ofPpO2ZsOEF/xOsY+HHB42bBWz4sxjapLrCHKzl2USn8zmgaPMmQnIDnmr+Vo 3STRM9oPRf4TAZq6fQuTPt77GMj1qGAgWJJEVu9FaWgkofA3Qvgym/i0JfIzWv3IUJQkkpI41/N15 DyuTEi+kPs6/6LrVoRuVK4HgjC7Wt8WIKk6tHnE7mP+5BgHqWcCEBlxi22TJ8uqr6ViYQdsOrwvcX ltSVMEYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1svyYQ-00000005uL0-0lqD; Wed, 02 Oct 2024 12:34:06 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1svyNf-00000005qZy-0dOR for linux-arm-kernel@lists.infradead.org; Wed, 02 Oct 2024 12:23:00 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-53993c115cfso4202281e87.2 for ; Wed, 02 Oct 2024 05:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727871777; x=1728476577; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EWiwvj5KSak5iw1HXEVPujm6Q2wWyAwA6z/lZYjaN0g=; b=pxspscwi8NbAyRkfJ1RMEM1neUReCgqKpMNoY88/h5sBYe7hUS1UnihumUn0hfvZx7 mtvUp7OQw+S5lzBVIWl2Bgg5Cd2iF06obofvBnBj81YzKNXsXGit+oDQPpFgsu4xBfwm NyIChFNY63J8Z9qrLj89e2Bt1T3ztJtYX4gIDVkIFM9Tx3WACUtm8pLiAFqygqgUm2CS XA5D8M+QR1M77Gs2XvNRPECw0OtHRoLsphfQ3Knibf56TfVkgfbvkII7PKj3i2CUWVhz 9qhAwql80SfEwoOwkfrTjI6BdBYsnNU9xxPYXeSIjn8P/Y9DrJsBP4Kbr3r7nu6BXyZP 0JsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871777; x=1728476577; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EWiwvj5KSak5iw1HXEVPujm6Q2wWyAwA6z/lZYjaN0g=; b=o5fR3ZGT4UxMqsu64K/+hZiOXfqHPWHF3vaBZL/na4Lca5/SXYfe510N+W9q8Qs95G JkTflZoEyv1b37e230xLK54zgTYQ1BHrbnqeFjNhQYr4FvpOvLHTWtLinl/3OaeI7Cel mUkCHfPA9PjNfcao0TbZQ3X61udDJFyxix4vOiWh7j96Q0QW0/oFRnyboJEIP7MRuDIT MqNiCnnytXboAXirfxVztyUFN5T0ui7sCfAi34hlo2uIDq0dLWDafXAldXdCj7cz9o0w 576bz3+s2LNKSXJXt1Vi1vQu2IBJWQNi8sw3BWG0mihs77QV09SlVBqzWS19ZHKiZPQ6 h60g== X-Forwarded-Encrypted: i=1; AJvYcCXk2i2VAgCJWxIOn8GhT4Eh1nSWX5+3KZRq2I4LxdYBTId/LV3T+BHSM94+nlYT7x2KAJM1CIGOKIMbbMKxbgSR@lists.infradead.org X-Gm-Message-State: AOJu0Yzx9vMY6jc24uMXUjMkzk0GK0djf/lrYoB/Sjg0tjaP29nBRpMf uSVCoxVDWFSSvmRr3hMTTsad+9zr7NBYG0mBgp96apMxvI8qkYTk2tTkAdPDC3j9+Q4/bK3x7PE K X-Google-Smtp-Source: AGHT+IG2YfIlzqOBf8Qe1+i7eKAaGcPaaQ69rOLevaHyKiEZfEu6G3jNyhzopd/Ym4Ztq1N1Cwr9lw== X-Received: by 2002:a05:6512:33d4:b0:52d:b226:9428 with SMTP id 2adb3069b0e04-539a065c7d5mr1786952e87.6.1727871777108; Wed, 02 Oct 2024 05:22:57 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-538a043204fsm1912659e87.165.2024.10.02.05.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 05:22:55 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: "Rafael J . Wysocki" , Dikshita Agarwal , Vedang Nagar , Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Viresh Kumar , Thierry Reding Subject: [PATCH v4 08/11] drm/tegra: gr3d: Convert into devm_pm_domain_attach_list() Date: Wed, 2 Oct 2024 14:22:29 +0200 Message-Id: <20241002122232.194245-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241002122232.194245-1-ulf.hansson@linaro.org> References: <20241002122232.194245-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241002_052259_216008_EC82D7C1 X-CRM114-Status: GOOD ( 15.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rather than hooking up the PM domains through devm_pm_opp_attach_genpd() and manage the device-link, let's avoid the boilerplate-code by converting into devm_pm_domain_attach_list(). Acked-by: Viresh Kumar Acked-by: Thierry Reding Signed-off-by: Ulf Hansson --- Changes in v4: - Minor. Use PD_FLAG_REQUIRED_OPP. --- drivers/gpu/drm/tegra/gr3d.c | 39 ++++++++---------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c index 00c8564520e7..caee824832b3 100644 --- a/drivers/gpu/drm/tegra/gr3d.c +++ b/drivers/gpu/drm/tegra/gr3d.c @@ -46,6 +46,7 @@ struct gr3d { unsigned int nclocks; struct reset_control_bulk_data resets[RST_GR3D_MAX]; unsigned int nresets; + struct dev_pm_domain_list *pd_list; DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS); }; @@ -369,18 +370,13 @@ static int gr3d_power_up_legacy_domain(struct device *dev, const char *name, return 0; } -static void gr3d_del_link(void *link) -{ - device_link_del(link); -} - static int gr3d_init_power(struct device *dev, struct gr3d *gr3d) { - static const char * const opp_genpd_names[] = { "3d0", "3d1", NULL }; - const u32 link_flags = DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME; - struct device **opp_virt_devs, *pd_dev; - struct device_link *link; - unsigned int i; + struct dev_pm_domain_attach_data pd_data = { + .pd_names = (const char *[]) { "3d0", "3d1" }, + .num_pd_names = 2, + .pd_flags = PD_FLAG_REQUIRED_OPP, + }; int err; err = of_count_phandle_with_args(dev->of_node, "power-domains", @@ -414,29 +410,10 @@ static int gr3d_init_power(struct device *dev, struct gr3d *gr3d) if (dev->pm_domain) return 0; - err = devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs); - if (err) + err = devm_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list); + if (err < 0) return err; - for (i = 0; opp_genpd_names[i]; i++) { - pd_dev = opp_virt_devs[i]; - if (!pd_dev) { - dev_err(dev, "failed to get %s power domain\n", - opp_genpd_names[i]); - return -EINVAL; - } - - link = device_link_add(dev, pd_dev, link_flags); - if (!link) { - dev_err(dev, "failed to link to %s\n", dev_name(pd_dev)); - return -EINVAL; - } - - err = devm_add_action_or_reset(dev, gr3d_del_link, link); - if (err) - return err; - } - return 0; }