From patchwork Wed Dec 20 06:02:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 181475 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2445342dyi; Tue, 19 Dec 2023 22:11:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQUSPiH9S7HVcQdHkhKMUhOvZKuv/2WkKGkyLo2rqwCESivJGktJnwwT0dj5Gd9BqEQKJ0 X-Received: by 2002:a50:d602:0:b0:553:84c0:1797 with SMTP id x2-20020a50d602000000b0055384c01797mr1492003edi.62.1703052709358; Tue, 19 Dec 2023 22:11:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703052709; cv=none; d=google.com; s=arc-20160816; b=z5/QEy5ea1041Lh9VK8v5hJHu7kfmH13jxyB+UMtfKV5MDpHQRuAGmFO1ydgt0cmIK JGfRE04cAFIaBKGmFLONSq2qCkTWg7aHkzQMpvRnAnuC9BjBhFlL3aq8pXDa3NlTj8vI uouDKyRPlVkLE+gY39+Cb21V22blc6Q+stwZFbzWDBgobUY3dB6Lt5jGb53sil+oOwXb md2IH9JzJV/ls8avnvrQ4WZ2yQr7XTrc9bpsOnYg2qGbBAaynbS+RIg4LoFM7FLJz8Ul crPkZ5iZ0LwI9CCtlzG/9XprMhgER+64nMGvBtA7AKKck1HwrA6Yn0GuYxPNswMM00KI Qp0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JrVRyZ96yUrBQQjgIufDAqTRtO5j55EQwDj2xFPFFbM=; fh=ajqwJHB27W/J8EhLqkTAR2+yy30uzELfRT2VzGpH0WI=; b=F3uTLlMDvDb1DOoIlNoPEM9J5wdT+SwskeVanga8PPaesR1foVe09jZu4qNHDXpS5I 1wCM0k2eZTSPR5QwGcWMSPHmEna4McR78gLHsgQazRR/6x6s5+ce8/uAfoQmiTvWEWlh 3arkn1iLwZSodUjuoTOcwF60iIoSytqO+/O1ZhKzzvO1wZDZSBTaI43zMyiTO6Rzvl7n Ws94ci0g1EuVGxt3trmdBxgW3/szbouyriSTgoZh5xF/yHZEhk2hSQeJV1qlGDkvi3hy I7f0aaxDn6sRxwJTXKQZYZo0/0fI/Js4BIAZmeLhyBG2GYVIWajEBAgD3rHsgaGsTkJj nXiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=B3rdraeO; spf=pass (google.com: domain of linux-kernel+bounces-6400-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6400-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c18-20020a05640227d200b0054cb3786d5dsi12030415ede.393.2023.12.19.22.11.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 22:11:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6400-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=B3rdraeO; spf=pass (google.com: domain of linux-kernel+bounces-6400-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6400-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 46C121F28434 for ; Wed, 20 Dec 2023 06:05:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C3001EB5F; Wed, 20 Dec 2023 06:03:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="B3rdraeO" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42EA110A36; Wed, 20 Dec 2023 06:03:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BK61KHh019634; Wed, 20 Dec 2023 06:02:48 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=JrVRyZ96yUrBQQjgIufD AqTRtO5j55EQwDj2xFPFFbM=; b=B3rdraeOmddSFxlwGKM4YQleLbKUBC/VB+N3 cSs6rx54H76BHCJ93Rw7R0JEN9AQOiyr7eknvZS75gSHODituF0aYpkXb6BJJ9z6 158vQwgMeatKzTizXHEijazKFu2Z2DKteeOJArb6S3lEkw+k38luLNBRJzFcG90i nf3pyJ41+EgRQSzV1JxXiNuotHpdC4xQ6nxI9uz4/Lgnnq/GRCuBxqmXUDU44DaX 1T0Hzr1TrCL5/Ox/V7+6vgGbyYW/CPhYW0TNjSwY2oN9KrGPi6Tkie7+3z60CwTd x+eqycuII8RVp0x8hCi6Z93HC4SPGjfW3BG3IUq4zw56RN4lZA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3v3tmm0040-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Dec 2023 06:02:47 +0000 (GMT) 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 3BK62kFM023280 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Dec 2023 06:02:47 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; Tue, 19 Dec 2023 22:02:46 -0800 From: Georgi Djakov To: , , , , , CC: , , , , , , , , , , , Subject: [PATCH v3 2/9] iommu/arm-smmu-qcom: Add support for TBUs Date: Tue, 19 Dec 2023 22:02:29 -0800 Message-ID: <20231220060236.18600-3-quic_c_gdjako@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231220060236.18600-1-quic_c_gdjako@quicinc.com> References: <20231220060236.18600-1-quic_c_gdjako@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 0yXttM7_80DqHKU_wIo5zAGw4ZibtNZn X-Proofpoint-ORIG-GUID: 0yXttM7_80DqHKU_wIo5zAGw4ZibtNZn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 impostorscore=0 mlxscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=999 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312200038 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785780197665360744 X-GMAIL-MSGID: 1785780197665360744 The ARM MMU-500 implements a Translation Buffer Unit (TBU) for each connected master besides a single TCU which controls and manages the address translations. Allow the Qualcomm SMMU driver to probe for any TBU devices that can provide additional debug features like triggering transactions, logging outstanding transactions, snapshot capture etc. The primary use-case would be to get information from a TBU and print it during a context fault. Signed-off-by: Georgi Djakov --- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 9 +++++++++ drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c index 8b04ece00420..581401d6c18a 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c @@ -1,12 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved */ #include #include #include #include +#include #include #include "arm-smmu.h" @@ -446,6 +448,7 @@ static struct arm_smmu_device *qcom_smmu_create(struct arm_smmu_device *smmu, const struct device_node *np = smmu->dev->of_node; const struct arm_smmu_impl *impl; struct qcom_smmu *qsmmu; + int ret; if (!data) return ERR_PTR(-EINVAL); @@ -469,6 +472,12 @@ static struct arm_smmu_device *qcom_smmu_create(struct arm_smmu_device *smmu, qsmmu->smmu.impl = impl; qsmmu->cfg = data->cfg; + INIT_LIST_HEAD(&qsmmu->tbu_list); + mutex_init(&qsmmu->tbu_list_lock); + ret = devm_of_platform_populate(smmu->dev); + if (ret) + return ERR_PTR(ret); + return &qsmmu->smmu; } diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h index 593910567b88..2164a9cf3dde 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _ARM_SMMU_QCOM_H @@ -12,6 +12,8 @@ struct qcom_smmu { bool bypass_quirk; u8 bypass_cbndx; u32 stall_enabled; + struct mutex tbu_list_lock; /* protects tbu_list */ + struct list_head tbu_list; }; enum qcom_smmu_impl_reg_offset {