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

Commit f59cfff3 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "diag: Do not fail pcie cb registrations for EEXIST return"

parents cdccc017 721b1771
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -125,6 +125,8 @@ int diag_pcie_register_ops(int proc, int ctx, struct diag_mux_ops *ops)
		return 0;

	pcie_logger.ops[proc] = ops;
	DIAG_LOG(DIAG_DEBUG_MUX,
	"diag: registering pcie for proc: %d\n", proc);
	err = diag_pcie_register(proc, ctx, ops);
	if (err) {
		pr_err("diag: MUX: unable to register pcie operations for proc: %d, err: %d\n",
+42 −14
Original line number Diff line number Diff line
@@ -416,31 +416,41 @@ void diag_pcie_client_cb(struct mhi_dev_client_cb_data *cb_data)
{
	struct diag_pcie_info *pcie_info = NULL;

	if (!cb_data)
	if (!cb_data) {
		pr_err("diag: %s: Invalid cb_data\n", __func__);
		return;

	}
	pcie_info = cb_data->user_data;
	if (!pcie_info)
	if (!pcie_info) {
		pr_err("diag: %s: Invalid pcie_info\n", __func__);
		return;

	}
	switch (cb_data->ctrl_info) {
	case  MHI_STATE_CONNECTED:
		if (cb_data->channel == pcie_info->out_chan) {
			DIAG_LOG(DIAG_DEBUG_MUX,
				" Received connect event from MHI for %d",
				"diag: Received connect event from MHI for %d\n",
				pcie_info->out_chan);
			if (atomic_read(&pcie_info->enabled)) {
				DIAG_LOG(DIAG_DEBUG_MUX,
				"diag: Channel %d is already enabled\n",
				pcie_info->out_chan);
			if (atomic_read(&pcie_info->enabled))
				return;
			}
			queue_work(pcie_info->wq, &pcie_info->open_work);
		}
		break;
	case MHI_STATE_DISCONNECTED:
		if (cb_data->channel == pcie_info->out_chan) {
			DIAG_LOG(DIAG_DEBUG_MUX,
				" Received disconnect event from MHI for %d",
				"diag: Received disconnect event from MHI for %d\n",
				pcie_info->out_chan);
			if (!atomic_read(&pcie_info->enabled)) {
				DIAG_LOG(DIAG_DEBUG_MUX,
				"diag: Channel %d is already disabled\n",
				pcie_info->out_chan);
			if (!atomic_read(&pcie_info->enabled))
				return;
			}
			queue_work(pcie_info->wq, &pcie_info->close_work);
		}
		break;
@@ -490,12 +500,9 @@ static void diag_pcie_connect(struct diag_pcie_info *ch)
	queue_work(ch->wq, &(ch->read_work));
}

void diag_pcie_open_work_fn(struct work_struct *work)
static void diag_pcie_open_channels(struct diag_pcie_info *pcie_info)
{
	int rc = 0;
	struct diag_pcie_info *pcie_info = container_of(work,
						      struct diag_pcie_info,
						      open_work);

	if (!pcie_info || atomic_read(&pcie_info->enabled))
		return;
@@ -540,6 +547,15 @@ void diag_pcie_open_work_fn(struct work_struct *work)
	mutex_unlock(&pcie_info->out_chan_lock);
}

void diag_pcie_open_work_fn(struct work_struct *work)
{
	struct diag_pcie_info *pcie_info = container_of(work,
						      struct diag_pcie_info,
						      open_work);

	diag_pcie_open_channels(pcie_info);
}

/*
 * This function performs pcie connect operations wrt Diag synchronously. It
 * doesn't translate to actual pcie connect. This is used when Diag switches
@@ -679,6 +695,8 @@ int diag_pcie_register(int id, int ctxt, struct diag_mux_ops *ops)
		return -EIO;
	}

	pr_info("diag: Pcie registration initiated for id: %d\n", id);

	ch = &diag_pcie[id];
	ch->ops = ops;
	ch->ctxt = ctxt;
@@ -692,17 +710,27 @@ int diag_pcie_register(int id, int ctxt, struct diag_mux_ops *ops)
	strlcpy(wq_name, "DIAG_PCIE_", sizeof(wq_name));
	strlcat(wq_name, ch->name, sizeof(wq_name));
	ch->wq = create_singlethread_workqueue(wq_name);
	if (!ch->wq)
	if (!ch->wq) {
		pr_err("diag: %s: failed creating workqueue for wq_name: %s\n",
		__func__, wq_name);
		return -ENOMEM;
	}
	DIAG_LOG(DIAG_DEBUG_MUX, "diag: created wq: %s\n", wq_name);
	diagmem_init(driver, ch->mempool);
	mutex_init(&ch->in_chan_lock);
	mutex_init(&ch->out_chan_lock);
	rc = diag_register_pcie_channels(ch);
	if (rc < 0) {
	if (rc == -EEXIST) {
		pr_err("diag: Handled -EEXIST error\n");
		diag_pcie_open_channels(ch);
	} else if (rc < 0 && rc != -EEXIST) {
		if (ch->wq)
			destroy_workqueue(ch->wq);
		kfree(ch->in_chan_attr.read_buffer);
		pr_err("diag: %s: failed registering pcie channels\n",
		__func__);
		return rc;
	}
	pr_info("diag: pcie channel with id: %d registered successfully\n", id);
	return 0;
}