Message ID | 20231227-topic-rpm_vreg_cleanup-v1-1-949da0864ac5@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-11761-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1188584dyb; Tue, 26 Dec 2023 17:29:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKx7OKgAlkNTuwopeVrl2fPyy2IT9F/bgT7HbdbeZNO1FX/C3Ck9x3t2mGLjpMpX+OPKaa X-Received: by 2002:a05:6a20:948a:b0:185:a90d:363d with SMTP id hs10-20020a056a20948a00b00185a90d363dmr2545060pzb.2.1703640596211; Tue, 26 Dec 2023 17:29:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703640596; cv=none; d=google.com; s=arc-20160816; b=xBla6YhUqWydMHzgLbCjx/gRhCaHvhfqgnFUNiv7L+QDQk4n1boWEJBz8Tmc+hF0NR a/BQ2mSlLaQEAVuvqhwyIEWzKsclpQqMCfrEyEC/79i2KDNvyqPPRv6qQqTs7JK0zCLn D6lUIKbtQkLoeu8pEQ3XVVsePHALyc2S0W1lrUSbMTrtUbnmLH7U/STkZErQFXsrNYKD aco0QlJnDibpUFQRh1cOjaF8FfzmQI0KjjnLhK8RBwDyUkgDfHUU3OLOdTSGhbNVAU1o zfgyOLw8k25LhkV4XABnQRpRElG32Hx8koS6lU0Df6wn8NCFBOnEuBee3C40qCxvnhMi aB2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=2D5wXd8y6YDz3Y7OZAiTyYTC//DCpbhbIggq/xSd+SI=; fh=YqCUu3IHdr2x/V42qXGmq9GqIjeiJWFLd8hl8HJ0aWc=; b=nnrVIQZTjrU6NDA1aQwRF+IW4+FBfAc8wjAqAMUUwQb7NZZJQ7f+s68LDz9Gaj/tU9 SK5y2+urwwCw+hL4qHgiAjW9pBD5MJdK3mq5d91YigAPXzRkHvHa45s6VqB6JsZPmFYH tUtYENaFIBibJZTLJiEMu+7dakYqLUZeydtXy4J1xTvnDnQEklxevXm/LDfFaejluxLy tZkxBdMIcv0j31K9pOrwoGETgw8lKmDL0X2d5xY22/vgI3Hx/sbYMsuDgMPxA/DBTM3B yhl/Qc2osWzMNdFcRIHgDASQEYLHW6tvfkBhz/kivgcfwWYdSWP1koYAexBfmvuCq6cD HRrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YhRzvGtn; spf=pass (google.com: domain of linux-kernel+bounces-11761-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11761-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c13-20020a170903234d00b001cfc9a1915bsi10483971plh.234.2023.12.26.17.29.56 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 17:29:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11761-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YhRzvGtn; spf=pass (google.com: domain of linux-kernel+bounces-11761-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11761-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BBB49281682 for <ouuuleilei@gmail.com>; Wed, 27 Dec 2023 01:29:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7955923BC; Wed, 27 Dec 2023 01:29:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="YhRzvGtn" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C48D1FA3 for <linux-kernel@vger.kernel.org>; Wed, 27 Dec 2023 01:29:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a26fa26e7aeso143696666b.3 for <linux-kernel@vger.kernel.org>; Tue, 26 Dec 2023 17:29:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703640574; x=1704245374; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=2D5wXd8y6YDz3Y7OZAiTyYTC//DCpbhbIggq/xSd+SI=; b=YhRzvGtn5AzXYqjNQgz8SnesemOt2K6TLUzkltbz6CBxSa6uKG3bXQKXYEqe3YAoe+ 3aSaQzBuxBEdJlLq6Ey8rw8jhMnxEnfX5NSdAwHvKtLMvd/SiCdmGDPShLC+iGdc/JTK WAgSenhIvt0mpJaf54+GJB+MGhtJ43f24bs+jgwwW76fcgZhx9LRtgqEayPp1+CVvujb QJXwLYOtXmB0BFwVnzZ6pkXfoS7kvbl12PYnj6g2BIY+bkfQcH1R36DulLaEo+At33S4 M6LdcfFwFAIYeoYE2L6A9n9UKqStMSEXVDCwAkDYSbroynKtME34RkU5yQ6YXUk7K1a0 hQ3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703640574; x=1704245374; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2D5wXd8y6YDz3Y7OZAiTyYTC//DCpbhbIggq/xSd+SI=; b=E5qyDyIa/Aw5MnAsmGhIfiJUqEEAi+J2y8LrWpixtpJe2QxJfe8ZzNp0webpl6bY1Z JjmdHnEzmofEq45FeaCGemFHkbrLbTWYylqjSrkSnx3W6WgVjT3rGHuDKnSzOhcUIgr6 Tmb7kQUL0JKlgUPnR0Nd+AFRAYbU+qNLq6dssVT/wnCdGW5x3LiMvUR4U/3/2E3F0XXo 5tg6oOHXMppDWwlmYrceGGNB7haYPBfFGuzuI9N987JXg0TH92gJODrp6EAEr3A/KR+z JZM7bZdFgI/5vgApLGhB1TZlc5qARxWmMztOOuRWWtkz2Rp8Nonjp/Lr8Su6fIcVhgm2 g8Tg== X-Gm-Message-State: AOJu0YxO2+hyQZhqy5qiP/s6DPkiqfsEJAOpRYadxcBkUYWTxAxYkm06 3Okum0SbVw4yFF4GHOo+kIxWDBsq9wgrIw== X-Received: by 2002:a17:906:6150:b0:a19:a19b:c701 with SMTP id p16-20020a170906615000b00a19a19bc701mr3969934ejl.81.1703640574350; Tue, 26 Dec 2023 17:29:34 -0800 (PST) Received: from [10.167.154.1] (178235179028.dynamic-4-waw-k-1-3-0.vectranet.pl. [178.235.179.28]) by smtp.gmail.com with ESMTPSA id up10-20020a170907cc8a00b00a2366090bcfsm2563010ejc.212.2023.12.26.17.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 17:29:34 -0800 (PST) From: Konrad Dybcio <konrad.dybcio@linaro.org> Date: Wed, 27 Dec 2023 02:29:33 +0100 Subject: [PATCH] regulator: qcom_smd: Keep one rpm handle for all vregs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231227-topic-rpm_vreg_cleanup-v1-1-949da0864ac5@linaro.org> X-B4-Tracking: v=1; b=H4sIAPx9i2UC/x2NWwqDQAwAryL5bkBTpI+rlCJrjBrYxiWrUhDv3 qWfMzDMAVlcJcOzOsBl16yLFWguFfAcbBLUoTBQTdeG6IbrkpTR06fbXaaOowTbEo6hfrQ8tHQ XhhL3IQv2HoznktsWY5HJZdTv//Z6n+cP3Rsjen0AAAA= To: Bjorn Andersson <andersson@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org> Cc: Marijn Suijten <marijn.suijten@somainline.org>, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio <konrad.dybcio@linaro.org> X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1703640573; l=2867; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=9Tqu1p9SYBTpsvzpd2G7/sD+9sC24EsBi4LoZn2SeCY=; b=mBHz7z3eGXsXINB18n0CU/5eNlgbMYl5gbtssb6tOVlg9/++g8QgKLVlTHRkQLJNj4Fsfd0kh kJEQaybQb3tBNAy9Kldff7BpHpIhuwbXpRQiSaqJIhiO1BgImv1qe34 X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786396641606871494 X-GMAIL-MSGID: 1786396641606871494 |
Series |
regulator: qcom_smd: Keep one rpm handle for all vregs
|
|
Commit Message
Konrad Dybcio
Dec. 27, 2023, 1:29 a.m. UTC
For no apparent reason (as there's just one RPM per SoC), all vregs
currently store a copy of a pointer to smd_rpm. Introduce a single,
global one to save up on space in each definition.
bloat-o-meter reports:
Total: Before=43944, After=43924, chg -0.05%
plus sizeof(ptr) on every dynamically allocated regulator :)
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
drivers/regulator/qcom_smd-regulator.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
---
base-commit: 39676dfe52331dba909c617f213fdb21015c8d10
change-id: 20231227-topic-rpm_vreg_cleanup-fa095cd528ec
Best regards,
Comments
Hi Konrad,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 39676dfe52331dba909c617f213fdb21015c8d10]
url: https://github.com/intel-lab-lkp/linux/commits/Konrad-Dybcio/regulator-qcom_smd-Keep-one-rpm-handle-for-all-vregs/20231227-093153
base: 39676dfe52331dba909c617f213fdb21015c8d10
patch link: https://lore.kernel.org/r/20231227-topic-rpm_vreg_cleanup-v1-1-949da0864ac5%40linaro.org
patch subject: [PATCH] regulator: qcom_smd: Keep one rpm handle for all vregs
config: arc-randconfig-001-20231227 (https://download.01.org/0day-ci/archive/20231227/202312271812.C5jldM3L-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231227/202312271812.C5jldM3L-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312271812.C5jldM3L-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/regulator/qcom_smd-regulator.c:1395: warning: Excess function parameter 'rpm' description in 'rpm_regulator_init_vreg'
vim +1395 drivers/regulator/qcom_smd-regulator.c
da65e367b67e15 Bjorn Andersson 2015-08-17 1379
14e2976fbabdac Konrad Dybcio 2021-12-30 1380 /**
14e2976fbabdac Konrad Dybcio 2021-12-30 1381 * rpm_regulator_init_vreg() - initialize all attributes of a qcom_smd-regulator
14e2976fbabdac Konrad Dybcio 2021-12-30 1382 * @vreg: Pointer to the individual qcom_smd-regulator resource
14e2976fbabdac Konrad Dybcio 2021-12-30 1383 * @dev: Pointer to the top level qcom_smd-regulator PMIC device
14e2976fbabdac Konrad Dybcio 2021-12-30 1384 * @node: Pointer to the individual qcom_smd-regulator resource
14e2976fbabdac Konrad Dybcio 2021-12-30 1385 * device node
14e2976fbabdac Konrad Dybcio 2021-12-30 1386 * @rpm: Pointer to the rpm bus node
14e2976fbabdac Konrad Dybcio 2021-12-30 1387 * @pmic_rpm_data: Pointer to a null-terminated array of qcom_smd-regulator
14e2976fbabdac Konrad Dybcio 2021-12-30 1388 * resources defined for the top level PMIC device
14e2976fbabdac Konrad Dybcio 2021-12-30 1389 *
14e2976fbabdac Konrad Dybcio 2021-12-30 1390 * Return: 0 on success, errno on failure
14e2976fbabdac Konrad Dybcio 2021-12-30 1391 */
14e2976fbabdac Konrad Dybcio 2021-12-30 1392 static int rpm_regulator_init_vreg(struct qcom_rpm_reg *vreg, struct device *dev,
d7cdd450e31088 Konrad Dybcio 2023-12-27 1393 struct device_node *node,
14e2976fbabdac Konrad Dybcio 2021-12-30 1394 const struct rpm_regulator_data *pmic_rpm_data)
da65e367b67e15 Bjorn Andersson 2015-08-17 @1395 {
da65e367b67e15 Bjorn Andersson 2015-08-17 1396 struct regulator_config config = {};
14e2976fbabdac Konrad Dybcio 2021-12-30 1397 const struct rpm_regulator_data *rpm_data;
da65e367b67e15 Bjorn Andersson 2015-08-17 1398 struct regulator_dev *rdev;
14e2976fbabdac Konrad Dybcio 2021-12-30 1399 int ret;
14e2976fbabdac Konrad Dybcio 2021-12-30 1400
14e2976fbabdac Konrad Dybcio 2021-12-30 1401 for (rpm_data = pmic_rpm_data; rpm_data->name; rpm_data++)
14e2976fbabdac Konrad Dybcio 2021-12-30 1402 if (of_node_name_eq(node, rpm_data->name))
14e2976fbabdac Konrad Dybcio 2021-12-30 1403 break;
14e2976fbabdac Konrad Dybcio 2021-12-30 1404
14e2976fbabdac Konrad Dybcio 2021-12-30 1405 if (!rpm_data->name) {
14e2976fbabdac Konrad Dybcio 2021-12-30 1406 dev_err(dev, "Unknown regulator %pOFn\n", node);
14e2976fbabdac Konrad Dybcio 2021-12-30 1407 return -EINVAL;
14e2976fbabdac Konrad Dybcio 2021-12-30 1408 }
14e2976fbabdac Konrad Dybcio 2021-12-30 1409
14e2976fbabdac Konrad Dybcio 2021-12-30 1410 vreg->dev = dev;
14e2976fbabdac Konrad Dybcio 2021-12-30 1411 vreg->type = rpm_data->type;
14e2976fbabdac Konrad Dybcio 2021-12-30 1412 vreg->id = rpm_data->id;
14e2976fbabdac Konrad Dybcio 2021-12-30 1413
14e2976fbabdac Konrad Dybcio 2021-12-30 1414 memcpy(&vreg->desc, rpm_data->desc, sizeof(vreg->desc));
14e2976fbabdac Konrad Dybcio 2021-12-30 1415 vreg->desc.name = rpm_data->name;
14e2976fbabdac Konrad Dybcio 2021-12-30 1416 vreg->desc.supply_name = rpm_data->supply;
14e2976fbabdac Konrad Dybcio 2021-12-30 1417 vreg->desc.owner = THIS_MODULE;
14e2976fbabdac Konrad Dybcio 2021-12-30 1418 vreg->desc.type = REGULATOR_VOLTAGE;
14e2976fbabdac Konrad Dybcio 2021-12-30 1419 vreg->desc.of_match = rpm_data->name;
14e2976fbabdac Konrad Dybcio 2021-12-30 1420
14e2976fbabdac Konrad Dybcio 2021-12-30 1421 config.dev = dev;
14e2976fbabdac Konrad Dybcio 2021-12-30 1422 config.of_node = node;
14e2976fbabdac Konrad Dybcio 2021-12-30 1423 config.driver_data = vreg;
14e2976fbabdac Konrad Dybcio 2021-12-30 1424
14e2976fbabdac Konrad Dybcio 2021-12-30 1425 rdev = devm_regulator_register(dev, &vreg->desc, &config);
14e2976fbabdac Konrad Dybcio 2021-12-30 1426 if (IS_ERR(rdev)) {
14e2976fbabdac Konrad Dybcio 2021-12-30 1427 ret = PTR_ERR(rdev);
14e2976fbabdac Konrad Dybcio 2021-12-30 1428 dev_err(dev, "%pOFn: devm_regulator_register() failed, ret=%d\n", node, ret);
14e2976fbabdac Konrad Dybcio 2021-12-30 1429 return ret;
14e2976fbabdac Konrad Dybcio 2021-12-30 1430 }
14e2976fbabdac Konrad Dybcio 2021-12-30 1431
14e2976fbabdac Konrad Dybcio 2021-12-30 1432 return 0;
14e2976fbabdac Konrad Dybcio 2021-12-30 1433 }
14e2976fbabdac Konrad Dybcio 2021-12-30 1434
On 27/12/2023 03:29, Konrad Dybcio wrote: > For no apparent reason (as there's just one RPM per SoC), all vregs > currently store a copy of a pointer to smd_rpm. Introduce a single, > global one to save up on space in each definition. > > bloat-o-meter reports: > > Total: Before=43944, After=43924, chg -0.05% > > plus sizeof(ptr) on every dynamically allocated regulator :) > > Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> > --- > drivers/regulator/qcom_smd-regulator.c | 18 +++++++----------- > 1 file changed, 7 insertions(+), 11 deletions(-) > > diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c > index d1be9568025e..905c15df8c85 100644 > --- a/drivers/regulator/qcom_smd-regulator.c > +++ b/drivers/regulator/qcom_smd-regulator.c > @@ -11,11 +11,10 @@ > #include <linux/regulator/of_regulator.h> > #include <linux/soc/qcom/smd-rpm.h> > > +struct qcom_smd_rpm *smd_vreg_rpm; > + > struct qcom_rpm_reg { > struct device *dev; > - > - struct qcom_smd_rpm *rpm; > - > u32 type; > u32 id; > > @@ -70,7 +69,7 @@ static int rpm_reg_write_active(struct qcom_rpm_reg *vreg) > if (!reqlen) > return 0; > > - ret = qcom_rpm_smd_write(vreg->rpm, QCOM_SMD_RPM_ACTIVE_STATE, > + ret = qcom_rpm_smd_write(smd_vreg_rpm, QCOM_SMD_RPM_ACTIVE_STATE, > vreg->type, vreg->id, > req, sizeof(req[0]) * reqlen); > if (!ret) { > @@ -1391,7 +1390,7 @@ MODULE_DEVICE_TABLE(of, rpm_of_match); > * Return: 0 on success, errno on failure > */ > static int rpm_regulator_init_vreg(struct qcom_rpm_reg *vreg, struct device *dev, > - struct device_node *node, struct qcom_smd_rpm *rpm, > + struct device_node *node, > const struct rpm_regulator_data *pmic_rpm_data) > { > struct regulator_config config = {}; > @@ -1409,7 +1408,6 @@ static int rpm_regulator_init_vreg(struct qcom_rpm_reg *vreg, struct device *dev > } > > vreg->dev = dev; > - vreg->rpm = rpm; > vreg->type = rpm_data->type; > vreg->id = rpm_data->id; > > @@ -1440,11 +1438,10 @@ static int rpm_reg_probe(struct platform_device *pdev) > const struct rpm_regulator_data *vreg_data; > struct device_node *node; > struct qcom_rpm_reg *vreg; > - struct qcom_smd_rpm *rpm; > int ret; > > - rpm = dev_get_drvdata(pdev->dev.parent); > - if (!rpm) { > + smd_vreg_rpm = dev_get_drvdata(pdev->dev.parent); > + if (!smd_vreg_rpm) { I thought about having a mutex around (I don't remember if secondary PMICs and/or chargers can be routed through RPM or not). Then I went on checking other RPM and SMD-RPM drivers. clk-rpm: global variable, field clk-smd-rpm: struct field regulator_qcom-smd-rpm: struct field Probably it's worth using the same approach in all four drivers? > dev_err(&pdev->dev, "Unable to retrieve handle to rpm\n"); > return -ENODEV; > } > @@ -1460,8 +1457,7 @@ static int rpm_reg_probe(struct platform_device *pdev) > return -ENOMEM; > } > > - ret = rpm_regulator_init_vreg(vreg, dev, node, rpm, vreg_data); > - > + ret = rpm_regulator_init_vreg(vreg, dev, node, vreg_data); > if (ret < 0) { > of_node_put(node); > return ret; > > --- > base-commit: 39676dfe52331dba909c617f213fdb21015c8d10 > change-id: 20231227-topic-rpm_vreg_cleanup-fa095cd528ec > > Best regards,
On 27.12.2023 12:48, Dmitry Baryshkov wrote: > On 27/12/2023 03:29, Konrad Dybcio wrote: >> For no apparent reason (as there's just one RPM per SoC), all vregs >> currently store a copy of a pointer to smd_rpm. Introduce a single, >> global one to save up on space in each definition. >> >> bloat-o-meter reports: >> >> Total: Before=43944, After=43924, chg -0.05% >> >> plus sizeof(ptr) on every dynamically allocated regulator :) >> >> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> >> --- [...] >> @@ -1440,11 +1438,10 @@ static int rpm_reg_probe(struct platform_device *pdev) >> const struct rpm_regulator_data *vreg_data; >> struct device_node *node; >> struct qcom_rpm_reg *vreg; >> - struct qcom_smd_rpm *rpm; >> int ret; >> - rpm = dev_get_drvdata(pdev->dev.parent); >> - if (!rpm) { >> + smd_vreg_rpm = dev_get_drvdata(pdev->dev.parent); >> + if (!smd_vreg_rpm) { > > I thought about having a mutex around (I don't remember if secondary PMICs and/or chargers can be routed through RPM or not). A mutex for assigning this? Konrad > > Then I went on checking other RPM and SMD-RPM drivers. > > clk-rpm: global variable, field > clk-smd-rpm: struct field > regulator_qcom-smd-rpm: struct field > > Probably it's worth using the same approach in all four drivers?
On Wed, 3 Jan 2024 at 12:03, Konrad Dybcio <konrad.dybcio@linaro.org> wrote: > > On 27.12.2023 12:48, Dmitry Baryshkov wrote: > > On 27/12/2023 03:29, Konrad Dybcio wrote: > >> For no apparent reason (as there's just one RPM per SoC), all vregs > >> currently store a copy of a pointer to smd_rpm. Introduce a single, > >> global one to save up on space in each definition. > >> > >> bloat-o-meter reports: > >> > >> Total: Before=43944, After=43924, chg -0.05% > >> > >> plus sizeof(ptr) on every dynamically allocated regulator :) > >> > >> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> > >> --- > > [...] > > >> @@ -1440,11 +1438,10 @@ static int rpm_reg_probe(struct platform_device *pdev) > >> const struct rpm_regulator_data *vreg_data; > >> struct device_node *node; > >> struct qcom_rpm_reg *vreg; > >> - struct qcom_smd_rpm *rpm; > >> int ret; > >> - rpm = dev_get_drvdata(pdev->dev.parent); > >> - if (!rpm) { > >> + smd_vreg_rpm = dev_get_drvdata(pdev->dev.parent); > >> + if (!smd_vreg_rpm) { > > > > I thought about having a mutex around (I don't remember if secondary PMICs and/or chargers can be routed through RPM or not). > > A mutex for assigning this? Yep. > > Konrad > > > > Then I went on checking other RPM and SMD-RPM drivers. > > > > clk-rpm: global variable, field > > clk-smd-rpm: struct field > > regulator_qcom-smd-rpm: struct field > > > > Probably it's worth using the same approach in all four drivers? > >
diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c index d1be9568025e..905c15df8c85 100644 --- a/drivers/regulator/qcom_smd-regulator.c +++ b/drivers/regulator/qcom_smd-regulator.c @@ -11,11 +11,10 @@ #include <linux/regulator/of_regulator.h> #include <linux/soc/qcom/smd-rpm.h> +struct qcom_smd_rpm *smd_vreg_rpm; + struct qcom_rpm_reg { struct device *dev; - - struct qcom_smd_rpm *rpm; - u32 type; u32 id; @@ -70,7 +69,7 @@ static int rpm_reg_write_active(struct qcom_rpm_reg *vreg) if (!reqlen) return 0; - ret = qcom_rpm_smd_write(vreg->rpm, QCOM_SMD_RPM_ACTIVE_STATE, + ret = qcom_rpm_smd_write(smd_vreg_rpm, QCOM_SMD_RPM_ACTIVE_STATE, vreg->type, vreg->id, req, sizeof(req[0]) * reqlen); if (!ret) { @@ -1391,7 +1390,7 @@ MODULE_DEVICE_TABLE(of, rpm_of_match); * Return: 0 on success, errno on failure */ static int rpm_regulator_init_vreg(struct qcom_rpm_reg *vreg, struct device *dev, - struct device_node *node, struct qcom_smd_rpm *rpm, + struct device_node *node, const struct rpm_regulator_data *pmic_rpm_data) { struct regulator_config config = {}; @@ -1409,7 +1408,6 @@ static int rpm_regulator_init_vreg(struct qcom_rpm_reg *vreg, struct device *dev } vreg->dev = dev; - vreg->rpm = rpm; vreg->type = rpm_data->type; vreg->id = rpm_data->id; @@ -1440,11 +1438,10 @@ static int rpm_reg_probe(struct platform_device *pdev) const struct rpm_regulator_data *vreg_data; struct device_node *node; struct qcom_rpm_reg *vreg; - struct qcom_smd_rpm *rpm; int ret; - rpm = dev_get_drvdata(pdev->dev.parent); - if (!rpm) { + smd_vreg_rpm = dev_get_drvdata(pdev->dev.parent); + if (!smd_vreg_rpm) { dev_err(&pdev->dev, "Unable to retrieve handle to rpm\n"); return -ENODEV; } @@ -1460,8 +1457,7 @@ static int rpm_reg_probe(struct platform_device *pdev) return -ENOMEM; } - ret = rpm_regulator_init_vreg(vreg, dev, node, rpm, vreg_data); - + ret = rpm_regulator_init_vreg(vreg, dev, node, vreg_data); if (ret < 0) { of_node_put(node); return ret;