From patchwork Sat Nov 18 04:27:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 166443 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp983879vqn; Fri, 17 Nov 2023 20:29:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IH7iAo+AqC/RIhLbm+YATzyXmbBnjC3mNrxpi5fYRXzHyByK+f8oSnck2oy8M1kAaKOMmZx X-Received: by 2002:a05:6a20:1584:b0:151:35ad:f331 with SMTP id h4-20020a056a20158400b0015135adf331mr1645052pzj.14.1700281768890; Fri, 17 Nov 2023 20:29:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700281768; cv=none; d=google.com; s=arc-20160816; b=DXAmRCKclLz1h5icMOBpoVNWF44Ju9gupgygCxChlPOO0h35QnwVT7JhmpHA0P8kVs lYjlxObqqt40Lggy03olH4sPHTETMv8rIE882BrrggAQ2QGZzWFL4ynRZ1Ztx1wJRB6T xJL3uPGa+mUZfGlK6iu3QD7xHE0ugMi3hc9L7TS28u4GjhlaW4YBiORS6BkqiCNUEFPw vBdgPMhdpjIlOuiJe5FNjagwP94g29Vm9DZpYbAKiOQNNyaY8eRoAX/ldSyr2Uge6qAA cRDDhfyRKafHCU9txyfLUyzWQjhgQ73s8eWRxCm4QLtu1cEuzHdJx63eNf8KJF7pXE6W yJUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=oZpwpALLZVf5oYxfHsoNAR84kMoOdlvkAEAeKd3xYIQ=; fh=ajqwJHB27W/J8EhLqkTAR2+yy30uzELfRT2VzGpH0WI=; b=oyCG97mH+mu+8OlnF10KAi7RqiirqLX7QLBBZyKtzWrzFpDJE+aLNuf5faseMa3nMV irAorhYZEp7YtJz1izVepEp08mFbOvQfSQXic0ip1XmpVoUxAVg6hqSdihZOtILCY0YM VmdxitvQVDIcI4esbXJqNgzv2ms2R9XLdNYghFz9ctFbe2lh6BkAxZi52BkqYDHcfJW8 t+zmQnP2K1oJEzi4FkkFKpU03H4poi9YRRl0ZNOgg9FWyEJcHJD+UCy8DZNA3ZurvNEt wO58fi8mNPh/CZxrxZfiL6RhXkANA/ra884u+cV52vSA/2ICvXk8qSEEH0KJQBDFJp2u Ufwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=UR5caZcv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id a3-20020a631a43000000b005b8615bd40dsi3545502pgm.813.2023.11.17.20.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 20:29:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=UR5caZcv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5165481C36E9; Fri, 17 Nov 2023 20:29:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229789AbjKRE21 (ORCPT + 29 others); Fri, 17 Nov 2023 23:28:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233008AbjKRE2K (ORCPT ); Fri, 17 Nov 2023 23:28:10 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EA8810DA; Fri, 17 Nov 2023 20:28:06 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AI4Mmki004987; Sat, 18 Nov 2023 04:27:45 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=oZpwpALLZVf5oYxfHsoNAR84kMoOdlvkAEAeKd3xYIQ=; b=UR5caZcvRLqxff+pK84r6w5W3GBhNGIVdezUyDg3jxICvtDZATA3HZ8nWZzSa97glYQW zU0TmItCW3aSYx/RBViVOl8IUlspFdVmz9cw+JZ5aTz8G4bqYEBZcjFErwRbeGx0fKcj 5eYWZJ1z17GBOniRMQbSs4AiFlsQ0Li2CzlpupKo5K7Sihxy8WV69R4mzGE/ud2gBqC/ Egrx6n5foKFcqu5Nc7BTLhRdpLsWHn8fmxjDs2Rtx/Cfr9cH+KBd7/zy6PzzuM3SdL8p hwynU8k5mWGBbPgs33obBaaKgCw+Yfv8z0yx+w0E8CQ4Mn34e5MopBP+yiegIUuHaDbF xg== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uenc0r1yg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 18 Nov 2023 04:27:45 +0000 Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3AI4RiNG032729 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 18 Nov 2023 04:27:44 GMT Received: from hu-c-gdjako-lv.qualcomm.com (10.49.16.6) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 17 Nov 2023 20:27:43 -0800 From: Georgi Djakov To: , , , , , CC: , , , , , , , , , , , Subject: [PATCH v2 4/6] iommu/arm-smmu: Allow using a threaded handler for context interrupts Date: Fri, 17 Nov 2023 20:27:28 -0800 Message-ID: <20231118042730.2799-5-quic_c_gdjako@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231118042730.2799-1-quic_c_gdjako@quicinc.com> References: <20231118042730.2799-1-quic_c_gdjako@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: nKuik_H_sbSzZ3Z50FpC8LgBu4e9Vu5M X-Proofpoint-ORIG-GUID: nKuik_H_sbSzZ3Z50FpC8LgBu4e9Vu5M X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-18_02,2023-11-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 spamscore=0 suspectscore=0 clxscore=1015 mlxlogscore=964 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311180032 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 17 Nov 2023 20:29:26 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782874655664370394 X-GMAIL-MSGID: 1782874655664370394 Threaded IRQ handlers run in a less critical context compared to normal IRQs, so they can perform more complex and time-consuming operations without causing significant delays in other parts of the kernel. During a context fault, it might be needed to do more processing and gather debug information from TBUs in the handler. These operations may sleep, so add an option to use a threaded IRQ handler in these cases. Signed-off-by: Georgi Djakov --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++++++-- drivers/iommu/arm/arm-smmu/arm-smmu.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index d6d1a2a55cc0..a6561bb245ad 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -796,8 +796,16 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, else context_fault = arm_smmu_context_fault; - ret = devm_request_irq(smmu->dev, irq, context_fault, - IRQF_SHARED, "arm-smmu-context-fault", domain); + if (smmu->impl && smmu->impl->context_fault_needs_threaded_irq) + ret = devm_request_threaded_irq(smmu->dev, irq, NULL, + context_fault, + IRQF_ONESHOT | IRQF_SHARED, + "arm-smmu-context-fault", + domain); + else + ret = devm_request_irq(smmu->dev, irq, context_fault, + IRQF_SHARED, "arm-smmu-context-fault", domain); + if (ret < 0) { dev_err(smmu->dev, "failed to request context IRQ %d (%u)\n", cfg->irptndx, irq); diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h index e5df65c0f81a..09f11f942ff8 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h @@ -439,6 +439,7 @@ struct arm_smmu_impl { int (*def_domain_type)(struct device *dev); irqreturn_t (*global_fault)(int irq, void *dev); irqreturn_t (*context_fault)(int irq, void *dev); + bool context_fault_needs_threaded_irq; int (*alloc_context_bank)(struct arm_smmu_domain *smmu_domain, struct arm_smmu_device *smmu, struct device *dev, int start);