From patchwork Thu May 21 15:25:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11563357 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CAF41391 for ; Thu, 21 May 2020 15:26:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15524207D8 for ; Thu, 21 May 2020 15:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590074817; bh=v/XfBYXoPrjYbHYgPlJHQY5tb/I1IRk35QKBoZMojHQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1c6+Lj0mhZmv8apFpyoeixgPXUdzu5DiaAjKQf3OIhx9sKOMCipgkusyvAjXLL/mC SblKFpx2Relg1iG6QUTtjhpFlmQGA6YNMdJn5d1HeR4Bfe6j2Jd9xbBZb5MZLrHhNZ g5L71/Ty9U+PQmsz4K6hyC4VoVmnLrHj3okBij+o= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729939AbgEUP0w (ORCPT ); Thu, 21 May 2020 11:26:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:34844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727898AbgEUP0v (ORCPT ); Thu, 21 May 2020 11:26:51 -0400 Received: from localhost.localdomain (unknown [157.51.235.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8DE8A204EA; Thu, 21 May 2020 15:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590074810; bh=v/XfBYXoPrjYbHYgPlJHQY5tb/I1IRk35QKBoZMojHQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ToEeusDgM5GQ6jN1ieKEu/mMhPDiPmj6k3SWbH7lowcxJ/R+d4PlpvKy6mREHEqaW 4rvf6MoC0Jk8siYY7FxszSGHlhEQ2t0cDHWRG1LuZq7Wq4EA6FpacRONertoBZeMuM Vf3FVAkyL5ebw3DPcK8F5pIGjJaN0XoD+uGDspFk= From: mani@kernel.org To: gregkh@linuxfoundation.org Cc: hemantk@codeaurora.org, jhugo@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 13/14] bus: mhi: core: Handle write lock properly in mhi_pm_m0_transition Date: Thu, 21 May 2020 20:55:39 +0530 Message-Id: <20200521152540.17335-14-mani@kernel.org> X-Mailer: git-send-email 2.26.GIT In-Reply-To: <20200521152540.17335-1-mani@kernel.org> References: <20200521152540.17335-1-mani@kernel.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Hemant Kumar Take write lock only to protect db_mode member of mhi channel. This allows rest of the mhi channels to just take read lock which fine grains the locking. It prevents channel readers to starve if they try to enter critical section after a writer. Signed-off-by: Hemant Kumar Reviewed-by: Manivannan Sadhasivam Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/pm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c index a5d9973059c8..e6236a3ca39d 100644 --- a/drivers/bus/mhi/core/pm.c +++ b/drivers/bus/mhi/core/pm.c @@ -288,14 +288,18 @@ int mhi_pm_m0_transition(struct mhi_controller *mhi_cntrl) for (i = 0; i < mhi_cntrl->max_chan; i++, mhi_chan++) { struct mhi_ring *tre_ring = &mhi_chan->tre_ring; - write_lock_irq(&mhi_chan->lock); - if (mhi_chan->db_cfg.reset_req) + if (mhi_chan->db_cfg.reset_req) { + write_lock_irq(&mhi_chan->lock); mhi_chan->db_cfg.db_mode = true; + write_unlock_irq(&mhi_chan->lock); + } + + read_lock_irq(&mhi_chan->lock); /* Only ring DB if ring is not empty */ if (tre_ring->base && tre_ring->wp != tre_ring->rp) mhi_ring_chan_db(mhi_cntrl, mhi_chan); - write_unlock_irq(&mhi_chan->lock); + read_unlock_irq(&mhi_chan->lock); } mhi_cntrl->wake_put(mhi_cntrl, false);