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

Commit e3a4f494 authored by Andrei Danaila's avatar Andrei Danaila Committed by Matt Wagantall
Browse files

msm: mhi: Prevent IRQ mask race condition in MHI



Fixed a race condition in MHI RmNet where the RX interrupt
could remain masked forever.

CRs-Fixed: 723355
Change-Id: I9606963b8b2d6d1cb125c0bc7be8610b06f67be3
Signed-off-by: default avatarAndrei Danaila <adanaila@codeaurora.org>
parent 3c6fcc3d
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ struct rmnet_mhi_private {
	u32			      rx_enabled;
	u32			      mhi_enabled;
	struct net_device	      *dev;
	int32_t                       irq_masked_cntr;
	atomic_t		      irq_masked_cntr;
	rwlock_t		      out_chan_full_lock;
};

@@ -310,9 +310,9 @@ static int rmnet_mhi_poll(struct napi_struct *napi, int budget)

	/* We got a NULL descriptor back */
	if (should_reschedule == false) {
		if (rmnet_mhi_ptr->irq_masked_cntr) {
		if (atomic_read(&rmnet_mhi_ptr->irq_masked_cntr)) {
			atomic_dec(&rmnet_mhi_ptr->irq_masked_cntr);
			mhi_unmask_irq(rmnet_mhi_ptr->rx_client_handle);
			--rmnet_mhi_ptr->irq_masked_cntr;
		}
	} else {
		if (received_packets == budget)
@@ -497,7 +497,7 @@ static void rmnet_mhi_rx_cb(struct mhi_result *result)

	if (napi_schedule_prep(&(rmnet_mhi_ptr->napi))) {
		mhi_mask_irq(rmnet_mhi_ptr->rx_client_handle);
		rmnet_mhi_ptr->irq_masked_cntr++;
		atomic_inc(&rmnet_mhi_ptr->irq_masked_cntr);
		__napi_schedule(&(rmnet_mhi_ptr->napi));
	} else {
		rx_interrupts_in_masked_irq[rmnet_mhi_ptr->dev_index]++;
@@ -539,9 +539,9 @@ static int rmnet_mhi_close(struct net_device *dev)
	rmnet_mhi_ptr->mhi_enabled = 0;
	rmnet_mhi_disable_iface(rmnet_mhi_ptr);
	napi_disable(&(rmnet_mhi_ptr->napi));
	if (rmnet_mhi_ptr->irq_masked_cntr) {
	if (atomic_read(&rmnet_mhi_ptr->irq_masked_cntr)) {
		atomic_dec(&rmnet_mhi_ptr->irq_masked_cntr);
		mhi_unmask_irq(rmnet_mhi_ptr->rx_client_handle);
		--rmnet_mhi_ptr->irq_masked_cntr;
	}
	return 0;
}