From patchwork Mon Mar 6 05:54:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Clevenger X-Patchwork-Id: 13160500 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 BCF05C61DA3 for ; Mon, 6 Mar 2023 05:55:58 +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=1v2DLPOpNl/FV6hjP4/9O3+JvQ8CYudDRHL4MFvnEGo=; b=WIuT7dExu1DEmY JyS7DtXzuEa8AIw7BrX6BXyHt7DJxzPsbTGg76Tupa7wEQO9OKF0uEFjoNsTfitLM1SCmR8ob3AE7 5s7ROQHsrVqbzcK5l4ESWzTCtKwoQfL6JBdXS9q5+BT4XiTjmAf54Dc2w0+IQO+ZBedxKCUE7KAGj F43AV595uHZVfhEN6B0kXG0rJihZaKsM0tCeB8W6nFAnXoHfQgxzsNzZ/iP8qNhQBcGtnKmej8QcB nXuQPtg57ESnJzYKH4bBEUFqXqFHsE2H2M67jI36vg/Eg/lRNpa1Wvoy4VIAB8RluO27xW6OprvCg oaSA3IRN7qzOojjunmAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZ3oE-00BR20-7f; Mon, 06 Mar 2023 05:54:54 +0000 Received: from mail-dm6nam11on2071f.outbound.protection.outlook.com ([2a01:111:f400:7eaa::71f] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZ3nw-00BQyF-Jy for linux-arm-kernel@lists.infradead.org; Mon, 06 Mar 2023 05:54:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xx7bUYPVk/Q5mYNsLU/NMaIRUAZSAtAX5jPFMJJwsmlcu4EJtn2exg3RPxdzTad0GXSxXerfUBuxB7ReWgTMuewxcC/dhYRpKm1N+sVK625o/ECvgMZj4r4an8SEvDAJ3/otTpQimJN76ciNMKDRFZZ/1QUPvirCf7w3BjYXhlp37NMcr+NntftQQxJKs9uTeyoGBuSsuguPf/FzVbd1XQNS4G8kcW56PfQrT28WfsNX1ZY7iSQEgksLV2ph+VYBQA4Vhl2WrJoUb6eibtA4Q8ni5O1FcKg4R+NSoeLRqkkzev3e+SxAlCTHGuPpBOJx7OvnFqU5AFvGqbE16uaJlw== 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=I6o5RPOu1t37Yj8xS5G6Fhj2Vd3z25AsPdZEegdsRgM=; b=MCxe/lmqtGtXqKmdNcVH4MT9yP/UgiF9DpcA2cAZgIJ9krsDIKHqNlup24iddd7p4Jzsx+czzb04ZQBUNFv5Dzznkvgvi2J45wxu3Pxf+3bsoILf7K0DfLzTiJm67JGG2JwFu2mxACROnZ0TPbOG2QaGstUNYodgues7c1tLWsXaQo7jHeQKRcD2HSgaMHyLx8QavIPT5DSazRVCOm33OiggBBEG3tUU2XziEAzdaGfwpJdulbJOSulvFaJygcKPGFyvZ9s/ThT5X3EWci9n6jsmRiXAKsfoB8zCWCPo61fU8EOYLVk3rH62KcS0juPA3NtMrFj+UsvOwherhlF9IQ== 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=I6o5RPOu1t37Yj8xS5G6Fhj2Vd3z25AsPdZEegdsRgM=; b=NBb61RuVnuLZD2n+FTACP5e+TT3g01hW0trwaq8kXXagPswpUUbQl0RLrMNpBbMpSV6y9qK6Ga07uekX6v8oZixg2K5/rVoSG0UxsdbhfuX3nznByg/m34wK/TdogSKNGuuFdCxhnVmq6OvNP4Chzgk/1SK1pMvvEkdPyam1hZw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SA1PR01MB8062.prod.exchangelabs.com (2603:10b6:806:335::13) by SA0PR01MB6460.prod.exchangelabs.com (2603:10b6:806:e1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.15; Mon, 6 Mar 2023 05:54:28 +0000 Received: from SA1PR01MB8062.prod.exchangelabs.com ([fe80::fb0b:d681:8228:bd50]) by SA1PR01MB8062.prod.exchangelabs.com ([fe80::fb0b:d681:8228:bd50%6]) with mapi id 15.20.6178.013; Mon, 6 Mar 2023 05:54:28 +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 2/3] coresight etm4x: Early clear TRCOSLAR.OSLK prior to TRCIDR1 read Date: Sun, 5 Mar 2023 22:54:07 -0700 Message-Id: <143540e5623d4c7393d24833f2b80600d8d745d2.1677881753.git.scclevenger@os.amperecomputing.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: CH2PR12CA0003.namprd12.prod.outlook.com (2603:10b6:610:57::13) To SA1PR01MB8062.prod.exchangelabs.com (2603:10b6:806:335::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR01MB8062:EE_|SA0PR01MB6460:EE_ X-MS-Office365-Filtering-Correlation-Id: 96671d58-d628-43f2-34de-08db1e073f88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Lpgv6W4cGeL/8+9UffPZAWcBMZ0WSl2I2w5pOG1w39tI7Y3vIZA0JVhfSX26FPvTR7vBGxs6JdPo2RI0LBkRk1dYtOI22lFGdZ9dXzRxI2IahY324M3x2Jj3YRbHwJYKOQlBHbMdy0Dzj4oF4C4VZthwskB8jlQY+t2nYPwqiBnwFxUvvEvaVtoh1wp1jnwWUnMEEucvQVeG8byaadNhRQup6U8M8aDyBosIJwsrZmCJGZ5dCVNb8xcfPugKDrT8/Zv5TweocVsZ9vBdCFhxGqYbI/sHtriHuQZZXVnGCgpCNce/etiZGqf265ca5T7rrGI0YPmuJwshhUW9o22h/ah+d1AHvTac0ZC4fD0MHwCm56VRlh975VBhVdcS9o+UEK/X1nkAV3HtJcBrYyD5UPsHNPMjBrOqs/KIfOYi2LlOy89IYWTpgLgb1+PsOW+iEs7cQm+/CMRl9uR7MK1VxT/HR/gWufEv95Q54UHsCUFj7Q653UA2oFK/LEoaKccEzIGXRNgcZSsIG/V823Wy396jHLJAvbeOxuK3Z/xpuZEgdk2jOvvi/ZmAlYADqn3WGWTwAcgfmVQ6Xlq2yohb95EkN2R/IhWPgXQU1eBAhmzWdYzuMZ25yS52MJ93bCmsXmJWedXJng5r47QfD5RkMyHqKnSrE6LoSWp5wMAAa9HYT9jOaQxgWERNWTNQw8Jd1lcRj1yJ3iehtGp+T0b8Lg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR01MB8062.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(136003)(396003)(366004)(346002)(39850400004)(376002)(451199018)(6512007)(6506007)(6486002)(966005)(6666004)(83380400001)(86362001)(38100700002)(38350700002)(186003)(26005)(2616005)(41300700001)(66476007)(66946007)(66556008)(4326008)(8676002)(2906002)(8936002)(5660300002)(478600001)(52116002)(316002)(32563001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w6BTyMZlkYGqRscha3JJls14I1KO97BOvb+ds02n/pQLOXcUiVde+/cutB+CTe3yN7xvQ6/3mRdmCmVHhy1H6YRQVp7EpXy9pRSMd7lc7SLabksesP0NBTKbwi12rQiW//OHyV3KQF0Z+4aNHC8Ng9/Cm1NAnZKqWFw1W0F1p3TRAFHxkoaXoWZ0SDZjQBPLA5BeHfLjw+KFWB/3e5vofyUYLpQBGJa8QnFQbnPZkhD57w8J2WRll5BEVxapPLukJ9UK8nehhWfFfwAmkR+dz8AfHEZbb8idAWJMqQDWarnT4VzDMHzC2Uiirt+1ywOd4/zj0VesmL1zujrxNl6JB2ATZVW9pbqlXstDTlVHST28bUc+Ind0slOSPW+Fa5SiSiVIBnS3yl8jhBTh4N50zfIKZKHG30Ub+RgaCoiE4trDbtLz/ZIv01wZaTS5kdlOnYWlAIocJzmA/gP3JBEA2565a1geOsJZ5Gb6iDIvSGHB6CJkdpr/5jHL7hKmSxBjUAPfT73xIouGMHgrINXPOtuDeAUPnfesizwH8ZigIQ/SKqvMdkCwSPbeoyASP9jywQuKtn2/JViMR/WNcE9hGEdyTrHVjgAx9bLX/db6Y/PCTyecC+P0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ecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96671d58-d628-43f2-34de-08db1e073f88 X-MS-Exchange-CrossTenant-AuthSource: SA1PR01MB8062.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 05:54:28.3802 (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: NqtMFMH2JqxYO+u4/Mg4t1BPi4MN0N/xm+E7a6tEg/shxsRug0n5sJfGQnp57gWqKIc5aqrfBc5v1Uz5XMHDesPqqLC1/IUjt4f0ZEKjEoN/01GLoshpONyJPw/TgLMm X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR01MB6460 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230305_215436_750524_9A864BA2 X-CRM114-Status: GOOD ( 20.74 ) 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 An Ampere Computing design decision is MMIO reads are considered the same as an external debug access. If TRCOSLAR.OSLK is left set, the TRCIDR1 access results in a bus fault followed by a kernel panic. A TRCIDR1 read should be valid regardless of TRCOSLAR.OSLK provided MMIO access (now deprecated) is supported. The Ampere work around is to early clear ETM TRCOSLAR.OSLK prior to TRCIDR1 access. Do not distinguish between manufacturers. AC03_DEBUG_06 is described in the AmpereOne Developer Errata: Add Ampere ETM PID required for Coresight ETM driver support. https://solutions.amperecomputing.com/customer-connect/products/AmpereOne-device-documentation Signed-off-by: Steve Clevenger --- .../coresight/coresight-etm4x-core.c | 50 ++++++++++++++----- include/linux/coresight.h | 3 ++ 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index 104333c2c8a3..6f7a14c4c78c 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -1047,6 +1047,7 @@ static bool etm4_init_sysreg_access(struct etmv4_drvdata *drvdata, case ETM_DEVARCH_ETMv4x_ARCH: *csa = (struct csdev_access) { .io_mem = false, + .no_quad_mmio = false, .read = etm4x_sysreg_read, .write = etm4x_sysreg_write, }; @@ -1054,6 +1055,7 @@ static bool etm4_init_sysreg_access(struct etmv4_drvdata *drvdata, case ETM_DEVARCH_ETE_ARCH: *csa = (struct csdev_access) { .io_mem = false, + .no_quad_mmio = false, .read = ete_sysreg_read, .write = ete_sysreg_write, }; @@ -1069,8 +1071,20 @@ static bool etm4_init_sysreg_access(struct etmv4_drvdata *drvdata, static bool etm4_init_iomem_access(struct etmv4_drvdata *drvdata, struct csdev_access *csa) { - u32 devarch = readl_relaxed(drvdata->base + TRCDEVARCH); - u32 idr1 = readl_relaxed(drvdata->base + TRCIDR1); + u32 devarch; + u32 idr1; + + /* Detect the support for OS Lock before we actually use it */ + etm_detect_os_lock(drvdata, csa); + + /* + * An ETM implementation may consider memory mapped I/O + * an external debug access so clear TRCOSLAR.OSLK early. + */ + etm4_os_unlock_csa(drvdata, csa); + + devarch = readl_relaxed(drvdata->base + TRCDEVARCH); + idr1 = readl_relaxed(drvdata->base + TRCIDR1); /* * All ETMs must implement TRCDEVARCH to indicate that @@ -1089,7 +1103,10 @@ static bool etm4_init_iomem_access(struct etmv4_drvdata *drvdata, drvdata->arch = etm_trcidr_to_arch(idr1); } - *csa = CSDEV_ACCESS_IOMEM(drvdata->base); + /* preserve pre-initialized fields */ + csa->io_mem = true; + csa->base = drvdata->base; + return true; } @@ -1151,18 +1168,13 @@ static void etm4_init_arch_data(void *info) csa = init_arg->csa; /* - * If we are unable to detect the access mechanism, - * or unable to detect the trace unit type, fail - * early. + * Make sure all registers are accessible. If we are unable + * to detect the access mechanism, or unable to detect the + * trace unit type, fail early. */ - if (!etm4_init_csdev_access(drvdata, csa)) - return; - - /* Detect the support for OS Lock before we actually use it */ - etm_detect_os_lock(drvdata, csa); + if (!etm4_init_csdev_access(drvdata, csa)) + return; - /* 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); @@ -2084,6 +2096,17 @@ 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 does not suport 64-bit MMIO access. + * This mask isolates the manufacturer JEP106 ID in the PID. + * TRCPIDR2 (JEDC|DES_1) << 16 | TRCPIDR1 (DES_0) << 8). + * Ampere does not currently use the implementation defined + * TRCIDR0 PART_0 and/or TRCIDR1 PART_1 fields to further + * describe the ETMv4 parts. + */ + if ((init_arg.pid & 0x000FF000) == 0x00096000) + init_arg.csa->no_quad_mmio = true; + /* * Serialize against CPUHP callbacks to avoid race condition * between the smp call and saving the delayed probe. @@ -2249,6 +2272,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/include/linux/coresight.h b/include/linux/coresight.h index f19a47b9bb5a..285d7aad6ef4 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -116,12 +116,14 @@ struct coresight_platform_data { * struct csdev_access - Abstraction of a CoreSight device access. * * @io_mem : True if the device has memory mapped I/O + * @no_quad_mmio: True if 64-bit register access is not suported * @base : When io_mem == true, base address of the component * @read : Read from the given "offset" of the given instance. * @write : Write "val" to the given "offset". */ struct csdev_access { bool io_mem; + bool no_quad_mmio; union { void __iomem *base; struct { @@ -135,6 +137,7 @@ struct csdev_access { #define CSDEV_ACCESS_IOMEM(_addr) \ ((struct csdev_access) { \ .io_mem = true, \ + .no_quad_mmio = false, \ .base = (_addr), \ })