Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1509066ybk; Thu, 21 May 2020 08:31:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+o2neih1x3hvjROz+Cbs5tLiMnxPmiSWYHiTDkCqsqSriGwYbP7UaKzpNgm5gP5Lgy6/m X-Received: by 2002:a17:906:3b9a:: with SMTP id u26mr4003589ejf.456.1590075092722; Thu, 21 May 2020 08:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590075092; cv=none; d=google.com; s=arc-20160816; b=SoHmAU0uhawhGTPRFZC7TAInqKYudPQ9fHAmOfD/QbytoU2SblJruh8Z4OfkKRKLqr svGf1sB/5ZDQrhzW/f4Pdt6VCb5LbJjJBa5c9tZLV8Oxx54anrUExUFyCsmPdeiqqQay EPQwHPXgH0hTHyxq4Lhe96D2l9eS1F5GiXgjxQEnO7mMZqXIswmg9WStqj1wSTUDOMTD 5Jf+zQKNKOW/AnsO8VIBdzauCjdMCach8sIVMRkHQFRZRRsYS/iNxKxpRIA/njFNutiK oMSs11Vr0VNGwZ83XtsEJRAspYmRxTf4Q8Hpjk0gG5JVTtcL19BiSfGR7BPMghrl7llT A/1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=izUD0cbOZcye+ELdNfkqrzNHWDiToOboBPemwPEri/0=; b=uw6t+wLkjnwpkjfkj0zhMPEyzk9HjYURuYIZw1NzSBEMsRrpgN0SYvNITwWygSXfMd 1o4pOuK7W8col/MrlTpl1TBbb7fj1ZJxNd64hSTmabuBxySDdNnbEacoqe0iF/sJsW0E PKqSskEuIY9kM9TajJAgU8Eu8wwcrIm7F85qgi9t4q3xq/gdWBU2idvKoC/RCmslDNxH NNe10h+31fWyUPrHUmxXjEqhJWEYwLprW/VM+/VYfbPF4/8GwpzxqpBjd4q9ifI2RStE xNYEKSbuA27JyYcGghU1wslS7jzxfFoQDlmfDJ0W74zSz/WseeE73fipZynxp1Ybr2qs ombQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ToEeusDg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk15si2824715ejb.697.2020.05.21.08.31.09; Thu, 21 May 2020 08:31:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ToEeusDg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730287AbgEUP0x (ORCPT + 99 others); Thu, 21 May 2020 11:26:53 -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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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); -- 2.26.GIT