Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp369021rdb; Tue, 19 Dec 2023 22:03:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVrAcBBW3biqMWGWmN3L3WLP7CcRRnPB4bGHJqmlw81rzWKiKdNVgAivQdDfoy7z1/cR0C X-Received: by 2002:a05:6214:cce:b0:67f:61ca:2e46 with SMTP id 14-20020a0562140cce00b0067f61ca2e46mr2792534qvx.21.1703052230732; Tue, 19 Dec 2023 22:03:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703052230; cv=none; d=google.com; s=arc-20160816; b=q8LaeKfZsy6djXG75wuyHBgSWERONbI1GnM8pv7aiYOVocxVDQNSn7jgEV0PU7lA1Q nz6A0BeYd9cP0ZI7WVLAMVwZI2ryMU+3pD2k2VQdGESRQ4+vmvWa1fp0bqYC1rEcHBHt RpPcGNjcuAhHG20Q38tiKFNMPIAbQkBJOep6FyD31qkY+TYhtQZef8FguFja2KGr79SB RN21BHRj1P4biQunuxD/peYjo590UEwk6YZPzZnx2oPyH8MZnNWVmsvonied+2p458VK pUGiQQ2spB8/M/ePmOUlOaQ58y2VR9w+YVRkUG0rVIZr7FWYaAG/1O5KbExh6XOTr/fE FpVw== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6400-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z10-20020a0cf00a000000b0067f2cf624b7si8781572qvk.588.2023.12.19.22.03.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 22:03:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6400-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6400-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7C73B1C24220 for ; Wed, 20 Dec 2023 06:03:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 661761773A; Wed, 20 Dec 2023 06:03:03 +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 Content-Type: text/plain 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 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 {