From patchwork Wed Jun 7 12:17:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Mylavarapu X-Patchwork-Id: 690227 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 6AA08C7EE29 for ; Wed, 7 Jun 2023 12:18:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240619AbjFGMSL (ORCPT ); Wed, 7 Jun 2023 08:18:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240580AbjFGMSH (ORCPT ); Wed, 7 Jun 2023 08:18:07 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10E26E65; Wed, 7 Jun 2023 05:18:05 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 357B0LMb006329; Wed, 7 Jun 2023 12:18:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=ilmTk6Qn4laTQ5e/YbI/igcb8obrPaVeYG5KEfh+b7U=; b=OlmAecR9gDPNxcZvFH8iDv/2mhFbuBp7FsjX5nYyrdXX2rILKH/TP9gg4dB9bnQ9pfpA BYvI1FWZmfJcuVQ9atrH+TYbzYAuaeQGoCACGGiwOeAEs+J41cNc2z9IlaInRccqobIm Xh03Y9EF1JMMJMgrHiBAHqDOencarFfym5EVwBeIwi1sXVDZpDC+51sT07QJOI0e44Hl +X1QkBV4RfKFsEFJjKsG3pKIAvpV9WGW6H6S/QwwYvy/k71e9omwJozjxpTQ6J6/iBs2 /3sYH5PNoxzckwP0IuOmLoHqpmTlb5HrP+iPkDKhtCHIhu5+KKpT3LdHJcbzWmo7oaCI 7w== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3r2a9thr32-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Jun 2023 12:18:02 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 357CI0GO006993 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 7 Jun 2023 12:18:00 GMT Received: from mmanikan-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 7 Jun 2023 05:17:56 -0700 From: Manikanta Mylavarapu To: , , , , , , CC: , , , , Subject: [PATCH 1/2] rpmsg: glink: change rx work queue type Date: Wed, 7 Jun 2023 17:47:30 +0530 Message-ID: <20230607121731.26958-2-quic_mmanikan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230607121731.26958-1-quic_mmanikan@quicinc.com> References: <20230607121731.26958-1-quic_mmanikan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: mpJym5lT85MU-tRfY1XOmWapXmxG-Byq X-Proofpoint-ORIG-GUID: mpJym5lT85MU-tRfY1XOmWapXmxG-Byq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-07_06,2023-06-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 adultscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306070102 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In case of heavy cpu load, rx worker thread not able to get cpu slot because it's bound to kernel global work queue. Glink client drivers will return timeout error if they didn't receive response within stipulated duration. Changing rx work queue type to UNBOUND workqueue ensures rx worker thread will be executed as early as possible. Signed-off-by: Manikanta Mylavarapu --- drivers/rpmsg/qcom_glink_native.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 1beb40a1d3df..6f9a439e5046 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -81,6 +81,7 @@ struct glink_core_rx_intent { * @rx_pipe: pipe object for receive FIFO * @tx_pipe: pipe object for transmit FIFO * @rx_work: worker for handling received control messages + * @rx_wq: work queue of rx_work * @rx_lock: protects the @rx_queue * @rx_queue: queue of received control messages to be processed in @rx_work * @tx_lock: synchronizes operations on the tx fifo @@ -100,6 +101,7 @@ struct qcom_glink { struct qcom_glink_pipe *tx_pipe; struct work_struct rx_work; + struct workqueue_struct *rx_wq; spinlock_t rx_lock; struct list_head rx_queue; @@ -822,7 +824,7 @@ static int qcom_glink_rx_defer(struct qcom_glink *glink, size_t extra) list_add_tail(&dcmd->node, &glink->rx_queue); spin_unlock(&glink->rx_lock); - schedule_work(&glink->rx_work); + queue_work(glink->rx_wq, &glink->rx_work); qcom_glink_rx_advance(glink, sizeof(dcmd->msg) + extra); return 0; @@ -1665,6 +1667,8 @@ static void qcom_glink_cancel_rx_work(struct qcom_glink *glink) /* cancel any pending deferred rx_work */ cancel_work_sync(&glink->rx_work); + destroy_workqueue(glink->rx_wq); + list_for_each_entry_safe(dcmd, tmp, &glink->rx_queue, node) kfree(dcmd); } @@ -1750,6 +1754,10 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev, INIT_WORK(&glink->rx_work, qcom_glink_work); init_waitqueue_head(&glink->tx_avail_notify); + glink->rx_wq = alloc_workqueue("glink_rx_wq", WQ_UNBOUND, 1); + if (!glink->rx_wq) + return ERR_PTR(-ENOMEM); + spin_lock_init(&glink->idr_lock); idr_init(&glink->lcids); idr_init(&glink->rcids); From patchwork Wed Jun 7 12:17:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Mylavarapu X-Patchwork-Id: 691482 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 D7AE8C7EE25 for ; Wed, 7 Jun 2023 12:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240580AbjFGMSS (ORCPT ); Wed, 7 Jun 2023 08:18:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240628AbjFGMSN (ORCPT ); Wed, 7 Jun 2023 08:18:13 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECDE01FC1; Wed, 7 Jun 2023 05:18:10 -0700 (PDT) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 357BlIW9004954; Wed, 7 Jun 2023 12:18:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=VHE8w+ShAqFQJicL/pWh6KAKyy97L6DwKhrLaJOzP84=; b=XD+IRKlDjwT7E5qWRTxji1l+l1TmoqUOV/IQxWzJsBXDosy89x10O/A1bvPKG0nOyNSM dTKdKQefc4Ck6U6hj/IkqzM22iv8ohptB5pnxnOGGKOE4OW/llTfwNl5EhJ93IwSCFes kykeHBU4znzWeWZSxk6fL6D+m1u6nOHVdYUcGjqI8L7Y+sJ/L11/9JmuyIfTmb8bVcOh ozetSsK2a25GXd38219+y2osqXtSm0m88SfmQMXRA5bUPvxJ+YnXlCPVm0qveAmmPa/j SifPVVA2Yeec92FDRJ7eY2ZYm4UzRpY6ZVmYd0hOfbQUPPbxbF+pP7vXp9x8Yjr2nI7k lA== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3r2a9t9rqb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Jun 2023 12:18:07 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 357CI5wY019704 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 7 Jun 2023 12:18:05 GMT Received: from mmanikan-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 7 Jun 2023 05:18:01 -0700 From: Manikanta Mylavarapu To: , , , , , , CC: , , , , Subject: [PATCH 2/2] rpmsg: glink: change intent work queue type Date: Wed, 7 Jun 2023 17:47:31 +0530 Message-ID: <20230607121731.26958-3-quic_mmanikan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230607121731.26958-1-quic_mmanikan@quicinc.com> References: <20230607121731.26958-1-quic_mmanikan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 0qrEEyXrMliSlsA-jatLlxTXYqgs9687 X-Proofpoint-GUID: 0qrEEyXrMliSlsA-jatLlxTXYqgs9687 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-07_06,2023-06-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 spamscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306070102 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org QDSP6 will clear heap memory once it's received RX_DONE event from APPS. Under heavy cpu load intent worker thread not able to get cpu slot because it's bound to kernel global work queue. Due to this QDSP6 firmware faces OOM and it leads to Q6 crash. Changing intent work queue type to UNBOUND workqueue ensures intent worker thread will be executed as early as possible. Signed-off-by: Manikanta Mylavarapu --- drivers/rpmsg/qcom_glink_native.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 6f9a439e5046..c3e076bb863f 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -140,6 +140,7 @@ enum { * @liids: idr of all local intents * @riids: idr of all remote intents * @intent_work: worker responsible for transmitting rx_done packets + * @intent_wq: work queue of intent_work * @done_intents: list of intents that needs to be announced rx_done * @buf: receive buffer, for gathering fragments * @buf_offset: write offset in @buf @@ -169,6 +170,7 @@ struct glink_channel { struct idr liids; struct idr riids; struct work_struct intent_work; + struct workqueue_struct *intent_wq; struct list_head done_intents; struct glink_core_rx_intent *buf; @@ -231,6 +233,14 @@ static struct glink_channel *qcom_glink_alloc_channel(struct qcom_glink *glink, INIT_LIST_HEAD(&channel->done_intents); INIT_WORK(&channel->intent_work, qcom_glink_rx_done_work); + channel->intent_wq = alloc_workqueue("intent_wq", WQ_UNBOUND, 1); + if (!channel->intent_wq) { + pr_err("failed to create %s channel intent work queue\n", + channel->name); + kfree(channel); + return ERR_PTR(-ENOMEM); + } + idr_init(&channel->liids); idr_init(&channel->riids); kref_init(&channel->refcount); @@ -270,6 +280,7 @@ static void qcom_glink_channel_release(struct kref *ref) idr_destroy(&channel->riids); spin_unlock_irqrestore(&channel->intent_lock, flags); + destroy_workqueue(channel->intent_wq); kfree(channel->name); kfree(channel); } @@ -573,7 +584,7 @@ static void qcom_glink_rx_done(struct qcom_glink *glink, list_add_tail(&intent->node, &channel->done_intents); spin_unlock(&channel->intent_lock); - schedule_work(&channel->intent_work); + queue_work(channel->intent_wq, &channel->intent_work); } /**