Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a40e910d authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: qmi: Match service version and instance during lookup"

parents c94a306f 18804516
Loading
Loading
Loading
Loading
+19 −9
Original line number Diff line number Diff line
@@ -172,37 +172,44 @@ int qmi_recv_msg(struct qmi_handle *handle);
 * qmi_connect_to_service() - Connect the QMI handle with a QMI service
 * @handle: QMI handle to be connected with the QMI service.
 * @service_id: Service id to identify the QMI service.
 * @instance_id: Instance id to identify the instance of the QMI service.
 * @service_vers: Version to identify the compatibility.
 * @service_ins: Instance id to identify the instance of the QMI service.
 *
 * @return: 0 on success, < 0 on error.
 */
int qmi_connect_to_service(struct qmi_handle *handle,
			   uint32_t service_id, uint32_t instance_id);
			   uint32_t service_id,
			   uint32_t service_vers,
			   uint32_t service_ins);

/**
 * qmi_svc_event_notifier_register() - Register a notifier block to receive
 *                                     events regarding a QMI service
 * @service_id: Service ID to identify the QMI service.
 * @instance_id: Instance ID to identify the instance of the QMI service.
 * @service_vers: Version to identify the compatibility.
 * @service_ins: Instance ID to identify the instance of the QMI service.
 * @nb: Notifier block used to receive the event.
 *
 * @return: 0 if successfully registered, < 0 on error.
 */
int qmi_svc_event_notifier_register(uint32_t service_id,
				    uint32_t instance_id,
				    uint32_t service_vers,
				    uint32_t service_ins,
				    struct notifier_block *nb);

/**
 * qmi_svc_event_notifier_unregister() - Unregister service event
 *                                       notifier block
 * @service_id: Service ID to identify the QMI service.
 * @instance_id: Instance ID to identify the instance of the QMI service.
 * @service_vers: Version to identify the compatibility.
 * @service_ins: Instance ID to identify the instance of the QMI service.
 * @nb: Notifier block registered to receive the events.
 *
 * @return: 0 if successfully registered, < 0 on error.
 */
int qmi_svc_event_notifier_unregister(uint32_t service_id,
				      uint32_t instance_id,
				      uint32_t service_vers,
				      uint32_t service_ins,
				      struct notifier_block *nb);
#else

@@ -260,20 +267,23 @@ static inline int qmi_recv_msg(struct qmi_handle *handle)

static inline int qmi_connect_to_service(struct qmi_handle *handle,
					 uint32_t service_id,
					 uint32_t instance_id)
					 uint32_t service_vers,
					 uint32_t service_ins)
{
	return -ENODEV;
}

static inline int qmi_svc_event_notifier_register(uint32_t service_id,
						  uint32_t instance_id,
						  uint32_t service_vers,
						  uint32_t service_ins,
						  struct notifier_block *nb)
{
	return -ENODEV;
}

static inline int qmi_svc_event_notifier_unregister(uint32_t service_id,
						    uint32_t instance_id,
						    uint32_t service_vers,
						    uint32_t service_ins,
						    struct notifier_block *nb)
{
	return -ENODEV;
+20 −5
Original line number Diff line number Diff line
@@ -33,6 +33,9 @@

#include "msm_qmi_interface_priv.h"

#define BUILD_INSTANCE_ID(vers, ins) (((vers) & 0xFF) | (((ins) & 0xFF) << 8))
#define LOOKUP_MASK 0xFFFFFFFF

static LIST_HEAD(svc_event_nb_list);
static DEFINE_MUTEX(svc_event_nb_list_lock);
static DEFINE_MUTEX(msm_qmi_init_lock);
@@ -628,12 +631,15 @@ int qmi_recv_msg(struct qmi_handle *handle)
EXPORT_SYMBOL(qmi_recv_msg);

int qmi_connect_to_service(struct qmi_handle *handle,
			   uint32_t service_id, uint32_t instance_id)
			   uint32_t service_id,
			   uint32_t service_vers,
			   uint32_t service_ins)
{
	struct msm_ipc_port_name svc_name;
	struct msm_ipc_server_info svc_info;
	struct msm_ipc_addr *svc_dest_addr;
	int rc;
	uint32_t instance_id;

	if (!handle)
		return -EINVAL;
@@ -645,12 +651,15 @@ int qmi_connect_to_service(struct qmi_handle *handle,
		return -ENOMEM;
	}

	instance_id = BUILD_INSTANCE_ID(service_vers, service_ins);
	svc_name.service = service_id;
	svc_name.instance = instance_id;

	rc = msm_ipc_router_lookup_server_name(&svc_name, &svc_info, 1, 0xFF);
	rc = msm_ipc_router_lookup_server_name(&svc_name, &svc_info,
						1, LOOKUP_MASK);
	if (rc <= 0) {
		pr_err("%s: Server not found\n", __func__);
		pr_err("%s: Server %08x:%08x not found\n",
			__func__, service_id, instance_id);
		return -ENODEV;
	}
	svc_dest_addr->addrtype = MSM_IPC_ADDR_ID;
@@ -783,13 +792,16 @@ static struct svc_event_nb *find_and_add_svc_event_nb(uint32_t service_id,
}

int qmi_svc_event_notifier_register(uint32_t service_id,
				    uint32_t instance_id,
				    uint32_t service_vers,
				    uint32_t service_ins,
				    struct notifier_block *nb)
{
	struct svc_event_nb *temp;
	unsigned long flags;
	int ret;
	uint32_t instance_id;

	instance_id = BUILD_INSTANCE_ID(service_vers, service_ins);
	temp = find_and_add_svc_event_nb(service_id, instance_id);
	if (!temp)
		return -EFAULT;
@@ -813,13 +825,16 @@ int qmi_svc_event_notifier_register(uint32_t service_id,
EXPORT_SYMBOL(qmi_svc_event_notifier_register);

int qmi_svc_event_notifier_unregister(uint32_t service_id,
				      uint32_t instance_id,
				      uint32_t service_vers,
				      uint32_t service_ins,
				      struct notifier_block *nb)
{
	int ret;
	struct svc_event_nb *temp;
	unsigned long flags;
	uint32_t instance_id;

	instance_id = BUILD_INSTANCE_ID(service_vers, service_ins);
	mutex_lock(&svc_event_nb_list_lock);
	temp = find_svc_event_nb(service_id, instance_id);
	if (!temp) {
+3 −0
Original line number Diff line number Diff line
@@ -1184,6 +1184,7 @@ static int ngd_slim_probe(struct platform_device *pdev)
	dev->qmi.nb.notifier_call = ngd_qmi_available;
	pm_runtime_get_noresume(dev->dev);
	ret = qmi_svc_event_notifier_register(SLIMBUS_QMI_SVC_ID,
				SLIMBUS_QMI_SVC_V1,
				SLIMBUS_QMI_INS_ID, &dev->qmi.nb);
	if (ret) {
		pr_err("Slimbus QMI service registration failed:%d", ret);
@@ -1211,6 +1212,7 @@ static int ngd_slim_probe(struct platform_device *pdev)

err_thread_create_failed:
	qmi_svc_event_notifier_unregister(SLIMBUS_QMI_SVC_ID,
				SLIMBUS_QMI_SVC_V1,
				SLIMBUS_QMI_INS_ID, &dev->qmi.nb);
qmi_register_failed:
	free_irq(dev->irq, dev);
@@ -1230,6 +1232,7 @@ static int ngd_slim_remove(struct platform_device *pdev)
	struct msm_slim_ctrl *dev = platform_get_drvdata(pdev);
	ngd_slim_enable(dev, false);
	qmi_svc_event_notifier_unregister(SLIMBUS_QMI_SVC_ID,
				SLIMBUS_QMI_SVC_V1,
				SLIMBUS_QMI_INS_ID, &dev->qmi.nb);
	pm_runtime_disable(&pdev->dev);
	free_irq(dev->irq, dev);
+1 −0
Original line number Diff line number Diff line
@@ -1174,6 +1174,7 @@ int msm_slim_qmi_init(struct msm_slim_ctrl *dev, bool apps_is_master)
	}

	rc = qmi_connect_to_service(handle, SLIMBUS_QMI_SVC_ID,
						SLIMBUS_QMI_SVC_V1,
						SLIMBUS_QMI_INS_ID);
	if (rc < 0) {
		pr_err("%s: QMI server not found\n", __func__);
+2 −1
Original line number Diff line number Diff line
@@ -82,7 +82,8 @@

/* Slimbus QMI service */
#define SLIMBUS_QMI_SVC_ID 0x0301
#define SLIMBUS_QMI_INS_ID 1
#define SLIMBUS_QMI_SVC_V1 1
#define SLIMBUS_QMI_INS_ID 0

#define PGD_THIS_EE(r, v) ((v) ? PGD_THIS_EE_V2(r) : PGD_THIS_EE_V1(r))
#define PGD_PORT(r, p, v) ((v) ? PGD_PORT_V2(r, p) : PGD_PORT_V1(r, p))