From patchwork Tue Apr 4 09:41:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Pernamitta X-Patchwork-Id: 670501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C244C6FD1D for ; Tue, 4 Apr 2023 09:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233860AbjDDJl7 (ORCPT ); Tue, 4 Apr 2023 05:41:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234038AbjDDJl6 (ORCPT ); Tue, 4 Apr 2023 05:41:58 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 001691BC0; Tue, 4 Apr 2023 02:41:57 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 333N1kFO004589; Tue, 4 Apr 2023 09:41:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id; s=qcppdkim1; bh=bv3LqF+vpq1ExVGwlnfJj1L/BJyT8J6hoWyOXdlEXJA=; b=c/UZtHvfqxjNhSQmY95Rzg8497/YSXnxH8PViKiGDXxpFhFgP4PsCmtFrkRCBS5X7gzj zK5R+TjCmWX2OpxpYCVVE6slQl0rsTgRBnLuoq7C/WDBEKPENZEIPq8jpMR6LA2VnSmi VI/u4AEr5kpnMM6FK8dnCgBJhE3Qyf+1rm1C6isrbMhQ0H3ldEHyUcEQxo6S2YsTrR0O SiE2ysX+Ru+Zz7U7MnBqxiv1eD9qWryKcaEbaZK+fnvTuiPlzCpvsFcuGDH7xYQu2fZj lIQ7JUkp2HHtTWJ07p91NSfz2G61u1nqtttooagzkEK8Pggbq6FdDRHfvCkzJNjfr6dT Wg== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pr4jm9nqs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Apr 2023 09:41:21 +0000 Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 3349fGN9026901; Tue, 4 Apr 2023 09:41:16 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 3ppdpkjnk9-1; Tue, 04 Apr 2023 09:41:16 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3349fGdK026896; Tue, 4 Apr 2023 09:41:16 GMT Received: from hu-sgudaval-hyd.qualcomm.com (hu-vpernami-hyd.qualcomm.com [10.213.107.240]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 3349fFNd026895; Tue, 04 Apr 2023 09:41:16 +0000 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 2370923) id 2BB3739CE; Tue, 4 Apr 2023 15:11:15 +0530 (+0530) From: Vivek Pernamitta To: mhi@lists.linux.dev Cc: quic_qianyu@quicinc.com, manivannan.sadhasivam@linaro.org, quic_vbadigan@quicinc.com, quic_krichai@quicinc.com, quic_skananth@quicinc.com, Vivek Pernamitta , Manivannan Sadhasivam , Jeffrey Hugo , Bhaumik Bhatt , Hemant Kumar , linux-arm-msm@vger.kernel.org (open list:MHI BUS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH V5] bus: mhi: host: Avoid ringing EV DB if there is no elements to process Date: Tue, 4 Apr 2023 15:11:10 +0530 Message-Id: <1680601272-8795-1-git-send-email-quic_vpernami@quicinc.com> X-Mailer: git-send-email 2.7.4 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 9scnxs51jytAxu9S6Q1HdGq00Z3LEbho X-Proofpoint-GUID: 9scnxs51jytAxu9S6Q1HdGq00Z3LEbho X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-04_02,2023-04-03_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 bulkscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1011 mlxscore=0 mlxlogscore=818 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304040089 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org curenlty mhi_process_data_event_ring()/mhi_process_ctrl_ev_ring() will ring DB even if there no ring elements to process. This could cause doorbell event to be processed by MHI device to check for any ring elements even it is none. So ring event DB only if any event ring elements are processed. Signed-off-by: Vivek Pernamitta Reviewed-by: Jeffrey Hugo Reviewed-by: Manivannan Sadhasivam --- changes since v5: updating the commit text. changes since v4: updating the commit text with more information. changes since v3: - Updating commit text for multiple versions of patches. changes since v2: - Updated comments in code. changes since v1: - Add an check to avoid ringing EV DB in mhi_process_ctrl_ev_ring(). --- drivers/bus/mhi/host/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index df0fbfe..1bbdb75 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -961,7 +961,9 @@ int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl, } read_lock_bh(&mhi_cntrl->pm_lock); - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl))) + + /* Ring EV DB only if there is any pending element to process */ + if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl)) && count) mhi_ring_er_db(mhi_event); read_unlock_bh(&mhi_cntrl->pm_lock); @@ -1031,7 +1033,9 @@ int mhi_process_data_event_ring(struct mhi_controller *mhi_cntrl, count++; } read_lock_bh(&mhi_cntrl->pm_lock); - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl))) + + /* Ring EV DB only if there is any pending element to process */ + if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl)) && count) mhi_ring_er_db(mhi_event); read_unlock_bh(&mhi_cntrl->pm_lock);