From: Krzysztof Kozlowski <krzk@kernel.org>
To: Gaurav Kohli <gaurav.kohli@oss.qualcomm.com>,
andersson@kernel.org, mathieu.poirier@linaro.org,
robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
rafael@kernel.org, daniel.lezcano@linaro.org,
rui.zhang@intel.com, lukasz.luba@arm.com, konradybcio@kernel.org,
amitk@kernel.org, mani@kernel.org, casey.connolly@linaro.org
Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH v1 4/8] thermal: qcom: add qmi-cooling driver
Date: Wed, 24 Dec 2025 10:01:07 +0100 [thread overview]
Message-ID: <7b48c104-5430-455b-be11-ab23387f88ff@kernel.org> (raw)
In-Reply-To: <20251223123227.1317244-5-gaurav.kohli@oss.qualcomm.com>
On 23/12/2025 13:32, Gaurav Kohli wrote:
> +static int thermal_qmi_new_server(struct qmi_handle *qmi, struct qmi_service *service)
> +{
> + struct qmi_tmd_client *client = container_of(qmi, struct qmi_tmd_client, handle);
> + struct sockaddr_qrtr sq = { AF_QIPCRTR, service->node, service->port };
> +
> + scoped_guard(mutex, &client->mutex)
> + kernel_connect(qmi->sock, (struct sockaddr_unsized *)&sq, sizeof(sq), 0);
> +
> + queue_work(system_highpri_wq, &client->svc_arrive_work);
> +
> + return 0;
> +}
> +
> +static struct qmi_ops thermal_qmi_event_ops = {
Why this is not const?
From where did you copy this code?
> + .new_server = thermal_qmi_new_server,
> + .del_server = thermal_qmi_del_server,
> + .net_reset = thermal_qmi_net_reset,
> +};
> +
> +static void qmi_tmd_cleanup(struct qmi_tmd_client *client)
> +{
> + struct qmi_tmd *tmd, *c_next;
> +
> + guard(mutex)(&client->mutex);
> +
> + client->connection_active = false;
> +
> + qmi_handle_release(&client->handle);
> + cancel_work(&client->svc_arrive_work);
> + list_for_each_entry_safe(tmd, c_next, &client->cdev_list, node) {
> + if (tmd->rproc_cdev)
> + remoteproc_cooling_unregister(tmd->rproc_cdev);
> +
> + list_del(&tmd->node);
> + }
> +}
> +
> +/* Parse the controls and allocate a qmi_tmd for each of them */
> +static int qmi_tmd_alloc_cdevs(struct qmi_tmd_client *client)
> +{
> + struct device *dev = client->dev;
> + struct qmi_tmd *tmd;
> + struct device_node *subnode, *node = dev->of_node;
> + int ret;
> +
> + for_each_available_child_of_node(node, subnode) {
> + const char *name;
> +
> + tmd = devm_kzalloc(dev, sizeof(*tmd), GFP_KERNEL);
> + if (!tmd)
> + return dev_err_probe(client->dev, -ENOMEM,
> + "Couldn't allocate tmd\n");
You leak nodes.
> +
> + tmd->type = devm_kasprintf(client->dev, GFP_KERNEL, "%s:%s",
> + client->name, subnode->name);
> + if (!tmd->type)
> + return dev_err_probe(dev, -ENOMEM,
> + "Couldn't allocate cooling device name\n");
Everywhere...
> +
> + if (of_property_read_string(subnode, "label", &name)) {
> + return dev_err_probe(client->dev, -EINVAL,
> + "Failed to parse dev name for %s\n",
> + subnode->name);
> + }
> +
> + ret = strscpy(tmd->qmi_name, name,
> + QMI_TMD_MITIGATION_DEV_ID_LENGTH_MAX_V01 + 1);
> + if (ret == -E2BIG) {
> + return dev_err_probe(dev, -EINVAL, "TMD label %s is too long\n",
> + name);
> + }
> +
> + tmd->client = client;
> + tmd->np = subnode;
> + tmd->cur_state = 0;
> + list_add(&tmd->node, &client->cdev_list);
> + }
> +
> + if (list_empty(&client->cdev_list))
> + return dev_err_probe(client->dev, -EINVAL,
> + "No cooling devices specified for client %s (%#x)\n",
> + client->name, client->id);
> +
> + return 0;
> +}
> +
> +static int qmi_tmd_client_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct qmi_tmd_client *client;
> + const struct qmi_instance_data *match;
> + int ret;
Open any existing Linux driver. How does this part look like?
> + client = devm_kzalloc(dev, sizeof(*client), GFP_KERNEL);
> + if (!client)
> + return -ENOMEM;
> +
> + client->dev = dev;
> +
> + match = of_device_get_match_data(dev);
> + if (!match)
> + return dev_err_probe(dev, -EINVAL, "No match data\n");
> +
> + client->id = match->id;
> + client->name = match->name;
> +
> + mutex_init(&client->mutex);
> + INIT_LIST_HEAD(&client->cdev_list);
> + INIT_WORK(&client->svc_arrive_work, qmi_tmd_svc_arrive);
> +
> + ret = qmi_tmd_alloc_cdevs(client);
> + if (ret)
> + return ret;
> +
> + platform_set_drvdata(pdev, client);
> +
> + ret = qmi_handle_init(&client->handle,
> + TMD_GET_MITIGATION_DEVICE_LIST_RESP_MSG_V01_MAX_MSG_LEN,
> + &thermal_qmi_event_ops, NULL);
> + if (ret < 0)
> + return dev_err_probe(client->dev, ret, "QMI handle init failed for client %#x\n",
> + client->id);
> +
> + ret = qmi_add_lookup(&client->handle, TMD_SERVICE_ID_V01, TMD_SERVICE_VERS_V01,
> + client->id);
> + if (ret < 0) {
> + qmi_handle_release(&client->handle);
> + return dev_err_probe(client->dev, ret, "QMI register failed for client 0x%x\n",
> + client->id);
> + }
> +
> + return 0;
> +}
> +
> +static void qmi_tmd_client_remove(struct platform_device *pdev)
> +{
> + struct qmi_tmd_client *client = platform_get_drvdata(pdev);
> +
> + qmi_tmd_cleanup(client);
> +}
> +
> +static const struct of_device_id qmi_tmd_device_table[] = {
> + {
> + .compatible = "qcom,qmi-cooling-cdsp",
> + .data = &((struct qmi_instance_data) { CDSP_INSTANCE_ID, "cdsp" }),
Please use Linux coding style.
> + },
> + {}
> +};
> +MODULE_DEVICE_TABLE(of, qmi_tmd_device_table);
> +
> +static struct platform_driver qmi_tmd_device_driver = {
> + .probe = qmi_tmd_client_probe,
> + .remove = qmi_tmd_client_remove,
> + .driver = {
> + .name = "qcom-qmi-cooling",
> + .of_match_table = qmi_tmd_device_table,
> + },
Best regards,
Krzysztof
next prev parent reply other threads:[~2025-12-24 9:01 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-23 12:32 [PATCH v1 0/8] Add RemoteProc cooling support Gaurav Kohli
2025-12-23 12:32 ` [PATCH v1 1/8] thermal: Add Remote Proc cooling driver Gaurav Kohli
2025-12-23 19:23 ` Dmitry Baryshkov
2025-12-24 8:20 ` Gaurav Kohli
2026-01-03 15:05 ` Bjorn Andersson
2026-01-05 5:18 ` Gaurav Kohli
2026-01-08 11:59 ` Zhongqiu Han
2026-01-29 5:40 ` Gaurav Kohli
2026-02-02 10:59 ` Lukasz Luba
2026-02-09 5:28 ` Gaurav Kohli
2026-02-09 10:21 ` Lukasz Luba
2025-12-23 12:32 ` [PATCH v1 2/8] remoteproc: qcom: probe all child devices Gaurav Kohli
2025-12-23 19:26 ` Dmitry Baryshkov
2026-01-03 14:56 ` Bjorn Andersson
2026-01-08 7:07 ` Gaurav Kohli
2026-01-23 13:53 ` Gaurav Kohli
2026-01-23 19:03 ` Dmitry Baryshkov
2026-01-27 16:12 ` Gaurav Kohli
2026-01-27 16:41 ` Dmitry Baryshkov
2026-01-28 9:39 ` Gaurav Kohli
2026-01-28 9:45 ` Konrad Dybcio
2026-01-30 7:03 ` Gaurav Kohli
2026-01-30 9:13 ` Konrad Dybcio
2026-01-31 8:06 ` Dmitry Baryshkov
2026-01-31 10:11 ` Gaurav Kohli
2026-01-31 11:40 ` Dmitry Baryshkov
2026-01-31 11:45 ` Gaurav Kohli
2025-12-23 12:32 ` [PATCH v1 3/8] dt-bindings: thermal: Add qcom,qmi-cooling yaml bindings Gaurav Kohli
2025-12-23 13:59 ` Rob Herring (Arm)
2025-12-24 8:20 ` Gaurav Kohli
2025-12-23 19:30 ` Dmitry Baryshkov
2025-12-24 8:24 ` Gaurav Kohli
2025-12-24 9:31 ` Dmitry Baryshkov
2026-01-03 15:08 ` Bjorn Andersson
2025-12-23 19:52 ` Dmitry Baryshkov
2025-12-24 8:57 ` Krzysztof Kozlowski
2025-12-24 10:08 ` Gaurav Kohli
2025-12-24 10:24 ` Krzysztof Kozlowski
2025-12-31 6:42 ` Gaurav Kohli
2025-12-31 7:35 ` Krzysztof Kozlowski
2025-12-31 7:47 ` Dmitry Baryshkov
2025-12-31 7:52 ` Gaurav Kohli
2025-12-31 7:55 ` Dmitry Baryshkov
2025-12-24 9:02 ` Krzysztof Kozlowski
2025-12-31 11:59 ` Konrad Dybcio
2026-01-08 8:43 ` Gaurav Kohli
2025-12-23 12:32 ` [PATCH v1 4/8] thermal: qcom: add qmi-cooling driver Gaurav Kohli
2025-12-23 19:49 ` Dmitry Baryshkov
2025-12-31 6:28 ` Gaurav Kohli
2025-12-31 6:33 ` Dmitry Baryshkov
2025-12-24 9:01 ` Krzysztof Kozlowski [this message]
2025-12-31 6:32 ` Gaurav Kohli
2025-12-23 12:32 ` [PATCH v1 5/8] arm64: dts: qcom: Enable cdsp qmi tmd devices for lemans Gaurav Kohli
2025-12-23 19:32 ` Dmitry Baryshkov
2025-12-23 12:32 ` [PATCH v1 6/8] arm64: dts: qcom: Enable cdsp qmi tmd devices for talos Gaurav Kohli
2026-01-03 15:13 ` Bjorn Andersson
2025-12-23 12:32 ` [PATCH v1 7/8] arm64: dts: qcom: Enable cdsp qmi tmd devices for kodiak Gaurav Kohli
2026-01-03 15:14 ` Bjorn Andersson
2025-12-23 12:32 ` [PATCH v1 8/8] arm64: dts: qcom: Enable cdsp qmi tmd devices for monaco Gaurav Kohli
2025-12-24 8:58 ` Krzysztof Kozlowski
2025-12-24 10:11 ` Gaurav Kohli
2026-01-10 16:13 ` [PATCH v1 0/8] Add RemoteProc cooling support Casey Connolly
2026-01-13 9:33 ` Gaurav Kohli
2026-02-01 20:20 ` Trilok Soni
2026-02-02 9:53 ` Konrad Dybcio
2026-02-09 10:22 ` Gaurav Kohli
2026-02-09 5:33 ` Gaurav Kohli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7b48c104-5430-455b-be11-ab23387f88ff@kernel.org \
--to=krzk@kernel.org \
--cc=amitk@kernel.org \
--cc=andersson@kernel.org \
--cc=casey.connolly@linaro.org \
--cc=conor+dt@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=gaurav.kohli@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=mani@kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox