From patchwork Mon Nov 25 03:50:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Moldovan X-Patchwork-Id: 845414 Received: from mail.ionic.de (ionic.de [145.239.234.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47C65BE4E; Mon, 25 Nov 2024 04:00:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=145.239.234.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732507225; cv=none; b=mH4c/sg7SgrAavqYUgYbpFxdby8t4m0XbSP+JtV3mT0cL2hjZeNlNQUBGcM4U/uD+KvTco6Xhnmg6obmlxBTEYeh/XzfaO5lUFds4GeQw9kGJIW6nJtfPw86hsZ2bGtyI0M4+liyzAfuAYt6g1c/SEv02QL0BuqxC/JULX9za00= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732507225; c=relaxed/simple; bh=APPsH5pzntsYizn7wbJLWf7AWNXzwzr+IK7xfg0q/Aw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pZbACcPCwrLjJs0jNGMMWj9D02f1HZG0kHUl7MUQgSx2JaytbAUSYB/4+CcYklmwe6GEOdGPME8GFAUgOWFk+j529W9DTKst2s1itvMSMopzfdI05V+qdDSKq/x5vW9MWRec7akONcAn7/eUF6AX6/EYLHidv3b/kyxqKRCRfQM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de; spf=pass smtp.mailfrom=ionic.de; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b=P4jPyIG1; arc=none smtp.client-ip=145.239.234.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionic.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b="P4jPyIG1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ionic.de; s=default; t=1732506707; bh=APPsH5pzntsYizn7wbJLWf7AWNXzwzr+IK7xfg0q/Aw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P4jPyIG17nibxS+0psdv9p6rnm/FodEILE66B3C2IpW8hsORh7Krk/W6pSczoZcER tM8qzynhvX+PCvnMdpwgOI/IIjxS0BCsfGQWxLjm1DoFian4REf03j9h1jfjhXKkt6 VBo0jTYeFE22sddCIY/YrfP5HocrtYjbm2miLyR0= Received: from grml.local.home.ionic.de (unknown [IPv6:2a00:11:fb41:7a00:21b:21ff:fe5e:dddc]) by mail.ionic.de (Postfix) with ESMTPSA id A1E2314873AA; Mon, 25 Nov 2024 04:51:47 +0100 (CET) From: Mihai Moldovan To: ath11k@lists.infradead.org, ath12k@lists.infradead.org, Kalle Valo , Jeff Johnson , Manivannan Sadhasivam Cc: Bjorn Andersson , Konrad Dybcio , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC] [PATCH v2 01/13] net: qrtr: support registering endpoint-specific data Date: Mon, 25 Nov 2024 04:50:16 +0100 Message-ID: <064e351e175e809e9a774022fa2f104b67862d9e.1732506261.git.ionic@ionic.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This adds the infrastructure for registering endpoint-specific data for endpoint IDs. Endpoint-specific data can be used to map an endpoint ID to a specific endpoint backend. Additional API is introduced as a common header in include/net to allow other parts of the kernel to query endpoint IDs for endpoint-specific data or make the QRTR subsystem assign a new endpoint ID for passed endpoint-specific data. This will allow other systems to register endpoint IDs before actual socket creation and usage, which in turn allows proper binding to endpoint IDs from the start. The endpoint registration function is changed to re-use endpoint IDs that match the backend's endpoint-specific data if possible, assign a new endpoint ID if the endpoint-specific data is not known yet, or create a new endpoint ID without endpoint-specific data attached to it if all else fails. There is one gripe with this implementation: other kernel subsystems can, theoretically, assign an unlimited number of new endpoint IDs and thus exhaust endpoint ID space. No API is provided to delete endpoint IDs and we also do not track which endpoint IDs are in use and which are not, which means that even the QRTR-internal code cannot easily clean up unused endpoint IDs. The only exception to this are endpoint IDs attached to QRTR nodes, which will be deleted when the QRTR nodes themselves are deleted. This is probably a potential memory leak that we can live with. Fixing that is rather difficult. We would either have to add some form of refcounting, wrap the endpoint-specific data pointer into yet another structure together with a kref and use that to free unused endpoint IDs, or periodically clean unused endpoint IDs up in a timer (executing, say, every 10 minutes), essentially doing garbage collection. Garbage collection is being frowned upon, especially in the kernel, but in this case, it really would make the most sense. Clients might allocate endpoint IDs that are never actually used (for instance because the client uses a wrong endpoint-specific data pointer, which is not used by a QRTR backend), and will need to hold a reference to this for their entire life time, which essentially defeats the concept of cleanup of unused endpoint IDs via reference counting. Clients can create endpoint IDs quite some time before the QRTR subsystem uses them, but there is no way to easily tell when this will be. The idea is that minutes as orders of magnitude would probably be a safe value for which to regard an endpoint ID as unused. Signed-off-by: Mihai Moldovan Depends-on: 25a7151cdc98 ("net: qrtr: ns: support multiple endpoints") Link: https://patch.msgid.link/20241018181842.1368394-1-denkenz@gmail.com --- MAINTAINERS | 1 + include/net/qrtr.h | 11 ++++ net/qrtr/af_qrtr.c | 124 +++++++++++++++++++++++++++++++++++++++++++-- net/qrtr/qrtr.h | 5 ++ 4 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 include/net/qrtr.h diff --git a/MAINTAINERS b/MAINTAINERS index 96b9344c3524..6993067c4194 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19115,6 +19115,7 @@ QUALCOMM IPC ROUTER (QRTR) DRIVER M: Manivannan Sadhasivam L: linux-arm-msm@vger.kernel.org S: Maintained +F: include/net/qrtr.h F: include/trace/events/qrtr.h F: include/uapi/linux/qrtr.h F: net/qrtr/ diff --git a/include/net/qrtr.h b/include/net/qrtr.h new file mode 100644 index 000000000000..799c84eb35ad --- /dev/null +++ b/include/net/qrtr.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef __NET_QRTR_H +#define __NET_QRTR_H + +#include + +int qrtr_endpoint_id_get(const void *data, u32 *id); +int qrtr_endpoint_id_assign(void *data, u32 *id); +int qrtr_endpoint_id_get_or_assign(void *data, u32 *id); + +#endif /* __NET_QRTR_H */ diff --git a/net/qrtr/af_qrtr.c b/net/qrtr/af_qrtr.c index cf8b5483ba2c..59227b3d49f4 100644 --- a/net/qrtr/af_qrtr.c +++ b/net/qrtr/af_qrtr.c @@ -11,6 +11,7 @@ #include #include +#include #include "qrtr.h" @@ -649,6 +650,114 @@ static struct sk_buff *qrtr_alloc_ctrl_packet(struct qrtr_ctrl_pkt **pkt, return skb; } +/** + * qrtr_endpoint_id_get() - get a registered endpoint for given data + * @data: endpoint-specific data to fetch ID for + * @id: pointer to store endpoint ID into + * Return: 0 on success, negative error code on failure + * + * The endpoint-specific data must not be NULL. + * The output parameter id must not be NULL. + * If no endpoint ID can be mapped to the endpoint-specific data, id will be + * set to 0. + */ +int qrtr_endpoint_id_get(const void *data, u32 *id) +{ + unsigned long idx = 0; + void *iter_data = NULL; + + if (!id) + return -EINVAL; + + if (!data) + return -EINVAL; + + *id = 0; + rcu_read_lock(); + xa_for_each_range(&qrtr_endpoints, idx, iter_data, + QRTR_ENDPOINT_RANGE.min, QRTR_ENDPOINT_RANGE.max) { + if (iter_data == data) { + *id = idx; + break; + } + } + rcu_read_unlock(); + + return 0; +} +EXPORT_SYMBOL_GPL(qrtr_endpoint_id_get); + +/** + * qrtr_endpoint_id_assign() - assigns a new endpoint ID for given data + * @data: endpoint-specific data to assign new ID for + * @id: pointer to store endpoint ID into + * Return: 0 on success, negative error code on failure + * + * The endpoint-specific data must not be NULL. + * The output parameter id must not be NULL. + * On error, id will be set to 0. + */ +int qrtr_endpoint_id_assign(void *data, u32 *id) +{ + int rc = 0; + + if (!id) + return -EINVAL; + + if (!data) + return -EINVAL; + + rc = xa_alloc_cyclic(&qrtr_endpoints, id, data, QRTR_ENDPOINT_RANGE, + &next_endpoint_id, GFP_KERNEL); + if (rc) + *id = 0; + + return rc; +} +EXPORT_SYMBOL_GPL(qrtr_endpoint_id_assign); + +/** + * qrtr_endpoint_id_get_or_assign() - gets or assigns endpoint ID for data + * @data: endpoint-specific data to assign new ID for + * @id: pointer to store endpoint ID into + * Return: positive on success, negative error code on failure + * + * The endpoint-specific data must not be NULL. + * + * If the endpoint-specific data is already registered to an endpoint ID, this + * ID will be assigned to id. Otherwise, this function assigns a new + * endpoint ID and associates it with the given endpoint-specific data. + * + * The output parameter id must not be NULL. It will either be set to the + * fetched or newly assigned endpoint ID on success, or set to 0 on error. + */ +int qrtr_endpoint_id_get_or_assign(void *data, u32 *id) +{ + int rc = 0; + + if (!data) + return -EINVAL; + + if (!id) + return -EINVAL; + + rc = qrtr_endpoint_id_get(data, id); + + if (rc) { + *id = 0; + return rc; + } + + if (!*id) + rc = qrtr_endpoint_id_assign(data, id); + + if (rc) + *id = 0; + + return rc; +} +EXPORT_SYMBOL_GPL(qrtr_endpoint_id_get_or_assign); + /** * qrtr_endpoint_register() - register a new endpoint * @ep: endpoint to register @@ -670,9 +779,18 @@ int qrtr_endpoint_register(struct qrtr_endpoint *ep, unsigned int nid) if (!node) return -ENOMEM; - rc = xa_alloc_cyclic(&qrtr_endpoints, &endpoint_id, NULL, - QRTR_ENDPOINT_RANGE, &next_endpoint_id, - GFP_KERNEL); + rc = qrtr_endpoint_id_get_or_assign(ep->endpoint_data, &endpoint_id); + + /* + * The previous function fails if ep->endpoint_data is NULL, so retry. + * + * We're going to assign an endpoint ID without endpoint-specific data + * set in this case. + */ + if (rc) + rc = xa_alloc_cyclic(&qrtr_endpoints, &endpoint_id, NULL, + QRTR_ENDPOINT_RANGE, &next_endpoint_id, + GFP_KERNEL); if (rc < 0) goto free_node; diff --git a/net/qrtr/qrtr.h b/net/qrtr/qrtr.h index b4f50336ae75..3509168e8a40 100644 --- a/net/qrtr/qrtr.h +++ b/net/qrtr/qrtr.h @@ -12,13 +12,18 @@ struct sk_buff; /** * struct qrtr_endpoint - endpoint handle * @xmit: Callback for outgoing packets + * @endpoint_data: endpoint-specific data pointer, can be NULL * * The socket buffer passed to the xmit function becomes owned by the endpoint * driver. As such, when the driver is done with the buffer, it should * call kfree_skb() on failure, or consume_skb() on success. + * + * If endpoint_data is NULL, endpoint IDs can not be directly mapped to a + * specific endpoint. */ struct qrtr_endpoint { int (*xmit)(struct qrtr_endpoint *ep, struct sk_buff *skb); + void *endpoint_data; /* private: not for endpoint use */ struct qrtr_node *node; u32 id; From patchwork Mon Nov 25 03:50:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Moldovan X-Patchwork-Id: 845413 Received: from mail.ionic.de (ionic.de [145.239.234.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50F8445003; Mon, 25 Nov 2024 04:00:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=145.239.234.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732507225; cv=none; b=Uu0JQn6aIJ5zQ40pnEihVbhlRcXPSogqHmoMLAq8ZATmLeVt+mbQs7Lh0YGxWzMTNmJdW6LKJ96m4IlUqnpeDAty4jFnAiww+bq7Zd525sEXgCajnMxK+bAn8Alxgjb2aNpML0UtDSo0GLWO6CEsxek7bFZKAGmUWQdidqxtISI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732507225; c=relaxed/simple; bh=3yCjE5tdSxEAWWiNtIYYOrdwsDaWqbpFW99BaTLk7HE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e7hPEckKJViq7iyqUyMVPES8AsUGofUNvBaBV642QfuUHy/veceN3m9EOcn2aG/kPxZ9ggupY6leCGyfJJJCXOM06DMcGVDe9GeWLlta9bAOviBIRn+9haPIFwmnzx19J0SP8Y6TnKIdo4n/PmYWF73UKxL7Xtpule2oaksZw/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de; spf=pass smtp.mailfrom=ionic.de; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b=f4lEPPq6; arc=none smtp.client-ip=145.239.234.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionic.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b="f4lEPPq6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ionic.de; s=default; t=1732506708; bh=3yCjE5tdSxEAWWiNtIYYOrdwsDaWqbpFW99BaTLk7HE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4lEPPq6yN01kQf4+fKAw0YTENFTPo/MlDnzIcFrF0d4czSDRBLx96AgcpwMaMMGc gMSQcKXSNZ3Eed7ETl5vXX+GcQZMcRS/wO2L/JONzHyrqwQVUBB9HpzAfmwY6VT6Qh zhACAhvk/LrEBF6BN/quVmICVol2t4OytK1VT/hk= Received: from grml.local.home.ionic.de (unknown [IPv6:2a00:11:fb41:7a00:21b:21ff:fe5e:dddc]) by mail.ionic.de (Postfix) with ESMTPSA id DD3981487FB2; Mon, 25 Nov 2024 04:51:47 +0100 (CET) From: Mihai Moldovan To: ath11k@lists.infradead.org, ath12k@lists.infradead.org, Kalle Valo , Jeff Johnson , Manivannan Sadhasivam Cc: Bjorn Andersson , Konrad Dybcio , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC] [PATCH v2 02/13] net: qrtr: mhi: register mhi_controller as endpoint-specific data Date: Mon, 25 Nov 2024 04:50:17 +0100 Message-ID: <90e0394bfd97d28853d17e9c62b6e372b236b760.1732506261.git.ionic@ionic.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For the MHI backend, we will use the mhi_controller pointer as the endpoint-specific data. This means that we can only have one endpoint ID per MHI controller, but since the MHI controller is the bus master in charge of the physical link, this is probably okay. Signed-off-by: Mihai Moldovan --- net/qrtr/mhi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/qrtr/mhi.c b/net/qrtr/mhi.c index 9a23c888e234..fc6869c3a7ec 100644 --- a/net/qrtr/mhi.c +++ b/net/qrtr/mhi.c @@ -95,6 +95,7 @@ static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev, qdev->mhi_dev = mhi_dev; qdev->dev = &mhi_dev->dev; qdev->ep.xmit = qcom_mhi_qrtr_send; + qdev->ep.endpoint_data = mhi_dev->mhi_cntrl; dev_set_drvdata(&mhi_dev->dev, qdev); rc = qrtr_endpoint_register(&qdev->ep, QRTR_EP_NID_AUTO); From patchwork Mon Nov 25 03:50:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Moldovan X-Patchwork-Id: 845415 Received: from mail.ionic.de (ionic.de [145.239.234.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 222D71E517; Mon, 25 Nov 2024 03:51:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=145.239.234.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732506720; cv=none; b=LufKyER0kaBdgy6wpdCWs4mwB2UnSqupYaLPIBHYxK6j7zIb+Oem3LMOLQWcH+z6KiUC9R647fzUxvla1Nwi3PJsH/5RUSq6jcp/GrFh/gHfrS5+KG0F90ba8etcljIW1PLJYsMe9jcF2JXbgm6PnlNfICeUfpfCCJqoImB7kew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732506720; c=relaxed/simple; bh=mwFNh6fCQilCetdqM9GB1/3XnP01zdiqQkD768arI/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rsQrS1s1mzsbu45lZuUGU1XhTaDqVE7CAFDFuBKSgIyWTmHWDXstydcLcj+z/irCOecoysn46czfozOSDT/VbtcbmVLABT+NRReXYnKn8Fi2LkaCk09WzYkLCgA6rpL2jErENuWhSLR2jKGf99IFO71AbNUYD8/20qx4BQCNClk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de; spf=pass smtp.mailfrom=ionic.de; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b=RmytRxVv; arc=none smtp.client-ip=145.239.234.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionic.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b="RmytRxVv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ionic.de; s=default; t=1732506708; bh=mwFNh6fCQilCetdqM9GB1/3XnP01zdiqQkD768arI/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RmytRxVv1y+Zq5OYaqttZVMLivau0IYhRxwDvVY+ojzSleN2mmJoHmjbxsXymNdoO lVZo9iESVcl4XbItZ/dsRvh08KYDo/4R5l3N0/x+wWh2ORmbHEEb66QNXK+83VpCsV OsgGsH7OXVlNjJDVL7bKj0+w3Z8pTmlXT2Vd0XXk= Received: from grml.local.home.ionic.de (unknown [IPv6:2a00:11:fb41:7a00:21b:21ff:fe5e:dddc]) by mail.ionic.de (Postfix) with ESMTPSA id AFE0E14886FE; Mon, 25 Nov 2024 04:51:48 +0100 (CET) From: Mihai Moldovan To: ath11k@lists.infradead.org, ath12k@lists.infradead.org, Kalle Valo , Jeff Johnson , Manivannan Sadhasivam Cc: Bjorn Andersson , Konrad Dybcio , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC] [PATCH v2 05/13] soc: qcom: qmi_helpers: add QRTR endpoint ID to qmi_handle Date: Mon, 25 Nov 2024 04:50:20 +0100 Message-ID: <68f8f8e04b6076d8f497f101ecae9c78b128f59b.1732506261.git.ionic@ionic.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Adding this allows us to easily supply an endpoint ID to bind on later on when creating the socket. Signed-off-by: Mihai Moldovan --- include/linux/soc/qcom/qmi.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/soc/qcom/qmi.h b/include/linux/soc/qcom/qmi.h index 469e02d2aa0d..77743c855762 100644 --- a/include/linux/soc/qcom/qmi.h +++ b/include/linux/soc/qcom/qmi.h @@ -212,6 +212,7 @@ struct qmi_msg_handler { * @txns: outstanding transactions * @txn_lock: lock for modifications of @txns * @handlers: list of handlers for incoming messages + * @endpoint_id: QRTR endpoint ID to bind on */ struct qmi_handle { struct socket *sock; @@ -235,6 +236,8 @@ struct qmi_handle { struct mutex txn_lock; const struct qmi_msg_handler *handlers; + + u32 endpoint_id; }; int qmi_add_lookup(struct qmi_handle *qmi, unsigned int service, From patchwork Mon Nov 25 03:50:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Moldovan X-Patchwork-Id: 845419 Received: from mail.ionic.de (ionic.de [145.239.234.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22290EAC7; Mon, 25 Nov 2024 03:51:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=145.239.234.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732506719; cv=none; b=fEe3AFAvVSHRRMeibut706tJlI0sivt39n60SU88PEkQXi8C10/fL5OPq1TE3IIPHFGtxJgKjO2D4gcc/0EfsaELG1n10W70xK3keS5D6hF9v04OVg3RAuWhr6/KXPaIPSrROOJGKKRdeqcAWKiHOUBZL9WfVnqjTK6C1qmqWKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732506719; c=relaxed/simple; bh=UyuABPlzyiqkE23T62xlQISSVDBGgpm7/N5AP3n04ZM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jNMaPrXobqe7dKecTup92lF890FZG+iTWKLt9wugKkBXav7Rc26RJUnr4fo5ocxb+U7agUlnpp84F5wdX6KCEF00qR60EfnSO3LCzZ4bh1YEqBolzbgA9gIRca5sVUO9b30ePktBzLs12DC4X2fkYxmf8lBmQChz9bHuxERj4w4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de; spf=pass smtp.mailfrom=ionic.de; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b=fOuCpeqV; arc=none smtp.client-ip=145.239.234.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionic.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b="fOuCpeqV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ionic.de; s=default; t=1732506709; bh=UyuABPlzyiqkE23T62xlQISSVDBGgpm7/N5AP3n04ZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fOuCpeqVtL5FKsBHcNc5N1UebrdiEJ/+F/uQBttmoTfpS2aWt829DskHdXSpCT3F2 HE/XTHZiYaBx4sqRacNewnMz13cYiptrM27eeUfN6BXk3nFa6yqAAboLRwxjI319n5 YuGzb30QQIxQdjZ9+GI+urwnqtgv1ogHNrtmOG5c= Received: from grml.local.home.ionic.de (unknown [IPv6:2a00:11:fb41:7a00:21b:21ff:fe5e:dddc]) by mail.ionic.de (Postfix) with ESMTPSA id F028314886FF; Mon, 25 Nov 2024 04:51:48 +0100 (CET) From: Mihai Moldovan To: ath11k@lists.infradead.org, ath12k@lists.infradead.org, Kalle Valo , Jeff Johnson , Manivannan Sadhasivam Cc: Bjorn Andersson , Konrad Dybcio , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC] [PATCH v2 06/13] soc: qcom: qmi_helpers: optionally bind to QRTR endpoint ID in qmi_sock_create Date: Mon, 25 Nov 2024 04:50:21 +0100 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For clients that already know the QRTR endpoint ID before actually creating the QMI socket and set it in struct qmi_handle, optionally try to bind to this QRTR endpoint ID when creating the socket. This can fail, and qmi_sock_create will issue diagnostic messages, but otherwise ignore the error. Signed-off-by: Mihai Moldovan --- drivers/soc/qcom/qmi_interface.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/soc/qcom/qmi_interface.c b/drivers/soc/qcom/qmi_interface.c index bb98b06e87f8..dd3978682c09 100644 --- a/drivers/soc/qcom/qmi_interface.c +++ b/drivers/soc/qcom/qmi_interface.c @@ -586,6 +586,7 @@ static struct socket *qmi_sock_create(struct qmi_handle *qmi, struct sockaddr_qrtr *sq) { struct socket *sock; + const struct proto_ops *ops = NULL; int ret; ret = sock_create_kern(&init_net, AF_QIPCRTR, SOCK_DGRAM, @@ -593,6 +594,33 @@ static struct socket *qmi_sock_create(struct qmi_handle *qmi, if (ret < 0) return ERR_PTR(ret); + ops = READ_ONCE(sock->ops); + + if (!ops) { + pr_warn("sock->ops not available for QMI socket\n"); + pr_warn("will not be able to bind to endpoint ID.\n"); + /* N.B.: this error value will not be passed out. */ + ret = -ENXIO; + } + + if (!ret && !ops->setsockopt) { + pr_warn("ops->setsockopt not available for QMI socket\n"); + pr_warn("will not be able to bind to endpoint ID.\n"); + /* N.B.: this error value will not be passed out. */ + ret = -ENXIO; + } + + /* Only bind to a specific endpoint if a valid one was provided. */ + if (!ret && qmi->endpoint_id) { + ret = ops->setsockopt(sock, SOL_QRTR, QRTR_BIND_ENDPOINT, + KERNEL_SOCKPTR(&qmi->endpoint_id), + sizeof(qmi->endpoint_id)); + + if (ret < 0) + pr_warn("binding to QRTR endpoint ID failed: %d\n", + ret); + } + ret = kernel_getsockname(sock, (struct sockaddr *)sq); if (ret < 0) { sock_release(sock); From patchwork Mon Nov 25 03:50:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Moldovan X-Patchwork-Id: 845416 Received: from mail.ionic.de (ionic.de [145.239.234.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F8AC1E519; Mon, 25 Nov 2024 03:51:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=145.239.234.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732506719; cv=none; b=eFHq1YHZxpVDRvDjZPEEBDFl+J94gQBDf8hphML5w8lJOFXREh6ek3Z0aBZd/lFMuNot6vicIo3i05ELCWiXDdxISm2BxBO9ue9RHsnorZ38gxbEongy07oUH5kANTantHUniNE6q9kkUjkGhLU0LEtz6SZ9SkvyLdcFGDZSpaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732506719; c=relaxed/simple; bh=HdvvnX3oBwORMiG9uXHBr/WQrekrk+ivf29v/3cUx50=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BMoIadOcB4BjL7YxLxHJt5Q8HYbg6PVO1ju0gA4hlLrAcwqAWWp+v9n8PXjZoHg9HleXVuJV7Eh+octD7hAL2aFTIghb873JaswaZbqPAmL4zGU/510FJKmvoQwkq05CM4oV0gXGyOTKv7rYkMu+QqpHo8rZ5BGAhZcys7IwDPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de; spf=pass smtp.mailfrom=ionic.de; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b=aIAVrJjG; arc=none smtp.client-ip=145.239.234.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionic.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b="aIAVrJjG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ionic.de; s=default; t=1732506709; bh=HdvvnX3oBwORMiG9uXHBr/WQrekrk+ivf29v/3cUx50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aIAVrJjGD8zUzNnhL67os6yVqTq+SDbezurYDgZOJ4/jl0mszLwnop60k83ZVOyM1 QFCKKkEaXMGVmYz/GIJBsY6ehvFjDjBJdVokc7BqQPrGWEvVzi8KPy7McOPpv1d3vI RnsLC/UK959s2w9nNIi6GltV8Lpoj6tPFuLAhqEA= Received: from grml.local.home.ionic.de (unknown [IPv6:2a00:11:fb41:7a00:21b:21ff:fe5e:dddc]) by mail.ionic.de (Postfix) with ESMTPSA id 7798F148870D; Mon, 25 Nov 2024 04:51:49 +0100 (CET) From: Mihai Moldovan To: ath11k@lists.infradead.org, ath12k@lists.infradead.org, Kalle Valo , Jeff Johnson , Manivannan Sadhasivam Cc: Bjorn Andersson , Konrad Dybcio , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC] [PATCH v2 08/13] wifi: ath11k: stub QRTR endpoint ID fetching for AHB Date: Mon, 25 Nov 2024 04:50:23 +0100 Message-ID: <1213282db93cb9aa126440bf46212f47dd015e69.1732506261.git.ionic@ionic.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 QRTR endpoint ID fetching will currently not be available for AHB. Signed-off-by: Mihai Moldovan --- drivers/net/wireless/ath/ath11k/ahb.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/ath/ath11k/ahb.c index f2fc04596d48..acb12d6d647f 100644 --- a/drivers/net/wireless/ath/ath11k/ahb.c +++ b/drivers/net/wireless/ath/ath11k/ahb.c @@ -773,6 +773,7 @@ static const struct ath11k_hif_ops ath11k_ahb_hif_ops_ipq8074 = { .map_service_to_pipe = ath11k_ahb_map_service_to_pipe, .power_down = ath11k_ahb_power_down, .power_up = ath11k_ahb_power_up, + .set_qrtr_endpoint_id = ath11k_ahb_set_qrtr_endpoint_id, }; static const struct ath11k_hif_ops ath11k_ahb_hif_ops_wcn6750 = { @@ -792,6 +793,7 @@ static const struct ath11k_hif_ops ath11k_ahb_hif_ops_wcn6750 = { .resume = ath11k_ahb_hif_resume, .ce_irq_enable = ath11k_pci_enable_ce_irqs_except_wake_irq, .ce_irq_disable = ath11k_pci_disable_ce_irqs_except_wake_irq, + .set_qrtr_endpoint_id = ath11k_ahb_set_qrtr_endpoint_id, }; static int ath11k_core_get_rproc(struct ath11k_base *ab) @@ -1312,6 +1314,11 @@ static void ath11k_ahb_shutdown(struct platform_device *pdev) ath11k_ahb_free_resources(ab); } +static ath11k_ahb_set_qrtr_endpoint_id(struct ath11k_base *ab) +{ + return -EOPNOTSUPP; +} + static struct platform_driver ath11k_ahb_driver = { .driver = { .name = "ath11k", From patchwork Mon Nov 25 03:50:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Moldovan X-Patchwork-Id: 845418 Received: from mail.ionic.de (ionic.de [145.239.234.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F9A82D052; Mon, 25 Nov 2024 03:51:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=145.239.234.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732506719; cv=none; b=jeFQe4RvGf2DMRbg3NqPgD9n+BkYyxHeUyqIAy/Sf1z07vpwWQmnwhNp7QW+KHBz0mUsa1gbu5ehMTBZzsDMKhlrXb6q9EUflZQsfj2AJDPBrJEsbnzbsZSmz/JcL5AJwfZqfyyCTFOZhRbcK+j71r5C/od4oIqS6ixPRLQESk4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732506719; c=relaxed/simple; bh=DN2g4ZHT+mEUQwKRS2uJbaQDq8nZOw1i3/GADcXe3KM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SaviGpFyThqtmUMyHRVGP0ZFeEz+A9oiO0X+mjnGKm9FTkDbQ1vfkde2QFKZlYTgvkDuZ0678jy50J9VT8uBotwJKC8p12Mu/S8A+N2KdoqiDFVolGDGCvIyAs62yX0BFNc1YvDj+LBxC4C7aHvaIkub9nzrPGG9EmvXE8B4xeI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de; spf=pass smtp.mailfrom=ionic.de; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b=BlTEBWpV; arc=none smtp.client-ip=145.239.234.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionic.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b="BlTEBWpV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ionic.de; s=default; t=1732506710; bh=DN2g4ZHT+mEUQwKRS2uJbaQDq8nZOw1i3/GADcXe3KM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BlTEBWpV4kuIL+1fMS8p847xYpPDDP4R3d1iOBDTal1JvmToNZtH7NbWJINDDq472 /jphI5Y8QjAQ1tRdZ4gLZaVUIwQaJyG2sHl1hVPBeo6ypaM5WIzBUQXpUK+irLJabo 9BtTcRaVl4cXi42EefwlprBxMAyaourlzLefysfk= Received: from grml.local.home.ionic.de (unknown [IPv6:2a00:11:fb41:7a00:21b:21ff:fe5e:dddc]) by mail.ionic.de (Postfix) with ESMTPSA id 028AB1488710; Mon, 25 Nov 2024 04:51:50 +0100 (CET) From: Mihai Moldovan To: ath11k@lists.infradead.org, ath12k@lists.infradead.org, Kalle Valo , Jeff Johnson , Manivannan Sadhasivam Cc: Bjorn Andersson , Konrad Dybcio , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC] [PATCH v2 10/13] wifi: ath11k: bind to QRTR endpoint ID in ath11k_qmi_init_service Date: Mon, 25 Nov 2024 04:50:25 +0100 Message-ID: <8768f055a92edb14d5f7bab8e497f437f06272b9.1732506261.git.ionic@ionic.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If possible, fetch the QRTR endpoint ID in ath11k_qmi_init_service, just before calling qmi_handle_init, and make it available in the qmi_handle. qmi_helpers will then automatically bind to this endpoint for us. This finally allows using multiple ath11k-based cards with the same QRTR node/port combination to work simultanenous (and, for that matter, at all). Signed-off-by: Mihai Moldovan Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-05266-QCAHSTSWPLZ_V2_TO_X86-1 --- drivers/net/wireless/ath/ath11k/qmi.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c index 5759fc521316..604d7211b980 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.c +++ b/drivers/net/wireless/ath/ath11k/qmi.c @@ -15,6 +15,7 @@ #include #include #include +#include #define SLEEP_CLOCK_SELECT_INTERNAL_BIT 0x02 #define HOST_CSTATE_BIT 0x04 @@ -3315,6 +3316,13 @@ int ath11k_qmi_init_service(struct ath11k_base *ab) ab->qmi.ab = ab; ab->qmi.target_mem_mode = ab->hw_params.fw_mem_mode; + + ret = ath11k_set_qrtr_endpoint_id(ab); + if (ret) { + ath11k_warn(ab, "failed to set QRTR endpoint ID: %d\n", ret); + ath11k_warn(ab, "only one device per system will be supported\n"); + } + ret = qmi_handle_init(&ab->qmi.handle, ATH11K_QMI_RESP_LEN_MAX, &ath11k_qmi_ops, ath11k_qmi_msg_handlers); if (ret < 0) { From patchwork Mon Nov 25 03:50:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Moldovan X-Patchwork-Id: 845417 Received: from mail.ionic.de (ionic.de [145.239.234.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8122E38382; Mon, 25 Nov 2024 03:51:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=145.239.234.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732506719; cv=none; b=T5ClZnqPYCeAVvX69T6j+N6o92fxghA7u9t8shuyaWr+v8bjOqww3lreqd7n3UqFdwXYr4d00X19/YZIT+5NrbkKH0cZpgms1+FdYQlhfbZCsm6GxNarWSKDTId2AVrVtMZnoNtbCb4+Chs2SJRRqZr4eFMQd3cm1I2IaTIzGUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732506719; c=relaxed/simple; bh=uKVKRmRDkN/eSoUbniCNPAitj2cpMMyzr4m9wHpkjkM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fppbDxsy9f0dGZdfZXzzQz59GFwFjd5neTTULauKL1pkGxs4uBQAMUYHl8+BQy/LoWFuR46xEb1K4CREEclRhr7fFe76fm6ddsu2e28oV/EPw8VNmLOPwY0VluzQGXsvIajDBol+CzRXAM6L3605v2HHbD3x8Rkf9GYMgaDxyVo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de; spf=pass smtp.mailfrom=ionic.de; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b=AqEXqkJH; arc=none smtp.client-ip=145.239.234.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ionic.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionic.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ionic.de header.i=@ionic.de header.b="AqEXqkJH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ionic.de; s=default; t=1732506710; bh=uKVKRmRDkN/eSoUbniCNPAitj2cpMMyzr4m9wHpkjkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AqEXqkJHG/9LQ53Vq3mgTjeMfkWYogi1qAhApXi/U20Ul2/8jiXZyPjyLRHyQNXwy XeGMlirfy/6uT5ceN+LP9gCQQ9YIgIMfOJImBdcoLbQjk0jTLcfOkOgLhuH+5mv/gL uWwoH3qUyxMnD5vAxjl2hj+kpvRF1VgBeNvReHGA= Received: from grml.local.home.ionic.de (unknown [IPv6:2a00:11:fb41:7a00:21b:21ff:fe5e:dddc]) by mail.ionic.de (Postfix) with ESMTPSA id C02871488DDC; Mon, 25 Nov 2024 04:51:50 +0100 (CET) From: Mihai Moldovan To: ath11k@lists.infradead.org, ath12k@lists.infradead.org, Kalle Valo , Jeff Johnson , Manivannan Sadhasivam Cc: Bjorn Andersson , Konrad Dybcio , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC] [PATCH v2 13/13] wifi: ath12k: bind to QRTR endpoint ID in ath12k_qmi_init_service Date: Mon, 25 Nov 2024 04:50:28 +0100 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If possible, fetch the QRTR endpoint ID in ath12k_qmi_init_service, just before calling qmi_handle_init, and make it available in the qmi_handle. qmi_helpers will then automatically bind to this endpoint for us. This finally allows using multiple ath12k-based cards with the same QRTR node/port combination to work simultanenous (and, for that matter, at all), including combinations of ath11k-based and ath12k-based cards. Signed-off-by: Mihai Moldovan Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 --- drivers/net/wireless/ath/ath12k/qmi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/wireless/ath/ath12k/qmi.c b/drivers/net/wireless/ath/ath12k/qmi.c index d2d9d03c7a28..a96bad490b10 100644 --- a/drivers/net/wireless/ath/ath12k/qmi.c +++ b/drivers/net/wireless/ath/ath12k/qmi.c @@ -9,8 +9,10 @@ #include "qmi.h" #include "core.h" #include "debug.h" +#include "hif.h" #include #include +#include #define SLEEP_CLOCK_SELECT_INTERNAL_BIT 0x02 #define HOST_CSTATE_BIT 0x04 @@ -3371,6 +3373,13 @@ int ath12k_qmi_init_service(struct ath12k_base *ab) ab->qmi.ab = ab; ab->qmi.target_mem_mode = ATH12K_QMI_TARGET_MEM_MODE_DEFAULT; + + ret = ath12k_hif_set_qrtr_endpoint_id(ab); + if (ret) { + ath12k_warn(ab, "failed to set QRTR endpoint ID: %d\n", ret); + ath12k_warn(ab, "only one device per system will be supported\n"); + } + ret = qmi_handle_init(&ab->qmi.handle, ATH12K_QMI_RESP_LEN_MAX, &ath12k_qmi_ops, ath12k_qmi_msg_handlers); if (ret < 0) {