From patchwork Wed Jan 3 20:18:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 759905 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 B5FA31D533 for ; Wed, 3 Jan 2024 20:18:45 +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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uZApOUn/" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-556c60c3f9aso1348125a12.3 for ; Wed, 03 Jan 2024 12:18:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704313124; x=1704917924; 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=A2ZJGOikkMPN7pWE+w4oJN8NP+AUZ90HIGt1xo13QEI=; b=uZApOUn/mxLlMGJPmm13Egfnu3YTFdKAaTNE1MiHXsPtABwULRkw060NScRKNlCRGg TwyZekzmk+yyQEm3C/VK7/5NLM7Do7DQcYPg5/o0D1I2lqGLjHzeZyhxAlzFuPmFT73c N2rR8KSfvthAYGNOV3mAKRjrVfjiaLR1V6I1PNzfAx5ZDvlcP+EX2sWU4ziVYLW6D96r y2sNojkabKsz899K7+EDz65kK4q1J2FLavuLP8xVb+iO/omjvAXS9zNOKgNd7aWzhkKw JIYoDwQ9v/HxsWnrcDIgqIfVkSWLyGBxVkyinHdMLQwpDLnp5sdY/tLUq+xZXsNbAEOx ab4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704313124; x=1704917924; 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=A2ZJGOikkMPN7pWE+w4oJN8NP+AUZ90HIGt1xo13QEI=; b=MbaCIsRSXUx3CiO8PYH+nZD7pNM+W9MXlgwrzOy+2f+j7yzIBKiCSoEsALoBqVs/FT CAnjc3UZfBR4gXT3Sv8iDm95hLvSXUTgns8aCYMKJBm15XizdMiQMZwfOde+Ifq1QahQ +YDpHcJrm26ur68cUC3VqFSIpWHlNmvyJTDdSBpnSnLe8Ilgo6JwpxoypeiuDefClLDh 4pE+UnzfIQZ45RuScJ2ehwQ00g2dJbbAkfShQylhJ+okY8r6yRUtv4QZBC3IqcaSkvjT NtSLRayJM/+CCFO8aOvqnwMN8nzsSoZd81YlzpcXLNVILDPB9x4jPt6jjd2Q5DPX19IF u31g== X-Gm-Message-State: AOJu0Yyt8WMJEeWhWgSsqZFkGDmNR5wuesjqHyQk8eohWvP5d1DagTE/ MezFdpRcnwNOOVV0i5UiOXV9rfBF/WxdUA== X-Google-Smtp-Source: AGHT+IEopSTbCf4B5V8fqwdakyTaEaltKwMaH7A9dLKVUUxSh9Idzu+RVi94wLwRocTrAJnl8BnPww== X-Received: by 2002:a17:907:7e8a:b0:a28:afb8:9eea with SMTP id qb10-20020a1709077e8a00b00a28afb89eeamr553258ejc.86.1704313124095; Wed, 03 Jan 2024 12:18:44 -0800 (PST) Received: from [10.167.154.1] (178235179036.dynamic-4-waw-k-1-3-0.vectranet.pl. [178.235.179.36]) by smtp.gmail.com with ESMTPSA id wl1-20020a170907310100b00a236378a43fsm12962108ejb.62.2024.01.03.12.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 12:18:43 -0800 (PST) From: Konrad Dybcio Date: Wed, 03 Jan 2024 21:18:37 +0100 Subject: [PATCH v2] regulator: qcom_smd: Keep one rpm handle for all vregs Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231227-topic-rpm_vreg_cleanup-v2-1-04c79c4f9166@linaro.org> X-B4-Tracking: v=1; b=H4sIABzBlWUC/4WNQQqDMBAAvyI5N0VTbbWn/qOIrHHVhTQJGw0t4 t+b+oEeZ2CYTQRkwiDu2SYYIwVyNoE6ZULPYCeUNCQWKleXQqmbXJwnLdm/usg4ddog2NXLEfK m0kOlatQixT0ElD2D1XPK7WpMkp5xpPdxe7aJZwqL488xj8XP/v3EQhayKZsB8vpagq4ehiywO zueRLvv+xfm8N3c0gAAAA== To: Bjorn Andersson , Liam Girdwood , Mark Brown Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1704313122; l=3511; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=oEtESB40r3b9IYd6/4bBqk9VXGazYB7UyTINdPp6n1U=; b=f7TiSIjD0bq8Xe77nwYvDy0TQG9DRzTS6fI3U1ukcZ2PtidSH0NyXUwOD0jeWtZGScn725yOg ztw/q+mYeCjBPXOb6WAX1KiLDgOrG7SFxOpTP/p9uYtBLeT+2Iovi7t X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= 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 --- Changes in v2: - Remove unused function argument from rpm_regulator_init_vreg kerneldoc - Do NOT add a mutex around the rpm assignment, talked to Dmitry offline and we concluded it makes no sense - Link to v1: https://lore.kernel.org/r/20231227-topic-rpm_vreg_cleanup-v1-1-949da0864ac5@linaro.org --- drivers/regulator/qcom_smd-regulator.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) --- base-commit: 0fef202ac2f8e6d9ad21aead648278f1226b9053 change-id: 20231227-topic-rpm_vreg_cleanup-fa095cd528ec Best regards, diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c index d1be9568025e..5461c03e2aac 100644 --- a/drivers/regulator/qcom_smd-regulator.c +++ b/drivers/regulator/qcom_smd-regulator.c @@ -11,11 +11,10 @@ #include #include +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) { @@ -1384,14 +1383,13 @@ MODULE_DEVICE_TABLE(of, rpm_of_match); * @dev: Pointer to the top level qcom_smd-regulator PMIC device * @node: Pointer to the individual qcom_smd-regulator resource * device node - * @rpm: Pointer to the rpm bus node * @pmic_rpm_data: Pointer to a null-terminated array of qcom_smd-regulator * resources defined for the top level PMIC device * * 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 +1407,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 +1437,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 +1456,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;