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

Commit 0fae5372 authored by Siddartha Mohanadoss's avatar Siddartha Mohanadoss
Browse files

mhi_dev: mhi: Process PCIe events from a workqueue



Currently MHI initializes MMIO after receiving a callback
from PCIe. Queue the events instead of running from the
callback context as PCIe callbacks maybe called in atomic
context.

Change-Id: I441494d9804ba43ab8982cb40884e494c65cbf89
Signed-off-by: default avatarSiddartha Mohanadoss <smohanad@codeaurora.org>
parent 714bfa4f
Loading
Loading
Loading
Loading
+23 −9
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ static void mhi_ring_init_cb(void *user_data);
static void mhi_update_state_info(uint32_t info);
static int mhi_deinit(struct mhi_dev *mhi);
static void mhi_dev_resume_init_with_link_up(struct ep_pcie_notify *notify);
static int mhi_dev_pcie_notify_event;

void mhi_dev_read_from_host(struct mhi_dev *mhi, struct mhi_addr *transfer)
{
@@ -2492,26 +2493,31 @@ static int mhi_dev_resume_mmio_mhi_init(struct mhi_dev *mhi_ctx)

void mhi_dev_resume_init_with_link_up(struct ep_pcie_notify *notify)
{
	int rc = 0;

	if (!notify) {
	if (!notify || !notify->user) {
		pr_err("Null argument for notify\n");
		return;
	}

	mhi_ctx = notify->user;
	if (!mhi_ctx) {
		pr_err("Invalid mhi_ctx\n");
		return;
	mhi_dev_pcie_notify_event = notify->options;
	mhi_log(MHI_MSG_INFO,
			"PCIe event=0x%x\n", notify->options);
	queue_work(mhi_ctx->pcie_event_wq, &mhi_ctx->pcie_event);
}

	if (notify->options == MHI_INIT) {
static void mhi_dev_pcie_handle_event(struct work_struct *work)
{
	struct mhi_dev *mhi_ctx = container_of(work, struct mhi_dev,
								pcie_event);
	int rc = 0;

	if (mhi_dev_pcie_notify_event == MHI_INIT) {
		rc = mhi_dev_resume_mmio_mhi_init(mhi_ctx);
		if (rc) {
			pr_err("Error during MHI device initialization\n");
			return;
		}
	} else if (notify->options == MHI_REINIT) {
	} else if (mhi_dev_pcie_notify_event == MHI_REINIT) {
		rc = mhi_dev_resume_mmio_mhi_reinit(mhi_ctx);
		if (rc) {
			pr_err("Error during MHI device re-initialization\n");
@@ -2540,6 +2546,14 @@ static int mhi_dev_probe(struct platform_device *pdev)
		mhi_update_state_info(MHI_STATE_CONFIGURED);
	}

	INIT_WORK(&mhi_ctx->pcie_event, mhi_dev_pcie_handle_event);
	mhi_ctx->pcie_event_wq = alloc_workqueue("mhi_dev_pcie_event_wq",
							WQ_HIGHPRI, 0);
	if (!mhi_ctx->pcie_event_wq) {
		rc = -ENOMEM;
		return rc;
	}

	mhi_ctx->phandle = ep_pcie_get_phandle(mhi_ctx->ifc_id);
	if (mhi_ctx->phandle) {
		/* PCIe link is already up */
+2 −0
Original line number Diff line number Diff line
@@ -523,9 +523,11 @@ struct mhi_dev {
	struct work_struct		re_init;

	/* EP PCIe registration */
	struct workqueue_struct		*pcie_event_wq;
	struct ep_pcie_register_event	event_reg;
	u32                             ifc_id;
	struct ep_pcie_hw               *phandle;
	struct work_struct		pcie_event;

	atomic_t			write_active;
	atomic_t			is_suspended;