soc: qcom: Introduce Protection Domain Restart helpers
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/3 soc: qcom: Introduce Protection Domain Restart helpers
Qualcomm SoCs (starting with MSM8998) allow for multiple protection domains to run on the same Q6 sub-system. This allows for services like ATH10K WLAN FW to have their own separate address space and crash/recover without disrupting the modem and other PDs running on the same sub-system. The PDR helpers introduces an abstraction that allows for tracking/controlling the life cycle of protection domains running on various Q6 sub-systems.
--- drivers/soc/qcom/Kconfig | 5 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/pdr_interface.c | 685 +++++++++++++++++++++++++++++++ drivers/soc/qcom/pdr_internal.h | 375 +++++++++++++++++ include/linux/soc/qcom/pdr.h | 102 +++++ include/linux/soc/qcom/qmi.h | 1 + 6 files changed, 1169 insertions(+) create mode 100644 drivers/soc/qcom/pdr_interface.c create mode 100644 drivers/soc/qcom/pdr_internal.h create mode 100644 include/linux/soc/qcom/pdr.h
drivers/soc/qcom/Kconfig +5 -0
@@ -76,6 +76,11 @@ config QCOM_OCMEM requirements. This is typically used by the GPU, camera/video, and audio components on some Snapdragon SoCs. +config QCOM_PDR_HELPERS + tristate + depends on ARCH_QCOM || COMPILE_TEST + select QCOM_QMI_HELPERS + config QCOM_PM bool "Qualcomm Power Management" depends on ARCH_QCOM && !ARM64
drivers/soc/qcom/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_QCOM_GLINK_SSR) += glink_ssr.o obj-$(CONFIG_QCOM_GSBI) += qcom_gsbi.o obj-$(CONFIG_QCOM_MDT_LOADER) += mdt_loader.o obj-$(CONFIG_QCOM_OCMEM) += ocmem.o +obj-$(CONFIG_QCOM_PDR_HELPERS) += pdr_interface.o obj-$(CONFIG_QCOM_PM) += spm.o obj-$(CONFIG_QCOM_QMI_HELPERS) += qmi_helpers.o qmi_helpers-y += qmi_encdec.o qmi_interface.o
drivers/soc/qcom/pdr_interface.c new file +685 -0
685 lines not on this page · raw message
drivers/soc/qcom/pdr_internal.h new file +375 -0
375 lines not on this page · raw message
include/linux/soc/qcom/pdr.h new file +102 -0
102 lines not on this page · raw message
include/linux/soc/qcom/qmi.h +1 -0
@@ -88,6 +88,7 @@ struct qmi_elem_info {#define QMI_ERR_CLIENT_IDS_EXHAUSTED_V01 5#define QMI_ERR_INVALID_ID_V01 41#define QMI_ERR_ENCODING_V01 58 +#define QMI_ERR_DISABLED_V01 69#define QMI_ERR_INCOMPATIBLE_STATE_V01 90#define QMI_ERR_NOT_SUPPORTED_V01 94
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 1/3 soc: qcom: Introduce Protection Domain Restart helpers
In reply to a message not in the archiveQualcomm SoCs (starting with MSM8998) allow for multiple protection domains to run on the same Q6 sub-system. This allows for services like ATH10K WLAN FW to have their own separate address space and crash/recover without disrupting the modem and other PDs running on the same sub-system. The PDR helpers introduces an abstraction that allows for tracking/controlling the life cycle of protection domains running on various Q6 sub-systems.
--- drivers/soc/qcom/Kconfig | 5 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/pdr_interface.c | 685 +++++++++++++++++++++++++++++++ drivers/soc/qcom/pdr_internal.h | 375 +++++++++++++++++ include/linux/soc/qcom/pdr.h | 102 +++++ include/linux/soc/qcom/qmi.h | 1 + 6 files changed, 1169 insertions(+) create mode 100644 drivers/soc/qcom/pdr_interface.c create mode 100644 drivers/soc/qcom/pdr_internal.h create mode 100644 include/linux/soc/qcom/pdr.h
drivers/soc/qcom/Kconfig +5 -0
@@ -76,6 +76,11 @@ config QCOM_OCMEM requirements. This is typically used by the GPU, camera/video, and audio components on some Snapdragon SoCs. +config QCOM_PDR_HELPERS + tristate + depends on ARCH_QCOM || COMPILE_TEST + select QCOM_QMI_HELPERS + config QCOM_PM bool "Qualcomm Power Management" depends on ARCH_QCOM && !ARM64
drivers/soc/qcom/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_QCOM_GLINK_SSR) += glink_ssr.o obj-$(CONFIG_QCOM_GSBI) += qcom_gsbi.o obj-$(CONFIG_QCOM_MDT_LOADER) += mdt_loader.o obj-$(CONFIG_QCOM_OCMEM) += ocmem.o +obj-$(CONFIG_QCOM_PDR_HELPERS) += pdr_interface.o obj-$(CONFIG_QCOM_PM) += spm.o obj-$(CONFIG_QCOM_QMI_HELPERS) += qmi_helpers.o qmi_helpers-y += qmi_encdec.o qmi_interface.o
drivers/soc/qcom/pdr_interface.c new file +685 -0
685 lines not on this page · raw message
drivers/soc/qcom/pdr_internal.h new file +375 -0
375 lines not on this page · raw message
include/linux/soc/qcom/pdr.h new file +102 -0
102 lines not on this page · raw message
include/linux/soc/qcom/qmi.h +1 -0
@@ -88,6 +88,7 @@ struct qmi_elem_info {#define QMI_ERR_CLIENT_IDS_EXHAUSTED_V01 5#define QMI_ERR_INVALID_ID_V01 41#define QMI_ERR_ENCODING_V01 58 +#define QMI_ERR_DISABLED_V01 69#define QMI_ERR_INCOMPATIBLE_STATE_V01 90#define QMI_ERR_NOT_SUPPORTED_V01 94
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 1 line · Sibi Sankar
drivers/soc/qcom/pdr_interface.c +0
-0
[..]
drivers/soc/qcom/pdr_interface.c line 251
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +10
-0+static void pdr_indack_work (struct work_struct *work) +{ + struct pdr_handle *pdr = container_of(work, struct pdr_handle, + indack_work); +struct pdr_list_node *ind, *tmp; +struct pdr_service *pds; + +list_for_each_entry_safe (ind, tmp, &pdr->indack_list, node) { + pds = ind->pds; +pdr_send_indack_msg (pdr, pds, ind->transaction_id);
So when we et a ind_cb with the new status, we need to send an ack request, which will result in a response, just to confirm that we got the event?
Seems like we should fix the qmi code to make it possible to send a request from the indication handler and then we could simply ignore the response. Or do we need to not pdr->status() until we get the response for some reason?
Regardless, I'm fine with scheduling this for now...
Quoted 86 lines
drivers/soc/qcom/pdr_interface.c +86
-0+ pdr->status (pdr, pds); +list_del (&ind->node); +kfree (ind); + } +} + +static void pdr_servreg_ind_cb (struct qmi_handle *qmi, +struct sockaddr_qrtr *sq, +struct qmi_txn *txn,const void *data) +{ + struct pdr_handle *pdr = container_of(qmi, struct pdr_handle, + servreg_client); +const struct servreg_state_updated_ind *ind_msg = data; +struct pdr_list_node *ind; +struct pdr_service *pds; + +if (!ind_msg || !ind_msg->service_path || +strlen (ind_msg->service_path) > (SERVREG_NAME_LENGTH +1 )) +return ; + +list_for_each_entry (pds, &pdr->lookups, node) { +if (!strcmp (pds->service_path, ind_msg->service_path)) + goto found; + } +return ; + +found: + pds->state = ind_msg->curr_state; + + ind =kzalloc (sizeof (*ind),GFP_KERNEL ); +if (!ind) +return ; + +pr_info ("PDR: Indication received from %s, state: 0x%x, trans-id: %d\n" , + ind_msg->service_path, ind_msg->curr_state, + ind_msg->transaction_id); + + ind->transaction_id = ind_msg->transaction_id; + ind->pds = pds; + +mutex_lock (&pdr->list_lock); +list_add_tail (&ind->node, &pdr->indack_list); +mutex_unlock (&pdr->list_lock); + +queue_work (pdr->indack_wq, &pdr->indack_work); +} + +static struct qmi_msg_handler qmi_indication_handler[] = { + { + .type =QMI_INDICATION , + .msg_id =SERVREG_STATE_UPDATED_IND_ID , + .ei = servreg_state_updated_ind_ei, + .decoded_size =sizeof (struct servreg_state_updated_ind ), + .fn = pdr_servreg_ind_cb, + }, + {} +}; + +static int pdr_get_domain_list (struct servreg_get_domain_list_req *req, +struct servreg_get_domain_list_resp *resp, +struct pdr_handle *pdr) +{ +struct qmi_txn txn; +int ret; + + ret =qmi_txn_init (&pdr->servloc_client, &txn, + servreg_get_domain_list_resp_ei, resp); +if (ret <0 ) +return ret; + + ret =qmi_send_request (&pdr->servloc_client, + &pdr->servloc_addr, + &txn,SERVREG_GET_DOMAIN_LIST_REQ , +SERVREG_GET_DOMAIN_LIST_REQ_MAX_LEN , + servreg_get_domain_list_req_ei, + req); +if (ret <0 ) { +qmi_txn_cancel (&txn); +return ret; + } + + ret =qmi_txn_wait (&txn,5 *HZ ); +if (ret <0 ) { +pr_err ("PDR: %s get domain list txn wait failed: %d\n" , + req->service_name, ret); +return ret;
drivers/soc/qcom/pdr_interface.c line 347
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +10
-0+ } + +/* Check the response */ +if (resp->resp.result !=QMI_RESULT_SUCCESS_V01 ) { +pr_err ("PDR: %s get domain list failed: 0x%x\n" , + req->service_name, resp->resp.error); +return -EREMOTEIO ; + } + +return ret;
ret here will be the number of bytes decoded, but you really only care about if this was an error or not. So I would suggest that you just return 0 here.
Quoted 27 lines
drivers/soc/qcom/pdr_interface.c +27
-0+} + +static int pdr_locate_service (struct pdr_handle *pdr,struct pdr_service *pds) +{ +struct servreg_get_domain_list_resp *resp =NULL ; +struct servreg_get_domain_list_req req; +int db_rev_count =0 , domains_read =0 ; +struct servreg_location_entry *entry; +int ret, i; + + resp =kzalloc (sizeof (*resp),GFP_KERNEL ); +if (!resp) +return -ENOMEM ; + +/* Prepare req message */ +strcpy (req.service_name, pds->service_name); + req.domain_offset_valid = true; + req.domain_offset =0 ; + + do { + req.domain_offset = domains_read; + ret = pdr_get_domain_list(&req, resp, pdr); + if (ret < 0) + goto out; + + if (!domains_read) + db_rev_count = resp->db_rev_count;
drivers/soc/qcom/pdr_interface.c line 384
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +10
-0+ +if (db_rev_count != resp->db_rev_count) { + ret = -EAGAIN ; + goto out; + } + +for (i = domains_read; i < resp->domain_list_len; i++) { + entry = &resp->domain_list[i]; + +if (strlen (entry->name) > (SERVREG_NAME_LENGTH +1 ))
In the event that the incoming string isn't NUL-terminated this will run off the array.
if (strnlen(entry->name, SERVREG_NAME_LENGTH + 1) == SERVREG_NAME_LENGTH + 1)
or perhaps, relying on sizeof instead of duplicating the knowledge that it is SERVREG_NAME_LENGTH + 1:
if (strnlen(entry->name, sizeof(entry->name)) == sizeof(entry->name))
Quoted 5 lines
drivers/soc/qcom/pdr_interface.c +5
-0+continue ; + +if (!strcmp (entry->name, pds->service_path)) { + pds->service_data_valid = entry->service_data_valid; + pds->service_data = entry->service_data;
drivers/soc/qcom/pdr_interface.c line 399
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +10
-0+ pds->instance = entry->instance; + goto out; + } + } + +/* Update ret to indicate that the service is not yet found */ + ret = -EINVAL ; + +/* Always read total_domains from the response msg */ +if (resp->domain_list_len > resp->total_domains)
Double space after '>'
Quoted 12 lines
drivers/soc/qcom/pdr_interface.c +12
-0+ resp->domain_list_len = resp->total_domains; + + domains_read += resp->domain_list_len; + }while (domains_read < resp->total_domains); +out: +kfree (resp); +return ret; +} + +static void pdr_servloc_work (struct work_struct *work) +{ + struct pdr_handle *pdr = container_of(work, struct pdr_handle,
drivers/soc/qcom/pdr_interface.c line 421
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +10
-0+ servloc_work); +struct pdr_list_node *servloc, *tmp; +struct pdr_service *pds; +int ret; + +list_for_each_entry_safe (servloc, tmp, &pdr->servloc_list, node) { + pds = servloc->pds; + +/* wait for PD Mapper to come up */ + ret =wait_for_completion_timeout (&pdr->locator_available,10 *HZ );
Afaict this means that we will only look for the locator during the 10 seconds that follows a pdr_add_lookup().
How about changing this so that you bail before the loop if the locator hasn't showed up yet and schedule this worker when the locator is registered?
Quoted 28 lines
drivers/soc/qcom/pdr_interface.c +28
-0+if (!ret) { +pr_err ("PDR: SERVICE LOCATOR service wait failed\n" ); + ret = -ETIMEDOUT ; + goto err; + } + + ret =pdr_locate_service (pdr, pds); +if (ret <0 ) { +pr_err ("PDR: service lookup for %s failed: %d\n" , + pds->service_name, ret); + goto err; + } + +qmi_add_lookup (&pdr->servreg_client, pds->service,1 , + pds->instance); +err: +list_del (&servloc->node); +kfree (servloc); + +/* cleanup pds on error */ +if (ret <0 ) { + pds->state =SERVREG_LOCATOR_ERR ; + pdr->status (pdr, pds); +list_del (&pds->node); +kfree (pds); + } + } +}
[..]
drivers/soc/qcom/pdr_interface.c line 469
Quoted 9 lines
drivers/soc/qcom/pdr_interface.c +9
-0+int pdr_add_lookup (struct pdr_handle *pdr,const char *service_name, +const char *service_path) +{ +struct pdr_service *pds, *pds_iter, *tmp; +struct pdr_list_node *servloc; +int ret; + +if (!service_name ||strlen (service_name) > (SERVREG_NAME_LENGTH +1 ) || + !service_path ||strlen (service_path) > (SERVREG_NAME_LENGTH +1 ))
When strlen(x) == SERVREG_NAME_LENGTH + 1 your strcpy below would write SERVREG_NAME_LENGTH + 2 bytes to service_name and service_path, so drop the + 1 from the comparisons.
Quoted 15 lines
drivers/soc/qcom/pdr_interface.c +15
-0+return -EINVAL ; + + servloc =kzalloc (sizeof (*servloc),GFP_KERNEL ); +if (!servloc) +return -ENOMEM ; + + pds =kzalloc (sizeof (*pds),GFP_KERNEL ); +if (!pds) { + ret = -ENOMEM ; + goto err; + } + + pds->service =SERVREG_NOTIFIER_SERVICE ; +strcpy (pds->service_name, service_name); +strcpy (pds->service_path, service_path);
[..]
drivers/soc/qcom/pdr_interface.c line 528
Quoted 9 lines
drivers/soc/qcom/pdr_interface.c +9
-0+int pdr_restart_pd (struct pdr_handle *pdr,const char *service_path) +{ +struct servreg_restart_pd_req req; +struct servreg_restart_pd_resp resp; +struct pdr_service *pds =NULL , *pds_iter, *tmp; +struct qmi_txn txn; +int ret; + +if (!service_path ||strlen (service_path) > (SERVREG_NAME_LENGTH +1 ))
As above, drop the + 1
Quoted 2 lines
drivers/soc/qcom/pdr_interface.c +2
-0+return -EINVAL ; +
[..]
Quoted 4 lines
drivers/soc/qcom/pdr_interface.c +4
-0+int pdr_handle_init (struct pdr_handle *pdr, +int (*status)(struct pdr_handle *pdr, +struct pdr_service *pds)) +{
[..]
drivers/soc/qcom/pdr_interface.c line 626
Quoted 5 lines
drivers/soc/qcom/pdr_interface.c +5
-0+ pdr->servreg_wq =create_singlethread_workqueue ("pdr_servreg_wq" ); +if (!pdr->servreg_wq) +return -ENOMEM ; + + pdr->indack_wq =alloc_ordered_workqueue ("pdr_indack_wq" ,WQ_HIGHPRI );
The two workqueues means that we should be able to call pdr->status() rom two concurrent contexts, I don't think our clients will expect that.
drivers/soc/qcom/pdr_interface.c line 631
Quoted 5 lines
drivers/soc/qcom/pdr_interface.c +5
-0+if (!pdr->indack_wq) { + ret = -ENOMEM ; + goto destroy_servreg; + } +
Regards,
Bjorn
Hey Bjorn,
Thanks for taking the time to review the series :)
Quoted 18 lines · Bjorn Andersson
Quoted 1 line · Sibi Sankar
drivers/soc/qcom/pdr_interface.c +0
-0[..]
drivers/soc/qcom/pdr_interface.c line 251
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +10
-0+static void pdr_indack_work (struct work_struct *work) +{ + struct pdr_handle *pdr = container_of(work, struct pdr_handle, + indack_work); +struct pdr_list_node *ind, *tmp; +struct pdr_service *pds; + +list_for_each_entry_safe (ind, tmp, &pdr->indack_list, node) { + pds = ind->pds; +pdr_send_indack_msg (pdr, pds, ind->transaction_id);So when we et a
ind_cbwith the new status, we need to send an ack request, which will result in a response, just to confirm that we got the event?
Quoted 2 lines
Seems like we should fix the qmi code to make it possible to send a request from the indication handler and then we could simply ignore the
yeah maybe having a provision to send custom requests back on indication would be the way
to go. Not all indication need to be services with requests.
Quoted 2 lines
response. Or do we need to not
pdr->status()until we get the response for some reason?
adsp waits on the ack response for a fixed duration and seems to throw a fatal err is the ack is not serviced. Hence holding back pd->status till we service the ack here.
Quoted 98 lines
Regardless, I'm fine with scheduling this for now...
Quoted 94 lines
drivers/soc/qcom/pdr_interface.c +34
-0+ pdr->status (pdr, pds); +list_del (&ind->node); +kfree (ind); + } +} + +static void pdr_servreg_ind_cb (struct qmi_handle *qmi, +struct sockaddr_qrtr *sq, +struct qmi_txn *txn,const void *data) +{ + struct pdr_handle *pdr = container_of(qmi, struct pdr_handle, + servreg_client); +const struct servreg_state_updated_ind *ind_msg = data; +struct pdr_list_node *ind; +struct pdr_service *pds; + +if (!ind_msg || !ind_msg->service_path || +strlen (ind_msg->service_path) > (SERVREG_NAME_LENGTH +1 )) +return ; + +list_for_each_entry (pds, &pdr->lookups, node) { +if (!strcmp (pds->service_path, ind_msg->service_path)) + goto found; + } +return ; + +found: + pds->state = ind_msg->curr_state; + + ind =kzalloc (sizeof (*ind),GFP_KERNEL ); +if (!ind) +return ; + + pr_info("PDR: Indication received from %s, state: 0x%x, trans-id:%d\n",
drivers/soc/qcom/pdr_interface.c +25
-0+ ind_msg->service_path, ind_msg->curr_state, + ind_msg->transaction_id); + + ind->transaction_id = ind_msg->transaction_id; + ind->pds = pds; + +mutex_lock (&pdr->list_lock); +list_add_tail (&ind->node, &pdr->indack_list); +mutex_unlock (&pdr->list_lock); + +queue_work (pdr->indack_wq, &pdr->indack_work); +} + +static struct qmi_msg_handler qmi_indication_handler[] = { + { + .type =QMI_INDICATION , + .msg_id =SERVREG_STATE_UPDATED_IND_ID , + .ei = servreg_state_updated_ind_ei, + .decoded_size =sizeof (struct servreg_state_updated_ind ), + .fn = pdr_servreg_ind_cb, + }, + {} +}; + +static int pdr_get_domain_list(struct servreg_get_domain_list_req*req,
drivers/soc/qcom/pdr_interface.c +33
-0+struct servreg_get_domain_list_resp *resp, + struct pdr_handle *pdr) +{ + struct qmi_txn txn; +int ret; + + ret =qmi_txn_init (&pdr->servloc_client, &txn, + servreg_get_domain_list_resp_ei, resp); +if (ret <0 ) +return ret; + + ret =qmi_send_request (&pdr->servloc_client, + &pdr->servloc_addr, + &txn,SERVREG_GET_DOMAIN_LIST_REQ , +SERVREG_GET_DOMAIN_LIST_REQ_MAX_LEN , + servreg_get_domain_list_req_ei, + req); +if (ret <0 ) { +qmi_txn_cancel (&txn); +return ret; + } + + ret =qmi_txn_wait (&txn,5 *HZ ); +if (ret <0 ) { +pr_err ("PDR: %s get domain list txn wait failed: %d\n" , + req->service_name, ret); +return ret; + } + +/* Check the response */ +if (resp->resp.result !=QMI_RESULT_SUCCESS_V01 ) { +pr_err ("PDR: %s get domain list failed: 0x%x\n" , + req->service_name, resp->resp.error);
Quoted 8 lines
drivers/soc/qcom/pdr_interface.c line 347
Quoted 4 lines
drivers/soc/qcom/pdr_interface.c +4
-0+return -EREMOTEIO ; + } + +return ret;ret here will be the number of bytes decoded, but you really only care about if this was an error or not. So I would suggest that you just return 0 here.
yeah will return 0
Quoted 43 lines
Quoted 29 lines
drivers/soc/qcom/pdr_interface.c +3
-0+} + +static int pdr_locate_service(struct pdr_handle *pdr, struct
pdr_service*pds)drivers/soc/qcom/pdr_interface.c +24
-0+{ +struct servreg_get_domain_list_resp *resp =NULL ; +struct servreg_get_domain_list_req req; +int db_rev_count =0 , domains_read =0 ; +struct servreg_location_entry *entry; +int ret, i; + + resp =kzalloc (sizeof (*resp),GFP_KERNEL ); +if (!resp) +return -ENOMEM ; + +/* Prepare req message */ +strcpy (req.service_name, pds->service_name); + req.domain_offset_valid = true; + req.domain_offset =0 ; + + do { + req.domain_offset = domains_read; + ret = pdr_get_domain_list(&req, resp, pdr); + if (ret < 0) + goto out; + + if (!domains_read) + db_rev_count = resp->db_rev_count;drivers/soc/qcom/pdr_interface.c line 384
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +10
-0+ +if (db_rev_count != resp->db_rev_count) { + ret = -EAGAIN ; + goto out; + } + +for (i = domains_read; i < resp->domain_list_len; i++) { + entry = &resp->domain_list[i]; + +if (strlen (entry->name) > (SERVREG_NAME_LENGTH +1 ))In the event that the incoming string isn't NUL-terminated this will run off the array.
Quoted 6 lines
if (
strnlen(entry->name, SERVREG_NAME_LENGTH + 1)==SERVREG_NAME_LENGTH+ 1)or perhaps, relying on sizeof instead of duplicating the knowledge that it is
SERVREG_NAME_LENGTH+ 1:if (
strnlen(entry->name, sizeof(entry->name))==sizeof(entry->name))
yeah I'll use ^^ then or maybe switch to a strncpy to further simplify things.
Quoted 10 lines
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +9
-0+continue ; + +if (!strcmp (entry->name, pds->service_path)) { + pds->service_data_valid = entry->service_data_valid; + pds->service_data = entry->service_data; + pds->instance = entry->instance; + goto out; + } + }
Quoted 8 lines
drivers/soc/qcom/pdr_interface.c line 399
Quoted 6 lines
drivers/soc/qcom/pdr_interface.c +6
-0+ +/* Update ret to indicate that the service is not yet found */ + ret = -EINVAL ; + +/* Always read total_domains from the response msg */ +if (resp->domain_list_len > resp->total_domains)Double space after '>'
thanks for catching this
Quoted 28 lines
Quoted 23 lines
drivers/soc/qcom/pdr_interface.c +22
-0+ resp->domain_list_len = resp->total_domains; + + domains_read += resp->domain_list_len; + }while (domains_read < resp->total_domains); +out: +kfree (resp); +return ret; +} + +static void pdr_servloc_work (struct work_struct *work) +{ + struct pdr_handle *pdr = container_of(work, struct pdr_handle, + servloc_work); +struct pdr_list_node *servloc, *tmp; +struct pdr_service *pds; +int ret; + +list_for_each_entry_safe (servloc, tmp, &pdr->servloc_list, node) { + pds = servloc->pds; + +/* wait for PD Mapper to come up */ + ret = wait_for_completion_timeout(&pdr->locator_available, 10 *Quoted 1 line
HZ);
Afaict this means that we will only look for the locator during the 10 seconds that follows a
pdr_add_lookup().
Quoted 3 lines
How about changing this so that you bail before the loop if the locator hasn't showed up yet and schedule this worker when the locator is registered?
yes makes sense, will do that. But by doing this the client will have to track timeouts
for lookups.
Quoted 30 lines
Quoted 29 lines
drivers/soc/qcom/pdr_interface.c +28
-0+if (!ret) { +pr_err ("PDR: SERVICE LOCATOR service wait failed\n" ); + ret = -ETIMEDOUT ; + goto err; + } + + ret =pdr_locate_service (pdr, pds); +if (ret <0 ) { +pr_err ("PDR: service lookup for %s failed: %d\n" , + pds->service_name, ret); + goto err; + } + +qmi_add_lookup (&pdr->servreg_client, pds->service,1 , + pds->instance); +err: +list_del (&servloc->node); +kfree (servloc); + +/* cleanup pds on error */ +if (ret <0 ) { + pds->state =SERVREG_LOCATOR_ERR ; + pdr->status (pdr, pds); +list_del (&pds->node); +kfree (pds); + } + } +}[..]
Quoted 15 lines
Quoted 11 lines
drivers/soc/qcom/pdr_interface.c +8
-0+int pdr_add_lookup(struct pdr_handle *pdr, const char *service_name, + const char *service_path) +{ + struct pdr_service *pds, *pds_iter, *tmp; + struct pdr_list_node *servloc; + int ret; + + if (!service_name || strlen(service_name) > (SERVREG_NAME_LENGTH +1) ||
drivers/soc/qcom/pdr_interface.c +1
-0+ !service_path || strlen(service_path) > (SERVREG_NAME_LENGTH +1))
When strlen(x) ==
SERVREG_NAME_LENGTH+ 1 your strcpy below would writeSERVREG_NAME_LENGTH+ 2 bytes toservice_nameandservice_path, so drop the + 1 from the comparisons.
yes will do that
Quoted 17 lines
Quoted 16 lines
drivers/soc/qcom/pdr_interface.c +15
-0+return -EINVAL ; + + servloc =kzalloc (sizeof (*servloc),GFP_KERNEL ); +if (!servloc) +return -ENOMEM ; + + pds =kzalloc (sizeof (*pds),GFP_KERNEL ); +if (!pds) { + ret = -ENOMEM ; + goto err; + } + + pds->service =SERVREG_NOTIFIER_SERVICE ; +strcpy (pds->service_name, service_name); +strcpy (pds->service_path, service_path);[..]
Quoted 12 lines
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +9
-0+int pdr_restart_pd(struct pdr_handle *pdr, const char *service_path) +{ + struct servreg_restart_pd_req req; + struct servreg_restart_pd_resp resp; + struct pdr_service *pds = NULL, *pds_iter, *tmp; + struct qmi_txn txn; + int ret; + + if (!service_path || strlen(service_path) > (SERVREG_NAME_LENGTH +1))
As above, drop the + 1
ditto
Quoted 9 lines
Quoted 3 lines
drivers/soc/qcom/pdr_interface.c +2
-0+return -EINVAL ; +[..]
Quoted 4 lines
drivers/soc/qcom/pdr_interface.c +4
-0+int pdr_handle_init (struct pdr_handle *pdr, +int (*status)(struct pdr_handle *pdr, +struct pdr_service *pds)) +{[..]
Quoted 10 lines
Quoted 6 lines
drivers/soc/qcom/pdr_interface.c +5
-0+ pdr->servreg_wq =create_singlethread_workqueue ("pdr_servreg_wq" ); +if (!pdr->servreg_wq) +return -ENOMEM ; + + pdr->indack_wq = alloc_ordered_workqueue("pdr_indack_wq",
WQ_HIGHPRI);The two workqueues means that we should be able to call
pdr->status()rom two concurrent contexts, I don't think our clients will expect that.
would creating another ordered wq to relay all the pd->status make sense?
Quoted 8 lines
drivers/soc/qcom/pdr_interface.c line 631
Quoted 5 lines
drivers/soc/qcom/pdr_interface.c +5
-0+if (!pdr->indack_wq) { + ret = -ENOMEM ; + goto destroy_servreg; + } +Regards,
Bjorn
Quoted 24 lines · On Tue 19 Nov 02:18 PST 2019, [email protected] wrote:
Hey Bjorn,
Thanks for taking the time to
review the series :)Quoted 19 lines · Bjorn Andersson
Quoted 2 lines · Sibi Sankar
drivers/soc/qcom/pdr_interface.c +0
-0[..]
drivers/soc/qcom/pdr_interface.c line 251
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +10
-0+static void pdr_indack_work (struct work_struct *work) +{ + struct pdr_handle *pdr = container_of(work, struct pdr_handle, + indack_work); +struct pdr_list_node *ind, *tmp; +struct pdr_service *pds; + +list_for_each_entry_safe (ind, tmp, &pdr->indack_list, node) { + pds = ind->pds; +pdr_send_indack_msg (pdr, pds, ind->transaction_id);So when we et a
ind_cbwith the new status, we need to send an ack request, which will result in a response, just to confirm that we got the event?
Quoted 7 lines
Quoted 2 lines
Seems like we should fix the qmi code to make it possible to send a request from the indication handler and then we could simply ignore the
yeah maybe having a provision to send custom requests back on indication would be the way to go. Not all indication need to be services with requests.
Let's put this on the todo list.
Quoted 7 lines
Quoted 2 lines
response. Or do we need to not
pdr->status()until we get the response for some reason?adsp waits on the ack response for a fixed duration and seems to throw a fatal err is the ack is not serviced. Hence holding back
pd->statustill we service the ack here.
You mean to ensure that someone sleeping in pd->status() doesn't delay that until its too late?
[..]
Quoted 16 lines
Quoted 5 lines
Quoted 4 lines
drivers/soc/qcom/pdr_interface.c +4
-0+int pdr_handle_init (struct pdr_handle *pdr, +int (*status)(struct pdr_handle *pdr, +struct pdr_service *pds)) +{[..]
Quoted 10 lines
Quoted 6 lines
drivers/soc/qcom/pdr_interface.c +5
-0+ pdr->servreg_wq =create_singlethread_workqueue ("pdr_servreg_wq" ); +if (!pdr->servreg_wq) +return -ENOMEM ; + + pdr->indack_wq = alloc_ordered_workqueue("pdr_indack_wq",
WQ_HIGHPRI);The two workqueues means that we should be able to call
pdr->status()rom two concurrent contexts, I don't think our clients will expect that.
Quoted 3 lines
would creating another ordered wq to relay all the
pd->statusmake sense?
I would prefer less work queues ;) But I presume you split out the indack_wq in order to improve the likelihood of meeting the latency requirements of the remote side.
Perhaps just wrap the status() calls with a status-mutex and then remove that by reworking the QMI interface to allow us to remove the indack work?
Regards,
Bjorn
Quoted 39 lines · Bjorn Andersson
Quoted 24 lines · On Tue 19 Nov 02:18 PST 2019, [email protected] wrote:
Hey Bjorn,
Thanks for taking the time to
review the series :)Quoted 19 lines · Bjorn Andersson
Quoted 2 lines · Sibi Sankar
drivers/soc/qcom/pdr_interface.c +0
-0[..]
drivers/soc/qcom/pdr_interface.c line 251
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +10
-0+static void pdr_indack_work (struct work_struct *work) +{ + struct pdr_handle *pdr = container_of(work, struct pdr_handle, + indack_work); +struct pdr_list_node *ind, *tmp; +struct pdr_service *pds; + +list_for_each_entry_safe (ind, tmp, &pdr->indack_list, node) { + pds = ind->pds; +pdr_send_indack_msg (pdr, pds, ind->transaction_id);So when we et a
ind_cbwith the new status, we need to send an ack request, which will result in a response, just to confirm that we got the event?Quoted 7 lines
Quoted 2 lines
Seems like we should fix the qmi code to make it possible to send a request from the indication handler and then we could simply ignore the
yeah maybe having a provision to send custom requests back on indication would be the way to go. Not all indication need to be services with requests.
Let's put this on the todo list.
Quoted 3 lines
Quoted 2 lines
response. Or do we need to not
pdr->status()until we get the response for some reason?
Quoted 7 lines
Quoted 4 lines
adsp waits on the ack response for a fixed duration and seems to throw a fatal err is the ack is not serviced. Hence holding back
pd->statustill we service the ack here.You mean to ensure that someone sleeping in
pd->status()doesn't delay that until its too late?
yes
Quoted 22 lines
[..]
Quoted 16 lines
Quoted 5 lines
Quoted 4 lines
drivers/soc/qcom/pdr_interface.c +4
-0+int pdr_handle_init (struct pdr_handle *pdr, +int (*status)(struct pdr_handle *pdr, +struct pdr_service *pds)) +{[..]
Quoted 10 lines
Quoted 6 lines
drivers/soc/qcom/pdr_interface.c +5
-0+ pdr->servreg_wq =create_singlethread_workqueue ("pdr_servreg_wq" ); +if (!pdr->servreg_wq) +return -ENOMEM ; + + pdr->indack_wq = alloc_ordered_workqueue("pdr_indack_wq",
WQ_HIGHPRI);The two workqueues means that we should be able to call
pdr->status()rom two concurrent contexts, I don't think our clients will expect that.Quoted 3 lines
would creating another ordered wq to relay all the
pd->statusmake sense?
Quoted 7 lines
I would prefer less work queues ;) But I presume you split out the
indack_wqin order to improve the likelihood of meeting the latency requirements of the remote side.Perhaps just wrap the
status()calls with a status-mutex and then remove that by reworking the QMI interface to allow us to remove the indack work?
okay will fix it in the next
re-spin.
Quoted 3 lines
Regards,
Bjorn
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 39 lines · Bjorn Andersson
Quoted 24 lines · On Tue 19 Nov 02:18 PST 2019, [email protected] wrote:
Hey Bjorn,
Thanks for taking the time to
review the series :)Quoted 19 lines · Bjorn Andersson
Quoted 2 lines · Sibi Sankar
drivers/soc/qcom/pdr_interface.c +0
-0[..]
drivers/soc/qcom/pdr_interface.c line 251
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +10
-0+static void pdr_indack_work (struct work_struct *work) +{ + struct pdr_handle *pdr = container_of(work, struct pdr_handle, + indack_work); +struct pdr_list_node *ind, *tmp; +struct pdr_service *pds; + +list_for_each_entry_safe (ind, tmp, &pdr->indack_list, node) { + pds = ind->pds; +pdr_send_indack_msg (pdr, pds, ind->transaction_id);So when we et a
ind_cbwith the new status, we need to send an ack request, which will result in a response, just to confirm that we got the event?Quoted 7 lines
Quoted 2 lines
Seems like we should fix the qmi code to make it possible to send a request from the indication handler and then we could simply ignore the
yeah maybe having a provision to send custom requests back on indication would be the way to go. Not all indication need to be services with requests.
Let's put this on the todo list.
Quoted 3 lines
Quoted 2 lines
response. Or do we need to not
pdr->status()until we get the response for some reason?
Quoted 7 lines
Quoted 4 lines
adsp waits on the ack response for a fixed duration and seems to throw a fatal err is the ack is not serviced. Hence holding back
pd->statustill we service the ack here.You mean to ensure that someone sleeping in
pd->status()doesn't delay that until its too late?
yes
Quoted 22 lines
[..]
Quoted 16 lines
Quoted 5 lines
Quoted 4 lines
drivers/soc/qcom/pdr_interface.c +4
-0+int pdr_handle_init (struct pdr_handle *pdr, +int (*status)(struct pdr_handle *pdr, +struct pdr_service *pds)) +{[..]
Quoted 10 lines
Quoted 6 lines
drivers/soc/qcom/pdr_interface.c +5
-0+ pdr->servreg_wq =create_singlethread_workqueue ("pdr_servreg_wq" ); +if (!pdr->servreg_wq) +return -ENOMEM ; + + pdr->indack_wq = alloc_ordered_workqueue("pdr_indack_wq",
WQ_HIGHPRI);The two workqueues means that we should be able to call
pdr->status()rom two concurrent contexts, I don't think our clients will expect that.Quoted 3 lines
would creating another ordered wq to relay all the
pd->statusmake sense?
Quoted 7 lines
I would prefer less work queues ;) But I presume you split out the
indack_wqin order to improve the likelihood of meeting the latency requirements of the remote side.Perhaps just wrap the
status()calls with a status-mutex and then remove that by reworking the QMI interface to allow us to remove the indack work?
okay will fix it in the next
re-spin.
Quoted 3 lines
Regards,
Bjorn
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Hey Bjorn,
Thanks for taking the time to review the series :)
Quoted 18 lines · Bjorn Andersson
Quoted 1 line · Sibi Sankar
drivers/soc/qcom/pdr_interface.c +0
-0[..]
drivers/soc/qcom/pdr_interface.c line 251
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +10
-0+static void pdr_indack_work (struct work_struct *work) +{ + struct pdr_handle *pdr = container_of(work, struct pdr_handle, + indack_work); +struct pdr_list_node *ind, *tmp; +struct pdr_service *pds; + +list_for_each_entry_safe (ind, tmp, &pdr->indack_list, node) { + pds = ind->pds; +pdr_send_indack_msg (pdr, pds, ind->transaction_id);So when we et a
ind_cbwith the new status, we need to send an ack request, which will result in a response, just to confirm that we got the event?
Quoted 2 lines
Seems like we should fix the qmi code to make it possible to send a request from the indication handler and then we could simply ignore the
yeah maybe having a provision to send custom requests back on indication would be the way
to go. Not all indication need to be services with requests.
Quoted 2 lines
response. Or do we need to not
pdr->status()until we get the response for some reason?
adsp waits on the ack response for a fixed duration and seems to throw a fatal err is the ack is not serviced. Hence holding back pd->status till we service the ack here.
Quoted 98 lines
Regardless, I'm fine with scheduling this for now...
Quoted 94 lines
drivers/soc/qcom/pdr_interface.c +34
-0+ pdr->status (pdr, pds); +list_del (&ind->node); +kfree (ind); + } +} + +static void pdr_servreg_ind_cb (struct qmi_handle *qmi, +struct sockaddr_qrtr *sq, +struct qmi_txn *txn,const void *data) +{ + struct pdr_handle *pdr = container_of(qmi, struct pdr_handle, + servreg_client); +const struct servreg_state_updated_ind *ind_msg = data; +struct pdr_list_node *ind; +struct pdr_service *pds; + +if (!ind_msg || !ind_msg->service_path || +strlen (ind_msg->service_path) > (SERVREG_NAME_LENGTH +1 )) +return ; + +list_for_each_entry (pds, &pdr->lookups, node) { +if (!strcmp (pds->service_path, ind_msg->service_path)) + goto found; + } +return ; + +found: + pds->state = ind_msg->curr_state; + + ind =kzalloc (sizeof (*ind),GFP_KERNEL ); +if (!ind) +return ; + + pr_info("PDR: Indication received from %s, state: 0x%x, trans-id:%d\n",
drivers/soc/qcom/pdr_interface.c +25
-0+ ind_msg->service_path, ind_msg->curr_state, + ind_msg->transaction_id); + + ind->transaction_id = ind_msg->transaction_id; + ind->pds = pds; + +mutex_lock (&pdr->list_lock); +list_add_tail (&ind->node, &pdr->indack_list); +mutex_unlock (&pdr->list_lock); + +queue_work (pdr->indack_wq, &pdr->indack_work); +} + +static struct qmi_msg_handler qmi_indication_handler[] = { + { + .type =QMI_INDICATION , + .msg_id =SERVREG_STATE_UPDATED_IND_ID , + .ei = servreg_state_updated_ind_ei, + .decoded_size =sizeof (struct servreg_state_updated_ind ), + .fn = pdr_servreg_ind_cb, + }, + {} +}; + +static int pdr_get_domain_list(struct servreg_get_domain_list_req*req,
drivers/soc/qcom/pdr_interface.c +33
-0+struct servreg_get_domain_list_resp *resp, + struct pdr_handle *pdr) +{ + struct qmi_txn txn; +int ret; + + ret =qmi_txn_init (&pdr->servloc_client, &txn, + servreg_get_domain_list_resp_ei, resp); +if (ret <0 ) +return ret; + + ret =qmi_send_request (&pdr->servloc_client, + &pdr->servloc_addr, + &txn,SERVREG_GET_DOMAIN_LIST_REQ , +SERVREG_GET_DOMAIN_LIST_REQ_MAX_LEN , + servreg_get_domain_list_req_ei, + req); +if (ret <0 ) { +qmi_txn_cancel (&txn); +return ret; + } + + ret =qmi_txn_wait (&txn,5 *HZ ); +if (ret <0 ) { +pr_err ("PDR: %s get domain list txn wait failed: %d\n" , + req->service_name, ret); +return ret; + } + +/* Check the response */ +if (resp->resp.result !=QMI_RESULT_SUCCESS_V01 ) { +pr_err ("PDR: %s get domain list failed: 0x%x\n" , + req->service_name, resp->resp.error);
Quoted 8 lines
drivers/soc/qcom/pdr_interface.c line 347
Quoted 4 lines
drivers/soc/qcom/pdr_interface.c +4
-0+return -EREMOTEIO ; + } + +return ret;ret here will be the number of bytes decoded, but you really only care about if this was an error or not. So I would suggest that you just return 0 here.
yeah will return 0
Quoted 43 lines
Quoted 29 lines
drivers/soc/qcom/pdr_interface.c +3
-0+} + +static int pdr_locate_service(struct pdr_handle *pdr, struct
pdr_service*pds)drivers/soc/qcom/pdr_interface.c +24
-0+{ +struct servreg_get_domain_list_resp *resp =NULL ; +struct servreg_get_domain_list_req req; +int db_rev_count =0 , domains_read =0 ; +struct servreg_location_entry *entry; +int ret, i; + + resp =kzalloc (sizeof (*resp),GFP_KERNEL ); +if (!resp) +return -ENOMEM ; + +/* Prepare req message */ +strcpy (req.service_name, pds->service_name); + req.domain_offset_valid = true; + req.domain_offset =0 ; + + do { + req.domain_offset = domains_read; + ret = pdr_get_domain_list(&req, resp, pdr); + if (ret < 0) + goto out; + + if (!domains_read) + db_rev_count = resp->db_rev_count;drivers/soc/qcom/pdr_interface.c line 384
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +10
-0+ +if (db_rev_count != resp->db_rev_count) { + ret = -EAGAIN ; + goto out; + } + +for (i = domains_read; i < resp->domain_list_len; i++) { + entry = &resp->domain_list[i]; + +if (strlen (entry->name) > (SERVREG_NAME_LENGTH +1 ))In the event that the incoming string isn't NUL-terminated this will run off the array.
Quoted 6 lines
if (
strnlen(entry->name, SERVREG_NAME_LENGTH + 1)==SERVREG_NAME_LENGTH+ 1)or perhaps, relying on sizeof instead of duplicating the knowledge that it is
SERVREG_NAME_LENGTH+ 1:if (
strnlen(entry->name, sizeof(entry->name))==sizeof(entry->name))
yeah I'll use ^^ then or maybe switch to a strncpy to further simplify things.
Quoted 10 lines
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +9
-0+continue ; + +if (!strcmp (entry->name, pds->service_path)) { + pds->service_data_valid = entry->service_data_valid; + pds->service_data = entry->service_data; + pds->instance = entry->instance; + goto out; + } + }
Quoted 8 lines
drivers/soc/qcom/pdr_interface.c line 399
Quoted 6 lines
drivers/soc/qcom/pdr_interface.c +6
-0+ +/* Update ret to indicate that the service is not yet found */ + ret = -EINVAL ; + +/* Always read total_domains from the response msg */ +if (resp->domain_list_len > resp->total_domains)Double space after '>'
thanks for catching this
Quoted 28 lines
Quoted 23 lines
drivers/soc/qcom/pdr_interface.c +22
-0+ resp->domain_list_len = resp->total_domains; + + domains_read += resp->domain_list_len; + }while (domains_read < resp->total_domains); +out: +kfree (resp); +return ret; +} + +static void pdr_servloc_work (struct work_struct *work) +{ + struct pdr_handle *pdr = container_of(work, struct pdr_handle, + servloc_work); +struct pdr_list_node *servloc, *tmp; +struct pdr_service *pds; +int ret; + +list_for_each_entry_safe (servloc, tmp, &pdr->servloc_list, node) { + pds = servloc->pds; + +/* wait for PD Mapper to come up */ + ret = wait_for_completion_timeout(&pdr->locator_available, 10 *Quoted 1 line
HZ);
Afaict this means that we will only look for the locator during the 10 seconds that follows a
pdr_add_lookup().
Quoted 3 lines
How about changing this so that you bail before the loop if the locator hasn't showed up yet and schedule this worker when the locator is registered?
yes makes sense, will do that. But by doing this the client will have to track timeouts
for lookups.
Quoted 30 lines
Quoted 29 lines
drivers/soc/qcom/pdr_interface.c +28
-0+if (!ret) { +pr_err ("PDR: SERVICE LOCATOR service wait failed\n" ); + ret = -ETIMEDOUT ; + goto err; + } + + ret =pdr_locate_service (pdr, pds); +if (ret <0 ) { +pr_err ("PDR: service lookup for %s failed: %d\n" , + pds->service_name, ret); + goto err; + } + +qmi_add_lookup (&pdr->servreg_client, pds->service,1 , + pds->instance); +err: +list_del (&servloc->node); +kfree (servloc); + +/* cleanup pds on error */ +if (ret <0 ) { + pds->state =SERVREG_LOCATOR_ERR ; + pdr->status (pdr, pds); +list_del (&pds->node); +kfree (pds); + } + } +}[..]
Quoted 15 lines
Quoted 11 lines
drivers/soc/qcom/pdr_interface.c +8
-0+int pdr_add_lookup(struct pdr_handle *pdr, const char *service_name, + const char *service_path) +{ + struct pdr_service *pds, *pds_iter, *tmp; + struct pdr_list_node *servloc; + int ret; + + if (!service_name || strlen(service_name) > (SERVREG_NAME_LENGTH +1) ||
drivers/soc/qcom/pdr_interface.c +1
-0+ !service_path || strlen(service_path) > (SERVREG_NAME_LENGTH +1))
When strlen(x) ==
SERVREG_NAME_LENGTH+ 1 your strcpy below would writeSERVREG_NAME_LENGTH+ 2 bytes toservice_nameandservice_path, so drop the + 1 from the comparisons.
yes will do that
Quoted 17 lines
Quoted 16 lines
drivers/soc/qcom/pdr_interface.c +15
-0+return -EINVAL ; + + servloc =kzalloc (sizeof (*servloc),GFP_KERNEL ); +if (!servloc) +return -ENOMEM ; + + pds =kzalloc (sizeof (*pds),GFP_KERNEL ); +if (!pds) { + ret = -ENOMEM ; + goto err; + } + + pds->service =SERVREG_NOTIFIER_SERVICE ; +strcpy (pds->service_name, service_name); +strcpy (pds->service_path, service_path);[..]
Quoted 12 lines
Quoted 10 lines
drivers/soc/qcom/pdr_interface.c +9
-0+int pdr_restart_pd(struct pdr_handle *pdr, const char *service_path) +{ + struct servreg_restart_pd_req req; + struct servreg_restart_pd_resp resp; + struct pdr_service *pds = NULL, *pds_iter, *tmp; + struct qmi_txn txn; + int ret; + + if (!service_path || strlen(service_path) > (SERVREG_NAME_LENGTH +1))
As above, drop the + 1
ditto
Quoted 9 lines
Quoted 3 lines
drivers/soc/qcom/pdr_interface.c +2
-0+return -EINVAL ; +[..]
Quoted 4 lines
drivers/soc/qcom/pdr_interface.c +4
-0+int pdr_handle_init (struct pdr_handle *pdr, +int (*status)(struct pdr_handle *pdr, +struct pdr_service *pds)) +{[..]
Quoted 10 lines
Quoted 6 lines
drivers/soc/qcom/pdr_interface.c +5
-0+ pdr->servreg_wq =create_singlethread_workqueue ("pdr_servreg_wq" ); +if (!pdr->servreg_wq) +return -ENOMEM ; + + pdr->indack_wq = alloc_ordered_workqueue("pdr_indack_wq",
WQ_HIGHPRI);The two workqueues means that we should be able to call
pdr->status()rom two concurrent contexts, I don't think our clients will expect that.
would creating another ordered wq to relay all the pd->status make sense?
Quoted 8 lines
drivers/soc/qcom/pdr_interface.c line 631
Quoted 5 lines
drivers/soc/qcom/pdr_interface.c +5
-0+if (!pdr->indack_wq) { + ret = -ENOMEM ; + goto destroy_servreg; + } +Regards,
Bjorn
PATCH 2/3 dt-bindings: soc: qcom: apr: Add protection domain bindings
In reply to a message not in the archiveAdd optional "qcom,protection-domain" bindings for APR services. This helps to capture the dependencies between APR services and the PD on which each apr service run.
--- .../devicetree/bindings/soc/qcom/qcom,apr.txt | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt +59 -0
@@ -45,6 +45,12 @@ by the individual bindings for the specific service 12 - Ultrasound stream manager. 13 - Listen stream manager. +- qcom,protection-domain + Usage: optional + Value type: <stringlist> + Definition: Must list the protection domain service name and path + that the particular apr service has a dependency on. + = EXAMPLE The following example represents a QDSP based sound card on a MSM8996 device which uses apr as communication between Apps and QDSP.
@@ -82,3 +88,56 @@ which uses apr as communication between Apps and QDSP. ... }; }; + += EXAMPLE 2 +The following example represents a QDSP based sound card on SDM845 device. +Here the apr services are dependent on "avs/audio" service running on AUDIO +Protection Domain hosted on ADSP remote processor. + + apr { + compatible = "qcom,apr-v2"; + qcom,glink-channels = "apr_audio_svc"; + qcom,apr-domain = <APR_DOMAIN_ADSP>; + + q6core { + compatible = "qcom,q6core"; + reg = <APR_SVC_ADSP_CORE>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + }; + + q6afe: q6afe { + compatible = "qcom,q6afe"; + reg = <APR_SVC_AFE>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6afedai: dais { + compatible = "qcom,q6afe-dais"; + #sound-dai-cells = <1>; + + qi2s@22 { + reg = <22>; + qcom,sd-lines = <3>; + }; + }; + }; + + q6asm: q6asm { + compatible = "qcom,q6asm"; + reg = <APR_SVC_ASM>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6asmdai: dais { + compatible = "qcom,q6asm-dais"; + #sound-dai-cells = <1>; + iommus = <&apps_smmu 0x1821 0x0>; + }; + }; + + q6adm: q6adm { + compatible = "qcom,q6adm"; + reg = <APR_SVC_ADM>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6routing: routing { + compatible = "qcom,q6adm-routing"; + #sound-dai-cells = <0>; + }; + }; + };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 2/3 dt-bindings: soc: qcom: apr: Add protection domain bindings
In reply to a message not in the archiveAdd optional "qcom,protection-domain" bindings for APR services. This helps to capture the dependencies between APR services and the PD on which each apr service run.
--- .../devicetree/bindings/soc/qcom/qcom,apr.txt | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt +59 -0
@@ -45,6 +45,12 @@ by the individual bindings for the specific service 12 - Ultrasound stream manager. 13 - Listen stream manager. +- qcom,protection-domain + Usage: optional + Value type: <stringlist> + Definition: Must list the protection domain service name and path + that the particular apr service has a dependency on. + = EXAMPLE The following example represents a QDSP based sound card on a MSM8996 device which uses apr as communication between Apps and QDSP.
@@ -82,3 +88,56 @@ which uses apr as communication between Apps and QDSP. ... }; }; + += EXAMPLE 2 +The following example represents a QDSP based sound card on SDM845 device. +Here the apr services are dependent on "avs/audio" service running on AUDIO +Protection Domain hosted on ADSP remote processor. + + apr { + compatible = "qcom,apr-v2"; + qcom,glink-channels = "apr_audio_svc"; + qcom,apr-domain = <APR_DOMAIN_ADSP>; + + q6core { + compatible = "qcom,q6core"; + reg = <APR_SVC_ADSP_CORE>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + }; + + q6afe: q6afe { + compatible = "qcom,q6afe"; + reg = <APR_SVC_AFE>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6afedai: dais { + compatible = "qcom,q6afe-dais"; + #sound-dai-cells = <1>; + + qi2s@22 { + reg = <22>; + qcom,sd-lines = <3>; + }; + }; + }; + + q6asm: q6asm { + compatible = "qcom,q6asm"; + reg = <APR_SVC_ASM>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6asmdai: dais { + compatible = "qcom,q6asm-dais"; + #sound-dai-cells = <1>; + iommus = <&apps_smmu 0x1821 0x0>; + }; + }; + + q6adm: q6adm { + compatible = "qcom,q6adm"; + reg = <APR_SVC_ADM>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6routing: routing { + compatible = "qcom,q6adm-routing"; + #sound-dai-cells = <0>; + }; + }; + };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 2/3] dt-bindings: soc: qcom: apr: Add protection domain bindings
Quoted 4 lines · Sibi Sankar
Add optional "qcom,protection-domain" bindings for APR services. This helps to capture the dependencies between APR services and the PD on which each apr service run.
Quoted 83 lines
Signed-off-by Sibi Sankar <[email protected]>--- .../devicetree/bindings/soc/qcom/qcom,apr.txt | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+)Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt +59
-0@@ -45,6 +45,12 @@ by the individual bindings for the specific service 12 - Ultrasound stream manager. 13 - Listen stream manager. +- qcom,protection-domain + Usage: optional + Value type: <stringlist> + Definition: Must list the protection domain service name and path + that the particular apr service has a dependency on. + = EXAMPLE The following example represents a QDSP based sound card on a MSM8996 device which uses apr as communication between Apps and QDSP.@@ -82,3 +88,56 @@ which uses apr as communication between Apps and QDSP. }; }; + += EXAMPLE 2 +The following example represents a QDSP based sound card on SDM845 device. +Here the apr services are dependent on "avs/audio" service running on AUDIO +Protection Domain hosted on ADSP remote processor. + + apr { + compatible = "qcom,apr-v2"; + qcom,glink-channels = "apr_audio_svc"; + qcom,apr-domain = <APR_DOMAIN_ADSP>; + + q6core { + compatible = "qcom,q6core"; + reg = <APR_SVC_ADSP_CORE>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + }; + + q6afe: q6afe { + compatible = "qcom,q6afe"; + reg = <APR_SVC_AFE>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6afedai: dais { + compatible = "qcom,q6afe-dais"; + #sound-dai-cells = <1>; + + qi2s@22 { + reg = <22>; + qcom,sd-lines = <3>; + }; + }; + }; + + q6asm: q6asm { + compatible = "qcom,q6asm"; + reg = <APR_SVC_ASM>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6asmdai: dais { + compatible = "qcom,q6asm-dais"; + #sound-dai-cells = <1>; + iommus = <&apps_smmu 0x1821 0x0>; + }; + }; + + q6adm: q6adm { + compatible = "qcom,q6adm"; + reg = <APR_SVC_ADM>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6routing: routing { + compatible = "qcom,q6adm-routing"; + #sound-dai-cells = <0>; + }; + }; + };Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 2/3] dt-bindings: soc: qcom: apr: Add protection domain bindings
In reply to Sibi SankarQuoted 5 lines · Sibi Sankar
Add optional "qcom,protection-domain" bindings for APR services. This helps to capture the dependencies between APR services and the PD on which each apr service run.
Signed-off-by Sibi Sankar <[email protected]>
LGTM
Quoted 79 lines
--- .../devicetree/bindings/soc/qcom/qcom,apr.txt | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+)Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt +59
-0@@ -45,6 +45,12 @@ by the individual bindings for the specific service 12 - Ultrasound stream manager. 13 - Listen stream manager. +- qcom,protection-domain + Usage: optional + Value type: <stringlist> + Definition: Must list the protection domain service name and path + that the particular apr service has a dependency on. + = EXAMPLE The following example represents a QDSP based sound card on a MSM8996 device which uses apr as communication between Apps and QDSP.@@ -82,3 +88,56 @@ which uses apr as communication between Apps and QDSP. }; }; + += EXAMPLE 2 +The following example represents a QDSP based sound card on SDM845 device. +Here the apr services are dependent on "avs/audio" service running on AUDIO +Protection Domain hosted on ADSP remote processor. + + apr { + compatible = "qcom,apr-v2"; + qcom,glink-channels = "apr_audio_svc"; + qcom,apr-domain = <APR_DOMAIN_ADSP>; + + q6core { + compatible = "qcom,q6core"; + reg = <APR_SVC_ADSP_CORE>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + }; + + q6afe: q6afe { + compatible = "qcom,q6afe"; + reg = <APR_SVC_AFE>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6afedai: dais { + compatible = "qcom,q6afe-dais"; + #sound-dai-cells = <1>; + + qi2s@22 { + reg = <22>; + qcom,sd-lines = <3>; + }; + }; + }; + + q6asm: q6asm { + compatible = "qcom,q6asm"; + reg = <APR_SVC_ASM>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6asmdai: dais { + compatible = "qcom,q6asm-dais"; + #sound-dai-cells = <1>; + iommus = <&apps_smmu 0x1821 0x0>; + }; + }; + + q6adm: q6adm { + compatible = "qcom,q6adm"; + reg = <APR_SVC_ADM>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6routing: routing { + compatible = "qcom,q6adm-routing"; + #sound-dai-cells = <0>; + }; + }; + };
PATCH 3/3 soc: qcom: apr: Add avs/audio tracking functionality
In reply to a message not in the archiveUse PDR helper functions to track the protection domains that the apr services are dependent upon on SDM845 SoC, specifically the "avs/audio" service running on ADSP Q6.
--- drivers/soc/qcom/Kconfig | 1 + drivers/soc/qcom/apr.c | 100 +++++++++++++++++++++++++++++++---- include/linux/soc/qcom/apr.h | 1 + 3 files changed, 91 insertions(+), 11 deletions(-)
drivers/soc/qcom/Kconfig +1 -0
@@ -202,6 +202,7 @@ config QCOM_APR tristate "Qualcomm APR Bus (Asynchronous Packet Router)" depends on ARCH_QCOM || COMPILE_TEST depends on RPMSG + select QCOM_PDR_HELPERS help Enable APR IPC protocol support between application processor and QDSP6. APR is
drivers/soc/qcom/apr.c +89 -11
153 lines not on this page · raw message
include/linux/soc/qcom/apr.h +1 -0
@@ -85,6 +85,7 @@ struct apr_device {uint16_t domain_id;uint32_t version;char name[APR_NAME_SIZE ]; +const char *service_path;spinlock_t lock;struct list_head node; };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 3/3] soc: qcom: apr: Add avs/audio tracking functionality
Quoted 1 line · Sibi Sankar
drivers/soc/qcom/Kconfig +0
-0
[..]
Quoted 12 lines
drivers/soc/qcom/Kconfig +5
-0+static void of_register_apr_devices(struct device *dev, const char *svc_path) { struct apr *apr = dev_get_drvdata(dev); struct device_node *node; + const char *service_path; + int ret; for_each_child_of_node(dev->of_node, node) { struct apr_device_id id = { {0} }; + ret = of_property_read_string_index(node, "qcom,protection-domain", + 1, &service_path);
drivers/soc/qcom/Kconfig
Quoted 10 lines
drivers/soc/qcom/Kconfig +10
-0+ if (svc_path) { + /* skip APR services that are PD independent */ + if (ret) + continue; + + /* skip APR services whose PD paths don't match */ + if (strcmp(service_path, svc_path)) + continue; + } else { + /* skip APR services whose PD lookups are registered*/
Missing space before */
Quoted 16 lines
drivers/soc/qcom/Kconfig +9
-0+ if (ret == 0) + continue; + } + if (of_property_read_u32(node, "reg", &id.svc_id)) continue;@@ -318,6 +365,37 @@ static void of_register_apr_devices(struct device *dev) } } +static int apr_remove_device(struct device *dev, void *svc_path) +{ + struct apr_device *adev = to_apr_device(dev); + + if (svc_path) {
drivers/soc/qcom/Kconfig static void of_register_apr_devices(struct device *dev) · line 382
Quoted 10 lines
drivers/soc/qcom/Kconfig +10
-0+ if (!strcmp(adev->service_path, (char *)svc_path)) + device_unregister(&adev->dev); + } else { + device_unregister(&adev->dev); + } + + return 0; +} + +static int apr_pd_status(struct pdr_handle *pdr, struct pdr_service *pds)
Why is the pdr status function returning an int?
Quoted 15 lines
drivers/soc/qcom/Kconfig +15
-0+{ + struct apr *apr = container_of(pdr, struct apr, pdr); + + switch (pds->state) { + case SERVREG_SERVICE_STATE_UP: + of_register_apr_devices(apr->dev, pds->service_path); + break; + case SERVREG_SERVICE_STATE_DOWN: + device_for_each_child(apr->dev, pds->service_path, + apr_remove_device); + break; + } + + return 0; +}
[..]
drivers/soc/qcom/Kconfig static int apr_probe(struct rpmsg_device *rpdev) · line 427
Quoted 8 lines
drivers/soc/qcom/Kconfig +4
-0@@ -343,20 +421,19 @@ static int apr_probe(struct rpmsg_device *rpdev) return -ENOMEM; } INIT_WORK(&apr->rx_work, apr_rxwq); + + ret = pdr_handle_init(&apr->pdr, apr_pd_status); + if (ret) { + dev_err(dev, "Failed to init PDR handle\n");
You need to destroy apr->rxwq here as well.
drivers/soc/qcom/Kconfig static int apr_probe(struct rpmsg_device *rpdev) · line 353
Quoted 11 lines
drivers/soc/qcom/Kconfig +3
-4+ return ret; + } + INIT_LIST_HEAD(&apr->rx_list); spin_lock_init(&apr->rx_lock); spin_lock_init(&apr->svcs_lock); idr_init(&apr->svcs_idr); - of_register_apr_devices(dev); - - return 0; -}
Regards,
Bjorn
Re: [PATCH 3/3] soc: qcom: apr: Add avs/audio tracking functionality
Quoted 14 lines · Bjorn Andersson
Quoted 1 line · Sibi Sankar
drivers/soc/qcom/Kconfig +0
-0[..]
Quoted 11 lines
+static void
of_register_apr_devices(struct device *dev, const char *svc_path)
{drivers/soc/qcom/Kconfig +2
-0struct apr *apr = dev_get_drvdata(dev); struct device_node *node; + const char *service_path; + int ret; for_each_child_of_node(dev->of_node, node) { struct apr_device_id id = { {0} };
Quoted 14 lines
drivers/soc/qcom/Kconfig
Quoted 12 lines
drivers/soc/qcom/Kconfig +12
-0+ ret = of_property_read_string_index(node, "qcom,protection-domain", + 1, &service_path); + if (svc_path) { + /* skip APR services that are PD independent */ + if (ret) + continue; + + /* skip APR services whose PD paths don't match */ + if (strcmp(service_path, svc_path)) + continue; + } else { + /* skip APR services whose PD lookups are registered*/Missing space before */
Thanks will add it
Quoted 23 lines
Quoted 23 lines
drivers/soc/qcom/Kconfig +14
-0+ if (ret == 0) + continue; + } + if (of_property_read_u32(node, "reg", &id.svc_id)) continue;@@ -318,6 +365,37 @@ static void of_register_apr_devices(struct device *dev) } } +static int apr_remove_device(struct device *dev, void *svc_path) +{ + struct apr_device *adev = to_apr_device(dev); + + if (svc_path) { + if (!strcmp(adev->service_path, (char *)svc_path)) + device_unregister(&adev->dev); + } else { + device_unregister(&adev->dev); + }
Quoted 8 lines
drivers/soc/qcom/Kconfig static void of_register_apr_devices(struct device · line 384
Quoted 6 lines
drivers/soc/qcom/Kconfig +5
-0+ + return 0; +} + +static int apr_pd_status(struct pdr_handle *pdr, struct pdr_service *pds)Why is the pdr status function returning an int?
yes since I am not using the
return value in pdr_helpers
will make it void.
Quoted 17 lines
Quoted 16 lines
drivers/soc/qcom/Kconfig +15
-0+{ + struct apr *apr = container_of(pdr, struct apr, pdr); + + switch (pds->state) { + case SERVREG_SERVICE_STATE_UP: + of_register_apr_devices(apr->dev, pds->service_path); + break; + case SERVREG_SERVICE_STATE_DOWN: + device_for_each_child(apr->dev, pds->service_path, + apr_remove_device); + break; + } + + return 0; +}[..]
Quoted 10 lines
drivers/soc/qcom/Kconfig static int apr_probe(struct rpmsg_device *rpdev) · line 427
Quoted 8 lines
drivers/soc/qcom/Kconfig +4
-0@@ -343,20 +421,19 @@ static int apr_probe(struct rpmsg_device *rpdev) return -ENOMEM; } INIT_WORK(&apr->rx_work, apr_rxwq); + + ret = pdr_handle_init(&apr->pdr, apr_pd_status); + if (ret) { + dev_err(dev, "Failed to init PDR handle\n");You need to destroy
apr->rxwqhere as well.
sry missed this
Quoted 15 lines
drivers/soc/qcom/Kconfig static int apr_probe(struct rpmsg_device *rpdev) · line 353
Quoted 12 lines
drivers/soc/qcom/Kconfig +3
-4+ return ret; + } + INIT_LIST_HEAD(&apr->rx_list); spin_lock_init(&apr->rx_lock); spin_lock_init(&apr->svcs_lock); idr_init(&apr->svcs_idr); - of_register_apr_devices(dev); - - return 0; -}Regards,
Bjorn
Re: [PATCH 3/3] soc: qcom: apr: Add avs/audio tracking functionality
In reply to Bjorn AnderssonQuoted 14 lines · Bjorn Andersson
Quoted 1 line · Sibi Sankar
drivers/soc/qcom/Kconfig +0
-0[..]
Quoted 11 lines
+static void
of_register_apr_devices(struct device *dev, const char *svc_path)
{drivers/soc/qcom/Kconfig +2
-0struct apr *apr = dev_get_drvdata(dev); struct device_node *node; + const char *service_path; + int ret; for_each_child_of_node(dev->of_node, node) { struct apr_device_id id = { {0} };
Quoted 14 lines
drivers/soc/qcom/Kconfig
Quoted 12 lines
drivers/soc/qcom/Kconfig +12
-0+ ret = of_property_read_string_index(node, "qcom,protection-domain", + 1, &service_path); + if (svc_path) { + /* skip APR services that are PD independent */ + if (ret) + continue; + + /* skip APR services whose PD paths don't match */ + if (strcmp(service_path, svc_path)) + continue; + } else { + /* skip APR services whose PD lookups are registered*/Missing space before */
Thanks will add it
Quoted 23 lines
Quoted 23 lines
drivers/soc/qcom/Kconfig +14
-0+ if (ret == 0) + continue; + } + if (of_property_read_u32(node, "reg", &id.svc_id)) continue;@@ -318,6 +365,37 @@ static void of_register_apr_devices(struct device *dev) } } +static int apr_remove_device(struct device *dev, void *svc_path) +{ + struct apr_device *adev = to_apr_device(dev); + + if (svc_path) { + if (!strcmp(adev->service_path, (char *)svc_path)) + device_unregister(&adev->dev); + } else { + device_unregister(&adev->dev); + }
Quoted 8 lines
drivers/soc/qcom/Kconfig static void of_register_apr_devices(struct device · line 384
Quoted 6 lines
drivers/soc/qcom/Kconfig +5
-0+ + return 0; +} + +static int apr_pd_status(struct pdr_handle *pdr, struct pdr_service *pds)Why is the pdr status function returning an int?
yes since I am not using the
return value in pdr_helpers
will make it void.
Quoted 17 lines
Quoted 16 lines
drivers/soc/qcom/Kconfig +15
-0+{ + struct apr *apr = container_of(pdr, struct apr, pdr); + + switch (pds->state) { + case SERVREG_SERVICE_STATE_UP: + of_register_apr_devices(apr->dev, pds->service_path); + break; + case SERVREG_SERVICE_STATE_DOWN: + device_for_each_child(apr->dev, pds->service_path, + apr_remove_device); + break; + } + + return 0; +}[..]
Quoted 10 lines
drivers/soc/qcom/Kconfig static int apr_probe(struct rpmsg_device *rpdev) · line 427
Quoted 8 lines
drivers/soc/qcom/Kconfig +4
-0@@ -343,20 +421,19 @@ static int apr_probe(struct rpmsg_device *rpdev) return -ENOMEM; } INIT_WORK(&apr->rx_work, apr_rxwq); + + ret = pdr_handle_init(&apr->pdr, apr_pd_status); + if (ret) { + dev_err(dev, "Failed to init PDR handle\n");You need to destroy
apr->rxwqhere as well.
sry missed this
Quoted 15 lines
drivers/soc/qcom/Kconfig static int apr_probe(struct rpmsg_device *rpdev) · line 353
Quoted 12 lines
drivers/soc/qcom/Kconfig +3
-4+ return ret; + } + INIT_LIST_HEAD(&apr->rx_list); spin_lock_init(&apr->rx_lock); spin_lock_init(&apr->svcs_lock); idr_init(&apr->svcs_idr); - of_register_apr_devices(dev); - - return 0; -}Regards,
Bjorn
PATCH 3/3 soc: qcom: apr: Add avs/audio tracking functionality
In reply to a message not in the archiveUse PDR helper functions to track the protection domains that the apr services are dependent upon on SDM845 SoC, specifically the "avs/audio" service running on ADSP Q6.
--- drivers/soc/qcom/Kconfig | 1 + drivers/soc/qcom/apr.c | 100 +++++++++++++++++++++++++++++++---- include/linux/soc/qcom/apr.h | 1 + 3 files changed, 91 insertions(+), 11 deletions(-)
drivers/soc/qcom/Kconfig +1 -0
@@ -202,6 +202,7 @@ config QCOM_APR tristate "Qualcomm APR Bus (Asynchronous Packet Router)" depends on ARCH_QCOM || COMPILE_TEST depends on RPMSG + select QCOM_PDR_HELPERS help Enable APR IPC protocol support between application processor and QDSP6. APR is
drivers/soc/qcom/apr.c +89 -11
153 lines not on this page · raw message
include/linux/soc/qcom/apr.h +1 -0
@@ -85,6 +85,7 @@ struct apr_device {uint16_t domain_id;uint32_t version;char name[APR_NAME_SIZE ]; +const char *service_path;spinlock_t lock;struct list_head node; };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
A message that is not in the archive (sent off-list or not yet received): 0101016e7ee9c591-d04928e8-6440-488c-a956-3b5c9b8988bf-000000@us-west-2.amazonses.com
Rob Herring
maintainerRe: [PATCH 2/3] dt-bindings: soc: qcom: apr: Add protection domain bindings
Quoted 14 lines · Sibi Sankar
Add optional "qcom,protection-domain" bindings for APR services. This helps to capture the dependencies between APR services and the PD on which each apr service run.
Signed-off-by Sibi Sankar <[email protected]>--- .../devicetree/bindings/soc/qcom/qcom,apr.txt | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+)Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt +0
-0
Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt by the individual bindings for the specific service · line 52
Quoted 8 lines
Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt +5
-0@@ -45,6 +45,12 @@ by the individual bindings for the specific service 12 - Ultrasound stream manager. 13 - Listen stream manager. +- qcom,protection-domain + Usage: optional + Value type: <stringlist> + Definition: Must list the protection domain service name and path + that the particular apr service has a dependency on.
Is name and path 2 values? Length is always 2?
You've got the same values for every case in the example. Is there a defined list of possible values?
Quoted 65 lines
Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt +54
-0+ = EXAMPLE The following example represents a QDSP based sound card on a MSM8996 device which uses apr as communication between Apps and QDSP.@@ -82,3 +88,56 @@ which uses apr as communication between Apps and QDSP. }; }; + += EXAMPLE 2 +The following example represents a QDSP based sound card on SDM845 device. +Here the apr services are dependent on "avs/audio" service running on AUDIO +Protection Domain hosted on ADSP remote processor. + + apr { + compatible = "qcom,apr-v2"; + qcom,glink-channels = "apr_audio_svc"; + qcom,apr-domain = <APR_DOMAIN_ADSP>; + + q6core { + compatible = "qcom,q6core"; + reg = <APR_SVC_ADSP_CORE>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + }; + + q6afe: q6afe { + compatible = "qcom,q6afe"; + reg = <APR_SVC_AFE>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6afedai: dais { + compatible = "qcom,q6afe-dais"; + #sound-dai-cells = <1>; + + qi2s@22 { + reg = <22>; + qcom,sd-lines = <3>; + }; + }; + }; + + q6asm: q6asm { + compatible = "qcom,q6asm"; + reg = <APR_SVC_ASM>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6asmdai: dais { + compatible = "qcom,q6asm-dais"; + #sound-dai-cells = <1>; + iommus = <&apps_smmu 0x1821 0x0>; + }; + }; + + q6adm: q6adm { + compatible = "qcom,q6adm"; + reg = <APR_SVC_ADM>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6routing: routing { + compatible = "qcom,q6adm-routing"; + #sound-dai-cells = <0>; + }; + }; + };Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 2/3] dt-bindings: soc: qcom: apr: Add protection domain bindings
Hey Rob,
Thanks for the review :)
Quoted 18 lines · Rob Herring
Quoted 17 lines · Sibi Sankar
Add optional "qcom,protection-domain" bindings for APR services. This helps to capture the dependencies between APR services and the PD on which each apr service run.
Signed-off-by Sibi Sankar <[email protected]>--- .../devicetree/bindings/soc/qcom/qcom,apr.txt | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+)Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt +0
-0@@ -45,6 +45,12 @@ by the individual bindings for the specific service 12 - Ultrasound stream manager. 13 - Listen stream manager.
Quoted 7 lines
Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt by the individual bindings for the specific service · line 52
Quoted 5 lines
Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt +5
-0+- qcom,protection-domain + Usage: optional + Value type: <stringlist> + Definition: Must list the protection domain service name and path + that the particular apr service has a dependency on.Is name and path 2 values? Length is always 2?
Yes the length is always 2 values i.e service name and the path where the service is hosted.
Quoted 3 lines
You've got the same values for every case in the example. Is there a defined list of possible values?
apr bus is expected to track just the "avs/audio" running on msm/adsp/audio_pd on msm8998 and sdm845 SoCs. So shouldn't make much sense to list all possible service names:paths here.
However the qcom,protection-domain is expected to be used on fastrpc compute bank nodes as well, where they track other services:paths. I'll make sure to include all the possible values that fastrpc cb nodes depend on.
Quoted 66 lines
Quoted 66 lines
Documentation/devicetree/bindings/soc/qcom/qcom,apr.txt +54
-0+ = EXAMPLE The following example represents a QDSP based sound card on a MSM8996 device which uses apr as communication between Apps and QDSP.@@ -82,3 +88,56 @@ which uses apr as communication between Apps and QDSP. }; }; + += EXAMPLE 2 +The following example represents a QDSP based sound card on SDM845 device. +Here the apr services are dependent on "avs/audio" service running on AUDIO +Protection Domain hosted on ADSP remote processor. + + apr { + compatible = "qcom,apr-v2"; + qcom,glink-channels = "apr_audio_svc"; + qcom,apr-domain = <APR_DOMAIN_ADSP>; + + q6core { + compatible = "qcom,q6core"; + reg = <APR_SVC_ADSP_CORE>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + }; + + q6afe: q6afe { + compatible = "qcom,q6afe"; + reg = <APR_SVC_AFE>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6afedai: dais { + compatible = "qcom,q6afe-dais"; + #sound-dai-cells = <1>; + + qi2s@22 { + reg = <22>; + qcom,sd-lines = <3>; + }; + }; + }; + + q6asm: q6asm { + compatible = "qcom,q6asm"; + reg = <APR_SVC_ASM>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6asmdai: dais { + compatible = "qcom,q6asm-dais"; + #sound-dai-cells = <1>; + iommus = <&apps_smmu 0x1821 0x0>; + }; + }; + + q6adm: q6adm { + compatible = "qcom,q6adm"; + reg = <APR_SVC_ADM>; + qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd"; + q6routing: routing { + compatible = "qcom,q6adm-routing"; + #sound-dai-cells = <0>; + }; + }; + };Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Signature · 3 lines
Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc, is a member of Code Aurora Forum, a Linux Foundation Collaborative Project