From patchwork Thu Oct 19 02:19:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 155254 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp118390vqb; Wed, 18 Oct 2023 19:20:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdXurWQ16w8w3Ta7/gowx8MR4BMXqm7fkpZzhxi1XbeoG5kXUTsh0aCyGVTtmoIwaheF3F X-Received: by 2002:a05:6a00:189c:b0:691:2d4:23b2 with SMTP id x28-20020a056a00189c00b0069102d423b2mr886503pfh.15.1697682015882; Wed, 18 Oct 2023 19:20:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697682015; cv=none; d=google.com; s=arc-20160816; b=QHrtowl1K1mgewu4TKG9Lk2q1GAYoXDGHvsHFZVov44GuEhwLlW1uafUFicFv9IFKP byFJvO32QKPoe7g+ZL74qOKv3TJu8ctLpKsnKgLszfyGLdTn+Qszwc2nUWoTZhP5La7w 2SLTHU0BK5HcBPg4SUhNHxFcsxMmptS070Vw9GPxOhH4ESrSeLOWCpX0RyZJBx84u9FO Ymwtj9djdQJt4l3Js2/yIS25DydCPVbZY6wjAmJIprJIDd7uV3jbawslJlAfPphtMwAc 0Z98nbw1o4ta4MsLmyjmyDfGJa8tdDFHGfYhBITISTcplOdbTnVYThj6DXonKctT9V8A XvXQ== 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=rSZyjBns+k9ApsVQaas5ctcturc6JQrl8dAUcAP5WfI=; fh=ajqwJHB27W/J8EhLqkTAR2+yy30uzELfRT2VzGpH0WI=; b=EtmfFXaLwAT6ycQTs6NHPf6FobihKdgg47p4jsfzWp3sVduZEsgEGTof/67bnzwE7s nTkUUAjrZhwMnppakVGVLK8f3y3sUY7/2aaRXfR9OKyk0cOqoKz+kl+WMtvPrp1rqRFY gVz1/CZIMceSmXB4pSBG0WXOAo9N/bz6nGnfngHrsUS6xKm3M0nfQlWd0fweJrocQuhR BzR1CeWi70ZZuT+FNP4P8fAYBXBeeu8YdYOCGZXJMyx5nCFyKoQ8hO0n2LRth4H5nf3L n64++fvMJTdF6BZAr/FgQLIc76gF0E5Hgo7X0yxkwgaq9MPnFzMqOmxgBYXTh+aoYM5X 6wIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=bBMCDIPb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id d20-20020a056a0024d400b0068ff3a3c9d0si5601248pfv.91.2023.10.18.19.20.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 19:20:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=bBMCDIPb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 1412A8216902; Wed, 18 Oct 2023 19:20:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232387AbjJSCUK (ORCPT + 24 others); Wed, 18 Oct 2023 22:20:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232385AbjJSCUE (ORCPT ); Wed, 18 Oct 2023 22:20:04 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B497D114; Wed, 18 Oct 2023 19:20:02 -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 39J2JLLn021860; Thu, 19 Oct 2023 02:19:43 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=rSZyjBns+k9ApsVQaas5ctcturc6JQrl8dAUcAP5WfI=; b=bBMCDIPbLCPjtJi08uTga0emi1Ca6MBJ+iP5HWodEu+Pad3RXHXqfSZ3aXhMdTJkWE97 et5WRGwxwT7clguvrLExJhO8ayuRTsQ0DWTYR7myGoNwEuelMZJh7WHkea17nsTMQD1e vkWcUBD3KCZc1+rIw/3FBYIBI+vt/lzF5yUvnGxPeA9CMZYh9wLbuNcd29+CXD/tnoOZ ytVJ65wkASWy/usl8Z3uhW2H8oqpjXWuUfhALm1HmSJjzgJX+ncYDWvu/FmFroZQBC8v 1iULpi5ucO9UYgePOZId4qILeJK18HUlf55CLdeB8P+jHKPQKBQmEZGLJ0OwC0HJQRTY uQ== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tt8xsam22-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Oct 2023 02:19:43 +0000 Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39J2Jg3V023043 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Oct 2023 02:19:42 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.39; Wed, 18 Oct 2023 19:19:41 -0700 From: Georgi Djakov To: , , , , , CC: , , , , , , , , , , , Subject: [PATCH 4/6] iommu/arm-smmu: Allow using a threaded handler for context interrupts Date: Wed, 18 Oct 2023 19:19:21 -0700 Message-ID: <20231019021923.13939-5-quic_c_gdjako@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231019021923.13939-1-quic_c_gdjako@quicinc.com> References: <20231019021923.13939-1-quic_c_gdjako@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) 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: FGv9foiXPH_io7IIJ0_yJu0rjt2_hGh_ X-Proofpoint-ORIG-GUID: FGv9foiXPH_io7IIJ0_yJu0rjt2_hGh_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-19_02,2023-10-18_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 suspectscore=0 clxscore=1015 impostorscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxlogscore=957 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310190018 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 18 Oct 2023 19:20:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780148617732755817 X-GMAIL-MSGID: 1780148617732755817 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);