From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99BB3C43334 for ; Tue, 5 Jul 2022 04:34:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229518AbiGEEeo (ORCPT ); Tue, 5 Jul 2022 00:34:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbiGEEen (ORCPT ); Tue, 5 Jul 2022 00:34:43 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1ECB13CF0 for ; Mon, 4 Jul 2022 21:34:42 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id k14so10026400plh.4 for ; Mon, 04 Jul 2022 21:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tmakuE4H8rZY3d6iU39dHrEeioyPOU2VRNgXbaFPqgw=; b=u7aod0CrQMXqVD1ebu7kjSt/WcQQQkg7j6oHslRmkt+QTw/T612mRYZc8qxkE8om3O EQM+h21JvLKnCzpiIq4xgwUXzQLpQJOdCt1694l5ZM1mQPkjlLZ33DO+Dp91Uof0icTc 2eCH31nP6U7iVCED/tU23T/actjjYFmw5UZLP7t0DKiBKU/nAR7cp0MXJlqAa8wI742A EQR0aX38sVjulvZcqY4l2O71LHN3k6M9c36toeseQylQoLjWGDZYqtxqvh3+p0Tozz/N XPHPZJPQNycYMom8jxQv3xsFNeAKZLSk+yfh0F9BKr8UZwwsSvArNI8r2sZRhz3icFzn 3CaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tmakuE4H8rZY3d6iU39dHrEeioyPOU2VRNgXbaFPqgw=; b=nRsv7L8iduYu80KuCVd0ZQaRvQms88ZgCU6iOxMHA+TOT4YxZm4YaNUuJtjI+IwiP9 k8kp+ItDHphtam8Ost/JQkNp4hnvXKxhzpg0X82Ft6Tnq8oLmpeCGAtzoebopZfJ3D1C PGTmaBMydczVyuUD55fU55lSn3zeHKQZLhVjaUAh9nEpUXUE7yBkR8vMrDfAufK9VRDB FY9RF0lejIl61PNEkBEDLAmoNGzYHU4ModHZM+T/ldFsPIn8V3t+cbBSflxuDxYpuL6L 5foo/tQH5bSXqpkc2gH4XixyEKzSFUHdkidHmfd0WjjY6zccbDwd6S5oNrF3/tQt8owX 2G0Q== X-Gm-Message-State: AJIora92rWaAtWhV/sUkWAHgE+rVaqCmsI/alpLDPX4oIN24GJeckOHe MtXAR67ksJLhUJ8XhHMhcD8C7A== X-Google-Smtp-Source: AGRyM1sRTY3jhmXML4zUAHI23oIyvbgNG1ONSMMqox+hipkmWXEtiTEid5mCOhRsoVVHI5UrE7Q83A== X-Received: by 2002:a17:90b:4a4f:b0:1ef:90fb:35a5 with SMTP id lb15-20020a17090b4a4f00b001ef90fb35a5mr5846805pjb.161.1656995682324; Mon, 04 Jul 2022 21:34:42 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id p26-20020a056a0026da00b005251e2b53acsm21651540pfw.116.2022.07.04.21.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 21:34:41 -0700 (PDT) Date: Tue, 5 Jul 2022 10:04:39 +0530 From: Viresh Kumar To: Steven Price Cc: "Rafael J. Wysocki" , Chanwoo Choi , MyungJoo Ham , Kyungmin Park , Krzysztof Kozlowski , Alim Akhtar , Qiang Yu , Rob Herring , Tomeu Vizoso , Alyssa Rosenzweig , Nishanth Menon , Stephen Boyd , Thierry Reding , Jonathan Hunter , linux-pm@vger.kernel.org, Vincent Guittot , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org, linux-tegra@vger.kernel.org Subject: Re: [PATCH V3 02/20] OPP: Make dev_pm_opp_set_regulators() accept NULL terminated list Message-ID: <20220705043439.xlrxusxrhwjupiyt@vireshk-i7> References: <9730e011004b7526e79c6f409f5147fb235b414a.1656935522.git.viresh.kumar@linaro.org> <48d865e8-6c0d-99c0-a43b-89793d5c3f85@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48d865e8-6c0d-99c0-a43b-89793d5c3f85@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org On 04-07-22, 15:35, Steven Price wrote: > I have to say the 'new improved' list ending with NULL approach doesn't > work out so well for Panfrost. We already have to have a separate > 'num_supplies' variable for devm_regulator_bulk_get() / > regulator_bulk_{en,dis}able(), so the keeping everything in sync > argument is lost here. > > I would suggest added the NULL on the end of the lists in panfrost_drv.c > but then it would break the use of ARRAY_SIZE() to automagically keep > the length correct... Actually we can still make it work. > For now the approach isn't too bad because Panfrost doesn't yet support > enabling devfreq with more than one supply. But that array isn't going > to work so nicely when that restriction is removed. > > The only sane way I can see of handling this in Panfrost would be > replicating the loop to count the supplies in the Panfrost code which > would allow dropping num_supplies from struct panfrost_compatible and > then supply_names in the same struct could be NULL terminated ready for > devm_pm_opp_set_regulators(). Or doing this, which will simplify both the cases. diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 7fcbc2a5b6cd..b3b55565b8ef 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -625,24 +625,29 @@ static int panfrost_remove(struct platform_device *pdev) return 0; } -static const char * const default_supplies[] = { "mali" }; +/* + * The OPP core wants the supply names to be NULL terminated, but we need the + * correct num_supplies value for regulator core. Hence, we NULL terminate here + * and then initialize num_supplies with ARRAY_SIZE - 1. + */ +static const char * const default_supplies[] = { "mali", NULL }; static const struct panfrost_compatible default_data = { - .num_supplies = ARRAY_SIZE(default_supplies), + .num_supplies = ARRAY_SIZE(default_supplies) - 1, .supply_names = default_supplies, .num_pm_domains = 1, /* optional */ .pm_domain_names = NULL, }; static const struct panfrost_compatible amlogic_data = { - .num_supplies = ARRAY_SIZE(default_supplies), + .num_supplies = ARRAY_SIZE(default_supplies) - 1, .supply_names = default_supplies, .vendor_quirk = panfrost_gpu_amlogic_quirk, }; -static const char * const mediatek_mt8183_supplies[] = { "mali", "sram" }; +static const char * const mediatek_mt8183_supplies[] = { "mali", "sram", NULL }; static const char * const mediatek_mt8183_pm_domains[] = { "core0", "core1", "core2" }; static const struct panfrost_compatible mediatek_mt8183_data = { - .num_supplies = ARRAY_SIZE(mediatek_mt8183_supplies), + .num_supplies = ARRAY_SIZE(mediatek_mt8183_supplies) - 1, .supply_names = mediatek_mt8183_supplies, .num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains), .pm_domain_names = mediatek_mt8183_pm_domains, -- viresh From mboxrd@z Thu Jan 1 00:00:00 1970 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 763A6C433EF for ; Tue, 5 Jul 2022 04:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=R9B8RvCfvXtnJp2aZ4Wh+YiTAMeMya1rFtRQA5NFMIY=; b=HIBXXYmyhu8Mih Bl7e0LfJXxElBn/SBW95MiUZbTvVjQ/BgwSKI3OrAQTF3Y/tHnBZbw5/lQbwL85NeljfheKAMPHCH XaLek8c9LhgPoZDBKpVQF6dVdvFoD6vKB47JkREYYhN4MbandLfOSHPs+2QhMCSbh1gbh5qQnmcaQ MXccHxr3vPFEvMUy9QfWOy/khtJmjxF8ABhW6wKrxT6LaAuY1vY7qWtmWLv4TjzJulxBwouv62Fwt AKoNESWLMi9vPBGjy2Qu92sHFhXH8qtL+Ag1SlVtIzvmlOEugtYq7uLGkpiNX7YQ0HnvBC758pK7M f9ZdOYq4U0ZhQ6QQZOcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o8aGs-00ERrz-3b; Tue, 05 Jul 2022 04:34:46 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o8aGp-00ERqw-IP for linux-arm-kernel@lists.infradead.org; Tue, 05 Jul 2022 04:34:45 +0000 Received: by mail-pl1-x62c.google.com with SMTP id n10so10061318plp.0 for ; Mon, 04 Jul 2022 21:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tmakuE4H8rZY3d6iU39dHrEeioyPOU2VRNgXbaFPqgw=; b=u7aod0CrQMXqVD1ebu7kjSt/WcQQQkg7j6oHslRmkt+QTw/T612mRYZc8qxkE8om3O EQM+h21JvLKnCzpiIq4xgwUXzQLpQJOdCt1694l5ZM1mQPkjlLZ33DO+Dp91Uof0icTc 2eCH31nP6U7iVCED/tU23T/actjjYFmw5UZLP7t0DKiBKU/nAR7cp0MXJlqAa8wI742A EQR0aX38sVjulvZcqY4l2O71LHN3k6M9c36toeseQylQoLjWGDZYqtxqvh3+p0Tozz/N XPHPZJPQNycYMom8jxQv3xsFNeAKZLSk+yfh0F9BKr8UZwwsSvArNI8r2sZRhz3icFzn 3CaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tmakuE4H8rZY3d6iU39dHrEeioyPOU2VRNgXbaFPqgw=; b=D8cmmCU9Wx/qIrxOaQp89K3Zp1dco0emxOuIfFmow7WR7fhIL43sv+Gd54YSQhi5Ek r7eXy/SFkKdY7lLqP4Knjl7ESqUPDfFFVJziekriPvjzI2BJ8QqsJCkTc4JbIO2kX3i1 Xg1kFBgKgINIeb5GQL47WoD32qJn8qGMuztANCpW3bCDJN3MjNhPpsORlIme2P5FYPjn HWrqKiG/+cE8EI3my+rozIAcl0yMtt+J8Pqk53sWqp+O9QGZBiM++fjo9DHJAW3FemlG 9Rb67e1JR7CJ/RaNK6zhToP3zJn9MFC5ZjGq8mbV9+xQzjKS180Hsvmg9CC/Ii1d/lLk GLPg== X-Gm-Message-State: AJIora/7LPsBSXsKuH1U55FmPb4mIOJG0X0DTbb7GtgqJAyJAMqbrAlO pUcleQV1ZaMlpCU3RZsvkxmf7A== X-Google-Smtp-Source: AGRyM1sRTY3jhmXML4zUAHI23oIyvbgNG1ONSMMqox+hipkmWXEtiTEid5mCOhRsoVVHI5UrE7Q83A== X-Received: by 2002:a17:90b:4a4f:b0:1ef:90fb:35a5 with SMTP id lb15-20020a17090b4a4f00b001ef90fb35a5mr5846805pjb.161.1656995682324; Mon, 04 Jul 2022 21:34:42 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id p26-20020a056a0026da00b005251e2b53acsm21651540pfw.116.2022.07.04.21.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 21:34:41 -0700 (PDT) Date: Tue, 5 Jul 2022 10:04:39 +0530 From: Viresh Kumar To: Steven Price Cc: "Rafael J. Wysocki" , Chanwoo Choi , MyungJoo Ham , Kyungmin Park , Krzysztof Kozlowski , Alim Akhtar , Qiang Yu , Rob Herring , Tomeu Vizoso , Alyssa Rosenzweig , Nishanth Menon , Stephen Boyd , Thierry Reding , Jonathan Hunter , linux-pm@vger.kernel.org, Vincent Guittot , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org, linux-tegra@vger.kernel.org Subject: Re: [PATCH V3 02/20] OPP: Make dev_pm_opp_set_regulators() accept NULL terminated list Message-ID: <20220705043439.xlrxusxrhwjupiyt@vireshk-i7> References: <9730e011004b7526e79c6f409f5147fb235b414a.1656935522.git.viresh.kumar@linaro.org> <48d865e8-6c0d-99c0-a43b-89793d5c3f85@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <48d865e8-6c0d-99c0-a43b-89793d5c3f85@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220704_213443_662387_C02CCB06 X-CRM114-Status: GOOD ( 24.29 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 04-07-22, 15:35, Steven Price wrote: > I have to say the 'new improved' list ending with NULL approach doesn't > work out so well for Panfrost. We already have to have a separate > 'num_supplies' variable for devm_regulator_bulk_get() / > regulator_bulk_{en,dis}able(), so the keeping everything in sync > argument is lost here. > > I would suggest added the NULL on the end of the lists in panfrost_drv.c > but then it would break the use of ARRAY_SIZE() to automagically keep > the length correct... Actually we can still make it work. > For now the approach isn't too bad because Panfrost doesn't yet support > enabling devfreq with more than one supply. But that array isn't going > to work so nicely when that restriction is removed. > > The only sane way I can see of handling this in Panfrost would be > replicating the loop to count the supplies in the Panfrost code which > would allow dropping num_supplies from struct panfrost_compatible and > then supply_names in the same struct could be NULL terminated ready for > devm_pm_opp_set_regulators(). Or doing this, which will simplify both the cases. diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 7fcbc2a5b6cd..b3b55565b8ef 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -625,24 +625,29 @@ static int panfrost_remove(struct platform_device *pdev) return 0; } -static const char * const default_supplies[] = { "mali" }; +/* + * The OPP core wants the supply names to be NULL terminated, but we need the + * correct num_supplies value for regulator core. Hence, we NULL terminate here + * and then initialize num_supplies with ARRAY_SIZE - 1. + */ +static const char * const default_supplies[] = { "mali", NULL }; static const struct panfrost_compatible default_data = { - .num_supplies = ARRAY_SIZE(default_supplies), + .num_supplies = ARRAY_SIZE(default_supplies) - 1, .supply_names = default_supplies, .num_pm_domains = 1, /* optional */ .pm_domain_names = NULL, }; static const struct panfrost_compatible amlogic_data = { - .num_supplies = ARRAY_SIZE(default_supplies), + .num_supplies = ARRAY_SIZE(default_supplies) - 1, .supply_names = default_supplies, .vendor_quirk = panfrost_gpu_amlogic_quirk, }; -static const char * const mediatek_mt8183_supplies[] = { "mali", "sram" }; +static const char * const mediatek_mt8183_supplies[] = { "mali", "sram", NULL }; static const char * const mediatek_mt8183_pm_domains[] = { "core0", "core1", "core2" }; static const struct panfrost_compatible mediatek_mt8183_data = { - .num_supplies = ARRAY_SIZE(mediatek_mt8183_supplies), + .num_supplies = ARRAY_SIZE(mediatek_mt8183_supplies) - 1, .supply_names = mediatek_mt8183_supplies, .num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains), .pm_domain_names = mediatek_mt8183_pm_domains, -- viresh _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 161DBC433EF for ; Tue, 5 Jul 2022 11:33:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2175510FC26; Tue, 5 Jul 2022 11:30:30 +0000 (UTC) Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by gabe.freedesktop.org (Postfix) with ESMTPS id D737710E021 for ; Tue, 5 Jul 2022 07:46:44 +0000 (UTC) Received: by mail-oi1-x232.google.com with SMTP id t189so15269326oie.8 for ; Tue, 05 Jul 2022 00:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tmakuE4H8rZY3d6iU39dHrEeioyPOU2VRNgXbaFPqgw=; b=u7aod0CrQMXqVD1ebu7kjSt/WcQQQkg7j6oHslRmkt+QTw/T612mRYZc8qxkE8om3O EQM+h21JvLKnCzpiIq4xgwUXzQLpQJOdCt1694l5ZM1mQPkjlLZ33DO+Dp91Uof0icTc 2eCH31nP6U7iVCED/tU23T/actjjYFmw5UZLP7t0DKiBKU/nAR7cp0MXJlqAa8wI742A EQR0aX38sVjulvZcqY4l2O71LHN3k6M9c36toeseQylQoLjWGDZYqtxqvh3+p0Tozz/N XPHPZJPQNycYMom8jxQv3xsFNeAKZLSk+yfh0F9BKr8UZwwsSvArNI8r2sZRhz3icFzn 3CaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tmakuE4H8rZY3d6iU39dHrEeioyPOU2VRNgXbaFPqgw=; b=bmN3t9kctkC5RMUsoFr2ghP5P+9Ou8tWDqQZ8KyEfryziPQ0kS3u4CBRxNqB0k+Tcz EV07+8l4WeB7O8bIz0iTV7P5wzunPs3ynW/bDk55CxjRx375q61CtbT8JHBGI4m2ENBV VlEGkZC/qLPzyvu4O/MfdcwcSDqvyImPzTL5s/+EUTh8l8FfP/AjzeBjFyNVBfaPMDlz SjjEZkxVgOonhRZnIatbZ7TnCgiKMgdfGssr1MVSEDACJkye66bfVyra3F5CVHU6S3zY QNC6iK3yyWXiR7jl7QGwzaD1kuxlsNwcHHpb/7P4VZEZhMmniI808Gg0g59jogdr+HHk mmfA== X-Gm-Message-State: AJIora/x5eWDQHqd8SvW8yRhbeVQ/dwYwt07TOx8s/hRY4rbcBAnxYT6 ihh3w5s2EFCFvU1fc6iFYrLJUkVV0o9Yvg== X-Google-Smtp-Source: AGRyM1sRTY3jhmXML4zUAHI23oIyvbgNG1ONSMMqox+hipkmWXEtiTEid5mCOhRsoVVHI5UrE7Q83A== X-Received: by 2002:a17:90b:4a4f:b0:1ef:90fb:35a5 with SMTP id lb15-20020a17090b4a4f00b001ef90fb35a5mr5846805pjb.161.1656995682324; Mon, 04 Jul 2022 21:34:42 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id p26-20020a056a0026da00b005251e2b53acsm21651540pfw.116.2022.07.04.21.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 21:34:41 -0700 (PDT) Date: Tue, 5 Jul 2022 10:04:39 +0530 From: Viresh Kumar To: Steven Price Subject: Re: [PATCH V3 02/20] OPP: Make dev_pm_opp_set_regulators() accept NULL terminated list Message-ID: <20220705043439.xlrxusxrhwjupiyt@vireshk-i7> References: <9730e011004b7526e79c6f409f5147fb235b414a.1656935522.git.viresh.kumar@linaro.org> <48d865e8-6c0d-99c0-a43b-89793d5c3f85@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48d865e8-6c0d-99c0-a43b-89793d5c3f85@arm.com> 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: Nishanth Menon , "Rafael J. Wysocki" , dri-devel@lists.freedesktop.org, Thierry Reding , Alim Akhtar , linux-samsung-soc@vger.kernel.org, Vincent Guittot , lima@lists.freedesktop.org, Kyungmin Park , Jonathan Hunter , Chanwoo Choi , MyungJoo Ham , Alyssa Rosenzweig , linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tomeu Vizoso , Stephen Boyd , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Krzysztof Kozlowski , Qiang Yu Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 04-07-22, 15:35, Steven Price wrote: > I have to say the 'new improved' list ending with NULL approach doesn't > work out so well for Panfrost. We already have to have a separate > 'num_supplies' variable for devm_regulator_bulk_get() / > regulator_bulk_{en,dis}able(), so the keeping everything in sync > argument is lost here. > > I would suggest added the NULL on the end of the lists in panfrost_drv.c > but then it would break the use of ARRAY_SIZE() to automagically keep > the length correct... Actually we can still make it work. > For now the approach isn't too bad because Panfrost doesn't yet support > enabling devfreq with more than one supply. But that array isn't going > to work so nicely when that restriction is removed. > > The only sane way I can see of handling this in Panfrost would be > replicating the loop to count the supplies in the Panfrost code which > would allow dropping num_supplies from struct panfrost_compatible and > then supply_names in the same struct could be NULL terminated ready for > devm_pm_opp_set_regulators(). Or doing this, which will simplify both the cases. diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 7fcbc2a5b6cd..b3b55565b8ef 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -625,24 +625,29 @@ static int panfrost_remove(struct platform_device *pdev) return 0; } -static const char * const default_supplies[] = { "mali" }; +/* + * The OPP core wants the supply names to be NULL terminated, but we need the + * correct num_supplies value for regulator core. Hence, we NULL terminate here + * and then initialize num_supplies with ARRAY_SIZE - 1. + */ +static const char * const default_supplies[] = { "mali", NULL }; static const struct panfrost_compatible default_data = { - .num_supplies = ARRAY_SIZE(default_supplies), + .num_supplies = ARRAY_SIZE(default_supplies) - 1, .supply_names = default_supplies, .num_pm_domains = 1, /* optional */ .pm_domain_names = NULL, }; static const struct panfrost_compatible amlogic_data = { - .num_supplies = ARRAY_SIZE(default_supplies), + .num_supplies = ARRAY_SIZE(default_supplies) - 1, .supply_names = default_supplies, .vendor_quirk = panfrost_gpu_amlogic_quirk, }; -static const char * const mediatek_mt8183_supplies[] = { "mali", "sram" }; +static const char * const mediatek_mt8183_supplies[] = { "mali", "sram", NULL }; static const char * const mediatek_mt8183_pm_domains[] = { "core0", "core1", "core2" }; static const struct panfrost_compatible mediatek_mt8183_data = { - .num_supplies = ARRAY_SIZE(mediatek_mt8183_supplies), + .num_supplies = ARRAY_SIZE(mediatek_mt8183_supplies) - 1, .supply_names = mediatek_mt8183_supplies, .num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains), .pm_domain_names = mediatek_mt8183_pm_domains, -- viresh