From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DCB0C433DF for ; Wed, 13 May 2020 18:39:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8572205CB for ; Wed, 13 May 2020 18:39:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="KCYMCu0N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390174AbgEMSj4 (ORCPT ); Wed, 13 May 2020 14:39:56 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:39986 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389724AbgEMSj4 (ORCPT ); Wed, 13 May 2020 14:39:56 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1589395194; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=jCjI/gfur3KFMSkfL+KsuB3WZ9C3iTq+gW/Y6HRbx7U=; b=KCYMCu0NJDaCvHyeQ1nC1pfnBMvITGvy5b9ys6fIJ0NM8SgSDDg693zAq1joJkaCe/QLXCAG m+0I/TjCn11+zKn/nF++7vf0+X53ZoZQu8XLjL316FbIEhlbUsnw9Rg6SXP48TVt793KJ+mR baQMxwWvRVHNTYs2VY1VkTbELc0= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5ebc3eee.7fe5ffe3ba78-smtp-out-n05; Wed, 13 May 2020 18:39:42 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 3D8E0C433BA; Wed, 13 May 2020 18:39:42 +0000 (UTC) Received: from [10.46.162.249] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: hemantk) by smtp.codeaurora.org (Postfix) with ESMTPSA id B6A1EC433D2; Wed, 13 May 2020 18:39:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B6A1EC433D2 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=hemantk@codeaurora.org Subject: Re: [PATCH v1 3/5] bus: mhi: core: Skip handling BHI irq if MHI reg access is not allowed To: Manivannan Sadhasivam Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, jhugo@codeaurora.org, bbhatt@codeaurora.org References: <1589248989-23824-1-git-send-email-hemantk@codeaurora.org> <1589248989-23824-4-git-send-email-hemantk@codeaurora.org> <20200512065349.GE4928@Mani-XPS-13-9360> <5e9a15ed-4bad-744a-af07-b28c3bcc47c4@codeaurora.org> <20200513070402.GA26866@Mani-XPS-13-9360> From: Hemant Kumar Message-ID: Date: Wed, 13 May 2020 11:39:40 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20200513070402.GA26866@Mani-XPS-13-9360> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Hi Mani, On 5/13/20 12:04 AM, Manivannan Sadhasivam wrote: > On Tue, May 12, 2020 at 05:28:45PM -0700, Hemant Kumar wrote: >> Hi Mani, >> >> On 5/11/20 11:53 PM, Manivannan Sadhasivam wrote: >>> On Mon, May 11, 2020 at 07:03:07PM -0700, Hemant Kumar wrote: >>>> Driver continues handling of BHI interrupt even if MHI register access >>>> is not allowed. By doing so it calls the status call back and performs >>>> early notification for the MHI client. This is not needed when MHI >>>> register access is not allowed. Hence skip the handling in this case and >>>> return. Also add debug log to print device state, local EE and device EE >>>> when reg access is valid. >>>> >>>> Signed-off-by: Hemant Kumar >>>> Reviewed-by: Jeffrey Hugo >>>> --- >>>> drivers/bus/mhi/core/main.c | 21 ++++++++++++++------- >>>> 1 file changed, 14 insertions(+), 7 deletions(-) >>>> >>>> diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c >>>> index 9ec9b36..467c0ba 100644 >>>> --- a/drivers/bus/mhi/core/main.c >>>> +++ b/drivers/bus/mhi/core/main.c >>>> @@ -369,22 +369,29 @@ irqreturn_t mhi_irq_handler(int irq_number, void *dev) >>>> return IRQ_HANDLED; >>>> } >>>> -irqreturn_t mhi_intvec_threaded_handler(int irq_number, void *dev) >>>> +irqreturn_t mhi_intvec_threaded_handler(int irq_number, void *priv) >>>> { >>>> - struct mhi_controller *mhi_cntrl = dev; >>>> + struct mhi_controller *mhi_cntrl = priv; >>>> + struct device *dev = &mhi_cntrl->mhi_dev->dev; >>>> enum mhi_state state = MHI_STATE_MAX; >>>> enum mhi_pm_state pm_state = 0; >>>> enum mhi_ee_type ee = 0; >>>> write_lock_irq(&mhi_cntrl->pm_lock); >>>> - if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { >>>> - state = mhi_get_mhi_state(mhi_cntrl); >>>> - ee = mhi_cntrl->ee; >>>> - mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl); >>>> + if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { >>>> + write_unlock_irq(&mhi_cntrl->pm_lock); >>> >>> write_lock is only used for protecting 'mhi_cntrl->ee' but here we are not >>> updating it if reg access is not valid. So there is no reason to hold this lock. >> Original code is using write_lock to protect pm_state as well as >> mhi_cntrl->ee. This patch is keeping the lock same as original code. Just if >> condition logic is negated here due to that write_unlock_irq is added under >> if condition. > > 'mhi_cntrl->pm_state' is not always protected by 'pm_lock' and that too > write_lock is used here but 'pm_state' is not modified. So as like in most of > the places, locks are abused here as well. > > I think after 5.8, you should really think about fixing the usage of locks > throughout the MHI stack. > > So I'll take this patch as it is. > Thanks for accepting this patch. Will revisit and review usage of locks in MHI stack and identify areas of improvement. > Thanks, > Mani > >>> >>>> + goto exit_intvec; >>>> } >>>> + state = mhi_get_mhi_state(mhi_cntrl); >>>> + ee = mhi_cntrl->ee; >>>> + mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl); >>> >>> But it is needed here. >>> >>> Thanks, >>> Mani >>> >>>> + dev_dbg(dev, "local ee:%s device ee:%s dev_state:%s\n", >>>> + TO_MHI_EXEC_STR(mhi_cntrl->ee), TO_MHI_EXEC_STR(ee), >>>> + TO_MHI_STATE_STR(state)); >>>> + >>>> if (state == MHI_STATE_SYS_ERR) { >>>> - dev_dbg(&mhi_cntrl->mhi_dev->dev, "System error detected\n"); >>>> + dev_dbg(dev, "System error detected\n"); >>>> pm_state = mhi_tryset_pm_state(mhi_cntrl, >>>> MHI_PM_SYS_ERR_DETECT); >>>> } >>>> -- >>>> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, >>>> a Linux Foundation Collaborative Project >> >> -- >> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, >> a Linux Foundation Collaborative Project -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project