From patchwork Fri Jan 20 00:51:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Clevenger X-Patchwork-Id: 13109023 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 754F2C38142 for ; Fri, 20 Jan 2023 00:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2h05YQvLvknSmAQz9u+hO581DdZbkfdruT5gzj/0GaE=; b=ycd2J/rF3l28of 6Sc/wbxdmbGYxsAGHeIra0Xk22SCUGeLy5F83LHqlyN4cBbhfAwiTGz9LuMq28oIxnXVesJF6R2G1 74OfUM1zbYFXcHVVyCd/4GiAXY3DKpMrgbO40q5w+8IRcQKOEaoNzwkn93LIa+a/19kod0fvLPwYN 17eGp8RZ8hgOvIyOFkTWiJFmV/erlYSgj4Gh7wDHKefhXxO2UIUzK2cTREHNWJI7O7xNxDeLvd0O2 Ja7CZ6aNFV57t1x7tMTInFfHfKYEghtBz12tD8WnONcb2aAYSAXB7n3NyqLxFDOoRNBSP/m073dXP XF91FIxGU5UHtXDjyLMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIfe0-007oab-O0; Fri, 20 Jan 2023 00:52:36 +0000 Received: from mail-bn1nam02on2103.outbound.protection.outlook.com ([40.107.212.103] helo=NAM02-BN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIfdm-007oXt-TS for linux-arm-kernel@lists.infradead.org; Fri, 20 Jan 2023 00:52:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SYrwpsx54kwdTWNlyk/rd46cFEGkQcWAcwZKL7vusnO57rlN4TgaOTq/0wW/U4oGaTqCbH4bIbrYvJLksVvM7WS9S2UNc0lAf8/jLqecOCyMnZQv4aHnuciiBBs3TAW2gE0IYxys4XkttgHIZ4zGJFBrMDlcDtuyKdDyZbFtRNMAql6ostjpI8y7uhjkPL7na76Azb3oB4+GgArznrQ7xlfcUfeCwJBpGv5fTfRWaRDifdUQuSN8yN9JoTIEpHSkklhhCXbG6of/RuBUyJzJqyIiBkrXNPmk/Prx5Xf+x11bOdhMtfwguwQOE4Qy5Tl3PTDgerwvDMOGdcw6cYdKsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xYHQIV2jn97l7swEo7VfBAhlHaD0wdgvo9nIFbnHIfg=; b=R7IVl7u8sH6GPjKCuHIG4bl+9U/l3EYevsI1XHJl/bVNV6S76LOZ4FrznXSBPoKFexu/1cBWnDmIMehULdDyGk5rsyipOAD3zmFKyG/ALAD5Qe9jWJbKDVY9gr4OnubSX2foB9aWhdjrKkwEdBKVHYwFvWHpSPP2yRQkKHM5TYJJm7Ni5IRaFCajiEbpkvGBRApiOhQxU/eOm64rk1TomLrBsvsWMd8U42hSTlBQ3di7F/MkQgmxEPkHb7kLlL8gFxA+6lzLIhQxwwmpq5TlL2/Z55ZNxDWiFMmHQm/Fy6ZZPLPc6zdGTHQ/UaeAz7KZVmk+wKiMYz00FqmUiMepnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xYHQIV2jn97l7swEo7VfBAhlHaD0wdgvo9nIFbnHIfg=; b=YHX2BuzHfz/e+mKoAn2wLgil3s3a/6W5U0daTxO+CJvhfB+aZFKLoDxmFKzvrqR/S027FDcIJFMAtayOlujhh7iMbtrkCSBdKHvEfPEPFIDjwc/f01gE+wqDXcza2oznsXgbeymTpfEST+YQzj8xsNSPHTa1T7MrI6P6odkdABk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SN2PR01MB2143.prod.exchangelabs.com (2603:10b6:804:d::13) by SN6PR0102MB3407.prod.exchangelabs.com (2603:10b6:805:11::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Fri, 20 Jan 2023 00:52:18 +0000 Received: from SN2PR01MB2143.prod.exchangelabs.com ([fe80::eef8:5973:baee:184c]) by SN2PR01MB2143.prod.exchangelabs.com ([fe80::eef8:5973:baee:184c%12]) with mapi id 15.20.5986.023; Fri, 20 Jan 2023 00:52:18 +0000 From: Steve Clevenger To: mathieu.poirier@linaro.org, suzuki.poulose@arm.com Cc: mike.leach@linaro.org, leo.yan@linaro.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] coresight etm4x: Early clear TRCOSLAR.OSLK prior to TRCIDR1 read Date: Thu, 19 Jan 2023 17:51:54 -0700 Message-Id: <2e25b4a0366c9f792730897f2ab76cc045ce6403.1674174972.git.scclevenger@os.amperecomputing.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: CH2PR04CA0008.namprd04.prod.outlook.com (2603:10b6:610:52::18) To SN2PR01MB2143.prod.exchangelabs.com (2603:10b6:804:d::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN2PR01MB2143:EE_|SN6PR0102MB3407:EE_ X-MS-Office365-Filtering-Correlation-Id: ee7eb7be-0cd8-4c05-998b-08dafa809442 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CwKLrS7IO72myECCBZoqVFnfG+t9JSRYBz3rnIbZqGs1ATQ7s3vVQ1dvQnQevFqMTrLDop6aMS6UpHLYoKxsmSNdESCwRPpiOBXHSMyi5BUaf6MMrHL8DjzcjSnGr374jPVVkfxd2GOLdNaLe4+csFE+jFFCL0LyFbmrCEJUwiL/dkiWeMRbwqxdSSnsGCH9ZxGXzZ9u2GW/MYMlmfroBd+QwI8+eX0cuk/Sn2AV3pttFt4E+R8J4bknJjhyjYmSHcSGJBDi3Aeulr7NGf/XNJgE21h2NThpF9bbFJHbxoEodSYyDSLv247UrWsFAoGBHHcK20HkqTM4bhUm9XKWuGhbLhgLFRQ7Gh68wHvKnVQ5e/o/vO3RiQOaQfbxJ27dxUpY2HoFkC/euTfWhltd+SzS0RO0rIRuyR5BDqIsg1g1YSG768+l3PynGqrNNk3nffYEQwNeupF2KvYSf8eDIvM8WwORfyOX5L7+Nzhlb0ZPhr7oqC/M5Gblpk+sbjNMbgrNcCamt4yx1h/M1F5dG8jsakY0kImnE/g3zv2G5i1nytPDfBdYnXZ2edAZyXDvgRsp5ErbEGdfWJfqusc5gr7Amvi+b9RB7Sh5UrgvYlc03ykjs1Iin/bfTHvW6uvGbY1t0CRpbjfTMYzAa/6dcAdT6PswIuRsKxK+unRHwwTwVi3xQUVyvFt2jhM3fDXysUNE1jBrix7AEStSGRARqsaRfRe/Wobm4iwpF5rPdT3WsVovUijOuDMsYHJH7mFX X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN2PR01MB2143.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(366004)(39850400004)(376002)(396003)(136003)(451199015)(26005)(66946007)(186003)(478600001)(966005)(6506007)(6486002)(6512007)(6666004)(52116002)(8676002)(4326008)(66476007)(41300700001)(8936002)(316002)(2616005)(83380400001)(2906002)(66556008)(38100700002)(5660300002)(86362001)(38350700002)(32563001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1WIXQYJ99x1MyPHTVJvyy5Me+2jQ3hs8zoPBQIv8MObOXqPm7X5lxfU53E8lH9JWJJzOtAtPSIHDoiJ4xcfWWfRJdbezS/Cr74FLAIGGmtO5zmek0xaiP7QQ6Yuxhg5rRPaK3LzHzBRIh6qliD21j+jzJYw78ZZ3R+3ENFQIPGb6a06KzCpgR9OwzjsG87gXPaajY3KHVcONLPi3cEWHw4ez9Cj107GkMmsFTEc40vf4O/rpwVREfJzb3RW8jFfLoSSy2/CjPBvdC1opIOPPbtJtNBcB9MeM95Bk+Uqxd8t8myobnK4u3FAxFhnM1abupP9jiunYrd4KS3coNpu0mrbLYLcHF6yzf+owuFeoB7i5Ht6BkD0TO8inUrahHeow61POeml8R3qzOW6xnZ8cFaYF5AXpnukED5ZH2U/s82ymn1Hzhhj4Ci4i9l1jZy5Grk6MOCJ16sWRoF7uhDLgYUECeq5elT0wD1DUK05zK2UhEX0Nv9QuQHaOEP1d63ceo3dDI2bC8c0FWTn/dAF+eMzpDzEdAtetCxIAl34+3f/sG6x0SaQ64v3AkxqNFkXBynBdaCF7ZOHRtMOWfin4G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perecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee7eb7be-0cd8-4c05-998b-08dafa809442 X-MS-Exchange-CrossTenant-AuthSource: SN2PR01MB2143.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2023 00:52:17.9465 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kYkWkwiuY3W6RyapGdDI/2dkPuHz8pyIC8KL24xc4DMZP8fyeIoRxVNqZdgPA4qiNDqc/F5PsaXCt/gyZ9AsHNO4U6xLoH7gK4ICFue+dcGmZmQTCFHboLk3+sChwLbo X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR0102MB3407 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230119_165222_991065_627EE9FF X-CRM114-Status: GOOD ( 17.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add Ampere early clear of ETM TRCOSLAR.OSLK prior to TRCIDR1 access. Ampere Computing erratum AC03_DEBUG_06 describes an Ampere Computing design decision MMIO reads are considered the same as an external debug access. If TRCOSLAR.OSLK is set, the TRCIDR1 access results in a bus fault followed by a kernel panic. A TRCIDR1 read is valid regardless of TRCOSLAR.OSLK provided MMIO access (now deprecated) is supported. AC03_DEBUG_06 is described in the AmpereOne Developer Errata: https://solutions.amperecomputing.com/customer-connect/products/AmpereOne-device-documentation Add Ampere ETM PID required for Coresight ETM driver support. Signed-off-by: Steve Clevenger --- .../coresight/coresight-etm4x-core.c | 36 +++++++++++++++---- drivers/hwtracing/coresight/coresight-etm4x.h | 2 ++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index 1cc052979e01..533be1928a09 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -1091,19 +1091,34 @@ static void etm4_init_arch_data(void *info) drvdata = dev_get_drvdata(init_arg->dev); csa = init_arg->csa; + /* Detect the support for OS Lock before we actually use it */ + etm_detect_os_lock(drvdata, csa); + + /* + * For ETM implementations that consider MMIO an external access + * clear TRCOSLAR.OSLK early. + */ + if (drvdata->mmio_external) + etm4_os_unlock_csa(drvdata, csa); + /* * If we are unable to detect the access mechanism, * or unable to detect the trace unit type, fail - * early. + * early. Reset TRCOSLAR.OSLK if cleared. */ - if (!etm4_init_csdev_access(drvdata, csa)) + if (!etm4_init_csdev_access(drvdata, csa)) { + if (drvdata->mmio_external) + etm4_os_lock(drvdata); return; + } - /* Detect the support for OS Lock before we actually use it */ - etm_detect_os_lock(drvdata, csa); + /* + * Make sure all registers are accessible + * TRCOSLAR.OSLK may already be clear + */ + if (!drvdata->mmio_external) + etm4_os_unlock_csa(drvdata, csa); - /* Make sure all registers are accessible */ - etm4_os_unlock_csa(drvdata, csa); etm4_cs_unlock(drvdata, csa); etm4_check_arch_features(drvdata, init_arg->pid); @@ -2027,6 +2042,14 @@ static int etm4_probe(struct device *dev, void __iomem *base, u32 etm_pid) init_arg.csa = &access; init_arg.pid = etm_pid; + /* + * Ampere ETM v4.6 considers MMIO access as external. This mask + * isolates the manufacturer JEP106 ID in the PID. + * TRCPIDR2 (JEDC|DES_1) << 16 | TRCPIDR1 (DES_0) << 8) + */ + if ((init_arg.pid & 0x000FF000) == 0x00096000) + drvdata->mmio_external = true; + /* * Serialize against CPUHP callbacks to avoid race condition * between the smp call and saving the delayed probe. @@ -2192,6 +2215,7 @@ static const struct amba_id etm4_ids[] = { CS_AMBA_ID(0x000bb95e), /* Cortex-A57 */ CS_AMBA_ID(0x000bb95a), /* Cortex-A72 */ CS_AMBA_ID(0x000bb959), /* Cortex-A73 */ + CS_AMBA_UCI_ID(0x00096000, uci_id_etm4),/* Ampere ARMv8 */ CS_AMBA_UCI_ID(0x000bb9da, uci_id_etm4),/* Cortex-A35 */ CS_AMBA_UCI_ID(0x000bbd05, uci_id_etm4),/* Cortex-A55 */ CS_AMBA_UCI_ID(0x000bbd0a, uci_id_etm4),/* Cortex-A75 */ diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h index 4b21bb79f168..cf4f9f2e1807 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -1015,6 +1015,7 @@ struct etmv4_save_state { * @skip_power_up: Indicates if an implementation can skip powering up * the trace unit. * @arch_features: Bitmap of arch features of etmv4 devices. + * @mmio_external: True if ETM considers MMIO an external access. */ struct etmv4_drvdata { void __iomem *base; @@ -1067,6 +1068,7 @@ struct etmv4_drvdata { bool state_needs_restore; bool skip_power_up; DECLARE_BITMAP(arch_features, ETM4_IMPDEF_FEATURE_MAX); + bool mmio_external; }; /* Address comparator access types */